blob: 7a78e039b1341dbe525f9a7be4e197c08b66f050 [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 Gohmanf17a25c2007-07-18 16:29:46 +0000328//===----------------------------------------------------------------------===//
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000329// Instruction list...
330//
331
332// ADJCALLSTACKDOWN/UP implicitly use/def ESP because they may be expanded into
333// a stack adjustment and the codegen must know that they may modify the stack
334// pointer before prolog-epilog rewriting occurs.
Chris Lattnerb56cc342008-03-11 03:23:40 +0000335// Pessimistically assume ADJCALLSTACKDOWN / ADJCALLSTACKUP will become
336// sub / add which can clobber EFLAGS.
Evan Cheng037364a2007-09-28 01:19:48 +0000337let Defs = [ESP, EFLAGS], Uses = [ESP] in {
Dan Gohman01c9f772008-10-01 18:28:06 +0000338def ADJCALLSTACKDOWN32 : I<0, Pseudo, (outs), (ins i32imm:$amt),
339 "#ADJCALLSTACKDOWN",
Chris Lattnerfe5d4022008-10-11 22:08:30 +0000340 [(X86callseq_start timm:$amt)]>,
Dan Gohman01c9f772008-10-01 18:28:06 +0000341 Requires<[In32BitMode]>;
342def ADJCALLSTACKUP32 : I<0, Pseudo, (outs), (ins i32imm:$amt1, i32imm:$amt2),
343 "#ADJCALLSTACKUP",
Chris Lattnerfe5d4022008-10-11 22:08:30 +0000344 [(X86callseq_end timm:$amt1, timm:$amt2)]>,
Dan Gohman01c9f772008-10-01 18:28:06 +0000345 Requires<[In32BitMode]>;
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000346}
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000347
348// Nop
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000349let neverHasSideEffects = 1 in
350 def NOOP : I<0x90, RawFrm, (outs), (ins), "nop", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000351
Evan Cheng0729ccf2008-01-05 00:41:47 +0000352// PIC base
Dan Gohman9499cfe2008-10-01 04:14:30 +0000353let neverHasSideEffects = 1, isNotDuplicable = 1, Uses = [ESP] in
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000354 def MOVPC32r : Ii32<0xE8, Pseudo, (outs GR32:$reg), (ins piclabel:$label),
355 "call\t$label\n\tpop{l}\t$reg", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000356
357//===----------------------------------------------------------------------===//
358// Control Flow Instructions...
359//
360
361// Return instructions.
362let isTerminator = 1, isReturn = 1, isBarrier = 1,
Chris Lattnerb56cc342008-03-11 03:23:40 +0000363 hasCtrlDep = 1, FPForm = SpecialFP, FPFormBits = SpecialFP.Value in {
Dan Gohman2c4be2a2008-05-31 02:11:25 +0000364 def RET : I <0xC3, RawFrm, (outs), (ins variable_ops),
Chris Lattnerb56cc342008-03-11 03:23:40 +0000365 "ret",
Dan Gohman2c4be2a2008-05-31 02:11:25 +0000366 [(X86retflag 0)]>;
Chris Lattnerb56cc342008-03-11 03:23:40 +0000367 def RETI : Ii16<0xC2, RawFrm, (outs), (ins i16imm:$amt, variable_ops),
368 "ret\t$amt",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000369 [(X86retflag imm:$amt)]>;
370}
371
372// All branches are RawFrm, Void, Branch, and Terminators
Evan Cheng37e7c752007-07-21 00:34:19 +0000373let isBranch = 1, isTerminator = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +0000374 class IBr<bits<8> opcode, dag ins, string asm, list<dag> pattern> :
375 I<opcode, RawFrm, (outs), ins, asm, pattern>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000376
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000377let isBranch = 1, isBarrier = 1 in
Dan Gohman91888f02007-07-31 20:11:57 +0000378 def JMP : IBr<0xE9, (ins brtarget:$dst), "jmp\t$dst", [(br bb:$dst)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000379
Owen Andersonf8053082007-11-12 07:39:39 +0000380// Indirect branches
381let isBranch = 1, isTerminator = 1, isBarrier = 1, isIndirectBranch = 1 in {
Dan Gohman91888f02007-07-31 20:11:57 +0000382 def JMP32r : I<0xFF, MRM4r, (outs), (ins GR32:$dst), "jmp{l}\t{*}$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000383 [(brind GR32:$dst)]>;
Dan Gohman91888f02007-07-31 20:11:57 +0000384 def JMP32m : I<0xFF, MRM4m, (outs), (ins i32mem:$dst), "jmp{l}\t{*}$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000385 [(brind (loadi32 addr:$dst))]>;
386}
387
388// Conditional branches
Evan Cheng950aac02007-09-25 01:57:46 +0000389let Uses = [EFLAGS] in {
Dan Gohman91888f02007-07-31 20:11:57 +0000390def JE : IBr<0x84, (ins brtarget:$dst), "je\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000391 [(X86brcond bb:$dst, X86_COND_E, EFLAGS)]>, TB;
Dan Gohman91888f02007-07-31 20:11:57 +0000392def JNE : IBr<0x85, (ins brtarget:$dst), "jne\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000393 [(X86brcond bb:$dst, X86_COND_NE, EFLAGS)]>, TB;
Dan Gohman91888f02007-07-31 20:11:57 +0000394def JL : IBr<0x8C, (ins brtarget:$dst), "jl\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000395 [(X86brcond bb:$dst, X86_COND_L, EFLAGS)]>, TB;
Dan Gohman91888f02007-07-31 20:11:57 +0000396def JLE : IBr<0x8E, (ins brtarget:$dst), "jle\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000397 [(X86brcond bb:$dst, X86_COND_LE, EFLAGS)]>, TB;
Dan Gohman91888f02007-07-31 20:11:57 +0000398def JG : IBr<0x8F, (ins brtarget:$dst), "jg\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000399 [(X86brcond bb:$dst, X86_COND_G, EFLAGS)]>, TB;
Dan Gohman91888f02007-07-31 20:11:57 +0000400def JGE : IBr<0x8D, (ins brtarget:$dst), "jge\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000401 [(X86brcond bb:$dst, X86_COND_GE, EFLAGS)]>, TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000402
Dan Gohman91888f02007-07-31 20:11:57 +0000403def JB : IBr<0x82, (ins brtarget:$dst), "jb\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000404 [(X86brcond bb:$dst, X86_COND_B, EFLAGS)]>, TB;
Dan Gohman91888f02007-07-31 20:11:57 +0000405def JBE : IBr<0x86, (ins brtarget:$dst), "jbe\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000406 [(X86brcond bb:$dst, X86_COND_BE, EFLAGS)]>, TB;
Dan Gohman91888f02007-07-31 20:11:57 +0000407def JA : IBr<0x87, (ins brtarget:$dst), "ja\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000408 [(X86brcond bb:$dst, X86_COND_A, EFLAGS)]>, TB;
Dan Gohman91888f02007-07-31 20:11:57 +0000409def JAE : IBr<0x83, (ins brtarget:$dst), "jae\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000410 [(X86brcond bb:$dst, X86_COND_AE, EFLAGS)]>, TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000411
Dan Gohman91888f02007-07-31 20:11:57 +0000412def JS : IBr<0x88, (ins brtarget:$dst), "js\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000413 [(X86brcond bb:$dst, X86_COND_S, EFLAGS)]>, TB;
Dan Gohman91888f02007-07-31 20:11:57 +0000414def JNS : IBr<0x89, (ins brtarget:$dst), "jns\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000415 [(X86brcond bb:$dst, X86_COND_NS, EFLAGS)]>, TB;
Dan Gohman91888f02007-07-31 20:11:57 +0000416def JP : IBr<0x8A, (ins brtarget:$dst), "jp\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000417 [(X86brcond bb:$dst, X86_COND_P, EFLAGS)]>, TB;
Dan Gohman91888f02007-07-31 20:11:57 +0000418def JNP : IBr<0x8B, (ins brtarget:$dst), "jnp\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000419 [(X86brcond bb:$dst, X86_COND_NP, EFLAGS)]>, TB;
Dan Gohman91888f02007-07-31 20:11:57 +0000420def JO : IBr<0x80, (ins brtarget:$dst), "jo\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000421 [(X86brcond bb:$dst, X86_COND_O, EFLAGS)]>, TB;
Dan Gohman91888f02007-07-31 20:11:57 +0000422def JNO : IBr<0x81, (ins brtarget:$dst), "jno\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000423 [(X86brcond bb:$dst, X86_COND_NO, EFLAGS)]>, TB;
Evan Cheng950aac02007-09-25 01:57:46 +0000424} // Uses = [EFLAGS]
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000425
426//===----------------------------------------------------------------------===//
427// Call Instructions...
428//
Evan Cheng37e7c752007-07-21 00:34:19 +0000429let isCall = 1 in
Dan Gohman01c9f772008-10-01 18:28:06 +0000430 // All calls clobber the non-callee saved registers. ESP is marked as
431 // a use to prevent stack-pointer assignments that appear immediately
432 // before calls from potentially appearing dead. Uses for argument
433 // registers are added manually.
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000434 let Defs = [EAX, ECX, EDX, FP0, FP1, FP2, FP3, FP4, FP5, FP6, ST0,
435 MM0, MM1, MM2, MM3, MM4, MM5, MM6, MM7,
Dan Gohman9499cfe2008-10-01 04:14:30 +0000436 XMM0, XMM1, XMM2, XMM3, XMM4, XMM5, XMM6, XMM7, EFLAGS],
437 Uses = [ESP] in {
Evan Cheng34f93712007-12-22 02:26:46 +0000438 def CALLpcrel32 : Ii32<0xE8, RawFrm, (outs), (ins i32imm:$dst,variable_ops),
439 "call\t${dst:call}", []>;
Evan Chengb783fa32007-07-19 01:14:50 +0000440 def CALL32r : I<0xFF, MRM2r, (outs), (ins GR32:$dst, variable_ops),
Dan Gohman91888f02007-07-31 20:11:57 +0000441 "call\t{*}$dst", [(X86call GR32:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000442 def CALL32m : I<0xFF, MRM2m, (outs), (ins i32mem:$dst, variable_ops),
Dan Gohmanea4faba2008-05-29 21:50:34 +0000443 "call\t{*}$dst", [(X86call (loadi32 addr:$dst))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000444 }
445
446// Tail call stuff.
Arnold Schwaighofere2d6bbb2007-10-11 19:40:01 +0000447
Chris Lattnerb56cc342008-03-11 03:23:40 +0000448def TAILCALL : I<0, Pseudo, (outs), (ins),
Arnold Schwaighofere2d6bbb2007-10-11 19:40:01 +0000449 "#TAILCALL",
450 []>;
451
Evan Cheng37e7c752007-07-21 00:34:19 +0000452let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1 in
Arnold Schwaighofer6fd37ac2008-03-19 16:39:45 +0000453def TCRETURNdi : I<0, Pseudo, (outs), (ins i32imm:$dst, i32imm:$offset, variable_ops),
Arnold Schwaighofere2d6bbb2007-10-11 19:40:01 +0000454 "#TC_RETURN $dst $offset",
455 []>;
456
457let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1 in
Arnold Schwaighofer6fd37ac2008-03-19 16:39:45 +0000458def TCRETURNri : I<0, Pseudo, (outs), (ins GR32:$dst, i32imm:$offset, variable_ops),
Arnold Schwaighofere2d6bbb2007-10-11 19:40:01 +0000459 "#TC_RETURN $dst $offset",
460 []>;
461
462let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1 in
Arnold Schwaighofera0032722008-04-30 09:16:33 +0000463
Arnold Schwaighofere2d6bbb2007-10-11 19:40:01 +0000464 def TAILJMPd : IBr<0xE9, (ins i32imm:$dst), "jmp\t${dst:call} # TAILCALL",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000465 []>;
Evan Cheng37e7c752007-07-21 00:34:19 +0000466let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1 in
Arnold Schwaighofere2d6bbb2007-10-11 19:40:01 +0000467 def TAILJMPr : I<0xFF, MRM4r, (outs), (ins GR32:$dst), "jmp{l}\t{*}$dst # TAILCALL",
468 []>;
Evan Cheng37e7c752007-07-21 00:34:19 +0000469let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +0000470 def TAILJMPm : I<0xFF, MRM4m, (outs), (ins i32mem:$dst),
Arnold Schwaighofere2d6bbb2007-10-11 19:40:01 +0000471 "jmp\t{*}$dst # TAILCALL", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000472
473//===----------------------------------------------------------------------===//
474// Miscellaneous Instructions...
475//
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000476let Defs = [EBP, ESP], Uses = [EBP, ESP], mayLoad = 1, neverHasSideEffects=1 in
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000477def LEAVE : I<0xC9, RawFrm,
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000478 (outs), (ins), "leave", []>;
479
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000480let Defs = [ESP], Uses = [ESP], neverHasSideEffects=1 in {
481let mayLoad = 1 in
Evan Chengd8434332007-09-26 01:29:06 +0000482def POP32r : I<0x58, AddRegFrm, (outs GR32:$reg), (ins), "pop{l}\t$reg", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000483
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000484let mayStore = 1 in
Evan Chengd8434332007-09-26 01:29:06 +0000485def PUSH32r : I<0x50, AddRegFrm, (outs), (ins GR32:$reg), "push{l}\t$reg",[]>;
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000486}
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000487
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000488let Defs = [ESP, EFLAGS], Uses = [ESP], mayLoad = 1, neverHasSideEffects=1 in
Evan Chengf1341312007-09-26 21:28:00 +0000489def POPFD : I<0x9D, RawFrm, (outs), (ins), "popf", []>;
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000490let Defs = [ESP], Uses = [ESP, EFLAGS], mayStore = 1, neverHasSideEffects=1 in
Evan Chengf1341312007-09-26 21:28:00 +0000491def PUSHFD : I<0x9C, RawFrm, (outs), (ins), "pushf", []>;
Evan Chengd8434332007-09-26 01:29:06 +0000492
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000493let isTwoAddress = 1 in // GR32 = bswap GR32
494 def BSWAP32r : I<0xC8, AddRegFrm,
Evan Chengb783fa32007-07-19 01:14:50 +0000495 (outs GR32:$dst), (ins GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000496 "bswap{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000497 [(set GR32:$dst, (bswap GR32:$src))]>, TB;
498
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000499
Evan Cheng48679f42007-12-14 02:13:44 +0000500// Bit scan instructions.
501let Defs = [EFLAGS] in {
Evan Cheng4e33de92007-12-14 18:49:43 +0000502def BSF16rr : I<0xBC, MRMSrcReg, (outs GR16:$dst), (ins GR16:$src),
Dan Gohmancdb54c62007-12-14 15:10:00 +0000503 "bsf{w}\t{$src, $dst|$dst, $src}",
Evan Cheng7cfbfe32007-12-14 08:30:15 +0000504 [(set GR16:$dst, (X86bsf GR16:$src)), (implicit EFLAGS)]>, TB;
Evan Cheng48679f42007-12-14 02:13:44 +0000505def BSF16rm : I<0xBC, MRMSrcMem, (outs GR16:$dst), (ins i16mem:$src),
Dan Gohmancdb54c62007-12-14 15:10:00 +0000506 "bsf{w}\t{$src, $dst|$dst, $src}",
Evan Cheng7cfbfe32007-12-14 08:30:15 +0000507 [(set GR16:$dst, (X86bsf (loadi16 addr:$src))),
508 (implicit EFLAGS)]>, TB;
Evan Cheng4e33de92007-12-14 18:49:43 +0000509def BSF32rr : I<0xBC, MRMSrcReg, (outs GR32:$dst), (ins GR32:$src),
Dan Gohmancdb54c62007-12-14 15:10:00 +0000510 "bsf{l}\t{$src, $dst|$dst, $src}",
Evan Cheng7cfbfe32007-12-14 08:30:15 +0000511 [(set GR32:$dst, (X86bsf GR32:$src)), (implicit EFLAGS)]>, TB;
Evan Cheng48679f42007-12-14 02:13:44 +0000512def BSF32rm : I<0xBC, MRMSrcMem, (outs GR32:$dst), (ins i32mem:$src),
Dan Gohmancdb54c62007-12-14 15:10:00 +0000513 "bsf{l}\t{$src, $dst|$dst, $src}",
Evan Cheng7cfbfe32007-12-14 08:30:15 +0000514 [(set GR32:$dst, (X86bsf (loadi32 addr:$src))),
515 (implicit EFLAGS)]>, TB;
Evan Cheng48679f42007-12-14 02:13:44 +0000516
Evan Cheng4e33de92007-12-14 18:49:43 +0000517def BSR16rr : I<0xBD, MRMSrcReg, (outs GR16:$dst), (ins GR16:$src),
Dan Gohmancdb54c62007-12-14 15:10:00 +0000518 "bsr{w}\t{$src, $dst|$dst, $src}",
Evan Cheng7cfbfe32007-12-14 08:30:15 +0000519 [(set GR16:$dst, (X86bsr GR16:$src)), (implicit EFLAGS)]>, TB;
Evan Cheng48679f42007-12-14 02:13:44 +0000520def BSR16rm : I<0xBD, MRMSrcMem, (outs GR16:$dst), (ins i16mem:$src),
Dan Gohmancdb54c62007-12-14 15:10:00 +0000521 "bsr{w}\t{$src, $dst|$dst, $src}",
Evan Cheng7cfbfe32007-12-14 08:30:15 +0000522 [(set GR16:$dst, (X86bsr (loadi16 addr:$src))),
523 (implicit EFLAGS)]>, TB;
Evan Cheng4e33de92007-12-14 18:49:43 +0000524def BSR32rr : I<0xBD, MRMSrcReg, (outs GR32:$dst), (ins GR32:$src),
Dan Gohmancdb54c62007-12-14 15:10:00 +0000525 "bsr{l}\t{$src, $dst|$dst, $src}",
Evan Cheng7cfbfe32007-12-14 08:30:15 +0000526 [(set GR32:$dst, (X86bsr GR32:$src)), (implicit EFLAGS)]>, TB;
Evan Cheng48679f42007-12-14 02:13:44 +0000527def BSR32rm : I<0xBD, MRMSrcMem, (outs GR32:$dst), (ins i32mem:$src),
Dan Gohmancdb54c62007-12-14 15:10:00 +0000528 "bsr{l}\t{$src, $dst|$dst, $src}",
Evan Cheng7cfbfe32007-12-14 08:30:15 +0000529 [(set GR32:$dst, (X86bsr (loadi32 addr:$src))),
530 (implicit EFLAGS)]>, TB;
Evan Cheng48679f42007-12-14 02:13:44 +0000531} // Defs = [EFLAGS]
532
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000533let neverHasSideEffects = 1 in
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000534def LEA16r : I<0x8D, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +0000535 (outs GR16:$dst), (ins i32mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000536 "lea{w}\t{$src|$dst}, {$dst|$src}", []>, OpSize;
Evan Cheng1ea8e6b2008-03-27 01:41:09 +0000537let isReMaterializable = 1 in
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000538def LEA32r : I<0x8D, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +0000539 (outs GR32:$dst), (ins lea32mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000540 "lea{l}\t{$src|$dst}, {$dst|$src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000541 [(set GR32:$dst, lea32addr:$src)]>, Requires<[In32BitMode]>;
542
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000543let Defs = [ECX,EDI,ESI], Uses = [ECX,EDI,ESI] in {
Evan Chengb783fa32007-07-19 01:14:50 +0000544def REP_MOVSB : I<0xA4, RawFrm, (outs), (ins), "{rep;movsb|rep movsb}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000545 [(X86rep_movs i8)]>, REP;
Evan Chengb783fa32007-07-19 01:14:50 +0000546def REP_MOVSW : I<0xA5, RawFrm, (outs), (ins), "{rep;movsw|rep movsw}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000547 [(X86rep_movs i16)]>, REP, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +0000548def REP_MOVSD : I<0xA5, RawFrm, (outs), (ins), "{rep;movsl|rep movsd}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000549 [(X86rep_movs i32)]>, REP;
550}
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000551
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000552let Defs = [ECX,EDI], Uses = [AL,ECX,EDI] in
Evan Chengb783fa32007-07-19 01:14:50 +0000553def REP_STOSB : I<0xAA, RawFrm, (outs), (ins), "{rep;stosb|rep stosb}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000554 [(X86rep_stos i8)]>, REP;
555let Defs = [ECX,EDI], Uses = [AX,ECX,EDI] in
Evan Chengb783fa32007-07-19 01:14:50 +0000556def REP_STOSW : I<0xAB, RawFrm, (outs), (ins), "{rep;stosw|rep stosw}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000557 [(X86rep_stos i16)]>, REP, OpSize;
558let Defs = [ECX,EDI], Uses = [EAX,ECX,EDI] in
Evan Chengb783fa32007-07-19 01:14:50 +0000559def REP_STOSD : I<0xAB, RawFrm, (outs), (ins), "{rep;stosl|rep stosd}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000560 [(X86rep_stos i32)]>, REP;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000561
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000562let Defs = [RAX, RDX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000563def RDTSC : I<0x31, RawFrm, (outs), (ins), "rdtsc", [(X86rdtsc)]>,
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000564 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000565
Anton Korobeynikov39d40ba2008-01-15 07:02:33 +0000566let isBarrier = 1, hasCtrlDep = 1 in {
Chris Lattner56b941f2008-01-15 21:58:22 +0000567def TRAP : I<0x0B, RawFrm, (outs), (ins), "ud2", [(trap)]>, TB;
Anton Korobeynikov39d40ba2008-01-15 07:02:33 +0000568}
569
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000570//===----------------------------------------------------------------------===//
571// Input/Output Instructions...
572//
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000573let Defs = [AL], Uses = [DX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000574def IN8rr : I<0xEC, RawFrm, (outs), (ins),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000575 "in{b}\t{%dx, %al|%AL, %DX}", []>;
576let Defs = [AX], Uses = [DX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000577def IN16rr : I<0xED, RawFrm, (outs), (ins),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000578 "in{w}\t{%dx, %ax|%AX, %DX}", []>, OpSize;
579let Defs = [EAX], Uses = [DX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000580def IN32rr : I<0xED, RawFrm, (outs), (ins),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000581 "in{l}\t{%dx, %eax|%EAX, %DX}", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000582
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000583let Defs = [AL] in
Evan Chengb783fa32007-07-19 01:14:50 +0000584def IN8ri : Ii8<0xE4, RawFrm, (outs), (ins i16i8imm:$port),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000585 "in{b}\t{$port, %al|%AL, $port}", []>;
586let Defs = [AX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000587def IN16ri : Ii8<0xE5, RawFrm, (outs), (ins i16i8imm:$port),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000588 "in{w}\t{$port, %ax|%AX, $port}", []>, OpSize;
589let Defs = [EAX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000590def IN32ri : Ii8<0xE5, RawFrm, (outs), (ins i16i8imm:$port),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000591 "in{l}\t{$port, %eax|%EAX, $port}", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000592
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000593let Uses = [DX, AL] in
Evan Chengb783fa32007-07-19 01:14:50 +0000594def OUT8rr : I<0xEE, RawFrm, (outs), (ins),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000595 "out{b}\t{%al, %dx|%DX, %AL}", []>;
596let Uses = [DX, AX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000597def OUT16rr : I<0xEF, RawFrm, (outs), (ins),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000598 "out{w}\t{%ax, %dx|%DX, %AX}", []>, OpSize;
599let Uses = [DX, EAX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000600def OUT32rr : I<0xEF, RawFrm, (outs), (ins),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000601 "out{l}\t{%eax, %dx|%DX, %EAX}", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000602
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000603let Uses = [AL] in
Evan Chengb783fa32007-07-19 01:14:50 +0000604def OUT8ir : Ii8<0xE6, RawFrm, (outs), (ins i16i8imm:$port),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000605 "out{b}\t{%al, $port|$port, %AL}", []>;
606let Uses = [AX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000607def OUT16ir : Ii8<0xE7, RawFrm, (outs), (ins i16i8imm:$port),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000608 "out{w}\t{%ax, $port|$port, %AX}", []>, OpSize;
609let Uses = [EAX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000610def OUT32ir : Ii8<0xE7, RawFrm, (outs), (ins i16i8imm:$port),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000611 "out{l}\t{%eax, $port|$port, %EAX}", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000612
613//===----------------------------------------------------------------------===//
614// Move Instructions...
615//
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000616let neverHasSideEffects = 1 in {
Evan Chengb783fa32007-07-19 01:14:50 +0000617def MOV8rr : I<0x88, MRMDestReg, (outs GR8 :$dst), (ins GR8 :$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000618 "mov{b}\t{$src, $dst|$dst, $src}", []>;
Evan Chengb783fa32007-07-19 01:14:50 +0000619def MOV16rr : I<0x89, MRMDestReg, (outs GR16:$dst), (ins GR16:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000620 "mov{w}\t{$src, $dst|$dst, $src}", []>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +0000621def MOV32rr : I<0x89, MRMDestReg, (outs GR32:$dst), (ins GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000622 "mov{l}\t{$src, $dst|$dst, $src}", []>;
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000623}
Evan Cheng6f26e8b2008-06-18 08:13:07 +0000624let isReMaterializable = 1, isAsCheapAsAMove = 1 in {
Evan Chengb783fa32007-07-19 01:14:50 +0000625def MOV8ri : Ii8 <0xB0, AddRegFrm, (outs GR8 :$dst), (ins i8imm :$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000626 "mov{b}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000627 [(set GR8:$dst, imm:$src)]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000628def MOV16ri : Ii16<0xB8, AddRegFrm, (outs GR16:$dst), (ins i16imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000629 "mov{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000630 [(set GR16:$dst, imm:$src)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +0000631def MOV32ri : Ii32<0xB8, AddRegFrm, (outs GR32:$dst), (ins i32imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000632 "mov{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000633 [(set GR32:$dst, imm:$src)]>;
634}
Evan Chengb783fa32007-07-19 01:14:50 +0000635def MOV8mi : Ii8 <0xC6, MRM0m, (outs), (ins i8mem :$dst, i8imm :$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000636 "mov{b}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000637 [(store (i8 imm:$src), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000638def MOV16mi : Ii16<0xC7, MRM0m, (outs), (ins i16mem:$dst, i16imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000639 "mov{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000640 [(store (i16 imm:$src), addr:$dst)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +0000641def MOV32mi : Ii32<0xC7, MRM0m, (outs), (ins i32mem:$dst, i32imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000642 "mov{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000643 [(store (i32 imm:$src), addr:$dst)]>;
644
Chris Lattner1a1932c2008-01-06 23:38:27 +0000645let isSimpleLoad = 1, isReMaterializable = 1, mayHaveSideEffects = 1 in {
Evan Chengb783fa32007-07-19 01:14:50 +0000646def MOV8rm : I<0x8A, MRMSrcMem, (outs GR8 :$dst), (ins i8mem :$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000647 "mov{b}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000648 [(set GR8:$dst, (load addr:$src))]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000649def MOV16rm : I<0x8B, MRMSrcMem, (outs GR16:$dst), (ins i16mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000650 "mov{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000651 [(set GR16:$dst, (load addr:$src))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +0000652def MOV32rm : I<0x8B, MRMSrcMem, (outs GR32:$dst), (ins i32mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000653 "mov{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000654 [(set GR32:$dst, (load addr:$src))]>;
Evan Cheng4e84e452007-08-30 05:49:43 +0000655}
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000656
Evan Chengb783fa32007-07-19 01:14:50 +0000657def MOV8mr : I<0x88, MRMDestMem, (outs), (ins i8mem :$dst, GR8 :$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000658 "mov{b}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000659 [(store GR8:$src, addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000660def MOV16mr : I<0x89, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000661 "mov{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000662 [(store GR16:$src, addr:$dst)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +0000663def MOV32mr : I<0x89, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000664 "mov{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000665 [(store GR32:$src, addr:$dst)]>;
666
667//===----------------------------------------------------------------------===//
668// Fixed-Register Multiplication and Division Instructions...
669//
670
671// Extra precision multiplication
Evan Cheng55687072007-09-14 21:48:26 +0000672let Defs = [AL,AH,EFLAGS], Uses = [AL] in
Dan Gohman91888f02007-07-31 20:11:57 +0000673def MUL8r : I<0xF6, MRM4r, (outs), (ins GR8:$src), "mul{b}\t$src",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000674 // FIXME: Used for 8-bit mul, ignore result upper 8 bits.
675 // This probably ought to be moved to a def : Pat<> if the
676 // syntax can be accepted.
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000677 [(set AL, (mul AL, GR8:$src))]>; // AL,AH = AL*GR8
Chris Lattnerc7e96e72008-01-11 07:18:17 +0000678let Defs = [AX,DX,EFLAGS], Uses = [AX], neverHasSideEffects = 1 in
Dan Gohman91888f02007-07-31 20:11:57 +0000679def MUL16r : I<0xF7, MRM4r, (outs), (ins GR16:$src), "mul{w}\t$src", []>,
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000680 OpSize; // AX,DX = AX*GR16
Chris Lattnerc7e96e72008-01-11 07:18:17 +0000681let Defs = [EAX,EDX,EFLAGS], Uses = [EAX], neverHasSideEffects = 1 in
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000682def MUL32r : I<0xF7, MRM4r, (outs), (ins GR32:$src), "mul{l}\t$src", []>;
683 // EAX,EDX = EAX*GR32
Evan Cheng55687072007-09-14 21:48:26 +0000684let Defs = [AL,AH,EFLAGS], Uses = [AL] in
Evan Chengb783fa32007-07-19 01:14:50 +0000685def MUL8m : I<0xF6, MRM4m, (outs), (ins i8mem :$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000686 "mul{b}\t$src",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000687 // FIXME: Used for 8-bit mul, ignore result upper 8 bits.
688 // This probably ought to be moved to a def : Pat<> if the
689 // syntax can be accepted.
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000690 [(set AL, (mul AL, (loadi8 addr:$src)))]>; // AL,AH = AL*[mem8]
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000691let mayLoad = 1, neverHasSideEffects = 1 in {
Evan Cheng55687072007-09-14 21:48:26 +0000692let Defs = [AX,DX,EFLAGS], Uses = [AX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000693def MUL16m : I<0xF7, MRM4m, (outs), (ins i16mem:$src),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000694 "mul{w}\t$src", []>, OpSize; // AX,DX = AX*[mem16]
Evan Cheng55687072007-09-14 21:48:26 +0000695let Defs = [EAX,EDX,EFLAGS], Uses = [EAX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000696def MUL32m : I<0xF7, MRM4m, (outs), (ins i32mem:$src),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000697 "mul{l}\t$src", []>; // EAX,EDX = EAX*[mem32]
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000698}
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000699
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000700let neverHasSideEffects = 1 in {
Evan Cheng55687072007-09-14 21:48:26 +0000701let Defs = [AL,AH,EFLAGS], Uses = [AL] in
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000702def IMUL8r : I<0xF6, MRM5r, (outs), (ins GR8:$src), "imul{b}\t$src", []>;
703 // AL,AH = AL*GR8
Evan Cheng55687072007-09-14 21:48:26 +0000704let Defs = [AX,DX,EFLAGS], Uses = [AX] in
Dan Gohman91888f02007-07-31 20:11:57 +0000705def IMUL16r : I<0xF7, MRM5r, (outs), (ins GR16:$src), "imul{w}\t$src", []>,
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000706 OpSize; // AX,DX = AX*GR16
Evan Cheng55687072007-09-14 21:48:26 +0000707let Defs = [EAX,EDX,EFLAGS], Uses = [EAX] in
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000708def IMUL32r : I<0xF7, MRM5r, (outs), (ins GR32:$src), "imul{l}\t$src", []>;
709 // EAX,EDX = EAX*GR32
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000710let mayLoad = 1 in {
Evan Cheng55687072007-09-14 21:48:26 +0000711let Defs = [AL,AH,EFLAGS], Uses = [AL] in
Evan Chengb783fa32007-07-19 01:14:50 +0000712def IMUL8m : I<0xF6, MRM5m, (outs), (ins i8mem :$src),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000713 "imul{b}\t$src", []>; // AL,AH = AL*[mem8]
Evan Cheng55687072007-09-14 21:48:26 +0000714let Defs = [AX,DX,EFLAGS], Uses = [AX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000715def IMUL16m : I<0xF7, MRM5m, (outs), (ins i16mem:$src),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000716 "imul{w}\t$src", []>, OpSize; // AX,DX = AX*[mem16]
717let Defs = [EAX,EDX], Uses = [EAX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000718def IMUL32m : I<0xF7, MRM5m, (outs), (ins i32mem:$src),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000719 "imul{l}\t$src", []>; // EAX,EDX = EAX*[mem32]
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000720}
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000721
722// unsigned division/remainder
Dale Johannesend8fd3562008-10-07 18:54:28 +0000723let Defs = [AL,AH,EFLAGS], Uses = [AX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000724def DIV8r : I<0xF6, MRM6r, (outs), (ins GR8:$src), // AX/r8 = AL,AH
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000725 "div{b}\t$src", []>;
Evan Cheng55687072007-09-14 21:48:26 +0000726let Defs = [AX,DX,EFLAGS], Uses = [AX,DX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000727def DIV16r : I<0xF7, MRM6r, (outs), (ins GR16:$src), // DX:AX/r16 = AX,DX
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000728 "div{w}\t$src", []>, OpSize;
Evan Cheng55687072007-09-14 21:48:26 +0000729let Defs = [EAX,EDX,EFLAGS], Uses = [EAX,EDX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000730def DIV32r : I<0xF7, MRM6r, (outs), (ins GR32:$src), // EDX:EAX/r32 = EAX,EDX
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000731 "div{l}\t$src", []>;
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000732let mayLoad = 1 in {
Dale Johannesend8fd3562008-10-07 18:54:28 +0000733let Defs = [AL,AH,EFLAGS], Uses = [AX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000734def DIV8m : I<0xF6, MRM6m, (outs), (ins i8mem:$src), // AX/[mem8] = AL,AH
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000735 "div{b}\t$src", []>;
Evan Cheng55687072007-09-14 21:48:26 +0000736let Defs = [AX,DX,EFLAGS], Uses = [AX,DX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000737def DIV16m : I<0xF7, MRM6m, (outs), (ins i16mem:$src), // DX:AX/[mem16] = AX,DX
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000738 "div{w}\t$src", []>, OpSize;
Evan Cheng55687072007-09-14 21:48:26 +0000739let Defs = [EAX,EDX,EFLAGS], Uses = [EAX,EDX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000740def DIV32m : I<0xF7, MRM6m, (outs), (ins i32mem:$src), // EDX:EAX/[mem32] = EAX,EDX
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000741 "div{l}\t$src", []>;
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000742}
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000743
744// Signed division/remainder.
Dale Johannesend8fd3562008-10-07 18:54:28 +0000745let Defs = [AL,AH,EFLAGS], Uses = [AX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000746def IDIV8r : I<0xF6, MRM7r, (outs), (ins GR8:$src), // AX/r8 = AL,AH
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000747 "idiv{b}\t$src", []>;
Evan Cheng55687072007-09-14 21:48:26 +0000748let Defs = [AX,DX,EFLAGS], Uses = [AX,DX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000749def IDIV16r: I<0xF7, MRM7r, (outs), (ins GR16:$src), // DX:AX/r16 = AX,DX
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000750 "idiv{w}\t$src", []>, OpSize;
Evan Cheng55687072007-09-14 21:48:26 +0000751let Defs = [EAX,EDX,EFLAGS], Uses = [EAX,EDX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000752def IDIV32r: I<0xF7, MRM7r, (outs), (ins GR32:$src), // EDX:EAX/r32 = EAX,EDX
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000753 "idiv{l}\t$src", []>;
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000754let mayLoad = 1, mayLoad = 1 in {
Dale Johannesend8fd3562008-10-07 18:54:28 +0000755let Defs = [AL,AH,EFLAGS], Uses = [AX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000756def IDIV8m : I<0xF6, MRM7m, (outs), (ins i8mem:$src), // AX/[mem8] = AL,AH
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000757 "idiv{b}\t$src", []>;
Evan Cheng55687072007-09-14 21:48:26 +0000758let Defs = [AX,DX,EFLAGS], Uses = [AX,DX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000759def IDIV16m: I<0xF7, MRM7m, (outs), (ins i16mem:$src), // DX:AX/[mem16] = AX,DX
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000760 "idiv{w}\t$src", []>, OpSize;
Evan Cheng55687072007-09-14 21:48:26 +0000761let Defs = [EAX,EDX,EFLAGS], Uses = [EAX,EDX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000762def IDIV32m: I<0xF7, MRM7m, (outs), (ins i32mem:$src), // EDX:EAX/[mem32] = EAX,EDX
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000763 "idiv{l}\t$src", []>;
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000764}
765} // neverHasSideEffects
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000766
767//===----------------------------------------------------------------------===//
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000768// Two address Instructions.
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000769//
770let isTwoAddress = 1 in {
771
772// Conditional moves
Evan Cheng950aac02007-09-25 01:57:46 +0000773let Uses = [EFLAGS] in {
Evan Cheng926658c2007-10-05 23:13:21 +0000774let isCommutable = 1 in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000775def CMOVB16rr : I<0x42, MRMSrcReg, // if <u, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +0000776 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000777 "cmovb\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000778 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000779 X86_COND_B, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000780 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000781def CMOVB32rr : I<0x42, MRMSrcReg, // if <u, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +0000782 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000783 "cmovb\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000784 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000785 X86_COND_B, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000786 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000787
788def CMOVAE16rr: I<0x43, MRMSrcReg, // if >=u, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +0000789 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000790 "cmovae\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000791 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000792 X86_COND_AE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000793 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000794def CMOVAE32rr: I<0x43, MRMSrcReg, // if >=u, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +0000795 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000796 "cmovae\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000797 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000798 X86_COND_AE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000799 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000800def CMOVE16rr : I<0x44, MRMSrcReg, // if ==, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +0000801 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000802 "cmove\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000803 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000804 X86_COND_E, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000805 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000806def CMOVE32rr : I<0x44, MRMSrcReg, // if ==, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +0000807 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000808 "cmove\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000809 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000810 X86_COND_E, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000811 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000812def CMOVNE16rr: I<0x45, MRMSrcReg, // if !=, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +0000813 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000814 "cmovne\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000815 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000816 X86_COND_NE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000817 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000818def CMOVNE32rr: I<0x45, MRMSrcReg, // if !=, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +0000819 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000820 "cmovne\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000821 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000822 X86_COND_NE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000823 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000824def CMOVBE16rr: I<0x46, MRMSrcReg, // if <=u, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +0000825 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000826 "cmovbe\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000827 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000828 X86_COND_BE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000829 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000830def CMOVBE32rr: I<0x46, MRMSrcReg, // if <=u, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +0000831 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000832 "cmovbe\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000833 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000834 X86_COND_BE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000835 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000836def CMOVA16rr : I<0x47, MRMSrcReg, // if >u, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +0000837 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000838 "cmova\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000839 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000840 X86_COND_A, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000841 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000842def CMOVA32rr : I<0x47, MRMSrcReg, // if >u, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +0000843 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000844 "cmova\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000845 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000846 X86_COND_A, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000847 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000848def CMOVL16rr : I<0x4C, MRMSrcReg, // if <s, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +0000849 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000850 "cmovl\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000851 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000852 X86_COND_L, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000853 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000854def CMOVL32rr : I<0x4C, MRMSrcReg, // if <s, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +0000855 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000856 "cmovl\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000857 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000858 X86_COND_L, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000859 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000860def CMOVGE16rr: I<0x4D, MRMSrcReg, // if >=s, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +0000861 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000862 "cmovge\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000863 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000864 X86_COND_GE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000865 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000866def CMOVGE32rr: I<0x4D, MRMSrcReg, // if >=s, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +0000867 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000868 "cmovge\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000869 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000870 X86_COND_GE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000871 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000872def CMOVLE16rr: I<0x4E, MRMSrcReg, // if <=s, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +0000873 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000874 "cmovle\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000875 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000876 X86_COND_LE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000877 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000878def CMOVLE32rr: I<0x4E, MRMSrcReg, // if <=s, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +0000879 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000880 "cmovle\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000881 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000882 X86_COND_LE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000883 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000884def CMOVG16rr : I<0x4F, MRMSrcReg, // if >s, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +0000885 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000886 "cmovg\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000887 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000888 X86_COND_G, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000889 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000890def CMOVG32rr : I<0x4F, MRMSrcReg, // if >s, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +0000891 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000892 "cmovg\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000893 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000894 X86_COND_G, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000895 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000896def CMOVS16rr : I<0x48, MRMSrcReg, // if signed, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +0000897 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000898 "cmovs\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000899 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000900 X86_COND_S, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000901 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000902def CMOVS32rr : I<0x48, MRMSrcReg, // if signed, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +0000903 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000904 "cmovs\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000905 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000906 X86_COND_S, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000907 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000908def CMOVNS16rr: I<0x49, MRMSrcReg, // if !signed, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +0000909 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000910 "cmovns\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000911 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000912 X86_COND_NS, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000913 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000914def CMOVNS32rr: I<0x49, MRMSrcReg, // if !signed, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +0000915 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000916 "cmovns\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000917 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000918 X86_COND_NS, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000919 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000920def CMOVP16rr : I<0x4A, MRMSrcReg, // if parity, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +0000921 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000922 "cmovp\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000923 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000924 X86_COND_P, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000925 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000926def CMOVP32rr : I<0x4A, MRMSrcReg, // if parity, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +0000927 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000928 "cmovp\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000929 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000930 X86_COND_P, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000931 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000932def CMOVNP16rr : I<0x4B, MRMSrcReg, // if !parity, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +0000933 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000934 "cmovnp\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000935 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000936 X86_COND_NP, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000937 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000938def CMOVNP32rr : I<0x4B, MRMSrcReg, // if !parity, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +0000939 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000940 "cmovnp\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000941 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000942 X86_COND_NP, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000943 TB;
Evan Cheng926658c2007-10-05 23:13:21 +0000944} // isCommutable = 1
945
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000946def CMOVNP32rm : I<0x4B, MRMSrcMem, // if !parity, GR32 = [mem32]
Evan Chengb783fa32007-07-19 01:14:50 +0000947 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000948 "cmovnp\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000949 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
Evan Cheng950aac02007-09-25 01:57:46 +0000950 X86_COND_NP, EFLAGS))]>,
951 TB;
Evan Cheng926658c2007-10-05 23:13:21 +0000952
953def CMOVB16rm : I<0x42, MRMSrcMem, // if <u, GR16 = [mem16]
954 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
955 "cmovb\t{$src2, $dst|$dst, $src2}",
956 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
957 X86_COND_B, EFLAGS))]>,
958 TB, OpSize;
959def CMOVB32rm : I<0x42, MRMSrcMem, // if <u, GR32 = [mem32]
960 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
961 "cmovb\t{$src2, $dst|$dst, $src2}",
962 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
963 X86_COND_B, EFLAGS))]>,
964 TB;
965def CMOVAE16rm: I<0x43, MRMSrcMem, // if >=u, GR16 = [mem16]
966 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
967 "cmovae\t{$src2, $dst|$dst, $src2}",
968 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
969 X86_COND_AE, EFLAGS))]>,
970 TB, OpSize;
971def CMOVAE32rm: I<0x43, MRMSrcMem, // if >=u, GR32 = [mem32]
972 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
973 "cmovae\t{$src2, $dst|$dst, $src2}",
974 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
975 X86_COND_AE, EFLAGS))]>,
976 TB;
977def CMOVE16rm : I<0x44, MRMSrcMem, // if ==, GR16 = [mem16]
978 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
979 "cmove\t{$src2, $dst|$dst, $src2}",
980 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
981 X86_COND_E, EFLAGS))]>,
982 TB, OpSize;
983def CMOVE32rm : I<0x44, MRMSrcMem, // if ==, GR32 = [mem32]
984 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
985 "cmove\t{$src2, $dst|$dst, $src2}",
986 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
987 X86_COND_E, EFLAGS))]>,
988 TB;
989def CMOVNE16rm: I<0x45, MRMSrcMem, // if !=, GR16 = [mem16]
990 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
991 "cmovne\t{$src2, $dst|$dst, $src2}",
992 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
993 X86_COND_NE, EFLAGS))]>,
994 TB, OpSize;
995def CMOVNE32rm: I<0x45, MRMSrcMem, // if !=, GR32 = [mem32]
996 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
997 "cmovne\t{$src2, $dst|$dst, $src2}",
998 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
999 X86_COND_NE, EFLAGS))]>,
1000 TB;
1001def CMOVBE16rm: I<0x46, MRMSrcMem, // if <=u, GR16 = [mem16]
1002 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1003 "cmovbe\t{$src2, $dst|$dst, $src2}",
1004 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1005 X86_COND_BE, EFLAGS))]>,
1006 TB, OpSize;
1007def CMOVBE32rm: I<0x46, MRMSrcMem, // if <=u, GR32 = [mem32]
1008 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1009 "cmovbe\t{$src2, $dst|$dst, $src2}",
1010 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1011 X86_COND_BE, EFLAGS))]>,
1012 TB;
1013def CMOVA16rm : I<0x47, MRMSrcMem, // if >u, GR16 = [mem16]
1014 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1015 "cmova\t{$src2, $dst|$dst, $src2}",
1016 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1017 X86_COND_A, EFLAGS))]>,
1018 TB, OpSize;
1019def CMOVA32rm : I<0x47, MRMSrcMem, // if >u, GR32 = [mem32]
1020 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1021 "cmova\t{$src2, $dst|$dst, $src2}",
1022 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1023 X86_COND_A, EFLAGS))]>,
1024 TB;
1025def CMOVL16rm : I<0x4C, MRMSrcMem, // if <s, GR16 = [mem16]
1026 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1027 "cmovl\t{$src2, $dst|$dst, $src2}",
1028 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1029 X86_COND_L, EFLAGS))]>,
1030 TB, OpSize;
1031def CMOVL32rm : I<0x4C, MRMSrcMem, // if <s, GR32 = [mem32]
1032 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1033 "cmovl\t{$src2, $dst|$dst, $src2}",
1034 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1035 X86_COND_L, EFLAGS))]>,
1036 TB;
1037def CMOVGE16rm: I<0x4D, MRMSrcMem, // if >=s, GR16 = [mem16]
1038 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1039 "cmovge\t{$src2, $dst|$dst, $src2}",
1040 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1041 X86_COND_GE, EFLAGS))]>,
1042 TB, OpSize;
1043def CMOVGE32rm: I<0x4D, MRMSrcMem, // if >=s, GR32 = [mem32]
1044 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1045 "cmovge\t{$src2, $dst|$dst, $src2}",
1046 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1047 X86_COND_GE, EFLAGS))]>,
1048 TB;
1049def CMOVLE16rm: I<0x4E, MRMSrcMem, // if <=s, GR16 = [mem16]
1050 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1051 "cmovle\t{$src2, $dst|$dst, $src2}",
1052 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1053 X86_COND_LE, EFLAGS))]>,
1054 TB, OpSize;
1055def CMOVLE32rm: I<0x4E, MRMSrcMem, // if <=s, GR32 = [mem32]
1056 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1057 "cmovle\t{$src2, $dst|$dst, $src2}",
1058 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1059 X86_COND_LE, EFLAGS))]>,
1060 TB;
1061def CMOVG16rm : I<0x4F, MRMSrcMem, // if >s, GR16 = [mem16]
1062 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1063 "cmovg\t{$src2, $dst|$dst, $src2}",
1064 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1065 X86_COND_G, EFLAGS))]>,
1066 TB, OpSize;
1067def CMOVG32rm : I<0x4F, MRMSrcMem, // if >s, GR32 = [mem32]
1068 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1069 "cmovg\t{$src2, $dst|$dst, $src2}",
1070 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1071 X86_COND_G, EFLAGS))]>,
1072 TB;
1073def CMOVS16rm : I<0x48, MRMSrcMem, // if signed, GR16 = [mem16]
1074 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1075 "cmovs\t{$src2, $dst|$dst, $src2}",
1076 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1077 X86_COND_S, EFLAGS))]>,
1078 TB, OpSize;
1079def CMOVS32rm : I<0x48, MRMSrcMem, // if signed, GR32 = [mem32]
1080 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1081 "cmovs\t{$src2, $dst|$dst, $src2}",
1082 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1083 X86_COND_S, EFLAGS))]>,
1084 TB;
1085def CMOVNS16rm: I<0x49, MRMSrcMem, // if !signed, GR16 = [mem16]
1086 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1087 "cmovns\t{$src2, $dst|$dst, $src2}",
1088 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1089 X86_COND_NS, EFLAGS))]>,
1090 TB, OpSize;
1091def CMOVNS32rm: I<0x49, MRMSrcMem, // if !signed, GR32 = [mem32]
1092 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1093 "cmovns\t{$src2, $dst|$dst, $src2}",
1094 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1095 X86_COND_NS, EFLAGS))]>,
1096 TB;
1097def CMOVP16rm : I<0x4A, MRMSrcMem, // if parity, GR16 = [mem16]
1098 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1099 "cmovp\t{$src2, $dst|$dst, $src2}",
1100 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1101 X86_COND_P, EFLAGS))]>,
1102 TB, OpSize;
1103def CMOVP32rm : I<0x4A, MRMSrcMem, // if parity, GR32 = [mem32]
1104 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1105 "cmovp\t{$src2, $dst|$dst, $src2}",
1106 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1107 X86_COND_P, EFLAGS))]>,
1108 TB;
1109def CMOVNP16rm : I<0x4B, MRMSrcMem, // if !parity, GR16 = [mem16]
1110 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1111 "cmovnp\t{$src2, $dst|$dst, $src2}",
1112 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1113 X86_COND_NP, EFLAGS))]>,
1114 TB, OpSize;
Evan Cheng950aac02007-09-25 01:57:46 +00001115} // Uses = [EFLAGS]
1116
1117
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001118// unary instructions
1119let CodeSize = 2 in {
Evan Cheng55687072007-09-14 21:48:26 +00001120let Defs = [EFLAGS] in {
Dan Gohman91888f02007-07-31 20:11:57 +00001121def NEG8r : I<0xF6, MRM3r, (outs GR8 :$dst), (ins GR8 :$src), "neg{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001122 [(set GR8:$dst, (ineg GR8:$src))]>;
Dan Gohman91888f02007-07-31 20:11:57 +00001123def NEG16r : I<0xF7, MRM3r, (outs GR16:$dst), (ins GR16:$src), "neg{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001124 [(set GR16:$dst, (ineg GR16:$src))]>, OpSize;
Dan Gohman91888f02007-07-31 20:11:57 +00001125def NEG32r : I<0xF7, MRM3r, (outs GR32:$dst), (ins GR32:$src), "neg{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001126 [(set GR32:$dst, (ineg GR32:$src))]>;
1127let isTwoAddress = 0 in {
Dan Gohman91888f02007-07-31 20:11:57 +00001128 def NEG8m : I<0xF6, MRM3m, (outs), (ins i8mem :$dst), "neg{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001129 [(store (ineg (loadi8 addr:$dst)), addr:$dst)]>;
Dan Gohman91888f02007-07-31 20:11:57 +00001130 def NEG16m : I<0xF7, MRM3m, (outs), (ins i16mem:$dst), "neg{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001131 [(store (ineg (loadi16 addr:$dst)), addr:$dst)]>, OpSize;
Dan Gohman91888f02007-07-31 20:11:57 +00001132 def NEG32m : I<0xF7, MRM3m, (outs), (ins i32mem:$dst), "neg{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001133 [(store (ineg (loadi32 addr:$dst)), addr:$dst)]>;
1134
1135}
Evan Cheng55687072007-09-14 21:48:26 +00001136} // Defs = [EFLAGS]
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001137
Dan Gohman91888f02007-07-31 20:11:57 +00001138def NOT8r : I<0xF6, MRM2r, (outs GR8 :$dst), (ins GR8 :$src), "not{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001139 [(set GR8:$dst, (not GR8:$src))]>;
Dan Gohman91888f02007-07-31 20:11:57 +00001140def NOT16r : I<0xF7, MRM2r, (outs GR16:$dst), (ins GR16:$src), "not{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001141 [(set GR16:$dst, (not GR16:$src))]>, OpSize;
Dan Gohman91888f02007-07-31 20:11:57 +00001142def NOT32r : I<0xF7, MRM2r, (outs GR32:$dst), (ins GR32:$src), "not{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001143 [(set GR32:$dst, (not GR32:$src))]>;
1144let isTwoAddress = 0 in {
Dan Gohman91888f02007-07-31 20:11:57 +00001145 def NOT8m : I<0xF6, MRM2m, (outs), (ins i8mem :$dst), "not{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001146 [(store (not (loadi8 addr:$dst)), addr:$dst)]>;
Dan Gohman91888f02007-07-31 20:11:57 +00001147 def NOT16m : I<0xF7, MRM2m, (outs), (ins i16mem:$dst), "not{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001148 [(store (not (loadi16 addr:$dst)), addr:$dst)]>, OpSize;
Dan Gohman91888f02007-07-31 20:11:57 +00001149 def NOT32m : I<0xF7, MRM2m, (outs), (ins i32mem:$dst), "not{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001150 [(store (not (loadi32 addr:$dst)), addr:$dst)]>;
1151}
1152} // CodeSize
1153
1154// TODO: inc/dec is slow for P4, but fast for Pentium-M.
Evan Cheng55687072007-09-14 21:48:26 +00001155let Defs = [EFLAGS] in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001156let CodeSize = 2 in
Dan Gohman91888f02007-07-31 20:11:57 +00001157def INC8r : I<0xFE, MRM0r, (outs GR8 :$dst), (ins GR8 :$src), "inc{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001158 [(set GR8:$dst, (add GR8:$src, 1))]>;
1159let isConvertibleToThreeAddress = 1, CodeSize = 1 in { // Can xform into LEA.
Dan Gohman91888f02007-07-31 20:11:57 +00001160def INC16r : I<0x40, AddRegFrm, (outs GR16:$dst), (ins GR16:$src), "inc{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001161 [(set GR16:$dst, (add GR16:$src, 1))]>,
1162 OpSize, Requires<[In32BitMode]>;
Dan Gohman91888f02007-07-31 20:11:57 +00001163def INC32r : I<0x40, AddRegFrm, (outs GR32:$dst), (ins GR32:$src), "inc{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001164 [(set GR32:$dst, (add GR32:$src, 1))]>, Requires<[In32BitMode]>;
1165}
1166let isTwoAddress = 0, CodeSize = 2 in {
Dan Gohman91888f02007-07-31 20:11:57 +00001167 def INC8m : I<0xFE, MRM0m, (outs), (ins i8mem :$dst), "inc{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001168 [(store (add (loadi8 addr:$dst), 1), addr:$dst)]>;
Dan Gohman91888f02007-07-31 20:11:57 +00001169 def INC16m : I<0xFF, MRM0m, (outs), (ins i16mem:$dst), "inc{w}\t$dst",
Evan Cheng4a7e72f2007-10-19 21:23:22 +00001170 [(store (add (loadi16 addr:$dst), 1), addr:$dst)]>,
1171 OpSize, Requires<[In32BitMode]>;
Dan Gohman91888f02007-07-31 20:11:57 +00001172 def INC32m : I<0xFF, MRM0m, (outs), (ins i32mem:$dst), "inc{l}\t$dst",
Evan Cheng4a7e72f2007-10-19 21:23:22 +00001173 [(store (add (loadi32 addr:$dst), 1), addr:$dst)]>,
1174 Requires<[In32BitMode]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001175}
1176
1177let CodeSize = 2 in
Dan Gohman91888f02007-07-31 20:11:57 +00001178def DEC8r : I<0xFE, MRM1r, (outs GR8 :$dst), (ins GR8 :$src), "dec{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001179 [(set GR8:$dst, (add GR8:$src, -1))]>;
1180let isConvertibleToThreeAddress = 1, CodeSize = 1 in { // Can xform into LEA.
Dan Gohman91888f02007-07-31 20:11:57 +00001181def DEC16r : I<0x48, AddRegFrm, (outs GR16:$dst), (ins GR16:$src), "dec{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001182 [(set GR16:$dst, (add GR16:$src, -1))]>,
1183 OpSize, Requires<[In32BitMode]>;
Dan Gohman91888f02007-07-31 20:11:57 +00001184def DEC32r : I<0x48, AddRegFrm, (outs GR32:$dst), (ins GR32:$src), "dec{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001185 [(set GR32:$dst, (add GR32:$src, -1))]>, Requires<[In32BitMode]>;
1186}
1187
1188let isTwoAddress = 0, CodeSize = 2 in {
Dan Gohman91888f02007-07-31 20:11:57 +00001189 def DEC8m : I<0xFE, MRM1m, (outs), (ins i8mem :$dst), "dec{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001190 [(store (add (loadi8 addr:$dst), -1), addr:$dst)]>;
Dan Gohman91888f02007-07-31 20:11:57 +00001191 def DEC16m : I<0xFF, MRM1m, (outs), (ins i16mem:$dst), "dec{w}\t$dst",
Evan Cheng4a7e72f2007-10-19 21:23:22 +00001192 [(store (add (loadi16 addr:$dst), -1), addr:$dst)]>,
1193 OpSize, Requires<[In32BitMode]>;
Dan Gohman91888f02007-07-31 20:11:57 +00001194 def DEC32m : I<0xFF, MRM1m, (outs), (ins i32mem:$dst), "dec{l}\t$dst",
Evan Cheng4a7e72f2007-10-19 21:23:22 +00001195 [(store (add (loadi32 addr:$dst), -1), addr:$dst)]>,
1196 Requires<[In32BitMode]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001197}
Evan Cheng55687072007-09-14 21:48:26 +00001198} // Defs = [EFLAGS]
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001199
1200// Logical operators...
Evan Cheng55687072007-09-14 21:48:26 +00001201let Defs = [EFLAGS] in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001202let isCommutable = 1 in { // X = AND Y, Z --> X = AND Z, Y
1203def AND8rr : I<0x20, MRMDestReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001204 (outs GR8 :$dst), (ins GR8 :$src1, GR8 :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001205 "and{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001206 [(set GR8:$dst, (and GR8:$src1, GR8:$src2))]>;
1207def AND16rr : I<0x21, MRMDestReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001208 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001209 "and{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001210 [(set GR16:$dst, (and GR16:$src1, GR16:$src2))]>, OpSize;
1211def AND32rr : I<0x21, MRMDestReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001212 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001213 "and{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001214 [(set GR32:$dst, (and GR32:$src1, GR32:$src2))]>;
1215}
1216
1217def AND8rm : I<0x22, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001218 (outs GR8 :$dst), (ins GR8 :$src1, i8mem :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001219 "and{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001220 [(set GR8:$dst, (and GR8:$src1, (load addr:$src2)))]>;
1221def AND16rm : I<0x23, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001222 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001223 "and{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001224 [(set GR16:$dst, (and GR16:$src1, (load addr:$src2)))]>, OpSize;
1225def AND32rm : I<0x23, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001226 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001227 "and{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001228 [(set GR32:$dst, (and GR32:$src1, (load addr:$src2)))]>;
1229
1230def AND8ri : Ii8<0x80, MRM4r,
Evan Chengb783fa32007-07-19 01:14:50 +00001231 (outs GR8 :$dst), (ins GR8 :$src1, i8imm :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001232 "and{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001233 [(set GR8:$dst, (and GR8:$src1, imm:$src2))]>;
1234def AND16ri : Ii16<0x81, MRM4r,
Evan Chengb783fa32007-07-19 01:14:50 +00001235 (outs GR16:$dst), (ins GR16:$src1, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001236 "and{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001237 [(set GR16:$dst, (and GR16:$src1, imm:$src2))]>, OpSize;
1238def AND32ri : Ii32<0x81, MRM4r,
Evan Chengb783fa32007-07-19 01:14:50 +00001239 (outs GR32:$dst), (ins GR32:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001240 "and{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001241 [(set GR32:$dst, (and GR32:$src1, imm:$src2))]>;
1242def AND16ri8 : Ii8<0x83, MRM4r,
Evan Chengb783fa32007-07-19 01:14:50 +00001243 (outs GR16:$dst), (ins GR16:$src1, i16i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001244 "and{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001245 [(set GR16:$dst, (and GR16:$src1, i16immSExt8:$src2))]>,
1246 OpSize;
1247def AND32ri8 : Ii8<0x83, MRM4r,
Evan Chengb783fa32007-07-19 01:14:50 +00001248 (outs GR32:$dst), (ins GR32:$src1, i32i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001249 "and{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001250 [(set GR32:$dst, (and GR32:$src1, i32immSExt8:$src2))]>;
1251
1252let isTwoAddress = 0 in {
1253 def AND8mr : I<0x20, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001254 (outs), (ins i8mem :$dst, GR8 :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001255 "and{b}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001256 [(store (and (load addr:$dst), GR8:$src), addr:$dst)]>;
1257 def AND16mr : I<0x21, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001258 (outs), (ins i16mem:$dst, GR16:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001259 "and{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001260 [(store (and (load addr:$dst), GR16:$src), addr:$dst)]>,
1261 OpSize;
1262 def AND32mr : I<0x21, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001263 (outs), (ins i32mem:$dst, GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001264 "and{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001265 [(store (and (load addr:$dst), GR32:$src), addr:$dst)]>;
1266 def AND8mi : Ii8<0x80, MRM4m,
Evan Chengb783fa32007-07-19 01:14:50 +00001267 (outs), (ins i8mem :$dst, i8imm :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001268 "and{b}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001269 [(store (and (loadi8 addr:$dst), imm:$src), addr:$dst)]>;
1270 def AND16mi : Ii16<0x81, MRM4m,
Evan Chengb783fa32007-07-19 01:14:50 +00001271 (outs), (ins i16mem:$dst, i16imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001272 "and{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001273 [(store (and (loadi16 addr:$dst), imm:$src), addr:$dst)]>,
1274 OpSize;
1275 def AND32mi : Ii32<0x81, MRM4m,
Evan Chengb783fa32007-07-19 01:14:50 +00001276 (outs), (ins i32mem:$dst, i32imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001277 "and{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001278 [(store (and (loadi32 addr:$dst), imm:$src), addr:$dst)]>;
1279 def AND16mi8 : Ii8<0x83, MRM4m,
Evan Chengb783fa32007-07-19 01:14:50 +00001280 (outs), (ins i16mem:$dst, i16i8imm :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001281 "and{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001282 [(store (and (load addr:$dst), i16immSExt8:$src), addr:$dst)]>,
1283 OpSize;
1284 def AND32mi8 : Ii8<0x83, MRM4m,
Evan Chengb783fa32007-07-19 01:14:50 +00001285 (outs), (ins i32mem:$dst, i32i8imm :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001286 "and{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001287 [(store (and (load addr:$dst), i32immSExt8:$src), addr:$dst)]>;
1288}
1289
1290
1291let isCommutable = 1 in { // X = OR Y, Z --> X = OR Z, Y
Evan Chengb783fa32007-07-19 01:14:50 +00001292def OR8rr : I<0x08, MRMDestReg, (outs GR8 :$dst), (ins GR8 :$src1, GR8 :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001293 "or{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001294 [(set GR8:$dst, (or GR8:$src1, GR8:$src2))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001295def OR16rr : I<0x09, MRMDestReg, (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001296 "or{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001297 [(set GR16:$dst, (or GR16:$src1, GR16:$src2))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001298def OR32rr : I<0x09, MRMDestReg, (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001299 "or{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001300 [(set GR32:$dst, (or GR32:$src1, GR32:$src2))]>;
1301}
Evan Chengb783fa32007-07-19 01:14:50 +00001302def OR8rm : I<0x0A, MRMSrcMem , (outs GR8 :$dst), (ins GR8 :$src1, i8mem :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001303 "or{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001304 [(set GR8:$dst, (or GR8:$src1, (load addr:$src2)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001305def OR16rm : I<0x0B, MRMSrcMem , (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001306 "or{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001307 [(set GR16:$dst, (or GR16:$src1, (load addr:$src2)))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001308def OR32rm : I<0x0B, MRMSrcMem , (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001309 "or{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001310 [(set GR32:$dst, (or GR32:$src1, (load addr:$src2)))]>;
1311
Evan Chengb783fa32007-07-19 01:14:50 +00001312def OR8ri : Ii8 <0x80, MRM1r, (outs GR8 :$dst), (ins GR8 :$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001313 "or{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001314 [(set GR8:$dst, (or GR8:$src1, imm:$src2))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001315def OR16ri : Ii16<0x81, MRM1r, (outs GR16:$dst), (ins GR16:$src1, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001316 "or{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001317 [(set GR16:$dst, (or GR16:$src1, imm:$src2))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001318def OR32ri : Ii32<0x81, MRM1r, (outs GR32:$dst), (ins GR32:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001319 "or{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001320 [(set GR32:$dst, (or GR32:$src1, imm:$src2))]>;
1321
Evan Chengb783fa32007-07-19 01:14:50 +00001322def OR16ri8 : Ii8<0x83, MRM1r, (outs GR16:$dst), (ins GR16:$src1, i16i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001323 "or{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001324 [(set GR16:$dst, (or GR16:$src1, i16immSExt8:$src2))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001325def OR32ri8 : Ii8<0x83, MRM1r, (outs GR32:$dst), (ins GR32:$src1, i32i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001326 "or{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001327 [(set GR32:$dst, (or GR32:$src1, i32immSExt8:$src2))]>;
1328let isTwoAddress = 0 in {
Evan Chengb783fa32007-07-19 01:14:50 +00001329 def OR8mr : I<0x08, MRMDestMem, (outs), (ins i8mem:$dst, GR8:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001330 "or{b}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001331 [(store (or (load addr:$dst), GR8:$src), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001332 def OR16mr : I<0x09, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001333 "or{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001334 [(store (or (load addr:$dst), GR16:$src), addr:$dst)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001335 def OR32mr : I<0x09, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001336 "or{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001337 [(store (or (load addr:$dst), GR32:$src), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001338 def OR8mi : Ii8<0x80, MRM1m, (outs), (ins i8mem :$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001339 "or{b}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001340 [(store (or (loadi8 addr:$dst), imm:$src), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001341 def OR16mi : Ii16<0x81, MRM1m, (outs), (ins i16mem:$dst, i16imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001342 "or{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001343 [(store (or (loadi16 addr:$dst), imm:$src), addr:$dst)]>,
1344 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001345 def OR32mi : Ii32<0x81, MRM1m, (outs), (ins i32mem:$dst, i32imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001346 "or{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001347 [(store (or (loadi32 addr:$dst), imm:$src), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001348 def OR16mi8 : Ii8<0x83, MRM1m, (outs), (ins i16mem:$dst, i16i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001349 "or{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001350 [(store (or (load addr:$dst), i16immSExt8:$src), addr:$dst)]>,
1351 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001352 def OR32mi8 : Ii8<0x83, MRM1m, (outs), (ins i32mem:$dst, i32i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001353 "or{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001354 [(store (or (load addr:$dst), i32immSExt8:$src), addr:$dst)]>;
Bill Wendlingba5d5b02008-05-29 01:02:09 +00001355} // isTwoAddress = 0
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001356
1357
Evan Cheng6f26e8b2008-06-18 08:13:07 +00001358let isCommutable = 1 in { // X = XOR Y, Z --> X = XOR Z, Y
Bill Wendlingba5d5b02008-05-29 01:02:09 +00001359 def XOR8rr : I<0x30, MRMDestReg,
1360 (outs GR8 :$dst), (ins GR8 :$src1, GR8 :$src2),
1361 "xor{b}\t{$src2, $dst|$dst, $src2}",
1362 [(set GR8:$dst, (xor GR8:$src1, GR8:$src2))]>;
1363 def XOR16rr : I<0x31, MRMDestReg,
1364 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
1365 "xor{w}\t{$src2, $dst|$dst, $src2}",
1366 [(set GR16:$dst, (xor GR16:$src1, GR16:$src2))]>, OpSize;
1367 def XOR32rr : I<0x31, MRMDestReg,
1368 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
1369 "xor{l}\t{$src2, $dst|$dst, $src2}",
1370 [(set GR32:$dst, (xor GR32:$src1, GR32:$src2))]>;
Evan Cheng6f26e8b2008-06-18 08:13:07 +00001371} // isCommutable = 1
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001372
1373def XOR8rm : I<0x32, MRMSrcMem ,
Evan Chengb783fa32007-07-19 01:14:50 +00001374 (outs GR8 :$dst), (ins GR8:$src1, i8mem :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001375 "xor{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001376 [(set GR8:$dst, (xor GR8:$src1, (load addr:$src2)))]>;
1377def XOR16rm : I<0x33, MRMSrcMem ,
Evan Chengb783fa32007-07-19 01:14:50 +00001378 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001379 "xor{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingba5d5b02008-05-29 01:02:09 +00001380 [(set GR16:$dst, (xor GR16:$src1, (load addr:$src2)))]>,
1381 OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001382def XOR32rm : I<0x33, MRMSrcMem ,
Evan Chengb783fa32007-07-19 01:14:50 +00001383 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001384 "xor{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001385 [(set GR32:$dst, (xor GR32:$src1, (load addr:$src2)))]>;
1386
Bill Wendlingbac38eb2008-05-29 03:46:36 +00001387def XOR8ri : Ii8<0x80, MRM6r,
1388 (outs GR8:$dst), (ins GR8:$src1, i8imm:$src2),
1389 "xor{b}\t{$src2, $dst|$dst, $src2}",
1390 [(set GR8:$dst, (xor GR8:$src1, imm:$src2))]>;
1391def XOR16ri : Ii16<0x81, MRM6r,
1392 (outs GR16:$dst), (ins GR16:$src1, i16imm:$src2),
1393 "xor{w}\t{$src2, $dst|$dst, $src2}",
1394 [(set GR16:$dst, (xor GR16:$src1, imm:$src2))]>, OpSize;
1395def XOR32ri : Ii32<0x81, MRM6r,
1396 (outs GR32:$dst), (ins GR32:$src1, i32imm:$src2),
1397 "xor{l}\t{$src2, $dst|$dst, $src2}",
1398 [(set GR32:$dst, (xor GR32:$src1, imm:$src2))]>;
1399def XOR16ri8 : Ii8<0x83, MRM6r,
1400 (outs GR16:$dst), (ins GR16:$src1, i16i8imm:$src2),
1401 "xor{w}\t{$src2, $dst|$dst, $src2}",
1402 [(set GR16:$dst, (xor GR16:$src1, i16immSExt8:$src2))]>,
1403 OpSize;
1404def XOR32ri8 : Ii8<0x83, MRM6r,
1405 (outs GR32:$dst), (ins GR32:$src1, i32i8imm:$src2),
1406 "xor{l}\t{$src2, $dst|$dst, $src2}",
1407 [(set GR32:$dst, (xor GR32:$src1, i32immSExt8:$src2))]>;
Bill Wendlingba5d5b02008-05-29 01:02:09 +00001408
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001409let isTwoAddress = 0 in {
1410 def XOR8mr : I<0x30, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001411 (outs), (ins i8mem :$dst, GR8 :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001412 "xor{b}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001413 [(store (xor (load addr:$dst), GR8:$src), addr:$dst)]>;
1414 def XOR16mr : I<0x31, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001415 (outs), (ins i16mem:$dst, GR16:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001416 "xor{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001417 [(store (xor (load addr:$dst), GR16:$src), addr:$dst)]>,
1418 OpSize;
1419 def XOR32mr : I<0x31, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001420 (outs), (ins i32mem:$dst, GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001421 "xor{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001422 [(store (xor (load addr:$dst), GR32:$src), addr:$dst)]>;
1423 def XOR8mi : Ii8<0x80, MRM6m,
Evan Chengb783fa32007-07-19 01:14:50 +00001424 (outs), (ins i8mem :$dst, i8imm :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001425 "xor{b}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001426 [(store (xor (loadi8 addr:$dst), imm:$src), addr:$dst)]>;
1427 def XOR16mi : Ii16<0x81, MRM6m,
Evan Chengb783fa32007-07-19 01:14:50 +00001428 (outs), (ins i16mem:$dst, i16imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001429 "xor{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001430 [(store (xor (loadi16 addr:$dst), imm:$src), addr:$dst)]>,
1431 OpSize;
1432 def XOR32mi : Ii32<0x81, MRM6m,
Evan Chengb783fa32007-07-19 01:14:50 +00001433 (outs), (ins i32mem:$dst, i32imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001434 "xor{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001435 [(store (xor (loadi32 addr:$dst), imm:$src), addr:$dst)]>;
1436 def XOR16mi8 : Ii8<0x83, MRM6m,
Evan Chengb783fa32007-07-19 01:14:50 +00001437 (outs), (ins i16mem:$dst, i16i8imm :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001438 "xor{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001439 [(store (xor (load addr:$dst), i16immSExt8:$src), addr:$dst)]>,
1440 OpSize;
1441 def XOR32mi8 : Ii8<0x83, MRM6m,
Evan Chengb783fa32007-07-19 01:14:50 +00001442 (outs), (ins i32mem:$dst, i32i8imm :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001443 "xor{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001444 [(store (xor (load addr:$dst), i32immSExt8:$src), addr:$dst)]>;
Bill Wendlingba5d5b02008-05-29 01:02:09 +00001445} // isTwoAddress = 0
Evan Cheng55687072007-09-14 21:48:26 +00001446} // Defs = [EFLAGS]
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001447
1448// Shift instructions
Evan Cheng55687072007-09-14 21:48:26 +00001449let Defs = [EFLAGS] in {
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001450let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00001451def SHL8rCL : I<0xD2, MRM4r, (outs GR8 :$dst), (ins GR8 :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001452 "shl{b}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001453 [(set GR8:$dst, (shl GR8:$src, CL))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001454def SHL16rCL : I<0xD3, MRM4r, (outs GR16:$dst), (ins GR16:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001455 "shl{w}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001456 [(set GR16:$dst, (shl GR16:$src, CL))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001457def SHL32rCL : I<0xD3, MRM4r, (outs GR32:$dst), (ins GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001458 "shl{l}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001459 [(set GR32:$dst, (shl GR32:$src, CL))]>;
Bill Wendlingba5d5b02008-05-29 01:02:09 +00001460} // Uses = [CL]
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001461
Evan Chengb783fa32007-07-19 01:14:50 +00001462def SHL8ri : Ii8<0xC0, MRM4r, (outs GR8 :$dst), (ins GR8 :$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001463 "shl{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001464 [(set GR8:$dst, (shl GR8:$src1, (i8 imm:$src2)))]>;
1465let isConvertibleToThreeAddress = 1 in { // Can transform into LEA.
Evan Chengb783fa32007-07-19 01:14:50 +00001466def SHL16ri : Ii8<0xC1, MRM4r, (outs GR16:$dst), (ins GR16:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001467 "shl{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001468 [(set GR16:$dst, (shl GR16:$src1, (i8 imm:$src2)))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001469def SHL32ri : Ii8<0xC1, MRM4r, (outs GR32:$dst), (ins GR32:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001470 "shl{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001471 [(set GR32:$dst, (shl GR32:$src1, (i8 imm:$src2)))]>;
Chris Lattnerf4005a82008-01-11 18:00:50 +00001472// NOTE: We don't use shifts of a register by one, because 'add reg,reg' is
1473// cheaper.
Bill Wendlingba5d5b02008-05-29 01:02:09 +00001474} // isConvertibleToThreeAddress = 1
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001475
1476let isTwoAddress = 0 in {
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001477 let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00001478 def SHL8mCL : I<0xD2, MRM4m, (outs), (ins i8mem :$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001479 "shl{b}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001480 [(store (shl (loadi8 addr:$dst), CL), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001481 def SHL16mCL : I<0xD3, MRM4m, (outs), (ins i16mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001482 "shl{w}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001483 [(store (shl (loadi16 addr:$dst), CL), addr:$dst)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001484 def SHL32mCL : I<0xD3, MRM4m, (outs), (ins i32mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001485 "shl{l}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001486 [(store (shl (loadi32 addr:$dst), CL), addr:$dst)]>;
1487 }
Evan Chengb783fa32007-07-19 01:14:50 +00001488 def SHL8mi : Ii8<0xC0, MRM4m, (outs), (ins i8mem :$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001489 "shl{b}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001490 [(store (shl (loadi8 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001491 def SHL16mi : Ii8<0xC1, MRM4m, (outs), (ins i16mem:$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001492 "shl{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001493 [(store (shl (loadi16 addr:$dst), (i8 imm:$src)), addr:$dst)]>,
1494 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001495 def SHL32mi : Ii8<0xC1, MRM4m, (outs), (ins i32mem:$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001496 "shl{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001497 [(store (shl (loadi32 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
1498
1499 // Shift by 1
Evan Chengb783fa32007-07-19 01:14:50 +00001500 def SHL8m1 : I<0xD0, MRM4m, (outs), (ins i8mem :$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001501 "shl{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001502 [(store (shl (loadi8 addr:$dst), (i8 1)), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001503 def SHL16m1 : I<0xD1, MRM4m, (outs), (ins i16mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001504 "shl{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001505 [(store (shl (loadi16 addr:$dst), (i8 1)), addr:$dst)]>,
1506 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001507 def SHL32m1 : I<0xD1, MRM4m, (outs), (ins i32mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001508 "shl{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001509 [(store (shl (loadi32 addr:$dst), (i8 1)), addr:$dst)]>;
1510}
1511
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001512let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00001513def SHR8rCL : I<0xD2, MRM5r, (outs GR8 :$dst), (ins GR8 :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001514 "shr{b}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001515 [(set GR8:$dst, (srl GR8:$src, CL))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001516def SHR16rCL : I<0xD3, MRM5r, (outs GR16:$dst), (ins GR16:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001517 "shr{w}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001518 [(set GR16:$dst, (srl GR16:$src, CL))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001519def SHR32rCL : I<0xD3, MRM5r, (outs GR32:$dst), (ins GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001520 "shr{l}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001521 [(set GR32:$dst, (srl GR32:$src, CL))]>;
1522}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001523
Evan Chengb783fa32007-07-19 01:14:50 +00001524def SHR8ri : Ii8<0xC0, MRM5r, (outs GR8:$dst), (ins GR8:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001525 "shr{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001526 [(set GR8:$dst, (srl GR8:$src1, (i8 imm:$src2)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001527def SHR16ri : Ii8<0xC1, MRM5r, (outs GR16:$dst), (ins GR16:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001528 "shr{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001529 [(set GR16:$dst, (srl GR16:$src1, (i8 imm:$src2)))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001530def SHR32ri : Ii8<0xC1, MRM5r, (outs GR32:$dst), (ins GR32:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001531 "shr{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001532 [(set GR32:$dst, (srl GR32:$src1, (i8 imm:$src2)))]>;
1533
1534// Shift by 1
Evan Chengb783fa32007-07-19 01:14:50 +00001535def SHR8r1 : I<0xD0, MRM5r, (outs GR8:$dst), (ins GR8:$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00001536 "shr{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001537 [(set GR8:$dst, (srl GR8:$src1, (i8 1)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001538def SHR16r1 : I<0xD1, MRM5r, (outs GR16:$dst), (ins GR16:$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00001539 "shr{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001540 [(set GR16:$dst, (srl GR16:$src1, (i8 1)))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001541def SHR32r1 : I<0xD1, MRM5r, (outs GR32:$dst), (ins GR32:$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00001542 "shr{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001543 [(set GR32:$dst, (srl GR32:$src1, (i8 1)))]>;
1544
1545let isTwoAddress = 0 in {
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001546 let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00001547 def SHR8mCL : I<0xD2, MRM5m, (outs), (ins i8mem :$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001548 "shr{b}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001549 [(store (srl (loadi8 addr:$dst), CL), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001550 def SHR16mCL : I<0xD3, MRM5m, (outs), (ins i16mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001551 "shr{w}\t{%cl, $dst|$dst, %CL}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001552 [(store (srl (loadi16 addr:$dst), CL), addr:$dst)]>,
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001553 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001554 def SHR32mCL : I<0xD3, MRM5m, (outs), (ins i32mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001555 "shr{l}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001556 [(store (srl (loadi32 addr:$dst), CL), addr:$dst)]>;
1557 }
Evan Chengb783fa32007-07-19 01:14:50 +00001558 def SHR8mi : Ii8<0xC0, MRM5m, (outs), (ins i8mem :$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001559 "shr{b}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001560 [(store (srl (loadi8 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001561 def SHR16mi : Ii8<0xC1, MRM5m, (outs), (ins i16mem:$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001562 "shr{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001563 [(store (srl (loadi16 addr:$dst), (i8 imm:$src)), addr:$dst)]>,
1564 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001565 def SHR32mi : Ii8<0xC1, MRM5m, (outs), (ins i32mem:$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001566 "shr{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001567 [(store (srl (loadi32 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
1568
1569 // Shift by 1
Evan Chengb783fa32007-07-19 01:14:50 +00001570 def SHR8m1 : I<0xD0, MRM5m, (outs), (ins i8mem :$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001571 "shr{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001572 [(store (srl (loadi8 addr:$dst), (i8 1)), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001573 def SHR16m1 : I<0xD1, MRM5m, (outs), (ins i16mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001574 "shr{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001575 [(store (srl (loadi16 addr:$dst), (i8 1)), addr:$dst)]>,OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001576 def SHR32m1 : I<0xD1, MRM5m, (outs), (ins i32mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001577 "shr{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001578 [(store (srl (loadi32 addr:$dst), (i8 1)), addr:$dst)]>;
1579}
1580
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001581let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00001582def SAR8rCL : I<0xD2, MRM7r, (outs GR8 :$dst), (ins GR8 :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001583 "sar{b}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001584 [(set GR8:$dst, (sra GR8:$src, CL))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001585def SAR16rCL : I<0xD3, MRM7r, (outs GR16:$dst), (ins GR16:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001586 "sar{w}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001587 [(set GR16:$dst, (sra GR16:$src, CL))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001588def SAR32rCL : I<0xD3, MRM7r, (outs GR32:$dst), (ins GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001589 "sar{l}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001590 [(set GR32:$dst, (sra GR32:$src, CL))]>;
1591}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001592
Evan Chengb783fa32007-07-19 01:14:50 +00001593def SAR8ri : Ii8<0xC0, MRM7r, (outs GR8 :$dst), (ins GR8 :$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001594 "sar{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001595 [(set GR8:$dst, (sra GR8:$src1, (i8 imm:$src2)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001596def SAR16ri : Ii8<0xC1, MRM7r, (outs GR16:$dst), (ins GR16:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001597 "sar{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001598 [(set GR16:$dst, (sra GR16:$src1, (i8 imm:$src2)))]>,
1599 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001600def SAR32ri : Ii8<0xC1, MRM7r, (outs GR32:$dst), (ins GR32:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001601 "sar{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001602 [(set GR32:$dst, (sra GR32:$src1, (i8 imm:$src2)))]>;
1603
1604// Shift by 1
Evan Chengb783fa32007-07-19 01:14:50 +00001605def SAR8r1 : I<0xD0, MRM7r, (outs GR8 :$dst), (ins GR8 :$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00001606 "sar{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001607 [(set GR8:$dst, (sra GR8:$src1, (i8 1)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001608def SAR16r1 : I<0xD1, MRM7r, (outs GR16:$dst), (ins GR16:$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00001609 "sar{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001610 [(set GR16:$dst, (sra GR16:$src1, (i8 1)))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001611def SAR32r1 : I<0xD1, MRM7r, (outs GR32:$dst), (ins GR32:$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00001612 "sar{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001613 [(set GR32:$dst, (sra GR32:$src1, (i8 1)))]>;
1614
1615let isTwoAddress = 0 in {
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001616 let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00001617 def SAR8mCL : I<0xD2, MRM7m, (outs), (ins i8mem :$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001618 "sar{b}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001619 [(store (sra (loadi8 addr:$dst), CL), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001620 def SAR16mCL : I<0xD3, MRM7m, (outs), (ins i16mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001621 "sar{w}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001622 [(store (sra (loadi16 addr:$dst), CL), addr:$dst)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001623 def SAR32mCL : I<0xD3, MRM7m, (outs), (ins i32mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001624 "sar{l}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001625 [(store (sra (loadi32 addr:$dst), CL), addr:$dst)]>;
1626 }
Evan Chengb783fa32007-07-19 01:14:50 +00001627 def SAR8mi : Ii8<0xC0, MRM7m, (outs), (ins i8mem :$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001628 "sar{b}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001629 [(store (sra (loadi8 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001630 def SAR16mi : Ii8<0xC1, MRM7m, (outs), (ins i16mem:$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001631 "sar{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001632 [(store (sra (loadi16 addr:$dst), (i8 imm:$src)), addr:$dst)]>,
1633 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001634 def SAR32mi : Ii8<0xC1, MRM7m, (outs), (ins i32mem:$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001635 "sar{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001636 [(store (sra (loadi32 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
1637
1638 // Shift by 1
Evan Chengb783fa32007-07-19 01:14:50 +00001639 def SAR8m1 : I<0xD0, MRM7m, (outs), (ins i8mem :$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001640 "sar{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001641 [(store (sra (loadi8 addr:$dst), (i8 1)), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001642 def SAR16m1 : I<0xD1, MRM7m, (outs), (ins i16mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001643 "sar{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001644 [(store (sra (loadi16 addr:$dst), (i8 1)), addr:$dst)]>,
1645 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001646 def SAR32m1 : I<0xD1, MRM7m, (outs), (ins i32mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001647 "sar{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001648 [(store (sra (loadi32 addr:$dst), (i8 1)), addr:$dst)]>;
1649}
1650
1651// Rotate instructions
1652// FIXME: provide shorter instructions when imm8 == 1
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001653let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00001654def ROL8rCL : I<0xD2, MRM0r, (outs GR8 :$dst), (ins GR8 :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001655 "rol{b}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001656 [(set GR8:$dst, (rotl GR8:$src, CL))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001657def ROL16rCL : I<0xD3, MRM0r, (outs GR16:$dst), (ins GR16:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001658 "rol{w}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001659 [(set GR16:$dst, (rotl GR16:$src, CL))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001660def ROL32rCL : I<0xD3, MRM0r, (outs GR32:$dst), (ins GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001661 "rol{l}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001662 [(set GR32:$dst, (rotl GR32:$src, CL))]>;
1663}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001664
Evan Chengb783fa32007-07-19 01:14:50 +00001665def ROL8ri : Ii8<0xC0, MRM0r, (outs GR8 :$dst), (ins GR8 :$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001666 "rol{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001667 [(set GR8:$dst, (rotl GR8:$src1, (i8 imm:$src2)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001668def ROL16ri : Ii8<0xC1, MRM0r, (outs GR16:$dst), (ins GR16:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001669 "rol{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001670 [(set GR16:$dst, (rotl GR16:$src1, (i8 imm:$src2)))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001671def ROL32ri : Ii8<0xC1, MRM0r, (outs GR32:$dst), (ins GR32:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001672 "rol{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001673 [(set GR32:$dst, (rotl GR32:$src1, (i8 imm:$src2)))]>;
1674
1675// Rotate by 1
Evan Chengb783fa32007-07-19 01:14:50 +00001676def ROL8r1 : I<0xD0, MRM0r, (outs GR8 :$dst), (ins GR8 :$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00001677 "rol{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001678 [(set GR8:$dst, (rotl GR8:$src1, (i8 1)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001679def ROL16r1 : I<0xD1, MRM0r, (outs GR16:$dst), (ins GR16:$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00001680 "rol{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001681 [(set GR16:$dst, (rotl GR16:$src1, (i8 1)))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001682def ROL32r1 : I<0xD1, MRM0r, (outs GR32:$dst), (ins GR32:$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00001683 "rol{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001684 [(set GR32:$dst, (rotl GR32:$src1, (i8 1)))]>;
1685
1686let isTwoAddress = 0 in {
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001687 let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00001688 def ROL8mCL : I<0xD2, MRM0m, (outs), (ins i8mem :$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001689 "rol{b}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001690 [(store (rotl (loadi8 addr:$dst), CL), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001691 def ROL16mCL : I<0xD3, MRM0m, (outs), (ins i16mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001692 "rol{w}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001693 [(store (rotl (loadi16 addr:$dst), CL), addr:$dst)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001694 def ROL32mCL : I<0xD3, MRM0m, (outs), (ins i32mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001695 "rol{l}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001696 [(store (rotl (loadi32 addr:$dst), CL), addr:$dst)]>;
1697 }
Evan Chengb783fa32007-07-19 01:14:50 +00001698 def ROL8mi : Ii8<0xC0, MRM0m, (outs), (ins i8mem :$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001699 "rol{b}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001700 [(store (rotl (loadi8 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001701 def ROL16mi : Ii8<0xC1, MRM0m, (outs), (ins i16mem:$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001702 "rol{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001703 [(store (rotl (loadi16 addr:$dst), (i8 imm:$src)), addr:$dst)]>,
1704 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001705 def ROL32mi : Ii8<0xC1, MRM0m, (outs), (ins i32mem:$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001706 "rol{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001707 [(store (rotl (loadi32 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
1708
1709 // Rotate by 1
Evan Chengb783fa32007-07-19 01:14:50 +00001710 def ROL8m1 : I<0xD0, MRM0m, (outs), (ins i8mem :$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001711 "rol{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001712 [(store (rotl (loadi8 addr:$dst), (i8 1)), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001713 def ROL16m1 : I<0xD1, MRM0m, (outs), (ins i16mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001714 "rol{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001715 [(store (rotl (loadi16 addr:$dst), (i8 1)), addr:$dst)]>,
1716 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001717 def ROL32m1 : I<0xD1, MRM0m, (outs), (ins i32mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001718 "rol{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001719 [(store (rotl (loadi32 addr:$dst), (i8 1)), addr:$dst)]>;
1720}
1721
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001722let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00001723def ROR8rCL : I<0xD2, MRM1r, (outs GR8 :$dst), (ins GR8 :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001724 "ror{b}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001725 [(set GR8:$dst, (rotr GR8:$src, CL))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001726def ROR16rCL : I<0xD3, MRM1r, (outs GR16:$dst), (ins GR16:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001727 "ror{w}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001728 [(set GR16:$dst, (rotr GR16:$src, CL))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001729def ROR32rCL : I<0xD3, MRM1r, (outs GR32:$dst), (ins GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001730 "ror{l}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001731 [(set GR32:$dst, (rotr GR32:$src, CL))]>;
1732}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001733
Evan Chengb783fa32007-07-19 01:14:50 +00001734def ROR8ri : Ii8<0xC0, MRM1r, (outs GR8 :$dst), (ins GR8 :$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001735 "ror{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001736 [(set GR8:$dst, (rotr GR8:$src1, (i8 imm:$src2)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001737def ROR16ri : Ii8<0xC1, MRM1r, (outs GR16:$dst), (ins GR16:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001738 "ror{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001739 [(set GR16:$dst, (rotr GR16:$src1, (i8 imm:$src2)))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001740def ROR32ri : Ii8<0xC1, MRM1r, (outs GR32:$dst), (ins GR32:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001741 "ror{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001742 [(set GR32:$dst, (rotr GR32:$src1, (i8 imm:$src2)))]>;
1743
1744// Rotate by 1
Evan Chengb783fa32007-07-19 01:14:50 +00001745def ROR8r1 : I<0xD0, MRM1r, (outs GR8 :$dst), (ins GR8 :$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00001746 "ror{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001747 [(set GR8:$dst, (rotr GR8:$src1, (i8 1)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001748def ROR16r1 : I<0xD1, MRM1r, (outs GR16:$dst), (ins GR16:$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00001749 "ror{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001750 [(set GR16:$dst, (rotr GR16:$src1, (i8 1)))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001751def ROR32r1 : I<0xD1, MRM1r, (outs GR32:$dst), (ins GR32:$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00001752 "ror{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001753 [(set GR32:$dst, (rotr GR32:$src1, (i8 1)))]>;
1754
1755let isTwoAddress = 0 in {
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001756 let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00001757 def ROR8mCL : I<0xD2, MRM1m, (outs), (ins i8mem :$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001758 "ror{b}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001759 [(store (rotr (loadi8 addr:$dst), CL), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001760 def ROR16mCL : I<0xD3, MRM1m, (outs), (ins i16mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001761 "ror{w}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001762 [(store (rotr (loadi16 addr:$dst), CL), addr:$dst)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001763 def ROR32mCL : I<0xD3, MRM1m, (outs), (ins i32mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001764 "ror{l}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001765 [(store (rotr (loadi32 addr:$dst), CL), addr:$dst)]>;
1766 }
Evan Chengb783fa32007-07-19 01:14:50 +00001767 def ROR8mi : Ii8<0xC0, MRM1m, (outs), (ins i8mem :$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001768 "ror{b}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001769 [(store (rotr (loadi8 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001770 def ROR16mi : Ii8<0xC1, MRM1m, (outs), (ins i16mem:$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001771 "ror{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001772 [(store (rotr (loadi16 addr:$dst), (i8 imm:$src)), addr:$dst)]>,
1773 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001774 def ROR32mi : Ii8<0xC1, MRM1m, (outs), (ins i32mem:$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001775 "ror{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001776 [(store (rotr (loadi32 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
1777
1778 // Rotate by 1
Evan Chengb783fa32007-07-19 01:14:50 +00001779 def ROR8m1 : I<0xD0, MRM1m, (outs), (ins i8mem :$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001780 "ror{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001781 [(store (rotr (loadi8 addr:$dst), (i8 1)), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001782 def ROR16m1 : I<0xD1, MRM1m, (outs), (ins i16mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001783 "ror{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001784 [(store (rotr (loadi16 addr:$dst), (i8 1)), addr:$dst)]>,
1785 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001786 def ROR32m1 : I<0xD1, MRM1m, (outs), (ins i32mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001787 "ror{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001788 [(store (rotr (loadi32 addr:$dst), (i8 1)), addr:$dst)]>;
1789}
1790
1791
1792
1793// Double shift instructions (generalizations of rotate)
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001794let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00001795def SHLD32rrCL : I<0xA5, MRMDestReg, (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001796 "shld{l}\t{%cl, $src2, $dst|$dst, $src2, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001797 [(set GR32:$dst, (X86shld GR32:$src1, GR32:$src2, CL))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00001798def SHRD32rrCL : I<0xAD, MRMDestReg, (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001799 "shrd{l}\t{%cl, $src2, $dst|$dst, $src2, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001800 [(set GR32:$dst, (X86shrd GR32:$src1, GR32:$src2, CL))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00001801def SHLD16rrCL : I<0xA5, MRMDestReg, (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001802 "shld{w}\t{%cl, $src2, $dst|$dst, $src2, %CL}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001803 [(set GR16:$dst, (X86shld GR16:$src1, GR16:$src2, CL))]>,
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001804 TB, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001805def SHRD16rrCL : I<0xAD, MRMDestReg, (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001806 "shrd{w}\t{%cl, $src2, $dst|$dst, $src2, %CL}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001807 [(set GR16:$dst, (X86shrd GR16:$src1, GR16:$src2, CL))]>,
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001808 TB, OpSize;
1809}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001810
1811let isCommutable = 1 in { // These instructions commute to each other.
1812def SHLD32rri8 : Ii8<0xA4, MRMDestReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001813 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2, i8imm:$src3),
Dan Gohman91888f02007-07-31 20:11:57 +00001814 "shld{l}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001815 [(set GR32:$dst, (X86shld GR32:$src1, GR32:$src2,
1816 (i8 imm:$src3)))]>,
1817 TB;
1818def SHRD32rri8 : Ii8<0xAC, MRMDestReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001819 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2, i8imm:$src3),
Dan Gohman91888f02007-07-31 20:11:57 +00001820 "shrd{l}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001821 [(set GR32:$dst, (X86shrd GR32:$src1, GR32:$src2,
1822 (i8 imm:$src3)))]>,
1823 TB;
1824def SHLD16rri8 : Ii8<0xA4, MRMDestReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001825 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2, i8imm:$src3),
Dan Gohman91888f02007-07-31 20:11:57 +00001826 "shld{w}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001827 [(set GR16:$dst, (X86shld GR16:$src1, GR16:$src2,
1828 (i8 imm:$src3)))]>,
1829 TB, OpSize;
1830def SHRD16rri8 : Ii8<0xAC, MRMDestReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001831 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2, i8imm:$src3),
Dan Gohman91888f02007-07-31 20:11:57 +00001832 "shrd{w}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001833 [(set GR16:$dst, (X86shrd GR16:$src1, GR16:$src2,
1834 (i8 imm:$src3)))]>,
1835 TB, OpSize;
1836}
1837
1838let isTwoAddress = 0 in {
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001839 let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00001840 def SHLD32mrCL : I<0xA5, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001841 "shld{l}\t{%cl, $src2, $dst|$dst, $src2, %CL}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001842 [(store (X86shld (loadi32 addr:$dst), GR32:$src2, CL),
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001843 addr:$dst)]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00001844 def SHRD32mrCL : I<0xAD, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001845 "shrd{l}\t{%cl, $src2, $dst|$dst, $src2, %CL}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001846 [(store (X86shrd (loadi32 addr:$dst), GR32:$src2, CL),
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001847 addr:$dst)]>, TB;
1848 }
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001849 def SHLD32mri8 : Ii8<0xA4, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001850 (outs), (ins i32mem:$dst, GR32:$src2, i8imm:$src3),
Dan Gohman91888f02007-07-31 20:11:57 +00001851 "shld{l}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001852 [(store (X86shld (loadi32 addr:$dst), GR32:$src2,
1853 (i8 imm:$src3)), addr:$dst)]>,
1854 TB;
1855 def SHRD32mri8 : Ii8<0xAC, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001856 (outs), (ins i32mem:$dst, GR32:$src2, i8imm:$src3),
Dan Gohman91888f02007-07-31 20:11:57 +00001857 "shrd{l}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001858 [(store (X86shrd (loadi32 addr:$dst), GR32:$src2,
1859 (i8 imm:$src3)), addr:$dst)]>,
1860 TB;
1861
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001862 let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00001863 def SHLD16mrCL : I<0xA5, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001864 "shld{w}\t{%cl, $src2, $dst|$dst, $src2, %CL}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001865 [(store (X86shld (loadi16 addr:$dst), GR16:$src2, CL),
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001866 addr:$dst)]>, TB, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001867 def SHRD16mrCL : I<0xAD, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001868 "shrd{w}\t{%cl, $src2, $dst|$dst, $src2, %CL}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001869 [(store (X86shrd (loadi16 addr:$dst), GR16:$src2, CL),
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001870 addr:$dst)]>, TB, OpSize;
1871 }
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001872 def SHLD16mri8 : Ii8<0xA4, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001873 (outs), (ins i16mem:$dst, GR16:$src2, i8imm:$src3),
Dan Gohman91888f02007-07-31 20:11:57 +00001874 "shld{w}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001875 [(store (X86shld (loadi16 addr:$dst), GR16:$src2,
1876 (i8 imm:$src3)), addr:$dst)]>,
1877 TB, OpSize;
1878 def SHRD16mri8 : Ii8<0xAC, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001879 (outs), (ins i16mem:$dst, GR16:$src2, i8imm:$src3),
Dan Gohman91888f02007-07-31 20:11:57 +00001880 "shrd{w}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001881 [(store (X86shrd (loadi16 addr:$dst), GR16:$src2,
1882 (i8 imm:$src3)), addr:$dst)]>,
1883 TB, OpSize;
1884}
Evan Cheng55687072007-09-14 21:48:26 +00001885} // Defs = [EFLAGS]
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001886
1887
1888// Arithmetic.
Evan Cheng55687072007-09-14 21:48:26 +00001889let Defs = [EFLAGS] in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001890let isCommutable = 1 in { // X = ADD Y, Z --> X = ADD Z, Y
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001891def ADD8rr : I<0x00, MRMDestReg, (outs GR8 :$dst),
1892 (ins GR8 :$src1, GR8 :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001893 "add{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001894 [(set GR8:$dst, (add GR8:$src1, GR8:$src2))]>;
1895let isConvertibleToThreeAddress = 1 in { // Can transform into LEA.
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001896def ADD16rr : I<0x01, MRMDestReg, (outs GR16:$dst),
1897 (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001898 "add{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001899 [(set GR16:$dst, (add GR16:$src1, GR16:$src2))]>, OpSize;
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001900def ADD32rr : I<0x01, MRMDestReg, (outs GR32:$dst),
1901 (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001902 "add{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001903 [(set GR32:$dst, (add GR32:$src1, GR32:$src2))]>;
1904} // end isConvertibleToThreeAddress
1905} // end isCommutable
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001906def ADD8rm : I<0x02, MRMSrcMem, (outs GR8 :$dst),
1907 (ins GR8 :$src1, i8mem :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001908 "add{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001909 [(set GR8:$dst, (add GR8:$src1, (load addr:$src2)))]>;
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001910def ADD16rm : I<0x03, MRMSrcMem, (outs GR16:$dst),
1911 (ins GR16:$src1, i16mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001912 "add{w}\t{$src2, $dst|$dst, $src2}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001913 [(set GR16:$dst, (add GR16:$src1, (load addr:$src2)))]>,OpSize;
1914def ADD32rm : I<0x03, MRMSrcMem, (outs GR32:$dst),
1915 (ins GR32:$src1, i32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001916 "add{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001917 [(set GR32:$dst, (add GR32:$src1, (load addr:$src2)))]>;
1918
Evan Chengb783fa32007-07-19 01:14:50 +00001919def ADD8ri : Ii8<0x80, MRM0r, (outs GR8:$dst), (ins GR8:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001920 "add{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001921 [(set GR8:$dst, (add GR8:$src1, imm:$src2))]>;
1922
1923let isConvertibleToThreeAddress = 1 in { // Can transform into LEA.
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001924def ADD16ri : Ii16<0x81, MRM0r, (outs GR16:$dst),
1925 (ins GR16:$src1, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001926 "add{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001927 [(set GR16:$dst, (add GR16:$src1, imm:$src2))]>, OpSize;
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001928def ADD32ri : Ii32<0x81, MRM0r, (outs GR32:$dst),
1929 (ins GR32:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001930 "add{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001931 [(set GR32:$dst, (add GR32:$src1, imm:$src2))]>;
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001932def ADD16ri8 : Ii8<0x83, MRM0r, (outs GR16:$dst),
1933 (ins GR16:$src1, i16i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001934 "add{w}\t{$src2, $dst|$dst, $src2}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001935 [(set GR16:$dst, (add GR16:$src1, i16immSExt8:$src2))]>, OpSize;
1936def ADD32ri8 : Ii8<0x83, MRM0r, (outs GR32:$dst),
1937 (ins GR32:$src1, i32i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001938 "add{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001939 [(set GR32:$dst, (add GR32:$src1, i32immSExt8:$src2))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001940}
1941
1942let isTwoAddress = 0 in {
Evan Chengb783fa32007-07-19 01:14:50 +00001943 def ADD8mr : I<0x00, MRMDestMem, (outs), (ins i8mem :$dst, GR8 :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001944 "add{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001945 [(store (add (load addr:$dst), GR8:$src2), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001946 def ADD16mr : I<0x01, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001947 "add{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001948 [(store (add (load addr:$dst), GR16:$src2), addr:$dst)]>,
Evan Cheng55687072007-09-14 21:48:26 +00001949 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001950 def ADD32mr : I<0x01, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001951 "add{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001952 [(store (add (load addr:$dst), GR32:$src2), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001953 def ADD8mi : Ii8<0x80, MRM0m, (outs), (ins i8mem :$dst, i8imm :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001954 "add{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001955 [(store (add (loadi8 addr:$dst), imm:$src2), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001956 def ADD16mi : Ii16<0x81, MRM0m, (outs), (ins i16mem:$dst, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001957 "add{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001958 [(store (add (loadi16 addr:$dst), imm:$src2), addr:$dst)]>,
Evan Cheng55687072007-09-14 21:48:26 +00001959 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001960 def ADD32mi : Ii32<0x81, MRM0m, (outs), (ins i32mem:$dst, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001961 "add{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001962 [(store (add (loadi32 addr:$dst), imm:$src2), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001963 def ADD16mi8 : Ii8<0x83, MRM0m, (outs), (ins i16mem:$dst, i16i8imm :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001964 "add{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001965 [(store (add (load addr:$dst), i16immSExt8:$src2), addr:$dst)]>,
Evan Cheng55687072007-09-14 21:48:26 +00001966 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001967 def ADD32mi8 : Ii8<0x83, MRM0m, (outs), (ins i32mem:$dst, i32i8imm :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001968 "add{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001969 [(store (add (load addr:$dst), i32immSExt8:$src2), addr:$dst)]>;
1970}
1971
Evan Cheng259471d2007-10-05 17:59:57 +00001972let Uses = [EFLAGS] in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001973let isCommutable = 1 in { // X = ADC Y, Z --> X = ADC Z, Y
Evan Chengb783fa32007-07-19 01:14:50 +00001974def ADC32rr : I<0x11, MRMDestReg, (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001975 "adc{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001976 [(set GR32:$dst, (adde GR32:$src1, GR32:$src2))]>;
1977}
Evan Chengb783fa32007-07-19 01:14:50 +00001978def ADC32rm : I<0x13, MRMSrcMem , (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001979 "adc{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001980 [(set GR32:$dst, (adde GR32:$src1, (load addr:$src2)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001981def ADC32ri : Ii32<0x81, MRM2r, (outs GR32:$dst), (ins GR32:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001982 "adc{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001983 [(set GR32:$dst, (adde GR32:$src1, imm:$src2))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001984def ADC32ri8 : Ii8<0x83, MRM2r, (outs GR32:$dst), (ins GR32:$src1, i32i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001985 "adc{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001986 [(set GR32:$dst, (adde GR32:$src1, i32immSExt8:$src2))]>;
1987
1988let isTwoAddress = 0 in {
Evan Chengb783fa32007-07-19 01:14:50 +00001989 def ADC32mr : I<0x11, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001990 "adc{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001991 [(store (adde (load addr:$dst), GR32:$src2), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001992 def ADC32mi : Ii32<0x81, MRM2m, (outs), (ins i32mem:$dst, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001993 "adc{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001994 [(store (adde (loadi32 addr:$dst), imm:$src2), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001995 def ADC32mi8 : Ii8<0x83, MRM2m, (outs), (ins i32mem:$dst, i32i8imm :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001996 "adc{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001997 [(store (adde (load addr:$dst), i32immSExt8:$src2), addr:$dst)]>;
1998}
Evan Cheng259471d2007-10-05 17:59:57 +00001999} // Uses = [EFLAGS]
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002000
Evan Chengb783fa32007-07-19 01:14:50 +00002001def SUB8rr : I<0x28, MRMDestReg, (outs GR8 :$dst), (ins GR8 :$src1, GR8 :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002002 "sub{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002003 [(set GR8:$dst, (sub GR8:$src1, GR8:$src2))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002004def SUB16rr : I<0x29, MRMDestReg, (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002005 "sub{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002006 [(set GR16:$dst, (sub GR16:$src1, GR16:$src2))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002007def SUB32rr : I<0x29, MRMDestReg, (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002008 "sub{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002009 [(set GR32:$dst, (sub GR32:$src1, GR32:$src2))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002010def SUB8rm : I<0x2A, MRMSrcMem, (outs GR8 :$dst), (ins GR8 :$src1, i8mem :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002011 "sub{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002012 [(set GR8:$dst, (sub GR8:$src1, (load addr:$src2)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002013def SUB16rm : I<0x2B, MRMSrcMem, (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002014 "sub{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002015 [(set GR16:$dst, (sub GR16:$src1, (load addr:$src2)))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002016def SUB32rm : I<0x2B, MRMSrcMem, (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002017 "sub{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002018 [(set GR32:$dst, (sub GR32:$src1, (load addr:$src2)))]>;
2019
Evan Chengb783fa32007-07-19 01:14:50 +00002020def SUB8ri : Ii8 <0x80, MRM5r, (outs GR8:$dst), (ins GR8:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002021 "sub{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002022 [(set GR8:$dst, (sub GR8:$src1, imm:$src2))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002023def SUB16ri : Ii16<0x81, MRM5r, (outs GR16:$dst), (ins GR16:$src1, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002024 "sub{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002025 [(set GR16:$dst, (sub GR16:$src1, imm:$src2))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002026def SUB32ri : Ii32<0x81, MRM5r, (outs GR32:$dst), (ins GR32:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002027 "sub{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002028 [(set GR32:$dst, (sub GR32:$src1, imm:$src2))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002029def SUB16ri8 : Ii8<0x83, MRM5r, (outs GR16:$dst), (ins GR16:$src1, i16i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002030 "sub{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002031 [(set GR16:$dst, (sub GR16:$src1, i16immSExt8:$src2))]>,
Evan Cheng55687072007-09-14 21:48:26 +00002032 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002033def SUB32ri8 : Ii8<0x83, MRM5r, (outs GR32:$dst), (ins GR32:$src1, i32i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002034 "sub{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002035 [(set GR32:$dst, (sub GR32:$src1, i32immSExt8:$src2))]>;
2036let isTwoAddress = 0 in {
Evan Chengb783fa32007-07-19 01:14:50 +00002037 def SUB8mr : I<0x28, MRMDestMem, (outs), (ins i8mem :$dst, GR8 :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002038 "sub{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002039 [(store (sub (load addr:$dst), GR8:$src2), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002040 def SUB16mr : I<0x29, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002041 "sub{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002042 [(store (sub (load addr:$dst), GR16:$src2), addr:$dst)]>,
Evan Cheng55687072007-09-14 21:48:26 +00002043 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002044 def SUB32mr : I<0x29, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002045 "sub{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002046 [(store (sub (load addr:$dst), GR32:$src2), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002047 def SUB8mi : Ii8<0x80, MRM5m, (outs), (ins i8mem :$dst, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002048 "sub{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002049 [(store (sub (loadi8 addr:$dst), imm:$src2), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002050 def SUB16mi : Ii16<0x81, MRM5m, (outs), (ins i16mem:$dst, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002051 "sub{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002052 [(store (sub (loadi16 addr:$dst), imm:$src2), addr:$dst)]>,
Evan Cheng55687072007-09-14 21:48:26 +00002053 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002054 def SUB32mi : Ii32<0x81, MRM5m, (outs), (ins i32mem:$dst, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002055 "sub{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002056 [(store (sub (loadi32 addr:$dst), imm:$src2), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002057 def SUB16mi8 : Ii8<0x83, MRM5m, (outs), (ins i16mem:$dst, i16i8imm :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002058 "sub{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002059 [(store (sub (load addr:$dst), i16immSExt8:$src2), addr:$dst)]>,
Evan Cheng55687072007-09-14 21:48:26 +00002060 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002061 def SUB32mi8 : Ii8<0x83, MRM5m, (outs), (ins i32mem:$dst, i32i8imm :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002062 "sub{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002063 [(store (sub (load addr:$dst), i32immSExt8:$src2), addr:$dst)]>;
2064}
2065
Evan Cheng259471d2007-10-05 17:59:57 +00002066let Uses = [EFLAGS] in {
Evan Chengb783fa32007-07-19 01:14:50 +00002067def SBB32rr : I<0x19, MRMDestReg, (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002068 "sbb{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng55687072007-09-14 21:48:26 +00002069 [(set GR32:$dst, (sube GR32:$src1, GR32:$src2))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002070
2071let isTwoAddress = 0 in {
Evan Chengb783fa32007-07-19 01:14:50 +00002072 def SBB32mr : I<0x19, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002073 "sbb{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002074 [(store (sube (load addr:$dst), GR32:$src2), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002075 def SBB8mi : Ii32<0x80, MRM3m, (outs), (ins i8mem:$dst, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002076 "sbb{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002077 [(store (sube (loadi8 addr:$dst), imm:$src2), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002078 def SBB32mi : Ii32<0x81, MRM3m, (outs), (ins i32mem:$dst, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002079 "sbb{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002080 [(store (sube (loadi32 addr:$dst), imm:$src2), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002081 def SBB32mi8 : Ii8<0x83, MRM3m, (outs), (ins i32mem:$dst, i32i8imm :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002082 "sbb{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng55687072007-09-14 21:48:26 +00002083 [(store (sube (load addr:$dst), i32immSExt8:$src2), addr:$dst)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002084}
Evan Chengb783fa32007-07-19 01:14:50 +00002085def SBB32rm : I<0x1B, MRMSrcMem, (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002086 "sbb{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002087 [(set GR32:$dst, (sube GR32:$src1, (load addr:$src2)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002088def SBB32ri : Ii32<0x81, MRM3r, (outs GR32:$dst), (ins GR32:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002089 "sbb{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002090 [(set GR32:$dst, (sube GR32:$src1, imm:$src2))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002091def SBB32ri8 : Ii8<0x83, MRM3r, (outs GR32:$dst), (ins GR32:$src1, i32i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002092 "sbb{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002093 [(set GR32:$dst, (sube GR32:$src1, i32immSExt8:$src2))]>;
Evan Cheng259471d2007-10-05 17:59:57 +00002094} // Uses = [EFLAGS]
Evan Cheng55687072007-09-14 21:48:26 +00002095} // Defs = [EFLAGS]
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002096
Evan Cheng55687072007-09-14 21:48:26 +00002097let Defs = [EFLAGS] in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002098let isCommutable = 1 in { // X = IMUL Y, Z --> X = IMUL Z, Y
Evan Chengb783fa32007-07-19 01:14:50 +00002099def IMUL16rr : I<0xAF, MRMSrcReg, (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002100 "imul{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002101 [(set GR16:$dst, (mul GR16:$src1, GR16:$src2))]>, TB, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002102def IMUL32rr : I<0xAF, MRMSrcReg, (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002103 "imul{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002104 [(set GR32:$dst, (mul GR32:$src1, GR32:$src2))]>, TB;
2105}
Evan Chengb783fa32007-07-19 01:14:50 +00002106def IMUL16rm : I<0xAF, MRMSrcMem, (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002107 "imul{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002108 [(set GR16:$dst, (mul GR16:$src1, (load addr:$src2)))]>,
2109 TB, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002110def IMUL32rm : I<0xAF, MRMSrcMem, (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002111 "imul{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002112 [(set GR32:$dst, (mul GR32:$src1, (load addr:$src2)))]>, TB;
Evan Cheng55687072007-09-14 21:48:26 +00002113} // Defs = [EFLAGS]
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002114} // end Two Address instructions
2115
2116// Suprisingly enough, these are not two address instructions!
Evan Cheng55687072007-09-14 21:48:26 +00002117let Defs = [EFLAGS] in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002118def IMUL16rri : Ii16<0x69, MRMSrcReg, // GR16 = GR16*I16
Evan Chengb783fa32007-07-19 01:14:50 +00002119 (outs GR16:$dst), (ins GR16:$src1, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002120 "imul{w}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002121 [(set GR16:$dst, (mul GR16:$src1, imm:$src2))]>, OpSize;
2122def IMUL32rri : Ii32<0x69, MRMSrcReg, // GR32 = GR32*I32
Evan Chengb783fa32007-07-19 01:14:50 +00002123 (outs GR32:$dst), (ins GR32:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002124 "imul{l}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002125 [(set GR32:$dst, (mul GR32:$src1, imm:$src2))]>;
2126def IMUL16rri8 : Ii8<0x6B, MRMSrcReg, // GR16 = GR16*I8
Evan Chengb783fa32007-07-19 01:14:50 +00002127 (outs GR16:$dst), (ins GR16:$src1, i16i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002128 "imul{w}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002129 [(set GR16:$dst, (mul GR16:$src1, i16immSExt8:$src2))]>,
2130 OpSize;
2131def IMUL32rri8 : Ii8<0x6B, MRMSrcReg, // GR32 = GR32*I8
Evan Chengb783fa32007-07-19 01:14:50 +00002132 (outs GR32:$dst), (ins GR32:$src1, i32i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002133 "imul{l}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002134 [(set GR32:$dst, (mul GR32:$src1, i32immSExt8:$src2))]>;
2135
2136def IMUL16rmi : Ii16<0x69, MRMSrcMem, // GR16 = [mem16]*I16
Evan Chengb783fa32007-07-19 01:14:50 +00002137 (outs GR16:$dst), (ins i16mem:$src1, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002138 "imul{w}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002139 [(set GR16:$dst, (mul (load addr:$src1), imm:$src2))]>,
2140 OpSize;
2141def IMUL32rmi : Ii32<0x69, MRMSrcMem, // GR32 = [mem32]*I32
Evan Chengb783fa32007-07-19 01:14:50 +00002142 (outs GR32:$dst), (ins i32mem:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002143 "imul{l}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002144 [(set GR32:$dst, (mul (load addr:$src1), imm:$src2))]>;
2145def IMUL16rmi8 : Ii8<0x6B, MRMSrcMem, // GR16 = [mem16]*I8
Evan Chengb783fa32007-07-19 01:14:50 +00002146 (outs GR16:$dst), (ins i16mem:$src1, i16i8imm :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002147 "imul{w}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002148 [(set GR16:$dst, (mul (load addr:$src1), i16immSExt8:$src2))]>,
2149 OpSize;
2150def IMUL32rmi8 : Ii8<0x6B, MRMSrcMem, // GR32 = [mem32]*I8
Evan Chengb783fa32007-07-19 01:14:50 +00002151 (outs GR32:$dst), (ins i32mem:$src1, i32i8imm: $src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002152 "imul{l}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002153 [(set GR32:$dst, (mul (load addr:$src1), i32immSExt8:$src2))]>;
Evan Cheng55687072007-09-14 21:48:26 +00002154} // Defs = [EFLAGS]
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002155
2156//===----------------------------------------------------------------------===//
2157// Test instructions are just like AND, except they don't generate a result.
2158//
Evan Cheng950aac02007-09-25 01:57:46 +00002159let Defs = [EFLAGS] in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002160let isCommutable = 1 in { // TEST X, Y --> TEST Y, X
Evan Chengb783fa32007-07-19 01:14:50 +00002161def TEST8rr : I<0x84, MRMDestReg, (outs), (ins GR8:$src1, GR8:$src2),
Evan Cheng621216e2007-09-29 00:00:36 +00002162 "test{b}\t{$src2, $src1|$src1, $src2}",
Chris Lattner21da6382008-02-19 17:37:35 +00002163 [(X86cmp (and_su GR8:$src1, GR8:$src2), 0),
Evan Cheng621216e2007-09-29 00:00:36 +00002164 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002165def TEST16rr : I<0x85, MRMDestReg, (outs), (ins GR16:$src1, GR16:$src2),
Evan Cheng621216e2007-09-29 00:00:36 +00002166 "test{w}\t{$src2, $src1|$src1, $src2}",
Chris Lattner21da6382008-02-19 17:37:35 +00002167 [(X86cmp (and_su GR16:$src1, GR16:$src2), 0),
Evan Cheng621216e2007-09-29 00:00:36 +00002168 (implicit EFLAGS)]>,
2169 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002170def TEST32rr : I<0x85, MRMDestReg, (outs), (ins GR32:$src1, GR32:$src2),
Evan Cheng621216e2007-09-29 00:00:36 +00002171 "test{l}\t{$src2, $src1|$src1, $src2}",
Chris Lattner21da6382008-02-19 17:37:35 +00002172 [(X86cmp (and_su GR32:$src1, GR32:$src2), 0),
Evan Cheng621216e2007-09-29 00:00:36 +00002173 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002174}
2175
Evan Chengb783fa32007-07-19 01:14:50 +00002176def TEST8rm : I<0x84, MRMSrcMem, (outs), (ins GR8 :$src1, i8mem :$src2),
Evan Cheng621216e2007-09-29 00:00:36 +00002177 "test{b}\t{$src2, $src1|$src1, $src2}",
2178 [(X86cmp (and GR8:$src1, (loadi8 addr:$src2)), 0),
2179 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002180def TEST16rm : I<0x85, MRMSrcMem, (outs), (ins GR16:$src1, i16mem:$src2),
Evan Cheng621216e2007-09-29 00:00:36 +00002181 "test{w}\t{$src2, $src1|$src1, $src2}",
2182 [(X86cmp (and GR16:$src1, (loadi16 addr:$src2)), 0),
2183 (implicit EFLAGS)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002184def TEST32rm : I<0x85, MRMSrcMem, (outs), (ins GR32:$src1, i32mem:$src2),
Evan Cheng621216e2007-09-29 00:00:36 +00002185 "test{l}\t{$src2, $src1|$src1, $src2}",
2186 [(X86cmp (and GR32:$src1, (loadi32 addr:$src2)), 0),
2187 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002188
2189def TEST8ri : Ii8 <0xF6, MRM0r, // flags = GR8 & imm8
Evan Chengb783fa32007-07-19 01:14:50 +00002190 (outs), (ins GR8:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002191 "test{b}\t{$src2, $src1|$src1, $src2}",
Chris Lattner21da6382008-02-19 17:37:35 +00002192 [(X86cmp (and_su GR8:$src1, imm:$src2), 0),
Evan Cheng621216e2007-09-29 00:00:36 +00002193 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002194def TEST16ri : Ii16<0xF7, MRM0r, // flags = GR16 & imm16
Evan Chengb783fa32007-07-19 01:14:50 +00002195 (outs), (ins GR16:$src1, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002196 "test{w}\t{$src2, $src1|$src1, $src2}",
Chris Lattner21da6382008-02-19 17:37:35 +00002197 [(X86cmp (and_su GR16:$src1, imm:$src2), 0),
Evan Cheng621216e2007-09-29 00:00:36 +00002198 (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002199def TEST32ri : Ii32<0xF7, MRM0r, // flags = GR32 & imm32
Evan Chengb783fa32007-07-19 01:14:50 +00002200 (outs), (ins GR32:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002201 "test{l}\t{$src2, $src1|$src1, $src2}",
Chris Lattner21da6382008-02-19 17:37:35 +00002202 [(X86cmp (and_su GR32:$src1, imm:$src2), 0),
Evan Cheng621216e2007-09-29 00:00:36 +00002203 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002204
Evan Cheng621216e2007-09-29 00:00:36 +00002205def TEST8mi : Ii8 <0xF6, MRM0m, // flags = [mem8] & imm8
Evan Chengb783fa32007-07-19 01:14:50 +00002206 (outs), (ins i8mem:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002207 "test{b}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002208 [(X86cmp (and (loadi8 addr:$src1), imm:$src2), 0),
2209 (implicit EFLAGS)]>;
2210def TEST16mi : Ii16<0xF7, MRM0m, // flags = [mem16] & imm16
Evan Chengb783fa32007-07-19 01:14:50 +00002211 (outs), (ins i16mem:$src1, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002212 "test{w}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002213 [(X86cmp (and (loadi16 addr:$src1), imm:$src2), 0),
2214 (implicit EFLAGS)]>, OpSize;
2215def TEST32mi : Ii32<0xF7, MRM0m, // flags = [mem32] & imm32
Evan Chengb783fa32007-07-19 01:14:50 +00002216 (outs), (ins i32mem:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002217 "test{l}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002218 [(X86cmp (and (loadi32 addr:$src1), imm:$src2), 0),
Evan Cheng950aac02007-09-25 01:57:46 +00002219 (implicit EFLAGS)]>;
2220} // Defs = [EFLAGS]
2221
2222
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002223// Condition code ops, incl. set if equal/not equal/...
Chris Lattnerc90ee9c2008-01-10 07:59:24 +00002224let Defs = [EFLAGS], Uses = [AH], neverHasSideEffects = 1 in
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002225def SAHF : I<0x9E, RawFrm, (outs), (ins), "sahf", []>; // flags = AH
Chris Lattnerc90ee9c2008-01-10 07:59:24 +00002226let Defs = [AH], Uses = [EFLAGS], neverHasSideEffects = 1 in
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002227def LAHF : I<0x9F, RawFrm, (outs), (ins), "lahf", []>; // AH = flags
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002228
Evan Cheng950aac02007-09-25 01:57:46 +00002229let Uses = [EFLAGS] in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002230def SETEr : I<0x94, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00002231 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002232 "sete\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002233 [(set GR8:$dst, (X86setcc X86_COND_E, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002234 TB; // GR8 = ==
2235def SETEm : I<0x94, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00002236 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002237 "sete\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002238 [(store (X86setcc X86_COND_E, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002239 TB; // [mem8] = ==
2240def SETNEr : I<0x95, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00002241 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002242 "setne\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002243 [(set GR8:$dst, (X86setcc X86_COND_NE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002244 TB; // GR8 = !=
2245def SETNEm : I<0x95, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00002246 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002247 "setne\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002248 [(store (X86setcc X86_COND_NE, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002249 TB; // [mem8] = !=
2250def SETLr : I<0x9C, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00002251 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002252 "setl\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002253 [(set GR8:$dst, (X86setcc X86_COND_L, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002254 TB; // GR8 = < signed
2255def SETLm : I<0x9C, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00002256 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002257 "setl\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002258 [(store (X86setcc X86_COND_L, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002259 TB; // [mem8] = < signed
2260def SETGEr : I<0x9D, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00002261 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002262 "setge\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002263 [(set GR8:$dst, (X86setcc X86_COND_GE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002264 TB; // GR8 = >= signed
2265def SETGEm : I<0x9D, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00002266 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002267 "setge\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002268 [(store (X86setcc X86_COND_GE, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002269 TB; // [mem8] = >= signed
2270def SETLEr : I<0x9E, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00002271 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002272 "setle\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002273 [(set GR8:$dst, (X86setcc X86_COND_LE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002274 TB; // GR8 = <= signed
2275def SETLEm : I<0x9E, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00002276 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002277 "setle\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002278 [(store (X86setcc X86_COND_LE, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002279 TB; // [mem8] = <= signed
2280def SETGr : I<0x9F, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00002281 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002282 "setg\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002283 [(set GR8:$dst, (X86setcc X86_COND_G, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002284 TB; // GR8 = > signed
2285def SETGm : I<0x9F, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00002286 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002287 "setg\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002288 [(store (X86setcc X86_COND_G, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002289 TB; // [mem8] = > signed
2290
2291def SETBr : I<0x92, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00002292 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002293 "setb\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002294 [(set GR8:$dst, (X86setcc X86_COND_B, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002295 TB; // GR8 = < unsign
2296def SETBm : I<0x92, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00002297 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002298 "setb\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002299 [(store (X86setcc X86_COND_B, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002300 TB; // [mem8] = < unsign
2301def SETAEr : I<0x93, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00002302 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002303 "setae\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002304 [(set GR8:$dst, (X86setcc X86_COND_AE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002305 TB; // GR8 = >= unsign
2306def SETAEm : I<0x93, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00002307 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002308 "setae\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002309 [(store (X86setcc X86_COND_AE, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002310 TB; // [mem8] = >= unsign
2311def SETBEr : I<0x96, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00002312 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002313 "setbe\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002314 [(set GR8:$dst, (X86setcc X86_COND_BE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002315 TB; // GR8 = <= unsign
2316def SETBEm : I<0x96, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00002317 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002318 "setbe\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002319 [(store (X86setcc X86_COND_BE, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002320 TB; // [mem8] = <= unsign
2321def SETAr : I<0x97, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00002322 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002323 "seta\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002324 [(set GR8:$dst, (X86setcc X86_COND_A, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002325 TB; // GR8 = > signed
2326def SETAm : I<0x97, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00002327 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002328 "seta\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002329 [(store (X86setcc X86_COND_A, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002330 TB; // [mem8] = > signed
2331
2332def SETSr : I<0x98, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00002333 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002334 "sets\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002335 [(set GR8:$dst, (X86setcc X86_COND_S, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002336 TB; // GR8 = <sign bit>
2337def SETSm : I<0x98, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00002338 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002339 "sets\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002340 [(store (X86setcc X86_COND_S, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002341 TB; // [mem8] = <sign bit>
2342def SETNSr : I<0x99, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00002343 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002344 "setns\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002345 [(set GR8:$dst, (X86setcc X86_COND_NS, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002346 TB; // GR8 = !<sign bit>
2347def SETNSm : I<0x99, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00002348 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002349 "setns\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002350 [(store (X86setcc X86_COND_NS, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002351 TB; // [mem8] = !<sign bit>
2352def SETPr : I<0x9A, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00002353 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002354 "setp\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002355 [(set GR8:$dst, (X86setcc X86_COND_P, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002356 TB; // GR8 = parity
2357def SETPm : I<0x9A, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00002358 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002359 "setp\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002360 [(store (X86setcc X86_COND_P, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002361 TB; // [mem8] = parity
2362def SETNPr : I<0x9B, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00002363 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002364 "setnp\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002365 [(set GR8:$dst, (X86setcc X86_COND_NP, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002366 TB; // GR8 = not parity
2367def SETNPm : I<0x9B, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00002368 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002369 "setnp\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002370 [(store (X86setcc X86_COND_NP, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002371 TB; // [mem8] = not parity
Evan Cheng950aac02007-09-25 01:57:46 +00002372} // Uses = [EFLAGS]
2373
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002374
2375// Integer comparisons
Evan Cheng55687072007-09-14 21:48:26 +00002376let Defs = [EFLAGS] in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002377def CMP8rr : I<0x38, MRMDestReg,
Evan Chengb783fa32007-07-19 01:14:50 +00002378 (outs), (ins GR8 :$src1, GR8 :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002379 "cmp{b}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002380 [(X86cmp GR8:$src1, GR8:$src2), (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002381def CMP16rr : I<0x39, MRMDestReg,
Evan Chengb783fa32007-07-19 01:14:50 +00002382 (outs), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002383 "cmp{w}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002384 [(X86cmp GR16:$src1, GR16:$src2), (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002385def CMP32rr : I<0x39, MRMDestReg,
Evan Chengb783fa32007-07-19 01:14:50 +00002386 (outs), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002387 "cmp{l}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002388 [(X86cmp GR32:$src1, GR32:$src2), (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002389def CMP8mr : I<0x38, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00002390 (outs), (ins i8mem :$src1, GR8 :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002391 "cmp{b}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002392 [(X86cmp (loadi8 addr:$src1), GR8:$src2),
2393 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002394def CMP16mr : I<0x39, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00002395 (outs), (ins i16mem:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002396 "cmp{w}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002397 [(X86cmp (loadi16 addr:$src1), GR16:$src2),
2398 (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002399def CMP32mr : I<0x39, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00002400 (outs), (ins i32mem:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002401 "cmp{l}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002402 [(X86cmp (loadi32 addr:$src1), GR32:$src2),
2403 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002404def CMP8rm : I<0x3A, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00002405 (outs), (ins GR8 :$src1, i8mem :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002406 "cmp{b}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002407 [(X86cmp GR8:$src1, (loadi8 addr:$src2)),
2408 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002409def CMP16rm : I<0x3B, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00002410 (outs), (ins GR16:$src1, i16mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002411 "cmp{w}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002412 [(X86cmp GR16:$src1, (loadi16 addr:$src2)),
2413 (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002414def CMP32rm : I<0x3B, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00002415 (outs), (ins GR32:$src1, i32mem:$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, (loadi32 addr:$src2)),
2418 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002419def CMP8ri : Ii8<0x80, MRM7r,
Evan Chengb783fa32007-07-19 01:14:50 +00002420 (outs), (ins GR8:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002421 "cmp{b}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002422 [(X86cmp GR8:$src1, imm:$src2), (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002423def CMP16ri : Ii16<0x81, MRM7r,
Evan Chengb783fa32007-07-19 01:14:50 +00002424 (outs), (ins GR16:$src1, i16imm:$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 GR16:$src1, imm:$src2),
2427 (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002428def CMP32ri : Ii32<0x81, MRM7r,
Evan Chengb783fa32007-07-19 01:14:50 +00002429 (outs), (ins GR32:$src1, i32imm:$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 GR32:$src1, imm:$src2), (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002432def CMP8mi : Ii8 <0x80, MRM7m,
Evan Chengb783fa32007-07-19 01:14:50 +00002433 (outs), (ins i8mem :$src1, i8imm :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002434 "cmp{b}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002435 [(X86cmp (loadi8 addr:$src1), imm:$src2),
2436 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002437def CMP16mi : Ii16<0x81, MRM7m,
Evan Chengb783fa32007-07-19 01:14:50 +00002438 (outs), (ins i16mem:$src1, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002439 "cmp{w}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002440 [(X86cmp (loadi16 addr:$src1), imm:$src2),
2441 (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002442def CMP32mi : Ii32<0x81, MRM7m,
Evan Chengb783fa32007-07-19 01:14:50 +00002443 (outs), (ins i32mem:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002444 "cmp{l}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002445 [(X86cmp (loadi32 addr:$src1), imm:$src2),
2446 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002447def CMP16ri8 : Ii8<0x83, MRM7r,
Evan Chengb783fa32007-07-19 01:14:50 +00002448 (outs), (ins GR16:$src1, i16i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002449 "cmp{w}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002450 [(X86cmp GR16:$src1, i16immSExt8:$src2),
2451 (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002452def CMP16mi8 : Ii8<0x83, MRM7m,
Evan Chengb783fa32007-07-19 01:14:50 +00002453 (outs), (ins i16mem:$src1, i16i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002454 "cmp{w}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002455 [(X86cmp (loadi16 addr:$src1), i16immSExt8:$src2),
2456 (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002457def CMP32mi8 : Ii8<0x83, MRM7m,
Evan Chengb783fa32007-07-19 01:14:50 +00002458 (outs), (ins i32mem:$src1, i32i8imm:$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 (loadi32 addr:$src1), i32immSExt8:$src2),
2461 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002462def CMP32ri8 : Ii8<0x83, MRM7r,
Evan Chengb783fa32007-07-19 01:14:50 +00002463 (outs), (ins GR32:$src1, i32i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002464 "cmp{l}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002465 [(X86cmp GR32:$src1, i32immSExt8:$src2),
Evan Cheng950aac02007-09-25 01:57:46 +00002466 (implicit EFLAGS)]>;
2467} // Defs = [EFLAGS]
2468
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002469// Sign/Zero extenders
Dan Gohman9203ab42008-07-30 18:09:17 +00002470// Use movsbl intead of movsbw; we don't care about the high 16 bits
2471// of the register here. This has a smaller encoding and avoids a
2472// partial-register update.
Evan Chengb783fa32007-07-19 01:14:50 +00002473def MOVSX16rr8 : I<0xBE, MRMSrcReg, (outs GR16:$dst), (ins GR8 :$src),
Dan Gohman9203ab42008-07-30 18:09:17 +00002474 "movs{bl|x}\t{$src, ${dst:subreg32}|${dst:subreg32}, $src}",
2475 [(set GR16:$dst, (sext GR8:$src))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00002476def MOVSX16rm8 : I<0xBE, MRMSrcMem, (outs GR16:$dst), (ins i8mem :$src),
Dan Gohman9203ab42008-07-30 18:09:17 +00002477 "movs{bl|x}\t{$src, ${dst:subreg32}|${dst:subreg32}, $src}",
2478 [(set GR16:$dst, (sextloadi16i8 addr:$src))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00002479def MOVSX32rr8 : I<0xBE, MRMSrcReg, (outs GR32:$dst), (ins GR8 :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002480 "movs{bl|x}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002481 [(set GR32:$dst, (sext GR8:$src))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00002482def MOVSX32rm8 : I<0xBE, MRMSrcMem, (outs GR32:$dst), (ins i8mem :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002483 "movs{bl|x}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002484 [(set GR32:$dst, (sextloadi32i8 addr:$src))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00002485def MOVSX32rr16: I<0xBF, MRMSrcReg, (outs GR32:$dst), (ins GR16:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002486 "movs{wl|x}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002487 [(set GR32:$dst, (sext GR16:$src))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00002488def MOVSX32rm16: I<0xBF, MRMSrcMem, (outs GR32:$dst), (ins i16mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002489 "movs{wl|x}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002490 [(set GR32:$dst, (sextloadi32i16 addr:$src))]>, TB;
2491
Dan Gohman9203ab42008-07-30 18:09:17 +00002492// Use movzbl intead of movzbw; we don't care about the high 16 bits
2493// of the register here. This has a smaller encoding and avoids a
2494// partial-register update.
Evan Chengb783fa32007-07-19 01:14:50 +00002495def MOVZX16rr8 : I<0xB6, MRMSrcReg, (outs GR16:$dst), (ins GR8 :$src),
Dan Gohman9203ab42008-07-30 18:09:17 +00002496 "movz{bl|x}\t{$src, ${dst:subreg32}|${dst:subreg32}, $src}",
2497 [(set GR16:$dst, (zext GR8:$src))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00002498def MOVZX16rm8 : I<0xB6, MRMSrcMem, (outs GR16:$dst), (ins i8mem :$src),
Dan Gohman9203ab42008-07-30 18:09:17 +00002499 "movz{bl|x}\t{$src, ${dst:subreg32}|${dst:subreg32}, $src}",
2500 [(set GR16:$dst, (zextloadi16i8 addr:$src))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00002501def MOVZX32rr8 : I<0xB6, MRMSrcReg, (outs GR32:$dst), (ins GR8 :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002502 "movz{bl|x}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002503 [(set GR32:$dst, (zext GR8:$src))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00002504def MOVZX32rm8 : I<0xB6, MRMSrcMem, (outs GR32:$dst), (ins i8mem :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002505 "movz{bl|x}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002506 [(set GR32:$dst, (zextloadi32i8 addr:$src))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00002507def MOVZX32rr16: I<0xB7, MRMSrcReg, (outs GR32:$dst), (ins GR16:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002508 "movz{wl|x}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002509 [(set GR32:$dst, (zext GR16:$src))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00002510def MOVZX32rm16: I<0xB7, MRMSrcMem, (outs GR32:$dst), (ins i16mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002511 "movz{wl|x}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002512 [(set GR32:$dst, (zextloadi32i16 addr:$src))]>, TB;
2513
Chris Lattnerc90ee9c2008-01-10 07:59:24 +00002514let neverHasSideEffects = 1 in {
2515 let Defs = [AX], Uses = [AL] in
2516 def CBW : I<0x98, RawFrm, (outs), (ins),
2517 "{cbtw|cbw}", []>, OpSize; // AX = signext(AL)
2518 let Defs = [EAX], Uses = [AX] in
2519 def CWDE : I<0x98, RawFrm, (outs), (ins),
2520 "{cwtl|cwde}", []>; // EAX = signext(AX)
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002521
Chris Lattnerc90ee9c2008-01-10 07:59:24 +00002522 let Defs = [AX,DX], Uses = [AX] in
2523 def CWD : I<0x99, RawFrm, (outs), (ins),
2524 "{cwtd|cwd}", []>, OpSize; // DX:AX = signext(AX)
2525 let Defs = [EAX,EDX], Uses = [EAX] in
2526 def CDQ : I<0x99, RawFrm, (outs), (ins),
2527 "{cltd|cdq}", []>; // EDX:EAX = signext(EAX)
2528}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002529
2530//===----------------------------------------------------------------------===//
2531// Alias Instructions
2532//===----------------------------------------------------------------------===//
2533
2534// Alias instructions that map movr0 to xor.
2535// FIXME: remove when we can teach regalloc that xor reg, reg is ok.
Bill Wendlingba5d5b02008-05-29 01:02:09 +00002536let Defs = [EFLAGS], isReMaterializable = 1, isAsCheapAsAMove = 1 in {
Evan Chengb783fa32007-07-19 01:14:50 +00002537def MOV8r0 : I<0x30, MRMInitReg, (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002538 "xor{b}\t$dst, $dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002539 [(set GR8:$dst, 0)]>;
Dan Gohman9203ab42008-07-30 18:09:17 +00002540// Use xorl instead of xorw since we don't care about the high 16 bits,
2541// it's smaller, and it avoids a partial-register update.
Evan Chengb783fa32007-07-19 01:14:50 +00002542def MOV16r0 : I<0x31, MRMInitReg, (outs GR16:$dst), (ins),
Dan Gohman9203ab42008-07-30 18:09:17 +00002543 "xor{l}\t${dst:subreg32}, ${dst:subreg32}",
2544 [(set GR16:$dst, 0)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002545def MOV32r0 : I<0x31, MRMInitReg, (outs GR32:$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002546 "xor{l}\t$dst, $dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002547 [(set GR32:$dst, 0)]>;
Dan Gohman8aef09b2007-09-07 21:32:51 +00002548}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002549
2550// Basic operations on GR16 / GR32 subclasses GR16_ and GR32_ which contains only
2551// those registers that have GR8 sub-registers (i.e. AX - DX, EAX - EDX).
Chris Lattnerc90ee9c2008-01-10 07:59:24 +00002552let neverHasSideEffects = 1 in {
Evan Chengb783fa32007-07-19 01:14:50 +00002553def MOV16to16_ : I<0x89, MRMDestReg, (outs GR16_:$dst), (ins GR16:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002554 "mov{w}\t{$src, $dst|$dst, $src}", []>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002555def MOV32to32_ : I<0x89, MRMDestReg, (outs GR32_:$dst), (ins GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002556 "mov{l}\t{$src, $dst|$dst, $src}", []>;
Chris Lattnerc90ee9c2008-01-10 07:59:24 +00002557
Evan Chengb783fa32007-07-19 01:14:50 +00002558def MOV16_rr : I<0x89, MRMDestReg, (outs GR16_:$dst), (ins GR16_:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002559 "mov{w}\t{$src, $dst|$dst, $src}", []>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002560def MOV32_rr : I<0x89, MRMDestReg, (outs GR32_:$dst), (ins GR32_:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002561 "mov{l}\t{$src, $dst|$dst, $src}", []>;
Chris Lattnerc90ee9c2008-01-10 07:59:24 +00002562} // neverHasSideEffects
2563
2564let isSimpleLoad = 1, mayLoad = 1, isReMaterializable = 1, mayHaveSideEffects = 1 in {
Evan Chengb783fa32007-07-19 01:14:50 +00002565def MOV16_rm : I<0x8B, MRMSrcMem, (outs GR16_:$dst), (ins i16mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002566 "mov{w}\t{$src, $dst|$dst, $src}", []>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002567def MOV32_rm : I<0x8B, MRMSrcMem, (outs GR32_:$dst), (ins i32mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002568 "mov{l}\t{$src, $dst|$dst, $src}", []>;
Evan Cheng4e84e452007-08-30 05:49:43 +00002569}
Chris Lattnerc90ee9c2008-01-10 07:59:24 +00002570let mayStore = 1, neverHasSideEffects = 1 in {
Evan Chengb783fa32007-07-19 01:14:50 +00002571def MOV16_mr : I<0x89, MRMDestMem, (outs), (ins i16mem:$dst, GR16_:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002572 "mov{w}\t{$src, $dst|$dst, $src}", []>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002573def MOV32_mr : I<0x89, MRMDestMem, (outs), (ins i32mem:$dst, GR32_:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002574 "mov{l}\t{$src, $dst|$dst, $src}", []>;
Chris Lattnerc90ee9c2008-01-10 07:59:24 +00002575}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002576
2577//===----------------------------------------------------------------------===//
2578// Thread Local Storage Instructions
2579//
2580
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002581let Uses = [EBX] in
Anton Korobeynikov4fbf00b2008-05-04 21:36:32 +00002582def TLS_addr32 : I<0, Pseudo, (outs GR32:$dst), (ins i32imm:$sym),
2583 "leal\t${sym:mem}(,%ebx,1), $dst",
2584 [(set GR32:$dst, (X86tlsaddr tglobaltlsaddr:$sym))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002585
2586let AddedComplexity = 10 in
Anton Korobeynikov4fbf00b2008-05-04 21:36:32 +00002587def TLS_gs_rr : I<0, Pseudo, (outs GR32:$dst), (ins GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002588 "movl\t%gs:($src), $dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002589 [(set GR32:$dst, (load (add X86TLStp, GR32:$src)))]>;
2590
2591let AddedComplexity = 15 in
Evan Chengb783fa32007-07-19 01:14:50 +00002592def TLS_gs_ri : I<0, Pseudo, (outs GR32:$dst), (ins i32imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002593 "movl\t%gs:${src:mem}, $dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002594 [(set GR32:$dst,
2595 (load (add X86TLStp, (X86Wrapper tglobaltlsaddr:$src))))]>;
2596
Evan Chengb783fa32007-07-19 01:14:50 +00002597def TLS_tp : I<0, Pseudo, (outs GR32:$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002598 "movl\t%gs:0, $dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002599 [(set GR32:$dst, X86TLStp)]>;
2600
2601//===----------------------------------------------------------------------===//
2602// DWARF Pseudo Instructions
2603//
2604
Evan Chengb783fa32007-07-19 01:14:50 +00002605def DWARF_LOC : I<0, Pseudo, (outs),
2606 (ins i32imm:$line, i32imm:$col, i32imm:$file),
Dan Gohman77af4a82007-09-24 19:25:06 +00002607 ".loc\t${file:debug} ${line:debug} ${col:debug}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002608 [(dwarf_loc (i32 imm:$line), (i32 imm:$col),
2609 (i32 imm:$file))]>;
2610
2611//===----------------------------------------------------------------------===//
2612// EH Pseudo Instructions
2613//
2614let isTerminator = 1, isReturn = 1, isBarrier = 1,
Evan Cheng37e7c752007-07-21 00:34:19 +00002615 hasCtrlDep = 1 in {
Evan Chengb783fa32007-07-19 01:14:50 +00002616def EH_RETURN : I<0xC3, RawFrm, (outs), (ins GR32:$addr),
Dan Gohman91888f02007-07-31 20:11:57 +00002617 "ret\t#eh_return, addr: $addr",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002618 [(X86ehret GR32:$addr)]>;
2619
2620}
2621
2622//===----------------------------------------------------------------------===//
Andrew Lenharthe44f3902008-02-21 06:45:13 +00002623// Atomic support
2624//
Andrew Lenharth7a5a4b22008-03-01 13:37:02 +00002625
Evan Cheng3e171562008-04-19 01:20:30 +00002626// Atomic swap. These are just normal xchg instructions. But since a memory
2627// operand is referenced, the atomicity is ensured.
Dan Gohmana41a1c092008-08-06 15:52:50 +00002628let Constraints = "$val = $dst" in {
Evan Cheng3e171562008-04-19 01:20:30 +00002629def XCHG32rm : I<0x87, MRMSrcMem, (outs GR32:$dst), (ins i32mem:$ptr, GR32:$val),
2630 "xchg{l}\t{$val, $ptr|$ptr, $val}",
2631 [(set GR32:$dst, (atomic_swap_32 addr:$ptr, GR32:$val))]>;
2632def XCHG16rm : I<0x87, MRMSrcMem, (outs GR16:$dst), (ins i16mem:$ptr, GR16:$val),
2633 "xchg{w}\t{$val, $ptr|$ptr, $val}",
2634 [(set GR16:$dst, (atomic_swap_16 addr:$ptr, GR16:$val))]>,
2635 OpSize;
2636def XCHG8rm : I<0x86, MRMSrcMem, (outs GR8:$dst), (ins i8mem:$ptr, GR8:$val),
2637 "xchg{b}\t{$val, $ptr|$ptr, $val}",
2638 [(set GR8:$dst, (atomic_swap_8 addr:$ptr, GR8:$val))]>;
2639}
2640
Evan Chengd49dbb82008-04-18 20:55:36 +00002641// Atomic compare and swap.
Andrew Lenharth7dfe23f2008-03-01 21:52:34 +00002642let Defs = [EAX, EFLAGS], Uses = [EAX] in {
Evan Chengd49dbb82008-04-18 20:55:36 +00002643def LCMPXCHG32 : I<0xB1, MRMDestMem, (outs), (ins i32mem:$ptr, GR32:$swap),
Dale Johannesend20e4452008-08-19 18:47:28 +00002644 "lock\n\tcmpxchg{l}\t{$swap, $ptr|$ptr, $swap}",
Evan Cheng09fbdee2008-03-04 03:20:06 +00002645 [(X86cas addr:$ptr, GR32:$swap, 4)]>, TB, LOCK;
Andrew Lenharth7a5a4b22008-03-01 13:37:02 +00002646}
Dale Johannesenf160d802008-10-02 18:53:47 +00002647let Defs = [EAX, EDX, EFLAGS], Uses = [EAX, EBX, ECX, EDX] in {
Anton Korobeynikovc4067392008-07-22 16:22:48 +00002648def LCMPXCHG8B : I<0xC7, MRM1m, (outs), (ins i32mem:$ptr),
Dale Johannesend20e4452008-08-19 18:47:28 +00002649 "lock\n\tcmpxchg8b\t$ptr",
Andrew Lenharth81580822008-03-05 01:15:49 +00002650 [(X86cas8 addr:$ptr)]>, TB, LOCK;
2651}
Andrew Lenharth7dfe23f2008-03-01 21:52:34 +00002652
2653let Defs = [AX, EFLAGS], Uses = [AX] in {
Evan Chengd49dbb82008-04-18 20:55:36 +00002654def LCMPXCHG16 : I<0xB1, MRMDestMem, (outs), (ins i16mem:$ptr, GR16:$swap),
Dale Johannesend20e4452008-08-19 18:47:28 +00002655 "lock\n\tcmpxchg{w}\t{$swap, $ptr|$ptr, $swap}",
Evan Cheng09fbdee2008-03-04 03:20:06 +00002656 [(X86cas addr:$ptr, GR16:$swap, 2)]>, TB, OpSize, LOCK;
Andrew Lenharth7a5a4b22008-03-01 13:37:02 +00002657}
Andrew Lenharth7dfe23f2008-03-01 21:52:34 +00002658let Defs = [AL, EFLAGS], Uses = [AL] in {
Evan Chengd49dbb82008-04-18 20:55:36 +00002659def LCMPXCHG8 : I<0xB0, MRMDestMem, (outs), (ins i8mem:$ptr, GR8:$swap),
Dale Johannesend20e4452008-08-19 18:47:28 +00002660 "lock\n\tcmpxchg{b}\t{$swap, $ptr|$ptr, $swap}",
Evan Cheng09fbdee2008-03-04 03:20:06 +00002661 [(X86cas addr:$ptr, GR8:$swap, 1)]>, TB, LOCK;
Andrew Lenharth7a5a4b22008-03-01 13:37:02 +00002662}
2663
Evan Chengd49dbb82008-04-18 20:55:36 +00002664// Atomic exchange and add
2665let Constraints = "$val = $dst", Defs = [EFLAGS] in {
2666def LXADD32 : I<0xC1, MRMSrcMem, (outs GR32:$dst), (ins i32mem:$ptr, GR32:$val),
Dale Johannesend20e4452008-08-19 18:47:28 +00002667 "lock\n\txadd{l}\t{$val, $ptr|$ptr, $val}",
Mon P Wang6bde9ec2008-06-25 08:15:39 +00002668 [(set GR32:$dst, (atomic_load_add_32 addr:$ptr, GR32:$val))]>,
Evan Chengd49dbb82008-04-18 20:55:36 +00002669 TB, LOCK;
2670def LXADD16 : I<0xC1, MRMSrcMem, (outs GR16:$dst), (ins i16mem:$ptr, GR16:$val),
Dale Johannesend20e4452008-08-19 18:47:28 +00002671 "lock\n\txadd{w}\t{$val, $ptr|$ptr, $val}",
Mon P Wang6bde9ec2008-06-25 08:15:39 +00002672 [(set GR16:$dst, (atomic_load_add_16 addr:$ptr, GR16:$val))]>,
Evan Chengd49dbb82008-04-18 20:55:36 +00002673 TB, OpSize, LOCK;
2674def LXADD8 : I<0xC0, MRMSrcMem, (outs GR8:$dst), (ins i8mem:$ptr, GR8:$val),
Dale Johannesend20e4452008-08-19 18:47:28 +00002675 "lock\n\txadd{b}\t{$val, $ptr|$ptr, $val}",
Mon P Wang6bde9ec2008-06-25 08:15:39 +00002676 [(set GR8:$dst, (atomic_load_add_8 addr:$ptr, GR8:$val))]>,
Evan Chengd49dbb82008-04-18 20:55:36 +00002677 TB, LOCK;
Andrew Lenharth7a5a4b22008-03-01 13:37:02 +00002678}
2679
Mon P Wang6bde9ec2008-06-25 08:15:39 +00002680// Atomic exchange, and, or, xor
Mon P Wang078a62d2008-05-05 19:05:59 +00002681let Constraints = "$val = $dst", Defs = [EFLAGS],
2682 usesCustomDAGSchedInserter = 1 in {
Dan Gohman8aeb61f2008-05-12 20:22:45 +00002683def ATOMAND32 : I<0, Pseudo, (outs GR32:$dst),(ins i32mem:$ptr, GR32:$val),
Mon P Wang078a62d2008-05-05 19:05:59 +00002684 "#ATOMAND32 PSUEDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00002685 [(set GR32:$dst, (atomic_load_and_32 addr:$ptr, GR32:$val))]>;
Dan Gohman8aeb61f2008-05-12 20:22:45 +00002686def ATOMOR32 : I<0, Pseudo, (outs GR32:$dst),(ins i32mem:$ptr, GR32:$val),
Mon P Wang078a62d2008-05-05 19:05:59 +00002687 "#ATOMOR32 PSUEDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00002688 [(set GR32:$dst, (atomic_load_or_32 addr:$ptr, GR32:$val))]>;
Dan Gohman8aeb61f2008-05-12 20:22:45 +00002689def ATOMXOR32 : I<0, Pseudo,(outs GR32:$dst),(ins i32mem:$ptr, GR32:$val),
Mon P Wang078a62d2008-05-05 19:05:59 +00002690 "#ATOMXOR32 PSUEDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00002691 [(set GR32:$dst, (atomic_load_xor_32 addr:$ptr, GR32:$val))]>;
Andrew Lenharthaf02d592008-06-14 05:48:15 +00002692def ATOMNAND32 : I<0, Pseudo,(outs GR32:$dst),(ins i32mem:$ptr, GR32:$val),
Mon P Wang6bde9ec2008-06-25 08:15:39 +00002693 "#ATOMNAND32 PSUEDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00002694 [(set GR32:$dst, (atomic_load_nand_32 addr:$ptr, GR32:$val))]>;
Dan Gohman8aeb61f2008-05-12 20:22:45 +00002695def ATOMMIN32: I<0, Pseudo, (outs GR32:$dst), (ins i32mem:$ptr, GR32:$val),
Mon P Wang078a62d2008-05-05 19:05:59 +00002696 "#ATOMMIN32 PSUEDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00002697 [(set GR32:$dst, (atomic_load_min_32 addr:$ptr, GR32:$val))]>;
Dan Gohman8aeb61f2008-05-12 20:22:45 +00002698def ATOMMAX32: I<0, Pseudo, (outs GR32:$dst),(ins i32mem:$ptr, GR32:$val),
Mon P Wang078a62d2008-05-05 19:05:59 +00002699 "#ATOMMAX32 PSUEDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00002700 [(set GR32:$dst, (atomic_load_max_32 addr:$ptr, GR32:$val))]>;
Dan Gohman8aeb61f2008-05-12 20:22:45 +00002701def ATOMUMIN32: I<0, Pseudo, (outs GR32:$dst),(ins i32mem:$ptr, GR32:$val),
Mon P Wang078a62d2008-05-05 19:05:59 +00002702 "#ATOMUMIN32 PSUEDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00002703 [(set GR32:$dst, (atomic_load_umin_32 addr:$ptr, GR32:$val))]>;
Dan Gohman8aeb61f2008-05-12 20:22:45 +00002704def ATOMUMAX32: I<0, Pseudo, (outs GR32:$dst),(ins i32mem:$ptr, GR32:$val),
Mon P Wang078a62d2008-05-05 19:05:59 +00002705 "#ATOMUMAX32 PSUEDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00002706 [(set GR32:$dst, (atomic_load_umax_32 addr:$ptr, GR32:$val))]>;
Dale Johannesend20e4452008-08-19 18:47:28 +00002707
2708def ATOMAND16 : I<0, Pseudo, (outs GR16:$dst),(ins i16mem:$ptr, GR16:$val),
2709 "#ATOMAND16 PSUEDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00002710 [(set GR16:$dst, (atomic_load_and_16 addr:$ptr, GR16:$val))]>;
Dale Johannesend20e4452008-08-19 18:47:28 +00002711def ATOMOR16 : I<0, Pseudo, (outs GR16:$dst),(ins i16mem:$ptr, GR16:$val),
2712 "#ATOMOR16 PSUEDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00002713 [(set GR16:$dst, (atomic_load_or_16 addr:$ptr, GR16:$val))]>;
Dale Johannesend20e4452008-08-19 18:47:28 +00002714def ATOMXOR16 : I<0, Pseudo,(outs GR16:$dst),(ins i16mem:$ptr, GR16:$val),
2715 "#ATOMXOR16 PSUEDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00002716 [(set GR16:$dst, (atomic_load_xor_16 addr:$ptr, GR16:$val))]>;
Dale Johannesend20e4452008-08-19 18:47:28 +00002717def ATOMNAND16 : I<0, Pseudo,(outs GR16:$dst),(ins i16mem:$ptr, GR16:$val),
2718 "#ATOMNAND16 PSUEDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00002719 [(set GR16:$dst, (atomic_load_nand_16 addr:$ptr, GR16:$val))]>;
Dale Johannesend20e4452008-08-19 18:47:28 +00002720def ATOMMIN16: I<0, Pseudo, (outs GR16:$dst), (ins i16mem:$ptr, GR16:$val),
2721 "#ATOMMIN16 PSUEDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00002722 [(set GR16:$dst, (atomic_load_min_16 addr:$ptr, GR16:$val))]>;
Dale Johannesend20e4452008-08-19 18:47:28 +00002723def ATOMMAX16: I<0, Pseudo, (outs GR16:$dst),(ins i16mem:$ptr, GR16:$val),
2724 "#ATOMMAX16 PSUEDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00002725 [(set GR16:$dst, (atomic_load_max_16 addr:$ptr, GR16:$val))]>;
Dale Johannesend20e4452008-08-19 18:47:28 +00002726def ATOMUMIN16: I<0, Pseudo, (outs GR16:$dst),(ins i16mem:$ptr, GR16:$val),
2727 "#ATOMUMIN16 PSUEDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00002728 [(set GR16:$dst, (atomic_load_umin_16 addr:$ptr, GR16:$val))]>;
Dale Johannesend20e4452008-08-19 18:47:28 +00002729def ATOMUMAX16: I<0, Pseudo, (outs GR16:$dst),(ins i16mem:$ptr, GR16:$val),
2730 "#ATOMUMAX16 PSUEDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00002731 [(set GR16:$dst, (atomic_load_umax_16 addr:$ptr, GR16:$val))]>;
Dale Johannesend20e4452008-08-19 18:47:28 +00002732
2733def ATOMAND8 : I<0, Pseudo, (outs GR8:$dst),(ins i8mem:$ptr, GR8:$val),
2734 "#ATOMAND8 PSUEDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00002735 [(set GR8:$dst, (atomic_load_and_8 addr:$ptr, GR8:$val))]>;
Dale Johannesend20e4452008-08-19 18:47:28 +00002736def ATOMOR8 : I<0, Pseudo, (outs GR8:$dst),(ins i8mem:$ptr, GR8:$val),
2737 "#ATOMOR8 PSUEDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00002738 [(set GR8:$dst, (atomic_load_or_8 addr:$ptr, GR8:$val))]>;
Dale Johannesend20e4452008-08-19 18:47:28 +00002739def ATOMXOR8 : I<0, Pseudo,(outs GR8:$dst),(ins i8mem:$ptr, GR8:$val),
2740 "#ATOMXOR8 PSUEDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00002741 [(set GR8:$dst, (atomic_load_xor_8 addr:$ptr, GR8:$val))]>;
Dale Johannesend20e4452008-08-19 18:47:28 +00002742def ATOMNAND8 : I<0, Pseudo,(outs GR8:$dst),(ins i8mem:$ptr, GR8:$val),
2743 "#ATOMNAND8 PSUEDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00002744 [(set GR8:$dst, (atomic_load_nand_8 addr:$ptr, GR8:$val))]>;
Mon P Wang078a62d2008-05-05 19:05:59 +00002745}
2746
Dale Johannesenf160d802008-10-02 18:53:47 +00002747let Constraints = "$val1 = $dst1, $val2 = $dst2",
2748 Defs = [EFLAGS, EAX, EBX, ECX, EDX],
2749 Uses = [EAX, EBX, ECX, EDX],
Dale Johannesen44eb5372008-10-03 19:41:08 +00002750 mayLoad = 1, mayStore = 1,
Dale Johannesenf160d802008-10-02 18:53:47 +00002751 usesCustomDAGSchedInserter = 1 in {
2752def ATOMAND6432 : I<0, Pseudo, (outs GR32:$dst1, GR32:$dst2),
2753 (ins i64mem:$ptr, GR32:$val1, GR32:$val2),
2754 "#ATOMAND6432 PSUEDO!", []>;
2755def ATOMOR6432 : I<0, Pseudo, (outs GR32:$dst1, GR32:$dst2),
2756 (ins i64mem:$ptr, GR32:$val1, GR32:$val2),
2757 "#ATOMOR6432 PSUEDO!", []>;
2758def ATOMXOR6432 : I<0, Pseudo, (outs GR32:$dst1, GR32:$dst2),
2759 (ins i64mem:$ptr, GR32:$val1, GR32:$val2),
2760 "#ATOMXOR6432 PSUEDO!", []>;
2761def ATOMNAND6432 : I<0, Pseudo, (outs GR32:$dst1, GR32:$dst2),
2762 (ins i64mem:$ptr, GR32:$val1, GR32:$val2),
2763 "#ATOMNAND6432 PSUEDO!", []>;
2764def ATOMADD6432 : I<0, Pseudo, (outs GR32:$dst1, GR32:$dst2),
2765 (ins i64mem:$ptr, GR32:$val1, GR32:$val2),
2766 "#ATOMADD6432 PSUEDO!", []>;
2767def ATOMSUB6432 : I<0, Pseudo, (outs GR32:$dst1, GR32:$dst2),
2768 (ins i64mem:$ptr, GR32:$val1, GR32:$val2),
2769 "#ATOMSUB6432 PSUEDO!", []>;
Dale Johannesen51c58ee2008-10-03 22:25:52 +00002770def ATOMSWAP6432 : I<0, Pseudo, (outs GR32:$dst1, GR32:$dst2),
2771 (ins i64mem:$ptr, GR32:$val1, GR32:$val2),
2772 "#ATOMSWAP6432 PSUEDO!", []>;
Dale Johannesenf160d802008-10-02 18:53:47 +00002773}
2774
Andrew Lenharthe44f3902008-02-21 06:45:13 +00002775//===----------------------------------------------------------------------===//
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002776// Non-Instruction Patterns
2777//===----------------------------------------------------------------------===//
2778
Bill Wendlingfef06052008-09-16 21:48:12 +00002779// ConstantPool GlobalAddress, ExternalSymbol, and JumpTable
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002780def : Pat<(i32 (X86Wrapper tconstpool :$dst)), (MOV32ri tconstpool :$dst)>;
2781def : Pat<(i32 (X86Wrapper tjumptable :$dst)), (MOV32ri tjumptable :$dst)>;
Nate Begemanb52948972008-04-12 00:47:57 +00002782def : Pat<(i32 (X86Wrapper tglobaltlsaddr:$dst)),(MOV32ri tglobaltlsaddr:$dst)>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002783def : Pat<(i32 (X86Wrapper tglobaladdr :$dst)), (MOV32ri tglobaladdr :$dst)>;
2784def : Pat<(i32 (X86Wrapper texternalsym:$dst)), (MOV32ri texternalsym:$dst)>;
2785
2786def : Pat<(add GR32:$src1, (X86Wrapper tconstpool:$src2)),
2787 (ADD32ri GR32:$src1, tconstpool:$src2)>;
2788def : Pat<(add GR32:$src1, (X86Wrapper tjumptable:$src2)),
2789 (ADD32ri GR32:$src1, tjumptable:$src2)>;
2790def : Pat<(add GR32:$src1, (X86Wrapper tglobaladdr :$src2)),
2791 (ADD32ri GR32:$src1, tglobaladdr:$src2)>;
2792def : Pat<(add GR32:$src1, (X86Wrapper texternalsym:$src2)),
2793 (ADD32ri GR32:$src1, texternalsym:$src2)>;
2794
2795def : Pat<(store (i32 (X86Wrapper tglobaladdr:$src)), addr:$dst),
2796 (MOV32mi addr:$dst, tglobaladdr:$src)>;
2797def : Pat<(store (i32 (X86Wrapper texternalsym:$src)), addr:$dst),
2798 (MOV32mi addr:$dst, texternalsym:$src)>;
2799
2800// Calls
Arnold Schwaighofere2d6bbb2007-10-11 19:40:01 +00002801// tailcall stuff
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002802def : Pat<(X86tailcall GR32:$dst),
Arnold Schwaighofere2d6bbb2007-10-11 19:40:01 +00002803 (TAILCALL)>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002804
2805def : Pat<(X86tailcall (i32 tglobaladdr:$dst)),
Arnold Schwaighofere2d6bbb2007-10-11 19:40:01 +00002806 (TAILCALL)>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002807def : Pat<(X86tailcall (i32 texternalsym:$dst)),
Arnold Schwaighofere2d6bbb2007-10-11 19:40:01 +00002808 (TAILCALL)>;
2809
2810def : Pat<(X86tcret GR32:$dst, imm:$off),
2811 (TCRETURNri GR32:$dst, imm:$off)>;
2812
2813def : Pat<(X86tcret (i32 tglobaladdr:$dst), imm:$off),
2814 (TCRETURNdi texternalsym:$dst, imm:$off)>;
2815
2816def : Pat<(X86tcret (i32 texternalsym:$dst), imm:$off),
2817 (TCRETURNdi texternalsym:$dst, imm:$off)>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002818
2819def : Pat<(X86call (i32 tglobaladdr:$dst)),
2820 (CALLpcrel32 tglobaladdr:$dst)>;
2821def : Pat<(X86call (i32 texternalsym:$dst)),
2822 (CALLpcrel32 texternalsym:$dst)>;
2823
2824// X86 specific add which produces a flag.
2825def : Pat<(addc GR32:$src1, GR32:$src2),
2826 (ADD32rr GR32:$src1, GR32:$src2)>;
2827def : Pat<(addc GR32:$src1, (load addr:$src2)),
2828 (ADD32rm GR32:$src1, addr:$src2)>;
2829def : Pat<(addc GR32:$src1, imm:$src2),
2830 (ADD32ri GR32:$src1, imm:$src2)>;
2831def : Pat<(addc GR32:$src1, i32immSExt8:$src2),
2832 (ADD32ri8 GR32:$src1, i32immSExt8:$src2)>;
2833
2834def : Pat<(subc GR32:$src1, GR32:$src2),
2835 (SUB32rr GR32:$src1, GR32:$src2)>;
2836def : Pat<(subc GR32:$src1, (load addr:$src2)),
2837 (SUB32rm GR32:$src1, addr:$src2)>;
2838def : Pat<(subc GR32:$src1, imm:$src2),
2839 (SUB32ri GR32:$src1, imm:$src2)>;
2840def : Pat<(subc GR32:$src1, i32immSExt8:$src2),
2841 (SUB32ri8 GR32:$src1, i32immSExt8:$src2)>;
2842
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002843// Comparisons.
2844
2845// TEST R,R is smaller than CMP R,0
Evan Cheng621216e2007-09-29 00:00:36 +00002846def : Pat<(parallel (X86cmp GR8:$src1, 0), (implicit EFLAGS)),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002847 (TEST8rr GR8:$src1, GR8:$src1)>;
Evan Cheng621216e2007-09-29 00:00:36 +00002848def : Pat<(parallel (X86cmp GR16:$src1, 0), (implicit EFLAGS)),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002849 (TEST16rr GR16:$src1, GR16:$src1)>;
Evan Cheng621216e2007-09-29 00:00:36 +00002850def : Pat<(parallel (X86cmp GR32:$src1, 0), (implicit EFLAGS)),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002851 (TEST32rr GR32:$src1, GR32:$src1)>;
2852
Duncan Sands082524c2008-01-23 20:39:46 +00002853// zextload bool -> zextload byte
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002854def : Pat<(zextloadi8i1 addr:$src), (MOV8rm addr:$src)>;
2855def : Pat<(zextloadi16i1 addr:$src), (MOVZX16rm8 addr:$src)>;
2856def : Pat<(zextloadi32i1 addr:$src), (MOVZX32rm8 addr:$src)>;
2857
2858// extload bool -> extload byte
2859def : Pat<(extloadi8i1 addr:$src), (MOV8rm addr:$src)>;
Bill Wendlingce1c5c12008-08-22 20:51:05 +00002860def : Pat<(extloadi16i1 addr:$src), (MOVZX16rm8 addr:$src)>,
2861 Requires<[In32BitMode]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002862def : Pat<(extloadi32i1 addr:$src), (MOVZX32rm8 addr:$src)>;
Bill Wendlingce1c5c12008-08-22 20:51:05 +00002863def : Pat<(extloadi16i8 addr:$src), (MOVZX16rm8 addr:$src)>,
2864 Requires<[In32BitMode]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002865def : Pat<(extloadi32i8 addr:$src), (MOVZX32rm8 addr:$src)>;
2866def : Pat<(extloadi32i16 addr:$src), (MOVZX32rm16 addr:$src)>;
2867
Dan Gohmandd612bb2008-08-20 21:27:32 +00002868// anyext
Bill Wendlingce1c5c12008-08-22 20:51:05 +00002869def : Pat<(i16 (anyext GR8 :$src)), (MOVZX16rr8 GR8 :$src)>,
2870 Requires<[In32BitMode]>;
2871def : Pat<(i32 (anyext GR8 :$src)), (MOVZX32rr8 GR8 :$src)>,
2872 Requires<[In32BitMode]>;
Dan Gohmandd612bb2008-08-20 21:27:32 +00002873def : Pat<(i32 (anyext GR16:$src)),
2874 (INSERT_SUBREG (i32 (IMPLICIT_DEF)), GR16:$src, x86_subreg_16bit)>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002875
Evan Chengf2abee72007-12-13 00:43:27 +00002876// (and (i32 load), 255) -> (zextload i8)
Evan Cheng1e5e5452008-09-29 17:26:18 +00002877def : Pat<(i32 (and (nvloadi32 addr:$src), (i32 255))),
2878 (MOVZX32rm8 addr:$src)>;
2879def : Pat<(i32 (and (nvloadi32 addr:$src), (i32 65535))),
2880 (MOVZX32rm16 addr:$src)>;
Evan Chengf2abee72007-12-13 00:43:27 +00002881
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002882//===----------------------------------------------------------------------===//
2883// Some peepholes
2884//===----------------------------------------------------------------------===//
2885
Dan Gohman9203ab42008-07-30 18:09:17 +00002886// r & (2^16-1) ==> movz
2887def : Pat<(and GR32:$src1, 0xffff),
Dan Gohmandd612bb2008-08-20 21:27:32 +00002888 (MOVZX32rr16 (i16 (EXTRACT_SUBREG GR32:$src1, x86_subreg_16bit)))>;
Dan Gohman5beb1ff2008-08-06 18:27:21 +00002889// r & (2^8-1) ==> movz
2890def : Pat<(and GR32:$src1, 0xff),
Dan Gohmandd612bb2008-08-20 21:27:32 +00002891 (MOVZX32rr8 (i8 (EXTRACT_SUBREG (MOV32to32_ GR32:$src1),
2892 x86_subreg_8bit)))>,
Dan Gohman5beb1ff2008-08-06 18:27:21 +00002893 Requires<[In32BitMode]>;
2894// r & (2^8-1) ==> movz
2895def : Pat<(and GR16:$src1, 0xff),
Dan Gohmandd612bb2008-08-20 21:27:32 +00002896 (MOVZX16rr8 (i8 (EXTRACT_SUBREG (MOV16to16_ GR16:$src1),
2897 x86_subreg_8bit)))>,
2898 Requires<[In32BitMode]>;
2899
2900// sext_inreg patterns
2901def : Pat<(sext_inreg GR32:$src, i16),
2902 (MOVSX32rr16 (i16 (EXTRACT_SUBREG GR32:$src, x86_subreg_16bit)))>;
2903def : Pat<(sext_inreg GR32:$src, i8),
2904 (MOVSX32rr8 (i8 (EXTRACT_SUBREG (MOV32to32_ GR32:$src),
2905 x86_subreg_8bit)))>,
2906 Requires<[In32BitMode]>;
2907def : Pat<(sext_inreg GR16:$src, i8),
2908 (MOVSX16rr8 (i8 (EXTRACT_SUBREG (MOV16to16_ GR16:$src),
2909 x86_subreg_8bit)))>,
2910 Requires<[In32BitMode]>;
2911
2912// trunc patterns
2913def : Pat<(i16 (trunc GR32:$src)),
2914 (i16 (EXTRACT_SUBREG GR32:$src, x86_subreg_16bit))>;
2915def : Pat<(i8 (trunc GR32:$src)),
2916 (i8 (EXTRACT_SUBREG (MOV32to32_ GR32:$src), x86_subreg_8bit))>,
2917 Requires<[In32BitMode]>;
2918def : Pat<(i8 (trunc GR16:$src)),
2919 (i8 (EXTRACT_SUBREG (MOV16to16_ GR16:$src), x86_subreg_8bit))>,
Dan Gohman5beb1ff2008-08-06 18:27:21 +00002920 Requires<[In32BitMode]>;
Dan Gohman9203ab42008-07-30 18:09:17 +00002921
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002922// (shl x, 1) ==> (add x, x)
2923def : Pat<(shl GR8 :$src1, (i8 1)), (ADD8rr GR8 :$src1, GR8 :$src1)>;
2924def : Pat<(shl GR16:$src1, (i8 1)), (ADD16rr GR16:$src1, GR16:$src1)>;
2925def : Pat<(shl GR32:$src1, (i8 1)), (ADD32rr GR32:$src1, GR32:$src1)>;
2926
Evan Cheng76a64c72008-08-30 02:03:58 +00002927// (shl x (and y, 31)) ==> (shl x, y)
2928def : Pat<(shl GR8:$src1, (and CL:$amt, 31)),
2929 (SHL8rCL GR8:$src1)>;
2930def : Pat<(shl GR16:$src1, (and CL:$amt, 31)),
2931 (SHL16rCL GR16:$src1)>;
2932def : Pat<(shl GR32:$src1, (and CL:$amt, 31)),
2933 (SHL32rCL GR32:$src1)>;
2934def : Pat<(store (shl (loadi8 addr:$dst), (and CL:$amt, 31)), addr:$dst),
2935 (SHL8mCL addr:$dst)>;
2936def : Pat<(store (shl (loadi16 addr:$dst), (and CL:$amt, 31)), addr:$dst),
2937 (SHL16mCL addr:$dst)>;
2938def : Pat<(store (shl (loadi32 addr:$dst), (and CL:$amt, 31)), addr:$dst),
2939 (SHL32mCL addr:$dst)>;
2940
2941def : Pat<(srl GR8:$src1, (and CL:$amt, 31)),
2942 (SHR8rCL GR8:$src1)>;
2943def : Pat<(srl GR16:$src1, (and CL:$amt, 31)),
2944 (SHR16rCL GR16:$src1)>;
2945def : Pat<(srl GR32:$src1, (and CL:$amt, 31)),
2946 (SHR32rCL GR32:$src1)>;
2947def : Pat<(store (srl (loadi8 addr:$dst), (and CL:$amt, 31)), addr:$dst),
2948 (SHR8mCL addr:$dst)>;
2949def : Pat<(store (srl (loadi16 addr:$dst), (and CL:$amt, 31)), addr:$dst),
2950 (SHR16mCL addr:$dst)>;
2951def : Pat<(store (srl (loadi32 addr:$dst), (and CL:$amt, 31)), addr:$dst),
2952 (SHR32mCL addr:$dst)>;
2953
2954def : Pat<(sra GR8:$src1, (and CL:$amt, 31)),
2955 (SAR8rCL GR8:$src1)>;
2956def : Pat<(sra GR16:$src1, (and CL:$amt, 31)),
2957 (SAR16rCL GR16:$src1)>;
2958def : Pat<(sra GR32:$src1, (and CL:$amt, 31)),
2959 (SAR32rCL GR32:$src1)>;
2960def : Pat<(store (sra (loadi8 addr:$dst), (and CL:$amt, 31)), addr:$dst),
2961 (SAR8mCL addr:$dst)>;
2962def : Pat<(store (sra (loadi16 addr:$dst), (and CL:$amt, 31)), addr:$dst),
2963 (SAR16mCL addr:$dst)>;
2964def : Pat<(store (sra (loadi32 addr:$dst), (and CL:$amt, 31)), addr:$dst),
2965 (SAR32mCL addr:$dst)>;
2966
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002967// (or (x >> c) | (y << (32 - c))) ==> (shrd32 x, y, c)
2968def : Pat<(or (srl GR32:$src1, CL:$amt),
2969 (shl GR32:$src2, (sub 32, CL:$amt))),
2970 (SHRD32rrCL GR32:$src1, GR32:$src2)>;
2971
2972def : Pat<(store (or (srl (loadi32 addr:$dst), CL:$amt),
2973 (shl GR32:$src2, (sub 32, CL:$amt))), addr:$dst),
2974 (SHRD32mrCL addr:$dst, GR32:$src2)>;
2975
2976// (or (x << c) | (y >> (32 - c))) ==> (shld32 x, y, c)
2977def : Pat<(or (shl GR32:$src1, CL:$amt),
2978 (srl GR32:$src2, (sub 32, CL:$amt))),
2979 (SHLD32rrCL GR32:$src1, GR32:$src2)>;
2980
2981def : Pat<(store (or (shl (loadi32 addr:$dst), CL:$amt),
2982 (srl GR32:$src2, (sub 32, CL:$amt))), addr:$dst),
2983 (SHLD32mrCL addr:$dst, GR32:$src2)>;
2984
2985// (or (x >> c) | (y << (16 - c))) ==> (shrd16 x, y, c)
2986def : Pat<(or (srl GR16:$src1, CL:$amt),
2987 (shl GR16:$src2, (sub 16, CL:$amt))),
2988 (SHRD16rrCL GR16:$src1, GR16:$src2)>;
2989
2990def : Pat<(store (or (srl (loadi16 addr:$dst), CL:$amt),
2991 (shl GR16:$src2, (sub 16, CL:$amt))), addr:$dst),
2992 (SHRD16mrCL addr:$dst, GR16:$src2)>;
2993
2994// (or (x << c) | (y >> (16 - c))) ==> (shld16 x, y, c)
2995def : Pat<(or (shl GR16:$src1, CL:$amt),
2996 (srl GR16:$src2, (sub 16, CL:$amt))),
2997 (SHLD16rrCL GR16:$src1, GR16:$src2)>;
2998
2999def : Pat<(store (or (shl (loadi16 addr:$dst), CL:$amt),
3000 (srl GR16:$src2, (sub 16, CL:$amt))), addr:$dst),
3001 (SHLD16mrCL addr:$dst, GR16:$src2)>;
3002
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003003//===----------------------------------------------------------------------===//
3004// Floating Point Stack Support
3005//===----------------------------------------------------------------------===//
3006
3007include "X86InstrFPStack.td"
3008
3009//===----------------------------------------------------------------------===//
Evan Cheng86ab7d32007-07-31 08:04:03 +00003010// X86-64 Support
3011//===----------------------------------------------------------------------===//
3012
Chris Lattner2de8d2b2008-01-10 05:50:42 +00003013include "X86Instr64bit.td"
Evan Cheng86ab7d32007-07-31 08:04:03 +00003014
3015//===----------------------------------------------------------------------===//
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003016// XMM Floating point support (requires SSE / SSE2)
3017//===----------------------------------------------------------------------===//
3018
3019include "X86InstrSSE.td"
Evan Cheng5e4d1e72008-04-25 18:19:54 +00003020
3021//===----------------------------------------------------------------------===//
3022// MMX and XMM Packed Integer support (requires MMX, SSE, and SSE2)
3023//===----------------------------------------------------------------------===//
3024
3025include "X86InstrMMX.td"