blob: 416f342efd1da824794271cb7591a9d0e501da77 [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
Bill Wendling4c2638c2009-06-15 19:39:04 +0000614let Defs = [ESP], Uses = [ESP], neverHasSideEffects = 1, mayStore = 1 in {
615def PUSH32i8 : Ii8<0x6a, RawFrm, (outs), (ins i8imm:$imm),
Bill Wendling0b0437f2009-06-15 20:59:31 +0000616 "push{l}\t$imm", []>;
Bill Wendling4c2638c2009-06-15 19:39:04 +0000617def PUSH32i16 : Ii16<0x68, RawFrm, (outs), (ins i16imm:$imm),
Bill Wendling0b0437f2009-06-15 20:59:31 +0000618 "push{l}\t$imm", []>;
Bill Wendling4c2638c2009-06-15 19:39:04 +0000619def PUSH32i32 : Ii32<0x68, RawFrm, (outs), (ins i32imm:$imm),
Bill Wendling0b0437f2009-06-15 20:59:31 +0000620 "push{l}\t$imm", []>;
Bill Wendling4c2638c2009-06-15 19:39:04 +0000621}
622
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000623let Defs = [ESP, EFLAGS], Uses = [ESP], mayLoad = 1, neverHasSideEffects=1 in
Evan Chengf1341312007-09-26 21:28:00 +0000624def POPFD : I<0x9D, RawFrm, (outs), (ins), "popf", []>;
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000625let Defs = [ESP], Uses = [ESP, EFLAGS], mayStore = 1, neverHasSideEffects=1 in
Evan Chengf1341312007-09-26 21:28:00 +0000626def PUSHFD : I<0x9C, RawFrm, (outs), (ins), "pushf", []>;
Evan Chengd8434332007-09-26 01:29:06 +0000627
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000628let isTwoAddress = 1 in // GR32 = bswap GR32
629 def BSWAP32r : I<0xC8, AddRegFrm,
Evan Chengb783fa32007-07-19 01:14:50 +0000630 (outs GR32:$dst), (ins GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000631 "bswap{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000632 [(set GR32:$dst, (bswap GR32:$src))]>, TB;
633
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000634
Evan Cheng48679f42007-12-14 02:13:44 +0000635// Bit scan instructions.
636let Defs = [EFLAGS] in {
Evan Cheng4e33de92007-12-14 18:49:43 +0000637def BSF16rr : I<0xBC, MRMSrcReg, (outs GR16:$dst), (ins GR16:$src),
Dan Gohmancdb54c62007-12-14 15:10:00 +0000638 "bsf{w}\t{$src, $dst|$dst, $src}",
Evan Cheng7cfbfe32007-12-14 08:30:15 +0000639 [(set GR16:$dst, (X86bsf GR16:$src)), (implicit EFLAGS)]>, TB;
Evan Cheng48679f42007-12-14 02:13:44 +0000640def BSF16rm : I<0xBC, MRMSrcMem, (outs GR16:$dst), (ins i16mem:$src),
Dan Gohmancdb54c62007-12-14 15:10:00 +0000641 "bsf{w}\t{$src, $dst|$dst, $src}",
Evan Cheng7cfbfe32007-12-14 08:30:15 +0000642 [(set GR16:$dst, (X86bsf (loadi16 addr:$src))),
643 (implicit EFLAGS)]>, TB;
Evan Cheng4e33de92007-12-14 18:49:43 +0000644def BSF32rr : I<0xBC, MRMSrcReg, (outs GR32:$dst), (ins GR32:$src),
Dan Gohmancdb54c62007-12-14 15:10:00 +0000645 "bsf{l}\t{$src, $dst|$dst, $src}",
Evan Cheng7cfbfe32007-12-14 08:30:15 +0000646 [(set GR32:$dst, (X86bsf GR32:$src)), (implicit EFLAGS)]>, TB;
Evan Cheng48679f42007-12-14 02:13:44 +0000647def BSF32rm : I<0xBC, MRMSrcMem, (outs GR32:$dst), (ins i32mem:$src),
Dan Gohmancdb54c62007-12-14 15:10:00 +0000648 "bsf{l}\t{$src, $dst|$dst, $src}",
Evan Cheng7cfbfe32007-12-14 08:30:15 +0000649 [(set GR32:$dst, (X86bsf (loadi32 addr:$src))),
650 (implicit EFLAGS)]>, TB;
Evan Cheng48679f42007-12-14 02:13:44 +0000651
Evan Cheng4e33de92007-12-14 18:49:43 +0000652def BSR16rr : I<0xBD, MRMSrcReg, (outs GR16:$dst), (ins GR16:$src),
Dan Gohmancdb54c62007-12-14 15:10:00 +0000653 "bsr{w}\t{$src, $dst|$dst, $src}",
Evan Cheng7cfbfe32007-12-14 08:30:15 +0000654 [(set GR16:$dst, (X86bsr GR16:$src)), (implicit EFLAGS)]>, TB;
Evan Cheng48679f42007-12-14 02:13:44 +0000655def BSR16rm : I<0xBD, MRMSrcMem, (outs GR16:$dst), (ins i16mem:$src),
Dan Gohmancdb54c62007-12-14 15:10:00 +0000656 "bsr{w}\t{$src, $dst|$dst, $src}",
Evan Cheng7cfbfe32007-12-14 08:30:15 +0000657 [(set GR16:$dst, (X86bsr (loadi16 addr:$src))),
658 (implicit EFLAGS)]>, TB;
Evan Cheng4e33de92007-12-14 18:49:43 +0000659def BSR32rr : I<0xBD, MRMSrcReg, (outs GR32:$dst), (ins GR32:$src),
Dan Gohmancdb54c62007-12-14 15:10:00 +0000660 "bsr{l}\t{$src, $dst|$dst, $src}",
Evan Cheng7cfbfe32007-12-14 08:30:15 +0000661 [(set GR32:$dst, (X86bsr GR32:$src)), (implicit EFLAGS)]>, TB;
Evan Cheng48679f42007-12-14 02:13:44 +0000662def BSR32rm : I<0xBD, MRMSrcMem, (outs GR32:$dst), (ins i32mem:$src),
Dan Gohmancdb54c62007-12-14 15:10:00 +0000663 "bsr{l}\t{$src, $dst|$dst, $src}",
Evan Cheng7cfbfe32007-12-14 08:30:15 +0000664 [(set GR32:$dst, (X86bsr (loadi32 addr:$src))),
665 (implicit EFLAGS)]>, TB;
Evan Cheng48679f42007-12-14 02:13:44 +0000666} // Defs = [EFLAGS]
667
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000668let neverHasSideEffects = 1 in
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000669def LEA16r : I<0x8D, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +0000670 (outs GR16:$dst), (ins i32mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000671 "lea{w}\t{$src|$dst}, {$dst|$src}", []>, OpSize;
Evan Cheng1ea8e6b2008-03-27 01:41:09 +0000672let isReMaterializable = 1 in
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000673def LEA32r : I<0x8D, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +0000674 (outs GR32:$dst), (ins lea32mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000675 "lea{l}\t{$src|$dst}, {$dst|$src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000676 [(set GR32:$dst, lea32addr:$src)]>, Requires<[In32BitMode]>;
677
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000678let Defs = [ECX,EDI,ESI], Uses = [ECX,EDI,ESI] in {
Evan Chengb783fa32007-07-19 01:14:50 +0000679def REP_MOVSB : I<0xA4, RawFrm, (outs), (ins), "{rep;movsb|rep movsb}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000680 [(X86rep_movs i8)]>, REP;
Evan Chengb783fa32007-07-19 01:14:50 +0000681def REP_MOVSW : I<0xA5, RawFrm, (outs), (ins), "{rep;movsw|rep movsw}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000682 [(X86rep_movs i16)]>, REP, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +0000683def REP_MOVSD : I<0xA5, RawFrm, (outs), (ins), "{rep;movsl|rep movsd}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000684 [(X86rep_movs i32)]>, REP;
685}
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000686
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000687let Defs = [ECX,EDI], Uses = [AL,ECX,EDI] in
Evan Chengb783fa32007-07-19 01:14:50 +0000688def REP_STOSB : I<0xAA, RawFrm, (outs), (ins), "{rep;stosb|rep stosb}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000689 [(X86rep_stos i8)]>, REP;
690let Defs = [ECX,EDI], Uses = [AX,ECX,EDI] in
Evan Chengb783fa32007-07-19 01:14:50 +0000691def REP_STOSW : I<0xAB, RawFrm, (outs), (ins), "{rep;stosw|rep stosw}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000692 [(X86rep_stos i16)]>, REP, OpSize;
693let Defs = [ECX,EDI], Uses = [EAX,ECX,EDI] in
Evan Chengb783fa32007-07-19 01:14:50 +0000694def REP_STOSD : I<0xAB, RawFrm, (outs), (ins), "{rep;stosl|rep stosd}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000695 [(X86rep_stos i32)]>, REP;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000696
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000697let Defs = [RAX, RDX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000698def RDTSC : I<0x31, RawFrm, (outs), (ins), "rdtsc", [(X86rdtsc)]>,
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000699 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000700
Anton Korobeynikov39d40ba2008-01-15 07:02:33 +0000701let isBarrier = 1, hasCtrlDep = 1 in {
Chris Lattner56b941f2008-01-15 21:58:22 +0000702def TRAP : I<0x0B, RawFrm, (outs), (ins), "ud2", [(trap)]>, TB;
Anton Korobeynikov39d40ba2008-01-15 07:02:33 +0000703}
704
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000705//===----------------------------------------------------------------------===//
706// Input/Output Instructions...
707//
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000708let Defs = [AL], Uses = [DX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000709def IN8rr : I<0xEC, RawFrm, (outs), (ins),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000710 "in{b}\t{%dx, %al|%AL, %DX}", []>;
711let Defs = [AX], Uses = [DX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000712def IN16rr : I<0xED, RawFrm, (outs), (ins),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000713 "in{w}\t{%dx, %ax|%AX, %DX}", []>, OpSize;
714let Defs = [EAX], Uses = [DX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000715def IN32rr : I<0xED, RawFrm, (outs), (ins),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000716 "in{l}\t{%dx, %eax|%EAX, %DX}", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000717
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000718let Defs = [AL] in
Evan Chengb783fa32007-07-19 01:14:50 +0000719def IN8ri : Ii8<0xE4, RawFrm, (outs), (ins i16i8imm:$port),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000720 "in{b}\t{$port, %al|%AL, $port}", []>;
721let Defs = [AX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000722def IN16ri : Ii8<0xE5, RawFrm, (outs), (ins i16i8imm:$port),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000723 "in{w}\t{$port, %ax|%AX, $port}", []>, OpSize;
724let Defs = [EAX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000725def IN32ri : Ii8<0xE5, RawFrm, (outs), (ins i16i8imm:$port),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000726 "in{l}\t{$port, %eax|%EAX, $port}", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000727
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000728let Uses = [DX, AL] in
Evan Chengb783fa32007-07-19 01:14:50 +0000729def OUT8rr : I<0xEE, RawFrm, (outs), (ins),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000730 "out{b}\t{%al, %dx|%DX, %AL}", []>;
731let Uses = [DX, AX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000732def OUT16rr : I<0xEF, RawFrm, (outs), (ins),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000733 "out{w}\t{%ax, %dx|%DX, %AX}", []>, OpSize;
734let Uses = [DX, EAX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000735def OUT32rr : I<0xEF, RawFrm, (outs), (ins),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000736 "out{l}\t{%eax, %dx|%DX, %EAX}", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000737
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000738let Uses = [AL] in
Evan Chengb783fa32007-07-19 01:14:50 +0000739def OUT8ir : Ii8<0xE6, RawFrm, (outs), (ins i16i8imm:$port),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000740 "out{b}\t{%al, $port|$port, %AL}", []>;
741let Uses = [AX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000742def OUT16ir : Ii8<0xE7, RawFrm, (outs), (ins i16i8imm:$port),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000743 "out{w}\t{%ax, $port|$port, %AX}", []>, OpSize;
744let Uses = [EAX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000745def OUT32ir : Ii8<0xE7, RawFrm, (outs), (ins i16i8imm:$port),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000746 "out{l}\t{%eax, $port|$port, %EAX}", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000747
748//===----------------------------------------------------------------------===//
749// Move Instructions...
750//
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000751let neverHasSideEffects = 1 in {
Evan Chengb783fa32007-07-19 01:14:50 +0000752def MOV8rr : I<0x88, MRMDestReg, (outs GR8 :$dst), (ins GR8 :$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000753 "mov{b}\t{$src, $dst|$dst, $src}", []>;
Evan Chengb783fa32007-07-19 01:14:50 +0000754def MOV16rr : I<0x89, MRMDestReg, (outs GR16:$dst), (ins GR16:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000755 "mov{w}\t{$src, $dst|$dst, $src}", []>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +0000756def MOV32rr : I<0x89, MRMDestReg, (outs GR32:$dst), (ins GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000757 "mov{l}\t{$src, $dst|$dst, $src}", []>;
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000758}
Evan Cheng6f26e8b2008-06-18 08:13:07 +0000759let isReMaterializable = 1, isAsCheapAsAMove = 1 in {
Evan Chengb783fa32007-07-19 01:14:50 +0000760def MOV8ri : Ii8 <0xB0, AddRegFrm, (outs GR8 :$dst), (ins i8imm :$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000761 "mov{b}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000762 [(set GR8:$dst, imm:$src)]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000763def MOV16ri : Ii16<0xB8, AddRegFrm, (outs GR16:$dst), (ins i16imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000764 "mov{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000765 [(set GR16:$dst, imm:$src)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +0000766def MOV32ri : Ii32<0xB8, AddRegFrm, (outs GR32:$dst), (ins i32imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000767 "mov{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000768 [(set GR32:$dst, imm:$src)]>;
769}
Evan Chengb783fa32007-07-19 01:14:50 +0000770def MOV8mi : Ii8 <0xC6, MRM0m, (outs), (ins i8mem :$dst, i8imm :$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000771 "mov{b}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000772 [(store (i8 imm:$src), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000773def MOV16mi : Ii16<0xC7, MRM0m, (outs), (ins i16mem:$dst, i16imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000774 "mov{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000775 [(store (i16 imm:$src), addr:$dst)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +0000776def MOV32mi : Ii32<0xC7, MRM0m, (outs), (ins i32mem:$dst, i32imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000777 "mov{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000778 [(store (i32 imm:$src), addr:$dst)]>;
779
Dan Gohman5574cc72008-12-03 18:15:48 +0000780let canFoldAsLoad = 1, isReMaterializable = 1, mayHaveSideEffects = 1 in {
Evan Chengb783fa32007-07-19 01:14:50 +0000781def MOV8rm : I<0x8A, MRMSrcMem, (outs GR8 :$dst), (ins i8mem :$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000782 "mov{b}\t{$src, $dst|$dst, $src}",
Chris Lattner12208612009-04-10 00:16:23 +0000783 [(set GR8:$dst, (loadi8 addr:$src))]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000784def MOV16rm : I<0x8B, MRMSrcMem, (outs GR16:$dst), (ins i16mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000785 "mov{w}\t{$src, $dst|$dst, $src}",
Chris Lattner12208612009-04-10 00:16:23 +0000786 [(set GR16:$dst, (loadi16 addr:$src))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +0000787def MOV32rm : I<0x8B, MRMSrcMem, (outs GR32:$dst), (ins i32mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000788 "mov{l}\t{$src, $dst|$dst, $src}",
Chris Lattner12208612009-04-10 00:16:23 +0000789 [(set GR32:$dst, (loadi32 addr:$src))]>;
Evan Cheng4e84e452007-08-30 05:49:43 +0000790}
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000791
Evan Chengb783fa32007-07-19 01:14:50 +0000792def MOV8mr : I<0x88, MRMDestMem, (outs), (ins i8mem :$dst, GR8 :$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000793 "mov{b}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000794 [(store GR8:$src, addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000795def MOV16mr : I<0x89, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000796 "mov{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000797 [(store GR16:$src, addr:$dst)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +0000798def MOV32mr : I<0x89, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000799 "mov{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000800 [(store GR32:$src, addr:$dst)]>;
Dan Gohman744d4622009-04-13 16:09:41 +0000801
Dan Gohman1d8ce9c2009-04-27 16:41:36 +0000802// Versions of MOV8rr, MOV8mr, and MOV8rm that use i8mem_NOREX and GR8_NOREX so
803// that they can be used for copying and storing h registers, which can't be
804// encoded when a REX prefix is present.
Dan Gohman2da0db32009-04-15 00:04:23 +0000805let neverHasSideEffects = 1 in
Dan Gohman40ddc362009-04-15 19:48:57 +0000806def MOV8rr_NOREX : I<0x88, MRMDestReg,
807 (outs GR8_NOREX:$dst), (ins GR8_NOREX:$src),
Dan Gohman2da0db32009-04-15 00:04:23 +0000808 "mov{b}\t{$src, $dst|$dst, $src} # NOREX", []>;
Evan Chengebc49402009-04-30 00:58:57 +0000809let mayStore = 1 in
Dan Gohman2da0db32009-04-15 00:04:23 +0000810def MOV8mr_NOREX : I<0x88, MRMDestMem,
811 (outs), (ins i8mem_NOREX:$dst, GR8_NOREX:$src),
812 "mov{b}\t{$src, $dst|$dst, $src} # NOREX", []>;
Evan Chengebc49402009-04-30 00:58:57 +0000813let mayLoad = 1,
814 canFoldAsLoad = 1, isReMaterializable = 1, mayHaveSideEffects = 1 in
Dan Gohman1d8ce9c2009-04-27 16:41:36 +0000815def MOV8rm_NOREX : I<0x8A, MRMSrcMem,
816 (outs GR8_NOREX:$dst), (ins i8mem_NOREX:$src),
817 "mov{b}\t{$src, $dst|$dst, $src} # NOREX", []>;
Dan Gohman744d4622009-04-13 16:09:41 +0000818
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000819//===----------------------------------------------------------------------===//
820// Fixed-Register Multiplication and Division Instructions...
821//
822
823// Extra precision multiplication
Evan Cheng55687072007-09-14 21:48:26 +0000824let Defs = [AL,AH,EFLAGS], Uses = [AL] in
Dan Gohman91888f02007-07-31 20:11:57 +0000825def MUL8r : I<0xF6, MRM4r, (outs), (ins GR8:$src), "mul{b}\t$src",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000826 // FIXME: Used for 8-bit mul, ignore result upper 8 bits.
827 // This probably ought to be moved to a def : Pat<> if the
828 // syntax can be accepted.
Bill Wendlingf5399032008-12-12 21:15:41 +0000829 [(set AL, (mul AL, GR8:$src)),
830 (implicit EFLAGS)]>; // AL,AH = AL*GR8
831
Chris Lattnerc7e96e72008-01-11 07:18:17 +0000832let Defs = [AX,DX,EFLAGS], Uses = [AX], neverHasSideEffects = 1 in
Bill Wendlingf5399032008-12-12 21:15:41 +0000833def MUL16r : I<0xF7, MRM4r, (outs), (ins GR16:$src),
834 "mul{w}\t$src",
835 []>, OpSize; // AX,DX = AX*GR16
836
Chris Lattnerc7e96e72008-01-11 07:18:17 +0000837let Defs = [EAX,EDX,EFLAGS], Uses = [EAX], neverHasSideEffects = 1 in
Bill Wendlingf5399032008-12-12 21:15:41 +0000838def MUL32r : I<0xF7, MRM4r, (outs), (ins GR32:$src),
839 "mul{l}\t$src",
840 []>; // EAX,EDX = EAX*GR32
841
Evan Cheng55687072007-09-14 21:48:26 +0000842let Defs = [AL,AH,EFLAGS], Uses = [AL] in
Evan Chengb783fa32007-07-19 01:14:50 +0000843def MUL8m : I<0xF6, MRM4m, (outs), (ins i8mem :$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000844 "mul{b}\t$src",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000845 // FIXME: Used for 8-bit mul, ignore result upper 8 bits.
846 // This probably ought to be moved to a def : Pat<> if the
847 // syntax can be accepted.
Bill Wendlingf5399032008-12-12 21:15:41 +0000848 [(set AL, (mul AL, (loadi8 addr:$src))),
849 (implicit EFLAGS)]>; // AL,AH = AL*[mem8]
850
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000851let mayLoad = 1, neverHasSideEffects = 1 in {
Evan Cheng55687072007-09-14 21:48:26 +0000852let Defs = [AX,DX,EFLAGS], Uses = [AX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000853def MUL16m : I<0xF7, MRM4m, (outs), (ins i16mem:$src),
Bill Wendlingf5399032008-12-12 21:15:41 +0000854 "mul{w}\t$src",
855 []>, OpSize; // AX,DX = AX*[mem16]
856
Evan Cheng55687072007-09-14 21:48:26 +0000857let Defs = [EAX,EDX,EFLAGS], Uses = [EAX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000858def MUL32m : I<0xF7, MRM4m, (outs), (ins i32mem:$src),
Bill Wendlingf5399032008-12-12 21:15:41 +0000859 "mul{l}\t$src",
860 []>; // EAX,EDX = EAX*[mem32]
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000861}
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000862
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000863let neverHasSideEffects = 1 in {
Evan Cheng55687072007-09-14 21:48:26 +0000864let Defs = [AL,AH,EFLAGS], Uses = [AL] in
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000865def IMUL8r : I<0xF6, MRM5r, (outs), (ins GR8:$src), "imul{b}\t$src", []>;
866 // AL,AH = AL*GR8
Evan Cheng55687072007-09-14 21:48:26 +0000867let Defs = [AX,DX,EFLAGS], Uses = [AX] in
Dan Gohman91888f02007-07-31 20:11:57 +0000868def IMUL16r : I<0xF7, MRM5r, (outs), (ins GR16:$src), "imul{w}\t$src", []>,
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000869 OpSize; // AX,DX = AX*GR16
Evan Cheng55687072007-09-14 21:48:26 +0000870let Defs = [EAX,EDX,EFLAGS], Uses = [EAX] in
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000871def IMUL32r : I<0xF7, MRM5r, (outs), (ins GR32:$src), "imul{l}\t$src", []>;
872 // EAX,EDX = EAX*GR32
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000873let mayLoad = 1 in {
Evan Cheng55687072007-09-14 21:48:26 +0000874let Defs = [AL,AH,EFLAGS], Uses = [AL] in
Evan Chengb783fa32007-07-19 01:14:50 +0000875def IMUL8m : I<0xF6, MRM5m, (outs), (ins i8mem :$src),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000876 "imul{b}\t$src", []>; // AL,AH = AL*[mem8]
Evan Cheng55687072007-09-14 21:48:26 +0000877let Defs = [AX,DX,EFLAGS], Uses = [AX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000878def IMUL16m : I<0xF7, MRM5m, (outs), (ins i16mem:$src),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000879 "imul{w}\t$src", []>, OpSize; // AX,DX = AX*[mem16]
880let Defs = [EAX,EDX], Uses = [EAX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000881def IMUL32m : I<0xF7, MRM5m, (outs), (ins i32mem:$src),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000882 "imul{l}\t$src", []>; // EAX,EDX = EAX*[mem32]
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000883}
Dan Gohmand44572d2008-11-18 21:29:14 +0000884} // neverHasSideEffects
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000885
886// unsigned division/remainder
Dale Johannesend8fd3562008-10-07 18:54:28 +0000887let Defs = [AL,AH,EFLAGS], Uses = [AX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000888def DIV8r : I<0xF6, MRM6r, (outs), (ins GR8:$src), // AX/r8 = AL,AH
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000889 "div{b}\t$src", []>;
Evan Cheng55687072007-09-14 21:48:26 +0000890let Defs = [AX,DX,EFLAGS], Uses = [AX,DX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000891def DIV16r : I<0xF7, MRM6r, (outs), (ins GR16:$src), // DX:AX/r16 = AX,DX
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000892 "div{w}\t$src", []>, OpSize;
Evan Cheng55687072007-09-14 21:48:26 +0000893let Defs = [EAX,EDX,EFLAGS], Uses = [EAX,EDX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000894def DIV32r : I<0xF7, MRM6r, (outs), (ins GR32:$src), // EDX:EAX/r32 = EAX,EDX
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000895 "div{l}\t$src", []>;
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000896let mayLoad = 1 in {
Dale Johannesend8fd3562008-10-07 18:54:28 +0000897let Defs = [AL,AH,EFLAGS], Uses = [AX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000898def DIV8m : I<0xF6, MRM6m, (outs), (ins i8mem:$src), // AX/[mem8] = AL,AH
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000899 "div{b}\t$src", []>;
Evan Cheng55687072007-09-14 21:48:26 +0000900let Defs = [AX,DX,EFLAGS], Uses = [AX,DX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000901def DIV16m : I<0xF7, MRM6m, (outs), (ins i16mem:$src), // DX:AX/[mem16] = AX,DX
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000902 "div{w}\t$src", []>, OpSize;
Evan Cheng55687072007-09-14 21:48:26 +0000903let Defs = [EAX,EDX,EFLAGS], Uses = [EAX,EDX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000904def DIV32m : I<0xF7, MRM6m, (outs), (ins i32mem:$src), // EDX:EAX/[mem32] = EAX,EDX
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000905 "div{l}\t$src", []>;
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000906}
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000907
908// Signed division/remainder.
Dale Johannesend8fd3562008-10-07 18:54:28 +0000909let Defs = [AL,AH,EFLAGS], Uses = [AX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000910def IDIV8r : I<0xF6, MRM7r, (outs), (ins GR8:$src), // AX/r8 = AL,AH
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000911 "idiv{b}\t$src", []>;
Evan Cheng55687072007-09-14 21:48:26 +0000912let Defs = [AX,DX,EFLAGS], Uses = [AX,DX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000913def IDIV16r: I<0xF7, MRM7r, (outs), (ins GR16:$src), // DX:AX/r16 = AX,DX
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000914 "idiv{w}\t$src", []>, OpSize;
Evan Cheng55687072007-09-14 21:48:26 +0000915let Defs = [EAX,EDX,EFLAGS], Uses = [EAX,EDX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000916def IDIV32r: I<0xF7, MRM7r, (outs), (ins GR32:$src), // EDX:EAX/r32 = EAX,EDX
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000917 "idiv{l}\t$src", []>;
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000918let mayLoad = 1, mayLoad = 1 in {
Dale Johannesend8fd3562008-10-07 18:54:28 +0000919let Defs = [AL,AH,EFLAGS], Uses = [AX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000920def IDIV8m : I<0xF6, MRM7m, (outs), (ins i8mem:$src), // AX/[mem8] = AL,AH
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000921 "idiv{b}\t$src", []>;
Evan Cheng55687072007-09-14 21:48:26 +0000922let Defs = [AX,DX,EFLAGS], Uses = [AX,DX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000923def IDIV16m: I<0xF7, MRM7m, (outs), (ins i16mem:$src), // DX:AX/[mem16] = AX,DX
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000924 "idiv{w}\t$src", []>, OpSize;
Evan Cheng55687072007-09-14 21:48:26 +0000925let Defs = [EAX,EDX,EFLAGS], Uses = [EAX,EDX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000926def IDIV32m: I<0xF7, MRM7m, (outs), (ins i32mem:$src), // EDX:EAX/[mem32] = EAX,EDX
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000927 "idiv{l}\t$src", []>;
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000928}
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000929
930//===----------------------------------------------------------------------===//
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000931// Two address Instructions.
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000932//
933let isTwoAddress = 1 in {
934
935// Conditional moves
Evan Cheng950aac02007-09-25 01:57:46 +0000936let Uses = [EFLAGS] in {
Evan Cheng926658c2007-10-05 23:13:21 +0000937let isCommutable = 1 in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000938def CMOVB16rr : I<0x42, MRMSrcReg, // if <u, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +0000939 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000940 "cmovb\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000941 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000942 X86_COND_B, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000943 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000944def CMOVB32rr : I<0x42, MRMSrcReg, // if <u, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +0000945 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000946 "cmovb\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000947 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000948 X86_COND_B, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000949 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000950def CMOVAE16rr: I<0x43, MRMSrcReg, // if >=u, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +0000951 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000952 "cmovae\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000953 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000954 X86_COND_AE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000955 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000956def CMOVAE32rr: I<0x43, MRMSrcReg, // if >=u, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +0000957 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000958 "cmovae\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000959 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000960 X86_COND_AE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000961 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000962def CMOVE16rr : I<0x44, MRMSrcReg, // if ==, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +0000963 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000964 "cmove\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000965 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000966 X86_COND_E, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000967 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000968def CMOVE32rr : I<0x44, MRMSrcReg, // if ==, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +0000969 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000970 "cmove\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000971 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000972 X86_COND_E, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000973 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000974def CMOVNE16rr: I<0x45, MRMSrcReg, // if !=, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +0000975 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000976 "cmovne\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000977 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000978 X86_COND_NE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000979 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000980def CMOVNE32rr: I<0x45, MRMSrcReg, // if !=, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +0000981 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000982 "cmovne\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000983 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000984 X86_COND_NE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000985 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000986def CMOVBE16rr: I<0x46, MRMSrcReg, // if <=u, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +0000987 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000988 "cmovbe\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000989 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000990 X86_COND_BE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000991 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000992def CMOVBE32rr: I<0x46, MRMSrcReg, // if <=u, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +0000993 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000994 "cmovbe\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000995 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000996 X86_COND_BE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000997 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000998def CMOVA16rr : I<0x47, MRMSrcReg, // if >u, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +0000999 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001000 "cmova\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001001 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001002 X86_COND_A, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001003 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001004def CMOVA32rr : I<0x47, MRMSrcReg, // if >u, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +00001005 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001006 "cmova\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001007 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001008 X86_COND_A, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001009 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001010def CMOVL16rr : I<0x4C, MRMSrcReg, // if <s, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +00001011 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001012 "cmovl\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001013 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001014 X86_COND_L, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001015 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001016def CMOVL32rr : I<0x4C, MRMSrcReg, // if <s, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +00001017 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001018 "cmovl\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001019 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001020 X86_COND_L, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001021 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001022def CMOVGE16rr: I<0x4D, MRMSrcReg, // if >=s, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +00001023 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001024 "cmovge\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001025 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001026 X86_COND_GE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001027 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001028def CMOVGE32rr: I<0x4D, MRMSrcReg, // if >=s, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +00001029 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001030 "cmovge\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001031 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001032 X86_COND_GE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001033 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001034def CMOVLE16rr: I<0x4E, MRMSrcReg, // if <=s, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +00001035 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001036 "cmovle\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001037 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001038 X86_COND_LE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001039 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001040def CMOVLE32rr: I<0x4E, MRMSrcReg, // if <=s, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +00001041 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001042 "cmovle\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001043 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001044 X86_COND_LE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001045 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001046def CMOVG16rr : I<0x4F, MRMSrcReg, // if >s, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +00001047 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001048 "cmovg\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001049 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001050 X86_COND_G, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001051 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001052def CMOVG32rr : I<0x4F, MRMSrcReg, // if >s, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +00001053 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001054 "cmovg\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001055 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001056 X86_COND_G, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001057 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001058def CMOVS16rr : I<0x48, MRMSrcReg, // if signed, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +00001059 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001060 "cmovs\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001061 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001062 X86_COND_S, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001063 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001064def CMOVS32rr : I<0x48, MRMSrcReg, // if signed, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +00001065 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001066 "cmovs\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001067 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001068 X86_COND_S, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001069 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001070def CMOVNS16rr: I<0x49, MRMSrcReg, // if !signed, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +00001071 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001072 "cmovns\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001073 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001074 X86_COND_NS, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001075 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001076def CMOVNS32rr: I<0x49, MRMSrcReg, // if !signed, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +00001077 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001078 "cmovns\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001079 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001080 X86_COND_NS, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001081 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001082def CMOVP16rr : I<0x4A, MRMSrcReg, // if parity, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +00001083 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001084 "cmovp\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001085 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001086 X86_COND_P, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001087 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001088def CMOVP32rr : I<0x4A, MRMSrcReg, // if parity, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +00001089 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001090 "cmovp\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001091 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001092 X86_COND_P, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001093 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001094def CMOVNP16rr : I<0x4B, MRMSrcReg, // if !parity, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +00001095 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001096 "cmovnp\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001097 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001098 X86_COND_NP, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001099 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001100def CMOVNP32rr : I<0x4B, MRMSrcReg, // if !parity, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +00001101 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001102 "cmovnp\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001103 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001104 X86_COND_NP, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001105 TB;
Dan Gohman12fd4d72009-01-07 00:35:10 +00001106def CMOVO16rr : I<0x40, MRMSrcReg, // if overflow, GR16 = GR16
1107 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
1108 "cmovo\t{$src2, $dst|$dst, $src2}",
1109 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
1110 X86_COND_O, EFLAGS))]>,
1111 TB, OpSize;
1112def CMOVO32rr : I<0x40, MRMSrcReg, // if overflow, GR32 = GR32
1113 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
1114 "cmovo\t{$src2, $dst|$dst, $src2}",
1115 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
1116 X86_COND_O, EFLAGS))]>,
Evan Cheng950aac02007-09-25 01:57:46 +00001117 TB;
Dan Gohman12fd4d72009-01-07 00:35:10 +00001118def CMOVNO16rr : I<0x41, MRMSrcReg, // if !overflow, GR16 = GR16
1119 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
1120 "cmovno\t{$src2, $dst|$dst, $src2}",
1121 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
1122 X86_COND_NO, EFLAGS))]>,
1123 TB, OpSize;
1124def CMOVNO32rr : I<0x41, MRMSrcReg, // if !overflow, GR32 = GR32
1125 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
1126 "cmovno\t{$src2, $dst|$dst, $src2}",
1127 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
1128 X86_COND_NO, EFLAGS))]>,
1129 TB;
1130} // isCommutable = 1
Evan Cheng926658c2007-10-05 23:13:21 +00001131
1132def CMOVB16rm : I<0x42, MRMSrcMem, // if <u, GR16 = [mem16]
1133 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1134 "cmovb\t{$src2, $dst|$dst, $src2}",
1135 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1136 X86_COND_B, EFLAGS))]>,
1137 TB, OpSize;
1138def CMOVB32rm : I<0x42, MRMSrcMem, // if <u, GR32 = [mem32]
1139 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1140 "cmovb\t{$src2, $dst|$dst, $src2}",
1141 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1142 X86_COND_B, EFLAGS))]>,
1143 TB;
1144def CMOVAE16rm: I<0x43, MRMSrcMem, // if >=u, GR16 = [mem16]
1145 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1146 "cmovae\t{$src2, $dst|$dst, $src2}",
1147 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1148 X86_COND_AE, EFLAGS))]>,
1149 TB, OpSize;
1150def CMOVAE32rm: I<0x43, MRMSrcMem, // if >=u, GR32 = [mem32]
1151 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1152 "cmovae\t{$src2, $dst|$dst, $src2}",
1153 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1154 X86_COND_AE, EFLAGS))]>,
1155 TB;
1156def CMOVE16rm : I<0x44, MRMSrcMem, // if ==, GR16 = [mem16]
1157 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1158 "cmove\t{$src2, $dst|$dst, $src2}",
1159 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1160 X86_COND_E, EFLAGS))]>,
1161 TB, OpSize;
1162def CMOVE32rm : I<0x44, MRMSrcMem, // if ==, GR32 = [mem32]
1163 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1164 "cmove\t{$src2, $dst|$dst, $src2}",
1165 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1166 X86_COND_E, EFLAGS))]>,
1167 TB;
1168def CMOVNE16rm: I<0x45, MRMSrcMem, // if !=, GR16 = [mem16]
1169 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1170 "cmovne\t{$src2, $dst|$dst, $src2}",
1171 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1172 X86_COND_NE, EFLAGS))]>,
1173 TB, OpSize;
1174def CMOVNE32rm: I<0x45, MRMSrcMem, // if !=, GR32 = [mem32]
1175 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1176 "cmovne\t{$src2, $dst|$dst, $src2}",
1177 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1178 X86_COND_NE, EFLAGS))]>,
1179 TB;
1180def CMOVBE16rm: I<0x46, MRMSrcMem, // if <=u, GR16 = [mem16]
1181 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1182 "cmovbe\t{$src2, $dst|$dst, $src2}",
1183 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1184 X86_COND_BE, EFLAGS))]>,
1185 TB, OpSize;
1186def CMOVBE32rm: I<0x46, MRMSrcMem, // if <=u, GR32 = [mem32]
1187 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1188 "cmovbe\t{$src2, $dst|$dst, $src2}",
1189 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1190 X86_COND_BE, EFLAGS))]>,
1191 TB;
1192def CMOVA16rm : I<0x47, MRMSrcMem, // if >u, GR16 = [mem16]
1193 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1194 "cmova\t{$src2, $dst|$dst, $src2}",
1195 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1196 X86_COND_A, EFLAGS))]>,
1197 TB, OpSize;
1198def CMOVA32rm : I<0x47, MRMSrcMem, // if >u, GR32 = [mem32]
1199 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1200 "cmova\t{$src2, $dst|$dst, $src2}",
1201 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1202 X86_COND_A, EFLAGS))]>,
1203 TB;
1204def CMOVL16rm : I<0x4C, MRMSrcMem, // if <s, GR16 = [mem16]
1205 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1206 "cmovl\t{$src2, $dst|$dst, $src2}",
1207 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1208 X86_COND_L, EFLAGS))]>,
1209 TB, OpSize;
1210def CMOVL32rm : I<0x4C, MRMSrcMem, // if <s, GR32 = [mem32]
1211 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1212 "cmovl\t{$src2, $dst|$dst, $src2}",
1213 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1214 X86_COND_L, EFLAGS))]>,
1215 TB;
1216def CMOVGE16rm: I<0x4D, MRMSrcMem, // if >=s, GR16 = [mem16]
1217 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1218 "cmovge\t{$src2, $dst|$dst, $src2}",
1219 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1220 X86_COND_GE, EFLAGS))]>,
1221 TB, OpSize;
1222def CMOVGE32rm: I<0x4D, MRMSrcMem, // if >=s, GR32 = [mem32]
1223 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1224 "cmovge\t{$src2, $dst|$dst, $src2}",
1225 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1226 X86_COND_GE, EFLAGS))]>,
1227 TB;
1228def CMOVLE16rm: I<0x4E, MRMSrcMem, // if <=s, GR16 = [mem16]
1229 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1230 "cmovle\t{$src2, $dst|$dst, $src2}",
1231 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1232 X86_COND_LE, EFLAGS))]>,
1233 TB, OpSize;
1234def CMOVLE32rm: I<0x4E, MRMSrcMem, // if <=s, GR32 = [mem32]
1235 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1236 "cmovle\t{$src2, $dst|$dst, $src2}",
1237 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1238 X86_COND_LE, EFLAGS))]>,
1239 TB;
1240def CMOVG16rm : I<0x4F, MRMSrcMem, // if >s, GR16 = [mem16]
1241 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1242 "cmovg\t{$src2, $dst|$dst, $src2}",
1243 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1244 X86_COND_G, EFLAGS))]>,
1245 TB, OpSize;
1246def CMOVG32rm : I<0x4F, MRMSrcMem, // if >s, GR32 = [mem32]
1247 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1248 "cmovg\t{$src2, $dst|$dst, $src2}",
1249 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1250 X86_COND_G, EFLAGS))]>,
1251 TB;
1252def CMOVS16rm : I<0x48, MRMSrcMem, // if signed, GR16 = [mem16]
1253 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1254 "cmovs\t{$src2, $dst|$dst, $src2}",
1255 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1256 X86_COND_S, EFLAGS))]>,
1257 TB, OpSize;
1258def CMOVS32rm : I<0x48, MRMSrcMem, // if signed, GR32 = [mem32]
1259 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1260 "cmovs\t{$src2, $dst|$dst, $src2}",
1261 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1262 X86_COND_S, EFLAGS))]>,
1263 TB;
1264def CMOVNS16rm: I<0x49, MRMSrcMem, // if !signed, GR16 = [mem16]
1265 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1266 "cmovns\t{$src2, $dst|$dst, $src2}",
1267 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1268 X86_COND_NS, EFLAGS))]>,
1269 TB, OpSize;
1270def CMOVNS32rm: I<0x49, MRMSrcMem, // if !signed, GR32 = [mem32]
1271 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1272 "cmovns\t{$src2, $dst|$dst, $src2}",
1273 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1274 X86_COND_NS, EFLAGS))]>,
1275 TB;
1276def CMOVP16rm : I<0x4A, MRMSrcMem, // if parity, GR16 = [mem16]
1277 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1278 "cmovp\t{$src2, $dst|$dst, $src2}",
1279 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1280 X86_COND_P, EFLAGS))]>,
1281 TB, OpSize;
1282def CMOVP32rm : I<0x4A, MRMSrcMem, // if parity, GR32 = [mem32]
1283 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1284 "cmovp\t{$src2, $dst|$dst, $src2}",
1285 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1286 X86_COND_P, EFLAGS))]>,
1287 TB;
1288def CMOVNP16rm : I<0x4B, MRMSrcMem, // if !parity, GR16 = [mem16]
1289 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1290 "cmovnp\t{$src2, $dst|$dst, $src2}",
1291 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1292 X86_COND_NP, EFLAGS))]>,
1293 TB, OpSize;
Dan Gohman12fd4d72009-01-07 00:35:10 +00001294def CMOVNP32rm : I<0x4B, MRMSrcMem, // if !parity, GR32 = [mem32]
1295 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1296 "cmovnp\t{$src2, $dst|$dst, $src2}",
1297 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1298 X86_COND_NP, EFLAGS))]>,
1299 TB;
1300def CMOVO16rm : I<0x40, MRMSrcMem, // if overflow, GR16 = [mem16]
1301 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1302 "cmovo\t{$src2, $dst|$dst, $src2}",
1303 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1304 X86_COND_O, EFLAGS))]>,
1305 TB, OpSize;
1306def CMOVO32rm : I<0x40, MRMSrcMem, // if overflow, GR32 = [mem32]
1307 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1308 "cmovo\t{$src2, $dst|$dst, $src2}",
1309 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1310 X86_COND_O, EFLAGS))]>,
1311 TB;
1312def CMOVNO16rm : I<0x41, MRMSrcMem, // if !overflow, GR16 = [mem16]
1313 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1314 "cmovno\t{$src2, $dst|$dst, $src2}",
1315 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1316 X86_COND_NO, EFLAGS))]>,
1317 TB, OpSize;
1318def CMOVNO32rm : I<0x41, MRMSrcMem, // if !overflow, GR32 = [mem32]
1319 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1320 "cmovno\t{$src2, $dst|$dst, $src2}",
1321 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1322 X86_COND_NO, EFLAGS))]>,
1323 TB;
Evan Cheng950aac02007-09-25 01:57:46 +00001324} // Uses = [EFLAGS]
1325
1326
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001327// unary instructions
1328let CodeSize = 2 in {
Evan Cheng55687072007-09-14 21:48:26 +00001329let Defs = [EFLAGS] in {
Dan Gohman91888f02007-07-31 20:11:57 +00001330def NEG8r : I<0xF6, MRM3r, (outs GR8 :$dst), (ins GR8 :$src), "neg{b}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001331 [(set GR8:$dst, (ineg GR8:$src)),
1332 (implicit EFLAGS)]>;
Dan Gohman91888f02007-07-31 20:11:57 +00001333def NEG16r : I<0xF7, MRM3r, (outs GR16:$dst), (ins GR16:$src), "neg{w}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001334 [(set GR16:$dst, (ineg GR16:$src)),
1335 (implicit EFLAGS)]>, OpSize;
Dan Gohman91888f02007-07-31 20:11:57 +00001336def NEG32r : I<0xF7, MRM3r, (outs GR32:$dst), (ins GR32:$src), "neg{l}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001337 [(set GR32:$dst, (ineg GR32:$src)),
1338 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001339let isTwoAddress = 0 in {
Dan Gohman91888f02007-07-31 20:11:57 +00001340 def NEG8m : I<0xF6, MRM3m, (outs), (ins i8mem :$dst), "neg{b}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001341 [(store (ineg (loadi8 addr:$dst)), addr:$dst),
1342 (implicit EFLAGS)]>;
Dan Gohman91888f02007-07-31 20:11:57 +00001343 def NEG16m : I<0xF7, MRM3m, (outs), (ins i16mem:$dst), "neg{w}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001344 [(store (ineg (loadi16 addr:$dst)), addr:$dst),
1345 (implicit EFLAGS)]>, OpSize;
Dan Gohman91888f02007-07-31 20:11:57 +00001346 def NEG32m : I<0xF7, MRM3m, (outs), (ins i32mem:$dst), "neg{l}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001347 [(store (ineg (loadi32 addr:$dst)), addr:$dst),
1348 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001349}
Evan Cheng55687072007-09-14 21:48:26 +00001350} // Defs = [EFLAGS]
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001351
Evan Chengc6cee682009-01-21 02:09:05 +00001352// Match xor -1 to not. Favors these over a move imm + xor to save code size.
1353let AddedComplexity = 15 in {
Dan Gohman91888f02007-07-31 20:11:57 +00001354def NOT8r : I<0xF6, MRM2r, (outs GR8 :$dst), (ins GR8 :$src), "not{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001355 [(set GR8:$dst, (not GR8:$src))]>;
Dan Gohman91888f02007-07-31 20:11:57 +00001356def NOT16r : I<0xF7, MRM2r, (outs GR16:$dst), (ins GR16:$src), "not{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001357 [(set GR16:$dst, (not GR16:$src))]>, OpSize;
Dan Gohman91888f02007-07-31 20:11:57 +00001358def NOT32r : I<0xF7, MRM2r, (outs GR32:$dst), (ins GR32:$src), "not{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001359 [(set GR32:$dst, (not GR32:$src))]>;
Evan Chengc6cee682009-01-21 02:09:05 +00001360}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001361let isTwoAddress = 0 in {
Dan Gohman91888f02007-07-31 20:11:57 +00001362 def NOT8m : I<0xF6, MRM2m, (outs), (ins i8mem :$dst), "not{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001363 [(store (not (loadi8 addr:$dst)), addr:$dst)]>;
Dan Gohman91888f02007-07-31 20:11:57 +00001364 def NOT16m : I<0xF7, MRM2m, (outs), (ins i16mem:$dst), "not{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001365 [(store (not (loadi16 addr:$dst)), addr:$dst)]>, OpSize;
Dan Gohman91888f02007-07-31 20:11:57 +00001366 def NOT32m : I<0xF7, MRM2m, (outs), (ins i32mem:$dst), "not{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001367 [(store (not (loadi32 addr:$dst)), addr:$dst)]>;
1368}
1369} // CodeSize
1370
1371// TODO: inc/dec is slow for P4, but fast for Pentium-M.
Evan Cheng55687072007-09-14 21:48:26 +00001372let Defs = [EFLAGS] in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001373let CodeSize = 2 in
Dan Gohman91888f02007-07-31 20:11:57 +00001374def INC8r : I<0xFE, MRM0r, (outs GR8 :$dst), (ins GR8 :$src), "inc{b}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001375 [(set GR8:$dst, (add GR8:$src, 1)),
1376 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001377let isConvertibleToThreeAddress = 1, CodeSize = 1 in { // Can xform into LEA.
Dan Gohman91888f02007-07-31 20:11:57 +00001378def INC16r : I<0x40, AddRegFrm, (outs GR16:$dst), (ins GR16:$src), "inc{w}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001379 [(set GR16:$dst, (add GR16:$src, 1)),
1380 (implicit EFLAGS)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001381 OpSize, Requires<[In32BitMode]>;
Dan Gohman91888f02007-07-31 20:11:57 +00001382def INC32r : I<0x40, AddRegFrm, (outs GR32:$dst), (ins GR32:$src), "inc{l}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001383 [(set GR32:$dst, (add GR32:$src, 1)),
1384 (implicit EFLAGS)]>, Requires<[In32BitMode]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001385}
1386let isTwoAddress = 0, CodeSize = 2 in {
Dan Gohman91888f02007-07-31 20:11:57 +00001387 def INC8m : I<0xFE, MRM0m, (outs), (ins i8mem :$dst), "inc{b}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001388 [(store (add (loadi8 addr:$dst), 1), addr:$dst),
1389 (implicit EFLAGS)]>;
Dan Gohman91888f02007-07-31 20:11:57 +00001390 def INC16m : I<0xFF, MRM0m, (outs), (ins i16mem:$dst), "inc{w}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001391 [(store (add (loadi16 addr:$dst), 1), addr:$dst),
1392 (implicit EFLAGS)]>,
Evan Cheng4a7e72f2007-10-19 21:23:22 +00001393 OpSize, Requires<[In32BitMode]>;
Dan Gohman91888f02007-07-31 20:11:57 +00001394 def INC32m : I<0xFF, MRM0m, (outs), (ins i32mem:$dst), "inc{l}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001395 [(store (add (loadi32 addr:$dst), 1), addr:$dst),
1396 (implicit EFLAGS)]>,
Evan Cheng4a7e72f2007-10-19 21:23:22 +00001397 Requires<[In32BitMode]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001398}
1399
1400let CodeSize = 2 in
Dan Gohman91888f02007-07-31 20:11:57 +00001401def DEC8r : I<0xFE, MRM1r, (outs GR8 :$dst), (ins GR8 :$src), "dec{b}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001402 [(set GR8:$dst, (add GR8:$src, -1)),
1403 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001404let isConvertibleToThreeAddress = 1, CodeSize = 1 in { // Can xform into LEA.
Dan Gohman91888f02007-07-31 20:11:57 +00001405def DEC16r : I<0x48, AddRegFrm, (outs GR16:$dst), (ins GR16:$src), "dec{w}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001406 [(set GR16:$dst, (add GR16:$src, -1)),
1407 (implicit EFLAGS)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001408 OpSize, Requires<[In32BitMode]>;
Dan Gohman91888f02007-07-31 20:11:57 +00001409def DEC32r : I<0x48, AddRegFrm, (outs GR32:$dst), (ins GR32:$src), "dec{l}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001410 [(set GR32:$dst, (add GR32:$src, -1)),
1411 (implicit EFLAGS)]>, Requires<[In32BitMode]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001412}
1413
1414let isTwoAddress = 0, CodeSize = 2 in {
Dan Gohman91888f02007-07-31 20:11:57 +00001415 def DEC8m : I<0xFE, MRM1m, (outs), (ins i8mem :$dst), "dec{b}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001416 [(store (add (loadi8 addr:$dst), -1), addr:$dst),
1417 (implicit EFLAGS)]>;
Dan Gohman91888f02007-07-31 20:11:57 +00001418 def DEC16m : I<0xFF, MRM1m, (outs), (ins i16mem:$dst), "dec{w}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001419 [(store (add (loadi16 addr:$dst), -1), addr:$dst),
1420 (implicit EFLAGS)]>,
Evan Cheng4a7e72f2007-10-19 21:23:22 +00001421 OpSize, Requires<[In32BitMode]>;
Dan Gohman91888f02007-07-31 20:11:57 +00001422 def DEC32m : I<0xFF, MRM1m, (outs), (ins i32mem:$dst), "dec{l}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001423 [(store (add (loadi32 addr:$dst), -1), addr:$dst),
1424 (implicit EFLAGS)]>,
Evan Cheng4a7e72f2007-10-19 21:23:22 +00001425 Requires<[In32BitMode]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001426}
Evan Cheng55687072007-09-14 21:48:26 +00001427} // Defs = [EFLAGS]
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001428
1429// Logical operators...
Evan Cheng55687072007-09-14 21:48:26 +00001430let Defs = [EFLAGS] in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001431let isCommutable = 1 in { // X = AND Y, Z --> X = AND Z, Y
1432def AND8rr : I<0x20, MRMDestReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001433 (outs GR8 :$dst), (ins GR8 :$src1, GR8 :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001434 "and{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001435 [(set GR8:$dst, (and GR8:$src1, GR8:$src2)),
1436 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001437def AND16rr : I<0x21, MRMDestReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001438 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001439 "and{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001440 [(set GR16:$dst, (and GR16:$src1, GR16:$src2)),
1441 (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001442def AND32rr : I<0x21, MRMDestReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001443 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001444 "and{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001445 [(set GR32:$dst, (and GR32:$src1, GR32:$src2)),
1446 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001447}
1448
1449def AND8rm : I<0x22, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001450 (outs GR8 :$dst), (ins GR8 :$src1, i8mem :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001451 "and{b}\t{$src2, $dst|$dst, $src2}",
Chris Lattner12208612009-04-10 00:16:23 +00001452 [(set GR8:$dst, (and GR8:$src1, (loadi8 addr:$src2))),
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001453 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001454def AND16rm : I<0x23, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001455 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001456 "and{w}\t{$src2, $dst|$dst, $src2}",
Chris Lattner12208612009-04-10 00:16:23 +00001457 [(set GR16:$dst, (and GR16:$src1, (loadi16 addr:$src2))),
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001458 (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001459def AND32rm : I<0x23, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001460 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001461 "and{l}\t{$src2, $dst|$dst, $src2}",
Chris Lattner12208612009-04-10 00:16:23 +00001462 [(set GR32:$dst, (and GR32:$src1, (loadi32 addr:$src2))),
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001463 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001464
1465def AND8ri : Ii8<0x80, MRM4r,
Evan Chengb783fa32007-07-19 01:14:50 +00001466 (outs GR8 :$dst), (ins GR8 :$src1, i8imm :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001467 "and{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001468 [(set GR8:$dst, (and GR8:$src1, imm:$src2)),
1469 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001470def AND16ri : Ii16<0x81, MRM4r,
Evan Chengb783fa32007-07-19 01:14:50 +00001471 (outs GR16:$dst), (ins GR16:$src1, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001472 "and{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001473 [(set GR16:$dst, (and GR16:$src1, imm:$src2)),
1474 (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001475def AND32ri : Ii32<0x81, MRM4r,
Evan Chengb783fa32007-07-19 01:14:50 +00001476 (outs GR32:$dst), (ins GR32:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001477 "and{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001478 [(set GR32:$dst, (and GR32:$src1, imm:$src2)),
1479 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001480def AND16ri8 : Ii8<0x83, MRM4r,
Evan Chengb783fa32007-07-19 01:14:50 +00001481 (outs GR16:$dst), (ins GR16:$src1, i16i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001482 "and{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001483 [(set GR16:$dst, (and GR16:$src1, i16immSExt8:$src2)),
1484 (implicit EFLAGS)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001485 OpSize;
1486def AND32ri8 : Ii8<0x83, MRM4r,
Evan Chengb783fa32007-07-19 01:14:50 +00001487 (outs GR32:$dst), (ins GR32:$src1, i32i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001488 "and{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001489 [(set GR32:$dst, (and GR32:$src1, i32immSExt8:$src2)),
1490 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001491
1492let isTwoAddress = 0 in {
1493 def AND8mr : I<0x20, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001494 (outs), (ins i8mem :$dst, GR8 :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001495 "and{b}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001496 [(store (and (load addr:$dst), GR8:$src), addr:$dst),
1497 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001498 def AND16mr : I<0x21, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001499 (outs), (ins i16mem:$dst, GR16:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001500 "and{w}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001501 [(store (and (load addr:$dst), GR16:$src), addr:$dst),
1502 (implicit EFLAGS)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001503 OpSize;
1504 def AND32mr : I<0x21, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001505 (outs), (ins i32mem:$dst, GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001506 "and{l}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001507 [(store (and (load addr:$dst), GR32:$src), addr:$dst),
1508 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001509 def AND8mi : Ii8<0x80, MRM4m,
Evan Chengb783fa32007-07-19 01:14:50 +00001510 (outs), (ins i8mem :$dst, i8imm :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001511 "and{b}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001512 [(store (and (loadi8 addr:$dst), imm:$src), addr:$dst),
1513 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001514 def AND16mi : Ii16<0x81, MRM4m,
Evan Chengb783fa32007-07-19 01:14:50 +00001515 (outs), (ins i16mem:$dst, i16imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001516 "and{w}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001517 [(store (and (loadi16 addr:$dst), imm:$src), addr:$dst),
1518 (implicit EFLAGS)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001519 OpSize;
1520 def AND32mi : Ii32<0x81, MRM4m,
Evan Chengb783fa32007-07-19 01:14:50 +00001521 (outs), (ins i32mem:$dst, i32imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001522 "and{l}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001523 [(store (and (loadi32 addr:$dst), imm:$src), addr:$dst),
1524 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001525 def AND16mi8 : Ii8<0x83, MRM4m,
Evan Chengb783fa32007-07-19 01:14:50 +00001526 (outs), (ins i16mem:$dst, i16i8imm :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001527 "and{w}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001528 [(store (and (load addr:$dst), i16immSExt8:$src), addr:$dst),
1529 (implicit EFLAGS)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001530 OpSize;
1531 def AND32mi8 : Ii8<0x83, MRM4m,
Evan Chengb783fa32007-07-19 01:14:50 +00001532 (outs), (ins i32mem:$dst, i32i8imm :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001533 "and{l}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001534 [(store (and (load addr:$dst), i32immSExt8:$src), addr:$dst),
1535 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001536}
1537
1538
1539let isCommutable = 1 in { // X = OR Y, Z --> X = OR Z, Y
Evan Chengb783fa32007-07-19 01:14:50 +00001540def OR8rr : I<0x08, MRMDestReg, (outs GR8 :$dst), (ins GR8 :$src1, GR8 :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001541 "or{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001542 [(set GR8:$dst, (or GR8:$src1, GR8:$src2)),
1543 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001544def OR16rr : I<0x09, MRMDestReg, (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001545 "or{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001546 [(set GR16:$dst, (or GR16:$src1, GR16:$src2)),
1547 (implicit EFLAGS)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001548def OR32rr : I<0x09, MRMDestReg, (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001549 "or{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001550 [(set GR32:$dst, (or GR32:$src1, GR32:$src2)),
1551 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001552}
Evan Chengb783fa32007-07-19 01:14:50 +00001553def OR8rm : I<0x0A, MRMSrcMem , (outs GR8 :$dst), (ins GR8 :$src1, i8mem :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001554 "or{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001555 [(set GR8:$dst, (or GR8:$src1, (load addr:$src2))),
1556 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001557def OR16rm : I<0x0B, MRMSrcMem , (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001558 "or{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001559 [(set GR16:$dst, (or GR16:$src1, (load addr:$src2))),
1560 (implicit EFLAGS)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001561def OR32rm : I<0x0B, MRMSrcMem , (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001562 "or{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001563 [(set GR32:$dst, (or GR32:$src1, (load addr:$src2))),
1564 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001565
Evan Chengb783fa32007-07-19 01:14:50 +00001566def OR8ri : Ii8 <0x80, MRM1r, (outs GR8 :$dst), (ins GR8 :$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001567 "or{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001568 [(set GR8:$dst, (or GR8:$src1, imm:$src2)),
1569 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001570def OR16ri : Ii16<0x81, MRM1r, (outs GR16:$dst), (ins GR16:$src1, i16imm:$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, imm:$src2)),
1573 (implicit EFLAGS)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001574def OR32ri : Ii32<0x81, MRM1r, (outs GR32:$dst), (ins GR32:$src1, i32imm:$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, imm:$src2)),
1577 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001578
Evan Chengb783fa32007-07-19 01:14:50 +00001579def OR16ri8 : Ii8<0x83, MRM1r, (outs GR16:$dst), (ins GR16:$src1, i16i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001580 "or{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001581 [(set GR16:$dst, (or GR16:$src1, i16immSExt8:$src2)),
1582 (implicit EFLAGS)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001583def OR32ri8 : Ii8<0x83, MRM1r, (outs GR32:$dst), (ins GR32:$src1, i32i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001584 "or{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001585 [(set GR32:$dst, (or GR32:$src1, i32immSExt8:$src2)),
1586 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001587let isTwoAddress = 0 in {
Evan Chengb783fa32007-07-19 01:14:50 +00001588 def OR8mr : I<0x08, MRMDestMem, (outs), (ins i8mem:$dst, GR8:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001589 "or{b}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001590 [(store (or (load addr:$dst), GR8:$src), addr:$dst),
1591 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001592 def OR16mr : I<0x09, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001593 "or{w}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001594 [(store (or (load addr:$dst), GR16:$src), addr:$dst),
1595 (implicit EFLAGS)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001596 def OR32mr : I<0x09, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001597 "or{l}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001598 [(store (or (load addr:$dst), GR32:$src), addr:$dst),
1599 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001600 def OR8mi : Ii8<0x80, MRM1m, (outs), (ins i8mem :$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001601 "or{b}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001602 [(store (or (loadi8 addr:$dst), imm:$src), addr:$dst),
1603 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001604 def OR16mi : Ii16<0x81, MRM1m, (outs), (ins i16mem:$dst, i16imm:$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 (loadi16 addr:$dst), imm:$src), addr:$dst),
1607 (implicit EFLAGS)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001608 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001609 def OR32mi : Ii32<0x81, MRM1m, (outs), (ins i32mem:$dst, i32imm:$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 (loadi32 addr:$dst), imm:$src), addr:$dst),
1612 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001613 def OR16mi8 : Ii8<0x83, MRM1m, (outs), (ins i16mem:$dst, i16i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001614 "or{w}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001615 [(store (or (load addr:$dst), i16immSExt8:$src), addr:$dst),
1616 (implicit EFLAGS)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001617 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001618 def OR32mi8 : Ii8<0x83, MRM1m, (outs), (ins i32mem:$dst, i32i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001619 "or{l}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001620 [(store (or (load addr:$dst), i32immSExt8:$src), addr:$dst),
1621 (implicit EFLAGS)]>;
Bill Wendlingba5d5b02008-05-29 01:02:09 +00001622} // isTwoAddress = 0
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001623
1624
Evan Cheng6f26e8b2008-06-18 08:13:07 +00001625let isCommutable = 1 in { // X = XOR Y, Z --> X = XOR Z, Y
Bill Wendlingba5d5b02008-05-29 01:02:09 +00001626 def XOR8rr : I<0x30, MRMDestReg,
1627 (outs GR8 :$dst), (ins GR8 :$src1, GR8 :$src2),
1628 "xor{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001629 [(set GR8:$dst, (xor GR8:$src1, GR8:$src2)),
1630 (implicit EFLAGS)]>;
Bill Wendlingba5d5b02008-05-29 01:02:09 +00001631 def XOR16rr : I<0x31, MRMDestReg,
1632 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
1633 "xor{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001634 [(set GR16:$dst, (xor GR16:$src1, GR16:$src2)),
1635 (implicit EFLAGS)]>, OpSize;
Bill Wendlingba5d5b02008-05-29 01:02:09 +00001636 def XOR32rr : I<0x31, MRMDestReg,
1637 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
1638 "xor{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001639 [(set GR32:$dst, (xor GR32:$src1, GR32:$src2)),
1640 (implicit EFLAGS)]>;
Evan Cheng6f26e8b2008-06-18 08:13:07 +00001641} // isCommutable = 1
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001642
1643def XOR8rm : I<0x32, MRMSrcMem ,
Evan Chengb783fa32007-07-19 01:14:50 +00001644 (outs GR8 :$dst), (ins GR8:$src1, i8mem :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001645 "xor{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001646 [(set GR8:$dst, (xor GR8:$src1, (load addr:$src2))),
1647 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001648def XOR16rm : I<0x33, MRMSrcMem ,
Evan Chengb783fa32007-07-19 01:14:50 +00001649 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001650 "xor{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001651 [(set GR16:$dst, (xor GR16:$src1, (load addr:$src2))),
1652 (implicit EFLAGS)]>,
Bill Wendlingba5d5b02008-05-29 01:02:09 +00001653 OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001654def XOR32rm : I<0x33, MRMSrcMem ,
Evan Chengb783fa32007-07-19 01:14:50 +00001655 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001656 "xor{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001657 [(set GR32:$dst, (xor GR32:$src1, (load addr:$src2))),
1658 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001659
Bill Wendlingbac38eb2008-05-29 03:46:36 +00001660def XOR8ri : Ii8<0x80, MRM6r,
1661 (outs GR8:$dst), (ins GR8:$src1, i8imm:$src2),
1662 "xor{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001663 [(set GR8:$dst, (xor GR8:$src1, imm:$src2)),
1664 (implicit EFLAGS)]>;
Bill Wendlingbac38eb2008-05-29 03:46:36 +00001665def XOR16ri : Ii16<0x81, MRM6r,
1666 (outs GR16:$dst), (ins GR16:$src1, i16imm:$src2),
1667 "xor{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001668 [(set GR16:$dst, (xor GR16:$src1, imm:$src2)),
1669 (implicit EFLAGS)]>, OpSize;
Bill Wendlingbac38eb2008-05-29 03:46:36 +00001670def XOR32ri : Ii32<0x81, MRM6r,
1671 (outs GR32:$dst), (ins GR32:$src1, i32imm:$src2),
1672 "xor{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001673 [(set GR32:$dst, (xor GR32:$src1, imm:$src2)),
1674 (implicit EFLAGS)]>;
Bill Wendlingbac38eb2008-05-29 03:46:36 +00001675def XOR16ri8 : Ii8<0x83, MRM6r,
1676 (outs GR16:$dst), (ins GR16:$src1, i16i8imm:$src2),
1677 "xor{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001678 [(set GR16:$dst, (xor GR16:$src1, i16immSExt8:$src2)),
1679 (implicit EFLAGS)]>,
Bill Wendlingbac38eb2008-05-29 03:46:36 +00001680 OpSize;
1681def XOR32ri8 : Ii8<0x83, MRM6r,
1682 (outs GR32:$dst), (ins GR32:$src1, i32i8imm:$src2),
1683 "xor{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001684 [(set GR32:$dst, (xor GR32:$src1, i32immSExt8:$src2)),
1685 (implicit EFLAGS)]>;
Bill Wendlingba5d5b02008-05-29 01:02:09 +00001686
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001687let isTwoAddress = 0 in {
1688 def XOR8mr : I<0x30, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001689 (outs), (ins i8mem :$dst, GR8 :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001690 "xor{b}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001691 [(store (xor (load addr:$dst), GR8:$src), addr:$dst),
1692 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001693 def XOR16mr : I<0x31, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001694 (outs), (ins i16mem:$dst, GR16:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001695 "xor{w}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001696 [(store (xor (load addr:$dst), GR16:$src), addr:$dst),
1697 (implicit EFLAGS)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001698 OpSize;
1699 def XOR32mr : I<0x31, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001700 (outs), (ins i32mem:$dst, GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001701 "xor{l}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001702 [(store (xor (load addr:$dst), GR32:$src), addr:$dst),
1703 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001704 def XOR8mi : Ii8<0x80, MRM6m,
Evan Chengb783fa32007-07-19 01:14:50 +00001705 (outs), (ins i8mem :$dst, i8imm :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001706 "xor{b}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001707 [(store (xor (loadi8 addr:$dst), imm:$src), addr:$dst),
1708 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001709 def XOR16mi : Ii16<0x81, MRM6m,
Evan Chengb783fa32007-07-19 01:14:50 +00001710 (outs), (ins i16mem:$dst, i16imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001711 "xor{w}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001712 [(store (xor (loadi16 addr:$dst), imm:$src), addr:$dst),
1713 (implicit EFLAGS)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001714 OpSize;
1715 def XOR32mi : Ii32<0x81, MRM6m,
Evan Chengb783fa32007-07-19 01:14:50 +00001716 (outs), (ins i32mem:$dst, i32imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001717 "xor{l}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001718 [(store (xor (loadi32 addr:$dst), imm:$src), addr:$dst),
1719 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001720 def XOR16mi8 : Ii8<0x83, MRM6m,
Evan Chengb783fa32007-07-19 01:14:50 +00001721 (outs), (ins i16mem:$dst, i16i8imm :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001722 "xor{w}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001723 [(store (xor (load addr:$dst), i16immSExt8:$src), addr:$dst),
1724 (implicit EFLAGS)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001725 OpSize;
1726 def XOR32mi8 : Ii8<0x83, MRM6m,
Evan Chengb783fa32007-07-19 01:14:50 +00001727 (outs), (ins i32mem:$dst, i32i8imm :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001728 "xor{l}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001729 [(store (xor (load addr:$dst), i32immSExt8:$src), addr:$dst),
1730 (implicit EFLAGS)]>;
Bill Wendlingba5d5b02008-05-29 01:02:09 +00001731} // isTwoAddress = 0
Evan Cheng55687072007-09-14 21:48:26 +00001732} // Defs = [EFLAGS]
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001733
1734// Shift instructions
Evan Cheng55687072007-09-14 21:48:26 +00001735let Defs = [EFLAGS] in {
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001736let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00001737def SHL8rCL : I<0xD2, MRM4r, (outs GR8 :$dst), (ins GR8 :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001738 "shl{b}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001739 [(set GR8:$dst, (shl GR8:$src, CL))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001740def SHL16rCL : I<0xD3, MRM4r, (outs GR16:$dst), (ins GR16:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001741 "shl{w}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001742 [(set GR16:$dst, (shl GR16:$src, CL))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001743def SHL32rCL : I<0xD3, MRM4r, (outs GR32:$dst), (ins GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001744 "shl{l}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001745 [(set GR32:$dst, (shl GR32:$src, CL))]>;
Bill Wendlingba5d5b02008-05-29 01:02:09 +00001746} // Uses = [CL]
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001747
Evan Chengb783fa32007-07-19 01:14:50 +00001748def SHL8ri : Ii8<0xC0, MRM4r, (outs GR8 :$dst), (ins GR8 :$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001749 "shl{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001750 [(set GR8:$dst, (shl GR8:$src1, (i8 imm:$src2)))]>;
1751let isConvertibleToThreeAddress = 1 in { // Can transform into LEA.
Evan Chengb783fa32007-07-19 01:14:50 +00001752def SHL16ri : Ii8<0xC1, MRM4r, (outs GR16:$dst), (ins GR16:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001753 "shl{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001754 [(set GR16:$dst, (shl GR16:$src1, (i8 imm:$src2)))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001755def SHL32ri : Ii8<0xC1, MRM4r, (outs GR32:$dst), (ins GR32:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001756 "shl{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001757 [(set GR32:$dst, (shl GR32:$src1, (i8 imm:$src2)))]>;
Chris Lattnerf4005a82008-01-11 18:00:50 +00001758// NOTE: We don't use shifts of a register by one, because 'add reg,reg' is
1759// cheaper.
Bill Wendlingba5d5b02008-05-29 01:02:09 +00001760} // isConvertibleToThreeAddress = 1
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001761
1762let isTwoAddress = 0 in {
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001763 let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00001764 def SHL8mCL : I<0xD2, MRM4m, (outs), (ins i8mem :$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001765 "shl{b}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001766 [(store (shl (loadi8 addr:$dst), CL), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001767 def SHL16mCL : I<0xD3, MRM4m, (outs), (ins i16mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001768 "shl{w}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001769 [(store (shl (loadi16 addr:$dst), CL), addr:$dst)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001770 def SHL32mCL : I<0xD3, MRM4m, (outs), (ins i32mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001771 "shl{l}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001772 [(store (shl (loadi32 addr:$dst), CL), addr:$dst)]>;
1773 }
Evan Chengb783fa32007-07-19 01:14:50 +00001774 def SHL8mi : Ii8<0xC0, MRM4m, (outs), (ins i8mem :$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001775 "shl{b}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001776 [(store (shl (loadi8 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001777 def SHL16mi : Ii8<0xC1, MRM4m, (outs), (ins i16mem:$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001778 "shl{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001779 [(store (shl (loadi16 addr:$dst), (i8 imm:$src)), addr:$dst)]>,
1780 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001781 def SHL32mi : Ii8<0xC1, MRM4m, (outs), (ins i32mem:$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001782 "shl{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001783 [(store (shl (loadi32 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
1784
1785 // Shift by 1
Evan Chengb783fa32007-07-19 01:14:50 +00001786 def SHL8m1 : I<0xD0, MRM4m, (outs), (ins i8mem :$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001787 "shl{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001788 [(store (shl (loadi8 addr:$dst), (i8 1)), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001789 def SHL16m1 : I<0xD1, MRM4m, (outs), (ins i16mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001790 "shl{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001791 [(store (shl (loadi16 addr:$dst), (i8 1)), addr:$dst)]>,
1792 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001793 def SHL32m1 : I<0xD1, MRM4m, (outs), (ins i32mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001794 "shl{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001795 [(store (shl (loadi32 addr:$dst), (i8 1)), addr:$dst)]>;
1796}
1797
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001798let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00001799def SHR8rCL : I<0xD2, MRM5r, (outs GR8 :$dst), (ins GR8 :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001800 "shr{b}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001801 [(set GR8:$dst, (srl GR8:$src, CL))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001802def SHR16rCL : I<0xD3, MRM5r, (outs GR16:$dst), (ins GR16:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001803 "shr{w}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001804 [(set GR16:$dst, (srl GR16:$src, CL))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001805def SHR32rCL : I<0xD3, MRM5r, (outs GR32:$dst), (ins GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001806 "shr{l}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001807 [(set GR32:$dst, (srl GR32:$src, CL))]>;
1808}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001809
Evan Chengb783fa32007-07-19 01:14:50 +00001810def SHR8ri : Ii8<0xC0, MRM5r, (outs GR8:$dst), (ins GR8:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001811 "shr{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001812 [(set GR8:$dst, (srl GR8:$src1, (i8 imm:$src2)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001813def SHR16ri : Ii8<0xC1, MRM5r, (outs GR16:$dst), (ins GR16:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001814 "shr{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001815 [(set GR16:$dst, (srl GR16:$src1, (i8 imm:$src2)))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001816def SHR32ri : Ii8<0xC1, MRM5r, (outs GR32:$dst), (ins GR32:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001817 "shr{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001818 [(set GR32:$dst, (srl GR32:$src1, (i8 imm:$src2)))]>;
1819
1820// Shift by 1
Evan Chengb783fa32007-07-19 01:14:50 +00001821def SHR8r1 : I<0xD0, MRM5r, (outs GR8:$dst), (ins GR8:$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00001822 "shr{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001823 [(set GR8:$dst, (srl GR8:$src1, (i8 1)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001824def SHR16r1 : I<0xD1, MRM5r, (outs GR16:$dst), (ins GR16:$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00001825 "shr{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001826 [(set GR16:$dst, (srl GR16:$src1, (i8 1)))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001827def SHR32r1 : I<0xD1, MRM5r, (outs GR32:$dst), (ins GR32:$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00001828 "shr{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001829 [(set GR32:$dst, (srl GR32:$src1, (i8 1)))]>;
1830
1831let isTwoAddress = 0 in {
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001832 let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00001833 def SHR8mCL : I<0xD2, MRM5m, (outs), (ins i8mem :$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001834 "shr{b}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001835 [(store (srl (loadi8 addr:$dst), CL), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001836 def SHR16mCL : I<0xD3, MRM5m, (outs), (ins i16mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001837 "shr{w}\t{%cl, $dst|$dst, %CL}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001838 [(store (srl (loadi16 addr:$dst), CL), addr:$dst)]>,
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001839 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001840 def SHR32mCL : I<0xD3, MRM5m, (outs), (ins i32mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001841 "shr{l}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001842 [(store (srl (loadi32 addr:$dst), CL), addr:$dst)]>;
1843 }
Evan Chengb783fa32007-07-19 01:14:50 +00001844 def SHR8mi : Ii8<0xC0, MRM5m, (outs), (ins i8mem :$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001845 "shr{b}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001846 [(store (srl (loadi8 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001847 def SHR16mi : Ii8<0xC1, MRM5m, (outs), (ins i16mem:$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001848 "shr{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001849 [(store (srl (loadi16 addr:$dst), (i8 imm:$src)), addr:$dst)]>,
1850 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001851 def SHR32mi : Ii8<0xC1, MRM5m, (outs), (ins i32mem:$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001852 "shr{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001853 [(store (srl (loadi32 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
1854
1855 // Shift by 1
Evan Chengb783fa32007-07-19 01:14:50 +00001856 def SHR8m1 : I<0xD0, MRM5m, (outs), (ins i8mem :$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001857 "shr{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001858 [(store (srl (loadi8 addr:$dst), (i8 1)), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001859 def SHR16m1 : I<0xD1, MRM5m, (outs), (ins i16mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001860 "shr{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001861 [(store (srl (loadi16 addr:$dst), (i8 1)), addr:$dst)]>,OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001862 def SHR32m1 : I<0xD1, MRM5m, (outs), (ins i32mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001863 "shr{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001864 [(store (srl (loadi32 addr:$dst), (i8 1)), addr:$dst)]>;
1865}
1866
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001867let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00001868def SAR8rCL : I<0xD2, MRM7r, (outs GR8 :$dst), (ins GR8 :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001869 "sar{b}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001870 [(set GR8:$dst, (sra GR8:$src, CL))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001871def SAR16rCL : I<0xD3, MRM7r, (outs GR16:$dst), (ins GR16:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001872 "sar{w}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001873 [(set GR16:$dst, (sra GR16:$src, CL))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001874def SAR32rCL : I<0xD3, MRM7r, (outs GR32:$dst), (ins GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001875 "sar{l}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001876 [(set GR32:$dst, (sra GR32:$src, CL))]>;
1877}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001878
Evan Chengb783fa32007-07-19 01:14:50 +00001879def SAR8ri : Ii8<0xC0, MRM7r, (outs GR8 :$dst), (ins GR8 :$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001880 "sar{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001881 [(set GR8:$dst, (sra GR8:$src1, (i8 imm:$src2)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001882def SAR16ri : Ii8<0xC1, MRM7r, (outs GR16:$dst), (ins GR16:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001883 "sar{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001884 [(set GR16:$dst, (sra GR16:$src1, (i8 imm:$src2)))]>,
1885 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001886def SAR32ri : Ii8<0xC1, MRM7r, (outs GR32:$dst), (ins GR32:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001887 "sar{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001888 [(set GR32:$dst, (sra GR32:$src1, (i8 imm:$src2)))]>;
1889
1890// Shift by 1
Evan Chengb783fa32007-07-19 01:14:50 +00001891def SAR8r1 : I<0xD0, MRM7r, (outs GR8 :$dst), (ins GR8 :$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00001892 "sar{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001893 [(set GR8:$dst, (sra GR8:$src1, (i8 1)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001894def SAR16r1 : I<0xD1, MRM7r, (outs GR16:$dst), (ins GR16:$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00001895 "sar{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001896 [(set GR16:$dst, (sra GR16:$src1, (i8 1)))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001897def SAR32r1 : I<0xD1, MRM7r, (outs GR32:$dst), (ins GR32:$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00001898 "sar{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001899 [(set GR32:$dst, (sra GR32:$src1, (i8 1)))]>;
1900
1901let isTwoAddress = 0 in {
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001902 let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00001903 def SAR8mCL : I<0xD2, MRM7m, (outs), (ins i8mem :$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001904 "sar{b}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001905 [(store (sra (loadi8 addr:$dst), CL), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001906 def SAR16mCL : I<0xD3, MRM7m, (outs), (ins i16mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001907 "sar{w}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001908 [(store (sra (loadi16 addr:$dst), CL), addr:$dst)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001909 def SAR32mCL : I<0xD3, MRM7m, (outs), (ins i32mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001910 "sar{l}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001911 [(store (sra (loadi32 addr:$dst), CL), addr:$dst)]>;
1912 }
Evan Chengb783fa32007-07-19 01:14:50 +00001913 def SAR8mi : Ii8<0xC0, MRM7m, (outs), (ins i8mem :$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001914 "sar{b}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001915 [(store (sra (loadi8 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001916 def SAR16mi : Ii8<0xC1, MRM7m, (outs), (ins i16mem:$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001917 "sar{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001918 [(store (sra (loadi16 addr:$dst), (i8 imm:$src)), addr:$dst)]>,
1919 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001920 def SAR32mi : Ii8<0xC1, MRM7m, (outs), (ins i32mem:$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001921 "sar{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001922 [(store (sra (loadi32 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
1923
1924 // Shift by 1
Evan Chengb783fa32007-07-19 01:14:50 +00001925 def SAR8m1 : I<0xD0, MRM7m, (outs), (ins i8mem :$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001926 "sar{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001927 [(store (sra (loadi8 addr:$dst), (i8 1)), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001928 def SAR16m1 : I<0xD1, MRM7m, (outs), (ins i16mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001929 "sar{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001930 [(store (sra (loadi16 addr:$dst), (i8 1)), addr:$dst)]>,
1931 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001932 def SAR32m1 : I<0xD1, MRM7m, (outs), (ins i32mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001933 "sar{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001934 [(store (sra (loadi32 addr:$dst), (i8 1)), addr:$dst)]>;
1935}
1936
1937// Rotate instructions
1938// FIXME: provide shorter instructions when imm8 == 1
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001939let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00001940def ROL8rCL : I<0xD2, MRM0r, (outs GR8 :$dst), (ins GR8 :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001941 "rol{b}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001942 [(set GR8:$dst, (rotl GR8:$src, CL))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001943def ROL16rCL : I<0xD3, MRM0r, (outs GR16:$dst), (ins GR16:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001944 "rol{w}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001945 [(set GR16:$dst, (rotl GR16:$src, CL))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001946def ROL32rCL : I<0xD3, MRM0r, (outs GR32:$dst), (ins GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001947 "rol{l}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001948 [(set GR32:$dst, (rotl GR32:$src, CL))]>;
1949}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001950
Evan Chengb783fa32007-07-19 01:14:50 +00001951def ROL8ri : Ii8<0xC0, MRM0r, (outs GR8 :$dst), (ins GR8 :$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001952 "rol{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001953 [(set GR8:$dst, (rotl GR8:$src1, (i8 imm:$src2)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001954def ROL16ri : Ii8<0xC1, MRM0r, (outs GR16:$dst), (ins GR16:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001955 "rol{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001956 [(set GR16:$dst, (rotl GR16:$src1, (i8 imm:$src2)))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001957def ROL32ri : Ii8<0xC1, MRM0r, (outs GR32:$dst), (ins GR32:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001958 "rol{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001959 [(set GR32:$dst, (rotl GR32:$src1, (i8 imm:$src2)))]>;
1960
1961// Rotate by 1
Evan Chengb783fa32007-07-19 01:14:50 +00001962def ROL8r1 : I<0xD0, MRM0r, (outs GR8 :$dst), (ins GR8 :$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00001963 "rol{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001964 [(set GR8:$dst, (rotl GR8:$src1, (i8 1)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001965def ROL16r1 : I<0xD1, MRM0r, (outs GR16:$dst), (ins GR16:$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00001966 "rol{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001967 [(set GR16:$dst, (rotl GR16:$src1, (i8 1)))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001968def ROL32r1 : I<0xD1, MRM0r, (outs GR32:$dst), (ins GR32:$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00001969 "rol{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001970 [(set GR32:$dst, (rotl GR32:$src1, (i8 1)))]>;
1971
1972let isTwoAddress = 0 in {
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001973 let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00001974 def ROL8mCL : I<0xD2, MRM0m, (outs), (ins i8mem :$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001975 "rol{b}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001976 [(store (rotl (loadi8 addr:$dst), CL), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001977 def ROL16mCL : I<0xD3, MRM0m, (outs), (ins i16mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001978 "rol{w}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001979 [(store (rotl (loadi16 addr:$dst), CL), addr:$dst)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001980 def ROL32mCL : I<0xD3, MRM0m, (outs), (ins i32mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001981 "rol{l}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001982 [(store (rotl (loadi32 addr:$dst), CL), addr:$dst)]>;
1983 }
Evan Chengb783fa32007-07-19 01:14:50 +00001984 def ROL8mi : Ii8<0xC0, MRM0m, (outs), (ins i8mem :$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001985 "rol{b}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001986 [(store (rotl (loadi8 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001987 def ROL16mi : Ii8<0xC1, MRM0m, (outs), (ins i16mem:$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001988 "rol{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001989 [(store (rotl (loadi16 addr:$dst), (i8 imm:$src)), addr:$dst)]>,
1990 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001991 def ROL32mi : Ii8<0xC1, MRM0m, (outs), (ins i32mem:$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001992 "rol{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001993 [(store (rotl (loadi32 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
1994
1995 // Rotate by 1
Evan Chengb783fa32007-07-19 01:14:50 +00001996 def ROL8m1 : I<0xD0, MRM0m, (outs), (ins i8mem :$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001997 "rol{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001998 [(store (rotl (loadi8 addr:$dst), (i8 1)), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001999 def ROL16m1 : I<0xD1, MRM0m, (outs), (ins i16mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002000 "rol{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002001 [(store (rotl (loadi16 addr:$dst), (i8 1)), addr:$dst)]>,
2002 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002003 def ROL32m1 : I<0xD1, MRM0m, (outs), (ins i32mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002004 "rol{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002005 [(store (rotl (loadi32 addr:$dst), (i8 1)), addr:$dst)]>;
2006}
2007
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002008let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00002009def ROR8rCL : I<0xD2, MRM1r, (outs GR8 :$dst), (ins GR8 :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002010 "ror{b}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002011 [(set GR8:$dst, (rotr GR8:$src, CL))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002012def ROR16rCL : I<0xD3, MRM1r, (outs GR16:$dst), (ins GR16:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002013 "ror{w}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002014 [(set GR16:$dst, (rotr GR16:$src, CL))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002015def ROR32rCL : I<0xD3, MRM1r, (outs GR32:$dst), (ins GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002016 "ror{l}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002017 [(set GR32:$dst, (rotr GR32:$src, CL))]>;
2018}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002019
Evan Chengb783fa32007-07-19 01:14:50 +00002020def ROR8ri : Ii8<0xC0, MRM1r, (outs GR8 :$dst), (ins GR8 :$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002021 "ror{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002022 [(set GR8:$dst, (rotr GR8:$src1, (i8 imm:$src2)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002023def ROR16ri : Ii8<0xC1, MRM1r, (outs GR16:$dst), (ins GR16:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002024 "ror{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002025 [(set GR16:$dst, (rotr GR16:$src1, (i8 imm:$src2)))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002026def ROR32ri : Ii8<0xC1, MRM1r, (outs GR32:$dst), (ins GR32:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002027 "ror{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002028 [(set GR32:$dst, (rotr GR32:$src1, (i8 imm:$src2)))]>;
2029
2030// Rotate by 1
Evan Chengb783fa32007-07-19 01:14:50 +00002031def ROR8r1 : I<0xD0, MRM1r, (outs GR8 :$dst), (ins GR8 :$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00002032 "ror{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002033 [(set GR8:$dst, (rotr GR8:$src1, (i8 1)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002034def ROR16r1 : I<0xD1, MRM1r, (outs GR16:$dst), (ins GR16:$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00002035 "ror{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002036 [(set GR16:$dst, (rotr GR16:$src1, (i8 1)))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002037def ROR32r1 : I<0xD1, MRM1r, (outs GR32:$dst), (ins GR32:$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00002038 "ror{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002039 [(set GR32:$dst, (rotr GR32:$src1, (i8 1)))]>;
2040
2041let isTwoAddress = 0 in {
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002042 let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00002043 def ROR8mCL : I<0xD2, MRM1m, (outs), (ins i8mem :$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002044 "ror{b}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002045 [(store (rotr (loadi8 addr:$dst), CL), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002046 def ROR16mCL : I<0xD3, MRM1m, (outs), (ins i16mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002047 "ror{w}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002048 [(store (rotr (loadi16 addr:$dst), CL), addr:$dst)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002049 def ROR32mCL : I<0xD3, MRM1m, (outs), (ins i32mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002050 "ror{l}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002051 [(store (rotr (loadi32 addr:$dst), CL), addr:$dst)]>;
2052 }
Evan Chengb783fa32007-07-19 01:14:50 +00002053 def ROR8mi : Ii8<0xC0, MRM1m, (outs), (ins i8mem :$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002054 "ror{b}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002055 [(store (rotr (loadi8 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002056 def ROR16mi : Ii8<0xC1, MRM1m, (outs), (ins i16mem:$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002057 "ror{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002058 [(store (rotr (loadi16 addr:$dst), (i8 imm:$src)), addr:$dst)]>,
2059 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002060 def ROR32mi : Ii8<0xC1, MRM1m, (outs), (ins i32mem:$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002061 "ror{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002062 [(store (rotr (loadi32 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
2063
2064 // Rotate by 1
Evan Chengb783fa32007-07-19 01:14:50 +00002065 def ROR8m1 : I<0xD0, MRM1m, (outs), (ins i8mem :$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002066 "ror{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002067 [(store (rotr (loadi8 addr:$dst), (i8 1)), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002068 def ROR16m1 : I<0xD1, MRM1m, (outs), (ins i16mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002069 "ror{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002070 [(store (rotr (loadi16 addr:$dst), (i8 1)), addr:$dst)]>,
2071 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002072 def ROR32m1 : I<0xD1, MRM1m, (outs), (ins i32mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002073 "ror{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002074 [(store (rotr (loadi32 addr:$dst), (i8 1)), addr:$dst)]>;
2075}
2076
2077
2078
2079// Double shift instructions (generalizations of rotate)
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002080let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00002081def SHLD32rrCL : I<0xA5, MRMDestReg, (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002082 "shld{l}\t{%cl, $src2, $dst|$dst, $src2, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002083 [(set GR32:$dst, (X86shld GR32:$src1, GR32:$src2, CL))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00002084def SHRD32rrCL : I<0xAD, MRMDestReg, (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002085 "shrd{l}\t{%cl, $src2, $dst|$dst, $src2, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002086 [(set GR32:$dst, (X86shrd GR32:$src1, GR32:$src2, CL))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00002087def SHLD16rrCL : I<0xA5, MRMDestReg, (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002088 "shld{w}\t{%cl, $src2, $dst|$dst, $src2, %CL}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002089 [(set GR16:$dst, (X86shld GR16:$src1, GR16:$src2, CL))]>,
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002090 TB, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002091def SHRD16rrCL : I<0xAD, MRMDestReg, (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002092 "shrd{w}\t{%cl, $src2, $dst|$dst, $src2, %CL}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002093 [(set GR16:$dst, (X86shrd GR16:$src1, GR16:$src2, CL))]>,
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002094 TB, OpSize;
2095}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002096
2097let isCommutable = 1 in { // These instructions commute to each other.
2098def SHLD32rri8 : Ii8<0xA4, MRMDestReg,
Evan Chengb783fa32007-07-19 01:14:50 +00002099 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2, i8imm:$src3),
Dan Gohman91888f02007-07-31 20:11:57 +00002100 "shld{l}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002101 [(set GR32:$dst, (X86shld GR32:$src1, GR32:$src2,
2102 (i8 imm:$src3)))]>,
2103 TB;
2104def SHRD32rri8 : Ii8<0xAC, MRMDestReg,
Evan Chengb783fa32007-07-19 01:14:50 +00002105 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2, i8imm:$src3),
Dan Gohman91888f02007-07-31 20:11:57 +00002106 "shrd{l}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002107 [(set GR32:$dst, (X86shrd GR32:$src1, GR32:$src2,
2108 (i8 imm:$src3)))]>,
2109 TB;
2110def SHLD16rri8 : Ii8<0xA4, MRMDestReg,
Evan Chengb783fa32007-07-19 01:14:50 +00002111 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2, i8imm:$src3),
Dan Gohman91888f02007-07-31 20:11:57 +00002112 "shld{w}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002113 [(set GR16:$dst, (X86shld GR16:$src1, GR16:$src2,
2114 (i8 imm:$src3)))]>,
2115 TB, OpSize;
2116def SHRD16rri8 : Ii8<0xAC, MRMDestReg,
Evan Chengb783fa32007-07-19 01:14:50 +00002117 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2, i8imm:$src3),
Dan Gohman91888f02007-07-31 20:11:57 +00002118 "shrd{w}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002119 [(set GR16:$dst, (X86shrd GR16:$src1, GR16:$src2,
2120 (i8 imm:$src3)))]>,
2121 TB, OpSize;
2122}
2123
2124let isTwoAddress = 0 in {
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002125 let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00002126 def SHLD32mrCL : I<0xA5, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002127 "shld{l}\t{%cl, $src2, $dst|$dst, $src2, %CL}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002128 [(store (X86shld (loadi32 addr:$dst), GR32:$src2, CL),
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002129 addr:$dst)]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00002130 def SHRD32mrCL : I<0xAD, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002131 "shrd{l}\t{%cl, $src2, $dst|$dst, $src2, %CL}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002132 [(store (X86shrd (loadi32 addr:$dst), GR32:$src2, CL),
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002133 addr:$dst)]>, TB;
2134 }
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002135 def SHLD32mri8 : Ii8<0xA4, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00002136 (outs), (ins i32mem:$dst, GR32:$src2, i8imm:$src3),
Dan Gohman91888f02007-07-31 20:11:57 +00002137 "shld{l}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002138 [(store (X86shld (loadi32 addr:$dst), GR32:$src2,
2139 (i8 imm:$src3)), addr:$dst)]>,
2140 TB;
2141 def SHRD32mri8 : Ii8<0xAC, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00002142 (outs), (ins i32mem:$dst, GR32:$src2, i8imm:$src3),
Dan Gohman91888f02007-07-31 20:11:57 +00002143 "shrd{l}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002144 [(store (X86shrd (loadi32 addr:$dst), GR32:$src2,
2145 (i8 imm:$src3)), addr:$dst)]>,
2146 TB;
2147
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002148 let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00002149 def SHLD16mrCL : I<0xA5, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002150 "shld{w}\t{%cl, $src2, $dst|$dst, $src2, %CL}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002151 [(store (X86shld (loadi16 addr:$dst), GR16:$src2, CL),
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002152 addr:$dst)]>, TB, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002153 def SHRD16mrCL : I<0xAD, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002154 "shrd{w}\t{%cl, $src2, $dst|$dst, $src2, %CL}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002155 [(store (X86shrd (loadi16 addr:$dst), GR16:$src2, CL),
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002156 addr:$dst)]>, TB, OpSize;
2157 }
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002158 def SHLD16mri8 : Ii8<0xA4, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00002159 (outs), (ins i16mem:$dst, GR16:$src2, i8imm:$src3),
Dan Gohman91888f02007-07-31 20:11:57 +00002160 "shld{w}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002161 [(store (X86shld (loadi16 addr:$dst), GR16:$src2,
2162 (i8 imm:$src3)), addr:$dst)]>,
2163 TB, OpSize;
2164 def SHRD16mri8 : Ii8<0xAC, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00002165 (outs), (ins i16mem:$dst, GR16:$src2, i8imm:$src3),
Dan Gohman91888f02007-07-31 20:11:57 +00002166 "shrd{w}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002167 [(store (X86shrd (loadi16 addr:$dst), GR16:$src2,
2168 (i8 imm:$src3)), addr:$dst)]>,
2169 TB, OpSize;
2170}
Evan Cheng55687072007-09-14 21:48:26 +00002171} // Defs = [EFLAGS]
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002172
2173
2174// Arithmetic.
Evan Cheng55687072007-09-14 21:48:26 +00002175let Defs = [EFLAGS] in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002176let isCommutable = 1 in { // X = ADD Y, Z --> X = ADD Z, Y
Bill Wendlingae034ed2008-12-12 00:56:36 +00002177// Register-Register Addition
2178def ADD8rr : I<0x00, MRMDestReg, (outs GR8 :$dst),
2179 (ins GR8 :$src1, GR8 :$src2),
2180 "add{b}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002181 [(set GR8:$dst, (add GR8:$src1, GR8:$src2)),
Bill Wendlingae034ed2008-12-12 00:56:36 +00002182 (implicit EFLAGS)]>;
2183
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002184let isConvertibleToThreeAddress = 1 in { // Can transform into LEA.
Bill Wendlingae034ed2008-12-12 00:56:36 +00002185// Register-Register Addition
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002186def ADD16rr : I<0x01, MRMDestReg, (outs GR16:$dst),
2187 (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002188 "add{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002189 [(set GR16:$dst, (add GR16:$src1, GR16:$src2)),
2190 (implicit EFLAGS)]>, OpSize;
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002191def ADD32rr : I<0x01, MRMDestReg, (outs GR32:$dst),
2192 (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002193 "add{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002194 [(set GR32:$dst, (add GR32:$src1, GR32:$src2)),
2195 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002196} // end isConvertibleToThreeAddress
2197} // end isCommutable
Bill Wendlingae034ed2008-12-12 00:56:36 +00002198
2199// Register-Memory Addition
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002200def ADD8rm : I<0x02, MRMSrcMem, (outs GR8 :$dst),
2201 (ins GR8 :$src1, i8mem :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002202 "add{b}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002203 [(set GR8:$dst, (add GR8:$src1, (load addr:$src2))),
2204 (implicit EFLAGS)]>;
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002205def ADD16rm : I<0x03, MRMSrcMem, (outs GR16:$dst),
2206 (ins GR16:$src1, i16mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002207 "add{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002208 [(set GR16:$dst, (add GR16:$src1, (load addr:$src2))),
2209 (implicit EFLAGS)]>, OpSize;
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002210def ADD32rm : I<0x03, MRMSrcMem, (outs GR32:$dst),
2211 (ins GR32:$src1, i32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002212 "add{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002213 [(set GR32:$dst, (add GR32:$src1, (load addr:$src2))),
2214 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002215
Bill Wendlingae034ed2008-12-12 00:56:36 +00002216// Register-Integer Addition
2217def ADD8ri : Ii8<0x80, MRM0r, (outs GR8:$dst), (ins GR8:$src1, i8imm:$src2),
2218 "add{b}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002219 [(set GR8:$dst, (add GR8:$src1, imm:$src2)),
2220 (implicit EFLAGS)]>;
Bill Wendlingae034ed2008-12-12 00:56:36 +00002221
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002222let isConvertibleToThreeAddress = 1 in { // Can transform into LEA.
Bill Wendlingae034ed2008-12-12 00:56:36 +00002223// Register-Integer Addition
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002224def ADD16ri : Ii16<0x81, MRM0r, (outs GR16:$dst),
2225 (ins GR16:$src1, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002226 "add{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002227 [(set GR16:$dst, (add GR16:$src1, imm:$src2)),
2228 (implicit EFLAGS)]>, OpSize;
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002229def ADD32ri : Ii32<0x81, MRM0r, (outs GR32:$dst),
2230 (ins GR32:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002231 "add{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002232 [(set GR32:$dst, (add GR32:$src1, imm:$src2)),
2233 (implicit EFLAGS)]>;
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002234def ADD16ri8 : Ii8<0x83, MRM0r, (outs GR16:$dst),
2235 (ins GR16:$src1, i16i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002236 "add{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002237 [(set GR16:$dst, (add GR16:$src1, i16immSExt8:$src2)),
2238 (implicit EFLAGS)]>, OpSize;
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002239def ADD32ri8 : Ii8<0x83, MRM0r, (outs GR32:$dst),
2240 (ins GR32:$src1, i32i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002241 "add{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002242 [(set GR32:$dst, (add GR32:$src1, i32immSExt8:$src2)),
2243 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002244}
2245
2246let isTwoAddress = 0 in {
Bill Wendlingae034ed2008-12-12 00:56:36 +00002247 // Memory-Register Addition
Bill Wendlingf5399032008-12-12 21:15:41 +00002248 def ADD8mr : I<0x00, MRMDestMem, (outs), (ins i8mem:$dst, GR8:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002249 "add{b}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002250 [(store (add (load addr:$dst), GR8:$src2), addr:$dst),
2251 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002252 def ADD16mr : I<0x01, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002253 "add{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002254 [(store (add (load addr:$dst), GR16:$src2), addr:$dst),
2255 (implicit EFLAGS)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002256 def ADD32mr : I<0x01, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002257 "add{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002258 [(store (add (load addr:$dst), GR32:$src2), addr:$dst),
2259 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002260 def ADD8mi : Ii8<0x80, MRM0m, (outs), (ins i8mem :$dst, i8imm :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002261 "add{b}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002262 [(store (add (loadi8 addr:$dst), imm:$src2), addr:$dst),
2263 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002264 def ADD16mi : Ii16<0x81, MRM0m, (outs), (ins i16mem:$dst, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002265 "add{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002266 [(store (add (loadi16 addr:$dst), imm:$src2), addr:$dst),
2267 (implicit EFLAGS)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002268 def ADD32mi : Ii32<0x81, MRM0m, (outs), (ins i32mem:$dst, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002269 "add{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002270 [(store (add (loadi32 addr:$dst), imm:$src2), addr:$dst),
2271 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002272 def ADD16mi8 : Ii8<0x83, MRM0m, (outs), (ins i16mem:$dst, i16i8imm :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002273 "add{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002274 [(store (add (load addr:$dst), i16immSExt8:$src2),
2275 addr:$dst),
2276 (implicit EFLAGS)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002277 def ADD32mi8 : Ii8<0x83, MRM0m, (outs), (ins i32mem:$dst, i32i8imm :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002278 "add{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingae034ed2008-12-12 00:56:36 +00002279 [(store (add (load addr:$dst), i32immSExt8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00002280 addr:$dst),
2281 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002282}
2283
Evan Cheng259471d2007-10-05 17:59:57 +00002284let Uses = [EFLAGS] in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002285let isCommutable = 1 in { // X = ADC Y, Z --> X = ADC Z, Y
Dale Johannesen747fe522009-06-02 03:12:52 +00002286def ADC8rr : I<0x10, MRMDestReg, (outs GR8:$dst), (ins GR8:$src1, GR8:$src2),
Dale Johannesen06b83f12009-05-18 17:44:15 +00002287 "adc{b}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002288 [(set GR8:$dst, (adde GR8:$src1, GR8:$src2))]>;
Dale Johannesen06b83f12009-05-18 17:44:15 +00002289def ADC16rr : I<0x11, MRMDestReg, (outs GR16:$dst),
2290 (ins GR16:$src1, GR16:$src2),
2291 "adc{w}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002292 [(set GR16:$dst, (adde GR16:$src1, GR16:$src2))]>, OpSize;
Dale Johannesen06b83f12009-05-18 17:44:15 +00002293def ADC32rr : I<0x11, MRMDestReg, (outs GR32:$dst),
2294 (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002295 "adc{l}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002296 [(set GR32:$dst, (adde GR32:$src1, GR32:$src2))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002297}
Dale Johannesen06b83f12009-05-18 17:44:15 +00002298def ADC8rm : I<0x12, MRMSrcMem , (outs GR8:$dst),
2299 (ins GR8:$src1, i8mem:$src2),
2300 "adc{b}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002301 [(set GR8:$dst, (adde GR8:$src1, (load addr:$src2)))]>;
Dale Johannesen06b83f12009-05-18 17:44:15 +00002302def ADC16rm : I<0x13, MRMSrcMem , (outs GR16:$dst),
2303 (ins GR16:$src1, i16mem:$src2),
2304 "adc{w}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002305 [(set GR16:$dst, (adde GR16:$src1, (load addr:$src2)))]>,
Dale Johannesen067cfb22009-05-18 21:41:59 +00002306 OpSize;
Dale Johannesen06b83f12009-05-18 17:44:15 +00002307def ADC32rm : I<0x13, MRMSrcMem , (outs GR32:$dst),
2308 (ins GR32:$src1, i32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002309 "adc{l}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002310 [(set GR32:$dst, (adde GR32:$src1, (load addr:$src2)))]>;
2311def ADC8ri : Ii8<0x80, MRM2r, (outs GR8:$dst), (ins GR8:$src1, i8imm:$src2),
Dale Johannesen06b83f12009-05-18 17:44:15 +00002312 "adc{b}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002313 [(set GR8:$dst, (adde GR8:$src1, imm:$src2))]>;
Dale Johannesen06b83f12009-05-18 17:44:15 +00002314def ADC16ri : Ii16<0x81, MRM2r, (outs GR16:$dst),
2315 (ins GR16:$src1, i16imm:$src2),
2316 "adc{w}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002317 [(set GR16:$dst, (adde GR16:$src1, imm:$src2))]>, OpSize;
Dale Johannesen06b83f12009-05-18 17:44:15 +00002318def ADC16ri8 : Ii8<0x83, MRM2r, (outs GR16:$dst),
2319 (ins GR16:$src1, i16i8imm:$src2),
2320 "adc{w}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002321 [(set GR16:$dst, (adde GR16:$src1, i16immSExt8:$src2))]>,
2322 OpSize;
Dale Johannesen06b83f12009-05-18 17:44:15 +00002323def ADC32ri : Ii32<0x81, MRM2r, (outs GR32:$dst),
2324 (ins GR32:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002325 "adc{l}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002326 [(set GR32:$dst, (adde GR32:$src1, imm:$src2))]>;
Dale Johannesen06b83f12009-05-18 17:44:15 +00002327def ADC32ri8 : Ii8<0x83, MRM2r, (outs GR32:$dst),
2328 (ins GR32:$src1, i32i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002329 "adc{l}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002330 [(set GR32:$dst, (adde GR32:$src1, i32immSExt8:$src2))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002331
2332let isTwoAddress = 0 in {
Dale Johannesen747fe522009-06-02 03:12:52 +00002333 def ADC8mr : I<0x10, MRMDestMem, (outs), (ins i8mem:$dst, GR8:$src2),
Dale Johannesen06b83f12009-05-18 17:44:15 +00002334 "adc{b}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002335 [(store (adde (load addr:$dst), GR8:$src2), addr:$dst)]>;
2336 def ADC16mr : I<0x11, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
Dale Johannesen06b83f12009-05-18 17:44:15 +00002337 "adc{w}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002338 [(store (adde (load addr:$dst), GR16:$src2), addr:$dst)]>,
2339 OpSize;
2340 def ADC32mr : I<0x11, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002341 "adc{l}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002342 [(store (adde (load addr:$dst), GR32:$src2), addr:$dst)]>;
2343 def ADC8mi : Ii8<0x80, MRM2m, (outs), (ins i8mem:$dst, i8imm:$src2),
Dale Johannesen06b83f12009-05-18 17:44:15 +00002344 "adc{b}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002345 [(store (adde (loadi8 addr:$dst), imm:$src2), addr:$dst)]>;
2346 def ADC16mi : Ii16<0x81, MRM2m, (outs), (ins i16mem:$dst, i16imm:$src2),
Dale Johannesen06b83f12009-05-18 17:44:15 +00002347 "adc{w}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002348 [(store (adde (loadi16 addr:$dst), imm:$src2), addr:$dst)]>,
2349 OpSize;
2350 def ADC16mi8 : Ii8<0x83, MRM2m, (outs), (ins i16mem:$dst, i16i8imm :$src2),
Dale Johannesen06b83f12009-05-18 17:44:15 +00002351 "adc{w}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002352 [(store (adde (load addr:$dst), i16immSExt8:$src2), addr:$dst)]>,
2353 OpSize;
2354 def ADC32mi : Ii32<0x81, MRM2m, (outs), (ins i32mem:$dst, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002355 "adc{l}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002356 [(store (adde (loadi32 addr:$dst), imm:$src2), addr:$dst)]>;
2357 def ADC32mi8 : Ii8<0x83, MRM2m, (outs), (ins i32mem:$dst, i32i8imm :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002358 "adc{l}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002359 [(store (adde (load addr:$dst), i32immSExt8:$src2), addr:$dst)]>;
2360}
Evan Cheng259471d2007-10-05 17:59:57 +00002361} // Uses = [EFLAGS]
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002362
Bill Wendlingae034ed2008-12-12 00:56:36 +00002363// Register-Register Subtraction
2364def SUB8rr : I<0x28, MRMDestReg, (outs GR8:$dst), (ins GR8:$src1, GR8:$src2),
2365 "sub{b}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002366 [(set GR8:$dst, (sub GR8:$src1, GR8:$src2)),
2367 (implicit EFLAGS)]>;
Bill Wendlingae034ed2008-12-12 00:56:36 +00002368def SUB16rr : I<0x29, MRMDestReg, (outs GR16:$dst), (ins GR16:$src1,GR16:$src2),
2369 "sub{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002370 [(set GR16:$dst, (sub GR16:$src1, GR16:$src2)),
2371 (implicit EFLAGS)]>, OpSize;
Bill Wendlingae034ed2008-12-12 00:56:36 +00002372def SUB32rr : I<0x29, MRMDestReg, (outs GR32:$dst), (ins GR32:$src1,GR32:$src2),
2373 "sub{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002374 [(set GR32:$dst, (sub GR32:$src1, GR32:$src2)),
2375 (implicit EFLAGS)]>;
Bill Wendlingae034ed2008-12-12 00:56:36 +00002376
2377// Register-Memory Subtraction
2378def SUB8rm : I<0x2A, MRMSrcMem, (outs GR8 :$dst),
2379 (ins GR8 :$src1, i8mem :$src2),
2380 "sub{b}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002381 [(set GR8:$dst, (sub GR8:$src1, (load addr:$src2))),
2382 (implicit EFLAGS)]>;
Bill Wendlingae034ed2008-12-12 00:56:36 +00002383def SUB16rm : I<0x2B, MRMSrcMem, (outs GR16:$dst),
2384 (ins GR16:$src1, i16mem:$src2),
2385 "sub{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002386 [(set GR16:$dst, (sub GR16:$src1, (load addr:$src2))),
2387 (implicit EFLAGS)]>, OpSize;
Bill Wendlingae034ed2008-12-12 00:56:36 +00002388def SUB32rm : I<0x2B, MRMSrcMem, (outs GR32:$dst),
2389 (ins GR32:$src1, i32mem:$src2),
2390 "sub{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002391 [(set GR32:$dst, (sub GR32:$src1, (load addr:$src2))),
2392 (implicit EFLAGS)]>;
Bill Wendlingae034ed2008-12-12 00:56:36 +00002393
2394// Register-Integer Subtraction
2395def SUB8ri : Ii8 <0x80, MRM5r, (outs GR8:$dst),
2396 (ins GR8:$src1, i8imm:$src2),
2397 "sub{b}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002398 [(set GR8:$dst, (sub GR8:$src1, imm:$src2)),
2399 (implicit EFLAGS)]>;
Bill Wendlingae034ed2008-12-12 00:56:36 +00002400def SUB16ri : Ii16<0x81, MRM5r, (outs GR16:$dst),
2401 (ins GR16:$src1, i16imm:$src2),
2402 "sub{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002403 [(set GR16:$dst, (sub GR16:$src1, imm:$src2)),
2404 (implicit EFLAGS)]>, OpSize;
Bill Wendlingae034ed2008-12-12 00:56:36 +00002405def SUB32ri : Ii32<0x81, MRM5r, (outs GR32:$dst),
2406 (ins GR32:$src1, i32imm:$src2),
2407 "sub{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002408 [(set GR32:$dst, (sub GR32:$src1, imm:$src2)),
2409 (implicit EFLAGS)]>;
Bill Wendlingae034ed2008-12-12 00:56:36 +00002410def SUB16ri8 : Ii8<0x83, MRM5r, (outs GR16:$dst),
2411 (ins GR16:$src1, i16i8imm:$src2),
2412 "sub{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002413 [(set GR16:$dst, (sub GR16:$src1, i16immSExt8:$src2)),
2414 (implicit EFLAGS)]>, OpSize;
Bill Wendlingae034ed2008-12-12 00:56:36 +00002415def SUB32ri8 : Ii8<0x83, MRM5r, (outs GR32:$dst),
2416 (ins GR32:$src1, i32i8imm:$src2),
2417 "sub{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002418 [(set GR32:$dst, (sub GR32:$src1, i32immSExt8:$src2)),
2419 (implicit EFLAGS)]>;
Bill Wendlingae034ed2008-12-12 00:56:36 +00002420
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002421let isTwoAddress = 0 in {
Bill Wendlingae034ed2008-12-12 00:56:36 +00002422 // Memory-Register Subtraction
Evan Chengb783fa32007-07-19 01:14:50 +00002423 def SUB8mr : I<0x28, MRMDestMem, (outs), (ins i8mem :$dst, GR8 :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002424 "sub{b}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002425 [(store (sub (load addr:$dst), GR8:$src2), addr:$dst),
2426 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002427 def SUB16mr : I<0x29, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002428 "sub{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002429 [(store (sub (load addr:$dst), GR16:$src2), addr:$dst),
2430 (implicit EFLAGS)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002431 def SUB32mr : I<0x29, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002432 "sub{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002433 [(store (sub (load addr:$dst), GR32:$src2), addr:$dst),
2434 (implicit EFLAGS)]>;
Bill Wendlingae034ed2008-12-12 00:56:36 +00002435
2436 // Memory-Integer Subtraction
Evan Chengb783fa32007-07-19 01:14:50 +00002437 def SUB8mi : Ii8<0x80, MRM5m, (outs), (ins i8mem :$dst, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002438 "sub{b}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002439 [(store (sub (loadi8 addr:$dst), imm:$src2), addr:$dst),
2440 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002441 def SUB16mi : Ii16<0x81, MRM5m, (outs), (ins i16mem:$dst, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002442 "sub{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002443 [(store (sub (loadi16 addr:$dst), imm:$src2),addr:$dst),
2444 (implicit EFLAGS)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002445 def SUB32mi : Ii32<0x81, MRM5m, (outs), (ins i32mem:$dst, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002446 "sub{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002447 [(store (sub (loadi32 addr:$dst), imm:$src2),addr:$dst),
2448 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002449 def SUB16mi8 : Ii8<0x83, MRM5m, (outs), (ins i16mem:$dst, i16i8imm :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002450 "sub{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingae034ed2008-12-12 00:56:36 +00002451 [(store (sub (load addr:$dst), i16immSExt8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00002452 addr:$dst),
2453 (implicit EFLAGS)]>, OpSize;
Bill Wendlingae034ed2008-12-12 00:56:36 +00002454 def SUB32mi8 : Ii8<0x83, MRM5m, (outs), (ins i32mem:$dst, i32i8imm :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002455 "sub{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingae034ed2008-12-12 00:56:36 +00002456 [(store (sub (load addr:$dst), i32immSExt8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00002457 addr:$dst),
2458 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002459}
2460
Evan Cheng259471d2007-10-05 17:59:57 +00002461let Uses = [EFLAGS] in {
Dale Johannesen06b83f12009-05-18 17:44:15 +00002462def SBB8rr : I<0x18, MRMDestReg, (outs GR8:$dst),
2463 (ins GR8:$src1, GR8:$src2),
2464 "sbb{b}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002465 [(set GR8:$dst, (sube GR8:$src1, GR8:$src2))]>;
Dale Johannesen06b83f12009-05-18 17:44:15 +00002466def SBB16rr : I<0x19, MRMDestReg, (outs GR16:$dst),
2467 (ins GR16:$src1, GR16:$src2),
2468 "sbb{w}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002469 [(set GR16:$dst, (sube GR16:$src1, GR16:$src2))]>, OpSize;
Dale Johannesen06b83f12009-05-18 17:44:15 +00002470def SBB32rr : I<0x19, MRMDestReg, (outs GR32:$dst),
2471 (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002472 "sbb{l}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002473 [(set GR32:$dst, (sube GR32:$src1, GR32:$src2))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002474
2475let isTwoAddress = 0 in {
Dale Johannesen06b83f12009-05-18 17:44:15 +00002476 def SBB8mr : I<0x18, MRMDestMem, (outs), (ins i8mem:$dst, GR8:$src2),
2477 "sbb{b}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002478 [(store (sube (load addr:$dst), GR8:$src2), addr:$dst)]>;
Dale Johannesen06b83f12009-05-18 17:44:15 +00002479 def SBB16mr : I<0x19, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
2480 "sbb{w}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002481 [(store (sube (load addr:$dst), GR16:$src2), addr:$dst)]>,
Dale Johannesen067cfb22009-05-18 21:41:59 +00002482 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002483 def SBB32mr : I<0x19, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002484 "sbb{l}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002485 [(store (sube (load addr:$dst), GR32:$src2), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002486 def SBB8mi : Ii32<0x80, MRM3m, (outs), (ins i8mem:$dst, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002487 "sbb{b}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002488 [(store (sube (loadi8 addr:$dst), imm:$src2), addr:$dst)]>;
Dale Johannesen06b83f12009-05-18 17:44:15 +00002489 def SBB16mi : Ii16<0x81, MRM3m, (outs), (ins i16mem:$dst, i16imm:$src2),
2490 "sbb{w}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002491 [(store (sube (loadi16 addr:$dst), imm:$src2), addr:$dst)]>,
Dale Johannesen067cfb22009-05-18 21:41:59 +00002492 OpSize;
Dale Johannesen06b83f12009-05-18 17:44:15 +00002493 def SBB16mi8 : Ii8<0x83, MRM3m, (outs), (ins i16mem:$dst, i16i8imm :$src2),
2494 "sbb{w}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002495 [(store (sube (load addr:$dst), i16immSExt8:$src2), addr:$dst)]>,
Dale Johannesen067cfb22009-05-18 21:41:59 +00002496 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002497 def SBB32mi : Ii32<0x81, MRM3m, (outs), (ins i32mem:$dst, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002498 "sbb{l}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002499 [(store (sube (loadi32 addr:$dst), imm:$src2), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002500 def SBB32mi8 : Ii8<0x83, MRM3m, (outs), (ins i32mem:$dst, i32i8imm :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002501 "sbb{l}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002502 [(store (sube (load addr:$dst), i32immSExt8:$src2), addr:$dst)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002503}
Dale Johannesen06b83f12009-05-18 17:44:15 +00002504def SBB8rm : I<0x1A, MRMSrcMem, (outs GR8:$dst), (ins GR8:$src1, i8mem:$src2),
2505 "sbb{b}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002506 [(set GR8:$dst, (sube GR8:$src1, (load addr:$src2)))]>;
Dale Johannesen06b83f12009-05-18 17:44:15 +00002507def SBB16rm : I<0x1B, MRMSrcMem, (outs GR16:$dst),
2508 (ins GR16:$src1, i16mem:$src2),
2509 "sbb{w}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002510 [(set GR16:$dst, (sube GR16:$src1, (load addr:$src2)))]>,
Dale Johannesen067cfb22009-05-18 21:41:59 +00002511 OpSize;
Dale Johannesen06b83f12009-05-18 17:44:15 +00002512def SBB32rm : I<0x1B, MRMSrcMem, (outs GR32:$dst),
2513 (ins GR32:$src1, i32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002514 "sbb{l}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002515 [(set GR32:$dst, (sube GR32:$src1, (load addr:$src2)))]>;
Dale Johannesen06b83f12009-05-18 17:44:15 +00002516def SBB8ri : Ii8<0x80, MRM3r, (outs GR8:$dst), (ins GR8:$src1, i8imm:$src2),
2517 "sbb{b}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002518 [(set GR8:$dst, (sube GR8:$src1, imm:$src2))]>;
Dale Johannesen06b83f12009-05-18 17:44:15 +00002519def SBB16ri : Ii16<0x81, MRM3r, (outs GR16:$dst),
2520 (ins GR16:$src1, i16imm:$src2),
2521 "sbb{w}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002522 [(set GR16:$dst, (sube GR16:$src1, imm:$src2))]>, OpSize;
Dale Johannesen06b83f12009-05-18 17:44:15 +00002523def SBB16ri8 : Ii8<0x83, MRM3r, (outs GR16:$dst),
2524 (ins GR16:$src1, i16i8imm:$src2),
2525 "sbb{w}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002526 [(set GR16:$dst, (sube GR16:$src1, i16immSExt8:$src2))]>,
2527 OpSize;
Dale Johannesen06b83f12009-05-18 17:44:15 +00002528def SBB32ri : Ii32<0x81, MRM3r, (outs GR32:$dst),
2529 (ins GR32:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002530 "sbb{l}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002531 [(set GR32:$dst, (sube GR32:$src1, imm:$src2))]>;
Dale Johannesen06b83f12009-05-18 17:44:15 +00002532def SBB32ri8 : Ii8<0x83, MRM3r, (outs GR32:$dst),
2533 (ins GR32:$src1, i32i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002534 "sbb{l}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002535 [(set GR32:$dst, (sube GR32:$src1, i32immSExt8:$src2))]>;
Evan Cheng259471d2007-10-05 17:59:57 +00002536} // Uses = [EFLAGS]
Evan Cheng55687072007-09-14 21:48:26 +00002537} // Defs = [EFLAGS]
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002538
Evan Cheng55687072007-09-14 21:48:26 +00002539let Defs = [EFLAGS] in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002540let isCommutable = 1 in { // X = IMUL Y, Z --> X = IMUL Z, Y
Bill Wendlingf5399032008-12-12 21:15:41 +00002541// Register-Register Signed Integer Multiply
Bill Wendlingae034ed2008-12-12 00:56:36 +00002542def IMUL16rr : I<0xAF, MRMSrcReg, (outs GR16:$dst), (ins GR16:$src1,GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002543 "imul{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002544 [(set GR16:$dst, (mul GR16:$src1, GR16:$src2)),
2545 (implicit EFLAGS)]>, TB, OpSize;
Bill Wendlingae034ed2008-12-12 00:56:36 +00002546def IMUL32rr : I<0xAF, MRMSrcReg, (outs GR32:$dst), (ins GR32:$src1,GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002547 "imul{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002548 [(set GR32:$dst, (mul GR32:$src1, GR32:$src2)),
2549 (implicit EFLAGS)]>, TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002550}
Bill Wendlingae034ed2008-12-12 00:56:36 +00002551
Bill Wendlingf5399032008-12-12 21:15:41 +00002552// Register-Memory Signed Integer Multiply
Bill Wendlingae034ed2008-12-12 00:56:36 +00002553def IMUL16rm : I<0xAF, MRMSrcMem, (outs GR16:$dst),
2554 (ins GR16:$src1, i16mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002555 "imul{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002556 [(set GR16:$dst, (mul GR16:$src1, (load addr:$src2))),
2557 (implicit EFLAGS)]>, TB, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002558def IMUL32rm : I<0xAF, MRMSrcMem, (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002559 "imul{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002560 [(set GR32:$dst, (mul GR32:$src1, (load addr:$src2))),
2561 (implicit EFLAGS)]>, TB;
Evan Cheng55687072007-09-14 21:48:26 +00002562} // Defs = [EFLAGS]
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002563} // end Two Address instructions
2564
2565// Suprisingly enough, these are not two address instructions!
Evan Cheng55687072007-09-14 21:48:26 +00002566let Defs = [EFLAGS] in {
Bill Wendlingf5399032008-12-12 21:15:41 +00002567// Register-Integer Signed Integer Multiply
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002568def IMUL16rri : Ii16<0x69, MRMSrcReg, // GR16 = GR16*I16
Evan Chengb783fa32007-07-19 01:14:50 +00002569 (outs GR16:$dst), (ins GR16:$src1, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002570 "imul{w}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002571 [(set GR16:$dst, (mul GR16:$src1, imm:$src2)),
2572 (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002573def IMUL32rri : Ii32<0x69, MRMSrcReg, // GR32 = GR32*I32
Evan Chengb783fa32007-07-19 01:14:50 +00002574 (outs GR32:$dst), (ins GR32:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002575 "imul{l}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002576 [(set GR32:$dst, (mul GR32:$src1, imm:$src2)),
2577 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002578def IMUL16rri8 : Ii8<0x6B, MRMSrcReg, // GR16 = GR16*I8
Evan Chengb783fa32007-07-19 01:14:50 +00002579 (outs GR16:$dst), (ins GR16:$src1, i16i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002580 "imul{w}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002581 [(set GR16:$dst, (mul GR16:$src1, i16immSExt8:$src2)),
2582 (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002583def IMUL32rri8 : Ii8<0x6B, MRMSrcReg, // GR32 = GR32*I8
Evan Chengb783fa32007-07-19 01:14:50 +00002584 (outs GR32:$dst), (ins GR32:$src1, i32i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002585 "imul{l}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002586 [(set GR32:$dst, (mul GR32:$src1, i32immSExt8:$src2)),
2587 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002588
Bill Wendlingf5399032008-12-12 21:15:41 +00002589// Memory-Integer Signed Integer Multiply
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002590def IMUL16rmi : Ii16<0x69, MRMSrcMem, // GR16 = [mem16]*I16
Evan Chengb783fa32007-07-19 01:14:50 +00002591 (outs GR16:$dst), (ins i16mem:$src1, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002592 "imul{w}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002593 [(set GR16:$dst, (mul (load addr:$src1), imm:$src2)),
2594 (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002595def IMUL32rmi : Ii32<0x69, MRMSrcMem, // GR32 = [mem32]*I32
Evan Chengb783fa32007-07-19 01:14:50 +00002596 (outs GR32:$dst), (ins i32mem:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002597 "imul{l}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002598 [(set GR32:$dst, (mul (load addr:$src1), imm:$src2)),
2599 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002600def IMUL16rmi8 : Ii8<0x6B, MRMSrcMem, // GR16 = [mem16]*I8
Evan Chengb783fa32007-07-19 01:14:50 +00002601 (outs GR16:$dst), (ins i16mem:$src1, i16i8imm :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002602 "imul{w}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Bill Wendlingae034ed2008-12-12 00:56:36 +00002603 [(set GR16:$dst, (mul (load addr:$src1),
Bill Wendlingf5399032008-12-12 21:15:41 +00002604 i16immSExt8:$src2)),
2605 (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002606def IMUL32rmi8 : Ii8<0x6B, MRMSrcMem, // GR32 = [mem32]*I8
Evan Chengb783fa32007-07-19 01:14:50 +00002607 (outs GR32:$dst), (ins i32mem:$src1, i32i8imm: $src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002608 "imul{l}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Bill Wendlingae034ed2008-12-12 00:56:36 +00002609 [(set GR32:$dst, (mul (load addr:$src1),
Bill Wendlingf5399032008-12-12 21:15:41 +00002610 i32immSExt8:$src2)),
2611 (implicit EFLAGS)]>;
Evan Cheng55687072007-09-14 21:48:26 +00002612} // Defs = [EFLAGS]
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002613
2614//===----------------------------------------------------------------------===//
2615// Test instructions are just like AND, except they don't generate a result.
2616//
Evan Cheng950aac02007-09-25 01:57:46 +00002617let Defs = [EFLAGS] in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002618let isCommutable = 1 in { // TEST X, Y --> TEST Y, X
Evan Chengb783fa32007-07-19 01:14:50 +00002619def TEST8rr : I<0x84, MRMDestReg, (outs), (ins GR8:$src1, GR8:$src2),
Evan Cheng621216e2007-09-29 00:00:36 +00002620 "test{b}\t{$src2, $src1|$src1, $src2}",
Chris Lattner21da6382008-02-19 17:37:35 +00002621 [(X86cmp (and_su GR8:$src1, GR8:$src2), 0),
Evan Cheng621216e2007-09-29 00:00:36 +00002622 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002623def TEST16rr : I<0x85, MRMDestReg, (outs), (ins GR16:$src1, GR16:$src2),
Evan Cheng621216e2007-09-29 00:00:36 +00002624 "test{w}\t{$src2, $src1|$src1, $src2}",
Chris Lattner21da6382008-02-19 17:37:35 +00002625 [(X86cmp (and_su GR16:$src1, GR16:$src2), 0),
Evan Cheng621216e2007-09-29 00:00:36 +00002626 (implicit EFLAGS)]>,
2627 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002628def TEST32rr : I<0x85, MRMDestReg, (outs), (ins GR32:$src1, GR32:$src2),
Evan Cheng621216e2007-09-29 00:00:36 +00002629 "test{l}\t{$src2, $src1|$src1, $src2}",
Chris Lattner21da6382008-02-19 17:37:35 +00002630 [(X86cmp (and_su GR32:$src1, GR32:$src2), 0),
Evan Cheng621216e2007-09-29 00:00:36 +00002631 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002632}
2633
Evan Chengb783fa32007-07-19 01:14:50 +00002634def TEST8rm : I<0x84, MRMSrcMem, (outs), (ins GR8 :$src1, i8mem :$src2),
Evan Cheng621216e2007-09-29 00:00:36 +00002635 "test{b}\t{$src2, $src1|$src1, $src2}",
2636 [(X86cmp (and GR8:$src1, (loadi8 addr:$src2)), 0),
2637 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002638def TEST16rm : I<0x85, MRMSrcMem, (outs), (ins GR16:$src1, i16mem:$src2),
Evan Cheng621216e2007-09-29 00:00:36 +00002639 "test{w}\t{$src2, $src1|$src1, $src2}",
2640 [(X86cmp (and GR16:$src1, (loadi16 addr:$src2)), 0),
2641 (implicit EFLAGS)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002642def TEST32rm : I<0x85, MRMSrcMem, (outs), (ins GR32:$src1, i32mem:$src2),
Evan Cheng621216e2007-09-29 00:00:36 +00002643 "test{l}\t{$src2, $src1|$src1, $src2}",
2644 [(X86cmp (and GR32:$src1, (loadi32 addr:$src2)), 0),
2645 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002646
2647def TEST8ri : Ii8 <0xF6, MRM0r, // flags = GR8 & imm8
Evan Chengb783fa32007-07-19 01:14:50 +00002648 (outs), (ins GR8:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002649 "test{b}\t{$src2, $src1|$src1, $src2}",
Chris Lattner21da6382008-02-19 17:37:35 +00002650 [(X86cmp (and_su GR8:$src1, imm:$src2), 0),
Evan Cheng621216e2007-09-29 00:00:36 +00002651 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002652def TEST16ri : Ii16<0xF7, MRM0r, // flags = GR16 & imm16
Evan Chengb783fa32007-07-19 01:14:50 +00002653 (outs), (ins GR16:$src1, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002654 "test{w}\t{$src2, $src1|$src1, $src2}",
Chris Lattner21da6382008-02-19 17:37:35 +00002655 [(X86cmp (and_su GR16:$src1, imm:$src2), 0),
Evan Cheng621216e2007-09-29 00:00:36 +00002656 (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002657def TEST32ri : Ii32<0xF7, MRM0r, // flags = GR32 & imm32
Evan Chengb783fa32007-07-19 01:14:50 +00002658 (outs), (ins GR32:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002659 "test{l}\t{$src2, $src1|$src1, $src2}",
Chris Lattner21da6382008-02-19 17:37:35 +00002660 [(X86cmp (and_su GR32:$src1, imm:$src2), 0),
Evan Cheng621216e2007-09-29 00:00:36 +00002661 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002662
Evan Cheng621216e2007-09-29 00:00:36 +00002663def TEST8mi : Ii8 <0xF6, MRM0m, // flags = [mem8] & imm8
Evan Chengb783fa32007-07-19 01:14:50 +00002664 (outs), (ins i8mem:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002665 "test{b}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002666 [(X86cmp (and (loadi8 addr:$src1), imm:$src2), 0),
2667 (implicit EFLAGS)]>;
2668def TEST16mi : Ii16<0xF7, MRM0m, // flags = [mem16] & imm16
Evan Chengb783fa32007-07-19 01:14:50 +00002669 (outs), (ins i16mem:$src1, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002670 "test{w}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002671 [(X86cmp (and (loadi16 addr:$src1), imm:$src2), 0),
2672 (implicit EFLAGS)]>, OpSize;
2673def TEST32mi : Ii32<0xF7, MRM0m, // flags = [mem32] & imm32
Evan Chengb783fa32007-07-19 01:14:50 +00002674 (outs), (ins i32mem:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002675 "test{l}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002676 [(X86cmp (and (loadi32 addr:$src1), imm:$src2), 0),
Evan Cheng950aac02007-09-25 01:57:46 +00002677 (implicit EFLAGS)]>;
2678} // Defs = [EFLAGS]
2679
2680
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002681// Condition code ops, incl. set if equal/not equal/...
Chris Lattnerc90ee9c2008-01-10 07:59:24 +00002682let Defs = [EFLAGS], Uses = [AH], neverHasSideEffects = 1 in
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002683def SAHF : I<0x9E, RawFrm, (outs), (ins), "sahf", []>; // flags = AH
Chris Lattnerc90ee9c2008-01-10 07:59:24 +00002684let Defs = [AH], Uses = [EFLAGS], neverHasSideEffects = 1 in
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002685def LAHF : I<0x9F, RawFrm, (outs), (ins), "lahf", []>; // AH = flags
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002686
Evan Cheng950aac02007-09-25 01:57:46 +00002687let Uses = [EFLAGS] in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002688def SETEr : I<0x94, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00002689 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002690 "sete\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002691 [(set GR8:$dst, (X86setcc X86_COND_E, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002692 TB; // GR8 = ==
2693def SETEm : I<0x94, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00002694 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002695 "sete\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002696 [(store (X86setcc X86_COND_E, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002697 TB; // [mem8] = ==
Bill Wendling0c52d0a2008-12-02 00:07:05 +00002698
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002699def SETNEr : I<0x95, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00002700 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002701 "setne\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002702 [(set GR8:$dst, (X86setcc X86_COND_NE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002703 TB; // GR8 = !=
2704def SETNEm : I<0x95, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00002705 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002706 "setne\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002707 [(store (X86setcc X86_COND_NE, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002708 TB; // [mem8] = !=
Bill Wendling0c52d0a2008-12-02 00:07:05 +00002709
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002710def SETLr : I<0x9C, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00002711 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002712 "setl\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002713 [(set GR8:$dst, (X86setcc X86_COND_L, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002714 TB; // GR8 = < signed
2715def SETLm : I<0x9C, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00002716 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002717 "setl\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002718 [(store (X86setcc X86_COND_L, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002719 TB; // [mem8] = < signed
Bill Wendling0c52d0a2008-12-02 00:07:05 +00002720
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002721def SETGEr : I<0x9D, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00002722 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002723 "setge\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002724 [(set GR8:$dst, (X86setcc X86_COND_GE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002725 TB; // GR8 = >= signed
2726def SETGEm : I<0x9D, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00002727 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002728 "setge\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002729 [(store (X86setcc X86_COND_GE, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002730 TB; // [mem8] = >= signed
Bill Wendling0c52d0a2008-12-02 00:07:05 +00002731
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002732def SETLEr : I<0x9E, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00002733 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002734 "setle\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002735 [(set GR8:$dst, (X86setcc X86_COND_LE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002736 TB; // GR8 = <= signed
2737def SETLEm : I<0x9E, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00002738 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002739 "setle\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002740 [(store (X86setcc X86_COND_LE, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002741 TB; // [mem8] = <= signed
Bill Wendling0c52d0a2008-12-02 00:07:05 +00002742
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002743def SETGr : I<0x9F, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00002744 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002745 "setg\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002746 [(set GR8:$dst, (X86setcc X86_COND_G, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002747 TB; // GR8 = > signed
2748def SETGm : I<0x9F, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00002749 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002750 "setg\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002751 [(store (X86setcc X86_COND_G, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002752 TB; // [mem8] = > signed
2753
2754def SETBr : I<0x92, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00002755 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002756 "setb\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002757 [(set GR8:$dst, (X86setcc X86_COND_B, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002758 TB; // GR8 = < unsign
2759def SETBm : I<0x92, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00002760 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002761 "setb\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002762 [(store (X86setcc X86_COND_B, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002763 TB; // [mem8] = < unsign
Bill Wendling0c52d0a2008-12-02 00:07:05 +00002764
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002765def SETAEr : I<0x93, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00002766 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002767 "setae\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002768 [(set GR8:$dst, (X86setcc X86_COND_AE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002769 TB; // GR8 = >= unsign
2770def SETAEm : I<0x93, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00002771 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002772 "setae\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002773 [(store (X86setcc X86_COND_AE, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002774 TB; // [mem8] = >= unsign
Bill Wendling0c52d0a2008-12-02 00:07:05 +00002775
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002776def SETBEr : I<0x96, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00002777 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002778 "setbe\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002779 [(set GR8:$dst, (X86setcc X86_COND_BE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002780 TB; // GR8 = <= unsign
2781def SETBEm : I<0x96, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00002782 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002783 "setbe\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002784 [(store (X86setcc X86_COND_BE, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002785 TB; // [mem8] = <= unsign
Bill Wendling0c52d0a2008-12-02 00:07:05 +00002786
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002787def SETAr : I<0x97, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00002788 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002789 "seta\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002790 [(set GR8:$dst, (X86setcc X86_COND_A, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002791 TB; // GR8 = > signed
2792def SETAm : I<0x97, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00002793 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002794 "seta\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002795 [(store (X86setcc X86_COND_A, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002796 TB; // [mem8] = > signed
2797
2798def SETSr : I<0x98, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00002799 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002800 "sets\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002801 [(set GR8:$dst, (X86setcc X86_COND_S, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002802 TB; // GR8 = <sign bit>
2803def SETSm : I<0x98, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00002804 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002805 "sets\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002806 [(store (X86setcc X86_COND_S, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002807 TB; // [mem8] = <sign bit>
2808def SETNSr : I<0x99, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00002809 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002810 "setns\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002811 [(set GR8:$dst, (X86setcc X86_COND_NS, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002812 TB; // GR8 = !<sign bit>
2813def SETNSm : I<0x99, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00002814 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002815 "setns\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002816 [(store (X86setcc X86_COND_NS, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002817 TB; // [mem8] = !<sign bit>
Bill Wendling0c52d0a2008-12-02 00:07:05 +00002818
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002819def SETPr : I<0x9A, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00002820 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002821 "setp\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002822 [(set GR8:$dst, (X86setcc X86_COND_P, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002823 TB; // GR8 = parity
2824def SETPm : I<0x9A, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00002825 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002826 "setp\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002827 [(store (X86setcc X86_COND_P, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002828 TB; // [mem8] = parity
2829def SETNPr : I<0x9B, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00002830 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002831 "setnp\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002832 [(set GR8:$dst, (X86setcc X86_COND_NP, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002833 TB; // GR8 = not parity
2834def SETNPm : I<0x9B, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00002835 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002836 "setnp\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002837 [(store (X86setcc X86_COND_NP, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002838 TB; // [mem8] = not parity
Bill Wendling0c52d0a2008-12-02 00:07:05 +00002839
2840def SETOr : I<0x90, MRM0r,
2841 (outs GR8 :$dst), (ins),
2842 "seto\t$dst",
2843 [(set GR8:$dst, (X86setcc X86_COND_O, EFLAGS))]>,
2844 TB; // GR8 = overflow
2845def SETOm : I<0x90, MRM0m,
2846 (outs), (ins i8mem:$dst),
2847 "seto\t$dst",
2848 [(store (X86setcc X86_COND_O, EFLAGS), addr:$dst)]>,
2849 TB; // [mem8] = overflow
2850def SETNOr : I<0x91, MRM0r,
2851 (outs GR8 :$dst), (ins),
2852 "setno\t$dst",
2853 [(set GR8:$dst, (X86setcc X86_COND_NO, EFLAGS))]>,
2854 TB; // GR8 = not overflow
2855def SETNOm : I<0x91, MRM0m,
2856 (outs), (ins i8mem:$dst),
2857 "setno\t$dst",
2858 [(store (X86setcc X86_COND_NO, EFLAGS), addr:$dst)]>,
2859 TB; // [mem8] = not overflow
Evan Cheng950aac02007-09-25 01:57:46 +00002860} // Uses = [EFLAGS]
2861
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002862
2863// Integer comparisons
Evan Cheng55687072007-09-14 21:48:26 +00002864let Defs = [EFLAGS] in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002865def CMP8rr : I<0x38, MRMDestReg,
Evan Chengb783fa32007-07-19 01:14:50 +00002866 (outs), (ins GR8 :$src1, GR8 :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002867 "cmp{b}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002868 [(X86cmp GR8:$src1, GR8:$src2), (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002869def CMP16rr : I<0x39, MRMDestReg,
Evan Chengb783fa32007-07-19 01:14:50 +00002870 (outs), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002871 "cmp{w}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002872 [(X86cmp GR16:$src1, GR16:$src2), (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002873def CMP32rr : I<0x39, MRMDestReg,
Evan Chengb783fa32007-07-19 01:14:50 +00002874 (outs), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002875 "cmp{l}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002876 [(X86cmp GR32:$src1, GR32:$src2), (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002877def CMP8mr : I<0x38, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00002878 (outs), (ins i8mem :$src1, GR8 :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002879 "cmp{b}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002880 [(X86cmp (loadi8 addr:$src1), GR8:$src2),
2881 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002882def CMP16mr : I<0x39, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00002883 (outs), (ins i16mem:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002884 "cmp{w}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002885 [(X86cmp (loadi16 addr:$src1), GR16:$src2),
2886 (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002887def CMP32mr : I<0x39, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00002888 (outs), (ins i32mem:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002889 "cmp{l}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002890 [(X86cmp (loadi32 addr:$src1), GR32:$src2),
2891 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002892def CMP8rm : I<0x3A, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00002893 (outs), (ins GR8 :$src1, i8mem :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002894 "cmp{b}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002895 [(X86cmp GR8:$src1, (loadi8 addr:$src2)),
2896 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002897def CMP16rm : I<0x3B, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00002898 (outs), (ins GR16:$src1, i16mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002899 "cmp{w}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002900 [(X86cmp GR16:$src1, (loadi16 addr:$src2)),
2901 (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002902def CMP32rm : I<0x3B, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00002903 (outs), (ins GR32:$src1, i32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002904 "cmp{l}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002905 [(X86cmp GR32:$src1, (loadi32 addr:$src2)),
2906 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002907def CMP8ri : Ii8<0x80, MRM7r,
Evan Chengb783fa32007-07-19 01:14:50 +00002908 (outs), (ins GR8:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002909 "cmp{b}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002910 [(X86cmp GR8:$src1, imm:$src2), (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002911def CMP16ri : Ii16<0x81, MRM7r,
Evan Chengb783fa32007-07-19 01:14:50 +00002912 (outs), (ins GR16:$src1, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002913 "cmp{w}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002914 [(X86cmp GR16:$src1, imm:$src2),
2915 (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002916def CMP32ri : Ii32<0x81, MRM7r,
Evan Chengb783fa32007-07-19 01:14:50 +00002917 (outs), (ins GR32:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002918 "cmp{l}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002919 [(X86cmp GR32:$src1, imm:$src2), (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002920def CMP8mi : Ii8 <0x80, MRM7m,
Evan Chengb783fa32007-07-19 01:14:50 +00002921 (outs), (ins i8mem :$src1, i8imm :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002922 "cmp{b}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002923 [(X86cmp (loadi8 addr:$src1), imm:$src2),
2924 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002925def CMP16mi : Ii16<0x81, MRM7m,
Evan Chengb783fa32007-07-19 01:14:50 +00002926 (outs), (ins i16mem:$src1, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002927 "cmp{w}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002928 [(X86cmp (loadi16 addr:$src1), imm:$src2),
2929 (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002930def CMP32mi : Ii32<0x81, MRM7m,
Evan Chengb783fa32007-07-19 01:14:50 +00002931 (outs), (ins i32mem:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002932 "cmp{l}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002933 [(X86cmp (loadi32 addr:$src1), imm:$src2),
2934 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002935def CMP16ri8 : Ii8<0x83, MRM7r,
Evan Chengb783fa32007-07-19 01:14:50 +00002936 (outs), (ins GR16:$src1, i16i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002937 "cmp{w}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002938 [(X86cmp GR16:$src1, i16immSExt8:$src2),
2939 (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002940def CMP16mi8 : Ii8<0x83, MRM7m,
Evan Chengb783fa32007-07-19 01:14:50 +00002941 (outs), (ins i16mem:$src1, i16i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002942 "cmp{w}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002943 [(X86cmp (loadi16 addr:$src1), i16immSExt8:$src2),
2944 (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002945def CMP32mi8 : Ii8<0x83, MRM7m,
Evan Chengb783fa32007-07-19 01:14:50 +00002946 (outs), (ins i32mem:$src1, i32i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002947 "cmp{l}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002948 [(X86cmp (loadi32 addr:$src1), i32immSExt8:$src2),
2949 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002950def CMP32ri8 : Ii8<0x83, MRM7r,
Evan Chengb783fa32007-07-19 01:14:50 +00002951 (outs), (ins GR32:$src1, i32i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002952 "cmp{l}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002953 [(X86cmp GR32:$src1, i32immSExt8:$src2),
Evan Cheng950aac02007-09-25 01:57:46 +00002954 (implicit EFLAGS)]>;
2955} // Defs = [EFLAGS]
2956
Dan Gohman7fe9b7f2008-12-23 22:45:23 +00002957// Bit tests.
Dan Gohman7fe9b7f2008-12-23 22:45:23 +00002958// TODO: BTC, BTR, and BTS
2959let Defs = [EFLAGS] in {
Dan Gohmanfc4eddb2009-01-13 20:32:45 +00002960def BT16rr : I<0xA3, MRMDestReg, (outs), (ins GR16:$src1, GR16:$src2),
Dan Gohman7fe9b7f2008-12-23 22:45:23 +00002961 "bt{w}\t{$src2, $src1|$src1, $src2}",
2962 [(X86bt GR16:$src1, GR16:$src2),
Chris Lattner5a95cde2008-12-25 01:32:49 +00002963 (implicit EFLAGS)]>, OpSize, TB;
Dan Gohmanfc4eddb2009-01-13 20:32:45 +00002964def BT32rr : I<0xA3, MRMDestReg, (outs), (ins GR32:$src1, GR32:$src2),
Dan Gohman7fe9b7f2008-12-23 22:45:23 +00002965 "bt{l}\t{$src2, $src1|$src1, $src2}",
2966 [(X86bt GR32:$src1, GR32:$src2),
Chris Lattner5a95cde2008-12-25 01:32:49 +00002967 (implicit EFLAGS)]>, TB;
Dan Gohman85a228c2009-01-13 23:23:30 +00002968
2969// Unlike with the register+register form, the memory+register form of the
2970// bt instruction does not ignore the high bits of the index. From ISel's
2971// perspective, this is pretty bizarre. Disable these instructions for now.
2972//def BT16mr : I<0xA3, MRMDestMem, (outs), (ins i16mem:$src1, GR16:$src2),
2973// "bt{w}\t{$src2, $src1|$src1, $src2}",
2974// [(X86bt (loadi16 addr:$src1), GR16:$src2),
2975// (implicit EFLAGS)]>, OpSize, TB, Requires<[FastBTMem]>;
2976//def BT32mr : I<0xA3, MRMDestMem, (outs), (ins i32mem:$src1, GR32:$src2),
2977// "bt{l}\t{$src2, $src1|$src1, $src2}",
2978// [(X86bt (loadi32 addr:$src1), GR32:$src2),
2979// (implicit EFLAGS)]>, TB, Requires<[FastBTMem]>;
Dan Gohman46fb1cf2009-01-13 20:33:23 +00002980
2981def BT16ri8 : Ii8<0xBA, MRM4r, (outs), (ins GR16:$src1, i16i8imm:$src2),
2982 "bt{w}\t{$src2, $src1|$src1, $src2}",
2983 [(X86bt GR16:$src1, i16immSExt8:$src2),
2984 (implicit EFLAGS)]>, OpSize, TB;
2985def BT32ri8 : Ii8<0xBA, MRM4r, (outs), (ins GR32:$src1, i32i8imm:$src2),
2986 "bt{l}\t{$src2, $src1|$src1, $src2}",
2987 [(X86bt GR32:$src1, i32immSExt8:$src2),
2988 (implicit EFLAGS)]>, TB;
2989// Note that these instructions don't need FastBTMem because that
2990// only applies when the other operand is in a register. When it's
2991// an immediate, bt is still fast.
2992def BT16mi8 : Ii8<0xBA, MRM4m, (outs), (ins i16mem:$src1, i16i8imm:$src2),
2993 "bt{w}\t{$src2, $src1|$src1, $src2}",
2994 [(X86bt (loadi16 addr:$src1), i16immSExt8:$src2),
2995 (implicit EFLAGS)]>, OpSize, TB;
2996def BT32mi8 : Ii8<0xBA, MRM4m, (outs), (ins i32mem:$src1, i32i8imm:$src2),
2997 "bt{l}\t{$src2, $src1|$src1, $src2}",
2998 [(X86bt (loadi32 addr:$src1), i32immSExt8:$src2),
2999 (implicit EFLAGS)]>, TB;
Dan Gohman7fe9b7f2008-12-23 22:45:23 +00003000} // Defs = [EFLAGS]
3001
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003002// Sign/Zero extenders
Dan Gohman9203ab42008-07-30 18:09:17 +00003003// Use movsbl intead of movsbw; we don't care about the high 16 bits
3004// of the register here. This has a smaller encoding and avoids a
3005// partial-register update.
Evan Chengb783fa32007-07-19 01:14:50 +00003006def MOVSX16rr8 : I<0xBE, MRMSrcReg, (outs GR16:$dst), (ins GR8 :$src),
Dan Gohman9203ab42008-07-30 18:09:17 +00003007 "movs{bl|x}\t{$src, ${dst:subreg32}|${dst:subreg32}, $src}",
3008 [(set GR16:$dst, (sext GR8:$src))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00003009def MOVSX16rm8 : I<0xBE, MRMSrcMem, (outs GR16:$dst), (ins i8mem :$src),
Dan Gohman9203ab42008-07-30 18:09:17 +00003010 "movs{bl|x}\t{$src, ${dst:subreg32}|${dst:subreg32}, $src}",
3011 [(set GR16:$dst, (sextloadi16i8 addr:$src))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00003012def MOVSX32rr8 : I<0xBE, MRMSrcReg, (outs GR32:$dst), (ins GR8 :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00003013 "movs{bl|x}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003014 [(set GR32:$dst, (sext GR8:$src))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00003015def MOVSX32rm8 : I<0xBE, MRMSrcMem, (outs GR32:$dst), (ins i8mem :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00003016 "movs{bl|x}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003017 [(set GR32:$dst, (sextloadi32i8 addr:$src))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00003018def MOVSX32rr16: I<0xBF, MRMSrcReg, (outs GR32:$dst), (ins GR16:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00003019 "movs{wl|x}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003020 [(set GR32:$dst, (sext GR16:$src))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00003021def MOVSX32rm16: I<0xBF, MRMSrcMem, (outs GR32:$dst), (ins i16mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00003022 "movs{wl|x}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003023 [(set GR32:$dst, (sextloadi32i16 addr:$src))]>, TB;
3024
Dan Gohman9203ab42008-07-30 18:09:17 +00003025// Use movzbl intead of movzbw; we don't care about the high 16 bits
3026// of the register here. This has a smaller encoding and avoids a
3027// partial-register update.
Evan Chengb783fa32007-07-19 01:14:50 +00003028def MOVZX16rr8 : I<0xB6, MRMSrcReg, (outs GR16:$dst), (ins GR8 :$src),
Dan Gohman9203ab42008-07-30 18:09:17 +00003029 "movz{bl|x}\t{$src, ${dst:subreg32}|${dst:subreg32}, $src}",
3030 [(set GR16:$dst, (zext GR8:$src))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00003031def MOVZX16rm8 : I<0xB6, MRMSrcMem, (outs GR16:$dst), (ins i8mem :$src),
Dan Gohman9203ab42008-07-30 18:09:17 +00003032 "movz{bl|x}\t{$src, ${dst:subreg32}|${dst:subreg32}, $src}",
3033 [(set GR16:$dst, (zextloadi16i8 addr:$src))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00003034def MOVZX32rr8 : I<0xB6, MRMSrcReg, (outs GR32:$dst), (ins GR8 :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00003035 "movz{bl|x}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003036 [(set GR32:$dst, (zext GR8:$src))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00003037def MOVZX32rm8 : I<0xB6, MRMSrcMem, (outs GR32:$dst), (ins i8mem :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00003038 "movz{bl|x}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003039 [(set GR32:$dst, (zextloadi32i8 addr:$src))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00003040def MOVZX32rr16: I<0xB7, MRMSrcReg, (outs GR32:$dst), (ins GR16:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00003041 "movz{wl|x}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003042 [(set GR32:$dst, (zext GR16:$src))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00003043def MOVZX32rm16: I<0xB7, MRMSrcMem, (outs GR32:$dst), (ins i16mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00003044 "movz{wl|x}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003045 [(set GR32:$dst, (zextloadi32i16 addr:$src))]>, TB;
3046
Dan Gohman744d4622009-04-13 16:09:41 +00003047// These are the same as the regular regular MOVZX32rr8 and MOVZX32rm8
3048// except that they use GR32_NOREX for the output operand register class
3049// instead of GR32. This allows them to operate on h registers on x86-64.
3050def MOVZX32_NOREXrr8 : I<0xB6, MRMSrcReg,
3051 (outs GR32_NOREX:$dst), (ins GR8:$src),
3052 "movz{bl|x}\t{$src, $dst|$dst, $src} # NOREX",
3053 []>, TB;
Dan Gohman89f4cda2009-04-30 03:11:48 +00003054let mayLoad = 1 in
Dan Gohman744d4622009-04-13 16:09:41 +00003055def MOVZX32_NOREXrm8 : I<0xB6, MRMSrcMem,
3056 (outs GR32_NOREX:$dst), (ins i8mem:$src),
3057 "movz{bl|x}\t{$src, $dst|$dst, $src} # NOREX",
3058 []>, TB;
3059
Chris Lattnerc90ee9c2008-01-10 07:59:24 +00003060let neverHasSideEffects = 1 in {
3061 let Defs = [AX], Uses = [AL] in
3062 def CBW : I<0x98, RawFrm, (outs), (ins),
3063 "{cbtw|cbw}", []>, OpSize; // AX = signext(AL)
3064 let Defs = [EAX], Uses = [AX] in
3065 def CWDE : I<0x98, RawFrm, (outs), (ins),
3066 "{cwtl|cwde}", []>; // EAX = signext(AX)
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003067
Chris Lattnerc90ee9c2008-01-10 07:59:24 +00003068 let Defs = [AX,DX], Uses = [AX] in
3069 def CWD : I<0x99, RawFrm, (outs), (ins),
3070 "{cwtd|cwd}", []>, OpSize; // DX:AX = signext(AX)
3071 let Defs = [EAX,EDX], Uses = [EAX] in
3072 def CDQ : I<0x99, RawFrm, (outs), (ins),
3073 "{cltd|cdq}", []>; // EDX:EAX = signext(EAX)
3074}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003075
3076//===----------------------------------------------------------------------===//
3077// Alias Instructions
3078//===----------------------------------------------------------------------===//
3079
3080// Alias instructions that map movr0 to xor.
3081// FIXME: remove when we can teach regalloc that xor reg, reg is ok.
Bill Wendlingba5d5b02008-05-29 01:02:09 +00003082let Defs = [EFLAGS], isReMaterializable = 1, isAsCheapAsAMove = 1 in {
Evan Chengb783fa32007-07-19 01:14:50 +00003083def MOV8r0 : I<0x30, MRMInitReg, (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00003084 "xor{b}\t$dst, $dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003085 [(set GR8:$dst, 0)]>;
Dan Gohman9203ab42008-07-30 18:09:17 +00003086// Use xorl instead of xorw since we don't care about the high 16 bits,
3087// it's smaller, and it avoids a partial-register update.
Evan Chengb783fa32007-07-19 01:14:50 +00003088def MOV16r0 : I<0x31, MRMInitReg, (outs GR16:$dst), (ins),
Dan Gohman9203ab42008-07-30 18:09:17 +00003089 "xor{l}\t${dst:subreg32}, ${dst:subreg32}",
3090 [(set GR16:$dst, 0)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00003091def MOV32r0 : I<0x31, MRMInitReg, (outs GR32:$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00003092 "xor{l}\t$dst, $dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003093 [(set GR32:$dst, 0)]>;
Dan Gohman8aef09b2007-09-07 21:32:51 +00003094}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003095
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003096//===----------------------------------------------------------------------===//
3097// Thread Local Storage Instructions
3098//
3099
Rafael Espindola7fc4b8d2009-04-24 12:59:40 +00003100// All calls clobber the non-callee saved registers. ESP is marked as
3101// a use to prevent stack-pointer assignments that appear immediately
3102// before calls from potentially appearing dead.
3103let Defs = [EAX, ECX, EDX, FP0, FP1, FP2, FP3, FP4, FP5, FP6, ST0,
3104 MM0, MM1, MM2, MM3, MM4, MM5, MM6, MM7,
3105 XMM0, XMM1, XMM2, XMM3, XMM4, XMM5, XMM6, XMM7,
3106 XMM8, XMM9, XMM10, XMM11, XMM12, XMM13, XMM14, XMM15, EFLAGS],
3107 Uses = [ESP, EBX] in
Rafael Espindolaaf759ab2009-04-17 14:35:58 +00003108def TLS_addr32 : I<0, Pseudo, (outs), (ins i32imm:$sym),
Dan Gohman70a8a112009-04-27 15:13:28 +00003109 "leal\t${sym:mem}(,%ebx,1), %eax; "
3110 "call\t___tls_get_addr@PLT",
Rafael Espindolaaf759ab2009-04-17 14:35:58 +00003111 [(X86tlsaddr tglobaltlsaddr:$sym)]>,
3112 Requires<[In32BitMode]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003113
sampo9cc09a32009-01-26 01:24:32 +00003114let AddedComplexity = 5 in
3115def GS_MOV32rm : I<0x8B, MRMSrcMem, (outs GR32:$dst), (ins i32mem:$src),
3116 "movl\t%gs:$src, $dst",
3117 [(set GR32:$dst, (gsload addr:$src))]>, SegGS;
3118
Chris Lattnera7c2d8a2009-05-05 18:52:19 +00003119let AddedComplexity = 5 in
3120def FS_MOV32rm : I<0x8B, MRMSrcMem, (outs GR32:$dst), (ins i32mem:$src),
3121 "movl\t%fs:$src, $dst",
3122 [(set GR32:$dst, (fsload addr:$src))]>, SegFS;
3123
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003124//===----------------------------------------------------------------------===//
3125// DWARF Pseudo Instructions
3126//
3127
Evan Chengb783fa32007-07-19 01:14:50 +00003128def DWARF_LOC : I<0, Pseudo, (outs),
3129 (ins i32imm:$line, i32imm:$col, i32imm:$file),
Dan Gohman77af4a82007-09-24 19:25:06 +00003130 ".loc\t${file:debug} ${line:debug} ${col:debug}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003131 [(dwarf_loc (i32 imm:$line), (i32 imm:$col),
3132 (i32 imm:$file))]>;
3133
3134//===----------------------------------------------------------------------===//
3135// EH Pseudo Instructions
3136//
3137let isTerminator = 1, isReturn = 1, isBarrier = 1,
Evan Cheng37e7c752007-07-21 00:34:19 +00003138 hasCtrlDep = 1 in {
Evan Chengb783fa32007-07-19 01:14:50 +00003139def EH_RETURN : I<0xC3, RawFrm, (outs), (ins GR32:$addr),
Dan Gohman91888f02007-07-31 20:11:57 +00003140 "ret\t#eh_return, addr: $addr",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003141 [(X86ehret GR32:$addr)]>;
3142
3143}
3144
3145//===----------------------------------------------------------------------===//
Andrew Lenharthe44f3902008-02-21 06:45:13 +00003146// Atomic support
3147//
Andrew Lenharth7a5a4b22008-03-01 13:37:02 +00003148
Evan Cheng3e171562008-04-19 01:20:30 +00003149// Atomic swap. These are just normal xchg instructions. But since a memory
3150// operand is referenced, the atomicity is ensured.
Dan Gohmana41a1c092008-08-06 15:52:50 +00003151let Constraints = "$val = $dst" in {
Evan Cheng3e171562008-04-19 01:20:30 +00003152def XCHG32rm : I<0x87, MRMSrcMem, (outs GR32:$dst), (ins i32mem:$ptr, GR32:$val),
3153 "xchg{l}\t{$val, $ptr|$ptr, $val}",
3154 [(set GR32:$dst, (atomic_swap_32 addr:$ptr, GR32:$val))]>;
3155def XCHG16rm : I<0x87, MRMSrcMem, (outs GR16:$dst), (ins i16mem:$ptr, GR16:$val),
3156 "xchg{w}\t{$val, $ptr|$ptr, $val}",
3157 [(set GR16:$dst, (atomic_swap_16 addr:$ptr, GR16:$val))]>,
3158 OpSize;
3159def XCHG8rm : I<0x86, MRMSrcMem, (outs GR8:$dst), (ins i8mem:$ptr, GR8:$val),
3160 "xchg{b}\t{$val, $ptr|$ptr, $val}",
3161 [(set GR8:$dst, (atomic_swap_8 addr:$ptr, GR8:$val))]>;
3162}
3163
Evan Chengd49dbb82008-04-18 20:55:36 +00003164// Atomic compare and swap.
Andrew Lenharth7dfe23f2008-03-01 21:52:34 +00003165let Defs = [EAX, EFLAGS], Uses = [EAX] in {
Evan Chengd49dbb82008-04-18 20:55:36 +00003166def LCMPXCHG32 : I<0xB1, MRMDestMem, (outs), (ins i32mem:$ptr, GR32:$swap),
Dan Gohman70a8a112009-04-27 15:13:28 +00003167 "lock\n\t"
3168 "cmpxchg{l}\t{$swap, $ptr|$ptr, $swap}",
Evan Cheng09fbdee2008-03-04 03:20:06 +00003169 [(X86cas addr:$ptr, GR32:$swap, 4)]>, TB, LOCK;
Andrew Lenharth7a5a4b22008-03-01 13:37:02 +00003170}
Dale Johannesenf160d802008-10-02 18:53:47 +00003171let Defs = [EAX, EDX, EFLAGS], Uses = [EAX, EBX, ECX, EDX] in {
Anton Korobeynikovc4067392008-07-22 16:22:48 +00003172def LCMPXCHG8B : I<0xC7, MRM1m, (outs), (ins i32mem:$ptr),
Dan Gohman70a8a112009-04-27 15:13:28 +00003173 "lock\n\t"
3174 "cmpxchg8b\t$ptr",
Andrew Lenharth81580822008-03-05 01:15:49 +00003175 [(X86cas8 addr:$ptr)]>, TB, LOCK;
3176}
Andrew Lenharth7dfe23f2008-03-01 21:52:34 +00003177
3178let Defs = [AX, EFLAGS], Uses = [AX] in {
Evan Chengd49dbb82008-04-18 20:55:36 +00003179def LCMPXCHG16 : I<0xB1, MRMDestMem, (outs), (ins i16mem:$ptr, GR16:$swap),
Dan Gohman70a8a112009-04-27 15:13:28 +00003180 "lock\n\t"
3181 "cmpxchg{w}\t{$swap, $ptr|$ptr, $swap}",
Evan Cheng09fbdee2008-03-04 03:20:06 +00003182 [(X86cas addr:$ptr, GR16:$swap, 2)]>, TB, OpSize, LOCK;
Andrew Lenharth7a5a4b22008-03-01 13:37:02 +00003183}
Andrew Lenharth7dfe23f2008-03-01 21:52:34 +00003184let Defs = [AL, EFLAGS], Uses = [AL] in {
Evan Chengd49dbb82008-04-18 20:55:36 +00003185def LCMPXCHG8 : I<0xB0, MRMDestMem, (outs), (ins i8mem:$ptr, GR8:$swap),
Dan Gohman70a8a112009-04-27 15:13:28 +00003186 "lock\n\t"
3187 "cmpxchg{b}\t{$swap, $ptr|$ptr, $swap}",
Evan Cheng09fbdee2008-03-04 03:20:06 +00003188 [(X86cas addr:$ptr, GR8:$swap, 1)]>, TB, LOCK;
Andrew Lenharth7a5a4b22008-03-01 13:37:02 +00003189}
3190
Evan Chengd49dbb82008-04-18 20:55:36 +00003191// Atomic exchange and add
3192let Constraints = "$val = $dst", Defs = [EFLAGS] in {
3193def LXADD32 : I<0xC1, MRMSrcMem, (outs GR32:$dst), (ins i32mem:$ptr, GR32:$val),
Dan Gohman70a8a112009-04-27 15:13:28 +00003194 "lock\n\t"
3195 "xadd{l}\t{$val, $ptr|$ptr, $val}",
Mon P Wang6bde9ec2008-06-25 08:15:39 +00003196 [(set GR32:$dst, (atomic_load_add_32 addr:$ptr, GR32:$val))]>,
Evan Chengd49dbb82008-04-18 20:55:36 +00003197 TB, LOCK;
3198def LXADD16 : I<0xC1, MRMSrcMem, (outs GR16:$dst), (ins i16mem:$ptr, GR16:$val),
Dan Gohman70a8a112009-04-27 15:13:28 +00003199 "lock\n\t"
3200 "xadd{w}\t{$val, $ptr|$ptr, $val}",
Mon P Wang6bde9ec2008-06-25 08:15:39 +00003201 [(set GR16:$dst, (atomic_load_add_16 addr:$ptr, GR16:$val))]>,
Evan Chengd49dbb82008-04-18 20:55:36 +00003202 TB, OpSize, LOCK;
3203def LXADD8 : I<0xC0, MRMSrcMem, (outs GR8:$dst), (ins i8mem:$ptr, GR8:$val),
Dan Gohman70a8a112009-04-27 15:13:28 +00003204 "lock\n\t"
3205 "xadd{b}\t{$val, $ptr|$ptr, $val}",
Mon P Wang6bde9ec2008-06-25 08:15:39 +00003206 [(set GR8:$dst, (atomic_load_add_8 addr:$ptr, GR8:$val))]>,
Evan Chengd49dbb82008-04-18 20:55:36 +00003207 TB, LOCK;
Andrew Lenharth7a5a4b22008-03-01 13:37:02 +00003208}
3209
Mon P Wang6bde9ec2008-06-25 08:15:39 +00003210// Atomic exchange, and, or, xor
Mon P Wang078a62d2008-05-05 19:05:59 +00003211let Constraints = "$val = $dst", Defs = [EFLAGS],
3212 usesCustomDAGSchedInserter = 1 in {
Dan Gohman8aeb61f2008-05-12 20:22:45 +00003213def ATOMAND32 : I<0, Pseudo, (outs GR32:$dst),(ins i32mem:$ptr, GR32:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003214 "#ATOMAND32 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003215 [(set GR32:$dst, (atomic_load_and_32 addr:$ptr, GR32:$val))]>;
Dan Gohman8aeb61f2008-05-12 20:22:45 +00003216def ATOMOR32 : I<0, Pseudo, (outs GR32:$dst),(ins i32mem:$ptr, GR32:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003217 "#ATOMOR32 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003218 [(set GR32:$dst, (atomic_load_or_32 addr:$ptr, GR32:$val))]>;
Dan Gohman8aeb61f2008-05-12 20:22:45 +00003219def ATOMXOR32 : I<0, Pseudo,(outs GR32:$dst),(ins i32mem:$ptr, GR32:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003220 "#ATOMXOR32 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003221 [(set GR32:$dst, (atomic_load_xor_32 addr:$ptr, GR32:$val))]>;
Andrew Lenharthaf02d592008-06-14 05:48:15 +00003222def ATOMNAND32 : I<0, Pseudo,(outs GR32:$dst),(ins i32mem:$ptr, GR32:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003223 "#ATOMNAND32 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003224 [(set GR32:$dst, (atomic_load_nand_32 addr:$ptr, GR32:$val))]>;
Dan Gohman8aeb61f2008-05-12 20:22:45 +00003225def ATOMMIN32: I<0, Pseudo, (outs GR32:$dst), (ins i32mem:$ptr, GR32:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003226 "#ATOMMIN32 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003227 [(set GR32:$dst, (atomic_load_min_32 addr:$ptr, GR32:$val))]>;
Dan Gohman8aeb61f2008-05-12 20:22:45 +00003228def ATOMMAX32: I<0, Pseudo, (outs GR32:$dst),(ins i32mem:$ptr, GR32:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003229 "#ATOMMAX32 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003230 [(set GR32:$dst, (atomic_load_max_32 addr:$ptr, GR32:$val))]>;
Dan Gohman8aeb61f2008-05-12 20:22:45 +00003231def ATOMUMIN32: I<0, Pseudo, (outs GR32:$dst),(ins i32mem:$ptr, GR32:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003232 "#ATOMUMIN32 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003233 [(set GR32:$dst, (atomic_load_umin_32 addr:$ptr, GR32:$val))]>;
Dan Gohman8aeb61f2008-05-12 20:22:45 +00003234def ATOMUMAX32: I<0, Pseudo, (outs GR32:$dst),(ins i32mem:$ptr, GR32:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003235 "#ATOMUMAX32 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003236 [(set GR32:$dst, (atomic_load_umax_32 addr:$ptr, GR32:$val))]>;
Dale Johannesend20e4452008-08-19 18:47:28 +00003237
3238def ATOMAND16 : I<0, Pseudo, (outs GR16:$dst),(ins i16mem:$ptr, GR16:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003239 "#ATOMAND16 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003240 [(set GR16:$dst, (atomic_load_and_16 addr:$ptr, GR16:$val))]>;
Dale Johannesend20e4452008-08-19 18:47:28 +00003241def ATOMOR16 : I<0, Pseudo, (outs GR16:$dst),(ins i16mem:$ptr, GR16:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003242 "#ATOMOR16 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003243 [(set GR16:$dst, (atomic_load_or_16 addr:$ptr, GR16:$val))]>;
Dale Johannesend20e4452008-08-19 18:47:28 +00003244def ATOMXOR16 : I<0, Pseudo,(outs GR16:$dst),(ins i16mem:$ptr, GR16:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003245 "#ATOMXOR16 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003246 [(set GR16:$dst, (atomic_load_xor_16 addr:$ptr, GR16:$val))]>;
Dale Johannesend20e4452008-08-19 18:47:28 +00003247def ATOMNAND16 : I<0, Pseudo,(outs GR16:$dst),(ins i16mem:$ptr, GR16:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003248 "#ATOMNAND16 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003249 [(set GR16:$dst, (atomic_load_nand_16 addr:$ptr, GR16:$val))]>;
Dale Johannesend20e4452008-08-19 18:47:28 +00003250def ATOMMIN16: I<0, Pseudo, (outs GR16:$dst), (ins i16mem:$ptr, GR16:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003251 "#ATOMMIN16 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003252 [(set GR16:$dst, (atomic_load_min_16 addr:$ptr, GR16:$val))]>;
Dale Johannesend20e4452008-08-19 18:47:28 +00003253def ATOMMAX16: I<0, Pseudo, (outs GR16:$dst),(ins i16mem:$ptr, GR16:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003254 "#ATOMMAX16 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003255 [(set GR16:$dst, (atomic_load_max_16 addr:$ptr, GR16:$val))]>;
Dale Johannesend20e4452008-08-19 18:47:28 +00003256def ATOMUMIN16: I<0, Pseudo, (outs GR16:$dst),(ins i16mem:$ptr, GR16:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003257 "#ATOMUMIN16 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003258 [(set GR16:$dst, (atomic_load_umin_16 addr:$ptr, GR16:$val))]>;
Dale Johannesend20e4452008-08-19 18:47:28 +00003259def ATOMUMAX16: I<0, Pseudo, (outs GR16:$dst),(ins i16mem:$ptr, GR16:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003260 "#ATOMUMAX16 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003261 [(set GR16:$dst, (atomic_load_umax_16 addr:$ptr, GR16:$val))]>;
Dale Johannesend20e4452008-08-19 18:47:28 +00003262
3263def ATOMAND8 : I<0, Pseudo, (outs GR8:$dst),(ins i8mem:$ptr, GR8:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003264 "#ATOMAND8 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003265 [(set GR8:$dst, (atomic_load_and_8 addr:$ptr, GR8:$val))]>;
Dale Johannesend20e4452008-08-19 18:47:28 +00003266def ATOMOR8 : I<0, Pseudo, (outs GR8:$dst),(ins i8mem:$ptr, GR8:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003267 "#ATOMOR8 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003268 [(set GR8:$dst, (atomic_load_or_8 addr:$ptr, GR8:$val))]>;
Dale Johannesend20e4452008-08-19 18:47:28 +00003269def ATOMXOR8 : I<0, Pseudo,(outs GR8:$dst),(ins i8mem:$ptr, GR8:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003270 "#ATOMXOR8 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003271 [(set GR8:$dst, (atomic_load_xor_8 addr:$ptr, GR8:$val))]>;
Dale Johannesend20e4452008-08-19 18:47:28 +00003272def ATOMNAND8 : I<0, Pseudo,(outs GR8:$dst),(ins i8mem:$ptr, GR8:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003273 "#ATOMNAND8 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003274 [(set GR8:$dst, (atomic_load_nand_8 addr:$ptr, GR8:$val))]>;
Mon P Wang078a62d2008-05-05 19:05:59 +00003275}
3276
Dale Johannesenf160d802008-10-02 18:53:47 +00003277let Constraints = "$val1 = $dst1, $val2 = $dst2",
3278 Defs = [EFLAGS, EAX, EBX, ECX, EDX],
3279 Uses = [EAX, EBX, ECX, EDX],
Dale Johannesen44eb5372008-10-03 19:41:08 +00003280 mayLoad = 1, mayStore = 1,
Dale Johannesenf160d802008-10-02 18:53:47 +00003281 usesCustomDAGSchedInserter = 1 in {
3282def ATOMAND6432 : I<0, Pseudo, (outs GR32:$dst1, GR32:$dst2),
3283 (ins i64mem:$ptr, GR32:$val1, GR32:$val2),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003284 "#ATOMAND6432 PSEUDO!", []>;
Dale Johannesenf160d802008-10-02 18:53:47 +00003285def ATOMOR6432 : I<0, Pseudo, (outs GR32:$dst1, GR32:$dst2),
3286 (ins i64mem:$ptr, GR32:$val1, GR32:$val2),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003287 "#ATOMOR6432 PSEUDO!", []>;
Dale Johannesenf160d802008-10-02 18:53:47 +00003288def ATOMXOR6432 : I<0, Pseudo, (outs GR32:$dst1, GR32:$dst2),
3289 (ins i64mem:$ptr, GR32:$val1, GR32:$val2),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003290 "#ATOMXOR6432 PSEUDO!", []>;
Dale Johannesenf160d802008-10-02 18:53:47 +00003291def ATOMNAND6432 : I<0, Pseudo, (outs GR32:$dst1, GR32:$dst2),
3292 (ins i64mem:$ptr, GR32:$val1, GR32:$val2),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003293 "#ATOMNAND6432 PSEUDO!", []>;
Dale Johannesenf160d802008-10-02 18:53:47 +00003294def ATOMADD6432 : I<0, Pseudo, (outs GR32:$dst1, GR32:$dst2),
3295 (ins i64mem:$ptr, GR32:$val1, GR32:$val2),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003296 "#ATOMADD6432 PSEUDO!", []>;
Dale Johannesenf160d802008-10-02 18:53:47 +00003297def ATOMSUB6432 : I<0, Pseudo, (outs GR32:$dst1, GR32:$dst2),
3298 (ins i64mem:$ptr, GR32:$val1, GR32:$val2),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003299 "#ATOMSUB6432 PSEUDO!", []>;
Dale Johannesen51c58ee2008-10-03 22:25:52 +00003300def ATOMSWAP6432 : I<0, Pseudo, (outs GR32:$dst1, GR32:$dst2),
3301 (ins i64mem:$ptr, GR32:$val1, GR32:$val2),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003302 "#ATOMSWAP6432 PSEUDO!", []>;
Dale Johannesenf160d802008-10-02 18:53:47 +00003303}
3304
Andrew Lenharthe44f3902008-02-21 06:45:13 +00003305//===----------------------------------------------------------------------===//
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003306// Non-Instruction Patterns
3307//===----------------------------------------------------------------------===//
3308
Bill Wendlingfef06052008-09-16 21:48:12 +00003309// ConstantPool GlobalAddress, ExternalSymbol, and JumpTable
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003310def : Pat<(i32 (X86Wrapper tconstpool :$dst)), (MOV32ri tconstpool :$dst)>;
3311def : Pat<(i32 (X86Wrapper tjumptable :$dst)), (MOV32ri tjumptable :$dst)>;
Nate Begemanb52948972008-04-12 00:47:57 +00003312def : Pat<(i32 (X86Wrapper tglobaltlsaddr:$dst)),(MOV32ri tglobaltlsaddr:$dst)>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003313def : Pat<(i32 (X86Wrapper tglobaladdr :$dst)), (MOV32ri tglobaladdr :$dst)>;
3314def : Pat<(i32 (X86Wrapper texternalsym:$dst)), (MOV32ri texternalsym:$dst)>;
3315
3316def : Pat<(add GR32:$src1, (X86Wrapper tconstpool:$src2)),
3317 (ADD32ri GR32:$src1, tconstpool:$src2)>;
3318def : Pat<(add GR32:$src1, (X86Wrapper tjumptable:$src2)),
3319 (ADD32ri GR32:$src1, tjumptable:$src2)>;
3320def : Pat<(add GR32:$src1, (X86Wrapper tglobaladdr :$src2)),
3321 (ADD32ri GR32:$src1, tglobaladdr:$src2)>;
3322def : Pat<(add GR32:$src1, (X86Wrapper texternalsym:$src2)),
3323 (ADD32ri GR32:$src1, texternalsym:$src2)>;
3324
3325def : Pat<(store (i32 (X86Wrapper tglobaladdr:$src)), addr:$dst),
3326 (MOV32mi addr:$dst, tglobaladdr:$src)>;
3327def : Pat<(store (i32 (X86Wrapper texternalsym:$src)), addr:$dst),
3328 (MOV32mi addr:$dst, texternalsym:$src)>;
3329
3330// Calls
Arnold Schwaighofere2d6bbb2007-10-11 19:40:01 +00003331// tailcall stuff
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003332def : Pat<(X86tailcall GR32:$dst),
Arnold Schwaighofere2d6bbb2007-10-11 19:40:01 +00003333 (TAILCALL)>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003334
3335def : Pat<(X86tailcall (i32 tglobaladdr:$dst)),
Arnold Schwaighofere2d6bbb2007-10-11 19:40:01 +00003336 (TAILCALL)>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003337def : Pat<(X86tailcall (i32 texternalsym:$dst)),
Arnold Schwaighofere2d6bbb2007-10-11 19:40:01 +00003338 (TAILCALL)>;
3339
3340def : Pat<(X86tcret GR32:$dst, imm:$off),
3341 (TCRETURNri GR32:$dst, imm:$off)>;
3342
3343def : Pat<(X86tcret (i32 tglobaladdr:$dst), imm:$off),
3344 (TCRETURNdi texternalsym:$dst, imm:$off)>;
3345
3346def : Pat<(X86tcret (i32 texternalsym:$dst), imm:$off),
3347 (TCRETURNdi texternalsym:$dst, imm:$off)>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003348
3349def : Pat<(X86call (i32 tglobaladdr:$dst)),
3350 (CALLpcrel32 tglobaladdr:$dst)>;
3351def : Pat<(X86call (i32 texternalsym:$dst)),
3352 (CALLpcrel32 texternalsym:$dst)>;
Evan Cheng6d35a4d2009-05-20 04:53:57 +00003353def : Pat<(X86call (i32 imm:$dst)),
3354 (CALLpcrel32 imm:$dst)>, Requires<[CallImmAddr]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003355
3356// X86 specific add which produces a flag.
3357def : Pat<(addc GR32:$src1, GR32:$src2),
3358 (ADD32rr GR32:$src1, GR32:$src2)>;
3359def : Pat<(addc GR32:$src1, (load addr:$src2)),
3360 (ADD32rm GR32:$src1, addr:$src2)>;
3361def : Pat<(addc GR32:$src1, imm:$src2),
3362 (ADD32ri GR32:$src1, imm:$src2)>;
3363def : Pat<(addc GR32:$src1, i32immSExt8:$src2),
3364 (ADD32ri8 GR32:$src1, i32immSExt8:$src2)>;
3365
3366def : Pat<(subc GR32:$src1, GR32:$src2),
3367 (SUB32rr GR32:$src1, GR32:$src2)>;
3368def : Pat<(subc GR32:$src1, (load addr:$src2)),
3369 (SUB32rm GR32:$src1, addr:$src2)>;
3370def : Pat<(subc GR32:$src1, imm:$src2),
3371 (SUB32ri GR32:$src1, imm:$src2)>;
3372def : Pat<(subc GR32:$src1, i32immSExt8:$src2),
3373 (SUB32ri8 GR32:$src1, i32immSExt8:$src2)>;
3374
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003375// Comparisons.
3376
3377// TEST R,R is smaller than CMP R,0
Evan Cheng621216e2007-09-29 00:00:36 +00003378def : Pat<(parallel (X86cmp GR8:$src1, 0), (implicit EFLAGS)),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003379 (TEST8rr GR8:$src1, GR8:$src1)>;
Evan Cheng621216e2007-09-29 00:00:36 +00003380def : Pat<(parallel (X86cmp GR16:$src1, 0), (implicit EFLAGS)),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003381 (TEST16rr GR16:$src1, GR16:$src1)>;
Evan Cheng621216e2007-09-29 00:00:36 +00003382def : Pat<(parallel (X86cmp GR32:$src1, 0), (implicit EFLAGS)),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003383 (TEST32rr GR32:$src1, GR32:$src1)>;
3384
Dan Gohman0a3c5222009-01-07 01:00:24 +00003385// Conditional moves with folded loads with operands swapped and conditions
3386// inverted.
3387def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_B, EFLAGS),
3388 (CMOVAE16rm GR16:$src2, addr:$src1)>;
3389def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_B, EFLAGS),
3390 (CMOVAE32rm GR32:$src2, addr:$src1)>;
3391def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_AE, EFLAGS),
3392 (CMOVB16rm GR16:$src2, addr:$src1)>;
3393def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_AE, EFLAGS),
3394 (CMOVB32rm GR32:$src2, addr:$src1)>;
3395def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_E, EFLAGS),
3396 (CMOVNE16rm GR16:$src2, addr:$src1)>;
3397def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_E, EFLAGS),
3398 (CMOVNE32rm GR32:$src2, addr:$src1)>;
3399def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_NE, EFLAGS),
3400 (CMOVE16rm GR16:$src2, addr:$src1)>;
3401def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_NE, EFLAGS),
3402 (CMOVE32rm GR32:$src2, addr:$src1)>;
3403def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_BE, EFLAGS),
3404 (CMOVA16rm GR16:$src2, addr:$src1)>;
3405def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_BE, EFLAGS),
3406 (CMOVA32rm GR32:$src2, addr:$src1)>;
3407def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_A, EFLAGS),
3408 (CMOVBE16rm GR16:$src2, addr:$src1)>;
3409def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_A, EFLAGS),
3410 (CMOVBE32rm GR32:$src2, addr:$src1)>;
3411def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_L, EFLAGS),
3412 (CMOVGE16rm GR16:$src2, addr:$src1)>;
3413def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_L, EFLAGS),
3414 (CMOVGE32rm GR32:$src2, addr:$src1)>;
3415def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_GE, EFLAGS),
3416 (CMOVL16rm GR16:$src2, addr:$src1)>;
3417def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_GE, EFLAGS),
3418 (CMOVL32rm GR32:$src2, addr:$src1)>;
3419def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_LE, EFLAGS),
3420 (CMOVG16rm GR16:$src2, addr:$src1)>;
3421def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_LE, EFLAGS),
3422 (CMOVG32rm GR32:$src2, addr:$src1)>;
3423def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_G, EFLAGS),
3424 (CMOVLE16rm GR16:$src2, addr:$src1)>;
3425def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_G, EFLAGS),
3426 (CMOVLE32rm GR32:$src2, addr:$src1)>;
3427def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_P, EFLAGS),
3428 (CMOVNP16rm GR16:$src2, addr:$src1)>;
3429def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_P, EFLAGS),
3430 (CMOVNP32rm GR32:$src2, addr:$src1)>;
3431def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_NP, EFLAGS),
3432 (CMOVP16rm GR16:$src2, addr:$src1)>;
3433def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_NP, EFLAGS),
3434 (CMOVP32rm GR32:$src2, addr:$src1)>;
3435def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_S, EFLAGS),
3436 (CMOVNS16rm GR16:$src2, addr:$src1)>;
3437def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_S, EFLAGS),
3438 (CMOVNS32rm GR32:$src2, addr:$src1)>;
3439def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_NS, EFLAGS),
3440 (CMOVS16rm GR16:$src2, addr:$src1)>;
3441def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_NS, EFLAGS),
3442 (CMOVS32rm GR32:$src2, addr:$src1)>;
3443def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_O, EFLAGS),
3444 (CMOVNO16rm GR16:$src2, addr:$src1)>;
3445def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_O, EFLAGS),
3446 (CMOVNO32rm GR32:$src2, addr:$src1)>;
3447def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_NO, EFLAGS),
3448 (CMOVO16rm GR16:$src2, addr:$src1)>;
3449def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_NO, EFLAGS),
3450 (CMOVO32rm GR32:$src2, addr:$src1)>;
3451
Duncan Sands082524c2008-01-23 20:39:46 +00003452// zextload bool -> zextload byte
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003453def : Pat<(zextloadi8i1 addr:$src), (MOV8rm addr:$src)>;
3454def : Pat<(zextloadi16i1 addr:$src), (MOVZX16rm8 addr:$src)>;
3455def : Pat<(zextloadi32i1 addr:$src), (MOVZX32rm8 addr:$src)>;
3456
3457// extload bool -> extload byte
3458def : Pat<(extloadi8i1 addr:$src), (MOV8rm addr:$src)>;
Bill Wendlingce1c5c12008-08-22 20:51:05 +00003459def : Pat<(extloadi16i1 addr:$src), (MOVZX16rm8 addr:$src)>,
3460 Requires<[In32BitMode]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003461def : Pat<(extloadi32i1 addr:$src), (MOVZX32rm8 addr:$src)>;
Bill Wendlingce1c5c12008-08-22 20:51:05 +00003462def : Pat<(extloadi16i8 addr:$src), (MOVZX16rm8 addr:$src)>,
3463 Requires<[In32BitMode]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003464def : Pat<(extloadi32i8 addr:$src), (MOVZX32rm8 addr:$src)>;
3465def : Pat<(extloadi32i16 addr:$src), (MOVZX32rm16 addr:$src)>;
3466
Dan Gohmandd612bb2008-08-20 21:27:32 +00003467// anyext
Bill Wendlingce1c5c12008-08-22 20:51:05 +00003468def : Pat<(i16 (anyext GR8 :$src)), (MOVZX16rr8 GR8 :$src)>,
3469 Requires<[In32BitMode]>;
3470def : Pat<(i32 (anyext GR8 :$src)), (MOVZX32rr8 GR8 :$src)>,
3471 Requires<[In32BitMode]>;
Dan Gohmandd612bb2008-08-20 21:27:32 +00003472def : Pat<(i32 (anyext GR16:$src)),
3473 (INSERT_SUBREG (i32 (IMPLICIT_DEF)), GR16:$src, x86_subreg_16bit)>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003474
Evan Chengf2abee72007-12-13 00:43:27 +00003475// (and (i32 load), 255) -> (zextload i8)
Evan Cheng1e5e5452008-09-29 17:26:18 +00003476def : Pat<(i32 (and (nvloadi32 addr:$src), (i32 255))),
3477 (MOVZX32rm8 addr:$src)>;
3478def : Pat<(i32 (and (nvloadi32 addr:$src), (i32 65535))),
3479 (MOVZX32rm16 addr:$src)>;
Evan Chengf2abee72007-12-13 00:43:27 +00003480
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003481//===----------------------------------------------------------------------===//
3482// Some peepholes
3483//===----------------------------------------------------------------------===//
3484
Dan Gohman5a5e6e92008-10-17 01:33:43 +00003485// Odd encoding trick: -128 fits into an 8-bit immediate field while
3486// +128 doesn't, so in this special case use a sub instead of an add.
3487def : Pat<(add GR16:$src1, 128),
3488 (SUB16ri8 GR16:$src1, -128)>;
3489def : Pat<(store (add (loadi16 addr:$dst), 128), addr:$dst),
3490 (SUB16mi8 addr:$dst, -128)>;
3491def : Pat<(add GR32:$src1, 128),
3492 (SUB32ri8 GR32:$src1, -128)>;
3493def : Pat<(store (add (loadi32 addr:$dst), 128), addr:$dst),
3494 (SUB32mi8 addr:$dst, -128)>;
3495
Dan Gohman9203ab42008-07-30 18:09:17 +00003496// r & (2^16-1) ==> movz
3497def : Pat<(and GR32:$src1, 0xffff),
Dan Gohman744d4622009-04-13 16:09:41 +00003498 (MOVZX32rr16 (EXTRACT_SUBREG GR32:$src1, x86_subreg_16bit))>;
Dan Gohman5beb1ff2008-08-06 18:27:21 +00003499// r & (2^8-1) ==> movz
3500def : Pat<(and GR32:$src1, 0xff),
Dan Gohman6e438702009-04-27 16:33:14 +00003501 (MOVZX32rr8 (EXTRACT_SUBREG (COPY_TO_REGCLASS GR32:$src1, GR32_ABCD),
Dan Gohman744d4622009-04-13 16:09:41 +00003502 x86_subreg_8bit))>,
Dan Gohman5beb1ff2008-08-06 18:27:21 +00003503 Requires<[In32BitMode]>;
3504// r & (2^8-1) ==> movz
3505def : Pat<(and GR16:$src1, 0xff),
Dan Gohman6e438702009-04-27 16:33:14 +00003506 (MOVZX16rr8 (EXTRACT_SUBREG (COPY_TO_REGCLASS GR16:$src1, GR16_ABCD),
Dan Gohman744d4622009-04-13 16:09:41 +00003507 x86_subreg_8bit))>,
Dan Gohmandd612bb2008-08-20 21:27:32 +00003508 Requires<[In32BitMode]>;
3509
3510// sext_inreg patterns
3511def : Pat<(sext_inreg GR32:$src, i16),
Dan Gohman744d4622009-04-13 16:09:41 +00003512 (MOVSX32rr16 (EXTRACT_SUBREG GR32:$src, x86_subreg_16bit))>;
Dan Gohmandd612bb2008-08-20 21:27:32 +00003513def : Pat<(sext_inreg GR32:$src, i8),
Dan Gohman6e438702009-04-27 16:33:14 +00003514 (MOVSX32rr8 (EXTRACT_SUBREG (COPY_TO_REGCLASS GR32:$src, GR32_ABCD),
Dan Gohman744d4622009-04-13 16:09:41 +00003515 x86_subreg_8bit))>,
Dan Gohmandd612bb2008-08-20 21:27:32 +00003516 Requires<[In32BitMode]>;
3517def : Pat<(sext_inreg GR16:$src, i8),
Dan Gohman6e438702009-04-27 16:33:14 +00003518 (MOVSX16rr8 (EXTRACT_SUBREG (COPY_TO_REGCLASS GR16:$src, GR16_ABCD),
Dan Gohman744d4622009-04-13 16:09:41 +00003519 x86_subreg_8bit))>,
Dan Gohmandd612bb2008-08-20 21:27:32 +00003520 Requires<[In32BitMode]>;
3521
3522// trunc patterns
3523def : Pat<(i16 (trunc GR32:$src)),
Dan Gohman744d4622009-04-13 16:09:41 +00003524 (EXTRACT_SUBREG GR32:$src, x86_subreg_16bit)>;
Dan Gohmandd612bb2008-08-20 21:27:32 +00003525def : Pat<(i8 (trunc GR32:$src)),
Dan Gohman6e438702009-04-27 16:33:14 +00003526 (EXTRACT_SUBREG (COPY_TO_REGCLASS GR32:$src, GR32_ABCD),
Dan Gohman744d4622009-04-13 16:09:41 +00003527 x86_subreg_8bit)>,
Dan Gohmandd612bb2008-08-20 21:27:32 +00003528 Requires<[In32BitMode]>;
3529def : Pat<(i8 (trunc GR16:$src)),
Dan Gohman6e438702009-04-27 16:33:14 +00003530 (EXTRACT_SUBREG (COPY_TO_REGCLASS GR16:$src, GR16_ABCD),
Dan Gohman744d4622009-04-13 16:09:41 +00003531 x86_subreg_8bit)>,
3532 Requires<[In32BitMode]>;
3533
3534// h-register tricks
3535def : Pat<(i8 (trunc (srl_su GR16:$src, (i8 8)))),
Dan Gohman6e438702009-04-27 16:33:14 +00003536 (EXTRACT_SUBREG (COPY_TO_REGCLASS GR16:$src, GR16_ABCD),
Dan Gohman744d4622009-04-13 16:09:41 +00003537 x86_subreg_8bit_hi)>,
3538 Requires<[In32BitMode]>;
3539def : Pat<(i8 (trunc (srl_su GR32:$src, (i8 8)))),
Dan Gohman6e438702009-04-27 16:33:14 +00003540 (EXTRACT_SUBREG (COPY_TO_REGCLASS GR32:$src, GR32_ABCD),
Dan Gohman744d4622009-04-13 16:09:41 +00003541 x86_subreg_8bit_hi)>,
3542 Requires<[In32BitMode]>;
3543def : Pat<(srl_su GR16:$src, (i8 8)),
3544 (EXTRACT_SUBREG
3545 (MOVZX32rr8
Dan Gohman6e438702009-04-27 16:33:14 +00003546 (EXTRACT_SUBREG (COPY_TO_REGCLASS GR16:$src, GR16_ABCD),
Dan Gohman744d4622009-04-13 16:09:41 +00003547 x86_subreg_8bit_hi)),
3548 x86_subreg_16bit)>,
3549 Requires<[In32BitMode]>;
Evan Cheng957ca282009-05-29 01:44:43 +00003550def : Pat<(i32 (zext (srl_su GR16:$src, (i8 8)))),
3551 (MOVZX32rr8 (EXTRACT_SUBREG (COPY_TO_REGCLASS GR16:$src, GR16_ABCD),
3552 x86_subreg_8bit_hi))>,
3553 Requires<[In32BitMode]>;
Dan Gohman744d4622009-04-13 16:09:41 +00003554def : Pat<(and (srl_su GR32:$src, (i8 8)), (i32 255)),
Dan Gohman6e438702009-04-27 16:33:14 +00003555 (MOVZX32rr8 (EXTRACT_SUBREG (COPY_TO_REGCLASS GR32:$src, GR32_ABCD),
Dan Gohman744d4622009-04-13 16:09:41 +00003556 x86_subreg_8bit_hi))>,
Dan Gohman5beb1ff2008-08-06 18:27:21 +00003557 Requires<[In32BitMode]>;
Dan Gohman9203ab42008-07-30 18:09:17 +00003558
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003559// (shl x, 1) ==> (add x, x)
3560def : Pat<(shl GR8 :$src1, (i8 1)), (ADD8rr GR8 :$src1, GR8 :$src1)>;
3561def : Pat<(shl GR16:$src1, (i8 1)), (ADD16rr GR16:$src1, GR16:$src1)>;
3562def : Pat<(shl GR32:$src1, (i8 1)), (ADD32rr GR32:$src1, GR32:$src1)>;
3563
Evan Cheng76a64c72008-08-30 02:03:58 +00003564// (shl x (and y, 31)) ==> (shl x, y)
3565def : Pat<(shl GR8:$src1, (and CL:$amt, 31)),
3566 (SHL8rCL GR8:$src1)>;
3567def : Pat<(shl GR16:$src1, (and CL:$amt, 31)),
3568 (SHL16rCL GR16:$src1)>;
3569def : Pat<(shl GR32:$src1, (and CL:$amt, 31)),
3570 (SHL32rCL GR32:$src1)>;
3571def : Pat<(store (shl (loadi8 addr:$dst), (and CL:$amt, 31)), addr:$dst),
3572 (SHL8mCL addr:$dst)>;
3573def : Pat<(store (shl (loadi16 addr:$dst), (and CL:$amt, 31)), addr:$dst),
3574 (SHL16mCL addr:$dst)>;
3575def : Pat<(store (shl (loadi32 addr:$dst), (and CL:$amt, 31)), addr:$dst),
3576 (SHL32mCL addr:$dst)>;
3577
3578def : Pat<(srl GR8:$src1, (and CL:$amt, 31)),
3579 (SHR8rCL GR8:$src1)>;
3580def : Pat<(srl GR16:$src1, (and CL:$amt, 31)),
3581 (SHR16rCL GR16:$src1)>;
3582def : Pat<(srl GR32:$src1, (and CL:$amt, 31)),
3583 (SHR32rCL GR32:$src1)>;
3584def : Pat<(store (srl (loadi8 addr:$dst), (and CL:$amt, 31)), addr:$dst),
3585 (SHR8mCL addr:$dst)>;
3586def : Pat<(store (srl (loadi16 addr:$dst), (and CL:$amt, 31)), addr:$dst),
3587 (SHR16mCL addr:$dst)>;
3588def : Pat<(store (srl (loadi32 addr:$dst), (and CL:$amt, 31)), addr:$dst),
3589 (SHR32mCL addr:$dst)>;
3590
3591def : Pat<(sra GR8:$src1, (and CL:$amt, 31)),
3592 (SAR8rCL GR8:$src1)>;
3593def : Pat<(sra GR16:$src1, (and CL:$amt, 31)),
3594 (SAR16rCL GR16:$src1)>;
3595def : Pat<(sra GR32:$src1, (and CL:$amt, 31)),
3596 (SAR32rCL GR32:$src1)>;
3597def : Pat<(store (sra (loadi8 addr:$dst), (and CL:$amt, 31)), addr:$dst),
3598 (SAR8mCL addr:$dst)>;
3599def : Pat<(store (sra (loadi16 addr:$dst), (and CL:$amt, 31)), addr:$dst),
3600 (SAR16mCL addr:$dst)>;
3601def : Pat<(store (sra (loadi32 addr:$dst), (and CL:$amt, 31)), addr:$dst),
3602 (SAR32mCL addr:$dst)>;
3603
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003604// (or (x >> c) | (y << (32 - c))) ==> (shrd32 x, y, c)
3605def : Pat<(or (srl GR32:$src1, CL:$amt),
3606 (shl GR32:$src2, (sub 32, CL:$amt))),
3607 (SHRD32rrCL GR32:$src1, GR32:$src2)>;
3608
3609def : Pat<(store (or (srl (loadi32 addr:$dst), CL:$amt),
3610 (shl GR32:$src2, (sub 32, CL:$amt))), addr:$dst),
3611 (SHRD32mrCL addr:$dst, GR32:$src2)>;
3612
Dan Gohman921581d2008-10-17 01:23:35 +00003613def : Pat<(or (srl GR32:$src1, (i8 (trunc ECX:$amt))),
3614 (shl GR32:$src2, (i8 (trunc (sub 32, ECX:$amt))))),
3615 (SHRD32rrCL GR32:$src1, GR32:$src2)>;
3616
3617def : Pat<(store (or (srl (loadi32 addr:$dst), (i8 (trunc ECX:$amt))),
3618 (shl GR32:$src2, (i8 (trunc (sub 32, ECX:$amt))))),
3619 addr:$dst),
3620 (SHRD32mrCL addr:$dst, GR32:$src2)>;
3621
3622def : Pat<(shrd GR32:$src1, (i8 imm:$amt1), GR32:$src2, (i8 imm:$amt2)),
3623 (SHRD32rri8 GR32:$src1, GR32:$src2, (i8 imm:$amt1))>;
3624
3625def : Pat<(store (shrd (loadi32 addr:$dst), (i8 imm:$amt1),
3626 GR32:$src2, (i8 imm:$amt2)), addr:$dst),
3627 (SHRD32mri8 addr:$dst, GR32:$src2, (i8 imm:$amt1))>;
3628
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003629// (or (x << c) | (y >> (32 - c))) ==> (shld32 x, y, c)
3630def : Pat<(or (shl GR32:$src1, CL:$amt),
3631 (srl GR32:$src2, (sub 32, CL:$amt))),
3632 (SHLD32rrCL GR32:$src1, GR32:$src2)>;
3633
3634def : Pat<(store (or (shl (loadi32 addr:$dst), CL:$amt),
3635 (srl GR32:$src2, (sub 32, CL:$amt))), addr:$dst),
3636 (SHLD32mrCL addr:$dst, GR32:$src2)>;
3637
Dan Gohman921581d2008-10-17 01:23:35 +00003638def : Pat<(or (shl GR32:$src1, (i8 (trunc ECX:$amt))),
3639 (srl GR32:$src2, (i8 (trunc (sub 32, ECX:$amt))))),
3640 (SHLD32rrCL GR32:$src1, GR32:$src2)>;
3641
3642def : Pat<(store (or (shl (loadi32 addr:$dst), (i8 (trunc ECX:$amt))),
3643 (srl GR32:$src2, (i8 (trunc (sub 32, ECX:$amt))))),
3644 addr:$dst),
3645 (SHLD32mrCL addr:$dst, GR32:$src2)>;
3646
3647def : Pat<(shld GR32:$src1, (i8 imm:$amt1), GR32:$src2, (i8 imm:$amt2)),
3648 (SHLD32rri8 GR32:$src1, GR32:$src2, (i8 imm:$amt1))>;
3649
3650def : Pat<(store (shld (loadi32 addr:$dst), (i8 imm:$amt1),
3651 GR32:$src2, (i8 imm:$amt2)), addr:$dst),
3652 (SHLD32mri8 addr:$dst, GR32:$src2, (i8 imm:$amt1))>;
3653
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003654// (or (x >> c) | (y << (16 - c))) ==> (shrd16 x, y, c)
3655def : Pat<(or (srl GR16:$src1, CL:$amt),
3656 (shl GR16:$src2, (sub 16, CL:$amt))),
3657 (SHRD16rrCL GR16:$src1, GR16:$src2)>;
3658
3659def : Pat<(store (or (srl (loadi16 addr:$dst), CL:$amt),
3660 (shl GR16:$src2, (sub 16, CL:$amt))), addr:$dst),
3661 (SHRD16mrCL addr:$dst, GR16:$src2)>;
3662
Dan Gohman921581d2008-10-17 01:23:35 +00003663def : Pat<(or (srl GR16:$src1, (i8 (trunc CX:$amt))),
3664 (shl GR16:$src2, (i8 (trunc (sub 16, CX:$amt))))),
3665 (SHRD16rrCL GR16:$src1, GR16:$src2)>;
3666
3667def : Pat<(store (or (srl (loadi16 addr:$dst), (i8 (trunc CX:$amt))),
3668 (shl GR16:$src2, (i8 (trunc (sub 16, CX:$amt))))),
3669 addr:$dst),
3670 (SHRD16mrCL addr:$dst, GR16:$src2)>;
3671
3672def : Pat<(shrd GR16:$src1, (i8 imm:$amt1), GR16:$src2, (i8 imm:$amt2)),
3673 (SHRD16rri8 GR16:$src1, GR16:$src2, (i8 imm:$amt1))>;
3674
3675def : Pat<(store (shrd (loadi16 addr:$dst), (i8 imm:$amt1),
3676 GR16:$src2, (i8 imm:$amt2)), addr:$dst),
3677 (SHRD16mri8 addr:$dst, GR16:$src2, (i8 imm:$amt1))>;
3678
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003679// (or (x << c) | (y >> (16 - c))) ==> (shld16 x, y, c)
3680def : Pat<(or (shl GR16:$src1, CL:$amt),
3681 (srl GR16:$src2, (sub 16, CL:$amt))),
3682 (SHLD16rrCL GR16:$src1, GR16:$src2)>;
3683
3684def : Pat<(store (or (shl (loadi16 addr:$dst), CL:$amt),
3685 (srl GR16:$src2, (sub 16, CL:$amt))), addr:$dst),
3686 (SHLD16mrCL addr:$dst, GR16:$src2)>;
3687
Dan Gohman921581d2008-10-17 01:23:35 +00003688def : Pat<(or (shl GR16:$src1, (i8 (trunc CX:$amt))),
3689 (srl GR16:$src2, (i8 (trunc (sub 16, CX:$amt))))),
3690 (SHLD16rrCL GR16:$src1, GR16:$src2)>;
3691
3692def : Pat<(store (or (shl (loadi16 addr:$dst), (i8 (trunc CX:$amt))),
3693 (srl GR16:$src2, (i8 (trunc (sub 16, CX:$amt))))),
3694 addr:$dst),
3695 (SHLD16mrCL addr:$dst, GR16:$src2)>;
3696
3697def : Pat<(shld GR16:$src1, (i8 imm:$amt1), GR16:$src2, (i8 imm:$amt2)),
3698 (SHLD16rri8 GR16:$src1, GR16:$src2, (i8 imm:$amt1))>;
3699
3700def : Pat<(store (shld (loadi16 addr:$dst), (i8 imm:$amt1),
3701 GR16:$src2, (i8 imm:$amt2)), addr:$dst),
3702 (SHLD16mri8 addr:$dst, GR16:$src2, (i8 imm:$amt1))>;
3703
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003704//===----------------------------------------------------------------------===//
Dan Gohman99a12192009-03-04 19:44:21 +00003705// EFLAGS-defining Patterns
Bill Wendlingf5399032008-12-12 21:15:41 +00003706//===----------------------------------------------------------------------===//
3707
Dan Gohman99a12192009-03-04 19:44:21 +00003708// Register-Register Addition with EFLAGS result
3709def : Pat<(parallel (X86add_flag GR8:$src1, GR8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003710 (implicit EFLAGS)),
3711 (ADD8rr GR8:$src1, GR8:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003712def : Pat<(parallel (X86add_flag GR16:$src1, GR16:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003713 (implicit EFLAGS)),
3714 (ADD16rr GR16:$src1, GR16:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003715def : Pat<(parallel (X86add_flag GR32:$src1, GR32:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003716 (implicit EFLAGS)),
3717 (ADD32rr GR32:$src1, GR32:$src2)>;
3718
Dan Gohman99a12192009-03-04 19:44:21 +00003719// Register-Memory Addition with EFLAGS result
3720def : Pat<(parallel (X86add_flag GR8:$src1, (loadi8 addr:$src2)),
Bill Wendlingf5399032008-12-12 21:15:41 +00003721 (implicit EFLAGS)),
3722 (ADD8rm GR8:$src1, addr:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003723def : Pat<(parallel (X86add_flag GR16:$src1, (loadi16 addr:$src2)),
Bill Wendlingf5399032008-12-12 21:15:41 +00003724 (implicit EFLAGS)),
3725 (ADD16rm GR16:$src1, addr:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003726def : Pat<(parallel (X86add_flag GR32:$src1, (loadi32 addr:$src2)),
Bill Wendlingf5399032008-12-12 21:15:41 +00003727 (implicit EFLAGS)),
3728 (ADD32rm GR32:$src1, addr:$src2)>;
3729
Dan Gohman99a12192009-03-04 19:44:21 +00003730// Register-Integer Addition with EFLAGS result
3731def : Pat<(parallel (X86add_flag GR8:$src1, imm:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003732 (implicit EFLAGS)),
3733 (ADD8ri GR8:$src1, imm:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003734def : Pat<(parallel (X86add_flag GR16:$src1, imm:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003735 (implicit EFLAGS)),
3736 (ADD16ri GR16:$src1, imm:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003737def : Pat<(parallel (X86add_flag GR32:$src1, imm:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003738 (implicit EFLAGS)),
3739 (ADD32ri GR32:$src1, imm:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003740def : Pat<(parallel (X86add_flag GR16:$src1, i16immSExt8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003741 (implicit EFLAGS)),
3742 (ADD16ri8 GR16:$src1, i16immSExt8:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003743def : Pat<(parallel (X86add_flag GR32:$src1, i32immSExt8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003744 (implicit EFLAGS)),
3745 (ADD32ri8 GR32:$src1, i32immSExt8:$src2)>;
3746
Dan Gohman99a12192009-03-04 19:44:21 +00003747// Memory-Register Addition with EFLAGS result
3748def : Pat<(parallel (store (X86add_flag (loadi8 addr:$dst), GR8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003749 addr:$dst),
3750 (implicit EFLAGS)),
3751 (ADD8mr addr:$dst, GR8:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003752def : Pat<(parallel (store (X86add_flag (loadi16 addr:$dst), GR16:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003753 addr:$dst),
3754 (implicit EFLAGS)),
3755 (ADD16mr addr:$dst, GR16:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003756def : Pat<(parallel (store (X86add_flag (loadi32 addr:$dst), GR32:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003757 addr:$dst),
3758 (implicit EFLAGS)),
3759 (ADD32mr addr:$dst, GR32:$src2)>;
Dale Johannesen06b83f12009-05-18 17:44:15 +00003760
3761// Memory-Integer Addition with EFLAGS result
Dan Gohman99a12192009-03-04 19:44:21 +00003762def : Pat<(parallel (store (X86add_flag (loadi8 addr:$dst), imm:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003763 addr:$dst),
3764 (implicit EFLAGS)),
3765 (ADD8mi addr:$dst, imm:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003766def : Pat<(parallel (store (X86add_flag (loadi16 addr:$dst), imm:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003767 addr:$dst),
3768 (implicit EFLAGS)),
3769 (ADD16mi addr:$dst, imm:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003770def : Pat<(parallel (store (X86add_flag (loadi32 addr:$dst), imm:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003771 addr:$dst),
3772 (implicit EFLAGS)),
3773 (ADD32mi addr:$dst, imm:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003774def : Pat<(parallel (store (X86add_flag (loadi16 addr:$dst), i16immSExt8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003775 addr:$dst),
3776 (implicit EFLAGS)),
3777 (ADD16mi8 addr:$dst, i16immSExt8:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003778def : Pat<(parallel (store (X86add_flag (loadi32 addr:$dst), i32immSExt8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003779 addr:$dst),
3780 (implicit EFLAGS)),
3781 (ADD32mi8 addr:$dst, i32immSExt8:$src2)>;
3782
Dan Gohman99a12192009-03-04 19:44:21 +00003783// Register-Register Subtraction with EFLAGS result
3784def : Pat<(parallel (X86sub_flag GR8:$src1, GR8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003785 (implicit EFLAGS)),
3786 (SUB8rr GR8:$src1, GR8:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003787def : Pat<(parallel (X86sub_flag GR16:$src1, GR16:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003788 (implicit EFLAGS)),
3789 (SUB16rr GR16:$src1, GR16:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003790def : Pat<(parallel (X86sub_flag GR32:$src1, GR32:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003791 (implicit EFLAGS)),
3792 (SUB32rr GR32:$src1, GR32:$src2)>;
3793
Dan Gohman99a12192009-03-04 19:44:21 +00003794// Register-Memory Subtraction with EFLAGS result
3795def : Pat<(parallel (X86sub_flag GR8:$src1, (loadi8 addr:$src2)),
Bill Wendlingf5399032008-12-12 21:15:41 +00003796 (implicit EFLAGS)),
3797 (SUB8rm GR8:$src1, addr:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003798def : Pat<(parallel (X86sub_flag GR16:$src1, (loadi16 addr:$src2)),
Bill Wendlingf5399032008-12-12 21:15:41 +00003799 (implicit EFLAGS)),
3800 (SUB16rm GR16:$src1, addr:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003801def : Pat<(parallel (X86sub_flag GR32:$src1, (loadi32 addr:$src2)),
Bill Wendlingf5399032008-12-12 21:15:41 +00003802 (implicit EFLAGS)),
3803 (SUB32rm GR32:$src1, addr:$src2)>;
3804
Dan Gohman99a12192009-03-04 19:44:21 +00003805// Register-Integer Subtraction with EFLAGS result
3806def : Pat<(parallel (X86sub_flag GR8:$src1, imm:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003807 (implicit EFLAGS)),
3808 (SUB8ri GR8:$src1, imm:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003809def : Pat<(parallel (X86sub_flag GR16:$src1, imm:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003810 (implicit EFLAGS)),
3811 (SUB16ri GR16:$src1, imm:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003812def : Pat<(parallel (X86sub_flag GR32:$src1, imm:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003813 (implicit EFLAGS)),
3814 (SUB32ri GR32:$src1, imm:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003815def : Pat<(parallel (X86sub_flag GR16:$src1, i16immSExt8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003816 (implicit EFLAGS)),
3817 (SUB16ri8 GR16:$src1, i16immSExt8:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003818def : Pat<(parallel (X86sub_flag GR32:$src1, i32immSExt8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003819 (implicit EFLAGS)),
3820 (SUB32ri8 GR32:$src1, i32immSExt8:$src2)>;
3821
Dan Gohman99a12192009-03-04 19:44:21 +00003822// Memory-Register Subtraction with EFLAGS result
3823def : Pat<(parallel (store (X86sub_flag (loadi8 addr:$dst), GR8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003824 addr:$dst),
3825 (implicit EFLAGS)),
3826 (SUB8mr addr:$dst, GR8:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003827def : Pat<(parallel (store (X86sub_flag (loadi16 addr:$dst), GR16:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003828 addr:$dst),
3829 (implicit EFLAGS)),
3830 (SUB16mr addr:$dst, GR16:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003831def : Pat<(parallel (store (X86sub_flag (loadi32 addr:$dst), GR32:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003832 addr:$dst),
3833 (implicit EFLAGS)),
3834 (SUB32mr addr:$dst, GR32:$src2)>;
3835
Dan Gohman99a12192009-03-04 19:44:21 +00003836// Memory-Integer Subtraction with EFLAGS result
3837def : Pat<(parallel (store (X86sub_flag (loadi8 addr:$dst), imm:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003838 addr:$dst),
3839 (implicit EFLAGS)),
3840 (SUB8mi addr:$dst, imm:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003841def : Pat<(parallel (store (X86sub_flag (loadi16 addr:$dst), imm:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003842 addr:$dst),
3843 (implicit EFLAGS)),
3844 (SUB16mi addr:$dst, imm:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003845def : Pat<(parallel (store (X86sub_flag (loadi32 addr:$dst), imm:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003846 addr:$dst),
3847 (implicit EFLAGS)),
3848 (SUB32mi addr:$dst, imm:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003849def : Pat<(parallel (store (X86sub_flag (loadi16 addr:$dst), i16immSExt8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003850 addr:$dst),
3851 (implicit EFLAGS)),
3852 (SUB16mi8 addr:$dst, i16immSExt8:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003853def : Pat<(parallel (store (X86sub_flag (loadi32 addr:$dst), i32immSExt8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003854 addr:$dst),
3855 (implicit EFLAGS)),
3856 (SUB32mi8 addr:$dst, i32immSExt8:$src2)>;
3857
3858
Dan Gohman99a12192009-03-04 19:44:21 +00003859// Register-Register Signed Integer Multiply with EFLAGS result
3860def : Pat<(parallel (X86smul_flag GR16:$src1, GR16:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003861 (implicit EFLAGS)),
3862 (IMUL16rr GR16:$src1, GR16:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003863def : Pat<(parallel (X86smul_flag GR32:$src1, GR32:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003864 (implicit EFLAGS)),
3865 (IMUL32rr GR32:$src1, GR32:$src2)>;
3866
Dan Gohman99a12192009-03-04 19:44:21 +00003867// Register-Memory Signed Integer Multiply with EFLAGS result
3868def : Pat<(parallel (X86smul_flag GR16:$src1, (loadi16 addr:$src2)),
Bill Wendlingf5399032008-12-12 21:15:41 +00003869 (implicit EFLAGS)),
3870 (IMUL16rm GR16:$src1, addr:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003871def : Pat<(parallel (X86smul_flag GR32:$src1, (loadi32 addr:$src2)),
Bill Wendlingf5399032008-12-12 21:15:41 +00003872 (implicit EFLAGS)),
3873 (IMUL32rm GR32:$src1, addr:$src2)>;
3874
Dan Gohman99a12192009-03-04 19:44:21 +00003875// Register-Integer Signed Integer Multiply with EFLAGS result
3876def : Pat<(parallel (X86smul_flag GR16:$src1, imm:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003877 (implicit EFLAGS)),
3878 (IMUL16rri GR16:$src1, imm:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003879def : Pat<(parallel (X86smul_flag GR32:$src1, imm:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003880 (implicit EFLAGS)),
3881 (IMUL32rri GR32:$src1, imm:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003882def : Pat<(parallel (X86smul_flag GR16:$src1, i16immSExt8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003883 (implicit EFLAGS)),
3884 (IMUL16rri8 GR16:$src1, i16immSExt8:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003885def : Pat<(parallel (X86smul_flag GR32:$src1, i32immSExt8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003886 (implicit EFLAGS)),
3887 (IMUL32rri8 GR32:$src1, i32immSExt8:$src2)>;
3888
Dan Gohman99a12192009-03-04 19:44:21 +00003889// Memory-Integer Signed Integer Multiply with EFLAGS result
3890def : Pat<(parallel (X86smul_flag (loadi16 addr:$src1), imm:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003891 (implicit EFLAGS)),
3892 (IMUL16rmi addr:$src1, imm:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003893def : Pat<(parallel (X86smul_flag (loadi32 addr:$src1), imm:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003894 (implicit EFLAGS)),
3895 (IMUL32rmi addr:$src1, imm:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003896def : Pat<(parallel (X86smul_flag (loadi16 addr:$src1), i16immSExt8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003897 (implicit EFLAGS)),
3898 (IMUL16rmi8 addr:$src1, i16immSExt8:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003899def : Pat<(parallel (X86smul_flag (loadi32 addr:$src1), i32immSExt8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003900 (implicit EFLAGS)),
3901 (IMUL32rmi8 addr:$src1, i32immSExt8:$src2)>;
3902
Dan Gohman99a12192009-03-04 19:44:21 +00003903// Optimize multiply by 2 with EFLAGS result.
Evan Cheng00cf7932009-01-27 03:30:42 +00003904let AddedComplexity = 2 in {
Dan Gohman99a12192009-03-04 19:44:21 +00003905def : Pat<(parallel (X86smul_flag GR16:$src1, 2),
Evan Cheng00cf7932009-01-27 03:30:42 +00003906 (implicit EFLAGS)),
3907 (ADD16rr GR16:$src1, GR16:$src1)>;
3908
Dan Gohman99a12192009-03-04 19:44:21 +00003909def : Pat<(parallel (X86smul_flag GR32:$src1, 2),
Evan Cheng00cf7932009-01-27 03:30:42 +00003910 (implicit EFLAGS)),
3911 (ADD32rr GR32:$src1, GR32:$src1)>;
3912}
3913
Dan Gohman99a12192009-03-04 19:44:21 +00003914// INC and DEC with EFLAGS result. Note that these do not set CF.
3915def : Pat<(parallel (X86inc_flag GR8:$src), (implicit EFLAGS)),
3916 (INC8r GR8:$src)>;
3917def : Pat<(parallel (store (i8 (X86inc_flag (loadi8 addr:$dst))), addr:$dst),
3918 (implicit EFLAGS)),
3919 (INC8m addr:$dst)>;
3920def : Pat<(parallel (X86dec_flag GR8:$src), (implicit EFLAGS)),
3921 (DEC8r GR8:$src)>;
3922def : Pat<(parallel (store (i8 (X86dec_flag (loadi8 addr:$dst))), addr:$dst),
3923 (implicit EFLAGS)),
3924 (DEC8m addr:$dst)>;
3925
3926def : Pat<(parallel (X86inc_flag GR16:$src), (implicit EFLAGS)),
Dan Gohmaneebcac72009-03-05 21:32:23 +00003927 (INC16r GR16:$src)>, Requires<[In32BitMode]>;
Dan Gohman99a12192009-03-04 19:44:21 +00003928def : Pat<(parallel (store (i16 (X86inc_flag (loadi16 addr:$dst))), addr:$dst),
3929 (implicit EFLAGS)),
Dan Gohmaneebcac72009-03-05 21:32:23 +00003930 (INC16m addr:$dst)>, Requires<[In32BitMode]>;
Dan Gohman99a12192009-03-04 19:44:21 +00003931def : Pat<(parallel (X86dec_flag GR16:$src), (implicit EFLAGS)),
Dan Gohmaneebcac72009-03-05 21:32:23 +00003932 (DEC16r GR16:$src)>, Requires<[In32BitMode]>;
Dan Gohman99a12192009-03-04 19:44:21 +00003933def : Pat<(parallel (store (i16 (X86dec_flag (loadi16 addr:$dst))), addr:$dst),
3934 (implicit EFLAGS)),
Dan Gohmaneebcac72009-03-05 21:32:23 +00003935 (DEC16m addr:$dst)>, Requires<[In32BitMode]>;
Dan Gohman99a12192009-03-04 19:44:21 +00003936
3937def : Pat<(parallel (X86inc_flag GR32:$src), (implicit EFLAGS)),
Dan Gohmaneebcac72009-03-05 21:32:23 +00003938 (INC32r GR32:$src)>, Requires<[In32BitMode]>;
Dan Gohman99a12192009-03-04 19:44:21 +00003939def : Pat<(parallel (store (i32 (X86inc_flag (loadi32 addr:$dst))), addr:$dst),
3940 (implicit EFLAGS)),
Dan Gohmaneebcac72009-03-05 21:32:23 +00003941 (INC32m addr:$dst)>, Requires<[In32BitMode]>;
Dan Gohman99a12192009-03-04 19:44:21 +00003942def : Pat<(parallel (X86dec_flag GR32:$src), (implicit EFLAGS)),
Dan Gohmaneebcac72009-03-05 21:32:23 +00003943 (DEC32r GR32:$src)>, Requires<[In32BitMode]>;
Dan Gohman99a12192009-03-04 19:44:21 +00003944def : Pat<(parallel (store (i32 (X86dec_flag (loadi32 addr:$dst))), addr:$dst),
3945 (implicit EFLAGS)),
Dan Gohmaneebcac72009-03-05 21:32:23 +00003946 (DEC32m addr:$dst)>, Requires<[In32BitMode]>;
Dan Gohman99a12192009-03-04 19:44:21 +00003947
Bill Wendlingf5399032008-12-12 21:15:41 +00003948//===----------------------------------------------------------------------===//
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003949// Floating Point Stack Support
3950//===----------------------------------------------------------------------===//
3951
3952include "X86InstrFPStack.td"
3953
3954//===----------------------------------------------------------------------===//
Evan Cheng86ab7d32007-07-31 08:04:03 +00003955// X86-64 Support
3956//===----------------------------------------------------------------------===//
3957
Chris Lattner2de8d2b2008-01-10 05:50:42 +00003958include "X86Instr64bit.td"
Evan Cheng86ab7d32007-07-31 08:04:03 +00003959
3960//===----------------------------------------------------------------------===//
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003961// XMM Floating point support (requires SSE / SSE2)
3962//===----------------------------------------------------------------------===//
3963
3964include "X86InstrSSE.td"
Evan Cheng5e4d1e72008-04-25 18:19:54 +00003965
3966//===----------------------------------------------------------------------===//
3967// MMX and XMM Packed Integer support (requires MMX, SSE, and SSE2)
3968//===----------------------------------------------------------------------===//
3969
3970include "X86InstrMMX.td"