blob: bef6b72c80103df6d42507ca47cf457da29f13d4 [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);
Chris Lattner12208612009-04-10 00:16:23 +0000280 if (const Value *Src = LD->getSrcValue())
281 if (const PointerType *PT = dyn_cast<PointerType>(Src->getType()))
282 if (PT->getAddressSpace() != 0)
283 return false;
Dan Gohman8335c412008-08-20 15:24:22 +0000284 ISD::LoadExtType ExtType = LD->getExtensionType();
285 if (ExtType == ISD::NON_EXTLOAD)
286 return true;
287 if (ExtType == ISD::EXTLOAD)
288 return LD->getAlignment() >= 2 && !LD->isVolatile();
Evan Cheng8b765e92008-05-13 00:54:02 +0000289 return false;
290}]>;
291
Dan Gohman2a174122008-10-15 06:50:19 +0000292def loadi16_anyext : PatFrag<(ops node:$ptr), (i32 (unindexedload node:$ptr)), [{
Evan Cheng56ec77b2008-09-24 23:27:55 +0000293 LoadSDNode *LD = cast<LoadSDNode>(N);
Chris Lattner12208612009-04-10 00:16:23 +0000294 if (const Value *Src = LD->getSrcValue())
295 if (const PointerType *PT = dyn_cast<PointerType>(Src->getType()))
296 if (PT->getAddressSpace() != 0)
297 return false;
Evan Cheng56ec77b2008-09-24 23:27:55 +0000298 ISD::LoadExtType ExtType = LD->getExtensionType();
299 if (ExtType == ISD::EXTLOAD)
300 return LD->getAlignment() >= 2 && !LD->isVolatile();
301 return false;
302}]>;
303
Dan Gohman2a174122008-10-15 06:50:19 +0000304def loadi32 : PatFrag<(ops node:$ptr), (i32 (unindexedload node:$ptr)), [{
Dan Gohman8335c412008-08-20 15:24:22 +0000305 LoadSDNode *LD = cast<LoadSDNode>(N);
Chris Lattner12208612009-04-10 00:16:23 +0000306 if (const Value *Src = LD->getSrcValue())
307 if (const PointerType *PT = dyn_cast<PointerType>(Src->getType()))
308 if (PT->getAddressSpace() != 0)
309 return false;
Dan Gohman8335c412008-08-20 15:24:22 +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 && !LD->isVolatile();
Evan Cheng8b765e92008-05-13 00:54:02 +0000315 return false;
316}]>;
317
Dan Gohman2a174122008-10-15 06:50:19 +0000318def nvloadi32 : PatFrag<(ops node:$ptr), (i32 (unindexedload node:$ptr)), [{
Evan Cheng1e5e5452008-09-29 17:26:18 +0000319 LoadSDNode *LD = cast<LoadSDNode>(N);
Chris Lattner12208612009-04-10 00:16:23 +0000320 if (const Value *Src = LD->getSrcValue())
321 if (const PointerType *PT = dyn_cast<PointerType>(Src->getType()))
322 if (PT->getAddressSpace() != 0)
323 return false;
Evan Cheng1e5e5452008-09-29 17:26:18 +0000324 if (LD->isVolatile())
325 return false;
Evan Cheng1e5e5452008-09-29 17:26:18 +0000326 ISD::LoadExtType ExtType = LD->getExtensionType();
327 if (ExtType == ISD::NON_EXTLOAD)
328 return true;
329 if (ExtType == ISD::EXTLOAD)
330 return LD->getAlignment() >= 4;
331 return false;
332}]>;
333
sampo9cc09a32009-01-26 01:24:32 +0000334def gsload : PatFrag<(ops node:$ptr), (load node:$ptr), [{
Chris Lattner12208612009-04-10 00:16:23 +0000335 if (const Value *Src = cast<LoadSDNode>(N)->getSrcValue())
336 if (const PointerType *PT = dyn_cast<PointerType>(Src->getType()))
337 return PT->getAddressSpace() == 256;
sampo9cc09a32009-01-26 01:24:32 +0000338 return false;
339}]>;
340
Chris Lattner12208612009-04-10 00:16:23 +0000341def loadi8 : PatFrag<(ops node:$ptr), (i8 (load node:$ptr)), [{
342 if (const Value *Src = cast<LoadSDNode>(N)->getSrcValue())
343 if (const PointerType *PT = dyn_cast<PointerType>(Src->getType()))
344 if (PT->getAddressSpace() != 0)
345 return false;
346 return true;
347}]>;
348def loadi64 : PatFrag<(ops node:$ptr), (i64 (load node:$ptr)), [{
349 if (const Value *Src = cast<LoadSDNode>(N)->getSrcValue())
350 if (const PointerType *PT = dyn_cast<PointerType>(Src->getType()))
351 if (PT->getAddressSpace() != 0)
352 return false;
353 return true;
354}]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000355
Chris Lattner12208612009-04-10 00:16:23 +0000356def loadf32 : PatFrag<(ops node:$ptr), (f32 (load node:$ptr)), [{
357 if (const Value *Src = cast<LoadSDNode>(N)->getSrcValue())
358 if (const PointerType *PT = dyn_cast<PointerType>(Src->getType()))
359 if (PT->getAddressSpace() != 0)
360 return false;
361 return true;
362}]>;
363def loadf64 : PatFrag<(ops node:$ptr), (f64 (load node:$ptr)), [{
364 if (const Value *Src = cast<LoadSDNode>(N)->getSrcValue())
365 if (const PointerType *PT = dyn_cast<PointerType>(Src->getType()))
366 if (PT->getAddressSpace() != 0)
367 return false;
368 return true;
369}]>;
370def loadf80 : PatFrag<(ops node:$ptr), (f80 (load node:$ptr)), [{
371 if (const Value *Src = cast<LoadSDNode>(N)->getSrcValue())
372 if (const PointerType *PT = dyn_cast<PointerType>(Src->getType()))
373 if (PT->getAddressSpace() != 0)
374 return false;
375 return true;
376}]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000377
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000378def sextloadi16i8 : PatFrag<(ops node:$ptr), (i16 (sextloadi8 node:$ptr))>;
379def sextloadi32i8 : PatFrag<(ops node:$ptr), (i32 (sextloadi8 node:$ptr))>;
380def sextloadi32i16 : PatFrag<(ops node:$ptr), (i32 (sextloadi16 node:$ptr))>;
381
382def zextloadi8i1 : PatFrag<(ops node:$ptr), (i8 (zextloadi1 node:$ptr))>;
383def zextloadi16i1 : PatFrag<(ops node:$ptr), (i16 (zextloadi1 node:$ptr))>;
384def zextloadi32i1 : PatFrag<(ops node:$ptr), (i32 (zextloadi1 node:$ptr))>;
385def zextloadi16i8 : PatFrag<(ops node:$ptr), (i16 (zextloadi8 node:$ptr))>;
386def zextloadi32i8 : PatFrag<(ops node:$ptr), (i32 (zextloadi8 node:$ptr))>;
387def zextloadi32i16 : PatFrag<(ops node:$ptr), (i32 (zextloadi16 node:$ptr))>;
388
389def extloadi8i1 : PatFrag<(ops node:$ptr), (i8 (extloadi1 node:$ptr))>;
390def extloadi16i1 : PatFrag<(ops node:$ptr), (i16 (extloadi1 node:$ptr))>;
391def extloadi32i1 : PatFrag<(ops node:$ptr), (i32 (extloadi1 node:$ptr))>;
392def extloadi16i8 : PatFrag<(ops node:$ptr), (i16 (extloadi8 node:$ptr))>;
393def extloadi32i8 : PatFrag<(ops node:$ptr), (i32 (extloadi8 node:$ptr))>;
394def extloadi32i16 : PatFrag<(ops node:$ptr), (i32 (extloadi16 node:$ptr))>;
395
Chris Lattner21da6382008-02-19 17:37:35 +0000396
397// An 'and' node with a single use.
398def and_su : PatFrag<(ops node:$lhs, node:$rhs), (and node:$lhs, node:$rhs), [{
Evan Cheng9123cfa2008-03-04 00:40:35 +0000399 return N->hasOneUse();
Chris Lattner21da6382008-02-19 17:37:35 +0000400}]>;
401
Dan Gohman921581d2008-10-17 01:23:35 +0000402// 'shld' and 'shrd' instruction patterns. Note that even though these have
403// the srl and shl in their patterns, the C++ code must still check for them,
404// because predicates are tested before children nodes are explored.
405
406def shrd : PatFrag<(ops node:$src1, node:$amt1, node:$src2, node:$amt2),
407 (or (srl node:$src1, node:$amt1),
408 (shl node:$src2, node:$amt2)), [{
409 assert(N->getOpcode() == ISD::OR);
410 return N->getOperand(0).getOpcode() == ISD::SRL &&
411 N->getOperand(1).getOpcode() == ISD::SHL &&
412 isa<ConstantSDNode>(N->getOperand(0).getOperand(1)) &&
413 isa<ConstantSDNode>(N->getOperand(1).getOperand(1)) &&
414 N->getOperand(0).getConstantOperandVal(1) ==
415 N->getValueSizeInBits(0) - N->getOperand(1).getConstantOperandVal(1);
416}]>;
417
418def shld : PatFrag<(ops node:$src1, node:$amt1, node:$src2, node:$amt2),
419 (or (shl node:$src1, node:$amt1),
420 (srl node:$src2, node:$amt2)), [{
421 assert(N->getOpcode() == ISD::OR);
422 return N->getOperand(0).getOpcode() == ISD::SHL &&
423 N->getOperand(1).getOpcode() == ISD::SRL &&
424 isa<ConstantSDNode>(N->getOperand(0).getOperand(1)) &&
425 isa<ConstantSDNode>(N->getOperand(1).getOperand(1)) &&
426 N->getOperand(0).getConstantOperandVal(1) ==
427 N->getValueSizeInBits(0) - N->getOperand(1).getConstantOperandVal(1);
428}]>;
429
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000430//===----------------------------------------------------------------------===//
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000431// Instruction list...
432//
433
434// ADJCALLSTACKDOWN/UP implicitly use/def ESP because they may be expanded into
435// a stack adjustment and the codegen must know that they may modify the stack
436// pointer before prolog-epilog rewriting occurs.
Chris Lattnerb56cc342008-03-11 03:23:40 +0000437// Pessimistically assume ADJCALLSTACKDOWN / ADJCALLSTACKUP will become
438// sub / add which can clobber EFLAGS.
Evan Cheng037364a2007-09-28 01:19:48 +0000439let Defs = [ESP, EFLAGS], Uses = [ESP] in {
Dan Gohman01c9f772008-10-01 18:28:06 +0000440def ADJCALLSTACKDOWN32 : I<0, Pseudo, (outs), (ins i32imm:$amt),
441 "#ADJCALLSTACKDOWN",
Chris Lattnerfe5d4022008-10-11 22:08:30 +0000442 [(X86callseq_start timm:$amt)]>,
Dan Gohman01c9f772008-10-01 18:28:06 +0000443 Requires<[In32BitMode]>;
444def ADJCALLSTACKUP32 : I<0, Pseudo, (outs), (ins i32imm:$amt1, i32imm:$amt2),
445 "#ADJCALLSTACKUP",
Chris Lattnerfe5d4022008-10-11 22:08:30 +0000446 [(X86callseq_end timm:$amt1, timm:$amt2)]>,
Dan Gohman01c9f772008-10-01 18:28:06 +0000447 Requires<[In32BitMode]>;
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000448}
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000449
450// Nop
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000451let neverHasSideEffects = 1 in
452 def NOOP : I<0x90, RawFrm, (outs), (ins), "nop", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000453
Evan Cheng0729ccf2008-01-05 00:41:47 +0000454// PIC base
Dan Gohman9499cfe2008-10-01 04:14:30 +0000455let neverHasSideEffects = 1, isNotDuplicable = 1, Uses = [ESP] in
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000456 def MOVPC32r : Ii32<0xE8, Pseudo, (outs GR32:$reg), (ins piclabel:$label),
457 "call\t$label\n\tpop{l}\t$reg", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000458
459//===----------------------------------------------------------------------===//
460// Control Flow Instructions...
461//
462
463// Return instructions.
464let isTerminator = 1, isReturn = 1, isBarrier = 1,
Chris Lattnerb56cc342008-03-11 03:23:40 +0000465 hasCtrlDep = 1, FPForm = SpecialFP, FPFormBits = SpecialFP.Value in {
Dan Gohman2c4be2a2008-05-31 02:11:25 +0000466 def RET : I <0xC3, RawFrm, (outs), (ins variable_ops),
Chris Lattnerb56cc342008-03-11 03:23:40 +0000467 "ret",
Dan Gohman2c4be2a2008-05-31 02:11:25 +0000468 [(X86retflag 0)]>;
Chris Lattnerb56cc342008-03-11 03:23:40 +0000469 def RETI : Ii16<0xC2, RawFrm, (outs), (ins i16imm:$amt, variable_ops),
470 "ret\t$amt",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000471 [(X86retflag imm:$amt)]>;
472}
473
474// All branches are RawFrm, Void, Branch, and Terminators
Evan Cheng37e7c752007-07-21 00:34:19 +0000475let isBranch = 1, isTerminator = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +0000476 class IBr<bits<8> opcode, dag ins, string asm, list<dag> pattern> :
477 I<opcode, RawFrm, (outs), ins, asm, pattern>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000478
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000479let isBranch = 1, isBarrier = 1 in
Dan Gohman91888f02007-07-31 20:11:57 +0000480 def JMP : IBr<0xE9, (ins brtarget:$dst), "jmp\t$dst", [(br bb:$dst)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000481
Owen Andersonf8053082007-11-12 07:39:39 +0000482// Indirect branches
483let isBranch = 1, isTerminator = 1, isBarrier = 1, isIndirectBranch = 1 in {
Dan Gohman91888f02007-07-31 20:11:57 +0000484 def JMP32r : I<0xFF, MRM4r, (outs), (ins GR32:$dst), "jmp{l}\t{*}$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000485 [(brind GR32:$dst)]>;
Dan Gohman91888f02007-07-31 20:11:57 +0000486 def JMP32m : I<0xFF, MRM4m, (outs), (ins i32mem:$dst), "jmp{l}\t{*}$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000487 [(brind (loadi32 addr:$dst))]>;
488}
489
490// Conditional branches
Evan Cheng950aac02007-09-25 01:57:46 +0000491let Uses = [EFLAGS] in {
Dan Gohman91888f02007-07-31 20:11:57 +0000492def JE : IBr<0x84, (ins brtarget:$dst), "je\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000493 [(X86brcond bb:$dst, X86_COND_E, EFLAGS)]>, TB;
Dan Gohman91888f02007-07-31 20:11:57 +0000494def JNE : IBr<0x85, (ins brtarget:$dst), "jne\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000495 [(X86brcond bb:$dst, X86_COND_NE, EFLAGS)]>, TB;
Dan Gohman91888f02007-07-31 20:11:57 +0000496def JL : IBr<0x8C, (ins brtarget:$dst), "jl\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000497 [(X86brcond bb:$dst, X86_COND_L, EFLAGS)]>, TB;
Dan Gohman91888f02007-07-31 20:11:57 +0000498def JLE : IBr<0x8E, (ins brtarget:$dst), "jle\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000499 [(X86brcond bb:$dst, X86_COND_LE, EFLAGS)]>, TB;
Dan Gohman91888f02007-07-31 20:11:57 +0000500def JG : IBr<0x8F, (ins brtarget:$dst), "jg\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000501 [(X86brcond bb:$dst, X86_COND_G, EFLAGS)]>, TB;
Dan Gohman91888f02007-07-31 20:11:57 +0000502def JGE : IBr<0x8D, (ins brtarget:$dst), "jge\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000503 [(X86brcond bb:$dst, X86_COND_GE, EFLAGS)]>, TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000504
Dan Gohman91888f02007-07-31 20:11:57 +0000505def JB : IBr<0x82, (ins brtarget:$dst), "jb\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000506 [(X86brcond bb:$dst, X86_COND_B, EFLAGS)]>, TB;
Dan Gohman91888f02007-07-31 20:11:57 +0000507def JBE : IBr<0x86, (ins brtarget:$dst), "jbe\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000508 [(X86brcond bb:$dst, X86_COND_BE, EFLAGS)]>, TB;
Dan Gohman91888f02007-07-31 20:11:57 +0000509def JA : IBr<0x87, (ins brtarget:$dst), "ja\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000510 [(X86brcond bb:$dst, X86_COND_A, EFLAGS)]>, TB;
Dan Gohman91888f02007-07-31 20:11:57 +0000511def JAE : IBr<0x83, (ins brtarget:$dst), "jae\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000512 [(X86brcond bb:$dst, X86_COND_AE, EFLAGS)]>, TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000513
Dan Gohman91888f02007-07-31 20:11:57 +0000514def JS : IBr<0x88, (ins brtarget:$dst), "js\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000515 [(X86brcond bb:$dst, X86_COND_S, EFLAGS)]>, TB;
Dan Gohman91888f02007-07-31 20:11:57 +0000516def JNS : IBr<0x89, (ins brtarget:$dst), "jns\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000517 [(X86brcond bb:$dst, X86_COND_NS, EFLAGS)]>, TB;
Dan Gohman91888f02007-07-31 20:11:57 +0000518def JP : IBr<0x8A, (ins brtarget:$dst), "jp\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000519 [(X86brcond bb:$dst, X86_COND_P, EFLAGS)]>, TB;
Dan Gohman91888f02007-07-31 20:11:57 +0000520def JNP : IBr<0x8B, (ins brtarget:$dst), "jnp\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000521 [(X86brcond bb:$dst, X86_COND_NP, EFLAGS)]>, TB;
Dan Gohman91888f02007-07-31 20:11:57 +0000522def JO : IBr<0x80, (ins brtarget:$dst), "jo\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000523 [(X86brcond bb:$dst, X86_COND_O, EFLAGS)]>, TB;
Dan Gohman91888f02007-07-31 20:11:57 +0000524def JNO : IBr<0x81, (ins brtarget:$dst), "jno\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000525 [(X86brcond bb:$dst, X86_COND_NO, EFLAGS)]>, TB;
Evan Cheng950aac02007-09-25 01:57:46 +0000526} // Uses = [EFLAGS]
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000527
528//===----------------------------------------------------------------------===//
529// Call Instructions...
530//
Evan Cheng37e7c752007-07-21 00:34:19 +0000531let isCall = 1 in
Dan Gohman01c9f772008-10-01 18:28:06 +0000532 // All calls clobber the non-callee saved registers. ESP is marked as
533 // a use to prevent stack-pointer assignments that appear immediately
534 // before calls from potentially appearing dead. Uses for argument
535 // registers are added manually.
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000536 let Defs = [EAX, ECX, EDX, FP0, FP1, FP2, FP3, FP4, FP5, FP6, ST0,
537 MM0, MM1, MM2, MM3, MM4, MM5, MM6, MM7,
Evan Cheng2293b252008-10-17 21:02:22 +0000538 XMM0, XMM1, XMM2, XMM3, XMM4, XMM5, XMM6, XMM7,
539 XMM8, XMM9, XMM10, XMM11, XMM12, XMM13, XMM14, XMM15, EFLAGS],
Dan Gohman9499cfe2008-10-01 04:14:30 +0000540 Uses = [ESP] in {
Evan Cheng34f93712007-12-22 02:26:46 +0000541 def CALLpcrel32 : Ii32<0xE8, RawFrm, (outs), (ins i32imm:$dst,variable_ops),
Evan Cheng0af5a042009-03-12 18:15:39 +0000542 "call\t${dst:call}", [(X86call imm:$dst)]>,
543 Requires<[In32BitMode]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000544 def CALL32r : I<0xFF, MRM2r, (outs), (ins GR32:$dst, variable_ops),
Dan Gohman91888f02007-07-31 20:11:57 +0000545 "call\t{*}$dst", [(X86call GR32:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000546 def CALL32m : I<0xFF, MRM2m, (outs), (ins i32mem:$dst, variable_ops),
Dan Gohmanea4faba2008-05-29 21:50:34 +0000547 "call\t{*}$dst", [(X86call (loadi32 addr:$dst))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000548 }
549
550// Tail call stuff.
Arnold Schwaighofere2d6bbb2007-10-11 19:40:01 +0000551
Chris Lattnerb56cc342008-03-11 03:23:40 +0000552def TAILCALL : I<0, Pseudo, (outs), (ins),
Arnold Schwaighofere2d6bbb2007-10-11 19:40:01 +0000553 "#TAILCALL",
554 []>;
555
Evan Cheng37e7c752007-07-21 00:34:19 +0000556let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1 in
Arnold Schwaighofer6fd37ac2008-03-19 16:39:45 +0000557def TCRETURNdi : I<0, Pseudo, (outs), (ins i32imm:$dst, i32imm:$offset, variable_ops),
Arnold Schwaighofere2d6bbb2007-10-11 19:40:01 +0000558 "#TC_RETURN $dst $offset",
559 []>;
560
561let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1 in
Arnold Schwaighofer6fd37ac2008-03-19 16:39:45 +0000562def TCRETURNri : I<0, Pseudo, (outs), (ins GR32:$dst, i32imm:$offset, variable_ops),
Arnold Schwaighofere2d6bbb2007-10-11 19:40:01 +0000563 "#TC_RETURN $dst $offset",
564 []>;
565
566let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1 in
Arnold Schwaighofera0032722008-04-30 09:16:33 +0000567
Arnold Schwaighofere2d6bbb2007-10-11 19:40:01 +0000568 def TAILJMPd : IBr<0xE9, (ins i32imm:$dst), "jmp\t${dst:call} # TAILCALL",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000569 []>;
Evan Cheng37e7c752007-07-21 00:34:19 +0000570let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1 in
Arnold Schwaighofere2d6bbb2007-10-11 19:40:01 +0000571 def TAILJMPr : I<0xFF, MRM4r, (outs), (ins GR32:$dst), "jmp{l}\t{*}$dst # TAILCALL",
572 []>;
Evan Cheng37e7c752007-07-21 00:34:19 +0000573let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +0000574 def TAILJMPm : I<0xFF, MRM4m, (outs), (ins i32mem:$dst),
Arnold Schwaighofere2d6bbb2007-10-11 19:40:01 +0000575 "jmp\t{*}$dst # TAILCALL", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000576
577//===----------------------------------------------------------------------===//
578// Miscellaneous Instructions...
579//
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000580let Defs = [EBP, ESP], Uses = [EBP, ESP], mayLoad = 1, neverHasSideEffects=1 in
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000581def LEAVE : I<0xC9, RawFrm,
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000582 (outs), (ins), "leave", []>;
583
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000584let Defs = [ESP], Uses = [ESP], neverHasSideEffects=1 in {
585let mayLoad = 1 in
Evan Chengd8434332007-09-26 01:29:06 +0000586def POP32r : I<0x58, AddRegFrm, (outs GR32:$reg), (ins), "pop{l}\t$reg", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000587
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000588let mayStore = 1 in
Evan Chengd8434332007-09-26 01:29:06 +0000589def PUSH32r : I<0x50, AddRegFrm, (outs), (ins GR32:$reg), "push{l}\t$reg",[]>;
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000590}
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000591
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000592let Defs = [ESP, EFLAGS], Uses = [ESP], mayLoad = 1, neverHasSideEffects=1 in
Evan Chengf1341312007-09-26 21:28:00 +0000593def POPFD : I<0x9D, RawFrm, (outs), (ins), "popf", []>;
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000594let Defs = [ESP], Uses = [ESP, EFLAGS], mayStore = 1, neverHasSideEffects=1 in
Evan Chengf1341312007-09-26 21:28:00 +0000595def PUSHFD : I<0x9C, RawFrm, (outs), (ins), "pushf", []>;
Evan Chengd8434332007-09-26 01:29:06 +0000596
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000597let isTwoAddress = 1 in // GR32 = bswap GR32
598 def BSWAP32r : I<0xC8, AddRegFrm,
Evan Chengb783fa32007-07-19 01:14:50 +0000599 (outs GR32:$dst), (ins GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000600 "bswap{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000601 [(set GR32:$dst, (bswap GR32:$src))]>, TB;
602
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000603
Evan Cheng48679f42007-12-14 02:13:44 +0000604// Bit scan instructions.
605let Defs = [EFLAGS] in {
Evan Cheng4e33de92007-12-14 18:49:43 +0000606def BSF16rr : I<0xBC, MRMSrcReg, (outs GR16:$dst), (ins GR16:$src),
Dan Gohmancdb54c62007-12-14 15:10:00 +0000607 "bsf{w}\t{$src, $dst|$dst, $src}",
Evan Cheng7cfbfe32007-12-14 08:30:15 +0000608 [(set GR16:$dst, (X86bsf GR16:$src)), (implicit EFLAGS)]>, TB;
Evan Cheng48679f42007-12-14 02:13:44 +0000609def BSF16rm : I<0xBC, MRMSrcMem, (outs GR16:$dst), (ins i16mem:$src),
Dan Gohmancdb54c62007-12-14 15:10:00 +0000610 "bsf{w}\t{$src, $dst|$dst, $src}",
Evan Cheng7cfbfe32007-12-14 08:30:15 +0000611 [(set GR16:$dst, (X86bsf (loadi16 addr:$src))),
612 (implicit EFLAGS)]>, TB;
Evan Cheng4e33de92007-12-14 18:49:43 +0000613def BSF32rr : I<0xBC, MRMSrcReg, (outs GR32:$dst), (ins GR32:$src),
Dan Gohmancdb54c62007-12-14 15:10:00 +0000614 "bsf{l}\t{$src, $dst|$dst, $src}",
Evan Cheng7cfbfe32007-12-14 08:30:15 +0000615 [(set GR32:$dst, (X86bsf GR32:$src)), (implicit EFLAGS)]>, TB;
Evan Cheng48679f42007-12-14 02:13:44 +0000616def BSF32rm : I<0xBC, MRMSrcMem, (outs GR32:$dst), (ins i32mem:$src),
Dan Gohmancdb54c62007-12-14 15:10:00 +0000617 "bsf{l}\t{$src, $dst|$dst, $src}",
Evan Cheng7cfbfe32007-12-14 08:30:15 +0000618 [(set GR32:$dst, (X86bsf (loadi32 addr:$src))),
619 (implicit EFLAGS)]>, TB;
Evan Cheng48679f42007-12-14 02:13:44 +0000620
Evan Cheng4e33de92007-12-14 18:49:43 +0000621def BSR16rr : I<0xBD, MRMSrcReg, (outs GR16:$dst), (ins GR16:$src),
Dan Gohmancdb54c62007-12-14 15:10:00 +0000622 "bsr{w}\t{$src, $dst|$dst, $src}",
Evan Cheng7cfbfe32007-12-14 08:30:15 +0000623 [(set GR16:$dst, (X86bsr GR16:$src)), (implicit EFLAGS)]>, TB;
Evan Cheng48679f42007-12-14 02:13:44 +0000624def BSR16rm : I<0xBD, MRMSrcMem, (outs GR16:$dst), (ins i16mem:$src),
Dan Gohmancdb54c62007-12-14 15:10:00 +0000625 "bsr{w}\t{$src, $dst|$dst, $src}",
Evan Cheng7cfbfe32007-12-14 08:30:15 +0000626 [(set GR16:$dst, (X86bsr (loadi16 addr:$src))),
627 (implicit EFLAGS)]>, TB;
Evan Cheng4e33de92007-12-14 18:49:43 +0000628def BSR32rr : I<0xBD, MRMSrcReg, (outs GR32:$dst), (ins GR32:$src),
Dan Gohmancdb54c62007-12-14 15:10:00 +0000629 "bsr{l}\t{$src, $dst|$dst, $src}",
Evan Cheng7cfbfe32007-12-14 08:30:15 +0000630 [(set GR32:$dst, (X86bsr GR32:$src)), (implicit EFLAGS)]>, TB;
Evan Cheng48679f42007-12-14 02:13:44 +0000631def BSR32rm : I<0xBD, MRMSrcMem, (outs GR32:$dst), (ins i32mem:$src),
Dan Gohmancdb54c62007-12-14 15:10:00 +0000632 "bsr{l}\t{$src, $dst|$dst, $src}",
Evan Cheng7cfbfe32007-12-14 08:30:15 +0000633 [(set GR32:$dst, (X86bsr (loadi32 addr:$src))),
634 (implicit EFLAGS)]>, TB;
Evan Cheng48679f42007-12-14 02:13:44 +0000635} // Defs = [EFLAGS]
636
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000637let neverHasSideEffects = 1 in
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000638def LEA16r : I<0x8D, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +0000639 (outs GR16:$dst), (ins i32mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000640 "lea{w}\t{$src|$dst}, {$dst|$src}", []>, OpSize;
Evan Cheng1ea8e6b2008-03-27 01:41:09 +0000641let isReMaterializable = 1 in
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000642def LEA32r : I<0x8D, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +0000643 (outs GR32:$dst), (ins lea32mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000644 "lea{l}\t{$src|$dst}, {$dst|$src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000645 [(set GR32:$dst, lea32addr:$src)]>, Requires<[In32BitMode]>;
646
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000647let Defs = [ECX,EDI,ESI], Uses = [ECX,EDI,ESI] in {
Evan Chengb783fa32007-07-19 01:14:50 +0000648def REP_MOVSB : I<0xA4, RawFrm, (outs), (ins), "{rep;movsb|rep movsb}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000649 [(X86rep_movs i8)]>, REP;
Evan Chengb783fa32007-07-19 01:14:50 +0000650def REP_MOVSW : I<0xA5, RawFrm, (outs), (ins), "{rep;movsw|rep movsw}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000651 [(X86rep_movs i16)]>, REP, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +0000652def REP_MOVSD : I<0xA5, RawFrm, (outs), (ins), "{rep;movsl|rep movsd}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000653 [(X86rep_movs i32)]>, REP;
654}
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000655
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000656let Defs = [ECX,EDI], Uses = [AL,ECX,EDI] in
Evan Chengb783fa32007-07-19 01:14:50 +0000657def REP_STOSB : I<0xAA, RawFrm, (outs), (ins), "{rep;stosb|rep stosb}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000658 [(X86rep_stos i8)]>, REP;
659let Defs = [ECX,EDI], Uses = [AX,ECX,EDI] in
Evan Chengb783fa32007-07-19 01:14:50 +0000660def REP_STOSW : I<0xAB, RawFrm, (outs), (ins), "{rep;stosw|rep stosw}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000661 [(X86rep_stos i16)]>, REP, OpSize;
662let Defs = [ECX,EDI], Uses = [EAX,ECX,EDI] in
Evan Chengb783fa32007-07-19 01:14:50 +0000663def REP_STOSD : I<0xAB, RawFrm, (outs), (ins), "{rep;stosl|rep stosd}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000664 [(X86rep_stos i32)]>, REP;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000665
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000666let Defs = [RAX, RDX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000667def RDTSC : I<0x31, RawFrm, (outs), (ins), "rdtsc", [(X86rdtsc)]>,
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000668 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000669
Anton Korobeynikov39d40ba2008-01-15 07:02:33 +0000670let isBarrier = 1, hasCtrlDep = 1 in {
Chris Lattner56b941f2008-01-15 21:58:22 +0000671def TRAP : I<0x0B, RawFrm, (outs), (ins), "ud2", [(trap)]>, TB;
Anton Korobeynikov39d40ba2008-01-15 07:02:33 +0000672}
673
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000674//===----------------------------------------------------------------------===//
675// Input/Output Instructions...
676//
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000677let Defs = [AL], Uses = [DX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000678def IN8rr : I<0xEC, RawFrm, (outs), (ins),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000679 "in{b}\t{%dx, %al|%AL, %DX}", []>;
680let Defs = [AX], Uses = [DX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000681def IN16rr : I<0xED, RawFrm, (outs), (ins),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000682 "in{w}\t{%dx, %ax|%AX, %DX}", []>, OpSize;
683let Defs = [EAX], Uses = [DX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000684def IN32rr : I<0xED, RawFrm, (outs), (ins),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000685 "in{l}\t{%dx, %eax|%EAX, %DX}", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000686
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000687let Defs = [AL] in
Evan Chengb783fa32007-07-19 01:14:50 +0000688def IN8ri : Ii8<0xE4, RawFrm, (outs), (ins i16i8imm:$port),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000689 "in{b}\t{$port, %al|%AL, $port}", []>;
690let Defs = [AX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000691def IN16ri : Ii8<0xE5, RawFrm, (outs), (ins i16i8imm:$port),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000692 "in{w}\t{$port, %ax|%AX, $port}", []>, OpSize;
693let Defs = [EAX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000694def IN32ri : Ii8<0xE5, RawFrm, (outs), (ins i16i8imm:$port),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000695 "in{l}\t{$port, %eax|%EAX, $port}", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000696
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000697let Uses = [DX, AL] in
Evan Chengb783fa32007-07-19 01:14:50 +0000698def OUT8rr : I<0xEE, RawFrm, (outs), (ins),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000699 "out{b}\t{%al, %dx|%DX, %AL}", []>;
700let Uses = [DX, AX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000701def OUT16rr : I<0xEF, RawFrm, (outs), (ins),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000702 "out{w}\t{%ax, %dx|%DX, %AX}", []>, OpSize;
703let Uses = [DX, EAX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000704def OUT32rr : I<0xEF, RawFrm, (outs), (ins),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000705 "out{l}\t{%eax, %dx|%DX, %EAX}", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000706
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000707let Uses = [AL] in
Evan Chengb783fa32007-07-19 01:14:50 +0000708def OUT8ir : Ii8<0xE6, RawFrm, (outs), (ins i16i8imm:$port),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000709 "out{b}\t{%al, $port|$port, %AL}", []>;
710let Uses = [AX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000711def OUT16ir : Ii8<0xE7, RawFrm, (outs), (ins i16i8imm:$port),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000712 "out{w}\t{%ax, $port|$port, %AX}", []>, OpSize;
713let Uses = [EAX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000714def OUT32ir : Ii8<0xE7, RawFrm, (outs), (ins i16i8imm:$port),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000715 "out{l}\t{%eax, $port|$port, %EAX}", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000716
717//===----------------------------------------------------------------------===//
718// Move Instructions...
719//
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000720let neverHasSideEffects = 1 in {
Evan Chengb783fa32007-07-19 01:14:50 +0000721def MOV8rr : I<0x88, MRMDestReg, (outs GR8 :$dst), (ins GR8 :$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000722 "mov{b}\t{$src, $dst|$dst, $src}", []>;
Evan Chengb783fa32007-07-19 01:14:50 +0000723def MOV16rr : I<0x89, MRMDestReg, (outs GR16:$dst), (ins GR16:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000724 "mov{w}\t{$src, $dst|$dst, $src}", []>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +0000725def MOV32rr : I<0x89, MRMDestReg, (outs GR32:$dst), (ins GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000726 "mov{l}\t{$src, $dst|$dst, $src}", []>;
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000727}
Evan Cheng6f26e8b2008-06-18 08:13:07 +0000728let isReMaterializable = 1, isAsCheapAsAMove = 1 in {
Evan Chengb783fa32007-07-19 01:14:50 +0000729def MOV8ri : Ii8 <0xB0, AddRegFrm, (outs GR8 :$dst), (ins i8imm :$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000730 "mov{b}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000731 [(set GR8:$dst, imm:$src)]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000732def MOV16ri : Ii16<0xB8, AddRegFrm, (outs GR16:$dst), (ins i16imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000733 "mov{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000734 [(set GR16:$dst, imm:$src)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +0000735def MOV32ri : Ii32<0xB8, AddRegFrm, (outs GR32:$dst), (ins i32imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000736 "mov{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000737 [(set GR32:$dst, imm:$src)]>;
738}
Evan Chengb783fa32007-07-19 01:14:50 +0000739def MOV8mi : Ii8 <0xC6, MRM0m, (outs), (ins i8mem :$dst, i8imm :$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000740 "mov{b}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000741 [(store (i8 imm:$src), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000742def MOV16mi : Ii16<0xC7, MRM0m, (outs), (ins i16mem:$dst, i16imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000743 "mov{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000744 [(store (i16 imm:$src), addr:$dst)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +0000745def MOV32mi : Ii32<0xC7, MRM0m, (outs), (ins i32mem:$dst, i32imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000746 "mov{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000747 [(store (i32 imm:$src), addr:$dst)]>;
748
Dan Gohman5574cc72008-12-03 18:15:48 +0000749let canFoldAsLoad = 1, isReMaterializable = 1, mayHaveSideEffects = 1 in {
Evan Chengb783fa32007-07-19 01:14:50 +0000750def MOV8rm : I<0x8A, MRMSrcMem, (outs GR8 :$dst), (ins i8mem :$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000751 "mov{b}\t{$src, $dst|$dst, $src}",
Chris Lattner12208612009-04-10 00:16:23 +0000752 [(set GR8:$dst, (loadi8 addr:$src))]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000753def MOV16rm : I<0x8B, MRMSrcMem, (outs GR16:$dst), (ins i16mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000754 "mov{w}\t{$src, $dst|$dst, $src}",
Chris Lattner12208612009-04-10 00:16:23 +0000755 [(set GR16:$dst, (loadi16 addr:$src))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +0000756def MOV32rm : I<0x8B, MRMSrcMem, (outs GR32:$dst), (ins i32mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000757 "mov{l}\t{$src, $dst|$dst, $src}",
Chris Lattner12208612009-04-10 00:16:23 +0000758 [(set GR32:$dst, (loadi32 addr:$src))]>;
Evan Cheng4e84e452007-08-30 05:49:43 +0000759}
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000760
Evan Chengb783fa32007-07-19 01:14:50 +0000761def MOV8mr : I<0x88, MRMDestMem, (outs), (ins i8mem :$dst, GR8 :$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000762 "mov{b}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000763 [(store GR8:$src, addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000764def MOV16mr : I<0x89, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000765 "mov{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000766 [(store GR16:$src, addr:$dst)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +0000767def MOV32mr : I<0x89, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000768 "mov{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000769 [(store GR32:$src, addr:$dst)]>;
770
771//===----------------------------------------------------------------------===//
772// Fixed-Register Multiplication and Division Instructions...
773//
774
775// Extra precision multiplication
Evan Cheng55687072007-09-14 21:48:26 +0000776let Defs = [AL,AH,EFLAGS], Uses = [AL] in
Dan Gohman91888f02007-07-31 20:11:57 +0000777def MUL8r : I<0xF6, MRM4r, (outs), (ins GR8:$src), "mul{b}\t$src",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000778 // FIXME: Used for 8-bit mul, ignore result upper 8 bits.
779 // This probably ought to be moved to a def : Pat<> if the
780 // syntax can be accepted.
Bill Wendlingf5399032008-12-12 21:15:41 +0000781 [(set AL, (mul AL, GR8:$src)),
782 (implicit EFLAGS)]>; // AL,AH = AL*GR8
783
Chris Lattnerc7e96e72008-01-11 07:18:17 +0000784let Defs = [AX,DX,EFLAGS], Uses = [AX], neverHasSideEffects = 1 in
Bill Wendlingf5399032008-12-12 21:15:41 +0000785def MUL16r : I<0xF7, MRM4r, (outs), (ins GR16:$src),
786 "mul{w}\t$src",
787 []>, OpSize; // AX,DX = AX*GR16
788
Chris Lattnerc7e96e72008-01-11 07:18:17 +0000789let Defs = [EAX,EDX,EFLAGS], Uses = [EAX], neverHasSideEffects = 1 in
Bill Wendlingf5399032008-12-12 21:15:41 +0000790def MUL32r : I<0xF7, MRM4r, (outs), (ins GR32:$src),
791 "mul{l}\t$src",
792 []>; // EAX,EDX = EAX*GR32
793
Evan Cheng55687072007-09-14 21:48:26 +0000794let Defs = [AL,AH,EFLAGS], Uses = [AL] in
Evan Chengb783fa32007-07-19 01:14:50 +0000795def MUL8m : I<0xF6, MRM4m, (outs), (ins i8mem :$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000796 "mul{b}\t$src",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000797 // FIXME: Used for 8-bit mul, ignore result upper 8 bits.
798 // This probably ought to be moved to a def : Pat<> if the
799 // syntax can be accepted.
Bill Wendlingf5399032008-12-12 21:15:41 +0000800 [(set AL, (mul AL, (loadi8 addr:$src))),
801 (implicit EFLAGS)]>; // AL,AH = AL*[mem8]
802
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000803let mayLoad = 1, neverHasSideEffects = 1 in {
Evan Cheng55687072007-09-14 21:48:26 +0000804let Defs = [AX,DX,EFLAGS], Uses = [AX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000805def MUL16m : I<0xF7, MRM4m, (outs), (ins i16mem:$src),
Bill Wendlingf5399032008-12-12 21:15:41 +0000806 "mul{w}\t$src",
807 []>, OpSize; // AX,DX = AX*[mem16]
808
Evan Cheng55687072007-09-14 21:48:26 +0000809let Defs = [EAX,EDX,EFLAGS], Uses = [EAX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000810def MUL32m : I<0xF7, MRM4m, (outs), (ins i32mem:$src),
Bill Wendlingf5399032008-12-12 21:15:41 +0000811 "mul{l}\t$src",
812 []>; // EAX,EDX = EAX*[mem32]
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000813}
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000814
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000815let neverHasSideEffects = 1 in {
Evan Cheng55687072007-09-14 21:48:26 +0000816let Defs = [AL,AH,EFLAGS], Uses = [AL] in
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000817def IMUL8r : I<0xF6, MRM5r, (outs), (ins GR8:$src), "imul{b}\t$src", []>;
818 // AL,AH = AL*GR8
Evan Cheng55687072007-09-14 21:48:26 +0000819let Defs = [AX,DX,EFLAGS], Uses = [AX] in
Dan Gohman91888f02007-07-31 20:11:57 +0000820def IMUL16r : I<0xF7, MRM5r, (outs), (ins GR16:$src), "imul{w}\t$src", []>,
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000821 OpSize; // AX,DX = AX*GR16
Evan Cheng55687072007-09-14 21:48:26 +0000822let Defs = [EAX,EDX,EFLAGS], Uses = [EAX] in
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000823def IMUL32r : I<0xF7, MRM5r, (outs), (ins GR32:$src), "imul{l}\t$src", []>;
824 // EAX,EDX = EAX*GR32
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000825let mayLoad = 1 in {
Evan Cheng55687072007-09-14 21:48:26 +0000826let Defs = [AL,AH,EFLAGS], Uses = [AL] in
Evan Chengb783fa32007-07-19 01:14:50 +0000827def IMUL8m : I<0xF6, MRM5m, (outs), (ins i8mem :$src),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000828 "imul{b}\t$src", []>; // AL,AH = AL*[mem8]
Evan Cheng55687072007-09-14 21:48:26 +0000829let Defs = [AX,DX,EFLAGS], Uses = [AX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000830def IMUL16m : I<0xF7, MRM5m, (outs), (ins i16mem:$src),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000831 "imul{w}\t$src", []>, OpSize; // AX,DX = AX*[mem16]
832let Defs = [EAX,EDX], Uses = [EAX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000833def IMUL32m : I<0xF7, MRM5m, (outs), (ins i32mem:$src),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000834 "imul{l}\t$src", []>; // EAX,EDX = EAX*[mem32]
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000835}
Dan Gohmand44572d2008-11-18 21:29:14 +0000836} // neverHasSideEffects
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000837
838// unsigned division/remainder
Dale Johannesend8fd3562008-10-07 18:54:28 +0000839let Defs = [AL,AH,EFLAGS], Uses = [AX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000840def DIV8r : I<0xF6, MRM6r, (outs), (ins GR8:$src), // AX/r8 = AL,AH
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000841 "div{b}\t$src", []>;
Evan Cheng55687072007-09-14 21:48:26 +0000842let Defs = [AX,DX,EFLAGS], Uses = [AX,DX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000843def DIV16r : I<0xF7, MRM6r, (outs), (ins GR16:$src), // DX:AX/r16 = AX,DX
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000844 "div{w}\t$src", []>, OpSize;
Evan Cheng55687072007-09-14 21:48:26 +0000845let Defs = [EAX,EDX,EFLAGS], Uses = [EAX,EDX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000846def DIV32r : I<0xF7, MRM6r, (outs), (ins GR32:$src), // EDX:EAX/r32 = EAX,EDX
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000847 "div{l}\t$src", []>;
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000848let mayLoad = 1 in {
Dale Johannesend8fd3562008-10-07 18:54:28 +0000849let Defs = [AL,AH,EFLAGS], Uses = [AX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000850def DIV8m : I<0xF6, MRM6m, (outs), (ins i8mem:$src), // AX/[mem8] = AL,AH
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000851 "div{b}\t$src", []>;
Evan Cheng55687072007-09-14 21:48:26 +0000852let Defs = [AX,DX,EFLAGS], Uses = [AX,DX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000853def DIV16m : I<0xF7, MRM6m, (outs), (ins i16mem:$src), // DX:AX/[mem16] = AX,DX
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000854 "div{w}\t$src", []>, OpSize;
Evan Cheng55687072007-09-14 21:48:26 +0000855let Defs = [EAX,EDX,EFLAGS], Uses = [EAX,EDX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000856def DIV32m : I<0xF7, MRM6m, (outs), (ins i32mem:$src), // EDX:EAX/[mem32] = EAX,EDX
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000857 "div{l}\t$src", []>;
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000858}
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000859
860// Signed division/remainder.
Dale Johannesend8fd3562008-10-07 18:54:28 +0000861let Defs = [AL,AH,EFLAGS], Uses = [AX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000862def IDIV8r : I<0xF6, MRM7r, (outs), (ins GR8:$src), // AX/r8 = AL,AH
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000863 "idiv{b}\t$src", []>;
Evan Cheng55687072007-09-14 21:48:26 +0000864let Defs = [AX,DX,EFLAGS], Uses = [AX,DX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000865def IDIV16r: I<0xF7, MRM7r, (outs), (ins GR16:$src), // DX:AX/r16 = AX,DX
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000866 "idiv{w}\t$src", []>, OpSize;
Evan Cheng55687072007-09-14 21:48:26 +0000867let Defs = [EAX,EDX,EFLAGS], Uses = [EAX,EDX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000868def IDIV32r: I<0xF7, MRM7r, (outs), (ins GR32:$src), // EDX:EAX/r32 = EAX,EDX
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000869 "idiv{l}\t$src", []>;
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000870let mayLoad = 1, mayLoad = 1 in {
Dale Johannesend8fd3562008-10-07 18:54:28 +0000871let Defs = [AL,AH,EFLAGS], Uses = [AX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000872def IDIV8m : I<0xF6, MRM7m, (outs), (ins i8mem:$src), // AX/[mem8] = AL,AH
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000873 "idiv{b}\t$src", []>;
Evan Cheng55687072007-09-14 21:48:26 +0000874let Defs = [AX,DX,EFLAGS], Uses = [AX,DX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000875def IDIV16m: I<0xF7, MRM7m, (outs), (ins i16mem:$src), // DX:AX/[mem16] = AX,DX
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000876 "idiv{w}\t$src", []>, OpSize;
Evan Cheng55687072007-09-14 21:48:26 +0000877let Defs = [EAX,EDX,EFLAGS], Uses = [EAX,EDX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000878def IDIV32m: I<0xF7, MRM7m, (outs), (ins i32mem:$src), // EDX:EAX/[mem32] = EAX,EDX
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000879 "idiv{l}\t$src", []>;
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000880}
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000881
882//===----------------------------------------------------------------------===//
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000883// Two address Instructions.
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000884//
885let isTwoAddress = 1 in {
886
887// Conditional moves
Evan Cheng950aac02007-09-25 01:57:46 +0000888let Uses = [EFLAGS] in {
Evan Cheng926658c2007-10-05 23:13:21 +0000889let isCommutable = 1 in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000890def CMOVB16rr : I<0x42, MRMSrcReg, // if <u, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +0000891 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000892 "cmovb\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000893 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000894 X86_COND_B, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000895 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000896def CMOVB32rr : I<0x42, MRMSrcReg, // if <u, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +0000897 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000898 "cmovb\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000899 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000900 X86_COND_B, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000901 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000902def CMOVAE16rr: I<0x43, MRMSrcReg, // if >=u, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +0000903 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000904 "cmovae\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000905 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000906 X86_COND_AE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000907 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000908def CMOVAE32rr: I<0x43, MRMSrcReg, // if >=u, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +0000909 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000910 "cmovae\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000911 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000912 X86_COND_AE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000913 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000914def CMOVE16rr : I<0x44, MRMSrcReg, // if ==, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +0000915 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000916 "cmove\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000917 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000918 X86_COND_E, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000919 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000920def CMOVE32rr : I<0x44, MRMSrcReg, // if ==, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +0000921 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000922 "cmove\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000923 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000924 X86_COND_E, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000925 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000926def CMOVNE16rr: I<0x45, MRMSrcReg, // if !=, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +0000927 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000928 "cmovne\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000929 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000930 X86_COND_NE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000931 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000932def CMOVNE32rr: I<0x45, MRMSrcReg, // if !=, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +0000933 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000934 "cmovne\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000935 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000936 X86_COND_NE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000937 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000938def CMOVBE16rr: I<0x46, MRMSrcReg, // if <=u, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +0000939 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000940 "cmovbe\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000941 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000942 X86_COND_BE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000943 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000944def CMOVBE32rr: I<0x46, MRMSrcReg, // if <=u, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +0000945 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000946 "cmovbe\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000947 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000948 X86_COND_BE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000949 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000950def CMOVA16rr : I<0x47, MRMSrcReg, // if >u, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +0000951 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000952 "cmova\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000953 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000954 X86_COND_A, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000955 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000956def CMOVA32rr : I<0x47, MRMSrcReg, // if >u, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +0000957 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000958 "cmova\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000959 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000960 X86_COND_A, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000961 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000962def CMOVL16rr : I<0x4C, MRMSrcReg, // if <s, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +0000963 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000964 "cmovl\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000965 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000966 X86_COND_L, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000967 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000968def CMOVL32rr : I<0x4C, MRMSrcReg, // if <s, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +0000969 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000970 "cmovl\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000971 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000972 X86_COND_L, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000973 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000974def CMOVGE16rr: I<0x4D, MRMSrcReg, // if >=s, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +0000975 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000976 "cmovge\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000977 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000978 X86_COND_GE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000979 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000980def CMOVGE32rr: I<0x4D, MRMSrcReg, // if >=s, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +0000981 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000982 "cmovge\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000983 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000984 X86_COND_GE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000985 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000986def CMOVLE16rr: I<0x4E, MRMSrcReg, // if <=s, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +0000987 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000988 "cmovle\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000989 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000990 X86_COND_LE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000991 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000992def CMOVLE32rr: I<0x4E, MRMSrcReg, // if <=s, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +0000993 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000994 "cmovle\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000995 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000996 X86_COND_LE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000997 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000998def CMOVG16rr : I<0x4F, MRMSrcReg, // if >s, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +0000999 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001000 "cmovg\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001001 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001002 X86_COND_G, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001003 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001004def CMOVG32rr : I<0x4F, MRMSrcReg, // if >s, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +00001005 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001006 "cmovg\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001007 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001008 X86_COND_G, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001009 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001010def CMOVS16rr : I<0x48, MRMSrcReg, // if signed, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +00001011 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001012 "cmovs\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001013 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001014 X86_COND_S, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001015 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001016def CMOVS32rr : I<0x48, MRMSrcReg, // if signed, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +00001017 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001018 "cmovs\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001019 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001020 X86_COND_S, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001021 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001022def CMOVNS16rr: I<0x49, MRMSrcReg, // if !signed, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +00001023 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001024 "cmovns\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001025 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001026 X86_COND_NS, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001027 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001028def CMOVNS32rr: I<0x49, MRMSrcReg, // if !signed, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +00001029 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001030 "cmovns\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001031 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001032 X86_COND_NS, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001033 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001034def CMOVP16rr : I<0x4A, MRMSrcReg, // if parity, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +00001035 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001036 "cmovp\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001037 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001038 X86_COND_P, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001039 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001040def CMOVP32rr : I<0x4A, MRMSrcReg, // if parity, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +00001041 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001042 "cmovp\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001043 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001044 X86_COND_P, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001045 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001046def CMOVNP16rr : I<0x4B, MRMSrcReg, // if !parity, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +00001047 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001048 "cmovnp\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001049 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001050 X86_COND_NP, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001051 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001052def CMOVNP32rr : I<0x4B, MRMSrcReg, // if !parity, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +00001053 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001054 "cmovnp\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001055 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001056 X86_COND_NP, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001057 TB;
Dan Gohman12fd4d72009-01-07 00:35:10 +00001058def CMOVO16rr : I<0x40, MRMSrcReg, // if overflow, GR16 = GR16
1059 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
1060 "cmovo\t{$src2, $dst|$dst, $src2}",
1061 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
1062 X86_COND_O, EFLAGS))]>,
1063 TB, OpSize;
1064def CMOVO32rr : I<0x40, MRMSrcReg, // if overflow, GR32 = GR32
1065 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
1066 "cmovo\t{$src2, $dst|$dst, $src2}",
1067 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
1068 X86_COND_O, EFLAGS))]>,
Evan Cheng950aac02007-09-25 01:57:46 +00001069 TB;
Dan Gohman12fd4d72009-01-07 00:35:10 +00001070def CMOVNO16rr : I<0x41, MRMSrcReg, // if !overflow, GR16 = GR16
1071 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
1072 "cmovno\t{$src2, $dst|$dst, $src2}",
1073 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
1074 X86_COND_NO, EFLAGS))]>,
1075 TB, OpSize;
1076def CMOVNO32rr : I<0x41, MRMSrcReg, // if !overflow, GR32 = GR32
1077 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
1078 "cmovno\t{$src2, $dst|$dst, $src2}",
1079 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
1080 X86_COND_NO, EFLAGS))]>,
1081 TB;
1082} // isCommutable = 1
Evan Cheng926658c2007-10-05 23:13:21 +00001083
1084def CMOVB16rm : I<0x42, MRMSrcMem, // if <u, GR16 = [mem16]
1085 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1086 "cmovb\t{$src2, $dst|$dst, $src2}",
1087 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1088 X86_COND_B, EFLAGS))]>,
1089 TB, OpSize;
1090def CMOVB32rm : I<0x42, MRMSrcMem, // if <u, GR32 = [mem32]
1091 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1092 "cmovb\t{$src2, $dst|$dst, $src2}",
1093 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1094 X86_COND_B, EFLAGS))]>,
1095 TB;
1096def CMOVAE16rm: I<0x43, MRMSrcMem, // if >=u, GR16 = [mem16]
1097 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1098 "cmovae\t{$src2, $dst|$dst, $src2}",
1099 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1100 X86_COND_AE, EFLAGS))]>,
1101 TB, OpSize;
1102def CMOVAE32rm: I<0x43, MRMSrcMem, // if >=u, GR32 = [mem32]
1103 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1104 "cmovae\t{$src2, $dst|$dst, $src2}",
1105 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1106 X86_COND_AE, EFLAGS))]>,
1107 TB;
1108def CMOVE16rm : I<0x44, MRMSrcMem, // if ==, GR16 = [mem16]
1109 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1110 "cmove\t{$src2, $dst|$dst, $src2}",
1111 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1112 X86_COND_E, EFLAGS))]>,
1113 TB, OpSize;
1114def CMOVE32rm : I<0x44, MRMSrcMem, // if ==, GR32 = [mem32]
1115 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1116 "cmove\t{$src2, $dst|$dst, $src2}",
1117 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1118 X86_COND_E, EFLAGS))]>,
1119 TB;
1120def CMOVNE16rm: I<0x45, MRMSrcMem, // if !=, GR16 = [mem16]
1121 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1122 "cmovne\t{$src2, $dst|$dst, $src2}",
1123 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1124 X86_COND_NE, EFLAGS))]>,
1125 TB, OpSize;
1126def CMOVNE32rm: I<0x45, MRMSrcMem, // if !=, GR32 = [mem32]
1127 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1128 "cmovne\t{$src2, $dst|$dst, $src2}",
1129 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1130 X86_COND_NE, EFLAGS))]>,
1131 TB;
1132def CMOVBE16rm: I<0x46, MRMSrcMem, // if <=u, GR16 = [mem16]
1133 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1134 "cmovbe\t{$src2, $dst|$dst, $src2}",
1135 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1136 X86_COND_BE, EFLAGS))]>,
1137 TB, OpSize;
1138def CMOVBE32rm: I<0x46, MRMSrcMem, // if <=u, GR32 = [mem32]
1139 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1140 "cmovbe\t{$src2, $dst|$dst, $src2}",
1141 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1142 X86_COND_BE, EFLAGS))]>,
1143 TB;
1144def CMOVA16rm : I<0x47, MRMSrcMem, // if >u, GR16 = [mem16]
1145 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1146 "cmova\t{$src2, $dst|$dst, $src2}",
1147 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1148 X86_COND_A, EFLAGS))]>,
1149 TB, OpSize;
1150def CMOVA32rm : I<0x47, MRMSrcMem, // if >u, GR32 = [mem32]
1151 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1152 "cmova\t{$src2, $dst|$dst, $src2}",
1153 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1154 X86_COND_A, EFLAGS))]>,
1155 TB;
1156def CMOVL16rm : I<0x4C, MRMSrcMem, // if <s, GR16 = [mem16]
1157 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1158 "cmovl\t{$src2, $dst|$dst, $src2}",
1159 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1160 X86_COND_L, EFLAGS))]>,
1161 TB, OpSize;
1162def CMOVL32rm : I<0x4C, MRMSrcMem, // if <s, GR32 = [mem32]
1163 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1164 "cmovl\t{$src2, $dst|$dst, $src2}",
1165 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1166 X86_COND_L, EFLAGS))]>,
1167 TB;
1168def CMOVGE16rm: I<0x4D, MRMSrcMem, // if >=s, GR16 = [mem16]
1169 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1170 "cmovge\t{$src2, $dst|$dst, $src2}",
1171 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1172 X86_COND_GE, EFLAGS))]>,
1173 TB, OpSize;
1174def CMOVGE32rm: I<0x4D, MRMSrcMem, // if >=s, GR32 = [mem32]
1175 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1176 "cmovge\t{$src2, $dst|$dst, $src2}",
1177 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1178 X86_COND_GE, EFLAGS))]>,
1179 TB;
1180def CMOVLE16rm: I<0x4E, MRMSrcMem, // if <=s, GR16 = [mem16]
1181 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1182 "cmovle\t{$src2, $dst|$dst, $src2}",
1183 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1184 X86_COND_LE, EFLAGS))]>,
1185 TB, OpSize;
1186def CMOVLE32rm: I<0x4E, MRMSrcMem, // if <=s, GR32 = [mem32]
1187 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1188 "cmovle\t{$src2, $dst|$dst, $src2}",
1189 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1190 X86_COND_LE, EFLAGS))]>,
1191 TB;
1192def CMOVG16rm : I<0x4F, MRMSrcMem, // if >s, GR16 = [mem16]
1193 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1194 "cmovg\t{$src2, $dst|$dst, $src2}",
1195 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1196 X86_COND_G, EFLAGS))]>,
1197 TB, OpSize;
1198def CMOVG32rm : I<0x4F, MRMSrcMem, // if >s, GR32 = [mem32]
1199 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1200 "cmovg\t{$src2, $dst|$dst, $src2}",
1201 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1202 X86_COND_G, EFLAGS))]>,
1203 TB;
1204def CMOVS16rm : I<0x48, MRMSrcMem, // if signed, GR16 = [mem16]
1205 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1206 "cmovs\t{$src2, $dst|$dst, $src2}",
1207 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1208 X86_COND_S, EFLAGS))]>,
1209 TB, OpSize;
1210def CMOVS32rm : I<0x48, MRMSrcMem, // if signed, GR32 = [mem32]
1211 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1212 "cmovs\t{$src2, $dst|$dst, $src2}",
1213 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1214 X86_COND_S, EFLAGS))]>,
1215 TB;
1216def CMOVNS16rm: I<0x49, MRMSrcMem, // if !signed, GR16 = [mem16]
1217 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1218 "cmovns\t{$src2, $dst|$dst, $src2}",
1219 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1220 X86_COND_NS, EFLAGS))]>,
1221 TB, OpSize;
1222def CMOVNS32rm: I<0x49, MRMSrcMem, // if !signed, GR32 = [mem32]
1223 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1224 "cmovns\t{$src2, $dst|$dst, $src2}",
1225 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1226 X86_COND_NS, EFLAGS))]>,
1227 TB;
1228def CMOVP16rm : I<0x4A, MRMSrcMem, // if parity, GR16 = [mem16]
1229 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1230 "cmovp\t{$src2, $dst|$dst, $src2}",
1231 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1232 X86_COND_P, EFLAGS))]>,
1233 TB, OpSize;
1234def CMOVP32rm : I<0x4A, MRMSrcMem, // if parity, GR32 = [mem32]
1235 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1236 "cmovp\t{$src2, $dst|$dst, $src2}",
1237 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1238 X86_COND_P, EFLAGS))]>,
1239 TB;
1240def CMOVNP16rm : I<0x4B, MRMSrcMem, // if !parity, GR16 = [mem16]
1241 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1242 "cmovnp\t{$src2, $dst|$dst, $src2}",
1243 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1244 X86_COND_NP, EFLAGS))]>,
1245 TB, OpSize;
Dan Gohman12fd4d72009-01-07 00:35:10 +00001246def CMOVNP32rm : I<0x4B, MRMSrcMem, // if !parity, GR32 = [mem32]
1247 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1248 "cmovnp\t{$src2, $dst|$dst, $src2}",
1249 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1250 X86_COND_NP, EFLAGS))]>,
1251 TB;
1252def CMOVO16rm : I<0x40, MRMSrcMem, // if overflow, GR16 = [mem16]
1253 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1254 "cmovo\t{$src2, $dst|$dst, $src2}",
1255 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1256 X86_COND_O, EFLAGS))]>,
1257 TB, OpSize;
1258def CMOVO32rm : I<0x40, MRMSrcMem, // if overflow, GR32 = [mem32]
1259 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1260 "cmovo\t{$src2, $dst|$dst, $src2}",
1261 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1262 X86_COND_O, EFLAGS))]>,
1263 TB;
1264def CMOVNO16rm : I<0x41, MRMSrcMem, // if !overflow, GR16 = [mem16]
1265 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1266 "cmovno\t{$src2, $dst|$dst, $src2}",
1267 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1268 X86_COND_NO, EFLAGS))]>,
1269 TB, OpSize;
1270def CMOVNO32rm : I<0x41, MRMSrcMem, // if !overflow, GR32 = [mem32]
1271 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1272 "cmovno\t{$src2, $dst|$dst, $src2}",
1273 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1274 X86_COND_NO, EFLAGS))]>,
1275 TB;
Evan Cheng950aac02007-09-25 01:57:46 +00001276} // Uses = [EFLAGS]
1277
1278
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001279// unary instructions
1280let CodeSize = 2 in {
Evan Cheng55687072007-09-14 21:48:26 +00001281let Defs = [EFLAGS] in {
Dan Gohman91888f02007-07-31 20:11:57 +00001282def NEG8r : I<0xF6, MRM3r, (outs GR8 :$dst), (ins GR8 :$src), "neg{b}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001283 [(set GR8:$dst, (ineg GR8:$src)),
1284 (implicit EFLAGS)]>;
Dan Gohman91888f02007-07-31 20:11:57 +00001285def NEG16r : I<0xF7, MRM3r, (outs GR16:$dst), (ins GR16:$src), "neg{w}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001286 [(set GR16:$dst, (ineg GR16:$src)),
1287 (implicit EFLAGS)]>, OpSize;
Dan Gohman91888f02007-07-31 20:11:57 +00001288def NEG32r : I<0xF7, MRM3r, (outs GR32:$dst), (ins GR32:$src), "neg{l}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001289 [(set GR32:$dst, (ineg GR32:$src)),
1290 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001291let isTwoAddress = 0 in {
Dan Gohman91888f02007-07-31 20:11:57 +00001292 def NEG8m : I<0xF6, MRM3m, (outs), (ins i8mem :$dst), "neg{b}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001293 [(store (ineg (loadi8 addr:$dst)), addr:$dst),
1294 (implicit EFLAGS)]>;
Dan Gohman91888f02007-07-31 20:11:57 +00001295 def NEG16m : I<0xF7, MRM3m, (outs), (ins i16mem:$dst), "neg{w}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001296 [(store (ineg (loadi16 addr:$dst)), addr:$dst),
1297 (implicit EFLAGS)]>, OpSize;
Dan Gohman91888f02007-07-31 20:11:57 +00001298 def NEG32m : I<0xF7, MRM3m, (outs), (ins i32mem:$dst), "neg{l}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001299 [(store (ineg (loadi32 addr:$dst)), addr:$dst),
1300 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001301}
Evan Cheng55687072007-09-14 21:48:26 +00001302} // Defs = [EFLAGS]
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001303
Evan Chengc6cee682009-01-21 02:09:05 +00001304// Match xor -1 to not. Favors these over a move imm + xor to save code size.
1305let AddedComplexity = 15 in {
Dan Gohman91888f02007-07-31 20:11:57 +00001306def NOT8r : I<0xF6, MRM2r, (outs GR8 :$dst), (ins GR8 :$src), "not{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001307 [(set GR8:$dst, (not GR8:$src))]>;
Dan Gohman91888f02007-07-31 20:11:57 +00001308def NOT16r : I<0xF7, MRM2r, (outs GR16:$dst), (ins GR16:$src), "not{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001309 [(set GR16:$dst, (not GR16:$src))]>, OpSize;
Dan Gohman91888f02007-07-31 20:11:57 +00001310def NOT32r : I<0xF7, MRM2r, (outs GR32:$dst), (ins GR32:$src), "not{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001311 [(set GR32:$dst, (not GR32:$src))]>;
Evan Chengc6cee682009-01-21 02:09:05 +00001312}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001313let isTwoAddress = 0 in {
Dan Gohman91888f02007-07-31 20:11:57 +00001314 def NOT8m : I<0xF6, MRM2m, (outs), (ins i8mem :$dst), "not{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001315 [(store (not (loadi8 addr:$dst)), addr:$dst)]>;
Dan Gohman91888f02007-07-31 20:11:57 +00001316 def NOT16m : I<0xF7, MRM2m, (outs), (ins i16mem:$dst), "not{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001317 [(store (not (loadi16 addr:$dst)), addr:$dst)]>, OpSize;
Dan Gohman91888f02007-07-31 20:11:57 +00001318 def NOT32m : I<0xF7, MRM2m, (outs), (ins i32mem:$dst), "not{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001319 [(store (not (loadi32 addr:$dst)), addr:$dst)]>;
1320}
1321} // CodeSize
1322
1323// TODO: inc/dec is slow for P4, but fast for Pentium-M.
Evan Cheng55687072007-09-14 21:48:26 +00001324let Defs = [EFLAGS] in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001325let CodeSize = 2 in
Dan Gohman91888f02007-07-31 20:11:57 +00001326def INC8r : I<0xFE, MRM0r, (outs GR8 :$dst), (ins GR8 :$src), "inc{b}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001327 [(set GR8:$dst, (add GR8:$src, 1)),
1328 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001329let isConvertibleToThreeAddress = 1, CodeSize = 1 in { // Can xform into LEA.
Dan Gohman91888f02007-07-31 20:11:57 +00001330def INC16r : I<0x40, AddRegFrm, (outs GR16:$dst), (ins GR16:$src), "inc{w}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001331 [(set GR16:$dst, (add GR16:$src, 1)),
1332 (implicit EFLAGS)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001333 OpSize, Requires<[In32BitMode]>;
Dan Gohman91888f02007-07-31 20:11:57 +00001334def INC32r : I<0x40, AddRegFrm, (outs GR32:$dst), (ins GR32:$src), "inc{l}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001335 [(set GR32:$dst, (add GR32:$src, 1)),
1336 (implicit EFLAGS)]>, Requires<[In32BitMode]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001337}
1338let isTwoAddress = 0, CodeSize = 2 in {
Dan Gohman91888f02007-07-31 20:11:57 +00001339 def INC8m : I<0xFE, MRM0m, (outs), (ins i8mem :$dst), "inc{b}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001340 [(store (add (loadi8 addr:$dst), 1), addr:$dst),
1341 (implicit EFLAGS)]>;
Dan Gohman91888f02007-07-31 20:11:57 +00001342 def INC16m : I<0xFF, MRM0m, (outs), (ins i16mem:$dst), "inc{w}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001343 [(store (add (loadi16 addr:$dst), 1), addr:$dst),
1344 (implicit EFLAGS)]>,
Evan Cheng4a7e72f2007-10-19 21:23:22 +00001345 OpSize, Requires<[In32BitMode]>;
Dan Gohman91888f02007-07-31 20:11:57 +00001346 def INC32m : I<0xFF, MRM0m, (outs), (ins i32mem:$dst), "inc{l}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001347 [(store (add (loadi32 addr:$dst), 1), addr:$dst),
1348 (implicit EFLAGS)]>,
Evan Cheng4a7e72f2007-10-19 21:23:22 +00001349 Requires<[In32BitMode]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001350}
1351
1352let CodeSize = 2 in
Dan Gohman91888f02007-07-31 20:11:57 +00001353def DEC8r : I<0xFE, MRM1r, (outs GR8 :$dst), (ins GR8 :$src), "dec{b}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001354 [(set GR8:$dst, (add GR8:$src, -1)),
1355 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001356let isConvertibleToThreeAddress = 1, CodeSize = 1 in { // Can xform into LEA.
Dan Gohman91888f02007-07-31 20:11:57 +00001357def DEC16r : I<0x48, AddRegFrm, (outs GR16:$dst), (ins GR16:$src), "dec{w}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001358 [(set GR16:$dst, (add GR16:$src, -1)),
1359 (implicit EFLAGS)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001360 OpSize, Requires<[In32BitMode]>;
Dan Gohman91888f02007-07-31 20:11:57 +00001361def DEC32r : I<0x48, AddRegFrm, (outs GR32:$dst), (ins GR32:$src), "dec{l}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001362 [(set GR32:$dst, (add GR32:$src, -1)),
1363 (implicit EFLAGS)]>, Requires<[In32BitMode]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001364}
1365
1366let isTwoAddress = 0, CodeSize = 2 in {
Dan Gohman91888f02007-07-31 20:11:57 +00001367 def DEC8m : I<0xFE, MRM1m, (outs), (ins i8mem :$dst), "dec{b}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001368 [(store (add (loadi8 addr:$dst), -1), addr:$dst),
1369 (implicit EFLAGS)]>;
Dan Gohman91888f02007-07-31 20:11:57 +00001370 def DEC16m : I<0xFF, MRM1m, (outs), (ins i16mem:$dst), "dec{w}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001371 [(store (add (loadi16 addr:$dst), -1), addr:$dst),
1372 (implicit EFLAGS)]>,
Evan Cheng4a7e72f2007-10-19 21:23:22 +00001373 OpSize, Requires<[In32BitMode]>;
Dan Gohman91888f02007-07-31 20:11:57 +00001374 def DEC32m : I<0xFF, MRM1m, (outs), (ins i32mem:$dst), "dec{l}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001375 [(store (add (loadi32 addr:$dst), -1), addr:$dst),
1376 (implicit EFLAGS)]>,
Evan Cheng4a7e72f2007-10-19 21:23:22 +00001377 Requires<[In32BitMode]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001378}
Evan Cheng55687072007-09-14 21:48:26 +00001379} // Defs = [EFLAGS]
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001380
1381// Logical operators...
Evan Cheng55687072007-09-14 21:48:26 +00001382let Defs = [EFLAGS] in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001383let isCommutable = 1 in { // X = AND Y, Z --> X = AND Z, Y
1384def AND8rr : I<0x20, MRMDestReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001385 (outs GR8 :$dst), (ins GR8 :$src1, GR8 :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001386 "and{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001387 [(set GR8:$dst, (and GR8:$src1, GR8:$src2)),
1388 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001389def AND16rr : I<0x21, MRMDestReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001390 (outs GR16:$dst), (ins GR16:$src1, GR16:$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, GR16:$src2)),
1393 (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001394def AND32rr : I<0x21, MRMDestReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001395 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001396 "and{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001397 [(set GR32:$dst, (and GR32:$src1, GR32:$src2)),
1398 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001399}
1400
1401def AND8rm : I<0x22, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001402 (outs GR8 :$dst), (ins GR8 :$src1, i8mem :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001403 "and{b}\t{$src2, $dst|$dst, $src2}",
Chris Lattner12208612009-04-10 00:16:23 +00001404 [(set GR8:$dst, (and GR8:$src1, (loadi8 addr:$src2))),
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001405 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001406def AND16rm : I<0x23, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001407 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001408 "and{w}\t{$src2, $dst|$dst, $src2}",
Chris Lattner12208612009-04-10 00:16:23 +00001409 [(set GR16:$dst, (and GR16:$src1, (loadi16 addr:$src2))),
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001410 (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001411def AND32rm : I<0x23, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001412 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001413 "and{l}\t{$src2, $dst|$dst, $src2}",
Chris Lattner12208612009-04-10 00:16:23 +00001414 [(set GR32:$dst, (and GR32:$src1, (loadi32 addr:$src2))),
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001415 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001416
1417def AND8ri : Ii8<0x80, MRM4r,
Evan Chengb783fa32007-07-19 01:14:50 +00001418 (outs GR8 :$dst), (ins GR8 :$src1, i8imm :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001419 "and{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001420 [(set GR8:$dst, (and GR8:$src1, imm:$src2)),
1421 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001422def AND16ri : Ii16<0x81, MRM4r,
Evan Chengb783fa32007-07-19 01:14:50 +00001423 (outs GR16:$dst), (ins GR16:$src1, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001424 "and{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001425 [(set GR16:$dst, (and GR16:$src1, imm:$src2)),
1426 (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001427def AND32ri : Ii32<0x81, MRM4r,
Evan Chengb783fa32007-07-19 01:14:50 +00001428 (outs GR32:$dst), (ins GR32:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001429 "and{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001430 [(set GR32:$dst, (and GR32:$src1, imm:$src2)),
1431 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001432def AND16ri8 : Ii8<0x83, MRM4r,
Evan Chengb783fa32007-07-19 01:14:50 +00001433 (outs GR16:$dst), (ins GR16:$src1, i16i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001434 "and{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001435 [(set GR16:$dst, (and GR16:$src1, i16immSExt8:$src2)),
1436 (implicit EFLAGS)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001437 OpSize;
1438def AND32ri8 : Ii8<0x83, MRM4r,
Evan Chengb783fa32007-07-19 01:14:50 +00001439 (outs GR32:$dst), (ins GR32:$src1, i32i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001440 "and{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001441 [(set GR32:$dst, (and GR32:$src1, i32immSExt8:$src2)),
1442 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001443
1444let isTwoAddress = 0 in {
1445 def AND8mr : I<0x20, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001446 (outs), (ins i8mem :$dst, GR8 :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001447 "and{b}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001448 [(store (and (load addr:$dst), GR8:$src), addr:$dst),
1449 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001450 def AND16mr : I<0x21, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001451 (outs), (ins i16mem:$dst, GR16:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001452 "and{w}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001453 [(store (and (load addr:$dst), GR16:$src), addr:$dst),
1454 (implicit EFLAGS)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001455 OpSize;
1456 def AND32mr : I<0x21, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001457 (outs), (ins i32mem:$dst, GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001458 "and{l}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001459 [(store (and (load addr:$dst), GR32:$src), addr:$dst),
1460 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001461 def AND8mi : Ii8<0x80, MRM4m,
Evan Chengb783fa32007-07-19 01:14:50 +00001462 (outs), (ins i8mem :$dst, i8imm :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001463 "and{b}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001464 [(store (and (loadi8 addr:$dst), imm:$src), addr:$dst),
1465 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001466 def AND16mi : Ii16<0x81, MRM4m,
Evan Chengb783fa32007-07-19 01:14:50 +00001467 (outs), (ins i16mem:$dst, i16imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001468 "and{w}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001469 [(store (and (loadi16 addr:$dst), imm:$src), addr:$dst),
1470 (implicit EFLAGS)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001471 OpSize;
1472 def AND32mi : Ii32<0x81, MRM4m,
Evan Chengb783fa32007-07-19 01:14:50 +00001473 (outs), (ins i32mem:$dst, i32imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001474 "and{l}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001475 [(store (and (loadi32 addr:$dst), imm:$src), addr:$dst),
1476 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001477 def AND16mi8 : Ii8<0x83, MRM4m,
Evan Chengb783fa32007-07-19 01:14:50 +00001478 (outs), (ins i16mem:$dst, i16i8imm :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001479 "and{w}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001480 [(store (and (load addr:$dst), i16immSExt8:$src), addr:$dst),
1481 (implicit EFLAGS)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001482 OpSize;
1483 def AND32mi8 : Ii8<0x83, MRM4m,
Evan Chengb783fa32007-07-19 01:14:50 +00001484 (outs), (ins i32mem:$dst, i32i8imm :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001485 "and{l}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001486 [(store (and (load addr:$dst), i32immSExt8:$src), addr:$dst),
1487 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001488}
1489
1490
1491let isCommutable = 1 in { // X = OR Y, Z --> X = OR Z, Y
Evan Chengb783fa32007-07-19 01:14:50 +00001492def OR8rr : I<0x08, MRMDestReg, (outs GR8 :$dst), (ins GR8 :$src1, GR8 :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001493 "or{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001494 [(set GR8:$dst, (or GR8:$src1, GR8:$src2)),
1495 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001496def OR16rr : I<0x09, MRMDestReg, (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001497 "or{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001498 [(set GR16:$dst, (or GR16:$src1, GR16:$src2)),
1499 (implicit EFLAGS)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001500def OR32rr : I<0x09, MRMDestReg, (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001501 "or{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001502 [(set GR32:$dst, (or GR32:$src1, GR32:$src2)),
1503 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001504}
Evan Chengb783fa32007-07-19 01:14:50 +00001505def OR8rm : I<0x0A, MRMSrcMem , (outs GR8 :$dst), (ins GR8 :$src1, i8mem :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001506 "or{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001507 [(set GR8:$dst, (or GR8:$src1, (load addr:$src2))),
1508 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001509def OR16rm : I<0x0B, MRMSrcMem , (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001510 "or{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001511 [(set GR16:$dst, (or GR16:$src1, (load addr:$src2))),
1512 (implicit EFLAGS)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001513def OR32rm : I<0x0B, MRMSrcMem , (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001514 "or{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001515 [(set GR32:$dst, (or GR32:$src1, (load addr:$src2))),
1516 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001517
Evan Chengb783fa32007-07-19 01:14:50 +00001518def OR8ri : Ii8 <0x80, MRM1r, (outs GR8 :$dst), (ins GR8 :$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001519 "or{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001520 [(set GR8:$dst, (or GR8:$src1, imm:$src2)),
1521 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001522def OR16ri : Ii16<0x81, MRM1r, (outs GR16:$dst), (ins GR16:$src1, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001523 "or{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001524 [(set GR16:$dst, (or GR16:$src1, imm:$src2)),
1525 (implicit EFLAGS)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001526def OR32ri : Ii32<0x81, MRM1r, (outs GR32:$dst), (ins GR32:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001527 "or{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001528 [(set GR32:$dst, (or GR32:$src1, imm:$src2)),
1529 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001530
Evan Chengb783fa32007-07-19 01:14:50 +00001531def OR16ri8 : Ii8<0x83, MRM1r, (outs GR16:$dst), (ins GR16:$src1, i16i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001532 "or{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001533 [(set GR16:$dst, (or GR16:$src1, i16immSExt8:$src2)),
1534 (implicit EFLAGS)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001535def OR32ri8 : Ii8<0x83, MRM1r, (outs GR32:$dst), (ins GR32:$src1, i32i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001536 "or{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001537 [(set GR32:$dst, (or GR32:$src1, i32immSExt8:$src2)),
1538 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001539let isTwoAddress = 0 in {
Evan Chengb783fa32007-07-19 01:14:50 +00001540 def OR8mr : I<0x08, MRMDestMem, (outs), (ins i8mem:$dst, GR8:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001541 "or{b}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001542 [(store (or (load addr:$dst), GR8:$src), addr:$dst),
1543 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001544 def OR16mr : I<0x09, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001545 "or{w}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001546 [(store (or (load addr:$dst), GR16:$src), addr:$dst),
1547 (implicit EFLAGS)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001548 def OR32mr : I<0x09, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001549 "or{l}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001550 [(store (or (load addr:$dst), GR32:$src), addr:$dst),
1551 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001552 def OR8mi : Ii8<0x80, MRM1m, (outs), (ins i8mem :$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001553 "or{b}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001554 [(store (or (loadi8 addr:$dst), imm:$src), addr:$dst),
1555 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001556 def OR16mi : Ii16<0x81, MRM1m, (outs), (ins i16mem:$dst, i16imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001557 "or{w}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001558 [(store (or (loadi16 addr:$dst), imm:$src), addr:$dst),
1559 (implicit EFLAGS)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001560 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001561 def OR32mi : Ii32<0x81, MRM1m, (outs), (ins i32mem:$dst, i32imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001562 "or{l}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001563 [(store (or (loadi32 addr:$dst), imm:$src), addr:$dst),
1564 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001565 def OR16mi8 : Ii8<0x83, MRM1m, (outs), (ins i16mem:$dst, i16i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001566 "or{w}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001567 [(store (or (load addr:$dst), i16immSExt8:$src), addr:$dst),
1568 (implicit EFLAGS)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001569 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001570 def OR32mi8 : Ii8<0x83, MRM1m, (outs), (ins i32mem:$dst, i32i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001571 "or{l}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001572 [(store (or (load addr:$dst), i32immSExt8:$src), addr:$dst),
1573 (implicit EFLAGS)]>;
Bill Wendlingba5d5b02008-05-29 01:02:09 +00001574} // isTwoAddress = 0
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001575
1576
Evan Cheng6f26e8b2008-06-18 08:13:07 +00001577let isCommutable = 1 in { // X = XOR Y, Z --> X = XOR Z, Y
Bill Wendlingba5d5b02008-05-29 01:02:09 +00001578 def XOR8rr : I<0x30, MRMDestReg,
1579 (outs GR8 :$dst), (ins GR8 :$src1, GR8 :$src2),
1580 "xor{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001581 [(set GR8:$dst, (xor GR8:$src1, GR8:$src2)),
1582 (implicit EFLAGS)]>;
Bill Wendlingba5d5b02008-05-29 01:02:09 +00001583 def XOR16rr : I<0x31, MRMDestReg,
1584 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
1585 "xor{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001586 [(set GR16:$dst, (xor GR16:$src1, GR16:$src2)),
1587 (implicit EFLAGS)]>, OpSize;
Bill Wendlingba5d5b02008-05-29 01:02:09 +00001588 def XOR32rr : I<0x31, MRMDestReg,
1589 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
1590 "xor{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001591 [(set GR32:$dst, (xor GR32:$src1, GR32:$src2)),
1592 (implicit EFLAGS)]>;
Evan Cheng6f26e8b2008-06-18 08:13:07 +00001593} // isCommutable = 1
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001594
1595def XOR8rm : I<0x32, MRMSrcMem ,
Evan Chengb783fa32007-07-19 01:14:50 +00001596 (outs GR8 :$dst), (ins GR8:$src1, i8mem :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001597 "xor{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001598 [(set GR8:$dst, (xor GR8:$src1, (load addr:$src2))),
1599 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001600def XOR16rm : I<0x33, MRMSrcMem ,
Evan Chengb783fa32007-07-19 01:14:50 +00001601 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001602 "xor{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001603 [(set GR16:$dst, (xor GR16:$src1, (load addr:$src2))),
1604 (implicit EFLAGS)]>,
Bill Wendlingba5d5b02008-05-29 01:02:09 +00001605 OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001606def XOR32rm : I<0x33, MRMSrcMem ,
Evan Chengb783fa32007-07-19 01:14:50 +00001607 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001608 "xor{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001609 [(set GR32:$dst, (xor GR32:$src1, (load addr:$src2))),
1610 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001611
Bill Wendlingbac38eb2008-05-29 03:46:36 +00001612def XOR8ri : Ii8<0x80, MRM6r,
1613 (outs GR8:$dst), (ins GR8:$src1, i8imm:$src2),
1614 "xor{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001615 [(set GR8:$dst, (xor GR8:$src1, imm:$src2)),
1616 (implicit EFLAGS)]>;
Bill Wendlingbac38eb2008-05-29 03:46:36 +00001617def XOR16ri : Ii16<0x81, MRM6r,
1618 (outs GR16:$dst), (ins GR16:$src1, i16imm:$src2),
1619 "xor{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001620 [(set GR16:$dst, (xor GR16:$src1, imm:$src2)),
1621 (implicit EFLAGS)]>, OpSize;
Bill Wendlingbac38eb2008-05-29 03:46:36 +00001622def XOR32ri : Ii32<0x81, MRM6r,
1623 (outs GR32:$dst), (ins GR32:$src1, i32imm:$src2),
1624 "xor{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001625 [(set GR32:$dst, (xor GR32:$src1, imm:$src2)),
1626 (implicit EFLAGS)]>;
Bill Wendlingbac38eb2008-05-29 03:46:36 +00001627def XOR16ri8 : Ii8<0x83, MRM6r,
1628 (outs GR16:$dst), (ins GR16:$src1, i16i8imm:$src2),
1629 "xor{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001630 [(set GR16:$dst, (xor GR16:$src1, i16immSExt8:$src2)),
1631 (implicit EFLAGS)]>,
Bill Wendlingbac38eb2008-05-29 03:46:36 +00001632 OpSize;
1633def XOR32ri8 : Ii8<0x83, MRM6r,
1634 (outs GR32:$dst), (ins GR32:$src1, i32i8imm:$src2),
1635 "xor{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001636 [(set GR32:$dst, (xor GR32:$src1, i32immSExt8:$src2)),
1637 (implicit EFLAGS)]>;
Bill Wendlingba5d5b02008-05-29 01:02:09 +00001638
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001639let isTwoAddress = 0 in {
1640 def XOR8mr : I<0x30, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001641 (outs), (ins i8mem :$dst, GR8 :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001642 "xor{b}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001643 [(store (xor (load addr:$dst), GR8:$src), addr:$dst),
1644 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001645 def XOR16mr : I<0x31, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001646 (outs), (ins i16mem:$dst, GR16:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001647 "xor{w}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001648 [(store (xor (load addr:$dst), GR16:$src), addr:$dst),
1649 (implicit EFLAGS)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001650 OpSize;
1651 def XOR32mr : I<0x31, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001652 (outs), (ins i32mem:$dst, GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001653 "xor{l}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001654 [(store (xor (load addr:$dst), GR32:$src), addr:$dst),
1655 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001656 def XOR8mi : Ii8<0x80, MRM6m,
Evan Chengb783fa32007-07-19 01:14:50 +00001657 (outs), (ins i8mem :$dst, i8imm :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001658 "xor{b}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001659 [(store (xor (loadi8 addr:$dst), imm:$src), addr:$dst),
1660 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001661 def XOR16mi : Ii16<0x81, MRM6m,
Evan Chengb783fa32007-07-19 01:14:50 +00001662 (outs), (ins i16mem:$dst, i16imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001663 "xor{w}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001664 [(store (xor (loadi16 addr:$dst), imm:$src), addr:$dst),
1665 (implicit EFLAGS)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001666 OpSize;
1667 def XOR32mi : Ii32<0x81, MRM6m,
Evan Chengb783fa32007-07-19 01:14:50 +00001668 (outs), (ins i32mem:$dst, i32imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001669 "xor{l}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001670 [(store (xor (loadi32 addr:$dst), imm:$src), addr:$dst),
1671 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001672 def XOR16mi8 : Ii8<0x83, MRM6m,
Evan Chengb783fa32007-07-19 01:14:50 +00001673 (outs), (ins i16mem:$dst, i16i8imm :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001674 "xor{w}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001675 [(store (xor (load addr:$dst), i16immSExt8:$src), addr:$dst),
1676 (implicit EFLAGS)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001677 OpSize;
1678 def XOR32mi8 : Ii8<0x83, MRM6m,
Evan Chengb783fa32007-07-19 01:14:50 +00001679 (outs), (ins i32mem:$dst, i32i8imm :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001680 "xor{l}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001681 [(store (xor (load addr:$dst), i32immSExt8:$src), addr:$dst),
1682 (implicit EFLAGS)]>;
Bill Wendlingba5d5b02008-05-29 01:02:09 +00001683} // isTwoAddress = 0
Evan Cheng55687072007-09-14 21:48:26 +00001684} // Defs = [EFLAGS]
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001685
1686// Shift instructions
Evan Cheng55687072007-09-14 21:48:26 +00001687let Defs = [EFLAGS] in {
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001688let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00001689def SHL8rCL : I<0xD2, MRM4r, (outs GR8 :$dst), (ins GR8 :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001690 "shl{b}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001691 [(set GR8:$dst, (shl GR8:$src, CL))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001692def SHL16rCL : I<0xD3, MRM4r, (outs GR16:$dst), (ins GR16:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001693 "shl{w}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001694 [(set GR16:$dst, (shl GR16:$src, CL))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001695def SHL32rCL : I<0xD3, MRM4r, (outs GR32:$dst), (ins GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001696 "shl{l}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001697 [(set GR32:$dst, (shl GR32:$src, CL))]>;
Bill Wendlingba5d5b02008-05-29 01:02:09 +00001698} // Uses = [CL]
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001699
Evan Chengb783fa32007-07-19 01:14:50 +00001700def SHL8ri : Ii8<0xC0, MRM4r, (outs GR8 :$dst), (ins GR8 :$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001701 "shl{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001702 [(set GR8:$dst, (shl GR8:$src1, (i8 imm:$src2)))]>;
1703let isConvertibleToThreeAddress = 1 in { // Can transform into LEA.
Evan Chengb783fa32007-07-19 01:14:50 +00001704def SHL16ri : Ii8<0xC1, MRM4r, (outs GR16:$dst), (ins GR16:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001705 "shl{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001706 [(set GR16:$dst, (shl GR16:$src1, (i8 imm:$src2)))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001707def SHL32ri : Ii8<0xC1, MRM4r, (outs GR32:$dst), (ins GR32:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001708 "shl{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001709 [(set GR32:$dst, (shl GR32:$src1, (i8 imm:$src2)))]>;
Chris Lattnerf4005a82008-01-11 18:00:50 +00001710// NOTE: We don't use shifts of a register by one, because 'add reg,reg' is
1711// cheaper.
Bill Wendlingba5d5b02008-05-29 01:02:09 +00001712} // isConvertibleToThreeAddress = 1
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001713
1714let isTwoAddress = 0 in {
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001715 let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00001716 def SHL8mCL : I<0xD2, MRM4m, (outs), (ins i8mem :$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001717 "shl{b}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001718 [(store (shl (loadi8 addr:$dst), CL), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001719 def SHL16mCL : I<0xD3, MRM4m, (outs), (ins i16mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001720 "shl{w}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001721 [(store (shl (loadi16 addr:$dst), CL), addr:$dst)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001722 def SHL32mCL : I<0xD3, MRM4m, (outs), (ins i32mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001723 "shl{l}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001724 [(store (shl (loadi32 addr:$dst), CL), addr:$dst)]>;
1725 }
Evan Chengb783fa32007-07-19 01:14:50 +00001726 def SHL8mi : Ii8<0xC0, MRM4m, (outs), (ins i8mem :$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001727 "shl{b}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001728 [(store (shl (loadi8 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001729 def SHL16mi : Ii8<0xC1, MRM4m, (outs), (ins i16mem:$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001730 "shl{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001731 [(store (shl (loadi16 addr:$dst), (i8 imm:$src)), addr:$dst)]>,
1732 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001733 def SHL32mi : Ii8<0xC1, MRM4m, (outs), (ins i32mem:$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001734 "shl{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001735 [(store (shl (loadi32 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
1736
1737 // Shift by 1
Evan Chengb783fa32007-07-19 01:14:50 +00001738 def SHL8m1 : I<0xD0, MRM4m, (outs), (ins i8mem :$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001739 "shl{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001740 [(store (shl (loadi8 addr:$dst), (i8 1)), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001741 def SHL16m1 : I<0xD1, MRM4m, (outs), (ins i16mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001742 "shl{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001743 [(store (shl (loadi16 addr:$dst), (i8 1)), addr:$dst)]>,
1744 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001745 def SHL32m1 : I<0xD1, MRM4m, (outs), (ins i32mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001746 "shl{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001747 [(store (shl (loadi32 addr:$dst), (i8 1)), addr:$dst)]>;
1748}
1749
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001750let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00001751def SHR8rCL : I<0xD2, MRM5r, (outs GR8 :$dst), (ins GR8 :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001752 "shr{b}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001753 [(set GR8:$dst, (srl GR8:$src, CL))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001754def SHR16rCL : I<0xD3, MRM5r, (outs GR16:$dst), (ins GR16:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001755 "shr{w}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001756 [(set GR16:$dst, (srl GR16:$src, CL))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001757def SHR32rCL : I<0xD3, MRM5r, (outs GR32:$dst), (ins GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001758 "shr{l}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001759 [(set GR32:$dst, (srl GR32:$src, CL))]>;
1760}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001761
Evan Chengb783fa32007-07-19 01:14:50 +00001762def SHR8ri : Ii8<0xC0, MRM5r, (outs GR8:$dst), (ins GR8:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001763 "shr{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001764 [(set GR8:$dst, (srl GR8:$src1, (i8 imm:$src2)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001765def SHR16ri : Ii8<0xC1, MRM5r, (outs GR16:$dst), (ins GR16:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001766 "shr{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001767 [(set GR16:$dst, (srl GR16:$src1, (i8 imm:$src2)))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001768def SHR32ri : Ii8<0xC1, MRM5r, (outs GR32:$dst), (ins GR32:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001769 "shr{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001770 [(set GR32:$dst, (srl GR32:$src1, (i8 imm:$src2)))]>;
1771
1772// Shift by 1
Evan Chengb783fa32007-07-19 01:14:50 +00001773def SHR8r1 : I<0xD0, MRM5r, (outs GR8:$dst), (ins GR8:$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00001774 "shr{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001775 [(set GR8:$dst, (srl GR8:$src1, (i8 1)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001776def SHR16r1 : I<0xD1, MRM5r, (outs GR16:$dst), (ins GR16:$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00001777 "shr{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001778 [(set GR16:$dst, (srl GR16:$src1, (i8 1)))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001779def SHR32r1 : I<0xD1, MRM5r, (outs GR32:$dst), (ins GR32:$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00001780 "shr{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001781 [(set GR32:$dst, (srl GR32:$src1, (i8 1)))]>;
1782
1783let isTwoAddress = 0 in {
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001784 let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00001785 def SHR8mCL : I<0xD2, MRM5m, (outs), (ins i8mem :$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001786 "shr{b}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001787 [(store (srl (loadi8 addr:$dst), CL), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001788 def SHR16mCL : I<0xD3, MRM5m, (outs), (ins i16mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001789 "shr{w}\t{%cl, $dst|$dst, %CL}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001790 [(store (srl (loadi16 addr:$dst), CL), addr:$dst)]>,
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001791 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001792 def SHR32mCL : I<0xD3, MRM5m, (outs), (ins i32mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001793 "shr{l}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001794 [(store (srl (loadi32 addr:$dst), CL), addr:$dst)]>;
1795 }
Evan Chengb783fa32007-07-19 01:14:50 +00001796 def SHR8mi : Ii8<0xC0, MRM5m, (outs), (ins i8mem :$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001797 "shr{b}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001798 [(store (srl (loadi8 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001799 def SHR16mi : Ii8<0xC1, MRM5m, (outs), (ins i16mem:$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001800 "shr{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001801 [(store (srl (loadi16 addr:$dst), (i8 imm:$src)), addr:$dst)]>,
1802 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001803 def SHR32mi : Ii8<0xC1, MRM5m, (outs), (ins i32mem:$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001804 "shr{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001805 [(store (srl (loadi32 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
1806
1807 // Shift by 1
Evan Chengb783fa32007-07-19 01:14:50 +00001808 def SHR8m1 : I<0xD0, MRM5m, (outs), (ins i8mem :$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001809 "shr{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001810 [(store (srl (loadi8 addr:$dst), (i8 1)), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001811 def SHR16m1 : I<0xD1, MRM5m, (outs), (ins i16mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001812 "shr{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001813 [(store (srl (loadi16 addr:$dst), (i8 1)), addr:$dst)]>,OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001814 def SHR32m1 : I<0xD1, MRM5m, (outs), (ins i32mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001815 "shr{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001816 [(store (srl (loadi32 addr:$dst), (i8 1)), addr:$dst)]>;
1817}
1818
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001819let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00001820def SAR8rCL : I<0xD2, MRM7r, (outs GR8 :$dst), (ins GR8 :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001821 "sar{b}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001822 [(set GR8:$dst, (sra GR8:$src, CL))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001823def SAR16rCL : I<0xD3, MRM7r, (outs GR16:$dst), (ins GR16:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001824 "sar{w}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001825 [(set GR16:$dst, (sra GR16:$src, CL))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001826def SAR32rCL : I<0xD3, MRM7r, (outs GR32:$dst), (ins GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001827 "sar{l}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001828 [(set GR32:$dst, (sra GR32:$src, CL))]>;
1829}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001830
Evan Chengb783fa32007-07-19 01:14:50 +00001831def SAR8ri : Ii8<0xC0, MRM7r, (outs GR8 :$dst), (ins GR8 :$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001832 "sar{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001833 [(set GR8:$dst, (sra GR8:$src1, (i8 imm:$src2)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001834def SAR16ri : Ii8<0xC1, MRM7r, (outs GR16:$dst), (ins GR16:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001835 "sar{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001836 [(set GR16:$dst, (sra GR16:$src1, (i8 imm:$src2)))]>,
1837 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001838def SAR32ri : Ii8<0xC1, MRM7r, (outs GR32:$dst), (ins GR32:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001839 "sar{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001840 [(set GR32:$dst, (sra GR32:$src1, (i8 imm:$src2)))]>;
1841
1842// Shift by 1
Evan Chengb783fa32007-07-19 01:14:50 +00001843def SAR8r1 : I<0xD0, MRM7r, (outs GR8 :$dst), (ins GR8 :$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00001844 "sar{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001845 [(set GR8:$dst, (sra GR8:$src1, (i8 1)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001846def SAR16r1 : I<0xD1, MRM7r, (outs GR16:$dst), (ins GR16:$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00001847 "sar{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001848 [(set GR16:$dst, (sra GR16:$src1, (i8 1)))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001849def SAR32r1 : I<0xD1, MRM7r, (outs GR32:$dst), (ins GR32:$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00001850 "sar{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001851 [(set GR32:$dst, (sra GR32:$src1, (i8 1)))]>;
1852
1853let isTwoAddress = 0 in {
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001854 let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00001855 def SAR8mCL : I<0xD2, MRM7m, (outs), (ins i8mem :$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001856 "sar{b}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001857 [(store (sra (loadi8 addr:$dst), CL), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001858 def SAR16mCL : I<0xD3, MRM7m, (outs), (ins i16mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001859 "sar{w}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001860 [(store (sra (loadi16 addr:$dst), CL), addr:$dst)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001861 def SAR32mCL : I<0xD3, MRM7m, (outs), (ins i32mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001862 "sar{l}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001863 [(store (sra (loadi32 addr:$dst), CL), addr:$dst)]>;
1864 }
Evan Chengb783fa32007-07-19 01:14:50 +00001865 def SAR8mi : Ii8<0xC0, MRM7m, (outs), (ins i8mem :$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001866 "sar{b}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001867 [(store (sra (loadi8 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001868 def SAR16mi : Ii8<0xC1, MRM7m, (outs), (ins i16mem:$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001869 "sar{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001870 [(store (sra (loadi16 addr:$dst), (i8 imm:$src)), addr:$dst)]>,
1871 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001872 def SAR32mi : Ii8<0xC1, MRM7m, (outs), (ins i32mem:$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001873 "sar{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001874 [(store (sra (loadi32 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
1875
1876 // Shift by 1
Evan Chengb783fa32007-07-19 01:14:50 +00001877 def SAR8m1 : I<0xD0, MRM7m, (outs), (ins i8mem :$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001878 "sar{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001879 [(store (sra (loadi8 addr:$dst), (i8 1)), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001880 def SAR16m1 : I<0xD1, MRM7m, (outs), (ins i16mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001881 "sar{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001882 [(store (sra (loadi16 addr:$dst), (i8 1)), addr:$dst)]>,
1883 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001884 def SAR32m1 : I<0xD1, MRM7m, (outs), (ins i32mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001885 "sar{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001886 [(store (sra (loadi32 addr:$dst), (i8 1)), addr:$dst)]>;
1887}
1888
1889// Rotate instructions
1890// FIXME: provide shorter instructions when imm8 == 1
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001891let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00001892def ROL8rCL : I<0xD2, MRM0r, (outs GR8 :$dst), (ins GR8 :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001893 "rol{b}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001894 [(set GR8:$dst, (rotl GR8:$src, CL))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001895def ROL16rCL : I<0xD3, MRM0r, (outs GR16:$dst), (ins GR16:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001896 "rol{w}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001897 [(set GR16:$dst, (rotl GR16:$src, CL))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001898def ROL32rCL : I<0xD3, MRM0r, (outs GR32:$dst), (ins GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001899 "rol{l}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001900 [(set GR32:$dst, (rotl GR32:$src, CL))]>;
1901}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001902
Evan Chengb783fa32007-07-19 01:14:50 +00001903def ROL8ri : Ii8<0xC0, MRM0r, (outs GR8 :$dst), (ins GR8 :$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001904 "rol{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001905 [(set GR8:$dst, (rotl GR8:$src1, (i8 imm:$src2)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001906def ROL16ri : Ii8<0xC1, MRM0r, (outs GR16:$dst), (ins GR16:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001907 "rol{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001908 [(set GR16:$dst, (rotl GR16:$src1, (i8 imm:$src2)))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001909def ROL32ri : Ii8<0xC1, MRM0r, (outs GR32:$dst), (ins GR32:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001910 "rol{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001911 [(set GR32:$dst, (rotl GR32:$src1, (i8 imm:$src2)))]>;
1912
1913// Rotate by 1
Evan Chengb783fa32007-07-19 01:14:50 +00001914def ROL8r1 : I<0xD0, MRM0r, (outs GR8 :$dst), (ins GR8 :$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00001915 "rol{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001916 [(set GR8:$dst, (rotl GR8:$src1, (i8 1)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001917def ROL16r1 : I<0xD1, MRM0r, (outs GR16:$dst), (ins GR16:$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00001918 "rol{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001919 [(set GR16:$dst, (rotl GR16:$src1, (i8 1)))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001920def ROL32r1 : I<0xD1, MRM0r, (outs GR32:$dst), (ins GR32:$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00001921 "rol{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001922 [(set GR32:$dst, (rotl GR32:$src1, (i8 1)))]>;
1923
1924let isTwoAddress = 0 in {
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001925 let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00001926 def ROL8mCL : I<0xD2, MRM0m, (outs), (ins i8mem :$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001927 "rol{b}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001928 [(store (rotl (loadi8 addr:$dst), CL), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001929 def ROL16mCL : I<0xD3, MRM0m, (outs), (ins i16mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001930 "rol{w}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001931 [(store (rotl (loadi16 addr:$dst), CL), addr:$dst)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001932 def ROL32mCL : I<0xD3, MRM0m, (outs), (ins i32mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001933 "rol{l}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001934 [(store (rotl (loadi32 addr:$dst), CL), addr:$dst)]>;
1935 }
Evan Chengb783fa32007-07-19 01:14:50 +00001936 def ROL8mi : Ii8<0xC0, MRM0m, (outs), (ins i8mem :$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001937 "rol{b}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001938 [(store (rotl (loadi8 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001939 def ROL16mi : Ii8<0xC1, MRM0m, (outs), (ins i16mem:$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001940 "rol{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001941 [(store (rotl (loadi16 addr:$dst), (i8 imm:$src)), addr:$dst)]>,
1942 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001943 def ROL32mi : Ii8<0xC1, MRM0m, (outs), (ins i32mem:$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001944 "rol{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001945 [(store (rotl (loadi32 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
1946
1947 // Rotate by 1
Evan Chengb783fa32007-07-19 01:14:50 +00001948 def ROL8m1 : I<0xD0, MRM0m, (outs), (ins i8mem :$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001949 "rol{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001950 [(store (rotl (loadi8 addr:$dst), (i8 1)), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001951 def ROL16m1 : I<0xD1, MRM0m, (outs), (ins i16mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001952 "rol{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001953 [(store (rotl (loadi16 addr:$dst), (i8 1)), addr:$dst)]>,
1954 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001955 def ROL32m1 : I<0xD1, MRM0m, (outs), (ins i32mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001956 "rol{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001957 [(store (rotl (loadi32 addr:$dst), (i8 1)), addr:$dst)]>;
1958}
1959
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001960let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00001961def ROR8rCL : I<0xD2, MRM1r, (outs GR8 :$dst), (ins GR8 :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001962 "ror{b}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001963 [(set GR8:$dst, (rotr GR8:$src, CL))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001964def ROR16rCL : I<0xD3, MRM1r, (outs GR16:$dst), (ins GR16:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001965 "ror{w}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001966 [(set GR16:$dst, (rotr GR16:$src, CL))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001967def ROR32rCL : I<0xD3, MRM1r, (outs GR32:$dst), (ins GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001968 "ror{l}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001969 [(set GR32:$dst, (rotr GR32:$src, CL))]>;
1970}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001971
Evan Chengb783fa32007-07-19 01:14:50 +00001972def ROR8ri : Ii8<0xC0, MRM1r, (outs GR8 :$dst), (ins GR8 :$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001973 "ror{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001974 [(set GR8:$dst, (rotr GR8:$src1, (i8 imm:$src2)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001975def ROR16ri : Ii8<0xC1, MRM1r, (outs GR16:$dst), (ins GR16:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001976 "ror{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001977 [(set GR16:$dst, (rotr GR16:$src1, (i8 imm:$src2)))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001978def ROR32ri : Ii8<0xC1, MRM1r, (outs GR32:$dst), (ins GR32:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001979 "ror{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001980 [(set GR32:$dst, (rotr GR32:$src1, (i8 imm:$src2)))]>;
1981
1982// Rotate by 1
Evan Chengb783fa32007-07-19 01:14:50 +00001983def ROR8r1 : I<0xD0, MRM1r, (outs GR8 :$dst), (ins GR8 :$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00001984 "ror{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001985 [(set GR8:$dst, (rotr GR8:$src1, (i8 1)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001986def ROR16r1 : I<0xD1, MRM1r, (outs GR16:$dst), (ins GR16:$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00001987 "ror{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001988 [(set GR16:$dst, (rotr GR16:$src1, (i8 1)))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001989def ROR32r1 : I<0xD1, MRM1r, (outs GR32:$dst), (ins GR32:$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00001990 "ror{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001991 [(set GR32:$dst, (rotr GR32:$src1, (i8 1)))]>;
1992
1993let isTwoAddress = 0 in {
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001994 let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00001995 def ROR8mCL : I<0xD2, MRM1m, (outs), (ins i8mem :$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001996 "ror{b}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001997 [(store (rotr (loadi8 addr:$dst), CL), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001998 def ROR16mCL : I<0xD3, MRM1m, (outs), (ins i16mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001999 "ror{w}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002000 [(store (rotr (loadi16 addr:$dst), CL), addr:$dst)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002001 def ROR32mCL : I<0xD3, MRM1m, (outs), (ins i32mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002002 "ror{l}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002003 [(store (rotr (loadi32 addr:$dst), CL), addr:$dst)]>;
2004 }
Evan Chengb783fa32007-07-19 01:14:50 +00002005 def ROR8mi : Ii8<0xC0, MRM1m, (outs), (ins i8mem :$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002006 "ror{b}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002007 [(store (rotr (loadi8 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002008 def ROR16mi : Ii8<0xC1, MRM1m, (outs), (ins i16mem:$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002009 "ror{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002010 [(store (rotr (loadi16 addr:$dst), (i8 imm:$src)), addr:$dst)]>,
2011 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002012 def ROR32mi : Ii8<0xC1, MRM1m, (outs), (ins i32mem:$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002013 "ror{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002014 [(store (rotr (loadi32 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
2015
2016 // Rotate by 1
Evan Chengb783fa32007-07-19 01:14:50 +00002017 def ROR8m1 : I<0xD0, MRM1m, (outs), (ins i8mem :$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002018 "ror{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002019 [(store (rotr (loadi8 addr:$dst), (i8 1)), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002020 def ROR16m1 : I<0xD1, MRM1m, (outs), (ins i16mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002021 "ror{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002022 [(store (rotr (loadi16 addr:$dst), (i8 1)), addr:$dst)]>,
2023 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002024 def ROR32m1 : I<0xD1, MRM1m, (outs), (ins i32mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002025 "ror{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002026 [(store (rotr (loadi32 addr:$dst), (i8 1)), addr:$dst)]>;
2027}
2028
2029
2030
2031// Double shift instructions (generalizations of rotate)
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002032let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00002033def SHLD32rrCL : I<0xA5, MRMDestReg, (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002034 "shld{l}\t{%cl, $src2, $dst|$dst, $src2, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002035 [(set GR32:$dst, (X86shld GR32:$src1, GR32:$src2, CL))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00002036def SHRD32rrCL : I<0xAD, MRMDestReg, (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002037 "shrd{l}\t{%cl, $src2, $dst|$dst, $src2, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002038 [(set GR32:$dst, (X86shrd GR32:$src1, GR32:$src2, CL))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00002039def SHLD16rrCL : I<0xA5, MRMDestReg, (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002040 "shld{w}\t{%cl, $src2, $dst|$dst, $src2, %CL}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002041 [(set GR16:$dst, (X86shld GR16:$src1, GR16:$src2, CL))]>,
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002042 TB, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002043def SHRD16rrCL : I<0xAD, MRMDestReg, (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002044 "shrd{w}\t{%cl, $src2, $dst|$dst, $src2, %CL}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002045 [(set GR16:$dst, (X86shrd GR16:$src1, GR16:$src2, CL))]>,
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002046 TB, OpSize;
2047}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002048
2049let isCommutable = 1 in { // These instructions commute to each other.
2050def SHLD32rri8 : Ii8<0xA4, MRMDestReg,
Evan Chengb783fa32007-07-19 01:14:50 +00002051 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2, i8imm:$src3),
Dan Gohman91888f02007-07-31 20:11:57 +00002052 "shld{l}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002053 [(set GR32:$dst, (X86shld GR32:$src1, GR32:$src2,
2054 (i8 imm:$src3)))]>,
2055 TB;
2056def SHRD32rri8 : Ii8<0xAC, MRMDestReg,
Evan Chengb783fa32007-07-19 01:14:50 +00002057 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2, i8imm:$src3),
Dan Gohman91888f02007-07-31 20:11:57 +00002058 "shrd{l}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002059 [(set GR32:$dst, (X86shrd GR32:$src1, GR32:$src2,
2060 (i8 imm:$src3)))]>,
2061 TB;
2062def SHLD16rri8 : Ii8<0xA4, MRMDestReg,
Evan Chengb783fa32007-07-19 01:14:50 +00002063 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2, i8imm:$src3),
Dan Gohman91888f02007-07-31 20:11:57 +00002064 "shld{w}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002065 [(set GR16:$dst, (X86shld GR16:$src1, GR16:$src2,
2066 (i8 imm:$src3)))]>,
2067 TB, OpSize;
2068def SHRD16rri8 : Ii8<0xAC, MRMDestReg,
Evan Chengb783fa32007-07-19 01:14:50 +00002069 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2, i8imm:$src3),
Dan Gohman91888f02007-07-31 20:11:57 +00002070 "shrd{w}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002071 [(set GR16:$dst, (X86shrd GR16:$src1, GR16:$src2,
2072 (i8 imm:$src3)))]>,
2073 TB, OpSize;
2074}
2075
2076let isTwoAddress = 0 in {
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002077 let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00002078 def SHLD32mrCL : I<0xA5, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002079 "shld{l}\t{%cl, $src2, $dst|$dst, $src2, %CL}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002080 [(store (X86shld (loadi32 addr:$dst), GR32:$src2, CL),
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002081 addr:$dst)]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00002082 def SHRD32mrCL : I<0xAD, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002083 "shrd{l}\t{%cl, $src2, $dst|$dst, $src2, %CL}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002084 [(store (X86shrd (loadi32 addr:$dst), GR32:$src2, CL),
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002085 addr:$dst)]>, TB;
2086 }
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002087 def SHLD32mri8 : Ii8<0xA4, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00002088 (outs), (ins i32mem:$dst, GR32:$src2, i8imm:$src3),
Dan Gohman91888f02007-07-31 20:11:57 +00002089 "shld{l}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002090 [(store (X86shld (loadi32 addr:$dst), GR32:$src2,
2091 (i8 imm:$src3)), addr:$dst)]>,
2092 TB;
2093 def SHRD32mri8 : Ii8<0xAC, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00002094 (outs), (ins i32mem:$dst, GR32:$src2, i8imm:$src3),
Dan Gohman91888f02007-07-31 20:11:57 +00002095 "shrd{l}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002096 [(store (X86shrd (loadi32 addr:$dst), GR32:$src2,
2097 (i8 imm:$src3)), addr:$dst)]>,
2098 TB;
2099
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002100 let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00002101 def SHLD16mrCL : I<0xA5, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002102 "shld{w}\t{%cl, $src2, $dst|$dst, $src2, %CL}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002103 [(store (X86shld (loadi16 addr:$dst), GR16:$src2, CL),
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002104 addr:$dst)]>, TB, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002105 def SHRD16mrCL : I<0xAD, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002106 "shrd{w}\t{%cl, $src2, $dst|$dst, $src2, %CL}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002107 [(store (X86shrd (loadi16 addr:$dst), GR16:$src2, CL),
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002108 addr:$dst)]>, TB, OpSize;
2109 }
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002110 def SHLD16mri8 : Ii8<0xA4, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00002111 (outs), (ins i16mem:$dst, GR16:$src2, i8imm:$src3),
Dan Gohman91888f02007-07-31 20:11:57 +00002112 "shld{w}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002113 [(store (X86shld (loadi16 addr:$dst), GR16:$src2,
2114 (i8 imm:$src3)), addr:$dst)]>,
2115 TB, OpSize;
2116 def SHRD16mri8 : Ii8<0xAC, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00002117 (outs), (ins i16mem:$dst, GR16:$src2, i8imm:$src3),
Dan Gohman91888f02007-07-31 20:11:57 +00002118 "shrd{w}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002119 [(store (X86shrd (loadi16 addr:$dst), GR16:$src2,
2120 (i8 imm:$src3)), addr:$dst)]>,
2121 TB, OpSize;
2122}
Evan Cheng55687072007-09-14 21:48:26 +00002123} // Defs = [EFLAGS]
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002124
2125
2126// Arithmetic.
Evan Cheng55687072007-09-14 21:48:26 +00002127let Defs = [EFLAGS] in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002128let isCommutable = 1 in { // X = ADD Y, Z --> X = ADD Z, Y
Bill Wendlingae034ed2008-12-12 00:56:36 +00002129// Register-Register Addition
2130def ADD8rr : I<0x00, MRMDestReg, (outs GR8 :$dst),
2131 (ins GR8 :$src1, GR8 :$src2),
2132 "add{b}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002133 [(set GR8:$dst, (add GR8:$src1, GR8:$src2)),
Bill Wendlingae034ed2008-12-12 00:56:36 +00002134 (implicit EFLAGS)]>;
2135
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002136let isConvertibleToThreeAddress = 1 in { // Can transform into LEA.
Bill Wendlingae034ed2008-12-12 00:56:36 +00002137// Register-Register Addition
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002138def ADD16rr : I<0x01, MRMDestReg, (outs GR16:$dst),
2139 (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002140 "add{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002141 [(set GR16:$dst, (add GR16:$src1, GR16:$src2)),
2142 (implicit EFLAGS)]>, OpSize;
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002143def ADD32rr : I<0x01, MRMDestReg, (outs GR32:$dst),
2144 (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002145 "add{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002146 [(set GR32:$dst, (add GR32:$src1, GR32:$src2)),
2147 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002148} // end isConvertibleToThreeAddress
2149} // end isCommutable
Bill Wendlingae034ed2008-12-12 00:56:36 +00002150
2151// Register-Memory Addition
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002152def ADD8rm : I<0x02, MRMSrcMem, (outs GR8 :$dst),
2153 (ins GR8 :$src1, i8mem :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002154 "add{b}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002155 [(set GR8:$dst, (add GR8:$src1, (load addr:$src2))),
2156 (implicit EFLAGS)]>;
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002157def ADD16rm : I<0x03, MRMSrcMem, (outs GR16:$dst),
2158 (ins GR16:$src1, i16mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002159 "add{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002160 [(set GR16:$dst, (add GR16:$src1, (load addr:$src2))),
2161 (implicit EFLAGS)]>, OpSize;
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002162def ADD32rm : I<0x03, MRMSrcMem, (outs GR32:$dst),
2163 (ins GR32:$src1, i32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002164 "add{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002165 [(set GR32:$dst, (add GR32:$src1, (load addr:$src2))),
2166 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002167
Bill Wendlingae034ed2008-12-12 00:56:36 +00002168// Register-Integer Addition
2169def ADD8ri : Ii8<0x80, MRM0r, (outs GR8:$dst), (ins GR8:$src1, i8imm:$src2),
2170 "add{b}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002171 [(set GR8:$dst, (add GR8:$src1, imm:$src2)),
2172 (implicit EFLAGS)]>;
Bill Wendlingae034ed2008-12-12 00:56:36 +00002173
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002174let isConvertibleToThreeAddress = 1 in { // Can transform into LEA.
Bill Wendlingae034ed2008-12-12 00:56:36 +00002175// Register-Integer Addition
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002176def ADD16ri : Ii16<0x81, MRM0r, (outs GR16:$dst),
2177 (ins GR16:$src1, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002178 "add{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002179 [(set GR16:$dst, (add GR16:$src1, imm:$src2)),
2180 (implicit EFLAGS)]>, OpSize;
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002181def ADD32ri : Ii32<0x81, MRM0r, (outs GR32:$dst),
2182 (ins GR32:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002183 "add{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002184 [(set GR32:$dst, (add GR32:$src1, imm:$src2)),
2185 (implicit EFLAGS)]>;
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002186def ADD16ri8 : Ii8<0x83, MRM0r, (outs GR16:$dst),
2187 (ins GR16:$src1, i16i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002188 "add{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002189 [(set GR16:$dst, (add GR16:$src1, i16immSExt8:$src2)),
2190 (implicit EFLAGS)]>, OpSize;
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002191def ADD32ri8 : Ii8<0x83, MRM0r, (outs GR32:$dst),
2192 (ins GR32:$src1, i32i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002193 "add{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002194 [(set GR32:$dst, (add GR32:$src1, i32immSExt8:$src2)),
2195 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002196}
2197
2198let isTwoAddress = 0 in {
Bill Wendlingae034ed2008-12-12 00:56:36 +00002199 // Memory-Register Addition
Bill Wendlingf5399032008-12-12 21:15:41 +00002200 def ADD8mr : I<0x00, MRMDestMem, (outs), (ins i8mem:$dst, GR8:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002201 "add{b}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002202 [(store (add (load addr:$dst), GR8:$src2), addr:$dst),
2203 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002204 def ADD16mr : I<0x01, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002205 "add{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002206 [(store (add (load addr:$dst), GR16:$src2), addr:$dst),
2207 (implicit EFLAGS)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002208 def ADD32mr : I<0x01, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002209 "add{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002210 [(store (add (load addr:$dst), GR32:$src2), addr:$dst),
2211 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002212 def ADD8mi : Ii8<0x80, MRM0m, (outs), (ins i8mem :$dst, i8imm :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002213 "add{b}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002214 [(store (add (loadi8 addr:$dst), imm:$src2), addr:$dst),
2215 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002216 def ADD16mi : Ii16<0x81, MRM0m, (outs), (ins i16mem:$dst, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002217 "add{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002218 [(store (add (loadi16 addr:$dst), imm:$src2), addr:$dst),
2219 (implicit EFLAGS)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002220 def ADD32mi : Ii32<0x81, MRM0m, (outs), (ins i32mem:$dst, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002221 "add{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002222 [(store (add (loadi32 addr:$dst), imm:$src2), addr:$dst),
2223 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002224 def ADD16mi8 : Ii8<0x83, MRM0m, (outs), (ins i16mem:$dst, i16i8imm :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002225 "add{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002226 [(store (add (load addr:$dst), i16immSExt8:$src2),
2227 addr:$dst),
2228 (implicit EFLAGS)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002229 def ADD32mi8 : Ii8<0x83, MRM0m, (outs), (ins i32mem:$dst, i32i8imm :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002230 "add{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingae034ed2008-12-12 00:56:36 +00002231 [(store (add (load addr:$dst), i32immSExt8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00002232 addr:$dst),
2233 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002234}
2235
Evan Cheng259471d2007-10-05 17:59:57 +00002236let Uses = [EFLAGS] in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002237let isCommutable = 1 in { // X = ADC Y, Z --> X = ADC Z, Y
Evan Chengb783fa32007-07-19 01:14:50 +00002238def ADC32rr : I<0x11, MRMDestReg, (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002239 "adc{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingc0ca7f32008-12-01 23:44:08 +00002240 [(set GR32:$dst, (adde GR32:$src1, GR32:$src2))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002241}
Evan Chengb783fa32007-07-19 01:14:50 +00002242def ADC32rm : I<0x13, MRMSrcMem , (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002243 "adc{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingc0ca7f32008-12-01 23:44:08 +00002244 [(set GR32:$dst, (adde GR32:$src1, (load addr:$src2)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002245def ADC32ri : Ii32<0x81, MRM2r, (outs GR32:$dst), (ins GR32:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002246 "adc{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingc0ca7f32008-12-01 23:44:08 +00002247 [(set GR32:$dst, (adde GR32:$src1, imm:$src2))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002248def ADC32ri8 : Ii8<0x83, MRM2r, (outs GR32:$dst), (ins GR32:$src1, i32i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002249 "adc{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingc0ca7f32008-12-01 23:44:08 +00002250 [(set GR32:$dst, (adde GR32:$src1, i32immSExt8:$src2))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002251
2252let isTwoAddress = 0 in {
Evan Chengb783fa32007-07-19 01:14:50 +00002253 def ADC32mr : I<0x11, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002254 "adc{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingc0ca7f32008-12-01 23:44:08 +00002255 [(store (adde (load addr:$dst), GR32:$src2), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002256 def ADC32mi : Ii32<0x81, MRM2m, (outs), (ins i32mem:$dst, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002257 "adc{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingc0ca7f32008-12-01 23:44:08 +00002258 [(store (adde (loadi32 addr:$dst), imm:$src2), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002259 def ADC32mi8 : Ii8<0x83, MRM2m, (outs), (ins i32mem:$dst, i32i8imm :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002260 "adc{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendling0c52d0a2008-12-02 00:07:05 +00002261 [(store (adde (load addr:$dst), i32immSExt8:$src2), addr:$dst)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002262}
Evan Cheng259471d2007-10-05 17:59:57 +00002263} // Uses = [EFLAGS]
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002264
Bill Wendlingae034ed2008-12-12 00:56:36 +00002265// Register-Register Subtraction
2266def SUB8rr : I<0x28, MRMDestReg, (outs GR8:$dst), (ins GR8:$src1, GR8:$src2),
2267 "sub{b}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002268 [(set GR8:$dst, (sub GR8:$src1, GR8:$src2)),
2269 (implicit EFLAGS)]>;
Bill Wendlingae034ed2008-12-12 00:56:36 +00002270def SUB16rr : I<0x29, MRMDestReg, (outs GR16:$dst), (ins GR16:$src1,GR16:$src2),
2271 "sub{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002272 [(set GR16:$dst, (sub GR16:$src1, GR16:$src2)),
2273 (implicit EFLAGS)]>, OpSize;
Bill Wendlingae034ed2008-12-12 00:56:36 +00002274def SUB32rr : I<0x29, MRMDestReg, (outs GR32:$dst), (ins GR32:$src1,GR32:$src2),
2275 "sub{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002276 [(set GR32:$dst, (sub GR32:$src1, GR32:$src2)),
2277 (implicit EFLAGS)]>;
Bill Wendlingae034ed2008-12-12 00:56:36 +00002278
2279// Register-Memory Subtraction
2280def SUB8rm : I<0x2A, MRMSrcMem, (outs GR8 :$dst),
2281 (ins GR8 :$src1, i8mem :$src2),
2282 "sub{b}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002283 [(set GR8:$dst, (sub GR8:$src1, (load addr:$src2))),
2284 (implicit EFLAGS)]>;
Bill Wendlingae034ed2008-12-12 00:56:36 +00002285def SUB16rm : I<0x2B, MRMSrcMem, (outs GR16:$dst),
2286 (ins GR16:$src1, i16mem:$src2),
2287 "sub{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002288 [(set GR16:$dst, (sub GR16:$src1, (load addr:$src2))),
2289 (implicit EFLAGS)]>, OpSize;
Bill Wendlingae034ed2008-12-12 00:56:36 +00002290def SUB32rm : I<0x2B, MRMSrcMem, (outs GR32:$dst),
2291 (ins GR32:$src1, i32mem:$src2),
2292 "sub{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002293 [(set GR32:$dst, (sub GR32:$src1, (load addr:$src2))),
2294 (implicit EFLAGS)]>;
Bill Wendlingae034ed2008-12-12 00:56:36 +00002295
2296// Register-Integer Subtraction
2297def SUB8ri : Ii8 <0x80, MRM5r, (outs GR8:$dst),
2298 (ins GR8:$src1, i8imm:$src2),
2299 "sub{b}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002300 [(set GR8:$dst, (sub GR8:$src1, imm:$src2)),
2301 (implicit EFLAGS)]>;
Bill Wendlingae034ed2008-12-12 00:56:36 +00002302def SUB16ri : Ii16<0x81, MRM5r, (outs GR16:$dst),
2303 (ins GR16:$src1, i16imm:$src2),
2304 "sub{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002305 [(set GR16:$dst, (sub GR16:$src1, imm:$src2)),
2306 (implicit EFLAGS)]>, OpSize;
Bill Wendlingae034ed2008-12-12 00:56:36 +00002307def SUB32ri : Ii32<0x81, MRM5r, (outs GR32:$dst),
2308 (ins GR32:$src1, i32imm:$src2),
2309 "sub{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002310 [(set GR32:$dst, (sub GR32:$src1, imm:$src2)),
2311 (implicit EFLAGS)]>;
Bill Wendlingae034ed2008-12-12 00:56:36 +00002312def SUB16ri8 : Ii8<0x83, MRM5r, (outs GR16:$dst),
2313 (ins GR16:$src1, i16i8imm:$src2),
2314 "sub{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002315 [(set GR16:$dst, (sub GR16:$src1, i16immSExt8:$src2)),
2316 (implicit EFLAGS)]>, OpSize;
Bill Wendlingae034ed2008-12-12 00:56:36 +00002317def SUB32ri8 : Ii8<0x83, MRM5r, (outs GR32:$dst),
2318 (ins GR32:$src1, i32i8imm:$src2),
2319 "sub{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002320 [(set GR32:$dst, (sub GR32:$src1, i32immSExt8:$src2)),
2321 (implicit EFLAGS)]>;
Bill Wendlingae034ed2008-12-12 00:56:36 +00002322
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002323let isTwoAddress = 0 in {
Bill Wendlingae034ed2008-12-12 00:56:36 +00002324 // Memory-Register Subtraction
Evan Chengb783fa32007-07-19 01:14:50 +00002325 def SUB8mr : I<0x28, MRMDestMem, (outs), (ins i8mem :$dst, GR8 :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002326 "sub{b}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002327 [(store (sub (load addr:$dst), GR8:$src2), addr:$dst),
2328 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002329 def SUB16mr : I<0x29, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002330 "sub{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002331 [(store (sub (load addr:$dst), GR16:$src2), addr:$dst),
2332 (implicit EFLAGS)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002333 def SUB32mr : I<0x29, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002334 "sub{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002335 [(store (sub (load addr:$dst), GR32:$src2), addr:$dst),
2336 (implicit EFLAGS)]>;
Bill Wendlingae034ed2008-12-12 00:56:36 +00002337
2338 // Memory-Integer Subtraction
Evan Chengb783fa32007-07-19 01:14:50 +00002339 def SUB8mi : Ii8<0x80, MRM5m, (outs), (ins i8mem :$dst, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002340 "sub{b}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002341 [(store (sub (loadi8 addr:$dst), imm:$src2), addr:$dst),
2342 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002343 def SUB16mi : Ii16<0x81, MRM5m, (outs), (ins i16mem:$dst, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002344 "sub{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002345 [(store (sub (loadi16 addr:$dst), imm:$src2),addr:$dst),
2346 (implicit EFLAGS)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002347 def SUB32mi : Ii32<0x81, MRM5m, (outs), (ins i32mem:$dst, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002348 "sub{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002349 [(store (sub (loadi32 addr:$dst), imm:$src2),addr:$dst),
2350 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002351 def SUB16mi8 : Ii8<0x83, MRM5m, (outs), (ins i16mem:$dst, i16i8imm :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002352 "sub{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingae034ed2008-12-12 00:56:36 +00002353 [(store (sub (load addr:$dst), i16immSExt8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00002354 addr:$dst),
2355 (implicit EFLAGS)]>, OpSize;
Bill Wendlingae034ed2008-12-12 00:56:36 +00002356 def SUB32mi8 : Ii8<0x83, MRM5m, (outs), (ins i32mem:$dst, i32i8imm :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002357 "sub{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingae034ed2008-12-12 00:56:36 +00002358 [(store (sub (load addr:$dst), i32immSExt8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00002359 addr:$dst),
2360 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002361}
2362
Evan Cheng259471d2007-10-05 17:59:57 +00002363let Uses = [EFLAGS] in {
Evan Chengb783fa32007-07-19 01:14:50 +00002364def SBB32rr : I<0x19, MRMDestReg, (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002365 "sbb{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng55687072007-09-14 21:48:26 +00002366 [(set GR32:$dst, (sube GR32:$src1, GR32:$src2))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002367
2368let isTwoAddress = 0 in {
Evan Chengb783fa32007-07-19 01:14:50 +00002369 def SBB32mr : I<0x19, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002370 "sbb{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002371 [(store (sube (load addr:$dst), GR32:$src2), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002372 def SBB8mi : Ii32<0x80, MRM3m, (outs), (ins i8mem:$dst, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002373 "sbb{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002374 [(store (sube (loadi8 addr:$dst), imm:$src2), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002375 def SBB32mi : Ii32<0x81, MRM3m, (outs), (ins i32mem:$dst, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002376 "sbb{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002377 [(store (sube (loadi32 addr:$dst), imm:$src2), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002378 def SBB32mi8 : Ii8<0x83, MRM3m, (outs), (ins i32mem:$dst, i32i8imm :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002379 "sbb{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng55687072007-09-14 21:48:26 +00002380 [(store (sube (load addr:$dst), i32immSExt8:$src2), addr:$dst)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002381}
Evan Chengb783fa32007-07-19 01:14:50 +00002382def SBB32rm : I<0x1B, MRMSrcMem, (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002383 "sbb{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002384 [(set GR32:$dst, (sube GR32:$src1, (load addr:$src2)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002385def SBB32ri : Ii32<0x81, MRM3r, (outs GR32:$dst), (ins GR32:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002386 "sbb{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002387 [(set GR32:$dst, (sube GR32:$src1, imm:$src2))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002388def SBB32ri8 : Ii8<0x83, MRM3r, (outs GR32:$dst), (ins GR32:$src1, i32i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002389 "sbb{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002390 [(set GR32:$dst, (sube GR32:$src1, i32immSExt8:$src2))]>;
Evan Cheng259471d2007-10-05 17:59:57 +00002391} // Uses = [EFLAGS]
Evan Cheng55687072007-09-14 21:48:26 +00002392} // Defs = [EFLAGS]
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002393
Evan Cheng55687072007-09-14 21:48:26 +00002394let Defs = [EFLAGS] in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002395let isCommutable = 1 in { // X = IMUL Y, Z --> X = IMUL Z, Y
Bill Wendlingf5399032008-12-12 21:15:41 +00002396// Register-Register Signed Integer Multiply
Bill Wendlingae034ed2008-12-12 00:56:36 +00002397def IMUL16rr : I<0xAF, MRMSrcReg, (outs GR16:$dst), (ins GR16:$src1,GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002398 "imul{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002399 [(set GR16:$dst, (mul GR16:$src1, GR16:$src2)),
2400 (implicit EFLAGS)]>, TB, OpSize;
Bill Wendlingae034ed2008-12-12 00:56:36 +00002401def IMUL32rr : I<0xAF, MRMSrcReg, (outs GR32:$dst), (ins GR32:$src1,GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002402 "imul{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002403 [(set GR32:$dst, (mul GR32:$src1, GR32:$src2)),
2404 (implicit EFLAGS)]>, TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002405}
Bill Wendlingae034ed2008-12-12 00:56:36 +00002406
Bill Wendlingf5399032008-12-12 21:15:41 +00002407// Register-Memory Signed Integer Multiply
Bill Wendlingae034ed2008-12-12 00:56:36 +00002408def IMUL16rm : I<0xAF, MRMSrcMem, (outs GR16:$dst),
2409 (ins GR16:$src1, i16mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002410 "imul{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002411 [(set GR16:$dst, (mul GR16:$src1, (load addr:$src2))),
2412 (implicit EFLAGS)]>, TB, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002413def IMUL32rm : I<0xAF, MRMSrcMem, (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002414 "imul{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002415 [(set GR32:$dst, (mul GR32:$src1, (load addr:$src2))),
2416 (implicit EFLAGS)]>, TB;
Evan Cheng55687072007-09-14 21:48:26 +00002417} // Defs = [EFLAGS]
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002418} // end Two Address instructions
2419
2420// Suprisingly enough, these are not two address instructions!
Evan Cheng55687072007-09-14 21:48:26 +00002421let Defs = [EFLAGS] in {
Bill Wendlingf5399032008-12-12 21:15:41 +00002422// Register-Integer Signed Integer Multiply
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002423def IMUL16rri : Ii16<0x69, MRMSrcReg, // GR16 = GR16*I16
Evan Chengb783fa32007-07-19 01:14:50 +00002424 (outs GR16:$dst), (ins GR16:$src1, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002425 "imul{w}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002426 [(set GR16:$dst, (mul GR16:$src1, imm:$src2)),
2427 (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002428def IMUL32rri : Ii32<0x69, MRMSrcReg, // GR32 = GR32*I32
Evan Chengb783fa32007-07-19 01:14:50 +00002429 (outs GR32:$dst), (ins GR32:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002430 "imul{l}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002431 [(set GR32:$dst, (mul GR32:$src1, imm:$src2)),
2432 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002433def IMUL16rri8 : Ii8<0x6B, MRMSrcReg, // GR16 = GR16*I8
Evan Chengb783fa32007-07-19 01:14:50 +00002434 (outs GR16:$dst), (ins GR16:$src1, i16i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002435 "imul{w}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002436 [(set GR16:$dst, (mul GR16:$src1, i16immSExt8:$src2)),
2437 (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002438def IMUL32rri8 : Ii8<0x6B, MRMSrcReg, // GR32 = GR32*I8
Evan Chengb783fa32007-07-19 01:14:50 +00002439 (outs GR32:$dst), (ins GR32:$src1, i32i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002440 "imul{l}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002441 [(set GR32:$dst, (mul GR32:$src1, i32immSExt8:$src2)),
2442 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002443
Bill Wendlingf5399032008-12-12 21:15:41 +00002444// Memory-Integer Signed Integer Multiply
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002445def IMUL16rmi : Ii16<0x69, MRMSrcMem, // GR16 = [mem16]*I16
Evan Chengb783fa32007-07-19 01:14:50 +00002446 (outs GR16:$dst), (ins i16mem:$src1, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002447 "imul{w}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002448 [(set GR16:$dst, (mul (load addr:$src1), imm:$src2)),
2449 (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002450def IMUL32rmi : Ii32<0x69, MRMSrcMem, // GR32 = [mem32]*I32
Evan Chengb783fa32007-07-19 01:14:50 +00002451 (outs GR32:$dst), (ins i32mem:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002452 "imul{l}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002453 [(set GR32:$dst, (mul (load addr:$src1), imm:$src2)),
2454 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002455def IMUL16rmi8 : Ii8<0x6B, MRMSrcMem, // GR16 = [mem16]*I8
Evan Chengb783fa32007-07-19 01:14:50 +00002456 (outs GR16:$dst), (ins i16mem:$src1, i16i8imm :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002457 "imul{w}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Bill Wendlingae034ed2008-12-12 00:56:36 +00002458 [(set GR16:$dst, (mul (load addr:$src1),
Bill Wendlingf5399032008-12-12 21:15:41 +00002459 i16immSExt8:$src2)),
2460 (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002461def IMUL32rmi8 : Ii8<0x6B, MRMSrcMem, // GR32 = [mem32]*I8
Evan Chengb783fa32007-07-19 01:14:50 +00002462 (outs GR32:$dst), (ins i32mem:$src1, i32i8imm: $src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002463 "imul{l}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Bill Wendlingae034ed2008-12-12 00:56:36 +00002464 [(set GR32:$dst, (mul (load addr:$src1),
Bill Wendlingf5399032008-12-12 21:15:41 +00002465 i32immSExt8:$src2)),
2466 (implicit EFLAGS)]>;
Evan Cheng55687072007-09-14 21:48:26 +00002467} // Defs = [EFLAGS]
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002468
2469//===----------------------------------------------------------------------===//
2470// Test instructions are just like AND, except they don't generate a result.
2471//
Evan Cheng950aac02007-09-25 01:57:46 +00002472let Defs = [EFLAGS] in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002473let isCommutable = 1 in { // TEST X, Y --> TEST Y, X
Evan Chengb783fa32007-07-19 01:14:50 +00002474def TEST8rr : I<0x84, MRMDestReg, (outs), (ins GR8:$src1, GR8:$src2),
Evan Cheng621216e2007-09-29 00:00:36 +00002475 "test{b}\t{$src2, $src1|$src1, $src2}",
Chris Lattner21da6382008-02-19 17:37:35 +00002476 [(X86cmp (and_su GR8:$src1, GR8:$src2), 0),
Evan Cheng621216e2007-09-29 00:00:36 +00002477 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002478def TEST16rr : I<0x85, MRMDestReg, (outs), (ins GR16:$src1, GR16:$src2),
Evan Cheng621216e2007-09-29 00:00:36 +00002479 "test{w}\t{$src2, $src1|$src1, $src2}",
Chris Lattner21da6382008-02-19 17:37:35 +00002480 [(X86cmp (and_su GR16:$src1, GR16:$src2), 0),
Evan Cheng621216e2007-09-29 00:00:36 +00002481 (implicit EFLAGS)]>,
2482 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002483def TEST32rr : I<0x85, MRMDestReg, (outs), (ins GR32:$src1, GR32:$src2),
Evan Cheng621216e2007-09-29 00:00:36 +00002484 "test{l}\t{$src2, $src1|$src1, $src2}",
Chris Lattner21da6382008-02-19 17:37:35 +00002485 [(X86cmp (and_su GR32:$src1, GR32:$src2), 0),
Evan Cheng621216e2007-09-29 00:00:36 +00002486 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002487}
2488
Evan Chengb783fa32007-07-19 01:14:50 +00002489def TEST8rm : I<0x84, MRMSrcMem, (outs), (ins GR8 :$src1, i8mem :$src2),
Evan Cheng621216e2007-09-29 00:00:36 +00002490 "test{b}\t{$src2, $src1|$src1, $src2}",
2491 [(X86cmp (and GR8:$src1, (loadi8 addr:$src2)), 0),
2492 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002493def TEST16rm : I<0x85, MRMSrcMem, (outs), (ins GR16:$src1, i16mem:$src2),
Evan Cheng621216e2007-09-29 00:00:36 +00002494 "test{w}\t{$src2, $src1|$src1, $src2}",
2495 [(X86cmp (and GR16:$src1, (loadi16 addr:$src2)), 0),
2496 (implicit EFLAGS)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002497def TEST32rm : I<0x85, MRMSrcMem, (outs), (ins GR32:$src1, i32mem:$src2),
Evan Cheng621216e2007-09-29 00:00:36 +00002498 "test{l}\t{$src2, $src1|$src1, $src2}",
2499 [(X86cmp (and GR32:$src1, (loadi32 addr:$src2)), 0),
2500 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002501
2502def TEST8ri : Ii8 <0xF6, MRM0r, // flags = GR8 & imm8
Evan Chengb783fa32007-07-19 01:14:50 +00002503 (outs), (ins GR8:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002504 "test{b}\t{$src2, $src1|$src1, $src2}",
Chris Lattner21da6382008-02-19 17:37:35 +00002505 [(X86cmp (and_su GR8:$src1, imm:$src2), 0),
Evan Cheng621216e2007-09-29 00:00:36 +00002506 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002507def TEST16ri : Ii16<0xF7, MRM0r, // flags = GR16 & imm16
Evan Chengb783fa32007-07-19 01:14:50 +00002508 (outs), (ins GR16:$src1, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002509 "test{w}\t{$src2, $src1|$src1, $src2}",
Chris Lattner21da6382008-02-19 17:37:35 +00002510 [(X86cmp (and_su GR16:$src1, imm:$src2), 0),
Evan Cheng621216e2007-09-29 00:00:36 +00002511 (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002512def TEST32ri : Ii32<0xF7, MRM0r, // flags = GR32 & imm32
Evan Chengb783fa32007-07-19 01:14:50 +00002513 (outs), (ins GR32:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002514 "test{l}\t{$src2, $src1|$src1, $src2}",
Chris Lattner21da6382008-02-19 17:37:35 +00002515 [(X86cmp (and_su GR32:$src1, imm:$src2), 0),
Evan Cheng621216e2007-09-29 00:00:36 +00002516 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002517
Evan Cheng621216e2007-09-29 00:00:36 +00002518def TEST8mi : Ii8 <0xF6, MRM0m, // flags = [mem8] & imm8
Evan Chengb783fa32007-07-19 01:14:50 +00002519 (outs), (ins i8mem:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002520 "test{b}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002521 [(X86cmp (and (loadi8 addr:$src1), imm:$src2), 0),
2522 (implicit EFLAGS)]>;
2523def TEST16mi : Ii16<0xF7, MRM0m, // flags = [mem16] & imm16
Evan Chengb783fa32007-07-19 01:14:50 +00002524 (outs), (ins i16mem:$src1, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002525 "test{w}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002526 [(X86cmp (and (loadi16 addr:$src1), imm:$src2), 0),
2527 (implicit EFLAGS)]>, OpSize;
2528def TEST32mi : Ii32<0xF7, MRM0m, // flags = [mem32] & imm32
Evan Chengb783fa32007-07-19 01:14:50 +00002529 (outs), (ins i32mem:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002530 "test{l}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002531 [(X86cmp (and (loadi32 addr:$src1), imm:$src2), 0),
Evan Cheng950aac02007-09-25 01:57:46 +00002532 (implicit EFLAGS)]>;
2533} // Defs = [EFLAGS]
2534
2535
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002536// Condition code ops, incl. set if equal/not equal/...
Chris Lattnerc90ee9c2008-01-10 07:59:24 +00002537let Defs = [EFLAGS], Uses = [AH], neverHasSideEffects = 1 in
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002538def SAHF : I<0x9E, RawFrm, (outs), (ins), "sahf", []>; // flags = AH
Chris Lattnerc90ee9c2008-01-10 07:59:24 +00002539let Defs = [AH], Uses = [EFLAGS], neverHasSideEffects = 1 in
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002540def LAHF : I<0x9F, RawFrm, (outs), (ins), "lahf", []>; // AH = flags
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002541
Evan Cheng950aac02007-09-25 01:57:46 +00002542let Uses = [EFLAGS] in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002543def SETEr : I<0x94, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00002544 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002545 "sete\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002546 [(set GR8:$dst, (X86setcc X86_COND_E, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002547 TB; // GR8 = ==
2548def SETEm : I<0x94, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00002549 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002550 "sete\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002551 [(store (X86setcc X86_COND_E, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002552 TB; // [mem8] = ==
Bill Wendling0c52d0a2008-12-02 00:07:05 +00002553
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002554def SETNEr : I<0x95, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00002555 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002556 "setne\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002557 [(set GR8:$dst, (X86setcc X86_COND_NE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002558 TB; // GR8 = !=
2559def SETNEm : I<0x95, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00002560 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002561 "setne\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002562 [(store (X86setcc X86_COND_NE, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002563 TB; // [mem8] = !=
Bill Wendling0c52d0a2008-12-02 00:07:05 +00002564
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002565def SETLr : I<0x9C, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00002566 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002567 "setl\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002568 [(set GR8:$dst, (X86setcc X86_COND_L, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002569 TB; // GR8 = < signed
2570def SETLm : I<0x9C, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00002571 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002572 "setl\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002573 [(store (X86setcc X86_COND_L, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002574 TB; // [mem8] = < signed
Bill Wendling0c52d0a2008-12-02 00:07:05 +00002575
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002576def SETGEr : I<0x9D, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00002577 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002578 "setge\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002579 [(set GR8:$dst, (X86setcc X86_COND_GE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002580 TB; // GR8 = >= signed
2581def SETGEm : I<0x9D, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00002582 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002583 "setge\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002584 [(store (X86setcc X86_COND_GE, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002585 TB; // [mem8] = >= signed
Bill Wendling0c52d0a2008-12-02 00:07:05 +00002586
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002587def SETLEr : I<0x9E, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00002588 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002589 "setle\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002590 [(set GR8:$dst, (X86setcc X86_COND_LE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002591 TB; // GR8 = <= signed
2592def SETLEm : I<0x9E, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00002593 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002594 "setle\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002595 [(store (X86setcc X86_COND_LE, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002596 TB; // [mem8] = <= signed
Bill Wendling0c52d0a2008-12-02 00:07:05 +00002597
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002598def SETGr : I<0x9F, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00002599 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002600 "setg\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002601 [(set GR8:$dst, (X86setcc X86_COND_G, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002602 TB; // GR8 = > signed
2603def SETGm : I<0x9F, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00002604 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002605 "setg\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002606 [(store (X86setcc X86_COND_G, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002607 TB; // [mem8] = > signed
2608
2609def SETBr : I<0x92, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00002610 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002611 "setb\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002612 [(set GR8:$dst, (X86setcc X86_COND_B, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002613 TB; // GR8 = < unsign
2614def SETBm : I<0x92, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00002615 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002616 "setb\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002617 [(store (X86setcc X86_COND_B, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002618 TB; // [mem8] = < unsign
Bill Wendling0c52d0a2008-12-02 00:07:05 +00002619
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002620def SETAEr : I<0x93, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00002621 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002622 "setae\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002623 [(set GR8:$dst, (X86setcc X86_COND_AE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002624 TB; // GR8 = >= unsign
2625def SETAEm : I<0x93, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00002626 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002627 "setae\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002628 [(store (X86setcc X86_COND_AE, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002629 TB; // [mem8] = >= unsign
Bill Wendling0c52d0a2008-12-02 00:07:05 +00002630
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002631def SETBEr : I<0x96, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00002632 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002633 "setbe\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002634 [(set GR8:$dst, (X86setcc X86_COND_BE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002635 TB; // GR8 = <= unsign
2636def SETBEm : I<0x96, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00002637 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002638 "setbe\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002639 [(store (X86setcc X86_COND_BE, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002640 TB; // [mem8] = <= unsign
Bill Wendling0c52d0a2008-12-02 00:07:05 +00002641
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002642def SETAr : I<0x97, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00002643 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002644 "seta\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002645 [(set GR8:$dst, (X86setcc X86_COND_A, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002646 TB; // GR8 = > signed
2647def SETAm : I<0x97, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00002648 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002649 "seta\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002650 [(store (X86setcc X86_COND_A, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002651 TB; // [mem8] = > signed
2652
2653def SETSr : I<0x98, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00002654 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002655 "sets\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002656 [(set GR8:$dst, (X86setcc X86_COND_S, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002657 TB; // GR8 = <sign bit>
2658def SETSm : I<0x98, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00002659 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002660 "sets\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002661 [(store (X86setcc X86_COND_S, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002662 TB; // [mem8] = <sign bit>
2663def SETNSr : I<0x99, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00002664 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002665 "setns\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002666 [(set GR8:$dst, (X86setcc X86_COND_NS, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002667 TB; // GR8 = !<sign bit>
2668def SETNSm : I<0x99, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00002669 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002670 "setns\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002671 [(store (X86setcc X86_COND_NS, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002672 TB; // [mem8] = !<sign bit>
Bill Wendling0c52d0a2008-12-02 00:07:05 +00002673
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002674def SETPr : I<0x9A, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00002675 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002676 "setp\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002677 [(set GR8:$dst, (X86setcc X86_COND_P, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002678 TB; // GR8 = parity
2679def SETPm : I<0x9A, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00002680 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002681 "setp\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002682 [(store (X86setcc X86_COND_P, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002683 TB; // [mem8] = parity
2684def SETNPr : I<0x9B, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00002685 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002686 "setnp\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002687 [(set GR8:$dst, (X86setcc X86_COND_NP, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002688 TB; // GR8 = not parity
2689def SETNPm : I<0x9B, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00002690 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002691 "setnp\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002692 [(store (X86setcc X86_COND_NP, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002693 TB; // [mem8] = not parity
Bill Wendling0c52d0a2008-12-02 00:07:05 +00002694
2695def SETOr : I<0x90, MRM0r,
2696 (outs GR8 :$dst), (ins),
2697 "seto\t$dst",
2698 [(set GR8:$dst, (X86setcc X86_COND_O, EFLAGS))]>,
2699 TB; // GR8 = overflow
2700def SETOm : I<0x90, MRM0m,
2701 (outs), (ins i8mem:$dst),
2702 "seto\t$dst",
2703 [(store (X86setcc X86_COND_O, EFLAGS), addr:$dst)]>,
2704 TB; // [mem8] = overflow
2705def SETNOr : I<0x91, MRM0r,
2706 (outs GR8 :$dst), (ins),
2707 "setno\t$dst",
2708 [(set GR8:$dst, (X86setcc X86_COND_NO, EFLAGS))]>,
2709 TB; // GR8 = not overflow
2710def SETNOm : I<0x91, MRM0m,
2711 (outs), (ins i8mem:$dst),
2712 "setno\t$dst",
2713 [(store (X86setcc X86_COND_NO, EFLAGS), addr:$dst)]>,
2714 TB; // [mem8] = not overflow
Evan Cheng950aac02007-09-25 01:57:46 +00002715} // Uses = [EFLAGS]
2716
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002717
2718// Integer comparisons
Evan Cheng55687072007-09-14 21:48:26 +00002719let Defs = [EFLAGS] in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002720def CMP8rr : I<0x38, MRMDestReg,
Evan Chengb783fa32007-07-19 01:14:50 +00002721 (outs), (ins GR8 :$src1, GR8 :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002722 "cmp{b}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002723 [(X86cmp GR8:$src1, GR8:$src2), (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002724def CMP16rr : I<0x39, MRMDestReg,
Evan Chengb783fa32007-07-19 01:14:50 +00002725 (outs), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002726 "cmp{w}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002727 [(X86cmp GR16:$src1, GR16:$src2), (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002728def CMP32rr : I<0x39, MRMDestReg,
Evan Chengb783fa32007-07-19 01:14:50 +00002729 (outs), (ins GR32:$src1, GR32:$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, GR32:$src2), (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002732def CMP8mr : I<0x38, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00002733 (outs), (ins i8mem :$src1, GR8 :$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), GR8:$src2),
2736 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002737def CMP16mr : I<0x39, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00002738 (outs), (ins i16mem:$src1, GR16:$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), GR16:$src2),
2741 (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002742def CMP32mr : I<0x39, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00002743 (outs), (ins i32mem:$src1, GR32:$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), GR32:$src2),
2746 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002747def CMP8rm : I<0x3A, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00002748 (outs), (ins GR8 :$src1, i8mem :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002749 "cmp{b}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002750 [(X86cmp GR8:$src1, (loadi8 addr:$src2)),
2751 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002752def CMP16rm : I<0x3B, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00002753 (outs), (ins GR16:$src1, i16mem:$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 GR16:$src1, (loadi16 addr:$src2)),
2756 (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002757def CMP32rm : I<0x3B, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00002758 (outs), (ins GR32:$src1, i32mem:$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 GR32:$src1, (loadi32 addr:$src2)),
2761 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002762def CMP8ri : Ii8<0x80, MRM7r,
Evan Chengb783fa32007-07-19 01:14:50 +00002763 (outs), (ins GR8:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002764 "cmp{b}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002765 [(X86cmp GR8:$src1, imm:$src2), (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002766def CMP16ri : Ii16<0x81, MRM7r,
Evan Chengb783fa32007-07-19 01:14:50 +00002767 (outs), (ins GR16:$src1, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002768 "cmp{w}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002769 [(X86cmp GR16:$src1, imm:$src2),
2770 (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002771def CMP32ri : Ii32<0x81, MRM7r,
Evan Chengb783fa32007-07-19 01:14:50 +00002772 (outs), (ins GR32:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002773 "cmp{l}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002774 [(X86cmp GR32:$src1, imm:$src2), (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002775def CMP8mi : Ii8 <0x80, MRM7m,
Evan Chengb783fa32007-07-19 01:14:50 +00002776 (outs), (ins i8mem :$src1, i8imm :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002777 "cmp{b}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002778 [(X86cmp (loadi8 addr:$src1), imm:$src2),
2779 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002780def CMP16mi : Ii16<0x81, MRM7m,
Evan Chengb783fa32007-07-19 01:14:50 +00002781 (outs), (ins i16mem:$src1, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002782 "cmp{w}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002783 [(X86cmp (loadi16 addr:$src1), imm:$src2),
2784 (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002785def CMP32mi : Ii32<0x81, MRM7m,
Evan Chengb783fa32007-07-19 01:14:50 +00002786 (outs), (ins i32mem:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002787 "cmp{l}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002788 [(X86cmp (loadi32 addr:$src1), imm:$src2),
2789 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002790def CMP16ri8 : Ii8<0x83, MRM7r,
Evan Chengb783fa32007-07-19 01:14:50 +00002791 (outs), (ins GR16:$src1, i16i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002792 "cmp{w}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002793 [(X86cmp GR16:$src1, i16immSExt8:$src2),
2794 (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002795def CMP16mi8 : Ii8<0x83, MRM7m,
Evan Chengb783fa32007-07-19 01:14:50 +00002796 (outs), (ins i16mem:$src1, i16i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002797 "cmp{w}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002798 [(X86cmp (loadi16 addr:$src1), i16immSExt8:$src2),
2799 (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002800def CMP32mi8 : Ii8<0x83, MRM7m,
Evan Chengb783fa32007-07-19 01:14:50 +00002801 (outs), (ins i32mem:$src1, i32i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002802 "cmp{l}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002803 [(X86cmp (loadi32 addr:$src1), i32immSExt8:$src2),
2804 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002805def CMP32ri8 : Ii8<0x83, MRM7r,
Evan Chengb783fa32007-07-19 01:14:50 +00002806 (outs), (ins GR32:$src1, i32i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002807 "cmp{l}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002808 [(X86cmp GR32:$src1, i32immSExt8:$src2),
Evan Cheng950aac02007-09-25 01:57:46 +00002809 (implicit EFLAGS)]>;
2810} // Defs = [EFLAGS]
2811
Dan Gohman7fe9b7f2008-12-23 22:45:23 +00002812// Bit tests.
Dan Gohman7fe9b7f2008-12-23 22:45:23 +00002813// TODO: BTC, BTR, and BTS
2814let Defs = [EFLAGS] in {
Dan Gohmanfc4eddb2009-01-13 20:32:45 +00002815def BT16rr : I<0xA3, MRMDestReg, (outs), (ins GR16:$src1, GR16:$src2),
Dan Gohman7fe9b7f2008-12-23 22:45:23 +00002816 "bt{w}\t{$src2, $src1|$src1, $src2}",
2817 [(X86bt GR16:$src1, GR16:$src2),
Chris Lattner5a95cde2008-12-25 01:32:49 +00002818 (implicit EFLAGS)]>, OpSize, TB;
Dan Gohmanfc4eddb2009-01-13 20:32:45 +00002819def BT32rr : I<0xA3, MRMDestReg, (outs), (ins GR32:$src1, GR32:$src2),
Dan Gohman7fe9b7f2008-12-23 22:45:23 +00002820 "bt{l}\t{$src2, $src1|$src1, $src2}",
2821 [(X86bt GR32:$src1, GR32:$src2),
Chris Lattner5a95cde2008-12-25 01:32:49 +00002822 (implicit EFLAGS)]>, TB;
Dan Gohman85a228c2009-01-13 23:23:30 +00002823
2824// Unlike with the register+register form, the memory+register form of the
2825// bt instruction does not ignore the high bits of the index. From ISel's
2826// perspective, this is pretty bizarre. Disable these instructions for now.
2827//def BT16mr : I<0xA3, MRMDestMem, (outs), (ins i16mem:$src1, GR16:$src2),
2828// "bt{w}\t{$src2, $src1|$src1, $src2}",
2829// [(X86bt (loadi16 addr:$src1), GR16:$src2),
2830// (implicit EFLAGS)]>, OpSize, TB, Requires<[FastBTMem]>;
2831//def BT32mr : I<0xA3, MRMDestMem, (outs), (ins i32mem:$src1, GR32:$src2),
2832// "bt{l}\t{$src2, $src1|$src1, $src2}",
2833// [(X86bt (loadi32 addr:$src1), GR32:$src2),
2834// (implicit EFLAGS)]>, TB, Requires<[FastBTMem]>;
Dan Gohman46fb1cf2009-01-13 20:33:23 +00002835
2836def BT16ri8 : Ii8<0xBA, MRM4r, (outs), (ins GR16:$src1, i16i8imm:$src2),
2837 "bt{w}\t{$src2, $src1|$src1, $src2}",
2838 [(X86bt GR16:$src1, i16immSExt8:$src2),
2839 (implicit EFLAGS)]>, OpSize, TB;
2840def BT32ri8 : Ii8<0xBA, MRM4r, (outs), (ins GR32:$src1, i32i8imm:$src2),
2841 "bt{l}\t{$src2, $src1|$src1, $src2}",
2842 [(X86bt GR32:$src1, i32immSExt8:$src2),
2843 (implicit EFLAGS)]>, TB;
2844// Note that these instructions don't need FastBTMem because that
2845// only applies when the other operand is in a register. When it's
2846// an immediate, bt is still fast.
2847def BT16mi8 : Ii8<0xBA, MRM4m, (outs), (ins i16mem:$src1, i16i8imm:$src2),
2848 "bt{w}\t{$src2, $src1|$src1, $src2}",
2849 [(X86bt (loadi16 addr:$src1), i16immSExt8:$src2),
2850 (implicit EFLAGS)]>, OpSize, TB;
2851def BT32mi8 : Ii8<0xBA, MRM4m, (outs), (ins i32mem:$src1, i32i8imm:$src2),
2852 "bt{l}\t{$src2, $src1|$src1, $src2}",
2853 [(X86bt (loadi32 addr:$src1), i32immSExt8:$src2),
2854 (implicit EFLAGS)]>, TB;
Dan Gohman7fe9b7f2008-12-23 22:45:23 +00002855} // Defs = [EFLAGS]
2856
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002857// Sign/Zero extenders
Dan Gohman9203ab42008-07-30 18:09:17 +00002858// Use movsbl intead of movsbw; we don't care about the high 16 bits
2859// of the register here. This has a smaller encoding and avoids a
2860// partial-register update.
Evan Chengb783fa32007-07-19 01:14:50 +00002861def MOVSX16rr8 : I<0xBE, MRMSrcReg, (outs GR16:$dst), (ins GR8 :$src),
Dan Gohman9203ab42008-07-30 18:09:17 +00002862 "movs{bl|x}\t{$src, ${dst:subreg32}|${dst:subreg32}, $src}",
2863 [(set GR16:$dst, (sext GR8:$src))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00002864def MOVSX16rm8 : I<0xBE, MRMSrcMem, (outs GR16:$dst), (ins i8mem :$src),
Dan Gohman9203ab42008-07-30 18:09:17 +00002865 "movs{bl|x}\t{$src, ${dst:subreg32}|${dst:subreg32}, $src}",
2866 [(set GR16:$dst, (sextloadi16i8 addr:$src))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00002867def MOVSX32rr8 : I<0xBE, MRMSrcReg, (outs GR32:$dst), (ins GR8 :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002868 "movs{bl|x}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002869 [(set GR32:$dst, (sext GR8:$src))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00002870def MOVSX32rm8 : I<0xBE, MRMSrcMem, (outs GR32:$dst), (ins i8mem :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002871 "movs{bl|x}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002872 [(set GR32:$dst, (sextloadi32i8 addr:$src))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00002873def MOVSX32rr16: I<0xBF, MRMSrcReg, (outs GR32:$dst), (ins GR16:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002874 "movs{wl|x}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002875 [(set GR32:$dst, (sext GR16:$src))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00002876def MOVSX32rm16: I<0xBF, MRMSrcMem, (outs GR32:$dst), (ins i16mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002877 "movs{wl|x}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002878 [(set GR32:$dst, (sextloadi32i16 addr:$src))]>, TB;
2879
Dan Gohman9203ab42008-07-30 18:09:17 +00002880// Use movzbl intead of movzbw; we don't care about the high 16 bits
2881// of the register here. This has a smaller encoding and avoids a
2882// partial-register update.
Evan Chengb783fa32007-07-19 01:14:50 +00002883def MOVZX16rr8 : I<0xB6, MRMSrcReg, (outs GR16:$dst), (ins GR8 :$src),
Dan Gohman9203ab42008-07-30 18:09:17 +00002884 "movz{bl|x}\t{$src, ${dst:subreg32}|${dst:subreg32}, $src}",
2885 [(set GR16:$dst, (zext GR8:$src))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00002886def MOVZX16rm8 : I<0xB6, MRMSrcMem, (outs GR16:$dst), (ins i8mem :$src),
Dan Gohman9203ab42008-07-30 18:09:17 +00002887 "movz{bl|x}\t{$src, ${dst:subreg32}|${dst:subreg32}, $src}",
2888 [(set GR16:$dst, (zextloadi16i8 addr:$src))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00002889def MOVZX32rr8 : I<0xB6, MRMSrcReg, (outs GR32:$dst), (ins GR8 :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002890 "movz{bl|x}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002891 [(set GR32:$dst, (zext GR8:$src))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00002892def MOVZX32rm8 : I<0xB6, MRMSrcMem, (outs GR32:$dst), (ins i8mem :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002893 "movz{bl|x}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002894 [(set GR32:$dst, (zextloadi32i8 addr:$src))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00002895def MOVZX32rr16: I<0xB7, MRMSrcReg, (outs GR32:$dst), (ins GR16:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002896 "movz{wl|x}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002897 [(set GR32:$dst, (zext GR16:$src))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00002898def MOVZX32rm16: I<0xB7, MRMSrcMem, (outs GR32:$dst), (ins i16mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002899 "movz{wl|x}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002900 [(set GR32:$dst, (zextloadi32i16 addr:$src))]>, TB;
2901
Chris Lattnerc90ee9c2008-01-10 07:59:24 +00002902let neverHasSideEffects = 1 in {
2903 let Defs = [AX], Uses = [AL] in
2904 def CBW : I<0x98, RawFrm, (outs), (ins),
2905 "{cbtw|cbw}", []>, OpSize; // AX = signext(AL)
2906 let Defs = [EAX], Uses = [AX] in
2907 def CWDE : I<0x98, RawFrm, (outs), (ins),
2908 "{cwtl|cwde}", []>; // EAX = signext(AX)
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002909
Chris Lattnerc90ee9c2008-01-10 07:59:24 +00002910 let Defs = [AX,DX], Uses = [AX] in
2911 def CWD : I<0x99, RawFrm, (outs), (ins),
2912 "{cwtd|cwd}", []>, OpSize; // DX:AX = signext(AX)
2913 let Defs = [EAX,EDX], Uses = [EAX] in
2914 def CDQ : I<0x99, RawFrm, (outs), (ins),
2915 "{cltd|cdq}", []>; // EDX:EAX = signext(EAX)
2916}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002917
2918//===----------------------------------------------------------------------===//
2919// Alias Instructions
2920//===----------------------------------------------------------------------===//
2921
2922// Alias instructions that map movr0 to xor.
2923// FIXME: remove when we can teach regalloc that xor reg, reg is ok.
Bill Wendlingba5d5b02008-05-29 01:02:09 +00002924let Defs = [EFLAGS], isReMaterializable = 1, isAsCheapAsAMove = 1 in {
Evan Chengb783fa32007-07-19 01:14:50 +00002925def MOV8r0 : I<0x30, MRMInitReg, (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002926 "xor{b}\t$dst, $dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002927 [(set GR8:$dst, 0)]>;
Dan Gohman9203ab42008-07-30 18:09:17 +00002928// Use xorl instead of xorw since we don't care about the high 16 bits,
2929// it's smaller, and it avoids a partial-register update.
Evan Chengb783fa32007-07-19 01:14:50 +00002930def MOV16r0 : I<0x31, MRMInitReg, (outs GR16:$dst), (ins),
Dan Gohman9203ab42008-07-30 18:09:17 +00002931 "xor{l}\t${dst:subreg32}, ${dst:subreg32}",
2932 [(set GR16:$dst, 0)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002933def MOV32r0 : I<0x31, MRMInitReg, (outs GR32:$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002934 "xor{l}\t$dst, $dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002935 [(set GR32:$dst, 0)]>;
Dan Gohman8aef09b2007-09-07 21:32:51 +00002936}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002937
2938// Basic operations on GR16 / GR32 subclasses GR16_ and GR32_ which contains only
2939// those registers that have GR8 sub-registers (i.e. AX - DX, EAX - EDX).
Evan Chengbd0ca9c2009-02-05 08:42:55 +00002940let neverHasSideEffects = 1, isAsCheapAsAMove = 1 in {
Evan Chengb783fa32007-07-19 01:14:50 +00002941def MOV16to16_ : I<0x89, MRMDestReg, (outs GR16_:$dst), (ins GR16:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002942 "mov{w}\t{$src, $dst|$dst, $src}", []>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002943def MOV32to32_ : I<0x89, MRMDestReg, (outs GR32_:$dst), (ins GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002944 "mov{l}\t{$src, $dst|$dst, $src}", []>;
Chris Lattnerc90ee9c2008-01-10 07:59:24 +00002945
Evan Chengb783fa32007-07-19 01:14:50 +00002946def MOV16_rr : I<0x89, MRMDestReg, (outs GR16_:$dst), (ins GR16_:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002947 "mov{w}\t{$src, $dst|$dst, $src}", []>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002948def MOV32_rr : I<0x89, MRMDestReg, (outs GR32_:$dst), (ins GR32_:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002949 "mov{l}\t{$src, $dst|$dst, $src}", []>;
Chris Lattnerc90ee9c2008-01-10 07:59:24 +00002950} // neverHasSideEffects
2951
Dan Gohman5574cc72008-12-03 18:15:48 +00002952let canFoldAsLoad = 1, mayLoad = 1, isReMaterializable = 1, mayHaveSideEffects = 1 in {
Evan Chengb783fa32007-07-19 01:14:50 +00002953def MOV16_rm : I<0x8B, MRMSrcMem, (outs GR16_:$dst), (ins i16mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002954 "mov{w}\t{$src, $dst|$dst, $src}", []>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002955def MOV32_rm : I<0x8B, MRMSrcMem, (outs GR32_:$dst), (ins i32mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002956 "mov{l}\t{$src, $dst|$dst, $src}", []>;
Evan Cheng4e84e452007-08-30 05:49:43 +00002957}
Chris Lattnerc90ee9c2008-01-10 07:59:24 +00002958let mayStore = 1, neverHasSideEffects = 1 in {
Evan Chengb783fa32007-07-19 01:14:50 +00002959def MOV16_mr : I<0x89, MRMDestMem, (outs), (ins i16mem:$dst, GR16_:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002960 "mov{w}\t{$src, $dst|$dst, $src}", []>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002961def MOV32_mr : I<0x89, MRMDestMem, (outs), (ins i32mem:$dst, GR32_:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002962 "mov{l}\t{$src, $dst|$dst, $src}", []>;
Chris Lattnerc90ee9c2008-01-10 07:59:24 +00002963}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002964
2965//===----------------------------------------------------------------------===//
2966// Thread Local Storage Instructions
2967//
2968
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002969let Uses = [EBX] in
Anton Korobeynikov4fbf00b2008-05-04 21:36:32 +00002970def TLS_addr32 : I<0, Pseudo, (outs GR32:$dst), (ins i32imm:$sym),
2971 "leal\t${sym:mem}(,%ebx,1), $dst",
2972 [(set GR32:$dst, (X86tlsaddr tglobaltlsaddr:$sym))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002973
sampo9cc09a32009-01-26 01:24:32 +00002974let AddedComplexity = 5 in
2975def GS_MOV32rm : I<0x8B, MRMSrcMem, (outs GR32:$dst), (ins i32mem:$src),
2976 "movl\t%gs:$src, $dst",
2977 [(set GR32:$dst, (gsload addr:$src))]>, SegGS;
2978
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002979//===----------------------------------------------------------------------===//
2980// DWARF Pseudo Instructions
2981//
2982
Evan Chengb783fa32007-07-19 01:14:50 +00002983def DWARF_LOC : I<0, Pseudo, (outs),
2984 (ins i32imm:$line, i32imm:$col, i32imm:$file),
Dan Gohman77af4a82007-09-24 19:25:06 +00002985 ".loc\t${file:debug} ${line:debug} ${col:debug}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002986 [(dwarf_loc (i32 imm:$line), (i32 imm:$col),
2987 (i32 imm:$file))]>;
2988
2989//===----------------------------------------------------------------------===//
2990// EH Pseudo Instructions
2991//
2992let isTerminator = 1, isReturn = 1, isBarrier = 1,
Evan Cheng37e7c752007-07-21 00:34:19 +00002993 hasCtrlDep = 1 in {
Evan Chengb783fa32007-07-19 01:14:50 +00002994def EH_RETURN : I<0xC3, RawFrm, (outs), (ins GR32:$addr),
Dan Gohman91888f02007-07-31 20:11:57 +00002995 "ret\t#eh_return, addr: $addr",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002996 [(X86ehret GR32:$addr)]>;
2997
2998}
2999
3000//===----------------------------------------------------------------------===//
Andrew Lenharthe44f3902008-02-21 06:45:13 +00003001// Atomic support
3002//
Andrew Lenharth7a5a4b22008-03-01 13:37:02 +00003003
Evan Cheng3e171562008-04-19 01:20:30 +00003004// Atomic swap. These are just normal xchg instructions. But since a memory
3005// operand is referenced, the atomicity is ensured.
Dan Gohmana41a1c092008-08-06 15:52:50 +00003006let Constraints = "$val = $dst" in {
Evan Cheng3e171562008-04-19 01:20:30 +00003007def XCHG32rm : I<0x87, MRMSrcMem, (outs GR32:$dst), (ins i32mem:$ptr, GR32:$val),
3008 "xchg{l}\t{$val, $ptr|$ptr, $val}",
3009 [(set GR32:$dst, (atomic_swap_32 addr:$ptr, GR32:$val))]>;
3010def XCHG16rm : I<0x87, MRMSrcMem, (outs GR16:$dst), (ins i16mem:$ptr, GR16:$val),
3011 "xchg{w}\t{$val, $ptr|$ptr, $val}",
3012 [(set GR16:$dst, (atomic_swap_16 addr:$ptr, GR16:$val))]>,
3013 OpSize;
3014def XCHG8rm : I<0x86, MRMSrcMem, (outs GR8:$dst), (ins i8mem:$ptr, GR8:$val),
3015 "xchg{b}\t{$val, $ptr|$ptr, $val}",
3016 [(set GR8:$dst, (atomic_swap_8 addr:$ptr, GR8:$val))]>;
3017}
3018
Evan Chengd49dbb82008-04-18 20:55:36 +00003019// Atomic compare and swap.
Andrew Lenharth7dfe23f2008-03-01 21:52:34 +00003020let Defs = [EAX, EFLAGS], Uses = [EAX] in {
Evan Chengd49dbb82008-04-18 20:55:36 +00003021def LCMPXCHG32 : I<0xB1, MRMDestMem, (outs), (ins i32mem:$ptr, GR32:$swap),
Dale Johannesend20e4452008-08-19 18:47:28 +00003022 "lock\n\tcmpxchg{l}\t{$swap, $ptr|$ptr, $swap}",
Evan Cheng09fbdee2008-03-04 03:20:06 +00003023 [(X86cas addr:$ptr, GR32:$swap, 4)]>, TB, LOCK;
Andrew Lenharth7a5a4b22008-03-01 13:37:02 +00003024}
Dale Johannesenf160d802008-10-02 18:53:47 +00003025let Defs = [EAX, EDX, EFLAGS], Uses = [EAX, EBX, ECX, EDX] in {
Anton Korobeynikovc4067392008-07-22 16:22:48 +00003026def LCMPXCHG8B : I<0xC7, MRM1m, (outs), (ins i32mem:$ptr),
Dale Johannesend20e4452008-08-19 18:47:28 +00003027 "lock\n\tcmpxchg8b\t$ptr",
Andrew Lenharth81580822008-03-05 01:15:49 +00003028 [(X86cas8 addr:$ptr)]>, TB, LOCK;
3029}
Andrew Lenharth7dfe23f2008-03-01 21:52:34 +00003030
3031let Defs = [AX, EFLAGS], Uses = [AX] in {
Evan Chengd49dbb82008-04-18 20:55:36 +00003032def LCMPXCHG16 : I<0xB1, MRMDestMem, (outs), (ins i16mem:$ptr, GR16:$swap),
Dale Johannesend20e4452008-08-19 18:47:28 +00003033 "lock\n\tcmpxchg{w}\t{$swap, $ptr|$ptr, $swap}",
Evan Cheng09fbdee2008-03-04 03:20:06 +00003034 [(X86cas addr:$ptr, GR16:$swap, 2)]>, TB, OpSize, LOCK;
Andrew Lenharth7a5a4b22008-03-01 13:37:02 +00003035}
Andrew Lenharth7dfe23f2008-03-01 21:52:34 +00003036let Defs = [AL, EFLAGS], Uses = [AL] in {
Evan Chengd49dbb82008-04-18 20:55:36 +00003037def LCMPXCHG8 : I<0xB0, MRMDestMem, (outs), (ins i8mem:$ptr, GR8:$swap),
Dale Johannesend20e4452008-08-19 18:47:28 +00003038 "lock\n\tcmpxchg{b}\t{$swap, $ptr|$ptr, $swap}",
Evan Cheng09fbdee2008-03-04 03:20:06 +00003039 [(X86cas addr:$ptr, GR8:$swap, 1)]>, TB, LOCK;
Andrew Lenharth7a5a4b22008-03-01 13:37:02 +00003040}
3041
Evan Chengd49dbb82008-04-18 20:55:36 +00003042// Atomic exchange and add
3043let Constraints = "$val = $dst", Defs = [EFLAGS] in {
3044def LXADD32 : I<0xC1, MRMSrcMem, (outs GR32:$dst), (ins i32mem:$ptr, GR32:$val),
Dale Johannesend20e4452008-08-19 18:47:28 +00003045 "lock\n\txadd{l}\t{$val, $ptr|$ptr, $val}",
Mon P Wang6bde9ec2008-06-25 08:15:39 +00003046 [(set GR32:$dst, (atomic_load_add_32 addr:$ptr, GR32:$val))]>,
Evan Chengd49dbb82008-04-18 20:55:36 +00003047 TB, LOCK;
3048def LXADD16 : I<0xC1, MRMSrcMem, (outs GR16:$dst), (ins i16mem:$ptr, GR16:$val),
Dale Johannesend20e4452008-08-19 18:47:28 +00003049 "lock\n\txadd{w}\t{$val, $ptr|$ptr, $val}",
Mon P Wang6bde9ec2008-06-25 08:15:39 +00003050 [(set GR16:$dst, (atomic_load_add_16 addr:$ptr, GR16:$val))]>,
Evan Chengd49dbb82008-04-18 20:55:36 +00003051 TB, OpSize, LOCK;
3052def LXADD8 : I<0xC0, MRMSrcMem, (outs GR8:$dst), (ins i8mem:$ptr, GR8:$val),
Dale Johannesend20e4452008-08-19 18:47:28 +00003053 "lock\n\txadd{b}\t{$val, $ptr|$ptr, $val}",
Mon P Wang6bde9ec2008-06-25 08:15:39 +00003054 [(set GR8:$dst, (atomic_load_add_8 addr:$ptr, GR8:$val))]>,
Evan Chengd49dbb82008-04-18 20:55:36 +00003055 TB, LOCK;
Andrew Lenharth7a5a4b22008-03-01 13:37:02 +00003056}
3057
Mon P Wang6bde9ec2008-06-25 08:15:39 +00003058// Atomic exchange, and, or, xor
Mon P Wang078a62d2008-05-05 19:05:59 +00003059let Constraints = "$val = $dst", Defs = [EFLAGS],
3060 usesCustomDAGSchedInserter = 1 in {
Dan Gohman8aeb61f2008-05-12 20:22:45 +00003061def ATOMAND32 : I<0, Pseudo, (outs GR32:$dst),(ins i32mem:$ptr, GR32:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003062 "#ATOMAND32 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003063 [(set GR32:$dst, (atomic_load_and_32 addr:$ptr, GR32:$val))]>;
Dan Gohman8aeb61f2008-05-12 20:22:45 +00003064def ATOMOR32 : I<0, Pseudo, (outs GR32:$dst),(ins i32mem:$ptr, GR32:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003065 "#ATOMOR32 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003066 [(set GR32:$dst, (atomic_load_or_32 addr:$ptr, GR32:$val))]>;
Dan Gohman8aeb61f2008-05-12 20:22:45 +00003067def ATOMXOR32 : I<0, Pseudo,(outs GR32:$dst),(ins i32mem:$ptr, GR32:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003068 "#ATOMXOR32 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003069 [(set GR32:$dst, (atomic_load_xor_32 addr:$ptr, GR32:$val))]>;
Andrew Lenharthaf02d592008-06-14 05:48:15 +00003070def ATOMNAND32 : I<0, Pseudo,(outs GR32:$dst),(ins i32mem:$ptr, GR32:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003071 "#ATOMNAND32 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003072 [(set GR32:$dst, (atomic_load_nand_32 addr:$ptr, GR32:$val))]>;
Dan Gohman8aeb61f2008-05-12 20:22:45 +00003073def ATOMMIN32: I<0, Pseudo, (outs GR32:$dst), (ins i32mem:$ptr, GR32:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003074 "#ATOMMIN32 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003075 [(set GR32:$dst, (atomic_load_min_32 addr:$ptr, GR32:$val))]>;
Dan Gohman8aeb61f2008-05-12 20:22:45 +00003076def ATOMMAX32: I<0, Pseudo, (outs GR32:$dst),(ins i32mem:$ptr, GR32:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003077 "#ATOMMAX32 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003078 [(set GR32:$dst, (atomic_load_max_32 addr:$ptr, GR32:$val))]>;
Dan Gohman8aeb61f2008-05-12 20:22:45 +00003079def ATOMUMIN32: I<0, Pseudo, (outs GR32:$dst),(ins i32mem:$ptr, GR32:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003080 "#ATOMUMIN32 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003081 [(set GR32:$dst, (atomic_load_umin_32 addr:$ptr, GR32:$val))]>;
Dan Gohman8aeb61f2008-05-12 20:22:45 +00003082def ATOMUMAX32: I<0, Pseudo, (outs GR32:$dst),(ins i32mem:$ptr, GR32:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003083 "#ATOMUMAX32 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003084 [(set GR32:$dst, (atomic_load_umax_32 addr:$ptr, GR32:$val))]>;
Dale Johannesend20e4452008-08-19 18:47:28 +00003085
3086def ATOMAND16 : I<0, Pseudo, (outs GR16:$dst),(ins i16mem:$ptr, GR16:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003087 "#ATOMAND16 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003088 [(set GR16:$dst, (atomic_load_and_16 addr:$ptr, GR16:$val))]>;
Dale Johannesend20e4452008-08-19 18:47:28 +00003089def ATOMOR16 : I<0, Pseudo, (outs GR16:$dst),(ins i16mem:$ptr, GR16:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003090 "#ATOMOR16 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003091 [(set GR16:$dst, (atomic_load_or_16 addr:$ptr, GR16:$val))]>;
Dale Johannesend20e4452008-08-19 18:47:28 +00003092def ATOMXOR16 : I<0, Pseudo,(outs GR16:$dst),(ins i16mem:$ptr, GR16:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003093 "#ATOMXOR16 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003094 [(set GR16:$dst, (atomic_load_xor_16 addr:$ptr, GR16:$val))]>;
Dale Johannesend20e4452008-08-19 18:47:28 +00003095def ATOMNAND16 : I<0, Pseudo,(outs GR16:$dst),(ins i16mem:$ptr, GR16:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003096 "#ATOMNAND16 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003097 [(set GR16:$dst, (atomic_load_nand_16 addr:$ptr, GR16:$val))]>;
Dale Johannesend20e4452008-08-19 18:47:28 +00003098def ATOMMIN16: I<0, Pseudo, (outs GR16:$dst), (ins i16mem:$ptr, GR16:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003099 "#ATOMMIN16 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003100 [(set GR16:$dst, (atomic_load_min_16 addr:$ptr, GR16:$val))]>;
Dale Johannesend20e4452008-08-19 18:47:28 +00003101def ATOMMAX16: I<0, Pseudo, (outs GR16:$dst),(ins i16mem:$ptr, GR16:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003102 "#ATOMMAX16 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003103 [(set GR16:$dst, (atomic_load_max_16 addr:$ptr, GR16:$val))]>;
Dale Johannesend20e4452008-08-19 18:47:28 +00003104def ATOMUMIN16: I<0, Pseudo, (outs GR16:$dst),(ins i16mem:$ptr, GR16:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003105 "#ATOMUMIN16 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003106 [(set GR16:$dst, (atomic_load_umin_16 addr:$ptr, GR16:$val))]>;
Dale Johannesend20e4452008-08-19 18:47:28 +00003107def ATOMUMAX16: I<0, Pseudo, (outs GR16:$dst),(ins i16mem:$ptr, GR16:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003108 "#ATOMUMAX16 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003109 [(set GR16:$dst, (atomic_load_umax_16 addr:$ptr, GR16:$val))]>;
Dale Johannesend20e4452008-08-19 18:47:28 +00003110
3111def ATOMAND8 : I<0, Pseudo, (outs GR8:$dst),(ins i8mem:$ptr, GR8:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003112 "#ATOMAND8 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003113 [(set GR8:$dst, (atomic_load_and_8 addr:$ptr, GR8:$val))]>;
Dale Johannesend20e4452008-08-19 18:47:28 +00003114def ATOMOR8 : I<0, Pseudo, (outs GR8:$dst),(ins i8mem:$ptr, GR8:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003115 "#ATOMOR8 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003116 [(set GR8:$dst, (atomic_load_or_8 addr:$ptr, GR8:$val))]>;
Dale Johannesend20e4452008-08-19 18:47:28 +00003117def ATOMXOR8 : I<0, Pseudo,(outs GR8:$dst),(ins i8mem:$ptr, GR8:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003118 "#ATOMXOR8 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003119 [(set GR8:$dst, (atomic_load_xor_8 addr:$ptr, GR8:$val))]>;
Dale Johannesend20e4452008-08-19 18:47:28 +00003120def ATOMNAND8 : I<0, Pseudo,(outs GR8:$dst),(ins i8mem:$ptr, GR8:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003121 "#ATOMNAND8 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003122 [(set GR8:$dst, (atomic_load_nand_8 addr:$ptr, GR8:$val))]>;
Mon P Wang078a62d2008-05-05 19:05:59 +00003123}
3124
Dale Johannesenf160d802008-10-02 18:53:47 +00003125let Constraints = "$val1 = $dst1, $val2 = $dst2",
3126 Defs = [EFLAGS, EAX, EBX, ECX, EDX],
3127 Uses = [EAX, EBX, ECX, EDX],
Dale Johannesen44eb5372008-10-03 19:41:08 +00003128 mayLoad = 1, mayStore = 1,
Dale Johannesenf160d802008-10-02 18:53:47 +00003129 usesCustomDAGSchedInserter = 1 in {
3130def ATOMAND6432 : I<0, Pseudo, (outs GR32:$dst1, GR32:$dst2),
3131 (ins i64mem:$ptr, GR32:$val1, GR32:$val2),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003132 "#ATOMAND6432 PSEUDO!", []>;
Dale Johannesenf160d802008-10-02 18:53:47 +00003133def ATOMOR6432 : I<0, Pseudo, (outs GR32:$dst1, GR32:$dst2),
3134 (ins i64mem:$ptr, GR32:$val1, GR32:$val2),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003135 "#ATOMOR6432 PSEUDO!", []>;
Dale Johannesenf160d802008-10-02 18:53:47 +00003136def ATOMXOR6432 : I<0, Pseudo, (outs GR32:$dst1, GR32:$dst2),
3137 (ins i64mem:$ptr, GR32:$val1, GR32:$val2),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003138 "#ATOMXOR6432 PSEUDO!", []>;
Dale Johannesenf160d802008-10-02 18:53:47 +00003139def ATOMNAND6432 : I<0, Pseudo, (outs GR32:$dst1, GR32:$dst2),
3140 (ins i64mem:$ptr, GR32:$val1, GR32:$val2),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003141 "#ATOMNAND6432 PSEUDO!", []>;
Dale Johannesenf160d802008-10-02 18:53:47 +00003142def ATOMADD6432 : I<0, Pseudo, (outs GR32:$dst1, GR32:$dst2),
3143 (ins i64mem:$ptr, GR32:$val1, GR32:$val2),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003144 "#ATOMADD6432 PSEUDO!", []>;
Dale Johannesenf160d802008-10-02 18:53:47 +00003145def ATOMSUB6432 : I<0, Pseudo, (outs GR32:$dst1, GR32:$dst2),
3146 (ins i64mem:$ptr, GR32:$val1, GR32:$val2),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003147 "#ATOMSUB6432 PSEUDO!", []>;
Dale Johannesen51c58ee2008-10-03 22:25:52 +00003148def ATOMSWAP6432 : I<0, Pseudo, (outs GR32:$dst1, GR32:$dst2),
3149 (ins i64mem:$ptr, GR32:$val1, GR32:$val2),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003150 "#ATOMSWAP6432 PSEUDO!", []>;
Dale Johannesenf160d802008-10-02 18:53:47 +00003151}
3152
Andrew Lenharthe44f3902008-02-21 06:45:13 +00003153//===----------------------------------------------------------------------===//
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003154// Non-Instruction Patterns
3155//===----------------------------------------------------------------------===//
3156
Bill Wendlingfef06052008-09-16 21:48:12 +00003157// ConstantPool GlobalAddress, ExternalSymbol, and JumpTable
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003158def : Pat<(i32 (X86Wrapper tconstpool :$dst)), (MOV32ri tconstpool :$dst)>;
3159def : Pat<(i32 (X86Wrapper tjumptable :$dst)), (MOV32ri tjumptable :$dst)>;
Nate Begemanb52948972008-04-12 00:47:57 +00003160def : Pat<(i32 (X86Wrapper tglobaltlsaddr:$dst)),(MOV32ri tglobaltlsaddr:$dst)>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003161def : Pat<(i32 (X86Wrapper tglobaladdr :$dst)), (MOV32ri tglobaladdr :$dst)>;
3162def : Pat<(i32 (X86Wrapper texternalsym:$dst)), (MOV32ri texternalsym:$dst)>;
3163
3164def : Pat<(add GR32:$src1, (X86Wrapper tconstpool:$src2)),
3165 (ADD32ri GR32:$src1, tconstpool:$src2)>;
3166def : Pat<(add GR32:$src1, (X86Wrapper tjumptable:$src2)),
3167 (ADD32ri GR32:$src1, tjumptable:$src2)>;
3168def : Pat<(add GR32:$src1, (X86Wrapper tglobaladdr :$src2)),
3169 (ADD32ri GR32:$src1, tglobaladdr:$src2)>;
3170def : Pat<(add GR32:$src1, (X86Wrapper texternalsym:$src2)),
3171 (ADD32ri GR32:$src1, texternalsym:$src2)>;
3172
3173def : Pat<(store (i32 (X86Wrapper tglobaladdr:$src)), addr:$dst),
3174 (MOV32mi addr:$dst, tglobaladdr:$src)>;
3175def : Pat<(store (i32 (X86Wrapper texternalsym:$src)), addr:$dst),
3176 (MOV32mi addr:$dst, texternalsym:$src)>;
3177
3178// Calls
Arnold Schwaighofere2d6bbb2007-10-11 19:40:01 +00003179// tailcall stuff
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003180def : Pat<(X86tailcall GR32:$dst),
Arnold Schwaighofere2d6bbb2007-10-11 19:40:01 +00003181 (TAILCALL)>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003182
3183def : Pat<(X86tailcall (i32 tglobaladdr:$dst)),
Arnold Schwaighofere2d6bbb2007-10-11 19:40:01 +00003184 (TAILCALL)>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003185def : Pat<(X86tailcall (i32 texternalsym:$dst)),
Arnold Schwaighofere2d6bbb2007-10-11 19:40:01 +00003186 (TAILCALL)>;
3187
3188def : Pat<(X86tcret GR32:$dst, imm:$off),
3189 (TCRETURNri GR32:$dst, imm:$off)>;
3190
3191def : Pat<(X86tcret (i32 tglobaladdr:$dst), imm:$off),
3192 (TCRETURNdi texternalsym:$dst, imm:$off)>;
3193
3194def : Pat<(X86tcret (i32 texternalsym:$dst), imm:$off),
3195 (TCRETURNdi texternalsym:$dst, imm:$off)>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003196
3197def : Pat<(X86call (i32 tglobaladdr:$dst)),
3198 (CALLpcrel32 tglobaladdr:$dst)>;
3199def : Pat<(X86call (i32 texternalsym:$dst)),
3200 (CALLpcrel32 texternalsym:$dst)>;
3201
3202// X86 specific add which produces a flag.
3203def : Pat<(addc GR32:$src1, GR32:$src2),
3204 (ADD32rr GR32:$src1, GR32:$src2)>;
3205def : Pat<(addc GR32:$src1, (load addr:$src2)),
3206 (ADD32rm GR32:$src1, addr:$src2)>;
3207def : Pat<(addc GR32:$src1, imm:$src2),
3208 (ADD32ri GR32:$src1, imm:$src2)>;
3209def : Pat<(addc GR32:$src1, i32immSExt8:$src2),
3210 (ADD32ri8 GR32:$src1, i32immSExt8:$src2)>;
3211
3212def : Pat<(subc GR32:$src1, GR32:$src2),
3213 (SUB32rr GR32:$src1, GR32:$src2)>;
3214def : Pat<(subc GR32:$src1, (load addr:$src2)),
3215 (SUB32rm GR32:$src1, addr:$src2)>;
3216def : Pat<(subc GR32:$src1, imm:$src2),
3217 (SUB32ri GR32:$src1, imm:$src2)>;
3218def : Pat<(subc GR32:$src1, i32immSExt8:$src2),
3219 (SUB32ri8 GR32:$src1, i32immSExt8:$src2)>;
3220
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003221// Comparisons.
3222
3223// TEST R,R is smaller than CMP R,0
Evan Cheng621216e2007-09-29 00:00:36 +00003224def : Pat<(parallel (X86cmp GR8:$src1, 0), (implicit EFLAGS)),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003225 (TEST8rr GR8:$src1, GR8:$src1)>;
Evan Cheng621216e2007-09-29 00:00:36 +00003226def : Pat<(parallel (X86cmp GR16:$src1, 0), (implicit EFLAGS)),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003227 (TEST16rr GR16:$src1, GR16:$src1)>;
Evan Cheng621216e2007-09-29 00:00:36 +00003228def : Pat<(parallel (X86cmp GR32:$src1, 0), (implicit EFLAGS)),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003229 (TEST32rr GR32:$src1, GR32:$src1)>;
3230
Dan Gohman0a3c5222009-01-07 01:00:24 +00003231// Conditional moves with folded loads with operands swapped and conditions
3232// inverted.
3233def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_B, EFLAGS),
3234 (CMOVAE16rm GR16:$src2, addr:$src1)>;
3235def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_B, EFLAGS),
3236 (CMOVAE32rm GR32:$src2, addr:$src1)>;
3237def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_AE, EFLAGS),
3238 (CMOVB16rm GR16:$src2, addr:$src1)>;
3239def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_AE, EFLAGS),
3240 (CMOVB32rm GR32:$src2, addr:$src1)>;
3241def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_E, EFLAGS),
3242 (CMOVNE16rm GR16:$src2, addr:$src1)>;
3243def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_E, EFLAGS),
3244 (CMOVNE32rm GR32:$src2, addr:$src1)>;
3245def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_NE, EFLAGS),
3246 (CMOVE16rm GR16:$src2, addr:$src1)>;
3247def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_NE, EFLAGS),
3248 (CMOVE32rm GR32:$src2, addr:$src1)>;
3249def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_BE, EFLAGS),
3250 (CMOVA16rm GR16:$src2, addr:$src1)>;
3251def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_BE, EFLAGS),
3252 (CMOVA32rm GR32:$src2, addr:$src1)>;
3253def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_A, EFLAGS),
3254 (CMOVBE16rm GR16:$src2, addr:$src1)>;
3255def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_A, EFLAGS),
3256 (CMOVBE32rm GR32:$src2, addr:$src1)>;
3257def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_L, EFLAGS),
3258 (CMOVGE16rm GR16:$src2, addr:$src1)>;
3259def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_L, EFLAGS),
3260 (CMOVGE32rm GR32:$src2, addr:$src1)>;
3261def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_GE, EFLAGS),
3262 (CMOVL16rm GR16:$src2, addr:$src1)>;
3263def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_GE, EFLAGS),
3264 (CMOVL32rm GR32:$src2, addr:$src1)>;
3265def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_LE, EFLAGS),
3266 (CMOVG16rm GR16:$src2, addr:$src1)>;
3267def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_LE, EFLAGS),
3268 (CMOVG32rm GR32:$src2, addr:$src1)>;
3269def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_G, EFLAGS),
3270 (CMOVLE16rm GR16:$src2, addr:$src1)>;
3271def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_G, EFLAGS),
3272 (CMOVLE32rm GR32:$src2, addr:$src1)>;
3273def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_P, EFLAGS),
3274 (CMOVNP16rm GR16:$src2, addr:$src1)>;
3275def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_P, EFLAGS),
3276 (CMOVNP32rm GR32:$src2, addr:$src1)>;
3277def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_NP, EFLAGS),
3278 (CMOVP16rm GR16:$src2, addr:$src1)>;
3279def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_NP, EFLAGS),
3280 (CMOVP32rm GR32:$src2, addr:$src1)>;
3281def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_S, EFLAGS),
3282 (CMOVNS16rm GR16:$src2, addr:$src1)>;
3283def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_S, EFLAGS),
3284 (CMOVNS32rm GR32:$src2, addr:$src1)>;
3285def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_NS, EFLAGS),
3286 (CMOVS16rm GR16:$src2, addr:$src1)>;
3287def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_NS, EFLAGS),
3288 (CMOVS32rm GR32:$src2, addr:$src1)>;
3289def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_O, EFLAGS),
3290 (CMOVNO16rm GR16:$src2, addr:$src1)>;
3291def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_O, EFLAGS),
3292 (CMOVNO32rm GR32:$src2, addr:$src1)>;
3293def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_NO, EFLAGS),
3294 (CMOVO16rm GR16:$src2, addr:$src1)>;
3295def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_NO, EFLAGS),
3296 (CMOVO32rm GR32:$src2, addr:$src1)>;
3297
Duncan Sands082524c2008-01-23 20:39:46 +00003298// zextload bool -> zextload byte
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003299def : Pat<(zextloadi8i1 addr:$src), (MOV8rm addr:$src)>;
3300def : Pat<(zextloadi16i1 addr:$src), (MOVZX16rm8 addr:$src)>;
3301def : Pat<(zextloadi32i1 addr:$src), (MOVZX32rm8 addr:$src)>;
3302
3303// extload bool -> extload byte
3304def : Pat<(extloadi8i1 addr:$src), (MOV8rm addr:$src)>;
Bill Wendlingce1c5c12008-08-22 20:51:05 +00003305def : Pat<(extloadi16i1 addr:$src), (MOVZX16rm8 addr:$src)>,
3306 Requires<[In32BitMode]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003307def : Pat<(extloadi32i1 addr:$src), (MOVZX32rm8 addr:$src)>;
Bill Wendlingce1c5c12008-08-22 20:51:05 +00003308def : Pat<(extloadi16i8 addr:$src), (MOVZX16rm8 addr:$src)>,
3309 Requires<[In32BitMode]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003310def : Pat<(extloadi32i8 addr:$src), (MOVZX32rm8 addr:$src)>;
3311def : Pat<(extloadi32i16 addr:$src), (MOVZX32rm16 addr:$src)>;
3312
Dan Gohmandd612bb2008-08-20 21:27:32 +00003313// anyext
Bill Wendlingce1c5c12008-08-22 20:51:05 +00003314def : Pat<(i16 (anyext GR8 :$src)), (MOVZX16rr8 GR8 :$src)>,
3315 Requires<[In32BitMode]>;
3316def : Pat<(i32 (anyext GR8 :$src)), (MOVZX32rr8 GR8 :$src)>,
3317 Requires<[In32BitMode]>;
Dan Gohmandd612bb2008-08-20 21:27:32 +00003318def : Pat<(i32 (anyext GR16:$src)),
3319 (INSERT_SUBREG (i32 (IMPLICIT_DEF)), GR16:$src, x86_subreg_16bit)>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003320
Evan Chengf2abee72007-12-13 00:43:27 +00003321// (and (i32 load), 255) -> (zextload i8)
Evan Cheng1e5e5452008-09-29 17:26:18 +00003322def : Pat<(i32 (and (nvloadi32 addr:$src), (i32 255))),
3323 (MOVZX32rm8 addr:$src)>;
3324def : Pat<(i32 (and (nvloadi32 addr:$src), (i32 65535))),
3325 (MOVZX32rm16 addr:$src)>;
Evan Chengf2abee72007-12-13 00:43:27 +00003326
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003327//===----------------------------------------------------------------------===//
3328// Some peepholes
3329//===----------------------------------------------------------------------===//
3330
Dan Gohman5a5e6e92008-10-17 01:33:43 +00003331// Odd encoding trick: -128 fits into an 8-bit immediate field while
3332// +128 doesn't, so in this special case use a sub instead of an add.
3333def : Pat<(add GR16:$src1, 128),
3334 (SUB16ri8 GR16:$src1, -128)>;
3335def : Pat<(store (add (loadi16 addr:$dst), 128), addr:$dst),
3336 (SUB16mi8 addr:$dst, -128)>;
3337def : Pat<(add GR32:$src1, 128),
3338 (SUB32ri8 GR32:$src1, -128)>;
3339def : Pat<(store (add (loadi32 addr:$dst), 128), addr:$dst),
3340 (SUB32mi8 addr:$dst, -128)>;
3341
Dan Gohman9203ab42008-07-30 18:09:17 +00003342// r & (2^16-1) ==> movz
3343def : Pat<(and GR32:$src1, 0xffff),
Dan Gohmandd612bb2008-08-20 21:27:32 +00003344 (MOVZX32rr16 (i16 (EXTRACT_SUBREG GR32:$src1, x86_subreg_16bit)))>;
Dan Gohman5beb1ff2008-08-06 18:27:21 +00003345// r & (2^8-1) ==> movz
3346def : Pat<(and GR32:$src1, 0xff),
Dan Gohmandd612bb2008-08-20 21:27:32 +00003347 (MOVZX32rr8 (i8 (EXTRACT_SUBREG (MOV32to32_ GR32:$src1),
3348 x86_subreg_8bit)))>,
Dan Gohman5beb1ff2008-08-06 18:27:21 +00003349 Requires<[In32BitMode]>;
3350// r & (2^8-1) ==> movz
3351def : Pat<(and GR16:$src1, 0xff),
Dan Gohmandd612bb2008-08-20 21:27:32 +00003352 (MOVZX16rr8 (i8 (EXTRACT_SUBREG (MOV16to16_ GR16:$src1),
3353 x86_subreg_8bit)))>,
3354 Requires<[In32BitMode]>;
3355
3356// sext_inreg patterns
3357def : Pat<(sext_inreg GR32:$src, i16),
3358 (MOVSX32rr16 (i16 (EXTRACT_SUBREG GR32:$src, x86_subreg_16bit)))>;
3359def : Pat<(sext_inreg GR32:$src, i8),
3360 (MOVSX32rr8 (i8 (EXTRACT_SUBREG (MOV32to32_ GR32:$src),
3361 x86_subreg_8bit)))>,
3362 Requires<[In32BitMode]>;
3363def : Pat<(sext_inreg GR16:$src, i8),
3364 (MOVSX16rr8 (i8 (EXTRACT_SUBREG (MOV16to16_ GR16:$src),
3365 x86_subreg_8bit)))>,
3366 Requires<[In32BitMode]>;
3367
3368// trunc patterns
3369def : Pat<(i16 (trunc GR32:$src)),
3370 (i16 (EXTRACT_SUBREG GR32:$src, x86_subreg_16bit))>;
3371def : Pat<(i8 (trunc GR32:$src)),
3372 (i8 (EXTRACT_SUBREG (MOV32to32_ GR32:$src), x86_subreg_8bit))>,
3373 Requires<[In32BitMode]>;
3374def : Pat<(i8 (trunc GR16:$src)),
3375 (i8 (EXTRACT_SUBREG (MOV16to16_ GR16:$src), x86_subreg_8bit))>,
Dan Gohman5beb1ff2008-08-06 18:27:21 +00003376 Requires<[In32BitMode]>;
Dan Gohman9203ab42008-07-30 18:09:17 +00003377
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003378// (shl x, 1) ==> (add x, x)
3379def : Pat<(shl GR8 :$src1, (i8 1)), (ADD8rr GR8 :$src1, GR8 :$src1)>;
3380def : Pat<(shl GR16:$src1, (i8 1)), (ADD16rr GR16:$src1, GR16:$src1)>;
3381def : Pat<(shl GR32:$src1, (i8 1)), (ADD32rr GR32:$src1, GR32:$src1)>;
3382
Evan Cheng76a64c72008-08-30 02:03:58 +00003383// (shl x (and y, 31)) ==> (shl x, y)
3384def : Pat<(shl GR8:$src1, (and CL:$amt, 31)),
3385 (SHL8rCL GR8:$src1)>;
3386def : Pat<(shl GR16:$src1, (and CL:$amt, 31)),
3387 (SHL16rCL GR16:$src1)>;
3388def : Pat<(shl GR32:$src1, (and CL:$amt, 31)),
3389 (SHL32rCL GR32:$src1)>;
3390def : Pat<(store (shl (loadi8 addr:$dst), (and CL:$amt, 31)), addr:$dst),
3391 (SHL8mCL addr:$dst)>;
3392def : Pat<(store (shl (loadi16 addr:$dst), (and CL:$amt, 31)), addr:$dst),
3393 (SHL16mCL addr:$dst)>;
3394def : Pat<(store (shl (loadi32 addr:$dst), (and CL:$amt, 31)), addr:$dst),
3395 (SHL32mCL addr:$dst)>;
3396
3397def : Pat<(srl GR8:$src1, (and CL:$amt, 31)),
3398 (SHR8rCL GR8:$src1)>;
3399def : Pat<(srl GR16:$src1, (and CL:$amt, 31)),
3400 (SHR16rCL GR16:$src1)>;
3401def : Pat<(srl GR32:$src1, (and CL:$amt, 31)),
3402 (SHR32rCL GR32:$src1)>;
3403def : Pat<(store (srl (loadi8 addr:$dst), (and CL:$amt, 31)), addr:$dst),
3404 (SHR8mCL addr:$dst)>;
3405def : Pat<(store (srl (loadi16 addr:$dst), (and CL:$amt, 31)), addr:$dst),
3406 (SHR16mCL addr:$dst)>;
3407def : Pat<(store (srl (loadi32 addr:$dst), (and CL:$amt, 31)), addr:$dst),
3408 (SHR32mCL addr:$dst)>;
3409
3410def : Pat<(sra GR8:$src1, (and CL:$amt, 31)),
3411 (SAR8rCL GR8:$src1)>;
3412def : Pat<(sra GR16:$src1, (and CL:$amt, 31)),
3413 (SAR16rCL GR16:$src1)>;
3414def : Pat<(sra GR32:$src1, (and CL:$amt, 31)),
3415 (SAR32rCL GR32:$src1)>;
3416def : Pat<(store (sra (loadi8 addr:$dst), (and CL:$amt, 31)), addr:$dst),
3417 (SAR8mCL addr:$dst)>;
3418def : Pat<(store (sra (loadi16 addr:$dst), (and CL:$amt, 31)), addr:$dst),
3419 (SAR16mCL addr:$dst)>;
3420def : Pat<(store (sra (loadi32 addr:$dst), (and CL:$amt, 31)), addr:$dst),
3421 (SAR32mCL addr:$dst)>;
3422
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003423// (or (x >> c) | (y << (32 - c))) ==> (shrd32 x, y, c)
3424def : Pat<(or (srl GR32:$src1, CL:$amt),
3425 (shl GR32:$src2, (sub 32, CL:$amt))),
3426 (SHRD32rrCL GR32:$src1, GR32:$src2)>;
3427
3428def : Pat<(store (or (srl (loadi32 addr:$dst), CL:$amt),
3429 (shl GR32:$src2, (sub 32, CL:$amt))), addr:$dst),
3430 (SHRD32mrCL addr:$dst, GR32:$src2)>;
3431
Dan Gohman921581d2008-10-17 01:23:35 +00003432def : Pat<(or (srl GR32:$src1, (i8 (trunc ECX:$amt))),
3433 (shl GR32:$src2, (i8 (trunc (sub 32, ECX:$amt))))),
3434 (SHRD32rrCL GR32:$src1, GR32:$src2)>;
3435
3436def : Pat<(store (or (srl (loadi32 addr:$dst), (i8 (trunc ECX:$amt))),
3437 (shl GR32:$src2, (i8 (trunc (sub 32, ECX:$amt))))),
3438 addr:$dst),
3439 (SHRD32mrCL addr:$dst, GR32:$src2)>;
3440
3441def : Pat<(shrd GR32:$src1, (i8 imm:$amt1), GR32:$src2, (i8 imm:$amt2)),
3442 (SHRD32rri8 GR32:$src1, GR32:$src2, (i8 imm:$amt1))>;
3443
3444def : Pat<(store (shrd (loadi32 addr:$dst), (i8 imm:$amt1),
3445 GR32:$src2, (i8 imm:$amt2)), addr:$dst),
3446 (SHRD32mri8 addr:$dst, GR32:$src2, (i8 imm:$amt1))>;
3447
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003448// (or (x << c) | (y >> (32 - c))) ==> (shld32 x, y, c)
3449def : Pat<(or (shl GR32:$src1, CL:$amt),
3450 (srl GR32:$src2, (sub 32, CL:$amt))),
3451 (SHLD32rrCL GR32:$src1, GR32:$src2)>;
3452
3453def : Pat<(store (or (shl (loadi32 addr:$dst), CL:$amt),
3454 (srl GR32:$src2, (sub 32, CL:$amt))), addr:$dst),
3455 (SHLD32mrCL addr:$dst, GR32:$src2)>;
3456
Dan Gohman921581d2008-10-17 01:23:35 +00003457def : Pat<(or (shl GR32:$src1, (i8 (trunc ECX:$amt))),
3458 (srl GR32:$src2, (i8 (trunc (sub 32, ECX:$amt))))),
3459 (SHLD32rrCL GR32:$src1, GR32:$src2)>;
3460
3461def : Pat<(store (or (shl (loadi32 addr:$dst), (i8 (trunc ECX:$amt))),
3462 (srl GR32:$src2, (i8 (trunc (sub 32, ECX:$amt))))),
3463 addr:$dst),
3464 (SHLD32mrCL addr:$dst, GR32:$src2)>;
3465
3466def : Pat<(shld GR32:$src1, (i8 imm:$amt1), GR32:$src2, (i8 imm:$amt2)),
3467 (SHLD32rri8 GR32:$src1, GR32:$src2, (i8 imm:$amt1))>;
3468
3469def : Pat<(store (shld (loadi32 addr:$dst), (i8 imm:$amt1),
3470 GR32:$src2, (i8 imm:$amt2)), addr:$dst),
3471 (SHLD32mri8 addr:$dst, GR32:$src2, (i8 imm:$amt1))>;
3472
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003473// (or (x >> c) | (y << (16 - c))) ==> (shrd16 x, y, c)
3474def : Pat<(or (srl GR16:$src1, CL:$amt),
3475 (shl GR16:$src2, (sub 16, CL:$amt))),
3476 (SHRD16rrCL GR16:$src1, GR16:$src2)>;
3477
3478def : Pat<(store (or (srl (loadi16 addr:$dst), CL:$amt),
3479 (shl GR16:$src2, (sub 16, CL:$amt))), addr:$dst),
3480 (SHRD16mrCL addr:$dst, GR16:$src2)>;
3481
Dan Gohman921581d2008-10-17 01:23:35 +00003482def : Pat<(or (srl GR16:$src1, (i8 (trunc CX:$amt))),
3483 (shl GR16:$src2, (i8 (trunc (sub 16, CX:$amt))))),
3484 (SHRD16rrCL GR16:$src1, GR16:$src2)>;
3485
3486def : Pat<(store (or (srl (loadi16 addr:$dst), (i8 (trunc CX:$amt))),
3487 (shl GR16:$src2, (i8 (trunc (sub 16, CX:$amt))))),
3488 addr:$dst),
3489 (SHRD16mrCL addr:$dst, GR16:$src2)>;
3490
3491def : Pat<(shrd GR16:$src1, (i8 imm:$amt1), GR16:$src2, (i8 imm:$amt2)),
3492 (SHRD16rri8 GR16:$src1, GR16:$src2, (i8 imm:$amt1))>;
3493
3494def : Pat<(store (shrd (loadi16 addr:$dst), (i8 imm:$amt1),
3495 GR16:$src2, (i8 imm:$amt2)), addr:$dst),
3496 (SHRD16mri8 addr:$dst, GR16:$src2, (i8 imm:$amt1))>;
3497
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003498// (or (x << c) | (y >> (16 - c))) ==> (shld16 x, y, c)
3499def : Pat<(or (shl GR16:$src1, CL:$amt),
3500 (srl GR16:$src2, (sub 16, CL:$amt))),
3501 (SHLD16rrCL GR16:$src1, GR16:$src2)>;
3502
3503def : Pat<(store (or (shl (loadi16 addr:$dst), CL:$amt),
3504 (srl GR16:$src2, (sub 16, CL:$amt))), addr:$dst),
3505 (SHLD16mrCL addr:$dst, GR16:$src2)>;
3506
Dan Gohman921581d2008-10-17 01:23:35 +00003507def : Pat<(or (shl GR16:$src1, (i8 (trunc CX:$amt))),
3508 (srl GR16:$src2, (i8 (trunc (sub 16, CX:$amt))))),
3509 (SHLD16rrCL GR16:$src1, GR16:$src2)>;
3510
3511def : Pat<(store (or (shl (loadi16 addr:$dst), (i8 (trunc CX:$amt))),
3512 (srl GR16:$src2, (i8 (trunc (sub 16, CX:$amt))))),
3513 addr:$dst),
3514 (SHLD16mrCL addr:$dst, GR16:$src2)>;
3515
3516def : Pat<(shld GR16:$src1, (i8 imm:$amt1), GR16:$src2, (i8 imm:$amt2)),
3517 (SHLD16rri8 GR16:$src1, GR16:$src2, (i8 imm:$amt1))>;
3518
3519def : Pat<(store (shld (loadi16 addr:$dst), (i8 imm:$amt1),
3520 GR16:$src2, (i8 imm:$amt2)), addr:$dst),
3521 (SHLD16mri8 addr:$dst, GR16:$src2, (i8 imm:$amt1))>;
3522
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003523//===----------------------------------------------------------------------===//
Dan Gohman99a12192009-03-04 19:44:21 +00003524// EFLAGS-defining Patterns
Bill Wendlingf5399032008-12-12 21:15:41 +00003525//===----------------------------------------------------------------------===//
3526
Dan Gohman99a12192009-03-04 19:44:21 +00003527// Register-Register Addition with EFLAGS result
3528def : Pat<(parallel (X86add_flag GR8:$src1, GR8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003529 (implicit EFLAGS)),
3530 (ADD8rr GR8:$src1, GR8:$src2)>;
3531
Dan Gohman99a12192009-03-04 19:44:21 +00003532// Register-Register Addition with EFLAGS result
3533def : Pat<(parallel (X86add_flag GR16:$src1, GR16:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003534 (implicit EFLAGS)),
3535 (ADD16rr GR16:$src1, GR16:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003536def : Pat<(parallel (X86add_flag GR32:$src1, GR32:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003537 (implicit EFLAGS)),
3538 (ADD32rr GR32:$src1, GR32:$src2)>;
3539
Dan Gohman99a12192009-03-04 19:44:21 +00003540// Register-Memory Addition with EFLAGS result
3541def : Pat<(parallel (X86add_flag GR8:$src1, (loadi8 addr:$src2)),
Bill Wendlingf5399032008-12-12 21:15:41 +00003542 (implicit EFLAGS)),
3543 (ADD8rm GR8:$src1, addr:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003544def : Pat<(parallel (X86add_flag GR16:$src1, (loadi16 addr:$src2)),
Bill Wendlingf5399032008-12-12 21:15:41 +00003545 (implicit EFLAGS)),
3546 (ADD16rm GR16:$src1, addr:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003547def : Pat<(parallel (X86add_flag GR32:$src1, (loadi32 addr:$src2)),
Bill Wendlingf5399032008-12-12 21:15:41 +00003548 (implicit EFLAGS)),
3549 (ADD32rm GR32:$src1, addr:$src2)>;
3550
Dan Gohman99a12192009-03-04 19:44:21 +00003551// Register-Integer Addition with EFLAGS result
3552def : Pat<(parallel (X86add_flag GR8:$src1, imm:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003553 (implicit EFLAGS)),
3554 (ADD8ri GR8:$src1, imm:$src2)>;
3555
Dan Gohman99a12192009-03-04 19:44:21 +00003556// Register-Integer Addition with EFLAGS result
3557def : Pat<(parallel (X86add_flag GR16:$src1, imm:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003558 (implicit EFLAGS)),
3559 (ADD16ri GR16:$src1, imm:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003560def : Pat<(parallel (X86add_flag GR32:$src1, imm:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003561 (implicit EFLAGS)),
3562 (ADD32ri GR32:$src1, imm:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003563def : Pat<(parallel (X86add_flag GR16:$src1, i16immSExt8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003564 (implicit EFLAGS)),
3565 (ADD16ri8 GR16:$src1, i16immSExt8:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003566def : Pat<(parallel (X86add_flag GR32:$src1, i32immSExt8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003567 (implicit EFLAGS)),
3568 (ADD32ri8 GR32:$src1, i32immSExt8:$src2)>;
3569
Dan Gohman99a12192009-03-04 19:44:21 +00003570// Memory-Register Addition with EFLAGS result
3571def : Pat<(parallel (store (X86add_flag (loadi8 addr:$dst), GR8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003572 addr:$dst),
3573 (implicit EFLAGS)),
3574 (ADD8mr addr:$dst, GR8:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003575def : Pat<(parallel (store (X86add_flag (loadi16 addr:$dst), GR16:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003576 addr:$dst),
3577 (implicit EFLAGS)),
3578 (ADD16mr addr:$dst, GR16:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003579def : Pat<(parallel (store (X86add_flag (loadi32 addr:$dst), GR32:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003580 addr:$dst),
3581 (implicit EFLAGS)),
3582 (ADD32mr addr:$dst, GR32:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003583def : Pat<(parallel (store (X86add_flag (loadi8 addr:$dst), imm:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003584 addr:$dst),
3585 (implicit EFLAGS)),
3586 (ADD8mi addr:$dst, imm:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003587def : Pat<(parallel (store (X86add_flag (loadi16 addr:$dst), imm:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003588 addr:$dst),
3589 (implicit EFLAGS)),
3590 (ADD16mi addr:$dst, imm:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003591def : Pat<(parallel (store (X86add_flag (loadi32 addr:$dst), imm:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003592 addr:$dst),
3593 (implicit EFLAGS)),
3594 (ADD32mi addr:$dst, imm:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003595def : Pat<(parallel (store (X86add_flag (loadi16 addr:$dst), i16immSExt8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003596 addr:$dst),
3597 (implicit EFLAGS)),
3598 (ADD16mi8 addr:$dst, i16immSExt8:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003599def : Pat<(parallel (store (X86add_flag (loadi32 addr:$dst), i32immSExt8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003600 addr:$dst),
3601 (implicit EFLAGS)),
3602 (ADD32mi8 addr:$dst, i32immSExt8:$src2)>;
3603
Dan Gohman99a12192009-03-04 19:44:21 +00003604// Register-Register Subtraction with EFLAGS result
3605def : Pat<(parallel (X86sub_flag GR8:$src1, GR8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003606 (implicit EFLAGS)),
3607 (SUB8rr GR8:$src1, GR8:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003608def : Pat<(parallel (X86sub_flag GR16:$src1, GR16:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003609 (implicit EFLAGS)),
3610 (SUB16rr GR16:$src1, GR16:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003611def : Pat<(parallel (X86sub_flag GR32:$src1, GR32:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003612 (implicit EFLAGS)),
3613 (SUB32rr GR32:$src1, GR32:$src2)>;
3614
Dan Gohman99a12192009-03-04 19:44:21 +00003615// Register-Memory Subtraction with EFLAGS result
3616def : Pat<(parallel (X86sub_flag GR8:$src1, (loadi8 addr:$src2)),
Bill Wendlingf5399032008-12-12 21:15:41 +00003617 (implicit EFLAGS)),
3618 (SUB8rm GR8:$src1, addr:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003619def : Pat<(parallel (X86sub_flag GR16:$src1, (loadi16 addr:$src2)),
Bill Wendlingf5399032008-12-12 21:15:41 +00003620 (implicit EFLAGS)),
3621 (SUB16rm GR16:$src1, addr:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003622def : Pat<(parallel (X86sub_flag GR32:$src1, (loadi32 addr:$src2)),
Bill Wendlingf5399032008-12-12 21:15:41 +00003623 (implicit EFLAGS)),
3624 (SUB32rm GR32:$src1, addr:$src2)>;
3625
Dan Gohman99a12192009-03-04 19:44:21 +00003626// Register-Integer Subtraction with EFLAGS result
3627def : Pat<(parallel (X86sub_flag GR8:$src1, imm:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003628 (implicit EFLAGS)),
3629 (SUB8ri GR8:$src1, imm:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003630def : Pat<(parallel (X86sub_flag GR16:$src1, imm:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003631 (implicit EFLAGS)),
3632 (SUB16ri GR16:$src1, imm:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003633def : Pat<(parallel (X86sub_flag GR32:$src1, imm:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003634 (implicit EFLAGS)),
3635 (SUB32ri GR32:$src1, imm:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003636def : Pat<(parallel (X86sub_flag GR16:$src1, i16immSExt8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003637 (implicit EFLAGS)),
3638 (SUB16ri8 GR16:$src1, i16immSExt8:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003639def : Pat<(parallel (X86sub_flag GR32:$src1, i32immSExt8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003640 (implicit EFLAGS)),
3641 (SUB32ri8 GR32:$src1, i32immSExt8:$src2)>;
3642
Dan Gohman99a12192009-03-04 19:44:21 +00003643// Memory-Register Subtraction with EFLAGS result
3644def : Pat<(parallel (store (X86sub_flag (loadi8 addr:$dst), GR8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003645 addr:$dst),
3646 (implicit EFLAGS)),
3647 (SUB8mr addr:$dst, GR8:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003648def : Pat<(parallel (store (X86sub_flag (loadi16 addr:$dst), GR16:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003649 addr:$dst),
3650 (implicit EFLAGS)),
3651 (SUB16mr addr:$dst, GR16:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003652def : Pat<(parallel (store (X86sub_flag (loadi32 addr:$dst), GR32:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003653 addr:$dst),
3654 (implicit EFLAGS)),
3655 (SUB32mr addr:$dst, GR32:$src2)>;
3656
Dan Gohman99a12192009-03-04 19:44:21 +00003657// Memory-Integer Subtraction with EFLAGS result
3658def : Pat<(parallel (store (X86sub_flag (loadi8 addr:$dst), imm:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003659 addr:$dst),
3660 (implicit EFLAGS)),
3661 (SUB8mi addr:$dst, imm:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003662def : Pat<(parallel (store (X86sub_flag (loadi16 addr:$dst), imm:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003663 addr:$dst),
3664 (implicit EFLAGS)),
3665 (SUB16mi addr:$dst, imm:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003666def : Pat<(parallel (store (X86sub_flag (loadi32 addr:$dst), imm:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003667 addr:$dst),
3668 (implicit EFLAGS)),
3669 (SUB32mi addr:$dst, imm:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003670def : Pat<(parallel (store (X86sub_flag (loadi16 addr:$dst), i16immSExt8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003671 addr:$dst),
3672 (implicit EFLAGS)),
3673 (SUB16mi8 addr:$dst, i16immSExt8:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003674def : Pat<(parallel (store (X86sub_flag (loadi32 addr:$dst), i32immSExt8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003675 addr:$dst),
3676 (implicit EFLAGS)),
3677 (SUB32mi8 addr:$dst, i32immSExt8:$src2)>;
3678
3679
Dan Gohman99a12192009-03-04 19:44:21 +00003680// Register-Register Signed Integer Multiply with EFLAGS result
3681def : Pat<(parallel (X86smul_flag GR16:$src1, GR16:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003682 (implicit EFLAGS)),
3683 (IMUL16rr GR16:$src1, GR16:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003684def : Pat<(parallel (X86smul_flag GR32:$src1, GR32:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003685 (implicit EFLAGS)),
3686 (IMUL32rr GR32:$src1, GR32:$src2)>;
3687
Dan Gohman99a12192009-03-04 19:44:21 +00003688// Register-Memory Signed Integer Multiply with EFLAGS result
3689def : Pat<(parallel (X86smul_flag GR16:$src1, (loadi16 addr:$src2)),
Bill Wendlingf5399032008-12-12 21:15:41 +00003690 (implicit EFLAGS)),
3691 (IMUL16rm GR16:$src1, addr:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003692def : Pat<(parallel (X86smul_flag GR32:$src1, (loadi32 addr:$src2)),
Bill Wendlingf5399032008-12-12 21:15:41 +00003693 (implicit EFLAGS)),
3694 (IMUL32rm GR32:$src1, addr:$src2)>;
3695
Dan Gohman99a12192009-03-04 19:44:21 +00003696// Register-Integer Signed Integer Multiply with EFLAGS result
3697def : Pat<(parallel (X86smul_flag GR16:$src1, imm:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003698 (implicit EFLAGS)),
3699 (IMUL16rri GR16:$src1, imm:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003700def : Pat<(parallel (X86smul_flag GR32:$src1, imm:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003701 (implicit EFLAGS)),
3702 (IMUL32rri GR32:$src1, imm:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003703def : Pat<(parallel (X86smul_flag GR16:$src1, i16immSExt8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003704 (implicit EFLAGS)),
3705 (IMUL16rri8 GR16:$src1, i16immSExt8:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003706def : Pat<(parallel (X86smul_flag GR32:$src1, i32immSExt8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003707 (implicit EFLAGS)),
3708 (IMUL32rri8 GR32:$src1, i32immSExt8:$src2)>;
3709
Dan Gohman99a12192009-03-04 19:44:21 +00003710// Memory-Integer Signed Integer Multiply with EFLAGS result
3711def : Pat<(parallel (X86smul_flag (loadi16 addr:$src1), imm:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003712 (implicit EFLAGS)),
3713 (IMUL16rmi addr:$src1, imm:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003714def : Pat<(parallel (X86smul_flag (loadi32 addr:$src1), imm:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003715 (implicit EFLAGS)),
3716 (IMUL32rmi addr:$src1, imm:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003717def : Pat<(parallel (X86smul_flag (loadi16 addr:$src1), i16immSExt8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003718 (implicit EFLAGS)),
3719 (IMUL16rmi8 addr:$src1, i16immSExt8:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003720def : Pat<(parallel (X86smul_flag (loadi32 addr:$src1), i32immSExt8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003721 (implicit EFLAGS)),
3722 (IMUL32rmi8 addr:$src1, i32immSExt8:$src2)>;
3723
Dan Gohman99a12192009-03-04 19:44:21 +00003724// Optimize multiply by 2 with EFLAGS result.
Evan Cheng00cf7932009-01-27 03:30:42 +00003725let AddedComplexity = 2 in {
Dan Gohman99a12192009-03-04 19:44:21 +00003726def : Pat<(parallel (X86smul_flag GR16:$src1, 2),
Evan Cheng00cf7932009-01-27 03:30:42 +00003727 (implicit EFLAGS)),
3728 (ADD16rr GR16:$src1, GR16:$src1)>;
3729
Dan Gohman99a12192009-03-04 19:44:21 +00003730def : Pat<(parallel (X86smul_flag GR32:$src1, 2),
Evan Cheng00cf7932009-01-27 03:30:42 +00003731 (implicit EFLAGS)),
3732 (ADD32rr GR32:$src1, GR32:$src1)>;
3733}
3734
Dan Gohman99a12192009-03-04 19:44:21 +00003735// INC and DEC with EFLAGS result. Note that these do not set CF.
3736def : Pat<(parallel (X86inc_flag GR8:$src), (implicit EFLAGS)),
3737 (INC8r GR8:$src)>;
3738def : Pat<(parallel (store (i8 (X86inc_flag (loadi8 addr:$dst))), addr:$dst),
3739 (implicit EFLAGS)),
3740 (INC8m addr:$dst)>;
3741def : Pat<(parallel (X86dec_flag GR8:$src), (implicit EFLAGS)),
3742 (DEC8r GR8:$src)>;
3743def : Pat<(parallel (store (i8 (X86dec_flag (loadi8 addr:$dst))), addr:$dst),
3744 (implicit EFLAGS)),
3745 (DEC8m addr:$dst)>;
3746
3747def : Pat<(parallel (X86inc_flag GR16:$src), (implicit EFLAGS)),
Dan Gohmaneebcac72009-03-05 21:32:23 +00003748 (INC16r GR16:$src)>, Requires<[In32BitMode]>;
Dan Gohman99a12192009-03-04 19:44:21 +00003749def : Pat<(parallel (store (i16 (X86inc_flag (loadi16 addr:$dst))), addr:$dst),
3750 (implicit EFLAGS)),
Dan Gohmaneebcac72009-03-05 21:32:23 +00003751 (INC16m addr:$dst)>, Requires<[In32BitMode]>;
Dan Gohman99a12192009-03-04 19:44:21 +00003752def : Pat<(parallel (X86dec_flag GR16:$src), (implicit EFLAGS)),
Dan Gohmaneebcac72009-03-05 21:32:23 +00003753 (DEC16r GR16:$src)>, Requires<[In32BitMode]>;
Dan Gohman99a12192009-03-04 19:44:21 +00003754def : Pat<(parallel (store (i16 (X86dec_flag (loadi16 addr:$dst))), addr:$dst),
3755 (implicit EFLAGS)),
Dan Gohmaneebcac72009-03-05 21:32:23 +00003756 (DEC16m addr:$dst)>, Requires<[In32BitMode]>;
Dan Gohman99a12192009-03-04 19:44:21 +00003757
3758def : Pat<(parallel (X86inc_flag GR32:$src), (implicit EFLAGS)),
Dan Gohmaneebcac72009-03-05 21:32:23 +00003759 (INC32r GR32:$src)>, Requires<[In32BitMode]>;
Dan Gohman99a12192009-03-04 19:44:21 +00003760def : Pat<(parallel (store (i32 (X86inc_flag (loadi32 addr:$dst))), addr:$dst),
3761 (implicit EFLAGS)),
Dan Gohmaneebcac72009-03-05 21:32:23 +00003762 (INC32m addr:$dst)>, Requires<[In32BitMode]>;
Dan Gohman99a12192009-03-04 19:44:21 +00003763def : Pat<(parallel (X86dec_flag GR32:$src), (implicit EFLAGS)),
Dan Gohmaneebcac72009-03-05 21:32:23 +00003764 (DEC32r GR32:$src)>, Requires<[In32BitMode]>;
Dan Gohman99a12192009-03-04 19:44:21 +00003765def : Pat<(parallel (store (i32 (X86dec_flag (loadi32 addr:$dst))), addr:$dst),
3766 (implicit EFLAGS)),
Dan Gohmaneebcac72009-03-05 21:32:23 +00003767 (DEC32m addr:$dst)>, Requires<[In32BitMode]>;
Dan Gohman99a12192009-03-04 19:44:21 +00003768
Bill Wendlingf5399032008-12-12 21:15:41 +00003769//===----------------------------------------------------------------------===//
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003770// Floating Point Stack Support
3771//===----------------------------------------------------------------------===//
3772
3773include "X86InstrFPStack.td"
3774
3775//===----------------------------------------------------------------------===//
Evan Cheng86ab7d32007-07-31 08:04:03 +00003776// X86-64 Support
3777//===----------------------------------------------------------------------===//
3778
Chris Lattner2de8d2b2008-01-10 05:50:42 +00003779include "X86Instr64bit.td"
Evan Cheng86ab7d32007-07-31 08:04:03 +00003780
3781//===----------------------------------------------------------------------===//
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003782// XMM Floating point support (requires SSE / SSE2)
3783//===----------------------------------------------------------------------===//
3784
3785include "X86InstrSSE.td"
Evan Cheng5e4d1e72008-04-25 18:19:54 +00003786
3787//===----------------------------------------------------------------------===//
3788// MMX and XMM Packed Integer support (requires MMX, SSE, and SSE2)
3789//===----------------------------------------------------------------------===//
3790
3791include "X86InstrMMX.td"