blob: 84c357308a59ebfc92d4e6604be80c6a23fd98cf [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>]>;
Evan Cheng621216e2007-09-29 00:00:36 +000037def SDTX86BrCond : SDTypeProfile<0, 3,
Evan Cheng950aac02007-09-25 01:57:46 +000038 [SDTCisVT<0, OtherVT>,
39 SDTCisVT<1, i8>, SDTCisVT<2, i32>]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +000040
Evan Cheng621216e2007-09-29 00:00:36 +000041def SDTX86SetCC : SDTypeProfile<1, 2,
Evan Cheng950aac02007-09-25 01:57:46 +000042 [SDTCisVT<0, i8>,
43 SDTCisVT<1, i8>, SDTCisVT<2, i32>]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +000044
Andrew Lenharth7dfe23f2008-03-01 21:52:34 +000045def SDTX86cas : SDTypeProfile<0, 3, [SDTCisPtrTy<0>, SDTCisInt<1>,
46 SDTCisVT<2, i8>]>;
Andrew Lenharth81580822008-03-05 01:15:49 +000047def SDTX86cas8 : SDTypeProfile<0, 1, [SDTCisPtrTy<0>]>;
Andrew Lenharth7dfe23f2008-03-01 21:52:34 +000048
Dale Johannesenf160d802008-10-02 18:53:47 +000049def SDTX86atomicBinary : SDTypeProfile<2, 3, [SDTCisInt<0>, SDTCisInt<1>,
50 SDTCisPtrTy<2>, SDTCisInt<3>,SDTCisInt<4>]>;
Chris Lattnerb56cc342008-03-11 03:23:40 +000051def SDTX86Ret : SDTypeProfile<0, -1, [SDTCisVT<0, i16>]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +000052
Bill Wendling7173da52007-11-13 09:19:02 +000053def SDT_X86CallSeqStart : SDCallSeqStart<[ SDTCisVT<0, i32> ]>;
54def SDT_X86CallSeqEnd : SDCallSeqEnd<[ SDTCisVT<0, i32>,
55 SDTCisVT<1, i32> ]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +000056
Dan Gohman3329ffe2008-05-29 19:57:41 +000057def SDT_X86Call : SDTypeProfile<0, -1, [SDTCisVT<0, iPTR>]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +000058
59def SDTX86RepStr : SDTypeProfile<0, 1, [SDTCisVT<0, OtherVT>]>;
60
61def SDTX86RdTsc : SDTypeProfile<0, 0, []>;
62
63def SDTX86Wrapper : SDTypeProfile<1, 1, [SDTCisSameAs<0, 1>, SDTCisPtrTy<0>]>;
64
Rafael Espindolaaf759ab2009-04-17 14:35:58 +000065def SDT_X86TLSADDR : SDTypeProfile<0, 1, [SDTCisInt<0>]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +000066
Rafael Espindolabca99f72009-04-08 21:14:34 +000067def SDT_X86SegmentBaseAddress : SDTypeProfile<1, 1, [SDTCisPtrTy<0>]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +000068
69def SDT_X86EHRET : SDTypeProfile<0, 1, [SDTCisInt<0>]>;
70
Arnold Schwaighofere2d6bbb2007-10-11 19:40:01 +000071def SDT_X86TCRET : SDTypeProfile<0, 2, [SDTCisPtrTy<0>, SDTCisVT<1, i32>]>;
72
Evan Cheng48679f42007-12-14 02:13:44 +000073def X86bsf : SDNode<"X86ISD::BSF", SDTIntUnaryOp>;
74def X86bsr : SDNode<"X86ISD::BSR", SDTIntUnaryOp>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +000075def X86shld : SDNode<"X86ISD::SHLD", SDTIntShiftDOp>;
76def X86shrd : SDNode<"X86ISD::SHRD", SDTIntShiftDOp>;
77
Evan Cheng621216e2007-09-29 00:00:36 +000078def X86cmp : SDNode<"X86ISD::CMP" , SDTX86CmpTest>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +000079
Dan Gohman7fe9b7f2008-12-23 22:45:23 +000080def X86bt : SDNode<"X86ISD::BT", SDTX86CmpTest>;
81
Evan Cheng621216e2007-09-29 00:00:36 +000082def X86cmov : SDNode<"X86ISD::CMOV", SDTX86Cmov>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +000083def X86brcond : SDNode<"X86ISD::BRCOND", SDTX86BrCond,
Evan Cheng950aac02007-09-25 01:57:46 +000084 [SDNPHasChain]>;
Evan Cheng621216e2007-09-29 00:00:36 +000085def X86setcc : SDNode<"X86ISD::SETCC", SDTX86SetCC>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +000086
Andrew Lenharth7dfe23f2008-03-01 21:52:34 +000087def X86cas : SDNode<"X86ISD::LCMPXCHG_DAG", SDTX86cas,
88 [SDNPHasChain, SDNPInFlag, SDNPOutFlag, SDNPMayStore,
89 SDNPMayLoad]>;
Andrew Lenharth81580822008-03-05 01:15:49 +000090def X86cas8 : SDNode<"X86ISD::LCMPXCHG8_DAG", SDTX86cas8,
91 [SDNPHasChain, SDNPInFlag, SDNPOutFlag, SDNPMayStore,
92 SDNPMayLoad]>;
Dale Johannesenf160d802008-10-02 18:53:47 +000093def X86AtomAdd64 : SDNode<"X86ISD::ATOMADD64_DAG", SDTX86atomicBinary,
94 [SDNPHasChain, SDNPMayStore,
95 SDNPMayLoad, SDNPMemOperand]>;
96def X86AtomSub64 : SDNode<"X86ISD::ATOMSUB64_DAG", SDTX86atomicBinary,
97 [SDNPHasChain, SDNPMayStore,
98 SDNPMayLoad, SDNPMemOperand]>;
99def X86AtomOr64 : SDNode<"X86ISD::ATOMOR64_DAG", SDTX86atomicBinary,
100 [SDNPHasChain, SDNPMayStore,
101 SDNPMayLoad, SDNPMemOperand]>;
102def X86AtomXor64 : SDNode<"X86ISD::ATOMXOR64_DAG", SDTX86atomicBinary,
103 [SDNPHasChain, SDNPMayStore,
104 SDNPMayLoad, SDNPMemOperand]>;
105def X86AtomAnd64 : SDNode<"X86ISD::ATOMAND64_DAG", SDTX86atomicBinary,
106 [SDNPHasChain, SDNPMayStore,
107 SDNPMayLoad, SDNPMemOperand]>;
108def X86AtomNand64 : SDNode<"X86ISD::ATOMNAND64_DAG", SDTX86atomicBinary,
109 [SDNPHasChain, SDNPMayStore,
110 SDNPMayLoad, SDNPMemOperand]>;
Dale Johannesen51c58ee2008-10-03 22:25:52 +0000111def X86AtomSwap64 : SDNode<"X86ISD::ATOMSWAP64_DAG", SDTX86atomicBinary,
112 [SDNPHasChain, SDNPMayStore,
113 SDNPMayLoad, SDNPMemOperand]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000114def X86retflag : SDNode<"X86ISD::RET_FLAG", SDTX86Ret,
115 [SDNPHasChain, SDNPOptInFlag]>;
116
117def X86callseq_start :
118 SDNode<"ISD::CALLSEQ_START", SDT_X86CallSeqStart,
119 [SDNPHasChain, SDNPOutFlag]>;
120def X86callseq_end :
121 SDNode<"ISD::CALLSEQ_END", SDT_X86CallSeqEnd,
Arnold Schwaighofere2d6bbb2007-10-11 19:40:01 +0000122 [SDNPHasChain, SDNPOptInFlag, SDNPOutFlag]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000123
124def X86call : SDNode<"X86ISD::CALL", SDT_X86Call,
125 [SDNPHasChain, SDNPOutFlag, SDNPOptInFlag]>;
126
127def X86tailcall: SDNode<"X86ISD::TAILCALL", SDT_X86Call,
128 [SDNPHasChain, SDNPOutFlag, SDNPOptInFlag]>;
129
130def X86rep_stos: SDNode<"X86ISD::REP_STOS", SDTX86RepStr,
Chris Lattnerca4e0fe2008-01-10 05:12:37 +0000131 [SDNPHasChain, SDNPInFlag, SDNPOutFlag, SDNPMayStore]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000132def X86rep_movs: SDNode<"X86ISD::REP_MOVS", SDTX86RepStr,
Chris Lattnerca4e0fe2008-01-10 05:12:37 +0000133 [SDNPHasChain, SDNPInFlag, SDNPOutFlag, SDNPMayStore,
134 SDNPMayLoad]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000135
136def X86rdtsc : SDNode<"X86ISD::RDTSC_DAG",SDTX86RdTsc,
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000137 [SDNPHasChain, SDNPOutFlag, SDNPSideEffect]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000138
139def X86Wrapper : SDNode<"X86ISD::Wrapper", SDTX86Wrapper>;
140def X86WrapperRIP : SDNode<"X86ISD::WrapperRIP", SDTX86Wrapper>;
141
142def X86tlsaddr : SDNode<"X86ISD::TLSADDR", SDT_X86TLSADDR,
Anton Korobeynikov4fbf00b2008-05-04 21:36:32 +0000143 [SDNPHasChain, SDNPOptInFlag, SDNPOutFlag]>;
Rafael Espindolabca99f72009-04-08 21:14:34 +0000144def X86SegmentBaseAddress : SDNode<"X86ISD::SegmentBaseAddress",
145 SDT_X86SegmentBaseAddress, []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000146
147def X86ehret : SDNode<"X86ISD::EH_RETURN", SDT_X86EHRET,
148 [SDNPHasChain]>;
149
Arnold Schwaighofere2d6bbb2007-10-11 19:40:01 +0000150def X86tcret : SDNode<"X86ISD::TC_RETURN", SDT_X86TCRET,
151 [SDNPHasChain, SDNPOptInFlag]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000152
Dan Gohman99a12192009-03-04 19:44:21 +0000153def X86add_flag : SDNode<"X86ISD::ADD", SDTBinaryArithWithFlags>;
154def X86sub_flag : SDNode<"X86ISD::SUB", SDTBinaryArithWithFlags>;
155def X86smul_flag : SDNode<"X86ISD::SMUL", SDTBinaryArithWithFlags>;
156def X86umul_flag : SDNode<"X86ISD::UMUL", SDTUnaryArithWithFlags>;
157def X86inc_flag : SDNode<"X86ISD::INC", SDTUnaryArithWithFlags>;
158def X86dec_flag : SDNode<"X86ISD::DEC", SDTUnaryArithWithFlags>;
Bill Wendlingae034ed2008-12-12 00:56:36 +0000159
Evan Chengc3495762009-03-30 21:36:47 +0000160def X86mul_imm : SDNode<"X86ISD::MUL_IMM", SDTIntBinOp>;
161
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000162//===----------------------------------------------------------------------===//
163// X86 Operand Definitions.
164//
165
166// *mem - Operand definitions for the funky X86 addressing mode operands.
167//
168class X86MemOperand<string printMethod> : Operand<iPTR> {
169 let PrintMethod = printMethod;
Rafael Espindolabca99f72009-04-08 21:14:34 +0000170 let MIOperandInfo = (ops ptr_rc, i8imm, ptr_rc, i32imm, i8imm);
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000171}
172
173def i8mem : X86MemOperand<"printi8mem">;
174def i16mem : X86MemOperand<"printi16mem">;
175def i32mem : X86MemOperand<"printi32mem">;
176def i64mem : X86MemOperand<"printi64mem">;
177def i128mem : X86MemOperand<"printi128mem">;
178def f32mem : X86MemOperand<"printf32mem">;
179def f64mem : X86MemOperand<"printf64mem">;
Dale Johannesen4ab00bd2007-08-05 18:49:15 +0000180def f80mem : X86MemOperand<"printf80mem">;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000181def f128mem : X86MemOperand<"printf128mem">;
182
Dan Gohman744d4622009-04-13 16:09:41 +0000183// A version of i8mem for use on x86-64 that uses GR64_NOREX instead of
184// plain GR64, so that it doesn't potentially require a REX prefix.
185def i8mem_NOREX : Operand<i64> {
186 let PrintMethod = "printi8mem";
187 let MIOperandInfo = (ops GR64_NOREX, i8imm, GR64_NOREX, i32imm, i8imm);
188}
189
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000190def lea32mem : Operand<i32> {
Rafael Espindolabca99f72009-04-08 21:14:34 +0000191 let PrintMethod = "printlea32mem";
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000192 let MIOperandInfo = (ops GR32, i8imm, GR32, i32imm);
193}
194
195def SSECC : Operand<i8> {
196 let PrintMethod = "printSSECC";
197}
198
199def piclabel: Operand<i32> {
200 let PrintMethod = "printPICLabel";
201}
202
203// A couple of more descriptive operand definitions.
204// 16-bits but only 8 bits are significant.
205def i16i8imm : Operand<i16>;
206// 32-bits but only 8 bits are significant.
207def i32i8imm : Operand<i32>;
208
209// Branch targets have OtherVT type.
210def brtarget : Operand<OtherVT>;
211
212//===----------------------------------------------------------------------===//
213// X86 Complex Pattern Definitions.
214//
215
216// Define X86 specific addressing mode.
Rafael Espindolabca99f72009-04-08 21:14:34 +0000217def addr : ComplexPattern<iPTR, 5, "SelectAddr", [], []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000218def lea32addr : ComplexPattern<i32, 4, "SelectLEAAddr",
Dan Gohman946223f2009-05-11 18:02:53 +0000219 [add, sub, mul, shl, or, frameindex], []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000220
221//===----------------------------------------------------------------------===//
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000222// X86 Instruction Predicate Definitions.
223def HasMMX : Predicate<"Subtarget->hasMMX()">;
224def HasSSE1 : Predicate<"Subtarget->hasSSE1()">;
225def HasSSE2 : Predicate<"Subtarget->hasSSE2()">;
226def HasSSE3 : Predicate<"Subtarget->hasSSE3()">;
227def HasSSSE3 : Predicate<"Subtarget->hasSSSE3()">;
Nate Begemanb2975562008-02-03 07:18:54 +0000228def HasSSE41 : Predicate<"Subtarget->hasSSE41()">;
229def HasSSE42 : Predicate<"Subtarget->hasSSE42()">;
Dale Johannesene0e0fd02007-09-23 14:52:20 +0000230def FPStackf32 : Predicate<"!Subtarget->hasSSE1()">;
231def FPStackf64 : Predicate<"!Subtarget->hasSSE2()">;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000232def In32BitMode : Predicate<"!Subtarget->is64Bit()">;
233def In64BitMode : Predicate<"Subtarget->is64Bit()">;
234def SmallCode : Predicate<"TM.getCodeModel() == CodeModel::Small">;
235def NotSmallCode : Predicate<"TM.getCodeModel() != CodeModel::Small">;
236def IsStatic : Predicate<"TM.getRelocationModel() == Reloc::Static">;
Evan Cheng13559d62008-09-26 23:41:32 +0000237def OptForSpeed : Predicate<"!OptForSize">;
Evan Cheng95a77fd2009-01-02 05:35:45 +0000238def FastBTMem : Predicate<"!Subtarget->isBTMemSlow()">;
Evan Cheng6d35a4d2009-05-20 04:53:57 +0000239def CallImmAddr : Predicate<"Subtarget->IsLegalToCallImmediateAddr(TM)">;
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()))
Mon P Wangdc97d5a2009-04-27 07:22:10 +0000289 if (PT->getAddressSpace() > 255)
Chris Lattner12208612009-04-10 00:16:23 +0000290 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()))
Mon P Wangdc97d5a2009-04-27 07:22:10 +0000303 if (PT->getAddressSpace() > 255)
Chris Lattner12208612009-04-10 00:16:23 +0000304 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()))
Mon P Wangdc97d5a2009-04-27 07:22:10 +0000315 if (PT->getAddressSpace() > 255)
Chris Lattner12208612009-04-10 00:16:23 +0000316 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()))
Mon P Wangdc97d5a2009-04-27 07:22:10 +0000329 if (PT->getAddressSpace() > 255)
Chris Lattner12208612009-04-10 00:16:23 +0000330 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 Lattnera7c2d8a2009-05-05 18:52:19 +0000348def fsload : PatFrag<(ops node:$ptr), (load node:$ptr), [{
349 if (const Value *Src = cast<LoadSDNode>(N)->getSrcValue())
350 if (const PointerType *PT = dyn_cast<PointerType>(Src->getType()))
351 return PT->getAddressSpace() == 257;
352 return false;
353}]>;
354
Chris Lattner12208612009-04-10 00:16:23 +0000355def loadi8 : PatFrag<(ops node:$ptr), (i8 (load node:$ptr)), [{
356 if (const Value *Src = cast<LoadSDNode>(N)->getSrcValue())
357 if (const PointerType *PT = dyn_cast<PointerType>(Src->getType()))
Mon P Wangdc97d5a2009-04-27 07:22:10 +0000358 if (PT->getAddressSpace() > 255)
Chris Lattner12208612009-04-10 00:16:23 +0000359 return false;
360 return true;
361}]>;
362def loadi64 : PatFrag<(ops node:$ptr), (i64 (load node:$ptr)), [{
363 if (const Value *Src = cast<LoadSDNode>(N)->getSrcValue())
364 if (const PointerType *PT = dyn_cast<PointerType>(Src->getType()))
Mon P Wangdc97d5a2009-04-27 07:22:10 +0000365 if (PT->getAddressSpace() > 255)
Chris Lattner12208612009-04-10 00:16:23 +0000366 return false;
367 return true;
368}]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000369
Chris Lattner12208612009-04-10 00:16:23 +0000370def loadf32 : PatFrag<(ops node:$ptr), (f32 (load node:$ptr)), [{
371 if (const Value *Src = cast<LoadSDNode>(N)->getSrcValue())
372 if (const PointerType *PT = dyn_cast<PointerType>(Src->getType()))
Mon P Wangdc97d5a2009-04-27 07:22:10 +0000373 if (PT->getAddressSpace() > 255)
Chris Lattner12208612009-04-10 00:16:23 +0000374 return false;
375 return true;
376}]>;
377def loadf64 : PatFrag<(ops node:$ptr), (f64 (load node:$ptr)), [{
378 if (const Value *Src = cast<LoadSDNode>(N)->getSrcValue())
379 if (const PointerType *PT = dyn_cast<PointerType>(Src->getType()))
Mon P Wangdc97d5a2009-04-27 07:22:10 +0000380 if (PT->getAddressSpace() > 255)
Chris Lattner12208612009-04-10 00:16:23 +0000381 return false;
382 return true;
383}]>;
384def loadf80 : PatFrag<(ops node:$ptr), (f80 (load node:$ptr)), [{
385 if (const Value *Src = cast<LoadSDNode>(N)->getSrcValue())
386 if (const PointerType *PT = dyn_cast<PointerType>(Src->getType()))
Mon P Wangdc97d5a2009-04-27 07:22:10 +0000387 if (PT->getAddressSpace() > 255)
Chris Lattner12208612009-04-10 00:16:23 +0000388 return false;
389 return true;
390}]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000391
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000392def sextloadi16i8 : PatFrag<(ops node:$ptr), (i16 (sextloadi8 node:$ptr))>;
393def sextloadi32i8 : PatFrag<(ops node:$ptr), (i32 (sextloadi8 node:$ptr))>;
394def sextloadi32i16 : PatFrag<(ops node:$ptr), (i32 (sextloadi16 node:$ptr))>;
395
396def zextloadi8i1 : PatFrag<(ops node:$ptr), (i8 (zextloadi1 node:$ptr))>;
397def zextloadi16i1 : PatFrag<(ops node:$ptr), (i16 (zextloadi1 node:$ptr))>;
398def zextloadi32i1 : PatFrag<(ops node:$ptr), (i32 (zextloadi1 node:$ptr))>;
399def zextloadi16i8 : PatFrag<(ops node:$ptr), (i16 (zextloadi8 node:$ptr))>;
400def zextloadi32i8 : PatFrag<(ops node:$ptr), (i32 (zextloadi8 node:$ptr))>;
401def zextloadi32i16 : PatFrag<(ops node:$ptr), (i32 (zextloadi16 node:$ptr))>;
402
403def extloadi8i1 : PatFrag<(ops node:$ptr), (i8 (extloadi1 node:$ptr))>;
404def extloadi16i1 : PatFrag<(ops node:$ptr), (i16 (extloadi1 node:$ptr))>;
405def extloadi32i1 : PatFrag<(ops node:$ptr), (i32 (extloadi1 node:$ptr))>;
406def extloadi16i8 : PatFrag<(ops node:$ptr), (i16 (extloadi8 node:$ptr))>;
407def extloadi32i8 : PatFrag<(ops node:$ptr), (i32 (extloadi8 node:$ptr))>;
408def extloadi32i16 : PatFrag<(ops node:$ptr), (i32 (extloadi16 node:$ptr))>;
409
Chris Lattner21da6382008-02-19 17:37:35 +0000410
411// An 'and' node with a single use.
412def and_su : PatFrag<(ops node:$lhs, node:$rhs), (and node:$lhs, node:$rhs), [{
Evan Cheng9123cfa2008-03-04 00:40:35 +0000413 return N->hasOneUse();
Chris Lattner21da6382008-02-19 17:37:35 +0000414}]>;
Dan Gohman744d4622009-04-13 16:09:41 +0000415// An 'srl' node with a single use.
416def srl_su : PatFrag<(ops node:$lhs, node:$rhs), (srl node:$lhs, node:$rhs), [{
417 return N->hasOneUse();
418}]>;
419// An 'trunc' node with a single use.
420def trunc_su : PatFrag<(ops node:$src), (trunc node:$src), [{
421 return N->hasOneUse();
422}]>;
Chris Lattner21da6382008-02-19 17:37:35 +0000423
Dan Gohman921581d2008-10-17 01:23:35 +0000424// 'shld' and 'shrd' instruction patterns. Note that even though these have
425// the srl and shl in their patterns, the C++ code must still check for them,
426// because predicates are tested before children nodes are explored.
427
428def shrd : PatFrag<(ops node:$src1, node:$amt1, node:$src2, node:$amt2),
429 (or (srl node:$src1, node:$amt1),
430 (shl node:$src2, node:$amt2)), [{
431 assert(N->getOpcode() == ISD::OR);
432 return N->getOperand(0).getOpcode() == ISD::SRL &&
433 N->getOperand(1).getOpcode() == ISD::SHL &&
434 isa<ConstantSDNode>(N->getOperand(0).getOperand(1)) &&
435 isa<ConstantSDNode>(N->getOperand(1).getOperand(1)) &&
436 N->getOperand(0).getConstantOperandVal(1) ==
437 N->getValueSizeInBits(0) - N->getOperand(1).getConstantOperandVal(1);
438}]>;
439
440def shld : PatFrag<(ops node:$src1, node:$amt1, node:$src2, node:$amt2),
441 (or (shl node:$src1, node:$amt1),
442 (srl node:$src2, node:$amt2)), [{
443 assert(N->getOpcode() == ISD::OR);
444 return N->getOperand(0).getOpcode() == ISD::SHL &&
445 N->getOperand(1).getOpcode() == ISD::SRL &&
446 isa<ConstantSDNode>(N->getOperand(0).getOperand(1)) &&
447 isa<ConstantSDNode>(N->getOperand(1).getOperand(1)) &&
448 N->getOperand(0).getConstantOperandVal(1) ==
449 N->getValueSizeInBits(0) - N->getOperand(1).getConstantOperandVal(1);
450}]>;
451
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000452//===----------------------------------------------------------------------===//
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000453// Instruction list...
454//
455
456// ADJCALLSTACKDOWN/UP implicitly use/def ESP because they may be expanded into
457// a stack adjustment and the codegen must know that they may modify the stack
458// pointer before prolog-epilog rewriting occurs.
Chris Lattnerb56cc342008-03-11 03:23:40 +0000459// Pessimistically assume ADJCALLSTACKDOWN / ADJCALLSTACKUP will become
460// sub / add which can clobber EFLAGS.
Evan Cheng037364a2007-09-28 01:19:48 +0000461let Defs = [ESP, EFLAGS], Uses = [ESP] in {
Dan Gohman01c9f772008-10-01 18:28:06 +0000462def ADJCALLSTACKDOWN32 : I<0, Pseudo, (outs), (ins i32imm:$amt),
463 "#ADJCALLSTACKDOWN",
Chris Lattnerfe5d4022008-10-11 22:08:30 +0000464 [(X86callseq_start timm:$amt)]>,
Dan Gohman01c9f772008-10-01 18:28:06 +0000465 Requires<[In32BitMode]>;
466def ADJCALLSTACKUP32 : I<0, Pseudo, (outs), (ins i32imm:$amt1, i32imm:$amt2),
467 "#ADJCALLSTACKUP",
Chris Lattnerfe5d4022008-10-11 22:08:30 +0000468 [(X86callseq_end timm:$amt1, timm:$amt2)]>,
Dan Gohman01c9f772008-10-01 18:28:06 +0000469 Requires<[In32BitMode]>;
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000470}
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000471
472// Nop
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000473let neverHasSideEffects = 1 in
474 def NOOP : I<0x90, RawFrm, (outs), (ins), "nop", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000475
Evan Cheng0729ccf2008-01-05 00:41:47 +0000476// PIC base
Dan Gohman9499cfe2008-10-01 04:14:30 +0000477let neverHasSideEffects = 1, isNotDuplicable = 1, Uses = [ESP] in
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000478 def MOVPC32r : Ii32<0xE8, Pseudo, (outs GR32:$reg), (ins piclabel:$label),
Dan Gohman70a8a112009-04-27 15:13:28 +0000479 "call\t$label\n\t"
480 "pop{l}\t$reg", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000481
482//===----------------------------------------------------------------------===//
483// Control Flow Instructions...
484//
485
486// Return instructions.
487let isTerminator = 1, isReturn = 1, isBarrier = 1,
Chris Lattnerb56cc342008-03-11 03:23:40 +0000488 hasCtrlDep = 1, FPForm = SpecialFP, FPFormBits = SpecialFP.Value in {
Dan Gohman2c4be2a2008-05-31 02:11:25 +0000489 def RET : I <0xC3, RawFrm, (outs), (ins variable_ops),
Chris Lattnerb56cc342008-03-11 03:23:40 +0000490 "ret",
Dan Gohman2c4be2a2008-05-31 02:11:25 +0000491 [(X86retflag 0)]>;
Chris Lattnerb56cc342008-03-11 03:23:40 +0000492 def RETI : Ii16<0xC2, RawFrm, (outs), (ins i16imm:$amt, variable_ops),
493 "ret\t$amt",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000494 [(X86retflag imm:$amt)]>;
495}
496
497// All branches are RawFrm, Void, Branch, and Terminators
Evan Cheng37e7c752007-07-21 00:34:19 +0000498let isBranch = 1, isTerminator = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +0000499 class IBr<bits<8> opcode, dag ins, string asm, list<dag> pattern> :
500 I<opcode, RawFrm, (outs), ins, asm, pattern>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000501
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000502let isBranch = 1, isBarrier = 1 in
Dan Gohman91888f02007-07-31 20:11:57 +0000503 def JMP : IBr<0xE9, (ins brtarget:$dst), "jmp\t$dst", [(br bb:$dst)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000504
Owen Andersonf8053082007-11-12 07:39:39 +0000505// Indirect branches
506let isBranch = 1, isTerminator = 1, isBarrier = 1, isIndirectBranch = 1 in {
Dan Gohman91888f02007-07-31 20:11:57 +0000507 def JMP32r : I<0xFF, MRM4r, (outs), (ins GR32:$dst), "jmp{l}\t{*}$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000508 [(brind GR32:$dst)]>;
Dan Gohman91888f02007-07-31 20:11:57 +0000509 def JMP32m : I<0xFF, MRM4m, (outs), (ins i32mem:$dst), "jmp{l}\t{*}$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000510 [(brind (loadi32 addr:$dst))]>;
511}
512
513// Conditional branches
Evan Cheng950aac02007-09-25 01:57:46 +0000514let Uses = [EFLAGS] in {
Dan Gohman91888f02007-07-31 20:11:57 +0000515def JE : IBr<0x84, (ins brtarget:$dst), "je\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000516 [(X86brcond bb:$dst, X86_COND_E, EFLAGS)]>, TB;
Dan Gohman91888f02007-07-31 20:11:57 +0000517def JNE : IBr<0x85, (ins brtarget:$dst), "jne\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000518 [(X86brcond bb:$dst, X86_COND_NE, EFLAGS)]>, TB;
Dan Gohman91888f02007-07-31 20:11:57 +0000519def JL : IBr<0x8C, (ins brtarget:$dst), "jl\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000520 [(X86brcond bb:$dst, X86_COND_L, EFLAGS)]>, TB;
Dan Gohman91888f02007-07-31 20:11:57 +0000521def JLE : IBr<0x8E, (ins brtarget:$dst), "jle\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000522 [(X86brcond bb:$dst, X86_COND_LE, EFLAGS)]>, TB;
Dan Gohman91888f02007-07-31 20:11:57 +0000523def JG : IBr<0x8F, (ins brtarget:$dst), "jg\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000524 [(X86brcond bb:$dst, X86_COND_G, EFLAGS)]>, TB;
Dan Gohman91888f02007-07-31 20:11:57 +0000525def JGE : IBr<0x8D, (ins brtarget:$dst), "jge\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000526 [(X86brcond bb:$dst, X86_COND_GE, EFLAGS)]>, TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000527
Dan Gohman91888f02007-07-31 20:11:57 +0000528def JB : IBr<0x82, (ins brtarget:$dst), "jb\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000529 [(X86brcond bb:$dst, X86_COND_B, EFLAGS)]>, TB;
Dan Gohman91888f02007-07-31 20:11:57 +0000530def JBE : IBr<0x86, (ins brtarget:$dst), "jbe\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000531 [(X86brcond bb:$dst, X86_COND_BE, EFLAGS)]>, TB;
Dan Gohman91888f02007-07-31 20:11:57 +0000532def JA : IBr<0x87, (ins brtarget:$dst), "ja\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000533 [(X86brcond bb:$dst, X86_COND_A, EFLAGS)]>, TB;
Dan Gohman91888f02007-07-31 20:11:57 +0000534def JAE : IBr<0x83, (ins brtarget:$dst), "jae\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000535 [(X86brcond bb:$dst, X86_COND_AE, EFLAGS)]>, TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000536
Dan Gohman91888f02007-07-31 20:11:57 +0000537def JS : IBr<0x88, (ins brtarget:$dst), "js\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000538 [(X86brcond bb:$dst, X86_COND_S, EFLAGS)]>, TB;
Dan Gohman91888f02007-07-31 20:11:57 +0000539def JNS : IBr<0x89, (ins brtarget:$dst), "jns\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000540 [(X86brcond bb:$dst, X86_COND_NS, EFLAGS)]>, TB;
Dan Gohman91888f02007-07-31 20:11:57 +0000541def JP : IBr<0x8A, (ins brtarget:$dst), "jp\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000542 [(X86brcond bb:$dst, X86_COND_P, EFLAGS)]>, TB;
Dan Gohman91888f02007-07-31 20:11:57 +0000543def JNP : IBr<0x8B, (ins brtarget:$dst), "jnp\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000544 [(X86brcond bb:$dst, X86_COND_NP, EFLAGS)]>, TB;
Dan Gohman91888f02007-07-31 20:11:57 +0000545def JO : IBr<0x80, (ins brtarget:$dst), "jo\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000546 [(X86brcond bb:$dst, X86_COND_O, EFLAGS)]>, TB;
Dan Gohman91888f02007-07-31 20:11:57 +0000547def JNO : IBr<0x81, (ins brtarget:$dst), "jno\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000548 [(X86brcond bb:$dst, X86_COND_NO, EFLAGS)]>, TB;
Evan Cheng950aac02007-09-25 01:57:46 +0000549} // Uses = [EFLAGS]
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000550
551//===----------------------------------------------------------------------===//
552// Call Instructions...
553//
Evan Cheng37e7c752007-07-21 00:34:19 +0000554let isCall = 1 in
Dan Gohman01c9f772008-10-01 18:28:06 +0000555 // All calls clobber the non-callee saved registers. ESP is marked as
556 // a use to prevent stack-pointer assignments that appear immediately
557 // before calls from potentially appearing dead. Uses for argument
558 // registers are added manually.
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000559 let Defs = [EAX, ECX, EDX, FP0, FP1, FP2, FP3, FP4, FP5, FP6, ST0,
560 MM0, MM1, MM2, MM3, MM4, MM5, MM6, MM7,
Evan Cheng2293b252008-10-17 21:02:22 +0000561 XMM0, XMM1, XMM2, XMM3, XMM4, XMM5, XMM6, XMM7,
562 XMM8, XMM9, XMM10, XMM11, XMM12, XMM13, XMM14, XMM15, EFLAGS],
Dan Gohman9499cfe2008-10-01 04:14:30 +0000563 Uses = [ESP] in {
Evan Cheng34f93712007-12-22 02:26:46 +0000564 def CALLpcrel32 : Ii32<0xE8, RawFrm, (outs), (ins i32imm:$dst,variable_ops),
Evan Cheng6d35a4d2009-05-20 04:53:57 +0000565 "call\t${dst:call}", []>;
Evan Chengb783fa32007-07-19 01:14:50 +0000566 def CALL32r : I<0xFF, MRM2r, (outs), (ins GR32:$dst, variable_ops),
Dan Gohman91888f02007-07-31 20:11:57 +0000567 "call\t{*}$dst", [(X86call GR32:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000568 def CALL32m : I<0xFF, MRM2m, (outs), (ins i32mem:$dst, variable_ops),
Dan Gohmanea4faba2008-05-29 21:50:34 +0000569 "call\t{*}$dst", [(X86call (loadi32 addr:$dst))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000570 }
571
572// Tail call stuff.
Arnold Schwaighofere2d6bbb2007-10-11 19:40:01 +0000573
Chris Lattnerb56cc342008-03-11 03:23:40 +0000574def TAILCALL : I<0, Pseudo, (outs), (ins),
Arnold Schwaighofere2d6bbb2007-10-11 19:40:01 +0000575 "#TAILCALL",
576 []>;
577
Evan Cheng37e7c752007-07-21 00:34:19 +0000578let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1 in
Arnold Schwaighofer6fd37ac2008-03-19 16:39:45 +0000579def TCRETURNdi : I<0, Pseudo, (outs), (ins i32imm:$dst, i32imm:$offset, variable_ops),
Arnold Schwaighofere2d6bbb2007-10-11 19:40:01 +0000580 "#TC_RETURN $dst $offset",
581 []>;
582
583let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1 in
Arnold Schwaighofer6fd37ac2008-03-19 16:39:45 +0000584def TCRETURNri : I<0, Pseudo, (outs), (ins GR32:$dst, i32imm:$offset, variable_ops),
Arnold Schwaighofere2d6bbb2007-10-11 19:40:01 +0000585 "#TC_RETURN $dst $offset",
586 []>;
587
588let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1 in
Arnold Schwaighofera0032722008-04-30 09:16:33 +0000589
Arnold Schwaighofere2d6bbb2007-10-11 19:40:01 +0000590 def TAILJMPd : IBr<0xE9, (ins i32imm:$dst), "jmp\t${dst:call} # TAILCALL",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000591 []>;
Evan Cheng37e7c752007-07-21 00:34:19 +0000592let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1 in
Arnold Schwaighofere2d6bbb2007-10-11 19:40:01 +0000593 def TAILJMPr : I<0xFF, MRM4r, (outs), (ins GR32:$dst), "jmp{l}\t{*}$dst # TAILCALL",
594 []>;
Evan Cheng37e7c752007-07-21 00:34:19 +0000595let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +0000596 def TAILJMPm : I<0xFF, MRM4m, (outs), (ins i32mem:$dst),
Arnold Schwaighofere2d6bbb2007-10-11 19:40:01 +0000597 "jmp\t{*}$dst # TAILCALL", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000598
599//===----------------------------------------------------------------------===//
600// Miscellaneous Instructions...
601//
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000602let Defs = [EBP, ESP], Uses = [EBP, ESP], mayLoad = 1, neverHasSideEffects=1 in
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000603def LEAVE : I<0xC9, RawFrm,
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000604 (outs), (ins), "leave", []>;
605
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000606let Defs = [ESP], Uses = [ESP], neverHasSideEffects=1 in {
607let mayLoad = 1 in
Evan Chengd8434332007-09-26 01:29:06 +0000608def POP32r : I<0x58, AddRegFrm, (outs GR32:$reg), (ins), "pop{l}\t$reg", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000609
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000610let mayStore = 1 in
Evan Chengd8434332007-09-26 01:29:06 +0000611def PUSH32r : I<0x50, AddRegFrm, (outs), (ins GR32:$reg), "push{l}\t$reg",[]>;
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000612}
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000613
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000614let Defs = [ESP, EFLAGS], Uses = [ESP], mayLoad = 1, neverHasSideEffects=1 in
Evan Chengf1341312007-09-26 21:28:00 +0000615def POPFD : I<0x9D, RawFrm, (outs), (ins), "popf", []>;
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000616let Defs = [ESP], Uses = [ESP, EFLAGS], mayStore = 1, neverHasSideEffects=1 in
Evan Chengf1341312007-09-26 21:28:00 +0000617def PUSHFD : I<0x9C, RawFrm, (outs), (ins), "pushf", []>;
Evan Chengd8434332007-09-26 01:29:06 +0000618
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000619let isTwoAddress = 1 in // GR32 = bswap GR32
620 def BSWAP32r : I<0xC8, AddRegFrm,
Evan Chengb783fa32007-07-19 01:14:50 +0000621 (outs GR32:$dst), (ins GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000622 "bswap{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000623 [(set GR32:$dst, (bswap GR32:$src))]>, TB;
624
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000625
Evan Cheng48679f42007-12-14 02:13:44 +0000626// Bit scan instructions.
627let Defs = [EFLAGS] in {
Evan Cheng4e33de92007-12-14 18:49:43 +0000628def BSF16rr : I<0xBC, MRMSrcReg, (outs GR16:$dst), (ins GR16:$src),
Dan Gohmancdb54c62007-12-14 15:10:00 +0000629 "bsf{w}\t{$src, $dst|$dst, $src}",
Evan Cheng7cfbfe32007-12-14 08:30:15 +0000630 [(set GR16:$dst, (X86bsf GR16:$src)), (implicit EFLAGS)]>, TB;
Evan Cheng48679f42007-12-14 02:13:44 +0000631def BSF16rm : I<0xBC, MRMSrcMem, (outs GR16:$dst), (ins i16mem:$src),
Dan Gohmancdb54c62007-12-14 15:10:00 +0000632 "bsf{w}\t{$src, $dst|$dst, $src}",
Evan Cheng7cfbfe32007-12-14 08:30:15 +0000633 [(set GR16:$dst, (X86bsf (loadi16 addr:$src))),
634 (implicit EFLAGS)]>, TB;
Evan Cheng4e33de92007-12-14 18:49:43 +0000635def BSF32rr : I<0xBC, MRMSrcReg, (outs GR32:$dst), (ins GR32:$src),
Dan Gohmancdb54c62007-12-14 15:10:00 +0000636 "bsf{l}\t{$src, $dst|$dst, $src}",
Evan Cheng7cfbfe32007-12-14 08:30:15 +0000637 [(set GR32:$dst, (X86bsf GR32:$src)), (implicit EFLAGS)]>, TB;
Evan Cheng48679f42007-12-14 02:13:44 +0000638def BSF32rm : I<0xBC, MRMSrcMem, (outs GR32:$dst), (ins i32mem:$src),
Dan Gohmancdb54c62007-12-14 15:10:00 +0000639 "bsf{l}\t{$src, $dst|$dst, $src}",
Evan Cheng7cfbfe32007-12-14 08:30:15 +0000640 [(set GR32:$dst, (X86bsf (loadi32 addr:$src))),
641 (implicit EFLAGS)]>, TB;
Evan Cheng48679f42007-12-14 02:13:44 +0000642
Evan Cheng4e33de92007-12-14 18:49:43 +0000643def BSR16rr : I<0xBD, MRMSrcReg, (outs GR16:$dst), (ins GR16:$src),
Dan Gohmancdb54c62007-12-14 15:10:00 +0000644 "bsr{w}\t{$src, $dst|$dst, $src}",
Evan Cheng7cfbfe32007-12-14 08:30:15 +0000645 [(set GR16:$dst, (X86bsr GR16:$src)), (implicit EFLAGS)]>, TB;
Evan Cheng48679f42007-12-14 02:13:44 +0000646def BSR16rm : I<0xBD, MRMSrcMem, (outs GR16:$dst), (ins i16mem:$src),
Dan Gohmancdb54c62007-12-14 15:10:00 +0000647 "bsr{w}\t{$src, $dst|$dst, $src}",
Evan Cheng7cfbfe32007-12-14 08:30:15 +0000648 [(set GR16:$dst, (X86bsr (loadi16 addr:$src))),
649 (implicit EFLAGS)]>, TB;
Evan Cheng4e33de92007-12-14 18:49:43 +0000650def BSR32rr : I<0xBD, MRMSrcReg, (outs GR32:$dst), (ins GR32:$src),
Dan Gohmancdb54c62007-12-14 15:10:00 +0000651 "bsr{l}\t{$src, $dst|$dst, $src}",
Evan Cheng7cfbfe32007-12-14 08:30:15 +0000652 [(set GR32:$dst, (X86bsr GR32:$src)), (implicit EFLAGS)]>, TB;
Evan Cheng48679f42007-12-14 02:13:44 +0000653def BSR32rm : I<0xBD, MRMSrcMem, (outs GR32:$dst), (ins i32mem:$src),
Dan Gohmancdb54c62007-12-14 15:10:00 +0000654 "bsr{l}\t{$src, $dst|$dst, $src}",
Evan Cheng7cfbfe32007-12-14 08:30:15 +0000655 [(set GR32:$dst, (X86bsr (loadi32 addr:$src))),
656 (implicit EFLAGS)]>, TB;
Evan Cheng48679f42007-12-14 02:13:44 +0000657} // Defs = [EFLAGS]
658
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000659let neverHasSideEffects = 1 in
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000660def LEA16r : I<0x8D, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +0000661 (outs GR16:$dst), (ins i32mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000662 "lea{w}\t{$src|$dst}, {$dst|$src}", []>, OpSize;
Evan Cheng1ea8e6b2008-03-27 01:41:09 +0000663let isReMaterializable = 1 in
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000664def LEA32r : I<0x8D, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +0000665 (outs GR32:$dst), (ins lea32mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000666 "lea{l}\t{$src|$dst}, {$dst|$src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000667 [(set GR32:$dst, lea32addr:$src)]>, Requires<[In32BitMode]>;
668
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000669let Defs = [ECX,EDI,ESI], Uses = [ECX,EDI,ESI] in {
Evan Chengb783fa32007-07-19 01:14:50 +0000670def REP_MOVSB : I<0xA4, RawFrm, (outs), (ins), "{rep;movsb|rep movsb}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000671 [(X86rep_movs i8)]>, REP;
Evan Chengb783fa32007-07-19 01:14:50 +0000672def REP_MOVSW : I<0xA5, RawFrm, (outs), (ins), "{rep;movsw|rep movsw}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000673 [(X86rep_movs i16)]>, REP, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +0000674def REP_MOVSD : I<0xA5, RawFrm, (outs), (ins), "{rep;movsl|rep movsd}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000675 [(X86rep_movs i32)]>, REP;
676}
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000677
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000678let Defs = [ECX,EDI], Uses = [AL,ECX,EDI] in
Evan Chengb783fa32007-07-19 01:14:50 +0000679def REP_STOSB : I<0xAA, RawFrm, (outs), (ins), "{rep;stosb|rep stosb}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000680 [(X86rep_stos i8)]>, REP;
681let Defs = [ECX,EDI], Uses = [AX,ECX,EDI] in
Evan Chengb783fa32007-07-19 01:14:50 +0000682def REP_STOSW : I<0xAB, RawFrm, (outs), (ins), "{rep;stosw|rep stosw}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000683 [(X86rep_stos i16)]>, REP, OpSize;
684let Defs = [ECX,EDI], Uses = [EAX,ECX,EDI] in
Evan Chengb783fa32007-07-19 01:14:50 +0000685def REP_STOSD : I<0xAB, RawFrm, (outs), (ins), "{rep;stosl|rep stosd}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000686 [(X86rep_stos i32)]>, REP;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000687
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000688let Defs = [RAX, RDX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000689def RDTSC : I<0x31, RawFrm, (outs), (ins), "rdtsc", [(X86rdtsc)]>,
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000690 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000691
Anton Korobeynikov39d40ba2008-01-15 07:02:33 +0000692let isBarrier = 1, hasCtrlDep = 1 in {
Chris Lattner56b941f2008-01-15 21:58:22 +0000693def TRAP : I<0x0B, RawFrm, (outs), (ins), "ud2", [(trap)]>, TB;
Anton Korobeynikov39d40ba2008-01-15 07:02:33 +0000694}
695
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000696//===----------------------------------------------------------------------===//
697// Input/Output Instructions...
698//
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000699let Defs = [AL], Uses = [DX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000700def IN8rr : I<0xEC, RawFrm, (outs), (ins),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000701 "in{b}\t{%dx, %al|%AL, %DX}", []>;
702let Defs = [AX], Uses = [DX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000703def IN16rr : I<0xED, RawFrm, (outs), (ins),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000704 "in{w}\t{%dx, %ax|%AX, %DX}", []>, OpSize;
705let Defs = [EAX], Uses = [DX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000706def IN32rr : I<0xED, RawFrm, (outs), (ins),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000707 "in{l}\t{%dx, %eax|%EAX, %DX}", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000708
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000709let Defs = [AL] in
Evan Chengb783fa32007-07-19 01:14:50 +0000710def IN8ri : Ii8<0xE4, RawFrm, (outs), (ins i16i8imm:$port),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000711 "in{b}\t{$port, %al|%AL, $port}", []>;
712let Defs = [AX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000713def IN16ri : Ii8<0xE5, RawFrm, (outs), (ins i16i8imm:$port),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000714 "in{w}\t{$port, %ax|%AX, $port}", []>, OpSize;
715let Defs = [EAX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000716def IN32ri : Ii8<0xE5, RawFrm, (outs), (ins i16i8imm:$port),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000717 "in{l}\t{$port, %eax|%EAX, $port}", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000718
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000719let Uses = [DX, AL] in
Evan Chengb783fa32007-07-19 01:14:50 +0000720def OUT8rr : I<0xEE, RawFrm, (outs), (ins),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000721 "out{b}\t{%al, %dx|%DX, %AL}", []>;
722let Uses = [DX, AX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000723def OUT16rr : I<0xEF, RawFrm, (outs), (ins),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000724 "out{w}\t{%ax, %dx|%DX, %AX}", []>, OpSize;
725let Uses = [DX, EAX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000726def OUT32rr : I<0xEF, RawFrm, (outs), (ins),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000727 "out{l}\t{%eax, %dx|%DX, %EAX}", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000728
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000729let Uses = [AL] in
Evan Chengb783fa32007-07-19 01:14:50 +0000730def OUT8ir : Ii8<0xE6, RawFrm, (outs), (ins i16i8imm:$port),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000731 "out{b}\t{%al, $port|$port, %AL}", []>;
732let Uses = [AX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000733def OUT16ir : Ii8<0xE7, RawFrm, (outs), (ins i16i8imm:$port),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000734 "out{w}\t{%ax, $port|$port, %AX}", []>, OpSize;
735let Uses = [EAX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000736def OUT32ir : Ii8<0xE7, RawFrm, (outs), (ins i16i8imm:$port),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000737 "out{l}\t{%eax, $port|$port, %EAX}", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000738
739//===----------------------------------------------------------------------===//
740// Move Instructions...
741//
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000742let neverHasSideEffects = 1 in {
Evan Chengb783fa32007-07-19 01:14:50 +0000743def MOV8rr : I<0x88, MRMDestReg, (outs GR8 :$dst), (ins GR8 :$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000744 "mov{b}\t{$src, $dst|$dst, $src}", []>;
Evan Chengb783fa32007-07-19 01:14:50 +0000745def MOV16rr : I<0x89, MRMDestReg, (outs GR16:$dst), (ins GR16:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000746 "mov{w}\t{$src, $dst|$dst, $src}", []>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +0000747def MOV32rr : I<0x89, MRMDestReg, (outs GR32:$dst), (ins GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000748 "mov{l}\t{$src, $dst|$dst, $src}", []>;
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000749}
Evan Cheng6f26e8b2008-06-18 08:13:07 +0000750let isReMaterializable = 1, isAsCheapAsAMove = 1 in {
Evan Chengb783fa32007-07-19 01:14:50 +0000751def MOV8ri : Ii8 <0xB0, AddRegFrm, (outs GR8 :$dst), (ins i8imm :$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000752 "mov{b}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000753 [(set GR8:$dst, imm:$src)]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000754def MOV16ri : Ii16<0xB8, AddRegFrm, (outs GR16:$dst), (ins i16imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000755 "mov{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000756 [(set GR16:$dst, imm:$src)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +0000757def MOV32ri : Ii32<0xB8, AddRegFrm, (outs GR32:$dst), (ins i32imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000758 "mov{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000759 [(set GR32:$dst, imm:$src)]>;
760}
Evan Chengb783fa32007-07-19 01:14:50 +0000761def MOV8mi : Ii8 <0xC6, MRM0m, (outs), (ins i8mem :$dst, i8imm :$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000762 "mov{b}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000763 [(store (i8 imm:$src), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000764def MOV16mi : Ii16<0xC7, MRM0m, (outs), (ins i16mem:$dst, i16imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000765 "mov{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000766 [(store (i16 imm:$src), addr:$dst)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +0000767def MOV32mi : Ii32<0xC7, MRM0m, (outs), (ins i32mem:$dst, i32imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000768 "mov{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000769 [(store (i32 imm:$src), addr:$dst)]>;
770
Dan Gohman5574cc72008-12-03 18:15:48 +0000771let canFoldAsLoad = 1, isReMaterializable = 1, mayHaveSideEffects = 1 in {
Evan Chengb783fa32007-07-19 01:14:50 +0000772def MOV8rm : I<0x8A, MRMSrcMem, (outs GR8 :$dst), (ins i8mem :$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000773 "mov{b}\t{$src, $dst|$dst, $src}",
Chris Lattner12208612009-04-10 00:16:23 +0000774 [(set GR8:$dst, (loadi8 addr:$src))]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000775def MOV16rm : I<0x8B, MRMSrcMem, (outs GR16:$dst), (ins i16mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000776 "mov{w}\t{$src, $dst|$dst, $src}",
Chris Lattner12208612009-04-10 00:16:23 +0000777 [(set GR16:$dst, (loadi16 addr:$src))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +0000778def MOV32rm : I<0x8B, MRMSrcMem, (outs GR32:$dst), (ins i32mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000779 "mov{l}\t{$src, $dst|$dst, $src}",
Chris Lattner12208612009-04-10 00:16:23 +0000780 [(set GR32:$dst, (loadi32 addr:$src))]>;
Evan Cheng4e84e452007-08-30 05:49:43 +0000781}
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000782
Evan Chengb783fa32007-07-19 01:14:50 +0000783def MOV8mr : I<0x88, MRMDestMem, (outs), (ins i8mem :$dst, GR8 :$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000784 "mov{b}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000785 [(store GR8:$src, addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000786def MOV16mr : I<0x89, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000787 "mov{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000788 [(store GR16:$src, addr:$dst)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +0000789def MOV32mr : I<0x89, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000790 "mov{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000791 [(store GR32:$src, addr:$dst)]>;
Dan Gohman744d4622009-04-13 16:09:41 +0000792
Dan Gohman1d8ce9c2009-04-27 16:41:36 +0000793// Versions of MOV8rr, MOV8mr, and MOV8rm that use i8mem_NOREX and GR8_NOREX so
794// that they can be used for copying and storing h registers, which can't be
795// encoded when a REX prefix is present.
Dan Gohman2da0db32009-04-15 00:04:23 +0000796let neverHasSideEffects = 1 in
Dan Gohman40ddc362009-04-15 19:48:57 +0000797def MOV8rr_NOREX : I<0x88, MRMDestReg,
798 (outs GR8_NOREX:$dst), (ins GR8_NOREX:$src),
Dan Gohman2da0db32009-04-15 00:04:23 +0000799 "mov{b}\t{$src, $dst|$dst, $src} # NOREX", []>;
Evan Chengebc49402009-04-30 00:58:57 +0000800let mayStore = 1 in
Dan Gohman2da0db32009-04-15 00:04:23 +0000801def MOV8mr_NOREX : I<0x88, MRMDestMem,
802 (outs), (ins i8mem_NOREX:$dst, GR8_NOREX:$src),
803 "mov{b}\t{$src, $dst|$dst, $src} # NOREX", []>;
Evan Chengebc49402009-04-30 00:58:57 +0000804let mayLoad = 1,
805 canFoldAsLoad = 1, isReMaterializable = 1, mayHaveSideEffects = 1 in
Dan Gohman1d8ce9c2009-04-27 16:41:36 +0000806def MOV8rm_NOREX : I<0x8A, MRMSrcMem,
807 (outs GR8_NOREX:$dst), (ins i8mem_NOREX:$src),
808 "mov{b}\t{$src, $dst|$dst, $src} # NOREX", []>;
Dan Gohman744d4622009-04-13 16:09:41 +0000809
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000810//===----------------------------------------------------------------------===//
811// Fixed-Register Multiplication and Division Instructions...
812//
813
814// Extra precision multiplication
Evan Cheng55687072007-09-14 21:48:26 +0000815let Defs = [AL,AH,EFLAGS], Uses = [AL] in
Dan Gohman91888f02007-07-31 20:11:57 +0000816def MUL8r : I<0xF6, MRM4r, (outs), (ins GR8:$src), "mul{b}\t$src",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000817 // FIXME: Used for 8-bit mul, ignore result upper 8 bits.
818 // This probably ought to be moved to a def : Pat<> if the
819 // syntax can be accepted.
Bill Wendlingf5399032008-12-12 21:15:41 +0000820 [(set AL, (mul AL, GR8:$src)),
821 (implicit EFLAGS)]>; // AL,AH = AL*GR8
822
Chris Lattnerc7e96e72008-01-11 07:18:17 +0000823let Defs = [AX,DX,EFLAGS], Uses = [AX], neverHasSideEffects = 1 in
Bill Wendlingf5399032008-12-12 21:15:41 +0000824def MUL16r : I<0xF7, MRM4r, (outs), (ins GR16:$src),
825 "mul{w}\t$src",
826 []>, OpSize; // AX,DX = AX*GR16
827
Chris Lattnerc7e96e72008-01-11 07:18:17 +0000828let Defs = [EAX,EDX,EFLAGS], Uses = [EAX], neverHasSideEffects = 1 in
Bill Wendlingf5399032008-12-12 21:15:41 +0000829def MUL32r : I<0xF7, MRM4r, (outs), (ins GR32:$src),
830 "mul{l}\t$src",
831 []>; // EAX,EDX = EAX*GR32
832
Evan Cheng55687072007-09-14 21:48:26 +0000833let Defs = [AL,AH,EFLAGS], Uses = [AL] in
Evan Chengb783fa32007-07-19 01:14:50 +0000834def MUL8m : I<0xF6, MRM4m, (outs), (ins i8mem :$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000835 "mul{b}\t$src",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000836 // FIXME: Used for 8-bit mul, ignore result upper 8 bits.
837 // This probably ought to be moved to a def : Pat<> if the
838 // syntax can be accepted.
Bill Wendlingf5399032008-12-12 21:15:41 +0000839 [(set AL, (mul AL, (loadi8 addr:$src))),
840 (implicit EFLAGS)]>; // AL,AH = AL*[mem8]
841
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000842let mayLoad = 1, neverHasSideEffects = 1 in {
Evan Cheng55687072007-09-14 21:48:26 +0000843let Defs = [AX,DX,EFLAGS], Uses = [AX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000844def MUL16m : I<0xF7, MRM4m, (outs), (ins i16mem:$src),
Bill Wendlingf5399032008-12-12 21:15:41 +0000845 "mul{w}\t$src",
846 []>, OpSize; // AX,DX = AX*[mem16]
847
Evan Cheng55687072007-09-14 21:48:26 +0000848let Defs = [EAX,EDX,EFLAGS], Uses = [EAX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000849def MUL32m : I<0xF7, MRM4m, (outs), (ins i32mem:$src),
Bill Wendlingf5399032008-12-12 21:15:41 +0000850 "mul{l}\t$src",
851 []>; // EAX,EDX = EAX*[mem32]
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000852}
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000853
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000854let neverHasSideEffects = 1 in {
Evan Cheng55687072007-09-14 21:48:26 +0000855let Defs = [AL,AH,EFLAGS], Uses = [AL] in
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000856def IMUL8r : I<0xF6, MRM5r, (outs), (ins GR8:$src), "imul{b}\t$src", []>;
857 // AL,AH = AL*GR8
Evan Cheng55687072007-09-14 21:48:26 +0000858let Defs = [AX,DX,EFLAGS], Uses = [AX] in
Dan Gohman91888f02007-07-31 20:11:57 +0000859def IMUL16r : I<0xF7, MRM5r, (outs), (ins GR16:$src), "imul{w}\t$src", []>,
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000860 OpSize; // AX,DX = AX*GR16
Evan Cheng55687072007-09-14 21:48:26 +0000861let Defs = [EAX,EDX,EFLAGS], Uses = [EAX] in
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000862def IMUL32r : I<0xF7, MRM5r, (outs), (ins GR32:$src), "imul{l}\t$src", []>;
863 // EAX,EDX = EAX*GR32
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000864let mayLoad = 1 in {
Evan Cheng55687072007-09-14 21:48:26 +0000865let Defs = [AL,AH,EFLAGS], Uses = [AL] in
Evan Chengb783fa32007-07-19 01:14:50 +0000866def IMUL8m : I<0xF6, MRM5m, (outs), (ins i8mem :$src),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000867 "imul{b}\t$src", []>; // AL,AH = AL*[mem8]
Evan Cheng55687072007-09-14 21:48:26 +0000868let Defs = [AX,DX,EFLAGS], Uses = [AX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000869def IMUL16m : I<0xF7, MRM5m, (outs), (ins i16mem:$src),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000870 "imul{w}\t$src", []>, OpSize; // AX,DX = AX*[mem16]
871let Defs = [EAX,EDX], Uses = [EAX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000872def IMUL32m : I<0xF7, MRM5m, (outs), (ins i32mem:$src),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000873 "imul{l}\t$src", []>; // EAX,EDX = EAX*[mem32]
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000874}
Dan Gohmand44572d2008-11-18 21:29:14 +0000875} // neverHasSideEffects
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000876
877// unsigned division/remainder
Dale Johannesend8fd3562008-10-07 18:54:28 +0000878let Defs = [AL,AH,EFLAGS], Uses = [AX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000879def DIV8r : I<0xF6, MRM6r, (outs), (ins GR8:$src), // AX/r8 = AL,AH
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000880 "div{b}\t$src", []>;
Evan Cheng55687072007-09-14 21:48:26 +0000881let Defs = [AX,DX,EFLAGS], Uses = [AX,DX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000882def DIV16r : I<0xF7, MRM6r, (outs), (ins GR16:$src), // DX:AX/r16 = AX,DX
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000883 "div{w}\t$src", []>, OpSize;
Evan Cheng55687072007-09-14 21:48:26 +0000884let Defs = [EAX,EDX,EFLAGS], Uses = [EAX,EDX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000885def DIV32r : I<0xF7, MRM6r, (outs), (ins GR32:$src), // EDX:EAX/r32 = EAX,EDX
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000886 "div{l}\t$src", []>;
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000887let mayLoad = 1 in {
Dale Johannesend8fd3562008-10-07 18:54:28 +0000888let Defs = [AL,AH,EFLAGS], Uses = [AX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000889def DIV8m : I<0xF6, MRM6m, (outs), (ins i8mem:$src), // AX/[mem8] = AL,AH
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000890 "div{b}\t$src", []>;
Evan Cheng55687072007-09-14 21:48:26 +0000891let Defs = [AX,DX,EFLAGS], Uses = [AX,DX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000892def DIV16m : I<0xF7, MRM6m, (outs), (ins i16mem:$src), // DX:AX/[mem16] = AX,DX
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000893 "div{w}\t$src", []>, OpSize;
Evan Cheng55687072007-09-14 21:48:26 +0000894let Defs = [EAX,EDX,EFLAGS], Uses = [EAX,EDX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000895def DIV32m : I<0xF7, MRM6m, (outs), (ins i32mem:$src), // EDX:EAX/[mem32] = EAX,EDX
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000896 "div{l}\t$src", []>;
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000897}
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000898
899// Signed division/remainder.
Dale Johannesend8fd3562008-10-07 18:54:28 +0000900let Defs = [AL,AH,EFLAGS], Uses = [AX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000901def IDIV8r : I<0xF6, MRM7r, (outs), (ins GR8:$src), // AX/r8 = AL,AH
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000902 "idiv{b}\t$src", []>;
Evan Cheng55687072007-09-14 21:48:26 +0000903let Defs = [AX,DX,EFLAGS], Uses = [AX,DX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000904def IDIV16r: I<0xF7, MRM7r, (outs), (ins GR16:$src), // DX:AX/r16 = AX,DX
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000905 "idiv{w}\t$src", []>, OpSize;
Evan Cheng55687072007-09-14 21:48:26 +0000906let Defs = [EAX,EDX,EFLAGS], Uses = [EAX,EDX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000907def IDIV32r: I<0xF7, MRM7r, (outs), (ins GR32:$src), // EDX:EAX/r32 = EAX,EDX
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000908 "idiv{l}\t$src", []>;
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000909let mayLoad = 1, mayLoad = 1 in {
Dale Johannesend8fd3562008-10-07 18:54:28 +0000910let Defs = [AL,AH,EFLAGS], Uses = [AX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000911def IDIV8m : I<0xF6, MRM7m, (outs), (ins i8mem:$src), // AX/[mem8] = AL,AH
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000912 "idiv{b}\t$src", []>;
Evan Cheng55687072007-09-14 21:48:26 +0000913let Defs = [AX,DX,EFLAGS], Uses = [AX,DX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000914def IDIV16m: I<0xF7, MRM7m, (outs), (ins i16mem:$src), // DX:AX/[mem16] = AX,DX
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000915 "idiv{w}\t$src", []>, OpSize;
Evan Cheng55687072007-09-14 21:48:26 +0000916let Defs = [EAX,EDX,EFLAGS], Uses = [EAX,EDX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000917def IDIV32m: I<0xF7, MRM7m, (outs), (ins i32mem:$src), // EDX:EAX/[mem32] = EAX,EDX
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000918 "idiv{l}\t$src", []>;
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000919}
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000920
921//===----------------------------------------------------------------------===//
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000922// Two address Instructions.
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000923//
924let isTwoAddress = 1 in {
925
926// Conditional moves
Evan Cheng950aac02007-09-25 01:57:46 +0000927let Uses = [EFLAGS] in {
Evan Cheng926658c2007-10-05 23:13:21 +0000928let isCommutable = 1 in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000929def CMOVB16rr : I<0x42, MRMSrcReg, // if <u, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +0000930 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000931 "cmovb\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000932 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000933 X86_COND_B, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000934 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000935def CMOVB32rr : I<0x42, MRMSrcReg, // if <u, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +0000936 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000937 "cmovb\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000938 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000939 X86_COND_B, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000940 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000941def CMOVAE16rr: I<0x43, MRMSrcReg, // if >=u, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +0000942 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000943 "cmovae\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000944 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000945 X86_COND_AE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000946 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000947def CMOVAE32rr: I<0x43, MRMSrcReg, // if >=u, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +0000948 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000949 "cmovae\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000950 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000951 X86_COND_AE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000952 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000953def CMOVE16rr : I<0x44, MRMSrcReg, // if ==, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +0000954 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000955 "cmove\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000956 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000957 X86_COND_E, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000958 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000959def CMOVE32rr : I<0x44, MRMSrcReg, // if ==, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +0000960 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000961 "cmove\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000962 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000963 X86_COND_E, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000964 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000965def CMOVNE16rr: I<0x45, MRMSrcReg, // if !=, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +0000966 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000967 "cmovne\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000968 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000969 X86_COND_NE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000970 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000971def CMOVNE32rr: I<0x45, MRMSrcReg, // if !=, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +0000972 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000973 "cmovne\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000974 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000975 X86_COND_NE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000976 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000977def CMOVBE16rr: I<0x46, MRMSrcReg, // if <=u, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +0000978 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000979 "cmovbe\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000980 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000981 X86_COND_BE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000982 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000983def CMOVBE32rr: I<0x46, MRMSrcReg, // if <=u, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +0000984 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000985 "cmovbe\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000986 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000987 X86_COND_BE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000988 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000989def CMOVA16rr : I<0x47, MRMSrcReg, // if >u, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +0000990 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000991 "cmova\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000992 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000993 X86_COND_A, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000994 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000995def CMOVA32rr : I<0x47, MRMSrcReg, // if >u, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +0000996 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000997 "cmova\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000998 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000999 X86_COND_A, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001000 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001001def CMOVL16rr : I<0x4C, MRMSrcReg, // if <s, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +00001002 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001003 "cmovl\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001004 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001005 X86_COND_L, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001006 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001007def CMOVL32rr : I<0x4C, MRMSrcReg, // if <s, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +00001008 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001009 "cmovl\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001010 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001011 X86_COND_L, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001012 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001013def CMOVGE16rr: I<0x4D, MRMSrcReg, // if >=s, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +00001014 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001015 "cmovge\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001016 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001017 X86_COND_GE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001018 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001019def CMOVGE32rr: I<0x4D, MRMSrcReg, // if >=s, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +00001020 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001021 "cmovge\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001022 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001023 X86_COND_GE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001024 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001025def CMOVLE16rr: I<0x4E, MRMSrcReg, // if <=s, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +00001026 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001027 "cmovle\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001028 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001029 X86_COND_LE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001030 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001031def CMOVLE32rr: I<0x4E, MRMSrcReg, // if <=s, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +00001032 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001033 "cmovle\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001034 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001035 X86_COND_LE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001036 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001037def CMOVG16rr : I<0x4F, MRMSrcReg, // if >s, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +00001038 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001039 "cmovg\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001040 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001041 X86_COND_G, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001042 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001043def CMOVG32rr : I<0x4F, MRMSrcReg, // if >s, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +00001044 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001045 "cmovg\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001046 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001047 X86_COND_G, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001048 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001049def CMOVS16rr : I<0x48, MRMSrcReg, // if signed, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +00001050 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001051 "cmovs\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001052 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001053 X86_COND_S, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001054 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001055def CMOVS32rr : I<0x48, MRMSrcReg, // if signed, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +00001056 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001057 "cmovs\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001058 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001059 X86_COND_S, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001060 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001061def CMOVNS16rr: I<0x49, MRMSrcReg, // if !signed, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +00001062 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001063 "cmovns\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001064 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001065 X86_COND_NS, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001066 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001067def CMOVNS32rr: I<0x49, MRMSrcReg, // if !signed, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +00001068 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001069 "cmovns\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001070 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001071 X86_COND_NS, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001072 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001073def CMOVP16rr : I<0x4A, MRMSrcReg, // if parity, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +00001074 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001075 "cmovp\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001076 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001077 X86_COND_P, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001078 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001079def CMOVP32rr : I<0x4A, MRMSrcReg, // if parity, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +00001080 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001081 "cmovp\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001082 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001083 X86_COND_P, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001084 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001085def CMOVNP16rr : I<0x4B, MRMSrcReg, // if !parity, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +00001086 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001087 "cmovnp\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001088 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001089 X86_COND_NP, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001090 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001091def CMOVNP32rr : I<0x4B, MRMSrcReg, // if !parity, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +00001092 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001093 "cmovnp\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001094 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001095 X86_COND_NP, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001096 TB;
Dan Gohman12fd4d72009-01-07 00:35:10 +00001097def CMOVO16rr : I<0x40, MRMSrcReg, // if overflow, GR16 = GR16
1098 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
1099 "cmovo\t{$src2, $dst|$dst, $src2}",
1100 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
1101 X86_COND_O, EFLAGS))]>,
1102 TB, OpSize;
1103def CMOVO32rr : I<0x40, MRMSrcReg, // if overflow, GR32 = GR32
1104 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
1105 "cmovo\t{$src2, $dst|$dst, $src2}",
1106 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
1107 X86_COND_O, EFLAGS))]>,
Evan Cheng950aac02007-09-25 01:57:46 +00001108 TB;
Dan Gohman12fd4d72009-01-07 00:35:10 +00001109def CMOVNO16rr : I<0x41, MRMSrcReg, // if !overflow, GR16 = GR16
1110 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
1111 "cmovno\t{$src2, $dst|$dst, $src2}",
1112 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
1113 X86_COND_NO, EFLAGS))]>,
1114 TB, OpSize;
1115def CMOVNO32rr : I<0x41, MRMSrcReg, // if !overflow, GR32 = GR32
1116 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
1117 "cmovno\t{$src2, $dst|$dst, $src2}",
1118 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
1119 X86_COND_NO, EFLAGS))]>,
1120 TB;
1121} // isCommutable = 1
Evan Cheng926658c2007-10-05 23:13:21 +00001122
1123def CMOVB16rm : I<0x42, MRMSrcMem, // if <u, GR16 = [mem16]
1124 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1125 "cmovb\t{$src2, $dst|$dst, $src2}",
1126 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1127 X86_COND_B, EFLAGS))]>,
1128 TB, OpSize;
1129def CMOVB32rm : I<0x42, MRMSrcMem, // if <u, GR32 = [mem32]
1130 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1131 "cmovb\t{$src2, $dst|$dst, $src2}",
1132 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1133 X86_COND_B, EFLAGS))]>,
1134 TB;
1135def CMOVAE16rm: I<0x43, MRMSrcMem, // if >=u, GR16 = [mem16]
1136 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1137 "cmovae\t{$src2, $dst|$dst, $src2}",
1138 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1139 X86_COND_AE, EFLAGS))]>,
1140 TB, OpSize;
1141def CMOVAE32rm: I<0x43, MRMSrcMem, // if >=u, GR32 = [mem32]
1142 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1143 "cmovae\t{$src2, $dst|$dst, $src2}",
1144 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1145 X86_COND_AE, EFLAGS))]>,
1146 TB;
1147def CMOVE16rm : I<0x44, MRMSrcMem, // if ==, GR16 = [mem16]
1148 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1149 "cmove\t{$src2, $dst|$dst, $src2}",
1150 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1151 X86_COND_E, EFLAGS))]>,
1152 TB, OpSize;
1153def CMOVE32rm : I<0x44, MRMSrcMem, // if ==, GR32 = [mem32]
1154 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1155 "cmove\t{$src2, $dst|$dst, $src2}",
1156 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1157 X86_COND_E, EFLAGS))]>,
1158 TB;
1159def CMOVNE16rm: I<0x45, MRMSrcMem, // if !=, GR16 = [mem16]
1160 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1161 "cmovne\t{$src2, $dst|$dst, $src2}",
1162 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1163 X86_COND_NE, EFLAGS))]>,
1164 TB, OpSize;
1165def CMOVNE32rm: I<0x45, MRMSrcMem, // if !=, GR32 = [mem32]
1166 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1167 "cmovne\t{$src2, $dst|$dst, $src2}",
1168 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1169 X86_COND_NE, EFLAGS))]>,
1170 TB;
1171def CMOVBE16rm: I<0x46, MRMSrcMem, // if <=u, GR16 = [mem16]
1172 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1173 "cmovbe\t{$src2, $dst|$dst, $src2}",
1174 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1175 X86_COND_BE, EFLAGS))]>,
1176 TB, OpSize;
1177def CMOVBE32rm: I<0x46, MRMSrcMem, // if <=u, GR32 = [mem32]
1178 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1179 "cmovbe\t{$src2, $dst|$dst, $src2}",
1180 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1181 X86_COND_BE, EFLAGS))]>,
1182 TB;
1183def CMOVA16rm : I<0x47, MRMSrcMem, // if >u, GR16 = [mem16]
1184 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1185 "cmova\t{$src2, $dst|$dst, $src2}",
1186 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1187 X86_COND_A, EFLAGS))]>,
1188 TB, OpSize;
1189def CMOVA32rm : I<0x47, MRMSrcMem, // if >u, GR32 = [mem32]
1190 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1191 "cmova\t{$src2, $dst|$dst, $src2}",
1192 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1193 X86_COND_A, EFLAGS))]>,
1194 TB;
1195def CMOVL16rm : I<0x4C, MRMSrcMem, // if <s, GR16 = [mem16]
1196 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1197 "cmovl\t{$src2, $dst|$dst, $src2}",
1198 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1199 X86_COND_L, EFLAGS))]>,
1200 TB, OpSize;
1201def CMOVL32rm : I<0x4C, MRMSrcMem, // if <s, GR32 = [mem32]
1202 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1203 "cmovl\t{$src2, $dst|$dst, $src2}",
1204 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1205 X86_COND_L, EFLAGS))]>,
1206 TB;
1207def CMOVGE16rm: I<0x4D, MRMSrcMem, // if >=s, GR16 = [mem16]
1208 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1209 "cmovge\t{$src2, $dst|$dst, $src2}",
1210 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1211 X86_COND_GE, EFLAGS))]>,
1212 TB, OpSize;
1213def CMOVGE32rm: I<0x4D, MRMSrcMem, // if >=s, GR32 = [mem32]
1214 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1215 "cmovge\t{$src2, $dst|$dst, $src2}",
1216 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1217 X86_COND_GE, EFLAGS))]>,
1218 TB;
1219def CMOVLE16rm: I<0x4E, MRMSrcMem, // if <=s, GR16 = [mem16]
1220 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1221 "cmovle\t{$src2, $dst|$dst, $src2}",
1222 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1223 X86_COND_LE, EFLAGS))]>,
1224 TB, OpSize;
1225def CMOVLE32rm: I<0x4E, MRMSrcMem, // if <=s, GR32 = [mem32]
1226 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1227 "cmovle\t{$src2, $dst|$dst, $src2}",
1228 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1229 X86_COND_LE, EFLAGS))]>,
1230 TB;
1231def CMOVG16rm : I<0x4F, MRMSrcMem, // if >s, GR16 = [mem16]
1232 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1233 "cmovg\t{$src2, $dst|$dst, $src2}",
1234 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1235 X86_COND_G, EFLAGS))]>,
1236 TB, OpSize;
1237def CMOVG32rm : I<0x4F, MRMSrcMem, // if >s, GR32 = [mem32]
1238 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1239 "cmovg\t{$src2, $dst|$dst, $src2}",
1240 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1241 X86_COND_G, EFLAGS))]>,
1242 TB;
1243def CMOVS16rm : I<0x48, MRMSrcMem, // if signed, GR16 = [mem16]
1244 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1245 "cmovs\t{$src2, $dst|$dst, $src2}",
1246 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1247 X86_COND_S, EFLAGS))]>,
1248 TB, OpSize;
1249def CMOVS32rm : I<0x48, MRMSrcMem, // if signed, GR32 = [mem32]
1250 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1251 "cmovs\t{$src2, $dst|$dst, $src2}",
1252 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1253 X86_COND_S, EFLAGS))]>,
1254 TB;
1255def CMOVNS16rm: I<0x49, MRMSrcMem, // if !signed, GR16 = [mem16]
1256 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1257 "cmovns\t{$src2, $dst|$dst, $src2}",
1258 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1259 X86_COND_NS, EFLAGS))]>,
1260 TB, OpSize;
1261def CMOVNS32rm: I<0x49, MRMSrcMem, // if !signed, GR32 = [mem32]
1262 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1263 "cmovns\t{$src2, $dst|$dst, $src2}",
1264 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1265 X86_COND_NS, EFLAGS))]>,
1266 TB;
1267def CMOVP16rm : I<0x4A, MRMSrcMem, // if parity, GR16 = [mem16]
1268 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1269 "cmovp\t{$src2, $dst|$dst, $src2}",
1270 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1271 X86_COND_P, EFLAGS))]>,
1272 TB, OpSize;
1273def CMOVP32rm : I<0x4A, MRMSrcMem, // if parity, GR32 = [mem32]
1274 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1275 "cmovp\t{$src2, $dst|$dst, $src2}",
1276 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1277 X86_COND_P, EFLAGS))]>,
1278 TB;
1279def CMOVNP16rm : I<0x4B, MRMSrcMem, // if !parity, GR16 = [mem16]
1280 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1281 "cmovnp\t{$src2, $dst|$dst, $src2}",
1282 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1283 X86_COND_NP, EFLAGS))]>,
1284 TB, OpSize;
Dan Gohman12fd4d72009-01-07 00:35:10 +00001285def CMOVNP32rm : I<0x4B, MRMSrcMem, // if !parity, GR32 = [mem32]
1286 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1287 "cmovnp\t{$src2, $dst|$dst, $src2}",
1288 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1289 X86_COND_NP, EFLAGS))]>,
1290 TB;
1291def CMOVO16rm : I<0x40, MRMSrcMem, // if overflow, GR16 = [mem16]
1292 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1293 "cmovo\t{$src2, $dst|$dst, $src2}",
1294 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1295 X86_COND_O, EFLAGS))]>,
1296 TB, OpSize;
1297def CMOVO32rm : I<0x40, MRMSrcMem, // if overflow, GR32 = [mem32]
1298 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1299 "cmovo\t{$src2, $dst|$dst, $src2}",
1300 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1301 X86_COND_O, EFLAGS))]>,
1302 TB;
1303def CMOVNO16rm : I<0x41, MRMSrcMem, // if !overflow, GR16 = [mem16]
1304 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1305 "cmovno\t{$src2, $dst|$dst, $src2}",
1306 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1307 X86_COND_NO, EFLAGS))]>,
1308 TB, OpSize;
1309def CMOVNO32rm : I<0x41, MRMSrcMem, // if !overflow, GR32 = [mem32]
1310 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1311 "cmovno\t{$src2, $dst|$dst, $src2}",
1312 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1313 X86_COND_NO, EFLAGS))]>,
1314 TB;
Evan Cheng950aac02007-09-25 01:57:46 +00001315} // Uses = [EFLAGS]
1316
1317
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001318// unary instructions
1319let CodeSize = 2 in {
Evan Cheng55687072007-09-14 21:48:26 +00001320let Defs = [EFLAGS] in {
Dan Gohman91888f02007-07-31 20:11:57 +00001321def NEG8r : I<0xF6, MRM3r, (outs GR8 :$dst), (ins GR8 :$src), "neg{b}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001322 [(set GR8:$dst, (ineg GR8:$src)),
1323 (implicit EFLAGS)]>;
Dan Gohman91888f02007-07-31 20:11:57 +00001324def NEG16r : I<0xF7, MRM3r, (outs GR16:$dst), (ins GR16:$src), "neg{w}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001325 [(set GR16:$dst, (ineg GR16:$src)),
1326 (implicit EFLAGS)]>, OpSize;
Dan Gohman91888f02007-07-31 20:11:57 +00001327def NEG32r : I<0xF7, MRM3r, (outs GR32:$dst), (ins GR32:$src), "neg{l}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001328 [(set GR32:$dst, (ineg GR32:$src)),
1329 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001330let isTwoAddress = 0 in {
Dan Gohman91888f02007-07-31 20:11:57 +00001331 def NEG8m : I<0xF6, MRM3m, (outs), (ins i8mem :$dst), "neg{b}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001332 [(store (ineg (loadi8 addr:$dst)), addr:$dst),
1333 (implicit EFLAGS)]>;
Dan Gohman91888f02007-07-31 20:11:57 +00001334 def NEG16m : I<0xF7, MRM3m, (outs), (ins i16mem:$dst), "neg{w}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001335 [(store (ineg (loadi16 addr:$dst)), addr:$dst),
1336 (implicit EFLAGS)]>, OpSize;
Dan Gohman91888f02007-07-31 20:11:57 +00001337 def NEG32m : I<0xF7, MRM3m, (outs), (ins i32mem:$dst), "neg{l}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001338 [(store (ineg (loadi32 addr:$dst)), addr:$dst),
1339 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001340}
Evan Cheng55687072007-09-14 21:48:26 +00001341} // Defs = [EFLAGS]
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001342
Evan Chengc6cee682009-01-21 02:09:05 +00001343// Match xor -1 to not. Favors these over a move imm + xor to save code size.
1344let AddedComplexity = 15 in {
Dan Gohman91888f02007-07-31 20:11:57 +00001345def NOT8r : I<0xF6, MRM2r, (outs GR8 :$dst), (ins GR8 :$src), "not{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001346 [(set GR8:$dst, (not GR8:$src))]>;
Dan Gohman91888f02007-07-31 20:11:57 +00001347def NOT16r : I<0xF7, MRM2r, (outs GR16:$dst), (ins GR16:$src), "not{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001348 [(set GR16:$dst, (not GR16:$src))]>, OpSize;
Dan Gohman91888f02007-07-31 20:11:57 +00001349def NOT32r : I<0xF7, MRM2r, (outs GR32:$dst), (ins GR32:$src), "not{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001350 [(set GR32:$dst, (not GR32:$src))]>;
Evan Chengc6cee682009-01-21 02:09:05 +00001351}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001352let isTwoAddress = 0 in {
Dan Gohman91888f02007-07-31 20:11:57 +00001353 def NOT8m : I<0xF6, MRM2m, (outs), (ins i8mem :$dst), "not{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001354 [(store (not (loadi8 addr:$dst)), addr:$dst)]>;
Dan Gohman91888f02007-07-31 20:11:57 +00001355 def NOT16m : I<0xF7, MRM2m, (outs), (ins i16mem:$dst), "not{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001356 [(store (not (loadi16 addr:$dst)), addr:$dst)]>, OpSize;
Dan Gohman91888f02007-07-31 20:11:57 +00001357 def NOT32m : I<0xF7, MRM2m, (outs), (ins i32mem:$dst), "not{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001358 [(store (not (loadi32 addr:$dst)), addr:$dst)]>;
1359}
1360} // CodeSize
1361
1362// TODO: inc/dec is slow for P4, but fast for Pentium-M.
Evan Cheng55687072007-09-14 21:48:26 +00001363let Defs = [EFLAGS] in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001364let CodeSize = 2 in
Dan Gohman91888f02007-07-31 20:11:57 +00001365def INC8r : I<0xFE, MRM0r, (outs GR8 :$dst), (ins GR8 :$src), "inc{b}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001366 [(set GR8:$dst, (add GR8:$src, 1)),
1367 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001368let isConvertibleToThreeAddress = 1, CodeSize = 1 in { // Can xform into LEA.
Dan Gohman91888f02007-07-31 20:11:57 +00001369def INC16r : I<0x40, AddRegFrm, (outs GR16:$dst), (ins GR16:$src), "inc{w}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001370 [(set GR16:$dst, (add GR16:$src, 1)),
1371 (implicit EFLAGS)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001372 OpSize, Requires<[In32BitMode]>;
Dan Gohman91888f02007-07-31 20:11:57 +00001373def INC32r : I<0x40, AddRegFrm, (outs GR32:$dst), (ins GR32:$src), "inc{l}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001374 [(set GR32:$dst, (add GR32:$src, 1)),
1375 (implicit EFLAGS)]>, Requires<[In32BitMode]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001376}
1377let isTwoAddress = 0, CodeSize = 2 in {
Dan Gohman91888f02007-07-31 20:11:57 +00001378 def INC8m : I<0xFE, MRM0m, (outs), (ins i8mem :$dst), "inc{b}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001379 [(store (add (loadi8 addr:$dst), 1), addr:$dst),
1380 (implicit EFLAGS)]>;
Dan Gohman91888f02007-07-31 20:11:57 +00001381 def INC16m : I<0xFF, MRM0m, (outs), (ins i16mem:$dst), "inc{w}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001382 [(store (add (loadi16 addr:$dst), 1), addr:$dst),
1383 (implicit EFLAGS)]>,
Evan Cheng4a7e72f2007-10-19 21:23:22 +00001384 OpSize, Requires<[In32BitMode]>;
Dan Gohman91888f02007-07-31 20:11:57 +00001385 def INC32m : I<0xFF, MRM0m, (outs), (ins i32mem:$dst), "inc{l}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001386 [(store (add (loadi32 addr:$dst), 1), addr:$dst),
1387 (implicit EFLAGS)]>,
Evan Cheng4a7e72f2007-10-19 21:23:22 +00001388 Requires<[In32BitMode]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001389}
1390
1391let CodeSize = 2 in
Dan Gohman91888f02007-07-31 20:11:57 +00001392def DEC8r : I<0xFE, MRM1r, (outs GR8 :$dst), (ins GR8 :$src), "dec{b}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001393 [(set GR8:$dst, (add GR8:$src, -1)),
1394 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001395let isConvertibleToThreeAddress = 1, CodeSize = 1 in { // Can xform into LEA.
Dan Gohman91888f02007-07-31 20:11:57 +00001396def DEC16r : I<0x48, AddRegFrm, (outs GR16:$dst), (ins GR16:$src), "dec{w}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001397 [(set GR16:$dst, (add GR16:$src, -1)),
1398 (implicit EFLAGS)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001399 OpSize, Requires<[In32BitMode]>;
Dan Gohman91888f02007-07-31 20:11:57 +00001400def DEC32r : I<0x48, AddRegFrm, (outs GR32:$dst), (ins GR32:$src), "dec{l}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001401 [(set GR32:$dst, (add GR32:$src, -1)),
1402 (implicit EFLAGS)]>, Requires<[In32BitMode]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001403}
1404
1405let isTwoAddress = 0, CodeSize = 2 in {
Dan Gohman91888f02007-07-31 20:11:57 +00001406 def DEC8m : I<0xFE, MRM1m, (outs), (ins i8mem :$dst), "dec{b}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001407 [(store (add (loadi8 addr:$dst), -1), addr:$dst),
1408 (implicit EFLAGS)]>;
Dan Gohman91888f02007-07-31 20:11:57 +00001409 def DEC16m : I<0xFF, MRM1m, (outs), (ins i16mem:$dst), "dec{w}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001410 [(store (add (loadi16 addr:$dst), -1), addr:$dst),
1411 (implicit EFLAGS)]>,
Evan Cheng4a7e72f2007-10-19 21:23:22 +00001412 OpSize, Requires<[In32BitMode]>;
Dan Gohman91888f02007-07-31 20:11:57 +00001413 def DEC32m : I<0xFF, MRM1m, (outs), (ins i32mem:$dst), "dec{l}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001414 [(store (add (loadi32 addr:$dst), -1), addr:$dst),
1415 (implicit EFLAGS)]>,
Evan Cheng4a7e72f2007-10-19 21:23:22 +00001416 Requires<[In32BitMode]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001417}
Evan Cheng55687072007-09-14 21:48:26 +00001418} // Defs = [EFLAGS]
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001419
1420// Logical operators...
Evan Cheng55687072007-09-14 21:48:26 +00001421let Defs = [EFLAGS] in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001422let isCommutable = 1 in { // X = AND Y, Z --> X = AND Z, Y
1423def AND8rr : I<0x20, MRMDestReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001424 (outs GR8 :$dst), (ins GR8 :$src1, GR8 :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001425 "and{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001426 [(set GR8:$dst, (and GR8:$src1, GR8:$src2)),
1427 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001428def AND16rr : I<0x21, MRMDestReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001429 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001430 "and{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001431 [(set GR16:$dst, (and GR16:$src1, GR16:$src2)),
1432 (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001433def AND32rr : I<0x21, MRMDestReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001434 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001435 "and{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001436 [(set GR32:$dst, (and GR32:$src1, GR32:$src2)),
1437 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001438}
1439
1440def AND8rm : I<0x22, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001441 (outs GR8 :$dst), (ins GR8 :$src1, i8mem :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001442 "and{b}\t{$src2, $dst|$dst, $src2}",
Chris Lattner12208612009-04-10 00:16:23 +00001443 [(set GR8:$dst, (and GR8:$src1, (loadi8 addr:$src2))),
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001444 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001445def AND16rm : I<0x23, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001446 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001447 "and{w}\t{$src2, $dst|$dst, $src2}",
Chris Lattner12208612009-04-10 00:16:23 +00001448 [(set GR16:$dst, (and GR16:$src1, (loadi16 addr:$src2))),
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001449 (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001450def AND32rm : I<0x23, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001451 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001452 "and{l}\t{$src2, $dst|$dst, $src2}",
Chris Lattner12208612009-04-10 00:16:23 +00001453 [(set GR32:$dst, (and GR32:$src1, (loadi32 addr:$src2))),
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001454 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001455
1456def AND8ri : Ii8<0x80, MRM4r,
Evan Chengb783fa32007-07-19 01:14:50 +00001457 (outs GR8 :$dst), (ins GR8 :$src1, i8imm :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001458 "and{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001459 [(set GR8:$dst, (and GR8:$src1, imm:$src2)),
1460 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001461def AND16ri : Ii16<0x81, MRM4r,
Evan Chengb783fa32007-07-19 01:14:50 +00001462 (outs GR16:$dst), (ins GR16:$src1, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001463 "and{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001464 [(set GR16:$dst, (and GR16:$src1, imm:$src2)),
1465 (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001466def AND32ri : Ii32<0x81, MRM4r,
Evan Chengb783fa32007-07-19 01:14:50 +00001467 (outs GR32:$dst), (ins GR32:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001468 "and{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001469 [(set GR32:$dst, (and GR32:$src1, imm:$src2)),
1470 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001471def AND16ri8 : Ii8<0x83, MRM4r,
Evan Chengb783fa32007-07-19 01:14:50 +00001472 (outs GR16:$dst), (ins GR16:$src1, i16i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001473 "and{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001474 [(set GR16:$dst, (and GR16:$src1, i16immSExt8:$src2)),
1475 (implicit EFLAGS)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001476 OpSize;
1477def AND32ri8 : Ii8<0x83, MRM4r,
Evan Chengb783fa32007-07-19 01:14:50 +00001478 (outs GR32:$dst), (ins GR32:$src1, i32i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001479 "and{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001480 [(set GR32:$dst, (and GR32:$src1, i32immSExt8:$src2)),
1481 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001482
1483let isTwoAddress = 0 in {
1484 def AND8mr : I<0x20, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001485 (outs), (ins i8mem :$dst, GR8 :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001486 "and{b}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001487 [(store (and (load addr:$dst), GR8:$src), addr:$dst),
1488 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001489 def AND16mr : I<0x21, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001490 (outs), (ins i16mem:$dst, GR16:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001491 "and{w}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001492 [(store (and (load addr:$dst), GR16:$src), addr:$dst),
1493 (implicit EFLAGS)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001494 OpSize;
1495 def AND32mr : I<0x21, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001496 (outs), (ins i32mem:$dst, GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001497 "and{l}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001498 [(store (and (load addr:$dst), GR32:$src), addr:$dst),
1499 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001500 def AND8mi : Ii8<0x80, MRM4m,
Evan Chengb783fa32007-07-19 01:14:50 +00001501 (outs), (ins i8mem :$dst, i8imm :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001502 "and{b}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001503 [(store (and (loadi8 addr:$dst), imm:$src), addr:$dst),
1504 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001505 def AND16mi : Ii16<0x81, MRM4m,
Evan Chengb783fa32007-07-19 01:14:50 +00001506 (outs), (ins i16mem:$dst, i16imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001507 "and{w}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001508 [(store (and (loadi16 addr:$dst), imm:$src), addr:$dst),
1509 (implicit EFLAGS)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001510 OpSize;
1511 def AND32mi : Ii32<0x81, MRM4m,
Evan Chengb783fa32007-07-19 01:14:50 +00001512 (outs), (ins i32mem:$dst, i32imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001513 "and{l}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001514 [(store (and (loadi32 addr:$dst), imm:$src), addr:$dst),
1515 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001516 def AND16mi8 : Ii8<0x83, MRM4m,
Evan Chengb783fa32007-07-19 01:14:50 +00001517 (outs), (ins i16mem:$dst, i16i8imm :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001518 "and{w}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001519 [(store (and (load addr:$dst), i16immSExt8:$src), addr:$dst),
1520 (implicit EFLAGS)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001521 OpSize;
1522 def AND32mi8 : Ii8<0x83, MRM4m,
Evan Chengb783fa32007-07-19 01:14:50 +00001523 (outs), (ins i32mem:$dst, i32i8imm :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001524 "and{l}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001525 [(store (and (load addr:$dst), i32immSExt8:$src), addr:$dst),
1526 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001527}
1528
1529
1530let isCommutable = 1 in { // X = OR Y, Z --> X = OR Z, Y
Evan Chengb783fa32007-07-19 01:14:50 +00001531def OR8rr : I<0x08, MRMDestReg, (outs GR8 :$dst), (ins GR8 :$src1, GR8 :$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, GR8:$src2)),
1534 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001535def OR16rr : I<0x09, MRMDestReg, (outs GR16:$dst), (ins GR16:$src1, GR16:$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, GR16:$src2)),
1538 (implicit EFLAGS)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001539def OR32rr : I<0x09, MRMDestReg, (outs GR32:$dst), (ins GR32:$src1, GR32:$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, GR32:$src2)),
1542 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001543}
Evan Chengb783fa32007-07-19 01:14:50 +00001544def OR8rm : I<0x0A, MRMSrcMem , (outs GR8 :$dst), (ins GR8 :$src1, i8mem :$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, (load addr:$src2))),
1547 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001548def OR16rm : I<0x0B, MRMSrcMem , (outs GR16:$dst), (ins GR16:$src1, i16mem:$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, (load addr:$src2))),
1551 (implicit EFLAGS)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001552def OR32rm : I<0x0B, MRMSrcMem , (outs GR32:$dst), (ins GR32:$src1, i32mem:$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, (load addr:$src2))),
1555 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001556
Evan Chengb783fa32007-07-19 01:14:50 +00001557def OR8ri : Ii8 <0x80, MRM1r, (outs GR8 :$dst), (ins GR8 :$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001558 "or{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001559 [(set GR8:$dst, (or GR8:$src1, imm:$src2)),
1560 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001561def OR16ri : Ii16<0x81, MRM1r, (outs GR16:$dst), (ins GR16:$src1, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001562 "or{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001563 [(set GR16:$dst, (or GR16:$src1, imm:$src2)),
1564 (implicit EFLAGS)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001565def OR32ri : Ii32<0x81, MRM1r, (outs GR32:$dst), (ins GR32:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001566 "or{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001567 [(set GR32:$dst, (or GR32:$src1, imm:$src2)),
1568 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001569
Evan Chengb783fa32007-07-19 01:14:50 +00001570def OR16ri8 : Ii8<0x83, MRM1r, (outs GR16:$dst), (ins GR16:$src1, i16i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001571 "or{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001572 [(set GR16:$dst, (or GR16:$src1, i16immSExt8:$src2)),
1573 (implicit EFLAGS)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001574def OR32ri8 : Ii8<0x83, MRM1r, (outs GR32:$dst), (ins GR32:$src1, i32i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001575 "or{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001576 [(set GR32:$dst, (or GR32:$src1, i32immSExt8:$src2)),
1577 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001578let isTwoAddress = 0 in {
Evan Chengb783fa32007-07-19 01:14:50 +00001579 def OR8mr : I<0x08, MRMDestMem, (outs), (ins i8mem:$dst, GR8:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001580 "or{b}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001581 [(store (or (load addr:$dst), GR8:$src), addr:$dst),
1582 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001583 def OR16mr : I<0x09, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001584 "or{w}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001585 [(store (or (load addr:$dst), GR16:$src), addr:$dst),
1586 (implicit EFLAGS)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001587 def OR32mr : I<0x09, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$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 (load addr:$dst), GR32:$src), addr:$dst),
1590 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001591 def OR8mi : Ii8<0x80, MRM1m, (outs), (ins i8mem :$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001592 "or{b}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001593 [(store (or (loadi8 addr:$dst), imm:$src), addr:$dst),
1594 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001595 def OR16mi : Ii16<0x81, MRM1m, (outs), (ins i16mem:$dst, i16imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001596 "or{w}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001597 [(store (or (loadi16 addr:$dst), imm:$src), addr:$dst),
1598 (implicit EFLAGS)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001599 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001600 def OR32mi : Ii32<0x81, MRM1m, (outs), (ins i32mem:$dst, i32imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001601 "or{l}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001602 [(store (or (loadi32 addr:$dst), imm:$src), addr:$dst),
1603 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001604 def OR16mi8 : Ii8<0x83, MRM1m, (outs), (ins i16mem:$dst, i16i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001605 "or{w}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001606 [(store (or (load addr:$dst), i16immSExt8:$src), addr:$dst),
1607 (implicit EFLAGS)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001608 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001609 def OR32mi8 : Ii8<0x83, MRM1m, (outs), (ins i32mem:$dst, i32i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001610 "or{l}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001611 [(store (or (load addr:$dst), i32immSExt8:$src), addr:$dst),
1612 (implicit EFLAGS)]>;
Bill Wendlingba5d5b02008-05-29 01:02:09 +00001613} // isTwoAddress = 0
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001614
1615
Evan Cheng6f26e8b2008-06-18 08:13:07 +00001616let isCommutable = 1 in { // X = XOR Y, Z --> X = XOR Z, Y
Bill Wendlingba5d5b02008-05-29 01:02:09 +00001617 def XOR8rr : I<0x30, MRMDestReg,
1618 (outs GR8 :$dst), (ins GR8 :$src1, GR8 :$src2),
1619 "xor{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001620 [(set GR8:$dst, (xor GR8:$src1, GR8:$src2)),
1621 (implicit EFLAGS)]>;
Bill Wendlingba5d5b02008-05-29 01:02:09 +00001622 def XOR16rr : I<0x31, MRMDestReg,
1623 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
1624 "xor{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001625 [(set GR16:$dst, (xor GR16:$src1, GR16:$src2)),
1626 (implicit EFLAGS)]>, OpSize;
Bill Wendlingba5d5b02008-05-29 01:02:09 +00001627 def XOR32rr : I<0x31, MRMDestReg,
1628 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
1629 "xor{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001630 [(set GR32:$dst, (xor GR32:$src1, GR32:$src2)),
1631 (implicit EFLAGS)]>;
Evan Cheng6f26e8b2008-06-18 08:13:07 +00001632} // isCommutable = 1
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001633
1634def XOR8rm : I<0x32, MRMSrcMem ,
Evan Chengb783fa32007-07-19 01:14:50 +00001635 (outs GR8 :$dst), (ins GR8:$src1, i8mem :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001636 "xor{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001637 [(set GR8:$dst, (xor GR8:$src1, (load addr:$src2))),
1638 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001639def XOR16rm : I<0x33, MRMSrcMem ,
Evan Chengb783fa32007-07-19 01:14:50 +00001640 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001641 "xor{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001642 [(set GR16:$dst, (xor GR16:$src1, (load addr:$src2))),
1643 (implicit EFLAGS)]>,
Bill Wendlingba5d5b02008-05-29 01:02:09 +00001644 OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001645def XOR32rm : I<0x33, MRMSrcMem ,
Evan Chengb783fa32007-07-19 01:14:50 +00001646 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001647 "xor{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001648 [(set GR32:$dst, (xor GR32:$src1, (load addr:$src2))),
1649 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001650
Bill Wendlingbac38eb2008-05-29 03:46:36 +00001651def XOR8ri : Ii8<0x80, MRM6r,
1652 (outs GR8:$dst), (ins GR8:$src1, i8imm:$src2),
1653 "xor{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001654 [(set GR8:$dst, (xor GR8:$src1, imm:$src2)),
1655 (implicit EFLAGS)]>;
Bill Wendlingbac38eb2008-05-29 03:46:36 +00001656def XOR16ri : Ii16<0x81, MRM6r,
1657 (outs GR16:$dst), (ins GR16:$src1, i16imm:$src2),
1658 "xor{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001659 [(set GR16:$dst, (xor GR16:$src1, imm:$src2)),
1660 (implicit EFLAGS)]>, OpSize;
Bill Wendlingbac38eb2008-05-29 03:46:36 +00001661def XOR32ri : Ii32<0x81, MRM6r,
1662 (outs GR32:$dst), (ins GR32:$src1, i32imm:$src2),
1663 "xor{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001664 [(set GR32:$dst, (xor GR32:$src1, imm:$src2)),
1665 (implicit EFLAGS)]>;
Bill Wendlingbac38eb2008-05-29 03:46:36 +00001666def XOR16ri8 : Ii8<0x83, MRM6r,
1667 (outs GR16:$dst), (ins GR16:$src1, i16i8imm:$src2),
1668 "xor{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001669 [(set GR16:$dst, (xor GR16:$src1, i16immSExt8:$src2)),
1670 (implicit EFLAGS)]>,
Bill Wendlingbac38eb2008-05-29 03:46:36 +00001671 OpSize;
1672def XOR32ri8 : Ii8<0x83, MRM6r,
1673 (outs GR32:$dst), (ins GR32:$src1, i32i8imm:$src2),
1674 "xor{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001675 [(set GR32:$dst, (xor GR32:$src1, i32immSExt8:$src2)),
1676 (implicit EFLAGS)]>;
Bill Wendlingba5d5b02008-05-29 01:02:09 +00001677
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001678let isTwoAddress = 0 in {
1679 def XOR8mr : I<0x30, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001680 (outs), (ins i8mem :$dst, GR8 :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001681 "xor{b}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001682 [(store (xor (load addr:$dst), GR8:$src), addr:$dst),
1683 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001684 def XOR16mr : I<0x31, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001685 (outs), (ins i16mem:$dst, GR16:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001686 "xor{w}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001687 [(store (xor (load addr:$dst), GR16:$src), addr:$dst),
1688 (implicit EFLAGS)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001689 OpSize;
1690 def XOR32mr : I<0x31, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001691 (outs), (ins i32mem:$dst, GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001692 "xor{l}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001693 [(store (xor (load addr:$dst), GR32:$src), addr:$dst),
1694 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001695 def XOR8mi : Ii8<0x80, MRM6m,
Evan Chengb783fa32007-07-19 01:14:50 +00001696 (outs), (ins i8mem :$dst, i8imm :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001697 "xor{b}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001698 [(store (xor (loadi8 addr:$dst), imm:$src), addr:$dst),
1699 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001700 def XOR16mi : Ii16<0x81, MRM6m,
Evan Chengb783fa32007-07-19 01:14:50 +00001701 (outs), (ins i16mem:$dst, i16imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001702 "xor{w}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001703 [(store (xor (loadi16 addr:$dst), imm:$src), addr:$dst),
1704 (implicit EFLAGS)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001705 OpSize;
1706 def XOR32mi : Ii32<0x81, MRM6m,
Evan Chengb783fa32007-07-19 01:14:50 +00001707 (outs), (ins i32mem:$dst, i32imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001708 "xor{l}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001709 [(store (xor (loadi32 addr:$dst), imm:$src), addr:$dst),
1710 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001711 def XOR16mi8 : Ii8<0x83, MRM6m,
Evan Chengb783fa32007-07-19 01:14:50 +00001712 (outs), (ins i16mem:$dst, i16i8imm :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001713 "xor{w}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001714 [(store (xor (load addr:$dst), i16immSExt8:$src), addr:$dst),
1715 (implicit EFLAGS)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001716 OpSize;
1717 def XOR32mi8 : Ii8<0x83, MRM6m,
Evan Chengb783fa32007-07-19 01:14:50 +00001718 (outs), (ins i32mem:$dst, i32i8imm :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001719 "xor{l}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001720 [(store (xor (load addr:$dst), i32immSExt8:$src), addr:$dst),
1721 (implicit EFLAGS)]>;
Bill Wendlingba5d5b02008-05-29 01:02:09 +00001722} // isTwoAddress = 0
Evan Cheng55687072007-09-14 21:48:26 +00001723} // Defs = [EFLAGS]
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001724
1725// Shift instructions
Evan Cheng55687072007-09-14 21:48:26 +00001726let Defs = [EFLAGS] in {
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001727let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00001728def SHL8rCL : I<0xD2, MRM4r, (outs GR8 :$dst), (ins GR8 :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001729 "shl{b}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001730 [(set GR8:$dst, (shl GR8:$src, CL))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001731def SHL16rCL : I<0xD3, MRM4r, (outs GR16:$dst), (ins GR16:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001732 "shl{w}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001733 [(set GR16:$dst, (shl GR16:$src, CL))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001734def SHL32rCL : I<0xD3, MRM4r, (outs GR32:$dst), (ins GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001735 "shl{l}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001736 [(set GR32:$dst, (shl GR32:$src, CL))]>;
Bill Wendlingba5d5b02008-05-29 01:02:09 +00001737} // Uses = [CL]
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001738
Evan Chengb783fa32007-07-19 01:14:50 +00001739def SHL8ri : Ii8<0xC0, MRM4r, (outs GR8 :$dst), (ins GR8 :$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001740 "shl{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001741 [(set GR8:$dst, (shl GR8:$src1, (i8 imm:$src2)))]>;
1742let isConvertibleToThreeAddress = 1 in { // Can transform into LEA.
Evan Chengb783fa32007-07-19 01:14:50 +00001743def SHL16ri : Ii8<0xC1, MRM4r, (outs GR16:$dst), (ins GR16:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001744 "shl{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001745 [(set GR16:$dst, (shl GR16:$src1, (i8 imm:$src2)))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001746def SHL32ri : Ii8<0xC1, MRM4r, (outs GR32:$dst), (ins GR32:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001747 "shl{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001748 [(set GR32:$dst, (shl GR32:$src1, (i8 imm:$src2)))]>;
Chris Lattnerf4005a82008-01-11 18:00:50 +00001749// NOTE: We don't use shifts of a register by one, because 'add reg,reg' is
1750// cheaper.
Bill Wendlingba5d5b02008-05-29 01:02:09 +00001751} // isConvertibleToThreeAddress = 1
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001752
1753let isTwoAddress = 0 in {
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001754 let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00001755 def SHL8mCL : I<0xD2, MRM4m, (outs), (ins i8mem :$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001756 "shl{b}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001757 [(store (shl (loadi8 addr:$dst), CL), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001758 def SHL16mCL : I<0xD3, MRM4m, (outs), (ins i16mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001759 "shl{w}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001760 [(store (shl (loadi16 addr:$dst), CL), addr:$dst)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001761 def SHL32mCL : I<0xD3, MRM4m, (outs), (ins i32mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001762 "shl{l}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001763 [(store (shl (loadi32 addr:$dst), CL), addr:$dst)]>;
1764 }
Evan Chengb783fa32007-07-19 01:14:50 +00001765 def SHL8mi : Ii8<0xC0, MRM4m, (outs), (ins i8mem :$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001766 "shl{b}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001767 [(store (shl (loadi8 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001768 def SHL16mi : Ii8<0xC1, MRM4m, (outs), (ins i16mem:$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001769 "shl{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001770 [(store (shl (loadi16 addr:$dst), (i8 imm:$src)), addr:$dst)]>,
1771 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001772 def SHL32mi : Ii8<0xC1, MRM4m, (outs), (ins i32mem:$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001773 "shl{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001774 [(store (shl (loadi32 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
1775
1776 // Shift by 1
Evan Chengb783fa32007-07-19 01:14:50 +00001777 def SHL8m1 : I<0xD0, MRM4m, (outs), (ins i8mem :$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001778 "shl{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001779 [(store (shl (loadi8 addr:$dst), (i8 1)), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001780 def SHL16m1 : I<0xD1, MRM4m, (outs), (ins i16mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001781 "shl{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001782 [(store (shl (loadi16 addr:$dst), (i8 1)), addr:$dst)]>,
1783 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001784 def SHL32m1 : I<0xD1, MRM4m, (outs), (ins i32mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001785 "shl{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001786 [(store (shl (loadi32 addr:$dst), (i8 1)), addr:$dst)]>;
1787}
1788
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001789let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00001790def SHR8rCL : I<0xD2, MRM5r, (outs GR8 :$dst), (ins GR8 :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001791 "shr{b}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001792 [(set GR8:$dst, (srl GR8:$src, CL))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001793def SHR16rCL : I<0xD3, MRM5r, (outs GR16:$dst), (ins GR16:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001794 "shr{w}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001795 [(set GR16:$dst, (srl GR16:$src, CL))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001796def SHR32rCL : I<0xD3, MRM5r, (outs GR32:$dst), (ins GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001797 "shr{l}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001798 [(set GR32:$dst, (srl GR32:$src, CL))]>;
1799}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001800
Evan Chengb783fa32007-07-19 01:14:50 +00001801def SHR8ri : Ii8<0xC0, MRM5r, (outs GR8:$dst), (ins GR8:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001802 "shr{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001803 [(set GR8:$dst, (srl GR8:$src1, (i8 imm:$src2)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001804def SHR16ri : Ii8<0xC1, MRM5r, (outs GR16:$dst), (ins GR16:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001805 "shr{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001806 [(set GR16:$dst, (srl GR16:$src1, (i8 imm:$src2)))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001807def SHR32ri : Ii8<0xC1, MRM5r, (outs GR32:$dst), (ins GR32:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001808 "shr{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001809 [(set GR32:$dst, (srl GR32:$src1, (i8 imm:$src2)))]>;
1810
1811// Shift by 1
Evan Chengb783fa32007-07-19 01:14:50 +00001812def SHR8r1 : I<0xD0, MRM5r, (outs GR8:$dst), (ins GR8:$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00001813 "shr{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001814 [(set GR8:$dst, (srl GR8:$src1, (i8 1)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001815def SHR16r1 : I<0xD1, MRM5r, (outs GR16:$dst), (ins GR16:$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00001816 "shr{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001817 [(set GR16:$dst, (srl GR16:$src1, (i8 1)))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001818def SHR32r1 : I<0xD1, MRM5r, (outs GR32:$dst), (ins GR32:$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00001819 "shr{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001820 [(set GR32:$dst, (srl GR32:$src1, (i8 1)))]>;
1821
1822let isTwoAddress = 0 in {
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001823 let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00001824 def SHR8mCL : I<0xD2, MRM5m, (outs), (ins i8mem :$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001825 "shr{b}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001826 [(store (srl (loadi8 addr:$dst), CL), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001827 def SHR16mCL : I<0xD3, MRM5m, (outs), (ins i16mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001828 "shr{w}\t{%cl, $dst|$dst, %CL}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001829 [(store (srl (loadi16 addr:$dst), CL), addr:$dst)]>,
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001830 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001831 def SHR32mCL : I<0xD3, MRM5m, (outs), (ins i32mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001832 "shr{l}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001833 [(store (srl (loadi32 addr:$dst), CL), addr:$dst)]>;
1834 }
Evan Chengb783fa32007-07-19 01:14:50 +00001835 def SHR8mi : Ii8<0xC0, MRM5m, (outs), (ins i8mem :$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001836 "shr{b}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001837 [(store (srl (loadi8 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001838 def SHR16mi : Ii8<0xC1, MRM5m, (outs), (ins i16mem:$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001839 "shr{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001840 [(store (srl (loadi16 addr:$dst), (i8 imm:$src)), addr:$dst)]>,
1841 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001842 def SHR32mi : Ii8<0xC1, MRM5m, (outs), (ins i32mem:$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001843 "shr{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001844 [(store (srl (loadi32 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
1845
1846 // Shift by 1
Evan Chengb783fa32007-07-19 01:14:50 +00001847 def SHR8m1 : I<0xD0, MRM5m, (outs), (ins i8mem :$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001848 "shr{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001849 [(store (srl (loadi8 addr:$dst), (i8 1)), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001850 def SHR16m1 : I<0xD1, MRM5m, (outs), (ins i16mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001851 "shr{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001852 [(store (srl (loadi16 addr:$dst), (i8 1)), addr:$dst)]>,OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001853 def SHR32m1 : I<0xD1, MRM5m, (outs), (ins i32mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001854 "shr{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001855 [(store (srl (loadi32 addr:$dst), (i8 1)), addr:$dst)]>;
1856}
1857
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001858let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00001859def SAR8rCL : I<0xD2, MRM7r, (outs GR8 :$dst), (ins GR8 :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001860 "sar{b}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001861 [(set GR8:$dst, (sra GR8:$src, CL))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001862def SAR16rCL : I<0xD3, MRM7r, (outs GR16:$dst), (ins GR16:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001863 "sar{w}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001864 [(set GR16:$dst, (sra GR16:$src, CL))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001865def SAR32rCL : I<0xD3, MRM7r, (outs GR32:$dst), (ins GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001866 "sar{l}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001867 [(set GR32:$dst, (sra GR32:$src, CL))]>;
1868}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001869
Evan Chengb783fa32007-07-19 01:14:50 +00001870def SAR8ri : Ii8<0xC0, MRM7r, (outs GR8 :$dst), (ins GR8 :$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001871 "sar{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001872 [(set GR8:$dst, (sra GR8:$src1, (i8 imm:$src2)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001873def SAR16ri : Ii8<0xC1, MRM7r, (outs GR16:$dst), (ins GR16:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001874 "sar{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001875 [(set GR16:$dst, (sra GR16:$src1, (i8 imm:$src2)))]>,
1876 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001877def SAR32ri : Ii8<0xC1, MRM7r, (outs GR32:$dst), (ins GR32:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001878 "sar{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001879 [(set GR32:$dst, (sra GR32:$src1, (i8 imm:$src2)))]>;
1880
1881// Shift by 1
Evan Chengb783fa32007-07-19 01:14:50 +00001882def SAR8r1 : I<0xD0, MRM7r, (outs GR8 :$dst), (ins GR8 :$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00001883 "sar{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001884 [(set GR8:$dst, (sra GR8:$src1, (i8 1)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001885def SAR16r1 : I<0xD1, MRM7r, (outs GR16:$dst), (ins GR16:$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00001886 "sar{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001887 [(set GR16:$dst, (sra GR16:$src1, (i8 1)))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001888def SAR32r1 : I<0xD1, MRM7r, (outs GR32:$dst), (ins GR32:$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00001889 "sar{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001890 [(set GR32:$dst, (sra GR32:$src1, (i8 1)))]>;
1891
1892let isTwoAddress = 0 in {
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001893 let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00001894 def SAR8mCL : I<0xD2, MRM7m, (outs), (ins i8mem :$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001895 "sar{b}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001896 [(store (sra (loadi8 addr:$dst), CL), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001897 def SAR16mCL : I<0xD3, MRM7m, (outs), (ins i16mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001898 "sar{w}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001899 [(store (sra (loadi16 addr:$dst), CL), addr:$dst)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001900 def SAR32mCL : I<0xD3, MRM7m, (outs), (ins i32mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001901 "sar{l}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001902 [(store (sra (loadi32 addr:$dst), CL), addr:$dst)]>;
1903 }
Evan Chengb783fa32007-07-19 01:14:50 +00001904 def SAR8mi : Ii8<0xC0, MRM7m, (outs), (ins i8mem :$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001905 "sar{b}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001906 [(store (sra (loadi8 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001907 def SAR16mi : Ii8<0xC1, MRM7m, (outs), (ins i16mem:$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001908 "sar{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001909 [(store (sra (loadi16 addr:$dst), (i8 imm:$src)), addr:$dst)]>,
1910 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001911 def SAR32mi : Ii8<0xC1, MRM7m, (outs), (ins i32mem:$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001912 "sar{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001913 [(store (sra (loadi32 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
1914
1915 // Shift by 1
Evan Chengb783fa32007-07-19 01:14:50 +00001916 def SAR8m1 : I<0xD0, MRM7m, (outs), (ins i8mem :$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001917 "sar{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001918 [(store (sra (loadi8 addr:$dst), (i8 1)), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001919 def SAR16m1 : I<0xD1, MRM7m, (outs), (ins i16mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001920 "sar{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001921 [(store (sra (loadi16 addr:$dst), (i8 1)), addr:$dst)]>,
1922 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001923 def SAR32m1 : I<0xD1, MRM7m, (outs), (ins i32mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001924 "sar{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001925 [(store (sra (loadi32 addr:$dst), (i8 1)), addr:$dst)]>;
1926}
1927
1928// Rotate instructions
1929// FIXME: provide shorter instructions when imm8 == 1
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001930let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00001931def ROL8rCL : I<0xD2, MRM0r, (outs GR8 :$dst), (ins GR8 :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001932 "rol{b}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001933 [(set GR8:$dst, (rotl GR8:$src, CL))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001934def ROL16rCL : I<0xD3, MRM0r, (outs GR16:$dst), (ins GR16:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001935 "rol{w}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001936 [(set GR16:$dst, (rotl GR16:$src, CL))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001937def ROL32rCL : I<0xD3, MRM0r, (outs GR32:$dst), (ins GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001938 "rol{l}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001939 [(set GR32:$dst, (rotl GR32:$src, CL))]>;
1940}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001941
Evan Chengb783fa32007-07-19 01:14:50 +00001942def ROL8ri : Ii8<0xC0, MRM0r, (outs GR8 :$dst), (ins GR8 :$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001943 "rol{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001944 [(set GR8:$dst, (rotl GR8:$src1, (i8 imm:$src2)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001945def ROL16ri : Ii8<0xC1, MRM0r, (outs GR16:$dst), (ins GR16:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001946 "rol{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001947 [(set GR16:$dst, (rotl GR16:$src1, (i8 imm:$src2)))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001948def ROL32ri : Ii8<0xC1, MRM0r, (outs GR32:$dst), (ins GR32:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001949 "rol{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001950 [(set GR32:$dst, (rotl GR32:$src1, (i8 imm:$src2)))]>;
1951
1952// Rotate by 1
Evan Chengb783fa32007-07-19 01:14:50 +00001953def ROL8r1 : I<0xD0, MRM0r, (outs GR8 :$dst), (ins GR8 :$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00001954 "rol{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001955 [(set GR8:$dst, (rotl GR8:$src1, (i8 1)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001956def ROL16r1 : I<0xD1, MRM0r, (outs GR16:$dst), (ins GR16:$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00001957 "rol{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001958 [(set GR16:$dst, (rotl GR16:$src1, (i8 1)))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001959def ROL32r1 : I<0xD1, MRM0r, (outs GR32:$dst), (ins GR32:$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00001960 "rol{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001961 [(set GR32:$dst, (rotl GR32:$src1, (i8 1)))]>;
1962
1963let isTwoAddress = 0 in {
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001964 let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00001965 def ROL8mCL : I<0xD2, MRM0m, (outs), (ins i8mem :$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001966 "rol{b}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001967 [(store (rotl (loadi8 addr:$dst), CL), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001968 def ROL16mCL : I<0xD3, MRM0m, (outs), (ins i16mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001969 "rol{w}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001970 [(store (rotl (loadi16 addr:$dst), CL), addr:$dst)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001971 def ROL32mCL : I<0xD3, MRM0m, (outs), (ins i32mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001972 "rol{l}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001973 [(store (rotl (loadi32 addr:$dst), CL), addr:$dst)]>;
1974 }
Evan Chengb783fa32007-07-19 01:14:50 +00001975 def ROL8mi : Ii8<0xC0, MRM0m, (outs), (ins i8mem :$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001976 "rol{b}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001977 [(store (rotl (loadi8 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001978 def ROL16mi : Ii8<0xC1, MRM0m, (outs), (ins i16mem:$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001979 "rol{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001980 [(store (rotl (loadi16 addr:$dst), (i8 imm:$src)), addr:$dst)]>,
1981 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001982 def ROL32mi : Ii8<0xC1, MRM0m, (outs), (ins i32mem:$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001983 "rol{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001984 [(store (rotl (loadi32 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
1985
1986 // Rotate by 1
Evan Chengb783fa32007-07-19 01:14:50 +00001987 def ROL8m1 : I<0xD0, MRM0m, (outs), (ins i8mem :$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001988 "rol{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001989 [(store (rotl (loadi8 addr:$dst), (i8 1)), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001990 def ROL16m1 : I<0xD1, MRM0m, (outs), (ins i16mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001991 "rol{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001992 [(store (rotl (loadi16 addr:$dst), (i8 1)), addr:$dst)]>,
1993 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001994 def ROL32m1 : I<0xD1, MRM0m, (outs), (ins i32mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001995 "rol{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001996 [(store (rotl (loadi32 addr:$dst), (i8 1)), addr:$dst)]>;
1997}
1998
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001999let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00002000def ROR8rCL : I<0xD2, MRM1r, (outs GR8 :$dst), (ins GR8 :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002001 "ror{b}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002002 [(set GR8:$dst, (rotr GR8:$src, CL))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002003def ROR16rCL : I<0xD3, MRM1r, (outs GR16:$dst), (ins GR16:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002004 "ror{w}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002005 [(set GR16:$dst, (rotr GR16:$src, CL))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002006def ROR32rCL : I<0xD3, MRM1r, (outs GR32:$dst), (ins GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002007 "ror{l}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002008 [(set GR32:$dst, (rotr GR32:$src, CL))]>;
2009}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002010
Evan Chengb783fa32007-07-19 01:14:50 +00002011def ROR8ri : Ii8<0xC0, MRM1r, (outs GR8 :$dst), (ins GR8 :$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002012 "ror{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002013 [(set GR8:$dst, (rotr GR8:$src1, (i8 imm:$src2)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002014def ROR16ri : Ii8<0xC1, MRM1r, (outs GR16:$dst), (ins GR16:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002015 "ror{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002016 [(set GR16:$dst, (rotr GR16:$src1, (i8 imm:$src2)))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002017def ROR32ri : Ii8<0xC1, MRM1r, (outs GR32:$dst), (ins GR32:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002018 "ror{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002019 [(set GR32:$dst, (rotr GR32:$src1, (i8 imm:$src2)))]>;
2020
2021// Rotate by 1
Evan Chengb783fa32007-07-19 01:14:50 +00002022def ROR8r1 : I<0xD0, MRM1r, (outs GR8 :$dst), (ins GR8 :$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00002023 "ror{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002024 [(set GR8:$dst, (rotr GR8:$src1, (i8 1)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002025def ROR16r1 : I<0xD1, MRM1r, (outs GR16:$dst), (ins GR16:$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00002026 "ror{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002027 [(set GR16:$dst, (rotr GR16:$src1, (i8 1)))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002028def ROR32r1 : I<0xD1, MRM1r, (outs GR32:$dst), (ins GR32:$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00002029 "ror{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002030 [(set GR32:$dst, (rotr GR32:$src1, (i8 1)))]>;
2031
2032let isTwoAddress = 0 in {
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002033 let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00002034 def ROR8mCL : I<0xD2, MRM1m, (outs), (ins i8mem :$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002035 "ror{b}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002036 [(store (rotr (loadi8 addr:$dst), CL), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002037 def ROR16mCL : I<0xD3, MRM1m, (outs), (ins i16mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002038 "ror{w}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002039 [(store (rotr (loadi16 addr:$dst), CL), addr:$dst)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002040 def ROR32mCL : I<0xD3, MRM1m, (outs), (ins i32mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002041 "ror{l}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002042 [(store (rotr (loadi32 addr:$dst), CL), addr:$dst)]>;
2043 }
Evan Chengb783fa32007-07-19 01:14:50 +00002044 def ROR8mi : Ii8<0xC0, MRM1m, (outs), (ins i8mem :$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002045 "ror{b}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002046 [(store (rotr (loadi8 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002047 def ROR16mi : Ii8<0xC1, MRM1m, (outs), (ins i16mem:$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002048 "ror{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002049 [(store (rotr (loadi16 addr:$dst), (i8 imm:$src)), addr:$dst)]>,
2050 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002051 def ROR32mi : Ii8<0xC1, MRM1m, (outs), (ins i32mem:$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002052 "ror{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002053 [(store (rotr (loadi32 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
2054
2055 // Rotate by 1
Evan Chengb783fa32007-07-19 01:14:50 +00002056 def ROR8m1 : I<0xD0, MRM1m, (outs), (ins i8mem :$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002057 "ror{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002058 [(store (rotr (loadi8 addr:$dst), (i8 1)), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002059 def ROR16m1 : I<0xD1, MRM1m, (outs), (ins i16mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002060 "ror{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002061 [(store (rotr (loadi16 addr:$dst), (i8 1)), addr:$dst)]>,
2062 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002063 def ROR32m1 : I<0xD1, MRM1m, (outs), (ins i32mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002064 "ror{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002065 [(store (rotr (loadi32 addr:$dst), (i8 1)), addr:$dst)]>;
2066}
2067
2068
2069
2070// Double shift instructions (generalizations of rotate)
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002071let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00002072def SHLD32rrCL : I<0xA5, MRMDestReg, (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002073 "shld{l}\t{%cl, $src2, $dst|$dst, $src2, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002074 [(set GR32:$dst, (X86shld GR32:$src1, GR32:$src2, CL))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00002075def SHRD32rrCL : I<0xAD, MRMDestReg, (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002076 "shrd{l}\t{%cl, $src2, $dst|$dst, $src2, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002077 [(set GR32:$dst, (X86shrd GR32:$src1, GR32:$src2, CL))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00002078def SHLD16rrCL : I<0xA5, MRMDestReg, (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002079 "shld{w}\t{%cl, $src2, $dst|$dst, $src2, %CL}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002080 [(set GR16:$dst, (X86shld GR16:$src1, GR16:$src2, CL))]>,
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002081 TB, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002082def SHRD16rrCL : I<0xAD, MRMDestReg, (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002083 "shrd{w}\t{%cl, $src2, $dst|$dst, $src2, %CL}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002084 [(set GR16:$dst, (X86shrd GR16:$src1, GR16:$src2, CL))]>,
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002085 TB, OpSize;
2086}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002087
2088let isCommutable = 1 in { // These instructions commute to each other.
2089def SHLD32rri8 : Ii8<0xA4, MRMDestReg,
Evan Chengb783fa32007-07-19 01:14:50 +00002090 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2, i8imm:$src3),
Dan Gohman91888f02007-07-31 20:11:57 +00002091 "shld{l}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002092 [(set GR32:$dst, (X86shld GR32:$src1, GR32:$src2,
2093 (i8 imm:$src3)))]>,
2094 TB;
2095def SHRD32rri8 : Ii8<0xAC, MRMDestReg,
Evan Chengb783fa32007-07-19 01:14:50 +00002096 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2, i8imm:$src3),
Dan Gohman91888f02007-07-31 20:11:57 +00002097 "shrd{l}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002098 [(set GR32:$dst, (X86shrd GR32:$src1, GR32:$src2,
2099 (i8 imm:$src3)))]>,
2100 TB;
2101def SHLD16rri8 : Ii8<0xA4, MRMDestReg,
Evan Chengb783fa32007-07-19 01:14:50 +00002102 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2, i8imm:$src3),
Dan Gohman91888f02007-07-31 20:11:57 +00002103 "shld{w}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002104 [(set GR16:$dst, (X86shld GR16:$src1, GR16:$src2,
2105 (i8 imm:$src3)))]>,
2106 TB, OpSize;
2107def SHRD16rri8 : Ii8<0xAC, MRMDestReg,
Evan Chengb783fa32007-07-19 01:14:50 +00002108 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2, i8imm:$src3),
Dan Gohman91888f02007-07-31 20:11:57 +00002109 "shrd{w}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002110 [(set GR16:$dst, (X86shrd GR16:$src1, GR16:$src2,
2111 (i8 imm:$src3)))]>,
2112 TB, OpSize;
2113}
2114
2115let isTwoAddress = 0 in {
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002116 let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00002117 def SHLD32mrCL : I<0xA5, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002118 "shld{l}\t{%cl, $src2, $dst|$dst, $src2, %CL}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002119 [(store (X86shld (loadi32 addr:$dst), GR32:$src2, CL),
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002120 addr:$dst)]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00002121 def SHRD32mrCL : I<0xAD, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002122 "shrd{l}\t{%cl, $src2, $dst|$dst, $src2, %CL}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002123 [(store (X86shrd (loadi32 addr:$dst), GR32:$src2, CL),
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002124 addr:$dst)]>, TB;
2125 }
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002126 def SHLD32mri8 : Ii8<0xA4, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00002127 (outs), (ins i32mem:$dst, GR32:$src2, i8imm:$src3),
Dan Gohman91888f02007-07-31 20:11:57 +00002128 "shld{l}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002129 [(store (X86shld (loadi32 addr:$dst), GR32:$src2,
2130 (i8 imm:$src3)), addr:$dst)]>,
2131 TB;
2132 def SHRD32mri8 : Ii8<0xAC, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00002133 (outs), (ins i32mem:$dst, GR32:$src2, i8imm:$src3),
Dan Gohman91888f02007-07-31 20:11:57 +00002134 "shrd{l}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002135 [(store (X86shrd (loadi32 addr:$dst), GR32:$src2,
2136 (i8 imm:$src3)), addr:$dst)]>,
2137 TB;
2138
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002139 let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00002140 def SHLD16mrCL : I<0xA5, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002141 "shld{w}\t{%cl, $src2, $dst|$dst, $src2, %CL}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002142 [(store (X86shld (loadi16 addr:$dst), GR16:$src2, CL),
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002143 addr:$dst)]>, TB, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002144 def SHRD16mrCL : I<0xAD, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002145 "shrd{w}\t{%cl, $src2, $dst|$dst, $src2, %CL}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002146 [(store (X86shrd (loadi16 addr:$dst), GR16:$src2, CL),
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002147 addr:$dst)]>, TB, OpSize;
2148 }
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002149 def SHLD16mri8 : Ii8<0xA4, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00002150 (outs), (ins i16mem:$dst, GR16:$src2, i8imm:$src3),
Dan Gohman91888f02007-07-31 20:11:57 +00002151 "shld{w}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002152 [(store (X86shld (loadi16 addr:$dst), GR16:$src2,
2153 (i8 imm:$src3)), addr:$dst)]>,
2154 TB, OpSize;
2155 def SHRD16mri8 : Ii8<0xAC, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00002156 (outs), (ins i16mem:$dst, GR16:$src2, i8imm:$src3),
Dan Gohman91888f02007-07-31 20:11:57 +00002157 "shrd{w}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002158 [(store (X86shrd (loadi16 addr:$dst), GR16:$src2,
2159 (i8 imm:$src3)), addr:$dst)]>,
2160 TB, OpSize;
2161}
Evan Cheng55687072007-09-14 21:48:26 +00002162} // Defs = [EFLAGS]
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002163
2164
2165// Arithmetic.
Evan Cheng55687072007-09-14 21:48:26 +00002166let Defs = [EFLAGS] in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002167let isCommutable = 1 in { // X = ADD Y, Z --> X = ADD Z, Y
Bill Wendlingae034ed2008-12-12 00:56:36 +00002168// Register-Register Addition
2169def ADD8rr : I<0x00, MRMDestReg, (outs GR8 :$dst),
2170 (ins GR8 :$src1, GR8 :$src2),
2171 "add{b}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002172 [(set GR8:$dst, (add GR8:$src1, GR8:$src2)),
Bill Wendlingae034ed2008-12-12 00:56:36 +00002173 (implicit EFLAGS)]>;
2174
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002175let isConvertibleToThreeAddress = 1 in { // Can transform into LEA.
Bill Wendlingae034ed2008-12-12 00:56:36 +00002176// Register-Register Addition
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002177def ADD16rr : I<0x01, MRMDestReg, (outs GR16:$dst),
2178 (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002179 "add{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002180 [(set GR16:$dst, (add GR16:$src1, GR16:$src2)),
2181 (implicit EFLAGS)]>, OpSize;
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002182def ADD32rr : I<0x01, MRMDestReg, (outs GR32:$dst),
2183 (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002184 "add{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002185 [(set GR32:$dst, (add GR32:$src1, GR32:$src2)),
2186 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002187} // end isConvertibleToThreeAddress
2188} // end isCommutable
Bill Wendlingae034ed2008-12-12 00:56:36 +00002189
2190// Register-Memory Addition
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002191def ADD8rm : I<0x02, MRMSrcMem, (outs GR8 :$dst),
2192 (ins GR8 :$src1, i8mem :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002193 "add{b}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002194 [(set GR8:$dst, (add GR8:$src1, (load addr:$src2))),
2195 (implicit EFLAGS)]>;
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002196def ADD16rm : I<0x03, MRMSrcMem, (outs GR16:$dst),
2197 (ins GR16:$src1, i16mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002198 "add{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002199 [(set GR16:$dst, (add GR16:$src1, (load addr:$src2))),
2200 (implicit EFLAGS)]>, OpSize;
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002201def ADD32rm : I<0x03, MRMSrcMem, (outs GR32:$dst),
2202 (ins GR32:$src1, i32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002203 "add{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002204 [(set GR32:$dst, (add GR32:$src1, (load addr:$src2))),
2205 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002206
Bill Wendlingae034ed2008-12-12 00:56:36 +00002207// Register-Integer Addition
2208def ADD8ri : Ii8<0x80, MRM0r, (outs GR8:$dst), (ins GR8:$src1, i8imm:$src2),
2209 "add{b}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002210 [(set GR8:$dst, (add GR8:$src1, imm:$src2)),
2211 (implicit EFLAGS)]>;
Bill Wendlingae034ed2008-12-12 00:56:36 +00002212
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002213let isConvertibleToThreeAddress = 1 in { // Can transform into LEA.
Bill Wendlingae034ed2008-12-12 00:56:36 +00002214// Register-Integer Addition
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002215def ADD16ri : Ii16<0x81, MRM0r, (outs GR16:$dst),
2216 (ins GR16:$src1, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002217 "add{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002218 [(set GR16:$dst, (add GR16:$src1, imm:$src2)),
2219 (implicit EFLAGS)]>, OpSize;
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002220def ADD32ri : Ii32<0x81, MRM0r, (outs GR32:$dst),
2221 (ins GR32:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002222 "add{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002223 [(set GR32:$dst, (add GR32:$src1, imm:$src2)),
2224 (implicit EFLAGS)]>;
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002225def ADD16ri8 : Ii8<0x83, MRM0r, (outs GR16:$dst),
2226 (ins GR16:$src1, i16i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002227 "add{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002228 [(set GR16:$dst, (add GR16:$src1, i16immSExt8:$src2)),
2229 (implicit EFLAGS)]>, OpSize;
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002230def ADD32ri8 : Ii8<0x83, MRM0r, (outs GR32:$dst),
2231 (ins GR32:$src1, i32i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002232 "add{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002233 [(set GR32:$dst, (add GR32:$src1, i32immSExt8:$src2)),
2234 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002235}
2236
2237let isTwoAddress = 0 in {
Bill Wendlingae034ed2008-12-12 00:56:36 +00002238 // Memory-Register Addition
Bill Wendlingf5399032008-12-12 21:15:41 +00002239 def ADD8mr : I<0x00, MRMDestMem, (outs), (ins i8mem:$dst, GR8:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002240 "add{b}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002241 [(store (add (load addr:$dst), GR8:$src2), addr:$dst),
2242 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002243 def ADD16mr : I<0x01, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002244 "add{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002245 [(store (add (load addr:$dst), GR16:$src2), addr:$dst),
2246 (implicit EFLAGS)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002247 def ADD32mr : I<0x01, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002248 "add{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002249 [(store (add (load addr:$dst), GR32:$src2), addr:$dst),
2250 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002251 def ADD8mi : Ii8<0x80, MRM0m, (outs), (ins i8mem :$dst, i8imm :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002252 "add{b}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002253 [(store (add (loadi8 addr:$dst), imm:$src2), addr:$dst),
2254 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002255 def ADD16mi : Ii16<0x81, MRM0m, (outs), (ins i16mem:$dst, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002256 "add{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002257 [(store (add (loadi16 addr:$dst), imm:$src2), addr:$dst),
2258 (implicit EFLAGS)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002259 def ADD32mi : Ii32<0x81, MRM0m, (outs), (ins i32mem:$dst, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002260 "add{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002261 [(store (add (loadi32 addr:$dst), imm:$src2), addr:$dst),
2262 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002263 def ADD16mi8 : Ii8<0x83, MRM0m, (outs), (ins i16mem:$dst, i16i8imm :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002264 "add{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002265 [(store (add (load addr:$dst), i16immSExt8:$src2),
2266 addr:$dst),
2267 (implicit EFLAGS)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002268 def ADD32mi8 : Ii8<0x83, MRM0m, (outs), (ins i32mem:$dst, i32i8imm :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002269 "add{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingae034ed2008-12-12 00:56:36 +00002270 [(store (add (load addr:$dst), i32immSExt8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00002271 addr:$dst),
2272 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002273}
2274
Evan Cheng259471d2007-10-05 17:59:57 +00002275let Uses = [EFLAGS] in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002276let isCommutable = 1 in { // X = ADC Y, Z --> X = ADC Z, Y
Dale Johannesen06b83f12009-05-18 17:44:15 +00002277def ADC8rr : I<0x10, MRMDestReg, (outs GR8:$dst), (ins GR8:$src1, GR8:$src2),
2278 "adc{b}\t{$src2, $dst|$dst, $src2}",
2279 [(set GR8:$dst, (adde GR8:$src1, GR8:$src2))]>;
2280def ADC16rr : I<0x11, MRMDestReg, (outs GR16:$dst),
2281 (ins GR16:$src1, GR16:$src2),
2282 "adc{w}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen067cfb22009-05-18 21:41:59 +00002283 [(set GR16:$dst, (adde GR16:$src1, GR16:$src2))]>, OpSize;
Dale Johannesen06b83f12009-05-18 17:44:15 +00002284def ADC32rr : I<0x11, MRMDestReg, (outs GR32:$dst),
2285 (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002286 "adc{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingc0ca7f32008-12-01 23:44:08 +00002287 [(set GR32:$dst, (adde GR32:$src1, GR32:$src2))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002288}
Dale Johannesen06b83f12009-05-18 17:44:15 +00002289def ADC8rm : I<0x12, MRMSrcMem , (outs GR8:$dst),
2290 (ins GR8:$src1, i8mem:$src2),
2291 "adc{b}\t{$src2, $dst|$dst, $src2}",
2292 [(set GR8:$dst, (adde GR8:$src1, (load addr:$src2)))]>;
2293def ADC16rm : I<0x13, MRMSrcMem , (outs GR16:$dst),
2294 (ins GR16:$src1, i16mem:$src2),
2295 "adc{w}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen067cfb22009-05-18 21:41:59 +00002296 [(set GR16:$dst, (adde GR16:$src1, (load addr:$src2)))]>,
2297 OpSize;
Dale Johannesen06b83f12009-05-18 17:44:15 +00002298def ADC32rm : I<0x13, MRMSrcMem , (outs GR32:$dst),
2299 (ins GR32:$src1, i32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002300 "adc{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingc0ca7f32008-12-01 23:44:08 +00002301 [(set GR32:$dst, (adde GR32:$src1, (load addr:$src2)))]>;
Dale Johannesen06b83f12009-05-18 17:44:15 +00002302def ADC8ri : Ii8<0x80, MRM2r, (outs GR8:$dst), (ins GR8:$src1, i8imm:$src2),
2303 "adc{b}\t{$src2, $dst|$dst, $src2}",
2304 [(set GR8:$dst, (adde GR8:$src1, imm:$src2))]>;
2305def ADC16ri : Ii16<0x81, MRM2r, (outs GR16:$dst),
2306 (ins GR16:$src1, i16imm:$src2),
2307 "adc{w}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen067cfb22009-05-18 21:41:59 +00002308 [(set GR16:$dst, (adde GR16:$src1, imm:$src2))]>, OpSize;
Dale Johannesen06b83f12009-05-18 17:44:15 +00002309def ADC16ri8 : Ii8<0x83, MRM2r, (outs GR16:$dst),
2310 (ins GR16:$src1, i16i8imm:$src2),
2311 "adc{w}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen067cfb22009-05-18 21:41:59 +00002312 [(set GR16:$dst, (adde GR16:$src1, i16immSExt8:$src2))]>,
2313 OpSize;
Dale Johannesen06b83f12009-05-18 17:44:15 +00002314def ADC32ri : Ii32<0x81, MRM2r, (outs GR32:$dst),
2315 (ins GR32:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002316 "adc{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingc0ca7f32008-12-01 23:44:08 +00002317 [(set GR32:$dst, (adde GR32:$src1, imm:$src2))]>;
Dale Johannesen06b83f12009-05-18 17:44:15 +00002318def ADC32ri8 : Ii8<0x83, MRM2r, (outs GR32:$dst),
2319 (ins GR32:$src1, i32i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002320 "adc{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingc0ca7f32008-12-01 23:44:08 +00002321 [(set GR32:$dst, (adde GR32:$src1, i32immSExt8:$src2))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002322
2323let isTwoAddress = 0 in {
Dale Johannesen06b83f12009-05-18 17:44:15 +00002324 def ADC8mr : I<0x10, MRMDestMem, (outs), (ins i8mem:$dst, GR8:$src2),
2325 "adc{b}\t{$src2, $dst|$dst, $src2}",
2326 [(store (adde (load addr:$dst), GR8:$src2), addr:$dst)]>;
2327 def ADC16mr : I<0x11, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
2328 "adc{w}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen067cfb22009-05-18 21:41:59 +00002329 [(store (adde (load addr:$dst), GR16:$src2), addr:$dst)]>,
2330 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002331 def ADC32mr : I<0x11, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002332 "adc{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingc0ca7f32008-12-01 23:44:08 +00002333 [(store (adde (load addr:$dst), GR32:$src2), addr:$dst)]>;
Dale Johannesen06b83f12009-05-18 17:44:15 +00002334 def ADC8mi : Ii8<0x80, MRM2m, (outs), (ins i8mem:$dst, i8imm:$src2),
2335 "adc{b}\t{$src2, $dst|$dst, $src2}",
2336 [(store (adde (loadi8 addr:$dst), imm:$src2), addr:$dst)]>;
2337 def ADC16mi : Ii16<0x81, MRM2m, (outs), (ins i16mem:$dst, i16imm:$src2),
2338 "adc{w}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen067cfb22009-05-18 21:41:59 +00002339 [(store (adde (loadi16 addr:$dst), imm:$src2), addr:$dst)]>,
2340 OpSize;
Dale Johannesen06b83f12009-05-18 17:44:15 +00002341 def ADC16mi8 : Ii8<0x83, MRM2m, (outs), (ins i16mem:$dst, i16i8imm :$src2),
2342 "adc{w}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen067cfb22009-05-18 21:41:59 +00002343 [(store (adde (load addr:$dst), i16immSExt8:$src2), addr:$dst)]>,
2344 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002345 def ADC32mi : Ii32<0x81, MRM2m, (outs), (ins i32mem:$dst, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002346 "adc{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingc0ca7f32008-12-01 23:44:08 +00002347 [(store (adde (loadi32 addr:$dst), imm:$src2), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002348 def ADC32mi8 : Ii8<0x83, MRM2m, (outs), (ins i32mem:$dst, i32i8imm :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002349 "adc{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendling0c52d0a2008-12-02 00:07:05 +00002350 [(store (adde (load addr:$dst), i32immSExt8:$src2), addr:$dst)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002351}
Evan Cheng259471d2007-10-05 17:59:57 +00002352} // Uses = [EFLAGS]
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002353
Bill Wendlingae034ed2008-12-12 00:56:36 +00002354// Register-Register Subtraction
2355def SUB8rr : I<0x28, MRMDestReg, (outs GR8:$dst), (ins GR8:$src1, GR8:$src2),
2356 "sub{b}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002357 [(set GR8:$dst, (sub GR8:$src1, GR8:$src2)),
2358 (implicit EFLAGS)]>;
Bill Wendlingae034ed2008-12-12 00:56:36 +00002359def SUB16rr : I<0x29, MRMDestReg, (outs GR16:$dst), (ins GR16:$src1,GR16:$src2),
2360 "sub{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002361 [(set GR16:$dst, (sub GR16:$src1, GR16:$src2)),
2362 (implicit EFLAGS)]>, OpSize;
Bill Wendlingae034ed2008-12-12 00:56:36 +00002363def SUB32rr : I<0x29, MRMDestReg, (outs GR32:$dst), (ins GR32:$src1,GR32:$src2),
2364 "sub{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002365 [(set GR32:$dst, (sub GR32:$src1, GR32:$src2)),
2366 (implicit EFLAGS)]>;
Bill Wendlingae034ed2008-12-12 00:56:36 +00002367
2368// Register-Memory Subtraction
2369def SUB8rm : I<0x2A, MRMSrcMem, (outs GR8 :$dst),
2370 (ins GR8 :$src1, i8mem :$src2),
2371 "sub{b}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002372 [(set GR8:$dst, (sub GR8:$src1, (load addr:$src2))),
2373 (implicit EFLAGS)]>;
Bill Wendlingae034ed2008-12-12 00:56:36 +00002374def SUB16rm : I<0x2B, MRMSrcMem, (outs GR16:$dst),
2375 (ins GR16:$src1, i16mem:$src2),
2376 "sub{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002377 [(set GR16:$dst, (sub GR16:$src1, (load addr:$src2))),
2378 (implicit EFLAGS)]>, OpSize;
Bill Wendlingae034ed2008-12-12 00:56:36 +00002379def SUB32rm : I<0x2B, MRMSrcMem, (outs GR32:$dst),
2380 (ins GR32:$src1, i32mem:$src2),
2381 "sub{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002382 [(set GR32:$dst, (sub GR32:$src1, (load addr:$src2))),
2383 (implicit EFLAGS)]>;
Bill Wendlingae034ed2008-12-12 00:56:36 +00002384
2385// Register-Integer Subtraction
2386def SUB8ri : Ii8 <0x80, MRM5r, (outs GR8:$dst),
2387 (ins GR8:$src1, i8imm:$src2),
2388 "sub{b}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002389 [(set GR8:$dst, (sub GR8:$src1, imm:$src2)),
2390 (implicit EFLAGS)]>;
Bill Wendlingae034ed2008-12-12 00:56:36 +00002391def SUB16ri : Ii16<0x81, MRM5r, (outs GR16:$dst),
2392 (ins GR16:$src1, i16imm:$src2),
2393 "sub{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002394 [(set GR16:$dst, (sub GR16:$src1, imm:$src2)),
2395 (implicit EFLAGS)]>, OpSize;
Bill Wendlingae034ed2008-12-12 00:56:36 +00002396def SUB32ri : Ii32<0x81, MRM5r, (outs GR32:$dst),
2397 (ins GR32:$src1, i32imm:$src2),
2398 "sub{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002399 [(set GR32:$dst, (sub GR32:$src1, imm:$src2)),
2400 (implicit EFLAGS)]>;
Bill Wendlingae034ed2008-12-12 00:56:36 +00002401def SUB16ri8 : Ii8<0x83, MRM5r, (outs GR16:$dst),
2402 (ins GR16:$src1, i16i8imm:$src2),
2403 "sub{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002404 [(set GR16:$dst, (sub GR16:$src1, i16immSExt8:$src2)),
2405 (implicit EFLAGS)]>, OpSize;
Bill Wendlingae034ed2008-12-12 00:56:36 +00002406def SUB32ri8 : Ii8<0x83, MRM5r, (outs GR32:$dst),
2407 (ins GR32:$src1, i32i8imm:$src2),
2408 "sub{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002409 [(set GR32:$dst, (sub GR32:$src1, i32immSExt8:$src2)),
2410 (implicit EFLAGS)]>;
Bill Wendlingae034ed2008-12-12 00:56:36 +00002411
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002412let isTwoAddress = 0 in {
Bill Wendlingae034ed2008-12-12 00:56:36 +00002413 // Memory-Register Subtraction
Evan Chengb783fa32007-07-19 01:14:50 +00002414 def SUB8mr : I<0x28, MRMDestMem, (outs), (ins i8mem :$dst, GR8 :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002415 "sub{b}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002416 [(store (sub (load addr:$dst), GR8:$src2), addr:$dst),
2417 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002418 def SUB16mr : I<0x29, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002419 "sub{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002420 [(store (sub (load addr:$dst), GR16:$src2), addr:$dst),
2421 (implicit EFLAGS)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002422 def SUB32mr : I<0x29, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002423 "sub{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002424 [(store (sub (load addr:$dst), GR32:$src2), addr:$dst),
2425 (implicit EFLAGS)]>;
Bill Wendlingae034ed2008-12-12 00:56:36 +00002426
2427 // Memory-Integer Subtraction
Evan Chengb783fa32007-07-19 01:14:50 +00002428 def SUB8mi : Ii8<0x80, MRM5m, (outs), (ins i8mem :$dst, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002429 "sub{b}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002430 [(store (sub (loadi8 addr:$dst), imm:$src2), addr:$dst),
2431 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002432 def SUB16mi : Ii16<0x81, MRM5m, (outs), (ins i16mem:$dst, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002433 "sub{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002434 [(store (sub (loadi16 addr:$dst), imm:$src2),addr:$dst),
2435 (implicit EFLAGS)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002436 def SUB32mi : Ii32<0x81, MRM5m, (outs), (ins i32mem:$dst, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002437 "sub{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002438 [(store (sub (loadi32 addr:$dst), imm:$src2),addr:$dst),
2439 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002440 def SUB16mi8 : Ii8<0x83, MRM5m, (outs), (ins i16mem:$dst, i16i8imm :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002441 "sub{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingae034ed2008-12-12 00:56:36 +00002442 [(store (sub (load addr:$dst), i16immSExt8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00002443 addr:$dst),
2444 (implicit EFLAGS)]>, OpSize;
Bill Wendlingae034ed2008-12-12 00:56:36 +00002445 def SUB32mi8 : Ii8<0x83, MRM5m, (outs), (ins i32mem:$dst, i32i8imm :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002446 "sub{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingae034ed2008-12-12 00:56:36 +00002447 [(store (sub (load addr:$dst), i32immSExt8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00002448 addr:$dst),
2449 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002450}
2451
Evan Cheng259471d2007-10-05 17:59:57 +00002452let Uses = [EFLAGS] in {
Dale Johannesen06b83f12009-05-18 17:44:15 +00002453def SBB8rr : I<0x18, MRMDestReg, (outs GR8:$dst),
2454 (ins GR8:$src1, GR8:$src2),
2455 "sbb{b}\t{$src2, $dst|$dst, $src2}",
2456 [(set GR8:$dst, (sube GR8:$src1, GR8:$src2))]>;
2457def SBB16rr : I<0x19, MRMDestReg, (outs GR16:$dst),
2458 (ins GR16:$src1, GR16:$src2),
2459 "sbb{w}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen067cfb22009-05-18 21:41:59 +00002460 [(set GR16:$dst, (sube GR16:$src1, GR16:$src2))]>, OpSize;
Dale Johannesen06b83f12009-05-18 17:44:15 +00002461def SBB32rr : I<0x19, MRMDestReg, (outs GR32:$dst),
2462 (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002463 "sbb{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng55687072007-09-14 21:48:26 +00002464 [(set GR32:$dst, (sube GR32:$src1, GR32:$src2))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002465
2466let isTwoAddress = 0 in {
Dale Johannesen06b83f12009-05-18 17:44:15 +00002467 def SBB8mr : I<0x18, MRMDestMem, (outs), (ins i8mem:$dst, GR8:$src2),
2468 "sbb{b}\t{$src2, $dst|$dst, $src2}",
2469 [(store (sube (load addr:$dst), GR8:$src2), addr:$dst)]>;
2470 def SBB16mr : I<0x19, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
2471 "sbb{w}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen067cfb22009-05-18 21:41:59 +00002472 [(store (sube (load addr:$dst), GR16:$src2), addr:$dst)]>,
2473 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002474 def SBB32mr : I<0x19, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002475 "sbb{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002476 [(store (sube (load addr:$dst), GR32:$src2), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002477 def SBB8mi : Ii32<0x80, MRM3m, (outs), (ins i8mem:$dst, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002478 "sbb{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002479 [(store (sube (loadi8 addr:$dst), imm:$src2), addr:$dst)]>;
Dale Johannesen06b83f12009-05-18 17:44:15 +00002480 def SBB16mi : Ii16<0x81, MRM3m, (outs), (ins i16mem:$dst, i16imm:$src2),
2481 "sbb{w}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen067cfb22009-05-18 21:41:59 +00002482 [(store (sube (loadi16 addr:$dst), imm:$src2), addr:$dst)]>,
2483 OpSize;
Dale Johannesen06b83f12009-05-18 17:44:15 +00002484 def SBB16mi8 : Ii8<0x83, MRM3m, (outs), (ins i16mem:$dst, i16i8imm :$src2),
2485 "sbb{w}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen067cfb22009-05-18 21:41:59 +00002486 [(store (sube (load addr:$dst), i16immSExt8:$src2), addr:$dst)]>,
2487 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002488 def SBB32mi : Ii32<0x81, MRM3m, (outs), (ins i32mem:$dst, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002489 "sbb{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002490 [(store (sube (loadi32 addr:$dst), imm:$src2), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002491 def SBB32mi8 : Ii8<0x83, MRM3m, (outs), (ins i32mem:$dst, i32i8imm :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002492 "sbb{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng55687072007-09-14 21:48:26 +00002493 [(store (sube (load addr:$dst), i32immSExt8:$src2), addr:$dst)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002494}
Dale Johannesen06b83f12009-05-18 17:44:15 +00002495def SBB8rm : I<0x1A, MRMSrcMem, (outs GR8:$dst), (ins GR8:$src1, i8mem:$src2),
2496 "sbb{b}\t{$src2, $dst|$dst, $src2}",
2497 [(set GR8:$dst, (sube GR8:$src1, (load addr:$src2)))]>;
2498def SBB16rm : I<0x1B, MRMSrcMem, (outs GR16:$dst),
2499 (ins GR16:$src1, i16mem:$src2),
2500 "sbb{w}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen067cfb22009-05-18 21:41:59 +00002501 [(set GR16:$dst, (sube GR16:$src1, (load addr:$src2)))]>,
2502 OpSize;
Dale Johannesen06b83f12009-05-18 17:44:15 +00002503def SBB32rm : I<0x1B, MRMSrcMem, (outs GR32:$dst),
2504 (ins GR32:$src1, i32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002505 "sbb{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002506 [(set GR32:$dst, (sube GR32:$src1, (load addr:$src2)))]>;
Dale Johannesen06b83f12009-05-18 17:44:15 +00002507def SBB8ri : Ii8<0x80, MRM3r, (outs GR8:$dst), (ins GR8:$src1, i8imm:$src2),
2508 "sbb{b}\t{$src2, $dst|$dst, $src2}",
2509 [(set GR8:$dst, (sube GR8:$src1, imm:$src2))]>;
2510def SBB16ri : Ii16<0x81, MRM3r, (outs GR16:$dst),
2511 (ins GR16:$src1, i16imm:$src2),
2512 "sbb{w}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen067cfb22009-05-18 21:41:59 +00002513 [(set GR16:$dst, (sube GR16:$src1, imm:$src2))]>, OpSize;
Dale Johannesen06b83f12009-05-18 17:44:15 +00002514def SBB16ri8 : Ii8<0x83, MRM3r, (outs GR16:$dst),
2515 (ins GR16:$src1, i16i8imm:$src2),
2516 "sbb{w}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen067cfb22009-05-18 21:41:59 +00002517 [(set GR16:$dst, (sube GR16:$src1, i16immSExt8:$src2))]>,
2518 OpSize;
Dale Johannesen06b83f12009-05-18 17:44:15 +00002519def SBB32ri : Ii32<0x81, MRM3r, (outs GR32:$dst),
2520 (ins GR32:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002521 "sbb{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002522 [(set GR32:$dst, (sube GR32:$src1, imm:$src2))]>;
Dale Johannesen06b83f12009-05-18 17:44:15 +00002523def SBB32ri8 : Ii8<0x83, MRM3r, (outs GR32:$dst),
2524 (ins GR32:$src1, i32i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002525 "sbb{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002526 [(set GR32:$dst, (sube GR32:$src1, i32immSExt8:$src2))]>;
Evan Cheng259471d2007-10-05 17:59:57 +00002527} // Uses = [EFLAGS]
Evan Cheng55687072007-09-14 21:48:26 +00002528} // Defs = [EFLAGS]
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002529
Evan Cheng55687072007-09-14 21:48:26 +00002530let Defs = [EFLAGS] in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002531let isCommutable = 1 in { // X = IMUL Y, Z --> X = IMUL Z, Y
Bill Wendlingf5399032008-12-12 21:15:41 +00002532// Register-Register Signed Integer Multiply
Bill Wendlingae034ed2008-12-12 00:56:36 +00002533def IMUL16rr : I<0xAF, MRMSrcReg, (outs GR16:$dst), (ins GR16:$src1,GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002534 "imul{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002535 [(set GR16:$dst, (mul GR16:$src1, GR16:$src2)),
2536 (implicit EFLAGS)]>, TB, OpSize;
Bill Wendlingae034ed2008-12-12 00:56:36 +00002537def IMUL32rr : I<0xAF, MRMSrcReg, (outs GR32:$dst), (ins GR32:$src1,GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002538 "imul{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002539 [(set GR32:$dst, (mul GR32:$src1, GR32:$src2)),
2540 (implicit EFLAGS)]>, TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002541}
Bill Wendlingae034ed2008-12-12 00:56:36 +00002542
Bill Wendlingf5399032008-12-12 21:15:41 +00002543// Register-Memory Signed Integer Multiply
Bill Wendlingae034ed2008-12-12 00:56:36 +00002544def IMUL16rm : I<0xAF, MRMSrcMem, (outs GR16:$dst),
2545 (ins GR16:$src1, i16mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002546 "imul{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002547 [(set GR16:$dst, (mul GR16:$src1, (load addr:$src2))),
2548 (implicit EFLAGS)]>, TB, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002549def IMUL32rm : I<0xAF, MRMSrcMem, (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002550 "imul{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002551 [(set GR32:$dst, (mul GR32:$src1, (load addr:$src2))),
2552 (implicit EFLAGS)]>, TB;
Evan Cheng55687072007-09-14 21:48:26 +00002553} // Defs = [EFLAGS]
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002554} // end Two Address instructions
2555
2556// Suprisingly enough, these are not two address instructions!
Evan Cheng55687072007-09-14 21:48:26 +00002557let Defs = [EFLAGS] in {
Bill Wendlingf5399032008-12-12 21:15:41 +00002558// Register-Integer Signed Integer Multiply
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002559def IMUL16rri : Ii16<0x69, MRMSrcReg, // GR16 = GR16*I16
Evan Chengb783fa32007-07-19 01:14:50 +00002560 (outs GR16:$dst), (ins GR16:$src1, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002561 "imul{w}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002562 [(set GR16:$dst, (mul GR16:$src1, imm:$src2)),
2563 (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002564def IMUL32rri : Ii32<0x69, MRMSrcReg, // GR32 = GR32*I32
Evan Chengb783fa32007-07-19 01:14:50 +00002565 (outs GR32:$dst), (ins GR32:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002566 "imul{l}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002567 [(set GR32:$dst, (mul GR32:$src1, imm:$src2)),
2568 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002569def IMUL16rri8 : Ii8<0x6B, MRMSrcReg, // GR16 = GR16*I8
Evan Chengb783fa32007-07-19 01:14:50 +00002570 (outs GR16:$dst), (ins GR16:$src1, i16i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002571 "imul{w}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002572 [(set GR16:$dst, (mul GR16:$src1, i16immSExt8:$src2)),
2573 (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002574def IMUL32rri8 : Ii8<0x6B, MRMSrcReg, // GR32 = GR32*I8
Evan Chengb783fa32007-07-19 01:14:50 +00002575 (outs GR32:$dst), (ins GR32:$src1, i32i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002576 "imul{l}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002577 [(set GR32:$dst, (mul GR32:$src1, i32immSExt8:$src2)),
2578 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002579
Bill Wendlingf5399032008-12-12 21:15:41 +00002580// Memory-Integer Signed Integer Multiply
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002581def IMUL16rmi : Ii16<0x69, MRMSrcMem, // GR16 = [mem16]*I16
Evan Chengb783fa32007-07-19 01:14:50 +00002582 (outs GR16:$dst), (ins i16mem:$src1, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002583 "imul{w}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002584 [(set GR16:$dst, (mul (load addr:$src1), imm:$src2)),
2585 (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002586def IMUL32rmi : Ii32<0x69, MRMSrcMem, // GR32 = [mem32]*I32
Evan Chengb783fa32007-07-19 01:14:50 +00002587 (outs GR32:$dst), (ins i32mem:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002588 "imul{l}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002589 [(set GR32:$dst, (mul (load addr:$src1), imm:$src2)),
2590 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002591def IMUL16rmi8 : Ii8<0x6B, MRMSrcMem, // GR16 = [mem16]*I8
Evan Chengb783fa32007-07-19 01:14:50 +00002592 (outs GR16:$dst), (ins i16mem:$src1, i16i8imm :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002593 "imul{w}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Bill Wendlingae034ed2008-12-12 00:56:36 +00002594 [(set GR16:$dst, (mul (load addr:$src1),
Bill Wendlingf5399032008-12-12 21:15:41 +00002595 i16immSExt8:$src2)),
2596 (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002597def IMUL32rmi8 : Ii8<0x6B, MRMSrcMem, // GR32 = [mem32]*I8
Evan Chengb783fa32007-07-19 01:14:50 +00002598 (outs GR32:$dst), (ins i32mem:$src1, i32i8imm: $src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002599 "imul{l}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Bill Wendlingae034ed2008-12-12 00:56:36 +00002600 [(set GR32:$dst, (mul (load addr:$src1),
Bill Wendlingf5399032008-12-12 21:15:41 +00002601 i32immSExt8:$src2)),
2602 (implicit EFLAGS)]>;
Evan Cheng55687072007-09-14 21:48:26 +00002603} // Defs = [EFLAGS]
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002604
2605//===----------------------------------------------------------------------===//
2606// Test instructions are just like AND, except they don't generate a result.
2607//
Evan Cheng950aac02007-09-25 01:57:46 +00002608let Defs = [EFLAGS] in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002609let isCommutable = 1 in { // TEST X, Y --> TEST Y, X
Evan Chengb783fa32007-07-19 01:14:50 +00002610def TEST8rr : I<0x84, MRMDestReg, (outs), (ins GR8:$src1, GR8:$src2),
Evan Cheng621216e2007-09-29 00:00:36 +00002611 "test{b}\t{$src2, $src1|$src1, $src2}",
Chris Lattner21da6382008-02-19 17:37:35 +00002612 [(X86cmp (and_su GR8:$src1, GR8:$src2), 0),
Evan Cheng621216e2007-09-29 00:00:36 +00002613 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002614def TEST16rr : I<0x85, MRMDestReg, (outs), (ins GR16:$src1, GR16:$src2),
Evan Cheng621216e2007-09-29 00:00:36 +00002615 "test{w}\t{$src2, $src1|$src1, $src2}",
Chris Lattner21da6382008-02-19 17:37:35 +00002616 [(X86cmp (and_su GR16:$src1, GR16:$src2), 0),
Evan Cheng621216e2007-09-29 00:00:36 +00002617 (implicit EFLAGS)]>,
2618 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002619def TEST32rr : I<0x85, MRMDestReg, (outs), (ins GR32:$src1, GR32:$src2),
Evan Cheng621216e2007-09-29 00:00:36 +00002620 "test{l}\t{$src2, $src1|$src1, $src2}",
Chris Lattner21da6382008-02-19 17:37:35 +00002621 [(X86cmp (and_su GR32:$src1, GR32:$src2), 0),
Evan Cheng621216e2007-09-29 00:00:36 +00002622 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002623}
2624
Evan Chengb783fa32007-07-19 01:14:50 +00002625def TEST8rm : I<0x84, MRMSrcMem, (outs), (ins GR8 :$src1, i8mem :$src2),
Evan Cheng621216e2007-09-29 00:00:36 +00002626 "test{b}\t{$src2, $src1|$src1, $src2}",
2627 [(X86cmp (and GR8:$src1, (loadi8 addr:$src2)), 0),
2628 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002629def TEST16rm : I<0x85, MRMSrcMem, (outs), (ins GR16:$src1, i16mem:$src2),
Evan Cheng621216e2007-09-29 00:00:36 +00002630 "test{w}\t{$src2, $src1|$src1, $src2}",
2631 [(X86cmp (and GR16:$src1, (loadi16 addr:$src2)), 0),
2632 (implicit EFLAGS)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002633def TEST32rm : I<0x85, MRMSrcMem, (outs), (ins GR32:$src1, i32mem:$src2),
Evan Cheng621216e2007-09-29 00:00:36 +00002634 "test{l}\t{$src2, $src1|$src1, $src2}",
2635 [(X86cmp (and GR32:$src1, (loadi32 addr:$src2)), 0),
2636 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002637
2638def TEST8ri : Ii8 <0xF6, MRM0r, // flags = GR8 & imm8
Evan Chengb783fa32007-07-19 01:14:50 +00002639 (outs), (ins GR8:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002640 "test{b}\t{$src2, $src1|$src1, $src2}",
Chris Lattner21da6382008-02-19 17:37:35 +00002641 [(X86cmp (and_su GR8:$src1, imm:$src2), 0),
Evan Cheng621216e2007-09-29 00:00:36 +00002642 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002643def TEST16ri : Ii16<0xF7, MRM0r, // flags = GR16 & imm16
Evan Chengb783fa32007-07-19 01:14:50 +00002644 (outs), (ins GR16:$src1, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002645 "test{w}\t{$src2, $src1|$src1, $src2}",
Chris Lattner21da6382008-02-19 17:37:35 +00002646 [(X86cmp (and_su GR16:$src1, imm:$src2), 0),
Evan Cheng621216e2007-09-29 00:00:36 +00002647 (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002648def TEST32ri : Ii32<0xF7, MRM0r, // flags = GR32 & imm32
Evan Chengb783fa32007-07-19 01:14:50 +00002649 (outs), (ins GR32:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002650 "test{l}\t{$src2, $src1|$src1, $src2}",
Chris Lattner21da6382008-02-19 17:37:35 +00002651 [(X86cmp (and_su GR32:$src1, imm:$src2), 0),
Evan Cheng621216e2007-09-29 00:00:36 +00002652 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002653
Evan Cheng621216e2007-09-29 00:00:36 +00002654def TEST8mi : Ii8 <0xF6, MRM0m, // flags = [mem8] & imm8
Evan Chengb783fa32007-07-19 01:14:50 +00002655 (outs), (ins i8mem:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002656 "test{b}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002657 [(X86cmp (and (loadi8 addr:$src1), imm:$src2), 0),
2658 (implicit EFLAGS)]>;
2659def TEST16mi : Ii16<0xF7, MRM0m, // flags = [mem16] & imm16
Evan Chengb783fa32007-07-19 01:14:50 +00002660 (outs), (ins i16mem:$src1, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002661 "test{w}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002662 [(X86cmp (and (loadi16 addr:$src1), imm:$src2), 0),
2663 (implicit EFLAGS)]>, OpSize;
2664def TEST32mi : Ii32<0xF7, MRM0m, // flags = [mem32] & imm32
Evan Chengb783fa32007-07-19 01:14:50 +00002665 (outs), (ins i32mem:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002666 "test{l}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002667 [(X86cmp (and (loadi32 addr:$src1), imm:$src2), 0),
Evan Cheng950aac02007-09-25 01:57:46 +00002668 (implicit EFLAGS)]>;
2669} // Defs = [EFLAGS]
2670
2671
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002672// Condition code ops, incl. set if equal/not equal/...
Chris Lattnerc90ee9c2008-01-10 07:59:24 +00002673let Defs = [EFLAGS], Uses = [AH], neverHasSideEffects = 1 in
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002674def SAHF : I<0x9E, RawFrm, (outs), (ins), "sahf", []>; // flags = AH
Chris Lattnerc90ee9c2008-01-10 07:59:24 +00002675let Defs = [AH], Uses = [EFLAGS], neverHasSideEffects = 1 in
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002676def LAHF : I<0x9F, RawFrm, (outs), (ins), "lahf", []>; // AH = flags
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002677
Evan Cheng950aac02007-09-25 01:57:46 +00002678let Uses = [EFLAGS] in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002679def SETEr : I<0x94, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00002680 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002681 "sete\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002682 [(set GR8:$dst, (X86setcc X86_COND_E, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002683 TB; // GR8 = ==
2684def SETEm : I<0x94, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00002685 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002686 "sete\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002687 [(store (X86setcc X86_COND_E, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002688 TB; // [mem8] = ==
Bill Wendling0c52d0a2008-12-02 00:07:05 +00002689
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002690def SETNEr : I<0x95, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00002691 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002692 "setne\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002693 [(set GR8:$dst, (X86setcc X86_COND_NE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002694 TB; // GR8 = !=
2695def SETNEm : I<0x95, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00002696 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002697 "setne\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002698 [(store (X86setcc X86_COND_NE, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002699 TB; // [mem8] = !=
Bill Wendling0c52d0a2008-12-02 00:07:05 +00002700
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002701def SETLr : I<0x9C, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00002702 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002703 "setl\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002704 [(set GR8:$dst, (X86setcc X86_COND_L, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002705 TB; // GR8 = < signed
2706def SETLm : I<0x9C, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00002707 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002708 "setl\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002709 [(store (X86setcc X86_COND_L, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002710 TB; // [mem8] = < signed
Bill Wendling0c52d0a2008-12-02 00:07:05 +00002711
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002712def SETGEr : I<0x9D, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00002713 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002714 "setge\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002715 [(set GR8:$dst, (X86setcc X86_COND_GE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002716 TB; // GR8 = >= signed
2717def SETGEm : I<0x9D, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00002718 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002719 "setge\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002720 [(store (X86setcc X86_COND_GE, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002721 TB; // [mem8] = >= signed
Bill Wendling0c52d0a2008-12-02 00:07:05 +00002722
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002723def SETLEr : I<0x9E, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00002724 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002725 "setle\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002726 [(set GR8:$dst, (X86setcc X86_COND_LE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002727 TB; // GR8 = <= signed
2728def SETLEm : I<0x9E, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00002729 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002730 "setle\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002731 [(store (X86setcc X86_COND_LE, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002732 TB; // [mem8] = <= signed
Bill Wendling0c52d0a2008-12-02 00:07:05 +00002733
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002734def SETGr : I<0x9F, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00002735 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002736 "setg\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002737 [(set GR8:$dst, (X86setcc X86_COND_G, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002738 TB; // GR8 = > signed
2739def SETGm : I<0x9F, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00002740 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002741 "setg\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002742 [(store (X86setcc X86_COND_G, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002743 TB; // [mem8] = > signed
2744
2745def SETBr : I<0x92, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00002746 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002747 "setb\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002748 [(set GR8:$dst, (X86setcc X86_COND_B, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002749 TB; // GR8 = < unsign
2750def SETBm : I<0x92, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00002751 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002752 "setb\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002753 [(store (X86setcc X86_COND_B, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002754 TB; // [mem8] = < unsign
Bill Wendling0c52d0a2008-12-02 00:07:05 +00002755
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002756def SETAEr : I<0x93, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00002757 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002758 "setae\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002759 [(set GR8:$dst, (X86setcc X86_COND_AE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002760 TB; // GR8 = >= unsign
2761def SETAEm : I<0x93, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00002762 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002763 "setae\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002764 [(store (X86setcc X86_COND_AE, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002765 TB; // [mem8] = >= unsign
Bill Wendling0c52d0a2008-12-02 00:07:05 +00002766
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002767def SETBEr : I<0x96, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00002768 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002769 "setbe\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002770 [(set GR8:$dst, (X86setcc X86_COND_BE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002771 TB; // GR8 = <= unsign
2772def SETBEm : I<0x96, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00002773 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002774 "setbe\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002775 [(store (X86setcc X86_COND_BE, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002776 TB; // [mem8] = <= unsign
Bill Wendling0c52d0a2008-12-02 00:07:05 +00002777
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002778def SETAr : I<0x97, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00002779 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002780 "seta\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002781 [(set GR8:$dst, (X86setcc X86_COND_A, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002782 TB; // GR8 = > signed
2783def SETAm : I<0x97, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00002784 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002785 "seta\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002786 [(store (X86setcc X86_COND_A, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002787 TB; // [mem8] = > signed
2788
2789def SETSr : I<0x98, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00002790 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002791 "sets\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002792 [(set GR8:$dst, (X86setcc X86_COND_S, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002793 TB; // GR8 = <sign bit>
2794def SETSm : I<0x98, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00002795 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002796 "sets\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002797 [(store (X86setcc X86_COND_S, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002798 TB; // [mem8] = <sign bit>
2799def SETNSr : I<0x99, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00002800 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002801 "setns\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002802 [(set GR8:$dst, (X86setcc X86_COND_NS, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002803 TB; // GR8 = !<sign bit>
2804def SETNSm : I<0x99, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00002805 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002806 "setns\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002807 [(store (X86setcc X86_COND_NS, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002808 TB; // [mem8] = !<sign bit>
Bill Wendling0c52d0a2008-12-02 00:07:05 +00002809
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002810def SETPr : I<0x9A, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00002811 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002812 "setp\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002813 [(set GR8:$dst, (X86setcc X86_COND_P, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002814 TB; // GR8 = parity
2815def SETPm : I<0x9A, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00002816 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002817 "setp\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002818 [(store (X86setcc X86_COND_P, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002819 TB; // [mem8] = parity
2820def SETNPr : I<0x9B, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00002821 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002822 "setnp\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002823 [(set GR8:$dst, (X86setcc X86_COND_NP, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002824 TB; // GR8 = not parity
2825def SETNPm : I<0x9B, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00002826 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002827 "setnp\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002828 [(store (X86setcc X86_COND_NP, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002829 TB; // [mem8] = not parity
Bill Wendling0c52d0a2008-12-02 00:07:05 +00002830
2831def SETOr : I<0x90, MRM0r,
2832 (outs GR8 :$dst), (ins),
2833 "seto\t$dst",
2834 [(set GR8:$dst, (X86setcc X86_COND_O, EFLAGS))]>,
2835 TB; // GR8 = overflow
2836def SETOm : I<0x90, MRM0m,
2837 (outs), (ins i8mem:$dst),
2838 "seto\t$dst",
2839 [(store (X86setcc X86_COND_O, EFLAGS), addr:$dst)]>,
2840 TB; // [mem8] = overflow
2841def SETNOr : I<0x91, MRM0r,
2842 (outs GR8 :$dst), (ins),
2843 "setno\t$dst",
2844 [(set GR8:$dst, (X86setcc X86_COND_NO, EFLAGS))]>,
2845 TB; // GR8 = not overflow
2846def SETNOm : I<0x91, MRM0m,
2847 (outs), (ins i8mem:$dst),
2848 "setno\t$dst",
2849 [(store (X86setcc X86_COND_NO, EFLAGS), addr:$dst)]>,
2850 TB; // [mem8] = not overflow
Evan Cheng950aac02007-09-25 01:57:46 +00002851} // Uses = [EFLAGS]
2852
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002853
2854// Integer comparisons
Evan Cheng55687072007-09-14 21:48:26 +00002855let Defs = [EFLAGS] in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002856def CMP8rr : I<0x38, MRMDestReg,
Evan Chengb783fa32007-07-19 01:14:50 +00002857 (outs), (ins GR8 :$src1, GR8 :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002858 "cmp{b}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002859 [(X86cmp GR8:$src1, GR8:$src2), (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002860def CMP16rr : I<0x39, MRMDestReg,
Evan Chengb783fa32007-07-19 01:14:50 +00002861 (outs), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002862 "cmp{w}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002863 [(X86cmp GR16:$src1, GR16:$src2), (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002864def CMP32rr : I<0x39, MRMDestReg,
Evan Chengb783fa32007-07-19 01:14:50 +00002865 (outs), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002866 "cmp{l}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002867 [(X86cmp GR32:$src1, GR32:$src2), (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002868def CMP8mr : I<0x38, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00002869 (outs), (ins i8mem :$src1, GR8 :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002870 "cmp{b}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002871 [(X86cmp (loadi8 addr:$src1), GR8:$src2),
2872 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002873def CMP16mr : I<0x39, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00002874 (outs), (ins i16mem:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002875 "cmp{w}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002876 [(X86cmp (loadi16 addr:$src1), GR16:$src2),
2877 (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002878def CMP32mr : I<0x39, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00002879 (outs), (ins i32mem:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002880 "cmp{l}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002881 [(X86cmp (loadi32 addr:$src1), GR32:$src2),
2882 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002883def CMP8rm : I<0x3A, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00002884 (outs), (ins GR8 :$src1, i8mem :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002885 "cmp{b}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002886 [(X86cmp GR8:$src1, (loadi8 addr:$src2)),
2887 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002888def CMP16rm : I<0x3B, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00002889 (outs), (ins GR16:$src1, i16mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002890 "cmp{w}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002891 [(X86cmp GR16:$src1, (loadi16 addr:$src2)),
2892 (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002893def CMP32rm : I<0x3B, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00002894 (outs), (ins GR32:$src1, i32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002895 "cmp{l}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002896 [(X86cmp GR32:$src1, (loadi32 addr:$src2)),
2897 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002898def CMP8ri : Ii8<0x80, MRM7r,
Evan Chengb783fa32007-07-19 01:14:50 +00002899 (outs), (ins GR8:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002900 "cmp{b}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002901 [(X86cmp GR8:$src1, imm:$src2), (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002902def CMP16ri : Ii16<0x81, MRM7r,
Evan Chengb783fa32007-07-19 01:14:50 +00002903 (outs), (ins GR16:$src1, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002904 "cmp{w}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002905 [(X86cmp GR16:$src1, imm:$src2),
2906 (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002907def CMP32ri : Ii32<0x81, MRM7r,
Evan Chengb783fa32007-07-19 01:14:50 +00002908 (outs), (ins GR32:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002909 "cmp{l}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002910 [(X86cmp GR32:$src1, imm:$src2), (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002911def CMP8mi : Ii8 <0x80, MRM7m,
Evan Chengb783fa32007-07-19 01:14:50 +00002912 (outs), (ins i8mem :$src1, i8imm :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002913 "cmp{b}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002914 [(X86cmp (loadi8 addr:$src1), imm:$src2),
2915 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002916def CMP16mi : Ii16<0x81, MRM7m,
Evan Chengb783fa32007-07-19 01:14:50 +00002917 (outs), (ins i16mem:$src1, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002918 "cmp{w}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002919 [(X86cmp (loadi16 addr:$src1), imm:$src2),
2920 (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002921def CMP32mi : Ii32<0x81, MRM7m,
Evan Chengb783fa32007-07-19 01:14:50 +00002922 (outs), (ins i32mem:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002923 "cmp{l}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002924 [(X86cmp (loadi32 addr:$src1), imm:$src2),
2925 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002926def CMP16ri8 : Ii8<0x83, MRM7r,
Evan Chengb783fa32007-07-19 01:14:50 +00002927 (outs), (ins GR16:$src1, i16i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002928 "cmp{w}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002929 [(X86cmp GR16:$src1, i16immSExt8:$src2),
2930 (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002931def CMP16mi8 : Ii8<0x83, MRM7m,
Evan Chengb783fa32007-07-19 01:14:50 +00002932 (outs), (ins i16mem:$src1, i16i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002933 "cmp{w}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002934 [(X86cmp (loadi16 addr:$src1), i16immSExt8:$src2),
2935 (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002936def CMP32mi8 : Ii8<0x83, MRM7m,
Evan Chengb783fa32007-07-19 01:14:50 +00002937 (outs), (ins i32mem:$src1, i32i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002938 "cmp{l}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002939 [(X86cmp (loadi32 addr:$src1), i32immSExt8:$src2),
2940 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002941def CMP32ri8 : Ii8<0x83, MRM7r,
Evan Chengb783fa32007-07-19 01:14:50 +00002942 (outs), (ins GR32:$src1, i32i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002943 "cmp{l}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002944 [(X86cmp GR32:$src1, i32immSExt8:$src2),
Evan Cheng950aac02007-09-25 01:57:46 +00002945 (implicit EFLAGS)]>;
2946} // Defs = [EFLAGS]
2947
Dan Gohman7fe9b7f2008-12-23 22:45:23 +00002948// Bit tests.
Dan Gohman7fe9b7f2008-12-23 22:45:23 +00002949// TODO: BTC, BTR, and BTS
2950let Defs = [EFLAGS] in {
Dan Gohmanfc4eddb2009-01-13 20:32:45 +00002951def BT16rr : I<0xA3, MRMDestReg, (outs), (ins GR16:$src1, GR16:$src2),
Dan Gohman7fe9b7f2008-12-23 22:45:23 +00002952 "bt{w}\t{$src2, $src1|$src1, $src2}",
2953 [(X86bt GR16:$src1, GR16:$src2),
Chris Lattner5a95cde2008-12-25 01:32:49 +00002954 (implicit EFLAGS)]>, OpSize, TB;
Dan Gohmanfc4eddb2009-01-13 20:32:45 +00002955def BT32rr : I<0xA3, MRMDestReg, (outs), (ins GR32:$src1, GR32:$src2),
Dan Gohman7fe9b7f2008-12-23 22:45:23 +00002956 "bt{l}\t{$src2, $src1|$src1, $src2}",
2957 [(X86bt GR32:$src1, GR32:$src2),
Chris Lattner5a95cde2008-12-25 01:32:49 +00002958 (implicit EFLAGS)]>, TB;
Dan Gohman85a228c2009-01-13 23:23:30 +00002959
2960// Unlike with the register+register form, the memory+register form of the
2961// bt instruction does not ignore the high bits of the index. From ISel's
2962// perspective, this is pretty bizarre. Disable these instructions for now.
2963//def BT16mr : I<0xA3, MRMDestMem, (outs), (ins i16mem:$src1, GR16:$src2),
2964// "bt{w}\t{$src2, $src1|$src1, $src2}",
2965// [(X86bt (loadi16 addr:$src1), GR16:$src2),
2966// (implicit EFLAGS)]>, OpSize, TB, Requires<[FastBTMem]>;
2967//def BT32mr : I<0xA3, MRMDestMem, (outs), (ins i32mem:$src1, GR32:$src2),
2968// "bt{l}\t{$src2, $src1|$src1, $src2}",
2969// [(X86bt (loadi32 addr:$src1), GR32:$src2),
2970// (implicit EFLAGS)]>, TB, Requires<[FastBTMem]>;
Dan Gohman46fb1cf2009-01-13 20:33:23 +00002971
2972def BT16ri8 : Ii8<0xBA, MRM4r, (outs), (ins GR16:$src1, i16i8imm:$src2),
2973 "bt{w}\t{$src2, $src1|$src1, $src2}",
2974 [(X86bt GR16:$src1, i16immSExt8:$src2),
2975 (implicit EFLAGS)]>, OpSize, TB;
2976def BT32ri8 : Ii8<0xBA, MRM4r, (outs), (ins GR32:$src1, i32i8imm:$src2),
2977 "bt{l}\t{$src2, $src1|$src1, $src2}",
2978 [(X86bt GR32:$src1, i32immSExt8:$src2),
2979 (implicit EFLAGS)]>, TB;
2980// Note that these instructions don't need FastBTMem because that
2981// only applies when the other operand is in a register. When it's
2982// an immediate, bt is still fast.
2983def BT16mi8 : Ii8<0xBA, MRM4m, (outs), (ins i16mem:$src1, i16i8imm:$src2),
2984 "bt{w}\t{$src2, $src1|$src1, $src2}",
2985 [(X86bt (loadi16 addr:$src1), i16immSExt8:$src2),
2986 (implicit EFLAGS)]>, OpSize, TB;
2987def BT32mi8 : Ii8<0xBA, MRM4m, (outs), (ins i32mem:$src1, i32i8imm:$src2),
2988 "bt{l}\t{$src2, $src1|$src1, $src2}",
2989 [(X86bt (loadi32 addr:$src1), i32immSExt8:$src2),
2990 (implicit EFLAGS)]>, TB;
Dan Gohman7fe9b7f2008-12-23 22:45:23 +00002991} // Defs = [EFLAGS]
2992
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002993// Sign/Zero extenders
Dan Gohman9203ab42008-07-30 18:09:17 +00002994// Use movsbl intead of movsbw; we don't care about the high 16 bits
2995// of the register here. This has a smaller encoding and avoids a
2996// partial-register update.
Evan Chengb783fa32007-07-19 01:14:50 +00002997def MOVSX16rr8 : I<0xBE, MRMSrcReg, (outs GR16:$dst), (ins GR8 :$src),
Dan Gohman9203ab42008-07-30 18:09:17 +00002998 "movs{bl|x}\t{$src, ${dst:subreg32}|${dst:subreg32}, $src}",
2999 [(set GR16:$dst, (sext GR8:$src))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00003000def MOVSX16rm8 : I<0xBE, MRMSrcMem, (outs GR16:$dst), (ins i8mem :$src),
Dan Gohman9203ab42008-07-30 18:09:17 +00003001 "movs{bl|x}\t{$src, ${dst:subreg32}|${dst:subreg32}, $src}",
3002 [(set GR16:$dst, (sextloadi16i8 addr:$src))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00003003def MOVSX32rr8 : I<0xBE, MRMSrcReg, (outs GR32:$dst), (ins GR8 :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00003004 "movs{bl|x}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003005 [(set GR32:$dst, (sext GR8:$src))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00003006def MOVSX32rm8 : I<0xBE, MRMSrcMem, (outs GR32:$dst), (ins i8mem :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00003007 "movs{bl|x}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003008 [(set GR32:$dst, (sextloadi32i8 addr:$src))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00003009def MOVSX32rr16: I<0xBF, MRMSrcReg, (outs GR32:$dst), (ins GR16:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00003010 "movs{wl|x}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003011 [(set GR32:$dst, (sext GR16:$src))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00003012def MOVSX32rm16: I<0xBF, MRMSrcMem, (outs GR32:$dst), (ins i16mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00003013 "movs{wl|x}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003014 [(set GR32:$dst, (sextloadi32i16 addr:$src))]>, TB;
3015
Dan Gohman9203ab42008-07-30 18:09:17 +00003016// Use movzbl intead of movzbw; we don't care about the high 16 bits
3017// of the register here. This has a smaller encoding and avoids a
3018// partial-register update.
Evan Chengb783fa32007-07-19 01:14:50 +00003019def MOVZX16rr8 : I<0xB6, MRMSrcReg, (outs GR16:$dst), (ins GR8 :$src),
Dan Gohman9203ab42008-07-30 18:09:17 +00003020 "movz{bl|x}\t{$src, ${dst:subreg32}|${dst:subreg32}, $src}",
3021 [(set GR16:$dst, (zext GR8:$src))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00003022def MOVZX16rm8 : I<0xB6, MRMSrcMem, (outs GR16:$dst), (ins i8mem :$src),
Dan Gohman9203ab42008-07-30 18:09:17 +00003023 "movz{bl|x}\t{$src, ${dst:subreg32}|${dst:subreg32}, $src}",
3024 [(set GR16:$dst, (zextloadi16i8 addr:$src))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00003025def MOVZX32rr8 : I<0xB6, MRMSrcReg, (outs GR32:$dst), (ins GR8 :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00003026 "movz{bl|x}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003027 [(set GR32:$dst, (zext GR8:$src))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00003028def MOVZX32rm8 : I<0xB6, MRMSrcMem, (outs GR32:$dst), (ins i8mem :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00003029 "movz{bl|x}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003030 [(set GR32:$dst, (zextloadi32i8 addr:$src))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00003031def MOVZX32rr16: I<0xB7, MRMSrcReg, (outs GR32:$dst), (ins GR16:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00003032 "movz{wl|x}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003033 [(set GR32:$dst, (zext GR16:$src))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00003034def MOVZX32rm16: I<0xB7, MRMSrcMem, (outs GR32:$dst), (ins i16mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00003035 "movz{wl|x}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003036 [(set GR32:$dst, (zextloadi32i16 addr:$src))]>, TB;
3037
Dan Gohman744d4622009-04-13 16:09:41 +00003038// These are the same as the regular regular MOVZX32rr8 and MOVZX32rm8
3039// except that they use GR32_NOREX for the output operand register class
3040// instead of GR32. This allows them to operate on h registers on x86-64.
3041def MOVZX32_NOREXrr8 : I<0xB6, MRMSrcReg,
3042 (outs GR32_NOREX:$dst), (ins GR8:$src),
3043 "movz{bl|x}\t{$src, $dst|$dst, $src} # NOREX",
3044 []>, TB;
Dan Gohman89f4cda2009-04-30 03:11:48 +00003045let mayLoad = 1 in
Dan Gohman744d4622009-04-13 16:09:41 +00003046def MOVZX32_NOREXrm8 : I<0xB6, MRMSrcMem,
3047 (outs GR32_NOREX:$dst), (ins i8mem:$src),
3048 "movz{bl|x}\t{$src, $dst|$dst, $src} # NOREX",
3049 []>, TB;
3050
Chris Lattnerc90ee9c2008-01-10 07:59:24 +00003051let neverHasSideEffects = 1 in {
3052 let Defs = [AX], Uses = [AL] in
3053 def CBW : I<0x98, RawFrm, (outs), (ins),
3054 "{cbtw|cbw}", []>, OpSize; // AX = signext(AL)
3055 let Defs = [EAX], Uses = [AX] in
3056 def CWDE : I<0x98, RawFrm, (outs), (ins),
3057 "{cwtl|cwde}", []>; // EAX = signext(AX)
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003058
Chris Lattnerc90ee9c2008-01-10 07:59:24 +00003059 let Defs = [AX,DX], Uses = [AX] in
3060 def CWD : I<0x99, RawFrm, (outs), (ins),
3061 "{cwtd|cwd}", []>, OpSize; // DX:AX = signext(AX)
3062 let Defs = [EAX,EDX], Uses = [EAX] in
3063 def CDQ : I<0x99, RawFrm, (outs), (ins),
3064 "{cltd|cdq}", []>; // EDX:EAX = signext(EAX)
3065}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003066
3067//===----------------------------------------------------------------------===//
3068// Alias Instructions
3069//===----------------------------------------------------------------------===//
3070
3071// Alias instructions that map movr0 to xor.
3072// FIXME: remove when we can teach regalloc that xor reg, reg is ok.
Bill Wendlingba5d5b02008-05-29 01:02:09 +00003073let Defs = [EFLAGS], isReMaterializable = 1, isAsCheapAsAMove = 1 in {
Evan Chengb783fa32007-07-19 01:14:50 +00003074def MOV8r0 : I<0x30, MRMInitReg, (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00003075 "xor{b}\t$dst, $dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003076 [(set GR8:$dst, 0)]>;
Dan Gohman9203ab42008-07-30 18:09:17 +00003077// Use xorl instead of xorw since we don't care about the high 16 bits,
3078// it's smaller, and it avoids a partial-register update.
Evan Chengb783fa32007-07-19 01:14:50 +00003079def MOV16r0 : I<0x31, MRMInitReg, (outs GR16:$dst), (ins),
Dan Gohman9203ab42008-07-30 18:09:17 +00003080 "xor{l}\t${dst:subreg32}, ${dst:subreg32}",
3081 [(set GR16:$dst, 0)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00003082def MOV32r0 : I<0x31, MRMInitReg, (outs GR32:$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00003083 "xor{l}\t$dst, $dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003084 [(set GR32:$dst, 0)]>;
Dan Gohman8aef09b2007-09-07 21:32:51 +00003085}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003086
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003087//===----------------------------------------------------------------------===//
3088// Thread Local Storage Instructions
3089//
3090
Rafael Espindola7fc4b8d2009-04-24 12:59:40 +00003091// All calls clobber the non-callee saved registers. ESP is marked as
3092// a use to prevent stack-pointer assignments that appear immediately
3093// before calls from potentially appearing dead.
3094let Defs = [EAX, ECX, EDX, FP0, FP1, FP2, FP3, FP4, FP5, FP6, ST0,
3095 MM0, MM1, MM2, MM3, MM4, MM5, MM6, MM7,
3096 XMM0, XMM1, XMM2, XMM3, XMM4, XMM5, XMM6, XMM7,
3097 XMM8, XMM9, XMM10, XMM11, XMM12, XMM13, XMM14, XMM15, EFLAGS],
3098 Uses = [ESP, EBX] in
Rafael Espindolaaf759ab2009-04-17 14:35:58 +00003099def TLS_addr32 : I<0, Pseudo, (outs), (ins i32imm:$sym),
Dan Gohman70a8a112009-04-27 15:13:28 +00003100 "leal\t${sym:mem}(,%ebx,1), %eax; "
3101 "call\t___tls_get_addr@PLT",
Rafael Espindolaaf759ab2009-04-17 14:35:58 +00003102 [(X86tlsaddr tglobaltlsaddr:$sym)]>,
3103 Requires<[In32BitMode]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003104
sampo9cc09a32009-01-26 01:24:32 +00003105let AddedComplexity = 5 in
3106def GS_MOV32rm : I<0x8B, MRMSrcMem, (outs GR32:$dst), (ins i32mem:$src),
3107 "movl\t%gs:$src, $dst",
3108 [(set GR32:$dst, (gsload addr:$src))]>, SegGS;
3109
Chris Lattnera7c2d8a2009-05-05 18:52:19 +00003110let AddedComplexity = 5 in
3111def FS_MOV32rm : I<0x8B, MRMSrcMem, (outs GR32:$dst), (ins i32mem:$src),
3112 "movl\t%fs:$src, $dst",
3113 [(set GR32:$dst, (fsload addr:$src))]>, SegFS;
3114
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003115//===----------------------------------------------------------------------===//
3116// DWARF Pseudo Instructions
3117//
3118
Evan Chengb783fa32007-07-19 01:14:50 +00003119def DWARF_LOC : I<0, Pseudo, (outs),
3120 (ins i32imm:$line, i32imm:$col, i32imm:$file),
Dan Gohman77af4a82007-09-24 19:25:06 +00003121 ".loc\t${file:debug} ${line:debug} ${col:debug}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003122 [(dwarf_loc (i32 imm:$line), (i32 imm:$col),
3123 (i32 imm:$file))]>;
3124
3125//===----------------------------------------------------------------------===//
3126// EH Pseudo Instructions
3127//
3128let isTerminator = 1, isReturn = 1, isBarrier = 1,
Evan Cheng37e7c752007-07-21 00:34:19 +00003129 hasCtrlDep = 1 in {
Evan Chengb783fa32007-07-19 01:14:50 +00003130def EH_RETURN : I<0xC3, RawFrm, (outs), (ins GR32:$addr),
Dan Gohman91888f02007-07-31 20:11:57 +00003131 "ret\t#eh_return, addr: $addr",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003132 [(X86ehret GR32:$addr)]>;
3133
3134}
3135
3136//===----------------------------------------------------------------------===//
Andrew Lenharthe44f3902008-02-21 06:45:13 +00003137// Atomic support
3138//
Andrew Lenharth7a5a4b22008-03-01 13:37:02 +00003139
Evan Cheng3e171562008-04-19 01:20:30 +00003140// Atomic swap. These are just normal xchg instructions. But since a memory
3141// operand is referenced, the atomicity is ensured.
Dan Gohmana41a1c092008-08-06 15:52:50 +00003142let Constraints = "$val = $dst" in {
Evan Cheng3e171562008-04-19 01:20:30 +00003143def XCHG32rm : I<0x87, MRMSrcMem, (outs GR32:$dst), (ins i32mem:$ptr, GR32:$val),
3144 "xchg{l}\t{$val, $ptr|$ptr, $val}",
3145 [(set GR32:$dst, (atomic_swap_32 addr:$ptr, GR32:$val))]>;
3146def XCHG16rm : I<0x87, MRMSrcMem, (outs GR16:$dst), (ins i16mem:$ptr, GR16:$val),
3147 "xchg{w}\t{$val, $ptr|$ptr, $val}",
3148 [(set GR16:$dst, (atomic_swap_16 addr:$ptr, GR16:$val))]>,
3149 OpSize;
3150def XCHG8rm : I<0x86, MRMSrcMem, (outs GR8:$dst), (ins i8mem:$ptr, GR8:$val),
3151 "xchg{b}\t{$val, $ptr|$ptr, $val}",
3152 [(set GR8:$dst, (atomic_swap_8 addr:$ptr, GR8:$val))]>;
3153}
3154
Evan Chengd49dbb82008-04-18 20:55:36 +00003155// Atomic compare and swap.
Andrew Lenharth7dfe23f2008-03-01 21:52:34 +00003156let Defs = [EAX, EFLAGS], Uses = [EAX] in {
Evan Chengd49dbb82008-04-18 20:55:36 +00003157def LCMPXCHG32 : I<0xB1, MRMDestMem, (outs), (ins i32mem:$ptr, GR32:$swap),
Dan Gohman70a8a112009-04-27 15:13:28 +00003158 "lock\n\t"
3159 "cmpxchg{l}\t{$swap, $ptr|$ptr, $swap}",
Evan Cheng09fbdee2008-03-04 03:20:06 +00003160 [(X86cas addr:$ptr, GR32:$swap, 4)]>, TB, LOCK;
Andrew Lenharth7a5a4b22008-03-01 13:37:02 +00003161}
Dale Johannesenf160d802008-10-02 18:53:47 +00003162let Defs = [EAX, EDX, EFLAGS], Uses = [EAX, EBX, ECX, EDX] in {
Anton Korobeynikovc4067392008-07-22 16:22:48 +00003163def LCMPXCHG8B : I<0xC7, MRM1m, (outs), (ins i32mem:$ptr),
Dan Gohman70a8a112009-04-27 15:13:28 +00003164 "lock\n\t"
3165 "cmpxchg8b\t$ptr",
Andrew Lenharth81580822008-03-05 01:15:49 +00003166 [(X86cas8 addr:$ptr)]>, TB, LOCK;
3167}
Andrew Lenharth7dfe23f2008-03-01 21:52:34 +00003168
3169let Defs = [AX, EFLAGS], Uses = [AX] in {
Evan Chengd49dbb82008-04-18 20:55:36 +00003170def LCMPXCHG16 : I<0xB1, MRMDestMem, (outs), (ins i16mem:$ptr, GR16:$swap),
Dan Gohman70a8a112009-04-27 15:13:28 +00003171 "lock\n\t"
3172 "cmpxchg{w}\t{$swap, $ptr|$ptr, $swap}",
Evan Cheng09fbdee2008-03-04 03:20:06 +00003173 [(X86cas addr:$ptr, GR16:$swap, 2)]>, TB, OpSize, LOCK;
Andrew Lenharth7a5a4b22008-03-01 13:37:02 +00003174}
Andrew Lenharth7dfe23f2008-03-01 21:52:34 +00003175let Defs = [AL, EFLAGS], Uses = [AL] in {
Evan Chengd49dbb82008-04-18 20:55:36 +00003176def LCMPXCHG8 : I<0xB0, MRMDestMem, (outs), (ins i8mem:$ptr, GR8:$swap),
Dan Gohman70a8a112009-04-27 15:13:28 +00003177 "lock\n\t"
3178 "cmpxchg{b}\t{$swap, $ptr|$ptr, $swap}",
Evan Cheng09fbdee2008-03-04 03:20:06 +00003179 [(X86cas addr:$ptr, GR8:$swap, 1)]>, TB, LOCK;
Andrew Lenharth7a5a4b22008-03-01 13:37:02 +00003180}
3181
Evan Chengd49dbb82008-04-18 20:55:36 +00003182// Atomic exchange and add
3183let Constraints = "$val = $dst", Defs = [EFLAGS] in {
3184def LXADD32 : I<0xC1, MRMSrcMem, (outs GR32:$dst), (ins i32mem:$ptr, GR32:$val),
Dan Gohman70a8a112009-04-27 15:13:28 +00003185 "lock\n\t"
3186 "xadd{l}\t{$val, $ptr|$ptr, $val}",
Mon P Wang6bde9ec2008-06-25 08:15:39 +00003187 [(set GR32:$dst, (atomic_load_add_32 addr:$ptr, GR32:$val))]>,
Evan Chengd49dbb82008-04-18 20:55:36 +00003188 TB, LOCK;
3189def LXADD16 : I<0xC1, MRMSrcMem, (outs GR16:$dst), (ins i16mem:$ptr, GR16:$val),
Dan Gohman70a8a112009-04-27 15:13:28 +00003190 "lock\n\t"
3191 "xadd{w}\t{$val, $ptr|$ptr, $val}",
Mon P Wang6bde9ec2008-06-25 08:15:39 +00003192 [(set GR16:$dst, (atomic_load_add_16 addr:$ptr, GR16:$val))]>,
Evan Chengd49dbb82008-04-18 20:55:36 +00003193 TB, OpSize, LOCK;
3194def LXADD8 : I<0xC0, MRMSrcMem, (outs GR8:$dst), (ins i8mem:$ptr, GR8:$val),
Dan Gohman70a8a112009-04-27 15:13:28 +00003195 "lock\n\t"
3196 "xadd{b}\t{$val, $ptr|$ptr, $val}",
Mon P Wang6bde9ec2008-06-25 08:15:39 +00003197 [(set GR8:$dst, (atomic_load_add_8 addr:$ptr, GR8:$val))]>,
Evan Chengd49dbb82008-04-18 20:55:36 +00003198 TB, LOCK;
Andrew Lenharth7a5a4b22008-03-01 13:37:02 +00003199}
3200
Mon P Wang6bde9ec2008-06-25 08:15:39 +00003201// Atomic exchange, and, or, xor
Mon P Wang078a62d2008-05-05 19:05:59 +00003202let Constraints = "$val = $dst", Defs = [EFLAGS],
3203 usesCustomDAGSchedInserter = 1 in {
Dan Gohman8aeb61f2008-05-12 20:22:45 +00003204def ATOMAND32 : I<0, Pseudo, (outs GR32:$dst),(ins i32mem:$ptr, GR32:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003205 "#ATOMAND32 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003206 [(set GR32:$dst, (atomic_load_and_32 addr:$ptr, GR32:$val))]>;
Dan Gohman8aeb61f2008-05-12 20:22:45 +00003207def ATOMOR32 : I<0, Pseudo, (outs GR32:$dst),(ins i32mem:$ptr, GR32:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003208 "#ATOMOR32 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003209 [(set GR32:$dst, (atomic_load_or_32 addr:$ptr, GR32:$val))]>;
Dan Gohman8aeb61f2008-05-12 20:22:45 +00003210def ATOMXOR32 : I<0, Pseudo,(outs GR32:$dst),(ins i32mem:$ptr, GR32:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003211 "#ATOMXOR32 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003212 [(set GR32:$dst, (atomic_load_xor_32 addr:$ptr, GR32:$val))]>;
Andrew Lenharthaf02d592008-06-14 05:48:15 +00003213def ATOMNAND32 : I<0, Pseudo,(outs GR32:$dst),(ins i32mem:$ptr, GR32:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003214 "#ATOMNAND32 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003215 [(set GR32:$dst, (atomic_load_nand_32 addr:$ptr, GR32:$val))]>;
Dan Gohman8aeb61f2008-05-12 20:22:45 +00003216def ATOMMIN32: I<0, Pseudo, (outs GR32:$dst), (ins i32mem:$ptr, GR32:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003217 "#ATOMMIN32 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003218 [(set GR32:$dst, (atomic_load_min_32 addr:$ptr, GR32:$val))]>;
Dan Gohman8aeb61f2008-05-12 20:22:45 +00003219def ATOMMAX32: I<0, Pseudo, (outs GR32:$dst),(ins i32mem:$ptr, GR32:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003220 "#ATOMMAX32 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003221 [(set GR32:$dst, (atomic_load_max_32 addr:$ptr, GR32:$val))]>;
Dan Gohman8aeb61f2008-05-12 20:22:45 +00003222def ATOMUMIN32: I<0, Pseudo, (outs GR32:$dst),(ins i32mem:$ptr, GR32:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003223 "#ATOMUMIN32 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003224 [(set GR32:$dst, (atomic_load_umin_32 addr:$ptr, GR32:$val))]>;
Dan Gohman8aeb61f2008-05-12 20:22:45 +00003225def ATOMUMAX32: I<0, Pseudo, (outs GR32:$dst),(ins i32mem:$ptr, GR32:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003226 "#ATOMUMAX32 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003227 [(set GR32:$dst, (atomic_load_umax_32 addr:$ptr, GR32:$val))]>;
Dale Johannesend20e4452008-08-19 18:47:28 +00003228
3229def ATOMAND16 : I<0, Pseudo, (outs GR16:$dst),(ins i16mem:$ptr, GR16:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003230 "#ATOMAND16 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003231 [(set GR16:$dst, (atomic_load_and_16 addr:$ptr, GR16:$val))]>;
Dale Johannesend20e4452008-08-19 18:47:28 +00003232def ATOMOR16 : I<0, Pseudo, (outs GR16:$dst),(ins i16mem:$ptr, GR16:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003233 "#ATOMOR16 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003234 [(set GR16:$dst, (atomic_load_or_16 addr:$ptr, GR16:$val))]>;
Dale Johannesend20e4452008-08-19 18:47:28 +00003235def ATOMXOR16 : I<0, Pseudo,(outs GR16:$dst),(ins i16mem:$ptr, GR16:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003236 "#ATOMXOR16 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003237 [(set GR16:$dst, (atomic_load_xor_16 addr:$ptr, GR16:$val))]>;
Dale Johannesend20e4452008-08-19 18:47:28 +00003238def ATOMNAND16 : I<0, Pseudo,(outs GR16:$dst),(ins i16mem:$ptr, GR16:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003239 "#ATOMNAND16 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003240 [(set GR16:$dst, (atomic_load_nand_16 addr:$ptr, GR16:$val))]>;
Dale Johannesend20e4452008-08-19 18:47:28 +00003241def ATOMMIN16: I<0, Pseudo, (outs GR16:$dst), (ins i16mem:$ptr, GR16:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003242 "#ATOMMIN16 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003243 [(set GR16:$dst, (atomic_load_min_16 addr:$ptr, GR16:$val))]>;
Dale Johannesend20e4452008-08-19 18:47:28 +00003244def ATOMMAX16: I<0, Pseudo, (outs GR16:$dst),(ins i16mem:$ptr, GR16:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003245 "#ATOMMAX16 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003246 [(set GR16:$dst, (atomic_load_max_16 addr:$ptr, GR16:$val))]>;
Dale Johannesend20e4452008-08-19 18:47:28 +00003247def ATOMUMIN16: I<0, Pseudo, (outs GR16:$dst),(ins i16mem:$ptr, GR16:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003248 "#ATOMUMIN16 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003249 [(set GR16:$dst, (atomic_load_umin_16 addr:$ptr, GR16:$val))]>;
Dale Johannesend20e4452008-08-19 18:47:28 +00003250def ATOMUMAX16: I<0, Pseudo, (outs GR16:$dst),(ins i16mem:$ptr, GR16:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003251 "#ATOMUMAX16 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003252 [(set GR16:$dst, (atomic_load_umax_16 addr:$ptr, GR16:$val))]>;
Dale Johannesend20e4452008-08-19 18:47:28 +00003253
3254def ATOMAND8 : I<0, Pseudo, (outs GR8:$dst),(ins i8mem:$ptr, GR8:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003255 "#ATOMAND8 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003256 [(set GR8:$dst, (atomic_load_and_8 addr:$ptr, GR8:$val))]>;
Dale Johannesend20e4452008-08-19 18:47:28 +00003257def ATOMOR8 : I<0, Pseudo, (outs GR8:$dst),(ins i8mem:$ptr, GR8:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003258 "#ATOMOR8 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003259 [(set GR8:$dst, (atomic_load_or_8 addr:$ptr, GR8:$val))]>;
Dale Johannesend20e4452008-08-19 18:47:28 +00003260def ATOMXOR8 : I<0, Pseudo,(outs GR8:$dst),(ins i8mem:$ptr, GR8:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003261 "#ATOMXOR8 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003262 [(set GR8:$dst, (atomic_load_xor_8 addr:$ptr, GR8:$val))]>;
Dale Johannesend20e4452008-08-19 18:47:28 +00003263def ATOMNAND8 : I<0, Pseudo,(outs GR8:$dst),(ins i8mem:$ptr, GR8:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003264 "#ATOMNAND8 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003265 [(set GR8:$dst, (atomic_load_nand_8 addr:$ptr, GR8:$val))]>;
Mon P Wang078a62d2008-05-05 19:05:59 +00003266}
3267
Dale Johannesenf160d802008-10-02 18:53:47 +00003268let Constraints = "$val1 = $dst1, $val2 = $dst2",
3269 Defs = [EFLAGS, EAX, EBX, ECX, EDX],
3270 Uses = [EAX, EBX, ECX, EDX],
Dale Johannesen44eb5372008-10-03 19:41:08 +00003271 mayLoad = 1, mayStore = 1,
Dale Johannesenf160d802008-10-02 18:53:47 +00003272 usesCustomDAGSchedInserter = 1 in {
3273def ATOMAND6432 : I<0, Pseudo, (outs GR32:$dst1, GR32:$dst2),
3274 (ins i64mem:$ptr, GR32:$val1, GR32:$val2),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003275 "#ATOMAND6432 PSEUDO!", []>;
Dale Johannesenf160d802008-10-02 18:53:47 +00003276def ATOMOR6432 : I<0, Pseudo, (outs GR32:$dst1, GR32:$dst2),
3277 (ins i64mem:$ptr, GR32:$val1, GR32:$val2),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003278 "#ATOMOR6432 PSEUDO!", []>;
Dale Johannesenf160d802008-10-02 18:53:47 +00003279def ATOMXOR6432 : I<0, Pseudo, (outs GR32:$dst1, GR32:$dst2),
3280 (ins i64mem:$ptr, GR32:$val1, GR32:$val2),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003281 "#ATOMXOR6432 PSEUDO!", []>;
Dale Johannesenf160d802008-10-02 18:53:47 +00003282def ATOMNAND6432 : I<0, Pseudo, (outs GR32:$dst1, GR32:$dst2),
3283 (ins i64mem:$ptr, GR32:$val1, GR32:$val2),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003284 "#ATOMNAND6432 PSEUDO!", []>;
Dale Johannesenf160d802008-10-02 18:53:47 +00003285def ATOMADD6432 : I<0, Pseudo, (outs GR32:$dst1, GR32:$dst2),
3286 (ins i64mem:$ptr, GR32:$val1, GR32:$val2),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003287 "#ATOMADD6432 PSEUDO!", []>;
Dale Johannesenf160d802008-10-02 18:53:47 +00003288def ATOMSUB6432 : I<0, Pseudo, (outs GR32:$dst1, GR32:$dst2),
3289 (ins i64mem:$ptr, GR32:$val1, GR32:$val2),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003290 "#ATOMSUB6432 PSEUDO!", []>;
Dale Johannesen51c58ee2008-10-03 22:25:52 +00003291def ATOMSWAP6432 : I<0, Pseudo, (outs GR32:$dst1, GR32:$dst2),
3292 (ins i64mem:$ptr, GR32:$val1, GR32:$val2),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003293 "#ATOMSWAP6432 PSEUDO!", []>;
Dale Johannesenf160d802008-10-02 18:53:47 +00003294}
3295
Andrew Lenharthe44f3902008-02-21 06:45:13 +00003296//===----------------------------------------------------------------------===//
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003297// Non-Instruction Patterns
3298//===----------------------------------------------------------------------===//
3299
Bill Wendlingfef06052008-09-16 21:48:12 +00003300// ConstantPool GlobalAddress, ExternalSymbol, and JumpTable
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003301def : Pat<(i32 (X86Wrapper tconstpool :$dst)), (MOV32ri tconstpool :$dst)>;
3302def : Pat<(i32 (X86Wrapper tjumptable :$dst)), (MOV32ri tjumptable :$dst)>;
Nate Begemanb52948972008-04-12 00:47:57 +00003303def : Pat<(i32 (X86Wrapper tglobaltlsaddr:$dst)),(MOV32ri tglobaltlsaddr:$dst)>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003304def : Pat<(i32 (X86Wrapper tglobaladdr :$dst)), (MOV32ri tglobaladdr :$dst)>;
3305def : Pat<(i32 (X86Wrapper texternalsym:$dst)), (MOV32ri texternalsym:$dst)>;
3306
3307def : Pat<(add GR32:$src1, (X86Wrapper tconstpool:$src2)),
3308 (ADD32ri GR32:$src1, tconstpool:$src2)>;
3309def : Pat<(add GR32:$src1, (X86Wrapper tjumptable:$src2)),
3310 (ADD32ri GR32:$src1, tjumptable:$src2)>;
3311def : Pat<(add GR32:$src1, (X86Wrapper tglobaladdr :$src2)),
3312 (ADD32ri GR32:$src1, tglobaladdr:$src2)>;
3313def : Pat<(add GR32:$src1, (X86Wrapper texternalsym:$src2)),
3314 (ADD32ri GR32:$src1, texternalsym:$src2)>;
3315
3316def : Pat<(store (i32 (X86Wrapper tglobaladdr:$src)), addr:$dst),
3317 (MOV32mi addr:$dst, tglobaladdr:$src)>;
3318def : Pat<(store (i32 (X86Wrapper texternalsym:$src)), addr:$dst),
3319 (MOV32mi addr:$dst, texternalsym:$src)>;
3320
3321// Calls
Arnold Schwaighofere2d6bbb2007-10-11 19:40:01 +00003322// tailcall stuff
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003323def : Pat<(X86tailcall GR32:$dst),
Arnold Schwaighofere2d6bbb2007-10-11 19:40:01 +00003324 (TAILCALL)>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003325
3326def : Pat<(X86tailcall (i32 tglobaladdr:$dst)),
Arnold Schwaighofere2d6bbb2007-10-11 19:40:01 +00003327 (TAILCALL)>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003328def : Pat<(X86tailcall (i32 texternalsym:$dst)),
Arnold Schwaighofere2d6bbb2007-10-11 19:40:01 +00003329 (TAILCALL)>;
3330
3331def : Pat<(X86tcret GR32:$dst, imm:$off),
3332 (TCRETURNri GR32:$dst, imm:$off)>;
3333
3334def : Pat<(X86tcret (i32 tglobaladdr:$dst), imm:$off),
3335 (TCRETURNdi texternalsym:$dst, imm:$off)>;
3336
3337def : Pat<(X86tcret (i32 texternalsym:$dst), imm:$off),
3338 (TCRETURNdi texternalsym:$dst, imm:$off)>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003339
3340def : Pat<(X86call (i32 tglobaladdr:$dst)),
3341 (CALLpcrel32 tglobaladdr:$dst)>;
3342def : Pat<(X86call (i32 texternalsym:$dst)),
3343 (CALLpcrel32 texternalsym:$dst)>;
Evan Cheng6d35a4d2009-05-20 04:53:57 +00003344def : Pat<(X86call (i32 imm:$dst)),
3345 (CALLpcrel32 imm:$dst)>, Requires<[CallImmAddr]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003346
3347// X86 specific add which produces a flag.
3348def : Pat<(addc GR32:$src1, GR32:$src2),
3349 (ADD32rr GR32:$src1, GR32:$src2)>;
3350def : Pat<(addc GR32:$src1, (load addr:$src2)),
3351 (ADD32rm GR32:$src1, addr:$src2)>;
3352def : Pat<(addc GR32:$src1, imm:$src2),
3353 (ADD32ri GR32:$src1, imm:$src2)>;
3354def : Pat<(addc GR32:$src1, i32immSExt8:$src2),
3355 (ADD32ri8 GR32:$src1, i32immSExt8:$src2)>;
3356
3357def : Pat<(subc GR32:$src1, GR32:$src2),
3358 (SUB32rr GR32:$src1, GR32:$src2)>;
3359def : Pat<(subc GR32:$src1, (load addr:$src2)),
3360 (SUB32rm GR32:$src1, addr:$src2)>;
3361def : Pat<(subc GR32:$src1, imm:$src2),
3362 (SUB32ri GR32:$src1, imm:$src2)>;
3363def : Pat<(subc GR32:$src1, i32immSExt8:$src2),
3364 (SUB32ri8 GR32:$src1, i32immSExt8:$src2)>;
3365
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003366// Comparisons.
3367
3368// TEST R,R is smaller than CMP R,0
Evan Cheng621216e2007-09-29 00:00:36 +00003369def : Pat<(parallel (X86cmp GR8:$src1, 0), (implicit EFLAGS)),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003370 (TEST8rr GR8:$src1, GR8:$src1)>;
Evan Cheng621216e2007-09-29 00:00:36 +00003371def : Pat<(parallel (X86cmp GR16:$src1, 0), (implicit EFLAGS)),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003372 (TEST16rr GR16:$src1, GR16:$src1)>;
Evan Cheng621216e2007-09-29 00:00:36 +00003373def : Pat<(parallel (X86cmp GR32:$src1, 0), (implicit EFLAGS)),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003374 (TEST32rr GR32:$src1, GR32:$src1)>;
3375
Dan Gohman0a3c5222009-01-07 01:00:24 +00003376// Conditional moves with folded loads with operands swapped and conditions
3377// inverted.
3378def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_B, EFLAGS),
3379 (CMOVAE16rm GR16:$src2, addr:$src1)>;
3380def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_B, EFLAGS),
3381 (CMOVAE32rm GR32:$src2, addr:$src1)>;
3382def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_AE, EFLAGS),
3383 (CMOVB16rm GR16:$src2, addr:$src1)>;
3384def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_AE, EFLAGS),
3385 (CMOVB32rm GR32:$src2, addr:$src1)>;
3386def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_E, EFLAGS),
3387 (CMOVNE16rm GR16:$src2, addr:$src1)>;
3388def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_E, EFLAGS),
3389 (CMOVNE32rm GR32:$src2, addr:$src1)>;
3390def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_NE, EFLAGS),
3391 (CMOVE16rm GR16:$src2, addr:$src1)>;
3392def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_NE, EFLAGS),
3393 (CMOVE32rm GR32:$src2, addr:$src1)>;
3394def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_BE, EFLAGS),
3395 (CMOVA16rm GR16:$src2, addr:$src1)>;
3396def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_BE, EFLAGS),
3397 (CMOVA32rm GR32:$src2, addr:$src1)>;
3398def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_A, EFLAGS),
3399 (CMOVBE16rm GR16:$src2, addr:$src1)>;
3400def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_A, EFLAGS),
3401 (CMOVBE32rm GR32:$src2, addr:$src1)>;
3402def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_L, EFLAGS),
3403 (CMOVGE16rm GR16:$src2, addr:$src1)>;
3404def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_L, EFLAGS),
3405 (CMOVGE32rm GR32:$src2, addr:$src1)>;
3406def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_GE, EFLAGS),
3407 (CMOVL16rm GR16:$src2, addr:$src1)>;
3408def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_GE, EFLAGS),
3409 (CMOVL32rm GR32:$src2, addr:$src1)>;
3410def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_LE, EFLAGS),
3411 (CMOVG16rm GR16:$src2, addr:$src1)>;
3412def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_LE, EFLAGS),
3413 (CMOVG32rm GR32:$src2, addr:$src1)>;
3414def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_G, EFLAGS),
3415 (CMOVLE16rm GR16:$src2, addr:$src1)>;
3416def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_G, EFLAGS),
3417 (CMOVLE32rm GR32:$src2, addr:$src1)>;
3418def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_P, EFLAGS),
3419 (CMOVNP16rm GR16:$src2, addr:$src1)>;
3420def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_P, EFLAGS),
3421 (CMOVNP32rm GR32:$src2, addr:$src1)>;
3422def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_NP, EFLAGS),
3423 (CMOVP16rm GR16:$src2, addr:$src1)>;
3424def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_NP, EFLAGS),
3425 (CMOVP32rm GR32:$src2, addr:$src1)>;
3426def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_S, EFLAGS),
3427 (CMOVNS16rm GR16:$src2, addr:$src1)>;
3428def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_S, EFLAGS),
3429 (CMOVNS32rm GR32:$src2, addr:$src1)>;
3430def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_NS, EFLAGS),
3431 (CMOVS16rm GR16:$src2, addr:$src1)>;
3432def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_NS, EFLAGS),
3433 (CMOVS32rm GR32:$src2, addr:$src1)>;
3434def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_O, EFLAGS),
3435 (CMOVNO16rm GR16:$src2, addr:$src1)>;
3436def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_O, EFLAGS),
3437 (CMOVNO32rm GR32:$src2, addr:$src1)>;
3438def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_NO, EFLAGS),
3439 (CMOVO16rm GR16:$src2, addr:$src1)>;
3440def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_NO, EFLAGS),
3441 (CMOVO32rm GR32:$src2, addr:$src1)>;
3442
Duncan Sands082524c2008-01-23 20:39:46 +00003443// zextload bool -> zextload byte
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003444def : Pat<(zextloadi8i1 addr:$src), (MOV8rm addr:$src)>;
3445def : Pat<(zextloadi16i1 addr:$src), (MOVZX16rm8 addr:$src)>;
3446def : Pat<(zextloadi32i1 addr:$src), (MOVZX32rm8 addr:$src)>;
3447
3448// extload bool -> extload byte
3449def : Pat<(extloadi8i1 addr:$src), (MOV8rm addr:$src)>;
Bill Wendlingce1c5c12008-08-22 20:51:05 +00003450def : Pat<(extloadi16i1 addr:$src), (MOVZX16rm8 addr:$src)>,
3451 Requires<[In32BitMode]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003452def : Pat<(extloadi32i1 addr:$src), (MOVZX32rm8 addr:$src)>;
Bill Wendlingce1c5c12008-08-22 20:51:05 +00003453def : Pat<(extloadi16i8 addr:$src), (MOVZX16rm8 addr:$src)>,
3454 Requires<[In32BitMode]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003455def : Pat<(extloadi32i8 addr:$src), (MOVZX32rm8 addr:$src)>;
3456def : Pat<(extloadi32i16 addr:$src), (MOVZX32rm16 addr:$src)>;
3457
Dan Gohmandd612bb2008-08-20 21:27:32 +00003458// anyext
Bill Wendlingce1c5c12008-08-22 20:51:05 +00003459def : Pat<(i16 (anyext GR8 :$src)), (MOVZX16rr8 GR8 :$src)>,
3460 Requires<[In32BitMode]>;
3461def : Pat<(i32 (anyext GR8 :$src)), (MOVZX32rr8 GR8 :$src)>,
3462 Requires<[In32BitMode]>;
Dan Gohmandd612bb2008-08-20 21:27:32 +00003463def : Pat<(i32 (anyext GR16:$src)),
3464 (INSERT_SUBREG (i32 (IMPLICIT_DEF)), GR16:$src, x86_subreg_16bit)>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003465
Evan Chengf2abee72007-12-13 00:43:27 +00003466// (and (i32 load), 255) -> (zextload i8)
Evan Cheng1e5e5452008-09-29 17:26:18 +00003467def : Pat<(i32 (and (nvloadi32 addr:$src), (i32 255))),
3468 (MOVZX32rm8 addr:$src)>;
3469def : Pat<(i32 (and (nvloadi32 addr:$src), (i32 65535))),
3470 (MOVZX32rm16 addr:$src)>;
Evan Chengf2abee72007-12-13 00:43:27 +00003471
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003472//===----------------------------------------------------------------------===//
3473// Some peepholes
3474//===----------------------------------------------------------------------===//
3475
Dan Gohman5a5e6e92008-10-17 01:33:43 +00003476// Odd encoding trick: -128 fits into an 8-bit immediate field while
3477// +128 doesn't, so in this special case use a sub instead of an add.
3478def : Pat<(add GR16:$src1, 128),
3479 (SUB16ri8 GR16:$src1, -128)>;
3480def : Pat<(store (add (loadi16 addr:$dst), 128), addr:$dst),
3481 (SUB16mi8 addr:$dst, -128)>;
3482def : Pat<(add GR32:$src1, 128),
3483 (SUB32ri8 GR32:$src1, -128)>;
3484def : Pat<(store (add (loadi32 addr:$dst), 128), addr:$dst),
3485 (SUB32mi8 addr:$dst, -128)>;
3486
Dan Gohman9203ab42008-07-30 18:09:17 +00003487// r & (2^16-1) ==> movz
3488def : Pat<(and GR32:$src1, 0xffff),
Dan Gohman744d4622009-04-13 16:09:41 +00003489 (MOVZX32rr16 (EXTRACT_SUBREG GR32:$src1, x86_subreg_16bit))>;
Dan Gohman5beb1ff2008-08-06 18:27:21 +00003490// r & (2^8-1) ==> movz
3491def : Pat<(and GR32:$src1, 0xff),
Dan Gohman6e438702009-04-27 16:33:14 +00003492 (MOVZX32rr8 (EXTRACT_SUBREG (COPY_TO_REGCLASS GR32:$src1, GR32_ABCD),
Dan Gohman744d4622009-04-13 16:09:41 +00003493 x86_subreg_8bit))>,
Dan Gohman5beb1ff2008-08-06 18:27:21 +00003494 Requires<[In32BitMode]>;
3495// r & (2^8-1) ==> movz
3496def : Pat<(and GR16:$src1, 0xff),
Dan Gohman6e438702009-04-27 16:33:14 +00003497 (MOVZX16rr8 (EXTRACT_SUBREG (COPY_TO_REGCLASS GR16:$src1, GR16_ABCD),
Dan Gohman744d4622009-04-13 16:09:41 +00003498 x86_subreg_8bit))>,
Dan Gohmandd612bb2008-08-20 21:27:32 +00003499 Requires<[In32BitMode]>;
3500
3501// sext_inreg patterns
3502def : Pat<(sext_inreg GR32:$src, i16),
Dan Gohman744d4622009-04-13 16:09:41 +00003503 (MOVSX32rr16 (EXTRACT_SUBREG GR32:$src, x86_subreg_16bit))>;
Dan Gohmandd612bb2008-08-20 21:27:32 +00003504def : Pat<(sext_inreg GR32:$src, i8),
Dan Gohman6e438702009-04-27 16:33:14 +00003505 (MOVSX32rr8 (EXTRACT_SUBREG (COPY_TO_REGCLASS GR32:$src, GR32_ABCD),
Dan Gohman744d4622009-04-13 16:09:41 +00003506 x86_subreg_8bit))>,
Dan Gohmandd612bb2008-08-20 21:27:32 +00003507 Requires<[In32BitMode]>;
3508def : Pat<(sext_inreg GR16:$src, i8),
Dan Gohman6e438702009-04-27 16:33:14 +00003509 (MOVSX16rr8 (EXTRACT_SUBREG (COPY_TO_REGCLASS GR16:$src, GR16_ABCD),
Dan Gohman744d4622009-04-13 16:09:41 +00003510 x86_subreg_8bit))>,
Dan Gohmandd612bb2008-08-20 21:27:32 +00003511 Requires<[In32BitMode]>;
3512
3513// trunc patterns
3514def : Pat<(i16 (trunc GR32:$src)),
Dan Gohman744d4622009-04-13 16:09:41 +00003515 (EXTRACT_SUBREG GR32:$src, x86_subreg_16bit)>;
Dan Gohmandd612bb2008-08-20 21:27:32 +00003516def : Pat<(i8 (trunc GR32:$src)),
Dan Gohman6e438702009-04-27 16:33:14 +00003517 (EXTRACT_SUBREG (COPY_TO_REGCLASS GR32:$src, GR32_ABCD),
Dan Gohman744d4622009-04-13 16:09:41 +00003518 x86_subreg_8bit)>,
Dan Gohmandd612bb2008-08-20 21:27:32 +00003519 Requires<[In32BitMode]>;
3520def : Pat<(i8 (trunc GR16:$src)),
Dan Gohman6e438702009-04-27 16:33:14 +00003521 (EXTRACT_SUBREG (COPY_TO_REGCLASS GR16:$src, GR16_ABCD),
Dan Gohman744d4622009-04-13 16:09:41 +00003522 x86_subreg_8bit)>,
3523 Requires<[In32BitMode]>;
3524
3525// h-register tricks
3526def : Pat<(i8 (trunc (srl_su GR16:$src, (i8 8)))),
Dan Gohman6e438702009-04-27 16:33:14 +00003527 (EXTRACT_SUBREG (COPY_TO_REGCLASS GR16:$src, GR16_ABCD),
Dan Gohman744d4622009-04-13 16:09:41 +00003528 x86_subreg_8bit_hi)>,
3529 Requires<[In32BitMode]>;
3530def : Pat<(i8 (trunc (srl_su GR32:$src, (i8 8)))),
Dan Gohman6e438702009-04-27 16:33:14 +00003531 (EXTRACT_SUBREG (COPY_TO_REGCLASS GR32:$src, GR32_ABCD),
Dan Gohman744d4622009-04-13 16:09:41 +00003532 x86_subreg_8bit_hi)>,
3533 Requires<[In32BitMode]>;
3534def : Pat<(srl_su GR16:$src, (i8 8)),
3535 (EXTRACT_SUBREG
3536 (MOVZX32rr8
Dan Gohman6e438702009-04-27 16:33:14 +00003537 (EXTRACT_SUBREG (COPY_TO_REGCLASS GR16:$src, GR16_ABCD),
Dan Gohman744d4622009-04-13 16:09:41 +00003538 x86_subreg_8bit_hi)),
3539 x86_subreg_16bit)>,
3540 Requires<[In32BitMode]>;
3541def : Pat<(and (srl_su GR32:$src, (i8 8)), (i32 255)),
Dan Gohman6e438702009-04-27 16:33:14 +00003542 (MOVZX32rr8 (EXTRACT_SUBREG (COPY_TO_REGCLASS GR32:$src, GR32_ABCD),
Dan Gohman744d4622009-04-13 16:09:41 +00003543 x86_subreg_8bit_hi))>,
Dan Gohman5beb1ff2008-08-06 18:27:21 +00003544 Requires<[In32BitMode]>;
Dan Gohman9203ab42008-07-30 18:09:17 +00003545
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003546// (shl x, 1) ==> (add x, x)
3547def : Pat<(shl GR8 :$src1, (i8 1)), (ADD8rr GR8 :$src1, GR8 :$src1)>;
3548def : Pat<(shl GR16:$src1, (i8 1)), (ADD16rr GR16:$src1, GR16:$src1)>;
3549def : Pat<(shl GR32:$src1, (i8 1)), (ADD32rr GR32:$src1, GR32:$src1)>;
3550
Evan Cheng76a64c72008-08-30 02:03:58 +00003551// (shl x (and y, 31)) ==> (shl x, y)
3552def : Pat<(shl GR8:$src1, (and CL:$amt, 31)),
3553 (SHL8rCL GR8:$src1)>;
3554def : Pat<(shl GR16:$src1, (and CL:$amt, 31)),
3555 (SHL16rCL GR16:$src1)>;
3556def : Pat<(shl GR32:$src1, (and CL:$amt, 31)),
3557 (SHL32rCL GR32:$src1)>;
3558def : Pat<(store (shl (loadi8 addr:$dst), (and CL:$amt, 31)), addr:$dst),
3559 (SHL8mCL addr:$dst)>;
3560def : Pat<(store (shl (loadi16 addr:$dst), (and CL:$amt, 31)), addr:$dst),
3561 (SHL16mCL addr:$dst)>;
3562def : Pat<(store (shl (loadi32 addr:$dst), (and CL:$amt, 31)), addr:$dst),
3563 (SHL32mCL addr:$dst)>;
3564
3565def : Pat<(srl GR8:$src1, (and CL:$amt, 31)),
3566 (SHR8rCL GR8:$src1)>;
3567def : Pat<(srl GR16:$src1, (and CL:$amt, 31)),
3568 (SHR16rCL GR16:$src1)>;
3569def : Pat<(srl GR32:$src1, (and CL:$amt, 31)),
3570 (SHR32rCL GR32:$src1)>;
3571def : Pat<(store (srl (loadi8 addr:$dst), (and CL:$amt, 31)), addr:$dst),
3572 (SHR8mCL addr:$dst)>;
3573def : Pat<(store (srl (loadi16 addr:$dst), (and CL:$amt, 31)), addr:$dst),
3574 (SHR16mCL addr:$dst)>;
3575def : Pat<(store (srl (loadi32 addr:$dst), (and CL:$amt, 31)), addr:$dst),
3576 (SHR32mCL addr:$dst)>;
3577
3578def : Pat<(sra GR8:$src1, (and CL:$amt, 31)),
3579 (SAR8rCL GR8:$src1)>;
3580def : Pat<(sra GR16:$src1, (and CL:$amt, 31)),
3581 (SAR16rCL GR16:$src1)>;
3582def : Pat<(sra GR32:$src1, (and CL:$amt, 31)),
3583 (SAR32rCL GR32:$src1)>;
3584def : Pat<(store (sra (loadi8 addr:$dst), (and CL:$amt, 31)), addr:$dst),
3585 (SAR8mCL addr:$dst)>;
3586def : Pat<(store (sra (loadi16 addr:$dst), (and CL:$amt, 31)), addr:$dst),
3587 (SAR16mCL addr:$dst)>;
3588def : Pat<(store (sra (loadi32 addr:$dst), (and CL:$amt, 31)), addr:$dst),
3589 (SAR32mCL addr:$dst)>;
3590
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003591// (or (x >> c) | (y << (32 - c))) ==> (shrd32 x, y, c)
3592def : Pat<(or (srl GR32:$src1, CL:$amt),
3593 (shl GR32:$src2, (sub 32, CL:$amt))),
3594 (SHRD32rrCL GR32:$src1, GR32:$src2)>;
3595
3596def : Pat<(store (or (srl (loadi32 addr:$dst), CL:$amt),
3597 (shl GR32:$src2, (sub 32, CL:$amt))), addr:$dst),
3598 (SHRD32mrCL addr:$dst, GR32:$src2)>;
3599
Dan Gohman921581d2008-10-17 01:23:35 +00003600def : Pat<(or (srl GR32:$src1, (i8 (trunc ECX:$amt))),
3601 (shl GR32:$src2, (i8 (trunc (sub 32, ECX:$amt))))),
3602 (SHRD32rrCL GR32:$src1, GR32:$src2)>;
3603
3604def : Pat<(store (or (srl (loadi32 addr:$dst), (i8 (trunc ECX:$amt))),
3605 (shl GR32:$src2, (i8 (trunc (sub 32, ECX:$amt))))),
3606 addr:$dst),
3607 (SHRD32mrCL addr:$dst, GR32:$src2)>;
3608
3609def : Pat<(shrd GR32:$src1, (i8 imm:$amt1), GR32:$src2, (i8 imm:$amt2)),
3610 (SHRD32rri8 GR32:$src1, GR32:$src2, (i8 imm:$amt1))>;
3611
3612def : Pat<(store (shrd (loadi32 addr:$dst), (i8 imm:$amt1),
3613 GR32:$src2, (i8 imm:$amt2)), addr:$dst),
3614 (SHRD32mri8 addr:$dst, GR32:$src2, (i8 imm:$amt1))>;
3615
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003616// (or (x << c) | (y >> (32 - c))) ==> (shld32 x, y, c)
3617def : Pat<(or (shl GR32:$src1, CL:$amt),
3618 (srl GR32:$src2, (sub 32, CL:$amt))),
3619 (SHLD32rrCL GR32:$src1, GR32:$src2)>;
3620
3621def : Pat<(store (or (shl (loadi32 addr:$dst), CL:$amt),
3622 (srl GR32:$src2, (sub 32, CL:$amt))), addr:$dst),
3623 (SHLD32mrCL addr:$dst, GR32:$src2)>;
3624
Dan Gohman921581d2008-10-17 01:23:35 +00003625def : Pat<(or (shl GR32:$src1, (i8 (trunc ECX:$amt))),
3626 (srl GR32:$src2, (i8 (trunc (sub 32, ECX:$amt))))),
3627 (SHLD32rrCL GR32:$src1, GR32:$src2)>;
3628
3629def : Pat<(store (or (shl (loadi32 addr:$dst), (i8 (trunc ECX:$amt))),
3630 (srl GR32:$src2, (i8 (trunc (sub 32, ECX:$amt))))),
3631 addr:$dst),
3632 (SHLD32mrCL addr:$dst, GR32:$src2)>;
3633
3634def : Pat<(shld GR32:$src1, (i8 imm:$amt1), GR32:$src2, (i8 imm:$amt2)),
3635 (SHLD32rri8 GR32:$src1, GR32:$src2, (i8 imm:$amt1))>;
3636
3637def : Pat<(store (shld (loadi32 addr:$dst), (i8 imm:$amt1),
3638 GR32:$src2, (i8 imm:$amt2)), addr:$dst),
3639 (SHLD32mri8 addr:$dst, GR32:$src2, (i8 imm:$amt1))>;
3640
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003641// (or (x >> c) | (y << (16 - c))) ==> (shrd16 x, y, c)
3642def : Pat<(or (srl GR16:$src1, CL:$amt),
3643 (shl GR16:$src2, (sub 16, CL:$amt))),
3644 (SHRD16rrCL GR16:$src1, GR16:$src2)>;
3645
3646def : Pat<(store (or (srl (loadi16 addr:$dst), CL:$amt),
3647 (shl GR16:$src2, (sub 16, CL:$amt))), addr:$dst),
3648 (SHRD16mrCL addr:$dst, GR16:$src2)>;
3649
Dan Gohman921581d2008-10-17 01:23:35 +00003650def : Pat<(or (srl GR16:$src1, (i8 (trunc CX:$amt))),
3651 (shl GR16:$src2, (i8 (trunc (sub 16, CX:$amt))))),
3652 (SHRD16rrCL GR16:$src1, GR16:$src2)>;
3653
3654def : Pat<(store (or (srl (loadi16 addr:$dst), (i8 (trunc CX:$amt))),
3655 (shl GR16:$src2, (i8 (trunc (sub 16, CX:$amt))))),
3656 addr:$dst),
3657 (SHRD16mrCL addr:$dst, GR16:$src2)>;
3658
3659def : Pat<(shrd GR16:$src1, (i8 imm:$amt1), GR16:$src2, (i8 imm:$amt2)),
3660 (SHRD16rri8 GR16:$src1, GR16:$src2, (i8 imm:$amt1))>;
3661
3662def : Pat<(store (shrd (loadi16 addr:$dst), (i8 imm:$amt1),
3663 GR16:$src2, (i8 imm:$amt2)), addr:$dst),
3664 (SHRD16mri8 addr:$dst, GR16:$src2, (i8 imm:$amt1))>;
3665
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003666// (or (x << c) | (y >> (16 - c))) ==> (shld16 x, y, c)
3667def : Pat<(or (shl GR16:$src1, CL:$amt),
3668 (srl GR16:$src2, (sub 16, CL:$amt))),
3669 (SHLD16rrCL GR16:$src1, GR16:$src2)>;
3670
3671def : Pat<(store (or (shl (loadi16 addr:$dst), CL:$amt),
3672 (srl GR16:$src2, (sub 16, CL:$amt))), addr:$dst),
3673 (SHLD16mrCL addr:$dst, GR16:$src2)>;
3674
Dan Gohman921581d2008-10-17 01:23:35 +00003675def : Pat<(or (shl GR16:$src1, (i8 (trunc CX:$amt))),
3676 (srl GR16:$src2, (i8 (trunc (sub 16, CX:$amt))))),
3677 (SHLD16rrCL GR16:$src1, GR16:$src2)>;
3678
3679def : Pat<(store (or (shl (loadi16 addr:$dst), (i8 (trunc CX:$amt))),
3680 (srl GR16:$src2, (i8 (trunc (sub 16, CX:$amt))))),
3681 addr:$dst),
3682 (SHLD16mrCL addr:$dst, GR16:$src2)>;
3683
3684def : Pat<(shld GR16:$src1, (i8 imm:$amt1), GR16:$src2, (i8 imm:$amt2)),
3685 (SHLD16rri8 GR16:$src1, GR16:$src2, (i8 imm:$amt1))>;
3686
3687def : Pat<(store (shld (loadi16 addr:$dst), (i8 imm:$amt1),
3688 GR16:$src2, (i8 imm:$amt2)), addr:$dst),
3689 (SHLD16mri8 addr:$dst, GR16:$src2, (i8 imm:$amt1))>;
3690
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003691//===----------------------------------------------------------------------===//
Dan Gohman99a12192009-03-04 19:44:21 +00003692// EFLAGS-defining Patterns
Bill Wendlingf5399032008-12-12 21:15:41 +00003693//===----------------------------------------------------------------------===//
3694
Dan Gohman99a12192009-03-04 19:44:21 +00003695// Register-Register Addition with EFLAGS result
3696def : Pat<(parallel (X86add_flag GR8:$src1, GR8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003697 (implicit EFLAGS)),
3698 (ADD8rr GR8:$src1, GR8:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003699def : Pat<(parallel (X86add_flag GR16:$src1, GR16:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003700 (implicit EFLAGS)),
3701 (ADD16rr GR16:$src1, GR16:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003702def : Pat<(parallel (X86add_flag GR32:$src1, GR32:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003703 (implicit EFLAGS)),
3704 (ADD32rr GR32:$src1, GR32:$src2)>;
3705
Dan Gohman99a12192009-03-04 19:44:21 +00003706// Register-Memory Addition with EFLAGS result
3707def : Pat<(parallel (X86add_flag GR8:$src1, (loadi8 addr:$src2)),
Bill Wendlingf5399032008-12-12 21:15:41 +00003708 (implicit EFLAGS)),
3709 (ADD8rm GR8:$src1, addr:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003710def : Pat<(parallel (X86add_flag GR16:$src1, (loadi16 addr:$src2)),
Bill Wendlingf5399032008-12-12 21:15:41 +00003711 (implicit EFLAGS)),
3712 (ADD16rm GR16:$src1, addr:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003713def : Pat<(parallel (X86add_flag GR32:$src1, (loadi32 addr:$src2)),
Bill Wendlingf5399032008-12-12 21:15:41 +00003714 (implicit EFLAGS)),
3715 (ADD32rm GR32:$src1, addr:$src2)>;
3716
Dan Gohman99a12192009-03-04 19:44:21 +00003717// Register-Integer Addition with EFLAGS result
3718def : Pat<(parallel (X86add_flag GR8:$src1, imm:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003719 (implicit EFLAGS)),
3720 (ADD8ri GR8:$src1, imm:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003721def : Pat<(parallel (X86add_flag GR16:$src1, imm:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003722 (implicit EFLAGS)),
3723 (ADD16ri GR16:$src1, imm:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003724def : Pat<(parallel (X86add_flag GR32:$src1, imm:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003725 (implicit EFLAGS)),
3726 (ADD32ri GR32:$src1, imm:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003727def : Pat<(parallel (X86add_flag GR16:$src1, i16immSExt8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003728 (implicit EFLAGS)),
3729 (ADD16ri8 GR16:$src1, i16immSExt8:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003730def : Pat<(parallel (X86add_flag GR32:$src1, i32immSExt8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003731 (implicit EFLAGS)),
3732 (ADD32ri8 GR32:$src1, i32immSExt8:$src2)>;
3733
Dan Gohman99a12192009-03-04 19:44:21 +00003734// Memory-Register Addition with EFLAGS result
3735def : Pat<(parallel (store (X86add_flag (loadi8 addr:$dst), GR8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003736 addr:$dst),
3737 (implicit EFLAGS)),
3738 (ADD8mr addr:$dst, GR8:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003739def : Pat<(parallel (store (X86add_flag (loadi16 addr:$dst), GR16:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003740 addr:$dst),
3741 (implicit EFLAGS)),
3742 (ADD16mr addr:$dst, GR16:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003743def : Pat<(parallel (store (X86add_flag (loadi32 addr:$dst), GR32:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003744 addr:$dst),
3745 (implicit EFLAGS)),
3746 (ADD32mr addr:$dst, GR32:$src2)>;
Dale Johannesen06b83f12009-05-18 17:44:15 +00003747
3748// Memory-Integer Addition with EFLAGS result
Dan Gohman99a12192009-03-04 19:44:21 +00003749def : Pat<(parallel (store (X86add_flag (loadi8 addr:$dst), imm:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003750 addr:$dst),
3751 (implicit EFLAGS)),
3752 (ADD8mi addr:$dst, imm:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003753def : Pat<(parallel (store (X86add_flag (loadi16 addr:$dst), imm:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003754 addr:$dst),
3755 (implicit EFLAGS)),
3756 (ADD16mi addr:$dst, imm:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003757def : Pat<(parallel (store (X86add_flag (loadi32 addr:$dst), imm:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003758 addr:$dst),
3759 (implicit EFLAGS)),
3760 (ADD32mi addr:$dst, imm:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003761def : Pat<(parallel (store (X86add_flag (loadi16 addr:$dst), i16immSExt8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003762 addr:$dst),
3763 (implicit EFLAGS)),
3764 (ADD16mi8 addr:$dst, i16immSExt8:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003765def : Pat<(parallel (store (X86add_flag (loadi32 addr:$dst), i32immSExt8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003766 addr:$dst),
3767 (implicit EFLAGS)),
3768 (ADD32mi8 addr:$dst, i32immSExt8:$src2)>;
3769
Dan Gohman99a12192009-03-04 19:44:21 +00003770// Register-Register Subtraction with EFLAGS result
3771def : Pat<(parallel (X86sub_flag GR8:$src1, GR8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003772 (implicit EFLAGS)),
3773 (SUB8rr GR8:$src1, GR8:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003774def : Pat<(parallel (X86sub_flag GR16:$src1, GR16:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003775 (implicit EFLAGS)),
3776 (SUB16rr GR16:$src1, GR16:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003777def : Pat<(parallel (X86sub_flag GR32:$src1, GR32:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003778 (implicit EFLAGS)),
3779 (SUB32rr GR32:$src1, GR32:$src2)>;
3780
Dan Gohman99a12192009-03-04 19:44:21 +00003781// Register-Memory Subtraction with EFLAGS result
3782def : Pat<(parallel (X86sub_flag GR8:$src1, (loadi8 addr:$src2)),
Bill Wendlingf5399032008-12-12 21:15:41 +00003783 (implicit EFLAGS)),
3784 (SUB8rm GR8:$src1, addr:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003785def : Pat<(parallel (X86sub_flag GR16:$src1, (loadi16 addr:$src2)),
Bill Wendlingf5399032008-12-12 21:15:41 +00003786 (implicit EFLAGS)),
3787 (SUB16rm GR16:$src1, addr:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003788def : Pat<(parallel (X86sub_flag GR32:$src1, (loadi32 addr:$src2)),
Bill Wendlingf5399032008-12-12 21:15:41 +00003789 (implicit EFLAGS)),
3790 (SUB32rm GR32:$src1, addr:$src2)>;
3791
Dan Gohman99a12192009-03-04 19:44:21 +00003792// Register-Integer Subtraction with EFLAGS result
3793def : Pat<(parallel (X86sub_flag GR8:$src1, imm:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003794 (implicit EFLAGS)),
3795 (SUB8ri GR8:$src1, imm:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003796def : Pat<(parallel (X86sub_flag GR16:$src1, imm:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003797 (implicit EFLAGS)),
3798 (SUB16ri GR16:$src1, imm:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003799def : Pat<(parallel (X86sub_flag GR32:$src1, imm:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003800 (implicit EFLAGS)),
3801 (SUB32ri GR32:$src1, imm:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003802def : Pat<(parallel (X86sub_flag GR16:$src1, i16immSExt8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003803 (implicit EFLAGS)),
3804 (SUB16ri8 GR16:$src1, i16immSExt8:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003805def : Pat<(parallel (X86sub_flag GR32:$src1, i32immSExt8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003806 (implicit EFLAGS)),
3807 (SUB32ri8 GR32:$src1, i32immSExt8:$src2)>;
3808
Dan Gohman99a12192009-03-04 19:44:21 +00003809// Memory-Register Subtraction with EFLAGS result
3810def : Pat<(parallel (store (X86sub_flag (loadi8 addr:$dst), GR8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003811 addr:$dst),
3812 (implicit EFLAGS)),
3813 (SUB8mr addr:$dst, GR8:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003814def : Pat<(parallel (store (X86sub_flag (loadi16 addr:$dst), GR16:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003815 addr:$dst),
3816 (implicit EFLAGS)),
3817 (SUB16mr addr:$dst, GR16:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003818def : Pat<(parallel (store (X86sub_flag (loadi32 addr:$dst), GR32:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003819 addr:$dst),
3820 (implicit EFLAGS)),
3821 (SUB32mr addr:$dst, GR32:$src2)>;
3822
Dan Gohman99a12192009-03-04 19:44:21 +00003823// Memory-Integer Subtraction with EFLAGS result
3824def : Pat<(parallel (store (X86sub_flag (loadi8 addr:$dst), imm:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003825 addr:$dst),
3826 (implicit EFLAGS)),
3827 (SUB8mi addr:$dst, imm:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003828def : Pat<(parallel (store (X86sub_flag (loadi16 addr:$dst), imm:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003829 addr:$dst),
3830 (implicit EFLAGS)),
3831 (SUB16mi addr:$dst, imm:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003832def : Pat<(parallel (store (X86sub_flag (loadi32 addr:$dst), imm:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003833 addr:$dst),
3834 (implicit EFLAGS)),
3835 (SUB32mi addr:$dst, imm:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003836def : Pat<(parallel (store (X86sub_flag (loadi16 addr:$dst), i16immSExt8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003837 addr:$dst),
3838 (implicit EFLAGS)),
3839 (SUB16mi8 addr:$dst, i16immSExt8:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003840def : Pat<(parallel (store (X86sub_flag (loadi32 addr:$dst), i32immSExt8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003841 addr:$dst),
3842 (implicit EFLAGS)),
3843 (SUB32mi8 addr:$dst, i32immSExt8:$src2)>;
3844
3845
Dan Gohman99a12192009-03-04 19:44:21 +00003846// Register-Register Signed Integer Multiply with EFLAGS result
3847def : Pat<(parallel (X86smul_flag GR16:$src1, GR16:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003848 (implicit EFLAGS)),
3849 (IMUL16rr GR16:$src1, GR16:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003850def : Pat<(parallel (X86smul_flag GR32:$src1, GR32:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003851 (implicit EFLAGS)),
3852 (IMUL32rr GR32:$src1, GR32:$src2)>;
3853
Dan Gohman99a12192009-03-04 19:44:21 +00003854// Register-Memory Signed Integer Multiply with EFLAGS result
3855def : Pat<(parallel (X86smul_flag GR16:$src1, (loadi16 addr:$src2)),
Bill Wendlingf5399032008-12-12 21:15:41 +00003856 (implicit EFLAGS)),
3857 (IMUL16rm GR16:$src1, addr:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003858def : Pat<(parallel (X86smul_flag GR32:$src1, (loadi32 addr:$src2)),
Bill Wendlingf5399032008-12-12 21:15:41 +00003859 (implicit EFLAGS)),
3860 (IMUL32rm GR32:$src1, addr:$src2)>;
3861
Dan Gohman99a12192009-03-04 19:44:21 +00003862// Register-Integer Signed Integer Multiply with EFLAGS result
3863def : Pat<(parallel (X86smul_flag GR16:$src1, imm:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003864 (implicit EFLAGS)),
3865 (IMUL16rri GR16:$src1, imm:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003866def : Pat<(parallel (X86smul_flag GR32:$src1, imm:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003867 (implicit EFLAGS)),
3868 (IMUL32rri GR32:$src1, imm:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003869def : Pat<(parallel (X86smul_flag GR16:$src1, i16immSExt8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003870 (implicit EFLAGS)),
3871 (IMUL16rri8 GR16:$src1, i16immSExt8:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003872def : Pat<(parallel (X86smul_flag GR32:$src1, i32immSExt8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003873 (implicit EFLAGS)),
3874 (IMUL32rri8 GR32:$src1, i32immSExt8:$src2)>;
3875
Dan Gohman99a12192009-03-04 19:44:21 +00003876// Memory-Integer Signed Integer Multiply with EFLAGS result
3877def : Pat<(parallel (X86smul_flag (loadi16 addr:$src1), imm:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003878 (implicit EFLAGS)),
3879 (IMUL16rmi addr:$src1, imm:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003880def : Pat<(parallel (X86smul_flag (loadi32 addr:$src1), imm:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003881 (implicit EFLAGS)),
3882 (IMUL32rmi addr:$src1, imm:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003883def : Pat<(parallel (X86smul_flag (loadi16 addr:$src1), i16immSExt8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003884 (implicit EFLAGS)),
3885 (IMUL16rmi8 addr:$src1, i16immSExt8:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003886def : Pat<(parallel (X86smul_flag (loadi32 addr:$src1), i32immSExt8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003887 (implicit EFLAGS)),
3888 (IMUL32rmi8 addr:$src1, i32immSExt8:$src2)>;
3889
Dan Gohman99a12192009-03-04 19:44:21 +00003890// Optimize multiply by 2 with EFLAGS result.
Evan Cheng00cf7932009-01-27 03:30:42 +00003891let AddedComplexity = 2 in {
Dan Gohman99a12192009-03-04 19:44:21 +00003892def : Pat<(parallel (X86smul_flag GR16:$src1, 2),
Evan Cheng00cf7932009-01-27 03:30:42 +00003893 (implicit EFLAGS)),
3894 (ADD16rr GR16:$src1, GR16:$src1)>;
3895
Dan Gohman99a12192009-03-04 19:44:21 +00003896def : Pat<(parallel (X86smul_flag GR32:$src1, 2),
Evan Cheng00cf7932009-01-27 03:30:42 +00003897 (implicit EFLAGS)),
3898 (ADD32rr GR32:$src1, GR32:$src1)>;
3899}
3900
Dan Gohman99a12192009-03-04 19:44:21 +00003901// INC and DEC with EFLAGS result. Note that these do not set CF.
3902def : Pat<(parallel (X86inc_flag GR8:$src), (implicit EFLAGS)),
3903 (INC8r GR8:$src)>;
3904def : Pat<(parallel (store (i8 (X86inc_flag (loadi8 addr:$dst))), addr:$dst),
3905 (implicit EFLAGS)),
3906 (INC8m addr:$dst)>;
3907def : Pat<(parallel (X86dec_flag GR8:$src), (implicit EFLAGS)),
3908 (DEC8r GR8:$src)>;
3909def : Pat<(parallel (store (i8 (X86dec_flag (loadi8 addr:$dst))), addr:$dst),
3910 (implicit EFLAGS)),
3911 (DEC8m addr:$dst)>;
3912
3913def : Pat<(parallel (X86inc_flag GR16:$src), (implicit EFLAGS)),
Dan Gohmaneebcac72009-03-05 21:32:23 +00003914 (INC16r GR16:$src)>, Requires<[In32BitMode]>;
Dan Gohman99a12192009-03-04 19:44:21 +00003915def : Pat<(parallel (store (i16 (X86inc_flag (loadi16 addr:$dst))), addr:$dst),
3916 (implicit EFLAGS)),
Dan Gohmaneebcac72009-03-05 21:32:23 +00003917 (INC16m addr:$dst)>, Requires<[In32BitMode]>;
Dan Gohman99a12192009-03-04 19:44:21 +00003918def : Pat<(parallel (X86dec_flag GR16:$src), (implicit EFLAGS)),
Dan Gohmaneebcac72009-03-05 21:32:23 +00003919 (DEC16r GR16:$src)>, Requires<[In32BitMode]>;
Dan Gohman99a12192009-03-04 19:44:21 +00003920def : Pat<(parallel (store (i16 (X86dec_flag (loadi16 addr:$dst))), addr:$dst),
3921 (implicit EFLAGS)),
Dan Gohmaneebcac72009-03-05 21:32:23 +00003922 (DEC16m addr:$dst)>, Requires<[In32BitMode]>;
Dan Gohman99a12192009-03-04 19:44:21 +00003923
3924def : Pat<(parallel (X86inc_flag GR32:$src), (implicit EFLAGS)),
Dan Gohmaneebcac72009-03-05 21:32:23 +00003925 (INC32r GR32:$src)>, Requires<[In32BitMode]>;
Dan Gohman99a12192009-03-04 19:44:21 +00003926def : Pat<(parallel (store (i32 (X86inc_flag (loadi32 addr:$dst))), addr:$dst),
3927 (implicit EFLAGS)),
Dan Gohmaneebcac72009-03-05 21:32:23 +00003928 (INC32m addr:$dst)>, Requires<[In32BitMode]>;
Dan Gohman99a12192009-03-04 19:44:21 +00003929def : Pat<(parallel (X86dec_flag GR32:$src), (implicit EFLAGS)),
Dan Gohmaneebcac72009-03-05 21:32:23 +00003930 (DEC32r GR32:$src)>, Requires<[In32BitMode]>;
Dan Gohman99a12192009-03-04 19:44:21 +00003931def : Pat<(parallel (store (i32 (X86dec_flag (loadi32 addr:$dst))), addr:$dst),
3932 (implicit EFLAGS)),
Dan Gohmaneebcac72009-03-05 21:32:23 +00003933 (DEC32m addr:$dst)>, Requires<[In32BitMode]>;
Dan Gohman99a12192009-03-04 19:44:21 +00003934
Bill Wendlingf5399032008-12-12 21:15:41 +00003935//===----------------------------------------------------------------------===//
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003936// Floating Point Stack Support
3937//===----------------------------------------------------------------------===//
3938
3939include "X86InstrFPStack.td"
3940
3941//===----------------------------------------------------------------------===//
Evan Cheng86ab7d32007-07-31 08:04:03 +00003942// X86-64 Support
3943//===----------------------------------------------------------------------===//
3944
Chris Lattner2de8d2b2008-01-10 05:50:42 +00003945include "X86Instr64bit.td"
Evan Cheng86ab7d32007-07-31 08:04:03 +00003946
3947//===----------------------------------------------------------------------===//
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003948// XMM Floating point support (requires SSE / SSE2)
3949//===----------------------------------------------------------------------===//
3950
3951include "X86InstrSSE.td"
Evan Cheng5e4d1e72008-04-25 18:19:54 +00003952
3953//===----------------------------------------------------------------------===//
3954// MMX and XMM Packed Integer support (requires MMX, SSE, and SSE2)
3955//===----------------------------------------------------------------------===//
3956
3957include "X86InstrMMX.td"