blob: e23bc704b086221ae5f3fa50c705ca3618b806b7 [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.
Dan Gohman2a174122008-10-15 06:50:19 +0000257def loadi16 : PatFrag<(ops node:$ptr), (i16 (unindexedload node:$ptr)), [{
Dan Gohman8335c412008-08-20 15:24:22 +0000258 LoadSDNode *LD = cast<LoadSDNode>(N);
Dan Gohman8335c412008-08-20 15:24:22 +0000259 ISD::LoadExtType ExtType = LD->getExtensionType();
260 if (ExtType == ISD::NON_EXTLOAD)
261 return true;
262 if (ExtType == ISD::EXTLOAD)
263 return LD->getAlignment() >= 2 && !LD->isVolatile();
Evan Cheng8b765e92008-05-13 00:54:02 +0000264 return false;
265}]>;
266
Dan Gohman2a174122008-10-15 06:50:19 +0000267def loadi16_anyext : PatFrag<(ops node:$ptr), (i32 (unindexedload node:$ptr)), [{
Evan Cheng56ec77b2008-09-24 23:27:55 +0000268 LoadSDNode *LD = cast<LoadSDNode>(N);
Evan Cheng56ec77b2008-09-24 23:27:55 +0000269 ISD::LoadExtType ExtType = LD->getExtensionType();
270 if (ExtType == ISD::EXTLOAD)
271 return LD->getAlignment() >= 2 && !LD->isVolatile();
272 return false;
273}]>;
274
Dan Gohman2a174122008-10-15 06:50:19 +0000275def loadi32 : PatFrag<(ops node:$ptr), (i32 (unindexedload node:$ptr)), [{
Dan Gohman8335c412008-08-20 15:24:22 +0000276 LoadSDNode *LD = cast<LoadSDNode>(N);
Dan Gohman8335c412008-08-20 15:24:22 +0000277 ISD::LoadExtType ExtType = LD->getExtensionType();
278 if (ExtType == ISD::NON_EXTLOAD)
279 return true;
280 if (ExtType == ISD::EXTLOAD)
281 return LD->getAlignment() >= 4 && !LD->isVolatile();
Evan Cheng8b765e92008-05-13 00:54:02 +0000282 return false;
283}]>;
284
Dan Gohman2a174122008-10-15 06:50:19 +0000285def nvloadi32 : PatFrag<(ops node:$ptr), (i32 (unindexedload node:$ptr)), [{
Evan Cheng1e5e5452008-09-29 17:26:18 +0000286 LoadSDNode *LD = cast<LoadSDNode>(N);
287 if (LD->isVolatile())
288 return false;
Evan Cheng1e5e5452008-09-29 17:26:18 +0000289 ISD::LoadExtType ExtType = LD->getExtensionType();
290 if (ExtType == ISD::NON_EXTLOAD)
291 return true;
292 if (ExtType == ISD::EXTLOAD)
293 return LD->getAlignment() >= 4;
294 return false;
295}]>;
296
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000297def loadi8 : PatFrag<(ops node:$ptr), (i8 (load node:$ptr))>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000298def loadi64 : PatFrag<(ops node:$ptr), (i64 (load node:$ptr))>;
299
300def loadf32 : PatFrag<(ops node:$ptr), (f32 (load node:$ptr))>;
301def loadf64 : PatFrag<(ops node:$ptr), (f64 (load node:$ptr))>;
Dale Johannesen4ab00bd2007-08-05 18:49:15 +0000302def loadf80 : PatFrag<(ops node:$ptr), (f80 (load node:$ptr))>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000303
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000304def sextloadi16i8 : PatFrag<(ops node:$ptr), (i16 (sextloadi8 node:$ptr))>;
305def sextloadi32i8 : PatFrag<(ops node:$ptr), (i32 (sextloadi8 node:$ptr))>;
306def sextloadi32i16 : PatFrag<(ops node:$ptr), (i32 (sextloadi16 node:$ptr))>;
307
308def zextloadi8i1 : PatFrag<(ops node:$ptr), (i8 (zextloadi1 node:$ptr))>;
309def zextloadi16i1 : PatFrag<(ops node:$ptr), (i16 (zextloadi1 node:$ptr))>;
310def zextloadi32i1 : PatFrag<(ops node:$ptr), (i32 (zextloadi1 node:$ptr))>;
311def zextloadi16i8 : PatFrag<(ops node:$ptr), (i16 (zextloadi8 node:$ptr))>;
312def zextloadi32i8 : PatFrag<(ops node:$ptr), (i32 (zextloadi8 node:$ptr))>;
313def zextloadi32i16 : PatFrag<(ops node:$ptr), (i32 (zextloadi16 node:$ptr))>;
314
315def extloadi8i1 : PatFrag<(ops node:$ptr), (i8 (extloadi1 node:$ptr))>;
316def extloadi16i1 : PatFrag<(ops node:$ptr), (i16 (extloadi1 node:$ptr))>;
317def extloadi32i1 : PatFrag<(ops node:$ptr), (i32 (extloadi1 node:$ptr))>;
318def extloadi16i8 : PatFrag<(ops node:$ptr), (i16 (extloadi8 node:$ptr))>;
319def extloadi32i8 : PatFrag<(ops node:$ptr), (i32 (extloadi8 node:$ptr))>;
320def extloadi32i16 : PatFrag<(ops node:$ptr), (i32 (extloadi16 node:$ptr))>;
321
Chris Lattner21da6382008-02-19 17:37:35 +0000322
323// An 'and' node with a single use.
324def and_su : PatFrag<(ops node:$lhs, node:$rhs), (and node:$lhs, node:$rhs), [{
Evan Cheng9123cfa2008-03-04 00:40:35 +0000325 return N->hasOneUse();
Chris Lattner21da6382008-02-19 17:37:35 +0000326}]>;
327
Dan Gohman921581d2008-10-17 01:23:35 +0000328// 'shld' and 'shrd' instruction patterns. Note that even though these have
329// the srl and shl in their patterns, the C++ code must still check for them,
330// because predicates are tested before children nodes are explored.
331
332def shrd : PatFrag<(ops node:$src1, node:$amt1, node:$src2, node:$amt2),
333 (or (srl node:$src1, node:$amt1),
334 (shl node:$src2, node:$amt2)), [{
335 assert(N->getOpcode() == ISD::OR);
336 return N->getOperand(0).getOpcode() == ISD::SRL &&
337 N->getOperand(1).getOpcode() == ISD::SHL &&
338 isa<ConstantSDNode>(N->getOperand(0).getOperand(1)) &&
339 isa<ConstantSDNode>(N->getOperand(1).getOperand(1)) &&
340 N->getOperand(0).getConstantOperandVal(1) ==
341 N->getValueSizeInBits(0) - N->getOperand(1).getConstantOperandVal(1);
342}]>;
343
344def shld : PatFrag<(ops node:$src1, node:$amt1, node:$src2, node:$amt2),
345 (or (shl node:$src1, node:$amt1),
346 (srl node:$src2, node:$amt2)), [{
347 assert(N->getOpcode() == ISD::OR);
348 return N->getOperand(0).getOpcode() == ISD::SHL &&
349 N->getOperand(1).getOpcode() == ISD::SRL &&
350 isa<ConstantSDNode>(N->getOperand(0).getOperand(1)) &&
351 isa<ConstantSDNode>(N->getOperand(1).getOperand(1)) &&
352 N->getOperand(0).getConstantOperandVal(1) ==
353 N->getValueSizeInBits(0) - N->getOperand(1).getConstantOperandVal(1);
354}]>;
355
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000356//===----------------------------------------------------------------------===//
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000357// Instruction list...
358//
359
360// ADJCALLSTACKDOWN/UP implicitly use/def ESP because they may be expanded into
361// a stack adjustment and the codegen must know that they may modify the stack
362// pointer before prolog-epilog rewriting occurs.
Chris Lattnerb56cc342008-03-11 03:23:40 +0000363// Pessimistically assume ADJCALLSTACKDOWN / ADJCALLSTACKUP will become
364// sub / add which can clobber EFLAGS.
Evan Cheng037364a2007-09-28 01:19:48 +0000365let Defs = [ESP, EFLAGS], Uses = [ESP] in {
Dan Gohman01c9f772008-10-01 18:28:06 +0000366def ADJCALLSTACKDOWN32 : I<0, Pseudo, (outs), (ins i32imm:$amt),
367 "#ADJCALLSTACKDOWN",
Chris Lattnerfe5d4022008-10-11 22:08:30 +0000368 [(X86callseq_start timm:$amt)]>,
Dan Gohman01c9f772008-10-01 18:28:06 +0000369 Requires<[In32BitMode]>;
370def ADJCALLSTACKUP32 : I<0, Pseudo, (outs), (ins i32imm:$amt1, i32imm:$amt2),
371 "#ADJCALLSTACKUP",
Chris Lattnerfe5d4022008-10-11 22:08:30 +0000372 [(X86callseq_end timm:$amt1, timm:$amt2)]>,
Dan Gohman01c9f772008-10-01 18:28:06 +0000373 Requires<[In32BitMode]>;
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000374}
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000375
376// Nop
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000377let neverHasSideEffects = 1 in
378 def NOOP : I<0x90, RawFrm, (outs), (ins), "nop", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000379
Evan Cheng0729ccf2008-01-05 00:41:47 +0000380// PIC base
Dan Gohman9499cfe2008-10-01 04:14:30 +0000381let neverHasSideEffects = 1, isNotDuplicable = 1, Uses = [ESP] in
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000382 def MOVPC32r : Ii32<0xE8, Pseudo, (outs GR32:$reg), (ins piclabel:$label),
383 "call\t$label\n\tpop{l}\t$reg", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000384
385//===----------------------------------------------------------------------===//
386// Control Flow Instructions...
387//
388
389// Return instructions.
390let isTerminator = 1, isReturn = 1, isBarrier = 1,
Chris Lattnerb56cc342008-03-11 03:23:40 +0000391 hasCtrlDep = 1, FPForm = SpecialFP, FPFormBits = SpecialFP.Value in {
Dan Gohman2c4be2a2008-05-31 02:11:25 +0000392 def RET : I <0xC3, RawFrm, (outs), (ins variable_ops),
Chris Lattnerb56cc342008-03-11 03:23:40 +0000393 "ret",
Dan Gohman2c4be2a2008-05-31 02:11:25 +0000394 [(X86retflag 0)]>;
Chris Lattnerb56cc342008-03-11 03:23:40 +0000395 def RETI : Ii16<0xC2, RawFrm, (outs), (ins i16imm:$amt, variable_ops),
396 "ret\t$amt",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000397 [(X86retflag imm:$amt)]>;
398}
399
400// All branches are RawFrm, Void, Branch, and Terminators
Evan Cheng37e7c752007-07-21 00:34:19 +0000401let isBranch = 1, isTerminator = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +0000402 class IBr<bits<8> opcode, dag ins, string asm, list<dag> pattern> :
403 I<opcode, RawFrm, (outs), ins, asm, pattern>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000404
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000405let isBranch = 1, isBarrier = 1 in
Dan Gohman91888f02007-07-31 20:11:57 +0000406 def JMP : IBr<0xE9, (ins brtarget:$dst), "jmp\t$dst", [(br bb:$dst)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000407
Owen Andersonf8053082007-11-12 07:39:39 +0000408// Indirect branches
409let isBranch = 1, isTerminator = 1, isBarrier = 1, isIndirectBranch = 1 in {
Dan Gohman91888f02007-07-31 20:11:57 +0000410 def JMP32r : I<0xFF, MRM4r, (outs), (ins GR32:$dst), "jmp{l}\t{*}$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000411 [(brind GR32:$dst)]>;
Dan Gohman91888f02007-07-31 20:11:57 +0000412 def JMP32m : I<0xFF, MRM4m, (outs), (ins i32mem:$dst), "jmp{l}\t{*}$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000413 [(brind (loadi32 addr:$dst))]>;
414}
415
416// Conditional branches
Evan Cheng950aac02007-09-25 01:57:46 +0000417let Uses = [EFLAGS] in {
Dan Gohman91888f02007-07-31 20:11:57 +0000418def JE : IBr<0x84, (ins brtarget:$dst), "je\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000419 [(X86brcond bb:$dst, X86_COND_E, EFLAGS)]>, TB;
Dan Gohman91888f02007-07-31 20:11:57 +0000420def JNE : IBr<0x85, (ins brtarget:$dst), "jne\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000421 [(X86brcond bb:$dst, X86_COND_NE, EFLAGS)]>, TB;
Dan Gohman91888f02007-07-31 20:11:57 +0000422def JL : IBr<0x8C, (ins brtarget:$dst), "jl\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000423 [(X86brcond bb:$dst, X86_COND_L, EFLAGS)]>, TB;
Dan Gohman91888f02007-07-31 20:11:57 +0000424def JLE : IBr<0x8E, (ins brtarget:$dst), "jle\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000425 [(X86brcond bb:$dst, X86_COND_LE, EFLAGS)]>, TB;
Dan Gohman91888f02007-07-31 20:11:57 +0000426def JG : IBr<0x8F, (ins brtarget:$dst), "jg\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000427 [(X86brcond bb:$dst, X86_COND_G, EFLAGS)]>, TB;
Dan Gohman91888f02007-07-31 20:11:57 +0000428def JGE : IBr<0x8D, (ins brtarget:$dst), "jge\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000429 [(X86brcond bb:$dst, X86_COND_GE, EFLAGS)]>, TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000430
Dan Gohman91888f02007-07-31 20:11:57 +0000431def JB : IBr<0x82, (ins brtarget:$dst), "jb\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000432 [(X86brcond bb:$dst, X86_COND_B, EFLAGS)]>, TB;
Dan Gohman91888f02007-07-31 20:11:57 +0000433def JBE : IBr<0x86, (ins brtarget:$dst), "jbe\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000434 [(X86brcond bb:$dst, X86_COND_BE, EFLAGS)]>, TB;
Dan Gohman91888f02007-07-31 20:11:57 +0000435def JA : IBr<0x87, (ins brtarget:$dst), "ja\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000436 [(X86brcond bb:$dst, X86_COND_A, EFLAGS)]>, TB;
Dan Gohman91888f02007-07-31 20:11:57 +0000437def JAE : IBr<0x83, (ins brtarget:$dst), "jae\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000438 [(X86brcond bb:$dst, X86_COND_AE, EFLAGS)]>, TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000439
Dan Gohman91888f02007-07-31 20:11:57 +0000440def JS : IBr<0x88, (ins brtarget:$dst), "js\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000441 [(X86brcond bb:$dst, X86_COND_S, EFLAGS)]>, TB;
Dan Gohman91888f02007-07-31 20:11:57 +0000442def JNS : IBr<0x89, (ins brtarget:$dst), "jns\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000443 [(X86brcond bb:$dst, X86_COND_NS, EFLAGS)]>, TB;
Dan Gohman91888f02007-07-31 20:11:57 +0000444def JP : IBr<0x8A, (ins brtarget:$dst), "jp\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000445 [(X86brcond bb:$dst, X86_COND_P, EFLAGS)]>, TB;
Dan Gohman91888f02007-07-31 20:11:57 +0000446def JNP : IBr<0x8B, (ins brtarget:$dst), "jnp\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000447 [(X86brcond bb:$dst, X86_COND_NP, EFLAGS)]>, TB;
Dan Gohman91888f02007-07-31 20:11:57 +0000448def JO : IBr<0x80, (ins brtarget:$dst), "jo\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000449 [(X86brcond bb:$dst, X86_COND_O, EFLAGS)]>, TB;
Dan Gohman91888f02007-07-31 20:11:57 +0000450def JNO : IBr<0x81, (ins brtarget:$dst), "jno\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000451 [(X86brcond bb:$dst, X86_COND_NO, EFLAGS)]>, TB;
Evan Cheng950aac02007-09-25 01:57:46 +0000452} // Uses = [EFLAGS]
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000453
454//===----------------------------------------------------------------------===//
455// Call Instructions...
456//
Evan Cheng37e7c752007-07-21 00:34:19 +0000457let isCall = 1 in
Dan Gohman01c9f772008-10-01 18:28:06 +0000458 // All calls clobber the non-callee saved registers. ESP is marked as
459 // a use to prevent stack-pointer assignments that appear immediately
460 // before calls from potentially appearing dead. Uses for argument
461 // registers are added manually.
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000462 let Defs = [EAX, ECX, EDX, FP0, FP1, FP2, FP3, FP4, FP5, FP6, ST0,
463 MM0, MM1, MM2, MM3, MM4, MM5, MM6, MM7,
Evan Cheng2293b252008-10-17 21:02:22 +0000464 XMM0, XMM1, XMM2, XMM3, XMM4, XMM5, XMM6, XMM7,
465 XMM8, XMM9, XMM10, XMM11, XMM12, XMM13, XMM14, XMM15, EFLAGS],
Dan Gohman9499cfe2008-10-01 04:14:30 +0000466 Uses = [ESP] in {
Evan Cheng34f93712007-12-22 02:26:46 +0000467 def CALLpcrel32 : Ii32<0xE8, RawFrm, (outs), (ins i32imm:$dst,variable_ops),
468 "call\t${dst:call}", []>;
Evan Chengb783fa32007-07-19 01:14:50 +0000469 def CALL32r : I<0xFF, MRM2r, (outs), (ins GR32:$dst, variable_ops),
Dan Gohman91888f02007-07-31 20:11:57 +0000470 "call\t{*}$dst", [(X86call GR32:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000471 def CALL32m : I<0xFF, MRM2m, (outs), (ins i32mem:$dst, variable_ops),
Dan Gohmanea4faba2008-05-29 21:50:34 +0000472 "call\t{*}$dst", [(X86call (loadi32 addr:$dst))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000473 }
474
475// Tail call stuff.
Arnold Schwaighofere2d6bbb2007-10-11 19:40:01 +0000476
Chris Lattnerb56cc342008-03-11 03:23:40 +0000477def TAILCALL : I<0, Pseudo, (outs), (ins),
Arnold Schwaighofere2d6bbb2007-10-11 19:40:01 +0000478 "#TAILCALL",
479 []>;
480
Evan Cheng37e7c752007-07-21 00:34:19 +0000481let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1 in
Arnold Schwaighofer6fd37ac2008-03-19 16:39:45 +0000482def TCRETURNdi : I<0, Pseudo, (outs), (ins i32imm:$dst, i32imm:$offset, variable_ops),
Arnold Schwaighofere2d6bbb2007-10-11 19:40:01 +0000483 "#TC_RETURN $dst $offset",
484 []>;
485
486let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1 in
Arnold Schwaighofer6fd37ac2008-03-19 16:39:45 +0000487def TCRETURNri : I<0, Pseudo, (outs), (ins GR32:$dst, i32imm:$offset, variable_ops),
Arnold Schwaighofere2d6bbb2007-10-11 19:40:01 +0000488 "#TC_RETURN $dst $offset",
489 []>;
490
491let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1 in
Arnold Schwaighofera0032722008-04-30 09:16:33 +0000492
Arnold Schwaighofere2d6bbb2007-10-11 19:40:01 +0000493 def TAILJMPd : IBr<0xE9, (ins i32imm:$dst), "jmp\t${dst:call} # TAILCALL",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000494 []>;
Evan Cheng37e7c752007-07-21 00:34:19 +0000495let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1 in
Arnold Schwaighofere2d6bbb2007-10-11 19:40:01 +0000496 def TAILJMPr : I<0xFF, MRM4r, (outs), (ins GR32:$dst), "jmp{l}\t{*}$dst # TAILCALL",
497 []>;
Evan Cheng37e7c752007-07-21 00:34:19 +0000498let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +0000499 def TAILJMPm : I<0xFF, MRM4m, (outs), (ins i32mem:$dst),
Arnold Schwaighofere2d6bbb2007-10-11 19:40:01 +0000500 "jmp\t{*}$dst # TAILCALL", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000501
502//===----------------------------------------------------------------------===//
503// Miscellaneous Instructions...
504//
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000505let Defs = [EBP, ESP], Uses = [EBP, ESP], mayLoad = 1, neverHasSideEffects=1 in
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000506def LEAVE : I<0xC9, RawFrm,
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000507 (outs), (ins), "leave", []>;
508
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000509let Defs = [ESP], Uses = [ESP], neverHasSideEffects=1 in {
510let mayLoad = 1 in
Evan Chengd8434332007-09-26 01:29:06 +0000511def POP32r : I<0x58, AddRegFrm, (outs GR32:$reg), (ins), "pop{l}\t$reg", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000512
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000513let mayStore = 1 in
Evan Chengd8434332007-09-26 01:29:06 +0000514def PUSH32r : I<0x50, AddRegFrm, (outs), (ins GR32:$reg), "push{l}\t$reg",[]>;
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000515}
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000516
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000517let Defs = [ESP, EFLAGS], Uses = [ESP], mayLoad = 1, neverHasSideEffects=1 in
Evan Chengf1341312007-09-26 21:28:00 +0000518def POPFD : I<0x9D, RawFrm, (outs), (ins), "popf", []>;
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000519let Defs = [ESP], Uses = [ESP, EFLAGS], mayStore = 1, neverHasSideEffects=1 in
Evan Chengf1341312007-09-26 21:28:00 +0000520def PUSHFD : I<0x9C, RawFrm, (outs), (ins), "pushf", []>;
Evan Chengd8434332007-09-26 01:29:06 +0000521
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000522let isTwoAddress = 1 in // GR32 = bswap GR32
523 def BSWAP32r : I<0xC8, AddRegFrm,
Evan Chengb783fa32007-07-19 01:14:50 +0000524 (outs GR32:$dst), (ins GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000525 "bswap{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000526 [(set GR32:$dst, (bswap GR32:$src))]>, TB;
527
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000528
Evan Cheng48679f42007-12-14 02:13:44 +0000529// Bit scan instructions.
530let Defs = [EFLAGS] in {
Evan Cheng4e33de92007-12-14 18:49:43 +0000531def BSF16rr : I<0xBC, MRMSrcReg, (outs GR16:$dst), (ins GR16:$src),
Dan Gohmancdb54c62007-12-14 15:10:00 +0000532 "bsf{w}\t{$src, $dst|$dst, $src}",
Evan Cheng7cfbfe32007-12-14 08:30:15 +0000533 [(set GR16:$dst, (X86bsf GR16:$src)), (implicit EFLAGS)]>, TB;
Evan Cheng48679f42007-12-14 02:13:44 +0000534def BSF16rm : I<0xBC, MRMSrcMem, (outs GR16:$dst), (ins i16mem:$src),
Dan Gohmancdb54c62007-12-14 15:10:00 +0000535 "bsf{w}\t{$src, $dst|$dst, $src}",
Evan Cheng7cfbfe32007-12-14 08:30:15 +0000536 [(set GR16:$dst, (X86bsf (loadi16 addr:$src))),
537 (implicit EFLAGS)]>, TB;
Evan Cheng4e33de92007-12-14 18:49:43 +0000538def BSF32rr : I<0xBC, MRMSrcReg, (outs GR32:$dst), (ins GR32:$src),
Dan Gohmancdb54c62007-12-14 15:10:00 +0000539 "bsf{l}\t{$src, $dst|$dst, $src}",
Evan Cheng7cfbfe32007-12-14 08:30:15 +0000540 [(set GR32:$dst, (X86bsf GR32:$src)), (implicit EFLAGS)]>, TB;
Evan Cheng48679f42007-12-14 02:13:44 +0000541def BSF32rm : I<0xBC, MRMSrcMem, (outs GR32:$dst), (ins i32mem:$src),
Dan Gohmancdb54c62007-12-14 15:10:00 +0000542 "bsf{l}\t{$src, $dst|$dst, $src}",
Evan Cheng7cfbfe32007-12-14 08:30:15 +0000543 [(set GR32:$dst, (X86bsf (loadi32 addr:$src))),
544 (implicit EFLAGS)]>, TB;
Evan Cheng48679f42007-12-14 02:13:44 +0000545
Evan Cheng4e33de92007-12-14 18:49:43 +0000546def BSR16rr : I<0xBD, MRMSrcReg, (outs GR16:$dst), (ins GR16:$src),
Dan Gohmancdb54c62007-12-14 15:10:00 +0000547 "bsr{w}\t{$src, $dst|$dst, $src}",
Evan Cheng7cfbfe32007-12-14 08:30:15 +0000548 [(set GR16:$dst, (X86bsr GR16:$src)), (implicit EFLAGS)]>, TB;
Evan Cheng48679f42007-12-14 02:13:44 +0000549def BSR16rm : I<0xBD, MRMSrcMem, (outs GR16:$dst), (ins i16mem:$src),
Dan Gohmancdb54c62007-12-14 15:10:00 +0000550 "bsr{w}\t{$src, $dst|$dst, $src}",
Evan Cheng7cfbfe32007-12-14 08:30:15 +0000551 [(set GR16:$dst, (X86bsr (loadi16 addr:$src))),
552 (implicit EFLAGS)]>, TB;
Evan Cheng4e33de92007-12-14 18:49:43 +0000553def BSR32rr : I<0xBD, MRMSrcReg, (outs GR32:$dst), (ins GR32:$src),
Dan Gohmancdb54c62007-12-14 15:10:00 +0000554 "bsr{l}\t{$src, $dst|$dst, $src}",
Evan Cheng7cfbfe32007-12-14 08:30:15 +0000555 [(set GR32:$dst, (X86bsr GR32:$src)), (implicit EFLAGS)]>, TB;
Evan Cheng48679f42007-12-14 02:13:44 +0000556def BSR32rm : I<0xBD, MRMSrcMem, (outs GR32:$dst), (ins i32mem:$src),
Dan Gohmancdb54c62007-12-14 15:10:00 +0000557 "bsr{l}\t{$src, $dst|$dst, $src}",
Evan Cheng7cfbfe32007-12-14 08:30:15 +0000558 [(set GR32:$dst, (X86bsr (loadi32 addr:$src))),
559 (implicit EFLAGS)]>, TB;
Evan Cheng48679f42007-12-14 02:13:44 +0000560} // Defs = [EFLAGS]
561
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000562let neverHasSideEffects = 1 in
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000563def LEA16r : I<0x8D, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +0000564 (outs GR16:$dst), (ins i32mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000565 "lea{w}\t{$src|$dst}, {$dst|$src}", []>, OpSize;
Evan Cheng1ea8e6b2008-03-27 01:41:09 +0000566let isReMaterializable = 1 in
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000567def LEA32r : I<0x8D, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +0000568 (outs GR32:$dst), (ins lea32mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000569 "lea{l}\t{$src|$dst}, {$dst|$src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000570 [(set GR32:$dst, lea32addr:$src)]>, Requires<[In32BitMode]>;
571
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000572let Defs = [ECX,EDI,ESI], Uses = [ECX,EDI,ESI] in {
Evan Chengb783fa32007-07-19 01:14:50 +0000573def REP_MOVSB : I<0xA4, RawFrm, (outs), (ins), "{rep;movsb|rep movsb}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000574 [(X86rep_movs i8)]>, REP;
Evan Chengb783fa32007-07-19 01:14:50 +0000575def REP_MOVSW : I<0xA5, RawFrm, (outs), (ins), "{rep;movsw|rep movsw}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000576 [(X86rep_movs i16)]>, REP, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +0000577def REP_MOVSD : I<0xA5, RawFrm, (outs), (ins), "{rep;movsl|rep movsd}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000578 [(X86rep_movs i32)]>, REP;
579}
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000580
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000581let Defs = [ECX,EDI], Uses = [AL,ECX,EDI] in
Evan Chengb783fa32007-07-19 01:14:50 +0000582def REP_STOSB : I<0xAA, RawFrm, (outs), (ins), "{rep;stosb|rep stosb}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000583 [(X86rep_stos i8)]>, REP;
584let Defs = [ECX,EDI], Uses = [AX,ECX,EDI] in
Evan Chengb783fa32007-07-19 01:14:50 +0000585def REP_STOSW : I<0xAB, RawFrm, (outs), (ins), "{rep;stosw|rep stosw}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000586 [(X86rep_stos i16)]>, REP, OpSize;
587let Defs = [ECX,EDI], Uses = [EAX,ECX,EDI] in
Evan Chengb783fa32007-07-19 01:14:50 +0000588def REP_STOSD : I<0xAB, RawFrm, (outs), (ins), "{rep;stosl|rep stosd}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000589 [(X86rep_stos i32)]>, REP;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000590
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000591let Defs = [RAX, RDX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000592def RDTSC : I<0x31, RawFrm, (outs), (ins), "rdtsc", [(X86rdtsc)]>,
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000593 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000594
Anton Korobeynikov39d40ba2008-01-15 07:02:33 +0000595let isBarrier = 1, hasCtrlDep = 1 in {
Chris Lattner56b941f2008-01-15 21:58:22 +0000596def TRAP : I<0x0B, RawFrm, (outs), (ins), "ud2", [(trap)]>, TB;
Anton Korobeynikov39d40ba2008-01-15 07:02:33 +0000597}
598
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000599//===----------------------------------------------------------------------===//
600// Input/Output Instructions...
601//
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000602let Defs = [AL], Uses = [DX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000603def IN8rr : I<0xEC, RawFrm, (outs), (ins),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000604 "in{b}\t{%dx, %al|%AL, %DX}", []>;
605let Defs = [AX], Uses = [DX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000606def IN16rr : I<0xED, RawFrm, (outs), (ins),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000607 "in{w}\t{%dx, %ax|%AX, %DX}", []>, OpSize;
608let Defs = [EAX], Uses = [DX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000609def IN32rr : I<0xED, RawFrm, (outs), (ins),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000610 "in{l}\t{%dx, %eax|%EAX, %DX}", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000611
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000612let Defs = [AL] in
Evan Chengb783fa32007-07-19 01:14:50 +0000613def IN8ri : Ii8<0xE4, RawFrm, (outs), (ins i16i8imm:$port),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000614 "in{b}\t{$port, %al|%AL, $port}", []>;
615let Defs = [AX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000616def IN16ri : Ii8<0xE5, RawFrm, (outs), (ins i16i8imm:$port),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000617 "in{w}\t{$port, %ax|%AX, $port}", []>, OpSize;
618let Defs = [EAX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000619def IN32ri : Ii8<0xE5, RawFrm, (outs), (ins i16i8imm:$port),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000620 "in{l}\t{$port, %eax|%EAX, $port}", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000621
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000622let Uses = [DX, AL] in
Evan Chengb783fa32007-07-19 01:14:50 +0000623def OUT8rr : I<0xEE, RawFrm, (outs), (ins),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000624 "out{b}\t{%al, %dx|%DX, %AL}", []>;
625let Uses = [DX, AX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000626def OUT16rr : I<0xEF, RawFrm, (outs), (ins),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000627 "out{w}\t{%ax, %dx|%DX, %AX}", []>, OpSize;
628let Uses = [DX, EAX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000629def OUT32rr : I<0xEF, RawFrm, (outs), (ins),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000630 "out{l}\t{%eax, %dx|%DX, %EAX}", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000631
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000632let Uses = [AL] in
Evan Chengb783fa32007-07-19 01:14:50 +0000633def OUT8ir : Ii8<0xE6, RawFrm, (outs), (ins i16i8imm:$port),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000634 "out{b}\t{%al, $port|$port, %AL}", []>;
635let Uses = [AX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000636def OUT16ir : Ii8<0xE7, RawFrm, (outs), (ins i16i8imm:$port),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000637 "out{w}\t{%ax, $port|$port, %AX}", []>, OpSize;
638let Uses = [EAX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000639def OUT32ir : Ii8<0xE7, RawFrm, (outs), (ins i16i8imm:$port),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000640 "out{l}\t{%eax, $port|$port, %EAX}", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000641
642//===----------------------------------------------------------------------===//
643// Move Instructions...
644//
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000645let neverHasSideEffects = 1 in {
Evan Chengb783fa32007-07-19 01:14:50 +0000646def MOV8rr : I<0x88, MRMDestReg, (outs GR8 :$dst), (ins GR8 :$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000647 "mov{b}\t{$src, $dst|$dst, $src}", []>;
Evan Chengb783fa32007-07-19 01:14:50 +0000648def MOV16rr : I<0x89, MRMDestReg, (outs GR16:$dst), (ins GR16:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000649 "mov{w}\t{$src, $dst|$dst, $src}", []>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +0000650def MOV32rr : I<0x89, MRMDestReg, (outs GR32:$dst), (ins GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000651 "mov{l}\t{$src, $dst|$dst, $src}", []>;
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000652}
Evan Cheng6f26e8b2008-06-18 08:13:07 +0000653let isReMaterializable = 1, isAsCheapAsAMove = 1 in {
Evan Chengb783fa32007-07-19 01:14:50 +0000654def MOV8ri : Ii8 <0xB0, AddRegFrm, (outs GR8 :$dst), (ins i8imm :$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, imm:$src)]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000657def MOV16ri : Ii16<0xB8, AddRegFrm, (outs GR16:$dst), (ins i16imm:$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, imm:$src)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +0000660def MOV32ri : Ii32<0xB8, AddRegFrm, (outs GR32:$dst), (ins i32imm:$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, imm:$src)]>;
663}
Evan Chengb783fa32007-07-19 01:14:50 +0000664def MOV8mi : Ii8 <0xC6, MRM0m, (outs), (ins i8mem :$dst, i8imm :$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000665 "mov{b}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000666 [(store (i8 imm:$src), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000667def MOV16mi : Ii16<0xC7, MRM0m, (outs), (ins i16mem:$dst, i16imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000668 "mov{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000669 [(store (i16 imm:$src), addr:$dst)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +0000670def MOV32mi : Ii32<0xC7, MRM0m, (outs), (ins i32mem:$dst, i32imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000671 "mov{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000672 [(store (i32 imm:$src), addr:$dst)]>;
673
Chris Lattner1a1932c2008-01-06 23:38:27 +0000674let isSimpleLoad = 1, isReMaterializable = 1, mayHaveSideEffects = 1 in {
Evan Chengb783fa32007-07-19 01:14:50 +0000675def MOV8rm : I<0x8A, MRMSrcMem, (outs GR8 :$dst), (ins i8mem :$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000676 "mov{b}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000677 [(set GR8:$dst, (load addr:$src))]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000678def MOV16rm : I<0x8B, MRMSrcMem, (outs GR16:$dst), (ins i16mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000679 "mov{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000680 [(set GR16:$dst, (load addr:$src))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +0000681def MOV32rm : I<0x8B, MRMSrcMem, (outs GR32:$dst), (ins i32mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000682 "mov{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000683 [(set GR32:$dst, (load addr:$src))]>;
Evan Cheng4e84e452007-08-30 05:49:43 +0000684}
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000685
Evan Chengb783fa32007-07-19 01:14:50 +0000686def MOV8mr : I<0x88, MRMDestMem, (outs), (ins i8mem :$dst, GR8 :$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000687 "mov{b}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000688 [(store GR8:$src, addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000689def MOV16mr : I<0x89, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000690 "mov{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000691 [(store GR16:$src, addr:$dst)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +0000692def MOV32mr : I<0x89, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000693 "mov{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000694 [(store GR32:$src, addr:$dst)]>;
695
696//===----------------------------------------------------------------------===//
697// Fixed-Register Multiplication and Division Instructions...
698//
699
700// Extra precision multiplication
Evan Cheng55687072007-09-14 21:48:26 +0000701let Defs = [AL,AH,EFLAGS], Uses = [AL] in
Dan Gohman91888f02007-07-31 20:11:57 +0000702def MUL8r : I<0xF6, MRM4r, (outs), (ins GR8:$src), "mul{b}\t$src",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000703 // FIXME: Used for 8-bit mul, ignore result upper 8 bits.
704 // This probably ought to be moved to a def : Pat<> if the
705 // syntax can be accepted.
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000706 [(set AL, (mul AL, GR8:$src))]>; // AL,AH = AL*GR8
Chris Lattnerc7e96e72008-01-11 07:18:17 +0000707let Defs = [AX,DX,EFLAGS], Uses = [AX], neverHasSideEffects = 1 in
Dan Gohman91888f02007-07-31 20:11:57 +0000708def MUL16r : I<0xF7, MRM4r, (outs), (ins GR16:$src), "mul{w}\t$src", []>,
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000709 OpSize; // AX,DX = AX*GR16
Chris Lattnerc7e96e72008-01-11 07:18:17 +0000710let Defs = [EAX,EDX,EFLAGS], Uses = [EAX], neverHasSideEffects = 1 in
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000711def MUL32r : I<0xF7, MRM4r, (outs), (ins GR32:$src), "mul{l}\t$src", []>;
712 // EAX,EDX = EAX*GR32
Evan Cheng55687072007-09-14 21:48:26 +0000713let Defs = [AL,AH,EFLAGS], Uses = [AL] in
Evan Chengb783fa32007-07-19 01:14:50 +0000714def MUL8m : I<0xF6, MRM4m, (outs), (ins i8mem :$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000715 "mul{b}\t$src",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000716 // FIXME: Used for 8-bit mul, ignore result upper 8 bits.
717 // This probably ought to be moved to a def : Pat<> if the
718 // syntax can be accepted.
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000719 [(set AL, (mul AL, (loadi8 addr:$src)))]>; // AL,AH = AL*[mem8]
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000720let mayLoad = 1, neverHasSideEffects = 1 in {
Evan Cheng55687072007-09-14 21:48:26 +0000721let Defs = [AX,DX,EFLAGS], Uses = [AX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000722def MUL16m : I<0xF7, MRM4m, (outs), (ins i16mem:$src),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000723 "mul{w}\t$src", []>, OpSize; // AX,DX = AX*[mem16]
Evan Cheng55687072007-09-14 21:48:26 +0000724let Defs = [EAX,EDX,EFLAGS], Uses = [EAX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000725def MUL32m : I<0xF7, MRM4m, (outs), (ins i32mem:$src),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000726 "mul{l}\t$src", []>; // EAX,EDX = EAX*[mem32]
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000727}
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000728
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000729let neverHasSideEffects = 1 in {
Evan Cheng55687072007-09-14 21:48:26 +0000730let Defs = [AL,AH,EFLAGS], Uses = [AL] in
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000731def IMUL8r : I<0xF6, MRM5r, (outs), (ins GR8:$src), "imul{b}\t$src", []>;
732 // AL,AH = AL*GR8
Evan Cheng55687072007-09-14 21:48:26 +0000733let Defs = [AX,DX,EFLAGS], Uses = [AX] in
Dan Gohman91888f02007-07-31 20:11:57 +0000734def IMUL16r : I<0xF7, MRM5r, (outs), (ins GR16:$src), "imul{w}\t$src", []>,
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000735 OpSize; // AX,DX = AX*GR16
Evan Cheng55687072007-09-14 21:48:26 +0000736let Defs = [EAX,EDX,EFLAGS], Uses = [EAX] in
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000737def IMUL32r : I<0xF7, MRM5r, (outs), (ins GR32:$src), "imul{l}\t$src", []>;
738 // EAX,EDX = EAX*GR32
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000739let mayLoad = 1 in {
Evan Cheng55687072007-09-14 21:48:26 +0000740let Defs = [AL,AH,EFLAGS], Uses = [AL] in
Evan Chengb783fa32007-07-19 01:14:50 +0000741def IMUL8m : I<0xF6, MRM5m, (outs), (ins i8mem :$src),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000742 "imul{b}\t$src", []>; // AL,AH = AL*[mem8]
Evan Cheng55687072007-09-14 21:48:26 +0000743let Defs = [AX,DX,EFLAGS], Uses = [AX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000744def IMUL16m : I<0xF7, MRM5m, (outs), (ins i16mem:$src),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000745 "imul{w}\t$src", []>, OpSize; // AX,DX = AX*[mem16]
746let Defs = [EAX,EDX], Uses = [EAX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000747def IMUL32m : I<0xF7, MRM5m, (outs), (ins i32mem:$src),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000748 "imul{l}\t$src", []>; // EAX,EDX = EAX*[mem32]
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000749}
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000750
751// unsigned division/remainder
Dale Johannesend8fd3562008-10-07 18:54:28 +0000752let Defs = [AL,AH,EFLAGS], Uses = [AX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000753def DIV8r : I<0xF6, MRM6r, (outs), (ins GR8:$src), // AX/r8 = AL,AH
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000754 "div{b}\t$src", []>;
Evan Cheng55687072007-09-14 21:48:26 +0000755let Defs = [AX,DX,EFLAGS], Uses = [AX,DX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000756def DIV16r : I<0xF7, MRM6r, (outs), (ins GR16:$src), // DX:AX/r16 = AX,DX
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000757 "div{w}\t$src", []>, OpSize;
Evan Cheng55687072007-09-14 21:48:26 +0000758let Defs = [EAX,EDX,EFLAGS], Uses = [EAX,EDX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000759def DIV32r : I<0xF7, MRM6r, (outs), (ins GR32:$src), // EDX:EAX/r32 = EAX,EDX
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000760 "div{l}\t$src", []>;
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000761let mayLoad = 1 in {
Dale Johannesend8fd3562008-10-07 18:54:28 +0000762let Defs = [AL,AH,EFLAGS], Uses = [AX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000763def DIV8m : I<0xF6, MRM6m, (outs), (ins i8mem:$src), // AX/[mem8] = AL,AH
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000764 "div{b}\t$src", []>;
Evan Cheng55687072007-09-14 21:48:26 +0000765let Defs = [AX,DX,EFLAGS], Uses = [AX,DX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000766def DIV16m : I<0xF7, MRM6m, (outs), (ins i16mem:$src), // DX:AX/[mem16] = AX,DX
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000767 "div{w}\t$src", []>, OpSize;
Evan Cheng55687072007-09-14 21:48:26 +0000768let Defs = [EAX,EDX,EFLAGS], Uses = [EAX,EDX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000769def DIV32m : I<0xF7, MRM6m, (outs), (ins i32mem:$src), // EDX:EAX/[mem32] = EAX,EDX
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000770 "div{l}\t$src", []>;
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000771}
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000772
773// Signed division/remainder.
Dale Johannesend8fd3562008-10-07 18:54:28 +0000774let Defs = [AL,AH,EFLAGS], Uses = [AX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000775def IDIV8r : I<0xF6, MRM7r, (outs), (ins GR8:$src), // AX/r8 = AL,AH
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000776 "idiv{b}\t$src", []>;
Evan Cheng55687072007-09-14 21:48:26 +0000777let Defs = [AX,DX,EFLAGS], Uses = [AX,DX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000778def IDIV16r: I<0xF7, MRM7r, (outs), (ins GR16:$src), // DX:AX/r16 = AX,DX
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000779 "idiv{w}\t$src", []>, OpSize;
Evan Cheng55687072007-09-14 21:48:26 +0000780let Defs = [EAX,EDX,EFLAGS], Uses = [EAX,EDX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000781def IDIV32r: I<0xF7, MRM7r, (outs), (ins GR32:$src), // EDX:EAX/r32 = EAX,EDX
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000782 "idiv{l}\t$src", []>;
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000783let mayLoad = 1, mayLoad = 1 in {
Dale Johannesend8fd3562008-10-07 18:54:28 +0000784let Defs = [AL,AH,EFLAGS], Uses = [AX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000785def IDIV8m : I<0xF6, MRM7m, (outs), (ins i8mem:$src), // AX/[mem8] = AL,AH
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000786 "idiv{b}\t$src", []>;
Evan Cheng55687072007-09-14 21:48:26 +0000787let Defs = [AX,DX,EFLAGS], Uses = [AX,DX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000788def IDIV16m: I<0xF7, MRM7m, (outs), (ins i16mem:$src), // DX:AX/[mem16] = AX,DX
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000789 "idiv{w}\t$src", []>, OpSize;
Evan Cheng55687072007-09-14 21:48:26 +0000790let Defs = [EAX,EDX,EFLAGS], Uses = [EAX,EDX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000791def IDIV32m: I<0xF7, MRM7m, (outs), (ins i32mem:$src), // EDX:EAX/[mem32] = EAX,EDX
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000792 "idiv{l}\t$src", []>;
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000793}
794} // neverHasSideEffects
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000795
796//===----------------------------------------------------------------------===//
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000797// Two address Instructions.
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000798//
799let isTwoAddress = 1 in {
800
801// Conditional moves
Evan Cheng950aac02007-09-25 01:57:46 +0000802let Uses = [EFLAGS] in {
Evan Cheng926658c2007-10-05 23:13:21 +0000803let isCommutable = 1 in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000804def CMOVB16rr : I<0x42, MRMSrcReg, // if <u, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +0000805 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000806 "cmovb\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000807 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000808 X86_COND_B, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000809 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000810def CMOVB32rr : I<0x42, MRMSrcReg, // if <u, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +0000811 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000812 "cmovb\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000813 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000814 X86_COND_B, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000815 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000816
817def CMOVAE16rr: I<0x43, MRMSrcReg, // if >=u, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +0000818 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000819 "cmovae\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000820 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000821 X86_COND_AE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000822 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000823def CMOVAE32rr: I<0x43, MRMSrcReg, // if >=u, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +0000824 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000825 "cmovae\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000826 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000827 X86_COND_AE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000828 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000829def CMOVE16rr : I<0x44, MRMSrcReg, // if ==, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +0000830 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000831 "cmove\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000832 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000833 X86_COND_E, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000834 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000835def CMOVE32rr : I<0x44, MRMSrcReg, // if ==, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +0000836 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000837 "cmove\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000838 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000839 X86_COND_E, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000840 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000841def CMOVNE16rr: I<0x45, MRMSrcReg, // if !=, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +0000842 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000843 "cmovne\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000844 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000845 X86_COND_NE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000846 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000847def CMOVNE32rr: I<0x45, MRMSrcReg, // if !=, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +0000848 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000849 "cmovne\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000850 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000851 X86_COND_NE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000852 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000853def CMOVBE16rr: I<0x46, MRMSrcReg, // if <=u, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +0000854 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000855 "cmovbe\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000856 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000857 X86_COND_BE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000858 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000859def CMOVBE32rr: I<0x46, MRMSrcReg, // if <=u, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +0000860 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000861 "cmovbe\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000862 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000863 X86_COND_BE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000864 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000865def CMOVA16rr : I<0x47, MRMSrcReg, // if >u, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +0000866 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000867 "cmova\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000868 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000869 X86_COND_A, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000870 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000871def CMOVA32rr : I<0x47, MRMSrcReg, // if >u, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +0000872 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000873 "cmova\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000874 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000875 X86_COND_A, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000876 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000877def CMOVL16rr : I<0x4C, MRMSrcReg, // if <s, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +0000878 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000879 "cmovl\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000880 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000881 X86_COND_L, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000882 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000883def CMOVL32rr : I<0x4C, MRMSrcReg, // if <s, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +0000884 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000885 "cmovl\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000886 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000887 X86_COND_L, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000888 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000889def CMOVGE16rr: I<0x4D, MRMSrcReg, // if >=s, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +0000890 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000891 "cmovge\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000892 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000893 X86_COND_GE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000894 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000895def CMOVGE32rr: I<0x4D, MRMSrcReg, // if >=s, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +0000896 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000897 "cmovge\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000898 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000899 X86_COND_GE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000900 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000901def CMOVLE16rr: I<0x4E, MRMSrcReg, // if <=s, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +0000902 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000903 "cmovle\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000904 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000905 X86_COND_LE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000906 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000907def CMOVLE32rr: I<0x4E, MRMSrcReg, // if <=s, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +0000908 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000909 "cmovle\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000910 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000911 X86_COND_LE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000912 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000913def CMOVG16rr : I<0x4F, MRMSrcReg, // if >s, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +0000914 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000915 "cmovg\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000916 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000917 X86_COND_G, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000918 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000919def CMOVG32rr : I<0x4F, MRMSrcReg, // if >s, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +0000920 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000921 "cmovg\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000922 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000923 X86_COND_G, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000924 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000925def CMOVS16rr : I<0x48, MRMSrcReg, // if signed, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +0000926 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000927 "cmovs\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000928 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000929 X86_COND_S, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000930 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000931def CMOVS32rr : I<0x48, MRMSrcReg, // if signed, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +0000932 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000933 "cmovs\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000934 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000935 X86_COND_S, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000936 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000937def CMOVNS16rr: I<0x49, MRMSrcReg, // if !signed, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +0000938 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000939 "cmovns\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000940 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000941 X86_COND_NS, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000942 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000943def CMOVNS32rr: I<0x49, MRMSrcReg, // if !signed, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +0000944 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000945 "cmovns\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000946 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000947 X86_COND_NS, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000948 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000949def CMOVP16rr : I<0x4A, MRMSrcReg, // if parity, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +0000950 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000951 "cmovp\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000952 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000953 X86_COND_P, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000954 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000955def CMOVP32rr : I<0x4A, MRMSrcReg, // if parity, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +0000956 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000957 "cmovp\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000958 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000959 X86_COND_P, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000960 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000961def CMOVNP16rr : I<0x4B, MRMSrcReg, // if !parity, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +0000962 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000963 "cmovnp\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000964 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000965 X86_COND_NP, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000966 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000967def CMOVNP32rr : I<0x4B, MRMSrcReg, // if !parity, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +0000968 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000969 "cmovnp\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000970 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000971 X86_COND_NP, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000972 TB;
Evan Cheng926658c2007-10-05 23:13:21 +0000973} // isCommutable = 1
974
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000975def CMOVNP32rm : I<0x4B, MRMSrcMem, // if !parity, GR32 = [mem32]
Evan Chengb783fa32007-07-19 01:14:50 +0000976 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000977 "cmovnp\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000978 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
Evan Cheng950aac02007-09-25 01:57:46 +0000979 X86_COND_NP, EFLAGS))]>,
980 TB;
Evan Cheng926658c2007-10-05 23:13:21 +0000981
982def CMOVB16rm : I<0x42, MRMSrcMem, // if <u, GR16 = [mem16]
983 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
984 "cmovb\t{$src2, $dst|$dst, $src2}",
985 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
986 X86_COND_B, EFLAGS))]>,
987 TB, OpSize;
988def CMOVB32rm : I<0x42, MRMSrcMem, // if <u, GR32 = [mem32]
989 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
990 "cmovb\t{$src2, $dst|$dst, $src2}",
991 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
992 X86_COND_B, EFLAGS))]>,
993 TB;
994def CMOVAE16rm: I<0x43, MRMSrcMem, // if >=u, GR16 = [mem16]
995 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
996 "cmovae\t{$src2, $dst|$dst, $src2}",
997 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
998 X86_COND_AE, EFLAGS))]>,
999 TB, OpSize;
1000def CMOVAE32rm: I<0x43, MRMSrcMem, // if >=u, GR32 = [mem32]
1001 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1002 "cmovae\t{$src2, $dst|$dst, $src2}",
1003 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1004 X86_COND_AE, EFLAGS))]>,
1005 TB;
1006def CMOVE16rm : I<0x44, MRMSrcMem, // if ==, GR16 = [mem16]
1007 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1008 "cmove\t{$src2, $dst|$dst, $src2}",
1009 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1010 X86_COND_E, EFLAGS))]>,
1011 TB, OpSize;
1012def CMOVE32rm : I<0x44, MRMSrcMem, // if ==, GR32 = [mem32]
1013 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1014 "cmove\t{$src2, $dst|$dst, $src2}",
1015 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1016 X86_COND_E, EFLAGS))]>,
1017 TB;
1018def CMOVNE16rm: I<0x45, MRMSrcMem, // if !=, GR16 = [mem16]
1019 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1020 "cmovne\t{$src2, $dst|$dst, $src2}",
1021 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1022 X86_COND_NE, EFLAGS))]>,
1023 TB, OpSize;
1024def CMOVNE32rm: I<0x45, MRMSrcMem, // if !=, GR32 = [mem32]
1025 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1026 "cmovne\t{$src2, $dst|$dst, $src2}",
1027 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1028 X86_COND_NE, EFLAGS))]>,
1029 TB;
1030def CMOVBE16rm: I<0x46, MRMSrcMem, // if <=u, GR16 = [mem16]
1031 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1032 "cmovbe\t{$src2, $dst|$dst, $src2}",
1033 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1034 X86_COND_BE, EFLAGS))]>,
1035 TB, OpSize;
1036def CMOVBE32rm: I<0x46, MRMSrcMem, // if <=u, GR32 = [mem32]
1037 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1038 "cmovbe\t{$src2, $dst|$dst, $src2}",
1039 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1040 X86_COND_BE, EFLAGS))]>,
1041 TB;
1042def CMOVA16rm : I<0x47, MRMSrcMem, // if >u, GR16 = [mem16]
1043 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1044 "cmova\t{$src2, $dst|$dst, $src2}",
1045 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1046 X86_COND_A, EFLAGS))]>,
1047 TB, OpSize;
1048def CMOVA32rm : I<0x47, MRMSrcMem, // if >u, GR32 = [mem32]
1049 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1050 "cmova\t{$src2, $dst|$dst, $src2}",
1051 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1052 X86_COND_A, EFLAGS))]>,
1053 TB;
1054def CMOVL16rm : I<0x4C, MRMSrcMem, // if <s, GR16 = [mem16]
1055 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1056 "cmovl\t{$src2, $dst|$dst, $src2}",
1057 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1058 X86_COND_L, EFLAGS))]>,
1059 TB, OpSize;
1060def CMOVL32rm : I<0x4C, MRMSrcMem, // if <s, GR32 = [mem32]
1061 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1062 "cmovl\t{$src2, $dst|$dst, $src2}",
1063 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1064 X86_COND_L, EFLAGS))]>,
1065 TB;
1066def CMOVGE16rm: I<0x4D, MRMSrcMem, // if >=s, GR16 = [mem16]
1067 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1068 "cmovge\t{$src2, $dst|$dst, $src2}",
1069 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1070 X86_COND_GE, EFLAGS))]>,
1071 TB, OpSize;
1072def CMOVGE32rm: I<0x4D, MRMSrcMem, // if >=s, GR32 = [mem32]
1073 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1074 "cmovge\t{$src2, $dst|$dst, $src2}",
1075 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1076 X86_COND_GE, EFLAGS))]>,
1077 TB;
1078def CMOVLE16rm: I<0x4E, MRMSrcMem, // if <=s, GR16 = [mem16]
1079 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1080 "cmovle\t{$src2, $dst|$dst, $src2}",
1081 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1082 X86_COND_LE, EFLAGS))]>,
1083 TB, OpSize;
1084def CMOVLE32rm: I<0x4E, MRMSrcMem, // if <=s, GR32 = [mem32]
1085 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1086 "cmovle\t{$src2, $dst|$dst, $src2}",
1087 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1088 X86_COND_LE, EFLAGS))]>,
1089 TB;
1090def CMOVG16rm : I<0x4F, MRMSrcMem, // if >s, GR16 = [mem16]
1091 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1092 "cmovg\t{$src2, $dst|$dst, $src2}",
1093 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1094 X86_COND_G, EFLAGS))]>,
1095 TB, OpSize;
1096def CMOVG32rm : I<0x4F, MRMSrcMem, // if >s, GR32 = [mem32]
1097 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1098 "cmovg\t{$src2, $dst|$dst, $src2}",
1099 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1100 X86_COND_G, EFLAGS))]>,
1101 TB;
1102def CMOVS16rm : I<0x48, MRMSrcMem, // if signed, GR16 = [mem16]
1103 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1104 "cmovs\t{$src2, $dst|$dst, $src2}",
1105 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1106 X86_COND_S, EFLAGS))]>,
1107 TB, OpSize;
1108def CMOVS32rm : I<0x48, MRMSrcMem, // if signed, GR32 = [mem32]
1109 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1110 "cmovs\t{$src2, $dst|$dst, $src2}",
1111 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1112 X86_COND_S, EFLAGS))]>,
1113 TB;
1114def CMOVNS16rm: I<0x49, MRMSrcMem, // if !signed, GR16 = [mem16]
1115 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1116 "cmovns\t{$src2, $dst|$dst, $src2}",
1117 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1118 X86_COND_NS, EFLAGS))]>,
1119 TB, OpSize;
1120def CMOVNS32rm: I<0x49, MRMSrcMem, // if !signed, GR32 = [mem32]
1121 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1122 "cmovns\t{$src2, $dst|$dst, $src2}",
1123 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1124 X86_COND_NS, EFLAGS))]>,
1125 TB;
1126def CMOVP16rm : I<0x4A, MRMSrcMem, // if parity, GR16 = [mem16]
1127 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1128 "cmovp\t{$src2, $dst|$dst, $src2}",
1129 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1130 X86_COND_P, EFLAGS))]>,
1131 TB, OpSize;
1132def CMOVP32rm : I<0x4A, MRMSrcMem, // if parity, GR32 = [mem32]
1133 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1134 "cmovp\t{$src2, $dst|$dst, $src2}",
1135 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1136 X86_COND_P, EFLAGS))]>,
1137 TB;
1138def CMOVNP16rm : I<0x4B, MRMSrcMem, // if !parity, GR16 = [mem16]
1139 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1140 "cmovnp\t{$src2, $dst|$dst, $src2}",
1141 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1142 X86_COND_NP, EFLAGS))]>,
1143 TB, OpSize;
Evan Cheng950aac02007-09-25 01:57:46 +00001144} // Uses = [EFLAGS]
1145
1146
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001147// unary instructions
1148let CodeSize = 2 in {
Evan Cheng55687072007-09-14 21:48:26 +00001149let Defs = [EFLAGS] in {
Dan Gohman91888f02007-07-31 20:11:57 +00001150def NEG8r : I<0xF6, MRM3r, (outs GR8 :$dst), (ins GR8 :$src), "neg{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001151 [(set GR8:$dst, (ineg GR8:$src))]>;
Dan Gohman91888f02007-07-31 20:11:57 +00001152def NEG16r : I<0xF7, MRM3r, (outs GR16:$dst), (ins GR16:$src), "neg{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001153 [(set GR16:$dst, (ineg GR16:$src))]>, OpSize;
Dan Gohman91888f02007-07-31 20:11:57 +00001154def NEG32r : I<0xF7, MRM3r, (outs GR32:$dst), (ins GR32:$src), "neg{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001155 [(set GR32:$dst, (ineg GR32:$src))]>;
1156let isTwoAddress = 0 in {
Dan Gohman91888f02007-07-31 20:11:57 +00001157 def NEG8m : I<0xF6, MRM3m, (outs), (ins i8mem :$dst), "neg{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001158 [(store (ineg (loadi8 addr:$dst)), addr:$dst)]>;
Dan Gohman91888f02007-07-31 20:11:57 +00001159 def NEG16m : I<0xF7, MRM3m, (outs), (ins i16mem:$dst), "neg{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001160 [(store (ineg (loadi16 addr:$dst)), addr:$dst)]>, OpSize;
Dan Gohman91888f02007-07-31 20:11:57 +00001161 def NEG32m : I<0xF7, MRM3m, (outs), (ins i32mem:$dst), "neg{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001162 [(store (ineg (loadi32 addr:$dst)), addr:$dst)]>;
1163
1164}
Evan Cheng55687072007-09-14 21:48:26 +00001165} // Defs = [EFLAGS]
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001166
Dan Gohman91888f02007-07-31 20:11:57 +00001167def NOT8r : I<0xF6, MRM2r, (outs GR8 :$dst), (ins GR8 :$src), "not{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001168 [(set GR8:$dst, (not GR8:$src))]>;
Dan Gohman91888f02007-07-31 20:11:57 +00001169def NOT16r : I<0xF7, MRM2r, (outs GR16:$dst), (ins GR16:$src), "not{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001170 [(set GR16:$dst, (not GR16:$src))]>, OpSize;
Dan Gohman91888f02007-07-31 20:11:57 +00001171def NOT32r : I<0xF7, MRM2r, (outs GR32:$dst), (ins GR32:$src), "not{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001172 [(set GR32:$dst, (not GR32:$src))]>;
1173let isTwoAddress = 0 in {
Dan Gohman91888f02007-07-31 20:11:57 +00001174 def NOT8m : I<0xF6, MRM2m, (outs), (ins i8mem :$dst), "not{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001175 [(store (not (loadi8 addr:$dst)), addr:$dst)]>;
Dan Gohman91888f02007-07-31 20:11:57 +00001176 def NOT16m : I<0xF7, MRM2m, (outs), (ins i16mem:$dst), "not{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001177 [(store (not (loadi16 addr:$dst)), addr:$dst)]>, OpSize;
Dan Gohman91888f02007-07-31 20:11:57 +00001178 def NOT32m : I<0xF7, MRM2m, (outs), (ins i32mem:$dst), "not{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001179 [(store (not (loadi32 addr:$dst)), addr:$dst)]>;
1180}
1181} // CodeSize
1182
1183// TODO: inc/dec is slow for P4, but fast for Pentium-M.
Evan Cheng55687072007-09-14 21:48:26 +00001184let Defs = [EFLAGS] in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001185let CodeSize = 2 in
Dan Gohman91888f02007-07-31 20:11:57 +00001186def INC8r : I<0xFE, MRM0r, (outs GR8 :$dst), (ins GR8 :$src), "inc{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 INC16r : I<0x40, AddRegFrm, (outs GR16:$dst), (ins GR16:$src), "inc{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 INC32r : I<0x40, AddRegFrm, (outs GR32:$dst), (ins GR32:$src), "inc{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001193 [(set GR32:$dst, (add GR32:$src, 1))]>, Requires<[In32BitMode]>;
1194}
1195let isTwoAddress = 0, CodeSize = 2 in {
Dan Gohman91888f02007-07-31 20:11:57 +00001196 def INC8m : I<0xFE, MRM0m, (outs), (ins i8mem :$dst), "inc{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001197 [(store (add (loadi8 addr:$dst), 1), addr:$dst)]>;
Dan Gohman91888f02007-07-31 20:11:57 +00001198 def INC16m : I<0xFF, MRM0m, (outs), (ins i16mem:$dst), "inc{w}\t$dst",
Evan Cheng4a7e72f2007-10-19 21:23:22 +00001199 [(store (add (loadi16 addr:$dst), 1), addr:$dst)]>,
1200 OpSize, Requires<[In32BitMode]>;
Dan Gohman91888f02007-07-31 20:11:57 +00001201 def INC32m : I<0xFF, MRM0m, (outs), (ins i32mem:$dst), "inc{l}\t$dst",
Evan Cheng4a7e72f2007-10-19 21:23:22 +00001202 [(store (add (loadi32 addr:$dst), 1), addr:$dst)]>,
1203 Requires<[In32BitMode]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001204}
1205
1206let CodeSize = 2 in
Dan Gohman91888f02007-07-31 20:11:57 +00001207def DEC8r : I<0xFE, MRM1r, (outs GR8 :$dst), (ins GR8 :$src), "dec{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001208 [(set GR8:$dst, (add GR8:$src, -1))]>;
1209let isConvertibleToThreeAddress = 1, CodeSize = 1 in { // Can xform into LEA.
Dan Gohman91888f02007-07-31 20:11:57 +00001210def DEC16r : I<0x48, AddRegFrm, (outs GR16:$dst), (ins GR16:$src), "dec{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001211 [(set GR16:$dst, (add GR16:$src, -1))]>,
1212 OpSize, Requires<[In32BitMode]>;
Dan Gohman91888f02007-07-31 20:11:57 +00001213def DEC32r : I<0x48, AddRegFrm, (outs GR32:$dst), (ins GR32:$src), "dec{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001214 [(set GR32:$dst, (add GR32:$src, -1))]>, Requires<[In32BitMode]>;
1215}
1216
1217let isTwoAddress = 0, CodeSize = 2 in {
Dan Gohman91888f02007-07-31 20:11:57 +00001218 def DEC8m : I<0xFE, MRM1m, (outs), (ins i8mem :$dst), "dec{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001219 [(store (add (loadi8 addr:$dst), -1), addr:$dst)]>;
Dan Gohman91888f02007-07-31 20:11:57 +00001220 def DEC16m : I<0xFF, MRM1m, (outs), (ins i16mem:$dst), "dec{w}\t$dst",
Evan Cheng4a7e72f2007-10-19 21:23:22 +00001221 [(store (add (loadi16 addr:$dst), -1), addr:$dst)]>,
1222 OpSize, Requires<[In32BitMode]>;
Dan Gohman91888f02007-07-31 20:11:57 +00001223 def DEC32m : I<0xFF, MRM1m, (outs), (ins i32mem:$dst), "dec{l}\t$dst",
Evan Cheng4a7e72f2007-10-19 21:23:22 +00001224 [(store (add (loadi32 addr:$dst), -1), addr:$dst)]>,
1225 Requires<[In32BitMode]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001226}
Evan Cheng55687072007-09-14 21:48:26 +00001227} // Defs = [EFLAGS]
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001228
1229// Logical operators...
Evan Cheng55687072007-09-14 21:48:26 +00001230let Defs = [EFLAGS] in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001231let isCommutable = 1 in { // X = AND Y, Z --> X = AND Z, Y
1232def AND8rr : I<0x20, MRMDestReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001233 (outs GR8 :$dst), (ins GR8 :$src1, GR8 :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001234 "and{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001235 [(set GR8:$dst, (and GR8:$src1, GR8:$src2))]>;
1236def AND16rr : I<0x21, MRMDestReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001237 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001238 "and{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001239 [(set GR16:$dst, (and GR16:$src1, GR16:$src2))]>, OpSize;
1240def AND32rr : I<0x21, MRMDestReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001241 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001242 "and{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001243 [(set GR32:$dst, (and GR32:$src1, GR32:$src2))]>;
1244}
1245
1246def AND8rm : I<0x22, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001247 (outs GR8 :$dst), (ins GR8 :$src1, i8mem :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001248 "and{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001249 [(set GR8:$dst, (and GR8:$src1, (load addr:$src2)))]>;
1250def AND16rm : I<0x23, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001251 (outs GR16:$dst), (ins GR16:$src1, i16mem:$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, (load addr:$src2)))]>, OpSize;
1254def AND32rm : I<0x23, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001255 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001256 "and{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001257 [(set GR32:$dst, (and GR32:$src1, (load addr:$src2)))]>;
1258
1259def AND8ri : Ii8<0x80, MRM4r,
Evan Chengb783fa32007-07-19 01:14:50 +00001260 (outs GR8 :$dst), (ins GR8 :$src1, i8imm :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001261 "and{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001262 [(set GR8:$dst, (and GR8:$src1, imm:$src2))]>;
1263def AND16ri : Ii16<0x81, MRM4r,
Evan Chengb783fa32007-07-19 01:14:50 +00001264 (outs GR16:$dst), (ins GR16:$src1, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001265 "and{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001266 [(set GR16:$dst, (and GR16:$src1, imm:$src2))]>, OpSize;
1267def AND32ri : Ii32<0x81, MRM4r,
Evan Chengb783fa32007-07-19 01:14:50 +00001268 (outs GR32:$dst), (ins GR32:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001269 "and{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001270 [(set GR32:$dst, (and GR32:$src1, imm:$src2))]>;
1271def AND16ri8 : Ii8<0x83, MRM4r,
Evan Chengb783fa32007-07-19 01:14:50 +00001272 (outs GR16:$dst), (ins GR16:$src1, i16i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001273 "and{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001274 [(set GR16:$dst, (and GR16:$src1, i16immSExt8:$src2))]>,
1275 OpSize;
1276def AND32ri8 : Ii8<0x83, MRM4r,
Evan Chengb783fa32007-07-19 01:14:50 +00001277 (outs GR32:$dst), (ins GR32:$src1, i32i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001278 "and{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001279 [(set GR32:$dst, (and GR32:$src1, i32immSExt8:$src2))]>;
1280
1281let isTwoAddress = 0 in {
1282 def AND8mr : I<0x20, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001283 (outs), (ins i8mem :$dst, GR8 :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001284 "and{b}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001285 [(store (and (load addr:$dst), GR8:$src), addr:$dst)]>;
1286 def AND16mr : I<0x21, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001287 (outs), (ins i16mem:$dst, GR16:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001288 "and{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001289 [(store (and (load addr:$dst), GR16:$src), addr:$dst)]>,
1290 OpSize;
1291 def AND32mr : I<0x21, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001292 (outs), (ins i32mem:$dst, GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001293 "and{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001294 [(store (and (load addr:$dst), GR32:$src), addr:$dst)]>;
1295 def AND8mi : Ii8<0x80, MRM4m,
Evan Chengb783fa32007-07-19 01:14:50 +00001296 (outs), (ins i8mem :$dst, i8imm :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001297 "and{b}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001298 [(store (and (loadi8 addr:$dst), imm:$src), addr:$dst)]>;
1299 def AND16mi : Ii16<0x81, MRM4m,
Evan Chengb783fa32007-07-19 01:14:50 +00001300 (outs), (ins i16mem:$dst, i16imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001301 "and{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001302 [(store (and (loadi16 addr:$dst), imm:$src), addr:$dst)]>,
1303 OpSize;
1304 def AND32mi : Ii32<0x81, MRM4m,
Evan Chengb783fa32007-07-19 01:14:50 +00001305 (outs), (ins i32mem:$dst, i32imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001306 "and{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001307 [(store (and (loadi32 addr:$dst), imm:$src), addr:$dst)]>;
1308 def AND16mi8 : Ii8<0x83, MRM4m,
Evan Chengb783fa32007-07-19 01:14:50 +00001309 (outs), (ins i16mem:$dst, i16i8imm :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001310 "and{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001311 [(store (and (load addr:$dst), i16immSExt8:$src), addr:$dst)]>,
1312 OpSize;
1313 def AND32mi8 : Ii8<0x83, MRM4m,
Evan Chengb783fa32007-07-19 01:14:50 +00001314 (outs), (ins i32mem:$dst, i32i8imm :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001315 "and{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001316 [(store (and (load addr:$dst), i32immSExt8:$src), addr:$dst)]>;
1317}
1318
1319
1320let isCommutable = 1 in { // X = OR Y, Z --> X = OR Z, Y
Evan Chengb783fa32007-07-19 01:14:50 +00001321def OR8rr : I<0x08, MRMDestReg, (outs GR8 :$dst), (ins GR8 :$src1, GR8 :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001322 "or{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001323 [(set GR8:$dst, (or GR8:$src1, GR8:$src2))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001324def OR16rr : I<0x09, MRMDestReg, (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001325 "or{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001326 [(set GR16:$dst, (or GR16:$src1, GR16:$src2))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001327def OR32rr : I<0x09, MRMDestReg, (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001328 "or{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001329 [(set GR32:$dst, (or GR32:$src1, GR32:$src2))]>;
1330}
Evan Chengb783fa32007-07-19 01:14:50 +00001331def OR8rm : I<0x0A, MRMSrcMem , (outs GR8 :$dst), (ins GR8 :$src1, i8mem :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001332 "or{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001333 [(set GR8:$dst, (or GR8:$src1, (load addr:$src2)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001334def OR16rm : I<0x0B, MRMSrcMem , (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001335 "or{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001336 [(set GR16:$dst, (or GR16:$src1, (load addr:$src2)))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001337def OR32rm : I<0x0B, MRMSrcMem , (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001338 "or{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001339 [(set GR32:$dst, (or GR32:$src1, (load addr:$src2)))]>;
1340
Evan Chengb783fa32007-07-19 01:14:50 +00001341def OR8ri : Ii8 <0x80, MRM1r, (outs GR8 :$dst), (ins GR8 :$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001342 "or{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001343 [(set GR8:$dst, (or GR8:$src1, imm:$src2))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001344def OR16ri : Ii16<0x81, MRM1r, (outs GR16:$dst), (ins GR16:$src1, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001345 "or{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001346 [(set GR16:$dst, (or GR16:$src1, imm:$src2))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001347def OR32ri : Ii32<0x81, MRM1r, (outs GR32:$dst), (ins GR32:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001348 "or{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001349 [(set GR32:$dst, (or GR32:$src1, imm:$src2))]>;
1350
Evan Chengb783fa32007-07-19 01:14:50 +00001351def OR16ri8 : Ii8<0x83, MRM1r, (outs GR16:$dst), (ins GR16:$src1, i16i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001352 "or{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001353 [(set GR16:$dst, (or GR16:$src1, i16immSExt8:$src2))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001354def OR32ri8 : Ii8<0x83, MRM1r, (outs GR32:$dst), (ins GR32:$src1, i32i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001355 "or{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001356 [(set GR32:$dst, (or GR32:$src1, i32immSExt8:$src2))]>;
1357let isTwoAddress = 0 in {
Evan Chengb783fa32007-07-19 01:14:50 +00001358 def OR8mr : I<0x08, MRMDestMem, (outs), (ins i8mem:$dst, GR8:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001359 "or{b}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001360 [(store (or (load addr:$dst), GR8:$src), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001361 def OR16mr : I<0x09, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001362 "or{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001363 [(store (or (load addr:$dst), GR16:$src), addr:$dst)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001364 def OR32mr : I<0x09, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001365 "or{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001366 [(store (or (load addr:$dst), GR32:$src), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001367 def OR8mi : Ii8<0x80, MRM1m, (outs), (ins i8mem :$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001368 "or{b}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001369 [(store (or (loadi8 addr:$dst), imm:$src), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001370 def OR16mi : Ii16<0x81, MRM1m, (outs), (ins i16mem:$dst, i16imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001371 "or{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001372 [(store (or (loadi16 addr:$dst), imm:$src), addr:$dst)]>,
1373 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001374 def OR32mi : Ii32<0x81, MRM1m, (outs), (ins i32mem:$dst, i32imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001375 "or{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001376 [(store (or (loadi32 addr:$dst), imm:$src), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001377 def OR16mi8 : Ii8<0x83, MRM1m, (outs), (ins i16mem:$dst, i16i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001378 "or{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001379 [(store (or (load addr:$dst), i16immSExt8:$src), addr:$dst)]>,
1380 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001381 def OR32mi8 : Ii8<0x83, MRM1m, (outs), (ins i32mem:$dst, i32i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001382 "or{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001383 [(store (or (load addr:$dst), i32immSExt8:$src), addr:$dst)]>;
Bill Wendlingba5d5b02008-05-29 01:02:09 +00001384} // isTwoAddress = 0
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001385
1386
Evan Cheng6f26e8b2008-06-18 08:13:07 +00001387let isCommutable = 1 in { // X = XOR Y, Z --> X = XOR Z, Y
Bill Wendlingba5d5b02008-05-29 01:02:09 +00001388 def XOR8rr : I<0x30, MRMDestReg,
1389 (outs GR8 :$dst), (ins GR8 :$src1, GR8 :$src2),
1390 "xor{b}\t{$src2, $dst|$dst, $src2}",
1391 [(set GR8:$dst, (xor GR8:$src1, GR8:$src2))]>;
1392 def XOR16rr : I<0x31, MRMDestReg,
1393 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
1394 "xor{w}\t{$src2, $dst|$dst, $src2}",
1395 [(set GR16:$dst, (xor GR16:$src1, GR16:$src2))]>, OpSize;
1396 def XOR32rr : I<0x31, MRMDestReg,
1397 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
1398 "xor{l}\t{$src2, $dst|$dst, $src2}",
1399 [(set GR32:$dst, (xor GR32:$src1, GR32:$src2))]>;
Evan Cheng6f26e8b2008-06-18 08:13:07 +00001400} // isCommutable = 1
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001401
1402def XOR8rm : I<0x32, MRMSrcMem ,
Evan Chengb783fa32007-07-19 01:14:50 +00001403 (outs GR8 :$dst), (ins GR8:$src1, i8mem :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001404 "xor{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001405 [(set GR8:$dst, (xor GR8:$src1, (load addr:$src2)))]>;
1406def XOR16rm : I<0x33, MRMSrcMem ,
Evan Chengb783fa32007-07-19 01:14:50 +00001407 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001408 "xor{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingba5d5b02008-05-29 01:02:09 +00001409 [(set GR16:$dst, (xor GR16:$src1, (load addr:$src2)))]>,
1410 OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001411def XOR32rm : I<0x33, MRMSrcMem ,
Evan Chengb783fa32007-07-19 01:14:50 +00001412 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001413 "xor{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001414 [(set GR32:$dst, (xor GR32:$src1, (load addr:$src2)))]>;
1415
Bill Wendlingbac38eb2008-05-29 03:46:36 +00001416def XOR8ri : Ii8<0x80, MRM6r,
1417 (outs GR8:$dst), (ins GR8:$src1, i8imm:$src2),
1418 "xor{b}\t{$src2, $dst|$dst, $src2}",
1419 [(set GR8:$dst, (xor GR8:$src1, imm:$src2))]>;
1420def XOR16ri : Ii16<0x81, MRM6r,
1421 (outs GR16:$dst), (ins GR16:$src1, i16imm:$src2),
1422 "xor{w}\t{$src2, $dst|$dst, $src2}",
1423 [(set GR16:$dst, (xor GR16:$src1, imm:$src2))]>, OpSize;
1424def XOR32ri : Ii32<0x81, MRM6r,
1425 (outs GR32:$dst), (ins GR32:$src1, i32imm:$src2),
1426 "xor{l}\t{$src2, $dst|$dst, $src2}",
1427 [(set GR32:$dst, (xor GR32:$src1, imm:$src2))]>;
1428def XOR16ri8 : Ii8<0x83, MRM6r,
1429 (outs GR16:$dst), (ins GR16:$src1, i16i8imm:$src2),
1430 "xor{w}\t{$src2, $dst|$dst, $src2}",
1431 [(set GR16:$dst, (xor GR16:$src1, i16immSExt8:$src2))]>,
1432 OpSize;
1433def XOR32ri8 : Ii8<0x83, MRM6r,
1434 (outs GR32:$dst), (ins GR32:$src1, i32i8imm:$src2),
1435 "xor{l}\t{$src2, $dst|$dst, $src2}",
1436 [(set GR32:$dst, (xor GR32:$src1, i32immSExt8:$src2))]>;
Bill Wendlingba5d5b02008-05-29 01:02:09 +00001437
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001438let isTwoAddress = 0 in {
1439 def XOR8mr : I<0x30, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001440 (outs), (ins i8mem :$dst, GR8 :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001441 "xor{b}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001442 [(store (xor (load addr:$dst), GR8:$src), addr:$dst)]>;
1443 def XOR16mr : I<0x31, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001444 (outs), (ins i16mem:$dst, GR16:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001445 "xor{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001446 [(store (xor (load addr:$dst), GR16:$src), addr:$dst)]>,
1447 OpSize;
1448 def XOR32mr : I<0x31, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001449 (outs), (ins i32mem:$dst, GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001450 "xor{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001451 [(store (xor (load addr:$dst), GR32:$src), addr:$dst)]>;
1452 def XOR8mi : Ii8<0x80, MRM6m,
Evan Chengb783fa32007-07-19 01:14:50 +00001453 (outs), (ins i8mem :$dst, i8imm :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001454 "xor{b}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001455 [(store (xor (loadi8 addr:$dst), imm:$src), addr:$dst)]>;
1456 def XOR16mi : Ii16<0x81, MRM6m,
Evan Chengb783fa32007-07-19 01:14:50 +00001457 (outs), (ins i16mem:$dst, i16imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001458 "xor{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001459 [(store (xor (loadi16 addr:$dst), imm:$src), addr:$dst)]>,
1460 OpSize;
1461 def XOR32mi : Ii32<0x81, MRM6m,
Evan Chengb783fa32007-07-19 01:14:50 +00001462 (outs), (ins i32mem:$dst, i32imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001463 "xor{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001464 [(store (xor (loadi32 addr:$dst), imm:$src), addr:$dst)]>;
1465 def XOR16mi8 : Ii8<0x83, MRM6m,
Evan Chengb783fa32007-07-19 01:14:50 +00001466 (outs), (ins i16mem:$dst, i16i8imm :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001467 "xor{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001468 [(store (xor (load addr:$dst), i16immSExt8:$src), addr:$dst)]>,
1469 OpSize;
1470 def XOR32mi8 : Ii8<0x83, MRM6m,
Evan Chengb783fa32007-07-19 01:14:50 +00001471 (outs), (ins i32mem:$dst, i32i8imm :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001472 "xor{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001473 [(store (xor (load addr:$dst), i32immSExt8:$src), addr:$dst)]>;
Bill Wendlingba5d5b02008-05-29 01:02:09 +00001474} // isTwoAddress = 0
Evan Cheng55687072007-09-14 21:48:26 +00001475} // Defs = [EFLAGS]
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001476
1477// Shift instructions
Evan Cheng55687072007-09-14 21:48:26 +00001478let Defs = [EFLAGS] in {
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001479let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00001480def SHL8rCL : I<0xD2, MRM4r, (outs GR8 :$dst), (ins GR8 :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001481 "shl{b}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001482 [(set GR8:$dst, (shl GR8:$src, CL))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001483def SHL16rCL : I<0xD3, MRM4r, (outs GR16:$dst), (ins GR16:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001484 "shl{w}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001485 [(set GR16:$dst, (shl GR16:$src, CL))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001486def SHL32rCL : I<0xD3, MRM4r, (outs GR32:$dst), (ins GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001487 "shl{l}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001488 [(set GR32:$dst, (shl GR32:$src, CL))]>;
Bill Wendlingba5d5b02008-05-29 01:02:09 +00001489} // Uses = [CL]
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001490
Evan Chengb783fa32007-07-19 01:14:50 +00001491def SHL8ri : Ii8<0xC0, MRM4r, (outs GR8 :$dst), (ins GR8 :$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001492 "shl{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001493 [(set GR8:$dst, (shl GR8:$src1, (i8 imm:$src2)))]>;
1494let isConvertibleToThreeAddress = 1 in { // Can transform into LEA.
Evan Chengb783fa32007-07-19 01:14:50 +00001495def SHL16ri : Ii8<0xC1, MRM4r, (outs GR16:$dst), (ins GR16:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001496 "shl{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001497 [(set GR16:$dst, (shl GR16:$src1, (i8 imm:$src2)))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001498def SHL32ri : Ii8<0xC1, MRM4r, (outs GR32:$dst), (ins GR32:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001499 "shl{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001500 [(set GR32:$dst, (shl GR32:$src1, (i8 imm:$src2)))]>;
Chris Lattnerf4005a82008-01-11 18:00:50 +00001501// NOTE: We don't use shifts of a register by one, because 'add reg,reg' is
1502// cheaper.
Bill Wendlingba5d5b02008-05-29 01:02:09 +00001503} // isConvertibleToThreeAddress = 1
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001504
1505let isTwoAddress = 0 in {
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001506 let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00001507 def SHL8mCL : I<0xD2, MRM4m, (outs), (ins i8mem :$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001508 "shl{b}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001509 [(store (shl (loadi8 addr:$dst), CL), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001510 def SHL16mCL : I<0xD3, MRM4m, (outs), (ins i16mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001511 "shl{w}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001512 [(store (shl (loadi16 addr:$dst), CL), addr:$dst)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001513 def SHL32mCL : I<0xD3, MRM4m, (outs), (ins i32mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001514 "shl{l}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001515 [(store (shl (loadi32 addr:$dst), CL), addr:$dst)]>;
1516 }
Evan Chengb783fa32007-07-19 01:14:50 +00001517 def SHL8mi : Ii8<0xC0, MRM4m, (outs), (ins i8mem :$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001518 "shl{b}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001519 [(store (shl (loadi8 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001520 def SHL16mi : Ii8<0xC1, MRM4m, (outs), (ins i16mem:$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001521 "shl{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001522 [(store (shl (loadi16 addr:$dst), (i8 imm:$src)), addr:$dst)]>,
1523 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001524 def SHL32mi : Ii8<0xC1, MRM4m, (outs), (ins i32mem:$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001525 "shl{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001526 [(store (shl (loadi32 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
1527
1528 // Shift by 1
Evan Chengb783fa32007-07-19 01:14:50 +00001529 def SHL8m1 : I<0xD0, MRM4m, (outs), (ins i8mem :$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001530 "shl{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001531 [(store (shl (loadi8 addr:$dst), (i8 1)), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001532 def SHL16m1 : I<0xD1, MRM4m, (outs), (ins i16mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001533 "shl{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001534 [(store (shl (loadi16 addr:$dst), (i8 1)), addr:$dst)]>,
1535 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001536 def SHL32m1 : I<0xD1, MRM4m, (outs), (ins i32mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001537 "shl{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001538 [(store (shl (loadi32 addr:$dst), (i8 1)), addr:$dst)]>;
1539}
1540
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001541let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00001542def SHR8rCL : I<0xD2, MRM5r, (outs GR8 :$dst), (ins GR8 :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001543 "shr{b}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001544 [(set GR8:$dst, (srl GR8:$src, CL))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001545def SHR16rCL : I<0xD3, MRM5r, (outs GR16:$dst), (ins GR16:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001546 "shr{w}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001547 [(set GR16:$dst, (srl GR16:$src, CL))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001548def SHR32rCL : I<0xD3, MRM5r, (outs GR32:$dst), (ins GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001549 "shr{l}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001550 [(set GR32:$dst, (srl GR32:$src, CL))]>;
1551}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001552
Evan Chengb783fa32007-07-19 01:14:50 +00001553def SHR8ri : Ii8<0xC0, MRM5r, (outs GR8:$dst), (ins GR8:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001554 "shr{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001555 [(set GR8:$dst, (srl GR8:$src1, (i8 imm:$src2)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001556def SHR16ri : Ii8<0xC1, MRM5r, (outs GR16:$dst), (ins GR16:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001557 "shr{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001558 [(set GR16:$dst, (srl GR16:$src1, (i8 imm:$src2)))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001559def SHR32ri : Ii8<0xC1, MRM5r, (outs GR32:$dst), (ins GR32:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001560 "shr{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001561 [(set GR32:$dst, (srl GR32:$src1, (i8 imm:$src2)))]>;
1562
1563// Shift by 1
Evan Chengb783fa32007-07-19 01:14:50 +00001564def SHR8r1 : I<0xD0, MRM5r, (outs GR8:$dst), (ins GR8:$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00001565 "shr{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001566 [(set GR8:$dst, (srl GR8:$src1, (i8 1)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001567def SHR16r1 : I<0xD1, MRM5r, (outs GR16:$dst), (ins GR16:$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00001568 "shr{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001569 [(set GR16:$dst, (srl GR16:$src1, (i8 1)))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001570def SHR32r1 : I<0xD1, MRM5r, (outs GR32:$dst), (ins GR32:$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00001571 "shr{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001572 [(set GR32:$dst, (srl GR32:$src1, (i8 1)))]>;
1573
1574let isTwoAddress = 0 in {
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001575 let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00001576 def SHR8mCL : I<0xD2, MRM5m, (outs), (ins i8mem :$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001577 "shr{b}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001578 [(store (srl (loadi8 addr:$dst), CL), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001579 def SHR16mCL : I<0xD3, MRM5m, (outs), (ins i16mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001580 "shr{w}\t{%cl, $dst|$dst, %CL}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001581 [(store (srl (loadi16 addr:$dst), CL), addr:$dst)]>,
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001582 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001583 def SHR32mCL : I<0xD3, MRM5m, (outs), (ins i32mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001584 "shr{l}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001585 [(store (srl (loadi32 addr:$dst), CL), addr:$dst)]>;
1586 }
Evan Chengb783fa32007-07-19 01:14:50 +00001587 def SHR8mi : Ii8<0xC0, MRM5m, (outs), (ins i8mem :$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001588 "shr{b}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001589 [(store (srl (loadi8 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001590 def SHR16mi : Ii8<0xC1, MRM5m, (outs), (ins i16mem:$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001591 "shr{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001592 [(store (srl (loadi16 addr:$dst), (i8 imm:$src)), addr:$dst)]>,
1593 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001594 def SHR32mi : Ii8<0xC1, MRM5m, (outs), (ins i32mem:$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001595 "shr{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001596 [(store (srl (loadi32 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
1597
1598 // Shift by 1
Evan Chengb783fa32007-07-19 01:14:50 +00001599 def SHR8m1 : I<0xD0, MRM5m, (outs), (ins i8mem :$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001600 "shr{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001601 [(store (srl (loadi8 addr:$dst), (i8 1)), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001602 def SHR16m1 : I<0xD1, MRM5m, (outs), (ins i16mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001603 "shr{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001604 [(store (srl (loadi16 addr:$dst), (i8 1)), addr:$dst)]>,OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001605 def SHR32m1 : I<0xD1, MRM5m, (outs), (ins i32mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001606 "shr{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001607 [(store (srl (loadi32 addr:$dst), (i8 1)), addr:$dst)]>;
1608}
1609
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001610let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00001611def SAR8rCL : I<0xD2, MRM7r, (outs GR8 :$dst), (ins GR8 :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001612 "sar{b}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001613 [(set GR8:$dst, (sra GR8:$src, CL))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001614def SAR16rCL : I<0xD3, MRM7r, (outs GR16:$dst), (ins GR16:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001615 "sar{w}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001616 [(set GR16:$dst, (sra GR16:$src, CL))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001617def SAR32rCL : I<0xD3, MRM7r, (outs GR32:$dst), (ins GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001618 "sar{l}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001619 [(set GR32:$dst, (sra GR32:$src, CL))]>;
1620}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001621
Evan Chengb783fa32007-07-19 01:14:50 +00001622def SAR8ri : Ii8<0xC0, MRM7r, (outs GR8 :$dst), (ins GR8 :$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001623 "sar{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001624 [(set GR8:$dst, (sra GR8:$src1, (i8 imm:$src2)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001625def SAR16ri : Ii8<0xC1, MRM7r, (outs GR16:$dst), (ins GR16:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001626 "sar{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001627 [(set GR16:$dst, (sra GR16:$src1, (i8 imm:$src2)))]>,
1628 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001629def SAR32ri : Ii8<0xC1, MRM7r, (outs GR32:$dst), (ins GR32:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001630 "sar{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001631 [(set GR32:$dst, (sra GR32:$src1, (i8 imm:$src2)))]>;
1632
1633// Shift by 1
Evan Chengb783fa32007-07-19 01:14:50 +00001634def SAR8r1 : I<0xD0, MRM7r, (outs GR8 :$dst), (ins GR8 :$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00001635 "sar{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001636 [(set GR8:$dst, (sra GR8:$src1, (i8 1)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001637def SAR16r1 : I<0xD1, MRM7r, (outs GR16:$dst), (ins GR16:$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00001638 "sar{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001639 [(set GR16:$dst, (sra GR16:$src1, (i8 1)))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001640def SAR32r1 : I<0xD1, MRM7r, (outs GR32:$dst), (ins GR32:$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00001641 "sar{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001642 [(set GR32:$dst, (sra GR32:$src1, (i8 1)))]>;
1643
1644let isTwoAddress = 0 in {
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001645 let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00001646 def SAR8mCL : I<0xD2, MRM7m, (outs), (ins i8mem :$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001647 "sar{b}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001648 [(store (sra (loadi8 addr:$dst), CL), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001649 def SAR16mCL : I<0xD3, MRM7m, (outs), (ins i16mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001650 "sar{w}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001651 [(store (sra (loadi16 addr:$dst), CL), addr:$dst)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001652 def SAR32mCL : I<0xD3, MRM7m, (outs), (ins i32mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001653 "sar{l}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001654 [(store (sra (loadi32 addr:$dst), CL), addr:$dst)]>;
1655 }
Evan Chengb783fa32007-07-19 01:14:50 +00001656 def SAR8mi : Ii8<0xC0, MRM7m, (outs), (ins i8mem :$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001657 "sar{b}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001658 [(store (sra (loadi8 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001659 def SAR16mi : Ii8<0xC1, MRM7m, (outs), (ins i16mem:$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001660 "sar{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001661 [(store (sra (loadi16 addr:$dst), (i8 imm:$src)), addr:$dst)]>,
1662 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001663 def SAR32mi : Ii8<0xC1, MRM7m, (outs), (ins i32mem:$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001664 "sar{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001665 [(store (sra (loadi32 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
1666
1667 // Shift by 1
Evan Chengb783fa32007-07-19 01:14:50 +00001668 def SAR8m1 : I<0xD0, MRM7m, (outs), (ins i8mem :$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001669 "sar{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001670 [(store (sra (loadi8 addr:$dst), (i8 1)), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001671 def SAR16m1 : I<0xD1, MRM7m, (outs), (ins i16mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001672 "sar{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001673 [(store (sra (loadi16 addr:$dst), (i8 1)), addr:$dst)]>,
1674 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001675 def SAR32m1 : I<0xD1, MRM7m, (outs), (ins i32mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001676 "sar{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001677 [(store (sra (loadi32 addr:$dst), (i8 1)), addr:$dst)]>;
1678}
1679
1680// Rotate instructions
1681// FIXME: provide shorter instructions when imm8 == 1
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001682let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00001683def ROL8rCL : I<0xD2, MRM0r, (outs GR8 :$dst), (ins GR8 :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001684 "rol{b}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001685 [(set GR8:$dst, (rotl GR8:$src, CL))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001686def ROL16rCL : I<0xD3, MRM0r, (outs GR16:$dst), (ins GR16:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001687 "rol{w}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001688 [(set GR16:$dst, (rotl GR16:$src, CL))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001689def ROL32rCL : I<0xD3, MRM0r, (outs GR32:$dst), (ins GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001690 "rol{l}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001691 [(set GR32:$dst, (rotl GR32:$src, CL))]>;
1692}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001693
Evan Chengb783fa32007-07-19 01:14:50 +00001694def ROL8ri : Ii8<0xC0, MRM0r, (outs GR8 :$dst), (ins GR8 :$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001695 "rol{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001696 [(set GR8:$dst, (rotl GR8:$src1, (i8 imm:$src2)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001697def ROL16ri : Ii8<0xC1, MRM0r, (outs GR16:$dst), (ins GR16:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001698 "rol{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001699 [(set GR16:$dst, (rotl GR16:$src1, (i8 imm:$src2)))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001700def ROL32ri : Ii8<0xC1, MRM0r, (outs GR32:$dst), (ins GR32:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001701 "rol{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001702 [(set GR32:$dst, (rotl GR32:$src1, (i8 imm:$src2)))]>;
1703
1704// Rotate by 1
Evan Chengb783fa32007-07-19 01:14:50 +00001705def ROL8r1 : I<0xD0, MRM0r, (outs GR8 :$dst), (ins GR8 :$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00001706 "rol{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001707 [(set GR8:$dst, (rotl GR8:$src1, (i8 1)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001708def ROL16r1 : I<0xD1, MRM0r, (outs GR16:$dst), (ins GR16:$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00001709 "rol{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001710 [(set GR16:$dst, (rotl GR16:$src1, (i8 1)))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001711def ROL32r1 : I<0xD1, MRM0r, (outs GR32:$dst), (ins GR32:$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00001712 "rol{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001713 [(set GR32:$dst, (rotl GR32:$src1, (i8 1)))]>;
1714
1715let isTwoAddress = 0 in {
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001716 let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00001717 def ROL8mCL : I<0xD2, MRM0m, (outs), (ins i8mem :$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001718 "rol{b}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001719 [(store (rotl (loadi8 addr:$dst), CL), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001720 def ROL16mCL : I<0xD3, MRM0m, (outs), (ins i16mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001721 "rol{w}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001722 [(store (rotl (loadi16 addr:$dst), CL), addr:$dst)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001723 def ROL32mCL : I<0xD3, MRM0m, (outs), (ins i32mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001724 "rol{l}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001725 [(store (rotl (loadi32 addr:$dst), CL), addr:$dst)]>;
1726 }
Evan Chengb783fa32007-07-19 01:14:50 +00001727 def ROL8mi : Ii8<0xC0, MRM0m, (outs), (ins i8mem :$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001728 "rol{b}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001729 [(store (rotl (loadi8 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001730 def ROL16mi : Ii8<0xC1, MRM0m, (outs), (ins i16mem:$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001731 "rol{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001732 [(store (rotl (loadi16 addr:$dst), (i8 imm:$src)), addr:$dst)]>,
1733 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001734 def ROL32mi : Ii8<0xC1, MRM0m, (outs), (ins i32mem:$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001735 "rol{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001736 [(store (rotl (loadi32 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
1737
1738 // Rotate by 1
Evan Chengb783fa32007-07-19 01:14:50 +00001739 def ROL8m1 : I<0xD0, MRM0m, (outs), (ins i8mem :$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001740 "rol{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001741 [(store (rotl (loadi8 addr:$dst), (i8 1)), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001742 def ROL16m1 : I<0xD1, MRM0m, (outs), (ins i16mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001743 "rol{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001744 [(store (rotl (loadi16 addr:$dst), (i8 1)), addr:$dst)]>,
1745 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001746 def ROL32m1 : I<0xD1, MRM0m, (outs), (ins i32mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001747 "rol{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001748 [(store (rotl (loadi32 addr:$dst), (i8 1)), addr:$dst)]>;
1749}
1750
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001751let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00001752def ROR8rCL : I<0xD2, MRM1r, (outs GR8 :$dst), (ins GR8 :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001753 "ror{b}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001754 [(set GR8:$dst, (rotr GR8:$src, CL))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001755def ROR16rCL : I<0xD3, MRM1r, (outs GR16:$dst), (ins GR16:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001756 "ror{w}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001757 [(set GR16:$dst, (rotr GR16:$src, CL))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001758def ROR32rCL : I<0xD3, MRM1r, (outs GR32:$dst), (ins GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001759 "ror{l}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001760 [(set GR32:$dst, (rotr GR32:$src, CL))]>;
1761}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001762
Evan Chengb783fa32007-07-19 01:14:50 +00001763def ROR8ri : Ii8<0xC0, MRM1r, (outs GR8 :$dst), (ins GR8 :$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001764 "ror{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001765 [(set GR8:$dst, (rotr GR8:$src1, (i8 imm:$src2)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001766def ROR16ri : Ii8<0xC1, MRM1r, (outs GR16:$dst), (ins GR16:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001767 "ror{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001768 [(set GR16:$dst, (rotr GR16:$src1, (i8 imm:$src2)))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001769def ROR32ri : Ii8<0xC1, MRM1r, (outs GR32:$dst), (ins GR32:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001770 "ror{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001771 [(set GR32:$dst, (rotr GR32:$src1, (i8 imm:$src2)))]>;
1772
1773// Rotate by 1
Evan Chengb783fa32007-07-19 01:14:50 +00001774def ROR8r1 : I<0xD0, MRM1r, (outs GR8 :$dst), (ins GR8 :$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00001775 "ror{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001776 [(set GR8:$dst, (rotr GR8:$src1, (i8 1)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001777def ROR16r1 : I<0xD1, MRM1r, (outs GR16:$dst), (ins GR16:$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00001778 "ror{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001779 [(set GR16:$dst, (rotr GR16:$src1, (i8 1)))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001780def ROR32r1 : I<0xD1, MRM1r, (outs GR32:$dst), (ins GR32:$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00001781 "ror{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001782 [(set GR32:$dst, (rotr GR32:$src1, (i8 1)))]>;
1783
1784let isTwoAddress = 0 in {
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001785 let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00001786 def ROR8mCL : I<0xD2, MRM1m, (outs), (ins i8mem :$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001787 "ror{b}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001788 [(store (rotr (loadi8 addr:$dst), CL), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001789 def ROR16mCL : I<0xD3, MRM1m, (outs), (ins i16mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001790 "ror{w}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001791 [(store (rotr (loadi16 addr:$dst), CL), addr:$dst)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001792 def ROR32mCL : I<0xD3, MRM1m, (outs), (ins i32mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001793 "ror{l}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001794 [(store (rotr (loadi32 addr:$dst), CL), addr:$dst)]>;
1795 }
Evan Chengb783fa32007-07-19 01:14:50 +00001796 def ROR8mi : Ii8<0xC0, MRM1m, (outs), (ins i8mem :$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001797 "ror{b}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001798 [(store (rotr (loadi8 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001799 def ROR16mi : Ii8<0xC1, MRM1m, (outs), (ins i16mem:$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001800 "ror{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001801 [(store (rotr (loadi16 addr:$dst), (i8 imm:$src)), addr:$dst)]>,
1802 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001803 def ROR32mi : Ii8<0xC1, MRM1m, (outs), (ins i32mem:$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001804 "ror{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001805 [(store (rotr (loadi32 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
1806
1807 // Rotate by 1
Evan Chengb783fa32007-07-19 01:14:50 +00001808 def ROR8m1 : I<0xD0, MRM1m, (outs), (ins i8mem :$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001809 "ror{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001810 [(store (rotr (loadi8 addr:$dst), (i8 1)), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001811 def ROR16m1 : I<0xD1, MRM1m, (outs), (ins i16mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001812 "ror{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001813 [(store (rotr (loadi16 addr:$dst), (i8 1)), addr:$dst)]>,
1814 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001815 def ROR32m1 : I<0xD1, MRM1m, (outs), (ins i32mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001816 "ror{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001817 [(store (rotr (loadi32 addr:$dst), (i8 1)), addr:$dst)]>;
1818}
1819
1820
1821
1822// Double shift instructions (generalizations of rotate)
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001823let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00001824def SHLD32rrCL : I<0xA5, MRMDestReg, (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001825 "shld{l}\t{%cl, $src2, $dst|$dst, $src2, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001826 [(set GR32:$dst, (X86shld GR32:$src1, GR32:$src2, CL))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00001827def SHRD32rrCL : I<0xAD, MRMDestReg, (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001828 "shrd{l}\t{%cl, $src2, $dst|$dst, $src2, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001829 [(set GR32:$dst, (X86shrd GR32:$src1, GR32:$src2, CL))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00001830def SHLD16rrCL : I<0xA5, MRMDestReg, (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001831 "shld{w}\t{%cl, $src2, $dst|$dst, $src2, %CL}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001832 [(set GR16:$dst, (X86shld GR16:$src1, GR16:$src2, CL))]>,
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001833 TB, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001834def SHRD16rrCL : I<0xAD, MRMDestReg, (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001835 "shrd{w}\t{%cl, $src2, $dst|$dst, $src2, %CL}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001836 [(set GR16:$dst, (X86shrd GR16:$src1, GR16:$src2, CL))]>,
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001837 TB, OpSize;
1838}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001839
1840let isCommutable = 1 in { // These instructions commute to each other.
1841def SHLD32rri8 : Ii8<0xA4, MRMDestReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001842 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2, i8imm:$src3),
Dan Gohman91888f02007-07-31 20:11:57 +00001843 "shld{l}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001844 [(set GR32:$dst, (X86shld GR32:$src1, GR32:$src2,
1845 (i8 imm:$src3)))]>,
1846 TB;
1847def SHRD32rri8 : Ii8<0xAC, MRMDestReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001848 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2, i8imm:$src3),
Dan Gohman91888f02007-07-31 20:11:57 +00001849 "shrd{l}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001850 [(set GR32:$dst, (X86shrd GR32:$src1, GR32:$src2,
1851 (i8 imm:$src3)))]>,
1852 TB;
1853def SHLD16rri8 : Ii8<0xA4, MRMDestReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001854 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2, i8imm:$src3),
Dan Gohman91888f02007-07-31 20:11:57 +00001855 "shld{w}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001856 [(set GR16:$dst, (X86shld GR16:$src1, GR16:$src2,
1857 (i8 imm:$src3)))]>,
1858 TB, OpSize;
1859def SHRD16rri8 : Ii8<0xAC, MRMDestReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001860 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2, i8imm:$src3),
Dan Gohman91888f02007-07-31 20:11:57 +00001861 "shrd{w}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001862 [(set GR16:$dst, (X86shrd GR16:$src1, GR16:$src2,
1863 (i8 imm:$src3)))]>,
1864 TB, OpSize;
1865}
1866
1867let isTwoAddress = 0 in {
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001868 let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00001869 def SHLD32mrCL : I<0xA5, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001870 "shld{l}\t{%cl, $src2, $dst|$dst, $src2, %CL}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001871 [(store (X86shld (loadi32 addr:$dst), GR32:$src2, CL),
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001872 addr:$dst)]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00001873 def SHRD32mrCL : I<0xAD, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001874 "shrd{l}\t{%cl, $src2, $dst|$dst, $src2, %CL}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001875 [(store (X86shrd (loadi32 addr:$dst), GR32:$src2, CL),
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001876 addr:$dst)]>, TB;
1877 }
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001878 def SHLD32mri8 : Ii8<0xA4, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001879 (outs), (ins i32mem:$dst, GR32:$src2, i8imm:$src3),
Dan Gohman91888f02007-07-31 20:11:57 +00001880 "shld{l}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001881 [(store (X86shld (loadi32 addr:$dst), GR32:$src2,
1882 (i8 imm:$src3)), addr:$dst)]>,
1883 TB;
1884 def SHRD32mri8 : Ii8<0xAC, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001885 (outs), (ins i32mem:$dst, GR32:$src2, i8imm:$src3),
Dan Gohman91888f02007-07-31 20:11:57 +00001886 "shrd{l}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001887 [(store (X86shrd (loadi32 addr:$dst), GR32:$src2,
1888 (i8 imm:$src3)), addr:$dst)]>,
1889 TB;
1890
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001891 let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00001892 def SHLD16mrCL : I<0xA5, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001893 "shld{w}\t{%cl, $src2, $dst|$dst, $src2, %CL}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001894 [(store (X86shld (loadi16 addr:$dst), GR16:$src2, CL),
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001895 addr:$dst)]>, TB, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001896 def SHRD16mrCL : I<0xAD, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001897 "shrd{w}\t{%cl, $src2, $dst|$dst, $src2, %CL}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001898 [(store (X86shrd (loadi16 addr:$dst), GR16:$src2, CL),
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001899 addr:$dst)]>, TB, OpSize;
1900 }
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001901 def SHLD16mri8 : Ii8<0xA4, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001902 (outs), (ins i16mem:$dst, GR16:$src2, i8imm:$src3),
Dan Gohman91888f02007-07-31 20:11:57 +00001903 "shld{w}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001904 [(store (X86shld (loadi16 addr:$dst), GR16:$src2,
1905 (i8 imm:$src3)), addr:$dst)]>,
1906 TB, OpSize;
1907 def SHRD16mri8 : Ii8<0xAC, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001908 (outs), (ins i16mem:$dst, GR16:$src2, i8imm:$src3),
Dan Gohman91888f02007-07-31 20:11:57 +00001909 "shrd{w}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001910 [(store (X86shrd (loadi16 addr:$dst), GR16:$src2,
1911 (i8 imm:$src3)), addr:$dst)]>,
1912 TB, OpSize;
1913}
Evan Cheng55687072007-09-14 21:48:26 +00001914} // Defs = [EFLAGS]
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001915
1916
1917// Arithmetic.
Evan Cheng55687072007-09-14 21:48:26 +00001918let Defs = [EFLAGS] in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001919let isCommutable = 1 in { // X = ADD Y, Z --> X = ADD Z, Y
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001920def ADD8rr : I<0x00, MRMDestReg, (outs GR8 :$dst),
1921 (ins GR8 :$src1, GR8 :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001922 "add{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001923 [(set GR8:$dst, (add GR8:$src1, GR8:$src2))]>;
1924let isConvertibleToThreeAddress = 1 in { // Can transform into LEA.
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001925def ADD16rr : I<0x01, MRMDestReg, (outs GR16:$dst),
1926 (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001927 "add{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001928 [(set GR16:$dst, (add GR16:$src1, GR16:$src2))]>, OpSize;
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001929def ADD32rr : I<0x01, MRMDestReg, (outs GR32:$dst),
1930 (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001931 "add{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001932 [(set GR32:$dst, (add GR32:$src1, GR32:$src2))]>;
1933} // end isConvertibleToThreeAddress
1934} // end isCommutable
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001935def ADD8rm : I<0x02, MRMSrcMem, (outs GR8 :$dst),
1936 (ins GR8 :$src1, i8mem :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001937 "add{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001938 [(set GR8:$dst, (add GR8:$src1, (load addr:$src2)))]>;
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001939def ADD16rm : I<0x03, MRMSrcMem, (outs GR16:$dst),
1940 (ins GR16:$src1, i16mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001941 "add{w}\t{$src2, $dst|$dst, $src2}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001942 [(set GR16:$dst, (add GR16:$src1, (load addr:$src2)))]>,OpSize;
1943def ADD32rm : I<0x03, MRMSrcMem, (outs GR32:$dst),
1944 (ins GR32:$src1, i32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001945 "add{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001946 [(set GR32:$dst, (add GR32:$src1, (load addr:$src2)))]>;
1947
Evan Chengb783fa32007-07-19 01:14:50 +00001948def ADD8ri : Ii8<0x80, MRM0r, (outs GR8:$dst), (ins GR8:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001949 "add{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001950 [(set GR8:$dst, (add GR8:$src1, imm:$src2))]>;
1951
1952let isConvertibleToThreeAddress = 1 in { // Can transform into LEA.
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001953def ADD16ri : Ii16<0x81, MRM0r, (outs GR16:$dst),
1954 (ins GR16:$src1, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001955 "add{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001956 [(set GR16:$dst, (add GR16:$src1, imm:$src2))]>, OpSize;
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001957def ADD32ri : Ii32<0x81, MRM0r, (outs GR32:$dst),
1958 (ins GR32:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001959 "add{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001960 [(set GR32:$dst, (add GR32:$src1, imm:$src2))]>;
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001961def ADD16ri8 : Ii8<0x83, MRM0r, (outs GR16:$dst),
1962 (ins GR16:$src1, i16i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001963 "add{w}\t{$src2, $dst|$dst, $src2}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001964 [(set GR16:$dst, (add GR16:$src1, i16immSExt8:$src2))]>, OpSize;
1965def ADD32ri8 : Ii8<0x83, MRM0r, (outs GR32:$dst),
1966 (ins GR32:$src1, i32i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001967 "add{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001968 [(set GR32:$dst, (add GR32:$src1, i32immSExt8:$src2))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001969}
1970
1971let isTwoAddress = 0 in {
Evan Chengb783fa32007-07-19 01:14:50 +00001972 def ADD8mr : I<0x00, MRMDestMem, (outs), (ins i8mem :$dst, GR8 :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001973 "add{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001974 [(store (add (load addr:$dst), GR8:$src2), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001975 def ADD16mr : I<0x01, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001976 "add{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001977 [(store (add (load addr:$dst), GR16:$src2), addr:$dst)]>,
Evan Cheng55687072007-09-14 21:48:26 +00001978 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001979 def ADD32mr : I<0x01, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001980 "add{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001981 [(store (add (load addr:$dst), GR32:$src2), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001982 def ADD8mi : Ii8<0x80, MRM0m, (outs), (ins i8mem :$dst, i8imm :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001983 "add{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001984 [(store (add (loadi8 addr:$dst), imm:$src2), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001985 def ADD16mi : Ii16<0x81, MRM0m, (outs), (ins i16mem:$dst, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001986 "add{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001987 [(store (add (loadi16 addr:$dst), imm:$src2), addr:$dst)]>,
Evan Cheng55687072007-09-14 21:48:26 +00001988 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001989 def ADD32mi : Ii32<0x81, MRM0m, (outs), (ins i32mem:$dst, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001990 "add{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001991 [(store (add (loadi32 addr:$dst), imm:$src2), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001992 def ADD16mi8 : Ii8<0x83, MRM0m, (outs), (ins i16mem:$dst, i16i8imm :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001993 "add{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001994 [(store (add (load addr:$dst), i16immSExt8:$src2), addr:$dst)]>,
Evan Cheng55687072007-09-14 21:48:26 +00001995 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001996 def ADD32mi8 : Ii8<0x83, MRM0m, (outs), (ins i32mem:$dst, i32i8imm :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001997 "add{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001998 [(store (add (load addr:$dst), i32immSExt8:$src2), addr:$dst)]>;
1999}
2000
Evan Cheng259471d2007-10-05 17:59:57 +00002001let Uses = [EFLAGS] in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002002let isCommutable = 1 in { // X = ADC Y, Z --> X = ADC Z, Y
Evan Chengb783fa32007-07-19 01:14:50 +00002003def ADC32rr : I<0x11, MRMDestReg, (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002004 "adc{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002005 [(set GR32:$dst, (adde GR32:$src1, GR32:$src2))]>;
2006}
Evan Chengb783fa32007-07-19 01:14:50 +00002007def ADC32rm : I<0x13, MRMSrcMem , (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002008 "adc{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002009 [(set GR32:$dst, (adde GR32:$src1, (load addr:$src2)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002010def ADC32ri : Ii32<0x81, MRM2r, (outs GR32:$dst), (ins GR32:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002011 "adc{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002012 [(set GR32:$dst, (adde GR32:$src1, imm:$src2))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002013def ADC32ri8 : Ii8<0x83, MRM2r, (outs GR32:$dst), (ins GR32:$src1, i32i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002014 "adc{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002015 [(set GR32:$dst, (adde GR32:$src1, i32immSExt8:$src2))]>;
2016
2017let isTwoAddress = 0 in {
Evan Chengb783fa32007-07-19 01:14:50 +00002018 def ADC32mr : I<0x11, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002019 "adc{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002020 [(store (adde (load addr:$dst), GR32:$src2), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002021 def ADC32mi : Ii32<0x81, MRM2m, (outs), (ins i32mem:$dst, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002022 "adc{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002023 [(store (adde (loadi32 addr:$dst), imm:$src2), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002024 def ADC32mi8 : Ii8<0x83, MRM2m, (outs), (ins i32mem:$dst, i32i8imm :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002025 "adc{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002026 [(store (adde (load addr:$dst), i32immSExt8:$src2), addr:$dst)]>;
2027}
Evan Cheng259471d2007-10-05 17:59:57 +00002028} // Uses = [EFLAGS]
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002029
Evan Chengb783fa32007-07-19 01:14:50 +00002030def SUB8rr : I<0x28, MRMDestReg, (outs GR8 :$dst), (ins GR8 :$src1, GR8 :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002031 "sub{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002032 [(set GR8:$dst, (sub GR8:$src1, GR8:$src2))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002033def SUB16rr : I<0x29, MRMDestReg, (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002034 "sub{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002035 [(set GR16:$dst, (sub GR16:$src1, GR16:$src2))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002036def SUB32rr : I<0x29, MRMDestReg, (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002037 "sub{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002038 [(set GR32:$dst, (sub GR32:$src1, GR32:$src2))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002039def SUB8rm : I<0x2A, MRMSrcMem, (outs GR8 :$dst), (ins GR8 :$src1, i8mem :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002040 "sub{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002041 [(set GR8:$dst, (sub GR8:$src1, (load addr:$src2)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002042def SUB16rm : I<0x2B, MRMSrcMem, (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002043 "sub{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002044 [(set GR16:$dst, (sub GR16:$src1, (load addr:$src2)))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002045def SUB32rm : I<0x2B, MRMSrcMem, (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002046 "sub{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002047 [(set GR32:$dst, (sub GR32:$src1, (load addr:$src2)))]>;
2048
Evan Chengb783fa32007-07-19 01:14:50 +00002049def SUB8ri : Ii8 <0x80, MRM5r, (outs GR8:$dst), (ins GR8:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002050 "sub{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002051 [(set GR8:$dst, (sub GR8:$src1, imm:$src2))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002052def SUB16ri : Ii16<0x81, MRM5r, (outs GR16:$dst), (ins GR16:$src1, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002053 "sub{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002054 [(set GR16:$dst, (sub GR16:$src1, imm:$src2))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002055def SUB32ri : Ii32<0x81, MRM5r, (outs GR32:$dst), (ins GR32:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002056 "sub{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002057 [(set GR32:$dst, (sub GR32:$src1, imm:$src2))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002058def SUB16ri8 : Ii8<0x83, MRM5r, (outs GR16:$dst), (ins GR16:$src1, i16i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002059 "sub{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002060 [(set GR16:$dst, (sub GR16:$src1, i16immSExt8:$src2))]>,
Evan Cheng55687072007-09-14 21:48:26 +00002061 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002062def SUB32ri8 : Ii8<0x83, MRM5r, (outs GR32:$dst), (ins GR32:$src1, i32i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002063 "sub{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002064 [(set GR32:$dst, (sub GR32:$src1, i32immSExt8:$src2))]>;
2065let isTwoAddress = 0 in {
Evan Chengb783fa32007-07-19 01:14:50 +00002066 def SUB8mr : I<0x28, MRMDestMem, (outs), (ins i8mem :$dst, GR8 :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002067 "sub{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002068 [(store (sub (load addr:$dst), GR8:$src2), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002069 def SUB16mr : I<0x29, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002070 "sub{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002071 [(store (sub (load addr:$dst), GR16:$src2), addr:$dst)]>,
Evan Cheng55687072007-09-14 21:48:26 +00002072 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002073 def SUB32mr : I<0x29, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002074 "sub{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002075 [(store (sub (load addr:$dst), GR32:$src2), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002076 def SUB8mi : Ii8<0x80, MRM5m, (outs), (ins i8mem :$dst, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002077 "sub{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002078 [(store (sub (loadi8 addr:$dst), imm:$src2), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002079 def SUB16mi : Ii16<0x81, MRM5m, (outs), (ins i16mem:$dst, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002080 "sub{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002081 [(store (sub (loadi16 addr:$dst), imm:$src2), addr:$dst)]>,
Evan Cheng55687072007-09-14 21:48:26 +00002082 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002083 def SUB32mi : Ii32<0x81, MRM5m, (outs), (ins i32mem:$dst, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002084 "sub{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002085 [(store (sub (loadi32 addr:$dst), imm:$src2), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002086 def SUB16mi8 : Ii8<0x83, MRM5m, (outs), (ins i16mem:$dst, i16i8imm :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002087 "sub{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002088 [(store (sub (load addr:$dst), i16immSExt8:$src2), addr:$dst)]>,
Evan Cheng55687072007-09-14 21:48:26 +00002089 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002090 def SUB32mi8 : Ii8<0x83, MRM5m, (outs), (ins i32mem:$dst, i32i8imm :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002091 "sub{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002092 [(store (sub (load addr:$dst), i32immSExt8:$src2), addr:$dst)]>;
2093}
2094
Evan Cheng259471d2007-10-05 17:59:57 +00002095let Uses = [EFLAGS] in {
Evan Chengb783fa32007-07-19 01:14:50 +00002096def SBB32rr : I<0x19, MRMDestReg, (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002097 "sbb{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng55687072007-09-14 21:48:26 +00002098 [(set GR32:$dst, (sube GR32:$src1, GR32:$src2))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002099
2100let isTwoAddress = 0 in {
Evan Chengb783fa32007-07-19 01:14:50 +00002101 def SBB32mr : I<0x19, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002102 "sbb{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002103 [(store (sube (load addr:$dst), GR32:$src2), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002104 def SBB8mi : Ii32<0x80, MRM3m, (outs), (ins i8mem:$dst, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002105 "sbb{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002106 [(store (sube (loadi8 addr:$dst), imm:$src2), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002107 def SBB32mi : Ii32<0x81, MRM3m, (outs), (ins i32mem:$dst, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002108 "sbb{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002109 [(store (sube (loadi32 addr:$dst), imm:$src2), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002110 def SBB32mi8 : Ii8<0x83, MRM3m, (outs), (ins i32mem:$dst, i32i8imm :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002111 "sbb{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng55687072007-09-14 21:48:26 +00002112 [(store (sube (load addr:$dst), i32immSExt8:$src2), addr:$dst)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002113}
Evan Chengb783fa32007-07-19 01:14:50 +00002114def SBB32rm : I<0x1B, MRMSrcMem, (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002115 "sbb{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002116 [(set GR32:$dst, (sube GR32:$src1, (load addr:$src2)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002117def SBB32ri : Ii32<0x81, MRM3r, (outs GR32:$dst), (ins GR32:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002118 "sbb{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002119 [(set GR32:$dst, (sube GR32:$src1, imm:$src2))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002120def SBB32ri8 : Ii8<0x83, MRM3r, (outs GR32:$dst), (ins GR32:$src1, i32i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002121 "sbb{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002122 [(set GR32:$dst, (sube GR32:$src1, i32immSExt8:$src2))]>;
Evan Cheng259471d2007-10-05 17:59:57 +00002123} // Uses = [EFLAGS]
Evan Cheng55687072007-09-14 21:48:26 +00002124} // Defs = [EFLAGS]
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002125
Evan Cheng55687072007-09-14 21:48:26 +00002126let Defs = [EFLAGS] in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002127let isCommutable = 1 in { // X = IMUL Y, Z --> X = IMUL Z, Y
Evan Chengb783fa32007-07-19 01:14:50 +00002128def IMUL16rr : I<0xAF, MRMSrcReg, (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002129 "imul{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002130 [(set GR16:$dst, (mul GR16:$src1, GR16:$src2))]>, TB, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002131def IMUL32rr : I<0xAF, MRMSrcReg, (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002132 "imul{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002133 [(set GR32:$dst, (mul GR32:$src1, GR32:$src2))]>, TB;
2134}
Evan Chengb783fa32007-07-19 01:14:50 +00002135def IMUL16rm : I<0xAF, MRMSrcMem, (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002136 "imul{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002137 [(set GR16:$dst, (mul GR16:$src1, (load addr:$src2)))]>,
2138 TB, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002139def IMUL32rm : I<0xAF, MRMSrcMem, (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002140 "imul{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002141 [(set GR32:$dst, (mul GR32:$src1, (load addr:$src2)))]>, TB;
Evan Cheng55687072007-09-14 21:48:26 +00002142} // Defs = [EFLAGS]
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002143} // end Two Address instructions
2144
2145// Suprisingly enough, these are not two address instructions!
Evan Cheng55687072007-09-14 21:48:26 +00002146let Defs = [EFLAGS] in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002147def IMUL16rri : Ii16<0x69, MRMSrcReg, // GR16 = GR16*I16
Evan Chengb783fa32007-07-19 01:14:50 +00002148 (outs GR16:$dst), (ins GR16:$src1, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002149 "imul{w}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002150 [(set GR16:$dst, (mul GR16:$src1, imm:$src2))]>, OpSize;
2151def IMUL32rri : Ii32<0x69, MRMSrcReg, // GR32 = GR32*I32
Evan Chengb783fa32007-07-19 01:14:50 +00002152 (outs GR32:$dst), (ins GR32:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002153 "imul{l}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002154 [(set GR32:$dst, (mul GR32:$src1, imm:$src2))]>;
2155def IMUL16rri8 : Ii8<0x6B, MRMSrcReg, // GR16 = GR16*I8
Evan Chengb783fa32007-07-19 01:14:50 +00002156 (outs GR16:$dst), (ins GR16:$src1, i16i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002157 "imul{w}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002158 [(set GR16:$dst, (mul GR16:$src1, i16immSExt8:$src2))]>,
2159 OpSize;
2160def IMUL32rri8 : Ii8<0x6B, MRMSrcReg, // GR32 = GR32*I8
Evan Chengb783fa32007-07-19 01:14:50 +00002161 (outs GR32:$dst), (ins GR32:$src1, i32i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002162 "imul{l}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002163 [(set GR32:$dst, (mul GR32:$src1, i32immSExt8:$src2))]>;
2164
2165def IMUL16rmi : Ii16<0x69, MRMSrcMem, // GR16 = [mem16]*I16
Evan Chengb783fa32007-07-19 01:14:50 +00002166 (outs GR16:$dst), (ins i16mem:$src1, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002167 "imul{w}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002168 [(set GR16:$dst, (mul (load addr:$src1), imm:$src2))]>,
2169 OpSize;
2170def IMUL32rmi : Ii32<0x69, MRMSrcMem, // GR32 = [mem32]*I32
Evan Chengb783fa32007-07-19 01:14:50 +00002171 (outs GR32:$dst), (ins i32mem:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002172 "imul{l}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002173 [(set GR32:$dst, (mul (load addr:$src1), imm:$src2))]>;
2174def IMUL16rmi8 : Ii8<0x6B, MRMSrcMem, // GR16 = [mem16]*I8
Evan Chengb783fa32007-07-19 01:14:50 +00002175 (outs GR16:$dst), (ins i16mem:$src1, i16i8imm :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002176 "imul{w}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002177 [(set GR16:$dst, (mul (load addr:$src1), i16immSExt8:$src2))]>,
2178 OpSize;
2179def IMUL32rmi8 : Ii8<0x6B, MRMSrcMem, // GR32 = [mem32]*I8
Evan Chengb783fa32007-07-19 01:14:50 +00002180 (outs GR32:$dst), (ins i32mem:$src1, i32i8imm: $src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002181 "imul{l}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002182 [(set GR32:$dst, (mul (load addr:$src1), i32immSExt8:$src2))]>;
Evan Cheng55687072007-09-14 21:48:26 +00002183} // Defs = [EFLAGS]
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002184
2185//===----------------------------------------------------------------------===//
2186// Test instructions are just like AND, except they don't generate a result.
2187//
Evan Cheng950aac02007-09-25 01:57:46 +00002188let Defs = [EFLAGS] in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002189let isCommutable = 1 in { // TEST X, Y --> TEST Y, X
Evan Chengb783fa32007-07-19 01:14:50 +00002190def TEST8rr : I<0x84, MRMDestReg, (outs), (ins GR8:$src1, GR8:$src2),
Evan Cheng621216e2007-09-29 00:00:36 +00002191 "test{b}\t{$src2, $src1|$src1, $src2}",
Chris Lattner21da6382008-02-19 17:37:35 +00002192 [(X86cmp (and_su GR8:$src1, GR8:$src2), 0),
Evan Cheng621216e2007-09-29 00:00:36 +00002193 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002194def TEST16rr : I<0x85, MRMDestReg, (outs), (ins GR16:$src1, GR16:$src2),
Evan Cheng621216e2007-09-29 00:00:36 +00002195 "test{w}\t{$src2, $src1|$src1, $src2}",
Chris Lattner21da6382008-02-19 17:37:35 +00002196 [(X86cmp (and_su GR16:$src1, GR16:$src2), 0),
Evan Cheng621216e2007-09-29 00:00:36 +00002197 (implicit EFLAGS)]>,
2198 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002199def TEST32rr : I<0x85, MRMDestReg, (outs), (ins GR32:$src1, GR32:$src2),
Evan Cheng621216e2007-09-29 00:00:36 +00002200 "test{l}\t{$src2, $src1|$src1, $src2}",
Chris Lattner21da6382008-02-19 17:37:35 +00002201 [(X86cmp (and_su GR32:$src1, GR32:$src2), 0),
Evan Cheng621216e2007-09-29 00:00:36 +00002202 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002203}
2204
Evan Chengb783fa32007-07-19 01:14:50 +00002205def TEST8rm : I<0x84, MRMSrcMem, (outs), (ins GR8 :$src1, i8mem :$src2),
Evan Cheng621216e2007-09-29 00:00:36 +00002206 "test{b}\t{$src2, $src1|$src1, $src2}",
2207 [(X86cmp (and GR8:$src1, (loadi8 addr:$src2)), 0),
2208 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002209def TEST16rm : I<0x85, MRMSrcMem, (outs), (ins GR16:$src1, i16mem:$src2),
Evan Cheng621216e2007-09-29 00:00:36 +00002210 "test{w}\t{$src2, $src1|$src1, $src2}",
2211 [(X86cmp (and GR16:$src1, (loadi16 addr:$src2)), 0),
2212 (implicit EFLAGS)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002213def TEST32rm : I<0x85, MRMSrcMem, (outs), (ins GR32:$src1, i32mem:$src2),
Evan Cheng621216e2007-09-29 00:00:36 +00002214 "test{l}\t{$src2, $src1|$src1, $src2}",
2215 [(X86cmp (and GR32:$src1, (loadi32 addr:$src2)), 0),
2216 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002217
2218def TEST8ri : Ii8 <0xF6, MRM0r, // flags = GR8 & imm8
Evan Chengb783fa32007-07-19 01:14:50 +00002219 (outs), (ins GR8:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002220 "test{b}\t{$src2, $src1|$src1, $src2}",
Chris Lattner21da6382008-02-19 17:37:35 +00002221 [(X86cmp (and_su GR8:$src1, imm:$src2), 0),
Evan Cheng621216e2007-09-29 00:00:36 +00002222 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002223def TEST16ri : Ii16<0xF7, MRM0r, // flags = GR16 & imm16
Evan Chengb783fa32007-07-19 01:14:50 +00002224 (outs), (ins GR16:$src1, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002225 "test{w}\t{$src2, $src1|$src1, $src2}",
Chris Lattner21da6382008-02-19 17:37:35 +00002226 [(X86cmp (and_su GR16:$src1, imm:$src2), 0),
Evan Cheng621216e2007-09-29 00:00:36 +00002227 (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002228def TEST32ri : Ii32<0xF7, MRM0r, // flags = GR32 & imm32
Evan Chengb783fa32007-07-19 01:14:50 +00002229 (outs), (ins GR32:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002230 "test{l}\t{$src2, $src1|$src1, $src2}",
Chris Lattner21da6382008-02-19 17:37:35 +00002231 [(X86cmp (and_su GR32:$src1, imm:$src2), 0),
Evan Cheng621216e2007-09-29 00:00:36 +00002232 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002233
Evan Cheng621216e2007-09-29 00:00:36 +00002234def TEST8mi : Ii8 <0xF6, MRM0m, // flags = [mem8] & imm8
Evan Chengb783fa32007-07-19 01:14:50 +00002235 (outs), (ins i8mem:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002236 "test{b}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002237 [(X86cmp (and (loadi8 addr:$src1), imm:$src2), 0),
2238 (implicit EFLAGS)]>;
2239def TEST16mi : Ii16<0xF7, MRM0m, // flags = [mem16] & imm16
Evan Chengb783fa32007-07-19 01:14:50 +00002240 (outs), (ins i16mem:$src1, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002241 "test{w}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002242 [(X86cmp (and (loadi16 addr:$src1), imm:$src2), 0),
2243 (implicit EFLAGS)]>, OpSize;
2244def TEST32mi : Ii32<0xF7, MRM0m, // flags = [mem32] & imm32
Evan Chengb783fa32007-07-19 01:14:50 +00002245 (outs), (ins i32mem:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002246 "test{l}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002247 [(X86cmp (and (loadi32 addr:$src1), imm:$src2), 0),
Evan Cheng950aac02007-09-25 01:57:46 +00002248 (implicit EFLAGS)]>;
2249} // Defs = [EFLAGS]
2250
2251
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002252// Condition code ops, incl. set if equal/not equal/...
Chris Lattnerc90ee9c2008-01-10 07:59:24 +00002253let Defs = [EFLAGS], Uses = [AH], neverHasSideEffects = 1 in
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002254def SAHF : I<0x9E, RawFrm, (outs), (ins), "sahf", []>; // flags = AH
Chris Lattnerc90ee9c2008-01-10 07:59:24 +00002255let Defs = [AH], Uses = [EFLAGS], neverHasSideEffects = 1 in
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002256def LAHF : I<0x9F, RawFrm, (outs), (ins), "lahf", []>; // AH = flags
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002257
Evan Cheng950aac02007-09-25 01:57:46 +00002258let Uses = [EFLAGS] in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002259def SETEr : I<0x94, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00002260 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002261 "sete\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002262 [(set GR8:$dst, (X86setcc X86_COND_E, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002263 TB; // GR8 = ==
2264def SETEm : I<0x94, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00002265 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002266 "sete\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002267 [(store (X86setcc X86_COND_E, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002268 TB; // [mem8] = ==
2269def SETNEr : I<0x95, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00002270 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002271 "setne\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002272 [(set GR8:$dst, (X86setcc X86_COND_NE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002273 TB; // GR8 = !=
2274def SETNEm : I<0x95, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00002275 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002276 "setne\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002277 [(store (X86setcc X86_COND_NE, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002278 TB; // [mem8] = !=
2279def SETLr : I<0x9C, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00002280 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002281 "setl\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002282 [(set GR8:$dst, (X86setcc X86_COND_L, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002283 TB; // GR8 = < signed
2284def SETLm : I<0x9C, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00002285 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002286 "setl\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002287 [(store (X86setcc X86_COND_L, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002288 TB; // [mem8] = < signed
2289def SETGEr : I<0x9D, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00002290 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002291 "setge\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002292 [(set GR8:$dst, (X86setcc X86_COND_GE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002293 TB; // GR8 = >= signed
2294def SETGEm : I<0x9D, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00002295 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002296 "setge\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002297 [(store (X86setcc X86_COND_GE, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002298 TB; // [mem8] = >= signed
2299def SETLEr : I<0x9E, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00002300 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002301 "setle\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002302 [(set GR8:$dst, (X86setcc X86_COND_LE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002303 TB; // GR8 = <= signed
2304def SETLEm : I<0x9E, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00002305 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002306 "setle\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002307 [(store (X86setcc X86_COND_LE, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002308 TB; // [mem8] = <= signed
2309def SETGr : I<0x9F, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00002310 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002311 "setg\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002312 [(set GR8:$dst, (X86setcc X86_COND_G, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002313 TB; // GR8 = > signed
2314def SETGm : I<0x9F, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00002315 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002316 "setg\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002317 [(store (X86setcc X86_COND_G, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002318 TB; // [mem8] = > signed
2319
2320def SETBr : I<0x92, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00002321 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002322 "setb\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002323 [(set GR8:$dst, (X86setcc X86_COND_B, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002324 TB; // GR8 = < unsign
2325def SETBm : I<0x92, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00002326 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002327 "setb\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002328 [(store (X86setcc X86_COND_B, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002329 TB; // [mem8] = < unsign
2330def SETAEr : I<0x93, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00002331 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002332 "setae\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002333 [(set GR8:$dst, (X86setcc X86_COND_AE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002334 TB; // GR8 = >= unsign
2335def SETAEm : I<0x93, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00002336 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002337 "setae\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002338 [(store (X86setcc X86_COND_AE, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002339 TB; // [mem8] = >= unsign
2340def SETBEr : I<0x96, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00002341 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002342 "setbe\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002343 [(set GR8:$dst, (X86setcc X86_COND_BE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002344 TB; // GR8 = <= unsign
2345def SETBEm : I<0x96, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00002346 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002347 "setbe\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002348 [(store (X86setcc X86_COND_BE, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002349 TB; // [mem8] = <= unsign
2350def SETAr : I<0x97, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00002351 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002352 "seta\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002353 [(set GR8:$dst, (X86setcc X86_COND_A, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002354 TB; // GR8 = > signed
2355def SETAm : I<0x97, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00002356 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002357 "seta\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002358 [(store (X86setcc X86_COND_A, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002359 TB; // [mem8] = > signed
2360
2361def SETSr : I<0x98, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00002362 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002363 "sets\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002364 [(set GR8:$dst, (X86setcc X86_COND_S, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002365 TB; // GR8 = <sign bit>
2366def SETSm : I<0x98, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00002367 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002368 "sets\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002369 [(store (X86setcc X86_COND_S, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002370 TB; // [mem8] = <sign bit>
2371def SETNSr : I<0x99, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00002372 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002373 "setns\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002374 [(set GR8:$dst, (X86setcc X86_COND_NS, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002375 TB; // GR8 = !<sign bit>
2376def SETNSm : I<0x99, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00002377 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002378 "setns\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002379 [(store (X86setcc X86_COND_NS, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002380 TB; // [mem8] = !<sign bit>
2381def SETPr : I<0x9A, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00002382 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002383 "setp\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002384 [(set GR8:$dst, (X86setcc X86_COND_P, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002385 TB; // GR8 = parity
2386def SETPm : I<0x9A, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00002387 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002388 "setp\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002389 [(store (X86setcc X86_COND_P, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002390 TB; // [mem8] = parity
2391def SETNPr : I<0x9B, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00002392 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002393 "setnp\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002394 [(set GR8:$dst, (X86setcc X86_COND_NP, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002395 TB; // GR8 = not parity
2396def SETNPm : I<0x9B, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00002397 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002398 "setnp\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002399 [(store (X86setcc X86_COND_NP, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002400 TB; // [mem8] = not parity
Evan Cheng950aac02007-09-25 01:57:46 +00002401} // Uses = [EFLAGS]
2402
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002403
2404// Integer comparisons
Evan Cheng55687072007-09-14 21:48:26 +00002405let Defs = [EFLAGS] in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002406def CMP8rr : I<0x38, MRMDestReg,
Evan Chengb783fa32007-07-19 01:14:50 +00002407 (outs), (ins GR8 :$src1, GR8 :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002408 "cmp{b}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002409 [(X86cmp GR8:$src1, GR8:$src2), (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002410def CMP16rr : I<0x39, MRMDestReg,
Evan Chengb783fa32007-07-19 01:14:50 +00002411 (outs), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002412 "cmp{w}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002413 [(X86cmp GR16:$src1, GR16:$src2), (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002414def CMP32rr : I<0x39, MRMDestReg,
Evan Chengb783fa32007-07-19 01:14:50 +00002415 (outs), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002416 "cmp{l}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002417 [(X86cmp GR32:$src1, GR32:$src2), (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002418def CMP8mr : I<0x38, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00002419 (outs), (ins i8mem :$src1, GR8 :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002420 "cmp{b}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002421 [(X86cmp (loadi8 addr:$src1), GR8:$src2),
2422 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002423def CMP16mr : I<0x39, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00002424 (outs), (ins i16mem:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002425 "cmp{w}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002426 [(X86cmp (loadi16 addr:$src1), GR16:$src2),
2427 (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002428def CMP32mr : I<0x39, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00002429 (outs), (ins i32mem:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002430 "cmp{l}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002431 [(X86cmp (loadi32 addr:$src1), GR32:$src2),
2432 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002433def CMP8rm : I<0x3A, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00002434 (outs), (ins GR8 :$src1, i8mem :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002435 "cmp{b}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002436 [(X86cmp GR8:$src1, (loadi8 addr:$src2)),
2437 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002438def CMP16rm : I<0x3B, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00002439 (outs), (ins GR16:$src1, i16mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002440 "cmp{w}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002441 [(X86cmp GR16:$src1, (loadi16 addr:$src2)),
2442 (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002443def CMP32rm : I<0x3B, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00002444 (outs), (ins GR32:$src1, i32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002445 "cmp{l}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002446 [(X86cmp GR32:$src1, (loadi32 addr:$src2)),
2447 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002448def CMP8ri : Ii8<0x80, MRM7r,
Evan Chengb783fa32007-07-19 01:14:50 +00002449 (outs), (ins GR8:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002450 "cmp{b}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002451 [(X86cmp GR8:$src1, imm:$src2), (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002452def CMP16ri : Ii16<0x81, MRM7r,
Evan Chengb783fa32007-07-19 01:14:50 +00002453 (outs), (ins GR16:$src1, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002454 "cmp{w}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002455 [(X86cmp GR16:$src1, imm:$src2),
2456 (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002457def CMP32ri : Ii32<0x81, MRM7r,
Evan Chengb783fa32007-07-19 01:14:50 +00002458 (outs), (ins GR32:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002459 "cmp{l}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002460 [(X86cmp GR32:$src1, imm:$src2), (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002461def CMP8mi : Ii8 <0x80, MRM7m,
Evan Chengb783fa32007-07-19 01:14:50 +00002462 (outs), (ins i8mem :$src1, i8imm :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002463 "cmp{b}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002464 [(X86cmp (loadi8 addr:$src1), imm:$src2),
2465 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002466def CMP16mi : Ii16<0x81, MRM7m,
Evan Chengb783fa32007-07-19 01:14:50 +00002467 (outs), (ins i16mem:$src1, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002468 "cmp{w}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002469 [(X86cmp (loadi16 addr:$src1), imm:$src2),
2470 (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002471def CMP32mi : Ii32<0x81, MRM7m,
Evan Chengb783fa32007-07-19 01:14:50 +00002472 (outs), (ins i32mem:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002473 "cmp{l}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002474 [(X86cmp (loadi32 addr:$src1), imm:$src2),
2475 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002476def CMP16ri8 : Ii8<0x83, MRM7r,
Evan Chengb783fa32007-07-19 01:14:50 +00002477 (outs), (ins GR16:$src1, i16i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002478 "cmp{w}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002479 [(X86cmp GR16:$src1, i16immSExt8:$src2),
2480 (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002481def CMP16mi8 : Ii8<0x83, MRM7m,
Evan Chengb783fa32007-07-19 01:14:50 +00002482 (outs), (ins i16mem:$src1, i16i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002483 "cmp{w}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002484 [(X86cmp (loadi16 addr:$src1), i16immSExt8:$src2),
2485 (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002486def CMP32mi8 : Ii8<0x83, MRM7m,
Evan Chengb783fa32007-07-19 01:14:50 +00002487 (outs), (ins i32mem:$src1, i32i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002488 "cmp{l}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002489 [(X86cmp (loadi32 addr:$src1), i32immSExt8:$src2),
2490 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002491def CMP32ri8 : Ii8<0x83, MRM7r,
Evan Chengb783fa32007-07-19 01:14:50 +00002492 (outs), (ins GR32:$src1, i32i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002493 "cmp{l}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002494 [(X86cmp GR32:$src1, i32immSExt8:$src2),
Evan Cheng950aac02007-09-25 01:57:46 +00002495 (implicit EFLAGS)]>;
2496} // Defs = [EFLAGS]
2497
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002498// Sign/Zero extenders
Dan Gohman9203ab42008-07-30 18:09:17 +00002499// Use movsbl intead of movsbw; we don't care about the high 16 bits
2500// of the register here. This has a smaller encoding and avoids a
2501// partial-register update.
Evan Chengb783fa32007-07-19 01:14:50 +00002502def MOVSX16rr8 : I<0xBE, MRMSrcReg, (outs GR16:$dst), (ins GR8 :$src),
Dan Gohman9203ab42008-07-30 18:09:17 +00002503 "movs{bl|x}\t{$src, ${dst:subreg32}|${dst:subreg32}, $src}",
2504 [(set GR16:$dst, (sext GR8:$src))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00002505def MOVSX16rm8 : I<0xBE, MRMSrcMem, (outs GR16:$dst), (ins i8mem :$src),
Dan Gohman9203ab42008-07-30 18:09:17 +00002506 "movs{bl|x}\t{$src, ${dst:subreg32}|${dst:subreg32}, $src}",
2507 [(set GR16:$dst, (sextloadi16i8 addr:$src))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00002508def MOVSX32rr8 : I<0xBE, MRMSrcReg, (outs GR32:$dst), (ins GR8 :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002509 "movs{bl|x}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002510 [(set GR32:$dst, (sext GR8:$src))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00002511def MOVSX32rm8 : I<0xBE, MRMSrcMem, (outs GR32:$dst), (ins i8mem :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002512 "movs{bl|x}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002513 [(set GR32:$dst, (sextloadi32i8 addr:$src))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00002514def MOVSX32rr16: I<0xBF, MRMSrcReg, (outs GR32:$dst), (ins GR16:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002515 "movs{wl|x}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002516 [(set GR32:$dst, (sext GR16:$src))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00002517def MOVSX32rm16: I<0xBF, MRMSrcMem, (outs GR32:$dst), (ins i16mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002518 "movs{wl|x}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002519 [(set GR32:$dst, (sextloadi32i16 addr:$src))]>, TB;
2520
Dan Gohman9203ab42008-07-30 18:09:17 +00002521// Use movzbl intead of movzbw; we don't care about the high 16 bits
2522// of the register here. This has a smaller encoding and avoids a
2523// partial-register update.
Evan Chengb783fa32007-07-19 01:14:50 +00002524def MOVZX16rr8 : I<0xB6, MRMSrcReg, (outs GR16:$dst), (ins GR8 :$src),
Dan Gohman9203ab42008-07-30 18:09:17 +00002525 "movz{bl|x}\t{$src, ${dst:subreg32}|${dst:subreg32}, $src}",
2526 [(set GR16:$dst, (zext GR8:$src))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00002527def MOVZX16rm8 : I<0xB6, MRMSrcMem, (outs GR16:$dst), (ins i8mem :$src),
Dan Gohman9203ab42008-07-30 18:09:17 +00002528 "movz{bl|x}\t{$src, ${dst:subreg32}|${dst:subreg32}, $src}",
2529 [(set GR16:$dst, (zextloadi16i8 addr:$src))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00002530def MOVZX32rr8 : I<0xB6, MRMSrcReg, (outs GR32:$dst), (ins GR8 :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002531 "movz{bl|x}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002532 [(set GR32:$dst, (zext GR8:$src))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00002533def MOVZX32rm8 : I<0xB6, MRMSrcMem, (outs GR32:$dst), (ins i8mem :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002534 "movz{bl|x}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002535 [(set GR32:$dst, (zextloadi32i8 addr:$src))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00002536def MOVZX32rr16: I<0xB7, MRMSrcReg, (outs GR32:$dst), (ins GR16:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002537 "movz{wl|x}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002538 [(set GR32:$dst, (zext GR16:$src))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00002539def MOVZX32rm16: I<0xB7, MRMSrcMem, (outs GR32:$dst), (ins i16mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002540 "movz{wl|x}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002541 [(set GR32:$dst, (zextloadi32i16 addr:$src))]>, TB;
2542
Chris Lattnerc90ee9c2008-01-10 07:59:24 +00002543let neverHasSideEffects = 1 in {
2544 let Defs = [AX], Uses = [AL] in
2545 def CBW : I<0x98, RawFrm, (outs), (ins),
2546 "{cbtw|cbw}", []>, OpSize; // AX = signext(AL)
2547 let Defs = [EAX], Uses = [AX] in
2548 def CWDE : I<0x98, RawFrm, (outs), (ins),
2549 "{cwtl|cwde}", []>; // EAX = signext(AX)
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002550
Chris Lattnerc90ee9c2008-01-10 07:59:24 +00002551 let Defs = [AX,DX], Uses = [AX] in
2552 def CWD : I<0x99, RawFrm, (outs), (ins),
2553 "{cwtd|cwd}", []>, OpSize; // DX:AX = signext(AX)
2554 let Defs = [EAX,EDX], Uses = [EAX] in
2555 def CDQ : I<0x99, RawFrm, (outs), (ins),
2556 "{cltd|cdq}", []>; // EDX:EAX = signext(EAX)
2557}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002558
2559//===----------------------------------------------------------------------===//
2560// Alias Instructions
2561//===----------------------------------------------------------------------===//
2562
2563// Alias instructions that map movr0 to xor.
2564// FIXME: remove when we can teach regalloc that xor reg, reg is ok.
Bill Wendlingba5d5b02008-05-29 01:02:09 +00002565let Defs = [EFLAGS], isReMaterializable = 1, isAsCheapAsAMove = 1 in {
Evan Chengb783fa32007-07-19 01:14:50 +00002566def MOV8r0 : I<0x30, MRMInitReg, (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002567 "xor{b}\t$dst, $dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002568 [(set GR8:$dst, 0)]>;
Dan Gohman9203ab42008-07-30 18:09:17 +00002569// Use xorl instead of xorw since we don't care about the high 16 bits,
2570// it's smaller, and it avoids a partial-register update.
Evan Chengb783fa32007-07-19 01:14:50 +00002571def MOV16r0 : I<0x31, MRMInitReg, (outs GR16:$dst), (ins),
Dan Gohman9203ab42008-07-30 18:09:17 +00002572 "xor{l}\t${dst:subreg32}, ${dst:subreg32}",
2573 [(set GR16:$dst, 0)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002574def MOV32r0 : I<0x31, MRMInitReg, (outs GR32:$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002575 "xor{l}\t$dst, $dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002576 [(set GR32:$dst, 0)]>;
Dan Gohman8aef09b2007-09-07 21:32:51 +00002577}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002578
2579// Basic operations on GR16 / GR32 subclasses GR16_ and GR32_ which contains only
2580// those registers that have GR8 sub-registers (i.e. AX - DX, EAX - EDX).
Chris Lattnerc90ee9c2008-01-10 07:59:24 +00002581let neverHasSideEffects = 1 in {
Evan Chengb783fa32007-07-19 01:14:50 +00002582def MOV16to16_ : I<0x89, MRMDestReg, (outs GR16_:$dst), (ins GR16:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002583 "mov{w}\t{$src, $dst|$dst, $src}", []>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002584def MOV32to32_ : I<0x89, MRMDestReg, (outs GR32_:$dst), (ins GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002585 "mov{l}\t{$src, $dst|$dst, $src}", []>;
Chris Lattnerc90ee9c2008-01-10 07:59:24 +00002586
Evan Chengb783fa32007-07-19 01:14:50 +00002587def MOV16_rr : I<0x89, MRMDestReg, (outs GR16_:$dst), (ins GR16_:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002588 "mov{w}\t{$src, $dst|$dst, $src}", []>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002589def MOV32_rr : I<0x89, MRMDestReg, (outs GR32_:$dst), (ins GR32_:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002590 "mov{l}\t{$src, $dst|$dst, $src}", []>;
Chris Lattnerc90ee9c2008-01-10 07:59:24 +00002591} // neverHasSideEffects
2592
2593let isSimpleLoad = 1, mayLoad = 1, isReMaterializable = 1, mayHaveSideEffects = 1 in {
Evan Chengb783fa32007-07-19 01:14:50 +00002594def MOV16_rm : I<0x8B, MRMSrcMem, (outs GR16_:$dst), (ins i16mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002595 "mov{w}\t{$src, $dst|$dst, $src}", []>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002596def MOV32_rm : I<0x8B, MRMSrcMem, (outs GR32_:$dst), (ins i32mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002597 "mov{l}\t{$src, $dst|$dst, $src}", []>;
Evan Cheng4e84e452007-08-30 05:49:43 +00002598}
Chris Lattnerc90ee9c2008-01-10 07:59:24 +00002599let mayStore = 1, neverHasSideEffects = 1 in {
Evan Chengb783fa32007-07-19 01:14:50 +00002600def MOV16_mr : I<0x89, MRMDestMem, (outs), (ins i16mem:$dst, GR16_:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002601 "mov{w}\t{$src, $dst|$dst, $src}", []>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002602def MOV32_mr : I<0x89, MRMDestMem, (outs), (ins i32mem:$dst, GR32_:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002603 "mov{l}\t{$src, $dst|$dst, $src}", []>;
Chris Lattnerc90ee9c2008-01-10 07:59:24 +00002604}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002605
2606//===----------------------------------------------------------------------===//
2607// Thread Local Storage Instructions
2608//
2609
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002610let Uses = [EBX] in
Anton Korobeynikov4fbf00b2008-05-04 21:36:32 +00002611def TLS_addr32 : I<0, Pseudo, (outs GR32:$dst), (ins i32imm:$sym),
2612 "leal\t${sym:mem}(,%ebx,1), $dst",
2613 [(set GR32:$dst, (X86tlsaddr tglobaltlsaddr:$sym))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002614
2615let AddedComplexity = 10 in
Anton Korobeynikov4fbf00b2008-05-04 21:36:32 +00002616def TLS_gs_rr : I<0, Pseudo, (outs GR32:$dst), (ins GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002617 "movl\t%gs:($src), $dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002618 [(set GR32:$dst, (load (add X86TLStp, GR32:$src)))]>;
2619
2620let AddedComplexity = 15 in
Evan Chengb783fa32007-07-19 01:14:50 +00002621def TLS_gs_ri : I<0, Pseudo, (outs GR32:$dst), (ins i32imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002622 "movl\t%gs:${src:mem}, $dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002623 [(set GR32:$dst,
2624 (load (add X86TLStp, (X86Wrapper tglobaltlsaddr:$src))))]>;
2625
Evan Chengb783fa32007-07-19 01:14:50 +00002626def TLS_tp : I<0, Pseudo, (outs GR32:$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002627 "movl\t%gs:0, $dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002628 [(set GR32:$dst, X86TLStp)]>;
2629
2630//===----------------------------------------------------------------------===//
2631// DWARF Pseudo Instructions
2632//
2633
Evan Chengb783fa32007-07-19 01:14:50 +00002634def DWARF_LOC : I<0, Pseudo, (outs),
2635 (ins i32imm:$line, i32imm:$col, i32imm:$file),
Dan Gohman77af4a82007-09-24 19:25:06 +00002636 ".loc\t${file:debug} ${line:debug} ${col:debug}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002637 [(dwarf_loc (i32 imm:$line), (i32 imm:$col),
2638 (i32 imm:$file))]>;
2639
2640//===----------------------------------------------------------------------===//
2641// EH Pseudo Instructions
2642//
2643let isTerminator = 1, isReturn = 1, isBarrier = 1,
Evan Cheng37e7c752007-07-21 00:34:19 +00002644 hasCtrlDep = 1 in {
Evan Chengb783fa32007-07-19 01:14:50 +00002645def EH_RETURN : I<0xC3, RawFrm, (outs), (ins GR32:$addr),
Dan Gohman91888f02007-07-31 20:11:57 +00002646 "ret\t#eh_return, addr: $addr",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002647 [(X86ehret GR32:$addr)]>;
2648
2649}
2650
2651//===----------------------------------------------------------------------===//
Andrew Lenharthe44f3902008-02-21 06:45:13 +00002652// Atomic support
2653//
Andrew Lenharth7a5a4b22008-03-01 13:37:02 +00002654
Evan Cheng3e171562008-04-19 01:20:30 +00002655// Atomic swap. These are just normal xchg instructions. But since a memory
2656// operand is referenced, the atomicity is ensured.
Dan Gohmana41a1c092008-08-06 15:52:50 +00002657let Constraints = "$val = $dst" in {
Evan Cheng3e171562008-04-19 01:20:30 +00002658def XCHG32rm : I<0x87, MRMSrcMem, (outs GR32:$dst), (ins i32mem:$ptr, GR32:$val),
2659 "xchg{l}\t{$val, $ptr|$ptr, $val}",
2660 [(set GR32:$dst, (atomic_swap_32 addr:$ptr, GR32:$val))]>;
2661def XCHG16rm : I<0x87, MRMSrcMem, (outs GR16:$dst), (ins i16mem:$ptr, GR16:$val),
2662 "xchg{w}\t{$val, $ptr|$ptr, $val}",
2663 [(set GR16:$dst, (atomic_swap_16 addr:$ptr, GR16:$val))]>,
2664 OpSize;
2665def XCHG8rm : I<0x86, MRMSrcMem, (outs GR8:$dst), (ins i8mem:$ptr, GR8:$val),
2666 "xchg{b}\t{$val, $ptr|$ptr, $val}",
2667 [(set GR8:$dst, (atomic_swap_8 addr:$ptr, GR8:$val))]>;
2668}
2669
Evan Chengd49dbb82008-04-18 20:55:36 +00002670// Atomic compare and swap.
Andrew Lenharth7dfe23f2008-03-01 21:52:34 +00002671let Defs = [EAX, EFLAGS], Uses = [EAX] in {
Evan Chengd49dbb82008-04-18 20:55:36 +00002672def LCMPXCHG32 : I<0xB1, MRMDestMem, (outs), (ins i32mem:$ptr, GR32:$swap),
Dale Johannesend20e4452008-08-19 18:47:28 +00002673 "lock\n\tcmpxchg{l}\t{$swap, $ptr|$ptr, $swap}",
Evan Cheng09fbdee2008-03-04 03:20:06 +00002674 [(X86cas addr:$ptr, GR32:$swap, 4)]>, TB, LOCK;
Andrew Lenharth7a5a4b22008-03-01 13:37:02 +00002675}
Dale Johannesenf160d802008-10-02 18:53:47 +00002676let Defs = [EAX, EDX, EFLAGS], Uses = [EAX, EBX, ECX, EDX] in {
Anton Korobeynikovc4067392008-07-22 16:22:48 +00002677def LCMPXCHG8B : I<0xC7, MRM1m, (outs), (ins i32mem:$ptr),
Dale Johannesend20e4452008-08-19 18:47:28 +00002678 "lock\n\tcmpxchg8b\t$ptr",
Andrew Lenharth81580822008-03-05 01:15:49 +00002679 [(X86cas8 addr:$ptr)]>, TB, LOCK;
2680}
Andrew Lenharth7dfe23f2008-03-01 21:52:34 +00002681
2682let Defs = [AX, EFLAGS], Uses = [AX] in {
Evan Chengd49dbb82008-04-18 20:55:36 +00002683def LCMPXCHG16 : I<0xB1, MRMDestMem, (outs), (ins i16mem:$ptr, GR16:$swap),
Dale Johannesend20e4452008-08-19 18:47:28 +00002684 "lock\n\tcmpxchg{w}\t{$swap, $ptr|$ptr, $swap}",
Evan Cheng09fbdee2008-03-04 03:20:06 +00002685 [(X86cas addr:$ptr, GR16:$swap, 2)]>, TB, OpSize, LOCK;
Andrew Lenharth7a5a4b22008-03-01 13:37:02 +00002686}
Andrew Lenharth7dfe23f2008-03-01 21:52:34 +00002687let Defs = [AL, EFLAGS], Uses = [AL] in {
Evan Chengd49dbb82008-04-18 20:55:36 +00002688def LCMPXCHG8 : I<0xB0, MRMDestMem, (outs), (ins i8mem:$ptr, GR8:$swap),
Dale Johannesend20e4452008-08-19 18:47:28 +00002689 "lock\n\tcmpxchg{b}\t{$swap, $ptr|$ptr, $swap}",
Evan Cheng09fbdee2008-03-04 03:20:06 +00002690 [(X86cas addr:$ptr, GR8:$swap, 1)]>, TB, LOCK;
Andrew Lenharth7a5a4b22008-03-01 13:37:02 +00002691}
2692
Evan Chengd49dbb82008-04-18 20:55:36 +00002693// Atomic exchange and add
2694let Constraints = "$val = $dst", Defs = [EFLAGS] in {
2695def LXADD32 : I<0xC1, MRMSrcMem, (outs GR32:$dst), (ins i32mem:$ptr, GR32:$val),
Dale Johannesend20e4452008-08-19 18:47:28 +00002696 "lock\n\txadd{l}\t{$val, $ptr|$ptr, $val}",
Mon P Wang6bde9ec2008-06-25 08:15:39 +00002697 [(set GR32:$dst, (atomic_load_add_32 addr:$ptr, GR32:$val))]>,
Evan Chengd49dbb82008-04-18 20:55:36 +00002698 TB, LOCK;
2699def LXADD16 : I<0xC1, MRMSrcMem, (outs GR16:$dst), (ins i16mem:$ptr, GR16:$val),
Dale Johannesend20e4452008-08-19 18:47:28 +00002700 "lock\n\txadd{w}\t{$val, $ptr|$ptr, $val}",
Mon P Wang6bde9ec2008-06-25 08:15:39 +00002701 [(set GR16:$dst, (atomic_load_add_16 addr:$ptr, GR16:$val))]>,
Evan Chengd49dbb82008-04-18 20:55:36 +00002702 TB, OpSize, LOCK;
2703def LXADD8 : I<0xC0, MRMSrcMem, (outs GR8:$dst), (ins i8mem:$ptr, GR8:$val),
Dale Johannesend20e4452008-08-19 18:47:28 +00002704 "lock\n\txadd{b}\t{$val, $ptr|$ptr, $val}",
Mon P Wang6bde9ec2008-06-25 08:15:39 +00002705 [(set GR8:$dst, (atomic_load_add_8 addr:$ptr, GR8:$val))]>,
Evan Chengd49dbb82008-04-18 20:55:36 +00002706 TB, LOCK;
Andrew Lenharth7a5a4b22008-03-01 13:37:02 +00002707}
2708
Mon P Wang6bde9ec2008-06-25 08:15:39 +00002709// Atomic exchange, and, or, xor
Mon P Wang078a62d2008-05-05 19:05:59 +00002710let Constraints = "$val = $dst", Defs = [EFLAGS],
2711 usesCustomDAGSchedInserter = 1 in {
Dan Gohman8aeb61f2008-05-12 20:22:45 +00002712def ATOMAND32 : I<0, Pseudo, (outs GR32:$dst),(ins i32mem:$ptr, GR32:$val),
Mon P Wang078a62d2008-05-05 19:05:59 +00002713 "#ATOMAND32 PSUEDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00002714 [(set GR32:$dst, (atomic_load_and_32 addr:$ptr, GR32:$val))]>;
Dan Gohman8aeb61f2008-05-12 20:22:45 +00002715def ATOMOR32 : I<0, Pseudo, (outs GR32:$dst),(ins i32mem:$ptr, GR32:$val),
Mon P Wang078a62d2008-05-05 19:05:59 +00002716 "#ATOMOR32 PSUEDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00002717 [(set GR32:$dst, (atomic_load_or_32 addr:$ptr, GR32:$val))]>;
Dan Gohman8aeb61f2008-05-12 20:22:45 +00002718def ATOMXOR32 : I<0, Pseudo,(outs GR32:$dst),(ins i32mem:$ptr, GR32:$val),
Mon P Wang078a62d2008-05-05 19:05:59 +00002719 "#ATOMXOR32 PSUEDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00002720 [(set GR32:$dst, (atomic_load_xor_32 addr:$ptr, GR32:$val))]>;
Andrew Lenharthaf02d592008-06-14 05:48:15 +00002721def ATOMNAND32 : I<0, Pseudo,(outs GR32:$dst),(ins i32mem:$ptr, GR32:$val),
Mon P Wang6bde9ec2008-06-25 08:15:39 +00002722 "#ATOMNAND32 PSUEDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00002723 [(set GR32:$dst, (atomic_load_nand_32 addr:$ptr, GR32:$val))]>;
Dan Gohman8aeb61f2008-05-12 20:22:45 +00002724def ATOMMIN32: I<0, Pseudo, (outs GR32:$dst), (ins i32mem:$ptr, GR32:$val),
Mon P Wang078a62d2008-05-05 19:05:59 +00002725 "#ATOMMIN32 PSUEDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00002726 [(set GR32:$dst, (atomic_load_min_32 addr:$ptr, GR32:$val))]>;
Dan Gohman8aeb61f2008-05-12 20:22:45 +00002727def ATOMMAX32: I<0, Pseudo, (outs GR32:$dst),(ins i32mem:$ptr, GR32:$val),
Mon P Wang078a62d2008-05-05 19:05:59 +00002728 "#ATOMMAX32 PSUEDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00002729 [(set GR32:$dst, (atomic_load_max_32 addr:$ptr, GR32:$val))]>;
Dan Gohman8aeb61f2008-05-12 20:22:45 +00002730def ATOMUMIN32: I<0, Pseudo, (outs GR32:$dst),(ins i32mem:$ptr, GR32:$val),
Mon P Wang078a62d2008-05-05 19:05:59 +00002731 "#ATOMUMIN32 PSUEDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00002732 [(set GR32:$dst, (atomic_load_umin_32 addr:$ptr, GR32:$val))]>;
Dan Gohman8aeb61f2008-05-12 20:22:45 +00002733def ATOMUMAX32: I<0, Pseudo, (outs GR32:$dst),(ins i32mem:$ptr, GR32:$val),
Mon P Wang078a62d2008-05-05 19:05:59 +00002734 "#ATOMUMAX32 PSUEDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00002735 [(set GR32:$dst, (atomic_load_umax_32 addr:$ptr, GR32:$val))]>;
Dale Johannesend20e4452008-08-19 18:47:28 +00002736
2737def ATOMAND16 : I<0, Pseudo, (outs GR16:$dst),(ins i16mem:$ptr, GR16:$val),
2738 "#ATOMAND16 PSUEDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00002739 [(set GR16:$dst, (atomic_load_and_16 addr:$ptr, GR16:$val))]>;
Dale Johannesend20e4452008-08-19 18:47:28 +00002740def ATOMOR16 : I<0, Pseudo, (outs GR16:$dst),(ins i16mem:$ptr, GR16:$val),
2741 "#ATOMOR16 PSUEDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00002742 [(set GR16:$dst, (atomic_load_or_16 addr:$ptr, GR16:$val))]>;
Dale Johannesend20e4452008-08-19 18:47:28 +00002743def ATOMXOR16 : I<0, Pseudo,(outs GR16:$dst),(ins i16mem:$ptr, GR16:$val),
2744 "#ATOMXOR16 PSUEDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00002745 [(set GR16:$dst, (atomic_load_xor_16 addr:$ptr, GR16:$val))]>;
Dale Johannesend20e4452008-08-19 18:47:28 +00002746def ATOMNAND16 : I<0, Pseudo,(outs GR16:$dst),(ins i16mem:$ptr, GR16:$val),
2747 "#ATOMNAND16 PSUEDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00002748 [(set GR16:$dst, (atomic_load_nand_16 addr:$ptr, GR16:$val))]>;
Dale Johannesend20e4452008-08-19 18:47:28 +00002749def ATOMMIN16: I<0, Pseudo, (outs GR16:$dst), (ins i16mem:$ptr, GR16:$val),
2750 "#ATOMMIN16 PSUEDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00002751 [(set GR16:$dst, (atomic_load_min_16 addr:$ptr, GR16:$val))]>;
Dale Johannesend20e4452008-08-19 18:47:28 +00002752def ATOMMAX16: I<0, Pseudo, (outs GR16:$dst),(ins i16mem:$ptr, GR16:$val),
2753 "#ATOMMAX16 PSUEDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00002754 [(set GR16:$dst, (atomic_load_max_16 addr:$ptr, GR16:$val))]>;
Dale Johannesend20e4452008-08-19 18:47:28 +00002755def ATOMUMIN16: I<0, Pseudo, (outs GR16:$dst),(ins i16mem:$ptr, GR16:$val),
2756 "#ATOMUMIN16 PSUEDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00002757 [(set GR16:$dst, (atomic_load_umin_16 addr:$ptr, GR16:$val))]>;
Dale Johannesend20e4452008-08-19 18:47:28 +00002758def ATOMUMAX16: I<0, Pseudo, (outs GR16:$dst),(ins i16mem:$ptr, GR16:$val),
2759 "#ATOMUMAX16 PSUEDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00002760 [(set GR16:$dst, (atomic_load_umax_16 addr:$ptr, GR16:$val))]>;
Dale Johannesend20e4452008-08-19 18:47:28 +00002761
2762def ATOMAND8 : I<0, Pseudo, (outs GR8:$dst),(ins i8mem:$ptr, GR8:$val),
2763 "#ATOMAND8 PSUEDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00002764 [(set GR8:$dst, (atomic_load_and_8 addr:$ptr, GR8:$val))]>;
Dale Johannesend20e4452008-08-19 18:47:28 +00002765def ATOMOR8 : I<0, Pseudo, (outs GR8:$dst),(ins i8mem:$ptr, GR8:$val),
2766 "#ATOMOR8 PSUEDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00002767 [(set GR8:$dst, (atomic_load_or_8 addr:$ptr, GR8:$val))]>;
Dale Johannesend20e4452008-08-19 18:47:28 +00002768def ATOMXOR8 : I<0, Pseudo,(outs GR8:$dst),(ins i8mem:$ptr, GR8:$val),
2769 "#ATOMXOR8 PSUEDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00002770 [(set GR8:$dst, (atomic_load_xor_8 addr:$ptr, GR8:$val))]>;
Dale Johannesend20e4452008-08-19 18:47:28 +00002771def ATOMNAND8 : I<0, Pseudo,(outs GR8:$dst),(ins i8mem:$ptr, GR8:$val),
2772 "#ATOMNAND8 PSUEDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00002773 [(set GR8:$dst, (atomic_load_nand_8 addr:$ptr, GR8:$val))]>;
Mon P Wang078a62d2008-05-05 19:05:59 +00002774}
2775
Dale Johannesenf160d802008-10-02 18:53:47 +00002776let Constraints = "$val1 = $dst1, $val2 = $dst2",
2777 Defs = [EFLAGS, EAX, EBX, ECX, EDX],
2778 Uses = [EAX, EBX, ECX, EDX],
Dale Johannesen44eb5372008-10-03 19:41:08 +00002779 mayLoad = 1, mayStore = 1,
Dale Johannesenf160d802008-10-02 18:53:47 +00002780 usesCustomDAGSchedInserter = 1 in {
2781def ATOMAND6432 : I<0, Pseudo, (outs GR32:$dst1, GR32:$dst2),
2782 (ins i64mem:$ptr, GR32:$val1, GR32:$val2),
2783 "#ATOMAND6432 PSUEDO!", []>;
2784def ATOMOR6432 : I<0, Pseudo, (outs GR32:$dst1, GR32:$dst2),
2785 (ins i64mem:$ptr, GR32:$val1, GR32:$val2),
2786 "#ATOMOR6432 PSUEDO!", []>;
2787def ATOMXOR6432 : I<0, Pseudo, (outs GR32:$dst1, GR32:$dst2),
2788 (ins i64mem:$ptr, GR32:$val1, GR32:$val2),
2789 "#ATOMXOR6432 PSUEDO!", []>;
2790def ATOMNAND6432 : I<0, Pseudo, (outs GR32:$dst1, GR32:$dst2),
2791 (ins i64mem:$ptr, GR32:$val1, GR32:$val2),
2792 "#ATOMNAND6432 PSUEDO!", []>;
2793def ATOMADD6432 : I<0, Pseudo, (outs GR32:$dst1, GR32:$dst2),
2794 (ins i64mem:$ptr, GR32:$val1, GR32:$val2),
2795 "#ATOMADD6432 PSUEDO!", []>;
2796def ATOMSUB6432 : I<0, Pseudo, (outs GR32:$dst1, GR32:$dst2),
2797 (ins i64mem:$ptr, GR32:$val1, GR32:$val2),
2798 "#ATOMSUB6432 PSUEDO!", []>;
Dale Johannesen51c58ee2008-10-03 22:25:52 +00002799def ATOMSWAP6432 : I<0, Pseudo, (outs GR32:$dst1, GR32:$dst2),
2800 (ins i64mem:$ptr, GR32:$val1, GR32:$val2),
2801 "#ATOMSWAP6432 PSUEDO!", []>;
Dale Johannesenf160d802008-10-02 18:53:47 +00002802}
2803
Andrew Lenharthe44f3902008-02-21 06:45:13 +00002804//===----------------------------------------------------------------------===//
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002805// Non-Instruction Patterns
2806//===----------------------------------------------------------------------===//
2807
Bill Wendlingfef06052008-09-16 21:48:12 +00002808// ConstantPool GlobalAddress, ExternalSymbol, and JumpTable
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002809def : Pat<(i32 (X86Wrapper tconstpool :$dst)), (MOV32ri tconstpool :$dst)>;
2810def : Pat<(i32 (X86Wrapper tjumptable :$dst)), (MOV32ri tjumptable :$dst)>;
Nate Begemanb52948972008-04-12 00:47:57 +00002811def : Pat<(i32 (X86Wrapper tglobaltlsaddr:$dst)),(MOV32ri tglobaltlsaddr:$dst)>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002812def : Pat<(i32 (X86Wrapper tglobaladdr :$dst)), (MOV32ri tglobaladdr :$dst)>;
2813def : Pat<(i32 (X86Wrapper texternalsym:$dst)), (MOV32ri texternalsym:$dst)>;
2814
2815def : Pat<(add GR32:$src1, (X86Wrapper tconstpool:$src2)),
2816 (ADD32ri GR32:$src1, tconstpool:$src2)>;
2817def : Pat<(add GR32:$src1, (X86Wrapper tjumptable:$src2)),
2818 (ADD32ri GR32:$src1, tjumptable:$src2)>;
2819def : Pat<(add GR32:$src1, (X86Wrapper tglobaladdr :$src2)),
2820 (ADD32ri GR32:$src1, tglobaladdr:$src2)>;
2821def : Pat<(add GR32:$src1, (X86Wrapper texternalsym:$src2)),
2822 (ADD32ri GR32:$src1, texternalsym:$src2)>;
2823
2824def : Pat<(store (i32 (X86Wrapper tglobaladdr:$src)), addr:$dst),
2825 (MOV32mi addr:$dst, tglobaladdr:$src)>;
2826def : Pat<(store (i32 (X86Wrapper texternalsym:$src)), addr:$dst),
2827 (MOV32mi addr:$dst, texternalsym:$src)>;
2828
2829// Calls
Arnold Schwaighofere2d6bbb2007-10-11 19:40:01 +00002830// tailcall stuff
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002831def : Pat<(X86tailcall GR32:$dst),
Arnold Schwaighofere2d6bbb2007-10-11 19:40:01 +00002832 (TAILCALL)>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002833
2834def : Pat<(X86tailcall (i32 tglobaladdr:$dst)),
Arnold Schwaighofere2d6bbb2007-10-11 19:40:01 +00002835 (TAILCALL)>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002836def : Pat<(X86tailcall (i32 texternalsym:$dst)),
Arnold Schwaighofere2d6bbb2007-10-11 19:40:01 +00002837 (TAILCALL)>;
2838
2839def : Pat<(X86tcret GR32:$dst, imm:$off),
2840 (TCRETURNri GR32:$dst, imm:$off)>;
2841
2842def : Pat<(X86tcret (i32 tglobaladdr:$dst), imm:$off),
2843 (TCRETURNdi texternalsym:$dst, imm:$off)>;
2844
2845def : Pat<(X86tcret (i32 texternalsym:$dst), imm:$off),
2846 (TCRETURNdi texternalsym:$dst, imm:$off)>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002847
2848def : Pat<(X86call (i32 tglobaladdr:$dst)),
2849 (CALLpcrel32 tglobaladdr:$dst)>;
2850def : Pat<(X86call (i32 texternalsym:$dst)),
2851 (CALLpcrel32 texternalsym:$dst)>;
2852
2853// X86 specific add which produces a flag.
2854def : Pat<(addc GR32:$src1, GR32:$src2),
2855 (ADD32rr GR32:$src1, GR32:$src2)>;
2856def : Pat<(addc GR32:$src1, (load addr:$src2)),
2857 (ADD32rm GR32:$src1, addr:$src2)>;
2858def : Pat<(addc GR32:$src1, imm:$src2),
2859 (ADD32ri GR32:$src1, imm:$src2)>;
2860def : Pat<(addc GR32:$src1, i32immSExt8:$src2),
2861 (ADD32ri8 GR32:$src1, i32immSExt8:$src2)>;
2862
2863def : Pat<(subc GR32:$src1, GR32:$src2),
2864 (SUB32rr GR32:$src1, GR32:$src2)>;
2865def : Pat<(subc GR32:$src1, (load addr:$src2)),
2866 (SUB32rm GR32:$src1, addr:$src2)>;
2867def : Pat<(subc GR32:$src1, imm:$src2),
2868 (SUB32ri GR32:$src1, imm:$src2)>;
2869def : Pat<(subc GR32:$src1, i32immSExt8:$src2),
2870 (SUB32ri8 GR32:$src1, i32immSExt8:$src2)>;
2871
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002872// Comparisons.
2873
2874// TEST R,R is smaller than CMP R,0
Evan Cheng621216e2007-09-29 00:00:36 +00002875def : Pat<(parallel (X86cmp GR8:$src1, 0), (implicit EFLAGS)),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002876 (TEST8rr GR8:$src1, GR8:$src1)>;
Evan Cheng621216e2007-09-29 00:00:36 +00002877def : Pat<(parallel (X86cmp GR16:$src1, 0), (implicit EFLAGS)),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002878 (TEST16rr GR16:$src1, GR16:$src1)>;
Evan Cheng621216e2007-09-29 00:00:36 +00002879def : Pat<(parallel (X86cmp GR32:$src1, 0), (implicit EFLAGS)),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002880 (TEST32rr GR32:$src1, GR32:$src1)>;
2881
Duncan Sands082524c2008-01-23 20:39:46 +00002882// zextload bool -> zextload byte
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002883def : Pat<(zextloadi8i1 addr:$src), (MOV8rm addr:$src)>;
2884def : Pat<(zextloadi16i1 addr:$src), (MOVZX16rm8 addr:$src)>;
2885def : Pat<(zextloadi32i1 addr:$src), (MOVZX32rm8 addr:$src)>;
2886
2887// extload bool -> extload byte
2888def : Pat<(extloadi8i1 addr:$src), (MOV8rm addr:$src)>;
Bill Wendlingce1c5c12008-08-22 20:51:05 +00002889def : Pat<(extloadi16i1 addr:$src), (MOVZX16rm8 addr:$src)>,
2890 Requires<[In32BitMode]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002891def : Pat<(extloadi32i1 addr:$src), (MOVZX32rm8 addr:$src)>;
Bill Wendlingce1c5c12008-08-22 20:51:05 +00002892def : Pat<(extloadi16i8 addr:$src), (MOVZX16rm8 addr:$src)>,
2893 Requires<[In32BitMode]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002894def : Pat<(extloadi32i8 addr:$src), (MOVZX32rm8 addr:$src)>;
2895def : Pat<(extloadi32i16 addr:$src), (MOVZX32rm16 addr:$src)>;
2896
Dan Gohmandd612bb2008-08-20 21:27:32 +00002897// anyext
Bill Wendlingce1c5c12008-08-22 20:51:05 +00002898def : Pat<(i16 (anyext GR8 :$src)), (MOVZX16rr8 GR8 :$src)>,
2899 Requires<[In32BitMode]>;
2900def : Pat<(i32 (anyext GR8 :$src)), (MOVZX32rr8 GR8 :$src)>,
2901 Requires<[In32BitMode]>;
Dan Gohmandd612bb2008-08-20 21:27:32 +00002902def : Pat<(i32 (anyext GR16:$src)),
2903 (INSERT_SUBREG (i32 (IMPLICIT_DEF)), GR16:$src, x86_subreg_16bit)>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002904
Evan Chengf2abee72007-12-13 00:43:27 +00002905// (and (i32 load), 255) -> (zextload i8)
Evan Cheng1e5e5452008-09-29 17:26:18 +00002906def : Pat<(i32 (and (nvloadi32 addr:$src), (i32 255))),
2907 (MOVZX32rm8 addr:$src)>;
2908def : Pat<(i32 (and (nvloadi32 addr:$src), (i32 65535))),
2909 (MOVZX32rm16 addr:$src)>;
Evan Chengf2abee72007-12-13 00:43:27 +00002910
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002911//===----------------------------------------------------------------------===//
2912// Some peepholes
2913//===----------------------------------------------------------------------===//
2914
Dan Gohman5a5e6e92008-10-17 01:33:43 +00002915// Odd encoding trick: -128 fits into an 8-bit immediate field while
2916// +128 doesn't, so in this special case use a sub instead of an add.
2917def : Pat<(add GR16:$src1, 128),
2918 (SUB16ri8 GR16:$src1, -128)>;
2919def : Pat<(store (add (loadi16 addr:$dst), 128), addr:$dst),
2920 (SUB16mi8 addr:$dst, -128)>;
2921def : Pat<(add GR32:$src1, 128),
2922 (SUB32ri8 GR32:$src1, -128)>;
2923def : Pat<(store (add (loadi32 addr:$dst), 128), addr:$dst),
2924 (SUB32mi8 addr:$dst, -128)>;
2925
Dan Gohman9203ab42008-07-30 18:09:17 +00002926// r & (2^16-1) ==> movz
2927def : Pat<(and GR32:$src1, 0xffff),
Dan Gohmandd612bb2008-08-20 21:27:32 +00002928 (MOVZX32rr16 (i16 (EXTRACT_SUBREG GR32:$src1, x86_subreg_16bit)))>;
Dan Gohman5beb1ff2008-08-06 18:27:21 +00002929// r & (2^8-1) ==> movz
2930def : Pat<(and GR32:$src1, 0xff),
Dan Gohmandd612bb2008-08-20 21:27:32 +00002931 (MOVZX32rr8 (i8 (EXTRACT_SUBREG (MOV32to32_ GR32:$src1),
2932 x86_subreg_8bit)))>,
Dan Gohman5beb1ff2008-08-06 18:27:21 +00002933 Requires<[In32BitMode]>;
2934// r & (2^8-1) ==> movz
2935def : Pat<(and GR16:$src1, 0xff),
Dan Gohmandd612bb2008-08-20 21:27:32 +00002936 (MOVZX16rr8 (i8 (EXTRACT_SUBREG (MOV16to16_ GR16:$src1),
2937 x86_subreg_8bit)))>,
2938 Requires<[In32BitMode]>;
2939
2940// sext_inreg patterns
2941def : Pat<(sext_inreg GR32:$src, i16),
2942 (MOVSX32rr16 (i16 (EXTRACT_SUBREG GR32:$src, x86_subreg_16bit)))>;
2943def : Pat<(sext_inreg GR32:$src, i8),
2944 (MOVSX32rr8 (i8 (EXTRACT_SUBREG (MOV32to32_ GR32:$src),
2945 x86_subreg_8bit)))>,
2946 Requires<[In32BitMode]>;
2947def : Pat<(sext_inreg GR16:$src, i8),
2948 (MOVSX16rr8 (i8 (EXTRACT_SUBREG (MOV16to16_ GR16:$src),
2949 x86_subreg_8bit)))>,
2950 Requires<[In32BitMode]>;
2951
2952// trunc patterns
2953def : Pat<(i16 (trunc GR32:$src)),
2954 (i16 (EXTRACT_SUBREG GR32:$src, x86_subreg_16bit))>;
2955def : Pat<(i8 (trunc GR32:$src)),
2956 (i8 (EXTRACT_SUBREG (MOV32to32_ GR32:$src), x86_subreg_8bit))>,
2957 Requires<[In32BitMode]>;
2958def : Pat<(i8 (trunc GR16:$src)),
2959 (i8 (EXTRACT_SUBREG (MOV16to16_ GR16:$src), x86_subreg_8bit))>,
Dan Gohman5beb1ff2008-08-06 18:27:21 +00002960 Requires<[In32BitMode]>;
Dan Gohman9203ab42008-07-30 18:09:17 +00002961
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002962// (shl x, 1) ==> (add x, x)
2963def : Pat<(shl GR8 :$src1, (i8 1)), (ADD8rr GR8 :$src1, GR8 :$src1)>;
2964def : Pat<(shl GR16:$src1, (i8 1)), (ADD16rr GR16:$src1, GR16:$src1)>;
2965def : Pat<(shl GR32:$src1, (i8 1)), (ADD32rr GR32:$src1, GR32:$src1)>;
2966
Evan Cheng76a64c72008-08-30 02:03:58 +00002967// (shl x (and y, 31)) ==> (shl x, y)
2968def : Pat<(shl GR8:$src1, (and CL:$amt, 31)),
2969 (SHL8rCL GR8:$src1)>;
2970def : Pat<(shl GR16:$src1, (and CL:$amt, 31)),
2971 (SHL16rCL GR16:$src1)>;
2972def : Pat<(shl GR32:$src1, (and CL:$amt, 31)),
2973 (SHL32rCL GR32:$src1)>;
2974def : Pat<(store (shl (loadi8 addr:$dst), (and CL:$amt, 31)), addr:$dst),
2975 (SHL8mCL addr:$dst)>;
2976def : Pat<(store (shl (loadi16 addr:$dst), (and CL:$amt, 31)), addr:$dst),
2977 (SHL16mCL addr:$dst)>;
2978def : Pat<(store (shl (loadi32 addr:$dst), (and CL:$amt, 31)), addr:$dst),
2979 (SHL32mCL addr:$dst)>;
2980
2981def : Pat<(srl GR8:$src1, (and CL:$amt, 31)),
2982 (SHR8rCL GR8:$src1)>;
2983def : Pat<(srl GR16:$src1, (and CL:$amt, 31)),
2984 (SHR16rCL GR16:$src1)>;
2985def : Pat<(srl GR32:$src1, (and CL:$amt, 31)),
2986 (SHR32rCL GR32:$src1)>;
2987def : Pat<(store (srl (loadi8 addr:$dst), (and CL:$amt, 31)), addr:$dst),
2988 (SHR8mCL addr:$dst)>;
2989def : Pat<(store (srl (loadi16 addr:$dst), (and CL:$amt, 31)), addr:$dst),
2990 (SHR16mCL addr:$dst)>;
2991def : Pat<(store (srl (loadi32 addr:$dst), (and CL:$amt, 31)), addr:$dst),
2992 (SHR32mCL addr:$dst)>;
2993
2994def : Pat<(sra GR8:$src1, (and CL:$amt, 31)),
2995 (SAR8rCL GR8:$src1)>;
2996def : Pat<(sra GR16:$src1, (and CL:$amt, 31)),
2997 (SAR16rCL GR16:$src1)>;
2998def : Pat<(sra GR32:$src1, (and CL:$amt, 31)),
2999 (SAR32rCL GR32:$src1)>;
3000def : Pat<(store (sra (loadi8 addr:$dst), (and CL:$amt, 31)), addr:$dst),
3001 (SAR8mCL addr:$dst)>;
3002def : Pat<(store (sra (loadi16 addr:$dst), (and CL:$amt, 31)), addr:$dst),
3003 (SAR16mCL addr:$dst)>;
3004def : Pat<(store (sra (loadi32 addr:$dst), (and CL:$amt, 31)), addr:$dst),
3005 (SAR32mCL addr:$dst)>;
3006
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003007// (or (x >> c) | (y << (32 - c))) ==> (shrd32 x, y, c)
3008def : Pat<(or (srl GR32:$src1, CL:$amt),
3009 (shl GR32:$src2, (sub 32, CL:$amt))),
3010 (SHRD32rrCL GR32:$src1, GR32:$src2)>;
3011
3012def : Pat<(store (or (srl (loadi32 addr:$dst), CL:$amt),
3013 (shl GR32:$src2, (sub 32, CL:$amt))), addr:$dst),
3014 (SHRD32mrCL addr:$dst, GR32:$src2)>;
3015
Dan Gohman921581d2008-10-17 01:23:35 +00003016def : Pat<(or (srl GR32:$src1, (i8 (trunc ECX:$amt))),
3017 (shl GR32:$src2, (i8 (trunc (sub 32, ECX:$amt))))),
3018 (SHRD32rrCL GR32:$src1, GR32:$src2)>;
3019
3020def : Pat<(store (or (srl (loadi32 addr:$dst), (i8 (trunc ECX:$amt))),
3021 (shl GR32:$src2, (i8 (trunc (sub 32, ECX:$amt))))),
3022 addr:$dst),
3023 (SHRD32mrCL addr:$dst, GR32:$src2)>;
3024
3025def : Pat<(shrd GR32:$src1, (i8 imm:$amt1), GR32:$src2, (i8 imm:$amt2)),
3026 (SHRD32rri8 GR32:$src1, GR32:$src2, (i8 imm:$amt1))>;
3027
3028def : Pat<(store (shrd (loadi32 addr:$dst), (i8 imm:$amt1),
3029 GR32:$src2, (i8 imm:$amt2)), addr:$dst),
3030 (SHRD32mri8 addr:$dst, GR32:$src2, (i8 imm:$amt1))>;
3031
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003032// (or (x << c) | (y >> (32 - c))) ==> (shld32 x, y, c)
3033def : Pat<(or (shl GR32:$src1, CL:$amt),
3034 (srl GR32:$src2, (sub 32, CL:$amt))),
3035 (SHLD32rrCL GR32:$src1, GR32:$src2)>;
3036
3037def : Pat<(store (or (shl (loadi32 addr:$dst), CL:$amt),
3038 (srl GR32:$src2, (sub 32, CL:$amt))), addr:$dst),
3039 (SHLD32mrCL addr:$dst, GR32:$src2)>;
3040
Dan Gohman921581d2008-10-17 01:23:35 +00003041def : Pat<(or (shl GR32:$src1, (i8 (trunc ECX:$amt))),
3042 (srl GR32:$src2, (i8 (trunc (sub 32, ECX:$amt))))),
3043 (SHLD32rrCL GR32:$src1, GR32:$src2)>;
3044
3045def : Pat<(store (or (shl (loadi32 addr:$dst), (i8 (trunc ECX:$amt))),
3046 (srl GR32:$src2, (i8 (trunc (sub 32, ECX:$amt))))),
3047 addr:$dst),
3048 (SHLD32mrCL addr:$dst, GR32:$src2)>;
3049
3050def : Pat<(shld GR32:$src1, (i8 imm:$amt1), GR32:$src2, (i8 imm:$amt2)),
3051 (SHLD32rri8 GR32:$src1, GR32:$src2, (i8 imm:$amt1))>;
3052
3053def : Pat<(store (shld (loadi32 addr:$dst), (i8 imm:$amt1),
3054 GR32:$src2, (i8 imm:$amt2)), addr:$dst),
3055 (SHLD32mri8 addr:$dst, GR32:$src2, (i8 imm:$amt1))>;
3056
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003057// (or (x >> c) | (y << (16 - c))) ==> (shrd16 x, y, c)
3058def : Pat<(or (srl GR16:$src1, CL:$amt),
3059 (shl GR16:$src2, (sub 16, CL:$amt))),
3060 (SHRD16rrCL GR16:$src1, GR16:$src2)>;
3061
3062def : Pat<(store (or (srl (loadi16 addr:$dst), CL:$amt),
3063 (shl GR16:$src2, (sub 16, CL:$amt))), addr:$dst),
3064 (SHRD16mrCL addr:$dst, GR16:$src2)>;
3065
Dan Gohman921581d2008-10-17 01:23:35 +00003066def : Pat<(or (srl GR16:$src1, (i8 (trunc CX:$amt))),
3067 (shl GR16:$src2, (i8 (trunc (sub 16, CX:$amt))))),
3068 (SHRD16rrCL GR16:$src1, GR16:$src2)>;
3069
3070def : Pat<(store (or (srl (loadi16 addr:$dst), (i8 (trunc CX:$amt))),
3071 (shl GR16:$src2, (i8 (trunc (sub 16, CX:$amt))))),
3072 addr:$dst),
3073 (SHRD16mrCL addr:$dst, GR16:$src2)>;
3074
3075def : Pat<(shrd GR16:$src1, (i8 imm:$amt1), GR16:$src2, (i8 imm:$amt2)),
3076 (SHRD16rri8 GR16:$src1, GR16:$src2, (i8 imm:$amt1))>;
3077
3078def : Pat<(store (shrd (loadi16 addr:$dst), (i8 imm:$amt1),
3079 GR16:$src2, (i8 imm:$amt2)), addr:$dst),
3080 (SHRD16mri8 addr:$dst, GR16:$src2, (i8 imm:$amt1))>;
3081
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003082// (or (x << c) | (y >> (16 - c))) ==> (shld16 x, y, c)
3083def : Pat<(or (shl GR16:$src1, CL:$amt),
3084 (srl GR16:$src2, (sub 16, CL:$amt))),
3085 (SHLD16rrCL GR16:$src1, GR16:$src2)>;
3086
3087def : Pat<(store (or (shl (loadi16 addr:$dst), CL:$amt),
3088 (srl GR16:$src2, (sub 16, CL:$amt))), addr:$dst),
3089 (SHLD16mrCL addr:$dst, GR16:$src2)>;
3090
Dan Gohman921581d2008-10-17 01:23:35 +00003091def : Pat<(or (shl GR16:$src1, (i8 (trunc CX:$amt))),
3092 (srl GR16:$src2, (i8 (trunc (sub 16, CX:$amt))))),
3093 (SHLD16rrCL GR16:$src1, GR16:$src2)>;
3094
3095def : Pat<(store (or (shl (loadi16 addr:$dst), (i8 (trunc CX:$amt))),
3096 (srl GR16:$src2, (i8 (trunc (sub 16, CX:$amt))))),
3097 addr:$dst),
3098 (SHLD16mrCL addr:$dst, GR16:$src2)>;
3099
3100def : Pat<(shld GR16:$src1, (i8 imm:$amt1), GR16:$src2, (i8 imm:$amt2)),
3101 (SHLD16rri8 GR16:$src1, GR16:$src2, (i8 imm:$amt1))>;
3102
3103def : Pat<(store (shld (loadi16 addr:$dst), (i8 imm:$amt1),
3104 GR16:$src2, (i8 imm:$amt2)), addr:$dst),
3105 (SHLD16mri8 addr:$dst, GR16:$src2, (i8 imm:$amt1))>;
3106
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003107//===----------------------------------------------------------------------===//
3108// Floating Point Stack Support
3109//===----------------------------------------------------------------------===//
3110
3111include "X86InstrFPStack.td"
3112
3113//===----------------------------------------------------------------------===//
Evan Cheng86ab7d32007-07-31 08:04:03 +00003114// X86-64 Support
3115//===----------------------------------------------------------------------===//
3116
Chris Lattner2de8d2b2008-01-10 05:50:42 +00003117include "X86Instr64bit.td"
Evan Cheng86ab7d32007-07-31 08:04:03 +00003118
3119//===----------------------------------------------------------------------===//
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003120// XMM Floating point support (requires SSE / SSE2)
3121//===----------------------------------------------------------------------===//
3122
3123include "X86InstrSSE.td"
Evan Cheng5e4d1e72008-04-25 18:19:54 +00003124
3125//===----------------------------------------------------------------------===//
3126// MMX and XMM Packed Integer support (requires MMX, SSE, and SSE2)
3127//===----------------------------------------------------------------------===//
3128
3129include "X86InstrMMX.td"