blob: 25d443a392b3327a9e442328c6c74299706fd6da [file] [log] [blame]
Arnold Schwaighofer373e8652007-10-12 21:30:57 +00001//===- X86InstrInfo.td - Describe the X86 Instruction Set --*- tablegen -*-===//
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002//
3// The LLVM Compiler Infrastructure
4//
Chris Lattner081ce942007-12-29 20:36:04 +00005// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
Dan Gohmanf17a25c2007-07-18 16:29:46 +00007//
8//===----------------------------------------------------------------------===//
9//
10// This file describes the X86 instruction set, defining the instructions, and
11// properties of the instructions which are needed for code generation, machine
12// code emission, and analysis.
13//
14//===----------------------------------------------------------------------===//
15
16//===----------------------------------------------------------------------===//
17// X86 specific DAG Nodes.
18//
19
20def SDTIntShiftDOp: SDTypeProfile<1, 3,
21 [SDTCisSameAs<0, 1>, SDTCisSameAs<0, 2>,
22 SDTCisInt<0>, SDTCisInt<3>]>;
23
24def SDTX86CmpTest : SDTypeProfile<0, 2, [SDTCisSameAs<0, 1>]>;
25
Evan Cheng621216e2007-09-29 00:00:36 +000026def SDTX86Cmov : SDTypeProfile<1, 4,
Evan Cheng950aac02007-09-25 01:57:46 +000027 [SDTCisSameAs<0, 1>, SDTCisSameAs<1, 2>,
28 SDTCisVT<3, i8>, SDTCisVT<4, i32>]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +000029
Dan Gohman99a12192009-03-04 19:44:21 +000030// Unary and binary operator instructions that set EFLAGS as a side-effect.
31def SDTUnaryArithWithFlags : SDTypeProfile<1, 1,
32 [SDTCisInt<0>]>;
33def SDTBinaryArithWithFlags : SDTypeProfile<1, 2,
34 [SDTCisSameAs<0, 1>,
35 SDTCisSameAs<0, 2>,
36 SDTCisInt<0>]>;
Evan Cheng621216e2007-09-29 00:00:36 +000037def SDTX86BrCond : SDTypeProfile<0, 3,
Evan Cheng950aac02007-09-25 01:57:46 +000038 [SDTCisVT<0, OtherVT>,
39 SDTCisVT<1, i8>, SDTCisVT<2, i32>]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +000040
Evan Cheng621216e2007-09-29 00:00:36 +000041def SDTX86SetCC : SDTypeProfile<1, 2,
Evan Cheng950aac02007-09-25 01:57:46 +000042 [SDTCisVT<0, i8>,
43 SDTCisVT<1, i8>, SDTCisVT<2, i32>]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +000044
Andrew Lenharth7dfe23f2008-03-01 21:52:34 +000045def SDTX86cas : SDTypeProfile<0, 3, [SDTCisPtrTy<0>, SDTCisInt<1>,
46 SDTCisVT<2, i8>]>;
Andrew Lenharth81580822008-03-05 01:15:49 +000047def SDTX86cas8 : SDTypeProfile<0, 1, [SDTCisPtrTy<0>]>;
Andrew Lenharth7dfe23f2008-03-01 21:52:34 +000048
Dale Johannesenf160d802008-10-02 18:53:47 +000049def SDTX86atomicBinary : SDTypeProfile<2, 3, [SDTCisInt<0>, SDTCisInt<1>,
50 SDTCisPtrTy<2>, SDTCisInt<3>,SDTCisInt<4>]>;
Chris Lattnerb56cc342008-03-11 03:23:40 +000051def SDTX86Ret : SDTypeProfile<0, -1, [SDTCisVT<0, i16>]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +000052
Bill Wendling7173da52007-11-13 09:19:02 +000053def SDT_X86CallSeqStart : SDCallSeqStart<[ SDTCisVT<0, i32> ]>;
54def SDT_X86CallSeqEnd : SDCallSeqEnd<[ SDTCisVT<0, i32>,
55 SDTCisVT<1, i32> ]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +000056
Dan Gohman3329ffe2008-05-29 19:57:41 +000057def SDT_X86Call : SDTypeProfile<0, -1, [SDTCisVT<0, iPTR>]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +000058
59def SDTX86RepStr : SDTypeProfile<0, 1, [SDTCisVT<0, OtherVT>]>;
60
61def SDTX86RdTsc : SDTypeProfile<0, 0, []>;
62
63def SDTX86Wrapper : SDTypeProfile<1, 1, [SDTCisSameAs<0, 1>, SDTCisPtrTy<0>]>;
64
Rafael Espindolaaf759ab2009-04-17 14:35:58 +000065def SDT_X86TLSADDR : SDTypeProfile<0, 1, [SDTCisInt<0>]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +000066
Rafael Espindolabca99f72009-04-08 21:14:34 +000067def SDT_X86SegmentBaseAddress : SDTypeProfile<1, 1, [SDTCisPtrTy<0>]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +000068
69def SDT_X86EHRET : SDTypeProfile<0, 1, [SDTCisInt<0>]>;
70
Arnold Schwaighofere2d6bbb2007-10-11 19:40:01 +000071def SDT_X86TCRET : SDTypeProfile<0, 2, [SDTCisPtrTy<0>, SDTCisVT<1, i32>]>;
72
Evan Cheng48679f42007-12-14 02:13:44 +000073def X86bsf : SDNode<"X86ISD::BSF", SDTIntUnaryOp>;
74def X86bsr : SDNode<"X86ISD::BSR", SDTIntUnaryOp>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +000075def X86shld : SDNode<"X86ISD::SHLD", SDTIntShiftDOp>;
76def X86shrd : SDNode<"X86ISD::SHRD", SDTIntShiftDOp>;
77
Evan Cheng621216e2007-09-29 00:00:36 +000078def X86cmp : SDNode<"X86ISD::CMP" , SDTX86CmpTest>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +000079
Dan Gohman7fe9b7f2008-12-23 22:45:23 +000080def X86bt : SDNode<"X86ISD::BT", SDTX86CmpTest>;
81
Evan Cheng621216e2007-09-29 00:00:36 +000082def X86cmov : SDNode<"X86ISD::CMOV", SDTX86Cmov>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +000083def X86brcond : SDNode<"X86ISD::BRCOND", SDTX86BrCond,
Evan Cheng950aac02007-09-25 01:57:46 +000084 [SDNPHasChain]>;
Evan Cheng621216e2007-09-29 00:00:36 +000085def X86setcc : SDNode<"X86ISD::SETCC", SDTX86SetCC>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +000086
Andrew Lenharth7dfe23f2008-03-01 21:52:34 +000087def X86cas : SDNode<"X86ISD::LCMPXCHG_DAG", SDTX86cas,
88 [SDNPHasChain, SDNPInFlag, SDNPOutFlag, SDNPMayStore,
89 SDNPMayLoad]>;
Andrew Lenharth81580822008-03-05 01:15:49 +000090def X86cas8 : SDNode<"X86ISD::LCMPXCHG8_DAG", SDTX86cas8,
91 [SDNPHasChain, SDNPInFlag, SDNPOutFlag, SDNPMayStore,
92 SDNPMayLoad]>;
Dale Johannesenf160d802008-10-02 18:53:47 +000093def X86AtomAdd64 : SDNode<"X86ISD::ATOMADD64_DAG", SDTX86atomicBinary,
94 [SDNPHasChain, SDNPMayStore,
95 SDNPMayLoad, SDNPMemOperand]>;
96def X86AtomSub64 : SDNode<"X86ISD::ATOMSUB64_DAG", SDTX86atomicBinary,
97 [SDNPHasChain, SDNPMayStore,
98 SDNPMayLoad, SDNPMemOperand]>;
99def X86AtomOr64 : SDNode<"X86ISD::ATOMOR64_DAG", SDTX86atomicBinary,
100 [SDNPHasChain, SDNPMayStore,
101 SDNPMayLoad, SDNPMemOperand]>;
102def X86AtomXor64 : SDNode<"X86ISD::ATOMXOR64_DAG", SDTX86atomicBinary,
103 [SDNPHasChain, SDNPMayStore,
104 SDNPMayLoad, SDNPMemOperand]>;
105def X86AtomAnd64 : SDNode<"X86ISD::ATOMAND64_DAG", SDTX86atomicBinary,
106 [SDNPHasChain, SDNPMayStore,
107 SDNPMayLoad, SDNPMemOperand]>;
108def X86AtomNand64 : SDNode<"X86ISD::ATOMNAND64_DAG", SDTX86atomicBinary,
109 [SDNPHasChain, SDNPMayStore,
110 SDNPMayLoad, SDNPMemOperand]>;
Dale Johannesen51c58ee2008-10-03 22:25:52 +0000111def X86AtomSwap64 : SDNode<"X86ISD::ATOMSWAP64_DAG", SDTX86atomicBinary,
112 [SDNPHasChain, SDNPMayStore,
113 SDNPMayLoad, SDNPMemOperand]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000114def X86retflag : SDNode<"X86ISD::RET_FLAG", SDTX86Ret,
115 [SDNPHasChain, SDNPOptInFlag]>;
116
117def X86callseq_start :
118 SDNode<"ISD::CALLSEQ_START", SDT_X86CallSeqStart,
119 [SDNPHasChain, SDNPOutFlag]>;
120def X86callseq_end :
121 SDNode<"ISD::CALLSEQ_END", SDT_X86CallSeqEnd,
Arnold Schwaighofere2d6bbb2007-10-11 19:40:01 +0000122 [SDNPHasChain, SDNPOptInFlag, SDNPOutFlag]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000123
124def X86call : SDNode<"X86ISD::CALL", SDT_X86Call,
125 [SDNPHasChain, SDNPOutFlag, SDNPOptInFlag]>;
126
127def X86tailcall: SDNode<"X86ISD::TAILCALL", SDT_X86Call,
128 [SDNPHasChain, SDNPOutFlag, SDNPOptInFlag]>;
129
130def X86rep_stos: SDNode<"X86ISD::REP_STOS", SDTX86RepStr,
Chris Lattnerca4e0fe2008-01-10 05:12:37 +0000131 [SDNPHasChain, SDNPInFlag, SDNPOutFlag, SDNPMayStore]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000132def X86rep_movs: SDNode<"X86ISD::REP_MOVS", SDTX86RepStr,
Chris Lattnerca4e0fe2008-01-10 05:12:37 +0000133 [SDNPHasChain, SDNPInFlag, SDNPOutFlag, SDNPMayStore,
134 SDNPMayLoad]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000135
136def X86rdtsc : SDNode<"X86ISD::RDTSC_DAG",SDTX86RdTsc,
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000137 [SDNPHasChain, SDNPOutFlag, SDNPSideEffect]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000138
139def X86Wrapper : SDNode<"X86ISD::Wrapper", SDTX86Wrapper>;
140def X86WrapperRIP : SDNode<"X86ISD::WrapperRIP", SDTX86Wrapper>;
141
142def X86tlsaddr : SDNode<"X86ISD::TLSADDR", SDT_X86TLSADDR,
Anton Korobeynikov4fbf00b2008-05-04 21:36:32 +0000143 [SDNPHasChain, SDNPOptInFlag, SDNPOutFlag]>;
Rafael Espindolabca99f72009-04-08 21:14:34 +0000144def X86SegmentBaseAddress : SDNode<"X86ISD::SegmentBaseAddress",
145 SDT_X86SegmentBaseAddress, []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000146
147def X86ehret : SDNode<"X86ISD::EH_RETURN", SDT_X86EHRET,
148 [SDNPHasChain]>;
149
Arnold Schwaighofere2d6bbb2007-10-11 19:40:01 +0000150def X86tcret : SDNode<"X86ISD::TC_RETURN", SDT_X86TCRET,
151 [SDNPHasChain, SDNPOptInFlag]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000152
Dan Gohman99a12192009-03-04 19:44:21 +0000153def X86add_flag : SDNode<"X86ISD::ADD", SDTBinaryArithWithFlags>;
154def X86sub_flag : SDNode<"X86ISD::SUB", SDTBinaryArithWithFlags>;
155def X86smul_flag : SDNode<"X86ISD::SMUL", SDTBinaryArithWithFlags>;
156def X86umul_flag : SDNode<"X86ISD::UMUL", SDTUnaryArithWithFlags>;
157def X86inc_flag : SDNode<"X86ISD::INC", SDTUnaryArithWithFlags>;
158def X86dec_flag : SDNode<"X86ISD::DEC", SDTUnaryArithWithFlags>;
Bill Wendlingae034ed2008-12-12 00:56:36 +0000159
Evan Chengc3495762009-03-30 21:36:47 +0000160def X86mul_imm : SDNode<"X86ISD::MUL_IMM", SDTIntBinOp>;
161
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000162//===----------------------------------------------------------------------===//
163// X86 Operand Definitions.
164//
165
166// *mem - Operand definitions for the funky X86 addressing mode operands.
167//
168class X86MemOperand<string printMethod> : Operand<iPTR> {
169 let PrintMethod = printMethod;
Rafael Espindolabca99f72009-04-08 21:14:34 +0000170 let MIOperandInfo = (ops ptr_rc, i8imm, ptr_rc, i32imm, i8imm);
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000171}
172
173def i8mem : X86MemOperand<"printi8mem">;
174def i16mem : X86MemOperand<"printi16mem">;
175def i32mem : X86MemOperand<"printi32mem">;
176def i64mem : X86MemOperand<"printi64mem">;
177def i128mem : X86MemOperand<"printi128mem">;
178def f32mem : X86MemOperand<"printf32mem">;
179def f64mem : X86MemOperand<"printf64mem">;
Dale Johannesen4ab00bd2007-08-05 18:49:15 +0000180def f80mem : X86MemOperand<"printf80mem">;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000181def f128mem : X86MemOperand<"printf128mem">;
182
Dan Gohman744d4622009-04-13 16:09:41 +0000183// A version of i8mem for use on x86-64 that uses GR64_NOREX instead of
184// plain GR64, so that it doesn't potentially require a REX prefix.
185def i8mem_NOREX : Operand<i64> {
186 let PrintMethod = "printi8mem";
187 let MIOperandInfo = (ops GR64_NOREX, i8imm, GR64_NOREX, i32imm, i8imm);
188}
189
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000190def lea32mem : Operand<i32> {
Rafael Espindolabca99f72009-04-08 21:14:34 +0000191 let PrintMethod = "printlea32mem";
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000192 let MIOperandInfo = (ops GR32, i8imm, GR32, i32imm);
193}
194
195def SSECC : Operand<i8> {
196 let PrintMethod = "printSSECC";
197}
198
199def piclabel: Operand<i32> {
200 let PrintMethod = "printPICLabel";
201}
202
203// A couple of more descriptive operand definitions.
204// 16-bits but only 8 bits are significant.
205def i16i8imm : Operand<i16>;
206// 32-bits but only 8 bits are significant.
207def i32i8imm : Operand<i32>;
208
209// Branch targets have OtherVT type.
210def brtarget : Operand<OtherVT>;
211
212//===----------------------------------------------------------------------===//
213// X86 Complex Pattern Definitions.
214//
215
216// Define X86 specific addressing mode.
Rafael Espindolabca99f72009-04-08 21:14:34 +0000217def addr : ComplexPattern<iPTR, 5, "SelectAddr", [], []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000218def lea32addr : ComplexPattern<i32, 4, "SelectLEAAddr",
Dan Gohman946223f2009-05-11 18:02:53 +0000219 [add, sub, mul, shl, or, frameindex], []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000220
221//===----------------------------------------------------------------------===//
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000222// X86 Instruction Predicate Definitions.
223def HasMMX : Predicate<"Subtarget->hasMMX()">;
224def HasSSE1 : Predicate<"Subtarget->hasSSE1()">;
225def HasSSE2 : Predicate<"Subtarget->hasSSE2()">;
226def HasSSE3 : Predicate<"Subtarget->hasSSE3()">;
227def HasSSSE3 : Predicate<"Subtarget->hasSSSE3()">;
Nate Begemanb2975562008-02-03 07:18:54 +0000228def HasSSE41 : Predicate<"Subtarget->hasSSE41()">;
229def HasSSE42 : Predicate<"Subtarget->hasSSE42()">;
Dale Johannesene0e0fd02007-09-23 14:52:20 +0000230def FPStackf32 : Predicate<"!Subtarget->hasSSE1()">;
231def FPStackf64 : Predicate<"!Subtarget->hasSSE2()">;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000232def In32BitMode : Predicate<"!Subtarget->is64Bit()">;
233def In64BitMode : Predicate<"Subtarget->is64Bit()">;
234def SmallCode : Predicate<"TM.getCodeModel() == CodeModel::Small">;
235def NotSmallCode : Predicate<"TM.getCodeModel() != CodeModel::Small">;
236def IsStatic : Predicate<"TM.getRelocationModel() == Reloc::Static">;
Evan Cheng13559d62008-09-26 23:41:32 +0000237def OptForSpeed : Predicate<"!OptForSize">;
Evan Cheng95a77fd2009-01-02 05:35:45 +0000238def FastBTMem : Predicate<"!Subtarget->isBTMemSlow()">;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000239
240//===----------------------------------------------------------------------===//
Evan Cheng86ab7d32007-07-31 08:04:03 +0000241// X86 Instruction Format Definitions.
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000242//
243
Evan Cheng86ab7d32007-07-31 08:04:03 +0000244include "X86InstrFormats.td"
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000245
246//===----------------------------------------------------------------------===//
247// Pattern fragments...
248//
249
250// X86 specific condition code. These correspond to CondCode in
251// X86InstrInfo.h. They must be kept in synch.
Dan Gohman0fc9ed62009-01-07 00:15:08 +0000252def X86_COND_A : PatLeaf<(i8 0)>; // alt. COND_NBE
253def X86_COND_AE : PatLeaf<(i8 1)>; // alt. COND_NC
254def X86_COND_B : PatLeaf<(i8 2)>; // alt. COND_C
255def X86_COND_BE : PatLeaf<(i8 3)>; // alt. COND_NA
256def X86_COND_E : PatLeaf<(i8 4)>; // alt. COND_Z
257def X86_COND_G : PatLeaf<(i8 5)>; // alt. COND_NLE
258def X86_COND_GE : PatLeaf<(i8 6)>; // alt. COND_NL
259def X86_COND_L : PatLeaf<(i8 7)>; // alt. COND_NGE
260def X86_COND_LE : PatLeaf<(i8 8)>; // alt. COND_NG
261def X86_COND_NE : PatLeaf<(i8 9)>; // alt. COND_NZ
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000262def X86_COND_NO : PatLeaf<(i8 10)>;
Dan Gohman0fc9ed62009-01-07 00:15:08 +0000263def X86_COND_NP : PatLeaf<(i8 11)>; // alt. COND_PO
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000264def X86_COND_NS : PatLeaf<(i8 12)>;
Dan Gohman0fc9ed62009-01-07 00:15:08 +0000265def X86_COND_O : PatLeaf<(i8 13)>;
266def X86_COND_P : PatLeaf<(i8 14)>; // alt. COND_PE
267def X86_COND_S : PatLeaf<(i8 15)>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000268
269def i16immSExt8 : PatLeaf<(i16 imm), [{
270 // i16immSExt8 predicate - True if the 16-bit immediate fits in a 8-bit
271 // sign extended field.
Dan Gohmanfaeb4a32008-09-12 16:56:44 +0000272 return (int16_t)N->getZExtValue() == (int8_t)N->getZExtValue();
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000273}]>;
274
275def i32immSExt8 : PatLeaf<(i32 imm), [{
276 // i32immSExt8 predicate - True if the 32-bit immediate fits in a 8-bit
277 // sign extended field.
Dan Gohmanfaeb4a32008-09-12 16:56:44 +0000278 return (int32_t)N->getZExtValue() == (int8_t)N->getZExtValue();
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000279}]>;
280
281// Helper fragments for loads.
Evan Chengb3e25ea2008-05-13 18:59:59 +0000282// It's always safe to treat a anyext i16 load as a i32 load if the i16 is
283// known to be 32-bit aligned or better. Ditto for i8 to i16.
Dan Gohman2a174122008-10-15 06:50:19 +0000284def loadi16 : PatFrag<(ops node:$ptr), (i16 (unindexedload node:$ptr)), [{
Dan Gohman8335c412008-08-20 15:24:22 +0000285 LoadSDNode *LD = cast<LoadSDNode>(N);
Chris Lattner12208612009-04-10 00:16:23 +0000286 if (const Value *Src = LD->getSrcValue())
287 if (const PointerType *PT = dyn_cast<PointerType>(Src->getType()))
Mon P Wangdc97d5a2009-04-27 07:22:10 +0000288 if (PT->getAddressSpace() > 255)
Chris Lattner12208612009-04-10 00:16:23 +0000289 return false;
Dan Gohman8335c412008-08-20 15:24:22 +0000290 ISD::LoadExtType ExtType = LD->getExtensionType();
291 if (ExtType == ISD::NON_EXTLOAD)
292 return true;
293 if (ExtType == ISD::EXTLOAD)
294 return LD->getAlignment() >= 2 && !LD->isVolatile();
Evan Cheng8b765e92008-05-13 00:54:02 +0000295 return false;
296}]>;
297
Dan Gohman2a174122008-10-15 06:50:19 +0000298def loadi16_anyext : PatFrag<(ops node:$ptr), (i32 (unindexedload node:$ptr)), [{
Evan Cheng56ec77b2008-09-24 23:27:55 +0000299 LoadSDNode *LD = cast<LoadSDNode>(N);
Chris Lattner12208612009-04-10 00:16:23 +0000300 if (const Value *Src = LD->getSrcValue())
301 if (const PointerType *PT = dyn_cast<PointerType>(Src->getType()))
Mon P Wangdc97d5a2009-04-27 07:22:10 +0000302 if (PT->getAddressSpace() > 255)
Chris Lattner12208612009-04-10 00:16:23 +0000303 return false;
Evan Cheng56ec77b2008-09-24 23:27:55 +0000304 ISD::LoadExtType ExtType = LD->getExtensionType();
305 if (ExtType == ISD::EXTLOAD)
306 return LD->getAlignment() >= 2 && !LD->isVolatile();
307 return false;
308}]>;
309
Dan Gohman2a174122008-10-15 06:50:19 +0000310def loadi32 : PatFrag<(ops node:$ptr), (i32 (unindexedload node:$ptr)), [{
Dan Gohman8335c412008-08-20 15:24:22 +0000311 LoadSDNode *LD = cast<LoadSDNode>(N);
Chris Lattner12208612009-04-10 00:16:23 +0000312 if (const Value *Src = LD->getSrcValue())
313 if (const PointerType *PT = dyn_cast<PointerType>(Src->getType()))
Mon P Wangdc97d5a2009-04-27 07:22:10 +0000314 if (PT->getAddressSpace() > 255)
Chris Lattner12208612009-04-10 00:16:23 +0000315 return false;
Dan Gohman8335c412008-08-20 15:24:22 +0000316 ISD::LoadExtType ExtType = LD->getExtensionType();
317 if (ExtType == ISD::NON_EXTLOAD)
318 return true;
319 if (ExtType == ISD::EXTLOAD)
320 return LD->getAlignment() >= 4 && !LD->isVolatile();
Evan Cheng8b765e92008-05-13 00:54:02 +0000321 return false;
322}]>;
323
Dan Gohman2a174122008-10-15 06:50:19 +0000324def nvloadi32 : PatFrag<(ops node:$ptr), (i32 (unindexedload node:$ptr)), [{
Evan Cheng1e5e5452008-09-29 17:26:18 +0000325 LoadSDNode *LD = cast<LoadSDNode>(N);
Chris Lattner12208612009-04-10 00:16:23 +0000326 if (const Value *Src = LD->getSrcValue())
327 if (const PointerType *PT = dyn_cast<PointerType>(Src->getType()))
Mon P Wangdc97d5a2009-04-27 07:22:10 +0000328 if (PT->getAddressSpace() > 255)
Chris Lattner12208612009-04-10 00:16:23 +0000329 return false;
Evan Cheng1e5e5452008-09-29 17:26:18 +0000330 if (LD->isVolatile())
331 return false;
Evan Cheng1e5e5452008-09-29 17:26:18 +0000332 ISD::LoadExtType ExtType = LD->getExtensionType();
333 if (ExtType == ISD::NON_EXTLOAD)
334 return true;
335 if (ExtType == ISD::EXTLOAD)
336 return LD->getAlignment() >= 4;
337 return false;
338}]>;
339
sampo9cc09a32009-01-26 01:24:32 +0000340def gsload : PatFrag<(ops node:$ptr), (load node:$ptr), [{
Chris Lattner12208612009-04-10 00:16:23 +0000341 if (const Value *Src = cast<LoadSDNode>(N)->getSrcValue())
342 if (const PointerType *PT = dyn_cast<PointerType>(Src->getType()))
343 return PT->getAddressSpace() == 256;
sampo9cc09a32009-01-26 01:24:32 +0000344 return false;
345}]>;
346
Chris Lattnera7c2d8a2009-05-05 18:52:19 +0000347def fsload : PatFrag<(ops node:$ptr), (load node:$ptr), [{
348 if (const Value *Src = cast<LoadSDNode>(N)->getSrcValue())
349 if (const PointerType *PT = dyn_cast<PointerType>(Src->getType()))
350 return PT->getAddressSpace() == 257;
351 return false;
352}]>;
353
Chris Lattner12208612009-04-10 00:16:23 +0000354def loadi8 : PatFrag<(ops node:$ptr), (i8 (load node:$ptr)), [{
355 if (const Value *Src = cast<LoadSDNode>(N)->getSrcValue())
356 if (const PointerType *PT = dyn_cast<PointerType>(Src->getType()))
Mon P Wangdc97d5a2009-04-27 07:22:10 +0000357 if (PT->getAddressSpace() > 255)
Chris Lattner12208612009-04-10 00:16:23 +0000358 return false;
359 return true;
360}]>;
361def loadi64 : PatFrag<(ops node:$ptr), (i64 (load node:$ptr)), [{
362 if (const Value *Src = cast<LoadSDNode>(N)->getSrcValue())
363 if (const PointerType *PT = dyn_cast<PointerType>(Src->getType()))
Mon P Wangdc97d5a2009-04-27 07:22:10 +0000364 if (PT->getAddressSpace() > 255)
Chris Lattner12208612009-04-10 00:16:23 +0000365 return false;
366 return true;
367}]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000368
Chris Lattner12208612009-04-10 00:16:23 +0000369def loadf32 : PatFrag<(ops node:$ptr), (f32 (load node:$ptr)), [{
370 if (const Value *Src = cast<LoadSDNode>(N)->getSrcValue())
371 if (const PointerType *PT = dyn_cast<PointerType>(Src->getType()))
Mon P Wangdc97d5a2009-04-27 07:22:10 +0000372 if (PT->getAddressSpace() > 255)
Chris Lattner12208612009-04-10 00:16:23 +0000373 return false;
374 return true;
375}]>;
376def loadf64 : PatFrag<(ops node:$ptr), (f64 (load node:$ptr)), [{
377 if (const Value *Src = cast<LoadSDNode>(N)->getSrcValue())
378 if (const PointerType *PT = dyn_cast<PointerType>(Src->getType()))
Mon P Wangdc97d5a2009-04-27 07:22:10 +0000379 if (PT->getAddressSpace() > 255)
Chris Lattner12208612009-04-10 00:16:23 +0000380 return false;
381 return true;
382}]>;
383def loadf80 : PatFrag<(ops node:$ptr), (f80 (load node:$ptr)), [{
384 if (const Value *Src = cast<LoadSDNode>(N)->getSrcValue())
385 if (const PointerType *PT = dyn_cast<PointerType>(Src->getType()))
Mon P Wangdc97d5a2009-04-27 07:22:10 +0000386 if (PT->getAddressSpace() > 255)
Chris Lattner12208612009-04-10 00:16:23 +0000387 return false;
388 return true;
389}]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000390
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000391def sextloadi16i8 : PatFrag<(ops node:$ptr), (i16 (sextloadi8 node:$ptr))>;
392def sextloadi32i8 : PatFrag<(ops node:$ptr), (i32 (sextloadi8 node:$ptr))>;
393def sextloadi32i16 : PatFrag<(ops node:$ptr), (i32 (sextloadi16 node:$ptr))>;
394
395def zextloadi8i1 : PatFrag<(ops node:$ptr), (i8 (zextloadi1 node:$ptr))>;
396def zextloadi16i1 : PatFrag<(ops node:$ptr), (i16 (zextloadi1 node:$ptr))>;
397def zextloadi32i1 : PatFrag<(ops node:$ptr), (i32 (zextloadi1 node:$ptr))>;
398def zextloadi16i8 : PatFrag<(ops node:$ptr), (i16 (zextloadi8 node:$ptr))>;
399def zextloadi32i8 : PatFrag<(ops node:$ptr), (i32 (zextloadi8 node:$ptr))>;
400def zextloadi32i16 : PatFrag<(ops node:$ptr), (i32 (zextloadi16 node:$ptr))>;
401
402def extloadi8i1 : PatFrag<(ops node:$ptr), (i8 (extloadi1 node:$ptr))>;
403def extloadi16i1 : PatFrag<(ops node:$ptr), (i16 (extloadi1 node:$ptr))>;
404def extloadi32i1 : PatFrag<(ops node:$ptr), (i32 (extloadi1 node:$ptr))>;
405def extloadi16i8 : PatFrag<(ops node:$ptr), (i16 (extloadi8 node:$ptr))>;
406def extloadi32i8 : PatFrag<(ops node:$ptr), (i32 (extloadi8 node:$ptr))>;
407def extloadi32i16 : PatFrag<(ops node:$ptr), (i32 (extloadi16 node:$ptr))>;
408
Chris Lattner21da6382008-02-19 17:37:35 +0000409
410// An 'and' node with a single use.
411def and_su : PatFrag<(ops node:$lhs, node:$rhs), (and node:$lhs, node:$rhs), [{
Evan Cheng9123cfa2008-03-04 00:40:35 +0000412 return N->hasOneUse();
Chris Lattner21da6382008-02-19 17:37:35 +0000413}]>;
Dan Gohman744d4622009-04-13 16:09:41 +0000414// An 'srl' node with a single use.
415def srl_su : PatFrag<(ops node:$lhs, node:$rhs), (srl node:$lhs, node:$rhs), [{
416 return N->hasOneUse();
417}]>;
418// An 'trunc' node with a single use.
419def trunc_su : PatFrag<(ops node:$src), (trunc node:$src), [{
420 return N->hasOneUse();
421}]>;
Chris Lattner21da6382008-02-19 17:37:35 +0000422
Dan Gohman921581d2008-10-17 01:23:35 +0000423// 'shld' and 'shrd' instruction patterns. Note that even though these have
424// the srl and shl in their patterns, the C++ code must still check for them,
425// because predicates are tested before children nodes are explored.
426
427def shrd : PatFrag<(ops node:$src1, node:$amt1, node:$src2, node:$amt2),
428 (or (srl node:$src1, node:$amt1),
429 (shl node:$src2, node:$amt2)), [{
430 assert(N->getOpcode() == ISD::OR);
431 return N->getOperand(0).getOpcode() == ISD::SRL &&
432 N->getOperand(1).getOpcode() == ISD::SHL &&
433 isa<ConstantSDNode>(N->getOperand(0).getOperand(1)) &&
434 isa<ConstantSDNode>(N->getOperand(1).getOperand(1)) &&
435 N->getOperand(0).getConstantOperandVal(1) ==
436 N->getValueSizeInBits(0) - N->getOperand(1).getConstantOperandVal(1);
437}]>;
438
439def shld : PatFrag<(ops node:$src1, node:$amt1, node:$src2, node:$amt2),
440 (or (shl node:$src1, node:$amt1),
441 (srl node:$src2, node:$amt2)), [{
442 assert(N->getOpcode() == ISD::OR);
443 return N->getOperand(0).getOpcode() == ISD::SHL &&
444 N->getOperand(1).getOpcode() == ISD::SRL &&
445 isa<ConstantSDNode>(N->getOperand(0).getOperand(1)) &&
446 isa<ConstantSDNode>(N->getOperand(1).getOperand(1)) &&
447 N->getOperand(0).getConstantOperandVal(1) ==
448 N->getValueSizeInBits(0) - N->getOperand(1).getConstantOperandVal(1);
449}]>;
450
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000451//===----------------------------------------------------------------------===//
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000452// Instruction list...
453//
454
455// ADJCALLSTACKDOWN/UP implicitly use/def ESP because they may be expanded into
456// a stack adjustment and the codegen must know that they may modify the stack
457// pointer before prolog-epilog rewriting occurs.
Chris Lattnerb56cc342008-03-11 03:23:40 +0000458// Pessimistically assume ADJCALLSTACKDOWN / ADJCALLSTACKUP will become
459// sub / add which can clobber EFLAGS.
Evan Cheng037364a2007-09-28 01:19:48 +0000460let Defs = [ESP, EFLAGS], Uses = [ESP] in {
Dan Gohman01c9f772008-10-01 18:28:06 +0000461def ADJCALLSTACKDOWN32 : I<0, Pseudo, (outs), (ins i32imm:$amt),
462 "#ADJCALLSTACKDOWN",
Chris Lattnerfe5d4022008-10-11 22:08:30 +0000463 [(X86callseq_start timm:$amt)]>,
Dan Gohman01c9f772008-10-01 18:28:06 +0000464 Requires<[In32BitMode]>;
465def ADJCALLSTACKUP32 : I<0, Pseudo, (outs), (ins i32imm:$amt1, i32imm:$amt2),
466 "#ADJCALLSTACKUP",
Chris Lattnerfe5d4022008-10-11 22:08:30 +0000467 [(X86callseq_end timm:$amt1, timm:$amt2)]>,
Dan Gohman01c9f772008-10-01 18:28:06 +0000468 Requires<[In32BitMode]>;
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000469}
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000470
471// Nop
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000472let neverHasSideEffects = 1 in
473 def NOOP : I<0x90, RawFrm, (outs), (ins), "nop", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000474
Evan Cheng0729ccf2008-01-05 00:41:47 +0000475// PIC base
Dan Gohman9499cfe2008-10-01 04:14:30 +0000476let neverHasSideEffects = 1, isNotDuplicable = 1, Uses = [ESP] in
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000477 def MOVPC32r : Ii32<0xE8, Pseudo, (outs GR32:$reg), (ins piclabel:$label),
Dan Gohman70a8a112009-04-27 15:13:28 +0000478 "call\t$label\n\t"
479 "pop{l}\t$reg", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000480
481//===----------------------------------------------------------------------===//
482// Control Flow Instructions...
483//
484
485// Return instructions.
486let isTerminator = 1, isReturn = 1, isBarrier = 1,
Chris Lattnerb56cc342008-03-11 03:23:40 +0000487 hasCtrlDep = 1, FPForm = SpecialFP, FPFormBits = SpecialFP.Value in {
Dan Gohman2c4be2a2008-05-31 02:11:25 +0000488 def RET : I <0xC3, RawFrm, (outs), (ins variable_ops),
Chris Lattnerb56cc342008-03-11 03:23:40 +0000489 "ret",
Dan Gohman2c4be2a2008-05-31 02:11:25 +0000490 [(X86retflag 0)]>;
Chris Lattnerb56cc342008-03-11 03:23:40 +0000491 def RETI : Ii16<0xC2, RawFrm, (outs), (ins i16imm:$amt, variable_ops),
492 "ret\t$amt",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000493 [(X86retflag imm:$amt)]>;
494}
495
496// All branches are RawFrm, Void, Branch, and Terminators
Evan Cheng37e7c752007-07-21 00:34:19 +0000497let isBranch = 1, isTerminator = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +0000498 class IBr<bits<8> opcode, dag ins, string asm, list<dag> pattern> :
499 I<opcode, RawFrm, (outs), ins, asm, pattern>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000500
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000501let isBranch = 1, isBarrier = 1 in
Dan Gohman91888f02007-07-31 20:11:57 +0000502 def JMP : IBr<0xE9, (ins brtarget:$dst), "jmp\t$dst", [(br bb:$dst)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000503
Owen Andersonf8053082007-11-12 07:39:39 +0000504// Indirect branches
505let isBranch = 1, isTerminator = 1, isBarrier = 1, isIndirectBranch = 1 in {
Dan Gohman91888f02007-07-31 20:11:57 +0000506 def JMP32r : I<0xFF, MRM4r, (outs), (ins GR32:$dst), "jmp{l}\t{*}$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000507 [(brind GR32:$dst)]>;
Dan Gohman91888f02007-07-31 20:11:57 +0000508 def JMP32m : I<0xFF, MRM4m, (outs), (ins i32mem:$dst), "jmp{l}\t{*}$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000509 [(brind (loadi32 addr:$dst))]>;
510}
511
512// Conditional branches
Evan Cheng950aac02007-09-25 01:57:46 +0000513let Uses = [EFLAGS] in {
Dan Gohman91888f02007-07-31 20:11:57 +0000514def JE : IBr<0x84, (ins brtarget:$dst), "je\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000515 [(X86brcond bb:$dst, X86_COND_E, EFLAGS)]>, TB;
Dan Gohman91888f02007-07-31 20:11:57 +0000516def JNE : IBr<0x85, (ins brtarget:$dst), "jne\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000517 [(X86brcond bb:$dst, X86_COND_NE, EFLAGS)]>, TB;
Dan Gohman91888f02007-07-31 20:11:57 +0000518def JL : IBr<0x8C, (ins brtarget:$dst), "jl\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000519 [(X86brcond bb:$dst, X86_COND_L, EFLAGS)]>, TB;
Dan Gohman91888f02007-07-31 20:11:57 +0000520def JLE : IBr<0x8E, (ins brtarget:$dst), "jle\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000521 [(X86brcond bb:$dst, X86_COND_LE, EFLAGS)]>, TB;
Dan Gohman91888f02007-07-31 20:11:57 +0000522def JG : IBr<0x8F, (ins brtarget:$dst), "jg\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000523 [(X86brcond bb:$dst, X86_COND_G, EFLAGS)]>, TB;
Dan Gohman91888f02007-07-31 20:11:57 +0000524def JGE : IBr<0x8D, (ins brtarget:$dst), "jge\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000525 [(X86brcond bb:$dst, X86_COND_GE, EFLAGS)]>, TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000526
Dan Gohman91888f02007-07-31 20:11:57 +0000527def JB : IBr<0x82, (ins brtarget:$dst), "jb\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000528 [(X86brcond bb:$dst, X86_COND_B, EFLAGS)]>, TB;
Dan Gohman91888f02007-07-31 20:11:57 +0000529def JBE : IBr<0x86, (ins brtarget:$dst), "jbe\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000530 [(X86brcond bb:$dst, X86_COND_BE, EFLAGS)]>, TB;
Dan Gohman91888f02007-07-31 20:11:57 +0000531def JA : IBr<0x87, (ins brtarget:$dst), "ja\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000532 [(X86brcond bb:$dst, X86_COND_A, EFLAGS)]>, TB;
Dan Gohman91888f02007-07-31 20:11:57 +0000533def JAE : IBr<0x83, (ins brtarget:$dst), "jae\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000534 [(X86brcond bb:$dst, X86_COND_AE, EFLAGS)]>, TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000535
Dan Gohman91888f02007-07-31 20:11:57 +0000536def JS : IBr<0x88, (ins brtarget:$dst), "js\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000537 [(X86brcond bb:$dst, X86_COND_S, EFLAGS)]>, TB;
Dan Gohman91888f02007-07-31 20:11:57 +0000538def JNS : IBr<0x89, (ins brtarget:$dst), "jns\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000539 [(X86brcond bb:$dst, X86_COND_NS, EFLAGS)]>, TB;
Dan Gohman91888f02007-07-31 20:11:57 +0000540def JP : IBr<0x8A, (ins brtarget:$dst), "jp\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000541 [(X86brcond bb:$dst, X86_COND_P, EFLAGS)]>, TB;
Dan Gohman91888f02007-07-31 20:11:57 +0000542def JNP : IBr<0x8B, (ins brtarget:$dst), "jnp\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000543 [(X86brcond bb:$dst, X86_COND_NP, EFLAGS)]>, TB;
Dan Gohman91888f02007-07-31 20:11:57 +0000544def JO : IBr<0x80, (ins brtarget:$dst), "jo\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000545 [(X86brcond bb:$dst, X86_COND_O, EFLAGS)]>, TB;
Dan Gohman91888f02007-07-31 20:11:57 +0000546def JNO : IBr<0x81, (ins brtarget:$dst), "jno\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000547 [(X86brcond bb:$dst, X86_COND_NO, EFLAGS)]>, TB;
Evan Cheng950aac02007-09-25 01:57:46 +0000548} // Uses = [EFLAGS]
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000549
550//===----------------------------------------------------------------------===//
551// Call Instructions...
552//
Evan Cheng37e7c752007-07-21 00:34:19 +0000553let isCall = 1 in
Dan Gohman01c9f772008-10-01 18:28:06 +0000554 // All calls clobber the non-callee saved registers. ESP is marked as
555 // a use to prevent stack-pointer assignments that appear immediately
556 // before calls from potentially appearing dead. Uses for argument
557 // registers are added manually.
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000558 let Defs = [EAX, ECX, EDX, FP0, FP1, FP2, FP3, FP4, FP5, FP6, ST0,
559 MM0, MM1, MM2, MM3, MM4, MM5, MM6, MM7,
Evan Cheng2293b252008-10-17 21:02:22 +0000560 XMM0, XMM1, XMM2, XMM3, XMM4, XMM5, XMM6, XMM7,
561 XMM8, XMM9, XMM10, XMM11, XMM12, XMM13, XMM14, XMM15, EFLAGS],
Dan Gohman9499cfe2008-10-01 04:14:30 +0000562 Uses = [ESP] in {
Evan Cheng34f93712007-12-22 02:26:46 +0000563 def CALLpcrel32 : Ii32<0xE8, RawFrm, (outs), (ins i32imm:$dst,variable_ops),
Evan Cheng0af5a042009-03-12 18:15:39 +0000564 "call\t${dst:call}", [(X86call imm:$dst)]>,
565 Requires<[In32BitMode]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000566 def CALL32r : I<0xFF, MRM2r, (outs), (ins GR32:$dst, variable_ops),
Dan Gohman91888f02007-07-31 20:11:57 +0000567 "call\t{*}$dst", [(X86call GR32:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000568 def CALL32m : I<0xFF, MRM2m, (outs), (ins i32mem:$dst, variable_ops),
Dan Gohmanea4faba2008-05-29 21:50:34 +0000569 "call\t{*}$dst", [(X86call (loadi32 addr:$dst))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000570 }
571
572// Tail call stuff.
Arnold Schwaighofere2d6bbb2007-10-11 19:40:01 +0000573
Chris Lattnerb56cc342008-03-11 03:23:40 +0000574def TAILCALL : I<0, Pseudo, (outs), (ins),
Arnold Schwaighofere2d6bbb2007-10-11 19:40:01 +0000575 "#TAILCALL",
576 []>;
577
Evan Cheng37e7c752007-07-21 00:34:19 +0000578let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1 in
Arnold Schwaighofer6fd37ac2008-03-19 16:39:45 +0000579def TCRETURNdi : I<0, Pseudo, (outs), (ins i32imm:$dst, i32imm:$offset, variable_ops),
Arnold Schwaighofere2d6bbb2007-10-11 19:40:01 +0000580 "#TC_RETURN $dst $offset",
581 []>;
582
583let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1 in
Arnold Schwaighofer6fd37ac2008-03-19 16:39:45 +0000584def TCRETURNri : I<0, Pseudo, (outs), (ins GR32:$dst, i32imm:$offset, variable_ops),
Arnold Schwaighofere2d6bbb2007-10-11 19:40:01 +0000585 "#TC_RETURN $dst $offset",
586 []>;
587
588let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1 in
Arnold Schwaighofera0032722008-04-30 09:16:33 +0000589
Arnold Schwaighofere2d6bbb2007-10-11 19:40:01 +0000590 def TAILJMPd : IBr<0xE9, (ins i32imm:$dst), "jmp\t${dst:call} # TAILCALL",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000591 []>;
Evan Cheng37e7c752007-07-21 00:34:19 +0000592let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1 in
Arnold Schwaighofere2d6bbb2007-10-11 19:40:01 +0000593 def TAILJMPr : I<0xFF, MRM4r, (outs), (ins GR32:$dst), "jmp{l}\t{*}$dst # TAILCALL",
594 []>;
Evan Cheng37e7c752007-07-21 00:34:19 +0000595let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +0000596 def TAILJMPm : I<0xFF, MRM4m, (outs), (ins i32mem:$dst),
Arnold Schwaighofere2d6bbb2007-10-11 19:40:01 +0000597 "jmp\t{*}$dst # TAILCALL", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000598
599//===----------------------------------------------------------------------===//
600// Miscellaneous Instructions...
601//
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000602let Defs = [EBP, ESP], Uses = [EBP, ESP], mayLoad = 1, neverHasSideEffects=1 in
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000603def LEAVE : I<0xC9, RawFrm,
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000604 (outs), (ins), "leave", []>;
605
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000606let Defs = [ESP], Uses = [ESP], neverHasSideEffects=1 in {
607let mayLoad = 1 in
Evan Chengd8434332007-09-26 01:29:06 +0000608def POP32r : I<0x58, AddRegFrm, (outs GR32:$reg), (ins), "pop{l}\t$reg", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000609
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000610let mayStore = 1 in
Evan Chengd8434332007-09-26 01:29:06 +0000611def PUSH32r : I<0x50, AddRegFrm, (outs), (ins GR32:$reg), "push{l}\t$reg",[]>;
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000612}
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000613
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000614let Defs = [ESP, EFLAGS], Uses = [ESP], mayLoad = 1, neverHasSideEffects=1 in
Evan Chengf1341312007-09-26 21:28:00 +0000615def POPFD : I<0x9D, RawFrm, (outs), (ins), "popf", []>;
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000616let Defs = [ESP], Uses = [ESP, EFLAGS], mayStore = 1, neverHasSideEffects=1 in
Evan Chengf1341312007-09-26 21:28:00 +0000617def PUSHFD : I<0x9C, RawFrm, (outs), (ins), "pushf", []>;
Evan Chengd8434332007-09-26 01:29:06 +0000618
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000619let isTwoAddress = 1 in // GR32 = bswap GR32
620 def BSWAP32r : I<0xC8, AddRegFrm,
Evan Chengb783fa32007-07-19 01:14:50 +0000621 (outs GR32:$dst), (ins GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000622 "bswap{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000623 [(set GR32:$dst, (bswap GR32:$src))]>, TB;
624
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000625
Evan Cheng48679f42007-12-14 02:13:44 +0000626// Bit scan instructions.
627let Defs = [EFLAGS] in {
Evan Cheng4e33de92007-12-14 18:49:43 +0000628def BSF16rr : I<0xBC, MRMSrcReg, (outs GR16:$dst), (ins GR16:$src),
Dan Gohmancdb54c62007-12-14 15:10:00 +0000629 "bsf{w}\t{$src, $dst|$dst, $src}",
Evan Cheng7cfbfe32007-12-14 08:30:15 +0000630 [(set GR16:$dst, (X86bsf GR16:$src)), (implicit EFLAGS)]>, TB;
Evan Cheng48679f42007-12-14 02:13:44 +0000631def BSF16rm : I<0xBC, MRMSrcMem, (outs GR16:$dst), (ins i16mem:$src),
Dan Gohmancdb54c62007-12-14 15:10:00 +0000632 "bsf{w}\t{$src, $dst|$dst, $src}",
Evan Cheng7cfbfe32007-12-14 08:30:15 +0000633 [(set GR16:$dst, (X86bsf (loadi16 addr:$src))),
634 (implicit EFLAGS)]>, TB;
Evan Cheng4e33de92007-12-14 18:49:43 +0000635def BSF32rr : I<0xBC, MRMSrcReg, (outs GR32:$dst), (ins GR32:$src),
Dan Gohmancdb54c62007-12-14 15:10:00 +0000636 "bsf{l}\t{$src, $dst|$dst, $src}",
Evan Cheng7cfbfe32007-12-14 08:30:15 +0000637 [(set GR32:$dst, (X86bsf GR32:$src)), (implicit EFLAGS)]>, TB;
Evan Cheng48679f42007-12-14 02:13:44 +0000638def BSF32rm : I<0xBC, MRMSrcMem, (outs GR32:$dst), (ins i32mem:$src),
Dan Gohmancdb54c62007-12-14 15:10:00 +0000639 "bsf{l}\t{$src, $dst|$dst, $src}",
Evan Cheng7cfbfe32007-12-14 08:30:15 +0000640 [(set GR32:$dst, (X86bsf (loadi32 addr:$src))),
641 (implicit EFLAGS)]>, TB;
Evan Cheng48679f42007-12-14 02:13:44 +0000642
Evan Cheng4e33de92007-12-14 18:49:43 +0000643def BSR16rr : I<0xBD, MRMSrcReg, (outs GR16:$dst), (ins GR16:$src),
Dan Gohmancdb54c62007-12-14 15:10:00 +0000644 "bsr{w}\t{$src, $dst|$dst, $src}",
Evan Cheng7cfbfe32007-12-14 08:30:15 +0000645 [(set GR16:$dst, (X86bsr GR16:$src)), (implicit EFLAGS)]>, TB;
Evan Cheng48679f42007-12-14 02:13:44 +0000646def BSR16rm : I<0xBD, MRMSrcMem, (outs GR16:$dst), (ins i16mem:$src),
Dan Gohmancdb54c62007-12-14 15:10:00 +0000647 "bsr{w}\t{$src, $dst|$dst, $src}",
Evan Cheng7cfbfe32007-12-14 08:30:15 +0000648 [(set GR16:$dst, (X86bsr (loadi16 addr:$src))),
649 (implicit EFLAGS)]>, TB;
Evan Cheng4e33de92007-12-14 18:49:43 +0000650def BSR32rr : I<0xBD, MRMSrcReg, (outs GR32:$dst), (ins GR32:$src),
Dan Gohmancdb54c62007-12-14 15:10:00 +0000651 "bsr{l}\t{$src, $dst|$dst, $src}",
Evan Cheng7cfbfe32007-12-14 08:30:15 +0000652 [(set GR32:$dst, (X86bsr GR32:$src)), (implicit EFLAGS)]>, TB;
Evan Cheng48679f42007-12-14 02:13:44 +0000653def BSR32rm : I<0xBD, MRMSrcMem, (outs GR32:$dst), (ins i32mem:$src),
Dan Gohmancdb54c62007-12-14 15:10:00 +0000654 "bsr{l}\t{$src, $dst|$dst, $src}",
Evan Cheng7cfbfe32007-12-14 08:30:15 +0000655 [(set GR32:$dst, (X86bsr (loadi32 addr:$src))),
656 (implicit EFLAGS)]>, TB;
Evan Cheng48679f42007-12-14 02:13:44 +0000657} // Defs = [EFLAGS]
658
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000659let neverHasSideEffects = 1 in
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000660def LEA16r : I<0x8D, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +0000661 (outs GR16:$dst), (ins i32mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000662 "lea{w}\t{$src|$dst}, {$dst|$src}", []>, OpSize;
Evan Cheng1ea8e6b2008-03-27 01:41:09 +0000663let isReMaterializable = 1 in
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000664def LEA32r : I<0x8D, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +0000665 (outs GR32:$dst), (ins lea32mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000666 "lea{l}\t{$src|$dst}, {$dst|$src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000667 [(set GR32:$dst, lea32addr:$src)]>, Requires<[In32BitMode]>;
668
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000669let Defs = [ECX,EDI,ESI], Uses = [ECX,EDI,ESI] in {
Evan Chengb783fa32007-07-19 01:14:50 +0000670def REP_MOVSB : I<0xA4, RawFrm, (outs), (ins), "{rep;movsb|rep movsb}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000671 [(X86rep_movs i8)]>, REP;
Evan Chengb783fa32007-07-19 01:14:50 +0000672def REP_MOVSW : I<0xA5, RawFrm, (outs), (ins), "{rep;movsw|rep movsw}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000673 [(X86rep_movs i16)]>, REP, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +0000674def REP_MOVSD : I<0xA5, RawFrm, (outs), (ins), "{rep;movsl|rep movsd}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000675 [(X86rep_movs i32)]>, REP;
676}
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000677
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000678let Defs = [ECX,EDI], Uses = [AL,ECX,EDI] in
Evan Chengb783fa32007-07-19 01:14:50 +0000679def REP_STOSB : I<0xAA, RawFrm, (outs), (ins), "{rep;stosb|rep stosb}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000680 [(X86rep_stos i8)]>, REP;
681let Defs = [ECX,EDI], Uses = [AX,ECX,EDI] in
Evan Chengb783fa32007-07-19 01:14:50 +0000682def REP_STOSW : I<0xAB, RawFrm, (outs), (ins), "{rep;stosw|rep stosw}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000683 [(X86rep_stos i16)]>, REP, OpSize;
684let Defs = [ECX,EDI], Uses = [EAX,ECX,EDI] in
Evan Chengb783fa32007-07-19 01:14:50 +0000685def REP_STOSD : I<0xAB, RawFrm, (outs), (ins), "{rep;stosl|rep stosd}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000686 [(X86rep_stos i32)]>, REP;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000687
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000688let Defs = [RAX, RDX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000689def RDTSC : I<0x31, RawFrm, (outs), (ins), "rdtsc", [(X86rdtsc)]>,
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000690 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000691
Anton Korobeynikov39d40ba2008-01-15 07:02:33 +0000692let isBarrier = 1, hasCtrlDep = 1 in {
Chris Lattner56b941f2008-01-15 21:58:22 +0000693def TRAP : I<0x0B, RawFrm, (outs), (ins), "ud2", [(trap)]>, TB;
Anton Korobeynikov39d40ba2008-01-15 07:02:33 +0000694}
695
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000696//===----------------------------------------------------------------------===//
697// Input/Output Instructions...
698//
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000699let Defs = [AL], Uses = [DX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000700def IN8rr : I<0xEC, RawFrm, (outs), (ins),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000701 "in{b}\t{%dx, %al|%AL, %DX}", []>;
702let Defs = [AX], Uses = [DX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000703def IN16rr : I<0xED, RawFrm, (outs), (ins),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000704 "in{w}\t{%dx, %ax|%AX, %DX}", []>, OpSize;
705let Defs = [EAX], Uses = [DX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000706def IN32rr : I<0xED, RawFrm, (outs), (ins),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000707 "in{l}\t{%dx, %eax|%EAX, %DX}", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000708
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000709let Defs = [AL] in
Evan Chengb783fa32007-07-19 01:14:50 +0000710def IN8ri : Ii8<0xE4, RawFrm, (outs), (ins i16i8imm:$port),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000711 "in{b}\t{$port, %al|%AL, $port}", []>;
712let Defs = [AX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000713def IN16ri : Ii8<0xE5, RawFrm, (outs), (ins i16i8imm:$port),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000714 "in{w}\t{$port, %ax|%AX, $port}", []>, OpSize;
715let Defs = [EAX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000716def IN32ri : Ii8<0xE5, RawFrm, (outs), (ins i16i8imm:$port),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000717 "in{l}\t{$port, %eax|%EAX, $port}", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000718
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000719let Uses = [DX, AL] in
Evan Chengb783fa32007-07-19 01:14:50 +0000720def OUT8rr : I<0xEE, RawFrm, (outs), (ins),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000721 "out{b}\t{%al, %dx|%DX, %AL}", []>;
722let Uses = [DX, AX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000723def OUT16rr : I<0xEF, RawFrm, (outs), (ins),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000724 "out{w}\t{%ax, %dx|%DX, %AX}", []>, OpSize;
725let Uses = [DX, EAX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000726def OUT32rr : I<0xEF, RawFrm, (outs), (ins),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000727 "out{l}\t{%eax, %dx|%DX, %EAX}", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000728
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000729let Uses = [AL] in
Evan Chengb783fa32007-07-19 01:14:50 +0000730def OUT8ir : Ii8<0xE6, RawFrm, (outs), (ins i16i8imm:$port),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000731 "out{b}\t{%al, $port|$port, %AL}", []>;
732let Uses = [AX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000733def OUT16ir : Ii8<0xE7, RawFrm, (outs), (ins i16i8imm:$port),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000734 "out{w}\t{%ax, $port|$port, %AX}", []>, OpSize;
735let Uses = [EAX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000736def OUT32ir : Ii8<0xE7, RawFrm, (outs), (ins i16i8imm:$port),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000737 "out{l}\t{%eax, $port|$port, %EAX}", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000738
739//===----------------------------------------------------------------------===//
740// Move Instructions...
741//
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000742let neverHasSideEffects = 1 in {
Evan Chengb783fa32007-07-19 01:14:50 +0000743def MOV8rr : I<0x88, MRMDestReg, (outs GR8 :$dst), (ins GR8 :$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000744 "mov{b}\t{$src, $dst|$dst, $src}", []>;
Evan Chengb783fa32007-07-19 01:14:50 +0000745def MOV16rr : I<0x89, MRMDestReg, (outs GR16:$dst), (ins GR16:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000746 "mov{w}\t{$src, $dst|$dst, $src}", []>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +0000747def MOV32rr : I<0x89, MRMDestReg, (outs GR32:$dst), (ins GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000748 "mov{l}\t{$src, $dst|$dst, $src}", []>;
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000749}
Evan Cheng6f26e8b2008-06-18 08:13:07 +0000750let isReMaterializable = 1, isAsCheapAsAMove = 1 in {
Evan Chengb783fa32007-07-19 01:14:50 +0000751def MOV8ri : Ii8 <0xB0, AddRegFrm, (outs GR8 :$dst), (ins i8imm :$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000752 "mov{b}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000753 [(set GR8:$dst, imm:$src)]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000754def MOV16ri : Ii16<0xB8, AddRegFrm, (outs GR16:$dst), (ins i16imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000755 "mov{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000756 [(set GR16:$dst, imm:$src)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +0000757def MOV32ri : Ii32<0xB8, AddRegFrm, (outs GR32:$dst), (ins i32imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000758 "mov{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000759 [(set GR32:$dst, imm:$src)]>;
760}
Evan Chengb783fa32007-07-19 01:14:50 +0000761def MOV8mi : Ii8 <0xC6, MRM0m, (outs), (ins i8mem :$dst, i8imm :$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000762 "mov{b}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000763 [(store (i8 imm:$src), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000764def MOV16mi : Ii16<0xC7, MRM0m, (outs), (ins i16mem:$dst, i16imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000765 "mov{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000766 [(store (i16 imm:$src), addr:$dst)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +0000767def MOV32mi : Ii32<0xC7, MRM0m, (outs), (ins i32mem:$dst, i32imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000768 "mov{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000769 [(store (i32 imm:$src), addr:$dst)]>;
770
Dan Gohman5574cc72008-12-03 18:15:48 +0000771let canFoldAsLoad = 1, isReMaterializable = 1, mayHaveSideEffects = 1 in {
Evan Chengb783fa32007-07-19 01:14:50 +0000772def MOV8rm : I<0x8A, MRMSrcMem, (outs GR8 :$dst), (ins i8mem :$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000773 "mov{b}\t{$src, $dst|$dst, $src}",
Chris Lattner12208612009-04-10 00:16:23 +0000774 [(set GR8:$dst, (loadi8 addr:$src))]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000775def MOV16rm : I<0x8B, MRMSrcMem, (outs GR16:$dst), (ins i16mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000776 "mov{w}\t{$src, $dst|$dst, $src}",
Chris Lattner12208612009-04-10 00:16:23 +0000777 [(set GR16:$dst, (loadi16 addr:$src))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +0000778def MOV32rm : I<0x8B, MRMSrcMem, (outs GR32:$dst), (ins i32mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000779 "mov{l}\t{$src, $dst|$dst, $src}",
Chris Lattner12208612009-04-10 00:16:23 +0000780 [(set GR32:$dst, (loadi32 addr:$src))]>;
Evan Cheng4e84e452007-08-30 05:49:43 +0000781}
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000782
Evan Chengb783fa32007-07-19 01:14:50 +0000783def MOV8mr : I<0x88, MRMDestMem, (outs), (ins i8mem :$dst, GR8 :$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000784 "mov{b}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000785 [(store GR8:$src, addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000786def MOV16mr : I<0x89, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000787 "mov{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000788 [(store GR16:$src, addr:$dst)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +0000789def MOV32mr : I<0x89, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000790 "mov{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000791 [(store GR32:$src, addr:$dst)]>;
Dan Gohman744d4622009-04-13 16:09:41 +0000792
Dan Gohman1d8ce9c2009-04-27 16:41:36 +0000793// Versions of MOV8rr, MOV8mr, and MOV8rm that use i8mem_NOREX and GR8_NOREX so
794// that they can be used for copying and storing h registers, which can't be
795// encoded when a REX prefix is present.
Dan Gohman2da0db32009-04-15 00:04:23 +0000796let neverHasSideEffects = 1 in
Dan Gohman40ddc362009-04-15 19:48:57 +0000797def MOV8rr_NOREX : I<0x88, MRMDestReg,
798 (outs GR8_NOREX:$dst), (ins GR8_NOREX:$src),
Dan Gohman2da0db32009-04-15 00:04:23 +0000799 "mov{b}\t{$src, $dst|$dst, $src} # NOREX", []>;
Evan Chengebc49402009-04-30 00:58:57 +0000800let mayStore = 1 in
Dan Gohman2da0db32009-04-15 00:04:23 +0000801def MOV8mr_NOREX : I<0x88, MRMDestMem,
802 (outs), (ins i8mem_NOREX:$dst, GR8_NOREX:$src),
803 "mov{b}\t{$src, $dst|$dst, $src} # NOREX", []>;
Evan Chengebc49402009-04-30 00:58:57 +0000804let mayLoad = 1,
805 canFoldAsLoad = 1, isReMaterializable = 1, mayHaveSideEffects = 1 in
Dan Gohman1d8ce9c2009-04-27 16:41:36 +0000806def MOV8rm_NOREX : I<0x8A, MRMSrcMem,
807 (outs GR8_NOREX:$dst), (ins i8mem_NOREX:$src),
808 "mov{b}\t{$src, $dst|$dst, $src} # NOREX", []>;
Dan Gohman744d4622009-04-13 16:09:41 +0000809
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000810//===----------------------------------------------------------------------===//
811// Fixed-Register Multiplication and Division Instructions...
812//
813
814// Extra precision multiplication
Evan Cheng55687072007-09-14 21:48:26 +0000815let Defs = [AL,AH,EFLAGS], Uses = [AL] in
Dan Gohman91888f02007-07-31 20:11:57 +0000816def MUL8r : I<0xF6, MRM4r, (outs), (ins GR8:$src), "mul{b}\t$src",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000817 // FIXME: Used for 8-bit mul, ignore result upper 8 bits.
818 // This probably ought to be moved to a def : Pat<> if the
819 // syntax can be accepted.
Bill Wendlingf5399032008-12-12 21:15:41 +0000820 [(set AL, (mul AL, GR8:$src)),
821 (implicit EFLAGS)]>; // AL,AH = AL*GR8
822
Chris Lattnerc7e96e72008-01-11 07:18:17 +0000823let Defs = [AX,DX,EFLAGS], Uses = [AX], neverHasSideEffects = 1 in
Bill Wendlingf5399032008-12-12 21:15:41 +0000824def MUL16r : I<0xF7, MRM4r, (outs), (ins GR16:$src),
825 "mul{w}\t$src",
826 []>, OpSize; // AX,DX = AX*GR16
827
Chris Lattnerc7e96e72008-01-11 07:18:17 +0000828let Defs = [EAX,EDX,EFLAGS], Uses = [EAX], neverHasSideEffects = 1 in
Bill Wendlingf5399032008-12-12 21:15:41 +0000829def MUL32r : I<0xF7, MRM4r, (outs), (ins GR32:$src),
830 "mul{l}\t$src",
831 []>; // EAX,EDX = EAX*GR32
832
Evan Cheng55687072007-09-14 21:48:26 +0000833let Defs = [AL,AH,EFLAGS], Uses = [AL] in
Evan Chengb783fa32007-07-19 01:14:50 +0000834def MUL8m : I<0xF6, MRM4m, (outs), (ins i8mem :$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000835 "mul{b}\t$src",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000836 // FIXME: Used for 8-bit mul, ignore result upper 8 bits.
837 // This probably ought to be moved to a def : Pat<> if the
838 // syntax can be accepted.
Bill Wendlingf5399032008-12-12 21:15:41 +0000839 [(set AL, (mul AL, (loadi8 addr:$src))),
840 (implicit EFLAGS)]>; // AL,AH = AL*[mem8]
841
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000842let mayLoad = 1, neverHasSideEffects = 1 in {
Evan Cheng55687072007-09-14 21:48:26 +0000843let Defs = [AX,DX,EFLAGS], Uses = [AX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000844def MUL16m : I<0xF7, MRM4m, (outs), (ins i16mem:$src),
Bill Wendlingf5399032008-12-12 21:15:41 +0000845 "mul{w}\t$src",
846 []>, OpSize; // AX,DX = AX*[mem16]
847
Evan Cheng55687072007-09-14 21:48:26 +0000848let Defs = [EAX,EDX,EFLAGS], Uses = [EAX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000849def MUL32m : I<0xF7, MRM4m, (outs), (ins i32mem:$src),
Bill Wendlingf5399032008-12-12 21:15:41 +0000850 "mul{l}\t$src",
851 []>; // EAX,EDX = EAX*[mem32]
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000852}
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000853
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000854let neverHasSideEffects = 1 in {
Evan Cheng55687072007-09-14 21:48:26 +0000855let Defs = [AL,AH,EFLAGS], Uses = [AL] in
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000856def IMUL8r : I<0xF6, MRM5r, (outs), (ins GR8:$src), "imul{b}\t$src", []>;
857 // AL,AH = AL*GR8
Evan Cheng55687072007-09-14 21:48:26 +0000858let Defs = [AX,DX,EFLAGS], Uses = [AX] in
Dan Gohman91888f02007-07-31 20:11:57 +0000859def IMUL16r : I<0xF7, MRM5r, (outs), (ins GR16:$src), "imul{w}\t$src", []>,
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000860 OpSize; // AX,DX = AX*GR16
Evan Cheng55687072007-09-14 21:48:26 +0000861let Defs = [EAX,EDX,EFLAGS], Uses = [EAX] in
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000862def IMUL32r : I<0xF7, MRM5r, (outs), (ins GR32:$src), "imul{l}\t$src", []>;
863 // EAX,EDX = EAX*GR32
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000864let mayLoad = 1 in {
Evan Cheng55687072007-09-14 21:48:26 +0000865let Defs = [AL,AH,EFLAGS], Uses = [AL] in
Evan Chengb783fa32007-07-19 01:14:50 +0000866def IMUL8m : I<0xF6, MRM5m, (outs), (ins i8mem :$src),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000867 "imul{b}\t$src", []>; // AL,AH = AL*[mem8]
Evan Cheng55687072007-09-14 21:48:26 +0000868let Defs = [AX,DX,EFLAGS], Uses = [AX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000869def IMUL16m : I<0xF7, MRM5m, (outs), (ins i16mem:$src),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000870 "imul{w}\t$src", []>, OpSize; // AX,DX = AX*[mem16]
871let Defs = [EAX,EDX], Uses = [EAX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000872def IMUL32m : I<0xF7, MRM5m, (outs), (ins i32mem:$src),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000873 "imul{l}\t$src", []>; // EAX,EDX = EAX*[mem32]
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000874}
Dan Gohmand44572d2008-11-18 21:29:14 +0000875} // neverHasSideEffects
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000876
877// unsigned division/remainder
Dale Johannesend8fd3562008-10-07 18:54:28 +0000878let Defs = [AL,AH,EFLAGS], Uses = [AX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000879def DIV8r : I<0xF6, MRM6r, (outs), (ins GR8:$src), // AX/r8 = AL,AH
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000880 "div{b}\t$src", []>;
Evan Cheng55687072007-09-14 21:48:26 +0000881let Defs = [AX,DX,EFLAGS], Uses = [AX,DX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000882def DIV16r : I<0xF7, MRM6r, (outs), (ins GR16:$src), // DX:AX/r16 = AX,DX
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000883 "div{w}\t$src", []>, OpSize;
Evan Cheng55687072007-09-14 21:48:26 +0000884let Defs = [EAX,EDX,EFLAGS], Uses = [EAX,EDX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000885def DIV32r : I<0xF7, MRM6r, (outs), (ins GR32:$src), // EDX:EAX/r32 = EAX,EDX
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000886 "div{l}\t$src", []>;
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000887let mayLoad = 1 in {
Dale Johannesend8fd3562008-10-07 18:54:28 +0000888let Defs = [AL,AH,EFLAGS], Uses = [AX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000889def DIV8m : I<0xF6, MRM6m, (outs), (ins i8mem:$src), // AX/[mem8] = AL,AH
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000890 "div{b}\t$src", []>;
Evan Cheng55687072007-09-14 21:48:26 +0000891let Defs = [AX,DX,EFLAGS], Uses = [AX,DX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000892def DIV16m : I<0xF7, MRM6m, (outs), (ins i16mem:$src), // DX:AX/[mem16] = AX,DX
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000893 "div{w}\t$src", []>, OpSize;
Evan Cheng55687072007-09-14 21:48:26 +0000894let Defs = [EAX,EDX,EFLAGS], Uses = [EAX,EDX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000895def DIV32m : I<0xF7, MRM6m, (outs), (ins i32mem:$src), // EDX:EAX/[mem32] = EAX,EDX
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000896 "div{l}\t$src", []>;
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000897}
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000898
899// Signed division/remainder.
Dale Johannesend8fd3562008-10-07 18:54:28 +0000900let Defs = [AL,AH,EFLAGS], Uses = [AX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000901def IDIV8r : I<0xF6, MRM7r, (outs), (ins GR8:$src), // AX/r8 = AL,AH
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000902 "idiv{b}\t$src", []>;
Evan Cheng55687072007-09-14 21:48:26 +0000903let Defs = [AX,DX,EFLAGS], Uses = [AX,DX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000904def IDIV16r: I<0xF7, MRM7r, (outs), (ins GR16:$src), // DX:AX/r16 = AX,DX
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000905 "idiv{w}\t$src", []>, OpSize;
Evan Cheng55687072007-09-14 21:48:26 +0000906let Defs = [EAX,EDX,EFLAGS], Uses = [EAX,EDX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000907def IDIV32r: I<0xF7, MRM7r, (outs), (ins GR32:$src), // EDX:EAX/r32 = EAX,EDX
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000908 "idiv{l}\t$src", []>;
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000909let mayLoad = 1, mayLoad = 1 in {
Dale Johannesend8fd3562008-10-07 18:54:28 +0000910let Defs = [AL,AH,EFLAGS], Uses = [AX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000911def IDIV8m : I<0xF6, MRM7m, (outs), (ins i8mem:$src), // AX/[mem8] = AL,AH
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000912 "idiv{b}\t$src", []>;
Evan Cheng55687072007-09-14 21:48:26 +0000913let Defs = [AX,DX,EFLAGS], Uses = [AX,DX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000914def IDIV16m: I<0xF7, MRM7m, (outs), (ins i16mem:$src), // DX:AX/[mem16] = AX,DX
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000915 "idiv{w}\t$src", []>, OpSize;
Evan Cheng55687072007-09-14 21:48:26 +0000916let Defs = [EAX,EDX,EFLAGS], Uses = [EAX,EDX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000917def IDIV32m: I<0xF7, MRM7m, (outs), (ins i32mem:$src), // EDX:EAX/[mem32] = EAX,EDX
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000918 "idiv{l}\t$src", []>;
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000919}
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000920
921//===----------------------------------------------------------------------===//
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000922// Two address Instructions.
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000923//
924let isTwoAddress = 1 in {
925
926// Conditional moves
Evan Cheng950aac02007-09-25 01:57:46 +0000927let Uses = [EFLAGS] in {
Evan Cheng926658c2007-10-05 23:13:21 +0000928let isCommutable = 1 in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000929def CMOVB16rr : I<0x42, MRMSrcReg, // if <u, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +0000930 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000931 "cmovb\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000932 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000933 X86_COND_B, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000934 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000935def CMOVB32rr : I<0x42, MRMSrcReg, // if <u, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +0000936 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000937 "cmovb\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000938 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000939 X86_COND_B, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000940 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000941def CMOVAE16rr: I<0x43, MRMSrcReg, // if >=u, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +0000942 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000943 "cmovae\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000944 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000945 X86_COND_AE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000946 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000947def CMOVAE32rr: I<0x43, MRMSrcReg, // if >=u, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +0000948 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000949 "cmovae\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000950 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000951 X86_COND_AE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000952 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000953def CMOVE16rr : I<0x44, MRMSrcReg, // if ==, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +0000954 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000955 "cmove\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000956 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000957 X86_COND_E, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000958 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000959def CMOVE32rr : I<0x44, MRMSrcReg, // if ==, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +0000960 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000961 "cmove\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000962 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000963 X86_COND_E, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000964 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000965def CMOVNE16rr: I<0x45, MRMSrcReg, // if !=, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +0000966 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000967 "cmovne\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000968 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000969 X86_COND_NE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000970 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000971def CMOVNE32rr: I<0x45, MRMSrcReg, // if !=, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +0000972 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000973 "cmovne\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000974 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000975 X86_COND_NE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000976 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000977def CMOVBE16rr: I<0x46, MRMSrcReg, // if <=u, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +0000978 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000979 "cmovbe\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000980 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000981 X86_COND_BE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000982 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000983def CMOVBE32rr: I<0x46, MRMSrcReg, // if <=u, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +0000984 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000985 "cmovbe\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000986 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000987 X86_COND_BE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000988 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000989def CMOVA16rr : I<0x47, MRMSrcReg, // if >u, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +0000990 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000991 "cmova\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000992 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000993 X86_COND_A, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000994 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000995def CMOVA32rr : I<0x47, MRMSrcReg, // if >u, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +0000996 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000997 "cmova\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000998 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000999 X86_COND_A, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001000 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001001def CMOVL16rr : I<0x4C, MRMSrcReg, // if <s, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +00001002 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001003 "cmovl\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001004 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001005 X86_COND_L, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001006 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001007def CMOVL32rr : I<0x4C, MRMSrcReg, // if <s, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +00001008 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001009 "cmovl\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001010 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001011 X86_COND_L, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001012 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001013def CMOVGE16rr: I<0x4D, MRMSrcReg, // if >=s, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +00001014 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001015 "cmovge\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001016 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001017 X86_COND_GE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001018 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001019def CMOVGE32rr: I<0x4D, MRMSrcReg, // if >=s, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +00001020 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001021 "cmovge\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001022 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001023 X86_COND_GE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001024 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001025def CMOVLE16rr: I<0x4E, MRMSrcReg, // if <=s, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +00001026 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001027 "cmovle\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001028 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001029 X86_COND_LE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001030 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001031def CMOVLE32rr: I<0x4E, MRMSrcReg, // if <=s, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +00001032 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001033 "cmovle\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001034 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001035 X86_COND_LE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001036 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001037def CMOVG16rr : I<0x4F, MRMSrcReg, // if >s, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +00001038 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001039 "cmovg\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001040 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001041 X86_COND_G, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001042 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001043def CMOVG32rr : I<0x4F, MRMSrcReg, // if >s, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +00001044 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001045 "cmovg\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001046 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001047 X86_COND_G, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001048 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001049def CMOVS16rr : I<0x48, MRMSrcReg, // if signed, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +00001050 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001051 "cmovs\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001052 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001053 X86_COND_S, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001054 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001055def CMOVS32rr : I<0x48, MRMSrcReg, // if signed, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +00001056 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001057 "cmovs\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001058 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001059 X86_COND_S, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001060 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001061def CMOVNS16rr: I<0x49, MRMSrcReg, // if !signed, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +00001062 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001063 "cmovns\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001064 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001065 X86_COND_NS, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001066 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001067def CMOVNS32rr: I<0x49, MRMSrcReg, // if !signed, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +00001068 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001069 "cmovns\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001070 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001071 X86_COND_NS, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001072 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001073def CMOVP16rr : I<0x4A, MRMSrcReg, // if parity, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +00001074 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001075 "cmovp\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001076 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001077 X86_COND_P, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001078 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001079def CMOVP32rr : I<0x4A, MRMSrcReg, // if parity, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +00001080 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001081 "cmovp\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001082 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001083 X86_COND_P, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001084 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001085def CMOVNP16rr : I<0x4B, MRMSrcReg, // if !parity, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +00001086 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001087 "cmovnp\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001088 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001089 X86_COND_NP, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001090 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001091def CMOVNP32rr : I<0x4B, MRMSrcReg, // if !parity, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +00001092 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001093 "cmovnp\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001094 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001095 X86_COND_NP, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001096 TB;
Dan Gohman12fd4d72009-01-07 00:35:10 +00001097def CMOVO16rr : I<0x40, MRMSrcReg, // if overflow, GR16 = GR16
1098 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
1099 "cmovo\t{$src2, $dst|$dst, $src2}",
1100 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
1101 X86_COND_O, EFLAGS))]>,
1102 TB, OpSize;
1103def CMOVO32rr : I<0x40, MRMSrcReg, // if overflow, GR32 = GR32
1104 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
1105 "cmovo\t{$src2, $dst|$dst, $src2}",
1106 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
1107 X86_COND_O, EFLAGS))]>,
Evan Cheng950aac02007-09-25 01:57:46 +00001108 TB;
Dan Gohman12fd4d72009-01-07 00:35:10 +00001109def CMOVNO16rr : I<0x41, MRMSrcReg, // if !overflow, GR16 = GR16
1110 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
1111 "cmovno\t{$src2, $dst|$dst, $src2}",
1112 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
1113 X86_COND_NO, EFLAGS))]>,
1114 TB, OpSize;
1115def CMOVNO32rr : I<0x41, MRMSrcReg, // if !overflow, GR32 = GR32
1116 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
1117 "cmovno\t{$src2, $dst|$dst, $src2}",
1118 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
1119 X86_COND_NO, EFLAGS))]>,
1120 TB;
1121} // isCommutable = 1
Evan Cheng926658c2007-10-05 23:13:21 +00001122
1123def CMOVB16rm : I<0x42, MRMSrcMem, // if <u, GR16 = [mem16]
1124 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1125 "cmovb\t{$src2, $dst|$dst, $src2}",
1126 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1127 X86_COND_B, EFLAGS))]>,
1128 TB, OpSize;
1129def CMOVB32rm : I<0x42, MRMSrcMem, // if <u, GR32 = [mem32]
1130 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1131 "cmovb\t{$src2, $dst|$dst, $src2}",
1132 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1133 X86_COND_B, EFLAGS))]>,
1134 TB;
1135def CMOVAE16rm: I<0x43, MRMSrcMem, // if >=u, GR16 = [mem16]
1136 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1137 "cmovae\t{$src2, $dst|$dst, $src2}",
1138 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1139 X86_COND_AE, EFLAGS))]>,
1140 TB, OpSize;
1141def CMOVAE32rm: I<0x43, MRMSrcMem, // if >=u, GR32 = [mem32]
1142 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1143 "cmovae\t{$src2, $dst|$dst, $src2}",
1144 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1145 X86_COND_AE, EFLAGS))]>,
1146 TB;
1147def CMOVE16rm : I<0x44, MRMSrcMem, // if ==, GR16 = [mem16]
1148 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1149 "cmove\t{$src2, $dst|$dst, $src2}",
1150 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1151 X86_COND_E, EFLAGS))]>,
1152 TB, OpSize;
1153def CMOVE32rm : I<0x44, MRMSrcMem, // if ==, GR32 = [mem32]
1154 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1155 "cmove\t{$src2, $dst|$dst, $src2}",
1156 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1157 X86_COND_E, EFLAGS))]>,
1158 TB;
1159def CMOVNE16rm: I<0x45, MRMSrcMem, // if !=, GR16 = [mem16]
1160 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1161 "cmovne\t{$src2, $dst|$dst, $src2}",
1162 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1163 X86_COND_NE, EFLAGS))]>,
1164 TB, OpSize;
1165def CMOVNE32rm: I<0x45, MRMSrcMem, // if !=, GR32 = [mem32]
1166 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1167 "cmovne\t{$src2, $dst|$dst, $src2}",
1168 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1169 X86_COND_NE, EFLAGS))]>,
1170 TB;
1171def CMOVBE16rm: I<0x46, MRMSrcMem, // if <=u, GR16 = [mem16]
1172 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1173 "cmovbe\t{$src2, $dst|$dst, $src2}",
1174 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1175 X86_COND_BE, EFLAGS))]>,
1176 TB, OpSize;
1177def CMOVBE32rm: I<0x46, MRMSrcMem, // if <=u, GR32 = [mem32]
1178 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1179 "cmovbe\t{$src2, $dst|$dst, $src2}",
1180 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1181 X86_COND_BE, EFLAGS))]>,
1182 TB;
1183def CMOVA16rm : I<0x47, MRMSrcMem, // if >u, GR16 = [mem16]
1184 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1185 "cmova\t{$src2, $dst|$dst, $src2}",
1186 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1187 X86_COND_A, EFLAGS))]>,
1188 TB, OpSize;
1189def CMOVA32rm : I<0x47, MRMSrcMem, // if >u, GR32 = [mem32]
1190 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1191 "cmova\t{$src2, $dst|$dst, $src2}",
1192 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1193 X86_COND_A, EFLAGS))]>,
1194 TB;
1195def CMOVL16rm : I<0x4C, MRMSrcMem, // if <s, GR16 = [mem16]
1196 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1197 "cmovl\t{$src2, $dst|$dst, $src2}",
1198 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1199 X86_COND_L, EFLAGS))]>,
1200 TB, OpSize;
1201def CMOVL32rm : I<0x4C, MRMSrcMem, // if <s, GR32 = [mem32]
1202 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1203 "cmovl\t{$src2, $dst|$dst, $src2}",
1204 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1205 X86_COND_L, EFLAGS))]>,
1206 TB;
1207def CMOVGE16rm: I<0x4D, MRMSrcMem, // if >=s, GR16 = [mem16]
1208 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1209 "cmovge\t{$src2, $dst|$dst, $src2}",
1210 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1211 X86_COND_GE, EFLAGS))]>,
1212 TB, OpSize;
1213def CMOVGE32rm: I<0x4D, MRMSrcMem, // if >=s, GR32 = [mem32]
1214 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1215 "cmovge\t{$src2, $dst|$dst, $src2}",
1216 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1217 X86_COND_GE, EFLAGS))]>,
1218 TB;
1219def CMOVLE16rm: I<0x4E, MRMSrcMem, // if <=s, GR16 = [mem16]
1220 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1221 "cmovle\t{$src2, $dst|$dst, $src2}",
1222 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1223 X86_COND_LE, EFLAGS))]>,
1224 TB, OpSize;
1225def CMOVLE32rm: I<0x4E, MRMSrcMem, // if <=s, GR32 = [mem32]
1226 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1227 "cmovle\t{$src2, $dst|$dst, $src2}",
1228 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1229 X86_COND_LE, EFLAGS))]>,
1230 TB;
1231def CMOVG16rm : I<0x4F, MRMSrcMem, // if >s, GR16 = [mem16]
1232 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1233 "cmovg\t{$src2, $dst|$dst, $src2}",
1234 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1235 X86_COND_G, EFLAGS))]>,
1236 TB, OpSize;
1237def CMOVG32rm : I<0x4F, MRMSrcMem, // if >s, GR32 = [mem32]
1238 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1239 "cmovg\t{$src2, $dst|$dst, $src2}",
1240 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1241 X86_COND_G, EFLAGS))]>,
1242 TB;
1243def CMOVS16rm : I<0x48, MRMSrcMem, // if signed, GR16 = [mem16]
1244 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1245 "cmovs\t{$src2, $dst|$dst, $src2}",
1246 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1247 X86_COND_S, EFLAGS))]>,
1248 TB, OpSize;
1249def CMOVS32rm : I<0x48, MRMSrcMem, // if signed, GR32 = [mem32]
1250 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1251 "cmovs\t{$src2, $dst|$dst, $src2}",
1252 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1253 X86_COND_S, EFLAGS))]>,
1254 TB;
1255def CMOVNS16rm: I<0x49, MRMSrcMem, // if !signed, GR16 = [mem16]
1256 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1257 "cmovns\t{$src2, $dst|$dst, $src2}",
1258 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1259 X86_COND_NS, EFLAGS))]>,
1260 TB, OpSize;
1261def CMOVNS32rm: I<0x49, MRMSrcMem, // if !signed, GR32 = [mem32]
1262 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1263 "cmovns\t{$src2, $dst|$dst, $src2}",
1264 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1265 X86_COND_NS, EFLAGS))]>,
1266 TB;
1267def CMOVP16rm : I<0x4A, MRMSrcMem, // if parity, GR16 = [mem16]
1268 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1269 "cmovp\t{$src2, $dst|$dst, $src2}",
1270 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1271 X86_COND_P, EFLAGS))]>,
1272 TB, OpSize;
1273def CMOVP32rm : I<0x4A, MRMSrcMem, // if parity, GR32 = [mem32]
1274 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1275 "cmovp\t{$src2, $dst|$dst, $src2}",
1276 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1277 X86_COND_P, EFLAGS))]>,
1278 TB;
1279def CMOVNP16rm : I<0x4B, MRMSrcMem, // if !parity, GR16 = [mem16]
1280 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1281 "cmovnp\t{$src2, $dst|$dst, $src2}",
1282 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1283 X86_COND_NP, EFLAGS))]>,
1284 TB, OpSize;
Dan Gohman12fd4d72009-01-07 00:35:10 +00001285def CMOVNP32rm : I<0x4B, MRMSrcMem, // if !parity, GR32 = [mem32]
1286 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1287 "cmovnp\t{$src2, $dst|$dst, $src2}",
1288 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1289 X86_COND_NP, EFLAGS))]>,
1290 TB;
1291def CMOVO16rm : I<0x40, MRMSrcMem, // if overflow, GR16 = [mem16]
1292 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1293 "cmovo\t{$src2, $dst|$dst, $src2}",
1294 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1295 X86_COND_O, EFLAGS))]>,
1296 TB, OpSize;
1297def CMOVO32rm : I<0x40, MRMSrcMem, // if overflow, GR32 = [mem32]
1298 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1299 "cmovo\t{$src2, $dst|$dst, $src2}",
1300 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1301 X86_COND_O, EFLAGS))]>,
1302 TB;
1303def CMOVNO16rm : I<0x41, MRMSrcMem, // if !overflow, GR16 = [mem16]
1304 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1305 "cmovno\t{$src2, $dst|$dst, $src2}",
1306 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1307 X86_COND_NO, EFLAGS))]>,
1308 TB, OpSize;
1309def CMOVNO32rm : I<0x41, MRMSrcMem, // if !overflow, GR32 = [mem32]
1310 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1311 "cmovno\t{$src2, $dst|$dst, $src2}",
1312 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1313 X86_COND_NO, EFLAGS))]>,
1314 TB;
Evan Cheng950aac02007-09-25 01:57:46 +00001315} // Uses = [EFLAGS]
1316
1317
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001318// unary instructions
1319let CodeSize = 2 in {
Evan Cheng55687072007-09-14 21:48:26 +00001320let Defs = [EFLAGS] in {
Dan Gohman91888f02007-07-31 20:11:57 +00001321def NEG8r : I<0xF6, MRM3r, (outs GR8 :$dst), (ins GR8 :$src), "neg{b}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001322 [(set GR8:$dst, (ineg GR8:$src)),
1323 (implicit EFLAGS)]>;
Dan Gohman91888f02007-07-31 20:11:57 +00001324def NEG16r : I<0xF7, MRM3r, (outs GR16:$dst), (ins GR16:$src), "neg{w}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001325 [(set GR16:$dst, (ineg GR16:$src)),
1326 (implicit EFLAGS)]>, OpSize;
Dan Gohman91888f02007-07-31 20:11:57 +00001327def NEG32r : I<0xF7, MRM3r, (outs GR32:$dst), (ins GR32:$src), "neg{l}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001328 [(set GR32:$dst, (ineg GR32:$src)),
1329 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001330let isTwoAddress = 0 in {
Dan Gohman91888f02007-07-31 20:11:57 +00001331 def NEG8m : I<0xF6, MRM3m, (outs), (ins i8mem :$dst), "neg{b}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001332 [(store (ineg (loadi8 addr:$dst)), addr:$dst),
1333 (implicit EFLAGS)]>;
Dan Gohman91888f02007-07-31 20:11:57 +00001334 def NEG16m : I<0xF7, MRM3m, (outs), (ins i16mem:$dst), "neg{w}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001335 [(store (ineg (loadi16 addr:$dst)), addr:$dst),
1336 (implicit EFLAGS)]>, OpSize;
Dan Gohman91888f02007-07-31 20:11:57 +00001337 def NEG32m : I<0xF7, MRM3m, (outs), (ins i32mem:$dst), "neg{l}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001338 [(store (ineg (loadi32 addr:$dst)), addr:$dst),
1339 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001340}
Evan Cheng55687072007-09-14 21:48:26 +00001341} // Defs = [EFLAGS]
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001342
Evan Chengc6cee682009-01-21 02:09:05 +00001343// Match xor -1 to not. Favors these over a move imm + xor to save code size.
1344let AddedComplexity = 15 in {
Dan Gohman91888f02007-07-31 20:11:57 +00001345def NOT8r : I<0xF6, MRM2r, (outs GR8 :$dst), (ins GR8 :$src), "not{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001346 [(set GR8:$dst, (not GR8:$src))]>;
Dan Gohman91888f02007-07-31 20:11:57 +00001347def NOT16r : I<0xF7, MRM2r, (outs GR16:$dst), (ins GR16:$src), "not{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001348 [(set GR16:$dst, (not GR16:$src))]>, OpSize;
Dan Gohman91888f02007-07-31 20:11:57 +00001349def NOT32r : I<0xF7, MRM2r, (outs GR32:$dst), (ins GR32:$src), "not{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001350 [(set GR32:$dst, (not GR32:$src))]>;
Evan Chengc6cee682009-01-21 02:09:05 +00001351}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001352let isTwoAddress = 0 in {
Dan Gohman91888f02007-07-31 20:11:57 +00001353 def NOT8m : I<0xF6, MRM2m, (outs), (ins i8mem :$dst), "not{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001354 [(store (not (loadi8 addr:$dst)), addr:$dst)]>;
Dan Gohman91888f02007-07-31 20:11:57 +00001355 def NOT16m : I<0xF7, MRM2m, (outs), (ins i16mem:$dst), "not{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001356 [(store (not (loadi16 addr:$dst)), addr:$dst)]>, OpSize;
Dan Gohman91888f02007-07-31 20:11:57 +00001357 def NOT32m : I<0xF7, MRM2m, (outs), (ins i32mem:$dst), "not{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001358 [(store (not (loadi32 addr:$dst)), addr:$dst)]>;
1359}
1360} // CodeSize
1361
1362// TODO: inc/dec is slow for P4, but fast for Pentium-M.
Evan Cheng55687072007-09-14 21:48:26 +00001363let Defs = [EFLAGS] in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001364let CodeSize = 2 in
Dan Gohman91888f02007-07-31 20:11:57 +00001365def INC8r : I<0xFE, MRM0r, (outs GR8 :$dst), (ins GR8 :$src), "inc{b}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001366 [(set GR8:$dst, (add GR8:$src, 1)),
1367 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001368let isConvertibleToThreeAddress = 1, CodeSize = 1 in { // Can xform into LEA.
Dan Gohman91888f02007-07-31 20:11:57 +00001369def INC16r : I<0x40, AddRegFrm, (outs GR16:$dst), (ins GR16:$src), "inc{w}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001370 [(set GR16:$dst, (add GR16:$src, 1)),
1371 (implicit EFLAGS)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001372 OpSize, Requires<[In32BitMode]>;
Dan Gohman91888f02007-07-31 20:11:57 +00001373def INC32r : I<0x40, AddRegFrm, (outs GR32:$dst), (ins GR32:$src), "inc{l}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001374 [(set GR32:$dst, (add GR32:$src, 1)),
1375 (implicit EFLAGS)]>, Requires<[In32BitMode]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001376}
1377let isTwoAddress = 0, CodeSize = 2 in {
Dan Gohman91888f02007-07-31 20:11:57 +00001378 def INC8m : I<0xFE, MRM0m, (outs), (ins i8mem :$dst), "inc{b}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001379 [(store (add (loadi8 addr:$dst), 1), addr:$dst),
1380 (implicit EFLAGS)]>;
Dan Gohman91888f02007-07-31 20:11:57 +00001381 def INC16m : I<0xFF, MRM0m, (outs), (ins i16mem:$dst), "inc{w}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001382 [(store (add (loadi16 addr:$dst), 1), addr:$dst),
1383 (implicit EFLAGS)]>,
Evan Cheng4a7e72f2007-10-19 21:23:22 +00001384 OpSize, Requires<[In32BitMode]>;
Dan Gohman91888f02007-07-31 20:11:57 +00001385 def INC32m : I<0xFF, MRM0m, (outs), (ins i32mem:$dst), "inc{l}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001386 [(store (add (loadi32 addr:$dst), 1), addr:$dst),
1387 (implicit EFLAGS)]>,
Evan Cheng4a7e72f2007-10-19 21:23:22 +00001388 Requires<[In32BitMode]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001389}
1390
1391let CodeSize = 2 in
Dan Gohman91888f02007-07-31 20:11:57 +00001392def DEC8r : I<0xFE, MRM1r, (outs GR8 :$dst), (ins GR8 :$src), "dec{b}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001393 [(set GR8:$dst, (add GR8:$src, -1)),
1394 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001395let isConvertibleToThreeAddress = 1, CodeSize = 1 in { // Can xform into LEA.
Dan Gohman91888f02007-07-31 20:11:57 +00001396def DEC16r : I<0x48, AddRegFrm, (outs GR16:$dst), (ins GR16:$src), "dec{w}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001397 [(set GR16:$dst, (add GR16:$src, -1)),
1398 (implicit EFLAGS)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001399 OpSize, Requires<[In32BitMode]>;
Dan Gohman91888f02007-07-31 20:11:57 +00001400def DEC32r : I<0x48, AddRegFrm, (outs GR32:$dst), (ins GR32:$src), "dec{l}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001401 [(set GR32:$dst, (add GR32:$src, -1)),
1402 (implicit EFLAGS)]>, Requires<[In32BitMode]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001403}
1404
1405let isTwoAddress = 0, CodeSize = 2 in {
Dan Gohman91888f02007-07-31 20:11:57 +00001406 def DEC8m : I<0xFE, MRM1m, (outs), (ins i8mem :$dst), "dec{b}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001407 [(store (add (loadi8 addr:$dst), -1), addr:$dst),
1408 (implicit EFLAGS)]>;
Dan Gohman91888f02007-07-31 20:11:57 +00001409 def DEC16m : I<0xFF, MRM1m, (outs), (ins i16mem:$dst), "dec{w}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001410 [(store (add (loadi16 addr:$dst), -1), addr:$dst),
1411 (implicit EFLAGS)]>,
Evan Cheng4a7e72f2007-10-19 21:23:22 +00001412 OpSize, Requires<[In32BitMode]>;
Dan Gohman91888f02007-07-31 20:11:57 +00001413 def DEC32m : I<0xFF, MRM1m, (outs), (ins i32mem:$dst), "dec{l}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001414 [(store (add (loadi32 addr:$dst), -1), addr:$dst),
1415 (implicit EFLAGS)]>,
Evan Cheng4a7e72f2007-10-19 21:23:22 +00001416 Requires<[In32BitMode]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001417}
Evan Cheng55687072007-09-14 21:48:26 +00001418} // Defs = [EFLAGS]
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001419
1420// Logical operators...
Evan Cheng55687072007-09-14 21:48:26 +00001421let Defs = [EFLAGS] in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001422let isCommutable = 1 in { // X = AND Y, Z --> X = AND Z, Y
1423def AND8rr : I<0x20, MRMDestReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001424 (outs GR8 :$dst), (ins GR8 :$src1, GR8 :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001425 "and{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001426 [(set GR8:$dst, (and GR8:$src1, GR8:$src2)),
1427 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001428def AND16rr : I<0x21, MRMDestReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001429 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001430 "and{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001431 [(set GR16:$dst, (and GR16:$src1, GR16:$src2)),
1432 (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001433def AND32rr : I<0x21, MRMDestReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001434 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001435 "and{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001436 [(set GR32:$dst, (and GR32:$src1, GR32:$src2)),
1437 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001438}
1439
1440def AND8rm : I<0x22, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001441 (outs GR8 :$dst), (ins GR8 :$src1, i8mem :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001442 "and{b}\t{$src2, $dst|$dst, $src2}",
Chris Lattner12208612009-04-10 00:16:23 +00001443 [(set GR8:$dst, (and GR8:$src1, (loadi8 addr:$src2))),
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001444 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001445def AND16rm : I<0x23, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001446 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001447 "and{w}\t{$src2, $dst|$dst, $src2}",
Chris Lattner12208612009-04-10 00:16:23 +00001448 [(set GR16:$dst, (and GR16:$src1, (loadi16 addr:$src2))),
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001449 (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001450def AND32rm : I<0x23, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001451 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001452 "and{l}\t{$src2, $dst|$dst, $src2}",
Chris Lattner12208612009-04-10 00:16:23 +00001453 [(set GR32:$dst, (and GR32:$src1, (loadi32 addr:$src2))),
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001454 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001455
1456def AND8ri : Ii8<0x80, MRM4r,
Evan Chengb783fa32007-07-19 01:14:50 +00001457 (outs GR8 :$dst), (ins GR8 :$src1, i8imm :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001458 "and{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001459 [(set GR8:$dst, (and GR8:$src1, imm:$src2)),
1460 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001461def AND16ri : Ii16<0x81, MRM4r,
Evan Chengb783fa32007-07-19 01:14:50 +00001462 (outs GR16:$dst), (ins GR16:$src1, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001463 "and{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001464 [(set GR16:$dst, (and GR16:$src1, imm:$src2)),
1465 (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001466def AND32ri : Ii32<0x81, MRM4r,
Evan Chengb783fa32007-07-19 01:14:50 +00001467 (outs GR32:$dst), (ins GR32:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001468 "and{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001469 [(set GR32:$dst, (and GR32:$src1, imm:$src2)),
1470 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001471def AND16ri8 : Ii8<0x83, MRM4r,
Evan Chengb783fa32007-07-19 01:14:50 +00001472 (outs GR16:$dst), (ins GR16:$src1, i16i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001473 "and{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001474 [(set GR16:$dst, (and GR16:$src1, i16immSExt8:$src2)),
1475 (implicit EFLAGS)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001476 OpSize;
1477def AND32ri8 : Ii8<0x83, MRM4r,
Evan Chengb783fa32007-07-19 01:14:50 +00001478 (outs GR32:$dst), (ins GR32:$src1, i32i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001479 "and{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001480 [(set GR32:$dst, (and GR32:$src1, i32immSExt8:$src2)),
1481 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001482
1483let isTwoAddress = 0 in {
1484 def AND8mr : I<0x20, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001485 (outs), (ins i8mem :$dst, GR8 :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001486 "and{b}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001487 [(store (and (load addr:$dst), GR8:$src), addr:$dst),
1488 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001489 def AND16mr : I<0x21, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001490 (outs), (ins i16mem:$dst, GR16:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001491 "and{w}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001492 [(store (and (load addr:$dst), GR16:$src), addr:$dst),
1493 (implicit EFLAGS)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001494 OpSize;
1495 def AND32mr : I<0x21, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001496 (outs), (ins i32mem:$dst, GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001497 "and{l}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001498 [(store (and (load addr:$dst), GR32:$src), addr:$dst),
1499 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001500 def AND8mi : Ii8<0x80, MRM4m,
Evan Chengb783fa32007-07-19 01:14:50 +00001501 (outs), (ins i8mem :$dst, i8imm :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001502 "and{b}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001503 [(store (and (loadi8 addr:$dst), imm:$src), addr:$dst),
1504 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001505 def AND16mi : Ii16<0x81, MRM4m,
Evan Chengb783fa32007-07-19 01:14:50 +00001506 (outs), (ins i16mem:$dst, i16imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001507 "and{w}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001508 [(store (and (loadi16 addr:$dst), imm:$src), addr:$dst),
1509 (implicit EFLAGS)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001510 OpSize;
1511 def AND32mi : Ii32<0x81, MRM4m,
Evan Chengb783fa32007-07-19 01:14:50 +00001512 (outs), (ins i32mem:$dst, i32imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001513 "and{l}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001514 [(store (and (loadi32 addr:$dst), imm:$src), addr:$dst),
1515 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001516 def AND16mi8 : Ii8<0x83, MRM4m,
Evan Chengb783fa32007-07-19 01:14:50 +00001517 (outs), (ins i16mem:$dst, i16i8imm :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001518 "and{w}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001519 [(store (and (load addr:$dst), i16immSExt8:$src), addr:$dst),
1520 (implicit EFLAGS)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001521 OpSize;
1522 def AND32mi8 : Ii8<0x83, MRM4m,
Evan Chengb783fa32007-07-19 01:14:50 +00001523 (outs), (ins i32mem:$dst, i32i8imm :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001524 "and{l}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001525 [(store (and (load addr:$dst), i32immSExt8:$src), addr:$dst),
1526 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001527}
1528
1529
1530let isCommutable = 1 in { // X = OR Y, Z --> X = OR Z, Y
Evan Chengb783fa32007-07-19 01:14:50 +00001531def OR8rr : I<0x08, MRMDestReg, (outs GR8 :$dst), (ins GR8 :$src1, GR8 :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001532 "or{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001533 [(set GR8:$dst, (or GR8:$src1, GR8:$src2)),
1534 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001535def OR16rr : I<0x09, MRMDestReg, (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001536 "or{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001537 [(set GR16:$dst, (or GR16:$src1, GR16:$src2)),
1538 (implicit EFLAGS)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001539def OR32rr : I<0x09, MRMDestReg, (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001540 "or{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001541 [(set GR32:$dst, (or GR32:$src1, GR32:$src2)),
1542 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001543}
Evan Chengb783fa32007-07-19 01:14:50 +00001544def OR8rm : I<0x0A, MRMSrcMem , (outs GR8 :$dst), (ins GR8 :$src1, i8mem :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001545 "or{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001546 [(set GR8:$dst, (or GR8:$src1, (load addr:$src2))),
1547 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001548def OR16rm : I<0x0B, MRMSrcMem , (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001549 "or{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001550 [(set GR16:$dst, (or GR16:$src1, (load addr:$src2))),
1551 (implicit EFLAGS)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001552def OR32rm : I<0x0B, MRMSrcMem , (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001553 "or{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001554 [(set GR32:$dst, (or GR32:$src1, (load addr:$src2))),
1555 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001556
Evan Chengb783fa32007-07-19 01:14:50 +00001557def OR8ri : Ii8 <0x80, MRM1r, (outs GR8 :$dst), (ins GR8 :$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001558 "or{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001559 [(set GR8:$dst, (or GR8:$src1, imm:$src2)),
1560 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001561def OR16ri : Ii16<0x81, MRM1r, (outs GR16:$dst), (ins GR16:$src1, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001562 "or{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001563 [(set GR16:$dst, (or GR16:$src1, imm:$src2)),
1564 (implicit EFLAGS)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001565def OR32ri : Ii32<0x81, MRM1r, (outs GR32:$dst), (ins GR32:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001566 "or{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001567 [(set GR32:$dst, (or GR32:$src1, imm:$src2)),
1568 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001569
Evan Chengb783fa32007-07-19 01:14:50 +00001570def OR16ri8 : Ii8<0x83, MRM1r, (outs GR16:$dst), (ins GR16:$src1, i16i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001571 "or{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001572 [(set GR16:$dst, (or GR16:$src1, i16immSExt8:$src2)),
1573 (implicit EFLAGS)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001574def OR32ri8 : Ii8<0x83, MRM1r, (outs GR32:$dst), (ins GR32:$src1, i32i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001575 "or{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001576 [(set GR32:$dst, (or GR32:$src1, i32immSExt8:$src2)),
1577 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001578let isTwoAddress = 0 in {
Evan Chengb783fa32007-07-19 01:14:50 +00001579 def OR8mr : I<0x08, MRMDestMem, (outs), (ins i8mem:$dst, GR8:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001580 "or{b}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001581 [(store (or (load addr:$dst), GR8:$src), addr:$dst),
1582 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001583 def OR16mr : I<0x09, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001584 "or{w}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001585 [(store (or (load addr:$dst), GR16:$src), addr:$dst),
1586 (implicit EFLAGS)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001587 def OR32mr : I<0x09, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001588 "or{l}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001589 [(store (or (load addr:$dst), GR32:$src), addr:$dst),
1590 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001591 def OR8mi : Ii8<0x80, MRM1m, (outs), (ins i8mem :$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001592 "or{b}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001593 [(store (or (loadi8 addr:$dst), imm:$src), addr:$dst),
1594 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001595 def OR16mi : Ii16<0x81, MRM1m, (outs), (ins i16mem:$dst, i16imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001596 "or{w}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001597 [(store (or (loadi16 addr:$dst), imm:$src), addr:$dst),
1598 (implicit EFLAGS)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001599 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001600 def OR32mi : Ii32<0x81, MRM1m, (outs), (ins i32mem:$dst, i32imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001601 "or{l}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001602 [(store (or (loadi32 addr:$dst), imm:$src), addr:$dst),
1603 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001604 def OR16mi8 : Ii8<0x83, MRM1m, (outs), (ins i16mem:$dst, i16i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001605 "or{w}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001606 [(store (or (load addr:$dst), i16immSExt8:$src), addr:$dst),
1607 (implicit EFLAGS)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001608 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001609 def OR32mi8 : Ii8<0x83, MRM1m, (outs), (ins i32mem:$dst, i32i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001610 "or{l}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001611 [(store (or (load addr:$dst), i32immSExt8:$src), addr:$dst),
1612 (implicit EFLAGS)]>;
Bill Wendlingba5d5b02008-05-29 01:02:09 +00001613} // isTwoAddress = 0
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001614
1615
Evan Cheng6f26e8b2008-06-18 08:13:07 +00001616let isCommutable = 1 in { // X = XOR Y, Z --> X = XOR Z, Y
Bill Wendlingba5d5b02008-05-29 01:02:09 +00001617 def XOR8rr : I<0x30, MRMDestReg,
1618 (outs GR8 :$dst), (ins GR8 :$src1, GR8 :$src2),
1619 "xor{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001620 [(set GR8:$dst, (xor GR8:$src1, GR8:$src2)),
1621 (implicit EFLAGS)]>;
Bill Wendlingba5d5b02008-05-29 01:02:09 +00001622 def XOR16rr : I<0x31, MRMDestReg,
1623 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
1624 "xor{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001625 [(set GR16:$dst, (xor GR16:$src1, GR16:$src2)),
1626 (implicit EFLAGS)]>, OpSize;
Bill Wendlingba5d5b02008-05-29 01:02:09 +00001627 def XOR32rr : I<0x31, MRMDestReg,
1628 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
1629 "xor{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001630 [(set GR32:$dst, (xor GR32:$src1, GR32:$src2)),
1631 (implicit EFLAGS)]>;
Evan Cheng6f26e8b2008-06-18 08:13:07 +00001632} // isCommutable = 1
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001633
1634def XOR8rm : I<0x32, MRMSrcMem ,
Evan Chengb783fa32007-07-19 01:14:50 +00001635 (outs GR8 :$dst), (ins GR8:$src1, i8mem :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001636 "xor{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001637 [(set GR8:$dst, (xor GR8:$src1, (load addr:$src2))),
1638 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001639def XOR16rm : I<0x33, MRMSrcMem ,
Evan Chengb783fa32007-07-19 01:14:50 +00001640 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001641 "xor{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001642 [(set GR16:$dst, (xor GR16:$src1, (load addr:$src2))),
1643 (implicit EFLAGS)]>,
Bill Wendlingba5d5b02008-05-29 01:02:09 +00001644 OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001645def XOR32rm : I<0x33, MRMSrcMem ,
Evan Chengb783fa32007-07-19 01:14:50 +00001646 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001647 "xor{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001648 [(set GR32:$dst, (xor GR32:$src1, (load addr:$src2))),
1649 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001650
Bill Wendlingbac38eb2008-05-29 03:46:36 +00001651def XOR8ri : Ii8<0x80, MRM6r,
1652 (outs GR8:$dst), (ins GR8:$src1, i8imm:$src2),
1653 "xor{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001654 [(set GR8:$dst, (xor GR8:$src1, imm:$src2)),
1655 (implicit EFLAGS)]>;
Bill Wendlingbac38eb2008-05-29 03:46:36 +00001656def XOR16ri : Ii16<0x81, MRM6r,
1657 (outs GR16:$dst), (ins GR16:$src1, i16imm:$src2),
1658 "xor{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001659 [(set GR16:$dst, (xor GR16:$src1, imm:$src2)),
1660 (implicit EFLAGS)]>, OpSize;
Bill Wendlingbac38eb2008-05-29 03:46:36 +00001661def XOR32ri : Ii32<0x81, MRM6r,
1662 (outs GR32:$dst), (ins GR32:$src1, i32imm:$src2),
1663 "xor{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001664 [(set GR32:$dst, (xor GR32:$src1, imm:$src2)),
1665 (implicit EFLAGS)]>;
Bill Wendlingbac38eb2008-05-29 03:46:36 +00001666def XOR16ri8 : Ii8<0x83, MRM6r,
1667 (outs GR16:$dst), (ins GR16:$src1, i16i8imm:$src2),
1668 "xor{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001669 [(set GR16:$dst, (xor GR16:$src1, i16immSExt8:$src2)),
1670 (implicit EFLAGS)]>,
Bill Wendlingbac38eb2008-05-29 03:46:36 +00001671 OpSize;
1672def XOR32ri8 : Ii8<0x83, MRM6r,
1673 (outs GR32:$dst), (ins GR32:$src1, i32i8imm:$src2),
1674 "xor{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001675 [(set GR32:$dst, (xor GR32:$src1, i32immSExt8:$src2)),
1676 (implicit EFLAGS)]>;
Bill Wendlingba5d5b02008-05-29 01:02:09 +00001677
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001678let isTwoAddress = 0 in {
1679 def XOR8mr : I<0x30, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001680 (outs), (ins i8mem :$dst, GR8 :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001681 "xor{b}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001682 [(store (xor (load addr:$dst), GR8:$src), addr:$dst),
1683 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001684 def XOR16mr : I<0x31, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001685 (outs), (ins i16mem:$dst, GR16:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001686 "xor{w}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001687 [(store (xor (load addr:$dst), GR16:$src), addr:$dst),
1688 (implicit EFLAGS)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001689 OpSize;
1690 def XOR32mr : I<0x31, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001691 (outs), (ins i32mem:$dst, GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001692 "xor{l}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001693 [(store (xor (load addr:$dst), GR32:$src), addr:$dst),
1694 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001695 def XOR8mi : Ii8<0x80, MRM6m,
Evan Chengb783fa32007-07-19 01:14:50 +00001696 (outs), (ins i8mem :$dst, i8imm :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001697 "xor{b}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001698 [(store (xor (loadi8 addr:$dst), imm:$src), addr:$dst),
1699 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001700 def XOR16mi : Ii16<0x81, MRM6m,
Evan Chengb783fa32007-07-19 01:14:50 +00001701 (outs), (ins i16mem:$dst, i16imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001702 "xor{w}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001703 [(store (xor (loadi16 addr:$dst), imm:$src), addr:$dst),
1704 (implicit EFLAGS)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001705 OpSize;
1706 def XOR32mi : Ii32<0x81, MRM6m,
Evan Chengb783fa32007-07-19 01:14:50 +00001707 (outs), (ins i32mem:$dst, i32imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001708 "xor{l}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001709 [(store (xor (loadi32 addr:$dst), imm:$src), addr:$dst),
1710 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001711 def XOR16mi8 : Ii8<0x83, MRM6m,
Evan Chengb783fa32007-07-19 01:14:50 +00001712 (outs), (ins i16mem:$dst, i16i8imm :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001713 "xor{w}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001714 [(store (xor (load addr:$dst), i16immSExt8:$src), addr:$dst),
1715 (implicit EFLAGS)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001716 OpSize;
1717 def XOR32mi8 : Ii8<0x83, MRM6m,
Evan Chengb783fa32007-07-19 01:14:50 +00001718 (outs), (ins i32mem:$dst, i32i8imm :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001719 "xor{l}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001720 [(store (xor (load addr:$dst), i32immSExt8:$src), addr:$dst),
1721 (implicit EFLAGS)]>;
Bill Wendlingba5d5b02008-05-29 01:02:09 +00001722} // isTwoAddress = 0
Evan Cheng55687072007-09-14 21:48:26 +00001723} // Defs = [EFLAGS]
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001724
1725// Shift instructions
Evan Cheng55687072007-09-14 21:48:26 +00001726let Defs = [EFLAGS] in {
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001727let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00001728def SHL8rCL : I<0xD2, MRM4r, (outs GR8 :$dst), (ins GR8 :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001729 "shl{b}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001730 [(set GR8:$dst, (shl GR8:$src, CL))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001731def SHL16rCL : I<0xD3, MRM4r, (outs GR16:$dst), (ins GR16:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001732 "shl{w}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001733 [(set GR16:$dst, (shl GR16:$src, CL))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001734def SHL32rCL : I<0xD3, MRM4r, (outs GR32:$dst), (ins GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001735 "shl{l}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001736 [(set GR32:$dst, (shl GR32:$src, CL))]>;
Bill Wendlingba5d5b02008-05-29 01:02:09 +00001737} // Uses = [CL]
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001738
Evan Chengb783fa32007-07-19 01:14:50 +00001739def SHL8ri : Ii8<0xC0, MRM4r, (outs GR8 :$dst), (ins GR8 :$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001740 "shl{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001741 [(set GR8:$dst, (shl GR8:$src1, (i8 imm:$src2)))]>;
1742let isConvertibleToThreeAddress = 1 in { // Can transform into LEA.
Evan Chengb783fa32007-07-19 01:14:50 +00001743def SHL16ri : Ii8<0xC1, MRM4r, (outs GR16:$dst), (ins GR16:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001744 "shl{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001745 [(set GR16:$dst, (shl GR16:$src1, (i8 imm:$src2)))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001746def SHL32ri : Ii8<0xC1, MRM4r, (outs GR32:$dst), (ins GR32:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001747 "shl{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001748 [(set GR32:$dst, (shl GR32:$src1, (i8 imm:$src2)))]>;
Chris Lattnerf4005a82008-01-11 18:00:50 +00001749// NOTE: We don't use shifts of a register by one, because 'add reg,reg' is
1750// cheaper.
Bill Wendlingba5d5b02008-05-29 01:02:09 +00001751} // isConvertibleToThreeAddress = 1
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001752
1753let isTwoAddress = 0 in {
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001754 let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00001755 def SHL8mCL : I<0xD2, MRM4m, (outs), (ins i8mem :$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001756 "shl{b}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001757 [(store (shl (loadi8 addr:$dst), CL), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001758 def SHL16mCL : I<0xD3, MRM4m, (outs), (ins i16mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001759 "shl{w}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001760 [(store (shl (loadi16 addr:$dst), CL), addr:$dst)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001761 def SHL32mCL : I<0xD3, MRM4m, (outs), (ins i32mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001762 "shl{l}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001763 [(store (shl (loadi32 addr:$dst), CL), addr:$dst)]>;
1764 }
Evan Chengb783fa32007-07-19 01:14:50 +00001765 def SHL8mi : Ii8<0xC0, MRM4m, (outs), (ins i8mem :$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001766 "shl{b}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001767 [(store (shl (loadi8 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001768 def SHL16mi : Ii8<0xC1, MRM4m, (outs), (ins i16mem:$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001769 "shl{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001770 [(store (shl (loadi16 addr:$dst), (i8 imm:$src)), addr:$dst)]>,
1771 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001772 def SHL32mi : Ii8<0xC1, MRM4m, (outs), (ins i32mem:$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001773 "shl{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001774 [(store (shl (loadi32 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
1775
1776 // Shift by 1
Evan Chengb783fa32007-07-19 01:14:50 +00001777 def SHL8m1 : I<0xD0, MRM4m, (outs), (ins i8mem :$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001778 "shl{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001779 [(store (shl (loadi8 addr:$dst), (i8 1)), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001780 def SHL16m1 : I<0xD1, MRM4m, (outs), (ins i16mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001781 "shl{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001782 [(store (shl (loadi16 addr:$dst), (i8 1)), addr:$dst)]>,
1783 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001784 def SHL32m1 : I<0xD1, MRM4m, (outs), (ins i32mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001785 "shl{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001786 [(store (shl (loadi32 addr:$dst), (i8 1)), addr:$dst)]>;
1787}
1788
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001789let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00001790def SHR8rCL : I<0xD2, MRM5r, (outs GR8 :$dst), (ins GR8 :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001791 "shr{b}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001792 [(set GR8:$dst, (srl GR8:$src, CL))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001793def SHR16rCL : I<0xD3, MRM5r, (outs GR16:$dst), (ins GR16:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001794 "shr{w}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001795 [(set GR16:$dst, (srl GR16:$src, CL))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001796def SHR32rCL : I<0xD3, MRM5r, (outs GR32:$dst), (ins GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001797 "shr{l}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001798 [(set GR32:$dst, (srl GR32:$src, CL))]>;
1799}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001800
Evan Chengb783fa32007-07-19 01:14:50 +00001801def SHR8ri : Ii8<0xC0, MRM5r, (outs GR8:$dst), (ins GR8:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001802 "shr{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001803 [(set GR8:$dst, (srl GR8:$src1, (i8 imm:$src2)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001804def SHR16ri : Ii8<0xC1, MRM5r, (outs GR16:$dst), (ins GR16:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001805 "shr{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001806 [(set GR16:$dst, (srl GR16:$src1, (i8 imm:$src2)))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001807def SHR32ri : Ii8<0xC1, MRM5r, (outs GR32:$dst), (ins GR32:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001808 "shr{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001809 [(set GR32:$dst, (srl GR32:$src1, (i8 imm:$src2)))]>;
1810
1811// Shift by 1
Evan Chengb783fa32007-07-19 01:14:50 +00001812def SHR8r1 : I<0xD0, MRM5r, (outs GR8:$dst), (ins GR8:$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00001813 "shr{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001814 [(set GR8:$dst, (srl GR8:$src1, (i8 1)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001815def SHR16r1 : I<0xD1, MRM5r, (outs GR16:$dst), (ins GR16:$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00001816 "shr{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001817 [(set GR16:$dst, (srl GR16:$src1, (i8 1)))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001818def SHR32r1 : I<0xD1, MRM5r, (outs GR32:$dst), (ins GR32:$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00001819 "shr{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001820 [(set GR32:$dst, (srl GR32:$src1, (i8 1)))]>;
1821
1822let isTwoAddress = 0 in {
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001823 let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00001824 def SHR8mCL : I<0xD2, MRM5m, (outs), (ins i8mem :$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001825 "shr{b}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001826 [(store (srl (loadi8 addr:$dst), CL), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001827 def SHR16mCL : I<0xD3, MRM5m, (outs), (ins i16mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001828 "shr{w}\t{%cl, $dst|$dst, %CL}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001829 [(store (srl (loadi16 addr:$dst), CL), addr:$dst)]>,
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001830 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001831 def SHR32mCL : I<0xD3, MRM5m, (outs), (ins i32mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001832 "shr{l}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001833 [(store (srl (loadi32 addr:$dst), CL), addr:$dst)]>;
1834 }
Evan Chengb783fa32007-07-19 01:14:50 +00001835 def SHR8mi : Ii8<0xC0, MRM5m, (outs), (ins i8mem :$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001836 "shr{b}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001837 [(store (srl (loadi8 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001838 def SHR16mi : Ii8<0xC1, MRM5m, (outs), (ins i16mem:$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001839 "shr{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001840 [(store (srl (loadi16 addr:$dst), (i8 imm:$src)), addr:$dst)]>,
1841 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001842 def SHR32mi : Ii8<0xC1, MRM5m, (outs), (ins i32mem:$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001843 "shr{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001844 [(store (srl (loadi32 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
1845
1846 // Shift by 1
Evan Chengb783fa32007-07-19 01:14:50 +00001847 def SHR8m1 : I<0xD0, MRM5m, (outs), (ins i8mem :$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001848 "shr{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001849 [(store (srl (loadi8 addr:$dst), (i8 1)), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001850 def SHR16m1 : I<0xD1, MRM5m, (outs), (ins i16mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001851 "shr{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001852 [(store (srl (loadi16 addr:$dst), (i8 1)), addr:$dst)]>,OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001853 def SHR32m1 : I<0xD1, MRM5m, (outs), (ins i32mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001854 "shr{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001855 [(store (srl (loadi32 addr:$dst), (i8 1)), addr:$dst)]>;
1856}
1857
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001858let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00001859def SAR8rCL : I<0xD2, MRM7r, (outs GR8 :$dst), (ins GR8 :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001860 "sar{b}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001861 [(set GR8:$dst, (sra GR8:$src, CL))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001862def SAR16rCL : I<0xD3, MRM7r, (outs GR16:$dst), (ins GR16:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001863 "sar{w}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001864 [(set GR16:$dst, (sra GR16:$src, CL))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001865def SAR32rCL : I<0xD3, MRM7r, (outs GR32:$dst), (ins GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001866 "sar{l}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001867 [(set GR32:$dst, (sra GR32:$src, CL))]>;
1868}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001869
Evan Chengb783fa32007-07-19 01:14:50 +00001870def SAR8ri : Ii8<0xC0, MRM7r, (outs GR8 :$dst), (ins GR8 :$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001871 "sar{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001872 [(set GR8:$dst, (sra GR8:$src1, (i8 imm:$src2)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001873def SAR16ri : Ii8<0xC1, MRM7r, (outs GR16:$dst), (ins GR16:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001874 "sar{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001875 [(set GR16:$dst, (sra GR16:$src1, (i8 imm:$src2)))]>,
1876 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001877def SAR32ri : Ii8<0xC1, MRM7r, (outs GR32:$dst), (ins GR32:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001878 "sar{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001879 [(set GR32:$dst, (sra GR32:$src1, (i8 imm:$src2)))]>;
1880
1881// Shift by 1
Evan Chengb783fa32007-07-19 01:14:50 +00001882def SAR8r1 : I<0xD0, MRM7r, (outs GR8 :$dst), (ins GR8 :$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00001883 "sar{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001884 [(set GR8:$dst, (sra GR8:$src1, (i8 1)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001885def SAR16r1 : I<0xD1, MRM7r, (outs GR16:$dst), (ins GR16:$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00001886 "sar{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001887 [(set GR16:$dst, (sra GR16:$src1, (i8 1)))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001888def SAR32r1 : I<0xD1, MRM7r, (outs GR32:$dst), (ins GR32:$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00001889 "sar{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001890 [(set GR32:$dst, (sra GR32:$src1, (i8 1)))]>;
1891
1892let isTwoAddress = 0 in {
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001893 let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00001894 def SAR8mCL : I<0xD2, MRM7m, (outs), (ins i8mem :$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001895 "sar{b}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001896 [(store (sra (loadi8 addr:$dst), CL), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001897 def SAR16mCL : I<0xD3, MRM7m, (outs), (ins i16mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001898 "sar{w}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001899 [(store (sra (loadi16 addr:$dst), CL), addr:$dst)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001900 def SAR32mCL : I<0xD3, MRM7m, (outs), (ins i32mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001901 "sar{l}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001902 [(store (sra (loadi32 addr:$dst), CL), addr:$dst)]>;
1903 }
Evan Chengb783fa32007-07-19 01:14:50 +00001904 def SAR8mi : Ii8<0xC0, MRM7m, (outs), (ins i8mem :$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001905 "sar{b}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001906 [(store (sra (loadi8 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001907 def SAR16mi : Ii8<0xC1, MRM7m, (outs), (ins i16mem:$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001908 "sar{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001909 [(store (sra (loadi16 addr:$dst), (i8 imm:$src)), addr:$dst)]>,
1910 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001911 def SAR32mi : Ii8<0xC1, MRM7m, (outs), (ins i32mem:$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001912 "sar{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001913 [(store (sra (loadi32 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
1914
1915 // Shift by 1
Evan Chengb783fa32007-07-19 01:14:50 +00001916 def SAR8m1 : I<0xD0, MRM7m, (outs), (ins i8mem :$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001917 "sar{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001918 [(store (sra (loadi8 addr:$dst), (i8 1)), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001919 def SAR16m1 : I<0xD1, MRM7m, (outs), (ins i16mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001920 "sar{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001921 [(store (sra (loadi16 addr:$dst), (i8 1)), addr:$dst)]>,
1922 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001923 def SAR32m1 : I<0xD1, MRM7m, (outs), (ins i32mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001924 "sar{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001925 [(store (sra (loadi32 addr:$dst), (i8 1)), addr:$dst)]>;
1926}
1927
1928// Rotate instructions
1929// FIXME: provide shorter instructions when imm8 == 1
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001930let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00001931def ROL8rCL : I<0xD2, MRM0r, (outs GR8 :$dst), (ins GR8 :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001932 "rol{b}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001933 [(set GR8:$dst, (rotl GR8:$src, CL))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001934def ROL16rCL : I<0xD3, MRM0r, (outs GR16:$dst), (ins GR16:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001935 "rol{w}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001936 [(set GR16:$dst, (rotl GR16:$src, CL))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001937def ROL32rCL : I<0xD3, MRM0r, (outs GR32:$dst), (ins GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001938 "rol{l}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001939 [(set GR32:$dst, (rotl GR32:$src, CL))]>;
1940}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001941
Evan Chengb783fa32007-07-19 01:14:50 +00001942def ROL8ri : Ii8<0xC0, MRM0r, (outs GR8 :$dst), (ins GR8 :$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001943 "rol{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001944 [(set GR8:$dst, (rotl GR8:$src1, (i8 imm:$src2)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001945def ROL16ri : Ii8<0xC1, MRM0r, (outs GR16:$dst), (ins GR16:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001946 "rol{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001947 [(set GR16:$dst, (rotl GR16:$src1, (i8 imm:$src2)))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001948def ROL32ri : Ii8<0xC1, MRM0r, (outs GR32:$dst), (ins GR32:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001949 "rol{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001950 [(set GR32:$dst, (rotl GR32:$src1, (i8 imm:$src2)))]>;
1951
1952// Rotate by 1
Evan Chengb783fa32007-07-19 01:14:50 +00001953def ROL8r1 : I<0xD0, MRM0r, (outs GR8 :$dst), (ins GR8 :$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00001954 "rol{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001955 [(set GR8:$dst, (rotl GR8:$src1, (i8 1)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001956def ROL16r1 : I<0xD1, MRM0r, (outs GR16:$dst), (ins GR16:$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00001957 "rol{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001958 [(set GR16:$dst, (rotl GR16:$src1, (i8 1)))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001959def ROL32r1 : I<0xD1, MRM0r, (outs GR32:$dst), (ins GR32:$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00001960 "rol{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001961 [(set GR32:$dst, (rotl GR32:$src1, (i8 1)))]>;
1962
1963let isTwoAddress = 0 in {
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001964 let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00001965 def ROL8mCL : I<0xD2, MRM0m, (outs), (ins i8mem :$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001966 "rol{b}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001967 [(store (rotl (loadi8 addr:$dst), CL), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001968 def ROL16mCL : I<0xD3, MRM0m, (outs), (ins i16mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001969 "rol{w}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001970 [(store (rotl (loadi16 addr:$dst), CL), addr:$dst)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001971 def ROL32mCL : I<0xD3, MRM0m, (outs), (ins i32mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001972 "rol{l}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001973 [(store (rotl (loadi32 addr:$dst), CL), addr:$dst)]>;
1974 }
Evan Chengb783fa32007-07-19 01:14:50 +00001975 def ROL8mi : Ii8<0xC0, MRM0m, (outs), (ins i8mem :$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001976 "rol{b}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001977 [(store (rotl (loadi8 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001978 def ROL16mi : Ii8<0xC1, MRM0m, (outs), (ins i16mem:$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001979 "rol{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001980 [(store (rotl (loadi16 addr:$dst), (i8 imm:$src)), addr:$dst)]>,
1981 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001982 def ROL32mi : Ii8<0xC1, MRM0m, (outs), (ins i32mem:$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001983 "rol{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001984 [(store (rotl (loadi32 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
1985
1986 // Rotate by 1
Evan Chengb783fa32007-07-19 01:14:50 +00001987 def ROL8m1 : I<0xD0, MRM0m, (outs), (ins i8mem :$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001988 "rol{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001989 [(store (rotl (loadi8 addr:$dst), (i8 1)), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001990 def ROL16m1 : I<0xD1, MRM0m, (outs), (ins i16mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001991 "rol{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001992 [(store (rotl (loadi16 addr:$dst), (i8 1)), addr:$dst)]>,
1993 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001994 def ROL32m1 : I<0xD1, MRM0m, (outs), (ins i32mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001995 "rol{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001996 [(store (rotl (loadi32 addr:$dst), (i8 1)), addr:$dst)]>;
1997}
1998
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001999let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00002000def ROR8rCL : I<0xD2, MRM1r, (outs GR8 :$dst), (ins GR8 :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002001 "ror{b}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002002 [(set GR8:$dst, (rotr GR8:$src, CL))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002003def ROR16rCL : I<0xD3, MRM1r, (outs GR16:$dst), (ins GR16:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002004 "ror{w}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002005 [(set GR16:$dst, (rotr GR16:$src, CL))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002006def ROR32rCL : I<0xD3, MRM1r, (outs GR32:$dst), (ins GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002007 "ror{l}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002008 [(set GR32:$dst, (rotr GR32:$src, CL))]>;
2009}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002010
Evan Chengb783fa32007-07-19 01:14:50 +00002011def ROR8ri : Ii8<0xC0, MRM1r, (outs GR8 :$dst), (ins GR8 :$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002012 "ror{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002013 [(set GR8:$dst, (rotr GR8:$src1, (i8 imm:$src2)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002014def ROR16ri : Ii8<0xC1, MRM1r, (outs GR16:$dst), (ins GR16:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002015 "ror{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002016 [(set GR16:$dst, (rotr GR16:$src1, (i8 imm:$src2)))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002017def ROR32ri : Ii8<0xC1, MRM1r, (outs GR32:$dst), (ins GR32:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002018 "ror{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002019 [(set GR32:$dst, (rotr GR32:$src1, (i8 imm:$src2)))]>;
2020
2021// Rotate by 1
Evan Chengb783fa32007-07-19 01:14:50 +00002022def ROR8r1 : I<0xD0, MRM1r, (outs GR8 :$dst), (ins GR8 :$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00002023 "ror{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002024 [(set GR8:$dst, (rotr GR8:$src1, (i8 1)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002025def ROR16r1 : I<0xD1, MRM1r, (outs GR16:$dst), (ins GR16:$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00002026 "ror{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002027 [(set GR16:$dst, (rotr GR16:$src1, (i8 1)))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002028def ROR32r1 : I<0xD1, MRM1r, (outs GR32:$dst), (ins GR32:$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00002029 "ror{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002030 [(set GR32:$dst, (rotr GR32:$src1, (i8 1)))]>;
2031
2032let isTwoAddress = 0 in {
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002033 let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00002034 def ROR8mCL : I<0xD2, MRM1m, (outs), (ins i8mem :$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002035 "ror{b}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002036 [(store (rotr (loadi8 addr:$dst), CL), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002037 def ROR16mCL : I<0xD3, MRM1m, (outs), (ins i16mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002038 "ror{w}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002039 [(store (rotr (loadi16 addr:$dst), CL), addr:$dst)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002040 def ROR32mCL : I<0xD3, MRM1m, (outs), (ins i32mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002041 "ror{l}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002042 [(store (rotr (loadi32 addr:$dst), CL), addr:$dst)]>;
2043 }
Evan Chengb783fa32007-07-19 01:14:50 +00002044 def ROR8mi : Ii8<0xC0, MRM1m, (outs), (ins i8mem :$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002045 "ror{b}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002046 [(store (rotr (loadi8 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002047 def ROR16mi : Ii8<0xC1, MRM1m, (outs), (ins i16mem:$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002048 "ror{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002049 [(store (rotr (loadi16 addr:$dst), (i8 imm:$src)), addr:$dst)]>,
2050 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002051 def ROR32mi : Ii8<0xC1, MRM1m, (outs), (ins i32mem:$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002052 "ror{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002053 [(store (rotr (loadi32 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
2054
2055 // Rotate by 1
Evan Chengb783fa32007-07-19 01:14:50 +00002056 def ROR8m1 : I<0xD0, MRM1m, (outs), (ins i8mem :$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002057 "ror{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002058 [(store (rotr (loadi8 addr:$dst), (i8 1)), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002059 def ROR16m1 : I<0xD1, MRM1m, (outs), (ins i16mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002060 "ror{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002061 [(store (rotr (loadi16 addr:$dst), (i8 1)), addr:$dst)]>,
2062 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002063 def ROR32m1 : I<0xD1, MRM1m, (outs), (ins i32mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002064 "ror{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002065 [(store (rotr (loadi32 addr:$dst), (i8 1)), addr:$dst)]>;
2066}
2067
2068
2069
2070// Double shift instructions (generalizations of rotate)
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002071let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00002072def SHLD32rrCL : I<0xA5, MRMDestReg, (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002073 "shld{l}\t{%cl, $src2, $dst|$dst, $src2, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002074 [(set GR32:$dst, (X86shld GR32:$src1, GR32:$src2, CL))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00002075def SHRD32rrCL : I<0xAD, MRMDestReg, (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002076 "shrd{l}\t{%cl, $src2, $dst|$dst, $src2, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002077 [(set GR32:$dst, (X86shrd GR32:$src1, GR32:$src2, CL))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00002078def SHLD16rrCL : I<0xA5, MRMDestReg, (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002079 "shld{w}\t{%cl, $src2, $dst|$dst, $src2, %CL}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002080 [(set GR16:$dst, (X86shld GR16:$src1, GR16:$src2, CL))]>,
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002081 TB, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002082def SHRD16rrCL : I<0xAD, MRMDestReg, (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002083 "shrd{w}\t{%cl, $src2, $dst|$dst, $src2, %CL}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002084 [(set GR16:$dst, (X86shrd GR16:$src1, GR16:$src2, CL))]>,
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002085 TB, OpSize;
2086}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002087
2088let isCommutable = 1 in { // These instructions commute to each other.
2089def SHLD32rri8 : Ii8<0xA4, MRMDestReg,
Evan Chengb783fa32007-07-19 01:14:50 +00002090 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2, i8imm:$src3),
Dan Gohman91888f02007-07-31 20:11:57 +00002091 "shld{l}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002092 [(set GR32:$dst, (X86shld GR32:$src1, GR32:$src2,
2093 (i8 imm:$src3)))]>,
2094 TB;
2095def SHRD32rri8 : Ii8<0xAC, MRMDestReg,
Evan Chengb783fa32007-07-19 01:14:50 +00002096 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2, i8imm:$src3),
Dan Gohman91888f02007-07-31 20:11:57 +00002097 "shrd{l}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002098 [(set GR32:$dst, (X86shrd GR32:$src1, GR32:$src2,
2099 (i8 imm:$src3)))]>,
2100 TB;
2101def SHLD16rri8 : Ii8<0xA4, MRMDestReg,
Evan Chengb783fa32007-07-19 01:14:50 +00002102 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2, i8imm:$src3),
Dan Gohman91888f02007-07-31 20:11:57 +00002103 "shld{w}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002104 [(set GR16:$dst, (X86shld GR16:$src1, GR16:$src2,
2105 (i8 imm:$src3)))]>,
2106 TB, OpSize;
2107def SHRD16rri8 : Ii8<0xAC, MRMDestReg,
Evan Chengb783fa32007-07-19 01:14:50 +00002108 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2, i8imm:$src3),
Dan Gohman91888f02007-07-31 20:11:57 +00002109 "shrd{w}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002110 [(set GR16:$dst, (X86shrd GR16:$src1, GR16:$src2,
2111 (i8 imm:$src3)))]>,
2112 TB, OpSize;
2113}
2114
2115let isTwoAddress = 0 in {
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002116 let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00002117 def SHLD32mrCL : I<0xA5, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002118 "shld{l}\t{%cl, $src2, $dst|$dst, $src2, %CL}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002119 [(store (X86shld (loadi32 addr:$dst), GR32:$src2, CL),
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002120 addr:$dst)]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00002121 def SHRD32mrCL : I<0xAD, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002122 "shrd{l}\t{%cl, $src2, $dst|$dst, $src2, %CL}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002123 [(store (X86shrd (loadi32 addr:$dst), GR32:$src2, CL),
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002124 addr:$dst)]>, TB;
2125 }
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002126 def SHLD32mri8 : Ii8<0xA4, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00002127 (outs), (ins i32mem:$dst, GR32:$src2, i8imm:$src3),
Dan Gohman91888f02007-07-31 20:11:57 +00002128 "shld{l}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002129 [(store (X86shld (loadi32 addr:$dst), GR32:$src2,
2130 (i8 imm:$src3)), addr:$dst)]>,
2131 TB;
2132 def SHRD32mri8 : Ii8<0xAC, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00002133 (outs), (ins i32mem:$dst, GR32:$src2, i8imm:$src3),
Dan Gohman91888f02007-07-31 20:11:57 +00002134 "shrd{l}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002135 [(store (X86shrd (loadi32 addr:$dst), GR32:$src2,
2136 (i8 imm:$src3)), addr:$dst)]>,
2137 TB;
2138
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002139 let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00002140 def SHLD16mrCL : I<0xA5, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002141 "shld{w}\t{%cl, $src2, $dst|$dst, $src2, %CL}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002142 [(store (X86shld (loadi16 addr:$dst), GR16:$src2, CL),
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002143 addr:$dst)]>, TB, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002144 def SHRD16mrCL : I<0xAD, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002145 "shrd{w}\t{%cl, $src2, $dst|$dst, $src2, %CL}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002146 [(store (X86shrd (loadi16 addr:$dst), GR16:$src2, CL),
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002147 addr:$dst)]>, TB, OpSize;
2148 }
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002149 def SHLD16mri8 : Ii8<0xA4, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00002150 (outs), (ins i16mem:$dst, GR16:$src2, i8imm:$src3),
Dan Gohman91888f02007-07-31 20:11:57 +00002151 "shld{w}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002152 [(store (X86shld (loadi16 addr:$dst), GR16:$src2,
2153 (i8 imm:$src3)), addr:$dst)]>,
2154 TB, OpSize;
2155 def SHRD16mri8 : Ii8<0xAC, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00002156 (outs), (ins i16mem:$dst, GR16:$src2, i8imm:$src3),
Dan Gohman91888f02007-07-31 20:11:57 +00002157 "shrd{w}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002158 [(store (X86shrd (loadi16 addr:$dst), GR16:$src2,
2159 (i8 imm:$src3)), addr:$dst)]>,
2160 TB, OpSize;
2161}
Evan Cheng55687072007-09-14 21:48:26 +00002162} // Defs = [EFLAGS]
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002163
2164
2165// Arithmetic.
Evan Cheng55687072007-09-14 21:48:26 +00002166let Defs = [EFLAGS] in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002167let isCommutable = 1 in { // X = ADD Y, Z --> X = ADD Z, Y
Bill Wendlingae034ed2008-12-12 00:56:36 +00002168// Register-Register Addition
2169def ADD8rr : I<0x00, MRMDestReg, (outs GR8 :$dst),
2170 (ins GR8 :$src1, GR8 :$src2),
2171 "add{b}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002172 [(set GR8:$dst, (add GR8:$src1, GR8:$src2)),
Bill Wendlingae034ed2008-12-12 00:56:36 +00002173 (implicit EFLAGS)]>;
2174
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002175let isConvertibleToThreeAddress = 1 in { // Can transform into LEA.
Bill Wendlingae034ed2008-12-12 00:56:36 +00002176// Register-Register Addition
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002177def ADD16rr : I<0x01, MRMDestReg, (outs GR16:$dst),
2178 (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002179 "add{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002180 [(set GR16:$dst, (add GR16:$src1, GR16:$src2)),
2181 (implicit EFLAGS)]>, OpSize;
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002182def ADD32rr : I<0x01, MRMDestReg, (outs GR32:$dst),
2183 (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002184 "add{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002185 [(set GR32:$dst, (add GR32:$src1, GR32:$src2)),
2186 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002187} // end isConvertibleToThreeAddress
2188} // end isCommutable
Bill Wendlingae034ed2008-12-12 00:56:36 +00002189
2190// Register-Memory Addition
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002191def ADD8rm : I<0x02, MRMSrcMem, (outs GR8 :$dst),
2192 (ins GR8 :$src1, i8mem :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002193 "add{b}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002194 [(set GR8:$dst, (add GR8:$src1, (load addr:$src2))),
2195 (implicit EFLAGS)]>;
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002196def ADD16rm : I<0x03, MRMSrcMem, (outs GR16:$dst),
2197 (ins GR16:$src1, i16mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002198 "add{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002199 [(set GR16:$dst, (add GR16:$src1, (load addr:$src2))),
2200 (implicit EFLAGS)]>, OpSize;
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002201def ADD32rm : I<0x03, MRMSrcMem, (outs GR32:$dst),
2202 (ins GR32:$src1, i32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002203 "add{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002204 [(set GR32:$dst, (add GR32:$src1, (load addr:$src2))),
2205 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002206
Bill Wendlingae034ed2008-12-12 00:56:36 +00002207// Register-Integer Addition
2208def ADD8ri : Ii8<0x80, MRM0r, (outs GR8:$dst), (ins GR8:$src1, i8imm:$src2),
2209 "add{b}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002210 [(set GR8:$dst, (add GR8:$src1, imm:$src2)),
2211 (implicit EFLAGS)]>;
Bill Wendlingae034ed2008-12-12 00:56:36 +00002212
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002213let isConvertibleToThreeAddress = 1 in { // Can transform into LEA.
Bill Wendlingae034ed2008-12-12 00:56:36 +00002214// Register-Integer Addition
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002215def ADD16ri : Ii16<0x81, MRM0r, (outs GR16:$dst),
2216 (ins GR16:$src1, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002217 "add{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002218 [(set GR16:$dst, (add GR16:$src1, imm:$src2)),
2219 (implicit EFLAGS)]>, OpSize;
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002220def ADD32ri : Ii32<0x81, MRM0r, (outs GR32:$dst),
2221 (ins GR32:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002222 "add{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002223 [(set GR32:$dst, (add GR32:$src1, imm:$src2)),
2224 (implicit EFLAGS)]>;
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002225def ADD16ri8 : Ii8<0x83, MRM0r, (outs GR16:$dst),
2226 (ins GR16:$src1, i16i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002227 "add{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002228 [(set GR16:$dst, (add GR16:$src1, i16immSExt8:$src2)),
2229 (implicit EFLAGS)]>, OpSize;
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002230def ADD32ri8 : Ii8<0x83, MRM0r, (outs GR32:$dst),
2231 (ins GR32:$src1, i32i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002232 "add{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002233 [(set GR32:$dst, (add GR32:$src1, i32immSExt8:$src2)),
2234 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002235}
2236
2237let isTwoAddress = 0 in {
Bill Wendlingae034ed2008-12-12 00:56:36 +00002238 // Memory-Register Addition
Bill Wendlingf5399032008-12-12 21:15:41 +00002239 def ADD8mr : I<0x00, MRMDestMem, (outs), (ins i8mem:$dst, GR8:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002240 "add{b}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002241 [(store (add (load addr:$dst), GR8:$src2), addr:$dst),
2242 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002243 def ADD16mr : I<0x01, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002244 "add{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002245 [(store (add (load addr:$dst), GR16:$src2), addr:$dst),
2246 (implicit EFLAGS)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002247 def ADD32mr : I<0x01, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002248 "add{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002249 [(store (add (load addr:$dst), GR32:$src2), addr:$dst),
2250 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002251 def ADD8mi : Ii8<0x80, MRM0m, (outs), (ins i8mem :$dst, i8imm :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002252 "add{b}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002253 [(store (add (loadi8 addr:$dst), imm:$src2), addr:$dst),
2254 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002255 def ADD16mi : Ii16<0x81, MRM0m, (outs), (ins i16mem:$dst, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002256 "add{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002257 [(store (add (loadi16 addr:$dst), imm:$src2), addr:$dst),
2258 (implicit EFLAGS)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002259 def ADD32mi : Ii32<0x81, MRM0m, (outs), (ins i32mem:$dst, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002260 "add{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002261 [(store (add (loadi32 addr:$dst), imm:$src2), addr:$dst),
2262 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002263 def ADD16mi8 : Ii8<0x83, MRM0m, (outs), (ins i16mem:$dst, i16i8imm :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002264 "add{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002265 [(store (add (load addr:$dst), i16immSExt8:$src2),
2266 addr:$dst),
2267 (implicit EFLAGS)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002268 def ADD32mi8 : Ii8<0x83, MRM0m, (outs), (ins i32mem:$dst, i32i8imm :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002269 "add{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingae034ed2008-12-12 00:56:36 +00002270 [(store (add (load addr:$dst), i32immSExt8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00002271 addr:$dst),
2272 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002273}
2274
Evan Cheng259471d2007-10-05 17:59:57 +00002275let Uses = [EFLAGS] in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002276let isCommutable = 1 in { // X = ADC Y, Z --> X = ADC Z, Y
Dale Johannesen06b83f12009-05-18 17:44:15 +00002277def ADC8rr : I<0x10, MRMDestReg, (outs GR8:$dst), (ins GR8:$src1, GR8:$src2),
2278 "adc{b}\t{$src2, $dst|$dst, $src2}",
2279 [(set GR8:$dst, (adde GR8:$src1, GR8:$src2))]>;
2280def ADC16rr : I<0x11, MRMDestReg, (outs GR16:$dst),
2281 (ins GR16:$src1, GR16:$src2),
2282 "adc{w}\t{$src2, $dst|$dst, $src2}",
2283 [(set GR16:$dst, (adde GR16:$src1, GR16:$src2))]>;
2284def ADC32rr : I<0x11, MRMDestReg, (outs GR32:$dst),
2285 (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002286 "adc{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingc0ca7f32008-12-01 23:44:08 +00002287 [(set GR32:$dst, (adde GR32:$src1, GR32:$src2))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002288}
Dale Johannesen06b83f12009-05-18 17:44:15 +00002289def ADC8rm : I<0x12, MRMSrcMem , (outs GR8:$dst),
2290 (ins GR8:$src1, i8mem:$src2),
2291 "adc{b}\t{$src2, $dst|$dst, $src2}",
2292 [(set GR8:$dst, (adde GR8:$src1, (load addr:$src2)))]>;
2293def ADC16rm : I<0x13, MRMSrcMem , (outs GR16:$dst),
2294 (ins GR16:$src1, i16mem:$src2),
2295 "adc{w}\t{$src2, $dst|$dst, $src2}",
2296 [(set GR16:$dst, (adde GR16:$src1, (load addr:$src2)))]>;
2297def ADC32rm : I<0x13, MRMSrcMem , (outs GR32:$dst),
2298 (ins GR32:$src1, i32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002299 "adc{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingc0ca7f32008-12-01 23:44:08 +00002300 [(set GR32:$dst, (adde GR32:$src1, (load addr:$src2)))]>;
Dale Johannesen06b83f12009-05-18 17:44:15 +00002301def ADC8ri : Ii8<0x80, MRM2r, (outs GR8:$dst), (ins GR8:$src1, i8imm:$src2),
2302 "adc{b}\t{$src2, $dst|$dst, $src2}",
2303 [(set GR8:$dst, (adde GR8:$src1, imm:$src2))]>;
2304def ADC16ri : Ii16<0x81, MRM2r, (outs GR16:$dst),
2305 (ins GR16:$src1, i16imm:$src2),
2306 "adc{w}\t{$src2, $dst|$dst, $src2}",
2307 [(set GR16:$dst, (adde GR16:$src1, imm:$src2))]>;
2308def ADC16ri8 : Ii8<0x83, MRM2r, (outs GR16:$dst),
2309 (ins GR16:$src1, i16i8imm:$src2),
2310 "adc{w}\t{$src2, $dst|$dst, $src2}",
2311 [(set GR16:$dst, (adde GR16:$src1, i16immSExt8:$src2))]>;
2312def ADC32ri : Ii32<0x81, MRM2r, (outs GR32:$dst),
2313 (ins GR32:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002314 "adc{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingc0ca7f32008-12-01 23:44:08 +00002315 [(set GR32:$dst, (adde GR32:$src1, imm:$src2))]>;
Dale Johannesen06b83f12009-05-18 17:44:15 +00002316def ADC32ri8 : Ii8<0x83, MRM2r, (outs GR32:$dst),
2317 (ins GR32:$src1, i32i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002318 "adc{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingc0ca7f32008-12-01 23:44:08 +00002319 [(set GR32:$dst, (adde GR32:$src1, i32immSExt8:$src2))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002320
2321let isTwoAddress = 0 in {
Dale Johannesen06b83f12009-05-18 17:44:15 +00002322 def ADC8mr : I<0x10, MRMDestMem, (outs), (ins i8mem:$dst, GR8:$src2),
2323 "adc{b}\t{$src2, $dst|$dst, $src2}",
2324 [(store (adde (load addr:$dst), GR8:$src2), addr:$dst)]>;
2325 def ADC16mr : I<0x11, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
2326 "adc{w}\t{$src2, $dst|$dst, $src2}",
2327 [(store (adde (load addr:$dst), GR16:$src2), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002328 def ADC32mr : I<0x11, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002329 "adc{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingc0ca7f32008-12-01 23:44:08 +00002330 [(store (adde (load addr:$dst), GR32:$src2), addr:$dst)]>;
Dale Johannesen06b83f12009-05-18 17:44:15 +00002331 def ADC8mi : Ii8<0x80, MRM2m, (outs), (ins i8mem:$dst, i8imm:$src2),
2332 "adc{b}\t{$src2, $dst|$dst, $src2}",
2333 [(store (adde (loadi8 addr:$dst), imm:$src2), addr:$dst)]>;
2334 def ADC16mi : Ii16<0x81, MRM2m, (outs), (ins i16mem:$dst, i16imm:$src2),
2335 "adc{w}\t{$src2, $dst|$dst, $src2}",
2336 [(store (adde (loadi16 addr:$dst), imm:$src2), addr:$dst)]>;
2337 def ADC16mi8 : Ii8<0x83, MRM2m, (outs), (ins i16mem:$dst, i16i8imm :$src2),
2338 "adc{w}\t{$src2, $dst|$dst, $src2}",
2339 [(store (adde (load addr:$dst), i16immSExt8:$src2), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002340 def ADC32mi : Ii32<0x81, MRM2m, (outs), (ins i32mem:$dst, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002341 "adc{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingc0ca7f32008-12-01 23:44:08 +00002342 [(store (adde (loadi32 addr:$dst), imm:$src2), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002343 def ADC32mi8 : Ii8<0x83, MRM2m, (outs), (ins i32mem:$dst, i32i8imm :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002344 "adc{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendling0c52d0a2008-12-02 00:07:05 +00002345 [(store (adde (load addr:$dst), i32immSExt8:$src2), addr:$dst)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002346}
Evan Cheng259471d2007-10-05 17:59:57 +00002347} // Uses = [EFLAGS]
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002348
Bill Wendlingae034ed2008-12-12 00:56:36 +00002349// Register-Register Subtraction
2350def SUB8rr : I<0x28, MRMDestReg, (outs GR8:$dst), (ins GR8:$src1, GR8:$src2),
2351 "sub{b}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002352 [(set GR8:$dst, (sub GR8:$src1, GR8:$src2)),
2353 (implicit EFLAGS)]>;
Bill Wendlingae034ed2008-12-12 00:56:36 +00002354def SUB16rr : I<0x29, MRMDestReg, (outs GR16:$dst), (ins GR16:$src1,GR16:$src2),
2355 "sub{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002356 [(set GR16:$dst, (sub GR16:$src1, GR16:$src2)),
2357 (implicit EFLAGS)]>, OpSize;
Bill Wendlingae034ed2008-12-12 00:56:36 +00002358def SUB32rr : I<0x29, MRMDestReg, (outs GR32:$dst), (ins GR32:$src1,GR32:$src2),
2359 "sub{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002360 [(set GR32:$dst, (sub GR32:$src1, GR32:$src2)),
2361 (implicit EFLAGS)]>;
Bill Wendlingae034ed2008-12-12 00:56:36 +00002362
2363// Register-Memory Subtraction
2364def SUB8rm : I<0x2A, MRMSrcMem, (outs GR8 :$dst),
2365 (ins GR8 :$src1, i8mem :$src2),
2366 "sub{b}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002367 [(set GR8:$dst, (sub GR8:$src1, (load addr:$src2))),
2368 (implicit EFLAGS)]>;
Bill Wendlingae034ed2008-12-12 00:56:36 +00002369def SUB16rm : I<0x2B, MRMSrcMem, (outs GR16:$dst),
2370 (ins GR16:$src1, i16mem:$src2),
2371 "sub{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002372 [(set GR16:$dst, (sub GR16:$src1, (load addr:$src2))),
2373 (implicit EFLAGS)]>, OpSize;
Bill Wendlingae034ed2008-12-12 00:56:36 +00002374def SUB32rm : I<0x2B, MRMSrcMem, (outs GR32:$dst),
2375 (ins GR32:$src1, i32mem:$src2),
2376 "sub{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002377 [(set GR32:$dst, (sub GR32:$src1, (load addr:$src2))),
2378 (implicit EFLAGS)]>;
Bill Wendlingae034ed2008-12-12 00:56:36 +00002379
2380// Register-Integer Subtraction
2381def SUB8ri : Ii8 <0x80, MRM5r, (outs GR8:$dst),
2382 (ins GR8:$src1, i8imm:$src2),
2383 "sub{b}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002384 [(set GR8:$dst, (sub GR8:$src1, imm:$src2)),
2385 (implicit EFLAGS)]>;
Bill Wendlingae034ed2008-12-12 00:56:36 +00002386def SUB16ri : Ii16<0x81, MRM5r, (outs GR16:$dst),
2387 (ins GR16:$src1, i16imm:$src2),
2388 "sub{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002389 [(set GR16:$dst, (sub GR16:$src1, imm:$src2)),
2390 (implicit EFLAGS)]>, OpSize;
Bill Wendlingae034ed2008-12-12 00:56:36 +00002391def SUB32ri : Ii32<0x81, MRM5r, (outs GR32:$dst),
2392 (ins GR32:$src1, i32imm:$src2),
2393 "sub{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002394 [(set GR32:$dst, (sub GR32:$src1, imm:$src2)),
2395 (implicit EFLAGS)]>;
Bill Wendlingae034ed2008-12-12 00:56:36 +00002396def SUB16ri8 : Ii8<0x83, MRM5r, (outs GR16:$dst),
2397 (ins GR16:$src1, i16i8imm:$src2),
2398 "sub{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002399 [(set GR16:$dst, (sub GR16:$src1, i16immSExt8:$src2)),
2400 (implicit EFLAGS)]>, OpSize;
Bill Wendlingae034ed2008-12-12 00:56:36 +00002401def SUB32ri8 : Ii8<0x83, MRM5r, (outs GR32:$dst),
2402 (ins GR32:$src1, i32i8imm:$src2),
2403 "sub{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002404 [(set GR32:$dst, (sub GR32:$src1, i32immSExt8:$src2)),
2405 (implicit EFLAGS)]>;
Bill Wendlingae034ed2008-12-12 00:56:36 +00002406
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002407let isTwoAddress = 0 in {
Bill Wendlingae034ed2008-12-12 00:56:36 +00002408 // Memory-Register Subtraction
Evan Chengb783fa32007-07-19 01:14:50 +00002409 def SUB8mr : I<0x28, MRMDestMem, (outs), (ins i8mem :$dst, GR8 :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002410 "sub{b}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002411 [(store (sub (load addr:$dst), GR8:$src2), addr:$dst),
2412 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002413 def SUB16mr : I<0x29, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002414 "sub{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002415 [(store (sub (load addr:$dst), GR16:$src2), addr:$dst),
2416 (implicit EFLAGS)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002417 def SUB32mr : I<0x29, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002418 "sub{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002419 [(store (sub (load addr:$dst), GR32:$src2), addr:$dst),
2420 (implicit EFLAGS)]>;
Bill Wendlingae034ed2008-12-12 00:56:36 +00002421
2422 // Memory-Integer Subtraction
Evan Chengb783fa32007-07-19 01:14:50 +00002423 def SUB8mi : Ii8<0x80, MRM5m, (outs), (ins i8mem :$dst, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002424 "sub{b}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002425 [(store (sub (loadi8 addr:$dst), imm:$src2), addr:$dst),
2426 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002427 def SUB16mi : Ii16<0x81, MRM5m, (outs), (ins i16mem:$dst, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002428 "sub{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002429 [(store (sub (loadi16 addr:$dst), imm:$src2),addr:$dst),
2430 (implicit EFLAGS)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002431 def SUB32mi : Ii32<0x81, MRM5m, (outs), (ins i32mem:$dst, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002432 "sub{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002433 [(store (sub (loadi32 addr:$dst), imm:$src2),addr:$dst),
2434 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002435 def SUB16mi8 : Ii8<0x83, MRM5m, (outs), (ins i16mem:$dst, i16i8imm :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002436 "sub{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingae034ed2008-12-12 00:56:36 +00002437 [(store (sub (load addr:$dst), i16immSExt8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00002438 addr:$dst),
2439 (implicit EFLAGS)]>, OpSize;
Bill Wendlingae034ed2008-12-12 00:56:36 +00002440 def SUB32mi8 : Ii8<0x83, MRM5m, (outs), (ins i32mem:$dst, i32i8imm :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002441 "sub{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingae034ed2008-12-12 00:56:36 +00002442 [(store (sub (load addr:$dst), i32immSExt8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00002443 addr:$dst),
2444 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002445}
2446
Evan Cheng259471d2007-10-05 17:59:57 +00002447let Uses = [EFLAGS] in {
Dale Johannesen06b83f12009-05-18 17:44:15 +00002448def SBB8rr : I<0x18, MRMDestReg, (outs GR8:$dst),
2449 (ins GR8:$src1, GR8:$src2),
2450 "sbb{b}\t{$src2, $dst|$dst, $src2}",
2451 [(set GR8:$dst, (sube GR8:$src1, GR8:$src2))]>;
2452def SBB16rr : I<0x19, MRMDestReg, (outs GR16:$dst),
2453 (ins GR16:$src1, GR16:$src2),
2454 "sbb{w}\t{$src2, $dst|$dst, $src2}",
2455 [(set GR16:$dst, (sube GR16:$src1, GR16:$src2))]>;
2456def SBB32rr : I<0x19, MRMDestReg, (outs GR32:$dst),
2457 (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002458 "sbb{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng55687072007-09-14 21:48:26 +00002459 [(set GR32:$dst, (sube GR32:$src1, GR32:$src2))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002460
2461let isTwoAddress = 0 in {
Dale Johannesen06b83f12009-05-18 17:44:15 +00002462 def SBB8mr : I<0x18, MRMDestMem, (outs), (ins i8mem:$dst, GR8:$src2),
2463 "sbb{b}\t{$src2, $dst|$dst, $src2}",
2464 [(store (sube (load addr:$dst), GR8:$src2), addr:$dst)]>;
2465 def SBB16mr : I<0x19, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
2466 "sbb{w}\t{$src2, $dst|$dst, $src2}",
2467 [(store (sube (load addr:$dst), GR16:$src2), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002468 def SBB32mr : I<0x19, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002469 "sbb{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002470 [(store (sube (load addr:$dst), GR32:$src2), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002471 def SBB8mi : Ii32<0x80, MRM3m, (outs), (ins i8mem:$dst, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002472 "sbb{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002473 [(store (sube (loadi8 addr:$dst), imm:$src2), addr:$dst)]>;
Dale Johannesen06b83f12009-05-18 17:44:15 +00002474 def SBB16mi : Ii16<0x81, MRM3m, (outs), (ins i16mem:$dst, i16imm:$src2),
2475 "sbb{w}\t{$src2, $dst|$dst, $src2}",
2476 [(store (sube (loadi16 addr:$dst), imm:$src2), addr:$dst)]>;
2477 def SBB16mi8 : Ii8<0x83, MRM3m, (outs), (ins i16mem:$dst, i16i8imm :$src2),
2478 "sbb{w}\t{$src2, $dst|$dst, $src2}",
2479 [(store (sube (load addr:$dst), i16immSExt8:$src2), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002480 def SBB32mi : Ii32<0x81, MRM3m, (outs), (ins i32mem:$dst, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002481 "sbb{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002482 [(store (sube (loadi32 addr:$dst), imm:$src2), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002483 def SBB32mi8 : Ii8<0x83, MRM3m, (outs), (ins i32mem:$dst, i32i8imm :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002484 "sbb{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng55687072007-09-14 21:48:26 +00002485 [(store (sube (load addr:$dst), i32immSExt8:$src2), addr:$dst)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002486}
Dale Johannesen06b83f12009-05-18 17:44:15 +00002487def SBB8rm : I<0x1A, MRMSrcMem, (outs GR8:$dst), (ins GR8:$src1, i8mem:$src2),
2488 "sbb{b}\t{$src2, $dst|$dst, $src2}",
2489 [(set GR8:$dst, (sube GR8:$src1, (load addr:$src2)))]>;
2490def SBB16rm : I<0x1B, MRMSrcMem, (outs GR16:$dst),
2491 (ins GR16:$src1, i16mem:$src2),
2492 "sbb{w}\t{$src2, $dst|$dst, $src2}",
2493 [(set GR16:$dst, (sube GR16:$src1, (load addr:$src2)))]>;
2494def SBB32rm : I<0x1B, MRMSrcMem, (outs GR32:$dst),
2495 (ins GR32:$src1, i32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002496 "sbb{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002497 [(set GR32:$dst, (sube GR32:$src1, (load addr:$src2)))]>;
Dale Johannesen06b83f12009-05-18 17:44:15 +00002498def SBB8ri : Ii8<0x80, MRM3r, (outs GR8:$dst), (ins GR8:$src1, i8imm:$src2),
2499 "sbb{b}\t{$src2, $dst|$dst, $src2}",
2500 [(set GR8:$dst, (sube GR8:$src1, imm:$src2))]>;
2501def SBB16ri : Ii16<0x81, MRM3r, (outs GR16:$dst),
2502 (ins GR16:$src1, i16imm:$src2),
2503 "sbb{w}\t{$src2, $dst|$dst, $src2}",
2504 [(set GR16:$dst, (sube GR16:$src1, imm:$src2))]>;
2505def SBB16ri8 : Ii8<0x83, MRM3r, (outs GR16:$dst),
2506 (ins GR16:$src1, i16i8imm:$src2),
2507 "sbb{w}\t{$src2, $dst|$dst, $src2}",
2508 [(set GR16:$dst, (sube GR16:$src1, i16immSExt8:$src2))]>;
2509def SBB32ri : Ii32<0x81, MRM3r, (outs GR32:$dst),
2510 (ins GR32:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002511 "sbb{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002512 [(set GR32:$dst, (sube GR32:$src1, imm:$src2))]>;
Dale Johannesen06b83f12009-05-18 17:44:15 +00002513def SBB32ri8 : Ii8<0x83, MRM3r, (outs GR32:$dst),
2514 (ins GR32:$src1, i32i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002515 "sbb{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002516 [(set GR32:$dst, (sube GR32:$src1, i32immSExt8:$src2))]>;
Evan Cheng259471d2007-10-05 17:59:57 +00002517} // Uses = [EFLAGS]
Evan Cheng55687072007-09-14 21:48:26 +00002518} // Defs = [EFLAGS]
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002519
Evan Cheng55687072007-09-14 21:48:26 +00002520let Defs = [EFLAGS] in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002521let isCommutable = 1 in { // X = IMUL Y, Z --> X = IMUL Z, Y
Bill Wendlingf5399032008-12-12 21:15:41 +00002522// Register-Register Signed Integer Multiply
Bill Wendlingae034ed2008-12-12 00:56:36 +00002523def IMUL16rr : I<0xAF, MRMSrcReg, (outs GR16:$dst), (ins GR16:$src1,GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002524 "imul{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002525 [(set GR16:$dst, (mul GR16:$src1, GR16:$src2)),
2526 (implicit EFLAGS)]>, TB, OpSize;
Bill Wendlingae034ed2008-12-12 00:56:36 +00002527def IMUL32rr : I<0xAF, MRMSrcReg, (outs GR32:$dst), (ins GR32:$src1,GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002528 "imul{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002529 [(set GR32:$dst, (mul GR32:$src1, GR32:$src2)),
2530 (implicit EFLAGS)]>, TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002531}
Bill Wendlingae034ed2008-12-12 00:56:36 +00002532
Bill Wendlingf5399032008-12-12 21:15:41 +00002533// Register-Memory Signed Integer Multiply
Bill Wendlingae034ed2008-12-12 00:56:36 +00002534def IMUL16rm : I<0xAF, MRMSrcMem, (outs GR16:$dst),
2535 (ins GR16:$src1, i16mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002536 "imul{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002537 [(set GR16:$dst, (mul GR16:$src1, (load addr:$src2))),
2538 (implicit EFLAGS)]>, TB, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002539def IMUL32rm : I<0xAF, MRMSrcMem, (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002540 "imul{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002541 [(set GR32:$dst, (mul GR32:$src1, (load addr:$src2))),
2542 (implicit EFLAGS)]>, TB;
Evan Cheng55687072007-09-14 21:48:26 +00002543} // Defs = [EFLAGS]
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002544} // end Two Address instructions
2545
2546// Suprisingly enough, these are not two address instructions!
Evan Cheng55687072007-09-14 21:48:26 +00002547let Defs = [EFLAGS] in {
Bill Wendlingf5399032008-12-12 21:15:41 +00002548// Register-Integer Signed Integer Multiply
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002549def IMUL16rri : Ii16<0x69, MRMSrcReg, // GR16 = GR16*I16
Evan Chengb783fa32007-07-19 01:14:50 +00002550 (outs GR16:$dst), (ins GR16:$src1, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002551 "imul{w}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002552 [(set GR16:$dst, (mul GR16:$src1, imm:$src2)),
2553 (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002554def IMUL32rri : Ii32<0x69, MRMSrcReg, // GR32 = GR32*I32
Evan Chengb783fa32007-07-19 01:14:50 +00002555 (outs GR32:$dst), (ins GR32:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002556 "imul{l}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002557 [(set GR32:$dst, (mul GR32:$src1, imm:$src2)),
2558 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002559def IMUL16rri8 : Ii8<0x6B, MRMSrcReg, // GR16 = GR16*I8
Evan Chengb783fa32007-07-19 01:14:50 +00002560 (outs GR16:$dst), (ins GR16:$src1, i16i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002561 "imul{w}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002562 [(set GR16:$dst, (mul GR16:$src1, i16immSExt8:$src2)),
2563 (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002564def IMUL32rri8 : Ii8<0x6B, MRMSrcReg, // GR32 = GR32*I8
Evan Chengb783fa32007-07-19 01:14:50 +00002565 (outs GR32:$dst), (ins GR32:$src1, i32i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002566 "imul{l}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002567 [(set GR32:$dst, (mul GR32:$src1, i32immSExt8:$src2)),
2568 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002569
Bill Wendlingf5399032008-12-12 21:15:41 +00002570// Memory-Integer Signed Integer Multiply
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002571def IMUL16rmi : Ii16<0x69, MRMSrcMem, // GR16 = [mem16]*I16
Evan Chengb783fa32007-07-19 01:14:50 +00002572 (outs GR16:$dst), (ins i16mem:$src1, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002573 "imul{w}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002574 [(set GR16:$dst, (mul (load addr:$src1), imm:$src2)),
2575 (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002576def IMUL32rmi : Ii32<0x69, MRMSrcMem, // GR32 = [mem32]*I32
Evan Chengb783fa32007-07-19 01:14:50 +00002577 (outs GR32:$dst), (ins i32mem:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002578 "imul{l}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002579 [(set GR32:$dst, (mul (load addr:$src1), imm:$src2)),
2580 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002581def IMUL16rmi8 : Ii8<0x6B, MRMSrcMem, // GR16 = [mem16]*I8
Evan Chengb783fa32007-07-19 01:14:50 +00002582 (outs GR16:$dst), (ins i16mem:$src1, i16i8imm :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002583 "imul{w}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Bill Wendlingae034ed2008-12-12 00:56:36 +00002584 [(set GR16:$dst, (mul (load addr:$src1),
Bill Wendlingf5399032008-12-12 21:15:41 +00002585 i16immSExt8:$src2)),
2586 (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002587def IMUL32rmi8 : Ii8<0x6B, MRMSrcMem, // GR32 = [mem32]*I8
Evan Chengb783fa32007-07-19 01:14:50 +00002588 (outs GR32:$dst), (ins i32mem:$src1, i32i8imm: $src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002589 "imul{l}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Bill Wendlingae034ed2008-12-12 00:56:36 +00002590 [(set GR32:$dst, (mul (load addr:$src1),
Bill Wendlingf5399032008-12-12 21:15:41 +00002591 i32immSExt8:$src2)),
2592 (implicit EFLAGS)]>;
Evan Cheng55687072007-09-14 21:48:26 +00002593} // Defs = [EFLAGS]
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002594
2595//===----------------------------------------------------------------------===//
2596// Test instructions are just like AND, except they don't generate a result.
2597//
Evan Cheng950aac02007-09-25 01:57:46 +00002598let Defs = [EFLAGS] in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002599let isCommutable = 1 in { // TEST X, Y --> TEST Y, X
Evan Chengb783fa32007-07-19 01:14:50 +00002600def TEST8rr : I<0x84, MRMDestReg, (outs), (ins GR8:$src1, GR8:$src2),
Evan Cheng621216e2007-09-29 00:00:36 +00002601 "test{b}\t{$src2, $src1|$src1, $src2}",
Chris Lattner21da6382008-02-19 17:37:35 +00002602 [(X86cmp (and_su GR8:$src1, GR8:$src2), 0),
Evan Cheng621216e2007-09-29 00:00:36 +00002603 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002604def TEST16rr : I<0x85, MRMDestReg, (outs), (ins GR16:$src1, GR16:$src2),
Evan Cheng621216e2007-09-29 00:00:36 +00002605 "test{w}\t{$src2, $src1|$src1, $src2}",
Chris Lattner21da6382008-02-19 17:37:35 +00002606 [(X86cmp (and_su GR16:$src1, GR16:$src2), 0),
Evan Cheng621216e2007-09-29 00:00:36 +00002607 (implicit EFLAGS)]>,
2608 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002609def TEST32rr : I<0x85, MRMDestReg, (outs), (ins GR32:$src1, GR32:$src2),
Evan Cheng621216e2007-09-29 00:00:36 +00002610 "test{l}\t{$src2, $src1|$src1, $src2}",
Chris Lattner21da6382008-02-19 17:37:35 +00002611 [(X86cmp (and_su GR32:$src1, GR32:$src2), 0),
Evan Cheng621216e2007-09-29 00:00:36 +00002612 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002613}
2614
Evan Chengb783fa32007-07-19 01:14:50 +00002615def TEST8rm : I<0x84, MRMSrcMem, (outs), (ins GR8 :$src1, i8mem :$src2),
Evan Cheng621216e2007-09-29 00:00:36 +00002616 "test{b}\t{$src2, $src1|$src1, $src2}",
2617 [(X86cmp (and GR8:$src1, (loadi8 addr:$src2)), 0),
2618 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002619def TEST16rm : I<0x85, MRMSrcMem, (outs), (ins GR16:$src1, i16mem:$src2),
Evan Cheng621216e2007-09-29 00:00:36 +00002620 "test{w}\t{$src2, $src1|$src1, $src2}",
2621 [(X86cmp (and GR16:$src1, (loadi16 addr:$src2)), 0),
2622 (implicit EFLAGS)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002623def TEST32rm : I<0x85, MRMSrcMem, (outs), (ins GR32:$src1, i32mem:$src2),
Evan Cheng621216e2007-09-29 00:00:36 +00002624 "test{l}\t{$src2, $src1|$src1, $src2}",
2625 [(X86cmp (and GR32:$src1, (loadi32 addr:$src2)), 0),
2626 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002627
2628def TEST8ri : Ii8 <0xF6, MRM0r, // flags = GR8 & imm8
Evan Chengb783fa32007-07-19 01:14:50 +00002629 (outs), (ins GR8:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002630 "test{b}\t{$src2, $src1|$src1, $src2}",
Chris Lattner21da6382008-02-19 17:37:35 +00002631 [(X86cmp (and_su GR8:$src1, imm:$src2), 0),
Evan Cheng621216e2007-09-29 00:00:36 +00002632 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002633def TEST16ri : Ii16<0xF7, MRM0r, // flags = GR16 & imm16
Evan Chengb783fa32007-07-19 01:14:50 +00002634 (outs), (ins GR16:$src1, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002635 "test{w}\t{$src2, $src1|$src1, $src2}",
Chris Lattner21da6382008-02-19 17:37:35 +00002636 [(X86cmp (and_su GR16:$src1, imm:$src2), 0),
Evan Cheng621216e2007-09-29 00:00:36 +00002637 (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002638def TEST32ri : Ii32<0xF7, MRM0r, // flags = GR32 & imm32
Evan Chengb783fa32007-07-19 01:14:50 +00002639 (outs), (ins GR32:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002640 "test{l}\t{$src2, $src1|$src1, $src2}",
Chris Lattner21da6382008-02-19 17:37:35 +00002641 [(X86cmp (and_su GR32:$src1, imm:$src2), 0),
Evan Cheng621216e2007-09-29 00:00:36 +00002642 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002643
Evan Cheng621216e2007-09-29 00:00:36 +00002644def TEST8mi : Ii8 <0xF6, MRM0m, // flags = [mem8] & imm8
Evan Chengb783fa32007-07-19 01:14:50 +00002645 (outs), (ins i8mem:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002646 "test{b}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002647 [(X86cmp (and (loadi8 addr:$src1), imm:$src2), 0),
2648 (implicit EFLAGS)]>;
2649def TEST16mi : Ii16<0xF7, MRM0m, // flags = [mem16] & imm16
Evan Chengb783fa32007-07-19 01:14:50 +00002650 (outs), (ins i16mem:$src1, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002651 "test{w}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002652 [(X86cmp (and (loadi16 addr:$src1), imm:$src2), 0),
2653 (implicit EFLAGS)]>, OpSize;
2654def TEST32mi : Ii32<0xF7, MRM0m, // flags = [mem32] & imm32
Evan Chengb783fa32007-07-19 01:14:50 +00002655 (outs), (ins i32mem:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002656 "test{l}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002657 [(X86cmp (and (loadi32 addr:$src1), imm:$src2), 0),
Evan Cheng950aac02007-09-25 01:57:46 +00002658 (implicit EFLAGS)]>;
2659} // Defs = [EFLAGS]
2660
2661
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002662// Condition code ops, incl. set if equal/not equal/...
Chris Lattnerc90ee9c2008-01-10 07:59:24 +00002663let Defs = [EFLAGS], Uses = [AH], neverHasSideEffects = 1 in
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002664def SAHF : I<0x9E, RawFrm, (outs), (ins), "sahf", []>; // flags = AH
Chris Lattnerc90ee9c2008-01-10 07:59:24 +00002665let Defs = [AH], Uses = [EFLAGS], neverHasSideEffects = 1 in
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002666def LAHF : I<0x9F, RawFrm, (outs), (ins), "lahf", []>; // AH = flags
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002667
Evan Cheng950aac02007-09-25 01:57:46 +00002668let Uses = [EFLAGS] in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002669def SETEr : I<0x94, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00002670 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002671 "sete\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002672 [(set GR8:$dst, (X86setcc X86_COND_E, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002673 TB; // GR8 = ==
2674def SETEm : I<0x94, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00002675 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002676 "sete\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002677 [(store (X86setcc X86_COND_E, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002678 TB; // [mem8] = ==
Bill Wendling0c52d0a2008-12-02 00:07:05 +00002679
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002680def SETNEr : I<0x95, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00002681 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002682 "setne\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002683 [(set GR8:$dst, (X86setcc X86_COND_NE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002684 TB; // GR8 = !=
2685def SETNEm : I<0x95, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00002686 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002687 "setne\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002688 [(store (X86setcc X86_COND_NE, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002689 TB; // [mem8] = !=
Bill Wendling0c52d0a2008-12-02 00:07:05 +00002690
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002691def SETLr : I<0x9C, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00002692 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002693 "setl\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002694 [(set GR8:$dst, (X86setcc X86_COND_L, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002695 TB; // GR8 = < signed
2696def SETLm : I<0x9C, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00002697 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002698 "setl\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002699 [(store (X86setcc X86_COND_L, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002700 TB; // [mem8] = < signed
Bill Wendling0c52d0a2008-12-02 00:07:05 +00002701
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002702def SETGEr : I<0x9D, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00002703 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002704 "setge\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002705 [(set GR8:$dst, (X86setcc X86_COND_GE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002706 TB; // GR8 = >= signed
2707def SETGEm : I<0x9D, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00002708 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002709 "setge\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002710 [(store (X86setcc X86_COND_GE, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002711 TB; // [mem8] = >= signed
Bill Wendling0c52d0a2008-12-02 00:07:05 +00002712
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002713def SETLEr : I<0x9E, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00002714 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002715 "setle\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002716 [(set GR8:$dst, (X86setcc X86_COND_LE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002717 TB; // GR8 = <= signed
2718def SETLEm : I<0x9E, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00002719 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002720 "setle\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002721 [(store (X86setcc X86_COND_LE, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002722 TB; // [mem8] = <= signed
Bill Wendling0c52d0a2008-12-02 00:07:05 +00002723
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002724def SETGr : I<0x9F, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00002725 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002726 "setg\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002727 [(set GR8:$dst, (X86setcc X86_COND_G, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002728 TB; // GR8 = > signed
2729def SETGm : I<0x9F, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00002730 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002731 "setg\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002732 [(store (X86setcc X86_COND_G, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002733 TB; // [mem8] = > signed
2734
2735def SETBr : I<0x92, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00002736 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002737 "setb\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002738 [(set GR8:$dst, (X86setcc X86_COND_B, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002739 TB; // GR8 = < unsign
2740def SETBm : I<0x92, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00002741 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002742 "setb\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002743 [(store (X86setcc X86_COND_B, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002744 TB; // [mem8] = < unsign
Bill Wendling0c52d0a2008-12-02 00:07:05 +00002745
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002746def SETAEr : I<0x93, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00002747 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002748 "setae\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002749 [(set GR8:$dst, (X86setcc X86_COND_AE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002750 TB; // GR8 = >= unsign
2751def SETAEm : I<0x93, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00002752 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002753 "setae\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002754 [(store (X86setcc X86_COND_AE, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002755 TB; // [mem8] = >= unsign
Bill Wendling0c52d0a2008-12-02 00:07:05 +00002756
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002757def SETBEr : I<0x96, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00002758 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002759 "setbe\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002760 [(set GR8:$dst, (X86setcc X86_COND_BE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002761 TB; // GR8 = <= unsign
2762def SETBEm : I<0x96, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00002763 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002764 "setbe\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002765 [(store (X86setcc X86_COND_BE, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002766 TB; // [mem8] = <= unsign
Bill Wendling0c52d0a2008-12-02 00:07:05 +00002767
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002768def SETAr : I<0x97, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00002769 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002770 "seta\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002771 [(set GR8:$dst, (X86setcc X86_COND_A, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002772 TB; // GR8 = > signed
2773def SETAm : I<0x97, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00002774 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002775 "seta\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002776 [(store (X86setcc X86_COND_A, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002777 TB; // [mem8] = > signed
2778
2779def SETSr : I<0x98, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00002780 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002781 "sets\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002782 [(set GR8:$dst, (X86setcc X86_COND_S, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002783 TB; // GR8 = <sign bit>
2784def SETSm : I<0x98, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00002785 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002786 "sets\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002787 [(store (X86setcc X86_COND_S, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002788 TB; // [mem8] = <sign bit>
2789def SETNSr : I<0x99, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00002790 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002791 "setns\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002792 [(set GR8:$dst, (X86setcc X86_COND_NS, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002793 TB; // GR8 = !<sign bit>
2794def SETNSm : I<0x99, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00002795 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002796 "setns\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002797 [(store (X86setcc X86_COND_NS, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002798 TB; // [mem8] = !<sign bit>
Bill Wendling0c52d0a2008-12-02 00:07:05 +00002799
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002800def SETPr : I<0x9A, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00002801 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002802 "setp\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002803 [(set GR8:$dst, (X86setcc X86_COND_P, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002804 TB; // GR8 = parity
2805def SETPm : I<0x9A, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00002806 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002807 "setp\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002808 [(store (X86setcc X86_COND_P, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002809 TB; // [mem8] = parity
2810def SETNPr : I<0x9B, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00002811 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002812 "setnp\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002813 [(set GR8:$dst, (X86setcc X86_COND_NP, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002814 TB; // GR8 = not parity
2815def SETNPm : I<0x9B, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00002816 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002817 "setnp\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002818 [(store (X86setcc X86_COND_NP, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002819 TB; // [mem8] = not parity
Bill Wendling0c52d0a2008-12-02 00:07:05 +00002820
2821def SETOr : I<0x90, MRM0r,
2822 (outs GR8 :$dst), (ins),
2823 "seto\t$dst",
2824 [(set GR8:$dst, (X86setcc X86_COND_O, EFLAGS))]>,
2825 TB; // GR8 = overflow
2826def SETOm : I<0x90, MRM0m,
2827 (outs), (ins i8mem:$dst),
2828 "seto\t$dst",
2829 [(store (X86setcc X86_COND_O, EFLAGS), addr:$dst)]>,
2830 TB; // [mem8] = overflow
2831def SETNOr : I<0x91, MRM0r,
2832 (outs GR8 :$dst), (ins),
2833 "setno\t$dst",
2834 [(set GR8:$dst, (X86setcc X86_COND_NO, EFLAGS))]>,
2835 TB; // GR8 = not overflow
2836def SETNOm : I<0x91, MRM0m,
2837 (outs), (ins i8mem:$dst),
2838 "setno\t$dst",
2839 [(store (X86setcc X86_COND_NO, EFLAGS), addr:$dst)]>,
2840 TB; // [mem8] = not overflow
Evan Cheng950aac02007-09-25 01:57:46 +00002841} // Uses = [EFLAGS]
2842
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002843
2844// Integer comparisons
Evan Cheng55687072007-09-14 21:48:26 +00002845let Defs = [EFLAGS] in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002846def CMP8rr : I<0x38, MRMDestReg,
Evan Chengb783fa32007-07-19 01:14:50 +00002847 (outs), (ins GR8 :$src1, GR8 :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002848 "cmp{b}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002849 [(X86cmp GR8:$src1, GR8:$src2), (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002850def CMP16rr : I<0x39, MRMDestReg,
Evan Chengb783fa32007-07-19 01:14:50 +00002851 (outs), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002852 "cmp{w}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002853 [(X86cmp GR16:$src1, GR16:$src2), (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002854def CMP32rr : I<0x39, MRMDestReg,
Evan Chengb783fa32007-07-19 01:14:50 +00002855 (outs), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002856 "cmp{l}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002857 [(X86cmp GR32:$src1, GR32:$src2), (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002858def CMP8mr : I<0x38, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00002859 (outs), (ins i8mem :$src1, GR8 :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002860 "cmp{b}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002861 [(X86cmp (loadi8 addr:$src1), GR8:$src2),
2862 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002863def CMP16mr : I<0x39, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00002864 (outs), (ins i16mem:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002865 "cmp{w}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002866 [(X86cmp (loadi16 addr:$src1), GR16:$src2),
2867 (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002868def CMP32mr : I<0x39, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00002869 (outs), (ins i32mem:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002870 "cmp{l}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002871 [(X86cmp (loadi32 addr:$src1), GR32:$src2),
2872 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002873def CMP8rm : I<0x3A, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00002874 (outs), (ins GR8 :$src1, i8mem :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002875 "cmp{b}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002876 [(X86cmp GR8:$src1, (loadi8 addr:$src2)),
2877 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002878def CMP16rm : I<0x3B, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00002879 (outs), (ins GR16:$src1, i16mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002880 "cmp{w}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002881 [(X86cmp GR16:$src1, (loadi16 addr:$src2)),
2882 (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002883def CMP32rm : I<0x3B, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00002884 (outs), (ins GR32:$src1, i32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002885 "cmp{l}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002886 [(X86cmp GR32:$src1, (loadi32 addr:$src2)),
2887 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002888def CMP8ri : Ii8<0x80, MRM7r,
Evan Chengb783fa32007-07-19 01:14:50 +00002889 (outs), (ins GR8:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002890 "cmp{b}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002891 [(X86cmp GR8:$src1, imm:$src2), (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002892def CMP16ri : Ii16<0x81, MRM7r,
Evan Chengb783fa32007-07-19 01:14:50 +00002893 (outs), (ins GR16:$src1, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002894 "cmp{w}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002895 [(X86cmp GR16:$src1, imm:$src2),
2896 (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002897def CMP32ri : Ii32<0x81, MRM7r,
Evan Chengb783fa32007-07-19 01:14:50 +00002898 (outs), (ins GR32:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002899 "cmp{l}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002900 [(X86cmp GR32:$src1, imm:$src2), (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002901def CMP8mi : Ii8 <0x80, MRM7m,
Evan Chengb783fa32007-07-19 01:14:50 +00002902 (outs), (ins i8mem :$src1, i8imm :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002903 "cmp{b}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002904 [(X86cmp (loadi8 addr:$src1), imm:$src2),
2905 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002906def CMP16mi : Ii16<0x81, MRM7m,
Evan Chengb783fa32007-07-19 01:14:50 +00002907 (outs), (ins i16mem:$src1, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002908 "cmp{w}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002909 [(X86cmp (loadi16 addr:$src1), imm:$src2),
2910 (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002911def CMP32mi : Ii32<0x81, MRM7m,
Evan Chengb783fa32007-07-19 01:14:50 +00002912 (outs), (ins i32mem:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002913 "cmp{l}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002914 [(X86cmp (loadi32 addr:$src1), imm:$src2),
2915 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002916def CMP16ri8 : Ii8<0x83, MRM7r,
Evan Chengb783fa32007-07-19 01:14:50 +00002917 (outs), (ins GR16:$src1, i16i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002918 "cmp{w}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002919 [(X86cmp GR16:$src1, i16immSExt8:$src2),
2920 (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002921def CMP16mi8 : Ii8<0x83, MRM7m,
Evan Chengb783fa32007-07-19 01:14:50 +00002922 (outs), (ins i16mem:$src1, i16i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002923 "cmp{w}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002924 [(X86cmp (loadi16 addr:$src1), i16immSExt8:$src2),
2925 (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002926def CMP32mi8 : Ii8<0x83, MRM7m,
Evan Chengb783fa32007-07-19 01:14:50 +00002927 (outs), (ins i32mem:$src1, i32i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002928 "cmp{l}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002929 [(X86cmp (loadi32 addr:$src1), i32immSExt8:$src2),
2930 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002931def CMP32ri8 : Ii8<0x83, MRM7r,
Evan Chengb783fa32007-07-19 01:14:50 +00002932 (outs), (ins GR32:$src1, i32i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002933 "cmp{l}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002934 [(X86cmp GR32:$src1, i32immSExt8:$src2),
Evan Cheng950aac02007-09-25 01:57:46 +00002935 (implicit EFLAGS)]>;
2936} // Defs = [EFLAGS]
2937
Dan Gohman7fe9b7f2008-12-23 22:45:23 +00002938// Bit tests.
Dan Gohman7fe9b7f2008-12-23 22:45:23 +00002939// TODO: BTC, BTR, and BTS
2940let Defs = [EFLAGS] in {
Dan Gohmanfc4eddb2009-01-13 20:32:45 +00002941def BT16rr : I<0xA3, MRMDestReg, (outs), (ins GR16:$src1, GR16:$src2),
Dan Gohman7fe9b7f2008-12-23 22:45:23 +00002942 "bt{w}\t{$src2, $src1|$src1, $src2}",
2943 [(X86bt GR16:$src1, GR16:$src2),
Chris Lattner5a95cde2008-12-25 01:32:49 +00002944 (implicit EFLAGS)]>, OpSize, TB;
Dan Gohmanfc4eddb2009-01-13 20:32:45 +00002945def BT32rr : I<0xA3, MRMDestReg, (outs), (ins GR32:$src1, GR32:$src2),
Dan Gohman7fe9b7f2008-12-23 22:45:23 +00002946 "bt{l}\t{$src2, $src1|$src1, $src2}",
2947 [(X86bt GR32:$src1, GR32:$src2),
Chris Lattner5a95cde2008-12-25 01:32:49 +00002948 (implicit EFLAGS)]>, TB;
Dan Gohman85a228c2009-01-13 23:23:30 +00002949
2950// Unlike with the register+register form, the memory+register form of the
2951// bt instruction does not ignore the high bits of the index. From ISel's
2952// perspective, this is pretty bizarre. Disable these instructions for now.
2953//def BT16mr : I<0xA3, MRMDestMem, (outs), (ins i16mem:$src1, GR16:$src2),
2954// "bt{w}\t{$src2, $src1|$src1, $src2}",
2955// [(X86bt (loadi16 addr:$src1), GR16:$src2),
2956// (implicit EFLAGS)]>, OpSize, TB, Requires<[FastBTMem]>;
2957//def BT32mr : I<0xA3, MRMDestMem, (outs), (ins i32mem:$src1, GR32:$src2),
2958// "bt{l}\t{$src2, $src1|$src1, $src2}",
2959// [(X86bt (loadi32 addr:$src1), GR32:$src2),
2960// (implicit EFLAGS)]>, TB, Requires<[FastBTMem]>;
Dan Gohman46fb1cf2009-01-13 20:33:23 +00002961
2962def BT16ri8 : Ii8<0xBA, MRM4r, (outs), (ins GR16:$src1, i16i8imm:$src2),
2963 "bt{w}\t{$src2, $src1|$src1, $src2}",
2964 [(X86bt GR16:$src1, i16immSExt8:$src2),
2965 (implicit EFLAGS)]>, OpSize, TB;
2966def BT32ri8 : Ii8<0xBA, MRM4r, (outs), (ins GR32:$src1, i32i8imm:$src2),
2967 "bt{l}\t{$src2, $src1|$src1, $src2}",
2968 [(X86bt GR32:$src1, i32immSExt8:$src2),
2969 (implicit EFLAGS)]>, TB;
2970// Note that these instructions don't need FastBTMem because that
2971// only applies when the other operand is in a register. When it's
2972// an immediate, bt is still fast.
2973def BT16mi8 : Ii8<0xBA, MRM4m, (outs), (ins i16mem:$src1, i16i8imm:$src2),
2974 "bt{w}\t{$src2, $src1|$src1, $src2}",
2975 [(X86bt (loadi16 addr:$src1), i16immSExt8:$src2),
2976 (implicit EFLAGS)]>, OpSize, TB;
2977def BT32mi8 : Ii8<0xBA, MRM4m, (outs), (ins i32mem:$src1, i32i8imm:$src2),
2978 "bt{l}\t{$src2, $src1|$src1, $src2}",
2979 [(X86bt (loadi32 addr:$src1), i32immSExt8:$src2),
2980 (implicit EFLAGS)]>, TB;
Dan Gohman7fe9b7f2008-12-23 22:45:23 +00002981} // Defs = [EFLAGS]
2982
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002983// Sign/Zero extenders
Dan Gohman9203ab42008-07-30 18:09:17 +00002984// Use movsbl intead of movsbw; we don't care about the high 16 bits
2985// of the register here. This has a smaller encoding and avoids a
2986// partial-register update.
Evan Chengb783fa32007-07-19 01:14:50 +00002987def MOVSX16rr8 : I<0xBE, MRMSrcReg, (outs GR16:$dst), (ins GR8 :$src),
Dan Gohman9203ab42008-07-30 18:09:17 +00002988 "movs{bl|x}\t{$src, ${dst:subreg32}|${dst:subreg32}, $src}",
2989 [(set GR16:$dst, (sext GR8:$src))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00002990def MOVSX16rm8 : I<0xBE, MRMSrcMem, (outs GR16:$dst), (ins i8mem :$src),
Dan Gohman9203ab42008-07-30 18:09:17 +00002991 "movs{bl|x}\t{$src, ${dst:subreg32}|${dst:subreg32}, $src}",
2992 [(set GR16:$dst, (sextloadi16i8 addr:$src))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00002993def MOVSX32rr8 : I<0xBE, MRMSrcReg, (outs GR32:$dst), (ins GR8 :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002994 "movs{bl|x}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002995 [(set GR32:$dst, (sext GR8:$src))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00002996def MOVSX32rm8 : I<0xBE, MRMSrcMem, (outs GR32:$dst), (ins i8mem :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002997 "movs{bl|x}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002998 [(set GR32:$dst, (sextloadi32i8 addr:$src))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00002999def MOVSX32rr16: I<0xBF, MRMSrcReg, (outs GR32:$dst), (ins GR16:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00003000 "movs{wl|x}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003001 [(set GR32:$dst, (sext GR16:$src))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00003002def MOVSX32rm16: I<0xBF, MRMSrcMem, (outs GR32:$dst), (ins i16mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00003003 "movs{wl|x}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003004 [(set GR32:$dst, (sextloadi32i16 addr:$src))]>, TB;
3005
Dan Gohman9203ab42008-07-30 18:09:17 +00003006// Use movzbl intead of movzbw; we don't care about the high 16 bits
3007// of the register here. This has a smaller encoding and avoids a
3008// partial-register update.
Evan Chengb783fa32007-07-19 01:14:50 +00003009def MOVZX16rr8 : I<0xB6, MRMSrcReg, (outs GR16:$dst), (ins GR8 :$src),
Dan Gohman9203ab42008-07-30 18:09:17 +00003010 "movz{bl|x}\t{$src, ${dst:subreg32}|${dst:subreg32}, $src}",
3011 [(set GR16:$dst, (zext GR8:$src))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00003012def MOVZX16rm8 : I<0xB6, MRMSrcMem, (outs GR16:$dst), (ins i8mem :$src),
Dan Gohman9203ab42008-07-30 18:09:17 +00003013 "movz{bl|x}\t{$src, ${dst:subreg32}|${dst:subreg32}, $src}",
3014 [(set GR16:$dst, (zextloadi16i8 addr:$src))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00003015def MOVZX32rr8 : I<0xB6, MRMSrcReg, (outs GR32:$dst), (ins GR8 :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00003016 "movz{bl|x}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003017 [(set GR32:$dst, (zext GR8:$src))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00003018def MOVZX32rm8 : I<0xB6, MRMSrcMem, (outs GR32:$dst), (ins i8mem :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00003019 "movz{bl|x}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003020 [(set GR32:$dst, (zextloadi32i8 addr:$src))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00003021def MOVZX32rr16: I<0xB7, MRMSrcReg, (outs GR32:$dst), (ins GR16:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00003022 "movz{wl|x}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003023 [(set GR32:$dst, (zext GR16:$src))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00003024def MOVZX32rm16: I<0xB7, MRMSrcMem, (outs GR32:$dst), (ins i16mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00003025 "movz{wl|x}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003026 [(set GR32:$dst, (zextloadi32i16 addr:$src))]>, TB;
3027
Dan Gohman744d4622009-04-13 16:09:41 +00003028// These are the same as the regular regular MOVZX32rr8 and MOVZX32rm8
3029// except that they use GR32_NOREX for the output operand register class
3030// instead of GR32. This allows them to operate on h registers on x86-64.
3031def MOVZX32_NOREXrr8 : I<0xB6, MRMSrcReg,
3032 (outs GR32_NOREX:$dst), (ins GR8:$src),
3033 "movz{bl|x}\t{$src, $dst|$dst, $src} # NOREX",
3034 []>, TB;
Dan Gohman89f4cda2009-04-30 03:11:48 +00003035let mayLoad = 1 in
Dan Gohman744d4622009-04-13 16:09:41 +00003036def MOVZX32_NOREXrm8 : I<0xB6, MRMSrcMem,
3037 (outs GR32_NOREX:$dst), (ins i8mem:$src),
3038 "movz{bl|x}\t{$src, $dst|$dst, $src} # NOREX",
3039 []>, TB;
3040
Chris Lattnerc90ee9c2008-01-10 07:59:24 +00003041let neverHasSideEffects = 1 in {
3042 let Defs = [AX], Uses = [AL] in
3043 def CBW : I<0x98, RawFrm, (outs), (ins),
3044 "{cbtw|cbw}", []>, OpSize; // AX = signext(AL)
3045 let Defs = [EAX], Uses = [AX] in
3046 def CWDE : I<0x98, RawFrm, (outs), (ins),
3047 "{cwtl|cwde}", []>; // EAX = signext(AX)
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003048
Chris Lattnerc90ee9c2008-01-10 07:59:24 +00003049 let Defs = [AX,DX], Uses = [AX] in
3050 def CWD : I<0x99, RawFrm, (outs), (ins),
3051 "{cwtd|cwd}", []>, OpSize; // DX:AX = signext(AX)
3052 let Defs = [EAX,EDX], Uses = [EAX] in
3053 def CDQ : I<0x99, RawFrm, (outs), (ins),
3054 "{cltd|cdq}", []>; // EDX:EAX = signext(EAX)
3055}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003056
3057//===----------------------------------------------------------------------===//
3058// Alias Instructions
3059//===----------------------------------------------------------------------===//
3060
3061// Alias instructions that map movr0 to xor.
3062// FIXME: remove when we can teach regalloc that xor reg, reg is ok.
Bill Wendlingba5d5b02008-05-29 01:02:09 +00003063let Defs = [EFLAGS], isReMaterializable = 1, isAsCheapAsAMove = 1 in {
Evan Chengb783fa32007-07-19 01:14:50 +00003064def MOV8r0 : I<0x30, MRMInitReg, (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00003065 "xor{b}\t$dst, $dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003066 [(set GR8:$dst, 0)]>;
Dan Gohman9203ab42008-07-30 18:09:17 +00003067// Use xorl instead of xorw since we don't care about the high 16 bits,
3068// it's smaller, and it avoids a partial-register update.
Evan Chengb783fa32007-07-19 01:14:50 +00003069def MOV16r0 : I<0x31, MRMInitReg, (outs GR16:$dst), (ins),
Dan Gohman9203ab42008-07-30 18:09:17 +00003070 "xor{l}\t${dst:subreg32}, ${dst:subreg32}",
3071 [(set GR16:$dst, 0)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00003072def MOV32r0 : I<0x31, MRMInitReg, (outs GR32:$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00003073 "xor{l}\t$dst, $dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003074 [(set GR32:$dst, 0)]>;
Dan Gohman8aef09b2007-09-07 21:32:51 +00003075}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003076
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003077//===----------------------------------------------------------------------===//
3078// Thread Local Storage Instructions
3079//
3080
Rafael Espindola7fc4b8d2009-04-24 12:59:40 +00003081// All calls clobber the non-callee saved registers. ESP is marked as
3082// a use to prevent stack-pointer assignments that appear immediately
3083// before calls from potentially appearing dead.
3084let Defs = [EAX, ECX, EDX, FP0, FP1, FP2, FP3, FP4, FP5, FP6, ST0,
3085 MM0, MM1, MM2, MM3, MM4, MM5, MM6, MM7,
3086 XMM0, XMM1, XMM2, XMM3, XMM4, XMM5, XMM6, XMM7,
3087 XMM8, XMM9, XMM10, XMM11, XMM12, XMM13, XMM14, XMM15, EFLAGS],
3088 Uses = [ESP, EBX] in
Rafael Espindolaaf759ab2009-04-17 14:35:58 +00003089def TLS_addr32 : I<0, Pseudo, (outs), (ins i32imm:$sym),
Dan Gohman70a8a112009-04-27 15:13:28 +00003090 "leal\t${sym:mem}(,%ebx,1), %eax; "
3091 "call\t___tls_get_addr@PLT",
Rafael Espindolaaf759ab2009-04-17 14:35:58 +00003092 [(X86tlsaddr tglobaltlsaddr:$sym)]>,
3093 Requires<[In32BitMode]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003094
sampo9cc09a32009-01-26 01:24:32 +00003095let AddedComplexity = 5 in
3096def GS_MOV32rm : I<0x8B, MRMSrcMem, (outs GR32:$dst), (ins i32mem:$src),
3097 "movl\t%gs:$src, $dst",
3098 [(set GR32:$dst, (gsload addr:$src))]>, SegGS;
3099
Chris Lattnera7c2d8a2009-05-05 18:52:19 +00003100let AddedComplexity = 5 in
3101def FS_MOV32rm : I<0x8B, MRMSrcMem, (outs GR32:$dst), (ins i32mem:$src),
3102 "movl\t%fs:$src, $dst",
3103 [(set GR32:$dst, (fsload addr:$src))]>, SegFS;
3104
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003105//===----------------------------------------------------------------------===//
3106// DWARF Pseudo Instructions
3107//
3108
Evan Chengb783fa32007-07-19 01:14:50 +00003109def DWARF_LOC : I<0, Pseudo, (outs),
3110 (ins i32imm:$line, i32imm:$col, i32imm:$file),
Dan Gohman77af4a82007-09-24 19:25:06 +00003111 ".loc\t${file:debug} ${line:debug} ${col:debug}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003112 [(dwarf_loc (i32 imm:$line), (i32 imm:$col),
3113 (i32 imm:$file))]>;
3114
3115//===----------------------------------------------------------------------===//
3116// EH Pseudo Instructions
3117//
3118let isTerminator = 1, isReturn = 1, isBarrier = 1,
Evan Cheng37e7c752007-07-21 00:34:19 +00003119 hasCtrlDep = 1 in {
Evan Chengb783fa32007-07-19 01:14:50 +00003120def EH_RETURN : I<0xC3, RawFrm, (outs), (ins GR32:$addr),
Dan Gohman91888f02007-07-31 20:11:57 +00003121 "ret\t#eh_return, addr: $addr",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003122 [(X86ehret GR32:$addr)]>;
3123
3124}
3125
3126//===----------------------------------------------------------------------===//
Andrew Lenharthe44f3902008-02-21 06:45:13 +00003127// Atomic support
3128//
Andrew Lenharth7a5a4b22008-03-01 13:37:02 +00003129
Evan Cheng3e171562008-04-19 01:20:30 +00003130// Atomic swap. These are just normal xchg instructions. But since a memory
3131// operand is referenced, the atomicity is ensured.
Dan Gohmana41a1c092008-08-06 15:52:50 +00003132let Constraints = "$val = $dst" in {
Evan Cheng3e171562008-04-19 01:20:30 +00003133def XCHG32rm : I<0x87, MRMSrcMem, (outs GR32:$dst), (ins i32mem:$ptr, GR32:$val),
3134 "xchg{l}\t{$val, $ptr|$ptr, $val}",
3135 [(set GR32:$dst, (atomic_swap_32 addr:$ptr, GR32:$val))]>;
3136def XCHG16rm : I<0x87, MRMSrcMem, (outs GR16:$dst), (ins i16mem:$ptr, GR16:$val),
3137 "xchg{w}\t{$val, $ptr|$ptr, $val}",
3138 [(set GR16:$dst, (atomic_swap_16 addr:$ptr, GR16:$val))]>,
3139 OpSize;
3140def XCHG8rm : I<0x86, MRMSrcMem, (outs GR8:$dst), (ins i8mem:$ptr, GR8:$val),
3141 "xchg{b}\t{$val, $ptr|$ptr, $val}",
3142 [(set GR8:$dst, (atomic_swap_8 addr:$ptr, GR8:$val))]>;
3143}
3144
Evan Chengd49dbb82008-04-18 20:55:36 +00003145// Atomic compare and swap.
Andrew Lenharth7dfe23f2008-03-01 21:52:34 +00003146let Defs = [EAX, EFLAGS], Uses = [EAX] in {
Evan Chengd49dbb82008-04-18 20:55:36 +00003147def LCMPXCHG32 : I<0xB1, MRMDestMem, (outs), (ins i32mem:$ptr, GR32:$swap),
Dan Gohman70a8a112009-04-27 15:13:28 +00003148 "lock\n\t"
3149 "cmpxchg{l}\t{$swap, $ptr|$ptr, $swap}",
Evan Cheng09fbdee2008-03-04 03:20:06 +00003150 [(X86cas addr:$ptr, GR32:$swap, 4)]>, TB, LOCK;
Andrew Lenharth7a5a4b22008-03-01 13:37:02 +00003151}
Dale Johannesenf160d802008-10-02 18:53:47 +00003152let Defs = [EAX, EDX, EFLAGS], Uses = [EAX, EBX, ECX, EDX] in {
Anton Korobeynikovc4067392008-07-22 16:22:48 +00003153def LCMPXCHG8B : I<0xC7, MRM1m, (outs), (ins i32mem:$ptr),
Dan Gohman70a8a112009-04-27 15:13:28 +00003154 "lock\n\t"
3155 "cmpxchg8b\t$ptr",
Andrew Lenharth81580822008-03-05 01:15:49 +00003156 [(X86cas8 addr:$ptr)]>, TB, LOCK;
3157}
Andrew Lenharth7dfe23f2008-03-01 21:52:34 +00003158
3159let Defs = [AX, EFLAGS], Uses = [AX] in {
Evan Chengd49dbb82008-04-18 20:55:36 +00003160def LCMPXCHG16 : I<0xB1, MRMDestMem, (outs), (ins i16mem:$ptr, GR16:$swap),
Dan Gohman70a8a112009-04-27 15:13:28 +00003161 "lock\n\t"
3162 "cmpxchg{w}\t{$swap, $ptr|$ptr, $swap}",
Evan Cheng09fbdee2008-03-04 03:20:06 +00003163 [(X86cas addr:$ptr, GR16:$swap, 2)]>, TB, OpSize, LOCK;
Andrew Lenharth7a5a4b22008-03-01 13:37:02 +00003164}
Andrew Lenharth7dfe23f2008-03-01 21:52:34 +00003165let Defs = [AL, EFLAGS], Uses = [AL] in {
Evan Chengd49dbb82008-04-18 20:55:36 +00003166def LCMPXCHG8 : I<0xB0, MRMDestMem, (outs), (ins i8mem:$ptr, GR8:$swap),
Dan Gohman70a8a112009-04-27 15:13:28 +00003167 "lock\n\t"
3168 "cmpxchg{b}\t{$swap, $ptr|$ptr, $swap}",
Evan Cheng09fbdee2008-03-04 03:20:06 +00003169 [(X86cas addr:$ptr, GR8:$swap, 1)]>, TB, LOCK;
Andrew Lenharth7a5a4b22008-03-01 13:37:02 +00003170}
3171
Evan Chengd49dbb82008-04-18 20:55:36 +00003172// Atomic exchange and add
3173let Constraints = "$val = $dst", Defs = [EFLAGS] in {
3174def LXADD32 : I<0xC1, MRMSrcMem, (outs GR32:$dst), (ins i32mem:$ptr, GR32:$val),
Dan Gohman70a8a112009-04-27 15:13:28 +00003175 "lock\n\t"
3176 "xadd{l}\t{$val, $ptr|$ptr, $val}",
Mon P Wang6bde9ec2008-06-25 08:15:39 +00003177 [(set GR32:$dst, (atomic_load_add_32 addr:$ptr, GR32:$val))]>,
Evan Chengd49dbb82008-04-18 20:55:36 +00003178 TB, LOCK;
3179def LXADD16 : I<0xC1, MRMSrcMem, (outs GR16:$dst), (ins i16mem:$ptr, GR16:$val),
Dan Gohman70a8a112009-04-27 15:13:28 +00003180 "lock\n\t"
3181 "xadd{w}\t{$val, $ptr|$ptr, $val}",
Mon P Wang6bde9ec2008-06-25 08:15:39 +00003182 [(set GR16:$dst, (atomic_load_add_16 addr:$ptr, GR16:$val))]>,
Evan Chengd49dbb82008-04-18 20:55:36 +00003183 TB, OpSize, LOCK;
3184def LXADD8 : I<0xC0, MRMSrcMem, (outs GR8:$dst), (ins i8mem:$ptr, GR8:$val),
Dan Gohman70a8a112009-04-27 15:13:28 +00003185 "lock\n\t"
3186 "xadd{b}\t{$val, $ptr|$ptr, $val}",
Mon P Wang6bde9ec2008-06-25 08:15:39 +00003187 [(set GR8:$dst, (atomic_load_add_8 addr:$ptr, GR8:$val))]>,
Evan Chengd49dbb82008-04-18 20:55:36 +00003188 TB, LOCK;
Andrew Lenharth7a5a4b22008-03-01 13:37:02 +00003189}
3190
Mon P Wang6bde9ec2008-06-25 08:15:39 +00003191// Atomic exchange, and, or, xor
Mon P Wang078a62d2008-05-05 19:05:59 +00003192let Constraints = "$val = $dst", Defs = [EFLAGS],
3193 usesCustomDAGSchedInserter = 1 in {
Dan Gohman8aeb61f2008-05-12 20:22:45 +00003194def ATOMAND32 : I<0, Pseudo, (outs GR32:$dst),(ins i32mem:$ptr, GR32:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003195 "#ATOMAND32 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003196 [(set GR32:$dst, (atomic_load_and_32 addr:$ptr, GR32:$val))]>;
Dan Gohman8aeb61f2008-05-12 20:22:45 +00003197def ATOMOR32 : I<0, Pseudo, (outs GR32:$dst),(ins i32mem:$ptr, GR32:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003198 "#ATOMOR32 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003199 [(set GR32:$dst, (atomic_load_or_32 addr:$ptr, GR32:$val))]>;
Dan Gohman8aeb61f2008-05-12 20:22:45 +00003200def ATOMXOR32 : I<0, Pseudo,(outs GR32:$dst),(ins i32mem:$ptr, GR32:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003201 "#ATOMXOR32 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003202 [(set GR32:$dst, (atomic_load_xor_32 addr:$ptr, GR32:$val))]>;
Andrew Lenharthaf02d592008-06-14 05:48:15 +00003203def ATOMNAND32 : I<0, Pseudo,(outs GR32:$dst),(ins i32mem:$ptr, GR32:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003204 "#ATOMNAND32 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003205 [(set GR32:$dst, (atomic_load_nand_32 addr:$ptr, GR32:$val))]>;
Dan Gohman8aeb61f2008-05-12 20:22:45 +00003206def ATOMMIN32: I<0, Pseudo, (outs GR32:$dst), (ins i32mem:$ptr, GR32:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003207 "#ATOMMIN32 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003208 [(set GR32:$dst, (atomic_load_min_32 addr:$ptr, GR32:$val))]>;
Dan Gohman8aeb61f2008-05-12 20:22:45 +00003209def ATOMMAX32: I<0, Pseudo, (outs GR32:$dst),(ins i32mem:$ptr, GR32:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003210 "#ATOMMAX32 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003211 [(set GR32:$dst, (atomic_load_max_32 addr:$ptr, GR32:$val))]>;
Dan Gohman8aeb61f2008-05-12 20:22:45 +00003212def ATOMUMIN32: I<0, Pseudo, (outs GR32:$dst),(ins i32mem:$ptr, GR32:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003213 "#ATOMUMIN32 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003214 [(set GR32:$dst, (atomic_load_umin_32 addr:$ptr, GR32:$val))]>;
Dan Gohman8aeb61f2008-05-12 20:22:45 +00003215def ATOMUMAX32: I<0, Pseudo, (outs GR32:$dst),(ins i32mem:$ptr, GR32:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003216 "#ATOMUMAX32 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003217 [(set GR32:$dst, (atomic_load_umax_32 addr:$ptr, GR32:$val))]>;
Dale Johannesend20e4452008-08-19 18:47:28 +00003218
3219def ATOMAND16 : I<0, Pseudo, (outs GR16:$dst),(ins i16mem:$ptr, GR16:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003220 "#ATOMAND16 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003221 [(set GR16:$dst, (atomic_load_and_16 addr:$ptr, GR16:$val))]>;
Dale Johannesend20e4452008-08-19 18:47:28 +00003222def ATOMOR16 : I<0, Pseudo, (outs GR16:$dst),(ins i16mem:$ptr, GR16:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003223 "#ATOMOR16 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003224 [(set GR16:$dst, (atomic_load_or_16 addr:$ptr, GR16:$val))]>;
Dale Johannesend20e4452008-08-19 18:47:28 +00003225def ATOMXOR16 : I<0, Pseudo,(outs GR16:$dst),(ins i16mem:$ptr, GR16:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003226 "#ATOMXOR16 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003227 [(set GR16:$dst, (atomic_load_xor_16 addr:$ptr, GR16:$val))]>;
Dale Johannesend20e4452008-08-19 18:47:28 +00003228def ATOMNAND16 : I<0, Pseudo,(outs GR16:$dst),(ins i16mem:$ptr, GR16:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003229 "#ATOMNAND16 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003230 [(set GR16:$dst, (atomic_load_nand_16 addr:$ptr, GR16:$val))]>;
Dale Johannesend20e4452008-08-19 18:47:28 +00003231def ATOMMIN16: I<0, Pseudo, (outs GR16:$dst), (ins i16mem:$ptr, GR16:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003232 "#ATOMMIN16 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003233 [(set GR16:$dst, (atomic_load_min_16 addr:$ptr, GR16:$val))]>;
Dale Johannesend20e4452008-08-19 18:47:28 +00003234def ATOMMAX16: I<0, Pseudo, (outs GR16:$dst),(ins i16mem:$ptr, GR16:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003235 "#ATOMMAX16 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003236 [(set GR16:$dst, (atomic_load_max_16 addr:$ptr, GR16:$val))]>;
Dale Johannesend20e4452008-08-19 18:47:28 +00003237def ATOMUMIN16: I<0, Pseudo, (outs GR16:$dst),(ins i16mem:$ptr, GR16:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003238 "#ATOMUMIN16 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003239 [(set GR16:$dst, (atomic_load_umin_16 addr:$ptr, GR16:$val))]>;
Dale Johannesend20e4452008-08-19 18:47:28 +00003240def ATOMUMAX16: I<0, Pseudo, (outs GR16:$dst),(ins i16mem:$ptr, GR16:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003241 "#ATOMUMAX16 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003242 [(set GR16:$dst, (atomic_load_umax_16 addr:$ptr, GR16:$val))]>;
Dale Johannesend20e4452008-08-19 18:47:28 +00003243
3244def ATOMAND8 : I<0, Pseudo, (outs GR8:$dst),(ins i8mem:$ptr, GR8:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003245 "#ATOMAND8 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003246 [(set GR8:$dst, (atomic_load_and_8 addr:$ptr, GR8:$val))]>;
Dale Johannesend20e4452008-08-19 18:47:28 +00003247def ATOMOR8 : I<0, Pseudo, (outs GR8:$dst),(ins i8mem:$ptr, GR8:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003248 "#ATOMOR8 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003249 [(set GR8:$dst, (atomic_load_or_8 addr:$ptr, GR8:$val))]>;
Dale Johannesend20e4452008-08-19 18:47:28 +00003250def ATOMXOR8 : I<0, Pseudo,(outs GR8:$dst),(ins i8mem:$ptr, GR8:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003251 "#ATOMXOR8 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003252 [(set GR8:$dst, (atomic_load_xor_8 addr:$ptr, GR8:$val))]>;
Dale Johannesend20e4452008-08-19 18:47:28 +00003253def ATOMNAND8 : I<0, Pseudo,(outs GR8:$dst),(ins i8mem:$ptr, GR8:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003254 "#ATOMNAND8 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003255 [(set GR8:$dst, (atomic_load_nand_8 addr:$ptr, GR8:$val))]>;
Mon P Wang078a62d2008-05-05 19:05:59 +00003256}
3257
Dale Johannesenf160d802008-10-02 18:53:47 +00003258let Constraints = "$val1 = $dst1, $val2 = $dst2",
3259 Defs = [EFLAGS, EAX, EBX, ECX, EDX],
3260 Uses = [EAX, EBX, ECX, EDX],
Dale Johannesen44eb5372008-10-03 19:41:08 +00003261 mayLoad = 1, mayStore = 1,
Dale Johannesenf160d802008-10-02 18:53:47 +00003262 usesCustomDAGSchedInserter = 1 in {
3263def ATOMAND6432 : I<0, Pseudo, (outs GR32:$dst1, GR32:$dst2),
3264 (ins i64mem:$ptr, GR32:$val1, GR32:$val2),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003265 "#ATOMAND6432 PSEUDO!", []>;
Dale Johannesenf160d802008-10-02 18:53:47 +00003266def ATOMOR6432 : I<0, Pseudo, (outs GR32:$dst1, GR32:$dst2),
3267 (ins i64mem:$ptr, GR32:$val1, GR32:$val2),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003268 "#ATOMOR6432 PSEUDO!", []>;
Dale Johannesenf160d802008-10-02 18:53:47 +00003269def ATOMXOR6432 : I<0, Pseudo, (outs GR32:$dst1, GR32:$dst2),
3270 (ins i64mem:$ptr, GR32:$val1, GR32:$val2),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003271 "#ATOMXOR6432 PSEUDO!", []>;
Dale Johannesenf160d802008-10-02 18:53:47 +00003272def ATOMNAND6432 : I<0, Pseudo, (outs GR32:$dst1, GR32:$dst2),
3273 (ins i64mem:$ptr, GR32:$val1, GR32:$val2),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003274 "#ATOMNAND6432 PSEUDO!", []>;
Dale Johannesenf160d802008-10-02 18:53:47 +00003275def ATOMADD6432 : I<0, Pseudo, (outs GR32:$dst1, GR32:$dst2),
3276 (ins i64mem:$ptr, GR32:$val1, GR32:$val2),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003277 "#ATOMADD6432 PSEUDO!", []>;
Dale Johannesenf160d802008-10-02 18:53:47 +00003278def ATOMSUB6432 : I<0, Pseudo, (outs GR32:$dst1, GR32:$dst2),
3279 (ins i64mem:$ptr, GR32:$val1, GR32:$val2),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003280 "#ATOMSUB6432 PSEUDO!", []>;
Dale Johannesen51c58ee2008-10-03 22:25:52 +00003281def ATOMSWAP6432 : I<0, Pseudo, (outs GR32:$dst1, GR32:$dst2),
3282 (ins i64mem:$ptr, GR32:$val1, GR32:$val2),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003283 "#ATOMSWAP6432 PSEUDO!", []>;
Dale Johannesenf160d802008-10-02 18:53:47 +00003284}
3285
Andrew Lenharthe44f3902008-02-21 06:45:13 +00003286//===----------------------------------------------------------------------===//
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003287// Non-Instruction Patterns
3288//===----------------------------------------------------------------------===//
3289
Bill Wendlingfef06052008-09-16 21:48:12 +00003290// ConstantPool GlobalAddress, ExternalSymbol, and JumpTable
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003291def : Pat<(i32 (X86Wrapper tconstpool :$dst)), (MOV32ri tconstpool :$dst)>;
3292def : Pat<(i32 (X86Wrapper tjumptable :$dst)), (MOV32ri tjumptable :$dst)>;
Nate Begemanb52948972008-04-12 00:47:57 +00003293def : Pat<(i32 (X86Wrapper tglobaltlsaddr:$dst)),(MOV32ri tglobaltlsaddr:$dst)>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003294def : Pat<(i32 (X86Wrapper tglobaladdr :$dst)), (MOV32ri tglobaladdr :$dst)>;
3295def : Pat<(i32 (X86Wrapper texternalsym:$dst)), (MOV32ri texternalsym:$dst)>;
3296
3297def : Pat<(add GR32:$src1, (X86Wrapper tconstpool:$src2)),
3298 (ADD32ri GR32:$src1, tconstpool:$src2)>;
3299def : Pat<(add GR32:$src1, (X86Wrapper tjumptable:$src2)),
3300 (ADD32ri GR32:$src1, tjumptable:$src2)>;
3301def : Pat<(add GR32:$src1, (X86Wrapper tglobaladdr :$src2)),
3302 (ADD32ri GR32:$src1, tglobaladdr:$src2)>;
3303def : Pat<(add GR32:$src1, (X86Wrapper texternalsym:$src2)),
3304 (ADD32ri GR32:$src1, texternalsym:$src2)>;
3305
3306def : Pat<(store (i32 (X86Wrapper tglobaladdr:$src)), addr:$dst),
3307 (MOV32mi addr:$dst, tglobaladdr:$src)>;
3308def : Pat<(store (i32 (X86Wrapper texternalsym:$src)), addr:$dst),
3309 (MOV32mi addr:$dst, texternalsym:$src)>;
3310
3311// Calls
Arnold Schwaighofere2d6bbb2007-10-11 19:40:01 +00003312// tailcall stuff
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003313def : Pat<(X86tailcall GR32:$dst),
Arnold Schwaighofere2d6bbb2007-10-11 19:40:01 +00003314 (TAILCALL)>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003315
3316def : Pat<(X86tailcall (i32 tglobaladdr:$dst)),
Arnold Schwaighofere2d6bbb2007-10-11 19:40:01 +00003317 (TAILCALL)>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003318def : Pat<(X86tailcall (i32 texternalsym:$dst)),
Arnold Schwaighofere2d6bbb2007-10-11 19:40:01 +00003319 (TAILCALL)>;
3320
3321def : Pat<(X86tcret GR32:$dst, imm:$off),
3322 (TCRETURNri GR32:$dst, imm:$off)>;
3323
3324def : Pat<(X86tcret (i32 tglobaladdr:$dst), imm:$off),
3325 (TCRETURNdi texternalsym:$dst, imm:$off)>;
3326
3327def : Pat<(X86tcret (i32 texternalsym:$dst), imm:$off),
3328 (TCRETURNdi texternalsym:$dst, imm:$off)>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003329
3330def : Pat<(X86call (i32 tglobaladdr:$dst)),
3331 (CALLpcrel32 tglobaladdr:$dst)>;
3332def : Pat<(X86call (i32 texternalsym:$dst)),
3333 (CALLpcrel32 texternalsym:$dst)>;
3334
3335// X86 specific add which produces a flag.
3336def : Pat<(addc GR32:$src1, GR32:$src2),
3337 (ADD32rr GR32:$src1, GR32:$src2)>;
3338def : Pat<(addc GR32:$src1, (load addr:$src2)),
3339 (ADD32rm GR32:$src1, addr:$src2)>;
3340def : Pat<(addc GR32:$src1, imm:$src2),
3341 (ADD32ri GR32:$src1, imm:$src2)>;
3342def : Pat<(addc GR32:$src1, i32immSExt8:$src2),
3343 (ADD32ri8 GR32:$src1, i32immSExt8:$src2)>;
3344
3345def : Pat<(subc GR32:$src1, GR32:$src2),
3346 (SUB32rr GR32:$src1, GR32:$src2)>;
3347def : Pat<(subc GR32:$src1, (load addr:$src2)),
3348 (SUB32rm GR32:$src1, addr:$src2)>;
3349def : Pat<(subc GR32:$src1, imm:$src2),
3350 (SUB32ri GR32:$src1, imm:$src2)>;
3351def : Pat<(subc GR32:$src1, i32immSExt8:$src2),
3352 (SUB32ri8 GR32:$src1, i32immSExt8:$src2)>;
3353
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003354// Comparisons.
3355
3356// TEST R,R is smaller than CMP R,0
Evan Cheng621216e2007-09-29 00:00:36 +00003357def : Pat<(parallel (X86cmp GR8:$src1, 0), (implicit EFLAGS)),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003358 (TEST8rr GR8:$src1, GR8:$src1)>;
Evan Cheng621216e2007-09-29 00:00:36 +00003359def : Pat<(parallel (X86cmp GR16:$src1, 0), (implicit EFLAGS)),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003360 (TEST16rr GR16:$src1, GR16:$src1)>;
Evan Cheng621216e2007-09-29 00:00:36 +00003361def : Pat<(parallel (X86cmp GR32:$src1, 0), (implicit EFLAGS)),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003362 (TEST32rr GR32:$src1, GR32:$src1)>;
3363
Dan Gohman0a3c5222009-01-07 01:00:24 +00003364// Conditional moves with folded loads with operands swapped and conditions
3365// inverted.
3366def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_B, EFLAGS),
3367 (CMOVAE16rm GR16:$src2, addr:$src1)>;
3368def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_B, EFLAGS),
3369 (CMOVAE32rm GR32:$src2, addr:$src1)>;
3370def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_AE, EFLAGS),
3371 (CMOVB16rm GR16:$src2, addr:$src1)>;
3372def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_AE, EFLAGS),
3373 (CMOVB32rm GR32:$src2, addr:$src1)>;
3374def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_E, EFLAGS),
3375 (CMOVNE16rm GR16:$src2, addr:$src1)>;
3376def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_E, EFLAGS),
3377 (CMOVNE32rm GR32:$src2, addr:$src1)>;
3378def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_NE, EFLAGS),
3379 (CMOVE16rm GR16:$src2, addr:$src1)>;
3380def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_NE, EFLAGS),
3381 (CMOVE32rm GR32:$src2, addr:$src1)>;
3382def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_BE, EFLAGS),
3383 (CMOVA16rm GR16:$src2, addr:$src1)>;
3384def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_BE, EFLAGS),
3385 (CMOVA32rm GR32:$src2, addr:$src1)>;
3386def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_A, EFLAGS),
3387 (CMOVBE16rm GR16:$src2, addr:$src1)>;
3388def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_A, EFLAGS),
3389 (CMOVBE32rm GR32:$src2, addr:$src1)>;
3390def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_L, EFLAGS),
3391 (CMOVGE16rm GR16:$src2, addr:$src1)>;
3392def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_L, EFLAGS),
3393 (CMOVGE32rm GR32:$src2, addr:$src1)>;
3394def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_GE, EFLAGS),
3395 (CMOVL16rm GR16:$src2, addr:$src1)>;
3396def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_GE, EFLAGS),
3397 (CMOVL32rm GR32:$src2, addr:$src1)>;
3398def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_LE, EFLAGS),
3399 (CMOVG16rm GR16:$src2, addr:$src1)>;
3400def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_LE, EFLAGS),
3401 (CMOVG32rm GR32:$src2, addr:$src1)>;
3402def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_G, EFLAGS),
3403 (CMOVLE16rm GR16:$src2, addr:$src1)>;
3404def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_G, EFLAGS),
3405 (CMOVLE32rm GR32:$src2, addr:$src1)>;
3406def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_P, EFLAGS),
3407 (CMOVNP16rm GR16:$src2, addr:$src1)>;
3408def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_P, EFLAGS),
3409 (CMOVNP32rm GR32:$src2, addr:$src1)>;
3410def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_NP, EFLAGS),
3411 (CMOVP16rm GR16:$src2, addr:$src1)>;
3412def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_NP, EFLAGS),
3413 (CMOVP32rm GR32:$src2, addr:$src1)>;
3414def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_S, EFLAGS),
3415 (CMOVNS16rm GR16:$src2, addr:$src1)>;
3416def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_S, EFLAGS),
3417 (CMOVNS32rm GR32:$src2, addr:$src1)>;
3418def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_NS, EFLAGS),
3419 (CMOVS16rm GR16:$src2, addr:$src1)>;
3420def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_NS, EFLAGS),
3421 (CMOVS32rm GR32:$src2, addr:$src1)>;
3422def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_O, EFLAGS),
3423 (CMOVNO16rm GR16:$src2, addr:$src1)>;
3424def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_O, EFLAGS),
3425 (CMOVNO32rm GR32:$src2, addr:$src1)>;
3426def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_NO, EFLAGS),
3427 (CMOVO16rm GR16:$src2, addr:$src1)>;
3428def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_NO, EFLAGS),
3429 (CMOVO32rm GR32:$src2, addr:$src1)>;
3430
Duncan Sands082524c2008-01-23 20:39:46 +00003431// zextload bool -> zextload byte
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003432def : Pat<(zextloadi8i1 addr:$src), (MOV8rm addr:$src)>;
3433def : Pat<(zextloadi16i1 addr:$src), (MOVZX16rm8 addr:$src)>;
3434def : Pat<(zextloadi32i1 addr:$src), (MOVZX32rm8 addr:$src)>;
3435
3436// extload bool -> extload byte
3437def : Pat<(extloadi8i1 addr:$src), (MOV8rm addr:$src)>;
Bill Wendlingce1c5c12008-08-22 20:51:05 +00003438def : Pat<(extloadi16i1 addr:$src), (MOVZX16rm8 addr:$src)>,
3439 Requires<[In32BitMode]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003440def : Pat<(extloadi32i1 addr:$src), (MOVZX32rm8 addr:$src)>;
Bill Wendlingce1c5c12008-08-22 20:51:05 +00003441def : Pat<(extloadi16i8 addr:$src), (MOVZX16rm8 addr:$src)>,
3442 Requires<[In32BitMode]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003443def : Pat<(extloadi32i8 addr:$src), (MOVZX32rm8 addr:$src)>;
3444def : Pat<(extloadi32i16 addr:$src), (MOVZX32rm16 addr:$src)>;
3445
Dan Gohmandd612bb2008-08-20 21:27:32 +00003446// anyext
Bill Wendlingce1c5c12008-08-22 20:51:05 +00003447def : Pat<(i16 (anyext GR8 :$src)), (MOVZX16rr8 GR8 :$src)>,
3448 Requires<[In32BitMode]>;
3449def : Pat<(i32 (anyext GR8 :$src)), (MOVZX32rr8 GR8 :$src)>,
3450 Requires<[In32BitMode]>;
Dan Gohmandd612bb2008-08-20 21:27:32 +00003451def : Pat<(i32 (anyext GR16:$src)),
3452 (INSERT_SUBREG (i32 (IMPLICIT_DEF)), GR16:$src, x86_subreg_16bit)>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003453
Evan Chengf2abee72007-12-13 00:43:27 +00003454// (and (i32 load), 255) -> (zextload i8)
Evan Cheng1e5e5452008-09-29 17:26:18 +00003455def : Pat<(i32 (and (nvloadi32 addr:$src), (i32 255))),
3456 (MOVZX32rm8 addr:$src)>;
3457def : Pat<(i32 (and (nvloadi32 addr:$src), (i32 65535))),
3458 (MOVZX32rm16 addr:$src)>;
Evan Chengf2abee72007-12-13 00:43:27 +00003459
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003460//===----------------------------------------------------------------------===//
3461// Some peepholes
3462//===----------------------------------------------------------------------===//
3463
Dan Gohman5a5e6e92008-10-17 01:33:43 +00003464// Odd encoding trick: -128 fits into an 8-bit immediate field while
3465// +128 doesn't, so in this special case use a sub instead of an add.
3466def : Pat<(add GR16:$src1, 128),
3467 (SUB16ri8 GR16:$src1, -128)>;
3468def : Pat<(store (add (loadi16 addr:$dst), 128), addr:$dst),
3469 (SUB16mi8 addr:$dst, -128)>;
3470def : Pat<(add GR32:$src1, 128),
3471 (SUB32ri8 GR32:$src1, -128)>;
3472def : Pat<(store (add (loadi32 addr:$dst), 128), addr:$dst),
3473 (SUB32mi8 addr:$dst, -128)>;
3474
Dan Gohman9203ab42008-07-30 18:09:17 +00003475// r & (2^16-1) ==> movz
3476def : Pat<(and GR32:$src1, 0xffff),
Dan Gohman744d4622009-04-13 16:09:41 +00003477 (MOVZX32rr16 (EXTRACT_SUBREG GR32:$src1, x86_subreg_16bit))>;
Dan Gohman5beb1ff2008-08-06 18:27:21 +00003478// r & (2^8-1) ==> movz
3479def : Pat<(and GR32:$src1, 0xff),
Dan Gohman6e438702009-04-27 16:33:14 +00003480 (MOVZX32rr8 (EXTRACT_SUBREG (COPY_TO_REGCLASS GR32:$src1, GR32_ABCD),
Dan Gohman744d4622009-04-13 16:09:41 +00003481 x86_subreg_8bit))>,
Dan Gohman5beb1ff2008-08-06 18:27:21 +00003482 Requires<[In32BitMode]>;
3483// r & (2^8-1) ==> movz
3484def : Pat<(and GR16:$src1, 0xff),
Dan Gohman6e438702009-04-27 16:33:14 +00003485 (MOVZX16rr8 (EXTRACT_SUBREG (COPY_TO_REGCLASS GR16:$src1, GR16_ABCD),
Dan Gohman744d4622009-04-13 16:09:41 +00003486 x86_subreg_8bit))>,
Dan Gohmandd612bb2008-08-20 21:27:32 +00003487 Requires<[In32BitMode]>;
3488
3489// sext_inreg patterns
3490def : Pat<(sext_inreg GR32:$src, i16),
Dan Gohman744d4622009-04-13 16:09:41 +00003491 (MOVSX32rr16 (EXTRACT_SUBREG GR32:$src, x86_subreg_16bit))>;
Dan Gohmandd612bb2008-08-20 21:27:32 +00003492def : Pat<(sext_inreg GR32:$src, i8),
Dan Gohman6e438702009-04-27 16:33:14 +00003493 (MOVSX32rr8 (EXTRACT_SUBREG (COPY_TO_REGCLASS GR32:$src, GR32_ABCD),
Dan Gohman744d4622009-04-13 16:09:41 +00003494 x86_subreg_8bit))>,
Dan Gohmandd612bb2008-08-20 21:27:32 +00003495 Requires<[In32BitMode]>;
3496def : Pat<(sext_inreg GR16:$src, i8),
Dan Gohman6e438702009-04-27 16:33:14 +00003497 (MOVSX16rr8 (EXTRACT_SUBREG (COPY_TO_REGCLASS GR16:$src, GR16_ABCD),
Dan Gohman744d4622009-04-13 16:09:41 +00003498 x86_subreg_8bit))>,
Dan Gohmandd612bb2008-08-20 21:27:32 +00003499 Requires<[In32BitMode]>;
3500
3501// trunc patterns
3502def : Pat<(i16 (trunc GR32:$src)),
Dan Gohman744d4622009-04-13 16:09:41 +00003503 (EXTRACT_SUBREG GR32:$src, x86_subreg_16bit)>;
Dan Gohmandd612bb2008-08-20 21:27:32 +00003504def : Pat<(i8 (trunc GR32:$src)),
Dan Gohman6e438702009-04-27 16:33:14 +00003505 (EXTRACT_SUBREG (COPY_TO_REGCLASS GR32:$src, GR32_ABCD),
Dan Gohman744d4622009-04-13 16:09:41 +00003506 x86_subreg_8bit)>,
Dan Gohmandd612bb2008-08-20 21:27:32 +00003507 Requires<[In32BitMode]>;
3508def : Pat<(i8 (trunc GR16:$src)),
Dan Gohman6e438702009-04-27 16:33:14 +00003509 (EXTRACT_SUBREG (COPY_TO_REGCLASS GR16:$src, GR16_ABCD),
Dan Gohman744d4622009-04-13 16:09:41 +00003510 x86_subreg_8bit)>,
3511 Requires<[In32BitMode]>;
3512
3513// h-register tricks
3514def : Pat<(i8 (trunc (srl_su GR16:$src, (i8 8)))),
Dan Gohman6e438702009-04-27 16:33:14 +00003515 (EXTRACT_SUBREG (COPY_TO_REGCLASS GR16:$src, GR16_ABCD),
Dan Gohman744d4622009-04-13 16:09:41 +00003516 x86_subreg_8bit_hi)>,
3517 Requires<[In32BitMode]>;
3518def : Pat<(i8 (trunc (srl_su GR32:$src, (i8 8)))),
Dan Gohman6e438702009-04-27 16:33:14 +00003519 (EXTRACT_SUBREG (COPY_TO_REGCLASS GR32:$src, GR32_ABCD),
Dan Gohman744d4622009-04-13 16:09:41 +00003520 x86_subreg_8bit_hi)>,
3521 Requires<[In32BitMode]>;
3522def : Pat<(srl_su GR16:$src, (i8 8)),
3523 (EXTRACT_SUBREG
3524 (MOVZX32rr8
Dan Gohman6e438702009-04-27 16:33:14 +00003525 (EXTRACT_SUBREG (COPY_TO_REGCLASS GR16:$src, GR16_ABCD),
Dan Gohman744d4622009-04-13 16:09:41 +00003526 x86_subreg_8bit_hi)),
3527 x86_subreg_16bit)>,
3528 Requires<[In32BitMode]>;
3529def : Pat<(and (srl_su GR32:$src, (i8 8)), (i32 255)),
Dan Gohman6e438702009-04-27 16:33:14 +00003530 (MOVZX32rr8 (EXTRACT_SUBREG (COPY_TO_REGCLASS GR32:$src, GR32_ABCD),
Dan Gohman744d4622009-04-13 16:09:41 +00003531 x86_subreg_8bit_hi))>,
Dan Gohman5beb1ff2008-08-06 18:27:21 +00003532 Requires<[In32BitMode]>;
Dan Gohman9203ab42008-07-30 18:09:17 +00003533
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003534// (shl x, 1) ==> (add x, x)
3535def : Pat<(shl GR8 :$src1, (i8 1)), (ADD8rr GR8 :$src1, GR8 :$src1)>;
3536def : Pat<(shl GR16:$src1, (i8 1)), (ADD16rr GR16:$src1, GR16:$src1)>;
3537def : Pat<(shl GR32:$src1, (i8 1)), (ADD32rr GR32:$src1, GR32:$src1)>;
3538
Evan Cheng76a64c72008-08-30 02:03:58 +00003539// (shl x (and y, 31)) ==> (shl x, y)
3540def : Pat<(shl GR8:$src1, (and CL:$amt, 31)),
3541 (SHL8rCL GR8:$src1)>;
3542def : Pat<(shl GR16:$src1, (and CL:$amt, 31)),
3543 (SHL16rCL GR16:$src1)>;
3544def : Pat<(shl GR32:$src1, (and CL:$amt, 31)),
3545 (SHL32rCL GR32:$src1)>;
3546def : Pat<(store (shl (loadi8 addr:$dst), (and CL:$amt, 31)), addr:$dst),
3547 (SHL8mCL addr:$dst)>;
3548def : Pat<(store (shl (loadi16 addr:$dst), (and CL:$amt, 31)), addr:$dst),
3549 (SHL16mCL addr:$dst)>;
3550def : Pat<(store (shl (loadi32 addr:$dst), (and CL:$amt, 31)), addr:$dst),
3551 (SHL32mCL addr:$dst)>;
3552
3553def : Pat<(srl GR8:$src1, (and CL:$amt, 31)),
3554 (SHR8rCL GR8:$src1)>;
3555def : Pat<(srl GR16:$src1, (and CL:$amt, 31)),
3556 (SHR16rCL GR16:$src1)>;
3557def : Pat<(srl GR32:$src1, (and CL:$amt, 31)),
3558 (SHR32rCL GR32:$src1)>;
3559def : Pat<(store (srl (loadi8 addr:$dst), (and CL:$amt, 31)), addr:$dst),
3560 (SHR8mCL addr:$dst)>;
3561def : Pat<(store (srl (loadi16 addr:$dst), (and CL:$amt, 31)), addr:$dst),
3562 (SHR16mCL addr:$dst)>;
3563def : Pat<(store (srl (loadi32 addr:$dst), (and CL:$amt, 31)), addr:$dst),
3564 (SHR32mCL addr:$dst)>;
3565
3566def : Pat<(sra GR8:$src1, (and CL:$amt, 31)),
3567 (SAR8rCL GR8:$src1)>;
3568def : Pat<(sra GR16:$src1, (and CL:$amt, 31)),
3569 (SAR16rCL GR16:$src1)>;
3570def : Pat<(sra GR32:$src1, (and CL:$amt, 31)),
3571 (SAR32rCL GR32:$src1)>;
3572def : Pat<(store (sra (loadi8 addr:$dst), (and CL:$amt, 31)), addr:$dst),
3573 (SAR8mCL addr:$dst)>;
3574def : Pat<(store (sra (loadi16 addr:$dst), (and CL:$amt, 31)), addr:$dst),
3575 (SAR16mCL addr:$dst)>;
3576def : Pat<(store (sra (loadi32 addr:$dst), (and CL:$amt, 31)), addr:$dst),
3577 (SAR32mCL addr:$dst)>;
3578
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003579// (or (x >> c) | (y << (32 - c))) ==> (shrd32 x, y, c)
3580def : Pat<(or (srl GR32:$src1, CL:$amt),
3581 (shl GR32:$src2, (sub 32, CL:$amt))),
3582 (SHRD32rrCL GR32:$src1, GR32:$src2)>;
3583
3584def : Pat<(store (or (srl (loadi32 addr:$dst), CL:$amt),
3585 (shl GR32:$src2, (sub 32, CL:$amt))), addr:$dst),
3586 (SHRD32mrCL addr:$dst, GR32:$src2)>;
3587
Dan Gohman921581d2008-10-17 01:23:35 +00003588def : Pat<(or (srl GR32:$src1, (i8 (trunc ECX:$amt))),
3589 (shl GR32:$src2, (i8 (trunc (sub 32, ECX:$amt))))),
3590 (SHRD32rrCL GR32:$src1, GR32:$src2)>;
3591
3592def : Pat<(store (or (srl (loadi32 addr:$dst), (i8 (trunc ECX:$amt))),
3593 (shl GR32:$src2, (i8 (trunc (sub 32, ECX:$amt))))),
3594 addr:$dst),
3595 (SHRD32mrCL addr:$dst, GR32:$src2)>;
3596
3597def : Pat<(shrd GR32:$src1, (i8 imm:$amt1), GR32:$src2, (i8 imm:$amt2)),
3598 (SHRD32rri8 GR32:$src1, GR32:$src2, (i8 imm:$amt1))>;
3599
3600def : Pat<(store (shrd (loadi32 addr:$dst), (i8 imm:$amt1),
3601 GR32:$src2, (i8 imm:$amt2)), addr:$dst),
3602 (SHRD32mri8 addr:$dst, GR32:$src2, (i8 imm:$amt1))>;
3603
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003604// (or (x << c) | (y >> (32 - c))) ==> (shld32 x, y, c)
3605def : Pat<(or (shl GR32:$src1, CL:$amt),
3606 (srl GR32:$src2, (sub 32, CL:$amt))),
3607 (SHLD32rrCL GR32:$src1, GR32:$src2)>;
3608
3609def : Pat<(store (or (shl (loadi32 addr:$dst), CL:$amt),
3610 (srl GR32:$src2, (sub 32, CL:$amt))), addr:$dst),
3611 (SHLD32mrCL addr:$dst, GR32:$src2)>;
3612
Dan Gohman921581d2008-10-17 01:23:35 +00003613def : Pat<(or (shl GR32:$src1, (i8 (trunc ECX:$amt))),
3614 (srl GR32:$src2, (i8 (trunc (sub 32, ECX:$amt))))),
3615 (SHLD32rrCL GR32:$src1, GR32:$src2)>;
3616
3617def : Pat<(store (or (shl (loadi32 addr:$dst), (i8 (trunc ECX:$amt))),
3618 (srl GR32:$src2, (i8 (trunc (sub 32, ECX:$amt))))),
3619 addr:$dst),
3620 (SHLD32mrCL addr:$dst, GR32:$src2)>;
3621
3622def : Pat<(shld GR32:$src1, (i8 imm:$amt1), GR32:$src2, (i8 imm:$amt2)),
3623 (SHLD32rri8 GR32:$src1, GR32:$src2, (i8 imm:$amt1))>;
3624
3625def : Pat<(store (shld (loadi32 addr:$dst), (i8 imm:$amt1),
3626 GR32:$src2, (i8 imm:$amt2)), addr:$dst),
3627 (SHLD32mri8 addr:$dst, GR32:$src2, (i8 imm:$amt1))>;
3628
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003629// (or (x >> c) | (y << (16 - c))) ==> (shrd16 x, y, c)
3630def : Pat<(or (srl GR16:$src1, CL:$amt),
3631 (shl GR16:$src2, (sub 16, CL:$amt))),
3632 (SHRD16rrCL GR16:$src1, GR16:$src2)>;
3633
3634def : Pat<(store (or (srl (loadi16 addr:$dst), CL:$amt),
3635 (shl GR16:$src2, (sub 16, CL:$amt))), addr:$dst),
3636 (SHRD16mrCL addr:$dst, GR16:$src2)>;
3637
Dan Gohman921581d2008-10-17 01:23:35 +00003638def : Pat<(or (srl GR16:$src1, (i8 (trunc CX:$amt))),
3639 (shl GR16:$src2, (i8 (trunc (sub 16, CX:$amt))))),
3640 (SHRD16rrCL GR16:$src1, GR16:$src2)>;
3641
3642def : Pat<(store (or (srl (loadi16 addr:$dst), (i8 (trunc CX:$amt))),
3643 (shl GR16:$src2, (i8 (trunc (sub 16, CX:$amt))))),
3644 addr:$dst),
3645 (SHRD16mrCL addr:$dst, GR16:$src2)>;
3646
3647def : Pat<(shrd GR16:$src1, (i8 imm:$amt1), GR16:$src2, (i8 imm:$amt2)),
3648 (SHRD16rri8 GR16:$src1, GR16:$src2, (i8 imm:$amt1))>;
3649
3650def : Pat<(store (shrd (loadi16 addr:$dst), (i8 imm:$amt1),
3651 GR16:$src2, (i8 imm:$amt2)), addr:$dst),
3652 (SHRD16mri8 addr:$dst, GR16:$src2, (i8 imm:$amt1))>;
3653
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003654// (or (x << c) | (y >> (16 - c))) ==> (shld16 x, y, c)
3655def : Pat<(or (shl GR16:$src1, CL:$amt),
3656 (srl GR16:$src2, (sub 16, CL:$amt))),
3657 (SHLD16rrCL GR16:$src1, GR16:$src2)>;
3658
3659def : Pat<(store (or (shl (loadi16 addr:$dst), CL:$amt),
3660 (srl GR16:$src2, (sub 16, CL:$amt))), addr:$dst),
3661 (SHLD16mrCL addr:$dst, GR16:$src2)>;
3662
Dan Gohman921581d2008-10-17 01:23:35 +00003663def : Pat<(or (shl GR16:$src1, (i8 (trunc CX:$amt))),
3664 (srl GR16:$src2, (i8 (trunc (sub 16, CX:$amt))))),
3665 (SHLD16rrCL GR16:$src1, GR16:$src2)>;
3666
3667def : Pat<(store (or (shl (loadi16 addr:$dst), (i8 (trunc CX:$amt))),
3668 (srl GR16:$src2, (i8 (trunc (sub 16, CX:$amt))))),
3669 addr:$dst),
3670 (SHLD16mrCL addr:$dst, GR16:$src2)>;
3671
3672def : Pat<(shld GR16:$src1, (i8 imm:$amt1), GR16:$src2, (i8 imm:$amt2)),
3673 (SHLD16rri8 GR16:$src1, GR16:$src2, (i8 imm:$amt1))>;
3674
3675def : Pat<(store (shld (loadi16 addr:$dst), (i8 imm:$amt1),
3676 GR16:$src2, (i8 imm:$amt2)), addr:$dst),
3677 (SHLD16mri8 addr:$dst, GR16:$src2, (i8 imm:$amt1))>;
3678
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003679//===----------------------------------------------------------------------===//
Dan Gohman99a12192009-03-04 19:44:21 +00003680// EFLAGS-defining Patterns
Bill Wendlingf5399032008-12-12 21:15:41 +00003681//===----------------------------------------------------------------------===//
3682
Dan Gohman99a12192009-03-04 19:44:21 +00003683// Register-Register Addition with EFLAGS result
3684def : Pat<(parallel (X86add_flag GR8:$src1, GR8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003685 (implicit EFLAGS)),
3686 (ADD8rr GR8:$src1, GR8:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003687def : Pat<(parallel (X86add_flag GR16:$src1, GR16:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003688 (implicit EFLAGS)),
3689 (ADD16rr GR16:$src1, GR16:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003690def : Pat<(parallel (X86add_flag GR32:$src1, GR32:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003691 (implicit EFLAGS)),
3692 (ADD32rr GR32:$src1, GR32:$src2)>;
3693
Dan Gohman99a12192009-03-04 19:44:21 +00003694// Register-Memory Addition with EFLAGS result
3695def : Pat<(parallel (X86add_flag GR8:$src1, (loadi8 addr:$src2)),
Bill Wendlingf5399032008-12-12 21:15:41 +00003696 (implicit EFLAGS)),
3697 (ADD8rm GR8:$src1, addr:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003698def : Pat<(parallel (X86add_flag GR16:$src1, (loadi16 addr:$src2)),
Bill Wendlingf5399032008-12-12 21:15:41 +00003699 (implicit EFLAGS)),
3700 (ADD16rm GR16:$src1, addr:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003701def : Pat<(parallel (X86add_flag GR32:$src1, (loadi32 addr:$src2)),
Bill Wendlingf5399032008-12-12 21:15:41 +00003702 (implicit EFLAGS)),
3703 (ADD32rm GR32:$src1, addr:$src2)>;
3704
Dan Gohman99a12192009-03-04 19:44:21 +00003705// Register-Integer Addition with EFLAGS result
3706def : Pat<(parallel (X86add_flag GR8:$src1, imm:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003707 (implicit EFLAGS)),
3708 (ADD8ri GR8:$src1, imm:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003709def : Pat<(parallel (X86add_flag GR16:$src1, imm:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003710 (implicit EFLAGS)),
3711 (ADD16ri GR16:$src1, imm:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003712def : Pat<(parallel (X86add_flag GR32:$src1, imm:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003713 (implicit EFLAGS)),
3714 (ADD32ri GR32:$src1, imm:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003715def : Pat<(parallel (X86add_flag GR16:$src1, i16immSExt8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003716 (implicit EFLAGS)),
3717 (ADD16ri8 GR16:$src1, i16immSExt8:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003718def : Pat<(parallel (X86add_flag GR32:$src1, i32immSExt8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003719 (implicit EFLAGS)),
3720 (ADD32ri8 GR32:$src1, i32immSExt8:$src2)>;
3721
Dan Gohman99a12192009-03-04 19:44:21 +00003722// Memory-Register Addition with EFLAGS result
3723def : Pat<(parallel (store (X86add_flag (loadi8 addr:$dst), GR8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003724 addr:$dst),
3725 (implicit EFLAGS)),
3726 (ADD8mr addr:$dst, GR8:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003727def : Pat<(parallel (store (X86add_flag (loadi16 addr:$dst), GR16:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003728 addr:$dst),
3729 (implicit EFLAGS)),
3730 (ADD16mr addr:$dst, GR16:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003731def : Pat<(parallel (store (X86add_flag (loadi32 addr:$dst), GR32:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003732 addr:$dst),
3733 (implicit EFLAGS)),
3734 (ADD32mr addr:$dst, GR32:$src2)>;
Dale Johannesen06b83f12009-05-18 17:44:15 +00003735
3736// Memory-Integer Addition with EFLAGS result
Dan Gohman99a12192009-03-04 19:44:21 +00003737def : Pat<(parallel (store (X86add_flag (loadi8 addr:$dst), imm:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003738 addr:$dst),
3739 (implicit EFLAGS)),
3740 (ADD8mi addr:$dst, imm:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003741def : Pat<(parallel (store (X86add_flag (loadi16 addr:$dst), imm:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003742 addr:$dst),
3743 (implicit EFLAGS)),
3744 (ADD16mi addr:$dst, imm:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003745def : Pat<(parallel (store (X86add_flag (loadi32 addr:$dst), imm:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003746 addr:$dst),
3747 (implicit EFLAGS)),
3748 (ADD32mi addr:$dst, imm:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003749def : Pat<(parallel (store (X86add_flag (loadi16 addr:$dst), i16immSExt8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003750 addr:$dst),
3751 (implicit EFLAGS)),
3752 (ADD16mi8 addr:$dst, i16immSExt8:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003753def : Pat<(parallel (store (X86add_flag (loadi32 addr:$dst), i32immSExt8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003754 addr:$dst),
3755 (implicit EFLAGS)),
3756 (ADD32mi8 addr:$dst, i32immSExt8:$src2)>;
3757
Dan Gohman99a12192009-03-04 19:44:21 +00003758// Register-Register Subtraction with EFLAGS result
3759def : Pat<(parallel (X86sub_flag GR8:$src1, GR8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003760 (implicit EFLAGS)),
3761 (SUB8rr GR8:$src1, GR8:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003762def : Pat<(parallel (X86sub_flag GR16:$src1, GR16:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003763 (implicit EFLAGS)),
3764 (SUB16rr GR16:$src1, GR16:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003765def : Pat<(parallel (X86sub_flag GR32:$src1, GR32:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003766 (implicit EFLAGS)),
3767 (SUB32rr GR32:$src1, GR32:$src2)>;
3768
Dan Gohman99a12192009-03-04 19:44:21 +00003769// Register-Memory Subtraction with EFLAGS result
3770def : Pat<(parallel (X86sub_flag GR8:$src1, (loadi8 addr:$src2)),
Bill Wendlingf5399032008-12-12 21:15:41 +00003771 (implicit EFLAGS)),
3772 (SUB8rm GR8:$src1, addr:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003773def : Pat<(parallel (X86sub_flag GR16:$src1, (loadi16 addr:$src2)),
Bill Wendlingf5399032008-12-12 21:15:41 +00003774 (implicit EFLAGS)),
3775 (SUB16rm GR16:$src1, addr:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003776def : Pat<(parallel (X86sub_flag GR32:$src1, (loadi32 addr:$src2)),
Bill Wendlingf5399032008-12-12 21:15:41 +00003777 (implicit EFLAGS)),
3778 (SUB32rm GR32:$src1, addr:$src2)>;
3779
Dan Gohman99a12192009-03-04 19:44:21 +00003780// Register-Integer Subtraction with EFLAGS result
3781def : Pat<(parallel (X86sub_flag GR8:$src1, imm:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003782 (implicit EFLAGS)),
3783 (SUB8ri GR8:$src1, imm:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003784def : Pat<(parallel (X86sub_flag GR16:$src1, imm:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003785 (implicit EFLAGS)),
3786 (SUB16ri GR16:$src1, imm:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003787def : Pat<(parallel (X86sub_flag GR32:$src1, imm:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003788 (implicit EFLAGS)),
3789 (SUB32ri GR32:$src1, imm:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003790def : Pat<(parallel (X86sub_flag GR16:$src1, i16immSExt8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003791 (implicit EFLAGS)),
3792 (SUB16ri8 GR16:$src1, i16immSExt8:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003793def : Pat<(parallel (X86sub_flag GR32:$src1, i32immSExt8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003794 (implicit EFLAGS)),
3795 (SUB32ri8 GR32:$src1, i32immSExt8:$src2)>;
3796
Dan Gohman99a12192009-03-04 19:44:21 +00003797// Memory-Register Subtraction with EFLAGS result
3798def : Pat<(parallel (store (X86sub_flag (loadi8 addr:$dst), GR8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003799 addr:$dst),
3800 (implicit EFLAGS)),
3801 (SUB8mr addr:$dst, GR8:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003802def : Pat<(parallel (store (X86sub_flag (loadi16 addr:$dst), GR16:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003803 addr:$dst),
3804 (implicit EFLAGS)),
3805 (SUB16mr addr:$dst, GR16:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003806def : Pat<(parallel (store (X86sub_flag (loadi32 addr:$dst), GR32:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003807 addr:$dst),
3808 (implicit EFLAGS)),
3809 (SUB32mr addr:$dst, GR32:$src2)>;
3810
Dan Gohman99a12192009-03-04 19:44:21 +00003811// Memory-Integer Subtraction with EFLAGS result
3812def : Pat<(parallel (store (X86sub_flag (loadi8 addr:$dst), imm:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003813 addr:$dst),
3814 (implicit EFLAGS)),
3815 (SUB8mi addr:$dst, imm:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003816def : Pat<(parallel (store (X86sub_flag (loadi16 addr:$dst), imm:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003817 addr:$dst),
3818 (implicit EFLAGS)),
3819 (SUB16mi addr:$dst, imm:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003820def : Pat<(parallel (store (X86sub_flag (loadi32 addr:$dst), imm:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003821 addr:$dst),
3822 (implicit EFLAGS)),
3823 (SUB32mi addr:$dst, imm:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003824def : Pat<(parallel (store (X86sub_flag (loadi16 addr:$dst), i16immSExt8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003825 addr:$dst),
3826 (implicit EFLAGS)),
3827 (SUB16mi8 addr:$dst, i16immSExt8:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003828def : Pat<(parallel (store (X86sub_flag (loadi32 addr:$dst), i32immSExt8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003829 addr:$dst),
3830 (implicit EFLAGS)),
3831 (SUB32mi8 addr:$dst, i32immSExt8:$src2)>;
3832
3833
Dan Gohman99a12192009-03-04 19:44:21 +00003834// Register-Register Signed Integer Multiply with EFLAGS result
3835def : Pat<(parallel (X86smul_flag GR16:$src1, GR16:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003836 (implicit EFLAGS)),
3837 (IMUL16rr GR16:$src1, GR16:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003838def : Pat<(parallel (X86smul_flag GR32:$src1, GR32:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003839 (implicit EFLAGS)),
3840 (IMUL32rr GR32:$src1, GR32:$src2)>;
3841
Dan Gohman99a12192009-03-04 19:44:21 +00003842// Register-Memory Signed Integer Multiply with EFLAGS result
3843def : Pat<(parallel (X86smul_flag GR16:$src1, (loadi16 addr:$src2)),
Bill Wendlingf5399032008-12-12 21:15:41 +00003844 (implicit EFLAGS)),
3845 (IMUL16rm GR16:$src1, addr:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003846def : Pat<(parallel (X86smul_flag GR32:$src1, (loadi32 addr:$src2)),
Bill Wendlingf5399032008-12-12 21:15:41 +00003847 (implicit EFLAGS)),
3848 (IMUL32rm GR32:$src1, addr:$src2)>;
3849
Dan Gohman99a12192009-03-04 19:44:21 +00003850// Register-Integer Signed Integer Multiply with EFLAGS result
3851def : Pat<(parallel (X86smul_flag GR16:$src1, imm:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003852 (implicit EFLAGS)),
3853 (IMUL16rri GR16:$src1, imm:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003854def : Pat<(parallel (X86smul_flag GR32:$src1, imm:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003855 (implicit EFLAGS)),
3856 (IMUL32rri GR32:$src1, imm:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003857def : Pat<(parallel (X86smul_flag GR16:$src1, i16immSExt8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003858 (implicit EFLAGS)),
3859 (IMUL16rri8 GR16:$src1, i16immSExt8:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003860def : Pat<(parallel (X86smul_flag GR32:$src1, i32immSExt8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003861 (implicit EFLAGS)),
3862 (IMUL32rri8 GR32:$src1, i32immSExt8:$src2)>;
3863
Dan Gohman99a12192009-03-04 19:44:21 +00003864// Memory-Integer Signed Integer Multiply with EFLAGS result
3865def : Pat<(parallel (X86smul_flag (loadi16 addr:$src1), imm:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003866 (implicit EFLAGS)),
3867 (IMUL16rmi addr:$src1, imm:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003868def : Pat<(parallel (X86smul_flag (loadi32 addr:$src1), imm:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003869 (implicit EFLAGS)),
3870 (IMUL32rmi addr:$src1, imm:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003871def : Pat<(parallel (X86smul_flag (loadi16 addr:$src1), i16immSExt8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003872 (implicit EFLAGS)),
3873 (IMUL16rmi8 addr:$src1, i16immSExt8:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003874def : Pat<(parallel (X86smul_flag (loadi32 addr:$src1), i32immSExt8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003875 (implicit EFLAGS)),
3876 (IMUL32rmi8 addr:$src1, i32immSExt8:$src2)>;
3877
Dan Gohman99a12192009-03-04 19:44:21 +00003878// Optimize multiply by 2 with EFLAGS result.
Evan Cheng00cf7932009-01-27 03:30:42 +00003879let AddedComplexity = 2 in {
Dan Gohman99a12192009-03-04 19:44:21 +00003880def : Pat<(parallel (X86smul_flag GR16:$src1, 2),
Evan Cheng00cf7932009-01-27 03:30:42 +00003881 (implicit EFLAGS)),
3882 (ADD16rr GR16:$src1, GR16:$src1)>;
3883
Dan Gohman99a12192009-03-04 19:44:21 +00003884def : Pat<(parallel (X86smul_flag GR32:$src1, 2),
Evan Cheng00cf7932009-01-27 03:30:42 +00003885 (implicit EFLAGS)),
3886 (ADD32rr GR32:$src1, GR32:$src1)>;
3887}
3888
Dan Gohman99a12192009-03-04 19:44:21 +00003889// INC and DEC with EFLAGS result. Note that these do not set CF.
3890def : Pat<(parallel (X86inc_flag GR8:$src), (implicit EFLAGS)),
3891 (INC8r GR8:$src)>;
3892def : Pat<(parallel (store (i8 (X86inc_flag (loadi8 addr:$dst))), addr:$dst),
3893 (implicit EFLAGS)),
3894 (INC8m addr:$dst)>;
3895def : Pat<(parallel (X86dec_flag GR8:$src), (implicit EFLAGS)),
3896 (DEC8r GR8:$src)>;
3897def : Pat<(parallel (store (i8 (X86dec_flag (loadi8 addr:$dst))), addr:$dst),
3898 (implicit EFLAGS)),
3899 (DEC8m addr:$dst)>;
3900
3901def : Pat<(parallel (X86inc_flag GR16:$src), (implicit EFLAGS)),
Dan Gohmaneebcac72009-03-05 21:32:23 +00003902 (INC16r GR16:$src)>, Requires<[In32BitMode]>;
Dan Gohman99a12192009-03-04 19:44:21 +00003903def : Pat<(parallel (store (i16 (X86inc_flag (loadi16 addr:$dst))), addr:$dst),
3904 (implicit EFLAGS)),
Dan Gohmaneebcac72009-03-05 21:32:23 +00003905 (INC16m addr:$dst)>, Requires<[In32BitMode]>;
Dan Gohman99a12192009-03-04 19:44:21 +00003906def : Pat<(parallel (X86dec_flag GR16:$src), (implicit EFLAGS)),
Dan Gohmaneebcac72009-03-05 21:32:23 +00003907 (DEC16r GR16:$src)>, Requires<[In32BitMode]>;
Dan Gohman99a12192009-03-04 19:44:21 +00003908def : Pat<(parallel (store (i16 (X86dec_flag (loadi16 addr:$dst))), addr:$dst),
3909 (implicit EFLAGS)),
Dan Gohmaneebcac72009-03-05 21:32:23 +00003910 (DEC16m addr:$dst)>, Requires<[In32BitMode]>;
Dan Gohman99a12192009-03-04 19:44:21 +00003911
3912def : Pat<(parallel (X86inc_flag GR32:$src), (implicit EFLAGS)),
Dan Gohmaneebcac72009-03-05 21:32:23 +00003913 (INC32r GR32:$src)>, Requires<[In32BitMode]>;
Dan Gohman99a12192009-03-04 19:44:21 +00003914def : Pat<(parallel (store (i32 (X86inc_flag (loadi32 addr:$dst))), addr:$dst),
3915 (implicit EFLAGS)),
Dan Gohmaneebcac72009-03-05 21:32:23 +00003916 (INC32m addr:$dst)>, Requires<[In32BitMode]>;
Dan Gohman99a12192009-03-04 19:44:21 +00003917def : Pat<(parallel (X86dec_flag GR32:$src), (implicit EFLAGS)),
Dan Gohmaneebcac72009-03-05 21:32:23 +00003918 (DEC32r GR32:$src)>, Requires<[In32BitMode]>;
Dan Gohman99a12192009-03-04 19:44:21 +00003919def : Pat<(parallel (store (i32 (X86dec_flag (loadi32 addr:$dst))), addr:$dst),
3920 (implicit EFLAGS)),
Dan Gohmaneebcac72009-03-05 21:32:23 +00003921 (DEC32m addr:$dst)>, Requires<[In32BitMode]>;
Dan Gohman99a12192009-03-04 19:44:21 +00003922
Bill Wendlingf5399032008-12-12 21:15:41 +00003923//===----------------------------------------------------------------------===//
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003924// Floating Point Stack Support
3925//===----------------------------------------------------------------------===//
3926
3927include "X86InstrFPStack.td"
3928
3929//===----------------------------------------------------------------------===//
Evan Cheng86ab7d32007-07-31 08:04:03 +00003930// X86-64 Support
3931//===----------------------------------------------------------------------===//
3932
Chris Lattner2de8d2b2008-01-10 05:50:42 +00003933include "X86Instr64bit.td"
Evan Cheng86ab7d32007-07-31 08:04:03 +00003934
3935//===----------------------------------------------------------------------===//
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003936// XMM Floating point support (requires SSE / SSE2)
3937//===----------------------------------------------------------------------===//
3938
3939include "X86InstrSSE.td"
Evan Cheng5e4d1e72008-04-25 18:19:54 +00003940
3941//===----------------------------------------------------------------------===//
3942// MMX and XMM Packed Integer support (requires MMX, SSE, and SSE2)
3943//===----------------------------------------------------------------------===//
3944
3945include "X86InstrMMX.td"