blob: f635d7a542b8eed9b23756a69ace7c9a5205d365 [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]>;
Dale Johannesen51c58ee2008-10-03 22:25:52 +0000102def X86AtomSwap64 : SDNode<"X86ISD::ATOMSWAP64_DAG", SDTX86atomicBinary,
103 [SDNPHasChain, SDNPMayStore,
104 SDNPMayLoad, SDNPMemOperand]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000105def X86retflag : SDNode<"X86ISD::RET_FLAG", SDTX86Ret,
106 [SDNPHasChain, SDNPOptInFlag]>;
107
108def X86callseq_start :
109 SDNode<"ISD::CALLSEQ_START", SDT_X86CallSeqStart,
110 [SDNPHasChain, SDNPOutFlag]>;
111def X86callseq_end :
112 SDNode<"ISD::CALLSEQ_END", SDT_X86CallSeqEnd,
Arnold Schwaighofere2d6bbb2007-10-11 19:40:01 +0000113 [SDNPHasChain, SDNPOptInFlag, SDNPOutFlag]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000114
115def X86call : SDNode<"X86ISD::CALL", SDT_X86Call,
116 [SDNPHasChain, SDNPOutFlag, SDNPOptInFlag]>;
117
118def X86tailcall: SDNode<"X86ISD::TAILCALL", SDT_X86Call,
119 [SDNPHasChain, SDNPOutFlag, SDNPOptInFlag]>;
120
121def X86rep_stos: SDNode<"X86ISD::REP_STOS", SDTX86RepStr,
Chris Lattnerca4e0fe2008-01-10 05:12:37 +0000122 [SDNPHasChain, SDNPInFlag, SDNPOutFlag, SDNPMayStore]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000123def X86rep_movs: SDNode<"X86ISD::REP_MOVS", SDTX86RepStr,
Chris Lattnerca4e0fe2008-01-10 05:12:37 +0000124 [SDNPHasChain, SDNPInFlag, SDNPOutFlag, SDNPMayStore,
125 SDNPMayLoad]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000126
127def X86rdtsc : SDNode<"X86ISD::RDTSC_DAG",SDTX86RdTsc,
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000128 [SDNPHasChain, SDNPOutFlag, SDNPSideEffect]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000129
130def X86Wrapper : SDNode<"X86ISD::Wrapper", SDTX86Wrapper>;
131def X86WrapperRIP : SDNode<"X86ISD::WrapperRIP", SDTX86Wrapper>;
132
133def X86tlsaddr : SDNode<"X86ISD::TLSADDR", SDT_X86TLSADDR,
Anton Korobeynikov4fbf00b2008-05-04 21:36:32 +0000134 [SDNPHasChain, SDNPOptInFlag, SDNPOutFlag]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000135def X86TLStp : SDNode<"X86ISD::THREAD_POINTER", SDT_X86TLSTP, []>;
136
137def X86ehret : SDNode<"X86ISD::EH_RETURN", SDT_X86EHRET,
138 [SDNPHasChain]>;
139
Arnold Schwaighofere2d6bbb2007-10-11 19:40:01 +0000140def X86tcret : SDNode<"X86ISD::TC_RETURN", SDT_X86TCRET,
141 [SDNPHasChain, SDNPOptInFlag]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000142
143//===----------------------------------------------------------------------===//
144// X86 Operand Definitions.
145//
146
147// *mem - Operand definitions for the funky X86 addressing mode operands.
148//
149class X86MemOperand<string printMethod> : Operand<iPTR> {
150 let PrintMethod = printMethod;
151 let MIOperandInfo = (ops ptr_rc, i8imm, ptr_rc, i32imm);
152}
153
154def i8mem : X86MemOperand<"printi8mem">;
155def i16mem : X86MemOperand<"printi16mem">;
156def i32mem : X86MemOperand<"printi32mem">;
157def i64mem : X86MemOperand<"printi64mem">;
158def i128mem : X86MemOperand<"printi128mem">;
159def f32mem : X86MemOperand<"printf32mem">;
160def f64mem : X86MemOperand<"printf64mem">;
Dale Johannesen4ab00bd2007-08-05 18:49:15 +0000161def f80mem : X86MemOperand<"printf80mem">;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000162def f128mem : X86MemOperand<"printf128mem">;
163
164def lea32mem : Operand<i32> {
165 let PrintMethod = "printi32mem";
166 let MIOperandInfo = (ops GR32, i8imm, GR32, i32imm);
167}
168
169def SSECC : Operand<i8> {
170 let PrintMethod = "printSSECC";
171}
172
173def piclabel: Operand<i32> {
174 let PrintMethod = "printPICLabel";
175}
176
177// A couple of more descriptive operand definitions.
178// 16-bits but only 8 bits are significant.
179def i16i8imm : Operand<i16>;
180// 32-bits but only 8 bits are significant.
181def i32i8imm : Operand<i32>;
182
183// Branch targets have OtherVT type.
184def brtarget : Operand<OtherVT>;
185
186//===----------------------------------------------------------------------===//
187// X86 Complex Pattern Definitions.
188//
189
190// Define X86 specific addressing mode.
191def addr : ComplexPattern<iPTR, 4, "SelectAddr", [], []>;
192def lea32addr : ComplexPattern<i32, 4, "SelectLEAAddr",
193 [add, mul, shl, or, frameindex], []>;
194
195//===----------------------------------------------------------------------===//
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000196// X86 Instruction Predicate Definitions.
197def HasMMX : Predicate<"Subtarget->hasMMX()">;
198def HasSSE1 : Predicate<"Subtarget->hasSSE1()">;
199def HasSSE2 : Predicate<"Subtarget->hasSSE2()">;
200def HasSSE3 : Predicate<"Subtarget->hasSSE3()">;
201def HasSSSE3 : Predicate<"Subtarget->hasSSSE3()">;
Nate Begemanb2975562008-02-03 07:18:54 +0000202def HasSSE41 : Predicate<"Subtarget->hasSSE41()">;
203def HasSSE42 : Predicate<"Subtarget->hasSSE42()">;
Dale Johannesene0e0fd02007-09-23 14:52:20 +0000204def FPStackf32 : Predicate<"!Subtarget->hasSSE1()">;
205def FPStackf64 : Predicate<"!Subtarget->hasSSE2()">;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000206def In32BitMode : Predicate<"!Subtarget->is64Bit()">;
207def In64BitMode : Predicate<"Subtarget->is64Bit()">;
208def SmallCode : Predicate<"TM.getCodeModel() == CodeModel::Small">;
209def NotSmallCode : Predicate<"TM.getCodeModel() != CodeModel::Small">;
210def IsStatic : Predicate<"TM.getRelocationModel() == Reloc::Static">;
Evan Cheng13559d62008-09-26 23:41:32 +0000211def OptForSpeed : Predicate<"!OptForSize">;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000212
213//===----------------------------------------------------------------------===//
Evan Cheng86ab7d32007-07-31 08:04:03 +0000214// X86 Instruction Format Definitions.
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000215//
216
Evan Cheng86ab7d32007-07-31 08:04:03 +0000217include "X86InstrFormats.td"
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000218
219//===----------------------------------------------------------------------===//
220// Pattern fragments...
221//
222
223// X86 specific condition code. These correspond to CondCode in
224// X86InstrInfo.h. They must be kept in synch.
225def X86_COND_A : PatLeaf<(i8 0)>;
226def X86_COND_AE : PatLeaf<(i8 1)>;
227def X86_COND_B : PatLeaf<(i8 2)>;
228def X86_COND_BE : PatLeaf<(i8 3)>;
229def X86_COND_E : PatLeaf<(i8 4)>;
230def X86_COND_G : PatLeaf<(i8 5)>;
231def X86_COND_GE : PatLeaf<(i8 6)>;
232def X86_COND_L : PatLeaf<(i8 7)>;
233def X86_COND_LE : PatLeaf<(i8 8)>;
234def X86_COND_NE : PatLeaf<(i8 9)>;
235def X86_COND_NO : PatLeaf<(i8 10)>;
236def X86_COND_NP : PatLeaf<(i8 11)>;
237def X86_COND_NS : PatLeaf<(i8 12)>;
238def X86_COND_O : PatLeaf<(i8 13)>;
239def X86_COND_P : PatLeaf<(i8 14)>;
240def X86_COND_S : PatLeaf<(i8 15)>;
241
242def i16immSExt8 : PatLeaf<(i16 imm), [{
243 // i16immSExt8 predicate - True if the 16-bit immediate fits in a 8-bit
244 // sign extended field.
Dan Gohmanfaeb4a32008-09-12 16:56:44 +0000245 return (int16_t)N->getZExtValue() == (int8_t)N->getZExtValue();
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000246}]>;
247
248def i32immSExt8 : PatLeaf<(i32 imm), [{
249 // i32immSExt8 predicate - True if the 32-bit immediate fits in a 8-bit
250 // sign extended field.
Dan Gohmanfaeb4a32008-09-12 16:56:44 +0000251 return (int32_t)N->getZExtValue() == (int8_t)N->getZExtValue();
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000252}]>;
253
254// Helper fragments for loads.
Evan Chengb3e25ea2008-05-13 18:59:59 +0000255// It's always safe to treat a anyext i16 load as a i32 load if the i16 is
256// known to be 32-bit aligned or better. Ditto for i8 to i16.
Evan Cheng8b765e92008-05-13 00:54:02 +0000257def loadi16 : PatFrag<(ops node:$ptr), (i16 (ld node:$ptr)), [{
Dan Gohman8335c412008-08-20 15:24:22 +0000258 LoadSDNode *LD = cast<LoadSDNode>(N);
259 if (LD->getAddressingMode() != ISD::UNINDEXED)
260 return false;
261 ISD::LoadExtType ExtType = LD->getExtensionType();
262 if (ExtType == ISD::NON_EXTLOAD)
263 return true;
264 if (ExtType == ISD::EXTLOAD)
265 return LD->getAlignment() >= 2 && !LD->isVolatile();
Evan Cheng8b765e92008-05-13 00:54:02 +0000266 return false;
267}]>;
268
Evan Cheng56ec77b2008-09-24 23:27:55 +0000269def loadi16_anyext : PatFrag<(ops node:$ptr), (i32 (ld node:$ptr)), [{
270 LoadSDNode *LD = cast<LoadSDNode>(N);
271 if (LD->getAddressingMode() != ISD::UNINDEXED)
272 return false;
273 ISD::LoadExtType ExtType = LD->getExtensionType();
274 if (ExtType == ISD::EXTLOAD)
275 return LD->getAlignment() >= 2 && !LD->isVolatile();
276 return false;
277}]>;
278
Evan Cheng8b765e92008-05-13 00:54:02 +0000279def loadi32 : PatFrag<(ops node:$ptr), (i32 (ld node:$ptr)), [{
Dan Gohman8335c412008-08-20 15:24:22 +0000280 LoadSDNode *LD = cast<LoadSDNode>(N);
281 if (LD->getAddressingMode() != ISD::UNINDEXED)
282 return false;
283 ISD::LoadExtType ExtType = LD->getExtensionType();
284 if (ExtType == ISD::NON_EXTLOAD)
285 return true;
286 if (ExtType == ISD::EXTLOAD)
287 return LD->getAlignment() >= 4 && !LD->isVolatile();
Evan Cheng8b765e92008-05-13 00:54:02 +0000288 return false;
289}]>;
290
Evan Cheng1e5e5452008-09-29 17:26:18 +0000291def nvloadi32 : PatFrag<(ops node:$ptr), (i32 (ld node:$ptr)), [{
292 LoadSDNode *LD = cast<LoadSDNode>(N);
293 if (LD->isVolatile())
294 return false;
295 if (LD->getAddressingMode() != ISD::UNINDEXED)
296 return false;
297 ISD::LoadExtType ExtType = LD->getExtensionType();
298 if (ExtType == ISD::NON_EXTLOAD)
299 return true;
300 if (ExtType == ISD::EXTLOAD)
301 return LD->getAlignment() >= 4;
302 return false;
303}]>;
304
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000305def loadi8 : PatFrag<(ops node:$ptr), (i8 (load node:$ptr))>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000306def loadi64 : PatFrag<(ops node:$ptr), (i64 (load node:$ptr))>;
307
308def loadf32 : PatFrag<(ops node:$ptr), (f32 (load node:$ptr))>;
309def loadf64 : PatFrag<(ops node:$ptr), (f64 (load node:$ptr))>;
Dale Johannesen4ab00bd2007-08-05 18:49:15 +0000310def loadf80 : PatFrag<(ops node:$ptr), (f80 (load node:$ptr))>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000311
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000312def sextloadi16i8 : PatFrag<(ops node:$ptr), (i16 (sextloadi8 node:$ptr))>;
313def sextloadi32i8 : PatFrag<(ops node:$ptr), (i32 (sextloadi8 node:$ptr))>;
314def sextloadi32i16 : PatFrag<(ops node:$ptr), (i32 (sextloadi16 node:$ptr))>;
315
316def zextloadi8i1 : PatFrag<(ops node:$ptr), (i8 (zextloadi1 node:$ptr))>;
317def zextloadi16i1 : PatFrag<(ops node:$ptr), (i16 (zextloadi1 node:$ptr))>;
318def zextloadi32i1 : PatFrag<(ops node:$ptr), (i32 (zextloadi1 node:$ptr))>;
319def zextloadi16i8 : PatFrag<(ops node:$ptr), (i16 (zextloadi8 node:$ptr))>;
320def zextloadi32i8 : PatFrag<(ops node:$ptr), (i32 (zextloadi8 node:$ptr))>;
321def zextloadi32i16 : PatFrag<(ops node:$ptr), (i32 (zextloadi16 node:$ptr))>;
322
323def extloadi8i1 : PatFrag<(ops node:$ptr), (i8 (extloadi1 node:$ptr))>;
324def extloadi16i1 : PatFrag<(ops node:$ptr), (i16 (extloadi1 node:$ptr))>;
325def extloadi32i1 : PatFrag<(ops node:$ptr), (i32 (extloadi1 node:$ptr))>;
326def extloadi16i8 : PatFrag<(ops node:$ptr), (i16 (extloadi8 node:$ptr))>;
327def extloadi32i8 : PatFrag<(ops node:$ptr), (i32 (extloadi8 node:$ptr))>;
328def extloadi32i16 : PatFrag<(ops node:$ptr), (i32 (extloadi16 node:$ptr))>;
329
Chris Lattner21da6382008-02-19 17:37:35 +0000330
331// An 'and' node with a single use.
332def and_su : PatFrag<(ops node:$lhs, node:$rhs), (and node:$lhs, node:$rhs), [{
Evan Cheng9123cfa2008-03-04 00:40:35 +0000333 return N->hasOneUse();
Chris Lattner21da6382008-02-19 17:37:35 +0000334}]>;
335
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000336//===----------------------------------------------------------------------===//
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000337// Instruction list...
338//
339
340// ADJCALLSTACKDOWN/UP implicitly use/def ESP because they may be expanded into
341// a stack adjustment and the codegen must know that they may modify the stack
342// pointer before prolog-epilog rewriting occurs.
Chris Lattnerb56cc342008-03-11 03:23:40 +0000343// Pessimistically assume ADJCALLSTACKDOWN / ADJCALLSTACKUP will become
344// sub / add which can clobber EFLAGS.
Evan Cheng037364a2007-09-28 01:19:48 +0000345let Defs = [ESP, EFLAGS], Uses = [ESP] in {
Dan Gohman01c9f772008-10-01 18:28:06 +0000346def ADJCALLSTACKDOWN32 : I<0, Pseudo, (outs), (ins i32imm:$amt),
347 "#ADJCALLSTACKDOWN",
348 [(X86callseq_start imm:$amt)]>,
349 Requires<[In32BitMode]>;
350def ADJCALLSTACKUP32 : I<0, Pseudo, (outs), (ins i32imm:$amt1, i32imm:$amt2),
351 "#ADJCALLSTACKUP",
352 [(X86callseq_end imm:$amt1, imm:$amt2)]>,
353 Requires<[In32BitMode]>;
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000354}
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000355
356// Nop
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000357let neverHasSideEffects = 1 in
358 def NOOP : I<0x90, RawFrm, (outs), (ins), "nop", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000359
Evan Cheng0729ccf2008-01-05 00:41:47 +0000360// PIC base
Dan Gohman9499cfe2008-10-01 04:14:30 +0000361let neverHasSideEffects = 1, isNotDuplicable = 1, Uses = [ESP] in
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000362 def MOVPC32r : Ii32<0xE8, Pseudo, (outs GR32:$reg), (ins piclabel:$label),
363 "call\t$label\n\tpop{l}\t$reg", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000364
365//===----------------------------------------------------------------------===//
366// Control Flow Instructions...
367//
368
369// Return instructions.
370let isTerminator = 1, isReturn = 1, isBarrier = 1,
Chris Lattnerb56cc342008-03-11 03:23:40 +0000371 hasCtrlDep = 1, FPForm = SpecialFP, FPFormBits = SpecialFP.Value in {
Dan Gohman2c4be2a2008-05-31 02:11:25 +0000372 def RET : I <0xC3, RawFrm, (outs), (ins variable_ops),
Chris Lattnerb56cc342008-03-11 03:23:40 +0000373 "ret",
Dan Gohman2c4be2a2008-05-31 02:11:25 +0000374 [(X86retflag 0)]>;
Chris Lattnerb56cc342008-03-11 03:23:40 +0000375 def RETI : Ii16<0xC2, RawFrm, (outs), (ins i16imm:$amt, variable_ops),
376 "ret\t$amt",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000377 [(X86retflag imm:$amt)]>;
378}
379
380// All branches are RawFrm, Void, Branch, and Terminators
Evan Cheng37e7c752007-07-21 00:34:19 +0000381let isBranch = 1, isTerminator = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +0000382 class IBr<bits<8> opcode, dag ins, string asm, list<dag> pattern> :
383 I<opcode, RawFrm, (outs), ins, asm, pattern>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000384
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000385let isBranch = 1, isBarrier = 1 in
Dan Gohman91888f02007-07-31 20:11:57 +0000386 def JMP : IBr<0xE9, (ins brtarget:$dst), "jmp\t$dst", [(br bb:$dst)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000387
Owen Andersonf8053082007-11-12 07:39:39 +0000388// Indirect branches
389let isBranch = 1, isTerminator = 1, isBarrier = 1, isIndirectBranch = 1 in {
Dan Gohman91888f02007-07-31 20:11:57 +0000390 def JMP32r : I<0xFF, MRM4r, (outs), (ins GR32:$dst), "jmp{l}\t{*}$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000391 [(brind GR32:$dst)]>;
Dan Gohman91888f02007-07-31 20:11:57 +0000392 def JMP32m : I<0xFF, MRM4m, (outs), (ins i32mem:$dst), "jmp{l}\t{*}$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000393 [(brind (loadi32 addr:$dst))]>;
394}
395
396// Conditional branches
Evan Cheng950aac02007-09-25 01:57:46 +0000397let Uses = [EFLAGS] in {
Dan Gohman91888f02007-07-31 20:11:57 +0000398def JE : IBr<0x84, (ins brtarget:$dst), "je\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000399 [(X86brcond bb:$dst, X86_COND_E, EFLAGS)]>, TB;
Dan Gohman91888f02007-07-31 20:11:57 +0000400def JNE : IBr<0x85, (ins brtarget:$dst), "jne\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000401 [(X86brcond bb:$dst, X86_COND_NE, EFLAGS)]>, TB;
Dan Gohman91888f02007-07-31 20:11:57 +0000402def JL : IBr<0x8C, (ins brtarget:$dst), "jl\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000403 [(X86brcond bb:$dst, X86_COND_L, EFLAGS)]>, TB;
Dan Gohman91888f02007-07-31 20:11:57 +0000404def JLE : IBr<0x8E, (ins brtarget:$dst), "jle\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000405 [(X86brcond bb:$dst, X86_COND_LE, EFLAGS)]>, TB;
Dan Gohman91888f02007-07-31 20:11:57 +0000406def JG : IBr<0x8F, (ins brtarget:$dst), "jg\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000407 [(X86brcond bb:$dst, X86_COND_G, EFLAGS)]>, TB;
Dan Gohman91888f02007-07-31 20:11:57 +0000408def JGE : IBr<0x8D, (ins brtarget:$dst), "jge\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000409 [(X86brcond bb:$dst, X86_COND_GE, EFLAGS)]>, TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000410
Dan Gohman91888f02007-07-31 20:11:57 +0000411def JB : IBr<0x82, (ins brtarget:$dst), "jb\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000412 [(X86brcond bb:$dst, X86_COND_B, EFLAGS)]>, TB;
Dan Gohman91888f02007-07-31 20:11:57 +0000413def JBE : IBr<0x86, (ins brtarget:$dst), "jbe\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000414 [(X86brcond bb:$dst, X86_COND_BE, EFLAGS)]>, TB;
Dan Gohman91888f02007-07-31 20:11:57 +0000415def JA : IBr<0x87, (ins brtarget:$dst), "ja\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000416 [(X86brcond bb:$dst, X86_COND_A, EFLAGS)]>, TB;
Dan Gohman91888f02007-07-31 20:11:57 +0000417def JAE : IBr<0x83, (ins brtarget:$dst), "jae\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000418 [(X86brcond bb:$dst, X86_COND_AE, EFLAGS)]>, TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000419
Dan Gohman91888f02007-07-31 20:11:57 +0000420def JS : IBr<0x88, (ins brtarget:$dst), "js\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000421 [(X86brcond bb:$dst, X86_COND_S, EFLAGS)]>, TB;
Dan Gohman91888f02007-07-31 20:11:57 +0000422def JNS : IBr<0x89, (ins brtarget:$dst), "jns\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000423 [(X86brcond bb:$dst, X86_COND_NS, EFLAGS)]>, TB;
Dan Gohman91888f02007-07-31 20:11:57 +0000424def JP : IBr<0x8A, (ins brtarget:$dst), "jp\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000425 [(X86brcond bb:$dst, X86_COND_P, EFLAGS)]>, TB;
Dan Gohman91888f02007-07-31 20:11:57 +0000426def JNP : IBr<0x8B, (ins brtarget:$dst), "jnp\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000427 [(X86brcond bb:$dst, X86_COND_NP, EFLAGS)]>, TB;
Dan Gohman91888f02007-07-31 20:11:57 +0000428def JO : IBr<0x80, (ins brtarget:$dst), "jo\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000429 [(X86brcond bb:$dst, X86_COND_O, EFLAGS)]>, TB;
Dan Gohman91888f02007-07-31 20:11:57 +0000430def JNO : IBr<0x81, (ins brtarget:$dst), "jno\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000431 [(X86brcond bb:$dst, X86_COND_NO, EFLAGS)]>, TB;
Evan Cheng950aac02007-09-25 01:57:46 +0000432} // Uses = [EFLAGS]
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000433
434//===----------------------------------------------------------------------===//
435// Call Instructions...
436//
Evan Cheng37e7c752007-07-21 00:34:19 +0000437let isCall = 1 in
Dan Gohman01c9f772008-10-01 18:28:06 +0000438 // All calls clobber the non-callee saved registers. ESP is marked as
439 // a use to prevent stack-pointer assignments that appear immediately
440 // before calls from potentially appearing dead. Uses for argument
441 // registers are added manually.
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000442 let Defs = [EAX, ECX, EDX, FP0, FP1, FP2, FP3, FP4, FP5, FP6, ST0,
443 MM0, MM1, MM2, MM3, MM4, MM5, MM6, MM7,
Dan Gohman9499cfe2008-10-01 04:14:30 +0000444 XMM0, XMM1, XMM2, XMM3, XMM4, XMM5, XMM6, XMM7, EFLAGS],
445 Uses = [ESP] in {
Evan Cheng34f93712007-12-22 02:26:46 +0000446 def CALLpcrel32 : Ii32<0xE8, RawFrm, (outs), (ins i32imm:$dst,variable_ops),
447 "call\t${dst:call}", []>;
Evan Chengb783fa32007-07-19 01:14:50 +0000448 def CALL32r : I<0xFF, MRM2r, (outs), (ins GR32:$dst, variable_ops),
Dan Gohman91888f02007-07-31 20:11:57 +0000449 "call\t{*}$dst", [(X86call GR32:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000450 def CALL32m : I<0xFF, MRM2m, (outs), (ins i32mem:$dst, variable_ops),
Dan Gohmanea4faba2008-05-29 21:50:34 +0000451 "call\t{*}$dst", [(X86call (loadi32 addr:$dst))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000452 }
453
454// Tail call stuff.
Arnold Schwaighofere2d6bbb2007-10-11 19:40:01 +0000455
Chris Lattnerb56cc342008-03-11 03:23:40 +0000456def TAILCALL : I<0, Pseudo, (outs), (ins),
Arnold Schwaighofere2d6bbb2007-10-11 19:40:01 +0000457 "#TAILCALL",
458 []>;
459
Evan Cheng37e7c752007-07-21 00:34:19 +0000460let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1 in
Arnold Schwaighofer6fd37ac2008-03-19 16:39:45 +0000461def TCRETURNdi : I<0, Pseudo, (outs), (ins i32imm:$dst, i32imm:$offset, variable_ops),
Arnold Schwaighofere2d6bbb2007-10-11 19:40:01 +0000462 "#TC_RETURN $dst $offset",
463 []>;
464
465let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1 in
Arnold Schwaighofer6fd37ac2008-03-19 16:39:45 +0000466def TCRETURNri : I<0, Pseudo, (outs), (ins GR32:$dst, i32imm:$offset, variable_ops),
Arnold Schwaighofere2d6bbb2007-10-11 19:40:01 +0000467 "#TC_RETURN $dst $offset",
468 []>;
469
470let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1 in
Arnold Schwaighofera0032722008-04-30 09:16:33 +0000471
Arnold Schwaighofere2d6bbb2007-10-11 19:40:01 +0000472 def TAILJMPd : IBr<0xE9, (ins i32imm:$dst), "jmp\t${dst:call} # TAILCALL",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000473 []>;
Evan Cheng37e7c752007-07-21 00:34:19 +0000474let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1 in
Arnold Schwaighofere2d6bbb2007-10-11 19:40:01 +0000475 def TAILJMPr : I<0xFF, MRM4r, (outs), (ins GR32:$dst), "jmp{l}\t{*}$dst # TAILCALL",
476 []>;
Evan Cheng37e7c752007-07-21 00:34:19 +0000477let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +0000478 def TAILJMPm : I<0xFF, MRM4m, (outs), (ins i32mem:$dst),
Arnold Schwaighofere2d6bbb2007-10-11 19:40:01 +0000479 "jmp\t{*}$dst # TAILCALL", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000480
481//===----------------------------------------------------------------------===//
482// Miscellaneous Instructions...
483//
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000484let Defs = [EBP, ESP], Uses = [EBP, ESP], mayLoad = 1, neverHasSideEffects=1 in
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000485def LEAVE : I<0xC9, RawFrm,
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000486 (outs), (ins), "leave", []>;
487
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000488let Defs = [ESP], Uses = [ESP], neverHasSideEffects=1 in {
489let mayLoad = 1 in
Evan Chengd8434332007-09-26 01:29:06 +0000490def POP32r : I<0x58, AddRegFrm, (outs GR32:$reg), (ins), "pop{l}\t$reg", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000491
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000492let mayStore = 1 in
Evan Chengd8434332007-09-26 01:29:06 +0000493def PUSH32r : I<0x50, AddRegFrm, (outs), (ins GR32:$reg), "push{l}\t$reg",[]>;
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000494}
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000495
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000496let Defs = [ESP, EFLAGS], Uses = [ESP], mayLoad = 1, neverHasSideEffects=1 in
Evan Chengf1341312007-09-26 21:28:00 +0000497def POPFD : I<0x9D, RawFrm, (outs), (ins), "popf", []>;
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000498let Defs = [ESP], Uses = [ESP, EFLAGS], mayStore = 1, neverHasSideEffects=1 in
Evan Chengf1341312007-09-26 21:28:00 +0000499def PUSHFD : I<0x9C, RawFrm, (outs), (ins), "pushf", []>;
Evan Chengd8434332007-09-26 01:29:06 +0000500
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000501let isTwoAddress = 1 in // GR32 = bswap GR32
502 def BSWAP32r : I<0xC8, AddRegFrm,
Evan Chengb783fa32007-07-19 01:14:50 +0000503 (outs GR32:$dst), (ins GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000504 "bswap{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000505 [(set GR32:$dst, (bswap GR32:$src))]>, TB;
506
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000507
Evan Cheng48679f42007-12-14 02:13:44 +0000508// Bit scan instructions.
509let Defs = [EFLAGS] in {
Evan Cheng4e33de92007-12-14 18:49:43 +0000510def BSF16rr : I<0xBC, MRMSrcReg, (outs GR16:$dst), (ins GR16:$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 GR16:$src)), (implicit EFLAGS)]>, TB;
Evan Cheng48679f42007-12-14 02:13:44 +0000513def BSF16rm : I<0xBC, MRMSrcMem, (outs GR16:$dst), (ins i16mem:$src),
Dan Gohmancdb54c62007-12-14 15:10:00 +0000514 "bsf{w}\t{$src, $dst|$dst, $src}",
Evan Cheng7cfbfe32007-12-14 08:30:15 +0000515 [(set GR16:$dst, (X86bsf (loadi16 addr:$src))),
516 (implicit EFLAGS)]>, TB;
Evan Cheng4e33de92007-12-14 18:49:43 +0000517def BSF32rr : I<0xBC, MRMSrcReg, (outs GR32:$dst), (ins GR32:$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 GR32:$src)), (implicit EFLAGS)]>, TB;
Evan Cheng48679f42007-12-14 02:13:44 +0000520def BSF32rm : I<0xBC, MRMSrcMem, (outs GR32:$dst), (ins i32mem:$src),
Dan Gohmancdb54c62007-12-14 15:10:00 +0000521 "bsf{l}\t{$src, $dst|$dst, $src}",
Evan Cheng7cfbfe32007-12-14 08:30:15 +0000522 [(set GR32:$dst, (X86bsf (loadi32 addr:$src))),
523 (implicit EFLAGS)]>, TB;
Evan Cheng48679f42007-12-14 02:13:44 +0000524
Evan Cheng4e33de92007-12-14 18:49:43 +0000525def BSR16rr : I<0xBD, MRMSrcReg, (outs GR16:$dst), (ins GR16:$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 GR16:$src)), (implicit EFLAGS)]>, TB;
Evan Cheng48679f42007-12-14 02:13:44 +0000528def BSR16rm : I<0xBD, MRMSrcMem, (outs GR16:$dst), (ins i16mem:$src),
Dan Gohmancdb54c62007-12-14 15:10:00 +0000529 "bsr{w}\t{$src, $dst|$dst, $src}",
Evan Cheng7cfbfe32007-12-14 08:30:15 +0000530 [(set GR16:$dst, (X86bsr (loadi16 addr:$src))),
531 (implicit EFLAGS)]>, TB;
Evan Cheng4e33de92007-12-14 18:49:43 +0000532def BSR32rr : I<0xBD, MRMSrcReg, (outs GR32:$dst), (ins GR32:$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 GR32:$src)), (implicit EFLAGS)]>, TB;
Evan Cheng48679f42007-12-14 02:13:44 +0000535def BSR32rm : I<0xBD, MRMSrcMem, (outs GR32:$dst), (ins i32mem:$src),
Dan Gohmancdb54c62007-12-14 15:10:00 +0000536 "bsr{l}\t{$src, $dst|$dst, $src}",
Evan Cheng7cfbfe32007-12-14 08:30:15 +0000537 [(set GR32:$dst, (X86bsr (loadi32 addr:$src))),
538 (implicit EFLAGS)]>, TB;
Evan Cheng48679f42007-12-14 02:13:44 +0000539} // Defs = [EFLAGS]
540
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000541let neverHasSideEffects = 1 in
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000542def LEA16r : I<0x8D, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +0000543 (outs GR16:$dst), (ins i32mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000544 "lea{w}\t{$src|$dst}, {$dst|$src}", []>, OpSize;
Evan Cheng1ea8e6b2008-03-27 01:41:09 +0000545let isReMaterializable = 1 in
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000546def LEA32r : I<0x8D, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +0000547 (outs GR32:$dst), (ins lea32mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000548 "lea{l}\t{$src|$dst}, {$dst|$src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000549 [(set GR32:$dst, lea32addr:$src)]>, Requires<[In32BitMode]>;
550
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000551let Defs = [ECX,EDI,ESI], Uses = [ECX,EDI,ESI] in {
Evan Chengb783fa32007-07-19 01:14:50 +0000552def REP_MOVSB : I<0xA4, RawFrm, (outs), (ins), "{rep;movsb|rep movsb}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000553 [(X86rep_movs i8)]>, REP;
Evan Chengb783fa32007-07-19 01:14:50 +0000554def REP_MOVSW : I<0xA5, RawFrm, (outs), (ins), "{rep;movsw|rep movsw}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000555 [(X86rep_movs i16)]>, REP, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +0000556def REP_MOVSD : I<0xA5, RawFrm, (outs), (ins), "{rep;movsl|rep movsd}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000557 [(X86rep_movs i32)]>, REP;
558}
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000559
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000560let Defs = [ECX,EDI], Uses = [AL,ECX,EDI] in
Evan Chengb783fa32007-07-19 01:14:50 +0000561def REP_STOSB : I<0xAA, RawFrm, (outs), (ins), "{rep;stosb|rep stosb}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000562 [(X86rep_stos i8)]>, REP;
563let Defs = [ECX,EDI], Uses = [AX,ECX,EDI] in
Evan Chengb783fa32007-07-19 01:14:50 +0000564def REP_STOSW : I<0xAB, RawFrm, (outs), (ins), "{rep;stosw|rep stosw}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000565 [(X86rep_stos i16)]>, REP, OpSize;
566let Defs = [ECX,EDI], Uses = [EAX,ECX,EDI] in
Evan Chengb783fa32007-07-19 01:14:50 +0000567def REP_STOSD : I<0xAB, RawFrm, (outs), (ins), "{rep;stosl|rep stosd}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000568 [(X86rep_stos i32)]>, REP;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000569
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000570let Defs = [RAX, RDX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000571def RDTSC : I<0x31, RawFrm, (outs), (ins), "rdtsc", [(X86rdtsc)]>,
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000572 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000573
Anton Korobeynikov39d40ba2008-01-15 07:02:33 +0000574let isBarrier = 1, hasCtrlDep = 1 in {
Chris Lattner56b941f2008-01-15 21:58:22 +0000575def TRAP : I<0x0B, RawFrm, (outs), (ins), "ud2", [(trap)]>, TB;
Anton Korobeynikov39d40ba2008-01-15 07:02:33 +0000576}
577
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000578//===----------------------------------------------------------------------===//
579// Input/Output Instructions...
580//
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000581let Defs = [AL], Uses = [DX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000582def IN8rr : I<0xEC, RawFrm, (outs), (ins),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000583 "in{b}\t{%dx, %al|%AL, %DX}", []>;
584let Defs = [AX], Uses = [DX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000585def IN16rr : I<0xED, RawFrm, (outs), (ins),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000586 "in{w}\t{%dx, %ax|%AX, %DX}", []>, OpSize;
587let Defs = [EAX], Uses = [DX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000588def IN32rr : I<0xED, RawFrm, (outs), (ins),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000589 "in{l}\t{%dx, %eax|%EAX, %DX}", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000590
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000591let Defs = [AL] in
Evan Chengb783fa32007-07-19 01:14:50 +0000592def IN8ri : Ii8<0xE4, RawFrm, (outs), (ins i16i8imm:$port),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000593 "in{b}\t{$port, %al|%AL, $port}", []>;
594let Defs = [AX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000595def IN16ri : Ii8<0xE5, RawFrm, (outs), (ins i16i8imm:$port),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000596 "in{w}\t{$port, %ax|%AX, $port}", []>, OpSize;
597let Defs = [EAX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000598def IN32ri : Ii8<0xE5, RawFrm, (outs), (ins i16i8imm:$port),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000599 "in{l}\t{$port, %eax|%EAX, $port}", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000600
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000601let Uses = [DX, AL] in
Evan Chengb783fa32007-07-19 01:14:50 +0000602def OUT8rr : I<0xEE, RawFrm, (outs), (ins),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000603 "out{b}\t{%al, %dx|%DX, %AL}", []>;
604let Uses = [DX, AX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000605def OUT16rr : I<0xEF, RawFrm, (outs), (ins),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000606 "out{w}\t{%ax, %dx|%DX, %AX}", []>, OpSize;
607let Uses = [DX, EAX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000608def OUT32rr : I<0xEF, RawFrm, (outs), (ins),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000609 "out{l}\t{%eax, %dx|%DX, %EAX}", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000610
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000611let Uses = [AL] in
Evan Chengb783fa32007-07-19 01:14:50 +0000612def OUT8ir : Ii8<0xE6, RawFrm, (outs), (ins i16i8imm:$port),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000613 "out{b}\t{%al, $port|$port, %AL}", []>;
614let Uses = [AX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000615def OUT16ir : Ii8<0xE7, RawFrm, (outs), (ins i16i8imm:$port),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000616 "out{w}\t{%ax, $port|$port, %AX}", []>, OpSize;
617let Uses = [EAX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000618def OUT32ir : Ii8<0xE7, RawFrm, (outs), (ins i16i8imm:$port),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000619 "out{l}\t{%eax, $port|$port, %EAX}", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000620
621//===----------------------------------------------------------------------===//
622// Move Instructions...
623//
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000624let neverHasSideEffects = 1 in {
Evan Chengb783fa32007-07-19 01:14:50 +0000625def MOV8rr : I<0x88, MRMDestReg, (outs GR8 :$dst), (ins GR8 :$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000626 "mov{b}\t{$src, $dst|$dst, $src}", []>;
Evan Chengb783fa32007-07-19 01:14:50 +0000627def MOV16rr : I<0x89, MRMDestReg, (outs GR16:$dst), (ins GR16:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000628 "mov{w}\t{$src, $dst|$dst, $src}", []>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +0000629def MOV32rr : I<0x89, MRMDestReg, (outs GR32:$dst), (ins GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000630 "mov{l}\t{$src, $dst|$dst, $src}", []>;
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000631}
Evan Cheng6f26e8b2008-06-18 08:13:07 +0000632let isReMaterializable = 1, isAsCheapAsAMove = 1 in {
Evan Chengb783fa32007-07-19 01:14:50 +0000633def MOV8ri : Ii8 <0xB0, AddRegFrm, (outs GR8 :$dst), (ins i8imm :$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000634 "mov{b}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000635 [(set GR8:$dst, imm:$src)]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000636def MOV16ri : Ii16<0xB8, AddRegFrm, (outs GR16:$dst), (ins i16imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000637 "mov{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000638 [(set GR16:$dst, imm:$src)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +0000639def MOV32ri : Ii32<0xB8, AddRegFrm, (outs GR32:$dst), (ins i32imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000640 "mov{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000641 [(set GR32:$dst, imm:$src)]>;
642}
Evan Chengb783fa32007-07-19 01:14:50 +0000643def MOV8mi : Ii8 <0xC6, MRM0m, (outs), (ins i8mem :$dst, i8imm :$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000644 "mov{b}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000645 [(store (i8 imm:$src), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000646def MOV16mi : Ii16<0xC7, MRM0m, (outs), (ins i16mem:$dst, i16imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000647 "mov{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000648 [(store (i16 imm:$src), addr:$dst)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +0000649def MOV32mi : Ii32<0xC7, MRM0m, (outs), (ins i32mem:$dst, i32imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000650 "mov{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000651 [(store (i32 imm:$src), addr:$dst)]>;
652
Chris Lattner1a1932c2008-01-06 23:38:27 +0000653let isSimpleLoad = 1, isReMaterializable = 1, mayHaveSideEffects = 1 in {
Evan Chengb783fa32007-07-19 01:14:50 +0000654def MOV8rm : I<0x8A, MRMSrcMem, (outs GR8 :$dst), (ins i8mem :$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000655 "mov{b}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000656 [(set GR8:$dst, (load addr:$src))]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000657def MOV16rm : I<0x8B, MRMSrcMem, (outs GR16:$dst), (ins i16mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000658 "mov{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000659 [(set GR16:$dst, (load addr:$src))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +0000660def MOV32rm : I<0x8B, MRMSrcMem, (outs GR32:$dst), (ins i32mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000661 "mov{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000662 [(set GR32:$dst, (load addr:$src))]>;
Evan Cheng4e84e452007-08-30 05:49:43 +0000663}
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000664
Evan Chengb783fa32007-07-19 01:14:50 +0000665def MOV8mr : I<0x88, MRMDestMem, (outs), (ins i8mem :$dst, GR8 :$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000666 "mov{b}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000667 [(store GR8:$src, addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000668def MOV16mr : I<0x89, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000669 "mov{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000670 [(store GR16:$src, addr:$dst)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +0000671def MOV32mr : I<0x89, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000672 "mov{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000673 [(store GR32:$src, addr:$dst)]>;
674
675//===----------------------------------------------------------------------===//
676// Fixed-Register Multiplication and Division Instructions...
677//
678
679// Extra precision multiplication
Evan Cheng55687072007-09-14 21:48:26 +0000680let Defs = [AL,AH,EFLAGS], Uses = [AL] in
Dan Gohman91888f02007-07-31 20:11:57 +0000681def MUL8r : I<0xF6, MRM4r, (outs), (ins GR8:$src), "mul{b}\t$src",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000682 // FIXME: Used for 8-bit mul, ignore result upper 8 bits.
683 // This probably ought to be moved to a def : Pat<> if the
684 // syntax can be accepted.
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000685 [(set AL, (mul AL, GR8:$src))]>; // AL,AH = AL*GR8
Chris Lattnerc7e96e72008-01-11 07:18:17 +0000686let Defs = [AX,DX,EFLAGS], Uses = [AX], neverHasSideEffects = 1 in
Dan Gohman91888f02007-07-31 20:11:57 +0000687def MUL16r : I<0xF7, MRM4r, (outs), (ins GR16:$src), "mul{w}\t$src", []>,
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000688 OpSize; // AX,DX = AX*GR16
Chris Lattnerc7e96e72008-01-11 07:18:17 +0000689let Defs = [EAX,EDX,EFLAGS], Uses = [EAX], neverHasSideEffects = 1 in
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000690def MUL32r : I<0xF7, MRM4r, (outs), (ins GR32:$src), "mul{l}\t$src", []>;
691 // EAX,EDX = EAX*GR32
Evan Cheng55687072007-09-14 21:48:26 +0000692let Defs = [AL,AH,EFLAGS], Uses = [AL] in
Evan Chengb783fa32007-07-19 01:14:50 +0000693def MUL8m : I<0xF6, MRM4m, (outs), (ins i8mem :$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000694 "mul{b}\t$src",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000695 // FIXME: Used for 8-bit mul, ignore result upper 8 bits.
696 // This probably ought to be moved to a def : Pat<> if the
697 // syntax can be accepted.
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000698 [(set AL, (mul AL, (loadi8 addr:$src)))]>; // AL,AH = AL*[mem8]
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000699let mayLoad = 1, neverHasSideEffects = 1 in {
Evan Cheng55687072007-09-14 21:48:26 +0000700let Defs = [AX,DX,EFLAGS], Uses = [AX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000701def MUL16m : I<0xF7, MRM4m, (outs), (ins i16mem:$src),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000702 "mul{w}\t$src", []>, OpSize; // AX,DX = AX*[mem16]
Evan Cheng55687072007-09-14 21:48:26 +0000703let Defs = [EAX,EDX,EFLAGS], Uses = [EAX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000704def MUL32m : I<0xF7, MRM4m, (outs), (ins i32mem:$src),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000705 "mul{l}\t$src", []>; // EAX,EDX = EAX*[mem32]
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000706}
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000707
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000708let neverHasSideEffects = 1 in {
Evan Cheng55687072007-09-14 21:48:26 +0000709let Defs = [AL,AH,EFLAGS], Uses = [AL] in
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000710def IMUL8r : I<0xF6, MRM5r, (outs), (ins GR8:$src), "imul{b}\t$src", []>;
711 // AL,AH = AL*GR8
Evan Cheng55687072007-09-14 21:48:26 +0000712let Defs = [AX,DX,EFLAGS], Uses = [AX] in
Dan Gohman91888f02007-07-31 20:11:57 +0000713def IMUL16r : I<0xF7, MRM5r, (outs), (ins GR16:$src), "imul{w}\t$src", []>,
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000714 OpSize; // AX,DX = AX*GR16
Evan Cheng55687072007-09-14 21:48:26 +0000715let Defs = [EAX,EDX,EFLAGS], Uses = [EAX] in
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000716def IMUL32r : I<0xF7, MRM5r, (outs), (ins GR32:$src), "imul{l}\t$src", []>;
717 // EAX,EDX = EAX*GR32
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000718let mayLoad = 1 in {
Evan Cheng55687072007-09-14 21:48:26 +0000719let Defs = [AL,AH,EFLAGS], Uses = [AL] in
Evan Chengb783fa32007-07-19 01:14:50 +0000720def IMUL8m : I<0xF6, MRM5m, (outs), (ins i8mem :$src),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000721 "imul{b}\t$src", []>; // AL,AH = AL*[mem8]
Evan Cheng55687072007-09-14 21:48:26 +0000722let Defs = [AX,DX,EFLAGS], Uses = [AX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000723def IMUL16m : I<0xF7, MRM5m, (outs), (ins i16mem:$src),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000724 "imul{w}\t$src", []>, OpSize; // AX,DX = AX*[mem16]
725let Defs = [EAX,EDX], Uses = [EAX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000726def IMUL32m : I<0xF7, MRM5m, (outs), (ins i32mem:$src),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000727 "imul{l}\t$src", []>; // EAX,EDX = EAX*[mem32]
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000728}
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000729
730// unsigned division/remainder
Dale Johannesend8fd3562008-10-07 18:54:28 +0000731let Defs = [AL,AH,EFLAGS], Uses = [AX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000732def DIV8r : I<0xF6, MRM6r, (outs), (ins GR8:$src), // AX/r8 = AL,AH
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000733 "div{b}\t$src", []>;
Evan Cheng55687072007-09-14 21:48:26 +0000734let Defs = [AX,DX,EFLAGS], Uses = [AX,DX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000735def DIV16r : I<0xF7, MRM6r, (outs), (ins GR16:$src), // DX:AX/r16 = AX,DX
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000736 "div{w}\t$src", []>, OpSize;
Evan Cheng55687072007-09-14 21:48:26 +0000737let Defs = [EAX,EDX,EFLAGS], Uses = [EAX,EDX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000738def DIV32r : I<0xF7, MRM6r, (outs), (ins GR32:$src), // EDX:EAX/r32 = EAX,EDX
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000739 "div{l}\t$src", []>;
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000740let mayLoad = 1 in {
Dale Johannesend8fd3562008-10-07 18:54:28 +0000741let Defs = [AL,AH,EFLAGS], Uses = [AX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000742def DIV8m : I<0xF6, MRM6m, (outs), (ins i8mem:$src), // AX/[mem8] = AL,AH
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000743 "div{b}\t$src", []>;
Evan Cheng55687072007-09-14 21:48:26 +0000744let Defs = [AX,DX,EFLAGS], Uses = [AX,DX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000745def DIV16m : I<0xF7, MRM6m, (outs), (ins i16mem:$src), // DX:AX/[mem16] = AX,DX
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000746 "div{w}\t$src", []>, OpSize;
Evan Cheng55687072007-09-14 21:48:26 +0000747let Defs = [EAX,EDX,EFLAGS], Uses = [EAX,EDX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000748def DIV32m : I<0xF7, MRM6m, (outs), (ins i32mem:$src), // EDX:EAX/[mem32] = EAX,EDX
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000749 "div{l}\t$src", []>;
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000750}
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000751
752// Signed division/remainder.
Dale Johannesend8fd3562008-10-07 18:54:28 +0000753let Defs = [AL,AH,EFLAGS], Uses = [AX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000754def IDIV8r : I<0xF6, MRM7r, (outs), (ins GR8:$src), // AX/r8 = AL,AH
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000755 "idiv{b}\t$src", []>;
Evan Cheng55687072007-09-14 21:48:26 +0000756let Defs = [AX,DX,EFLAGS], Uses = [AX,DX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000757def IDIV16r: I<0xF7, MRM7r, (outs), (ins GR16:$src), // DX:AX/r16 = AX,DX
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000758 "idiv{w}\t$src", []>, OpSize;
Evan Cheng55687072007-09-14 21:48:26 +0000759let Defs = [EAX,EDX,EFLAGS], Uses = [EAX,EDX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000760def IDIV32r: I<0xF7, MRM7r, (outs), (ins GR32:$src), // EDX:EAX/r32 = EAX,EDX
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000761 "idiv{l}\t$src", []>;
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000762let mayLoad = 1, mayLoad = 1 in {
Dale Johannesend8fd3562008-10-07 18:54:28 +0000763let Defs = [AL,AH,EFLAGS], Uses = [AX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000764def IDIV8m : I<0xF6, MRM7m, (outs), (ins i8mem:$src), // AX/[mem8] = AL,AH
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000765 "idiv{b}\t$src", []>;
Evan Cheng55687072007-09-14 21:48:26 +0000766let Defs = [AX,DX,EFLAGS], Uses = [AX,DX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000767def IDIV16m: I<0xF7, MRM7m, (outs), (ins i16mem:$src), // DX:AX/[mem16] = AX,DX
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000768 "idiv{w}\t$src", []>, OpSize;
Evan Cheng55687072007-09-14 21:48:26 +0000769let Defs = [EAX,EDX,EFLAGS], Uses = [EAX,EDX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000770def IDIV32m: I<0xF7, MRM7m, (outs), (ins i32mem:$src), // EDX:EAX/[mem32] = EAX,EDX
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000771 "idiv{l}\t$src", []>;
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000772}
773} // neverHasSideEffects
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000774
775//===----------------------------------------------------------------------===//
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000776// Two address Instructions.
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000777//
778let isTwoAddress = 1 in {
779
780// Conditional moves
Evan Cheng950aac02007-09-25 01:57:46 +0000781let Uses = [EFLAGS] in {
Evan Cheng926658c2007-10-05 23:13:21 +0000782let isCommutable = 1 in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000783def CMOVB16rr : I<0x42, MRMSrcReg, // if <u, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +0000784 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000785 "cmovb\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000786 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000787 X86_COND_B, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000788 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000789def CMOVB32rr : I<0x42, MRMSrcReg, // if <u, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +0000790 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000791 "cmovb\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000792 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000793 X86_COND_B, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000794 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000795
796def CMOVAE16rr: I<0x43, MRMSrcReg, // if >=u, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +0000797 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000798 "cmovae\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000799 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000800 X86_COND_AE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000801 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000802def CMOVAE32rr: I<0x43, MRMSrcReg, // if >=u, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +0000803 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000804 "cmovae\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000805 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000806 X86_COND_AE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000807 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000808def CMOVE16rr : I<0x44, MRMSrcReg, // if ==, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +0000809 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000810 "cmove\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000811 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000812 X86_COND_E, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000813 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000814def CMOVE32rr : I<0x44, MRMSrcReg, // if ==, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +0000815 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000816 "cmove\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000817 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000818 X86_COND_E, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000819 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000820def CMOVNE16rr: I<0x45, MRMSrcReg, // if !=, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +0000821 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000822 "cmovne\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000823 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000824 X86_COND_NE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000825 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000826def CMOVNE32rr: I<0x45, MRMSrcReg, // if !=, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +0000827 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000828 "cmovne\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000829 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000830 X86_COND_NE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000831 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000832def CMOVBE16rr: I<0x46, MRMSrcReg, // if <=u, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +0000833 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000834 "cmovbe\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000835 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000836 X86_COND_BE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000837 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000838def CMOVBE32rr: I<0x46, MRMSrcReg, // if <=u, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +0000839 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000840 "cmovbe\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000841 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000842 X86_COND_BE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000843 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000844def CMOVA16rr : I<0x47, MRMSrcReg, // if >u, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +0000845 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000846 "cmova\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000847 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000848 X86_COND_A, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000849 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000850def CMOVA32rr : I<0x47, MRMSrcReg, // if >u, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +0000851 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000852 "cmova\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000853 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000854 X86_COND_A, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000855 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000856def CMOVL16rr : I<0x4C, MRMSrcReg, // if <s, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +0000857 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000858 "cmovl\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000859 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000860 X86_COND_L, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000861 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000862def CMOVL32rr : I<0x4C, MRMSrcReg, // if <s, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +0000863 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000864 "cmovl\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000865 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000866 X86_COND_L, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000867 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000868def CMOVGE16rr: I<0x4D, MRMSrcReg, // if >=s, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +0000869 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000870 "cmovge\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000871 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000872 X86_COND_GE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000873 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000874def CMOVGE32rr: I<0x4D, MRMSrcReg, // if >=s, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +0000875 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000876 "cmovge\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000877 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000878 X86_COND_GE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000879 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000880def CMOVLE16rr: I<0x4E, MRMSrcReg, // if <=s, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +0000881 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000882 "cmovle\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000883 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000884 X86_COND_LE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000885 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000886def CMOVLE32rr: I<0x4E, MRMSrcReg, // if <=s, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +0000887 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000888 "cmovle\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000889 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000890 X86_COND_LE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000891 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000892def CMOVG16rr : I<0x4F, MRMSrcReg, // if >s, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +0000893 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000894 "cmovg\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000895 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000896 X86_COND_G, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000897 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000898def CMOVG32rr : I<0x4F, MRMSrcReg, // if >s, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +0000899 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000900 "cmovg\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000901 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000902 X86_COND_G, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000903 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000904def CMOVS16rr : I<0x48, MRMSrcReg, // if signed, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +0000905 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000906 "cmovs\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000907 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000908 X86_COND_S, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000909 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000910def CMOVS32rr : I<0x48, MRMSrcReg, // if signed, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +0000911 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000912 "cmovs\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000913 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000914 X86_COND_S, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000915 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000916def CMOVNS16rr: I<0x49, MRMSrcReg, // if !signed, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +0000917 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000918 "cmovns\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000919 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000920 X86_COND_NS, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000921 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000922def CMOVNS32rr: I<0x49, MRMSrcReg, // if !signed, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +0000923 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000924 "cmovns\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000925 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000926 X86_COND_NS, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000927 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000928def CMOVP16rr : I<0x4A, MRMSrcReg, // if parity, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +0000929 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000930 "cmovp\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000931 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000932 X86_COND_P, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000933 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000934def CMOVP32rr : I<0x4A, MRMSrcReg, // if parity, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +0000935 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000936 "cmovp\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000937 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000938 X86_COND_P, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000939 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000940def CMOVNP16rr : I<0x4B, MRMSrcReg, // if !parity, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +0000941 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000942 "cmovnp\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000943 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000944 X86_COND_NP, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000945 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000946def CMOVNP32rr : I<0x4B, MRMSrcReg, // if !parity, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +0000947 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000948 "cmovnp\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000949 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000950 X86_COND_NP, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000951 TB;
Evan Cheng926658c2007-10-05 23:13:21 +0000952} // isCommutable = 1
953
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000954def CMOVNP32rm : I<0x4B, MRMSrcMem, // if !parity, GR32 = [mem32]
Evan Chengb783fa32007-07-19 01:14:50 +0000955 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000956 "cmovnp\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000957 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
Evan Cheng950aac02007-09-25 01:57:46 +0000958 X86_COND_NP, EFLAGS))]>,
959 TB;
Evan Cheng926658c2007-10-05 23:13:21 +0000960
961def CMOVB16rm : I<0x42, MRMSrcMem, // if <u, GR16 = [mem16]
962 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
963 "cmovb\t{$src2, $dst|$dst, $src2}",
964 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
965 X86_COND_B, EFLAGS))]>,
966 TB, OpSize;
967def CMOVB32rm : I<0x42, MRMSrcMem, // if <u, GR32 = [mem32]
968 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
969 "cmovb\t{$src2, $dst|$dst, $src2}",
970 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
971 X86_COND_B, EFLAGS))]>,
972 TB;
973def CMOVAE16rm: I<0x43, MRMSrcMem, // if >=u, GR16 = [mem16]
974 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
975 "cmovae\t{$src2, $dst|$dst, $src2}",
976 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
977 X86_COND_AE, EFLAGS))]>,
978 TB, OpSize;
979def CMOVAE32rm: I<0x43, MRMSrcMem, // if >=u, GR32 = [mem32]
980 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
981 "cmovae\t{$src2, $dst|$dst, $src2}",
982 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
983 X86_COND_AE, EFLAGS))]>,
984 TB;
985def CMOVE16rm : I<0x44, MRMSrcMem, // if ==, GR16 = [mem16]
986 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
987 "cmove\t{$src2, $dst|$dst, $src2}",
988 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
989 X86_COND_E, EFLAGS))]>,
990 TB, OpSize;
991def CMOVE32rm : I<0x44, MRMSrcMem, // if ==, GR32 = [mem32]
992 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
993 "cmove\t{$src2, $dst|$dst, $src2}",
994 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
995 X86_COND_E, EFLAGS))]>,
996 TB;
997def CMOVNE16rm: I<0x45, MRMSrcMem, // if !=, GR16 = [mem16]
998 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
999 "cmovne\t{$src2, $dst|$dst, $src2}",
1000 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1001 X86_COND_NE, EFLAGS))]>,
1002 TB, OpSize;
1003def CMOVNE32rm: I<0x45, MRMSrcMem, // if !=, GR32 = [mem32]
1004 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1005 "cmovne\t{$src2, $dst|$dst, $src2}",
1006 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1007 X86_COND_NE, EFLAGS))]>,
1008 TB;
1009def CMOVBE16rm: I<0x46, MRMSrcMem, // if <=u, GR16 = [mem16]
1010 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1011 "cmovbe\t{$src2, $dst|$dst, $src2}",
1012 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1013 X86_COND_BE, EFLAGS))]>,
1014 TB, OpSize;
1015def CMOVBE32rm: I<0x46, MRMSrcMem, // if <=u, GR32 = [mem32]
1016 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1017 "cmovbe\t{$src2, $dst|$dst, $src2}",
1018 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1019 X86_COND_BE, EFLAGS))]>,
1020 TB;
1021def CMOVA16rm : I<0x47, MRMSrcMem, // if >u, GR16 = [mem16]
1022 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1023 "cmova\t{$src2, $dst|$dst, $src2}",
1024 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1025 X86_COND_A, EFLAGS))]>,
1026 TB, OpSize;
1027def CMOVA32rm : I<0x47, MRMSrcMem, // if >u, GR32 = [mem32]
1028 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1029 "cmova\t{$src2, $dst|$dst, $src2}",
1030 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1031 X86_COND_A, EFLAGS))]>,
1032 TB;
1033def CMOVL16rm : I<0x4C, MRMSrcMem, // if <s, GR16 = [mem16]
1034 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1035 "cmovl\t{$src2, $dst|$dst, $src2}",
1036 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1037 X86_COND_L, EFLAGS))]>,
1038 TB, OpSize;
1039def CMOVL32rm : I<0x4C, MRMSrcMem, // if <s, GR32 = [mem32]
1040 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1041 "cmovl\t{$src2, $dst|$dst, $src2}",
1042 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1043 X86_COND_L, EFLAGS))]>,
1044 TB;
1045def CMOVGE16rm: I<0x4D, MRMSrcMem, // if >=s, GR16 = [mem16]
1046 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1047 "cmovge\t{$src2, $dst|$dst, $src2}",
1048 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1049 X86_COND_GE, EFLAGS))]>,
1050 TB, OpSize;
1051def CMOVGE32rm: I<0x4D, MRMSrcMem, // if >=s, GR32 = [mem32]
1052 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1053 "cmovge\t{$src2, $dst|$dst, $src2}",
1054 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1055 X86_COND_GE, EFLAGS))]>,
1056 TB;
1057def CMOVLE16rm: I<0x4E, MRMSrcMem, // if <=s, GR16 = [mem16]
1058 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1059 "cmovle\t{$src2, $dst|$dst, $src2}",
1060 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1061 X86_COND_LE, EFLAGS))]>,
1062 TB, OpSize;
1063def CMOVLE32rm: I<0x4E, MRMSrcMem, // if <=s, GR32 = [mem32]
1064 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1065 "cmovle\t{$src2, $dst|$dst, $src2}",
1066 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1067 X86_COND_LE, EFLAGS))]>,
1068 TB;
1069def CMOVG16rm : I<0x4F, MRMSrcMem, // if >s, GR16 = [mem16]
1070 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1071 "cmovg\t{$src2, $dst|$dst, $src2}",
1072 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1073 X86_COND_G, EFLAGS))]>,
1074 TB, OpSize;
1075def CMOVG32rm : I<0x4F, MRMSrcMem, // if >s, GR32 = [mem32]
1076 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1077 "cmovg\t{$src2, $dst|$dst, $src2}",
1078 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1079 X86_COND_G, EFLAGS))]>,
1080 TB;
1081def CMOVS16rm : I<0x48, MRMSrcMem, // if signed, GR16 = [mem16]
1082 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1083 "cmovs\t{$src2, $dst|$dst, $src2}",
1084 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1085 X86_COND_S, EFLAGS))]>,
1086 TB, OpSize;
1087def CMOVS32rm : I<0x48, MRMSrcMem, // if signed, GR32 = [mem32]
1088 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1089 "cmovs\t{$src2, $dst|$dst, $src2}",
1090 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1091 X86_COND_S, EFLAGS))]>,
1092 TB;
1093def CMOVNS16rm: I<0x49, MRMSrcMem, // if !signed, GR16 = [mem16]
1094 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1095 "cmovns\t{$src2, $dst|$dst, $src2}",
1096 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1097 X86_COND_NS, EFLAGS))]>,
1098 TB, OpSize;
1099def CMOVNS32rm: I<0x49, MRMSrcMem, // if !signed, GR32 = [mem32]
1100 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1101 "cmovns\t{$src2, $dst|$dst, $src2}",
1102 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1103 X86_COND_NS, EFLAGS))]>,
1104 TB;
1105def CMOVP16rm : I<0x4A, MRMSrcMem, // if parity, GR16 = [mem16]
1106 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1107 "cmovp\t{$src2, $dst|$dst, $src2}",
1108 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1109 X86_COND_P, EFLAGS))]>,
1110 TB, OpSize;
1111def CMOVP32rm : I<0x4A, MRMSrcMem, // if parity, GR32 = [mem32]
1112 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1113 "cmovp\t{$src2, $dst|$dst, $src2}",
1114 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1115 X86_COND_P, EFLAGS))]>,
1116 TB;
1117def CMOVNP16rm : I<0x4B, MRMSrcMem, // if !parity, GR16 = [mem16]
1118 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1119 "cmovnp\t{$src2, $dst|$dst, $src2}",
1120 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1121 X86_COND_NP, EFLAGS))]>,
1122 TB, OpSize;
Evan Cheng950aac02007-09-25 01:57:46 +00001123} // Uses = [EFLAGS]
1124
1125
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001126// unary instructions
1127let CodeSize = 2 in {
Evan Cheng55687072007-09-14 21:48:26 +00001128let Defs = [EFLAGS] in {
Dan Gohman91888f02007-07-31 20:11:57 +00001129def NEG8r : I<0xF6, MRM3r, (outs GR8 :$dst), (ins GR8 :$src), "neg{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001130 [(set GR8:$dst, (ineg GR8:$src))]>;
Dan Gohman91888f02007-07-31 20:11:57 +00001131def NEG16r : I<0xF7, MRM3r, (outs GR16:$dst), (ins GR16:$src), "neg{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001132 [(set GR16:$dst, (ineg GR16:$src))]>, OpSize;
Dan Gohman91888f02007-07-31 20:11:57 +00001133def NEG32r : I<0xF7, MRM3r, (outs GR32:$dst), (ins GR32:$src), "neg{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001134 [(set GR32:$dst, (ineg GR32:$src))]>;
1135let isTwoAddress = 0 in {
Dan Gohman91888f02007-07-31 20:11:57 +00001136 def NEG8m : I<0xF6, MRM3m, (outs), (ins i8mem :$dst), "neg{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001137 [(store (ineg (loadi8 addr:$dst)), addr:$dst)]>;
Dan Gohman91888f02007-07-31 20:11:57 +00001138 def NEG16m : I<0xF7, MRM3m, (outs), (ins i16mem:$dst), "neg{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001139 [(store (ineg (loadi16 addr:$dst)), addr:$dst)]>, OpSize;
Dan Gohman91888f02007-07-31 20:11:57 +00001140 def NEG32m : I<0xF7, MRM3m, (outs), (ins i32mem:$dst), "neg{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001141 [(store (ineg (loadi32 addr:$dst)), addr:$dst)]>;
1142
1143}
Evan Cheng55687072007-09-14 21:48:26 +00001144} // Defs = [EFLAGS]
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001145
Dan Gohman91888f02007-07-31 20:11:57 +00001146def NOT8r : I<0xF6, MRM2r, (outs GR8 :$dst), (ins GR8 :$src), "not{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001147 [(set GR8:$dst, (not GR8:$src))]>;
Dan Gohman91888f02007-07-31 20:11:57 +00001148def NOT16r : I<0xF7, MRM2r, (outs GR16:$dst), (ins GR16:$src), "not{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001149 [(set GR16:$dst, (not GR16:$src))]>, OpSize;
Dan Gohman91888f02007-07-31 20:11:57 +00001150def NOT32r : I<0xF7, MRM2r, (outs GR32:$dst), (ins GR32:$src), "not{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001151 [(set GR32:$dst, (not GR32:$src))]>;
1152let isTwoAddress = 0 in {
Dan Gohman91888f02007-07-31 20:11:57 +00001153 def NOT8m : I<0xF6, MRM2m, (outs), (ins i8mem :$dst), "not{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001154 [(store (not (loadi8 addr:$dst)), addr:$dst)]>;
Dan Gohman91888f02007-07-31 20:11:57 +00001155 def NOT16m : I<0xF7, MRM2m, (outs), (ins i16mem:$dst), "not{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001156 [(store (not (loadi16 addr:$dst)), addr:$dst)]>, OpSize;
Dan Gohman91888f02007-07-31 20:11:57 +00001157 def NOT32m : I<0xF7, MRM2m, (outs), (ins i32mem:$dst), "not{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001158 [(store (not (loadi32 addr:$dst)), addr:$dst)]>;
1159}
1160} // CodeSize
1161
1162// TODO: inc/dec is slow for P4, but fast for Pentium-M.
Evan Cheng55687072007-09-14 21:48:26 +00001163let Defs = [EFLAGS] in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001164let CodeSize = 2 in
Dan Gohman91888f02007-07-31 20:11:57 +00001165def INC8r : I<0xFE, MRM0r, (outs GR8 :$dst), (ins GR8 :$src), "inc{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001166 [(set GR8:$dst, (add GR8:$src, 1))]>;
1167let isConvertibleToThreeAddress = 1, CodeSize = 1 in { // Can xform into LEA.
Dan Gohman91888f02007-07-31 20:11:57 +00001168def INC16r : I<0x40, AddRegFrm, (outs GR16:$dst), (ins GR16:$src), "inc{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001169 [(set GR16:$dst, (add GR16:$src, 1))]>,
1170 OpSize, Requires<[In32BitMode]>;
Dan Gohman91888f02007-07-31 20:11:57 +00001171def INC32r : I<0x40, AddRegFrm, (outs GR32:$dst), (ins GR32:$src), "inc{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001172 [(set GR32:$dst, (add GR32:$src, 1))]>, Requires<[In32BitMode]>;
1173}
1174let isTwoAddress = 0, CodeSize = 2 in {
Dan Gohman91888f02007-07-31 20:11:57 +00001175 def INC8m : I<0xFE, MRM0m, (outs), (ins i8mem :$dst), "inc{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001176 [(store (add (loadi8 addr:$dst), 1), addr:$dst)]>;
Dan Gohman91888f02007-07-31 20:11:57 +00001177 def INC16m : I<0xFF, MRM0m, (outs), (ins i16mem:$dst), "inc{w}\t$dst",
Evan Cheng4a7e72f2007-10-19 21:23:22 +00001178 [(store (add (loadi16 addr:$dst), 1), addr:$dst)]>,
1179 OpSize, Requires<[In32BitMode]>;
Dan Gohman91888f02007-07-31 20:11:57 +00001180 def INC32m : I<0xFF, MRM0m, (outs), (ins i32mem:$dst), "inc{l}\t$dst",
Evan Cheng4a7e72f2007-10-19 21:23:22 +00001181 [(store (add (loadi32 addr:$dst), 1), addr:$dst)]>,
1182 Requires<[In32BitMode]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001183}
1184
1185let CodeSize = 2 in
Dan Gohman91888f02007-07-31 20:11:57 +00001186def DEC8r : I<0xFE, MRM1r, (outs GR8 :$dst), (ins GR8 :$src), "dec{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001187 [(set GR8:$dst, (add GR8:$src, -1))]>;
1188let isConvertibleToThreeAddress = 1, CodeSize = 1 in { // Can xform into LEA.
Dan Gohman91888f02007-07-31 20:11:57 +00001189def DEC16r : I<0x48, AddRegFrm, (outs GR16:$dst), (ins GR16:$src), "dec{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001190 [(set GR16:$dst, (add GR16:$src, -1))]>,
1191 OpSize, Requires<[In32BitMode]>;
Dan Gohman91888f02007-07-31 20:11:57 +00001192def DEC32r : I<0x48, AddRegFrm, (outs GR32:$dst), (ins GR32:$src), "dec{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001193 [(set GR32:$dst, (add GR32:$src, -1))]>, Requires<[In32BitMode]>;
1194}
1195
1196let isTwoAddress = 0, CodeSize = 2 in {
Dan Gohman91888f02007-07-31 20:11:57 +00001197 def DEC8m : I<0xFE, MRM1m, (outs), (ins i8mem :$dst), "dec{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001198 [(store (add (loadi8 addr:$dst), -1), addr:$dst)]>;
Dan Gohman91888f02007-07-31 20:11:57 +00001199 def DEC16m : I<0xFF, MRM1m, (outs), (ins i16mem:$dst), "dec{w}\t$dst",
Evan Cheng4a7e72f2007-10-19 21:23:22 +00001200 [(store (add (loadi16 addr:$dst), -1), addr:$dst)]>,
1201 OpSize, Requires<[In32BitMode]>;
Dan Gohman91888f02007-07-31 20:11:57 +00001202 def DEC32m : I<0xFF, MRM1m, (outs), (ins i32mem:$dst), "dec{l}\t$dst",
Evan Cheng4a7e72f2007-10-19 21:23:22 +00001203 [(store (add (loadi32 addr:$dst), -1), addr:$dst)]>,
1204 Requires<[In32BitMode]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001205}
Evan Cheng55687072007-09-14 21:48:26 +00001206} // Defs = [EFLAGS]
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001207
1208// Logical operators...
Evan Cheng55687072007-09-14 21:48:26 +00001209let Defs = [EFLAGS] in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001210let isCommutable = 1 in { // X = AND Y, Z --> X = AND Z, Y
1211def AND8rr : I<0x20, MRMDestReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001212 (outs GR8 :$dst), (ins GR8 :$src1, GR8 :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001213 "and{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001214 [(set GR8:$dst, (and GR8:$src1, GR8:$src2))]>;
1215def AND16rr : I<0x21, MRMDestReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001216 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001217 "and{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001218 [(set GR16:$dst, (and GR16:$src1, GR16:$src2))]>, OpSize;
1219def AND32rr : I<0x21, MRMDestReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001220 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001221 "and{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001222 [(set GR32:$dst, (and GR32:$src1, GR32:$src2))]>;
1223}
1224
1225def AND8rm : I<0x22, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001226 (outs GR8 :$dst), (ins GR8 :$src1, i8mem :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001227 "and{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001228 [(set GR8:$dst, (and GR8:$src1, (load addr:$src2)))]>;
1229def AND16rm : I<0x23, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001230 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001231 "and{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001232 [(set GR16:$dst, (and GR16:$src1, (load addr:$src2)))]>, OpSize;
1233def AND32rm : I<0x23, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001234 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001235 "and{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001236 [(set GR32:$dst, (and GR32:$src1, (load addr:$src2)))]>;
1237
1238def AND8ri : Ii8<0x80, MRM4r,
Evan Chengb783fa32007-07-19 01:14:50 +00001239 (outs GR8 :$dst), (ins GR8 :$src1, i8imm :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001240 "and{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001241 [(set GR8:$dst, (and GR8:$src1, imm:$src2))]>;
1242def AND16ri : Ii16<0x81, MRM4r,
Evan Chengb783fa32007-07-19 01:14:50 +00001243 (outs GR16:$dst), (ins GR16:$src1, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001244 "and{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001245 [(set GR16:$dst, (and GR16:$src1, imm:$src2))]>, OpSize;
1246def AND32ri : Ii32<0x81, MRM4r,
Evan Chengb783fa32007-07-19 01:14:50 +00001247 (outs GR32:$dst), (ins GR32:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001248 "and{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001249 [(set GR32:$dst, (and GR32:$src1, imm:$src2))]>;
1250def AND16ri8 : Ii8<0x83, MRM4r,
Evan Chengb783fa32007-07-19 01:14:50 +00001251 (outs GR16:$dst), (ins GR16:$src1, i16i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001252 "and{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001253 [(set GR16:$dst, (and GR16:$src1, i16immSExt8:$src2))]>,
1254 OpSize;
1255def AND32ri8 : Ii8<0x83, MRM4r,
Evan Chengb783fa32007-07-19 01:14:50 +00001256 (outs GR32:$dst), (ins GR32:$src1, i32i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001257 "and{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001258 [(set GR32:$dst, (and GR32:$src1, i32immSExt8:$src2))]>;
1259
1260let isTwoAddress = 0 in {
1261 def AND8mr : I<0x20, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001262 (outs), (ins i8mem :$dst, GR8 :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001263 "and{b}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001264 [(store (and (load addr:$dst), GR8:$src), addr:$dst)]>;
1265 def AND16mr : I<0x21, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001266 (outs), (ins i16mem:$dst, GR16:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001267 "and{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001268 [(store (and (load addr:$dst), GR16:$src), addr:$dst)]>,
1269 OpSize;
1270 def AND32mr : I<0x21, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001271 (outs), (ins i32mem:$dst, GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001272 "and{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001273 [(store (and (load addr:$dst), GR32:$src), addr:$dst)]>;
1274 def AND8mi : Ii8<0x80, MRM4m,
Evan Chengb783fa32007-07-19 01:14:50 +00001275 (outs), (ins i8mem :$dst, i8imm :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001276 "and{b}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001277 [(store (and (loadi8 addr:$dst), imm:$src), addr:$dst)]>;
1278 def AND16mi : Ii16<0x81, MRM4m,
Evan Chengb783fa32007-07-19 01:14:50 +00001279 (outs), (ins i16mem:$dst, i16imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001280 "and{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001281 [(store (and (loadi16 addr:$dst), imm:$src), addr:$dst)]>,
1282 OpSize;
1283 def AND32mi : Ii32<0x81, MRM4m,
Evan Chengb783fa32007-07-19 01:14:50 +00001284 (outs), (ins i32mem:$dst, i32imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001285 "and{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001286 [(store (and (loadi32 addr:$dst), imm:$src), addr:$dst)]>;
1287 def AND16mi8 : Ii8<0x83, MRM4m,
Evan Chengb783fa32007-07-19 01:14:50 +00001288 (outs), (ins i16mem:$dst, i16i8imm :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001289 "and{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001290 [(store (and (load addr:$dst), i16immSExt8:$src), addr:$dst)]>,
1291 OpSize;
1292 def AND32mi8 : Ii8<0x83, MRM4m,
Evan Chengb783fa32007-07-19 01:14:50 +00001293 (outs), (ins i32mem:$dst, i32i8imm :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001294 "and{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001295 [(store (and (load addr:$dst), i32immSExt8:$src), addr:$dst)]>;
1296}
1297
1298
1299let isCommutable = 1 in { // X = OR Y, Z --> X = OR Z, Y
Evan Chengb783fa32007-07-19 01:14:50 +00001300def OR8rr : I<0x08, MRMDestReg, (outs GR8 :$dst), (ins GR8 :$src1, GR8 :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001301 "or{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001302 [(set GR8:$dst, (or GR8:$src1, GR8:$src2))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001303def OR16rr : I<0x09, MRMDestReg, (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001304 "or{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001305 [(set GR16:$dst, (or GR16:$src1, GR16:$src2))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001306def OR32rr : I<0x09, MRMDestReg, (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001307 "or{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001308 [(set GR32:$dst, (or GR32:$src1, GR32:$src2))]>;
1309}
Evan Chengb783fa32007-07-19 01:14:50 +00001310def OR8rm : I<0x0A, MRMSrcMem , (outs GR8 :$dst), (ins GR8 :$src1, i8mem :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001311 "or{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001312 [(set GR8:$dst, (or GR8:$src1, (load addr:$src2)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001313def OR16rm : I<0x0B, MRMSrcMem , (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001314 "or{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001315 [(set GR16:$dst, (or GR16:$src1, (load addr:$src2)))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001316def OR32rm : I<0x0B, MRMSrcMem , (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001317 "or{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001318 [(set GR32:$dst, (or GR32:$src1, (load addr:$src2)))]>;
1319
Evan Chengb783fa32007-07-19 01:14:50 +00001320def OR8ri : Ii8 <0x80, MRM1r, (outs GR8 :$dst), (ins GR8 :$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001321 "or{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001322 [(set GR8:$dst, (or GR8:$src1, imm:$src2))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001323def OR16ri : Ii16<0x81, MRM1r, (outs GR16:$dst), (ins GR16:$src1, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001324 "or{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001325 [(set GR16:$dst, (or GR16:$src1, imm:$src2))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001326def OR32ri : Ii32<0x81, MRM1r, (outs GR32:$dst), (ins GR32:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001327 "or{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001328 [(set GR32:$dst, (or GR32:$src1, imm:$src2))]>;
1329
Evan Chengb783fa32007-07-19 01:14:50 +00001330def OR16ri8 : Ii8<0x83, MRM1r, (outs GR16:$dst), (ins GR16:$src1, i16i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001331 "or{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001332 [(set GR16:$dst, (or GR16:$src1, i16immSExt8:$src2))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001333def OR32ri8 : Ii8<0x83, MRM1r, (outs GR32:$dst), (ins GR32:$src1, i32i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001334 "or{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001335 [(set GR32:$dst, (or GR32:$src1, i32immSExt8:$src2))]>;
1336let isTwoAddress = 0 in {
Evan Chengb783fa32007-07-19 01:14:50 +00001337 def OR8mr : I<0x08, MRMDestMem, (outs), (ins i8mem:$dst, GR8:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001338 "or{b}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001339 [(store (or (load addr:$dst), GR8:$src), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001340 def OR16mr : I<0x09, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001341 "or{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001342 [(store (or (load addr:$dst), GR16:$src), addr:$dst)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001343 def OR32mr : I<0x09, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001344 "or{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001345 [(store (or (load addr:$dst), GR32:$src), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001346 def OR8mi : Ii8<0x80, MRM1m, (outs), (ins i8mem :$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001347 "or{b}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001348 [(store (or (loadi8 addr:$dst), imm:$src), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001349 def OR16mi : Ii16<0x81, MRM1m, (outs), (ins i16mem:$dst, i16imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001350 "or{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001351 [(store (or (loadi16 addr:$dst), imm:$src), addr:$dst)]>,
1352 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001353 def OR32mi : Ii32<0x81, MRM1m, (outs), (ins i32mem:$dst, i32imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001354 "or{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001355 [(store (or (loadi32 addr:$dst), imm:$src), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001356 def OR16mi8 : Ii8<0x83, MRM1m, (outs), (ins i16mem:$dst, i16i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001357 "or{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001358 [(store (or (load addr:$dst), i16immSExt8:$src), addr:$dst)]>,
1359 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001360 def OR32mi8 : Ii8<0x83, MRM1m, (outs), (ins i32mem:$dst, i32i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001361 "or{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001362 [(store (or (load addr:$dst), i32immSExt8:$src), addr:$dst)]>;
Bill Wendlingba5d5b02008-05-29 01:02:09 +00001363} // isTwoAddress = 0
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001364
1365
Evan Cheng6f26e8b2008-06-18 08:13:07 +00001366let isCommutable = 1 in { // X = XOR Y, Z --> X = XOR Z, Y
Bill Wendlingba5d5b02008-05-29 01:02:09 +00001367 def XOR8rr : I<0x30, MRMDestReg,
1368 (outs GR8 :$dst), (ins GR8 :$src1, GR8 :$src2),
1369 "xor{b}\t{$src2, $dst|$dst, $src2}",
1370 [(set GR8:$dst, (xor GR8:$src1, GR8:$src2))]>;
1371 def XOR16rr : I<0x31, MRMDestReg,
1372 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
1373 "xor{w}\t{$src2, $dst|$dst, $src2}",
1374 [(set GR16:$dst, (xor GR16:$src1, GR16:$src2))]>, OpSize;
1375 def XOR32rr : I<0x31, MRMDestReg,
1376 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
1377 "xor{l}\t{$src2, $dst|$dst, $src2}",
1378 [(set GR32:$dst, (xor GR32:$src1, GR32:$src2))]>;
Evan Cheng6f26e8b2008-06-18 08:13:07 +00001379} // isCommutable = 1
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001380
1381def XOR8rm : I<0x32, MRMSrcMem ,
Evan Chengb783fa32007-07-19 01:14:50 +00001382 (outs GR8 :$dst), (ins GR8:$src1, i8mem :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001383 "xor{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001384 [(set GR8:$dst, (xor GR8:$src1, (load addr:$src2)))]>;
1385def XOR16rm : I<0x33, MRMSrcMem ,
Evan Chengb783fa32007-07-19 01:14:50 +00001386 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001387 "xor{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingba5d5b02008-05-29 01:02:09 +00001388 [(set GR16:$dst, (xor GR16:$src1, (load addr:$src2)))]>,
1389 OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001390def XOR32rm : I<0x33, MRMSrcMem ,
Evan Chengb783fa32007-07-19 01:14:50 +00001391 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001392 "xor{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001393 [(set GR32:$dst, (xor GR32:$src1, (load addr:$src2)))]>;
1394
Bill Wendlingbac38eb2008-05-29 03:46:36 +00001395def XOR8ri : Ii8<0x80, MRM6r,
1396 (outs GR8:$dst), (ins GR8:$src1, i8imm:$src2),
1397 "xor{b}\t{$src2, $dst|$dst, $src2}",
1398 [(set GR8:$dst, (xor GR8:$src1, imm:$src2))]>;
1399def XOR16ri : Ii16<0x81, MRM6r,
1400 (outs GR16:$dst), (ins GR16:$src1, i16imm:$src2),
1401 "xor{w}\t{$src2, $dst|$dst, $src2}",
1402 [(set GR16:$dst, (xor GR16:$src1, imm:$src2))]>, OpSize;
1403def XOR32ri : Ii32<0x81, MRM6r,
1404 (outs GR32:$dst), (ins GR32:$src1, i32imm:$src2),
1405 "xor{l}\t{$src2, $dst|$dst, $src2}",
1406 [(set GR32:$dst, (xor GR32:$src1, imm:$src2))]>;
1407def XOR16ri8 : Ii8<0x83, MRM6r,
1408 (outs GR16:$dst), (ins GR16:$src1, i16i8imm:$src2),
1409 "xor{w}\t{$src2, $dst|$dst, $src2}",
1410 [(set GR16:$dst, (xor GR16:$src1, i16immSExt8:$src2))]>,
1411 OpSize;
1412def XOR32ri8 : Ii8<0x83, MRM6r,
1413 (outs GR32:$dst), (ins GR32:$src1, i32i8imm:$src2),
1414 "xor{l}\t{$src2, $dst|$dst, $src2}",
1415 [(set GR32:$dst, (xor GR32:$src1, i32immSExt8:$src2))]>;
Bill Wendlingba5d5b02008-05-29 01:02:09 +00001416
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001417let isTwoAddress = 0 in {
1418 def XOR8mr : I<0x30, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001419 (outs), (ins i8mem :$dst, GR8 :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001420 "xor{b}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001421 [(store (xor (load addr:$dst), GR8:$src), addr:$dst)]>;
1422 def XOR16mr : I<0x31, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001423 (outs), (ins i16mem:$dst, GR16:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001424 "xor{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001425 [(store (xor (load addr:$dst), GR16:$src), addr:$dst)]>,
1426 OpSize;
1427 def XOR32mr : I<0x31, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001428 (outs), (ins i32mem:$dst, GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001429 "xor{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001430 [(store (xor (load addr:$dst), GR32:$src), addr:$dst)]>;
1431 def XOR8mi : Ii8<0x80, MRM6m,
Evan Chengb783fa32007-07-19 01:14:50 +00001432 (outs), (ins i8mem :$dst, i8imm :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001433 "xor{b}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001434 [(store (xor (loadi8 addr:$dst), imm:$src), addr:$dst)]>;
1435 def XOR16mi : Ii16<0x81, MRM6m,
Evan Chengb783fa32007-07-19 01:14:50 +00001436 (outs), (ins i16mem:$dst, i16imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001437 "xor{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001438 [(store (xor (loadi16 addr:$dst), imm:$src), addr:$dst)]>,
1439 OpSize;
1440 def XOR32mi : Ii32<0x81, MRM6m,
Evan Chengb783fa32007-07-19 01:14:50 +00001441 (outs), (ins i32mem:$dst, i32imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001442 "xor{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001443 [(store (xor (loadi32 addr:$dst), imm:$src), addr:$dst)]>;
1444 def XOR16mi8 : Ii8<0x83, MRM6m,
Evan Chengb783fa32007-07-19 01:14:50 +00001445 (outs), (ins i16mem:$dst, i16i8imm :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001446 "xor{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001447 [(store (xor (load addr:$dst), i16immSExt8:$src), addr:$dst)]>,
1448 OpSize;
1449 def XOR32mi8 : Ii8<0x83, MRM6m,
Evan Chengb783fa32007-07-19 01:14:50 +00001450 (outs), (ins i32mem:$dst, i32i8imm :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001451 "xor{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001452 [(store (xor (load addr:$dst), i32immSExt8:$src), addr:$dst)]>;
Bill Wendlingba5d5b02008-05-29 01:02:09 +00001453} // isTwoAddress = 0
Evan Cheng55687072007-09-14 21:48:26 +00001454} // Defs = [EFLAGS]
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001455
1456// Shift instructions
Evan Cheng55687072007-09-14 21:48:26 +00001457let Defs = [EFLAGS] in {
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001458let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00001459def SHL8rCL : I<0xD2, MRM4r, (outs GR8 :$dst), (ins GR8 :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001460 "shl{b}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001461 [(set GR8:$dst, (shl GR8:$src, CL))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001462def SHL16rCL : I<0xD3, MRM4r, (outs GR16:$dst), (ins GR16:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001463 "shl{w}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001464 [(set GR16:$dst, (shl GR16:$src, CL))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001465def SHL32rCL : I<0xD3, MRM4r, (outs GR32:$dst), (ins GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001466 "shl{l}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001467 [(set GR32:$dst, (shl GR32:$src, CL))]>;
Bill Wendlingba5d5b02008-05-29 01:02:09 +00001468} // Uses = [CL]
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001469
Evan Chengb783fa32007-07-19 01:14:50 +00001470def SHL8ri : Ii8<0xC0, MRM4r, (outs GR8 :$dst), (ins GR8 :$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001471 "shl{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001472 [(set GR8:$dst, (shl GR8:$src1, (i8 imm:$src2)))]>;
1473let isConvertibleToThreeAddress = 1 in { // Can transform into LEA.
Evan Chengb783fa32007-07-19 01:14:50 +00001474def SHL16ri : Ii8<0xC1, MRM4r, (outs GR16:$dst), (ins GR16:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001475 "shl{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001476 [(set GR16:$dst, (shl GR16:$src1, (i8 imm:$src2)))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001477def SHL32ri : Ii8<0xC1, MRM4r, (outs GR32:$dst), (ins GR32:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001478 "shl{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001479 [(set GR32:$dst, (shl GR32:$src1, (i8 imm:$src2)))]>;
Chris Lattnerf4005a82008-01-11 18:00:50 +00001480// NOTE: We don't use shifts of a register by one, because 'add reg,reg' is
1481// cheaper.
Bill Wendlingba5d5b02008-05-29 01:02:09 +00001482} // isConvertibleToThreeAddress = 1
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001483
1484let isTwoAddress = 0 in {
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001485 let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00001486 def SHL8mCL : I<0xD2, MRM4m, (outs), (ins i8mem :$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001487 "shl{b}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001488 [(store (shl (loadi8 addr:$dst), CL), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001489 def SHL16mCL : I<0xD3, MRM4m, (outs), (ins i16mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001490 "shl{w}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001491 [(store (shl (loadi16 addr:$dst), CL), addr:$dst)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001492 def SHL32mCL : I<0xD3, MRM4m, (outs), (ins i32mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001493 "shl{l}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001494 [(store (shl (loadi32 addr:$dst), CL), addr:$dst)]>;
1495 }
Evan Chengb783fa32007-07-19 01:14:50 +00001496 def SHL8mi : Ii8<0xC0, MRM4m, (outs), (ins i8mem :$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001497 "shl{b}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001498 [(store (shl (loadi8 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001499 def SHL16mi : Ii8<0xC1, MRM4m, (outs), (ins i16mem:$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001500 "shl{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001501 [(store (shl (loadi16 addr:$dst), (i8 imm:$src)), addr:$dst)]>,
1502 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001503 def SHL32mi : Ii8<0xC1, MRM4m, (outs), (ins i32mem:$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001504 "shl{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001505 [(store (shl (loadi32 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
1506
1507 // Shift by 1
Evan Chengb783fa32007-07-19 01:14:50 +00001508 def SHL8m1 : I<0xD0, MRM4m, (outs), (ins i8mem :$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001509 "shl{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001510 [(store (shl (loadi8 addr:$dst), (i8 1)), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001511 def SHL16m1 : I<0xD1, MRM4m, (outs), (ins i16mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001512 "shl{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001513 [(store (shl (loadi16 addr:$dst), (i8 1)), addr:$dst)]>,
1514 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001515 def SHL32m1 : I<0xD1, MRM4m, (outs), (ins i32mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001516 "shl{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001517 [(store (shl (loadi32 addr:$dst), (i8 1)), addr:$dst)]>;
1518}
1519
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001520let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00001521def SHR8rCL : I<0xD2, MRM5r, (outs GR8 :$dst), (ins GR8 :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001522 "shr{b}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001523 [(set GR8:$dst, (srl GR8:$src, CL))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001524def SHR16rCL : I<0xD3, MRM5r, (outs GR16:$dst), (ins GR16:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001525 "shr{w}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001526 [(set GR16:$dst, (srl GR16:$src, CL))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001527def SHR32rCL : I<0xD3, MRM5r, (outs GR32:$dst), (ins GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001528 "shr{l}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001529 [(set GR32:$dst, (srl GR32:$src, CL))]>;
1530}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001531
Evan Chengb783fa32007-07-19 01:14:50 +00001532def SHR8ri : Ii8<0xC0, MRM5r, (outs GR8:$dst), (ins GR8:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001533 "shr{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001534 [(set GR8:$dst, (srl GR8:$src1, (i8 imm:$src2)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001535def SHR16ri : Ii8<0xC1, MRM5r, (outs GR16:$dst), (ins GR16:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001536 "shr{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001537 [(set GR16:$dst, (srl GR16:$src1, (i8 imm:$src2)))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001538def SHR32ri : Ii8<0xC1, MRM5r, (outs GR32:$dst), (ins GR32:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001539 "shr{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001540 [(set GR32:$dst, (srl GR32:$src1, (i8 imm:$src2)))]>;
1541
1542// Shift by 1
Evan Chengb783fa32007-07-19 01:14:50 +00001543def SHR8r1 : I<0xD0, MRM5r, (outs GR8:$dst), (ins GR8:$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00001544 "shr{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001545 [(set GR8:$dst, (srl GR8:$src1, (i8 1)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001546def SHR16r1 : I<0xD1, MRM5r, (outs GR16:$dst), (ins GR16:$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00001547 "shr{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001548 [(set GR16:$dst, (srl GR16:$src1, (i8 1)))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001549def SHR32r1 : I<0xD1, MRM5r, (outs GR32:$dst), (ins GR32:$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00001550 "shr{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001551 [(set GR32:$dst, (srl GR32:$src1, (i8 1)))]>;
1552
1553let isTwoAddress = 0 in {
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001554 let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00001555 def SHR8mCL : I<0xD2, MRM5m, (outs), (ins i8mem :$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001556 "shr{b}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001557 [(store (srl (loadi8 addr:$dst), CL), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001558 def SHR16mCL : I<0xD3, MRM5m, (outs), (ins i16mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001559 "shr{w}\t{%cl, $dst|$dst, %CL}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001560 [(store (srl (loadi16 addr:$dst), CL), addr:$dst)]>,
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001561 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001562 def SHR32mCL : I<0xD3, MRM5m, (outs), (ins i32mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001563 "shr{l}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001564 [(store (srl (loadi32 addr:$dst), CL), addr:$dst)]>;
1565 }
Evan Chengb783fa32007-07-19 01:14:50 +00001566 def SHR8mi : Ii8<0xC0, MRM5m, (outs), (ins i8mem :$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001567 "shr{b}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001568 [(store (srl (loadi8 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001569 def SHR16mi : Ii8<0xC1, MRM5m, (outs), (ins i16mem:$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001570 "shr{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001571 [(store (srl (loadi16 addr:$dst), (i8 imm:$src)), addr:$dst)]>,
1572 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001573 def SHR32mi : Ii8<0xC1, MRM5m, (outs), (ins i32mem:$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001574 "shr{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001575 [(store (srl (loadi32 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
1576
1577 // Shift by 1
Evan Chengb783fa32007-07-19 01:14:50 +00001578 def SHR8m1 : I<0xD0, MRM5m, (outs), (ins i8mem :$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001579 "shr{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001580 [(store (srl (loadi8 addr:$dst), (i8 1)), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001581 def SHR16m1 : I<0xD1, MRM5m, (outs), (ins i16mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001582 "shr{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001583 [(store (srl (loadi16 addr:$dst), (i8 1)), addr:$dst)]>,OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001584 def SHR32m1 : I<0xD1, MRM5m, (outs), (ins i32mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001585 "shr{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001586 [(store (srl (loadi32 addr:$dst), (i8 1)), addr:$dst)]>;
1587}
1588
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001589let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00001590def SAR8rCL : I<0xD2, MRM7r, (outs GR8 :$dst), (ins GR8 :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001591 "sar{b}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001592 [(set GR8:$dst, (sra GR8:$src, CL))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001593def SAR16rCL : I<0xD3, MRM7r, (outs GR16:$dst), (ins GR16:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001594 "sar{w}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001595 [(set GR16:$dst, (sra GR16:$src, CL))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001596def SAR32rCL : I<0xD3, MRM7r, (outs GR32:$dst), (ins GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001597 "sar{l}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001598 [(set GR32:$dst, (sra GR32:$src, CL))]>;
1599}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001600
Evan Chengb783fa32007-07-19 01:14:50 +00001601def SAR8ri : Ii8<0xC0, MRM7r, (outs GR8 :$dst), (ins GR8 :$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001602 "sar{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001603 [(set GR8:$dst, (sra GR8:$src1, (i8 imm:$src2)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001604def SAR16ri : Ii8<0xC1, MRM7r, (outs GR16:$dst), (ins GR16:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001605 "sar{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001606 [(set GR16:$dst, (sra GR16:$src1, (i8 imm:$src2)))]>,
1607 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001608def SAR32ri : Ii8<0xC1, MRM7r, (outs GR32:$dst), (ins GR32:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001609 "sar{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001610 [(set GR32:$dst, (sra GR32:$src1, (i8 imm:$src2)))]>;
1611
1612// Shift by 1
Evan Chengb783fa32007-07-19 01:14:50 +00001613def SAR8r1 : I<0xD0, MRM7r, (outs GR8 :$dst), (ins GR8 :$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00001614 "sar{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001615 [(set GR8:$dst, (sra GR8:$src1, (i8 1)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001616def SAR16r1 : I<0xD1, MRM7r, (outs GR16:$dst), (ins GR16:$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00001617 "sar{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001618 [(set GR16:$dst, (sra GR16:$src1, (i8 1)))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001619def SAR32r1 : I<0xD1, MRM7r, (outs GR32:$dst), (ins GR32:$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00001620 "sar{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001621 [(set GR32:$dst, (sra GR32:$src1, (i8 1)))]>;
1622
1623let isTwoAddress = 0 in {
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001624 let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00001625 def SAR8mCL : I<0xD2, MRM7m, (outs), (ins i8mem :$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001626 "sar{b}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001627 [(store (sra (loadi8 addr:$dst), CL), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001628 def SAR16mCL : I<0xD3, MRM7m, (outs), (ins i16mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001629 "sar{w}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001630 [(store (sra (loadi16 addr:$dst), CL), addr:$dst)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001631 def SAR32mCL : I<0xD3, MRM7m, (outs), (ins i32mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001632 "sar{l}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001633 [(store (sra (loadi32 addr:$dst), CL), addr:$dst)]>;
1634 }
Evan Chengb783fa32007-07-19 01:14:50 +00001635 def SAR8mi : Ii8<0xC0, MRM7m, (outs), (ins i8mem :$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001636 "sar{b}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001637 [(store (sra (loadi8 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001638 def SAR16mi : Ii8<0xC1, MRM7m, (outs), (ins i16mem:$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001639 "sar{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001640 [(store (sra (loadi16 addr:$dst), (i8 imm:$src)), addr:$dst)]>,
1641 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001642 def SAR32mi : Ii8<0xC1, MRM7m, (outs), (ins i32mem:$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001643 "sar{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001644 [(store (sra (loadi32 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
1645
1646 // Shift by 1
Evan Chengb783fa32007-07-19 01:14:50 +00001647 def SAR8m1 : I<0xD0, MRM7m, (outs), (ins i8mem :$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001648 "sar{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001649 [(store (sra (loadi8 addr:$dst), (i8 1)), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001650 def SAR16m1 : I<0xD1, MRM7m, (outs), (ins i16mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001651 "sar{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001652 [(store (sra (loadi16 addr:$dst), (i8 1)), addr:$dst)]>,
1653 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001654 def SAR32m1 : I<0xD1, MRM7m, (outs), (ins i32mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001655 "sar{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001656 [(store (sra (loadi32 addr:$dst), (i8 1)), addr:$dst)]>;
1657}
1658
1659// Rotate instructions
1660// FIXME: provide shorter instructions when imm8 == 1
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001661let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00001662def ROL8rCL : I<0xD2, MRM0r, (outs GR8 :$dst), (ins GR8 :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001663 "rol{b}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001664 [(set GR8:$dst, (rotl GR8:$src, CL))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001665def ROL16rCL : I<0xD3, MRM0r, (outs GR16:$dst), (ins GR16:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001666 "rol{w}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001667 [(set GR16:$dst, (rotl GR16:$src, CL))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001668def ROL32rCL : I<0xD3, MRM0r, (outs GR32:$dst), (ins GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001669 "rol{l}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001670 [(set GR32:$dst, (rotl GR32:$src, CL))]>;
1671}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001672
Evan Chengb783fa32007-07-19 01:14:50 +00001673def ROL8ri : Ii8<0xC0, MRM0r, (outs GR8 :$dst), (ins GR8 :$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001674 "rol{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001675 [(set GR8:$dst, (rotl GR8:$src1, (i8 imm:$src2)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001676def ROL16ri : Ii8<0xC1, MRM0r, (outs GR16:$dst), (ins GR16:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001677 "rol{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001678 [(set GR16:$dst, (rotl GR16:$src1, (i8 imm:$src2)))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001679def ROL32ri : Ii8<0xC1, MRM0r, (outs GR32:$dst), (ins GR32:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001680 "rol{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001681 [(set GR32:$dst, (rotl GR32:$src1, (i8 imm:$src2)))]>;
1682
1683// Rotate by 1
Evan Chengb783fa32007-07-19 01:14:50 +00001684def ROL8r1 : I<0xD0, MRM0r, (outs GR8 :$dst), (ins GR8 :$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00001685 "rol{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001686 [(set GR8:$dst, (rotl GR8:$src1, (i8 1)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001687def ROL16r1 : I<0xD1, MRM0r, (outs GR16:$dst), (ins GR16:$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00001688 "rol{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001689 [(set GR16:$dst, (rotl GR16:$src1, (i8 1)))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001690def ROL32r1 : I<0xD1, MRM0r, (outs GR32:$dst), (ins GR32:$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00001691 "rol{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001692 [(set GR32:$dst, (rotl GR32:$src1, (i8 1)))]>;
1693
1694let isTwoAddress = 0 in {
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001695 let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00001696 def ROL8mCL : I<0xD2, MRM0m, (outs), (ins i8mem :$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001697 "rol{b}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001698 [(store (rotl (loadi8 addr:$dst), CL), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001699 def ROL16mCL : I<0xD3, MRM0m, (outs), (ins i16mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001700 "rol{w}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001701 [(store (rotl (loadi16 addr:$dst), CL), addr:$dst)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001702 def ROL32mCL : I<0xD3, MRM0m, (outs), (ins i32mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001703 "rol{l}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001704 [(store (rotl (loadi32 addr:$dst), CL), addr:$dst)]>;
1705 }
Evan Chengb783fa32007-07-19 01:14:50 +00001706 def ROL8mi : Ii8<0xC0, MRM0m, (outs), (ins i8mem :$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001707 "rol{b}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001708 [(store (rotl (loadi8 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001709 def ROL16mi : Ii8<0xC1, MRM0m, (outs), (ins i16mem:$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001710 "rol{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001711 [(store (rotl (loadi16 addr:$dst), (i8 imm:$src)), addr:$dst)]>,
1712 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001713 def ROL32mi : Ii8<0xC1, MRM0m, (outs), (ins i32mem:$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001714 "rol{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001715 [(store (rotl (loadi32 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
1716
1717 // Rotate by 1
Evan Chengb783fa32007-07-19 01:14:50 +00001718 def ROL8m1 : I<0xD0, MRM0m, (outs), (ins i8mem :$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001719 "rol{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001720 [(store (rotl (loadi8 addr:$dst), (i8 1)), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001721 def ROL16m1 : I<0xD1, MRM0m, (outs), (ins i16mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001722 "rol{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001723 [(store (rotl (loadi16 addr:$dst), (i8 1)), addr:$dst)]>,
1724 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001725 def ROL32m1 : I<0xD1, MRM0m, (outs), (ins i32mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001726 "rol{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001727 [(store (rotl (loadi32 addr:$dst), (i8 1)), addr:$dst)]>;
1728}
1729
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001730let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00001731def ROR8rCL : I<0xD2, MRM1r, (outs GR8 :$dst), (ins GR8 :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001732 "ror{b}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001733 [(set GR8:$dst, (rotr GR8:$src, CL))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001734def ROR16rCL : I<0xD3, MRM1r, (outs GR16:$dst), (ins GR16:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001735 "ror{w}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001736 [(set GR16:$dst, (rotr GR16:$src, CL))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001737def ROR32rCL : I<0xD3, MRM1r, (outs GR32:$dst), (ins GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001738 "ror{l}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001739 [(set GR32:$dst, (rotr GR32:$src, CL))]>;
1740}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001741
Evan Chengb783fa32007-07-19 01:14:50 +00001742def ROR8ri : Ii8<0xC0, MRM1r, (outs GR8 :$dst), (ins GR8 :$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001743 "ror{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001744 [(set GR8:$dst, (rotr GR8:$src1, (i8 imm:$src2)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001745def ROR16ri : Ii8<0xC1, MRM1r, (outs GR16:$dst), (ins GR16:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001746 "ror{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001747 [(set GR16:$dst, (rotr GR16:$src1, (i8 imm:$src2)))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001748def ROR32ri : Ii8<0xC1, MRM1r, (outs GR32:$dst), (ins GR32:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001749 "ror{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001750 [(set GR32:$dst, (rotr GR32:$src1, (i8 imm:$src2)))]>;
1751
1752// Rotate by 1
Evan Chengb783fa32007-07-19 01:14:50 +00001753def ROR8r1 : I<0xD0, MRM1r, (outs GR8 :$dst), (ins GR8 :$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00001754 "ror{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001755 [(set GR8:$dst, (rotr GR8:$src1, (i8 1)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001756def ROR16r1 : I<0xD1, MRM1r, (outs GR16:$dst), (ins GR16:$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00001757 "ror{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001758 [(set GR16:$dst, (rotr GR16:$src1, (i8 1)))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001759def ROR32r1 : I<0xD1, MRM1r, (outs GR32:$dst), (ins GR32:$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00001760 "ror{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001761 [(set GR32:$dst, (rotr GR32:$src1, (i8 1)))]>;
1762
1763let isTwoAddress = 0 in {
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001764 let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00001765 def ROR8mCL : I<0xD2, MRM1m, (outs), (ins i8mem :$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001766 "ror{b}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001767 [(store (rotr (loadi8 addr:$dst), CL), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001768 def ROR16mCL : I<0xD3, MRM1m, (outs), (ins i16mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001769 "ror{w}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001770 [(store (rotr (loadi16 addr:$dst), CL), addr:$dst)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001771 def ROR32mCL : I<0xD3, MRM1m, (outs), (ins i32mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001772 "ror{l}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001773 [(store (rotr (loadi32 addr:$dst), CL), addr:$dst)]>;
1774 }
Evan Chengb783fa32007-07-19 01:14:50 +00001775 def ROR8mi : Ii8<0xC0, MRM1m, (outs), (ins i8mem :$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001776 "ror{b}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001777 [(store (rotr (loadi8 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001778 def ROR16mi : Ii8<0xC1, MRM1m, (outs), (ins i16mem:$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001779 "ror{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001780 [(store (rotr (loadi16 addr:$dst), (i8 imm:$src)), addr:$dst)]>,
1781 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001782 def ROR32mi : Ii8<0xC1, MRM1m, (outs), (ins i32mem:$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001783 "ror{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001784 [(store (rotr (loadi32 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
1785
1786 // Rotate by 1
Evan Chengb783fa32007-07-19 01:14:50 +00001787 def ROR8m1 : I<0xD0, MRM1m, (outs), (ins i8mem :$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001788 "ror{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001789 [(store (rotr (loadi8 addr:$dst), (i8 1)), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001790 def ROR16m1 : I<0xD1, MRM1m, (outs), (ins i16mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001791 "ror{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001792 [(store (rotr (loadi16 addr:$dst), (i8 1)), addr:$dst)]>,
1793 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001794 def ROR32m1 : I<0xD1, MRM1m, (outs), (ins i32mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001795 "ror{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001796 [(store (rotr (loadi32 addr:$dst), (i8 1)), addr:$dst)]>;
1797}
1798
1799
1800
1801// Double shift instructions (generalizations of rotate)
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001802let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00001803def SHLD32rrCL : I<0xA5, MRMDestReg, (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001804 "shld{l}\t{%cl, $src2, $dst|$dst, $src2, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001805 [(set GR32:$dst, (X86shld GR32:$src1, GR32:$src2, CL))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00001806def SHRD32rrCL : I<0xAD, MRMDestReg, (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001807 "shrd{l}\t{%cl, $src2, $dst|$dst, $src2, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001808 [(set GR32:$dst, (X86shrd GR32:$src1, GR32:$src2, CL))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00001809def SHLD16rrCL : I<0xA5, MRMDestReg, (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001810 "shld{w}\t{%cl, $src2, $dst|$dst, $src2, %CL}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001811 [(set GR16:$dst, (X86shld GR16:$src1, GR16:$src2, CL))]>,
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001812 TB, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001813def SHRD16rrCL : I<0xAD, MRMDestReg, (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001814 "shrd{w}\t{%cl, $src2, $dst|$dst, $src2, %CL}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001815 [(set GR16:$dst, (X86shrd GR16:$src1, GR16:$src2, CL))]>,
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001816 TB, OpSize;
1817}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001818
1819let isCommutable = 1 in { // These instructions commute to each other.
1820def SHLD32rri8 : Ii8<0xA4, MRMDestReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001821 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2, i8imm:$src3),
Dan Gohman91888f02007-07-31 20:11:57 +00001822 "shld{l}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001823 [(set GR32:$dst, (X86shld GR32:$src1, GR32:$src2,
1824 (i8 imm:$src3)))]>,
1825 TB;
1826def SHRD32rri8 : Ii8<0xAC, MRMDestReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001827 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2, i8imm:$src3),
Dan Gohman91888f02007-07-31 20:11:57 +00001828 "shrd{l}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001829 [(set GR32:$dst, (X86shrd GR32:$src1, GR32:$src2,
1830 (i8 imm:$src3)))]>,
1831 TB;
1832def SHLD16rri8 : Ii8<0xA4, MRMDestReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001833 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2, i8imm:$src3),
Dan Gohman91888f02007-07-31 20:11:57 +00001834 "shld{w}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001835 [(set GR16:$dst, (X86shld GR16:$src1, GR16:$src2,
1836 (i8 imm:$src3)))]>,
1837 TB, OpSize;
1838def SHRD16rri8 : Ii8<0xAC, MRMDestReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001839 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2, i8imm:$src3),
Dan Gohman91888f02007-07-31 20:11:57 +00001840 "shrd{w}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001841 [(set GR16:$dst, (X86shrd GR16:$src1, GR16:$src2,
1842 (i8 imm:$src3)))]>,
1843 TB, OpSize;
1844}
1845
1846let isTwoAddress = 0 in {
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001847 let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00001848 def SHLD32mrCL : I<0xA5, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001849 "shld{l}\t{%cl, $src2, $dst|$dst, $src2, %CL}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001850 [(store (X86shld (loadi32 addr:$dst), GR32:$src2, CL),
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001851 addr:$dst)]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00001852 def SHRD32mrCL : I<0xAD, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001853 "shrd{l}\t{%cl, $src2, $dst|$dst, $src2, %CL}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001854 [(store (X86shrd (loadi32 addr:$dst), GR32:$src2, CL),
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001855 addr:$dst)]>, TB;
1856 }
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001857 def SHLD32mri8 : Ii8<0xA4, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001858 (outs), (ins i32mem:$dst, GR32:$src2, i8imm:$src3),
Dan Gohman91888f02007-07-31 20:11:57 +00001859 "shld{l}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001860 [(store (X86shld (loadi32 addr:$dst), GR32:$src2,
1861 (i8 imm:$src3)), addr:$dst)]>,
1862 TB;
1863 def SHRD32mri8 : Ii8<0xAC, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001864 (outs), (ins i32mem:$dst, GR32:$src2, i8imm:$src3),
Dan Gohman91888f02007-07-31 20:11:57 +00001865 "shrd{l}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001866 [(store (X86shrd (loadi32 addr:$dst), GR32:$src2,
1867 (i8 imm:$src3)), addr:$dst)]>,
1868 TB;
1869
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001870 let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00001871 def SHLD16mrCL : I<0xA5, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001872 "shld{w}\t{%cl, $src2, $dst|$dst, $src2, %CL}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001873 [(store (X86shld (loadi16 addr:$dst), GR16:$src2, CL),
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001874 addr:$dst)]>, TB, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001875 def SHRD16mrCL : I<0xAD, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001876 "shrd{w}\t{%cl, $src2, $dst|$dst, $src2, %CL}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001877 [(store (X86shrd (loadi16 addr:$dst), GR16:$src2, CL),
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001878 addr:$dst)]>, TB, OpSize;
1879 }
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001880 def SHLD16mri8 : Ii8<0xA4, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001881 (outs), (ins i16mem:$dst, GR16:$src2, i8imm:$src3),
Dan Gohman91888f02007-07-31 20:11:57 +00001882 "shld{w}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001883 [(store (X86shld (loadi16 addr:$dst), GR16:$src2,
1884 (i8 imm:$src3)), addr:$dst)]>,
1885 TB, OpSize;
1886 def SHRD16mri8 : Ii8<0xAC, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001887 (outs), (ins i16mem:$dst, GR16:$src2, i8imm:$src3),
Dan Gohman91888f02007-07-31 20:11:57 +00001888 "shrd{w}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001889 [(store (X86shrd (loadi16 addr:$dst), GR16:$src2,
1890 (i8 imm:$src3)), addr:$dst)]>,
1891 TB, OpSize;
1892}
Evan Cheng55687072007-09-14 21:48:26 +00001893} // Defs = [EFLAGS]
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001894
1895
1896// Arithmetic.
Evan Cheng55687072007-09-14 21:48:26 +00001897let Defs = [EFLAGS] in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001898let isCommutable = 1 in { // X = ADD Y, Z --> X = ADD Z, Y
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001899def ADD8rr : I<0x00, MRMDestReg, (outs GR8 :$dst),
1900 (ins GR8 :$src1, GR8 :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001901 "add{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001902 [(set GR8:$dst, (add GR8:$src1, GR8:$src2))]>;
1903let isConvertibleToThreeAddress = 1 in { // Can transform into LEA.
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001904def ADD16rr : I<0x01, MRMDestReg, (outs GR16:$dst),
1905 (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001906 "add{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001907 [(set GR16:$dst, (add GR16:$src1, GR16:$src2))]>, OpSize;
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001908def ADD32rr : I<0x01, MRMDestReg, (outs GR32:$dst),
1909 (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001910 "add{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001911 [(set GR32:$dst, (add GR32:$src1, GR32:$src2))]>;
1912} // end isConvertibleToThreeAddress
1913} // end isCommutable
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001914def ADD8rm : I<0x02, MRMSrcMem, (outs GR8 :$dst),
1915 (ins GR8 :$src1, i8mem :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001916 "add{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001917 [(set GR8:$dst, (add GR8:$src1, (load addr:$src2)))]>;
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001918def ADD16rm : I<0x03, MRMSrcMem, (outs GR16:$dst),
1919 (ins GR16:$src1, i16mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001920 "add{w}\t{$src2, $dst|$dst, $src2}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001921 [(set GR16:$dst, (add GR16:$src1, (load addr:$src2)))]>,OpSize;
1922def ADD32rm : I<0x03, MRMSrcMem, (outs GR32:$dst),
1923 (ins GR32:$src1, i32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001924 "add{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001925 [(set GR32:$dst, (add GR32:$src1, (load addr:$src2)))]>;
1926
Evan Chengb783fa32007-07-19 01:14:50 +00001927def ADD8ri : Ii8<0x80, MRM0r, (outs GR8:$dst), (ins GR8:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001928 "add{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001929 [(set GR8:$dst, (add GR8:$src1, imm:$src2))]>;
1930
1931let isConvertibleToThreeAddress = 1 in { // Can transform into LEA.
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001932def ADD16ri : Ii16<0x81, MRM0r, (outs GR16:$dst),
1933 (ins GR16:$src1, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001934 "add{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001935 [(set GR16:$dst, (add GR16:$src1, imm:$src2))]>, OpSize;
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001936def ADD32ri : Ii32<0x81, MRM0r, (outs GR32:$dst),
1937 (ins GR32:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001938 "add{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001939 [(set GR32:$dst, (add GR32:$src1, imm:$src2))]>;
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001940def ADD16ri8 : Ii8<0x83, MRM0r, (outs GR16:$dst),
1941 (ins GR16:$src1, i16i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001942 "add{w}\t{$src2, $dst|$dst, $src2}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001943 [(set GR16:$dst, (add GR16:$src1, i16immSExt8:$src2))]>, OpSize;
1944def ADD32ri8 : Ii8<0x83, MRM0r, (outs GR32:$dst),
1945 (ins GR32:$src1, i32i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001946 "add{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001947 [(set GR32:$dst, (add GR32:$src1, i32immSExt8:$src2))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001948}
1949
1950let isTwoAddress = 0 in {
Evan Chengb783fa32007-07-19 01:14:50 +00001951 def ADD8mr : I<0x00, MRMDestMem, (outs), (ins i8mem :$dst, GR8 :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001952 "add{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001953 [(store (add (load addr:$dst), GR8:$src2), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001954 def ADD16mr : I<0x01, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001955 "add{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001956 [(store (add (load addr:$dst), GR16:$src2), addr:$dst)]>,
Evan Cheng55687072007-09-14 21:48:26 +00001957 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001958 def ADD32mr : I<0x01, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001959 "add{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001960 [(store (add (load addr:$dst), GR32:$src2), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001961 def ADD8mi : Ii8<0x80, MRM0m, (outs), (ins i8mem :$dst, i8imm :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001962 "add{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001963 [(store (add (loadi8 addr:$dst), imm:$src2), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001964 def ADD16mi : Ii16<0x81, MRM0m, (outs), (ins i16mem:$dst, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001965 "add{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001966 [(store (add (loadi16 addr:$dst), imm:$src2), addr:$dst)]>,
Evan Cheng55687072007-09-14 21:48:26 +00001967 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001968 def ADD32mi : Ii32<0x81, MRM0m, (outs), (ins i32mem:$dst, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001969 "add{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001970 [(store (add (loadi32 addr:$dst), imm:$src2), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001971 def ADD16mi8 : Ii8<0x83, MRM0m, (outs), (ins i16mem:$dst, i16i8imm :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001972 "add{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001973 [(store (add (load addr:$dst), i16immSExt8:$src2), addr:$dst)]>,
Evan Cheng55687072007-09-14 21:48:26 +00001974 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001975 def ADD32mi8 : Ii8<0x83, MRM0m, (outs), (ins i32mem:$dst, i32i8imm :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001976 "add{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001977 [(store (add (load addr:$dst), i32immSExt8:$src2), addr:$dst)]>;
1978}
1979
Evan Cheng259471d2007-10-05 17:59:57 +00001980let Uses = [EFLAGS] in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001981let isCommutable = 1 in { // X = ADC Y, Z --> X = ADC Z, Y
Evan Chengb783fa32007-07-19 01:14:50 +00001982def ADC32rr : I<0x11, MRMDestReg, (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001983 "adc{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001984 [(set GR32:$dst, (adde GR32:$src1, GR32:$src2))]>;
1985}
Evan Chengb783fa32007-07-19 01:14:50 +00001986def ADC32rm : I<0x13, MRMSrcMem , (outs GR32:$dst), (ins GR32:$src1, i32mem:$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, (load addr:$src2)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001989def ADC32ri : Ii32<0x81, MRM2r, (outs GR32:$dst), (ins GR32:$src1, i32imm:$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, imm:$src2))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001992def ADC32ri8 : Ii8<0x83, MRM2r, (outs GR32:$dst), (ins GR32:$src1, i32i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001993 "adc{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001994 [(set GR32:$dst, (adde GR32:$src1, i32immSExt8:$src2))]>;
1995
1996let isTwoAddress = 0 in {
Evan Chengb783fa32007-07-19 01:14:50 +00001997 def ADC32mr : I<0x11, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$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 (load addr:$dst), GR32:$src2), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002000 def ADC32mi : Ii32<0x81, MRM2m, (outs), (ins i32mem:$dst, i32imm:$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 (loadi32 addr:$dst), imm:$src2), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002003 def ADC32mi8 : Ii8<0x83, MRM2m, (outs), (ins i32mem:$dst, i32i8imm :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002004 "adc{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002005 [(store (adde (load addr:$dst), i32immSExt8:$src2), addr:$dst)]>;
2006}
Evan Cheng259471d2007-10-05 17:59:57 +00002007} // Uses = [EFLAGS]
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002008
Evan Chengb783fa32007-07-19 01:14:50 +00002009def SUB8rr : I<0x28, MRMDestReg, (outs GR8 :$dst), (ins GR8 :$src1, GR8 :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002010 "sub{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002011 [(set GR8:$dst, (sub GR8:$src1, GR8:$src2))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002012def SUB16rr : I<0x29, MRMDestReg, (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002013 "sub{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002014 [(set GR16:$dst, (sub GR16:$src1, GR16:$src2))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002015def SUB32rr : I<0x29, MRMDestReg, (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002016 "sub{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002017 [(set GR32:$dst, (sub GR32:$src1, GR32:$src2))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002018def SUB8rm : I<0x2A, MRMSrcMem, (outs GR8 :$dst), (ins GR8 :$src1, i8mem :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002019 "sub{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002020 [(set GR8:$dst, (sub GR8:$src1, (load addr:$src2)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002021def SUB16rm : I<0x2B, MRMSrcMem, (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002022 "sub{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002023 [(set GR16:$dst, (sub GR16:$src1, (load addr:$src2)))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002024def SUB32rm : I<0x2B, MRMSrcMem, (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002025 "sub{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002026 [(set GR32:$dst, (sub GR32:$src1, (load addr:$src2)))]>;
2027
Evan Chengb783fa32007-07-19 01:14:50 +00002028def SUB8ri : Ii8 <0x80, MRM5r, (outs GR8:$dst), (ins GR8:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002029 "sub{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002030 [(set GR8:$dst, (sub GR8:$src1, imm:$src2))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002031def SUB16ri : Ii16<0x81, MRM5r, (outs GR16:$dst), (ins GR16:$src1, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002032 "sub{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002033 [(set GR16:$dst, (sub GR16:$src1, imm:$src2))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002034def SUB32ri : Ii32<0x81, MRM5r, (outs GR32:$dst), (ins GR32:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002035 "sub{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002036 [(set GR32:$dst, (sub GR32:$src1, imm:$src2))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002037def SUB16ri8 : Ii8<0x83, MRM5r, (outs GR16:$dst), (ins GR16:$src1, i16i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002038 "sub{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002039 [(set GR16:$dst, (sub GR16:$src1, i16immSExt8:$src2))]>,
Evan Cheng55687072007-09-14 21:48:26 +00002040 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002041def SUB32ri8 : Ii8<0x83, MRM5r, (outs GR32:$dst), (ins GR32:$src1, i32i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002042 "sub{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002043 [(set GR32:$dst, (sub GR32:$src1, i32immSExt8:$src2))]>;
2044let isTwoAddress = 0 in {
Evan Chengb783fa32007-07-19 01:14:50 +00002045 def SUB8mr : I<0x28, MRMDestMem, (outs), (ins i8mem :$dst, GR8 :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002046 "sub{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002047 [(store (sub (load addr:$dst), GR8:$src2), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002048 def SUB16mr : I<0x29, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002049 "sub{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002050 [(store (sub (load addr:$dst), GR16:$src2), addr:$dst)]>,
Evan Cheng55687072007-09-14 21:48:26 +00002051 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002052 def SUB32mr : I<0x29, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002053 "sub{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002054 [(store (sub (load addr:$dst), GR32:$src2), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002055 def SUB8mi : Ii8<0x80, MRM5m, (outs), (ins i8mem :$dst, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002056 "sub{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002057 [(store (sub (loadi8 addr:$dst), imm:$src2), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002058 def SUB16mi : Ii16<0x81, MRM5m, (outs), (ins i16mem:$dst, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002059 "sub{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002060 [(store (sub (loadi16 addr:$dst), imm:$src2), addr:$dst)]>,
Evan Cheng55687072007-09-14 21:48:26 +00002061 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002062 def SUB32mi : Ii32<0x81, MRM5m, (outs), (ins i32mem:$dst, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002063 "sub{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002064 [(store (sub (loadi32 addr:$dst), imm:$src2), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002065 def SUB16mi8 : Ii8<0x83, MRM5m, (outs), (ins i16mem:$dst, i16i8imm :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002066 "sub{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002067 [(store (sub (load addr:$dst), i16immSExt8:$src2), addr:$dst)]>,
Evan Cheng55687072007-09-14 21:48:26 +00002068 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002069 def SUB32mi8 : Ii8<0x83, MRM5m, (outs), (ins i32mem:$dst, i32i8imm :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002070 "sub{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002071 [(store (sub (load addr:$dst), i32immSExt8:$src2), addr:$dst)]>;
2072}
2073
Evan Cheng259471d2007-10-05 17:59:57 +00002074let Uses = [EFLAGS] in {
Evan Chengb783fa32007-07-19 01:14:50 +00002075def SBB32rr : I<0x19, MRMDestReg, (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002076 "sbb{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng55687072007-09-14 21:48:26 +00002077 [(set GR32:$dst, (sube GR32:$src1, GR32:$src2))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002078
2079let isTwoAddress = 0 in {
Evan Chengb783fa32007-07-19 01:14:50 +00002080 def SBB32mr : I<0x19, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002081 "sbb{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002082 [(store (sube (load addr:$dst), GR32:$src2), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002083 def SBB8mi : Ii32<0x80, MRM3m, (outs), (ins i8mem:$dst, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002084 "sbb{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002085 [(store (sube (loadi8 addr:$dst), imm:$src2), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002086 def SBB32mi : Ii32<0x81, MRM3m, (outs), (ins i32mem:$dst, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002087 "sbb{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002088 [(store (sube (loadi32 addr:$dst), imm:$src2), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002089 def SBB32mi8 : Ii8<0x83, MRM3m, (outs), (ins i32mem:$dst, i32i8imm :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002090 "sbb{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng55687072007-09-14 21:48:26 +00002091 [(store (sube (load addr:$dst), i32immSExt8:$src2), addr:$dst)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002092}
Evan Chengb783fa32007-07-19 01:14:50 +00002093def SBB32rm : I<0x1B, MRMSrcMem, (outs GR32:$dst), (ins GR32:$src1, i32mem:$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, (load addr:$src2)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002096def SBB32ri : Ii32<0x81, MRM3r, (outs GR32:$dst), (ins GR32:$src1, i32imm:$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, imm:$src2))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002099def SBB32ri8 : Ii8<0x83, MRM3r, (outs GR32:$dst), (ins GR32:$src1, i32i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002100 "sbb{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002101 [(set GR32:$dst, (sube GR32:$src1, i32immSExt8:$src2))]>;
Evan Cheng259471d2007-10-05 17:59:57 +00002102} // Uses = [EFLAGS]
Evan Cheng55687072007-09-14 21:48:26 +00002103} // Defs = [EFLAGS]
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002104
Evan Cheng55687072007-09-14 21:48:26 +00002105let Defs = [EFLAGS] in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002106let isCommutable = 1 in { // X = IMUL Y, Z --> X = IMUL Z, Y
Evan Chengb783fa32007-07-19 01:14:50 +00002107def IMUL16rr : I<0xAF, MRMSrcReg, (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002108 "imul{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002109 [(set GR16:$dst, (mul GR16:$src1, GR16:$src2))]>, TB, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002110def IMUL32rr : I<0xAF, MRMSrcReg, (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002111 "imul{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002112 [(set GR32:$dst, (mul GR32:$src1, GR32:$src2))]>, TB;
2113}
Evan Chengb783fa32007-07-19 01:14:50 +00002114def IMUL16rm : I<0xAF, MRMSrcMem, (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002115 "imul{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002116 [(set GR16:$dst, (mul GR16:$src1, (load addr:$src2)))]>,
2117 TB, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002118def IMUL32rm : I<0xAF, MRMSrcMem, (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002119 "imul{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002120 [(set GR32:$dst, (mul GR32:$src1, (load addr:$src2)))]>, TB;
Evan Cheng55687072007-09-14 21:48:26 +00002121} // Defs = [EFLAGS]
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002122} // end Two Address instructions
2123
2124// Suprisingly enough, these are not two address instructions!
Evan Cheng55687072007-09-14 21:48:26 +00002125let Defs = [EFLAGS] in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002126def IMUL16rri : Ii16<0x69, MRMSrcReg, // GR16 = GR16*I16
Evan Chengb783fa32007-07-19 01:14:50 +00002127 (outs GR16:$dst), (ins GR16:$src1, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002128 "imul{w}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002129 [(set GR16:$dst, (mul GR16:$src1, imm:$src2))]>, OpSize;
2130def IMUL32rri : Ii32<0x69, MRMSrcReg, // GR32 = GR32*I32
Evan Chengb783fa32007-07-19 01:14:50 +00002131 (outs GR32:$dst), (ins GR32:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002132 "imul{l}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002133 [(set GR32:$dst, (mul GR32:$src1, imm:$src2))]>;
2134def IMUL16rri8 : Ii8<0x6B, MRMSrcReg, // GR16 = GR16*I8
Evan Chengb783fa32007-07-19 01:14:50 +00002135 (outs GR16:$dst), (ins GR16:$src1, i16i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002136 "imul{w}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002137 [(set GR16:$dst, (mul GR16:$src1, i16immSExt8:$src2))]>,
2138 OpSize;
2139def IMUL32rri8 : Ii8<0x6B, MRMSrcReg, // GR32 = GR32*I8
Evan Chengb783fa32007-07-19 01:14:50 +00002140 (outs GR32:$dst), (ins GR32:$src1, i32i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002141 "imul{l}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002142 [(set GR32:$dst, (mul GR32:$src1, i32immSExt8:$src2))]>;
2143
2144def IMUL16rmi : Ii16<0x69, MRMSrcMem, // GR16 = [mem16]*I16
Evan Chengb783fa32007-07-19 01:14:50 +00002145 (outs GR16:$dst), (ins i16mem:$src1, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002146 "imul{w}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002147 [(set GR16:$dst, (mul (load addr:$src1), imm:$src2))]>,
2148 OpSize;
2149def IMUL32rmi : Ii32<0x69, MRMSrcMem, // GR32 = [mem32]*I32
Evan Chengb783fa32007-07-19 01:14:50 +00002150 (outs GR32:$dst), (ins i32mem:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002151 "imul{l}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002152 [(set GR32:$dst, (mul (load addr:$src1), imm:$src2))]>;
2153def IMUL16rmi8 : Ii8<0x6B, MRMSrcMem, // GR16 = [mem16]*I8
Evan Chengb783fa32007-07-19 01:14:50 +00002154 (outs GR16:$dst), (ins i16mem:$src1, i16i8imm :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002155 "imul{w}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002156 [(set GR16:$dst, (mul (load addr:$src1), i16immSExt8:$src2))]>,
2157 OpSize;
2158def IMUL32rmi8 : Ii8<0x6B, MRMSrcMem, // GR32 = [mem32]*I8
Evan Chengb783fa32007-07-19 01:14:50 +00002159 (outs GR32:$dst), (ins i32mem:$src1, i32i8imm: $src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002160 "imul{l}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002161 [(set GR32:$dst, (mul (load addr:$src1), i32immSExt8:$src2))]>;
Evan Cheng55687072007-09-14 21:48:26 +00002162} // Defs = [EFLAGS]
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002163
2164//===----------------------------------------------------------------------===//
2165// Test instructions are just like AND, except they don't generate a result.
2166//
Evan Cheng950aac02007-09-25 01:57:46 +00002167let Defs = [EFLAGS] in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002168let isCommutable = 1 in { // TEST X, Y --> TEST Y, X
Evan Chengb783fa32007-07-19 01:14:50 +00002169def TEST8rr : I<0x84, MRMDestReg, (outs), (ins GR8:$src1, GR8:$src2),
Evan Cheng621216e2007-09-29 00:00:36 +00002170 "test{b}\t{$src2, $src1|$src1, $src2}",
Chris Lattner21da6382008-02-19 17:37:35 +00002171 [(X86cmp (and_su GR8:$src1, GR8:$src2), 0),
Evan Cheng621216e2007-09-29 00:00:36 +00002172 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002173def TEST16rr : I<0x85, MRMDestReg, (outs), (ins GR16:$src1, GR16:$src2),
Evan Cheng621216e2007-09-29 00:00:36 +00002174 "test{w}\t{$src2, $src1|$src1, $src2}",
Chris Lattner21da6382008-02-19 17:37:35 +00002175 [(X86cmp (and_su GR16:$src1, GR16:$src2), 0),
Evan Cheng621216e2007-09-29 00:00:36 +00002176 (implicit EFLAGS)]>,
2177 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002178def TEST32rr : I<0x85, MRMDestReg, (outs), (ins GR32:$src1, GR32:$src2),
Evan Cheng621216e2007-09-29 00:00:36 +00002179 "test{l}\t{$src2, $src1|$src1, $src2}",
Chris Lattner21da6382008-02-19 17:37:35 +00002180 [(X86cmp (and_su GR32:$src1, GR32:$src2), 0),
Evan Cheng621216e2007-09-29 00:00:36 +00002181 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002182}
2183
Evan Chengb783fa32007-07-19 01:14:50 +00002184def TEST8rm : I<0x84, MRMSrcMem, (outs), (ins GR8 :$src1, i8mem :$src2),
Evan Cheng621216e2007-09-29 00:00:36 +00002185 "test{b}\t{$src2, $src1|$src1, $src2}",
2186 [(X86cmp (and GR8:$src1, (loadi8 addr:$src2)), 0),
2187 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002188def TEST16rm : I<0x85, MRMSrcMem, (outs), (ins GR16:$src1, i16mem:$src2),
Evan Cheng621216e2007-09-29 00:00:36 +00002189 "test{w}\t{$src2, $src1|$src1, $src2}",
2190 [(X86cmp (and GR16:$src1, (loadi16 addr:$src2)), 0),
2191 (implicit EFLAGS)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002192def TEST32rm : I<0x85, MRMSrcMem, (outs), (ins GR32:$src1, i32mem:$src2),
Evan Cheng621216e2007-09-29 00:00:36 +00002193 "test{l}\t{$src2, $src1|$src1, $src2}",
2194 [(X86cmp (and GR32:$src1, (loadi32 addr:$src2)), 0),
2195 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002196
2197def TEST8ri : Ii8 <0xF6, MRM0r, // flags = GR8 & imm8
Evan Chengb783fa32007-07-19 01:14:50 +00002198 (outs), (ins GR8:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002199 "test{b}\t{$src2, $src1|$src1, $src2}",
Chris Lattner21da6382008-02-19 17:37:35 +00002200 [(X86cmp (and_su GR8:$src1, imm:$src2), 0),
Evan Cheng621216e2007-09-29 00:00:36 +00002201 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002202def TEST16ri : Ii16<0xF7, MRM0r, // flags = GR16 & imm16
Evan Chengb783fa32007-07-19 01:14:50 +00002203 (outs), (ins GR16:$src1, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002204 "test{w}\t{$src2, $src1|$src1, $src2}",
Chris Lattner21da6382008-02-19 17:37:35 +00002205 [(X86cmp (and_su GR16:$src1, imm:$src2), 0),
Evan Cheng621216e2007-09-29 00:00:36 +00002206 (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002207def TEST32ri : Ii32<0xF7, MRM0r, // flags = GR32 & imm32
Evan Chengb783fa32007-07-19 01:14:50 +00002208 (outs), (ins GR32:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002209 "test{l}\t{$src2, $src1|$src1, $src2}",
Chris Lattner21da6382008-02-19 17:37:35 +00002210 [(X86cmp (and_su GR32:$src1, imm:$src2), 0),
Evan Cheng621216e2007-09-29 00:00:36 +00002211 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002212
Evan Cheng621216e2007-09-29 00:00:36 +00002213def TEST8mi : Ii8 <0xF6, MRM0m, // flags = [mem8] & imm8
Evan Chengb783fa32007-07-19 01:14:50 +00002214 (outs), (ins i8mem:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002215 "test{b}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002216 [(X86cmp (and (loadi8 addr:$src1), imm:$src2), 0),
2217 (implicit EFLAGS)]>;
2218def TEST16mi : Ii16<0xF7, MRM0m, // flags = [mem16] & imm16
Evan Chengb783fa32007-07-19 01:14:50 +00002219 (outs), (ins i16mem:$src1, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002220 "test{w}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002221 [(X86cmp (and (loadi16 addr:$src1), imm:$src2), 0),
2222 (implicit EFLAGS)]>, OpSize;
2223def TEST32mi : Ii32<0xF7, MRM0m, // flags = [mem32] & imm32
Evan Chengb783fa32007-07-19 01:14:50 +00002224 (outs), (ins i32mem:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002225 "test{l}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002226 [(X86cmp (and (loadi32 addr:$src1), imm:$src2), 0),
Evan Cheng950aac02007-09-25 01:57:46 +00002227 (implicit EFLAGS)]>;
2228} // Defs = [EFLAGS]
2229
2230
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002231// Condition code ops, incl. set if equal/not equal/...
Chris Lattnerc90ee9c2008-01-10 07:59:24 +00002232let Defs = [EFLAGS], Uses = [AH], neverHasSideEffects = 1 in
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002233def SAHF : I<0x9E, RawFrm, (outs), (ins), "sahf", []>; // flags = AH
Chris Lattnerc90ee9c2008-01-10 07:59:24 +00002234let Defs = [AH], Uses = [EFLAGS], neverHasSideEffects = 1 in
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002235def LAHF : I<0x9F, RawFrm, (outs), (ins), "lahf", []>; // AH = flags
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002236
Evan Cheng950aac02007-09-25 01:57:46 +00002237let Uses = [EFLAGS] in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002238def SETEr : I<0x94, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00002239 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002240 "sete\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002241 [(set GR8:$dst, (X86setcc X86_COND_E, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002242 TB; // GR8 = ==
2243def SETEm : I<0x94, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00002244 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002245 "sete\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002246 [(store (X86setcc X86_COND_E, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002247 TB; // [mem8] = ==
2248def SETNEr : I<0x95, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00002249 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002250 "setne\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002251 [(set GR8:$dst, (X86setcc X86_COND_NE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002252 TB; // GR8 = !=
2253def SETNEm : I<0x95, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00002254 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002255 "setne\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002256 [(store (X86setcc X86_COND_NE, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002257 TB; // [mem8] = !=
2258def SETLr : I<0x9C, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00002259 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002260 "setl\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002261 [(set GR8:$dst, (X86setcc X86_COND_L, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002262 TB; // GR8 = < signed
2263def SETLm : I<0x9C, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00002264 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002265 "setl\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002266 [(store (X86setcc X86_COND_L, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002267 TB; // [mem8] = < signed
2268def SETGEr : I<0x9D, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00002269 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002270 "setge\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002271 [(set GR8:$dst, (X86setcc X86_COND_GE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002272 TB; // GR8 = >= signed
2273def SETGEm : I<0x9D, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00002274 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002275 "setge\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002276 [(store (X86setcc X86_COND_GE, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002277 TB; // [mem8] = >= signed
2278def SETLEr : I<0x9E, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00002279 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002280 "setle\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002281 [(set GR8:$dst, (X86setcc X86_COND_LE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002282 TB; // GR8 = <= signed
2283def SETLEm : I<0x9E, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00002284 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002285 "setle\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002286 [(store (X86setcc X86_COND_LE, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002287 TB; // [mem8] = <= signed
2288def SETGr : I<0x9F, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00002289 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002290 "setg\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002291 [(set GR8:$dst, (X86setcc X86_COND_G, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002292 TB; // GR8 = > signed
2293def SETGm : I<0x9F, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00002294 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002295 "setg\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002296 [(store (X86setcc X86_COND_G, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002297 TB; // [mem8] = > signed
2298
2299def SETBr : I<0x92, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00002300 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002301 "setb\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002302 [(set GR8:$dst, (X86setcc X86_COND_B, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002303 TB; // GR8 = < unsign
2304def SETBm : I<0x92, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00002305 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002306 "setb\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002307 [(store (X86setcc X86_COND_B, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002308 TB; // [mem8] = < unsign
2309def SETAEr : I<0x93, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00002310 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002311 "setae\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002312 [(set GR8:$dst, (X86setcc X86_COND_AE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002313 TB; // GR8 = >= unsign
2314def SETAEm : I<0x93, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00002315 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002316 "setae\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002317 [(store (X86setcc X86_COND_AE, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002318 TB; // [mem8] = >= unsign
2319def SETBEr : I<0x96, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00002320 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002321 "setbe\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002322 [(set GR8:$dst, (X86setcc X86_COND_BE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002323 TB; // GR8 = <= unsign
2324def SETBEm : I<0x96, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00002325 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002326 "setbe\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002327 [(store (X86setcc X86_COND_BE, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002328 TB; // [mem8] = <= unsign
2329def SETAr : I<0x97, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00002330 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002331 "seta\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002332 [(set GR8:$dst, (X86setcc X86_COND_A, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002333 TB; // GR8 = > signed
2334def SETAm : I<0x97, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00002335 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002336 "seta\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002337 [(store (X86setcc X86_COND_A, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002338 TB; // [mem8] = > signed
2339
2340def SETSr : I<0x98, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00002341 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002342 "sets\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002343 [(set GR8:$dst, (X86setcc X86_COND_S, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002344 TB; // GR8 = <sign bit>
2345def SETSm : I<0x98, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00002346 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002347 "sets\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002348 [(store (X86setcc X86_COND_S, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002349 TB; // [mem8] = <sign bit>
2350def SETNSr : I<0x99, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00002351 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002352 "setns\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002353 [(set GR8:$dst, (X86setcc X86_COND_NS, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002354 TB; // GR8 = !<sign bit>
2355def SETNSm : I<0x99, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00002356 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002357 "setns\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002358 [(store (X86setcc X86_COND_NS, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002359 TB; // [mem8] = !<sign bit>
2360def SETPr : I<0x9A, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00002361 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002362 "setp\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002363 [(set GR8:$dst, (X86setcc X86_COND_P, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002364 TB; // GR8 = parity
2365def SETPm : I<0x9A, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00002366 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002367 "setp\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002368 [(store (X86setcc X86_COND_P, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002369 TB; // [mem8] = parity
2370def SETNPr : I<0x9B, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00002371 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002372 "setnp\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002373 [(set GR8:$dst, (X86setcc X86_COND_NP, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002374 TB; // GR8 = not parity
2375def SETNPm : I<0x9B, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00002376 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002377 "setnp\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002378 [(store (X86setcc X86_COND_NP, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002379 TB; // [mem8] = not parity
Evan Cheng950aac02007-09-25 01:57:46 +00002380} // Uses = [EFLAGS]
2381
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002382
2383// Integer comparisons
Evan Cheng55687072007-09-14 21:48:26 +00002384let Defs = [EFLAGS] in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002385def CMP8rr : I<0x38, MRMDestReg,
Evan Chengb783fa32007-07-19 01:14:50 +00002386 (outs), (ins GR8 :$src1, GR8 :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002387 "cmp{b}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002388 [(X86cmp GR8:$src1, GR8:$src2), (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002389def CMP16rr : I<0x39, MRMDestReg,
Evan Chengb783fa32007-07-19 01:14:50 +00002390 (outs), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002391 "cmp{w}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002392 [(X86cmp GR16:$src1, GR16:$src2), (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002393def CMP32rr : I<0x39, MRMDestReg,
Evan Chengb783fa32007-07-19 01:14:50 +00002394 (outs), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002395 "cmp{l}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002396 [(X86cmp GR32:$src1, GR32:$src2), (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002397def CMP8mr : I<0x38, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00002398 (outs), (ins i8mem :$src1, GR8 :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002399 "cmp{b}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002400 [(X86cmp (loadi8 addr:$src1), GR8:$src2),
2401 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002402def CMP16mr : I<0x39, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00002403 (outs), (ins i16mem:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002404 "cmp{w}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002405 [(X86cmp (loadi16 addr:$src1), GR16:$src2),
2406 (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002407def CMP32mr : I<0x39, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00002408 (outs), (ins i32mem:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002409 "cmp{l}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002410 [(X86cmp (loadi32 addr:$src1), GR32:$src2),
2411 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002412def CMP8rm : I<0x3A, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00002413 (outs), (ins GR8 :$src1, i8mem :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002414 "cmp{b}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002415 [(X86cmp GR8:$src1, (loadi8 addr:$src2)),
2416 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002417def CMP16rm : I<0x3B, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00002418 (outs), (ins GR16:$src1, i16mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002419 "cmp{w}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002420 [(X86cmp GR16:$src1, (loadi16 addr:$src2)),
2421 (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002422def CMP32rm : I<0x3B, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00002423 (outs), (ins GR32:$src1, i32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002424 "cmp{l}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002425 [(X86cmp GR32:$src1, (loadi32 addr:$src2)),
2426 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002427def CMP8ri : Ii8<0x80, MRM7r,
Evan Chengb783fa32007-07-19 01:14:50 +00002428 (outs), (ins GR8:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002429 "cmp{b}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002430 [(X86cmp GR8:$src1, imm:$src2), (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002431def CMP16ri : Ii16<0x81, MRM7r,
Evan Chengb783fa32007-07-19 01:14:50 +00002432 (outs), (ins GR16:$src1, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002433 "cmp{w}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002434 [(X86cmp GR16:$src1, imm:$src2),
2435 (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002436def CMP32ri : Ii32<0x81, MRM7r,
Evan Chengb783fa32007-07-19 01:14:50 +00002437 (outs), (ins GR32:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002438 "cmp{l}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002439 [(X86cmp GR32:$src1, imm:$src2), (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002440def CMP8mi : Ii8 <0x80, MRM7m,
Evan Chengb783fa32007-07-19 01:14:50 +00002441 (outs), (ins i8mem :$src1, i8imm :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002442 "cmp{b}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002443 [(X86cmp (loadi8 addr:$src1), imm:$src2),
2444 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002445def CMP16mi : Ii16<0x81, MRM7m,
Evan Chengb783fa32007-07-19 01:14:50 +00002446 (outs), (ins i16mem:$src1, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002447 "cmp{w}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002448 [(X86cmp (loadi16 addr:$src1), imm:$src2),
2449 (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002450def CMP32mi : Ii32<0x81, MRM7m,
Evan Chengb783fa32007-07-19 01:14:50 +00002451 (outs), (ins i32mem:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002452 "cmp{l}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002453 [(X86cmp (loadi32 addr:$src1), imm:$src2),
2454 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002455def CMP16ri8 : Ii8<0x83, MRM7r,
Evan Chengb783fa32007-07-19 01:14:50 +00002456 (outs), (ins GR16:$src1, i16i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002457 "cmp{w}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002458 [(X86cmp GR16:$src1, i16immSExt8:$src2),
2459 (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002460def CMP16mi8 : Ii8<0x83, MRM7m,
Evan Chengb783fa32007-07-19 01:14:50 +00002461 (outs), (ins i16mem:$src1, i16i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002462 "cmp{w}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002463 [(X86cmp (loadi16 addr:$src1), i16immSExt8:$src2),
2464 (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002465def CMP32mi8 : Ii8<0x83, MRM7m,
Evan Chengb783fa32007-07-19 01:14:50 +00002466 (outs), (ins i32mem:$src1, i32i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002467 "cmp{l}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002468 [(X86cmp (loadi32 addr:$src1), i32immSExt8:$src2),
2469 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002470def CMP32ri8 : Ii8<0x83, MRM7r,
Evan Chengb783fa32007-07-19 01:14:50 +00002471 (outs), (ins GR32:$src1, i32i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002472 "cmp{l}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002473 [(X86cmp GR32:$src1, i32immSExt8:$src2),
Evan Cheng950aac02007-09-25 01:57:46 +00002474 (implicit EFLAGS)]>;
2475} // Defs = [EFLAGS]
2476
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002477// Sign/Zero extenders
Dan Gohman9203ab42008-07-30 18:09:17 +00002478// Use movsbl intead of movsbw; we don't care about the high 16 bits
2479// of the register here. This has a smaller encoding and avoids a
2480// partial-register update.
Evan Chengb783fa32007-07-19 01:14:50 +00002481def MOVSX16rr8 : I<0xBE, MRMSrcReg, (outs GR16:$dst), (ins GR8 :$src),
Dan Gohman9203ab42008-07-30 18:09:17 +00002482 "movs{bl|x}\t{$src, ${dst:subreg32}|${dst:subreg32}, $src}",
2483 [(set GR16:$dst, (sext GR8:$src))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00002484def MOVSX16rm8 : I<0xBE, MRMSrcMem, (outs GR16:$dst), (ins i8mem :$src),
Dan Gohman9203ab42008-07-30 18:09:17 +00002485 "movs{bl|x}\t{$src, ${dst:subreg32}|${dst:subreg32}, $src}",
2486 [(set GR16:$dst, (sextloadi16i8 addr:$src))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00002487def MOVSX32rr8 : I<0xBE, MRMSrcReg, (outs GR32:$dst), (ins GR8 :$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, (sext GR8:$src))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00002490def MOVSX32rm8 : I<0xBE, MRMSrcMem, (outs GR32:$dst), (ins i8mem :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002491 "movs{bl|x}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002492 [(set GR32:$dst, (sextloadi32i8 addr:$src))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00002493def MOVSX32rr16: I<0xBF, MRMSrcReg, (outs GR32:$dst), (ins GR16:$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, (sext GR16:$src))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00002496def MOVSX32rm16: I<0xBF, MRMSrcMem, (outs GR32:$dst), (ins i16mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002497 "movs{wl|x}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002498 [(set GR32:$dst, (sextloadi32i16 addr:$src))]>, TB;
2499
Dan Gohman9203ab42008-07-30 18:09:17 +00002500// Use movzbl intead of movzbw; we don't care about the high 16 bits
2501// of the register here. This has a smaller encoding and avoids a
2502// partial-register update.
Evan Chengb783fa32007-07-19 01:14:50 +00002503def MOVZX16rr8 : I<0xB6, MRMSrcReg, (outs GR16:$dst), (ins GR8 :$src),
Dan Gohman9203ab42008-07-30 18:09:17 +00002504 "movz{bl|x}\t{$src, ${dst:subreg32}|${dst:subreg32}, $src}",
2505 [(set GR16:$dst, (zext GR8:$src))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00002506def MOVZX16rm8 : I<0xB6, MRMSrcMem, (outs GR16:$dst), (ins i8mem :$src),
Dan Gohman9203ab42008-07-30 18:09:17 +00002507 "movz{bl|x}\t{$src, ${dst:subreg32}|${dst:subreg32}, $src}",
2508 [(set GR16:$dst, (zextloadi16i8 addr:$src))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00002509def MOVZX32rr8 : I<0xB6, MRMSrcReg, (outs GR32:$dst), (ins GR8 :$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, (zext GR8:$src))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00002512def MOVZX32rm8 : I<0xB6, MRMSrcMem, (outs GR32:$dst), (ins i8mem :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002513 "movz{bl|x}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002514 [(set GR32:$dst, (zextloadi32i8 addr:$src))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00002515def MOVZX32rr16: I<0xB7, MRMSrcReg, (outs GR32:$dst), (ins GR16:$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, (zext GR16:$src))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00002518def MOVZX32rm16: I<0xB7, MRMSrcMem, (outs GR32:$dst), (ins i16mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002519 "movz{wl|x}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002520 [(set GR32:$dst, (zextloadi32i16 addr:$src))]>, TB;
2521
Chris Lattnerc90ee9c2008-01-10 07:59:24 +00002522let neverHasSideEffects = 1 in {
2523 let Defs = [AX], Uses = [AL] in
2524 def CBW : I<0x98, RawFrm, (outs), (ins),
2525 "{cbtw|cbw}", []>, OpSize; // AX = signext(AL)
2526 let Defs = [EAX], Uses = [AX] in
2527 def CWDE : I<0x98, RawFrm, (outs), (ins),
2528 "{cwtl|cwde}", []>; // EAX = signext(AX)
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002529
Chris Lattnerc90ee9c2008-01-10 07:59:24 +00002530 let Defs = [AX,DX], Uses = [AX] in
2531 def CWD : I<0x99, RawFrm, (outs), (ins),
2532 "{cwtd|cwd}", []>, OpSize; // DX:AX = signext(AX)
2533 let Defs = [EAX,EDX], Uses = [EAX] in
2534 def CDQ : I<0x99, RawFrm, (outs), (ins),
2535 "{cltd|cdq}", []>; // EDX:EAX = signext(EAX)
2536}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002537
2538//===----------------------------------------------------------------------===//
2539// Alias Instructions
2540//===----------------------------------------------------------------------===//
2541
2542// Alias instructions that map movr0 to xor.
2543// FIXME: remove when we can teach regalloc that xor reg, reg is ok.
Bill Wendlingba5d5b02008-05-29 01:02:09 +00002544let Defs = [EFLAGS], isReMaterializable = 1, isAsCheapAsAMove = 1 in {
Evan Chengb783fa32007-07-19 01:14:50 +00002545def MOV8r0 : I<0x30, MRMInitReg, (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002546 "xor{b}\t$dst, $dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002547 [(set GR8:$dst, 0)]>;
Dan Gohman9203ab42008-07-30 18:09:17 +00002548// Use xorl instead of xorw since we don't care about the high 16 bits,
2549// it's smaller, and it avoids a partial-register update.
Evan Chengb783fa32007-07-19 01:14:50 +00002550def MOV16r0 : I<0x31, MRMInitReg, (outs GR16:$dst), (ins),
Dan Gohman9203ab42008-07-30 18:09:17 +00002551 "xor{l}\t${dst:subreg32}, ${dst:subreg32}",
2552 [(set GR16:$dst, 0)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002553def MOV32r0 : I<0x31, MRMInitReg, (outs GR32:$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002554 "xor{l}\t$dst, $dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002555 [(set GR32:$dst, 0)]>;
Dan Gohman8aef09b2007-09-07 21:32:51 +00002556}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002557
2558// Basic operations on GR16 / GR32 subclasses GR16_ and GR32_ which contains only
2559// those registers that have GR8 sub-registers (i.e. AX - DX, EAX - EDX).
Chris Lattnerc90ee9c2008-01-10 07:59:24 +00002560let neverHasSideEffects = 1 in {
Evan Chengb783fa32007-07-19 01:14:50 +00002561def MOV16to16_ : I<0x89, MRMDestReg, (outs GR16_:$dst), (ins GR16:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002562 "mov{w}\t{$src, $dst|$dst, $src}", []>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002563def MOV32to32_ : I<0x89, MRMDestReg, (outs GR32_:$dst), (ins GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002564 "mov{l}\t{$src, $dst|$dst, $src}", []>;
Chris Lattnerc90ee9c2008-01-10 07:59:24 +00002565
Evan Chengb783fa32007-07-19 01:14:50 +00002566def MOV16_rr : I<0x89, MRMDestReg, (outs GR16_:$dst), (ins GR16_:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002567 "mov{w}\t{$src, $dst|$dst, $src}", []>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002568def MOV32_rr : I<0x89, MRMDestReg, (outs GR32_:$dst), (ins GR32_:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002569 "mov{l}\t{$src, $dst|$dst, $src}", []>;
Chris Lattnerc90ee9c2008-01-10 07:59:24 +00002570} // neverHasSideEffects
2571
2572let isSimpleLoad = 1, mayLoad = 1, isReMaterializable = 1, mayHaveSideEffects = 1 in {
Evan Chengb783fa32007-07-19 01:14:50 +00002573def MOV16_rm : I<0x8B, MRMSrcMem, (outs GR16_:$dst), (ins i16mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002574 "mov{w}\t{$src, $dst|$dst, $src}", []>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002575def MOV32_rm : I<0x8B, MRMSrcMem, (outs GR32_:$dst), (ins i32mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002576 "mov{l}\t{$src, $dst|$dst, $src}", []>;
Evan Cheng4e84e452007-08-30 05:49:43 +00002577}
Chris Lattnerc90ee9c2008-01-10 07:59:24 +00002578let mayStore = 1, neverHasSideEffects = 1 in {
Evan Chengb783fa32007-07-19 01:14:50 +00002579def MOV16_mr : I<0x89, MRMDestMem, (outs), (ins i16mem:$dst, GR16_:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002580 "mov{w}\t{$src, $dst|$dst, $src}", []>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002581def MOV32_mr : I<0x89, MRMDestMem, (outs), (ins i32mem:$dst, GR32_:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002582 "mov{l}\t{$src, $dst|$dst, $src}", []>;
Chris Lattnerc90ee9c2008-01-10 07:59:24 +00002583}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002584
2585//===----------------------------------------------------------------------===//
2586// Thread Local Storage Instructions
2587//
2588
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002589let Uses = [EBX] in
Anton Korobeynikov4fbf00b2008-05-04 21:36:32 +00002590def TLS_addr32 : I<0, Pseudo, (outs GR32:$dst), (ins i32imm:$sym),
2591 "leal\t${sym:mem}(,%ebx,1), $dst",
2592 [(set GR32:$dst, (X86tlsaddr tglobaltlsaddr:$sym))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002593
2594let AddedComplexity = 10 in
Anton Korobeynikov4fbf00b2008-05-04 21:36:32 +00002595def TLS_gs_rr : I<0, Pseudo, (outs GR32:$dst), (ins GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002596 "movl\t%gs:($src), $dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002597 [(set GR32:$dst, (load (add X86TLStp, GR32:$src)))]>;
2598
2599let AddedComplexity = 15 in
Evan Chengb783fa32007-07-19 01:14:50 +00002600def TLS_gs_ri : I<0, Pseudo, (outs GR32:$dst), (ins i32imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002601 "movl\t%gs:${src:mem}, $dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002602 [(set GR32:$dst,
2603 (load (add X86TLStp, (X86Wrapper tglobaltlsaddr:$src))))]>;
2604
Evan Chengb783fa32007-07-19 01:14:50 +00002605def TLS_tp : I<0, Pseudo, (outs GR32:$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002606 "movl\t%gs:0, $dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002607 [(set GR32:$dst, X86TLStp)]>;
2608
2609//===----------------------------------------------------------------------===//
2610// DWARF Pseudo Instructions
2611//
2612
Evan Chengb783fa32007-07-19 01:14:50 +00002613def DWARF_LOC : I<0, Pseudo, (outs),
2614 (ins i32imm:$line, i32imm:$col, i32imm:$file),
Dan Gohman77af4a82007-09-24 19:25:06 +00002615 ".loc\t${file:debug} ${line:debug} ${col:debug}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002616 [(dwarf_loc (i32 imm:$line), (i32 imm:$col),
2617 (i32 imm:$file))]>;
2618
2619//===----------------------------------------------------------------------===//
2620// EH Pseudo Instructions
2621//
2622let isTerminator = 1, isReturn = 1, isBarrier = 1,
Evan Cheng37e7c752007-07-21 00:34:19 +00002623 hasCtrlDep = 1 in {
Evan Chengb783fa32007-07-19 01:14:50 +00002624def EH_RETURN : I<0xC3, RawFrm, (outs), (ins GR32:$addr),
Dan Gohman91888f02007-07-31 20:11:57 +00002625 "ret\t#eh_return, addr: $addr",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002626 [(X86ehret GR32:$addr)]>;
2627
2628}
2629
2630//===----------------------------------------------------------------------===//
Andrew Lenharthe44f3902008-02-21 06:45:13 +00002631// Atomic support
2632//
Andrew Lenharth7a5a4b22008-03-01 13:37:02 +00002633
Evan Cheng3e171562008-04-19 01:20:30 +00002634// Atomic swap. These are just normal xchg instructions. But since a memory
2635// operand is referenced, the atomicity is ensured.
Dan Gohmana41a1c092008-08-06 15:52:50 +00002636let Constraints = "$val = $dst" in {
Evan Cheng3e171562008-04-19 01:20:30 +00002637def XCHG32rm : I<0x87, MRMSrcMem, (outs GR32:$dst), (ins i32mem:$ptr, GR32:$val),
2638 "xchg{l}\t{$val, $ptr|$ptr, $val}",
2639 [(set GR32:$dst, (atomic_swap_32 addr:$ptr, GR32:$val))]>;
2640def XCHG16rm : I<0x87, MRMSrcMem, (outs GR16:$dst), (ins i16mem:$ptr, GR16:$val),
2641 "xchg{w}\t{$val, $ptr|$ptr, $val}",
2642 [(set GR16:$dst, (atomic_swap_16 addr:$ptr, GR16:$val))]>,
2643 OpSize;
2644def XCHG8rm : I<0x86, MRMSrcMem, (outs GR8:$dst), (ins i8mem:$ptr, GR8:$val),
2645 "xchg{b}\t{$val, $ptr|$ptr, $val}",
2646 [(set GR8:$dst, (atomic_swap_8 addr:$ptr, GR8:$val))]>;
2647}
2648
Evan Chengd49dbb82008-04-18 20:55:36 +00002649// Atomic compare and swap.
Andrew Lenharth7dfe23f2008-03-01 21:52:34 +00002650let Defs = [EAX, EFLAGS], Uses = [EAX] in {
Evan Chengd49dbb82008-04-18 20:55:36 +00002651def LCMPXCHG32 : I<0xB1, MRMDestMem, (outs), (ins i32mem:$ptr, GR32:$swap),
Dale Johannesend20e4452008-08-19 18:47:28 +00002652 "lock\n\tcmpxchg{l}\t{$swap, $ptr|$ptr, $swap}",
Evan Cheng09fbdee2008-03-04 03:20:06 +00002653 [(X86cas addr:$ptr, GR32:$swap, 4)]>, TB, LOCK;
Andrew Lenharth7a5a4b22008-03-01 13:37:02 +00002654}
Dale Johannesenf160d802008-10-02 18:53:47 +00002655let Defs = [EAX, EDX, EFLAGS], Uses = [EAX, EBX, ECX, EDX] in {
Anton Korobeynikovc4067392008-07-22 16:22:48 +00002656def LCMPXCHG8B : I<0xC7, MRM1m, (outs), (ins i32mem:$ptr),
Dale Johannesend20e4452008-08-19 18:47:28 +00002657 "lock\n\tcmpxchg8b\t$ptr",
Andrew Lenharth81580822008-03-05 01:15:49 +00002658 [(X86cas8 addr:$ptr)]>, TB, LOCK;
2659}
Andrew Lenharth7dfe23f2008-03-01 21:52:34 +00002660
2661let Defs = [AX, EFLAGS], Uses = [AX] in {
Evan Chengd49dbb82008-04-18 20:55:36 +00002662def LCMPXCHG16 : I<0xB1, MRMDestMem, (outs), (ins i16mem:$ptr, GR16:$swap),
Dale Johannesend20e4452008-08-19 18:47:28 +00002663 "lock\n\tcmpxchg{w}\t{$swap, $ptr|$ptr, $swap}",
Evan Cheng09fbdee2008-03-04 03:20:06 +00002664 [(X86cas addr:$ptr, GR16:$swap, 2)]>, TB, OpSize, LOCK;
Andrew Lenharth7a5a4b22008-03-01 13:37:02 +00002665}
Andrew Lenharth7dfe23f2008-03-01 21:52:34 +00002666let Defs = [AL, EFLAGS], Uses = [AL] in {
Evan Chengd49dbb82008-04-18 20:55:36 +00002667def LCMPXCHG8 : I<0xB0, MRMDestMem, (outs), (ins i8mem:$ptr, GR8:$swap),
Dale Johannesend20e4452008-08-19 18:47:28 +00002668 "lock\n\tcmpxchg{b}\t{$swap, $ptr|$ptr, $swap}",
Evan Cheng09fbdee2008-03-04 03:20:06 +00002669 [(X86cas addr:$ptr, GR8:$swap, 1)]>, TB, LOCK;
Andrew Lenharth7a5a4b22008-03-01 13:37:02 +00002670}
2671
Evan Chengd49dbb82008-04-18 20:55:36 +00002672// Atomic exchange and add
2673let Constraints = "$val = $dst", Defs = [EFLAGS] in {
2674def LXADD32 : I<0xC1, MRMSrcMem, (outs GR32:$dst), (ins i32mem:$ptr, GR32:$val),
Dale Johannesend20e4452008-08-19 18:47:28 +00002675 "lock\n\txadd{l}\t{$val, $ptr|$ptr, $val}",
Mon P Wang6bde9ec2008-06-25 08:15:39 +00002676 [(set GR32:$dst, (atomic_load_add_32 addr:$ptr, GR32:$val))]>,
Evan Chengd49dbb82008-04-18 20:55:36 +00002677 TB, LOCK;
2678def LXADD16 : I<0xC1, MRMSrcMem, (outs GR16:$dst), (ins i16mem:$ptr, GR16:$val),
Dale Johannesend20e4452008-08-19 18:47:28 +00002679 "lock\n\txadd{w}\t{$val, $ptr|$ptr, $val}",
Mon P Wang6bde9ec2008-06-25 08:15:39 +00002680 [(set GR16:$dst, (atomic_load_add_16 addr:$ptr, GR16:$val))]>,
Evan Chengd49dbb82008-04-18 20:55:36 +00002681 TB, OpSize, LOCK;
2682def LXADD8 : I<0xC0, MRMSrcMem, (outs GR8:$dst), (ins i8mem:$ptr, GR8:$val),
Dale Johannesend20e4452008-08-19 18:47:28 +00002683 "lock\n\txadd{b}\t{$val, $ptr|$ptr, $val}",
Mon P Wang6bde9ec2008-06-25 08:15:39 +00002684 [(set GR8:$dst, (atomic_load_add_8 addr:$ptr, GR8:$val))]>,
Evan Chengd49dbb82008-04-18 20:55:36 +00002685 TB, LOCK;
Andrew Lenharth7a5a4b22008-03-01 13:37:02 +00002686}
2687
Mon P Wang6bde9ec2008-06-25 08:15:39 +00002688// Atomic exchange, and, or, xor
Mon P Wang078a62d2008-05-05 19:05:59 +00002689let Constraints = "$val = $dst", Defs = [EFLAGS],
2690 usesCustomDAGSchedInserter = 1 in {
Dan Gohman8aeb61f2008-05-12 20:22:45 +00002691def ATOMAND32 : I<0, Pseudo, (outs GR32:$dst),(ins i32mem:$ptr, GR32:$val),
Mon P Wang078a62d2008-05-05 19:05:59 +00002692 "#ATOMAND32 PSUEDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00002693 [(set GR32:$dst, (atomic_load_and_32 addr:$ptr, GR32:$val))]>;
Dan Gohman8aeb61f2008-05-12 20:22:45 +00002694def ATOMOR32 : I<0, Pseudo, (outs GR32:$dst),(ins i32mem:$ptr, GR32:$val),
Mon P Wang078a62d2008-05-05 19:05:59 +00002695 "#ATOMOR32 PSUEDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00002696 [(set GR32:$dst, (atomic_load_or_32 addr:$ptr, GR32:$val))]>;
Dan Gohman8aeb61f2008-05-12 20:22:45 +00002697def ATOMXOR32 : I<0, Pseudo,(outs GR32:$dst),(ins i32mem:$ptr, GR32:$val),
Mon P Wang078a62d2008-05-05 19:05:59 +00002698 "#ATOMXOR32 PSUEDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00002699 [(set GR32:$dst, (atomic_load_xor_32 addr:$ptr, GR32:$val))]>;
Andrew Lenharthaf02d592008-06-14 05:48:15 +00002700def ATOMNAND32 : I<0, Pseudo,(outs GR32:$dst),(ins i32mem:$ptr, GR32:$val),
Mon P Wang6bde9ec2008-06-25 08:15:39 +00002701 "#ATOMNAND32 PSUEDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00002702 [(set GR32:$dst, (atomic_load_nand_32 addr:$ptr, GR32:$val))]>;
Dan Gohman8aeb61f2008-05-12 20:22:45 +00002703def ATOMMIN32: I<0, Pseudo, (outs GR32:$dst), (ins i32mem:$ptr, GR32:$val),
Mon P Wang078a62d2008-05-05 19:05:59 +00002704 "#ATOMMIN32 PSUEDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00002705 [(set GR32:$dst, (atomic_load_min_32 addr:$ptr, GR32:$val))]>;
Dan Gohman8aeb61f2008-05-12 20:22:45 +00002706def ATOMMAX32: I<0, Pseudo, (outs GR32:$dst),(ins i32mem:$ptr, GR32:$val),
Mon P Wang078a62d2008-05-05 19:05:59 +00002707 "#ATOMMAX32 PSUEDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00002708 [(set GR32:$dst, (atomic_load_max_32 addr:$ptr, GR32:$val))]>;
Dan Gohman8aeb61f2008-05-12 20:22:45 +00002709def ATOMUMIN32: I<0, Pseudo, (outs GR32:$dst),(ins i32mem:$ptr, GR32:$val),
Mon P Wang078a62d2008-05-05 19:05:59 +00002710 "#ATOMUMIN32 PSUEDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00002711 [(set GR32:$dst, (atomic_load_umin_32 addr:$ptr, GR32:$val))]>;
Dan Gohman8aeb61f2008-05-12 20:22:45 +00002712def ATOMUMAX32: I<0, Pseudo, (outs GR32:$dst),(ins i32mem:$ptr, GR32:$val),
Mon P Wang078a62d2008-05-05 19:05:59 +00002713 "#ATOMUMAX32 PSUEDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00002714 [(set GR32:$dst, (atomic_load_umax_32 addr:$ptr, GR32:$val))]>;
Dale Johannesend20e4452008-08-19 18:47:28 +00002715
2716def ATOMAND16 : I<0, Pseudo, (outs GR16:$dst),(ins i16mem:$ptr, GR16:$val),
2717 "#ATOMAND16 PSUEDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00002718 [(set GR16:$dst, (atomic_load_and_16 addr:$ptr, GR16:$val))]>;
Dale Johannesend20e4452008-08-19 18:47:28 +00002719def ATOMOR16 : I<0, Pseudo, (outs GR16:$dst),(ins i16mem:$ptr, GR16:$val),
2720 "#ATOMOR16 PSUEDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00002721 [(set GR16:$dst, (atomic_load_or_16 addr:$ptr, GR16:$val))]>;
Dale Johannesend20e4452008-08-19 18:47:28 +00002722def ATOMXOR16 : I<0, Pseudo,(outs GR16:$dst),(ins i16mem:$ptr, GR16:$val),
2723 "#ATOMXOR16 PSUEDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00002724 [(set GR16:$dst, (atomic_load_xor_16 addr:$ptr, GR16:$val))]>;
Dale Johannesend20e4452008-08-19 18:47:28 +00002725def ATOMNAND16 : I<0, Pseudo,(outs GR16:$dst),(ins i16mem:$ptr, GR16:$val),
2726 "#ATOMNAND16 PSUEDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00002727 [(set GR16:$dst, (atomic_load_nand_16 addr:$ptr, GR16:$val))]>;
Dale Johannesend20e4452008-08-19 18:47:28 +00002728def ATOMMIN16: I<0, Pseudo, (outs GR16:$dst), (ins i16mem:$ptr, GR16:$val),
2729 "#ATOMMIN16 PSUEDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00002730 [(set GR16:$dst, (atomic_load_min_16 addr:$ptr, GR16:$val))]>;
Dale Johannesend20e4452008-08-19 18:47:28 +00002731def ATOMMAX16: I<0, Pseudo, (outs GR16:$dst),(ins i16mem:$ptr, GR16:$val),
2732 "#ATOMMAX16 PSUEDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00002733 [(set GR16:$dst, (atomic_load_max_16 addr:$ptr, GR16:$val))]>;
Dale Johannesend20e4452008-08-19 18:47:28 +00002734def ATOMUMIN16: I<0, Pseudo, (outs GR16:$dst),(ins i16mem:$ptr, GR16:$val),
2735 "#ATOMUMIN16 PSUEDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00002736 [(set GR16:$dst, (atomic_load_umin_16 addr:$ptr, GR16:$val))]>;
Dale Johannesend20e4452008-08-19 18:47:28 +00002737def ATOMUMAX16: I<0, Pseudo, (outs GR16:$dst),(ins i16mem:$ptr, GR16:$val),
2738 "#ATOMUMAX16 PSUEDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00002739 [(set GR16:$dst, (atomic_load_umax_16 addr:$ptr, GR16:$val))]>;
Dale Johannesend20e4452008-08-19 18:47:28 +00002740
2741def ATOMAND8 : I<0, Pseudo, (outs GR8:$dst),(ins i8mem:$ptr, GR8:$val),
2742 "#ATOMAND8 PSUEDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00002743 [(set GR8:$dst, (atomic_load_and_8 addr:$ptr, GR8:$val))]>;
Dale Johannesend20e4452008-08-19 18:47:28 +00002744def ATOMOR8 : I<0, Pseudo, (outs GR8:$dst),(ins i8mem:$ptr, GR8:$val),
2745 "#ATOMOR8 PSUEDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00002746 [(set GR8:$dst, (atomic_load_or_8 addr:$ptr, GR8:$val))]>;
Dale Johannesend20e4452008-08-19 18:47:28 +00002747def ATOMXOR8 : I<0, Pseudo,(outs GR8:$dst),(ins i8mem:$ptr, GR8:$val),
2748 "#ATOMXOR8 PSUEDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00002749 [(set GR8:$dst, (atomic_load_xor_8 addr:$ptr, GR8:$val))]>;
Dale Johannesend20e4452008-08-19 18:47:28 +00002750def ATOMNAND8 : I<0, Pseudo,(outs GR8:$dst),(ins i8mem:$ptr, GR8:$val),
2751 "#ATOMNAND8 PSUEDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00002752 [(set GR8:$dst, (atomic_load_nand_8 addr:$ptr, GR8:$val))]>;
Mon P Wang078a62d2008-05-05 19:05:59 +00002753}
2754
Dale Johannesenf160d802008-10-02 18:53:47 +00002755let Constraints = "$val1 = $dst1, $val2 = $dst2",
2756 Defs = [EFLAGS, EAX, EBX, ECX, EDX],
2757 Uses = [EAX, EBX, ECX, EDX],
Dale Johannesen44eb5372008-10-03 19:41:08 +00002758 mayLoad = 1, mayStore = 1,
Dale Johannesenf160d802008-10-02 18:53:47 +00002759 usesCustomDAGSchedInserter = 1 in {
2760def ATOMAND6432 : I<0, Pseudo, (outs GR32:$dst1, GR32:$dst2),
2761 (ins i64mem:$ptr, GR32:$val1, GR32:$val2),
2762 "#ATOMAND6432 PSUEDO!", []>;
2763def ATOMOR6432 : I<0, Pseudo, (outs GR32:$dst1, GR32:$dst2),
2764 (ins i64mem:$ptr, GR32:$val1, GR32:$val2),
2765 "#ATOMOR6432 PSUEDO!", []>;
2766def ATOMXOR6432 : I<0, Pseudo, (outs GR32:$dst1, GR32:$dst2),
2767 (ins i64mem:$ptr, GR32:$val1, GR32:$val2),
2768 "#ATOMXOR6432 PSUEDO!", []>;
2769def ATOMNAND6432 : I<0, Pseudo, (outs GR32:$dst1, GR32:$dst2),
2770 (ins i64mem:$ptr, GR32:$val1, GR32:$val2),
2771 "#ATOMNAND6432 PSUEDO!", []>;
2772def ATOMADD6432 : I<0, Pseudo, (outs GR32:$dst1, GR32:$dst2),
2773 (ins i64mem:$ptr, GR32:$val1, GR32:$val2),
2774 "#ATOMADD6432 PSUEDO!", []>;
2775def ATOMSUB6432 : I<0, Pseudo, (outs GR32:$dst1, GR32:$dst2),
2776 (ins i64mem:$ptr, GR32:$val1, GR32:$val2),
2777 "#ATOMSUB6432 PSUEDO!", []>;
Dale Johannesen51c58ee2008-10-03 22:25:52 +00002778def ATOMSWAP6432 : I<0, Pseudo, (outs GR32:$dst1, GR32:$dst2),
2779 (ins i64mem:$ptr, GR32:$val1, GR32:$val2),
2780 "#ATOMSWAP6432 PSUEDO!", []>;
Dale Johannesenf160d802008-10-02 18:53:47 +00002781}
2782
Andrew Lenharthe44f3902008-02-21 06:45:13 +00002783//===----------------------------------------------------------------------===//
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002784// Non-Instruction Patterns
2785//===----------------------------------------------------------------------===//
2786
Bill Wendlingfef06052008-09-16 21:48:12 +00002787// ConstantPool GlobalAddress, ExternalSymbol, and JumpTable
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002788def : Pat<(i32 (X86Wrapper tconstpool :$dst)), (MOV32ri tconstpool :$dst)>;
2789def : Pat<(i32 (X86Wrapper tjumptable :$dst)), (MOV32ri tjumptable :$dst)>;
Nate Begemanb52948972008-04-12 00:47:57 +00002790def : Pat<(i32 (X86Wrapper tglobaltlsaddr:$dst)),(MOV32ri tglobaltlsaddr:$dst)>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002791def : Pat<(i32 (X86Wrapper tglobaladdr :$dst)), (MOV32ri tglobaladdr :$dst)>;
2792def : Pat<(i32 (X86Wrapper texternalsym:$dst)), (MOV32ri texternalsym:$dst)>;
2793
2794def : Pat<(add GR32:$src1, (X86Wrapper tconstpool:$src2)),
2795 (ADD32ri GR32:$src1, tconstpool:$src2)>;
2796def : Pat<(add GR32:$src1, (X86Wrapper tjumptable:$src2)),
2797 (ADD32ri GR32:$src1, tjumptable:$src2)>;
2798def : Pat<(add GR32:$src1, (X86Wrapper tglobaladdr :$src2)),
2799 (ADD32ri GR32:$src1, tglobaladdr:$src2)>;
2800def : Pat<(add GR32:$src1, (X86Wrapper texternalsym:$src2)),
2801 (ADD32ri GR32:$src1, texternalsym:$src2)>;
2802
2803def : Pat<(store (i32 (X86Wrapper tglobaladdr:$src)), addr:$dst),
2804 (MOV32mi addr:$dst, tglobaladdr:$src)>;
2805def : Pat<(store (i32 (X86Wrapper texternalsym:$src)), addr:$dst),
2806 (MOV32mi addr:$dst, texternalsym:$src)>;
2807
2808// Calls
Arnold Schwaighofere2d6bbb2007-10-11 19:40:01 +00002809// tailcall stuff
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002810def : Pat<(X86tailcall GR32:$dst),
Arnold Schwaighofere2d6bbb2007-10-11 19:40:01 +00002811 (TAILCALL)>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002812
2813def : Pat<(X86tailcall (i32 tglobaladdr:$dst)),
Arnold Schwaighofere2d6bbb2007-10-11 19:40:01 +00002814 (TAILCALL)>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002815def : Pat<(X86tailcall (i32 texternalsym:$dst)),
Arnold Schwaighofere2d6bbb2007-10-11 19:40:01 +00002816 (TAILCALL)>;
2817
2818def : Pat<(X86tcret GR32:$dst, imm:$off),
2819 (TCRETURNri GR32:$dst, imm:$off)>;
2820
2821def : Pat<(X86tcret (i32 tglobaladdr:$dst), imm:$off),
2822 (TCRETURNdi texternalsym:$dst, imm:$off)>;
2823
2824def : Pat<(X86tcret (i32 texternalsym:$dst), imm:$off),
2825 (TCRETURNdi texternalsym:$dst, imm:$off)>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002826
2827def : Pat<(X86call (i32 tglobaladdr:$dst)),
2828 (CALLpcrel32 tglobaladdr:$dst)>;
2829def : Pat<(X86call (i32 texternalsym:$dst)),
2830 (CALLpcrel32 texternalsym:$dst)>;
2831
2832// X86 specific add which produces a flag.
2833def : Pat<(addc GR32:$src1, GR32:$src2),
2834 (ADD32rr GR32:$src1, GR32:$src2)>;
2835def : Pat<(addc GR32:$src1, (load addr:$src2)),
2836 (ADD32rm GR32:$src1, addr:$src2)>;
2837def : Pat<(addc GR32:$src1, imm:$src2),
2838 (ADD32ri GR32:$src1, imm:$src2)>;
2839def : Pat<(addc GR32:$src1, i32immSExt8:$src2),
2840 (ADD32ri8 GR32:$src1, i32immSExt8:$src2)>;
2841
2842def : Pat<(subc GR32:$src1, GR32:$src2),
2843 (SUB32rr GR32:$src1, GR32:$src2)>;
2844def : Pat<(subc GR32:$src1, (load addr:$src2)),
2845 (SUB32rm GR32:$src1, addr:$src2)>;
2846def : Pat<(subc GR32:$src1, imm:$src2),
2847 (SUB32ri GR32:$src1, imm:$src2)>;
2848def : Pat<(subc GR32:$src1, i32immSExt8:$src2),
2849 (SUB32ri8 GR32:$src1, i32immSExt8:$src2)>;
2850
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002851// Comparisons.
2852
2853// TEST R,R is smaller than CMP R,0
Evan Cheng621216e2007-09-29 00:00:36 +00002854def : Pat<(parallel (X86cmp GR8:$src1, 0), (implicit EFLAGS)),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002855 (TEST8rr GR8:$src1, GR8:$src1)>;
Evan Cheng621216e2007-09-29 00:00:36 +00002856def : Pat<(parallel (X86cmp GR16:$src1, 0), (implicit EFLAGS)),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002857 (TEST16rr GR16:$src1, GR16:$src1)>;
Evan Cheng621216e2007-09-29 00:00:36 +00002858def : Pat<(parallel (X86cmp GR32:$src1, 0), (implicit EFLAGS)),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002859 (TEST32rr GR32:$src1, GR32:$src1)>;
2860
Duncan Sands082524c2008-01-23 20:39:46 +00002861// zextload bool -> zextload byte
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002862def : Pat<(zextloadi8i1 addr:$src), (MOV8rm addr:$src)>;
2863def : Pat<(zextloadi16i1 addr:$src), (MOVZX16rm8 addr:$src)>;
2864def : Pat<(zextloadi32i1 addr:$src), (MOVZX32rm8 addr:$src)>;
2865
2866// extload bool -> extload byte
2867def : Pat<(extloadi8i1 addr:$src), (MOV8rm addr:$src)>;
Bill Wendlingce1c5c12008-08-22 20:51:05 +00002868def : Pat<(extloadi16i1 addr:$src), (MOVZX16rm8 addr:$src)>,
2869 Requires<[In32BitMode]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002870def : Pat<(extloadi32i1 addr:$src), (MOVZX32rm8 addr:$src)>;
Bill Wendlingce1c5c12008-08-22 20:51:05 +00002871def : Pat<(extloadi16i8 addr:$src), (MOVZX16rm8 addr:$src)>,
2872 Requires<[In32BitMode]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002873def : Pat<(extloadi32i8 addr:$src), (MOVZX32rm8 addr:$src)>;
2874def : Pat<(extloadi32i16 addr:$src), (MOVZX32rm16 addr:$src)>;
2875
Dan Gohmandd612bb2008-08-20 21:27:32 +00002876// anyext
Bill Wendlingce1c5c12008-08-22 20:51:05 +00002877def : Pat<(i16 (anyext GR8 :$src)), (MOVZX16rr8 GR8 :$src)>,
2878 Requires<[In32BitMode]>;
2879def : Pat<(i32 (anyext GR8 :$src)), (MOVZX32rr8 GR8 :$src)>,
2880 Requires<[In32BitMode]>;
Dan Gohmandd612bb2008-08-20 21:27:32 +00002881def : Pat<(i32 (anyext GR16:$src)),
2882 (INSERT_SUBREG (i32 (IMPLICIT_DEF)), GR16:$src, x86_subreg_16bit)>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002883
Evan Chengf2abee72007-12-13 00:43:27 +00002884// (and (i32 load), 255) -> (zextload i8)
Evan Cheng1e5e5452008-09-29 17:26:18 +00002885def : Pat<(i32 (and (nvloadi32 addr:$src), (i32 255))),
2886 (MOVZX32rm8 addr:$src)>;
2887def : Pat<(i32 (and (nvloadi32 addr:$src), (i32 65535))),
2888 (MOVZX32rm16 addr:$src)>;
Evan Chengf2abee72007-12-13 00:43:27 +00002889
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002890//===----------------------------------------------------------------------===//
2891// Some peepholes
2892//===----------------------------------------------------------------------===//
2893
Dan Gohman9203ab42008-07-30 18:09:17 +00002894// r & (2^16-1) ==> movz
2895def : Pat<(and GR32:$src1, 0xffff),
Dan Gohmandd612bb2008-08-20 21:27:32 +00002896 (MOVZX32rr16 (i16 (EXTRACT_SUBREG GR32:$src1, x86_subreg_16bit)))>;
Dan Gohman5beb1ff2008-08-06 18:27:21 +00002897// r & (2^8-1) ==> movz
2898def : Pat<(and GR32:$src1, 0xff),
Dan Gohmandd612bb2008-08-20 21:27:32 +00002899 (MOVZX32rr8 (i8 (EXTRACT_SUBREG (MOV32to32_ GR32:$src1),
2900 x86_subreg_8bit)))>,
Dan Gohman5beb1ff2008-08-06 18:27:21 +00002901 Requires<[In32BitMode]>;
2902// r & (2^8-1) ==> movz
2903def : Pat<(and GR16:$src1, 0xff),
Dan Gohmandd612bb2008-08-20 21:27:32 +00002904 (MOVZX16rr8 (i8 (EXTRACT_SUBREG (MOV16to16_ GR16:$src1),
2905 x86_subreg_8bit)))>,
2906 Requires<[In32BitMode]>;
2907
2908// sext_inreg patterns
2909def : Pat<(sext_inreg GR32:$src, i16),
2910 (MOVSX32rr16 (i16 (EXTRACT_SUBREG GR32:$src, x86_subreg_16bit)))>;
2911def : Pat<(sext_inreg GR32:$src, i8),
2912 (MOVSX32rr8 (i8 (EXTRACT_SUBREG (MOV32to32_ GR32:$src),
2913 x86_subreg_8bit)))>,
2914 Requires<[In32BitMode]>;
2915def : Pat<(sext_inreg GR16:$src, i8),
2916 (MOVSX16rr8 (i8 (EXTRACT_SUBREG (MOV16to16_ GR16:$src),
2917 x86_subreg_8bit)))>,
2918 Requires<[In32BitMode]>;
2919
2920// trunc patterns
2921def : Pat<(i16 (trunc GR32:$src)),
2922 (i16 (EXTRACT_SUBREG GR32:$src, x86_subreg_16bit))>;
2923def : Pat<(i8 (trunc GR32:$src)),
2924 (i8 (EXTRACT_SUBREG (MOV32to32_ GR32:$src), x86_subreg_8bit))>,
2925 Requires<[In32BitMode]>;
2926def : Pat<(i8 (trunc GR16:$src)),
2927 (i8 (EXTRACT_SUBREG (MOV16to16_ GR16:$src), x86_subreg_8bit))>,
Dan Gohman5beb1ff2008-08-06 18:27:21 +00002928 Requires<[In32BitMode]>;
Dan Gohman9203ab42008-07-30 18:09:17 +00002929
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002930// (shl x, 1) ==> (add x, x)
2931def : Pat<(shl GR8 :$src1, (i8 1)), (ADD8rr GR8 :$src1, GR8 :$src1)>;
2932def : Pat<(shl GR16:$src1, (i8 1)), (ADD16rr GR16:$src1, GR16:$src1)>;
2933def : Pat<(shl GR32:$src1, (i8 1)), (ADD32rr GR32:$src1, GR32:$src1)>;
2934
Evan Cheng76a64c72008-08-30 02:03:58 +00002935// (shl x (and y, 31)) ==> (shl x, y)
2936def : Pat<(shl GR8:$src1, (and CL:$amt, 31)),
2937 (SHL8rCL GR8:$src1)>;
2938def : Pat<(shl GR16:$src1, (and CL:$amt, 31)),
2939 (SHL16rCL GR16:$src1)>;
2940def : Pat<(shl GR32:$src1, (and CL:$amt, 31)),
2941 (SHL32rCL GR32:$src1)>;
2942def : Pat<(store (shl (loadi8 addr:$dst), (and CL:$amt, 31)), addr:$dst),
2943 (SHL8mCL addr:$dst)>;
2944def : Pat<(store (shl (loadi16 addr:$dst), (and CL:$amt, 31)), addr:$dst),
2945 (SHL16mCL addr:$dst)>;
2946def : Pat<(store (shl (loadi32 addr:$dst), (and CL:$amt, 31)), addr:$dst),
2947 (SHL32mCL addr:$dst)>;
2948
2949def : Pat<(srl GR8:$src1, (and CL:$amt, 31)),
2950 (SHR8rCL GR8:$src1)>;
2951def : Pat<(srl GR16:$src1, (and CL:$amt, 31)),
2952 (SHR16rCL GR16:$src1)>;
2953def : Pat<(srl GR32:$src1, (and CL:$amt, 31)),
2954 (SHR32rCL GR32:$src1)>;
2955def : Pat<(store (srl (loadi8 addr:$dst), (and CL:$amt, 31)), addr:$dst),
2956 (SHR8mCL addr:$dst)>;
2957def : Pat<(store (srl (loadi16 addr:$dst), (and CL:$amt, 31)), addr:$dst),
2958 (SHR16mCL addr:$dst)>;
2959def : Pat<(store (srl (loadi32 addr:$dst), (and CL:$amt, 31)), addr:$dst),
2960 (SHR32mCL addr:$dst)>;
2961
2962def : Pat<(sra GR8:$src1, (and CL:$amt, 31)),
2963 (SAR8rCL GR8:$src1)>;
2964def : Pat<(sra GR16:$src1, (and CL:$amt, 31)),
2965 (SAR16rCL GR16:$src1)>;
2966def : Pat<(sra GR32:$src1, (and CL:$amt, 31)),
2967 (SAR32rCL GR32:$src1)>;
2968def : Pat<(store (sra (loadi8 addr:$dst), (and CL:$amt, 31)), addr:$dst),
2969 (SAR8mCL addr:$dst)>;
2970def : Pat<(store (sra (loadi16 addr:$dst), (and CL:$amt, 31)), addr:$dst),
2971 (SAR16mCL addr:$dst)>;
2972def : Pat<(store (sra (loadi32 addr:$dst), (and CL:$amt, 31)), addr:$dst),
2973 (SAR32mCL addr:$dst)>;
2974
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002975// (or (x >> c) | (y << (32 - c))) ==> (shrd32 x, y, c)
2976def : Pat<(or (srl GR32:$src1, CL:$amt),
2977 (shl GR32:$src2, (sub 32, CL:$amt))),
2978 (SHRD32rrCL GR32:$src1, GR32:$src2)>;
2979
2980def : Pat<(store (or (srl (loadi32 addr:$dst), CL:$amt),
2981 (shl GR32:$src2, (sub 32, CL:$amt))), addr:$dst),
2982 (SHRD32mrCL addr:$dst, GR32:$src2)>;
2983
2984// (or (x << c) | (y >> (32 - c))) ==> (shld32 x, y, c)
2985def : Pat<(or (shl GR32:$src1, CL:$amt),
2986 (srl GR32:$src2, (sub 32, CL:$amt))),
2987 (SHLD32rrCL GR32:$src1, GR32:$src2)>;
2988
2989def : Pat<(store (or (shl (loadi32 addr:$dst), CL:$amt),
2990 (srl GR32:$src2, (sub 32, CL:$amt))), addr:$dst),
2991 (SHLD32mrCL addr:$dst, GR32:$src2)>;
2992
2993// (or (x >> c) | (y << (16 - c))) ==> (shrd16 x, y, c)
2994def : Pat<(or (srl GR16:$src1, CL:$amt),
2995 (shl GR16:$src2, (sub 16, CL:$amt))),
2996 (SHRD16rrCL GR16:$src1, GR16:$src2)>;
2997
2998def : Pat<(store (or (srl (loadi16 addr:$dst), CL:$amt),
2999 (shl GR16:$src2, (sub 16, CL:$amt))), addr:$dst),
3000 (SHRD16mrCL addr:$dst, GR16:$src2)>;
3001
3002// (or (x << c) | (y >> (16 - c))) ==> (shld16 x, y, c)
3003def : Pat<(or (shl GR16:$src1, CL:$amt),
3004 (srl GR16:$src2, (sub 16, CL:$amt))),
3005 (SHLD16rrCL GR16:$src1, GR16:$src2)>;
3006
3007def : Pat<(store (or (shl (loadi16 addr:$dst), CL:$amt),
3008 (srl GR16:$src2, (sub 16, CL:$amt))), addr:$dst),
3009 (SHLD16mrCL addr:$dst, GR16:$src2)>;
3010
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003011//===----------------------------------------------------------------------===//
3012// Floating Point Stack Support
3013//===----------------------------------------------------------------------===//
3014
3015include "X86InstrFPStack.td"
3016
3017//===----------------------------------------------------------------------===//
Evan Cheng86ab7d32007-07-31 08:04:03 +00003018// X86-64 Support
3019//===----------------------------------------------------------------------===//
3020
Chris Lattner2de8d2b2008-01-10 05:50:42 +00003021include "X86Instr64bit.td"
Evan Cheng86ab7d32007-07-31 08:04:03 +00003022
3023//===----------------------------------------------------------------------===//
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003024// XMM Floating point support (requires SSE / SSE2)
3025//===----------------------------------------------------------------------===//
3026
3027include "X86InstrSSE.td"
Evan Cheng5e4d1e72008-04-25 18:19:54 +00003028
3029//===----------------------------------------------------------------------===//
3030// MMX and XMM Packed Integer support (requires MMX, SSE, and SSE2)
3031//===----------------------------------------------------------------------===//
3032
3033include "X86InstrMMX.td"