blob: f9585b0810965724f120ba93fbee10c167b8aeae [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
Dan Gohman2ec42142009-03-04 03:54:19 +000030def SDTUnaryArithOvf : SDTypeProfile<1, 1,
31 [SDTCisInt<0>]>;
32def SDTBinaryArithOvf : SDTypeProfile<1, 2,
33 [SDTCisSameAs<0, 1>, SDTCisSameAs<0, 2>,
34 SDTCisInt<0>]>;
Bill Wendlingae034ed2008-12-12 00:56:36 +000035
Evan Cheng621216e2007-09-29 00:00:36 +000036def SDTX86BrCond : SDTypeProfile<0, 3,
Evan Cheng950aac02007-09-25 01:57:46 +000037 [SDTCisVT<0, OtherVT>,
38 SDTCisVT<1, i8>, SDTCisVT<2, i32>]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +000039
Evan Cheng621216e2007-09-29 00:00:36 +000040def SDTX86SetCC : SDTypeProfile<1, 2,
Evan Cheng950aac02007-09-25 01:57:46 +000041 [SDTCisVT<0, i8>,
42 SDTCisVT<1, i8>, SDTCisVT<2, i32>]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +000043
Andrew Lenharth7dfe23f2008-03-01 21:52:34 +000044def SDTX86cas : SDTypeProfile<0, 3, [SDTCisPtrTy<0>, SDTCisInt<1>,
45 SDTCisVT<2, i8>]>;
Andrew Lenharth81580822008-03-05 01:15:49 +000046def SDTX86cas8 : SDTypeProfile<0, 1, [SDTCisPtrTy<0>]>;
Andrew Lenharth7dfe23f2008-03-01 21:52:34 +000047
Dale Johannesenf160d802008-10-02 18:53:47 +000048def SDTX86atomicBinary : SDTypeProfile<2, 3, [SDTCisInt<0>, SDTCisInt<1>,
49 SDTCisPtrTy<2>, SDTCisInt<3>,SDTCisInt<4>]>;
Chris Lattnerb56cc342008-03-11 03:23:40 +000050def SDTX86Ret : SDTypeProfile<0, -1, [SDTCisVT<0, i16>]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +000051
Bill Wendling7173da52007-11-13 09:19:02 +000052def SDT_X86CallSeqStart : SDCallSeqStart<[ SDTCisVT<0, i32> ]>;
53def SDT_X86CallSeqEnd : SDCallSeqEnd<[ SDTCisVT<0, i32>,
54 SDTCisVT<1, i32> ]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +000055
Dan Gohman3329ffe2008-05-29 19:57:41 +000056def SDT_X86Call : SDTypeProfile<0, -1, [SDTCisVT<0, iPTR>]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +000057
58def SDTX86RepStr : SDTypeProfile<0, 1, [SDTCisVT<0, OtherVT>]>;
59
60def SDTX86RdTsc : SDTypeProfile<0, 0, []>;
61
62def SDTX86Wrapper : SDTypeProfile<1, 1, [SDTCisSameAs<0, 1>, SDTCisPtrTy<0>]>;
63
64def SDT_X86TLSADDR : SDTypeProfile<1, 1, [SDTCisPtrTy<0>, SDTCisInt<1>]>;
65
66def SDT_X86TLSTP : SDTypeProfile<1, 0, [SDTCisPtrTy<0>]>;
67
68def SDT_X86EHRET : SDTypeProfile<0, 1, [SDTCisInt<0>]>;
69
Arnold Schwaighofere2d6bbb2007-10-11 19:40:01 +000070def SDT_X86TCRET : SDTypeProfile<0, 2, [SDTCisPtrTy<0>, SDTCisVT<1, i32>]>;
71
Evan Cheng48679f42007-12-14 02:13:44 +000072def X86bsf : SDNode<"X86ISD::BSF", SDTIntUnaryOp>;
73def X86bsr : SDNode<"X86ISD::BSR", SDTIntUnaryOp>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +000074def X86shld : SDNode<"X86ISD::SHLD", SDTIntShiftDOp>;
75def X86shrd : SDNode<"X86ISD::SHRD", SDTIntShiftDOp>;
76
Evan Cheng621216e2007-09-29 00:00:36 +000077def X86cmp : SDNode<"X86ISD::CMP" , SDTX86CmpTest>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +000078
Dan Gohman7fe9b7f2008-12-23 22:45:23 +000079def X86bt : SDNode<"X86ISD::BT", SDTX86CmpTest>;
80
Evan Cheng621216e2007-09-29 00:00:36 +000081def X86cmov : SDNode<"X86ISD::CMOV", SDTX86Cmov>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +000082def X86brcond : SDNode<"X86ISD::BRCOND", SDTX86BrCond,
Evan Cheng950aac02007-09-25 01:57:46 +000083 [SDNPHasChain]>;
Evan Cheng621216e2007-09-29 00:00:36 +000084def X86setcc : SDNode<"X86ISD::SETCC", SDTX86SetCC>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +000085
Andrew Lenharth7dfe23f2008-03-01 21:52:34 +000086def X86cas : SDNode<"X86ISD::LCMPXCHG_DAG", SDTX86cas,
87 [SDNPHasChain, SDNPInFlag, SDNPOutFlag, SDNPMayStore,
88 SDNPMayLoad]>;
Andrew Lenharth81580822008-03-05 01:15:49 +000089def X86cas8 : SDNode<"X86ISD::LCMPXCHG8_DAG", SDTX86cas8,
90 [SDNPHasChain, SDNPInFlag, SDNPOutFlag, SDNPMayStore,
91 SDNPMayLoad]>;
Dale Johannesenf160d802008-10-02 18:53:47 +000092def X86AtomAdd64 : SDNode<"X86ISD::ATOMADD64_DAG", SDTX86atomicBinary,
93 [SDNPHasChain, SDNPMayStore,
94 SDNPMayLoad, SDNPMemOperand]>;
95def X86AtomSub64 : SDNode<"X86ISD::ATOMSUB64_DAG", SDTX86atomicBinary,
96 [SDNPHasChain, SDNPMayStore,
97 SDNPMayLoad, SDNPMemOperand]>;
98def X86AtomOr64 : SDNode<"X86ISD::ATOMOR64_DAG", SDTX86atomicBinary,
99 [SDNPHasChain, SDNPMayStore,
100 SDNPMayLoad, SDNPMemOperand]>;
101def X86AtomXor64 : SDNode<"X86ISD::ATOMXOR64_DAG", SDTX86atomicBinary,
102 [SDNPHasChain, SDNPMayStore,
103 SDNPMayLoad, SDNPMemOperand]>;
104def X86AtomAnd64 : SDNode<"X86ISD::ATOMAND64_DAG", SDTX86atomicBinary,
105 [SDNPHasChain, SDNPMayStore,
106 SDNPMayLoad, SDNPMemOperand]>;
107def X86AtomNand64 : SDNode<"X86ISD::ATOMNAND64_DAG", SDTX86atomicBinary,
108 [SDNPHasChain, SDNPMayStore,
109 SDNPMayLoad, SDNPMemOperand]>;
Dale Johannesen51c58ee2008-10-03 22:25:52 +0000110def X86AtomSwap64 : SDNode<"X86ISD::ATOMSWAP64_DAG", SDTX86atomicBinary,
111 [SDNPHasChain, SDNPMayStore,
112 SDNPMayLoad, SDNPMemOperand]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000113def X86retflag : SDNode<"X86ISD::RET_FLAG", SDTX86Ret,
114 [SDNPHasChain, SDNPOptInFlag]>;
115
116def X86callseq_start :
117 SDNode<"ISD::CALLSEQ_START", SDT_X86CallSeqStart,
118 [SDNPHasChain, SDNPOutFlag]>;
119def X86callseq_end :
120 SDNode<"ISD::CALLSEQ_END", SDT_X86CallSeqEnd,
Arnold Schwaighofere2d6bbb2007-10-11 19:40:01 +0000121 [SDNPHasChain, SDNPOptInFlag, SDNPOutFlag]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000122
123def X86call : SDNode<"X86ISD::CALL", SDT_X86Call,
124 [SDNPHasChain, SDNPOutFlag, SDNPOptInFlag]>;
125
126def X86tailcall: SDNode<"X86ISD::TAILCALL", SDT_X86Call,
127 [SDNPHasChain, SDNPOutFlag, SDNPOptInFlag]>;
128
129def X86rep_stos: SDNode<"X86ISD::REP_STOS", SDTX86RepStr,
Chris Lattnerca4e0fe2008-01-10 05:12:37 +0000130 [SDNPHasChain, SDNPInFlag, SDNPOutFlag, SDNPMayStore]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000131def X86rep_movs: SDNode<"X86ISD::REP_MOVS", SDTX86RepStr,
Chris Lattnerca4e0fe2008-01-10 05:12:37 +0000132 [SDNPHasChain, SDNPInFlag, SDNPOutFlag, SDNPMayStore,
133 SDNPMayLoad]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000134
135def X86rdtsc : SDNode<"X86ISD::RDTSC_DAG",SDTX86RdTsc,
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000136 [SDNPHasChain, SDNPOutFlag, SDNPSideEffect]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000137
138def X86Wrapper : SDNode<"X86ISD::Wrapper", SDTX86Wrapper>;
139def X86WrapperRIP : SDNode<"X86ISD::WrapperRIP", SDTX86Wrapper>;
140
141def X86tlsaddr : SDNode<"X86ISD::TLSADDR", SDT_X86TLSADDR,
Anton Korobeynikov4fbf00b2008-05-04 21:36:32 +0000142 [SDNPHasChain, SDNPOptInFlag, SDNPOutFlag]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000143def X86TLStp : SDNode<"X86ISD::THREAD_POINTER", SDT_X86TLSTP, []>;
144
145def X86ehret : SDNode<"X86ISD::EH_RETURN", SDT_X86EHRET,
146 [SDNPHasChain]>;
147
Arnold Schwaighofere2d6bbb2007-10-11 19:40:01 +0000148def X86tcret : SDNode<"X86ISD::TC_RETURN", SDT_X86TCRET,
149 [SDNPHasChain, SDNPOptInFlag]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000150
Dan Gohman2ec42142009-03-04 03:54:19 +0000151def X86add_ovf : SDNode<"X86ISD::ADD", SDTBinaryArithOvf>;
152def X86sub_ovf : SDNode<"X86ISD::SUB", SDTBinaryArithOvf>;
153def X86smul_ovf : SDNode<"X86ISD::SMUL", SDTBinaryArithOvf>;
154def X86umul_ovf : SDNode<"X86ISD::UMUL", SDTUnaryArithOvf>;
Bill Wendlingae034ed2008-12-12 00:56:36 +0000155
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000156//===----------------------------------------------------------------------===//
157// X86 Operand Definitions.
158//
159
160// *mem - Operand definitions for the funky X86 addressing mode operands.
161//
162class X86MemOperand<string printMethod> : Operand<iPTR> {
163 let PrintMethod = printMethod;
164 let MIOperandInfo = (ops ptr_rc, i8imm, ptr_rc, i32imm);
165}
166
167def i8mem : X86MemOperand<"printi8mem">;
168def i16mem : X86MemOperand<"printi16mem">;
169def i32mem : X86MemOperand<"printi32mem">;
170def i64mem : X86MemOperand<"printi64mem">;
171def i128mem : X86MemOperand<"printi128mem">;
172def f32mem : X86MemOperand<"printf32mem">;
173def f64mem : X86MemOperand<"printf64mem">;
Dale Johannesen4ab00bd2007-08-05 18:49:15 +0000174def f80mem : X86MemOperand<"printf80mem">;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000175def f128mem : X86MemOperand<"printf128mem">;
176
177def lea32mem : Operand<i32> {
178 let PrintMethod = "printi32mem";
179 let MIOperandInfo = (ops GR32, i8imm, GR32, i32imm);
180}
181
182def SSECC : Operand<i8> {
183 let PrintMethod = "printSSECC";
184}
185
186def piclabel: Operand<i32> {
187 let PrintMethod = "printPICLabel";
188}
189
190// A couple of more descriptive operand definitions.
191// 16-bits but only 8 bits are significant.
192def i16i8imm : Operand<i16>;
193// 32-bits but only 8 bits are significant.
194def i32i8imm : Operand<i32>;
195
196// Branch targets have OtherVT type.
197def brtarget : Operand<OtherVT>;
198
199//===----------------------------------------------------------------------===//
200// X86 Complex Pattern Definitions.
201//
202
203// Define X86 specific addressing mode.
204def addr : ComplexPattern<iPTR, 4, "SelectAddr", [], []>;
205def lea32addr : ComplexPattern<i32, 4, "SelectLEAAddr",
206 [add, mul, shl, or, frameindex], []>;
207
208//===----------------------------------------------------------------------===//
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000209// X86 Instruction Predicate Definitions.
210def HasMMX : Predicate<"Subtarget->hasMMX()">;
211def HasSSE1 : Predicate<"Subtarget->hasSSE1()">;
212def HasSSE2 : Predicate<"Subtarget->hasSSE2()">;
213def HasSSE3 : Predicate<"Subtarget->hasSSE3()">;
214def HasSSSE3 : Predicate<"Subtarget->hasSSSE3()">;
Nate Begemanb2975562008-02-03 07:18:54 +0000215def HasSSE41 : Predicate<"Subtarget->hasSSE41()">;
216def HasSSE42 : Predicate<"Subtarget->hasSSE42()">;
Dale Johannesene0e0fd02007-09-23 14:52:20 +0000217def FPStackf32 : Predicate<"!Subtarget->hasSSE1()">;
218def FPStackf64 : Predicate<"!Subtarget->hasSSE2()">;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000219def In32BitMode : Predicate<"!Subtarget->is64Bit()">;
220def In64BitMode : Predicate<"Subtarget->is64Bit()">;
221def SmallCode : Predicate<"TM.getCodeModel() == CodeModel::Small">;
222def NotSmallCode : Predicate<"TM.getCodeModel() != CodeModel::Small">;
223def IsStatic : Predicate<"TM.getRelocationModel() == Reloc::Static">;
Evan Cheng13559d62008-09-26 23:41:32 +0000224def OptForSpeed : Predicate<"!OptForSize">;
Evan Cheng95a77fd2009-01-02 05:35:45 +0000225def FastBTMem : Predicate<"!Subtarget->isBTMemSlow()">;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000226
227//===----------------------------------------------------------------------===//
Evan Cheng86ab7d32007-07-31 08:04:03 +0000228// X86 Instruction Format Definitions.
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000229//
230
Evan Cheng86ab7d32007-07-31 08:04:03 +0000231include "X86InstrFormats.td"
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000232
233//===----------------------------------------------------------------------===//
234// Pattern fragments...
235//
236
237// X86 specific condition code. These correspond to CondCode in
238// X86InstrInfo.h. They must be kept in synch.
Dan Gohman0fc9ed62009-01-07 00:15:08 +0000239def X86_COND_A : PatLeaf<(i8 0)>; // alt. COND_NBE
240def X86_COND_AE : PatLeaf<(i8 1)>; // alt. COND_NC
241def X86_COND_B : PatLeaf<(i8 2)>; // alt. COND_C
242def X86_COND_BE : PatLeaf<(i8 3)>; // alt. COND_NA
243def X86_COND_E : PatLeaf<(i8 4)>; // alt. COND_Z
244def X86_COND_G : PatLeaf<(i8 5)>; // alt. COND_NLE
245def X86_COND_GE : PatLeaf<(i8 6)>; // alt. COND_NL
246def X86_COND_L : PatLeaf<(i8 7)>; // alt. COND_NGE
247def X86_COND_LE : PatLeaf<(i8 8)>; // alt. COND_NG
248def X86_COND_NE : PatLeaf<(i8 9)>; // alt. COND_NZ
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000249def X86_COND_NO : PatLeaf<(i8 10)>;
Dan Gohman0fc9ed62009-01-07 00:15:08 +0000250def X86_COND_NP : PatLeaf<(i8 11)>; // alt. COND_PO
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000251def X86_COND_NS : PatLeaf<(i8 12)>;
Dan Gohman0fc9ed62009-01-07 00:15:08 +0000252def X86_COND_O : PatLeaf<(i8 13)>;
253def X86_COND_P : PatLeaf<(i8 14)>; // alt. COND_PE
254def X86_COND_S : PatLeaf<(i8 15)>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000255
256def i16immSExt8 : PatLeaf<(i16 imm), [{
257 // i16immSExt8 predicate - True if the 16-bit immediate fits in a 8-bit
258 // sign extended field.
Dan Gohmanfaeb4a32008-09-12 16:56:44 +0000259 return (int16_t)N->getZExtValue() == (int8_t)N->getZExtValue();
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000260}]>;
261
262def i32immSExt8 : PatLeaf<(i32 imm), [{
263 // i32immSExt8 predicate - True if the 32-bit immediate fits in a 8-bit
264 // sign extended field.
Dan Gohmanfaeb4a32008-09-12 16:56:44 +0000265 return (int32_t)N->getZExtValue() == (int8_t)N->getZExtValue();
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000266}]>;
267
268// Helper fragments for loads.
Evan Chengb3e25ea2008-05-13 18:59:59 +0000269// It's always safe to treat a anyext i16 load as a i32 load if the i16 is
270// known to be 32-bit aligned or better. Ditto for i8 to i16.
Dan Gohman2a174122008-10-15 06:50:19 +0000271def loadi16 : PatFrag<(ops node:$ptr), (i16 (unindexedload node:$ptr)), [{
Dan Gohman8335c412008-08-20 15:24:22 +0000272 LoadSDNode *LD = cast<LoadSDNode>(N);
Dan Gohman8335c412008-08-20 15:24:22 +0000273 ISD::LoadExtType ExtType = LD->getExtensionType();
274 if (ExtType == ISD::NON_EXTLOAD)
275 return true;
276 if (ExtType == ISD::EXTLOAD)
277 return LD->getAlignment() >= 2 && !LD->isVolatile();
Evan Cheng8b765e92008-05-13 00:54:02 +0000278 return false;
279}]>;
280
Dan Gohman2a174122008-10-15 06:50:19 +0000281def loadi16_anyext : PatFrag<(ops node:$ptr), (i32 (unindexedload node:$ptr)), [{
Evan Cheng56ec77b2008-09-24 23:27:55 +0000282 LoadSDNode *LD = cast<LoadSDNode>(N);
Evan Cheng56ec77b2008-09-24 23:27:55 +0000283 ISD::LoadExtType ExtType = LD->getExtensionType();
284 if (ExtType == ISD::EXTLOAD)
285 return LD->getAlignment() >= 2 && !LD->isVolatile();
286 return false;
287}]>;
288
Dan Gohman2a174122008-10-15 06:50:19 +0000289def loadi32 : PatFrag<(ops node:$ptr), (i32 (unindexedload node:$ptr)), [{
Dan Gohman8335c412008-08-20 15:24:22 +0000290 LoadSDNode *LD = cast<LoadSDNode>(N);
Dan Gohman8335c412008-08-20 15:24:22 +0000291 ISD::LoadExtType ExtType = LD->getExtensionType();
292 if (ExtType == ISD::NON_EXTLOAD)
293 return true;
294 if (ExtType == ISD::EXTLOAD)
295 return LD->getAlignment() >= 4 && !LD->isVolatile();
Evan Cheng8b765e92008-05-13 00:54:02 +0000296 return false;
297}]>;
298
Dan Gohman2a174122008-10-15 06:50:19 +0000299def nvloadi32 : PatFrag<(ops node:$ptr), (i32 (unindexedload node:$ptr)), [{
Evan Cheng1e5e5452008-09-29 17:26:18 +0000300 LoadSDNode *LD = cast<LoadSDNode>(N);
301 if (LD->isVolatile())
302 return false;
Evan Cheng1e5e5452008-09-29 17:26:18 +0000303 ISD::LoadExtType ExtType = LD->getExtensionType();
304 if (ExtType == ISD::NON_EXTLOAD)
305 return true;
306 if (ExtType == ISD::EXTLOAD)
307 return LD->getAlignment() >= 4;
308 return false;
309}]>;
310
sampo9cc09a32009-01-26 01:24:32 +0000311def gsload : PatFrag<(ops node:$ptr), (load node:$ptr), [{
312 LoadSDNode *LD = cast<LoadSDNode>(N);
313 const Value *Src = LD->getSrcValue();
314 if (!Src)
315 return false;
316 if (const PointerType *PT = dyn_cast<PointerType>(Src->getType()))
317 return PT->getAddressSpace() == 256;
318 return false;
319}]>;
320
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000321def loadi8 : PatFrag<(ops node:$ptr), (i8 (load node:$ptr))>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000322def loadi64 : PatFrag<(ops node:$ptr), (i64 (load node:$ptr))>;
323
324def loadf32 : PatFrag<(ops node:$ptr), (f32 (load node:$ptr))>;
325def loadf64 : PatFrag<(ops node:$ptr), (f64 (load node:$ptr))>;
Dale Johannesen4ab00bd2007-08-05 18:49:15 +0000326def loadf80 : PatFrag<(ops node:$ptr), (f80 (load node:$ptr))>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000327
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000328def sextloadi16i8 : PatFrag<(ops node:$ptr), (i16 (sextloadi8 node:$ptr))>;
329def sextloadi32i8 : PatFrag<(ops node:$ptr), (i32 (sextloadi8 node:$ptr))>;
330def sextloadi32i16 : PatFrag<(ops node:$ptr), (i32 (sextloadi16 node:$ptr))>;
331
332def zextloadi8i1 : PatFrag<(ops node:$ptr), (i8 (zextloadi1 node:$ptr))>;
333def zextloadi16i1 : PatFrag<(ops node:$ptr), (i16 (zextloadi1 node:$ptr))>;
334def zextloadi32i1 : PatFrag<(ops node:$ptr), (i32 (zextloadi1 node:$ptr))>;
335def zextloadi16i8 : PatFrag<(ops node:$ptr), (i16 (zextloadi8 node:$ptr))>;
336def zextloadi32i8 : PatFrag<(ops node:$ptr), (i32 (zextloadi8 node:$ptr))>;
337def zextloadi32i16 : PatFrag<(ops node:$ptr), (i32 (zextloadi16 node:$ptr))>;
338
339def extloadi8i1 : PatFrag<(ops node:$ptr), (i8 (extloadi1 node:$ptr))>;
340def extloadi16i1 : PatFrag<(ops node:$ptr), (i16 (extloadi1 node:$ptr))>;
341def extloadi32i1 : PatFrag<(ops node:$ptr), (i32 (extloadi1 node:$ptr))>;
342def extloadi16i8 : PatFrag<(ops node:$ptr), (i16 (extloadi8 node:$ptr))>;
343def extloadi32i8 : PatFrag<(ops node:$ptr), (i32 (extloadi8 node:$ptr))>;
344def extloadi32i16 : PatFrag<(ops node:$ptr), (i32 (extloadi16 node:$ptr))>;
345
Chris Lattner21da6382008-02-19 17:37:35 +0000346
347// An 'and' node with a single use.
348def and_su : PatFrag<(ops node:$lhs, node:$rhs), (and node:$lhs, node:$rhs), [{
Evan Cheng9123cfa2008-03-04 00:40:35 +0000349 return N->hasOneUse();
Chris Lattner21da6382008-02-19 17:37:35 +0000350}]>;
351
Dan Gohman921581d2008-10-17 01:23:35 +0000352// 'shld' and 'shrd' instruction patterns. Note that even though these have
353// the srl and shl in their patterns, the C++ code must still check for them,
354// because predicates are tested before children nodes are explored.
355
356def shrd : PatFrag<(ops node:$src1, node:$amt1, node:$src2, node:$amt2),
357 (or (srl node:$src1, node:$amt1),
358 (shl node:$src2, node:$amt2)), [{
359 assert(N->getOpcode() == ISD::OR);
360 return N->getOperand(0).getOpcode() == ISD::SRL &&
361 N->getOperand(1).getOpcode() == ISD::SHL &&
362 isa<ConstantSDNode>(N->getOperand(0).getOperand(1)) &&
363 isa<ConstantSDNode>(N->getOperand(1).getOperand(1)) &&
364 N->getOperand(0).getConstantOperandVal(1) ==
365 N->getValueSizeInBits(0) - N->getOperand(1).getConstantOperandVal(1);
366}]>;
367
368def shld : PatFrag<(ops node:$src1, node:$amt1, node:$src2, node:$amt2),
369 (or (shl node:$src1, node:$amt1),
370 (srl node:$src2, node:$amt2)), [{
371 assert(N->getOpcode() == ISD::OR);
372 return N->getOperand(0).getOpcode() == ISD::SHL &&
373 N->getOperand(1).getOpcode() == ISD::SRL &&
374 isa<ConstantSDNode>(N->getOperand(0).getOperand(1)) &&
375 isa<ConstantSDNode>(N->getOperand(1).getOperand(1)) &&
376 N->getOperand(0).getConstantOperandVal(1) ==
377 N->getValueSizeInBits(0) - N->getOperand(1).getConstantOperandVal(1);
378}]>;
379
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000380//===----------------------------------------------------------------------===//
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000381// Instruction list...
382//
383
384// ADJCALLSTACKDOWN/UP implicitly use/def ESP because they may be expanded into
385// a stack adjustment and the codegen must know that they may modify the stack
386// pointer before prolog-epilog rewriting occurs.
Chris Lattnerb56cc342008-03-11 03:23:40 +0000387// Pessimistically assume ADJCALLSTACKDOWN / ADJCALLSTACKUP will become
388// sub / add which can clobber EFLAGS.
Evan Cheng037364a2007-09-28 01:19:48 +0000389let Defs = [ESP, EFLAGS], Uses = [ESP] in {
Dan Gohman01c9f772008-10-01 18:28:06 +0000390def ADJCALLSTACKDOWN32 : I<0, Pseudo, (outs), (ins i32imm:$amt),
391 "#ADJCALLSTACKDOWN",
Chris Lattnerfe5d4022008-10-11 22:08:30 +0000392 [(X86callseq_start timm:$amt)]>,
Dan Gohman01c9f772008-10-01 18:28:06 +0000393 Requires<[In32BitMode]>;
394def ADJCALLSTACKUP32 : I<0, Pseudo, (outs), (ins i32imm:$amt1, i32imm:$amt2),
395 "#ADJCALLSTACKUP",
Chris Lattnerfe5d4022008-10-11 22:08:30 +0000396 [(X86callseq_end timm:$amt1, timm:$amt2)]>,
Dan Gohman01c9f772008-10-01 18:28:06 +0000397 Requires<[In32BitMode]>;
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000398}
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000399
400// Nop
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000401let neverHasSideEffects = 1 in
402 def NOOP : I<0x90, RawFrm, (outs), (ins), "nop", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000403
Evan Cheng0729ccf2008-01-05 00:41:47 +0000404// PIC base
Dan Gohman9499cfe2008-10-01 04:14:30 +0000405let neverHasSideEffects = 1, isNotDuplicable = 1, Uses = [ESP] in
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000406 def MOVPC32r : Ii32<0xE8, Pseudo, (outs GR32:$reg), (ins piclabel:$label),
407 "call\t$label\n\tpop{l}\t$reg", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000408
409//===----------------------------------------------------------------------===//
410// Control Flow Instructions...
411//
412
413// Return instructions.
414let isTerminator = 1, isReturn = 1, isBarrier = 1,
Chris Lattnerb56cc342008-03-11 03:23:40 +0000415 hasCtrlDep = 1, FPForm = SpecialFP, FPFormBits = SpecialFP.Value in {
Dan Gohman2c4be2a2008-05-31 02:11:25 +0000416 def RET : I <0xC3, RawFrm, (outs), (ins variable_ops),
Chris Lattnerb56cc342008-03-11 03:23:40 +0000417 "ret",
Dan Gohman2c4be2a2008-05-31 02:11:25 +0000418 [(X86retflag 0)]>;
Chris Lattnerb56cc342008-03-11 03:23:40 +0000419 def RETI : Ii16<0xC2, RawFrm, (outs), (ins i16imm:$amt, variable_ops),
420 "ret\t$amt",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000421 [(X86retflag imm:$amt)]>;
422}
423
424// All branches are RawFrm, Void, Branch, and Terminators
Evan Cheng37e7c752007-07-21 00:34:19 +0000425let isBranch = 1, isTerminator = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +0000426 class IBr<bits<8> opcode, dag ins, string asm, list<dag> pattern> :
427 I<opcode, RawFrm, (outs), ins, asm, pattern>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000428
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000429let isBranch = 1, isBarrier = 1 in
Dan Gohman91888f02007-07-31 20:11:57 +0000430 def JMP : IBr<0xE9, (ins brtarget:$dst), "jmp\t$dst", [(br bb:$dst)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000431
Owen Andersonf8053082007-11-12 07:39:39 +0000432// Indirect branches
433let isBranch = 1, isTerminator = 1, isBarrier = 1, isIndirectBranch = 1 in {
Dan Gohman91888f02007-07-31 20:11:57 +0000434 def JMP32r : I<0xFF, MRM4r, (outs), (ins GR32:$dst), "jmp{l}\t{*}$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000435 [(brind GR32:$dst)]>;
Dan Gohman91888f02007-07-31 20:11:57 +0000436 def JMP32m : I<0xFF, MRM4m, (outs), (ins i32mem:$dst), "jmp{l}\t{*}$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000437 [(brind (loadi32 addr:$dst))]>;
438}
439
440// Conditional branches
Evan Cheng950aac02007-09-25 01:57:46 +0000441let Uses = [EFLAGS] in {
Dan Gohman91888f02007-07-31 20:11:57 +0000442def JE : IBr<0x84, (ins brtarget:$dst), "je\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000443 [(X86brcond bb:$dst, X86_COND_E, EFLAGS)]>, TB;
Dan Gohman91888f02007-07-31 20:11:57 +0000444def JNE : IBr<0x85, (ins brtarget:$dst), "jne\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000445 [(X86brcond bb:$dst, X86_COND_NE, EFLAGS)]>, TB;
Dan Gohman91888f02007-07-31 20:11:57 +0000446def JL : IBr<0x8C, (ins brtarget:$dst), "jl\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000447 [(X86brcond bb:$dst, X86_COND_L, EFLAGS)]>, TB;
Dan Gohman91888f02007-07-31 20:11:57 +0000448def JLE : IBr<0x8E, (ins brtarget:$dst), "jle\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000449 [(X86brcond bb:$dst, X86_COND_LE, EFLAGS)]>, TB;
Dan Gohman91888f02007-07-31 20:11:57 +0000450def JG : IBr<0x8F, (ins brtarget:$dst), "jg\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000451 [(X86brcond bb:$dst, X86_COND_G, EFLAGS)]>, TB;
Dan Gohman91888f02007-07-31 20:11:57 +0000452def JGE : IBr<0x8D, (ins brtarget:$dst), "jge\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000453 [(X86brcond bb:$dst, X86_COND_GE, EFLAGS)]>, TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000454
Dan Gohman91888f02007-07-31 20:11:57 +0000455def JB : IBr<0x82, (ins brtarget:$dst), "jb\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000456 [(X86brcond bb:$dst, X86_COND_B, EFLAGS)]>, TB;
Dan Gohman91888f02007-07-31 20:11:57 +0000457def JBE : IBr<0x86, (ins brtarget:$dst), "jbe\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000458 [(X86brcond bb:$dst, X86_COND_BE, EFLAGS)]>, TB;
Dan Gohman91888f02007-07-31 20:11:57 +0000459def JA : IBr<0x87, (ins brtarget:$dst), "ja\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000460 [(X86brcond bb:$dst, X86_COND_A, EFLAGS)]>, TB;
Dan Gohman91888f02007-07-31 20:11:57 +0000461def JAE : IBr<0x83, (ins brtarget:$dst), "jae\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000462 [(X86brcond bb:$dst, X86_COND_AE, EFLAGS)]>, TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000463
Dan Gohman91888f02007-07-31 20:11:57 +0000464def JS : IBr<0x88, (ins brtarget:$dst), "js\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000465 [(X86brcond bb:$dst, X86_COND_S, EFLAGS)]>, TB;
Dan Gohman91888f02007-07-31 20:11:57 +0000466def JNS : IBr<0x89, (ins brtarget:$dst), "jns\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000467 [(X86brcond bb:$dst, X86_COND_NS, EFLAGS)]>, TB;
Dan Gohman91888f02007-07-31 20:11:57 +0000468def JP : IBr<0x8A, (ins brtarget:$dst), "jp\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000469 [(X86brcond bb:$dst, X86_COND_P, EFLAGS)]>, TB;
Dan Gohman91888f02007-07-31 20:11:57 +0000470def JNP : IBr<0x8B, (ins brtarget:$dst), "jnp\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000471 [(X86brcond bb:$dst, X86_COND_NP, EFLAGS)]>, TB;
Dan Gohman91888f02007-07-31 20:11:57 +0000472def JO : IBr<0x80, (ins brtarget:$dst), "jo\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000473 [(X86brcond bb:$dst, X86_COND_O, EFLAGS)]>, TB;
Dan Gohman91888f02007-07-31 20:11:57 +0000474def JNO : IBr<0x81, (ins brtarget:$dst), "jno\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000475 [(X86brcond bb:$dst, X86_COND_NO, EFLAGS)]>, TB;
Evan Cheng950aac02007-09-25 01:57:46 +0000476} // Uses = [EFLAGS]
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000477
478//===----------------------------------------------------------------------===//
479// Call Instructions...
480//
Evan Cheng37e7c752007-07-21 00:34:19 +0000481let isCall = 1 in
Dan Gohman01c9f772008-10-01 18:28:06 +0000482 // All calls clobber the non-callee saved registers. ESP is marked as
483 // a use to prevent stack-pointer assignments that appear immediately
484 // before calls from potentially appearing dead. Uses for argument
485 // registers are added manually.
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000486 let Defs = [EAX, ECX, EDX, FP0, FP1, FP2, FP3, FP4, FP5, FP6, ST0,
487 MM0, MM1, MM2, MM3, MM4, MM5, MM6, MM7,
Evan Cheng2293b252008-10-17 21:02:22 +0000488 XMM0, XMM1, XMM2, XMM3, XMM4, XMM5, XMM6, XMM7,
489 XMM8, XMM9, XMM10, XMM11, XMM12, XMM13, XMM14, XMM15, EFLAGS],
Dan Gohman9499cfe2008-10-01 04:14:30 +0000490 Uses = [ESP] in {
Evan Cheng34f93712007-12-22 02:26:46 +0000491 def CALLpcrel32 : Ii32<0xE8, RawFrm, (outs), (ins i32imm:$dst,variable_ops),
Evan Cheng75952172009-03-04 06:48:53 +0000492 "call\t${dst:call}", [(X86call imm:$dst)]>,
493 Requires<[In32BitMode]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000494 def CALL32r : I<0xFF, MRM2r, (outs), (ins GR32:$dst, variable_ops),
Dan Gohman91888f02007-07-31 20:11:57 +0000495 "call\t{*}$dst", [(X86call GR32:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000496 def CALL32m : I<0xFF, MRM2m, (outs), (ins i32mem:$dst, variable_ops),
Dan Gohmanea4faba2008-05-29 21:50:34 +0000497 "call\t{*}$dst", [(X86call (loadi32 addr:$dst))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000498 }
499
500// Tail call stuff.
Arnold Schwaighofere2d6bbb2007-10-11 19:40:01 +0000501
Chris Lattnerb56cc342008-03-11 03:23:40 +0000502def TAILCALL : I<0, Pseudo, (outs), (ins),
Arnold Schwaighofere2d6bbb2007-10-11 19:40:01 +0000503 "#TAILCALL",
504 []>;
505
Evan Cheng37e7c752007-07-21 00:34:19 +0000506let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1 in
Arnold Schwaighofer6fd37ac2008-03-19 16:39:45 +0000507def TCRETURNdi : I<0, Pseudo, (outs), (ins i32imm:$dst, i32imm:$offset, variable_ops),
Arnold Schwaighofere2d6bbb2007-10-11 19:40:01 +0000508 "#TC_RETURN $dst $offset",
509 []>;
510
511let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1 in
Arnold Schwaighofer6fd37ac2008-03-19 16:39:45 +0000512def TCRETURNri : I<0, Pseudo, (outs), (ins GR32:$dst, i32imm:$offset, variable_ops),
Arnold Schwaighofere2d6bbb2007-10-11 19:40:01 +0000513 "#TC_RETURN $dst $offset",
514 []>;
515
516let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1 in
Arnold Schwaighofera0032722008-04-30 09:16:33 +0000517
Arnold Schwaighofere2d6bbb2007-10-11 19:40:01 +0000518 def TAILJMPd : IBr<0xE9, (ins i32imm:$dst), "jmp\t${dst:call} # TAILCALL",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000519 []>;
Evan Cheng37e7c752007-07-21 00:34:19 +0000520let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1 in
Arnold Schwaighofere2d6bbb2007-10-11 19:40:01 +0000521 def TAILJMPr : I<0xFF, MRM4r, (outs), (ins GR32:$dst), "jmp{l}\t{*}$dst # TAILCALL",
522 []>;
Evan Cheng37e7c752007-07-21 00:34:19 +0000523let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +0000524 def TAILJMPm : I<0xFF, MRM4m, (outs), (ins i32mem:$dst),
Arnold Schwaighofere2d6bbb2007-10-11 19:40:01 +0000525 "jmp\t{*}$dst # TAILCALL", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000526
527//===----------------------------------------------------------------------===//
528// Miscellaneous Instructions...
529//
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000530let Defs = [EBP, ESP], Uses = [EBP, ESP], mayLoad = 1, neverHasSideEffects=1 in
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000531def LEAVE : I<0xC9, RawFrm,
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000532 (outs), (ins), "leave", []>;
533
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000534let Defs = [ESP], Uses = [ESP], neverHasSideEffects=1 in {
535let mayLoad = 1 in
Evan Chengd8434332007-09-26 01:29:06 +0000536def POP32r : I<0x58, AddRegFrm, (outs GR32:$reg), (ins), "pop{l}\t$reg", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000537
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000538let mayStore = 1 in
Evan Chengd8434332007-09-26 01:29:06 +0000539def PUSH32r : I<0x50, AddRegFrm, (outs), (ins GR32:$reg), "push{l}\t$reg",[]>;
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000540}
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000541
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000542let Defs = [ESP, EFLAGS], Uses = [ESP], mayLoad = 1, neverHasSideEffects=1 in
Evan Chengf1341312007-09-26 21:28:00 +0000543def POPFD : I<0x9D, RawFrm, (outs), (ins), "popf", []>;
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000544let Defs = [ESP], Uses = [ESP, EFLAGS], mayStore = 1, neverHasSideEffects=1 in
Evan Chengf1341312007-09-26 21:28:00 +0000545def PUSHFD : I<0x9C, RawFrm, (outs), (ins), "pushf", []>;
Evan Chengd8434332007-09-26 01:29:06 +0000546
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000547let isTwoAddress = 1 in // GR32 = bswap GR32
548 def BSWAP32r : I<0xC8, AddRegFrm,
Evan Chengb783fa32007-07-19 01:14:50 +0000549 (outs GR32:$dst), (ins GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000550 "bswap{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000551 [(set GR32:$dst, (bswap GR32:$src))]>, TB;
552
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000553
Evan Cheng48679f42007-12-14 02:13:44 +0000554// Bit scan instructions.
555let Defs = [EFLAGS] in {
Evan Cheng4e33de92007-12-14 18:49:43 +0000556def BSF16rr : I<0xBC, MRMSrcReg, (outs GR16:$dst), (ins GR16:$src),
Dan Gohmancdb54c62007-12-14 15:10:00 +0000557 "bsf{w}\t{$src, $dst|$dst, $src}",
Evan Cheng7cfbfe32007-12-14 08:30:15 +0000558 [(set GR16:$dst, (X86bsf GR16:$src)), (implicit EFLAGS)]>, TB;
Evan Cheng48679f42007-12-14 02:13:44 +0000559def BSF16rm : I<0xBC, MRMSrcMem, (outs GR16:$dst), (ins i16mem:$src),
Dan Gohmancdb54c62007-12-14 15:10:00 +0000560 "bsf{w}\t{$src, $dst|$dst, $src}",
Evan Cheng7cfbfe32007-12-14 08:30:15 +0000561 [(set GR16:$dst, (X86bsf (loadi16 addr:$src))),
562 (implicit EFLAGS)]>, TB;
Evan Cheng4e33de92007-12-14 18:49:43 +0000563def BSF32rr : I<0xBC, MRMSrcReg, (outs GR32:$dst), (ins GR32:$src),
Dan Gohmancdb54c62007-12-14 15:10:00 +0000564 "bsf{l}\t{$src, $dst|$dst, $src}",
Evan Cheng7cfbfe32007-12-14 08:30:15 +0000565 [(set GR32:$dst, (X86bsf GR32:$src)), (implicit EFLAGS)]>, TB;
Evan Cheng48679f42007-12-14 02:13:44 +0000566def BSF32rm : I<0xBC, MRMSrcMem, (outs GR32:$dst), (ins i32mem:$src),
Dan Gohmancdb54c62007-12-14 15:10:00 +0000567 "bsf{l}\t{$src, $dst|$dst, $src}",
Evan Cheng7cfbfe32007-12-14 08:30:15 +0000568 [(set GR32:$dst, (X86bsf (loadi32 addr:$src))),
569 (implicit EFLAGS)]>, TB;
Evan Cheng48679f42007-12-14 02:13:44 +0000570
Evan Cheng4e33de92007-12-14 18:49:43 +0000571def BSR16rr : I<0xBD, MRMSrcReg, (outs GR16:$dst), (ins GR16:$src),
Dan Gohmancdb54c62007-12-14 15:10:00 +0000572 "bsr{w}\t{$src, $dst|$dst, $src}",
Evan Cheng7cfbfe32007-12-14 08:30:15 +0000573 [(set GR16:$dst, (X86bsr GR16:$src)), (implicit EFLAGS)]>, TB;
Evan Cheng48679f42007-12-14 02:13:44 +0000574def BSR16rm : I<0xBD, MRMSrcMem, (outs GR16:$dst), (ins i16mem:$src),
Dan Gohmancdb54c62007-12-14 15:10:00 +0000575 "bsr{w}\t{$src, $dst|$dst, $src}",
Evan Cheng7cfbfe32007-12-14 08:30:15 +0000576 [(set GR16:$dst, (X86bsr (loadi16 addr:$src))),
577 (implicit EFLAGS)]>, TB;
Evan Cheng4e33de92007-12-14 18:49:43 +0000578def BSR32rr : I<0xBD, MRMSrcReg, (outs GR32:$dst), (ins GR32:$src),
Dan Gohmancdb54c62007-12-14 15:10:00 +0000579 "bsr{l}\t{$src, $dst|$dst, $src}",
Evan Cheng7cfbfe32007-12-14 08:30:15 +0000580 [(set GR32:$dst, (X86bsr GR32:$src)), (implicit EFLAGS)]>, TB;
Evan Cheng48679f42007-12-14 02:13:44 +0000581def BSR32rm : I<0xBD, MRMSrcMem, (outs GR32:$dst), (ins i32mem:$src),
Dan Gohmancdb54c62007-12-14 15:10:00 +0000582 "bsr{l}\t{$src, $dst|$dst, $src}",
Evan Cheng7cfbfe32007-12-14 08:30:15 +0000583 [(set GR32:$dst, (X86bsr (loadi32 addr:$src))),
584 (implicit EFLAGS)]>, TB;
Evan Cheng48679f42007-12-14 02:13:44 +0000585} // Defs = [EFLAGS]
586
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000587let neverHasSideEffects = 1 in
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000588def LEA16r : I<0x8D, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +0000589 (outs GR16:$dst), (ins i32mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000590 "lea{w}\t{$src|$dst}, {$dst|$src}", []>, OpSize;
Evan Cheng1ea8e6b2008-03-27 01:41:09 +0000591let isReMaterializable = 1 in
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000592def LEA32r : I<0x8D, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +0000593 (outs GR32:$dst), (ins lea32mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000594 "lea{l}\t{$src|$dst}, {$dst|$src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000595 [(set GR32:$dst, lea32addr:$src)]>, Requires<[In32BitMode]>;
596
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000597let Defs = [ECX,EDI,ESI], Uses = [ECX,EDI,ESI] in {
Evan Chengb783fa32007-07-19 01:14:50 +0000598def REP_MOVSB : I<0xA4, RawFrm, (outs), (ins), "{rep;movsb|rep movsb}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000599 [(X86rep_movs i8)]>, REP;
Evan Chengb783fa32007-07-19 01:14:50 +0000600def REP_MOVSW : I<0xA5, RawFrm, (outs), (ins), "{rep;movsw|rep movsw}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000601 [(X86rep_movs i16)]>, REP, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +0000602def REP_MOVSD : I<0xA5, RawFrm, (outs), (ins), "{rep;movsl|rep movsd}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000603 [(X86rep_movs i32)]>, REP;
604}
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000605
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000606let Defs = [ECX,EDI], Uses = [AL,ECX,EDI] in
Evan Chengb783fa32007-07-19 01:14:50 +0000607def REP_STOSB : I<0xAA, RawFrm, (outs), (ins), "{rep;stosb|rep stosb}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000608 [(X86rep_stos i8)]>, REP;
609let Defs = [ECX,EDI], Uses = [AX,ECX,EDI] in
Evan Chengb783fa32007-07-19 01:14:50 +0000610def REP_STOSW : I<0xAB, RawFrm, (outs), (ins), "{rep;stosw|rep stosw}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000611 [(X86rep_stos i16)]>, REP, OpSize;
612let Defs = [ECX,EDI], Uses = [EAX,ECX,EDI] in
Evan Chengb783fa32007-07-19 01:14:50 +0000613def REP_STOSD : I<0xAB, RawFrm, (outs), (ins), "{rep;stosl|rep stosd}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000614 [(X86rep_stos i32)]>, REP;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000615
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000616let Defs = [RAX, RDX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000617def RDTSC : I<0x31, RawFrm, (outs), (ins), "rdtsc", [(X86rdtsc)]>,
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000618 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000619
Anton Korobeynikov39d40ba2008-01-15 07:02:33 +0000620let isBarrier = 1, hasCtrlDep = 1 in {
Chris Lattner56b941f2008-01-15 21:58:22 +0000621def TRAP : I<0x0B, RawFrm, (outs), (ins), "ud2", [(trap)]>, TB;
Anton Korobeynikov39d40ba2008-01-15 07:02:33 +0000622}
623
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000624//===----------------------------------------------------------------------===//
625// Input/Output Instructions...
626//
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000627let Defs = [AL], Uses = [DX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000628def IN8rr : I<0xEC, RawFrm, (outs), (ins),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000629 "in{b}\t{%dx, %al|%AL, %DX}", []>;
630let Defs = [AX], Uses = [DX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000631def IN16rr : I<0xED, RawFrm, (outs), (ins),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000632 "in{w}\t{%dx, %ax|%AX, %DX}", []>, OpSize;
633let Defs = [EAX], Uses = [DX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000634def IN32rr : I<0xED, RawFrm, (outs), (ins),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000635 "in{l}\t{%dx, %eax|%EAX, %DX}", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000636
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000637let Defs = [AL] in
Evan Chengb783fa32007-07-19 01:14:50 +0000638def IN8ri : Ii8<0xE4, RawFrm, (outs), (ins i16i8imm:$port),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000639 "in{b}\t{$port, %al|%AL, $port}", []>;
640let Defs = [AX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000641def IN16ri : Ii8<0xE5, RawFrm, (outs), (ins i16i8imm:$port),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000642 "in{w}\t{$port, %ax|%AX, $port}", []>, OpSize;
643let Defs = [EAX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000644def IN32ri : Ii8<0xE5, RawFrm, (outs), (ins i16i8imm:$port),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000645 "in{l}\t{$port, %eax|%EAX, $port}", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000646
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000647let Uses = [DX, AL] in
Evan Chengb783fa32007-07-19 01:14:50 +0000648def OUT8rr : I<0xEE, RawFrm, (outs), (ins),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000649 "out{b}\t{%al, %dx|%DX, %AL}", []>;
650let Uses = [DX, AX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000651def OUT16rr : I<0xEF, RawFrm, (outs), (ins),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000652 "out{w}\t{%ax, %dx|%DX, %AX}", []>, OpSize;
653let Uses = [DX, EAX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000654def OUT32rr : I<0xEF, RawFrm, (outs), (ins),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000655 "out{l}\t{%eax, %dx|%DX, %EAX}", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000656
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000657let Uses = [AL] in
Evan Chengb783fa32007-07-19 01:14:50 +0000658def OUT8ir : Ii8<0xE6, RawFrm, (outs), (ins i16i8imm:$port),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000659 "out{b}\t{%al, $port|$port, %AL}", []>;
660let Uses = [AX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000661def OUT16ir : Ii8<0xE7, RawFrm, (outs), (ins i16i8imm:$port),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000662 "out{w}\t{%ax, $port|$port, %AX}", []>, OpSize;
663let Uses = [EAX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000664def OUT32ir : Ii8<0xE7, RawFrm, (outs), (ins i16i8imm:$port),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000665 "out{l}\t{%eax, $port|$port, %EAX}", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000666
667//===----------------------------------------------------------------------===//
668// Move Instructions...
669//
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000670let neverHasSideEffects = 1 in {
Evan Chengb783fa32007-07-19 01:14:50 +0000671def MOV8rr : I<0x88, MRMDestReg, (outs GR8 :$dst), (ins GR8 :$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000672 "mov{b}\t{$src, $dst|$dst, $src}", []>;
Evan Chengb783fa32007-07-19 01:14:50 +0000673def MOV16rr : I<0x89, MRMDestReg, (outs GR16:$dst), (ins GR16:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000674 "mov{w}\t{$src, $dst|$dst, $src}", []>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +0000675def MOV32rr : I<0x89, MRMDestReg, (outs GR32:$dst), (ins GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000676 "mov{l}\t{$src, $dst|$dst, $src}", []>;
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000677}
Evan Cheng6f26e8b2008-06-18 08:13:07 +0000678let isReMaterializable = 1, isAsCheapAsAMove = 1 in {
Evan Chengb783fa32007-07-19 01:14:50 +0000679def MOV8ri : Ii8 <0xB0, AddRegFrm, (outs GR8 :$dst), (ins i8imm :$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000680 "mov{b}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000681 [(set GR8:$dst, imm:$src)]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000682def MOV16ri : Ii16<0xB8, AddRegFrm, (outs GR16:$dst), (ins i16imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000683 "mov{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000684 [(set GR16:$dst, imm:$src)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +0000685def MOV32ri : Ii32<0xB8, AddRegFrm, (outs GR32:$dst), (ins i32imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000686 "mov{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000687 [(set GR32:$dst, imm:$src)]>;
688}
Evan Chengb783fa32007-07-19 01:14:50 +0000689def MOV8mi : Ii8 <0xC6, MRM0m, (outs), (ins i8mem :$dst, i8imm :$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000690 "mov{b}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000691 [(store (i8 imm:$src), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000692def MOV16mi : Ii16<0xC7, MRM0m, (outs), (ins i16mem:$dst, i16imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000693 "mov{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000694 [(store (i16 imm:$src), addr:$dst)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +0000695def MOV32mi : Ii32<0xC7, MRM0m, (outs), (ins i32mem:$dst, i32imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000696 "mov{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000697 [(store (i32 imm:$src), addr:$dst)]>;
698
Dan Gohman5574cc72008-12-03 18:15:48 +0000699let canFoldAsLoad = 1, isReMaterializable = 1, mayHaveSideEffects = 1 in {
Evan Chengb783fa32007-07-19 01:14:50 +0000700def MOV8rm : I<0x8A, MRMSrcMem, (outs GR8 :$dst), (ins i8mem :$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000701 "mov{b}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000702 [(set GR8:$dst, (load addr:$src))]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000703def MOV16rm : I<0x8B, MRMSrcMem, (outs GR16:$dst), (ins i16mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000704 "mov{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000705 [(set GR16:$dst, (load addr:$src))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +0000706def MOV32rm : I<0x8B, MRMSrcMem, (outs GR32:$dst), (ins i32mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000707 "mov{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000708 [(set GR32:$dst, (load addr:$src))]>;
Evan Cheng4e84e452007-08-30 05:49:43 +0000709}
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000710
Evan Chengb783fa32007-07-19 01:14:50 +0000711def MOV8mr : I<0x88, MRMDestMem, (outs), (ins i8mem :$dst, GR8 :$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000712 "mov{b}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000713 [(store GR8:$src, addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000714def MOV16mr : I<0x89, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000715 "mov{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000716 [(store GR16:$src, addr:$dst)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +0000717def MOV32mr : I<0x89, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000718 "mov{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000719 [(store GR32:$src, addr:$dst)]>;
720
721//===----------------------------------------------------------------------===//
722// Fixed-Register Multiplication and Division Instructions...
723//
724
725// Extra precision multiplication
Evan Cheng55687072007-09-14 21:48:26 +0000726let Defs = [AL,AH,EFLAGS], Uses = [AL] in
Dan Gohman91888f02007-07-31 20:11:57 +0000727def MUL8r : I<0xF6, MRM4r, (outs), (ins GR8:$src), "mul{b}\t$src",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000728 // FIXME: Used for 8-bit mul, ignore result upper 8 bits.
729 // This probably ought to be moved to a def : Pat<> if the
730 // syntax can be accepted.
Bill Wendlingf5399032008-12-12 21:15:41 +0000731 [(set AL, (mul AL, GR8:$src)),
732 (implicit EFLAGS)]>; // AL,AH = AL*GR8
733
Chris Lattnerc7e96e72008-01-11 07:18:17 +0000734let Defs = [AX,DX,EFLAGS], Uses = [AX], neverHasSideEffects = 1 in
Bill Wendlingf5399032008-12-12 21:15:41 +0000735def MUL16r : I<0xF7, MRM4r, (outs), (ins GR16:$src),
736 "mul{w}\t$src",
737 []>, OpSize; // AX,DX = AX*GR16
738
Chris Lattnerc7e96e72008-01-11 07:18:17 +0000739let Defs = [EAX,EDX,EFLAGS], Uses = [EAX], neverHasSideEffects = 1 in
Bill Wendlingf5399032008-12-12 21:15:41 +0000740def MUL32r : I<0xF7, MRM4r, (outs), (ins GR32:$src),
741 "mul{l}\t$src",
742 []>; // EAX,EDX = EAX*GR32
743
Evan Cheng55687072007-09-14 21:48:26 +0000744let Defs = [AL,AH,EFLAGS], Uses = [AL] in
Evan Chengb783fa32007-07-19 01:14:50 +0000745def MUL8m : I<0xF6, MRM4m, (outs), (ins i8mem :$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000746 "mul{b}\t$src",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000747 // FIXME: Used for 8-bit mul, ignore result upper 8 bits.
748 // This probably ought to be moved to a def : Pat<> if the
749 // syntax can be accepted.
Bill Wendlingf5399032008-12-12 21:15:41 +0000750 [(set AL, (mul AL, (loadi8 addr:$src))),
751 (implicit EFLAGS)]>; // AL,AH = AL*[mem8]
752
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000753let mayLoad = 1, neverHasSideEffects = 1 in {
Evan Cheng55687072007-09-14 21:48:26 +0000754let Defs = [AX,DX,EFLAGS], Uses = [AX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000755def MUL16m : I<0xF7, MRM4m, (outs), (ins i16mem:$src),
Bill Wendlingf5399032008-12-12 21:15:41 +0000756 "mul{w}\t$src",
757 []>, OpSize; // AX,DX = AX*[mem16]
758
Evan Cheng55687072007-09-14 21:48:26 +0000759let Defs = [EAX,EDX,EFLAGS], Uses = [EAX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000760def MUL32m : I<0xF7, MRM4m, (outs), (ins i32mem:$src),
Bill Wendlingf5399032008-12-12 21:15:41 +0000761 "mul{l}\t$src",
762 []>; // EAX,EDX = EAX*[mem32]
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000763}
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000764
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000765let neverHasSideEffects = 1 in {
Evan Cheng55687072007-09-14 21:48:26 +0000766let Defs = [AL,AH,EFLAGS], Uses = [AL] in
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000767def IMUL8r : I<0xF6, MRM5r, (outs), (ins GR8:$src), "imul{b}\t$src", []>;
768 // AL,AH = AL*GR8
Evan Cheng55687072007-09-14 21:48:26 +0000769let Defs = [AX,DX,EFLAGS], Uses = [AX] in
Dan Gohman91888f02007-07-31 20:11:57 +0000770def IMUL16r : I<0xF7, MRM5r, (outs), (ins GR16:$src), "imul{w}\t$src", []>,
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000771 OpSize; // AX,DX = AX*GR16
Evan Cheng55687072007-09-14 21:48:26 +0000772let Defs = [EAX,EDX,EFLAGS], Uses = [EAX] in
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000773def IMUL32r : I<0xF7, MRM5r, (outs), (ins GR32:$src), "imul{l}\t$src", []>;
774 // EAX,EDX = EAX*GR32
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000775let mayLoad = 1 in {
Evan Cheng55687072007-09-14 21:48:26 +0000776let Defs = [AL,AH,EFLAGS], Uses = [AL] in
Evan Chengb783fa32007-07-19 01:14:50 +0000777def IMUL8m : I<0xF6, MRM5m, (outs), (ins i8mem :$src),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000778 "imul{b}\t$src", []>; // AL,AH = AL*[mem8]
Evan Cheng55687072007-09-14 21:48:26 +0000779let Defs = [AX,DX,EFLAGS], Uses = [AX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000780def IMUL16m : I<0xF7, MRM5m, (outs), (ins i16mem:$src),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000781 "imul{w}\t$src", []>, OpSize; // AX,DX = AX*[mem16]
782let Defs = [EAX,EDX], Uses = [EAX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000783def IMUL32m : I<0xF7, MRM5m, (outs), (ins i32mem:$src),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000784 "imul{l}\t$src", []>; // EAX,EDX = EAX*[mem32]
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000785}
Dan Gohmand44572d2008-11-18 21:29:14 +0000786} // neverHasSideEffects
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000787
788// unsigned 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 DIV8r : I<0xF6, MRM6r, (outs), (ins GR8:$src), // AX/r8 = AL,AH
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000791 "div{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 DIV16r : I<0xF7, MRM6r, (outs), (ins GR16:$src), // DX:AX/r16 = AX,DX
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000794 "div{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 DIV32r : I<0xF7, MRM6r, (outs), (ins GR32:$src), // EDX:EAX/r32 = EAX,EDX
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000797 "div{l}\t$src", []>;
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000798let 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 DIV8m : I<0xF6, MRM6m, (outs), (ins i8mem:$src), // AX/[mem8] = AL,AH
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000801 "div{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 DIV16m : I<0xF7, MRM6m, (outs), (ins i16mem:$src), // DX:AX/[mem16] = AX,DX
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000804 "div{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 DIV32m : I<0xF7, MRM6m, (outs), (ins i32mem:$src), // EDX:EAX/[mem32] = EAX,EDX
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000807 "div{l}\t$src", []>;
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000808}
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000809
810// Signed division/remainder.
Dale Johannesend8fd3562008-10-07 18:54:28 +0000811let Defs = [AL,AH,EFLAGS], Uses = [AX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000812def IDIV8r : I<0xF6, MRM7r, (outs), (ins GR8:$src), // AX/r8 = AL,AH
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000813 "idiv{b}\t$src", []>;
Evan Cheng55687072007-09-14 21:48:26 +0000814let Defs = [AX,DX,EFLAGS], Uses = [AX,DX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000815def IDIV16r: I<0xF7, MRM7r, (outs), (ins GR16:$src), // DX:AX/r16 = AX,DX
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000816 "idiv{w}\t$src", []>, OpSize;
Evan Cheng55687072007-09-14 21:48:26 +0000817let Defs = [EAX,EDX,EFLAGS], Uses = [EAX,EDX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000818def IDIV32r: I<0xF7, MRM7r, (outs), (ins GR32:$src), // EDX:EAX/r32 = EAX,EDX
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000819 "idiv{l}\t$src", []>;
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000820let mayLoad = 1, mayLoad = 1 in {
Dale Johannesend8fd3562008-10-07 18:54:28 +0000821let Defs = [AL,AH,EFLAGS], Uses = [AX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000822def IDIV8m : I<0xF6, MRM7m, (outs), (ins i8mem:$src), // AX/[mem8] = AL,AH
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000823 "idiv{b}\t$src", []>;
Evan Cheng55687072007-09-14 21:48:26 +0000824let Defs = [AX,DX,EFLAGS], Uses = [AX,DX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000825def IDIV16m: I<0xF7, MRM7m, (outs), (ins i16mem:$src), // DX:AX/[mem16] = AX,DX
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000826 "idiv{w}\t$src", []>, OpSize;
Evan Cheng55687072007-09-14 21:48:26 +0000827let Defs = [EAX,EDX,EFLAGS], Uses = [EAX,EDX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000828def IDIV32m: I<0xF7, MRM7m, (outs), (ins i32mem:$src), // EDX:EAX/[mem32] = EAX,EDX
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000829 "idiv{l}\t$src", []>;
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000830}
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000831
832//===----------------------------------------------------------------------===//
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000833// Two address Instructions.
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000834//
835let isTwoAddress = 1 in {
836
837// Conditional moves
Evan Cheng950aac02007-09-25 01:57:46 +0000838let Uses = [EFLAGS] in {
Evan Cheng926658c2007-10-05 23:13:21 +0000839let isCommutable = 1 in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000840def CMOVB16rr : I<0x42, MRMSrcReg, // if <u, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +0000841 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000842 "cmovb\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000843 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000844 X86_COND_B, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000845 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000846def CMOVB32rr : I<0x42, MRMSrcReg, // if <u, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +0000847 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000848 "cmovb\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000849 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000850 X86_COND_B, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000851 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000852def CMOVAE16rr: I<0x43, MRMSrcReg, // if >=u, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +0000853 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000854 "cmovae\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000855 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000856 X86_COND_AE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000857 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000858def CMOVAE32rr: I<0x43, MRMSrcReg, // if >=u, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +0000859 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000860 "cmovae\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000861 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000862 X86_COND_AE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000863 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000864def CMOVE16rr : I<0x44, MRMSrcReg, // if ==, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +0000865 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000866 "cmove\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000867 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000868 X86_COND_E, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000869 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000870def CMOVE32rr : I<0x44, MRMSrcReg, // if ==, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +0000871 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000872 "cmove\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000873 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000874 X86_COND_E, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000875 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000876def CMOVNE16rr: I<0x45, MRMSrcReg, // if !=, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +0000877 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000878 "cmovne\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000879 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000880 X86_COND_NE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000881 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000882def CMOVNE32rr: I<0x45, MRMSrcReg, // if !=, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +0000883 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000884 "cmovne\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000885 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000886 X86_COND_NE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000887 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000888def CMOVBE16rr: I<0x46, MRMSrcReg, // if <=u, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +0000889 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000890 "cmovbe\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000891 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000892 X86_COND_BE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000893 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000894def CMOVBE32rr: I<0x46, MRMSrcReg, // if <=u, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +0000895 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000896 "cmovbe\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000897 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000898 X86_COND_BE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000899 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000900def CMOVA16rr : I<0x47, MRMSrcReg, // if >u, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +0000901 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000902 "cmova\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000903 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000904 X86_COND_A, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000905 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000906def CMOVA32rr : I<0x47, MRMSrcReg, // if >u, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +0000907 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000908 "cmova\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000909 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000910 X86_COND_A, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000911 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000912def CMOVL16rr : I<0x4C, MRMSrcReg, // if <s, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +0000913 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000914 "cmovl\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000915 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000916 X86_COND_L, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000917 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000918def CMOVL32rr : I<0x4C, MRMSrcReg, // if <s, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +0000919 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000920 "cmovl\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000921 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000922 X86_COND_L, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000923 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000924def CMOVGE16rr: I<0x4D, MRMSrcReg, // if >=s, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +0000925 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000926 "cmovge\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000927 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000928 X86_COND_GE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000929 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000930def CMOVGE32rr: I<0x4D, MRMSrcReg, // if >=s, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +0000931 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000932 "cmovge\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000933 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000934 X86_COND_GE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000935 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000936def CMOVLE16rr: I<0x4E, MRMSrcReg, // if <=s, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +0000937 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000938 "cmovle\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000939 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000940 X86_COND_LE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000941 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000942def CMOVLE32rr: I<0x4E, MRMSrcReg, // if <=s, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +0000943 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000944 "cmovle\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000945 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000946 X86_COND_LE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000947 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000948def CMOVG16rr : I<0x4F, MRMSrcReg, // if >s, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +0000949 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000950 "cmovg\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000951 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000952 X86_COND_G, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000953 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000954def CMOVG32rr : I<0x4F, MRMSrcReg, // if >s, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +0000955 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000956 "cmovg\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000957 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000958 X86_COND_G, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000959 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000960def CMOVS16rr : I<0x48, MRMSrcReg, // if signed, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +0000961 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000962 "cmovs\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000963 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000964 X86_COND_S, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000965 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000966def CMOVS32rr : I<0x48, MRMSrcReg, // if signed, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +0000967 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000968 "cmovs\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000969 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000970 X86_COND_S, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000971 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000972def CMOVNS16rr: I<0x49, MRMSrcReg, // if !signed, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +0000973 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000974 "cmovns\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000975 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000976 X86_COND_NS, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000977 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000978def CMOVNS32rr: I<0x49, MRMSrcReg, // if !signed, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +0000979 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000980 "cmovns\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000981 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000982 X86_COND_NS, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000983 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000984def CMOVP16rr : I<0x4A, MRMSrcReg, // if parity, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +0000985 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000986 "cmovp\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000987 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000988 X86_COND_P, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000989 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000990def CMOVP32rr : I<0x4A, MRMSrcReg, // if parity, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +0000991 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000992 "cmovp\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000993 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000994 X86_COND_P, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000995 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000996def CMOVNP16rr : I<0x4B, MRMSrcReg, // if !parity, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +0000997 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000998 "cmovnp\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000999 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001000 X86_COND_NP, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001001 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001002def CMOVNP32rr : I<0x4B, MRMSrcReg, // if !parity, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +00001003 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001004 "cmovnp\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001005 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001006 X86_COND_NP, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001007 TB;
Dan Gohman12fd4d72009-01-07 00:35:10 +00001008def CMOVO16rr : I<0x40, MRMSrcReg, // if overflow, GR16 = GR16
1009 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
1010 "cmovo\t{$src2, $dst|$dst, $src2}",
1011 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
1012 X86_COND_O, EFLAGS))]>,
1013 TB, OpSize;
1014def CMOVO32rr : I<0x40, MRMSrcReg, // if overflow, GR32 = GR32
1015 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
1016 "cmovo\t{$src2, $dst|$dst, $src2}",
1017 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
1018 X86_COND_O, EFLAGS))]>,
Evan Cheng950aac02007-09-25 01:57:46 +00001019 TB;
Dan Gohman12fd4d72009-01-07 00:35:10 +00001020def CMOVNO16rr : I<0x41, MRMSrcReg, // if !overflow, GR16 = GR16
1021 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
1022 "cmovno\t{$src2, $dst|$dst, $src2}",
1023 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
1024 X86_COND_NO, EFLAGS))]>,
1025 TB, OpSize;
1026def CMOVNO32rr : I<0x41, MRMSrcReg, // if !overflow, GR32 = GR32
1027 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
1028 "cmovno\t{$src2, $dst|$dst, $src2}",
1029 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
1030 X86_COND_NO, EFLAGS))]>,
1031 TB;
1032} // isCommutable = 1
Evan Cheng926658c2007-10-05 23:13:21 +00001033
1034def CMOVB16rm : I<0x42, MRMSrcMem, // if <u, GR16 = [mem16]
1035 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1036 "cmovb\t{$src2, $dst|$dst, $src2}",
1037 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1038 X86_COND_B, EFLAGS))]>,
1039 TB, OpSize;
1040def CMOVB32rm : I<0x42, MRMSrcMem, // if <u, GR32 = [mem32]
1041 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1042 "cmovb\t{$src2, $dst|$dst, $src2}",
1043 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1044 X86_COND_B, EFLAGS))]>,
1045 TB;
1046def CMOVAE16rm: I<0x43, MRMSrcMem, // if >=u, GR16 = [mem16]
1047 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1048 "cmovae\t{$src2, $dst|$dst, $src2}",
1049 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1050 X86_COND_AE, EFLAGS))]>,
1051 TB, OpSize;
1052def CMOVAE32rm: I<0x43, MRMSrcMem, // if >=u, GR32 = [mem32]
1053 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1054 "cmovae\t{$src2, $dst|$dst, $src2}",
1055 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1056 X86_COND_AE, EFLAGS))]>,
1057 TB;
1058def CMOVE16rm : I<0x44, MRMSrcMem, // if ==, GR16 = [mem16]
1059 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1060 "cmove\t{$src2, $dst|$dst, $src2}",
1061 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1062 X86_COND_E, EFLAGS))]>,
1063 TB, OpSize;
1064def CMOVE32rm : I<0x44, MRMSrcMem, // if ==, GR32 = [mem32]
1065 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1066 "cmove\t{$src2, $dst|$dst, $src2}",
1067 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1068 X86_COND_E, EFLAGS))]>,
1069 TB;
1070def CMOVNE16rm: I<0x45, MRMSrcMem, // if !=, GR16 = [mem16]
1071 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1072 "cmovne\t{$src2, $dst|$dst, $src2}",
1073 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1074 X86_COND_NE, EFLAGS))]>,
1075 TB, OpSize;
1076def CMOVNE32rm: I<0x45, MRMSrcMem, // if !=, GR32 = [mem32]
1077 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1078 "cmovne\t{$src2, $dst|$dst, $src2}",
1079 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1080 X86_COND_NE, EFLAGS))]>,
1081 TB;
1082def CMOVBE16rm: I<0x46, MRMSrcMem, // if <=u, GR16 = [mem16]
1083 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1084 "cmovbe\t{$src2, $dst|$dst, $src2}",
1085 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1086 X86_COND_BE, EFLAGS))]>,
1087 TB, OpSize;
1088def CMOVBE32rm: I<0x46, MRMSrcMem, // if <=u, GR32 = [mem32]
1089 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1090 "cmovbe\t{$src2, $dst|$dst, $src2}",
1091 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1092 X86_COND_BE, EFLAGS))]>,
1093 TB;
1094def CMOVA16rm : I<0x47, MRMSrcMem, // if >u, GR16 = [mem16]
1095 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1096 "cmova\t{$src2, $dst|$dst, $src2}",
1097 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1098 X86_COND_A, EFLAGS))]>,
1099 TB, OpSize;
1100def CMOVA32rm : I<0x47, MRMSrcMem, // if >u, GR32 = [mem32]
1101 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1102 "cmova\t{$src2, $dst|$dst, $src2}",
1103 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1104 X86_COND_A, EFLAGS))]>,
1105 TB;
1106def CMOVL16rm : I<0x4C, MRMSrcMem, // if <s, GR16 = [mem16]
1107 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1108 "cmovl\t{$src2, $dst|$dst, $src2}",
1109 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1110 X86_COND_L, EFLAGS))]>,
1111 TB, OpSize;
1112def CMOVL32rm : I<0x4C, MRMSrcMem, // if <s, GR32 = [mem32]
1113 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1114 "cmovl\t{$src2, $dst|$dst, $src2}",
1115 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1116 X86_COND_L, EFLAGS))]>,
1117 TB;
1118def CMOVGE16rm: I<0x4D, MRMSrcMem, // if >=s, GR16 = [mem16]
1119 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1120 "cmovge\t{$src2, $dst|$dst, $src2}",
1121 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1122 X86_COND_GE, EFLAGS))]>,
1123 TB, OpSize;
1124def CMOVGE32rm: I<0x4D, MRMSrcMem, // if >=s, GR32 = [mem32]
1125 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1126 "cmovge\t{$src2, $dst|$dst, $src2}",
1127 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1128 X86_COND_GE, EFLAGS))]>,
1129 TB;
1130def CMOVLE16rm: I<0x4E, MRMSrcMem, // if <=s, GR16 = [mem16]
1131 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1132 "cmovle\t{$src2, $dst|$dst, $src2}",
1133 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1134 X86_COND_LE, EFLAGS))]>,
1135 TB, OpSize;
1136def CMOVLE32rm: I<0x4E, MRMSrcMem, // if <=s, GR32 = [mem32]
1137 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1138 "cmovle\t{$src2, $dst|$dst, $src2}",
1139 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1140 X86_COND_LE, EFLAGS))]>,
1141 TB;
1142def CMOVG16rm : I<0x4F, MRMSrcMem, // if >s, GR16 = [mem16]
1143 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1144 "cmovg\t{$src2, $dst|$dst, $src2}",
1145 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1146 X86_COND_G, EFLAGS))]>,
1147 TB, OpSize;
1148def CMOVG32rm : I<0x4F, MRMSrcMem, // if >s, GR32 = [mem32]
1149 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1150 "cmovg\t{$src2, $dst|$dst, $src2}",
1151 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1152 X86_COND_G, EFLAGS))]>,
1153 TB;
1154def CMOVS16rm : I<0x48, MRMSrcMem, // if signed, GR16 = [mem16]
1155 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1156 "cmovs\t{$src2, $dst|$dst, $src2}",
1157 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1158 X86_COND_S, EFLAGS))]>,
1159 TB, OpSize;
1160def CMOVS32rm : I<0x48, MRMSrcMem, // if signed, GR32 = [mem32]
1161 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1162 "cmovs\t{$src2, $dst|$dst, $src2}",
1163 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1164 X86_COND_S, EFLAGS))]>,
1165 TB;
1166def CMOVNS16rm: I<0x49, MRMSrcMem, // if !signed, GR16 = [mem16]
1167 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1168 "cmovns\t{$src2, $dst|$dst, $src2}",
1169 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1170 X86_COND_NS, EFLAGS))]>,
1171 TB, OpSize;
1172def CMOVNS32rm: I<0x49, MRMSrcMem, // if !signed, GR32 = [mem32]
1173 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1174 "cmovns\t{$src2, $dst|$dst, $src2}",
1175 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1176 X86_COND_NS, EFLAGS))]>,
1177 TB;
1178def CMOVP16rm : I<0x4A, MRMSrcMem, // if parity, GR16 = [mem16]
1179 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1180 "cmovp\t{$src2, $dst|$dst, $src2}",
1181 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1182 X86_COND_P, EFLAGS))]>,
1183 TB, OpSize;
1184def CMOVP32rm : I<0x4A, MRMSrcMem, // if parity, GR32 = [mem32]
1185 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1186 "cmovp\t{$src2, $dst|$dst, $src2}",
1187 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1188 X86_COND_P, EFLAGS))]>,
1189 TB;
1190def CMOVNP16rm : I<0x4B, MRMSrcMem, // if !parity, GR16 = [mem16]
1191 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1192 "cmovnp\t{$src2, $dst|$dst, $src2}",
1193 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1194 X86_COND_NP, EFLAGS))]>,
1195 TB, OpSize;
Dan Gohman12fd4d72009-01-07 00:35:10 +00001196def CMOVNP32rm : I<0x4B, MRMSrcMem, // if !parity, GR32 = [mem32]
1197 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1198 "cmovnp\t{$src2, $dst|$dst, $src2}",
1199 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1200 X86_COND_NP, EFLAGS))]>,
1201 TB;
1202def CMOVO16rm : I<0x40, MRMSrcMem, // if overflow, GR16 = [mem16]
1203 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1204 "cmovo\t{$src2, $dst|$dst, $src2}",
1205 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1206 X86_COND_O, EFLAGS))]>,
1207 TB, OpSize;
1208def CMOVO32rm : I<0x40, MRMSrcMem, // if overflow, GR32 = [mem32]
1209 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1210 "cmovo\t{$src2, $dst|$dst, $src2}",
1211 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1212 X86_COND_O, EFLAGS))]>,
1213 TB;
1214def CMOVNO16rm : I<0x41, MRMSrcMem, // if !overflow, GR16 = [mem16]
1215 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1216 "cmovno\t{$src2, $dst|$dst, $src2}",
1217 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1218 X86_COND_NO, EFLAGS))]>,
1219 TB, OpSize;
1220def CMOVNO32rm : I<0x41, MRMSrcMem, // if !overflow, GR32 = [mem32]
1221 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1222 "cmovno\t{$src2, $dst|$dst, $src2}",
1223 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1224 X86_COND_NO, EFLAGS))]>,
1225 TB;
Evan Cheng950aac02007-09-25 01:57:46 +00001226} // Uses = [EFLAGS]
1227
1228
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001229// unary instructions
1230let CodeSize = 2 in {
Evan Cheng55687072007-09-14 21:48:26 +00001231let Defs = [EFLAGS] in {
Dan Gohman91888f02007-07-31 20:11:57 +00001232def NEG8r : I<0xF6, MRM3r, (outs GR8 :$dst), (ins GR8 :$src), "neg{b}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001233 [(set GR8:$dst, (ineg GR8:$src)),
1234 (implicit EFLAGS)]>;
Dan Gohman91888f02007-07-31 20:11:57 +00001235def NEG16r : I<0xF7, MRM3r, (outs GR16:$dst), (ins GR16:$src), "neg{w}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001236 [(set GR16:$dst, (ineg GR16:$src)),
1237 (implicit EFLAGS)]>, OpSize;
Dan Gohman91888f02007-07-31 20:11:57 +00001238def NEG32r : I<0xF7, MRM3r, (outs GR32:$dst), (ins GR32:$src), "neg{l}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001239 [(set GR32:$dst, (ineg GR32:$src)),
1240 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001241let isTwoAddress = 0 in {
Dan Gohman91888f02007-07-31 20:11:57 +00001242 def NEG8m : I<0xF6, MRM3m, (outs), (ins i8mem :$dst), "neg{b}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001243 [(store (ineg (loadi8 addr:$dst)), addr:$dst),
1244 (implicit EFLAGS)]>;
Dan Gohman91888f02007-07-31 20:11:57 +00001245 def NEG16m : I<0xF7, MRM3m, (outs), (ins i16mem:$dst), "neg{w}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001246 [(store (ineg (loadi16 addr:$dst)), addr:$dst),
1247 (implicit EFLAGS)]>, OpSize;
Dan Gohman91888f02007-07-31 20:11:57 +00001248 def NEG32m : I<0xF7, MRM3m, (outs), (ins i32mem:$dst), "neg{l}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001249 [(store (ineg (loadi32 addr:$dst)), addr:$dst),
1250 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001251}
Evan Cheng55687072007-09-14 21:48:26 +00001252} // Defs = [EFLAGS]
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001253
Evan Chengc6cee682009-01-21 02:09:05 +00001254// Match xor -1 to not. Favors these over a move imm + xor to save code size.
1255let AddedComplexity = 15 in {
Dan Gohman91888f02007-07-31 20:11:57 +00001256def NOT8r : I<0xF6, MRM2r, (outs GR8 :$dst), (ins GR8 :$src), "not{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001257 [(set GR8:$dst, (not GR8:$src))]>;
Dan Gohman91888f02007-07-31 20:11:57 +00001258def NOT16r : I<0xF7, MRM2r, (outs GR16:$dst), (ins GR16:$src), "not{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001259 [(set GR16:$dst, (not GR16:$src))]>, OpSize;
Dan Gohman91888f02007-07-31 20:11:57 +00001260def NOT32r : I<0xF7, MRM2r, (outs GR32:$dst), (ins GR32:$src), "not{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001261 [(set GR32:$dst, (not GR32:$src))]>;
Evan Chengc6cee682009-01-21 02:09:05 +00001262}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001263let isTwoAddress = 0 in {
Dan Gohman91888f02007-07-31 20:11:57 +00001264 def NOT8m : I<0xF6, MRM2m, (outs), (ins i8mem :$dst), "not{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001265 [(store (not (loadi8 addr:$dst)), addr:$dst)]>;
Dan Gohman91888f02007-07-31 20:11:57 +00001266 def NOT16m : I<0xF7, MRM2m, (outs), (ins i16mem:$dst), "not{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001267 [(store (not (loadi16 addr:$dst)), addr:$dst)]>, OpSize;
Dan Gohman91888f02007-07-31 20:11:57 +00001268 def NOT32m : I<0xF7, MRM2m, (outs), (ins i32mem:$dst), "not{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001269 [(store (not (loadi32 addr:$dst)), addr:$dst)]>;
1270}
1271} // CodeSize
1272
1273// TODO: inc/dec is slow for P4, but fast for Pentium-M.
Evan Cheng55687072007-09-14 21:48:26 +00001274let Defs = [EFLAGS] in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001275let CodeSize = 2 in
Dan Gohman91888f02007-07-31 20:11:57 +00001276def INC8r : I<0xFE, MRM0r, (outs GR8 :$dst), (ins GR8 :$src), "inc{b}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001277 [(set GR8:$dst, (add GR8:$src, 1)),
1278 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001279let isConvertibleToThreeAddress = 1, CodeSize = 1 in { // Can xform into LEA.
Dan Gohman91888f02007-07-31 20:11:57 +00001280def INC16r : I<0x40, AddRegFrm, (outs GR16:$dst), (ins GR16:$src), "inc{w}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001281 [(set GR16:$dst, (add GR16:$src, 1)),
1282 (implicit EFLAGS)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001283 OpSize, Requires<[In32BitMode]>;
Dan Gohman91888f02007-07-31 20:11:57 +00001284def INC32r : I<0x40, AddRegFrm, (outs GR32:$dst), (ins GR32:$src), "inc{l}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001285 [(set GR32:$dst, (add GR32:$src, 1)),
1286 (implicit EFLAGS)]>, Requires<[In32BitMode]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001287}
1288let isTwoAddress = 0, CodeSize = 2 in {
Dan Gohman91888f02007-07-31 20:11:57 +00001289 def INC8m : I<0xFE, MRM0m, (outs), (ins i8mem :$dst), "inc{b}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001290 [(store (add (loadi8 addr:$dst), 1), addr:$dst),
1291 (implicit EFLAGS)]>;
Dan Gohman91888f02007-07-31 20:11:57 +00001292 def INC16m : I<0xFF, MRM0m, (outs), (ins i16mem:$dst), "inc{w}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001293 [(store (add (loadi16 addr:$dst), 1), addr:$dst),
1294 (implicit EFLAGS)]>,
Evan Cheng4a7e72f2007-10-19 21:23:22 +00001295 OpSize, Requires<[In32BitMode]>;
Dan Gohman91888f02007-07-31 20:11:57 +00001296 def INC32m : I<0xFF, MRM0m, (outs), (ins i32mem:$dst), "inc{l}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001297 [(store (add (loadi32 addr:$dst), 1), addr:$dst),
1298 (implicit EFLAGS)]>,
Evan Cheng4a7e72f2007-10-19 21:23:22 +00001299 Requires<[In32BitMode]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001300}
1301
1302let CodeSize = 2 in
Dan Gohman91888f02007-07-31 20:11:57 +00001303def DEC8r : I<0xFE, MRM1r, (outs GR8 :$dst), (ins GR8 :$src), "dec{b}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001304 [(set GR8:$dst, (add GR8:$src, -1)),
1305 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001306let isConvertibleToThreeAddress = 1, CodeSize = 1 in { // Can xform into LEA.
Dan Gohman91888f02007-07-31 20:11:57 +00001307def DEC16r : I<0x48, AddRegFrm, (outs GR16:$dst), (ins GR16:$src), "dec{w}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001308 [(set GR16:$dst, (add GR16:$src, -1)),
1309 (implicit EFLAGS)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001310 OpSize, Requires<[In32BitMode]>;
Dan Gohman91888f02007-07-31 20:11:57 +00001311def DEC32r : I<0x48, AddRegFrm, (outs GR32:$dst), (ins GR32:$src), "dec{l}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001312 [(set GR32:$dst, (add GR32:$src, -1)),
1313 (implicit EFLAGS)]>, Requires<[In32BitMode]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001314}
1315
1316let isTwoAddress = 0, CodeSize = 2 in {
Dan Gohman91888f02007-07-31 20:11:57 +00001317 def DEC8m : I<0xFE, MRM1m, (outs), (ins i8mem :$dst), "dec{b}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001318 [(store (add (loadi8 addr:$dst), -1), addr:$dst),
1319 (implicit EFLAGS)]>;
Dan Gohman91888f02007-07-31 20:11:57 +00001320 def DEC16m : I<0xFF, MRM1m, (outs), (ins i16mem:$dst), "dec{w}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001321 [(store (add (loadi16 addr:$dst), -1), addr:$dst),
1322 (implicit EFLAGS)]>,
Evan Cheng4a7e72f2007-10-19 21:23:22 +00001323 OpSize, Requires<[In32BitMode]>;
Dan Gohman91888f02007-07-31 20:11:57 +00001324 def DEC32m : I<0xFF, MRM1m, (outs), (ins i32mem:$dst), "dec{l}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001325 [(store (add (loadi32 addr:$dst), -1), addr:$dst),
1326 (implicit EFLAGS)]>,
Evan Cheng4a7e72f2007-10-19 21:23:22 +00001327 Requires<[In32BitMode]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001328}
Evan Cheng55687072007-09-14 21:48:26 +00001329} // Defs = [EFLAGS]
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001330
1331// Logical operators...
Evan Cheng55687072007-09-14 21:48:26 +00001332let Defs = [EFLAGS] in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001333let isCommutable = 1 in { // X = AND Y, Z --> X = AND Z, Y
1334def AND8rr : I<0x20, MRMDestReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001335 (outs GR8 :$dst), (ins GR8 :$src1, GR8 :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001336 "and{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001337 [(set GR8:$dst, (and GR8:$src1, GR8:$src2)),
1338 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001339def AND16rr : I<0x21, MRMDestReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001340 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001341 "and{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001342 [(set GR16:$dst, (and GR16:$src1, GR16:$src2)),
1343 (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001344def AND32rr : I<0x21, MRMDestReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001345 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001346 "and{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001347 [(set GR32:$dst, (and GR32:$src1, GR32:$src2)),
1348 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001349}
1350
1351def AND8rm : I<0x22, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001352 (outs GR8 :$dst), (ins GR8 :$src1, i8mem :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001353 "and{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001354 [(set GR8:$dst, (and GR8:$src1, (load addr:$src2))),
1355 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001356def AND16rm : I<0x23, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001357 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001358 "and{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001359 [(set GR16:$dst, (and GR16:$src1, (load addr:$src2))),
1360 (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001361def AND32rm : I<0x23, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001362 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001363 "and{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001364 [(set GR32:$dst, (and GR32:$src1, (load addr:$src2))),
1365 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001366
1367def AND8ri : Ii8<0x80, MRM4r,
Evan Chengb783fa32007-07-19 01:14:50 +00001368 (outs GR8 :$dst), (ins GR8 :$src1, i8imm :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001369 "and{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001370 [(set GR8:$dst, (and GR8:$src1, imm:$src2)),
1371 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001372def AND16ri : Ii16<0x81, MRM4r,
Evan Chengb783fa32007-07-19 01:14:50 +00001373 (outs GR16:$dst), (ins GR16:$src1, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001374 "and{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001375 [(set GR16:$dst, (and GR16:$src1, imm:$src2)),
1376 (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001377def AND32ri : Ii32<0x81, MRM4r,
Evan Chengb783fa32007-07-19 01:14:50 +00001378 (outs GR32:$dst), (ins GR32:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001379 "and{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001380 [(set GR32:$dst, (and GR32:$src1, imm:$src2)),
1381 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001382def AND16ri8 : Ii8<0x83, MRM4r,
Evan Chengb783fa32007-07-19 01:14:50 +00001383 (outs GR16:$dst), (ins GR16:$src1, i16i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001384 "and{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001385 [(set GR16:$dst, (and GR16:$src1, i16immSExt8:$src2)),
1386 (implicit EFLAGS)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001387 OpSize;
1388def AND32ri8 : Ii8<0x83, MRM4r,
Evan Chengb783fa32007-07-19 01:14:50 +00001389 (outs GR32:$dst), (ins GR32:$src1, i32i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001390 "and{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001391 [(set GR32:$dst, (and GR32:$src1, i32immSExt8:$src2)),
1392 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001393
1394let isTwoAddress = 0 in {
1395 def AND8mr : I<0x20, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001396 (outs), (ins i8mem :$dst, GR8 :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001397 "and{b}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001398 [(store (and (load addr:$dst), GR8:$src), addr:$dst),
1399 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001400 def AND16mr : I<0x21, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001401 (outs), (ins i16mem:$dst, GR16:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001402 "and{w}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001403 [(store (and (load addr:$dst), GR16:$src), addr:$dst),
1404 (implicit EFLAGS)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001405 OpSize;
1406 def AND32mr : I<0x21, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001407 (outs), (ins i32mem:$dst, GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001408 "and{l}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001409 [(store (and (load addr:$dst), GR32:$src), addr:$dst),
1410 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001411 def AND8mi : Ii8<0x80, MRM4m,
Evan Chengb783fa32007-07-19 01:14:50 +00001412 (outs), (ins i8mem :$dst, i8imm :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001413 "and{b}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001414 [(store (and (loadi8 addr:$dst), imm:$src), addr:$dst),
1415 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001416 def AND16mi : Ii16<0x81, MRM4m,
Evan Chengb783fa32007-07-19 01:14:50 +00001417 (outs), (ins i16mem:$dst, i16imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001418 "and{w}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001419 [(store (and (loadi16 addr:$dst), imm:$src), addr:$dst),
1420 (implicit EFLAGS)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001421 OpSize;
1422 def AND32mi : Ii32<0x81, MRM4m,
Evan Chengb783fa32007-07-19 01:14:50 +00001423 (outs), (ins i32mem:$dst, i32imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001424 "and{l}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001425 [(store (and (loadi32 addr:$dst), imm:$src), addr:$dst),
1426 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001427 def AND16mi8 : Ii8<0x83, MRM4m,
Evan Chengb783fa32007-07-19 01:14:50 +00001428 (outs), (ins i16mem:$dst, i16i8imm :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001429 "and{w}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001430 [(store (and (load addr:$dst), i16immSExt8:$src), addr:$dst),
1431 (implicit EFLAGS)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001432 OpSize;
1433 def AND32mi8 : Ii8<0x83, MRM4m,
Evan Chengb783fa32007-07-19 01:14:50 +00001434 (outs), (ins i32mem:$dst, i32i8imm :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001435 "and{l}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001436 [(store (and (load addr:$dst), i32immSExt8:$src), addr:$dst),
1437 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001438}
1439
1440
1441let isCommutable = 1 in { // X = OR Y, Z --> X = OR Z, Y
Evan Chengb783fa32007-07-19 01:14:50 +00001442def OR8rr : I<0x08, MRMDestReg, (outs GR8 :$dst), (ins GR8 :$src1, GR8 :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001443 "or{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001444 [(set GR8:$dst, (or GR8:$src1, GR8:$src2)),
1445 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001446def OR16rr : I<0x09, MRMDestReg, (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001447 "or{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001448 [(set GR16:$dst, (or GR16:$src1, GR16:$src2)),
1449 (implicit EFLAGS)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001450def OR32rr : I<0x09, MRMDestReg, (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001451 "or{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001452 [(set GR32:$dst, (or GR32:$src1, GR32:$src2)),
1453 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001454}
Evan Chengb783fa32007-07-19 01:14:50 +00001455def OR8rm : I<0x0A, MRMSrcMem , (outs GR8 :$dst), (ins GR8 :$src1, i8mem :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001456 "or{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001457 [(set GR8:$dst, (or GR8:$src1, (load addr:$src2))),
1458 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001459def OR16rm : I<0x0B, MRMSrcMem , (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001460 "or{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001461 [(set GR16:$dst, (or GR16:$src1, (load addr:$src2))),
1462 (implicit EFLAGS)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001463def OR32rm : I<0x0B, MRMSrcMem , (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001464 "or{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001465 [(set GR32:$dst, (or GR32:$src1, (load addr:$src2))),
1466 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001467
Evan Chengb783fa32007-07-19 01:14:50 +00001468def OR8ri : Ii8 <0x80, MRM1r, (outs GR8 :$dst), (ins GR8 :$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001469 "or{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001470 [(set GR8:$dst, (or GR8:$src1, imm:$src2)),
1471 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001472def OR16ri : Ii16<0x81, MRM1r, (outs GR16:$dst), (ins GR16:$src1, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001473 "or{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001474 [(set GR16:$dst, (or GR16:$src1, imm:$src2)),
1475 (implicit EFLAGS)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001476def OR32ri : Ii32<0x81, MRM1r, (outs GR32:$dst), (ins GR32:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001477 "or{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001478 [(set GR32:$dst, (or GR32:$src1, imm:$src2)),
1479 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001480
Evan Chengb783fa32007-07-19 01:14:50 +00001481def OR16ri8 : Ii8<0x83, MRM1r, (outs GR16:$dst), (ins GR16:$src1, i16i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001482 "or{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001483 [(set GR16:$dst, (or GR16:$src1, i16immSExt8:$src2)),
1484 (implicit EFLAGS)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001485def OR32ri8 : Ii8<0x83, MRM1r, (outs GR32:$dst), (ins GR32:$src1, i32i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001486 "or{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001487 [(set GR32:$dst, (or GR32:$src1, i32immSExt8:$src2)),
1488 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001489let isTwoAddress = 0 in {
Evan Chengb783fa32007-07-19 01:14:50 +00001490 def OR8mr : I<0x08, MRMDestMem, (outs), (ins i8mem:$dst, GR8:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001491 "or{b}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001492 [(store (or (load addr:$dst), GR8:$src), addr:$dst),
1493 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001494 def OR16mr : I<0x09, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001495 "or{w}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001496 [(store (or (load addr:$dst), GR16:$src), addr:$dst),
1497 (implicit EFLAGS)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001498 def OR32mr : I<0x09, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001499 "or{l}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001500 [(store (or (load addr:$dst), GR32:$src), addr:$dst),
1501 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001502 def OR8mi : Ii8<0x80, MRM1m, (outs), (ins i8mem :$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001503 "or{b}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001504 [(store (or (loadi8 addr:$dst), imm:$src), addr:$dst),
1505 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001506 def OR16mi : Ii16<0x81, MRM1m, (outs), (ins i16mem:$dst, i16imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001507 "or{w}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001508 [(store (or (loadi16 addr:$dst), imm:$src), addr:$dst),
1509 (implicit EFLAGS)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001510 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001511 def OR32mi : Ii32<0x81, MRM1m, (outs), (ins i32mem:$dst, i32imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001512 "or{l}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001513 [(store (or (loadi32 addr:$dst), imm:$src), addr:$dst),
1514 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001515 def OR16mi8 : Ii8<0x83, MRM1m, (outs), (ins i16mem:$dst, i16i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001516 "or{w}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001517 [(store (or (load addr:$dst), i16immSExt8:$src), addr:$dst),
1518 (implicit EFLAGS)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001519 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001520 def OR32mi8 : Ii8<0x83, MRM1m, (outs), (ins i32mem:$dst, i32i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001521 "or{l}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001522 [(store (or (load addr:$dst), i32immSExt8:$src), addr:$dst),
1523 (implicit EFLAGS)]>;
Bill Wendlingba5d5b02008-05-29 01:02:09 +00001524} // isTwoAddress = 0
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001525
1526
Evan Cheng6f26e8b2008-06-18 08:13:07 +00001527let isCommutable = 1 in { // X = XOR Y, Z --> X = XOR Z, Y
Bill Wendlingba5d5b02008-05-29 01:02:09 +00001528 def XOR8rr : I<0x30, MRMDestReg,
1529 (outs GR8 :$dst), (ins GR8 :$src1, GR8 :$src2),
1530 "xor{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001531 [(set GR8:$dst, (xor GR8:$src1, GR8:$src2)),
1532 (implicit EFLAGS)]>;
Bill Wendlingba5d5b02008-05-29 01:02:09 +00001533 def XOR16rr : I<0x31, MRMDestReg,
1534 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
1535 "xor{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001536 [(set GR16:$dst, (xor GR16:$src1, GR16:$src2)),
1537 (implicit EFLAGS)]>, OpSize;
Bill Wendlingba5d5b02008-05-29 01:02:09 +00001538 def XOR32rr : I<0x31, MRMDestReg,
1539 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
1540 "xor{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001541 [(set GR32:$dst, (xor GR32:$src1, GR32:$src2)),
1542 (implicit EFLAGS)]>;
Evan Cheng6f26e8b2008-06-18 08:13:07 +00001543} // isCommutable = 1
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001544
1545def XOR8rm : I<0x32, MRMSrcMem ,
Evan Chengb783fa32007-07-19 01:14:50 +00001546 (outs GR8 :$dst), (ins GR8:$src1, i8mem :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001547 "xor{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001548 [(set GR8:$dst, (xor GR8:$src1, (load addr:$src2))),
1549 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001550def XOR16rm : I<0x33, MRMSrcMem ,
Evan Chengb783fa32007-07-19 01:14:50 +00001551 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001552 "xor{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001553 [(set GR16:$dst, (xor GR16:$src1, (load addr:$src2))),
1554 (implicit EFLAGS)]>,
Bill Wendlingba5d5b02008-05-29 01:02:09 +00001555 OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001556def XOR32rm : I<0x33, MRMSrcMem ,
Evan Chengb783fa32007-07-19 01:14:50 +00001557 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001558 "xor{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001559 [(set GR32:$dst, (xor GR32:$src1, (load addr:$src2))),
1560 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001561
Bill Wendlingbac38eb2008-05-29 03:46:36 +00001562def XOR8ri : Ii8<0x80, MRM6r,
1563 (outs GR8:$dst), (ins GR8:$src1, i8imm:$src2),
1564 "xor{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001565 [(set GR8:$dst, (xor GR8:$src1, imm:$src2)),
1566 (implicit EFLAGS)]>;
Bill Wendlingbac38eb2008-05-29 03:46:36 +00001567def XOR16ri : Ii16<0x81, MRM6r,
1568 (outs GR16:$dst), (ins GR16:$src1, i16imm:$src2),
1569 "xor{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001570 [(set GR16:$dst, (xor GR16:$src1, imm:$src2)),
1571 (implicit EFLAGS)]>, OpSize;
Bill Wendlingbac38eb2008-05-29 03:46:36 +00001572def XOR32ri : Ii32<0x81, MRM6r,
1573 (outs GR32:$dst), (ins GR32:$src1, i32imm:$src2),
1574 "xor{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001575 [(set GR32:$dst, (xor GR32:$src1, imm:$src2)),
1576 (implicit EFLAGS)]>;
Bill Wendlingbac38eb2008-05-29 03:46:36 +00001577def XOR16ri8 : Ii8<0x83, MRM6r,
1578 (outs GR16:$dst), (ins GR16:$src1, i16i8imm:$src2),
1579 "xor{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001580 [(set GR16:$dst, (xor GR16:$src1, i16immSExt8:$src2)),
1581 (implicit EFLAGS)]>,
Bill Wendlingbac38eb2008-05-29 03:46:36 +00001582 OpSize;
1583def XOR32ri8 : Ii8<0x83, MRM6r,
1584 (outs GR32:$dst), (ins GR32:$src1, i32i8imm:$src2),
1585 "xor{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001586 [(set GR32:$dst, (xor GR32:$src1, i32immSExt8:$src2)),
1587 (implicit EFLAGS)]>;
Bill Wendlingba5d5b02008-05-29 01:02:09 +00001588
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001589let isTwoAddress = 0 in {
1590 def XOR8mr : I<0x30, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001591 (outs), (ins i8mem :$dst, GR8 :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001592 "xor{b}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001593 [(store (xor (load addr:$dst), GR8:$src), addr:$dst),
1594 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001595 def XOR16mr : I<0x31, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001596 (outs), (ins i16mem:$dst, GR16:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001597 "xor{w}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001598 [(store (xor (load addr:$dst), GR16:$src), addr:$dst),
1599 (implicit EFLAGS)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001600 OpSize;
1601 def XOR32mr : I<0x31, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001602 (outs), (ins i32mem:$dst, GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001603 "xor{l}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001604 [(store (xor (load addr:$dst), GR32:$src), addr:$dst),
1605 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001606 def XOR8mi : Ii8<0x80, MRM6m,
Evan Chengb783fa32007-07-19 01:14:50 +00001607 (outs), (ins i8mem :$dst, i8imm :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001608 "xor{b}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001609 [(store (xor (loadi8 addr:$dst), imm:$src), addr:$dst),
1610 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001611 def XOR16mi : Ii16<0x81, MRM6m,
Evan Chengb783fa32007-07-19 01:14:50 +00001612 (outs), (ins i16mem:$dst, i16imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001613 "xor{w}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001614 [(store (xor (loadi16 addr:$dst), imm:$src), addr:$dst),
1615 (implicit EFLAGS)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001616 OpSize;
1617 def XOR32mi : Ii32<0x81, MRM6m,
Evan Chengb783fa32007-07-19 01:14:50 +00001618 (outs), (ins i32mem:$dst, i32imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001619 "xor{l}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001620 [(store (xor (loadi32 addr:$dst), imm:$src), addr:$dst),
1621 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001622 def XOR16mi8 : Ii8<0x83, MRM6m,
Evan Chengb783fa32007-07-19 01:14:50 +00001623 (outs), (ins i16mem:$dst, i16i8imm :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001624 "xor{w}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001625 [(store (xor (load addr:$dst), i16immSExt8:$src), addr:$dst),
1626 (implicit EFLAGS)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001627 OpSize;
1628 def XOR32mi8 : Ii8<0x83, MRM6m,
Evan Chengb783fa32007-07-19 01:14:50 +00001629 (outs), (ins i32mem:$dst, i32i8imm :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001630 "xor{l}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001631 [(store (xor (load addr:$dst), i32immSExt8:$src), addr:$dst),
1632 (implicit EFLAGS)]>;
Bill Wendlingba5d5b02008-05-29 01:02:09 +00001633} // isTwoAddress = 0
Evan Cheng55687072007-09-14 21:48:26 +00001634} // Defs = [EFLAGS]
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001635
1636// Shift instructions
Evan Cheng55687072007-09-14 21:48:26 +00001637let Defs = [EFLAGS] in {
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001638let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00001639def SHL8rCL : I<0xD2, MRM4r, (outs GR8 :$dst), (ins GR8 :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001640 "shl{b}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001641 [(set GR8:$dst, (shl GR8:$src, CL))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001642def SHL16rCL : I<0xD3, MRM4r, (outs GR16:$dst), (ins GR16:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001643 "shl{w}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001644 [(set GR16:$dst, (shl GR16:$src, CL))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001645def SHL32rCL : I<0xD3, MRM4r, (outs GR32:$dst), (ins GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001646 "shl{l}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001647 [(set GR32:$dst, (shl GR32:$src, CL))]>;
Bill Wendlingba5d5b02008-05-29 01:02:09 +00001648} // Uses = [CL]
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001649
Evan Chengb783fa32007-07-19 01:14:50 +00001650def SHL8ri : Ii8<0xC0, MRM4r, (outs GR8 :$dst), (ins GR8 :$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001651 "shl{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001652 [(set GR8:$dst, (shl GR8:$src1, (i8 imm:$src2)))]>;
1653let isConvertibleToThreeAddress = 1 in { // Can transform into LEA.
Evan Chengb783fa32007-07-19 01:14:50 +00001654def SHL16ri : Ii8<0xC1, MRM4r, (outs GR16:$dst), (ins GR16:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001655 "shl{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001656 [(set GR16:$dst, (shl GR16:$src1, (i8 imm:$src2)))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001657def SHL32ri : Ii8<0xC1, MRM4r, (outs GR32:$dst), (ins GR32:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001658 "shl{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001659 [(set GR32:$dst, (shl GR32:$src1, (i8 imm:$src2)))]>;
Chris Lattnerf4005a82008-01-11 18:00:50 +00001660// NOTE: We don't use shifts of a register by one, because 'add reg,reg' is
1661// cheaper.
Bill Wendlingba5d5b02008-05-29 01:02:09 +00001662} // isConvertibleToThreeAddress = 1
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001663
1664let isTwoAddress = 0 in {
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001665 let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00001666 def SHL8mCL : I<0xD2, MRM4m, (outs), (ins i8mem :$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001667 "shl{b}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001668 [(store (shl (loadi8 addr:$dst), CL), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001669 def SHL16mCL : I<0xD3, MRM4m, (outs), (ins i16mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001670 "shl{w}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001671 [(store (shl (loadi16 addr:$dst), CL), addr:$dst)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001672 def SHL32mCL : I<0xD3, MRM4m, (outs), (ins i32mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001673 "shl{l}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001674 [(store (shl (loadi32 addr:$dst), CL), addr:$dst)]>;
1675 }
Evan Chengb783fa32007-07-19 01:14:50 +00001676 def SHL8mi : Ii8<0xC0, MRM4m, (outs), (ins i8mem :$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001677 "shl{b}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001678 [(store (shl (loadi8 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001679 def SHL16mi : Ii8<0xC1, MRM4m, (outs), (ins i16mem:$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001680 "shl{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001681 [(store (shl (loadi16 addr:$dst), (i8 imm:$src)), addr:$dst)]>,
1682 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001683 def SHL32mi : Ii8<0xC1, MRM4m, (outs), (ins i32mem:$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001684 "shl{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001685 [(store (shl (loadi32 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
1686
1687 // Shift by 1
Evan Chengb783fa32007-07-19 01:14:50 +00001688 def SHL8m1 : I<0xD0, MRM4m, (outs), (ins i8mem :$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001689 "shl{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001690 [(store (shl (loadi8 addr:$dst), (i8 1)), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001691 def SHL16m1 : I<0xD1, MRM4m, (outs), (ins i16mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001692 "shl{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001693 [(store (shl (loadi16 addr:$dst), (i8 1)), addr:$dst)]>,
1694 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001695 def SHL32m1 : I<0xD1, MRM4m, (outs), (ins i32mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001696 "shl{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001697 [(store (shl (loadi32 addr:$dst), (i8 1)), addr:$dst)]>;
1698}
1699
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001700let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00001701def SHR8rCL : I<0xD2, MRM5r, (outs GR8 :$dst), (ins GR8 :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001702 "shr{b}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001703 [(set GR8:$dst, (srl GR8:$src, CL))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001704def SHR16rCL : I<0xD3, MRM5r, (outs GR16:$dst), (ins GR16:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001705 "shr{w}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001706 [(set GR16:$dst, (srl GR16:$src, CL))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001707def SHR32rCL : I<0xD3, MRM5r, (outs GR32:$dst), (ins GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001708 "shr{l}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001709 [(set GR32:$dst, (srl GR32:$src, CL))]>;
1710}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001711
Evan Chengb783fa32007-07-19 01:14:50 +00001712def SHR8ri : Ii8<0xC0, MRM5r, (outs GR8:$dst), (ins GR8:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001713 "shr{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001714 [(set GR8:$dst, (srl GR8:$src1, (i8 imm:$src2)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001715def SHR16ri : Ii8<0xC1, MRM5r, (outs GR16:$dst), (ins GR16:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001716 "shr{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001717 [(set GR16:$dst, (srl GR16:$src1, (i8 imm:$src2)))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001718def SHR32ri : Ii8<0xC1, MRM5r, (outs GR32:$dst), (ins GR32:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001719 "shr{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001720 [(set GR32:$dst, (srl GR32:$src1, (i8 imm:$src2)))]>;
1721
1722// Shift by 1
Evan Chengb783fa32007-07-19 01:14:50 +00001723def SHR8r1 : I<0xD0, MRM5r, (outs GR8:$dst), (ins GR8:$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00001724 "shr{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001725 [(set GR8:$dst, (srl GR8:$src1, (i8 1)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001726def SHR16r1 : I<0xD1, MRM5r, (outs GR16:$dst), (ins GR16:$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00001727 "shr{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001728 [(set GR16:$dst, (srl GR16:$src1, (i8 1)))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001729def SHR32r1 : I<0xD1, MRM5r, (outs GR32:$dst), (ins GR32:$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00001730 "shr{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001731 [(set GR32:$dst, (srl GR32:$src1, (i8 1)))]>;
1732
1733let isTwoAddress = 0 in {
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001734 let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00001735 def SHR8mCL : I<0xD2, MRM5m, (outs), (ins i8mem :$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001736 "shr{b}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001737 [(store (srl (loadi8 addr:$dst), CL), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001738 def SHR16mCL : I<0xD3, MRM5m, (outs), (ins i16mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001739 "shr{w}\t{%cl, $dst|$dst, %CL}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001740 [(store (srl (loadi16 addr:$dst), CL), addr:$dst)]>,
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001741 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001742 def SHR32mCL : I<0xD3, MRM5m, (outs), (ins i32mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001743 "shr{l}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001744 [(store (srl (loadi32 addr:$dst), CL), addr:$dst)]>;
1745 }
Evan Chengb783fa32007-07-19 01:14:50 +00001746 def SHR8mi : Ii8<0xC0, MRM5m, (outs), (ins i8mem :$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001747 "shr{b}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001748 [(store (srl (loadi8 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001749 def SHR16mi : Ii8<0xC1, MRM5m, (outs), (ins i16mem:$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001750 "shr{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001751 [(store (srl (loadi16 addr:$dst), (i8 imm:$src)), addr:$dst)]>,
1752 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001753 def SHR32mi : Ii8<0xC1, MRM5m, (outs), (ins i32mem:$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001754 "shr{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001755 [(store (srl (loadi32 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
1756
1757 // Shift by 1
Evan Chengb783fa32007-07-19 01:14:50 +00001758 def SHR8m1 : I<0xD0, MRM5m, (outs), (ins i8mem :$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001759 "shr{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001760 [(store (srl (loadi8 addr:$dst), (i8 1)), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001761 def SHR16m1 : I<0xD1, MRM5m, (outs), (ins i16mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001762 "shr{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001763 [(store (srl (loadi16 addr:$dst), (i8 1)), addr:$dst)]>,OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001764 def SHR32m1 : I<0xD1, MRM5m, (outs), (ins i32mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001765 "shr{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001766 [(store (srl (loadi32 addr:$dst), (i8 1)), addr:$dst)]>;
1767}
1768
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001769let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00001770def SAR8rCL : I<0xD2, MRM7r, (outs GR8 :$dst), (ins GR8 :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001771 "sar{b}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001772 [(set GR8:$dst, (sra GR8:$src, CL))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001773def SAR16rCL : I<0xD3, MRM7r, (outs GR16:$dst), (ins GR16:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001774 "sar{w}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001775 [(set GR16:$dst, (sra GR16:$src, CL))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001776def SAR32rCL : I<0xD3, MRM7r, (outs GR32:$dst), (ins GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001777 "sar{l}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001778 [(set GR32:$dst, (sra GR32:$src, CL))]>;
1779}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001780
Evan Chengb783fa32007-07-19 01:14:50 +00001781def SAR8ri : Ii8<0xC0, MRM7r, (outs GR8 :$dst), (ins GR8 :$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001782 "sar{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001783 [(set GR8:$dst, (sra GR8:$src1, (i8 imm:$src2)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001784def SAR16ri : Ii8<0xC1, MRM7r, (outs GR16:$dst), (ins GR16:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001785 "sar{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001786 [(set GR16:$dst, (sra GR16:$src1, (i8 imm:$src2)))]>,
1787 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001788def SAR32ri : Ii8<0xC1, MRM7r, (outs GR32:$dst), (ins GR32:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001789 "sar{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001790 [(set GR32:$dst, (sra GR32:$src1, (i8 imm:$src2)))]>;
1791
1792// Shift by 1
Evan Chengb783fa32007-07-19 01:14:50 +00001793def SAR8r1 : I<0xD0, MRM7r, (outs GR8 :$dst), (ins GR8 :$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00001794 "sar{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001795 [(set GR8:$dst, (sra GR8:$src1, (i8 1)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001796def SAR16r1 : I<0xD1, MRM7r, (outs GR16:$dst), (ins GR16:$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00001797 "sar{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001798 [(set GR16:$dst, (sra GR16:$src1, (i8 1)))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001799def SAR32r1 : I<0xD1, MRM7r, (outs GR32:$dst), (ins GR32:$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00001800 "sar{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001801 [(set GR32:$dst, (sra GR32:$src1, (i8 1)))]>;
1802
1803let isTwoAddress = 0 in {
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001804 let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00001805 def SAR8mCL : I<0xD2, MRM7m, (outs), (ins i8mem :$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001806 "sar{b}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001807 [(store (sra (loadi8 addr:$dst), CL), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001808 def SAR16mCL : I<0xD3, MRM7m, (outs), (ins i16mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001809 "sar{w}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001810 [(store (sra (loadi16 addr:$dst), CL), addr:$dst)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001811 def SAR32mCL : I<0xD3, MRM7m, (outs), (ins i32mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001812 "sar{l}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001813 [(store (sra (loadi32 addr:$dst), CL), addr:$dst)]>;
1814 }
Evan Chengb783fa32007-07-19 01:14:50 +00001815 def SAR8mi : Ii8<0xC0, MRM7m, (outs), (ins i8mem :$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001816 "sar{b}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001817 [(store (sra (loadi8 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001818 def SAR16mi : Ii8<0xC1, MRM7m, (outs), (ins i16mem:$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001819 "sar{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001820 [(store (sra (loadi16 addr:$dst), (i8 imm:$src)), addr:$dst)]>,
1821 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001822 def SAR32mi : Ii8<0xC1, MRM7m, (outs), (ins i32mem:$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001823 "sar{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001824 [(store (sra (loadi32 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
1825
1826 // Shift by 1
Evan Chengb783fa32007-07-19 01:14:50 +00001827 def SAR8m1 : I<0xD0, MRM7m, (outs), (ins i8mem :$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001828 "sar{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001829 [(store (sra (loadi8 addr:$dst), (i8 1)), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001830 def SAR16m1 : I<0xD1, MRM7m, (outs), (ins i16mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001831 "sar{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001832 [(store (sra (loadi16 addr:$dst), (i8 1)), addr:$dst)]>,
1833 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001834 def SAR32m1 : I<0xD1, MRM7m, (outs), (ins i32mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001835 "sar{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001836 [(store (sra (loadi32 addr:$dst), (i8 1)), addr:$dst)]>;
1837}
1838
1839// Rotate instructions
1840// FIXME: provide shorter instructions when imm8 == 1
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001841let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00001842def ROL8rCL : I<0xD2, MRM0r, (outs GR8 :$dst), (ins GR8 :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001843 "rol{b}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001844 [(set GR8:$dst, (rotl GR8:$src, CL))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001845def ROL16rCL : I<0xD3, MRM0r, (outs GR16:$dst), (ins GR16:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001846 "rol{w}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001847 [(set GR16:$dst, (rotl GR16:$src, CL))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001848def ROL32rCL : I<0xD3, MRM0r, (outs GR32:$dst), (ins GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001849 "rol{l}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001850 [(set GR32:$dst, (rotl GR32:$src, CL))]>;
1851}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001852
Evan Chengb783fa32007-07-19 01:14:50 +00001853def ROL8ri : Ii8<0xC0, MRM0r, (outs GR8 :$dst), (ins GR8 :$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001854 "rol{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001855 [(set GR8:$dst, (rotl GR8:$src1, (i8 imm:$src2)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001856def ROL16ri : Ii8<0xC1, MRM0r, (outs GR16:$dst), (ins GR16:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001857 "rol{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001858 [(set GR16:$dst, (rotl GR16:$src1, (i8 imm:$src2)))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001859def ROL32ri : Ii8<0xC1, MRM0r, (outs GR32:$dst), (ins GR32:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001860 "rol{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001861 [(set GR32:$dst, (rotl GR32:$src1, (i8 imm:$src2)))]>;
1862
1863// Rotate by 1
Evan Chengb783fa32007-07-19 01:14:50 +00001864def ROL8r1 : I<0xD0, MRM0r, (outs GR8 :$dst), (ins GR8 :$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00001865 "rol{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001866 [(set GR8:$dst, (rotl GR8:$src1, (i8 1)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001867def ROL16r1 : I<0xD1, MRM0r, (outs GR16:$dst), (ins GR16:$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00001868 "rol{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001869 [(set GR16:$dst, (rotl GR16:$src1, (i8 1)))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001870def ROL32r1 : I<0xD1, MRM0r, (outs GR32:$dst), (ins GR32:$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00001871 "rol{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001872 [(set GR32:$dst, (rotl GR32:$src1, (i8 1)))]>;
1873
1874let isTwoAddress = 0 in {
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001875 let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00001876 def ROL8mCL : I<0xD2, MRM0m, (outs), (ins i8mem :$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001877 "rol{b}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001878 [(store (rotl (loadi8 addr:$dst), CL), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001879 def ROL16mCL : I<0xD3, MRM0m, (outs), (ins i16mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001880 "rol{w}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001881 [(store (rotl (loadi16 addr:$dst), CL), addr:$dst)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001882 def ROL32mCL : I<0xD3, MRM0m, (outs), (ins i32mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001883 "rol{l}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001884 [(store (rotl (loadi32 addr:$dst), CL), addr:$dst)]>;
1885 }
Evan Chengb783fa32007-07-19 01:14:50 +00001886 def ROL8mi : Ii8<0xC0, MRM0m, (outs), (ins i8mem :$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001887 "rol{b}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001888 [(store (rotl (loadi8 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001889 def ROL16mi : Ii8<0xC1, MRM0m, (outs), (ins i16mem:$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001890 "rol{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001891 [(store (rotl (loadi16 addr:$dst), (i8 imm:$src)), addr:$dst)]>,
1892 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001893 def ROL32mi : Ii8<0xC1, MRM0m, (outs), (ins i32mem:$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001894 "rol{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001895 [(store (rotl (loadi32 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
1896
1897 // Rotate by 1
Evan Chengb783fa32007-07-19 01:14:50 +00001898 def ROL8m1 : I<0xD0, MRM0m, (outs), (ins i8mem :$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001899 "rol{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001900 [(store (rotl (loadi8 addr:$dst), (i8 1)), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001901 def ROL16m1 : I<0xD1, MRM0m, (outs), (ins i16mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001902 "rol{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001903 [(store (rotl (loadi16 addr:$dst), (i8 1)), addr:$dst)]>,
1904 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001905 def ROL32m1 : I<0xD1, MRM0m, (outs), (ins i32mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001906 "rol{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001907 [(store (rotl (loadi32 addr:$dst), (i8 1)), addr:$dst)]>;
1908}
1909
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001910let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00001911def ROR8rCL : I<0xD2, MRM1r, (outs GR8 :$dst), (ins GR8 :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001912 "ror{b}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001913 [(set GR8:$dst, (rotr GR8:$src, CL))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001914def ROR16rCL : I<0xD3, MRM1r, (outs GR16:$dst), (ins GR16:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001915 "ror{w}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001916 [(set GR16:$dst, (rotr GR16:$src, CL))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001917def ROR32rCL : I<0xD3, MRM1r, (outs GR32:$dst), (ins GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001918 "ror{l}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001919 [(set GR32:$dst, (rotr GR32:$src, CL))]>;
1920}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001921
Evan Chengb783fa32007-07-19 01:14:50 +00001922def ROR8ri : Ii8<0xC0, MRM1r, (outs GR8 :$dst), (ins GR8 :$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001923 "ror{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001924 [(set GR8:$dst, (rotr GR8:$src1, (i8 imm:$src2)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001925def ROR16ri : Ii8<0xC1, MRM1r, (outs GR16:$dst), (ins GR16:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001926 "ror{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001927 [(set GR16:$dst, (rotr GR16:$src1, (i8 imm:$src2)))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001928def ROR32ri : Ii8<0xC1, MRM1r, (outs GR32:$dst), (ins GR32:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001929 "ror{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001930 [(set GR32:$dst, (rotr GR32:$src1, (i8 imm:$src2)))]>;
1931
1932// Rotate by 1
Evan Chengb783fa32007-07-19 01:14:50 +00001933def ROR8r1 : I<0xD0, MRM1r, (outs GR8 :$dst), (ins GR8 :$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00001934 "ror{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001935 [(set GR8:$dst, (rotr GR8:$src1, (i8 1)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001936def ROR16r1 : I<0xD1, MRM1r, (outs GR16:$dst), (ins GR16:$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00001937 "ror{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001938 [(set GR16:$dst, (rotr GR16:$src1, (i8 1)))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001939def ROR32r1 : I<0xD1, MRM1r, (outs GR32:$dst), (ins GR32:$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00001940 "ror{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001941 [(set GR32:$dst, (rotr GR32:$src1, (i8 1)))]>;
1942
1943let isTwoAddress = 0 in {
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001944 let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00001945 def ROR8mCL : I<0xD2, MRM1m, (outs), (ins i8mem :$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001946 "ror{b}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001947 [(store (rotr (loadi8 addr:$dst), CL), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001948 def ROR16mCL : I<0xD3, MRM1m, (outs), (ins i16mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001949 "ror{w}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001950 [(store (rotr (loadi16 addr:$dst), CL), addr:$dst)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001951 def ROR32mCL : I<0xD3, MRM1m, (outs), (ins i32mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001952 "ror{l}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001953 [(store (rotr (loadi32 addr:$dst), CL), addr:$dst)]>;
1954 }
Evan Chengb783fa32007-07-19 01:14:50 +00001955 def ROR8mi : Ii8<0xC0, MRM1m, (outs), (ins i8mem :$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001956 "ror{b}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001957 [(store (rotr (loadi8 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001958 def ROR16mi : Ii8<0xC1, MRM1m, (outs), (ins i16mem:$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001959 "ror{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001960 [(store (rotr (loadi16 addr:$dst), (i8 imm:$src)), addr:$dst)]>,
1961 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001962 def ROR32mi : Ii8<0xC1, MRM1m, (outs), (ins i32mem:$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001963 "ror{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001964 [(store (rotr (loadi32 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
1965
1966 // Rotate by 1
Evan Chengb783fa32007-07-19 01:14:50 +00001967 def ROR8m1 : I<0xD0, MRM1m, (outs), (ins i8mem :$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001968 "ror{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001969 [(store (rotr (loadi8 addr:$dst), (i8 1)), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001970 def ROR16m1 : I<0xD1, MRM1m, (outs), (ins i16mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001971 "ror{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001972 [(store (rotr (loadi16 addr:$dst), (i8 1)), addr:$dst)]>,
1973 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001974 def ROR32m1 : I<0xD1, MRM1m, (outs), (ins i32mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001975 "ror{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001976 [(store (rotr (loadi32 addr:$dst), (i8 1)), addr:$dst)]>;
1977}
1978
1979
1980
1981// Double shift instructions (generalizations of rotate)
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001982let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00001983def SHLD32rrCL : I<0xA5, MRMDestReg, (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001984 "shld{l}\t{%cl, $src2, $dst|$dst, $src2, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001985 [(set GR32:$dst, (X86shld GR32:$src1, GR32:$src2, CL))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00001986def SHRD32rrCL : I<0xAD, MRMDestReg, (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001987 "shrd{l}\t{%cl, $src2, $dst|$dst, $src2, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001988 [(set GR32:$dst, (X86shrd GR32:$src1, GR32:$src2, CL))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00001989def SHLD16rrCL : I<0xA5, MRMDestReg, (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001990 "shld{w}\t{%cl, $src2, $dst|$dst, $src2, %CL}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001991 [(set GR16:$dst, (X86shld GR16:$src1, GR16:$src2, CL))]>,
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001992 TB, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001993def SHRD16rrCL : I<0xAD, MRMDestReg, (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001994 "shrd{w}\t{%cl, $src2, $dst|$dst, $src2, %CL}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001995 [(set GR16:$dst, (X86shrd GR16:$src1, GR16:$src2, CL))]>,
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001996 TB, OpSize;
1997}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001998
1999let isCommutable = 1 in { // These instructions commute to each other.
2000def SHLD32rri8 : Ii8<0xA4, MRMDestReg,
Evan Chengb783fa32007-07-19 01:14:50 +00002001 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2, i8imm:$src3),
Dan Gohman91888f02007-07-31 20:11:57 +00002002 "shld{l}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002003 [(set GR32:$dst, (X86shld GR32:$src1, GR32:$src2,
2004 (i8 imm:$src3)))]>,
2005 TB;
2006def SHRD32rri8 : Ii8<0xAC, MRMDestReg,
Evan Chengb783fa32007-07-19 01:14:50 +00002007 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2, i8imm:$src3),
Dan Gohman91888f02007-07-31 20:11:57 +00002008 "shrd{l}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002009 [(set GR32:$dst, (X86shrd GR32:$src1, GR32:$src2,
2010 (i8 imm:$src3)))]>,
2011 TB;
2012def SHLD16rri8 : Ii8<0xA4, MRMDestReg,
Evan Chengb783fa32007-07-19 01:14:50 +00002013 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2, i8imm:$src3),
Dan Gohman91888f02007-07-31 20:11:57 +00002014 "shld{w}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002015 [(set GR16:$dst, (X86shld GR16:$src1, GR16:$src2,
2016 (i8 imm:$src3)))]>,
2017 TB, OpSize;
2018def SHRD16rri8 : Ii8<0xAC, MRMDestReg,
Evan Chengb783fa32007-07-19 01:14:50 +00002019 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2, i8imm:$src3),
Dan Gohman91888f02007-07-31 20:11:57 +00002020 "shrd{w}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002021 [(set GR16:$dst, (X86shrd GR16:$src1, GR16:$src2,
2022 (i8 imm:$src3)))]>,
2023 TB, OpSize;
2024}
2025
2026let isTwoAddress = 0 in {
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002027 let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00002028 def SHLD32mrCL : I<0xA5, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002029 "shld{l}\t{%cl, $src2, $dst|$dst, $src2, %CL}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002030 [(store (X86shld (loadi32 addr:$dst), GR32:$src2, CL),
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002031 addr:$dst)]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00002032 def SHRD32mrCL : I<0xAD, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002033 "shrd{l}\t{%cl, $src2, $dst|$dst, $src2, %CL}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002034 [(store (X86shrd (loadi32 addr:$dst), GR32:$src2, CL),
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002035 addr:$dst)]>, TB;
2036 }
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002037 def SHLD32mri8 : Ii8<0xA4, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00002038 (outs), (ins i32mem:$dst, GR32:$src2, i8imm:$src3),
Dan Gohman91888f02007-07-31 20:11:57 +00002039 "shld{l}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002040 [(store (X86shld (loadi32 addr:$dst), GR32:$src2,
2041 (i8 imm:$src3)), addr:$dst)]>,
2042 TB;
2043 def SHRD32mri8 : Ii8<0xAC, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00002044 (outs), (ins i32mem:$dst, GR32:$src2, i8imm:$src3),
Dan Gohman91888f02007-07-31 20:11:57 +00002045 "shrd{l}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002046 [(store (X86shrd (loadi32 addr:$dst), GR32:$src2,
2047 (i8 imm:$src3)), addr:$dst)]>,
2048 TB;
2049
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002050 let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00002051 def SHLD16mrCL : I<0xA5, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002052 "shld{w}\t{%cl, $src2, $dst|$dst, $src2, %CL}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002053 [(store (X86shld (loadi16 addr:$dst), GR16:$src2, CL),
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002054 addr:$dst)]>, TB, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002055 def SHRD16mrCL : I<0xAD, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002056 "shrd{w}\t{%cl, $src2, $dst|$dst, $src2, %CL}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002057 [(store (X86shrd (loadi16 addr:$dst), GR16:$src2, CL),
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002058 addr:$dst)]>, TB, OpSize;
2059 }
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002060 def SHLD16mri8 : Ii8<0xA4, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00002061 (outs), (ins i16mem:$dst, GR16:$src2, i8imm:$src3),
Dan Gohman91888f02007-07-31 20:11:57 +00002062 "shld{w}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002063 [(store (X86shld (loadi16 addr:$dst), GR16:$src2,
2064 (i8 imm:$src3)), addr:$dst)]>,
2065 TB, OpSize;
2066 def SHRD16mri8 : Ii8<0xAC, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00002067 (outs), (ins i16mem:$dst, GR16:$src2, i8imm:$src3),
Dan Gohman91888f02007-07-31 20:11:57 +00002068 "shrd{w}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002069 [(store (X86shrd (loadi16 addr:$dst), GR16:$src2,
2070 (i8 imm:$src3)), addr:$dst)]>,
2071 TB, OpSize;
2072}
Evan Cheng55687072007-09-14 21:48:26 +00002073} // Defs = [EFLAGS]
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002074
2075
2076// Arithmetic.
Evan Cheng55687072007-09-14 21:48:26 +00002077let Defs = [EFLAGS] in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002078let isCommutable = 1 in { // X = ADD Y, Z --> X = ADD Z, Y
Bill Wendlingae034ed2008-12-12 00:56:36 +00002079// Register-Register Addition
2080def ADD8rr : I<0x00, MRMDestReg, (outs GR8 :$dst),
2081 (ins GR8 :$src1, GR8 :$src2),
2082 "add{b}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002083 [(set GR8:$dst, (add GR8:$src1, GR8:$src2)),
Bill Wendlingae034ed2008-12-12 00:56:36 +00002084 (implicit EFLAGS)]>;
2085
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002086let isConvertibleToThreeAddress = 1 in { // Can transform into LEA.
Bill Wendlingae034ed2008-12-12 00:56:36 +00002087// Register-Register Addition
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002088def ADD16rr : I<0x01, MRMDestReg, (outs GR16:$dst),
2089 (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002090 "add{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002091 [(set GR16:$dst, (add GR16:$src1, GR16:$src2)),
2092 (implicit EFLAGS)]>, OpSize;
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002093def ADD32rr : I<0x01, MRMDestReg, (outs GR32:$dst),
2094 (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002095 "add{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002096 [(set GR32:$dst, (add GR32:$src1, GR32:$src2)),
2097 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002098} // end isConvertibleToThreeAddress
2099} // end isCommutable
Bill Wendlingae034ed2008-12-12 00:56:36 +00002100
2101// Register-Memory Addition
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002102def ADD8rm : I<0x02, MRMSrcMem, (outs GR8 :$dst),
2103 (ins GR8 :$src1, i8mem :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002104 "add{b}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002105 [(set GR8:$dst, (add GR8:$src1, (load addr:$src2))),
2106 (implicit EFLAGS)]>;
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002107def ADD16rm : I<0x03, MRMSrcMem, (outs GR16:$dst),
2108 (ins GR16:$src1, i16mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002109 "add{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002110 [(set GR16:$dst, (add GR16:$src1, (load addr:$src2))),
2111 (implicit EFLAGS)]>, OpSize;
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002112def ADD32rm : I<0x03, MRMSrcMem, (outs GR32:$dst),
2113 (ins GR32:$src1, i32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002114 "add{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002115 [(set GR32:$dst, (add GR32:$src1, (load addr:$src2))),
2116 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002117
Bill Wendlingae034ed2008-12-12 00:56:36 +00002118// Register-Integer Addition
2119def ADD8ri : Ii8<0x80, MRM0r, (outs GR8:$dst), (ins GR8:$src1, i8imm:$src2),
2120 "add{b}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002121 [(set GR8:$dst, (add GR8:$src1, imm:$src2)),
2122 (implicit EFLAGS)]>;
Bill Wendlingae034ed2008-12-12 00:56:36 +00002123
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002124let isConvertibleToThreeAddress = 1 in { // Can transform into LEA.
Bill Wendlingae034ed2008-12-12 00:56:36 +00002125// Register-Integer Addition
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002126def ADD16ri : Ii16<0x81, MRM0r, (outs GR16:$dst),
2127 (ins GR16:$src1, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002128 "add{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002129 [(set GR16:$dst, (add GR16:$src1, imm:$src2)),
2130 (implicit EFLAGS)]>, OpSize;
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002131def ADD32ri : Ii32<0x81, MRM0r, (outs GR32:$dst),
2132 (ins GR32:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002133 "add{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002134 [(set GR32:$dst, (add GR32:$src1, imm:$src2)),
2135 (implicit EFLAGS)]>;
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002136def ADD16ri8 : Ii8<0x83, MRM0r, (outs GR16:$dst),
2137 (ins GR16:$src1, i16i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002138 "add{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002139 [(set GR16:$dst, (add GR16:$src1, i16immSExt8:$src2)),
2140 (implicit EFLAGS)]>, OpSize;
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002141def ADD32ri8 : Ii8<0x83, MRM0r, (outs GR32:$dst),
2142 (ins GR32:$src1, i32i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002143 "add{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002144 [(set GR32:$dst, (add GR32:$src1, i32immSExt8:$src2)),
2145 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002146}
2147
2148let isTwoAddress = 0 in {
Bill Wendlingae034ed2008-12-12 00:56:36 +00002149 // Memory-Register Addition
Bill Wendlingf5399032008-12-12 21:15:41 +00002150 def ADD8mr : I<0x00, MRMDestMem, (outs), (ins i8mem:$dst, GR8:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002151 "add{b}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002152 [(store (add (load addr:$dst), GR8:$src2), addr:$dst),
2153 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002154 def ADD16mr : I<0x01, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002155 "add{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002156 [(store (add (load addr:$dst), GR16:$src2), addr:$dst),
2157 (implicit EFLAGS)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002158 def ADD32mr : I<0x01, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002159 "add{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002160 [(store (add (load addr:$dst), GR32:$src2), addr:$dst),
2161 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002162 def ADD8mi : Ii8<0x80, MRM0m, (outs), (ins i8mem :$dst, i8imm :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002163 "add{b}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002164 [(store (add (loadi8 addr:$dst), imm:$src2), addr:$dst),
2165 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002166 def ADD16mi : Ii16<0x81, MRM0m, (outs), (ins i16mem:$dst, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002167 "add{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002168 [(store (add (loadi16 addr:$dst), imm:$src2), addr:$dst),
2169 (implicit EFLAGS)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002170 def ADD32mi : Ii32<0x81, MRM0m, (outs), (ins i32mem:$dst, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002171 "add{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002172 [(store (add (loadi32 addr:$dst), imm:$src2), addr:$dst),
2173 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002174 def ADD16mi8 : Ii8<0x83, MRM0m, (outs), (ins i16mem:$dst, i16i8imm :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002175 "add{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002176 [(store (add (load addr:$dst), i16immSExt8:$src2),
2177 addr:$dst),
2178 (implicit EFLAGS)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002179 def ADD32mi8 : Ii8<0x83, MRM0m, (outs), (ins i32mem:$dst, i32i8imm :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002180 "add{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingae034ed2008-12-12 00:56:36 +00002181 [(store (add (load addr:$dst), i32immSExt8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00002182 addr:$dst),
2183 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002184}
2185
Evan Cheng259471d2007-10-05 17:59:57 +00002186let Uses = [EFLAGS] in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002187let isCommutable = 1 in { // X = ADC Y, Z --> X = ADC Z, Y
Evan Chengb783fa32007-07-19 01:14:50 +00002188def ADC32rr : I<0x11, MRMDestReg, (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002189 "adc{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingc0ca7f32008-12-01 23:44:08 +00002190 [(set GR32:$dst, (adde GR32:$src1, GR32:$src2))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002191}
Evan Chengb783fa32007-07-19 01:14:50 +00002192def ADC32rm : I<0x13, MRMSrcMem , (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002193 "adc{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingc0ca7f32008-12-01 23:44:08 +00002194 [(set GR32:$dst, (adde GR32:$src1, (load addr:$src2)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002195def ADC32ri : Ii32<0x81, MRM2r, (outs GR32:$dst), (ins GR32:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002196 "adc{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingc0ca7f32008-12-01 23:44:08 +00002197 [(set GR32:$dst, (adde GR32:$src1, imm:$src2))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002198def ADC32ri8 : Ii8<0x83, MRM2r, (outs GR32:$dst), (ins GR32:$src1, i32i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002199 "adc{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingc0ca7f32008-12-01 23:44:08 +00002200 [(set GR32:$dst, (adde GR32:$src1, i32immSExt8:$src2))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002201
2202let isTwoAddress = 0 in {
Evan Chengb783fa32007-07-19 01:14:50 +00002203 def ADC32mr : I<0x11, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002204 "adc{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingc0ca7f32008-12-01 23:44:08 +00002205 [(store (adde (load addr:$dst), GR32:$src2), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002206 def ADC32mi : Ii32<0x81, MRM2m, (outs), (ins i32mem:$dst, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002207 "adc{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingc0ca7f32008-12-01 23:44:08 +00002208 [(store (adde (loadi32 addr:$dst), imm:$src2), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002209 def ADC32mi8 : Ii8<0x83, MRM2m, (outs), (ins i32mem:$dst, i32i8imm :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002210 "adc{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendling0c52d0a2008-12-02 00:07:05 +00002211 [(store (adde (load addr:$dst), i32immSExt8:$src2), addr:$dst)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002212}
Evan Cheng259471d2007-10-05 17:59:57 +00002213} // Uses = [EFLAGS]
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002214
Bill Wendlingae034ed2008-12-12 00:56:36 +00002215// Register-Register Subtraction
2216def SUB8rr : I<0x28, MRMDestReg, (outs GR8:$dst), (ins GR8:$src1, GR8:$src2),
2217 "sub{b}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002218 [(set GR8:$dst, (sub GR8:$src1, GR8:$src2)),
2219 (implicit EFLAGS)]>;
Bill Wendlingae034ed2008-12-12 00:56:36 +00002220def SUB16rr : I<0x29, MRMDestReg, (outs GR16:$dst), (ins GR16:$src1,GR16:$src2),
2221 "sub{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002222 [(set GR16:$dst, (sub GR16:$src1, GR16:$src2)),
2223 (implicit EFLAGS)]>, OpSize;
Bill Wendlingae034ed2008-12-12 00:56:36 +00002224def SUB32rr : I<0x29, MRMDestReg, (outs GR32:$dst), (ins GR32:$src1,GR32:$src2),
2225 "sub{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002226 [(set GR32:$dst, (sub GR32:$src1, GR32:$src2)),
2227 (implicit EFLAGS)]>;
Bill Wendlingae034ed2008-12-12 00:56:36 +00002228
2229// Register-Memory Subtraction
2230def SUB8rm : I<0x2A, MRMSrcMem, (outs GR8 :$dst),
2231 (ins GR8 :$src1, i8mem :$src2),
2232 "sub{b}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002233 [(set GR8:$dst, (sub GR8:$src1, (load addr:$src2))),
2234 (implicit EFLAGS)]>;
Bill Wendlingae034ed2008-12-12 00:56:36 +00002235def SUB16rm : I<0x2B, MRMSrcMem, (outs GR16:$dst),
2236 (ins GR16:$src1, i16mem:$src2),
2237 "sub{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002238 [(set GR16:$dst, (sub GR16:$src1, (load addr:$src2))),
2239 (implicit EFLAGS)]>, OpSize;
Bill Wendlingae034ed2008-12-12 00:56:36 +00002240def SUB32rm : I<0x2B, MRMSrcMem, (outs GR32:$dst),
2241 (ins GR32:$src1, i32mem:$src2),
2242 "sub{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002243 [(set GR32:$dst, (sub GR32:$src1, (load addr:$src2))),
2244 (implicit EFLAGS)]>;
Bill Wendlingae034ed2008-12-12 00:56:36 +00002245
2246// Register-Integer Subtraction
2247def SUB8ri : Ii8 <0x80, MRM5r, (outs GR8:$dst),
2248 (ins GR8:$src1, i8imm:$src2),
2249 "sub{b}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002250 [(set GR8:$dst, (sub GR8:$src1, imm:$src2)),
2251 (implicit EFLAGS)]>;
Bill Wendlingae034ed2008-12-12 00:56:36 +00002252def SUB16ri : Ii16<0x81, MRM5r, (outs GR16:$dst),
2253 (ins GR16:$src1, i16imm:$src2),
2254 "sub{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002255 [(set GR16:$dst, (sub GR16:$src1, imm:$src2)),
2256 (implicit EFLAGS)]>, OpSize;
Bill Wendlingae034ed2008-12-12 00:56:36 +00002257def SUB32ri : Ii32<0x81, MRM5r, (outs GR32:$dst),
2258 (ins GR32:$src1, i32imm:$src2),
2259 "sub{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002260 [(set GR32:$dst, (sub GR32:$src1, imm:$src2)),
2261 (implicit EFLAGS)]>;
Bill Wendlingae034ed2008-12-12 00:56:36 +00002262def SUB16ri8 : Ii8<0x83, MRM5r, (outs GR16:$dst),
2263 (ins GR16:$src1, i16i8imm:$src2),
2264 "sub{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002265 [(set GR16:$dst, (sub GR16:$src1, i16immSExt8:$src2)),
2266 (implicit EFLAGS)]>, OpSize;
Bill Wendlingae034ed2008-12-12 00:56:36 +00002267def SUB32ri8 : Ii8<0x83, MRM5r, (outs GR32:$dst),
2268 (ins GR32:$src1, i32i8imm:$src2),
2269 "sub{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002270 [(set GR32:$dst, (sub GR32:$src1, i32immSExt8:$src2)),
2271 (implicit EFLAGS)]>;
Bill Wendlingae034ed2008-12-12 00:56:36 +00002272
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002273let isTwoAddress = 0 in {
Bill Wendlingae034ed2008-12-12 00:56:36 +00002274 // Memory-Register Subtraction
Evan Chengb783fa32007-07-19 01:14:50 +00002275 def SUB8mr : I<0x28, MRMDestMem, (outs), (ins i8mem :$dst, GR8 :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002276 "sub{b}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002277 [(store (sub (load addr:$dst), GR8:$src2), addr:$dst),
2278 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002279 def SUB16mr : I<0x29, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002280 "sub{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002281 [(store (sub (load addr:$dst), GR16:$src2), addr:$dst),
2282 (implicit EFLAGS)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002283 def SUB32mr : I<0x29, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002284 "sub{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002285 [(store (sub (load addr:$dst), GR32:$src2), addr:$dst),
2286 (implicit EFLAGS)]>;
Bill Wendlingae034ed2008-12-12 00:56:36 +00002287
2288 // Memory-Integer Subtraction
Evan Chengb783fa32007-07-19 01:14:50 +00002289 def SUB8mi : Ii8<0x80, MRM5m, (outs), (ins i8mem :$dst, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002290 "sub{b}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002291 [(store (sub (loadi8 addr:$dst), imm:$src2), addr:$dst),
2292 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002293 def SUB16mi : Ii16<0x81, MRM5m, (outs), (ins i16mem:$dst, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002294 "sub{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002295 [(store (sub (loadi16 addr:$dst), imm:$src2),addr:$dst),
2296 (implicit EFLAGS)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002297 def SUB32mi : Ii32<0x81, MRM5m, (outs), (ins i32mem:$dst, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002298 "sub{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002299 [(store (sub (loadi32 addr:$dst), imm:$src2),addr:$dst),
2300 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002301 def SUB16mi8 : Ii8<0x83, MRM5m, (outs), (ins i16mem:$dst, i16i8imm :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002302 "sub{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingae034ed2008-12-12 00:56:36 +00002303 [(store (sub (load addr:$dst), i16immSExt8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00002304 addr:$dst),
2305 (implicit EFLAGS)]>, OpSize;
Bill Wendlingae034ed2008-12-12 00:56:36 +00002306 def SUB32mi8 : Ii8<0x83, MRM5m, (outs), (ins i32mem:$dst, i32i8imm :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002307 "sub{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingae034ed2008-12-12 00:56:36 +00002308 [(store (sub (load addr:$dst), i32immSExt8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00002309 addr:$dst),
2310 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002311}
2312
Evan Cheng259471d2007-10-05 17:59:57 +00002313let Uses = [EFLAGS] in {
Evan Chengb783fa32007-07-19 01:14:50 +00002314def SBB32rr : I<0x19, MRMDestReg, (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002315 "sbb{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng55687072007-09-14 21:48:26 +00002316 [(set GR32:$dst, (sube GR32:$src1, GR32:$src2))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002317
2318let isTwoAddress = 0 in {
Evan Chengb783fa32007-07-19 01:14:50 +00002319 def SBB32mr : I<0x19, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002320 "sbb{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002321 [(store (sube (load addr:$dst), GR32:$src2), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002322 def SBB8mi : Ii32<0x80, MRM3m, (outs), (ins i8mem:$dst, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002323 "sbb{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002324 [(store (sube (loadi8 addr:$dst), imm:$src2), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002325 def SBB32mi : Ii32<0x81, MRM3m, (outs), (ins i32mem:$dst, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002326 "sbb{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002327 [(store (sube (loadi32 addr:$dst), imm:$src2), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002328 def SBB32mi8 : Ii8<0x83, MRM3m, (outs), (ins i32mem:$dst, i32i8imm :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002329 "sbb{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng55687072007-09-14 21:48:26 +00002330 [(store (sube (load addr:$dst), i32immSExt8:$src2), addr:$dst)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002331}
Evan Chengb783fa32007-07-19 01:14:50 +00002332def SBB32rm : I<0x1B, MRMSrcMem, (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002333 "sbb{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002334 [(set GR32:$dst, (sube GR32:$src1, (load addr:$src2)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002335def SBB32ri : Ii32<0x81, MRM3r, (outs GR32:$dst), (ins GR32:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002336 "sbb{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002337 [(set GR32:$dst, (sube GR32:$src1, imm:$src2))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002338def SBB32ri8 : Ii8<0x83, MRM3r, (outs GR32:$dst), (ins GR32:$src1, i32i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002339 "sbb{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002340 [(set GR32:$dst, (sube GR32:$src1, i32immSExt8:$src2))]>;
Evan Cheng259471d2007-10-05 17:59:57 +00002341} // Uses = [EFLAGS]
Evan Cheng55687072007-09-14 21:48:26 +00002342} // Defs = [EFLAGS]
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002343
Evan Cheng55687072007-09-14 21:48:26 +00002344let Defs = [EFLAGS] in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002345let isCommutable = 1 in { // X = IMUL Y, Z --> X = IMUL Z, Y
Bill Wendlingf5399032008-12-12 21:15:41 +00002346// Register-Register Signed Integer Multiply
Bill Wendlingae034ed2008-12-12 00:56:36 +00002347def IMUL16rr : I<0xAF, MRMSrcReg, (outs GR16:$dst), (ins GR16:$src1,GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002348 "imul{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002349 [(set GR16:$dst, (mul GR16:$src1, GR16:$src2)),
2350 (implicit EFLAGS)]>, TB, OpSize;
Bill Wendlingae034ed2008-12-12 00:56:36 +00002351def IMUL32rr : I<0xAF, MRMSrcReg, (outs GR32:$dst), (ins GR32:$src1,GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002352 "imul{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002353 [(set GR32:$dst, (mul GR32:$src1, GR32:$src2)),
2354 (implicit EFLAGS)]>, TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002355}
Bill Wendlingae034ed2008-12-12 00:56:36 +00002356
Bill Wendlingf5399032008-12-12 21:15:41 +00002357// Register-Memory Signed Integer Multiply
Bill Wendlingae034ed2008-12-12 00:56:36 +00002358def IMUL16rm : I<0xAF, MRMSrcMem, (outs GR16:$dst),
2359 (ins GR16:$src1, i16mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002360 "imul{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002361 [(set GR16:$dst, (mul GR16:$src1, (load addr:$src2))),
2362 (implicit EFLAGS)]>, TB, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002363def IMUL32rm : I<0xAF, MRMSrcMem, (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002364 "imul{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002365 [(set GR32:$dst, (mul GR32:$src1, (load addr:$src2))),
2366 (implicit EFLAGS)]>, TB;
Evan Cheng55687072007-09-14 21:48:26 +00002367} // Defs = [EFLAGS]
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002368} // end Two Address instructions
2369
2370// Suprisingly enough, these are not two address instructions!
Evan Cheng55687072007-09-14 21:48:26 +00002371let Defs = [EFLAGS] in {
Bill Wendlingf5399032008-12-12 21:15:41 +00002372// Register-Integer Signed Integer Multiply
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002373def IMUL16rri : Ii16<0x69, MRMSrcReg, // GR16 = GR16*I16
Evan Chengb783fa32007-07-19 01:14:50 +00002374 (outs GR16:$dst), (ins GR16:$src1, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002375 "imul{w}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002376 [(set GR16:$dst, (mul GR16:$src1, imm:$src2)),
2377 (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002378def IMUL32rri : Ii32<0x69, MRMSrcReg, // GR32 = GR32*I32
Evan Chengb783fa32007-07-19 01:14:50 +00002379 (outs GR32:$dst), (ins GR32:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002380 "imul{l}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002381 [(set GR32:$dst, (mul GR32:$src1, imm:$src2)),
2382 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002383def IMUL16rri8 : Ii8<0x6B, MRMSrcReg, // GR16 = GR16*I8
Evan Chengb783fa32007-07-19 01:14:50 +00002384 (outs GR16:$dst), (ins GR16:$src1, i16i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002385 "imul{w}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002386 [(set GR16:$dst, (mul GR16:$src1, i16immSExt8:$src2)),
2387 (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002388def IMUL32rri8 : Ii8<0x6B, MRMSrcReg, // GR32 = GR32*I8
Evan Chengb783fa32007-07-19 01:14:50 +00002389 (outs GR32:$dst), (ins GR32:$src1, i32i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002390 "imul{l}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002391 [(set GR32:$dst, (mul GR32:$src1, i32immSExt8:$src2)),
2392 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002393
Bill Wendlingf5399032008-12-12 21:15:41 +00002394// Memory-Integer Signed Integer Multiply
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002395def IMUL16rmi : Ii16<0x69, MRMSrcMem, // GR16 = [mem16]*I16
Evan Chengb783fa32007-07-19 01:14:50 +00002396 (outs GR16:$dst), (ins i16mem:$src1, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002397 "imul{w}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002398 [(set GR16:$dst, (mul (load addr:$src1), imm:$src2)),
2399 (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002400def IMUL32rmi : Ii32<0x69, MRMSrcMem, // GR32 = [mem32]*I32
Evan Chengb783fa32007-07-19 01:14:50 +00002401 (outs GR32:$dst), (ins i32mem:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002402 "imul{l}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002403 [(set GR32:$dst, (mul (load addr:$src1), imm:$src2)),
2404 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002405def IMUL16rmi8 : Ii8<0x6B, MRMSrcMem, // GR16 = [mem16]*I8
Evan Chengb783fa32007-07-19 01:14:50 +00002406 (outs GR16:$dst), (ins i16mem:$src1, i16i8imm :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002407 "imul{w}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Bill Wendlingae034ed2008-12-12 00:56:36 +00002408 [(set GR16:$dst, (mul (load addr:$src1),
Bill Wendlingf5399032008-12-12 21:15:41 +00002409 i16immSExt8:$src2)),
2410 (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002411def IMUL32rmi8 : Ii8<0x6B, MRMSrcMem, // GR32 = [mem32]*I8
Evan Chengb783fa32007-07-19 01:14:50 +00002412 (outs GR32:$dst), (ins i32mem:$src1, i32i8imm: $src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002413 "imul{l}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Bill Wendlingae034ed2008-12-12 00:56:36 +00002414 [(set GR32:$dst, (mul (load addr:$src1),
Bill Wendlingf5399032008-12-12 21:15:41 +00002415 i32immSExt8:$src2)),
2416 (implicit EFLAGS)]>;
Evan Cheng55687072007-09-14 21:48:26 +00002417} // Defs = [EFLAGS]
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002418
2419//===----------------------------------------------------------------------===//
2420// Test instructions are just like AND, except they don't generate a result.
2421//
Evan Cheng950aac02007-09-25 01:57:46 +00002422let Defs = [EFLAGS] in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002423let isCommutable = 1 in { // TEST X, Y --> TEST Y, X
Evan Chengb783fa32007-07-19 01:14:50 +00002424def TEST8rr : I<0x84, MRMDestReg, (outs), (ins GR8:$src1, GR8:$src2),
Evan Cheng621216e2007-09-29 00:00:36 +00002425 "test{b}\t{$src2, $src1|$src1, $src2}",
Chris Lattner21da6382008-02-19 17:37:35 +00002426 [(X86cmp (and_su GR8:$src1, GR8:$src2), 0),
Evan Cheng621216e2007-09-29 00:00:36 +00002427 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002428def TEST16rr : I<0x85, MRMDestReg, (outs), (ins GR16:$src1, GR16:$src2),
Evan Cheng621216e2007-09-29 00:00:36 +00002429 "test{w}\t{$src2, $src1|$src1, $src2}",
Chris Lattner21da6382008-02-19 17:37:35 +00002430 [(X86cmp (and_su GR16:$src1, GR16:$src2), 0),
Evan Cheng621216e2007-09-29 00:00:36 +00002431 (implicit EFLAGS)]>,
2432 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002433def TEST32rr : I<0x85, MRMDestReg, (outs), (ins GR32:$src1, GR32:$src2),
Evan Cheng621216e2007-09-29 00:00:36 +00002434 "test{l}\t{$src2, $src1|$src1, $src2}",
Chris Lattner21da6382008-02-19 17:37:35 +00002435 [(X86cmp (and_su GR32:$src1, GR32:$src2), 0),
Evan Cheng621216e2007-09-29 00:00:36 +00002436 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002437}
2438
Evan Chengb783fa32007-07-19 01:14:50 +00002439def TEST8rm : I<0x84, MRMSrcMem, (outs), (ins GR8 :$src1, i8mem :$src2),
Evan Cheng621216e2007-09-29 00:00:36 +00002440 "test{b}\t{$src2, $src1|$src1, $src2}",
2441 [(X86cmp (and GR8:$src1, (loadi8 addr:$src2)), 0),
2442 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002443def TEST16rm : I<0x85, MRMSrcMem, (outs), (ins GR16:$src1, i16mem:$src2),
Evan Cheng621216e2007-09-29 00:00:36 +00002444 "test{w}\t{$src2, $src1|$src1, $src2}",
2445 [(X86cmp (and GR16:$src1, (loadi16 addr:$src2)), 0),
2446 (implicit EFLAGS)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002447def TEST32rm : I<0x85, MRMSrcMem, (outs), (ins GR32:$src1, i32mem:$src2),
Evan Cheng621216e2007-09-29 00:00:36 +00002448 "test{l}\t{$src2, $src1|$src1, $src2}",
2449 [(X86cmp (and GR32:$src1, (loadi32 addr:$src2)), 0),
2450 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002451
2452def TEST8ri : Ii8 <0xF6, MRM0r, // flags = GR8 & imm8
Evan Chengb783fa32007-07-19 01:14:50 +00002453 (outs), (ins GR8:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002454 "test{b}\t{$src2, $src1|$src1, $src2}",
Chris Lattner21da6382008-02-19 17:37:35 +00002455 [(X86cmp (and_su GR8:$src1, imm:$src2), 0),
Evan Cheng621216e2007-09-29 00:00:36 +00002456 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002457def TEST16ri : Ii16<0xF7, MRM0r, // flags = GR16 & imm16
Evan Chengb783fa32007-07-19 01:14:50 +00002458 (outs), (ins GR16:$src1, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002459 "test{w}\t{$src2, $src1|$src1, $src2}",
Chris Lattner21da6382008-02-19 17:37:35 +00002460 [(X86cmp (and_su GR16:$src1, imm:$src2), 0),
Evan Cheng621216e2007-09-29 00:00:36 +00002461 (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002462def TEST32ri : Ii32<0xF7, MRM0r, // flags = GR32 & imm32
Evan Chengb783fa32007-07-19 01:14:50 +00002463 (outs), (ins GR32:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002464 "test{l}\t{$src2, $src1|$src1, $src2}",
Chris Lattner21da6382008-02-19 17:37:35 +00002465 [(X86cmp (and_su GR32:$src1, imm:$src2), 0),
Evan Cheng621216e2007-09-29 00:00:36 +00002466 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002467
Evan Cheng621216e2007-09-29 00:00:36 +00002468def TEST8mi : Ii8 <0xF6, MRM0m, // flags = [mem8] & imm8
Evan Chengb783fa32007-07-19 01:14:50 +00002469 (outs), (ins i8mem:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002470 "test{b}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002471 [(X86cmp (and (loadi8 addr:$src1), imm:$src2), 0),
2472 (implicit EFLAGS)]>;
2473def TEST16mi : Ii16<0xF7, MRM0m, // flags = [mem16] & imm16
Evan Chengb783fa32007-07-19 01:14:50 +00002474 (outs), (ins i16mem:$src1, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002475 "test{w}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002476 [(X86cmp (and (loadi16 addr:$src1), imm:$src2), 0),
2477 (implicit EFLAGS)]>, OpSize;
2478def TEST32mi : Ii32<0xF7, MRM0m, // flags = [mem32] & imm32
Evan Chengb783fa32007-07-19 01:14:50 +00002479 (outs), (ins i32mem:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002480 "test{l}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002481 [(X86cmp (and (loadi32 addr:$src1), imm:$src2), 0),
Evan Cheng950aac02007-09-25 01:57:46 +00002482 (implicit EFLAGS)]>;
2483} // Defs = [EFLAGS]
2484
2485
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002486// Condition code ops, incl. set if equal/not equal/...
Chris Lattnerc90ee9c2008-01-10 07:59:24 +00002487let Defs = [EFLAGS], Uses = [AH], neverHasSideEffects = 1 in
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002488def SAHF : I<0x9E, RawFrm, (outs), (ins), "sahf", []>; // flags = AH
Chris Lattnerc90ee9c2008-01-10 07:59:24 +00002489let Defs = [AH], Uses = [EFLAGS], neverHasSideEffects = 1 in
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002490def LAHF : I<0x9F, RawFrm, (outs), (ins), "lahf", []>; // AH = flags
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002491
Evan Cheng950aac02007-09-25 01:57:46 +00002492let Uses = [EFLAGS] in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002493def SETEr : I<0x94, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00002494 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002495 "sete\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002496 [(set GR8:$dst, (X86setcc X86_COND_E, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002497 TB; // GR8 = ==
2498def SETEm : I<0x94, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00002499 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002500 "sete\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002501 [(store (X86setcc X86_COND_E, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002502 TB; // [mem8] = ==
Bill Wendling0c52d0a2008-12-02 00:07:05 +00002503
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002504def SETNEr : I<0x95, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00002505 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002506 "setne\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002507 [(set GR8:$dst, (X86setcc X86_COND_NE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002508 TB; // GR8 = !=
2509def SETNEm : I<0x95, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00002510 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002511 "setne\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002512 [(store (X86setcc X86_COND_NE, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002513 TB; // [mem8] = !=
Bill Wendling0c52d0a2008-12-02 00:07:05 +00002514
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002515def SETLr : I<0x9C, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00002516 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002517 "setl\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002518 [(set GR8:$dst, (X86setcc X86_COND_L, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002519 TB; // GR8 = < signed
2520def SETLm : I<0x9C, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00002521 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002522 "setl\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002523 [(store (X86setcc X86_COND_L, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002524 TB; // [mem8] = < signed
Bill Wendling0c52d0a2008-12-02 00:07:05 +00002525
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002526def SETGEr : I<0x9D, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00002527 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002528 "setge\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002529 [(set GR8:$dst, (X86setcc X86_COND_GE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002530 TB; // GR8 = >= signed
2531def SETGEm : I<0x9D, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00002532 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002533 "setge\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002534 [(store (X86setcc X86_COND_GE, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002535 TB; // [mem8] = >= signed
Bill Wendling0c52d0a2008-12-02 00:07:05 +00002536
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002537def SETLEr : I<0x9E, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00002538 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002539 "setle\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002540 [(set GR8:$dst, (X86setcc X86_COND_LE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002541 TB; // GR8 = <= signed
2542def SETLEm : I<0x9E, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00002543 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002544 "setle\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002545 [(store (X86setcc X86_COND_LE, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002546 TB; // [mem8] = <= signed
Bill Wendling0c52d0a2008-12-02 00:07:05 +00002547
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002548def SETGr : I<0x9F, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00002549 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002550 "setg\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002551 [(set GR8:$dst, (X86setcc X86_COND_G, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002552 TB; // GR8 = > signed
2553def SETGm : I<0x9F, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00002554 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002555 "setg\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002556 [(store (X86setcc X86_COND_G, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002557 TB; // [mem8] = > signed
2558
2559def SETBr : I<0x92, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00002560 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002561 "setb\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002562 [(set GR8:$dst, (X86setcc X86_COND_B, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002563 TB; // GR8 = < unsign
2564def SETBm : I<0x92, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00002565 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002566 "setb\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002567 [(store (X86setcc X86_COND_B, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002568 TB; // [mem8] = < unsign
Bill Wendling0c52d0a2008-12-02 00:07:05 +00002569
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002570def SETAEr : I<0x93, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00002571 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002572 "setae\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002573 [(set GR8:$dst, (X86setcc X86_COND_AE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002574 TB; // GR8 = >= unsign
2575def SETAEm : I<0x93, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00002576 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002577 "setae\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002578 [(store (X86setcc X86_COND_AE, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002579 TB; // [mem8] = >= unsign
Bill Wendling0c52d0a2008-12-02 00:07:05 +00002580
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002581def SETBEr : I<0x96, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00002582 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002583 "setbe\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002584 [(set GR8:$dst, (X86setcc X86_COND_BE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002585 TB; // GR8 = <= unsign
2586def SETBEm : I<0x96, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00002587 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002588 "setbe\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002589 [(store (X86setcc X86_COND_BE, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002590 TB; // [mem8] = <= unsign
Bill Wendling0c52d0a2008-12-02 00:07:05 +00002591
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002592def SETAr : I<0x97, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00002593 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002594 "seta\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002595 [(set GR8:$dst, (X86setcc X86_COND_A, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002596 TB; // GR8 = > signed
2597def SETAm : I<0x97, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00002598 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002599 "seta\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002600 [(store (X86setcc X86_COND_A, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002601 TB; // [mem8] = > signed
2602
2603def SETSr : I<0x98, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00002604 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002605 "sets\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002606 [(set GR8:$dst, (X86setcc X86_COND_S, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002607 TB; // GR8 = <sign bit>
2608def SETSm : I<0x98, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00002609 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002610 "sets\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002611 [(store (X86setcc X86_COND_S, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002612 TB; // [mem8] = <sign bit>
2613def SETNSr : I<0x99, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00002614 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002615 "setns\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002616 [(set GR8:$dst, (X86setcc X86_COND_NS, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002617 TB; // GR8 = !<sign bit>
2618def SETNSm : I<0x99, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00002619 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002620 "setns\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002621 [(store (X86setcc X86_COND_NS, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002622 TB; // [mem8] = !<sign bit>
Bill Wendling0c52d0a2008-12-02 00:07:05 +00002623
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002624def SETPr : I<0x9A, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00002625 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002626 "setp\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002627 [(set GR8:$dst, (X86setcc X86_COND_P, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002628 TB; // GR8 = parity
2629def SETPm : I<0x9A, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00002630 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002631 "setp\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002632 [(store (X86setcc X86_COND_P, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002633 TB; // [mem8] = parity
2634def SETNPr : I<0x9B, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00002635 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002636 "setnp\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002637 [(set GR8:$dst, (X86setcc X86_COND_NP, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002638 TB; // GR8 = not parity
2639def SETNPm : I<0x9B, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00002640 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002641 "setnp\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002642 [(store (X86setcc X86_COND_NP, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002643 TB; // [mem8] = not parity
Bill Wendling0c52d0a2008-12-02 00:07:05 +00002644
2645def SETOr : I<0x90, MRM0r,
2646 (outs GR8 :$dst), (ins),
2647 "seto\t$dst",
2648 [(set GR8:$dst, (X86setcc X86_COND_O, EFLAGS))]>,
2649 TB; // GR8 = overflow
2650def SETOm : I<0x90, MRM0m,
2651 (outs), (ins i8mem:$dst),
2652 "seto\t$dst",
2653 [(store (X86setcc X86_COND_O, EFLAGS), addr:$dst)]>,
2654 TB; // [mem8] = overflow
2655def SETNOr : I<0x91, MRM0r,
2656 (outs GR8 :$dst), (ins),
2657 "setno\t$dst",
2658 [(set GR8:$dst, (X86setcc X86_COND_NO, EFLAGS))]>,
2659 TB; // GR8 = not overflow
2660def SETNOm : I<0x91, MRM0m,
2661 (outs), (ins i8mem:$dst),
2662 "setno\t$dst",
2663 [(store (X86setcc X86_COND_NO, EFLAGS), addr:$dst)]>,
2664 TB; // [mem8] = not overflow
Evan Cheng950aac02007-09-25 01:57:46 +00002665} // Uses = [EFLAGS]
2666
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002667
2668// Integer comparisons
Evan Cheng55687072007-09-14 21:48:26 +00002669let Defs = [EFLAGS] in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002670def CMP8rr : I<0x38, MRMDestReg,
Evan Chengb783fa32007-07-19 01:14:50 +00002671 (outs), (ins GR8 :$src1, GR8 :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002672 "cmp{b}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002673 [(X86cmp GR8:$src1, GR8:$src2), (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002674def CMP16rr : I<0x39, MRMDestReg,
Evan Chengb783fa32007-07-19 01:14:50 +00002675 (outs), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002676 "cmp{w}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002677 [(X86cmp GR16:$src1, GR16:$src2), (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002678def CMP32rr : I<0x39, MRMDestReg,
Evan Chengb783fa32007-07-19 01:14:50 +00002679 (outs), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002680 "cmp{l}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002681 [(X86cmp GR32:$src1, GR32:$src2), (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002682def CMP8mr : I<0x38, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00002683 (outs), (ins i8mem :$src1, GR8 :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002684 "cmp{b}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002685 [(X86cmp (loadi8 addr:$src1), GR8:$src2),
2686 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002687def CMP16mr : I<0x39, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00002688 (outs), (ins i16mem:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002689 "cmp{w}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002690 [(X86cmp (loadi16 addr:$src1), GR16:$src2),
2691 (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002692def CMP32mr : I<0x39, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00002693 (outs), (ins i32mem:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002694 "cmp{l}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002695 [(X86cmp (loadi32 addr:$src1), GR32:$src2),
2696 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002697def CMP8rm : I<0x3A, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00002698 (outs), (ins GR8 :$src1, i8mem :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002699 "cmp{b}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002700 [(X86cmp GR8:$src1, (loadi8 addr:$src2)),
2701 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002702def CMP16rm : I<0x3B, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00002703 (outs), (ins GR16:$src1, i16mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002704 "cmp{w}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002705 [(X86cmp GR16:$src1, (loadi16 addr:$src2)),
2706 (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002707def CMP32rm : I<0x3B, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00002708 (outs), (ins GR32:$src1, i32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002709 "cmp{l}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002710 [(X86cmp GR32:$src1, (loadi32 addr:$src2)),
2711 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002712def CMP8ri : Ii8<0x80, MRM7r,
Evan Chengb783fa32007-07-19 01:14:50 +00002713 (outs), (ins GR8:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002714 "cmp{b}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002715 [(X86cmp GR8:$src1, imm:$src2), (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002716def CMP16ri : Ii16<0x81, MRM7r,
Evan Chengb783fa32007-07-19 01:14:50 +00002717 (outs), (ins GR16:$src1, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002718 "cmp{w}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002719 [(X86cmp GR16:$src1, imm:$src2),
2720 (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002721def CMP32ri : Ii32<0x81, MRM7r,
Evan Chengb783fa32007-07-19 01:14:50 +00002722 (outs), (ins GR32:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002723 "cmp{l}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002724 [(X86cmp GR32:$src1, imm:$src2), (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002725def CMP8mi : Ii8 <0x80, MRM7m,
Evan Chengb783fa32007-07-19 01:14:50 +00002726 (outs), (ins i8mem :$src1, i8imm :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002727 "cmp{b}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002728 [(X86cmp (loadi8 addr:$src1), imm:$src2),
2729 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002730def CMP16mi : Ii16<0x81, MRM7m,
Evan Chengb783fa32007-07-19 01:14:50 +00002731 (outs), (ins i16mem:$src1, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002732 "cmp{w}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002733 [(X86cmp (loadi16 addr:$src1), imm:$src2),
2734 (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002735def CMP32mi : Ii32<0x81, MRM7m,
Evan Chengb783fa32007-07-19 01:14:50 +00002736 (outs), (ins i32mem:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002737 "cmp{l}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002738 [(X86cmp (loadi32 addr:$src1), imm:$src2),
2739 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002740def CMP16ri8 : Ii8<0x83, MRM7r,
Evan Chengb783fa32007-07-19 01:14:50 +00002741 (outs), (ins GR16:$src1, i16i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002742 "cmp{w}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002743 [(X86cmp GR16:$src1, i16immSExt8:$src2),
2744 (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002745def CMP16mi8 : Ii8<0x83, MRM7m,
Evan Chengb783fa32007-07-19 01:14:50 +00002746 (outs), (ins i16mem:$src1, i16i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002747 "cmp{w}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002748 [(X86cmp (loadi16 addr:$src1), i16immSExt8:$src2),
2749 (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002750def CMP32mi8 : Ii8<0x83, MRM7m,
Evan Chengb783fa32007-07-19 01:14:50 +00002751 (outs), (ins i32mem:$src1, i32i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002752 "cmp{l}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002753 [(X86cmp (loadi32 addr:$src1), i32immSExt8:$src2),
2754 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002755def CMP32ri8 : Ii8<0x83, MRM7r,
Evan Chengb783fa32007-07-19 01:14:50 +00002756 (outs), (ins GR32:$src1, i32i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002757 "cmp{l}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002758 [(X86cmp GR32:$src1, i32immSExt8:$src2),
Evan Cheng950aac02007-09-25 01:57:46 +00002759 (implicit EFLAGS)]>;
2760} // Defs = [EFLAGS]
2761
Dan Gohman7fe9b7f2008-12-23 22:45:23 +00002762// Bit tests.
Dan Gohman7fe9b7f2008-12-23 22:45:23 +00002763// TODO: BTC, BTR, and BTS
2764let Defs = [EFLAGS] in {
Dan Gohmanfc4eddb2009-01-13 20:32:45 +00002765def BT16rr : I<0xA3, MRMDestReg, (outs), (ins GR16:$src1, GR16:$src2),
Dan Gohman7fe9b7f2008-12-23 22:45:23 +00002766 "bt{w}\t{$src2, $src1|$src1, $src2}",
2767 [(X86bt GR16:$src1, GR16:$src2),
Chris Lattner5a95cde2008-12-25 01:32:49 +00002768 (implicit EFLAGS)]>, OpSize, TB;
Dan Gohmanfc4eddb2009-01-13 20:32:45 +00002769def BT32rr : I<0xA3, MRMDestReg, (outs), (ins GR32:$src1, GR32:$src2),
Dan Gohman7fe9b7f2008-12-23 22:45:23 +00002770 "bt{l}\t{$src2, $src1|$src1, $src2}",
2771 [(X86bt GR32:$src1, GR32:$src2),
Chris Lattner5a95cde2008-12-25 01:32:49 +00002772 (implicit EFLAGS)]>, TB;
Dan Gohman85a228c2009-01-13 23:23:30 +00002773
2774// Unlike with the register+register form, the memory+register form of the
2775// bt instruction does not ignore the high bits of the index. From ISel's
2776// perspective, this is pretty bizarre. Disable these instructions for now.
2777//def BT16mr : I<0xA3, MRMDestMem, (outs), (ins i16mem:$src1, GR16:$src2),
2778// "bt{w}\t{$src2, $src1|$src1, $src2}",
2779// [(X86bt (loadi16 addr:$src1), GR16:$src2),
2780// (implicit EFLAGS)]>, OpSize, TB, Requires<[FastBTMem]>;
2781//def BT32mr : I<0xA3, MRMDestMem, (outs), (ins i32mem:$src1, GR32:$src2),
2782// "bt{l}\t{$src2, $src1|$src1, $src2}",
2783// [(X86bt (loadi32 addr:$src1), GR32:$src2),
2784// (implicit EFLAGS)]>, TB, Requires<[FastBTMem]>;
Dan Gohman46fb1cf2009-01-13 20:33:23 +00002785
2786def BT16ri8 : Ii8<0xBA, MRM4r, (outs), (ins GR16:$src1, i16i8imm:$src2),
2787 "bt{w}\t{$src2, $src1|$src1, $src2}",
2788 [(X86bt GR16:$src1, i16immSExt8:$src2),
2789 (implicit EFLAGS)]>, OpSize, TB;
2790def BT32ri8 : Ii8<0xBA, MRM4r, (outs), (ins GR32:$src1, i32i8imm:$src2),
2791 "bt{l}\t{$src2, $src1|$src1, $src2}",
2792 [(X86bt GR32:$src1, i32immSExt8:$src2),
2793 (implicit EFLAGS)]>, TB;
2794// Note that these instructions don't need FastBTMem because that
2795// only applies when the other operand is in a register. When it's
2796// an immediate, bt is still fast.
2797def BT16mi8 : Ii8<0xBA, MRM4m, (outs), (ins i16mem:$src1, i16i8imm:$src2),
2798 "bt{w}\t{$src2, $src1|$src1, $src2}",
2799 [(X86bt (loadi16 addr:$src1), i16immSExt8:$src2),
2800 (implicit EFLAGS)]>, OpSize, TB;
2801def BT32mi8 : Ii8<0xBA, MRM4m, (outs), (ins i32mem:$src1, i32i8imm:$src2),
2802 "bt{l}\t{$src2, $src1|$src1, $src2}",
2803 [(X86bt (loadi32 addr:$src1), i32immSExt8:$src2),
2804 (implicit EFLAGS)]>, TB;
Dan Gohman7fe9b7f2008-12-23 22:45:23 +00002805} // Defs = [EFLAGS]
2806
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002807// Sign/Zero extenders
Dan Gohman9203ab42008-07-30 18:09:17 +00002808// Use movsbl intead of movsbw; we don't care about the high 16 bits
2809// of the register here. This has a smaller encoding and avoids a
2810// partial-register update.
Evan Chengb783fa32007-07-19 01:14:50 +00002811def MOVSX16rr8 : I<0xBE, MRMSrcReg, (outs GR16:$dst), (ins GR8 :$src),
Dan Gohman9203ab42008-07-30 18:09:17 +00002812 "movs{bl|x}\t{$src, ${dst:subreg32}|${dst:subreg32}, $src}",
2813 [(set GR16:$dst, (sext GR8:$src))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00002814def MOVSX16rm8 : I<0xBE, MRMSrcMem, (outs GR16:$dst), (ins i8mem :$src),
Dan Gohman9203ab42008-07-30 18:09:17 +00002815 "movs{bl|x}\t{$src, ${dst:subreg32}|${dst:subreg32}, $src}",
2816 [(set GR16:$dst, (sextloadi16i8 addr:$src))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00002817def MOVSX32rr8 : I<0xBE, MRMSrcReg, (outs GR32:$dst), (ins GR8 :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002818 "movs{bl|x}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002819 [(set GR32:$dst, (sext GR8:$src))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00002820def MOVSX32rm8 : I<0xBE, MRMSrcMem, (outs GR32:$dst), (ins i8mem :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002821 "movs{bl|x}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002822 [(set GR32:$dst, (sextloadi32i8 addr:$src))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00002823def MOVSX32rr16: I<0xBF, MRMSrcReg, (outs GR32:$dst), (ins GR16:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002824 "movs{wl|x}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002825 [(set GR32:$dst, (sext GR16:$src))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00002826def MOVSX32rm16: I<0xBF, MRMSrcMem, (outs GR32:$dst), (ins i16mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002827 "movs{wl|x}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002828 [(set GR32:$dst, (sextloadi32i16 addr:$src))]>, TB;
2829
Dan Gohman9203ab42008-07-30 18:09:17 +00002830// Use movzbl intead of movzbw; we don't care about the high 16 bits
2831// of the register here. This has a smaller encoding and avoids a
2832// partial-register update.
Evan Chengb783fa32007-07-19 01:14:50 +00002833def MOVZX16rr8 : I<0xB6, MRMSrcReg, (outs GR16:$dst), (ins GR8 :$src),
Dan Gohman9203ab42008-07-30 18:09:17 +00002834 "movz{bl|x}\t{$src, ${dst:subreg32}|${dst:subreg32}, $src}",
2835 [(set GR16:$dst, (zext GR8:$src))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00002836def MOVZX16rm8 : I<0xB6, MRMSrcMem, (outs GR16:$dst), (ins i8mem :$src),
Dan Gohman9203ab42008-07-30 18:09:17 +00002837 "movz{bl|x}\t{$src, ${dst:subreg32}|${dst:subreg32}, $src}",
2838 [(set GR16:$dst, (zextloadi16i8 addr:$src))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00002839def MOVZX32rr8 : I<0xB6, MRMSrcReg, (outs GR32:$dst), (ins GR8 :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002840 "movz{bl|x}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002841 [(set GR32:$dst, (zext GR8:$src))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00002842def MOVZX32rm8 : I<0xB6, MRMSrcMem, (outs GR32:$dst), (ins i8mem :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002843 "movz{bl|x}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002844 [(set GR32:$dst, (zextloadi32i8 addr:$src))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00002845def MOVZX32rr16: I<0xB7, MRMSrcReg, (outs GR32:$dst), (ins GR16:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002846 "movz{wl|x}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002847 [(set GR32:$dst, (zext GR16:$src))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00002848def MOVZX32rm16: I<0xB7, MRMSrcMem, (outs GR32:$dst), (ins i16mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002849 "movz{wl|x}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002850 [(set GR32:$dst, (zextloadi32i16 addr:$src))]>, TB;
2851
Chris Lattnerc90ee9c2008-01-10 07:59:24 +00002852let neverHasSideEffects = 1 in {
2853 let Defs = [AX], Uses = [AL] in
2854 def CBW : I<0x98, RawFrm, (outs), (ins),
2855 "{cbtw|cbw}", []>, OpSize; // AX = signext(AL)
2856 let Defs = [EAX], Uses = [AX] in
2857 def CWDE : I<0x98, RawFrm, (outs), (ins),
2858 "{cwtl|cwde}", []>; // EAX = signext(AX)
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002859
Chris Lattnerc90ee9c2008-01-10 07:59:24 +00002860 let Defs = [AX,DX], Uses = [AX] in
2861 def CWD : I<0x99, RawFrm, (outs), (ins),
2862 "{cwtd|cwd}", []>, OpSize; // DX:AX = signext(AX)
2863 let Defs = [EAX,EDX], Uses = [EAX] in
2864 def CDQ : I<0x99, RawFrm, (outs), (ins),
2865 "{cltd|cdq}", []>; // EDX:EAX = signext(EAX)
2866}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002867
2868//===----------------------------------------------------------------------===//
2869// Alias Instructions
2870//===----------------------------------------------------------------------===//
2871
2872// Alias instructions that map movr0 to xor.
2873// FIXME: remove when we can teach regalloc that xor reg, reg is ok.
Bill Wendlingba5d5b02008-05-29 01:02:09 +00002874let Defs = [EFLAGS], isReMaterializable = 1, isAsCheapAsAMove = 1 in {
Evan Chengb783fa32007-07-19 01:14:50 +00002875def MOV8r0 : I<0x30, MRMInitReg, (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002876 "xor{b}\t$dst, $dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002877 [(set GR8:$dst, 0)]>;
Dan Gohman9203ab42008-07-30 18:09:17 +00002878// Use xorl instead of xorw since we don't care about the high 16 bits,
2879// it's smaller, and it avoids a partial-register update.
Evan Chengb783fa32007-07-19 01:14:50 +00002880def MOV16r0 : I<0x31, MRMInitReg, (outs GR16:$dst), (ins),
Dan Gohman9203ab42008-07-30 18:09:17 +00002881 "xor{l}\t${dst:subreg32}, ${dst:subreg32}",
2882 [(set GR16:$dst, 0)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002883def MOV32r0 : I<0x31, MRMInitReg, (outs GR32:$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002884 "xor{l}\t$dst, $dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002885 [(set GR32:$dst, 0)]>;
Dan Gohman8aef09b2007-09-07 21:32:51 +00002886}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002887
2888// Basic operations on GR16 / GR32 subclasses GR16_ and GR32_ which contains only
2889// those registers that have GR8 sub-registers (i.e. AX - DX, EAX - EDX).
Evan Chengbd0ca9c2009-02-05 08:42:55 +00002890let neverHasSideEffects = 1, isAsCheapAsAMove = 1 in {
Evan Chengb783fa32007-07-19 01:14:50 +00002891def MOV16to16_ : I<0x89, MRMDestReg, (outs GR16_:$dst), (ins GR16:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002892 "mov{w}\t{$src, $dst|$dst, $src}", []>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002893def MOV32to32_ : I<0x89, MRMDestReg, (outs GR32_:$dst), (ins GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002894 "mov{l}\t{$src, $dst|$dst, $src}", []>;
Chris Lattnerc90ee9c2008-01-10 07:59:24 +00002895
Evan Chengb783fa32007-07-19 01:14:50 +00002896def MOV16_rr : I<0x89, MRMDestReg, (outs GR16_:$dst), (ins GR16_:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002897 "mov{w}\t{$src, $dst|$dst, $src}", []>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002898def MOV32_rr : I<0x89, MRMDestReg, (outs GR32_:$dst), (ins GR32_:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002899 "mov{l}\t{$src, $dst|$dst, $src}", []>;
Chris Lattnerc90ee9c2008-01-10 07:59:24 +00002900} // neverHasSideEffects
2901
Dan Gohman5574cc72008-12-03 18:15:48 +00002902let canFoldAsLoad = 1, mayLoad = 1, isReMaterializable = 1, mayHaveSideEffects = 1 in {
Evan Chengb783fa32007-07-19 01:14:50 +00002903def MOV16_rm : I<0x8B, MRMSrcMem, (outs GR16_:$dst), (ins i16mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002904 "mov{w}\t{$src, $dst|$dst, $src}", []>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002905def MOV32_rm : I<0x8B, MRMSrcMem, (outs GR32_:$dst), (ins i32mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002906 "mov{l}\t{$src, $dst|$dst, $src}", []>;
Evan Cheng4e84e452007-08-30 05:49:43 +00002907}
Chris Lattnerc90ee9c2008-01-10 07:59:24 +00002908let mayStore = 1, neverHasSideEffects = 1 in {
Evan Chengb783fa32007-07-19 01:14:50 +00002909def MOV16_mr : I<0x89, MRMDestMem, (outs), (ins i16mem:$dst, GR16_:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002910 "mov{w}\t{$src, $dst|$dst, $src}", []>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002911def MOV32_mr : I<0x89, MRMDestMem, (outs), (ins i32mem:$dst, GR32_:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002912 "mov{l}\t{$src, $dst|$dst, $src}", []>;
Chris Lattnerc90ee9c2008-01-10 07:59:24 +00002913}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002914
2915//===----------------------------------------------------------------------===//
2916// Thread Local Storage Instructions
2917//
2918
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002919let Uses = [EBX] in
Anton Korobeynikov4fbf00b2008-05-04 21:36:32 +00002920def TLS_addr32 : I<0, Pseudo, (outs GR32:$dst), (ins i32imm:$sym),
2921 "leal\t${sym:mem}(,%ebx,1), $dst",
2922 [(set GR32:$dst, (X86tlsaddr tglobaltlsaddr:$sym))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002923
2924let AddedComplexity = 10 in
Anton Korobeynikov4fbf00b2008-05-04 21:36:32 +00002925def TLS_gs_rr : I<0, Pseudo, (outs GR32:$dst), (ins GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002926 "movl\t%gs:($src), $dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002927 [(set GR32:$dst, (load (add X86TLStp, GR32:$src)))]>;
2928
2929let AddedComplexity = 15 in
Nicolas Geoffray81580792008-10-25 15:22:06 +00002930def TLS_gs_ri : I<0x8B, Pseudo, (outs GR32:$dst), (ins i32imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002931 "movl\t%gs:${src:mem}, $dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002932 [(set GR32:$dst,
Nicolas Geoffray81580792008-10-25 15:22:06 +00002933 (load (add X86TLStp, (X86Wrapper tglobaltlsaddr:$src))))]>,
2934 SegGS;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002935
Nicolas Geoffray81580792008-10-25 15:22:06 +00002936def TLS_tp : I<0x8B, Pseudo, (outs GR32:$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002937 "movl\t%gs:0, $dst",
Nicolas Geoffray81580792008-10-25 15:22:06 +00002938 [(set GR32:$dst, X86TLStp)]>, SegGS;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002939
sampo9cc09a32009-01-26 01:24:32 +00002940let AddedComplexity = 5 in
2941def GS_MOV32rm : I<0x8B, MRMSrcMem, (outs GR32:$dst), (ins i32mem:$src),
2942 "movl\t%gs:$src, $dst",
2943 [(set GR32:$dst, (gsload addr:$src))]>, SegGS;
2944
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002945//===----------------------------------------------------------------------===//
2946// DWARF Pseudo Instructions
2947//
2948
Evan Chengb783fa32007-07-19 01:14:50 +00002949def DWARF_LOC : I<0, Pseudo, (outs),
2950 (ins i32imm:$line, i32imm:$col, i32imm:$file),
Dan Gohman77af4a82007-09-24 19:25:06 +00002951 ".loc\t${file:debug} ${line:debug} ${col:debug}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002952 [(dwarf_loc (i32 imm:$line), (i32 imm:$col),
2953 (i32 imm:$file))]>;
2954
2955//===----------------------------------------------------------------------===//
2956// EH Pseudo Instructions
2957//
2958let isTerminator = 1, isReturn = 1, isBarrier = 1,
Evan Cheng37e7c752007-07-21 00:34:19 +00002959 hasCtrlDep = 1 in {
Evan Chengb783fa32007-07-19 01:14:50 +00002960def EH_RETURN : I<0xC3, RawFrm, (outs), (ins GR32:$addr),
Dan Gohman91888f02007-07-31 20:11:57 +00002961 "ret\t#eh_return, addr: $addr",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002962 [(X86ehret GR32:$addr)]>;
2963
2964}
2965
2966//===----------------------------------------------------------------------===//
Andrew Lenharthe44f3902008-02-21 06:45:13 +00002967// Atomic support
2968//
Andrew Lenharth7a5a4b22008-03-01 13:37:02 +00002969
Evan Cheng3e171562008-04-19 01:20:30 +00002970// Atomic swap. These are just normal xchg instructions. But since a memory
2971// operand is referenced, the atomicity is ensured.
Dan Gohmana41a1c092008-08-06 15:52:50 +00002972let Constraints = "$val = $dst" in {
Evan Cheng3e171562008-04-19 01:20:30 +00002973def XCHG32rm : I<0x87, MRMSrcMem, (outs GR32:$dst), (ins i32mem:$ptr, GR32:$val),
2974 "xchg{l}\t{$val, $ptr|$ptr, $val}",
2975 [(set GR32:$dst, (atomic_swap_32 addr:$ptr, GR32:$val))]>;
2976def XCHG16rm : I<0x87, MRMSrcMem, (outs GR16:$dst), (ins i16mem:$ptr, GR16:$val),
2977 "xchg{w}\t{$val, $ptr|$ptr, $val}",
2978 [(set GR16:$dst, (atomic_swap_16 addr:$ptr, GR16:$val))]>,
2979 OpSize;
2980def XCHG8rm : I<0x86, MRMSrcMem, (outs GR8:$dst), (ins i8mem:$ptr, GR8:$val),
2981 "xchg{b}\t{$val, $ptr|$ptr, $val}",
2982 [(set GR8:$dst, (atomic_swap_8 addr:$ptr, GR8:$val))]>;
2983}
2984
Evan Chengd49dbb82008-04-18 20:55:36 +00002985// Atomic compare and swap.
Andrew Lenharth7dfe23f2008-03-01 21:52:34 +00002986let Defs = [EAX, EFLAGS], Uses = [EAX] in {
Evan Chengd49dbb82008-04-18 20:55:36 +00002987def LCMPXCHG32 : I<0xB1, MRMDestMem, (outs), (ins i32mem:$ptr, GR32:$swap),
Dale Johannesend20e4452008-08-19 18:47:28 +00002988 "lock\n\tcmpxchg{l}\t{$swap, $ptr|$ptr, $swap}",
Evan Cheng09fbdee2008-03-04 03:20:06 +00002989 [(X86cas addr:$ptr, GR32:$swap, 4)]>, TB, LOCK;
Andrew Lenharth7a5a4b22008-03-01 13:37:02 +00002990}
Dale Johannesenf160d802008-10-02 18:53:47 +00002991let Defs = [EAX, EDX, EFLAGS], Uses = [EAX, EBX, ECX, EDX] in {
Anton Korobeynikovc4067392008-07-22 16:22:48 +00002992def LCMPXCHG8B : I<0xC7, MRM1m, (outs), (ins i32mem:$ptr),
Dale Johannesend20e4452008-08-19 18:47:28 +00002993 "lock\n\tcmpxchg8b\t$ptr",
Andrew Lenharth81580822008-03-05 01:15:49 +00002994 [(X86cas8 addr:$ptr)]>, TB, LOCK;
2995}
Andrew Lenharth7dfe23f2008-03-01 21:52:34 +00002996
2997let Defs = [AX, EFLAGS], Uses = [AX] in {
Evan Chengd49dbb82008-04-18 20:55:36 +00002998def LCMPXCHG16 : I<0xB1, MRMDestMem, (outs), (ins i16mem:$ptr, GR16:$swap),
Dale Johannesend20e4452008-08-19 18:47:28 +00002999 "lock\n\tcmpxchg{w}\t{$swap, $ptr|$ptr, $swap}",
Evan Cheng09fbdee2008-03-04 03:20:06 +00003000 [(X86cas addr:$ptr, GR16:$swap, 2)]>, TB, OpSize, LOCK;
Andrew Lenharth7a5a4b22008-03-01 13:37:02 +00003001}
Andrew Lenharth7dfe23f2008-03-01 21:52:34 +00003002let Defs = [AL, EFLAGS], Uses = [AL] in {
Evan Chengd49dbb82008-04-18 20:55:36 +00003003def LCMPXCHG8 : I<0xB0, MRMDestMem, (outs), (ins i8mem:$ptr, GR8:$swap),
Dale Johannesend20e4452008-08-19 18:47:28 +00003004 "lock\n\tcmpxchg{b}\t{$swap, $ptr|$ptr, $swap}",
Evan Cheng09fbdee2008-03-04 03:20:06 +00003005 [(X86cas addr:$ptr, GR8:$swap, 1)]>, TB, LOCK;
Andrew Lenharth7a5a4b22008-03-01 13:37:02 +00003006}
3007
Evan Chengd49dbb82008-04-18 20:55:36 +00003008// Atomic exchange and add
3009let Constraints = "$val = $dst", Defs = [EFLAGS] in {
3010def LXADD32 : I<0xC1, MRMSrcMem, (outs GR32:$dst), (ins i32mem:$ptr, GR32:$val),
Dale Johannesend20e4452008-08-19 18:47:28 +00003011 "lock\n\txadd{l}\t{$val, $ptr|$ptr, $val}",
Mon P Wang6bde9ec2008-06-25 08:15:39 +00003012 [(set GR32:$dst, (atomic_load_add_32 addr:$ptr, GR32:$val))]>,
Evan Chengd49dbb82008-04-18 20:55:36 +00003013 TB, LOCK;
3014def LXADD16 : I<0xC1, MRMSrcMem, (outs GR16:$dst), (ins i16mem:$ptr, GR16:$val),
Dale Johannesend20e4452008-08-19 18:47:28 +00003015 "lock\n\txadd{w}\t{$val, $ptr|$ptr, $val}",
Mon P Wang6bde9ec2008-06-25 08:15:39 +00003016 [(set GR16:$dst, (atomic_load_add_16 addr:$ptr, GR16:$val))]>,
Evan Chengd49dbb82008-04-18 20:55:36 +00003017 TB, OpSize, LOCK;
3018def LXADD8 : I<0xC0, MRMSrcMem, (outs GR8:$dst), (ins i8mem:$ptr, GR8:$val),
Dale Johannesend20e4452008-08-19 18:47:28 +00003019 "lock\n\txadd{b}\t{$val, $ptr|$ptr, $val}",
Mon P Wang6bde9ec2008-06-25 08:15:39 +00003020 [(set GR8:$dst, (atomic_load_add_8 addr:$ptr, GR8:$val))]>,
Evan Chengd49dbb82008-04-18 20:55:36 +00003021 TB, LOCK;
Andrew Lenharth7a5a4b22008-03-01 13:37:02 +00003022}
3023
Mon P Wang6bde9ec2008-06-25 08:15:39 +00003024// Atomic exchange, and, or, xor
Mon P Wang078a62d2008-05-05 19:05:59 +00003025let Constraints = "$val = $dst", Defs = [EFLAGS],
3026 usesCustomDAGSchedInserter = 1 in {
Dan Gohman8aeb61f2008-05-12 20:22:45 +00003027def ATOMAND32 : I<0, Pseudo, (outs GR32:$dst),(ins i32mem:$ptr, GR32:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003028 "#ATOMAND32 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003029 [(set GR32:$dst, (atomic_load_and_32 addr:$ptr, GR32:$val))]>;
Dan Gohman8aeb61f2008-05-12 20:22:45 +00003030def ATOMOR32 : I<0, Pseudo, (outs GR32:$dst),(ins i32mem:$ptr, GR32:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003031 "#ATOMOR32 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003032 [(set GR32:$dst, (atomic_load_or_32 addr:$ptr, GR32:$val))]>;
Dan Gohman8aeb61f2008-05-12 20:22:45 +00003033def ATOMXOR32 : I<0, Pseudo,(outs GR32:$dst),(ins i32mem:$ptr, GR32:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003034 "#ATOMXOR32 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003035 [(set GR32:$dst, (atomic_load_xor_32 addr:$ptr, GR32:$val))]>;
Andrew Lenharthaf02d592008-06-14 05:48:15 +00003036def ATOMNAND32 : I<0, Pseudo,(outs GR32:$dst),(ins i32mem:$ptr, GR32:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003037 "#ATOMNAND32 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003038 [(set GR32:$dst, (atomic_load_nand_32 addr:$ptr, GR32:$val))]>;
Dan Gohman8aeb61f2008-05-12 20:22:45 +00003039def ATOMMIN32: I<0, Pseudo, (outs GR32:$dst), (ins i32mem:$ptr, GR32:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003040 "#ATOMMIN32 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003041 [(set GR32:$dst, (atomic_load_min_32 addr:$ptr, GR32:$val))]>;
Dan Gohman8aeb61f2008-05-12 20:22:45 +00003042def ATOMMAX32: I<0, Pseudo, (outs GR32:$dst),(ins i32mem:$ptr, GR32:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003043 "#ATOMMAX32 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003044 [(set GR32:$dst, (atomic_load_max_32 addr:$ptr, GR32:$val))]>;
Dan Gohman8aeb61f2008-05-12 20:22:45 +00003045def ATOMUMIN32: I<0, Pseudo, (outs GR32:$dst),(ins i32mem:$ptr, GR32:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003046 "#ATOMUMIN32 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003047 [(set GR32:$dst, (atomic_load_umin_32 addr:$ptr, GR32:$val))]>;
Dan Gohman8aeb61f2008-05-12 20:22:45 +00003048def ATOMUMAX32: I<0, Pseudo, (outs GR32:$dst),(ins i32mem:$ptr, GR32:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003049 "#ATOMUMAX32 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003050 [(set GR32:$dst, (atomic_load_umax_32 addr:$ptr, GR32:$val))]>;
Dale Johannesend20e4452008-08-19 18:47:28 +00003051
3052def ATOMAND16 : I<0, Pseudo, (outs GR16:$dst),(ins i16mem:$ptr, GR16:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003053 "#ATOMAND16 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003054 [(set GR16:$dst, (atomic_load_and_16 addr:$ptr, GR16:$val))]>;
Dale Johannesend20e4452008-08-19 18:47:28 +00003055def ATOMOR16 : I<0, Pseudo, (outs GR16:$dst),(ins i16mem:$ptr, GR16:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003056 "#ATOMOR16 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003057 [(set GR16:$dst, (atomic_load_or_16 addr:$ptr, GR16:$val))]>;
Dale Johannesend20e4452008-08-19 18:47:28 +00003058def ATOMXOR16 : I<0, Pseudo,(outs GR16:$dst),(ins i16mem:$ptr, GR16:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003059 "#ATOMXOR16 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003060 [(set GR16:$dst, (atomic_load_xor_16 addr:$ptr, GR16:$val))]>;
Dale Johannesend20e4452008-08-19 18:47:28 +00003061def ATOMNAND16 : I<0, Pseudo,(outs GR16:$dst),(ins i16mem:$ptr, GR16:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003062 "#ATOMNAND16 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003063 [(set GR16:$dst, (atomic_load_nand_16 addr:$ptr, GR16:$val))]>;
Dale Johannesend20e4452008-08-19 18:47:28 +00003064def ATOMMIN16: I<0, Pseudo, (outs GR16:$dst), (ins i16mem:$ptr, GR16:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003065 "#ATOMMIN16 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003066 [(set GR16:$dst, (atomic_load_min_16 addr:$ptr, GR16:$val))]>;
Dale Johannesend20e4452008-08-19 18:47:28 +00003067def ATOMMAX16: I<0, Pseudo, (outs GR16:$dst),(ins i16mem:$ptr, GR16:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003068 "#ATOMMAX16 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003069 [(set GR16:$dst, (atomic_load_max_16 addr:$ptr, GR16:$val))]>;
Dale Johannesend20e4452008-08-19 18:47:28 +00003070def ATOMUMIN16: I<0, Pseudo, (outs GR16:$dst),(ins i16mem:$ptr, GR16:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003071 "#ATOMUMIN16 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003072 [(set GR16:$dst, (atomic_load_umin_16 addr:$ptr, GR16:$val))]>;
Dale Johannesend20e4452008-08-19 18:47:28 +00003073def ATOMUMAX16: I<0, Pseudo, (outs GR16:$dst),(ins i16mem:$ptr, GR16:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003074 "#ATOMUMAX16 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003075 [(set GR16:$dst, (atomic_load_umax_16 addr:$ptr, GR16:$val))]>;
Dale Johannesend20e4452008-08-19 18:47:28 +00003076
3077def ATOMAND8 : I<0, Pseudo, (outs GR8:$dst),(ins i8mem:$ptr, GR8:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003078 "#ATOMAND8 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003079 [(set GR8:$dst, (atomic_load_and_8 addr:$ptr, GR8:$val))]>;
Dale Johannesend20e4452008-08-19 18:47:28 +00003080def ATOMOR8 : I<0, Pseudo, (outs GR8:$dst),(ins i8mem:$ptr, GR8:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003081 "#ATOMOR8 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003082 [(set GR8:$dst, (atomic_load_or_8 addr:$ptr, GR8:$val))]>;
Dale Johannesend20e4452008-08-19 18:47:28 +00003083def ATOMXOR8 : I<0, Pseudo,(outs GR8:$dst),(ins i8mem:$ptr, GR8:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003084 "#ATOMXOR8 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003085 [(set GR8:$dst, (atomic_load_xor_8 addr:$ptr, GR8:$val))]>;
Dale Johannesend20e4452008-08-19 18:47:28 +00003086def ATOMNAND8 : I<0, Pseudo,(outs GR8:$dst),(ins i8mem:$ptr, GR8:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003087 "#ATOMNAND8 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003088 [(set GR8:$dst, (atomic_load_nand_8 addr:$ptr, GR8:$val))]>;
Mon P Wang078a62d2008-05-05 19:05:59 +00003089}
3090
Dale Johannesenf160d802008-10-02 18:53:47 +00003091let Constraints = "$val1 = $dst1, $val2 = $dst2",
3092 Defs = [EFLAGS, EAX, EBX, ECX, EDX],
3093 Uses = [EAX, EBX, ECX, EDX],
Dale Johannesen44eb5372008-10-03 19:41:08 +00003094 mayLoad = 1, mayStore = 1,
Dale Johannesenf160d802008-10-02 18:53:47 +00003095 usesCustomDAGSchedInserter = 1 in {
3096def ATOMAND6432 : I<0, Pseudo, (outs GR32:$dst1, GR32:$dst2),
3097 (ins i64mem:$ptr, GR32:$val1, GR32:$val2),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003098 "#ATOMAND6432 PSEUDO!", []>;
Dale Johannesenf160d802008-10-02 18:53:47 +00003099def ATOMOR6432 : I<0, Pseudo, (outs GR32:$dst1, GR32:$dst2),
3100 (ins i64mem:$ptr, GR32:$val1, GR32:$val2),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003101 "#ATOMOR6432 PSEUDO!", []>;
Dale Johannesenf160d802008-10-02 18:53:47 +00003102def ATOMXOR6432 : I<0, Pseudo, (outs GR32:$dst1, GR32:$dst2),
3103 (ins i64mem:$ptr, GR32:$val1, GR32:$val2),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003104 "#ATOMXOR6432 PSEUDO!", []>;
Dale Johannesenf160d802008-10-02 18:53:47 +00003105def ATOMNAND6432 : I<0, Pseudo, (outs GR32:$dst1, GR32:$dst2),
3106 (ins i64mem:$ptr, GR32:$val1, GR32:$val2),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003107 "#ATOMNAND6432 PSEUDO!", []>;
Dale Johannesenf160d802008-10-02 18:53:47 +00003108def ATOMADD6432 : I<0, Pseudo, (outs GR32:$dst1, GR32:$dst2),
3109 (ins i64mem:$ptr, GR32:$val1, GR32:$val2),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003110 "#ATOMADD6432 PSEUDO!", []>;
Dale Johannesenf160d802008-10-02 18:53:47 +00003111def ATOMSUB6432 : I<0, Pseudo, (outs GR32:$dst1, GR32:$dst2),
3112 (ins i64mem:$ptr, GR32:$val1, GR32:$val2),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003113 "#ATOMSUB6432 PSEUDO!", []>;
Dale Johannesen51c58ee2008-10-03 22:25:52 +00003114def ATOMSWAP6432 : I<0, Pseudo, (outs GR32:$dst1, GR32:$dst2),
3115 (ins i64mem:$ptr, GR32:$val1, GR32:$val2),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003116 "#ATOMSWAP6432 PSEUDO!", []>;
Dale Johannesenf160d802008-10-02 18:53:47 +00003117}
3118
Andrew Lenharthe44f3902008-02-21 06:45:13 +00003119//===----------------------------------------------------------------------===//
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003120// Non-Instruction Patterns
3121//===----------------------------------------------------------------------===//
3122
Bill Wendlingfef06052008-09-16 21:48:12 +00003123// ConstantPool GlobalAddress, ExternalSymbol, and JumpTable
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003124def : Pat<(i32 (X86Wrapper tconstpool :$dst)), (MOV32ri tconstpool :$dst)>;
3125def : Pat<(i32 (X86Wrapper tjumptable :$dst)), (MOV32ri tjumptable :$dst)>;
Nate Begemanb52948972008-04-12 00:47:57 +00003126def : Pat<(i32 (X86Wrapper tglobaltlsaddr:$dst)),(MOV32ri tglobaltlsaddr:$dst)>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003127def : Pat<(i32 (X86Wrapper tglobaladdr :$dst)), (MOV32ri tglobaladdr :$dst)>;
3128def : Pat<(i32 (X86Wrapper texternalsym:$dst)), (MOV32ri texternalsym:$dst)>;
3129
3130def : Pat<(add GR32:$src1, (X86Wrapper tconstpool:$src2)),
3131 (ADD32ri GR32:$src1, tconstpool:$src2)>;
3132def : Pat<(add GR32:$src1, (X86Wrapper tjumptable:$src2)),
3133 (ADD32ri GR32:$src1, tjumptable:$src2)>;
3134def : Pat<(add GR32:$src1, (X86Wrapper tglobaladdr :$src2)),
3135 (ADD32ri GR32:$src1, tglobaladdr:$src2)>;
3136def : Pat<(add GR32:$src1, (X86Wrapper texternalsym:$src2)),
3137 (ADD32ri GR32:$src1, texternalsym:$src2)>;
3138
3139def : Pat<(store (i32 (X86Wrapper tglobaladdr:$src)), addr:$dst),
3140 (MOV32mi addr:$dst, tglobaladdr:$src)>;
3141def : Pat<(store (i32 (X86Wrapper texternalsym:$src)), addr:$dst),
3142 (MOV32mi addr:$dst, texternalsym:$src)>;
3143
3144// Calls
Arnold Schwaighofere2d6bbb2007-10-11 19:40:01 +00003145// tailcall stuff
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003146def : Pat<(X86tailcall GR32:$dst),
Arnold Schwaighofere2d6bbb2007-10-11 19:40:01 +00003147 (TAILCALL)>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003148
3149def : Pat<(X86tailcall (i32 tglobaladdr:$dst)),
Arnold Schwaighofere2d6bbb2007-10-11 19:40:01 +00003150 (TAILCALL)>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003151def : Pat<(X86tailcall (i32 texternalsym:$dst)),
Arnold Schwaighofere2d6bbb2007-10-11 19:40:01 +00003152 (TAILCALL)>;
3153
3154def : Pat<(X86tcret GR32:$dst, imm:$off),
3155 (TCRETURNri GR32:$dst, imm:$off)>;
3156
3157def : Pat<(X86tcret (i32 tglobaladdr:$dst), imm:$off),
3158 (TCRETURNdi texternalsym:$dst, imm:$off)>;
3159
3160def : Pat<(X86tcret (i32 texternalsym:$dst), imm:$off),
3161 (TCRETURNdi texternalsym:$dst, imm:$off)>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003162
3163def : Pat<(X86call (i32 tglobaladdr:$dst)),
3164 (CALLpcrel32 tglobaladdr:$dst)>;
3165def : Pat<(X86call (i32 texternalsym:$dst)),
3166 (CALLpcrel32 texternalsym:$dst)>;
3167
3168// X86 specific add which produces a flag.
3169def : Pat<(addc GR32:$src1, GR32:$src2),
3170 (ADD32rr GR32:$src1, GR32:$src2)>;
3171def : Pat<(addc GR32:$src1, (load addr:$src2)),
3172 (ADD32rm GR32:$src1, addr:$src2)>;
3173def : Pat<(addc GR32:$src1, imm:$src2),
3174 (ADD32ri GR32:$src1, imm:$src2)>;
3175def : Pat<(addc GR32:$src1, i32immSExt8:$src2),
3176 (ADD32ri8 GR32:$src1, i32immSExt8:$src2)>;
3177
3178def : Pat<(subc GR32:$src1, GR32:$src2),
3179 (SUB32rr GR32:$src1, GR32:$src2)>;
3180def : Pat<(subc GR32:$src1, (load addr:$src2)),
3181 (SUB32rm GR32:$src1, addr:$src2)>;
3182def : Pat<(subc GR32:$src1, imm:$src2),
3183 (SUB32ri GR32:$src1, imm:$src2)>;
3184def : Pat<(subc GR32:$src1, i32immSExt8:$src2),
3185 (SUB32ri8 GR32:$src1, i32immSExt8:$src2)>;
3186
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003187// Comparisons.
3188
3189// TEST R,R is smaller than CMP R,0
Evan Cheng621216e2007-09-29 00:00:36 +00003190def : Pat<(parallel (X86cmp GR8:$src1, 0), (implicit EFLAGS)),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003191 (TEST8rr GR8:$src1, GR8:$src1)>;
Evan Cheng621216e2007-09-29 00:00:36 +00003192def : Pat<(parallel (X86cmp GR16:$src1, 0), (implicit EFLAGS)),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003193 (TEST16rr GR16:$src1, GR16:$src1)>;
Evan Cheng621216e2007-09-29 00:00:36 +00003194def : Pat<(parallel (X86cmp GR32:$src1, 0), (implicit EFLAGS)),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003195 (TEST32rr GR32:$src1, GR32:$src1)>;
3196
Dan Gohman0a3c5222009-01-07 01:00:24 +00003197// Conditional moves with folded loads with operands swapped and conditions
3198// inverted.
3199def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_B, EFLAGS),
3200 (CMOVAE16rm GR16:$src2, addr:$src1)>;
3201def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_B, EFLAGS),
3202 (CMOVAE32rm GR32:$src2, addr:$src1)>;
3203def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_AE, EFLAGS),
3204 (CMOVB16rm GR16:$src2, addr:$src1)>;
3205def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_AE, EFLAGS),
3206 (CMOVB32rm GR32:$src2, addr:$src1)>;
3207def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_E, EFLAGS),
3208 (CMOVNE16rm GR16:$src2, addr:$src1)>;
3209def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_E, EFLAGS),
3210 (CMOVNE32rm GR32:$src2, addr:$src1)>;
3211def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_NE, EFLAGS),
3212 (CMOVE16rm GR16:$src2, addr:$src1)>;
3213def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_NE, EFLAGS),
3214 (CMOVE32rm GR32:$src2, addr:$src1)>;
3215def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_BE, EFLAGS),
3216 (CMOVA16rm GR16:$src2, addr:$src1)>;
3217def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_BE, EFLAGS),
3218 (CMOVA32rm GR32:$src2, addr:$src1)>;
3219def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_A, EFLAGS),
3220 (CMOVBE16rm GR16:$src2, addr:$src1)>;
3221def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_A, EFLAGS),
3222 (CMOVBE32rm GR32:$src2, addr:$src1)>;
3223def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_L, EFLAGS),
3224 (CMOVGE16rm GR16:$src2, addr:$src1)>;
3225def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_L, EFLAGS),
3226 (CMOVGE32rm GR32:$src2, addr:$src1)>;
3227def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_GE, EFLAGS),
3228 (CMOVL16rm GR16:$src2, addr:$src1)>;
3229def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_GE, EFLAGS),
3230 (CMOVL32rm GR32:$src2, addr:$src1)>;
3231def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_LE, EFLAGS),
3232 (CMOVG16rm GR16:$src2, addr:$src1)>;
3233def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_LE, EFLAGS),
3234 (CMOVG32rm GR32:$src2, addr:$src1)>;
3235def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_G, EFLAGS),
3236 (CMOVLE16rm GR16:$src2, addr:$src1)>;
3237def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_G, EFLAGS),
3238 (CMOVLE32rm GR32:$src2, addr:$src1)>;
3239def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_P, EFLAGS),
3240 (CMOVNP16rm GR16:$src2, addr:$src1)>;
3241def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_P, EFLAGS),
3242 (CMOVNP32rm GR32:$src2, addr:$src1)>;
3243def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_NP, EFLAGS),
3244 (CMOVP16rm GR16:$src2, addr:$src1)>;
3245def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_NP, EFLAGS),
3246 (CMOVP32rm GR32:$src2, addr:$src1)>;
3247def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_S, EFLAGS),
3248 (CMOVNS16rm GR16:$src2, addr:$src1)>;
3249def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_S, EFLAGS),
3250 (CMOVNS32rm GR32:$src2, addr:$src1)>;
3251def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_NS, EFLAGS),
3252 (CMOVS16rm GR16:$src2, addr:$src1)>;
3253def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_NS, EFLAGS),
3254 (CMOVS32rm GR32:$src2, addr:$src1)>;
3255def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_O, EFLAGS),
3256 (CMOVNO16rm GR16:$src2, addr:$src1)>;
3257def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_O, EFLAGS),
3258 (CMOVNO32rm GR32:$src2, addr:$src1)>;
3259def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_NO, EFLAGS),
3260 (CMOVO16rm GR16:$src2, addr:$src1)>;
3261def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_NO, EFLAGS),
3262 (CMOVO32rm GR32:$src2, addr:$src1)>;
3263
Duncan Sands082524c2008-01-23 20:39:46 +00003264// zextload bool -> zextload byte
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003265def : Pat<(zextloadi8i1 addr:$src), (MOV8rm addr:$src)>;
3266def : Pat<(zextloadi16i1 addr:$src), (MOVZX16rm8 addr:$src)>;
3267def : Pat<(zextloadi32i1 addr:$src), (MOVZX32rm8 addr:$src)>;
3268
3269// extload bool -> extload byte
3270def : Pat<(extloadi8i1 addr:$src), (MOV8rm addr:$src)>;
Bill Wendlingce1c5c12008-08-22 20:51:05 +00003271def : Pat<(extloadi16i1 addr:$src), (MOVZX16rm8 addr:$src)>,
3272 Requires<[In32BitMode]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003273def : Pat<(extloadi32i1 addr:$src), (MOVZX32rm8 addr:$src)>;
Bill Wendlingce1c5c12008-08-22 20:51:05 +00003274def : Pat<(extloadi16i8 addr:$src), (MOVZX16rm8 addr:$src)>,
3275 Requires<[In32BitMode]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003276def : Pat<(extloadi32i8 addr:$src), (MOVZX32rm8 addr:$src)>;
3277def : Pat<(extloadi32i16 addr:$src), (MOVZX32rm16 addr:$src)>;
3278
Dan Gohmandd612bb2008-08-20 21:27:32 +00003279// anyext
Bill Wendlingce1c5c12008-08-22 20:51:05 +00003280def : Pat<(i16 (anyext GR8 :$src)), (MOVZX16rr8 GR8 :$src)>,
3281 Requires<[In32BitMode]>;
3282def : Pat<(i32 (anyext GR8 :$src)), (MOVZX32rr8 GR8 :$src)>,
3283 Requires<[In32BitMode]>;
Dan Gohmandd612bb2008-08-20 21:27:32 +00003284def : Pat<(i32 (anyext GR16:$src)),
3285 (INSERT_SUBREG (i32 (IMPLICIT_DEF)), GR16:$src, x86_subreg_16bit)>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003286
Evan Chengf2abee72007-12-13 00:43:27 +00003287// (and (i32 load), 255) -> (zextload i8)
Evan Cheng1e5e5452008-09-29 17:26:18 +00003288def : Pat<(i32 (and (nvloadi32 addr:$src), (i32 255))),
3289 (MOVZX32rm8 addr:$src)>;
3290def : Pat<(i32 (and (nvloadi32 addr:$src), (i32 65535))),
3291 (MOVZX32rm16 addr:$src)>;
Evan Chengf2abee72007-12-13 00:43:27 +00003292
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003293//===----------------------------------------------------------------------===//
3294// Some peepholes
3295//===----------------------------------------------------------------------===//
3296
Dan Gohman5a5e6e92008-10-17 01:33:43 +00003297// Odd encoding trick: -128 fits into an 8-bit immediate field while
3298// +128 doesn't, so in this special case use a sub instead of an add.
3299def : Pat<(add GR16:$src1, 128),
3300 (SUB16ri8 GR16:$src1, -128)>;
3301def : Pat<(store (add (loadi16 addr:$dst), 128), addr:$dst),
3302 (SUB16mi8 addr:$dst, -128)>;
3303def : Pat<(add GR32:$src1, 128),
3304 (SUB32ri8 GR32:$src1, -128)>;
3305def : Pat<(store (add (loadi32 addr:$dst), 128), addr:$dst),
3306 (SUB32mi8 addr:$dst, -128)>;
3307
Dan Gohman9203ab42008-07-30 18:09:17 +00003308// r & (2^16-1) ==> movz
3309def : Pat<(and GR32:$src1, 0xffff),
Dan Gohmandd612bb2008-08-20 21:27:32 +00003310 (MOVZX32rr16 (i16 (EXTRACT_SUBREG GR32:$src1, x86_subreg_16bit)))>;
Dan Gohman5beb1ff2008-08-06 18:27:21 +00003311// r & (2^8-1) ==> movz
3312def : Pat<(and GR32:$src1, 0xff),
Dan Gohmandd612bb2008-08-20 21:27:32 +00003313 (MOVZX32rr8 (i8 (EXTRACT_SUBREG (MOV32to32_ GR32:$src1),
3314 x86_subreg_8bit)))>,
Dan Gohman5beb1ff2008-08-06 18:27:21 +00003315 Requires<[In32BitMode]>;
3316// r & (2^8-1) ==> movz
3317def : Pat<(and GR16:$src1, 0xff),
Dan Gohmandd612bb2008-08-20 21:27:32 +00003318 (MOVZX16rr8 (i8 (EXTRACT_SUBREG (MOV16to16_ GR16:$src1),
3319 x86_subreg_8bit)))>,
3320 Requires<[In32BitMode]>;
3321
3322// sext_inreg patterns
3323def : Pat<(sext_inreg GR32:$src, i16),
3324 (MOVSX32rr16 (i16 (EXTRACT_SUBREG GR32:$src, x86_subreg_16bit)))>;
3325def : Pat<(sext_inreg GR32:$src, i8),
3326 (MOVSX32rr8 (i8 (EXTRACT_SUBREG (MOV32to32_ GR32:$src),
3327 x86_subreg_8bit)))>,
3328 Requires<[In32BitMode]>;
3329def : Pat<(sext_inreg GR16:$src, i8),
3330 (MOVSX16rr8 (i8 (EXTRACT_SUBREG (MOV16to16_ GR16:$src),
3331 x86_subreg_8bit)))>,
3332 Requires<[In32BitMode]>;
3333
3334// trunc patterns
3335def : Pat<(i16 (trunc GR32:$src)),
3336 (i16 (EXTRACT_SUBREG GR32:$src, x86_subreg_16bit))>;
3337def : Pat<(i8 (trunc GR32:$src)),
3338 (i8 (EXTRACT_SUBREG (MOV32to32_ GR32:$src), x86_subreg_8bit))>,
3339 Requires<[In32BitMode]>;
3340def : Pat<(i8 (trunc GR16:$src)),
3341 (i8 (EXTRACT_SUBREG (MOV16to16_ GR16:$src), x86_subreg_8bit))>,
Dan Gohman5beb1ff2008-08-06 18:27:21 +00003342 Requires<[In32BitMode]>;
Dan Gohman9203ab42008-07-30 18:09:17 +00003343
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003344// (shl x, 1) ==> (add x, x)
3345def : Pat<(shl GR8 :$src1, (i8 1)), (ADD8rr GR8 :$src1, GR8 :$src1)>;
3346def : Pat<(shl GR16:$src1, (i8 1)), (ADD16rr GR16:$src1, GR16:$src1)>;
3347def : Pat<(shl GR32:$src1, (i8 1)), (ADD32rr GR32:$src1, GR32:$src1)>;
3348
Evan Cheng76a64c72008-08-30 02:03:58 +00003349// (shl x (and y, 31)) ==> (shl x, y)
3350def : Pat<(shl GR8:$src1, (and CL:$amt, 31)),
3351 (SHL8rCL GR8:$src1)>;
3352def : Pat<(shl GR16:$src1, (and CL:$amt, 31)),
3353 (SHL16rCL GR16:$src1)>;
3354def : Pat<(shl GR32:$src1, (and CL:$amt, 31)),
3355 (SHL32rCL GR32:$src1)>;
3356def : Pat<(store (shl (loadi8 addr:$dst), (and CL:$amt, 31)), addr:$dst),
3357 (SHL8mCL addr:$dst)>;
3358def : Pat<(store (shl (loadi16 addr:$dst), (and CL:$amt, 31)), addr:$dst),
3359 (SHL16mCL addr:$dst)>;
3360def : Pat<(store (shl (loadi32 addr:$dst), (and CL:$amt, 31)), addr:$dst),
3361 (SHL32mCL addr:$dst)>;
3362
3363def : Pat<(srl GR8:$src1, (and CL:$amt, 31)),
3364 (SHR8rCL GR8:$src1)>;
3365def : Pat<(srl GR16:$src1, (and CL:$amt, 31)),
3366 (SHR16rCL GR16:$src1)>;
3367def : Pat<(srl GR32:$src1, (and CL:$amt, 31)),
3368 (SHR32rCL GR32:$src1)>;
3369def : Pat<(store (srl (loadi8 addr:$dst), (and CL:$amt, 31)), addr:$dst),
3370 (SHR8mCL addr:$dst)>;
3371def : Pat<(store (srl (loadi16 addr:$dst), (and CL:$amt, 31)), addr:$dst),
3372 (SHR16mCL addr:$dst)>;
3373def : Pat<(store (srl (loadi32 addr:$dst), (and CL:$amt, 31)), addr:$dst),
3374 (SHR32mCL addr:$dst)>;
3375
3376def : Pat<(sra GR8:$src1, (and CL:$amt, 31)),
3377 (SAR8rCL GR8:$src1)>;
3378def : Pat<(sra GR16:$src1, (and CL:$amt, 31)),
3379 (SAR16rCL GR16:$src1)>;
3380def : Pat<(sra GR32:$src1, (and CL:$amt, 31)),
3381 (SAR32rCL GR32:$src1)>;
3382def : Pat<(store (sra (loadi8 addr:$dst), (and CL:$amt, 31)), addr:$dst),
3383 (SAR8mCL addr:$dst)>;
3384def : Pat<(store (sra (loadi16 addr:$dst), (and CL:$amt, 31)), addr:$dst),
3385 (SAR16mCL addr:$dst)>;
3386def : Pat<(store (sra (loadi32 addr:$dst), (and CL:$amt, 31)), addr:$dst),
3387 (SAR32mCL addr:$dst)>;
3388
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003389// (or (x >> c) | (y << (32 - c))) ==> (shrd32 x, y, c)
3390def : Pat<(or (srl GR32:$src1, CL:$amt),
3391 (shl GR32:$src2, (sub 32, CL:$amt))),
3392 (SHRD32rrCL GR32:$src1, GR32:$src2)>;
3393
3394def : Pat<(store (or (srl (loadi32 addr:$dst), CL:$amt),
3395 (shl GR32:$src2, (sub 32, CL:$amt))), addr:$dst),
3396 (SHRD32mrCL addr:$dst, GR32:$src2)>;
3397
Dan Gohman921581d2008-10-17 01:23:35 +00003398def : Pat<(or (srl GR32:$src1, (i8 (trunc ECX:$amt))),
3399 (shl GR32:$src2, (i8 (trunc (sub 32, ECX:$amt))))),
3400 (SHRD32rrCL GR32:$src1, GR32:$src2)>;
3401
3402def : Pat<(store (or (srl (loadi32 addr:$dst), (i8 (trunc ECX:$amt))),
3403 (shl GR32:$src2, (i8 (trunc (sub 32, ECX:$amt))))),
3404 addr:$dst),
3405 (SHRD32mrCL addr:$dst, GR32:$src2)>;
3406
3407def : Pat<(shrd GR32:$src1, (i8 imm:$amt1), GR32:$src2, (i8 imm:$amt2)),
3408 (SHRD32rri8 GR32:$src1, GR32:$src2, (i8 imm:$amt1))>;
3409
3410def : Pat<(store (shrd (loadi32 addr:$dst), (i8 imm:$amt1),
3411 GR32:$src2, (i8 imm:$amt2)), addr:$dst),
3412 (SHRD32mri8 addr:$dst, GR32:$src2, (i8 imm:$amt1))>;
3413
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003414// (or (x << c) | (y >> (32 - c))) ==> (shld32 x, y, c)
3415def : Pat<(or (shl GR32:$src1, CL:$amt),
3416 (srl GR32:$src2, (sub 32, CL:$amt))),
3417 (SHLD32rrCL GR32:$src1, GR32:$src2)>;
3418
3419def : Pat<(store (or (shl (loadi32 addr:$dst), CL:$amt),
3420 (srl GR32:$src2, (sub 32, CL:$amt))), addr:$dst),
3421 (SHLD32mrCL addr:$dst, GR32:$src2)>;
3422
Dan Gohman921581d2008-10-17 01:23:35 +00003423def : Pat<(or (shl GR32:$src1, (i8 (trunc ECX:$amt))),
3424 (srl GR32:$src2, (i8 (trunc (sub 32, ECX:$amt))))),
3425 (SHLD32rrCL GR32:$src1, GR32:$src2)>;
3426
3427def : Pat<(store (or (shl (loadi32 addr:$dst), (i8 (trunc ECX:$amt))),
3428 (srl GR32:$src2, (i8 (trunc (sub 32, ECX:$amt))))),
3429 addr:$dst),
3430 (SHLD32mrCL addr:$dst, GR32:$src2)>;
3431
3432def : Pat<(shld GR32:$src1, (i8 imm:$amt1), GR32:$src2, (i8 imm:$amt2)),
3433 (SHLD32rri8 GR32:$src1, GR32:$src2, (i8 imm:$amt1))>;
3434
3435def : Pat<(store (shld (loadi32 addr:$dst), (i8 imm:$amt1),
3436 GR32:$src2, (i8 imm:$amt2)), addr:$dst),
3437 (SHLD32mri8 addr:$dst, GR32:$src2, (i8 imm:$amt1))>;
3438
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003439// (or (x >> c) | (y << (16 - c))) ==> (shrd16 x, y, c)
3440def : Pat<(or (srl GR16:$src1, CL:$amt),
3441 (shl GR16:$src2, (sub 16, CL:$amt))),
3442 (SHRD16rrCL GR16:$src1, GR16:$src2)>;
3443
3444def : Pat<(store (or (srl (loadi16 addr:$dst), CL:$amt),
3445 (shl GR16:$src2, (sub 16, CL:$amt))), addr:$dst),
3446 (SHRD16mrCL addr:$dst, GR16:$src2)>;
3447
Dan Gohman921581d2008-10-17 01:23:35 +00003448def : Pat<(or (srl GR16:$src1, (i8 (trunc CX:$amt))),
3449 (shl GR16:$src2, (i8 (trunc (sub 16, CX:$amt))))),
3450 (SHRD16rrCL GR16:$src1, GR16:$src2)>;
3451
3452def : Pat<(store (or (srl (loadi16 addr:$dst), (i8 (trunc CX:$amt))),
3453 (shl GR16:$src2, (i8 (trunc (sub 16, CX:$amt))))),
3454 addr:$dst),
3455 (SHRD16mrCL addr:$dst, GR16:$src2)>;
3456
3457def : Pat<(shrd GR16:$src1, (i8 imm:$amt1), GR16:$src2, (i8 imm:$amt2)),
3458 (SHRD16rri8 GR16:$src1, GR16:$src2, (i8 imm:$amt1))>;
3459
3460def : Pat<(store (shrd (loadi16 addr:$dst), (i8 imm:$amt1),
3461 GR16:$src2, (i8 imm:$amt2)), addr:$dst),
3462 (SHRD16mri8 addr:$dst, GR16:$src2, (i8 imm:$amt1))>;
3463
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003464// (or (x << c) | (y >> (16 - c))) ==> (shld16 x, y, c)
3465def : Pat<(or (shl GR16:$src1, CL:$amt),
3466 (srl GR16:$src2, (sub 16, CL:$amt))),
3467 (SHLD16rrCL GR16:$src1, GR16:$src2)>;
3468
3469def : Pat<(store (or (shl (loadi16 addr:$dst), CL:$amt),
3470 (srl GR16:$src2, (sub 16, CL:$amt))), addr:$dst),
3471 (SHLD16mrCL addr:$dst, GR16:$src2)>;
3472
Dan Gohman921581d2008-10-17 01:23:35 +00003473def : Pat<(or (shl GR16:$src1, (i8 (trunc CX:$amt))),
3474 (srl GR16:$src2, (i8 (trunc (sub 16, CX:$amt))))),
3475 (SHLD16rrCL GR16:$src1, GR16:$src2)>;
3476
3477def : Pat<(store (or (shl (loadi16 addr:$dst), (i8 (trunc CX:$amt))),
3478 (srl GR16:$src2, (i8 (trunc (sub 16, CX:$amt))))),
3479 addr:$dst),
3480 (SHLD16mrCL addr:$dst, GR16:$src2)>;
3481
3482def : Pat<(shld GR16:$src1, (i8 imm:$amt1), GR16:$src2, (i8 imm:$amt2)),
3483 (SHLD16rri8 GR16:$src1, GR16:$src2, (i8 imm:$amt1))>;
3484
3485def : Pat<(store (shld (loadi16 addr:$dst), (i8 imm:$amt1),
3486 GR16:$src2, (i8 imm:$amt2)), addr:$dst),
3487 (SHLD16mri8 addr:$dst, GR16:$src2, (i8 imm:$amt1))>;
3488
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003489//===----------------------------------------------------------------------===//
Dan Gohman2ec42142009-03-04 03:54:19 +00003490// Overflow Patterns
Bill Wendlingf5399032008-12-12 21:15:41 +00003491//===----------------------------------------------------------------------===//
3492
Dan Gohman2ec42142009-03-04 03:54:19 +00003493// Register-Register Addition with Overflow
3494def : Pat<(parallel (X86add_ovf GR8:$src1, GR8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003495 (implicit EFLAGS)),
3496 (ADD8rr GR8:$src1, GR8:$src2)>;
3497
Dan Gohman2ec42142009-03-04 03:54:19 +00003498// Register-Register Addition with Overflow
3499def : Pat<(parallel (X86add_ovf GR16:$src1, GR16:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003500 (implicit EFLAGS)),
3501 (ADD16rr GR16:$src1, GR16:$src2)>;
Dan Gohman2ec42142009-03-04 03:54:19 +00003502def : Pat<(parallel (X86add_ovf GR32:$src1, GR32:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003503 (implicit EFLAGS)),
3504 (ADD32rr GR32:$src1, GR32:$src2)>;
3505
Dan Gohman2ec42142009-03-04 03:54:19 +00003506// Register-Memory Addition with Overflow
3507def : Pat<(parallel (X86add_ovf GR8:$src1, (load addr:$src2)),
Bill Wendlingf5399032008-12-12 21:15:41 +00003508 (implicit EFLAGS)),
3509 (ADD8rm GR8:$src1, addr:$src2)>;
Dan Gohman2ec42142009-03-04 03:54:19 +00003510def : Pat<(parallel (X86add_ovf GR16:$src1, (load addr:$src2)),
Bill Wendlingf5399032008-12-12 21:15:41 +00003511 (implicit EFLAGS)),
3512 (ADD16rm GR16:$src1, addr:$src2)>;
Dan Gohman2ec42142009-03-04 03:54:19 +00003513def : Pat<(parallel (X86add_ovf GR32:$src1, (load addr:$src2)),
Bill Wendlingf5399032008-12-12 21:15:41 +00003514 (implicit EFLAGS)),
3515 (ADD32rm GR32:$src1, addr:$src2)>;
3516
Dan Gohman2ec42142009-03-04 03:54:19 +00003517// Register-Integer Addition with Overflow
3518def : Pat<(parallel (X86add_ovf GR8:$src1, imm:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003519 (implicit EFLAGS)),
3520 (ADD8ri GR8:$src1, imm:$src2)>;
3521
Dan Gohman2ec42142009-03-04 03:54:19 +00003522// Register-Integer Addition with Overflow
3523def : Pat<(parallel (X86add_ovf GR16:$src1, imm:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003524 (implicit EFLAGS)),
3525 (ADD16ri GR16:$src1, imm:$src2)>;
Dan Gohman2ec42142009-03-04 03:54:19 +00003526def : Pat<(parallel (X86add_ovf GR32:$src1, imm:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003527 (implicit EFLAGS)),
3528 (ADD32ri GR32:$src1, imm:$src2)>;
Dan Gohman2ec42142009-03-04 03:54:19 +00003529def : Pat<(parallel (X86add_ovf GR16:$src1, i16immSExt8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003530 (implicit EFLAGS)),
3531 (ADD16ri8 GR16:$src1, i16immSExt8:$src2)>;
Dan Gohman2ec42142009-03-04 03:54:19 +00003532def : Pat<(parallel (X86add_ovf GR32:$src1, i32immSExt8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003533 (implicit EFLAGS)),
3534 (ADD32ri8 GR32:$src1, i32immSExt8:$src2)>;
3535
Dan Gohman2ec42142009-03-04 03:54:19 +00003536// Memory-Register Addition with Overflow
3537def : Pat<(parallel (store (X86add_ovf (load addr:$dst), GR8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003538 addr:$dst),
3539 (implicit EFLAGS)),
3540 (ADD8mr addr:$dst, GR8:$src2)>;
Dan Gohman2ec42142009-03-04 03:54:19 +00003541def : Pat<(parallel (store (X86add_ovf (load addr:$dst), GR16:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003542 addr:$dst),
3543 (implicit EFLAGS)),
3544 (ADD16mr addr:$dst, GR16:$src2)>;
Dan Gohman2ec42142009-03-04 03:54:19 +00003545def : Pat<(parallel (store (X86add_ovf (load addr:$dst), GR32:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003546 addr:$dst),
3547 (implicit EFLAGS)),
3548 (ADD32mr addr:$dst, GR32:$src2)>;
Dan Gohman2ec42142009-03-04 03:54:19 +00003549def : Pat<(parallel (store (X86add_ovf (loadi8 addr:$dst), imm:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003550 addr:$dst),
3551 (implicit EFLAGS)),
3552 (ADD8mi addr:$dst, imm:$src2)>;
Dan Gohman2ec42142009-03-04 03:54:19 +00003553def : Pat<(parallel (store (X86add_ovf (loadi16 addr:$dst), imm:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003554 addr:$dst),
3555 (implicit EFLAGS)),
3556 (ADD16mi addr:$dst, imm:$src2)>;
Dan Gohman2ec42142009-03-04 03:54:19 +00003557def : Pat<(parallel (store (X86add_ovf (loadi32 addr:$dst), imm:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003558 addr:$dst),
3559 (implicit EFLAGS)),
3560 (ADD32mi addr:$dst, imm:$src2)>;
Dan Gohman2ec42142009-03-04 03:54:19 +00003561def : Pat<(parallel (store (X86add_ovf (load addr:$dst), i16immSExt8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003562 addr:$dst),
3563 (implicit EFLAGS)),
3564 (ADD16mi8 addr:$dst, i16immSExt8:$src2)>;
Dan Gohman2ec42142009-03-04 03:54:19 +00003565def : Pat<(parallel (store (X86add_ovf (load addr:$dst), i32immSExt8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003566 addr:$dst),
3567 (implicit EFLAGS)),
3568 (ADD32mi8 addr:$dst, i32immSExt8:$src2)>;
3569
Dan Gohman2ec42142009-03-04 03:54:19 +00003570// Register-Register Subtraction with Overflow
3571def : Pat<(parallel (X86sub_ovf GR8:$src1, GR8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003572 (implicit EFLAGS)),
3573 (SUB8rr GR8:$src1, GR8:$src2)>;
Dan Gohman2ec42142009-03-04 03:54:19 +00003574def : Pat<(parallel (X86sub_ovf GR16:$src1, GR16:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003575 (implicit EFLAGS)),
3576 (SUB16rr GR16:$src1, GR16:$src2)>;
Dan Gohman2ec42142009-03-04 03:54:19 +00003577def : Pat<(parallel (X86sub_ovf GR32:$src1, GR32:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003578 (implicit EFLAGS)),
3579 (SUB32rr GR32:$src1, GR32:$src2)>;
3580
Dan Gohman2ec42142009-03-04 03:54:19 +00003581// Register-Memory Subtraction with Overflow
3582def : Pat<(parallel (X86sub_ovf GR8:$src1, (load addr:$src2)),
Bill Wendlingf5399032008-12-12 21:15:41 +00003583 (implicit EFLAGS)),
3584 (SUB8rm GR8:$src1, addr:$src2)>;
Dan Gohman2ec42142009-03-04 03:54:19 +00003585def : Pat<(parallel (X86sub_ovf GR16:$src1, (load addr:$src2)),
Bill Wendlingf5399032008-12-12 21:15:41 +00003586 (implicit EFLAGS)),
3587 (SUB16rm GR16:$src1, addr:$src2)>;
Dan Gohman2ec42142009-03-04 03:54:19 +00003588def : Pat<(parallel (X86sub_ovf GR32:$src1, (load addr:$src2)),
Bill Wendlingf5399032008-12-12 21:15:41 +00003589 (implicit EFLAGS)),
3590 (SUB32rm GR32:$src1, addr:$src2)>;
3591
Dan Gohman2ec42142009-03-04 03:54:19 +00003592// Register-Integer Subtraction with Overflow
3593def : Pat<(parallel (X86sub_ovf GR8:$src1, imm:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003594 (implicit EFLAGS)),
3595 (SUB8ri GR8:$src1, imm:$src2)>;
Dan Gohman2ec42142009-03-04 03:54:19 +00003596def : Pat<(parallel (X86sub_ovf GR16:$src1, imm:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003597 (implicit EFLAGS)),
3598 (SUB16ri GR16:$src1, imm:$src2)>;
Dan Gohman2ec42142009-03-04 03:54:19 +00003599def : Pat<(parallel (X86sub_ovf GR32:$src1, imm:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003600 (implicit EFLAGS)),
3601 (SUB32ri GR32:$src1, imm:$src2)>;
Dan Gohman2ec42142009-03-04 03:54:19 +00003602def : Pat<(parallel (X86sub_ovf GR16:$src1, i16immSExt8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003603 (implicit EFLAGS)),
3604 (SUB16ri8 GR16:$src1, i16immSExt8:$src2)>;
Dan Gohman2ec42142009-03-04 03:54:19 +00003605def : Pat<(parallel (X86sub_ovf GR32:$src1, i32immSExt8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003606 (implicit EFLAGS)),
3607 (SUB32ri8 GR32:$src1, i32immSExt8:$src2)>;
3608
Dan Gohman2ec42142009-03-04 03:54:19 +00003609// Memory-Register Subtraction with Overflow
3610def : Pat<(parallel (store (X86sub_ovf (load addr:$dst), GR8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003611 addr:$dst),
3612 (implicit EFLAGS)),
3613 (SUB8mr addr:$dst, GR8:$src2)>;
Dan Gohman2ec42142009-03-04 03:54:19 +00003614def : Pat<(parallel (store (X86sub_ovf (load addr:$dst), GR16:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003615 addr:$dst),
3616 (implicit EFLAGS)),
3617 (SUB16mr addr:$dst, GR16:$src2)>;
Dan Gohman2ec42142009-03-04 03:54:19 +00003618def : Pat<(parallel (store (X86sub_ovf (load addr:$dst), GR32:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003619 addr:$dst),
3620 (implicit EFLAGS)),
3621 (SUB32mr addr:$dst, GR32:$src2)>;
3622
Dan Gohman2ec42142009-03-04 03:54:19 +00003623// Memory-Integer Subtraction with Overflow
3624def : Pat<(parallel (store (X86sub_ovf (loadi8 addr:$dst), imm:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003625 addr:$dst),
3626 (implicit EFLAGS)),
3627 (SUB8mi addr:$dst, imm:$src2)>;
Dan Gohman2ec42142009-03-04 03:54:19 +00003628def : Pat<(parallel (store (X86sub_ovf (loadi16 addr:$dst), imm:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003629 addr:$dst),
3630 (implicit EFLAGS)),
3631 (SUB16mi addr:$dst, imm:$src2)>;
Dan Gohman2ec42142009-03-04 03:54:19 +00003632def : Pat<(parallel (store (X86sub_ovf (loadi32 addr:$dst), imm:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003633 addr:$dst),
3634 (implicit EFLAGS)),
3635 (SUB32mi addr:$dst, imm:$src2)>;
Dan Gohman2ec42142009-03-04 03:54:19 +00003636def : Pat<(parallel (store (X86sub_ovf (load addr:$dst), i16immSExt8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003637 addr:$dst),
3638 (implicit EFLAGS)),
3639 (SUB16mi8 addr:$dst, i16immSExt8:$src2)>;
Dan Gohman2ec42142009-03-04 03:54:19 +00003640def : Pat<(parallel (store (X86sub_ovf (load addr:$dst), i32immSExt8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003641 addr:$dst),
3642 (implicit EFLAGS)),
3643 (SUB32mi8 addr:$dst, i32immSExt8:$src2)>;
3644
3645
Dan Gohman2ec42142009-03-04 03:54:19 +00003646// Register-Register Signed Integer Multiply with Overflow
3647def : Pat<(parallel (X86smul_ovf GR16:$src1, GR16:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003648 (implicit EFLAGS)),
3649 (IMUL16rr GR16:$src1, GR16:$src2)>;
Dan Gohman2ec42142009-03-04 03:54:19 +00003650def : Pat<(parallel (X86smul_ovf GR32:$src1, GR32:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003651 (implicit EFLAGS)),
3652 (IMUL32rr GR32:$src1, GR32:$src2)>;
3653
Dan Gohman2ec42142009-03-04 03:54:19 +00003654// Register-Memory Signed Integer Multiply with Overflow
3655def : Pat<(parallel (X86smul_ovf GR16:$src1, (load addr:$src2)),
Bill Wendlingf5399032008-12-12 21:15:41 +00003656 (implicit EFLAGS)),
3657 (IMUL16rm GR16:$src1, addr:$src2)>;
Dan Gohman2ec42142009-03-04 03:54:19 +00003658def : Pat<(parallel (X86smul_ovf GR32:$src1, (load addr:$src2)),
Bill Wendlingf5399032008-12-12 21:15:41 +00003659 (implicit EFLAGS)),
3660 (IMUL32rm GR32:$src1, addr:$src2)>;
3661
Dan Gohman2ec42142009-03-04 03:54:19 +00003662// Register-Integer Signed Integer Multiply with Overflow
3663def : Pat<(parallel (X86smul_ovf GR16:$src1, imm:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003664 (implicit EFLAGS)),
3665 (IMUL16rri GR16:$src1, imm:$src2)>;
Dan Gohman2ec42142009-03-04 03:54:19 +00003666def : Pat<(parallel (X86smul_ovf GR32:$src1, imm:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003667 (implicit EFLAGS)),
3668 (IMUL32rri GR32:$src1, imm:$src2)>;
Dan Gohman2ec42142009-03-04 03:54:19 +00003669def : Pat<(parallel (X86smul_ovf GR16:$src1, i16immSExt8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003670 (implicit EFLAGS)),
3671 (IMUL16rri8 GR16:$src1, i16immSExt8:$src2)>;
Dan Gohman2ec42142009-03-04 03:54:19 +00003672def : Pat<(parallel (X86smul_ovf GR32:$src1, i32immSExt8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003673 (implicit EFLAGS)),
3674 (IMUL32rri8 GR32:$src1, i32immSExt8:$src2)>;
3675
Dan Gohman2ec42142009-03-04 03:54:19 +00003676// Memory-Integer Signed Integer Multiply with Overflow
3677def : Pat<(parallel (X86smul_ovf (load addr:$src1), imm:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003678 (implicit EFLAGS)),
3679 (IMUL16rmi addr:$src1, imm:$src2)>;
Dan Gohman2ec42142009-03-04 03:54:19 +00003680def : Pat<(parallel (X86smul_ovf (load addr:$src1), imm:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003681 (implicit EFLAGS)),
3682 (IMUL32rmi addr:$src1, imm:$src2)>;
Dan Gohman2ec42142009-03-04 03:54:19 +00003683def : Pat<(parallel (X86smul_ovf (load addr:$src1), i16immSExt8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003684 (implicit EFLAGS)),
3685 (IMUL16rmi8 addr:$src1, i16immSExt8:$src2)>;
Dan Gohman2ec42142009-03-04 03:54:19 +00003686def : Pat<(parallel (X86smul_ovf (load addr:$src1), i32immSExt8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003687 (implicit EFLAGS)),
3688 (IMUL32rmi8 addr:$src1, i32immSExt8:$src2)>;
3689
Dan Gohman2ec42142009-03-04 03:54:19 +00003690// Optimize multiple with overflow by 2.
Evan Cheng00cf7932009-01-27 03:30:42 +00003691let AddedComplexity = 2 in {
Dan Gohman2ec42142009-03-04 03:54:19 +00003692def : Pat<(parallel (X86smul_ovf GR16:$src1, 2),
Evan Cheng00cf7932009-01-27 03:30:42 +00003693 (implicit EFLAGS)),
3694 (ADD16rr GR16:$src1, GR16:$src1)>;
3695
Dan Gohman2ec42142009-03-04 03:54:19 +00003696def : Pat<(parallel (X86smul_ovf GR32:$src1, 2),
Evan Cheng00cf7932009-01-27 03:30:42 +00003697 (implicit EFLAGS)),
3698 (ADD32rr GR32:$src1, GR32:$src1)>;
3699}
3700
Bill Wendlingf5399032008-12-12 21:15:41 +00003701//===----------------------------------------------------------------------===//
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003702// Floating Point Stack Support
3703//===----------------------------------------------------------------------===//
3704
3705include "X86InstrFPStack.td"
3706
3707//===----------------------------------------------------------------------===//
Evan Cheng86ab7d32007-07-31 08:04:03 +00003708// X86-64 Support
3709//===----------------------------------------------------------------------===//
3710
Chris Lattner2de8d2b2008-01-10 05:50:42 +00003711include "X86Instr64bit.td"
Evan Cheng86ab7d32007-07-31 08:04:03 +00003712
3713//===----------------------------------------------------------------------===//
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003714// XMM Floating point support (requires SSE / SSE2)
3715//===----------------------------------------------------------------------===//
3716
3717include "X86InstrSSE.td"
Evan Cheng5e4d1e72008-04-25 18:19:54 +00003718
3719//===----------------------------------------------------------------------===//
3720// MMX and XMM Packed Integer support (requires MMX, SSE, and SSE2)
3721//===----------------------------------------------------------------------===//
3722
3723include "X86InstrMMX.td"