blob: 98b111432710859c576645e194e0d6fc7f31168f [file] [log] [blame]
Arnold Schwaighofer373e8652007-10-12 21:30:57 +00001//===- X86InstrInfo.td - Describe the X86 Instruction Set --*- tablegen -*-===//
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002//
3// The LLVM Compiler Infrastructure
4//
Chris Lattner081ce942007-12-29 20:36:04 +00005// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
Dan Gohmanf17a25c2007-07-18 16:29:46 +00007//
8//===----------------------------------------------------------------------===//
9//
10// This file describes the X86 instruction set, defining the instructions, and
11// properties of the instructions which are needed for code generation, machine
12// code emission, and analysis.
13//
14//===----------------------------------------------------------------------===//
15
16//===----------------------------------------------------------------------===//
17// X86 specific DAG Nodes.
18//
19
20def SDTIntShiftDOp: SDTypeProfile<1, 3,
21 [SDTCisSameAs<0, 1>, SDTCisSameAs<0, 2>,
22 SDTCisInt<0>, SDTCisInt<3>]>;
23
24def SDTX86CmpTest : SDTypeProfile<0, 2, [SDTCisSameAs<0, 1>]>;
25
Evan Cheng621216e2007-09-29 00:00:36 +000026def SDTX86Cmov : SDTypeProfile<1, 4,
Evan Cheng950aac02007-09-25 01:57:46 +000027 [SDTCisSameAs<0, 1>, SDTCisSameAs<1, 2>,
28 SDTCisVT<3, i8>, SDTCisVT<4, i32>]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +000029
Dan Gohman99a12192009-03-04 19:44:21 +000030// Unary and binary operator instructions that set EFLAGS as a side-effect.
31def SDTUnaryArithWithFlags : SDTypeProfile<1, 1,
32 [SDTCisInt<0>]>;
33def SDTBinaryArithWithFlags : SDTypeProfile<1, 2,
34 [SDTCisSameAs<0, 1>,
35 SDTCisSameAs<0, 2>,
36 SDTCisInt<0>]>;
Bill Wendlingae034ed2008-12-12 00:56:36 +000037
Evan Cheng621216e2007-09-29 00:00:36 +000038def SDTX86BrCond : SDTypeProfile<0, 3,
Evan Cheng950aac02007-09-25 01:57:46 +000039 [SDTCisVT<0, OtherVT>,
40 SDTCisVT<1, i8>, SDTCisVT<2, i32>]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +000041
Evan Cheng621216e2007-09-29 00:00:36 +000042def SDTX86SetCC : SDTypeProfile<1, 2,
Evan Cheng950aac02007-09-25 01:57:46 +000043 [SDTCisVT<0, i8>,
44 SDTCisVT<1, i8>, SDTCisVT<2, i32>]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +000045
Andrew Lenharth7dfe23f2008-03-01 21:52:34 +000046def SDTX86cas : SDTypeProfile<0, 3, [SDTCisPtrTy<0>, SDTCisInt<1>,
47 SDTCisVT<2, i8>]>;
Andrew Lenharth81580822008-03-05 01:15:49 +000048def SDTX86cas8 : SDTypeProfile<0, 1, [SDTCisPtrTy<0>]>;
Andrew Lenharth7dfe23f2008-03-01 21:52:34 +000049
Dale Johannesenf160d802008-10-02 18:53:47 +000050def SDTX86atomicBinary : SDTypeProfile<2, 3, [SDTCisInt<0>, SDTCisInt<1>,
51 SDTCisPtrTy<2>, SDTCisInt<3>,SDTCisInt<4>]>;
Chris Lattnerb56cc342008-03-11 03:23:40 +000052def SDTX86Ret : SDTypeProfile<0, -1, [SDTCisVT<0, i16>]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +000053
Bill Wendling7173da52007-11-13 09:19:02 +000054def SDT_X86CallSeqStart : SDCallSeqStart<[ SDTCisVT<0, i32> ]>;
55def SDT_X86CallSeqEnd : SDCallSeqEnd<[ SDTCisVT<0, i32>,
56 SDTCisVT<1, i32> ]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +000057
Dan Gohman3329ffe2008-05-29 19:57:41 +000058def SDT_X86Call : SDTypeProfile<0, -1, [SDTCisVT<0, iPTR>]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +000059
60def SDTX86RepStr : SDTypeProfile<0, 1, [SDTCisVT<0, OtherVT>]>;
61
62def SDTX86RdTsc : SDTypeProfile<0, 0, []>;
63
64def SDTX86Wrapper : SDTypeProfile<1, 1, [SDTCisSameAs<0, 1>, SDTCisPtrTy<0>]>;
65
66def SDT_X86TLSADDR : SDTypeProfile<1, 1, [SDTCisPtrTy<0>, SDTCisInt<1>]>;
67
Rafael Espindolabca99f72009-04-08 21:14:34 +000068def SDT_X86SegmentBaseAddress : SDTypeProfile<1, 1, [SDTCisPtrTy<0>]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +000069
70def SDT_X86EHRET : SDTypeProfile<0, 1, [SDTCisInt<0>]>;
71
Arnold Schwaighofere2d6bbb2007-10-11 19:40:01 +000072def SDT_X86TCRET : SDTypeProfile<0, 2, [SDTCisPtrTy<0>, SDTCisVT<1, i32>]>;
73
Evan Cheng48679f42007-12-14 02:13:44 +000074def X86bsf : SDNode<"X86ISD::BSF", SDTIntUnaryOp>;
75def X86bsr : SDNode<"X86ISD::BSR", SDTIntUnaryOp>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +000076def X86shld : SDNode<"X86ISD::SHLD", SDTIntShiftDOp>;
77def X86shrd : SDNode<"X86ISD::SHRD", SDTIntShiftDOp>;
78
Evan Cheng621216e2007-09-29 00:00:36 +000079def X86cmp : SDNode<"X86ISD::CMP" , SDTX86CmpTest>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +000080
Dan Gohman7fe9b7f2008-12-23 22:45:23 +000081def X86bt : SDNode<"X86ISD::BT", SDTX86CmpTest>;
82
Evan Cheng621216e2007-09-29 00:00:36 +000083def X86cmov : SDNode<"X86ISD::CMOV", SDTX86Cmov>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +000084def X86brcond : SDNode<"X86ISD::BRCOND", SDTX86BrCond,
Evan Cheng950aac02007-09-25 01:57:46 +000085 [SDNPHasChain]>;
Evan Cheng621216e2007-09-29 00:00:36 +000086def X86setcc : SDNode<"X86ISD::SETCC", SDTX86SetCC>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +000087
Andrew Lenharth7dfe23f2008-03-01 21:52:34 +000088def X86cas : SDNode<"X86ISD::LCMPXCHG_DAG", SDTX86cas,
89 [SDNPHasChain, SDNPInFlag, SDNPOutFlag, SDNPMayStore,
90 SDNPMayLoad]>;
Andrew Lenharth81580822008-03-05 01:15:49 +000091def X86cas8 : SDNode<"X86ISD::LCMPXCHG8_DAG", SDTX86cas8,
92 [SDNPHasChain, SDNPInFlag, SDNPOutFlag, SDNPMayStore,
93 SDNPMayLoad]>;
Dale Johannesenf160d802008-10-02 18:53:47 +000094def X86AtomAdd64 : SDNode<"X86ISD::ATOMADD64_DAG", SDTX86atomicBinary,
95 [SDNPHasChain, SDNPMayStore,
96 SDNPMayLoad, SDNPMemOperand]>;
97def X86AtomSub64 : SDNode<"X86ISD::ATOMSUB64_DAG", SDTX86atomicBinary,
98 [SDNPHasChain, SDNPMayStore,
99 SDNPMayLoad, SDNPMemOperand]>;
100def X86AtomOr64 : SDNode<"X86ISD::ATOMOR64_DAG", SDTX86atomicBinary,
101 [SDNPHasChain, SDNPMayStore,
102 SDNPMayLoad, SDNPMemOperand]>;
103def X86AtomXor64 : SDNode<"X86ISD::ATOMXOR64_DAG", SDTX86atomicBinary,
104 [SDNPHasChain, SDNPMayStore,
105 SDNPMayLoad, SDNPMemOperand]>;
106def X86AtomAnd64 : SDNode<"X86ISD::ATOMAND64_DAG", SDTX86atomicBinary,
107 [SDNPHasChain, SDNPMayStore,
108 SDNPMayLoad, SDNPMemOperand]>;
109def X86AtomNand64 : SDNode<"X86ISD::ATOMNAND64_DAG", SDTX86atomicBinary,
110 [SDNPHasChain, SDNPMayStore,
111 SDNPMayLoad, SDNPMemOperand]>;
Dale Johannesen51c58ee2008-10-03 22:25:52 +0000112def X86AtomSwap64 : SDNode<"X86ISD::ATOMSWAP64_DAG", SDTX86atomicBinary,
113 [SDNPHasChain, SDNPMayStore,
114 SDNPMayLoad, SDNPMemOperand]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000115def X86retflag : SDNode<"X86ISD::RET_FLAG", SDTX86Ret,
116 [SDNPHasChain, SDNPOptInFlag]>;
117
118def X86callseq_start :
119 SDNode<"ISD::CALLSEQ_START", SDT_X86CallSeqStart,
120 [SDNPHasChain, SDNPOutFlag]>;
121def X86callseq_end :
122 SDNode<"ISD::CALLSEQ_END", SDT_X86CallSeqEnd,
Arnold Schwaighofere2d6bbb2007-10-11 19:40:01 +0000123 [SDNPHasChain, SDNPOptInFlag, SDNPOutFlag]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000124
125def X86call : SDNode<"X86ISD::CALL", SDT_X86Call,
126 [SDNPHasChain, SDNPOutFlag, SDNPOptInFlag]>;
127
128def X86tailcall: SDNode<"X86ISD::TAILCALL", SDT_X86Call,
129 [SDNPHasChain, SDNPOutFlag, SDNPOptInFlag]>;
130
131def X86rep_stos: SDNode<"X86ISD::REP_STOS", SDTX86RepStr,
Chris Lattnerca4e0fe2008-01-10 05:12:37 +0000132 [SDNPHasChain, SDNPInFlag, SDNPOutFlag, SDNPMayStore]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000133def X86rep_movs: SDNode<"X86ISD::REP_MOVS", SDTX86RepStr,
Chris Lattnerca4e0fe2008-01-10 05:12:37 +0000134 [SDNPHasChain, SDNPInFlag, SDNPOutFlag, SDNPMayStore,
135 SDNPMayLoad]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000136
137def X86rdtsc : SDNode<"X86ISD::RDTSC_DAG",SDTX86RdTsc,
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000138 [SDNPHasChain, SDNPOutFlag, SDNPSideEffect]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000139
140def X86Wrapper : SDNode<"X86ISD::Wrapper", SDTX86Wrapper>;
141def X86WrapperRIP : SDNode<"X86ISD::WrapperRIP", SDTX86Wrapper>;
142
143def X86tlsaddr : SDNode<"X86ISD::TLSADDR", SDT_X86TLSADDR,
Anton Korobeynikov4fbf00b2008-05-04 21:36:32 +0000144 [SDNPHasChain, SDNPOptInFlag, SDNPOutFlag]>;
Rafael Espindolabca99f72009-04-08 21:14:34 +0000145def X86SegmentBaseAddress : SDNode<"X86ISD::SegmentBaseAddress",
146 SDT_X86SegmentBaseAddress, []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000147
148def X86ehret : SDNode<"X86ISD::EH_RETURN", SDT_X86EHRET,
149 [SDNPHasChain]>;
150
Arnold Schwaighofere2d6bbb2007-10-11 19:40:01 +0000151def X86tcret : SDNode<"X86ISD::TC_RETURN", SDT_X86TCRET,
152 [SDNPHasChain, SDNPOptInFlag]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000153
Dan Gohman99a12192009-03-04 19:44:21 +0000154def X86add_flag : SDNode<"X86ISD::ADD", SDTBinaryArithWithFlags>;
155def X86sub_flag : SDNode<"X86ISD::SUB", SDTBinaryArithWithFlags>;
156def X86smul_flag : SDNode<"X86ISD::SMUL", SDTBinaryArithWithFlags>;
157def X86umul_flag : SDNode<"X86ISD::UMUL", SDTUnaryArithWithFlags>;
158def X86inc_flag : SDNode<"X86ISD::INC", SDTUnaryArithWithFlags>;
159def X86dec_flag : SDNode<"X86ISD::DEC", SDTUnaryArithWithFlags>;
Bill Wendlingae034ed2008-12-12 00:56:36 +0000160
Evan Chengc3495762009-03-30 21:36:47 +0000161def X86mul_imm : SDNode<"X86ISD::MUL_IMM", SDTIntBinOp>;
162
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000163//===----------------------------------------------------------------------===//
164// X86 Operand Definitions.
165//
166
167// *mem - Operand definitions for the funky X86 addressing mode operands.
168//
169class X86MemOperand<string printMethod> : Operand<iPTR> {
170 let PrintMethod = printMethod;
Rafael Espindolabca99f72009-04-08 21:14:34 +0000171 let MIOperandInfo = (ops ptr_rc, i8imm, ptr_rc, i32imm, i8imm);
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000172}
173
174def i8mem : X86MemOperand<"printi8mem">;
175def i16mem : X86MemOperand<"printi16mem">;
176def i32mem : X86MemOperand<"printi32mem">;
177def i64mem : X86MemOperand<"printi64mem">;
178def i128mem : X86MemOperand<"printi128mem">;
179def f32mem : X86MemOperand<"printf32mem">;
180def f64mem : X86MemOperand<"printf64mem">;
Dale Johannesen4ab00bd2007-08-05 18:49:15 +0000181def f80mem : X86MemOperand<"printf80mem">;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000182def f128mem : X86MemOperand<"printf128mem">;
183
184def lea32mem : Operand<i32> {
Rafael Espindolabca99f72009-04-08 21:14:34 +0000185 let PrintMethod = "printlea32mem";
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000186 let MIOperandInfo = (ops GR32, i8imm, GR32, i32imm);
187}
188
189def SSECC : Operand<i8> {
190 let PrintMethod = "printSSECC";
191}
192
193def piclabel: Operand<i32> {
194 let PrintMethod = "printPICLabel";
195}
196
197// A couple of more descriptive operand definitions.
198// 16-bits but only 8 bits are significant.
199def i16i8imm : Operand<i16>;
200// 32-bits but only 8 bits are significant.
201def i32i8imm : Operand<i32>;
202
203// Branch targets have OtherVT type.
204def brtarget : Operand<OtherVT>;
205
206//===----------------------------------------------------------------------===//
207// X86 Complex Pattern Definitions.
208//
209
210// Define X86 specific addressing mode.
Rafael Espindolabca99f72009-04-08 21:14:34 +0000211def addr : ComplexPattern<iPTR, 5, "SelectAddr", [], []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000212def lea32addr : ComplexPattern<i32, 4, "SelectLEAAddr",
213 [add, mul, shl, or, frameindex], []>;
214
215//===----------------------------------------------------------------------===//
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000216// X86 Instruction Predicate Definitions.
217def HasMMX : Predicate<"Subtarget->hasMMX()">;
218def HasSSE1 : Predicate<"Subtarget->hasSSE1()">;
219def HasSSE2 : Predicate<"Subtarget->hasSSE2()">;
220def HasSSE3 : Predicate<"Subtarget->hasSSE3()">;
221def HasSSSE3 : Predicate<"Subtarget->hasSSSE3()">;
Nate Begemanb2975562008-02-03 07:18:54 +0000222def HasSSE41 : Predicate<"Subtarget->hasSSE41()">;
223def HasSSE42 : Predicate<"Subtarget->hasSSE42()">;
Dale Johannesene0e0fd02007-09-23 14:52:20 +0000224def FPStackf32 : Predicate<"!Subtarget->hasSSE1()">;
225def FPStackf64 : Predicate<"!Subtarget->hasSSE2()">;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000226def In32BitMode : Predicate<"!Subtarget->is64Bit()">;
227def In64BitMode : Predicate<"Subtarget->is64Bit()">;
228def SmallCode : Predicate<"TM.getCodeModel() == CodeModel::Small">;
229def NotSmallCode : Predicate<"TM.getCodeModel() != CodeModel::Small">;
230def IsStatic : Predicate<"TM.getRelocationModel() == Reloc::Static">;
Evan Cheng13559d62008-09-26 23:41:32 +0000231def OptForSpeed : Predicate<"!OptForSize">;
Evan Cheng95a77fd2009-01-02 05:35:45 +0000232def FastBTMem : Predicate<"!Subtarget->isBTMemSlow()">;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000233
234//===----------------------------------------------------------------------===//
Evan Cheng86ab7d32007-07-31 08:04:03 +0000235// X86 Instruction Format Definitions.
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000236//
237
Evan Cheng86ab7d32007-07-31 08:04:03 +0000238include "X86InstrFormats.td"
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000239
240//===----------------------------------------------------------------------===//
241// Pattern fragments...
242//
243
244// X86 specific condition code. These correspond to CondCode in
245// X86InstrInfo.h. They must be kept in synch.
Dan Gohman0fc9ed62009-01-07 00:15:08 +0000246def X86_COND_A : PatLeaf<(i8 0)>; // alt. COND_NBE
247def X86_COND_AE : PatLeaf<(i8 1)>; // alt. COND_NC
248def X86_COND_B : PatLeaf<(i8 2)>; // alt. COND_C
249def X86_COND_BE : PatLeaf<(i8 3)>; // alt. COND_NA
250def X86_COND_E : PatLeaf<(i8 4)>; // alt. COND_Z
251def X86_COND_G : PatLeaf<(i8 5)>; // alt. COND_NLE
252def X86_COND_GE : PatLeaf<(i8 6)>; // alt. COND_NL
253def X86_COND_L : PatLeaf<(i8 7)>; // alt. COND_NGE
254def X86_COND_LE : PatLeaf<(i8 8)>; // alt. COND_NG
255def X86_COND_NE : PatLeaf<(i8 9)>; // alt. COND_NZ
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000256def X86_COND_NO : PatLeaf<(i8 10)>;
Dan Gohman0fc9ed62009-01-07 00:15:08 +0000257def X86_COND_NP : PatLeaf<(i8 11)>; // alt. COND_PO
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000258def X86_COND_NS : PatLeaf<(i8 12)>;
Dan Gohman0fc9ed62009-01-07 00:15:08 +0000259def X86_COND_O : PatLeaf<(i8 13)>;
260def X86_COND_P : PatLeaf<(i8 14)>; // alt. COND_PE
261def X86_COND_S : PatLeaf<(i8 15)>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000262
263def i16immSExt8 : PatLeaf<(i16 imm), [{
264 // i16immSExt8 predicate - True if the 16-bit immediate fits in a 8-bit
265 // sign extended field.
Dan Gohmanfaeb4a32008-09-12 16:56:44 +0000266 return (int16_t)N->getZExtValue() == (int8_t)N->getZExtValue();
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000267}]>;
268
269def i32immSExt8 : PatLeaf<(i32 imm), [{
270 // i32immSExt8 predicate - True if the 32-bit immediate fits in a 8-bit
271 // sign extended field.
Dan Gohmanfaeb4a32008-09-12 16:56:44 +0000272 return (int32_t)N->getZExtValue() == (int8_t)N->getZExtValue();
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000273}]>;
274
275// Helper fragments for loads.
Evan Chengb3e25ea2008-05-13 18:59:59 +0000276// It's always safe to treat a anyext i16 load as a i32 load if the i16 is
277// known to be 32-bit aligned or better. Ditto for i8 to i16.
Dan Gohman2a174122008-10-15 06:50:19 +0000278def loadi16 : PatFrag<(ops node:$ptr), (i16 (unindexedload node:$ptr)), [{
Dan Gohman8335c412008-08-20 15:24:22 +0000279 LoadSDNode *LD = cast<LoadSDNode>(N);
Dan Gohman8335c412008-08-20 15:24:22 +0000280 ISD::LoadExtType ExtType = LD->getExtensionType();
281 if (ExtType == ISD::NON_EXTLOAD)
282 return true;
283 if (ExtType == ISD::EXTLOAD)
284 return LD->getAlignment() >= 2 && !LD->isVolatile();
Evan Cheng8b765e92008-05-13 00:54:02 +0000285 return false;
286}]>;
287
Dan Gohman2a174122008-10-15 06:50:19 +0000288def loadi16_anyext : PatFrag<(ops node:$ptr), (i32 (unindexedload node:$ptr)), [{
Evan Cheng56ec77b2008-09-24 23:27:55 +0000289 LoadSDNode *LD = cast<LoadSDNode>(N);
Evan Cheng56ec77b2008-09-24 23:27:55 +0000290 ISD::LoadExtType ExtType = LD->getExtensionType();
291 if (ExtType == ISD::EXTLOAD)
292 return LD->getAlignment() >= 2 && !LD->isVolatile();
293 return false;
294}]>;
295
Dan Gohman2a174122008-10-15 06:50:19 +0000296def loadi32 : PatFrag<(ops node:$ptr), (i32 (unindexedload node:$ptr)), [{
Dan Gohman8335c412008-08-20 15:24:22 +0000297 LoadSDNode *LD = cast<LoadSDNode>(N);
Dan Gohman8335c412008-08-20 15:24:22 +0000298 ISD::LoadExtType ExtType = LD->getExtensionType();
299 if (ExtType == ISD::NON_EXTLOAD)
300 return true;
301 if (ExtType == ISD::EXTLOAD)
302 return LD->getAlignment() >= 4 && !LD->isVolatile();
Evan Cheng8b765e92008-05-13 00:54:02 +0000303 return false;
304}]>;
305
Dan Gohman2a174122008-10-15 06:50:19 +0000306def nvloadi32 : PatFrag<(ops node:$ptr), (i32 (unindexedload node:$ptr)), [{
Evan Cheng1e5e5452008-09-29 17:26:18 +0000307 LoadSDNode *LD = cast<LoadSDNode>(N);
308 if (LD->isVolatile())
309 return false;
Evan Cheng1e5e5452008-09-29 17:26:18 +0000310 ISD::LoadExtType ExtType = LD->getExtensionType();
311 if (ExtType == ISD::NON_EXTLOAD)
312 return true;
313 if (ExtType == ISD::EXTLOAD)
314 return LD->getAlignment() >= 4;
315 return false;
316}]>;
317
sampo9cc09a32009-01-26 01:24:32 +0000318def gsload : PatFrag<(ops node:$ptr), (load node:$ptr), [{
319 LoadSDNode *LD = cast<LoadSDNode>(N);
320 const Value *Src = LD->getSrcValue();
321 if (!Src)
322 return false;
323 if (const PointerType *PT = dyn_cast<PointerType>(Src->getType()))
324 return PT->getAddressSpace() == 256;
325 return false;
326}]>;
327
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000328def loadi8 : PatFrag<(ops node:$ptr), (i8 (load node:$ptr))>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000329def loadi64 : PatFrag<(ops node:$ptr), (i64 (load node:$ptr))>;
330
331def loadf32 : PatFrag<(ops node:$ptr), (f32 (load node:$ptr))>;
332def loadf64 : PatFrag<(ops node:$ptr), (f64 (load node:$ptr))>;
Dale Johannesen4ab00bd2007-08-05 18:49:15 +0000333def loadf80 : PatFrag<(ops node:$ptr), (f80 (load node:$ptr))>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000334
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000335def sextloadi16i8 : PatFrag<(ops node:$ptr), (i16 (sextloadi8 node:$ptr))>;
336def sextloadi32i8 : PatFrag<(ops node:$ptr), (i32 (sextloadi8 node:$ptr))>;
337def sextloadi32i16 : PatFrag<(ops node:$ptr), (i32 (sextloadi16 node:$ptr))>;
338
339def zextloadi8i1 : PatFrag<(ops node:$ptr), (i8 (zextloadi1 node:$ptr))>;
340def zextloadi16i1 : PatFrag<(ops node:$ptr), (i16 (zextloadi1 node:$ptr))>;
341def zextloadi32i1 : PatFrag<(ops node:$ptr), (i32 (zextloadi1 node:$ptr))>;
342def zextloadi16i8 : PatFrag<(ops node:$ptr), (i16 (zextloadi8 node:$ptr))>;
343def zextloadi32i8 : PatFrag<(ops node:$ptr), (i32 (zextloadi8 node:$ptr))>;
344def zextloadi32i16 : PatFrag<(ops node:$ptr), (i32 (zextloadi16 node:$ptr))>;
345
346def extloadi8i1 : PatFrag<(ops node:$ptr), (i8 (extloadi1 node:$ptr))>;
347def extloadi16i1 : PatFrag<(ops node:$ptr), (i16 (extloadi1 node:$ptr))>;
348def extloadi32i1 : PatFrag<(ops node:$ptr), (i32 (extloadi1 node:$ptr))>;
349def extloadi16i8 : PatFrag<(ops node:$ptr), (i16 (extloadi8 node:$ptr))>;
350def extloadi32i8 : PatFrag<(ops node:$ptr), (i32 (extloadi8 node:$ptr))>;
351def extloadi32i16 : PatFrag<(ops node:$ptr), (i32 (extloadi16 node:$ptr))>;
352
Chris Lattner21da6382008-02-19 17:37:35 +0000353
354// An 'and' node with a single use.
355def and_su : PatFrag<(ops node:$lhs, node:$rhs), (and node:$lhs, node:$rhs), [{
Evan Cheng9123cfa2008-03-04 00:40:35 +0000356 return N->hasOneUse();
Chris Lattner21da6382008-02-19 17:37:35 +0000357}]>;
358
Dan Gohman921581d2008-10-17 01:23:35 +0000359// 'shld' and 'shrd' instruction patterns. Note that even though these have
360// the srl and shl in their patterns, the C++ code must still check for them,
361// because predicates are tested before children nodes are explored.
362
363def shrd : PatFrag<(ops node:$src1, node:$amt1, node:$src2, node:$amt2),
364 (or (srl node:$src1, node:$amt1),
365 (shl node:$src2, node:$amt2)), [{
366 assert(N->getOpcode() == ISD::OR);
367 return N->getOperand(0).getOpcode() == ISD::SRL &&
368 N->getOperand(1).getOpcode() == ISD::SHL &&
369 isa<ConstantSDNode>(N->getOperand(0).getOperand(1)) &&
370 isa<ConstantSDNode>(N->getOperand(1).getOperand(1)) &&
371 N->getOperand(0).getConstantOperandVal(1) ==
372 N->getValueSizeInBits(0) - N->getOperand(1).getConstantOperandVal(1);
373}]>;
374
375def shld : PatFrag<(ops node:$src1, node:$amt1, node:$src2, node:$amt2),
376 (or (shl node:$src1, node:$amt1),
377 (srl node:$src2, node:$amt2)), [{
378 assert(N->getOpcode() == ISD::OR);
379 return N->getOperand(0).getOpcode() == ISD::SHL &&
380 N->getOperand(1).getOpcode() == ISD::SRL &&
381 isa<ConstantSDNode>(N->getOperand(0).getOperand(1)) &&
382 isa<ConstantSDNode>(N->getOperand(1).getOperand(1)) &&
383 N->getOperand(0).getConstantOperandVal(1) ==
384 N->getValueSizeInBits(0) - N->getOperand(1).getConstantOperandVal(1);
385}]>;
386
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000387//===----------------------------------------------------------------------===//
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000388// Instruction list...
389//
390
391// ADJCALLSTACKDOWN/UP implicitly use/def ESP because they may be expanded into
392// a stack adjustment and the codegen must know that they may modify the stack
393// pointer before prolog-epilog rewriting occurs.
Chris Lattnerb56cc342008-03-11 03:23:40 +0000394// Pessimistically assume ADJCALLSTACKDOWN / ADJCALLSTACKUP will become
395// sub / add which can clobber EFLAGS.
Evan Cheng037364a2007-09-28 01:19:48 +0000396let Defs = [ESP, EFLAGS], Uses = [ESP] in {
Dan Gohman01c9f772008-10-01 18:28:06 +0000397def ADJCALLSTACKDOWN32 : I<0, Pseudo, (outs), (ins i32imm:$amt),
398 "#ADJCALLSTACKDOWN",
Chris Lattnerfe5d4022008-10-11 22:08:30 +0000399 [(X86callseq_start timm:$amt)]>,
Dan Gohman01c9f772008-10-01 18:28:06 +0000400 Requires<[In32BitMode]>;
401def ADJCALLSTACKUP32 : I<0, Pseudo, (outs), (ins i32imm:$amt1, i32imm:$amt2),
402 "#ADJCALLSTACKUP",
Chris Lattnerfe5d4022008-10-11 22:08:30 +0000403 [(X86callseq_end timm:$amt1, timm:$amt2)]>,
Dan Gohman01c9f772008-10-01 18:28:06 +0000404 Requires<[In32BitMode]>;
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000405}
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000406
407// Nop
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000408let neverHasSideEffects = 1 in
409 def NOOP : I<0x90, RawFrm, (outs), (ins), "nop", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000410
Evan Cheng0729ccf2008-01-05 00:41:47 +0000411// PIC base
Dan Gohman9499cfe2008-10-01 04:14:30 +0000412let neverHasSideEffects = 1, isNotDuplicable = 1, Uses = [ESP] in
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000413 def MOVPC32r : Ii32<0xE8, Pseudo, (outs GR32:$reg), (ins piclabel:$label),
414 "call\t$label\n\tpop{l}\t$reg", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000415
416//===----------------------------------------------------------------------===//
417// Control Flow Instructions...
418//
419
420// Return instructions.
421let isTerminator = 1, isReturn = 1, isBarrier = 1,
Chris Lattnerb56cc342008-03-11 03:23:40 +0000422 hasCtrlDep = 1, FPForm = SpecialFP, FPFormBits = SpecialFP.Value in {
Dan Gohman2c4be2a2008-05-31 02:11:25 +0000423 def RET : I <0xC3, RawFrm, (outs), (ins variable_ops),
Chris Lattnerb56cc342008-03-11 03:23:40 +0000424 "ret",
Dan Gohman2c4be2a2008-05-31 02:11:25 +0000425 [(X86retflag 0)]>;
Chris Lattnerb56cc342008-03-11 03:23:40 +0000426 def RETI : Ii16<0xC2, RawFrm, (outs), (ins i16imm:$amt, variable_ops),
427 "ret\t$amt",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000428 [(X86retflag imm:$amt)]>;
429}
430
431// All branches are RawFrm, Void, Branch, and Terminators
Evan Cheng37e7c752007-07-21 00:34:19 +0000432let isBranch = 1, isTerminator = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +0000433 class IBr<bits<8> opcode, dag ins, string asm, list<dag> pattern> :
434 I<opcode, RawFrm, (outs), ins, asm, pattern>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000435
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000436let isBranch = 1, isBarrier = 1 in
Dan Gohman91888f02007-07-31 20:11:57 +0000437 def JMP : IBr<0xE9, (ins brtarget:$dst), "jmp\t$dst", [(br bb:$dst)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000438
Owen Andersonf8053082007-11-12 07:39:39 +0000439// Indirect branches
440let isBranch = 1, isTerminator = 1, isBarrier = 1, isIndirectBranch = 1 in {
Dan Gohman91888f02007-07-31 20:11:57 +0000441 def JMP32r : I<0xFF, MRM4r, (outs), (ins GR32:$dst), "jmp{l}\t{*}$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000442 [(brind GR32:$dst)]>;
Dan Gohman91888f02007-07-31 20:11:57 +0000443 def JMP32m : I<0xFF, MRM4m, (outs), (ins i32mem:$dst), "jmp{l}\t{*}$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000444 [(brind (loadi32 addr:$dst))]>;
445}
446
447// Conditional branches
Evan Cheng950aac02007-09-25 01:57:46 +0000448let Uses = [EFLAGS] in {
Dan Gohman91888f02007-07-31 20:11:57 +0000449def JE : IBr<0x84, (ins brtarget:$dst), "je\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000450 [(X86brcond bb:$dst, X86_COND_E, EFLAGS)]>, TB;
Dan Gohman91888f02007-07-31 20:11:57 +0000451def JNE : IBr<0x85, (ins brtarget:$dst), "jne\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000452 [(X86brcond bb:$dst, X86_COND_NE, EFLAGS)]>, TB;
Dan Gohman91888f02007-07-31 20:11:57 +0000453def JL : IBr<0x8C, (ins brtarget:$dst), "jl\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000454 [(X86brcond bb:$dst, X86_COND_L, EFLAGS)]>, TB;
Dan Gohman91888f02007-07-31 20:11:57 +0000455def JLE : IBr<0x8E, (ins brtarget:$dst), "jle\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000456 [(X86brcond bb:$dst, X86_COND_LE, EFLAGS)]>, TB;
Dan Gohman91888f02007-07-31 20:11:57 +0000457def JG : IBr<0x8F, (ins brtarget:$dst), "jg\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000458 [(X86brcond bb:$dst, X86_COND_G, EFLAGS)]>, TB;
Dan Gohman91888f02007-07-31 20:11:57 +0000459def JGE : IBr<0x8D, (ins brtarget:$dst), "jge\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000460 [(X86brcond bb:$dst, X86_COND_GE, EFLAGS)]>, TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000461
Dan Gohman91888f02007-07-31 20:11:57 +0000462def JB : IBr<0x82, (ins brtarget:$dst), "jb\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000463 [(X86brcond bb:$dst, X86_COND_B, EFLAGS)]>, TB;
Dan Gohman91888f02007-07-31 20:11:57 +0000464def JBE : IBr<0x86, (ins brtarget:$dst), "jbe\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000465 [(X86brcond bb:$dst, X86_COND_BE, EFLAGS)]>, TB;
Dan Gohman91888f02007-07-31 20:11:57 +0000466def JA : IBr<0x87, (ins brtarget:$dst), "ja\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000467 [(X86brcond bb:$dst, X86_COND_A, EFLAGS)]>, TB;
Dan Gohman91888f02007-07-31 20:11:57 +0000468def JAE : IBr<0x83, (ins brtarget:$dst), "jae\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000469 [(X86brcond bb:$dst, X86_COND_AE, EFLAGS)]>, TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000470
Dan Gohman91888f02007-07-31 20:11:57 +0000471def JS : IBr<0x88, (ins brtarget:$dst), "js\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000472 [(X86brcond bb:$dst, X86_COND_S, EFLAGS)]>, TB;
Dan Gohman91888f02007-07-31 20:11:57 +0000473def JNS : IBr<0x89, (ins brtarget:$dst), "jns\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000474 [(X86brcond bb:$dst, X86_COND_NS, EFLAGS)]>, TB;
Dan Gohman91888f02007-07-31 20:11:57 +0000475def JP : IBr<0x8A, (ins brtarget:$dst), "jp\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000476 [(X86brcond bb:$dst, X86_COND_P, EFLAGS)]>, TB;
Dan Gohman91888f02007-07-31 20:11:57 +0000477def JNP : IBr<0x8B, (ins brtarget:$dst), "jnp\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000478 [(X86brcond bb:$dst, X86_COND_NP, EFLAGS)]>, TB;
Dan Gohman91888f02007-07-31 20:11:57 +0000479def JO : IBr<0x80, (ins brtarget:$dst), "jo\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000480 [(X86brcond bb:$dst, X86_COND_O, EFLAGS)]>, TB;
Dan Gohman91888f02007-07-31 20:11:57 +0000481def JNO : IBr<0x81, (ins brtarget:$dst), "jno\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000482 [(X86brcond bb:$dst, X86_COND_NO, EFLAGS)]>, TB;
Evan Cheng950aac02007-09-25 01:57:46 +0000483} // Uses = [EFLAGS]
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000484
485//===----------------------------------------------------------------------===//
486// Call Instructions...
487//
Evan Cheng37e7c752007-07-21 00:34:19 +0000488let isCall = 1 in
Dan Gohman01c9f772008-10-01 18:28:06 +0000489 // All calls clobber the non-callee saved registers. ESP is marked as
490 // a use to prevent stack-pointer assignments that appear immediately
491 // before calls from potentially appearing dead. Uses for argument
492 // registers are added manually.
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000493 let Defs = [EAX, ECX, EDX, FP0, FP1, FP2, FP3, FP4, FP5, FP6, ST0,
494 MM0, MM1, MM2, MM3, MM4, MM5, MM6, MM7,
Evan Cheng2293b252008-10-17 21:02:22 +0000495 XMM0, XMM1, XMM2, XMM3, XMM4, XMM5, XMM6, XMM7,
496 XMM8, XMM9, XMM10, XMM11, XMM12, XMM13, XMM14, XMM15, EFLAGS],
Dan Gohman9499cfe2008-10-01 04:14:30 +0000497 Uses = [ESP] in {
Evan Cheng34f93712007-12-22 02:26:46 +0000498 def CALLpcrel32 : Ii32<0xE8, RawFrm, (outs), (ins i32imm:$dst,variable_ops),
Evan Cheng0af5a042009-03-12 18:15:39 +0000499 "call\t${dst:call}", [(X86call imm:$dst)]>,
500 Requires<[In32BitMode]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000501 def CALL32r : I<0xFF, MRM2r, (outs), (ins GR32:$dst, variable_ops),
Dan Gohman91888f02007-07-31 20:11:57 +0000502 "call\t{*}$dst", [(X86call GR32:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000503 def CALL32m : I<0xFF, MRM2m, (outs), (ins i32mem:$dst, variable_ops),
Dan Gohmanea4faba2008-05-29 21:50:34 +0000504 "call\t{*}$dst", [(X86call (loadi32 addr:$dst))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000505 }
506
507// Tail call stuff.
Arnold Schwaighofere2d6bbb2007-10-11 19:40:01 +0000508
Chris Lattnerb56cc342008-03-11 03:23:40 +0000509def TAILCALL : I<0, Pseudo, (outs), (ins),
Arnold Schwaighofere2d6bbb2007-10-11 19:40:01 +0000510 "#TAILCALL",
511 []>;
512
Evan Cheng37e7c752007-07-21 00:34:19 +0000513let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1 in
Arnold Schwaighofer6fd37ac2008-03-19 16:39:45 +0000514def TCRETURNdi : I<0, Pseudo, (outs), (ins i32imm:$dst, i32imm:$offset, variable_ops),
Arnold Schwaighofere2d6bbb2007-10-11 19:40:01 +0000515 "#TC_RETURN $dst $offset",
516 []>;
517
518let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1 in
Arnold Schwaighofer6fd37ac2008-03-19 16:39:45 +0000519def TCRETURNri : I<0, Pseudo, (outs), (ins GR32:$dst, i32imm:$offset, variable_ops),
Arnold Schwaighofere2d6bbb2007-10-11 19:40:01 +0000520 "#TC_RETURN $dst $offset",
521 []>;
522
523let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1 in
Arnold Schwaighofera0032722008-04-30 09:16:33 +0000524
Arnold Schwaighofere2d6bbb2007-10-11 19:40:01 +0000525 def TAILJMPd : IBr<0xE9, (ins i32imm:$dst), "jmp\t${dst:call} # TAILCALL",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000526 []>;
Evan Cheng37e7c752007-07-21 00:34:19 +0000527let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1 in
Arnold Schwaighofere2d6bbb2007-10-11 19:40:01 +0000528 def TAILJMPr : I<0xFF, MRM4r, (outs), (ins GR32:$dst), "jmp{l}\t{*}$dst # TAILCALL",
529 []>;
Evan Cheng37e7c752007-07-21 00:34:19 +0000530let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +0000531 def TAILJMPm : I<0xFF, MRM4m, (outs), (ins i32mem:$dst),
Arnold Schwaighofere2d6bbb2007-10-11 19:40:01 +0000532 "jmp\t{*}$dst # TAILCALL", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000533
534//===----------------------------------------------------------------------===//
535// Miscellaneous Instructions...
536//
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000537let Defs = [EBP, ESP], Uses = [EBP, ESP], mayLoad = 1, neverHasSideEffects=1 in
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000538def LEAVE : I<0xC9, RawFrm,
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000539 (outs), (ins), "leave", []>;
540
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000541let Defs = [ESP], Uses = [ESP], neverHasSideEffects=1 in {
542let mayLoad = 1 in
Evan Chengd8434332007-09-26 01:29:06 +0000543def POP32r : I<0x58, AddRegFrm, (outs GR32:$reg), (ins), "pop{l}\t$reg", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000544
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000545let mayStore = 1 in
Evan Chengd8434332007-09-26 01:29:06 +0000546def PUSH32r : I<0x50, AddRegFrm, (outs), (ins GR32:$reg), "push{l}\t$reg",[]>;
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000547}
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000548
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000549let Defs = [ESP, EFLAGS], Uses = [ESP], mayLoad = 1, neverHasSideEffects=1 in
Evan Chengf1341312007-09-26 21:28:00 +0000550def POPFD : I<0x9D, RawFrm, (outs), (ins), "popf", []>;
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000551let Defs = [ESP], Uses = [ESP, EFLAGS], mayStore = 1, neverHasSideEffects=1 in
Evan Chengf1341312007-09-26 21:28:00 +0000552def PUSHFD : I<0x9C, RawFrm, (outs), (ins), "pushf", []>;
Evan Chengd8434332007-09-26 01:29:06 +0000553
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000554let isTwoAddress = 1 in // GR32 = bswap GR32
555 def BSWAP32r : I<0xC8, AddRegFrm,
Evan Chengb783fa32007-07-19 01:14:50 +0000556 (outs GR32:$dst), (ins GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000557 "bswap{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000558 [(set GR32:$dst, (bswap GR32:$src))]>, TB;
559
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000560
Evan Cheng48679f42007-12-14 02:13:44 +0000561// Bit scan instructions.
562let Defs = [EFLAGS] in {
Evan Cheng4e33de92007-12-14 18:49:43 +0000563def BSF16rr : I<0xBC, MRMSrcReg, (outs GR16:$dst), (ins GR16:$src),
Dan Gohmancdb54c62007-12-14 15:10:00 +0000564 "bsf{w}\t{$src, $dst|$dst, $src}",
Evan Cheng7cfbfe32007-12-14 08:30:15 +0000565 [(set GR16:$dst, (X86bsf GR16:$src)), (implicit EFLAGS)]>, TB;
Evan Cheng48679f42007-12-14 02:13:44 +0000566def BSF16rm : I<0xBC, MRMSrcMem, (outs GR16:$dst), (ins i16mem:$src),
Dan Gohmancdb54c62007-12-14 15:10:00 +0000567 "bsf{w}\t{$src, $dst|$dst, $src}",
Evan Cheng7cfbfe32007-12-14 08:30:15 +0000568 [(set GR16:$dst, (X86bsf (loadi16 addr:$src))),
569 (implicit EFLAGS)]>, TB;
Evan Cheng4e33de92007-12-14 18:49:43 +0000570def BSF32rr : I<0xBC, MRMSrcReg, (outs GR32:$dst), (ins GR32:$src),
Dan Gohmancdb54c62007-12-14 15:10:00 +0000571 "bsf{l}\t{$src, $dst|$dst, $src}",
Evan Cheng7cfbfe32007-12-14 08:30:15 +0000572 [(set GR32:$dst, (X86bsf GR32:$src)), (implicit EFLAGS)]>, TB;
Evan Cheng48679f42007-12-14 02:13:44 +0000573def BSF32rm : I<0xBC, MRMSrcMem, (outs GR32:$dst), (ins i32mem:$src),
Dan Gohmancdb54c62007-12-14 15:10:00 +0000574 "bsf{l}\t{$src, $dst|$dst, $src}",
Evan Cheng7cfbfe32007-12-14 08:30:15 +0000575 [(set GR32:$dst, (X86bsf (loadi32 addr:$src))),
576 (implicit EFLAGS)]>, TB;
Evan Cheng48679f42007-12-14 02:13:44 +0000577
Evan Cheng4e33de92007-12-14 18:49:43 +0000578def BSR16rr : I<0xBD, MRMSrcReg, (outs GR16:$dst), (ins GR16:$src),
Dan Gohmancdb54c62007-12-14 15:10:00 +0000579 "bsr{w}\t{$src, $dst|$dst, $src}",
Evan Cheng7cfbfe32007-12-14 08:30:15 +0000580 [(set GR16:$dst, (X86bsr GR16:$src)), (implicit EFLAGS)]>, TB;
Evan Cheng48679f42007-12-14 02:13:44 +0000581def BSR16rm : I<0xBD, MRMSrcMem, (outs GR16:$dst), (ins i16mem:$src),
Dan Gohmancdb54c62007-12-14 15:10:00 +0000582 "bsr{w}\t{$src, $dst|$dst, $src}",
Evan Cheng7cfbfe32007-12-14 08:30:15 +0000583 [(set GR16:$dst, (X86bsr (loadi16 addr:$src))),
584 (implicit EFLAGS)]>, TB;
Evan Cheng4e33de92007-12-14 18:49:43 +0000585def BSR32rr : I<0xBD, MRMSrcReg, (outs GR32:$dst), (ins GR32:$src),
Dan Gohmancdb54c62007-12-14 15:10:00 +0000586 "bsr{l}\t{$src, $dst|$dst, $src}",
Evan Cheng7cfbfe32007-12-14 08:30:15 +0000587 [(set GR32:$dst, (X86bsr GR32:$src)), (implicit EFLAGS)]>, TB;
Evan Cheng48679f42007-12-14 02:13:44 +0000588def BSR32rm : I<0xBD, MRMSrcMem, (outs GR32:$dst), (ins i32mem:$src),
Dan Gohmancdb54c62007-12-14 15:10:00 +0000589 "bsr{l}\t{$src, $dst|$dst, $src}",
Evan Cheng7cfbfe32007-12-14 08:30:15 +0000590 [(set GR32:$dst, (X86bsr (loadi32 addr:$src))),
591 (implicit EFLAGS)]>, TB;
Evan Cheng48679f42007-12-14 02:13:44 +0000592} // Defs = [EFLAGS]
593
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000594let neverHasSideEffects = 1 in
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000595def LEA16r : I<0x8D, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +0000596 (outs GR16:$dst), (ins i32mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000597 "lea{w}\t{$src|$dst}, {$dst|$src}", []>, OpSize;
Evan Cheng1ea8e6b2008-03-27 01:41:09 +0000598let isReMaterializable = 1 in
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000599def LEA32r : I<0x8D, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +0000600 (outs GR32:$dst), (ins lea32mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000601 "lea{l}\t{$src|$dst}, {$dst|$src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000602 [(set GR32:$dst, lea32addr:$src)]>, Requires<[In32BitMode]>;
603
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000604let Defs = [ECX,EDI,ESI], Uses = [ECX,EDI,ESI] in {
Evan Chengb783fa32007-07-19 01:14:50 +0000605def REP_MOVSB : I<0xA4, RawFrm, (outs), (ins), "{rep;movsb|rep movsb}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000606 [(X86rep_movs i8)]>, REP;
Evan Chengb783fa32007-07-19 01:14:50 +0000607def REP_MOVSW : I<0xA5, RawFrm, (outs), (ins), "{rep;movsw|rep movsw}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000608 [(X86rep_movs i16)]>, REP, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +0000609def REP_MOVSD : I<0xA5, RawFrm, (outs), (ins), "{rep;movsl|rep movsd}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000610 [(X86rep_movs i32)]>, REP;
611}
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000612
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000613let Defs = [ECX,EDI], Uses = [AL,ECX,EDI] in
Evan Chengb783fa32007-07-19 01:14:50 +0000614def REP_STOSB : I<0xAA, RawFrm, (outs), (ins), "{rep;stosb|rep stosb}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000615 [(X86rep_stos i8)]>, REP;
616let Defs = [ECX,EDI], Uses = [AX,ECX,EDI] in
Evan Chengb783fa32007-07-19 01:14:50 +0000617def REP_STOSW : I<0xAB, RawFrm, (outs), (ins), "{rep;stosw|rep stosw}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000618 [(X86rep_stos i16)]>, REP, OpSize;
619let Defs = [ECX,EDI], Uses = [EAX,ECX,EDI] in
Evan Chengb783fa32007-07-19 01:14:50 +0000620def REP_STOSD : I<0xAB, RawFrm, (outs), (ins), "{rep;stosl|rep stosd}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000621 [(X86rep_stos i32)]>, REP;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000622
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000623let Defs = [RAX, RDX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000624def RDTSC : I<0x31, RawFrm, (outs), (ins), "rdtsc", [(X86rdtsc)]>,
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000625 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000626
Anton Korobeynikov39d40ba2008-01-15 07:02:33 +0000627let isBarrier = 1, hasCtrlDep = 1 in {
Chris Lattner56b941f2008-01-15 21:58:22 +0000628def TRAP : I<0x0B, RawFrm, (outs), (ins), "ud2", [(trap)]>, TB;
Anton Korobeynikov39d40ba2008-01-15 07:02:33 +0000629}
630
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000631//===----------------------------------------------------------------------===//
632// Input/Output Instructions...
633//
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000634let Defs = [AL], Uses = [DX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000635def IN8rr : I<0xEC, RawFrm, (outs), (ins),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000636 "in{b}\t{%dx, %al|%AL, %DX}", []>;
637let Defs = [AX], Uses = [DX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000638def IN16rr : I<0xED, RawFrm, (outs), (ins),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000639 "in{w}\t{%dx, %ax|%AX, %DX}", []>, OpSize;
640let Defs = [EAX], Uses = [DX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000641def IN32rr : I<0xED, RawFrm, (outs), (ins),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000642 "in{l}\t{%dx, %eax|%EAX, %DX}", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000643
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000644let Defs = [AL] in
Evan Chengb783fa32007-07-19 01:14:50 +0000645def IN8ri : Ii8<0xE4, RawFrm, (outs), (ins i16i8imm:$port),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000646 "in{b}\t{$port, %al|%AL, $port}", []>;
647let Defs = [AX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000648def IN16ri : Ii8<0xE5, RawFrm, (outs), (ins i16i8imm:$port),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000649 "in{w}\t{$port, %ax|%AX, $port}", []>, OpSize;
650let Defs = [EAX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000651def IN32ri : Ii8<0xE5, RawFrm, (outs), (ins i16i8imm:$port),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000652 "in{l}\t{$port, %eax|%EAX, $port}", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000653
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000654let Uses = [DX, AL] in
Evan Chengb783fa32007-07-19 01:14:50 +0000655def OUT8rr : I<0xEE, RawFrm, (outs), (ins),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000656 "out{b}\t{%al, %dx|%DX, %AL}", []>;
657let Uses = [DX, AX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000658def OUT16rr : I<0xEF, RawFrm, (outs), (ins),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000659 "out{w}\t{%ax, %dx|%DX, %AX}", []>, OpSize;
660let Uses = [DX, EAX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000661def OUT32rr : I<0xEF, RawFrm, (outs), (ins),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000662 "out{l}\t{%eax, %dx|%DX, %EAX}", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000663
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000664let Uses = [AL] in
Evan Chengb783fa32007-07-19 01:14:50 +0000665def OUT8ir : Ii8<0xE6, RawFrm, (outs), (ins i16i8imm:$port),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000666 "out{b}\t{%al, $port|$port, %AL}", []>;
667let Uses = [AX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000668def OUT16ir : Ii8<0xE7, RawFrm, (outs), (ins i16i8imm:$port),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000669 "out{w}\t{%ax, $port|$port, %AX}", []>, OpSize;
670let Uses = [EAX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000671def OUT32ir : Ii8<0xE7, RawFrm, (outs), (ins i16i8imm:$port),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000672 "out{l}\t{%eax, $port|$port, %EAX}", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000673
674//===----------------------------------------------------------------------===//
675// Move Instructions...
676//
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000677let neverHasSideEffects = 1 in {
Evan Chengb783fa32007-07-19 01:14:50 +0000678def MOV8rr : I<0x88, MRMDestReg, (outs GR8 :$dst), (ins GR8 :$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000679 "mov{b}\t{$src, $dst|$dst, $src}", []>;
Evan Chengb783fa32007-07-19 01:14:50 +0000680def MOV16rr : I<0x89, MRMDestReg, (outs GR16:$dst), (ins GR16:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000681 "mov{w}\t{$src, $dst|$dst, $src}", []>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +0000682def MOV32rr : I<0x89, MRMDestReg, (outs GR32:$dst), (ins GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000683 "mov{l}\t{$src, $dst|$dst, $src}", []>;
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000684}
Evan Cheng6f26e8b2008-06-18 08:13:07 +0000685let isReMaterializable = 1, isAsCheapAsAMove = 1 in {
Evan Chengb783fa32007-07-19 01:14:50 +0000686def MOV8ri : Ii8 <0xB0, AddRegFrm, (outs GR8 :$dst), (ins i8imm :$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000687 "mov{b}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000688 [(set GR8:$dst, imm:$src)]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000689def MOV16ri : Ii16<0xB8, AddRegFrm, (outs GR16:$dst), (ins i16imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000690 "mov{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000691 [(set GR16:$dst, imm:$src)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +0000692def MOV32ri : Ii32<0xB8, AddRegFrm, (outs GR32:$dst), (ins i32imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000693 "mov{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000694 [(set GR32:$dst, imm:$src)]>;
695}
Evan Chengb783fa32007-07-19 01:14:50 +0000696def MOV8mi : Ii8 <0xC6, MRM0m, (outs), (ins i8mem :$dst, i8imm :$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000697 "mov{b}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000698 [(store (i8 imm:$src), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000699def MOV16mi : Ii16<0xC7, MRM0m, (outs), (ins i16mem:$dst, i16imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000700 "mov{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000701 [(store (i16 imm:$src), addr:$dst)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +0000702def MOV32mi : Ii32<0xC7, MRM0m, (outs), (ins i32mem:$dst, i32imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000703 "mov{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000704 [(store (i32 imm:$src), addr:$dst)]>;
705
Dan Gohman5574cc72008-12-03 18:15:48 +0000706let canFoldAsLoad = 1, isReMaterializable = 1, mayHaveSideEffects = 1 in {
Evan Chengb783fa32007-07-19 01:14:50 +0000707def MOV8rm : I<0x8A, MRMSrcMem, (outs GR8 :$dst), (ins i8mem :$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000708 "mov{b}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000709 [(set GR8:$dst, (load addr:$src))]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000710def MOV16rm : I<0x8B, MRMSrcMem, (outs GR16:$dst), (ins i16mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000711 "mov{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000712 [(set GR16:$dst, (load addr:$src))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +0000713def MOV32rm : I<0x8B, MRMSrcMem, (outs GR32:$dst), (ins i32mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000714 "mov{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000715 [(set GR32:$dst, (load addr:$src))]>;
Evan Cheng4e84e452007-08-30 05:49:43 +0000716}
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000717
Evan Chengb783fa32007-07-19 01:14:50 +0000718def MOV8mr : I<0x88, MRMDestMem, (outs), (ins i8mem :$dst, GR8 :$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000719 "mov{b}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000720 [(store GR8:$src, addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000721def MOV16mr : I<0x89, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000722 "mov{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000723 [(store GR16:$src, addr:$dst)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +0000724def MOV32mr : I<0x89, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000725 "mov{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000726 [(store GR32:$src, addr:$dst)]>;
727
728//===----------------------------------------------------------------------===//
729// Fixed-Register Multiplication and Division Instructions...
730//
731
732// Extra precision multiplication
Evan Cheng55687072007-09-14 21:48:26 +0000733let Defs = [AL,AH,EFLAGS], Uses = [AL] in
Dan Gohman91888f02007-07-31 20:11:57 +0000734def MUL8r : I<0xF6, MRM4r, (outs), (ins GR8:$src), "mul{b}\t$src",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000735 // FIXME: Used for 8-bit mul, ignore result upper 8 bits.
736 // This probably ought to be moved to a def : Pat<> if the
737 // syntax can be accepted.
Bill Wendlingf5399032008-12-12 21:15:41 +0000738 [(set AL, (mul AL, GR8:$src)),
739 (implicit EFLAGS)]>; // AL,AH = AL*GR8
740
Chris Lattnerc7e96e72008-01-11 07:18:17 +0000741let Defs = [AX,DX,EFLAGS], Uses = [AX], neverHasSideEffects = 1 in
Bill Wendlingf5399032008-12-12 21:15:41 +0000742def MUL16r : I<0xF7, MRM4r, (outs), (ins GR16:$src),
743 "mul{w}\t$src",
744 []>, OpSize; // AX,DX = AX*GR16
745
Chris Lattnerc7e96e72008-01-11 07:18:17 +0000746let Defs = [EAX,EDX,EFLAGS], Uses = [EAX], neverHasSideEffects = 1 in
Bill Wendlingf5399032008-12-12 21:15:41 +0000747def MUL32r : I<0xF7, MRM4r, (outs), (ins GR32:$src),
748 "mul{l}\t$src",
749 []>; // EAX,EDX = EAX*GR32
750
Evan Cheng55687072007-09-14 21:48:26 +0000751let Defs = [AL,AH,EFLAGS], Uses = [AL] in
Evan Chengb783fa32007-07-19 01:14:50 +0000752def MUL8m : I<0xF6, MRM4m, (outs), (ins i8mem :$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000753 "mul{b}\t$src",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000754 // FIXME: Used for 8-bit mul, ignore result upper 8 bits.
755 // This probably ought to be moved to a def : Pat<> if the
756 // syntax can be accepted.
Bill Wendlingf5399032008-12-12 21:15:41 +0000757 [(set AL, (mul AL, (loadi8 addr:$src))),
758 (implicit EFLAGS)]>; // AL,AH = AL*[mem8]
759
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000760let mayLoad = 1, neverHasSideEffects = 1 in {
Evan Cheng55687072007-09-14 21:48:26 +0000761let Defs = [AX,DX,EFLAGS], Uses = [AX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000762def MUL16m : I<0xF7, MRM4m, (outs), (ins i16mem:$src),
Bill Wendlingf5399032008-12-12 21:15:41 +0000763 "mul{w}\t$src",
764 []>, OpSize; // AX,DX = AX*[mem16]
765
Evan Cheng55687072007-09-14 21:48:26 +0000766let Defs = [EAX,EDX,EFLAGS], Uses = [EAX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000767def MUL32m : I<0xF7, MRM4m, (outs), (ins i32mem:$src),
Bill Wendlingf5399032008-12-12 21:15:41 +0000768 "mul{l}\t$src",
769 []>; // EAX,EDX = EAX*[mem32]
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000770}
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000771
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000772let neverHasSideEffects = 1 in {
Evan Cheng55687072007-09-14 21:48:26 +0000773let Defs = [AL,AH,EFLAGS], Uses = [AL] in
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000774def IMUL8r : I<0xF6, MRM5r, (outs), (ins GR8:$src), "imul{b}\t$src", []>;
775 // AL,AH = AL*GR8
Evan Cheng55687072007-09-14 21:48:26 +0000776let Defs = [AX,DX,EFLAGS], Uses = [AX] in
Dan Gohman91888f02007-07-31 20:11:57 +0000777def IMUL16r : I<0xF7, MRM5r, (outs), (ins GR16:$src), "imul{w}\t$src", []>,
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000778 OpSize; // AX,DX = AX*GR16
Evan Cheng55687072007-09-14 21:48:26 +0000779let Defs = [EAX,EDX,EFLAGS], Uses = [EAX] in
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000780def IMUL32r : I<0xF7, MRM5r, (outs), (ins GR32:$src), "imul{l}\t$src", []>;
781 // EAX,EDX = EAX*GR32
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000782let mayLoad = 1 in {
Evan Cheng55687072007-09-14 21:48:26 +0000783let Defs = [AL,AH,EFLAGS], Uses = [AL] in
Evan Chengb783fa32007-07-19 01:14:50 +0000784def IMUL8m : I<0xF6, MRM5m, (outs), (ins i8mem :$src),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000785 "imul{b}\t$src", []>; // AL,AH = AL*[mem8]
Evan Cheng55687072007-09-14 21:48:26 +0000786let Defs = [AX,DX,EFLAGS], Uses = [AX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000787def IMUL16m : I<0xF7, MRM5m, (outs), (ins i16mem:$src),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000788 "imul{w}\t$src", []>, OpSize; // AX,DX = AX*[mem16]
789let Defs = [EAX,EDX], Uses = [EAX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000790def IMUL32m : I<0xF7, MRM5m, (outs), (ins i32mem:$src),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000791 "imul{l}\t$src", []>; // EAX,EDX = EAX*[mem32]
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000792}
Dan Gohmand44572d2008-11-18 21:29:14 +0000793} // neverHasSideEffects
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000794
795// unsigned division/remainder
Dale Johannesend8fd3562008-10-07 18:54:28 +0000796let Defs = [AL,AH,EFLAGS], Uses = [AX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000797def DIV8r : I<0xF6, MRM6r, (outs), (ins GR8:$src), // AX/r8 = AL,AH
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000798 "div{b}\t$src", []>;
Evan Cheng55687072007-09-14 21:48:26 +0000799let Defs = [AX,DX,EFLAGS], Uses = [AX,DX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000800def DIV16r : I<0xF7, MRM6r, (outs), (ins GR16:$src), // DX:AX/r16 = AX,DX
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000801 "div{w}\t$src", []>, OpSize;
Evan Cheng55687072007-09-14 21:48:26 +0000802let Defs = [EAX,EDX,EFLAGS], Uses = [EAX,EDX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000803def DIV32r : I<0xF7, MRM6r, (outs), (ins GR32:$src), // EDX:EAX/r32 = EAX,EDX
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000804 "div{l}\t$src", []>;
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000805let mayLoad = 1 in {
Dale Johannesend8fd3562008-10-07 18:54:28 +0000806let Defs = [AL,AH,EFLAGS], Uses = [AX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000807def DIV8m : I<0xF6, MRM6m, (outs), (ins i8mem:$src), // AX/[mem8] = AL,AH
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000808 "div{b}\t$src", []>;
Evan Cheng55687072007-09-14 21:48:26 +0000809let Defs = [AX,DX,EFLAGS], Uses = [AX,DX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000810def DIV16m : I<0xF7, MRM6m, (outs), (ins i16mem:$src), // DX:AX/[mem16] = AX,DX
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000811 "div{w}\t$src", []>, OpSize;
Evan Cheng55687072007-09-14 21:48:26 +0000812let Defs = [EAX,EDX,EFLAGS], Uses = [EAX,EDX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000813def DIV32m : I<0xF7, MRM6m, (outs), (ins i32mem:$src), // EDX:EAX/[mem32] = EAX,EDX
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000814 "div{l}\t$src", []>;
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000815}
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000816
817// Signed division/remainder.
Dale Johannesend8fd3562008-10-07 18:54:28 +0000818let Defs = [AL,AH,EFLAGS], Uses = [AX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000819def IDIV8r : I<0xF6, MRM7r, (outs), (ins GR8:$src), // AX/r8 = AL,AH
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000820 "idiv{b}\t$src", []>;
Evan Cheng55687072007-09-14 21:48:26 +0000821let Defs = [AX,DX,EFLAGS], Uses = [AX,DX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000822def IDIV16r: I<0xF7, MRM7r, (outs), (ins GR16:$src), // DX:AX/r16 = AX,DX
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000823 "idiv{w}\t$src", []>, OpSize;
Evan Cheng55687072007-09-14 21:48:26 +0000824let Defs = [EAX,EDX,EFLAGS], Uses = [EAX,EDX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000825def IDIV32r: I<0xF7, MRM7r, (outs), (ins GR32:$src), // EDX:EAX/r32 = EAX,EDX
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000826 "idiv{l}\t$src", []>;
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000827let mayLoad = 1, mayLoad = 1 in {
Dale Johannesend8fd3562008-10-07 18:54:28 +0000828let Defs = [AL,AH,EFLAGS], Uses = [AX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000829def IDIV8m : I<0xF6, MRM7m, (outs), (ins i8mem:$src), // AX/[mem8] = AL,AH
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000830 "idiv{b}\t$src", []>;
Evan Cheng55687072007-09-14 21:48:26 +0000831let Defs = [AX,DX,EFLAGS], Uses = [AX,DX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000832def IDIV16m: I<0xF7, MRM7m, (outs), (ins i16mem:$src), // DX:AX/[mem16] = AX,DX
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000833 "idiv{w}\t$src", []>, OpSize;
Evan Cheng55687072007-09-14 21:48:26 +0000834let Defs = [EAX,EDX,EFLAGS], Uses = [EAX,EDX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000835def IDIV32m: I<0xF7, MRM7m, (outs), (ins i32mem:$src), // EDX:EAX/[mem32] = EAX,EDX
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000836 "idiv{l}\t$src", []>;
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000837}
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000838
839//===----------------------------------------------------------------------===//
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000840// Two address Instructions.
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000841//
842let isTwoAddress = 1 in {
843
844// Conditional moves
Evan Cheng950aac02007-09-25 01:57:46 +0000845let Uses = [EFLAGS] in {
Evan Cheng926658c2007-10-05 23:13:21 +0000846let isCommutable = 1 in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000847def CMOVB16rr : I<0x42, MRMSrcReg, // if <u, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +0000848 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000849 "cmovb\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000850 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000851 X86_COND_B, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000852 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000853def CMOVB32rr : I<0x42, MRMSrcReg, // if <u, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +0000854 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000855 "cmovb\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000856 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000857 X86_COND_B, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000858 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000859def CMOVAE16rr: I<0x43, MRMSrcReg, // if >=u, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +0000860 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000861 "cmovae\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000862 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000863 X86_COND_AE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000864 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000865def CMOVAE32rr: I<0x43, MRMSrcReg, // if >=u, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +0000866 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000867 "cmovae\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000868 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000869 X86_COND_AE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000870 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000871def CMOVE16rr : I<0x44, MRMSrcReg, // if ==, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +0000872 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000873 "cmove\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000874 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000875 X86_COND_E, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000876 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000877def CMOVE32rr : I<0x44, MRMSrcReg, // if ==, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +0000878 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000879 "cmove\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000880 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000881 X86_COND_E, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000882 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000883def CMOVNE16rr: I<0x45, MRMSrcReg, // if !=, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +0000884 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000885 "cmovne\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000886 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000887 X86_COND_NE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000888 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000889def CMOVNE32rr: I<0x45, MRMSrcReg, // if !=, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +0000890 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000891 "cmovne\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000892 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000893 X86_COND_NE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000894 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000895def CMOVBE16rr: I<0x46, MRMSrcReg, // if <=u, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +0000896 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000897 "cmovbe\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000898 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000899 X86_COND_BE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000900 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000901def CMOVBE32rr: I<0x46, MRMSrcReg, // if <=u, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +0000902 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000903 "cmovbe\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000904 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000905 X86_COND_BE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000906 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000907def CMOVA16rr : I<0x47, MRMSrcReg, // if >u, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +0000908 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000909 "cmova\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000910 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000911 X86_COND_A, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000912 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000913def CMOVA32rr : I<0x47, MRMSrcReg, // if >u, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +0000914 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000915 "cmova\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000916 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000917 X86_COND_A, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000918 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000919def CMOVL16rr : I<0x4C, MRMSrcReg, // if <s, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +0000920 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000921 "cmovl\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000922 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000923 X86_COND_L, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000924 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000925def CMOVL32rr : I<0x4C, MRMSrcReg, // if <s, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +0000926 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000927 "cmovl\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000928 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000929 X86_COND_L, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000930 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000931def CMOVGE16rr: I<0x4D, MRMSrcReg, // if >=s, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +0000932 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000933 "cmovge\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000934 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000935 X86_COND_GE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000936 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000937def CMOVGE32rr: I<0x4D, MRMSrcReg, // if >=s, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +0000938 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000939 "cmovge\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000940 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000941 X86_COND_GE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000942 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000943def CMOVLE16rr: I<0x4E, MRMSrcReg, // if <=s, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +0000944 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000945 "cmovle\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000946 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000947 X86_COND_LE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000948 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000949def CMOVLE32rr: I<0x4E, MRMSrcReg, // if <=s, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +0000950 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000951 "cmovle\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000952 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000953 X86_COND_LE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000954 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000955def CMOVG16rr : I<0x4F, MRMSrcReg, // if >s, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +0000956 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000957 "cmovg\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000958 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000959 X86_COND_G, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000960 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000961def CMOVG32rr : I<0x4F, MRMSrcReg, // if >s, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +0000962 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000963 "cmovg\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000964 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000965 X86_COND_G, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000966 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000967def CMOVS16rr : I<0x48, MRMSrcReg, // if signed, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +0000968 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000969 "cmovs\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000970 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000971 X86_COND_S, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000972 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000973def CMOVS32rr : I<0x48, MRMSrcReg, // if signed, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +0000974 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000975 "cmovs\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000976 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000977 X86_COND_S, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000978 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000979def CMOVNS16rr: I<0x49, MRMSrcReg, // if !signed, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +0000980 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000981 "cmovns\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000982 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000983 X86_COND_NS, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000984 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000985def CMOVNS32rr: I<0x49, MRMSrcReg, // if !signed, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +0000986 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000987 "cmovns\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000988 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000989 X86_COND_NS, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000990 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000991def CMOVP16rr : I<0x4A, MRMSrcReg, // if parity, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +0000992 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000993 "cmovp\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000994 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000995 X86_COND_P, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000996 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000997def CMOVP32rr : I<0x4A, MRMSrcReg, // if parity, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +0000998 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000999 "cmovp\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001000 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001001 X86_COND_P, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001002 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001003def CMOVNP16rr : I<0x4B, MRMSrcReg, // if !parity, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +00001004 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001005 "cmovnp\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001006 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001007 X86_COND_NP, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001008 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001009def CMOVNP32rr : I<0x4B, MRMSrcReg, // if !parity, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +00001010 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001011 "cmovnp\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001012 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001013 X86_COND_NP, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001014 TB;
Dan Gohman12fd4d72009-01-07 00:35:10 +00001015def CMOVO16rr : I<0x40, MRMSrcReg, // if overflow, GR16 = GR16
1016 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
1017 "cmovo\t{$src2, $dst|$dst, $src2}",
1018 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
1019 X86_COND_O, EFLAGS))]>,
1020 TB, OpSize;
1021def CMOVO32rr : I<0x40, MRMSrcReg, // if overflow, GR32 = GR32
1022 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
1023 "cmovo\t{$src2, $dst|$dst, $src2}",
1024 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
1025 X86_COND_O, EFLAGS))]>,
Evan Cheng950aac02007-09-25 01:57:46 +00001026 TB;
Dan Gohman12fd4d72009-01-07 00:35:10 +00001027def CMOVNO16rr : I<0x41, MRMSrcReg, // if !overflow, GR16 = GR16
1028 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
1029 "cmovno\t{$src2, $dst|$dst, $src2}",
1030 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
1031 X86_COND_NO, EFLAGS))]>,
1032 TB, OpSize;
1033def CMOVNO32rr : I<0x41, MRMSrcReg, // if !overflow, GR32 = GR32
1034 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
1035 "cmovno\t{$src2, $dst|$dst, $src2}",
1036 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
1037 X86_COND_NO, EFLAGS))]>,
1038 TB;
1039} // isCommutable = 1
Evan Cheng926658c2007-10-05 23:13:21 +00001040
1041def CMOVB16rm : I<0x42, MRMSrcMem, // if <u, GR16 = [mem16]
1042 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1043 "cmovb\t{$src2, $dst|$dst, $src2}",
1044 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1045 X86_COND_B, EFLAGS))]>,
1046 TB, OpSize;
1047def CMOVB32rm : I<0x42, MRMSrcMem, // if <u, GR32 = [mem32]
1048 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1049 "cmovb\t{$src2, $dst|$dst, $src2}",
1050 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1051 X86_COND_B, EFLAGS))]>,
1052 TB;
1053def CMOVAE16rm: I<0x43, MRMSrcMem, // if >=u, GR16 = [mem16]
1054 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1055 "cmovae\t{$src2, $dst|$dst, $src2}",
1056 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1057 X86_COND_AE, EFLAGS))]>,
1058 TB, OpSize;
1059def CMOVAE32rm: I<0x43, MRMSrcMem, // if >=u, GR32 = [mem32]
1060 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1061 "cmovae\t{$src2, $dst|$dst, $src2}",
1062 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1063 X86_COND_AE, EFLAGS))]>,
1064 TB;
1065def CMOVE16rm : I<0x44, MRMSrcMem, // if ==, GR16 = [mem16]
1066 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1067 "cmove\t{$src2, $dst|$dst, $src2}",
1068 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1069 X86_COND_E, EFLAGS))]>,
1070 TB, OpSize;
1071def CMOVE32rm : I<0x44, MRMSrcMem, // if ==, GR32 = [mem32]
1072 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1073 "cmove\t{$src2, $dst|$dst, $src2}",
1074 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1075 X86_COND_E, EFLAGS))]>,
1076 TB;
1077def CMOVNE16rm: I<0x45, MRMSrcMem, // if !=, GR16 = [mem16]
1078 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1079 "cmovne\t{$src2, $dst|$dst, $src2}",
1080 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1081 X86_COND_NE, EFLAGS))]>,
1082 TB, OpSize;
1083def CMOVNE32rm: I<0x45, MRMSrcMem, // if !=, GR32 = [mem32]
1084 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1085 "cmovne\t{$src2, $dst|$dst, $src2}",
1086 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1087 X86_COND_NE, EFLAGS))]>,
1088 TB;
1089def CMOVBE16rm: I<0x46, MRMSrcMem, // if <=u, GR16 = [mem16]
1090 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1091 "cmovbe\t{$src2, $dst|$dst, $src2}",
1092 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1093 X86_COND_BE, EFLAGS))]>,
1094 TB, OpSize;
1095def CMOVBE32rm: I<0x46, MRMSrcMem, // if <=u, GR32 = [mem32]
1096 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1097 "cmovbe\t{$src2, $dst|$dst, $src2}",
1098 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1099 X86_COND_BE, EFLAGS))]>,
1100 TB;
1101def CMOVA16rm : I<0x47, MRMSrcMem, // if >u, GR16 = [mem16]
1102 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1103 "cmova\t{$src2, $dst|$dst, $src2}",
1104 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1105 X86_COND_A, EFLAGS))]>,
1106 TB, OpSize;
1107def CMOVA32rm : I<0x47, MRMSrcMem, // if >u, GR32 = [mem32]
1108 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1109 "cmova\t{$src2, $dst|$dst, $src2}",
1110 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1111 X86_COND_A, EFLAGS))]>,
1112 TB;
1113def CMOVL16rm : I<0x4C, MRMSrcMem, // if <s, GR16 = [mem16]
1114 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1115 "cmovl\t{$src2, $dst|$dst, $src2}",
1116 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1117 X86_COND_L, EFLAGS))]>,
1118 TB, OpSize;
1119def CMOVL32rm : I<0x4C, MRMSrcMem, // if <s, GR32 = [mem32]
1120 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1121 "cmovl\t{$src2, $dst|$dst, $src2}",
1122 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1123 X86_COND_L, EFLAGS))]>,
1124 TB;
1125def CMOVGE16rm: I<0x4D, MRMSrcMem, // if >=s, GR16 = [mem16]
1126 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1127 "cmovge\t{$src2, $dst|$dst, $src2}",
1128 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1129 X86_COND_GE, EFLAGS))]>,
1130 TB, OpSize;
1131def CMOVGE32rm: I<0x4D, MRMSrcMem, // if >=s, GR32 = [mem32]
1132 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1133 "cmovge\t{$src2, $dst|$dst, $src2}",
1134 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1135 X86_COND_GE, EFLAGS))]>,
1136 TB;
1137def CMOVLE16rm: I<0x4E, MRMSrcMem, // if <=s, GR16 = [mem16]
1138 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1139 "cmovle\t{$src2, $dst|$dst, $src2}",
1140 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1141 X86_COND_LE, EFLAGS))]>,
1142 TB, OpSize;
1143def CMOVLE32rm: I<0x4E, MRMSrcMem, // if <=s, GR32 = [mem32]
1144 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1145 "cmovle\t{$src2, $dst|$dst, $src2}",
1146 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1147 X86_COND_LE, EFLAGS))]>,
1148 TB;
1149def CMOVG16rm : I<0x4F, MRMSrcMem, // if >s, GR16 = [mem16]
1150 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1151 "cmovg\t{$src2, $dst|$dst, $src2}",
1152 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1153 X86_COND_G, EFLAGS))]>,
1154 TB, OpSize;
1155def CMOVG32rm : I<0x4F, MRMSrcMem, // if >s, GR32 = [mem32]
1156 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1157 "cmovg\t{$src2, $dst|$dst, $src2}",
1158 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1159 X86_COND_G, EFLAGS))]>,
1160 TB;
1161def CMOVS16rm : I<0x48, MRMSrcMem, // if signed, GR16 = [mem16]
1162 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1163 "cmovs\t{$src2, $dst|$dst, $src2}",
1164 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1165 X86_COND_S, EFLAGS))]>,
1166 TB, OpSize;
1167def CMOVS32rm : I<0x48, MRMSrcMem, // if signed, GR32 = [mem32]
1168 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1169 "cmovs\t{$src2, $dst|$dst, $src2}",
1170 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1171 X86_COND_S, EFLAGS))]>,
1172 TB;
1173def CMOVNS16rm: I<0x49, MRMSrcMem, // if !signed, GR16 = [mem16]
1174 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1175 "cmovns\t{$src2, $dst|$dst, $src2}",
1176 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1177 X86_COND_NS, EFLAGS))]>,
1178 TB, OpSize;
1179def CMOVNS32rm: I<0x49, MRMSrcMem, // if !signed, GR32 = [mem32]
1180 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1181 "cmovns\t{$src2, $dst|$dst, $src2}",
1182 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1183 X86_COND_NS, EFLAGS))]>,
1184 TB;
1185def CMOVP16rm : I<0x4A, MRMSrcMem, // if parity, GR16 = [mem16]
1186 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1187 "cmovp\t{$src2, $dst|$dst, $src2}",
1188 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1189 X86_COND_P, EFLAGS))]>,
1190 TB, OpSize;
1191def CMOVP32rm : I<0x4A, MRMSrcMem, // if parity, GR32 = [mem32]
1192 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1193 "cmovp\t{$src2, $dst|$dst, $src2}",
1194 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1195 X86_COND_P, EFLAGS))]>,
1196 TB;
1197def CMOVNP16rm : I<0x4B, MRMSrcMem, // if !parity, GR16 = [mem16]
1198 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1199 "cmovnp\t{$src2, $dst|$dst, $src2}",
1200 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1201 X86_COND_NP, EFLAGS))]>,
1202 TB, OpSize;
Dan Gohman12fd4d72009-01-07 00:35:10 +00001203def CMOVNP32rm : I<0x4B, MRMSrcMem, // if !parity, GR32 = [mem32]
1204 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1205 "cmovnp\t{$src2, $dst|$dst, $src2}",
1206 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1207 X86_COND_NP, EFLAGS))]>,
1208 TB;
1209def CMOVO16rm : I<0x40, MRMSrcMem, // if overflow, GR16 = [mem16]
1210 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1211 "cmovo\t{$src2, $dst|$dst, $src2}",
1212 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1213 X86_COND_O, EFLAGS))]>,
1214 TB, OpSize;
1215def CMOVO32rm : I<0x40, MRMSrcMem, // if overflow, GR32 = [mem32]
1216 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1217 "cmovo\t{$src2, $dst|$dst, $src2}",
1218 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1219 X86_COND_O, EFLAGS))]>,
1220 TB;
1221def CMOVNO16rm : I<0x41, MRMSrcMem, // if !overflow, GR16 = [mem16]
1222 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1223 "cmovno\t{$src2, $dst|$dst, $src2}",
1224 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1225 X86_COND_NO, EFLAGS))]>,
1226 TB, OpSize;
1227def CMOVNO32rm : I<0x41, MRMSrcMem, // if !overflow, GR32 = [mem32]
1228 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1229 "cmovno\t{$src2, $dst|$dst, $src2}",
1230 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1231 X86_COND_NO, EFLAGS))]>,
1232 TB;
Evan Cheng950aac02007-09-25 01:57:46 +00001233} // Uses = [EFLAGS]
1234
1235
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001236// unary instructions
1237let CodeSize = 2 in {
Evan Cheng55687072007-09-14 21:48:26 +00001238let Defs = [EFLAGS] in {
Dan Gohman91888f02007-07-31 20:11:57 +00001239def NEG8r : I<0xF6, MRM3r, (outs GR8 :$dst), (ins GR8 :$src), "neg{b}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001240 [(set GR8:$dst, (ineg GR8:$src)),
1241 (implicit EFLAGS)]>;
Dan Gohman91888f02007-07-31 20:11:57 +00001242def NEG16r : I<0xF7, MRM3r, (outs GR16:$dst), (ins GR16:$src), "neg{w}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001243 [(set GR16:$dst, (ineg GR16:$src)),
1244 (implicit EFLAGS)]>, OpSize;
Dan Gohman91888f02007-07-31 20:11:57 +00001245def NEG32r : I<0xF7, MRM3r, (outs GR32:$dst), (ins GR32:$src), "neg{l}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001246 [(set GR32:$dst, (ineg GR32:$src)),
1247 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001248let isTwoAddress = 0 in {
Dan Gohman91888f02007-07-31 20:11:57 +00001249 def NEG8m : I<0xF6, MRM3m, (outs), (ins i8mem :$dst), "neg{b}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001250 [(store (ineg (loadi8 addr:$dst)), addr:$dst),
1251 (implicit EFLAGS)]>;
Dan Gohman91888f02007-07-31 20:11:57 +00001252 def NEG16m : I<0xF7, MRM3m, (outs), (ins i16mem:$dst), "neg{w}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001253 [(store (ineg (loadi16 addr:$dst)), addr:$dst),
1254 (implicit EFLAGS)]>, OpSize;
Dan Gohman91888f02007-07-31 20:11:57 +00001255 def NEG32m : I<0xF7, MRM3m, (outs), (ins i32mem:$dst), "neg{l}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001256 [(store (ineg (loadi32 addr:$dst)), addr:$dst),
1257 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001258}
Evan Cheng55687072007-09-14 21:48:26 +00001259} // Defs = [EFLAGS]
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001260
Evan Chengc6cee682009-01-21 02:09:05 +00001261// Match xor -1 to not. Favors these over a move imm + xor to save code size.
1262let AddedComplexity = 15 in {
Dan Gohman91888f02007-07-31 20:11:57 +00001263def NOT8r : I<0xF6, MRM2r, (outs GR8 :$dst), (ins GR8 :$src), "not{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001264 [(set GR8:$dst, (not GR8:$src))]>;
Dan Gohman91888f02007-07-31 20:11:57 +00001265def NOT16r : I<0xF7, MRM2r, (outs GR16:$dst), (ins GR16:$src), "not{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001266 [(set GR16:$dst, (not GR16:$src))]>, OpSize;
Dan Gohman91888f02007-07-31 20:11:57 +00001267def NOT32r : I<0xF7, MRM2r, (outs GR32:$dst), (ins GR32:$src), "not{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001268 [(set GR32:$dst, (not GR32:$src))]>;
Evan Chengc6cee682009-01-21 02:09:05 +00001269}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001270let isTwoAddress = 0 in {
Dan Gohman91888f02007-07-31 20:11:57 +00001271 def NOT8m : I<0xF6, MRM2m, (outs), (ins i8mem :$dst), "not{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001272 [(store (not (loadi8 addr:$dst)), addr:$dst)]>;
Dan Gohman91888f02007-07-31 20:11:57 +00001273 def NOT16m : I<0xF7, MRM2m, (outs), (ins i16mem:$dst), "not{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001274 [(store (not (loadi16 addr:$dst)), addr:$dst)]>, OpSize;
Dan Gohman91888f02007-07-31 20:11:57 +00001275 def NOT32m : I<0xF7, MRM2m, (outs), (ins i32mem:$dst), "not{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001276 [(store (not (loadi32 addr:$dst)), addr:$dst)]>;
1277}
1278} // CodeSize
1279
1280// TODO: inc/dec is slow for P4, but fast for Pentium-M.
Evan Cheng55687072007-09-14 21:48:26 +00001281let Defs = [EFLAGS] in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001282let CodeSize = 2 in
Dan Gohman91888f02007-07-31 20:11:57 +00001283def INC8r : I<0xFE, MRM0r, (outs GR8 :$dst), (ins GR8 :$src), "inc{b}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001284 [(set GR8:$dst, (add GR8:$src, 1)),
1285 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001286let isConvertibleToThreeAddress = 1, CodeSize = 1 in { // Can xform into LEA.
Dan Gohman91888f02007-07-31 20:11:57 +00001287def INC16r : I<0x40, AddRegFrm, (outs GR16:$dst), (ins GR16:$src), "inc{w}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001288 [(set GR16:$dst, (add GR16:$src, 1)),
1289 (implicit EFLAGS)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001290 OpSize, Requires<[In32BitMode]>;
Dan Gohman91888f02007-07-31 20:11:57 +00001291def INC32r : I<0x40, AddRegFrm, (outs GR32:$dst), (ins GR32:$src), "inc{l}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001292 [(set GR32:$dst, (add GR32:$src, 1)),
1293 (implicit EFLAGS)]>, Requires<[In32BitMode]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001294}
1295let isTwoAddress = 0, CodeSize = 2 in {
Dan Gohman91888f02007-07-31 20:11:57 +00001296 def INC8m : I<0xFE, MRM0m, (outs), (ins i8mem :$dst), "inc{b}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001297 [(store (add (loadi8 addr:$dst), 1), addr:$dst),
1298 (implicit EFLAGS)]>;
Dan Gohman91888f02007-07-31 20:11:57 +00001299 def INC16m : I<0xFF, MRM0m, (outs), (ins i16mem:$dst), "inc{w}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001300 [(store (add (loadi16 addr:$dst), 1), addr:$dst),
1301 (implicit EFLAGS)]>,
Evan Cheng4a7e72f2007-10-19 21:23:22 +00001302 OpSize, Requires<[In32BitMode]>;
Dan Gohman91888f02007-07-31 20:11:57 +00001303 def INC32m : I<0xFF, MRM0m, (outs), (ins i32mem:$dst), "inc{l}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001304 [(store (add (loadi32 addr:$dst), 1), addr:$dst),
1305 (implicit EFLAGS)]>,
Evan Cheng4a7e72f2007-10-19 21:23:22 +00001306 Requires<[In32BitMode]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001307}
1308
1309let CodeSize = 2 in
Dan Gohman91888f02007-07-31 20:11:57 +00001310def DEC8r : I<0xFE, MRM1r, (outs GR8 :$dst), (ins GR8 :$src), "dec{b}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001311 [(set GR8:$dst, (add GR8:$src, -1)),
1312 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001313let isConvertibleToThreeAddress = 1, CodeSize = 1 in { // Can xform into LEA.
Dan Gohman91888f02007-07-31 20:11:57 +00001314def DEC16r : I<0x48, AddRegFrm, (outs GR16:$dst), (ins GR16:$src), "dec{w}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001315 [(set GR16:$dst, (add GR16:$src, -1)),
1316 (implicit EFLAGS)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001317 OpSize, Requires<[In32BitMode]>;
Dan Gohman91888f02007-07-31 20:11:57 +00001318def DEC32r : I<0x48, AddRegFrm, (outs GR32:$dst), (ins GR32:$src), "dec{l}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001319 [(set GR32:$dst, (add GR32:$src, -1)),
1320 (implicit EFLAGS)]>, Requires<[In32BitMode]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001321}
1322
1323let isTwoAddress = 0, CodeSize = 2 in {
Dan Gohman91888f02007-07-31 20:11:57 +00001324 def DEC8m : I<0xFE, MRM1m, (outs), (ins i8mem :$dst), "dec{b}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001325 [(store (add (loadi8 addr:$dst), -1), addr:$dst),
1326 (implicit EFLAGS)]>;
Dan Gohman91888f02007-07-31 20:11:57 +00001327 def DEC16m : I<0xFF, MRM1m, (outs), (ins i16mem:$dst), "dec{w}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001328 [(store (add (loadi16 addr:$dst), -1), addr:$dst),
1329 (implicit EFLAGS)]>,
Evan Cheng4a7e72f2007-10-19 21:23:22 +00001330 OpSize, Requires<[In32BitMode]>;
Dan Gohman91888f02007-07-31 20:11:57 +00001331 def DEC32m : I<0xFF, MRM1m, (outs), (ins i32mem:$dst), "dec{l}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001332 [(store (add (loadi32 addr:$dst), -1), addr:$dst),
1333 (implicit EFLAGS)]>,
Evan Cheng4a7e72f2007-10-19 21:23:22 +00001334 Requires<[In32BitMode]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001335}
Evan Cheng55687072007-09-14 21:48:26 +00001336} // Defs = [EFLAGS]
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001337
1338// Logical operators...
Evan Cheng55687072007-09-14 21:48:26 +00001339let Defs = [EFLAGS] in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001340let isCommutable = 1 in { // X = AND Y, Z --> X = AND Z, Y
1341def AND8rr : I<0x20, MRMDestReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001342 (outs GR8 :$dst), (ins GR8 :$src1, GR8 :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001343 "and{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001344 [(set GR8:$dst, (and GR8:$src1, GR8:$src2)),
1345 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001346def AND16rr : I<0x21, MRMDestReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001347 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001348 "and{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001349 [(set GR16:$dst, (and GR16:$src1, GR16:$src2)),
1350 (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001351def AND32rr : I<0x21, MRMDestReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001352 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001353 "and{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001354 [(set GR32:$dst, (and GR32:$src1, GR32:$src2)),
1355 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001356}
1357
1358def AND8rm : I<0x22, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001359 (outs GR8 :$dst), (ins GR8 :$src1, i8mem :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001360 "and{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001361 [(set GR8:$dst, (and GR8:$src1, (load addr:$src2))),
1362 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001363def AND16rm : I<0x23, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001364 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001365 "and{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001366 [(set GR16:$dst, (and GR16:$src1, (load addr:$src2))),
1367 (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001368def AND32rm : I<0x23, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001369 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001370 "and{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001371 [(set GR32:$dst, (and GR32:$src1, (load addr:$src2))),
1372 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001373
1374def AND8ri : Ii8<0x80, MRM4r,
Evan Chengb783fa32007-07-19 01:14:50 +00001375 (outs GR8 :$dst), (ins GR8 :$src1, i8imm :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001376 "and{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001377 [(set GR8:$dst, (and GR8:$src1, imm:$src2)),
1378 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001379def AND16ri : Ii16<0x81, MRM4r,
Evan Chengb783fa32007-07-19 01:14:50 +00001380 (outs GR16:$dst), (ins GR16:$src1, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001381 "and{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001382 [(set GR16:$dst, (and GR16:$src1, imm:$src2)),
1383 (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001384def AND32ri : Ii32<0x81, MRM4r,
Evan Chengb783fa32007-07-19 01:14:50 +00001385 (outs GR32:$dst), (ins GR32:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001386 "and{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001387 [(set GR32:$dst, (and GR32:$src1, imm:$src2)),
1388 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001389def AND16ri8 : Ii8<0x83, MRM4r,
Evan Chengb783fa32007-07-19 01:14:50 +00001390 (outs GR16:$dst), (ins GR16:$src1, i16i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001391 "and{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001392 [(set GR16:$dst, (and GR16:$src1, i16immSExt8:$src2)),
1393 (implicit EFLAGS)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001394 OpSize;
1395def AND32ri8 : Ii8<0x83, MRM4r,
Evan Chengb783fa32007-07-19 01:14:50 +00001396 (outs GR32:$dst), (ins GR32:$src1, i32i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001397 "and{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001398 [(set GR32:$dst, (and GR32:$src1, i32immSExt8:$src2)),
1399 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001400
1401let isTwoAddress = 0 in {
1402 def AND8mr : I<0x20, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001403 (outs), (ins i8mem :$dst, GR8 :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001404 "and{b}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001405 [(store (and (load addr:$dst), GR8:$src), addr:$dst),
1406 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001407 def AND16mr : I<0x21, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001408 (outs), (ins i16mem:$dst, GR16:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001409 "and{w}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001410 [(store (and (load addr:$dst), GR16:$src), addr:$dst),
1411 (implicit EFLAGS)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001412 OpSize;
1413 def AND32mr : I<0x21, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001414 (outs), (ins i32mem:$dst, GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001415 "and{l}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001416 [(store (and (load addr:$dst), GR32:$src), addr:$dst),
1417 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001418 def AND8mi : Ii8<0x80, MRM4m,
Evan Chengb783fa32007-07-19 01:14:50 +00001419 (outs), (ins i8mem :$dst, i8imm :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001420 "and{b}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001421 [(store (and (loadi8 addr:$dst), imm:$src), addr:$dst),
1422 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001423 def AND16mi : Ii16<0x81, MRM4m,
Evan Chengb783fa32007-07-19 01:14:50 +00001424 (outs), (ins i16mem:$dst, i16imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001425 "and{w}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001426 [(store (and (loadi16 addr:$dst), imm:$src), addr:$dst),
1427 (implicit EFLAGS)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001428 OpSize;
1429 def AND32mi : Ii32<0x81, MRM4m,
Evan Chengb783fa32007-07-19 01:14:50 +00001430 (outs), (ins i32mem:$dst, i32imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001431 "and{l}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001432 [(store (and (loadi32 addr:$dst), imm:$src), addr:$dst),
1433 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001434 def AND16mi8 : Ii8<0x83, MRM4m,
Evan Chengb783fa32007-07-19 01:14:50 +00001435 (outs), (ins i16mem:$dst, i16i8imm :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001436 "and{w}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001437 [(store (and (load addr:$dst), i16immSExt8:$src), addr:$dst),
1438 (implicit EFLAGS)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001439 OpSize;
1440 def AND32mi8 : Ii8<0x83, MRM4m,
Evan Chengb783fa32007-07-19 01:14:50 +00001441 (outs), (ins i32mem:$dst, i32i8imm :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001442 "and{l}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001443 [(store (and (load addr:$dst), i32immSExt8:$src), addr:$dst),
1444 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001445}
1446
1447
1448let isCommutable = 1 in { // X = OR Y, Z --> X = OR Z, Y
Evan Chengb783fa32007-07-19 01:14:50 +00001449def OR8rr : I<0x08, MRMDestReg, (outs GR8 :$dst), (ins GR8 :$src1, GR8 :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001450 "or{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001451 [(set GR8:$dst, (or GR8:$src1, GR8:$src2)),
1452 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001453def OR16rr : I<0x09, MRMDestReg, (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001454 "or{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001455 [(set GR16:$dst, (or GR16:$src1, GR16:$src2)),
1456 (implicit EFLAGS)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001457def OR32rr : I<0x09, MRMDestReg, (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001458 "or{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001459 [(set GR32:$dst, (or GR32:$src1, GR32:$src2)),
1460 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001461}
Evan Chengb783fa32007-07-19 01:14:50 +00001462def OR8rm : I<0x0A, MRMSrcMem , (outs GR8 :$dst), (ins GR8 :$src1, i8mem :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001463 "or{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001464 [(set GR8:$dst, (or GR8:$src1, (load addr:$src2))),
1465 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001466def OR16rm : I<0x0B, MRMSrcMem , (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001467 "or{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001468 [(set GR16:$dst, (or GR16:$src1, (load addr:$src2))),
1469 (implicit EFLAGS)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001470def OR32rm : I<0x0B, MRMSrcMem , (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001471 "or{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001472 [(set GR32:$dst, (or GR32:$src1, (load addr:$src2))),
1473 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001474
Evan Chengb783fa32007-07-19 01:14:50 +00001475def OR8ri : Ii8 <0x80, MRM1r, (outs GR8 :$dst), (ins GR8 :$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001476 "or{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001477 [(set GR8:$dst, (or GR8:$src1, imm:$src2)),
1478 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001479def OR16ri : Ii16<0x81, MRM1r, (outs GR16:$dst), (ins GR16:$src1, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001480 "or{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001481 [(set GR16:$dst, (or GR16:$src1, imm:$src2)),
1482 (implicit EFLAGS)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001483def OR32ri : Ii32<0x81, MRM1r, (outs GR32:$dst), (ins GR32:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001484 "or{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001485 [(set GR32:$dst, (or GR32:$src1, imm:$src2)),
1486 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001487
Evan Chengb783fa32007-07-19 01:14:50 +00001488def OR16ri8 : Ii8<0x83, MRM1r, (outs GR16:$dst), (ins GR16:$src1, i16i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001489 "or{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001490 [(set GR16:$dst, (or GR16:$src1, i16immSExt8:$src2)),
1491 (implicit EFLAGS)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001492def OR32ri8 : Ii8<0x83, MRM1r, (outs GR32:$dst), (ins GR32:$src1, i32i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001493 "or{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001494 [(set GR32:$dst, (or GR32:$src1, i32immSExt8:$src2)),
1495 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001496let isTwoAddress = 0 in {
Evan Chengb783fa32007-07-19 01:14:50 +00001497 def OR8mr : I<0x08, MRMDestMem, (outs), (ins i8mem:$dst, GR8:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001498 "or{b}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001499 [(store (or (load addr:$dst), GR8:$src), addr:$dst),
1500 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001501 def OR16mr : I<0x09, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001502 "or{w}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001503 [(store (or (load addr:$dst), GR16:$src), addr:$dst),
1504 (implicit EFLAGS)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001505 def OR32mr : I<0x09, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001506 "or{l}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001507 [(store (or (load addr:$dst), GR32:$src), addr:$dst),
1508 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001509 def OR8mi : Ii8<0x80, MRM1m, (outs), (ins i8mem :$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001510 "or{b}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001511 [(store (or (loadi8 addr:$dst), imm:$src), addr:$dst),
1512 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001513 def OR16mi : Ii16<0x81, MRM1m, (outs), (ins i16mem:$dst, i16imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001514 "or{w}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001515 [(store (or (loadi16 addr:$dst), imm:$src), addr:$dst),
1516 (implicit EFLAGS)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001517 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001518 def OR32mi : Ii32<0x81, MRM1m, (outs), (ins i32mem:$dst, i32imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001519 "or{l}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001520 [(store (or (loadi32 addr:$dst), imm:$src), addr:$dst),
1521 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001522 def OR16mi8 : Ii8<0x83, MRM1m, (outs), (ins i16mem:$dst, i16i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001523 "or{w}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001524 [(store (or (load addr:$dst), i16immSExt8:$src), addr:$dst),
1525 (implicit EFLAGS)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001526 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001527 def OR32mi8 : Ii8<0x83, MRM1m, (outs), (ins i32mem:$dst, i32i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001528 "or{l}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001529 [(store (or (load addr:$dst), i32immSExt8:$src), addr:$dst),
1530 (implicit EFLAGS)]>;
Bill Wendlingba5d5b02008-05-29 01:02:09 +00001531} // isTwoAddress = 0
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001532
1533
Evan Cheng6f26e8b2008-06-18 08:13:07 +00001534let isCommutable = 1 in { // X = XOR Y, Z --> X = XOR Z, Y
Bill Wendlingba5d5b02008-05-29 01:02:09 +00001535 def XOR8rr : I<0x30, MRMDestReg,
1536 (outs GR8 :$dst), (ins GR8 :$src1, GR8 :$src2),
1537 "xor{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001538 [(set GR8:$dst, (xor GR8:$src1, GR8:$src2)),
1539 (implicit EFLAGS)]>;
Bill Wendlingba5d5b02008-05-29 01:02:09 +00001540 def XOR16rr : I<0x31, MRMDestReg,
1541 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
1542 "xor{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001543 [(set GR16:$dst, (xor GR16:$src1, GR16:$src2)),
1544 (implicit EFLAGS)]>, OpSize;
Bill Wendlingba5d5b02008-05-29 01:02:09 +00001545 def XOR32rr : I<0x31, MRMDestReg,
1546 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
1547 "xor{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001548 [(set GR32:$dst, (xor GR32:$src1, GR32:$src2)),
1549 (implicit EFLAGS)]>;
Evan Cheng6f26e8b2008-06-18 08:13:07 +00001550} // isCommutable = 1
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001551
1552def XOR8rm : I<0x32, MRMSrcMem ,
Evan Chengb783fa32007-07-19 01:14:50 +00001553 (outs GR8 :$dst), (ins GR8:$src1, i8mem :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001554 "xor{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001555 [(set GR8:$dst, (xor GR8:$src1, (load addr:$src2))),
1556 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001557def XOR16rm : I<0x33, MRMSrcMem ,
Evan Chengb783fa32007-07-19 01:14:50 +00001558 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001559 "xor{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001560 [(set GR16:$dst, (xor GR16:$src1, (load addr:$src2))),
1561 (implicit EFLAGS)]>,
Bill Wendlingba5d5b02008-05-29 01:02:09 +00001562 OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001563def XOR32rm : I<0x33, MRMSrcMem ,
Evan Chengb783fa32007-07-19 01:14:50 +00001564 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001565 "xor{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001566 [(set GR32:$dst, (xor GR32:$src1, (load addr:$src2))),
1567 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001568
Bill Wendlingbac38eb2008-05-29 03:46:36 +00001569def XOR8ri : Ii8<0x80, MRM6r,
1570 (outs GR8:$dst), (ins GR8:$src1, i8imm:$src2),
1571 "xor{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001572 [(set GR8:$dst, (xor GR8:$src1, imm:$src2)),
1573 (implicit EFLAGS)]>;
Bill Wendlingbac38eb2008-05-29 03:46:36 +00001574def XOR16ri : Ii16<0x81, MRM6r,
1575 (outs GR16:$dst), (ins GR16:$src1, i16imm:$src2),
1576 "xor{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001577 [(set GR16:$dst, (xor GR16:$src1, imm:$src2)),
1578 (implicit EFLAGS)]>, OpSize;
Bill Wendlingbac38eb2008-05-29 03:46:36 +00001579def XOR32ri : Ii32<0x81, MRM6r,
1580 (outs GR32:$dst), (ins GR32:$src1, i32imm:$src2),
1581 "xor{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001582 [(set GR32:$dst, (xor GR32:$src1, imm:$src2)),
1583 (implicit EFLAGS)]>;
Bill Wendlingbac38eb2008-05-29 03:46:36 +00001584def XOR16ri8 : Ii8<0x83, MRM6r,
1585 (outs GR16:$dst), (ins GR16:$src1, i16i8imm:$src2),
1586 "xor{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001587 [(set GR16:$dst, (xor GR16:$src1, i16immSExt8:$src2)),
1588 (implicit EFLAGS)]>,
Bill Wendlingbac38eb2008-05-29 03:46:36 +00001589 OpSize;
1590def XOR32ri8 : Ii8<0x83, MRM6r,
1591 (outs GR32:$dst), (ins GR32:$src1, i32i8imm:$src2),
1592 "xor{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001593 [(set GR32:$dst, (xor GR32:$src1, i32immSExt8:$src2)),
1594 (implicit EFLAGS)]>;
Bill Wendlingba5d5b02008-05-29 01:02:09 +00001595
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001596let isTwoAddress = 0 in {
1597 def XOR8mr : I<0x30, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001598 (outs), (ins i8mem :$dst, GR8 :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001599 "xor{b}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001600 [(store (xor (load addr:$dst), GR8:$src), addr:$dst),
1601 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001602 def XOR16mr : I<0x31, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001603 (outs), (ins i16mem:$dst, GR16:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001604 "xor{w}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001605 [(store (xor (load addr:$dst), GR16:$src), addr:$dst),
1606 (implicit EFLAGS)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001607 OpSize;
1608 def XOR32mr : I<0x31, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001609 (outs), (ins i32mem:$dst, GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001610 "xor{l}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001611 [(store (xor (load addr:$dst), GR32:$src), addr:$dst),
1612 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001613 def XOR8mi : Ii8<0x80, MRM6m,
Evan Chengb783fa32007-07-19 01:14:50 +00001614 (outs), (ins i8mem :$dst, i8imm :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001615 "xor{b}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001616 [(store (xor (loadi8 addr:$dst), imm:$src), addr:$dst),
1617 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001618 def XOR16mi : Ii16<0x81, MRM6m,
Evan Chengb783fa32007-07-19 01:14:50 +00001619 (outs), (ins i16mem:$dst, i16imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001620 "xor{w}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001621 [(store (xor (loadi16 addr:$dst), imm:$src), addr:$dst),
1622 (implicit EFLAGS)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001623 OpSize;
1624 def XOR32mi : Ii32<0x81, MRM6m,
Evan Chengb783fa32007-07-19 01:14:50 +00001625 (outs), (ins i32mem:$dst, i32imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001626 "xor{l}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001627 [(store (xor (loadi32 addr:$dst), imm:$src), addr:$dst),
1628 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001629 def XOR16mi8 : Ii8<0x83, MRM6m,
Evan Chengb783fa32007-07-19 01:14:50 +00001630 (outs), (ins i16mem:$dst, i16i8imm :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001631 "xor{w}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001632 [(store (xor (load addr:$dst), i16immSExt8:$src), addr:$dst),
1633 (implicit EFLAGS)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001634 OpSize;
1635 def XOR32mi8 : Ii8<0x83, MRM6m,
Evan Chengb783fa32007-07-19 01:14:50 +00001636 (outs), (ins i32mem:$dst, i32i8imm :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001637 "xor{l}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001638 [(store (xor (load addr:$dst), i32immSExt8:$src), addr:$dst),
1639 (implicit EFLAGS)]>;
Bill Wendlingba5d5b02008-05-29 01:02:09 +00001640} // isTwoAddress = 0
Evan Cheng55687072007-09-14 21:48:26 +00001641} // Defs = [EFLAGS]
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001642
1643// Shift instructions
Evan Cheng55687072007-09-14 21:48:26 +00001644let Defs = [EFLAGS] in {
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001645let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00001646def SHL8rCL : I<0xD2, MRM4r, (outs GR8 :$dst), (ins GR8 :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001647 "shl{b}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001648 [(set GR8:$dst, (shl GR8:$src, CL))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001649def SHL16rCL : I<0xD3, MRM4r, (outs GR16:$dst), (ins GR16:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001650 "shl{w}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001651 [(set GR16:$dst, (shl GR16:$src, CL))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001652def SHL32rCL : I<0xD3, MRM4r, (outs GR32:$dst), (ins GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001653 "shl{l}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001654 [(set GR32:$dst, (shl GR32:$src, CL))]>;
Bill Wendlingba5d5b02008-05-29 01:02:09 +00001655} // Uses = [CL]
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001656
Evan Chengb783fa32007-07-19 01:14:50 +00001657def SHL8ri : Ii8<0xC0, MRM4r, (outs GR8 :$dst), (ins GR8 :$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001658 "shl{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001659 [(set GR8:$dst, (shl GR8:$src1, (i8 imm:$src2)))]>;
1660let isConvertibleToThreeAddress = 1 in { // Can transform into LEA.
Evan Chengb783fa32007-07-19 01:14:50 +00001661def SHL16ri : Ii8<0xC1, MRM4r, (outs GR16:$dst), (ins GR16:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001662 "shl{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001663 [(set GR16:$dst, (shl GR16:$src1, (i8 imm:$src2)))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001664def SHL32ri : Ii8<0xC1, MRM4r, (outs GR32:$dst), (ins GR32:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001665 "shl{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001666 [(set GR32:$dst, (shl GR32:$src1, (i8 imm:$src2)))]>;
Chris Lattnerf4005a82008-01-11 18:00:50 +00001667// NOTE: We don't use shifts of a register by one, because 'add reg,reg' is
1668// cheaper.
Bill Wendlingba5d5b02008-05-29 01:02:09 +00001669} // isConvertibleToThreeAddress = 1
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001670
1671let isTwoAddress = 0 in {
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001672 let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00001673 def SHL8mCL : I<0xD2, MRM4m, (outs), (ins i8mem :$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001674 "shl{b}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001675 [(store (shl (loadi8 addr:$dst), CL), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001676 def SHL16mCL : I<0xD3, MRM4m, (outs), (ins i16mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001677 "shl{w}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001678 [(store (shl (loadi16 addr:$dst), CL), addr:$dst)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001679 def SHL32mCL : I<0xD3, MRM4m, (outs), (ins i32mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001680 "shl{l}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001681 [(store (shl (loadi32 addr:$dst), CL), addr:$dst)]>;
1682 }
Evan Chengb783fa32007-07-19 01:14:50 +00001683 def SHL8mi : Ii8<0xC0, MRM4m, (outs), (ins i8mem :$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001684 "shl{b}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001685 [(store (shl (loadi8 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001686 def SHL16mi : Ii8<0xC1, MRM4m, (outs), (ins i16mem:$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001687 "shl{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001688 [(store (shl (loadi16 addr:$dst), (i8 imm:$src)), addr:$dst)]>,
1689 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001690 def SHL32mi : Ii8<0xC1, MRM4m, (outs), (ins i32mem:$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001691 "shl{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001692 [(store (shl (loadi32 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
1693
1694 // Shift by 1
Evan Chengb783fa32007-07-19 01:14:50 +00001695 def SHL8m1 : I<0xD0, MRM4m, (outs), (ins i8mem :$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001696 "shl{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001697 [(store (shl (loadi8 addr:$dst), (i8 1)), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001698 def SHL16m1 : I<0xD1, MRM4m, (outs), (ins i16mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001699 "shl{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001700 [(store (shl (loadi16 addr:$dst), (i8 1)), addr:$dst)]>,
1701 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001702 def SHL32m1 : I<0xD1, MRM4m, (outs), (ins i32mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001703 "shl{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001704 [(store (shl (loadi32 addr:$dst), (i8 1)), addr:$dst)]>;
1705}
1706
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001707let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00001708def SHR8rCL : I<0xD2, MRM5r, (outs GR8 :$dst), (ins GR8 :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001709 "shr{b}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001710 [(set GR8:$dst, (srl GR8:$src, CL))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001711def SHR16rCL : I<0xD3, MRM5r, (outs GR16:$dst), (ins GR16:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001712 "shr{w}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001713 [(set GR16:$dst, (srl GR16:$src, CL))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001714def SHR32rCL : I<0xD3, MRM5r, (outs GR32:$dst), (ins GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001715 "shr{l}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001716 [(set GR32:$dst, (srl GR32:$src, CL))]>;
1717}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001718
Evan Chengb783fa32007-07-19 01:14:50 +00001719def SHR8ri : Ii8<0xC0, MRM5r, (outs GR8:$dst), (ins GR8:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001720 "shr{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001721 [(set GR8:$dst, (srl GR8:$src1, (i8 imm:$src2)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001722def SHR16ri : Ii8<0xC1, MRM5r, (outs GR16:$dst), (ins GR16:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001723 "shr{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001724 [(set GR16:$dst, (srl GR16:$src1, (i8 imm:$src2)))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001725def SHR32ri : Ii8<0xC1, MRM5r, (outs GR32:$dst), (ins GR32:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001726 "shr{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001727 [(set GR32:$dst, (srl GR32:$src1, (i8 imm:$src2)))]>;
1728
1729// Shift by 1
Evan Chengb783fa32007-07-19 01:14:50 +00001730def SHR8r1 : I<0xD0, MRM5r, (outs GR8:$dst), (ins GR8:$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00001731 "shr{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001732 [(set GR8:$dst, (srl GR8:$src1, (i8 1)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001733def SHR16r1 : I<0xD1, MRM5r, (outs GR16:$dst), (ins GR16:$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00001734 "shr{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001735 [(set GR16:$dst, (srl GR16:$src1, (i8 1)))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001736def SHR32r1 : I<0xD1, MRM5r, (outs GR32:$dst), (ins GR32:$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00001737 "shr{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001738 [(set GR32:$dst, (srl GR32:$src1, (i8 1)))]>;
1739
1740let isTwoAddress = 0 in {
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001741 let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00001742 def SHR8mCL : I<0xD2, MRM5m, (outs), (ins i8mem :$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001743 "shr{b}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001744 [(store (srl (loadi8 addr:$dst), CL), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001745 def SHR16mCL : I<0xD3, MRM5m, (outs), (ins i16mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001746 "shr{w}\t{%cl, $dst|$dst, %CL}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001747 [(store (srl (loadi16 addr:$dst), CL), addr:$dst)]>,
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001748 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001749 def SHR32mCL : I<0xD3, MRM5m, (outs), (ins i32mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001750 "shr{l}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001751 [(store (srl (loadi32 addr:$dst), CL), addr:$dst)]>;
1752 }
Evan Chengb783fa32007-07-19 01:14:50 +00001753 def SHR8mi : Ii8<0xC0, MRM5m, (outs), (ins i8mem :$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001754 "shr{b}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001755 [(store (srl (loadi8 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001756 def SHR16mi : Ii8<0xC1, MRM5m, (outs), (ins i16mem:$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001757 "shr{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001758 [(store (srl (loadi16 addr:$dst), (i8 imm:$src)), addr:$dst)]>,
1759 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001760 def SHR32mi : Ii8<0xC1, MRM5m, (outs), (ins i32mem:$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001761 "shr{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001762 [(store (srl (loadi32 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
1763
1764 // Shift by 1
Evan Chengb783fa32007-07-19 01:14:50 +00001765 def SHR8m1 : I<0xD0, MRM5m, (outs), (ins i8mem :$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001766 "shr{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001767 [(store (srl (loadi8 addr:$dst), (i8 1)), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001768 def SHR16m1 : I<0xD1, MRM5m, (outs), (ins i16mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001769 "shr{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001770 [(store (srl (loadi16 addr:$dst), (i8 1)), addr:$dst)]>,OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001771 def SHR32m1 : I<0xD1, MRM5m, (outs), (ins i32mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001772 "shr{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001773 [(store (srl (loadi32 addr:$dst), (i8 1)), addr:$dst)]>;
1774}
1775
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001776let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00001777def SAR8rCL : I<0xD2, MRM7r, (outs GR8 :$dst), (ins GR8 :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001778 "sar{b}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001779 [(set GR8:$dst, (sra GR8:$src, CL))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001780def SAR16rCL : I<0xD3, MRM7r, (outs GR16:$dst), (ins GR16:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001781 "sar{w}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001782 [(set GR16:$dst, (sra GR16:$src, CL))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001783def SAR32rCL : I<0xD3, MRM7r, (outs GR32:$dst), (ins GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001784 "sar{l}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001785 [(set GR32:$dst, (sra GR32:$src, CL))]>;
1786}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001787
Evan Chengb783fa32007-07-19 01:14:50 +00001788def SAR8ri : Ii8<0xC0, MRM7r, (outs GR8 :$dst), (ins GR8 :$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001789 "sar{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001790 [(set GR8:$dst, (sra GR8:$src1, (i8 imm:$src2)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001791def SAR16ri : Ii8<0xC1, MRM7r, (outs GR16:$dst), (ins GR16:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001792 "sar{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001793 [(set GR16:$dst, (sra GR16:$src1, (i8 imm:$src2)))]>,
1794 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001795def SAR32ri : Ii8<0xC1, MRM7r, (outs GR32:$dst), (ins GR32:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001796 "sar{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001797 [(set GR32:$dst, (sra GR32:$src1, (i8 imm:$src2)))]>;
1798
1799// Shift by 1
Evan Chengb783fa32007-07-19 01:14:50 +00001800def SAR8r1 : I<0xD0, MRM7r, (outs GR8 :$dst), (ins GR8 :$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00001801 "sar{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001802 [(set GR8:$dst, (sra GR8:$src1, (i8 1)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001803def SAR16r1 : I<0xD1, MRM7r, (outs GR16:$dst), (ins GR16:$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00001804 "sar{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001805 [(set GR16:$dst, (sra GR16:$src1, (i8 1)))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001806def SAR32r1 : I<0xD1, MRM7r, (outs GR32:$dst), (ins GR32:$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00001807 "sar{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001808 [(set GR32:$dst, (sra GR32:$src1, (i8 1)))]>;
1809
1810let isTwoAddress = 0 in {
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001811 let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00001812 def SAR8mCL : I<0xD2, MRM7m, (outs), (ins i8mem :$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001813 "sar{b}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001814 [(store (sra (loadi8 addr:$dst), CL), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001815 def SAR16mCL : I<0xD3, MRM7m, (outs), (ins i16mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001816 "sar{w}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001817 [(store (sra (loadi16 addr:$dst), CL), addr:$dst)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001818 def SAR32mCL : I<0xD3, MRM7m, (outs), (ins i32mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001819 "sar{l}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001820 [(store (sra (loadi32 addr:$dst), CL), addr:$dst)]>;
1821 }
Evan Chengb783fa32007-07-19 01:14:50 +00001822 def SAR8mi : Ii8<0xC0, MRM7m, (outs), (ins i8mem :$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001823 "sar{b}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001824 [(store (sra (loadi8 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001825 def SAR16mi : Ii8<0xC1, MRM7m, (outs), (ins i16mem:$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001826 "sar{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001827 [(store (sra (loadi16 addr:$dst), (i8 imm:$src)), addr:$dst)]>,
1828 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001829 def SAR32mi : Ii8<0xC1, MRM7m, (outs), (ins i32mem:$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001830 "sar{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001831 [(store (sra (loadi32 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
1832
1833 // Shift by 1
Evan Chengb783fa32007-07-19 01:14:50 +00001834 def SAR8m1 : I<0xD0, MRM7m, (outs), (ins i8mem :$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001835 "sar{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001836 [(store (sra (loadi8 addr:$dst), (i8 1)), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001837 def SAR16m1 : I<0xD1, MRM7m, (outs), (ins i16mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001838 "sar{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001839 [(store (sra (loadi16 addr:$dst), (i8 1)), addr:$dst)]>,
1840 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001841 def SAR32m1 : I<0xD1, MRM7m, (outs), (ins i32mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001842 "sar{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001843 [(store (sra (loadi32 addr:$dst), (i8 1)), addr:$dst)]>;
1844}
1845
1846// Rotate instructions
1847// FIXME: provide shorter instructions when imm8 == 1
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001848let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00001849def ROL8rCL : I<0xD2, MRM0r, (outs GR8 :$dst), (ins GR8 :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001850 "rol{b}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001851 [(set GR8:$dst, (rotl GR8:$src, CL))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001852def ROL16rCL : I<0xD3, MRM0r, (outs GR16:$dst), (ins GR16:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001853 "rol{w}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001854 [(set GR16:$dst, (rotl GR16:$src, CL))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001855def ROL32rCL : I<0xD3, MRM0r, (outs GR32:$dst), (ins GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001856 "rol{l}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001857 [(set GR32:$dst, (rotl GR32:$src, CL))]>;
1858}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001859
Evan Chengb783fa32007-07-19 01:14:50 +00001860def ROL8ri : Ii8<0xC0, MRM0r, (outs GR8 :$dst), (ins GR8 :$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001861 "rol{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001862 [(set GR8:$dst, (rotl GR8:$src1, (i8 imm:$src2)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001863def ROL16ri : Ii8<0xC1, MRM0r, (outs GR16:$dst), (ins GR16:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001864 "rol{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001865 [(set GR16:$dst, (rotl GR16:$src1, (i8 imm:$src2)))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001866def ROL32ri : Ii8<0xC1, MRM0r, (outs GR32:$dst), (ins GR32:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001867 "rol{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001868 [(set GR32:$dst, (rotl GR32:$src1, (i8 imm:$src2)))]>;
1869
1870// Rotate by 1
Evan Chengb783fa32007-07-19 01:14:50 +00001871def ROL8r1 : I<0xD0, MRM0r, (outs GR8 :$dst), (ins GR8 :$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00001872 "rol{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001873 [(set GR8:$dst, (rotl GR8:$src1, (i8 1)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001874def ROL16r1 : I<0xD1, MRM0r, (outs GR16:$dst), (ins GR16:$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00001875 "rol{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001876 [(set GR16:$dst, (rotl GR16:$src1, (i8 1)))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001877def ROL32r1 : I<0xD1, MRM0r, (outs GR32:$dst), (ins GR32:$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00001878 "rol{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001879 [(set GR32:$dst, (rotl GR32:$src1, (i8 1)))]>;
1880
1881let isTwoAddress = 0 in {
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001882 let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00001883 def ROL8mCL : I<0xD2, MRM0m, (outs), (ins i8mem :$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001884 "rol{b}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001885 [(store (rotl (loadi8 addr:$dst), CL), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001886 def ROL16mCL : I<0xD3, MRM0m, (outs), (ins i16mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001887 "rol{w}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001888 [(store (rotl (loadi16 addr:$dst), CL), addr:$dst)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001889 def ROL32mCL : I<0xD3, MRM0m, (outs), (ins i32mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001890 "rol{l}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001891 [(store (rotl (loadi32 addr:$dst), CL), addr:$dst)]>;
1892 }
Evan Chengb783fa32007-07-19 01:14:50 +00001893 def ROL8mi : Ii8<0xC0, MRM0m, (outs), (ins i8mem :$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001894 "rol{b}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001895 [(store (rotl (loadi8 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001896 def ROL16mi : Ii8<0xC1, MRM0m, (outs), (ins i16mem:$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001897 "rol{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001898 [(store (rotl (loadi16 addr:$dst), (i8 imm:$src)), addr:$dst)]>,
1899 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001900 def ROL32mi : Ii8<0xC1, MRM0m, (outs), (ins i32mem:$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001901 "rol{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001902 [(store (rotl (loadi32 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
1903
1904 // Rotate by 1
Evan Chengb783fa32007-07-19 01:14:50 +00001905 def ROL8m1 : I<0xD0, MRM0m, (outs), (ins i8mem :$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001906 "rol{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001907 [(store (rotl (loadi8 addr:$dst), (i8 1)), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001908 def ROL16m1 : I<0xD1, MRM0m, (outs), (ins i16mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001909 "rol{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001910 [(store (rotl (loadi16 addr:$dst), (i8 1)), addr:$dst)]>,
1911 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001912 def ROL32m1 : I<0xD1, MRM0m, (outs), (ins i32mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001913 "rol{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001914 [(store (rotl (loadi32 addr:$dst), (i8 1)), addr:$dst)]>;
1915}
1916
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001917let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00001918def ROR8rCL : I<0xD2, MRM1r, (outs GR8 :$dst), (ins GR8 :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001919 "ror{b}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001920 [(set GR8:$dst, (rotr GR8:$src, CL))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001921def ROR16rCL : I<0xD3, MRM1r, (outs GR16:$dst), (ins GR16:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001922 "ror{w}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001923 [(set GR16:$dst, (rotr GR16:$src, CL))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001924def ROR32rCL : I<0xD3, MRM1r, (outs GR32:$dst), (ins GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001925 "ror{l}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001926 [(set GR32:$dst, (rotr GR32:$src, CL))]>;
1927}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001928
Evan Chengb783fa32007-07-19 01:14:50 +00001929def ROR8ri : Ii8<0xC0, MRM1r, (outs GR8 :$dst), (ins GR8 :$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001930 "ror{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001931 [(set GR8:$dst, (rotr GR8:$src1, (i8 imm:$src2)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001932def ROR16ri : Ii8<0xC1, MRM1r, (outs GR16:$dst), (ins GR16:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001933 "ror{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001934 [(set GR16:$dst, (rotr GR16:$src1, (i8 imm:$src2)))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001935def ROR32ri : Ii8<0xC1, MRM1r, (outs GR32:$dst), (ins GR32:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001936 "ror{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001937 [(set GR32:$dst, (rotr GR32:$src1, (i8 imm:$src2)))]>;
1938
1939// Rotate by 1
Evan Chengb783fa32007-07-19 01:14:50 +00001940def ROR8r1 : I<0xD0, MRM1r, (outs GR8 :$dst), (ins GR8 :$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00001941 "ror{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001942 [(set GR8:$dst, (rotr GR8:$src1, (i8 1)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001943def ROR16r1 : I<0xD1, MRM1r, (outs GR16:$dst), (ins GR16:$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00001944 "ror{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001945 [(set GR16:$dst, (rotr GR16:$src1, (i8 1)))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001946def ROR32r1 : I<0xD1, MRM1r, (outs GR32:$dst), (ins GR32:$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00001947 "ror{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001948 [(set GR32:$dst, (rotr GR32:$src1, (i8 1)))]>;
1949
1950let isTwoAddress = 0 in {
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001951 let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00001952 def ROR8mCL : I<0xD2, MRM1m, (outs), (ins i8mem :$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001953 "ror{b}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001954 [(store (rotr (loadi8 addr:$dst), CL), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001955 def ROR16mCL : I<0xD3, MRM1m, (outs), (ins i16mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001956 "ror{w}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001957 [(store (rotr (loadi16 addr:$dst), CL), addr:$dst)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001958 def ROR32mCL : I<0xD3, MRM1m, (outs), (ins i32mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001959 "ror{l}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001960 [(store (rotr (loadi32 addr:$dst), CL), addr:$dst)]>;
1961 }
Evan Chengb783fa32007-07-19 01:14:50 +00001962 def ROR8mi : Ii8<0xC0, MRM1m, (outs), (ins i8mem :$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001963 "ror{b}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001964 [(store (rotr (loadi8 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001965 def ROR16mi : Ii8<0xC1, MRM1m, (outs), (ins i16mem:$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001966 "ror{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001967 [(store (rotr (loadi16 addr:$dst), (i8 imm:$src)), addr:$dst)]>,
1968 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001969 def ROR32mi : Ii8<0xC1, MRM1m, (outs), (ins i32mem:$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001970 "ror{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001971 [(store (rotr (loadi32 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
1972
1973 // Rotate by 1
Evan Chengb783fa32007-07-19 01:14:50 +00001974 def ROR8m1 : I<0xD0, MRM1m, (outs), (ins i8mem :$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001975 "ror{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001976 [(store (rotr (loadi8 addr:$dst), (i8 1)), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001977 def ROR16m1 : I<0xD1, MRM1m, (outs), (ins i16mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001978 "ror{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001979 [(store (rotr (loadi16 addr:$dst), (i8 1)), addr:$dst)]>,
1980 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001981 def ROR32m1 : I<0xD1, MRM1m, (outs), (ins i32mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001982 "ror{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001983 [(store (rotr (loadi32 addr:$dst), (i8 1)), addr:$dst)]>;
1984}
1985
1986
1987
1988// Double shift instructions (generalizations of rotate)
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001989let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00001990def SHLD32rrCL : I<0xA5, MRMDestReg, (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001991 "shld{l}\t{%cl, $src2, $dst|$dst, $src2, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001992 [(set GR32:$dst, (X86shld GR32:$src1, GR32:$src2, CL))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00001993def SHRD32rrCL : I<0xAD, MRMDestReg, (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001994 "shrd{l}\t{%cl, $src2, $dst|$dst, $src2, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001995 [(set GR32:$dst, (X86shrd GR32:$src1, GR32:$src2, CL))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00001996def SHLD16rrCL : I<0xA5, MRMDestReg, (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001997 "shld{w}\t{%cl, $src2, $dst|$dst, $src2, %CL}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001998 [(set GR16:$dst, (X86shld GR16:$src1, GR16:$src2, CL))]>,
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001999 TB, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002000def SHRD16rrCL : I<0xAD, MRMDestReg, (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002001 "shrd{w}\t{%cl, $src2, $dst|$dst, $src2, %CL}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002002 [(set GR16:$dst, (X86shrd GR16:$src1, GR16:$src2, CL))]>,
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002003 TB, OpSize;
2004}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002005
2006let isCommutable = 1 in { // These instructions commute to each other.
2007def SHLD32rri8 : Ii8<0xA4, MRMDestReg,
Evan Chengb783fa32007-07-19 01:14:50 +00002008 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2, i8imm:$src3),
Dan Gohman91888f02007-07-31 20:11:57 +00002009 "shld{l}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002010 [(set GR32:$dst, (X86shld GR32:$src1, GR32:$src2,
2011 (i8 imm:$src3)))]>,
2012 TB;
2013def SHRD32rri8 : Ii8<0xAC, MRMDestReg,
Evan Chengb783fa32007-07-19 01:14:50 +00002014 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2, i8imm:$src3),
Dan Gohman91888f02007-07-31 20:11:57 +00002015 "shrd{l}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002016 [(set GR32:$dst, (X86shrd GR32:$src1, GR32:$src2,
2017 (i8 imm:$src3)))]>,
2018 TB;
2019def SHLD16rri8 : Ii8<0xA4, MRMDestReg,
Evan Chengb783fa32007-07-19 01:14:50 +00002020 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2, i8imm:$src3),
Dan Gohman91888f02007-07-31 20:11:57 +00002021 "shld{w}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002022 [(set GR16:$dst, (X86shld GR16:$src1, GR16:$src2,
2023 (i8 imm:$src3)))]>,
2024 TB, OpSize;
2025def SHRD16rri8 : Ii8<0xAC, MRMDestReg,
Evan Chengb783fa32007-07-19 01:14:50 +00002026 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2, i8imm:$src3),
Dan Gohman91888f02007-07-31 20:11:57 +00002027 "shrd{w}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002028 [(set GR16:$dst, (X86shrd GR16:$src1, GR16:$src2,
2029 (i8 imm:$src3)))]>,
2030 TB, OpSize;
2031}
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 SHLD32mrCL : I<0xA5, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002036 "shld{l}\t{%cl, $src2, $dst|$dst, $src2, %CL}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002037 [(store (X86shld (loadi32 addr:$dst), GR32:$src2, CL),
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002038 addr:$dst)]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00002039 def SHRD32mrCL : I<0xAD, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002040 "shrd{l}\t{%cl, $src2, $dst|$dst, $src2, %CL}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002041 [(store (X86shrd (loadi32 addr:$dst), GR32:$src2, CL),
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002042 addr:$dst)]>, TB;
2043 }
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002044 def SHLD32mri8 : Ii8<0xA4, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00002045 (outs), (ins i32mem:$dst, GR32:$src2, i8imm:$src3),
Dan Gohman91888f02007-07-31 20:11:57 +00002046 "shld{l}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002047 [(store (X86shld (loadi32 addr:$dst), GR32:$src2,
2048 (i8 imm:$src3)), addr:$dst)]>,
2049 TB;
2050 def SHRD32mri8 : Ii8<0xAC, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00002051 (outs), (ins i32mem:$dst, GR32:$src2, i8imm:$src3),
Dan Gohman91888f02007-07-31 20:11:57 +00002052 "shrd{l}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002053 [(store (X86shrd (loadi32 addr:$dst), GR32:$src2,
2054 (i8 imm:$src3)), addr:$dst)]>,
2055 TB;
2056
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002057 let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00002058 def SHLD16mrCL : I<0xA5, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002059 "shld{w}\t{%cl, $src2, $dst|$dst, $src2, %CL}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002060 [(store (X86shld (loadi16 addr:$dst), GR16:$src2, CL),
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002061 addr:$dst)]>, TB, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002062 def SHRD16mrCL : I<0xAD, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002063 "shrd{w}\t{%cl, $src2, $dst|$dst, $src2, %CL}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002064 [(store (X86shrd (loadi16 addr:$dst), GR16:$src2, CL),
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002065 addr:$dst)]>, TB, OpSize;
2066 }
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002067 def SHLD16mri8 : Ii8<0xA4, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00002068 (outs), (ins i16mem:$dst, GR16:$src2, i8imm:$src3),
Dan Gohman91888f02007-07-31 20:11:57 +00002069 "shld{w}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002070 [(store (X86shld (loadi16 addr:$dst), GR16:$src2,
2071 (i8 imm:$src3)), addr:$dst)]>,
2072 TB, OpSize;
2073 def SHRD16mri8 : Ii8<0xAC, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00002074 (outs), (ins i16mem:$dst, GR16:$src2, i8imm:$src3),
Dan Gohman91888f02007-07-31 20:11:57 +00002075 "shrd{w}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002076 [(store (X86shrd (loadi16 addr:$dst), GR16:$src2,
2077 (i8 imm:$src3)), addr:$dst)]>,
2078 TB, OpSize;
2079}
Evan Cheng55687072007-09-14 21:48:26 +00002080} // Defs = [EFLAGS]
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002081
2082
2083// Arithmetic.
Evan Cheng55687072007-09-14 21:48:26 +00002084let Defs = [EFLAGS] in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002085let isCommutable = 1 in { // X = ADD Y, Z --> X = ADD Z, Y
Bill Wendlingae034ed2008-12-12 00:56:36 +00002086// Register-Register Addition
2087def ADD8rr : I<0x00, MRMDestReg, (outs GR8 :$dst),
2088 (ins GR8 :$src1, GR8 :$src2),
2089 "add{b}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002090 [(set GR8:$dst, (add GR8:$src1, GR8:$src2)),
Bill Wendlingae034ed2008-12-12 00:56:36 +00002091 (implicit EFLAGS)]>;
2092
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002093let isConvertibleToThreeAddress = 1 in { // Can transform into LEA.
Bill Wendlingae034ed2008-12-12 00:56:36 +00002094// Register-Register Addition
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002095def ADD16rr : I<0x01, MRMDestReg, (outs GR16:$dst),
2096 (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002097 "add{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002098 [(set GR16:$dst, (add GR16:$src1, GR16:$src2)),
2099 (implicit EFLAGS)]>, OpSize;
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002100def ADD32rr : I<0x01, MRMDestReg, (outs GR32:$dst),
2101 (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002102 "add{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002103 [(set GR32:$dst, (add GR32:$src1, GR32:$src2)),
2104 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002105} // end isConvertibleToThreeAddress
2106} // end isCommutable
Bill Wendlingae034ed2008-12-12 00:56:36 +00002107
2108// Register-Memory Addition
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002109def ADD8rm : I<0x02, MRMSrcMem, (outs GR8 :$dst),
2110 (ins GR8 :$src1, i8mem :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002111 "add{b}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002112 [(set GR8:$dst, (add GR8:$src1, (load addr:$src2))),
2113 (implicit EFLAGS)]>;
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002114def ADD16rm : I<0x03, MRMSrcMem, (outs GR16:$dst),
2115 (ins GR16:$src1, i16mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002116 "add{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002117 [(set GR16:$dst, (add GR16:$src1, (load addr:$src2))),
2118 (implicit EFLAGS)]>, OpSize;
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002119def ADD32rm : I<0x03, MRMSrcMem, (outs GR32:$dst),
2120 (ins GR32:$src1, i32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002121 "add{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002122 [(set GR32:$dst, (add GR32:$src1, (load addr:$src2))),
2123 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002124
Bill Wendlingae034ed2008-12-12 00:56:36 +00002125// Register-Integer Addition
2126def ADD8ri : Ii8<0x80, MRM0r, (outs GR8:$dst), (ins GR8:$src1, i8imm:$src2),
2127 "add{b}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002128 [(set GR8:$dst, (add GR8:$src1, imm:$src2)),
2129 (implicit EFLAGS)]>;
Bill Wendlingae034ed2008-12-12 00:56:36 +00002130
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002131let isConvertibleToThreeAddress = 1 in { // Can transform into LEA.
Bill Wendlingae034ed2008-12-12 00:56:36 +00002132// Register-Integer Addition
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002133def ADD16ri : Ii16<0x81, MRM0r, (outs GR16:$dst),
2134 (ins GR16:$src1, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002135 "add{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002136 [(set GR16:$dst, (add GR16:$src1, imm:$src2)),
2137 (implicit EFLAGS)]>, OpSize;
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002138def ADD32ri : Ii32<0x81, MRM0r, (outs GR32:$dst),
2139 (ins GR32:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002140 "add{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002141 [(set GR32:$dst, (add GR32:$src1, imm:$src2)),
2142 (implicit EFLAGS)]>;
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002143def ADD16ri8 : Ii8<0x83, MRM0r, (outs GR16:$dst),
2144 (ins GR16:$src1, i16i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002145 "add{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002146 [(set GR16:$dst, (add GR16:$src1, i16immSExt8:$src2)),
2147 (implicit EFLAGS)]>, OpSize;
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002148def ADD32ri8 : Ii8<0x83, MRM0r, (outs GR32:$dst),
2149 (ins GR32:$src1, i32i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002150 "add{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002151 [(set GR32:$dst, (add GR32:$src1, i32immSExt8:$src2)),
2152 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002153}
2154
2155let isTwoAddress = 0 in {
Bill Wendlingae034ed2008-12-12 00:56:36 +00002156 // Memory-Register Addition
Bill Wendlingf5399032008-12-12 21:15:41 +00002157 def ADD8mr : I<0x00, MRMDestMem, (outs), (ins i8mem:$dst, GR8:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002158 "add{b}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002159 [(store (add (load addr:$dst), GR8:$src2), addr:$dst),
2160 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002161 def ADD16mr : I<0x01, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002162 "add{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002163 [(store (add (load addr:$dst), GR16:$src2), addr:$dst),
2164 (implicit EFLAGS)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002165 def ADD32mr : I<0x01, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002166 "add{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002167 [(store (add (load addr:$dst), GR32:$src2), addr:$dst),
2168 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002169 def ADD8mi : Ii8<0x80, MRM0m, (outs), (ins i8mem :$dst, i8imm :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002170 "add{b}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002171 [(store (add (loadi8 addr:$dst), imm:$src2), addr:$dst),
2172 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002173 def ADD16mi : Ii16<0x81, MRM0m, (outs), (ins i16mem:$dst, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002174 "add{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002175 [(store (add (loadi16 addr:$dst), imm:$src2), addr:$dst),
2176 (implicit EFLAGS)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002177 def ADD32mi : Ii32<0x81, MRM0m, (outs), (ins i32mem:$dst, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002178 "add{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002179 [(store (add (loadi32 addr:$dst), imm:$src2), addr:$dst),
2180 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002181 def ADD16mi8 : Ii8<0x83, MRM0m, (outs), (ins i16mem:$dst, i16i8imm :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002182 "add{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002183 [(store (add (load addr:$dst), i16immSExt8:$src2),
2184 addr:$dst),
2185 (implicit EFLAGS)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002186 def ADD32mi8 : Ii8<0x83, MRM0m, (outs), (ins i32mem:$dst, i32i8imm :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002187 "add{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingae034ed2008-12-12 00:56:36 +00002188 [(store (add (load addr:$dst), i32immSExt8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00002189 addr:$dst),
2190 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002191}
2192
Evan Cheng259471d2007-10-05 17:59:57 +00002193let Uses = [EFLAGS] in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002194let isCommutable = 1 in { // X = ADC Y, Z --> X = ADC Z, Y
Evan Chengb783fa32007-07-19 01:14:50 +00002195def ADC32rr : I<0x11, MRMDestReg, (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002196 "adc{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingc0ca7f32008-12-01 23:44:08 +00002197 [(set GR32:$dst, (adde GR32:$src1, GR32:$src2))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002198}
Evan Chengb783fa32007-07-19 01:14:50 +00002199def ADC32rm : I<0x13, MRMSrcMem , (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002200 "adc{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingc0ca7f32008-12-01 23:44:08 +00002201 [(set GR32:$dst, (adde GR32:$src1, (load addr:$src2)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002202def ADC32ri : Ii32<0x81, MRM2r, (outs GR32:$dst), (ins GR32:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002203 "adc{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingc0ca7f32008-12-01 23:44:08 +00002204 [(set GR32:$dst, (adde GR32:$src1, imm:$src2))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002205def ADC32ri8 : Ii8<0x83, MRM2r, (outs GR32:$dst), (ins GR32:$src1, i32i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002206 "adc{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingc0ca7f32008-12-01 23:44:08 +00002207 [(set GR32:$dst, (adde GR32:$src1, i32immSExt8:$src2))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002208
2209let isTwoAddress = 0 in {
Evan Chengb783fa32007-07-19 01:14:50 +00002210 def ADC32mr : I<0x11, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002211 "adc{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingc0ca7f32008-12-01 23:44:08 +00002212 [(store (adde (load addr:$dst), GR32:$src2), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002213 def ADC32mi : Ii32<0x81, MRM2m, (outs), (ins i32mem:$dst, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002214 "adc{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingc0ca7f32008-12-01 23:44:08 +00002215 [(store (adde (loadi32 addr:$dst), imm:$src2), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002216 def ADC32mi8 : Ii8<0x83, MRM2m, (outs), (ins i32mem:$dst, i32i8imm :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002217 "adc{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendling0c52d0a2008-12-02 00:07:05 +00002218 [(store (adde (load addr:$dst), i32immSExt8:$src2), addr:$dst)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002219}
Evan Cheng259471d2007-10-05 17:59:57 +00002220} // Uses = [EFLAGS]
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002221
Bill Wendlingae034ed2008-12-12 00:56:36 +00002222// Register-Register Subtraction
2223def SUB8rr : I<0x28, MRMDestReg, (outs GR8:$dst), (ins GR8:$src1, GR8:$src2),
2224 "sub{b}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002225 [(set GR8:$dst, (sub GR8:$src1, GR8:$src2)),
2226 (implicit EFLAGS)]>;
Bill Wendlingae034ed2008-12-12 00:56:36 +00002227def SUB16rr : I<0x29, MRMDestReg, (outs GR16:$dst), (ins GR16:$src1,GR16:$src2),
2228 "sub{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002229 [(set GR16:$dst, (sub GR16:$src1, GR16:$src2)),
2230 (implicit EFLAGS)]>, OpSize;
Bill Wendlingae034ed2008-12-12 00:56:36 +00002231def SUB32rr : I<0x29, MRMDestReg, (outs GR32:$dst), (ins GR32:$src1,GR32:$src2),
2232 "sub{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002233 [(set GR32:$dst, (sub GR32:$src1, GR32:$src2)),
2234 (implicit EFLAGS)]>;
Bill Wendlingae034ed2008-12-12 00:56:36 +00002235
2236// Register-Memory Subtraction
2237def SUB8rm : I<0x2A, MRMSrcMem, (outs GR8 :$dst),
2238 (ins GR8 :$src1, i8mem :$src2),
2239 "sub{b}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002240 [(set GR8:$dst, (sub GR8:$src1, (load addr:$src2))),
2241 (implicit EFLAGS)]>;
Bill Wendlingae034ed2008-12-12 00:56:36 +00002242def SUB16rm : I<0x2B, MRMSrcMem, (outs GR16:$dst),
2243 (ins GR16:$src1, i16mem:$src2),
2244 "sub{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002245 [(set GR16:$dst, (sub GR16:$src1, (load addr:$src2))),
2246 (implicit EFLAGS)]>, OpSize;
Bill Wendlingae034ed2008-12-12 00:56:36 +00002247def SUB32rm : I<0x2B, MRMSrcMem, (outs GR32:$dst),
2248 (ins GR32:$src1, i32mem:$src2),
2249 "sub{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002250 [(set GR32:$dst, (sub GR32:$src1, (load addr:$src2))),
2251 (implicit EFLAGS)]>;
Bill Wendlingae034ed2008-12-12 00:56:36 +00002252
2253// Register-Integer Subtraction
2254def SUB8ri : Ii8 <0x80, MRM5r, (outs GR8:$dst),
2255 (ins GR8:$src1, i8imm:$src2),
2256 "sub{b}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002257 [(set GR8:$dst, (sub GR8:$src1, imm:$src2)),
2258 (implicit EFLAGS)]>;
Bill Wendlingae034ed2008-12-12 00:56:36 +00002259def SUB16ri : Ii16<0x81, MRM5r, (outs GR16:$dst),
2260 (ins GR16:$src1, i16imm:$src2),
2261 "sub{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002262 [(set GR16:$dst, (sub GR16:$src1, imm:$src2)),
2263 (implicit EFLAGS)]>, OpSize;
Bill Wendlingae034ed2008-12-12 00:56:36 +00002264def SUB32ri : Ii32<0x81, MRM5r, (outs GR32:$dst),
2265 (ins GR32:$src1, i32imm:$src2),
2266 "sub{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002267 [(set GR32:$dst, (sub GR32:$src1, imm:$src2)),
2268 (implicit EFLAGS)]>;
Bill Wendlingae034ed2008-12-12 00:56:36 +00002269def SUB16ri8 : Ii8<0x83, MRM5r, (outs GR16:$dst),
2270 (ins GR16:$src1, i16i8imm:$src2),
2271 "sub{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002272 [(set GR16:$dst, (sub GR16:$src1, i16immSExt8:$src2)),
2273 (implicit EFLAGS)]>, OpSize;
Bill Wendlingae034ed2008-12-12 00:56:36 +00002274def SUB32ri8 : Ii8<0x83, MRM5r, (outs GR32:$dst),
2275 (ins GR32:$src1, i32i8imm:$src2),
2276 "sub{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002277 [(set GR32:$dst, (sub GR32:$src1, i32immSExt8:$src2)),
2278 (implicit EFLAGS)]>;
Bill Wendlingae034ed2008-12-12 00:56:36 +00002279
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002280let isTwoAddress = 0 in {
Bill Wendlingae034ed2008-12-12 00:56:36 +00002281 // Memory-Register Subtraction
Evan Chengb783fa32007-07-19 01:14:50 +00002282 def SUB8mr : I<0x28, MRMDestMem, (outs), (ins i8mem :$dst, GR8 :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002283 "sub{b}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002284 [(store (sub (load addr:$dst), GR8:$src2), addr:$dst),
2285 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002286 def SUB16mr : I<0x29, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002287 "sub{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002288 [(store (sub (load addr:$dst), GR16:$src2), addr:$dst),
2289 (implicit EFLAGS)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002290 def SUB32mr : I<0x29, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002291 "sub{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002292 [(store (sub (load addr:$dst), GR32:$src2), addr:$dst),
2293 (implicit EFLAGS)]>;
Bill Wendlingae034ed2008-12-12 00:56:36 +00002294
2295 // Memory-Integer Subtraction
Evan Chengb783fa32007-07-19 01:14:50 +00002296 def SUB8mi : Ii8<0x80, MRM5m, (outs), (ins i8mem :$dst, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002297 "sub{b}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002298 [(store (sub (loadi8 addr:$dst), imm:$src2), addr:$dst),
2299 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002300 def SUB16mi : Ii16<0x81, MRM5m, (outs), (ins i16mem:$dst, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002301 "sub{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002302 [(store (sub (loadi16 addr:$dst), imm:$src2),addr:$dst),
2303 (implicit EFLAGS)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002304 def SUB32mi : Ii32<0x81, MRM5m, (outs), (ins i32mem:$dst, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002305 "sub{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002306 [(store (sub (loadi32 addr:$dst), imm:$src2),addr:$dst),
2307 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002308 def SUB16mi8 : Ii8<0x83, MRM5m, (outs), (ins i16mem:$dst, i16i8imm :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002309 "sub{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingae034ed2008-12-12 00:56:36 +00002310 [(store (sub (load addr:$dst), i16immSExt8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00002311 addr:$dst),
2312 (implicit EFLAGS)]>, OpSize;
Bill Wendlingae034ed2008-12-12 00:56:36 +00002313 def SUB32mi8 : Ii8<0x83, MRM5m, (outs), (ins i32mem:$dst, i32i8imm :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002314 "sub{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingae034ed2008-12-12 00:56:36 +00002315 [(store (sub (load addr:$dst), i32immSExt8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00002316 addr:$dst),
2317 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002318}
2319
Evan Cheng259471d2007-10-05 17:59:57 +00002320let Uses = [EFLAGS] in {
Evan Chengb783fa32007-07-19 01:14:50 +00002321def SBB32rr : I<0x19, MRMDestReg, (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002322 "sbb{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng55687072007-09-14 21:48:26 +00002323 [(set GR32:$dst, (sube GR32:$src1, GR32:$src2))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002324
2325let isTwoAddress = 0 in {
Evan Chengb783fa32007-07-19 01:14:50 +00002326 def SBB32mr : I<0x19, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002327 "sbb{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002328 [(store (sube (load addr:$dst), GR32:$src2), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002329 def SBB8mi : Ii32<0x80, MRM3m, (outs), (ins i8mem:$dst, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002330 "sbb{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002331 [(store (sube (loadi8 addr:$dst), imm:$src2), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002332 def SBB32mi : Ii32<0x81, MRM3m, (outs), (ins i32mem:$dst, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002333 "sbb{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002334 [(store (sube (loadi32 addr:$dst), imm:$src2), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002335 def SBB32mi8 : Ii8<0x83, MRM3m, (outs), (ins i32mem:$dst, i32i8imm :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002336 "sbb{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng55687072007-09-14 21:48:26 +00002337 [(store (sube (load addr:$dst), i32immSExt8:$src2), addr:$dst)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002338}
Evan Chengb783fa32007-07-19 01:14:50 +00002339def SBB32rm : I<0x1B, MRMSrcMem, (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002340 "sbb{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002341 [(set GR32:$dst, (sube GR32:$src1, (load addr:$src2)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002342def SBB32ri : Ii32<0x81, MRM3r, (outs GR32:$dst), (ins GR32:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002343 "sbb{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002344 [(set GR32:$dst, (sube GR32:$src1, imm:$src2))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002345def SBB32ri8 : Ii8<0x83, MRM3r, (outs GR32:$dst), (ins GR32:$src1, i32i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002346 "sbb{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002347 [(set GR32:$dst, (sube GR32:$src1, i32immSExt8:$src2))]>;
Evan Cheng259471d2007-10-05 17:59:57 +00002348} // Uses = [EFLAGS]
Evan Cheng55687072007-09-14 21:48:26 +00002349} // Defs = [EFLAGS]
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002350
Evan Cheng55687072007-09-14 21:48:26 +00002351let Defs = [EFLAGS] in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002352let isCommutable = 1 in { // X = IMUL Y, Z --> X = IMUL Z, Y
Bill Wendlingf5399032008-12-12 21:15:41 +00002353// Register-Register Signed Integer Multiply
Bill Wendlingae034ed2008-12-12 00:56:36 +00002354def IMUL16rr : I<0xAF, MRMSrcReg, (outs GR16:$dst), (ins GR16:$src1,GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002355 "imul{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002356 [(set GR16:$dst, (mul GR16:$src1, GR16:$src2)),
2357 (implicit EFLAGS)]>, TB, OpSize;
Bill Wendlingae034ed2008-12-12 00:56:36 +00002358def IMUL32rr : I<0xAF, MRMSrcReg, (outs GR32:$dst), (ins GR32:$src1,GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002359 "imul{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002360 [(set GR32:$dst, (mul GR32:$src1, GR32:$src2)),
2361 (implicit EFLAGS)]>, TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002362}
Bill Wendlingae034ed2008-12-12 00:56:36 +00002363
Bill Wendlingf5399032008-12-12 21:15:41 +00002364// Register-Memory Signed Integer Multiply
Bill Wendlingae034ed2008-12-12 00:56:36 +00002365def IMUL16rm : I<0xAF, MRMSrcMem, (outs GR16:$dst),
2366 (ins GR16:$src1, i16mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002367 "imul{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002368 [(set GR16:$dst, (mul GR16:$src1, (load addr:$src2))),
2369 (implicit EFLAGS)]>, TB, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002370def IMUL32rm : I<0xAF, MRMSrcMem, (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002371 "imul{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002372 [(set GR32:$dst, (mul GR32:$src1, (load addr:$src2))),
2373 (implicit EFLAGS)]>, TB;
Evan Cheng55687072007-09-14 21:48:26 +00002374} // Defs = [EFLAGS]
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002375} // end Two Address instructions
2376
2377// Suprisingly enough, these are not two address instructions!
Evan Cheng55687072007-09-14 21:48:26 +00002378let Defs = [EFLAGS] in {
Bill Wendlingf5399032008-12-12 21:15:41 +00002379// Register-Integer Signed Integer Multiply
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002380def IMUL16rri : Ii16<0x69, MRMSrcReg, // GR16 = GR16*I16
Evan Chengb783fa32007-07-19 01:14:50 +00002381 (outs GR16:$dst), (ins GR16:$src1, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002382 "imul{w}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002383 [(set GR16:$dst, (mul GR16:$src1, imm:$src2)),
2384 (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002385def IMUL32rri : Ii32<0x69, MRMSrcReg, // GR32 = GR32*I32
Evan Chengb783fa32007-07-19 01:14:50 +00002386 (outs GR32:$dst), (ins GR32:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002387 "imul{l}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002388 [(set GR32:$dst, (mul GR32:$src1, imm:$src2)),
2389 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002390def IMUL16rri8 : Ii8<0x6B, MRMSrcReg, // GR16 = GR16*I8
Evan Chengb783fa32007-07-19 01:14:50 +00002391 (outs GR16:$dst), (ins GR16:$src1, i16i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002392 "imul{w}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002393 [(set GR16:$dst, (mul GR16:$src1, i16immSExt8:$src2)),
2394 (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002395def IMUL32rri8 : Ii8<0x6B, MRMSrcReg, // GR32 = GR32*I8
Evan Chengb783fa32007-07-19 01:14:50 +00002396 (outs GR32:$dst), (ins GR32:$src1, i32i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002397 "imul{l}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002398 [(set GR32:$dst, (mul GR32:$src1, i32immSExt8:$src2)),
2399 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002400
Bill Wendlingf5399032008-12-12 21:15:41 +00002401// Memory-Integer Signed Integer Multiply
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002402def IMUL16rmi : Ii16<0x69, MRMSrcMem, // GR16 = [mem16]*I16
Evan Chengb783fa32007-07-19 01:14:50 +00002403 (outs GR16:$dst), (ins i16mem:$src1, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002404 "imul{w}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002405 [(set GR16:$dst, (mul (load addr:$src1), imm:$src2)),
2406 (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002407def IMUL32rmi : Ii32<0x69, MRMSrcMem, // GR32 = [mem32]*I32
Evan Chengb783fa32007-07-19 01:14:50 +00002408 (outs GR32:$dst), (ins i32mem:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002409 "imul{l}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002410 [(set GR32:$dst, (mul (load addr:$src1), imm:$src2)),
2411 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002412def IMUL16rmi8 : Ii8<0x6B, MRMSrcMem, // GR16 = [mem16]*I8
Evan Chengb783fa32007-07-19 01:14:50 +00002413 (outs GR16:$dst), (ins i16mem:$src1, i16i8imm :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002414 "imul{w}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Bill Wendlingae034ed2008-12-12 00:56:36 +00002415 [(set GR16:$dst, (mul (load addr:$src1),
Bill Wendlingf5399032008-12-12 21:15:41 +00002416 i16immSExt8:$src2)),
2417 (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002418def IMUL32rmi8 : Ii8<0x6B, MRMSrcMem, // GR32 = [mem32]*I8
Evan Chengb783fa32007-07-19 01:14:50 +00002419 (outs GR32:$dst), (ins i32mem:$src1, i32i8imm: $src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002420 "imul{l}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Bill Wendlingae034ed2008-12-12 00:56:36 +00002421 [(set GR32:$dst, (mul (load addr:$src1),
Bill Wendlingf5399032008-12-12 21:15:41 +00002422 i32immSExt8:$src2)),
2423 (implicit EFLAGS)]>;
Evan Cheng55687072007-09-14 21:48:26 +00002424} // Defs = [EFLAGS]
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002425
2426//===----------------------------------------------------------------------===//
2427// Test instructions are just like AND, except they don't generate a result.
2428//
Evan Cheng950aac02007-09-25 01:57:46 +00002429let Defs = [EFLAGS] in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002430let isCommutable = 1 in { // TEST X, Y --> TEST Y, X
Evan Chengb783fa32007-07-19 01:14:50 +00002431def TEST8rr : I<0x84, MRMDestReg, (outs), (ins GR8:$src1, GR8:$src2),
Evan Cheng621216e2007-09-29 00:00:36 +00002432 "test{b}\t{$src2, $src1|$src1, $src2}",
Chris Lattner21da6382008-02-19 17:37:35 +00002433 [(X86cmp (and_su GR8:$src1, GR8:$src2), 0),
Evan Cheng621216e2007-09-29 00:00:36 +00002434 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002435def TEST16rr : I<0x85, MRMDestReg, (outs), (ins GR16:$src1, GR16:$src2),
Evan Cheng621216e2007-09-29 00:00:36 +00002436 "test{w}\t{$src2, $src1|$src1, $src2}",
Chris Lattner21da6382008-02-19 17:37:35 +00002437 [(X86cmp (and_su GR16:$src1, GR16:$src2), 0),
Evan Cheng621216e2007-09-29 00:00:36 +00002438 (implicit EFLAGS)]>,
2439 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002440def TEST32rr : I<0x85, MRMDestReg, (outs), (ins GR32:$src1, GR32:$src2),
Evan Cheng621216e2007-09-29 00:00:36 +00002441 "test{l}\t{$src2, $src1|$src1, $src2}",
Chris Lattner21da6382008-02-19 17:37:35 +00002442 [(X86cmp (and_su GR32:$src1, GR32:$src2), 0),
Evan Cheng621216e2007-09-29 00:00:36 +00002443 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002444}
2445
Evan Chengb783fa32007-07-19 01:14:50 +00002446def TEST8rm : I<0x84, MRMSrcMem, (outs), (ins GR8 :$src1, i8mem :$src2),
Evan Cheng621216e2007-09-29 00:00:36 +00002447 "test{b}\t{$src2, $src1|$src1, $src2}",
2448 [(X86cmp (and GR8:$src1, (loadi8 addr:$src2)), 0),
2449 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002450def TEST16rm : I<0x85, MRMSrcMem, (outs), (ins GR16:$src1, i16mem:$src2),
Evan Cheng621216e2007-09-29 00:00:36 +00002451 "test{w}\t{$src2, $src1|$src1, $src2}",
2452 [(X86cmp (and GR16:$src1, (loadi16 addr:$src2)), 0),
2453 (implicit EFLAGS)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002454def TEST32rm : I<0x85, MRMSrcMem, (outs), (ins GR32:$src1, i32mem:$src2),
Evan Cheng621216e2007-09-29 00:00:36 +00002455 "test{l}\t{$src2, $src1|$src1, $src2}",
2456 [(X86cmp (and GR32:$src1, (loadi32 addr:$src2)), 0),
2457 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002458
2459def TEST8ri : Ii8 <0xF6, MRM0r, // flags = GR8 & imm8
Evan Chengb783fa32007-07-19 01:14:50 +00002460 (outs), (ins GR8:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002461 "test{b}\t{$src2, $src1|$src1, $src2}",
Chris Lattner21da6382008-02-19 17:37:35 +00002462 [(X86cmp (and_su GR8:$src1, imm:$src2), 0),
Evan Cheng621216e2007-09-29 00:00:36 +00002463 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002464def TEST16ri : Ii16<0xF7, MRM0r, // flags = GR16 & imm16
Evan Chengb783fa32007-07-19 01:14:50 +00002465 (outs), (ins GR16:$src1, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002466 "test{w}\t{$src2, $src1|$src1, $src2}",
Chris Lattner21da6382008-02-19 17:37:35 +00002467 [(X86cmp (and_su GR16:$src1, imm:$src2), 0),
Evan Cheng621216e2007-09-29 00:00:36 +00002468 (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002469def TEST32ri : Ii32<0xF7, MRM0r, // flags = GR32 & imm32
Evan Chengb783fa32007-07-19 01:14:50 +00002470 (outs), (ins GR32:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002471 "test{l}\t{$src2, $src1|$src1, $src2}",
Chris Lattner21da6382008-02-19 17:37:35 +00002472 [(X86cmp (and_su GR32:$src1, imm:$src2), 0),
Evan Cheng621216e2007-09-29 00:00:36 +00002473 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002474
Evan Cheng621216e2007-09-29 00:00:36 +00002475def TEST8mi : Ii8 <0xF6, MRM0m, // flags = [mem8] & imm8
Evan Chengb783fa32007-07-19 01:14:50 +00002476 (outs), (ins i8mem:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002477 "test{b}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002478 [(X86cmp (and (loadi8 addr:$src1), imm:$src2), 0),
2479 (implicit EFLAGS)]>;
2480def TEST16mi : Ii16<0xF7, MRM0m, // flags = [mem16] & imm16
Evan Chengb783fa32007-07-19 01:14:50 +00002481 (outs), (ins i16mem:$src1, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002482 "test{w}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002483 [(X86cmp (and (loadi16 addr:$src1), imm:$src2), 0),
2484 (implicit EFLAGS)]>, OpSize;
2485def TEST32mi : Ii32<0xF7, MRM0m, // flags = [mem32] & imm32
Evan Chengb783fa32007-07-19 01:14:50 +00002486 (outs), (ins i32mem:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002487 "test{l}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002488 [(X86cmp (and (loadi32 addr:$src1), imm:$src2), 0),
Evan Cheng950aac02007-09-25 01:57:46 +00002489 (implicit EFLAGS)]>;
2490} // Defs = [EFLAGS]
2491
2492
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002493// Condition code ops, incl. set if equal/not equal/...
Chris Lattnerc90ee9c2008-01-10 07:59:24 +00002494let Defs = [EFLAGS], Uses = [AH], neverHasSideEffects = 1 in
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002495def SAHF : I<0x9E, RawFrm, (outs), (ins), "sahf", []>; // flags = AH
Chris Lattnerc90ee9c2008-01-10 07:59:24 +00002496let Defs = [AH], Uses = [EFLAGS], neverHasSideEffects = 1 in
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002497def LAHF : I<0x9F, RawFrm, (outs), (ins), "lahf", []>; // AH = flags
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002498
Evan Cheng950aac02007-09-25 01:57:46 +00002499let Uses = [EFLAGS] in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002500def SETEr : I<0x94, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00002501 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002502 "sete\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002503 [(set GR8:$dst, (X86setcc X86_COND_E, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002504 TB; // GR8 = ==
2505def SETEm : I<0x94, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00002506 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002507 "sete\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002508 [(store (X86setcc X86_COND_E, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002509 TB; // [mem8] = ==
Bill Wendling0c52d0a2008-12-02 00:07:05 +00002510
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002511def SETNEr : I<0x95, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00002512 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002513 "setne\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002514 [(set GR8:$dst, (X86setcc X86_COND_NE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002515 TB; // GR8 = !=
2516def SETNEm : I<0x95, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00002517 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002518 "setne\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002519 [(store (X86setcc X86_COND_NE, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002520 TB; // [mem8] = !=
Bill Wendling0c52d0a2008-12-02 00:07:05 +00002521
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002522def SETLr : I<0x9C, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00002523 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002524 "setl\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002525 [(set GR8:$dst, (X86setcc X86_COND_L, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002526 TB; // GR8 = < signed
2527def SETLm : I<0x9C, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00002528 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002529 "setl\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002530 [(store (X86setcc X86_COND_L, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002531 TB; // [mem8] = < signed
Bill Wendling0c52d0a2008-12-02 00:07:05 +00002532
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002533def SETGEr : I<0x9D, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00002534 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002535 "setge\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002536 [(set GR8:$dst, (X86setcc X86_COND_GE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002537 TB; // GR8 = >= signed
2538def SETGEm : I<0x9D, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00002539 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002540 "setge\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002541 [(store (X86setcc X86_COND_GE, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002542 TB; // [mem8] = >= signed
Bill Wendling0c52d0a2008-12-02 00:07:05 +00002543
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002544def SETLEr : I<0x9E, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00002545 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002546 "setle\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002547 [(set GR8:$dst, (X86setcc X86_COND_LE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002548 TB; // GR8 = <= signed
2549def SETLEm : I<0x9E, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00002550 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002551 "setle\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002552 [(store (X86setcc X86_COND_LE, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002553 TB; // [mem8] = <= signed
Bill Wendling0c52d0a2008-12-02 00:07:05 +00002554
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002555def SETGr : I<0x9F, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00002556 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002557 "setg\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002558 [(set GR8:$dst, (X86setcc X86_COND_G, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002559 TB; // GR8 = > signed
2560def SETGm : I<0x9F, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00002561 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002562 "setg\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002563 [(store (X86setcc X86_COND_G, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002564 TB; // [mem8] = > signed
2565
2566def SETBr : I<0x92, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00002567 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002568 "setb\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002569 [(set GR8:$dst, (X86setcc X86_COND_B, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002570 TB; // GR8 = < unsign
2571def SETBm : I<0x92, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00002572 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002573 "setb\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002574 [(store (X86setcc X86_COND_B, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002575 TB; // [mem8] = < unsign
Bill Wendling0c52d0a2008-12-02 00:07:05 +00002576
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002577def SETAEr : I<0x93, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00002578 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002579 "setae\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002580 [(set GR8:$dst, (X86setcc X86_COND_AE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002581 TB; // GR8 = >= unsign
2582def SETAEm : I<0x93, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00002583 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002584 "setae\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002585 [(store (X86setcc X86_COND_AE, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002586 TB; // [mem8] = >= unsign
Bill Wendling0c52d0a2008-12-02 00:07:05 +00002587
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002588def SETBEr : I<0x96, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00002589 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002590 "setbe\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002591 [(set GR8:$dst, (X86setcc X86_COND_BE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002592 TB; // GR8 = <= unsign
2593def SETBEm : I<0x96, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00002594 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002595 "setbe\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002596 [(store (X86setcc X86_COND_BE, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002597 TB; // [mem8] = <= unsign
Bill Wendling0c52d0a2008-12-02 00:07:05 +00002598
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002599def SETAr : I<0x97, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00002600 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002601 "seta\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002602 [(set GR8:$dst, (X86setcc X86_COND_A, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002603 TB; // GR8 = > signed
2604def SETAm : I<0x97, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00002605 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002606 "seta\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002607 [(store (X86setcc X86_COND_A, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002608 TB; // [mem8] = > signed
2609
2610def SETSr : I<0x98, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00002611 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002612 "sets\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002613 [(set GR8:$dst, (X86setcc X86_COND_S, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002614 TB; // GR8 = <sign bit>
2615def SETSm : I<0x98, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00002616 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002617 "sets\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002618 [(store (X86setcc X86_COND_S, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002619 TB; // [mem8] = <sign bit>
2620def SETNSr : I<0x99, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00002621 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002622 "setns\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002623 [(set GR8:$dst, (X86setcc X86_COND_NS, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002624 TB; // GR8 = !<sign bit>
2625def SETNSm : I<0x99, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00002626 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002627 "setns\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002628 [(store (X86setcc X86_COND_NS, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002629 TB; // [mem8] = !<sign bit>
Bill Wendling0c52d0a2008-12-02 00:07:05 +00002630
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002631def SETPr : I<0x9A, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00002632 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002633 "setp\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002634 [(set GR8:$dst, (X86setcc X86_COND_P, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002635 TB; // GR8 = parity
2636def SETPm : I<0x9A, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00002637 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002638 "setp\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002639 [(store (X86setcc X86_COND_P, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002640 TB; // [mem8] = parity
2641def SETNPr : I<0x9B, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00002642 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002643 "setnp\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002644 [(set GR8:$dst, (X86setcc X86_COND_NP, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002645 TB; // GR8 = not parity
2646def SETNPm : I<0x9B, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00002647 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002648 "setnp\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002649 [(store (X86setcc X86_COND_NP, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002650 TB; // [mem8] = not parity
Bill Wendling0c52d0a2008-12-02 00:07:05 +00002651
2652def SETOr : I<0x90, MRM0r,
2653 (outs GR8 :$dst), (ins),
2654 "seto\t$dst",
2655 [(set GR8:$dst, (X86setcc X86_COND_O, EFLAGS))]>,
2656 TB; // GR8 = overflow
2657def SETOm : I<0x90, MRM0m,
2658 (outs), (ins i8mem:$dst),
2659 "seto\t$dst",
2660 [(store (X86setcc X86_COND_O, EFLAGS), addr:$dst)]>,
2661 TB; // [mem8] = overflow
2662def SETNOr : I<0x91, MRM0r,
2663 (outs GR8 :$dst), (ins),
2664 "setno\t$dst",
2665 [(set GR8:$dst, (X86setcc X86_COND_NO, EFLAGS))]>,
2666 TB; // GR8 = not overflow
2667def SETNOm : I<0x91, MRM0m,
2668 (outs), (ins i8mem:$dst),
2669 "setno\t$dst",
2670 [(store (X86setcc X86_COND_NO, EFLAGS), addr:$dst)]>,
2671 TB; // [mem8] = not overflow
Evan Cheng950aac02007-09-25 01:57:46 +00002672} // Uses = [EFLAGS]
2673
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002674
2675// Integer comparisons
Evan Cheng55687072007-09-14 21:48:26 +00002676let Defs = [EFLAGS] in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002677def CMP8rr : I<0x38, MRMDestReg,
Evan Chengb783fa32007-07-19 01:14:50 +00002678 (outs), (ins GR8 :$src1, GR8 :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002679 "cmp{b}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002680 [(X86cmp GR8:$src1, GR8:$src2), (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002681def CMP16rr : I<0x39, MRMDestReg,
Evan Chengb783fa32007-07-19 01:14:50 +00002682 (outs), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002683 "cmp{w}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002684 [(X86cmp GR16:$src1, GR16:$src2), (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002685def CMP32rr : I<0x39, MRMDestReg,
Evan Chengb783fa32007-07-19 01:14:50 +00002686 (outs), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002687 "cmp{l}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002688 [(X86cmp GR32:$src1, GR32:$src2), (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002689def CMP8mr : I<0x38, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00002690 (outs), (ins i8mem :$src1, GR8 :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002691 "cmp{b}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002692 [(X86cmp (loadi8 addr:$src1), GR8:$src2),
2693 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002694def CMP16mr : I<0x39, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00002695 (outs), (ins i16mem:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002696 "cmp{w}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002697 [(X86cmp (loadi16 addr:$src1), GR16:$src2),
2698 (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002699def CMP32mr : I<0x39, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00002700 (outs), (ins i32mem:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002701 "cmp{l}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002702 [(X86cmp (loadi32 addr:$src1), GR32:$src2),
2703 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002704def CMP8rm : I<0x3A, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00002705 (outs), (ins GR8 :$src1, i8mem :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002706 "cmp{b}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002707 [(X86cmp GR8:$src1, (loadi8 addr:$src2)),
2708 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002709def CMP16rm : I<0x3B, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00002710 (outs), (ins GR16:$src1, i16mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002711 "cmp{w}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002712 [(X86cmp GR16:$src1, (loadi16 addr:$src2)),
2713 (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002714def CMP32rm : I<0x3B, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00002715 (outs), (ins GR32:$src1, i32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002716 "cmp{l}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002717 [(X86cmp GR32:$src1, (loadi32 addr:$src2)),
2718 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002719def CMP8ri : Ii8<0x80, MRM7r,
Evan Chengb783fa32007-07-19 01:14:50 +00002720 (outs), (ins GR8:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002721 "cmp{b}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002722 [(X86cmp GR8:$src1, imm:$src2), (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002723def CMP16ri : Ii16<0x81, MRM7r,
Evan Chengb783fa32007-07-19 01:14:50 +00002724 (outs), (ins GR16:$src1, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002725 "cmp{w}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002726 [(X86cmp GR16:$src1, imm:$src2),
2727 (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002728def CMP32ri : Ii32<0x81, MRM7r,
Evan Chengb783fa32007-07-19 01:14:50 +00002729 (outs), (ins GR32:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002730 "cmp{l}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002731 [(X86cmp GR32:$src1, imm:$src2), (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002732def CMP8mi : Ii8 <0x80, MRM7m,
Evan Chengb783fa32007-07-19 01:14:50 +00002733 (outs), (ins i8mem :$src1, i8imm :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002734 "cmp{b}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002735 [(X86cmp (loadi8 addr:$src1), imm:$src2),
2736 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002737def CMP16mi : Ii16<0x81, MRM7m,
Evan Chengb783fa32007-07-19 01:14:50 +00002738 (outs), (ins i16mem:$src1, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002739 "cmp{w}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002740 [(X86cmp (loadi16 addr:$src1), imm:$src2),
2741 (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002742def CMP32mi : Ii32<0x81, MRM7m,
Evan Chengb783fa32007-07-19 01:14:50 +00002743 (outs), (ins i32mem:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002744 "cmp{l}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002745 [(X86cmp (loadi32 addr:$src1), imm:$src2),
2746 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002747def CMP16ri8 : Ii8<0x83, MRM7r,
Evan Chengb783fa32007-07-19 01:14:50 +00002748 (outs), (ins GR16:$src1, i16i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002749 "cmp{w}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002750 [(X86cmp GR16:$src1, i16immSExt8:$src2),
2751 (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002752def CMP16mi8 : Ii8<0x83, MRM7m,
Evan Chengb783fa32007-07-19 01:14:50 +00002753 (outs), (ins i16mem:$src1, i16i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002754 "cmp{w}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002755 [(X86cmp (loadi16 addr:$src1), i16immSExt8:$src2),
2756 (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002757def CMP32mi8 : Ii8<0x83, MRM7m,
Evan Chengb783fa32007-07-19 01:14:50 +00002758 (outs), (ins i32mem:$src1, i32i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002759 "cmp{l}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002760 [(X86cmp (loadi32 addr:$src1), i32immSExt8:$src2),
2761 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002762def CMP32ri8 : Ii8<0x83, MRM7r,
Evan Chengb783fa32007-07-19 01:14:50 +00002763 (outs), (ins GR32:$src1, i32i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002764 "cmp{l}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002765 [(X86cmp GR32:$src1, i32immSExt8:$src2),
Evan Cheng950aac02007-09-25 01:57:46 +00002766 (implicit EFLAGS)]>;
2767} // Defs = [EFLAGS]
2768
Dan Gohman7fe9b7f2008-12-23 22:45:23 +00002769// Bit tests.
Dan Gohman7fe9b7f2008-12-23 22:45:23 +00002770// TODO: BTC, BTR, and BTS
2771let Defs = [EFLAGS] in {
Dan Gohmanfc4eddb2009-01-13 20:32:45 +00002772def BT16rr : I<0xA3, MRMDestReg, (outs), (ins GR16:$src1, GR16:$src2),
Dan Gohman7fe9b7f2008-12-23 22:45:23 +00002773 "bt{w}\t{$src2, $src1|$src1, $src2}",
2774 [(X86bt GR16:$src1, GR16:$src2),
Chris Lattner5a95cde2008-12-25 01:32:49 +00002775 (implicit EFLAGS)]>, OpSize, TB;
Dan Gohmanfc4eddb2009-01-13 20:32:45 +00002776def BT32rr : I<0xA3, MRMDestReg, (outs), (ins GR32:$src1, GR32:$src2),
Dan Gohman7fe9b7f2008-12-23 22:45:23 +00002777 "bt{l}\t{$src2, $src1|$src1, $src2}",
2778 [(X86bt GR32:$src1, GR32:$src2),
Chris Lattner5a95cde2008-12-25 01:32:49 +00002779 (implicit EFLAGS)]>, TB;
Dan Gohman85a228c2009-01-13 23:23:30 +00002780
2781// Unlike with the register+register form, the memory+register form of the
2782// bt instruction does not ignore the high bits of the index. From ISel's
2783// perspective, this is pretty bizarre. Disable these instructions for now.
2784//def BT16mr : I<0xA3, MRMDestMem, (outs), (ins i16mem:$src1, GR16:$src2),
2785// "bt{w}\t{$src2, $src1|$src1, $src2}",
2786// [(X86bt (loadi16 addr:$src1), GR16:$src2),
2787// (implicit EFLAGS)]>, OpSize, TB, Requires<[FastBTMem]>;
2788//def BT32mr : I<0xA3, MRMDestMem, (outs), (ins i32mem:$src1, GR32:$src2),
2789// "bt{l}\t{$src2, $src1|$src1, $src2}",
2790// [(X86bt (loadi32 addr:$src1), GR32:$src2),
2791// (implicit EFLAGS)]>, TB, Requires<[FastBTMem]>;
Dan Gohman46fb1cf2009-01-13 20:33:23 +00002792
2793def BT16ri8 : Ii8<0xBA, MRM4r, (outs), (ins GR16:$src1, i16i8imm:$src2),
2794 "bt{w}\t{$src2, $src1|$src1, $src2}",
2795 [(X86bt GR16:$src1, i16immSExt8:$src2),
2796 (implicit EFLAGS)]>, OpSize, TB;
2797def BT32ri8 : Ii8<0xBA, MRM4r, (outs), (ins GR32:$src1, i32i8imm:$src2),
2798 "bt{l}\t{$src2, $src1|$src1, $src2}",
2799 [(X86bt GR32:$src1, i32immSExt8:$src2),
2800 (implicit EFLAGS)]>, TB;
2801// Note that these instructions don't need FastBTMem because that
2802// only applies when the other operand is in a register. When it's
2803// an immediate, bt is still fast.
2804def BT16mi8 : Ii8<0xBA, MRM4m, (outs), (ins i16mem:$src1, i16i8imm:$src2),
2805 "bt{w}\t{$src2, $src1|$src1, $src2}",
2806 [(X86bt (loadi16 addr:$src1), i16immSExt8:$src2),
2807 (implicit EFLAGS)]>, OpSize, TB;
2808def BT32mi8 : Ii8<0xBA, MRM4m, (outs), (ins i32mem:$src1, i32i8imm:$src2),
2809 "bt{l}\t{$src2, $src1|$src1, $src2}",
2810 [(X86bt (loadi32 addr:$src1), i32immSExt8:$src2),
2811 (implicit EFLAGS)]>, TB;
Dan Gohman7fe9b7f2008-12-23 22:45:23 +00002812} // Defs = [EFLAGS]
2813
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002814// Sign/Zero extenders
Dan Gohman9203ab42008-07-30 18:09:17 +00002815// Use movsbl intead of movsbw; we don't care about the high 16 bits
2816// of the register here. This has a smaller encoding and avoids a
2817// partial-register update.
Evan Chengb783fa32007-07-19 01:14:50 +00002818def MOVSX16rr8 : I<0xBE, MRMSrcReg, (outs GR16:$dst), (ins GR8 :$src),
Dan Gohman9203ab42008-07-30 18:09:17 +00002819 "movs{bl|x}\t{$src, ${dst:subreg32}|${dst:subreg32}, $src}",
2820 [(set GR16:$dst, (sext GR8:$src))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00002821def MOVSX16rm8 : I<0xBE, MRMSrcMem, (outs GR16:$dst), (ins i8mem :$src),
Dan Gohman9203ab42008-07-30 18:09:17 +00002822 "movs{bl|x}\t{$src, ${dst:subreg32}|${dst:subreg32}, $src}",
2823 [(set GR16:$dst, (sextloadi16i8 addr:$src))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00002824def MOVSX32rr8 : I<0xBE, MRMSrcReg, (outs GR32:$dst), (ins GR8 :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002825 "movs{bl|x}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002826 [(set GR32:$dst, (sext GR8:$src))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00002827def MOVSX32rm8 : I<0xBE, MRMSrcMem, (outs GR32:$dst), (ins i8mem :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002828 "movs{bl|x}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002829 [(set GR32:$dst, (sextloadi32i8 addr:$src))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00002830def MOVSX32rr16: I<0xBF, MRMSrcReg, (outs GR32:$dst), (ins GR16:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002831 "movs{wl|x}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002832 [(set GR32:$dst, (sext GR16:$src))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00002833def MOVSX32rm16: I<0xBF, MRMSrcMem, (outs GR32:$dst), (ins i16mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002834 "movs{wl|x}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002835 [(set GR32:$dst, (sextloadi32i16 addr:$src))]>, TB;
2836
Dan Gohman9203ab42008-07-30 18:09:17 +00002837// Use movzbl intead of movzbw; we don't care about the high 16 bits
2838// of the register here. This has a smaller encoding and avoids a
2839// partial-register update.
Evan Chengb783fa32007-07-19 01:14:50 +00002840def MOVZX16rr8 : I<0xB6, MRMSrcReg, (outs GR16:$dst), (ins GR8 :$src),
Dan Gohman9203ab42008-07-30 18:09:17 +00002841 "movz{bl|x}\t{$src, ${dst:subreg32}|${dst:subreg32}, $src}",
2842 [(set GR16:$dst, (zext GR8:$src))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00002843def MOVZX16rm8 : I<0xB6, MRMSrcMem, (outs GR16:$dst), (ins i8mem :$src),
Dan Gohman9203ab42008-07-30 18:09:17 +00002844 "movz{bl|x}\t{$src, ${dst:subreg32}|${dst:subreg32}, $src}",
2845 [(set GR16:$dst, (zextloadi16i8 addr:$src))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00002846def MOVZX32rr8 : I<0xB6, MRMSrcReg, (outs GR32:$dst), (ins GR8 :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002847 "movz{bl|x}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002848 [(set GR32:$dst, (zext GR8:$src))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00002849def MOVZX32rm8 : I<0xB6, MRMSrcMem, (outs GR32:$dst), (ins i8mem :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002850 "movz{bl|x}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002851 [(set GR32:$dst, (zextloadi32i8 addr:$src))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00002852def MOVZX32rr16: I<0xB7, MRMSrcReg, (outs GR32:$dst), (ins GR16:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002853 "movz{wl|x}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002854 [(set GR32:$dst, (zext GR16:$src))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00002855def MOVZX32rm16: I<0xB7, MRMSrcMem, (outs GR32:$dst), (ins i16mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002856 "movz{wl|x}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002857 [(set GR32:$dst, (zextloadi32i16 addr:$src))]>, TB;
2858
Chris Lattnerc90ee9c2008-01-10 07:59:24 +00002859let neverHasSideEffects = 1 in {
2860 let Defs = [AX], Uses = [AL] in
2861 def CBW : I<0x98, RawFrm, (outs), (ins),
2862 "{cbtw|cbw}", []>, OpSize; // AX = signext(AL)
2863 let Defs = [EAX], Uses = [AX] in
2864 def CWDE : I<0x98, RawFrm, (outs), (ins),
2865 "{cwtl|cwde}", []>; // EAX = signext(AX)
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002866
Chris Lattnerc90ee9c2008-01-10 07:59:24 +00002867 let Defs = [AX,DX], Uses = [AX] in
2868 def CWD : I<0x99, RawFrm, (outs), (ins),
2869 "{cwtd|cwd}", []>, OpSize; // DX:AX = signext(AX)
2870 let Defs = [EAX,EDX], Uses = [EAX] in
2871 def CDQ : I<0x99, RawFrm, (outs), (ins),
2872 "{cltd|cdq}", []>; // EDX:EAX = signext(EAX)
2873}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002874
2875//===----------------------------------------------------------------------===//
2876// Alias Instructions
2877//===----------------------------------------------------------------------===//
2878
2879// Alias instructions that map movr0 to xor.
2880// FIXME: remove when we can teach regalloc that xor reg, reg is ok.
Bill Wendlingba5d5b02008-05-29 01:02:09 +00002881let Defs = [EFLAGS], isReMaterializable = 1, isAsCheapAsAMove = 1 in {
Evan Chengb783fa32007-07-19 01:14:50 +00002882def MOV8r0 : I<0x30, MRMInitReg, (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002883 "xor{b}\t$dst, $dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002884 [(set GR8:$dst, 0)]>;
Dan Gohman9203ab42008-07-30 18:09:17 +00002885// Use xorl instead of xorw since we don't care about the high 16 bits,
2886// it's smaller, and it avoids a partial-register update.
Evan Chengb783fa32007-07-19 01:14:50 +00002887def MOV16r0 : I<0x31, MRMInitReg, (outs GR16:$dst), (ins),
Dan Gohman9203ab42008-07-30 18:09:17 +00002888 "xor{l}\t${dst:subreg32}, ${dst:subreg32}",
2889 [(set GR16:$dst, 0)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002890def MOV32r0 : I<0x31, MRMInitReg, (outs GR32:$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002891 "xor{l}\t$dst, $dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002892 [(set GR32:$dst, 0)]>;
Dan Gohman8aef09b2007-09-07 21:32:51 +00002893}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002894
2895// Basic operations on GR16 / GR32 subclasses GR16_ and GR32_ which contains only
2896// those registers that have GR8 sub-registers (i.e. AX - DX, EAX - EDX).
Evan Chengbd0ca9c2009-02-05 08:42:55 +00002897let neverHasSideEffects = 1, isAsCheapAsAMove = 1 in {
Evan Chengb783fa32007-07-19 01:14:50 +00002898def MOV16to16_ : I<0x89, MRMDestReg, (outs GR16_:$dst), (ins GR16:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002899 "mov{w}\t{$src, $dst|$dst, $src}", []>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002900def MOV32to32_ : I<0x89, MRMDestReg, (outs GR32_:$dst), (ins GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002901 "mov{l}\t{$src, $dst|$dst, $src}", []>;
Chris Lattnerc90ee9c2008-01-10 07:59:24 +00002902
Evan Chengb783fa32007-07-19 01:14:50 +00002903def MOV16_rr : I<0x89, MRMDestReg, (outs GR16_:$dst), (ins GR16_:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002904 "mov{w}\t{$src, $dst|$dst, $src}", []>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002905def MOV32_rr : I<0x89, MRMDestReg, (outs GR32_:$dst), (ins GR32_:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002906 "mov{l}\t{$src, $dst|$dst, $src}", []>;
Chris Lattnerc90ee9c2008-01-10 07:59:24 +00002907} // neverHasSideEffects
2908
Dan Gohman5574cc72008-12-03 18:15:48 +00002909let canFoldAsLoad = 1, mayLoad = 1, isReMaterializable = 1, mayHaveSideEffects = 1 in {
Evan Chengb783fa32007-07-19 01:14:50 +00002910def MOV16_rm : I<0x8B, MRMSrcMem, (outs GR16_:$dst), (ins i16mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002911 "mov{w}\t{$src, $dst|$dst, $src}", []>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002912def MOV32_rm : I<0x8B, MRMSrcMem, (outs GR32_:$dst), (ins i32mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002913 "mov{l}\t{$src, $dst|$dst, $src}", []>;
Evan Cheng4e84e452007-08-30 05:49:43 +00002914}
Chris Lattnerc90ee9c2008-01-10 07:59:24 +00002915let mayStore = 1, neverHasSideEffects = 1 in {
Evan Chengb783fa32007-07-19 01:14:50 +00002916def MOV16_mr : I<0x89, MRMDestMem, (outs), (ins i16mem:$dst, GR16_:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002917 "mov{w}\t{$src, $dst|$dst, $src}", []>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002918def MOV32_mr : I<0x89, MRMDestMem, (outs), (ins i32mem:$dst, GR32_:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002919 "mov{l}\t{$src, $dst|$dst, $src}", []>;
Chris Lattnerc90ee9c2008-01-10 07:59:24 +00002920}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002921
2922//===----------------------------------------------------------------------===//
2923// Thread Local Storage Instructions
2924//
2925
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002926let Uses = [EBX] in
Anton Korobeynikov4fbf00b2008-05-04 21:36:32 +00002927def TLS_addr32 : I<0, Pseudo, (outs GR32:$dst), (ins i32imm:$sym),
2928 "leal\t${sym:mem}(,%ebx,1), $dst",
2929 [(set GR32:$dst, (X86tlsaddr tglobaltlsaddr:$sym))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002930
sampo9cc09a32009-01-26 01:24:32 +00002931let AddedComplexity = 5 in
2932def GS_MOV32rm : I<0x8B, MRMSrcMem, (outs GR32:$dst), (ins i32mem:$src),
2933 "movl\t%gs:$src, $dst",
2934 [(set GR32:$dst, (gsload addr:$src))]>, SegGS;
2935
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002936//===----------------------------------------------------------------------===//
2937// DWARF Pseudo Instructions
2938//
2939
Evan Chengb783fa32007-07-19 01:14:50 +00002940def DWARF_LOC : I<0, Pseudo, (outs),
2941 (ins i32imm:$line, i32imm:$col, i32imm:$file),
Dan Gohman77af4a82007-09-24 19:25:06 +00002942 ".loc\t${file:debug} ${line:debug} ${col:debug}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002943 [(dwarf_loc (i32 imm:$line), (i32 imm:$col),
2944 (i32 imm:$file))]>;
2945
2946//===----------------------------------------------------------------------===//
2947// EH Pseudo Instructions
2948//
2949let isTerminator = 1, isReturn = 1, isBarrier = 1,
Evan Cheng37e7c752007-07-21 00:34:19 +00002950 hasCtrlDep = 1 in {
Evan Chengb783fa32007-07-19 01:14:50 +00002951def EH_RETURN : I<0xC3, RawFrm, (outs), (ins GR32:$addr),
Dan Gohman91888f02007-07-31 20:11:57 +00002952 "ret\t#eh_return, addr: $addr",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002953 [(X86ehret GR32:$addr)]>;
2954
2955}
2956
2957//===----------------------------------------------------------------------===//
Andrew Lenharthe44f3902008-02-21 06:45:13 +00002958// Atomic support
2959//
Andrew Lenharth7a5a4b22008-03-01 13:37:02 +00002960
Evan Cheng3e171562008-04-19 01:20:30 +00002961// Atomic swap. These are just normal xchg instructions. But since a memory
2962// operand is referenced, the atomicity is ensured.
Dan Gohmana41a1c092008-08-06 15:52:50 +00002963let Constraints = "$val = $dst" in {
Evan Cheng3e171562008-04-19 01:20:30 +00002964def XCHG32rm : I<0x87, MRMSrcMem, (outs GR32:$dst), (ins i32mem:$ptr, GR32:$val),
2965 "xchg{l}\t{$val, $ptr|$ptr, $val}",
2966 [(set GR32:$dst, (atomic_swap_32 addr:$ptr, GR32:$val))]>;
2967def XCHG16rm : I<0x87, MRMSrcMem, (outs GR16:$dst), (ins i16mem:$ptr, GR16:$val),
2968 "xchg{w}\t{$val, $ptr|$ptr, $val}",
2969 [(set GR16:$dst, (atomic_swap_16 addr:$ptr, GR16:$val))]>,
2970 OpSize;
2971def XCHG8rm : I<0x86, MRMSrcMem, (outs GR8:$dst), (ins i8mem:$ptr, GR8:$val),
2972 "xchg{b}\t{$val, $ptr|$ptr, $val}",
2973 [(set GR8:$dst, (atomic_swap_8 addr:$ptr, GR8:$val))]>;
2974}
2975
Evan Chengd49dbb82008-04-18 20:55:36 +00002976// Atomic compare and swap.
Andrew Lenharth7dfe23f2008-03-01 21:52:34 +00002977let Defs = [EAX, EFLAGS], Uses = [EAX] in {
Evan Chengd49dbb82008-04-18 20:55:36 +00002978def LCMPXCHG32 : I<0xB1, MRMDestMem, (outs), (ins i32mem:$ptr, GR32:$swap),
Dale Johannesend20e4452008-08-19 18:47:28 +00002979 "lock\n\tcmpxchg{l}\t{$swap, $ptr|$ptr, $swap}",
Evan Cheng09fbdee2008-03-04 03:20:06 +00002980 [(X86cas addr:$ptr, GR32:$swap, 4)]>, TB, LOCK;
Andrew Lenharth7a5a4b22008-03-01 13:37:02 +00002981}
Dale Johannesenf160d802008-10-02 18:53:47 +00002982let Defs = [EAX, EDX, EFLAGS], Uses = [EAX, EBX, ECX, EDX] in {
Anton Korobeynikovc4067392008-07-22 16:22:48 +00002983def LCMPXCHG8B : I<0xC7, MRM1m, (outs), (ins i32mem:$ptr),
Dale Johannesend20e4452008-08-19 18:47:28 +00002984 "lock\n\tcmpxchg8b\t$ptr",
Andrew Lenharth81580822008-03-05 01:15:49 +00002985 [(X86cas8 addr:$ptr)]>, TB, LOCK;
2986}
Andrew Lenharth7dfe23f2008-03-01 21:52:34 +00002987
2988let Defs = [AX, EFLAGS], Uses = [AX] in {
Evan Chengd49dbb82008-04-18 20:55:36 +00002989def LCMPXCHG16 : I<0xB1, MRMDestMem, (outs), (ins i16mem:$ptr, GR16:$swap),
Dale Johannesend20e4452008-08-19 18:47:28 +00002990 "lock\n\tcmpxchg{w}\t{$swap, $ptr|$ptr, $swap}",
Evan Cheng09fbdee2008-03-04 03:20:06 +00002991 [(X86cas addr:$ptr, GR16:$swap, 2)]>, TB, OpSize, LOCK;
Andrew Lenharth7a5a4b22008-03-01 13:37:02 +00002992}
Andrew Lenharth7dfe23f2008-03-01 21:52:34 +00002993let Defs = [AL, EFLAGS], Uses = [AL] in {
Evan Chengd49dbb82008-04-18 20:55:36 +00002994def LCMPXCHG8 : I<0xB0, MRMDestMem, (outs), (ins i8mem:$ptr, GR8:$swap),
Dale Johannesend20e4452008-08-19 18:47:28 +00002995 "lock\n\tcmpxchg{b}\t{$swap, $ptr|$ptr, $swap}",
Evan Cheng09fbdee2008-03-04 03:20:06 +00002996 [(X86cas addr:$ptr, GR8:$swap, 1)]>, TB, LOCK;
Andrew Lenharth7a5a4b22008-03-01 13:37:02 +00002997}
2998
Evan Chengd49dbb82008-04-18 20:55:36 +00002999// Atomic exchange and add
3000let Constraints = "$val = $dst", Defs = [EFLAGS] in {
3001def LXADD32 : I<0xC1, MRMSrcMem, (outs GR32:$dst), (ins i32mem:$ptr, GR32:$val),
Dale Johannesend20e4452008-08-19 18:47:28 +00003002 "lock\n\txadd{l}\t{$val, $ptr|$ptr, $val}",
Mon P Wang6bde9ec2008-06-25 08:15:39 +00003003 [(set GR32:$dst, (atomic_load_add_32 addr:$ptr, GR32:$val))]>,
Evan Chengd49dbb82008-04-18 20:55:36 +00003004 TB, LOCK;
3005def LXADD16 : I<0xC1, MRMSrcMem, (outs GR16:$dst), (ins i16mem:$ptr, GR16:$val),
Dale Johannesend20e4452008-08-19 18:47:28 +00003006 "lock\n\txadd{w}\t{$val, $ptr|$ptr, $val}",
Mon P Wang6bde9ec2008-06-25 08:15:39 +00003007 [(set GR16:$dst, (atomic_load_add_16 addr:$ptr, GR16:$val))]>,
Evan Chengd49dbb82008-04-18 20:55:36 +00003008 TB, OpSize, LOCK;
3009def LXADD8 : I<0xC0, MRMSrcMem, (outs GR8:$dst), (ins i8mem:$ptr, GR8:$val),
Dale Johannesend20e4452008-08-19 18:47:28 +00003010 "lock\n\txadd{b}\t{$val, $ptr|$ptr, $val}",
Mon P Wang6bde9ec2008-06-25 08:15:39 +00003011 [(set GR8:$dst, (atomic_load_add_8 addr:$ptr, GR8:$val))]>,
Evan Chengd49dbb82008-04-18 20:55:36 +00003012 TB, LOCK;
Andrew Lenharth7a5a4b22008-03-01 13:37:02 +00003013}
3014
Mon P Wang6bde9ec2008-06-25 08:15:39 +00003015// Atomic exchange, and, or, xor
Mon P Wang078a62d2008-05-05 19:05:59 +00003016let Constraints = "$val = $dst", Defs = [EFLAGS],
3017 usesCustomDAGSchedInserter = 1 in {
Dan Gohman8aeb61f2008-05-12 20:22:45 +00003018def ATOMAND32 : I<0, Pseudo, (outs GR32:$dst),(ins i32mem:$ptr, GR32:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003019 "#ATOMAND32 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003020 [(set GR32:$dst, (atomic_load_and_32 addr:$ptr, GR32:$val))]>;
Dan Gohman8aeb61f2008-05-12 20:22:45 +00003021def ATOMOR32 : I<0, Pseudo, (outs GR32:$dst),(ins i32mem:$ptr, GR32:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003022 "#ATOMOR32 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003023 [(set GR32:$dst, (atomic_load_or_32 addr:$ptr, GR32:$val))]>;
Dan Gohman8aeb61f2008-05-12 20:22:45 +00003024def ATOMXOR32 : I<0, Pseudo,(outs GR32:$dst),(ins i32mem:$ptr, GR32:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003025 "#ATOMXOR32 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003026 [(set GR32:$dst, (atomic_load_xor_32 addr:$ptr, GR32:$val))]>;
Andrew Lenharthaf02d592008-06-14 05:48:15 +00003027def ATOMNAND32 : I<0, Pseudo,(outs GR32:$dst),(ins i32mem:$ptr, GR32:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003028 "#ATOMNAND32 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003029 [(set GR32:$dst, (atomic_load_nand_32 addr:$ptr, GR32:$val))]>;
Dan Gohman8aeb61f2008-05-12 20:22:45 +00003030def ATOMMIN32: I<0, Pseudo, (outs GR32:$dst), (ins i32mem:$ptr, GR32:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003031 "#ATOMMIN32 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003032 [(set GR32:$dst, (atomic_load_min_32 addr:$ptr, GR32:$val))]>;
Dan Gohman8aeb61f2008-05-12 20:22:45 +00003033def ATOMMAX32: I<0, Pseudo, (outs GR32:$dst),(ins i32mem:$ptr, GR32:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003034 "#ATOMMAX32 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003035 [(set GR32:$dst, (atomic_load_max_32 addr:$ptr, GR32:$val))]>;
Dan Gohman8aeb61f2008-05-12 20:22:45 +00003036def ATOMUMIN32: I<0, Pseudo, (outs GR32:$dst),(ins i32mem:$ptr, GR32:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003037 "#ATOMUMIN32 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003038 [(set GR32:$dst, (atomic_load_umin_32 addr:$ptr, GR32:$val))]>;
Dan Gohman8aeb61f2008-05-12 20:22:45 +00003039def ATOMUMAX32: I<0, Pseudo, (outs GR32:$dst),(ins i32mem:$ptr, GR32:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003040 "#ATOMUMAX32 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003041 [(set GR32:$dst, (atomic_load_umax_32 addr:$ptr, GR32:$val))]>;
Dale Johannesend20e4452008-08-19 18:47:28 +00003042
3043def ATOMAND16 : I<0, Pseudo, (outs GR16:$dst),(ins i16mem:$ptr, GR16:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003044 "#ATOMAND16 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003045 [(set GR16:$dst, (atomic_load_and_16 addr:$ptr, GR16:$val))]>;
Dale Johannesend20e4452008-08-19 18:47:28 +00003046def ATOMOR16 : I<0, Pseudo, (outs GR16:$dst),(ins i16mem:$ptr, GR16:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003047 "#ATOMOR16 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003048 [(set GR16:$dst, (atomic_load_or_16 addr:$ptr, GR16:$val))]>;
Dale Johannesend20e4452008-08-19 18:47:28 +00003049def ATOMXOR16 : I<0, Pseudo,(outs GR16:$dst),(ins i16mem:$ptr, GR16:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003050 "#ATOMXOR16 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003051 [(set GR16:$dst, (atomic_load_xor_16 addr:$ptr, GR16:$val))]>;
Dale Johannesend20e4452008-08-19 18:47:28 +00003052def ATOMNAND16 : I<0, Pseudo,(outs GR16:$dst),(ins i16mem:$ptr, GR16:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003053 "#ATOMNAND16 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003054 [(set GR16:$dst, (atomic_load_nand_16 addr:$ptr, GR16:$val))]>;
Dale Johannesend20e4452008-08-19 18:47:28 +00003055def ATOMMIN16: I<0, Pseudo, (outs GR16:$dst), (ins i16mem:$ptr, GR16:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003056 "#ATOMMIN16 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003057 [(set GR16:$dst, (atomic_load_min_16 addr:$ptr, GR16:$val))]>;
Dale Johannesend20e4452008-08-19 18:47:28 +00003058def ATOMMAX16: I<0, Pseudo, (outs GR16:$dst),(ins i16mem:$ptr, GR16:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003059 "#ATOMMAX16 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003060 [(set GR16:$dst, (atomic_load_max_16 addr:$ptr, GR16:$val))]>;
Dale Johannesend20e4452008-08-19 18:47:28 +00003061def ATOMUMIN16: I<0, Pseudo, (outs GR16:$dst),(ins i16mem:$ptr, GR16:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003062 "#ATOMUMIN16 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003063 [(set GR16:$dst, (atomic_load_umin_16 addr:$ptr, GR16:$val))]>;
Dale Johannesend20e4452008-08-19 18:47:28 +00003064def ATOMUMAX16: I<0, Pseudo, (outs GR16:$dst),(ins i16mem:$ptr, GR16:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003065 "#ATOMUMAX16 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003066 [(set GR16:$dst, (atomic_load_umax_16 addr:$ptr, GR16:$val))]>;
Dale Johannesend20e4452008-08-19 18:47:28 +00003067
3068def ATOMAND8 : I<0, Pseudo, (outs GR8:$dst),(ins i8mem:$ptr, GR8:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003069 "#ATOMAND8 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003070 [(set GR8:$dst, (atomic_load_and_8 addr:$ptr, GR8:$val))]>;
Dale Johannesend20e4452008-08-19 18:47:28 +00003071def ATOMOR8 : I<0, Pseudo, (outs GR8:$dst),(ins i8mem:$ptr, GR8:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003072 "#ATOMOR8 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003073 [(set GR8:$dst, (atomic_load_or_8 addr:$ptr, GR8:$val))]>;
Dale Johannesend20e4452008-08-19 18:47:28 +00003074def ATOMXOR8 : I<0, Pseudo,(outs GR8:$dst),(ins i8mem:$ptr, GR8:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003075 "#ATOMXOR8 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003076 [(set GR8:$dst, (atomic_load_xor_8 addr:$ptr, GR8:$val))]>;
Dale Johannesend20e4452008-08-19 18:47:28 +00003077def ATOMNAND8 : I<0, Pseudo,(outs GR8:$dst),(ins i8mem:$ptr, GR8:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003078 "#ATOMNAND8 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003079 [(set GR8:$dst, (atomic_load_nand_8 addr:$ptr, GR8:$val))]>;
Mon P Wang078a62d2008-05-05 19:05:59 +00003080}
3081
Dale Johannesenf160d802008-10-02 18:53:47 +00003082let Constraints = "$val1 = $dst1, $val2 = $dst2",
3083 Defs = [EFLAGS, EAX, EBX, ECX, EDX],
3084 Uses = [EAX, EBX, ECX, EDX],
Dale Johannesen44eb5372008-10-03 19:41:08 +00003085 mayLoad = 1, mayStore = 1,
Dale Johannesenf160d802008-10-02 18:53:47 +00003086 usesCustomDAGSchedInserter = 1 in {
3087def ATOMAND6432 : I<0, Pseudo, (outs GR32:$dst1, GR32:$dst2),
3088 (ins i64mem:$ptr, GR32:$val1, GR32:$val2),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003089 "#ATOMAND6432 PSEUDO!", []>;
Dale Johannesenf160d802008-10-02 18:53:47 +00003090def ATOMOR6432 : I<0, Pseudo, (outs GR32:$dst1, GR32:$dst2),
3091 (ins i64mem:$ptr, GR32:$val1, GR32:$val2),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003092 "#ATOMOR6432 PSEUDO!", []>;
Dale Johannesenf160d802008-10-02 18:53:47 +00003093def ATOMXOR6432 : I<0, Pseudo, (outs GR32:$dst1, GR32:$dst2),
3094 (ins i64mem:$ptr, GR32:$val1, GR32:$val2),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003095 "#ATOMXOR6432 PSEUDO!", []>;
Dale Johannesenf160d802008-10-02 18:53:47 +00003096def ATOMNAND6432 : I<0, Pseudo, (outs GR32:$dst1, GR32:$dst2),
3097 (ins i64mem:$ptr, GR32:$val1, GR32:$val2),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003098 "#ATOMNAND6432 PSEUDO!", []>;
Dale Johannesenf160d802008-10-02 18:53:47 +00003099def ATOMADD6432 : I<0, Pseudo, (outs GR32:$dst1, GR32:$dst2),
3100 (ins i64mem:$ptr, GR32:$val1, GR32:$val2),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003101 "#ATOMADD6432 PSEUDO!", []>;
Dale Johannesenf160d802008-10-02 18:53:47 +00003102def ATOMSUB6432 : I<0, Pseudo, (outs GR32:$dst1, GR32:$dst2),
3103 (ins i64mem:$ptr, GR32:$val1, GR32:$val2),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003104 "#ATOMSUB6432 PSEUDO!", []>;
Dale Johannesen51c58ee2008-10-03 22:25:52 +00003105def ATOMSWAP6432 : I<0, Pseudo, (outs GR32:$dst1, GR32:$dst2),
3106 (ins i64mem:$ptr, GR32:$val1, GR32:$val2),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003107 "#ATOMSWAP6432 PSEUDO!", []>;
Dale Johannesenf160d802008-10-02 18:53:47 +00003108}
3109
Andrew Lenharthe44f3902008-02-21 06:45:13 +00003110//===----------------------------------------------------------------------===//
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003111// Non-Instruction Patterns
3112//===----------------------------------------------------------------------===//
3113
Bill Wendlingfef06052008-09-16 21:48:12 +00003114// ConstantPool GlobalAddress, ExternalSymbol, and JumpTable
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003115def : Pat<(i32 (X86Wrapper tconstpool :$dst)), (MOV32ri tconstpool :$dst)>;
3116def : Pat<(i32 (X86Wrapper tjumptable :$dst)), (MOV32ri tjumptable :$dst)>;
Nate Begemanb52948972008-04-12 00:47:57 +00003117def : Pat<(i32 (X86Wrapper tglobaltlsaddr:$dst)),(MOV32ri tglobaltlsaddr:$dst)>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003118def : Pat<(i32 (X86Wrapper tglobaladdr :$dst)), (MOV32ri tglobaladdr :$dst)>;
3119def : Pat<(i32 (X86Wrapper texternalsym:$dst)), (MOV32ri texternalsym:$dst)>;
3120
3121def : Pat<(add GR32:$src1, (X86Wrapper tconstpool:$src2)),
3122 (ADD32ri GR32:$src1, tconstpool:$src2)>;
3123def : Pat<(add GR32:$src1, (X86Wrapper tjumptable:$src2)),
3124 (ADD32ri GR32:$src1, tjumptable:$src2)>;
3125def : Pat<(add GR32:$src1, (X86Wrapper tglobaladdr :$src2)),
3126 (ADD32ri GR32:$src1, tglobaladdr:$src2)>;
3127def : Pat<(add GR32:$src1, (X86Wrapper texternalsym:$src2)),
3128 (ADD32ri GR32:$src1, texternalsym:$src2)>;
3129
3130def : Pat<(store (i32 (X86Wrapper tglobaladdr:$src)), addr:$dst),
3131 (MOV32mi addr:$dst, tglobaladdr:$src)>;
3132def : Pat<(store (i32 (X86Wrapper texternalsym:$src)), addr:$dst),
3133 (MOV32mi addr:$dst, texternalsym:$src)>;
3134
3135// Calls
Arnold Schwaighofere2d6bbb2007-10-11 19:40:01 +00003136// tailcall stuff
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003137def : Pat<(X86tailcall GR32:$dst),
Arnold Schwaighofere2d6bbb2007-10-11 19:40:01 +00003138 (TAILCALL)>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003139
3140def : Pat<(X86tailcall (i32 tglobaladdr:$dst)),
Arnold Schwaighofere2d6bbb2007-10-11 19:40:01 +00003141 (TAILCALL)>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003142def : Pat<(X86tailcall (i32 texternalsym:$dst)),
Arnold Schwaighofere2d6bbb2007-10-11 19:40:01 +00003143 (TAILCALL)>;
3144
3145def : Pat<(X86tcret GR32:$dst, imm:$off),
3146 (TCRETURNri GR32:$dst, imm:$off)>;
3147
3148def : Pat<(X86tcret (i32 tglobaladdr:$dst), imm:$off),
3149 (TCRETURNdi texternalsym:$dst, imm:$off)>;
3150
3151def : Pat<(X86tcret (i32 texternalsym:$dst), imm:$off),
3152 (TCRETURNdi texternalsym:$dst, imm:$off)>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003153
3154def : Pat<(X86call (i32 tglobaladdr:$dst)),
3155 (CALLpcrel32 tglobaladdr:$dst)>;
3156def : Pat<(X86call (i32 texternalsym:$dst)),
3157 (CALLpcrel32 texternalsym:$dst)>;
3158
3159// X86 specific add which produces a flag.
3160def : Pat<(addc GR32:$src1, GR32:$src2),
3161 (ADD32rr GR32:$src1, GR32:$src2)>;
3162def : Pat<(addc GR32:$src1, (load addr:$src2)),
3163 (ADD32rm GR32:$src1, addr:$src2)>;
3164def : Pat<(addc GR32:$src1, imm:$src2),
3165 (ADD32ri GR32:$src1, imm:$src2)>;
3166def : Pat<(addc GR32:$src1, i32immSExt8:$src2),
3167 (ADD32ri8 GR32:$src1, i32immSExt8:$src2)>;
3168
3169def : Pat<(subc GR32:$src1, GR32:$src2),
3170 (SUB32rr GR32:$src1, GR32:$src2)>;
3171def : Pat<(subc GR32:$src1, (load addr:$src2)),
3172 (SUB32rm GR32:$src1, addr:$src2)>;
3173def : Pat<(subc GR32:$src1, imm:$src2),
3174 (SUB32ri GR32:$src1, imm:$src2)>;
3175def : Pat<(subc GR32:$src1, i32immSExt8:$src2),
3176 (SUB32ri8 GR32:$src1, i32immSExt8:$src2)>;
3177
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003178// Comparisons.
3179
3180// TEST R,R is smaller than CMP R,0
Evan Cheng621216e2007-09-29 00:00:36 +00003181def : Pat<(parallel (X86cmp GR8:$src1, 0), (implicit EFLAGS)),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003182 (TEST8rr GR8:$src1, GR8:$src1)>;
Evan Cheng621216e2007-09-29 00:00:36 +00003183def : Pat<(parallel (X86cmp GR16:$src1, 0), (implicit EFLAGS)),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003184 (TEST16rr GR16:$src1, GR16:$src1)>;
Evan Cheng621216e2007-09-29 00:00:36 +00003185def : Pat<(parallel (X86cmp GR32:$src1, 0), (implicit EFLAGS)),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003186 (TEST32rr GR32:$src1, GR32:$src1)>;
3187
Dan Gohman0a3c5222009-01-07 01:00:24 +00003188// Conditional moves with folded loads with operands swapped and conditions
3189// inverted.
3190def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_B, EFLAGS),
3191 (CMOVAE16rm GR16:$src2, addr:$src1)>;
3192def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_B, EFLAGS),
3193 (CMOVAE32rm GR32:$src2, addr:$src1)>;
3194def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_AE, EFLAGS),
3195 (CMOVB16rm GR16:$src2, addr:$src1)>;
3196def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_AE, EFLAGS),
3197 (CMOVB32rm GR32:$src2, addr:$src1)>;
3198def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_E, EFLAGS),
3199 (CMOVNE16rm GR16:$src2, addr:$src1)>;
3200def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_E, EFLAGS),
3201 (CMOVNE32rm GR32:$src2, addr:$src1)>;
3202def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_NE, EFLAGS),
3203 (CMOVE16rm GR16:$src2, addr:$src1)>;
3204def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_NE, EFLAGS),
3205 (CMOVE32rm GR32:$src2, addr:$src1)>;
3206def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_BE, EFLAGS),
3207 (CMOVA16rm GR16:$src2, addr:$src1)>;
3208def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_BE, EFLAGS),
3209 (CMOVA32rm GR32:$src2, addr:$src1)>;
3210def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_A, EFLAGS),
3211 (CMOVBE16rm GR16:$src2, addr:$src1)>;
3212def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_A, EFLAGS),
3213 (CMOVBE32rm GR32:$src2, addr:$src1)>;
3214def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_L, EFLAGS),
3215 (CMOVGE16rm GR16:$src2, addr:$src1)>;
3216def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_L, EFLAGS),
3217 (CMOVGE32rm GR32:$src2, addr:$src1)>;
3218def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_GE, EFLAGS),
3219 (CMOVL16rm GR16:$src2, addr:$src1)>;
3220def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_GE, EFLAGS),
3221 (CMOVL32rm GR32:$src2, addr:$src1)>;
3222def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_LE, EFLAGS),
3223 (CMOVG16rm GR16:$src2, addr:$src1)>;
3224def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_LE, EFLAGS),
3225 (CMOVG32rm GR32:$src2, addr:$src1)>;
3226def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_G, EFLAGS),
3227 (CMOVLE16rm GR16:$src2, addr:$src1)>;
3228def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_G, EFLAGS),
3229 (CMOVLE32rm GR32:$src2, addr:$src1)>;
3230def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_P, EFLAGS),
3231 (CMOVNP16rm GR16:$src2, addr:$src1)>;
3232def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_P, EFLAGS),
3233 (CMOVNP32rm GR32:$src2, addr:$src1)>;
3234def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_NP, EFLAGS),
3235 (CMOVP16rm GR16:$src2, addr:$src1)>;
3236def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_NP, EFLAGS),
3237 (CMOVP32rm GR32:$src2, addr:$src1)>;
3238def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_S, EFLAGS),
3239 (CMOVNS16rm GR16:$src2, addr:$src1)>;
3240def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_S, EFLAGS),
3241 (CMOVNS32rm GR32:$src2, addr:$src1)>;
3242def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_NS, EFLAGS),
3243 (CMOVS16rm GR16:$src2, addr:$src1)>;
3244def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_NS, EFLAGS),
3245 (CMOVS32rm GR32:$src2, addr:$src1)>;
3246def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_O, EFLAGS),
3247 (CMOVNO16rm GR16:$src2, addr:$src1)>;
3248def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_O, EFLAGS),
3249 (CMOVNO32rm GR32:$src2, addr:$src1)>;
3250def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_NO, EFLAGS),
3251 (CMOVO16rm GR16:$src2, addr:$src1)>;
3252def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_NO, EFLAGS),
3253 (CMOVO32rm GR32:$src2, addr:$src1)>;
3254
Duncan Sands082524c2008-01-23 20:39:46 +00003255// zextload bool -> zextload byte
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003256def : Pat<(zextloadi8i1 addr:$src), (MOV8rm addr:$src)>;
3257def : Pat<(zextloadi16i1 addr:$src), (MOVZX16rm8 addr:$src)>;
3258def : Pat<(zextloadi32i1 addr:$src), (MOVZX32rm8 addr:$src)>;
3259
3260// extload bool -> extload byte
3261def : Pat<(extloadi8i1 addr:$src), (MOV8rm addr:$src)>;
Bill Wendlingce1c5c12008-08-22 20:51:05 +00003262def : Pat<(extloadi16i1 addr:$src), (MOVZX16rm8 addr:$src)>,
3263 Requires<[In32BitMode]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003264def : Pat<(extloadi32i1 addr:$src), (MOVZX32rm8 addr:$src)>;
Bill Wendlingce1c5c12008-08-22 20:51:05 +00003265def : Pat<(extloadi16i8 addr:$src), (MOVZX16rm8 addr:$src)>,
3266 Requires<[In32BitMode]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003267def : Pat<(extloadi32i8 addr:$src), (MOVZX32rm8 addr:$src)>;
3268def : Pat<(extloadi32i16 addr:$src), (MOVZX32rm16 addr:$src)>;
3269
Dan Gohmandd612bb2008-08-20 21:27:32 +00003270// anyext
Bill Wendlingce1c5c12008-08-22 20:51:05 +00003271def : Pat<(i16 (anyext GR8 :$src)), (MOVZX16rr8 GR8 :$src)>,
3272 Requires<[In32BitMode]>;
3273def : Pat<(i32 (anyext GR8 :$src)), (MOVZX32rr8 GR8 :$src)>,
3274 Requires<[In32BitMode]>;
Dan Gohmandd612bb2008-08-20 21:27:32 +00003275def : Pat<(i32 (anyext GR16:$src)),
3276 (INSERT_SUBREG (i32 (IMPLICIT_DEF)), GR16:$src, x86_subreg_16bit)>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003277
Evan Chengf2abee72007-12-13 00:43:27 +00003278// (and (i32 load), 255) -> (zextload i8)
Evan Cheng1e5e5452008-09-29 17:26:18 +00003279def : Pat<(i32 (and (nvloadi32 addr:$src), (i32 255))),
3280 (MOVZX32rm8 addr:$src)>;
3281def : Pat<(i32 (and (nvloadi32 addr:$src), (i32 65535))),
3282 (MOVZX32rm16 addr:$src)>;
Evan Chengf2abee72007-12-13 00:43:27 +00003283
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003284//===----------------------------------------------------------------------===//
3285// Some peepholes
3286//===----------------------------------------------------------------------===//
3287
Dan Gohman5a5e6e92008-10-17 01:33:43 +00003288// Odd encoding trick: -128 fits into an 8-bit immediate field while
3289// +128 doesn't, so in this special case use a sub instead of an add.
3290def : Pat<(add GR16:$src1, 128),
3291 (SUB16ri8 GR16:$src1, -128)>;
3292def : Pat<(store (add (loadi16 addr:$dst), 128), addr:$dst),
3293 (SUB16mi8 addr:$dst, -128)>;
3294def : Pat<(add GR32:$src1, 128),
3295 (SUB32ri8 GR32:$src1, -128)>;
3296def : Pat<(store (add (loadi32 addr:$dst), 128), addr:$dst),
3297 (SUB32mi8 addr:$dst, -128)>;
3298
Dan Gohman9203ab42008-07-30 18:09:17 +00003299// r & (2^16-1) ==> movz
3300def : Pat<(and GR32:$src1, 0xffff),
Dan Gohmandd612bb2008-08-20 21:27:32 +00003301 (MOVZX32rr16 (i16 (EXTRACT_SUBREG GR32:$src1, x86_subreg_16bit)))>;
Dan Gohman5beb1ff2008-08-06 18:27:21 +00003302// r & (2^8-1) ==> movz
3303def : Pat<(and GR32:$src1, 0xff),
Dan Gohmandd612bb2008-08-20 21:27:32 +00003304 (MOVZX32rr8 (i8 (EXTRACT_SUBREG (MOV32to32_ GR32:$src1),
3305 x86_subreg_8bit)))>,
Dan Gohman5beb1ff2008-08-06 18:27:21 +00003306 Requires<[In32BitMode]>;
3307// r & (2^8-1) ==> movz
3308def : Pat<(and GR16:$src1, 0xff),
Dan Gohmandd612bb2008-08-20 21:27:32 +00003309 (MOVZX16rr8 (i8 (EXTRACT_SUBREG (MOV16to16_ GR16:$src1),
3310 x86_subreg_8bit)))>,
3311 Requires<[In32BitMode]>;
3312
3313// sext_inreg patterns
3314def : Pat<(sext_inreg GR32:$src, i16),
3315 (MOVSX32rr16 (i16 (EXTRACT_SUBREG GR32:$src, x86_subreg_16bit)))>;
3316def : Pat<(sext_inreg GR32:$src, i8),
3317 (MOVSX32rr8 (i8 (EXTRACT_SUBREG (MOV32to32_ GR32:$src),
3318 x86_subreg_8bit)))>,
3319 Requires<[In32BitMode]>;
3320def : Pat<(sext_inreg GR16:$src, i8),
3321 (MOVSX16rr8 (i8 (EXTRACT_SUBREG (MOV16to16_ GR16:$src),
3322 x86_subreg_8bit)))>,
3323 Requires<[In32BitMode]>;
3324
3325// trunc patterns
3326def : Pat<(i16 (trunc GR32:$src)),
3327 (i16 (EXTRACT_SUBREG GR32:$src, x86_subreg_16bit))>;
3328def : Pat<(i8 (trunc GR32:$src)),
3329 (i8 (EXTRACT_SUBREG (MOV32to32_ GR32:$src), x86_subreg_8bit))>,
3330 Requires<[In32BitMode]>;
3331def : Pat<(i8 (trunc GR16:$src)),
3332 (i8 (EXTRACT_SUBREG (MOV16to16_ GR16:$src), x86_subreg_8bit))>,
Dan Gohman5beb1ff2008-08-06 18:27:21 +00003333 Requires<[In32BitMode]>;
Dan Gohman9203ab42008-07-30 18:09:17 +00003334
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003335// (shl x, 1) ==> (add x, x)
3336def : Pat<(shl GR8 :$src1, (i8 1)), (ADD8rr GR8 :$src1, GR8 :$src1)>;
3337def : Pat<(shl GR16:$src1, (i8 1)), (ADD16rr GR16:$src1, GR16:$src1)>;
3338def : Pat<(shl GR32:$src1, (i8 1)), (ADD32rr GR32:$src1, GR32:$src1)>;
3339
Evan Cheng76a64c72008-08-30 02:03:58 +00003340// (shl x (and y, 31)) ==> (shl x, y)
3341def : Pat<(shl GR8:$src1, (and CL:$amt, 31)),
3342 (SHL8rCL GR8:$src1)>;
3343def : Pat<(shl GR16:$src1, (and CL:$amt, 31)),
3344 (SHL16rCL GR16:$src1)>;
3345def : Pat<(shl GR32:$src1, (and CL:$amt, 31)),
3346 (SHL32rCL GR32:$src1)>;
3347def : Pat<(store (shl (loadi8 addr:$dst), (and CL:$amt, 31)), addr:$dst),
3348 (SHL8mCL addr:$dst)>;
3349def : Pat<(store (shl (loadi16 addr:$dst), (and CL:$amt, 31)), addr:$dst),
3350 (SHL16mCL addr:$dst)>;
3351def : Pat<(store (shl (loadi32 addr:$dst), (and CL:$amt, 31)), addr:$dst),
3352 (SHL32mCL addr:$dst)>;
3353
3354def : Pat<(srl GR8:$src1, (and CL:$amt, 31)),
3355 (SHR8rCL GR8:$src1)>;
3356def : Pat<(srl GR16:$src1, (and CL:$amt, 31)),
3357 (SHR16rCL GR16:$src1)>;
3358def : Pat<(srl GR32:$src1, (and CL:$amt, 31)),
3359 (SHR32rCL GR32:$src1)>;
3360def : Pat<(store (srl (loadi8 addr:$dst), (and CL:$amt, 31)), addr:$dst),
3361 (SHR8mCL addr:$dst)>;
3362def : Pat<(store (srl (loadi16 addr:$dst), (and CL:$amt, 31)), addr:$dst),
3363 (SHR16mCL addr:$dst)>;
3364def : Pat<(store (srl (loadi32 addr:$dst), (and CL:$amt, 31)), addr:$dst),
3365 (SHR32mCL addr:$dst)>;
3366
3367def : Pat<(sra GR8:$src1, (and CL:$amt, 31)),
3368 (SAR8rCL GR8:$src1)>;
3369def : Pat<(sra GR16:$src1, (and CL:$amt, 31)),
3370 (SAR16rCL GR16:$src1)>;
3371def : Pat<(sra GR32:$src1, (and CL:$amt, 31)),
3372 (SAR32rCL GR32:$src1)>;
3373def : Pat<(store (sra (loadi8 addr:$dst), (and CL:$amt, 31)), addr:$dst),
3374 (SAR8mCL addr:$dst)>;
3375def : Pat<(store (sra (loadi16 addr:$dst), (and CL:$amt, 31)), addr:$dst),
3376 (SAR16mCL addr:$dst)>;
3377def : Pat<(store (sra (loadi32 addr:$dst), (and CL:$amt, 31)), addr:$dst),
3378 (SAR32mCL addr:$dst)>;
3379
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003380// (or (x >> c) | (y << (32 - c))) ==> (shrd32 x, y, c)
3381def : Pat<(or (srl GR32:$src1, CL:$amt),
3382 (shl GR32:$src2, (sub 32, CL:$amt))),
3383 (SHRD32rrCL GR32:$src1, GR32:$src2)>;
3384
3385def : Pat<(store (or (srl (loadi32 addr:$dst), CL:$amt),
3386 (shl GR32:$src2, (sub 32, CL:$amt))), addr:$dst),
3387 (SHRD32mrCL addr:$dst, GR32:$src2)>;
3388
Dan Gohman921581d2008-10-17 01:23:35 +00003389def : Pat<(or (srl GR32:$src1, (i8 (trunc ECX:$amt))),
3390 (shl GR32:$src2, (i8 (trunc (sub 32, ECX:$amt))))),
3391 (SHRD32rrCL GR32:$src1, GR32:$src2)>;
3392
3393def : Pat<(store (or (srl (loadi32 addr:$dst), (i8 (trunc ECX:$amt))),
3394 (shl GR32:$src2, (i8 (trunc (sub 32, ECX:$amt))))),
3395 addr:$dst),
3396 (SHRD32mrCL addr:$dst, GR32:$src2)>;
3397
3398def : Pat<(shrd GR32:$src1, (i8 imm:$amt1), GR32:$src2, (i8 imm:$amt2)),
3399 (SHRD32rri8 GR32:$src1, GR32:$src2, (i8 imm:$amt1))>;
3400
3401def : Pat<(store (shrd (loadi32 addr:$dst), (i8 imm:$amt1),
3402 GR32:$src2, (i8 imm:$amt2)), addr:$dst),
3403 (SHRD32mri8 addr:$dst, GR32:$src2, (i8 imm:$amt1))>;
3404
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003405// (or (x << c) | (y >> (32 - c))) ==> (shld32 x, y, c)
3406def : Pat<(or (shl GR32:$src1, CL:$amt),
3407 (srl GR32:$src2, (sub 32, CL:$amt))),
3408 (SHLD32rrCL GR32:$src1, GR32:$src2)>;
3409
3410def : Pat<(store (or (shl (loadi32 addr:$dst), CL:$amt),
3411 (srl GR32:$src2, (sub 32, CL:$amt))), addr:$dst),
3412 (SHLD32mrCL addr:$dst, GR32:$src2)>;
3413
Dan Gohman921581d2008-10-17 01:23:35 +00003414def : Pat<(or (shl GR32:$src1, (i8 (trunc ECX:$amt))),
3415 (srl GR32:$src2, (i8 (trunc (sub 32, ECX:$amt))))),
3416 (SHLD32rrCL GR32:$src1, GR32:$src2)>;
3417
3418def : Pat<(store (or (shl (loadi32 addr:$dst), (i8 (trunc ECX:$amt))),
3419 (srl GR32:$src2, (i8 (trunc (sub 32, ECX:$amt))))),
3420 addr:$dst),
3421 (SHLD32mrCL addr:$dst, GR32:$src2)>;
3422
3423def : Pat<(shld GR32:$src1, (i8 imm:$amt1), GR32:$src2, (i8 imm:$amt2)),
3424 (SHLD32rri8 GR32:$src1, GR32:$src2, (i8 imm:$amt1))>;
3425
3426def : Pat<(store (shld (loadi32 addr:$dst), (i8 imm:$amt1),
3427 GR32:$src2, (i8 imm:$amt2)), addr:$dst),
3428 (SHLD32mri8 addr:$dst, GR32:$src2, (i8 imm:$amt1))>;
3429
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003430// (or (x >> c) | (y << (16 - c))) ==> (shrd16 x, y, c)
3431def : Pat<(or (srl GR16:$src1, CL:$amt),
3432 (shl GR16:$src2, (sub 16, CL:$amt))),
3433 (SHRD16rrCL GR16:$src1, GR16:$src2)>;
3434
3435def : Pat<(store (or (srl (loadi16 addr:$dst), CL:$amt),
3436 (shl GR16:$src2, (sub 16, CL:$amt))), addr:$dst),
3437 (SHRD16mrCL addr:$dst, GR16:$src2)>;
3438
Dan Gohman921581d2008-10-17 01:23:35 +00003439def : Pat<(or (srl GR16:$src1, (i8 (trunc CX:$amt))),
3440 (shl GR16:$src2, (i8 (trunc (sub 16, CX:$amt))))),
3441 (SHRD16rrCL GR16:$src1, GR16:$src2)>;
3442
3443def : Pat<(store (or (srl (loadi16 addr:$dst), (i8 (trunc CX:$amt))),
3444 (shl GR16:$src2, (i8 (trunc (sub 16, CX:$amt))))),
3445 addr:$dst),
3446 (SHRD16mrCL addr:$dst, GR16:$src2)>;
3447
3448def : Pat<(shrd GR16:$src1, (i8 imm:$amt1), GR16:$src2, (i8 imm:$amt2)),
3449 (SHRD16rri8 GR16:$src1, GR16:$src2, (i8 imm:$amt1))>;
3450
3451def : Pat<(store (shrd (loadi16 addr:$dst), (i8 imm:$amt1),
3452 GR16:$src2, (i8 imm:$amt2)), addr:$dst),
3453 (SHRD16mri8 addr:$dst, GR16:$src2, (i8 imm:$amt1))>;
3454
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003455// (or (x << c) | (y >> (16 - c))) ==> (shld16 x, y, c)
3456def : Pat<(or (shl GR16:$src1, CL:$amt),
3457 (srl GR16:$src2, (sub 16, CL:$amt))),
3458 (SHLD16rrCL GR16:$src1, GR16:$src2)>;
3459
3460def : Pat<(store (or (shl (loadi16 addr:$dst), CL:$amt),
3461 (srl GR16:$src2, (sub 16, CL:$amt))), addr:$dst),
3462 (SHLD16mrCL addr:$dst, GR16:$src2)>;
3463
Dan Gohman921581d2008-10-17 01:23:35 +00003464def : Pat<(or (shl GR16:$src1, (i8 (trunc CX:$amt))),
3465 (srl GR16:$src2, (i8 (trunc (sub 16, CX:$amt))))),
3466 (SHLD16rrCL GR16:$src1, GR16:$src2)>;
3467
3468def : Pat<(store (or (shl (loadi16 addr:$dst), (i8 (trunc CX:$amt))),
3469 (srl GR16:$src2, (i8 (trunc (sub 16, CX:$amt))))),
3470 addr:$dst),
3471 (SHLD16mrCL addr:$dst, GR16:$src2)>;
3472
3473def : Pat<(shld GR16:$src1, (i8 imm:$amt1), GR16:$src2, (i8 imm:$amt2)),
3474 (SHLD16rri8 GR16:$src1, GR16:$src2, (i8 imm:$amt1))>;
3475
3476def : Pat<(store (shld (loadi16 addr:$dst), (i8 imm:$amt1),
3477 GR16:$src2, (i8 imm:$amt2)), addr:$dst),
3478 (SHLD16mri8 addr:$dst, GR16:$src2, (i8 imm:$amt1))>;
3479
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003480//===----------------------------------------------------------------------===//
Dan Gohman99a12192009-03-04 19:44:21 +00003481// EFLAGS-defining Patterns
Bill Wendlingf5399032008-12-12 21:15:41 +00003482//===----------------------------------------------------------------------===//
3483
Dan Gohman99a12192009-03-04 19:44:21 +00003484// Register-Register Addition with EFLAGS result
3485def : Pat<(parallel (X86add_flag GR8:$src1, GR8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003486 (implicit EFLAGS)),
3487 (ADD8rr GR8:$src1, GR8:$src2)>;
3488
Dan Gohman99a12192009-03-04 19:44:21 +00003489// Register-Register Addition with EFLAGS result
3490def : Pat<(parallel (X86add_flag GR16:$src1, GR16:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003491 (implicit EFLAGS)),
3492 (ADD16rr GR16:$src1, GR16:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003493def : Pat<(parallel (X86add_flag GR32:$src1, GR32:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003494 (implicit EFLAGS)),
3495 (ADD32rr GR32:$src1, GR32:$src2)>;
3496
Dan Gohman99a12192009-03-04 19:44:21 +00003497// Register-Memory Addition with EFLAGS result
3498def : Pat<(parallel (X86add_flag GR8:$src1, (loadi8 addr:$src2)),
Bill Wendlingf5399032008-12-12 21:15:41 +00003499 (implicit EFLAGS)),
3500 (ADD8rm GR8:$src1, addr:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003501def : Pat<(parallel (X86add_flag GR16:$src1, (loadi16 addr:$src2)),
Bill Wendlingf5399032008-12-12 21:15:41 +00003502 (implicit EFLAGS)),
3503 (ADD16rm GR16:$src1, addr:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003504def : Pat<(parallel (X86add_flag GR32:$src1, (loadi32 addr:$src2)),
Bill Wendlingf5399032008-12-12 21:15:41 +00003505 (implicit EFLAGS)),
3506 (ADD32rm GR32:$src1, addr:$src2)>;
3507
Dan Gohman99a12192009-03-04 19:44:21 +00003508// Register-Integer Addition with EFLAGS result
3509def : Pat<(parallel (X86add_flag GR8:$src1, imm:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003510 (implicit EFLAGS)),
3511 (ADD8ri GR8:$src1, imm:$src2)>;
3512
Dan Gohman99a12192009-03-04 19:44:21 +00003513// Register-Integer Addition with EFLAGS result
3514def : Pat<(parallel (X86add_flag GR16:$src1, imm:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003515 (implicit EFLAGS)),
3516 (ADD16ri GR16:$src1, imm:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003517def : Pat<(parallel (X86add_flag GR32:$src1, imm:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003518 (implicit EFLAGS)),
3519 (ADD32ri GR32:$src1, imm:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003520def : Pat<(parallel (X86add_flag GR16:$src1, i16immSExt8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003521 (implicit EFLAGS)),
3522 (ADD16ri8 GR16:$src1, i16immSExt8:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003523def : Pat<(parallel (X86add_flag GR32:$src1, i32immSExt8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003524 (implicit EFLAGS)),
3525 (ADD32ri8 GR32:$src1, i32immSExt8:$src2)>;
3526
Dan Gohman99a12192009-03-04 19:44:21 +00003527// Memory-Register Addition with EFLAGS result
3528def : Pat<(parallel (store (X86add_flag (loadi8 addr:$dst), GR8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003529 addr:$dst),
3530 (implicit EFLAGS)),
3531 (ADD8mr addr:$dst, GR8:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003532def : Pat<(parallel (store (X86add_flag (loadi16 addr:$dst), GR16:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003533 addr:$dst),
3534 (implicit EFLAGS)),
3535 (ADD16mr addr:$dst, GR16:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003536def : Pat<(parallel (store (X86add_flag (loadi32 addr:$dst), GR32:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003537 addr:$dst),
3538 (implicit EFLAGS)),
3539 (ADD32mr addr:$dst, GR32:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003540def : Pat<(parallel (store (X86add_flag (loadi8 addr:$dst), imm:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003541 addr:$dst),
3542 (implicit EFLAGS)),
3543 (ADD8mi addr:$dst, imm:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003544def : Pat<(parallel (store (X86add_flag (loadi16 addr:$dst), imm:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003545 addr:$dst),
3546 (implicit EFLAGS)),
3547 (ADD16mi addr:$dst, imm:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003548def : Pat<(parallel (store (X86add_flag (loadi32 addr:$dst), imm:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003549 addr:$dst),
3550 (implicit EFLAGS)),
3551 (ADD32mi addr:$dst, imm:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003552def : Pat<(parallel (store (X86add_flag (loadi16 addr:$dst), i16immSExt8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003553 addr:$dst),
3554 (implicit EFLAGS)),
3555 (ADD16mi8 addr:$dst, i16immSExt8:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003556def : Pat<(parallel (store (X86add_flag (loadi32 addr:$dst), i32immSExt8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003557 addr:$dst),
3558 (implicit EFLAGS)),
3559 (ADD32mi8 addr:$dst, i32immSExt8:$src2)>;
3560
Dan Gohman99a12192009-03-04 19:44:21 +00003561// Register-Register Subtraction with EFLAGS result
3562def : Pat<(parallel (X86sub_flag GR8:$src1, GR8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003563 (implicit EFLAGS)),
3564 (SUB8rr GR8:$src1, GR8:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003565def : Pat<(parallel (X86sub_flag GR16:$src1, GR16:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003566 (implicit EFLAGS)),
3567 (SUB16rr GR16:$src1, GR16:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003568def : Pat<(parallel (X86sub_flag GR32:$src1, GR32:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003569 (implicit EFLAGS)),
3570 (SUB32rr GR32:$src1, GR32:$src2)>;
3571
Dan Gohman99a12192009-03-04 19:44:21 +00003572// Register-Memory Subtraction with EFLAGS result
3573def : Pat<(parallel (X86sub_flag GR8:$src1, (loadi8 addr:$src2)),
Bill Wendlingf5399032008-12-12 21:15:41 +00003574 (implicit EFLAGS)),
3575 (SUB8rm GR8:$src1, addr:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003576def : Pat<(parallel (X86sub_flag GR16:$src1, (loadi16 addr:$src2)),
Bill Wendlingf5399032008-12-12 21:15:41 +00003577 (implicit EFLAGS)),
3578 (SUB16rm GR16:$src1, addr:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003579def : Pat<(parallel (X86sub_flag GR32:$src1, (loadi32 addr:$src2)),
Bill Wendlingf5399032008-12-12 21:15:41 +00003580 (implicit EFLAGS)),
3581 (SUB32rm GR32:$src1, addr:$src2)>;
3582
Dan Gohman99a12192009-03-04 19:44:21 +00003583// Register-Integer Subtraction with EFLAGS result
3584def : Pat<(parallel (X86sub_flag GR8:$src1, imm:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003585 (implicit EFLAGS)),
3586 (SUB8ri GR8:$src1, imm:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003587def : Pat<(parallel (X86sub_flag GR16:$src1, imm:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003588 (implicit EFLAGS)),
3589 (SUB16ri GR16:$src1, imm:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003590def : Pat<(parallel (X86sub_flag GR32:$src1, imm:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003591 (implicit EFLAGS)),
3592 (SUB32ri GR32:$src1, imm:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003593def : Pat<(parallel (X86sub_flag GR16:$src1, i16immSExt8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003594 (implicit EFLAGS)),
3595 (SUB16ri8 GR16:$src1, i16immSExt8:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003596def : Pat<(parallel (X86sub_flag GR32:$src1, i32immSExt8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003597 (implicit EFLAGS)),
3598 (SUB32ri8 GR32:$src1, i32immSExt8:$src2)>;
3599
Dan Gohman99a12192009-03-04 19:44:21 +00003600// Memory-Register Subtraction with EFLAGS result
3601def : Pat<(parallel (store (X86sub_flag (loadi8 addr:$dst), GR8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003602 addr:$dst),
3603 (implicit EFLAGS)),
3604 (SUB8mr addr:$dst, GR8:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003605def : Pat<(parallel (store (X86sub_flag (loadi16 addr:$dst), GR16:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003606 addr:$dst),
3607 (implicit EFLAGS)),
3608 (SUB16mr addr:$dst, GR16:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003609def : Pat<(parallel (store (X86sub_flag (loadi32 addr:$dst), GR32:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003610 addr:$dst),
3611 (implicit EFLAGS)),
3612 (SUB32mr addr:$dst, GR32:$src2)>;
3613
Dan Gohman99a12192009-03-04 19:44:21 +00003614// Memory-Integer Subtraction with EFLAGS result
3615def : Pat<(parallel (store (X86sub_flag (loadi8 addr:$dst), imm:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003616 addr:$dst),
3617 (implicit EFLAGS)),
3618 (SUB8mi addr:$dst, imm:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003619def : Pat<(parallel (store (X86sub_flag (loadi16 addr:$dst), imm:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003620 addr:$dst),
3621 (implicit EFLAGS)),
3622 (SUB16mi addr:$dst, imm:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003623def : Pat<(parallel (store (X86sub_flag (loadi32 addr:$dst), imm:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003624 addr:$dst),
3625 (implicit EFLAGS)),
3626 (SUB32mi addr:$dst, imm:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003627def : Pat<(parallel (store (X86sub_flag (loadi16 addr:$dst), i16immSExt8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003628 addr:$dst),
3629 (implicit EFLAGS)),
3630 (SUB16mi8 addr:$dst, i16immSExt8:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003631def : Pat<(parallel (store (X86sub_flag (loadi32 addr:$dst), i32immSExt8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003632 addr:$dst),
3633 (implicit EFLAGS)),
3634 (SUB32mi8 addr:$dst, i32immSExt8:$src2)>;
3635
3636
Dan Gohman99a12192009-03-04 19:44:21 +00003637// Register-Register Signed Integer Multiply with EFLAGS result
3638def : Pat<(parallel (X86smul_flag GR16:$src1, GR16:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003639 (implicit EFLAGS)),
3640 (IMUL16rr GR16:$src1, GR16:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003641def : Pat<(parallel (X86smul_flag GR32:$src1, GR32:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003642 (implicit EFLAGS)),
3643 (IMUL32rr GR32:$src1, GR32:$src2)>;
3644
Dan Gohman99a12192009-03-04 19:44:21 +00003645// Register-Memory Signed Integer Multiply with EFLAGS result
3646def : Pat<(parallel (X86smul_flag GR16:$src1, (loadi16 addr:$src2)),
Bill Wendlingf5399032008-12-12 21:15:41 +00003647 (implicit EFLAGS)),
3648 (IMUL16rm GR16:$src1, addr:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003649def : Pat<(parallel (X86smul_flag GR32:$src1, (loadi32 addr:$src2)),
Bill Wendlingf5399032008-12-12 21:15:41 +00003650 (implicit EFLAGS)),
3651 (IMUL32rm GR32:$src1, addr:$src2)>;
3652
Dan Gohman99a12192009-03-04 19:44:21 +00003653// Register-Integer Signed Integer Multiply with EFLAGS result
3654def : Pat<(parallel (X86smul_flag GR16:$src1, imm:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003655 (implicit EFLAGS)),
3656 (IMUL16rri GR16:$src1, imm:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003657def : Pat<(parallel (X86smul_flag GR32:$src1, imm:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003658 (implicit EFLAGS)),
3659 (IMUL32rri GR32:$src1, imm:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003660def : Pat<(parallel (X86smul_flag GR16:$src1, i16immSExt8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003661 (implicit EFLAGS)),
3662 (IMUL16rri8 GR16:$src1, i16immSExt8:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003663def : Pat<(parallel (X86smul_flag GR32:$src1, i32immSExt8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003664 (implicit EFLAGS)),
3665 (IMUL32rri8 GR32:$src1, i32immSExt8:$src2)>;
3666
Dan Gohman99a12192009-03-04 19:44:21 +00003667// Memory-Integer Signed Integer Multiply with EFLAGS result
3668def : Pat<(parallel (X86smul_flag (loadi16 addr:$src1), imm:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003669 (implicit EFLAGS)),
3670 (IMUL16rmi addr:$src1, imm:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003671def : Pat<(parallel (X86smul_flag (loadi32 addr:$src1), imm:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003672 (implicit EFLAGS)),
3673 (IMUL32rmi addr:$src1, imm:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003674def : Pat<(parallel (X86smul_flag (loadi16 addr:$src1), i16immSExt8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003675 (implicit EFLAGS)),
3676 (IMUL16rmi8 addr:$src1, i16immSExt8:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003677def : Pat<(parallel (X86smul_flag (loadi32 addr:$src1), i32immSExt8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003678 (implicit EFLAGS)),
3679 (IMUL32rmi8 addr:$src1, i32immSExt8:$src2)>;
3680
Dan Gohman99a12192009-03-04 19:44:21 +00003681// Optimize multiply by 2 with EFLAGS result.
Evan Cheng00cf7932009-01-27 03:30:42 +00003682let AddedComplexity = 2 in {
Dan Gohman99a12192009-03-04 19:44:21 +00003683def : Pat<(parallel (X86smul_flag GR16:$src1, 2),
Evan Cheng00cf7932009-01-27 03:30:42 +00003684 (implicit EFLAGS)),
3685 (ADD16rr GR16:$src1, GR16:$src1)>;
3686
Dan Gohman99a12192009-03-04 19:44:21 +00003687def : Pat<(parallel (X86smul_flag GR32:$src1, 2),
Evan Cheng00cf7932009-01-27 03:30:42 +00003688 (implicit EFLAGS)),
3689 (ADD32rr GR32:$src1, GR32:$src1)>;
3690}
3691
Dan Gohman99a12192009-03-04 19:44:21 +00003692// INC and DEC with EFLAGS result. Note that these do not set CF.
3693def : Pat<(parallel (X86inc_flag GR8:$src), (implicit EFLAGS)),
3694 (INC8r GR8:$src)>;
3695def : Pat<(parallel (store (i8 (X86inc_flag (loadi8 addr:$dst))), addr:$dst),
3696 (implicit EFLAGS)),
3697 (INC8m addr:$dst)>;
3698def : Pat<(parallel (X86dec_flag GR8:$src), (implicit EFLAGS)),
3699 (DEC8r GR8:$src)>;
3700def : Pat<(parallel (store (i8 (X86dec_flag (loadi8 addr:$dst))), addr:$dst),
3701 (implicit EFLAGS)),
3702 (DEC8m addr:$dst)>;
3703
3704def : Pat<(parallel (X86inc_flag GR16:$src), (implicit EFLAGS)),
Dan Gohmaneebcac72009-03-05 21:32:23 +00003705 (INC16r GR16:$src)>, Requires<[In32BitMode]>;
Dan Gohman99a12192009-03-04 19:44:21 +00003706def : Pat<(parallel (store (i16 (X86inc_flag (loadi16 addr:$dst))), addr:$dst),
3707 (implicit EFLAGS)),
Dan Gohmaneebcac72009-03-05 21:32:23 +00003708 (INC16m addr:$dst)>, Requires<[In32BitMode]>;
Dan Gohman99a12192009-03-04 19:44:21 +00003709def : Pat<(parallel (X86dec_flag GR16:$src), (implicit EFLAGS)),
Dan Gohmaneebcac72009-03-05 21:32:23 +00003710 (DEC16r GR16:$src)>, Requires<[In32BitMode]>;
Dan Gohman99a12192009-03-04 19:44:21 +00003711def : Pat<(parallel (store (i16 (X86dec_flag (loadi16 addr:$dst))), addr:$dst),
3712 (implicit EFLAGS)),
Dan Gohmaneebcac72009-03-05 21:32:23 +00003713 (DEC16m addr:$dst)>, Requires<[In32BitMode]>;
Dan Gohman99a12192009-03-04 19:44:21 +00003714
3715def : Pat<(parallel (X86inc_flag GR32:$src), (implicit EFLAGS)),
Dan Gohmaneebcac72009-03-05 21:32:23 +00003716 (INC32r GR32:$src)>, Requires<[In32BitMode]>;
Dan Gohman99a12192009-03-04 19:44:21 +00003717def : Pat<(parallel (store (i32 (X86inc_flag (loadi32 addr:$dst))), addr:$dst),
3718 (implicit EFLAGS)),
Dan Gohmaneebcac72009-03-05 21:32:23 +00003719 (INC32m addr:$dst)>, Requires<[In32BitMode]>;
Dan Gohman99a12192009-03-04 19:44:21 +00003720def : Pat<(parallel (X86dec_flag GR32:$src), (implicit EFLAGS)),
Dan Gohmaneebcac72009-03-05 21:32:23 +00003721 (DEC32r GR32:$src)>, Requires<[In32BitMode]>;
Dan Gohman99a12192009-03-04 19:44:21 +00003722def : Pat<(parallel (store (i32 (X86dec_flag (loadi32 addr:$dst))), addr:$dst),
3723 (implicit EFLAGS)),
Dan Gohmaneebcac72009-03-05 21:32:23 +00003724 (DEC32m addr:$dst)>, Requires<[In32BitMode]>;
Dan Gohman99a12192009-03-04 19:44:21 +00003725
Bill Wendlingf5399032008-12-12 21:15:41 +00003726//===----------------------------------------------------------------------===//
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003727// Floating Point Stack Support
3728//===----------------------------------------------------------------------===//
3729
3730include "X86InstrFPStack.td"
3731
3732//===----------------------------------------------------------------------===//
Evan Cheng86ab7d32007-07-31 08:04:03 +00003733// X86-64 Support
3734//===----------------------------------------------------------------------===//
3735
Chris Lattner2de8d2b2008-01-10 05:50:42 +00003736include "X86Instr64bit.td"
Evan Cheng86ab7d32007-07-31 08:04:03 +00003737
3738//===----------------------------------------------------------------------===//
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003739// XMM Floating point support (requires SSE / SSE2)
3740//===----------------------------------------------------------------------===//
3741
3742include "X86InstrSSE.td"
Evan Cheng5e4d1e72008-04-25 18:19:54 +00003743
3744//===----------------------------------------------------------------------===//
3745// MMX and XMM Packed Integer support (requires MMX, SSE, and SSE2)
3746//===----------------------------------------------------------------------===//
3747
3748include "X86InstrMMX.td"