blob: 343691188b1d61c507b110101f0080dd1240855a [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 Gohman99a12192009-03-04 19:44:21 +000030// Unary and binary operator instructions that set EFLAGS as a side-effect.
31def SDTUnaryArithWithFlags : SDTypeProfile<1, 1,
32 [SDTCisInt<0>]>;
33def SDTBinaryArithWithFlags : SDTypeProfile<1, 2,
34 [SDTCisSameAs<0, 1>,
35 SDTCisSameAs<0, 2>,
36 SDTCisInt<0>]>;
Bill Wendlingae034ed2008-12-12 00:56:36 +000037
Evan Cheng621216e2007-09-29 00:00:36 +000038def SDTX86BrCond : SDTypeProfile<0, 3,
Evan Cheng950aac02007-09-25 01:57:46 +000039 [SDTCisVT<0, OtherVT>,
40 SDTCisVT<1, i8>, SDTCisVT<2, i32>]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +000041
Evan Cheng621216e2007-09-29 00:00:36 +000042def SDTX86SetCC : SDTypeProfile<1, 2,
Evan Cheng950aac02007-09-25 01:57:46 +000043 [SDTCisVT<0, i8>,
44 SDTCisVT<1, i8>, SDTCisVT<2, i32>]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +000045
Andrew Lenharth7dfe23f2008-03-01 21:52:34 +000046def SDTX86cas : SDTypeProfile<0, 3, [SDTCisPtrTy<0>, SDTCisInt<1>,
47 SDTCisVT<2, i8>]>;
Andrew Lenharth81580822008-03-05 01:15:49 +000048def SDTX86cas8 : SDTypeProfile<0, 1, [SDTCisPtrTy<0>]>;
Andrew Lenharth7dfe23f2008-03-01 21:52:34 +000049
Dale Johannesenf160d802008-10-02 18:53:47 +000050def SDTX86atomicBinary : SDTypeProfile<2, 3, [SDTCisInt<0>, SDTCisInt<1>,
51 SDTCisPtrTy<2>, SDTCisInt<3>,SDTCisInt<4>]>;
Chris Lattnerb56cc342008-03-11 03:23:40 +000052def SDTX86Ret : SDTypeProfile<0, -1, [SDTCisVT<0, i16>]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +000053
Bill Wendling7173da52007-11-13 09:19:02 +000054def SDT_X86CallSeqStart : SDCallSeqStart<[ SDTCisVT<0, i32> ]>;
55def SDT_X86CallSeqEnd : SDCallSeqEnd<[ SDTCisVT<0, i32>,
56 SDTCisVT<1, i32> ]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +000057
Dan Gohman3329ffe2008-05-29 19:57:41 +000058def SDT_X86Call : SDTypeProfile<0, -1, [SDTCisVT<0, iPTR>]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +000059
60def SDTX86RepStr : SDTypeProfile<0, 1, [SDTCisVT<0, OtherVT>]>;
61
62def SDTX86RdTsc : SDTypeProfile<0, 0, []>;
63
64def SDTX86Wrapper : SDTypeProfile<1, 1, [SDTCisSameAs<0, 1>, SDTCisPtrTy<0>]>;
65
66def SDT_X86TLSADDR : SDTypeProfile<1, 1, [SDTCisPtrTy<0>, SDTCisInt<1>]>;
67
Rafael Espindolabca99f72009-04-08 21:14:34 +000068def SDT_X86SegmentBaseAddress : SDTypeProfile<1, 1, [SDTCisPtrTy<0>]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +000069
70def SDT_X86EHRET : SDTypeProfile<0, 1, [SDTCisInt<0>]>;
71
Arnold Schwaighofere2d6bbb2007-10-11 19:40:01 +000072def SDT_X86TCRET : SDTypeProfile<0, 2, [SDTCisPtrTy<0>, SDTCisVT<1, i32>]>;
73
Evan Cheng48679f42007-12-14 02:13:44 +000074def X86bsf : SDNode<"X86ISD::BSF", SDTIntUnaryOp>;
75def X86bsr : SDNode<"X86ISD::BSR", SDTIntUnaryOp>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +000076def X86shld : SDNode<"X86ISD::SHLD", SDTIntShiftDOp>;
77def X86shrd : SDNode<"X86ISD::SHRD", SDTIntShiftDOp>;
78
Evan Cheng621216e2007-09-29 00:00:36 +000079def X86cmp : SDNode<"X86ISD::CMP" , SDTX86CmpTest>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +000080
Dan Gohman7fe9b7f2008-12-23 22:45:23 +000081def X86bt : SDNode<"X86ISD::BT", SDTX86CmpTest>;
82
Evan Cheng621216e2007-09-29 00:00:36 +000083def X86cmov : SDNode<"X86ISD::CMOV", SDTX86Cmov>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +000084def X86brcond : SDNode<"X86ISD::BRCOND", SDTX86BrCond,
Evan Cheng950aac02007-09-25 01:57:46 +000085 [SDNPHasChain]>;
Evan Cheng621216e2007-09-29 00:00:36 +000086def X86setcc : SDNode<"X86ISD::SETCC", SDTX86SetCC>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +000087
Andrew Lenharth7dfe23f2008-03-01 21:52:34 +000088def X86cas : SDNode<"X86ISD::LCMPXCHG_DAG", SDTX86cas,
89 [SDNPHasChain, SDNPInFlag, SDNPOutFlag, SDNPMayStore,
90 SDNPMayLoad]>;
Andrew Lenharth81580822008-03-05 01:15:49 +000091def X86cas8 : SDNode<"X86ISD::LCMPXCHG8_DAG", SDTX86cas8,
92 [SDNPHasChain, SDNPInFlag, SDNPOutFlag, SDNPMayStore,
93 SDNPMayLoad]>;
Dale Johannesenf160d802008-10-02 18:53:47 +000094def X86AtomAdd64 : SDNode<"X86ISD::ATOMADD64_DAG", SDTX86atomicBinary,
95 [SDNPHasChain, SDNPMayStore,
96 SDNPMayLoad, SDNPMemOperand]>;
97def X86AtomSub64 : SDNode<"X86ISD::ATOMSUB64_DAG", SDTX86atomicBinary,
98 [SDNPHasChain, SDNPMayStore,
99 SDNPMayLoad, SDNPMemOperand]>;
100def X86AtomOr64 : SDNode<"X86ISD::ATOMOR64_DAG", SDTX86atomicBinary,
101 [SDNPHasChain, SDNPMayStore,
102 SDNPMayLoad, SDNPMemOperand]>;
103def X86AtomXor64 : SDNode<"X86ISD::ATOMXOR64_DAG", SDTX86atomicBinary,
104 [SDNPHasChain, SDNPMayStore,
105 SDNPMayLoad, SDNPMemOperand]>;
106def X86AtomAnd64 : SDNode<"X86ISD::ATOMAND64_DAG", SDTX86atomicBinary,
107 [SDNPHasChain, SDNPMayStore,
108 SDNPMayLoad, SDNPMemOperand]>;
109def X86AtomNand64 : SDNode<"X86ISD::ATOMNAND64_DAG", SDTX86atomicBinary,
110 [SDNPHasChain, SDNPMayStore,
111 SDNPMayLoad, SDNPMemOperand]>;
Dale Johannesen51c58ee2008-10-03 22:25:52 +0000112def X86AtomSwap64 : SDNode<"X86ISD::ATOMSWAP64_DAG", SDTX86atomicBinary,
113 [SDNPHasChain, SDNPMayStore,
114 SDNPMayLoad, SDNPMemOperand]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000115def X86retflag : SDNode<"X86ISD::RET_FLAG", SDTX86Ret,
116 [SDNPHasChain, SDNPOptInFlag]>;
117
118def X86callseq_start :
119 SDNode<"ISD::CALLSEQ_START", SDT_X86CallSeqStart,
120 [SDNPHasChain, SDNPOutFlag]>;
121def X86callseq_end :
122 SDNode<"ISD::CALLSEQ_END", SDT_X86CallSeqEnd,
Arnold Schwaighofere2d6bbb2007-10-11 19:40:01 +0000123 [SDNPHasChain, SDNPOptInFlag, SDNPOutFlag]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000124
125def X86call : SDNode<"X86ISD::CALL", SDT_X86Call,
126 [SDNPHasChain, SDNPOutFlag, SDNPOptInFlag]>;
127
128def X86tailcall: SDNode<"X86ISD::TAILCALL", SDT_X86Call,
129 [SDNPHasChain, SDNPOutFlag, SDNPOptInFlag]>;
130
131def X86rep_stos: SDNode<"X86ISD::REP_STOS", SDTX86RepStr,
Chris Lattnerca4e0fe2008-01-10 05:12:37 +0000132 [SDNPHasChain, SDNPInFlag, SDNPOutFlag, SDNPMayStore]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000133def X86rep_movs: SDNode<"X86ISD::REP_MOVS", SDTX86RepStr,
Chris Lattnerca4e0fe2008-01-10 05:12:37 +0000134 [SDNPHasChain, SDNPInFlag, SDNPOutFlag, SDNPMayStore,
135 SDNPMayLoad]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000136
137def X86rdtsc : SDNode<"X86ISD::RDTSC_DAG",SDTX86RdTsc,
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000138 [SDNPHasChain, SDNPOutFlag, SDNPSideEffect]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000139
140def X86Wrapper : SDNode<"X86ISD::Wrapper", SDTX86Wrapper>;
141def X86WrapperRIP : SDNode<"X86ISD::WrapperRIP", SDTX86Wrapper>;
142
143def X86tlsaddr : SDNode<"X86ISD::TLSADDR", SDT_X86TLSADDR,
Anton Korobeynikov4fbf00b2008-05-04 21:36:32 +0000144 [SDNPHasChain, SDNPOptInFlag, SDNPOutFlag]>;
Rafael Espindolabca99f72009-04-08 21:14:34 +0000145def X86SegmentBaseAddress : SDNode<"X86ISD::SegmentBaseAddress",
146 SDT_X86SegmentBaseAddress, []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000147
148def X86ehret : SDNode<"X86ISD::EH_RETURN", SDT_X86EHRET,
149 [SDNPHasChain]>;
150
Arnold Schwaighofere2d6bbb2007-10-11 19:40:01 +0000151def X86tcret : SDNode<"X86ISD::TC_RETURN", SDT_X86TCRET,
152 [SDNPHasChain, SDNPOptInFlag]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000153
Dan Gohman99a12192009-03-04 19:44:21 +0000154def X86add_flag : SDNode<"X86ISD::ADD", SDTBinaryArithWithFlags>;
155def X86sub_flag : SDNode<"X86ISD::SUB", SDTBinaryArithWithFlags>;
156def X86smul_flag : SDNode<"X86ISD::SMUL", SDTBinaryArithWithFlags>;
157def X86umul_flag : SDNode<"X86ISD::UMUL", SDTUnaryArithWithFlags>;
158def X86inc_flag : SDNode<"X86ISD::INC", SDTUnaryArithWithFlags>;
159def X86dec_flag : SDNode<"X86ISD::DEC", SDTUnaryArithWithFlags>;
Bill Wendlingae034ed2008-12-12 00:56:36 +0000160
Evan Chengc3495762009-03-30 21:36:47 +0000161def X86mul_imm : SDNode<"X86ISD::MUL_IMM", SDTIntBinOp>;
162
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000163//===----------------------------------------------------------------------===//
164// X86 Operand Definitions.
165//
166
167// *mem - Operand definitions for the funky X86 addressing mode operands.
168//
169class X86MemOperand<string printMethod> : Operand<iPTR> {
170 let PrintMethod = printMethod;
Rafael Espindolabca99f72009-04-08 21:14:34 +0000171 let MIOperandInfo = (ops ptr_rc, i8imm, ptr_rc, i32imm, i8imm);
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000172}
173
174def i8mem : X86MemOperand<"printi8mem">;
175def i16mem : X86MemOperand<"printi16mem">;
176def i32mem : X86MemOperand<"printi32mem">;
177def i64mem : X86MemOperand<"printi64mem">;
178def i128mem : X86MemOperand<"printi128mem">;
179def f32mem : X86MemOperand<"printf32mem">;
180def f64mem : X86MemOperand<"printf64mem">;
Dale Johannesen4ab00bd2007-08-05 18:49:15 +0000181def f80mem : X86MemOperand<"printf80mem">;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000182def f128mem : X86MemOperand<"printf128mem">;
183
Dan Gohman744d4622009-04-13 16:09:41 +0000184// A version of i8mem for use on x86-64 that uses GR64_NOREX instead of
185// plain GR64, so that it doesn't potentially require a REX prefix.
186def i8mem_NOREX : Operand<i64> {
187 let PrintMethod = "printi8mem";
188 let MIOperandInfo = (ops GR64_NOREX, i8imm, GR64_NOREX, i32imm, i8imm);
189}
190
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000191def lea32mem : Operand<i32> {
Rafael Espindolabca99f72009-04-08 21:14:34 +0000192 let PrintMethod = "printlea32mem";
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000193 let MIOperandInfo = (ops GR32, i8imm, GR32, i32imm);
194}
195
196def SSECC : Operand<i8> {
197 let PrintMethod = "printSSECC";
198}
199
200def piclabel: Operand<i32> {
201 let PrintMethod = "printPICLabel";
202}
203
204// A couple of more descriptive operand definitions.
205// 16-bits but only 8 bits are significant.
206def i16i8imm : Operand<i16>;
207// 32-bits but only 8 bits are significant.
208def i32i8imm : Operand<i32>;
209
210// Branch targets have OtherVT type.
211def brtarget : Operand<OtherVT>;
212
213//===----------------------------------------------------------------------===//
214// X86 Complex Pattern Definitions.
215//
216
217// Define X86 specific addressing mode.
Rafael Espindolabca99f72009-04-08 21:14:34 +0000218def addr : ComplexPattern<iPTR, 5, "SelectAddr", [], []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000219def lea32addr : ComplexPattern<i32, 4, "SelectLEAAddr",
220 [add, mul, shl, or, frameindex], []>;
221
222//===----------------------------------------------------------------------===//
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000223// X86 Instruction Predicate Definitions.
224def HasMMX : Predicate<"Subtarget->hasMMX()">;
225def HasSSE1 : Predicate<"Subtarget->hasSSE1()">;
226def HasSSE2 : Predicate<"Subtarget->hasSSE2()">;
227def HasSSE3 : Predicate<"Subtarget->hasSSE3()">;
228def HasSSSE3 : Predicate<"Subtarget->hasSSSE3()">;
Nate Begemanb2975562008-02-03 07:18:54 +0000229def HasSSE41 : Predicate<"Subtarget->hasSSE41()">;
230def HasSSE42 : Predicate<"Subtarget->hasSSE42()">;
Dale Johannesene0e0fd02007-09-23 14:52:20 +0000231def FPStackf32 : Predicate<"!Subtarget->hasSSE1()">;
232def FPStackf64 : Predicate<"!Subtarget->hasSSE2()">;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000233def In32BitMode : Predicate<"!Subtarget->is64Bit()">;
234def In64BitMode : Predicate<"Subtarget->is64Bit()">;
235def SmallCode : Predicate<"TM.getCodeModel() == CodeModel::Small">;
236def NotSmallCode : Predicate<"TM.getCodeModel() != CodeModel::Small">;
237def IsStatic : Predicate<"TM.getRelocationModel() == Reloc::Static">;
Evan Cheng13559d62008-09-26 23:41:32 +0000238def OptForSpeed : Predicate<"!OptForSize">;
Evan Cheng95a77fd2009-01-02 05:35:45 +0000239def FastBTMem : Predicate<"!Subtarget->isBTMemSlow()">;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000240
241//===----------------------------------------------------------------------===//
Evan Cheng86ab7d32007-07-31 08:04:03 +0000242// X86 Instruction Format Definitions.
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000243//
244
Evan Cheng86ab7d32007-07-31 08:04:03 +0000245include "X86InstrFormats.td"
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000246
247//===----------------------------------------------------------------------===//
248// Pattern fragments...
249//
250
251// X86 specific condition code. These correspond to CondCode in
252// X86InstrInfo.h. They must be kept in synch.
Dan Gohman0fc9ed62009-01-07 00:15:08 +0000253def X86_COND_A : PatLeaf<(i8 0)>; // alt. COND_NBE
254def X86_COND_AE : PatLeaf<(i8 1)>; // alt. COND_NC
255def X86_COND_B : PatLeaf<(i8 2)>; // alt. COND_C
256def X86_COND_BE : PatLeaf<(i8 3)>; // alt. COND_NA
257def X86_COND_E : PatLeaf<(i8 4)>; // alt. COND_Z
258def X86_COND_G : PatLeaf<(i8 5)>; // alt. COND_NLE
259def X86_COND_GE : PatLeaf<(i8 6)>; // alt. COND_NL
260def X86_COND_L : PatLeaf<(i8 7)>; // alt. COND_NGE
261def X86_COND_LE : PatLeaf<(i8 8)>; // alt. COND_NG
262def X86_COND_NE : PatLeaf<(i8 9)>; // alt. COND_NZ
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000263def X86_COND_NO : PatLeaf<(i8 10)>;
Dan Gohman0fc9ed62009-01-07 00:15:08 +0000264def X86_COND_NP : PatLeaf<(i8 11)>; // alt. COND_PO
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000265def X86_COND_NS : PatLeaf<(i8 12)>;
Dan Gohman0fc9ed62009-01-07 00:15:08 +0000266def X86_COND_O : PatLeaf<(i8 13)>;
267def X86_COND_P : PatLeaf<(i8 14)>; // alt. COND_PE
268def X86_COND_S : PatLeaf<(i8 15)>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000269
270def i16immSExt8 : PatLeaf<(i16 imm), [{
271 // i16immSExt8 predicate - True if the 16-bit immediate fits in a 8-bit
272 // sign extended field.
Dan Gohmanfaeb4a32008-09-12 16:56:44 +0000273 return (int16_t)N->getZExtValue() == (int8_t)N->getZExtValue();
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000274}]>;
275
276def i32immSExt8 : PatLeaf<(i32 imm), [{
277 // i32immSExt8 predicate - True if the 32-bit immediate fits in a 8-bit
278 // sign extended field.
Dan Gohmanfaeb4a32008-09-12 16:56:44 +0000279 return (int32_t)N->getZExtValue() == (int8_t)N->getZExtValue();
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000280}]>;
281
282// Helper fragments for loads.
Evan Chengb3e25ea2008-05-13 18:59:59 +0000283// It's always safe to treat a anyext i16 load as a i32 load if the i16 is
284// known to be 32-bit aligned or better. Ditto for i8 to i16.
Dan Gohman2a174122008-10-15 06:50:19 +0000285def loadi16 : PatFrag<(ops node:$ptr), (i16 (unindexedload node:$ptr)), [{
Dan Gohman8335c412008-08-20 15:24:22 +0000286 LoadSDNode *LD = cast<LoadSDNode>(N);
Chris Lattner12208612009-04-10 00:16:23 +0000287 if (const Value *Src = LD->getSrcValue())
288 if (const PointerType *PT = dyn_cast<PointerType>(Src->getType()))
289 if (PT->getAddressSpace() != 0)
290 return false;
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() >= 2 && !LD->isVolatile();
Evan Cheng8b765e92008-05-13 00:54:02 +0000296 return false;
297}]>;
298
Dan Gohman2a174122008-10-15 06:50:19 +0000299def loadi16_anyext : PatFrag<(ops node:$ptr), (i32 (unindexedload node:$ptr)), [{
Evan Cheng56ec77b2008-09-24 23:27:55 +0000300 LoadSDNode *LD = cast<LoadSDNode>(N);
Chris Lattner12208612009-04-10 00:16:23 +0000301 if (const Value *Src = LD->getSrcValue())
302 if (const PointerType *PT = dyn_cast<PointerType>(Src->getType()))
303 if (PT->getAddressSpace() != 0)
304 return false;
Evan Cheng56ec77b2008-09-24 23:27:55 +0000305 ISD::LoadExtType ExtType = LD->getExtensionType();
306 if (ExtType == ISD::EXTLOAD)
307 return LD->getAlignment() >= 2 && !LD->isVolatile();
308 return false;
309}]>;
310
Dan Gohman2a174122008-10-15 06:50:19 +0000311def loadi32 : PatFrag<(ops node:$ptr), (i32 (unindexedload node:$ptr)), [{
Dan Gohman8335c412008-08-20 15:24:22 +0000312 LoadSDNode *LD = cast<LoadSDNode>(N);
Chris Lattner12208612009-04-10 00:16:23 +0000313 if (const Value *Src = LD->getSrcValue())
314 if (const PointerType *PT = dyn_cast<PointerType>(Src->getType()))
315 if (PT->getAddressSpace() != 0)
316 return false;
Dan Gohman8335c412008-08-20 15:24:22 +0000317 ISD::LoadExtType ExtType = LD->getExtensionType();
318 if (ExtType == ISD::NON_EXTLOAD)
319 return true;
320 if (ExtType == ISD::EXTLOAD)
321 return LD->getAlignment() >= 4 && !LD->isVolatile();
Evan Cheng8b765e92008-05-13 00:54:02 +0000322 return false;
323}]>;
324
Dan Gohman2a174122008-10-15 06:50:19 +0000325def nvloadi32 : PatFrag<(ops node:$ptr), (i32 (unindexedload node:$ptr)), [{
Evan Cheng1e5e5452008-09-29 17:26:18 +0000326 LoadSDNode *LD = cast<LoadSDNode>(N);
Chris Lattner12208612009-04-10 00:16:23 +0000327 if (const Value *Src = LD->getSrcValue())
328 if (const PointerType *PT = dyn_cast<PointerType>(Src->getType()))
329 if (PT->getAddressSpace() != 0)
330 return false;
Evan Cheng1e5e5452008-09-29 17:26:18 +0000331 if (LD->isVolatile())
332 return false;
Evan Cheng1e5e5452008-09-29 17:26:18 +0000333 ISD::LoadExtType ExtType = LD->getExtensionType();
334 if (ExtType == ISD::NON_EXTLOAD)
335 return true;
336 if (ExtType == ISD::EXTLOAD)
337 return LD->getAlignment() >= 4;
338 return false;
339}]>;
340
sampo9cc09a32009-01-26 01:24:32 +0000341def gsload : PatFrag<(ops node:$ptr), (load node:$ptr), [{
Chris Lattner12208612009-04-10 00:16:23 +0000342 if (const Value *Src = cast<LoadSDNode>(N)->getSrcValue())
343 if (const PointerType *PT = dyn_cast<PointerType>(Src->getType()))
344 return PT->getAddressSpace() == 256;
sampo9cc09a32009-01-26 01:24:32 +0000345 return false;
346}]>;
347
Chris Lattner12208612009-04-10 00:16:23 +0000348def loadi8 : PatFrag<(ops node:$ptr), (i8 (load node:$ptr)), [{
349 if (const Value *Src = cast<LoadSDNode>(N)->getSrcValue())
350 if (const PointerType *PT = dyn_cast<PointerType>(Src->getType()))
351 if (PT->getAddressSpace() != 0)
352 return false;
353 return true;
354}]>;
355def loadi64 : PatFrag<(ops node:$ptr), (i64 (load node:$ptr)), [{
356 if (const Value *Src = cast<LoadSDNode>(N)->getSrcValue())
357 if (const PointerType *PT = dyn_cast<PointerType>(Src->getType()))
358 if (PT->getAddressSpace() != 0)
359 return false;
360 return true;
361}]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000362
Chris Lattner12208612009-04-10 00:16:23 +0000363def loadf32 : PatFrag<(ops node:$ptr), (f32 (load node:$ptr)), [{
364 if (const Value *Src = cast<LoadSDNode>(N)->getSrcValue())
365 if (const PointerType *PT = dyn_cast<PointerType>(Src->getType()))
366 if (PT->getAddressSpace() != 0)
367 return false;
368 return true;
369}]>;
370def loadf64 : PatFrag<(ops node:$ptr), (f64 (load node:$ptr)), [{
371 if (const Value *Src = cast<LoadSDNode>(N)->getSrcValue())
372 if (const PointerType *PT = dyn_cast<PointerType>(Src->getType()))
373 if (PT->getAddressSpace() != 0)
374 return false;
375 return true;
376}]>;
377def loadf80 : PatFrag<(ops node:$ptr), (f80 (load node:$ptr)), [{
378 if (const Value *Src = cast<LoadSDNode>(N)->getSrcValue())
379 if (const PointerType *PT = dyn_cast<PointerType>(Src->getType()))
380 if (PT->getAddressSpace() != 0)
381 return false;
382 return true;
383}]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000384
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000385def sextloadi16i8 : PatFrag<(ops node:$ptr), (i16 (sextloadi8 node:$ptr))>;
386def sextloadi32i8 : PatFrag<(ops node:$ptr), (i32 (sextloadi8 node:$ptr))>;
387def sextloadi32i16 : PatFrag<(ops node:$ptr), (i32 (sextloadi16 node:$ptr))>;
388
389def zextloadi8i1 : PatFrag<(ops node:$ptr), (i8 (zextloadi1 node:$ptr))>;
390def zextloadi16i1 : PatFrag<(ops node:$ptr), (i16 (zextloadi1 node:$ptr))>;
391def zextloadi32i1 : PatFrag<(ops node:$ptr), (i32 (zextloadi1 node:$ptr))>;
392def zextloadi16i8 : PatFrag<(ops node:$ptr), (i16 (zextloadi8 node:$ptr))>;
393def zextloadi32i8 : PatFrag<(ops node:$ptr), (i32 (zextloadi8 node:$ptr))>;
394def zextloadi32i16 : PatFrag<(ops node:$ptr), (i32 (zextloadi16 node:$ptr))>;
395
396def extloadi8i1 : PatFrag<(ops node:$ptr), (i8 (extloadi1 node:$ptr))>;
397def extloadi16i1 : PatFrag<(ops node:$ptr), (i16 (extloadi1 node:$ptr))>;
398def extloadi32i1 : PatFrag<(ops node:$ptr), (i32 (extloadi1 node:$ptr))>;
399def extloadi16i8 : PatFrag<(ops node:$ptr), (i16 (extloadi8 node:$ptr))>;
400def extloadi32i8 : PatFrag<(ops node:$ptr), (i32 (extloadi8 node:$ptr))>;
401def extloadi32i16 : PatFrag<(ops node:$ptr), (i32 (extloadi16 node:$ptr))>;
402
Chris Lattner21da6382008-02-19 17:37:35 +0000403
404// An 'and' node with a single use.
405def and_su : PatFrag<(ops node:$lhs, node:$rhs), (and node:$lhs, node:$rhs), [{
Evan Cheng9123cfa2008-03-04 00:40:35 +0000406 return N->hasOneUse();
Chris Lattner21da6382008-02-19 17:37:35 +0000407}]>;
Dan Gohman744d4622009-04-13 16:09:41 +0000408// An 'srl' node with a single use.
409def srl_su : PatFrag<(ops node:$lhs, node:$rhs), (srl node:$lhs, node:$rhs), [{
410 return N->hasOneUse();
411}]>;
412// An 'trunc' node with a single use.
413def trunc_su : PatFrag<(ops node:$src), (trunc node:$src), [{
414 return N->hasOneUse();
415}]>;
Chris Lattner21da6382008-02-19 17:37:35 +0000416
Dan Gohman921581d2008-10-17 01:23:35 +0000417// 'shld' and 'shrd' instruction patterns. Note that even though these have
418// the srl and shl in their patterns, the C++ code must still check for them,
419// because predicates are tested before children nodes are explored.
420
421def shrd : PatFrag<(ops node:$src1, node:$amt1, node:$src2, node:$amt2),
422 (or (srl node:$src1, node:$amt1),
423 (shl node:$src2, node:$amt2)), [{
424 assert(N->getOpcode() == ISD::OR);
425 return N->getOperand(0).getOpcode() == ISD::SRL &&
426 N->getOperand(1).getOpcode() == ISD::SHL &&
427 isa<ConstantSDNode>(N->getOperand(0).getOperand(1)) &&
428 isa<ConstantSDNode>(N->getOperand(1).getOperand(1)) &&
429 N->getOperand(0).getConstantOperandVal(1) ==
430 N->getValueSizeInBits(0) - N->getOperand(1).getConstantOperandVal(1);
431}]>;
432
433def shld : PatFrag<(ops node:$src1, node:$amt1, node:$src2, node:$amt2),
434 (or (shl node:$src1, node:$amt1),
435 (srl node:$src2, node:$amt2)), [{
436 assert(N->getOpcode() == ISD::OR);
437 return N->getOperand(0).getOpcode() == ISD::SHL &&
438 N->getOperand(1).getOpcode() == ISD::SRL &&
439 isa<ConstantSDNode>(N->getOperand(0).getOperand(1)) &&
440 isa<ConstantSDNode>(N->getOperand(1).getOperand(1)) &&
441 N->getOperand(0).getConstantOperandVal(1) ==
442 N->getValueSizeInBits(0) - N->getOperand(1).getConstantOperandVal(1);
443}]>;
444
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000445//===----------------------------------------------------------------------===//
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000446// Instruction list...
447//
448
449// ADJCALLSTACKDOWN/UP implicitly use/def ESP because they may be expanded into
450// a stack adjustment and the codegen must know that they may modify the stack
451// pointer before prolog-epilog rewriting occurs.
Chris Lattnerb56cc342008-03-11 03:23:40 +0000452// Pessimistically assume ADJCALLSTACKDOWN / ADJCALLSTACKUP will become
453// sub / add which can clobber EFLAGS.
Evan Cheng037364a2007-09-28 01:19:48 +0000454let Defs = [ESP, EFLAGS], Uses = [ESP] in {
Dan Gohman01c9f772008-10-01 18:28:06 +0000455def ADJCALLSTACKDOWN32 : I<0, Pseudo, (outs), (ins i32imm:$amt),
456 "#ADJCALLSTACKDOWN",
Chris Lattnerfe5d4022008-10-11 22:08:30 +0000457 [(X86callseq_start timm:$amt)]>,
Dan Gohman01c9f772008-10-01 18:28:06 +0000458 Requires<[In32BitMode]>;
459def ADJCALLSTACKUP32 : I<0, Pseudo, (outs), (ins i32imm:$amt1, i32imm:$amt2),
460 "#ADJCALLSTACKUP",
Chris Lattnerfe5d4022008-10-11 22:08:30 +0000461 [(X86callseq_end timm:$amt1, timm:$amt2)]>,
Dan Gohman01c9f772008-10-01 18:28:06 +0000462 Requires<[In32BitMode]>;
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000463}
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000464
465// Nop
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000466let neverHasSideEffects = 1 in
467 def NOOP : I<0x90, RawFrm, (outs), (ins), "nop", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000468
Evan Cheng0729ccf2008-01-05 00:41:47 +0000469// PIC base
Dan Gohman9499cfe2008-10-01 04:14:30 +0000470let neverHasSideEffects = 1, isNotDuplicable = 1, Uses = [ESP] in
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000471 def MOVPC32r : Ii32<0xE8, Pseudo, (outs GR32:$reg), (ins piclabel:$label),
472 "call\t$label\n\tpop{l}\t$reg", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000473
474//===----------------------------------------------------------------------===//
475// Control Flow Instructions...
476//
477
478// Return instructions.
479let isTerminator = 1, isReturn = 1, isBarrier = 1,
Chris Lattnerb56cc342008-03-11 03:23:40 +0000480 hasCtrlDep = 1, FPForm = SpecialFP, FPFormBits = SpecialFP.Value in {
Dan Gohman2c4be2a2008-05-31 02:11:25 +0000481 def RET : I <0xC3, RawFrm, (outs), (ins variable_ops),
Chris Lattnerb56cc342008-03-11 03:23:40 +0000482 "ret",
Dan Gohman2c4be2a2008-05-31 02:11:25 +0000483 [(X86retflag 0)]>;
Chris Lattnerb56cc342008-03-11 03:23:40 +0000484 def RETI : Ii16<0xC2, RawFrm, (outs), (ins i16imm:$amt, variable_ops),
485 "ret\t$amt",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000486 [(X86retflag imm:$amt)]>;
487}
488
489// All branches are RawFrm, Void, Branch, and Terminators
Evan Cheng37e7c752007-07-21 00:34:19 +0000490let isBranch = 1, isTerminator = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +0000491 class IBr<bits<8> opcode, dag ins, string asm, list<dag> pattern> :
492 I<opcode, RawFrm, (outs), ins, asm, pattern>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000493
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000494let isBranch = 1, isBarrier = 1 in
Dan Gohman91888f02007-07-31 20:11:57 +0000495 def JMP : IBr<0xE9, (ins brtarget:$dst), "jmp\t$dst", [(br bb:$dst)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000496
Owen Andersonf8053082007-11-12 07:39:39 +0000497// Indirect branches
498let isBranch = 1, isTerminator = 1, isBarrier = 1, isIndirectBranch = 1 in {
Dan Gohman91888f02007-07-31 20:11:57 +0000499 def JMP32r : I<0xFF, MRM4r, (outs), (ins GR32:$dst), "jmp{l}\t{*}$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000500 [(brind GR32:$dst)]>;
Dan Gohman91888f02007-07-31 20:11:57 +0000501 def JMP32m : I<0xFF, MRM4m, (outs), (ins i32mem:$dst), "jmp{l}\t{*}$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000502 [(brind (loadi32 addr:$dst))]>;
503}
504
505// Conditional branches
Evan Cheng950aac02007-09-25 01:57:46 +0000506let Uses = [EFLAGS] in {
Dan Gohman91888f02007-07-31 20:11:57 +0000507def JE : IBr<0x84, (ins brtarget:$dst), "je\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000508 [(X86brcond bb:$dst, X86_COND_E, EFLAGS)]>, TB;
Dan Gohman91888f02007-07-31 20:11:57 +0000509def JNE : IBr<0x85, (ins brtarget:$dst), "jne\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000510 [(X86brcond bb:$dst, X86_COND_NE, EFLAGS)]>, TB;
Dan Gohman91888f02007-07-31 20:11:57 +0000511def JL : IBr<0x8C, (ins brtarget:$dst), "jl\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000512 [(X86brcond bb:$dst, X86_COND_L, EFLAGS)]>, TB;
Dan Gohman91888f02007-07-31 20:11:57 +0000513def JLE : IBr<0x8E, (ins brtarget:$dst), "jle\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000514 [(X86brcond bb:$dst, X86_COND_LE, EFLAGS)]>, TB;
Dan Gohman91888f02007-07-31 20:11:57 +0000515def JG : IBr<0x8F, (ins brtarget:$dst), "jg\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000516 [(X86brcond bb:$dst, X86_COND_G, EFLAGS)]>, TB;
Dan Gohman91888f02007-07-31 20:11:57 +0000517def JGE : IBr<0x8D, (ins brtarget:$dst), "jge\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000518 [(X86brcond bb:$dst, X86_COND_GE, EFLAGS)]>, TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000519
Dan Gohman91888f02007-07-31 20:11:57 +0000520def JB : IBr<0x82, (ins brtarget:$dst), "jb\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000521 [(X86brcond bb:$dst, X86_COND_B, EFLAGS)]>, TB;
Dan Gohman91888f02007-07-31 20:11:57 +0000522def JBE : IBr<0x86, (ins brtarget:$dst), "jbe\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000523 [(X86brcond bb:$dst, X86_COND_BE, EFLAGS)]>, TB;
Dan Gohman91888f02007-07-31 20:11:57 +0000524def JA : IBr<0x87, (ins brtarget:$dst), "ja\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000525 [(X86brcond bb:$dst, X86_COND_A, EFLAGS)]>, TB;
Dan Gohman91888f02007-07-31 20:11:57 +0000526def JAE : IBr<0x83, (ins brtarget:$dst), "jae\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000527 [(X86brcond bb:$dst, X86_COND_AE, EFLAGS)]>, TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000528
Dan Gohman91888f02007-07-31 20:11:57 +0000529def JS : IBr<0x88, (ins brtarget:$dst), "js\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000530 [(X86brcond bb:$dst, X86_COND_S, EFLAGS)]>, TB;
Dan Gohman91888f02007-07-31 20:11:57 +0000531def JNS : IBr<0x89, (ins brtarget:$dst), "jns\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000532 [(X86brcond bb:$dst, X86_COND_NS, EFLAGS)]>, TB;
Dan Gohman91888f02007-07-31 20:11:57 +0000533def JP : IBr<0x8A, (ins brtarget:$dst), "jp\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000534 [(X86brcond bb:$dst, X86_COND_P, EFLAGS)]>, TB;
Dan Gohman91888f02007-07-31 20:11:57 +0000535def JNP : IBr<0x8B, (ins brtarget:$dst), "jnp\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000536 [(X86brcond bb:$dst, X86_COND_NP, EFLAGS)]>, TB;
Dan Gohman91888f02007-07-31 20:11:57 +0000537def JO : IBr<0x80, (ins brtarget:$dst), "jo\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000538 [(X86brcond bb:$dst, X86_COND_O, EFLAGS)]>, TB;
Dan Gohman91888f02007-07-31 20:11:57 +0000539def JNO : IBr<0x81, (ins brtarget:$dst), "jno\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000540 [(X86brcond bb:$dst, X86_COND_NO, EFLAGS)]>, TB;
Evan Cheng950aac02007-09-25 01:57:46 +0000541} // Uses = [EFLAGS]
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000542
543//===----------------------------------------------------------------------===//
544// Call Instructions...
545//
Evan Cheng37e7c752007-07-21 00:34:19 +0000546let isCall = 1 in
Dan Gohman01c9f772008-10-01 18:28:06 +0000547 // All calls clobber the non-callee saved registers. ESP is marked as
548 // a use to prevent stack-pointer assignments that appear immediately
549 // before calls from potentially appearing dead. Uses for argument
550 // registers are added manually.
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000551 let Defs = [EAX, ECX, EDX, FP0, FP1, FP2, FP3, FP4, FP5, FP6, ST0,
552 MM0, MM1, MM2, MM3, MM4, MM5, MM6, MM7,
Evan Cheng2293b252008-10-17 21:02:22 +0000553 XMM0, XMM1, XMM2, XMM3, XMM4, XMM5, XMM6, XMM7,
554 XMM8, XMM9, XMM10, XMM11, XMM12, XMM13, XMM14, XMM15, EFLAGS],
Dan Gohman9499cfe2008-10-01 04:14:30 +0000555 Uses = [ESP] in {
Evan Cheng34f93712007-12-22 02:26:46 +0000556 def CALLpcrel32 : Ii32<0xE8, RawFrm, (outs), (ins i32imm:$dst,variable_ops),
Evan Cheng0af5a042009-03-12 18:15:39 +0000557 "call\t${dst:call}", [(X86call imm:$dst)]>,
558 Requires<[In32BitMode]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000559 def CALL32r : I<0xFF, MRM2r, (outs), (ins GR32:$dst, variable_ops),
Dan Gohman91888f02007-07-31 20:11:57 +0000560 "call\t{*}$dst", [(X86call GR32:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000561 def CALL32m : I<0xFF, MRM2m, (outs), (ins i32mem:$dst, variable_ops),
Dan Gohmanea4faba2008-05-29 21:50:34 +0000562 "call\t{*}$dst", [(X86call (loadi32 addr:$dst))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000563 }
564
565// Tail call stuff.
Arnold Schwaighofere2d6bbb2007-10-11 19:40:01 +0000566
Chris Lattnerb56cc342008-03-11 03:23:40 +0000567def TAILCALL : I<0, Pseudo, (outs), (ins),
Arnold Schwaighofere2d6bbb2007-10-11 19:40:01 +0000568 "#TAILCALL",
569 []>;
570
Evan Cheng37e7c752007-07-21 00:34:19 +0000571let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1 in
Arnold Schwaighofer6fd37ac2008-03-19 16:39:45 +0000572def TCRETURNdi : I<0, Pseudo, (outs), (ins i32imm:$dst, i32imm:$offset, variable_ops),
Arnold Schwaighofere2d6bbb2007-10-11 19:40:01 +0000573 "#TC_RETURN $dst $offset",
574 []>;
575
576let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1 in
Arnold Schwaighofer6fd37ac2008-03-19 16:39:45 +0000577def TCRETURNri : I<0, Pseudo, (outs), (ins GR32:$dst, i32imm:$offset, variable_ops),
Arnold Schwaighofere2d6bbb2007-10-11 19:40:01 +0000578 "#TC_RETURN $dst $offset",
579 []>;
580
581let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1 in
Arnold Schwaighofera0032722008-04-30 09:16:33 +0000582
Arnold Schwaighofere2d6bbb2007-10-11 19:40:01 +0000583 def TAILJMPd : IBr<0xE9, (ins i32imm:$dst), "jmp\t${dst:call} # TAILCALL",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000584 []>;
Evan Cheng37e7c752007-07-21 00:34:19 +0000585let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1 in
Arnold Schwaighofere2d6bbb2007-10-11 19:40:01 +0000586 def TAILJMPr : I<0xFF, MRM4r, (outs), (ins GR32:$dst), "jmp{l}\t{*}$dst # TAILCALL",
587 []>;
Evan Cheng37e7c752007-07-21 00:34:19 +0000588let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +0000589 def TAILJMPm : I<0xFF, MRM4m, (outs), (ins i32mem:$dst),
Arnold Schwaighofere2d6bbb2007-10-11 19:40:01 +0000590 "jmp\t{*}$dst # TAILCALL", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000591
592//===----------------------------------------------------------------------===//
593// Miscellaneous Instructions...
594//
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000595let Defs = [EBP, ESP], Uses = [EBP, ESP], mayLoad = 1, neverHasSideEffects=1 in
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000596def LEAVE : I<0xC9, RawFrm,
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000597 (outs), (ins), "leave", []>;
598
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000599let Defs = [ESP], Uses = [ESP], neverHasSideEffects=1 in {
600let mayLoad = 1 in
Evan Chengd8434332007-09-26 01:29:06 +0000601def POP32r : I<0x58, AddRegFrm, (outs GR32:$reg), (ins), "pop{l}\t$reg", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000602
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000603let mayStore = 1 in
Evan Chengd8434332007-09-26 01:29:06 +0000604def PUSH32r : I<0x50, AddRegFrm, (outs), (ins GR32:$reg), "push{l}\t$reg",[]>;
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000605}
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000606
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000607let Defs = [ESP, EFLAGS], Uses = [ESP], mayLoad = 1, neverHasSideEffects=1 in
Evan Chengf1341312007-09-26 21:28:00 +0000608def POPFD : I<0x9D, RawFrm, (outs), (ins), "popf", []>;
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000609let Defs = [ESP], Uses = [ESP, EFLAGS], mayStore = 1, neverHasSideEffects=1 in
Evan Chengf1341312007-09-26 21:28:00 +0000610def PUSHFD : I<0x9C, RawFrm, (outs), (ins), "pushf", []>;
Evan Chengd8434332007-09-26 01:29:06 +0000611
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000612let isTwoAddress = 1 in // GR32 = bswap GR32
613 def BSWAP32r : I<0xC8, AddRegFrm,
Evan Chengb783fa32007-07-19 01:14:50 +0000614 (outs GR32:$dst), (ins GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000615 "bswap{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000616 [(set GR32:$dst, (bswap GR32:$src))]>, TB;
617
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000618
Evan Cheng48679f42007-12-14 02:13:44 +0000619// Bit scan instructions.
620let Defs = [EFLAGS] in {
Evan Cheng4e33de92007-12-14 18:49:43 +0000621def BSF16rr : I<0xBC, MRMSrcReg, (outs GR16:$dst), (ins GR16:$src),
Dan Gohmancdb54c62007-12-14 15:10:00 +0000622 "bsf{w}\t{$src, $dst|$dst, $src}",
Evan Cheng7cfbfe32007-12-14 08:30:15 +0000623 [(set GR16:$dst, (X86bsf GR16:$src)), (implicit EFLAGS)]>, TB;
Evan Cheng48679f42007-12-14 02:13:44 +0000624def BSF16rm : I<0xBC, MRMSrcMem, (outs GR16:$dst), (ins i16mem:$src),
Dan Gohmancdb54c62007-12-14 15:10:00 +0000625 "bsf{w}\t{$src, $dst|$dst, $src}",
Evan Cheng7cfbfe32007-12-14 08:30:15 +0000626 [(set GR16:$dst, (X86bsf (loadi16 addr:$src))),
627 (implicit EFLAGS)]>, TB;
Evan Cheng4e33de92007-12-14 18:49:43 +0000628def BSF32rr : I<0xBC, MRMSrcReg, (outs GR32:$dst), (ins GR32:$src),
Dan Gohmancdb54c62007-12-14 15:10:00 +0000629 "bsf{l}\t{$src, $dst|$dst, $src}",
Evan Cheng7cfbfe32007-12-14 08:30:15 +0000630 [(set GR32:$dst, (X86bsf GR32:$src)), (implicit EFLAGS)]>, TB;
Evan Cheng48679f42007-12-14 02:13:44 +0000631def BSF32rm : I<0xBC, MRMSrcMem, (outs GR32:$dst), (ins i32mem:$src),
Dan Gohmancdb54c62007-12-14 15:10:00 +0000632 "bsf{l}\t{$src, $dst|$dst, $src}",
Evan Cheng7cfbfe32007-12-14 08:30:15 +0000633 [(set GR32:$dst, (X86bsf (loadi32 addr:$src))),
634 (implicit EFLAGS)]>, TB;
Evan Cheng48679f42007-12-14 02:13:44 +0000635
Evan Cheng4e33de92007-12-14 18:49:43 +0000636def BSR16rr : I<0xBD, MRMSrcReg, (outs GR16:$dst), (ins GR16:$src),
Dan Gohmancdb54c62007-12-14 15:10:00 +0000637 "bsr{w}\t{$src, $dst|$dst, $src}",
Evan Cheng7cfbfe32007-12-14 08:30:15 +0000638 [(set GR16:$dst, (X86bsr GR16:$src)), (implicit EFLAGS)]>, TB;
Evan Cheng48679f42007-12-14 02:13:44 +0000639def BSR16rm : I<0xBD, MRMSrcMem, (outs GR16:$dst), (ins i16mem:$src),
Dan Gohmancdb54c62007-12-14 15:10:00 +0000640 "bsr{w}\t{$src, $dst|$dst, $src}",
Evan Cheng7cfbfe32007-12-14 08:30:15 +0000641 [(set GR16:$dst, (X86bsr (loadi16 addr:$src))),
642 (implicit EFLAGS)]>, TB;
Evan Cheng4e33de92007-12-14 18:49:43 +0000643def BSR32rr : I<0xBD, MRMSrcReg, (outs GR32:$dst), (ins GR32:$src),
Dan Gohmancdb54c62007-12-14 15:10:00 +0000644 "bsr{l}\t{$src, $dst|$dst, $src}",
Evan Cheng7cfbfe32007-12-14 08:30:15 +0000645 [(set GR32:$dst, (X86bsr GR32:$src)), (implicit EFLAGS)]>, TB;
Evan Cheng48679f42007-12-14 02:13:44 +0000646def BSR32rm : I<0xBD, MRMSrcMem, (outs GR32:$dst), (ins i32mem:$src),
Dan Gohmancdb54c62007-12-14 15:10:00 +0000647 "bsr{l}\t{$src, $dst|$dst, $src}",
Evan Cheng7cfbfe32007-12-14 08:30:15 +0000648 [(set GR32:$dst, (X86bsr (loadi32 addr:$src))),
649 (implicit EFLAGS)]>, TB;
Evan Cheng48679f42007-12-14 02:13:44 +0000650} // Defs = [EFLAGS]
651
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000652let neverHasSideEffects = 1 in
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000653def LEA16r : I<0x8D, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +0000654 (outs GR16:$dst), (ins i32mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000655 "lea{w}\t{$src|$dst}, {$dst|$src}", []>, OpSize;
Evan Cheng1ea8e6b2008-03-27 01:41:09 +0000656let isReMaterializable = 1 in
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000657def LEA32r : I<0x8D, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +0000658 (outs GR32:$dst), (ins lea32mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000659 "lea{l}\t{$src|$dst}, {$dst|$src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000660 [(set GR32:$dst, lea32addr:$src)]>, Requires<[In32BitMode]>;
661
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000662let Defs = [ECX,EDI,ESI], Uses = [ECX,EDI,ESI] in {
Evan Chengb783fa32007-07-19 01:14:50 +0000663def REP_MOVSB : I<0xA4, RawFrm, (outs), (ins), "{rep;movsb|rep movsb}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000664 [(X86rep_movs i8)]>, REP;
Evan Chengb783fa32007-07-19 01:14:50 +0000665def REP_MOVSW : I<0xA5, RawFrm, (outs), (ins), "{rep;movsw|rep movsw}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000666 [(X86rep_movs i16)]>, REP, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +0000667def REP_MOVSD : I<0xA5, RawFrm, (outs), (ins), "{rep;movsl|rep movsd}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000668 [(X86rep_movs i32)]>, REP;
669}
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000670
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000671let Defs = [ECX,EDI], Uses = [AL,ECX,EDI] in
Evan Chengb783fa32007-07-19 01:14:50 +0000672def REP_STOSB : I<0xAA, RawFrm, (outs), (ins), "{rep;stosb|rep stosb}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000673 [(X86rep_stos i8)]>, REP;
674let Defs = [ECX,EDI], Uses = [AX,ECX,EDI] in
Evan Chengb783fa32007-07-19 01:14:50 +0000675def REP_STOSW : I<0xAB, RawFrm, (outs), (ins), "{rep;stosw|rep stosw}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000676 [(X86rep_stos i16)]>, REP, OpSize;
677let Defs = [ECX,EDI], Uses = [EAX,ECX,EDI] in
Evan Chengb783fa32007-07-19 01:14:50 +0000678def REP_STOSD : I<0xAB, RawFrm, (outs), (ins), "{rep;stosl|rep stosd}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000679 [(X86rep_stos i32)]>, REP;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000680
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000681let Defs = [RAX, RDX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000682def RDTSC : I<0x31, RawFrm, (outs), (ins), "rdtsc", [(X86rdtsc)]>,
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000683 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000684
Anton Korobeynikov39d40ba2008-01-15 07:02:33 +0000685let isBarrier = 1, hasCtrlDep = 1 in {
Chris Lattner56b941f2008-01-15 21:58:22 +0000686def TRAP : I<0x0B, RawFrm, (outs), (ins), "ud2", [(trap)]>, TB;
Anton Korobeynikov39d40ba2008-01-15 07:02:33 +0000687}
688
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000689//===----------------------------------------------------------------------===//
690// Input/Output Instructions...
691//
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000692let Defs = [AL], Uses = [DX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000693def IN8rr : I<0xEC, RawFrm, (outs), (ins),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000694 "in{b}\t{%dx, %al|%AL, %DX}", []>;
695let Defs = [AX], Uses = [DX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000696def IN16rr : I<0xED, RawFrm, (outs), (ins),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000697 "in{w}\t{%dx, %ax|%AX, %DX}", []>, OpSize;
698let Defs = [EAX], Uses = [DX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000699def IN32rr : I<0xED, RawFrm, (outs), (ins),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000700 "in{l}\t{%dx, %eax|%EAX, %DX}", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000701
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000702let Defs = [AL] in
Evan Chengb783fa32007-07-19 01:14:50 +0000703def IN8ri : Ii8<0xE4, RawFrm, (outs), (ins i16i8imm:$port),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000704 "in{b}\t{$port, %al|%AL, $port}", []>;
705let Defs = [AX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000706def IN16ri : Ii8<0xE5, RawFrm, (outs), (ins i16i8imm:$port),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000707 "in{w}\t{$port, %ax|%AX, $port}", []>, OpSize;
708let Defs = [EAX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000709def IN32ri : Ii8<0xE5, RawFrm, (outs), (ins i16i8imm:$port),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000710 "in{l}\t{$port, %eax|%EAX, $port}", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000711
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000712let Uses = [DX, AL] in
Evan Chengb783fa32007-07-19 01:14:50 +0000713def OUT8rr : I<0xEE, RawFrm, (outs), (ins),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000714 "out{b}\t{%al, %dx|%DX, %AL}", []>;
715let Uses = [DX, AX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000716def OUT16rr : I<0xEF, RawFrm, (outs), (ins),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000717 "out{w}\t{%ax, %dx|%DX, %AX}", []>, OpSize;
718let Uses = [DX, EAX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000719def OUT32rr : I<0xEF, RawFrm, (outs), (ins),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000720 "out{l}\t{%eax, %dx|%DX, %EAX}", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000721
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000722let Uses = [AL] in
Evan Chengb783fa32007-07-19 01:14:50 +0000723def OUT8ir : Ii8<0xE6, RawFrm, (outs), (ins i16i8imm:$port),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000724 "out{b}\t{%al, $port|$port, %AL}", []>;
725let Uses = [AX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000726def OUT16ir : Ii8<0xE7, RawFrm, (outs), (ins i16i8imm:$port),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000727 "out{w}\t{%ax, $port|$port, %AX}", []>, OpSize;
728let Uses = [EAX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000729def OUT32ir : Ii8<0xE7, RawFrm, (outs), (ins i16i8imm:$port),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000730 "out{l}\t{%eax, $port|$port, %EAX}", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000731
732//===----------------------------------------------------------------------===//
733// Move Instructions...
734//
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000735let neverHasSideEffects = 1 in {
Evan Chengb783fa32007-07-19 01:14:50 +0000736def MOV8rr : I<0x88, MRMDestReg, (outs GR8 :$dst), (ins GR8 :$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000737 "mov{b}\t{$src, $dst|$dst, $src}", []>;
Evan Chengb783fa32007-07-19 01:14:50 +0000738def MOV16rr : I<0x89, MRMDestReg, (outs GR16:$dst), (ins GR16:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000739 "mov{w}\t{$src, $dst|$dst, $src}", []>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +0000740def MOV32rr : I<0x89, MRMDestReg, (outs GR32:$dst), (ins GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000741 "mov{l}\t{$src, $dst|$dst, $src}", []>;
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000742}
Evan Cheng6f26e8b2008-06-18 08:13:07 +0000743let isReMaterializable = 1, isAsCheapAsAMove = 1 in {
Evan Chengb783fa32007-07-19 01:14:50 +0000744def MOV8ri : Ii8 <0xB0, AddRegFrm, (outs GR8 :$dst), (ins i8imm :$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000745 "mov{b}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000746 [(set GR8:$dst, imm:$src)]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000747def MOV16ri : Ii16<0xB8, AddRegFrm, (outs GR16:$dst), (ins i16imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000748 "mov{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000749 [(set GR16:$dst, imm:$src)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +0000750def MOV32ri : Ii32<0xB8, AddRegFrm, (outs GR32:$dst), (ins i32imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000751 "mov{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000752 [(set GR32:$dst, imm:$src)]>;
753}
Evan Chengb783fa32007-07-19 01:14:50 +0000754def MOV8mi : Ii8 <0xC6, MRM0m, (outs), (ins i8mem :$dst, i8imm :$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000755 "mov{b}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000756 [(store (i8 imm:$src), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000757def MOV16mi : Ii16<0xC7, MRM0m, (outs), (ins i16mem:$dst, i16imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000758 "mov{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000759 [(store (i16 imm:$src), addr:$dst)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +0000760def MOV32mi : Ii32<0xC7, MRM0m, (outs), (ins i32mem:$dst, i32imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000761 "mov{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000762 [(store (i32 imm:$src), addr:$dst)]>;
763
Dan Gohman5574cc72008-12-03 18:15:48 +0000764let canFoldAsLoad = 1, isReMaterializable = 1, mayHaveSideEffects = 1 in {
Evan Chengb783fa32007-07-19 01:14:50 +0000765def MOV8rm : I<0x8A, MRMSrcMem, (outs GR8 :$dst), (ins i8mem :$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000766 "mov{b}\t{$src, $dst|$dst, $src}",
Chris Lattner12208612009-04-10 00:16:23 +0000767 [(set GR8:$dst, (loadi8 addr:$src))]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000768def MOV16rm : I<0x8B, MRMSrcMem, (outs GR16:$dst), (ins i16mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000769 "mov{w}\t{$src, $dst|$dst, $src}",
Chris Lattner12208612009-04-10 00:16:23 +0000770 [(set GR16:$dst, (loadi16 addr:$src))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +0000771def MOV32rm : I<0x8B, MRMSrcMem, (outs GR32:$dst), (ins i32mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000772 "mov{l}\t{$src, $dst|$dst, $src}",
Chris Lattner12208612009-04-10 00:16:23 +0000773 [(set GR32:$dst, (loadi32 addr:$src))]>;
Evan Cheng4e84e452007-08-30 05:49:43 +0000774}
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000775
Evan Chengb783fa32007-07-19 01:14:50 +0000776def MOV8mr : I<0x88, MRMDestMem, (outs), (ins i8mem :$dst, GR8 :$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000777 "mov{b}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000778 [(store GR8:$src, addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000779def MOV16mr : I<0x89, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000780 "mov{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000781 [(store GR16:$src, addr:$dst)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +0000782def MOV32mr : I<0x89, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000783 "mov{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000784 [(store GR32:$src, addr:$dst)]>;
Dan Gohman744d4622009-04-13 16:09:41 +0000785
Dan Gohman2da0db32009-04-15 00:04:23 +0000786// Versions of MOV8rr and MOV8mr that use i8mem_NOREX and GR8_NOREX so that they
787// can be used for copying and storing h registers, which can't be encoded when
788// a REX prefix is present.
789let neverHasSideEffects = 1 in
Dan Gohman40ddc362009-04-15 19:48:57 +0000790def MOV8rr_NOREX : I<0x88, MRMDestReg,
791 (outs GR8_NOREX:$dst), (ins GR8_NOREX:$src),
Dan Gohman2da0db32009-04-15 00:04:23 +0000792 "mov{b}\t{$src, $dst|$dst, $src} # NOREX", []>;
793def MOV8mr_NOREX : I<0x88, MRMDestMem,
794 (outs), (ins i8mem_NOREX:$dst, GR8_NOREX:$src),
795 "mov{b}\t{$src, $dst|$dst, $src} # NOREX", []>;
Dan Gohman744d4622009-04-13 16:09:41 +0000796
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000797//===----------------------------------------------------------------------===//
798// Fixed-Register Multiplication and Division Instructions...
799//
800
801// Extra precision multiplication
Evan Cheng55687072007-09-14 21:48:26 +0000802let Defs = [AL,AH,EFLAGS], Uses = [AL] in
Dan Gohman91888f02007-07-31 20:11:57 +0000803def MUL8r : I<0xF6, MRM4r, (outs), (ins GR8:$src), "mul{b}\t$src",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000804 // FIXME: Used for 8-bit mul, ignore result upper 8 bits.
805 // This probably ought to be moved to a def : Pat<> if the
806 // syntax can be accepted.
Bill Wendlingf5399032008-12-12 21:15:41 +0000807 [(set AL, (mul AL, GR8:$src)),
808 (implicit EFLAGS)]>; // AL,AH = AL*GR8
809
Chris Lattnerc7e96e72008-01-11 07:18:17 +0000810let Defs = [AX,DX,EFLAGS], Uses = [AX], neverHasSideEffects = 1 in
Bill Wendlingf5399032008-12-12 21:15:41 +0000811def MUL16r : I<0xF7, MRM4r, (outs), (ins GR16:$src),
812 "mul{w}\t$src",
813 []>, OpSize; // AX,DX = AX*GR16
814
Chris Lattnerc7e96e72008-01-11 07:18:17 +0000815let Defs = [EAX,EDX,EFLAGS], Uses = [EAX], neverHasSideEffects = 1 in
Bill Wendlingf5399032008-12-12 21:15:41 +0000816def MUL32r : I<0xF7, MRM4r, (outs), (ins GR32:$src),
817 "mul{l}\t$src",
818 []>; // EAX,EDX = EAX*GR32
819
Evan Cheng55687072007-09-14 21:48:26 +0000820let Defs = [AL,AH,EFLAGS], Uses = [AL] in
Evan Chengb783fa32007-07-19 01:14:50 +0000821def MUL8m : I<0xF6, MRM4m, (outs), (ins i8mem :$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000822 "mul{b}\t$src",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000823 // FIXME: Used for 8-bit mul, ignore result upper 8 bits.
824 // This probably ought to be moved to a def : Pat<> if the
825 // syntax can be accepted.
Bill Wendlingf5399032008-12-12 21:15:41 +0000826 [(set AL, (mul AL, (loadi8 addr:$src))),
827 (implicit EFLAGS)]>; // AL,AH = AL*[mem8]
828
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000829let mayLoad = 1, neverHasSideEffects = 1 in {
Evan Cheng55687072007-09-14 21:48:26 +0000830let Defs = [AX,DX,EFLAGS], Uses = [AX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000831def MUL16m : I<0xF7, MRM4m, (outs), (ins i16mem:$src),
Bill Wendlingf5399032008-12-12 21:15:41 +0000832 "mul{w}\t$src",
833 []>, OpSize; // AX,DX = AX*[mem16]
834
Evan Cheng55687072007-09-14 21:48:26 +0000835let Defs = [EAX,EDX,EFLAGS], Uses = [EAX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000836def MUL32m : I<0xF7, MRM4m, (outs), (ins i32mem:$src),
Bill Wendlingf5399032008-12-12 21:15:41 +0000837 "mul{l}\t$src",
838 []>; // EAX,EDX = EAX*[mem32]
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000839}
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000840
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000841let neverHasSideEffects = 1 in {
Evan Cheng55687072007-09-14 21:48:26 +0000842let Defs = [AL,AH,EFLAGS], Uses = [AL] in
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000843def IMUL8r : I<0xF6, MRM5r, (outs), (ins GR8:$src), "imul{b}\t$src", []>;
844 // AL,AH = AL*GR8
Evan Cheng55687072007-09-14 21:48:26 +0000845let Defs = [AX,DX,EFLAGS], Uses = [AX] in
Dan Gohman91888f02007-07-31 20:11:57 +0000846def IMUL16r : I<0xF7, MRM5r, (outs), (ins GR16:$src), "imul{w}\t$src", []>,
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000847 OpSize; // AX,DX = AX*GR16
Evan Cheng55687072007-09-14 21:48:26 +0000848let Defs = [EAX,EDX,EFLAGS], Uses = [EAX] in
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000849def IMUL32r : I<0xF7, MRM5r, (outs), (ins GR32:$src), "imul{l}\t$src", []>;
850 // EAX,EDX = EAX*GR32
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000851let mayLoad = 1 in {
Evan Cheng55687072007-09-14 21:48:26 +0000852let Defs = [AL,AH,EFLAGS], Uses = [AL] in
Evan Chengb783fa32007-07-19 01:14:50 +0000853def IMUL8m : I<0xF6, MRM5m, (outs), (ins i8mem :$src),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000854 "imul{b}\t$src", []>; // AL,AH = AL*[mem8]
Evan Cheng55687072007-09-14 21:48:26 +0000855let Defs = [AX,DX,EFLAGS], Uses = [AX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000856def IMUL16m : I<0xF7, MRM5m, (outs), (ins i16mem:$src),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000857 "imul{w}\t$src", []>, OpSize; // AX,DX = AX*[mem16]
858let Defs = [EAX,EDX], Uses = [EAX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000859def IMUL32m : I<0xF7, MRM5m, (outs), (ins i32mem:$src),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000860 "imul{l}\t$src", []>; // EAX,EDX = EAX*[mem32]
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000861}
Dan Gohmand44572d2008-11-18 21:29:14 +0000862} // neverHasSideEffects
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000863
864// unsigned division/remainder
Dale Johannesend8fd3562008-10-07 18:54:28 +0000865let Defs = [AL,AH,EFLAGS], Uses = [AX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000866def DIV8r : I<0xF6, MRM6r, (outs), (ins GR8:$src), // AX/r8 = AL,AH
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000867 "div{b}\t$src", []>;
Evan Cheng55687072007-09-14 21:48:26 +0000868let Defs = [AX,DX,EFLAGS], Uses = [AX,DX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000869def DIV16r : I<0xF7, MRM6r, (outs), (ins GR16:$src), // DX:AX/r16 = AX,DX
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000870 "div{w}\t$src", []>, OpSize;
Evan Cheng55687072007-09-14 21:48:26 +0000871let Defs = [EAX,EDX,EFLAGS], Uses = [EAX,EDX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000872def DIV32r : I<0xF7, MRM6r, (outs), (ins GR32:$src), // EDX:EAX/r32 = EAX,EDX
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000873 "div{l}\t$src", []>;
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000874let mayLoad = 1 in {
Dale Johannesend8fd3562008-10-07 18:54:28 +0000875let Defs = [AL,AH,EFLAGS], Uses = [AX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000876def DIV8m : I<0xF6, MRM6m, (outs), (ins i8mem:$src), // AX/[mem8] = AL,AH
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000877 "div{b}\t$src", []>;
Evan Cheng55687072007-09-14 21:48:26 +0000878let Defs = [AX,DX,EFLAGS], Uses = [AX,DX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000879def DIV16m : I<0xF7, MRM6m, (outs), (ins i16mem:$src), // DX:AX/[mem16] = AX,DX
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000880 "div{w}\t$src", []>, OpSize;
Evan Cheng55687072007-09-14 21:48:26 +0000881let Defs = [EAX,EDX,EFLAGS], Uses = [EAX,EDX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000882def DIV32m : I<0xF7, MRM6m, (outs), (ins i32mem:$src), // EDX:EAX/[mem32] = EAX,EDX
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000883 "div{l}\t$src", []>;
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000884}
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000885
886// Signed division/remainder.
Dale Johannesend8fd3562008-10-07 18:54:28 +0000887let Defs = [AL,AH,EFLAGS], Uses = [AX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000888def IDIV8r : I<0xF6, MRM7r, (outs), (ins GR8:$src), // AX/r8 = AL,AH
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000889 "idiv{b}\t$src", []>;
Evan Cheng55687072007-09-14 21:48:26 +0000890let Defs = [AX,DX,EFLAGS], Uses = [AX,DX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000891def IDIV16r: I<0xF7, MRM7r, (outs), (ins GR16:$src), // DX:AX/r16 = AX,DX
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000892 "idiv{w}\t$src", []>, OpSize;
Evan Cheng55687072007-09-14 21:48:26 +0000893let Defs = [EAX,EDX,EFLAGS], Uses = [EAX,EDX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000894def IDIV32r: I<0xF7, MRM7r, (outs), (ins GR32:$src), // EDX:EAX/r32 = EAX,EDX
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000895 "idiv{l}\t$src", []>;
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000896let mayLoad = 1, mayLoad = 1 in {
Dale Johannesend8fd3562008-10-07 18:54:28 +0000897let Defs = [AL,AH,EFLAGS], Uses = [AX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000898def IDIV8m : I<0xF6, MRM7m, (outs), (ins i8mem:$src), // AX/[mem8] = AL,AH
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000899 "idiv{b}\t$src", []>;
Evan Cheng55687072007-09-14 21:48:26 +0000900let Defs = [AX,DX,EFLAGS], Uses = [AX,DX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000901def IDIV16m: I<0xF7, MRM7m, (outs), (ins i16mem:$src), // DX:AX/[mem16] = AX,DX
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000902 "idiv{w}\t$src", []>, OpSize;
Evan Cheng55687072007-09-14 21:48:26 +0000903let Defs = [EAX,EDX,EFLAGS], Uses = [EAX,EDX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000904def IDIV32m: I<0xF7, MRM7m, (outs), (ins i32mem:$src), // EDX:EAX/[mem32] = EAX,EDX
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000905 "idiv{l}\t$src", []>;
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000906}
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000907
908//===----------------------------------------------------------------------===//
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000909// Two address Instructions.
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000910//
911let isTwoAddress = 1 in {
912
913// Conditional moves
Evan Cheng950aac02007-09-25 01:57:46 +0000914let Uses = [EFLAGS] in {
Evan Cheng926658c2007-10-05 23:13:21 +0000915let isCommutable = 1 in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000916def CMOVB16rr : I<0x42, MRMSrcReg, // if <u, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +0000917 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000918 "cmovb\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000919 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000920 X86_COND_B, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000921 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000922def CMOVB32rr : I<0x42, MRMSrcReg, // if <u, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +0000923 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000924 "cmovb\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000925 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000926 X86_COND_B, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000927 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000928def CMOVAE16rr: I<0x43, MRMSrcReg, // if >=u, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +0000929 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000930 "cmovae\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000931 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000932 X86_COND_AE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000933 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000934def CMOVAE32rr: I<0x43, MRMSrcReg, // if >=u, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +0000935 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000936 "cmovae\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000937 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000938 X86_COND_AE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000939 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000940def CMOVE16rr : I<0x44, MRMSrcReg, // if ==, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +0000941 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000942 "cmove\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000943 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000944 X86_COND_E, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000945 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000946def CMOVE32rr : I<0x44, MRMSrcReg, // if ==, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +0000947 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000948 "cmove\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000949 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000950 X86_COND_E, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000951 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000952def CMOVNE16rr: I<0x45, MRMSrcReg, // if !=, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +0000953 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000954 "cmovne\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000955 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000956 X86_COND_NE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000957 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000958def CMOVNE32rr: I<0x45, MRMSrcReg, // if !=, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +0000959 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000960 "cmovne\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000961 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000962 X86_COND_NE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000963 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000964def CMOVBE16rr: I<0x46, MRMSrcReg, // if <=u, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +0000965 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000966 "cmovbe\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000967 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000968 X86_COND_BE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000969 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000970def CMOVBE32rr: I<0x46, MRMSrcReg, // if <=u, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +0000971 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000972 "cmovbe\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000973 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000974 X86_COND_BE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000975 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000976def CMOVA16rr : I<0x47, MRMSrcReg, // if >u, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +0000977 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000978 "cmova\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000979 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000980 X86_COND_A, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000981 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000982def CMOVA32rr : I<0x47, MRMSrcReg, // if >u, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +0000983 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000984 "cmova\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000985 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000986 X86_COND_A, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000987 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000988def CMOVL16rr : I<0x4C, MRMSrcReg, // if <s, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +0000989 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000990 "cmovl\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000991 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000992 X86_COND_L, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000993 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000994def CMOVL32rr : I<0x4C, MRMSrcReg, // if <s, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +0000995 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000996 "cmovl\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000997 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000998 X86_COND_L, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000999 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001000def CMOVGE16rr: I<0x4D, MRMSrcReg, // if >=s, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +00001001 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001002 "cmovge\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001003 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001004 X86_COND_GE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001005 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001006def CMOVGE32rr: I<0x4D, MRMSrcReg, // if >=s, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +00001007 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001008 "cmovge\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001009 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001010 X86_COND_GE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001011 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001012def CMOVLE16rr: I<0x4E, MRMSrcReg, // if <=s, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +00001013 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001014 "cmovle\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001015 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001016 X86_COND_LE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001017 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001018def CMOVLE32rr: I<0x4E, MRMSrcReg, // if <=s, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +00001019 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001020 "cmovle\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001021 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001022 X86_COND_LE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001023 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001024def CMOVG16rr : I<0x4F, MRMSrcReg, // if >s, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +00001025 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001026 "cmovg\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001027 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001028 X86_COND_G, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001029 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001030def CMOVG32rr : I<0x4F, MRMSrcReg, // if >s, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +00001031 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001032 "cmovg\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001033 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001034 X86_COND_G, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001035 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001036def CMOVS16rr : I<0x48, MRMSrcReg, // if signed, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +00001037 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001038 "cmovs\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001039 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001040 X86_COND_S, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001041 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001042def CMOVS32rr : I<0x48, MRMSrcReg, // if signed, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +00001043 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001044 "cmovs\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001045 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001046 X86_COND_S, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001047 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001048def CMOVNS16rr: I<0x49, MRMSrcReg, // if !signed, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +00001049 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001050 "cmovns\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001051 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001052 X86_COND_NS, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001053 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001054def CMOVNS32rr: I<0x49, MRMSrcReg, // if !signed, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +00001055 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001056 "cmovns\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001057 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001058 X86_COND_NS, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001059 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001060def CMOVP16rr : I<0x4A, MRMSrcReg, // if parity, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +00001061 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001062 "cmovp\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001063 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001064 X86_COND_P, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001065 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001066def CMOVP32rr : I<0x4A, MRMSrcReg, // if parity, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +00001067 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001068 "cmovp\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001069 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001070 X86_COND_P, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001071 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001072def CMOVNP16rr : I<0x4B, MRMSrcReg, // if !parity, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +00001073 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001074 "cmovnp\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001075 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001076 X86_COND_NP, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001077 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001078def CMOVNP32rr : I<0x4B, MRMSrcReg, // if !parity, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +00001079 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001080 "cmovnp\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001081 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001082 X86_COND_NP, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001083 TB;
Dan Gohman12fd4d72009-01-07 00:35:10 +00001084def CMOVO16rr : I<0x40, MRMSrcReg, // if overflow, GR16 = GR16
1085 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
1086 "cmovo\t{$src2, $dst|$dst, $src2}",
1087 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
1088 X86_COND_O, EFLAGS))]>,
1089 TB, OpSize;
1090def CMOVO32rr : I<0x40, MRMSrcReg, // if overflow, GR32 = GR32
1091 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
1092 "cmovo\t{$src2, $dst|$dst, $src2}",
1093 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
1094 X86_COND_O, EFLAGS))]>,
Evan Cheng950aac02007-09-25 01:57:46 +00001095 TB;
Dan Gohman12fd4d72009-01-07 00:35:10 +00001096def CMOVNO16rr : I<0x41, MRMSrcReg, // if !overflow, GR16 = GR16
1097 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
1098 "cmovno\t{$src2, $dst|$dst, $src2}",
1099 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
1100 X86_COND_NO, EFLAGS))]>,
1101 TB, OpSize;
1102def CMOVNO32rr : I<0x41, MRMSrcReg, // if !overflow, GR32 = GR32
1103 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
1104 "cmovno\t{$src2, $dst|$dst, $src2}",
1105 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
1106 X86_COND_NO, EFLAGS))]>,
1107 TB;
1108} // isCommutable = 1
Evan Cheng926658c2007-10-05 23:13:21 +00001109
1110def CMOVB16rm : I<0x42, MRMSrcMem, // if <u, GR16 = [mem16]
1111 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1112 "cmovb\t{$src2, $dst|$dst, $src2}",
1113 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1114 X86_COND_B, EFLAGS))]>,
1115 TB, OpSize;
1116def CMOVB32rm : I<0x42, MRMSrcMem, // if <u, GR32 = [mem32]
1117 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1118 "cmovb\t{$src2, $dst|$dst, $src2}",
1119 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1120 X86_COND_B, EFLAGS))]>,
1121 TB;
1122def CMOVAE16rm: I<0x43, MRMSrcMem, // if >=u, GR16 = [mem16]
1123 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1124 "cmovae\t{$src2, $dst|$dst, $src2}",
1125 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1126 X86_COND_AE, EFLAGS))]>,
1127 TB, OpSize;
1128def CMOVAE32rm: I<0x43, MRMSrcMem, // if >=u, GR32 = [mem32]
1129 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1130 "cmovae\t{$src2, $dst|$dst, $src2}",
1131 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1132 X86_COND_AE, EFLAGS))]>,
1133 TB;
1134def CMOVE16rm : I<0x44, MRMSrcMem, // if ==, GR16 = [mem16]
1135 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1136 "cmove\t{$src2, $dst|$dst, $src2}",
1137 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1138 X86_COND_E, EFLAGS))]>,
1139 TB, OpSize;
1140def CMOVE32rm : I<0x44, MRMSrcMem, // if ==, GR32 = [mem32]
1141 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1142 "cmove\t{$src2, $dst|$dst, $src2}",
1143 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1144 X86_COND_E, EFLAGS))]>,
1145 TB;
1146def CMOVNE16rm: I<0x45, MRMSrcMem, // if !=, GR16 = [mem16]
1147 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1148 "cmovne\t{$src2, $dst|$dst, $src2}",
1149 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1150 X86_COND_NE, EFLAGS))]>,
1151 TB, OpSize;
1152def CMOVNE32rm: I<0x45, MRMSrcMem, // if !=, GR32 = [mem32]
1153 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1154 "cmovne\t{$src2, $dst|$dst, $src2}",
1155 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1156 X86_COND_NE, EFLAGS))]>,
1157 TB;
1158def CMOVBE16rm: I<0x46, MRMSrcMem, // if <=u, GR16 = [mem16]
1159 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1160 "cmovbe\t{$src2, $dst|$dst, $src2}",
1161 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1162 X86_COND_BE, EFLAGS))]>,
1163 TB, OpSize;
1164def CMOVBE32rm: I<0x46, MRMSrcMem, // if <=u, GR32 = [mem32]
1165 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1166 "cmovbe\t{$src2, $dst|$dst, $src2}",
1167 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1168 X86_COND_BE, EFLAGS))]>,
1169 TB;
1170def CMOVA16rm : I<0x47, MRMSrcMem, // if >u, GR16 = [mem16]
1171 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1172 "cmova\t{$src2, $dst|$dst, $src2}",
1173 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1174 X86_COND_A, EFLAGS))]>,
1175 TB, OpSize;
1176def CMOVA32rm : I<0x47, MRMSrcMem, // if >u, GR32 = [mem32]
1177 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1178 "cmova\t{$src2, $dst|$dst, $src2}",
1179 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1180 X86_COND_A, EFLAGS))]>,
1181 TB;
1182def CMOVL16rm : I<0x4C, MRMSrcMem, // if <s, GR16 = [mem16]
1183 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1184 "cmovl\t{$src2, $dst|$dst, $src2}",
1185 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1186 X86_COND_L, EFLAGS))]>,
1187 TB, OpSize;
1188def CMOVL32rm : I<0x4C, MRMSrcMem, // if <s, GR32 = [mem32]
1189 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1190 "cmovl\t{$src2, $dst|$dst, $src2}",
1191 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1192 X86_COND_L, EFLAGS))]>,
1193 TB;
1194def CMOVGE16rm: I<0x4D, MRMSrcMem, // if >=s, GR16 = [mem16]
1195 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1196 "cmovge\t{$src2, $dst|$dst, $src2}",
1197 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1198 X86_COND_GE, EFLAGS))]>,
1199 TB, OpSize;
1200def CMOVGE32rm: I<0x4D, MRMSrcMem, // if >=s, GR32 = [mem32]
1201 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1202 "cmovge\t{$src2, $dst|$dst, $src2}",
1203 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1204 X86_COND_GE, EFLAGS))]>,
1205 TB;
1206def CMOVLE16rm: I<0x4E, MRMSrcMem, // if <=s, GR16 = [mem16]
1207 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1208 "cmovle\t{$src2, $dst|$dst, $src2}",
1209 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1210 X86_COND_LE, EFLAGS))]>,
1211 TB, OpSize;
1212def CMOVLE32rm: I<0x4E, MRMSrcMem, // if <=s, GR32 = [mem32]
1213 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1214 "cmovle\t{$src2, $dst|$dst, $src2}",
1215 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1216 X86_COND_LE, EFLAGS))]>,
1217 TB;
1218def CMOVG16rm : I<0x4F, MRMSrcMem, // if >s, GR16 = [mem16]
1219 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1220 "cmovg\t{$src2, $dst|$dst, $src2}",
1221 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1222 X86_COND_G, EFLAGS))]>,
1223 TB, OpSize;
1224def CMOVG32rm : I<0x4F, MRMSrcMem, // if >s, GR32 = [mem32]
1225 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1226 "cmovg\t{$src2, $dst|$dst, $src2}",
1227 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1228 X86_COND_G, EFLAGS))]>,
1229 TB;
1230def CMOVS16rm : I<0x48, MRMSrcMem, // if signed, GR16 = [mem16]
1231 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1232 "cmovs\t{$src2, $dst|$dst, $src2}",
1233 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1234 X86_COND_S, EFLAGS))]>,
1235 TB, OpSize;
1236def CMOVS32rm : I<0x48, MRMSrcMem, // if signed, GR32 = [mem32]
1237 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1238 "cmovs\t{$src2, $dst|$dst, $src2}",
1239 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1240 X86_COND_S, EFLAGS))]>,
1241 TB;
1242def CMOVNS16rm: I<0x49, MRMSrcMem, // if !signed, GR16 = [mem16]
1243 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1244 "cmovns\t{$src2, $dst|$dst, $src2}",
1245 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1246 X86_COND_NS, EFLAGS))]>,
1247 TB, OpSize;
1248def CMOVNS32rm: I<0x49, MRMSrcMem, // if !signed, GR32 = [mem32]
1249 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1250 "cmovns\t{$src2, $dst|$dst, $src2}",
1251 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1252 X86_COND_NS, EFLAGS))]>,
1253 TB;
1254def CMOVP16rm : I<0x4A, MRMSrcMem, // if parity, GR16 = [mem16]
1255 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1256 "cmovp\t{$src2, $dst|$dst, $src2}",
1257 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1258 X86_COND_P, EFLAGS))]>,
1259 TB, OpSize;
1260def CMOVP32rm : I<0x4A, MRMSrcMem, // if parity, GR32 = [mem32]
1261 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1262 "cmovp\t{$src2, $dst|$dst, $src2}",
1263 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1264 X86_COND_P, EFLAGS))]>,
1265 TB;
1266def CMOVNP16rm : I<0x4B, MRMSrcMem, // if !parity, GR16 = [mem16]
1267 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1268 "cmovnp\t{$src2, $dst|$dst, $src2}",
1269 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1270 X86_COND_NP, EFLAGS))]>,
1271 TB, OpSize;
Dan Gohman12fd4d72009-01-07 00:35:10 +00001272def CMOVNP32rm : I<0x4B, MRMSrcMem, // if !parity, GR32 = [mem32]
1273 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1274 "cmovnp\t{$src2, $dst|$dst, $src2}",
1275 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1276 X86_COND_NP, EFLAGS))]>,
1277 TB;
1278def CMOVO16rm : I<0x40, MRMSrcMem, // if overflow, GR16 = [mem16]
1279 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1280 "cmovo\t{$src2, $dst|$dst, $src2}",
1281 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1282 X86_COND_O, EFLAGS))]>,
1283 TB, OpSize;
1284def CMOVO32rm : I<0x40, MRMSrcMem, // if overflow, GR32 = [mem32]
1285 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1286 "cmovo\t{$src2, $dst|$dst, $src2}",
1287 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1288 X86_COND_O, EFLAGS))]>,
1289 TB;
1290def CMOVNO16rm : I<0x41, MRMSrcMem, // if !overflow, GR16 = [mem16]
1291 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1292 "cmovno\t{$src2, $dst|$dst, $src2}",
1293 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1294 X86_COND_NO, EFLAGS))]>,
1295 TB, OpSize;
1296def CMOVNO32rm : I<0x41, MRMSrcMem, // if !overflow, GR32 = [mem32]
1297 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1298 "cmovno\t{$src2, $dst|$dst, $src2}",
1299 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1300 X86_COND_NO, EFLAGS))]>,
1301 TB;
Evan Cheng950aac02007-09-25 01:57:46 +00001302} // Uses = [EFLAGS]
1303
1304
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001305// unary instructions
1306let CodeSize = 2 in {
Evan Cheng55687072007-09-14 21:48:26 +00001307let Defs = [EFLAGS] in {
Dan Gohman91888f02007-07-31 20:11:57 +00001308def NEG8r : I<0xF6, MRM3r, (outs GR8 :$dst), (ins GR8 :$src), "neg{b}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001309 [(set GR8:$dst, (ineg GR8:$src)),
1310 (implicit EFLAGS)]>;
Dan Gohman91888f02007-07-31 20:11:57 +00001311def NEG16r : I<0xF7, MRM3r, (outs GR16:$dst), (ins GR16:$src), "neg{w}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001312 [(set GR16:$dst, (ineg GR16:$src)),
1313 (implicit EFLAGS)]>, OpSize;
Dan Gohman91888f02007-07-31 20:11:57 +00001314def NEG32r : I<0xF7, MRM3r, (outs GR32:$dst), (ins GR32:$src), "neg{l}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001315 [(set GR32:$dst, (ineg GR32:$src)),
1316 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001317let isTwoAddress = 0 in {
Dan Gohman91888f02007-07-31 20:11:57 +00001318 def NEG8m : I<0xF6, MRM3m, (outs), (ins i8mem :$dst), "neg{b}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001319 [(store (ineg (loadi8 addr:$dst)), addr:$dst),
1320 (implicit EFLAGS)]>;
Dan Gohman91888f02007-07-31 20:11:57 +00001321 def NEG16m : I<0xF7, MRM3m, (outs), (ins i16mem:$dst), "neg{w}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001322 [(store (ineg (loadi16 addr:$dst)), addr:$dst),
1323 (implicit EFLAGS)]>, OpSize;
Dan Gohman91888f02007-07-31 20:11:57 +00001324 def NEG32m : I<0xF7, MRM3m, (outs), (ins i32mem:$dst), "neg{l}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001325 [(store (ineg (loadi32 addr:$dst)), addr:$dst),
1326 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001327}
Evan Cheng55687072007-09-14 21:48:26 +00001328} // Defs = [EFLAGS]
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001329
Evan Chengc6cee682009-01-21 02:09:05 +00001330// Match xor -1 to not. Favors these over a move imm + xor to save code size.
1331let AddedComplexity = 15 in {
Dan Gohman91888f02007-07-31 20:11:57 +00001332def NOT8r : I<0xF6, MRM2r, (outs GR8 :$dst), (ins GR8 :$src), "not{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001333 [(set GR8:$dst, (not GR8:$src))]>;
Dan Gohman91888f02007-07-31 20:11:57 +00001334def NOT16r : I<0xF7, MRM2r, (outs GR16:$dst), (ins GR16:$src), "not{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001335 [(set GR16:$dst, (not GR16:$src))]>, OpSize;
Dan Gohman91888f02007-07-31 20:11:57 +00001336def NOT32r : I<0xF7, MRM2r, (outs GR32:$dst), (ins GR32:$src), "not{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001337 [(set GR32:$dst, (not GR32:$src))]>;
Evan Chengc6cee682009-01-21 02:09:05 +00001338}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001339let isTwoAddress = 0 in {
Dan Gohman91888f02007-07-31 20:11:57 +00001340 def NOT8m : I<0xF6, MRM2m, (outs), (ins i8mem :$dst), "not{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001341 [(store (not (loadi8 addr:$dst)), addr:$dst)]>;
Dan Gohman91888f02007-07-31 20:11:57 +00001342 def NOT16m : I<0xF7, MRM2m, (outs), (ins i16mem:$dst), "not{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001343 [(store (not (loadi16 addr:$dst)), addr:$dst)]>, OpSize;
Dan Gohman91888f02007-07-31 20:11:57 +00001344 def NOT32m : I<0xF7, MRM2m, (outs), (ins i32mem:$dst), "not{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001345 [(store (not (loadi32 addr:$dst)), addr:$dst)]>;
1346}
1347} // CodeSize
1348
1349// TODO: inc/dec is slow for P4, but fast for Pentium-M.
Evan Cheng55687072007-09-14 21:48:26 +00001350let Defs = [EFLAGS] in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001351let CodeSize = 2 in
Dan Gohman91888f02007-07-31 20:11:57 +00001352def INC8r : I<0xFE, MRM0r, (outs GR8 :$dst), (ins GR8 :$src), "inc{b}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001353 [(set GR8:$dst, (add GR8:$src, 1)),
1354 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001355let isConvertibleToThreeAddress = 1, CodeSize = 1 in { // Can xform into LEA.
Dan Gohman91888f02007-07-31 20:11:57 +00001356def INC16r : I<0x40, AddRegFrm, (outs GR16:$dst), (ins GR16:$src), "inc{w}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001357 [(set GR16:$dst, (add GR16:$src, 1)),
1358 (implicit EFLAGS)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001359 OpSize, Requires<[In32BitMode]>;
Dan Gohman91888f02007-07-31 20:11:57 +00001360def INC32r : I<0x40, AddRegFrm, (outs GR32:$dst), (ins GR32:$src), "inc{l}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001361 [(set GR32:$dst, (add GR32:$src, 1)),
1362 (implicit EFLAGS)]>, Requires<[In32BitMode]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001363}
1364let isTwoAddress = 0, CodeSize = 2 in {
Dan Gohman91888f02007-07-31 20:11:57 +00001365 def INC8m : I<0xFE, MRM0m, (outs), (ins i8mem :$dst), "inc{b}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001366 [(store (add (loadi8 addr:$dst), 1), addr:$dst),
1367 (implicit EFLAGS)]>;
Dan Gohman91888f02007-07-31 20:11:57 +00001368 def INC16m : I<0xFF, MRM0m, (outs), (ins i16mem:$dst), "inc{w}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001369 [(store (add (loadi16 addr:$dst), 1), addr:$dst),
1370 (implicit EFLAGS)]>,
Evan Cheng4a7e72f2007-10-19 21:23:22 +00001371 OpSize, Requires<[In32BitMode]>;
Dan Gohman91888f02007-07-31 20:11:57 +00001372 def INC32m : I<0xFF, MRM0m, (outs), (ins i32mem:$dst), "inc{l}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001373 [(store (add (loadi32 addr:$dst), 1), addr:$dst),
1374 (implicit EFLAGS)]>,
Evan Cheng4a7e72f2007-10-19 21:23:22 +00001375 Requires<[In32BitMode]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001376}
1377
1378let CodeSize = 2 in
Dan Gohman91888f02007-07-31 20:11:57 +00001379def DEC8r : I<0xFE, MRM1r, (outs GR8 :$dst), (ins GR8 :$src), "dec{b}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001380 [(set GR8:$dst, (add GR8:$src, -1)),
1381 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001382let isConvertibleToThreeAddress = 1, CodeSize = 1 in { // Can xform into LEA.
Dan Gohman91888f02007-07-31 20:11:57 +00001383def DEC16r : I<0x48, AddRegFrm, (outs GR16:$dst), (ins GR16:$src), "dec{w}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001384 [(set GR16:$dst, (add GR16:$src, -1)),
1385 (implicit EFLAGS)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001386 OpSize, Requires<[In32BitMode]>;
Dan Gohman91888f02007-07-31 20:11:57 +00001387def DEC32r : I<0x48, AddRegFrm, (outs GR32:$dst), (ins GR32:$src), "dec{l}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001388 [(set GR32:$dst, (add GR32:$src, -1)),
1389 (implicit EFLAGS)]>, Requires<[In32BitMode]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001390}
1391
1392let isTwoAddress = 0, CodeSize = 2 in {
Dan Gohman91888f02007-07-31 20:11:57 +00001393 def DEC8m : I<0xFE, MRM1m, (outs), (ins i8mem :$dst), "dec{b}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001394 [(store (add (loadi8 addr:$dst), -1), addr:$dst),
1395 (implicit EFLAGS)]>;
Dan Gohman91888f02007-07-31 20:11:57 +00001396 def DEC16m : I<0xFF, MRM1m, (outs), (ins i16mem:$dst), "dec{w}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001397 [(store (add (loadi16 addr:$dst), -1), addr:$dst),
1398 (implicit EFLAGS)]>,
Evan Cheng4a7e72f2007-10-19 21:23:22 +00001399 OpSize, Requires<[In32BitMode]>;
Dan Gohman91888f02007-07-31 20:11:57 +00001400 def DEC32m : I<0xFF, MRM1m, (outs), (ins i32mem:$dst), "dec{l}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001401 [(store (add (loadi32 addr:$dst), -1), addr:$dst),
1402 (implicit EFLAGS)]>,
Evan Cheng4a7e72f2007-10-19 21:23:22 +00001403 Requires<[In32BitMode]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001404}
Evan Cheng55687072007-09-14 21:48:26 +00001405} // Defs = [EFLAGS]
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001406
1407// Logical operators...
Evan Cheng55687072007-09-14 21:48:26 +00001408let Defs = [EFLAGS] in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001409let isCommutable = 1 in { // X = AND Y, Z --> X = AND Z, Y
1410def AND8rr : I<0x20, MRMDestReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001411 (outs GR8 :$dst), (ins GR8 :$src1, GR8 :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001412 "and{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001413 [(set GR8:$dst, (and GR8:$src1, GR8:$src2)),
1414 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001415def AND16rr : I<0x21, MRMDestReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001416 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001417 "and{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001418 [(set GR16:$dst, (and GR16:$src1, GR16:$src2)),
1419 (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001420def AND32rr : I<0x21, MRMDestReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001421 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001422 "and{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001423 [(set GR32:$dst, (and GR32:$src1, GR32:$src2)),
1424 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001425}
1426
1427def AND8rm : I<0x22, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001428 (outs GR8 :$dst), (ins GR8 :$src1, i8mem :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001429 "and{b}\t{$src2, $dst|$dst, $src2}",
Chris Lattner12208612009-04-10 00:16:23 +00001430 [(set GR8:$dst, (and GR8:$src1, (loadi8 addr:$src2))),
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001431 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001432def AND16rm : I<0x23, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001433 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001434 "and{w}\t{$src2, $dst|$dst, $src2}",
Chris Lattner12208612009-04-10 00:16:23 +00001435 [(set GR16:$dst, (and GR16:$src1, (loadi16 addr:$src2))),
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001436 (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001437def AND32rm : I<0x23, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001438 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001439 "and{l}\t{$src2, $dst|$dst, $src2}",
Chris Lattner12208612009-04-10 00:16:23 +00001440 [(set GR32:$dst, (and GR32:$src1, (loadi32 addr:$src2))),
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001441 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001442
1443def AND8ri : Ii8<0x80, MRM4r,
Evan Chengb783fa32007-07-19 01:14:50 +00001444 (outs GR8 :$dst), (ins GR8 :$src1, i8imm :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001445 "and{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001446 [(set GR8:$dst, (and GR8:$src1, imm:$src2)),
1447 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001448def AND16ri : Ii16<0x81, MRM4r,
Evan Chengb783fa32007-07-19 01:14:50 +00001449 (outs GR16:$dst), (ins GR16:$src1, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001450 "and{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001451 [(set GR16:$dst, (and GR16:$src1, imm:$src2)),
1452 (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001453def AND32ri : Ii32<0x81, MRM4r,
Evan Chengb783fa32007-07-19 01:14:50 +00001454 (outs GR32:$dst), (ins GR32:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001455 "and{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001456 [(set GR32:$dst, (and GR32:$src1, imm:$src2)),
1457 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001458def AND16ri8 : Ii8<0x83, MRM4r,
Evan Chengb783fa32007-07-19 01:14:50 +00001459 (outs GR16:$dst), (ins GR16:$src1, i16i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001460 "and{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001461 [(set GR16:$dst, (and GR16:$src1, i16immSExt8:$src2)),
1462 (implicit EFLAGS)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001463 OpSize;
1464def AND32ri8 : Ii8<0x83, MRM4r,
Evan Chengb783fa32007-07-19 01:14:50 +00001465 (outs GR32:$dst), (ins GR32:$src1, i32i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001466 "and{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001467 [(set GR32:$dst, (and GR32:$src1, i32immSExt8:$src2)),
1468 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001469
1470let isTwoAddress = 0 in {
1471 def AND8mr : I<0x20, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001472 (outs), (ins i8mem :$dst, GR8 :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001473 "and{b}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001474 [(store (and (load addr:$dst), GR8:$src), addr:$dst),
1475 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001476 def AND16mr : I<0x21, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001477 (outs), (ins i16mem:$dst, GR16:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001478 "and{w}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001479 [(store (and (load addr:$dst), GR16:$src), addr:$dst),
1480 (implicit EFLAGS)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001481 OpSize;
1482 def AND32mr : I<0x21, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001483 (outs), (ins i32mem:$dst, GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001484 "and{l}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001485 [(store (and (load addr:$dst), GR32:$src), addr:$dst),
1486 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001487 def AND8mi : Ii8<0x80, MRM4m,
Evan Chengb783fa32007-07-19 01:14:50 +00001488 (outs), (ins i8mem :$dst, i8imm :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001489 "and{b}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001490 [(store (and (loadi8 addr:$dst), imm:$src), addr:$dst),
1491 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001492 def AND16mi : Ii16<0x81, MRM4m,
Evan Chengb783fa32007-07-19 01:14:50 +00001493 (outs), (ins i16mem:$dst, i16imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001494 "and{w}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001495 [(store (and (loadi16 addr:$dst), imm:$src), addr:$dst),
1496 (implicit EFLAGS)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001497 OpSize;
1498 def AND32mi : Ii32<0x81, MRM4m,
Evan Chengb783fa32007-07-19 01:14:50 +00001499 (outs), (ins i32mem:$dst, i32imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001500 "and{l}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001501 [(store (and (loadi32 addr:$dst), imm:$src), addr:$dst),
1502 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001503 def AND16mi8 : Ii8<0x83, MRM4m,
Evan Chengb783fa32007-07-19 01:14:50 +00001504 (outs), (ins i16mem:$dst, i16i8imm :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001505 "and{w}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001506 [(store (and (load addr:$dst), i16immSExt8:$src), addr:$dst),
1507 (implicit EFLAGS)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001508 OpSize;
1509 def AND32mi8 : Ii8<0x83, MRM4m,
Evan Chengb783fa32007-07-19 01:14:50 +00001510 (outs), (ins i32mem:$dst, i32i8imm :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001511 "and{l}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001512 [(store (and (load addr:$dst), i32immSExt8:$src), addr:$dst),
1513 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001514}
1515
1516
1517let isCommutable = 1 in { // X = OR Y, Z --> X = OR Z, Y
Evan Chengb783fa32007-07-19 01:14:50 +00001518def OR8rr : I<0x08, MRMDestReg, (outs GR8 :$dst), (ins GR8 :$src1, GR8 :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001519 "or{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001520 [(set GR8:$dst, (or GR8:$src1, GR8:$src2)),
1521 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001522def OR16rr : I<0x09, MRMDestReg, (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001523 "or{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001524 [(set GR16:$dst, (or GR16:$src1, GR16:$src2)),
1525 (implicit EFLAGS)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001526def OR32rr : I<0x09, MRMDestReg, (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001527 "or{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001528 [(set GR32:$dst, (or GR32:$src1, GR32:$src2)),
1529 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001530}
Evan Chengb783fa32007-07-19 01:14:50 +00001531def OR8rm : I<0x0A, MRMSrcMem , (outs GR8 :$dst), (ins GR8 :$src1, i8mem :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001532 "or{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001533 [(set GR8:$dst, (or GR8:$src1, (load addr:$src2))),
1534 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001535def OR16rm : I<0x0B, MRMSrcMem , (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001536 "or{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001537 [(set GR16:$dst, (or GR16:$src1, (load addr:$src2))),
1538 (implicit EFLAGS)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001539def OR32rm : I<0x0B, MRMSrcMem , (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001540 "or{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001541 [(set GR32:$dst, (or GR32:$src1, (load addr:$src2))),
1542 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001543
Evan Chengb783fa32007-07-19 01:14:50 +00001544def OR8ri : Ii8 <0x80, MRM1r, (outs GR8 :$dst), (ins GR8 :$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001545 "or{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001546 [(set GR8:$dst, (or GR8:$src1, imm:$src2)),
1547 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001548def OR16ri : Ii16<0x81, MRM1r, (outs GR16:$dst), (ins GR16:$src1, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001549 "or{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001550 [(set GR16:$dst, (or GR16:$src1, imm:$src2)),
1551 (implicit EFLAGS)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001552def OR32ri : Ii32<0x81, MRM1r, (outs GR32:$dst), (ins GR32:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001553 "or{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001554 [(set GR32:$dst, (or GR32:$src1, imm:$src2)),
1555 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001556
Evan Chengb783fa32007-07-19 01:14:50 +00001557def OR16ri8 : Ii8<0x83, MRM1r, (outs GR16:$dst), (ins GR16:$src1, i16i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001558 "or{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001559 [(set GR16:$dst, (or GR16:$src1, i16immSExt8:$src2)),
1560 (implicit EFLAGS)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001561def OR32ri8 : Ii8<0x83, MRM1r, (outs GR32:$dst), (ins GR32:$src1, i32i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001562 "or{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001563 [(set GR32:$dst, (or GR32:$src1, i32immSExt8:$src2)),
1564 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001565let isTwoAddress = 0 in {
Evan Chengb783fa32007-07-19 01:14:50 +00001566 def OR8mr : I<0x08, MRMDestMem, (outs), (ins i8mem:$dst, GR8:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001567 "or{b}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001568 [(store (or (load addr:$dst), GR8:$src), addr:$dst),
1569 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001570 def OR16mr : I<0x09, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001571 "or{w}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001572 [(store (or (load addr:$dst), GR16:$src), addr:$dst),
1573 (implicit EFLAGS)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001574 def OR32mr : I<0x09, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001575 "or{l}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001576 [(store (or (load addr:$dst), GR32:$src), addr:$dst),
1577 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001578 def OR8mi : Ii8<0x80, MRM1m, (outs), (ins i8mem :$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001579 "or{b}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001580 [(store (or (loadi8 addr:$dst), imm:$src), addr:$dst),
1581 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001582 def OR16mi : Ii16<0x81, MRM1m, (outs), (ins i16mem:$dst, i16imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001583 "or{w}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001584 [(store (or (loadi16 addr:$dst), imm:$src), addr:$dst),
1585 (implicit EFLAGS)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001586 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001587 def OR32mi : Ii32<0x81, MRM1m, (outs), (ins i32mem:$dst, i32imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001588 "or{l}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001589 [(store (or (loadi32 addr:$dst), imm:$src), addr:$dst),
1590 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001591 def OR16mi8 : Ii8<0x83, MRM1m, (outs), (ins i16mem:$dst, i16i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001592 "or{w}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001593 [(store (or (load addr:$dst), i16immSExt8:$src), addr:$dst),
1594 (implicit EFLAGS)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001595 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001596 def OR32mi8 : Ii8<0x83, MRM1m, (outs), (ins i32mem:$dst, i32i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001597 "or{l}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001598 [(store (or (load addr:$dst), i32immSExt8:$src), addr:$dst),
1599 (implicit EFLAGS)]>;
Bill Wendlingba5d5b02008-05-29 01:02:09 +00001600} // isTwoAddress = 0
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001601
1602
Evan Cheng6f26e8b2008-06-18 08:13:07 +00001603let isCommutable = 1 in { // X = XOR Y, Z --> X = XOR Z, Y
Bill Wendlingba5d5b02008-05-29 01:02:09 +00001604 def XOR8rr : I<0x30, MRMDestReg,
1605 (outs GR8 :$dst), (ins GR8 :$src1, GR8 :$src2),
1606 "xor{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001607 [(set GR8:$dst, (xor GR8:$src1, GR8:$src2)),
1608 (implicit EFLAGS)]>;
Bill Wendlingba5d5b02008-05-29 01:02:09 +00001609 def XOR16rr : I<0x31, MRMDestReg,
1610 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
1611 "xor{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001612 [(set GR16:$dst, (xor GR16:$src1, GR16:$src2)),
1613 (implicit EFLAGS)]>, OpSize;
Bill Wendlingba5d5b02008-05-29 01:02:09 +00001614 def XOR32rr : I<0x31, MRMDestReg,
1615 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
1616 "xor{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001617 [(set GR32:$dst, (xor GR32:$src1, GR32:$src2)),
1618 (implicit EFLAGS)]>;
Evan Cheng6f26e8b2008-06-18 08:13:07 +00001619} // isCommutable = 1
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001620
1621def XOR8rm : I<0x32, MRMSrcMem ,
Evan Chengb783fa32007-07-19 01:14:50 +00001622 (outs GR8 :$dst), (ins GR8:$src1, i8mem :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001623 "xor{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001624 [(set GR8:$dst, (xor GR8:$src1, (load addr:$src2))),
1625 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001626def XOR16rm : I<0x33, MRMSrcMem ,
Evan Chengb783fa32007-07-19 01:14:50 +00001627 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001628 "xor{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001629 [(set GR16:$dst, (xor GR16:$src1, (load addr:$src2))),
1630 (implicit EFLAGS)]>,
Bill Wendlingba5d5b02008-05-29 01:02:09 +00001631 OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001632def XOR32rm : I<0x33, MRMSrcMem ,
Evan Chengb783fa32007-07-19 01:14:50 +00001633 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001634 "xor{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001635 [(set GR32:$dst, (xor GR32:$src1, (load addr:$src2))),
1636 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001637
Bill Wendlingbac38eb2008-05-29 03:46:36 +00001638def XOR8ri : Ii8<0x80, MRM6r,
1639 (outs GR8:$dst), (ins GR8:$src1, i8imm:$src2),
1640 "xor{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001641 [(set GR8:$dst, (xor GR8:$src1, imm:$src2)),
1642 (implicit EFLAGS)]>;
Bill Wendlingbac38eb2008-05-29 03:46:36 +00001643def XOR16ri : Ii16<0x81, MRM6r,
1644 (outs GR16:$dst), (ins GR16:$src1, i16imm:$src2),
1645 "xor{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001646 [(set GR16:$dst, (xor GR16:$src1, imm:$src2)),
1647 (implicit EFLAGS)]>, OpSize;
Bill Wendlingbac38eb2008-05-29 03:46:36 +00001648def XOR32ri : Ii32<0x81, MRM6r,
1649 (outs GR32:$dst), (ins GR32:$src1, i32imm:$src2),
1650 "xor{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001651 [(set GR32:$dst, (xor GR32:$src1, imm:$src2)),
1652 (implicit EFLAGS)]>;
Bill Wendlingbac38eb2008-05-29 03:46:36 +00001653def XOR16ri8 : Ii8<0x83, MRM6r,
1654 (outs GR16:$dst), (ins GR16:$src1, i16i8imm:$src2),
1655 "xor{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001656 [(set GR16:$dst, (xor GR16:$src1, i16immSExt8:$src2)),
1657 (implicit EFLAGS)]>,
Bill Wendlingbac38eb2008-05-29 03:46:36 +00001658 OpSize;
1659def XOR32ri8 : Ii8<0x83, MRM6r,
1660 (outs GR32:$dst), (ins GR32:$src1, i32i8imm:$src2),
1661 "xor{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001662 [(set GR32:$dst, (xor GR32:$src1, i32immSExt8:$src2)),
1663 (implicit EFLAGS)]>;
Bill Wendlingba5d5b02008-05-29 01:02:09 +00001664
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001665let isTwoAddress = 0 in {
1666 def XOR8mr : I<0x30, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001667 (outs), (ins i8mem :$dst, GR8 :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001668 "xor{b}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001669 [(store (xor (load addr:$dst), GR8:$src), addr:$dst),
1670 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001671 def XOR16mr : I<0x31, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001672 (outs), (ins i16mem:$dst, GR16:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001673 "xor{w}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001674 [(store (xor (load addr:$dst), GR16:$src), addr:$dst),
1675 (implicit EFLAGS)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001676 OpSize;
1677 def XOR32mr : I<0x31, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001678 (outs), (ins i32mem:$dst, GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001679 "xor{l}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001680 [(store (xor (load addr:$dst), GR32:$src), addr:$dst),
1681 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001682 def XOR8mi : Ii8<0x80, MRM6m,
Evan Chengb783fa32007-07-19 01:14:50 +00001683 (outs), (ins i8mem :$dst, i8imm :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001684 "xor{b}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001685 [(store (xor (loadi8 addr:$dst), imm:$src), addr:$dst),
1686 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001687 def XOR16mi : Ii16<0x81, MRM6m,
Evan Chengb783fa32007-07-19 01:14:50 +00001688 (outs), (ins i16mem:$dst, i16imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001689 "xor{w}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001690 [(store (xor (loadi16 addr:$dst), imm:$src), addr:$dst),
1691 (implicit EFLAGS)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001692 OpSize;
1693 def XOR32mi : Ii32<0x81, MRM6m,
Evan Chengb783fa32007-07-19 01:14:50 +00001694 (outs), (ins i32mem:$dst, i32imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001695 "xor{l}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001696 [(store (xor (loadi32 addr:$dst), imm:$src), addr:$dst),
1697 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001698 def XOR16mi8 : Ii8<0x83, MRM6m,
Evan Chengb783fa32007-07-19 01:14:50 +00001699 (outs), (ins i16mem:$dst, i16i8imm :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001700 "xor{w}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001701 [(store (xor (load addr:$dst), i16immSExt8:$src), addr:$dst),
1702 (implicit EFLAGS)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001703 OpSize;
1704 def XOR32mi8 : Ii8<0x83, MRM6m,
Evan Chengb783fa32007-07-19 01:14:50 +00001705 (outs), (ins i32mem:$dst, i32i8imm :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001706 "xor{l}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001707 [(store (xor (load addr:$dst), i32immSExt8:$src), addr:$dst),
1708 (implicit EFLAGS)]>;
Bill Wendlingba5d5b02008-05-29 01:02:09 +00001709} // isTwoAddress = 0
Evan Cheng55687072007-09-14 21:48:26 +00001710} // Defs = [EFLAGS]
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001711
1712// Shift instructions
Evan Cheng55687072007-09-14 21:48:26 +00001713let Defs = [EFLAGS] in {
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001714let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00001715def SHL8rCL : I<0xD2, MRM4r, (outs GR8 :$dst), (ins GR8 :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001716 "shl{b}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001717 [(set GR8:$dst, (shl GR8:$src, CL))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001718def SHL16rCL : I<0xD3, MRM4r, (outs GR16:$dst), (ins GR16:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001719 "shl{w}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001720 [(set GR16:$dst, (shl GR16:$src, CL))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001721def SHL32rCL : I<0xD3, MRM4r, (outs GR32:$dst), (ins GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001722 "shl{l}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001723 [(set GR32:$dst, (shl GR32:$src, CL))]>;
Bill Wendlingba5d5b02008-05-29 01:02:09 +00001724} // Uses = [CL]
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001725
Evan Chengb783fa32007-07-19 01:14:50 +00001726def SHL8ri : Ii8<0xC0, MRM4r, (outs GR8 :$dst), (ins GR8 :$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001727 "shl{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001728 [(set GR8:$dst, (shl GR8:$src1, (i8 imm:$src2)))]>;
1729let isConvertibleToThreeAddress = 1 in { // Can transform into LEA.
Evan Chengb783fa32007-07-19 01:14:50 +00001730def SHL16ri : Ii8<0xC1, MRM4r, (outs GR16:$dst), (ins GR16:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001731 "shl{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001732 [(set GR16:$dst, (shl GR16:$src1, (i8 imm:$src2)))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001733def SHL32ri : Ii8<0xC1, MRM4r, (outs GR32:$dst), (ins GR32:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001734 "shl{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001735 [(set GR32:$dst, (shl GR32:$src1, (i8 imm:$src2)))]>;
Chris Lattnerf4005a82008-01-11 18:00:50 +00001736// NOTE: We don't use shifts of a register by one, because 'add reg,reg' is
1737// cheaper.
Bill Wendlingba5d5b02008-05-29 01:02:09 +00001738} // isConvertibleToThreeAddress = 1
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001739
1740let isTwoAddress = 0 in {
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001741 let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00001742 def SHL8mCL : I<0xD2, MRM4m, (outs), (ins i8mem :$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001743 "shl{b}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001744 [(store (shl (loadi8 addr:$dst), CL), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001745 def SHL16mCL : I<0xD3, MRM4m, (outs), (ins i16mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001746 "shl{w}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001747 [(store (shl (loadi16 addr:$dst), CL), addr:$dst)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001748 def SHL32mCL : I<0xD3, MRM4m, (outs), (ins i32mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001749 "shl{l}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001750 [(store (shl (loadi32 addr:$dst), CL), addr:$dst)]>;
1751 }
Evan Chengb783fa32007-07-19 01:14:50 +00001752 def SHL8mi : Ii8<0xC0, MRM4m, (outs), (ins i8mem :$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001753 "shl{b}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001754 [(store (shl (loadi8 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001755 def SHL16mi : Ii8<0xC1, MRM4m, (outs), (ins i16mem:$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001756 "shl{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001757 [(store (shl (loadi16 addr:$dst), (i8 imm:$src)), addr:$dst)]>,
1758 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001759 def SHL32mi : Ii8<0xC1, MRM4m, (outs), (ins i32mem:$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001760 "shl{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001761 [(store (shl (loadi32 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
1762
1763 // Shift by 1
Evan Chengb783fa32007-07-19 01:14:50 +00001764 def SHL8m1 : I<0xD0, MRM4m, (outs), (ins i8mem :$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001765 "shl{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001766 [(store (shl (loadi8 addr:$dst), (i8 1)), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001767 def SHL16m1 : I<0xD1, MRM4m, (outs), (ins i16mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001768 "shl{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001769 [(store (shl (loadi16 addr:$dst), (i8 1)), addr:$dst)]>,
1770 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001771 def SHL32m1 : I<0xD1, MRM4m, (outs), (ins i32mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001772 "shl{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001773 [(store (shl (loadi32 addr:$dst), (i8 1)), addr:$dst)]>;
1774}
1775
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001776let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00001777def SHR8rCL : I<0xD2, MRM5r, (outs GR8 :$dst), (ins GR8 :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001778 "shr{b}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001779 [(set GR8:$dst, (srl GR8:$src, CL))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001780def SHR16rCL : I<0xD3, MRM5r, (outs GR16:$dst), (ins GR16:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001781 "shr{w}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001782 [(set GR16:$dst, (srl GR16:$src, CL))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001783def SHR32rCL : I<0xD3, MRM5r, (outs GR32:$dst), (ins GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001784 "shr{l}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001785 [(set GR32:$dst, (srl GR32:$src, CL))]>;
1786}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001787
Evan Chengb783fa32007-07-19 01:14:50 +00001788def SHR8ri : Ii8<0xC0, MRM5r, (outs GR8:$dst), (ins GR8:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001789 "shr{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001790 [(set GR8:$dst, (srl GR8:$src1, (i8 imm:$src2)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001791def SHR16ri : Ii8<0xC1, MRM5r, (outs GR16:$dst), (ins GR16:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001792 "shr{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001793 [(set GR16:$dst, (srl GR16:$src1, (i8 imm:$src2)))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001794def SHR32ri : Ii8<0xC1, MRM5r, (outs GR32:$dst), (ins GR32:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001795 "shr{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001796 [(set GR32:$dst, (srl GR32:$src1, (i8 imm:$src2)))]>;
1797
1798// Shift by 1
Evan Chengb783fa32007-07-19 01:14:50 +00001799def SHR8r1 : I<0xD0, MRM5r, (outs GR8:$dst), (ins GR8:$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00001800 "shr{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001801 [(set GR8:$dst, (srl GR8:$src1, (i8 1)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001802def SHR16r1 : I<0xD1, MRM5r, (outs GR16:$dst), (ins GR16:$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00001803 "shr{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001804 [(set GR16:$dst, (srl GR16:$src1, (i8 1)))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001805def SHR32r1 : I<0xD1, MRM5r, (outs GR32:$dst), (ins GR32:$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00001806 "shr{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001807 [(set GR32:$dst, (srl GR32:$src1, (i8 1)))]>;
1808
1809let isTwoAddress = 0 in {
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001810 let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00001811 def SHR8mCL : I<0xD2, MRM5m, (outs), (ins i8mem :$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001812 "shr{b}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001813 [(store (srl (loadi8 addr:$dst), CL), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001814 def SHR16mCL : I<0xD3, MRM5m, (outs), (ins i16mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001815 "shr{w}\t{%cl, $dst|$dst, %CL}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001816 [(store (srl (loadi16 addr:$dst), CL), addr:$dst)]>,
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001817 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001818 def SHR32mCL : I<0xD3, MRM5m, (outs), (ins i32mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001819 "shr{l}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001820 [(store (srl (loadi32 addr:$dst), CL), addr:$dst)]>;
1821 }
Evan Chengb783fa32007-07-19 01:14:50 +00001822 def SHR8mi : Ii8<0xC0, MRM5m, (outs), (ins i8mem :$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001823 "shr{b}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001824 [(store (srl (loadi8 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001825 def SHR16mi : Ii8<0xC1, MRM5m, (outs), (ins i16mem:$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001826 "shr{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001827 [(store (srl (loadi16 addr:$dst), (i8 imm:$src)), addr:$dst)]>,
1828 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001829 def SHR32mi : Ii8<0xC1, MRM5m, (outs), (ins i32mem:$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001830 "shr{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001831 [(store (srl (loadi32 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
1832
1833 // Shift by 1
Evan Chengb783fa32007-07-19 01:14:50 +00001834 def SHR8m1 : I<0xD0, MRM5m, (outs), (ins i8mem :$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001835 "shr{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001836 [(store (srl (loadi8 addr:$dst), (i8 1)), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001837 def SHR16m1 : I<0xD1, MRM5m, (outs), (ins i16mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001838 "shr{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001839 [(store (srl (loadi16 addr:$dst), (i8 1)), addr:$dst)]>,OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001840 def SHR32m1 : I<0xD1, MRM5m, (outs), (ins i32mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001841 "shr{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001842 [(store (srl (loadi32 addr:$dst), (i8 1)), addr:$dst)]>;
1843}
1844
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001845let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00001846def SAR8rCL : I<0xD2, MRM7r, (outs GR8 :$dst), (ins GR8 :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001847 "sar{b}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001848 [(set GR8:$dst, (sra GR8:$src, CL))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001849def SAR16rCL : I<0xD3, MRM7r, (outs GR16:$dst), (ins GR16:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001850 "sar{w}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001851 [(set GR16:$dst, (sra GR16:$src, CL))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001852def SAR32rCL : I<0xD3, MRM7r, (outs GR32:$dst), (ins GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001853 "sar{l}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001854 [(set GR32:$dst, (sra GR32:$src, CL))]>;
1855}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001856
Evan Chengb783fa32007-07-19 01:14:50 +00001857def SAR8ri : Ii8<0xC0, MRM7r, (outs GR8 :$dst), (ins GR8 :$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001858 "sar{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001859 [(set GR8:$dst, (sra GR8:$src1, (i8 imm:$src2)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001860def SAR16ri : Ii8<0xC1, MRM7r, (outs GR16:$dst), (ins GR16:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001861 "sar{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001862 [(set GR16:$dst, (sra GR16:$src1, (i8 imm:$src2)))]>,
1863 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001864def SAR32ri : Ii8<0xC1, MRM7r, (outs GR32:$dst), (ins GR32:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001865 "sar{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001866 [(set GR32:$dst, (sra GR32:$src1, (i8 imm:$src2)))]>;
1867
1868// Shift by 1
Evan Chengb783fa32007-07-19 01:14:50 +00001869def SAR8r1 : I<0xD0, MRM7r, (outs GR8 :$dst), (ins GR8 :$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00001870 "sar{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001871 [(set GR8:$dst, (sra GR8:$src1, (i8 1)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001872def SAR16r1 : I<0xD1, MRM7r, (outs GR16:$dst), (ins GR16:$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00001873 "sar{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001874 [(set GR16:$dst, (sra GR16:$src1, (i8 1)))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001875def SAR32r1 : I<0xD1, MRM7r, (outs GR32:$dst), (ins GR32:$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00001876 "sar{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001877 [(set GR32:$dst, (sra GR32:$src1, (i8 1)))]>;
1878
1879let isTwoAddress = 0 in {
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001880 let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00001881 def SAR8mCL : I<0xD2, MRM7m, (outs), (ins i8mem :$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001882 "sar{b}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001883 [(store (sra (loadi8 addr:$dst), CL), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001884 def SAR16mCL : I<0xD3, MRM7m, (outs), (ins i16mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001885 "sar{w}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001886 [(store (sra (loadi16 addr:$dst), CL), addr:$dst)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001887 def SAR32mCL : I<0xD3, MRM7m, (outs), (ins i32mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001888 "sar{l}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001889 [(store (sra (loadi32 addr:$dst), CL), addr:$dst)]>;
1890 }
Evan Chengb783fa32007-07-19 01:14:50 +00001891 def SAR8mi : Ii8<0xC0, MRM7m, (outs), (ins i8mem :$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001892 "sar{b}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001893 [(store (sra (loadi8 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001894 def SAR16mi : Ii8<0xC1, MRM7m, (outs), (ins i16mem:$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001895 "sar{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001896 [(store (sra (loadi16 addr:$dst), (i8 imm:$src)), addr:$dst)]>,
1897 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001898 def SAR32mi : Ii8<0xC1, MRM7m, (outs), (ins i32mem:$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001899 "sar{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001900 [(store (sra (loadi32 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
1901
1902 // Shift by 1
Evan Chengb783fa32007-07-19 01:14:50 +00001903 def SAR8m1 : I<0xD0, MRM7m, (outs), (ins i8mem :$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001904 "sar{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001905 [(store (sra (loadi8 addr:$dst), (i8 1)), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001906 def SAR16m1 : I<0xD1, MRM7m, (outs), (ins i16mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001907 "sar{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001908 [(store (sra (loadi16 addr:$dst), (i8 1)), addr:$dst)]>,
1909 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001910 def SAR32m1 : I<0xD1, MRM7m, (outs), (ins i32mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001911 "sar{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001912 [(store (sra (loadi32 addr:$dst), (i8 1)), addr:$dst)]>;
1913}
1914
1915// Rotate instructions
1916// FIXME: provide shorter instructions when imm8 == 1
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001917let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00001918def ROL8rCL : I<0xD2, MRM0r, (outs GR8 :$dst), (ins GR8 :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001919 "rol{b}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001920 [(set GR8:$dst, (rotl GR8:$src, CL))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001921def ROL16rCL : I<0xD3, MRM0r, (outs GR16:$dst), (ins GR16:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001922 "rol{w}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001923 [(set GR16:$dst, (rotl GR16:$src, CL))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001924def ROL32rCL : I<0xD3, MRM0r, (outs GR32:$dst), (ins GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001925 "rol{l}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001926 [(set GR32:$dst, (rotl GR32:$src, CL))]>;
1927}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001928
Evan Chengb783fa32007-07-19 01:14:50 +00001929def ROL8ri : Ii8<0xC0, MRM0r, (outs GR8 :$dst), (ins GR8 :$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001930 "rol{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001931 [(set GR8:$dst, (rotl GR8:$src1, (i8 imm:$src2)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001932def ROL16ri : Ii8<0xC1, MRM0r, (outs GR16:$dst), (ins GR16:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001933 "rol{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001934 [(set GR16:$dst, (rotl GR16:$src1, (i8 imm:$src2)))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001935def ROL32ri : Ii8<0xC1, MRM0r, (outs GR32:$dst), (ins GR32:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001936 "rol{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001937 [(set GR32:$dst, (rotl GR32:$src1, (i8 imm:$src2)))]>;
1938
1939// Rotate by 1
Evan Chengb783fa32007-07-19 01:14:50 +00001940def ROL8r1 : I<0xD0, MRM0r, (outs GR8 :$dst), (ins GR8 :$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00001941 "rol{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001942 [(set GR8:$dst, (rotl GR8:$src1, (i8 1)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001943def ROL16r1 : I<0xD1, MRM0r, (outs GR16:$dst), (ins GR16:$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00001944 "rol{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001945 [(set GR16:$dst, (rotl GR16:$src1, (i8 1)))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001946def ROL32r1 : I<0xD1, MRM0r, (outs GR32:$dst), (ins GR32:$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00001947 "rol{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001948 [(set GR32:$dst, (rotl GR32:$src1, (i8 1)))]>;
1949
1950let isTwoAddress = 0 in {
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001951 let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00001952 def ROL8mCL : I<0xD2, MRM0m, (outs), (ins i8mem :$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001953 "rol{b}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001954 [(store (rotl (loadi8 addr:$dst), CL), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001955 def ROL16mCL : I<0xD3, MRM0m, (outs), (ins i16mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001956 "rol{w}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001957 [(store (rotl (loadi16 addr:$dst), CL), addr:$dst)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001958 def ROL32mCL : I<0xD3, MRM0m, (outs), (ins i32mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001959 "rol{l}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001960 [(store (rotl (loadi32 addr:$dst), CL), addr:$dst)]>;
1961 }
Evan Chengb783fa32007-07-19 01:14:50 +00001962 def ROL8mi : Ii8<0xC0, MRM0m, (outs), (ins i8mem :$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001963 "rol{b}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001964 [(store (rotl (loadi8 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001965 def ROL16mi : Ii8<0xC1, MRM0m, (outs), (ins i16mem:$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001966 "rol{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001967 [(store (rotl (loadi16 addr:$dst), (i8 imm:$src)), addr:$dst)]>,
1968 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001969 def ROL32mi : Ii8<0xC1, MRM0m, (outs), (ins i32mem:$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001970 "rol{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001971 [(store (rotl (loadi32 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
1972
1973 // Rotate by 1
Evan Chengb783fa32007-07-19 01:14:50 +00001974 def ROL8m1 : I<0xD0, MRM0m, (outs), (ins i8mem :$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001975 "rol{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001976 [(store (rotl (loadi8 addr:$dst), (i8 1)), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001977 def ROL16m1 : I<0xD1, MRM0m, (outs), (ins i16mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001978 "rol{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001979 [(store (rotl (loadi16 addr:$dst), (i8 1)), addr:$dst)]>,
1980 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001981 def ROL32m1 : I<0xD1, MRM0m, (outs), (ins i32mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001982 "rol{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001983 [(store (rotl (loadi32 addr:$dst), (i8 1)), addr:$dst)]>;
1984}
1985
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001986let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00001987def ROR8rCL : I<0xD2, MRM1r, (outs GR8 :$dst), (ins GR8 :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001988 "ror{b}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001989 [(set GR8:$dst, (rotr GR8:$src, CL))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001990def ROR16rCL : I<0xD3, MRM1r, (outs GR16:$dst), (ins GR16:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001991 "ror{w}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001992 [(set GR16:$dst, (rotr GR16:$src, CL))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001993def ROR32rCL : I<0xD3, MRM1r, (outs GR32:$dst), (ins GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001994 "ror{l}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001995 [(set GR32:$dst, (rotr GR32:$src, CL))]>;
1996}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001997
Evan Chengb783fa32007-07-19 01:14:50 +00001998def ROR8ri : Ii8<0xC0, MRM1r, (outs GR8 :$dst), (ins GR8 :$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001999 "ror{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002000 [(set GR8:$dst, (rotr GR8:$src1, (i8 imm:$src2)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002001def ROR16ri : Ii8<0xC1, MRM1r, (outs GR16:$dst), (ins GR16:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002002 "ror{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002003 [(set GR16:$dst, (rotr GR16:$src1, (i8 imm:$src2)))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002004def ROR32ri : Ii8<0xC1, MRM1r, (outs GR32:$dst), (ins GR32:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002005 "ror{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002006 [(set GR32:$dst, (rotr GR32:$src1, (i8 imm:$src2)))]>;
2007
2008// Rotate by 1
Evan Chengb783fa32007-07-19 01:14:50 +00002009def ROR8r1 : I<0xD0, MRM1r, (outs GR8 :$dst), (ins GR8 :$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00002010 "ror{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002011 [(set GR8:$dst, (rotr GR8:$src1, (i8 1)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002012def ROR16r1 : I<0xD1, MRM1r, (outs GR16:$dst), (ins GR16:$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00002013 "ror{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002014 [(set GR16:$dst, (rotr GR16:$src1, (i8 1)))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002015def ROR32r1 : I<0xD1, MRM1r, (outs GR32:$dst), (ins GR32:$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00002016 "ror{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002017 [(set GR32:$dst, (rotr GR32:$src1, (i8 1)))]>;
2018
2019let isTwoAddress = 0 in {
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002020 let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00002021 def ROR8mCL : I<0xD2, MRM1m, (outs), (ins i8mem :$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002022 "ror{b}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002023 [(store (rotr (loadi8 addr:$dst), CL), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002024 def ROR16mCL : I<0xD3, MRM1m, (outs), (ins i16mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002025 "ror{w}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002026 [(store (rotr (loadi16 addr:$dst), CL), addr:$dst)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002027 def ROR32mCL : I<0xD3, MRM1m, (outs), (ins i32mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002028 "ror{l}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002029 [(store (rotr (loadi32 addr:$dst), CL), addr:$dst)]>;
2030 }
Evan Chengb783fa32007-07-19 01:14:50 +00002031 def ROR8mi : Ii8<0xC0, MRM1m, (outs), (ins i8mem :$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002032 "ror{b}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002033 [(store (rotr (loadi8 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002034 def ROR16mi : Ii8<0xC1, MRM1m, (outs), (ins i16mem:$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002035 "ror{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002036 [(store (rotr (loadi16 addr:$dst), (i8 imm:$src)), addr:$dst)]>,
2037 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002038 def ROR32mi : Ii8<0xC1, MRM1m, (outs), (ins i32mem:$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002039 "ror{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002040 [(store (rotr (loadi32 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
2041
2042 // Rotate by 1
Evan Chengb783fa32007-07-19 01:14:50 +00002043 def ROR8m1 : I<0xD0, MRM1m, (outs), (ins i8mem :$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002044 "ror{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002045 [(store (rotr (loadi8 addr:$dst), (i8 1)), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002046 def ROR16m1 : I<0xD1, MRM1m, (outs), (ins i16mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002047 "ror{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002048 [(store (rotr (loadi16 addr:$dst), (i8 1)), addr:$dst)]>,
2049 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002050 def ROR32m1 : I<0xD1, MRM1m, (outs), (ins i32mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002051 "ror{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002052 [(store (rotr (loadi32 addr:$dst), (i8 1)), addr:$dst)]>;
2053}
2054
2055
2056
2057// Double shift instructions (generalizations of rotate)
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002058let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00002059def SHLD32rrCL : I<0xA5, MRMDestReg, (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002060 "shld{l}\t{%cl, $src2, $dst|$dst, $src2, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002061 [(set GR32:$dst, (X86shld GR32:$src1, GR32:$src2, CL))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00002062def SHRD32rrCL : I<0xAD, MRMDestReg, (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002063 "shrd{l}\t{%cl, $src2, $dst|$dst, $src2, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002064 [(set GR32:$dst, (X86shrd GR32:$src1, GR32:$src2, CL))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00002065def SHLD16rrCL : I<0xA5, MRMDestReg, (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002066 "shld{w}\t{%cl, $src2, $dst|$dst, $src2, %CL}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002067 [(set GR16:$dst, (X86shld GR16:$src1, GR16:$src2, CL))]>,
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002068 TB, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002069def SHRD16rrCL : I<0xAD, MRMDestReg, (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002070 "shrd{w}\t{%cl, $src2, $dst|$dst, $src2, %CL}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002071 [(set GR16:$dst, (X86shrd GR16:$src1, GR16:$src2, CL))]>,
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002072 TB, OpSize;
2073}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002074
2075let isCommutable = 1 in { // These instructions commute to each other.
2076def SHLD32rri8 : Ii8<0xA4, MRMDestReg,
Evan Chengb783fa32007-07-19 01:14:50 +00002077 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2, i8imm:$src3),
Dan Gohman91888f02007-07-31 20:11:57 +00002078 "shld{l}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002079 [(set GR32:$dst, (X86shld GR32:$src1, GR32:$src2,
2080 (i8 imm:$src3)))]>,
2081 TB;
2082def SHRD32rri8 : Ii8<0xAC, MRMDestReg,
Evan Chengb783fa32007-07-19 01:14:50 +00002083 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2, i8imm:$src3),
Dan Gohman91888f02007-07-31 20:11:57 +00002084 "shrd{l}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002085 [(set GR32:$dst, (X86shrd GR32:$src1, GR32:$src2,
2086 (i8 imm:$src3)))]>,
2087 TB;
2088def SHLD16rri8 : Ii8<0xA4, MRMDestReg,
Evan Chengb783fa32007-07-19 01:14:50 +00002089 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2, i8imm:$src3),
Dan Gohman91888f02007-07-31 20:11:57 +00002090 "shld{w}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002091 [(set GR16:$dst, (X86shld GR16:$src1, GR16:$src2,
2092 (i8 imm:$src3)))]>,
2093 TB, OpSize;
2094def SHRD16rri8 : Ii8<0xAC, MRMDestReg,
Evan Chengb783fa32007-07-19 01:14:50 +00002095 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2, i8imm:$src3),
Dan Gohman91888f02007-07-31 20:11:57 +00002096 "shrd{w}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002097 [(set GR16:$dst, (X86shrd GR16:$src1, GR16:$src2,
2098 (i8 imm:$src3)))]>,
2099 TB, OpSize;
2100}
2101
2102let isTwoAddress = 0 in {
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002103 let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00002104 def SHLD32mrCL : I<0xA5, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002105 "shld{l}\t{%cl, $src2, $dst|$dst, $src2, %CL}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002106 [(store (X86shld (loadi32 addr:$dst), GR32:$src2, CL),
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002107 addr:$dst)]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00002108 def SHRD32mrCL : I<0xAD, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002109 "shrd{l}\t{%cl, $src2, $dst|$dst, $src2, %CL}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002110 [(store (X86shrd (loadi32 addr:$dst), GR32:$src2, CL),
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002111 addr:$dst)]>, TB;
2112 }
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002113 def SHLD32mri8 : Ii8<0xA4, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00002114 (outs), (ins i32mem:$dst, GR32:$src2, i8imm:$src3),
Dan Gohman91888f02007-07-31 20:11:57 +00002115 "shld{l}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002116 [(store (X86shld (loadi32 addr:$dst), GR32:$src2,
2117 (i8 imm:$src3)), addr:$dst)]>,
2118 TB;
2119 def SHRD32mri8 : Ii8<0xAC, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00002120 (outs), (ins i32mem:$dst, GR32:$src2, i8imm:$src3),
Dan Gohman91888f02007-07-31 20:11:57 +00002121 "shrd{l}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002122 [(store (X86shrd (loadi32 addr:$dst), GR32:$src2,
2123 (i8 imm:$src3)), addr:$dst)]>,
2124 TB;
2125
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002126 let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00002127 def SHLD16mrCL : I<0xA5, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002128 "shld{w}\t{%cl, $src2, $dst|$dst, $src2, %CL}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002129 [(store (X86shld (loadi16 addr:$dst), GR16:$src2, CL),
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002130 addr:$dst)]>, TB, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002131 def SHRD16mrCL : I<0xAD, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002132 "shrd{w}\t{%cl, $src2, $dst|$dst, $src2, %CL}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002133 [(store (X86shrd (loadi16 addr:$dst), GR16:$src2, CL),
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002134 addr:$dst)]>, TB, OpSize;
2135 }
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002136 def SHLD16mri8 : Ii8<0xA4, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00002137 (outs), (ins i16mem:$dst, GR16:$src2, i8imm:$src3),
Dan Gohman91888f02007-07-31 20:11:57 +00002138 "shld{w}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002139 [(store (X86shld (loadi16 addr:$dst), GR16:$src2,
2140 (i8 imm:$src3)), addr:$dst)]>,
2141 TB, OpSize;
2142 def SHRD16mri8 : Ii8<0xAC, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00002143 (outs), (ins i16mem:$dst, GR16:$src2, i8imm:$src3),
Dan Gohman91888f02007-07-31 20:11:57 +00002144 "shrd{w}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002145 [(store (X86shrd (loadi16 addr:$dst), GR16:$src2,
2146 (i8 imm:$src3)), addr:$dst)]>,
2147 TB, OpSize;
2148}
Evan Cheng55687072007-09-14 21:48:26 +00002149} // Defs = [EFLAGS]
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002150
2151
2152// Arithmetic.
Evan Cheng55687072007-09-14 21:48:26 +00002153let Defs = [EFLAGS] in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002154let isCommutable = 1 in { // X = ADD Y, Z --> X = ADD Z, Y
Bill Wendlingae034ed2008-12-12 00:56:36 +00002155// Register-Register Addition
2156def ADD8rr : I<0x00, MRMDestReg, (outs GR8 :$dst),
2157 (ins GR8 :$src1, GR8 :$src2),
2158 "add{b}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002159 [(set GR8:$dst, (add GR8:$src1, GR8:$src2)),
Bill Wendlingae034ed2008-12-12 00:56:36 +00002160 (implicit EFLAGS)]>;
2161
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002162let isConvertibleToThreeAddress = 1 in { // Can transform into LEA.
Bill Wendlingae034ed2008-12-12 00:56:36 +00002163// Register-Register Addition
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002164def ADD16rr : I<0x01, MRMDestReg, (outs GR16:$dst),
2165 (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002166 "add{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002167 [(set GR16:$dst, (add GR16:$src1, GR16:$src2)),
2168 (implicit EFLAGS)]>, OpSize;
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002169def ADD32rr : I<0x01, MRMDestReg, (outs GR32:$dst),
2170 (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002171 "add{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002172 [(set GR32:$dst, (add GR32:$src1, GR32:$src2)),
2173 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002174} // end isConvertibleToThreeAddress
2175} // end isCommutable
Bill Wendlingae034ed2008-12-12 00:56:36 +00002176
2177// Register-Memory Addition
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002178def ADD8rm : I<0x02, MRMSrcMem, (outs GR8 :$dst),
2179 (ins GR8 :$src1, i8mem :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002180 "add{b}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002181 [(set GR8:$dst, (add GR8:$src1, (load addr:$src2))),
2182 (implicit EFLAGS)]>;
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002183def ADD16rm : I<0x03, MRMSrcMem, (outs GR16:$dst),
2184 (ins GR16:$src1, i16mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002185 "add{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002186 [(set GR16:$dst, (add GR16:$src1, (load addr:$src2))),
2187 (implicit EFLAGS)]>, OpSize;
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002188def ADD32rm : I<0x03, MRMSrcMem, (outs GR32:$dst),
2189 (ins GR32:$src1, i32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002190 "add{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002191 [(set GR32:$dst, (add GR32:$src1, (load addr:$src2))),
2192 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002193
Bill Wendlingae034ed2008-12-12 00:56:36 +00002194// Register-Integer Addition
2195def ADD8ri : Ii8<0x80, MRM0r, (outs GR8:$dst), (ins GR8:$src1, i8imm:$src2),
2196 "add{b}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002197 [(set GR8:$dst, (add GR8:$src1, imm:$src2)),
2198 (implicit EFLAGS)]>;
Bill Wendlingae034ed2008-12-12 00:56:36 +00002199
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002200let isConvertibleToThreeAddress = 1 in { // Can transform into LEA.
Bill Wendlingae034ed2008-12-12 00:56:36 +00002201// Register-Integer Addition
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002202def ADD16ri : Ii16<0x81, MRM0r, (outs GR16:$dst),
2203 (ins GR16:$src1, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002204 "add{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002205 [(set GR16:$dst, (add GR16:$src1, imm:$src2)),
2206 (implicit EFLAGS)]>, OpSize;
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002207def ADD32ri : Ii32<0x81, MRM0r, (outs GR32:$dst),
2208 (ins GR32:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002209 "add{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002210 [(set GR32:$dst, (add GR32:$src1, imm:$src2)),
2211 (implicit EFLAGS)]>;
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002212def ADD16ri8 : Ii8<0x83, MRM0r, (outs GR16:$dst),
2213 (ins GR16:$src1, i16i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002214 "add{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002215 [(set GR16:$dst, (add GR16:$src1, i16immSExt8:$src2)),
2216 (implicit EFLAGS)]>, OpSize;
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002217def ADD32ri8 : Ii8<0x83, MRM0r, (outs GR32:$dst),
2218 (ins GR32:$src1, i32i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002219 "add{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002220 [(set GR32:$dst, (add GR32:$src1, i32immSExt8:$src2)),
2221 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002222}
2223
2224let isTwoAddress = 0 in {
Bill Wendlingae034ed2008-12-12 00:56:36 +00002225 // Memory-Register Addition
Bill Wendlingf5399032008-12-12 21:15:41 +00002226 def ADD8mr : I<0x00, MRMDestMem, (outs), (ins i8mem:$dst, GR8:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002227 "add{b}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002228 [(store (add (load addr:$dst), GR8:$src2), addr:$dst),
2229 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002230 def ADD16mr : I<0x01, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002231 "add{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002232 [(store (add (load addr:$dst), GR16:$src2), addr:$dst),
2233 (implicit EFLAGS)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002234 def ADD32mr : I<0x01, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002235 "add{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002236 [(store (add (load addr:$dst), GR32:$src2), addr:$dst),
2237 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002238 def ADD8mi : Ii8<0x80, MRM0m, (outs), (ins i8mem :$dst, i8imm :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002239 "add{b}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002240 [(store (add (loadi8 addr:$dst), imm:$src2), addr:$dst),
2241 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002242 def ADD16mi : Ii16<0x81, MRM0m, (outs), (ins i16mem:$dst, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002243 "add{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002244 [(store (add (loadi16 addr:$dst), imm:$src2), addr:$dst),
2245 (implicit EFLAGS)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002246 def ADD32mi : Ii32<0x81, MRM0m, (outs), (ins i32mem:$dst, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002247 "add{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002248 [(store (add (loadi32 addr:$dst), imm:$src2), addr:$dst),
2249 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002250 def ADD16mi8 : Ii8<0x83, MRM0m, (outs), (ins i16mem:$dst, i16i8imm :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002251 "add{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002252 [(store (add (load addr:$dst), i16immSExt8:$src2),
2253 addr:$dst),
2254 (implicit EFLAGS)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002255 def ADD32mi8 : Ii8<0x83, MRM0m, (outs), (ins i32mem:$dst, i32i8imm :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002256 "add{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingae034ed2008-12-12 00:56:36 +00002257 [(store (add (load addr:$dst), i32immSExt8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00002258 addr:$dst),
2259 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002260}
2261
Evan Cheng259471d2007-10-05 17:59:57 +00002262let Uses = [EFLAGS] in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002263let isCommutable = 1 in { // X = ADC Y, Z --> X = ADC Z, Y
Evan Chengb783fa32007-07-19 01:14:50 +00002264def ADC32rr : I<0x11, MRMDestReg, (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002265 "adc{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingc0ca7f32008-12-01 23:44:08 +00002266 [(set GR32:$dst, (adde GR32:$src1, GR32:$src2))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002267}
Evan Chengb783fa32007-07-19 01:14:50 +00002268def ADC32rm : I<0x13, MRMSrcMem , (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002269 "adc{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingc0ca7f32008-12-01 23:44:08 +00002270 [(set GR32:$dst, (adde GR32:$src1, (load addr:$src2)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002271def ADC32ri : Ii32<0x81, MRM2r, (outs GR32:$dst), (ins GR32:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002272 "adc{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingc0ca7f32008-12-01 23:44:08 +00002273 [(set GR32:$dst, (adde GR32:$src1, imm:$src2))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002274def ADC32ri8 : Ii8<0x83, MRM2r, (outs GR32:$dst), (ins GR32:$src1, i32i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002275 "adc{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingc0ca7f32008-12-01 23:44:08 +00002276 [(set GR32:$dst, (adde GR32:$src1, i32immSExt8:$src2))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002277
2278let isTwoAddress = 0 in {
Evan Chengb783fa32007-07-19 01:14:50 +00002279 def ADC32mr : I<0x11, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002280 "adc{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingc0ca7f32008-12-01 23:44:08 +00002281 [(store (adde (load addr:$dst), GR32:$src2), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002282 def ADC32mi : Ii32<0x81, MRM2m, (outs), (ins i32mem:$dst, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002283 "adc{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingc0ca7f32008-12-01 23:44:08 +00002284 [(store (adde (loadi32 addr:$dst), imm:$src2), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002285 def ADC32mi8 : Ii8<0x83, MRM2m, (outs), (ins i32mem:$dst, i32i8imm :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002286 "adc{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendling0c52d0a2008-12-02 00:07:05 +00002287 [(store (adde (load addr:$dst), i32immSExt8:$src2), addr:$dst)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002288}
Evan Cheng259471d2007-10-05 17:59:57 +00002289} // Uses = [EFLAGS]
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002290
Bill Wendlingae034ed2008-12-12 00:56:36 +00002291// Register-Register Subtraction
2292def SUB8rr : I<0x28, MRMDestReg, (outs GR8:$dst), (ins GR8:$src1, GR8:$src2),
2293 "sub{b}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002294 [(set GR8:$dst, (sub GR8:$src1, GR8:$src2)),
2295 (implicit EFLAGS)]>;
Bill Wendlingae034ed2008-12-12 00:56:36 +00002296def SUB16rr : I<0x29, MRMDestReg, (outs GR16:$dst), (ins GR16:$src1,GR16:$src2),
2297 "sub{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002298 [(set GR16:$dst, (sub GR16:$src1, GR16:$src2)),
2299 (implicit EFLAGS)]>, OpSize;
Bill Wendlingae034ed2008-12-12 00:56:36 +00002300def SUB32rr : I<0x29, MRMDestReg, (outs GR32:$dst), (ins GR32:$src1,GR32:$src2),
2301 "sub{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002302 [(set GR32:$dst, (sub GR32:$src1, GR32:$src2)),
2303 (implicit EFLAGS)]>;
Bill Wendlingae034ed2008-12-12 00:56:36 +00002304
2305// Register-Memory Subtraction
2306def SUB8rm : I<0x2A, MRMSrcMem, (outs GR8 :$dst),
2307 (ins GR8 :$src1, i8mem :$src2),
2308 "sub{b}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002309 [(set GR8:$dst, (sub GR8:$src1, (load addr:$src2))),
2310 (implicit EFLAGS)]>;
Bill Wendlingae034ed2008-12-12 00:56:36 +00002311def SUB16rm : I<0x2B, MRMSrcMem, (outs GR16:$dst),
2312 (ins GR16:$src1, i16mem:$src2),
2313 "sub{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002314 [(set GR16:$dst, (sub GR16:$src1, (load addr:$src2))),
2315 (implicit EFLAGS)]>, OpSize;
Bill Wendlingae034ed2008-12-12 00:56:36 +00002316def SUB32rm : I<0x2B, MRMSrcMem, (outs GR32:$dst),
2317 (ins GR32:$src1, i32mem:$src2),
2318 "sub{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002319 [(set GR32:$dst, (sub GR32:$src1, (load addr:$src2))),
2320 (implicit EFLAGS)]>;
Bill Wendlingae034ed2008-12-12 00:56:36 +00002321
2322// Register-Integer Subtraction
2323def SUB8ri : Ii8 <0x80, MRM5r, (outs GR8:$dst),
2324 (ins GR8:$src1, i8imm:$src2),
2325 "sub{b}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002326 [(set GR8:$dst, (sub GR8:$src1, imm:$src2)),
2327 (implicit EFLAGS)]>;
Bill Wendlingae034ed2008-12-12 00:56:36 +00002328def SUB16ri : Ii16<0x81, MRM5r, (outs GR16:$dst),
2329 (ins GR16:$src1, i16imm:$src2),
2330 "sub{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002331 [(set GR16:$dst, (sub GR16:$src1, imm:$src2)),
2332 (implicit EFLAGS)]>, OpSize;
Bill Wendlingae034ed2008-12-12 00:56:36 +00002333def SUB32ri : Ii32<0x81, MRM5r, (outs GR32:$dst),
2334 (ins GR32:$src1, i32imm:$src2),
2335 "sub{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002336 [(set GR32:$dst, (sub GR32:$src1, imm:$src2)),
2337 (implicit EFLAGS)]>;
Bill Wendlingae034ed2008-12-12 00:56:36 +00002338def SUB16ri8 : Ii8<0x83, MRM5r, (outs GR16:$dst),
2339 (ins GR16:$src1, i16i8imm:$src2),
2340 "sub{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002341 [(set GR16:$dst, (sub GR16:$src1, i16immSExt8:$src2)),
2342 (implicit EFLAGS)]>, OpSize;
Bill Wendlingae034ed2008-12-12 00:56:36 +00002343def SUB32ri8 : Ii8<0x83, MRM5r, (outs GR32:$dst),
2344 (ins GR32:$src1, i32i8imm:$src2),
2345 "sub{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002346 [(set GR32:$dst, (sub GR32:$src1, i32immSExt8:$src2)),
2347 (implicit EFLAGS)]>;
Bill Wendlingae034ed2008-12-12 00:56:36 +00002348
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002349let isTwoAddress = 0 in {
Bill Wendlingae034ed2008-12-12 00:56:36 +00002350 // Memory-Register Subtraction
Evan Chengb783fa32007-07-19 01:14:50 +00002351 def SUB8mr : I<0x28, MRMDestMem, (outs), (ins i8mem :$dst, GR8 :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002352 "sub{b}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002353 [(store (sub (load addr:$dst), GR8:$src2), addr:$dst),
2354 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002355 def SUB16mr : I<0x29, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002356 "sub{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002357 [(store (sub (load addr:$dst), GR16:$src2), addr:$dst),
2358 (implicit EFLAGS)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002359 def SUB32mr : I<0x29, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002360 "sub{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002361 [(store (sub (load addr:$dst), GR32:$src2), addr:$dst),
2362 (implicit EFLAGS)]>;
Bill Wendlingae034ed2008-12-12 00:56:36 +00002363
2364 // Memory-Integer Subtraction
Evan Chengb783fa32007-07-19 01:14:50 +00002365 def SUB8mi : Ii8<0x80, MRM5m, (outs), (ins i8mem :$dst, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002366 "sub{b}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002367 [(store (sub (loadi8 addr:$dst), imm:$src2), addr:$dst),
2368 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002369 def SUB16mi : Ii16<0x81, MRM5m, (outs), (ins i16mem:$dst, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002370 "sub{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002371 [(store (sub (loadi16 addr:$dst), imm:$src2),addr:$dst),
2372 (implicit EFLAGS)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002373 def SUB32mi : Ii32<0x81, MRM5m, (outs), (ins i32mem:$dst, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002374 "sub{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002375 [(store (sub (loadi32 addr:$dst), imm:$src2),addr:$dst),
2376 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002377 def SUB16mi8 : Ii8<0x83, MRM5m, (outs), (ins i16mem:$dst, i16i8imm :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002378 "sub{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingae034ed2008-12-12 00:56:36 +00002379 [(store (sub (load addr:$dst), i16immSExt8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00002380 addr:$dst),
2381 (implicit EFLAGS)]>, OpSize;
Bill Wendlingae034ed2008-12-12 00:56:36 +00002382 def SUB32mi8 : Ii8<0x83, MRM5m, (outs), (ins i32mem:$dst, i32i8imm :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002383 "sub{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingae034ed2008-12-12 00:56:36 +00002384 [(store (sub (load addr:$dst), i32immSExt8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00002385 addr:$dst),
2386 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002387}
2388
Evan Cheng259471d2007-10-05 17:59:57 +00002389let Uses = [EFLAGS] in {
Evan Chengb783fa32007-07-19 01:14:50 +00002390def SBB32rr : I<0x19, MRMDestReg, (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002391 "sbb{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng55687072007-09-14 21:48:26 +00002392 [(set GR32:$dst, (sube GR32:$src1, GR32:$src2))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002393
2394let isTwoAddress = 0 in {
Evan Chengb783fa32007-07-19 01:14:50 +00002395 def SBB32mr : I<0x19, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002396 "sbb{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002397 [(store (sube (load addr:$dst), GR32:$src2), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002398 def SBB8mi : Ii32<0x80, MRM3m, (outs), (ins i8mem:$dst, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002399 "sbb{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002400 [(store (sube (loadi8 addr:$dst), imm:$src2), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002401 def SBB32mi : Ii32<0x81, MRM3m, (outs), (ins i32mem:$dst, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002402 "sbb{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002403 [(store (sube (loadi32 addr:$dst), imm:$src2), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002404 def SBB32mi8 : Ii8<0x83, MRM3m, (outs), (ins i32mem:$dst, i32i8imm :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002405 "sbb{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng55687072007-09-14 21:48:26 +00002406 [(store (sube (load addr:$dst), i32immSExt8:$src2), addr:$dst)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002407}
Evan Chengb783fa32007-07-19 01:14:50 +00002408def SBB32rm : I<0x1B, MRMSrcMem, (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002409 "sbb{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002410 [(set GR32:$dst, (sube GR32:$src1, (load addr:$src2)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002411def SBB32ri : Ii32<0x81, MRM3r, (outs GR32:$dst), (ins GR32:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002412 "sbb{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002413 [(set GR32:$dst, (sube GR32:$src1, imm:$src2))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002414def SBB32ri8 : Ii8<0x83, MRM3r, (outs GR32:$dst), (ins GR32:$src1, i32i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002415 "sbb{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002416 [(set GR32:$dst, (sube GR32:$src1, i32immSExt8:$src2))]>;
Evan Cheng259471d2007-10-05 17:59:57 +00002417} // Uses = [EFLAGS]
Evan Cheng55687072007-09-14 21:48:26 +00002418} // Defs = [EFLAGS]
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002419
Evan Cheng55687072007-09-14 21:48:26 +00002420let Defs = [EFLAGS] in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002421let isCommutable = 1 in { // X = IMUL Y, Z --> X = IMUL Z, Y
Bill Wendlingf5399032008-12-12 21:15:41 +00002422// Register-Register Signed Integer Multiply
Bill Wendlingae034ed2008-12-12 00:56:36 +00002423def IMUL16rr : I<0xAF, MRMSrcReg, (outs GR16:$dst), (ins GR16:$src1,GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002424 "imul{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002425 [(set GR16:$dst, (mul GR16:$src1, GR16:$src2)),
2426 (implicit EFLAGS)]>, TB, OpSize;
Bill Wendlingae034ed2008-12-12 00:56:36 +00002427def IMUL32rr : I<0xAF, MRMSrcReg, (outs GR32:$dst), (ins GR32:$src1,GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002428 "imul{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002429 [(set GR32:$dst, (mul GR32:$src1, GR32:$src2)),
2430 (implicit EFLAGS)]>, TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002431}
Bill Wendlingae034ed2008-12-12 00:56:36 +00002432
Bill Wendlingf5399032008-12-12 21:15:41 +00002433// Register-Memory Signed Integer Multiply
Bill Wendlingae034ed2008-12-12 00:56:36 +00002434def IMUL16rm : I<0xAF, MRMSrcMem, (outs GR16:$dst),
2435 (ins GR16:$src1, i16mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002436 "imul{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002437 [(set GR16:$dst, (mul GR16:$src1, (load addr:$src2))),
2438 (implicit EFLAGS)]>, TB, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002439def IMUL32rm : I<0xAF, MRMSrcMem, (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002440 "imul{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002441 [(set GR32:$dst, (mul GR32:$src1, (load addr:$src2))),
2442 (implicit EFLAGS)]>, TB;
Evan Cheng55687072007-09-14 21:48:26 +00002443} // Defs = [EFLAGS]
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002444} // end Two Address instructions
2445
2446// Suprisingly enough, these are not two address instructions!
Evan Cheng55687072007-09-14 21:48:26 +00002447let Defs = [EFLAGS] in {
Bill Wendlingf5399032008-12-12 21:15:41 +00002448// Register-Integer Signed Integer Multiply
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002449def IMUL16rri : Ii16<0x69, MRMSrcReg, // GR16 = GR16*I16
Evan Chengb783fa32007-07-19 01:14:50 +00002450 (outs GR16:$dst), (ins GR16:$src1, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002451 "imul{w}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002452 [(set GR16:$dst, (mul GR16:$src1, imm:$src2)),
2453 (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002454def IMUL32rri : Ii32<0x69, MRMSrcReg, // GR32 = GR32*I32
Evan Chengb783fa32007-07-19 01:14:50 +00002455 (outs GR32:$dst), (ins GR32:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002456 "imul{l}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002457 [(set GR32:$dst, (mul GR32:$src1, imm:$src2)),
2458 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002459def IMUL16rri8 : Ii8<0x6B, MRMSrcReg, // GR16 = GR16*I8
Evan Chengb783fa32007-07-19 01:14:50 +00002460 (outs GR16:$dst), (ins GR16:$src1, i16i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002461 "imul{w}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002462 [(set GR16:$dst, (mul GR16:$src1, i16immSExt8:$src2)),
2463 (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002464def IMUL32rri8 : Ii8<0x6B, MRMSrcReg, // GR32 = GR32*I8
Evan Chengb783fa32007-07-19 01:14:50 +00002465 (outs GR32:$dst), (ins GR32:$src1, i32i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002466 "imul{l}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002467 [(set GR32:$dst, (mul GR32:$src1, i32immSExt8:$src2)),
2468 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002469
Bill Wendlingf5399032008-12-12 21:15:41 +00002470// Memory-Integer Signed Integer Multiply
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002471def IMUL16rmi : Ii16<0x69, MRMSrcMem, // GR16 = [mem16]*I16
Evan Chengb783fa32007-07-19 01:14:50 +00002472 (outs GR16:$dst), (ins i16mem:$src1, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002473 "imul{w}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002474 [(set GR16:$dst, (mul (load addr:$src1), imm:$src2)),
2475 (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002476def IMUL32rmi : Ii32<0x69, MRMSrcMem, // GR32 = [mem32]*I32
Evan Chengb783fa32007-07-19 01:14:50 +00002477 (outs GR32:$dst), (ins i32mem:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002478 "imul{l}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002479 [(set GR32:$dst, (mul (load addr:$src1), imm:$src2)),
2480 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002481def IMUL16rmi8 : Ii8<0x6B, MRMSrcMem, // GR16 = [mem16]*I8
Evan Chengb783fa32007-07-19 01:14:50 +00002482 (outs GR16:$dst), (ins i16mem:$src1, i16i8imm :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002483 "imul{w}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Bill Wendlingae034ed2008-12-12 00:56:36 +00002484 [(set GR16:$dst, (mul (load addr:$src1),
Bill Wendlingf5399032008-12-12 21:15:41 +00002485 i16immSExt8:$src2)),
2486 (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002487def IMUL32rmi8 : Ii8<0x6B, MRMSrcMem, // GR32 = [mem32]*I8
Evan Chengb783fa32007-07-19 01:14:50 +00002488 (outs GR32:$dst), (ins i32mem:$src1, i32i8imm: $src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002489 "imul{l}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Bill Wendlingae034ed2008-12-12 00:56:36 +00002490 [(set GR32:$dst, (mul (load addr:$src1),
Bill Wendlingf5399032008-12-12 21:15:41 +00002491 i32immSExt8:$src2)),
2492 (implicit EFLAGS)]>;
Evan Cheng55687072007-09-14 21:48:26 +00002493} // Defs = [EFLAGS]
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002494
2495//===----------------------------------------------------------------------===//
2496// Test instructions are just like AND, except they don't generate a result.
2497//
Evan Cheng950aac02007-09-25 01:57:46 +00002498let Defs = [EFLAGS] in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002499let isCommutable = 1 in { // TEST X, Y --> TEST Y, X
Evan Chengb783fa32007-07-19 01:14:50 +00002500def TEST8rr : I<0x84, MRMDestReg, (outs), (ins GR8:$src1, GR8:$src2),
Evan Cheng621216e2007-09-29 00:00:36 +00002501 "test{b}\t{$src2, $src1|$src1, $src2}",
Chris Lattner21da6382008-02-19 17:37:35 +00002502 [(X86cmp (and_su GR8:$src1, GR8:$src2), 0),
Evan Cheng621216e2007-09-29 00:00:36 +00002503 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002504def TEST16rr : I<0x85, MRMDestReg, (outs), (ins GR16:$src1, GR16:$src2),
Evan Cheng621216e2007-09-29 00:00:36 +00002505 "test{w}\t{$src2, $src1|$src1, $src2}",
Chris Lattner21da6382008-02-19 17:37:35 +00002506 [(X86cmp (and_su GR16:$src1, GR16:$src2), 0),
Evan Cheng621216e2007-09-29 00:00:36 +00002507 (implicit EFLAGS)]>,
2508 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002509def TEST32rr : I<0x85, MRMDestReg, (outs), (ins GR32:$src1, GR32:$src2),
Evan Cheng621216e2007-09-29 00:00:36 +00002510 "test{l}\t{$src2, $src1|$src1, $src2}",
Chris Lattner21da6382008-02-19 17:37:35 +00002511 [(X86cmp (and_su GR32:$src1, GR32:$src2), 0),
Evan Cheng621216e2007-09-29 00:00:36 +00002512 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002513}
2514
Evan Chengb783fa32007-07-19 01:14:50 +00002515def TEST8rm : I<0x84, MRMSrcMem, (outs), (ins GR8 :$src1, i8mem :$src2),
Evan Cheng621216e2007-09-29 00:00:36 +00002516 "test{b}\t{$src2, $src1|$src1, $src2}",
2517 [(X86cmp (and GR8:$src1, (loadi8 addr:$src2)), 0),
2518 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002519def TEST16rm : I<0x85, MRMSrcMem, (outs), (ins GR16:$src1, i16mem:$src2),
Evan Cheng621216e2007-09-29 00:00:36 +00002520 "test{w}\t{$src2, $src1|$src1, $src2}",
2521 [(X86cmp (and GR16:$src1, (loadi16 addr:$src2)), 0),
2522 (implicit EFLAGS)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002523def TEST32rm : I<0x85, MRMSrcMem, (outs), (ins GR32:$src1, i32mem:$src2),
Evan Cheng621216e2007-09-29 00:00:36 +00002524 "test{l}\t{$src2, $src1|$src1, $src2}",
2525 [(X86cmp (and GR32:$src1, (loadi32 addr:$src2)), 0),
2526 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002527
2528def TEST8ri : Ii8 <0xF6, MRM0r, // flags = GR8 & imm8
Evan Chengb783fa32007-07-19 01:14:50 +00002529 (outs), (ins GR8:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002530 "test{b}\t{$src2, $src1|$src1, $src2}",
Chris Lattner21da6382008-02-19 17:37:35 +00002531 [(X86cmp (and_su GR8:$src1, imm:$src2), 0),
Evan Cheng621216e2007-09-29 00:00:36 +00002532 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002533def TEST16ri : Ii16<0xF7, MRM0r, // flags = GR16 & imm16
Evan Chengb783fa32007-07-19 01:14:50 +00002534 (outs), (ins GR16:$src1, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002535 "test{w}\t{$src2, $src1|$src1, $src2}",
Chris Lattner21da6382008-02-19 17:37:35 +00002536 [(X86cmp (and_su GR16:$src1, imm:$src2), 0),
Evan Cheng621216e2007-09-29 00:00:36 +00002537 (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002538def TEST32ri : Ii32<0xF7, MRM0r, // flags = GR32 & imm32
Evan Chengb783fa32007-07-19 01:14:50 +00002539 (outs), (ins GR32:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002540 "test{l}\t{$src2, $src1|$src1, $src2}",
Chris Lattner21da6382008-02-19 17:37:35 +00002541 [(X86cmp (and_su GR32:$src1, imm:$src2), 0),
Evan Cheng621216e2007-09-29 00:00:36 +00002542 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002543
Evan Cheng621216e2007-09-29 00:00:36 +00002544def TEST8mi : Ii8 <0xF6, MRM0m, // flags = [mem8] & imm8
Evan Chengb783fa32007-07-19 01:14:50 +00002545 (outs), (ins i8mem:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002546 "test{b}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002547 [(X86cmp (and (loadi8 addr:$src1), imm:$src2), 0),
2548 (implicit EFLAGS)]>;
2549def TEST16mi : Ii16<0xF7, MRM0m, // flags = [mem16] & imm16
Evan Chengb783fa32007-07-19 01:14:50 +00002550 (outs), (ins i16mem:$src1, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002551 "test{w}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002552 [(X86cmp (and (loadi16 addr:$src1), imm:$src2), 0),
2553 (implicit EFLAGS)]>, OpSize;
2554def TEST32mi : Ii32<0xF7, MRM0m, // flags = [mem32] & imm32
Evan Chengb783fa32007-07-19 01:14:50 +00002555 (outs), (ins i32mem:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002556 "test{l}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002557 [(X86cmp (and (loadi32 addr:$src1), imm:$src2), 0),
Evan Cheng950aac02007-09-25 01:57:46 +00002558 (implicit EFLAGS)]>;
2559} // Defs = [EFLAGS]
2560
2561
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002562// Condition code ops, incl. set if equal/not equal/...
Chris Lattnerc90ee9c2008-01-10 07:59:24 +00002563let Defs = [EFLAGS], Uses = [AH], neverHasSideEffects = 1 in
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002564def SAHF : I<0x9E, RawFrm, (outs), (ins), "sahf", []>; // flags = AH
Chris Lattnerc90ee9c2008-01-10 07:59:24 +00002565let Defs = [AH], Uses = [EFLAGS], neverHasSideEffects = 1 in
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002566def LAHF : I<0x9F, RawFrm, (outs), (ins), "lahf", []>; // AH = flags
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002567
Evan Cheng950aac02007-09-25 01:57:46 +00002568let Uses = [EFLAGS] in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002569def SETEr : I<0x94, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00002570 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002571 "sete\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002572 [(set GR8:$dst, (X86setcc X86_COND_E, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002573 TB; // GR8 = ==
2574def SETEm : I<0x94, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00002575 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002576 "sete\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002577 [(store (X86setcc X86_COND_E, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002578 TB; // [mem8] = ==
Bill Wendling0c52d0a2008-12-02 00:07:05 +00002579
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002580def SETNEr : I<0x95, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00002581 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002582 "setne\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002583 [(set GR8:$dst, (X86setcc X86_COND_NE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002584 TB; // GR8 = !=
2585def SETNEm : I<0x95, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00002586 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002587 "setne\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002588 [(store (X86setcc X86_COND_NE, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002589 TB; // [mem8] = !=
Bill Wendling0c52d0a2008-12-02 00:07:05 +00002590
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002591def SETLr : I<0x9C, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00002592 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002593 "setl\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002594 [(set GR8:$dst, (X86setcc X86_COND_L, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002595 TB; // GR8 = < signed
2596def SETLm : I<0x9C, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00002597 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002598 "setl\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002599 [(store (X86setcc X86_COND_L, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002600 TB; // [mem8] = < signed
Bill Wendling0c52d0a2008-12-02 00:07:05 +00002601
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002602def SETGEr : I<0x9D, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00002603 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002604 "setge\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002605 [(set GR8:$dst, (X86setcc X86_COND_GE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002606 TB; // GR8 = >= signed
2607def SETGEm : I<0x9D, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00002608 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002609 "setge\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002610 [(store (X86setcc X86_COND_GE, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002611 TB; // [mem8] = >= signed
Bill Wendling0c52d0a2008-12-02 00:07:05 +00002612
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002613def SETLEr : I<0x9E, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00002614 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002615 "setle\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002616 [(set GR8:$dst, (X86setcc X86_COND_LE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002617 TB; // GR8 = <= signed
2618def SETLEm : I<0x9E, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00002619 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002620 "setle\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002621 [(store (X86setcc X86_COND_LE, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002622 TB; // [mem8] = <= signed
Bill Wendling0c52d0a2008-12-02 00:07:05 +00002623
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002624def SETGr : I<0x9F, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00002625 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002626 "setg\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002627 [(set GR8:$dst, (X86setcc X86_COND_G, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002628 TB; // GR8 = > signed
2629def SETGm : I<0x9F, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00002630 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002631 "setg\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002632 [(store (X86setcc X86_COND_G, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002633 TB; // [mem8] = > signed
2634
2635def SETBr : I<0x92, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00002636 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002637 "setb\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002638 [(set GR8:$dst, (X86setcc X86_COND_B, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002639 TB; // GR8 = < unsign
2640def SETBm : I<0x92, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00002641 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002642 "setb\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002643 [(store (X86setcc X86_COND_B, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002644 TB; // [mem8] = < unsign
Bill Wendling0c52d0a2008-12-02 00:07:05 +00002645
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002646def SETAEr : I<0x93, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00002647 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002648 "setae\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002649 [(set GR8:$dst, (X86setcc X86_COND_AE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002650 TB; // GR8 = >= unsign
2651def SETAEm : I<0x93, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00002652 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002653 "setae\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002654 [(store (X86setcc X86_COND_AE, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002655 TB; // [mem8] = >= unsign
Bill Wendling0c52d0a2008-12-02 00:07:05 +00002656
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002657def SETBEr : I<0x96, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00002658 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002659 "setbe\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002660 [(set GR8:$dst, (X86setcc X86_COND_BE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002661 TB; // GR8 = <= unsign
2662def SETBEm : I<0x96, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00002663 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002664 "setbe\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002665 [(store (X86setcc X86_COND_BE, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002666 TB; // [mem8] = <= unsign
Bill Wendling0c52d0a2008-12-02 00:07:05 +00002667
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002668def SETAr : I<0x97, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00002669 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002670 "seta\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002671 [(set GR8:$dst, (X86setcc X86_COND_A, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002672 TB; // GR8 = > signed
2673def SETAm : I<0x97, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00002674 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002675 "seta\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002676 [(store (X86setcc X86_COND_A, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002677 TB; // [mem8] = > signed
2678
2679def SETSr : I<0x98, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00002680 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002681 "sets\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002682 [(set GR8:$dst, (X86setcc X86_COND_S, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002683 TB; // GR8 = <sign bit>
2684def SETSm : I<0x98, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00002685 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002686 "sets\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002687 [(store (X86setcc X86_COND_S, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002688 TB; // [mem8] = <sign bit>
2689def SETNSr : I<0x99, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00002690 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002691 "setns\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002692 [(set GR8:$dst, (X86setcc X86_COND_NS, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002693 TB; // GR8 = !<sign bit>
2694def SETNSm : I<0x99, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00002695 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002696 "setns\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002697 [(store (X86setcc X86_COND_NS, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002698 TB; // [mem8] = !<sign bit>
Bill Wendling0c52d0a2008-12-02 00:07:05 +00002699
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002700def SETPr : I<0x9A, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00002701 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002702 "setp\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002703 [(set GR8:$dst, (X86setcc X86_COND_P, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002704 TB; // GR8 = parity
2705def SETPm : I<0x9A, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00002706 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002707 "setp\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002708 [(store (X86setcc X86_COND_P, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002709 TB; // [mem8] = parity
2710def SETNPr : I<0x9B, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00002711 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002712 "setnp\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002713 [(set GR8:$dst, (X86setcc X86_COND_NP, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002714 TB; // GR8 = not parity
2715def SETNPm : I<0x9B, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00002716 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002717 "setnp\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002718 [(store (X86setcc X86_COND_NP, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002719 TB; // [mem8] = not parity
Bill Wendling0c52d0a2008-12-02 00:07:05 +00002720
2721def SETOr : I<0x90, MRM0r,
2722 (outs GR8 :$dst), (ins),
2723 "seto\t$dst",
2724 [(set GR8:$dst, (X86setcc X86_COND_O, EFLAGS))]>,
2725 TB; // GR8 = overflow
2726def SETOm : I<0x90, MRM0m,
2727 (outs), (ins i8mem:$dst),
2728 "seto\t$dst",
2729 [(store (X86setcc X86_COND_O, EFLAGS), addr:$dst)]>,
2730 TB; // [mem8] = overflow
2731def SETNOr : I<0x91, MRM0r,
2732 (outs GR8 :$dst), (ins),
2733 "setno\t$dst",
2734 [(set GR8:$dst, (X86setcc X86_COND_NO, EFLAGS))]>,
2735 TB; // GR8 = not overflow
2736def SETNOm : I<0x91, MRM0m,
2737 (outs), (ins i8mem:$dst),
2738 "setno\t$dst",
2739 [(store (X86setcc X86_COND_NO, EFLAGS), addr:$dst)]>,
2740 TB; // [mem8] = not overflow
Evan Cheng950aac02007-09-25 01:57:46 +00002741} // Uses = [EFLAGS]
2742
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002743
2744// Integer comparisons
Evan Cheng55687072007-09-14 21:48:26 +00002745let Defs = [EFLAGS] in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002746def CMP8rr : I<0x38, MRMDestReg,
Evan Chengb783fa32007-07-19 01:14:50 +00002747 (outs), (ins GR8 :$src1, GR8 :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002748 "cmp{b}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002749 [(X86cmp GR8:$src1, GR8:$src2), (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002750def CMP16rr : I<0x39, MRMDestReg,
Evan Chengb783fa32007-07-19 01:14:50 +00002751 (outs), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002752 "cmp{w}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002753 [(X86cmp GR16:$src1, GR16:$src2), (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002754def CMP32rr : I<0x39, MRMDestReg,
Evan Chengb783fa32007-07-19 01:14:50 +00002755 (outs), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002756 "cmp{l}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002757 [(X86cmp GR32:$src1, GR32:$src2), (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002758def CMP8mr : I<0x38, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00002759 (outs), (ins i8mem :$src1, GR8 :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002760 "cmp{b}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002761 [(X86cmp (loadi8 addr:$src1), GR8:$src2),
2762 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002763def CMP16mr : I<0x39, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00002764 (outs), (ins i16mem:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002765 "cmp{w}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002766 [(X86cmp (loadi16 addr:$src1), GR16:$src2),
2767 (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002768def CMP32mr : I<0x39, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00002769 (outs), (ins i32mem:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002770 "cmp{l}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002771 [(X86cmp (loadi32 addr:$src1), GR32:$src2),
2772 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002773def CMP8rm : I<0x3A, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00002774 (outs), (ins GR8 :$src1, i8mem :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002775 "cmp{b}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002776 [(X86cmp GR8:$src1, (loadi8 addr:$src2)),
2777 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002778def CMP16rm : I<0x3B, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00002779 (outs), (ins GR16:$src1, i16mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002780 "cmp{w}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002781 [(X86cmp GR16:$src1, (loadi16 addr:$src2)),
2782 (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002783def CMP32rm : I<0x3B, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00002784 (outs), (ins GR32:$src1, i32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002785 "cmp{l}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002786 [(X86cmp GR32:$src1, (loadi32 addr:$src2)),
2787 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002788def CMP8ri : Ii8<0x80, MRM7r,
Evan Chengb783fa32007-07-19 01:14:50 +00002789 (outs), (ins GR8:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002790 "cmp{b}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002791 [(X86cmp GR8:$src1, imm:$src2), (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002792def CMP16ri : Ii16<0x81, MRM7r,
Evan Chengb783fa32007-07-19 01:14:50 +00002793 (outs), (ins GR16:$src1, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002794 "cmp{w}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002795 [(X86cmp GR16:$src1, imm:$src2),
2796 (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002797def CMP32ri : Ii32<0x81, MRM7r,
Evan Chengb783fa32007-07-19 01:14:50 +00002798 (outs), (ins GR32:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002799 "cmp{l}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002800 [(X86cmp GR32:$src1, imm:$src2), (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002801def CMP8mi : Ii8 <0x80, MRM7m,
Evan Chengb783fa32007-07-19 01:14:50 +00002802 (outs), (ins i8mem :$src1, i8imm :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002803 "cmp{b}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002804 [(X86cmp (loadi8 addr:$src1), imm:$src2),
2805 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002806def CMP16mi : Ii16<0x81, MRM7m,
Evan Chengb783fa32007-07-19 01:14:50 +00002807 (outs), (ins i16mem:$src1, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002808 "cmp{w}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002809 [(X86cmp (loadi16 addr:$src1), imm:$src2),
2810 (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002811def CMP32mi : Ii32<0x81, MRM7m,
Evan Chengb783fa32007-07-19 01:14:50 +00002812 (outs), (ins i32mem:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002813 "cmp{l}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002814 [(X86cmp (loadi32 addr:$src1), imm:$src2),
2815 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002816def CMP16ri8 : Ii8<0x83, MRM7r,
Evan Chengb783fa32007-07-19 01:14:50 +00002817 (outs), (ins GR16:$src1, i16i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002818 "cmp{w}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002819 [(X86cmp GR16:$src1, i16immSExt8:$src2),
2820 (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002821def CMP16mi8 : Ii8<0x83, MRM7m,
Evan Chengb783fa32007-07-19 01:14:50 +00002822 (outs), (ins i16mem:$src1, i16i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002823 "cmp{w}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002824 [(X86cmp (loadi16 addr:$src1), i16immSExt8:$src2),
2825 (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002826def CMP32mi8 : Ii8<0x83, MRM7m,
Evan Chengb783fa32007-07-19 01:14:50 +00002827 (outs), (ins i32mem:$src1, i32i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002828 "cmp{l}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002829 [(X86cmp (loadi32 addr:$src1), i32immSExt8:$src2),
2830 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002831def CMP32ri8 : Ii8<0x83, MRM7r,
Evan Chengb783fa32007-07-19 01:14:50 +00002832 (outs), (ins GR32:$src1, i32i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002833 "cmp{l}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002834 [(X86cmp GR32:$src1, i32immSExt8:$src2),
Evan Cheng950aac02007-09-25 01:57:46 +00002835 (implicit EFLAGS)]>;
2836} // Defs = [EFLAGS]
2837
Dan Gohman7fe9b7f2008-12-23 22:45:23 +00002838// Bit tests.
Dan Gohman7fe9b7f2008-12-23 22:45:23 +00002839// TODO: BTC, BTR, and BTS
2840let Defs = [EFLAGS] in {
Dan Gohmanfc4eddb2009-01-13 20:32:45 +00002841def BT16rr : I<0xA3, MRMDestReg, (outs), (ins GR16:$src1, GR16:$src2),
Dan Gohman7fe9b7f2008-12-23 22:45:23 +00002842 "bt{w}\t{$src2, $src1|$src1, $src2}",
2843 [(X86bt GR16:$src1, GR16:$src2),
Chris Lattner5a95cde2008-12-25 01:32:49 +00002844 (implicit EFLAGS)]>, OpSize, TB;
Dan Gohmanfc4eddb2009-01-13 20:32:45 +00002845def BT32rr : I<0xA3, MRMDestReg, (outs), (ins GR32:$src1, GR32:$src2),
Dan Gohman7fe9b7f2008-12-23 22:45:23 +00002846 "bt{l}\t{$src2, $src1|$src1, $src2}",
2847 [(X86bt GR32:$src1, GR32:$src2),
Chris Lattner5a95cde2008-12-25 01:32:49 +00002848 (implicit EFLAGS)]>, TB;
Dan Gohman85a228c2009-01-13 23:23:30 +00002849
2850// Unlike with the register+register form, the memory+register form of the
2851// bt instruction does not ignore the high bits of the index. From ISel's
2852// perspective, this is pretty bizarre. Disable these instructions for now.
2853//def BT16mr : I<0xA3, MRMDestMem, (outs), (ins i16mem:$src1, GR16:$src2),
2854// "bt{w}\t{$src2, $src1|$src1, $src2}",
2855// [(X86bt (loadi16 addr:$src1), GR16:$src2),
2856// (implicit EFLAGS)]>, OpSize, TB, Requires<[FastBTMem]>;
2857//def BT32mr : I<0xA3, MRMDestMem, (outs), (ins i32mem:$src1, GR32:$src2),
2858// "bt{l}\t{$src2, $src1|$src1, $src2}",
2859// [(X86bt (loadi32 addr:$src1), GR32:$src2),
2860// (implicit EFLAGS)]>, TB, Requires<[FastBTMem]>;
Dan Gohman46fb1cf2009-01-13 20:33:23 +00002861
2862def BT16ri8 : Ii8<0xBA, MRM4r, (outs), (ins GR16:$src1, i16i8imm:$src2),
2863 "bt{w}\t{$src2, $src1|$src1, $src2}",
2864 [(X86bt GR16:$src1, i16immSExt8:$src2),
2865 (implicit EFLAGS)]>, OpSize, TB;
2866def BT32ri8 : Ii8<0xBA, MRM4r, (outs), (ins GR32:$src1, i32i8imm:$src2),
2867 "bt{l}\t{$src2, $src1|$src1, $src2}",
2868 [(X86bt GR32:$src1, i32immSExt8:$src2),
2869 (implicit EFLAGS)]>, TB;
2870// Note that these instructions don't need FastBTMem because that
2871// only applies when the other operand is in a register. When it's
2872// an immediate, bt is still fast.
2873def BT16mi8 : Ii8<0xBA, MRM4m, (outs), (ins i16mem:$src1, i16i8imm:$src2),
2874 "bt{w}\t{$src2, $src1|$src1, $src2}",
2875 [(X86bt (loadi16 addr:$src1), i16immSExt8:$src2),
2876 (implicit EFLAGS)]>, OpSize, TB;
2877def BT32mi8 : Ii8<0xBA, MRM4m, (outs), (ins i32mem:$src1, i32i8imm:$src2),
2878 "bt{l}\t{$src2, $src1|$src1, $src2}",
2879 [(X86bt (loadi32 addr:$src1), i32immSExt8:$src2),
2880 (implicit EFLAGS)]>, TB;
Dan Gohman7fe9b7f2008-12-23 22:45:23 +00002881} // Defs = [EFLAGS]
2882
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002883// Sign/Zero extenders
Dan Gohman9203ab42008-07-30 18:09:17 +00002884// Use movsbl intead of movsbw; we don't care about the high 16 bits
2885// of the register here. This has a smaller encoding and avoids a
2886// partial-register update.
Evan Chengb783fa32007-07-19 01:14:50 +00002887def MOVSX16rr8 : I<0xBE, MRMSrcReg, (outs GR16:$dst), (ins GR8 :$src),
Dan Gohman9203ab42008-07-30 18:09:17 +00002888 "movs{bl|x}\t{$src, ${dst:subreg32}|${dst:subreg32}, $src}",
2889 [(set GR16:$dst, (sext GR8:$src))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00002890def MOVSX16rm8 : I<0xBE, MRMSrcMem, (outs GR16:$dst), (ins i8mem :$src),
Dan Gohman9203ab42008-07-30 18:09:17 +00002891 "movs{bl|x}\t{$src, ${dst:subreg32}|${dst:subreg32}, $src}",
2892 [(set GR16:$dst, (sextloadi16i8 addr:$src))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00002893def MOVSX32rr8 : I<0xBE, MRMSrcReg, (outs GR32:$dst), (ins GR8 :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002894 "movs{bl|x}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002895 [(set GR32:$dst, (sext GR8:$src))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00002896def MOVSX32rm8 : I<0xBE, MRMSrcMem, (outs GR32:$dst), (ins i8mem :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002897 "movs{bl|x}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002898 [(set GR32:$dst, (sextloadi32i8 addr:$src))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00002899def MOVSX32rr16: I<0xBF, MRMSrcReg, (outs GR32:$dst), (ins GR16:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002900 "movs{wl|x}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002901 [(set GR32:$dst, (sext GR16:$src))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00002902def MOVSX32rm16: I<0xBF, MRMSrcMem, (outs GR32:$dst), (ins i16mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002903 "movs{wl|x}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002904 [(set GR32:$dst, (sextloadi32i16 addr:$src))]>, TB;
2905
Dan Gohman9203ab42008-07-30 18:09:17 +00002906// Use movzbl intead of movzbw; we don't care about the high 16 bits
2907// of the register here. This has a smaller encoding and avoids a
2908// partial-register update.
Evan Chengb783fa32007-07-19 01:14:50 +00002909def MOVZX16rr8 : I<0xB6, MRMSrcReg, (outs GR16:$dst), (ins GR8 :$src),
Dan Gohman9203ab42008-07-30 18:09:17 +00002910 "movz{bl|x}\t{$src, ${dst:subreg32}|${dst:subreg32}, $src}",
2911 [(set GR16:$dst, (zext GR8:$src))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00002912def MOVZX16rm8 : I<0xB6, MRMSrcMem, (outs GR16:$dst), (ins i8mem :$src),
Dan Gohman9203ab42008-07-30 18:09:17 +00002913 "movz{bl|x}\t{$src, ${dst:subreg32}|${dst:subreg32}, $src}",
2914 [(set GR16:$dst, (zextloadi16i8 addr:$src))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00002915def MOVZX32rr8 : I<0xB6, MRMSrcReg, (outs GR32:$dst), (ins GR8 :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002916 "movz{bl|x}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002917 [(set GR32:$dst, (zext GR8:$src))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00002918def MOVZX32rm8 : I<0xB6, MRMSrcMem, (outs GR32:$dst), (ins i8mem :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002919 "movz{bl|x}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002920 [(set GR32:$dst, (zextloadi32i8 addr:$src))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00002921def MOVZX32rr16: I<0xB7, MRMSrcReg, (outs GR32:$dst), (ins GR16:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002922 "movz{wl|x}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002923 [(set GR32:$dst, (zext GR16:$src))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00002924def MOVZX32rm16: I<0xB7, MRMSrcMem, (outs GR32:$dst), (ins i16mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002925 "movz{wl|x}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002926 [(set GR32:$dst, (zextloadi32i16 addr:$src))]>, TB;
2927
Dan Gohman744d4622009-04-13 16:09:41 +00002928// These are the same as the regular regular MOVZX32rr8 and MOVZX32rm8
2929// except that they use GR32_NOREX for the output operand register class
2930// instead of GR32. This allows them to operate on h registers on x86-64.
2931def MOVZX32_NOREXrr8 : I<0xB6, MRMSrcReg,
2932 (outs GR32_NOREX:$dst), (ins GR8:$src),
2933 "movz{bl|x}\t{$src, $dst|$dst, $src} # NOREX",
2934 []>, TB;
2935def MOVZX32_NOREXrm8 : I<0xB6, MRMSrcMem,
2936 (outs GR32_NOREX:$dst), (ins i8mem:$src),
2937 "movz{bl|x}\t{$src, $dst|$dst, $src} # NOREX",
2938 []>, TB;
2939
Chris Lattnerc90ee9c2008-01-10 07:59:24 +00002940let neverHasSideEffects = 1 in {
2941 let Defs = [AX], Uses = [AL] in
2942 def CBW : I<0x98, RawFrm, (outs), (ins),
2943 "{cbtw|cbw}", []>, OpSize; // AX = signext(AL)
2944 let Defs = [EAX], Uses = [AX] in
2945 def CWDE : I<0x98, RawFrm, (outs), (ins),
2946 "{cwtl|cwde}", []>; // EAX = signext(AX)
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002947
Chris Lattnerc90ee9c2008-01-10 07:59:24 +00002948 let Defs = [AX,DX], Uses = [AX] in
2949 def CWD : I<0x99, RawFrm, (outs), (ins),
2950 "{cwtd|cwd}", []>, OpSize; // DX:AX = signext(AX)
2951 let Defs = [EAX,EDX], Uses = [EAX] in
2952 def CDQ : I<0x99, RawFrm, (outs), (ins),
2953 "{cltd|cdq}", []>; // EDX:EAX = signext(EAX)
2954}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002955
2956//===----------------------------------------------------------------------===//
2957// Alias Instructions
2958//===----------------------------------------------------------------------===//
2959
2960// Alias instructions that map movr0 to xor.
2961// FIXME: remove when we can teach regalloc that xor reg, reg is ok.
Bill Wendlingba5d5b02008-05-29 01:02:09 +00002962let Defs = [EFLAGS], isReMaterializable = 1, isAsCheapAsAMove = 1 in {
Evan Chengb783fa32007-07-19 01:14:50 +00002963def MOV8r0 : I<0x30, MRMInitReg, (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002964 "xor{b}\t$dst, $dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002965 [(set GR8:$dst, 0)]>;
Dan Gohman9203ab42008-07-30 18:09:17 +00002966// Use xorl instead of xorw since we don't care about the high 16 bits,
2967// it's smaller, and it avoids a partial-register update.
Evan Chengb783fa32007-07-19 01:14:50 +00002968def MOV16r0 : I<0x31, MRMInitReg, (outs GR16:$dst), (ins),
Dan Gohman9203ab42008-07-30 18:09:17 +00002969 "xor{l}\t${dst:subreg32}, ${dst:subreg32}",
2970 [(set GR16:$dst, 0)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002971def MOV32r0 : I<0x31, MRMInitReg, (outs GR32:$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002972 "xor{l}\t$dst, $dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002973 [(set GR32:$dst, 0)]>;
Dan Gohman8aef09b2007-09-07 21:32:51 +00002974}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002975
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002976//===----------------------------------------------------------------------===//
2977// Thread Local Storage Instructions
2978//
2979
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002980let Uses = [EBX] in
Anton Korobeynikov4fbf00b2008-05-04 21:36:32 +00002981def TLS_addr32 : I<0, Pseudo, (outs GR32:$dst), (ins i32imm:$sym),
2982 "leal\t${sym:mem}(,%ebx,1), $dst",
2983 [(set GR32:$dst, (X86tlsaddr tglobaltlsaddr:$sym))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002984
sampo9cc09a32009-01-26 01:24:32 +00002985let AddedComplexity = 5 in
2986def GS_MOV32rm : I<0x8B, MRMSrcMem, (outs GR32:$dst), (ins i32mem:$src),
2987 "movl\t%gs:$src, $dst",
2988 [(set GR32:$dst, (gsload addr:$src))]>, SegGS;
2989
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002990//===----------------------------------------------------------------------===//
2991// DWARF Pseudo Instructions
2992//
2993
Evan Chengb783fa32007-07-19 01:14:50 +00002994def DWARF_LOC : I<0, Pseudo, (outs),
2995 (ins i32imm:$line, i32imm:$col, i32imm:$file),
Dan Gohman77af4a82007-09-24 19:25:06 +00002996 ".loc\t${file:debug} ${line:debug} ${col:debug}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002997 [(dwarf_loc (i32 imm:$line), (i32 imm:$col),
2998 (i32 imm:$file))]>;
2999
3000//===----------------------------------------------------------------------===//
3001// EH Pseudo Instructions
3002//
3003let isTerminator = 1, isReturn = 1, isBarrier = 1,
Evan Cheng37e7c752007-07-21 00:34:19 +00003004 hasCtrlDep = 1 in {
Evan Chengb783fa32007-07-19 01:14:50 +00003005def EH_RETURN : I<0xC3, RawFrm, (outs), (ins GR32:$addr),
Dan Gohman91888f02007-07-31 20:11:57 +00003006 "ret\t#eh_return, addr: $addr",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003007 [(X86ehret GR32:$addr)]>;
3008
3009}
3010
3011//===----------------------------------------------------------------------===//
Andrew Lenharthe44f3902008-02-21 06:45:13 +00003012// Atomic support
3013//
Andrew Lenharth7a5a4b22008-03-01 13:37:02 +00003014
Evan Cheng3e171562008-04-19 01:20:30 +00003015// Atomic swap. These are just normal xchg instructions. But since a memory
3016// operand is referenced, the atomicity is ensured.
Dan Gohmana41a1c092008-08-06 15:52:50 +00003017let Constraints = "$val = $dst" in {
Evan Cheng3e171562008-04-19 01:20:30 +00003018def XCHG32rm : I<0x87, MRMSrcMem, (outs GR32:$dst), (ins i32mem:$ptr, GR32:$val),
3019 "xchg{l}\t{$val, $ptr|$ptr, $val}",
3020 [(set GR32:$dst, (atomic_swap_32 addr:$ptr, GR32:$val))]>;
3021def XCHG16rm : I<0x87, MRMSrcMem, (outs GR16:$dst), (ins i16mem:$ptr, GR16:$val),
3022 "xchg{w}\t{$val, $ptr|$ptr, $val}",
3023 [(set GR16:$dst, (atomic_swap_16 addr:$ptr, GR16:$val))]>,
3024 OpSize;
3025def XCHG8rm : I<0x86, MRMSrcMem, (outs GR8:$dst), (ins i8mem:$ptr, GR8:$val),
3026 "xchg{b}\t{$val, $ptr|$ptr, $val}",
3027 [(set GR8:$dst, (atomic_swap_8 addr:$ptr, GR8:$val))]>;
3028}
3029
Evan Chengd49dbb82008-04-18 20:55:36 +00003030// Atomic compare and swap.
Andrew Lenharth7dfe23f2008-03-01 21:52:34 +00003031let Defs = [EAX, EFLAGS], Uses = [EAX] in {
Evan Chengd49dbb82008-04-18 20:55:36 +00003032def LCMPXCHG32 : I<0xB1, MRMDestMem, (outs), (ins i32mem:$ptr, GR32:$swap),
Dale Johannesend20e4452008-08-19 18:47:28 +00003033 "lock\n\tcmpxchg{l}\t{$swap, $ptr|$ptr, $swap}",
Evan Cheng09fbdee2008-03-04 03:20:06 +00003034 [(X86cas addr:$ptr, GR32:$swap, 4)]>, TB, LOCK;
Andrew Lenharth7a5a4b22008-03-01 13:37:02 +00003035}
Dale Johannesenf160d802008-10-02 18:53:47 +00003036let Defs = [EAX, EDX, EFLAGS], Uses = [EAX, EBX, ECX, EDX] in {
Anton Korobeynikovc4067392008-07-22 16:22:48 +00003037def LCMPXCHG8B : I<0xC7, MRM1m, (outs), (ins i32mem:$ptr),
Dale Johannesend20e4452008-08-19 18:47:28 +00003038 "lock\n\tcmpxchg8b\t$ptr",
Andrew Lenharth81580822008-03-05 01:15:49 +00003039 [(X86cas8 addr:$ptr)]>, TB, LOCK;
3040}
Andrew Lenharth7dfe23f2008-03-01 21:52:34 +00003041
3042let Defs = [AX, EFLAGS], Uses = [AX] in {
Evan Chengd49dbb82008-04-18 20:55:36 +00003043def LCMPXCHG16 : I<0xB1, MRMDestMem, (outs), (ins i16mem:$ptr, GR16:$swap),
Dale Johannesend20e4452008-08-19 18:47:28 +00003044 "lock\n\tcmpxchg{w}\t{$swap, $ptr|$ptr, $swap}",
Evan Cheng09fbdee2008-03-04 03:20:06 +00003045 [(X86cas addr:$ptr, GR16:$swap, 2)]>, TB, OpSize, LOCK;
Andrew Lenharth7a5a4b22008-03-01 13:37:02 +00003046}
Andrew Lenharth7dfe23f2008-03-01 21:52:34 +00003047let Defs = [AL, EFLAGS], Uses = [AL] in {
Evan Chengd49dbb82008-04-18 20:55:36 +00003048def LCMPXCHG8 : I<0xB0, MRMDestMem, (outs), (ins i8mem:$ptr, GR8:$swap),
Dale Johannesend20e4452008-08-19 18:47:28 +00003049 "lock\n\tcmpxchg{b}\t{$swap, $ptr|$ptr, $swap}",
Evan Cheng09fbdee2008-03-04 03:20:06 +00003050 [(X86cas addr:$ptr, GR8:$swap, 1)]>, TB, LOCK;
Andrew Lenharth7a5a4b22008-03-01 13:37:02 +00003051}
3052
Evan Chengd49dbb82008-04-18 20:55:36 +00003053// Atomic exchange and add
3054let Constraints = "$val = $dst", Defs = [EFLAGS] in {
3055def LXADD32 : I<0xC1, MRMSrcMem, (outs GR32:$dst), (ins i32mem:$ptr, GR32:$val),
Dale Johannesend20e4452008-08-19 18:47:28 +00003056 "lock\n\txadd{l}\t{$val, $ptr|$ptr, $val}",
Mon P Wang6bde9ec2008-06-25 08:15:39 +00003057 [(set GR32:$dst, (atomic_load_add_32 addr:$ptr, GR32:$val))]>,
Evan Chengd49dbb82008-04-18 20:55:36 +00003058 TB, LOCK;
3059def LXADD16 : I<0xC1, MRMSrcMem, (outs GR16:$dst), (ins i16mem:$ptr, GR16:$val),
Dale Johannesend20e4452008-08-19 18:47:28 +00003060 "lock\n\txadd{w}\t{$val, $ptr|$ptr, $val}",
Mon P Wang6bde9ec2008-06-25 08:15:39 +00003061 [(set GR16:$dst, (atomic_load_add_16 addr:$ptr, GR16:$val))]>,
Evan Chengd49dbb82008-04-18 20:55:36 +00003062 TB, OpSize, LOCK;
3063def LXADD8 : I<0xC0, MRMSrcMem, (outs GR8:$dst), (ins i8mem:$ptr, GR8:$val),
Dale Johannesend20e4452008-08-19 18:47:28 +00003064 "lock\n\txadd{b}\t{$val, $ptr|$ptr, $val}",
Mon P Wang6bde9ec2008-06-25 08:15:39 +00003065 [(set GR8:$dst, (atomic_load_add_8 addr:$ptr, GR8:$val))]>,
Evan Chengd49dbb82008-04-18 20:55:36 +00003066 TB, LOCK;
Andrew Lenharth7a5a4b22008-03-01 13:37:02 +00003067}
3068
Mon P Wang6bde9ec2008-06-25 08:15:39 +00003069// Atomic exchange, and, or, xor
Mon P Wang078a62d2008-05-05 19:05:59 +00003070let Constraints = "$val = $dst", Defs = [EFLAGS],
3071 usesCustomDAGSchedInserter = 1 in {
Dan Gohman8aeb61f2008-05-12 20:22:45 +00003072def ATOMAND32 : I<0, Pseudo, (outs GR32:$dst),(ins i32mem:$ptr, GR32:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003073 "#ATOMAND32 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003074 [(set GR32:$dst, (atomic_load_and_32 addr:$ptr, GR32:$val))]>;
Dan Gohman8aeb61f2008-05-12 20:22:45 +00003075def ATOMOR32 : I<0, Pseudo, (outs GR32:$dst),(ins i32mem:$ptr, GR32:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003076 "#ATOMOR32 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003077 [(set GR32:$dst, (atomic_load_or_32 addr:$ptr, GR32:$val))]>;
Dan Gohman8aeb61f2008-05-12 20:22:45 +00003078def ATOMXOR32 : I<0, Pseudo,(outs GR32:$dst),(ins i32mem:$ptr, GR32:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003079 "#ATOMXOR32 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003080 [(set GR32:$dst, (atomic_load_xor_32 addr:$ptr, GR32:$val))]>;
Andrew Lenharthaf02d592008-06-14 05:48:15 +00003081def ATOMNAND32 : I<0, Pseudo,(outs GR32:$dst),(ins i32mem:$ptr, GR32:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003082 "#ATOMNAND32 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003083 [(set GR32:$dst, (atomic_load_nand_32 addr:$ptr, GR32:$val))]>;
Dan Gohman8aeb61f2008-05-12 20:22:45 +00003084def ATOMMIN32: I<0, Pseudo, (outs GR32:$dst), (ins i32mem:$ptr, GR32:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003085 "#ATOMMIN32 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003086 [(set GR32:$dst, (atomic_load_min_32 addr:$ptr, GR32:$val))]>;
Dan Gohman8aeb61f2008-05-12 20:22:45 +00003087def ATOMMAX32: I<0, Pseudo, (outs GR32:$dst),(ins i32mem:$ptr, GR32:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003088 "#ATOMMAX32 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003089 [(set GR32:$dst, (atomic_load_max_32 addr:$ptr, GR32:$val))]>;
Dan Gohman8aeb61f2008-05-12 20:22:45 +00003090def ATOMUMIN32: I<0, Pseudo, (outs GR32:$dst),(ins i32mem:$ptr, GR32:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003091 "#ATOMUMIN32 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003092 [(set GR32:$dst, (atomic_load_umin_32 addr:$ptr, GR32:$val))]>;
Dan Gohman8aeb61f2008-05-12 20:22:45 +00003093def ATOMUMAX32: I<0, Pseudo, (outs GR32:$dst),(ins i32mem:$ptr, GR32:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003094 "#ATOMUMAX32 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003095 [(set GR32:$dst, (atomic_load_umax_32 addr:$ptr, GR32:$val))]>;
Dale Johannesend20e4452008-08-19 18:47:28 +00003096
3097def ATOMAND16 : I<0, Pseudo, (outs GR16:$dst),(ins i16mem:$ptr, GR16:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003098 "#ATOMAND16 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003099 [(set GR16:$dst, (atomic_load_and_16 addr:$ptr, GR16:$val))]>;
Dale Johannesend20e4452008-08-19 18:47:28 +00003100def ATOMOR16 : I<0, Pseudo, (outs GR16:$dst),(ins i16mem:$ptr, GR16:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003101 "#ATOMOR16 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003102 [(set GR16:$dst, (atomic_load_or_16 addr:$ptr, GR16:$val))]>;
Dale Johannesend20e4452008-08-19 18:47:28 +00003103def ATOMXOR16 : I<0, Pseudo,(outs GR16:$dst),(ins i16mem:$ptr, GR16:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003104 "#ATOMXOR16 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003105 [(set GR16:$dst, (atomic_load_xor_16 addr:$ptr, GR16:$val))]>;
Dale Johannesend20e4452008-08-19 18:47:28 +00003106def ATOMNAND16 : I<0, Pseudo,(outs GR16:$dst),(ins i16mem:$ptr, GR16:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003107 "#ATOMNAND16 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003108 [(set GR16:$dst, (atomic_load_nand_16 addr:$ptr, GR16:$val))]>;
Dale Johannesend20e4452008-08-19 18:47:28 +00003109def ATOMMIN16: I<0, Pseudo, (outs GR16:$dst), (ins i16mem:$ptr, GR16:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003110 "#ATOMMIN16 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003111 [(set GR16:$dst, (atomic_load_min_16 addr:$ptr, GR16:$val))]>;
Dale Johannesend20e4452008-08-19 18:47:28 +00003112def ATOMMAX16: I<0, Pseudo, (outs GR16:$dst),(ins i16mem:$ptr, GR16:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003113 "#ATOMMAX16 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003114 [(set GR16:$dst, (atomic_load_max_16 addr:$ptr, GR16:$val))]>;
Dale Johannesend20e4452008-08-19 18:47:28 +00003115def ATOMUMIN16: I<0, Pseudo, (outs GR16:$dst),(ins i16mem:$ptr, GR16:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003116 "#ATOMUMIN16 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003117 [(set GR16:$dst, (atomic_load_umin_16 addr:$ptr, GR16:$val))]>;
Dale Johannesend20e4452008-08-19 18:47:28 +00003118def ATOMUMAX16: I<0, Pseudo, (outs GR16:$dst),(ins i16mem:$ptr, GR16:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003119 "#ATOMUMAX16 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003120 [(set GR16:$dst, (atomic_load_umax_16 addr:$ptr, GR16:$val))]>;
Dale Johannesend20e4452008-08-19 18:47:28 +00003121
3122def ATOMAND8 : I<0, Pseudo, (outs GR8:$dst),(ins i8mem:$ptr, GR8:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003123 "#ATOMAND8 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003124 [(set GR8:$dst, (atomic_load_and_8 addr:$ptr, GR8:$val))]>;
Dale Johannesend20e4452008-08-19 18:47:28 +00003125def ATOMOR8 : I<0, Pseudo, (outs GR8:$dst),(ins i8mem:$ptr, GR8:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003126 "#ATOMOR8 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003127 [(set GR8:$dst, (atomic_load_or_8 addr:$ptr, GR8:$val))]>;
Dale Johannesend20e4452008-08-19 18:47:28 +00003128def ATOMXOR8 : I<0, Pseudo,(outs GR8:$dst),(ins i8mem:$ptr, GR8:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003129 "#ATOMXOR8 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003130 [(set GR8:$dst, (atomic_load_xor_8 addr:$ptr, GR8:$val))]>;
Dale Johannesend20e4452008-08-19 18:47:28 +00003131def ATOMNAND8 : I<0, Pseudo,(outs GR8:$dst),(ins i8mem:$ptr, GR8:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003132 "#ATOMNAND8 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003133 [(set GR8:$dst, (atomic_load_nand_8 addr:$ptr, GR8:$val))]>;
Mon P Wang078a62d2008-05-05 19:05:59 +00003134}
3135
Dale Johannesenf160d802008-10-02 18:53:47 +00003136let Constraints = "$val1 = $dst1, $val2 = $dst2",
3137 Defs = [EFLAGS, EAX, EBX, ECX, EDX],
3138 Uses = [EAX, EBX, ECX, EDX],
Dale Johannesen44eb5372008-10-03 19:41:08 +00003139 mayLoad = 1, mayStore = 1,
Dale Johannesenf160d802008-10-02 18:53:47 +00003140 usesCustomDAGSchedInserter = 1 in {
3141def ATOMAND6432 : I<0, Pseudo, (outs GR32:$dst1, GR32:$dst2),
3142 (ins i64mem:$ptr, GR32:$val1, GR32:$val2),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003143 "#ATOMAND6432 PSEUDO!", []>;
Dale Johannesenf160d802008-10-02 18:53:47 +00003144def ATOMOR6432 : I<0, Pseudo, (outs GR32:$dst1, GR32:$dst2),
3145 (ins i64mem:$ptr, GR32:$val1, GR32:$val2),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003146 "#ATOMOR6432 PSEUDO!", []>;
Dale Johannesenf160d802008-10-02 18:53:47 +00003147def ATOMXOR6432 : I<0, Pseudo, (outs GR32:$dst1, GR32:$dst2),
3148 (ins i64mem:$ptr, GR32:$val1, GR32:$val2),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003149 "#ATOMXOR6432 PSEUDO!", []>;
Dale Johannesenf160d802008-10-02 18:53:47 +00003150def ATOMNAND6432 : I<0, Pseudo, (outs GR32:$dst1, GR32:$dst2),
3151 (ins i64mem:$ptr, GR32:$val1, GR32:$val2),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003152 "#ATOMNAND6432 PSEUDO!", []>;
Dale Johannesenf160d802008-10-02 18:53:47 +00003153def ATOMADD6432 : I<0, Pseudo, (outs GR32:$dst1, GR32:$dst2),
3154 (ins i64mem:$ptr, GR32:$val1, GR32:$val2),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003155 "#ATOMADD6432 PSEUDO!", []>;
Dale Johannesenf160d802008-10-02 18:53:47 +00003156def ATOMSUB6432 : I<0, Pseudo, (outs GR32:$dst1, GR32:$dst2),
3157 (ins i64mem:$ptr, GR32:$val1, GR32:$val2),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003158 "#ATOMSUB6432 PSEUDO!", []>;
Dale Johannesen51c58ee2008-10-03 22:25:52 +00003159def ATOMSWAP6432 : I<0, Pseudo, (outs GR32:$dst1, GR32:$dst2),
3160 (ins i64mem:$ptr, GR32:$val1, GR32:$val2),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003161 "#ATOMSWAP6432 PSEUDO!", []>;
Dale Johannesenf160d802008-10-02 18:53:47 +00003162}
3163
Andrew Lenharthe44f3902008-02-21 06:45:13 +00003164//===----------------------------------------------------------------------===//
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003165// Non-Instruction Patterns
3166//===----------------------------------------------------------------------===//
3167
Bill Wendlingfef06052008-09-16 21:48:12 +00003168// ConstantPool GlobalAddress, ExternalSymbol, and JumpTable
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003169def : Pat<(i32 (X86Wrapper tconstpool :$dst)), (MOV32ri tconstpool :$dst)>;
3170def : Pat<(i32 (X86Wrapper tjumptable :$dst)), (MOV32ri tjumptable :$dst)>;
Nate Begemanb52948972008-04-12 00:47:57 +00003171def : Pat<(i32 (X86Wrapper tglobaltlsaddr:$dst)),(MOV32ri tglobaltlsaddr:$dst)>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003172def : Pat<(i32 (X86Wrapper tglobaladdr :$dst)), (MOV32ri tglobaladdr :$dst)>;
3173def : Pat<(i32 (X86Wrapper texternalsym:$dst)), (MOV32ri texternalsym:$dst)>;
3174
3175def : Pat<(add GR32:$src1, (X86Wrapper tconstpool:$src2)),
3176 (ADD32ri GR32:$src1, tconstpool:$src2)>;
3177def : Pat<(add GR32:$src1, (X86Wrapper tjumptable:$src2)),
3178 (ADD32ri GR32:$src1, tjumptable:$src2)>;
3179def : Pat<(add GR32:$src1, (X86Wrapper tglobaladdr :$src2)),
3180 (ADD32ri GR32:$src1, tglobaladdr:$src2)>;
3181def : Pat<(add GR32:$src1, (X86Wrapper texternalsym:$src2)),
3182 (ADD32ri GR32:$src1, texternalsym:$src2)>;
3183
3184def : Pat<(store (i32 (X86Wrapper tglobaladdr:$src)), addr:$dst),
3185 (MOV32mi addr:$dst, tglobaladdr:$src)>;
3186def : Pat<(store (i32 (X86Wrapper texternalsym:$src)), addr:$dst),
3187 (MOV32mi addr:$dst, texternalsym:$src)>;
3188
3189// Calls
Arnold Schwaighofere2d6bbb2007-10-11 19:40:01 +00003190// tailcall stuff
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003191def : Pat<(X86tailcall GR32:$dst),
Arnold Schwaighofere2d6bbb2007-10-11 19:40:01 +00003192 (TAILCALL)>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003193
3194def : Pat<(X86tailcall (i32 tglobaladdr:$dst)),
Arnold Schwaighofere2d6bbb2007-10-11 19:40:01 +00003195 (TAILCALL)>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003196def : Pat<(X86tailcall (i32 texternalsym:$dst)),
Arnold Schwaighofere2d6bbb2007-10-11 19:40:01 +00003197 (TAILCALL)>;
3198
3199def : Pat<(X86tcret GR32:$dst, imm:$off),
3200 (TCRETURNri GR32:$dst, imm:$off)>;
3201
3202def : Pat<(X86tcret (i32 tglobaladdr:$dst), imm:$off),
3203 (TCRETURNdi texternalsym:$dst, imm:$off)>;
3204
3205def : Pat<(X86tcret (i32 texternalsym:$dst), imm:$off),
3206 (TCRETURNdi texternalsym:$dst, imm:$off)>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003207
3208def : Pat<(X86call (i32 tglobaladdr:$dst)),
3209 (CALLpcrel32 tglobaladdr:$dst)>;
3210def : Pat<(X86call (i32 texternalsym:$dst)),
3211 (CALLpcrel32 texternalsym:$dst)>;
3212
3213// X86 specific add which produces a flag.
3214def : Pat<(addc GR32:$src1, GR32:$src2),
3215 (ADD32rr GR32:$src1, GR32:$src2)>;
3216def : Pat<(addc GR32:$src1, (load addr:$src2)),
3217 (ADD32rm GR32:$src1, addr:$src2)>;
3218def : Pat<(addc GR32:$src1, imm:$src2),
3219 (ADD32ri GR32:$src1, imm:$src2)>;
3220def : Pat<(addc GR32:$src1, i32immSExt8:$src2),
3221 (ADD32ri8 GR32:$src1, i32immSExt8:$src2)>;
3222
3223def : Pat<(subc GR32:$src1, GR32:$src2),
3224 (SUB32rr GR32:$src1, GR32:$src2)>;
3225def : Pat<(subc GR32:$src1, (load addr:$src2)),
3226 (SUB32rm GR32:$src1, addr:$src2)>;
3227def : Pat<(subc GR32:$src1, imm:$src2),
3228 (SUB32ri GR32:$src1, imm:$src2)>;
3229def : Pat<(subc GR32:$src1, i32immSExt8:$src2),
3230 (SUB32ri8 GR32:$src1, i32immSExt8:$src2)>;
3231
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003232// Comparisons.
3233
3234// TEST R,R is smaller than CMP R,0
Evan Cheng621216e2007-09-29 00:00:36 +00003235def : Pat<(parallel (X86cmp GR8:$src1, 0), (implicit EFLAGS)),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003236 (TEST8rr GR8:$src1, GR8:$src1)>;
Evan Cheng621216e2007-09-29 00:00:36 +00003237def : Pat<(parallel (X86cmp GR16:$src1, 0), (implicit EFLAGS)),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003238 (TEST16rr GR16:$src1, GR16:$src1)>;
Evan Cheng621216e2007-09-29 00:00:36 +00003239def : Pat<(parallel (X86cmp GR32:$src1, 0), (implicit EFLAGS)),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003240 (TEST32rr GR32:$src1, GR32:$src1)>;
3241
Dan Gohman0a3c5222009-01-07 01:00:24 +00003242// Conditional moves with folded loads with operands swapped and conditions
3243// inverted.
3244def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_B, EFLAGS),
3245 (CMOVAE16rm GR16:$src2, addr:$src1)>;
3246def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_B, EFLAGS),
3247 (CMOVAE32rm GR32:$src2, addr:$src1)>;
3248def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_AE, EFLAGS),
3249 (CMOVB16rm GR16:$src2, addr:$src1)>;
3250def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_AE, EFLAGS),
3251 (CMOVB32rm GR32:$src2, addr:$src1)>;
3252def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_E, EFLAGS),
3253 (CMOVNE16rm GR16:$src2, addr:$src1)>;
3254def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_E, EFLAGS),
3255 (CMOVNE32rm GR32:$src2, addr:$src1)>;
3256def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_NE, EFLAGS),
3257 (CMOVE16rm GR16:$src2, addr:$src1)>;
3258def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_NE, EFLAGS),
3259 (CMOVE32rm GR32:$src2, addr:$src1)>;
3260def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_BE, EFLAGS),
3261 (CMOVA16rm GR16:$src2, addr:$src1)>;
3262def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_BE, EFLAGS),
3263 (CMOVA32rm GR32:$src2, addr:$src1)>;
3264def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_A, EFLAGS),
3265 (CMOVBE16rm GR16:$src2, addr:$src1)>;
3266def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_A, EFLAGS),
3267 (CMOVBE32rm GR32:$src2, addr:$src1)>;
3268def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_L, EFLAGS),
3269 (CMOVGE16rm GR16:$src2, addr:$src1)>;
3270def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_L, EFLAGS),
3271 (CMOVGE32rm GR32:$src2, addr:$src1)>;
3272def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_GE, EFLAGS),
3273 (CMOVL16rm GR16:$src2, addr:$src1)>;
3274def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_GE, EFLAGS),
3275 (CMOVL32rm GR32:$src2, addr:$src1)>;
3276def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_LE, EFLAGS),
3277 (CMOVG16rm GR16:$src2, addr:$src1)>;
3278def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_LE, EFLAGS),
3279 (CMOVG32rm GR32:$src2, addr:$src1)>;
3280def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_G, EFLAGS),
3281 (CMOVLE16rm GR16:$src2, addr:$src1)>;
3282def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_G, EFLAGS),
3283 (CMOVLE32rm GR32:$src2, addr:$src1)>;
3284def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_P, EFLAGS),
3285 (CMOVNP16rm GR16:$src2, addr:$src1)>;
3286def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_P, EFLAGS),
3287 (CMOVNP32rm GR32:$src2, addr:$src1)>;
3288def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_NP, EFLAGS),
3289 (CMOVP16rm GR16:$src2, addr:$src1)>;
3290def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_NP, EFLAGS),
3291 (CMOVP32rm GR32:$src2, addr:$src1)>;
3292def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_S, EFLAGS),
3293 (CMOVNS16rm GR16:$src2, addr:$src1)>;
3294def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_S, EFLAGS),
3295 (CMOVNS32rm GR32:$src2, addr:$src1)>;
3296def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_NS, EFLAGS),
3297 (CMOVS16rm GR16:$src2, addr:$src1)>;
3298def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_NS, EFLAGS),
3299 (CMOVS32rm GR32:$src2, addr:$src1)>;
3300def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_O, EFLAGS),
3301 (CMOVNO16rm GR16:$src2, addr:$src1)>;
3302def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_O, EFLAGS),
3303 (CMOVNO32rm GR32:$src2, addr:$src1)>;
3304def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_NO, EFLAGS),
3305 (CMOVO16rm GR16:$src2, addr:$src1)>;
3306def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_NO, EFLAGS),
3307 (CMOVO32rm GR32:$src2, addr:$src1)>;
3308
Duncan Sands082524c2008-01-23 20:39:46 +00003309// zextload bool -> zextload byte
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003310def : Pat<(zextloadi8i1 addr:$src), (MOV8rm addr:$src)>;
3311def : Pat<(zextloadi16i1 addr:$src), (MOVZX16rm8 addr:$src)>;
3312def : Pat<(zextloadi32i1 addr:$src), (MOVZX32rm8 addr:$src)>;
3313
3314// extload bool -> extload byte
3315def : Pat<(extloadi8i1 addr:$src), (MOV8rm addr:$src)>;
Bill Wendlingce1c5c12008-08-22 20:51:05 +00003316def : Pat<(extloadi16i1 addr:$src), (MOVZX16rm8 addr:$src)>,
3317 Requires<[In32BitMode]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003318def : Pat<(extloadi32i1 addr:$src), (MOVZX32rm8 addr:$src)>;
Bill Wendlingce1c5c12008-08-22 20:51:05 +00003319def : Pat<(extloadi16i8 addr:$src), (MOVZX16rm8 addr:$src)>,
3320 Requires<[In32BitMode]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003321def : Pat<(extloadi32i8 addr:$src), (MOVZX32rm8 addr:$src)>;
3322def : Pat<(extloadi32i16 addr:$src), (MOVZX32rm16 addr:$src)>;
3323
Dan Gohmandd612bb2008-08-20 21:27:32 +00003324// anyext
Bill Wendlingce1c5c12008-08-22 20:51:05 +00003325def : Pat<(i16 (anyext GR8 :$src)), (MOVZX16rr8 GR8 :$src)>,
3326 Requires<[In32BitMode]>;
3327def : Pat<(i32 (anyext GR8 :$src)), (MOVZX32rr8 GR8 :$src)>,
3328 Requires<[In32BitMode]>;
Dan Gohmandd612bb2008-08-20 21:27:32 +00003329def : Pat<(i32 (anyext GR16:$src)),
3330 (INSERT_SUBREG (i32 (IMPLICIT_DEF)), GR16:$src, x86_subreg_16bit)>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003331
Evan Chengf2abee72007-12-13 00:43:27 +00003332// (and (i32 load), 255) -> (zextload i8)
Evan Cheng1e5e5452008-09-29 17:26:18 +00003333def : Pat<(i32 (and (nvloadi32 addr:$src), (i32 255))),
3334 (MOVZX32rm8 addr:$src)>;
3335def : Pat<(i32 (and (nvloadi32 addr:$src), (i32 65535))),
3336 (MOVZX32rm16 addr:$src)>;
Evan Chengf2abee72007-12-13 00:43:27 +00003337
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003338//===----------------------------------------------------------------------===//
3339// Some peepholes
3340//===----------------------------------------------------------------------===//
3341
Dan Gohman5a5e6e92008-10-17 01:33:43 +00003342// Odd encoding trick: -128 fits into an 8-bit immediate field while
3343// +128 doesn't, so in this special case use a sub instead of an add.
3344def : Pat<(add GR16:$src1, 128),
3345 (SUB16ri8 GR16:$src1, -128)>;
3346def : Pat<(store (add (loadi16 addr:$dst), 128), addr:$dst),
3347 (SUB16mi8 addr:$dst, -128)>;
3348def : Pat<(add GR32:$src1, 128),
3349 (SUB32ri8 GR32:$src1, -128)>;
3350def : Pat<(store (add (loadi32 addr:$dst), 128), addr:$dst),
3351 (SUB32mi8 addr:$dst, -128)>;
3352
Dan Gohman9203ab42008-07-30 18:09:17 +00003353// r & (2^16-1) ==> movz
3354def : Pat<(and GR32:$src1, 0xffff),
Dan Gohman744d4622009-04-13 16:09:41 +00003355 (MOVZX32rr16 (EXTRACT_SUBREG GR32:$src1, x86_subreg_16bit))>;
Dan Gohman5beb1ff2008-08-06 18:27:21 +00003356// r & (2^8-1) ==> movz
3357def : Pat<(and GR32:$src1, 0xff),
Dan Gohman4c10fc72009-04-13 21:06:25 +00003358 (MOVZX32rr8 (EXTRACT_SUBREG (COPY_TO_REGCLASS GR32:$src1, GR32_),
Dan Gohman744d4622009-04-13 16:09:41 +00003359 x86_subreg_8bit))>,
Dan Gohman5beb1ff2008-08-06 18:27:21 +00003360 Requires<[In32BitMode]>;
3361// r & (2^8-1) ==> movz
3362def : Pat<(and GR16:$src1, 0xff),
Dan Gohman4c10fc72009-04-13 21:06:25 +00003363 (MOVZX16rr8 (EXTRACT_SUBREG (COPY_TO_REGCLASS GR16:$src1, GR16_),
Dan Gohman744d4622009-04-13 16:09:41 +00003364 x86_subreg_8bit))>,
Dan Gohmandd612bb2008-08-20 21:27:32 +00003365 Requires<[In32BitMode]>;
3366
3367// sext_inreg patterns
3368def : Pat<(sext_inreg GR32:$src, i16),
Dan Gohman744d4622009-04-13 16:09:41 +00003369 (MOVSX32rr16 (EXTRACT_SUBREG GR32:$src, x86_subreg_16bit))>;
Dan Gohmandd612bb2008-08-20 21:27:32 +00003370def : Pat<(sext_inreg GR32:$src, i8),
Dan Gohman4c10fc72009-04-13 21:06:25 +00003371 (MOVSX32rr8 (EXTRACT_SUBREG (COPY_TO_REGCLASS GR32:$src, GR32_),
Dan Gohman744d4622009-04-13 16:09:41 +00003372 x86_subreg_8bit))>,
Dan Gohmandd612bb2008-08-20 21:27:32 +00003373 Requires<[In32BitMode]>;
3374def : Pat<(sext_inreg GR16:$src, i8),
Dan Gohman4c10fc72009-04-13 21:06:25 +00003375 (MOVSX16rr8 (EXTRACT_SUBREG (COPY_TO_REGCLASS GR16:$src, GR16_),
Dan Gohman744d4622009-04-13 16:09:41 +00003376 x86_subreg_8bit))>,
Dan Gohmandd612bb2008-08-20 21:27:32 +00003377 Requires<[In32BitMode]>;
3378
3379// trunc patterns
3380def : Pat<(i16 (trunc GR32:$src)),
Dan Gohman744d4622009-04-13 16:09:41 +00003381 (EXTRACT_SUBREG GR32:$src, x86_subreg_16bit)>;
Dan Gohmandd612bb2008-08-20 21:27:32 +00003382def : Pat<(i8 (trunc GR32:$src)),
Dan Gohman4c10fc72009-04-13 21:06:25 +00003383 (EXTRACT_SUBREG (COPY_TO_REGCLASS GR32:$src, GR32_),
Dan Gohman744d4622009-04-13 16:09:41 +00003384 x86_subreg_8bit)>,
Dan Gohmandd612bb2008-08-20 21:27:32 +00003385 Requires<[In32BitMode]>;
3386def : Pat<(i8 (trunc GR16:$src)),
Dan Gohman4c10fc72009-04-13 21:06:25 +00003387 (EXTRACT_SUBREG (COPY_TO_REGCLASS GR16:$src, GR16_),
Dan Gohman744d4622009-04-13 16:09:41 +00003388 x86_subreg_8bit)>,
3389 Requires<[In32BitMode]>;
3390
3391// h-register tricks
3392def : Pat<(i8 (trunc (srl_su GR16:$src, (i8 8)))),
Dan Gohman4c10fc72009-04-13 21:06:25 +00003393 (EXTRACT_SUBREG (COPY_TO_REGCLASS GR16:$src, GR16_),
Dan Gohman744d4622009-04-13 16:09:41 +00003394 x86_subreg_8bit_hi)>,
3395 Requires<[In32BitMode]>;
3396def : Pat<(i8 (trunc (srl_su GR32:$src, (i8 8)))),
Dan Gohman4c10fc72009-04-13 21:06:25 +00003397 (EXTRACT_SUBREG (COPY_TO_REGCLASS GR32:$src, GR32_),
Dan Gohman744d4622009-04-13 16:09:41 +00003398 x86_subreg_8bit_hi)>,
3399 Requires<[In32BitMode]>;
3400def : Pat<(srl_su GR16:$src, (i8 8)),
3401 (EXTRACT_SUBREG
3402 (MOVZX32rr8
Dan Gohman4c10fc72009-04-13 21:06:25 +00003403 (EXTRACT_SUBREG (COPY_TO_REGCLASS GR16:$src, GR16_),
Dan Gohman744d4622009-04-13 16:09:41 +00003404 x86_subreg_8bit_hi)),
3405 x86_subreg_16bit)>,
3406 Requires<[In32BitMode]>;
3407def : Pat<(and (srl_su GR32:$src, (i8 8)), (i32 255)),
Dan Gohman4c10fc72009-04-13 21:06:25 +00003408 (MOVZX32rr8 (EXTRACT_SUBREG (COPY_TO_REGCLASS GR32:$src, GR32_),
Dan Gohman744d4622009-04-13 16:09:41 +00003409 x86_subreg_8bit_hi))>,
Dan Gohman5beb1ff2008-08-06 18:27:21 +00003410 Requires<[In32BitMode]>;
Dan Gohman9203ab42008-07-30 18:09:17 +00003411
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003412// (shl x, 1) ==> (add x, x)
3413def : Pat<(shl GR8 :$src1, (i8 1)), (ADD8rr GR8 :$src1, GR8 :$src1)>;
3414def : Pat<(shl GR16:$src1, (i8 1)), (ADD16rr GR16:$src1, GR16:$src1)>;
3415def : Pat<(shl GR32:$src1, (i8 1)), (ADD32rr GR32:$src1, GR32:$src1)>;
3416
Evan Cheng76a64c72008-08-30 02:03:58 +00003417// (shl x (and y, 31)) ==> (shl x, y)
3418def : Pat<(shl GR8:$src1, (and CL:$amt, 31)),
3419 (SHL8rCL GR8:$src1)>;
3420def : Pat<(shl GR16:$src1, (and CL:$amt, 31)),
3421 (SHL16rCL GR16:$src1)>;
3422def : Pat<(shl GR32:$src1, (and CL:$amt, 31)),
3423 (SHL32rCL GR32:$src1)>;
3424def : Pat<(store (shl (loadi8 addr:$dst), (and CL:$amt, 31)), addr:$dst),
3425 (SHL8mCL addr:$dst)>;
3426def : Pat<(store (shl (loadi16 addr:$dst), (and CL:$amt, 31)), addr:$dst),
3427 (SHL16mCL addr:$dst)>;
3428def : Pat<(store (shl (loadi32 addr:$dst), (and CL:$amt, 31)), addr:$dst),
3429 (SHL32mCL addr:$dst)>;
3430
3431def : Pat<(srl GR8:$src1, (and CL:$amt, 31)),
3432 (SHR8rCL GR8:$src1)>;
3433def : Pat<(srl GR16:$src1, (and CL:$amt, 31)),
3434 (SHR16rCL GR16:$src1)>;
3435def : Pat<(srl GR32:$src1, (and CL:$amt, 31)),
3436 (SHR32rCL GR32:$src1)>;
3437def : Pat<(store (srl (loadi8 addr:$dst), (and CL:$amt, 31)), addr:$dst),
3438 (SHR8mCL addr:$dst)>;
3439def : Pat<(store (srl (loadi16 addr:$dst), (and CL:$amt, 31)), addr:$dst),
3440 (SHR16mCL addr:$dst)>;
3441def : Pat<(store (srl (loadi32 addr:$dst), (and CL:$amt, 31)), addr:$dst),
3442 (SHR32mCL addr:$dst)>;
3443
3444def : Pat<(sra GR8:$src1, (and CL:$amt, 31)),
3445 (SAR8rCL GR8:$src1)>;
3446def : Pat<(sra GR16:$src1, (and CL:$amt, 31)),
3447 (SAR16rCL GR16:$src1)>;
3448def : Pat<(sra GR32:$src1, (and CL:$amt, 31)),
3449 (SAR32rCL GR32:$src1)>;
3450def : Pat<(store (sra (loadi8 addr:$dst), (and CL:$amt, 31)), addr:$dst),
3451 (SAR8mCL addr:$dst)>;
3452def : Pat<(store (sra (loadi16 addr:$dst), (and CL:$amt, 31)), addr:$dst),
3453 (SAR16mCL addr:$dst)>;
3454def : Pat<(store (sra (loadi32 addr:$dst), (and CL:$amt, 31)), addr:$dst),
3455 (SAR32mCL addr:$dst)>;
3456
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003457// (or (x >> c) | (y << (32 - c))) ==> (shrd32 x, y, c)
3458def : Pat<(or (srl GR32:$src1, CL:$amt),
3459 (shl GR32:$src2, (sub 32, CL:$amt))),
3460 (SHRD32rrCL GR32:$src1, GR32:$src2)>;
3461
3462def : Pat<(store (or (srl (loadi32 addr:$dst), CL:$amt),
3463 (shl GR32:$src2, (sub 32, CL:$amt))), addr:$dst),
3464 (SHRD32mrCL addr:$dst, GR32:$src2)>;
3465
Dan Gohman921581d2008-10-17 01:23:35 +00003466def : Pat<(or (srl GR32:$src1, (i8 (trunc ECX:$amt))),
3467 (shl GR32:$src2, (i8 (trunc (sub 32, ECX:$amt))))),
3468 (SHRD32rrCL GR32:$src1, GR32:$src2)>;
3469
3470def : Pat<(store (or (srl (loadi32 addr:$dst), (i8 (trunc ECX:$amt))),
3471 (shl GR32:$src2, (i8 (trunc (sub 32, ECX:$amt))))),
3472 addr:$dst),
3473 (SHRD32mrCL addr:$dst, GR32:$src2)>;
3474
3475def : Pat<(shrd GR32:$src1, (i8 imm:$amt1), GR32:$src2, (i8 imm:$amt2)),
3476 (SHRD32rri8 GR32:$src1, GR32:$src2, (i8 imm:$amt1))>;
3477
3478def : Pat<(store (shrd (loadi32 addr:$dst), (i8 imm:$amt1),
3479 GR32:$src2, (i8 imm:$amt2)), addr:$dst),
3480 (SHRD32mri8 addr:$dst, GR32:$src2, (i8 imm:$amt1))>;
3481
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003482// (or (x << c) | (y >> (32 - c))) ==> (shld32 x, y, c)
3483def : Pat<(or (shl GR32:$src1, CL:$amt),
3484 (srl GR32:$src2, (sub 32, CL:$amt))),
3485 (SHLD32rrCL GR32:$src1, GR32:$src2)>;
3486
3487def : Pat<(store (or (shl (loadi32 addr:$dst), CL:$amt),
3488 (srl GR32:$src2, (sub 32, CL:$amt))), addr:$dst),
3489 (SHLD32mrCL addr:$dst, GR32:$src2)>;
3490
Dan Gohman921581d2008-10-17 01:23:35 +00003491def : Pat<(or (shl GR32:$src1, (i8 (trunc ECX:$amt))),
3492 (srl GR32:$src2, (i8 (trunc (sub 32, ECX:$amt))))),
3493 (SHLD32rrCL GR32:$src1, GR32:$src2)>;
3494
3495def : Pat<(store (or (shl (loadi32 addr:$dst), (i8 (trunc ECX:$amt))),
3496 (srl GR32:$src2, (i8 (trunc (sub 32, ECX:$amt))))),
3497 addr:$dst),
3498 (SHLD32mrCL addr:$dst, GR32:$src2)>;
3499
3500def : Pat<(shld GR32:$src1, (i8 imm:$amt1), GR32:$src2, (i8 imm:$amt2)),
3501 (SHLD32rri8 GR32:$src1, GR32:$src2, (i8 imm:$amt1))>;
3502
3503def : Pat<(store (shld (loadi32 addr:$dst), (i8 imm:$amt1),
3504 GR32:$src2, (i8 imm:$amt2)), addr:$dst),
3505 (SHLD32mri8 addr:$dst, GR32:$src2, (i8 imm:$amt1))>;
3506
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003507// (or (x >> c) | (y << (16 - c))) ==> (shrd16 x, y, c)
3508def : Pat<(or (srl GR16:$src1, CL:$amt),
3509 (shl GR16:$src2, (sub 16, CL:$amt))),
3510 (SHRD16rrCL GR16:$src1, GR16:$src2)>;
3511
3512def : Pat<(store (or (srl (loadi16 addr:$dst), CL:$amt),
3513 (shl GR16:$src2, (sub 16, CL:$amt))), addr:$dst),
3514 (SHRD16mrCL addr:$dst, GR16:$src2)>;
3515
Dan Gohman921581d2008-10-17 01:23:35 +00003516def : Pat<(or (srl GR16:$src1, (i8 (trunc CX:$amt))),
3517 (shl GR16:$src2, (i8 (trunc (sub 16, CX:$amt))))),
3518 (SHRD16rrCL GR16:$src1, GR16:$src2)>;
3519
3520def : Pat<(store (or (srl (loadi16 addr:$dst), (i8 (trunc CX:$amt))),
3521 (shl GR16:$src2, (i8 (trunc (sub 16, CX:$amt))))),
3522 addr:$dst),
3523 (SHRD16mrCL addr:$dst, GR16:$src2)>;
3524
3525def : Pat<(shrd GR16:$src1, (i8 imm:$amt1), GR16:$src2, (i8 imm:$amt2)),
3526 (SHRD16rri8 GR16:$src1, GR16:$src2, (i8 imm:$amt1))>;
3527
3528def : Pat<(store (shrd (loadi16 addr:$dst), (i8 imm:$amt1),
3529 GR16:$src2, (i8 imm:$amt2)), addr:$dst),
3530 (SHRD16mri8 addr:$dst, GR16:$src2, (i8 imm:$amt1))>;
3531
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003532// (or (x << c) | (y >> (16 - c))) ==> (shld16 x, y, c)
3533def : Pat<(or (shl GR16:$src1, CL:$amt),
3534 (srl GR16:$src2, (sub 16, CL:$amt))),
3535 (SHLD16rrCL GR16:$src1, GR16:$src2)>;
3536
3537def : Pat<(store (or (shl (loadi16 addr:$dst), CL:$amt),
3538 (srl GR16:$src2, (sub 16, CL:$amt))), addr:$dst),
3539 (SHLD16mrCL addr:$dst, GR16:$src2)>;
3540
Dan Gohman921581d2008-10-17 01:23:35 +00003541def : Pat<(or (shl GR16:$src1, (i8 (trunc CX:$amt))),
3542 (srl GR16:$src2, (i8 (trunc (sub 16, CX:$amt))))),
3543 (SHLD16rrCL GR16:$src1, GR16:$src2)>;
3544
3545def : Pat<(store (or (shl (loadi16 addr:$dst), (i8 (trunc CX:$amt))),
3546 (srl GR16:$src2, (i8 (trunc (sub 16, CX:$amt))))),
3547 addr:$dst),
3548 (SHLD16mrCL addr:$dst, GR16:$src2)>;
3549
3550def : Pat<(shld GR16:$src1, (i8 imm:$amt1), GR16:$src2, (i8 imm:$amt2)),
3551 (SHLD16rri8 GR16:$src1, GR16:$src2, (i8 imm:$amt1))>;
3552
3553def : Pat<(store (shld (loadi16 addr:$dst), (i8 imm:$amt1),
3554 GR16:$src2, (i8 imm:$amt2)), addr:$dst),
3555 (SHLD16mri8 addr:$dst, GR16:$src2, (i8 imm:$amt1))>;
3556
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003557//===----------------------------------------------------------------------===//
Dan Gohman99a12192009-03-04 19:44:21 +00003558// EFLAGS-defining Patterns
Bill Wendlingf5399032008-12-12 21:15:41 +00003559//===----------------------------------------------------------------------===//
3560
Dan Gohman99a12192009-03-04 19:44:21 +00003561// Register-Register Addition with EFLAGS result
3562def : Pat<(parallel (X86add_flag GR8:$src1, GR8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003563 (implicit EFLAGS)),
3564 (ADD8rr GR8:$src1, GR8:$src2)>;
3565
Dan Gohman99a12192009-03-04 19:44:21 +00003566// Register-Register Addition with EFLAGS result
3567def : Pat<(parallel (X86add_flag GR16:$src1, GR16:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003568 (implicit EFLAGS)),
3569 (ADD16rr GR16:$src1, GR16:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003570def : Pat<(parallel (X86add_flag GR32:$src1, GR32:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003571 (implicit EFLAGS)),
3572 (ADD32rr GR32:$src1, GR32:$src2)>;
3573
Dan Gohman99a12192009-03-04 19:44:21 +00003574// Register-Memory Addition with EFLAGS result
3575def : Pat<(parallel (X86add_flag GR8:$src1, (loadi8 addr:$src2)),
Bill Wendlingf5399032008-12-12 21:15:41 +00003576 (implicit EFLAGS)),
3577 (ADD8rm GR8:$src1, addr:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003578def : Pat<(parallel (X86add_flag GR16:$src1, (loadi16 addr:$src2)),
Bill Wendlingf5399032008-12-12 21:15:41 +00003579 (implicit EFLAGS)),
3580 (ADD16rm GR16:$src1, addr:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003581def : Pat<(parallel (X86add_flag GR32:$src1, (loadi32 addr:$src2)),
Bill Wendlingf5399032008-12-12 21:15:41 +00003582 (implicit EFLAGS)),
3583 (ADD32rm GR32:$src1, addr:$src2)>;
3584
Dan Gohman99a12192009-03-04 19:44:21 +00003585// Register-Integer Addition with EFLAGS result
3586def : Pat<(parallel (X86add_flag GR8:$src1, imm:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003587 (implicit EFLAGS)),
3588 (ADD8ri GR8:$src1, imm:$src2)>;
3589
Dan Gohman99a12192009-03-04 19:44:21 +00003590// Register-Integer Addition with EFLAGS result
3591def : Pat<(parallel (X86add_flag GR16:$src1, imm:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003592 (implicit EFLAGS)),
3593 (ADD16ri GR16:$src1, imm:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003594def : Pat<(parallel (X86add_flag GR32:$src1, imm:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003595 (implicit EFLAGS)),
3596 (ADD32ri GR32:$src1, imm:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003597def : Pat<(parallel (X86add_flag GR16:$src1, i16immSExt8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003598 (implicit EFLAGS)),
3599 (ADD16ri8 GR16:$src1, i16immSExt8:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003600def : Pat<(parallel (X86add_flag GR32:$src1, i32immSExt8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003601 (implicit EFLAGS)),
3602 (ADD32ri8 GR32:$src1, i32immSExt8:$src2)>;
3603
Dan Gohman99a12192009-03-04 19:44:21 +00003604// Memory-Register Addition with EFLAGS result
3605def : Pat<(parallel (store (X86add_flag (loadi8 addr:$dst), GR8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003606 addr:$dst),
3607 (implicit EFLAGS)),
3608 (ADD8mr addr:$dst, GR8:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003609def : Pat<(parallel (store (X86add_flag (loadi16 addr:$dst), GR16:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003610 addr:$dst),
3611 (implicit EFLAGS)),
3612 (ADD16mr addr:$dst, GR16:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003613def : Pat<(parallel (store (X86add_flag (loadi32 addr:$dst), GR32:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003614 addr:$dst),
3615 (implicit EFLAGS)),
3616 (ADD32mr addr:$dst, GR32:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003617def : Pat<(parallel (store (X86add_flag (loadi8 addr:$dst), imm:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003618 addr:$dst),
3619 (implicit EFLAGS)),
3620 (ADD8mi addr:$dst, imm:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003621def : Pat<(parallel (store (X86add_flag (loadi16 addr:$dst), imm:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003622 addr:$dst),
3623 (implicit EFLAGS)),
3624 (ADD16mi addr:$dst, imm:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003625def : Pat<(parallel (store (X86add_flag (loadi32 addr:$dst), imm:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003626 addr:$dst),
3627 (implicit EFLAGS)),
3628 (ADD32mi addr:$dst, imm:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003629def : Pat<(parallel (store (X86add_flag (loadi16 addr:$dst), i16immSExt8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003630 addr:$dst),
3631 (implicit EFLAGS)),
3632 (ADD16mi8 addr:$dst, i16immSExt8:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003633def : Pat<(parallel (store (X86add_flag (loadi32 addr:$dst), i32immSExt8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003634 addr:$dst),
3635 (implicit EFLAGS)),
3636 (ADD32mi8 addr:$dst, i32immSExt8:$src2)>;
3637
Dan Gohman99a12192009-03-04 19:44:21 +00003638// Register-Register Subtraction with EFLAGS result
3639def : Pat<(parallel (X86sub_flag GR8:$src1, GR8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003640 (implicit EFLAGS)),
3641 (SUB8rr GR8:$src1, GR8:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003642def : Pat<(parallel (X86sub_flag GR16:$src1, GR16:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003643 (implicit EFLAGS)),
3644 (SUB16rr GR16:$src1, GR16:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003645def : Pat<(parallel (X86sub_flag GR32:$src1, GR32:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003646 (implicit EFLAGS)),
3647 (SUB32rr GR32:$src1, GR32:$src2)>;
3648
Dan Gohman99a12192009-03-04 19:44:21 +00003649// Register-Memory Subtraction with EFLAGS result
3650def : Pat<(parallel (X86sub_flag GR8:$src1, (loadi8 addr:$src2)),
Bill Wendlingf5399032008-12-12 21:15:41 +00003651 (implicit EFLAGS)),
3652 (SUB8rm GR8:$src1, addr:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003653def : Pat<(parallel (X86sub_flag GR16:$src1, (loadi16 addr:$src2)),
Bill Wendlingf5399032008-12-12 21:15:41 +00003654 (implicit EFLAGS)),
3655 (SUB16rm GR16:$src1, addr:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003656def : Pat<(parallel (X86sub_flag GR32:$src1, (loadi32 addr:$src2)),
Bill Wendlingf5399032008-12-12 21:15:41 +00003657 (implicit EFLAGS)),
3658 (SUB32rm GR32:$src1, addr:$src2)>;
3659
Dan Gohman99a12192009-03-04 19:44:21 +00003660// Register-Integer Subtraction with EFLAGS result
3661def : Pat<(parallel (X86sub_flag GR8:$src1, imm:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003662 (implicit EFLAGS)),
3663 (SUB8ri GR8:$src1, imm:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003664def : Pat<(parallel (X86sub_flag GR16:$src1, imm:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003665 (implicit EFLAGS)),
3666 (SUB16ri GR16:$src1, imm:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003667def : Pat<(parallel (X86sub_flag GR32:$src1, imm:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003668 (implicit EFLAGS)),
3669 (SUB32ri GR32:$src1, imm:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003670def : Pat<(parallel (X86sub_flag GR16:$src1, i16immSExt8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003671 (implicit EFLAGS)),
3672 (SUB16ri8 GR16:$src1, i16immSExt8:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003673def : Pat<(parallel (X86sub_flag GR32:$src1, i32immSExt8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003674 (implicit EFLAGS)),
3675 (SUB32ri8 GR32:$src1, i32immSExt8:$src2)>;
3676
Dan Gohman99a12192009-03-04 19:44:21 +00003677// Memory-Register Subtraction with EFLAGS result
3678def : Pat<(parallel (store (X86sub_flag (loadi8 addr:$dst), GR8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003679 addr:$dst),
3680 (implicit EFLAGS)),
3681 (SUB8mr addr:$dst, GR8:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003682def : Pat<(parallel (store (X86sub_flag (loadi16 addr:$dst), GR16:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003683 addr:$dst),
3684 (implicit EFLAGS)),
3685 (SUB16mr addr:$dst, GR16:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003686def : Pat<(parallel (store (X86sub_flag (loadi32 addr:$dst), GR32:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003687 addr:$dst),
3688 (implicit EFLAGS)),
3689 (SUB32mr addr:$dst, GR32:$src2)>;
3690
Dan Gohman99a12192009-03-04 19:44:21 +00003691// Memory-Integer Subtraction with EFLAGS result
3692def : Pat<(parallel (store (X86sub_flag (loadi8 addr:$dst), imm:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003693 addr:$dst),
3694 (implicit EFLAGS)),
3695 (SUB8mi addr:$dst, imm:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003696def : Pat<(parallel (store (X86sub_flag (loadi16 addr:$dst), imm:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003697 addr:$dst),
3698 (implicit EFLAGS)),
3699 (SUB16mi addr:$dst, imm:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003700def : Pat<(parallel (store (X86sub_flag (loadi32 addr:$dst), imm:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003701 addr:$dst),
3702 (implicit EFLAGS)),
3703 (SUB32mi addr:$dst, imm:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003704def : Pat<(parallel (store (X86sub_flag (loadi16 addr:$dst), i16immSExt8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003705 addr:$dst),
3706 (implicit EFLAGS)),
3707 (SUB16mi8 addr:$dst, i16immSExt8:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003708def : Pat<(parallel (store (X86sub_flag (loadi32 addr:$dst), i32immSExt8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003709 addr:$dst),
3710 (implicit EFLAGS)),
3711 (SUB32mi8 addr:$dst, i32immSExt8:$src2)>;
3712
3713
Dan Gohman99a12192009-03-04 19:44:21 +00003714// Register-Register Signed Integer Multiply with EFLAGS result
3715def : Pat<(parallel (X86smul_flag GR16:$src1, GR16:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003716 (implicit EFLAGS)),
3717 (IMUL16rr GR16:$src1, GR16:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003718def : Pat<(parallel (X86smul_flag GR32:$src1, GR32:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003719 (implicit EFLAGS)),
3720 (IMUL32rr GR32:$src1, GR32:$src2)>;
3721
Dan Gohman99a12192009-03-04 19:44:21 +00003722// Register-Memory Signed Integer Multiply with EFLAGS result
3723def : Pat<(parallel (X86smul_flag GR16:$src1, (loadi16 addr:$src2)),
Bill Wendlingf5399032008-12-12 21:15:41 +00003724 (implicit EFLAGS)),
3725 (IMUL16rm GR16:$src1, addr:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003726def : Pat<(parallel (X86smul_flag GR32:$src1, (loadi32 addr:$src2)),
Bill Wendlingf5399032008-12-12 21:15:41 +00003727 (implicit EFLAGS)),
3728 (IMUL32rm GR32:$src1, addr:$src2)>;
3729
Dan Gohman99a12192009-03-04 19:44:21 +00003730// Register-Integer Signed Integer Multiply with EFLAGS result
3731def : Pat<(parallel (X86smul_flag GR16:$src1, imm:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003732 (implicit EFLAGS)),
3733 (IMUL16rri GR16:$src1, imm:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003734def : Pat<(parallel (X86smul_flag GR32:$src1, imm:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003735 (implicit EFLAGS)),
3736 (IMUL32rri GR32:$src1, imm:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003737def : Pat<(parallel (X86smul_flag GR16:$src1, i16immSExt8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003738 (implicit EFLAGS)),
3739 (IMUL16rri8 GR16:$src1, i16immSExt8:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003740def : Pat<(parallel (X86smul_flag GR32:$src1, i32immSExt8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003741 (implicit EFLAGS)),
3742 (IMUL32rri8 GR32:$src1, i32immSExt8:$src2)>;
3743
Dan Gohman99a12192009-03-04 19:44:21 +00003744// Memory-Integer Signed Integer Multiply with EFLAGS result
3745def : Pat<(parallel (X86smul_flag (loadi16 addr:$src1), imm:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003746 (implicit EFLAGS)),
3747 (IMUL16rmi addr:$src1, imm:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003748def : Pat<(parallel (X86smul_flag (loadi32 addr:$src1), imm:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003749 (implicit EFLAGS)),
3750 (IMUL32rmi addr:$src1, imm:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003751def : Pat<(parallel (X86smul_flag (loadi16 addr:$src1), i16immSExt8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003752 (implicit EFLAGS)),
3753 (IMUL16rmi8 addr:$src1, i16immSExt8:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003754def : Pat<(parallel (X86smul_flag (loadi32 addr:$src1), i32immSExt8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003755 (implicit EFLAGS)),
3756 (IMUL32rmi8 addr:$src1, i32immSExt8:$src2)>;
3757
Dan Gohman99a12192009-03-04 19:44:21 +00003758// Optimize multiply by 2 with EFLAGS result.
Evan Cheng00cf7932009-01-27 03:30:42 +00003759let AddedComplexity = 2 in {
Dan Gohman99a12192009-03-04 19:44:21 +00003760def : Pat<(parallel (X86smul_flag GR16:$src1, 2),
Evan Cheng00cf7932009-01-27 03:30:42 +00003761 (implicit EFLAGS)),
3762 (ADD16rr GR16:$src1, GR16:$src1)>;
3763
Dan Gohman99a12192009-03-04 19:44:21 +00003764def : Pat<(parallel (X86smul_flag GR32:$src1, 2),
Evan Cheng00cf7932009-01-27 03:30:42 +00003765 (implicit EFLAGS)),
3766 (ADD32rr GR32:$src1, GR32:$src1)>;
3767}
3768
Dan Gohman99a12192009-03-04 19:44:21 +00003769// INC and DEC with EFLAGS result. Note that these do not set CF.
3770def : Pat<(parallel (X86inc_flag GR8:$src), (implicit EFLAGS)),
3771 (INC8r GR8:$src)>;
3772def : Pat<(parallel (store (i8 (X86inc_flag (loadi8 addr:$dst))), addr:$dst),
3773 (implicit EFLAGS)),
3774 (INC8m addr:$dst)>;
3775def : Pat<(parallel (X86dec_flag GR8:$src), (implicit EFLAGS)),
3776 (DEC8r GR8:$src)>;
3777def : Pat<(parallel (store (i8 (X86dec_flag (loadi8 addr:$dst))), addr:$dst),
3778 (implicit EFLAGS)),
3779 (DEC8m addr:$dst)>;
3780
3781def : Pat<(parallel (X86inc_flag GR16:$src), (implicit EFLAGS)),
Dan Gohmaneebcac72009-03-05 21:32:23 +00003782 (INC16r GR16:$src)>, Requires<[In32BitMode]>;
Dan Gohman99a12192009-03-04 19:44:21 +00003783def : Pat<(parallel (store (i16 (X86inc_flag (loadi16 addr:$dst))), addr:$dst),
3784 (implicit EFLAGS)),
Dan Gohmaneebcac72009-03-05 21:32:23 +00003785 (INC16m addr:$dst)>, Requires<[In32BitMode]>;
Dan Gohman99a12192009-03-04 19:44:21 +00003786def : Pat<(parallel (X86dec_flag GR16:$src), (implicit EFLAGS)),
Dan Gohmaneebcac72009-03-05 21:32:23 +00003787 (DEC16r GR16:$src)>, Requires<[In32BitMode]>;
Dan Gohman99a12192009-03-04 19:44:21 +00003788def : Pat<(parallel (store (i16 (X86dec_flag (loadi16 addr:$dst))), addr:$dst),
3789 (implicit EFLAGS)),
Dan Gohmaneebcac72009-03-05 21:32:23 +00003790 (DEC16m addr:$dst)>, Requires<[In32BitMode]>;
Dan Gohman99a12192009-03-04 19:44:21 +00003791
3792def : Pat<(parallel (X86inc_flag GR32:$src), (implicit EFLAGS)),
Dan Gohmaneebcac72009-03-05 21:32:23 +00003793 (INC32r GR32:$src)>, Requires<[In32BitMode]>;
Dan Gohman99a12192009-03-04 19:44:21 +00003794def : Pat<(parallel (store (i32 (X86inc_flag (loadi32 addr:$dst))), addr:$dst),
3795 (implicit EFLAGS)),
Dan Gohmaneebcac72009-03-05 21:32:23 +00003796 (INC32m addr:$dst)>, Requires<[In32BitMode]>;
Dan Gohman99a12192009-03-04 19:44:21 +00003797def : Pat<(parallel (X86dec_flag GR32:$src), (implicit EFLAGS)),
Dan Gohmaneebcac72009-03-05 21:32:23 +00003798 (DEC32r GR32:$src)>, Requires<[In32BitMode]>;
Dan Gohman99a12192009-03-04 19:44:21 +00003799def : Pat<(parallel (store (i32 (X86dec_flag (loadi32 addr:$dst))), addr:$dst),
3800 (implicit EFLAGS)),
Dan Gohmaneebcac72009-03-05 21:32:23 +00003801 (DEC32m addr:$dst)>, Requires<[In32BitMode]>;
Dan Gohman99a12192009-03-04 19:44:21 +00003802
Bill Wendlingf5399032008-12-12 21:15:41 +00003803//===----------------------------------------------------------------------===//
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003804// Floating Point Stack Support
3805//===----------------------------------------------------------------------===//
3806
3807include "X86InstrFPStack.td"
3808
3809//===----------------------------------------------------------------------===//
Evan Cheng86ab7d32007-07-31 08:04:03 +00003810// X86-64 Support
3811//===----------------------------------------------------------------------===//
3812
Chris Lattner2de8d2b2008-01-10 05:50:42 +00003813include "X86Instr64bit.td"
Evan Cheng86ab7d32007-07-31 08:04:03 +00003814
3815//===----------------------------------------------------------------------===//
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003816// XMM Floating point support (requires SSE / SSE2)
3817//===----------------------------------------------------------------------===//
3818
3819include "X86InstrSSE.td"
Evan Cheng5e4d1e72008-04-25 18:19:54 +00003820
3821//===----------------------------------------------------------------------===//
3822// MMX and XMM Packed Integer support (requires MMX, SSE, and SSE2)
3823//===----------------------------------------------------------------------===//
3824
3825include "X86InstrMMX.td"