blob: 10eddf0f110d88cecf8c615a39e19e3322e0142a [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 Cheng52da5762009-05-20 01:11:00 +0000237def IsNotPIC : Predicate<"TM.getRelocationModel() != Reloc::PIC_">;
Evan Cheng13559d62008-09-26 23:41:32 +0000238def OptForSpeed : Predicate<"!OptForSize">;
Evan Cheng95a77fd2009-01-02 05:35:45 +0000239def FastBTMem : Predicate<"!Subtarget->isBTMemSlow()">;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000240
241//===----------------------------------------------------------------------===//
Evan Cheng86ab7d32007-07-31 08:04:03 +0000242// X86 Instruction Format Definitions.
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000243//
244
Evan Cheng86ab7d32007-07-31 08:04:03 +0000245include "X86InstrFormats.td"
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000246
247//===----------------------------------------------------------------------===//
248// Pattern fragments...
249//
250
251// X86 specific condition code. These correspond to CondCode in
252// X86InstrInfo.h. They must be kept in synch.
Dan Gohman0fc9ed62009-01-07 00:15:08 +0000253def X86_COND_A : PatLeaf<(i8 0)>; // alt. COND_NBE
254def X86_COND_AE : PatLeaf<(i8 1)>; // alt. COND_NC
255def X86_COND_B : PatLeaf<(i8 2)>; // alt. COND_C
256def X86_COND_BE : PatLeaf<(i8 3)>; // alt. COND_NA
257def X86_COND_E : PatLeaf<(i8 4)>; // alt. COND_Z
258def X86_COND_G : PatLeaf<(i8 5)>; // alt. COND_NLE
259def X86_COND_GE : PatLeaf<(i8 6)>; // alt. COND_NL
260def X86_COND_L : PatLeaf<(i8 7)>; // alt. COND_NGE
261def X86_COND_LE : PatLeaf<(i8 8)>; // alt. COND_NG
262def X86_COND_NE : PatLeaf<(i8 9)>; // alt. COND_NZ
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000263def X86_COND_NO : PatLeaf<(i8 10)>;
Dan Gohman0fc9ed62009-01-07 00:15:08 +0000264def X86_COND_NP : PatLeaf<(i8 11)>; // alt. COND_PO
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000265def X86_COND_NS : PatLeaf<(i8 12)>;
Dan Gohman0fc9ed62009-01-07 00:15:08 +0000266def X86_COND_O : PatLeaf<(i8 13)>;
267def X86_COND_P : PatLeaf<(i8 14)>; // alt. COND_PE
268def X86_COND_S : PatLeaf<(i8 15)>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000269
270def i16immSExt8 : PatLeaf<(i16 imm), [{
271 // i16immSExt8 predicate - True if the 16-bit immediate fits in a 8-bit
272 // sign extended field.
Dan Gohmanfaeb4a32008-09-12 16:56:44 +0000273 return (int16_t)N->getZExtValue() == (int8_t)N->getZExtValue();
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000274}]>;
275
276def i32immSExt8 : PatLeaf<(i32 imm), [{
277 // i32immSExt8 predicate - True if the 32-bit immediate fits in a 8-bit
278 // sign extended field.
Dan Gohmanfaeb4a32008-09-12 16:56:44 +0000279 return (int32_t)N->getZExtValue() == (int8_t)N->getZExtValue();
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000280}]>;
281
282// Helper fragments for loads.
Evan Chengb3e25ea2008-05-13 18:59:59 +0000283// It's always safe to treat a anyext i16 load as a i32 load if the i16 is
284// known to be 32-bit aligned or better. Ditto for i8 to i16.
Dan Gohman2a174122008-10-15 06:50:19 +0000285def loadi16 : PatFrag<(ops node:$ptr), (i16 (unindexedload node:$ptr)), [{
Dan Gohman8335c412008-08-20 15:24:22 +0000286 LoadSDNode *LD = cast<LoadSDNode>(N);
Chris Lattner12208612009-04-10 00:16:23 +0000287 if (const Value *Src = LD->getSrcValue())
288 if (const PointerType *PT = dyn_cast<PointerType>(Src->getType()))
Mon P Wangdc97d5a2009-04-27 07:22:10 +0000289 if (PT->getAddressSpace() > 255)
Chris Lattner12208612009-04-10 00:16:23 +0000290 return false;
Dan Gohman8335c412008-08-20 15:24:22 +0000291 ISD::LoadExtType ExtType = LD->getExtensionType();
292 if (ExtType == ISD::NON_EXTLOAD)
293 return true;
294 if (ExtType == ISD::EXTLOAD)
295 return LD->getAlignment() >= 2 && !LD->isVolatile();
Evan Cheng8b765e92008-05-13 00:54:02 +0000296 return false;
297}]>;
298
Dan Gohman2a174122008-10-15 06:50:19 +0000299def loadi16_anyext : PatFrag<(ops node:$ptr), (i32 (unindexedload node:$ptr)), [{
Evan Cheng56ec77b2008-09-24 23:27:55 +0000300 LoadSDNode *LD = cast<LoadSDNode>(N);
Chris Lattner12208612009-04-10 00:16:23 +0000301 if (const Value *Src = LD->getSrcValue())
302 if (const PointerType *PT = dyn_cast<PointerType>(Src->getType()))
Mon P Wangdc97d5a2009-04-27 07:22:10 +0000303 if (PT->getAddressSpace() > 255)
Chris Lattner12208612009-04-10 00:16:23 +0000304 return false;
Evan Cheng56ec77b2008-09-24 23:27:55 +0000305 ISD::LoadExtType ExtType = LD->getExtensionType();
306 if (ExtType == ISD::EXTLOAD)
307 return LD->getAlignment() >= 2 && !LD->isVolatile();
308 return false;
309}]>;
310
Dan Gohman2a174122008-10-15 06:50:19 +0000311def loadi32 : PatFrag<(ops node:$ptr), (i32 (unindexedload node:$ptr)), [{
Dan Gohman8335c412008-08-20 15:24:22 +0000312 LoadSDNode *LD = cast<LoadSDNode>(N);
Chris Lattner12208612009-04-10 00:16:23 +0000313 if (const Value *Src = LD->getSrcValue())
314 if (const PointerType *PT = dyn_cast<PointerType>(Src->getType()))
Mon P Wangdc97d5a2009-04-27 07:22:10 +0000315 if (PT->getAddressSpace() > 255)
Chris Lattner12208612009-04-10 00:16:23 +0000316 return false;
Dan Gohman8335c412008-08-20 15:24:22 +0000317 ISD::LoadExtType ExtType = LD->getExtensionType();
318 if (ExtType == ISD::NON_EXTLOAD)
319 return true;
320 if (ExtType == ISD::EXTLOAD)
321 return LD->getAlignment() >= 4 && !LD->isVolatile();
Evan Cheng8b765e92008-05-13 00:54:02 +0000322 return false;
323}]>;
324
Dan Gohman2a174122008-10-15 06:50:19 +0000325def nvloadi32 : PatFrag<(ops node:$ptr), (i32 (unindexedload node:$ptr)), [{
Evan Cheng1e5e5452008-09-29 17:26:18 +0000326 LoadSDNode *LD = cast<LoadSDNode>(N);
Chris Lattner12208612009-04-10 00:16:23 +0000327 if (const Value *Src = LD->getSrcValue())
328 if (const PointerType *PT = dyn_cast<PointerType>(Src->getType()))
Mon P Wangdc97d5a2009-04-27 07:22:10 +0000329 if (PT->getAddressSpace() > 255)
Chris Lattner12208612009-04-10 00:16:23 +0000330 return false;
Evan Cheng1e5e5452008-09-29 17:26:18 +0000331 if (LD->isVolatile())
332 return false;
Evan Cheng1e5e5452008-09-29 17:26:18 +0000333 ISD::LoadExtType ExtType = LD->getExtensionType();
334 if (ExtType == ISD::NON_EXTLOAD)
335 return true;
336 if (ExtType == ISD::EXTLOAD)
337 return LD->getAlignment() >= 4;
338 return false;
339}]>;
340
sampo9cc09a32009-01-26 01:24:32 +0000341def gsload : PatFrag<(ops node:$ptr), (load node:$ptr), [{
Chris Lattner12208612009-04-10 00:16:23 +0000342 if (const Value *Src = cast<LoadSDNode>(N)->getSrcValue())
343 if (const PointerType *PT = dyn_cast<PointerType>(Src->getType()))
344 return PT->getAddressSpace() == 256;
sampo9cc09a32009-01-26 01:24:32 +0000345 return false;
346}]>;
347
Chris Lattnera7c2d8a2009-05-05 18:52:19 +0000348def fsload : PatFrag<(ops node:$ptr), (load node:$ptr), [{
349 if (const Value *Src = cast<LoadSDNode>(N)->getSrcValue())
350 if (const PointerType *PT = dyn_cast<PointerType>(Src->getType()))
351 return PT->getAddressSpace() == 257;
352 return false;
353}]>;
354
Chris Lattner12208612009-04-10 00:16:23 +0000355def loadi8 : PatFrag<(ops node:$ptr), (i8 (load node:$ptr)), [{
356 if (const Value *Src = cast<LoadSDNode>(N)->getSrcValue())
357 if (const PointerType *PT = dyn_cast<PointerType>(Src->getType()))
Mon P Wangdc97d5a2009-04-27 07:22:10 +0000358 if (PT->getAddressSpace() > 255)
Chris Lattner12208612009-04-10 00:16:23 +0000359 return false;
360 return true;
361}]>;
362def loadi64 : PatFrag<(ops node:$ptr), (i64 (load node:$ptr)), [{
363 if (const Value *Src = cast<LoadSDNode>(N)->getSrcValue())
364 if (const PointerType *PT = dyn_cast<PointerType>(Src->getType()))
Mon P Wangdc97d5a2009-04-27 07:22:10 +0000365 if (PT->getAddressSpace() > 255)
Chris Lattner12208612009-04-10 00:16:23 +0000366 return false;
367 return true;
368}]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000369
Chris Lattner12208612009-04-10 00:16:23 +0000370def loadf32 : PatFrag<(ops node:$ptr), (f32 (load node:$ptr)), [{
371 if (const Value *Src = cast<LoadSDNode>(N)->getSrcValue())
372 if (const PointerType *PT = dyn_cast<PointerType>(Src->getType()))
Mon P Wangdc97d5a2009-04-27 07:22:10 +0000373 if (PT->getAddressSpace() > 255)
Chris Lattner12208612009-04-10 00:16:23 +0000374 return false;
375 return true;
376}]>;
377def loadf64 : PatFrag<(ops node:$ptr), (f64 (load node:$ptr)), [{
378 if (const Value *Src = cast<LoadSDNode>(N)->getSrcValue())
379 if (const PointerType *PT = dyn_cast<PointerType>(Src->getType()))
Mon P Wangdc97d5a2009-04-27 07:22:10 +0000380 if (PT->getAddressSpace() > 255)
Chris Lattner12208612009-04-10 00:16:23 +0000381 return false;
382 return true;
383}]>;
384def loadf80 : PatFrag<(ops node:$ptr), (f80 (load node:$ptr)), [{
385 if (const Value *Src = cast<LoadSDNode>(N)->getSrcValue())
386 if (const PointerType *PT = dyn_cast<PointerType>(Src->getType()))
Mon P Wangdc97d5a2009-04-27 07:22:10 +0000387 if (PT->getAddressSpace() > 255)
Chris Lattner12208612009-04-10 00:16:23 +0000388 return false;
389 return true;
390}]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000391
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000392def sextloadi16i8 : PatFrag<(ops node:$ptr), (i16 (sextloadi8 node:$ptr))>;
393def sextloadi32i8 : PatFrag<(ops node:$ptr), (i32 (sextloadi8 node:$ptr))>;
394def sextloadi32i16 : PatFrag<(ops node:$ptr), (i32 (sextloadi16 node:$ptr))>;
395
396def zextloadi8i1 : PatFrag<(ops node:$ptr), (i8 (zextloadi1 node:$ptr))>;
397def zextloadi16i1 : PatFrag<(ops node:$ptr), (i16 (zextloadi1 node:$ptr))>;
398def zextloadi32i1 : PatFrag<(ops node:$ptr), (i32 (zextloadi1 node:$ptr))>;
399def zextloadi16i8 : PatFrag<(ops node:$ptr), (i16 (zextloadi8 node:$ptr))>;
400def zextloadi32i8 : PatFrag<(ops node:$ptr), (i32 (zextloadi8 node:$ptr))>;
401def zextloadi32i16 : PatFrag<(ops node:$ptr), (i32 (zextloadi16 node:$ptr))>;
402
403def extloadi8i1 : PatFrag<(ops node:$ptr), (i8 (extloadi1 node:$ptr))>;
404def extloadi16i1 : PatFrag<(ops node:$ptr), (i16 (extloadi1 node:$ptr))>;
405def extloadi32i1 : PatFrag<(ops node:$ptr), (i32 (extloadi1 node:$ptr))>;
406def extloadi16i8 : PatFrag<(ops node:$ptr), (i16 (extloadi8 node:$ptr))>;
407def extloadi32i8 : PatFrag<(ops node:$ptr), (i32 (extloadi8 node:$ptr))>;
408def extloadi32i16 : PatFrag<(ops node:$ptr), (i32 (extloadi16 node:$ptr))>;
409
Chris Lattner21da6382008-02-19 17:37:35 +0000410
411// An 'and' node with a single use.
412def and_su : PatFrag<(ops node:$lhs, node:$rhs), (and node:$lhs, node:$rhs), [{
Evan Cheng9123cfa2008-03-04 00:40:35 +0000413 return N->hasOneUse();
Chris Lattner21da6382008-02-19 17:37:35 +0000414}]>;
Dan Gohman744d4622009-04-13 16:09:41 +0000415// An 'srl' node with a single use.
416def srl_su : PatFrag<(ops node:$lhs, node:$rhs), (srl node:$lhs, node:$rhs), [{
417 return N->hasOneUse();
418}]>;
419// An 'trunc' node with a single use.
420def trunc_su : PatFrag<(ops node:$src), (trunc node:$src), [{
421 return N->hasOneUse();
422}]>;
Chris Lattner21da6382008-02-19 17:37:35 +0000423
Dan Gohman921581d2008-10-17 01:23:35 +0000424// 'shld' and 'shrd' instruction patterns. Note that even though these have
425// the srl and shl in their patterns, the C++ code must still check for them,
426// because predicates are tested before children nodes are explored.
427
428def shrd : PatFrag<(ops node:$src1, node:$amt1, node:$src2, node:$amt2),
429 (or (srl node:$src1, node:$amt1),
430 (shl node:$src2, node:$amt2)), [{
431 assert(N->getOpcode() == ISD::OR);
432 return N->getOperand(0).getOpcode() == ISD::SRL &&
433 N->getOperand(1).getOpcode() == ISD::SHL &&
434 isa<ConstantSDNode>(N->getOperand(0).getOperand(1)) &&
435 isa<ConstantSDNode>(N->getOperand(1).getOperand(1)) &&
436 N->getOperand(0).getConstantOperandVal(1) ==
437 N->getValueSizeInBits(0) - N->getOperand(1).getConstantOperandVal(1);
438}]>;
439
440def shld : PatFrag<(ops node:$src1, node:$amt1, node:$src2, node:$amt2),
441 (or (shl node:$src1, node:$amt1),
442 (srl node:$src2, node:$amt2)), [{
443 assert(N->getOpcode() == ISD::OR);
444 return N->getOperand(0).getOpcode() == ISD::SHL &&
445 N->getOperand(1).getOpcode() == ISD::SRL &&
446 isa<ConstantSDNode>(N->getOperand(0).getOperand(1)) &&
447 isa<ConstantSDNode>(N->getOperand(1).getOperand(1)) &&
448 N->getOperand(0).getConstantOperandVal(1) ==
449 N->getValueSizeInBits(0) - N->getOperand(1).getConstantOperandVal(1);
450}]>;
451
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000452//===----------------------------------------------------------------------===//
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000453// Instruction list...
454//
455
456// ADJCALLSTACKDOWN/UP implicitly use/def ESP because they may be expanded into
457// a stack adjustment and the codegen must know that they may modify the stack
458// pointer before prolog-epilog rewriting occurs.
Chris Lattnerb56cc342008-03-11 03:23:40 +0000459// Pessimistically assume ADJCALLSTACKDOWN / ADJCALLSTACKUP will become
460// sub / add which can clobber EFLAGS.
Evan Cheng037364a2007-09-28 01:19:48 +0000461let Defs = [ESP, EFLAGS], Uses = [ESP] in {
Dan Gohman01c9f772008-10-01 18:28:06 +0000462def ADJCALLSTACKDOWN32 : I<0, Pseudo, (outs), (ins i32imm:$amt),
463 "#ADJCALLSTACKDOWN",
Chris Lattnerfe5d4022008-10-11 22:08:30 +0000464 [(X86callseq_start timm:$amt)]>,
Dan Gohman01c9f772008-10-01 18:28:06 +0000465 Requires<[In32BitMode]>;
466def ADJCALLSTACKUP32 : I<0, Pseudo, (outs), (ins i32imm:$amt1, i32imm:$amt2),
467 "#ADJCALLSTACKUP",
Chris Lattnerfe5d4022008-10-11 22:08:30 +0000468 [(X86callseq_end timm:$amt1, timm:$amt2)]>,
Dan Gohman01c9f772008-10-01 18:28:06 +0000469 Requires<[In32BitMode]>;
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000470}
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000471
472// Nop
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000473let neverHasSideEffects = 1 in
474 def NOOP : I<0x90, RawFrm, (outs), (ins), "nop", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000475
Evan Cheng0729ccf2008-01-05 00:41:47 +0000476// PIC base
Dan Gohman9499cfe2008-10-01 04:14:30 +0000477let neverHasSideEffects = 1, isNotDuplicable = 1, Uses = [ESP] in
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000478 def MOVPC32r : Ii32<0xE8, Pseudo, (outs GR32:$reg), (ins piclabel:$label),
Dan Gohman70a8a112009-04-27 15:13:28 +0000479 "call\t$label\n\t"
480 "pop{l}\t$reg", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000481
482//===----------------------------------------------------------------------===//
483// Control Flow Instructions...
484//
485
486// Return instructions.
487let isTerminator = 1, isReturn = 1, isBarrier = 1,
Chris Lattnerb56cc342008-03-11 03:23:40 +0000488 hasCtrlDep = 1, FPForm = SpecialFP, FPFormBits = SpecialFP.Value in {
Dan Gohman2c4be2a2008-05-31 02:11:25 +0000489 def RET : I <0xC3, RawFrm, (outs), (ins variable_ops),
Chris Lattnerb56cc342008-03-11 03:23:40 +0000490 "ret",
Dan Gohman2c4be2a2008-05-31 02:11:25 +0000491 [(X86retflag 0)]>;
Chris Lattnerb56cc342008-03-11 03:23:40 +0000492 def RETI : Ii16<0xC2, RawFrm, (outs), (ins i16imm:$amt, variable_ops),
493 "ret\t$amt",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000494 [(X86retflag imm:$amt)]>;
495}
496
497// All branches are RawFrm, Void, Branch, and Terminators
Evan Cheng37e7c752007-07-21 00:34:19 +0000498let isBranch = 1, isTerminator = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +0000499 class IBr<bits<8> opcode, dag ins, string asm, list<dag> pattern> :
500 I<opcode, RawFrm, (outs), ins, asm, pattern>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000501
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000502let isBranch = 1, isBarrier = 1 in
Dan Gohman91888f02007-07-31 20:11:57 +0000503 def JMP : IBr<0xE9, (ins brtarget:$dst), "jmp\t$dst", [(br bb:$dst)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000504
Owen Andersonf8053082007-11-12 07:39:39 +0000505// Indirect branches
506let isBranch = 1, isTerminator = 1, isBarrier = 1, isIndirectBranch = 1 in {
Dan Gohman91888f02007-07-31 20:11:57 +0000507 def JMP32r : I<0xFF, MRM4r, (outs), (ins GR32:$dst), "jmp{l}\t{*}$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000508 [(brind GR32:$dst)]>;
Dan Gohman91888f02007-07-31 20:11:57 +0000509 def JMP32m : I<0xFF, MRM4m, (outs), (ins i32mem:$dst), "jmp{l}\t{*}$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000510 [(brind (loadi32 addr:$dst))]>;
511}
512
513// Conditional branches
Evan Cheng950aac02007-09-25 01:57:46 +0000514let Uses = [EFLAGS] in {
Dan Gohman91888f02007-07-31 20:11:57 +0000515def JE : IBr<0x84, (ins brtarget:$dst), "je\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000516 [(X86brcond bb:$dst, X86_COND_E, EFLAGS)]>, TB;
Dan Gohman91888f02007-07-31 20:11:57 +0000517def JNE : IBr<0x85, (ins brtarget:$dst), "jne\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000518 [(X86brcond bb:$dst, X86_COND_NE, EFLAGS)]>, TB;
Dan Gohman91888f02007-07-31 20:11:57 +0000519def JL : IBr<0x8C, (ins brtarget:$dst), "jl\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000520 [(X86brcond bb:$dst, X86_COND_L, EFLAGS)]>, TB;
Dan Gohman91888f02007-07-31 20:11:57 +0000521def JLE : IBr<0x8E, (ins brtarget:$dst), "jle\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000522 [(X86brcond bb:$dst, X86_COND_LE, EFLAGS)]>, TB;
Dan Gohman91888f02007-07-31 20:11:57 +0000523def JG : IBr<0x8F, (ins brtarget:$dst), "jg\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000524 [(X86brcond bb:$dst, X86_COND_G, EFLAGS)]>, TB;
Dan Gohman91888f02007-07-31 20:11:57 +0000525def JGE : IBr<0x8D, (ins brtarget:$dst), "jge\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000526 [(X86brcond bb:$dst, X86_COND_GE, EFLAGS)]>, TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000527
Dan Gohman91888f02007-07-31 20:11:57 +0000528def JB : IBr<0x82, (ins brtarget:$dst), "jb\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000529 [(X86brcond bb:$dst, X86_COND_B, EFLAGS)]>, TB;
Dan Gohman91888f02007-07-31 20:11:57 +0000530def JBE : IBr<0x86, (ins brtarget:$dst), "jbe\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000531 [(X86brcond bb:$dst, X86_COND_BE, EFLAGS)]>, TB;
Dan Gohman91888f02007-07-31 20:11:57 +0000532def JA : IBr<0x87, (ins brtarget:$dst), "ja\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000533 [(X86brcond bb:$dst, X86_COND_A, EFLAGS)]>, TB;
Dan Gohman91888f02007-07-31 20:11:57 +0000534def JAE : IBr<0x83, (ins brtarget:$dst), "jae\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000535 [(X86brcond bb:$dst, X86_COND_AE, EFLAGS)]>, TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000536
Dan Gohman91888f02007-07-31 20:11:57 +0000537def JS : IBr<0x88, (ins brtarget:$dst), "js\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000538 [(X86brcond bb:$dst, X86_COND_S, EFLAGS)]>, TB;
Dan Gohman91888f02007-07-31 20:11:57 +0000539def JNS : IBr<0x89, (ins brtarget:$dst), "jns\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000540 [(X86brcond bb:$dst, X86_COND_NS, EFLAGS)]>, TB;
Dan Gohman91888f02007-07-31 20:11:57 +0000541def JP : IBr<0x8A, (ins brtarget:$dst), "jp\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000542 [(X86brcond bb:$dst, X86_COND_P, EFLAGS)]>, TB;
Dan Gohman91888f02007-07-31 20:11:57 +0000543def JNP : IBr<0x8B, (ins brtarget:$dst), "jnp\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000544 [(X86brcond bb:$dst, X86_COND_NP, EFLAGS)]>, TB;
Dan Gohman91888f02007-07-31 20:11:57 +0000545def JO : IBr<0x80, (ins brtarget:$dst), "jo\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000546 [(X86brcond bb:$dst, X86_COND_O, EFLAGS)]>, TB;
Dan Gohman91888f02007-07-31 20:11:57 +0000547def JNO : IBr<0x81, (ins brtarget:$dst), "jno\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000548 [(X86brcond bb:$dst, X86_COND_NO, EFLAGS)]>, TB;
Evan Cheng950aac02007-09-25 01:57:46 +0000549} // Uses = [EFLAGS]
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000550
551//===----------------------------------------------------------------------===//
552// Call Instructions...
553//
Evan Cheng37e7c752007-07-21 00:34:19 +0000554let isCall = 1 in
Dan Gohman01c9f772008-10-01 18:28:06 +0000555 // All calls clobber the non-callee saved registers. ESP is marked as
556 // a use to prevent stack-pointer assignments that appear immediately
557 // before calls from potentially appearing dead. Uses for argument
558 // registers are added manually.
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000559 let Defs = [EAX, ECX, EDX, FP0, FP1, FP2, FP3, FP4, FP5, FP6, ST0,
560 MM0, MM1, MM2, MM3, MM4, MM5, MM6, MM7,
Evan Cheng2293b252008-10-17 21:02:22 +0000561 XMM0, XMM1, XMM2, XMM3, XMM4, XMM5, XMM6, XMM7,
562 XMM8, XMM9, XMM10, XMM11, XMM12, XMM13, XMM14, XMM15, EFLAGS],
Dan Gohman9499cfe2008-10-01 04:14:30 +0000563 Uses = [ESP] in {
Evan Cheng34f93712007-12-22 02:26:46 +0000564 def CALLpcrel32 : Ii32<0xE8, RawFrm, (outs), (ins i32imm:$dst,variable_ops),
Evan Cheng0af5a042009-03-12 18:15:39 +0000565 "call\t${dst:call}", [(X86call imm:$dst)]>,
Evan Cheng52da5762009-05-20 01:11:00 +0000566 Requires<[In32BitMode, IsNotPIC]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000567 def CALL32r : I<0xFF, MRM2r, (outs), (ins GR32:$dst, variable_ops),
Dan Gohman91888f02007-07-31 20:11:57 +0000568 "call\t{*}$dst", [(X86call GR32:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000569 def CALL32m : I<0xFF, MRM2m, (outs), (ins i32mem:$dst, variable_ops),
Dan Gohmanea4faba2008-05-29 21:50:34 +0000570 "call\t{*}$dst", [(X86call (loadi32 addr:$dst))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000571 }
572
573// Tail call stuff.
Arnold Schwaighofere2d6bbb2007-10-11 19:40:01 +0000574
Chris Lattnerb56cc342008-03-11 03:23:40 +0000575def TAILCALL : I<0, Pseudo, (outs), (ins),
Arnold Schwaighofere2d6bbb2007-10-11 19:40:01 +0000576 "#TAILCALL",
577 []>;
578
Evan Cheng37e7c752007-07-21 00:34:19 +0000579let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1 in
Arnold Schwaighofer6fd37ac2008-03-19 16:39:45 +0000580def TCRETURNdi : I<0, Pseudo, (outs), (ins i32imm:$dst, i32imm:$offset, variable_ops),
Arnold Schwaighofere2d6bbb2007-10-11 19:40:01 +0000581 "#TC_RETURN $dst $offset",
582 []>;
583
584let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1 in
Arnold Schwaighofer6fd37ac2008-03-19 16:39:45 +0000585def TCRETURNri : I<0, Pseudo, (outs), (ins GR32:$dst, i32imm:$offset, variable_ops),
Arnold Schwaighofere2d6bbb2007-10-11 19:40:01 +0000586 "#TC_RETURN $dst $offset",
587 []>;
588
589let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1 in
Arnold Schwaighofera0032722008-04-30 09:16:33 +0000590
Arnold Schwaighofere2d6bbb2007-10-11 19:40:01 +0000591 def TAILJMPd : IBr<0xE9, (ins i32imm:$dst), "jmp\t${dst:call} # TAILCALL",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000592 []>;
Evan Cheng37e7c752007-07-21 00:34:19 +0000593let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1 in
Arnold Schwaighofere2d6bbb2007-10-11 19:40:01 +0000594 def TAILJMPr : I<0xFF, MRM4r, (outs), (ins GR32:$dst), "jmp{l}\t{*}$dst # TAILCALL",
595 []>;
Evan Cheng37e7c752007-07-21 00:34:19 +0000596let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +0000597 def TAILJMPm : I<0xFF, MRM4m, (outs), (ins i32mem:$dst),
Arnold Schwaighofere2d6bbb2007-10-11 19:40:01 +0000598 "jmp\t{*}$dst # TAILCALL", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000599
600//===----------------------------------------------------------------------===//
601// Miscellaneous Instructions...
602//
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000603let Defs = [EBP, ESP], Uses = [EBP, ESP], mayLoad = 1, neverHasSideEffects=1 in
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000604def LEAVE : I<0xC9, RawFrm,
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000605 (outs), (ins), "leave", []>;
606
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000607let Defs = [ESP], Uses = [ESP], neverHasSideEffects=1 in {
608let mayLoad = 1 in
Evan Chengd8434332007-09-26 01:29:06 +0000609def POP32r : I<0x58, AddRegFrm, (outs GR32:$reg), (ins), "pop{l}\t$reg", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000610
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000611let mayStore = 1 in
Evan Chengd8434332007-09-26 01:29:06 +0000612def PUSH32r : I<0x50, AddRegFrm, (outs), (ins GR32:$reg), "push{l}\t$reg",[]>;
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000613}
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000614
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000615let Defs = [ESP, EFLAGS], Uses = [ESP], mayLoad = 1, neverHasSideEffects=1 in
Evan Chengf1341312007-09-26 21:28:00 +0000616def POPFD : I<0x9D, RawFrm, (outs), (ins), "popf", []>;
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000617let Defs = [ESP], Uses = [ESP, EFLAGS], mayStore = 1, neverHasSideEffects=1 in
Evan Chengf1341312007-09-26 21:28:00 +0000618def PUSHFD : I<0x9C, RawFrm, (outs), (ins), "pushf", []>;
Evan Chengd8434332007-09-26 01:29:06 +0000619
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000620let isTwoAddress = 1 in // GR32 = bswap GR32
621 def BSWAP32r : I<0xC8, AddRegFrm,
Evan Chengb783fa32007-07-19 01:14:50 +0000622 (outs GR32:$dst), (ins GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000623 "bswap{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000624 [(set GR32:$dst, (bswap GR32:$src))]>, TB;
625
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000626
Evan Cheng48679f42007-12-14 02:13:44 +0000627// Bit scan instructions.
628let Defs = [EFLAGS] in {
Evan Cheng4e33de92007-12-14 18:49:43 +0000629def BSF16rr : I<0xBC, MRMSrcReg, (outs GR16:$dst), (ins GR16:$src),
Dan Gohmancdb54c62007-12-14 15:10:00 +0000630 "bsf{w}\t{$src, $dst|$dst, $src}",
Evan Cheng7cfbfe32007-12-14 08:30:15 +0000631 [(set GR16:$dst, (X86bsf GR16:$src)), (implicit EFLAGS)]>, TB;
Evan Cheng48679f42007-12-14 02:13:44 +0000632def BSF16rm : I<0xBC, MRMSrcMem, (outs GR16:$dst), (ins i16mem:$src),
Dan Gohmancdb54c62007-12-14 15:10:00 +0000633 "bsf{w}\t{$src, $dst|$dst, $src}",
Evan Cheng7cfbfe32007-12-14 08:30:15 +0000634 [(set GR16:$dst, (X86bsf (loadi16 addr:$src))),
635 (implicit EFLAGS)]>, TB;
Evan Cheng4e33de92007-12-14 18:49:43 +0000636def BSF32rr : I<0xBC, MRMSrcReg, (outs GR32:$dst), (ins GR32:$src),
Dan Gohmancdb54c62007-12-14 15:10:00 +0000637 "bsf{l}\t{$src, $dst|$dst, $src}",
Evan Cheng7cfbfe32007-12-14 08:30:15 +0000638 [(set GR32:$dst, (X86bsf GR32:$src)), (implicit EFLAGS)]>, TB;
Evan Cheng48679f42007-12-14 02:13:44 +0000639def BSF32rm : I<0xBC, MRMSrcMem, (outs GR32:$dst), (ins i32mem:$src),
Dan Gohmancdb54c62007-12-14 15:10:00 +0000640 "bsf{l}\t{$src, $dst|$dst, $src}",
Evan Cheng7cfbfe32007-12-14 08:30:15 +0000641 [(set GR32:$dst, (X86bsf (loadi32 addr:$src))),
642 (implicit EFLAGS)]>, TB;
Evan Cheng48679f42007-12-14 02:13:44 +0000643
Evan Cheng4e33de92007-12-14 18:49:43 +0000644def BSR16rr : I<0xBD, MRMSrcReg, (outs GR16:$dst), (ins GR16:$src),
Dan Gohmancdb54c62007-12-14 15:10:00 +0000645 "bsr{w}\t{$src, $dst|$dst, $src}",
Evan Cheng7cfbfe32007-12-14 08:30:15 +0000646 [(set GR16:$dst, (X86bsr GR16:$src)), (implicit EFLAGS)]>, TB;
Evan Cheng48679f42007-12-14 02:13:44 +0000647def BSR16rm : I<0xBD, MRMSrcMem, (outs GR16:$dst), (ins i16mem:$src),
Dan Gohmancdb54c62007-12-14 15:10:00 +0000648 "bsr{w}\t{$src, $dst|$dst, $src}",
Evan Cheng7cfbfe32007-12-14 08:30:15 +0000649 [(set GR16:$dst, (X86bsr (loadi16 addr:$src))),
650 (implicit EFLAGS)]>, TB;
Evan Cheng4e33de92007-12-14 18:49:43 +0000651def BSR32rr : I<0xBD, MRMSrcReg, (outs GR32:$dst), (ins GR32:$src),
Dan Gohmancdb54c62007-12-14 15:10:00 +0000652 "bsr{l}\t{$src, $dst|$dst, $src}",
Evan Cheng7cfbfe32007-12-14 08:30:15 +0000653 [(set GR32:$dst, (X86bsr GR32:$src)), (implicit EFLAGS)]>, TB;
Evan Cheng48679f42007-12-14 02:13:44 +0000654def BSR32rm : I<0xBD, MRMSrcMem, (outs GR32:$dst), (ins i32mem:$src),
Dan Gohmancdb54c62007-12-14 15:10:00 +0000655 "bsr{l}\t{$src, $dst|$dst, $src}",
Evan Cheng7cfbfe32007-12-14 08:30:15 +0000656 [(set GR32:$dst, (X86bsr (loadi32 addr:$src))),
657 (implicit EFLAGS)]>, TB;
Evan Cheng48679f42007-12-14 02:13:44 +0000658} // Defs = [EFLAGS]
659
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000660let neverHasSideEffects = 1 in
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000661def LEA16r : I<0x8D, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +0000662 (outs GR16:$dst), (ins i32mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000663 "lea{w}\t{$src|$dst}, {$dst|$src}", []>, OpSize;
Evan Cheng1ea8e6b2008-03-27 01:41:09 +0000664let isReMaterializable = 1 in
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000665def LEA32r : I<0x8D, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +0000666 (outs GR32:$dst), (ins lea32mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000667 "lea{l}\t{$src|$dst}, {$dst|$src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000668 [(set GR32:$dst, lea32addr:$src)]>, Requires<[In32BitMode]>;
669
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000670let Defs = [ECX,EDI,ESI], Uses = [ECX,EDI,ESI] in {
Evan Chengb783fa32007-07-19 01:14:50 +0000671def REP_MOVSB : I<0xA4, RawFrm, (outs), (ins), "{rep;movsb|rep movsb}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000672 [(X86rep_movs i8)]>, REP;
Evan Chengb783fa32007-07-19 01:14:50 +0000673def REP_MOVSW : I<0xA5, RawFrm, (outs), (ins), "{rep;movsw|rep movsw}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000674 [(X86rep_movs i16)]>, REP, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +0000675def REP_MOVSD : I<0xA5, RawFrm, (outs), (ins), "{rep;movsl|rep movsd}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000676 [(X86rep_movs i32)]>, REP;
677}
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000678
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000679let Defs = [ECX,EDI], Uses = [AL,ECX,EDI] in
Evan Chengb783fa32007-07-19 01:14:50 +0000680def REP_STOSB : I<0xAA, RawFrm, (outs), (ins), "{rep;stosb|rep stosb}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000681 [(X86rep_stos i8)]>, REP;
682let Defs = [ECX,EDI], Uses = [AX,ECX,EDI] in
Evan Chengb783fa32007-07-19 01:14:50 +0000683def REP_STOSW : I<0xAB, RawFrm, (outs), (ins), "{rep;stosw|rep stosw}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000684 [(X86rep_stos i16)]>, REP, OpSize;
685let Defs = [ECX,EDI], Uses = [EAX,ECX,EDI] in
Evan Chengb783fa32007-07-19 01:14:50 +0000686def REP_STOSD : I<0xAB, RawFrm, (outs), (ins), "{rep;stosl|rep stosd}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000687 [(X86rep_stos i32)]>, REP;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000688
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000689let Defs = [RAX, RDX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000690def RDTSC : I<0x31, RawFrm, (outs), (ins), "rdtsc", [(X86rdtsc)]>,
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000691 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000692
Anton Korobeynikov39d40ba2008-01-15 07:02:33 +0000693let isBarrier = 1, hasCtrlDep = 1 in {
Chris Lattner56b941f2008-01-15 21:58:22 +0000694def TRAP : I<0x0B, RawFrm, (outs), (ins), "ud2", [(trap)]>, TB;
Anton Korobeynikov39d40ba2008-01-15 07:02:33 +0000695}
696
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000697//===----------------------------------------------------------------------===//
698// Input/Output Instructions...
699//
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000700let Defs = [AL], Uses = [DX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000701def IN8rr : I<0xEC, RawFrm, (outs), (ins),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000702 "in{b}\t{%dx, %al|%AL, %DX}", []>;
703let Defs = [AX], Uses = [DX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000704def IN16rr : I<0xED, RawFrm, (outs), (ins),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000705 "in{w}\t{%dx, %ax|%AX, %DX}", []>, OpSize;
706let Defs = [EAX], Uses = [DX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000707def IN32rr : I<0xED, RawFrm, (outs), (ins),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000708 "in{l}\t{%dx, %eax|%EAX, %DX}", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000709
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000710let Defs = [AL] in
Evan Chengb783fa32007-07-19 01:14:50 +0000711def IN8ri : Ii8<0xE4, RawFrm, (outs), (ins i16i8imm:$port),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000712 "in{b}\t{$port, %al|%AL, $port}", []>;
713let Defs = [AX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000714def IN16ri : Ii8<0xE5, RawFrm, (outs), (ins i16i8imm:$port),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000715 "in{w}\t{$port, %ax|%AX, $port}", []>, OpSize;
716let Defs = [EAX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000717def IN32ri : Ii8<0xE5, RawFrm, (outs), (ins i16i8imm:$port),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000718 "in{l}\t{$port, %eax|%EAX, $port}", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000719
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000720let Uses = [DX, AL] in
Evan Chengb783fa32007-07-19 01:14:50 +0000721def OUT8rr : I<0xEE, RawFrm, (outs), (ins),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000722 "out{b}\t{%al, %dx|%DX, %AL}", []>;
723let Uses = [DX, AX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000724def OUT16rr : I<0xEF, RawFrm, (outs), (ins),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000725 "out{w}\t{%ax, %dx|%DX, %AX}", []>, OpSize;
726let Uses = [DX, EAX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000727def OUT32rr : I<0xEF, RawFrm, (outs), (ins),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000728 "out{l}\t{%eax, %dx|%DX, %EAX}", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000729
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000730let Uses = [AL] in
Evan Chengb783fa32007-07-19 01:14:50 +0000731def OUT8ir : Ii8<0xE6, RawFrm, (outs), (ins i16i8imm:$port),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000732 "out{b}\t{%al, $port|$port, %AL}", []>;
733let Uses = [AX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000734def OUT16ir : Ii8<0xE7, RawFrm, (outs), (ins i16i8imm:$port),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000735 "out{w}\t{%ax, $port|$port, %AX}", []>, OpSize;
736let Uses = [EAX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000737def OUT32ir : Ii8<0xE7, RawFrm, (outs), (ins i16i8imm:$port),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000738 "out{l}\t{%eax, $port|$port, %EAX}", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000739
740//===----------------------------------------------------------------------===//
741// Move Instructions...
742//
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000743let neverHasSideEffects = 1 in {
Evan Chengb783fa32007-07-19 01:14:50 +0000744def MOV8rr : I<0x88, MRMDestReg, (outs GR8 :$dst), (ins GR8 :$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000745 "mov{b}\t{$src, $dst|$dst, $src}", []>;
Evan Chengb783fa32007-07-19 01:14:50 +0000746def MOV16rr : I<0x89, MRMDestReg, (outs GR16:$dst), (ins GR16:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000747 "mov{w}\t{$src, $dst|$dst, $src}", []>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +0000748def MOV32rr : I<0x89, MRMDestReg, (outs GR32:$dst), (ins GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000749 "mov{l}\t{$src, $dst|$dst, $src}", []>;
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000750}
Evan Cheng6f26e8b2008-06-18 08:13:07 +0000751let isReMaterializable = 1, isAsCheapAsAMove = 1 in {
Evan Chengb783fa32007-07-19 01:14:50 +0000752def MOV8ri : Ii8 <0xB0, AddRegFrm, (outs GR8 :$dst), (ins i8imm :$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000753 "mov{b}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000754 [(set GR8:$dst, imm:$src)]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000755def MOV16ri : Ii16<0xB8, AddRegFrm, (outs GR16:$dst), (ins i16imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000756 "mov{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000757 [(set GR16:$dst, imm:$src)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +0000758def MOV32ri : Ii32<0xB8, AddRegFrm, (outs GR32:$dst), (ins i32imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000759 "mov{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000760 [(set GR32:$dst, imm:$src)]>;
761}
Evan Chengb783fa32007-07-19 01:14:50 +0000762def MOV8mi : Ii8 <0xC6, MRM0m, (outs), (ins i8mem :$dst, i8imm :$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000763 "mov{b}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000764 [(store (i8 imm:$src), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000765def MOV16mi : Ii16<0xC7, MRM0m, (outs), (ins i16mem:$dst, i16imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000766 "mov{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000767 [(store (i16 imm:$src), addr:$dst)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +0000768def MOV32mi : Ii32<0xC7, MRM0m, (outs), (ins i32mem:$dst, i32imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000769 "mov{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000770 [(store (i32 imm:$src), addr:$dst)]>;
771
Dan Gohman5574cc72008-12-03 18:15:48 +0000772let canFoldAsLoad = 1, isReMaterializable = 1, mayHaveSideEffects = 1 in {
Evan Chengb783fa32007-07-19 01:14:50 +0000773def MOV8rm : I<0x8A, MRMSrcMem, (outs GR8 :$dst), (ins i8mem :$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000774 "mov{b}\t{$src, $dst|$dst, $src}",
Chris Lattner12208612009-04-10 00:16:23 +0000775 [(set GR8:$dst, (loadi8 addr:$src))]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000776def MOV16rm : I<0x8B, MRMSrcMem, (outs GR16:$dst), (ins i16mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000777 "mov{w}\t{$src, $dst|$dst, $src}",
Chris Lattner12208612009-04-10 00:16:23 +0000778 [(set GR16:$dst, (loadi16 addr:$src))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +0000779def MOV32rm : I<0x8B, MRMSrcMem, (outs GR32:$dst), (ins i32mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000780 "mov{l}\t{$src, $dst|$dst, $src}",
Chris Lattner12208612009-04-10 00:16:23 +0000781 [(set GR32:$dst, (loadi32 addr:$src))]>;
Evan Cheng4e84e452007-08-30 05:49:43 +0000782}
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000783
Evan Chengb783fa32007-07-19 01:14:50 +0000784def MOV8mr : I<0x88, MRMDestMem, (outs), (ins i8mem :$dst, GR8 :$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000785 "mov{b}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000786 [(store GR8:$src, addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000787def MOV16mr : I<0x89, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000788 "mov{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000789 [(store GR16:$src, addr:$dst)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +0000790def MOV32mr : I<0x89, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000791 "mov{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000792 [(store GR32:$src, addr:$dst)]>;
Dan Gohman744d4622009-04-13 16:09:41 +0000793
Dan Gohman1d8ce9c2009-04-27 16:41:36 +0000794// Versions of MOV8rr, MOV8mr, and MOV8rm that use i8mem_NOREX and GR8_NOREX so
795// that they can be used for copying and storing h registers, which can't be
796// encoded when a REX prefix is present.
Dan Gohman2da0db32009-04-15 00:04:23 +0000797let neverHasSideEffects = 1 in
Dan Gohman40ddc362009-04-15 19:48:57 +0000798def MOV8rr_NOREX : I<0x88, MRMDestReg,
799 (outs GR8_NOREX:$dst), (ins GR8_NOREX:$src),
Dan Gohman2da0db32009-04-15 00:04:23 +0000800 "mov{b}\t{$src, $dst|$dst, $src} # NOREX", []>;
Evan Chengebc49402009-04-30 00:58:57 +0000801let mayStore = 1 in
Dan Gohman2da0db32009-04-15 00:04:23 +0000802def MOV8mr_NOREX : I<0x88, MRMDestMem,
803 (outs), (ins i8mem_NOREX:$dst, GR8_NOREX:$src),
804 "mov{b}\t{$src, $dst|$dst, $src} # NOREX", []>;
Evan Chengebc49402009-04-30 00:58:57 +0000805let mayLoad = 1,
806 canFoldAsLoad = 1, isReMaterializable = 1, mayHaveSideEffects = 1 in
Dan Gohman1d8ce9c2009-04-27 16:41:36 +0000807def MOV8rm_NOREX : I<0x8A, MRMSrcMem,
808 (outs GR8_NOREX:$dst), (ins i8mem_NOREX:$src),
809 "mov{b}\t{$src, $dst|$dst, $src} # NOREX", []>;
Dan Gohman744d4622009-04-13 16:09:41 +0000810
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000811//===----------------------------------------------------------------------===//
812// Fixed-Register Multiplication and Division Instructions...
813//
814
815// Extra precision multiplication
Evan Cheng55687072007-09-14 21:48:26 +0000816let Defs = [AL,AH,EFLAGS], Uses = [AL] in
Dan Gohman91888f02007-07-31 20:11:57 +0000817def MUL8r : I<0xF6, MRM4r, (outs), (ins GR8:$src), "mul{b}\t$src",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000818 // FIXME: Used for 8-bit mul, ignore result upper 8 bits.
819 // This probably ought to be moved to a def : Pat<> if the
820 // syntax can be accepted.
Bill Wendlingf5399032008-12-12 21:15:41 +0000821 [(set AL, (mul AL, GR8:$src)),
822 (implicit EFLAGS)]>; // AL,AH = AL*GR8
823
Chris Lattnerc7e96e72008-01-11 07:18:17 +0000824let Defs = [AX,DX,EFLAGS], Uses = [AX], neverHasSideEffects = 1 in
Bill Wendlingf5399032008-12-12 21:15:41 +0000825def MUL16r : I<0xF7, MRM4r, (outs), (ins GR16:$src),
826 "mul{w}\t$src",
827 []>, OpSize; // AX,DX = AX*GR16
828
Chris Lattnerc7e96e72008-01-11 07:18:17 +0000829let Defs = [EAX,EDX,EFLAGS], Uses = [EAX], neverHasSideEffects = 1 in
Bill Wendlingf5399032008-12-12 21:15:41 +0000830def MUL32r : I<0xF7, MRM4r, (outs), (ins GR32:$src),
831 "mul{l}\t$src",
832 []>; // EAX,EDX = EAX*GR32
833
Evan Cheng55687072007-09-14 21:48:26 +0000834let Defs = [AL,AH,EFLAGS], Uses = [AL] in
Evan Chengb783fa32007-07-19 01:14:50 +0000835def MUL8m : I<0xF6, MRM4m, (outs), (ins i8mem :$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000836 "mul{b}\t$src",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000837 // FIXME: Used for 8-bit mul, ignore result upper 8 bits.
838 // This probably ought to be moved to a def : Pat<> if the
839 // syntax can be accepted.
Bill Wendlingf5399032008-12-12 21:15:41 +0000840 [(set AL, (mul AL, (loadi8 addr:$src))),
841 (implicit EFLAGS)]>; // AL,AH = AL*[mem8]
842
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000843let mayLoad = 1, neverHasSideEffects = 1 in {
Evan Cheng55687072007-09-14 21:48:26 +0000844let Defs = [AX,DX,EFLAGS], Uses = [AX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000845def MUL16m : I<0xF7, MRM4m, (outs), (ins i16mem:$src),
Bill Wendlingf5399032008-12-12 21:15:41 +0000846 "mul{w}\t$src",
847 []>, OpSize; // AX,DX = AX*[mem16]
848
Evan Cheng55687072007-09-14 21:48:26 +0000849let Defs = [EAX,EDX,EFLAGS], Uses = [EAX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000850def MUL32m : I<0xF7, MRM4m, (outs), (ins i32mem:$src),
Bill Wendlingf5399032008-12-12 21:15:41 +0000851 "mul{l}\t$src",
852 []>; // EAX,EDX = EAX*[mem32]
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000853}
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000854
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000855let neverHasSideEffects = 1 in {
Evan Cheng55687072007-09-14 21:48:26 +0000856let Defs = [AL,AH,EFLAGS], Uses = [AL] in
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000857def IMUL8r : I<0xF6, MRM5r, (outs), (ins GR8:$src), "imul{b}\t$src", []>;
858 // AL,AH = AL*GR8
Evan Cheng55687072007-09-14 21:48:26 +0000859let Defs = [AX,DX,EFLAGS], Uses = [AX] in
Dan Gohman91888f02007-07-31 20:11:57 +0000860def IMUL16r : I<0xF7, MRM5r, (outs), (ins GR16:$src), "imul{w}\t$src", []>,
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000861 OpSize; // AX,DX = AX*GR16
Evan Cheng55687072007-09-14 21:48:26 +0000862let Defs = [EAX,EDX,EFLAGS], Uses = [EAX] in
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000863def IMUL32r : I<0xF7, MRM5r, (outs), (ins GR32:$src), "imul{l}\t$src", []>;
864 // EAX,EDX = EAX*GR32
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000865let mayLoad = 1 in {
Evan Cheng55687072007-09-14 21:48:26 +0000866let Defs = [AL,AH,EFLAGS], Uses = [AL] in
Evan Chengb783fa32007-07-19 01:14:50 +0000867def IMUL8m : I<0xF6, MRM5m, (outs), (ins i8mem :$src),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000868 "imul{b}\t$src", []>; // AL,AH = AL*[mem8]
Evan Cheng55687072007-09-14 21:48:26 +0000869let Defs = [AX,DX,EFLAGS], Uses = [AX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000870def IMUL16m : I<0xF7, MRM5m, (outs), (ins i16mem:$src),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000871 "imul{w}\t$src", []>, OpSize; // AX,DX = AX*[mem16]
872let Defs = [EAX,EDX], Uses = [EAX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000873def IMUL32m : I<0xF7, MRM5m, (outs), (ins i32mem:$src),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000874 "imul{l}\t$src", []>; // EAX,EDX = EAX*[mem32]
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000875}
Dan Gohmand44572d2008-11-18 21:29:14 +0000876} // neverHasSideEffects
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000877
878// unsigned division/remainder
Dale Johannesend8fd3562008-10-07 18:54:28 +0000879let Defs = [AL,AH,EFLAGS], Uses = [AX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000880def DIV8r : I<0xF6, MRM6r, (outs), (ins GR8:$src), // AX/r8 = AL,AH
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000881 "div{b}\t$src", []>;
Evan Cheng55687072007-09-14 21:48:26 +0000882let Defs = [AX,DX,EFLAGS], Uses = [AX,DX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000883def DIV16r : I<0xF7, MRM6r, (outs), (ins GR16:$src), // DX:AX/r16 = AX,DX
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000884 "div{w}\t$src", []>, OpSize;
Evan Cheng55687072007-09-14 21:48:26 +0000885let Defs = [EAX,EDX,EFLAGS], Uses = [EAX,EDX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000886def DIV32r : I<0xF7, MRM6r, (outs), (ins GR32:$src), // EDX:EAX/r32 = EAX,EDX
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000887 "div{l}\t$src", []>;
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000888let mayLoad = 1 in {
Dale Johannesend8fd3562008-10-07 18:54:28 +0000889let Defs = [AL,AH,EFLAGS], Uses = [AX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000890def DIV8m : I<0xF6, MRM6m, (outs), (ins i8mem:$src), // AX/[mem8] = AL,AH
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000891 "div{b}\t$src", []>;
Evan Cheng55687072007-09-14 21:48:26 +0000892let Defs = [AX,DX,EFLAGS], Uses = [AX,DX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000893def DIV16m : I<0xF7, MRM6m, (outs), (ins i16mem:$src), // DX:AX/[mem16] = AX,DX
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000894 "div{w}\t$src", []>, OpSize;
Evan Cheng55687072007-09-14 21:48:26 +0000895let Defs = [EAX,EDX,EFLAGS], Uses = [EAX,EDX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000896def DIV32m : I<0xF7, MRM6m, (outs), (ins i32mem:$src), // EDX:EAX/[mem32] = EAX,EDX
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000897 "div{l}\t$src", []>;
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000898}
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000899
900// Signed division/remainder.
Dale Johannesend8fd3562008-10-07 18:54:28 +0000901let Defs = [AL,AH,EFLAGS], Uses = [AX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000902def IDIV8r : I<0xF6, MRM7r, (outs), (ins GR8:$src), // AX/r8 = AL,AH
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000903 "idiv{b}\t$src", []>;
Evan Cheng55687072007-09-14 21:48:26 +0000904let Defs = [AX,DX,EFLAGS], Uses = [AX,DX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000905def IDIV16r: I<0xF7, MRM7r, (outs), (ins GR16:$src), // DX:AX/r16 = AX,DX
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000906 "idiv{w}\t$src", []>, OpSize;
Evan Cheng55687072007-09-14 21:48:26 +0000907let Defs = [EAX,EDX,EFLAGS], Uses = [EAX,EDX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000908def IDIV32r: I<0xF7, MRM7r, (outs), (ins GR32:$src), // EDX:EAX/r32 = EAX,EDX
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000909 "idiv{l}\t$src", []>;
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000910let mayLoad = 1, mayLoad = 1 in {
Dale Johannesend8fd3562008-10-07 18:54:28 +0000911let Defs = [AL,AH,EFLAGS], Uses = [AX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000912def IDIV8m : I<0xF6, MRM7m, (outs), (ins i8mem:$src), // AX/[mem8] = AL,AH
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000913 "idiv{b}\t$src", []>;
Evan Cheng55687072007-09-14 21:48:26 +0000914let Defs = [AX,DX,EFLAGS], Uses = [AX,DX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000915def IDIV16m: I<0xF7, MRM7m, (outs), (ins i16mem:$src), // DX:AX/[mem16] = AX,DX
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000916 "idiv{w}\t$src", []>, OpSize;
Evan Cheng55687072007-09-14 21:48:26 +0000917let Defs = [EAX,EDX,EFLAGS], Uses = [EAX,EDX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000918def IDIV32m: I<0xF7, MRM7m, (outs), (ins i32mem:$src), // EDX:EAX/[mem32] = EAX,EDX
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000919 "idiv{l}\t$src", []>;
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000920}
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000921
922//===----------------------------------------------------------------------===//
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000923// Two address Instructions.
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000924//
925let isTwoAddress = 1 in {
926
927// Conditional moves
Evan Cheng950aac02007-09-25 01:57:46 +0000928let Uses = [EFLAGS] in {
Evan Cheng926658c2007-10-05 23:13:21 +0000929let isCommutable = 1 in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000930def CMOVB16rr : I<0x42, MRMSrcReg, // if <u, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +0000931 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000932 "cmovb\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000933 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000934 X86_COND_B, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000935 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000936def CMOVB32rr : I<0x42, MRMSrcReg, // if <u, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +0000937 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000938 "cmovb\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000939 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000940 X86_COND_B, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000941 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000942def CMOVAE16rr: I<0x43, MRMSrcReg, // if >=u, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +0000943 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000944 "cmovae\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000945 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000946 X86_COND_AE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000947 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000948def CMOVAE32rr: I<0x43, MRMSrcReg, // if >=u, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +0000949 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000950 "cmovae\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000951 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000952 X86_COND_AE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000953 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000954def CMOVE16rr : I<0x44, MRMSrcReg, // if ==, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +0000955 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000956 "cmove\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000957 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000958 X86_COND_E, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000959 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000960def CMOVE32rr : I<0x44, MRMSrcReg, // if ==, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +0000961 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000962 "cmove\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000963 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000964 X86_COND_E, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000965 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000966def CMOVNE16rr: I<0x45, MRMSrcReg, // if !=, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +0000967 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000968 "cmovne\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000969 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000970 X86_COND_NE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000971 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000972def CMOVNE32rr: I<0x45, MRMSrcReg, // if !=, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +0000973 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000974 "cmovne\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000975 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000976 X86_COND_NE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000977 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000978def CMOVBE16rr: I<0x46, MRMSrcReg, // if <=u, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +0000979 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000980 "cmovbe\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000981 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000982 X86_COND_BE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000983 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000984def CMOVBE32rr: I<0x46, MRMSrcReg, // if <=u, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +0000985 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000986 "cmovbe\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000987 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000988 X86_COND_BE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000989 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000990def CMOVA16rr : I<0x47, MRMSrcReg, // if >u, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +0000991 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000992 "cmova\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000993 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000994 X86_COND_A, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000995 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000996def CMOVA32rr : I<0x47, MRMSrcReg, // if >u, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +0000997 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000998 "cmova\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000999 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001000 X86_COND_A, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001001 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001002def CMOVL16rr : I<0x4C, MRMSrcReg, // if <s, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +00001003 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001004 "cmovl\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001005 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001006 X86_COND_L, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001007 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001008def CMOVL32rr : I<0x4C, MRMSrcReg, // if <s, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +00001009 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001010 "cmovl\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001011 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001012 X86_COND_L, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001013 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001014def CMOVGE16rr: I<0x4D, MRMSrcReg, // if >=s, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +00001015 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001016 "cmovge\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001017 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001018 X86_COND_GE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001019 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001020def CMOVGE32rr: I<0x4D, MRMSrcReg, // if >=s, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +00001021 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001022 "cmovge\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001023 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001024 X86_COND_GE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001025 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001026def CMOVLE16rr: I<0x4E, MRMSrcReg, // if <=s, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +00001027 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001028 "cmovle\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001029 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001030 X86_COND_LE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001031 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001032def CMOVLE32rr: I<0x4E, MRMSrcReg, // if <=s, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +00001033 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001034 "cmovle\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001035 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001036 X86_COND_LE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001037 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001038def CMOVG16rr : I<0x4F, MRMSrcReg, // if >s, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +00001039 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001040 "cmovg\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001041 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001042 X86_COND_G, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001043 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001044def CMOVG32rr : I<0x4F, MRMSrcReg, // if >s, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +00001045 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001046 "cmovg\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001047 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001048 X86_COND_G, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001049 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001050def CMOVS16rr : I<0x48, MRMSrcReg, // if signed, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +00001051 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001052 "cmovs\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001053 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001054 X86_COND_S, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001055 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001056def CMOVS32rr : I<0x48, MRMSrcReg, // if signed, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +00001057 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001058 "cmovs\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001059 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001060 X86_COND_S, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001061 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001062def CMOVNS16rr: I<0x49, MRMSrcReg, // if !signed, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +00001063 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001064 "cmovns\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001065 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001066 X86_COND_NS, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001067 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001068def CMOVNS32rr: I<0x49, MRMSrcReg, // if !signed, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +00001069 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001070 "cmovns\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001071 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001072 X86_COND_NS, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001073 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001074def CMOVP16rr : I<0x4A, MRMSrcReg, // if parity, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +00001075 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001076 "cmovp\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001077 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001078 X86_COND_P, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001079 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001080def CMOVP32rr : I<0x4A, MRMSrcReg, // if parity, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +00001081 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001082 "cmovp\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001083 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001084 X86_COND_P, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001085 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001086def CMOVNP16rr : I<0x4B, MRMSrcReg, // if !parity, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +00001087 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001088 "cmovnp\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001089 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001090 X86_COND_NP, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001091 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001092def CMOVNP32rr : I<0x4B, MRMSrcReg, // if !parity, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +00001093 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001094 "cmovnp\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001095 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001096 X86_COND_NP, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001097 TB;
Dan Gohman12fd4d72009-01-07 00:35:10 +00001098def CMOVO16rr : I<0x40, MRMSrcReg, // if overflow, GR16 = GR16
1099 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
1100 "cmovo\t{$src2, $dst|$dst, $src2}",
1101 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
1102 X86_COND_O, EFLAGS))]>,
1103 TB, OpSize;
1104def CMOVO32rr : I<0x40, MRMSrcReg, // if overflow, GR32 = GR32
1105 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
1106 "cmovo\t{$src2, $dst|$dst, $src2}",
1107 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
1108 X86_COND_O, EFLAGS))]>,
Evan Cheng950aac02007-09-25 01:57:46 +00001109 TB;
Dan Gohman12fd4d72009-01-07 00:35:10 +00001110def CMOVNO16rr : I<0x41, MRMSrcReg, // if !overflow, GR16 = GR16
1111 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
1112 "cmovno\t{$src2, $dst|$dst, $src2}",
1113 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
1114 X86_COND_NO, EFLAGS))]>,
1115 TB, OpSize;
1116def CMOVNO32rr : I<0x41, MRMSrcReg, // if !overflow, GR32 = GR32
1117 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
1118 "cmovno\t{$src2, $dst|$dst, $src2}",
1119 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
1120 X86_COND_NO, EFLAGS))]>,
1121 TB;
1122} // isCommutable = 1
Evan Cheng926658c2007-10-05 23:13:21 +00001123
1124def CMOVB16rm : I<0x42, MRMSrcMem, // if <u, GR16 = [mem16]
1125 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1126 "cmovb\t{$src2, $dst|$dst, $src2}",
1127 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1128 X86_COND_B, EFLAGS))]>,
1129 TB, OpSize;
1130def CMOVB32rm : I<0x42, MRMSrcMem, // if <u, GR32 = [mem32]
1131 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1132 "cmovb\t{$src2, $dst|$dst, $src2}",
1133 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1134 X86_COND_B, EFLAGS))]>,
1135 TB;
1136def CMOVAE16rm: I<0x43, MRMSrcMem, // if >=u, GR16 = [mem16]
1137 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1138 "cmovae\t{$src2, $dst|$dst, $src2}",
1139 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1140 X86_COND_AE, EFLAGS))]>,
1141 TB, OpSize;
1142def CMOVAE32rm: I<0x43, MRMSrcMem, // if >=u, GR32 = [mem32]
1143 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1144 "cmovae\t{$src2, $dst|$dst, $src2}",
1145 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1146 X86_COND_AE, EFLAGS))]>,
1147 TB;
1148def CMOVE16rm : I<0x44, MRMSrcMem, // if ==, GR16 = [mem16]
1149 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1150 "cmove\t{$src2, $dst|$dst, $src2}",
1151 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1152 X86_COND_E, EFLAGS))]>,
1153 TB, OpSize;
1154def CMOVE32rm : I<0x44, MRMSrcMem, // if ==, GR32 = [mem32]
1155 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1156 "cmove\t{$src2, $dst|$dst, $src2}",
1157 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1158 X86_COND_E, EFLAGS))]>,
1159 TB;
1160def CMOVNE16rm: I<0x45, MRMSrcMem, // if !=, GR16 = [mem16]
1161 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1162 "cmovne\t{$src2, $dst|$dst, $src2}",
1163 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1164 X86_COND_NE, EFLAGS))]>,
1165 TB, OpSize;
1166def CMOVNE32rm: I<0x45, MRMSrcMem, // if !=, GR32 = [mem32]
1167 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1168 "cmovne\t{$src2, $dst|$dst, $src2}",
1169 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1170 X86_COND_NE, EFLAGS))]>,
1171 TB;
1172def CMOVBE16rm: I<0x46, MRMSrcMem, // if <=u, GR16 = [mem16]
1173 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1174 "cmovbe\t{$src2, $dst|$dst, $src2}",
1175 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1176 X86_COND_BE, EFLAGS))]>,
1177 TB, OpSize;
1178def CMOVBE32rm: I<0x46, MRMSrcMem, // if <=u, GR32 = [mem32]
1179 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1180 "cmovbe\t{$src2, $dst|$dst, $src2}",
1181 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1182 X86_COND_BE, EFLAGS))]>,
1183 TB;
1184def CMOVA16rm : I<0x47, MRMSrcMem, // if >u, GR16 = [mem16]
1185 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1186 "cmova\t{$src2, $dst|$dst, $src2}",
1187 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1188 X86_COND_A, EFLAGS))]>,
1189 TB, OpSize;
1190def CMOVA32rm : I<0x47, MRMSrcMem, // if >u, GR32 = [mem32]
1191 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1192 "cmova\t{$src2, $dst|$dst, $src2}",
1193 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1194 X86_COND_A, EFLAGS))]>,
1195 TB;
1196def CMOVL16rm : I<0x4C, MRMSrcMem, // if <s, GR16 = [mem16]
1197 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1198 "cmovl\t{$src2, $dst|$dst, $src2}",
1199 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1200 X86_COND_L, EFLAGS))]>,
1201 TB, OpSize;
1202def CMOVL32rm : I<0x4C, MRMSrcMem, // if <s, GR32 = [mem32]
1203 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1204 "cmovl\t{$src2, $dst|$dst, $src2}",
1205 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1206 X86_COND_L, EFLAGS))]>,
1207 TB;
1208def CMOVGE16rm: I<0x4D, MRMSrcMem, // if >=s, GR16 = [mem16]
1209 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1210 "cmovge\t{$src2, $dst|$dst, $src2}",
1211 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1212 X86_COND_GE, EFLAGS))]>,
1213 TB, OpSize;
1214def CMOVGE32rm: I<0x4D, MRMSrcMem, // if >=s, GR32 = [mem32]
1215 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1216 "cmovge\t{$src2, $dst|$dst, $src2}",
1217 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1218 X86_COND_GE, EFLAGS))]>,
1219 TB;
1220def CMOVLE16rm: I<0x4E, MRMSrcMem, // if <=s, GR16 = [mem16]
1221 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1222 "cmovle\t{$src2, $dst|$dst, $src2}",
1223 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1224 X86_COND_LE, EFLAGS))]>,
1225 TB, OpSize;
1226def CMOVLE32rm: I<0x4E, MRMSrcMem, // if <=s, GR32 = [mem32]
1227 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1228 "cmovle\t{$src2, $dst|$dst, $src2}",
1229 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1230 X86_COND_LE, EFLAGS))]>,
1231 TB;
1232def CMOVG16rm : I<0x4F, MRMSrcMem, // if >s, GR16 = [mem16]
1233 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1234 "cmovg\t{$src2, $dst|$dst, $src2}",
1235 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1236 X86_COND_G, EFLAGS))]>,
1237 TB, OpSize;
1238def CMOVG32rm : I<0x4F, MRMSrcMem, // if >s, GR32 = [mem32]
1239 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1240 "cmovg\t{$src2, $dst|$dst, $src2}",
1241 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1242 X86_COND_G, EFLAGS))]>,
1243 TB;
1244def CMOVS16rm : I<0x48, MRMSrcMem, // if signed, GR16 = [mem16]
1245 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1246 "cmovs\t{$src2, $dst|$dst, $src2}",
1247 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1248 X86_COND_S, EFLAGS))]>,
1249 TB, OpSize;
1250def CMOVS32rm : I<0x48, MRMSrcMem, // if signed, GR32 = [mem32]
1251 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1252 "cmovs\t{$src2, $dst|$dst, $src2}",
1253 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1254 X86_COND_S, EFLAGS))]>,
1255 TB;
1256def CMOVNS16rm: I<0x49, MRMSrcMem, // if !signed, GR16 = [mem16]
1257 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1258 "cmovns\t{$src2, $dst|$dst, $src2}",
1259 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1260 X86_COND_NS, EFLAGS))]>,
1261 TB, OpSize;
1262def CMOVNS32rm: I<0x49, MRMSrcMem, // if !signed, GR32 = [mem32]
1263 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1264 "cmovns\t{$src2, $dst|$dst, $src2}",
1265 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1266 X86_COND_NS, EFLAGS))]>,
1267 TB;
1268def CMOVP16rm : I<0x4A, MRMSrcMem, // if parity, GR16 = [mem16]
1269 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1270 "cmovp\t{$src2, $dst|$dst, $src2}",
1271 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1272 X86_COND_P, EFLAGS))]>,
1273 TB, OpSize;
1274def CMOVP32rm : I<0x4A, MRMSrcMem, // if parity, GR32 = [mem32]
1275 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1276 "cmovp\t{$src2, $dst|$dst, $src2}",
1277 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1278 X86_COND_P, EFLAGS))]>,
1279 TB;
1280def CMOVNP16rm : I<0x4B, MRMSrcMem, // if !parity, GR16 = [mem16]
1281 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1282 "cmovnp\t{$src2, $dst|$dst, $src2}",
1283 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1284 X86_COND_NP, EFLAGS))]>,
1285 TB, OpSize;
Dan Gohman12fd4d72009-01-07 00:35:10 +00001286def CMOVNP32rm : I<0x4B, MRMSrcMem, // if !parity, GR32 = [mem32]
1287 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1288 "cmovnp\t{$src2, $dst|$dst, $src2}",
1289 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1290 X86_COND_NP, EFLAGS))]>,
1291 TB;
1292def CMOVO16rm : I<0x40, MRMSrcMem, // if overflow, GR16 = [mem16]
1293 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1294 "cmovo\t{$src2, $dst|$dst, $src2}",
1295 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1296 X86_COND_O, EFLAGS))]>,
1297 TB, OpSize;
1298def CMOVO32rm : I<0x40, MRMSrcMem, // if overflow, GR32 = [mem32]
1299 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1300 "cmovo\t{$src2, $dst|$dst, $src2}",
1301 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1302 X86_COND_O, EFLAGS))]>,
1303 TB;
1304def CMOVNO16rm : I<0x41, MRMSrcMem, // if !overflow, GR16 = [mem16]
1305 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1306 "cmovno\t{$src2, $dst|$dst, $src2}",
1307 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1308 X86_COND_NO, EFLAGS))]>,
1309 TB, OpSize;
1310def CMOVNO32rm : I<0x41, MRMSrcMem, // if !overflow, GR32 = [mem32]
1311 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1312 "cmovno\t{$src2, $dst|$dst, $src2}",
1313 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1314 X86_COND_NO, EFLAGS))]>,
1315 TB;
Evan Cheng950aac02007-09-25 01:57:46 +00001316} // Uses = [EFLAGS]
1317
1318
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001319// unary instructions
1320let CodeSize = 2 in {
Evan Cheng55687072007-09-14 21:48:26 +00001321let Defs = [EFLAGS] in {
Dan Gohman91888f02007-07-31 20:11:57 +00001322def NEG8r : I<0xF6, MRM3r, (outs GR8 :$dst), (ins GR8 :$src), "neg{b}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001323 [(set GR8:$dst, (ineg GR8:$src)),
1324 (implicit EFLAGS)]>;
Dan Gohman91888f02007-07-31 20:11:57 +00001325def NEG16r : I<0xF7, MRM3r, (outs GR16:$dst), (ins GR16:$src), "neg{w}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001326 [(set GR16:$dst, (ineg GR16:$src)),
1327 (implicit EFLAGS)]>, OpSize;
Dan Gohman91888f02007-07-31 20:11:57 +00001328def NEG32r : I<0xF7, MRM3r, (outs GR32:$dst), (ins GR32:$src), "neg{l}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001329 [(set GR32:$dst, (ineg GR32:$src)),
1330 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001331let isTwoAddress = 0 in {
Dan Gohman91888f02007-07-31 20:11:57 +00001332 def NEG8m : I<0xF6, MRM3m, (outs), (ins i8mem :$dst), "neg{b}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001333 [(store (ineg (loadi8 addr:$dst)), addr:$dst),
1334 (implicit EFLAGS)]>;
Dan Gohman91888f02007-07-31 20:11:57 +00001335 def NEG16m : I<0xF7, MRM3m, (outs), (ins i16mem:$dst), "neg{w}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001336 [(store (ineg (loadi16 addr:$dst)), addr:$dst),
1337 (implicit EFLAGS)]>, OpSize;
Dan Gohman91888f02007-07-31 20:11:57 +00001338 def NEG32m : I<0xF7, MRM3m, (outs), (ins i32mem:$dst), "neg{l}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001339 [(store (ineg (loadi32 addr:$dst)), addr:$dst),
1340 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001341}
Evan Cheng55687072007-09-14 21:48:26 +00001342} // Defs = [EFLAGS]
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001343
Evan Chengc6cee682009-01-21 02:09:05 +00001344// Match xor -1 to not. Favors these over a move imm + xor to save code size.
1345let AddedComplexity = 15 in {
Dan Gohman91888f02007-07-31 20:11:57 +00001346def NOT8r : I<0xF6, MRM2r, (outs GR8 :$dst), (ins GR8 :$src), "not{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001347 [(set GR8:$dst, (not GR8:$src))]>;
Dan Gohman91888f02007-07-31 20:11:57 +00001348def NOT16r : I<0xF7, MRM2r, (outs GR16:$dst), (ins GR16:$src), "not{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001349 [(set GR16:$dst, (not GR16:$src))]>, OpSize;
Dan Gohman91888f02007-07-31 20:11:57 +00001350def NOT32r : I<0xF7, MRM2r, (outs GR32:$dst), (ins GR32:$src), "not{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001351 [(set GR32:$dst, (not GR32:$src))]>;
Evan Chengc6cee682009-01-21 02:09:05 +00001352}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001353let isTwoAddress = 0 in {
Dan Gohman91888f02007-07-31 20:11:57 +00001354 def NOT8m : I<0xF6, MRM2m, (outs), (ins i8mem :$dst), "not{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001355 [(store (not (loadi8 addr:$dst)), addr:$dst)]>;
Dan Gohman91888f02007-07-31 20:11:57 +00001356 def NOT16m : I<0xF7, MRM2m, (outs), (ins i16mem:$dst), "not{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001357 [(store (not (loadi16 addr:$dst)), addr:$dst)]>, OpSize;
Dan Gohman91888f02007-07-31 20:11:57 +00001358 def NOT32m : I<0xF7, MRM2m, (outs), (ins i32mem:$dst), "not{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001359 [(store (not (loadi32 addr:$dst)), addr:$dst)]>;
1360}
1361} // CodeSize
1362
1363// TODO: inc/dec is slow for P4, but fast for Pentium-M.
Evan Cheng55687072007-09-14 21:48:26 +00001364let Defs = [EFLAGS] in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001365let CodeSize = 2 in
Dan Gohman91888f02007-07-31 20:11:57 +00001366def INC8r : I<0xFE, MRM0r, (outs GR8 :$dst), (ins GR8 :$src), "inc{b}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001367 [(set GR8:$dst, (add GR8:$src, 1)),
1368 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001369let isConvertibleToThreeAddress = 1, CodeSize = 1 in { // Can xform into LEA.
Dan Gohman91888f02007-07-31 20:11:57 +00001370def INC16r : I<0x40, AddRegFrm, (outs GR16:$dst), (ins GR16:$src), "inc{w}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001371 [(set GR16:$dst, (add GR16:$src, 1)),
1372 (implicit EFLAGS)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001373 OpSize, Requires<[In32BitMode]>;
Dan Gohman91888f02007-07-31 20:11:57 +00001374def INC32r : I<0x40, AddRegFrm, (outs GR32:$dst), (ins GR32:$src), "inc{l}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001375 [(set GR32:$dst, (add GR32:$src, 1)),
1376 (implicit EFLAGS)]>, Requires<[In32BitMode]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001377}
1378let isTwoAddress = 0, CodeSize = 2 in {
Dan Gohman91888f02007-07-31 20:11:57 +00001379 def INC8m : I<0xFE, MRM0m, (outs), (ins i8mem :$dst), "inc{b}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001380 [(store (add (loadi8 addr:$dst), 1), addr:$dst),
1381 (implicit EFLAGS)]>;
Dan Gohman91888f02007-07-31 20:11:57 +00001382 def INC16m : I<0xFF, MRM0m, (outs), (ins i16mem:$dst), "inc{w}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001383 [(store (add (loadi16 addr:$dst), 1), addr:$dst),
1384 (implicit EFLAGS)]>,
Evan Cheng4a7e72f2007-10-19 21:23:22 +00001385 OpSize, Requires<[In32BitMode]>;
Dan Gohman91888f02007-07-31 20:11:57 +00001386 def INC32m : I<0xFF, MRM0m, (outs), (ins i32mem:$dst), "inc{l}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001387 [(store (add (loadi32 addr:$dst), 1), addr:$dst),
1388 (implicit EFLAGS)]>,
Evan Cheng4a7e72f2007-10-19 21:23:22 +00001389 Requires<[In32BitMode]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001390}
1391
1392let CodeSize = 2 in
Dan Gohman91888f02007-07-31 20:11:57 +00001393def DEC8r : I<0xFE, MRM1r, (outs GR8 :$dst), (ins GR8 :$src), "dec{b}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001394 [(set GR8:$dst, (add GR8:$src, -1)),
1395 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001396let isConvertibleToThreeAddress = 1, CodeSize = 1 in { // Can xform into LEA.
Dan Gohman91888f02007-07-31 20:11:57 +00001397def DEC16r : I<0x48, AddRegFrm, (outs GR16:$dst), (ins GR16:$src), "dec{w}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001398 [(set GR16:$dst, (add GR16:$src, -1)),
1399 (implicit EFLAGS)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001400 OpSize, Requires<[In32BitMode]>;
Dan Gohman91888f02007-07-31 20:11:57 +00001401def DEC32r : I<0x48, AddRegFrm, (outs GR32:$dst), (ins GR32:$src), "dec{l}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001402 [(set GR32:$dst, (add GR32:$src, -1)),
1403 (implicit EFLAGS)]>, Requires<[In32BitMode]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001404}
1405
1406let isTwoAddress = 0, CodeSize = 2 in {
Dan Gohman91888f02007-07-31 20:11:57 +00001407 def DEC8m : I<0xFE, MRM1m, (outs), (ins i8mem :$dst), "dec{b}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001408 [(store (add (loadi8 addr:$dst), -1), addr:$dst),
1409 (implicit EFLAGS)]>;
Dan Gohman91888f02007-07-31 20:11:57 +00001410 def DEC16m : I<0xFF, MRM1m, (outs), (ins i16mem:$dst), "dec{w}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001411 [(store (add (loadi16 addr:$dst), -1), addr:$dst),
1412 (implicit EFLAGS)]>,
Evan Cheng4a7e72f2007-10-19 21:23:22 +00001413 OpSize, Requires<[In32BitMode]>;
Dan Gohman91888f02007-07-31 20:11:57 +00001414 def DEC32m : I<0xFF, MRM1m, (outs), (ins i32mem:$dst), "dec{l}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001415 [(store (add (loadi32 addr:$dst), -1), addr:$dst),
1416 (implicit EFLAGS)]>,
Evan Cheng4a7e72f2007-10-19 21:23:22 +00001417 Requires<[In32BitMode]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001418}
Evan Cheng55687072007-09-14 21:48:26 +00001419} // Defs = [EFLAGS]
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001420
1421// Logical operators...
Evan Cheng55687072007-09-14 21:48:26 +00001422let Defs = [EFLAGS] in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001423let isCommutable = 1 in { // X = AND Y, Z --> X = AND Z, Y
1424def AND8rr : I<0x20, MRMDestReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001425 (outs GR8 :$dst), (ins GR8 :$src1, GR8 :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001426 "and{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001427 [(set GR8:$dst, (and GR8:$src1, GR8:$src2)),
1428 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001429def AND16rr : I<0x21, MRMDestReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001430 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001431 "and{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001432 [(set GR16:$dst, (and GR16:$src1, GR16:$src2)),
1433 (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001434def AND32rr : I<0x21, MRMDestReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001435 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001436 "and{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001437 [(set GR32:$dst, (and GR32:$src1, GR32:$src2)),
1438 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001439}
1440
1441def AND8rm : I<0x22, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001442 (outs GR8 :$dst), (ins GR8 :$src1, i8mem :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001443 "and{b}\t{$src2, $dst|$dst, $src2}",
Chris Lattner12208612009-04-10 00:16:23 +00001444 [(set GR8:$dst, (and GR8:$src1, (loadi8 addr:$src2))),
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001445 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001446def AND16rm : I<0x23, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001447 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001448 "and{w}\t{$src2, $dst|$dst, $src2}",
Chris Lattner12208612009-04-10 00:16:23 +00001449 [(set GR16:$dst, (and GR16:$src1, (loadi16 addr:$src2))),
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001450 (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001451def AND32rm : I<0x23, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001452 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001453 "and{l}\t{$src2, $dst|$dst, $src2}",
Chris Lattner12208612009-04-10 00:16:23 +00001454 [(set GR32:$dst, (and GR32:$src1, (loadi32 addr:$src2))),
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001455 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001456
1457def AND8ri : Ii8<0x80, MRM4r,
Evan Chengb783fa32007-07-19 01:14:50 +00001458 (outs GR8 :$dst), (ins GR8 :$src1, i8imm :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001459 "and{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001460 [(set GR8:$dst, (and GR8:$src1, imm:$src2)),
1461 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001462def AND16ri : Ii16<0x81, MRM4r,
Evan Chengb783fa32007-07-19 01:14:50 +00001463 (outs GR16:$dst), (ins GR16:$src1, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001464 "and{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001465 [(set GR16:$dst, (and GR16:$src1, imm:$src2)),
1466 (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001467def AND32ri : Ii32<0x81, MRM4r,
Evan Chengb783fa32007-07-19 01:14:50 +00001468 (outs GR32:$dst), (ins GR32:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001469 "and{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001470 [(set GR32:$dst, (and GR32:$src1, imm:$src2)),
1471 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001472def AND16ri8 : Ii8<0x83, MRM4r,
Evan Chengb783fa32007-07-19 01:14:50 +00001473 (outs GR16:$dst), (ins GR16:$src1, i16i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001474 "and{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001475 [(set GR16:$dst, (and GR16:$src1, i16immSExt8:$src2)),
1476 (implicit EFLAGS)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001477 OpSize;
1478def AND32ri8 : Ii8<0x83, MRM4r,
Evan Chengb783fa32007-07-19 01:14:50 +00001479 (outs GR32:$dst), (ins GR32:$src1, i32i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001480 "and{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001481 [(set GR32:$dst, (and GR32:$src1, i32immSExt8:$src2)),
1482 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001483
1484let isTwoAddress = 0 in {
1485 def AND8mr : I<0x20, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001486 (outs), (ins i8mem :$dst, GR8 :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001487 "and{b}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001488 [(store (and (load addr:$dst), GR8:$src), addr:$dst),
1489 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001490 def AND16mr : I<0x21, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001491 (outs), (ins i16mem:$dst, GR16:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001492 "and{w}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001493 [(store (and (load addr:$dst), GR16:$src), addr:$dst),
1494 (implicit EFLAGS)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001495 OpSize;
1496 def AND32mr : I<0x21, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001497 (outs), (ins i32mem:$dst, GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001498 "and{l}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001499 [(store (and (load addr:$dst), GR32:$src), addr:$dst),
1500 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001501 def AND8mi : Ii8<0x80, MRM4m,
Evan Chengb783fa32007-07-19 01:14:50 +00001502 (outs), (ins i8mem :$dst, i8imm :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001503 "and{b}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001504 [(store (and (loadi8 addr:$dst), imm:$src), addr:$dst),
1505 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001506 def AND16mi : Ii16<0x81, MRM4m,
Evan Chengb783fa32007-07-19 01:14:50 +00001507 (outs), (ins i16mem:$dst, i16imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001508 "and{w}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001509 [(store (and (loadi16 addr:$dst), imm:$src), addr:$dst),
1510 (implicit EFLAGS)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001511 OpSize;
1512 def AND32mi : Ii32<0x81, MRM4m,
Evan Chengb783fa32007-07-19 01:14:50 +00001513 (outs), (ins i32mem:$dst, i32imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001514 "and{l}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001515 [(store (and (loadi32 addr:$dst), imm:$src), addr:$dst),
1516 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001517 def AND16mi8 : Ii8<0x83, MRM4m,
Evan Chengb783fa32007-07-19 01:14:50 +00001518 (outs), (ins i16mem:$dst, i16i8imm :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001519 "and{w}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001520 [(store (and (load addr:$dst), i16immSExt8:$src), addr:$dst),
1521 (implicit EFLAGS)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001522 OpSize;
1523 def AND32mi8 : Ii8<0x83, MRM4m,
Evan Chengb783fa32007-07-19 01:14:50 +00001524 (outs), (ins i32mem:$dst, i32i8imm :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001525 "and{l}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001526 [(store (and (load addr:$dst), i32immSExt8:$src), addr:$dst),
1527 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001528}
1529
1530
1531let isCommutable = 1 in { // X = OR Y, Z --> X = OR Z, Y
Evan Chengb783fa32007-07-19 01:14:50 +00001532def OR8rr : I<0x08, MRMDestReg, (outs GR8 :$dst), (ins GR8 :$src1, GR8 :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001533 "or{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001534 [(set GR8:$dst, (or GR8:$src1, GR8:$src2)),
1535 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001536def OR16rr : I<0x09, MRMDestReg, (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001537 "or{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001538 [(set GR16:$dst, (or GR16:$src1, GR16:$src2)),
1539 (implicit EFLAGS)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001540def OR32rr : I<0x09, MRMDestReg, (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001541 "or{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001542 [(set GR32:$dst, (or GR32:$src1, GR32:$src2)),
1543 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001544}
Evan Chengb783fa32007-07-19 01:14:50 +00001545def OR8rm : I<0x0A, MRMSrcMem , (outs GR8 :$dst), (ins GR8 :$src1, i8mem :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001546 "or{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001547 [(set GR8:$dst, (or GR8:$src1, (load addr:$src2))),
1548 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001549def OR16rm : I<0x0B, MRMSrcMem , (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001550 "or{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001551 [(set GR16:$dst, (or GR16:$src1, (load addr:$src2))),
1552 (implicit EFLAGS)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001553def OR32rm : I<0x0B, MRMSrcMem , (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001554 "or{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001555 [(set GR32:$dst, (or GR32:$src1, (load addr:$src2))),
1556 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001557
Evan Chengb783fa32007-07-19 01:14:50 +00001558def OR8ri : Ii8 <0x80, MRM1r, (outs GR8 :$dst), (ins GR8 :$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001559 "or{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001560 [(set GR8:$dst, (or GR8:$src1, imm:$src2)),
1561 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001562def OR16ri : Ii16<0x81, MRM1r, (outs GR16:$dst), (ins GR16:$src1, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001563 "or{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001564 [(set GR16:$dst, (or GR16:$src1, imm:$src2)),
1565 (implicit EFLAGS)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001566def OR32ri : Ii32<0x81, MRM1r, (outs GR32:$dst), (ins GR32:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001567 "or{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001568 [(set GR32:$dst, (or GR32:$src1, imm:$src2)),
1569 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001570
Evan Chengb783fa32007-07-19 01:14:50 +00001571def OR16ri8 : Ii8<0x83, MRM1r, (outs GR16:$dst), (ins GR16:$src1, i16i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001572 "or{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001573 [(set GR16:$dst, (or GR16:$src1, i16immSExt8:$src2)),
1574 (implicit EFLAGS)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001575def OR32ri8 : Ii8<0x83, MRM1r, (outs GR32:$dst), (ins GR32:$src1, i32i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001576 "or{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001577 [(set GR32:$dst, (or GR32:$src1, i32immSExt8:$src2)),
1578 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001579let isTwoAddress = 0 in {
Evan Chengb783fa32007-07-19 01:14:50 +00001580 def OR8mr : I<0x08, MRMDestMem, (outs), (ins i8mem:$dst, GR8:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001581 "or{b}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001582 [(store (or (load addr:$dst), GR8:$src), addr:$dst),
1583 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001584 def OR16mr : I<0x09, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001585 "or{w}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001586 [(store (or (load addr:$dst), GR16:$src), addr:$dst),
1587 (implicit EFLAGS)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001588 def OR32mr : I<0x09, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001589 "or{l}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001590 [(store (or (load addr:$dst), GR32:$src), addr:$dst),
1591 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001592 def OR8mi : Ii8<0x80, MRM1m, (outs), (ins i8mem :$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001593 "or{b}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001594 [(store (or (loadi8 addr:$dst), imm:$src), addr:$dst),
1595 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001596 def OR16mi : Ii16<0x81, MRM1m, (outs), (ins i16mem:$dst, i16imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001597 "or{w}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001598 [(store (or (loadi16 addr:$dst), imm:$src), addr:$dst),
1599 (implicit EFLAGS)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001600 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001601 def OR32mi : Ii32<0x81, MRM1m, (outs), (ins i32mem:$dst, i32imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001602 "or{l}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001603 [(store (or (loadi32 addr:$dst), imm:$src), addr:$dst),
1604 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001605 def OR16mi8 : Ii8<0x83, MRM1m, (outs), (ins i16mem:$dst, i16i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001606 "or{w}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001607 [(store (or (load addr:$dst), i16immSExt8:$src), addr:$dst),
1608 (implicit EFLAGS)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001609 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001610 def OR32mi8 : Ii8<0x83, MRM1m, (outs), (ins i32mem:$dst, i32i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001611 "or{l}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001612 [(store (or (load addr:$dst), i32immSExt8:$src), addr:$dst),
1613 (implicit EFLAGS)]>;
Bill Wendlingba5d5b02008-05-29 01:02:09 +00001614} // isTwoAddress = 0
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001615
1616
Evan Cheng6f26e8b2008-06-18 08:13:07 +00001617let isCommutable = 1 in { // X = XOR Y, Z --> X = XOR Z, Y
Bill Wendlingba5d5b02008-05-29 01:02:09 +00001618 def XOR8rr : I<0x30, MRMDestReg,
1619 (outs GR8 :$dst), (ins GR8 :$src1, GR8 :$src2),
1620 "xor{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001621 [(set GR8:$dst, (xor GR8:$src1, GR8:$src2)),
1622 (implicit EFLAGS)]>;
Bill Wendlingba5d5b02008-05-29 01:02:09 +00001623 def XOR16rr : I<0x31, MRMDestReg,
1624 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
1625 "xor{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001626 [(set GR16:$dst, (xor GR16:$src1, GR16:$src2)),
1627 (implicit EFLAGS)]>, OpSize;
Bill Wendlingba5d5b02008-05-29 01:02:09 +00001628 def XOR32rr : I<0x31, MRMDestReg,
1629 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
1630 "xor{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001631 [(set GR32:$dst, (xor GR32:$src1, GR32:$src2)),
1632 (implicit EFLAGS)]>;
Evan Cheng6f26e8b2008-06-18 08:13:07 +00001633} // isCommutable = 1
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001634
1635def XOR8rm : I<0x32, MRMSrcMem ,
Evan Chengb783fa32007-07-19 01:14:50 +00001636 (outs GR8 :$dst), (ins GR8:$src1, i8mem :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001637 "xor{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001638 [(set GR8:$dst, (xor GR8:$src1, (load addr:$src2))),
1639 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001640def XOR16rm : I<0x33, MRMSrcMem ,
Evan Chengb783fa32007-07-19 01:14:50 +00001641 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001642 "xor{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001643 [(set GR16:$dst, (xor GR16:$src1, (load addr:$src2))),
1644 (implicit EFLAGS)]>,
Bill Wendlingba5d5b02008-05-29 01:02:09 +00001645 OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001646def XOR32rm : I<0x33, MRMSrcMem ,
Evan Chengb783fa32007-07-19 01:14:50 +00001647 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001648 "xor{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001649 [(set GR32:$dst, (xor GR32:$src1, (load addr:$src2))),
1650 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001651
Bill Wendlingbac38eb2008-05-29 03:46:36 +00001652def XOR8ri : Ii8<0x80, MRM6r,
1653 (outs GR8:$dst), (ins GR8:$src1, i8imm:$src2),
1654 "xor{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001655 [(set GR8:$dst, (xor GR8:$src1, imm:$src2)),
1656 (implicit EFLAGS)]>;
Bill Wendlingbac38eb2008-05-29 03:46:36 +00001657def XOR16ri : Ii16<0x81, MRM6r,
1658 (outs GR16:$dst), (ins GR16:$src1, i16imm:$src2),
1659 "xor{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001660 [(set GR16:$dst, (xor GR16:$src1, imm:$src2)),
1661 (implicit EFLAGS)]>, OpSize;
Bill Wendlingbac38eb2008-05-29 03:46:36 +00001662def XOR32ri : Ii32<0x81, MRM6r,
1663 (outs GR32:$dst), (ins GR32:$src1, i32imm:$src2),
1664 "xor{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001665 [(set GR32:$dst, (xor GR32:$src1, imm:$src2)),
1666 (implicit EFLAGS)]>;
Bill Wendlingbac38eb2008-05-29 03:46:36 +00001667def XOR16ri8 : Ii8<0x83, MRM6r,
1668 (outs GR16:$dst), (ins GR16:$src1, i16i8imm:$src2),
1669 "xor{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001670 [(set GR16:$dst, (xor GR16:$src1, i16immSExt8:$src2)),
1671 (implicit EFLAGS)]>,
Bill Wendlingbac38eb2008-05-29 03:46:36 +00001672 OpSize;
1673def XOR32ri8 : Ii8<0x83, MRM6r,
1674 (outs GR32:$dst), (ins GR32:$src1, i32i8imm:$src2),
1675 "xor{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001676 [(set GR32:$dst, (xor GR32:$src1, i32immSExt8:$src2)),
1677 (implicit EFLAGS)]>;
Bill Wendlingba5d5b02008-05-29 01:02:09 +00001678
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001679let isTwoAddress = 0 in {
1680 def XOR8mr : I<0x30, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001681 (outs), (ins i8mem :$dst, GR8 :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001682 "xor{b}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001683 [(store (xor (load addr:$dst), GR8:$src), addr:$dst),
1684 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001685 def XOR16mr : I<0x31, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001686 (outs), (ins i16mem:$dst, GR16:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001687 "xor{w}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001688 [(store (xor (load addr:$dst), GR16:$src), addr:$dst),
1689 (implicit EFLAGS)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001690 OpSize;
1691 def XOR32mr : I<0x31, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001692 (outs), (ins i32mem:$dst, GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001693 "xor{l}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001694 [(store (xor (load addr:$dst), GR32:$src), addr:$dst),
1695 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001696 def XOR8mi : Ii8<0x80, MRM6m,
Evan Chengb783fa32007-07-19 01:14:50 +00001697 (outs), (ins i8mem :$dst, i8imm :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001698 "xor{b}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001699 [(store (xor (loadi8 addr:$dst), imm:$src), addr:$dst),
1700 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001701 def XOR16mi : Ii16<0x81, MRM6m,
Evan Chengb783fa32007-07-19 01:14:50 +00001702 (outs), (ins i16mem:$dst, i16imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001703 "xor{w}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001704 [(store (xor (loadi16 addr:$dst), imm:$src), addr:$dst),
1705 (implicit EFLAGS)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001706 OpSize;
1707 def XOR32mi : Ii32<0x81, MRM6m,
Evan Chengb783fa32007-07-19 01:14:50 +00001708 (outs), (ins i32mem:$dst, i32imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001709 "xor{l}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001710 [(store (xor (loadi32 addr:$dst), imm:$src), addr:$dst),
1711 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001712 def XOR16mi8 : Ii8<0x83, MRM6m,
Evan Chengb783fa32007-07-19 01:14:50 +00001713 (outs), (ins i16mem:$dst, i16i8imm :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001714 "xor{w}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001715 [(store (xor (load addr:$dst), i16immSExt8:$src), addr:$dst),
1716 (implicit EFLAGS)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001717 OpSize;
1718 def XOR32mi8 : Ii8<0x83, MRM6m,
Evan Chengb783fa32007-07-19 01:14:50 +00001719 (outs), (ins i32mem:$dst, i32i8imm :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001720 "xor{l}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001721 [(store (xor (load addr:$dst), i32immSExt8:$src), addr:$dst),
1722 (implicit EFLAGS)]>;
Bill Wendlingba5d5b02008-05-29 01:02:09 +00001723} // isTwoAddress = 0
Evan Cheng55687072007-09-14 21:48:26 +00001724} // Defs = [EFLAGS]
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001725
1726// Shift instructions
Evan Cheng55687072007-09-14 21:48:26 +00001727let Defs = [EFLAGS] in {
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001728let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00001729def SHL8rCL : I<0xD2, MRM4r, (outs GR8 :$dst), (ins GR8 :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001730 "shl{b}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001731 [(set GR8:$dst, (shl GR8:$src, CL))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001732def SHL16rCL : I<0xD3, MRM4r, (outs GR16:$dst), (ins GR16:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001733 "shl{w}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001734 [(set GR16:$dst, (shl GR16:$src, CL))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001735def SHL32rCL : I<0xD3, MRM4r, (outs GR32:$dst), (ins GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001736 "shl{l}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001737 [(set GR32:$dst, (shl GR32:$src, CL))]>;
Bill Wendlingba5d5b02008-05-29 01:02:09 +00001738} // Uses = [CL]
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001739
Evan Chengb783fa32007-07-19 01:14:50 +00001740def SHL8ri : Ii8<0xC0, MRM4r, (outs GR8 :$dst), (ins GR8 :$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001741 "shl{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001742 [(set GR8:$dst, (shl GR8:$src1, (i8 imm:$src2)))]>;
1743let isConvertibleToThreeAddress = 1 in { // Can transform into LEA.
Evan Chengb783fa32007-07-19 01:14:50 +00001744def SHL16ri : Ii8<0xC1, MRM4r, (outs GR16:$dst), (ins GR16:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001745 "shl{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001746 [(set GR16:$dst, (shl GR16:$src1, (i8 imm:$src2)))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001747def SHL32ri : Ii8<0xC1, MRM4r, (outs GR32:$dst), (ins GR32:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001748 "shl{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001749 [(set GR32:$dst, (shl GR32:$src1, (i8 imm:$src2)))]>;
Chris Lattnerf4005a82008-01-11 18:00:50 +00001750// NOTE: We don't use shifts of a register by one, because 'add reg,reg' is
1751// cheaper.
Bill Wendlingba5d5b02008-05-29 01:02:09 +00001752} // isConvertibleToThreeAddress = 1
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001753
1754let isTwoAddress = 0 in {
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001755 let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00001756 def SHL8mCL : I<0xD2, MRM4m, (outs), (ins i8mem :$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001757 "shl{b}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001758 [(store (shl (loadi8 addr:$dst), CL), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001759 def SHL16mCL : I<0xD3, MRM4m, (outs), (ins i16mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001760 "shl{w}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001761 [(store (shl (loadi16 addr:$dst), CL), addr:$dst)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001762 def SHL32mCL : I<0xD3, MRM4m, (outs), (ins i32mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001763 "shl{l}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001764 [(store (shl (loadi32 addr:$dst), CL), addr:$dst)]>;
1765 }
Evan Chengb783fa32007-07-19 01:14:50 +00001766 def SHL8mi : Ii8<0xC0, MRM4m, (outs), (ins i8mem :$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001767 "shl{b}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001768 [(store (shl (loadi8 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001769 def SHL16mi : Ii8<0xC1, MRM4m, (outs), (ins i16mem:$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001770 "shl{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001771 [(store (shl (loadi16 addr:$dst), (i8 imm:$src)), addr:$dst)]>,
1772 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001773 def SHL32mi : Ii8<0xC1, MRM4m, (outs), (ins i32mem:$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001774 "shl{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001775 [(store (shl (loadi32 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
1776
1777 // Shift by 1
Evan Chengb783fa32007-07-19 01:14:50 +00001778 def SHL8m1 : I<0xD0, MRM4m, (outs), (ins i8mem :$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001779 "shl{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001780 [(store (shl (loadi8 addr:$dst), (i8 1)), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001781 def SHL16m1 : I<0xD1, MRM4m, (outs), (ins i16mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001782 "shl{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001783 [(store (shl (loadi16 addr:$dst), (i8 1)), addr:$dst)]>,
1784 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001785 def SHL32m1 : I<0xD1, MRM4m, (outs), (ins i32mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001786 "shl{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001787 [(store (shl (loadi32 addr:$dst), (i8 1)), addr:$dst)]>;
1788}
1789
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001790let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00001791def SHR8rCL : I<0xD2, MRM5r, (outs GR8 :$dst), (ins GR8 :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001792 "shr{b}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001793 [(set GR8:$dst, (srl GR8:$src, CL))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001794def SHR16rCL : I<0xD3, MRM5r, (outs GR16:$dst), (ins GR16:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001795 "shr{w}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001796 [(set GR16:$dst, (srl GR16:$src, CL))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001797def SHR32rCL : I<0xD3, MRM5r, (outs GR32:$dst), (ins GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001798 "shr{l}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001799 [(set GR32:$dst, (srl GR32:$src, CL))]>;
1800}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001801
Evan Chengb783fa32007-07-19 01:14:50 +00001802def SHR8ri : Ii8<0xC0, MRM5r, (outs GR8:$dst), (ins GR8:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001803 "shr{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001804 [(set GR8:$dst, (srl GR8:$src1, (i8 imm:$src2)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001805def SHR16ri : Ii8<0xC1, MRM5r, (outs GR16:$dst), (ins GR16:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001806 "shr{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001807 [(set GR16:$dst, (srl GR16:$src1, (i8 imm:$src2)))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001808def SHR32ri : Ii8<0xC1, MRM5r, (outs GR32:$dst), (ins GR32:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001809 "shr{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001810 [(set GR32:$dst, (srl GR32:$src1, (i8 imm:$src2)))]>;
1811
1812// Shift by 1
Evan Chengb783fa32007-07-19 01:14:50 +00001813def SHR8r1 : I<0xD0, MRM5r, (outs GR8:$dst), (ins GR8:$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00001814 "shr{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001815 [(set GR8:$dst, (srl GR8:$src1, (i8 1)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001816def SHR16r1 : I<0xD1, MRM5r, (outs GR16:$dst), (ins GR16:$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00001817 "shr{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001818 [(set GR16:$dst, (srl GR16:$src1, (i8 1)))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001819def SHR32r1 : I<0xD1, MRM5r, (outs GR32:$dst), (ins GR32:$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00001820 "shr{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001821 [(set GR32:$dst, (srl GR32:$src1, (i8 1)))]>;
1822
1823let isTwoAddress = 0 in {
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001824 let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00001825 def SHR8mCL : I<0xD2, MRM5m, (outs), (ins i8mem :$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001826 "shr{b}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001827 [(store (srl (loadi8 addr:$dst), CL), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001828 def SHR16mCL : I<0xD3, MRM5m, (outs), (ins i16mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001829 "shr{w}\t{%cl, $dst|$dst, %CL}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001830 [(store (srl (loadi16 addr:$dst), CL), addr:$dst)]>,
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001831 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001832 def SHR32mCL : I<0xD3, MRM5m, (outs), (ins i32mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001833 "shr{l}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001834 [(store (srl (loadi32 addr:$dst), CL), addr:$dst)]>;
1835 }
Evan Chengb783fa32007-07-19 01:14:50 +00001836 def SHR8mi : Ii8<0xC0, MRM5m, (outs), (ins i8mem :$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001837 "shr{b}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001838 [(store (srl (loadi8 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001839 def SHR16mi : Ii8<0xC1, MRM5m, (outs), (ins i16mem:$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001840 "shr{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001841 [(store (srl (loadi16 addr:$dst), (i8 imm:$src)), addr:$dst)]>,
1842 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001843 def SHR32mi : Ii8<0xC1, MRM5m, (outs), (ins i32mem:$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001844 "shr{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001845 [(store (srl (loadi32 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
1846
1847 // Shift by 1
Evan Chengb783fa32007-07-19 01:14:50 +00001848 def SHR8m1 : I<0xD0, MRM5m, (outs), (ins i8mem :$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001849 "shr{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001850 [(store (srl (loadi8 addr:$dst), (i8 1)), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001851 def SHR16m1 : I<0xD1, MRM5m, (outs), (ins i16mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001852 "shr{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001853 [(store (srl (loadi16 addr:$dst), (i8 1)), addr:$dst)]>,OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001854 def SHR32m1 : I<0xD1, MRM5m, (outs), (ins i32mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001855 "shr{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001856 [(store (srl (loadi32 addr:$dst), (i8 1)), addr:$dst)]>;
1857}
1858
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001859let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00001860def SAR8rCL : I<0xD2, MRM7r, (outs GR8 :$dst), (ins GR8 :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001861 "sar{b}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001862 [(set GR8:$dst, (sra GR8:$src, CL))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001863def SAR16rCL : I<0xD3, MRM7r, (outs GR16:$dst), (ins GR16:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001864 "sar{w}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001865 [(set GR16:$dst, (sra GR16:$src, CL))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001866def SAR32rCL : I<0xD3, MRM7r, (outs GR32:$dst), (ins GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001867 "sar{l}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001868 [(set GR32:$dst, (sra GR32:$src, CL))]>;
1869}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001870
Evan Chengb783fa32007-07-19 01:14:50 +00001871def SAR8ri : Ii8<0xC0, MRM7r, (outs GR8 :$dst), (ins GR8 :$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001872 "sar{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001873 [(set GR8:$dst, (sra GR8:$src1, (i8 imm:$src2)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001874def SAR16ri : Ii8<0xC1, MRM7r, (outs GR16:$dst), (ins GR16:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001875 "sar{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001876 [(set GR16:$dst, (sra GR16:$src1, (i8 imm:$src2)))]>,
1877 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001878def SAR32ri : Ii8<0xC1, MRM7r, (outs GR32:$dst), (ins GR32:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001879 "sar{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001880 [(set GR32:$dst, (sra GR32:$src1, (i8 imm:$src2)))]>;
1881
1882// Shift by 1
Evan Chengb783fa32007-07-19 01:14:50 +00001883def SAR8r1 : I<0xD0, MRM7r, (outs GR8 :$dst), (ins GR8 :$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00001884 "sar{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001885 [(set GR8:$dst, (sra GR8:$src1, (i8 1)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001886def SAR16r1 : I<0xD1, MRM7r, (outs GR16:$dst), (ins GR16:$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00001887 "sar{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001888 [(set GR16:$dst, (sra GR16:$src1, (i8 1)))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001889def SAR32r1 : I<0xD1, MRM7r, (outs GR32:$dst), (ins GR32:$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00001890 "sar{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001891 [(set GR32:$dst, (sra GR32:$src1, (i8 1)))]>;
1892
1893let isTwoAddress = 0 in {
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001894 let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00001895 def SAR8mCL : I<0xD2, MRM7m, (outs), (ins i8mem :$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001896 "sar{b}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001897 [(store (sra (loadi8 addr:$dst), CL), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001898 def SAR16mCL : I<0xD3, MRM7m, (outs), (ins i16mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001899 "sar{w}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001900 [(store (sra (loadi16 addr:$dst), CL), addr:$dst)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001901 def SAR32mCL : I<0xD3, MRM7m, (outs), (ins i32mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001902 "sar{l}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001903 [(store (sra (loadi32 addr:$dst), CL), addr:$dst)]>;
1904 }
Evan Chengb783fa32007-07-19 01:14:50 +00001905 def SAR8mi : Ii8<0xC0, MRM7m, (outs), (ins i8mem :$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001906 "sar{b}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001907 [(store (sra (loadi8 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001908 def SAR16mi : Ii8<0xC1, MRM7m, (outs), (ins i16mem:$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001909 "sar{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001910 [(store (sra (loadi16 addr:$dst), (i8 imm:$src)), addr:$dst)]>,
1911 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001912 def SAR32mi : Ii8<0xC1, MRM7m, (outs), (ins i32mem:$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001913 "sar{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001914 [(store (sra (loadi32 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
1915
1916 // Shift by 1
Evan Chengb783fa32007-07-19 01:14:50 +00001917 def SAR8m1 : I<0xD0, MRM7m, (outs), (ins i8mem :$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001918 "sar{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001919 [(store (sra (loadi8 addr:$dst), (i8 1)), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001920 def SAR16m1 : I<0xD1, MRM7m, (outs), (ins i16mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001921 "sar{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001922 [(store (sra (loadi16 addr:$dst), (i8 1)), addr:$dst)]>,
1923 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001924 def SAR32m1 : I<0xD1, MRM7m, (outs), (ins i32mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001925 "sar{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001926 [(store (sra (loadi32 addr:$dst), (i8 1)), addr:$dst)]>;
1927}
1928
1929// Rotate instructions
1930// FIXME: provide shorter instructions when imm8 == 1
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001931let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00001932def ROL8rCL : I<0xD2, MRM0r, (outs GR8 :$dst), (ins GR8 :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001933 "rol{b}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001934 [(set GR8:$dst, (rotl GR8:$src, CL))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001935def ROL16rCL : I<0xD3, MRM0r, (outs GR16:$dst), (ins GR16:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001936 "rol{w}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001937 [(set GR16:$dst, (rotl GR16:$src, CL))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001938def ROL32rCL : I<0xD3, MRM0r, (outs GR32:$dst), (ins GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001939 "rol{l}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001940 [(set GR32:$dst, (rotl GR32:$src, CL))]>;
1941}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001942
Evan Chengb783fa32007-07-19 01:14:50 +00001943def ROL8ri : Ii8<0xC0, MRM0r, (outs GR8 :$dst), (ins GR8 :$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001944 "rol{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001945 [(set GR8:$dst, (rotl GR8:$src1, (i8 imm:$src2)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001946def ROL16ri : Ii8<0xC1, MRM0r, (outs GR16:$dst), (ins GR16:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001947 "rol{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001948 [(set GR16:$dst, (rotl GR16:$src1, (i8 imm:$src2)))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001949def ROL32ri : Ii8<0xC1, MRM0r, (outs GR32:$dst), (ins GR32:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001950 "rol{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001951 [(set GR32:$dst, (rotl GR32:$src1, (i8 imm:$src2)))]>;
1952
1953// Rotate by 1
Evan Chengb783fa32007-07-19 01:14:50 +00001954def ROL8r1 : I<0xD0, MRM0r, (outs GR8 :$dst), (ins GR8 :$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00001955 "rol{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001956 [(set GR8:$dst, (rotl GR8:$src1, (i8 1)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001957def ROL16r1 : I<0xD1, MRM0r, (outs GR16:$dst), (ins GR16:$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00001958 "rol{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001959 [(set GR16:$dst, (rotl GR16:$src1, (i8 1)))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001960def ROL32r1 : I<0xD1, MRM0r, (outs GR32:$dst), (ins GR32:$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00001961 "rol{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001962 [(set GR32:$dst, (rotl GR32:$src1, (i8 1)))]>;
1963
1964let isTwoAddress = 0 in {
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001965 let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00001966 def ROL8mCL : I<0xD2, MRM0m, (outs), (ins i8mem :$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001967 "rol{b}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001968 [(store (rotl (loadi8 addr:$dst), CL), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001969 def ROL16mCL : I<0xD3, MRM0m, (outs), (ins i16mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001970 "rol{w}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001971 [(store (rotl (loadi16 addr:$dst), CL), addr:$dst)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001972 def ROL32mCL : I<0xD3, MRM0m, (outs), (ins i32mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001973 "rol{l}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001974 [(store (rotl (loadi32 addr:$dst), CL), addr:$dst)]>;
1975 }
Evan Chengb783fa32007-07-19 01:14:50 +00001976 def ROL8mi : Ii8<0xC0, MRM0m, (outs), (ins i8mem :$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001977 "rol{b}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001978 [(store (rotl (loadi8 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001979 def ROL16mi : Ii8<0xC1, MRM0m, (outs), (ins i16mem:$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001980 "rol{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001981 [(store (rotl (loadi16 addr:$dst), (i8 imm:$src)), addr:$dst)]>,
1982 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001983 def ROL32mi : Ii8<0xC1, MRM0m, (outs), (ins i32mem:$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001984 "rol{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001985 [(store (rotl (loadi32 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
1986
1987 // Rotate by 1
Evan Chengb783fa32007-07-19 01:14:50 +00001988 def ROL8m1 : I<0xD0, MRM0m, (outs), (ins i8mem :$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001989 "rol{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001990 [(store (rotl (loadi8 addr:$dst), (i8 1)), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001991 def ROL16m1 : I<0xD1, MRM0m, (outs), (ins i16mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001992 "rol{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001993 [(store (rotl (loadi16 addr:$dst), (i8 1)), addr:$dst)]>,
1994 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001995 def ROL32m1 : I<0xD1, MRM0m, (outs), (ins i32mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001996 "rol{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001997 [(store (rotl (loadi32 addr:$dst), (i8 1)), addr:$dst)]>;
1998}
1999
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002000let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00002001def ROR8rCL : I<0xD2, MRM1r, (outs GR8 :$dst), (ins GR8 :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002002 "ror{b}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002003 [(set GR8:$dst, (rotr GR8:$src, CL))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002004def ROR16rCL : I<0xD3, MRM1r, (outs GR16:$dst), (ins GR16:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002005 "ror{w}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002006 [(set GR16:$dst, (rotr GR16:$src, CL))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002007def ROR32rCL : I<0xD3, MRM1r, (outs GR32:$dst), (ins GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002008 "ror{l}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002009 [(set GR32:$dst, (rotr GR32:$src, CL))]>;
2010}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002011
Evan Chengb783fa32007-07-19 01:14:50 +00002012def ROR8ri : Ii8<0xC0, MRM1r, (outs GR8 :$dst), (ins GR8 :$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002013 "ror{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002014 [(set GR8:$dst, (rotr GR8:$src1, (i8 imm:$src2)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002015def ROR16ri : Ii8<0xC1, MRM1r, (outs GR16:$dst), (ins GR16:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002016 "ror{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002017 [(set GR16:$dst, (rotr GR16:$src1, (i8 imm:$src2)))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002018def ROR32ri : Ii8<0xC1, MRM1r, (outs GR32:$dst), (ins GR32:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002019 "ror{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002020 [(set GR32:$dst, (rotr GR32:$src1, (i8 imm:$src2)))]>;
2021
2022// Rotate by 1
Evan Chengb783fa32007-07-19 01:14:50 +00002023def ROR8r1 : I<0xD0, MRM1r, (outs GR8 :$dst), (ins GR8 :$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00002024 "ror{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002025 [(set GR8:$dst, (rotr GR8:$src1, (i8 1)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002026def ROR16r1 : I<0xD1, MRM1r, (outs GR16:$dst), (ins GR16:$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00002027 "ror{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002028 [(set GR16:$dst, (rotr GR16:$src1, (i8 1)))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002029def ROR32r1 : I<0xD1, MRM1r, (outs GR32:$dst), (ins GR32:$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00002030 "ror{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002031 [(set GR32:$dst, (rotr GR32:$src1, (i8 1)))]>;
2032
2033let isTwoAddress = 0 in {
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002034 let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00002035 def ROR8mCL : I<0xD2, MRM1m, (outs), (ins i8mem :$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002036 "ror{b}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002037 [(store (rotr (loadi8 addr:$dst), CL), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002038 def ROR16mCL : I<0xD3, MRM1m, (outs), (ins i16mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002039 "ror{w}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002040 [(store (rotr (loadi16 addr:$dst), CL), addr:$dst)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002041 def ROR32mCL : I<0xD3, MRM1m, (outs), (ins i32mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002042 "ror{l}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002043 [(store (rotr (loadi32 addr:$dst), CL), addr:$dst)]>;
2044 }
Evan Chengb783fa32007-07-19 01:14:50 +00002045 def ROR8mi : Ii8<0xC0, MRM1m, (outs), (ins i8mem :$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002046 "ror{b}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002047 [(store (rotr (loadi8 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002048 def ROR16mi : Ii8<0xC1, MRM1m, (outs), (ins i16mem:$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002049 "ror{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002050 [(store (rotr (loadi16 addr:$dst), (i8 imm:$src)), addr:$dst)]>,
2051 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002052 def ROR32mi : Ii8<0xC1, MRM1m, (outs), (ins i32mem:$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002053 "ror{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002054 [(store (rotr (loadi32 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
2055
2056 // Rotate by 1
Evan Chengb783fa32007-07-19 01:14:50 +00002057 def ROR8m1 : I<0xD0, MRM1m, (outs), (ins i8mem :$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002058 "ror{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002059 [(store (rotr (loadi8 addr:$dst), (i8 1)), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002060 def ROR16m1 : I<0xD1, MRM1m, (outs), (ins i16mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002061 "ror{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002062 [(store (rotr (loadi16 addr:$dst), (i8 1)), addr:$dst)]>,
2063 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002064 def ROR32m1 : I<0xD1, MRM1m, (outs), (ins i32mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002065 "ror{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002066 [(store (rotr (loadi32 addr:$dst), (i8 1)), addr:$dst)]>;
2067}
2068
2069
2070
2071// Double shift instructions (generalizations of rotate)
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002072let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00002073def SHLD32rrCL : I<0xA5, MRMDestReg, (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002074 "shld{l}\t{%cl, $src2, $dst|$dst, $src2, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002075 [(set GR32:$dst, (X86shld GR32:$src1, GR32:$src2, CL))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00002076def SHRD32rrCL : I<0xAD, MRMDestReg, (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002077 "shrd{l}\t{%cl, $src2, $dst|$dst, $src2, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002078 [(set GR32:$dst, (X86shrd GR32:$src1, GR32:$src2, CL))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00002079def SHLD16rrCL : I<0xA5, MRMDestReg, (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002080 "shld{w}\t{%cl, $src2, $dst|$dst, $src2, %CL}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002081 [(set GR16:$dst, (X86shld GR16:$src1, GR16:$src2, CL))]>,
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002082 TB, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002083def SHRD16rrCL : I<0xAD, MRMDestReg, (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002084 "shrd{w}\t{%cl, $src2, $dst|$dst, $src2, %CL}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002085 [(set GR16:$dst, (X86shrd GR16:$src1, GR16:$src2, CL))]>,
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002086 TB, OpSize;
2087}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002088
2089let isCommutable = 1 in { // These instructions commute to each other.
2090def SHLD32rri8 : Ii8<0xA4, MRMDestReg,
Evan Chengb783fa32007-07-19 01:14:50 +00002091 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2, i8imm:$src3),
Dan Gohman91888f02007-07-31 20:11:57 +00002092 "shld{l}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002093 [(set GR32:$dst, (X86shld GR32:$src1, GR32:$src2,
2094 (i8 imm:$src3)))]>,
2095 TB;
2096def SHRD32rri8 : Ii8<0xAC, MRMDestReg,
Evan Chengb783fa32007-07-19 01:14:50 +00002097 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2, i8imm:$src3),
Dan Gohman91888f02007-07-31 20:11:57 +00002098 "shrd{l}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002099 [(set GR32:$dst, (X86shrd GR32:$src1, GR32:$src2,
2100 (i8 imm:$src3)))]>,
2101 TB;
2102def SHLD16rri8 : Ii8<0xA4, MRMDestReg,
Evan Chengb783fa32007-07-19 01:14:50 +00002103 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2, i8imm:$src3),
Dan Gohman91888f02007-07-31 20:11:57 +00002104 "shld{w}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002105 [(set GR16:$dst, (X86shld GR16:$src1, GR16:$src2,
2106 (i8 imm:$src3)))]>,
2107 TB, OpSize;
2108def SHRD16rri8 : Ii8<0xAC, MRMDestReg,
Evan Chengb783fa32007-07-19 01:14:50 +00002109 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2, i8imm:$src3),
Dan Gohman91888f02007-07-31 20:11:57 +00002110 "shrd{w}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002111 [(set GR16:$dst, (X86shrd GR16:$src1, GR16:$src2,
2112 (i8 imm:$src3)))]>,
2113 TB, OpSize;
2114}
2115
2116let isTwoAddress = 0 in {
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002117 let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00002118 def SHLD32mrCL : I<0xA5, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002119 "shld{l}\t{%cl, $src2, $dst|$dst, $src2, %CL}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002120 [(store (X86shld (loadi32 addr:$dst), GR32:$src2, CL),
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002121 addr:$dst)]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00002122 def SHRD32mrCL : I<0xAD, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002123 "shrd{l}\t{%cl, $src2, $dst|$dst, $src2, %CL}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002124 [(store (X86shrd (loadi32 addr:$dst), GR32:$src2, CL),
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002125 addr:$dst)]>, TB;
2126 }
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002127 def SHLD32mri8 : Ii8<0xA4, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00002128 (outs), (ins i32mem:$dst, GR32:$src2, i8imm:$src3),
Dan Gohman91888f02007-07-31 20:11:57 +00002129 "shld{l}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002130 [(store (X86shld (loadi32 addr:$dst), GR32:$src2,
2131 (i8 imm:$src3)), addr:$dst)]>,
2132 TB;
2133 def SHRD32mri8 : Ii8<0xAC, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00002134 (outs), (ins i32mem:$dst, GR32:$src2, i8imm:$src3),
Dan Gohman91888f02007-07-31 20:11:57 +00002135 "shrd{l}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002136 [(store (X86shrd (loadi32 addr:$dst), GR32:$src2,
2137 (i8 imm:$src3)), addr:$dst)]>,
2138 TB;
2139
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002140 let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00002141 def SHLD16mrCL : I<0xA5, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002142 "shld{w}\t{%cl, $src2, $dst|$dst, $src2, %CL}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002143 [(store (X86shld (loadi16 addr:$dst), GR16:$src2, CL),
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002144 addr:$dst)]>, TB, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002145 def SHRD16mrCL : I<0xAD, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002146 "shrd{w}\t{%cl, $src2, $dst|$dst, $src2, %CL}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002147 [(store (X86shrd (loadi16 addr:$dst), GR16:$src2, CL),
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002148 addr:$dst)]>, TB, OpSize;
2149 }
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002150 def SHLD16mri8 : Ii8<0xA4, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00002151 (outs), (ins i16mem:$dst, GR16:$src2, i8imm:$src3),
Dan Gohman91888f02007-07-31 20:11:57 +00002152 "shld{w}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002153 [(store (X86shld (loadi16 addr:$dst), GR16:$src2,
2154 (i8 imm:$src3)), addr:$dst)]>,
2155 TB, OpSize;
2156 def SHRD16mri8 : Ii8<0xAC, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00002157 (outs), (ins i16mem:$dst, GR16:$src2, i8imm:$src3),
Dan Gohman91888f02007-07-31 20:11:57 +00002158 "shrd{w}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002159 [(store (X86shrd (loadi16 addr:$dst), GR16:$src2,
2160 (i8 imm:$src3)), addr:$dst)]>,
2161 TB, OpSize;
2162}
Evan Cheng55687072007-09-14 21:48:26 +00002163} // Defs = [EFLAGS]
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002164
2165
2166// Arithmetic.
Evan Cheng55687072007-09-14 21:48:26 +00002167let Defs = [EFLAGS] in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002168let isCommutable = 1 in { // X = ADD Y, Z --> X = ADD Z, Y
Bill Wendlingae034ed2008-12-12 00:56:36 +00002169// Register-Register Addition
2170def ADD8rr : I<0x00, MRMDestReg, (outs GR8 :$dst),
2171 (ins GR8 :$src1, GR8 :$src2),
2172 "add{b}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002173 [(set GR8:$dst, (add GR8:$src1, GR8:$src2)),
Bill Wendlingae034ed2008-12-12 00:56:36 +00002174 (implicit EFLAGS)]>;
2175
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002176let isConvertibleToThreeAddress = 1 in { // Can transform into LEA.
Bill Wendlingae034ed2008-12-12 00:56:36 +00002177// Register-Register Addition
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002178def ADD16rr : I<0x01, MRMDestReg, (outs GR16:$dst),
2179 (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002180 "add{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002181 [(set GR16:$dst, (add GR16:$src1, GR16:$src2)),
2182 (implicit EFLAGS)]>, OpSize;
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002183def ADD32rr : I<0x01, MRMDestReg, (outs GR32:$dst),
2184 (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002185 "add{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002186 [(set GR32:$dst, (add GR32:$src1, GR32:$src2)),
2187 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002188} // end isConvertibleToThreeAddress
2189} // end isCommutable
Bill Wendlingae034ed2008-12-12 00:56:36 +00002190
2191// Register-Memory Addition
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002192def ADD8rm : I<0x02, MRMSrcMem, (outs GR8 :$dst),
2193 (ins GR8 :$src1, i8mem :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002194 "add{b}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002195 [(set GR8:$dst, (add GR8:$src1, (load addr:$src2))),
2196 (implicit EFLAGS)]>;
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002197def ADD16rm : I<0x03, MRMSrcMem, (outs GR16:$dst),
2198 (ins GR16:$src1, i16mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002199 "add{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002200 [(set GR16:$dst, (add GR16:$src1, (load addr:$src2))),
2201 (implicit EFLAGS)]>, OpSize;
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002202def ADD32rm : I<0x03, MRMSrcMem, (outs GR32:$dst),
2203 (ins GR32:$src1, i32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002204 "add{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002205 [(set GR32:$dst, (add GR32:$src1, (load addr:$src2))),
2206 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002207
Bill Wendlingae034ed2008-12-12 00:56:36 +00002208// Register-Integer Addition
2209def ADD8ri : Ii8<0x80, MRM0r, (outs GR8:$dst), (ins GR8:$src1, i8imm:$src2),
2210 "add{b}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002211 [(set GR8:$dst, (add GR8:$src1, imm:$src2)),
2212 (implicit EFLAGS)]>;
Bill Wendlingae034ed2008-12-12 00:56:36 +00002213
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002214let isConvertibleToThreeAddress = 1 in { // Can transform into LEA.
Bill Wendlingae034ed2008-12-12 00:56:36 +00002215// Register-Integer Addition
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002216def ADD16ri : Ii16<0x81, MRM0r, (outs GR16:$dst),
2217 (ins GR16:$src1, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002218 "add{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002219 [(set GR16:$dst, (add GR16:$src1, imm:$src2)),
2220 (implicit EFLAGS)]>, OpSize;
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002221def ADD32ri : Ii32<0x81, MRM0r, (outs GR32:$dst),
2222 (ins GR32:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002223 "add{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002224 [(set GR32:$dst, (add GR32:$src1, imm:$src2)),
2225 (implicit EFLAGS)]>;
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002226def ADD16ri8 : Ii8<0x83, MRM0r, (outs GR16:$dst),
2227 (ins GR16:$src1, i16i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002228 "add{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002229 [(set GR16:$dst, (add GR16:$src1, i16immSExt8:$src2)),
2230 (implicit EFLAGS)]>, OpSize;
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002231def ADD32ri8 : Ii8<0x83, MRM0r, (outs GR32:$dst),
2232 (ins GR32:$src1, i32i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002233 "add{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002234 [(set GR32:$dst, (add GR32:$src1, i32immSExt8:$src2)),
2235 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002236}
2237
2238let isTwoAddress = 0 in {
Bill Wendlingae034ed2008-12-12 00:56:36 +00002239 // Memory-Register Addition
Bill Wendlingf5399032008-12-12 21:15:41 +00002240 def ADD8mr : I<0x00, MRMDestMem, (outs), (ins i8mem:$dst, GR8:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002241 "add{b}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002242 [(store (add (load addr:$dst), GR8:$src2), addr:$dst),
2243 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002244 def ADD16mr : I<0x01, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002245 "add{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002246 [(store (add (load addr:$dst), GR16:$src2), addr:$dst),
2247 (implicit EFLAGS)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002248 def ADD32mr : I<0x01, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002249 "add{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002250 [(store (add (load addr:$dst), GR32:$src2), addr:$dst),
2251 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002252 def ADD8mi : Ii8<0x80, MRM0m, (outs), (ins i8mem :$dst, i8imm :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002253 "add{b}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002254 [(store (add (loadi8 addr:$dst), imm:$src2), addr:$dst),
2255 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002256 def ADD16mi : Ii16<0x81, MRM0m, (outs), (ins i16mem:$dst, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002257 "add{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002258 [(store (add (loadi16 addr:$dst), imm:$src2), addr:$dst),
2259 (implicit EFLAGS)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002260 def ADD32mi : Ii32<0x81, MRM0m, (outs), (ins i32mem:$dst, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002261 "add{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002262 [(store (add (loadi32 addr:$dst), imm:$src2), addr:$dst),
2263 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002264 def ADD16mi8 : Ii8<0x83, MRM0m, (outs), (ins i16mem:$dst, i16i8imm :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002265 "add{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002266 [(store (add (load addr:$dst), i16immSExt8:$src2),
2267 addr:$dst),
2268 (implicit EFLAGS)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002269 def ADD32mi8 : Ii8<0x83, MRM0m, (outs), (ins i32mem:$dst, i32i8imm :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002270 "add{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingae034ed2008-12-12 00:56:36 +00002271 [(store (add (load addr:$dst), i32immSExt8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00002272 addr:$dst),
2273 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002274}
2275
Evan Cheng259471d2007-10-05 17:59:57 +00002276let Uses = [EFLAGS] in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002277let isCommutable = 1 in { // X = ADC Y, Z --> X = ADC Z, Y
Dale Johannesen06b83f12009-05-18 17:44:15 +00002278def ADC8rr : I<0x10, MRMDestReg, (outs GR8:$dst), (ins GR8:$src1, GR8:$src2),
2279 "adc{b}\t{$src2, $dst|$dst, $src2}",
2280 [(set GR8:$dst, (adde GR8:$src1, GR8:$src2))]>;
2281def ADC16rr : I<0x11, MRMDestReg, (outs GR16:$dst),
2282 (ins GR16:$src1, GR16:$src2),
2283 "adc{w}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen067cfb22009-05-18 21:41:59 +00002284 [(set GR16:$dst, (adde GR16:$src1, GR16:$src2))]>, OpSize;
Dale Johannesen06b83f12009-05-18 17:44:15 +00002285def ADC32rr : I<0x11, MRMDestReg, (outs GR32:$dst),
2286 (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002287 "adc{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingc0ca7f32008-12-01 23:44:08 +00002288 [(set GR32:$dst, (adde GR32:$src1, GR32:$src2))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002289}
Dale Johannesen06b83f12009-05-18 17:44:15 +00002290def ADC8rm : I<0x12, MRMSrcMem , (outs GR8:$dst),
2291 (ins GR8:$src1, i8mem:$src2),
2292 "adc{b}\t{$src2, $dst|$dst, $src2}",
2293 [(set GR8:$dst, (adde GR8:$src1, (load addr:$src2)))]>;
2294def ADC16rm : I<0x13, MRMSrcMem , (outs GR16:$dst),
2295 (ins GR16:$src1, i16mem:$src2),
2296 "adc{w}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen067cfb22009-05-18 21:41:59 +00002297 [(set GR16:$dst, (adde GR16:$src1, (load addr:$src2)))]>,
2298 OpSize;
Dale Johannesen06b83f12009-05-18 17:44:15 +00002299def ADC32rm : I<0x13, MRMSrcMem , (outs GR32:$dst),
2300 (ins GR32:$src1, i32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002301 "adc{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingc0ca7f32008-12-01 23:44:08 +00002302 [(set GR32:$dst, (adde GR32:$src1, (load addr:$src2)))]>;
Dale Johannesen06b83f12009-05-18 17:44:15 +00002303def ADC8ri : Ii8<0x80, MRM2r, (outs GR8:$dst), (ins GR8:$src1, i8imm:$src2),
2304 "adc{b}\t{$src2, $dst|$dst, $src2}",
2305 [(set GR8:$dst, (adde GR8:$src1, imm:$src2))]>;
2306def ADC16ri : Ii16<0x81, MRM2r, (outs GR16:$dst),
2307 (ins GR16:$src1, i16imm:$src2),
2308 "adc{w}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen067cfb22009-05-18 21:41:59 +00002309 [(set GR16:$dst, (adde GR16:$src1, imm:$src2))]>, OpSize;
Dale Johannesen06b83f12009-05-18 17:44:15 +00002310def ADC16ri8 : Ii8<0x83, MRM2r, (outs GR16:$dst),
2311 (ins GR16:$src1, i16i8imm:$src2),
2312 "adc{w}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen067cfb22009-05-18 21:41:59 +00002313 [(set GR16:$dst, (adde GR16:$src1, i16immSExt8:$src2))]>,
2314 OpSize;
Dale Johannesen06b83f12009-05-18 17:44:15 +00002315def ADC32ri : Ii32<0x81, MRM2r, (outs GR32:$dst),
2316 (ins GR32:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002317 "adc{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingc0ca7f32008-12-01 23:44:08 +00002318 [(set GR32:$dst, (adde GR32:$src1, imm:$src2))]>;
Dale Johannesen06b83f12009-05-18 17:44:15 +00002319def ADC32ri8 : Ii8<0x83, MRM2r, (outs GR32:$dst),
2320 (ins GR32:$src1, i32i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002321 "adc{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingc0ca7f32008-12-01 23:44:08 +00002322 [(set GR32:$dst, (adde GR32:$src1, i32immSExt8:$src2))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002323
2324let isTwoAddress = 0 in {
Dale Johannesen06b83f12009-05-18 17:44:15 +00002325 def ADC8mr : I<0x10, MRMDestMem, (outs), (ins i8mem:$dst, GR8:$src2),
2326 "adc{b}\t{$src2, $dst|$dst, $src2}",
2327 [(store (adde (load addr:$dst), GR8:$src2), addr:$dst)]>;
2328 def ADC16mr : I<0x11, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
2329 "adc{w}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen067cfb22009-05-18 21:41:59 +00002330 [(store (adde (load addr:$dst), GR16:$src2), addr:$dst)]>,
2331 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002332 def ADC32mr : I<0x11, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002333 "adc{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingc0ca7f32008-12-01 23:44:08 +00002334 [(store (adde (load addr:$dst), GR32:$src2), addr:$dst)]>;
Dale Johannesen06b83f12009-05-18 17:44:15 +00002335 def ADC8mi : Ii8<0x80, MRM2m, (outs), (ins i8mem:$dst, i8imm:$src2),
2336 "adc{b}\t{$src2, $dst|$dst, $src2}",
2337 [(store (adde (loadi8 addr:$dst), imm:$src2), addr:$dst)]>;
2338 def ADC16mi : Ii16<0x81, MRM2m, (outs), (ins i16mem:$dst, i16imm:$src2),
2339 "adc{w}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen067cfb22009-05-18 21:41:59 +00002340 [(store (adde (loadi16 addr:$dst), imm:$src2), addr:$dst)]>,
2341 OpSize;
Dale Johannesen06b83f12009-05-18 17:44:15 +00002342 def ADC16mi8 : Ii8<0x83, MRM2m, (outs), (ins i16mem:$dst, i16i8imm :$src2),
2343 "adc{w}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen067cfb22009-05-18 21:41:59 +00002344 [(store (adde (load addr:$dst), i16immSExt8:$src2), addr:$dst)]>,
2345 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002346 def ADC32mi : Ii32<0x81, MRM2m, (outs), (ins i32mem:$dst, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002347 "adc{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingc0ca7f32008-12-01 23:44:08 +00002348 [(store (adde (loadi32 addr:$dst), imm:$src2), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002349 def ADC32mi8 : Ii8<0x83, MRM2m, (outs), (ins i32mem:$dst, i32i8imm :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002350 "adc{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendling0c52d0a2008-12-02 00:07:05 +00002351 [(store (adde (load addr:$dst), i32immSExt8:$src2), addr:$dst)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002352}
Evan Cheng259471d2007-10-05 17:59:57 +00002353} // Uses = [EFLAGS]
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002354
Bill Wendlingae034ed2008-12-12 00:56:36 +00002355// Register-Register Subtraction
2356def SUB8rr : I<0x28, MRMDestReg, (outs GR8:$dst), (ins GR8:$src1, GR8:$src2),
2357 "sub{b}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002358 [(set GR8:$dst, (sub GR8:$src1, GR8:$src2)),
2359 (implicit EFLAGS)]>;
Bill Wendlingae034ed2008-12-12 00:56:36 +00002360def SUB16rr : I<0x29, MRMDestReg, (outs GR16:$dst), (ins GR16:$src1,GR16:$src2),
2361 "sub{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002362 [(set GR16:$dst, (sub GR16:$src1, GR16:$src2)),
2363 (implicit EFLAGS)]>, OpSize;
Bill Wendlingae034ed2008-12-12 00:56:36 +00002364def SUB32rr : I<0x29, MRMDestReg, (outs GR32:$dst), (ins GR32:$src1,GR32:$src2),
2365 "sub{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002366 [(set GR32:$dst, (sub GR32:$src1, GR32:$src2)),
2367 (implicit EFLAGS)]>;
Bill Wendlingae034ed2008-12-12 00:56:36 +00002368
2369// Register-Memory Subtraction
2370def SUB8rm : I<0x2A, MRMSrcMem, (outs GR8 :$dst),
2371 (ins GR8 :$src1, i8mem :$src2),
2372 "sub{b}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002373 [(set GR8:$dst, (sub GR8:$src1, (load addr:$src2))),
2374 (implicit EFLAGS)]>;
Bill Wendlingae034ed2008-12-12 00:56:36 +00002375def SUB16rm : I<0x2B, MRMSrcMem, (outs GR16:$dst),
2376 (ins GR16:$src1, i16mem:$src2),
2377 "sub{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002378 [(set GR16:$dst, (sub GR16:$src1, (load addr:$src2))),
2379 (implicit EFLAGS)]>, OpSize;
Bill Wendlingae034ed2008-12-12 00:56:36 +00002380def SUB32rm : I<0x2B, MRMSrcMem, (outs GR32:$dst),
2381 (ins GR32:$src1, i32mem:$src2),
2382 "sub{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002383 [(set GR32:$dst, (sub GR32:$src1, (load addr:$src2))),
2384 (implicit EFLAGS)]>;
Bill Wendlingae034ed2008-12-12 00:56:36 +00002385
2386// Register-Integer Subtraction
2387def SUB8ri : Ii8 <0x80, MRM5r, (outs GR8:$dst),
2388 (ins GR8:$src1, i8imm:$src2),
2389 "sub{b}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002390 [(set GR8:$dst, (sub GR8:$src1, imm:$src2)),
2391 (implicit EFLAGS)]>;
Bill Wendlingae034ed2008-12-12 00:56:36 +00002392def SUB16ri : Ii16<0x81, MRM5r, (outs GR16:$dst),
2393 (ins GR16:$src1, i16imm:$src2),
2394 "sub{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002395 [(set GR16:$dst, (sub GR16:$src1, imm:$src2)),
2396 (implicit EFLAGS)]>, OpSize;
Bill Wendlingae034ed2008-12-12 00:56:36 +00002397def SUB32ri : Ii32<0x81, MRM5r, (outs GR32:$dst),
2398 (ins GR32:$src1, i32imm:$src2),
2399 "sub{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002400 [(set GR32:$dst, (sub GR32:$src1, imm:$src2)),
2401 (implicit EFLAGS)]>;
Bill Wendlingae034ed2008-12-12 00:56:36 +00002402def SUB16ri8 : Ii8<0x83, MRM5r, (outs GR16:$dst),
2403 (ins GR16:$src1, i16i8imm:$src2),
2404 "sub{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002405 [(set GR16:$dst, (sub GR16:$src1, i16immSExt8:$src2)),
2406 (implicit EFLAGS)]>, OpSize;
Bill Wendlingae034ed2008-12-12 00:56:36 +00002407def SUB32ri8 : Ii8<0x83, MRM5r, (outs GR32:$dst),
2408 (ins GR32:$src1, i32i8imm:$src2),
2409 "sub{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002410 [(set GR32:$dst, (sub GR32:$src1, i32immSExt8:$src2)),
2411 (implicit EFLAGS)]>;
Bill Wendlingae034ed2008-12-12 00:56:36 +00002412
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002413let isTwoAddress = 0 in {
Bill Wendlingae034ed2008-12-12 00:56:36 +00002414 // Memory-Register Subtraction
Evan Chengb783fa32007-07-19 01:14:50 +00002415 def SUB8mr : I<0x28, MRMDestMem, (outs), (ins i8mem :$dst, GR8 :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002416 "sub{b}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002417 [(store (sub (load addr:$dst), GR8:$src2), addr:$dst),
2418 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002419 def SUB16mr : I<0x29, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002420 "sub{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002421 [(store (sub (load addr:$dst), GR16:$src2), addr:$dst),
2422 (implicit EFLAGS)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002423 def SUB32mr : I<0x29, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002424 "sub{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002425 [(store (sub (load addr:$dst), GR32:$src2), addr:$dst),
2426 (implicit EFLAGS)]>;
Bill Wendlingae034ed2008-12-12 00:56:36 +00002427
2428 // Memory-Integer Subtraction
Evan Chengb783fa32007-07-19 01:14:50 +00002429 def SUB8mi : Ii8<0x80, MRM5m, (outs), (ins i8mem :$dst, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002430 "sub{b}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002431 [(store (sub (loadi8 addr:$dst), imm:$src2), addr:$dst),
2432 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002433 def SUB16mi : Ii16<0x81, MRM5m, (outs), (ins i16mem:$dst, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002434 "sub{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002435 [(store (sub (loadi16 addr:$dst), imm:$src2),addr:$dst),
2436 (implicit EFLAGS)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002437 def SUB32mi : Ii32<0x81, MRM5m, (outs), (ins i32mem:$dst, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002438 "sub{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002439 [(store (sub (loadi32 addr:$dst), imm:$src2),addr:$dst),
2440 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002441 def SUB16mi8 : Ii8<0x83, MRM5m, (outs), (ins i16mem:$dst, i16i8imm :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002442 "sub{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingae034ed2008-12-12 00:56:36 +00002443 [(store (sub (load addr:$dst), i16immSExt8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00002444 addr:$dst),
2445 (implicit EFLAGS)]>, OpSize;
Bill Wendlingae034ed2008-12-12 00:56:36 +00002446 def SUB32mi8 : Ii8<0x83, MRM5m, (outs), (ins i32mem:$dst, i32i8imm :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002447 "sub{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingae034ed2008-12-12 00:56:36 +00002448 [(store (sub (load addr:$dst), i32immSExt8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00002449 addr:$dst),
2450 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002451}
2452
Evan Cheng259471d2007-10-05 17:59:57 +00002453let Uses = [EFLAGS] in {
Dale Johannesen06b83f12009-05-18 17:44:15 +00002454def SBB8rr : I<0x18, MRMDestReg, (outs GR8:$dst),
2455 (ins GR8:$src1, GR8:$src2),
2456 "sbb{b}\t{$src2, $dst|$dst, $src2}",
2457 [(set GR8:$dst, (sube GR8:$src1, GR8:$src2))]>;
2458def SBB16rr : I<0x19, MRMDestReg, (outs GR16:$dst),
2459 (ins GR16:$src1, GR16:$src2),
2460 "sbb{w}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen067cfb22009-05-18 21:41:59 +00002461 [(set GR16:$dst, (sube GR16:$src1, GR16:$src2))]>, OpSize;
Dale Johannesen06b83f12009-05-18 17:44:15 +00002462def SBB32rr : I<0x19, MRMDestReg, (outs GR32:$dst),
2463 (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002464 "sbb{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng55687072007-09-14 21:48:26 +00002465 [(set GR32:$dst, (sube GR32:$src1, GR32:$src2))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002466
2467let isTwoAddress = 0 in {
Dale Johannesen06b83f12009-05-18 17:44:15 +00002468 def SBB8mr : I<0x18, MRMDestMem, (outs), (ins i8mem:$dst, GR8:$src2),
2469 "sbb{b}\t{$src2, $dst|$dst, $src2}",
2470 [(store (sube (load addr:$dst), GR8:$src2), addr:$dst)]>;
2471 def SBB16mr : I<0x19, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
2472 "sbb{w}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen067cfb22009-05-18 21:41:59 +00002473 [(store (sube (load addr:$dst), GR16:$src2), addr:$dst)]>,
2474 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002475 def SBB32mr : I<0x19, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002476 "sbb{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002477 [(store (sube (load addr:$dst), GR32:$src2), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002478 def SBB8mi : Ii32<0x80, MRM3m, (outs), (ins i8mem:$dst, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002479 "sbb{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002480 [(store (sube (loadi8 addr:$dst), imm:$src2), addr:$dst)]>;
Dale Johannesen06b83f12009-05-18 17:44:15 +00002481 def SBB16mi : Ii16<0x81, MRM3m, (outs), (ins i16mem:$dst, i16imm:$src2),
2482 "sbb{w}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen067cfb22009-05-18 21:41:59 +00002483 [(store (sube (loadi16 addr:$dst), imm:$src2), addr:$dst)]>,
2484 OpSize;
Dale Johannesen06b83f12009-05-18 17:44:15 +00002485 def SBB16mi8 : Ii8<0x83, MRM3m, (outs), (ins i16mem:$dst, i16i8imm :$src2),
2486 "sbb{w}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen067cfb22009-05-18 21:41:59 +00002487 [(store (sube (load addr:$dst), i16immSExt8:$src2), addr:$dst)]>,
2488 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002489 def SBB32mi : Ii32<0x81, MRM3m, (outs), (ins i32mem:$dst, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002490 "sbb{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002491 [(store (sube (loadi32 addr:$dst), imm:$src2), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002492 def SBB32mi8 : Ii8<0x83, MRM3m, (outs), (ins i32mem:$dst, i32i8imm :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002493 "sbb{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng55687072007-09-14 21:48:26 +00002494 [(store (sube (load addr:$dst), i32immSExt8:$src2), addr:$dst)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002495}
Dale Johannesen06b83f12009-05-18 17:44:15 +00002496def SBB8rm : I<0x1A, MRMSrcMem, (outs GR8:$dst), (ins GR8:$src1, i8mem:$src2),
2497 "sbb{b}\t{$src2, $dst|$dst, $src2}",
2498 [(set GR8:$dst, (sube GR8:$src1, (load addr:$src2)))]>;
2499def SBB16rm : I<0x1B, MRMSrcMem, (outs GR16:$dst),
2500 (ins GR16:$src1, i16mem:$src2),
2501 "sbb{w}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen067cfb22009-05-18 21:41:59 +00002502 [(set GR16:$dst, (sube GR16:$src1, (load addr:$src2)))]>,
2503 OpSize;
Dale Johannesen06b83f12009-05-18 17:44:15 +00002504def SBB32rm : I<0x1B, MRMSrcMem, (outs GR32:$dst),
2505 (ins GR32:$src1, i32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002506 "sbb{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002507 [(set GR32:$dst, (sube GR32:$src1, (load addr:$src2)))]>;
Dale Johannesen06b83f12009-05-18 17:44:15 +00002508def SBB8ri : Ii8<0x80, MRM3r, (outs GR8:$dst), (ins GR8:$src1, i8imm:$src2),
2509 "sbb{b}\t{$src2, $dst|$dst, $src2}",
2510 [(set GR8:$dst, (sube GR8:$src1, imm:$src2))]>;
2511def SBB16ri : Ii16<0x81, MRM3r, (outs GR16:$dst),
2512 (ins GR16:$src1, i16imm:$src2),
2513 "sbb{w}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen067cfb22009-05-18 21:41:59 +00002514 [(set GR16:$dst, (sube GR16:$src1, imm:$src2))]>, OpSize;
Dale Johannesen06b83f12009-05-18 17:44:15 +00002515def SBB16ri8 : Ii8<0x83, MRM3r, (outs GR16:$dst),
2516 (ins GR16:$src1, i16i8imm:$src2),
2517 "sbb{w}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen067cfb22009-05-18 21:41:59 +00002518 [(set GR16:$dst, (sube GR16:$src1, i16immSExt8:$src2))]>,
2519 OpSize;
Dale Johannesen06b83f12009-05-18 17:44:15 +00002520def SBB32ri : Ii32<0x81, MRM3r, (outs GR32:$dst),
2521 (ins GR32:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002522 "sbb{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002523 [(set GR32:$dst, (sube GR32:$src1, imm:$src2))]>;
Dale Johannesen06b83f12009-05-18 17:44:15 +00002524def SBB32ri8 : Ii8<0x83, MRM3r, (outs GR32:$dst),
2525 (ins GR32:$src1, i32i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002526 "sbb{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002527 [(set GR32:$dst, (sube GR32:$src1, i32immSExt8:$src2))]>;
Evan Cheng259471d2007-10-05 17:59:57 +00002528} // Uses = [EFLAGS]
Evan Cheng55687072007-09-14 21:48:26 +00002529} // Defs = [EFLAGS]
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002530
Evan Cheng55687072007-09-14 21:48:26 +00002531let Defs = [EFLAGS] in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002532let isCommutable = 1 in { // X = IMUL Y, Z --> X = IMUL Z, Y
Bill Wendlingf5399032008-12-12 21:15:41 +00002533// Register-Register Signed Integer Multiply
Bill Wendlingae034ed2008-12-12 00:56:36 +00002534def IMUL16rr : I<0xAF, MRMSrcReg, (outs GR16:$dst), (ins GR16:$src1,GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002535 "imul{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002536 [(set GR16:$dst, (mul GR16:$src1, GR16:$src2)),
2537 (implicit EFLAGS)]>, TB, OpSize;
Bill Wendlingae034ed2008-12-12 00:56:36 +00002538def IMUL32rr : I<0xAF, MRMSrcReg, (outs GR32:$dst), (ins GR32:$src1,GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002539 "imul{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002540 [(set GR32:$dst, (mul GR32:$src1, GR32:$src2)),
2541 (implicit EFLAGS)]>, TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002542}
Bill Wendlingae034ed2008-12-12 00:56:36 +00002543
Bill Wendlingf5399032008-12-12 21:15:41 +00002544// Register-Memory Signed Integer Multiply
Bill Wendlingae034ed2008-12-12 00:56:36 +00002545def IMUL16rm : I<0xAF, MRMSrcMem, (outs GR16:$dst),
2546 (ins GR16:$src1, i16mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002547 "imul{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002548 [(set GR16:$dst, (mul GR16:$src1, (load addr:$src2))),
2549 (implicit EFLAGS)]>, TB, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002550def IMUL32rm : I<0xAF, MRMSrcMem, (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002551 "imul{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002552 [(set GR32:$dst, (mul GR32:$src1, (load addr:$src2))),
2553 (implicit EFLAGS)]>, TB;
Evan Cheng55687072007-09-14 21:48:26 +00002554} // Defs = [EFLAGS]
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002555} // end Two Address instructions
2556
2557// Suprisingly enough, these are not two address instructions!
Evan Cheng55687072007-09-14 21:48:26 +00002558let Defs = [EFLAGS] in {
Bill Wendlingf5399032008-12-12 21:15:41 +00002559// Register-Integer Signed Integer Multiply
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002560def IMUL16rri : Ii16<0x69, MRMSrcReg, // GR16 = GR16*I16
Evan Chengb783fa32007-07-19 01:14:50 +00002561 (outs GR16:$dst), (ins GR16:$src1, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002562 "imul{w}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002563 [(set GR16:$dst, (mul GR16:$src1, imm:$src2)),
2564 (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002565def IMUL32rri : Ii32<0x69, MRMSrcReg, // GR32 = GR32*I32
Evan Chengb783fa32007-07-19 01:14:50 +00002566 (outs GR32:$dst), (ins GR32:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002567 "imul{l}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002568 [(set GR32:$dst, (mul GR32:$src1, imm:$src2)),
2569 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002570def IMUL16rri8 : Ii8<0x6B, MRMSrcReg, // GR16 = GR16*I8
Evan Chengb783fa32007-07-19 01:14:50 +00002571 (outs GR16:$dst), (ins GR16:$src1, i16i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002572 "imul{w}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002573 [(set GR16:$dst, (mul GR16:$src1, i16immSExt8:$src2)),
2574 (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002575def IMUL32rri8 : Ii8<0x6B, MRMSrcReg, // GR32 = GR32*I8
Evan Chengb783fa32007-07-19 01:14:50 +00002576 (outs GR32:$dst), (ins GR32:$src1, i32i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002577 "imul{l}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002578 [(set GR32:$dst, (mul GR32:$src1, i32immSExt8:$src2)),
2579 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002580
Bill Wendlingf5399032008-12-12 21:15:41 +00002581// Memory-Integer Signed Integer Multiply
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002582def IMUL16rmi : Ii16<0x69, MRMSrcMem, // GR16 = [mem16]*I16
Evan Chengb783fa32007-07-19 01:14:50 +00002583 (outs GR16:$dst), (ins i16mem:$src1, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002584 "imul{w}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002585 [(set GR16:$dst, (mul (load addr:$src1), imm:$src2)),
2586 (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002587def IMUL32rmi : Ii32<0x69, MRMSrcMem, // GR32 = [mem32]*I32
Evan Chengb783fa32007-07-19 01:14:50 +00002588 (outs GR32:$dst), (ins i32mem:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002589 "imul{l}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002590 [(set GR32:$dst, (mul (load addr:$src1), imm:$src2)),
2591 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002592def IMUL16rmi8 : Ii8<0x6B, MRMSrcMem, // GR16 = [mem16]*I8
Evan Chengb783fa32007-07-19 01:14:50 +00002593 (outs GR16:$dst), (ins i16mem:$src1, i16i8imm :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002594 "imul{w}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Bill Wendlingae034ed2008-12-12 00:56:36 +00002595 [(set GR16:$dst, (mul (load addr:$src1),
Bill Wendlingf5399032008-12-12 21:15:41 +00002596 i16immSExt8:$src2)),
2597 (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002598def IMUL32rmi8 : Ii8<0x6B, MRMSrcMem, // GR32 = [mem32]*I8
Evan Chengb783fa32007-07-19 01:14:50 +00002599 (outs GR32:$dst), (ins i32mem:$src1, i32i8imm: $src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002600 "imul{l}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Bill Wendlingae034ed2008-12-12 00:56:36 +00002601 [(set GR32:$dst, (mul (load addr:$src1),
Bill Wendlingf5399032008-12-12 21:15:41 +00002602 i32immSExt8:$src2)),
2603 (implicit EFLAGS)]>;
Evan Cheng55687072007-09-14 21:48:26 +00002604} // Defs = [EFLAGS]
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002605
2606//===----------------------------------------------------------------------===//
2607// Test instructions are just like AND, except they don't generate a result.
2608//
Evan Cheng950aac02007-09-25 01:57:46 +00002609let Defs = [EFLAGS] in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002610let isCommutable = 1 in { // TEST X, Y --> TEST Y, X
Evan Chengb783fa32007-07-19 01:14:50 +00002611def TEST8rr : I<0x84, MRMDestReg, (outs), (ins GR8:$src1, GR8:$src2),
Evan Cheng621216e2007-09-29 00:00:36 +00002612 "test{b}\t{$src2, $src1|$src1, $src2}",
Chris Lattner21da6382008-02-19 17:37:35 +00002613 [(X86cmp (and_su GR8:$src1, GR8:$src2), 0),
Evan Cheng621216e2007-09-29 00:00:36 +00002614 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002615def TEST16rr : I<0x85, MRMDestReg, (outs), (ins GR16:$src1, GR16:$src2),
Evan Cheng621216e2007-09-29 00:00:36 +00002616 "test{w}\t{$src2, $src1|$src1, $src2}",
Chris Lattner21da6382008-02-19 17:37:35 +00002617 [(X86cmp (and_su GR16:$src1, GR16:$src2), 0),
Evan Cheng621216e2007-09-29 00:00:36 +00002618 (implicit EFLAGS)]>,
2619 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002620def TEST32rr : I<0x85, MRMDestReg, (outs), (ins GR32:$src1, GR32:$src2),
Evan Cheng621216e2007-09-29 00:00:36 +00002621 "test{l}\t{$src2, $src1|$src1, $src2}",
Chris Lattner21da6382008-02-19 17:37:35 +00002622 [(X86cmp (and_su GR32:$src1, GR32:$src2), 0),
Evan Cheng621216e2007-09-29 00:00:36 +00002623 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002624}
2625
Evan Chengb783fa32007-07-19 01:14:50 +00002626def TEST8rm : I<0x84, MRMSrcMem, (outs), (ins GR8 :$src1, i8mem :$src2),
Evan Cheng621216e2007-09-29 00:00:36 +00002627 "test{b}\t{$src2, $src1|$src1, $src2}",
2628 [(X86cmp (and GR8:$src1, (loadi8 addr:$src2)), 0),
2629 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002630def TEST16rm : I<0x85, MRMSrcMem, (outs), (ins GR16:$src1, i16mem:$src2),
Evan Cheng621216e2007-09-29 00:00:36 +00002631 "test{w}\t{$src2, $src1|$src1, $src2}",
2632 [(X86cmp (and GR16:$src1, (loadi16 addr:$src2)), 0),
2633 (implicit EFLAGS)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002634def TEST32rm : I<0x85, MRMSrcMem, (outs), (ins GR32:$src1, i32mem:$src2),
Evan Cheng621216e2007-09-29 00:00:36 +00002635 "test{l}\t{$src2, $src1|$src1, $src2}",
2636 [(X86cmp (and GR32:$src1, (loadi32 addr:$src2)), 0),
2637 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002638
2639def TEST8ri : Ii8 <0xF6, MRM0r, // flags = GR8 & imm8
Evan Chengb783fa32007-07-19 01:14:50 +00002640 (outs), (ins GR8:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002641 "test{b}\t{$src2, $src1|$src1, $src2}",
Chris Lattner21da6382008-02-19 17:37:35 +00002642 [(X86cmp (and_su GR8:$src1, imm:$src2), 0),
Evan Cheng621216e2007-09-29 00:00:36 +00002643 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002644def TEST16ri : Ii16<0xF7, MRM0r, // flags = GR16 & imm16
Evan Chengb783fa32007-07-19 01:14:50 +00002645 (outs), (ins GR16:$src1, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002646 "test{w}\t{$src2, $src1|$src1, $src2}",
Chris Lattner21da6382008-02-19 17:37:35 +00002647 [(X86cmp (and_su GR16:$src1, imm:$src2), 0),
Evan Cheng621216e2007-09-29 00:00:36 +00002648 (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002649def TEST32ri : Ii32<0xF7, MRM0r, // flags = GR32 & imm32
Evan Chengb783fa32007-07-19 01:14:50 +00002650 (outs), (ins GR32:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002651 "test{l}\t{$src2, $src1|$src1, $src2}",
Chris Lattner21da6382008-02-19 17:37:35 +00002652 [(X86cmp (and_su GR32:$src1, imm:$src2), 0),
Evan Cheng621216e2007-09-29 00:00:36 +00002653 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002654
Evan Cheng621216e2007-09-29 00:00:36 +00002655def TEST8mi : Ii8 <0xF6, MRM0m, // flags = [mem8] & imm8
Evan Chengb783fa32007-07-19 01:14:50 +00002656 (outs), (ins i8mem:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002657 "test{b}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002658 [(X86cmp (and (loadi8 addr:$src1), imm:$src2), 0),
2659 (implicit EFLAGS)]>;
2660def TEST16mi : Ii16<0xF7, MRM0m, // flags = [mem16] & imm16
Evan Chengb783fa32007-07-19 01:14:50 +00002661 (outs), (ins i16mem:$src1, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002662 "test{w}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002663 [(X86cmp (and (loadi16 addr:$src1), imm:$src2), 0),
2664 (implicit EFLAGS)]>, OpSize;
2665def TEST32mi : Ii32<0xF7, MRM0m, // flags = [mem32] & imm32
Evan Chengb783fa32007-07-19 01:14:50 +00002666 (outs), (ins i32mem:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002667 "test{l}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002668 [(X86cmp (and (loadi32 addr:$src1), imm:$src2), 0),
Evan Cheng950aac02007-09-25 01:57:46 +00002669 (implicit EFLAGS)]>;
2670} // Defs = [EFLAGS]
2671
2672
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002673// Condition code ops, incl. set if equal/not equal/...
Chris Lattnerc90ee9c2008-01-10 07:59:24 +00002674let Defs = [EFLAGS], Uses = [AH], neverHasSideEffects = 1 in
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002675def SAHF : I<0x9E, RawFrm, (outs), (ins), "sahf", []>; // flags = AH
Chris Lattnerc90ee9c2008-01-10 07:59:24 +00002676let Defs = [AH], Uses = [EFLAGS], neverHasSideEffects = 1 in
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002677def LAHF : I<0x9F, RawFrm, (outs), (ins), "lahf", []>; // AH = flags
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002678
Evan Cheng950aac02007-09-25 01:57:46 +00002679let Uses = [EFLAGS] in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002680def SETEr : I<0x94, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00002681 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002682 "sete\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002683 [(set GR8:$dst, (X86setcc X86_COND_E, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002684 TB; // GR8 = ==
2685def SETEm : I<0x94, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00002686 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002687 "sete\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002688 [(store (X86setcc X86_COND_E, 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 SETNEr : I<0x95, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00002692 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002693 "setne\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002694 [(set GR8:$dst, (X86setcc X86_COND_NE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002695 TB; // GR8 = !=
2696def SETNEm : I<0x95, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00002697 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002698 "setne\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002699 [(store (X86setcc X86_COND_NE, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002700 TB; // [mem8] = !=
Bill Wendling0c52d0a2008-12-02 00:07:05 +00002701
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002702def SETLr : I<0x9C, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00002703 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002704 "setl\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002705 [(set GR8:$dst, (X86setcc X86_COND_L, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002706 TB; // GR8 = < signed
2707def SETLm : I<0x9C, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00002708 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002709 "setl\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002710 [(store (X86setcc X86_COND_L, 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 SETGEr : I<0x9D, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00002714 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002715 "setge\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002716 [(set GR8:$dst, (X86setcc X86_COND_GE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002717 TB; // GR8 = >= signed
2718def SETGEm : I<0x9D, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00002719 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002720 "setge\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002721 [(store (X86setcc X86_COND_GE, 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 SETLEr : I<0x9E, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00002725 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002726 "setle\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002727 [(set GR8:$dst, (X86setcc X86_COND_LE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002728 TB; // GR8 = <= signed
2729def SETLEm : I<0x9E, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00002730 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002731 "setle\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002732 [(store (X86setcc X86_COND_LE, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002733 TB; // [mem8] = <= signed
Bill Wendling0c52d0a2008-12-02 00:07:05 +00002734
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002735def SETGr : I<0x9F, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00002736 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002737 "setg\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002738 [(set GR8:$dst, (X86setcc X86_COND_G, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002739 TB; // GR8 = > signed
2740def SETGm : I<0x9F, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00002741 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002742 "setg\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002743 [(store (X86setcc X86_COND_G, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002744 TB; // [mem8] = > signed
2745
2746def SETBr : I<0x92, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00002747 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002748 "setb\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002749 [(set GR8:$dst, (X86setcc X86_COND_B, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002750 TB; // GR8 = < unsign
2751def SETBm : I<0x92, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00002752 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002753 "setb\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002754 [(store (X86setcc X86_COND_B, 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 SETAEr : I<0x93, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00002758 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002759 "setae\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002760 [(set GR8:$dst, (X86setcc X86_COND_AE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002761 TB; // GR8 = >= unsign
2762def SETAEm : I<0x93, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00002763 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002764 "setae\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002765 [(store (X86setcc X86_COND_AE, 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 SETBEr : I<0x96, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00002769 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002770 "setbe\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002771 [(set GR8:$dst, (X86setcc X86_COND_BE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002772 TB; // GR8 = <= unsign
2773def SETBEm : I<0x96, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00002774 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002775 "setbe\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002776 [(store (X86setcc X86_COND_BE, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002777 TB; // [mem8] = <= unsign
Bill Wendling0c52d0a2008-12-02 00:07:05 +00002778
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002779def SETAr : I<0x97, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00002780 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002781 "seta\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002782 [(set GR8:$dst, (X86setcc X86_COND_A, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002783 TB; // GR8 = > signed
2784def SETAm : I<0x97, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00002785 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002786 "seta\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002787 [(store (X86setcc X86_COND_A, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002788 TB; // [mem8] = > signed
2789
2790def SETSr : I<0x98, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00002791 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002792 "sets\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002793 [(set GR8:$dst, (X86setcc X86_COND_S, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002794 TB; // GR8 = <sign bit>
2795def SETSm : I<0x98, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00002796 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002797 "sets\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002798 [(store (X86setcc X86_COND_S, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002799 TB; // [mem8] = <sign bit>
2800def SETNSr : I<0x99, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00002801 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002802 "setns\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002803 [(set GR8:$dst, (X86setcc X86_COND_NS, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002804 TB; // GR8 = !<sign bit>
2805def SETNSm : I<0x99, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00002806 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002807 "setns\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002808 [(store (X86setcc X86_COND_NS, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002809 TB; // [mem8] = !<sign bit>
Bill Wendling0c52d0a2008-12-02 00:07:05 +00002810
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002811def SETPr : I<0x9A, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00002812 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002813 "setp\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002814 [(set GR8:$dst, (X86setcc X86_COND_P, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002815 TB; // GR8 = parity
2816def SETPm : I<0x9A, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00002817 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002818 "setp\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002819 [(store (X86setcc X86_COND_P, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002820 TB; // [mem8] = parity
2821def SETNPr : I<0x9B, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00002822 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002823 "setnp\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002824 [(set GR8:$dst, (X86setcc X86_COND_NP, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002825 TB; // GR8 = not parity
2826def SETNPm : I<0x9B, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00002827 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002828 "setnp\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002829 [(store (X86setcc X86_COND_NP, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002830 TB; // [mem8] = not parity
Bill Wendling0c52d0a2008-12-02 00:07:05 +00002831
2832def SETOr : I<0x90, MRM0r,
2833 (outs GR8 :$dst), (ins),
2834 "seto\t$dst",
2835 [(set GR8:$dst, (X86setcc X86_COND_O, EFLAGS))]>,
2836 TB; // GR8 = overflow
2837def SETOm : I<0x90, MRM0m,
2838 (outs), (ins i8mem:$dst),
2839 "seto\t$dst",
2840 [(store (X86setcc X86_COND_O, EFLAGS), addr:$dst)]>,
2841 TB; // [mem8] = overflow
2842def SETNOr : I<0x91, MRM0r,
2843 (outs GR8 :$dst), (ins),
2844 "setno\t$dst",
2845 [(set GR8:$dst, (X86setcc X86_COND_NO, EFLAGS))]>,
2846 TB; // GR8 = not overflow
2847def SETNOm : I<0x91, MRM0m,
2848 (outs), (ins i8mem:$dst),
2849 "setno\t$dst",
2850 [(store (X86setcc X86_COND_NO, EFLAGS), addr:$dst)]>,
2851 TB; // [mem8] = not overflow
Evan Cheng950aac02007-09-25 01:57:46 +00002852} // Uses = [EFLAGS]
2853
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002854
2855// Integer comparisons
Evan Cheng55687072007-09-14 21:48:26 +00002856let Defs = [EFLAGS] in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002857def CMP8rr : I<0x38, MRMDestReg,
Evan Chengb783fa32007-07-19 01:14:50 +00002858 (outs), (ins GR8 :$src1, GR8 :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002859 "cmp{b}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002860 [(X86cmp GR8:$src1, GR8:$src2), (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002861def CMP16rr : I<0x39, MRMDestReg,
Evan Chengb783fa32007-07-19 01:14:50 +00002862 (outs), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002863 "cmp{w}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002864 [(X86cmp GR16:$src1, GR16:$src2), (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002865def CMP32rr : I<0x39, MRMDestReg,
Evan Chengb783fa32007-07-19 01:14:50 +00002866 (outs), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002867 "cmp{l}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002868 [(X86cmp GR32:$src1, GR32:$src2), (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002869def CMP8mr : I<0x38, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00002870 (outs), (ins i8mem :$src1, GR8 :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002871 "cmp{b}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002872 [(X86cmp (loadi8 addr:$src1), GR8:$src2),
2873 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002874def CMP16mr : I<0x39, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00002875 (outs), (ins i16mem:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002876 "cmp{w}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002877 [(X86cmp (loadi16 addr:$src1), GR16:$src2),
2878 (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002879def CMP32mr : I<0x39, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00002880 (outs), (ins i32mem:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002881 "cmp{l}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002882 [(X86cmp (loadi32 addr:$src1), GR32:$src2),
2883 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002884def CMP8rm : I<0x3A, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00002885 (outs), (ins GR8 :$src1, i8mem :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002886 "cmp{b}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002887 [(X86cmp GR8:$src1, (loadi8 addr:$src2)),
2888 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002889def CMP16rm : I<0x3B, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00002890 (outs), (ins GR16:$src1, i16mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002891 "cmp{w}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002892 [(X86cmp GR16:$src1, (loadi16 addr:$src2)),
2893 (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002894def CMP32rm : I<0x3B, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00002895 (outs), (ins GR32:$src1, i32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002896 "cmp{l}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002897 [(X86cmp GR32:$src1, (loadi32 addr:$src2)),
2898 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002899def CMP8ri : Ii8<0x80, MRM7r,
Evan Chengb783fa32007-07-19 01:14:50 +00002900 (outs), (ins GR8:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002901 "cmp{b}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002902 [(X86cmp GR8:$src1, imm:$src2), (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002903def CMP16ri : Ii16<0x81, MRM7r,
Evan Chengb783fa32007-07-19 01:14:50 +00002904 (outs), (ins GR16:$src1, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002905 "cmp{w}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002906 [(X86cmp GR16:$src1, imm:$src2),
2907 (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002908def CMP32ri : Ii32<0x81, MRM7r,
Evan Chengb783fa32007-07-19 01:14:50 +00002909 (outs), (ins GR32:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002910 "cmp{l}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002911 [(X86cmp GR32:$src1, imm:$src2), (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002912def CMP8mi : Ii8 <0x80, MRM7m,
Evan Chengb783fa32007-07-19 01:14:50 +00002913 (outs), (ins i8mem :$src1, i8imm :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002914 "cmp{b}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002915 [(X86cmp (loadi8 addr:$src1), imm:$src2),
2916 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002917def CMP16mi : Ii16<0x81, MRM7m,
Evan Chengb783fa32007-07-19 01:14:50 +00002918 (outs), (ins i16mem:$src1, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002919 "cmp{w}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002920 [(X86cmp (loadi16 addr:$src1), imm:$src2),
2921 (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002922def CMP32mi : Ii32<0x81, MRM7m,
Evan Chengb783fa32007-07-19 01:14:50 +00002923 (outs), (ins i32mem:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002924 "cmp{l}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002925 [(X86cmp (loadi32 addr:$src1), imm:$src2),
2926 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002927def CMP16ri8 : Ii8<0x83, MRM7r,
Evan Chengb783fa32007-07-19 01:14:50 +00002928 (outs), (ins GR16:$src1, i16i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002929 "cmp{w}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002930 [(X86cmp GR16:$src1, i16immSExt8:$src2),
2931 (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002932def CMP16mi8 : Ii8<0x83, MRM7m,
Evan Chengb783fa32007-07-19 01:14:50 +00002933 (outs), (ins i16mem:$src1, i16i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002934 "cmp{w}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002935 [(X86cmp (loadi16 addr:$src1), i16immSExt8:$src2),
2936 (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002937def CMP32mi8 : Ii8<0x83, MRM7m,
Evan Chengb783fa32007-07-19 01:14:50 +00002938 (outs), (ins i32mem:$src1, i32i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002939 "cmp{l}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002940 [(X86cmp (loadi32 addr:$src1), i32immSExt8:$src2),
2941 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002942def CMP32ri8 : Ii8<0x83, MRM7r,
Evan Chengb783fa32007-07-19 01:14:50 +00002943 (outs), (ins GR32:$src1, i32i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002944 "cmp{l}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002945 [(X86cmp GR32:$src1, i32immSExt8:$src2),
Evan Cheng950aac02007-09-25 01:57:46 +00002946 (implicit EFLAGS)]>;
2947} // Defs = [EFLAGS]
2948
Dan Gohman7fe9b7f2008-12-23 22:45:23 +00002949// Bit tests.
Dan Gohman7fe9b7f2008-12-23 22:45:23 +00002950// TODO: BTC, BTR, and BTS
2951let Defs = [EFLAGS] in {
Dan Gohmanfc4eddb2009-01-13 20:32:45 +00002952def BT16rr : I<0xA3, MRMDestReg, (outs), (ins GR16:$src1, GR16:$src2),
Dan Gohman7fe9b7f2008-12-23 22:45:23 +00002953 "bt{w}\t{$src2, $src1|$src1, $src2}",
2954 [(X86bt GR16:$src1, GR16:$src2),
Chris Lattner5a95cde2008-12-25 01:32:49 +00002955 (implicit EFLAGS)]>, OpSize, TB;
Dan Gohmanfc4eddb2009-01-13 20:32:45 +00002956def BT32rr : I<0xA3, MRMDestReg, (outs), (ins GR32:$src1, GR32:$src2),
Dan Gohman7fe9b7f2008-12-23 22:45:23 +00002957 "bt{l}\t{$src2, $src1|$src1, $src2}",
2958 [(X86bt GR32:$src1, GR32:$src2),
Chris Lattner5a95cde2008-12-25 01:32:49 +00002959 (implicit EFLAGS)]>, TB;
Dan Gohman85a228c2009-01-13 23:23:30 +00002960
2961// Unlike with the register+register form, the memory+register form of the
2962// bt instruction does not ignore the high bits of the index. From ISel's
2963// perspective, this is pretty bizarre. Disable these instructions for now.
2964//def BT16mr : I<0xA3, MRMDestMem, (outs), (ins i16mem:$src1, GR16:$src2),
2965// "bt{w}\t{$src2, $src1|$src1, $src2}",
2966// [(X86bt (loadi16 addr:$src1), GR16:$src2),
2967// (implicit EFLAGS)]>, OpSize, TB, Requires<[FastBTMem]>;
2968//def BT32mr : I<0xA3, MRMDestMem, (outs), (ins i32mem:$src1, GR32:$src2),
2969// "bt{l}\t{$src2, $src1|$src1, $src2}",
2970// [(X86bt (loadi32 addr:$src1), GR32:$src2),
2971// (implicit EFLAGS)]>, TB, Requires<[FastBTMem]>;
Dan Gohman46fb1cf2009-01-13 20:33:23 +00002972
2973def BT16ri8 : Ii8<0xBA, MRM4r, (outs), (ins GR16:$src1, i16i8imm:$src2),
2974 "bt{w}\t{$src2, $src1|$src1, $src2}",
2975 [(X86bt GR16:$src1, i16immSExt8:$src2),
2976 (implicit EFLAGS)]>, OpSize, TB;
2977def BT32ri8 : Ii8<0xBA, MRM4r, (outs), (ins GR32:$src1, i32i8imm:$src2),
2978 "bt{l}\t{$src2, $src1|$src1, $src2}",
2979 [(X86bt GR32:$src1, i32immSExt8:$src2),
2980 (implicit EFLAGS)]>, TB;
2981// Note that these instructions don't need FastBTMem because that
2982// only applies when the other operand is in a register. When it's
2983// an immediate, bt is still fast.
2984def BT16mi8 : Ii8<0xBA, MRM4m, (outs), (ins i16mem:$src1, i16i8imm:$src2),
2985 "bt{w}\t{$src2, $src1|$src1, $src2}",
2986 [(X86bt (loadi16 addr:$src1), i16immSExt8:$src2),
2987 (implicit EFLAGS)]>, OpSize, TB;
2988def BT32mi8 : Ii8<0xBA, MRM4m, (outs), (ins i32mem:$src1, i32i8imm:$src2),
2989 "bt{l}\t{$src2, $src1|$src1, $src2}",
2990 [(X86bt (loadi32 addr:$src1), i32immSExt8:$src2),
2991 (implicit EFLAGS)]>, TB;
Dan Gohman7fe9b7f2008-12-23 22:45:23 +00002992} // Defs = [EFLAGS]
2993
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002994// Sign/Zero extenders
Dan Gohman9203ab42008-07-30 18:09:17 +00002995// Use movsbl intead of movsbw; we don't care about the high 16 bits
2996// of the register here. This has a smaller encoding and avoids a
2997// partial-register update.
Evan Chengb783fa32007-07-19 01:14:50 +00002998def MOVSX16rr8 : I<0xBE, MRMSrcReg, (outs GR16:$dst), (ins GR8 :$src),
Dan Gohman9203ab42008-07-30 18:09:17 +00002999 "movs{bl|x}\t{$src, ${dst:subreg32}|${dst:subreg32}, $src}",
3000 [(set GR16:$dst, (sext GR8:$src))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00003001def MOVSX16rm8 : I<0xBE, MRMSrcMem, (outs GR16:$dst), (ins i8mem :$src),
Dan Gohman9203ab42008-07-30 18:09:17 +00003002 "movs{bl|x}\t{$src, ${dst:subreg32}|${dst:subreg32}, $src}",
3003 [(set GR16:$dst, (sextloadi16i8 addr:$src))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00003004def MOVSX32rr8 : I<0xBE, MRMSrcReg, (outs GR32:$dst), (ins GR8 :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00003005 "movs{bl|x}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003006 [(set GR32:$dst, (sext GR8:$src))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00003007def MOVSX32rm8 : I<0xBE, MRMSrcMem, (outs GR32:$dst), (ins i8mem :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00003008 "movs{bl|x}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003009 [(set GR32:$dst, (sextloadi32i8 addr:$src))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00003010def MOVSX32rr16: I<0xBF, MRMSrcReg, (outs GR32:$dst), (ins GR16:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00003011 "movs{wl|x}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003012 [(set GR32:$dst, (sext GR16:$src))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00003013def MOVSX32rm16: I<0xBF, MRMSrcMem, (outs GR32:$dst), (ins i16mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00003014 "movs{wl|x}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003015 [(set GR32:$dst, (sextloadi32i16 addr:$src))]>, TB;
3016
Dan Gohman9203ab42008-07-30 18:09:17 +00003017// Use movzbl intead of movzbw; we don't care about the high 16 bits
3018// of the register here. This has a smaller encoding and avoids a
3019// partial-register update.
Evan Chengb783fa32007-07-19 01:14:50 +00003020def MOVZX16rr8 : I<0xB6, MRMSrcReg, (outs GR16:$dst), (ins GR8 :$src),
Dan Gohman9203ab42008-07-30 18:09:17 +00003021 "movz{bl|x}\t{$src, ${dst:subreg32}|${dst:subreg32}, $src}",
3022 [(set GR16:$dst, (zext GR8:$src))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00003023def MOVZX16rm8 : I<0xB6, MRMSrcMem, (outs GR16:$dst), (ins i8mem :$src),
Dan Gohman9203ab42008-07-30 18:09:17 +00003024 "movz{bl|x}\t{$src, ${dst:subreg32}|${dst:subreg32}, $src}",
3025 [(set GR16:$dst, (zextloadi16i8 addr:$src))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00003026def MOVZX32rr8 : I<0xB6, MRMSrcReg, (outs GR32:$dst), (ins GR8 :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00003027 "movz{bl|x}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003028 [(set GR32:$dst, (zext GR8:$src))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00003029def MOVZX32rm8 : I<0xB6, MRMSrcMem, (outs GR32:$dst), (ins i8mem :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00003030 "movz{bl|x}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003031 [(set GR32:$dst, (zextloadi32i8 addr:$src))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00003032def MOVZX32rr16: I<0xB7, MRMSrcReg, (outs GR32:$dst), (ins GR16:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00003033 "movz{wl|x}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003034 [(set GR32:$dst, (zext GR16:$src))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00003035def MOVZX32rm16: I<0xB7, MRMSrcMem, (outs GR32:$dst), (ins i16mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00003036 "movz{wl|x}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003037 [(set GR32:$dst, (zextloadi32i16 addr:$src))]>, TB;
3038
Dan Gohman744d4622009-04-13 16:09:41 +00003039// These are the same as the regular regular MOVZX32rr8 and MOVZX32rm8
3040// except that they use GR32_NOREX for the output operand register class
3041// instead of GR32. This allows them to operate on h registers on x86-64.
3042def MOVZX32_NOREXrr8 : I<0xB6, MRMSrcReg,
3043 (outs GR32_NOREX:$dst), (ins GR8:$src),
3044 "movz{bl|x}\t{$src, $dst|$dst, $src} # NOREX",
3045 []>, TB;
Dan Gohman89f4cda2009-04-30 03:11:48 +00003046let mayLoad = 1 in
Dan Gohman744d4622009-04-13 16:09:41 +00003047def MOVZX32_NOREXrm8 : I<0xB6, MRMSrcMem,
3048 (outs GR32_NOREX:$dst), (ins i8mem:$src),
3049 "movz{bl|x}\t{$src, $dst|$dst, $src} # NOREX",
3050 []>, TB;
3051
Chris Lattnerc90ee9c2008-01-10 07:59:24 +00003052let neverHasSideEffects = 1 in {
3053 let Defs = [AX], Uses = [AL] in
3054 def CBW : I<0x98, RawFrm, (outs), (ins),
3055 "{cbtw|cbw}", []>, OpSize; // AX = signext(AL)
3056 let Defs = [EAX], Uses = [AX] in
3057 def CWDE : I<0x98, RawFrm, (outs), (ins),
3058 "{cwtl|cwde}", []>; // EAX = signext(AX)
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003059
Chris Lattnerc90ee9c2008-01-10 07:59:24 +00003060 let Defs = [AX,DX], Uses = [AX] in
3061 def CWD : I<0x99, RawFrm, (outs), (ins),
3062 "{cwtd|cwd}", []>, OpSize; // DX:AX = signext(AX)
3063 let Defs = [EAX,EDX], Uses = [EAX] in
3064 def CDQ : I<0x99, RawFrm, (outs), (ins),
3065 "{cltd|cdq}", []>; // EDX:EAX = signext(EAX)
3066}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003067
3068//===----------------------------------------------------------------------===//
3069// Alias Instructions
3070//===----------------------------------------------------------------------===//
3071
3072// Alias instructions that map movr0 to xor.
3073// FIXME: remove when we can teach regalloc that xor reg, reg is ok.
Bill Wendlingba5d5b02008-05-29 01:02:09 +00003074let Defs = [EFLAGS], isReMaterializable = 1, isAsCheapAsAMove = 1 in {
Evan Chengb783fa32007-07-19 01:14:50 +00003075def MOV8r0 : I<0x30, MRMInitReg, (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00003076 "xor{b}\t$dst, $dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003077 [(set GR8:$dst, 0)]>;
Dan Gohman9203ab42008-07-30 18:09:17 +00003078// Use xorl instead of xorw since we don't care about the high 16 bits,
3079// it's smaller, and it avoids a partial-register update.
Evan Chengb783fa32007-07-19 01:14:50 +00003080def MOV16r0 : I<0x31, MRMInitReg, (outs GR16:$dst), (ins),
Dan Gohman9203ab42008-07-30 18:09:17 +00003081 "xor{l}\t${dst:subreg32}, ${dst:subreg32}",
3082 [(set GR16:$dst, 0)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00003083def MOV32r0 : I<0x31, MRMInitReg, (outs GR32:$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00003084 "xor{l}\t$dst, $dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003085 [(set GR32:$dst, 0)]>;
Dan Gohman8aef09b2007-09-07 21:32:51 +00003086}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003087
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003088//===----------------------------------------------------------------------===//
3089// Thread Local Storage Instructions
3090//
3091
Rafael Espindola7fc4b8d2009-04-24 12:59:40 +00003092// All calls clobber the non-callee saved registers. ESP is marked as
3093// a use to prevent stack-pointer assignments that appear immediately
3094// before calls from potentially appearing dead.
3095let Defs = [EAX, ECX, EDX, FP0, FP1, FP2, FP3, FP4, FP5, FP6, ST0,
3096 MM0, MM1, MM2, MM3, MM4, MM5, MM6, MM7,
3097 XMM0, XMM1, XMM2, XMM3, XMM4, XMM5, XMM6, XMM7,
3098 XMM8, XMM9, XMM10, XMM11, XMM12, XMM13, XMM14, XMM15, EFLAGS],
3099 Uses = [ESP, EBX] in
Rafael Espindolaaf759ab2009-04-17 14:35:58 +00003100def TLS_addr32 : I<0, Pseudo, (outs), (ins i32imm:$sym),
Dan Gohman70a8a112009-04-27 15:13:28 +00003101 "leal\t${sym:mem}(,%ebx,1), %eax; "
3102 "call\t___tls_get_addr@PLT",
Rafael Espindolaaf759ab2009-04-17 14:35:58 +00003103 [(X86tlsaddr tglobaltlsaddr:$sym)]>,
3104 Requires<[In32BitMode]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003105
sampo9cc09a32009-01-26 01:24:32 +00003106let AddedComplexity = 5 in
3107def GS_MOV32rm : I<0x8B, MRMSrcMem, (outs GR32:$dst), (ins i32mem:$src),
3108 "movl\t%gs:$src, $dst",
3109 [(set GR32:$dst, (gsload addr:$src))]>, SegGS;
3110
Chris Lattnera7c2d8a2009-05-05 18:52:19 +00003111let AddedComplexity = 5 in
3112def FS_MOV32rm : I<0x8B, MRMSrcMem, (outs GR32:$dst), (ins i32mem:$src),
3113 "movl\t%fs:$src, $dst",
3114 [(set GR32:$dst, (fsload addr:$src))]>, SegFS;
3115
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003116//===----------------------------------------------------------------------===//
3117// DWARF Pseudo Instructions
3118//
3119
Evan Chengb783fa32007-07-19 01:14:50 +00003120def DWARF_LOC : I<0, Pseudo, (outs),
3121 (ins i32imm:$line, i32imm:$col, i32imm:$file),
Dan Gohman77af4a82007-09-24 19:25:06 +00003122 ".loc\t${file:debug} ${line:debug} ${col:debug}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003123 [(dwarf_loc (i32 imm:$line), (i32 imm:$col),
3124 (i32 imm:$file))]>;
3125
3126//===----------------------------------------------------------------------===//
3127// EH Pseudo Instructions
3128//
3129let isTerminator = 1, isReturn = 1, isBarrier = 1,
Evan Cheng37e7c752007-07-21 00:34:19 +00003130 hasCtrlDep = 1 in {
Evan Chengb783fa32007-07-19 01:14:50 +00003131def EH_RETURN : I<0xC3, RawFrm, (outs), (ins GR32:$addr),
Dan Gohman91888f02007-07-31 20:11:57 +00003132 "ret\t#eh_return, addr: $addr",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003133 [(X86ehret GR32:$addr)]>;
3134
3135}
3136
3137//===----------------------------------------------------------------------===//
Andrew Lenharthe44f3902008-02-21 06:45:13 +00003138// Atomic support
3139//
Andrew Lenharth7a5a4b22008-03-01 13:37:02 +00003140
Evan Cheng3e171562008-04-19 01:20:30 +00003141// Atomic swap. These are just normal xchg instructions. But since a memory
3142// operand is referenced, the atomicity is ensured.
Dan Gohmana41a1c092008-08-06 15:52:50 +00003143let Constraints = "$val = $dst" in {
Evan Cheng3e171562008-04-19 01:20:30 +00003144def XCHG32rm : I<0x87, MRMSrcMem, (outs GR32:$dst), (ins i32mem:$ptr, GR32:$val),
3145 "xchg{l}\t{$val, $ptr|$ptr, $val}",
3146 [(set GR32:$dst, (atomic_swap_32 addr:$ptr, GR32:$val))]>;
3147def XCHG16rm : I<0x87, MRMSrcMem, (outs GR16:$dst), (ins i16mem:$ptr, GR16:$val),
3148 "xchg{w}\t{$val, $ptr|$ptr, $val}",
3149 [(set GR16:$dst, (atomic_swap_16 addr:$ptr, GR16:$val))]>,
3150 OpSize;
3151def XCHG8rm : I<0x86, MRMSrcMem, (outs GR8:$dst), (ins i8mem:$ptr, GR8:$val),
3152 "xchg{b}\t{$val, $ptr|$ptr, $val}",
3153 [(set GR8:$dst, (atomic_swap_8 addr:$ptr, GR8:$val))]>;
3154}
3155
Evan Chengd49dbb82008-04-18 20:55:36 +00003156// Atomic compare and swap.
Andrew Lenharth7dfe23f2008-03-01 21:52:34 +00003157let Defs = [EAX, EFLAGS], Uses = [EAX] in {
Evan Chengd49dbb82008-04-18 20:55:36 +00003158def LCMPXCHG32 : I<0xB1, MRMDestMem, (outs), (ins i32mem:$ptr, GR32:$swap),
Dan Gohman70a8a112009-04-27 15:13:28 +00003159 "lock\n\t"
3160 "cmpxchg{l}\t{$swap, $ptr|$ptr, $swap}",
Evan Cheng09fbdee2008-03-04 03:20:06 +00003161 [(X86cas addr:$ptr, GR32:$swap, 4)]>, TB, LOCK;
Andrew Lenharth7a5a4b22008-03-01 13:37:02 +00003162}
Dale Johannesenf160d802008-10-02 18:53:47 +00003163let Defs = [EAX, EDX, EFLAGS], Uses = [EAX, EBX, ECX, EDX] in {
Anton Korobeynikovc4067392008-07-22 16:22:48 +00003164def LCMPXCHG8B : I<0xC7, MRM1m, (outs), (ins i32mem:$ptr),
Dan Gohman70a8a112009-04-27 15:13:28 +00003165 "lock\n\t"
3166 "cmpxchg8b\t$ptr",
Andrew Lenharth81580822008-03-05 01:15:49 +00003167 [(X86cas8 addr:$ptr)]>, TB, LOCK;
3168}
Andrew Lenharth7dfe23f2008-03-01 21:52:34 +00003169
3170let Defs = [AX, EFLAGS], Uses = [AX] in {
Evan Chengd49dbb82008-04-18 20:55:36 +00003171def LCMPXCHG16 : I<0xB1, MRMDestMem, (outs), (ins i16mem:$ptr, GR16:$swap),
Dan Gohman70a8a112009-04-27 15:13:28 +00003172 "lock\n\t"
3173 "cmpxchg{w}\t{$swap, $ptr|$ptr, $swap}",
Evan Cheng09fbdee2008-03-04 03:20:06 +00003174 [(X86cas addr:$ptr, GR16:$swap, 2)]>, TB, OpSize, LOCK;
Andrew Lenharth7a5a4b22008-03-01 13:37:02 +00003175}
Andrew Lenharth7dfe23f2008-03-01 21:52:34 +00003176let Defs = [AL, EFLAGS], Uses = [AL] in {
Evan Chengd49dbb82008-04-18 20:55:36 +00003177def LCMPXCHG8 : I<0xB0, MRMDestMem, (outs), (ins i8mem:$ptr, GR8:$swap),
Dan Gohman70a8a112009-04-27 15:13:28 +00003178 "lock\n\t"
3179 "cmpxchg{b}\t{$swap, $ptr|$ptr, $swap}",
Evan Cheng09fbdee2008-03-04 03:20:06 +00003180 [(X86cas addr:$ptr, GR8:$swap, 1)]>, TB, LOCK;
Andrew Lenharth7a5a4b22008-03-01 13:37:02 +00003181}
3182
Evan Chengd49dbb82008-04-18 20:55:36 +00003183// Atomic exchange and add
3184let Constraints = "$val = $dst", Defs = [EFLAGS] in {
3185def LXADD32 : I<0xC1, MRMSrcMem, (outs GR32:$dst), (ins i32mem:$ptr, GR32:$val),
Dan Gohman70a8a112009-04-27 15:13:28 +00003186 "lock\n\t"
3187 "xadd{l}\t{$val, $ptr|$ptr, $val}",
Mon P Wang6bde9ec2008-06-25 08:15:39 +00003188 [(set GR32:$dst, (atomic_load_add_32 addr:$ptr, GR32:$val))]>,
Evan Chengd49dbb82008-04-18 20:55:36 +00003189 TB, LOCK;
3190def LXADD16 : I<0xC1, MRMSrcMem, (outs GR16:$dst), (ins i16mem:$ptr, GR16:$val),
Dan Gohman70a8a112009-04-27 15:13:28 +00003191 "lock\n\t"
3192 "xadd{w}\t{$val, $ptr|$ptr, $val}",
Mon P Wang6bde9ec2008-06-25 08:15:39 +00003193 [(set GR16:$dst, (atomic_load_add_16 addr:$ptr, GR16:$val))]>,
Evan Chengd49dbb82008-04-18 20:55:36 +00003194 TB, OpSize, LOCK;
3195def LXADD8 : I<0xC0, MRMSrcMem, (outs GR8:$dst), (ins i8mem:$ptr, GR8:$val),
Dan Gohman70a8a112009-04-27 15:13:28 +00003196 "lock\n\t"
3197 "xadd{b}\t{$val, $ptr|$ptr, $val}",
Mon P Wang6bde9ec2008-06-25 08:15:39 +00003198 [(set GR8:$dst, (atomic_load_add_8 addr:$ptr, GR8:$val))]>,
Evan Chengd49dbb82008-04-18 20:55:36 +00003199 TB, LOCK;
Andrew Lenharth7a5a4b22008-03-01 13:37:02 +00003200}
3201
Mon P Wang6bde9ec2008-06-25 08:15:39 +00003202// Atomic exchange, and, or, xor
Mon P Wang078a62d2008-05-05 19:05:59 +00003203let Constraints = "$val = $dst", Defs = [EFLAGS],
3204 usesCustomDAGSchedInserter = 1 in {
Dan Gohman8aeb61f2008-05-12 20:22:45 +00003205def ATOMAND32 : I<0, Pseudo, (outs GR32:$dst),(ins i32mem:$ptr, GR32:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003206 "#ATOMAND32 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003207 [(set GR32:$dst, (atomic_load_and_32 addr:$ptr, GR32:$val))]>;
Dan Gohman8aeb61f2008-05-12 20:22:45 +00003208def ATOMOR32 : I<0, Pseudo, (outs GR32:$dst),(ins i32mem:$ptr, GR32:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003209 "#ATOMOR32 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003210 [(set GR32:$dst, (atomic_load_or_32 addr:$ptr, GR32:$val))]>;
Dan Gohman8aeb61f2008-05-12 20:22:45 +00003211def ATOMXOR32 : I<0, Pseudo,(outs GR32:$dst),(ins i32mem:$ptr, GR32:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003212 "#ATOMXOR32 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003213 [(set GR32:$dst, (atomic_load_xor_32 addr:$ptr, GR32:$val))]>;
Andrew Lenharthaf02d592008-06-14 05:48:15 +00003214def ATOMNAND32 : I<0, Pseudo,(outs GR32:$dst),(ins i32mem:$ptr, GR32:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003215 "#ATOMNAND32 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003216 [(set GR32:$dst, (atomic_load_nand_32 addr:$ptr, GR32:$val))]>;
Dan Gohman8aeb61f2008-05-12 20:22:45 +00003217def ATOMMIN32: I<0, Pseudo, (outs GR32:$dst), (ins i32mem:$ptr, GR32:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003218 "#ATOMMIN32 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003219 [(set GR32:$dst, (atomic_load_min_32 addr:$ptr, GR32:$val))]>;
Dan Gohman8aeb61f2008-05-12 20:22:45 +00003220def ATOMMAX32: I<0, Pseudo, (outs GR32:$dst),(ins i32mem:$ptr, GR32:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003221 "#ATOMMAX32 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003222 [(set GR32:$dst, (atomic_load_max_32 addr:$ptr, GR32:$val))]>;
Dan Gohman8aeb61f2008-05-12 20:22:45 +00003223def ATOMUMIN32: I<0, Pseudo, (outs GR32:$dst),(ins i32mem:$ptr, GR32:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003224 "#ATOMUMIN32 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003225 [(set GR32:$dst, (atomic_load_umin_32 addr:$ptr, GR32:$val))]>;
Dan Gohman8aeb61f2008-05-12 20:22:45 +00003226def ATOMUMAX32: I<0, Pseudo, (outs GR32:$dst),(ins i32mem:$ptr, GR32:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003227 "#ATOMUMAX32 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003228 [(set GR32:$dst, (atomic_load_umax_32 addr:$ptr, GR32:$val))]>;
Dale Johannesend20e4452008-08-19 18:47:28 +00003229
3230def ATOMAND16 : I<0, Pseudo, (outs GR16:$dst),(ins i16mem:$ptr, GR16:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003231 "#ATOMAND16 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003232 [(set GR16:$dst, (atomic_load_and_16 addr:$ptr, GR16:$val))]>;
Dale Johannesend20e4452008-08-19 18:47:28 +00003233def ATOMOR16 : I<0, Pseudo, (outs GR16:$dst),(ins i16mem:$ptr, GR16:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003234 "#ATOMOR16 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003235 [(set GR16:$dst, (atomic_load_or_16 addr:$ptr, GR16:$val))]>;
Dale Johannesend20e4452008-08-19 18:47:28 +00003236def ATOMXOR16 : I<0, Pseudo,(outs GR16:$dst),(ins i16mem:$ptr, GR16:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003237 "#ATOMXOR16 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003238 [(set GR16:$dst, (atomic_load_xor_16 addr:$ptr, GR16:$val))]>;
Dale Johannesend20e4452008-08-19 18:47:28 +00003239def ATOMNAND16 : I<0, Pseudo,(outs GR16:$dst),(ins i16mem:$ptr, GR16:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003240 "#ATOMNAND16 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003241 [(set GR16:$dst, (atomic_load_nand_16 addr:$ptr, GR16:$val))]>;
Dale Johannesend20e4452008-08-19 18:47:28 +00003242def ATOMMIN16: I<0, Pseudo, (outs GR16:$dst), (ins i16mem:$ptr, GR16:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003243 "#ATOMMIN16 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003244 [(set GR16:$dst, (atomic_load_min_16 addr:$ptr, GR16:$val))]>;
Dale Johannesend20e4452008-08-19 18:47:28 +00003245def ATOMMAX16: I<0, Pseudo, (outs GR16:$dst),(ins i16mem:$ptr, GR16:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003246 "#ATOMMAX16 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003247 [(set GR16:$dst, (atomic_load_max_16 addr:$ptr, GR16:$val))]>;
Dale Johannesend20e4452008-08-19 18:47:28 +00003248def ATOMUMIN16: I<0, Pseudo, (outs GR16:$dst),(ins i16mem:$ptr, GR16:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003249 "#ATOMUMIN16 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003250 [(set GR16:$dst, (atomic_load_umin_16 addr:$ptr, GR16:$val))]>;
Dale Johannesend20e4452008-08-19 18:47:28 +00003251def ATOMUMAX16: I<0, Pseudo, (outs GR16:$dst),(ins i16mem:$ptr, GR16:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003252 "#ATOMUMAX16 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003253 [(set GR16:$dst, (atomic_load_umax_16 addr:$ptr, GR16:$val))]>;
Dale Johannesend20e4452008-08-19 18:47:28 +00003254
3255def ATOMAND8 : I<0, Pseudo, (outs GR8:$dst),(ins i8mem:$ptr, GR8:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003256 "#ATOMAND8 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003257 [(set GR8:$dst, (atomic_load_and_8 addr:$ptr, GR8:$val))]>;
Dale Johannesend20e4452008-08-19 18:47:28 +00003258def ATOMOR8 : I<0, Pseudo, (outs GR8:$dst),(ins i8mem:$ptr, GR8:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003259 "#ATOMOR8 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003260 [(set GR8:$dst, (atomic_load_or_8 addr:$ptr, GR8:$val))]>;
Dale Johannesend20e4452008-08-19 18:47:28 +00003261def ATOMXOR8 : I<0, Pseudo,(outs GR8:$dst),(ins i8mem:$ptr, GR8:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003262 "#ATOMXOR8 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003263 [(set GR8:$dst, (atomic_load_xor_8 addr:$ptr, GR8:$val))]>;
Dale Johannesend20e4452008-08-19 18:47:28 +00003264def ATOMNAND8 : I<0, Pseudo,(outs GR8:$dst),(ins i8mem:$ptr, GR8:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003265 "#ATOMNAND8 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003266 [(set GR8:$dst, (atomic_load_nand_8 addr:$ptr, GR8:$val))]>;
Mon P Wang078a62d2008-05-05 19:05:59 +00003267}
3268
Dale Johannesenf160d802008-10-02 18:53:47 +00003269let Constraints = "$val1 = $dst1, $val2 = $dst2",
3270 Defs = [EFLAGS, EAX, EBX, ECX, EDX],
3271 Uses = [EAX, EBX, ECX, EDX],
Dale Johannesen44eb5372008-10-03 19:41:08 +00003272 mayLoad = 1, mayStore = 1,
Dale Johannesenf160d802008-10-02 18:53:47 +00003273 usesCustomDAGSchedInserter = 1 in {
3274def ATOMAND6432 : I<0, Pseudo, (outs GR32:$dst1, GR32:$dst2),
3275 (ins i64mem:$ptr, GR32:$val1, GR32:$val2),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003276 "#ATOMAND6432 PSEUDO!", []>;
Dale Johannesenf160d802008-10-02 18:53:47 +00003277def ATOMOR6432 : I<0, Pseudo, (outs GR32:$dst1, GR32:$dst2),
3278 (ins i64mem:$ptr, GR32:$val1, GR32:$val2),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003279 "#ATOMOR6432 PSEUDO!", []>;
Dale Johannesenf160d802008-10-02 18:53:47 +00003280def ATOMXOR6432 : I<0, Pseudo, (outs GR32:$dst1, GR32:$dst2),
3281 (ins i64mem:$ptr, GR32:$val1, GR32:$val2),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003282 "#ATOMXOR6432 PSEUDO!", []>;
Dale Johannesenf160d802008-10-02 18:53:47 +00003283def ATOMNAND6432 : I<0, Pseudo, (outs GR32:$dst1, GR32:$dst2),
3284 (ins i64mem:$ptr, GR32:$val1, GR32:$val2),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003285 "#ATOMNAND6432 PSEUDO!", []>;
Dale Johannesenf160d802008-10-02 18:53:47 +00003286def ATOMADD6432 : I<0, Pseudo, (outs GR32:$dst1, GR32:$dst2),
3287 (ins i64mem:$ptr, GR32:$val1, GR32:$val2),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003288 "#ATOMADD6432 PSEUDO!", []>;
Dale Johannesenf160d802008-10-02 18:53:47 +00003289def ATOMSUB6432 : I<0, Pseudo, (outs GR32:$dst1, GR32:$dst2),
3290 (ins i64mem:$ptr, GR32:$val1, GR32:$val2),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003291 "#ATOMSUB6432 PSEUDO!", []>;
Dale Johannesen51c58ee2008-10-03 22:25:52 +00003292def ATOMSWAP6432 : I<0, Pseudo, (outs GR32:$dst1, GR32:$dst2),
3293 (ins i64mem:$ptr, GR32:$val1, GR32:$val2),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003294 "#ATOMSWAP6432 PSEUDO!", []>;
Dale Johannesenf160d802008-10-02 18:53:47 +00003295}
3296
Andrew Lenharthe44f3902008-02-21 06:45:13 +00003297//===----------------------------------------------------------------------===//
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003298// Non-Instruction Patterns
3299//===----------------------------------------------------------------------===//
3300
Bill Wendlingfef06052008-09-16 21:48:12 +00003301// ConstantPool GlobalAddress, ExternalSymbol, and JumpTable
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003302def : Pat<(i32 (X86Wrapper tconstpool :$dst)), (MOV32ri tconstpool :$dst)>;
3303def : Pat<(i32 (X86Wrapper tjumptable :$dst)), (MOV32ri tjumptable :$dst)>;
Nate Begemanb52948972008-04-12 00:47:57 +00003304def : Pat<(i32 (X86Wrapper tglobaltlsaddr:$dst)),(MOV32ri tglobaltlsaddr:$dst)>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003305def : Pat<(i32 (X86Wrapper tglobaladdr :$dst)), (MOV32ri tglobaladdr :$dst)>;
3306def : Pat<(i32 (X86Wrapper texternalsym:$dst)), (MOV32ri texternalsym:$dst)>;
3307
3308def : Pat<(add GR32:$src1, (X86Wrapper tconstpool:$src2)),
3309 (ADD32ri GR32:$src1, tconstpool:$src2)>;
3310def : Pat<(add GR32:$src1, (X86Wrapper tjumptable:$src2)),
3311 (ADD32ri GR32:$src1, tjumptable:$src2)>;
3312def : Pat<(add GR32:$src1, (X86Wrapper tglobaladdr :$src2)),
3313 (ADD32ri GR32:$src1, tglobaladdr:$src2)>;
3314def : Pat<(add GR32:$src1, (X86Wrapper texternalsym:$src2)),
3315 (ADD32ri GR32:$src1, texternalsym:$src2)>;
3316
3317def : Pat<(store (i32 (X86Wrapper tglobaladdr:$src)), addr:$dst),
3318 (MOV32mi addr:$dst, tglobaladdr:$src)>;
3319def : Pat<(store (i32 (X86Wrapper texternalsym:$src)), addr:$dst),
3320 (MOV32mi addr:$dst, texternalsym:$src)>;
3321
3322// Calls
Arnold Schwaighofere2d6bbb2007-10-11 19:40:01 +00003323// tailcall stuff
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003324def : Pat<(X86tailcall GR32:$dst),
Arnold Schwaighofere2d6bbb2007-10-11 19:40:01 +00003325 (TAILCALL)>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003326
3327def : Pat<(X86tailcall (i32 tglobaladdr:$dst)),
Arnold Schwaighofere2d6bbb2007-10-11 19:40:01 +00003328 (TAILCALL)>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003329def : Pat<(X86tailcall (i32 texternalsym:$dst)),
Arnold Schwaighofere2d6bbb2007-10-11 19:40:01 +00003330 (TAILCALL)>;
3331
3332def : Pat<(X86tcret GR32:$dst, imm:$off),
3333 (TCRETURNri GR32:$dst, imm:$off)>;
3334
3335def : Pat<(X86tcret (i32 tglobaladdr:$dst), imm:$off),
3336 (TCRETURNdi texternalsym:$dst, imm:$off)>;
3337
3338def : Pat<(X86tcret (i32 texternalsym:$dst), imm:$off),
3339 (TCRETURNdi texternalsym:$dst, imm:$off)>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003340
3341def : Pat<(X86call (i32 tglobaladdr:$dst)),
3342 (CALLpcrel32 tglobaladdr:$dst)>;
3343def : Pat<(X86call (i32 texternalsym:$dst)),
3344 (CALLpcrel32 texternalsym:$dst)>;
3345
3346// X86 specific add which produces a flag.
3347def : Pat<(addc GR32:$src1, GR32:$src2),
3348 (ADD32rr GR32:$src1, GR32:$src2)>;
3349def : Pat<(addc GR32:$src1, (load addr:$src2)),
3350 (ADD32rm GR32:$src1, addr:$src2)>;
3351def : Pat<(addc GR32:$src1, imm:$src2),
3352 (ADD32ri GR32:$src1, imm:$src2)>;
3353def : Pat<(addc GR32:$src1, i32immSExt8:$src2),
3354 (ADD32ri8 GR32:$src1, i32immSExt8:$src2)>;
3355
3356def : Pat<(subc GR32:$src1, GR32:$src2),
3357 (SUB32rr GR32:$src1, GR32:$src2)>;
3358def : Pat<(subc GR32:$src1, (load addr:$src2)),
3359 (SUB32rm GR32:$src1, addr:$src2)>;
3360def : Pat<(subc GR32:$src1, imm:$src2),
3361 (SUB32ri GR32:$src1, imm:$src2)>;
3362def : Pat<(subc GR32:$src1, i32immSExt8:$src2),
3363 (SUB32ri8 GR32:$src1, i32immSExt8:$src2)>;
3364
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003365// Comparisons.
3366
3367// TEST R,R is smaller than CMP R,0
Evan Cheng621216e2007-09-29 00:00:36 +00003368def : Pat<(parallel (X86cmp GR8:$src1, 0), (implicit EFLAGS)),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003369 (TEST8rr GR8:$src1, GR8:$src1)>;
Evan Cheng621216e2007-09-29 00:00:36 +00003370def : Pat<(parallel (X86cmp GR16:$src1, 0), (implicit EFLAGS)),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003371 (TEST16rr GR16:$src1, GR16:$src1)>;
Evan Cheng621216e2007-09-29 00:00:36 +00003372def : Pat<(parallel (X86cmp GR32:$src1, 0), (implicit EFLAGS)),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003373 (TEST32rr GR32:$src1, GR32:$src1)>;
3374
Dan Gohman0a3c5222009-01-07 01:00:24 +00003375// Conditional moves with folded loads with operands swapped and conditions
3376// inverted.
3377def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_B, EFLAGS),
3378 (CMOVAE16rm GR16:$src2, addr:$src1)>;
3379def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_B, EFLAGS),
3380 (CMOVAE32rm GR32:$src2, addr:$src1)>;
3381def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_AE, EFLAGS),
3382 (CMOVB16rm GR16:$src2, addr:$src1)>;
3383def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_AE, EFLAGS),
3384 (CMOVB32rm GR32:$src2, addr:$src1)>;
3385def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_E, EFLAGS),
3386 (CMOVNE16rm GR16:$src2, addr:$src1)>;
3387def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_E, EFLAGS),
3388 (CMOVNE32rm GR32:$src2, addr:$src1)>;
3389def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_NE, EFLAGS),
3390 (CMOVE16rm GR16:$src2, addr:$src1)>;
3391def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_NE, EFLAGS),
3392 (CMOVE32rm GR32:$src2, addr:$src1)>;
3393def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_BE, EFLAGS),
3394 (CMOVA16rm GR16:$src2, addr:$src1)>;
3395def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_BE, EFLAGS),
3396 (CMOVA32rm GR32:$src2, addr:$src1)>;
3397def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_A, EFLAGS),
3398 (CMOVBE16rm GR16:$src2, addr:$src1)>;
3399def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_A, EFLAGS),
3400 (CMOVBE32rm GR32:$src2, addr:$src1)>;
3401def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_L, EFLAGS),
3402 (CMOVGE16rm GR16:$src2, addr:$src1)>;
3403def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_L, EFLAGS),
3404 (CMOVGE32rm GR32:$src2, addr:$src1)>;
3405def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_GE, EFLAGS),
3406 (CMOVL16rm GR16:$src2, addr:$src1)>;
3407def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_GE, EFLAGS),
3408 (CMOVL32rm GR32:$src2, addr:$src1)>;
3409def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_LE, EFLAGS),
3410 (CMOVG16rm GR16:$src2, addr:$src1)>;
3411def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_LE, EFLAGS),
3412 (CMOVG32rm GR32:$src2, addr:$src1)>;
3413def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_G, EFLAGS),
3414 (CMOVLE16rm GR16:$src2, addr:$src1)>;
3415def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_G, EFLAGS),
3416 (CMOVLE32rm GR32:$src2, addr:$src1)>;
3417def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_P, EFLAGS),
3418 (CMOVNP16rm GR16:$src2, addr:$src1)>;
3419def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_P, EFLAGS),
3420 (CMOVNP32rm GR32:$src2, addr:$src1)>;
3421def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_NP, EFLAGS),
3422 (CMOVP16rm GR16:$src2, addr:$src1)>;
3423def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_NP, EFLAGS),
3424 (CMOVP32rm GR32:$src2, addr:$src1)>;
3425def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_S, EFLAGS),
3426 (CMOVNS16rm GR16:$src2, addr:$src1)>;
3427def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_S, EFLAGS),
3428 (CMOVNS32rm GR32:$src2, addr:$src1)>;
3429def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_NS, EFLAGS),
3430 (CMOVS16rm GR16:$src2, addr:$src1)>;
3431def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_NS, EFLAGS),
3432 (CMOVS32rm GR32:$src2, addr:$src1)>;
3433def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_O, EFLAGS),
3434 (CMOVNO16rm GR16:$src2, addr:$src1)>;
3435def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_O, EFLAGS),
3436 (CMOVNO32rm GR32:$src2, addr:$src1)>;
3437def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_NO, EFLAGS),
3438 (CMOVO16rm GR16:$src2, addr:$src1)>;
3439def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_NO, EFLAGS),
3440 (CMOVO32rm GR32:$src2, addr:$src1)>;
3441
Duncan Sands082524c2008-01-23 20:39:46 +00003442// zextload bool -> zextload byte
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003443def : Pat<(zextloadi8i1 addr:$src), (MOV8rm addr:$src)>;
3444def : Pat<(zextloadi16i1 addr:$src), (MOVZX16rm8 addr:$src)>;
3445def : Pat<(zextloadi32i1 addr:$src), (MOVZX32rm8 addr:$src)>;
3446
3447// extload bool -> extload byte
3448def : Pat<(extloadi8i1 addr:$src), (MOV8rm addr:$src)>;
Bill Wendlingce1c5c12008-08-22 20:51:05 +00003449def : Pat<(extloadi16i1 addr:$src), (MOVZX16rm8 addr:$src)>,
3450 Requires<[In32BitMode]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003451def : Pat<(extloadi32i1 addr:$src), (MOVZX32rm8 addr:$src)>;
Bill Wendlingce1c5c12008-08-22 20:51:05 +00003452def : Pat<(extloadi16i8 addr:$src), (MOVZX16rm8 addr:$src)>,
3453 Requires<[In32BitMode]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003454def : Pat<(extloadi32i8 addr:$src), (MOVZX32rm8 addr:$src)>;
3455def : Pat<(extloadi32i16 addr:$src), (MOVZX32rm16 addr:$src)>;
3456
Dan Gohmandd612bb2008-08-20 21:27:32 +00003457// anyext
Bill Wendlingce1c5c12008-08-22 20:51:05 +00003458def : Pat<(i16 (anyext GR8 :$src)), (MOVZX16rr8 GR8 :$src)>,
3459 Requires<[In32BitMode]>;
3460def : Pat<(i32 (anyext GR8 :$src)), (MOVZX32rr8 GR8 :$src)>,
3461 Requires<[In32BitMode]>;
Dan Gohmandd612bb2008-08-20 21:27:32 +00003462def : Pat<(i32 (anyext GR16:$src)),
3463 (INSERT_SUBREG (i32 (IMPLICIT_DEF)), GR16:$src, x86_subreg_16bit)>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003464
Evan Chengf2abee72007-12-13 00:43:27 +00003465// (and (i32 load), 255) -> (zextload i8)
Evan Cheng1e5e5452008-09-29 17:26:18 +00003466def : Pat<(i32 (and (nvloadi32 addr:$src), (i32 255))),
3467 (MOVZX32rm8 addr:$src)>;
3468def : Pat<(i32 (and (nvloadi32 addr:$src), (i32 65535))),
3469 (MOVZX32rm16 addr:$src)>;
Evan Chengf2abee72007-12-13 00:43:27 +00003470
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003471//===----------------------------------------------------------------------===//
3472// Some peepholes
3473//===----------------------------------------------------------------------===//
3474
Dan Gohman5a5e6e92008-10-17 01:33:43 +00003475// Odd encoding trick: -128 fits into an 8-bit immediate field while
3476// +128 doesn't, so in this special case use a sub instead of an add.
3477def : Pat<(add GR16:$src1, 128),
3478 (SUB16ri8 GR16:$src1, -128)>;
3479def : Pat<(store (add (loadi16 addr:$dst), 128), addr:$dst),
3480 (SUB16mi8 addr:$dst, -128)>;
3481def : Pat<(add GR32:$src1, 128),
3482 (SUB32ri8 GR32:$src1, -128)>;
3483def : Pat<(store (add (loadi32 addr:$dst), 128), addr:$dst),
3484 (SUB32mi8 addr:$dst, -128)>;
3485
Dan Gohman9203ab42008-07-30 18:09:17 +00003486// r & (2^16-1) ==> movz
3487def : Pat<(and GR32:$src1, 0xffff),
Dan Gohman744d4622009-04-13 16:09:41 +00003488 (MOVZX32rr16 (EXTRACT_SUBREG GR32:$src1, x86_subreg_16bit))>;
Dan Gohman5beb1ff2008-08-06 18:27:21 +00003489// r & (2^8-1) ==> movz
3490def : Pat<(and GR32:$src1, 0xff),
Dan Gohman6e438702009-04-27 16:33:14 +00003491 (MOVZX32rr8 (EXTRACT_SUBREG (COPY_TO_REGCLASS GR32:$src1, GR32_ABCD),
Dan Gohman744d4622009-04-13 16:09:41 +00003492 x86_subreg_8bit))>,
Dan Gohman5beb1ff2008-08-06 18:27:21 +00003493 Requires<[In32BitMode]>;
3494// r & (2^8-1) ==> movz
3495def : Pat<(and GR16:$src1, 0xff),
Dan Gohman6e438702009-04-27 16:33:14 +00003496 (MOVZX16rr8 (EXTRACT_SUBREG (COPY_TO_REGCLASS GR16:$src1, GR16_ABCD),
Dan Gohman744d4622009-04-13 16:09:41 +00003497 x86_subreg_8bit))>,
Dan Gohmandd612bb2008-08-20 21:27:32 +00003498 Requires<[In32BitMode]>;
3499
3500// sext_inreg patterns
3501def : Pat<(sext_inreg GR32:$src, i16),
Dan Gohman744d4622009-04-13 16:09:41 +00003502 (MOVSX32rr16 (EXTRACT_SUBREG GR32:$src, x86_subreg_16bit))>;
Dan Gohmandd612bb2008-08-20 21:27:32 +00003503def : Pat<(sext_inreg GR32:$src, i8),
Dan Gohman6e438702009-04-27 16:33:14 +00003504 (MOVSX32rr8 (EXTRACT_SUBREG (COPY_TO_REGCLASS GR32:$src, GR32_ABCD),
Dan Gohman744d4622009-04-13 16:09:41 +00003505 x86_subreg_8bit))>,
Dan Gohmandd612bb2008-08-20 21:27:32 +00003506 Requires<[In32BitMode]>;
3507def : Pat<(sext_inreg GR16:$src, i8),
Dan Gohman6e438702009-04-27 16:33:14 +00003508 (MOVSX16rr8 (EXTRACT_SUBREG (COPY_TO_REGCLASS GR16:$src, GR16_ABCD),
Dan Gohman744d4622009-04-13 16:09:41 +00003509 x86_subreg_8bit))>,
Dan Gohmandd612bb2008-08-20 21:27:32 +00003510 Requires<[In32BitMode]>;
3511
3512// trunc patterns
3513def : Pat<(i16 (trunc GR32:$src)),
Dan Gohman744d4622009-04-13 16:09:41 +00003514 (EXTRACT_SUBREG GR32:$src, x86_subreg_16bit)>;
Dan Gohmandd612bb2008-08-20 21:27:32 +00003515def : Pat<(i8 (trunc GR32:$src)),
Dan Gohman6e438702009-04-27 16:33:14 +00003516 (EXTRACT_SUBREG (COPY_TO_REGCLASS GR32:$src, GR32_ABCD),
Dan Gohman744d4622009-04-13 16:09:41 +00003517 x86_subreg_8bit)>,
Dan Gohmandd612bb2008-08-20 21:27:32 +00003518 Requires<[In32BitMode]>;
3519def : Pat<(i8 (trunc GR16:$src)),
Dan Gohman6e438702009-04-27 16:33:14 +00003520 (EXTRACT_SUBREG (COPY_TO_REGCLASS GR16:$src, GR16_ABCD),
Dan Gohman744d4622009-04-13 16:09:41 +00003521 x86_subreg_8bit)>,
3522 Requires<[In32BitMode]>;
3523
3524// h-register tricks
3525def : Pat<(i8 (trunc (srl_su GR16:$src, (i8 8)))),
Dan Gohman6e438702009-04-27 16:33:14 +00003526 (EXTRACT_SUBREG (COPY_TO_REGCLASS GR16:$src, GR16_ABCD),
Dan Gohman744d4622009-04-13 16:09:41 +00003527 x86_subreg_8bit_hi)>,
3528 Requires<[In32BitMode]>;
3529def : Pat<(i8 (trunc (srl_su GR32:$src, (i8 8)))),
Dan Gohman6e438702009-04-27 16:33:14 +00003530 (EXTRACT_SUBREG (COPY_TO_REGCLASS GR32:$src, GR32_ABCD),
Dan Gohman744d4622009-04-13 16:09:41 +00003531 x86_subreg_8bit_hi)>,
3532 Requires<[In32BitMode]>;
3533def : Pat<(srl_su GR16:$src, (i8 8)),
3534 (EXTRACT_SUBREG
3535 (MOVZX32rr8
Dan Gohman6e438702009-04-27 16:33:14 +00003536 (EXTRACT_SUBREG (COPY_TO_REGCLASS GR16:$src, GR16_ABCD),
Dan Gohman744d4622009-04-13 16:09:41 +00003537 x86_subreg_8bit_hi)),
3538 x86_subreg_16bit)>,
3539 Requires<[In32BitMode]>;
3540def : Pat<(and (srl_su GR32:$src, (i8 8)), (i32 255)),
Dan Gohman6e438702009-04-27 16:33:14 +00003541 (MOVZX32rr8 (EXTRACT_SUBREG (COPY_TO_REGCLASS GR32:$src, GR32_ABCD),
Dan Gohman744d4622009-04-13 16:09:41 +00003542 x86_subreg_8bit_hi))>,
Dan Gohman5beb1ff2008-08-06 18:27:21 +00003543 Requires<[In32BitMode]>;
Dan Gohman9203ab42008-07-30 18:09:17 +00003544
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003545// (shl x, 1) ==> (add x, x)
3546def : Pat<(shl GR8 :$src1, (i8 1)), (ADD8rr GR8 :$src1, GR8 :$src1)>;
3547def : Pat<(shl GR16:$src1, (i8 1)), (ADD16rr GR16:$src1, GR16:$src1)>;
3548def : Pat<(shl GR32:$src1, (i8 1)), (ADD32rr GR32:$src1, GR32:$src1)>;
3549
Evan Cheng76a64c72008-08-30 02:03:58 +00003550// (shl x (and y, 31)) ==> (shl x, y)
3551def : Pat<(shl GR8:$src1, (and CL:$amt, 31)),
3552 (SHL8rCL GR8:$src1)>;
3553def : Pat<(shl GR16:$src1, (and CL:$amt, 31)),
3554 (SHL16rCL GR16:$src1)>;
3555def : Pat<(shl GR32:$src1, (and CL:$amt, 31)),
3556 (SHL32rCL GR32:$src1)>;
3557def : Pat<(store (shl (loadi8 addr:$dst), (and CL:$amt, 31)), addr:$dst),
3558 (SHL8mCL addr:$dst)>;
3559def : Pat<(store (shl (loadi16 addr:$dst), (and CL:$amt, 31)), addr:$dst),
3560 (SHL16mCL addr:$dst)>;
3561def : Pat<(store (shl (loadi32 addr:$dst), (and CL:$amt, 31)), addr:$dst),
3562 (SHL32mCL addr:$dst)>;
3563
3564def : Pat<(srl GR8:$src1, (and CL:$amt, 31)),
3565 (SHR8rCL GR8:$src1)>;
3566def : Pat<(srl GR16:$src1, (and CL:$amt, 31)),
3567 (SHR16rCL GR16:$src1)>;
3568def : Pat<(srl GR32:$src1, (and CL:$amt, 31)),
3569 (SHR32rCL GR32:$src1)>;
3570def : Pat<(store (srl (loadi8 addr:$dst), (and CL:$amt, 31)), addr:$dst),
3571 (SHR8mCL addr:$dst)>;
3572def : Pat<(store (srl (loadi16 addr:$dst), (and CL:$amt, 31)), addr:$dst),
3573 (SHR16mCL addr:$dst)>;
3574def : Pat<(store (srl (loadi32 addr:$dst), (and CL:$amt, 31)), addr:$dst),
3575 (SHR32mCL addr:$dst)>;
3576
3577def : Pat<(sra GR8:$src1, (and CL:$amt, 31)),
3578 (SAR8rCL GR8:$src1)>;
3579def : Pat<(sra GR16:$src1, (and CL:$amt, 31)),
3580 (SAR16rCL GR16:$src1)>;
3581def : Pat<(sra GR32:$src1, (and CL:$amt, 31)),
3582 (SAR32rCL GR32:$src1)>;
3583def : Pat<(store (sra (loadi8 addr:$dst), (and CL:$amt, 31)), addr:$dst),
3584 (SAR8mCL addr:$dst)>;
3585def : Pat<(store (sra (loadi16 addr:$dst), (and CL:$amt, 31)), addr:$dst),
3586 (SAR16mCL addr:$dst)>;
3587def : Pat<(store (sra (loadi32 addr:$dst), (and CL:$amt, 31)), addr:$dst),
3588 (SAR32mCL addr:$dst)>;
3589
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003590// (or (x >> c) | (y << (32 - c))) ==> (shrd32 x, y, c)
3591def : Pat<(or (srl GR32:$src1, CL:$amt),
3592 (shl GR32:$src2, (sub 32, CL:$amt))),
3593 (SHRD32rrCL GR32:$src1, GR32:$src2)>;
3594
3595def : Pat<(store (or (srl (loadi32 addr:$dst), CL:$amt),
3596 (shl GR32:$src2, (sub 32, CL:$amt))), addr:$dst),
3597 (SHRD32mrCL addr:$dst, GR32:$src2)>;
3598
Dan Gohman921581d2008-10-17 01:23:35 +00003599def : Pat<(or (srl GR32:$src1, (i8 (trunc ECX:$amt))),
3600 (shl GR32:$src2, (i8 (trunc (sub 32, ECX:$amt))))),
3601 (SHRD32rrCL GR32:$src1, GR32:$src2)>;
3602
3603def : Pat<(store (or (srl (loadi32 addr:$dst), (i8 (trunc ECX:$amt))),
3604 (shl GR32:$src2, (i8 (trunc (sub 32, ECX:$amt))))),
3605 addr:$dst),
3606 (SHRD32mrCL addr:$dst, GR32:$src2)>;
3607
3608def : Pat<(shrd GR32:$src1, (i8 imm:$amt1), GR32:$src2, (i8 imm:$amt2)),
3609 (SHRD32rri8 GR32:$src1, GR32:$src2, (i8 imm:$amt1))>;
3610
3611def : Pat<(store (shrd (loadi32 addr:$dst), (i8 imm:$amt1),
3612 GR32:$src2, (i8 imm:$amt2)), addr:$dst),
3613 (SHRD32mri8 addr:$dst, GR32:$src2, (i8 imm:$amt1))>;
3614
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003615// (or (x << c) | (y >> (32 - c))) ==> (shld32 x, y, c)
3616def : Pat<(or (shl GR32:$src1, CL:$amt),
3617 (srl GR32:$src2, (sub 32, CL:$amt))),
3618 (SHLD32rrCL GR32:$src1, GR32:$src2)>;
3619
3620def : Pat<(store (or (shl (loadi32 addr:$dst), CL:$amt),
3621 (srl GR32:$src2, (sub 32, CL:$amt))), addr:$dst),
3622 (SHLD32mrCL addr:$dst, GR32:$src2)>;
3623
Dan Gohman921581d2008-10-17 01:23:35 +00003624def : Pat<(or (shl GR32:$src1, (i8 (trunc ECX:$amt))),
3625 (srl GR32:$src2, (i8 (trunc (sub 32, ECX:$amt))))),
3626 (SHLD32rrCL GR32:$src1, GR32:$src2)>;
3627
3628def : Pat<(store (or (shl (loadi32 addr:$dst), (i8 (trunc ECX:$amt))),
3629 (srl GR32:$src2, (i8 (trunc (sub 32, ECX:$amt))))),
3630 addr:$dst),
3631 (SHLD32mrCL addr:$dst, GR32:$src2)>;
3632
3633def : Pat<(shld GR32:$src1, (i8 imm:$amt1), GR32:$src2, (i8 imm:$amt2)),
3634 (SHLD32rri8 GR32:$src1, GR32:$src2, (i8 imm:$amt1))>;
3635
3636def : Pat<(store (shld (loadi32 addr:$dst), (i8 imm:$amt1),
3637 GR32:$src2, (i8 imm:$amt2)), addr:$dst),
3638 (SHLD32mri8 addr:$dst, GR32:$src2, (i8 imm:$amt1))>;
3639
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003640// (or (x >> c) | (y << (16 - c))) ==> (shrd16 x, y, c)
3641def : Pat<(or (srl GR16:$src1, CL:$amt),
3642 (shl GR16:$src2, (sub 16, CL:$amt))),
3643 (SHRD16rrCL GR16:$src1, GR16:$src2)>;
3644
3645def : Pat<(store (or (srl (loadi16 addr:$dst), CL:$amt),
3646 (shl GR16:$src2, (sub 16, CL:$amt))), addr:$dst),
3647 (SHRD16mrCL addr:$dst, GR16:$src2)>;
3648
Dan Gohman921581d2008-10-17 01:23:35 +00003649def : Pat<(or (srl GR16:$src1, (i8 (trunc CX:$amt))),
3650 (shl GR16:$src2, (i8 (trunc (sub 16, CX:$amt))))),
3651 (SHRD16rrCL GR16:$src1, GR16:$src2)>;
3652
3653def : Pat<(store (or (srl (loadi16 addr:$dst), (i8 (trunc CX:$amt))),
3654 (shl GR16:$src2, (i8 (trunc (sub 16, CX:$amt))))),
3655 addr:$dst),
3656 (SHRD16mrCL addr:$dst, GR16:$src2)>;
3657
3658def : Pat<(shrd GR16:$src1, (i8 imm:$amt1), GR16:$src2, (i8 imm:$amt2)),
3659 (SHRD16rri8 GR16:$src1, GR16:$src2, (i8 imm:$amt1))>;
3660
3661def : Pat<(store (shrd (loadi16 addr:$dst), (i8 imm:$amt1),
3662 GR16:$src2, (i8 imm:$amt2)), addr:$dst),
3663 (SHRD16mri8 addr:$dst, GR16:$src2, (i8 imm:$amt1))>;
3664
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003665// (or (x << c) | (y >> (16 - c))) ==> (shld16 x, y, c)
3666def : Pat<(or (shl GR16:$src1, CL:$amt),
3667 (srl GR16:$src2, (sub 16, CL:$amt))),
3668 (SHLD16rrCL GR16:$src1, GR16:$src2)>;
3669
3670def : Pat<(store (or (shl (loadi16 addr:$dst), CL:$amt),
3671 (srl GR16:$src2, (sub 16, CL:$amt))), addr:$dst),
3672 (SHLD16mrCL addr:$dst, GR16:$src2)>;
3673
Dan Gohman921581d2008-10-17 01:23:35 +00003674def : Pat<(or (shl GR16:$src1, (i8 (trunc CX:$amt))),
3675 (srl GR16:$src2, (i8 (trunc (sub 16, CX:$amt))))),
3676 (SHLD16rrCL GR16:$src1, GR16:$src2)>;
3677
3678def : Pat<(store (or (shl (loadi16 addr:$dst), (i8 (trunc CX:$amt))),
3679 (srl GR16:$src2, (i8 (trunc (sub 16, CX:$amt))))),
3680 addr:$dst),
3681 (SHLD16mrCL addr:$dst, GR16:$src2)>;
3682
3683def : Pat<(shld GR16:$src1, (i8 imm:$amt1), GR16:$src2, (i8 imm:$amt2)),
3684 (SHLD16rri8 GR16:$src1, GR16:$src2, (i8 imm:$amt1))>;
3685
3686def : Pat<(store (shld (loadi16 addr:$dst), (i8 imm:$amt1),
3687 GR16:$src2, (i8 imm:$amt2)), addr:$dst),
3688 (SHLD16mri8 addr:$dst, GR16:$src2, (i8 imm:$amt1))>;
3689
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003690//===----------------------------------------------------------------------===//
Dan Gohman99a12192009-03-04 19:44:21 +00003691// EFLAGS-defining Patterns
Bill Wendlingf5399032008-12-12 21:15:41 +00003692//===----------------------------------------------------------------------===//
3693
Dan Gohman99a12192009-03-04 19:44:21 +00003694// Register-Register Addition with EFLAGS result
3695def : Pat<(parallel (X86add_flag GR8:$src1, GR8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003696 (implicit EFLAGS)),
3697 (ADD8rr GR8:$src1, GR8:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003698def : Pat<(parallel (X86add_flag GR16:$src1, GR16:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003699 (implicit EFLAGS)),
3700 (ADD16rr GR16:$src1, GR16:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003701def : Pat<(parallel (X86add_flag GR32:$src1, GR32:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003702 (implicit EFLAGS)),
3703 (ADD32rr GR32:$src1, GR32:$src2)>;
3704
Dan Gohman99a12192009-03-04 19:44:21 +00003705// Register-Memory Addition with EFLAGS result
3706def : Pat<(parallel (X86add_flag GR8:$src1, (loadi8 addr:$src2)),
Bill Wendlingf5399032008-12-12 21:15:41 +00003707 (implicit EFLAGS)),
3708 (ADD8rm GR8:$src1, addr:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003709def : Pat<(parallel (X86add_flag GR16:$src1, (loadi16 addr:$src2)),
Bill Wendlingf5399032008-12-12 21:15:41 +00003710 (implicit EFLAGS)),
3711 (ADD16rm GR16:$src1, addr:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003712def : Pat<(parallel (X86add_flag GR32:$src1, (loadi32 addr:$src2)),
Bill Wendlingf5399032008-12-12 21:15:41 +00003713 (implicit EFLAGS)),
3714 (ADD32rm GR32:$src1, addr:$src2)>;
3715
Dan Gohman99a12192009-03-04 19:44:21 +00003716// Register-Integer Addition with EFLAGS result
3717def : Pat<(parallel (X86add_flag GR8:$src1, imm:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003718 (implicit EFLAGS)),
3719 (ADD8ri GR8:$src1, imm:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003720def : Pat<(parallel (X86add_flag GR16:$src1, imm:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003721 (implicit EFLAGS)),
3722 (ADD16ri GR16:$src1, imm:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003723def : Pat<(parallel (X86add_flag GR32:$src1, imm:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003724 (implicit EFLAGS)),
3725 (ADD32ri GR32:$src1, imm:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003726def : Pat<(parallel (X86add_flag GR16:$src1, i16immSExt8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003727 (implicit EFLAGS)),
3728 (ADD16ri8 GR16:$src1, i16immSExt8:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003729def : Pat<(parallel (X86add_flag GR32:$src1, i32immSExt8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003730 (implicit EFLAGS)),
3731 (ADD32ri8 GR32:$src1, i32immSExt8:$src2)>;
3732
Dan Gohman99a12192009-03-04 19:44:21 +00003733// Memory-Register Addition with EFLAGS result
3734def : Pat<(parallel (store (X86add_flag (loadi8 addr:$dst), GR8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003735 addr:$dst),
3736 (implicit EFLAGS)),
3737 (ADD8mr addr:$dst, GR8:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003738def : Pat<(parallel (store (X86add_flag (loadi16 addr:$dst), GR16:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003739 addr:$dst),
3740 (implicit EFLAGS)),
3741 (ADD16mr addr:$dst, GR16:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003742def : Pat<(parallel (store (X86add_flag (loadi32 addr:$dst), GR32:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003743 addr:$dst),
3744 (implicit EFLAGS)),
3745 (ADD32mr addr:$dst, GR32:$src2)>;
Dale Johannesen06b83f12009-05-18 17:44:15 +00003746
3747// Memory-Integer Addition with EFLAGS result
Dan Gohman99a12192009-03-04 19:44:21 +00003748def : Pat<(parallel (store (X86add_flag (loadi8 addr:$dst), imm:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003749 addr:$dst),
3750 (implicit EFLAGS)),
3751 (ADD8mi addr:$dst, imm:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003752def : Pat<(parallel (store (X86add_flag (loadi16 addr:$dst), imm:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003753 addr:$dst),
3754 (implicit EFLAGS)),
3755 (ADD16mi addr:$dst, imm:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003756def : Pat<(parallel (store (X86add_flag (loadi32 addr:$dst), imm:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003757 addr:$dst),
3758 (implicit EFLAGS)),
3759 (ADD32mi addr:$dst, imm:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003760def : Pat<(parallel (store (X86add_flag (loadi16 addr:$dst), i16immSExt8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003761 addr:$dst),
3762 (implicit EFLAGS)),
3763 (ADD16mi8 addr:$dst, i16immSExt8:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003764def : Pat<(parallel (store (X86add_flag (loadi32 addr:$dst), i32immSExt8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003765 addr:$dst),
3766 (implicit EFLAGS)),
3767 (ADD32mi8 addr:$dst, i32immSExt8:$src2)>;
3768
Dan Gohman99a12192009-03-04 19:44:21 +00003769// Register-Register Subtraction with EFLAGS result
3770def : Pat<(parallel (X86sub_flag GR8:$src1, GR8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003771 (implicit EFLAGS)),
3772 (SUB8rr GR8:$src1, GR8:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003773def : Pat<(parallel (X86sub_flag GR16:$src1, GR16:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003774 (implicit EFLAGS)),
3775 (SUB16rr GR16:$src1, GR16:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003776def : Pat<(parallel (X86sub_flag GR32:$src1, GR32:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003777 (implicit EFLAGS)),
3778 (SUB32rr GR32:$src1, GR32:$src2)>;
3779
Dan Gohman99a12192009-03-04 19:44:21 +00003780// Register-Memory Subtraction with EFLAGS result
3781def : Pat<(parallel (X86sub_flag GR8:$src1, (loadi8 addr:$src2)),
Bill Wendlingf5399032008-12-12 21:15:41 +00003782 (implicit EFLAGS)),
3783 (SUB8rm GR8:$src1, addr:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003784def : Pat<(parallel (X86sub_flag GR16:$src1, (loadi16 addr:$src2)),
Bill Wendlingf5399032008-12-12 21:15:41 +00003785 (implicit EFLAGS)),
3786 (SUB16rm GR16:$src1, addr:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003787def : Pat<(parallel (X86sub_flag GR32:$src1, (loadi32 addr:$src2)),
Bill Wendlingf5399032008-12-12 21:15:41 +00003788 (implicit EFLAGS)),
3789 (SUB32rm GR32:$src1, addr:$src2)>;
3790
Dan Gohman99a12192009-03-04 19:44:21 +00003791// Register-Integer Subtraction with EFLAGS result
3792def : Pat<(parallel (X86sub_flag GR8:$src1, imm:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003793 (implicit EFLAGS)),
3794 (SUB8ri GR8:$src1, imm:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003795def : Pat<(parallel (X86sub_flag GR16:$src1, imm:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003796 (implicit EFLAGS)),
3797 (SUB16ri GR16:$src1, imm:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003798def : Pat<(parallel (X86sub_flag GR32:$src1, imm:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003799 (implicit EFLAGS)),
3800 (SUB32ri GR32:$src1, imm:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003801def : Pat<(parallel (X86sub_flag GR16:$src1, i16immSExt8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003802 (implicit EFLAGS)),
3803 (SUB16ri8 GR16:$src1, i16immSExt8:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003804def : Pat<(parallel (X86sub_flag GR32:$src1, i32immSExt8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003805 (implicit EFLAGS)),
3806 (SUB32ri8 GR32:$src1, i32immSExt8:$src2)>;
3807
Dan Gohman99a12192009-03-04 19:44:21 +00003808// Memory-Register Subtraction with EFLAGS result
3809def : Pat<(parallel (store (X86sub_flag (loadi8 addr:$dst), GR8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003810 addr:$dst),
3811 (implicit EFLAGS)),
3812 (SUB8mr addr:$dst, GR8:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003813def : Pat<(parallel (store (X86sub_flag (loadi16 addr:$dst), GR16:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003814 addr:$dst),
3815 (implicit EFLAGS)),
3816 (SUB16mr addr:$dst, GR16:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003817def : Pat<(parallel (store (X86sub_flag (loadi32 addr:$dst), GR32:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003818 addr:$dst),
3819 (implicit EFLAGS)),
3820 (SUB32mr addr:$dst, GR32:$src2)>;
3821
Dan Gohman99a12192009-03-04 19:44:21 +00003822// Memory-Integer Subtraction with EFLAGS result
3823def : Pat<(parallel (store (X86sub_flag (loadi8 addr:$dst), imm:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003824 addr:$dst),
3825 (implicit EFLAGS)),
3826 (SUB8mi addr:$dst, imm:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003827def : Pat<(parallel (store (X86sub_flag (loadi16 addr:$dst), imm:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003828 addr:$dst),
3829 (implicit EFLAGS)),
3830 (SUB16mi addr:$dst, imm:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003831def : Pat<(parallel (store (X86sub_flag (loadi32 addr:$dst), imm:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003832 addr:$dst),
3833 (implicit EFLAGS)),
3834 (SUB32mi addr:$dst, imm:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003835def : Pat<(parallel (store (X86sub_flag (loadi16 addr:$dst), i16immSExt8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003836 addr:$dst),
3837 (implicit EFLAGS)),
3838 (SUB16mi8 addr:$dst, i16immSExt8:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003839def : Pat<(parallel (store (X86sub_flag (loadi32 addr:$dst), i32immSExt8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003840 addr:$dst),
3841 (implicit EFLAGS)),
3842 (SUB32mi8 addr:$dst, i32immSExt8:$src2)>;
3843
3844
Dan Gohman99a12192009-03-04 19:44:21 +00003845// Register-Register Signed Integer Multiply with EFLAGS result
3846def : Pat<(parallel (X86smul_flag GR16:$src1, GR16:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003847 (implicit EFLAGS)),
3848 (IMUL16rr GR16:$src1, GR16:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003849def : Pat<(parallel (X86smul_flag GR32:$src1, GR32:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003850 (implicit EFLAGS)),
3851 (IMUL32rr GR32:$src1, GR32:$src2)>;
3852
Dan Gohman99a12192009-03-04 19:44:21 +00003853// Register-Memory Signed Integer Multiply with EFLAGS result
3854def : Pat<(parallel (X86smul_flag GR16:$src1, (loadi16 addr:$src2)),
Bill Wendlingf5399032008-12-12 21:15:41 +00003855 (implicit EFLAGS)),
3856 (IMUL16rm GR16:$src1, addr:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003857def : Pat<(parallel (X86smul_flag GR32:$src1, (loadi32 addr:$src2)),
Bill Wendlingf5399032008-12-12 21:15:41 +00003858 (implicit EFLAGS)),
3859 (IMUL32rm GR32:$src1, addr:$src2)>;
3860
Dan Gohman99a12192009-03-04 19:44:21 +00003861// Register-Integer Signed Integer Multiply with EFLAGS result
3862def : Pat<(parallel (X86smul_flag GR16:$src1, imm:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003863 (implicit EFLAGS)),
3864 (IMUL16rri GR16:$src1, imm:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003865def : Pat<(parallel (X86smul_flag GR32:$src1, imm:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003866 (implicit EFLAGS)),
3867 (IMUL32rri GR32:$src1, imm:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003868def : Pat<(parallel (X86smul_flag GR16:$src1, i16immSExt8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003869 (implicit EFLAGS)),
3870 (IMUL16rri8 GR16:$src1, i16immSExt8:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003871def : Pat<(parallel (X86smul_flag GR32:$src1, i32immSExt8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003872 (implicit EFLAGS)),
3873 (IMUL32rri8 GR32:$src1, i32immSExt8:$src2)>;
3874
Dan Gohman99a12192009-03-04 19:44:21 +00003875// Memory-Integer Signed Integer Multiply with EFLAGS result
3876def : Pat<(parallel (X86smul_flag (loadi16 addr:$src1), imm:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003877 (implicit EFLAGS)),
3878 (IMUL16rmi addr:$src1, imm:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003879def : Pat<(parallel (X86smul_flag (loadi32 addr:$src1), imm:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003880 (implicit EFLAGS)),
3881 (IMUL32rmi addr:$src1, imm:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003882def : Pat<(parallel (X86smul_flag (loadi16 addr:$src1), i16immSExt8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003883 (implicit EFLAGS)),
3884 (IMUL16rmi8 addr:$src1, i16immSExt8:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003885def : Pat<(parallel (X86smul_flag (loadi32 addr:$src1), i32immSExt8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003886 (implicit EFLAGS)),
3887 (IMUL32rmi8 addr:$src1, i32immSExt8:$src2)>;
3888
Dan Gohman99a12192009-03-04 19:44:21 +00003889// Optimize multiply by 2 with EFLAGS result.
Evan Cheng00cf7932009-01-27 03:30:42 +00003890let AddedComplexity = 2 in {
Dan Gohman99a12192009-03-04 19:44:21 +00003891def : Pat<(parallel (X86smul_flag GR16:$src1, 2),
Evan Cheng00cf7932009-01-27 03:30:42 +00003892 (implicit EFLAGS)),
3893 (ADD16rr GR16:$src1, GR16:$src1)>;
3894
Dan Gohman99a12192009-03-04 19:44:21 +00003895def : Pat<(parallel (X86smul_flag GR32:$src1, 2),
Evan Cheng00cf7932009-01-27 03:30:42 +00003896 (implicit EFLAGS)),
3897 (ADD32rr GR32:$src1, GR32:$src1)>;
3898}
3899
Dan Gohman99a12192009-03-04 19:44:21 +00003900// INC and DEC with EFLAGS result. Note that these do not set CF.
3901def : Pat<(parallel (X86inc_flag GR8:$src), (implicit EFLAGS)),
3902 (INC8r GR8:$src)>;
3903def : Pat<(parallel (store (i8 (X86inc_flag (loadi8 addr:$dst))), addr:$dst),
3904 (implicit EFLAGS)),
3905 (INC8m addr:$dst)>;
3906def : Pat<(parallel (X86dec_flag GR8:$src), (implicit EFLAGS)),
3907 (DEC8r GR8:$src)>;
3908def : Pat<(parallel (store (i8 (X86dec_flag (loadi8 addr:$dst))), addr:$dst),
3909 (implicit EFLAGS)),
3910 (DEC8m addr:$dst)>;
3911
3912def : Pat<(parallel (X86inc_flag GR16:$src), (implicit EFLAGS)),
Dan Gohmaneebcac72009-03-05 21:32:23 +00003913 (INC16r GR16:$src)>, Requires<[In32BitMode]>;
Dan Gohman99a12192009-03-04 19:44:21 +00003914def : Pat<(parallel (store (i16 (X86inc_flag (loadi16 addr:$dst))), addr:$dst),
3915 (implicit EFLAGS)),
Dan Gohmaneebcac72009-03-05 21:32:23 +00003916 (INC16m addr:$dst)>, Requires<[In32BitMode]>;
Dan Gohman99a12192009-03-04 19:44:21 +00003917def : Pat<(parallel (X86dec_flag GR16:$src), (implicit EFLAGS)),
Dan Gohmaneebcac72009-03-05 21:32:23 +00003918 (DEC16r GR16:$src)>, Requires<[In32BitMode]>;
Dan Gohman99a12192009-03-04 19:44:21 +00003919def : Pat<(parallel (store (i16 (X86dec_flag (loadi16 addr:$dst))), addr:$dst),
3920 (implicit EFLAGS)),
Dan Gohmaneebcac72009-03-05 21:32:23 +00003921 (DEC16m addr:$dst)>, Requires<[In32BitMode]>;
Dan Gohman99a12192009-03-04 19:44:21 +00003922
3923def : Pat<(parallel (X86inc_flag GR32:$src), (implicit EFLAGS)),
Dan Gohmaneebcac72009-03-05 21:32:23 +00003924 (INC32r GR32:$src)>, Requires<[In32BitMode]>;
Dan Gohman99a12192009-03-04 19:44:21 +00003925def : Pat<(parallel (store (i32 (X86inc_flag (loadi32 addr:$dst))), addr:$dst),
3926 (implicit EFLAGS)),
Dan Gohmaneebcac72009-03-05 21:32:23 +00003927 (INC32m addr:$dst)>, Requires<[In32BitMode]>;
Dan Gohman99a12192009-03-04 19:44:21 +00003928def : Pat<(parallel (X86dec_flag GR32:$src), (implicit EFLAGS)),
Dan Gohmaneebcac72009-03-05 21:32:23 +00003929 (DEC32r GR32:$src)>, Requires<[In32BitMode]>;
Dan Gohman99a12192009-03-04 19:44:21 +00003930def : Pat<(parallel (store (i32 (X86dec_flag (loadi32 addr:$dst))), addr:$dst),
3931 (implicit EFLAGS)),
Dan Gohmaneebcac72009-03-05 21:32:23 +00003932 (DEC32m addr:$dst)>, Requires<[In32BitMode]>;
Dan Gohman99a12192009-03-04 19:44:21 +00003933
Bill Wendlingf5399032008-12-12 21:15:41 +00003934//===----------------------------------------------------------------------===//
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003935// Floating Point Stack Support
3936//===----------------------------------------------------------------------===//
3937
3938include "X86InstrFPStack.td"
3939
3940//===----------------------------------------------------------------------===//
Evan Cheng86ab7d32007-07-31 08:04:03 +00003941// X86-64 Support
3942//===----------------------------------------------------------------------===//
3943
Chris Lattner2de8d2b2008-01-10 05:50:42 +00003944include "X86Instr64bit.td"
Evan Cheng86ab7d32007-07-31 08:04:03 +00003945
3946//===----------------------------------------------------------------------===//
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003947// XMM Floating point support (requires SSE / SSE2)
3948//===----------------------------------------------------------------------===//
3949
3950include "X86InstrSSE.td"
Evan Cheng5e4d1e72008-04-25 18:19:54 +00003951
3952//===----------------------------------------------------------------------===//
3953// MMX and XMM Packed Integer support (requires MMX, SSE, and SSE2)
3954//===----------------------------------------------------------------------===//
3955
3956include "X86InstrMMX.td"