blob: 88208f3698f36535f9af1adf50ff544897e0ef5f [file] [log] [blame]
Arnold Schwaighofer373e8652007-10-12 21:30:57 +00001//===- X86InstrInfo.td - Describe the X86 Instruction Set --*- tablegen -*-===//
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002//
3// The LLVM Compiler Infrastructure
4//
Chris Lattner081ce942007-12-29 20:36:04 +00005// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
Dan Gohmanf17a25c2007-07-18 16:29:46 +00007//
8//===----------------------------------------------------------------------===//
9//
10// This file describes the X86 instruction set, defining the instructions, and
11// properties of the instructions which are needed for code generation, machine
12// code emission, and analysis.
13//
14//===----------------------------------------------------------------------===//
15
16//===----------------------------------------------------------------------===//
17// X86 specific DAG Nodes.
18//
19
20def SDTIntShiftDOp: SDTypeProfile<1, 3,
21 [SDTCisSameAs<0, 1>, SDTCisSameAs<0, 2>,
22 SDTCisInt<0>, SDTCisInt<3>]>;
23
24def SDTX86CmpTest : SDTypeProfile<0, 2, [SDTCisSameAs<0, 1>]>;
25
Evan Cheng621216e2007-09-29 00:00:36 +000026def SDTX86Cmov : SDTypeProfile<1, 4,
Evan Cheng950aac02007-09-25 01:57:46 +000027 [SDTCisSameAs<0, 1>, SDTCisSameAs<1, 2>,
28 SDTCisVT<3, i8>, SDTCisVT<4, i32>]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +000029
Dan Gohman99a12192009-03-04 19:44:21 +000030// Unary and binary operator instructions that set EFLAGS as a side-effect.
31def SDTUnaryArithWithFlags : SDTypeProfile<1, 1,
32 [SDTCisInt<0>]>;
33def SDTBinaryArithWithFlags : SDTypeProfile<1, 2,
34 [SDTCisSameAs<0, 1>,
35 SDTCisSameAs<0, 2>,
36 SDTCisInt<0>]>;
Bill Wendlingae034ed2008-12-12 00:56:36 +000037
Evan Cheng621216e2007-09-29 00:00:36 +000038def SDTX86BrCond : SDTypeProfile<0, 3,
Evan Cheng950aac02007-09-25 01:57:46 +000039 [SDTCisVT<0, OtherVT>,
40 SDTCisVT<1, i8>, SDTCisVT<2, i32>]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +000041
Evan Cheng621216e2007-09-29 00:00:36 +000042def SDTX86SetCC : SDTypeProfile<1, 2,
Evan Cheng950aac02007-09-25 01:57:46 +000043 [SDTCisVT<0, i8>,
44 SDTCisVT<1, i8>, SDTCisVT<2, i32>]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +000045
Andrew Lenharth7dfe23f2008-03-01 21:52:34 +000046def SDTX86cas : SDTypeProfile<0, 3, [SDTCisPtrTy<0>, SDTCisInt<1>,
47 SDTCisVT<2, i8>]>;
Andrew Lenharth81580822008-03-05 01:15:49 +000048def SDTX86cas8 : SDTypeProfile<0, 1, [SDTCisPtrTy<0>]>;
Andrew Lenharth7dfe23f2008-03-01 21:52:34 +000049
Dale Johannesenf160d802008-10-02 18:53:47 +000050def SDTX86atomicBinary : SDTypeProfile<2, 3, [SDTCisInt<0>, SDTCisInt<1>,
51 SDTCisPtrTy<2>, SDTCisInt<3>,SDTCisInt<4>]>;
Chris Lattnerb56cc342008-03-11 03:23:40 +000052def SDTX86Ret : SDTypeProfile<0, -1, [SDTCisVT<0, i16>]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +000053
Bill Wendling7173da52007-11-13 09:19:02 +000054def SDT_X86CallSeqStart : SDCallSeqStart<[ SDTCisVT<0, i32> ]>;
55def SDT_X86CallSeqEnd : SDCallSeqEnd<[ SDTCisVT<0, i32>,
56 SDTCisVT<1, i32> ]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +000057
Dan Gohman3329ffe2008-05-29 19:57:41 +000058def SDT_X86Call : SDTypeProfile<0, -1, [SDTCisVT<0, iPTR>]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +000059
60def SDTX86RepStr : SDTypeProfile<0, 1, [SDTCisVT<0, OtherVT>]>;
61
62def SDTX86RdTsc : SDTypeProfile<0, 0, []>;
63
64def SDTX86Wrapper : SDTypeProfile<1, 1, [SDTCisSameAs<0, 1>, SDTCisPtrTy<0>]>;
65
Rafael Espindolaaf759ab2009-04-17 14:35:58 +000066def SDT_X86TLSADDR : SDTypeProfile<0, 1, [SDTCisInt<0>]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +000067
Rafael Espindolabca99f72009-04-08 21:14:34 +000068def SDT_X86SegmentBaseAddress : SDTypeProfile<1, 1, [SDTCisPtrTy<0>]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +000069
70def SDT_X86EHRET : SDTypeProfile<0, 1, [SDTCisInt<0>]>;
71
Arnold Schwaighofere2d6bbb2007-10-11 19:40:01 +000072def SDT_X86TCRET : SDTypeProfile<0, 2, [SDTCisPtrTy<0>, SDTCisVT<1, i32>]>;
73
Evan Cheng48679f42007-12-14 02:13:44 +000074def X86bsf : SDNode<"X86ISD::BSF", SDTIntUnaryOp>;
75def X86bsr : SDNode<"X86ISD::BSR", SDTIntUnaryOp>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +000076def X86shld : SDNode<"X86ISD::SHLD", SDTIntShiftDOp>;
77def X86shrd : SDNode<"X86ISD::SHRD", SDTIntShiftDOp>;
78
Evan Cheng621216e2007-09-29 00:00:36 +000079def X86cmp : SDNode<"X86ISD::CMP" , SDTX86CmpTest>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +000080
Dan Gohman7fe9b7f2008-12-23 22:45:23 +000081def X86bt : SDNode<"X86ISD::BT", SDTX86CmpTest>;
82
Evan Cheng621216e2007-09-29 00:00:36 +000083def X86cmov : SDNode<"X86ISD::CMOV", SDTX86Cmov>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +000084def X86brcond : SDNode<"X86ISD::BRCOND", SDTX86BrCond,
Evan Cheng950aac02007-09-25 01:57:46 +000085 [SDNPHasChain]>;
Evan Cheng621216e2007-09-29 00:00:36 +000086def X86setcc : SDNode<"X86ISD::SETCC", SDTX86SetCC>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +000087
Andrew Lenharth7dfe23f2008-03-01 21:52:34 +000088def X86cas : SDNode<"X86ISD::LCMPXCHG_DAG", SDTX86cas,
89 [SDNPHasChain, SDNPInFlag, SDNPOutFlag, SDNPMayStore,
90 SDNPMayLoad]>;
Andrew Lenharth81580822008-03-05 01:15:49 +000091def X86cas8 : SDNode<"X86ISD::LCMPXCHG8_DAG", SDTX86cas8,
92 [SDNPHasChain, SDNPInFlag, SDNPOutFlag, SDNPMayStore,
93 SDNPMayLoad]>;
Dale Johannesenf160d802008-10-02 18:53:47 +000094def X86AtomAdd64 : SDNode<"X86ISD::ATOMADD64_DAG", SDTX86atomicBinary,
95 [SDNPHasChain, SDNPMayStore,
96 SDNPMayLoad, SDNPMemOperand]>;
97def X86AtomSub64 : SDNode<"X86ISD::ATOMSUB64_DAG", SDTX86atomicBinary,
98 [SDNPHasChain, SDNPMayStore,
99 SDNPMayLoad, SDNPMemOperand]>;
100def X86AtomOr64 : SDNode<"X86ISD::ATOMOR64_DAG", SDTX86atomicBinary,
101 [SDNPHasChain, SDNPMayStore,
102 SDNPMayLoad, SDNPMemOperand]>;
103def X86AtomXor64 : SDNode<"X86ISD::ATOMXOR64_DAG", SDTX86atomicBinary,
104 [SDNPHasChain, SDNPMayStore,
105 SDNPMayLoad, SDNPMemOperand]>;
106def X86AtomAnd64 : SDNode<"X86ISD::ATOMAND64_DAG", SDTX86atomicBinary,
107 [SDNPHasChain, SDNPMayStore,
108 SDNPMayLoad, SDNPMemOperand]>;
109def X86AtomNand64 : SDNode<"X86ISD::ATOMNAND64_DAG", SDTX86atomicBinary,
110 [SDNPHasChain, SDNPMayStore,
111 SDNPMayLoad, SDNPMemOperand]>;
Dale Johannesen51c58ee2008-10-03 22:25:52 +0000112def X86AtomSwap64 : SDNode<"X86ISD::ATOMSWAP64_DAG", SDTX86atomicBinary,
113 [SDNPHasChain, SDNPMayStore,
114 SDNPMayLoad, SDNPMemOperand]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000115def X86retflag : SDNode<"X86ISD::RET_FLAG", SDTX86Ret,
116 [SDNPHasChain, SDNPOptInFlag]>;
117
118def X86callseq_start :
119 SDNode<"ISD::CALLSEQ_START", SDT_X86CallSeqStart,
120 [SDNPHasChain, SDNPOutFlag]>;
121def X86callseq_end :
122 SDNode<"ISD::CALLSEQ_END", SDT_X86CallSeqEnd,
Arnold Schwaighofere2d6bbb2007-10-11 19:40:01 +0000123 [SDNPHasChain, SDNPOptInFlag, SDNPOutFlag]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000124
125def X86call : SDNode<"X86ISD::CALL", SDT_X86Call,
126 [SDNPHasChain, SDNPOutFlag, SDNPOptInFlag]>;
127
128def X86tailcall: SDNode<"X86ISD::TAILCALL", SDT_X86Call,
129 [SDNPHasChain, SDNPOutFlag, SDNPOptInFlag]>;
130
131def X86rep_stos: SDNode<"X86ISD::REP_STOS", SDTX86RepStr,
Chris Lattnerca4e0fe2008-01-10 05:12:37 +0000132 [SDNPHasChain, SDNPInFlag, SDNPOutFlag, SDNPMayStore]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000133def X86rep_movs: SDNode<"X86ISD::REP_MOVS", SDTX86RepStr,
Chris Lattnerca4e0fe2008-01-10 05:12:37 +0000134 [SDNPHasChain, SDNPInFlag, SDNPOutFlag, SDNPMayStore,
135 SDNPMayLoad]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000136
137def X86rdtsc : SDNode<"X86ISD::RDTSC_DAG",SDTX86RdTsc,
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000138 [SDNPHasChain, SDNPOutFlag, SDNPSideEffect]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000139
140def X86Wrapper : SDNode<"X86ISD::Wrapper", SDTX86Wrapper>;
141def X86WrapperRIP : SDNode<"X86ISD::WrapperRIP", SDTX86Wrapper>;
142
143def X86tlsaddr : SDNode<"X86ISD::TLSADDR", SDT_X86TLSADDR,
Anton Korobeynikov4fbf00b2008-05-04 21:36:32 +0000144 [SDNPHasChain, SDNPOptInFlag, SDNPOutFlag]>;
Rafael Espindolabca99f72009-04-08 21:14:34 +0000145def X86SegmentBaseAddress : SDNode<"X86ISD::SegmentBaseAddress",
146 SDT_X86SegmentBaseAddress, []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000147
148def X86ehret : SDNode<"X86ISD::EH_RETURN", SDT_X86EHRET,
149 [SDNPHasChain]>;
150
Arnold Schwaighofere2d6bbb2007-10-11 19:40:01 +0000151def X86tcret : SDNode<"X86ISD::TC_RETURN", SDT_X86TCRET,
152 [SDNPHasChain, SDNPOptInFlag]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000153
Dan Gohman99a12192009-03-04 19:44:21 +0000154def X86add_flag : SDNode<"X86ISD::ADD", SDTBinaryArithWithFlags>;
155def X86sub_flag : SDNode<"X86ISD::SUB", SDTBinaryArithWithFlags>;
156def X86smul_flag : SDNode<"X86ISD::SMUL", SDTBinaryArithWithFlags>;
157def X86umul_flag : SDNode<"X86ISD::UMUL", SDTUnaryArithWithFlags>;
158def X86inc_flag : SDNode<"X86ISD::INC", SDTUnaryArithWithFlags>;
159def X86dec_flag : SDNode<"X86ISD::DEC", SDTUnaryArithWithFlags>;
Bill Wendlingae034ed2008-12-12 00:56:36 +0000160
Evan Chengc3495762009-03-30 21:36:47 +0000161def X86mul_imm : SDNode<"X86ISD::MUL_IMM", SDTIntBinOp>;
162
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000163//===----------------------------------------------------------------------===//
164// X86 Operand Definitions.
165//
166
167// *mem - Operand definitions for the funky X86 addressing mode operands.
168//
169class X86MemOperand<string printMethod> : Operand<iPTR> {
170 let PrintMethod = printMethod;
Rafael Espindolabca99f72009-04-08 21:14:34 +0000171 let MIOperandInfo = (ops ptr_rc, i8imm, ptr_rc, i32imm, i8imm);
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000172}
173
174def i8mem : X86MemOperand<"printi8mem">;
175def i16mem : X86MemOperand<"printi16mem">;
176def i32mem : X86MemOperand<"printi32mem">;
177def i64mem : X86MemOperand<"printi64mem">;
178def i128mem : X86MemOperand<"printi128mem">;
179def f32mem : X86MemOperand<"printf32mem">;
180def f64mem : X86MemOperand<"printf64mem">;
Dale Johannesen4ab00bd2007-08-05 18:49:15 +0000181def f80mem : X86MemOperand<"printf80mem">;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000182def f128mem : X86MemOperand<"printf128mem">;
183
Dan Gohman744d4622009-04-13 16:09:41 +0000184// A version of i8mem for use on x86-64 that uses GR64_NOREX instead of
185// plain GR64, so that it doesn't potentially require a REX prefix.
186def i8mem_NOREX : Operand<i64> {
187 let PrintMethod = "printi8mem";
188 let MIOperandInfo = (ops GR64_NOREX, i8imm, GR64_NOREX, i32imm, i8imm);
189}
190
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000191def lea32mem : Operand<i32> {
Rafael Espindolabca99f72009-04-08 21:14:34 +0000192 let PrintMethod = "printlea32mem";
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000193 let MIOperandInfo = (ops GR32, i8imm, GR32, i32imm);
194}
195
196def SSECC : Operand<i8> {
197 let PrintMethod = "printSSECC";
198}
199
200def piclabel: Operand<i32> {
201 let PrintMethod = "printPICLabel";
202}
203
204// A couple of more descriptive operand definitions.
205// 16-bits but only 8 bits are significant.
206def i16i8imm : Operand<i16>;
207// 32-bits but only 8 bits are significant.
208def i32i8imm : Operand<i32>;
209
210// Branch targets have OtherVT type.
211def brtarget : Operand<OtherVT>;
212
213//===----------------------------------------------------------------------===//
214// X86 Complex Pattern Definitions.
215//
216
217// Define X86 specific addressing mode.
Rafael Espindolabca99f72009-04-08 21:14:34 +0000218def addr : ComplexPattern<iPTR, 5, "SelectAddr", [], []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000219def lea32addr : ComplexPattern<i32, 4, "SelectLEAAddr",
220 [add, mul, shl, or, frameindex], []>;
221
222//===----------------------------------------------------------------------===//
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000223// X86 Instruction Predicate Definitions.
224def HasMMX : Predicate<"Subtarget->hasMMX()">;
225def HasSSE1 : Predicate<"Subtarget->hasSSE1()">;
226def HasSSE2 : Predicate<"Subtarget->hasSSE2()">;
227def HasSSE3 : Predicate<"Subtarget->hasSSE3()">;
228def HasSSSE3 : Predicate<"Subtarget->hasSSSE3()">;
Nate Begemanb2975562008-02-03 07:18:54 +0000229def HasSSE41 : Predicate<"Subtarget->hasSSE41()">;
230def HasSSE42 : Predicate<"Subtarget->hasSSE42()">;
Dale Johannesene0e0fd02007-09-23 14:52:20 +0000231def FPStackf32 : Predicate<"!Subtarget->hasSSE1()">;
232def FPStackf64 : Predicate<"!Subtarget->hasSSE2()">;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000233def In32BitMode : Predicate<"!Subtarget->is64Bit()">;
234def In64BitMode : Predicate<"Subtarget->is64Bit()">;
235def SmallCode : Predicate<"TM.getCodeModel() == CodeModel::Small">;
236def NotSmallCode : Predicate<"TM.getCodeModel() != CodeModel::Small">;
237def IsStatic : Predicate<"TM.getRelocationModel() == Reloc::Static">;
Evan Cheng13559d62008-09-26 23:41:32 +0000238def OptForSpeed : Predicate<"!OptForSize">;
Evan Cheng95a77fd2009-01-02 05:35:45 +0000239def FastBTMem : Predicate<"!Subtarget->isBTMemSlow()">;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000240
241//===----------------------------------------------------------------------===//
Evan Cheng86ab7d32007-07-31 08:04:03 +0000242// X86 Instruction Format Definitions.
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000243//
244
Evan Cheng86ab7d32007-07-31 08:04:03 +0000245include "X86InstrFormats.td"
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000246
247//===----------------------------------------------------------------------===//
248// Pattern fragments...
249//
250
251// X86 specific condition code. These correspond to CondCode in
252// X86InstrInfo.h. They must be kept in synch.
Dan Gohman0fc9ed62009-01-07 00:15:08 +0000253def X86_COND_A : PatLeaf<(i8 0)>; // alt. COND_NBE
254def X86_COND_AE : PatLeaf<(i8 1)>; // alt. COND_NC
255def X86_COND_B : PatLeaf<(i8 2)>; // alt. COND_C
256def X86_COND_BE : PatLeaf<(i8 3)>; // alt. COND_NA
257def X86_COND_E : PatLeaf<(i8 4)>; // alt. COND_Z
258def X86_COND_G : PatLeaf<(i8 5)>; // alt. COND_NLE
259def X86_COND_GE : PatLeaf<(i8 6)>; // alt. COND_NL
260def X86_COND_L : PatLeaf<(i8 7)>; // alt. COND_NGE
261def X86_COND_LE : PatLeaf<(i8 8)>; // alt. COND_NG
262def X86_COND_NE : PatLeaf<(i8 9)>; // alt. COND_NZ
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000263def X86_COND_NO : PatLeaf<(i8 10)>;
Dan Gohman0fc9ed62009-01-07 00:15:08 +0000264def X86_COND_NP : PatLeaf<(i8 11)>; // alt. COND_PO
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000265def X86_COND_NS : PatLeaf<(i8 12)>;
Dan Gohman0fc9ed62009-01-07 00:15:08 +0000266def X86_COND_O : PatLeaf<(i8 13)>;
267def X86_COND_P : PatLeaf<(i8 14)>; // alt. COND_PE
268def X86_COND_S : PatLeaf<(i8 15)>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000269
270def i16immSExt8 : PatLeaf<(i16 imm), [{
271 // i16immSExt8 predicate - True if the 16-bit immediate fits in a 8-bit
272 // sign extended field.
Dan Gohmanfaeb4a32008-09-12 16:56:44 +0000273 return (int16_t)N->getZExtValue() == (int8_t)N->getZExtValue();
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000274}]>;
275
276def i32immSExt8 : PatLeaf<(i32 imm), [{
277 // i32immSExt8 predicate - True if the 32-bit immediate fits in a 8-bit
278 // sign extended field.
Dan Gohmanfaeb4a32008-09-12 16:56:44 +0000279 return (int32_t)N->getZExtValue() == (int8_t)N->getZExtValue();
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000280}]>;
281
282// Helper fragments for loads.
Evan Chengb3e25ea2008-05-13 18:59:59 +0000283// It's always safe to treat a anyext i16 load as a i32 load if the i16 is
284// known to be 32-bit aligned or better. Ditto for i8 to i16.
Dan Gohman2a174122008-10-15 06:50:19 +0000285def loadi16 : PatFrag<(ops node:$ptr), (i16 (unindexedload node:$ptr)), [{
Dan Gohman8335c412008-08-20 15:24:22 +0000286 LoadSDNode *LD = cast<LoadSDNode>(N);
Chris Lattner12208612009-04-10 00:16:23 +0000287 if (const Value *Src = LD->getSrcValue())
288 if (const PointerType *PT = dyn_cast<PointerType>(Src->getType()))
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 Lattner12208612009-04-10 00:16:23 +0000348def loadi8 : PatFrag<(ops node:$ptr), (i8 (load node:$ptr)), [{
349 if (const Value *Src = cast<LoadSDNode>(N)->getSrcValue())
350 if (const PointerType *PT = dyn_cast<PointerType>(Src->getType()))
Mon P Wangdc97d5a2009-04-27 07:22:10 +0000351 if (PT->getAddressSpace() > 255)
Chris Lattner12208612009-04-10 00:16:23 +0000352 return false;
353 return true;
354}]>;
355def loadi64 : PatFrag<(ops node:$ptr), (i64 (load node:$ptr)), [{
356 if (const Value *Src = cast<LoadSDNode>(N)->getSrcValue())
357 if (const PointerType *PT = dyn_cast<PointerType>(Src->getType()))
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}]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000362
Chris Lattner12208612009-04-10 00:16:23 +0000363def loadf32 : PatFrag<(ops node:$ptr), (f32 (load node:$ptr)), [{
364 if (const Value *Src = cast<LoadSDNode>(N)->getSrcValue())
365 if (const PointerType *PT = dyn_cast<PointerType>(Src->getType()))
Mon P Wangdc97d5a2009-04-27 07:22:10 +0000366 if (PT->getAddressSpace() > 255)
Chris Lattner12208612009-04-10 00:16:23 +0000367 return false;
368 return true;
369}]>;
370def loadf64 : PatFrag<(ops node:$ptr), (f64 (load node:$ptr)), [{
371 if (const Value *Src = cast<LoadSDNode>(N)->getSrcValue())
372 if (const PointerType *PT = dyn_cast<PointerType>(Src->getType()))
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 loadf80 : PatFrag<(ops node:$ptr), (f80 (load node:$ptr)), [{
378 if (const Value *Src = cast<LoadSDNode>(N)->getSrcValue())
379 if (const PointerType *PT = dyn_cast<PointerType>(Src->getType()))
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}]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000384
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000385def sextloadi16i8 : PatFrag<(ops node:$ptr), (i16 (sextloadi8 node:$ptr))>;
386def sextloadi32i8 : PatFrag<(ops node:$ptr), (i32 (sextloadi8 node:$ptr))>;
387def sextloadi32i16 : PatFrag<(ops node:$ptr), (i32 (sextloadi16 node:$ptr))>;
388
389def zextloadi8i1 : PatFrag<(ops node:$ptr), (i8 (zextloadi1 node:$ptr))>;
390def zextloadi16i1 : PatFrag<(ops node:$ptr), (i16 (zextloadi1 node:$ptr))>;
391def zextloadi32i1 : PatFrag<(ops node:$ptr), (i32 (zextloadi1 node:$ptr))>;
392def zextloadi16i8 : PatFrag<(ops node:$ptr), (i16 (zextloadi8 node:$ptr))>;
393def zextloadi32i8 : PatFrag<(ops node:$ptr), (i32 (zextloadi8 node:$ptr))>;
394def zextloadi32i16 : PatFrag<(ops node:$ptr), (i32 (zextloadi16 node:$ptr))>;
395
396def extloadi8i1 : PatFrag<(ops node:$ptr), (i8 (extloadi1 node:$ptr))>;
397def extloadi16i1 : PatFrag<(ops node:$ptr), (i16 (extloadi1 node:$ptr))>;
398def extloadi32i1 : PatFrag<(ops node:$ptr), (i32 (extloadi1 node:$ptr))>;
399def extloadi16i8 : PatFrag<(ops node:$ptr), (i16 (extloadi8 node:$ptr))>;
400def extloadi32i8 : PatFrag<(ops node:$ptr), (i32 (extloadi8 node:$ptr))>;
401def extloadi32i16 : PatFrag<(ops node:$ptr), (i32 (extloadi16 node:$ptr))>;
402
Chris Lattner21da6382008-02-19 17:37:35 +0000403
404// An 'and' node with a single use.
405def and_su : PatFrag<(ops node:$lhs, node:$rhs), (and node:$lhs, node:$rhs), [{
Evan Cheng9123cfa2008-03-04 00:40:35 +0000406 return N->hasOneUse();
Chris Lattner21da6382008-02-19 17:37:35 +0000407}]>;
Dan Gohman744d4622009-04-13 16:09:41 +0000408// An 'srl' node with a single use.
409def srl_su : PatFrag<(ops node:$lhs, node:$rhs), (srl node:$lhs, node:$rhs), [{
410 return N->hasOneUse();
411}]>;
412// An 'trunc' node with a single use.
413def trunc_su : PatFrag<(ops node:$src), (trunc node:$src), [{
414 return N->hasOneUse();
415}]>;
Chris Lattner21da6382008-02-19 17:37:35 +0000416
Dan Gohman921581d2008-10-17 01:23:35 +0000417// 'shld' and 'shrd' instruction patterns. Note that even though these have
418// the srl and shl in their patterns, the C++ code must still check for them,
419// because predicates are tested before children nodes are explored.
420
421def shrd : PatFrag<(ops node:$src1, node:$amt1, node:$src2, node:$amt2),
422 (or (srl node:$src1, node:$amt1),
423 (shl node:$src2, node:$amt2)), [{
424 assert(N->getOpcode() == ISD::OR);
425 return N->getOperand(0).getOpcode() == ISD::SRL &&
426 N->getOperand(1).getOpcode() == ISD::SHL &&
427 isa<ConstantSDNode>(N->getOperand(0).getOperand(1)) &&
428 isa<ConstantSDNode>(N->getOperand(1).getOperand(1)) &&
429 N->getOperand(0).getConstantOperandVal(1) ==
430 N->getValueSizeInBits(0) - N->getOperand(1).getConstantOperandVal(1);
431}]>;
432
433def shld : PatFrag<(ops node:$src1, node:$amt1, node:$src2, node:$amt2),
434 (or (shl node:$src1, node:$amt1),
435 (srl node:$src2, node:$amt2)), [{
436 assert(N->getOpcode() == ISD::OR);
437 return N->getOperand(0).getOpcode() == ISD::SHL &&
438 N->getOperand(1).getOpcode() == ISD::SRL &&
439 isa<ConstantSDNode>(N->getOperand(0).getOperand(1)) &&
440 isa<ConstantSDNode>(N->getOperand(1).getOperand(1)) &&
441 N->getOperand(0).getConstantOperandVal(1) ==
442 N->getValueSizeInBits(0) - N->getOperand(1).getConstantOperandVal(1);
443}]>;
444
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000445//===----------------------------------------------------------------------===//
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000446// Instruction list...
447//
448
449// ADJCALLSTACKDOWN/UP implicitly use/def ESP because they may be expanded into
450// a stack adjustment and the codegen must know that they may modify the stack
451// pointer before prolog-epilog rewriting occurs.
Chris Lattnerb56cc342008-03-11 03:23:40 +0000452// Pessimistically assume ADJCALLSTACKDOWN / ADJCALLSTACKUP will become
453// sub / add which can clobber EFLAGS.
Evan Cheng037364a2007-09-28 01:19:48 +0000454let Defs = [ESP, EFLAGS], Uses = [ESP] in {
Dan Gohman01c9f772008-10-01 18:28:06 +0000455def ADJCALLSTACKDOWN32 : I<0, Pseudo, (outs), (ins i32imm:$amt),
456 "#ADJCALLSTACKDOWN",
Chris Lattnerfe5d4022008-10-11 22:08:30 +0000457 [(X86callseq_start timm:$amt)]>,
Dan Gohman01c9f772008-10-01 18:28:06 +0000458 Requires<[In32BitMode]>;
459def ADJCALLSTACKUP32 : I<0, Pseudo, (outs), (ins i32imm:$amt1, i32imm:$amt2),
460 "#ADJCALLSTACKUP",
Chris Lattnerfe5d4022008-10-11 22:08:30 +0000461 [(X86callseq_end timm:$amt1, timm:$amt2)]>,
Dan Gohman01c9f772008-10-01 18:28:06 +0000462 Requires<[In32BitMode]>;
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000463}
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000464
465// Nop
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000466let neverHasSideEffects = 1 in
467 def NOOP : I<0x90, RawFrm, (outs), (ins), "nop", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000468
Evan Cheng0729ccf2008-01-05 00:41:47 +0000469// PIC base
Dan Gohman9499cfe2008-10-01 04:14:30 +0000470let neverHasSideEffects = 1, isNotDuplicable = 1, Uses = [ESP] in
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000471 def MOVPC32r : Ii32<0xE8, Pseudo, (outs GR32:$reg), (ins piclabel:$label),
Dan Gohman70a8a112009-04-27 15:13:28 +0000472 "call\t$label\n\t"
473 "pop{l}\t$reg", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000474
475//===----------------------------------------------------------------------===//
476// Control Flow Instructions...
477//
478
479// Return instructions.
480let isTerminator = 1, isReturn = 1, isBarrier = 1,
Chris Lattnerb56cc342008-03-11 03:23:40 +0000481 hasCtrlDep = 1, FPForm = SpecialFP, FPFormBits = SpecialFP.Value in {
Dan Gohman2c4be2a2008-05-31 02:11:25 +0000482 def RET : I <0xC3, RawFrm, (outs), (ins variable_ops),
Chris Lattnerb56cc342008-03-11 03:23:40 +0000483 "ret",
Dan Gohman2c4be2a2008-05-31 02:11:25 +0000484 [(X86retflag 0)]>;
Chris Lattnerb56cc342008-03-11 03:23:40 +0000485 def RETI : Ii16<0xC2, RawFrm, (outs), (ins i16imm:$amt, variable_ops),
486 "ret\t$amt",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000487 [(X86retflag imm:$amt)]>;
488}
489
490// All branches are RawFrm, Void, Branch, and Terminators
Evan Cheng37e7c752007-07-21 00:34:19 +0000491let isBranch = 1, isTerminator = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +0000492 class IBr<bits<8> opcode, dag ins, string asm, list<dag> pattern> :
493 I<opcode, RawFrm, (outs), ins, asm, pattern>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000494
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000495let isBranch = 1, isBarrier = 1 in
Dan Gohman91888f02007-07-31 20:11:57 +0000496 def JMP : IBr<0xE9, (ins brtarget:$dst), "jmp\t$dst", [(br bb:$dst)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000497
Owen Andersonf8053082007-11-12 07:39:39 +0000498// Indirect branches
499let isBranch = 1, isTerminator = 1, isBarrier = 1, isIndirectBranch = 1 in {
Dan Gohman91888f02007-07-31 20:11:57 +0000500 def JMP32r : I<0xFF, MRM4r, (outs), (ins GR32:$dst), "jmp{l}\t{*}$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000501 [(brind GR32:$dst)]>;
Dan Gohman91888f02007-07-31 20:11:57 +0000502 def JMP32m : I<0xFF, MRM4m, (outs), (ins i32mem:$dst), "jmp{l}\t{*}$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000503 [(brind (loadi32 addr:$dst))]>;
504}
505
506// Conditional branches
Evan Cheng950aac02007-09-25 01:57:46 +0000507let Uses = [EFLAGS] in {
Dan Gohman91888f02007-07-31 20:11:57 +0000508def JE : IBr<0x84, (ins brtarget:$dst), "je\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000509 [(X86brcond bb:$dst, X86_COND_E, EFLAGS)]>, TB;
Dan Gohman91888f02007-07-31 20:11:57 +0000510def JNE : IBr<0x85, (ins brtarget:$dst), "jne\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000511 [(X86brcond bb:$dst, X86_COND_NE, EFLAGS)]>, TB;
Dan Gohman91888f02007-07-31 20:11:57 +0000512def JL : IBr<0x8C, (ins brtarget:$dst), "jl\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000513 [(X86brcond bb:$dst, X86_COND_L, EFLAGS)]>, TB;
Dan Gohman91888f02007-07-31 20:11:57 +0000514def JLE : IBr<0x8E, (ins brtarget:$dst), "jle\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000515 [(X86brcond bb:$dst, X86_COND_LE, EFLAGS)]>, TB;
Dan Gohman91888f02007-07-31 20:11:57 +0000516def JG : IBr<0x8F, (ins brtarget:$dst), "jg\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000517 [(X86brcond bb:$dst, X86_COND_G, EFLAGS)]>, TB;
Dan Gohman91888f02007-07-31 20:11:57 +0000518def JGE : IBr<0x8D, (ins brtarget:$dst), "jge\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000519 [(X86brcond bb:$dst, X86_COND_GE, EFLAGS)]>, TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000520
Dan Gohman91888f02007-07-31 20:11:57 +0000521def JB : IBr<0x82, (ins brtarget:$dst), "jb\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000522 [(X86brcond bb:$dst, X86_COND_B, EFLAGS)]>, TB;
Dan Gohman91888f02007-07-31 20:11:57 +0000523def JBE : IBr<0x86, (ins brtarget:$dst), "jbe\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000524 [(X86brcond bb:$dst, X86_COND_BE, EFLAGS)]>, TB;
Dan Gohman91888f02007-07-31 20:11:57 +0000525def JA : IBr<0x87, (ins brtarget:$dst), "ja\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000526 [(X86brcond bb:$dst, X86_COND_A, EFLAGS)]>, TB;
Dan Gohman91888f02007-07-31 20:11:57 +0000527def JAE : IBr<0x83, (ins brtarget:$dst), "jae\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000528 [(X86brcond bb:$dst, X86_COND_AE, EFLAGS)]>, TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000529
Dan Gohman91888f02007-07-31 20:11:57 +0000530def JS : IBr<0x88, (ins brtarget:$dst), "js\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000531 [(X86brcond bb:$dst, X86_COND_S, EFLAGS)]>, TB;
Dan Gohman91888f02007-07-31 20:11:57 +0000532def JNS : IBr<0x89, (ins brtarget:$dst), "jns\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000533 [(X86brcond bb:$dst, X86_COND_NS, EFLAGS)]>, TB;
Dan Gohman91888f02007-07-31 20:11:57 +0000534def JP : IBr<0x8A, (ins brtarget:$dst), "jp\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000535 [(X86brcond bb:$dst, X86_COND_P, EFLAGS)]>, TB;
Dan Gohman91888f02007-07-31 20:11:57 +0000536def JNP : IBr<0x8B, (ins brtarget:$dst), "jnp\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000537 [(X86brcond bb:$dst, X86_COND_NP, EFLAGS)]>, TB;
Dan Gohman91888f02007-07-31 20:11:57 +0000538def JO : IBr<0x80, (ins brtarget:$dst), "jo\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000539 [(X86brcond bb:$dst, X86_COND_O, EFLAGS)]>, TB;
Dan Gohman91888f02007-07-31 20:11:57 +0000540def JNO : IBr<0x81, (ins brtarget:$dst), "jno\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000541 [(X86brcond bb:$dst, X86_COND_NO, EFLAGS)]>, TB;
Evan Cheng950aac02007-09-25 01:57:46 +0000542} // Uses = [EFLAGS]
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000543
544//===----------------------------------------------------------------------===//
545// Call Instructions...
546//
Evan Cheng37e7c752007-07-21 00:34:19 +0000547let isCall = 1 in
Dan Gohman01c9f772008-10-01 18:28:06 +0000548 // All calls clobber the non-callee saved registers. ESP is marked as
549 // a use to prevent stack-pointer assignments that appear immediately
550 // before calls from potentially appearing dead. Uses for argument
551 // registers are added manually.
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000552 let Defs = [EAX, ECX, EDX, FP0, FP1, FP2, FP3, FP4, FP5, FP6, ST0,
553 MM0, MM1, MM2, MM3, MM4, MM5, MM6, MM7,
Evan Cheng2293b252008-10-17 21:02:22 +0000554 XMM0, XMM1, XMM2, XMM3, XMM4, XMM5, XMM6, XMM7,
555 XMM8, XMM9, XMM10, XMM11, XMM12, XMM13, XMM14, XMM15, EFLAGS],
Dan Gohman9499cfe2008-10-01 04:14:30 +0000556 Uses = [ESP] in {
Evan Cheng34f93712007-12-22 02:26:46 +0000557 def CALLpcrel32 : Ii32<0xE8, RawFrm, (outs), (ins i32imm:$dst,variable_ops),
Evan Cheng0af5a042009-03-12 18:15:39 +0000558 "call\t${dst:call}", [(X86call imm:$dst)]>,
559 Requires<[In32BitMode]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000560 def CALL32r : I<0xFF, MRM2r, (outs), (ins GR32:$dst, variable_ops),
Dan Gohman91888f02007-07-31 20:11:57 +0000561 "call\t{*}$dst", [(X86call GR32:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000562 def CALL32m : I<0xFF, MRM2m, (outs), (ins i32mem:$dst, variable_ops),
Dan Gohmanea4faba2008-05-29 21:50:34 +0000563 "call\t{*}$dst", [(X86call (loadi32 addr:$dst))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000564 }
565
566// Tail call stuff.
Arnold Schwaighofere2d6bbb2007-10-11 19:40:01 +0000567
Chris Lattnerb56cc342008-03-11 03:23:40 +0000568def TAILCALL : I<0, Pseudo, (outs), (ins),
Arnold Schwaighofere2d6bbb2007-10-11 19:40:01 +0000569 "#TAILCALL",
570 []>;
571
Evan Cheng37e7c752007-07-21 00:34:19 +0000572let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1 in
Arnold Schwaighofer6fd37ac2008-03-19 16:39:45 +0000573def TCRETURNdi : I<0, Pseudo, (outs), (ins i32imm:$dst, i32imm:$offset, variable_ops),
Arnold Schwaighofere2d6bbb2007-10-11 19:40:01 +0000574 "#TC_RETURN $dst $offset",
575 []>;
576
577let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1 in
Arnold Schwaighofer6fd37ac2008-03-19 16:39:45 +0000578def TCRETURNri : I<0, Pseudo, (outs), (ins GR32:$dst, i32imm:$offset, variable_ops),
Arnold Schwaighofere2d6bbb2007-10-11 19:40:01 +0000579 "#TC_RETURN $dst $offset",
580 []>;
581
582let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1 in
Arnold Schwaighofera0032722008-04-30 09:16:33 +0000583
Arnold Schwaighofere2d6bbb2007-10-11 19:40:01 +0000584 def TAILJMPd : IBr<0xE9, (ins i32imm:$dst), "jmp\t${dst:call} # TAILCALL",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000585 []>;
Evan Cheng37e7c752007-07-21 00:34:19 +0000586let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1 in
Arnold Schwaighofere2d6bbb2007-10-11 19:40:01 +0000587 def TAILJMPr : I<0xFF, MRM4r, (outs), (ins GR32:$dst), "jmp{l}\t{*}$dst # TAILCALL",
588 []>;
Evan Cheng37e7c752007-07-21 00:34:19 +0000589let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +0000590 def TAILJMPm : I<0xFF, MRM4m, (outs), (ins i32mem:$dst),
Arnold Schwaighofere2d6bbb2007-10-11 19:40:01 +0000591 "jmp\t{*}$dst # TAILCALL", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000592
593//===----------------------------------------------------------------------===//
594// Miscellaneous Instructions...
595//
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000596let Defs = [EBP, ESP], Uses = [EBP, ESP], mayLoad = 1, neverHasSideEffects=1 in
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000597def LEAVE : I<0xC9, RawFrm,
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000598 (outs), (ins), "leave", []>;
599
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000600let Defs = [ESP], Uses = [ESP], neverHasSideEffects=1 in {
601let mayLoad = 1 in
Evan Chengd8434332007-09-26 01:29:06 +0000602def POP32r : I<0x58, AddRegFrm, (outs GR32:$reg), (ins), "pop{l}\t$reg", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000603
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000604let mayStore = 1 in
Evan Chengd8434332007-09-26 01:29:06 +0000605def PUSH32r : I<0x50, AddRegFrm, (outs), (ins GR32:$reg), "push{l}\t$reg",[]>;
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000606}
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000607
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000608let Defs = [ESP, EFLAGS], Uses = [ESP], mayLoad = 1, neverHasSideEffects=1 in
Evan Chengf1341312007-09-26 21:28:00 +0000609def POPFD : I<0x9D, RawFrm, (outs), (ins), "popf", []>;
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000610let Defs = [ESP], Uses = [ESP, EFLAGS], mayStore = 1, neverHasSideEffects=1 in
Evan Chengf1341312007-09-26 21:28:00 +0000611def PUSHFD : I<0x9C, RawFrm, (outs), (ins), "pushf", []>;
Evan Chengd8434332007-09-26 01:29:06 +0000612
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000613let isTwoAddress = 1 in // GR32 = bswap GR32
614 def BSWAP32r : I<0xC8, AddRegFrm,
Evan Chengb783fa32007-07-19 01:14:50 +0000615 (outs GR32:$dst), (ins GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000616 "bswap{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000617 [(set GR32:$dst, (bswap GR32:$src))]>, TB;
618
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000619
Evan Cheng48679f42007-12-14 02:13:44 +0000620// Bit scan instructions.
621let Defs = [EFLAGS] in {
Evan Cheng4e33de92007-12-14 18:49:43 +0000622def BSF16rr : I<0xBC, MRMSrcReg, (outs GR16:$dst), (ins GR16:$src),
Dan Gohmancdb54c62007-12-14 15:10:00 +0000623 "bsf{w}\t{$src, $dst|$dst, $src}",
Evan Cheng7cfbfe32007-12-14 08:30:15 +0000624 [(set GR16:$dst, (X86bsf GR16:$src)), (implicit EFLAGS)]>, TB;
Evan Cheng48679f42007-12-14 02:13:44 +0000625def BSF16rm : I<0xBC, MRMSrcMem, (outs GR16:$dst), (ins i16mem:$src),
Dan Gohmancdb54c62007-12-14 15:10:00 +0000626 "bsf{w}\t{$src, $dst|$dst, $src}",
Evan Cheng7cfbfe32007-12-14 08:30:15 +0000627 [(set GR16:$dst, (X86bsf (loadi16 addr:$src))),
628 (implicit EFLAGS)]>, TB;
Evan Cheng4e33de92007-12-14 18:49:43 +0000629def BSF32rr : I<0xBC, MRMSrcReg, (outs GR32:$dst), (ins GR32:$src),
Dan Gohmancdb54c62007-12-14 15:10:00 +0000630 "bsf{l}\t{$src, $dst|$dst, $src}",
Evan Cheng7cfbfe32007-12-14 08:30:15 +0000631 [(set GR32:$dst, (X86bsf GR32:$src)), (implicit EFLAGS)]>, TB;
Evan Cheng48679f42007-12-14 02:13:44 +0000632def BSF32rm : I<0xBC, MRMSrcMem, (outs GR32:$dst), (ins i32mem:$src),
Dan Gohmancdb54c62007-12-14 15:10:00 +0000633 "bsf{l}\t{$src, $dst|$dst, $src}",
Evan Cheng7cfbfe32007-12-14 08:30:15 +0000634 [(set GR32:$dst, (X86bsf (loadi32 addr:$src))),
635 (implicit EFLAGS)]>, TB;
Evan Cheng48679f42007-12-14 02:13:44 +0000636
Evan Cheng4e33de92007-12-14 18:49:43 +0000637def BSR16rr : I<0xBD, MRMSrcReg, (outs GR16:$dst), (ins GR16:$src),
Dan Gohmancdb54c62007-12-14 15:10:00 +0000638 "bsr{w}\t{$src, $dst|$dst, $src}",
Evan Cheng7cfbfe32007-12-14 08:30:15 +0000639 [(set GR16:$dst, (X86bsr GR16:$src)), (implicit EFLAGS)]>, TB;
Evan Cheng48679f42007-12-14 02:13:44 +0000640def BSR16rm : I<0xBD, MRMSrcMem, (outs GR16:$dst), (ins i16mem:$src),
Dan Gohmancdb54c62007-12-14 15:10:00 +0000641 "bsr{w}\t{$src, $dst|$dst, $src}",
Evan Cheng7cfbfe32007-12-14 08:30:15 +0000642 [(set GR16:$dst, (X86bsr (loadi16 addr:$src))),
643 (implicit EFLAGS)]>, TB;
Evan Cheng4e33de92007-12-14 18:49:43 +0000644def BSR32rr : I<0xBD, MRMSrcReg, (outs GR32:$dst), (ins GR32:$src),
Dan Gohmancdb54c62007-12-14 15:10:00 +0000645 "bsr{l}\t{$src, $dst|$dst, $src}",
Evan Cheng7cfbfe32007-12-14 08:30:15 +0000646 [(set GR32:$dst, (X86bsr GR32:$src)), (implicit EFLAGS)]>, TB;
Evan Cheng48679f42007-12-14 02:13:44 +0000647def BSR32rm : I<0xBD, MRMSrcMem, (outs GR32:$dst), (ins i32mem:$src),
Dan Gohmancdb54c62007-12-14 15:10:00 +0000648 "bsr{l}\t{$src, $dst|$dst, $src}",
Evan Cheng7cfbfe32007-12-14 08:30:15 +0000649 [(set GR32:$dst, (X86bsr (loadi32 addr:$src))),
650 (implicit EFLAGS)]>, TB;
Evan Cheng48679f42007-12-14 02:13:44 +0000651} // Defs = [EFLAGS]
652
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000653let neverHasSideEffects = 1 in
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000654def LEA16r : I<0x8D, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +0000655 (outs GR16:$dst), (ins i32mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000656 "lea{w}\t{$src|$dst}, {$dst|$src}", []>, OpSize;
Evan Cheng1ea8e6b2008-03-27 01:41:09 +0000657let isReMaterializable = 1 in
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000658def LEA32r : I<0x8D, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +0000659 (outs GR32:$dst), (ins lea32mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000660 "lea{l}\t{$src|$dst}, {$dst|$src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000661 [(set GR32:$dst, lea32addr:$src)]>, Requires<[In32BitMode]>;
662
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000663let Defs = [ECX,EDI,ESI], Uses = [ECX,EDI,ESI] in {
Evan Chengb783fa32007-07-19 01:14:50 +0000664def REP_MOVSB : I<0xA4, RawFrm, (outs), (ins), "{rep;movsb|rep movsb}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000665 [(X86rep_movs i8)]>, REP;
Evan Chengb783fa32007-07-19 01:14:50 +0000666def REP_MOVSW : I<0xA5, RawFrm, (outs), (ins), "{rep;movsw|rep movsw}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000667 [(X86rep_movs i16)]>, REP, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +0000668def REP_MOVSD : I<0xA5, RawFrm, (outs), (ins), "{rep;movsl|rep movsd}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000669 [(X86rep_movs i32)]>, REP;
670}
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000671
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000672let Defs = [ECX,EDI], Uses = [AL,ECX,EDI] in
Evan Chengb783fa32007-07-19 01:14:50 +0000673def REP_STOSB : I<0xAA, RawFrm, (outs), (ins), "{rep;stosb|rep stosb}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000674 [(X86rep_stos i8)]>, REP;
675let Defs = [ECX,EDI], Uses = [AX,ECX,EDI] in
Evan Chengb783fa32007-07-19 01:14:50 +0000676def REP_STOSW : I<0xAB, RawFrm, (outs), (ins), "{rep;stosw|rep stosw}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000677 [(X86rep_stos i16)]>, REP, OpSize;
678let Defs = [ECX,EDI], Uses = [EAX,ECX,EDI] in
Evan Chengb783fa32007-07-19 01:14:50 +0000679def REP_STOSD : I<0xAB, RawFrm, (outs), (ins), "{rep;stosl|rep stosd}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000680 [(X86rep_stos i32)]>, REP;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000681
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000682let Defs = [RAX, RDX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000683def RDTSC : I<0x31, RawFrm, (outs), (ins), "rdtsc", [(X86rdtsc)]>,
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000684 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000685
Anton Korobeynikov39d40ba2008-01-15 07:02:33 +0000686let isBarrier = 1, hasCtrlDep = 1 in {
Chris Lattner56b941f2008-01-15 21:58:22 +0000687def TRAP : I<0x0B, RawFrm, (outs), (ins), "ud2", [(trap)]>, TB;
Anton Korobeynikov39d40ba2008-01-15 07:02:33 +0000688}
689
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000690//===----------------------------------------------------------------------===//
691// Input/Output Instructions...
692//
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000693let Defs = [AL], Uses = [DX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000694def IN8rr : I<0xEC, RawFrm, (outs), (ins),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000695 "in{b}\t{%dx, %al|%AL, %DX}", []>;
696let Defs = [AX], Uses = [DX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000697def IN16rr : I<0xED, RawFrm, (outs), (ins),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000698 "in{w}\t{%dx, %ax|%AX, %DX}", []>, OpSize;
699let Defs = [EAX], Uses = [DX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000700def IN32rr : I<0xED, RawFrm, (outs), (ins),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000701 "in{l}\t{%dx, %eax|%EAX, %DX}", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000702
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000703let Defs = [AL] in
Evan Chengb783fa32007-07-19 01:14:50 +0000704def IN8ri : Ii8<0xE4, RawFrm, (outs), (ins i16i8imm:$port),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000705 "in{b}\t{$port, %al|%AL, $port}", []>;
706let Defs = [AX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000707def IN16ri : Ii8<0xE5, RawFrm, (outs), (ins i16i8imm:$port),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000708 "in{w}\t{$port, %ax|%AX, $port}", []>, OpSize;
709let Defs = [EAX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000710def IN32ri : Ii8<0xE5, RawFrm, (outs), (ins i16i8imm:$port),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000711 "in{l}\t{$port, %eax|%EAX, $port}", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000712
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000713let Uses = [DX, AL] in
Evan Chengb783fa32007-07-19 01:14:50 +0000714def OUT8rr : I<0xEE, RawFrm, (outs), (ins),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000715 "out{b}\t{%al, %dx|%DX, %AL}", []>;
716let Uses = [DX, AX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000717def OUT16rr : I<0xEF, RawFrm, (outs), (ins),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000718 "out{w}\t{%ax, %dx|%DX, %AX}", []>, OpSize;
719let Uses = [DX, EAX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000720def OUT32rr : I<0xEF, RawFrm, (outs), (ins),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000721 "out{l}\t{%eax, %dx|%DX, %EAX}", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000722
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000723let Uses = [AL] in
Evan Chengb783fa32007-07-19 01:14:50 +0000724def OUT8ir : Ii8<0xE6, RawFrm, (outs), (ins i16i8imm:$port),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000725 "out{b}\t{%al, $port|$port, %AL}", []>;
726let Uses = [AX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000727def OUT16ir : Ii8<0xE7, RawFrm, (outs), (ins i16i8imm:$port),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000728 "out{w}\t{%ax, $port|$port, %AX}", []>, OpSize;
729let Uses = [EAX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000730def OUT32ir : Ii8<0xE7, RawFrm, (outs), (ins i16i8imm:$port),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000731 "out{l}\t{%eax, $port|$port, %EAX}", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000732
733//===----------------------------------------------------------------------===//
734// Move Instructions...
735//
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000736let neverHasSideEffects = 1 in {
Evan Chengb783fa32007-07-19 01:14:50 +0000737def MOV8rr : I<0x88, MRMDestReg, (outs GR8 :$dst), (ins GR8 :$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000738 "mov{b}\t{$src, $dst|$dst, $src}", []>;
Evan Chengb783fa32007-07-19 01:14:50 +0000739def MOV16rr : I<0x89, MRMDestReg, (outs GR16:$dst), (ins GR16:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000740 "mov{w}\t{$src, $dst|$dst, $src}", []>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +0000741def MOV32rr : I<0x89, MRMDestReg, (outs GR32:$dst), (ins GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000742 "mov{l}\t{$src, $dst|$dst, $src}", []>;
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000743}
Evan Cheng6f26e8b2008-06-18 08:13:07 +0000744let isReMaterializable = 1, isAsCheapAsAMove = 1 in {
Evan Chengb783fa32007-07-19 01:14:50 +0000745def MOV8ri : Ii8 <0xB0, AddRegFrm, (outs GR8 :$dst), (ins i8imm :$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000746 "mov{b}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000747 [(set GR8:$dst, imm:$src)]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000748def MOV16ri : Ii16<0xB8, AddRegFrm, (outs GR16:$dst), (ins i16imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000749 "mov{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000750 [(set GR16:$dst, imm:$src)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +0000751def MOV32ri : Ii32<0xB8, AddRegFrm, (outs GR32:$dst), (ins i32imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000752 "mov{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000753 [(set GR32:$dst, imm:$src)]>;
754}
Evan Chengb783fa32007-07-19 01:14:50 +0000755def MOV8mi : Ii8 <0xC6, MRM0m, (outs), (ins i8mem :$dst, i8imm :$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000756 "mov{b}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000757 [(store (i8 imm:$src), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000758def MOV16mi : Ii16<0xC7, MRM0m, (outs), (ins i16mem:$dst, i16imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000759 "mov{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000760 [(store (i16 imm:$src), addr:$dst)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +0000761def MOV32mi : Ii32<0xC7, MRM0m, (outs), (ins i32mem:$dst, i32imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000762 "mov{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000763 [(store (i32 imm:$src), addr:$dst)]>;
764
Dan Gohman5574cc72008-12-03 18:15:48 +0000765let canFoldAsLoad = 1, isReMaterializable = 1, mayHaveSideEffects = 1 in {
Evan Chengb783fa32007-07-19 01:14:50 +0000766def MOV8rm : I<0x8A, MRMSrcMem, (outs GR8 :$dst), (ins i8mem :$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000767 "mov{b}\t{$src, $dst|$dst, $src}",
Chris Lattner12208612009-04-10 00:16:23 +0000768 [(set GR8:$dst, (loadi8 addr:$src))]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000769def MOV16rm : I<0x8B, MRMSrcMem, (outs GR16:$dst), (ins i16mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000770 "mov{w}\t{$src, $dst|$dst, $src}",
Chris Lattner12208612009-04-10 00:16:23 +0000771 [(set GR16:$dst, (loadi16 addr:$src))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +0000772def MOV32rm : I<0x8B, MRMSrcMem, (outs GR32:$dst), (ins i32mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000773 "mov{l}\t{$src, $dst|$dst, $src}",
Chris Lattner12208612009-04-10 00:16:23 +0000774 [(set GR32:$dst, (loadi32 addr:$src))]>;
Evan Cheng4e84e452007-08-30 05:49:43 +0000775}
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000776
Evan Chengb783fa32007-07-19 01:14:50 +0000777def MOV8mr : I<0x88, MRMDestMem, (outs), (ins i8mem :$dst, GR8 :$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000778 "mov{b}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000779 [(store GR8:$src, addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000780def MOV16mr : I<0x89, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000781 "mov{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000782 [(store GR16:$src, addr:$dst)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +0000783def MOV32mr : I<0x89, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000784 "mov{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000785 [(store GR32:$src, addr:$dst)]>;
Dan Gohman744d4622009-04-13 16:09:41 +0000786
Dan Gohman1d8ce9c2009-04-27 16:41:36 +0000787// Versions of MOV8rr, MOV8mr, and MOV8rm that use i8mem_NOREX and GR8_NOREX so
788// that they can be used for copying and storing h registers, which can't be
789// encoded when a REX prefix is present.
Dan Gohman2da0db32009-04-15 00:04:23 +0000790let neverHasSideEffects = 1 in
Dan Gohman40ddc362009-04-15 19:48:57 +0000791def MOV8rr_NOREX : I<0x88, MRMDestReg,
792 (outs GR8_NOREX:$dst), (ins GR8_NOREX:$src),
Dan Gohman2da0db32009-04-15 00:04:23 +0000793 "mov{b}\t{$src, $dst|$dst, $src} # NOREX", []>;
794def MOV8mr_NOREX : I<0x88, MRMDestMem,
795 (outs), (ins i8mem_NOREX:$dst, GR8_NOREX:$src),
796 "mov{b}\t{$src, $dst|$dst, $src} # NOREX", []>;
Dan Gohman1d8ce9c2009-04-27 16:41:36 +0000797let canFoldAsLoad = 1, isReMaterializable = 1, mayHaveSideEffects = 1 in
798def MOV8rm_NOREX : I<0x8A, MRMSrcMem,
799 (outs GR8_NOREX:$dst), (ins i8mem_NOREX:$src),
800 "mov{b}\t{$src, $dst|$dst, $src} # NOREX", []>;
Dan Gohman744d4622009-04-13 16:09:41 +0000801
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000802//===----------------------------------------------------------------------===//
803// Fixed-Register Multiplication and Division Instructions...
804//
805
806// Extra precision multiplication
Evan Cheng55687072007-09-14 21:48:26 +0000807let Defs = [AL,AH,EFLAGS], Uses = [AL] in
Dan Gohman91888f02007-07-31 20:11:57 +0000808def MUL8r : I<0xF6, MRM4r, (outs), (ins GR8:$src), "mul{b}\t$src",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000809 // FIXME: Used for 8-bit mul, ignore result upper 8 bits.
810 // This probably ought to be moved to a def : Pat<> if the
811 // syntax can be accepted.
Bill Wendlingf5399032008-12-12 21:15:41 +0000812 [(set AL, (mul AL, GR8:$src)),
813 (implicit EFLAGS)]>; // AL,AH = AL*GR8
814
Chris Lattnerc7e96e72008-01-11 07:18:17 +0000815let Defs = [AX,DX,EFLAGS], Uses = [AX], neverHasSideEffects = 1 in
Bill Wendlingf5399032008-12-12 21:15:41 +0000816def MUL16r : I<0xF7, MRM4r, (outs), (ins GR16:$src),
817 "mul{w}\t$src",
818 []>, OpSize; // AX,DX = AX*GR16
819
Chris Lattnerc7e96e72008-01-11 07:18:17 +0000820let Defs = [EAX,EDX,EFLAGS], Uses = [EAX], neverHasSideEffects = 1 in
Bill Wendlingf5399032008-12-12 21:15:41 +0000821def MUL32r : I<0xF7, MRM4r, (outs), (ins GR32:$src),
822 "mul{l}\t$src",
823 []>; // EAX,EDX = EAX*GR32
824
Evan Cheng55687072007-09-14 21:48:26 +0000825let Defs = [AL,AH,EFLAGS], Uses = [AL] in
Evan Chengb783fa32007-07-19 01:14:50 +0000826def MUL8m : I<0xF6, MRM4m, (outs), (ins i8mem :$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000827 "mul{b}\t$src",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000828 // FIXME: Used for 8-bit mul, ignore result upper 8 bits.
829 // This probably ought to be moved to a def : Pat<> if the
830 // syntax can be accepted.
Bill Wendlingf5399032008-12-12 21:15:41 +0000831 [(set AL, (mul AL, (loadi8 addr:$src))),
832 (implicit EFLAGS)]>; // AL,AH = AL*[mem8]
833
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000834let mayLoad = 1, neverHasSideEffects = 1 in {
Evan Cheng55687072007-09-14 21:48:26 +0000835let Defs = [AX,DX,EFLAGS], Uses = [AX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000836def MUL16m : I<0xF7, MRM4m, (outs), (ins i16mem:$src),
Bill Wendlingf5399032008-12-12 21:15:41 +0000837 "mul{w}\t$src",
838 []>, OpSize; // AX,DX = AX*[mem16]
839
Evan Cheng55687072007-09-14 21:48:26 +0000840let Defs = [EAX,EDX,EFLAGS], Uses = [EAX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000841def MUL32m : I<0xF7, MRM4m, (outs), (ins i32mem:$src),
Bill Wendlingf5399032008-12-12 21:15:41 +0000842 "mul{l}\t$src",
843 []>; // EAX,EDX = EAX*[mem32]
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000844}
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000845
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000846let neverHasSideEffects = 1 in {
Evan Cheng55687072007-09-14 21:48:26 +0000847let Defs = [AL,AH,EFLAGS], Uses = [AL] in
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000848def IMUL8r : I<0xF6, MRM5r, (outs), (ins GR8:$src), "imul{b}\t$src", []>;
849 // AL,AH = AL*GR8
Evan Cheng55687072007-09-14 21:48:26 +0000850let Defs = [AX,DX,EFLAGS], Uses = [AX] in
Dan Gohman91888f02007-07-31 20:11:57 +0000851def IMUL16r : I<0xF7, MRM5r, (outs), (ins GR16:$src), "imul{w}\t$src", []>,
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000852 OpSize; // AX,DX = AX*GR16
Evan Cheng55687072007-09-14 21:48:26 +0000853let Defs = [EAX,EDX,EFLAGS], Uses = [EAX] in
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000854def IMUL32r : I<0xF7, MRM5r, (outs), (ins GR32:$src), "imul{l}\t$src", []>;
855 // EAX,EDX = EAX*GR32
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000856let mayLoad = 1 in {
Evan Cheng55687072007-09-14 21:48:26 +0000857let Defs = [AL,AH,EFLAGS], Uses = [AL] in
Evan Chengb783fa32007-07-19 01:14:50 +0000858def IMUL8m : I<0xF6, MRM5m, (outs), (ins i8mem :$src),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000859 "imul{b}\t$src", []>; // AL,AH = AL*[mem8]
Evan Cheng55687072007-09-14 21:48:26 +0000860let Defs = [AX,DX,EFLAGS], Uses = [AX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000861def IMUL16m : I<0xF7, MRM5m, (outs), (ins i16mem:$src),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000862 "imul{w}\t$src", []>, OpSize; // AX,DX = AX*[mem16]
863let Defs = [EAX,EDX], Uses = [EAX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000864def IMUL32m : I<0xF7, MRM5m, (outs), (ins i32mem:$src),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000865 "imul{l}\t$src", []>; // EAX,EDX = EAX*[mem32]
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000866}
Dan Gohmand44572d2008-11-18 21:29:14 +0000867} // neverHasSideEffects
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000868
869// unsigned division/remainder
Dale Johannesend8fd3562008-10-07 18:54:28 +0000870let Defs = [AL,AH,EFLAGS], Uses = [AX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000871def DIV8r : I<0xF6, MRM6r, (outs), (ins GR8:$src), // AX/r8 = AL,AH
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000872 "div{b}\t$src", []>;
Evan Cheng55687072007-09-14 21:48:26 +0000873let Defs = [AX,DX,EFLAGS], Uses = [AX,DX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000874def DIV16r : I<0xF7, MRM6r, (outs), (ins GR16:$src), // DX:AX/r16 = AX,DX
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000875 "div{w}\t$src", []>, OpSize;
Evan Cheng55687072007-09-14 21:48:26 +0000876let Defs = [EAX,EDX,EFLAGS], Uses = [EAX,EDX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000877def DIV32r : I<0xF7, MRM6r, (outs), (ins GR32:$src), // EDX:EAX/r32 = EAX,EDX
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000878 "div{l}\t$src", []>;
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000879let mayLoad = 1 in {
Dale Johannesend8fd3562008-10-07 18:54:28 +0000880let Defs = [AL,AH,EFLAGS], Uses = [AX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000881def DIV8m : I<0xF6, MRM6m, (outs), (ins i8mem:$src), // AX/[mem8] = AL,AH
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000882 "div{b}\t$src", []>;
Evan Cheng55687072007-09-14 21:48:26 +0000883let Defs = [AX,DX,EFLAGS], Uses = [AX,DX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000884def DIV16m : I<0xF7, MRM6m, (outs), (ins i16mem:$src), // DX:AX/[mem16] = AX,DX
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000885 "div{w}\t$src", []>, OpSize;
Evan Cheng55687072007-09-14 21:48:26 +0000886let Defs = [EAX,EDX,EFLAGS], Uses = [EAX,EDX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000887def DIV32m : I<0xF7, MRM6m, (outs), (ins i32mem:$src), // EDX:EAX/[mem32] = EAX,EDX
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000888 "div{l}\t$src", []>;
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000889}
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000890
891// Signed division/remainder.
Dale Johannesend8fd3562008-10-07 18:54:28 +0000892let Defs = [AL,AH,EFLAGS], Uses = [AX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000893def IDIV8r : I<0xF6, MRM7r, (outs), (ins GR8:$src), // AX/r8 = AL,AH
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000894 "idiv{b}\t$src", []>;
Evan Cheng55687072007-09-14 21:48:26 +0000895let Defs = [AX,DX,EFLAGS], Uses = [AX,DX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000896def IDIV16r: I<0xF7, MRM7r, (outs), (ins GR16:$src), // DX:AX/r16 = AX,DX
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000897 "idiv{w}\t$src", []>, OpSize;
Evan Cheng55687072007-09-14 21:48:26 +0000898let Defs = [EAX,EDX,EFLAGS], Uses = [EAX,EDX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000899def IDIV32r: I<0xF7, MRM7r, (outs), (ins GR32:$src), // EDX:EAX/r32 = EAX,EDX
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000900 "idiv{l}\t$src", []>;
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000901let mayLoad = 1, mayLoad = 1 in {
Dale Johannesend8fd3562008-10-07 18:54:28 +0000902let Defs = [AL,AH,EFLAGS], Uses = [AX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000903def IDIV8m : I<0xF6, MRM7m, (outs), (ins i8mem:$src), // AX/[mem8] = AL,AH
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000904 "idiv{b}\t$src", []>;
Evan Cheng55687072007-09-14 21:48:26 +0000905let Defs = [AX,DX,EFLAGS], Uses = [AX,DX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000906def IDIV16m: I<0xF7, MRM7m, (outs), (ins i16mem:$src), // DX:AX/[mem16] = AX,DX
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000907 "idiv{w}\t$src", []>, OpSize;
Evan Cheng55687072007-09-14 21:48:26 +0000908let Defs = [EAX,EDX,EFLAGS], Uses = [EAX,EDX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000909def IDIV32m: I<0xF7, MRM7m, (outs), (ins i32mem:$src), // EDX:EAX/[mem32] = EAX,EDX
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000910 "idiv{l}\t$src", []>;
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000911}
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000912
913//===----------------------------------------------------------------------===//
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000914// Two address Instructions.
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000915//
916let isTwoAddress = 1 in {
917
918// Conditional moves
Evan Cheng950aac02007-09-25 01:57:46 +0000919let Uses = [EFLAGS] in {
Evan Cheng926658c2007-10-05 23:13:21 +0000920let isCommutable = 1 in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000921def CMOVB16rr : I<0x42, MRMSrcReg, // if <u, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +0000922 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000923 "cmovb\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000924 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000925 X86_COND_B, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000926 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000927def CMOVB32rr : I<0x42, MRMSrcReg, // if <u, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +0000928 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000929 "cmovb\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000930 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000931 X86_COND_B, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000932 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000933def CMOVAE16rr: I<0x43, MRMSrcReg, // if >=u, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +0000934 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000935 "cmovae\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000936 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000937 X86_COND_AE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000938 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000939def CMOVAE32rr: I<0x43, MRMSrcReg, // if >=u, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +0000940 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000941 "cmovae\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000942 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000943 X86_COND_AE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000944 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000945def CMOVE16rr : I<0x44, MRMSrcReg, // if ==, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +0000946 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000947 "cmove\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000948 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000949 X86_COND_E, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000950 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000951def CMOVE32rr : I<0x44, MRMSrcReg, // if ==, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +0000952 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000953 "cmove\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000954 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000955 X86_COND_E, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000956 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000957def CMOVNE16rr: I<0x45, MRMSrcReg, // if !=, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +0000958 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000959 "cmovne\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000960 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000961 X86_COND_NE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000962 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000963def CMOVNE32rr: I<0x45, MRMSrcReg, // if !=, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +0000964 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000965 "cmovne\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000966 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000967 X86_COND_NE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000968 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000969def CMOVBE16rr: I<0x46, MRMSrcReg, // if <=u, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +0000970 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000971 "cmovbe\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000972 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000973 X86_COND_BE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000974 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000975def CMOVBE32rr: I<0x46, MRMSrcReg, // if <=u, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +0000976 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000977 "cmovbe\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000978 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000979 X86_COND_BE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000980 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000981def CMOVA16rr : I<0x47, MRMSrcReg, // if >u, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +0000982 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000983 "cmova\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000984 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000985 X86_COND_A, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000986 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000987def CMOVA32rr : I<0x47, MRMSrcReg, // if >u, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +0000988 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000989 "cmova\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000990 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000991 X86_COND_A, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000992 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000993def CMOVL16rr : I<0x4C, MRMSrcReg, // if <s, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +0000994 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000995 "cmovl\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000996 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000997 X86_COND_L, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000998 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000999def CMOVL32rr : I<0x4C, MRMSrcReg, // if <s, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +00001000 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001001 "cmovl\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001002 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001003 X86_COND_L, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001004 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001005def CMOVGE16rr: I<0x4D, MRMSrcReg, // if >=s, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +00001006 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001007 "cmovge\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001008 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001009 X86_COND_GE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001010 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001011def CMOVGE32rr: I<0x4D, MRMSrcReg, // if >=s, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +00001012 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001013 "cmovge\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001014 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001015 X86_COND_GE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001016 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001017def CMOVLE16rr: I<0x4E, MRMSrcReg, // if <=s, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +00001018 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001019 "cmovle\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001020 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001021 X86_COND_LE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001022 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001023def CMOVLE32rr: I<0x4E, MRMSrcReg, // if <=s, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +00001024 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001025 "cmovle\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001026 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001027 X86_COND_LE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001028 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001029def CMOVG16rr : I<0x4F, MRMSrcReg, // if >s, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +00001030 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001031 "cmovg\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001032 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001033 X86_COND_G, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001034 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001035def CMOVG32rr : I<0x4F, MRMSrcReg, // if >s, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +00001036 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001037 "cmovg\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001038 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001039 X86_COND_G, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001040 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001041def CMOVS16rr : I<0x48, MRMSrcReg, // if signed, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +00001042 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001043 "cmovs\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001044 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001045 X86_COND_S, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001046 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001047def CMOVS32rr : I<0x48, MRMSrcReg, // if signed, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +00001048 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001049 "cmovs\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001050 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001051 X86_COND_S, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001052 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001053def CMOVNS16rr: I<0x49, MRMSrcReg, // if !signed, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +00001054 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001055 "cmovns\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001056 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001057 X86_COND_NS, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001058 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001059def CMOVNS32rr: I<0x49, MRMSrcReg, // if !signed, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +00001060 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001061 "cmovns\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001062 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001063 X86_COND_NS, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001064 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001065def CMOVP16rr : I<0x4A, MRMSrcReg, // if parity, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +00001066 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001067 "cmovp\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001068 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001069 X86_COND_P, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001070 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001071def CMOVP32rr : I<0x4A, MRMSrcReg, // if parity, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +00001072 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001073 "cmovp\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001074 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001075 X86_COND_P, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001076 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001077def CMOVNP16rr : I<0x4B, MRMSrcReg, // if !parity, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +00001078 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001079 "cmovnp\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001080 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001081 X86_COND_NP, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001082 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001083def CMOVNP32rr : I<0x4B, MRMSrcReg, // if !parity, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +00001084 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001085 "cmovnp\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001086 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001087 X86_COND_NP, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001088 TB;
Dan Gohman12fd4d72009-01-07 00:35:10 +00001089def CMOVO16rr : I<0x40, MRMSrcReg, // if overflow, GR16 = GR16
1090 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
1091 "cmovo\t{$src2, $dst|$dst, $src2}",
1092 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
1093 X86_COND_O, EFLAGS))]>,
1094 TB, OpSize;
1095def CMOVO32rr : I<0x40, MRMSrcReg, // if overflow, GR32 = GR32
1096 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
1097 "cmovo\t{$src2, $dst|$dst, $src2}",
1098 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
1099 X86_COND_O, EFLAGS))]>,
Evan Cheng950aac02007-09-25 01:57:46 +00001100 TB;
Dan Gohman12fd4d72009-01-07 00:35:10 +00001101def CMOVNO16rr : I<0x41, MRMSrcReg, // if !overflow, GR16 = GR16
1102 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
1103 "cmovno\t{$src2, $dst|$dst, $src2}",
1104 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
1105 X86_COND_NO, EFLAGS))]>,
1106 TB, OpSize;
1107def CMOVNO32rr : I<0x41, MRMSrcReg, // if !overflow, GR32 = GR32
1108 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
1109 "cmovno\t{$src2, $dst|$dst, $src2}",
1110 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
1111 X86_COND_NO, EFLAGS))]>,
1112 TB;
1113} // isCommutable = 1
Evan Cheng926658c2007-10-05 23:13:21 +00001114
1115def CMOVB16rm : I<0x42, MRMSrcMem, // if <u, GR16 = [mem16]
1116 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1117 "cmovb\t{$src2, $dst|$dst, $src2}",
1118 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1119 X86_COND_B, EFLAGS))]>,
1120 TB, OpSize;
1121def CMOVB32rm : I<0x42, MRMSrcMem, // if <u, GR32 = [mem32]
1122 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1123 "cmovb\t{$src2, $dst|$dst, $src2}",
1124 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1125 X86_COND_B, EFLAGS))]>,
1126 TB;
1127def CMOVAE16rm: I<0x43, MRMSrcMem, // if >=u, GR16 = [mem16]
1128 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1129 "cmovae\t{$src2, $dst|$dst, $src2}",
1130 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1131 X86_COND_AE, EFLAGS))]>,
1132 TB, OpSize;
1133def CMOVAE32rm: I<0x43, MRMSrcMem, // if >=u, GR32 = [mem32]
1134 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1135 "cmovae\t{$src2, $dst|$dst, $src2}",
1136 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1137 X86_COND_AE, EFLAGS))]>,
1138 TB;
1139def CMOVE16rm : I<0x44, MRMSrcMem, // if ==, GR16 = [mem16]
1140 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1141 "cmove\t{$src2, $dst|$dst, $src2}",
1142 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1143 X86_COND_E, EFLAGS))]>,
1144 TB, OpSize;
1145def CMOVE32rm : I<0x44, MRMSrcMem, // if ==, GR32 = [mem32]
1146 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1147 "cmove\t{$src2, $dst|$dst, $src2}",
1148 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1149 X86_COND_E, EFLAGS))]>,
1150 TB;
1151def CMOVNE16rm: I<0x45, MRMSrcMem, // if !=, GR16 = [mem16]
1152 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1153 "cmovne\t{$src2, $dst|$dst, $src2}",
1154 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1155 X86_COND_NE, EFLAGS))]>,
1156 TB, OpSize;
1157def CMOVNE32rm: I<0x45, MRMSrcMem, // if !=, GR32 = [mem32]
1158 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1159 "cmovne\t{$src2, $dst|$dst, $src2}",
1160 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1161 X86_COND_NE, EFLAGS))]>,
1162 TB;
1163def CMOVBE16rm: I<0x46, MRMSrcMem, // if <=u, GR16 = [mem16]
1164 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1165 "cmovbe\t{$src2, $dst|$dst, $src2}",
1166 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1167 X86_COND_BE, EFLAGS))]>,
1168 TB, OpSize;
1169def CMOVBE32rm: I<0x46, MRMSrcMem, // if <=u, GR32 = [mem32]
1170 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1171 "cmovbe\t{$src2, $dst|$dst, $src2}",
1172 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1173 X86_COND_BE, EFLAGS))]>,
1174 TB;
1175def CMOVA16rm : I<0x47, MRMSrcMem, // if >u, GR16 = [mem16]
1176 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1177 "cmova\t{$src2, $dst|$dst, $src2}",
1178 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1179 X86_COND_A, EFLAGS))]>,
1180 TB, OpSize;
1181def CMOVA32rm : I<0x47, MRMSrcMem, // if >u, GR32 = [mem32]
1182 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1183 "cmova\t{$src2, $dst|$dst, $src2}",
1184 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1185 X86_COND_A, EFLAGS))]>,
1186 TB;
1187def CMOVL16rm : I<0x4C, MRMSrcMem, // if <s, GR16 = [mem16]
1188 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1189 "cmovl\t{$src2, $dst|$dst, $src2}",
1190 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1191 X86_COND_L, EFLAGS))]>,
1192 TB, OpSize;
1193def CMOVL32rm : I<0x4C, MRMSrcMem, // if <s, GR32 = [mem32]
1194 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1195 "cmovl\t{$src2, $dst|$dst, $src2}",
1196 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1197 X86_COND_L, EFLAGS))]>,
1198 TB;
1199def CMOVGE16rm: I<0x4D, MRMSrcMem, // if >=s, GR16 = [mem16]
1200 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1201 "cmovge\t{$src2, $dst|$dst, $src2}",
1202 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1203 X86_COND_GE, EFLAGS))]>,
1204 TB, OpSize;
1205def CMOVGE32rm: I<0x4D, MRMSrcMem, // if >=s, GR32 = [mem32]
1206 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1207 "cmovge\t{$src2, $dst|$dst, $src2}",
1208 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1209 X86_COND_GE, EFLAGS))]>,
1210 TB;
1211def CMOVLE16rm: I<0x4E, MRMSrcMem, // if <=s, GR16 = [mem16]
1212 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1213 "cmovle\t{$src2, $dst|$dst, $src2}",
1214 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1215 X86_COND_LE, EFLAGS))]>,
1216 TB, OpSize;
1217def CMOVLE32rm: I<0x4E, MRMSrcMem, // if <=s, GR32 = [mem32]
1218 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1219 "cmovle\t{$src2, $dst|$dst, $src2}",
1220 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1221 X86_COND_LE, EFLAGS))]>,
1222 TB;
1223def CMOVG16rm : I<0x4F, MRMSrcMem, // if >s, GR16 = [mem16]
1224 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1225 "cmovg\t{$src2, $dst|$dst, $src2}",
1226 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1227 X86_COND_G, EFLAGS))]>,
1228 TB, OpSize;
1229def CMOVG32rm : I<0x4F, MRMSrcMem, // if >s, GR32 = [mem32]
1230 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1231 "cmovg\t{$src2, $dst|$dst, $src2}",
1232 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1233 X86_COND_G, EFLAGS))]>,
1234 TB;
1235def CMOVS16rm : I<0x48, MRMSrcMem, // if signed, GR16 = [mem16]
1236 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1237 "cmovs\t{$src2, $dst|$dst, $src2}",
1238 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1239 X86_COND_S, EFLAGS))]>,
1240 TB, OpSize;
1241def CMOVS32rm : I<0x48, MRMSrcMem, // if signed, GR32 = [mem32]
1242 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1243 "cmovs\t{$src2, $dst|$dst, $src2}",
1244 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1245 X86_COND_S, EFLAGS))]>,
1246 TB;
1247def CMOVNS16rm: I<0x49, MRMSrcMem, // if !signed, GR16 = [mem16]
1248 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1249 "cmovns\t{$src2, $dst|$dst, $src2}",
1250 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1251 X86_COND_NS, EFLAGS))]>,
1252 TB, OpSize;
1253def CMOVNS32rm: I<0x49, MRMSrcMem, // if !signed, GR32 = [mem32]
1254 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1255 "cmovns\t{$src2, $dst|$dst, $src2}",
1256 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1257 X86_COND_NS, EFLAGS))]>,
1258 TB;
1259def CMOVP16rm : I<0x4A, MRMSrcMem, // if parity, GR16 = [mem16]
1260 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1261 "cmovp\t{$src2, $dst|$dst, $src2}",
1262 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1263 X86_COND_P, EFLAGS))]>,
1264 TB, OpSize;
1265def CMOVP32rm : I<0x4A, MRMSrcMem, // if parity, GR32 = [mem32]
1266 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1267 "cmovp\t{$src2, $dst|$dst, $src2}",
1268 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1269 X86_COND_P, EFLAGS))]>,
1270 TB;
1271def CMOVNP16rm : I<0x4B, MRMSrcMem, // if !parity, GR16 = [mem16]
1272 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1273 "cmovnp\t{$src2, $dst|$dst, $src2}",
1274 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1275 X86_COND_NP, EFLAGS))]>,
1276 TB, OpSize;
Dan Gohman12fd4d72009-01-07 00:35:10 +00001277def CMOVNP32rm : I<0x4B, MRMSrcMem, // if !parity, GR32 = [mem32]
1278 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1279 "cmovnp\t{$src2, $dst|$dst, $src2}",
1280 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1281 X86_COND_NP, EFLAGS))]>,
1282 TB;
1283def CMOVO16rm : I<0x40, MRMSrcMem, // if overflow, GR16 = [mem16]
1284 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1285 "cmovo\t{$src2, $dst|$dst, $src2}",
1286 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1287 X86_COND_O, EFLAGS))]>,
1288 TB, OpSize;
1289def CMOVO32rm : I<0x40, MRMSrcMem, // if overflow, GR32 = [mem32]
1290 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1291 "cmovo\t{$src2, $dst|$dst, $src2}",
1292 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1293 X86_COND_O, EFLAGS))]>,
1294 TB;
1295def CMOVNO16rm : I<0x41, MRMSrcMem, // if !overflow, GR16 = [mem16]
1296 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1297 "cmovno\t{$src2, $dst|$dst, $src2}",
1298 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1299 X86_COND_NO, EFLAGS))]>,
1300 TB, OpSize;
1301def CMOVNO32rm : I<0x41, MRMSrcMem, // if !overflow, GR32 = [mem32]
1302 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1303 "cmovno\t{$src2, $dst|$dst, $src2}",
1304 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1305 X86_COND_NO, EFLAGS))]>,
1306 TB;
Evan Cheng950aac02007-09-25 01:57:46 +00001307} // Uses = [EFLAGS]
1308
1309
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001310// unary instructions
1311let CodeSize = 2 in {
Evan Cheng55687072007-09-14 21:48:26 +00001312let Defs = [EFLAGS] in {
Dan Gohman91888f02007-07-31 20:11:57 +00001313def NEG8r : I<0xF6, MRM3r, (outs GR8 :$dst), (ins GR8 :$src), "neg{b}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001314 [(set GR8:$dst, (ineg GR8:$src)),
1315 (implicit EFLAGS)]>;
Dan Gohman91888f02007-07-31 20:11:57 +00001316def NEG16r : I<0xF7, MRM3r, (outs GR16:$dst), (ins GR16:$src), "neg{w}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001317 [(set GR16:$dst, (ineg GR16:$src)),
1318 (implicit EFLAGS)]>, OpSize;
Dan Gohman91888f02007-07-31 20:11:57 +00001319def NEG32r : I<0xF7, MRM3r, (outs GR32:$dst), (ins GR32:$src), "neg{l}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001320 [(set GR32:$dst, (ineg GR32:$src)),
1321 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001322let isTwoAddress = 0 in {
Dan Gohman91888f02007-07-31 20:11:57 +00001323 def NEG8m : I<0xF6, MRM3m, (outs), (ins i8mem :$dst), "neg{b}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001324 [(store (ineg (loadi8 addr:$dst)), addr:$dst),
1325 (implicit EFLAGS)]>;
Dan Gohman91888f02007-07-31 20:11:57 +00001326 def NEG16m : I<0xF7, MRM3m, (outs), (ins i16mem:$dst), "neg{w}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001327 [(store (ineg (loadi16 addr:$dst)), addr:$dst),
1328 (implicit EFLAGS)]>, OpSize;
Dan Gohman91888f02007-07-31 20:11:57 +00001329 def NEG32m : I<0xF7, MRM3m, (outs), (ins i32mem:$dst), "neg{l}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001330 [(store (ineg (loadi32 addr:$dst)), addr:$dst),
1331 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001332}
Evan Cheng55687072007-09-14 21:48:26 +00001333} // Defs = [EFLAGS]
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001334
Evan Chengc6cee682009-01-21 02:09:05 +00001335// Match xor -1 to not. Favors these over a move imm + xor to save code size.
1336let AddedComplexity = 15 in {
Dan Gohman91888f02007-07-31 20:11:57 +00001337def NOT8r : I<0xF6, MRM2r, (outs GR8 :$dst), (ins GR8 :$src), "not{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001338 [(set GR8:$dst, (not GR8:$src))]>;
Dan Gohman91888f02007-07-31 20:11:57 +00001339def NOT16r : I<0xF7, MRM2r, (outs GR16:$dst), (ins GR16:$src), "not{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001340 [(set GR16:$dst, (not GR16:$src))]>, OpSize;
Dan Gohman91888f02007-07-31 20:11:57 +00001341def NOT32r : I<0xF7, MRM2r, (outs GR32:$dst), (ins GR32:$src), "not{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001342 [(set GR32:$dst, (not GR32:$src))]>;
Evan Chengc6cee682009-01-21 02:09:05 +00001343}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001344let isTwoAddress = 0 in {
Dan Gohman91888f02007-07-31 20:11:57 +00001345 def NOT8m : I<0xF6, MRM2m, (outs), (ins i8mem :$dst), "not{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001346 [(store (not (loadi8 addr:$dst)), addr:$dst)]>;
Dan Gohman91888f02007-07-31 20:11:57 +00001347 def NOT16m : I<0xF7, MRM2m, (outs), (ins i16mem:$dst), "not{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001348 [(store (not (loadi16 addr:$dst)), addr:$dst)]>, OpSize;
Dan Gohman91888f02007-07-31 20:11:57 +00001349 def NOT32m : I<0xF7, MRM2m, (outs), (ins i32mem:$dst), "not{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001350 [(store (not (loadi32 addr:$dst)), addr:$dst)]>;
1351}
1352} // CodeSize
1353
1354// TODO: inc/dec is slow for P4, but fast for Pentium-M.
Evan Cheng55687072007-09-14 21:48:26 +00001355let Defs = [EFLAGS] in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001356let CodeSize = 2 in
Dan Gohman91888f02007-07-31 20:11:57 +00001357def INC8r : I<0xFE, MRM0r, (outs GR8 :$dst), (ins GR8 :$src), "inc{b}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001358 [(set GR8:$dst, (add GR8:$src, 1)),
1359 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001360let isConvertibleToThreeAddress = 1, CodeSize = 1 in { // Can xform into LEA.
Dan Gohman91888f02007-07-31 20:11:57 +00001361def INC16r : I<0x40, AddRegFrm, (outs GR16:$dst), (ins GR16:$src), "inc{w}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001362 [(set GR16:$dst, (add GR16:$src, 1)),
1363 (implicit EFLAGS)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001364 OpSize, Requires<[In32BitMode]>;
Dan Gohman91888f02007-07-31 20:11:57 +00001365def INC32r : I<0x40, AddRegFrm, (outs GR32:$dst), (ins GR32:$src), "inc{l}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001366 [(set GR32:$dst, (add GR32:$src, 1)),
1367 (implicit EFLAGS)]>, Requires<[In32BitMode]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001368}
1369let isTwoAddress = 0, CodeSize = 2 in {
Dan Gohman91888f02007-07-31 20:11:57 +00001370 def INC8m : I<0xFE, MRM0m, (outs), (ins i8mem :$dst), "inc{b}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001371 [(store (add (loadi8 addr:$dst), 1), addr:$dst),
1372 (implicit EFLAGS)]>;
Dan Gohman91888f02007-07-31 20:11:57 +00001373 def INC16m : I<0xFF, MRM0m, (outs), (ins i16mem:$dst), "inc{w}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001374 [(store (add (loadi16 addr:$dst), 1), addr:$dst),
1375 (implicit EFLAGS)]>,
Evan Cheng4a7e72f2007-10-19 21:23:22 +00001376 OpSize, Requires<[In32BitMode]>;
Dan Gohman91888f02007-07-31 20:11:57 +00001377 def INC32m : I<0xFF, MRM0m, (outs), (ins i32mem:$dst), "inc{l}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001378 [(store (add (loadi32 addr:$dst), 1), addr:$dst),
1379 (implicit EFLAGS)]>,
Evan Cheng4a7e72f2007-10-19 21:23:22 +00001380 Requires<[In32BitMode]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001381}
1382
1383let CodeSize = 2 in
Dan Gohman91888f02007-07-31 20:11:57 +00001384def DEC8r : I<0xFE, MRM1r, (outs GR8 :$dst), (ins GR8 :$src), "dec{b}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001385 [(set GR8:$dst, (add GR8:$src, -1)),
1386 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001387let isConvertibleToThreeAddress = 1, CodeSize = 1 in { // Can xform into LEA.
Dan Gohman91888f02007-07-31 20:11:57 +00001388def DEC16r : I<0x48, AddRegFrm, (outs GR16:$dst), (ins GR16:$src), "dec{w}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001389 [(set GR16:$dst, (add GR16:$src, -1)),
1390 (implicit EFLAGS)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001391 OpSize, Requires<[In32BitMode]>;
Dan Gohman91888f02007-07-31 20:11:57 +00001392def DEC32r : I<0x48, AddRegFrm, (outs GR32:$dst), (ins GR32:$src), "dec{l}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001393 [(set GR32:$dst, (add GR32:$src, -1)),
1394 (implicit EFLAGS)]>, Requires<[In32BitMode]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001395}
1396
1397let isTwoAddress = 0, CodeSize = 2 in {
Dan Gohman91888f02007-07-31 20:11:57 +00001398 def DEC8m : I<0xFE, MRM1m, (outs), (ins i8mem :$dst), "dec{b}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001399 [(store (add (loadi8 addr:$dst), -1), addr:$dst),
1400 (implicit EFLAGS)]>;
Dan Gohman91888f02007-07-31 20:11:57 +00001401 def DEC16m : I<0xFF, MRM1m, (outs), (ins i16mem:$dst), "dec{w}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001402 [(store (add (loadi16 addr:$dst), -1), addr:$dst),
1403 (implicit EFLAGS)]>,
Evan Cheng4a7e72f2007-10-19 21:23:22 +00001404 OpSize, Requires<[In32BitMode]>;
Dan Gohman91888f02007-07-31 20:11:57 +00001405 def DEC32m : I<0xFF, MRM1m, (outs), (ins i32mem:$dst), "dec{l}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001406 [(store (add (loadi32 addr:$dst), -1), addr:$dst),
1407 (implicit EFLAGS)]>,
Evan Cheng4a7e72f2007-10-19 21:23:22 +00001408 Requires<[In32BitMode]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001409}
Evan Cheng55687072007-09-14 21:48:26 +00001410} // Defs = [EFLAGS]
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001411
1412// Logical operators...
Evan Cheng55687072007-09-14 21:48:26 +00001413let Defs = [EFLAGS] in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001414let isCommutable = 1 in { // X = AND Y, Z --> X = AND Z, Y
1415def AND8rr : I<0x20, MRMDestReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001416 (outs GR8 :$dst), (ins GR8 :$src1, GR8 :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001417 "and{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001418 [(set GR8:$dst, (and GR8:$src1, GR8:$src2)),
1419 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001420def AND16rr : I<0x21, MRMDestReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001421 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001422 "and{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001423 [(set GR16:$dst, (and GR16:$src1, GR16:$src2)),
1424 (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001425def AND32rr : I<0x21, MRMDestReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001426 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001427 "and{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001428 [(set GR32:$dst, (and GR32:$src1, GR32:$src2)),
1429 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001430}
1431
1432def AND8rm : I<0x22, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001433 (outs GR8 :$dst), (ins GR8 :$src1, i8mem :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001434 "and{b}\t{$src2, $dst|$dst, $src2}",
Chris Lattner12208612009-04-10 00:16:23 +00001435 [(set GR8:$dst, (and GR8:$src1, (loadi8 addr:$src2))),
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001436 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001437def AND16rm : I<0x23, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001438 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001439 "and{w}\t{$src2, $dst|$dst, $src2}",
Chris Lattner12208612009-04-10 00:16:23 +00001440 [(set GR16:$dst, (and GR16:$src1, (loadi16 addr:$src2))),
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001441 (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001442def AND32rm : I<0x23, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001443 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001444 "and{l}\t{$src2, $dst|$dst, $src2}",
Chris Lattner12208612009-04-10 00:16:23 +00001445 [(set GR32:$dst, (and GR32:$src1, (loadi32 addr:$src2))),
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001446 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001447
1448def AND8ri : Ii8<0x80, MRM4r,
Evan Chengb783fa32007-07-19 01:14:50 +00001449 (outs GR8 :$dst), (ins GR8 :$src1, i8imm :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001450 "and{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001451 [(set GR8:$dst, (and GR8:$src1, imm:$src2)),
1452 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001453def AND16ri : Ii16<0x81, MRM4r,
Evan Chengb783fa32007-07-19 01:14:50 +00001454 (outs GR16:$dst), (ins GR16:$src1, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001455 "and{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001456 [(set GR16:$dst, (and GR16:$src1, imm:$src2)),
1457 (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001458def AND32ri : Ii32<0x81, MRM4r,
Evan Chengb783fa32007-07-19 01:14:50 +00001459 (outs GR32:$dst), (ins GR32:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001460 "and{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001461 [(set GR32:$dst, (and GR32:$src1, imm:$src2)),
1462 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001463def AND16ri8 : Ii8<0x83, MRM4r,
Evan Chengb783fa32007-07-19 01:14:50 +00001464 (outs GR16:$dst), (ins GR16:$src1, i16i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001465 "and{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001466 [(set GR16:$dst, (and GR16:$src1, i16immSExt8:$src2)),
1467 (implicit EFLAGS)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001468 OpSize;
1469def AND32ri8 : Ii8<0x83, MRM4r,
Evan Chengb783fa32007-07-19 01:14:50 +00001470 (outs GR32:$dst), (ins GR32:$src1, i32i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001471 "and{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001472 [(set GR32:$dst, (and GR32:$src1, i32immSExt8:$src2)),
1473 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001474
1475let isTwoAddress = 0 in {
1476 def AND8mr : I<0x20, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001477 (outs), (ins i8mem :$dst, GR8 :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001478 "and{b}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001479 [(store (and (load addr:$dst), GR8:$src), addr:$dst),
1480 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001481 def AND16mr : I<0x21, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001482 (outs), (ins i16mem:$dst, GR16:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001483 "and{w}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001484 [(store (and (load addr:$dst), GR16:$src), addr:$dst),
1485 (implicit EFLAGS)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001486 OpSize;
1487 def AND32mr : I<0x21, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001488 (outs), (ins i32mem:$dst, GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001489 "and{l}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001490 [(store (and (load addr:$dst), GR32:$src), addr:$dst),
1491 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001492 def AND8mi : Ii8<0x80, MRM4m,
Evan Chengb783fa32007-07-19 01:14:50 +00001493 (outs), (ins i8mem :$dst, i8imm :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001494 "and{b}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001495 [(store (and (loadi8 addr:$dst), imm:$src), addr:$dst),
1496 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001497 def AND16mi : Ii16<0x81, MRM4m,
Evan Chengb783fa32007-07-19 01:14:50 +00001498 (outs), (ins i16mem:$dst, i16imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001499 "and{w}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001500 [(store (and (loadi16 addr:$dst), imm:$src), addr:$dst),
1501 (implicit EFLAGS)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001502 OpSize;
1503 def AND32mi : Ii32<0x81, MRM4m,
Evan Chengb783fa32007-07-19 01:14:50 +00001504 (outs), (ins i32mem:$dst, i32imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001505 "and{l}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001506 [(store (and (loadi32 addr:$dst), imm:$src), addr:$dst),
1507 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001508 def AND16mi8 : Ii8<0x83, MRM4m,
Evan Chengb783fa32007-07-19 01:14:50 +00001509 (outs), (ins i16mem:$dst, i16i8imm :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001510 "and{w}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001511 [(store (and (load addr:$dst), i16immSExt8:$src), addr:$dst),
1512 (implicit EFLAGS)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001513 OpSize;
1514 def AND32mi8 : Ii8<0x83, MRM4m,
Evan Chengb783fa32007-07-19 01:14:50 +00001515 (outs), (ins i32mem:$dst, i32i8imm :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001516 "and{l}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001517 [(store (and (load addr:$dst), i32immSExt8:$src), addr:$dst),
1518 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001519}
1520
1521
1522let isCommutable = 1 in { // X = OR Y, Z --> X = OR Z, Y
Evan Chengb783fa32007-07-19 01:14:50 +00001523def OR8rr : I<0x08, MRMDestReg, (outs GR8 :$dst), (ins GR8 :$src1, GR8 :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001524 "or{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001525 [(set GR8:$dst, (or GR8:$src1, GR8:$src2)),
1526 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001527def OR16rr : I<0x09, MRMDestReg, (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001528 "or{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001529 [(set GR16:$dst, (or GR16:$src1, GR16:$src2)),
1530 (implicit EFLAGS)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001531def OR32rr : I<0x09, MRMDestReg, (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001532 "or{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001533 [(set GR32:$dst, (or GR32:$src1, GR32:$src2)),
1534 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001535}
Evan Chengb783fa32007-07-19 01:14:50 +00001536def OR8rm : I<0x0A, MRMSrcMem , (outs GR8 :$dst), (ins GR8 :$src1, i8mem :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001537 "or{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001538 [(set GR8:$dst, (or GR8:$src1, (load addr:$src2))),
1539 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001540def OR16rm : I<0x0B, MRMSrcMem , (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001541 "or{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001542 [(set GR16:$dst, (or GR16:$src1, (load addr:$src2))),
1543 (implicit EFLAGS)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001544def OR32rm : I<0x0B, MRMSrcMem , (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001545 "or{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001546 [(set GR32:$dst, (or GR32:$src1, (load addr:$src2))),
1547 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001548
Evan Chengb783fa32007-07-19 01:14:50 +00001549def OR8ri : Ii8 <0x80, MRM1r, (outs GR8 :$dst), (ins GR8 :$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001550 "or{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001551 [(set GR8:$dst, (or GR8:$src1, imm:$src2)),
1552 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001553def OR16ri : Ii16<0x81, MRM1r, (outs GR16:$dst), (ins GR16:$src1, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001554 "or{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001555 [(set GR16:$dst, (or GR16:$src1, imm:$src2)),
1556 (implicit EFLAGS)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001557def OR32ri : Ii32<0x81, MRM1r, (outs GR32:$dst), (ins GR32:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001558 "or{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001559 [(set GR32:$dst, (or GR32:$src1, imm:$src2)),
1560 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001561
Evan Chengb783fa32007-07-19 01:14:50 +00001562def OR16ri8 : Ii8<0x83, MRM1r, (outs GR16:$dst), (ins GR16:$src1, i16i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001563 "or{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001564 [(set GR16:$dst, (or GR16:$src1, i16immSExt8:$src2)),
1565 (implicit EFLAGS)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001566def OR32ri8 : Ii8<0x83, MRM1r, (outs GR32:$dst), (ins GR32:$src1, i32i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001567 "or{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001568 [(set GR32:$dst, (or GR32:$src1, i32immSExt8:$src2)),
1569 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001570let isTwoAddress = 0 in {
Evan Chengb783fa32007-07-19 01:14:50 +00001571 def OR8mr : I<0x08, MRMDestMem, (outs), (ins i8mem:$dst, GR8:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001572 "or{b}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001573 [(store (or (load addr:$dst), GR8:$src), addr:$dst),
1574 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001575 def OR16mr : I<0x09, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001576 "or{w}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001577 [(store (or (load addr:$dst), GR16:$src), addr:$dst),
1578 (implicit EFLAGS)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001579 def OR32mr : I<0x09, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001580 "or{l}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001581 [(store (or (load addr:$dst), GR32:$src), addr:$dst),
1582 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001583 def OR8mi : Ii8<0x80, MRM1m, (outs), (ins i8mem :$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001584 "or{b}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001585 [(store (or (loadi8 addr:$dst), imm:$src), addr:$dst),
1586 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001587 def OR16mi : Ii16<0x81, MRM1m, (outs), (ins i16mem:$dst, i16imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001588 "or{w}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001589 [(store (or (loadi16 addr:$dst), imm:$src), addr:$dst),
1590 (implicit EFLAGS)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001591 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001592 def OR32mi : Ii32<0x81, MRM1m, (outs), (ins i32mem:$dst, i32imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001593 "or{l}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001594 [(store (or (loadi32 addr:$dst), imm:$src), addr:$dst),
1595 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001596 def OR16mi8 : Ii8<0x83, MRM1m, (outs), (ins i16mem:$dst, i16i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001597 "or{w}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001598 [(store (or (load addr:$dst), i16immSExt8:$src), addr:$dst),
1599 (implicit EFLAGS)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001600 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001601 def OR32mi8 : Ii8<0x83, MRM1m, (outs), (ins i32mem:$dst, i32i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001602 "or{l}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001603 [(store (or (load addr:$dst), i32immSExt8:$src), addr:$dst),
1604 (implicit EFLAGS)]>;
Bill Wendlingba5d5b02008-05-29 01:02:09 +00001605} // isTwoAddress = 0
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001606
1607
Evan Cheng6f26e8b2008-06-18 08:13:07 +00001608let isCommutable = 1 in { // X = XOR Y, Z --> X = XOR Z, Y
Bill Wendlingba5d5b02008-05-29 01:02:09 +00001609 def XOR8rr : I<0x30, MRMDestReg,
1610 (outs GR8 :$dst), (ins GR8 :$src1, GR8 :$src2),
1611 "xor{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001612 [(set GR8:$dst, (xor GR8:$src1, GR8:$src2)),
1613 (implicit EFLAGS)]>;
Bill Wendlingba5d5b02008-05-29 01:02:09 +00001614 def XOR16rr : I<0x31, MRMDestReg,
1615 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
1616 "xor{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001617 [(set GR16:$dst, (xor GR16:$src1, GR16:$src2)),
1618 (implicit EFLAGS)]>, OpSize;
Bill Wendlingba5d5b02008-05-29 01:02:09 +00001619 def XOR32rr : I<0x31, MRMDestReg,
1620 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
1621 "xor{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001622 [(set GR32:$dst, (xor GR32:$src1, GR32:$src2)),
1623 (implicit EFLAGS)]>;
Evan Cheng6f26e8b2008-06-18 08:13:07 +00001624} // isCommutable = 1
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001625
1626def XOR8rm : I<0x32, MRMSrcMem ,
Evan Chengb783fa32007-07-19 01:14:50 +00001627 (outs GR8 :$dst), (ins GR8:$src1, i8mem :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001628 "xor{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001629 [(set GR8:$dst, (xor GR8:$src1, (load addr:$src2))),
1630 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001631def XOR16rm : I<0x33, MRMSrcMem ,
Evan Chengb783fa32007-07-19 01:14:50 +00001632 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001633 "xor{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001634 [(set GR16:$dst, (xor GR16:$src1, (load addr:$src2))),
1635 (implicit EFLAGS)]>,
Bill Wendlingba5d5b02008-05-29 01:02:09 +00001636 OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001637def XOR32rm : I<0x33, MRMSrcMem ,
Evan Chengb783fa32007-07-19 01:14:50 +00001638 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001639 "xor{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001640 [(set GR32:$dst, (xor GR32:$src1, (load addr:$src2))),
1641 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001642
Bill Wendlingbac38eb2008-05-29 03:46:36 +00001643def XOR8ri : Ii8<0x80, MRM6r,
1644 (outs GR8:$dst), (ins GR8:$src1, i8imm:$src2),
1645 "xor{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001646 [(set GR8:$dst, (xor GR8:$src1, imm:$src2)),
1647 (implicit EFLAGS)]>;
Bill Wendlingbac38eb2008-05-29 03:46:36 +00001648def XOR16ri : Ii16<0x81, MRM6r,
1649 (outs GR16:$dst), (ins GR16:$src1, i16imm:$src2),
1650 "xor{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001651 [(set GR16:$dst, (xor GR16:$src1, imm:$src2)),
1652 (implicit EFLAGS)]>, OpSize;
Bill Wendlingbac38eb2008-05-29 03:46:36 +00001653def XOR32ri : Ii32<0x81, MRM6r,
1654 (outs GR32:$dst), (ins GR32:$src1, i32imm:$src2),
1655 "xor{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001656 [(set GR32:$dst, (xor GR32:$src1, imm:$src2)),
1657 (implicit EFLAGS)]>;
Bill Wendlingbac38eb2008-05-29 03:46:36 +00001658def XOR16ri8 : Ii8<0x83, MRM6r,
1659 (outs GR16:$dst), (ins GR16:$src1, i16i8imm:$src2),
1660 "xor{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001661 [(set GR16:$dst, (xor GR16:$src1, i16immSExt8:$src2)),
1662 (implicit EFLAGS)]>,
Bill Wendlingbac38eb2008-05-29 03:46:36 +00001663 OpSize;
1664def XOR32ri8 : Ii8<0x83, MRM6r,
1665 (outs GR32:$dst), (ins GR32:$src1, i32i8imm:$src2),
1666 "xor{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001667 [(set GR32:$dst, (xor GR32:$src1, i32immSExt8:$src2)),
1668 (implicit EFLAGS)]>;
Bill Wendlingba5d5b02008-05-29 01:02:09 +00001669
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001670let isTwoAddress = 0 in {
1671 def XOR8mr : I<0x30, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001672 (outs), (ins i8mem :$dst, GR8 :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001673 "xor{b}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001674 [(store (xor (load addr:$dst), GR8:$src), addr:$dst),
1675 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001676 def XOR16mr : I<0x31, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001677 (outs), (ins i16mem:$dst, GR16:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001678 "xor{w}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001679 [(store (xor (load addr:$dst), GR16:$src), addr:$dst),
1680 (implicit EFLAGS)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001681 OpSize;
1682 def XOR32mr : I<0x31, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001683 (outs), (ins i32mem:$dst, GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001684 "xor{l}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001685 [(store (xor (load addr:$dst), GR32:$src), addr:$dst),
1686 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001687 def XOR8mi : Ii8<0x80, MRM6m,
Evan Chengb783fa32007-07-19 01:14:50 +00001688 (outs), (ins i8mem :$dst, i8imm :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001689 "xor{b}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001690 [(store (xor (loadi8 addr:$dst), imm:$src), addr:$dst),
1691 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001692 def XOR16mi : Ii16<0x81, MRM6m,
Evan Chengb783fa32007-07-19 01:14:50 +00001693 (outs), (ins i16mem:$dst, i16imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001694 "xor{w}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001695 [(store (xor (loadi16 addr:$dst), imm:$src), addr:$dst),
1696 (implicit EFLAGS)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001697 OpSize;
1698 def XOR32mi : Ii32<0x81, MRM6m,
Evan Chengb783fa32007-07-19 01:14:50 +00001699 (outs), (ins i32mem:$dst, i32imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001700 "xor{l}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001701 [(store (xor (loadi32 addr:$dst), imm:$src), addr:$dst),
1702 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001703 def XOR16mi8 : Ii8<0x83, MRM6m,
Evan Chengb783fa32007-07-19 01:14:50 +00001704 (outs), (ins i16mem:$dst, i16i8imm :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001705 "xor{w}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001706 [(store (xor (load addr:$dst), i16immSExt8:$src), addr:$dst),
1707 (implicit EFLAGS)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001708 OpSize;
1709 def XOR32mi8 : Ii8<0x83, MRM6m,
Evan Chengb783fa32007-07-19 01:14:50 +00001710 (outs), (ins i32mem:$dst, i32i8imm :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001711 "xor{l}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001712 [(store (xor (load addr:$dst), i32immSExt8:$src), addr:$dst),
1713 (implicit EFLAGS)]>;
Bill Wendlingba5d5b02008-05-29 01:02:09 +00001714} // isTwoAddress = 0
Evan Cheng55687072007-09-14 21:48:26 +00001715} // Defs = [EFLAGS]
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001716
1717// Shift instructions
Evan Cheng55687072007-09-14 21:48:26 +00001718let Defs = [EFLAGS] in {
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001719let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00001720def SHL8rCL : I<0xD2, MRM4r, (outs GR8 :$dst), (ins GR8 :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001721 "shl{b}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001722 [(set GR8:$dst, (shl GR8:$src, CL))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001723def SHL16rCL : I<0xD3, MRM4r, (outs GR16:$dst), (ins GR16:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001724 "shl{w}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001725 [(set GR16:$dst, (shl GR16:$src, CL))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001726def SHL32rCL : I<0xD3, MRM4r, (outs GR32:$dst), (ins GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001727 "shl{l}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001728 [(set GR32:$dst, (shl GR32:$src, CL))]>;
Bill Wendlingba5d5b02008-05-29 01:02:09 +00001729} // Uses = [CL]
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001730
Evan Chengb783fa32007-07-19 01:14:50 +00001731def SHL8ri : Ii8<0xC0, MRM4r, (outs GR8 :$dst), (ins GR8 :$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001732 "shl{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001733 [(set GR8:$dst, (shl GR8:$src1, (i8 imm:$src2)))]>;
1734let isConvertibleToThreeAddress = 1 in { // Can transform into LEA.
Evan Chengb783fa32007-07-19 01:14:50 +00001735def SHL16ri : Ii8<0xC1, MRM4r, (outs GR16:$dst), (ins GR16:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001736 "shl{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001737 [(set GR16:$dst, (shl GR16:$src1, (i8 imm:$src2)))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001738def SHL32ri : Ii8<0xC1, MRM4r, (outs GR32:$dst), (ins GR32:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001739 "shl{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001740 [(set GR32:$dst, (shl GR32:$src1, (i8 imm:$src2)))]>;
Chris Lattnerf4005a82008-01-11 18:00:50 +00001741// NOTE: We don't use shifts of a register by one, because 'add reg,reg' is
1742// cheaper.
Bill Wendlingba5d5b02008-05-29 01:02:09 +00001743} // isConvertibleToThreeAddress = 1
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001744
1745let isTwoAddress = 0 in {
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001746 let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00001747 def SHL8mCL : I<0xD2, MRM4m, (outs), (ins i8mem :$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001748 "shl{b}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001749 [(store (shl (loadi8 addr:$dst), CL), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001750 def SHL16mCL : I<0xD3, MRM4m, (outs), (ins i16mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001751 "shl{w}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001752 [(store (shl (loadi16 addr:$dst), CL), addr:$dst)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001753 def SHL32mCL : I<0xD3, MRM4m, (outs), (ins i32mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001754 "shl{l}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001755 [(store (shl (loadi32 addr:$dst), CL), addr:$dst)]>;
1756 }
Evan Chengb783fa32007-07-19 01:14:50 +00001757 def SHL8mi : Ii8<0xC0, MRM4m, (outs), (ins i8mem :$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001758 "shl{b}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001759 [(store (shl (loadi8 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001760 def SHL16mi : Ii8<0xC1, MRM4m, (outs), (ins i16mem:$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001761 "shl{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001762 [(store (shl (loadi16 addr:$dst), (i8 imm:$src)), addr:$dst)]>,
1763 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001764 def SHL32mi : Ii8<0xC1, MRM4m, (outs), (ins i32mem:$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001765 "shl{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001766 [(store (shl (loadi32 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
1767
1768 // Shift by 1
Evan Chengb783fa32007-07-19 01:14:50 +00001769 def SHL8m1 : I<0xD0, MRM4m, (outs), (ins i8mem :$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001770 "shl{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001771 [(store (shl (loadi8 addr:$dst), (i8 1)), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001772 def SHL16m1 : I<0xD1, MRM4m, (outs), (ins i16mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001773 "shl{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001774 [(store (shl (loadi16 addr:$dst), (i8 1)), addr:$dst)]>,
1775 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001776 def SHL32m1 : I<0xD1, MRM4m, (outs), (ins i32mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001777 "shl{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001778 [(store (shl (loadi32 addr:$dst), (i8 1)), addr:$dst)]>;
1779}
1780
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001781let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00001782def SHR8rCL : I<0xD2, MRM5r, (outs GR8 :$dst), (ins GR8 :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001783 "shr{b}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001784 [(set GR8:$dst, (srl GR8:$src, CL))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001785def SHR16rCL : I<0xD3, MRM5r, (outs GR16:$dst), (ins GR16:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001786 "shr{w}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001787 [(set GR16:$dst, (srl GR16:$src, CL))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001788def SHR32rCL : I<0xD3, MRM5r, (outs GR32:$dst), (ins GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001789 "shr{l}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001790 [(set GR32:$dst, (srl GR32:$src, CL))]>;
1791}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001792
Evan Chengb783fa32007-07-19 01:14:50 +00001793def SHR8ri : Ii8<0xC0, MRM5r, (outs GR8:$dst), (ins GR8:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001794 "shr{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001795 [(set GR8:$dst, (srl GR8:$src1, (i8 imm:$src2)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001796def SHR16ri : Ii8<0xC1, MRM5r, (outs GR16:$dst), (ins GR16:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001797 "shr{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001798 [(set GR16:$dst, (srl GR16:$src1, (i8 imm:$src2)))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001799def SHR32ri : Ii8<0xC1, MRM5r, (outs GR32:$dst), (ins GR32:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001800 "shr{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001801 [(set GR32:$dst, (srl GR32:$src1, (i8 imm:$src2)))]>;
1802
1803// Shift by 1
Evan Chengb783fa32007-07-19 01:14:50 +00001804def SHR8r1 : I<0xD0, MRM5r, (outs GR8:$dst), (ins GR8:$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00001805 "shr{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001806 [(set GR8:$dst, (srl GR8:$src1, (i8 1)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001807def SHR16r1 : I<0xD1, MRM5r, (outs GR16:$dst), (ins GR16:$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00001808 "shr{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001809 [(set GR16:$dst, (srl GR16:$src1, (i8 1)))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001810def SHR32r1 : I<0xD1, MRM5r, (outs GR32:$dst), (ins GR32:$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00001811 "shr{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001812 [(set GR32:$dst, (srl GR32:$src1, (i8 1)))]>;
1813
1814let isTwoAddress = 0 in {
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001815 let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00001816 def SHR8mCL : I<0xD2, MRM5m, (outs), (ins i8mem :$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001817 "shr{b}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001818 [(store (srl (loadi8 addr:$dst), CL), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001819 def SHR16mCL : I<0xD3, MRM5m, (outs), (ins i16mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001820 "shr{w}\t{%cl, $dst|$dst, %CL}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001821 [(store (srl (loadi16 addr:$dst), CL), addr:$dst)]>,
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001822 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001823 def SHR32mCL : I<0xD3, MRM5m, (outs), (ins i32mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001824 "shr{l}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001825 [(store (srl (loadi32 addr:$dst), CL), addr:$dst)]>;
1826 }
Evan Chengb783fa32007-07-19 01:14:50 +00001827 def SHR8mi : Ii8<0xC0, MRM5m, (outs), (ins i8mem :$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001828 "shr{b}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001829 [(store (srl (loadi8 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001830 def SHR16mi : Ii8<0xC1, MRM5m, (outs), (ins i16mem:$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001831 "shr{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001832 [(store (srl (loadi16 addr:$dst), (i8 imm:$src)), addr:$dst)]>,
1833 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001834 def SHR32mi : Ii8<0xC1, MRM5m, (outs), (ins i32mem:$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001835 "shr{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001836 [(store (srl (loadi32 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
1837
1838 // Shift by 1
Evan Chengb783fa32007-07-19 01:14:50 +00001839 def SHR8m1 : I<0xD0, MRM5m, (outs), (ins i8mem :$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001840 "shr{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001841 [(store (srl (loadi8 addr:$dst), (i8 1)), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001842 def SHR16m1 : I<0xD1, MRM5m, (outs), (ins i16mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001843 "shr{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001844 [(store (srl (loadi16 addr:$dst), (i8 1)), addr:$dst)]>,OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001845 def SHR32m1 : I<0xD1, MRM5m, (outs), (ins i32mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001846 "shr{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001847 [(store (srl (loadi32 addr:$dst), (i8 1)), addr:$dst)]>;
1848}
1849
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001850let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00001851def SAR8rCL : I<0xD2, MRM7r, (outs GR8 :$dst), (ins GR8 :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001852 "sar{b}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001853 [(set GR8:$dst, (sra GR8:$src, CL))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001854def SAR16rCL : I<0xD3, MRM7r, (outs GR16:$dst), (ins GR16:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001855 "sar{w}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001856 [(set GR16:$dst, (sra GR16:$src, CL))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001857def SAR32rCL : I<0xD3, MRM7r, (outs GR32:$dst), (ins GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001858 "sar{l}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001859 [(set GR32:$dst, (sra GR32:$src, CL))]>;
1860}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001861
Evan Chengb783fa32007-07-19 01:14:50 +00001862def SAR8ri : Ii8<0xC0, MRM7r, (outs GR8 :$dst), (ins GR8 :$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001863 "sar{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001864 [(set GR8:$dst, (sra GR8:$src1, (i8 imm:$src2)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001865def SAR16ri : Ii8<0xC1, MRM7r, (outs GR16:$dst), (ins GR16:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001866 "sar{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001867 [(set GR16:$dst, (sra GR16:$src1, (i8 imm:$src2)))]>,
1868 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001869def SAR32ri : Ii8<0xC1, MRM7r, (outs GR32:$dst), (ins GR32:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001870 "sar{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001871 [(set GR32:$dst, (sra GR32:$src1, (i8 imm:$src2)))]>;
1872
1873// Shift by 1
Evan Chengb783fa32007-07-19 01:14:50 +00001874def SAR8r1 : I<0xD0, MRM7r, (outs GR8 :$dst), (ins GR8 :$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00001875 "sar{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001876 [(set GR8:$dst, (sra GR8:$src1, (i8 1)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001877def SAR16r1 : I<0xD1, MRM7r, (outs GR16:$dst), (ins GR16:$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00001878 "sar{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001879 [(set GR16:$dst, (sra GR16:$src1, (i8 1)))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001880def SAR32r1 : I<0xD1, MRM7r, (outs GR32:$dst), (ins GR32:$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00001881 "sar{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001882 [(set GR32:$dst, (sra GR32:$src1, (i8 1)))]>;
1883
1884let isTwoAddress = 0 in {
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001885 let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00001886 def SAR8mCL : I<0xD2, MRM7m, (outs), (ins i8mem :$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001887 "sar{b}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001888 [(store (sra (loadi8 addr:$dst), CL), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001889 def SAR16mCL : I<0xD3, MRM7m, (outs), (ins i16mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001890 "sar{w}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001891 [(store (sra (loadi16 addr:$dst), CL), addr:$dst)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001892 def SAR32mCL : I<0xD3, MRM7m, (outs), (ins i32mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001893 "sar{l}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001894 [(store (sra (loadi32 addr:$dst), CL), addr:$dst)]>;
1895 }
Evan Chengb783fa32007-07-19 01:14:50 +00001896 def SAR8mi : Ii8<0xC0, MRM7m, (outs), (ins i8mem :$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001897 "sar{b}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001898 [(store (sra (loadi8 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001899 def SAR16mi : Ii8<0xC1, MRM7m, (outs), (ins i16mem:$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001900 "sar{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001901 [(store (sra (loadi16 addr:$dst), (i8 imm:$src)), addr:$dst)]>,
1902 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001903 def SAR32mi : Ii8<0xC1, MRM7m, (outs), (ins i32mem:$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001904 "sar{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001905 [(store (sra (loadi32 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
1906
1907 // Shift by 1
Evan Chengb783fa32007-07-19 01:14:50 +00001908 def SAR8m1 : I<0xD0, MRM7m, (outs), (ins i8mem :$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001909 "sar{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001910 [(store (sra (loadi8 addr:$dst), (i8 1)), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001911 def SAR16m1 : I<0xD1, MRM7m, (outs), (ins i16mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001912 "sar{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001913 [(store (sra (loadi16 addr:$dst), (i8 1)), addr:$dst)]>,
1914 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001915 def SAR32m1 : I<0xD1, MRM7m, (outs), (ins i32mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001916 "sar{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001917 [(store (sra (loadi32 addr:$dst), (i8 1)), addr:$dst)]>;
1918}
1919
1920// Rotate instructions
1921// FIXME: provide shorter instructions when imm8 == 1
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001922let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00001923def ROL8rCL : I<0xD2, MRM0r, (outs GR8 :$dst), (ins GR8 :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001924 "rol{b}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001925 [(set GR8:$dst, (rotl GR8:$src, CL))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001926def ROL16rCL : I<0xD3, MRM0r, (outs GR16:$dst), (ins GR16:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001927 "rol{w}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001928 [(set GR16:$dst, (rotl GR16:$src, CL))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001929def ROL32rCL : I<0xD3, MRM0r, (outs GR32:$dst), (ins GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001930 "rol{l}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001931 [(set GR32:$dst, (rotl GR32:$src, CL))]>;
1932}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001933
Evan Chengb783fa32007-07-19 01:14:50 +00001934def ROL8ri : Ii8<0xC0, MRM0r, (outs GR8 :$dst), (ins GR8 :$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001935 "rol{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001936 [(set GR8:$dst, (rotl GR8:$src1, (i8 imm:$src2)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001937def ROL16ri : Ii8<0xC1, MRM0r, (outs GR16:$dst), (ins GR16:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001938 "rol{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001939 [(set GR16:$dst, (rotl GR16:$src1, (i8 imm:$src2)))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001940def ROL32ri : Ii8<0xC1, MRM0r, (outs GR32:$dst), (ins GR32:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001941 "rol{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001942 [(set GR32:$dst, (rotl GR32:$src1, (i8 imm:$src2)))]>;
1943
1944// Rotate by 1
Evan Chengb783fa32007-07-19 01:14:50 +00001945def ROL8r1 : I<0xD0, MRM0r, (outs GR8 :$dst), (ins GR8 :$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00001946 "rol{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001947 [(set GR8:$dst, (rotl GR8:$src1, (i8 1)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001948def ROL16r1 : I<0xD1, MRM0r, (outs GR16:$dst), (ins GR16:$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00001949 "rol{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001950 [(set GR16:$dst, (rotl GR16:$src1, (i8 1)))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001951def ROL32r1 : I<0xD1, MRM0r, (outs GR32:$dst), (ins GR32:$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00001952 "rol{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001953 [(set GR32:$dst, (rotl GR32:$src1, (i8 1)))]>;
1954
1955let isTwoAddress = 0 in {
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001956 let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00001957 def ROL8mCL : I<0xD2, MRM0m, (outs), (ins i8mem :$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001958 "rol{b}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001959 [(store (rotl (loadi8 addr:$dst), CL), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001960 def ROL16mCL : I<0xD3, MRM0m, (outs), (ins i16mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001961 "rol{w}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001962 [(store (rotl (loadi16 addr:$dst), CL), addr:$dst)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001963 def ROL32mCL : I<0xD3, MRM0m, (outs), (ins i32mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001964 "rol{l}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001965 [(store (rotl (loadi32 addr:$dst), CL), addr:$dst)]>;
1966 }
Evan Chengb783fa32007-07-19 01:14:50 +00001967 def ROL8mi : Ii8<0xC0, MRM0m, (outs), (ins i8mem :$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001968 "rol{b}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001969 [(store (rotl (loadi8 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001970 def ROL16mi : Ii8<0xC1, MRM0m, (outs), (ins i16mem:$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001971 "rol{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001972 [(store (rotl (loadi16 addr:$dst), (i8 imm:$src)), addr:$dst)]>,
1973 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001974 def ROL32mi : Ii8<0xC1, MRM0m, (outs), (ins i32mem:$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001975 "rol{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001976 [(store (rotl (loadi32 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
1977
1978 // Rotate by 1
Evan Chengb783fa32007-07-19 01:14:50 +00001979 def ROL8m1 : I<0xD0, MRM0m, (outs), (ins i8mem :$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001980 "rol{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001981 [(store (rotl (loadi8 addr:$dst), (i8 1)), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001982 def ROL16m1 : I<0xD1, MRM0m, (outs), (ins i16mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001983 "rol{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001984 [(store (rotl (loadi16 addr:$dst), (i8 1)), addr:$dst)]>,
1985 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001986 def ROL32m1 : I<0xD1, MRM0m, (outs), (ins i32mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001987 "rol{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001988 [(store (rotl (loadi32 addr:$dst), (i8 1)), addr:$dst)]>;
1989}
1990
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001991let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00001992def ROR8rCL : I<0xD2, MRM1r, (outs GR8 :$dst), (ins GR8 :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001993 "ror{b}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001994 [(set GR8:$dst, (rotr GR8:$src, CL))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001995def ROR16rCL : I<0xD3, MRM1r, (outs GR16:$dst), (ins GR16:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001996 "ror{w}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001997 [(set GR16:$dst, (rotr GR16:$src, CL))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001998def ROR32rCL : I<0xD3, MRM1r, (outs GR32:$dst), (ins GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001999 "ror{l}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002000 [(set GR32:$dst, (rotr GR32:$src, CL))]>;
2001}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002002
Evan Chengb783fa32007-07-19 01:14:50 +00002003def ROR8ri : Ii8<0xC0, MRM1r, (outs GR8 :$dst), (ins GR8 :$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002004 "ror{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002005 [(set GR8:$dst, (rotr GR8:$src1, (i8 imm:$src2)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002006def ROR16ri : Ii8<0xC1, MRM1r, (outs GR16:$dst), (ins GR16:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002007 "ror{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002008 [(set GR16:$dst, (rotr GR16:$src1, (i8 imm:$src2)))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002009def ROR32ri : Ii8<0xC1, MRM1r, (outs GR32:$dst), (ins GR32:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002010 "ror{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002011 [(set GR32:$dst, (rotr GR32:$src1, (i8 imm:$src2)))]>;
2012
2013// Rotate by 1
Evan Chengb783fa32007-07-19 01:14:50 +00002014def ROR8r1 : I<0xD0, MRM1r, (outs GR8 :$dst), (ins GR8 :$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00002015 "ror{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002016 [(set GR8:$dst, (rotr GR8:$src1, (i8 1)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002017def ROR16r1 : I<0xD1, MRM1r, (outs GR16:$dst), (ins GR16:$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00002018 "ror{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002019 [(set GR16:$dst, (rotr GR16:$src1, (i8 1)))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002020def ROR32r1 : I<0xD1, MRM1r, (outs GR32:$dst), (ins GR32:$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00002021 "ror{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002022 [(set GR32:$dst, (rotr GR32:$src1, (i8 1)))]>;
2023
2024let isTwoAddress = 0 in {
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002025 let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00002026 def ROR8mCL : I<0xD2, MRM1m, (outs), (ins i8mem :$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002027 "ror{b}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002028 [(store (rotr (loadi8 addr:$dst), CL), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002029 def ROR16mCL : I<0xD3, MRM1m, (outs), (ins i16mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002030 "ror{w}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002031 [(store (rotr (loadi16 addr:$dst), CL), addr:$dst)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002032 def ROR32mCL : I<0xD3, MRM1m, (outs), (ins i32mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002033 "ror{l}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002034 [(store (rotr (loadi32 addr:$dst), CL), addr:$dst)]>;
2035 }
Evan Chengb783fa32007-07-19 01:14:50 +00002036 def ROR8mi : Ii8<0xC0, MRM1m, (outs), (ins i8mem :$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002037 "ror{b}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002038 [(store (rotr (loadi8 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002039 def ROR16mi : Ii8<0xC1, MRM1m, (outs), (ins i16mem:$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002040 "ror{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002041 [(store (rotr (loadi16 addr:$dst), (i8 imm:$src)), addr:$dst)]>,
2042 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002043 def ROR32mi : Ii8<0xC1, MRM1m, (outs), (ins i32mem:$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002044 "ror{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002045 [(store (rotr (loadi32 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
2046
2047 // Rotate by 1
Evan Chengb783fa32007-07-19 01:14:50 +00002048 def ROR8m1 : I<0xD0, MRM1m, (outs), (ins i8mem :$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002049 "ror{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002050 [(store (rotr (loadi8 addr:$dst), (i8 1)), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002051 def ROR16m1 : I<0xD1, MRM1m, (outs), (ins i16mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002052 "ror{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002053 [(store (rotr (loadi16 addr:$dst), (i8 1)), addr:$dst)]>,
2054 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002055 def ROR32m1 : I<0xD1, MRM1m, (outs), (ins i32mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002056 "ror{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002057 [(store (rotr (loadi32 addr:$dst), (i8 1)), addr:$dst)]>;
2058}
2059
2060
2061
2062// Double shift instructions (generalizations of rotate)
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002063let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00002064def SHLD32rrCL : I<0xA5, MRMDestReg, (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002065 "shld{l}\t{%cl, $src2, $dst|$dst, $src2, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002066 [(set GR32:$dst, (X86shld GR32:$src1, GR32:$src2, CL))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00002067def SHRD32rrCL : I<0xAD, MRMDestReg, (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002068 "shrd{l}\t{%cl, $src2, $dst|$dst, $src2, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002069 [(set GR32:$dst, (X86shrd GR32:$src1, GR32:$src2, CL))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00002070def SHLD16rrCL : I<0xA5, MRMDestReg, (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002071 "shld{w}\t{%cl, $src2, $dst|$dst, $src2, %CL}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002072 [(set GR16:$dst, (X86shld GR16:$src1, GR16:$src2, CL))]>,
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002073 TB, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002074def SHRD16rrCL : I<0xAD, MRMDestReg, (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002075 "shrd{w}\t{%cl, $src2, $dst|$dst, $src2, %CL}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002076 [(set GR16:$dst, (X86shrd GR16:$src1, GR16:$src2, CL))]>,
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002077 TB, OpSize;
2078}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002079
2080let isCommutable = 1 in { // These instructions commute to each other.
2081def SHLD32rri8 : Ii8<0xA4, MRMDestReg,
Evan Chengb783fa32007-07-19 01:14:50 +00002082 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2, i8imm:$src3),
Dan Gohman91888f02007-07-31 20:11:57 +00002083 "shld{l}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002084 [(set GR32:$dst, (X86shld GR32:$src1, GR32:$src2,
2085 (i8 imm:$src3)))]>,
2086 TB;
2087def SHRD32rri8 : Ii8<0xAC, MRMDestReg,
Evan Chengb783fa32007-07-19 01:14:50 +00002088 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2, i8imm:$src3),
Dan Gohman91888f02007-07-31 20:11:57 +00002089 "shrd{l}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002090 [(set GR32:$dst, (X86shrd GR32:$src1, GR32:$src2,
2091 (i8 imm:$src3)))]>,
2092 TB;
2093def SHLD16rri8 : Ii8<0xA4, MRMDestReg,
Evan Chengb783fa32007-07-19 01:14:50 +00002094 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2, i8imm:$src3),
Dan Gohman91888f02007-07-31 20:11:57 +00002095 "shld{w}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002096 [(set GR16:$dst, (X86shld GR16:$src1, GR16:$src2,
2097 (i8 imm:$src3)))]>,
2098 TB, OpSize;
2099def SHRD16rri8 : Ii8<0xAC, MRMDestReg,
Evan Chengb783fa32007-07-19 01:14:50 +00002100 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2, i8imm:$src3),
Dan Gohman91888f02007-07-31 20:11:57 +00002101 "shrd{w}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002102 [(set GR16:$dst, (X86shrd GR16:$src1, GR16:$src2,
2103 (i8 imm:$src3)))]>,
2104 TB, OpSize;
2105}
2106
2107let isTwoAddress = 0 in {
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002108 let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00002109 def SHLD32mrCL : I<0xA5, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002110 "shld{l}\t{%cl, $src2, $dst|$dst, $src2, %CL}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002111 [(store (X86shld (loadi32 addr:$dst), GR32:$src2, CL),
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002112 addr:$dst)]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00002113 def SHRD32mrCL : I<0xAD, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002114 "shrd{l}\t{%cl, $src2, $dst|$dst, $src2, %CL}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002115 [(store (X86shrd (loadi32 addr:$dst), GR32:$src2, CL),
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002116 addr:$dst)]>, TB;
2117 }
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002118 def SHLD32mri8 : Ii8<0xA4, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00002119 (outs), (ins i32mem:$dst, GR32:$src2, i8imm:$src3),
Dan Gohman91888f02007-07-31 20:11:57 +00002120 "shld{l}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002121 [(store (X86shld (loadi32 addr:$dst), GR32:$src2,
2122 (i8 imm:$src3)), addr:$dst)]>,
2123 TB;
2124 def SHRD32mri8 : Ii8<0xAC, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00002125 (outs), (ins i32mem:$dst, GR32:$src2, i8imm:$src3),
Dan Gohman91888f02007-07-31 20:11:57 +00002126 "shrd{l}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002127 [(store (X86shrd (loadi32 addr:$dst), GR32:$src2,
2128 (i8 imm:$src3)), addr:$dst)]>,
2129 TB;
2130
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002131 let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00002132 def SHLD16mrCL : I<0xA5, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002133 "shld{w}\t{%cl, $src2, $dst|$dst, $src2, %CL}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002134 [(store (X86shld (loadi16 addr:$dst), GR16:$src2, CL),
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002135 addr:$dst)]>, TB, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002136 def SHRD16mrCL : I<0xAD, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002137 "shrd{w}\t{%cl, $src2, $dst|$dst, $src2, %CL}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002138 [(store (X86shrd (loadi16 addr:$dst), GR16:$src2, CL),
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002139 addr:$dst)]>, TB, OpSize;
2140 }
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002141 def SHLD16mri8 : Ii8<0xA4, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00002142 (outs), (ins i16mem:$dst, GR16:$src2, i8imm:$src3),
Dan Gohman91888f02007-07-31 20:11:57 +00002143 "shld{w}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002144 [(store (X86shld (loadi16 addr:$dst), GR16:$src2,
2145 (i8 imm:$src3)), addr:$dst)]>,
2146 TB, OpSize;
2147 def SHRD16mri8 : Ii8<0xAC, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00002148 (outs), (ins i16mem:$dst, GR16:$src2, i8imm:$src3),
Dan Gohman91888f02007-07-31 20:11:57 +00002149 "shrd{w}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002150 [(store (X86shrd (loadi16 addr:$dst), GR16:$src2,
2151 (i8 imm:$src3)), addr:$dst)]>,
2152 TB, OpSize;
2153}
Evan Cheng55687072007-09-14 21:48:26 +00002154} // Defs = [EFLAGS]
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002155
2156
2157// Arithmetic.
Evan Cheng55687072007-09-14 21:48:26 +00002158let Defs = [EFLAGS] in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002159let isCommutable = 1 in { // X = ADD Y, Z --> X = ADD Z, Y
Bill Wendlingae034ed2008-12-12 00:56:36 +00002160// Register-Register Addition
2161def ADD8rr : I<0x00, MRMDestReg, (outs GR8 :$dst),
2162 (ins GR8 :$src1, GR8 :$src2),
2163 "add{b}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002164 [(set GR8:$dst, (add GR8:$src1, GR8:$src2)),
Bill Wendlingae034ed2008-12-12 00:56:36 +00002165 (implicit EFLAGS)]>;
2166
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002167let isConvertibleToThreeAddress = 1 in { // Can transform into LEA.
Bill Wendlingae034ed2008-12-12 00:56:36 +00002168// Register-Register Addition
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002169def ADD16rr : I<0x01, MRMDestReg, (outs GR16:$dst),
2170 (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002171 "add{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002172 [(set GR16:$dst, (add GR16:$src1, GR16:$src2)),
2173 (implicit EFLAGS)]>, OpSize;
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002174def ADD32rr : I<0x01, MRMDestReg, (outs GR32:$dst),
2175 (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002176 "add{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002177 [(set GR32:$dst, (add GR32:$src1, GR32:$src2)),
2178 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002179} // end isConvertibleToThreeAddress
2180} // end isCommutable
Bill Wendlingae034ed2008-12-12 00:56:36 +00002181
2182// Register-Memory Addition
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002183def ADD8rm : I<0x02, MRMSrcMem, (outs GR8 :$dst),
2184 (ins GR8 :$src1, i8mem :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002185 "add{b}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002186 [(set GR8:$dst, (add GR8:$src1, (load addr:$src2))),
2187 (implicit EFLAGS)]>;
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002188def ADD16rm : I<0x03, MRMSrcMem, (outs GR16:$dst),
2189 (ins GR16:$src1, i16mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002190 "add{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002191 [(set GR16:$dst, (add GR16:$src1, (load addr:$src2))),
2192 (implicit EFLAGS)]>, OpSize;
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002193def ADD32rm : I<0x03, MRMSrcMem, (outs GR32:$dst),
2194 (ins GR32:$src1, i32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002195 "add{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002196 [(set GR32:$dst, (add GR32:$src1, (load addr:$src2))),
2197 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002198
Bill Wendlingae034ed2008-12-12 00:56:36 +00002199// Register-Integer Addition
2200def ADD8ri : Ii8<0x80, MRM0r, (outs GR8:$dst), (ins GR8:$src1, i8imm:$src2),
2201 "add{b}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002202 [(set GR8:$dst, (add GR8:$src1, imm:$src2)),
2203 (implicit EFLAGS)]>;
Bill Wendlingae034ed2008-12-12 00:56:36 +00002204
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002205let isConvertibleToThreeAddress = 1 in { // Can transform into LEA.
Bill Wendlingae034ed2008-12-12 00:56:36 +00002206// Register-Integer Addition
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002207def ADD16ri : Ii16<0x81, MRM0r, (outs GR16:$dst),
2208 (ins GR16:$src1, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002209 "add{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002210 [(set GR16:$dst, (add GR16:$src1, imm:$src2)),
2211 (implicit EFLAGS)]>, OpSize;
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002212def ADD32ri : Ii32<0x81, MRM0r, (outs GR32:$dst),
2213 (ins GR32:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002214 "add{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002215 [(set GR32:$dst, (add GR32:$src1, imm:$src2)),
2216 (implicit EFLAGS)]>;
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002217def ADD16ri8 : Ii8<0x83, MRM0r, (outs GR16:$dst),
2218 (ins GR16:$src1, i16i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002219 "add{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002220 [(set GR16:$dst, (add GR16:$src1, i16immSExt8:$src2)),
2221 (implicit EFLAGS)]>, OpSize;
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002222def ADD32ri8 : Ii8<0x83, MRM0r, (outs GR32:$dst),
2223 (ins GR32:$src1, i32i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002224 "add{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002225 [(set GR32:$dst, (add GR32:$src1, i32immSExt8:$src2)),
2226 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002227}
2228
2229let isTwoAddress = 0 in {
Bill Wendlingae034ed2008-12-12 00:56:36 +00002230 // Memory-Register Addition
Bill Wendlingf5399032008-12-12 21:15:41 +00002231 def ADD8mr : I<0x00, MRMDestMem, (outs), (ins i8mem:$dst, GR8:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002232 "add{b}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002233 [(store (add (load addr:$dst), GR8:$src2), addr:$dst),
2234 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002235 def ADD16mr : I<0x01, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002236 "add{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002237 [(store (add (load addr:$dst), GR16:$src2), addr:$dst),
2238 (implicit EFLAGS)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002239 def ADD32mr : I<0x01, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002240 "add{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002241 [(store (add (load addr:$dst), GR32:$src2), addr:$dst),
2242 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002243 def ADD8mi : Ii8<0x80, MRM0m, (outs), (ins i8mem :$dst, i8imm :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002244 "add{b}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002245 [(store (add (loadi8 addr:$dst), imm:$src2), addr:$dst),
2246 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002247 def ADD16mi : Ii16<0x81, MRM0m, (outs), (ins i16mem:$dst, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002248 "add{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002249 [(store (add (loadi16 addr:$dst), imm:$src2), addr:$dst),
2250 (implicit EFLAGS)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002251 def ADD32mi : Ii32<0x81, MRM0m, (outs), (ins i32mem:$dst, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002252 "add{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002253 [(store (add (loadi32 addr:$dst), imm:$src2), addr:$dst),
2254 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002255 def ADD16mi8 : Ii8<0x83, MRM0m, (outs), (ins i16mem:$dst, i16i8imm :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002256 "add{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002257 [(store (add (load addr:$dst), i16immSExt8:$src2),
2258 addr:$dst),
2259 (implicit EFLAGS)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002260 def ADD32mi8 : Ii8<0x83, MRM0m, (outs), (ins i32mem:$dst, i32i8imm :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002261 "add{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingae034ed2008-12-12 00:56:36 +00002262 [(store (add (load addr:$dst), i32immSExt8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00002263 addr:$dst),
2264 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002265}
2266
Evan Cheng259471d2007-10-05 17:59:57 +00002267let Uses = [EFLAGS] in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002268let isCommutable = 1 in { // X = ADC Y, Z --> X = ADC Z, Y
Evan Chengb783fa32007-07-19 01:14:50 +00002269def ADC32rr : I<0x11, MRMDestReg, (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002270 "adc{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingc0ca7f32008-12-01 23:44:08 +00002271 [(set GR32:$dst, (adde GR32:$src1, GR32:$src2))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002272}
Evan Chengb783fa32007-07-19 01:14:50 +00002273def ADC32rm : I<0x13, MRMSrcMem , (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002274 "adc{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingc0ca7f32008-12-01 23:44:08 +00002275 [(set GR32:$dst, (adde GR32:$src1, (load addr:$src2)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002276def ADC32ri : Ii32<0x81, MRM2r, (outs GR32:$dst), (ins GR32:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002277 "adc{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingc0ca7f32008-12-01 23:44:08 +00002278 [(set GR32:$dst, (adde GR32:$src1, imm:$src2))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002279def ADC32ri8 : Ii8<0x83, MRM2r, (outs GR32:$dst), (ins GR32:$src1, i32i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002280 "adc{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingc0ca7f32008-12-01 23:44:08 +00002281 [(set GR32:$dst, (adde GR32:$src1, i32immSExt8:$src2))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002282
2283let isTwoAddress = 0 in {
Evan Chengb783fa32007-07-19 01:14:50 +00002284 def ADC32mr : I<0x11, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002285 "adc{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingc0ca7f32008-12-01 23:44:08 +00002286 [(store (adde (load addr:$dst), GR32:$src2), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002287 def ADC32mi : Ii32<0x81, MRM2m, (outs), (ins i32mem:$dst, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002288 "adc{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingc0ca7f32008-12-01 23:44:08 +00002289 [(store (adde (loadi32 addr:$dst), imm:$src2), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002290 def ADC32mi8 : Ii8<0x83, MRM2m, (outs), (ins i32mem:$dst, i32i8imm :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002291 "adc{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendling0c52d0a2008-12-02 00:07:05 +00002292 [(store (adde (load addr:$dst), i32immSExt8:$src2), addr:$dst)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002293}
Evan Cheng259471d2007-10-05 17:59:57 +00002294} // Uses = [EFLAGS]
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002295
Bill Wendlingae034ed2008-12-12 00:56:36 +00002296// Register-Register Subtraction
2297def SUB8rr : I<0x28, MRMDestReg, (outs GR8:$dst), (ins GR8:$src1, GR8:$src2),
2298 "sub{b}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002299 [(set GR8:$dst, (sub GR8:$src1, GR8:$src2)),
2300 (implicit EFLAGS)]>;
Bill Wendlingae034ed2008-12-12 00:56:36 +00002301def SUB16rr : I<0x29, MRMDestReg, (outs GR16:$dst), (ins GR16:$src1,GR16:$src2),
2302 "sub{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002303 [(set GR16:$dst, (sub GR16:$src1, GR16:$src2)),
2304 (implicit EFLAGS)]>, OpSize;
Bill Wendlingae034ed2008-12-12 00:56:36 +00002305def SUB32rr : I<0x29, MRMDestReg, (outs GR32:$dst), (ins GR32:$src1,GR32:$src2),
2306 "sub{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002307 [(set GR32:$dst, (sub GR32:$src1, GR32:$src2)),
2308 (implicit EFLAGS)]>;
Bill Wendlingae034ed2008-12-12 00:56:36 +00002309
2310// Register-Memory Subtraction
2311def SUB8rm : I<0x2A, MRMSrcMem, (outs GR8 :$dst),
2312 (ins GR8 :$src1, i8mem :$src2),
2313 "sub{b}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002314 [(set GR8:$dst, (sub GR8:$src1, (load addr:$src2))),
2315 (implicit EFLAGS)]>;
Bill Wendlingae034ed2008-12-12 00:56:36 +00002316def SUB16rm : I<0x2B, MRMSrcMem, (outs GR16:$dst),
2317 (ins GR16:$src1, i16mem:$src2),
2318 "sub{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002319 [(set GR16:$dst, (sub GR16:$src1, (load addr:$src2))),
2320 (implicit EFLAGS)]>, OpSize;
Bill Wendlingae034ed2008-12-12 00:56:36 +00002321def SUB32rm : I<0x2B, MRMSrcMem, (outs GR32:$dst),
2322 (ins GR32:$src1, i32mem:$src2),
2323 "sub{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002324 [(set GR32:$dst, (sub GR32:$src1, (load addr:$src2))),
2325 (implicit EFLAGS)]>;
Bill Wendlingae034ed2008-12-12 00:56:36 +00002326
2327// Register-Integer Subtraction
2328def SUB8ri : Ii8 <0x80, MRM5r, (outs GR8:$dst),
2329 (ins GR8:$src1, i8imm:$src2),
2330 "sub{b}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002331 [(set GR8:$dst, (sub GR8:$src1, imm:$src2)),
2332 (implicit EFLAGS)]>;
Bill Wendlingae034ed2008-12-12 00:56:36 +00002333def SUB16ri : Ii16<0x81, MRM5r, (outs GR16:$dst),
2334 (ins GR16:$src1, i16imm:$src2),
2335 "sub{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002336 [(set GR16:$dst, (sub GR16:$src1, imm:$src2)),
2337 (implicit EFLAGS)]>, OpSize;
Bill Wendlingae034ed2008-12-12 00:56:36 +00002338def SUB32ri : Ii32<0x81, MRM5r, (outs GR32:$dst),
2339 (ins GR32:$src1, i32imm:$src2),
2340 "sub{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002341 [(set GR32:$dst, (sub GR32:$src1, imm:$src2)),
2342 (implicit EFLAGS)]>;
Bill Wendlingae034ed2008-12-12 00:56:36 +00002343def SUB16ri8 : Ii8<0x83, MRM5r, (outs GR16:$dst),
2344 (ins GR16:$src1, i16i8imm:$src2),
2345 "sub{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002346 [(set GR16:$dst, (sub GR16:$src1, i16immSExt8:$src2)),
2347 (implicit EFLAGS)]>, OpSize;
Bill Wendlingae034ed2008-12-12 00:56:36 +00002348def SUB32ri8 : Ii8<0x83, MRM5r, (outs GR32:$dst),
2349 (ins GR32:$src1, i32i8imm:$src2),
2350 "sub{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002351 [(set GR32:$dst, (sub GR32:$src1, i32immSExt8:$src2)),
2352 (implicit EFLAGS)]>;
Bill Wendlingae034ed2008-12-12 00:56:36 +00002353
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002354let isTwoAddress = 0 in {
Bill Wendlingae034ed2008-12-12 00:56:36 +00002355 // Memory-Register Subtraction
Evan Chengb783fa32007-07-19 01:14:50 +00002356 def SUB8mr : I<0x28, MRMDestMem, (outs), (ins i8mem :$dst, GR8 :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002357 "sub{b}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002358 [(store (sub (load addr:$dst), GR8:$src2), addr:$dst),
2359 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002360 def SUB16mr : I<0x29, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002361 "sub{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002362 [(store (sub (load addr:$dst), GR16:$src2), addr:$dst),
2363 (implicit EFLAGS)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002364 def SUB32mr : I<0x29, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002365 "sub{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002366 [(store (sub (load addr:$dst), GR32:$src2), addr:$dst),
2367 (implicit EFLAGS)]>;
Bill Wendlingae034ed2008-12-12 00:56:36 +00002368
2369 // Memory-Integer Subtraction
Evan Chengb783fa32007-07-19 01:14:50 +00002370 def SUB8mi : Ii8<0x80, MRM5m, (outs), (ins i8mem :$dst, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002371 "sub{b}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002372 [(store (sub (loadi8 addr:$dst), imm:$src2), addr:$dst),
2373 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002374 def SUB16mi : Ii16<0x81, MRM5m, (outs), (ins i16mem:$dst, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002375 "sub{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002376 [(store (sub (loadi16 addr:$dst), imm:$src2),addr:$dst),
2377 (implicit EFLAGS)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002378 def SUB32mi : Ii32<0x81, MRM5m, (outs), (ins i32mem:$dst, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002379 "sub{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002380 [(store (sub (loadi32 addr:$dst), imm:$src2),addr:$dst),
2381 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002382 def SUB16mi8 : Ii8<0x83, MRM5m, (outs), (ins i16mem:$dst, i16i8imm :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002383 "sub{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingae034ed2008-12-12 00:56:36 +00002384 [(store (sub (load addr:$dst), i16immSExt8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00002385 addr:$dst),
2386 (implicit EFLAGS)]>, OpSize;
Bill Wendlingae034ed2008-12-12 00:56:36 +00002387 def SUB32mi8 : Ii8<0x83, MRM5m, (outs), (ins i32mem:$dst, i32i8imm :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002388 "sub{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingae034ed2008-12-12 00:56:36 +00002389 [(store (sub (load addr:$dst), i32immSExt8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00002390 addr:$dst),
2391 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002392}
2393
Evan Cheng259471d2007-10-05 17:59:57 +00002394let Uses = [EFLAGS] in {
Evan Chengb783fa32007-07-19 01:14:50 +00002395def SBB32rr : I<0x19, MRMDestReg, (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002396 "sbb{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng55687072007-09-14 21:48:26 +00002397 [(set GR32:$dst, (sube GR32:$src1, GR32:$src2))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002398
2399let isTwoAddress = 0 in {
Evan Chengb783fa32007-07-19 01:14:50 +00002400 def SBB32mr : I<0x19, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002401 "sbb{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002402 [(store (sube (load addr:$dst), GR32:$src2), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002403 def SBB8mi : Ii32<0x80, MRM3m, (outs), (ins i8mem:$dst, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002404 "sbb{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002405 [(store (sube (loadi8 addr:$dst), imm:$src2), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002406 def SBB32mi : Ii32<0x81, MRM3m, (outs), (ins i32mem:$dst, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002407 "sbb{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002408 [(store (sube (loadi32 addr:$dst), imm:$src2), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002409 def SBB32mi8 : Ii8<0x83, MRM3m, (outs), (ins i32mem:$dst, i32i8imm :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002410 "sbb{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng55687072007-09-14 21:48:26 +00002411 [(store (sube (load addr:$dst), i32immSExt8:$src2), addr:$dst)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002412}
Evan Chengb783fa32007-07-19 01:14:50 +00002413def SBB32rm : I<0x1B, MRMSrcMem, (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002414 "sbb{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002415 [(set GR32:$dst, (sube GR32:$src1, (load addr:$src2)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002416def SBB32ri : Ii32<0x81, MRM3r, (outs GR32:$dst), (ins GR32:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002417 "sbb{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002418 [(set GR32:$dst, (sube GR32:$src1, imm:$src2))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002419def SBB32ri8 : Ii8<0x83, MRM3r, (outs GR32:$dst), (ins GR32:$src1, i32i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002420 "sbb{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002421 [(set GR32:$dst, (sube GR32:$src1, i32immSExt8:$src2))]>;
Evan Cheng259471d2007-10-05 17:59:57 +00002422} // Uses = [EFLAGS]
Evan Cheng55687072007-09-14 21:48:26 +00002423} // Defs = [EFLAGS]
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002424
Evan Cheng55687072007-09-14 21:48:26 +00002425let Defs = [EFLAGS] in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002426let isCommutable = 1 in { // X = IMUL Y, Z --> X = IMUL Z, Y
Bill Wendlingf5399032008-12-12 21:15:41 +00002427// Register-Register Signed Integer Multiply
Bill Wendlingae034ed2008-12-12 00:56:36 +00002428def IMUL16rr : I<0xAF, MRMSrcReg, (outs GR16:$dst), (ins GR16:$src1,GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002429 "imul{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002430 [(set GR16:$dst, (mul GR16:$src1, GR16:$src2)),
2431 (implicit EFLAGS)]>, TB, OpSize;
Bill Wendlingae034ed2008-12-12 00:56:36 +00002432def IMUL32rr : I<0xAF, MRMSrcReg, (outs GR32:$dst), (ins GR32:$src1,GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002433 "imul{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002434 [(set GR32:$dst, (mul GR32:$src1, GR32:$src2)),
2435 (implicit EFLAGS)]>, TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002436}
Bill Wendlingae034ed2008-12-12 00:56:36 +00002437
Bill Wendlingf5399032008-12-12 21:15:41 +00002438// Register-Memory Signed Integer Multiply
Bill Wendlingae034ed2008-12-12 00:56:36 +00002439def IMUL16rm : I<0xAF, MRMSrcMem, (outs GR16:$dst),
2440 (ins GR16:$src1, i16mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002441 "imul{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002442 [(set GR16:$dst, (mul GR16:$src1, (load addr:$src2))),
2443 (implicit EFLAGS)]>, TB, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002444def IMUL32rm : I<0xAF, MRMSrcMem, (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002445 "imul{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002446 [(set GR32:$dst, (mul GR32:$src1, (load addr:$src2))),
2447 (implicit EFLAGS)]>, TB;
Evan Cheng55687072007-09-14 21:48:26 +00002448} // Defs = [EFLAGS]
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002449} // end Two Address instructions
2450
2451// Suprisingly enough, these are not two address instructions!
Evan Cheng55687072007-09-14 21:48:26 +00002452let Defs = [EFLAGS] in {
Bill Wendlingf5399032008-12-12 21:15:41 +00002453// Register-Integer Signed Integer Multiply
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002454def IMUL16rri : Ii16<0x69, MRMSrcReg, // GR16 = GR16*I16
Evan Chengb783fa32007-07-19 01:14:50 +00002455 (outs GR16:$dst), (ins GR16:$src1, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002456 "imul{w}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002457 [(set GR16:$dst, (mul GR16:$src1, imm:$src2)),
2458 (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002459def IMUL32rri : Ii32<0x69, MRMSrcReg, // GR32 = GR32*I32
Evan Chengb783fa32007-07-19 01:14:50 +00002460 (outs GR32:$dst), (ins GR32:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002461 "imul{l}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002462 [(set GR32:$dst, (mul GR32:$src1, imm:$src2)),
2463 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002464def IMUL16rri8 : Ii8<0x6B, MRMSrcReg, // GR16 = GR16*I8
Evan Chengb783fa32007-07-19 01:14:50 +00002465 (outs GR16:$dst), (ins GR16:$src1, i16i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002466 "imul{w}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002467 [(set GR16:$dst, (mul GR16:$src1, i16immSExt8:$src2)),
2468 (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002469def IMUL32rri8 : Ii8<0x6B, MRMSrcReg, // GR32 = GR32*I8
Evan Chengb783fa32007-07-19 01:14:50 +00002470 (outs GR32:$dst), (ins GR32:$src1, i32i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002471 "imul{l}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002472 [(set GR32:$dst, (mul GR32:$src1, i32immSExt8:$src2)),
2473 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002474
Bill Wendlingf5399032008-12-12 21:15:41 +00002475// Memory-Integer Signed Integer Multiply
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002476def IMUL16rmi : Ii16<0x69, MRMSrcMem, // GR16 = [mem16]*I16
Evan Chengb783fa32007-07-19 01:14:50 +00002477 (outs GR16:$dst), (ins i16mem:$src1, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002478 "imul{w}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002479 [(set GR16:$dst, (mul (load addr:$src1), imm:$src2)),
2480 (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002481def IMUL32rmi : Ii32<0x69, MRMSrcMem, // GR32 = [mem32]*I32
Evan Chengb783fa32007-07-19 01:14:50 +00002482 (outs GR32:$dst), (ins i32mem:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002483 "imul{l}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002484 [(set GR32:$dst, (mul (load addr:$src1), imm:$src2)),
2485 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002486def IMUL16rmi8 : Ii8<0x6B, MRMSrcMem, // GR16 = [mem16]*I8
Evan Chengb783fa32007-07-19 01:14:50 +00002487 (outs GR16:$dst), (ins i16mem:$src1, i16i8imm :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002488 "imul{w}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Bill Wendlingae034ed2008-12-12 00:56:36 +00002489 [(set GR16:$dst, (mul (load addr:$src1),
Bill Wendlingf5399032008-12-12 21:15:41 +00002490 i16immSExt8:$src2)),
2491 (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002492def IMUL32rmi8 : Ii8<0x6B, MRMSrcMem, // GR32 = [mem32]*I8
Evan Chengb783fa32007-07-19 01:14:50 +00002493 (outs GR32:$dst), (ins i32mem:$src1, i32i8imm: $src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002494 "imul{l}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Bill Wendlingae034ed2008-12-12 00:56:36 +00002495 [(set GR32:$dst, (mul (load addr:$src1),
Bill Wendlingf5399032008-12-12 21:15:41 +00002496 i32immSExt8:$src2)),
2497 (implicit EFLAGS)]>;
Evan Cheng55687072007-09-14 21:48:26 +00002498} // Defs = [EFLAGS]
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002499
2500//===----------------------------------------------------------------------===//
2501// Test instructions are just like AND, except they don't generate a result.
2502//
Evan Cheng950aac02007-09-25 01:57:46 +00002503let Defs = [EFLAGS] in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002504let isCommutable = 1 in { // TEST X, Y --> TEST Y, X
Evan Chengb783fa32007-07-19 01:14:50 +00002505def TEST8rr : I<0x84, MRMDestReg, (outs), (ins GR8:$src1, GR8:$src2),
Evan Cheng621216e2007-09-29 00:00:36 +00002506 "test{b}\t{$src2, $src1|$src1, $src2}",
Chris Lattner21da6382008-02-19 17:37:35 +00002507 [(X86cmp (and_su GR8:$src1, GR8:$src2), 0),
Evan Cheng621216e2007-09-29 00:00:36 +00002508 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002509def TEST16rr : I<0x85, MRMDestReg, (outs), (ins GR16:$src1, GR16:$src2),
Evan Cheng621216e2007-09-29 00:00:36 +00002510 "test{w}\t{$src2, $src1|$src1, $src2}",
Chris Lattner21da6382008-02-19 17:37:35 +00002511 [(X86cmp (and_su GR16:$src1, GR16:$src2), 0),
Evan Cheng621216e2007-09-29 00:00:36 +00002512 (implicit EFLAGS)]>,
2513 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002514def TEST32rr : I<0x85, MRMDestReg, (outs), (ins GR32:$src1, GR32:$src2),
Evan Cheng621216e2007-09-29 00:00:36 +00002515 "test{l}\t{$src2, $src1|$src1, $src2}",
Chris Lattner21da6382008-02-19 17:37:35 +00002516 [(X86cmp (and_su GR32:$src1, GR32:$src2), 0),
Evan Cheng621216e2007-09-29 00:00:36 +00002517 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002518}
2519
Evan Chengb783fa32007-07-19 01:14:50 +00002520def TEST8rm : I<0x84, MRMSrcMem, (outs), (ins GR8 :$src1, i8mem :$src2),
Evan Cheng621216e2007-09-29 00:00:36 +00002521 "test{b}\t{$src2, $src1|$src1, $src2}",
2522 [(X86cmp (and GR8:$src1, (loadi8 addr:$src2)), 0),
2523 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002524def TEST16rm : I<0x85, MRMSrcMem, (outs), (ins GR16:$src1, i16mem:$src2),
Evan Cheng621216e2007-09-29 00:00:36 +00002525 "test{w}\t{$src2, $src1|$src1, $src2}",
2526 [(X86cmp (and GR16:$src1, (loadi16 addr:$src2)), 0),
2527 (implicit EFLAGS)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002528def TEST32rm : I<0x85, MRMSrcMem, (outs), (ins GR32:$src1, i32mem:$src2),
Evan Cheng621216e2007-09-29 00:00:36 +00002529 "test{l}\t{$src2, $src1|$src1, $src2}",
2530 [(X86cmp (and GR32:$src1, (loadi32 addr:$src2)), 0),
2531 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002532
2533def TEST8ri : Ii8 <0xF6, MRM0r, // flags = GR8 & imm8
Evan Chengb783fa32007-07-19 01:14:50 +00002534 (outs), (ins GR8:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002535 "test{b}\t{$src2, $src1|$src1, $src2}",
Chris Lattner21da6382008-02-19 17:37:35 +00002536 [(X86cmp (and_su GR8:$src1, imm:$src2), 0),
Evan Cheng621216e2007-09-29 00:00:36 +00002537 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002538def TEST16ri : Ii16<0xF7, MRM0r, // flags = GR16 & imm16
Evan Chengb783fa32007-07-19 01:14:50 +00002539 (outs), (ins GR16:$src1, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002540 "test{w}\t{$src2, $src1|$src1, $src2}",
Chris Lattner21da6382008-02-19 17:37:35 +00002541 [(X86cmp (and_su GR16:$src1, imm:$src2), 0),
Evan Cheng621216e2007-09-29 00:00:36 +00002542 (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002543def TEST32ri : Ii32<0xF7, MRM0r, // flags = GR32 & imm32
Evan Chengb783fa32007-07-19 01:14:50 +00002544 (outs), (ins GR32:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002545 "test{l}\t{$src2, $src1|$src1, $src2}",
Chris Lattner21da6382008-02-19 17:37:35 +00002546 [(X86cmp (and_su GR32:$src1, imm:$src2), 0),
Evan Cheng621216e2007-09-29 00:00:36 +00002547 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002548
Evan Cheng621216e2007-09-29 00:00:36 +00002549def TEST8mi : Ii8 <0xF6, MRM0m, // flags = [mem8] & imm8
Evan Chengb783fa32007-07-19 01:14:50 +00002550 (outs), (ins i8mem:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002551 "test{b}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002552 [(X86cmp (and (loadi8 addr:$src1), imm:$src2), 0),
2553 (implicit EFLAGS)]>;
2554def TEST16mi : Ii16<0xF7, MRM0m, // flags = [mem16] & imm16
Evan Chengb783fa32007-07-19 01:14:50 +00002555 (outs), (ins i16mem:$src1, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002556 "test{w}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002557 [(X86cmp (and (loadi16 addr:$src1), imm:$src2), 0),
2558 (implicit EFLAGS)]>, OpSize;
2559def TEST32mi : Ii32<0xF7, MRM0m, // flags = [mem32] & imm32
Evan Chengb783fa32007-07-19 01:14:50 +00002560 (outs), (ins i32mem:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002561 "test{l}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002562 [(X86cmp (and (loadi32 addr:$src1), imm:$src2), 0),
Evan Cheng950aac02007-09-25 01:57:46 +00002563 (implicit EFLAGS)]>;
2564} // Defs = [EFLAGS]
2565
2566
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002567// Condition code ops, incl. set if equal/not equal/...
Chris Lattnerc90ee9c2008-01-10 07:59:24 +00002568let Defs = [EFLAGS], Uses = [AH], neverHasSideEffects = 1 in
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002569def SAHF : I<0x9E, RawFrm, (outs), (ins), "sahf", []>; // flags = AH
Chris Lattnerc90ee9c2008-01-10 07:59:24 +00002570let Defs = [AH], Uses = [EFLAGS], neverHasSideEffects = 1 in
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002571def LAHF : I<0x9F, RawFrm, (outs), (ins), "lahf", []>; // AH = flags
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002572
Evan Cheng950aac02007-09-25 01:57:46 +00002573let Uses = [EFLAGS] in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002574def SETEr : I<0x94, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00002575 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002576 "sete\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002577 [(set GR8:$dst, (X86setcc X86_COND_E, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002578 TB; // GR8 = ==
2579def SETEm : I<0x94, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00002580 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002581 "sete\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002582 [(store (X86setcc X86_COND_E, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002583 TB; // [mem8] = ==
Bill Wendling0c52d0a2008-12-02 00:07:05 +00002584
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002585def SETNEr : I<0x95, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00002586 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002587 "setne\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002588 [(set GR8:$dst, (X86setcc X86_COND_NE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002589 TB; // GR8 = !=
2590def SETNEm : I<0x95, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00002591 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002592 "setne\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002593 [(store (X86setcc X86_COND_NE, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002594 TB; // [mem8] = !=
Bill Wendling0c52d0a2008-12-02 00:07:05 +00002595
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002596def SETLr : I<0x9C, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00002597 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002598 "setl\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002599 [(set GR8:$dst, (X86setcc X86_COND_L, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002600 TB; // GR8 = < signed
2601def SETLm : I<0x9C, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00002602 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002603 "setl\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002604 [(store (X86setcc X86_COND_L, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002605 TB; // [mem8] = < signed
Bill Wendling0c52d0a2008-12-02 00:07:05 +00002606
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002607def SETGEr : I<0x9D, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00002608 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002609 "setge\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002610 [(set GR8:$dst, (X86setcc X86_COND_GE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002611 TB; // GR8 = >= signed
2612def SETGEm : I<0x9D, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00002613 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002614 "setge\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002615 [(store (X86setcc X86_COND_GE, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002616 TB; // [mem8] = >= signed
Bill Wendling0c52d0a2008-12-02 00:07:05 +00002617
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002618def SETLEr : I<0x9E, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00002619 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002620 "setle\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002621 [(set GR8:$dst, (X86setcc X86_COND_LE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002622 TB; // GR8 = <= signed
2623def SETLEm : I<0x9E, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00002624 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002625 "setle\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002626 [(store (X86setcc X86_COND_LE, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002627 TB; // [mem8] = <= signed
Bill Wendling0c52d0a2008-12-02 00:07:05 +00002628
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002629def SETGr : I<0x9F, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00002630 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002631 "setg\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002632 [(set GR8:$dst, (X86setcc X86_COND_G, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002633 TB; // GR8 = > signed
2634def SETGm : I<0x9F, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00002635 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002636 "setg\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002637 [(store (X86setcc X86_COND_G, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002638 TB; // [mem8] = > signed
2639
2640def SETBr : I<0x92, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00002641 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002642 "setb\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002643 [(set GR8:$dst, (X86setcc X86_COND_B, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002644 TB; // GR8 = < unsign
2645def SETBm : I<0x92, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00002646 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002647 "setb\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002648 [(store (X86setcc X86_COND_B, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002649 TB; // [mem8] = < unsign
Bill Wendling0c52d0a2008-12-02 00:07:05 +00002650
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002651def SETAEr : I<0x93, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00002652 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002653 "setae\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002654 [(set GR8:$dst, (X86setcc X86_COND_AE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002655 TB; // GR8 = >= unsign
2656def SETAEm : I<0x93, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00002657 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002658 "setae\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002659 [(store (X86setcc X86_COND_AE, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002660 TB; // [mem8] = >= unsign
Bill Wendling0c52d0a2008-12-02 00:07:05 +00002661
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002662def SETBEr : I<0x96, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00002663 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002664 "setbe\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002665 [(set GR8:$dst, (X86setcc X86_COND_BE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002666 TB; // GR8 = <= unsign
2667def SETBEm : I<0x96, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00002668 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002669 "setbe\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002670 [(store (X86setcc X86_COND_BE, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002671 TB; // [mem8] = <= unsign
Bill Wendling0c52d0a2008-12-02 00:07:05 +00002672
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002673def SETAr : I<0x97, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00002674 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002675 "seta\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002676 [(set GR8:$dst, (X86setcc X86_COND_A, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002677 TB; // GR8 = > signed
2678def SETAm : I<0x97, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00002679 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002680 "seta\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002681 [(store (X86setcc X86_COND_A, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002682 TB; // [mem8] = > signed
2683
2684def SETSr : I<0x98, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00002685 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002686 "sets\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002687 [(set GR8:$dst, (X86setcc X86_COND_S, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002688 TB; // GR8 = <sign bit>
2689def SETSm : I<0x98, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00002690 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002691 "sets\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002692 [(store (X86setcc X86_COND_S, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002693 TB; // [mem8] = <sign bit>
2694def SETNSr : I<0x99, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00002695 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002696 "setns\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002697 [(set GR8:$dst, (X86setcc X86_COND_NS, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002698 TB; // GR8 = !<sign bit>
2699def SETNSm : I<0x99, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00002700 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002701 "setns\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002702 [(store (X86setcc X86_COND_NS, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002703 TB; // [mem8] = !<sign bit>
Bill Wendling0c52d0a2008-12-02 00:07:05 +00002704
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002705def SETPr : I<0x9A, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00002706 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002707 "setp\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002708 [(set GR8:$dst, (X86setcc X86_COND_P, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002709 TB; // GR8 = parity
2710def SETPm : I<0x9A, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00002711 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002712 "setp\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002713 [(store (X86setcc X86_COND_P, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002714 TB; // [mem8] = parity
2715def SETNPr : I<0x9B, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00002716 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002717 "setnp\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002718 [(set GR8:$dst, (X86setcc X86_COND_NP, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002719 TB; // GR8 = not parity
2720def SETNPm : I<0x9B, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00002721 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002722 "setnp\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002723 [(store (X86setcc X86_COND_NP, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002724 TB; // [mem8] = not parity
Bill Wendling0c52d0a2008-12-02 00:07:05 +00002725
2726def SETOr : I<0x90, MRM0r,
2727 (outs GR8 :$dst), (ins),
2728 "seto\t$dst",
2729 [(set GR8:$dst, (X86setcc X86_COND_O, EFLAGS))]>,
2730 TB; // GR8 = overflow
2731def SETOm : I<0x90, MRM0m,
2732 (outs), (ins i8mem:$dst),
2733 "seto\t$dst",
2734 [(store (X86setcc X86_COND_O, EFLAGS), addr:$dst)]>,
2735 TB; // [mem8] = overflow
2736def SETNOr : I<0x91, MRM0r,
2737 (outs GR8 :$dst), (ins),
2738 "setno\t$dst",
2739 [(set GR8:$dst, (X86setcc X86_COND_NO, EFLAGS))]>,
2740 TB; // GR8 = not overflow
2741def SETNOm : I<0x91, MRM0m,
2742 (outs), (ins i8mem:$dst),
2743 "setno\t$dst",
2744 [(store (X86setcc X86_COND_NO, EFLAGS), addr:$dst)]>,
2745 TB; // [mem8] = not overflow
Evan Cheng950aac02007-09-25 01:57:46 +00002746} // Uses = [EFLAGS]
2747
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002748
2749// Integer comparisons
Evan Cheng55687072007-09-14 21:48:26 +00002750let Defs = [EFLAGS] in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002751def CMP8rr : I<0x38, MRMDestReg,
Evan Chengb783fa32007-07-19 01:14:50 +00002752 (outs), (ins GR8 :$src1, GR8 :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002753 "cmp{b}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002754 [(X86cmp GR8:$src1, GR8:$src2), (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002755def CMP16rr : I<0x39, MRMDestReg,
Evan Chengb783fa32007-07-19 01:14:50 +00002756 (outs), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002757 "cmp{w}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002758 [(X86cmp GR16:$src1, GR16:$src2), (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002759def CMP32rr : I<0x39, MRMDestReg,
Evan Chengb783fa32007-07-19 01:14:50 +00002760 (outs), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002761 "cmp{l}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002762 [(X86cmp GR32:$src1, GR32:$src2), (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002763def CMP8mr : I<0x38, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00002764 (outs), (ins i8mem :$src1, GR8 :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002765 "cmp{b}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002766 [(X86cmp (loadi8 addr:$src1), GR8:$src2),
2767 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002768def CMP16mr : I<0x39, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00002769 (outs), (ins i16mem:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002770 "cmp{w}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002771 [(X86cmp (loadi16 addr:$src1), GR16:$src2),
2772 (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002773def CMP32mr : I<0x39, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00002774 (outs), (ins i32mem:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002775 "cmp{l}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002776 [(X86cmp (loadi32 addr:$src1), GR32:$src2),
2777 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002778def CMP8rm : I<0x3A, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00002779 (outs), (ins GR8 :$src1, i8mem :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002780 "cmp{b}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002781 [(X86cmp GR8:$src1, (loadi8 addr:$src2)),
2782 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002783def CMP16rm : I<0x3B, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00002784 (outs), (ins GR16:$src1, i16mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002785 "cmp{w}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002786 [(X86cmp GR16:$src1, (loadi16 addr:$src2)),
2787 (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002788def CMP32rm : I<0x3B, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00002789 (outs), (ins GR32:$src1, i32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002790 "cmp{l}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002791 [(X86cmp GR32:$src1, (loadi32 addr:$src2)),
2792 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002793def CMP8ri : Ii8<0x80, MRM7r,
Evan Chengb783fa32007-07-19 01:14:50 +00002794 (outs), (ins GR8:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002795 "cmp{b}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002796 [(X86cmp GR8:$src1, imm:$src2), (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002797def CMP16ri : Ii16<0x81, MRM7r,
Evan Chengb783fa32007-07-19 01:14:50 +00002798 (outs), (ins GR16:$src1, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002799 "cmp{w}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002800 [(X86cmp GR16:$src1, imm:$src2),
2801 (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002802def CMP32ri : Ii32<0x81, MRM7r,
Evan Chengb783fa32007-07-19 01:14:50 +00002803 (outs), (ins GR32:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002804 "cmp{l}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002805 [(X86cmp GR32:$src1, imm:$src2), (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002806def CMP8mi : Ii8 <0x80, MRM7m,
Evan Chengb783fa32007-07-19 01:14:50 +00002807 (outs), (ins i8mem :$src1, i8imm :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002808 "cmp{b}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002809 [(X86cmp (loadi8 addr:$src1), imm:$src2),
2810 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002811def CMP16mi : Ii16<0x81, MRM7m,
Evan Chengb783fa32007-07-19 01:14:50 +00002812 (outs), (ins i16mem:$src1, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002813 "cmp{w}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002814 [(X86cmp (loadi16 addr:$src1), imm:$src2),
2815 (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002816def CMP32mi : Ii32<0x81, MRM7m,
Evan Chengb783fa32007-07-19 01:14:50 +00002817 (outs), (ins i32mem:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002818 "cmp{l}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002819 [(X86cmp (loadi32 addr:$src1), imm:$src2),
2820 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002821def CMP16ri8 : Ii8<0x83, MRM7r,
Evan Chengb783fa32007-07-19 01:14:50 +00002822 (outs), (ins GR16:$src1, i16i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002823 "cmp{w}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002824 [(X86cmp GR16:$src1, i16immSExt8:$src2),
2825 (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002826def CMP16mi8 : Ii8<0x83, MRM7m,
Evan Chengb783fa32007-07-19 01:14:50 +00002827 (outs), (ins i16mem:$src1, i16i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002828 "cmp{w}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002829 [(X86cmp (loadi16 addr:$src1), i16immSExt8:$src2),
2830 (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002831def CMP32mi8 : Ii8<0x83, MRM7m,
Evan Chengb783fa32007-07-19 01:14:50 +00002832 (outs), (ins i32mem:$src1, i32i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002833 "cmp{l}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002834 [(X86cmp (loadi32 addr:$src1), i32immSExt8:$src2),
2835 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002836def CMP32ri8 : Ii8<0x83, MRM7r,
Evan Chengb783fa32007-07-19 01:14:50 +00002837 (outs), (ins GR32:$src1, i32i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002838 "cmp{l}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002839 [(X86cmp GR32:$src1, i32immSExt8:$src2),
Evan Cheng950aac02007-09-25 01:57:46 +00002840 (implicit EFLAGS)]>;
2841} // Defs = [EFLAGS]
2842
Dan Gohman7fe9b7f2008-12-23 22:45:23 +00002843// Bit tests.
Dan Gohman7fe9b7f2008-12-23 22:45:23 +00002844// TODO: BTC, BTR, and BTS
2845let Defs = [EFLAGS] in {
Dan Gohmanfc4eddb2009-01-13 20:32:45 +00002846def BT16rr : I<0xA3, MRMDestReg, (outs), (ins GR16:$src1, GR16:$src2),
Dan Gohman7fe9b7f2008-12-23 22:45:23 +00002847 "bt{w}\t{$src2, $src1|$src1, $src2}",
2848 [(X86bt GR16:$src1, GR16:$src2),
Chris Lattner5a95cde2008-12-25 01:32:49 +00002849 (implicit EFLAGS)]>, OpSize, TB;
Dan Gohmanfc4eddb2009-01-13 20:32:45 +00002850def BT32rr : I<0xA3, MRMDestReg, (outs), (ins GR32:$src1, GR32:$src2),
Dan Gohman7fe9b7f2008-12-23 22:45:23 +00002851 "bt{l}\t{$src2, $src1|$src1, $src2}",
2852 [(X86bt GR32:$src1, GR32:$src2),
Chris Lattner5a95cde2008-12-25 01:32:49 +00002853 (implicit EFLAGS)]>, TB;
Dan Gohman85a228c2009-01-13 23:23:30 +00002854
2855// Unlike with the register+register form, the memory+register form of the
2856// bt instruction does not ignore the high bits of the index. From ISel's
2857// perspective, this is pretty bizarre. Disable these instructions for now.
2858//def BT16mr : I<0xA3, MRMDestMem, (outs), (ins i16mem:$src1, GR16:$src2),
2859// "bt{w}\t{$src2, $src1|$src1, $src2}",
2860// [(X86bt (loadi16 addr:$src1), GR16:$src2),
2861// (implicit EFLAGS)]>, OpSize, TB, Requires<[FastBTMem]>;
2862//def BT32mr : I<0xA3, MRMDestMem, (outs), (ins i32mem:$src1, GR32:$src2),
2863// "bt{l}\t{$src2, $src1|$src1, $src2}",
2864// [(X86bt (loadi32 addr:$src1), GR32:$src2),
2865// (implicit EFLAGS)]>, TB, Requires<[FastBTMem]>;
Dan Gohman46fb1cf2009-01-13 20:33:23 +00002866
2867def BT16ri8 : Ii8<0xBA, MRM4r, (outs), (ins GR16:$src1, i16i8imm:$src2),
2868 "bt{w}\t{$src2, $src1|$src1, $src2}",
2869 [(X86bt GR16:$src1, i16immSExt8:$src2),
2870 (implicit EFLAGS)]>, OpSize, TB;
2871def BT32ri8 : Ii8<0xBA, MRM4r, (outs), (ins GR32:$src1, i32i8imm:$src2),
2872 "bt{l}\t{$src2, $src1|$src1, $src2}",
2873 [(X86bt GR32:$src1, i32immSExt8:$src2),
2874 (implicit EFLAGS)]>, TB;
2875// Note that these instructions don't need FastBTMem because that
2876// only applies when the other operand is in a register. When it's
2877// an immediate, bt is still fast.
2878def BT16mi8 : Ii8<0xBA, MRM4m, (outs), (ins i16mem:$src1, i16i8imm:$src2),
2879 "bt{w}\t{$src2, $src1|$src1, $src2}",
2880 [(X86bt (loadi16 addr:$src1), i16immSExt8:$src2),
2881 (implicit EFLAGS)]>, OpSize, TB;
2882def BT32mi8 : Ii8<0xBA, MRM4m, (outs), (ins i32mem:$src1, i32i8imm:$src2),
2883 "bt{l}\t{$src2, $src1|$src1, $src2}",
2884 [(X86bt (loadi32 addr:$src1), i32immSExt8:$src2),
2885 (implicit EFLAGS)]>, TB;
Dan Gohman7fe9b7f2008-12-23 22:45:23 +00002886} // Defs = [EFLAGS]
2887
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002888// Sign/Zero extenders
Dan Gohman9203ab42008-07-30 18:09:17 +00002889// Use movsbl intead of movsbw; we don't care about the high 16 bits
2890// of the register here. This has a smaller encoding and avoids a
2891// partial-register update.
Evan Chengb783fa32007-07-19 01:14:50 +00002892def MOVSX16rr8 : I<0xBE, MRMSrcReg, (outs GR16:$dst), (ins GR8 :$src),
Dan Gohman9203ab42008-07-30 18:09:17 +00002893 "movs{bl|x}\t{$src, ${dst:subreg32}|${dst:subreg32}, $src}",
2894 [(set GR16:$dst, (sext GR8:$src))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00002895def MOVSX16rm8 : I<0xBE, MRMSrcMem, (outs GR16:$dst), (ins i8mem :$src),
Dan Gohman9203ab42008-07-30 18:09:17 +00002896 "movs{bl|x}\t{$src, ${dst:subreg32}|${dst:subreg32}, $src}",
2897 [(set GR16:$dst, (sextloadi16i8 addr:$src))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00002898def MOVSX32rr8 : I<0xBE, MRMSrcReg, (outs GR32:$dst), (ins GR8 :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002899 "movs{bl|x}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002900 [(set GR32:$dst, (sext GR8:$src))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00002901def MOVSX32rm8 : I<0xBE, MRMSrcMem, (outs GR32:$dst), (ins i8mem :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002902 "movs{bl|x}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002903 [(set GR32:$dst, (sextloadi32i8 addr:$src))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00002904def MOVSX32rr16: I<0xBF, MRMSrcReg, (outs GR32:$dst), (ins GR16:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002905 "movs{wl|x}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002906 [(set GR32:$dst, (sext GR16:$src))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00002907def MOVSX32rm16: I<0xBF, MRMSrcMem, (outs GR32:$dst), (ins i16mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002908 "movs{wl|x}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002909 [(set GR32:$dst, (sextloadi32i16 addr:$src))]>, TB;
2910
Dan Gohman9203ab42008-07-30 18:09:17 +00002911// Use movzbl intead of movzbw; we don't care about the high 16 bits
2912// of the register here. This has a smaller encoding and avoids a
2913// partial-register update.
Evan Chengb783fa32007-07-19 01:14:50 +00002914def MOVZX16rr8 : I<0xB6, MRMSrcReg, (outs GR16:$dst), (ins GR8 :$src),
Dan Gohman9203ab42008-07-30 18:09:17 +00002915 "movz{bl|x}\t{$src, ${dst:subreg32}|${dst:subreg32}, $src}",
2916 [(set GR16:$dst, (zext GR8:$src))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00002917def MOVZX16rm8 : I<0xB6, MRMSrcMem, (outs GR16:$dst), (ins i8mem :$src),
Dan Gohman9203ab42008-07-30 18:09:17 +00002918 "movz{bl|x}\t{$src, ${dst:subreg32}|${dst:subreg32}, $src}",
2919 [(set GR16:$dst, (zextloadi16i8 addr:$src))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00002920def MOVZX32rr8 : I<0xB6, MRMSrcReg, (outs GR32:$dst), (ins GR8 :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002921 "movz{bl|x}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002922 [(set GR32:$dst, (zext GR8:$src))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00002923def MOVZX32rm8 : I<0xB6, MRMSrcMem, (outs GR32:$dst), (ins i8mem :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002924 "movz{bl|x}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002925 [(set GR32:$dst, (zextloadi32i8 addr:$src))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00002926def MOVZX32rr16: I<0xB7, MRMSrcReg, (outs GR32:$dst), (ins GR16:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002927 "movz{wl|x}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002928 [(set GR32:$dst, (zext GR16:$src))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00002929def MOVZX32rm16: I<0xB7, MRMSrcMem, (outs GR32:$dst), (ins i16mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002930 "movz{wl|x}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002931 [(set GR32:$dst, (zextloadi32i16 addr:$src))]>, TB;
2932
Dan Gohman744d4622009-04-13 16:09:41 +00002933// These are the same as the regular regular MOVZX32rr8 and MOVZX32rm8
2934// except that they use GR32_NOREX for the output operand register class
2935// instead of GR32. This allows them to operate on h registers on x86-64.
2936def MOVZX32_NOREXrr8 : I<0xB6, MRMSrcReg,
2937 (outs GR32_NOREX:$dst), (ins GR8:$src),
2938 "movz{bl|x}\t{$src, $dst|$dst, $src} # NOREX",
2939 []>, TB;
2940def MOVZX32_NOREXrm8 : I<0xB6, MRMSrcMem,
2941 (outs GR32_NOREX:$dst), (ins i8mem:$src),
2942 "movz{bl|x}\t{$src, $dst|$dst, $src} # NOREX",
2943 []>, TB;
2944
Chris Lattnerc90ee9c2008-01-10 07:59:24 +00002945let neverHasSideEffects = 1 in {
2946 let Defs = [AX], Uses = [AL] in
2947 def CBW : I<0x98, RawFrm, (outs), (ins),
2948 "{cbtw|cbw}", []>, OpSize; // AX = signext(AL)
2949 let Defs = [EAX], Uses = [AX] in
2950 def CWDE : I<0x98, RawFrm, (outs), (ins),
2951 "{cwtl|cwde}", []>; // EAX = signext(AX)
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002952
Chris Lattnerc90ee9c2008-01-10 07:59:24 +00002953 let Defs = [AX,DX], Uses = [AX] in
2954 def CWD : I<0x99, RawFrm, (outs), (ins),
2955 "{cwtd|cwd}", []>, OpSize; // DX:AX = signext(AX)
2956 let Defs = [EAX,EDX], Uses = [EAX] in
2957 def CDQ : I<0x99, RawFrm, (outs), (ins),
2958 "{cltd|cdq}", []>; // EDX:EAX = signext(EAX)
2959}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002960
2961//===----------------------------------------------------------------------===//
2962// Alias Instructions
2963//===----------------------------------------------------------------------===//
2964
2965// Alias instructions that map movr0 to xor.
2966// FIXME: remove when we can teach regalloc that xor reg, reg is ok.
Bill Wendlingba5d5b02008-05-29 01:02:09 +00002967let Defs = [EFLAGS], isReMaterializable = 1, isAsCheapAsAMove = 1 in {
Evan Chengb783fa32007-07-19 01:14:50 +00002968def MOV8r0 : I<0x30, MRMInitReg, (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002969 "xor{b}\t$dst, $dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002970 [(set GR8:$dst, 0)]>;
Dan Gohman9203ab42008-07-30 18:09:17 +00002971// Use xorl instead of xorw since we don't care about the high 16 bits,
2972// it's smaller, and it avoids a partial-register update.
Evan Chengb783fa32007-07-19 01:14:50 +00002973def MOV16r0 : I<0x31, MRMInitReg, (outs GR16:$dst), (ins),
Dan Gohman9203ab42008-07-30 18:09:17 +00002974 "xor{l}\t${dst:subreg32}, ${dst:subreg32}",
2975 [(set GR16:$dst, 0)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002976def MOV32r0 : I<0x31, MRMInitReg, (outs GR32:$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002977 "xor{l}\t$dst, $dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002978 [(set GR32:$dst, 0)]>;
Dan Gohman8aef09b2007-09-07 21:32:51 +00002979}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002980
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002981//===----------------------------------------------------------------------===//
2982// Thread Local Storage Instructions
2983//
2984
Rafael Espindola7fc4b8d2009-04-24 12:59:40 +00002985// All calls clobber the non-callee saved registers. ESP is marked as
2986// a use to prevent stack-pointer assignments that appear immediately
2987// before calls from potentially appearing dead.
2988let Defs = [EAX, ECX, EDX, FP0, FP1, FP2, FP3, FP4, FP5, FP6, ST0,
2989 MM0, MM1, MM2, MM3, MM4, MM5, MM6, MM7,
2990 XMM0, XMM1, XMM2, XMM3, XMM4, XMM5, XMM6, XMM7,
2991 XMM8, XMM9, XMM10, XMM11, XMM12, XMM13, XMM14, XMM15, EFLAGS],
2992 Uses = [ESP, EBX] in
Rafael Espindolaaf759ab2009-04-17 14:35:58 +00002993def TLS_addr32 : I<0, Pseudo, (outs), (ins i32imm:$sym),
Dan Gohman70a8a112009-04-27 15:13:28 +00002994 "leal\t${sym:mem}(,%ebx,1), %eax; "
2995 "call\t___tls_get_addr@PLT",
Rafael Espindolaaf759ab2009-04-17 14:35:58 +00002996 [(X86tlsaddr tglobaltlsaddr:$sym)]>,
2997 Requires<[In32BitMode]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002998
sampo9cc09a32009-01-26 01:24:32 +00002999let AddedComplexity = 5 in
3000def GS_MOV32rm : I<0x8B, MRMSrcMem, (outs GR32:$dst), (ins i32mem:$src),
3001 "movl\t%gs:$src, $dst",
3002 [(set GR32:$dst, (gsload addr:$src))]>, SegGS;
3003
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003004//===----------------------------------------------------------------------===//
3005// DWARF Pseudo Instructions
3006//
3007
Evan Chengb783fa32007-07-19 01:14:50 +00003008def DWARF_LOC : I<0, Pseudo, (outs),
3009 (ins i32imm:$line, i32imm:$col, i32imm:$file),
Dan Gohman77af4a82007-09-24 19:25:06 +00003010 ".loc\t${file:debug} ${line:debug} ${col:debug}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003011 [(dwarf_loc (i32 imm:$line), (i32 imm:$col),
3012 (i32 imm:$file))]>;
3013
3014//===----------------------------------------------------------------------===//
3015// EH Pseudo Instructions
3016//
3017let isTerminator = 1, isReturn = 1, isBarrier = 1,
Evan Cheng37e7c752007-07-21 00:34:19 +00003018 hasCtrlDep = 1 in {
Evan Chengb783fa32007-07-19 01:14:50 +00003019def EH_RETURN : I<0xC3, RawFrm, (outs), (ins GR32:$addr),
Dan Gohman91888f02007-07-31 20:11:57 +00003020 "ret\t#eh_return, addr: $addr",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003021 [(X86ehret GR32:$addr)]>;
3022
3023}
3024
3025//===----------------------------------------------------------------------===//
Andrew Lenharthe44f3902008-02-21 06:45:13 +00003026// Atomic support
3027//
Andrew Lenharth7a5a4b22008-03-01 13:37:02 +00003028
Evan Cheng3e171562008-04-19 01:20:30 +00003029// Atomic swap. These are just normal xchg instructions. But since a memory
3030// operand is referenced, the atomicity is ensured.
Dan Gohmana41a1c092008-08-06 15:52:50 +00003031let Constraints = "$val = $dst" in {
Evan Cheng3e171562008-04-19 01:20:30 +00003032def XCHG32rm : I<0x87, MRMSrcMem, (outs GR32:$dst), (ins i32mem:$ptr, GR32:$val),
3033 "xchg{l}\t{$val, $ptr|$ptr, $val}",
3034 [(set GR32:$dst, (atomic_swap_32 addr:$ptr, GR32:$val))]>;
3035def XCHG16rm : I<0x87, MRMSrcMem, (outs GR16:$dst), (ins i16mem:$ptr, GR16:$val),
3036 "xchg{w}\t{$val, $ptr|$ptr, $val}",
3037 [(set GR16:$dst, (atomic_swap_16 addr:$ptr, GR16:$val))]>,
3038 OpSize;
3039def XCHG8rm : I<0x86, MRMSrcMem, (outs GR8:$dst), (ins i8mem:$ptr, GR8:$val),
3040 "xchg{b}\t{$val, $ptr|$ptr, $val}",
3041 [(set GR8:$dst, (atomic_swap_8 addr:$ptr, GR8:$val))]>;
3042}
3043
Evan Chengd49dbb82008-04-18 20:55:36 +00003044// Atomic compare and swap.
Andrew Lenharth7dfe23f2008-03-01 21:52:34 +00003045let Defs = [EAX, EFLAGS], Uses = [EAX] in {
Evan Chengd49dbb82008-04-18 20:55:36 +00003046def LCMPXCHG32 : I<0xB1, MRMDestMem, (outs), (ins i32mem:$ptr, GR32:$swap),
Dan Gohman70a8a112009-04-27 15:13:28 +00003047 "lock\n\t"
3048 "cmpxchg{l}\t{$swap, $ptr|$ptr, $swap}",
Evan Cheng09fbdee2008-03-04 03:20:06 +00003049 [(X86cas addr:$ptr, GR32:$swap, 4)]>, TB, LOCK;
Andrew Lenharth7a5a4b22008-03-01 13:37:02 +00003050}
Dale Johannesenf160d802008-10-02 18:53:47 +00003051let Defs = [EAX, EDX, EFLAGS], Uses = [EAX, EBX, ECX, EDX] in {
Anton Korobeynikovc4067392008-07-22 16:22:48 +00003052def LCMPXCHG8B : I<0xC7, MRM1m, (outs), (ins i32mem:$ptr),
Dan Gohman70a8a112009-04-27 15:13:28 +00003053 "lock\n\t"
3054 "cmpxchg8b\t$ptr",
Andrew Lenharth81580822008-03-05 01:15:49 +00003055 [(X86cas8 addr:$ptr)]>, TB, LOCK;
3056}
Andrew Lenharth7dfe23f2008-03-01 21:52:34 +00003057
3058let Defs = [AX, EFLAGS], Uses = [AX] in {
Evan Chengd49dbb82008-04-18 20:55:36 +00003059def LCMPXCHG16 : I<0xB1, MRMDestMem, (outs), (ins i16mem:$ptr, GR16:$swap),
Dan Gohman70a8a112009-04-27 15:13:28 +00003060 "lock\n\t"
3061 "cmpxchg{w}\t{$swap, $ptr|$ptr, $swap}",
Evan Cheng09fbdee2008-03-04 03:20:06 +00003062 [(X86cas addr:$ptr, GR16:$swap, 2)]>, TB, OpSize, LOCK;
Andrew Lenharth7a5a4b22008-03-01 13:37:02 +00003063}
Andrew Lenharth7dfe23f2008-03-01 21:52:34 +00003064let Defs = [AL, EFLAGS], Uses = [AL] in {
Evan Chengd49dbb82008-04-18 20:55:36 +00003065def LCMPXCHG8 : I<0xB0, MRMDestMem, (outs), (ins i8mem:$ptr, GR8:$swap),
Dan Gohman70a8a112009-04-27 15:13:28 +00003066 "lock\n\t"
3067 "cmpxchg{b}\t{$swap, $ptr|$ptr, $swap}",
Evan Cheng09fbdee2008-03-04 03:20:06 +00003068 [(X86cas addr:$ptr, GR8:$swap, 1)]>, TB, LOCK;
Andrew Lenharth7a5a4b22008-03-01 13:37:02 +00003069}
3070
Evan Chengd49dbb82008-04-18 20:55:36 +00003071// Atomic exchange and add
3072let Constraints = "$val = $dst", Defs = [EFLAGS] in {
3073def LXADD32 : I<0xC1, MRMSrcMem, (outs GR32:$dst), (ins i32mem:$ptr, GR32:$val),
Dan Gohman70a8a112009-04-27 15:13:28 +00003074 "lock\n\t"
3075 "xadd{l}\t{$val, $ptr|$ptr, $val}",
Mon P Wang6bde9ec2008-06-25 08:15:39 +00003076 [(set GR32:$dst, (atomic_load_add_32 addr:$ptr, GR32:$val))]>,
Evan Chengd49dbb82008-04-18 20:55:36 +00003077 TB, LOCK;
3078def LXADD16 : I<0xC1, MRMSrcMem, (outs GR16:$dst), (ins i16mem:$ptr, GR16:$val),
Dan Gohman70a8a112009-04-27 15:13:28 +00003079 "lock\n\t"
3080 "xadd{w}\t{$val, $ptr|$ptr, $val}",
Mon P Wang6bde9ec2008-06-25 08:15:39 +00003081 [(set GR16:$dst, (atomic_load_add_16 addr:$ptr, GR16:$val))]>,
Evan Chengd49dbb82008-04-18 20:55:36 +00003082 TB, OpSize, LOCK;
3083def LXADD8 : I<0xC0, MRMSrcMem, (outs GR8:$dst), (ins i8mem:$ptr, GR8:$val),
Dan Gohman70a8a112009-04-27 15:13:28 +00003084 "lock\n\t"
3085 "xadd{b}\t{$val, $ptr|$ptr, $val}",
Mon P Wang6bde9ec2008-06-25 08:15:39 +00003086 [(set GR8:$dst, (atomic_load_add_8 addr:$ptr, GR8:$val))]>,
Evan Chengd49dbb82008-04-18 20:55:36 +00003087 TB, LOCK;
Andrew Lenharth7a5a4b22008-03-01 13:37:02 +00003088}
3089
Mon P Wang6bde9ec2008-06-25 08:15:39 +00003090// Atomic exchange, and, or, xor
Mon P Wang078a62d2008-05-05 19:05:59 +00003091let Constraints = "$val = $dst", Defs = [EFLAGS],
3092 usesCustomDAGSchedInserter = 1 in {
Dan Gohman8aeb61f2008-05-12 20:22:45 +00003093def ATOMAND32 : I<0, Pseudo, (outs GR32:$dst),(ins i32mem:$ptr, GR32:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003094 "#ATOMAND32 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003095 [(set GR32:$dst, (atomic_load_and_32 addr:$ptr, GR32:$val))]>;
Dan Gohman8aeb61f2008-05-12 20:22:45 +00003096def ATOMOR32 : I<0, Pseudo, (outs GR32:$dst),(ins i32mem:$ptr, GR32:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003097 "#ATOMOR32 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003098 [(set GR32:$dst, (atomic_load_or_32 addr:$ptr, GR32:$val))]>;
Dan Gohman8aeb61f2008-05-12 20:22:45 +00003099def ATOMXOR32 : I<0, Pseudo,(outs GR32:$dst),(ins i32mem:$ptr, GR32:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003100 "#ATOMXOR32 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003101 [(set GR32:$dst, (atomic_load_xor_32 addr:$ptr, GR32:$val))]>;
Andrew Lenharthaf02d592008-06-14 05:48:15 +00003102def ATOMNAND32 : I<0, Pseudo,(outs GR32:$dst),(ins i32mem:$ptr, GR32:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003103 "#ATOMNAND32 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003104 [(set GR32:$dst, (atomic_load_nand_32 addr:$ptr, GR32:$val))]>;
Dan Gohman8aeb61f2008-05-12 20:22:45 +00003105def ATOMMIN32: I<0, Pseudo, (outs GR32:$dst), (ins i32mem:$ptr, GR32:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003106 "#ATOMMIN32 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003107 [(set GR32:$dst, (atomic_load_min_32 addr:$ptr, GR32:$val))]>;
Dan Gohman8aeb61f2008-05-12 20:22:45 +00003108def ATOMMAX32: I<0, Pseudo, (outs GR32:$dst),(ins i32mem:$ptr, GR32:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003109 "#ATOMMAX32 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003110 [(set GR32:$dst, (atomic_load_max_32 addr:$ptr, GR32:$val))]>;
Dan Gohman8aeb61f2008-05-12 20:22:45 +00003111def ATOMUMIN32: I<0, Pseudo, (outs GR32:$dst),(ins i32mem:$ptr, GR32:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003112 "#ATOMUMIN32 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003113 [(set GR32:$dst, (atomic_load_umin_32 addr:$ptr, GR32:$val))]>;
Dan Gohman8aeb61f2008-05-12 20:22:45 +00003114def ATOMUMAX32: I<0, Pseudo, (outs GR32:$dst),(ins i32mem:$ptr, GR32:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003115 "#ATOMUMAX32 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003116 [(set GR32:$dst, (atomic_load_umax_32 addr:$ptr, GR32:$val))]>;
Dale Johannesend20e4452008-08-19 18:47:28 +00003117
3118def ATOMAND16 : I<0, Pseudo, (outs GR16:$dst),(ins i16mem:$ptr, GR16:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003119 "#ATOMAND16 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003120 [(set GR16:$dst, (atomic_load_and_16 addr:$ptr, GR16:$val))]>;
Dale Johannesend20e4452008-08-19 18:47:28 +00003121def ATOMOR16 : I<0, Pseudo, (outs GR16:$dst),(ins i16mem:$ptr, GR16:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003122 "#ATOMOR16 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003123 [(set GR16:$dst, (atomic_load_or_16 addr:$ptr, GR16:$val))]>;
Dale Johannesend20e4452008-08-19 18:47:28 +00003124def ATOMXOR16 : I<0, Pseudo,(outs GR16:$dst),(ins i16mem:$ptr, GR16:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003125 "#ATOMXOR16 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003126 [(set GR16:$dst, (atomic_load_xor_16 addr:$ptr, GR16:$val))]>;
Dale Johannesend20e4452008-08-19 18:47:28 +00003127def ATOMNAND16 : I<0, Pseudo,(outs GR16:$dst),(ins i16mem:$ptr, GR16:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003128 "#ATOMNAND16 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003129 [(set GR16:$dst, (atomic_load_nand_16 addr:$ptr, GR16:$val))]>;
Dale Johannesend20e4452008-08-19 18:47:28 +00003130def ATOMMIN16: I<0, Pseudo, (outs GR16:$dst), (ins i16mem:$ptr, GR16:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003131 "#ATOMMIN16 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003132 [(set GR16:$dst, (atomic_load_min_16 addr:$ptr, GR16:$val))]>;
Dale Johannesend20e4452008-08-19 18:47:28 +00003133def ATOMMAX16: I<0, Pseudo, (outs GR16:$dst),(ins i16mem:$ptr, GR16:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003134 "#ATOMMAX16 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003135 [(set GR16:$dst, (atomic_load_max_16 addr:$ptr, GR16:$val))]>;
Dale Johannesend20e4452008-08-19 18:47:28 +00003136def ATOMUMIN16: I<0, Pseudo, (outs GR16:$dst),(ins i16mem:$ptr, GR16:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003137 "#ATOMUMIN16 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003138 [(set GR16:$dst, (atomic_load_umin_16 addr:$ptr, GR16:$val))]>;
Dale Johannesend20e4452008-08-19 18:47:28 +00003139def ATOMUMAX16: I<0, Pseudo, (outs GR16:$dst),(ins i16mem:$ptr, GR16:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003140 "#ATOMUMAX16 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003141 [(set GR16:$dst, (atomic_load_umax_16 addr:$ptr, GR16:$val))]>;
Dale Johannesend20e4452008-08-19 18:47:28 +00003142
3143def ATOMAND8 : I<0, Pseudo, (outs GR8:$dst),(ins i8mem:$ptr, GR8:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003144 "#ATOMAND8 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003145 [(set GR8:$dst, (atomic_load_and_8 addr:$ptr, GR8:$val))]>;
Dale Johannesend20e4452008-08-19 18:47:28 +00003146def ATOMOR8 : I<0, Pseudo, (outs GR8:$dst),(ins i8mem:$ptr, GR8:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003147 "#ATOMOR8 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003148 [(set GR8:$dst, (atomic_load_or_8 addr:$ptr, GR8:$val))]>;
Dale Johannesend20e4452008-08-19 18:47:28 +00003149def ATOMXOR8 : I<0, Pseudo,(outs GR8:$dst),(ins i8mem:$ptr, GR8:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003150 "#ATOMXOR8 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003151 [(set GR8:$dst, (atomic_load_xor_8 addr:$ptr, GR8:$val))]>;
Dale Johannesend20e4452008-08-19 18:47:28 +00003152def ATOMNAND8 : I<0, Pseudo,(outs GR8:$dst),(ins i8mem:$ptr, GR8:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003153 "#ATOMNAND8 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003154 [(set GR8:$dst, (atomic_load_nand_8 addr:$ptr, GR8:$val))]>;
Mon P Wang078a62d2008-05-05 19:05:59 +00003155}
3156
Dale Johannesenf160d802008-10-02 18:53:47 +00003157let Constraints = "$val1 = $dst1, $val2 = $dst2",
3158 Defs = [EFLAGS, EAX, EBX, ECX, EDX],
3159 Uses = [EAX, EBX, ECX, EDX],
Dale Johannesen44eb5372008-10-03 19:41:08 +00003160 mayLoad = 1, mayStore = 1,
Dale Johannesenf160d802008-10-02 18:53:47 +00003161 usesCustomDAGSchedInserter = 1 in {
3162def ATOMAND6432 : I<0, Pseudo, (outs GR32:$dst1, GR32:$dst2),
3163 (ins i64mem:$ptr, GR32:$val1, GR32:$val2),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003164 "#ATOMAND6432 PSEUDO!", []>;
Dale Johannesenf160d802008-10-02 18:53:47 +00003165def ATOMOR6432 : I<0, Pseudo, (outs GR32:$dst1, GR32:$dst2),
3166 (ins i64mem:$ptr, GR32:$val1, GR32:$val2),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003167 "#ATOMOR6432 PSEUDO!", []>;
Dale Johannesenf160d802008-10-02 18:53:47 +00003168def ATOMXOR6432 : I<0, Pseudo, (outs GR32:$dst1, GR32:$dst2),
3169 (ins i64mem:$ptr, GR32:$val1, GR32:$val2),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003170 "#ATOMXOR6432 PSEUDO!", []>;
Dale Johannesenf160d802008-10-02 18:53:47 +00003171def ATOMNAND6432 : I<0, Pseudo, (outs GR32:$dst1, GR32:$dst2),
3172 (ins i64mem:$ptr, GR32:$val1, GR32:$val2),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003173 "#ATOMNAND6432 PSEUDO!", []>;
Dale Johannesenf160d802008-10-02 18:53:47 +00003174def ATOMADD6432 : I<0, Pseudo, (outs GR32:$dst1, GR32:$dst2),
3175 (ins i64mem:$ptr, GR32:$val1, GR32:$val2),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003176 "#ATOMADD6432 PSEUDO!", []>;
Dale Johannesenf160d802008-10-02 18:53:47 +00003177def ATOMSUB6432 : I<0, Pseudo, (outs GR32:$dst1, GR32:$dst2),
3178 (ins i64mem:$ptr, GR32:$val1, GR32:$val2),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003179 "#ATOMSUB6432 PSEUDO!", []>;
Dale Johannesen51c58ee2008-10-03 22:25:52 +00003180def ATOMSWAP6432 : I<0, Pseudo, (outs GR32:$dst1, GR32:$dst2),
3181 (ins i64mem:$ptr, GR32:$val1, GR32:$val2),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003182 "#ATOMSWAP6432 PSEUDO!", []>;
Dale Johannesenf160d802008-10-02 18:53:47 +00003183}
3184
Andrew Lenharthe44f3902008-02-21 06:45:13 +00003185//===----------------------------------------------------------------------===//
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003186// Non-Instruction Patterns
3187//===----------------------------------------------------------------------===//
3188
Bill Wendlingfef06052008-09-16 21:48:12 +00003189// ConstantPool GlobalAddress, ExternalSymbol, and JumpTable
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003190def : Pat<(i32 (X86Wrapper tconstpool :$dst)), (MOV32ri tconstpool :$dst)>;
3191def : Pat<(i32 (X86Wrapper tjumptable :$dst)), (MOV32ri tjumptable :$dst)>;
Nate Begemanb52948972008-04-12 00:47:57 +00003192def : Pat<(i32 (X86Wrapper tglobaltlsaddr:$dst)),(MOV32ri tglobaltlsaddr:$dst)>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003193def : Pat<(i32 (X86Wrapper tglobaladdr :$dst)), (MOV32ri tglobaladdr :$dst)>;
3194def : Pat<(i32 (X86Wrapper texternalsym:$dst)), (MOV32ri texternalsym:$dst)>;
3195
3196def : Pat<(add GR32:$src1, (X86Wrapper tconstpool:$src2)),
3197 (ADD32ri GR32:$src1, tconstpool:$src2)>;
3198def : Pat<(add GR32:$src1, (X86Wrapper tjumptable:$src2)),
3199 (ADD32ri GR32:$src1, tjumptable:$src2)>;
3200def : Pat<(add GR32:$src1, (X86Wrapper tglobaladdr :$src2)),
3201 (ADD32ri GR32:$src1, tglobaladdr:$src2)>;
3202def : Pat<(add GR32:$src1, (X86Wrapper texternalsym:$src2)),
3203 (ADD32ri GR32:$src1, texternalsym:$src2)>;
3204
3205def : Pat<(store (i32 (X86Wrapper tglobaladdr:$src)), addr:$dst),
3206 (MOV32mi addr:$dst, tglobaladdr:$src)>;
3207def : Pat<(store (i32 (X86Wrapper texternalsym:$src)), addr:$dst),
3208 (MOV32mi addr:$dst, texternalsym:$src)>;
3209
3210// Calls
Arnold Schwaighofere2d6bbb2007-10-11 19:40:01 +00003211// tailcall stuff
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003212def : Pat<(X86tailcall GR32:$dst),
Arnold Schwaighofere2d6bbb2007-10-11 19:40:01 +00003213 (TAILCALL)>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003214
3215def : Pat<(X86tailcall (i32 tglobaladdr:$dst)),
Arnold Schwaighofere2d6bbb2007-10-11 19:40:01 +00003216 (TAILCALL)>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003217def : Pat<(X86tailcall (i32 texternalsym:$dst)),
Arnold Schwaighofere2d6bbb2007-10-11 19:40:01 +00003218 (TAILCALL)>;
3219
3220def : Pat<(X86tcret GR32:$dst, imm:$off),
3221 (TCRETURNri GR32:$dst, imm:$off)>;
3222
3223def : Pat<(X86tcret (i32 tglobaladdr:$dst), imm:$off),
3224 (TCRETURNdi texternalsym:$dst, imm:$off)>;
3225
3226def : Pat<(X86tcret (i32 texternalsym:$dst), imm:$off),
3227 (TCRETURNdi texternalsym:$dst, imm:$off)>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003228
3229def : Pat<(X86call (i32 tglobaladdr:$dst)),
3230 (CALLpcrel32 tglobaladdr:$dst)>;
3231def : Pat<(X86call (i32 texternalsym:$dst)),
3232 (CALLpcrel32 texternalsym:$dst)>;
3233
3234// X86 specific add which produces a flag.
3235def : Pat<(addc GR32:$src1, GR32:$src2),
3236 (ADD32rr GR32:$src1, GR32:$src2)>;
3237def : Pat<(addc GR32:$src1, (load addr:$src2)),
3238 (ADD32rm GR32:$src1, addr:$src2)>;
3239def : Pat<(addc GR32:$src1, imm:$src2),
3240 (ADD32ri GR32:$src1, imm:$src2)>;
3241def : Pat<(addc GR32:$src1, i32immSExt8:$src2),
3242 (ADD32ri8 GR32:$src1, i32immSExt8:$src2)>;
3243
3244def : Pat<(subc GR32:$src1, GR32:$src2),
3245 (SUB32rr GR32:$src1, GR32:$src2)>;
3246def : Pat<(subc GR32:$src1, (load addr:$src2)),
3247 (SUB32rm GR32:$src1, addr:$src2)>;
3248def : Pat<(subc GR32:$src1, imm:$src2),
3249 (SUB32ri GR32:$src1, imm:$src2)>;
3250def : Pat<(subc GR32:$src1, i32immSExt8:$src2),
3251 (SUB32ri8 GR32:$src1, i32immSExt8:$src2)>;
3252
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003253// Comparisons.
3254
3255// TEST R,R is smaller than CMP R,0
Evan Cheng621216e2007-09-29 00:00:36 +00003256def : Pat<(parallel (X86cmp GR8:$src1, 0), (implicit EFLAGS)),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003257 (TEST8rr GR8:$src1, GR8:$src1)>;
Evan Cheng621216e2007-09-29 00:00:36 +00003258def : Pat<(parallel (X86cmp GR16:$src1, 0), (implicit EFLAGS)),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003259 (TEST16rr GR16:$src1, GR16:$src1)>;
Evan Cheng621216e2007-09-29 00:00:36 +00003260def : Pat<(parallel (X86cmp GR32:$src1, 0), (implicit EFLAGS)),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003261 (TEST32rr GR32:$src1, GR32:$src1)>;
3262
Dan Gohman0a3c5222009-01-07 01:00:24 +00003263// Conditional moves with folded loads with operands swapped and conditions
3264// inverted.
3265def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_B, EFLAGS),
3266 (CMOVAE16rm GR16:$src2, addr:$src1)>;
3267def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_B, EFLAGS),
3268 (CMOVAE32rm GR32:$src2, addr:$src1)>;
3269def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_AE, EFLAGS),
3270 (CMOVB16rm GR16:$src2, addr:$src1)>;
3271def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_AE, EFLAGS),
3272 (CMOVB32rm GR32:$src2, addr:$src1)>;
3273def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_E, EFLAGS),
3274 (CMOVNE16rm GR16:$src2, addr:$src1)>;
3275def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_E, EFLAGS),
3276 (CMOVNE32rm GR32:$src2, addr:$src1)>;
3277def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_NE, EFLAGS),
3278 (CMOVE16rm GR16:$src2, addr:$src1)>;
3279def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_NE, EFLAGS),
3280 (CMOVE32rm GR32:$src2, addr:$src1)>;
3281def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_BE, EFLAGS),
3282 (CMOVA16rm GR16:$src2, addr:$src1)>;
3283def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_BE, EFLAGS),
3284 (CMOVA32rm GR32:$src2, addr:$src1)>;
3285def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_A, EFLAGS),
3286 (CMOVBE16rm GR16:$src2, addr:$src1)>;
3287def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_A, EFLAGS),
3288 (CMOVBE32rm GR32:$src2, addr:$src1)>;
3289def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_L, EFLAGS),
3290 (CMOVGE16rm GR16:$src2, addr:$src1)>;
3291def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_L, EFLAGS),
3292 (CMOVGE32rm GR32:$src2, addr:$src1)>;
3293def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_GE, EFLAGS),
3294 (CMOVL16rm GR16:$src2, addr:$src1)>;
3295def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_GE, EFLAGS),
3296 (CMOVL32rm GR32:$src2, addr:$src1)>;
3297def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_LE, EFLAGS),
3298 (CMOVG16rm GR16:$src2, addr:$src1)>;
3299def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_LE, EFLAGS),
3300 (CMOVG32rm GR32:$src2, addr:$src1)>;
3301def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_G, EFLAGS),
3302 (CMOVLE16rm GR16:$src2, addr:$src1)>;
3303def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_G, EFLAGS),
3304 (CMOVLE32rm GR32:$src2, addr:$src1)>;
3305def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_P, EFLAGS),
3306 (CMOVNP16rm GR16:$src2, addr:$src1)>;
3307def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_P, EFLAGS),
3308 (CMOVNP32rm GR32:$src2, addr:$src1)>;
3309def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_NP, EFLAGS),
3310 (CMOVP16rm GR16:$src2, addr:$src1)>;
3311def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_NP, EFLAGS),
3312 (CMOVP32rm GR32:$src2, addr:$src1)>;
3313def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_S, EFLAGS),
3314 (CMOVNS16rm GR16:$src2, addr:$src1)>;
3315def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_S, EFLAGS),
3316 (CMOVNS32rm GR32:$src2, addr:$src1)>;
3317def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_NS, EFLAGS),
3318 (CMOVS16rm GR16:$src2, addr:$src1)>;
3319def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_NS, EFLAGS),
3320 (CMOVS32rm GR32:$src2, addr:$src1)>;
3321def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_O, EFLAGS),
3322 (CMOVNO16rm GR16:$src2, addr:$src1)>;
3323def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_O, EFLAGS),
3324 (CMOVNO32rm GR32:$src2, addr:$src1)>;
3325def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_NO, EFLAGS),
3326 (CMOVO16rm GR16:$src2, addr:$src1)>;
3327def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_NO, EFLAGS),
3328 (CMOVO32rm GR32:$src2, addr:$src1)>;
3329
Duncan Sands082524c2008-01-23 20:39:46 +00003330// zextload bool -> zextload byte
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003331def : Pat<(zextloadi8i1 addr:$src), (MOV8rm addr:$src)>;
3332def : Pat<(zextloadi16i1 addr:$src), (MOVZX16rm8 addr:$src)>;
3333def : Pat<(zextloadi32i1 addr:$src), (MOVZX32rm8 addr:$src)>;
3334
3335// extload bool -> extload byte
3336def : Pat<(extloadi8i1 addr:$src), (MOV8rm addr:$src)>;
Bill Wendlingce1c5c12008-08-22 20:51:05 +00003337def : Pat<(extloadi16i1 addr:$src), (MOVZX16rm8 addr:$src)>,
3338 Requires<[In32BitMode]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003339def : Pat<(extloadi32i1 addr:$src), (MOVZX32rm8 addr:$src)>;
Bill Wendlingce1c5c12008-08-22 20:51:05 +00003340def : Pat<(extloadi16i8 addr:$src), (MOVZX16rm8 addr:$src)>,
3341 Requires<[In32BitMode]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003342def : Pat<(extloadi32i8 addr:$src), (MOVZX32rm8 addr:$src)>;
3343def : Pat<(extloadi32i16 addr:$src), (MOVZX32rm16 addr:$src)>;
3344
Dan Gohmandd612bb2008-08-20 21:27:32 +00003345// anyext
Bill Wendlingce1c5c12008-08-22 20:51:05 +00003346def : Pat<(i16 (anyext GR8 :$src)), (MOVZX16rr8 GR8 :$src)>,
3347 Requires<[In32BitMode]>;
3348def : Pat<(i32 (anyext GR8 :$src)), (MOVZX32rr8 GR8 :$src)>,
3349 Requires<[In32BitMode]>;
Dan Gohmandd612bb2008-08-20 21:27:32 +00003350def : Pat<(i32 (anyext GR16:$src)),
3351 (INSERT_SUBREG (i32 (IMPLICIT_DEF)), GR16:$src, x86_subreg_16bit)>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003352
Evan Chengf2abee72007-12-13 00:43:27 +00003353// (and (i32 load), 255) -> (zextload i8)
Evan Cheng1e5e5452008-09-29 17:26:18 +00003354def : Pat<(i32 (and (nvloadi32 addr:$src), (i32 255))),
3355 (MOVZX32rm8 addr:$src)>;
3356def : Pat<(i32 (and (nvloadi32 addr:$src), (i32 65535))),
3357 (MOVZX32rm16 addr:$src)>;
Evan Chengf2abee72007-12-13 00:43:27 +00003358
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003359//===----------------------------------------------------------------------===//
3360// Some peepholes
3361//===----------------------------------------------------------------------===//
3362
Dan Gohman5a5e6e92008-10-17 01:33:43 +00003363// Odd encoding trick: -128 fits into an 8-bit immediate field while
3364// +128 doesn't, so in this special case use a sub instead of an add.
3365def : Pat<(add GR16:$src1, 128),
3366 (SUB16ri8 GR16:$src1, -128)>;
3367def : Pat<(store (add (loadi16 addr:$dst), 128), addr:$dst),
3368 (SUB16mi8 addr:$dst, -128)>;
3369def : Pat<(add GR32:$src1, 128),
3370 (SUB32ri8 GR32:$src1, -128)>;
3371def : Pat<(store (add (loadi32 addr:$dst), 128), addr:$dst),
3372 (SUB32mi8 addr:$dst, -128)>;
3373
Dan Gohman9203ab42008-07-30 18:09:17 +00003374// r & (2^16-1) ==> movz
3375def : Pat<(and GR32:$src1, 0xffff),
Dan Gohman744d4622009-04-13 16:09:41 +00003376 (MOVZX32rr16 (EXTRACT_SUBREG GR32:$src1, x86_subreg_16bit))>;
Dan Gohman5beb1ff2008-08-06 18:27:21 +00003377// r & (2^8-1) ==> movz
3378def : Pat<(and GR32:$src1, 0xff),
Dan Gohman6e438702009-04-27 16:33:14 +00003379 (MOVZX32rr8 (EXTRACT_SUBREG (COPY_TO_REGCLASS GR32:$src1, GR32_ABCD),
Dan Gohman744d4622009-04-13 16:09:41 +00003380 x86_subreg_8bit))>,
Dan Gohman5beb1ff2008-08-06 18:27:21 +00003381 Requires<[In32BitMode]>;
3382// r & (2^8-1) ==> movz
3383def : Pat<(and GR16:$src1, 0xff),
Dan Gohman6e438702009-04-27 16:33:14 +00003384 (MOVZX16rr8 (EXTRACT_SUBREG (COPY_TO_REGCLASS GR16:$src1, GR16_ABCD),
Dan Gohman744d4622009-04-13 16:09:41 +00003385 x86_subreg_8bit))>,
Dan Gohmandd612bb2008-08-20 21:27:32 +00003386 Requires<[In32BitMode]>;
3387
3388// sext_inreg patterns
3389def : Pat<(sext_inreg GR32:$src, i16),
Dan Gohman744d4622009-04-13 16:09:41 +00003390 (MOVSX32rr16 (EXTRACT_SUBREG GR32:$src, x86_subreg_16bit))>;
Dan Gohmandd612bb2008-08-20 21:27:32 +00003391def : Pat<(sext_inreg GR32:$src, i8),
Dan Gohman6e438702009-04-27 16:33:14 +00003392 (MOVSX32rr8 (EXTRACT_SUBREG (COPY_TO_REGCLASS GR32:$src, GR32_ABCD),
Dan Gohman744d4622009-04-13 16:09:41 +00003393 x86_subreg_8bit))>,
Dan Gohmandd612bb2008-08-20 21:27:32 +00003394 Requires<[In32BitMode]>;
3395def : Pat<(sext_inreg GR16:$src, i8),
Dan Gohman6e438702009-04-27 16:33:14 +00003396 (MOVSX16rr8 (EXTRACT_SUBREG (COPY_TO_REGCLASS GR16:$src, GR16_ABCD),
Dan Gohman744d4622009-04-13 16:09:41 +00003397 x86_subreg_8bit))>,
Dan Gohmandd612bb2008-08-20 21:27:32 +00003398 Requires<[In32BitMode]>;
3399
3400// trunc patterns
3401def : Pat<(i16 (trunc GR32:$src)),
Dan Gohman744d4622009-04-13 16:09:41 +00003402 (EXTRACT_SUBREG GR32:$src, x86_subreg_16bit)>;
Dan Gohmandd612bb2008-08-20 21:27:32 +00003403def : Pat<(i8 (trunc GR32:$src)),
Dan Gohman6e438702009-04-27 16:33:14 +00003404 (EXTRACT_SUBREG (COPY_TO_REGCLASS GR32:$src, GR32_ABCD),
Dan Gohman744d4622009-04-13 16:09:41 +00003405 x86_subreg_8bit)>,
Dan Gohmandd612bb2008-08-20 21:27:32 +00003406 Requires<[In32BitMode]>;
3407def : Pat<(i8 (trunc GR16:$src)),
Dan Gohman6e438702009-04-27 16:33:14 +00003408 (EXTRACT_SUBREG (COPY_TO_REGCLASS GR16:$src, GR16_ABCD),
Dan Gohman744d4622009-04-13 16:09:41 +00003409 x86_subreg_8bit)>,
3410 Requires<[In32BitMode]>;
3411
3412// h-register tricks
3413def : Pat<(i8 (trunc (srl_su GR16:$src, (i8 8)))),
Dan Gohman6e438702009-04-27 16:33:14 +00003414 (EXTRACT_SUBREG (COPY_TO_REGCLASS GR16:$src, GR16_ABCD),
Dan Gohman744d4622009-04-13 16:09:41 +00003415 x86_subreg_8bit_hi)>,
3416 Requires<[In32BitMode]>;
3417def : Pat<(i8 (trunc (srl_su GR32:$src, (i8 8)))),
Dan Gohman6e438702009-04-27 16:33:14 +00003418 (EXTRACT_SUBREG (COPY_TO_REGCLASS GR32:$src, GR32_ABCD),
Dan Gohman744d4622009-04-13 16:09:41 +00003419 x86_subreg_8bit_hi)>,
3420 Requires<[In32BitMode]>;
3421def : Pat<(srl_su GR16:$src, (i8 8)),
3422 (EXTRACT_SUBREG
3423 (MOVZX32rr8
Dan Gohman6e438702009-04-27 16:33:14 +00003424 (EXTRACT_SUBREG (COPY_TO_REGCLASS GR16:$src, GR16_ABCD),
Dan Gohman744d4622009-04-13 16:09:41 +00003425 x86_subreg_8bit_hi)),
3426 x86_subreg_16bit)>,
3427 Requires<[In32BitMode]>;
3428def : Pat<(and (srl_su GR32:$src, (i8 8)), (i32 255)),
Dan Gohman6e438702009-04-27 16:33:14 +00003429 (MOVZX32rr8 (EXTRACT_SUBREG (COPY_TO_REGCLASS GR32:$src, GR32_ABCD),
Dan Gohman744d4622009-04-13 16:09:41 +00003430 x86_subreg_8bit_hi))>,
Dan Gohman5beb1ff2008-08-06 18:27:21 +00003431 Requires<[In32BitMode]>;
Dan Gohman9203ab42008-07-30 18:09:17 +00003432
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003433// (shl x, 1) ==> (add x, x)
3434def : Pat<(shl GR8 :$src1, (i8 1)), (ADD8rr GR8 :$src1, GR8 :$src1)>;
3435def : Pat<(shl GR16:$src1, (i8 1)), (ADD16rr GR16:$src1, GR16:$src1)>;
3436def : Pat<(shl GR32:$src1, (i8 1)), (ADD32rr GR32:$src1, GR32:$src1)>;
3437
Evan Cheng76a64c72008-08-30 02:03:58 +00003438// (shl x (and y, 31)) ==> (shl x, y)
3439def : Pat<(shl GR8:$src1, (and CL:$amt, 31)),
3440 (SHL8rCL GR8:$src1)>;
3441def : Pat<(shl GR16:$src1, (and CL:$amt, 31)),
3442 (SHL16rCL GR16:$src1)>;
3443def : Pat<(shl GR32:$src1, (and CL:$amt, 31)),
3444 (SHL32rCL GR32:$src1)>;
3445def : Pat<(store (shl (loadi8 addr:$dst), (and CL:$amt, 31)), addr:$dst),
3446 (SHL8mCL addr:$dst)>;
3447def : Pat<(store (shl (loadi16 addr:$dst), (and CL:$amt, 31)), addr:$dst),
3448 (SHL16mCL addr:$dst)>;
3449def : Pat<(store (shl (loadi32 addr:$dst), (and CL:$amt, 31)), addr:$dst),
3450 (SHL32mCL addr:$dst)>;
3451
3452def : Pat<(srl GR8:$src1, (and CL:$amt, 31)),
3453 (SHR8rCL GR8:$src1)>;
3454def : Pat<(srl GR16:$src1, (and CL:$amt, 31)),
3455 (SHR16rCL GR16:$src1)>;
3456def : Pat<(srl GR32:$src1, (and CL:$amt, 31)),
3457 (SHR32rCL GR32:$src1)>;
3458def : Pat<(store (srl (loadi8 addr:$dst), (and CL:$amt, 31)), addr:$dst),
3459 (SHR8mCL addr:$dst)>;
3460def : Pat<(store (srl (loadi16 addr:$dst), (and CL:$amt, 31)), addr:$dst),
3461 (SHR16mCL addr:$dst)>;
3462def : Pat<(store (srl (loadi32 addr:$dst), (and CL:$amt, 31)), addr:$dst),
3463 (SHR32mCL addr:$dst)>;
3464
3465def : Pat<(sra GR8:$src1, (and CL:$amt, 31)),
3466 (SAR8rCL GR8:$src1)>;
3467def : Pat<(sra GR16:$src1, (and CL:$amt, 31)),
3468 (SAR16rCL GR16:$src1)>;
3469def : Pat<(sra GR32:$src1, (and CL:$amt, 31)),
3470 (SAR32rCL GR32:$src1)>;
3471def : Pat<(store (sra (loadi8 addr:$dst), (and CL:$amt, 31)), addr:$dst),
3472 (SAR8mCL addr:$dst)>;
3473def : Pat<(store (sra (loadi16 addr:$dst), (and CL:$amt, 31)), addr:$dst),
3474 (SAR16mCL addr:$dst)>;
3475def : Pat<(store (sra (loadi32 addr:$dst), (and CL:$amt, 31)), addr:$dst),
3476 (SAR32mCL addr:$dst)>;
3477
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003478// (or (x >> c) | (y << (32 - c))) ==> (shrd32 x, y, c)
3479def : Pat<(or (srl GR32:$src1, CL:$amt),
3480 (shl GR32:$src2, (sub 32, CL:$amt))),
3481 (SHRD32rrCL GR32:$src1, GR32:$src2)>;
3482
3483def : Pat<(store (or (srl (loadi32 addr:$dst), CL:$amt),
3484 (shl GR32:$src2, (sub 32, CL:$amt))), addr:$dst),
3485 (SHRD32mrCL addr:$dst, GR32:$src2)>;
3486
Dan Gohman921581d2008-10-17 01:23:35 +00003487def : Pat<(or (srl GR32:$src1, (i8 (trunc ECX:$amt))),
3488 (shl GR32:$src2, (i8 (trunc (sub 32, ECX:$amt))))),
3489 (SHRD32rrCL GR32:$src1, GR32:$src2)>;
3490
3491def : Pat<(store (or (srl (loadi32 addr:$dst), (i8 (trunc ECX:$amt))),
3492 (shl GR32:$src2, (i8 (trunc (sub 32, ECX:$amt))))),
3493 addr:$dst),
3494 (SHRD32mrCL addr:$dst, GR32:$src2)>;
3495
3496def : Pat<(shrd GR32:$src1, (i8 imm:$amt1), GR32:$src2, (i8 imm:$amt2)),
3497 (SHRD32rri8 GR32:$src1, GR32:$src2, (i8 imm:$amt1))>;
3498
3499def : Pat<(store (shrd (loadi32 addr:$dst), (i8 imm:$amt1),
3500 GR32:$src2, (i8 imm:$amt2)), addr:$dst),
3501 (SHRD32mri8 addr:$dst, GR32:$src2, (i8 imm:$amt1))>;
3502
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003503// (or (x << c) | (y >> (32 - c))) ==> (shld32 x, y, c)
3504def : Pat<(or (shl GR32:$src1, CL:$amt),
3505 (srl GR32:$src2, (sub 32, CL:$amt))),
3506 (SHLD32rrCL GR32:$src1, GR32:$src2)>;
3507
3508def : Pat<(store (or (shl (loadi32 addr:$dst), CL:$amt),
3509 (srl GR32:$src2, (sub 32, CL:$amt))), addr:$dst),
3510 (SHLD32mrCL addr:$dst, GR32:$src2)>;
3511
Dan Gohman921581d2008-10-17 01:23:35 +00003512def : Pat<(or (shl GR32:$src1, (i8 (trunc ECX:$amt))),
3513 (srl GR32:$src2, (i8 (trunc (sub 32, ECX:$amt))))),
3514 (SHLD32rrCL GR32:$src1, GR32:$src2)>;
3515
3516def : Pat<(store (or (shl (loadi32 addr:$dst), (i8 (trunc ECX:$amt))),
3517 (srl GR32:$src2, (i8 (trunc (sub 32, ECX:$amt))))),
3518 addr:$dst),
3519 (SHLD32mrCL addr:$dst, GR32:$src2)>;
3520
3521def : Pat<(shld GR32:$src1, (i8 imm:$amt1), GR32:$src2, (i8 imm:$amt2)),
3522 (SHLD32rri8 GR32:$src1, GR32:$src2, (i8 imm:$amt1))>;
3523
3524def : Pat<(store (shld (loadi32 addr:$dst), (i8 imm:$amt1),
3525 GR32:$src2, (i8 imm:$amt2)), addr:$dst),
3526 (SHLD32mri8 addr:$dst, GR32:$src2, (i8 imm:$amt1))>;
3527
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003528// (or (x >> c) | (y << (16 - c))) ==> (shrd16 x, y, c)
3529def : Pat<(or (srl GR16:$src1, CL:$amt),
3530 (shl GR16:$src2, (sub 16, CL:$amt))),
3531 (SHRD16rrCL GR16:$src1, GR16:$src2)>;
3532
3533def : Pat<(store (or (srl (loadi16 addr:$dst), CL:$amt),
3534 (shl GR16:$src2, (sub 16, CL:$amt))), addr:$dst),
3535 (SHRD16mrCL addr:$dst, GR16:$src2)>;
3536
Dan Gohman921581d2008-10-17 01:23:35 +00003537def : Pat<(or (srl GR16:$src1, (i8 (trunc CX:$amt))),
3538 (shl GR16:$src2, (i8 (trunc (sub 16, CX:$amt))))),
3539 (SHRD16rrCL GR16:$src1, GR16:$src2)>;
3540
3541def : Pat<(store (or (srl (loadi16 addr:$dst), (i8 (trunc CX:$amt))),
3542 (shl GR16:$src2, (i8 (trunc (sub 16, CX:$amt))))),
3543 addr:$dst),
3544 (SHRD16mrCL addr:$dst, GR16:$src2)>;
3545
3546def : Pat<(shrd GR16:$src1, (i8 imm:$amt1), GR16:$src2, (i8 imm:$amt2)),
3547 (SHRD16rri8 GR16:$src1, GR16:$src2, (i8 imm:$amt1))>;
3548
3549def : Pat<(store (shrd (loadi16 addr:$dst), (i8 imm:$amt1),
3550 GR16:$src2, (i8 imm:$amt2)), addr:$dst),
3551 (SHRD16mri8 addr:$dst, GR16:$src2, (i8 imm:$amt1))>;
3552
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003553// (or (x << c) | (y >> (16 - c))) ==> (shld16 x, y, c)
3554def : Pat<(or (shl GR16:$src1, CL:$amt),
3555 (srl GR16:$src2, (sub 16, CL:$amt))),
3556 (SHLD16rrCL GR16:$src1, GR16:$src2)>;
3557
3558def : Pat<(store (or (shl (loadi16 addr:$dst), CL:$amt),
3559 (srl GR16:$src2, (sub 16, CL:$amt))), addr:$dst),
3560 (SHLD16mrCL addr:$dst, GR16:$src2)>;
3561
Dan Gohman921581d2008-10-17 01:23:35 +00003562def : Pat<(or (shl GR16:$src1, (i8 (trunc CX:$amt))),
3563 (srl GR16:$src2, (i8 (trunc (sub 16, CX:$amt))))),
3564 (SHLD16rrCL GR16:$src1, GR16:$src2)>;
3565
3566def : Pat<(store (or (shl (loadi16 addr:$dst), (i8 (trunc CX:$amt))),
3567 (srl GR16:$src2, (i8 (trunc (sub 16, CX:$amt))))),
3568 addr:$dst),
3569 (SHLD16mrCL addr:$dst, GR16:$src2)>;
3570
3571def : Pat<(shld GR16:$src1, (i8 imm:$amt1), GR16:$src2, (i8 imm:$amt2)),
3572 (SHLD16rri8 GR16:$src1, GR16:$src2, (i8 imm:$amt1))>;
3573
3574def : Pat<(store (shld (loadi16 addr:$dst), (i8 imm:$amt1),
3575 GR16:$src2, (i8 imm:$amt2)), addr:$dst),
3576 (SHLD16mri8 addr:$dst, GR16:$src2, (i8 imm:$amt1))>;
3577
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003578//===----------------------------------------------------------------------===//
Dan Gohman99a12192009-03-04 19:44:21 +00003579// EFLAGS-defining Patterns
Bill Wendlingf5399032008-12-12 21:15:41 +00003580//===----------------------------------------------------------------------===//
3581
Dan Gohman99a12192009-03-04 19:44:21 +00003582// Register-Register Addition with EFLAGS result
3583def : Pat<(parallel (X86add_flag GR8:$src1, GR8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003584 (implicit EFLAGS)),
3585 (ADD8rr GR8:$src1, GR8:$src2)>;
3586
Dan Gohman99a12192009-03-04 19:44:21 +00003587// Register-Register Addition with EFLAGS result
3588def : Pat<(parallel (X86add_flag GR16:$src1, GR16:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003589 (implicit EFLAGS)),
3590 (ADD16rr GR16:$src1, GR16:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003591def : Pat<(parallel (X86add_flag GR32:$src1, GR32:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003592 (implicit EFLAGS)),
3593 (ADD32rr GR32:$src1, GR32:$src2)>;
3594
Dan Gohman99a12192009-03-04 19:44:21 +00003595// Register-Memory Addition with EFLAGS result
3596def : Pat<(parallel (X86add_flag GR8:$src1, (loadi8 addr:$src2)),
Bill Wendlingf5399032008-12-12 21:15:41 +00003597 (implicit EFLAGS)),
3598 (ADD8rm GR8:$src1, addr:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003599def : Pat<(parallel (X86add_flag GR16:$src1, (loadi16 addr:$src2)),
Bill Wendlingf5399032008-12-12 21:15:41 +00003600 (implicit EFLAGS)),
3601 (ADD16rm GR16:$src1, addr:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003602def : Pat<(parallel (X86add_flag GR32:$src1, (loadi32 addr:$src2)),
Bill Wendlingf5399032008-12-12 21:15:41 +00003603 (implicit EFLAGS)),
3604 (ADD32rm GR32:$src1, addr:$src2)>;
3605
Dan Gohman99a12192009-03-04 19:44:21 +00003606// Register-Integer Addition with EFLAGS result
3607def : Pat<(parallel (X86add_flag GR8:$src1, imm:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003608 (implicit EFLAGS)),
3609 (ADD8ri GR8:$src1, imm:$src2)>;
3610
Dan Gohman99a12192009-03-04 19:44:21 +00003611// Register-Integer Addition with EFLAGS result
3612def : Pat<(parallel (X86add_flag GR16:$src1, imm:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003613 (implicit EFLAGS)),
3614 (ADD16ri GR16:$src1, imm:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003615def : Pat<(parallel (X86add_flag GR32:$src1, imm:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003616 (implicit EFLAGS)),
3617 (ADD32ri GR32:$src1, imm:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003618def : Pat<(parallel (X86add_flag GR16:$src1, i16immSExt8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003619 (implicit EFLAGS)),
3620 (ADD16ri8 GR16:$src1, i16immSExt8:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003621def : Pat<(parallel (X86add_flag GR32:$src1, i32immSExt8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003622 (implicit EFLAGS)),
3623 (ADD32ri8 GR32:$src1, i32immSExt8:$src2)>;
3624
Dan Gohman99a12192009-03-04 19:44:21 +00003625// Memory-Register Addition with EFLAGS result
3626def : Pat<(parallel (store (X86add_flag (loadi8 addr:$dst), GR8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003627 addr:$dst),
3628 (implicit EFLAGS)),
3629 (ADD8mr addr:$dst, GR8:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003630def : Pat<(parallel (store (X86add_flag (loadi16 addr:$dst), GR16:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003631 addr:$dst),
3632 (implicit EFLAGS)),
3633 (ADD16mr addr:$dst, GR16:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003634def : Pat<(parallel (store (X86add_flag (loadi32 addr:$dst), GR32:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003635 addr:$dst),
3636 (implicit EFLAGS)),
3637 (ADD32mr addr:$dst, GR32:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003638def : Pat<(parallel (store (X86add_flag (loadi8 addr:$dst), imm:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003639 addr:$dst),
3640 (implicit EFLAGS)),
3641 (ADD8mi addr:$dst, imm:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003642def : Pat<(parallel (store (X86add_flag (loadi16 addr:$dst), imm:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003643 addr:$dst),
3644 (implicit EFLAGS)),
3645 (ADD16mi addr:$dst, imm:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003646def : Pat<(parallel (store (X86add_flag (loadi32 addr:$dst), imm:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003647 addr:$dst),
3648 (implicit EFLAGS)),
3649 (ADD32mi addr:$dst, imm:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003650def : Pat<(parallel (store (X86add_flag (loadi16 addr:$dst), i16immSExt8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003651 addr:$dst),
3652 (implicit EFLAGS)),
3653 (ADD16mi8 addr:$dst, i16immSExt8:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003654def : Pat<(parallel (store (X86add_flag (loadi32 addr:$dst), i32immSExt8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003655 addr:$dst),
3656 (implicit EFLAGS)),
3657 (ADD32mi8 addr:$dst, i32immSExt8:$src2)>;
3658
Dan Gohman99a12192009-03-04 19:44:21 +00003659// Register-Register Subtraction with EFLAGS result
3660def : Pat<(parallel (X86sub_flag GR8:$src1, GR8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003661 (implicit EFLAGS)),
3662 (SUB8rr GR8:$src1, GR8:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003663def : Pat<(parallel (X86sub_flag GR16:$src1, GR16:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003664 (implicit EFLAGS)),
3665 (SUB16rr GR16:$src1, GR16:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003666def : Pat<(parallel (X86sub_flag GR32:$src1, GR32:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003667 (implicit EFLAGS)),
3668 (SUB32rr GR32:$src1, GR32:$src2)>;
3669
Dan Gohman99a12192009-03-04 19:44:21 +00003670// Register-Memory Subtraction with EFLAGS result
3671def : Pat<(parallel (X86sub_flag GR8:$src1, (loadi8 addr:$src2)),
Bill Wendlingf5399032008-12-12 21:15:41 +00003672 (implicit EFLAGS)),
3673 (SUB8rm GR8:$src1, addr:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003674def : Pat<(parallel (X86sub_flag GR16:$src1, (loadi16 addr:$src2)),
Bill Wendlingf5399032008-12-12 21:15:41 +00003675 (implicit EFLAGS)),
3676 (SUB16rm GR16:$src1, addr:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003677def : Pat<(parallel (X86sub_flag GR32:$src1, (loadi32 addr:$src2)),
Bill Wendlingf5399032008-12-12 21:15:41 +00003678 (implicit EFLAGS)),
3679 (SUB32rm GR32:$src1, addr:$src2)>;
3680
Dan Gohman99a12192009-03-04 19:44:21 +00003681// Register-Integer Subtraction with EFLAGS result
3682def : Pat<(parallel (X86sub_flag GR8:$src1, imm:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003683 (implicit EFLAGS)),
3684 (SUB8ri GR8:$src1, imm:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003685def : Pat<(parallel (X86sub_flag GR16:$src1, imm:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003686 (implicit EFLAGS)),
3687 (SUB16ri GR16:$src1, imm:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003688def : Pat<(parallel (X86sub_flag GR32:$src1, imm:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003689 (implicit EFLAGS)),
3690 (SUB32ri GR32:$src1, imm:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003691def : Pat<(parallel (X86sub_flag GR16:$src1, i16immSExt8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003692 (implicit EFLAGS)),
3693 (SUB16ri8 GR16:$src1, i16immSExt8:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003694def : Pat<(parallel (X86sub_flag GR32:$src1, i32immSExt8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003695 (implicit EFLAGS)),
3696 (SUB32ri8 GR32:$src1, i32immSExt8:$src2)>;
3697
Dan Gohman99a12192009-03-04 19:44:21 +00003698// Memory-Register Subtraction with EFLAGS result
3699def : Pat<(parallel (store (X86sub_flag (loadi8 addr:$dst), GR8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003700 addr:$dst),
3701 (implicit EFLAGS)),
3702 (SUB8mr addr:$dst, GR8:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003703def : Pat<(parallel (store (X86sub_flag (loadi16 addr:$dst), GR16:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003704 addr:$dst),
3705 (implicit EFLAGS)),
3706 (SUB16mr addr:$dst, GR16:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003707def : Pat<(parallel (store (X86sub_flag (loadi32 addr:$dst), GR32:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003708 addr:$dst),
3709 (implicit EFLAGS)),
3710 (SUB32mr addr:$dst, GR32:$src2)>;
3711
Dan Gohman99a12192009-03-04 19:44:21 +00003712// Memory-Integer Subtraction with EFLAGS result
3713def : Pat<(parallel (store (X86sub_flag (loadi8 addr:$dst), imm:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003714 addr:$dst),
3715 (implicit EFLAGS)),
3716 (SUB8mi addr:$dst, imm:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003717def : Pat<(parallel (store (X86sub_flag (loadi16 addr:$dst), imm:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003718 addr:$dst),
3719 (implicit EFLAGS)),
3720 (SUB16mi addr:$dst, imm:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003721def : Pat<(parallel (store (X86sub_flag (loadi32 addr:$dst), imm:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003722 addr:$dst),
3723 (implicit EFLAGS)),
3724 (SUB32mi addr:$dst, imm:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003725def : Pat<(parallel (store (X86sub_flag (loadi16 addr:$dst), i16immSExt8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003726 addr:$dst),
3727 (implicit EFLAGS)),
3728 (SUB16mi8 addr:$dst, i16immSExt8:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003729def : Pat<(parallel (store (X86sub_flag (loadi32 addr:$dst), i32immSExt8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003730 addr:$dst),
3731 (implicit EFLAGS)),
3732 (SUB32mi8 addr:$dst, i32immSExt8:$src2)>;
3733
3734
Dan Gohman99a12192009-03-04 19:44:21 +00003735// Register-Register Signed Integer Multiply with EFLAGS result
3736def : Pat<(parallel (X86smul_flag GR16:$src1, GR16:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003737 (implicit EFLAGS)),
3738 (IMUL16rr GR16:$src1, GR16:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003739def : Pat<(parallel (X86smul_flag GR32:$src1, GR32:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003740 (implicit EFLAGS)),
3741 (IMUL32rr GR32:$src1, GR32:$src2)>;
3742
Dan Gohman99a12192009-03-04 19:44:21 +00003743// Register-Memory Signed Integer Multiply with EFLAGS result
3744def : Pat<(parallel (X86smul_flag GR16:$src1, (loadi16 addr:$src2)),
Bill Wendlingf5399032008-12-12 21:15:41 +00003745 (implicit EFLAGS)),
3746 (IMUL16rm GR16:$src1, addr:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003747def : Pat<(parallel (X86smul_flag GR32:$src1, (loadi32 addr:$src2)),
Bill Wendlingf5399032008-12-12 21:15:41 +00003748 (implicit EFLAGS)),
3749 (IMUL32rm GR32:$src1, addr:$src2)>;
3750
Dan Gohman99a12192009-03-04 19:44:21 +00003751// Register-Integer Signed Integer Multiply with EFLAGS result
3752def : Pat<(parallel (X86smul_flag GR16:$src1, imm:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003753 (implicit EFLAGS)),
3754 (IMUL16rri GR16:$src1, imm:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003755def : Pat<(parallel (X86smul_flag GR32:$src1, imm:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003756 (implicit EFLAGS)),
3757 (IMUL32rri GR32:$src1, imm:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003758def : Pat<(parallel (X86smul_flag GR16:$src1, i16immSExt8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003759 (implicit EFLAGS)),
3760 (IMUL16rri8 GR16:$src1, i16immSExt8:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003761def : Pat<(parallel (X86smul_flag GR32:$src1, i32immSExt8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003762 (implicit EFLAGS)),
3763 (IMUL32rri8 GR32:$src1, i32immSExt8:$src2)>;
3764
Dan Gohman99a12192009-03-04 19:44:21 +00003765// Memory-Integer Signed Integer Multiply with EFLAGS result
3766def : Pat<(parallel (X86smul_flag (loadi16 addr:$src1), imm:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003767 (implicit EFLAGS)),
3768 (IMUL16rmi addr:$src1, imm:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003769def : Pat<(parallel (X86smul_flag (loadi32 addr:$src1), imm:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003770 (implicit EFLAGS)),
3771 (IMUL32rmi addr:$src1, imm:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003772def : Pat<(parallel (X86smul_flag (loadi16 addr:$src1), i16immSExt8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003773 (implicit EFLAGS)),
3774 (IMUL16rmi8 addr:$src1, i16immSExt8:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003775def : Pat<(parallel (X86smul_flag (loadi32 addr:$src1), i32immSExt8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003776 (implicit EFLAGS)),
3777 (IMUL32rmi8 addr:$src1, i32immSExt8:$src2)>;
3778
Dan Gohman99a12192009-03-04 19:44:21 +00003779// Optimize multiply by 2 with EFLAGS result.
Evan Cheng00cf7932009-01-27 03:30:42 +00003780let AddedComplexity = 2 in {
Dan Gohman99a12192009-03-04 19:44:21 +00003781def : Pat<(parallel (X86smul_flag GR16:$src1, 2),
Evan Cheng00cf7932009-01-27 03:30:42 +00003782 (implicit EFLAGS)),
3783 (ADD16rr GR16:$src1, GR16:$src1)>;
3784
Dan Gohman99a12192009-03-04 19:44:21 +00003785def : Pat<(parallel (X86smul_flag GR32:$src1, 2),
Evan Cheng00cf7932009-01-27 03:30:42 +00003786 (implicit EFLAGS)),
3787 (ADD32rr GR32:$src1, GR32:$src1)>;
3788}
3789
Dan Gohman99a12192009-03-04 19:44:21 +00003790// INC and DEC with EFLAGS result. Note that these do not set CF.
3791def : Pat<(parallel (X86inc_flag GR8:$src), (implicit EFLAGS)),
3792 (INC8r GR8:$src)>;
3793def : Pat<(parallel (store (i8 (X86inc_flag (loadi8 addr:$dst))), addr:$dst),
3794 (implicit EFLAGS)),
3795 (INC8m addr:$dst)>;
3796def : Pat<(parallel (X86dec_flag GR8:$src), (implicit EFLAGS)),
3797 (DEC8r GR8:$src)>;
3798def : Pat<(parallel (store (i8 (X86dec_flag (loadi8 addr:$dst))), addr:$dst),
3799 (implicit EFLAGS)),
3800 (DEC8m addr:$dst)>;
3801
3802def : Pat<(parallel (X86inc_flag GR16:$src), (implicit EFLAGS)),
Dan Gohmaneebcac72009-03-05 21:32:23 +00003803 (INC16r GR16:$src)>, Requires<[In32BitMode]>;
Dan Gohman99a12192009-03-04 19:44:21 +00003804def : Pat<(parallel (store (i16 (X86inc_flag (loadi16 addr:$dst))), addr:$dst),
3805 (implicit EFLAGS)),
Dan Gohmaneebcac72009-03-05 21:32:23 +00003806 (INC16m addr:$dst)>, Requires<[In32BitMode]>;
Dan Gohman99a12192009-03-04 19:44:21 +00003807def : Pat<(parallel (X86dec_flag GR16:$src), (implicit EFLAGS)),
Dan Gohmaneebcac72009-03-05 21:32:23 +00003808 (DEC16r GR16:$src)>, Requires<[In32BitMode]>;
Dan Gohman99a12192009-03-04 19:44:21 +00003809def : Pat<(parallel (store (i16 (X86dec_flag (loadi16 addr:$dst))), addr:$dst),
3810 (implicit EFLAGS)),
Dan Gohmaneebcac72009-03-05 21:32:23 +00003811 (DEC16m addr:$dst)>, Requires<[In32BitMode]>;
Dan Gohman99a12192009-03-04 19:44:21 +00003812
3813def : Pat<(parallel (X86inc_flag GR32:$src), (implicit EFLAGS)),
Dan Gohmaneebcac72009-03-05 21:32:23 +00003814 (INC32r GR32:$src)>, Requires<[In32BitMode]>;
Dan Gohman99a12192009-03-04 19:44:21 +00003815def : Pat<(parallel (store (i32 (X86inc_flag (loadi32 addr:$dst))), addr:$dst),
3816 (implicit EFLAGS)),
Dan Gohmaneebcac72009-03-05 21:32:23 +00003817 (INC32m addr:$dst)>, Requires<[In32BitMode]>;
Dan Gohman99a12192009-03-04 19:44:21 +00003818def : Pat<(parallel (X86dec_flag GR32:$src), (implicit EFLAGS)),
Dan Gohmaneebcac72009-03-05 21:32:23 +00003819 (DEC32r GR32:$src)>, Requires<[In32BitMode]>;
Dan Gohman99a12192009-03-04 19:44:21 +00003820def : Pat<(parallel (store (i32 (X86dec_flag (loadi32 addr:$dst))), addr:$dst),
3821 (implicit EFLAGS)),
Dan Gohmaneebcac72009-03-05 21:32:23 +00003822 (DEC32m addr:$dst)>, Requires<[In32BitMode]>;
Dan Gohman99a12192009-03-04 19:44:21 +00003823
Bill Wendlingf5399032008-12-12 21:15:41 +00003824//===----------------------------------------------------------------------===//
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003825// Floating Point Stack Support
3826//===----------------------------------------------------------------------===//
3827
3828include "X86InstrFPStack.td"
3829
3830//===----------------------------------------------------------------------===//
Evan Cheng86ab7d32007-07-31 08:04:03 +00003831// X86-64 Support
3832//===----------------------------------------------------------------------===//
3833
Chris Lattner2de8d2b2008-01-10 05:50:42 +00003834include "X86Instr64bit.td"
Evan Cheng86ab7d32007-07-31 08:04:03 +00003835
3836//===----------------------------------------------------------------------===//
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003837// XMM Floating point support (requires SSE / SSE2)
3838//===----------------------------------------------------------------------===//
3839
3840include "X86InstrSSE.td"
Evan Cheng5e4d1e72008-04-25 18:19:54 +00003841
3842//===----------------------------------------------------------------------===//
3843// MMX and XMM Packed Integer support (requires MMX, SSE, and SSE2)
3844//===----------------------------------------------------------------------===//
3845
3846include "X86InstrMMX.td"