blob: ffbcb16fda64381ba59a34bc4b1ec114d323f1d7 [file] [log] [blame]
Arnold Schwaighofer373e8652007-10-12 21:30:57 +00001//===- X86InstrInfo.td - Describe the X86 Instruction Set --*- tablegen -*-===//
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002//
3// The LLVM Compiler Infrastructure
4//
Chris Lattner081ce942007-12-29 20:36:04 +00005// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
Dan Gohmanf17a25c2007-07-18 16:29:46 +00007//
8//===----------------------------------------------------------------------===//
9//
10// This file describes the X86 instruction set, defining the instructions, and
11// properties of the instructions which are needed for code generation, machine
12// code emission, and analysis.
13//
14//===----------------------------------------------------------------------===//
15
16//===----------------------------------------------------------------------===//
17// X86 specific DAG Nodes.
18//
19
20def SDTIntShiftDOp: SDTypeProfile<1, 3,
21 [SDTCisSameAs<0, 1>, SDTCisSameAs<0, 2>,
22 SDTCisInt<0>, SDTCisInt<3>]>;
23
24def SDTX86CmpTest : SDTypeProfile<0, 2, [SDTCisSameAs<0, 1>]>;
25
Evan Cheng621216e2007-09-29 00:00:36 +000026def SDTX86Cmov : SDTypeProfile<1, 4,
Evan Cheng950aac02007-09-25 01:57:46 +000027 [SDTCisSameAs<0, 1>, SDTCisSameAs<1, 2>,
28 SDTCisVT<3, i8>, SDTCisVT<4, i32>]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +000029
Bill Wendlingae034ed2008-12-12 00:56:36 +000030def SDTArithOvf : SDTypeProfile<1, 2,
31 [SDTCisSameAs<0, 1>, SDTCisSameAs<0, 2>,
32 SDTCisInt<0>]>;
33
Evan Cheng621216e2007-09-29 00:00:36 +000034def SDTX86BrCond : SDTypeProfile<0, 3,
Evan Cheng950aac02007-09-25 01:57:46 +000035 [SDTCisVT<0, OtherVT>,
36 SDTCisVT<1, i8>, SDTCisVT<2, i32>]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +000037
Evan Cheng621216e2007-09-29 00:00:36 +000038def SDTX86SetCC : SDTypeProfile<1, 2,
Evan Cheng950aac02007-09-25 01:57:46 +000039 [SDTCisVT<0, i8>,
40 SDTCisVT<1, i8>, SDTCisVT<2, i32>]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +000041
Andrew Lenharth7dfe23f2008-03-01 21:52:34 +000042def SDTX86cas : SDTypeProfile<0, 3, [SDTCisPtrTy<0>, SDTCisInt<1>,
43 SDTCisVT<2, i8>]>;
Andrew Lenharth81580822008-03-05 01:15:49 +000044def SDTX86cas8 : SDTypeProfile<0, 1, [SDTCisPtrTy<0>]>;
Andrew Lenharth7dfe23f2008-03-01 21:52:34 +000045
Dale Johannesenf160d802008-10-02 18:53:47 +000046def SDTX86atomicBinary : SDTypeProfile<2, 3, [SDTCisInt<0>, SDTCisInt<1>,
47 SDTCisPtrTy<2>, SDTCisInt<3>,SDTCisInt<4>]>;
Chris Lattnerb56cc342008-03-11 03:23:40 +000048def SDTX86Ret : SDTypeProfile<0, -1, [SDTCisVT<0, i16>]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +000049
Bill Wendling7173da52007-11-13 09:19:02 +000050def SDT_X86CallSeqStart : SDCallSeqStart<[ SDTCisVT<0, i32> ]>;
51def SDT_X86CallSeqEnd : SDCallSeqEnd<[ SDTCisVT<0, i32>,
52 SDTCisVT<1, i32> ]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +000053
Dan Gohman3329ffe2008-05-29 19:57:41 +000054def SDT_X86Call : SDTypeProfile<0, -1, [SDTCisVT<0, iPTR>]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +000055
56def SDTX86RepStr : SDTypeProfile<0, 1, [SDTCisVT<0, OtherVT>]>;
57
58def SDTX86RdTsc : SDTypeProfile<0, 0, []>;
59
60def SDTX86Wrapper : SDTypeProfile<1, 1, [SDTCisSameAs<0, 1>, SDTCisPtrTy<0>]>;
61
62def SDT_X86TLSADDR : SDTypeProfile<1, 1, [SDTCisPtrTy<0>, SDTCisInt<1>]>;
63
64def SDT_X86TLSTP : SDTypeProfile<1, 0, [SDTCisPtrTy<0>]>;
65
66def SDT_X86EHRET : SDTypeProfile<0, 1, [SDTCisInt<0>]>;
67
Arnold Schwaighofere2d6bbb2007-10-11 19:40:01 +000068def SDT_X86TCRET : SDTypeProfile<0, 2, [SDTCisPtrTy<0>, SDTCisVT<1, i32>]>;
69
Evan Cheng48679f42007-12-14 02:13:44 +000070def X86bsf : SDNode<"X86ISD::BSF", SDTIntUnaryOp>;
71def X86bsr : SDNode<"X86ISD::BSR", SDTIntUnaryOp>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +000072def X86shld : SDNode<"X86ISD::SHLD", SDTIntShiftDOp>;
73def X86shrd : SDNode<"X86ISD::SHRD", SDTIntShiftDOp>;
74
Evan Cheng621216e2007-09-29 00:00:36 +000075def X86cmp : SDNode<"X86ISD::CMP" , SDTX86CmpTest>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +000076
Evan Cheng621216e2007-09-29 00:00:36 +000077def X86cmov : SDNode<"X86ISD::CMOV", SDTX86Cmov>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +000078def X86brcond : SDNode<"X86ISD::BRCOND", SDTX86BrCond,
Evan Cheng950aac02007-09-25 01:57:46 +000079 [SDNPHasChain]>;
Evan Cheng621216e2007-09-29 00:00:36 +000080def X86setcc : SDNode<"X86ISD::SETCC", SDTX86SetCC>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +000081
Andrew Lenharth7dfe23f2008-03-01 21:52:34 +000082def X86cas : SDNode<"X86ISD::LCMPXCHG_DAG", SDTX86cas,
83 [SDNPHasChain, SDNPInFlag, SDNPOutFlag, SDNPMayStore,
84 SDNPMayLoad]>;
Andrew Lenharth81580822008-03-05 01:15:49 +000085def X86cas8 : SDNode<"X86ISD::LCMPXCHG8_DAG", SDTX86cas8,
86 [SDNPHasChain, SDNPInFlag, SDNPOutFlag, SDNPMayStore,
87 SDNPMayLoad]>;
Dale Johannesenf160d802008-10-02 18:53:47 +000088def X86AtomAdd64 : SDNode<"X86ISD::ATOMADD64_DAG", SDTX86atomicBinary,
89 [SDNPHasChain, SDNPMayStore,
90 SDNPMayLoad, SDNPMemOperand]>;
91def X86AtomSub64 : SDNode<"X86ISD::ATOMSUB64_DAG", SDTX86atomicBinary,
92 [SDNPHasChain, SDNPMayStore,
93 SDNPMayLoad, SDNPMemOperand]>;
94def X86AtomOr64 : SDNode<"X86ISD::ATOMOR64_DAG", SDTX86atomicBinary,
95 [SDNPHasChain, SDNPMayStore,
96 SDNPMayLoad, SDNPMemOperand]>;
97def X86AtomXor64 : SDNode<"X86ISD::ATOMXOR64_DAG", SDTX86atomicBinary,
98 [SDNPHasChain, SDNPMayStore,
99 SDNPMayLoad, SDNPMemOperand]>;
100def X86AtomAnd64 : SDNode<"X86ISD::ATOMAND64_DAG", SDTX86atomicBinary,
101 [SDNPHasChain, SDNPMayStore,
102 SDNPMayLoad, SDNPMemOperand]>;
103def X86AtomNand64 : SDNode<"X86ISD::ATOMNAND64_DAG", SDTX86atomicBinary,
104 [SDNPHasChain, SDNPMayStore,
105 SDNPMayLoad, SDNPMemOperand]>;
Dale Johannesen51c58ee2008-10-03 22:25:52 +0000106def X86AtomSwap64 : SDNode<"X86ISD::ATOMSWAP64_DAG", SDTX86atomicBinary,
107 [SDNPHasChain, SDNPMayStore,
108 SDNPMayLoad, SDNPMemOperand]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000109def X86retflag : SDNode<"X86ISD::RET_FLAG", SDTX86Ret,
110 [SDNPHasChain, SDNPOptInFlag]>;
111
112def X86callseq_start :
113 SDNode<"ISD::CALLSEQ_START", SDT_X86CallSeqStart,
114 [SDNPHasChain, SDNPOutFlag]>;
115def X86callseq_end :
116 SDNode<"ISD::CALLSEQ_END", SDT_X86CallSeqEnd,
Arnold Schwaighofere2d6bbb2007-10-11 19:40:01 +0000117 [SDNPHasChain, SDNPOptInFlag, SDNPOutFlag]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000118
119def X86call : SDNode<"X86ISD::CALL", SDT_X86Call,
120 [SDNPHasChain, SDNPOutFlag, SDNPOptInFlag]>;
121
122def X86tailcall: SDNode<"X86ISD::TAILCALL", SDT_X86Call,
123 [SDNPHasChain, SDNPOutFlag, SDNPOptInFlag]>;
124
125def X86rep_stos: SDNode<"X86ISD::REP_STOS", SDTX86RepStr,
Chris Lattnerca4e0fe2008-01-10 05:12:37 +0000126 [SDNPHasChain, SDNPInFlag, SDNPOutFlag, SDNPMayStore]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000127def X86rep_movs: SDNode<"X86ISD::REP_MOVS", SDTX86RepStr,
Chris Lattnerca4e0fe2008-01-10 05:12:37 +0000128 [SDNPHasChain, SDNPInFlag, SDNPOutFlag, SDNPMayStore,
129 SDNPMayLoad]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000130
131def X86rdtsc : SDNode<"X86ISD::RDTSC_DAG",SDTX86RdTsc,
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000132 [SDNPHasChain, SDNPOutFlag, SDNPSideEffect]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000133
134def X86Wrapper : SDNode<"X86ISD::Wrapper", SDTX86Wrapper>;
135def X86WrapperRIP : SDNode<"X86ISD::WrapperRIP", SDTX86Wrapper>;
136
137def X86tlsaddr : SDNode<"X86ISD::TLSADDR", SDT_X86TLSADDR,
Anton Korobeynikov4fbf00b2008-05-04 21:36:32 +0000138 [SDNPHasChain, SDNPOptInFlag, SDNPOutFlag]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000139def X86TLStp : SDNode<"X86ISD::THREAD_POINTER", SDT_X86TLSTP, []>;
140
141def X86ehret : SDNode<"X86ISD::EH_RETURN", SDT_X86EHRET,
142 [SDNPHasChain]>;
143
Arnold Schwaighofere2d6bbb2007-10-11 19:40:01 +0000144def X86tcret : SDNode<"X86ISD::TC_RETURN", SDT_X86TCRET,
145 [SDNPHasChain, SDNPOptInFlag]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000146
Bill Wendlingae034ed2008-12-12 00:56:36 +0000147def X86add_ovf : SDNode<"X86ISD::ADD", SDTArithOvf>;
148def X86sub_ovf : SDNode<"X86ISD::SUB", SDTArithOvf>;
149def X86mul_ovf : SDNode<"X86ISD::MUL", SDTArithOvf>;
150
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000151//===----------------------------------------------------------------------===//
152// X86 Operand Definitions.
153//
154
155// *mem - Operand definitions for the funky X86 addressing mode operands.
156//
157class X86MemOperand<string printMethod> : Operand<iPTR> {
158 let PrintMethod = printMethod;
159 let MIOperandInfo = (ops ptr_rc, i8imm, ptr_rc, i32imm);
160}
161
162def i8mem : X86MemOperand<"printi8mem">;
163def i16mem : X86MemOperand<"printi16mem">;
164def i32mem : X86MemOperand<"printi32mem">;
165def i64mem : X86MemOperand<"printi64mem">;
166def i128mem : X86MemOperand<"printi128mem">;
167def f32mem : X86MemOperand<"printf32mem">;
168def f64mem : X86MemOperand<"printf64mem">;
Dale Johannesen4ab00bd2007-08-05 18:49:15 +0000169def f80mem : X86MemOperand<"printf80mem">;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000170def f128mem : X86MemOperand<"printf128mem">;
171
172def lea32mem : Operand<i32> {
173 let PrintMethod = "printi32mem";
174 let MIOperandInfo = (ops GR32, i8imm, GR32, i32imm);
175}
176
177def SSECC : Operand<i8> {
178 let PrintMethod = "printSSECC";
179}
180
181def piclabel: Operand<i32> {
182 let PrintMethod = "printPICLabel";
183}
184
185// A couple of more descriptive operand definitions.
186// 16-bits but only 8 bits are significant.
187def i16i8imm : Operand<i16>;
188// 32-bits but only 8 bits are significant.
189def i32i8imm : Operand<i32>;
190
191// Branch targets have OtherVT type.
192def brtarget : Operand<OtherVT>;
193
194//===----------------------------------------------------------------------===//
195// X86 Complex Pattern Definitions.
196//
197
198// Define X86 specific addressing mode.
199def addr : ComplexPattern<iPTR, 4, "SelectAddr", [], []>;
200def lea32addr : ComplexPattern<i32, 4, "SelectLEAAddr",
201 [add, mul, shl, or, frameindex], []>;
202
203//===----------------------------------------------------------------------===//
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000204// X86 Instruction Predicate Definitions.
205def HasMMX : Predicate<"Subtarget->hasMMX()">;
206def HasSSE1 : Predicate<"Subtarget->hasSSE1()">;
207def HasSSE2 : Predicate<"Subtarget->hasSSE2()">;
208def HasSSE3 : Predicate<"Subtarget->hasSSE3()">;
209def HasSSSE3 : Predicate<"Subtarget->hasSSSE3()">;
Nate Begemanb2975562008-02-03 07:18:54 +0000210def HasSSE41 : Predicate<"Subtarget->hasSSE41()">;
211def HasSSE42 : Predicate<"Subtarget->hasSSE42()">;
Dale Johannesene0e0fd02007-09-23 14:52:20 +0000212def FPStackf32 : Predicate<"!Subtarget->hasSSE1()">;
213def FPStackf64 : Predicate<"!Subtarget->hasSSE2()">;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000214def In32BitMode : Predicate<"!Subtarget->is64Bit()">;
215def In64BitMode : Predicate<"Subtarget->is64Bit()">;
216def SmallCode : Predicate<"TM.getCodeModel() == CodeModel::Small">;
217def NotSmallCode : Predicate<"TM.getCodeModel() != CodeModel::Small">;
218def IsStatic : Predicate<"TM.getRelocationModel() == Reloc::Static">;
Evan Cheng13559d62008-09-26 23:41:32 +0000219def OptForSpeed : Predicate<"!OptForSize">;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000220
221//===----------------------------------------------------------------------===//
Evan Cheng86ab7d32007-07-31 08:04:03 +0000222// X86 Instruction Format Definitions.
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000223//
224
Evan Cheng86ab7d32007-07-31 08:04:03 +0000225include "X86InstrFormats.td"
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000226
227//===----------------------------------------------------------------------===//
228// Pattern fragments...
229//
230
231// X86 specific condition code. These correspond to CondCode in
232// X86InstrInfo.h. They must be kept in synch.
233def X86_COND_A : PatLeaf<(i8 0)>;
234def X86_COND_AE : PatLeaf<(i8 1)>;
235def X86_COND_B : PatLeaf<(i8 2)>;
236def X86_COND_BE : PatLeaf<(i8 3)>;
237def X86_COND_E : PatLeaf<(i8 4)>;
238def X86_COND_G : PatLeaf<(i8 5)>;
239def X86_COND_GE : PatLeaf<(i8 6)>;
240def X86_COND_L : PatLeaf<(i8 7)>;
241def X86_COND_LE : PatLeaf<(i8 8)>;
242def X86_COND_NE : PatLeaf<(i8 9)>;
243def X86_COND_NO : PatLeaf<(i8 10)>;
244def X86_COND_NP : PatLeaf<(i8 11)>;
245def X86_COND_NS : PatLeaf<(i8 12)>;
Bill Wendlingd06b4202008-11-26 22:37:40 +0000246def X86_COND_NC : PatLeaf<(i8 13)>;
247def X86_COND_O : PatLeaf<(i8 14)>;
248def X86_COND_P : PatLeaf<(i8 15)>;
249def X86_COND_S : PatLeaf<(i8 16)>;
250def X86_COND_C : PatLeaf<(i8 17)>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000251
252def i16immSExt8 : PatLeaf<(i16 imm), [{
253 // i16immSExt8 predicate - True if the 16-bit immediate fits in a 8-bit
254 // sign extended field.
Dan Gohmanfaeb4a32008-09-12 16:56:44 +0000255 return (int16_t)N->getZExtValue() == (int8_t)N->getZExtValue();
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000256}]>;
257
258def i32immSExt8 : PatLeaf<(i32 imm), [{
259 // i32immSExt8 predicate - True if the 32-bit immediate fits in a 8-bit
260 // sign extended field.
Dan Gohmanfaeb4a32008-09-12 16:56:44 +0000261 return (int32_t)N->getZExtValue() == (int8_t)N->getZExtValue();
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000262}]>;
263
264// Helper fragments for loads.
Evan Chengb3e25ea2008-05-13 18:59:59 +0000265// It's always safe to treat a anyext i16 load as a i32 load if the i16 is
266// known to be 32-bit aligned or better. Ditto for i8 to i16.
Dan Gohman2a174122008-10-15 06:50:19 +0000267def loadi16 : PatFrag<(ops node:$ptr), (i16 (unindexedload node:$ptr)), [{
Dan Gohman8335c412008-08-20 15:24:22 +0000268 LoadSDNode *LD = cast<LoadSDNode>(N);
Dan Gohman8335c412008-08-20 15:24:22 +0000269 ISD::LoadExtType ExtType = LD->getExtensionType();
270 if (ExtType == ISD::NON_EXTLOAD)
271 return true;
272 if (ExtType == ISD::EXTLOAD)
273 return LD->getAlignment() >= 2 && !LD->isVolatile();
Evan Cheng8b765e92008-05-13 00:54:02 +0000274 return false;
275}]>;
276
Dan Gohman2a174122008-10-15 06:50:19 +0000277def loadi16_anyext : PatFrag<(ops node:$ptr), (i32 (unindexedload node:$ptr)), [{
Evan Cheng56ec77b2008-09-24 23:27:55 +0000278 LoadSDNode *LD = cast<LoadSDNode>(N);
Evan Cheng56ec77b2008-09-24 23:27:55 +0000279 ISD::LoadExtType ExtType = LD->getExtensionType();
280 if (ExtType == ISD::EXTLOAD)
281 return LD->getAlignment() >= 2 && !LD->isVolatile();
282 return false;
283}]>;
284
Dan Gohman2a174122008-10-15 06:50:19 +0000285def loadi32 : PatFrag<(ops node:$ptr), (i32 (unindexedload node:$ptr)), [{
Dan Gohman8335c412008-08-20 15:24:22 +0000286 LoadSDNode *LD = cast<LoadSDNode>(N);
Dan Gohman8335c412008-08-20 15:24:22 +0000287 ISD::LoadExtType ExtType = LD->getExtensionType();
288 if (ExtType == ISD::NON_EXTLOAD)
289 return true;
290 if (ExtType == ISD::EXTLOAD)
291 return LD->getAlignment() >= 4 && !LD->isVolatile();
Evan Cheng8b765e92008-05-13 00:54:02 +0000292 return false;
293}]>;
294
Dan Gohman2a174122008-10-15 06:50:19 +0000295def nvloadi32 : PatFrag<(ops node:$ptr), (i32 (unindexedload node:$ptr)), [{
Evan Cheng1e5e5452008-09-29 17:26:18 +0000296 LoadSDNode *LD = cast<LoadSDNode>(N);
297 if (LD->isVolatile())
298 return false;
Evan Cheng1e5e5452008-09-29 17:26:18 +0000299 ISD::LoadExtType ExtType = LD->getExtensionType();
300 if (ExtType == ISD::NON_EXTLOAD)
301 return true;
302 if (ExtType == ISD::EXTLOAD)
303 return LD->getAlignment() >= 4;
304 return false;
305}]>;
306
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000307def loadi8 : PatFrag<(ops node:$ptr), (i8 (load node:$ptr))>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000308def loadi64 : PatFrag<(ops node:$ptr), (i64 (load node:$ptr))>;
309
310def loadf32 : PatFrag<(ops node:$ptr), (f32 (load node:$ptr))>;
311def loadf64 : PatFrag<(ops node:$ptr), (f64 (load node:$ptr))>;
Dale Johannesen4ab00bd2007-08-05 18:49:15 +0000312def loadf80 : PatFrag<(ops node:$ptr), (f80 (load node:$ptr))>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000313
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000314def sextloadi16i8 : PatFrag<(ops node:$ptr), (i16 (sextloadi8 node:$ptr))>;
315def sextloadi32i8 : PatFrag<(ops node:$ptr), (i32 (sextloadi8 node:$ptr))>;
316def sextloadi32i16 : PatFrag<(ops node:$ptr), (i32 (sextloadi16 node:$ptr))>;
317
318def zextloadi8i1 : PatFrag<(ops node:$ptr), (i8 (zextloadi1 node:$ptr))>;
319def zextloadi16i1 : PatFrag<(ops node:$ptr), (i16 (zextloadi1 node:$ptr))>;
320def zextloadi32i1 : PatFrag<(ops node:$ptr), (i32 (zextloadi1 node:$ptr))>;
321def zextloadi16i8 : PatFrag<(ops node:$ptr), (i16 (zextloadi8 node:$ptr))>;
322def zextloadi32i8 : PatFrag<(ops node:$ptr), (i32 (zextloadi8 node:$ptr))>;
323def zextloadi32i16 : PatFrag<(ops node:$ptr), (i32 (zextloadi16 node:$ptr))>;
324
325def extloadi8i1 : PatFrag<(ops node:$ptr), (i8 (extloadi1 node:$ptr))>;
326def extloadi16i1 : PatFrag<(ops node:$ptr), (i16 (extloadi1 node:$ptr))>;
327def extloadi32i1 : PatFrag<(ops node:$ptr), (i32 (extloadi1 node:$ptr))>;
328def extloadi16i8 : PatFrag<(ops node:$ptr), (i16 (extloadi8 node:$ptr))>;
329def extloadi32i8 : PatFrag<(ops node:$ptr), (i32 (extloadi8 node:$ptr))>;
330def extloadi32i16 : PatFrag<(ops node:$ptr), (i32 (extloadi16 node:$ptr))>;
331
Chris Lattner21da6382008-02-19 17:37:35 +0000332
333// An 'and' node with a single use.
334def and_su : PatFrag<(ops node:$lhs, node:$rhs), (and node:$lhs, node:$rhs), [{
Evan Cheng9123cfa2008-03-04 00:40:35 +0000335 return N->hasOneUse();
Chris Lattner21da6382008-02-19 17:37:35 +0000336}]>;
337
Dan Gohman921581d2008-10-17 01:23:35 +0000338// 'shld' and 'shrd' instruction patterns. Note that even though these have
339// the srl and shl in their patterns, the C++ code must still check for them,
340// because predicates are tested before children nodes are explored.
341
342def shrd : PatFrag<(ops node:$src1, node:$amt1, node:$src2, node:$amt2),
343 (or (srl node:$src1, node:$amt1),
344 (shl node:$src2, node:$amt2)), [{
345 assert(N->getOpcode() == ISD::OR);
346 return N->getOperand(0).getOpcode() == ISD::SRL &&
347 N->getOperand(1).getOpcode() == ISD::SHL &&
348 isa<ConstantSDNode>(N->getOperand(0).getOperand(1)) &&
349 isa<ConstantSDNode>(N->getOperand(1).getOperand(1)) &&
350 N->getOperand(0).getConstantOperandVal(1) ==
351 N->getValueSizeInBits(0) - N->getOperand(1).getConstantOperandVal(1);
352}]>;
353
354def shld : PatFrag<(ops node:$src1, node:$amt1, node:$src2, node:$amt2),
355 (or (shl node:$src1, node:$amt1),
356 (srl node:$src2, node:$amt2)), [{
357 assert(N->getOpcode() == ISD::OR);
358 return N->getOperand(0).getOpcode() == ISD::SHL &&
359 N->getOperand(1).getOpcode() == ISD::SRL &&
360 isa<ConstantSDNode>(N->getOperand(0).getOperand(1)) &&
361 isa<ConstantSDNode>(N->getOperand(1).getOperand(1)) &&
362 N->getOperand(0).getConstantOperandVal(1) ==
363 N->getValueSizeInBits(0) - N->getOperand(1).getConstantOperandVal(1);
364}]>;
365
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000366//===----------------------------------------------------------------------===//
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000367// Instruction list...
368//
369
370// ADJCALLSTACKDOWN/UP implicitly use/def ESP because they may be expanded into
371// a stack adjustment and the codegen must know that they may modify the stack
372// pointer before prolog-epilog rewriting occurs.
Chris Lattnerb56cc342008-03-11 03:23:40 +0000373// Pessimistically assume ADJCALLSTACKDOWN / ADJCALLSTACKUP will become
374// sub / add which can clobber EFLAGS.
Evan Cheng037364a2007-09-28 01:19:48 +0000375let Defs = [ESP, EFLAGS], Uses = [ESP] in {
Dan Gohman01c9f772008-10-01 18:28:06 +0000376def ADJCALLSTACKDOWN32 : I<0, Pseudo, (outs), (ins i32imm:$amt),
377 "#ADJCALLSTACKDOWN",
Chris Lattnerfe5d4022008-10-11 22:08:30 +0000378 [(X86callseq_start timm:$amt)]>,
Dan Gohman01c9f772008-10-01 18:28:06 +0000379 Requires<[In32BitMode]>;
380def ADJCALLSTACKUP32 : I<0, Pseudo, (outs), (ins i32imm:$amt1, i32imm:$amt2),
381 "#ADJCALLSTACKUP",
Chris Lattnerfe5d4022008-10-11 22:08:30 +0000382 [(X86callseq_end timm:$amt1, timm:$amt2)]>,
Dan Gohman01c9f772008-10-01 18:28:06 +0000383 Requires<[In32BitMode]>;
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000384}
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000385
386// Nop
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000387let neverHasSideEffects = 1 in
388 def NOOP : I<0x90, RawFrm, (outs), (ins), "nop", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000389
Evan Cheng0729ccf2008-01-05 00:41:47 +0000390// PIC base
Dan Gohman9499cfe2008-10-01 04:14:30 +0000391let neverHasSideEffects = 1, isNotDuplicable = 1, Uses = [ESP] in
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000392 def MOVPC32r : Ii32<0xE8, Pseudo, (outs GR32:$reg), (ins piclabel:$label),
393 "call\t$label\n\tpop{l}\t$reg", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000394
395//===----------------------------------------------------------------------===//
396// Control Flow Instructions...
397//
398
399// Return instructions.
400let isTerminator = 1, isReturn = 1, isBarrier = 1,
Chris Lattnerb56cc342008-03-11 03:23:40 +0000401 hasCtrlDep = 1, FPForm = SpecialFP, FPFormBits = SpecialFP.Value in {
Dan Gohman2c4be2a2008-05-31 02:11:25 +0000402 def RET : I <0xC3, RawFrm, (outs), (ins variable_ops),
Chris Lattnerb56cc342008-03-11 03:23:40 +0000403 "ret",
Dan Gohman2c4be2a2008-05-31 02:11:25 +0000404 [(X86retflag 0)]>;
Chris Lattnerb56cc342008-03-11 03:23:40 +0000405 def RETI : Ii16<0xC2, RawFrm, (outs), (ins i16imm:$amt, variable_ops),
406 "ret\t$amt",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000407 [(X86retflag imm:$amt)]>;
408}
409
410// All branches are RawFrm, Void, Branch, and Terminators
Evan Cheng37e7c752007-07-21 00:34:19 +0000411let isBranch = 1, isTerminator = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +0000412 class IBr<bits<8> opcode, dag ins, string asm, list<dag> pattern> :
413 I<opcode, RawFrm, (outs), ins, asm, pattern>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000414
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000415let isBranch = 1, isBarrier = 1 in
Dan Gohman91888f02007-07-31 20:11:57 +0000416 def JMP : IBr<0xE9, (ins brtarget:$dst), "jmp\t$dst", [(br bb:$dst)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000417
Owen Andersonf8053082007-11-12 07:39:39 +0000418// Indirect branches
419let isBranch = 1, isTerminator = 1, isBarrier = 1, isIndirectBranch = 1 in {
Dan Gohman91888f02007-07-31 20:11:57 +0000420 def JMP32r : I<0xFF, MRM4r, (outs), (ins GR32:$dst), "jmp{l}\t{*}$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000421 [(brind GR32:$dst)]>;
Dan Gohman91888f02007-07-31 20:11:57 +0000422 def JMP32m : I<0xFF, MRM4m, (outs), (ins i32mem:$dst), "jmp{l}\t{*}$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000423 [(brind (loadi32 addr:$dst))]>;
424}
425
426// Conditional branches
Evan Cheng950aac02007-09-25 01:57:46 +0000427let Uses = [EFLAGS] in {
Dan Gohman91888f02007-07-31 20:11:57 +0000428def JE : IBr<0x84, (ins brtarget:$dst), "je\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000429 [(X86brcond bb:$dst, X86_COND_E, EFLAGS)]>, TB;
Dan Gohman91888f02007-07-31 20:11:57 +0000430def JNE : IBr<0x85, (ins brtarget:$dst), "jne\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000431 [(X86brcond bb:$dst, X86_COND_NE, EFLAGS)]>, TB;
Dan Gohman91888f02007-07-31 20:11:57 +0000432def JL : IBr<0x8C, (ins brtarget:$dst), "jl\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000433 [(X86brcond bb:$dst, X86_COND_L, EFLAGS)]>, TB;
Dan Gohman91888f02007-07-31 20:11:57 +0000434def JLE : IBr<0x8E, (ins brtarget:$dst), "jle\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000435 [(X86brcond bb:$dst, X86_COND_LE, EFLAGS)]>, TB;
Dan Gohman91888f02007-07-31 20:11:57 +0000436def JG : IBr<0x8F, (ins brtarget:$dst), "jg\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000437 [(X86brcond bb:$dst, X86_COND_G, EFLAGS)]>, TB;
Dan Gohman91888f02007-07-31 20:11:57 +0000438def JGE : IBr<0x8D, (ins brtarget:$dst), "jge\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000439 [(X86brcond bb:$dst, X86_COND_GE, EFLAGS)]>, TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000440
Dan Gohman91888f02007-07-31 20:11:57 +0000441def JB : IBr<0x82, (ins brtarget:$dst), "jb\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000442 [(X86brcond bb:$dst, X86_COND_B, EFLAGS)]>, TB;
Dan Gohman91888f02007-07-31 20:11:57 +0000443def JBE : IBr<0x86, (ins brtarget:$dst), "jbe\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000444 [(X86brcond bb:$dst, X86_COND_BE, EFLAGS)]>, TB;
Dan Gohman91888f02007-07-31 20:11:57 +0000445def JA : IBr<0x87, (ins brtarget:$dst), "ja\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000446 [(X86brcond bb:$dst, X86_COND_A, EFLAGS)]>, TB;
Dan Gohman91888f02007-07-31 20:11:57 +0000447def JAE : IBr<0x83, (ins brtarget:$dst), "jae\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000448 [(X86brcond bb:$dst, X86_COND_AE, EFLAGS)]>, TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000449
Dan Gohman91888f02007-07-31 20:11:57 +0000450def JS : IBr<0x88, (ins brtarget:$dst), "js\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000451 [(X86brcond bb:$dst, X86_COND_S, EFLAGS)]>, TB;
Dan Gohman91888f02007-07-31 20:11:57 +0000452def JNS : IBr<0x89, (ins brtarget:$dst), "jns\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000453 [(X86brcond bb:$dst, X86_COND_NS, EFLAGS)]>, TB;
Dan Gohman91888f02007-07-31 20:11:57 +0000454def JP : IBr<0x8A, (ins brtarget:$dst), "jp\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000455 [(X86brcond bb:$dst, X86_COND_P, EFLAGS)]>, TB;
Dan Gohman91888f02007-07-31 20:11:57 +0000456def JNP : IBr<0x8B, (ins brtarget:$dst), "jnp\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000457 [(X86brcond bb:$dst, X86_COND_NP, EFLAGS)]>, TB;
Dan Gohman91888f02007-07-31 20:11:57 +0000458def JO : IBr<0x80, (ins brtarget:$dst), "jo\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000459 [(X86brcond bb:$dst, X86_COND_O, EFLAGS)]>, TB;
Dan Gohman91888f02007-07-31 20:11:57 +0000460def JNO : IBr<0x81, (ins brtarget:$dst), "jno\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000461 [(X86brcond bb:$dst, X86_COND_NO, EFLAGS)]>, TB;
Bill Wendlingd06b4202008-11-26 22:37:40 +0000462def JC : IBr<0x82, (ins brtarget:$dst), "jc\t$dst",
463 [(X86brcond bb:$dst, X86_COND_C, EFLAGS)]>, TB;
464def JNC : IBr<0x83, (ins brtarget:$dst), "jnc\t$dst",
465 [(X86brcond bb:$dst, X86_COND_NC, EFLAGS)]>, TB;
Evan Cheng950aac02007-09-25 01:57:46 +0000466} // Uses = [EFLAGS]
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000467
468//===----------------------------------------------------------------------===//
469// Call Instructions...
470//
Evan Cheng37e7c752007-07-21 00:34:19 +0000471let isCall = 1 in
Dan Gohman01c9f772008-10-01 18:28:06 +0000472 // All calls clobber the non-callee saved registers. ESP is marked as
473 // a use to prevent stack-pointer assignments that appear immediately
474 // before calls from potentially appearing dead. Uses for argument
475 // registers are added manually.
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000476 let Defs = [EAX, ECX, EDX, FP0, FP1, FP2, FP3, FP4, FP5, FP6, ST0,
477 MM0, MM1, MM2, MM3, MM4, MM5, MM6, MM7,
Evan Cheng2293b252008-10-17 21:02:22 +0000478 XMM0, XMM1, XMM2, XMM3, XMM4, XMM5, XMM6, XMM7,
479 XMM8, XMM9, XMM10, XMM11, XMM12, XMM13, XMM14, XMM15, EFLAGS],
Dan Gohman9499cfe2008-10-01 04:14:30 +0000480 Uses = [ESP] in {
Evan Cheng34f93712007-12-22 02:26:46 +0000481 def CALLpcrel32 : Ii32<0xE8, RawFrm, (outs), (ins i32imm:$dst,variable_ops),
482 "call\t${dst:call}", []>;
Evan Chengb783fa32007-07-19 01:14:50 +0000483 def CALL32r : I<0xFF, MRM2r, (outs), (ins GR32:$dst, variable_ops),
Dan Gohman91888f02007-07-31 20:11:57 +0000484 "call\t{*}$dst", [(X86call GR32:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000485 def CALL32m : I<0xFF, MRM2m, (outs), (ins i32mem:$dst, variable_ops),
Dan Gohmanea4faba2008-05-29 21:50:34 +0000486 "call\t{*}$dst", [(X86call (loadi32 addr:$dst))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000487 }
488
489// Tail call stuff.
Arnold Schwaighofere2d6bbb2007-10-11 19:40:01 +0000490
Chris Lattnerb56cc342008-03-11 03:23:40 +0000491def TAILCALL : I<0, Pseudo, (outs), (ins),
Arnold Schwaighofere2d6bbb2007-10-11 19:40:01 +0000492 "#TAILCALL",
493 []>;
494
Evan Cheng37e7c752007-07-21 00:34:19 +0000495let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1 in
Arnold Schwaighofer6fd37ac2008-03-19 16:39:45 +0000496def TCRETURNdi : I<0, Pseudo, (outs), (ins i32imm:$dst, i32imm:$offset, variable_ops),
Arnold Schwaighofere2d6bbb2007-10-11 19:40:01 +0000497 "#TC_RETURN $dst $offset",
498 []>;
499
500let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1 in
Arnold Schwaighofer6fd37ac2008-03-19 16:39:45 +0000501def TCRETURNri : I<0, Pseudo, (outs), (ins GR32:$dst, i32imm:$offset, variable_ops),
Arnold Schwaighofere2d6bbb2007-10-11 19:40:01 +0000502 "#TC_RETURN $dst $offset",
503 []>;
504
505let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1 in
Arnold Schwaighofera0032722008-04-30 09:16:33 +0000506
Arnold Schwaighofere2d6bbb2007-10-11 19:40:01 +0000507 def TAILJMPd : IBr<0xE9, (ins i32imm:$dst), "jmp\t${dst:call} # TAILCALL",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000508 []>;
Evan Cheng37e7c752007-07-21 00:34:19 +0000509let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1 in
Arnold Schwaighofere2d6bbb2007-10-11 19:40:01 +0000510 def TAILJMPr : I<0xFF, MRM4r, (outs), (ins GR32:$dst), "jmp{l}\t{*}$dst # TAILCALL",
511 []>;
Evan Cheng37e7c752007-07-21 00:34:19 +0000512let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +0000513 def TAILJMPm : I<0xFF, MRM4m, (outs), (ins i32mem:$dst),
Arnold Schwaighofere2d6bbb2007-10-11 19:40:01 +0000514 "jmp\t{*}$dst # TAILCALL", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000515
516//===----------------------------------------------------------------------===//
517// Miscellaneous Instructions...
518//
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000519let Defs = [EBP, ESP], Uses = [EBP, ESP], mayLoad = 1, neverHasSideEffects=1 in
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000520def LEAVE : I<0xC9, RawFrm,
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000521 (outs), (ins), "leave", []>;
522
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000523let Defs = [ESP], Uses = [ESP], neverHasSideEffects=1 in {
524let mayLoad = 1 in
Evan Chengd8434332007-09-26 01:29:06 +0000525def POP32r : I<0x58, AddRegFrm, (outs GR32:$reg), (ins), "pop{l}\t$reg", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000526
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000527let mayStore = 1 in
Evan Chengd8434332007-09-26 01:29:06 +0000528def PUSH32r : I<0x50, AddRegFrm, (outs), (ins GR32:$reg), "push{l}\t$reg",[]>;
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000529}
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000530
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000531let Defs = [ESP, EFLAGS], Uses = [ESP], mayLoad = 1, neverHasSideEffects=1 in
Evan Chengf1341312007-09-26 21:28:00 +0000532def POPFD : I<0x9D, RawFrm, (outs), (ins), "popf", []>;
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000533let Defs = [ESP], Uses = [ESP, EFLAGS], mayStore = 1, neverHasSideEffects=1 in
Evan Chengf1341312007-09-26 21:28:00 +0000534def PUSHFD : I<0x9C, RawFrm, (outs), (ins), "pushf", []>;
Evan Chengd8434332007-09-26 01:29:06 +0000535
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000536let isTwoAddress = 1 in // GR32 = bswap GR32
537 def BSWAP32r : I<0xC8, AddRegFrm,
Evan Chengb783fa32007-07-19 01:14:50 +0000538 (outs GR32:$dst), (ins GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000539 "bswap{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000540 [(set GR32:$dst, (bswap GR32:$src))]>, TB;
541
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000542
Evan Cheng48679f42007-12-14 02:13:44 +0000543// Bit scan instructions.
544let Defs = [EFLAGS] in {
Evan Cheng4e33de92007-12-14 18:49:43 +0000545def BSF16rr : I<0xBC, MRMSrcReg, (outs GR16:$dst), (ins GR16:$src),
Dan Gohmancdb54c62007-12-14 15:10:00 +0000546 "bsf{w}\t{$src, $dst|$dst, $src}",
Evan Cheng7cfbfe32007-12-14 08:30:15 +0000547 [(set GR16:$dst, (X86bsf GR16:$src)), (implicit EFLAGS)]>, TB;
Evan Cheng48679f42007-12-14 02:13:44 +0000548def BSF16rm : I<0xBC, MRMSrcMem, (outs GR16:$dst), (ins i16mem:$src),
Dan Gohmancdb54c62007-12-14 15:10:00 +0000549 "bsf{w}\t{$src, $dst|$dst, $src}",
Evan Cheng7cfbfe32007-12-14 08:30:15 +0000550 [(set GR16:$dst, (X86bsf (loadi16 addr:$src))),
551 (implicit EFLAGS)]>, TB;
Evan Cheng4e33de92007-12-14 18:49:43 +0000552def BSF32rr : I<0xBC, MRMSrcReg, (outs GR32:$dst), (ins GR32:$src),
Dan Gohmancdb54c62007-12-14 15:10:00 +0000553 "bsf{l}\t{$src, $dst|$dst, $src}",
Evan Cheng7cfbfe32007-12-14 08:30:15 +0000554 [(set GR32:$dst, (X86bsf GR32:$src)), (implicit EFLAGS)]>, TB;
Evan Cheng48679f42007-12-14 02:13:44 +0000555def BSF32rm : I<0xBC, MRMSrcMem, (outs GR32:$dst), (ins i32mem:$src),
Dan Gohmancdb54c62007-12-14 15:10:00 +0000556 "bsf{l}\t{$src, $dst|$dst, $src}",
Evan Cheng7cfbfe32007-12-14 08:30:15 +0000557 [(set GR32:$dst, (X86bsf (loadi32 addr:$src))),
558 (implicit EFLAGS)]>, TB;
Evan Cheng48679f42007-12-14 02:13:44 +0000559
Evan Cheng4e33de92007-12-14 18:49:43 +0000560def BSR16rr : I<0xBD, MRMSrcReg, (outs GR16:$dst), (ins GR16:$src),
Dan Gohmancdb54c62007-12-14 15:10:00 +0000561 "bsr{w}\t{$src, $dst|$dst, $src}",
Evan Cheng7cfbfe32007-12-14 08:30:15 +0000562 [(set GR16:$dst, (X86bsr GR16:$src)), (implicit EFLAGS)]>, TB;
Evan Cheng48679f42007-12-14 02:13:44 +0000563def BSR16rm : I<0xBD, MRMSrcMem, (outs GR16:$dst), (ins i16mem:$src),
Dan Gohmancdb54c62007-12-14 15:10:00 +0000564 "bsr{w}\t{$src, $dst|$dst, $src}",
Evan Cheng7cfbfe32007-12-14 08:30:15 +0000565 [(set GR16:$dst, (X86bsr (loadi16 addr:$src))),
566 (implicit EFLAGS)]>, TB;
Evan Cheng4e33de92007-12-14 18:49:43 +0000567def BSR32rr : I<0xBD, MRMSrcReg, (outs GR32:$dst), (ins GR32:$src),
Dan Gohmancdb54c62007-12-14 15:10:00 +0000568 "bsr{l}\t{$src, $dst|$dst, $src}",
Evan Cheng7cfbfe32007-12-14 08:30:15 +0000569 [(set GR32:$dst, (X86bsr GR32:$src)), (implicit EFLAGS)]>, TB;
Evan Cheng48679f42007-12-14 02:13:44 +0000570def BSR32rm : I<0xBD, MRMSrcMem, (outs GR32:$dst), (ins i32mem:$src),
Dan Gohmancdb54c62007-12-14 15:10:00 +0000571 "bsr{l}\t{$src, $dst|$dst, $src}",
Evan Cheng7cfbfe32007-12-14 08:30:15 +0000572 [(set GR32:$dst, (X86bsr (loadi32 addr:$src))),
573 (implicit EFLAGS)]>, TB;
Evan Cheng48679f42007-12-14 02:13:44 +0000574} // Defs = [EFLAGS]
575
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000576let neverHasSideEffects = 1 in
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000577def LEA16r : I<0x8D, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +0000578 (outs GR16:$dst), (ins i32mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000579 "lea{w}\t{$src|$dst}, {$dst|$src}", []>, OpSize;
Evan Cheng1ea8e6b2008-03-27 01:41:09 +0000580let isReMaterializable = 1 in
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000581def LEA32r : I<0x8D, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +0000582 (outs GR32:$dst), (ins lea32mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000583 "lea{l}\t{$src|$dst}, {$dst|$src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000584 [(set GR32:$dst, lea32addr:$src)]>, Requires<[In32BitMode]>;
585
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000586let Defs = [ECX,EDI,ESI], Uses = [ECX,EDI,ESI] in {
Evan Chengb783fa32007-07-19 01:14:50 +0000587def REP_MOVSB : I<0xA4, RawFrm, (outs), (ins), "{rep;movsb|rep movsb}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000588 [(X86rep_movs i8)]>, REP;
Evan Chengb783fa32007-07-19 01:14:50 +0000589def REP_MOVSW : I<0xA5, RawFrm, (outs), (ins), "{rep;movsw|rep movsw}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000590 [(X86rep_movs i16)]>, REP, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +0000591def REP_MOVSD : I<0xA5, RawFrm, (outs), (ins), "{rep;movsl|rep movsd}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000592 [(X86rep_movs i32)]>, REP;
593}
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000594
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000595let Defs = [ECX,EDI], Uses = [AL,ECX,EDI] in
Evan Chengb783fa32007-07-19 01:14:50 +0000596def REP_STOSB : I<0xAA, RawFrm, (outs), (ins), "{rep;stosb|rep stosb}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000597 [(X86rep_stos i8)]>, REP;
598let Defs = [ECX,EDI], Uses = [AX,ECX,EDI] in
Evan Chengb783fa32007-07-19 01:14:50 +0000599def REP_STOSW : I<0xAB, RawFrm, (outs), (ins), "{rep;stosw|rep stosw}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000600 [(X86rep_stos i16)]>, REP, OpSize;
601let Defs = [ECX,EDI], Uses = [EAX,ECX,EDI] in
Evan Chengb783fa32007-07-19 01:14:50 +0000602def REP_STOSD : I<0xAB, RawFrm, (outs), (ins), "{rep;stosl|rep stosd}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000603 [(X86rep_stos i32)]>, REP;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000604
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000605let Defs = [RAX, RDX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000606def RDTSC : I<0x31, RawFrm, (outs), (ins), "rdtsc", [(X86rdtsc)]>,
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000607 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000608
Anton Korobeynikov39d40ba2008-01-15 07:02:33 +0000609let isBarrier = 1, hasCtrlDep = 1 in {
Chris Lattner56b941f2008-01-15 21:58:22 +0000610def TRAP : I<0x0B, RawFrm, (outs), (ins), "ud2", [(trap)]>, TB;
Anton Korobeynikov39d40ba2008-01-15 07:02:33 +0000611}
612
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000613//===----------------------------------------------------------------------===//
614// Input/Output Instructions...
615//
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000616let Defs = [AL], Uses = [DX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000617def IN8rr : I<0xEC, RawFrm, (outs), (ins),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000618 "in{b}\t{%dx, %al|%AL, %DX}", []>;
619let Defs = [AX], Uses = [DX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000620def IN16rr : I<0xED, RawFrm, (outs), (ins),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000621 "in{w}\t{%dx, %ax|%AX, %DX}", []>, OpSize;
622let Defs = [EAX], Uses = [DX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000623def IN32rr : I<0xED, RawFrm, (outs), (ins),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000624 "in{l}\t{%dx, %eax|%EAX, %DX}", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000625
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000626let Defs = [AL] in
Evan Chengb783fa32007-07-19 01:14:50 +0000627def IN8ri : Ii8<0xE4, RawFrm, (outs), (ins i16i8imm:$port),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000628 "in{b}\t{$port, %al|%AL, $port}", []>;
629let Defs = [AX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000630def IN16ri : Ii8<0xE5, RawFrm, (outs), (ins i16i8imm:$port),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000631 "in{w}\t{$port, %ax|%AX, $port}", []>, OpSize;
632let Defs = [EAX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000633def IN32ri : Ii8<0xE5, RawFrm, (outs), (ins i16i8imm:$port),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000634 "in{l}\t{$port, %eax|%EAX, $port}", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000635
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000636let Uses = [DX, AL] in
Evan Chengb783fa32007-07-19 01:14:50 +0000637def OUT8rr : I<0xEE, RawFrm, (outs), (ins),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000638 "out{b}\t{%al, %dx|%DX, %AL}", []>;
639let Uses = [DX, AX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000640def OUT16rr : I<0xEF, RawFrm, (outs), (ins),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000641 "out{w}\t{%ax, %dx|%DX, %AX}", []>, OpSize;
642let Uses = [DX, EAX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000643def OUT32rr : I<0xEF, RawFrm, (outs), (ins),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000644 "out{l}\t{%eax, %dx|%DX, %EAX}", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000645
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000646let Uses = [AL] in
Evan Chengb783fa32007-07-19 01:14:50 +0000647def OUT8ir : Ii8<0xE6, RawFrm, (outs), (ins i16i8imm:$port),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000648 "out{b}\t{%al, $port|$port, %AL}", []>;
649let Uses = [AX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000650def OUT16ir : Ii8<0xE7, RawFrm, (outs), (ins i16i8imm:$port),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000651 "out{w}\t{%ax, $port|$port, %AX}", []>, OpSize;
652let Uses = [EAX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000653def OUT32ir : Ii8<0xE7, RawFrm, (outs), (ins i16i8imm:$port),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000654 "out{l}\t{%eax, $port|$port, %EAX}", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000655
656//===----------------------------------------------------------------------===//
657// Move Instructions...
658//
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000659let neverHasSideEffects = 1 in {
Evan Chengb783fa32007-07-19 01:14:50 +0000660def MOV8rr : I<0x88, MRMDestReg, (outs GR8 :$dst), (ins GR8 :$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000661 "mov{b}\t{$src, $dst|$dst, $src}", []>;
Evan Chengb783fa32007-07-19 01:14:50 +0000662def MOV16rr : I<0x89, MRMDestReg, (outs GR16:$dst), (ins GR16:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000663 "mov{w}\t{$src, $dst|$dst, $src}", []>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +0000664def MOV32rr : I<0x89, MRMDestReg, (outs GR32:$dst), (ins GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000665 "mov{l}\t{$src, $dst|$dst, $src}", []>;
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000666}
Evan Cheng6f26e8b2008-06-18 08:13:07 +0000667let isReMaterializable = 1, isAsCheapAsAMove = 1 in {
Evan Chengb783fa32007-07-19 01:14:50 +0000668def MOV8ri : Ii8 <0xB0, AddRegFrm, (outs GR8 :$dst), (ins i8imm :$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000669 "mov{b}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000670 [(set GR8:$dst, imm:$src)]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000671def MOV16ri : Ii16<0xB8, AddRegFrm, (outs GR16:$dst), (ins i16imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000672 "mov{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000673 [(set GR16:$dst, imm:$src)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +0000674def MOV32ri : Ii32<0xB8, AddRegFrm, (outs GR32:$dst), (ins i32imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000675 "mov{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000676 [(set GR32:$dst, imm:$src)]>;
677}
Evan Chengb783fa32007-07-19 01:14:50 +0000678def MOV8mi : Ii8 <0xC6, MRM0m, (outs), (ins i8mem :$dst, i8imm :$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000679 "mov{b}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000680 [(store (i8 imm:$src), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000681def MOV16mi : Ii16<0xC7, MRM0m, (outs), (ins i16mem:$dst, i16imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000682 "mov{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000683 [(store (i16 imm:$src), addr:$dst)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +0000684def MOV32mi : Ii32<0xC7, MRM0m, (outs), (ins i32mem:$dst, i32imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000685 "mov{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000686 [(store (i32 imm:$src), addr:$dst)]>;
687
Dan Gohman5574cc72008-12-03 18:15:48 +0000688let canFoldAsLoad = 1, isReMaterializable = 1, mayHaveSideEffects = 1 in {
Evan Chengb783fa32007-07-19 01:14:50 +0000689def MOV8rm : I<0x8A, MRMSrcMem, (outs GR8 :$dst), (ins i8mem :$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000690 "mov{b}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000691 [(set GR8:$dst, (load addr:$src))]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000692def MOV16rm : I<0x8B, MRMSrcMem, (outs GR16:$dst), (ins i16mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000693 "mov{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000694 [(set GR16:$dst, (load addr:$src))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +0000695def MOV32rm : I<0x8B, MRMSrcMem, (outs GR32:$dst), (ins i32mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000696 "mov{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000697 [(set GR32:$dst, (load addr:$src))]>;
Evan Cheng4e84e452007-08-30 05:49:43 +0000698}
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000699
Evan Chengb783fa32007-07-19 01:14:50 +0000700def MOV8mr : I<0x88, MRMDestMem, (outs), (ins i8mem :$dst, GR8 :$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000701 "mov{b}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000702 [(store GR8:$src, addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000703def MOV16mr : I<0x89, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000704 "mov{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000705 [(store GR16:$src, addr:$dst)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +0000706def MOV32mr : I<0x89, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000707 "mov{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000708 [(store GR32:$src, addr:$dst)]>;
709
710//===----------------------------------------------------------------------===//
711// Fixed-Register Multiplication and Division Instructions...
712//
713
714// Extra precision multiplication
Evan Cheng55687072007-09-14 21:48:26 +0000715let Defs = [AL,AH,EFLAGS], Uses = [AL] in
Dan Gohman91888f02007-07-31 20:11:57 +0000716def MUL8r : I<0xF6, MRM4r, (outs), (ins GR8:$src), "mul{b}\t$src",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000717 // FIXME: Used for 8-bit mul, ignore result upper 8 bits.
718 // This probably ought to be moved to a def : Pat<> if the
719 // syntax can be accepted.
Bill Wendling7e04be62008-12-09 22:08:41 +0000720 [(set AL, (mul AL, GR8:$src))]>; // AL,AH = AL*GR8
Chris Lattnerc7e96e72008-01-11 07:18:17 +0000721let Defs = [AX,DX,EFLAGS], Uses = [AX], neverHasSideEffects = 1 in
Bill Wendling7e04be62008-12-09 22:08:41 +0000722def MUL16r : I<0xF7, MRM4r, (outs), (ins GR16:$src), "mul{w}\t$src",
723 []>, OpSize; // AX,DX = AX*GR16
Chris Lattnerc7e96e72008-01-11 07:18:17 +0000724let Defs = [EAX,EDX,EFLAGS], Uses = [EAX], neverHasSideEffects = 1 in
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000725def MUL32r : I<0xF7, MRM4r, (outs), (ins GR32:$src), "mul{l}\t$src", []>;
726 // EAX,EDX = EAX*GR32
Evan Cheng55687072007-09-14 21:48:26 +0000727let Defs = [AL,AH,EFLAGS], Uses = [AL] in
Evan Chengb783fa32007-07-19 01:14:50 +0000728def MUL8m : I<0xF6, MRM4m, (outs), (ins i8mem :$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000729 "mul{b}\t$src",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000730 // FIXME: Used for 8-bit mul, ignore result upper 8 bits.
731 // This probably ought to be moved to a def : Pat<> if the
732 // syntax can be accepted.
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000733 [(set AL, (mul AL, (loadi8 addr:$src)))]>; // AL,AH = AL*[mem8]
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000734let mayLoad = 1, neverHasSideEffects = 1 in {
Evan Cheng55687072007-09-14 21:48:26 +0000735let Defs = [AX,DX,EFLAGS], Uses = [AX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000736def MUL16m : I<0xF7, MRM4m, (outs), (ins i16mem:$src),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000737 "mul{w}\t$src", []>, OpSize; // AX,DX = AX*[mem16]
Evan Cheng55687072007-09-14 21:48:26 +0000738let Defs = [EAX,EDX,EFLAGS], Uses = [EAX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000739def MUL32m : I<0xF7, MRM4m, (outs), (ins i32mem:$src),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000740 "mul{l}\t$src", []>; // EAX,EDX = EAX*[mem32]
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000741}
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000742
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000743let neverHasSideEffects = 1 in {
Evan Cheng55687072007-09-14 21:48:26 +0000744let Defs = [AL,AH,EFLAGS], Uses = [AL] in
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000745def IMUL8r : I<0xF6, MRM5r, (outs), (ins GR8:$src), "imul{b}\t$src", []>;
746 // AL,AH = AL*GR8
Evan Cheng55687072007-09-14 21:48:26 +0000747let Defs = [AX,DX,EFLAGS], Uses = [AX] in
Dan Gohman91888f02007-07-31 20:11:57 +0000748def IMUL16r : I<0xF7, MRM5r, (outs), (ins GR16:$src), "imul{w}\t$src", []>,
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000749 OpSize; // AX,DX = AX*GR16
Evan Cheng55687072007-09-14 21:48:26 +0000750let Defs = [EAX,EDX,EFLAGS], Uses = [EAX] in
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000751def IMUL32r : I<0xF7, MRM5r, (outs), (ins GR32:$src), "imul{l}\t$src", []>;
752 // EAX,EDX = EAX*GR32
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000753let mayLoad = 1 in {
Evan Cheng55687072007-09-14 21:48:26 +0000754let Defs = [AL,AH,EFLAGS], Uses = [AL] in
Evan Chengb783fa32007-07-19 01:14:50 +0000755def IMUL8m : I<0xF6, MRM5m, (outs), (ins i8mem :$src),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000756 "imul{b}\t$src", []>; // AL,AH = AL*[mem8]
Evan Cheng55687072007-09-14 21:48:26 +0000757let Defs = [AX,DX,EFLAGS], Uses = [AX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000758def IMUL16m : I<0xF7, MRM5m, (outs), (ins i16mem:$src),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000759 "imul{w}\t$src", []>, OpSize; // AX,DX = AX*[mem16]
760let Defs = [EAX,EDX], Uses = [EAX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000761def IMUL32m : I<0xF7, MRM5m, (outs), (ins i32mem:$src),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000762 "imul{l}\t$src", []>; // EAX,EDX = EAX*[mem32]
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000763}
Dan Gohmand44572d2008-11-18 21:29:14 +0000764} // neverHasSideEffects
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000765
766// unsigned division/remainder
Dale Johannesend8fd3562008-10-07 18:54:28 +0000767let Defs = [AL,AH,EFLAGS], Uses = [AX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000768def DIV8r : I<0xF6, MRM6r, (outs), (ins GR8:$src), // AX/r8 = AL,AH
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000769 "div{b}\t$src", []>;
Evan Cheng55687072007-09-14 21:48:26 +0000770let Defs = [AX,DX,EFLAGS], Uses = [AX,DX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000771def DIV16r : I<0xF7, MRM6r, (outs), (ins GR16:$src), // DX:AX/r16 = AX,DX
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000772 "div{w}\t$src", []>, OpSize;
Evan Cheng55687072007-09-14 21:48:26 +0000773let Defs = [EAX,EDX,EFLAGS], Uses = [EAX,EDX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000774def DIV32r : I<0xF7, MRM6r, (outs), (ins GR32:$src), // EDX:EAX/r32 = EAX,EDX
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000775 "div{l}\t$src", []>;
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000776let mayLoad = 1 in {
Dale Johannesend8fd3562008-10-07 18:54:28 +0000777let Defs = [AL,AH,EFLAGS], Uses = [AX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000778def DIV8m : I<0xF6, MRM6m, (outs), (ins i8mem:$src), // AX/[mem8] = AL,AH
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000779 "div{b}\t$src", []>;
Evan Cheng55687072007-09-14 21:48:26 +0000780let Defs = [AX,DX,EFLAGS], Uses = [AX,DX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000781def DIV16m : I<0xF7, MRM6m, (outs), (ins i16mem:$src), // DX:AX/[mem16] = AX,DX
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000782 "div{w}\t$src", []>, OpSize;
Evan Cheng55687072007-09-14 21:48:26 +0000783let Defs = [EAX,EDX,EFLAGS], Uses = [EAX,EDX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000784def DIV32m : I<0xF7, MRM6m, (outs), (ins i32mem:$src), // EDX:EAX/[mem32] = EAX,EDX
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000785 "div{l}\t$src", []>;
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000786}
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000787
788// Signed division/remainder.
Dale Johannesend8fd3562008-10-07 18:54:28 +0000789let Defs = [AL,AH,EFLAGS], Uses = [AX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000790def IDIV8r : I<0xF6, MRM7r, (outs), (ins GR8:$src), // AX/r8 = AL,AH
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000791 "idiv{b}\t$src", []>;
Evan Cheng55687072007-09-14 21:48:26 +0000792let Defs = [AX,DX,EFLAGS], Uses = [AX,DX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000793def IDIV16r: I<0xF7, MRM7r, (outs), (ins GR16:$src), // DX:AX/r16 = AX,DX
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000794 "idiv{w}\t$src", []>, OpSize;
Evan Cheng55687072007-09-14 21:48:26 +0000795let Defs = [EAX,EDX,EFLAGS], Uses = [EAX,EDX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000796def IDIV32r: I<0xF7, MRM7r, (outs), (ins GR32:$src), // EDX:EAX/r32 = EAX,EDX
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000797 "idiv{l}\t$src", []>;
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000798let mayLoad = 1, mayLoad = 1 in {
Dale Johannesend8fd3562008-10-07 18:54:28 +0000799let Defs = [AL,AH,EFLAGS], Uses = [AX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000800def IDIV8m : I<0xF6, MRM7m, (outs), (ins i8mem:$src), // AX/[mem8] = AL,AH
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000801 "idiv{b}\t$src", []>;
Evan Cheng55687072007-09-14 21:48:26 +0000802let Defs = [AX,DX,EFLAGS], Uses = [AX,DX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000803def IDIV16m: I<0xF7, MRM7m, (outs), (ins i16mem:$src), // DX:AX/[mem16] = AX,DX
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000804 "idiv{w}\t$src", []>, OpSize;
Evan Cheng55687072007-09-14 21:48:26 +0000805let Defs = [EAX,EDX,EFLAGS], Uses = [EAX,EDX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000806def IDIV32m: I<0xF7, MRM7m, (outs), (ins i32mem:$src), // EDX:EAX/[mem32] = EAX,EDX
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000807 "idiv{l}\t$src", []>;
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000808}
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000809
810//===----------------------------------------------------------------------===//
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000811// Two address Instructions.
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000812//
813let isTwoAddress = 1 in {
814
815// Conditional moves
Evan Cheng950aac02007-09-25 01:57:46 +0000816let Uses = [EFLAGS] in {
Evan Cheng926658c2007-10-05 23:13:21 +0000817let isCommutable = 1 in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000818def CMOVB16rr : I<0x42, MRMSrcReg, // if <u, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +0000819 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000820 "cmovb\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000821 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000822 X86_COND_B, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000823 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000824def CMOVB32rr : I<0x42, MRMSrcReg, // if <u, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +0000825 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000826 "cmovb\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000827 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000828 X86_COND_B, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000829 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000830
831def CMOVAE16rr: I<0x43, MRMSrcReg, // if >=u, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +0000832 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000833 "cmovae\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000834 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000835 X86_COND_AE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000836 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000837def CMOVAE32rr: I<0x43, MRMSrcReg, // if >=u, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +0000838 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000839 "cmovae\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000840 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000841 X86_COND_AE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000842 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000843def CMOVE16rr : I<0x44, MRMSrcReg, // if ==, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +0000844 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000845 "cmove\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000846 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000847 X86_COND_E, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000848 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000849def CMOVE32rr : I<0x44, MRMSrcReg, // if ==, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +0000850 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000851 "cmove\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000852 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000853 X86_COND_E, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000854 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000855def CMOVNE16rr: I<0x45, MRMSrcReg, // if !=, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +0000856 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000857 "cmovne\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000858 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000859 X86_COND_NE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000860 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000861def CMOVNE32rr: I<0x45, MRMSrcReg, // if !=, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +0000862 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000863 "cmovne\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000864 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000865 X86_COND_NE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000866 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000867def CMOVBE16rr: I<0x46, MRMSrcReg, // if <=u, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +0000868 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000869 "cmovbe\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000870 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000871 X86_COND_BE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000872 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000873def CMOVBE32rr: I<0x46, MRMSrcReg, // if <=u, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +0000874 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000875 "cmovbe\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000876 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000877 X86_COND_BE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000878 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000879def CMOVA16rr : I<0x47, MRMSrcReg, // if >u, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +0000880 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000881 "cmova\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000882 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000883 X86_COND_A, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000884 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000885def CMOVA32rr : I<0x47, MRMSrcReg, // if >u, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +0000886 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000887 "cmova\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000888 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000889 X86_COND_A, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000890 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000891def CMOVL16rr : I<0x4C, MRMSrcReg, // if <s, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +0000892 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000893 "cmovl\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000894 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000895 X86_COND_L, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000896 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000897def CMOVL32rr : I<0x4C, MRMSrcReg, // if <s, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +0000898 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000899 "cmovl\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000900 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000901 X86_COND_L, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000902 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000903def CMOVGE16rr: I<0x4D, MRMSrcReg, // if >=s, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +0000904 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000905 "cmovge\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000906 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000907 X86_COND_GE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000908 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000909def CMOVGE32rr: I<0x4D, MRMSrcReg, // if >=s, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +0000910 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000911 "cmovge\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000912 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000913 X86_COND_GE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000914 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000915def CMOVLE16rr: I<0x4E, MRMSrcReg, // if <=s, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +0000916 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000917 "cmovle\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000918 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000919 X86_COND_LE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000920 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000921def CMOVLE32rr: I<0x4E, MRMSrcReg, // if <=s, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +0000922 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000923 "cmovle\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000924 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000925 X86_COND_LE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000926 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000927def CMOVG16rr : I<0x4F, MRMSrcReg, // if >s, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +0000928 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000929 "cmovg\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000930 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000931 X86_COND_G, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000932 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000933def CMOVG32rr : I<0x4F, MRMSrcReg, // if >s, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +0000934 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000935 "cmovg\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000936 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000937 X86_COND_G, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000938 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000939def CMOVS16rr : I<0x48, MRMSrcReg, // if signed, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +0000940 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000941 "cmovs\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000942 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000943 X86_COND_S, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000944 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000945def CMOVS32rr : I<0x48, MRMSrcReg, // if signed, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +0000946 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000947 "cmovs\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000948 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000949 X86_COND_S, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000950 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000951def CMOVNS16rr: I<0x49, MRMSrcReg, // if !signed, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +0000952 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000953 "cmovns\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000954 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000955 X86_COND_NS, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000956 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000957def CMOVNS32rr: I<0x49, MRMSrcReg, // if !signed, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +0000958 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000959 "cmovns\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000960 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000961 X86_COND_NS, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000962 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000963def CMOVP16rr : I<0x4A, MRMSrcReg, // if parity, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +0000964 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000965 "cmovp\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000966 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000967 X86_COND_P, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000968 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000969def CMOVP32rr : I<0x4A, MRMSrcReg, // if parity, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +0000970 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000971 "cmovp\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000972 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000973 X86_COND_P, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000974 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000975def CMOVNP16rr : I<0x4B, MRMSrcReg, // if !parity, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +0000976 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000977 "cmovnp\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000978 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000979 X86_COND_NP, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000980 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000981def CMOVNP32rr : I<0x4B, MRMSrcReg, // if !parity, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +0000982 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000983 "cmovnp\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000984 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000985 X86_COND_NP, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000986 TB;
Evan Cheng926658c2007-10-05 23:13:21 +0000987} // isCommutable = 1
988
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000989def CMOVNP32rm : I<0x4B, MRMSrcMem, // if !parity, GR32 = [mem32]
Evan Chengb783fa32007-07-19 01:14:50 +0000990 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000991 "cmovnp\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000992 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
Evan Cheng950aac02007-09-25 01:57:46 +0000993 X86_COND_NP, EFLAGS))]>,
994 TB;
Evan Cheng926658c2007-10-05 23:13:21 +0000995
996def CMOVB16rm : I<0x42, MRMSrcMem, // if <u, GR16 = [mem16]
997 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
998 "cmovb\t{$src2, $dst|$dst, $src2}",
999 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1000 X86_COND_B, EFLAGS))]>,
1001 TB, OpSize;
1002def CMOVB32rm : I<0x42, MRMSrcMem, // if <u, GR32 = [mem32]
1003 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1004 "cmovb\t{$src2, $dst|$dst, $src2}",
1005 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1006 X86_COND_B, EFLAGS))]>,
1007 TB;
1008def CMOVAE16rm: I<0x43, MRMSrcMem, // if >=u, GR16 = [mem16]
1009 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1010 "cmovae\t{$src2, $dst|$dst, $src2}",
1011 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1012 X86_COND_AE, EFLAGS))]>,
1013 TB, OpSize;
1014def CMOVAE32rm: I<0x43, MRMSrcMem, // if >=u, GR32 = [mem32]
1015 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1016 "cmovae\t{$src2, $dst|$dst, $src2}",
1017 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1018 X86_COND_AE, EFLAGS))]>,
1019 TB;
1020def CMOVE16rm : I<0x44, MRMSrcMem, // if ==, GR16 = [mem16]
1021 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1022 "cmove\t{$src2, $dst|$dst, $src2}",
1023 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1024 X86_COND_E, EFLAGS))]>,
1025 TB, OpSize;
1026def CMOVE32rm : I<0x44, MRMSrcMem, // if ==, GR32 = [mem32]
1027 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1028 "cmove\t{$src2, $dst|$dst, $src2}",
1029 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1030 X86_COND_E, EFLAGS))]>,
1031 TB;
1032def CMOVNE16rm: I<0x45, MRMSrcMem, // if !=, GR16 = [mem16]
1033 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1034 "cmovne\t{$src2, $dst|$dst, $src2}",
1035 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1036 X86_COND_NE, EFLAGS))]>,
1037 TB, OpSize;
1038def CMOVNE32rm: I<0x45, MRMSrcMem, // if !=, GR32 = [mem32]
1039 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1040 "cmovne\t{$src2, $dst|$dst, $src2}",
1041 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1042 X86_COND_NE, EFLAGS))]>,
1043 TB;
1044def CMOVBE16rm: I<0x46, MRMSrcMem, // if <=u, GR16 = [mem16]
1045 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1046 "cmovbe\t{$src2, $dst|$dst, $src2}",
1047 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1048 X86_COND_BE, EFLAGS))]>,
1049 TB, OpSize;
1050def CMOVBE32rm: I<0x46, MRMSrcMem, // if <=u, GR32 = [mem32]
1051 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1052 "cmovbe\t{$src2, $dst|$dst, $src2}",
1053 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1054 X86_COND_BE, EFLAGS))]>,
1055 TB;
1056def CMOVA16rm : I<0x47, MRMSrcMem, // if >u, GR16 = [mem16]
1057 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1058 "cmova\t{$src2, $dst|$dst, $src2}",
1059 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1060 X86_COND_A, EFLAGS))]>,
1061 TB, OpSize;
1062def CMOVA32rm : I<0x47, MRMSrcMem, // if >u, GR32 = [mem32]
1063 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1064 "cmova\t{$src2, $dst|$dst, $src2}",
1065 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1066 X86_COND_A, EFLAGS))]>,
1067 TB;
1068def CMOVL16rm : I<0x4C, MRMSrcMem, // if <s, GR16 = [mem16]
1069 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1070 "cmovl\t{$src2, $dst|$dst, $src2}",
1071 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1072 X86_COND_L, EFLAGS))]>,
1073 TB, OpSize;
1074def CMOVL32rm : I<0x4C, MRMSrcMem, // if <s, GR32 = [mem32]
1075 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1076 "cmovl\t{$src2, $dst|$dst, $src2}",
1077 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1078 X86_COND_L, EFLAGS))]>,
1079 TB;
1080def CMOVGE16rm: I<0x4D, MRMSrcMem, // if >=s, GR16 = [mem16]
1081 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1082 "cmovge\t{$src2, $dst|$dst, $src2}",
1083 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1084 X86_COND_GE, EFLAGS))]>,
1085 TB, OpSize;
1086def CMOVGE32rm: I<0x4D, MRMSrcMem, // if >=s, GR32 = [mem32]
1087 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1088 "cmovge\t{$src2, $dst|$dst, $src2}",
1089 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1090 X86_COND_GE, EFLAGS))]>,
1091 TB;
1092def CMOVLE16rm: I<0x4E, MRMSrcMem, // if <=s, GR16 = [mem16]
1093 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1094 "cmovle\t{$src2, $dst|$dst, $src2}",
1095 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1096 X86_COND_LE, EFLAGS))]>,
1097 TB, OpSize;
1098def CMOVLE32rm: I<0x4E, MRMSrcMem, // if <=s, GR32 = [mem32]
1099 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1100 "cmovle\t{$src2, $dst|$dst, $src2}",
1101 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1102 X86_COND_LE, EFLAGS))]>,
1103 TB;
1104def CMOVG16rm : I<0x4F, MRMSrcMem, // if >s, GR16 = [mem16]
1105 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1106 "cmovg\t{$src2, $dst|$dst, $src2}",
1107 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1108 X86_COND_G, EFLAGS))]>,
1109 TB, OpSize;
1110def CMOVG32rm : I<0x4F, MRMSrcMem, // if >s, GR32 = [mem32]
1111 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1112 "cmovg\t{$src2, $dst|$dst, $src2}",
1113 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1114 X86_COND_G, EFLAGS))]>,
1115 TB;
1116def CMOVS16rm : I<0x48, MRMSrcMem, // if signed, GR16 = [mem16]
1117 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1118 "cmovs\t{$src2, $dst|$dst, $src2}",
1119 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1120 X86_COND_S, EFLAGS))]>,
1121 TB, OpSize;
1122def CMOVS32rm : I<0x48, MRMSrcMem, // if signed, GR32 = [mem32]
1123 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1124 "cmovs\t{$src2, $dst|$dst, $src2}",
1125 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1126 X86_COND_S, EFLAGS))]>,
1127 TB;
1128def CMOVNS16rm: I<0x49, MRMSrcMem, // if !signed, GR16 = [mem16]
1129 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1130 "cmovns\t{$src2, $dst|$dst, $src2}",
1131 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1132 X86_COND_NS, EFLAGS))]>,
1133 TB, OpSize;
1134def CMOVNS32rm: I<0x49, MRMSrcMem, // if !signed, GR32 = [mem32]
1135 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1136 "cmovns\t{$src2, $dst|$dst, $src2}",
1137 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1138 X86_COND_NS, EFLAGS))]>,
1139 TB;
1140def CMOVP16rm : I<0x4A, MRMSrcMem, // if parity, GR16 = [mem16]
1141 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1142 "cmovp\t{$src2, $dst|$dst, $src2}",
1143 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1144 X86_COND_P, EFLAGS))]>,
1145 TB, OpSize;
1146def CMOVP32rm : I<0x4A, MRMSrcMem, // if parity, GR32 = [mem32]
1147 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1148 "cmovp\t{$src2, $dst|$dst, $src2}",
1149 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1150 X86_COND_P, EFLAGS))]>,
1151 TB;
1152def CMOVNP16rm : I<0x4B, MRMSrcMem, // if !parity, GR16 = [mem16]
1153 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1154 "cmovnp\t{$src2, $dst|$dst, $src2}",
1155 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1156 X86_COND_NP, EFLAGS))]>,
1157 TB, OpSize;
Evan Cheng950aac02007-09-25 01:57:46 +00001158} // Uses = [EFLAGS]
1159
1160
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001161// unary instructions
1162let CodeSize = 2 in {
Evan Cheng55687072007-09-14 21:48:26 +00001163let Defs = [EFLAGS] in {
Dan Gohman91888f02007-07-31 20:11:57 +00001164def NEG8r : I<0xF6, MRM3r, (outs GR8 :$dst), (ins GR8 :$src), "neg{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001165 [(set GR8:$dst, (ineg GR8:$src))]>;
Dan Gohman91888f02007-07-31 20:11:57 +00001166def NEG16r : I<0xF7, MRM3r, (outs GR16:$dst), (ins GR16:$src), "neg{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001167 [(set GR16:$dst, (ineg GR16:$src))]>, OpSize;
Dan Gohman91888f02007-07-31 20:11:57 +00001168def NEG32r : I<0xF7, MRM3r, (outs GR32:$dst), (ins GR32:$src), "neg{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001169 [(set GR32:$dst, (ineg GR32:$src))]>;
1170let isTwoAddress = 0 in {
Dan Gohman91888f02007-07-31 20:11:57 +00001171 def NEG8m : I<0xF6, MRM3m, (outs), (ins i8mem :$dst), "neg{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001172 [(store (ineg (loadi8 addr:$dst)), addr:$dst)]>;
Dan Gohman91888f02007-07-31 20:11:57 +00001173 def NEG16m : I<0xF7, MRM3m, (outs), (ins i16mem:$dst), "neg{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001174 [(store (ineg (loadi16 addr:$dst)), addr:$dst)]>, OpSize;
Dan Gohman91888f02007-07-31 20:11:57 +00001175 def NEG32m : I<0xF7, MRM3m, (outs), (ins i32mem:$dst), "neg{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001176 [(store (ineg (loadi32 addr:$dst)), addr:$dst)]>;
1177
1178}
Evan Cheng55687072007-09-14 21:48:26 +00001179} // Defs = [EFLAGS]
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001180
Dan Gohman91888f02007-07-31 20:11:57 +00001181def NOT8r : I<0xF6, MRM2r, (outs GR8 :$dst), (ins GR8 :$src), "not{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001182 [(set GR8:$dst, (not GR8:$src))]>;
Dan Gohman91888f02007-07-31 20:11:57 +00001183def NOT16r : I<0xF7, MRM2r, (outs GR16:$dst), (ins GR16:$src), "not{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001184 [(set GR16:$dst, (not GR16:$src))]>, OpSize;
Dan Gohman91888f02007-07-31 20:11:57 +00001185def NOT32r : I<0xF7, MRM2r, (outs GR32:$dst), (ins GR32:$src), "not{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001186 [(set GR32:$dst, (not GR32:$src))]>;
1187let isTwoAddress = 0 in {
Dan Gohman91888f02007-07-31 20:11:57 +00001188 def NOT8m : I<0xF6, MRM2m, (outs), (ins i8mem :$dst), "not{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001189 [(store (not (loadi8 addr:$dst)), addr:$dst)]>;
Dan Gohman91888f02007-07-31 20:11:57 +00001190 def NOT16m : I<0xF7, MRM2m, (outs), (ins i16mem:$dst), "not{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001191 [(store (not (loadi16 addr:$dst)), addr:$dst)]>, OpSize;
Dan Gohman91888f02007-07-31 20:11:57 +00001192 def NOT32m : I<0xF7, MRM2m, (outs), (ins i32mem:$dst), "not{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001193 [(store (not (loadi32 addr:$dst)), addr:$dst)]>;
1194}
1195} // CodeSize
1196
1197// TODO: inc/dec is slow for P4, but fast for Pentium-M.
Evan Cheng55687072007-09-14 21:48:26 +00001198let Defs = [EFLAGS] in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001199let CodeSize = 2 in
Dan Gohman91888f02007-07-31 20:11:57 +00001200def INC8r : I<0xFE, MRM0r, (outs GR8 :$dst), (ins GR8 :$src), "inc{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001201 [(set GR8:$dst, (add GR8:$src, 1))]>;
1202let isConvertibleToThreeAddress = 1, CodeSize = 1 in { // Can xform into LEA.
Dan Gohman91888f02007-07-31 20:11:57 +00001203def INC16r : I<0x40, AddRegFrm, (outs GR16:$dst), (ins GR16:$src), "inc{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001204 [(set GR16:$dst, (add GR16:$src, 1))]>,
1205 OpSize, Requires<[In32BitMode]>;
Dan Gohman91888f02007-07-31 20:11:57 +00001206def INC32r : I<0x40, AddRegFrm, (outs GR32:$dst), (ins GR32:$src), "inc{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001207 [(set GR32:$dst, (add GR32:$src, 1))]>, Requires<[In32BitMode]>;
1208}
1209let isTwoAddress = 0, CodeSize = 2 in {
Dan Gohman91888f02007-07-31 20:11:57 +00001210 def INC8m : I<0xFE, MRM0m, (outs), (ins i8mem :$dst), "inc{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001211 [(store (add (loadi8 addr:$dst), 1), addr:$dst)]>;
Dan Gohman91888f02007-07-31 20:11:57 +00001212 def INC16m : I<0xFF, MRM0m, (outs), (ins i16mem:$dst), "inc{w}\t$dst",
Evan Cheng4a7e72f2007-10-19 21:23:22 +00001213 [(store (add (loadi16 addr:$dst), 1), addr:$dst)]>,
1214 OpSize, Requires<[In32BitMode]>;
Dan Gohman91888f02007-07-31 20:11:57 +00001215 def INC32m : I<0xFF, MRM0m, (outs), (ins i32mem:$dst), "inc{l}\t$dst",
Evan Cheng4a7e72f2007-10-19 21:23:22 +00001216 [(store (add (loadi32 addr:$dst), 1), addr:$dst)]>,
1217 Requires<[In32BitMode]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001218}
1219
1220let CodeSize = 2 in
Dan Gohman91888f02007-07-31 20:11:57 +00001221def DEC8r : I<0xFE, MRM1r, (outs GR8 :$dst), (ins GR8 :$src), "dec{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001222 [(set GR8:$dst, (add GR8:$src, -1))]>;
1223let isConvertibleToThreeAddress = 1, CodeSize = 1 in { // Can xform into LEA.
Dan Gohman91888f02007-07-31 20:11:57 +00001224def DEC16r : I<0x48, AddRegFrm, (outs GR16:$dst), (ins GR16:$src), "dec{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001225 [(set GR16:$dst, (add GR16:$src, -1))]>,
1226 OpSize, Requires<[In32BitMode]>;
Dan Gohman91888f02007-07-31 20:11:57 +00001227def DEC32r : I<0x48, AddRegFrm, (outs GR32:$dst), (ins GR32:$src), "dec{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001228 [(set GR32:$dst, (add GR32:$src, -1))]>, Requires<[In32BitMode]>;
1229}
1230
1231let isTwoAddress = 0, CodeSize = 2 in {
Dan Gohman91888f02007-07-31 20:11:57 +00001232 def DEC8m : I<0xFE, MRM1m, (outs), (ins i8mem :$dst), "dec{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001233 [(store (add (loadi8 addr:$dst), -1), addr:$dst)]>;
Dan Gohman91888f02007-07-31 20:11:57 +00001234 def DEC16m : I<0xFF, MRM1m, (outs), (ins i16mem:$dst), "dec{w}\t$dst",
Evan Cheng4a7e72f2007-10-19 21:23:22 +00001235 [(store (add (loadi16 addr:$dst), -1), addr:$dst)]>,
1236 OpSize, Requires<[In32BitMode]>;
Dan Gohman91888f02007-07-31 20:11:57 +00001237 def DEC32m : I<0xFF, MRM1m, (outs), (ins i32mem:$dst), "dec{l}\t$dst",
Evan Cheng4a7e72f2007-10-19 21:23:22 +00001238 [(store (add (loadi32 addr:$dst), -1), addr:$dst)]>,
1239 Requires<[In32BitMode]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001240}
Evan Cheng55687072007-09-14 21:48:26 +00001241} // Defs = [EFLAGS]
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001242
1243// Logical operators...
Evan Cheng55687072007-09-14 21:48:26 +00001244let Defs = [EFLAGS] in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001245let isCommutable = 1 in { // X = AND Y, Z --> X = AND Z, Y
1246def AND8rr : I<0x20, MRMDestReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001247 (outs GR8 :$dst), (ins GR8 :$src1, GR8 :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001248 "and{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001249 [(set GR8:$dst, (and GR8:$src1, GR8:$src2))]>;
1250def AND16rr : I<0x21, MRMDestReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001251 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001252 "and{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001253 [(set GR16:$dst, (and GR16:$src1, GR16:$src2))]>, OpSize;
1254def AND32rr : I<0x21, MRMDestReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001255 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001256 "and{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001257 [(set GR32:$dst, (and GR32:$src1, GR32:$src2))]>;
1258}
1259
1260def AND8rm : I<0x22, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001261 (outs GR8 :$dst), (ins GR8 :$src1, i8mem :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001262 "and{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001263 [(set GR8:$dst, (and GR8:$src1, (load addr:$src2)))]>;
1264def AND16rm : I<0x23, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001265 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001266 "and{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001267 [(set GR16:$dst, (and GR16:$src1, (load addr:$src2)))]>, OpSize;
1268def AND32rm : I<0x23, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001269 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001270 "and{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001271 [(set GR32:$dst, (and GR32:$src1, (load addr:$src2)))]>;
1272
1273def AND8ri : Ii8<0x80, MRM4r,
Evan Chengb783fa32007-07-19 01:14:50 +00001274 (outs GR8 :$dst), (ins GR8 :$src1, i8imm :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001275 "and{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001276 [(set GR8:$dst, (and GR8:$src1, imm:$src2))]>;
1277def AND16ri : Ii16<0x81, MRM4r,
Evan Chengb783fa32007-07-19 01:14:50 +00001278 (outs GR16:$dst), (ins GR16:$src1, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001279 "and{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001280 [(set GR16:$dst, (and GR16:$src1, imm:$src2))]>, OpSize;
1281def AND32ri : Ii32<0x81, MRM4r,
Evan Chengb783fa32007-07-19 01:14:50 +00001282 (outs GR32:$dst), (ins GR32:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001283 "and{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001284 [(set GR32:$dst, (and GR32:$src1, imm:$src2))]>;
1285def AND16ri8 : Ii8<0x83, MRM4r,
Evan Chengb783fa32007-07-19 01:14:50 +00001286 (outs GR16:$dst), (ins GR16:$src1, i16i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001287 "and{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001288 [(set GR16:$dst, (and GR16:$src1, i16immSExt8:$src2))]>,
1289 OpSize;
1290def AND32ri8 : Ii8<0x83, MRM4r,
Evan Chengb783fa32007-07-19 01:14:50 +00001291 (outs GR32:$dst), (ins GR32:$src1, i32i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001292 "and{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001293 [(set GR32:$dst, (and GR32:$src1, i32immSExt8:$src2))]>;
1294
1295let isTwoAddress = 0 in {
1296 def AND8mr : I<0x20, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001297 (outs), (ins i8mem :$dst, GR8 :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001298 "and{b}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001299 [(store (and (load addr:$dst), GR8:$src), addr:$dst)]>;
1300 def AND16mr : I<0x21, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001301 (outs), (ins i16mem:$dst, GR16:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001302 "and{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001303 [(store (and (load addr:$dst), GR16:$src), addr:$dst)]>,
1304 OpSize;
1305 def AND32mr : I<0x21, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001306 (outs), (ins i32mem:$dst, GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001307 "and{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001308 [(store (and (load addr:$dst), GR32:$src), addr:$dst)]>;
1309 def AND8mi : Ii8<0x80, MRM4m,
Evan Chengb783fa32007-07-19 01:14:50 +00001310 (outs), (ins i8mem :$dst, i8imm :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001311 "and{b}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001312 [(store (and (loadi8 addr:$dst), imm:$src), addr:$dst)]>;
1313 def AND16mi : Ii16<0x81, MRM4m,
Evan Chengb783fa32007-07-19 01:14:50 +00001314 (outs), (ins i16mem:$dst, i16imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001315 "and{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001316 [(store (and (loadi16 addr:$dst), imm:$src), addr:$dst)]>,
1317 OpSize;
1318 def AND32mi : Ii32<0x81, MRM4m,
Evan Chengb783fa32007-07-19 01:14:50 +00001319 (outs), (ins i32mem:$dst, i32imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001320 "and{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001321 [(store (and (loadi32 addr:$dst), imm:$src), addr:$dst)]>;
1322 def AND16mi8 : Ii8<0x83, MRM4m,
Evan Chengb783fa32007-07-19 01:14:50 +00001323 (outs), (ins i16mem:$dst, i16i8imm :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001324 "and{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001325 [(store (and (load addr:$dst), i16immSExt8:$src), addr:$dst)]>,
1326 OpSize;
1327 def AND32mi8 : Ii8<0x83, MRM4m,
Evan Chengb783fa32007-07-19 01:14:50 +00001328 (outs), (ins i32mem:$dst, i32i8imm :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001329 "and{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001330 [(store (and (load addr:$dst), i32immSExt8:$src), addr:$dst)]>;
1331}
1332
1333
1334let isCommutable = 1 in { // X = OR Y, Z --> X = OR Z, Y
Evan Chengb783fa32007-07-19 01:14:50 +00001335def OR8rr : I<0x08, MRMDestReg, (outs GR8 :$dst), (ins GR8 :$src1, GR8 :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001336 "or{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001337 [(set GR8:$dst, (or GR8:$src1, GR8:$src2))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001338def OR16rr : I<0x09, MRMDestReg, (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001339 "or{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001340 [(set GR16:$dst, (or GR16:$src1, GR16:$src2))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001341def OR32rr : I<0x09, MRMDestReg, (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001342 "or{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001343 [(set GR32:$dst, (or GR32:$src1, GR32:$src2))]>;
1344}
Evan Chengb783fa32007-07-19 01:14:50 +00001345def OR8rm : I<0x0A, MRMSrcMem , (outs GR8 :$dst), (ins GR8 :$src1, i8mem :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001346 "or{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001347 [(set GR8:$dst, (or GR8:$src1, (load addr:$src2)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001348def OR16rm : I<0x0B, MRMSrcMem , (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001349 "or{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001350 [(set GR16:$dst, (or GR16:$src1, (load addr:$src2)))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001351def OR32rm : I<0x0B, MRMSrcMem , (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001352 "or{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001353 [(set GR32:$dst, (or GR32:$src1, (load addr:$src2)))]>;
1354
Evan Chengb783fa32007-07-19 01:14:50 +00001355def OR8ri : Ii8 <0x80, MRM1r, (outs GR8 :$dst), (ins GR8 :$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001356 "or{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001357 [(set GR8:$dst, (or GR8:$src1, imm:$src2))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001358def OR16ri : Ii16<0x81, MRM1r, (outs GR16:$dst), (ins GR16:$src1, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001359 "or{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001360 [(set GR16:$dst, (or GR16:$src1, imm:$src2))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001361def OR32ri : Ii32<0x81, MRM1r, (outs GR32:$dst), (ins GR32:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001362 "or{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001363 [(set GR32:$dst, (or GR32:$src1, imm:$src2))]>;
1364
Evan Chengb783fa32007-07-19 01:14:50 +00001365def OR16ri8 : Ii8<0x83, MRM1r, (outs GR16:$dst), (ins GR16:$src1, i16i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001366 "or{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001367 [(set GR16:$dst, (or GR16:$src1, i16immSExt8:$src2))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001368def OR32ri8 : Ii8<0x83, MRM1r, (outs GR32:$dst), (ins GR32:$src1, i32i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001369 "or{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001370 [(set GR32:$dst, (or GR32:$src1, i32immSExt8:$src2))]>;
1371let isTwoAddress = 0 in {
Evan Chengb783fa32007-07-19 01:14:50 +00001372 def OR8mr : I<0x08, MRMDestMem, (outs), (ins i8mem:$dst, GR8:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001373 "or{b}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001374 [(store (or (load addr:$dst), GR8:$src), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001375 def OR16mr : I<0x09, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001376 "or{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001377 [(store (or (load addr:$dst), GR16:$src), addr:$dst)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001378 def OR32mr : I<0x09, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001379 "or{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001380 [(store (or (load addr:$dst), GR32:$src), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001381 def OR8mi : Ii8<0x80, MRM1m, (outs), (ins i8mem :$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001382 "or{b}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001383 [(store (or (loadi8 addr:$dst), imm:$src), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001384 def OR16mi : Ii16<0x81, MRM1m, (outs), (ins i16mem:$dst, i16imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001385 "or{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001386 [(store (or (loadi16 addr:$dst), imm:$src), addr:$dst)]>,
1387 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001388 def OR32mi : Ii32<0x81, MRM1m, (outs), (ins i32mem:$dst, i32imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001389 "or{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001390 [(store (or (loadi32 addr:$dst), imm:$src), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001391 def OR16mi8 : Ii8<0x83, MRM1m, (outs), (ins i16mem:$dst, i16i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001392 "or{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001393 [(store (or (load addr:$dst), i16immSExt8:$src), addr:$dst)]>,
1394 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001395 def OR32mi8 : Ii8<0x83, MRM1m, (outs), (ins i32mem:$dst, i32i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001396 "or{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001397 [(store (or (load addr:$dst), i32immSExt8:$src), addr:$dst)]>;
Bill Wendlingba5d5b02008-05-29 01:02:09 +00001398} // isTwoAddress = 0
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001399
1400
Evan Cheng6f26e8b2008-06-18 08:13:07 +00001401let isCommutable = 1 in { // X = XOR Y, Z --> X = XOR Z, Y
Bill Wendlingba5d5b02008-05-29 01:02:09 +00001402 def XOR8rr : I<0x30, MRMDestReg,
1403 (outs GR8 :$dst), (ins GR8 :$src1, GR8 :$src2),
1404 "xor{b}\t{$src2, $dst|$dst, $src2}",
1405 [(set GR8:$dst, (xor GR8:$src1, GR8:$src2))]>;
1406 def XOR16rr : I<0x31, MRMDestReg,
1407 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
1408 "xor{w}\t{$src2, $dst|$dst, $src2}",
1409 [(set GR16:$dst, (xor GR16:$src1, GR16:$src2))]>, OpSize;
1410 def XOR32rr : I<0x31, MRMDestReg,
1411 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
1412 "xor{l}\t{$src2, $dst|$dst, $src2}",
1413 [(set GR32:$dst, (xor GR32:$src1, GR32:$src2))]>;
Evan Cheng6f26e8b2008-06-18 08:13:07 +00001414} // isCommutable = 1
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001415
1416def XOR8rm : I<0x32, MRMSrcMem ,
Evan Chengb783fa32007-07-19 01:14:50 +00001417 (outs GR8 :$dst), (ins GR8:$src1, i8mem :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001418 "xor{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001419 [(set GR8:$dst, (xor GR8:$src1, (load addr:$src2)))]>;
1420def XOR16rm : I<0x33, MRMSrcMem ,
Evan Chengb783fa32007-07-19 01:14:50 +00001421 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001422 "xor{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingba5d5b02008-05-29 01:02:09 +00001423 [(set GR16:$dst, (xor GR16:$src1, (load addr:$src2)))]>,
1424 OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001425def XOR32rm : I<0x33, MRMSrcMem ,
Evan Chengb783fa32007-07-19 01:14:50 +00001426 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001427 "xor{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001428 [(set GR32:$dst, (xor GR32:$src1, (load addr:$src2)))]>;
1429
Bill Wendlingbac38eb2008-05-29 03:46:36 +00001430def XOR8ri : Ii8<0x80, MRM6r,
1431 (outs GR8:$dst), (ins GR8:$src1, i8imm:$src2),
1432 "xor{b}\t{$src2, $dst|$dst, $src2}",
1433 [(set GR8:$dst, (xor GR8:$src1, imm:$src2))]>;
1434def XOR16ri : Ii16<0x81, MRM6r,
1435 (outs GR16:$dst), (ins GR16:$src1, i16imm:$src2),
1436 "xor{w}\t{$src2, $dst|$dst, $src2}",
1437 [(set GR16:$dst, (xor GR16:$src1, imm:$src2))]>, OpSize;
1438def XOR32ri : Ii32<0x81, MRM6r,
1439 (outs GR32:$dst), (ins GR32:$src1, i32imm:$src2),
1440 "xor{l}\t{$src2, $dst|$dst, $src2}",
1441 [(set GR32:$dst, (xor GR32:$src1, imm:$src2))]>;
1442def XOR16ri8 : Ii8<0x83, MRM6r,
1443 (outs GR16:$dst), (ins GR16:$src1, i16i8imm:$src2),
1444 "xor{w}\t{$src2, $dst|$dst, $src2}",
1445 [(set GR16:$dst, (xor GR16:$src1, i16immSExt8:$src2))]>,
1446 OpSize;
1447def XOR32ri8 : Ii8<0x83, MRM6r,
1448 (outs GR32:$dst), (ins GR32:$src1, i32i8imm:$src2),
1449 "xor{l}\t{$src2, $dst|$dst, $src2}",
1450 [(set GR32:$dst, (xor GR32:$src1, i32immSExt8:$src2))]>;
Bill Wendlingba5d5b02008-05-29 01:02:09 +00001451
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001452let isTwoAddress = 0 in {
1453 def XOR8mr : I<0x30, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001454 (outs), (ins i8mem :$dst, GR8 :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001455 "xor{b}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001456 [(store (xor (load addr:$dst), GR8:$src), addr:$dst)]>;
1457 def XOR16mr : I<0x31, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001458 (outs), (ins i16mem:$dst, GR16:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001459 "xor{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001460 [(store (xor (load addr:$dst), GR16:$src), addr:$dst)]>,
1461 OpSize;
1462 def XOR32mr : I<0x31, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001463 (outs), (ins i32mem:$dst, GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001464 "xor{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001465 [(store (xor (load addr:$dst), GR32:$src), addr:$dst)]>;
1466 def XOR8mi : Ii8<0x80, MRM6m,
Evan Chengb783fa32007-07-19 01:14:50 +00001467 (outs), (ins i8mem :$dst, i8imm :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001468 "xor{b}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001469 [(store (xor (loadi8 addr:$dst), imm:$src), addr:$dst)]>;
1470 def XOR16mi : Ii16<0x81, MRM6m,
Evan Chengb783fa32007-07-19 01:14:50 +00001471 (outs), (ins i16mem:$dst, i16imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001472 "xor{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001473 [(store (xor (loadi16 addr:$dst), imm:$src), addr:$dst)]>,
1474 OpSize;
1475 def XOR32mi : Ii32<0x81, MRM6m,
Evan Chengb783fa32007-07-19 01:14:50 +00001476 (outs), (ins i32mem:$dst, i32imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001477 "xor{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001478 [(store (xor (loadi32 addr:$dst), imm:$src), addr:$dst)]>;
1479 def XOR16mi8 : Ii8<0x83, MRM6m,
Evan Chengb783fa32007-07-19 01:14:50 +00001480 (outs), (ins i16mem:$dst, i16i8imm :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001481 "xor{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001482 [(store (xor (load addr:$dst), i16immSExt8:$src), addr:$dst)]>,
1483 OpSize;
1484 def XOR32mi8 : Ii8<0x83, MRM6m,
Evan Chengb783fa32007-07-19 01:14:50 +00001485 (outs), (ins i32mem:$dst, i32i8imm :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001486 "xor{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001487 [(store (xor (load addr:$dst), i32immSExt8:$src), addr:$dst)]>;
Bill Wendlingba5d5b02008-05-29 01:02:09 +00001488} // isTwoAddress = 0
Evan Cheng55687072007-09-14 21:48:26 +00001489} // Defs = [EFLAGS]
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001490
1491// Shift instructions
Evan Cheng55687072007-09-14 21:48:26 +00001492let Defs = [EFLAGS] in {
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001493let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00001494def SHL8rCL : I<0xD2, MRM4r, (outs GR8 :$dst), (ins GR8 :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001495 "shl{b}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001496 [(set GR8:$dst, (shl GR8:$src, CL))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001497def SHL16rCL : I<0xD3, MRM4r, (outs GR16:$dst), (ins GR16:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001498 "shl{w}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001499 [(set GR16:$dst, (shl GR16:$src, CL))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001500def SHL32rCL : I<0xD3, MRM4r, (outs GR32:$dst), (ins GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001501 "shl{l}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001502 [(set GR32:$dst, (shl GR32:$src, CL))]>;
Bill Wendlingba5d5b02008-05-29 01:02:09 +00001503} // Uses = [CL]
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001504
Evan Chengb783fa32007-07-19 01:14:50 +00001505def SHL8ri : Ii8<0xC0, MRM4r, (outs GR8 :$dst), (ins GR8 :$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001506 "shl{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001507 [(set GR8:$dst, (shl GR8:$src1, (i8 imm:$src2)))]>;
1508let isConvertibleToThreeAddress = 1 in { // Can transform into LEA.
Evan Chengb783fa32007-07-19 01:14:50 +00001509def SHL16ri : Ii8<0xC1, MRM4r, (outs GR16:$dst), (ins GR16:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001510 "shl{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001511 [(set GR16:$dst, (shl GR16:$src1, (i8 imm:$src2)))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001512def SHL32ri : Ii8<0xC1, MRM4r, (outs GR32:$dst), (ins GR32:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001513 "shl{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001514 [(set GR32:$dst, (shl GR32:$src1, (i8 imm:$src2)))]>;
Chris Lattnerf4005a82008-01-11 18:00:50 +00001515// NOTE: We don't use shifts of a register by one, because 'add reg,reg' is
1516// cheaper.
Bill Wendlingba5d5b02008-05-29 01:02:09 +00001517} // isConvertibleToThreeAddress = 1
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001518
1519let isTwoAddress = 0 in {
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001520 let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00001521 def SHL8mCL : I<0xD2, MRM4m, (outs), (ins i8mem :$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001522 "shl{b}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001523 [(store (shl (loadi8 addr:$dst), CL), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001524 def SHL16mCL : I<0xD3, MRM4m, (outs), (ins i16mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001525 "shl{w}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001526 [(store (shl (loadi16 addr:$dst), CL), addr:$dst)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001527 def SHL32mCL : I<0xD3, MRM4m, (outs), (ins i32mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001528 "shl{l}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001529 [(store (shl (loadi32 addr:$dst), CL), addr:$dst)]>;
1530 }
Evan Chengb783fa32007-07-19 01:14:50 +00001531 def SHL8mi : Ii8<0xC0, MRM4m, (outs), (ins i8mem :$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001532 "shl{b}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001533 [(store (shl (loadi8 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001534 def SHL16mi : Ii8<0xC1, MRM4m, (outs), (ins i16mem:$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001535 "shl{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001536 [(store (shl (loadi16 addr:$dst), (i8 imm:$src)), addr:$dst)]>,
1537 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001538 def SHL32mi : Ii8<0xC1, MRM4m, (outs), (ins i32mem:$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001539 "shl{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001540 [(store (shl (loadi32 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
1541
1542 // Shift by 1
Evan Chengb783fa32007-07-19 01:14:50 +00001543 def SHL8m1 : I<0xD0, MRM4m, (outs), (ins i8mem :$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001544 "shl{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001545 [(store (shl (loadi8 addr:$dst), (i8 1)), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001546 def SHL16m1 : I<0xD1, MRM4m, (outs), (ins i16mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001547 "shl{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001548 [(store (shl (loadi16 addr:$dst), (i8 1)), addr:$dst)]>,
1549 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001550 def SHL32m1 : I<0xD1, MRM4m, (outs), (ins i32mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001551 "shl{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001552 [(store (shl (loadi32 addr:$dst), (i8 1)), addr:$dst)]>;
1553}
1554
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001555let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00001556def SHR8rCL : I<0xD2, MRM5r, (outs GR8 :$dst), (ins GR8 :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001557 "shr{b}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001558 [(set GR8:$dst, (srl GR8:$src, CL))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001559def SHR16rCL : I<0xD3, MRM5r, (outs GR16:$dst), (ins GR16:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001560 "shr{w}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001561 [(set GR16:$dst, (srl GR16:$src, CL))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001562def SHR32rCL : I<0xD3, MRM5r, (outs GR32:$dst), (ins GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001563 "shr{l}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001564 [(set GR32:$dst, (srl GR32:$src, CL))]>;
1565}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001566
Evan Chengb783fa32007-07-19 01:14:50 +00001567def SHR8ri : Ii8<0xC0, MRM5r, (outs GR8:$dst), (ins GR8:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001568 "shr{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001569 [(set GR8:$dst, (srl GR8:$src1, (i8 imm:$src2)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001570def SHR16ri : Ii8<0xC1, MRM5r, (outs GR16:$dst), (ins GR16:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001571 "shr{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001572 [(set GR16:$dst, (srl GR16:$src1, (i8 imm:$src2)))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001573def SHR32ri : Ii8<0xC1, MRM5r, (outs GR32:$dst), (ins GR32:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001574 "shr{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001575 [(set GR32:$dst, (srl GR32:$src1, (i8 imm:$src2)))]>;
1576
1577// Shift by 1
Evan Chengb783fa32007-07-19 01:14:50 +00001578def SHR8r1 : I<0xD0, MRM5r, (outs GR8:$dst), (ins GR8:$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00001579 "shr{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001580 [(set GR8:$dst, (srl GR8:$src1, (i8 1)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001581def SHR16r1 : I<0xD1, MRM5r, (outs GR16:$dst), (ins GR16:$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00001582 "shr{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001583 [(set GR16:$dst, (srl GR16:$src1, (i8 1)))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001584def SHR32r1 : I<0xD1, MRM5r, (outs GR32:$dst), (ins GR32:$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00001585 "shr{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001586 [(set GR32:$dst, (srl GR32:$src1, (i8 1)))]>;
1587
1588let isTwoAddress = 0 in {
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001589 let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00001590 def SHR8mCL : I<0xD2, MRM5m, (outs), (ins i8mem :$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001591 "shr{b}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001592 [(store (srl (loadi8 addr:$dst), CL), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001593 def SHR16mCL : I<0xD3, MRM5m, (outs), (ins i16mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001594 "shr{w}\t{%cl, $dst|$dst, %CL}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001595 [(store (srl (loadi16 addr:$dst), CL), addr:$dst)]>,
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001596 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001597 def SHR32mCL : I<0xD3, MRM5m, (outs), (ins i32mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001598 "shr{l}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001599 [(store (srl (loadi32 addr:$dst), CL), addr:$dst)]>;
1600 }
Evan Chengb783fa32007-07-19 01:14:50 +00001601 def SHR8mi : Ii8<0xC0, MRM5m, (outs), (ins i8mem :$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001602 "shr{b}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001603 [(store (srl (loadi8 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001604 def SHR16mi : Ii8<0xC1, MRM5m, (outs), (ins i16mem:$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001605 "shr{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001606 [(store (srl (loadi16 addr:$dst), (i8 imm:$src)), addr:$dst)]>,
1607 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001608 def SHR32mi : Ii8<0xC1, MRM5m, (outs), (ins i32mem:$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001609 "shr{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001610 [(store (srl (loadi32 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
1611
1612 // Shift by 1
Evan Chengb783fa32007-07-19 01:14:50 +00001613 def SHR8m1 : I<0xD0, MRM5m, (outs), (ins i8mem :$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001614 "shr{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001615 [(store (srl (loadi8 addr:$dst), (i8 1)), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001616 def SHR16m1 : I<0xD1, MRM5m, (outs), (ins i16mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001617 "shr{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001618 [(store (srl (loadi16 addr:$dst), (i8 1)), addr:$dst)]>,OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001619 def SHR32m1 : I<0xD1, MRM5m, (outs), (ins i32mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001620 "shr{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001621 [(store (srl (loadi32 addr:$dst), (i8 1)), addr:$dst)]>;
1622}
1623
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001624let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00001625def SAR8rCL : I<0xD2, MRM7r, (outs GR8 :$dst), (ins GR8 :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001626 "sar{b}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001627 [(set GR8:$dst, (sra GR8:$src, CL))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001628def SAR16rCL : I<0xD3, MRM7r, (outs GR16:$dst), (ins GR16:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001629 "sar{w}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001630 [(set GR16:$dst, (sra GR16:$src, CL))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001631def SAR32rCL : I<0xD3, MRM7r, (outs GR32:$dst), (ins GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001632 "sar{l}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001633 [(set GR32:$dst, (sra GR32:$src, CL))]>;
1634}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001635
Evan Chengb783fa32007-07-19 01:14:50 +00001636def SAR8ri : Ii8<0xC0, MRM7r, (outs GR8 :$dst), (ins GR8 :$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001637 "sar{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001638 [(set GR8:$dst, (sra GR8:$src1, (i8 imm:$src2)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001639def SAR16ri : Ii8<0xC1, MRM7r, (outs GR16:$dst), (ins GR16:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001640 "sar{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001641 [(set GR16:$dst, (sra GR16:$src1, (i8 imm:$src2)))]>,
1642 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001643def SAR32ri : Ii8<0xC1, MRM7r, (outs GR32:$dst), (ins GR32:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001644 "sar{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001645 [(set GR32:$dst, (sra GR32:$src1, (i8 imm:$src2)))]>;
1646
1647// Shift by 1
Evan Chengb783fa32007-07-19 01:14:50 +00001648def SAR8r1 : I<0xD0, MRM7r, (outs GR8 :$dst), (ins GR8 :$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00001649 "sar{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001650 [(set GR8:$dst, (sra GR8:$src1, (i8 1)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001651def SAR16r1 : I<0xD1, MRM7r, (outs GR16:$dst), (ins GR16:$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00001652 "sar{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001653 [(set GR16:$dst, (sra GR16:$src1, (i8 1)))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001654def SAR32r1 : I<0xD1, MRM7r, (outs GR32:$dst), (ins GR32:$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00001655 "sar{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001656 [(set GR32:$dst, (sra GR32:$src1, (i8 1)))]>;
1657
1658let isTwoAddress = 0 in {
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001659 let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00001660 def SAR8mCL : I<0xD2, MRM7m, (outs), (ins i8mem :$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001661 "sar{b}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001662 [(store (sra (loadi8 addr:$dst), CL), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001663 def SAR16mCL : I<0xD3, MRM7m, (outs), (ins i16mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001664 "sar{w}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001665 [(store (sra (loadi16 addr:$dst), CL), addr:$dst)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001666 def SAR32mCL : I<0xD3, MRM7m, (outs), (ins i32mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001667 "sar{l}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001668 [(store (sra (loadi32 addr:$dst), CL), addr:$dst)]>;
1669 }
Evan Chengb783fa32007-07-19 01:14:50 +00001670 def SAR8mi : Ii8<0xC0, MRM7m, (outs), (ins i8mem :$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001671 "sar{b}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001672 [(store (sra (loadi8 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001673 def SAR16mi : Ii8<0xC1, MRM7m, (outs), (ins i16mem:$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001674 "sar{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001675 [(store (sra (loadi16 addr:$dst), (i8 imm:$src)), addr:$dst)]>,
1676 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001677 def SAR32mi : Ii8<0xC1, MRM7m, (outs), (ins i32mem:$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001678 "sar{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001679 [(store (sra (loadi32 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
1680
1681 // Shift by 1
Evan Chengb783fa32007-07-19 01:14:50 +00001682 def SAR8m1 : I<0xD0, MRM7m, (outs), (ins i8mem :$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001683 "sar{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001684 [(store (sra (loadi8 addr:$dst), (i8 1)), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001685 def SAR16m1 : I<0xD1, MRM7m, (outs), (ins i16mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001686 "sar{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001687 [(store (sra (loadi16 addr:$dst), (i8 1)), addr:$dst)]>,
1688 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001689 def SAR32m1 : I<0xD1, MRM7m, (outs), (ins i32mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001690 "sar{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001691 [(store (sra (loadi32 addr:$dst), (i8 1)), addr:$dst)]>;
1692}
1693
1694// Rotate instructions
1695// FIXME: provide shorter instructions when imm8 == 1
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001696let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00001697def ROL8rCL : I<0xD2, MRM0r, (outs GR8 :$dst), (ins GR8 :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001698 "rol{b}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001699 [(set GR8:$dst, (rotl GR8:$src, CL))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001700def ROL16rCL : I<0xD3, MRM0r, (outs GR16:$dst), (ins GR16:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001701 "rol{w}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001702 [(set GR16:$dst, (rotl GR16:$src, CL))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001703def ROL32rCL : I<0xD3, MRM0r, (outs GR32:$dst), (ins GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001704 "rol{l}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001705 [(set GR32:$dst, (rotl GR32:$src, CL))]>;
1706}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001707
Evan Chengb783fa32007-07-19 01:14:50 +00001708def ROL8ri : Ii8<0xC0, MRM0r, (outs GR8 :$dst), (ins GR8 :$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001709 "rol{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001710 [(set GR8:$dst, (rotl GR8:$src1, (i8 imm:$src2)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001711def ROL16ri : Ii8<0xC1, MRM0r, (outs GR16:$dst), (ins GR16:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001712 "rol{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001713 [(set GR16:$dst, (rotl GR16:$src1, (i8 imm:$src2)))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001714def ROL32ri : Ii8<0xC1, MRM0r, (outs GR32:$dst), (ins GR32:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001715 "rol{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001716 [(set GR32:$dst, (rotl GR32:$src1, (i8 imm:$src2)))]>;
1717
1718// Rotate by 1
Evan Chengb783fa32007-07-19 01:14:50 +00001719def ROL8r1 : I<0xD0, MRM0r, (outs GR8 :$dst), (ins GR8 :$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00001720 "rol{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001721 [(set GR8:$dst, (rotl GR8:$src1, (i8 1)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001722def ROL16r1 : I<0xD1, MRM0r, (outs GR16:$dst), (ins GR16:$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00001723 "rol{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001724 [(set GR16:$dst, (rotl GR16:$src1, (i8 1)))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001725def ROL32r1 : I<0xD1, MRM0r, (outs GR32:$dst), (ins GR32:$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00001726 "rol{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001727 [(set GR32:$dst, (rotl GR32:$src1, (i8 1)))]>;
1728
1729let isTwoAddress = 0 in {
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001730 let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00001731 def ROL8mCL : I<0xD2, MRM0m, (outs), (ins i8mem :$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001732 "rol{b}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001733 [(store (rotl (loadi8 addr:$dst), CL), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001734 def ROL16mCL : I<0xD3, MRM0m, (outs), (ins i16mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001735 "rol{w}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001736 [(store (rotl (loadi16 addr:$dst), CL), addr:$dst)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001737 def ROL32mCL : I<0xD3, MRM0m, (outs), (ins i32mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001738 "rol{l}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001739 [(store (rotl (loadi32 addr:$dst), CL), addr:$dst)]>;
1740 }
Evan Chengb783fa32007-07-19 01:14:50 +00001741 def ROL8mi : Ii8<0xC0, MRM0m, (outs), (ins i8mem :$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001742 "rol{b}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001743 [(store (rotl (loadi8 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001744 def ROL16mi : Ii8<0xC1, MRM0m, (outs), (ins i16mem:$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001745 "rol{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001746 [(store (rotl (loadi16 addr:$dst), (i8 imm:$src)), addr:$dst)]>,
1747 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001748 def ROL32mi : Ii8<0xC1, MRM0m, (outs), (ins i32mem:$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001749 "rol{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001750 [(store (rotl (loadi32 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
1751
1752 // Rotate by 1
Evan Chengb783fa32007-07-19 01:14:50 +00001753 def ROL8m1 : I<0xD0, MRM0m, (outs), (ins i8mem :$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001754 "rol{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001755 [(store (rotl (loadi8 addr:$dst), (i8 1)), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001756 def ROL16m1 : I<0xD1, MRM0m, (outs), (ins i16mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001757 "rol{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001758 [(store (rotl (loadi16 addr:$dst), (i8 1)), addr:$dst)]>,
1759 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001760 def ROL32m1 : I<0xD1, MRM0m, (outs), (ins i32mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001761 "rol{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001762 [(store (rotl (loadi32 addr:$dst), (i8 1)), addr:$dst)]>;
1763}
1764
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001765let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00001766def ROR8rCL : I<0xD2, MRM1r, (outs GR8 :$dst), (ins GR8 :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001767 "ror{b}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001768 [(set GR8:$dst, (rotr GR8:$src, CL))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001769def ROR16rCL : I<0xD3, MRM1r, (outs GR16:$dst), (ins GR16:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001770 "ror{w}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001771 [(set GR16:$dst, (rotr GR16:$src, CL))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001772def ROR32rCL : I<0xD3, MRM1r, (outs GR32:$dst), (ins GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001773 "ror{l}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001774 [(set GR32:$dst, (rotr GR32:$src, CL))]>;
1775}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001776
Evan Chengb783fa32007-07-19 01:14:50 +00001777def ROR8ri : Ii8<0xC0, MRM1r, (outs GR8 :$dst), (ins GR8 :$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001778 "ror{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001779 [(set GR8:$dst, (rotr GR8:$src1, (i8 imm:$src2)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001780def ROR16ri : Ii8<0xC1, MRM1r, (outs GR16:$dst), (ins GR16:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001781 "ror{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001782 [(set GR16:$dst, (rotr GR16:$src1, (i8 imm:$src2)))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001783def ROR32ri : Ii8<0xC1, MRM1r, (outs GR32:$dst), (ins GR32:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001784 "ror{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001785 [(set GR32:$dst, (rotr GR32:$src1, (i8 imm:$src2)))]>;
1786
1787// Rotate by 1
Evan Chengb783fa32007-07-19 01:14:50 +00001788def ROR8r1 : I<0xD0, MRM1r, (outs GR8 :$dst), (ins GR8 :$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00001789 "ror{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001790 [(set GR8:$dst, (rotr GR8:$src1, (i8 1)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001791def ROR16r1 : I<0xD1, MRM1r, (outs GR16:$dst), (ins GR16:$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00001792 "ror{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001793 [(set GR16:$dst, (rotr GR16:$src1, (i8 1)))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001794def ROR32r1 : I<0xD1, MRM1r, (outs GR32:$dst), (ins GR32:$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00001795 "ror{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001796 [(set GR32:$dst, (rotr GR32:$src1, (i8 1)))]>;
1797
1798let isTwoAddress = 0 in {
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001799 let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00001800 def ROR8mCL : I<0xD2, MRM1m, (outs), (ins i8mem :$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001801 "ror{b}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001802 [(store (rotr (loadi8 addr:$dst), CL), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001803 def ROR16mCL : I<0xD3, MRM1m, (outs), (ins i16mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001804 "ror{w}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001805 [(store (rotr (loadi16 addr:$dst), CL), addr:$dst)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001806 def ROR32mCL : I<0xD3, MRM1m, (outs), (ins i32mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001807 "ror{l}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001808 [(store (rotr (loadi32 addr:$dst), CL), addr:$dst)]>;
1809 }
Evan Chengb783fa32007-07-19 01:14:50 +00001810 def ROR8mi : Ii8<0xC0, MRM1m, (outs), (ins i8mem :$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001811 "ror{b}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001812 [(store (rotr (loadi8 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001813 def ROR16mi : Ii8<0xC1, MRM1m, (outs), (ins i16mem:$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001814 "ror{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001815 [(store (rotr (loadi16 addr:$dst), (i8 imm:$src)), addr:$dst)]>,
1816 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001817 def ROR32mi : Ii8<0xC1, MRM1m, (outs), (ins i32mem:$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001818 "ror{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001819 [(store (rotr (loadi32 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
1820
1821 // Rotate by 1
Evan Chengb783fa32007-07-19 01:14:50 +00001822 def ROR8m1 : I<0xD0, MRM1m, (outs), (ins i8mem :$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001823 "ror{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001824 [(store (rotr (loadi8 addr:$dst), (i8 1)), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001825 def ROR16m1 : I<0xD1, MRM1m, (outs), (ins i16mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001826 "ror{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001827 [(store (rotr (loadi16 addr:$dst), (i8 1)), addr:$dst)]>,
1828 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001829 def ROR32m1 : I<0xD1, MRM1m, (outs), (ins i32mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001830 "ror{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001831 [(store (rotr (loadi32 addr:$dst), (i8 1)), addr:$dst)]>;
1832}
1833
1834
1835
1836// Double shift instructions (generalizations of rotate)
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001837let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00001838def SHLD32rrCL : I<0xA5, MRMDestReg, (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001839 "shld{l}\t{%cl, $src2, $dst|$dst, $src2, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001840 [(set GR32:$dst, (X86shld GR32:$src1, GR32:$src2, CL))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00001841def SHRD32rrCL : I<0xAD, MRMDestReg, (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001842 "shrd{l}\t{%cl, $src2, $dst|$dst, $src2, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001843 [(set GR32:$dst, (X86shrd GR32:$src1, GR32:$src2, CL))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00001844def SHLD16rrCL : I<0xA5, MRMDestReg, (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001845 "shld{w}\t{%cl, $src2, $dst|$dst, $src2, %CL}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001846 [(set GR16:$dst, (X86shld GR16:$src1, GR16:$src2, CL))]>,
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001847 TB, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001848def SHRD16rrCL : I<0xAD, MRMDestReg, (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001849 "shrd{w}\t{%cl, $src2, $dst|$dst, $src2, %CL}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001850 [(set GR16:$dst, (X86shrd GR16:$src1, GR16:$src2, CL))]>,
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001851 TB, OpSize;
1852}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001853
1854let isCommutable = 1 in { // These instructions commute to each other.
1855def SHLD32rri8 : Ii8<0xA4, MRMDestReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001856 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2, i8imm:$src3),
Dan Gohman91888f02007-07-31 20:11:57 +00001857 "shld{l}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001858 [(set GR32:$dst, (X86shld GR32:$src1, GR32:$src2,
1859 (i8 imm:$src3)))]>,
1860 TB;
1861def SHRD32rri8 : Ii8<0xAC, MRMDestReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001862 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2, i8imm:$src3),
Dan Gohman91888f02007-07-31 20:11:57 +00001863 "shrd{l}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001864 [(set GR32:$dst, (X86shrd GR32:$src1, GR32:$src2,
1865 (i8 imm:$src3)))]>,
1866 TB;
1867def SHLD16rri8 : Ii8<0xA4, MRMDestReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001868 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2, i8imm:$src3),
Dan Gohman91888f02007-07-31 20:11:57 +00001869 "shld{w}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001870 [(set GR16:$dst, (X86shld GR16:$src1, GR16:$src2,
1871 (i8 imm:$src3)))]>,
1872 TB, OpSize;
1873def SHRD16rri8 : Ii8<0xAC, MRMDestReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001874 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2, i8imm:$src3),
Dan Gohman91888f02007-07-31 20:11:57 +00001875 "shrd{w}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001876 [(set GR16:$dst, (X86shrd GR16:$src1, GR16:$src2,
1877 (i8 imm:$src3)))]>,
1878 TB, OpSize;
1879}
1880
1881let isTwoAddress = 0 in {
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001882 let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00001883 def SHLD32mrCL : I<0xA5, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001884 "shld{l}\t{%cl, $src2, $dst|$dst, $src2, %CL}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001885 [(store (X86shld (loadi32 addr:$dst), GR32:$src2, CL),
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001886 addr:$dst)]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00001887 def SHRD32mrCL : I<0xAD, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001888 "shrd{l}\t{%cl, $src2, $dst|$dst, $src2, %CL}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001889 [(store (X86shrd (loadi32 addr:$dst), GR32:$src2, CL),
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001890 addr:$dst)]>, TB;
1891 }
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001892 def SHLD32mri8 : Ii8<0xA4, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001893 (outs), (ins i32mem:$dst, GR32:$src2, i8imm:$src3),
Dan Gohman91888f02007-07-31 20:11:57 +00001894 "shld{l}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001895 [(store (X86shld (loadi32 addr:$dst), GR32:$src2,
1896 (i8 imm:$src3)), addr:$dst)]>,
1897 TB;
1898 def SHRD32mri8 : Ii8<0xAC, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001899 (outs), (ins i32mem:$dst, GR32:$src2, i8imm:$src3),
Dan Gohman91888f02007-07-31 20:11:57 +00001900 "shrd{l}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001901 [(store (X86shrd (loadi32 addr:$dst), GR32:$src2,
1902 (i8 imm:$src3)), addr:$dst)]>,
1903 TB;
1904
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001905 let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00001906 def SHLD16mrCL : I<0xA5, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001907 "shld{w}\t{%cl, $src2, $dst|$dst, $src2, %CL}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001908 [(store (X86shld (loadi16 addr:$dst), GR16:$src2, CL),
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001909 addr:$dst)]>, TB, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001910 def SHRD16mrCL : I<0xAD, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001911 "shrd{w}\t{%cl, $src2, $dst|$dst, $src2, %CL}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001912 [(store (X86shrd (loadi16 addr:$dst), GR16:$src2, CL),
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001913 addr:$dst)]>, TB, OpSize;
1914 }
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001915 def SHLD16mri8 : Ii8<0xA4, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001916 (outs), (ins i16mem:$dst, GR16:$src2, i8imm:$src3),
Dan Gohman91888f02007-07-31 20:11:57 +00001917 "shld{w}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001918 [(store (X86shld (loadi16 addr:$dst), GR16:$src2,
1919 (i8 imm:$src3)), addr:$dst)]>,
1920 TB, OpSize;
1921 def SHRD16mri8 : Ii8<0xAC, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001922 (outs), (ins i16mem:$dst, GR16:$src2, i8imm:$src3),
Dan Gohman91888f02007-07-31 20:11:57 +00001923 "shrd{w}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001924 [(store (X86shrd (loadi16 addr:$dst), GR16:$src2,
1925 (i8 imm:$src3)), addr:$dst)]>,
1926 TB, OpSize;
1927}
Evan Cheng55687072007-09-14 21:48:26 +00001928} // Defs = [EFLAGS]
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001929
1930
1931// Arithmetic.
Evan Cheng55687072007-09-14 21:48:26 +00001932let Defs = [EFLAGS] in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001933let isCommutable = 1 in { // X = ADD Y, Z --> X = ADD Z, Y
Bill Wendlingae034ed2008-12-12 00:56:36 +00001934// Register-Register Addition
1935def ADD8rr : I<0x00, MRMDestReg, (outs GR8 :$dst),
1936 (ins GR8 :$src1, GR8 :$src2),
1937 "add{b}\t{$src2, $dst|$dst, $src2}",
1938 [(set GR8:$dst, (add GR8:$src1, GR8:$src2))]>;
1939
1940// Register-Register Addition with Overflow
1941def ADDOvf8rr : I<0x00, MRMDestReg, (outs GR8 :$dst),
1942 (ins GR8 :$src1, GR8 :$src2),
1943 "add{b}\t{$src2, $dst|$dst, $src2}",
1944 [(set GR8:$dst, (X86add_ovf GR8:$src1, GR8:$src2)),
1945 (implicit EFLAGS)]>;
1946
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001947let isConvertibleToThreeAddress = 1 in { // Can transform into LEA.
Bill Wendlingae034ed2008-12-12 00:56:36 +00001948// Register-Register Addition
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001949def ADD16rr : I<0x01, MRMDestReg, (outs GR16:$dst),
1950 (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001951 "add{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingae034ed2008-12-12 00:56:36 +00001952 [(set GR16:$dst, (add GR16:$src1, GR16:$src2))]>, OpSize;
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001953def ADD32rr : I<0x01, MRMDestReg, (outs GR32:$dst),
1954 (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001955 "add{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingae034ed2008-12-12 00:56:36 +00001956 [(set GR32:$dst, (add GR32:$src1, GR32:$src2))]>;
1957
1958// Register-Register Addition with Overflow
1959def ADDOvf16rr : I<0x01, MRMDestReg, (outs GR16:$dst),
1960 (ins GR16:$src1, GR16:$src2),
1961 "add{w}\t{$src2, $dst|$dst, $src2}",
1962 [(set GR16:$dst, (X86add_ovf GR16:$src1, GR16:$src2)),
1963 (implicit EFLAGS)]>, OpSize;
1964def ADDOvf32rr : I<0x01, MRMDestReg, (outs GR32:$dst),
1965 (ins GR32:$src1, GR32:$src2),
1966 "add{l}\t{$src2, $dst|$dst, $src2}",
1967 [(set GR32:$dst, (X86add_ovf GR32:$src1, GR32:$src2)),
1968 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001969} // end isConvertibleToThreeAddress
1970} // end isCommutable
Bill Wendlingae034ed2008-12-12 00:56:36 +00001971
1972// Register-Memory Addition
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001973def ADD8rm : I<0x02, MRMSrcMem, (outs GR8 :$dst),
1974 (ins GR8 :$src1, i8mem :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001975 "add{b}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingae034ed2008-12-12 00:56:36 +00001976 [(set GR8:$dst, (add GR8:$src1, (load addr:$src2)))]>;
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001977def ADD16rm : I<0x03, MRMSrcMem, (outs GR16:$dst),
1978 (ins GR16:$src1, i16mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001979 "add{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingae034ed2008-12-12 00:56:36 +00001980 [(set GR16:$dst, (add GR16:$src1, (load addr:$src2)))]>,OpSize;
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001981def ADD32rm : I<0x03, MRMSrcMem, (outs GR32:$dst),
1982 (ins GR32:$src1, i32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001983 "add{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingae034ed2008-12-12 00:56:36 +00001984 [(set GR32:$dst, (add GR32:$src1, (load addr:$src2)))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001985
Bill Wendlingae034ed2008-12-12 00:56:36 +00001986// Register-Memory Addition with Overflow
1987def ADDOvf8rm : I<0x02, MRMSrcMem, (outs GR8 :$dst),
1988 (ins GR8 :$src1, i8mem :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001989 "add{b}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingae034ed2008-12-12 00:56:36 +00001990 [(set GR8:$dst, (X86add_ovf GR8:$src1, (load addr:$src2))),
1991 (implicit EFLAGS)]>;
1992def ADDOvf16rm : I<0x03, MRMSrcMem, (outs GR16:$dst),
1993 (ins GR16:$src1, i16mem:$src2),
1994 "add{w}\t{$src2, $dst|$dst, $src2}",
1995 [(set GR16:$dst, (X86add_ovf GR16:$src1, (load addr:$src2))),
1996 (implicit EFLAGS)]>, OpSize;
1997def ADDOvf32rm : I<0x03, MRMSrcMem, (outs GR32:$dst),
1998 (ins GR32:$src1, i32mem:$src2),
1999 "add{l}\t{$src2, $dst|$dst, $src2}",
2000 [(set GR32:$dst, (X86add_ovf GR32:$src1, (load addr:$src2))),
Bill Wendling0c52d0a2008-12-02 00:07:05 +00002001 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002002
Bill Wendlingae034ed2008-12-12 00:56:36 +00002003// Register-Integer Addition
2004def ADD8ri : Ii8<0x80, MRM0r, (outs GR8:$dst), (ins GR8:$src1, i8imm:$src2),
2005 "add{b}\t{$src2, $dst|$dst, $src2}",
2006 [(set GR8:$dst, (add GR8:$src1, imm:$src2))]>;
2007
2008// Register-Integer Addition with Overflow
2009def ADDOvf8ri : Ii8<0x80, MRM0r, (outs GR8:$dst), (ins GR8:$src1, i8imm:$src2),
2010 "add{b}\t{$src2, $dst|$dst, $src2}",
2011 [(set GR8:$dst, (X86add_ovf GR8:$src1, imm:$src2)),
2012 (implicit EFLAGS)]>;
2013
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002014let isConvertibleToThreeAddress = 1 in { // Can transform into LEA.
Bill Wendlingae034ed2008-12-12 00:56:36 +00002015// Register-Integer Addition
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002016def ADD16ri : Ii16<0x81, MRM0r, (outs GR16:$dst),
2017 (ins GR16:$src1, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002018 "add{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingae034ed2008-12-12 00:56:36 +00002019 [(set GR16:$dst, (add GR16:$src1, imm:$src2))]>, OpSize;
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002020def ADD32ri : Ii32<0x81, MRM0r, (outs GR32:$dst),
2021 (ins GR32:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002022 "add{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingae034ed2008-12-12 00:56:36 +00002023 [(set GR32:$dst, (add GR32:$src1, imm:$src2))]>;
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002024def ADD16ri8 : Ii8<0x83, MRM0r, (outs GR16:$dst),
2025 (ins GR16:$src1, i16i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002026 "add{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingae034ed2008-12-12 00:56:36 +00002027 [(set GR16:$dst, (add GR16:$src1, i16immSExt8:$src2))]>, OpSize;
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002028def ADD32ri8 : Ii8<0x83, MRM0r, (outs GR32:$dst),
2029 (ins GR32:$src1, i32i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002030 "add{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingae034ed2008-12-12 00:56:36 +00002031 [(set GR32:$dst, (add GR32:$src1, i32immSExt8:$src2))]>;
2032
2033// Register-Integer Addition with Overflow
2034def ADDOvf16ri : Ii16<0x81, MRM0r, (outs GR16:$dst),
2035 (ins GR16:$src1, i16imm:$src2),
2036 "add{w}\t{$src2, $dst|$dst, $src2}",
2037 [(set GR16:$dst, (X86add_ovf GR16:$src1, imm:$src2)),
2038 (implicit EFLAGS)]>, OpSize;
2039def ADDOvf32ri : Ii32<0x81, MRM0r, (outs GR32:$dst),
2040 (ins GR32:$src1, i32imm:$src2),
2041 "add{l}\t{$src2, $dst|$dst, $src2}",
2042 [(set GR32:$dst, (X86add_ovf GR32:$src1, imm:$src2)),
2043 (implicit EFLAGS)]>;
2044def ADDOvf16ri8 : Ii8<0x83, MRM0r, (outs GR16:$dst),
2045 (ins GR16:$src1, i16i8imm:$src2),
2046 "add{w}\t{$src2, $dst|$dst, $src2}",
2047 [(set GR16:$dst, (X86add_ovf GR16:$src1,
2048 i16immSExt8:$src2)),
2049 (implicit EFLAGS)]>, OpSize;
2050def ADDOvf32ri8 : Ii8<0x83, MRM0r, (outs GR32:$dst),
2051 (ins GR32:$src1, i32i8imm:$src2),
2052 "add{l}\t{$src2, $dst|$dst, $src2}",
2053 [(set GR32:$dst, (X86add_ovf GR32:$src1,
2054 i32immSExt8:$src2)),
2055 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002056}
2057
2058let isTwoAddress = 0 in {
Bill Wendlingae034ed2008-12-12 00:56:36 +00002059 // Memory-Register Addition
Evan Chengb783fa32007-07-19 01:14:50 +00002060 def ADD8mr : I<0x00, MRMDestMem, (outs), (ins i8mem :$dst, GR8 :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002061 "add{b}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingae034ed2008-12-12 00:56:36 +00002062 [(store (add (load addr:$dst), GR8:$src2), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002063 def ADD16mr : I<0x01, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002064 "add{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingae034ed2008-12-12 00:56:36 +00002065 [(store (add (load addr:$dst), GR16:$src2), addr:$dst)]>,
2066 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002067 def ADD32mr : I<0x01, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002068 "add{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingae034ed2008-12-12 00:56:36 +00002069 [(store (add (load addr:$dst), GR32:$src2), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002070 def ADD8mi : Ii8<0x80, MRM0m, (outs), (ins i8mem :$dst, i8imm :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002071 "add{b}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingae034ed2008-12-12 00:56:36 +00002072 [(store (add (loadi8 addr:$dst), imm:$src2), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002073 def ADD16mi : Ii16<0x81, MRM0m, (outs), (ins i16mem:$dst, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002074 "add{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingae034ed2008-12-12 00:56:36 +00002075 [(store (add (loadi16 addr:$dst), imm:$src2), addr:$dst)]>,
2076 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002077 def ADD32mi : Ii32<0x81, MRM0m, (outs), (ins i32mem:$dst, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002078 "add{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingae034ed2008-12-12 00:56:36 +00002079 [(store (add (loadi32 addr:$dst), imm:$src2), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002080 def ADD16mi8 : Ii8<0x83, MRM0m, (outs), (ins i16mem:$dst, i16i8imm :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002081 "add{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingae034ed2008-12-12 00:56:36 +00002082 [(store (add (load addr:$dst), i16immSExt8:$src2),
2083 addr:$dst)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002084 def ADD32mi8 : Ii8<0x83, MRM0m, (outs), (ins i32mem:$dst, i32i8imm :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002085 "add{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingae034ed2008-12-12 00:56:36 +00002086 [(store (add (load addr:$dst), i32immSExt8:$src2),
2087 addr:$dst)]>;
2088
2089 // Memory-Register Addition with Overflow
2090 def ADDOvf8mr : I<0x00, MRMDestMem, (outs), (ins i8mem :$dst, GR8 :$src2),
2091 "add{b}\t{$src2, $dst|$dst, $src2}",
2092 [(store (X86add_ovf (load addr:$dst), GR8:$src2),
2093 addr:$dst),
2094 (implicit EFLAGS)]>;
2095 def ADDOvf16mr : I<0x01, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
2096 "add{w}\t{$src2, $dst|$dst, $src2}",
2097 [(store (X86add_ovf (load addr:$dst), GR16:$src2),
2098 addr:$dst),
2099 (implicit EFLAGS)]>, OpSize;
2100 def ADDOvf32mr : I<0x01, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
2101 "add{l}\t{$src2, $dst|$dst, $src2}",
2102 [(store (X86add_ovf (load addr:$dst), GR32:$src2),
2103 addr:$dst),
2104 (implicit EFLAGS)]>;
2105 def ADDOvf8mi : Ii8<0x80, MRM0m, (outs), (ins i8mem :$dst, i8imm :$src2),
2106 "add{b}\t{$src2, $dst|$dst, $src2}",
2107 [(store (X86add_ovf (loadi8 addr:$dst), imm:$src2),
2108 addr:$dst),
2109 (implicit EFLAGS)]>;
2110 def ADDOvf16mi : Ii16<0x81, MRM0m, (outs), (ins i16mem:$dst, i16imm:$src2),
2111 "add{w}\t{$src2, $dst|$dst, $src2}",
2112 [(store (X86add_ovf (loadi16 addr:$dst), imm:$src2),
2113 addr:$dst),
2114 (implicit EFLAGS)]>, OpSize;
2115 def ADDOvf32mi : Ii32<0x81, MRM0m, (outs), (ins i32mem:$dst, i32imm:$src2),
2116 "add{l}\t{$src2, $dst|$dst, $src2}",
2117 [(store (X86add_ovf (loadi32 addr:$dst), imm:$src2),
2118 addr:$dst),
2119 (implicit EFLAGS)]>;
2120 def ADDOvf16mi8 : Ii8<0x83, MRM0m, (outs), (ins i16mem:$dst, i16i8imm :$src2),
2121 "add{w}\t{$src2, $dst|$dst, $src2}",
2122 [(store (X86add_ovf (load addr:$dst),i16immSExt8:$src2),
2123 addr:$dst),
2124 (implicit EFLAGS)]>, OpSize;
2125 def ADDOvf32mi8 : Ii8<0x83, MRM0m, (outs), (ins i32mem:$dst, i32i8imm :$src2),
2126 "add{l}\t{$src2, $dst|$dst, $src2}",
2127 [(store (X86add_ovf (load addr:$dst),i32immSExt8:$src2),
2128 addr:$dst),
2129 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002130}
2131
Evan Cheng259471d2007-10-05 17:59:57 +00002132let Uses = [EFLAGS] in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002133let isCommutable = 1 in { // X = ADC Y, Z --> X = ADC Z, Y
Evan Chengb783fa32007-07-19 01:14:50 +00002134def ADC32rr : I<0x11, MRMDestReg, (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002135 "adc{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingc0ca7f32008-12-01 23:44:08 +00002136 [(set GR32:$dst, (adde GR32:$src1, GR32:$src2))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002137}
Evan Chengb783fa32007-07-19 01:14:50 +00002138def ADC32rm : I<0x13, MRMSrcMem , (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002139 "adc{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingc0ca7f32008-12-01 23:44:08 +00002140 [(set GR32:$dst, (adde GR32:$src1, (load addr:$src2)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002141def ADC32ri : Ii32<0x81, MRM2r, (outs GR32:$dst), (ins GR32:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002142 "adc{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingc0ca7f32008-12-01 23:44:08 +00002143 [(set GR32:$dst, (adde GR32:$src1, imm:$src2))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002144def ADC32ri8 : Ii8<0x83, MRM2r, (outs GR32:$dst), (ins GR32:$src1, i32i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002145 "adc{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingc0ca7f32008-12-01 23:44:08 +00002146 [(set GR32:$dst, (adde GR32:$src1, i32immSExt8:$src2))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002147
2148let isTwoAddress = 0 in {
Evan Chengb783fa32007-07-19 01:14:50 +00002149 def ADC32mr : I<0x11, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002150 "adc{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingc0ca7f32008-12-01 23:44:08 +00002151 [(store (adde (load addr:$dst), GR32:$src2), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002152 def ADC32mi : Ii32<0x81, MRM2m, (outs), (ins i32mem:$dst, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002153 "adc{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingc0ca7f32008-12-01 23:44:08 +00002154 [(store (adde (loadi32 addr:$dst), imm:$src2), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002155 def ADC32mi8 : Ii8<0x83, MRM2m, (outs), (ins i32mem:$dst, i32i8imm :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002156 "adc{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendling0c52d0a2008-12-02 00:07:05 +00002157 [(store (adde (load addr:$dst), i32immSExt8:$src2), addr:$dst)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002158}
Evan Cheng259471d2007-10-05 17:59:57 +00002159} // Uses = [EFLAGS]
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002160
Bill Wendlingae034ed2008-12-12 00:56:36 +00002161// Register-Register Subtraction
2162def SUB8rr : I<0x28, MRMDestReg, (outs GR8:$dst), (ins GR8:$src1, GR8:$src2),
2163 "sub{b}\t{$src2, $dst|$dst, $src2}",
2164 [(set GR8:$dst, (sub GR8:$src1, GR8:$src2))]>;
2165def SUB16rr : I<0x29, MRMDestReg, (outs GR16:$dst), (ins GR16:$src1,GR16:$src2),
2166 "sub{w}\t{$src2, $dst|$dst, $src2}",
2167 [(set GR16:$dst, (sub GR16:$src1, GR16:$src2))]>, OpSize;
2168def SUB32rr : I<0x29, MRMDestReg, (outs GR32:$dst), (ins GR32:$src1,GR32:$src2),
2169 "sub{l}\t{$src2, $dst|$dst, $src2}",
2170 [(set GR32:$dst, (sub GR32:$src1, GR32:$src2))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002171
Bill Wendlingae034ed2008-12-12 00:56:36 +00002172// Register-Register Subtraction with Overflow
2173def SUBOvf8rr : I<0x28, MRMDestReg, (outs GR8:$dst),
2174 (ins GR8:$src1, GR8:$src2),
2175 "sub{b}\t{$src2, $dst|$dst, $src2}",
2176 [(set GR8:$dst, (X86sub_ovf GR8:$src1, GR8:$src2)),
Bill Wendling7e04be62008-12-09 22:08:41 +00002177 (implicit EFLAGS)]>;
Bill Wendlingae034ed2008-12-12 00:56:36 +00002178def SUBOvf16rr : I<0x29, MRMDestReg, (outs GR16:$dst),
2179 (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002180 "sub{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingae034ed2008-12-12 00:56:36 +00002181 [(set GR16:$dst, (X86sub_ovf GR16:$src1, GR16:$src2)),
2182 (implicit EFLAGS)]>, OpSize;
2183def SUBOvf32rr : I<0x29, MRMDestReg, (outs GR32:$dst),
2184 (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002185 "sub{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingae034ed2008-12-12 00:56:36 +00002186 [(set GR32:$dst, (X86sub_ovf GR32:$src1, GR32:$src2)),
2187 (implicit EFLAGS)]>;
2188
2189// Register-Memory Subtraction
2190def SUB8rm : I<0x2A, MRMSrcMem, (outs GR8 :$dst),
2191 (ins GR8 :$src1, i8mem :$src2),
2192 "sub{b}\t{$src2, $dst|$dst, $src2}",
2193 [(set GR8:$dst, (sub GR8:$src1, (load addr:$src2)))]>;
2194def SUB16rm : I<0x2B, MRMSrcMem, (outs GR16:$dst),
2195 (ins GR16:$src1, i16mem:$src2),
2196 "sub{w}\t{$src2, $dst|$dst, $src2}",
2197 [(set GR16:$dst, (sub GR16:$src1, (load addr:$src2)))]>, OpSize;
2198def SUB32rm : I<0x2B, MRMSrcMem, (outs GR32:$dst),
2199 (ins GR32:$src1, i32mem:$src2),
2200 "sub{l}\t{$src2, $dst|$dst, $src2}",
2201 [(set GR32:$dst, (sub GR32:$src1, (load addr:$src2)))]>;
2202
2203// Register-Memory Subtraction with Overflow
2204def SUBOvf8rm : I<0x2A, MRMSrcMem, (outs GR8:$dst),
2205 (ins GR8:$src1, i8mem:$src2),
2206 "sub{b}\t{$src2, $dst|$dst, $src2}",
2207 [(set GR8:$dst, (X86sub_ovf GR8:$src1, (load addr:$src2))),
2208 (implicit EFLAGS)]>;
2209def SUBOvf16rm : I<0x2B, MRMSrcMem, (outs GR16:$dst),
2210 (ins GR16:$src1, i16mem:$src2),
2211 "sub{w}\t{$src2, $dst|$dst, $src2}",
2212 [(set GR16:$dst, (X86sub_ovf GR16:$src1, (load addr:$src2))),
2213 (implicit EFLAGS)]>, OpSize;
2214def SUBOvf32rm : I<0x2B, MRMSrcMem, (outs GR32:$dst),
2215 (ins GR32:$src1, i32mem:$src2),
2216 "sub{l}\t{$src2, $dst|$dst, $src2}",
2217 [(set GR32:$dst, (X86sub_ovf GR32:$src1, (load addr:$src2))),
2218 (implicit EFLAGS)]>;
2219
2220// Register-Integer Subtraction
2221def SUB8ri : Ii8 <0x80, MRM5r, (outs GR8:$dst),
2222 (ins GR8:$src1, i8imm:$src2),
2223 "sub{b}\t{$src2, $dst|$dst, $src2}",
2224 [(set GR8:$dst, (sub GR8:$src1, imm:$src2))]>;
2225def SUB16ri : Ii16<0x81, MRM5r, (outs GR16:$dst),
2226 (ins GR16:$src1, i16imm:$src2),
2227 "sub{w}\t{$src2, $dst|$dst, $src2}",
2228 [(set GR16:$dst, (sub GR16:$src1, imm:$src2))]>, OpSize;
2229def SUB32ri : Ii32<0x81, MRM5r, (outs GR32:$dst),
2230 (ins GR32:$src1, i32imm:$src2),
2231 "sub{l}\t{$src2, $dst|$dst, $src2}",
2232 [(set GR32:$dst, (sub GR32:$src1, imm:$src2))]>;
2233def SUB16ri8 : Ii8<0x83, MRM5r, (outs GR16:$dst),
2234 (ins GR16:$src1, i16i8imm:$src2),
2235 "sub{w}\t{$src2, $dst|$dst, $src2}",
2236 [(set GR16:$dst, (sub GR16:$src1, i16immSExt8:$src2))]>,
2237 OpSize;
2238def SUB32ri8 : Ii8<0x83, MRM5r, (outs GR32:$dst),
2239 (ins GR32:$src1, i32i8imm:$src2),
2240 "sub{l}\t{$src2, $dst|$dst, $src2}",
2241 [(set GR32:$dst, (sub GR32:$src1, i32immSExt8:$src2))]>;
2242
2243// Register-Integer Subtraction with Overflow
2244def SUBOvf8ri : Ii8 <0x80, MRM5r, (outs GR8:$dst),
2245 (ins GR8:$src1, i8imm:$src2),
2246 "sub{b}\t{$src2, $dst|$dst, $src2}",
2247 [(set GR8:$dst, (X86sub_ovf GR8:$src1, imm:$src2)),
2248 (implicit EFLAGS)]>;
2249def SUBOvf16ri : Ii16<0x81, MRM5r, (outs GR16:$dst),
2250 (ins GR16:$src1, i16imm:$src2),
2251 "sub{w}\t{$src2, $dst|$dst, $src2}",
2252 [(set GR16:$dst, (X86sub_ovf GR16:$src1, imm:$src2)),
2253 (implicit EFLAGS)]>, OpSize;
2254def SUBOvf32ri : Ii32<0x81, MRM5r, (outs GR32:$dst),
2255 (ins GR32:$src1, i32imm:$src2),
2256 "sub{l}\t{$src2, $dst|$dst, $src2}",
2257 [(set GR32:$dst, (X86sub_ovf GR32:$src1, imm:$src2)),
2258 (implicit EFLAGS)]>;
2259def SUBOvf16ri8 : Ii8<0x83, MRM5r, (outs GR16:$dst),
2260 (ins GR16:$src1, i16i8imm:$src2),
2261 "sub{w}\t{$src2, $dst|$dst, $src2}",
2262 [(set GR16:$dst, (X86sub_ovf GR16:$src1,
2263 i16immSExt8:$src2)),
2264 (implicit EFLAGS)]>, OpSize;
2265def SUBOvf32ri8 : Ii8<0x83, MRM5r, (outs GR32:$dst),
2266 (ins GR32:$src1, i32i8imm:$src2),
2267 "sub{l}\t{$src2, $dst|$dst, $src2}",
2268 [(set GR32:$dst, (X86sub_ovf GR32:$src1,
2269 i32immSExt8:$src2)),
2270 (implicit EFLAGS)]>;
2271
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002272let isTwoAddress = 0 in {
Bill Wendlingae034ed2008-12-12 00:56:36 +00002273 // Memory-Register Subtraction
Evan Chengb783fa32007-07-19 01:14:50 +00002274 def SUB8mr : I<0x28, MRMDestMem, (outs), (ins i8mem :$dst, GR8 :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002275 "sub{b}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingae034ed2008-12-12 00:56:36 +00002276 [(store (sub (load addr:$dst), GR8:$src2), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002277 def SUB16mr : I<0x29, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002278 "sub{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingae034ed2008-12-12 00:56:36 +00002279 [(store (sub (load addr:$dst), GR16:$src2), addr:$dst)]>,
2280 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002281 def SUB32mr : I<0x29, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002282 "sub{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingae034ed2008-12-12 00:56:36 +00002283 [(store (sub (load addr:$dst), GR32:$src2), addr:$dst)]>;
2284
2285 // Memory-Register Subtraction with Overflow
2286 def SUBOvf8mr : I<0x28, MRMDestMem, (outs), (ins i8mem :$dst, GR8 :$src2),
2287 "sub{b}\t{$src2, $dst|$dst, $src2}",
2288 [(store (X86sub_ovf (load addr:$dst), GR8:$src2),
2289 addr:$dst),
2290 (implicit EFLAGS)]>;
2291 def SUBOvf16mr : I<0x29, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
2292 "sub{w}\t{$src2, $dst|$dst, $src2}",
2293 [(store (X86sub_ovf (load addr:$dst), GR16:$src2),
2294 addr:$dst),
2295 (implicit EFLAGS)]>, OpSize;
2296 def SUBOvf32mr : I<0x29, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
2297 "sub{l}\t{$src2, $dst|$dst, $src2}",
2298 [(store (X86sub_ovf (load addr:$dst), GR32:$src2),
2299 addr:$dst),
2300 (implicit EFLAGS)]>;
2301
2302 // Memory-Integer Subtraction
Evan Chengb783fa32007-07-19 01:14:50 +00002303 def SUB8mi : Ii8<0x80, MRM5m, (outs), (ins i8mem :$dst, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002304 "sub{b}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingae034ed2008-12-12 00:56:36 +00002305 [(store (sub (loadi8 addr:$dst), imm:$src2), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002306 def SUB16mi : Ii16<0x81, MRM5m, (outs), (ins i16mem:$dst, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002307 "sub{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingae034ed2008-12-12 00:56:36 +00002308 [(store (sub (loadi16 addr:$dst), imm:$src2),addr:$dst)]>,
2309 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002310 def SUB32mi : Ii32<0x81, MRM5m, (outs), (ins i32mem:$dst, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002311 "sub{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingae034ed2008-12-12 00:56:36 +00002312 [(store (sub (loadi32 addr:$dst), imm:$src2),addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002313 def SUB16mi8 : Ii8<0x83, MRM5m, (outs), (ins i16mem:$dst, i16i8imm :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002314 "sub{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingae034ed2008-12-12 00:56:36 +00002315 [(store (sub (load addr:$dst), i16immSExt8:$src2),
2316 addr:$dst)]>, OpSize;
2317 def SUB32mi8 : Ii8<0x83, MRM5m, (outs), (ins i32mem:$dst, i32i8imm :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002318 "sub{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingae034ed2008-12-12 00:56:36 +00002319 [(store (sub (load addr:$dst), i32immSExt8:$src2),
2320 addr:$dst)]>;
2321
2322 // Memory-Integer Subtraction with Overflow
2323 def SUBOvf8mi : Ii8<0x80, MRM5m, (outs), (ins i8mem :$dst, i8imm:$src2),
2324 "sub{b}\t{$src2, $dst|$dst, $src2}",
2325 [(store (X86sub_ovf (loadi8 addr:$dst), imm:$src2),
2326 addr:$dst),
2327 (implicit EFLAGS)]>;
2328 def SUBOvf16mi : Ii16<0x81, MRM5m, (outs), (ins i16mem:$dst, i16imm:$src2),
2329 "sub{w}\t{$src2, $dst|$dst, $src2}",
2330 [(store (X86sub_ovf (loadi16 addr:$dst), imm:$src2),
2331 addr:$dst),
2332 (implicit EFLAGS)]>, OpSize;
2333 def SUBOvf32mi : Ii32<0x81, MRM5m, (outs), (ins i32mem:$dst, i32imm:$src2),
2334 "sub{l}\t{$src2, $dst|$dst, $src2}",
2335 [(store (X86sub_ovf (loadi32 addr:$dst), imm:$src2),
2336 addr:$dst),
2337 (implicit EFLAGS)]>;
2338 def SUBOvf16mi8 : Ii8<0x83, MRM5m, (outs), (ins i16mem:$dst, i16i8imm :$src2),
2339 "sub{w}\t{$src2, $dst|$dst, $src2}",
2340 [(store (X86sub_ovf (load addr:$dst),i16immSExt8:$src2),
2341 addr:$dst),
2342 (implicit EFLAGS)]>, OpSize;
2343 def SUBOvf32mi8 : Ii8<0x83, MRM5m, (outs), (ins i32mem:$dst, i32i8imm :$src2),
2344 "sub{l}\t{$src2, $dst|$dst, $src2}",
2345 [(store (X86sub_ovf (load addr:$dst),i32immSExt8:$src2),
2346 addr:$dst),
2347 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002348}
2349
Evan Cheng259471d2007-10-05 17:59:57 +00002350let Uses = [EFLAGS] in {
Evan Chengb783fa32007-07-19 01:14:50 +00002351def SBB32rr : I<0x19, MRMDestReg, (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002352 "sbb{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng55687072007-09-14 21:48:26 +00002353 [(set GR32:$dst, (sube GR32:$src1, GR32:$src2))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002354
2355let isTwoAddress = 0 in {
Evan Chengb783fa32007-07-19 01:14:50 +00002356 def SBB32mr : I<0x19, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002357 "sbb{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002358 [(store (sube (load addr:$dst), GR32:$src2), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002359 def SBB8mi : Ii32<0x80, MRM3m, (outs), (ins i8mem:$dst, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002360 "sbb{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002361 [(store (sube (loadi8 addr:$dst), imm:$src2), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002362 def SBB32mi : Ii32<0x81, MRM3m, (outs), (ins i32mem:$dst, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002363 "sbb{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002364 [(store (sube (loadi32 addr:$dst), imm:$src2), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002365 def SBB32mi8 : Ii8<0x83, MRM3m, (outs), (ins i32mem:$dst, i32i8imm :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002366 "sbb{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng55687072007-09-14 21:48:26 +00002367 [(store (sube (load addr:$dst), i32immSExt8:$src2), addr:$dst)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002368}
Evan Chengb783fa32007-07-19 01:14:50 +00002369def SBB32rm : I<0x1B, MRMSrcMem, (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002370 "sbb{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002371 [(set GR32:$dst, (sube GR32:$src1, (load addr:$src2)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002372def SBB32ri : Ii32<0x81, MRM3r, (outs GR32:$dst), (ins GR32:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002373 "sbb{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002374 [(set GR32:$dst, (sube GR32:$src1, imm:$src2))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002375def SBB32ri8 : Ii8<0x83, MRM3r, (outs GR32:$dst), (ins GR32:$src1, i32i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002376 "sbb{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002377 [(set GR32:$dst, (sube GR32:$src1, i32immSExt8:$src2))]>;
Evan Cheng259471d2007-10-05 17:59:57 +00002378} // Uses = [EFLAGS]
Evan Cheng55687072007-09-14 21:48:26 +00002379} // Defs = [EFLAGS]
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002380
Evan Cheng55687072007-09-14 21:48:26 +00002381let Defs = [EFLAGS] in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002382let isCommutable = 1 in { // X = IMUL Y, Z --> X = IMUL Z, Y
Bill Wendlingae034ed2008-12-12 00:56:36 +00002383// Register-Register Integer Multiply
2384def IMUL16rr : I<0xAF, MRMSrcReg, (outs GR16:$dst), (ins GR16:$src1,GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002385 "imul{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingae034ed2008-12-12 00:56:36 +00002386 [(set GR16:$dst, (mul GR16:$src1, GR16:$src2))]>, TB, OpSize;
2387def IMUL32rr : I<0xAF, MRMSrcReg, (outs GR32:$dst), (ins GR32:$src1,GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002388 "imul{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingae034ed2008-12-12 00:56:36 +00002389 [(set GR32:$dst, (mul GR32:$src1, GR32:$src2))]>, TB;
2390
2391// Register-Register Integer Multiply
2392def IMULOvf16rr : I<0xAF, MRMSrcReg, (outs GR16:$dst),
2393 (ins GR16:$src1, GR16:$src2),
2394 "imul{w}\t{$src2, $dst|$dst, $src2}",
2395 [(set GR16:$dst, (X86mul_ovf GR16:$src1, GR16:$src2)),
2396 (implicit EFLAGS)]>, TB, OpSize;
2397def IMULOvf32rr : I<0xAF, MRMSrcReg, (outs GR32:$dst),
2398 (ins GR32:$src1, GR32:$src2),
2399 "imul{l}\t{$src2, $dst|$dst, $src2}",
2400 [(set GR32:$dst, (X86mul_ovf GR32:$src1, GR32:$src2)),
2401 (implicit EFLAGS)]>, TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002402}
Bill Wendlingae034ed2008-12-12 00:56:36 +00002403
2404// Register-Memory Integer Multiply
2405def IMUL16rm : I<0xAF, MRMSrcMem, (outs GR16:$dst),
2406 (ins GR16:$src1, i16mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002407 "imul{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingae034ed2008-12-12 00:56:36 +00002408 [(set GR16:$dst, (mul GR16:$src1, (load addr:$src2)))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002409 TB, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002410def IMUL32rm : I<0xAF, MRMSrcMem, (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002411 "imul{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingae034ed2008-12-12 00:56:36 +00002412 [(set GR32:$dst, (mul GR32:$src1, (load addr:$src2)))]>, TB;
2413
2414// Register-Memory Integer Multiply with Overflow
2415def IMULOvf16rm : I<0xAF, MRMSrcMem, (outs GR16:$dst),
2416 (ins GR16:$src1, i16mem:$src2),
2417 "imul{w}\t{$src2, $dst|$dst, $src2}",
2418 [(set GR16:$dst, (X86mul_ovf GR16:$src1,(load addr:$src2))),
2419 (implicit EFLAGS)]>,
2420 TB, OpSize;
2421def IMULOvf32rm : I<0xAF, MRMSrcMem, (outs GR32:$dst),
2422 (ins GR32:$src1, i32mem:$src2),
2423 "imul{l}\t{$src2, $dst|$dst, $src2}",
2424 [(set GR32:$dst, (X86mul_ovf GR32:$src1,(load addr:$src2))),
2425 (implicit EFLAGS)]>, TB;
Evan Cheng55687072007-09-14 21:48:26 +00002426} // Defs = [EFLAGS]
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002427} // end Two Address instructions
2428
2429// Suprisingly enough, these are not two address instructions!
Evan Cheng55687072007-09-14 21:48:26 +00002430let Defs = [EFLAGS] in {
Bill Wendlingae034ed2008-12-12 00:56:36 +00002431// Register-Integer Integer Multiply
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002432def IMUL16rri : Ii16<0x69, MRMSrcReg, // GR16 = GR16*I16
Evan Chengb783fa32007-07-19 01:14:50 +00002433 (outs GR16:$dst), (ins GR16:$src1, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002434 "imul{w}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Bill Wendlingae034ed2008-12-12 00:56:36 +00002435 [(set GR16:$dst, (mul GR16:$src1, imm:$src2))]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002436def IMUL32rri : Ii32<0x69, MRMSrcReg, // GR32 = GR32*I32
Evan Chengb783fa32007-07-19 01:14:50 +00002437 (outs GR32:$dst), (ins GR32:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002438 "imul{l}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Bill Wendlingae034ed2008-12-12 00:56:36 +00002439 [(set GR32:$dst, (mul GR32:$src1, imm:$src2))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002440def IMUL16rri8 : Ii8<0x6B, MRMSrcReg, // GR16 = GR16*I8
Evan Chengb783fa32007-07-19 01:14:50 +00002441 (outs GR16:$dst), (ins GR16:$src1, i16i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002442 "imul{w}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Bill Wendlingae034ed2008-12-12 00:56:36 +00002443 [(set GR16:$dst, (mul GR16:$src1, i16immSExt8:$src2))]>,
2444 OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002445def IMUL32rri8 : Ii8<0x6B, MRMSrcReg, // GR32 = GR32*I8
Evan Chengb783fa32007-07-19 01:14:50 +00002446 (outs GR32:$dst), (ins GR32:$src1, i32i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002447 "imul{l}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Bill Wendlingae034ed2008-12-12 00:56:36 +00002448 [(set GR32:$dst, (mul GR32:$src1, i32immSExt8:$src2))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002449
Bill Wendlingae034ed2008-12-12 00:56:36 +00002450// Register-Integer Integer Multiply with Overflow
2451def IMULOvf16rri : Ii16<0x69, MRMSrcReg, // GR16 = GR16*I16
2452 (outs GR16:$dst), (ins GR16:$src1, i16imm:$src2),
2453 "imul{w}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
2454 [(set GR16:$dst, (X86mul_ovf GR16:$src1, imm:$src2)),
2455 (implicit EFLAGS)]>, OpSize;
2456def IMULOvf32rri : Ii32<0x69, MRMSrcReg, // GR32 = GR32*I32
2457 (outs GR32:$dst), (ins GR32:$src1, i32imm:$src2),
2458 "imul{l}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
2459 [(set GR32:$dst, (X86mul_ovf GR32:$src1, imm:$src2)),
2460 (implicit EFLAGS)]>;
2461def IMULOvf16rri8 : Ii8<0x6B, MRMSrcReg, // GR16 = GR16*I8
2462 (outs GR16:$dst), (ins GR16:$src1, i16i8imm:$src2),
2463 "imul{w}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
2464 [(set GR16:$dst, (X86mul_ovf GR16:$src1,
2465 i16immSExt8:$src2)),
2466 (implicit EFLAGS)]>, OpSize;
2467def IMULOvf32rri8 : Ii8<0x6B, MRMSrcReg, // GR32 = GR32*I8
2468 (outs GR32:$dst), (ins GR32:$src1, i32i8imm:$src2),
2469 "imul{l}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
2470 [(set GR32:$dst, (X86mul_ovf GR32:$src1,
2471 i32immSExt8:$src2)),
2472 (implicit EFLAGS)]>;
2473
2474// Memory-Integer Integer Multiply
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002475def IMUL16rmi : Ii16<0x69, MRMSrcMem, // GR16 = [mem16]*I16
Evan Chengb783fa32007-07-19 01:14:50 +00002476 (outs GR16:$dst), (ins i16mem:$src1, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002477 "imul{w}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Bill Wendlingae034ed2008-12-12 00:56:36 +00002478 [(set GR16:$dst, (mul (load addr:$src1), imm:$src2))]>,
2479 OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002480def IMUL32rmi : Ii32<0x69, MRMSrcMem, // GR32 = [mem32]*I32
Evan Chengb783fa32007-07-19 01:14:50 +00002481 (outs GR32:$dst), (ins i32mem:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002482 "imul{l}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Bill Wendlingae034ed2008-12-12 00:56:36 +00002483 [(set GR32:$dst, (mul (load addr:$src1), imm:$src2))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002484def IMUL16rmi8 : Ii8<0x6B, MRMSrcMem, // GR16 = [mem16]*I8
Evan Chengb783fa32007-07-19 01:14:50 +00002485 (outs GR16:$dst), (ins i16mem:$src1, i16i8imm :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002486 "imul{w}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Bill Wendlingae034ed2008-12-12 00:56:36 +00002487 [(set GR16:$dst, (mul (load addr:$src1),
2488 i16immSExt8:$src2))]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002489def IMUL32rmi8 : Ii8<0x6B, MRMSrcMem, // GR32 = [mem32]*I8
Evan Chengb783fa32007-07-19 01:14:50 +00002490 (outs GR32:$dst), (ins i32mem:$src1, i32i8imm: $src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002491 "imul{l}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Bill Wendlingae034ed2008-12-12 00:56:36 +00002492 [(set GR32:$dst, (mul (load addr:$src1),
2493 i32immSExt8:$src2))]>;
2494
2495// Memory-Integer Integer Multiply with Overflow
2496def IMULOvf16rmi : Ii16<0x69, MRMSrcMem, // GR16 = [mem16]*I16
2497 (outs GR16:$dst), (ins i16mem:$src1, i16imm:$src2),
2498 "imul{w}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
2499 [(set GR16:$dst, (X86mul_ovf (load addr:$src1),
2500 imm:$src2)),
2501 (implicit EFLAGS)]>, OpSize;
2502def IMULOvf32rmi : Ii32<0x69, MRMSrcMem, // GR32 = [mem32]*I32
2503 (outs GR32:$dst), (ins i32mem:$src1, i32imm:$src2),
2504 "imul{l}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
2505 [(set GR32:$dst, (X86mul_ovf (load addr:$src1),
2506 imm:$src2)),
2507 (implicit EFLAGS)]>;
2508def IMULOvf16rmi8 : Ii8<0x6B, MRMSrcMem, // GR16 = [mem16]*I8
2509 (outs GR16:$dst), (ins i16mem:$src1, i16i8imm :$src2),
2510 "imul{w}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
2511 [(set GR16:$dst, (X86mul_ovf (load addr:$src1),
2512 i16immSExt8:$src2)),
2513 (implicit EFLAGS)]>, OpSize;
2514def IMULOvf32rmi8 : Ii8<0x6B, MRMSrcMem, // GR32 = [mem32]*I8
2515 (outs GR32:$dst), (ins i32mem:$src1, i32i8imm: $src2),
2516 "imul{l}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
2517 [(set GR32:$dst, (X86mul_ovf (load addr:$src1),
2518 i32immSExt8:$src2)),
2519 (implicit EFLAGS)]>;
Evan Cheng55687072007-09-14 21:48:26 +00002520} // Defs = [EFLAGS]
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002521
2522//===----------------------------------------------------------------------===//
2523// Test instructions are just like AND, except they don't generate a result.
2524//
Evan Cheng950aac02007-09-25 01:57:46 +00002525let Defs = [EFLAGS] in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002526let isCommutable = 1 in { // TEST X, Y --> TEST Y, X
Evan Chengb783fa32007-07-19 01:14:50 +00002527def TEST8rr : I<0x84, MRMDestReg, (outs), (ins GR8:$src1, GR8:$src2),
Evan Cheng621216e2007-09-29 00:00:36 +00002528 "test{b}\t{$src2, $src1|$src1, $src2}",
Chris Lattner21da6382008-02-19 17:37:35 +00002529 [(X86cmp (and_su GR8:$src1, GR8:$src2), 0),
Evan Cheng621216e2007-09-29 00:00:36 +00002530 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002531def TEST16rr : I<0x85, MRMDestReg, (outs), (ins GR16:$src1, GR16:$src2),
Evan Cheng621216e2007-09-29 00:00:36 +00002532 "test{w}\t{$src2, $src1|$src1, $src2}",
Chris Lattner21da6382008-02-19 17:37:35 +00002533 [(X86cmp (and_su GR16:$src1, GR16:$src2), 0),
Evan Cheng621216e2007-09-29 00:00:36 +00002534 (implicit EFLAGS)]>,
2535 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002536def TEST32rr : I<0x85, MRMDestReg, (outs), (ins GR32:$src1, GR32:$src2),
Evan Cheng621216e2007-09-29 00:00:36 +00002537 "test{l}\t{$src2, $src1|$src1, $src2}",
Chris Lattner21da6382008-02-19 17:37:35 +00002538 [(X86cmp (and_su GR32:$src1, GR32:$src2), 0),
Evan Cheng621216e2007-09-29 00:00:36 +00002539 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002540}
2541
Evan Chengb783fa32007-07-19 01:14:50 +00002542def TEST8rm : I<0x84, MRMSrcMem, (outs), (ins GR8 :$src1, i8mem :$src2),
Evan Cheng621216e2007-09-29 00:00:36 +00002543 "test{b}\t{$src2, $src1|$src1, $src2}",
2544 [(X86cmp (and GR8:$src1, (loadi8 addr:$src2)), 0),
2545 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002546def TEST16rm : I<0x85, MRMSrcMem, (outs), (ins GR16:$src1, i16mem:$src2),
Evan Cheng621216e2007-09-29 00:00:36 +00002547 "test{w}\t{$src2, $src1|$src1, $src2}",
2548 [(X86cmp (and GR16:$src1, (loadi16 addr:$src2)), 0),
2549 (implicit EFLAGS)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002550def TEST32rm : I<0x85, MRMSrcMem, (outs), (ins GR32:$src1, i32mem:$src2),
Evan Cheng621216e2007-09-29 00:00:36 +00002551 "test{l}\t{$src2, $src1|$src1, $src2}",
2552 [(X86cmp (and GR32:$src1, (loadi32 addr:$src2)), 0),
2553 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002554
2555def TEST8ri : Ii8 <0xF6, MRM0r, // flags = GR8 & imm8
Evan Chengb783fa32007-07-19 01:14:50 +00002556 (outs), (ins GR8:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002557 "test{b}\t{$src2, $src1|$src1, $src2}",
Chris Lattner21da6382008-02-19 17:37:35 +00002558 [(X86cmp (and_su GR8:$src1, imm:$src2), 0),
Evan Cheng621216e2007-09-29 00:00:36 +00002559 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002560def TEST16ri : Ii16<0xF7, MRM0r, // flags = GR16 & imm16
Evan Chengb783fa32007-07-19 01:14:50 +00002561 (outs), (ins GR16:$src1, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002562 "test{w}\t{$src2, $src1|$src1, $src2}",
Chris Lattner21da6382008-02-19 17:37:35 +00002563 [(X86cmp (and_su GR16:$src1, imm:$src2), 0),
Evan Cheng621216e2007-09-29 00:00:36 +00002564 (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002565def TEST32ri : Ii32<0xF7, MRM0r, // flags = GR32 & imm32
Evan Chengb783fa32007-07-19 01:14:50 +00002566 (outs), (ins GR32:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002567 "test{l}\t{$src2, $src1|$src1, $src2}",
Chris Lattner21da6382008-02-19 17:37:35 +00002568 [(X86cmp (and_su GR32:$src1, imm:$src2), 0),
Evan Cheng621216e2007-09-29 00:00:36 +00002569 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002570
Evan Cheng621216e2007-09-29 00:00:36 +00002571def TEST8mi : Ii8 <0xF6, MRM0m, // flags = [mem8] & imm8
Evan Chengb783fa32007-07-19 01:14:50 +00002572 (outs), (ins i8mem:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002573 "test{b}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002574 [(X86cmp (and (loadi8 addr:$src1), imm:$src2), 0),
2575 (implicit EFLAGS)]>;
2576def TEST16mi : Ii16<0xF7, MRM0m, // flags = [mem16] & imm16
Evan Chengb783fa32007-07-19 01:14:50 +00002577 (outs), (ins i16mem:$src1, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002578 "test{w}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002579 [(X86cmp (and (loadi16 addr:$src1), imm:$src2), 0),
2580 (implicit EFLAGS)]>, OpSize;
2581def TEST32mi : Ii32<0xF7, MRM0m, // flags = [mem32] & imm32
Evan Chengb783fa32007-07-19 01:14:50 +00002582 (outs), (ins i32mem:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002583 "test{l}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002584 [(X86cmp (and (loadi32 addr:$src1), imm:$src2), 0),
Evan Cheng950aac02007-09-25 01:57:46 +00002585 (implicit EFLAGS)]>;
2586} // Defs = [EFLAGS]
2587
2588
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002589// Condition code ops, incl. set if equal/not equal/...
Chris Lattnerc90ee9c2008-01-10 07:59:24 +00002590let Defs = [EFLAGS], Uses = [AH], neverHasSideEffects = 1 in
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002591def SAHF : I<0x9E, RawFrm, (outs), (ins), "sahf", []>; // flags = AH
Chris Lattnerc90ee9c2008-01-10 07:59:24 +00002592let Defs = [AH], Uses = [EFLAGS], neverHasSideEffects = 1 in
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002593def LAHF : I<0x9F, RawFrm, (outs), (ins), "lahf", []>; // AH = flags
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002594
Evan Cheng950aac02007-09-25 01:57:46 +00002595let Uses = [EFLAGS] in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002596def SETEr : I<0x94, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00002597 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002598 "sete\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002599 [(set GR8:$dst, (X86setcc X86_COND_E, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002600 TB; // GR8 = ==
2601def SETEm : I<0x94, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00002602 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002603 "sete\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002604 [(store (X86setcc X86_COND_E, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002605 TB; // [mem8] = ==
Bill Wendling0c52d0a2008-12-02 00:07:05 +00002606
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002607def SETNEr : I<0x95, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00002608 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002609 "setne\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002610 [(set GR8:$dst, (X86setcc X86_COND_NE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002611 TB; // GR8 = !=
2612def SETNEm : I<0x95, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00002613 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002614 "setne\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002615 [(store (X86setcc X86_COND_NE, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002616 TB; // [mem8] = !=
Bill Wendling0c52d0a2008-12-02 00:07:05 +00002617
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002618def SETLr : I<0x9C, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00002619 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002620 "setl\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002621 [(set GR8:$dst, (X86setcc X86_COND_L, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002622 TB; // GR8 = < signed
2623def SETLm : I<0x9C, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00002624 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002625 "setl\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002626 [(store (X86setcc X86_COND_L, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002627 TB; // [mem8] = < signed
Bill Wendling0c52d0a2008-12-02 00:07:05 +00002628
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002629def SETGEr : I<0x9D, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00002630 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002631 "setge\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002632 [(set GR8:$dst, (X86setcc X86_COND_GE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002633 TB; // GR8 = >= signed
2634def SETGEm : I<0x9D, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00002635 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002636 "setge\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002637 [(store (X86setcc X86_COND_GE, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002638 TB; // [mem8] = >= signed
Bill Wendling0c52d0a2008-12-02 00:07:05 +00002639
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002640def SETLEr : I<0x9E, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00002641 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002642 "setle\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002643 [(set GR8:$dst, (X86setcc X86_COND_LE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002644 TB; // GR8 = <= signed
2645def SETLEm : I<0x9E, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00002646 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002647 "setle\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002648 [(store (X86setcc X86_COND_LE, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002649 TB; // [mem8] = <= signed
Bill Wendling0c52d0a2008-12-02 00:07:05 +00002650
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002651def SETGr : I<0x9F, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00002652 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002653 "setg\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002654 [(set GR8:$dst, (X86setcc X86_COND_G, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002655 TB; // GR8 = > signed
2656def SETGm : I<0x9F, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00002657 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002658 "setg\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002659 [(store (X86setcc X86_COND_G, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002660 TB; // [mem8] = > signed
2661
2662def SETBr : I<0x92, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00002663 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002664 "setb\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002665 [(set GR8:$dst, (X86setcc X86_COND_B, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002666 TB; // GR8 = < unsign
2667def SETBm : I<0x92, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00002668 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002669 "setb\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002670 [(store (X86setcc X86_COND_B, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002671 TB; // [mem8] = < unsign
Bill Wendling0c52d0a2008-12-02 00:07:05 +00002672
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002673def SETAEr : I<0x93, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00002674 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002675 "setae\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002676 [(set GR8:$dst, (X86setcc X86_COND_AE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002677 TB; // GR8 = >= unsign
2678def SETAEm : I<0x93, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00002679 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002680 "setae\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002681 [(store (X86setcc X86_COND_AE, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002682 TB; // [mem8] = >= unsign
Bill Wendling0c52d0a2008-12-02 00:07:05 +00002683
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002684def SETBEr : I<0x96, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00002685 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002686 "setbe\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002687 [(set GR8:$dst, (X86setcc X86_COND_BE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002688 TB; // GR8 = <= unsign
2689def SETBEm : I<0x96, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00002690 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002691 "setbe\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002692 [(store (X86setcc X86_COND_BE, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002693 TB; // [mem8] = <= unsign
Bill Wendling0c52d0a2008-12-02 00:07:05 +00002694
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002695def SETAr : I<0x97, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00002696 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002697 "seta\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002698 [(set GR8:$dst, (X86setcc X86_COND_A, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002699 TB; // GR8 = > signed
2700def SETAm : I<0x97, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00002701 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002702 "seta\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002703 [(store (X86setcc X86_COND_A, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002704 TB; // [mem8] = > signed
2705
2706def SETSr : I<0x98, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00002707 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002708 "sets\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002709 [(set GR8:$dst, (X86setcc X86_COND_S, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002710 TB; // GR8 = <sign bit>
2711def SETSm : I<0x98, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00002712 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002713 "sets\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002714 [(store (X86setcc X86_COND_S, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002715 TB; // [mem8] = <sign bit>
2716def SETNSr : I<0x99, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00002717 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002718 "setns\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002719 [(set GR8:$dst, (X86setcc X86_COND_NS, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002720 TB; // GR8 = !<sign bit>
2721def SETNSm : I<0x99, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00002722 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002723 "setns\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002724 [(store (X86setcc X86_COND_NS, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002725 TB; // [mem8] = !<sign bit>
Bill Wendling0c52d0a2008-12-02 00:07:05 +00002726
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002727def SETPr : I<0x9A, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00002728 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002729 "setp\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002730 [(set GR8:$dst, (X86setcc X86_COND_P, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002731 TB; // GR8 = parity
2732def SETPm : I<0x9A, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00002733 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002734 "setp\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002735 [(store (X86setcc X86_COND_P, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002736 TB; // [mem8] = parity
2737def SETNPr : I<0x9B, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00002738 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002739 "setnp\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002740 [(set GR8:$dst, (X86setcc X86_COND_NP, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002741 TB; // GR8 = not parity
2742def SETNPm : I<0x9B, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00002743 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002744 "setnp\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002745 [(store (X86setcc X86_COND_NP, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002746 TB; // [mem8] = not parity
Bill Wendling0c52d0a2008-12-02 00:07:05 +00002747
2748def SETOr : I<0x90, MRM0r,
2749 (outs GR8 :$dst), (ins),
2750 "seto\t$dst",
2751 [(set GR8:$dst, (X86setcc X86_COND_O, EFLAGS))]>,
2752 TB; // GR8 = overflow
2753def SETOm : I<0x90, MRM0m,
2754 (outs), (ins i8mem:$dst),
2755 "seto\t$dst",
2756 [(store (X86setcc X86_COND_O, EFLAGS), addr:$dst)]>,
2757 TB; // [mem8] = overflow
2758def SETNOr : I<0x91, MRM0r,
2759 (outs GR8 :$dst), (ins),
2760 "setno\t$dst",
2761 [(set GR8:$dst, (X86setcc X86_COND_NO, EFLAGS))]>,
2762 TB; // GR8 = not overflow
2763def SETNOm : I<0x91, MRM0m,
2764 (outs), (ins i8mem:$dst),
2765 "setno\t$dst",
2766 [(store (X86setcc X86_COND_NO, EFLAGS), addr:$dst)]>,
2767 TB; // [mem8] = not overflow
2768
2769def SETCr : I<0x92, MRM0r,
2770 (outs GR8 :$dst), (ins),
2771 "setc\t$dst",
2772 [(set GR8:$dst, (X86setcc X86_COND_C, EFLAGS))]>,
2773 TB; // GR8 = carry
2774def SETCm : I<0x92, MRM0m,
2775 (outs), (ins i8mem:$dst),
2776 "setc\t$dst",
2777 [(store (X86setcc X86_COND_C, EFLAGS), addr:$dst)]>,
2778 TB; // [mem8] = carry
2779def SETNCr : I<0x93, MRM0r,
2780 (outs GR8 :$dst), (ins),
2781 "setnc\t$dst",
2782 [(set GR8:$dst, (X86setcc X86_COND_NC, EFLAGS))]>,
2783 TB; // GR8 = not carry
2784def SETNCm : I<0x93, MRM0m,
2785 (outs), (ins i8mem:$dst),
2786 "setnc\t$dst",
2787 [(store (X86setcc X86_COND_NC, EFLAGS), addr:$dst)]>,
2788 TB; // [mem8] = not carry
Evan Cheng950aac02007-09-25 01:57:46 +00002789} // Uses = [EFLAGS]
2790
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002791
2792// Integer comparisons
Evan Cheng55687072007-09-14 21:48:26 +00002793let Defs = [EFLAGS] in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002794def CMP8rr : I<0x38, MRMDestReg,
Evan Chengb783fa32007-07-19 01:14:50 +00002795 (outs), (ins GR8 :$src1, GR8 :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002796 "cmp{b}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002797 [(X86cmp GR8:$src1, GR8:$src2), (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002798def CMP16rr : I<0x39, MRMDestReg,
Evan Chengb783fa32007-07-19 01:14:50 +00002799 (outs), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002800 "cmp{w}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002801 [(X86cmp GR16:$src1, GR16:$src2), (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002802def CMP32rr : I<0x39, MRMDestReg,
Evan Chengb783fa32007-07-19 01:14:50 +00002803 (outs), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002804 "cmp{l}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002805 [(X86cmp GR32:$src1, GR32:$src2), (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002806def CMP8mr : I<0x38, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00002807 (outs), (ins i8mem :$src1, GR8 :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002808 "cmp{b}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002809 [(X86cmp (loadi8 addr:$src1), GR8:$src2),
2810 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002811def CMP16mr : I<0x39, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00002812 (outs), (ins i16mem:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002813 "cmp{w}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002814 [(X86cmp (loadi16 addr:$src1), GR16:$src2),
2815 (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002816def CMP32mr : I<0x39, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00002817 (outs), (ins i32mem:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002818 "cmp{l}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002819 [(X86cmp (loadi32 addr:$src1), GR32:$src2),
2820 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002821def CMP8rm : I<0x3A, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00002822 (outs), (ins GR8 :$src1, i8mem :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002823 "cmp{b}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002824 [(X86cmp GR8:$src1, (loadi8 addr:$src2)),
2825 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002826def CMP16rm : I<0x3B, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00002827 (outs), (ins GR16:$src1, i16mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002828 "cmp{w}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002829 [(X86cmp GR16:$src1, (loadi16 addr:$src2)),
2830 (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002831def CMP32rm : I<0x3B, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00002832 (outs), (ins GR32:$src1, i32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002833 "cmp{l}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002834 [(X86cmp GR32:$src1, (loadi32 addr:$src2)),
2835 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002836def CMP8ri : Ii8<0x80, MRM7r,
Evan Chengb783fa32007-07-19 01:14:50 +00002837 (outs), (ins GR8:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002838 "cmp{b}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002839 [(X86cmp GR8:$src1, imm:$src2), (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002840def CMP16ri : Ii16<0x81, MRM7r,
Evan Chengb783fa32007-07-19 01:14:50 +00002841 (outs), (ins GR16:$src1, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002842 "cmp{w}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002843 [(X86cmp GR16:$src1, imm:$src2),
2844 (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002845def CMP32ri : Ii32<0x81, MRM7r,
Evan Chengb783fa32007-07-19 01:14:50 +00002846 (outs), (ins GR32:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002847 "cmp{l}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002848 [(X86cmp GR32:$src1, imm:$src2), (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002849def CMP8mi : Ii8 <0x80, MRM7m,
Evan Chengb783fa32007-07-19 01:14:50 +00002850 (outs), (ins i8mem :$src1, i8imm :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002851 "cmp{b}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002852 [(X86cmp (loadi8 addr:$src1), imm:$src2),
2853 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002854def CMP16mi : Ii16<0x81, MRM7m,
Evan Chengb783fa32007-07-19 01:14:50 +00002855 (outs), (ins i16mem:$src1, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002856 "cmp{w}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002857 [(X86cmp (loadi16 addr:$src1), imm:$src2),
2858 (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002859def CMP32mi : Ii32<0x81, MRM7m,
Evan Chengb783fa32007-07-19 01:14:50 +00002860 (outs), (ins i32mem:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002861 "cmp{l}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002862 [(X86cmp (loadi32 addr:$src1), imm:$src2),
2863 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002864def CMP16ri8 : Ii8<0x83, MRM7r,
Evan Chengb783fa32007-07-19 01:14:50 +00002865 (outs), (ins GR16:$src1, i16i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002866 "cmp{w}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002867 [(X86cmp GR16:$src1, i16immSExt8:$src2),
2868 (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002869def CMP16mi8 : Ii8<0x83, MRM7m,
Evan Chengb783fa32007-07-19 01:14:50 +00002870 (outs), (ins i16mem:$src1, i16i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002871 "cmp{w}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002872 [(X86cmp (loadi16 addr:$src1), i16immSExt8:$src2),
2873 (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002874def CMP32mi8 : Ii8<0x83, MRM7m,
Evan Chengb783fa32007-07-19 01:14:50 +00002875 (outs), (ins i32mem:$src1, i32i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002876 "cmp{l}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002877 [(X86cmp (loadi32 addr:$src1), i32immSExt8:$src2),
2878 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002879def CMP32ri8 : Ii8<0x83, MRM7r,
Evan Chengb783fa32007-07-19 01:14:50 +00002880 (outs), (ins GR32:$src1, i32i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002881 "cmp{l}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002882 [(X86cmp GR32:$src1, i32immSExt8:$src2),
Evan Cheng950aac02007-09-25 01:57:46 +00002883 (implicit EFLAGS)]>;
2884} // Defs = [EFLAGS]
2885
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002886// Sign/Zero extenders
Dan Gohman9203ab42008-07-30 18:09:17 +00002887// Use movsbl intead of movsbw; we don't care about the high 16 bits
2888// of the register here. This has a smaller encoding and avoids a
2889// partial-register update.
Evan Chengb783fa32007-07-19 01:14:50 +00002890def MOVSX16rr8 : I<0xBE, MRMSrcReg, (outs GR16:$dst), (ins GR8 :$src),
Dan Gohman9203ab42008-07-30 18:09:17 +00002891 "movs{bl|x}\t{$src, ${dst:subreg32}|${dst:subreg32}, $src}",
2892 [(set GR16:$dst, (sext GR8:$src))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00002893def MOVSX16rm8 : I<0xBE, MRMSrcMem, (outs GR16:$dst), (ins i8mem :$src),
Dan Gohman9203ab42008-07-30 18:09:17 +00002894 "movs{bl|x}\t{$src, ${dst:subreg32}|${dst:subreg32}, $src}",
2895 [(set GR16:$dst, (sextloadi16i8 addr:$src))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00002896def MOVSX32rr8 : I<0xBE, MRMSrcReg, (outs GR32:$dst), (ins GR8 :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002897 "movs{bl|x}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002898 [(set GR32:$dst, (sext GR8:$src))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00002899def MOVSX32rm8 : I<0xBE, MRMSrcMem, (outs GR32:$dst), (ins i8mem :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002900 "movs{bl|x}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002901 [(set GR32:$dst, (sextloadi32i8 addr:$src))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00002902def MOVSX32rr16: I<0xBF, MRMSrcReg, (outs GR32:$dst), (ins GR16:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002903 "movs{wl|x}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002904 [(set GR32:$dst, (sext GR16:$src))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00002905def MOVSX32rm16: I<0xBF, MRMSrcMem, (outs GR32:$dst), (ins i16mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002906 "movs{wl|x}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002907 [(set GR32:$dst, (sextloadi32i16 addr:$src))]>, TB;
2908
Dan Gohman9203ab42008-07-30 18:09:17 +00002909// Use movzbl intead of movzbw; we don't care about the high 16 bits
2910// of the register here. This has a smaller encoding and avoids a
2911// partial-register update.
Evan Chengb783fa32007-07-19 01:14:50 +00002912def MOVZX16rr8 : I<0xB6, MRMSrcReg, (outs GR16:$dst), (ins GR8 :$src),
Dan Gohman9203ab42008-07-30 18:09:17 +00002913 "movz{bl|x}\t{$src, ${dst:subreg32}|${dst:subreg32}, $src}",
2914 [(set GR16:$dst, (zext GR8:$src))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00002915def MOVZX16rm8 : I<0xB6, MRMSrcMem, (outs GR16:$dst), (ins i8mem :$src),
Dan Gohman9203ab42008-07-30 18:09:17 +00002916 "movz{bl|x}\t{$src, ${dst:subreg32}|${dst:subreg32}, $src}",
2917 [(set GR16:$dst, (zextloadi16i8 addr:$src))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00002918def MOVZX32rr8 : I<0xB6, MRMSrcReg, (outs GR32:$dst), (ins GR8 :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002919 "movz{bl|x}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002920 [(set GR32:$dst, (zext GR8:$src))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00002921def MOVZX32rm8 : I<0xB6, MRMSrcMem, (outs GR32:$dst), (ins i8mem :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002922 "movz{bl|x}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002923 [(set GR32:$dst, (zextloadi32i8 addr:$src))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00002924def MOVZX32rr16: I<0xB7, MRMSrcReg, (outs GR32:$dst), (ins GR16:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002925 "movz{wl|x}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002926 [(set GR32:$dst, (zext GR16:$src))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00002927def MOVZX32rm16: I<0xB7, MRMSrcMem, (outs GR32:$dst), (ins i16mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002928 "movz{wl|x}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002929 [(set GR32:$dst, (zextloadi32i16 addr:$src))]>, TB;
2930
Chris Lattnerc90ee9c2008-01-10 07:59:24 +00002931let neverHasSideEffects = 1 in {
2932 let Defs = [AX], Uses = [AL] in
2933 def CBW : I<0x98, RawFrm, (outs), (ins),
2934 "{cbtw|cbw}", []>, OpSize; // AX = signext(AL)
2935 let Defs = [EAX], Uses = [AX] in
2936 def CWDE : I<0x98, RawFrm, (outs), (ins),
2937 "{cwtl|cwde}", []>; // EAX = signext(AX)
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002938
Chris Lattnerc90ee9c2008-01-10 07:59:24 +00002939 let Defs = [AX,DX], Uses = [AX] in
2940 def CWD : I<0x99, RawFrm, (outs), (ins),
2941 "{cwtd|cwd}", []>, OpSize; // DX:AX = signext(AX)
2942 let Defs = [EAX,EDX], Uses = [EAX] in
2943 def CDQ : I<0x99, RawFrm, (outs), (ins),
2944 "{cltd|cdq}", []>; // EDX:EAX = signext(EAX)
2945}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002946
2947//===----------------------------------------------------------------------===//
2948// Alias Instructions
2949//===----------------------------------------------------------------------===//
2950
2951// Alias instructions that map movr0 to xor.
2952// FIXME: remove when we can teach regalloc that xor reg, reg is ok.
Bill Wendlingba5d5b02008-05-29 01:02:09 +00002953let Defs = [EFLAGS], isReMaterializable = 1, isAsCheapAsAMove = 1 in {
Evan Chengb783fa32007-07-19 01:14:50 +00002954def MOV8r0 : I<0x30, MRMInitReg, (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002955 "xor{b}\t$dst, $dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002956 [(set GR8:$dst, 0)]>;
Dan Gohman9203ab42008-07-30 18:09:17 +00002957// Use xorl instead of xorw since we don't care about the high 16 bits,
2958// it's smaller, and it avoids a partial-register update.
Evan Chengb783fa32007-07-19 01:14:50 +00002959def MOV16r0 : I<0x31, MRMInitReg, (outs GR16:$dst), (ins),
Dan Gohman9203ab42008-07-30 18:09:17 +00002960 "xor{l}\t${dst:subreg32}, ${dst:subreg32}",
2961 [(set GR16:$dst, 0)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002962def MOV32r0 : I<0x31, MRMInitReg, (outs GR32:$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002963 "xor{l}\t$dst, $dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002964 [(set GR32:$dst, 0)]>;
Dan Gohman8aef09b2007-09-07 21:32:51 +00002965}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002966
2967// Basic operations on GR16 / GR32 subclasses GR16_ and GR32_ which contains only
2968// those registers that have GR8 sub-registers (i.e. AX - DX, EAX - EDX).
Chris Lattnerc90ee9c2008-01-10 07:59:24 +00002969let neverHasSideEffects = 1 in {
Evan Chengb783fa32007-07-19 01:14:50 +00002970def MOV16to16_ : I<0x89, MRMDestReg, (outs GR16_:$dst), (ins GR16:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002971 "mov{w}\t{$src, $dst|$dst, $src}", []>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002972def MOV32to32_ : I<0x89, MRMDestReg, (outs GR32_:$dst), (ins GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002973 "mov{l}\t{$src, $dst|$dst, $src}", []>;
Chris Lattnerc90ee9c2008-01-10 07:59:24 +00002974
Evan Chengb783fa32007-07-19 01:14:50 +00002975def MOV16_rr : I<0x89, MRMDestReg, (outs GR16_:$dst), (ins GR16_:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002976 "mov{w}\t{$src, $dst|$dst, $src}", []>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002977def MOV32_rr : I<0x89, MRMDestReg, (outs GR32_:$dst), (ins GR32_:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002978 "mov{l}\t{$src, $dst|$dst, $src}", []>;
Chris Lattnerc90ee9c2008-01-10 07:59:24 +00002979} // neverHasSideEffects
2980
Dan Gohman5574cc72008-12-03 18:15:48 +00002981let canFoldAsLoad = 1, mayLoad = 1, isReMaterializable = 1, mayHaveSideEffects = 1 in {
Evan Chengb783fa32007-07-19 01:14:50 +00002982def MOV16_rm : I<0x8B, MRMSrcMem, (outs GR16_:$dst), (ins i16mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002983 "mov{w}\t{$src, $dst|$dst, $src}", []>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002984def MOV32_rm : I<0x8B, MRMSrcMem, (outs GR32_:$dst), (ins i32mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002985 "mov{l}\t{$src, $dst|$dst, $src}", []>;
Evan Cheng4e84e452007-08-30 05:49:43 +00002986}
Chris Lattnerc90ee9c2008-01-10 07:59:24 +00002987let mayStore = 1, neverHasSideEffects = 1 in {
Evan Chengb783fa32007-07-19 01:14:50 +00002988def MOV16_mr : I<0x89, MRMDestMem, (outs), (ins i16mem:$dst, GR16_:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002989 "mov{w}\t{$src, $dst|$dst, $src}", []>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002990def MOV32_mr : I<0x89, MRMDestMem, (outs), (ins i32mem:$dst, GR32_:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002991 "mov{l}\t{$src, $dst|$dst, $src}", []>;
Chris Lattnerc90ee9c2008-01-10 07:59:24 +00002992}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002993
2994//===----------------------------------------------------------------------===//
2995// Thread Local Storage Instructions
2996//
2997
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002998let Uses = [EBX] in
Anton Korobeynikov4fbf00b2008-05-04 21:36:32 +00002999def TLS_addr32 : I<0, Pseudo, (outs GR32:$dst), (ins i32imm:$sym),
3000 "leal\t${sym:mem}(,%ebx,1), $dst",
3001 [(set GR32:$dst, (X86tlsaddr tglobaltlsaddr:$sym))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003002
3003let AddedComplexity = 10 in
Anton Korobeynikov4fbf00b2008-05-04 21:36:32 +00003004def TLS_gs_rr : I<0, Pseudo, (outs GR32:$dst), (ins GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00003005 "movl\t%gs:($src), $dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003006 [(set GR32:$dst, (load (add X86TLStp, GR32:$src)))]>;
3007
3008let AddedComplexity = 15 in
Nicolas Geoffray81580792008-10-25 15:22:06 +00003009def TLS_gs_ri : I<0x8B, Pseudo, (outs GR32:$dst), (ins i32imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00003010 "movl\t%gs:${src:mem}, $dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003011 [(set GR32:$dst,
Nicolas Geoffray81580792008-10-25 15:22:06 +00003012 (load (add X86TLStp, (X86Wrapper tglobaltlsaddr:$src))))]>,
3013 SegGS;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003014
Nicolas Geoffray81580792008-10-25 15:22:06 +00003015def TLS_tp : I<0x8B, Pseudo, (outs GR32:$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00003016 "movl\t%gs:0, $dst",
Nicolas Geoffray81580792008-10-25 15:22:06 +00003017 [(set GR32:$dst, X86TLStp)]>, SegGS;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003018
3019//===----------------------------------------------------------------------===//
3020// DWARF Pseudo Instructions
3021//
3022
Evan Chengb783fa32007-07-19 01:14:50 +00003023def DWARF_LOC : I<0, Pseudo, (outs),
3024 (ins i32imm:$line, i32imm:$col, i32imm:$file),
Dan Gohman77af4a82007-09-24 19:25:06 +00003025 ".loc\t${file:debug} ${line:debug} ${col:debug}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003026 [(dwarf_loc (i32 imm:$line), (i32 imm:$col),
3027 (i32 imm:$file))]>;
3028
3029//===----------------------------------------------------------------------===//
3030// EH Pseudo Instructions
3031//
3032let isTerminator = 1, isReturn = 1, isBarrier = 1,
Evan Cheng37e7c752007-07-21 00:34:19 +00003033 hasCtrlDep = 1 in {
Evan Chengb783fa32007-07-19 01:14:50 +00003034def EH_RETURN : I<0xC3, RawFrm, (outs), (ins GR32:$addr),
Dan Gohman91888f02007-07-31 20:11:57 +00003035 "ret\t#eh_return, addr: $addr",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003036 [(X86ehret GR32:$addr)]>;
3037
3038}
3039
3040//===----------------------------------------------------------------------===//
Andrew Lenharthe44f3902008-02-21 06:45:13 +00003041// Atomic support
3042//
Andrew Lenharth7a5a4b22008-03-01 13:37:02 +00003043
Evan Cheng3e171562008-04-19 01:20:30 +00003044// Atomic swap. These are just normal xchg instructions. But since a memory
3045// operand is referenced, the atomicity is ensured.
Dan Gohmana41a1c092008-08-06 15:52:50 +00003046let Constraints = "$val = $dst" in {
Evan Cheng3e171562008-04-19 01:20:30 +00003047def XCHG32rm : I<0x87, MRMSrcMem, (outs GR32:$dst), (ins i32mem:$ptr, GR32:$val),
3048 "xchg{l}\t{$val, $ptr|$ptr, $val}",
3049 [(set GR32:$dst, (atomic_swap_32 addr:$ptr, GR32:$val))]>;
3050def XCHG16rm : I<0x87, MRMSrcMem, (outs GR16:$dst), (ins i16mem:$ptr, GR16:$val),
3051 "xchg{w}\t{$val, $ptr|$ptr, $val}",
3052 [(set GR16:$dst, (atomic_swap_16 addr:$ptr, GR16:$val))]>,
3053 OpSize;
3054def XCHG8rm : I<0x86, MRMSrcMem, (outs GR8:$dst), (ins i8mem:$ptr, GR8:$val),
3055 "xchg{b}\t{$val, $ptr|$ptr, $val}",
3056 [(set GR8:$dst, (atomic_swap_8 addr:$ptr, GR8:$val))]>;
3057}
3058
Evan Chengd49dbb82008-04-18 20:55:36 +00003059// Atomic compare and swap.
Andrew Lenharth7dfe23f2008-03-01 21:52:34 +00003060let Defs = [EAX, EFLAGS], Uses = [EAX] in {
Evan Chengd49dbb82008-04-18 20:55:36 +00003061def LCMPXCHG32 : I<0xB1, MRMDestMem, (outs), (ins i32mem:$ptr, GR32:$swap),
Dale Johannesend20e4452008-08-19 18:47:28 +00003062 "lock\n\tcmpxchg{l}\t{$swap, $ptr|$ptr, $swap}",
Evan Cheng09fbdee2008-03-04 03:20:06 +00003063 [(X86cas addr:$ptr, GR32:$swap, 4)]>, TB, LOCK;
Andrew Lenharth7a5a4b22008-03-01 13:37:02 +00003064}
Dale Johannesenf160d802008-10-02 18:53:47 +00003065let Defs = [EAX, EDX, EFLAGS], Uses = [EAX, EBX, ECX, EDX] in {
Anton Korobeynikovc4067392008-07-22 16:22:48 +00003066def LCMPXCHG8B : I<0xC7, MRM1m, (outs), (ins i32mem:$ptr),
Dale Johannesend20e4452008-08-19 18:47:28 +00003067 "lock\n\tcmpxchg8b\t$ptr",
Andrew Lenharth81580822008-03-05 01:15:49 +00003068 [(X86cas8 addr:$ptr)]>, TB, LOCK;
3069}
Andrew Lenharth7dfe23f2008-03-01 21:52:34 +00003070
3071let Defs = [AX, EFLAGS], Uses = [AX] in {
Evan Chengd49dbb82008-04-18 20:55:36 +00003072def LCMPXCHG16 : I<0xB1, MRMDestMem, (outs), (ins i16mem:$ptr, GR16:$swap),
Dale Johannesend20e4452008-08-19 18:47:28 +00003073 "lock\n\tcmpxchg{w}\t{$swap, $ptr|$ptr, $swap}",
Evan Cheng09fbdee2008-03-04 03:20:06 +00003074 [(X86cas addr:$ptr, GR16:$swap, 2)]>, TB, OpSize, LOCK;
Andrew Lenharth7a5a4b22008-03-01 13:37:02 +00003075}
Andrew Lenharth7dfe23f2008-03-01 21:52:34 +00003076let Defs = [AL, EFLAGS], Uses = [AL] in {
Evan Chengd49dbb82008-04-18 20:55:36 +00003077def LCMPXCHG8 : I<0xB0, MRMDestMem, (outs), (ins i8mem:$ptr, GR8:$swap),
Dale Johannesend20e4452008-08-19 18:47:28 +00003078 "lock\n\tcmpxchg{b}\t{$swap, $ptr|$ptr, $swap}",
Evan Cheng09fbdee2008-03-04 03:20:06 +00003079 [(X86cas addr:$ptr, GR8:$swap, 1)]>, TB, LOCK;
Andrew Lenharth7a5a4b22008-03-01 13:37:02 +00003080}
3081
Evan Chengd49dbb82008-04-18 20:55:36 +00003082// Atomic exchange and add
3083let Constraints = "$val = $dst", Defs = [EFLAGS] in {
3084def LXADD32 : I<0xC1, MRMSrcMem, (outs GR32:$dst), (ins i32mem:$ptr, GR32:$val),
Dale Johannesend20e4452008-08-19 18:47:28 +00003085 "lock\n\txadd{l}\t{$val, $ptr|$ptr, $val}",
Mon P Wang6bde9ec2008-06-25 08:15:39 +00003086 [(set GR32:$dst, (atomic_load_add_32 addr:$ptr, GR32:$val))]>,
Evan Chengd49dbb82008-04-18 20:55:36 +00003087 TB, LOCK;
3088def LXADD16 : I<0xC1, MRMSrcMem, (outs GR16:$dst), (ins i16mem:$ptr, GR16:$val),
Dale Johannesend20e4452008-08-19 18:47:28 +00003089 "lock\n\txadd{w}\t{$val, $ptr|$ptr, $val}",
Mon P Wang6bde9ec2008-06-25 08:15:39 +00003090 [(set GR16:$dst, (atomic_load_add_16 addr:$ptr, GR16:$val))]>,
Evan Chengd49dbb82008-04-18 20:55:36 +00003091 TB, OpSize, LOCK;
3092def LXADD8 : I<0xC0, MRMSrcMem, (outs GR8:$dst), (ins i8mem:$ptr, GR8:$val),
Dale Johannesend20e4452008-08-19 18:47:28 +00003093 "lock\n\txadd{b}\t{$val, $ptr|$ptr, $val}",
Mon P Wang6bde9ec2008-06-25 08:15:39 +00003094 [(set GR8:$dst, (atomic_load_add_8 addr:$ptr, GR8:$val))]>,
Evan Chengd49dbb82008-04-18 20:55:36 +00003095 TB, LOCK;
Andrew Lenharth7a5a4b22008-03-01 13:37:02 +00003096}
3097
Mon P Wang6bde9ec2008-06-25 08:15:39 +00003098// Atomic exchange, and, or, xor
Mon P Wang078a62d2008-05-05 19:05:59 +00003099let Constraints = "$val = $dst", Defs = [EFLAGS],
3100 usesCustomDAGSchedInserter = 1 in {
Dan Gohman8aeb61f2008-05-12 20:22:45 +00003101def ATOMAND32 : I<0, Pseudo, (outs GR32:$dst),(ins i32mem:$ptr, GR32:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003102 "#ATOMAND32 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003103 [(set GR32:$dst, (atomic_load_and_32 addr:$ptr, GR32:$val))]>;
Dan Gohman8aeb61f2008-05-12 20:22:45 +00003104def ATOMOR32 : I<0, Pseudo, (outs GR32:$dst),(ins i32mem:$ptr, GR32:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003105 "#ATOMOR32 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003106 [(set GR32:$dst, (atomic_load_or_32 addr:$ptr, GR32:$val))]>;
Dan Gohman8aeb61f2008-05-12 20:22:45 +00003107def ATOMXOR32 : I<0, Pseudo,(outs GR32:$dst),(ins i32mem:$ptr, GR32:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003108 "#ATOMXOR32 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003109 [(set GR32:$dst, (atomic_load_xor_32 addr:$ptr, GR32:$val))]>;
Andrew Lenharthaf02d592008-06-14 05:48:15 +00003110def ATOMNAND32 : I<0, Pseudo,(outs GR32:$dst),(ins i32mem:$ptr, GR32:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003111 "#ATOMNAND32 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003112 [(set GR32:$dst, (atomic_load_nand_32 addr:$ptr, GR32:$val))]>;
Dan Gohman8aeb61f2008-05-12 20:22:45 +00003113def ATOMMIN32: I<0, Pseudo, (outs GR32:$dst), (ins i32mem:$ptr, GR32:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003114 "#ATOMMIN32 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003115 [(set GR32:$dst, (atomic_load_min_32 addr:$ptr, GR32:$val))]>;
Dan Gohman8aeb61f2008-05-12 20:22:45 +00003116def ATOMMAX32: I<0, Pseudo, (outs GR32:$dst),(ins i32mem:$ptr, GR32:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003117 "#ATOMMAX32 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003118 [(set GR32:$dst, (atomic_load_max_32 addr:$ptr, GR32:$val))]>;
Dan Gohman8aeb61f2008-05-12 20:22:45 +00003119def ATOMUMIN32: I<0, Pseudo, (outs GR32:$dst),(ins i32mem:$ptr, GR32:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003120 "#ATOMUMIN32 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003121 [(set GR32:$dst, (atomic_load_umin_32 addr:$ptr, GR32:$val))]>;
Dan Gohman8aeb61f2008-05-12 20:22:45 +00003122def ATOMUMAX32: I<0, Pseudo, (outs GR32:$dst),(ins i32mem:$ptr, GR32:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003123 "#ATOMUMAX32 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003124 [(set GR32:$dst, (atomic_load_umax_32 addr:$ptr, GR32:$val))]>;
Dale Johannesend20e4452008-08-19 18:47:28 +00003125
3126def ATOMAND16 : I<0, Pseudo, (outs GR16:$dst),(ins i16mem:$ptr, GR16:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003127 "#ATOMAND16 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003128 [(set GR16:$dst, (atomic_load_and_16 addr:$ptr, GR16:$val))]>;
Dale Johannesend20e4452008-08-19 18:47:28 +00003129def ATOMOR16 : I<0, Pseudo, (outs GR16:$dst),(ins i16mem:$ptr, GR16:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003130 "#ATOMOR16 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003131 [(set GR16:$dst, (atomic_load_or_16 addr:$ptr, GR16:$val))]>;
Dale Johannesend20e4452008-08-19 18:47:28 +00003132def ATOMXOR16 : I<0, Pseudo,(outs GR16:$dst),(ins i16mem:$ptr, GR16:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003133 "#ATOMXOR16 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003134 [(set GR16:$dst, (atomic_load_xor_16 addr:$ptr, GR16:$val))]>;
Dale Johannesend20e4452008-08-19 18:47:28 +00003135def ATOMNAND16 : I<0, Pseudo,(outs GR16:$dst),(ins i16mem:$ptr, GR16:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003136 "#ATOMNAND16 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003137 [(set GR16:$dst, (atomic_load_nand_16 addr:$ptr, GR16:$val))]>;
Dale Johannesend20e4452008-08-19 18:47:28 +00003138def ATOMMIN16: I<0, Pseudo, (outs GR16:$dst), (ins i16mem:$ptr, GR16:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003139 "#ATOMMIN16 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003140 [(set GR16:$dst, (atomic_load_min_16 addr:$ptr, GR16:$val))]>;
Dale Johannesend20e4452008-08-19 18:47:28 +00003141def ATOMMAX16: I<0, Pseudo, (outs GR16:$dst),(ins i16mem:$ptr, GR16:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003142 "#ATOMMAX16 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003143 [(set GR16:$dst, (atomic_load_max_16 addr:$ptr, GR16:$val))]>;
Dale Johannesend20e4452008-08-19 18:47:28 +00003144def ATOMUMIN16: I<0, Pseudo, (outs GR16:$dst),(ins i16mem:$ptr, GR16:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003145 "#ATOMUMIN16 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003146 [(set GR16:$dst, (atomic_load_umin_16 addr:$ptr, GR16:$val))]>;
Dale Johannesend20e4452008-08-19 18:47:28 +00003147def ATOMUMAX16: I<0, Pseudo, (outs GR16:$dst),(ins i16mem:$ptr, GR16:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003148 "#ATOMUMAX16 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003149 [(set GR16:$dst, (atomic_load_umax_16 addr:$ptr, GR16:$val))]>;
Dale Johannesend20e4452008-08-19 18:47:28 +00003150
3151def ATOMAND8 : I<0, Pseudo, (outs GR8:$dst),(ins i8mem:$ptr, GR8:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003152 "#ATOMAND8 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003153 [(set GR8:$dst, (atomic_load_and_8 addr:$ptr, GR8:$val))]>;
Dale Johannesend20e4452008-08-19 18:47:28 +00003154def ATOMOR8 : I<0, Pseudo, (outs GR8:$dst),(ins i8mem:$ptr, GR8:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003155 "#ATOMOR8 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003156 [(set GR8:$dst, (atomic_load_or_8 addr:$ptr, GR8:$val))]>;
Dale Johannesend20e4452008-08-19 18:47:28 +00003157def ATOMXOR8 : I<0, Pseudo,(outs GR8:$dst),(ins i8mem:$ptr, GR8:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003158 "#ATOMXOR8 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003159 [(set GR8:$dst, (atomic_load_xor_8 addr:$ptr, GR8:$val))]>;
Dale Johannesend20e4452008-08-19 18:47:28 +00003160def ATOMNAND8 : I<0, Pseudo,(outs GR8:$dst),(ins i8mem:$ptr, GR8:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003161 "#ATOMNAND8 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003162 [(set GR8:$dst, (atomic_load_nand_8 addr:$ptr, GR8:$val))]>;
Mon P Wang078a62d2008-05-05 19:05:59 +00003163}
3164
Dale Johannesenf160d802008-10-02 18:53:47 +00003165let Constraints = "$val1 = $dst1, $val2 = $dst2",
3166 Defs = [EFLAGS, EAX, EBX, ECX, EDX],
3167 Uses = [EAX, EBX, ECX, EDX],
Dale Johannesen44eb5372008-10-03 19:41:08 +00003168 mayLoad = 1, mayStore = 1,
Dale Johannesenf160d802008-10-02 18:53:47 +00003169 usesCustomDAGSchedInserter = 1 in {
3170def ATOMAND6432 : I<0, Pseudo, (outs GR32:$dst1, GR32:$dst2),
3171 (ins i64mem:$ptr, GR32:$val1, GR32:$val2),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003172 "#ATOMAND6432 PSEUDO!", []>;
Dale Johannesenf160d802008-10-02 18:53:47 +00003173def ATOMOR6432 : I<0, Pseudo, (outs GR32:$dst1, GR32:$dst2),
3174 (ins i64mem:$ptr, GR32:$val1, GR32:$val2),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003175 "#ATOMOR6432 PSEUDO!", []>;
Dale Johannesenf160d802008-10-02 18:53:47 +00003176def ATOMXOR6432 : I<0, Pseudo, (outs GR32:$dst1, GR32:$dst2),
3177 (ins i64mem:$ptr, GR32:$val1, GR32:$val2),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003178 "#ATOMXOR6432 PSEUDO!", []>;
Dale Johannesenf160d802008-10-02 18:53:47 +00003179def ATOMNAND6432 : I<0, Pseudo, (outs GR32:$dst1, GR32:$dst2),
3180 (ins i64mem:$ptr, GR32:$val1, GR32:$val2),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003181 "#ATOMNAND6432 PSEUDO!", []>;
Dale Johannesenf160d802008-10-02 18:53:47 +00003182def ATOMADD6432 : I<0, Pseudo, (outs GR32:$dst1, GR32:$dst2),
3183 (ins i64mem:$ptr, GR32:$val1, GR32:$val2),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003184 "#ATOMADD6432 PSEUDO!", []>;
Dale Johannesenf160d802008-10-02 18:53:47 +00003185def ATOMSUB6432 : I<0, Pseudo, (outs GR32:$dst1, GR32:$dst2),
3186 (ins i64mem:$ptr, GR32:$val1, GR32:$val2),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003187 "#ATOMSUB6432 PSEUDO!", []>;
Dale Johannesen51c58ee2008-10-03 22:25:52 +00003188def ATOMSWAP6432 : I<0, Pseudo, (outs GR32:$dst1, GR32:$dst2),
3189 (ins i64mem:$ptr, GR32:$val1, GR32:$val2),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003190 "#ATOMSWAP6432 PSEUDO!", []>;
Dale Johannesenf160d802008-10-02 18:53:47 +00003191}
3192
Andrew Lenharthe44f3902008-02-21 06:45:13 +00003193//===----------------------------------------------------------------------===//
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003194// Non-Instruction Patterns
3195//===----------------------------------------------------------------------===//
3196
Bill Wendlingfef06052008-09-16 21:48:12 +00003197// ConstantPool GlobalAddress, ExternalSymbol, and JumpTable
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003198def : Pat<(i32 (X86Wrapper tconstpool :$dst)), (MOV32ri tconstpool :$dst)>;
3199def : Pat<(i32 (X86Wrapper tjumptable :$dst)), (MOV32ri tjumptable :$dst)>;
Nate Begemanb52948972008-04-12 00:47:57 +00003200def : Pat<(i32 (X86Wrapper tglobaltlsaddr:$dst)),(MOV32ri tglobaltlsaddr:$dst)>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003201def : Pat<(i32 (X86Wrapper tglobaladdr :$dst)), (MOV32ri tglobaladdr :$dst)>;
3202def : Pat<(i32 (X86Wrapper texternalsym:$dst)), (MOV32ri texternalsym:$dst)>;
3203
3204def : Pat<(add GR32:$src1, (X86Wrapper tconstpool:$src2)),
3205 (ADD32ri GR32:$src1, tconstpool:$src2)>;
3206def : Pat<(add GR32:$src1, (X86Wrapper tjumptable:$src2)),
3207 (ADD32ri GR32:$src1, tjumptable:$src2)>;
3208def : Pat<(add GR32:$src1, (X86Wrapper tglobaladdr :$src2)),
3209 (ADD32ri GR32:$src1, tglobaladdr:$src2)>;
3210def : Pat<(add GR32:$src1, (X86Wrapper texternalsym:$src2)),
3211 (ADD32ri GR32:$src1, texternalsym:$src2)>;
3212
3213def : Pat<(store (i32 (X86Wrapper tglobaladdr:$src)), addr:$dst),
3214 (MOV32mi addr:$dst, tglobaladdr:$src)>;
3215def : Pat<(store (i32 (X86Wrapper texternalsym:$src)), addr:$dst),
3216 (MOV32mi addr:$dst, texternalsym:$src)>;
3217
3218// Calls
Arnold Schwaighofere2d6bbb2007-10-11 19:40:01 +00003219// tailcall stuff
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003220def : Pat<(X86tailcall GR32:$dst),
Arnold Schwaighofere2d6bbb2007-10-11 19:40:01 +00003221 (TAILCALL)>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003222
3223def : Pat<(X86tailcall (i32 tglobaladdr:$dst)),
Arnold Schwaighofere2d6bbb2007-10-11 19:40:01 +00003224 (TAILCALL)>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003225def : Pat<(X86tailcall (i32 texternalsym:$dst)),
Arnold Schwaighofere2d6bbb2007-10-11 19:40:01 +00003226 (TAILCALL)>;
3227
3228def : Pat<(X86tcret GR32:$dst, imm:$off),
3229 (TCRETURNri GR32:$dst, imm:$off)>;
3230
3231def : Pat<(X86tcret (i32 tglobaladdr:$dst), imm:$off),
3232 (TCRETURNdi texternalsym:$dst, imm:$off)>;
3233
3234def : Pat<(X86tcret (i32 texternalsym:$dst), imm:$off),
3235 (TCRETURNdi texternalsym:$dst, imm:$off)>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003236
3237def : Pat<(X86call (i32 tglobaladdr:$dst)),
3238 (CALLpcrel32 tglobaladdr:$dst)>;
3239def : Pat<(X86call (i32 texternalsym:$dst)),
3240 (CALLpcrel32 texternalsym:$dst)>;
3241
3242// X86 specific add which produces a flag.
3243def : Pat<(addc GR32:$src1, GR32:$src2),
3244 (ADD32rr GR32:$src1, GR32:$src2)>;
3245def : Pat<(addc GR32:$src1, (load addr:$src2)),
3246 (ADD32rm GR32:$src1, addr:$src2)>;
3247def : Pat<(addc GR32:$src1, imm:$src2),
3248 (ADD32ri GR32:$src1, imm:$src2)>;
3249def : Pat<(addc GR32:$src1, i32immSExt8:$src2),
3250 (ADD32ri8 GR32:$src1, i32immSExt8:$src2)>;
3251
3252def : Pat<(subc GR32:$src1, GR32:$src2),
3253 (SUB32rr GR32:$src1, GR32:$src2)>;
3254def : Pat<(subc GR32:$src1, (load addr:$src2)),
3255 (SUB32rm GR32:$src1, addr:$src2)>;
3256def : Pat<(subc GR32:$src1, imm:$src2),
3257 (SUB32ri GR32:$src1, imm:$src2)>;
3258def : Pat<(subc GR32:$src1, i32immSExt8:$src2),
3259 (SUB32ri8 GR32:$src1, i32immSExt8:$src2)>;
3260
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003261// Comparisons.
3262
3263// TEST R,R is smaller than CMP R,0
Evan Cheng621216e2007-09-29 00:00:36 +00003264def : Pat<(parallel (X86cmp GR8:$src1, 0), (implicit EFLAGS)),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003265 (TEST8rr GR8:$src1, GR8:$src1)>;
Evan Cheng621216e2007-09-29 00:00:36 +00003266def : Pat<(parallel (X86cmp GR16:$src1, 0), (implicit EFLAGS)),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003267 (TEST16rr GR16:$src1, GR16:$src1)>;
Evan Cheng621216e2007-09-29 00:00:36 +00003268def : Pat<(parallel (X86cmp GR32:$src1, 0), (implicit EFLAGS)),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003269 (TEST32rr GR32:$src1, GR32:$src1)>;
3270
Duncan Sands082524c2008-01-23 20:39:46 +00003271// zextload bool -> zextload byte
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003272def : Pat<(zextloadi8i1 addr:$src), (MOV8rm addr:$src)>;
3273def : Pat<(zextloadi16i1 addr:$src), (MOVZX16rm8 addr:$src)>;
3274def : Pat<(zextloadi32i1 addr:$src), (MOVZX32rm8 addr:$src)>;
3275
3276// extload bool -> extload byte
3277def : Pat<(extloadi8i1 addr:$src), (MOV8rm addr:$src)>;
Bill Wendlingce1c5c12008-08-22 20:51:05 +00003278def : Pat<(extloadi16i1 addr:$src), (MOVZX16rm8 addr:$src)>,
3279 Requires<[In32BitMode]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003280def : Pat<(extloadi32i1 addr:$src), (MOVZX32rm8 addr:$src)>;
Bill Wendlingce1c5c12008-08-22 20:51:05 +00003281def : Pat<(extloadi16i8 addr:$src), (MOVZX16rm8 addr:$src)>,
3282 Requires<[In32BitMode]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003283def : Pat<(extloadi32i8 addr:$src), (MOVZX32rm8 addr:$src)>;
3284def : Pat<(extloadi32i16 addr:$src), (MOVZX32rm16 addr:$src)>;
3285
Dan Gohmandd612bb2008-08-20 21:27:32 +00003286// anyext
Bill Wendlingce1c5c12008-08-22 20:51:05 +00003287def : Pat<(i16 (anyext GR8 :$src)), (MOVZX16rr8 GR8 :$src)>,
3288 Requires<[In32BitMode]>;
3289def : Pat<(i32 (anyext GR8 :$src)), (MOVZX32rr8 GR8 :$src)>,
3290 Requires<[In32BitMode]>;
Dan Gohmandd612bb2008-08-20 21:27:32 +00003291def : Pat<(i32 (anyext GR16:$src)),
3292 (INSERT_SUBREG (i32 (IMPLICIT_DEF)), GR16:$src, x86_subreg_16bit)>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003293
Evan Chengf2abee72007-12-13 00:43:27 +00003294// (and (i32 load), 255) -> (zextload i8)
Evan Cheng1e5e5452008-09-29 17:26:18 +00003295def : Pat<(i32 (and (nvloadi32 addr:$src), (i32 255))),
3296 (MOVZX32rm8 addr:$src)>;
3297def : Pat<(i32 (and (nvloadi32 addr:$src), (i32 65535))),
3298 (MOVZX32rm16 addr:$src)>;
Evan Chengf2abee72007-12-13 00:43:27 +00003299
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003300//===----------------------------------------------------------------------===//
3301// Some peepholes
3302//===----------------------------------------------------------------------===//
3303
Dan Gohman5a5e6e92008-10-17 01:33:43 +00003304// Odd encoding trick: -128 fits into an 8-bit immediate field while
3305// +128 doesn't, so in this special case use a sub instead of an add.
3306def : Pat<(add GR16:$src1, 128),
3307 (SUB16ri8 GR16:$src1, -128)>;
3308def : Pat<(store (add (loadi16 addr:$dst), 128), addr:$dst),
3309 (SUB16mi8 addr:$dst, -128)>;
3310def : Pat<(add GR32:$src1, 128),
3311 (SUB32ri8 GR32:$src1, -128)>;
3312def : Pat<(store (add (loadi32 addr:$dst), 128), addr:$dst),
3313 (SUB32mi8 addr:$dst, -128)>;
3314
Dan Gohman9203ab42008-07-30 18:09:17 +00003315// r & (2^16-1) ==> movz
3316def : Pat<(and GR32:$src1, 0xffff),
Dan Gohmandd612bb2008-08-20 21:27:32 +00003317 (MOVZX32rr16 (i16 (EXTRACT_SUBREG GR32:$src1, x86_subreg_16bit)))>;
Dan Gohman5beb1ff2008-08-06 18:27:21 +00003318// r & (2^8-1) ==> movz
3319def : Pat<(and GR32:$src1, 0xff),
Dan Gohmandd612bb2008-08-20 21:27:32 +00003320 (MOVZX32rr8 (i8 (EXTRACT_SUBREG (MOV32to32_ GR32:$src1),
3321 x86_subreg_8bit)))>,
Dan Gohman5beb1ff2008-08-06 18:27:21 +00003322 Requires<[In32BitMode]>;
3323// r & (2^8-1) ==> movz
3324def : Pat<(and GR16:$src1, 0xff),
Dan Gohmandd612bb2008-08-20 21:27:32 +00003325 (MOVZX16rr8 (i8 (EXTRACT_SUBREG (MOV16to16_ GR16:$src1),
3326 x86_subreg_8bit)))>,
3327 Requires<[In32BitMode]>;
3328
3329// sext_inreg patterns
3330def : Pat<(sext_inreg GR32:$src, i16),
3331 (MOVSX32rr16 (i16 (EXTRACT_SUBREG GR32:$src, x86_subreg_16bit)))>;
3332def : Pat<(sext_inreg GR32:$src, i8),
3333 (MOVSX32rr8 (i8 (EXTRACT_SUBREG (MOV32to32_ GR32:$src),
3334 x86_subreg_8bit)))>,
3335 Requires<[In32BitMode]>;
3336def : Pat<(sext_inreg GR16:$src, i8),
3337 (MOVSX16rr8 (i8 (EXTRACT_SUBREG (MOV16to16_ GR16:$src),
3338 x86_subreg_8bit)))>,
3339 Requires<[In32BitMode]>;
3340
3341// trunc patterns
3342def : Pat<(i16 (trunc GR32:$src)),
3343 (i16 (EXTRACT_SUBREG GR32:$src, x86_subreg_16bit))>;
3344def : Pat<(i8 (trunc GR32:$src)),
3345 (i8 (EXTRACT_SUBREG (MOV32to32_ GR32:$src), x86_subreg_8bit))>,
3346 Requires<[In32BitMode]>;
3347def : Pat<(i8 (trunc GR16:$src)),
3348 (i8 (EXTRACT_SUBREG (MOV16to16_ GR16:$src), x86_subreg_8bit))>,
Dan Gohman5beb1ff2008-08-06 18:27:21 +00003349 Requires<[In32BitMode]>;
Dan Gohman9203ab42008-07-30 18:09:17 +00003350
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003351// (shl x, 1) ==> (add x, x)
3352def : Pat<(shl GR8 :$src1, (i8 1)), (ADD8rr GR8 :$src1, GR8 :$src1)>;
3353def : Pat<(shl GR16:$src1, (i8 1)), (ADD16rr GR16:$src1, GR16:$src1)>;
3354def : Pat<(shl GR32:$src1, (i8 1)), (ADD32rr GR32:$src1, GR32:$src1)>;
3355
Evan Cheng76a64c72008-08-30 02:03:58 +00003356// (shl x (and y, 31)) ==> (shl x, y)
3357def : Pat<(shl GR8:$src1, (and CL:$amt, 31)),
3358 (SHL8rCL GR8:$src1)>;
3359def : Pat<(shl GR16:$src1, (and CL:$amt, 31)),
3360 (SHL16rCL GR16:$src1)>;
3361def : Pat<(shl GR32:$src1, (and CL:$amt, 31)),
3362 (SHL32rCL GR32:$src1)>;
3363def : Pat<(store (shl (loadi8 addr:$dst), (and CL:$amt, 31)), addr:$dst),
3364 (SHL8mCL addr:$dst)>;
3365def : Pat<(store (shl (loadi16 addr:$dst), (and CL:$amt, 31)), addr:$dst),
3366 (SHL16mCL addr:$dst)>;
3367def : Pat<(store (shl (loadi32 addr:$dst), (and CL:$amt, 31)), addr:$dst),
3368 (SHL32mCL addr:$dst)>;
3369
3370def : Pat<(srl GR8:$src1, (and CL:$amt, 31)),
3371 (SHR8rCL GR8:$src1)>;
3372def : Pat<(srl GR16:$src1, (and CL:$amt, 31)),
3373 (SHR16rCL GR16:$src1)>;
3374def : Pat<(srl GR32:$src1, (and CL:$amt, 31)),
3375 (SHR32rCL GR32:$src1)>;
3376def : Pat<(store (srl (loadi8 addr:$dst), (and CL:$amt, 31)), addr:$dst),
3377 (SHR8mCL addr:$dst)>;
3378def : Pat<(store (srl (loadi16 addr:$dst), (and CL:$amt, 31)), addr:$dst),
3379 (SHR16mCL addr:$dst)>;
3380def : Pat<(store (srl (loadi32 addr:$dst), (and CL:$amt, 31)), addr:$dst),
3381 (SHR32mCL addr:$dst)>;
3382
3383def : Pat<(sra GR8:$src1, (and CL:$amt, 31)),
3384 (SAR8rCL GR8:$src1)>;
3385def : Pat<(sra GR16:$src1, (and CL:$amt, 31)),
3386 (SAR16rCL GR16:$src1)>;
3387def : Pat<(sra GR32:$src1, (and CL:$amt, 31)),
3388 (SAR32rCL GR32:$src1)>;
3389def : Pat<(store (sra (loadi8 addr:$dst), (and CL:$amt, 31)), addr:$dst),
3390 (SAR8mCL addr:$dst)>;
3391def : Pat<(store (sra (loadi16 addr:$dst), (and CL:$amt, 31)), addr:$dst),
3392 (SAR16mCL addr:$dst)>;
3393def : Pat<(store (sra (loadi32 addr:$dst), (and CL:$amt, 31)), addr:$dst),
3394 (SAR32mCL addr:$dst)>;
3395
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003396// (or (x >> c) | (y << (32 - c))) ==> (shrd32 x, y, c)
3397def : Pat<(or (srl GR32:$src1, CL:$amt),
3398 (shl GR32:$src2, (sub 32, CL:$amt))),
3399 (SHRD32rrCL GR32:$src1, GR32:$src2)>;
3400
3401def : Pat<(store (or (srl (loadi32 addr:$dst), CL:$amt),
3402 (shl GR32:$src2, (sub 32, CL:$amt))), addr:$dst),
3403 (SHRD32mrCL addr:$dst, GR32:$src2)>;
3404
Dan Gohman921581d2008-10-17 01:23:35 +00003405def : Pat<(or (srl GR32:$src1, (i8 (trunc ECX:$amt))),
3406 (shl GR32:$src2, (i8 (trunc (sub 32, ECX:$amt))))),
3407 (SHRD32rrCL GR32:$src1, GR32:$src2)>;
3408
3409def : Pat<(store (or (srl (loadi32 addr:$dst), (i8 (trunc ECX:$amt))),
3410 (shl GR32:$src2, (i8 (trunc (sub 32, ECX:$amt))))),
3411 addr:$dst),
3412 (SHRD32mrCL addr:$dst, GR32:$src2)>;
3413
3414def : Pat<(shrd GR32:$src1, (i8 imm:$amt1), GR32:$src2, (i8 imm:$amt2)),
3415 (SHRD32rri8 GR32:$src1, GR32:$src2, (i8 imm:$amt1))>;
3416
3417def : Pat<(store (shrd (loadi32 addr:$dst), (i8 imm:$amt1),
3418 GR32:$src2, (i8 imm:$amt2)), addr:$dst),
3419 (SHRD32mri8 addr:$dst, GR32:$src2, (i8 imm:$amt1))>;
3420
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003421// (or (x << c) | (y >> (32 - c))) ==> (shld32 x, y, c)
3422def : Pat<(or (shl GR32:$src1, CL:$amt),
3423 (srl GR32:$src2, (sub 32, CL:$amt))),
3424 (SHLD32rrCL GR32:$src1, GR32:$src2)>;
3425
3426def : Pat<(store (or (shl (loadi32 addr:$dst), CL:$amt),
3427 (srl GR32:$src2, (sub 32, CL:$amt))), addr:$dst),
3428 (SHLD32mrCL addr:$dst, GR32:$src2)>;
3429
Dan Gohman921581d2008-10-17 01:23:35 +00003430def : Pat<(or (shl GR32:$src1, (i8 (trunc ECX:$amt))),
3431 (srl GR32:$src2, (i8 (trunc (sub 32, ECX:$amt))))),
3432 (SHLD32rrCL GR32:$src1, GR32:$src2)>;
3433
3434def : Pat<(store (or (shl (loadi32 addr:$dst), (i8 (trunc ECX:$amt))),
3435 (srl GR32:$src2, (i8 (trunc (sub 32, ECX:$amt))))),
3436 addr:$dst),
3437 (SHLD32mrCL addr:$dst, GR32:$src2)>;
3438
3439def : Pat<(shld GR32:$src1, (i8 imm:$amt1), GR32:$src2, (i8 imm:$amt2)),
3440 (SHLD32rri8 GR32:$src1, GR32:$src2, (i8 imm:$amt1))>;
3441
3442def : Pat<(store (shld (loadi32 addr:$dst), (i8 imm:$amt1),
3443 GR32:$src2, (i8 imm:$amt2)), addr:$dst),
3444 (SHLD32mri8 addr:$dst, GR32:$src2, (i8 imm:$amt1))>;
3445
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003446// (or (x >> c) | (y << (16 - c))) ==> (shrd16 x, y, c)
3447def : Pat<(or (srl GR16:$src1, CL:$amt),
3448 (shl GR16:$src2, (sub 16, CL:$amt))),
3449 (SHRD16rrCL GR16:$src1, GR16:$src2)>;
3450
3451def : Pat<(store (or (srl (loadi16 addr:$dst), CL:$amt),
3452 (shl GR16:$src2, (sub 16, CL:$amt))), addr:$dst),
3453 (SHRD16mrCL addr:$dst, GR16:$src2)>;
3454
Dan Gohman921581d2008-10-17 01:23:35 +00003455def : Pat<(or (srl GR16:$src1, (i8 (trunc CX:$amt))),
3456 (shl GR16:$src2, (i8 (trunc (sub 16, CX:$amt))))),
3457 (SHRD16rrCL GR16:$src1, GR16:$src2)>;
3458
3459def : Pat<(store (or (srl (loadi16 addr:$dst), (i8 (trunc CX:$amt))),
3460 (shl GR16:$src2, (i8 (trunc (sub 16, CX:$amt))))),
3461 addr:$dst),
3462 (SHRD16mrCL addr:$dst, GR16:$src2)>;
3463
3464def : Pat<(shrd GR16:$src1, (i8 imm:$amt1), GR16:$src2, (i8 imm:$amt2)),
3465 (SHRD16rri8 GR16:$src1, GR16:$src2, (i8 imm:$amt1))>;
3466
3467def : Pat<(store (shrd (loadi16 addr:$dst), (i8 imm:$amt1),
3468 GR16:$src2, (i8 imm:$amt2)), addr:$dst),
3469 (SHRD16mri8 addr:$dst, GR16:$src2, (i8 imm:$amt1))>;
3470
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003471// (or (x << c) | (y >> (16 - c))) ==> (shld16 x, y, c)
3472def : Pat<(or (shl GR16:$src1, CL:$amt),
3473 (srl GR16:$src2, (sub 16, CL:$amt))),
3474 (SHLD16rrCL GR16:$src1, GR16:$src2)>;
3475
3476def : Pat<(store (or (shl (loadi16 addr:$dst), CL:$amt),
3477 (srl GR16:$src2, (sub 16, CL:$amt))), addr:$dst),
3478 (SHLD16mrCL addr:$dst, GR16:$src2)>;
3479
Dan Gohman921581d2008-10-17 01:23:35 +00003480def : Pat<(or (shl GR16:$src1, (i8 (trunc CX:$amt))),
3481 (srl GR16:$src2, (i8 (trunc (sub 16, CX:$amt))))),
3482 (SHLD16rrCL GR16:$src1, GR16:$src2)>;
3483
3484def : Pat<(store (or (shl (loadi16 addr:$dst), (i8 (trunc CX:$amt))),
3485 (srl GR16:$src2, (i8 (trunc (sub 16, CX:$amt))))),
3486 addr:$dst),
3487 (SHLD16mrCL addr:$dst, GR16:$src2)>;
3488
3489def : Pat<(shld GR16:$src1, (i8 imm:$amt1), GR16:$src2, (i8 imm:$amt2)),
3490 (SHLD16rri8 GR16:$src1, GR16:$src2, (i8 imm:$amt1))>;
3491
3492def : Pat<(store (shld (loadi16 addr:$dst), (i8 imm:$amt1),
3493 GR16:$src2, (i8 imm:$amt2)), addr:$dst),
3494 (SHLD16mri8 addr:$dst, GR16:$src2, (i8 imm:$amt1))>;
3495
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003496//===----------------------------------------------------------------------===//
3497// Floating Point Stack Support
3498//===----------------------------------------------------------------------===//
3499
3500include "X86InstrFPStack.td"
3501
3502//===----------------------------------------------------------------------===//
Evan Cheng86ab7d32007-07-31 08:04:03 +00003503// X86-64 Support
3504//===----------------------------------------------------------------------===//
3505
Chris Lattner2de8d2b2008-01-10 05:50:42 +00003506include "X86Instr64bit.td"
Evan Cheng86ab7d32007-07-31 08:04:03 +00003507
3508//===----------------------------------------------------------------------===//
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003509// XMM Floating point support (requires SSE / SSE2)
3510//===----------------------------------------------------------------------===//
3511
3512include "X86InstrSSE.td"
Evan Cheng5e4d1e72008-04-25 18:19:54 +00003513
3514//===----------------------------------------------------------------------===//
3515// MMX and XMM Packed Integer support (requires MMX, SSE, and SSE2)
3516//===----------------------------------------------------------------------===//
3517
3518include "X86InstrMMX.td"