blob: b0f78422e7a1b78dbee2cc883cfaa53a3ec8d797 [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
68def SDT_X86TLSTP : SDTypeProfile<1, 0, [SDTCisPtrTy<0>]>;
69
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]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000145def X86TLStp : SDNode<"X86ISD::THREAD_POINTER", SDT_X86TLSTP, []>;
146
147def X86ehret : SDNode<"X86ISD::EH_RETURN", SDT_X86EHRET,
148 [SDNPHasChain]>;
149
Arnold Schwaighofere2d6bbb2007-10-11 19:40:01 +0000150def X86tcret : SDNode<"X86ISD::TC_RETURN", SDT_X86TCRET,
151 [SDNPHasChain, SDNPOptInFlag]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000152
Dan Gohman99a12192009-03-04 19:44:21 +0000153def X86add_flag : SDNode<"X86ISD::ADD", SDTBinaryArithWithFlags>;
154def X86sub_flag : SDNode<"X86ISD::SUB", SDTBinaryArithWithFlags>;
155def X86smul_flag : SDNode<"X86ISD::SMUL", SDTBinaryArithWithFlags>;
156def X86umul_flag : SDNode<"X86ISD::UMUL", SDTUnaryArithWithFlags>;
157def X86inc_flag : SDNode<"X86ISD::INC", SDTUnaryArithWithFlags>;
158def X86dec_flag : SDNode<"X86ISD::DEC", SDTUnaryArithWithFlags>;
Bill Wendlingae034ed2008-12-12 00:56:36 +0000159
Evan Chengc3495762009-03-30 21:36:47 +0000160def X86mul_imm : SDNode<"X86ISD::MUL_IMM", SDTIntBinOp>;
161
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000162//===----------------------------------------------------------------------===//
163// X86 Operand Definitions.
164//
165
166// *mem - Operand definitions for the funky X86 addressing mode operands.
167//
168class X86MemOperand<string printMethod> : Operand<iPTR> {
169 let PrintMethod = printMethod;
170 let MIOperandInfo = (ops ptr_rc, i8imm, ptr_rc, i32imm);
171}
172
173def i8mem : X86MemOperand<"printi8mem">;
174def i16mem : X86MemOperand<"printi16mem">;
175def i32mem : X86MemOperand<"printi32mem">;
176def i64mem : X86MemOperand<"printi64mem">;
177def i128mem : X86MemOperand<"printi128mem">;
178def f32mem : X86MemOperand<"printf32mem">;
179def f64mem : X86MemOperand<"printf64mem">;
Dale Johannesen4ab00bd2007-08-05 18:49:15 +0000180def f80mem : X86MemOperand<"printf80mem">;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000181def f128mem : X86MemOperand<"printf128mem">;
182
183def lea32mem : Operand<i32> {
184 let PrintMethod = "printi32mem";
185 let MIOperandInfo = (ops GR32, i8imm, GR32, i32imm);
186}
187
188def SSECC : Operand<i8> {
189 let PrintMethod = "printSSECC";
190}
191
192def piclabel: Operand<i32> {
193 let PrintMethod = "printPICLabel";
194}
195
196// A couple of more descriptive operand definitions.
197// 16-bits but only 8 bits are significant.
198def i16i8imm : Operand<i16>;
199// 32-bits but only 8 bits are significant.
200def i32i8imm : Operand<i32>;
201
202// Branch targets have OtherVT type.
203def brtarget : Operand<OtherVT>;
204
205//===----------------------------------------------------------------------===//
206// X86 Complex Pattern Definitions.
207//
208
209// Define X86 specific addressing mode.
210def addr : ComplexPattern<iPTR, 4, "SelectAddr", [], []>;
211def lea32addr : ComplexPattern<i32, 4, "SelectLEAAddr",
212 [add, mul, shl, or, frameindex], []>;
213
214//===----------------------------------------------------------------------===//
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000215// X86 Instruction Predicate Definitions.
216def HasMMX : Predicate<"Subtarget->hasMMX()">;
217def HasSSE1 : Predicate<"Subtarget->hasSSE1()">;
218def HasSSE2 : Predicate<"Subtarget->hasSSE2()">;
219def HasSSE3 : Predicate<"Subtarget->hasSSE3()">;
220def HasSSSE3 : Predicate<"Subtarget->hasSSSE3()">;
Nate Begemanb2975562008-02-03 07:18:54 +0000221def HasSSE41 : Predicate<"Subtarget->hasSSE41()">;
222def HasSSE42 : Predicate<"Subtarget->hasSSE42()">;
Dale Johannesene0e0fd02007-09-23 14:52:20 +0000223def FPStackf32 : Predicate<"!Subtarget->hasSSE1()">;
224def FPStackf64 : Predicate<"!Subtarget->hasSSE2()">;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000225def In32BitMode : Predicate<"!Subtarget->is64Bit()">;
226def In64BitMode : Predicate<"Subtarget->is64Bit()">;
227def SmallCode : Predicate<"TM.getCodeModel() == CodeModel::Small">;
228def NotSmallCode : Predicate<"TM.getCodeModel() != CodeModel::Small">;
229def IsStatic : Predicate<"TM.getRelocationModel() == Reloc::Static">;
Evan Cheng13559d62008-09-26 23:41:32 +0000230def OptForSpeed : Predicate<"!OptForSize">;
Evan Cheng95a77fd2009-01-02 05:35:45 +0000231def FastBTMem : Predicate<"!Subtarget->isBTMemSlow()">;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000232
233//===----------------------------------------------------------------------===//
Evan Cheng86ab7d32007-07-31 08:04:03 +0000234// X86 Instruction Format Definitions.
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000235//
236
Evan Cheng86ab7d32007-07-31 08:04:03 +0000237include "X86InstrFormats.td"
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000238
239//===----------------------------------------------------------------------===//
240// Pattern fragments...
241//
242
243// X86 specific condition code. These correspond to CondCode in
244// X86InstrInfo.h. They must be kept in synch.
Dan Gohman0fc9ed62009-01-07 00:15:08 +0000245def X86_COND_A : PatLeaf<(i8 0)>; // alt. COND_NBE
246def X86_COND_AE : PatLeaf<(i8 1)>; // alt. COND_NC
247def X86_COND_B : PatLeaf<(i8 2)>; // alt. COND_C
248def X86_COND_BE : PatLeaf<(i8 3)>; // alt. COND_NA
249def X86_COND_E : PatLeaf<(i8 4)>; // alt. COND_Z
250def X86_COND_G : PatLeaf<(i8 5)>; // alt. COND_NLE
251def X86_COND_GE : PatLeaf<(i8 6)>; // alt. COND_NL
252def X86_COND_L : PatLeaf<(i8 7)>; // alt. COND_NGE
253def X86_COND_LE : PatLeaf<(i8 8)>; // alt. COND_NG
254def X86_COND_NE : PatLeaf<(i8 9)>; // alt. COND_NZ
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000255def X86_COND_NO : PatLeaf<(i8 10)>;
Dan Gohman0fc9ed62009-01-07 00:15:08 +0000256def X86_COND_NP : PatLeaf<(i8 11)>; // alt. COND_PO
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000257def X86_COND_NS : PatLeaf<(i8 12)>;
Dan Gohman0fc9ed62009-01-07 00:15:08 +0000258def X86_COND_O : PatLeaf<(i8 13)>;
259def X86_COND_P : PatLeaf<(i8 14)>; // alt. COND_PE
260def X86_COND_S : PatLeaf<(i8 15)>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000261
262def i16immSExt8 : PatLeaf<(i16 imm), [{
263 // i16immSExt8 predicate - True if the 16-bit immediate fits in a 8-bit
264 // sign extended field.
Dan Gohmanfaeb4a32008-09-12 16:56:44 +0000265 return (int16_t)N->getZExtValue() == (int8_t)N->getZExtValue();
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000266}]>;
267
268def i32immSExt8 : PatLeaf<(i32 imm), [{
269 // i32immSExt8 predicate - True if the 32-bit immediate fits in a 8-bit
270 // sign extended field.
Dan Gohmanfaeb4a32008-09-12 16:56:44 +0000271 return (int32_t)N->getZExtValue() == (int8_t)N->getZExtValue();
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000272}]>;
273
274// Helper fragments for loads.
Evan Chengb3e25ea2008-05-13 18:59:59 +0000275// It's always safe to treat a anyext i16 load as a i32 load if the i16 is
276// known to be 32-bit aligned or better. Ditto for i8 to i16.
Dan Gohman2a174122008-10-15 06:50:19 +0000277def loadi16 : PatFrag<(ops node:$ptr), (i16 (unindexedload node:$ptr)), [{
Dan Gohman8335c412008-08-20 15:24:22 +0000278 LoadSDNode *LD = cast<LoadSDNode>(N);
Dan Gohman8335c412008-08-20 15:24:22 +0000279 ISD::LoadExtType ExtType = LD->getExtensionType();
280 if (ExtType == ISD::NON_EXTLOAD)
281 return true;
282 if (ExtType == ISD::EXTLOAD)
283 return LD->getAlignment() >= 2 && !LD->isVolatile();
Evan Cheng8b765e92008-05-13 00:54:02 +0000284 return false;
285}]>;
286
Dan Gohman2a174122008-10-15 06:50:19 +0000287def loadi16_anyext : PatFrag<(ops node:$ptr), (i32 (unindexedload node:$ptr)), [{
Evan Cheng56ec77b2008-09-24 23:27:55 +0000288 LoadSDNode *LD = cast<LoadSDNode>(N);
Evan Cheng56ec77b2008-09-24 23:27:55 +0000289 ISD::LoadExtType ExtType = LD->getExtensionType();
290 if (ExtType == ISD::EXTLOAD)
291 return LD->getAlignment() >= 2 && !LD->isVolatile();
292 return false;
293}]>;
294
Dan Gohman2a174122008-10-15 06:50:19 +0000295def loadi32 : PatFrag<(ops node:$ptr), (i32 (unindexedload node:$ptr)), [{
Dan Gohman8335c412008-08-20 15:24:22 +0000296 LoadSDNode *LD = cast<LoadSDNode>(N);
Dan Gohman8335c412008-08-20 15:24:22 +0000297 ISD::LoadExtType ExtType = LD->getExtensionType();
298 if (ExtType == ISD::NON_EXTLOAD)
299 return true;
300 if (ExtType == ISD::EXTLOAD)
301 return LD->getAlignment() >= 4 && !LD->isVolatile();
Evan Cheng8b765e92008-05-13 00:54:02 +0000302 return false;
303}]>;
304
Dan Gohman2a174122008-10-15 06:50:19 +0000305def nvloadi32 : PatFrag<(ops node:$ptr), (i32 (unindexedload node:$ptr)), [{
Evan Cheng1e5e5452008-09-29 17:26:18 +0000306 LoadSDNode *LD = cast<LoadSDNode>(N);
307 if (LD->isVolatile())
308 return false;
Evan Cheng1e5e5452008-09-29 17:26:18 +0000309 ISD::LoadExtType ExtType = LD->getExtensionType();
310 if (ExtType == ISD::NON_EXTLOAD)
311 return true;
312 if (ExtType == ISD::EXTLOAD)
313 return LD->getAlignment() >= 4;
314 return false;
315}]>;
316
sampo9cc09a32009-01-26 01:24:32 +0000317def gsload : PatFrag<(ops node:$ptr), (load node:$ptr), [{
318 LoadSDNode *LD = cast<LoadSDNode>(N);
319 const Value *Src = LD->getSrcValue();
320 if (!Src)
321 return false;
322 if (const PointerType *PT = dyn_cast<PointerType>(Src->getType()))
323 return PT->getAddressSpace() == 256;
324 return false;
325}]>;
326
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000327def loadi8 : PatFrag<(ops node:$ptr), (i8 (load node:$ptr))>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000328def loadi64 : PatFrag<(ops node:$ptr), (i64 (load node:$ptr))>;
329
330def loadf32 : PatFrag<(ops node:$ptr), (f32 (load node:$ptr))>;
331def loadf64 : PatFrag<(ops node:$ptr), (f64 (load node:$ptr))>;
Dale Johannesen4ab00bd2007-08-05 18:49:15 +0000332def loadf80 : PatFrag<(ops node:$ptr), (f80 (load node:$ptr))>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000333
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000334def sextloadi16i8 : PatFrag<(ops node:$ptr), (i16 (sextloadi8 node:$ptr))>;
335def sextloadi32i8 : PatFrag<(ops node:$ptr), (i32 (sextloadi8 node:$ptr))>;
336def sextloadi32i16 : PatFrag<(ops node:$ptr), (i32 (sextloadi16 node:$ptr))>;
337
338def zextloadi8i1 : PatFrag<(ops node:$ptr), (i8 (zextloadi1 node:$ptr))>;
339def zextloadi16i1 : PatFrag<(ops node:$ptr), (i16 (zextloadi1 node:$ptr))>;
340def zextloadi32i1 : PatFrag<(ops node:$ptr), (i32 (zextloadi1 node:$ptr))>;
341def zextloadi16i8 : PatFrag<(ops node:$ptr), (i16 (zextloadi8 node:$ptr))>;
342def zextloadi32i8 : PatFrag<(ops node:$ptr), (i32 (zextloadi8 node:$ptr))>;
343def zextloadi32i16 : PatFrag<(ops node:$ptr), (i32 (zextloadi16 node:$ptr))>;
344
345def extloadi8i1 : PatFrag<(ops node:$ptr), (i8 (extloadi1 node:$ptr))>;
346def extloadi16i1 : PatFrag<(ops node:$ptr), (i16 (extloadi1 node:$ptr))>;
347def extloadi32i1 : PatFrag<(ops node:$ptr), (i32 (extloadi1 node:$ptr))>;
348def extloadi16i8 : PatFrag<(ops node:$ptr), (i16 (extloadi8 node:$ptr))>;
349def extloadi32i8 : PatFrag<(ops node:$ptr), (i32 (extloadi8 node:$ptr))>;
350def extloadi32i16 : PatFrag<(ops node:$ptr), (i32 (extloadi16 node:$ptr))>;
351
Chris Lattner21da6382008-02-19 17:37:35 +0000352
353// An 'and' node with a single use.
354def and_su : PatFrag<(ops node:$lhs, node:$rhs), (and node:$lhs, node:$rhs), [{
Evan Cheng9123cfa2008-03-04 00:40:35 +0000355 return N->hasOneUse();
Chris Lattner21da6382008-02-19 17:37:35 +0000356}]>;
357
Dan Gohman921581d2008-10-17 01:23:35 +0000358// 'shld' and 'shrd' instruction patterns. Note that even though these have
359// the srl and shl in their patterns, the C++ code must still check for them,
360// because predicates are tested before children nodes are explored.
361
362def shrd : PatFrag<(ops node:$src1, node:$amt1, node:$src2, node:$amt2),
363 (or (srl node:$src1, node:$amt1),
364 (shl node:$src2, node:$amt2)), [{
365 assert(N->getOpcode() == ISD::OR);
366 return N->getOperand(0).getOpcode() == ISD::SRL &&
367 N->getOperand(1).getOpcode() == ISD::SHL &&
368 isa<ConstantSDNode>(N->getOperand(0).getOperand(1)) &&
369 isa<ConstantSDNode>(N->getOperand(1).getOperand(1)) &&
370 N->getOperand(0).getConstantOperandVal(1) ==
371 N->getValueSizeInBits(0) - N->getOperand(1).getConstantOperandVal(1);
372}]>;
373
374def shld : PatFrag<(ops node:$src1, node:$amt1, node:$src2, node:$amt2),
375 (or (shl node:$src1, node:$amt1),
376 (srl node:$src2, node:$amt2)), [{
377 assert(N->getOpcode() == ISD::OR);
378 return N->getOperand(0).getOpcode() == ISD::SHL &&
379 N->getOperand(1).getOpcode() == ISD::SRL &&
380 isa<ConstantSDNode>(N->getOperand(0).getOperand(1)) &&
381 isa<ConstantSDNode>(N->getOperand(1).getOperand(1)) &&
382 N->getOperand(0).getConstantOperandVal(1) ==
383 N->getValueSizeInBits(0) - N->getOperand(1).getConstantOperandVal(1);
384}]>;
385
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000386//===----------------------------------------------------------------------===//
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000387// Instruction list...
388//
389
390// ADJCALLSTACKDOWN/UP implicitly use/def ESP because they may be expanded into
391// a stack adjustment and the codegen must know that they may modify the stack
392// pointer before prolog-epilog rewriting occurs.
Chris Lattnerb56cc342008-03-11 03:23:40 +0000393// Pessimistically assume ADJCALLSTACKDOWN / ADJCALLSTACKUP will become
394// sub / add which can clobber EFLAGS.
Evan Cheng037364a2007-09-28 01:19:48 +0000395let Defs = [ESP, EFLAGS], Uses = [ESP] in {
Dan Gohman01c9f772008-10-01 18:28:06 +0000396def ADJCALLSTACKDOWN32 : I<0, Pseudo, (outs), (ins i32imm:$amt),
397 "#ADJCALLSTACKDOWN",
Chris Lattnerfe5d4022008-10-11 22:08:30 +0000398 [(X86callseq_start timm:$amt)]>,
Dan Gohman01c9f772008-10-01 18:28:06 +0000399 Requires<[In32BitMode]>;
400def ADJCALLSTACKUP32 : I<0, Pseudo, (outs), (ins i32imm:$amt1, i32imm:$amt2),
401 "#ADJCALLSTACKUP",
Chris Lattnerfe5d4022008-10-11 22:08:30 +0000402 [(X86callseq_end timm:$amt1, timm:$amt2)]>,
Dan Gohman01c9f772008-10-01 18:28:06 +0000403 Requires<[In32BitMode]>;
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000404}
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000405
406// Nop
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000407let neverHasSideEffects = 1 in
408 def NOOP : I<0x90, RawFrm, (outs), (ins), "nop", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000409
Evan Cheng0729ccf2008-01-05 00:41:47 +0000410// PIC base
Dan Gohman9499cfe2008-10-01 04:14:30 +0000411let neverHasSideEffects = 1, isNotDuplicable = 1, Uses = [ESP] in
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000412 def MOVPC32r : Ii32<0xE8, Pseudo, (outs GR32:$reg), (ins piclabel:$label),
413 "call\t$label\n\tpop{l}\t$reg", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000414
415//===----------------------------------------------------------------------===//
416// Control Flow Instructions...
417//
418
419// Return instructions.
420let isTerminator = 1, isReturn = 1, isBarrier = 1,
Chris Lattnerb56cc342008-03-11 03:23:40 +0000421 hasCtrlDep = 1, FPForm = SpecialFP, FPFormBits = SpecialFP.Value in {
Dan Gohman2c4be2a2008-05-31 02:11:25 +0000422 def RET : I <0xC3, RawFrm, (outs), (ins variable_ops),
Chris Lattnerb56cc342008-03-11 03:23:40 +0000423 "ret",
Dan Gohman2c4be2a2008-05-31 02:11:25 +0000424 [(X86retflag 0)]>;
Chris Lattnerb56cc342008-03-11 03:23:40 +0000425 def RETI : Ii16<0xC2, RawFrm, (outs), (ins i16imm:$amt, variable_ops),
426 "ret\t$amt",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000427 [(X86retflag imm:$amt)]>;
428}
429
430// All branches are RawFrm, Void, Branch, and Terminators
Evan Cheng37e7c752007-07-21 00:34:19 +0000431let isBranch = 1, isTerminator = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +0000432 class IBr<bits<8> opcode, dag ins, string asm, list<dag> pattern> :
433 I<opcode, RawFrm, (outs), ins, asm, pattern>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000434
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000435let isBranch = 1, isBarrier = 1 in
Dan Gohman91888f02007-07-31 20:11:57 +0000436 def JMP : IBr<0xE9, (ins brtarget:$dst), "jmp\t$dst", [(br bb:$dst)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000437
Owen Andersonf8053082007-11-12 07:39:39 +0000438// Indirect branches
439let isBranch = 1, isTerminator = 1, isBarrier = 1, isIndirectBranch = 1 in {
Dan Gohman91888f02007-07-31 20:11:57 +0000440 def JMP32r : I<0xFF, MRM4r, (outs), (ins GR32:$dst), "jmp{l}\t{*}$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000441 [(brind GR32:$dst)]>;
Dan Gohman91888f02007-07-31 20:11:57 +0000442 def JMP32m : I<0xFF, MRM4m, (outs), (ins i32mem:$dst), "jmp{l}\t{*}$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000443 [(brind (loadi32 addr:$dst))]>;
444}
445
446// Conditional branches
Evan Cheng950aac02007-09-25 01:57:46 +0000447let Uses = [EFLAGS] in {
Dan Gohman91888f02007-07-31 20:11:57 +0000448def JE : IBr<0x84, (ins brtarget:$dst), "je\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000449 [(X86brcond bb:$dst, X86_COND_E, EFLAGS)]>, TB;
Dan Gohman91888f02007-07-31 20:11:57 +0000450def JNE : IBr<0x85, (ins brtarget:$dst), "jne\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000451 [(X86brcond bb:$dst, X86_COND_NE, EFLAGS)]>, TB;
Dan Gohman91888f02007-07-31 20:11:57 +0000452def JL : IBr<0x8C, (ins brtarget:$dst), "jl\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000453 [(X86brcond bb:$dst, X86_COND_L, EFLAGS)]>, TB;
Dan Gohman91888f02007-07-31 20:11:57 +0000454def JLE : IBr<0x8E, (ins brtarget:$dst), "jle\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000455 [(X86brcond bb:$dst, X86_COND_LE, EFLAGS)]>, TB;
Dan Gohman91888f02007-07-31 20:11:57 +0000456def JG : IBr<0x8F, (ins brtarget:$dst), "jg\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000457 [(X86brcond bb:$dst, X86_COND_G, EFLAGS)]>, TB;
Dan Gohman91888f02007-07-31 20:11:57 +0000458def JGE : IBr<0x8D, (ins brtarget:$dst), "jge\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000459 [(X86brcond bb:$dst, X86_COND_GE, EFLAGS)]>, TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000460
Dan Gohman91888f02007-07-31 20:11:57 +0000461def JB : IBr<0x82, (ins brtarget:$dst), "jb\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000462 [(X86brcond bb:$dst, X86_COND_B, EFLAGS)]>, TB;
Dan Gohman91888f02007-07-31 20:11:57 +0000463def JBE : IBr<0x86, (ins brtarget:$dst), "jbe\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000464 [(X86brcond bb:$dst, X86_COND_BE, EFLAGS)]>, TB;
Dan Gohman91888f02007-07-31 20:11:57 +0000465def JA : IBr<0x87, (ins brtarget:$dst), "ja\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000466 [(X86brcond bb:$dst, X86_COND_A, EFLAGS)]>, TB;
Dan Gohman91888f02007-07-31 20:11:57 +0000467def JAE : IBr<0x83, (ins brtarget:$dst), "jae\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000468 [(X86brcond bb:$dst, X86_COND_AE, EFLAGS)]>, TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000469
Dan Gohman91888f02007-07-31 20:11:57 +0000470def JS : IBr<0x88, (ins brtarget:$dst), "js\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000471 [(X86brcond bb:$dst, X86_COND_S, EFLAGS)]>, TB;
Dan Gohman91888f02007-07-31 20:11:57 +0000472def JNS : IBr<0x89, (ins brtarget:$dst), "jns\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000473 [(X86brcond bb:$dst, X86_COND_NS, EFLAGS)]>, TB;
Dan Gohman91888f02007-07-31 20:11:57 +0000474def JP : IBr<0x8A, (ins brtarget:$dst), "jp\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000475 [(X86brcond bb:$dst, X86_COND_P, EFLAGS)]>, TB;
Dan Gohman91888f02007-07-31 20:11:57 +0000476def JNP : IBr<0x8B, (ins brtarget:$dst), "jnp\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000477 [(X86brcond bb:$dst, X86_COND_NP, EFLAGS)]>, TB;
Dan Gohman91888f02007-07-31 20:11:57 +0000478def JO : IBr<0x80, (ins brtarget:$dst), "jo\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000479 [(X86brcond bb:$dst, X86_COND_O, EFLAGS)]>, TB;
Dan Gohman91888f02007-07-31 20:11:57 +0000480def JNO : IBr<0x81, (ins brtarget:$dst), "jno\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000481 [(X86brcond bb:$dst, X86_COND_NO, EFLAGS)]>, TB;
Evan Cheng950aac02007-09-25 01:57:46 +0000482} // Uses = [EFLAGS]
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000483
484//===----------------------------------------------------------------------===//
485// Call Instructions...
486//
Evan Cheng37e7c752007-07-21 00:34:19 +0000487let isCall = 1 in
Dan Gohman01c9f772008-10-01 18:28:06 +0000488 // All calls clobber the non-callee saved registers. ESP is marked as
489 // a use to prevent stack-pointer assignments that appear immediately
490 // before calls from potentially appearing dead. Uses for argument
491 // registers are added manually.
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000492 let Defs = [EAX, ECX, EDX, FP0, FP1, FP2, FP3, FP4, FP5, FP6, ST0,
493 MM0, MM1, MM2, MM3, MM4, MM5, MM6, MM7,
Evan Cheng2293b252008-10-17 21:02:22 +0000494 XMM0, XMM1, XMM2, XMM3, XMM4, XMM5, XMM6, XMM7,
495 XMM8, XMM9, XMM10, XMM11, XMM12, XMM13, XMM14, XMM15, EFLAGS],
Dan Gohman9499cfe2008-10-01 04:14:30 +0000496 Uses = [ESP] in {
Evan Cheng34f93712007-12-22 02:26:46 +0000497 def CALLpcrel32 : Ii32<0xE8, RawFrm, (outs), (ins i32imm:$dst,variable_ops),
Evan Cheng0af5a042009-03-12 18:15:39 +0000498 "call\t${dst:call}", [(X86call imm:$dst)]>,
499 Requires<[In32BitMode]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000500 def CALL32r : I<0xFF, MRM2r, (outs), (ins GR32:$dst, variable_ops),
Dan Gohman91888f02007-07-31 20:11:57 +0000501 "call\t{*}$dst", [(X86call GR32:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000502 def CALL32m : I<0xFF, MRM2m, (outs), (ins i32mem:$dst, variable_ops),
Dan Gohmanea4faba2008-05-29 21:50:34 +0000503 "call\t{*}$dst", [(X86call (loadi32 addr:$dst))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000504 }
505
506// Tail call stuff.
Arnold Schwaighofere2d6bbb2007-10-11 19:40:01 +0000507
Chris Lattnerb56cc342008-03-11 03:23:40 +0000508def TAILCALL : I<0, Pseudo, (outs), (ins),
Arnold Schwaighofere2d6bbb2007-10-11 19:40:01 +0000509 "#TAILCALL",
510 []>;
511
Evan Cheng37e7c752007-07-21 00:34:19 +0000512let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1 in
Arnold Schwaighofer6fd37ac2008-03-19 16:39:45 +0000513def TCRETURNdi : I<0, Pseudo, (outs), (ins i32imm:$dst, i32imm:$offset, variable_ops),
Arnold Schwaighofere2d6bbb2007-10-11 19:40:01 +0000514 "#TC_RETURN $dst $offset",
515 []>;
516
517let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1 in
Arnold Schwaighofer6fd37ac2008-03-19 16:39:45 +0000518def TCRETURNri : I<0, Pseudo, (outs), (ins GR32:$dst, i32imm:$offset, variable_ops),
Arnold Schwaighofere2d6bbb2007-10-11 19:40:01 +0000519 "#TC_RETURN $dst $offset",
520 []>;
521
522let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1 in
Arnold Schwaighofera0032722008-04-30 09:16:33 +0000523
Arnold Schwaighofere2d6bbb2007-10-11 19:40:01 +0000524 def TAILJMPd : IBr<0xE9, (ins i32imm:$dst), "jmp\t${dst:call} # TAILCALL",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000525 []>;
Evan Cheng37e7c752007-07-21 00:34:19 +0000526let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1 in
Arnold Schwaighofere2d6bbb2007-10-11 19:40:01 +0000527 def TAILJMPr : I<0xFF, MRM4r, (outs), (ins GR32:$dst), "jmp{l}\t{*}$dst # TAILCALL",
528 []>;
Evan Cheng37e7c752007-07-21 00:34:19 +0000529let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +0000530 def TAILJMPm : I<0xFF, MRM4m, (outs), (ins i32mem:$dst),
Arnold Schwaighofere2d6bbb2007-10-11 19:40:01 +0000531 "jmp\t{*}$dst # TAILCALL", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000532
533//===----------------------------------------------------------------------===//
534// Miscellaneous Instructions...
535//
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000536let Defs = [EBP, ESP], Uses = [EBP, ESP], mayLoad = 1, neverHasSideEffects=1 in
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000537def LEAVE : I<0xC9, RawFrm,
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000538 (outs), (ins), "leave", []>;
539
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000540let Defs = [ESP], Uses = [ESP], neverHasSideEffects=1 in {
541let mayLoad = 1 in
Evan Chengd8434332007-09-26 01:29:06 +0000542def POP32r : I<0x58, AddRegFrm, (outs GR32:$reg), (ins), "pop{l}\t$reg", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000543
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000544let mayStore = 1 in
Evan Chengd8434332007-09-26 01:29:06 +0000545def PUSH32r : I<0x50, AddRegFrm, (outs), (ins GR32:$reg), "push{l}\t$reg",[]>;
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000546}
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000547
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000548let Defs = [ESP, EFLAGS], Uses = [ESP], mayLoad = 1, neverHasSideEffects=1 in
Evan Chengf1341312007-09-26 21:28:00 +0000549def POPFD : I<0x9D, RawFrm, (outs), (ins), "popf", []>;
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000550let Defs = [ESP], Uses = [ESP, EFLAGS], mayStore = 1, neverHasSideEffects=1 in
Evan Chengf1341312007-09-26 21:28:00 +0000551def PUSHFD : I<0x9C, RawFrm, (outs), (ins), "pushf", []>;
Evan Chengd8434332007-09-26 01:29:06 +0000552
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000553let isTwoAddress = 1 in // GR32 = bswap GR32
554 def BSWAP32r : I<0xC8, AddRegFrm,
Evan Chengb783fa32007-07-19 01:14:50 +0000555 (outs GR32:$dst), (ins GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000556 "bswap{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000557 [(set GR32:$dst, (bswap GR32:$src))]>, TB;
558
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000559
Evan Cheng48679f42007-12-14 02:13:44 +0000560// Bit scan instructions.
561let Defs = [EFLAGS] in {
Evan Cheng4e33de92007-12-14 18:49:43 +0000562def BSF16rr : I<0xBC, MRMSrcReg, (outs GR16:$dst), (ins GR16:$src),
Dan Gohmancdb54c62007-12-14 15:10:00 +0000563 "bsf{w}\t{$src, $dst|$dst, $src}",
Evan Cheng7cfbfe32007-12-14 08:30:15 +0000564 [(set GR16:$dst, (X86bsf GR16:$src)), (implicit EFLAGS)]>, TB;
Evan Cheng48679f42007-12-14 02:13:44 +0000565def BSF16rm : I<0xBC, MRMSrcMem, (outs GR16:$dst), (ins i16mem:$src),
Dan Gohmancdb54c62007-12-14 15:10:00 +0000566 "bsf{w}\t{$src, $dst|$dst, $src}",
Evan Cheng7cfbfe32007-12-14 08:30:15 +0000567 [(set GR16:$dst, (X86bsf (loadi16 addr:$src))),
568 (implicit EFLAGS)]>, TB;
Evan Cheng4e33de92007-12-14 18:49:43 +0000569def BSF32rr : I<0xBC, MRMSrcReg, (outs GR32:$dst), (ins GR32:$src),
Dan Gohmancdb54c62007-12-14 15:10:00 +0000570 "bsf{l}\t{$src, $dst|$dst, $src}",
Evan Cheng7cfbfe32007-12-14 08:30:15 +0000571 [(set GR32:$dst, (X86bsf GR32:$src)), (implicit EFLAGS)]>, TB;
Evan Cheng48679f42007-12-14 02:13:44 +0000572def BSF32rm : I<0xBC, MRMSrcMem, (outs GR32:$dst), (ins i32mem:$src),
Dan Gohmancdb54c62007-12-14 15:10:00 +0000573 "bsf{l}\t{$src, $dst|$dst, $src}",
Evan Cheng7cfbfe32007-12-14 08:30:15 +0000574 [(set GR32:$dst, (X86bsf (loadi32 addr:$src))),
575 (implicit EFLAGS)]>, TB;
Evan Cheng48679f42007-12-14 02:13:44 +0000576
Evan Cheng4e33de92007-12-14 18:49:43 +0000577def BSR16rr : I<0xBD, MRMSrcReg, (outs GR16:$dst), (ins GR16:$src),
Dan Gohmancdb54c62007-12-14 15:10:00 +0000578 "bsr{w}\t{$src, $dst|$dst, $src}",
Evan Cheng7cfbfe32007-12-14 08:30:15 +0000579 [(set GR16:$dst, (X86bsr GR16:$src)), (implicit EFLAGS)]>, TB;
Evan Cheng48679f42007-12-14 02:13:44 +0000580def BSR16rm : I<0xBD, MRMSrcMem, (outs GR16:$dst), (ins i16mem:$src),
Dan Gohmancdb54c62007-12-14 15:10:00 +0000581 "bsr{w}\t{$src, $dst|$dst, $src}",
Evan Cheng7cfbfe32007-12-14 08:30:15 +0000582 [(set GR16:$dst, (X86bsr (loadi16 addr:$src))),
583 (implicit EFLAGS)]>, TB;
Evan Cheng4e33de92007-12-14 18:49:43 +0000584def BSR32rr : I<0xBD, MRMSrcReg, (outs GR32:$dst), (ins GR32:$src),
Dan Gohmancdb54c62007-12-14 15:10:00 +0000585 "bsr{l}\t{$src, $dst|$dst, $src}",
Evan Cheng7cfbfe32007-12-14 08:30:15 +0000586 [(set GR32:$dst, (X86bsr GR32:$src)), (implicit EFLAGS)]>, TB;
Evan Cheng48679f42007-12-14 02:13:44 +0000587def BSR32rm : I<0xBD, MRMSrcMem, (outs GR32:$dst), (ins i32mem:$src),
Dan Gohmancdb54c62007-12-14 15:10:00 +0000588 "bsr{l}\t{$src, $dst|$dst, $src}",
Evan Cheng7cfbfe32007-12-14 08:30:15 +0000589 [(set GR32:$dst, (X86bsr (loadi32 addr:$src))),
590 (implicit EFLAGS)]>, TB;
Evan Cheng48679f42007-12-14 02:13:44 +0000591} // Defs = [EFLAGS]
592
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000593let neverHasSideEffects = 1 in
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000594def LEA16r : I<0x8D, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +0000595 (outs GR16:$dst), (ins i32mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000596 "lea{w}\t{$src|$dst}, {$dst|$src}", []>, OpSize;
Evan Cheng1ea8e6b2008-03-27 01:41:09 +0000597let isReMaterializable = 1 in
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000598def LEA32r : I<0x8D, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +0000599 (outs GR32:$dst), (ins lea32mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000600 "lea{l}\t{$src|$dst}, {$dst|$src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000601 [(set GR32:$dst, lea32addr:$src)]>, Requires<[In32BitMode]>;
602
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000603let Defs = [ECX,EDI,ESI], Uses = [ECX,EDI,ESI] in {
Evan Chengb783fa32007-07-19 01:14:50 +0000604def REP_MOVSB : I<0xA4, RawFrm, (outs), (ins), "{rep;movsb|rep movsb}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000605 [(X86rep_movs i8)]>, REP;
Evan Chengb783fa32007-07-19 01:14:50 +0000606def REP_MOVSW : I<0xA5, RawFrm, (outs), (ins), "{rep;movsw|rep movsw}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000607 [(X86rep_movs i16)]>, REP, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +0000608def REP_MOVSD : I<0xA5, RawFrm, (outs), (ins), "{rep;movsl|rep movsd}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000609 [(X86rep_movs i32)]>, REP;
610}
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000611
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000612let Defs = [ECX,EDI], Uses = [AL,ECX,EDI] in
Evan Chengb783fa32007-07-19 01:14:50 +0000613def REP_STOSB : I<0xAA, RawFrm, (outs), (ins), "{rep;stosb|rep stosb}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000614 [(X86rep_stos i8)]>, REP;
615let Defs = [ECX,EDI], Uses = [AX,ECX,EDI] in
Evan Chengb783fa32007-07-19 01:14:50 +0000616def REP_STOSW : I<0xAB, RawFrm, (outs), (ins), "{rep;stosw|rep stosw}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000617 [(X86rep_stos i16)]>, REP, OpSize;
618let Defs = [ECX,EDI], Uses = [EAX,ECX,EDI] in
Evan Chengb783fa32007-07-19 01:14:50 +0000619def REP_STOSD : I<0xAB, RawFrm, (outs), (ins), "{rep;stosl|rep stosd}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000620 [(X86rep_stos i32)]>, REP;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000621
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000622let Defs = [RAX, RDX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000623def RDTSC : I<0x31, RawFrm, (outs), (ins), "rdtsc", [(X86rdtsc)]>,
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000624 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000625
Anton Korobeynikov39d40ba2008-01-15 07:02:33 +0000626let isBarrier = 1, hasCtrlDep = 1 in {
Chris Lattner56b941f2008-01-15 21:58:22 +0000627def TRAP : I<0x0B, RawFrm, (outs), (ins), "ud2", [(trap)]>, TB;
Anton Korobeynikov39d40ba2008-01-15 07:02:33 +0000628}
629
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000630//===----------------------------------------------------------------------===//
631// Input/Output Instructions...
632//
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000633let Defs = [AL], Uses = [DX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000634def IN8rr : I<0xEC, RawFrm, (outs), (ins),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000635 "in{b}\t{%dx, %al|%AL, %DX}", []>;
636let Defs = [AX], Uses = [DX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000637def IN16rr : I<0xED, RawFrm, (outs), (ins),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000638 "in{w}\t{%dx, %ax|%AX, %DX}", []>, OpSize;
639let Defs = [EAX], Uses = [DX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000640def IN32rr : I<0xED, RawFrm, (outs), (ins),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000641 "in{l}\t{%dx, %eax|%EAX, %DX}", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000642
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000643let Defs = [AL] in
Evan Chengb783fa32007-07-19 01:14:50 +0000644def IN8ri : Ii8<0xE4, RawFrm, (outs), (ins i16i8imm:$port),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000645 "in{b}\t{$port, %al|%AL, $port}", []>;
646let Defs = [AX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000647def IN16ri : Ii8<0xE5, RawFrm, (outs), (ins i16i8imm:$port),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000648 "in{w}\t{$port, %ax|%AX, $port}", []>, OpSize;
649let Defs = [EAX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000650def IN32ri : Ii8<0xE5, RawFrm, (outs), (ins i16i8imm:$port),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000651 "in{l}\t{$port, %eax|%EAX, $port}", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000652
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000653let Uses = [DX, AL] in
Evan Chengb783fa32007-07-19 01:14:50 +0000654def OUT8rr : I<0xEE, RawFrm, (outs), (ins),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000655 "out{b}\t{%al, %dx|%DX, %AL}", []>;
656let Uses = [DX, AX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000657def OUT16rr : I<0xEF, RawFrm, (outs), (ins),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000658 "out{w}\t{%ax, %dx|%DX, %AX}", []>, OpSize;
659let Uses = [DX, EAX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000660def OUT32rr : I<0xEF, RawFrm, (outs), (ins),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000661 "out{l}\t{%eax, %dx|%DX, %EAX}", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000662
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000663let Uses = [AL] in
Evan Chengb783fa32007-07-19 01:14:50 +0000664def OUT8ir : Ii8<0xE6, RawFrm, (outs), (ins i16i8imm:$port),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000665 "out{b}\t{%al, $port|$port, %AL}", []>;
666let Uses = [AX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000667def OUT16ir : Ii8<0xE7, RawFrm, (outs), (ins i16i8imm:$port),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000668 "out{w}\t{%ax, $port|$port, %AX}", []>, OpSize;
669let Uses = [EAX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000670def OUT32ir : Ii8<0xE7, RawFrm, (outs), (ins i16i8imm:$port),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000671 "out{l}\t{%eax, $port|$port, %EAX}", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000672
673//===----------------------------------------------------------------------===//
674// Move Instructions...
675//
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000676let neverHasSideEffects = 1 in {
Evan Chengb783fa32007-07-19 01:14:50 +0000677def MOV8rr : I<0x88, MRMDestReg, (outs GR8 :$dst), (ins GR8 :$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000678 "mov{b}\t{$src, $dst|$dst, $src}", []>;
Evan Chengb783fa32007-07-19 01:14:50 +0000679def MOV16rr : I<0x89, MRMDestReg, (outs GR16:$dst), (ins GR16:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000680 "mov{w}\t{$src, $dst|$dst, $src}", []>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +0000681def MOV32rr : I<0x89, MRMDestReg, (outs GR32:$dst), (ins GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000682 "mov{l}\t{$src, $dst|$dst, $src}", []>;
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000683}
Evan Cheng6f26e8b2008-06-18 08:13:07 +0000684let isReMaterializable = 1, isAsCheapAsAMove = 1 in {
Evan Chengb783fa32007-07-19 01:14:50 +0000685def MOV8ri : Ii8 <0xB0, AddRegFrm, (outs GR8 :$dst), (ins i8imm :$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000686 "mov{b}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000687 [(set GR8:$dst, imm:$src)]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000688def MOV16ri : Ii16<0xB8, AddRegFrm, (outs GR16:$dst), (ins i16imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000689 "mov{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000690 [(set GR16:$dst, imm:$src)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +0000691def MOV32ri : Ii32<0xB8, AddRegFrm, (outs GR32:$dst), (ins i32imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000692 "mov{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000693 [(set GR32:$dst, imm:$src)]>;
694}
Evan Chengb783fa32007-07-19 01:14:50 +0000695def MOV8mi : Ii8 <0xC6, MRM0m, (outs), (ins i8mem :$dst, i8imm :$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000696 "mov{b}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000697 [(store (i8 imm:$src), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000698def MOV16mi : Ii16<0xC7, MRM0m, (outs), (ins i16mem:$dst, i16imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000699 "mov{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000700 [(store (i16 imm:$src), addr:$dst)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +0000701def MOV32mi : Ii32<0xC7, MRM0m, (outs), (ins i32mem:$dst, i32imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000702 "mov{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000703 [(store (i32 imm:$src), addr:$dst)]>;
704
Dan Gohman5574cc72008-12-03 18:15:48 +0000705let canFoldAsLoad = 1, isReMaterializable = 1, mayHaveSideEffects = 1 in {
Evan Chengb783fa32007-07-19 01:14:50 +0000706def MOV8rm : I<0x8A, MRMSrcMem, (outs GR8 :$dst), (ins i8mem :$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000707 "mov{b}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000708 [(set GR8:$dst, (load addr:$src))]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000709def MOV16rm : I<0x8B, MRMSrcMem, (outs GR16:$dst), (ins i16mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000710 "mov{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000711 [(set GR16:$dst, (load addr:$src))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +0000712def MOV32rm : I<0x8B, MRMSrcMem, (outs GR32:$dst), (ins i32mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000713 "mov{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000714 [(set GR32:$dst, (load addr:$src))]>;
Evan Cheng4e84e452007-08-30 05:49:43 +0000715}
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000716
Evan Chengb783fa32007-07-19 01:14:50 +0000717def MOV8mr : I<0x88, MRMDestMem, (outs), (ins i8mem :$dst, GR8 :$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000718 "mov{b}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000719 [(store GR8:$src, addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000720def MOV16mr : I<0x89, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000721 "mov{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000722 [(store GR16:$src, addr:$dst)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +0000723def MOV32mr : I<0x89, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000724 "mov{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000725 [(store GR32:$src, addr:$dst)]>;
726
727//===----------------------------------------------------------------------===//
728// Fixed-Register Multiplication and Division Instructions...
729//
730
731// Extra precision multiplication
Evan Cheng55687072007-09-14 21:48:26 +0000732let Defs = [AL,AH,EFLAGS], Uses = [AL] in
Dan Gohman91888f02007-07-31 20:11:57 +0000733def MUL8r : I<0xF6, MRM4r, (outs), (ins GR8:$src), "mul{b}\t$src",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000734 // FIXME: Used for 8-bit mul, ignore result upper 8 bits.
735 // This probably ought to be moved to a def : Pat<> if the
736 // syntax can be accepted.
Bill Wendlingf5399032008-12-12 21:15:41 +0000737 [(set AL, (mul AL, GR8:$src)),
738 (implicit EFLAGS)]>; // AL,AH = AL*GR8
739
Chris Lattnerc7e96e72008-01-11 07:18:17 +0000740let Defs = [AX,DX,EFLAGS], Uses = [AX], neverHasSideEffects = 1 in
Bill Wendlingf5399032008-12-12 21:15:41 +0000741def MUL16r : I<0xF7, MRM4r, (outs), (ins GR16:$src),
742 "mul{w}\t$src",
743 []>, OpSize; // AX,DX = AX*GR16
744
Chris Lattnerc7e96e72008-01-11 07:18:17 +0000745let Defs = [EAX,EDX,EFLAGS], Uses = [EAX], neverHasSideEffects = 1 in
Bill Wendlingf5399032008-12-12 21:15:41 +0000746def MUL32r : I<0xF7, MRM4r, (outs), (ins GR32:$src),
747 "mul{l}\t$src",
748 []>; // EAX,EDX = EAX*GR32
749
Evan Cheng55687072007-09-14 21:48:26 +0000750let Defs = [AL,AH,EFLAGS], Uses = [AL] in
Evan Chengb783fa32007-07-19 01:14:50 +0000751def MUL8m : I<0xF6, MRM4m, (outs), (ins i8mem :$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000752 "mul{b}\t$src",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000753 // FIXME: Used for 8-bit mul, ignore result upper 8 bits.
754 // This probably ought to be moved to a def : Pat<> if the
755 // syntax can be accepted.
Bill Wendlingf5399032008-12-12 21:15:41 +0000756 [(set AL, (mul AL, (loadi8 addr:$src))),
757 (implicit EFLAGS)]>; // AL,AH = AL*[mem8]
758
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000759let mayLoad = 1, neverHasSideEffects = 1 in {
Evan Cheng55687072007-09-14 21:48:26 +0000760let Defs = [AX,DX,EFLAGS], Uses = [AX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000761def MUL16m : I<0xF7, MRM4m, (outs), (ins i16mem:$src),
Bill Wendlingf5399032008-12-12 21:15:41 +0000762 "mul{w}\t$src",
763 []>, OpSize; // AX,DX = AX*[mem16]
764
Evan Cheng55687072007-09-14 21:48:26 +0000765let Defs = [EAX,EDX,EFLAGS], Uses = [EAX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000766def MUL32m : I<0xF7, MRM4m, (outs), (ins i32mem:$src),
Bill Wendlingf5399032008-12-12 21:15:41 +0000767 "mul{l}\t$src",
768 []>; // EAX,EDX = EAX*[mem32]
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000769}
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000770
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000771let neverHasSideEffects = 1 in {
Evan Cheng55687072007-09-14 21:48:26 +0000772let Defs = [AL,AH,EFLAGS], Uses = [AL] in
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000773def IMUL8r : I<0xF6, MRM5r, (outs), (ins GR8:$src), "imul{b}\t$src", []>;
774 // AL,AH = AL*GR8
Evan Cheng55687072007-09-14 21:48:26 +0000775let Defs = [AX,DX,EFLAGS], Uses = [AX] in
Dan Gohman91888f02007-07-31 20:11:57 +0000776def IMUL16r : I<0xF7, MRM5r, (outs), (ins GR16:$src), "imul{w}\t$src", []>,
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000777 OpSize; // AX,DX = AX*GR16
Evan Cheng55687072007-09-14 21:48:26 +0000778let Defs = [EAX,EDX,EFLAGS], Uses = [EAX] in
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000779def IMUL32r : I<0xF7, MRM5r, (outs), (ins GR32:$src), "imul{l}\t$src", []>;
780 // EAX,EDX = EAX*GR32
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000781let mayLoad = 1 in {
Evan Cheng55687072007-09-14 21:48:26 +0000782let Defs = [AL,AH,EFLAGS], Uses = [AL] in
Evan Chengb783fa32007-07-19 01:14:50 +0000783def IMUL8m : I<0xF6, MRM5m, (outs), (ins i8mem :$src),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000784 "imul{b}\t$src", []>; // AL,AH = AL*[mem8]
Evan Cheng55687072007-09-14 21:48:26 +0000785let Defs = [AX,DX,EFLAGS], Uses = [AX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000786def IMUL16m : I<0xF7, MRM5m, (outs), (ins i16mem:$src),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000787 "imul{w}\t$src", []>, OpSize; // AX,DX = AX*[mem16]
788let Defs = [EAX,EDX], Uses = [EAX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000789def IMUL32m : I<0xF7, MRM5m, (outs), (ins i32mem:$src),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000790 "imul{l}\t$src", []>; // EAX,EDX = EAX*[mem32]
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000791}
Dan Gohmand44572d2008-11-18 21:29:14 +0000792} // neverHasSideEffects
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000793
794// unsigned division/remainder
Dale Johannesend8fd3562008-10-07 18:54:28 +0000795let Defs = [AL,AH,EFLAGS], Uses = [AX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000796def DIV8r : I<0xF6, MRM6r, (outs), (ins GR8:$src), // AX/r8 = AL,AH
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000797 "div{b}\t$src", []>;
Evan Cheng55687072007-09-14 21:48:26 +0000798let Defs = [AX,DX,EFLAGS], Uses = [AX,DX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000799def DIV16r : I<0xF7, MRM6r, (outs), (ins GR16:$src), // DX:AX/r16 = AX,DX
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000800 "div{w}\t$src", []>, OpSize;
Evan Cheng55687072007-09-14 21:48:26 +0000801let Defs = [EAX,EDX,EFLAGS], Uses = [EAX,EDX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000802def DIV32r : I<0xF7, MRM6r, (outs), (ins GR32:$src), // EDX:EAX/r32 = EAX,EDX
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000803 "div{l}\t$src", []>;
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000804let mayLoad = 1 in {
Dale Johannesend8fd3562008-10-07 18:54:28 +0000805let Defs = [AL,AH,EFLAGS], Uses = [AX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000806def DIV8m : I<0xF6, MRM6m, (outs), (ins i8mem:$src), // AX/[mem8] = AL,AH
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000807 "div{b}\t$src", []>;
Evan Cheng55687072007-09-14 21:48:26 +0000808let Defs = [AX,DX,EFLAGS], Uses = [AX,DX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000809def DIV16m : I<0xF7, MRM6m, (outs), (ins i16mem:$src), // DX:AX/[mem16] = AX,DX
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000810 "div{w}\t$src", []>, OpSize;
Evan Cheng55687072007-09-14 21:48:26 +0000811let Defs = [EAX,EDX,EFLAGS], Uses = [EAX,EDX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000812def DIV32m : I<0xF7, MRM6m, (outs), (ins i32mem:$src), // EDX:EAX/[mem32] = EAX,EDX
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000813 "div{l}\t$src", []>;
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000814}
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000815
816// Signed division/remainder.
Dale Johannesend8fd3562008-10-07 18:54:28 +0000817let Defs = [AL,AH,EFLAGS], Uses = [AX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000818def IDIV8r : I<0xF6, MRM7r, (outs), (ins GR8:$src), // AX/r8 = AL,AH
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000819 "idiv{b}\t$src", []>;
Evan Cheng55687072007-09-14 21:48:26 +0000820let Defs = [AX,DX,EFLAGS], Uses = [AX,DX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000821def IDIV16r: I<0xF7, MRM7r, (outs), (ins GR16:$src), // DX:AX/r16 = AX,DX
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000822 "idiv{w}\t$src", []>, OpSize;
Evan Cheng55687072007-09-14 21:48:26 +0000823let Defs = [EAX,EDX,EFLAGS], Uses = [EAX,EDX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000824def IDIV32r: I<0xF7, MRM7r, (outs), (ins GR32:$src), // EDX:EAX/r32 = EAX,EDX
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000825 "idiv{l}\t$src", []>;
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000826let mayLoad = 1, mayLoad = 1 in {
Dale Johannesend8fd3562008-10-07 18:54:28 +0000827let Defs = [AL,AH,EFLAGS], Uses = [AX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000828def IDIV8m : I<0xF6, MRM7m, (outs), (ins i8mem:$src), // AX/[mem8] = AL,AH
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000829 "idiv{b}\t$src", []>;
Evan Cheng55687072007-09-14 21:48:26 +0000830let Defs = [AX,DX,EFLAGS], Uses = [AX,DX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000831def IDIV16m: I<0xF7, MRM7m, (outs), (ins i16mem:$src), // DX:AX/[mem16] = AX,DX
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000832 "idiv{w}\t$src", []>, OpSize;
Evan Cheng55687072007-09-14 21:48:26 +0000833let Defs = [EAX,EDX,EFLAGS], Uses = [EAX,EDX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000834def IDIV32m: I<0xF7, MRM7m, (outs), (ins i32mem:$src), // EDX:EAX/[mem32] = EAX,EDX
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000835 "idiv{l}\t$src", []>;
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000836}
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000837
838//===----------------------------------------------------------------------===//
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000839// Two address Instructions.
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000840//
841let isTwoAddress = 1 in {
842
843// Conditional moves
Evan Cheng950aac02007-09-25 01:57:46 +0000844let Uses = [EFLAGS] in {
Evan Cheng926658c2007-10-05 23:13:21 +0000845let isCommutable = 1 in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000846def CMOVB16rr : I<0x42, MRMSrcReg, // if <u, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +0000847 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000848 "cmovb\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000849 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000850 X86_COND_B, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000851 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000852def CMOVB32rr : I<0x42, MRMSrcReg, // if <u, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +0000853 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000854 "cmovb\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000855 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000856 X86_COND_B, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000857 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000858def CMOVAE16rr: I<0x43, MRMSrcReg, // if >=u, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +0000859 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000860 "cmovae\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000861 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000862 X86_COND_AE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000863 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000864def CMOVAE32rr: I<0x43, MRMSrcReg, // if >=u, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +0000865 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000866 "cmovae\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000867 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000868 X86_COND_AE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000869 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000870def CMOVE16rr : I<0x44, MRMSrcReg, // if ==, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +0000871 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000872 "cmove\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000873 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000874 X86_COND_E, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000875 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000876def CMOVE32rr : I<0x44, MRMSrcReg, // if ==, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +0000877 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000878 "cmove\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000879 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000880 X86_COND_E, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000881 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000882def CMOVNE16rr: I<0x45, MRMSrcReg, // if !=, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +0000883 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000884 "cmovne\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000885 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000886 X86_COND_NE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000887 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000888def CMOVNE32rr: I<0x45, MRMSrcReg, // if !=, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +0000889 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000890 "cmovne\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000891 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000892 X86_COND_NE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000893 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000894def CMOVBE16rr: I<0x46, MRMSrcReg, // if <=u, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +0000895 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000896 "cmovbe\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000897 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000898 X86_COND_BE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000899 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000900def CMOVBE32rr: I<0x46, MRMSrcReg, // if <=u, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +0000901 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000902 "cmovbe\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000903 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000904 X86_COND_BE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000905 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000906def CMOVA16rr : I<0x47, MRMSrcReg, // if >u, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +0000907 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000908 "cmova\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000909 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000910 X86_COND_A, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000911 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000912def CMOVA32rr : I<0x47, MRMSrcReg, // if >u, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +0000913 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000914 "cmova\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000915 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000916 X86_COND_A, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000917 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000918def CMOVL16rr : I<0x4C, MRMSrcReg, // if <s, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +0000919 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000920 "cmovl\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000921 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000922 X86_COND_L, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000923 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000924def CMOVL32rr : I<0x4C, MRMSrcReg, // if <s, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +0000925 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000926 "cmovl\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000927 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000928 X86_COND_L, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000929 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000930def CMOVGE16rr: I<0x4D, MRMSrcReg, // if >=s, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +0000931 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000932 "cmovge\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000933 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000934 X86_COND_GE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000935 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000936def CMOVGE32rr: I<0x4D, MRMSrcReg, // if >=s, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +0000937 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000938 "cmovge\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000939 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000940 X86_COND_GE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000941 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000942def CMOVLE16rr: I<0x4E, MRMSrcReg, // if <=s, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +0000943 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000944 "cmovle\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000945 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000946 X86_COND_LE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000947 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000948def CMOVLE32rr: I<0x4E, MRMSrcReg, // if <=s, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +0000949 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000950 "cmovle\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000951 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000952 X86_COND_LE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000953 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000954def CMOVG16rr : I<0x4F, MRMSrcReg, // if >s, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +0000955 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000956 "cmovg\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000957 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000958 X86_COND_G, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000959 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000960def CMOVG32rr : I<0x4F, MRMSrcReg, // if >s, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +0000961 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000962 "cmovg\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000963 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000964 X86_COND_G, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000965 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000966def CMOVS16rr : I<0x48, MRMSrcReg, // if signed, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +0000967 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000968 "cmovs\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000969 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000970 X86_COND_S, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000971 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000972def CMOVS32rr : I<0x48, MRMSrcReg, // if signed, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +0000973 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000974 "cmovs\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000975 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000976 X86_COND_S, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000977 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000978def CMOVNS16rr: I<0x49, MRMSrcReg, // if !signed, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +0000979 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000980 "cmovns\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000981 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000982 X86_COND_NS, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000983 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000984def CMOVNS32rr: I<0x49, MRMSrcReg, // if !signed, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +0000985 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000986 "cmovns\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000987 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000988 X86_COND_NS, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000989 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000990def CMOVP16rr : I<0x4A, MRMSrcReg, // if parity, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +0000991 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000992 "cmovp\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000993 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000994 X86_COND_P, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000995 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000996def CMOVP32rr : I<0x4A, MRMSrcReg, // if parity, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +0000997 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000998 "cmovp\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000999 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001000 X86_COND_P, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001001 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001002def CMOVNP16rr : I<0x4B, MRMSrcReg, // if !parity, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +00001003 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001004 "cmovnp\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001005 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001006 X86_COND_NP, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001007 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001008def CMOVNP32rr : I<0x4B, MRMSrcReg, // if !parity, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +00001009 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001010 "cmovnp\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001011 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001012 X86_COND_NP, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001013 TB;
Dan Gohman12fd4d72009-01-07 00:35:10 +00001014def CMOVO16rr : I<0x40, MRMSrcReg, // if overflow, GR16 = GR16
1015 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
1016 "cmovo\t{$src2, $dst|$dst, $src2}",
1017 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
1018 X86_COND_O, EFLAGS))]>,
1019 TB, OpSize;
1020def CMOVO32rr : I<0x40, MRMSrcReg, // if overflow, GR32 = GR32
1021 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
1022 "cmovo\t{$src2, $dst|$dst, $src2}",
1023 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
1024 X86_COND_O, EFLAGS))]>,
Evan Cheng950aac02007-09-25 01:57:46 +00001025 TB;
Dan Gohman12fd4d72009-01-07 00:35:10 +00001026def CMOVNO16rr : I<0x41, MRMSrcReg, // if !overflow, GR16 = GR16
1027 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
1028 "cmovno\t{$src2, $dst|$dst, $src2}",
1029 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
1030 X86_COND_NO, EFLAGS))]>,
1031 TB, OpSize;
1032def CMOVNO32rr : I<0x41, MRMSrcReg, // if !overflow, GR32 = GR32
1033 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
1034 "cmovno\t{$src2, $dst|$dst, $src2}",
1035 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
1036 X86_COND_NO, EFLAGS))]>,
1037 TB;
1038} // isCommutable = 1
Evan Cheng926658c2007-10-05 23:13:21 +00001039
1040def CMOVB16rm : I<0x42, MRMSrcMem, // if <u, GR16 = [mem16]
1041 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1042 "cmovb\t{$src2, $dst|$dst, $src2}",
1043 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1044 X86_COND_B, EFLAGS))]>,
1045 TB, OpSize;
1046def CMOVB32rm : I<0x42, MRMSrcMem, // if <u, GR32 = [mem32]
1047 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1048 "cmovb\t{$src2, $dst|$dst, $src2}",
1049 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1050 X86_COND_B, EFLAGS))]>,
1051 TB;
1052def CMOVAE16rm: I<0x43, MRMSrcMem, // if >=u, GR16 = [mem16]
1053 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1054 "cmovae\t{$src2, $dst|$dst, $src2}",
1055 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1056 X86_COND_AE, EFLAGS))]>,
1057 TB, OpSize;
1058def CMOVAE32rm: I<0x43, MRMSrcMem, // if >=u, GR32 = [mem32]
1059 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1060 "cmovae\t{$src2, $dst|$dst, $src2}",
1061 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1062 X86_COND_AE, EFLAGS))]>,
1063 TB;
1064def CMOVE16rm : I<0x44, MRMSrcMem, // if ==, GR16 = [mem16]
1065 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1066 "cmove\t{$src2, $dst|$dst, $src2}",
1067 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1068 X86_COND_E, EFLAGS))]>,
1069 TB, OpSize;
1070def CMOVE32rm : I<0x44, MRMSrcMem, // if ==, GR32 = [mem32]
1071 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1072 "cmove\t{$src2, $dst|$dst, $src2}",
1073 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1074 X86_COND_E, EFLAGS))]>,
1075 TB;
1076def CMOVNE16rm: I<0x45, MRMSrcMem, // if !=, GR16 = [mem16]
1077 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1078 "cmovne\t{$src2, $dst|$dst, $src2}",
1079 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1080 X86_COND_NE, EFLAGS))]>,
1081 TB, OpSize;
1082def CMOVNE32rm: I<0x45, MRMSrcMem, // if !=, GR32 = [mem32]
1083 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1084 "cmovne\t{$src2, $dst|$dst, $src2}",
1085 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1086 X86_COND_NE, EFLAGS))]>,
1087 TB;
1088def CMOVBE16rm: I<0x46, MRMSrcMem, // if <=u, GR16 = [mem16]
1089 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1090 "cmovbe\t{$src2, $dst|$dst, $src2}",
1091 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1092 X86_COND_BE, EFLAGS))]>,
1093 TB, OpSize;
1094def CMOVBE32rm: I<0x46, MRMSrcMem, // if <=u, GR32 = [mem32]
1095 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1096 "cmovbe\t{$src2, $dst|$dst, $src2}",
1097 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1098 X86_COND_BE, EFLAGS))]>,
1099 TB;
1100def CMOVA16rm : I<0x47, MRMSrcMem, // if >u, GR16 = [mem16]
1101 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1102 "cmova\t{$src2, $dst|$dst, $src2}",
1103 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1104 X86_COND_A, EFLAGS))]>,
1105 TB, OpSize;
1106def CMOVA32rm : I<0x47, MRMSrcMem, // if >u, GR32 = [mem32]
1107 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1108 "cmova\t{$src2, $dst|$dst, $src2}",
1109 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1110 X86_COND_A, EFLAGS))]>,
1111 TB;
1112def CMOVL16rm : I<0x4C, MRMSrcMem, // if <s, GR16 = [mem16]
1113 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1114 "cmovl\t{$src2, $dst|$dst, $src2}",
1115 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1116 X86_COND_L, EFLAGS))]>,
1117 TB, OpSize;
1118def CMOVL32rm : I<0x4C, MRMSrcMem, // if <s, GR32 = [mem32]
1119 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1120 "cmovl\t{$src2, $dst|$dst, $src2}",
1121 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1122 X86_COND_L, EFLAGS))]>,
1123 TB;
1124def CMOVGE16rm: I<0x4D, MRMSrcMem, // if >=s, GR16 = [mem16]
1125 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1126 "cmovge\t{$src2, $dst|$dst, $src2}",
1127 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1128 X86_COND_GE, EFLAGS))]>,
1129 TB, OpSize;
1130def CMOVGE32rm: I<0x4D, MRMSrcMem, // if >=s, GR32 = [mem32]
1131 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1132 "cmovge\t{$src2, $dst|$dst, $src2}",
1133 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1134 X86_COND_GE, EFLAGS))]>,
1135 TB;
1136def CMOVLE16rm: I<0x4E, MRMSrcMem, // if <=s, GR16 = [mem16]
1137 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1138 "cmovle\t{$src2, $dst|$dst, $src2}",
1139 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1140 X86_COND_LE, EFLAGS))]>,
1141 TB, OpSize;
1142def CMOVLE32rm: I<0x4E, MRMSrcMem, // if <=s, GR32 = [mem32]
1143 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1144 "cmovle\t{$src2, $dst|$dst, $src2}",
1145 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1146 X86_COND_LE, EFLAGS))]>,
1147 TB;
1148def CMOVG16rm : I<0x4F, MRMSrcMem, // if >s, GR16 = [mem16]
1149 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1150 "cmovg\t{$src2, $dst|$dst, $src2}",
1151 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1152 X86_COND_G, EFLAGS))]>,
1153 TB, OpSize;
1154def CMOVG32rm : I<0x4F, MRMSrcMem, // if >s, GR32 = [mem32]
1155 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1156 "cmovg\t{$src2, $dst|$dst, $src2}",
1157 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1158 X86_COND_G, EFLAGS))]>,
1159 TB;
1160def CMOVS16rm : I<0x48, MRMSrcMem, // if signed, GR16 = [mem16]
1161 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1162 "cmovs\t{$src2, $dst|$dst, $src2}",
1163 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1164 X86_COND_S, EFLAGS))]>,
1165 TB, OpSize;
1166def CMOVS32rm : I<0x48, MRMSrcMem, // if signed, GR32 = [mem32]
1167 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1168 "cmovs\t{$src2, $dst|$dst, $src2}",
1169 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1170 X86_COND_S, EFLAGS))]>,
1171 TB;
1172def CMOVNS16rm: I<0x49, MRMSrcMem, // if !signed, GR16 = [mem16]
1173 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1174 "cmovns\t{$src2, $dst|$dst, $src2}",
1175 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1176 X86_COND_NS, EFLAGS))]>,
1177 TB, OpSize;
1178def CMOVNS32rm: I<0x49, MRMSrcMem, // if !signed, GR32 = [mem32]
1179 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1180 "cmovns\t{$src2, $dst|$dst, $src2}",
1181 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1182 X86_COND_NS, EFLAGS))]>,
1183 TB;
1184def CMOVP16rm : I<0x4A, MRMSrcMem, // if parity, GR16 = [mem16]
1185 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1186 "cmovp\t{$src2, $dst|$dst, $src2}",
1187 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1188 X86_COND_P, EFLAGS))]>,
1189 TB, OpSize;
1190def CMOVP32rm : I<0x4A, MRMSrcMem, // if parity, GR32 = [mem32]
1191 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1192 "cmovp\t{$src2, $dst|$dst, $src2}",
1193 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1194 X86_COND_P, EFLAGS))]>,
1195 TB;
1196def CMOVNP16rm : I<0x4B, MRMSrcMem, // if !parity, GR16 = [mem16]
1197 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1198 "cmovnp\t{$src2, $dst|$dst, $src2}",
1199 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1200 X86_COND_NP, EFLAGS))]>,
1201 TB, OpSize;
Dan Gohman12fd4d72009-01-07 00:35:10 +00001202def CMOVNP32rm : I<0x4B, MRMSrcMem, // if !parity, GR32 = [mem32]
1203 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1204 "cmovnp\t{$src2, $dst|$dst, $src2}",
1205 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1206 X86_COND_NP, EFLAGS))]>,
1207 TB;
1208def CMOVO16rm : I<0x40, MRMSrcMem, // if overflow, GR16 = [mem16]
1209 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1210 "cmovo\t{$src2, $dst|$dst, $src2}",
1211 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1212 X86_COND_O, EFLAGS))]>,
1213 TB, OpSize;
1214def CMOVO32rm : I<0x40, MRMSrcMem, // if overflow, GR32 = [mem32]
1215 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1216 "cmovo\t{$src2, $dst|$dst, $src2}",
1217 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1218 X86_COND_O, EFLAGS))]>,
1219 TB;
1220def CMOVNO16rm : I<0x41, MRMSrcMem, // if !overflow, GR16 = [mem16]
1221 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1222 "cmovno\t{$src2, $dst|$dst, $src2}",
1223 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1224 X86_COND_NO, EFLAGS))]>,
1225 TB, OpSize;
1226def CMOVNO32rm : I<0x41, MRMSrcMem, // if !overflow, GR32 = [mem32]
1227 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1228 "cmovno\t{$src2, $dst|$dst, $src2}",
1229 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1230 X86_COND_NO, EFLAGS))]>,
1231 TB;
Evan Cheng950aac02007-09-25 01:57:46 +00001232} // Uses = [EFLAGS]
1233
1234
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001235// unary instructions
1236let CodeSize = 2 in {
Evan Cheng55687072007-09-14 21:48:26 +00001237let Defs = [EFLAGS] in {
Dan Gohman91888f02007-07-31 20:11:57 +00001238def NEG8r : I<0xF6, MRM3r, (outs GR8 :$dst), (ins GR8 :$src), "neg{b}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001239 [(set GR8:$dst, (ineg GR8:$src)),
1240 (implicit EFLAGS)]>;
Dan Gohman91888f02007-07-31 20:11:57 +00001241def NEG16r : I<0xF7, MRM3r, (outs GR16:$dst), (ins GR16:$src), "neg{w}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001242 [(set GR16:$dst, (ineg GR16:$src)),
1243 (implicit EFLAGS)]>, OpSize;
Dan Gohman91888f02007-07-31 20:11:57 +00001244def NEG32r : I<0xF7, MRM3r, (outs GR32:$dst), (ins GR32:$src), "neg{l}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001245 [(set GR32:$dst, (ineg GR32:$src)),
1246 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001247let isTwoAddress = 0 in {
Dan Gohman91888f02007-07-31 20:11:57 +00001248 def NEG8m : I<0xF6, MRM3m, (outs), (ins i8mem :$dst), "neg{b}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001249 [(store (ineg (loadi8 addr:$dst)), addr:$dst),
1250 (implicit EFLAGS)]>;
Dan Gohman91888f02007-07-31 20:11:57 +00001251 def NEG16m : I<0xF7, MRM3m, (outs), (ins i16mem:$dst), "neg{w}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001252 [(store (ineg (loadi16 addr:$dst)), addr:$dst),
1253 (implicit EFLAGS)]>, OpSize;
Dan Gohman91888f02007-07-31 20:11:57 +00001254 def NEG32m : I<0xF7, MRM3m, (outs), (ins i32mem:$dst), "neg{l}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001255 [(store (ineg (loadi32 addr:$dst)), addr:$dst),
1256 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001257}
Evan Cheng55687072007-09-14 21:48:26 +00001258} // Defs = [EFLAGS]
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001259
Evan Chengc6cee682009-01-21 02:09:05 +00001260// Match xor -1 to not. Favors these over a move imm + xor to save code size.
1261let AddedComplexity = 15 in {
Dan Gohman91888f02007-07-31 20:11:57 +00001262def NOT8r : I<0xF6, MRM2r, (outs GR8 :$dst), (ins GR8 :$src), "not{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001263 [(set GR8:$dst, (not GR8:$src))]>;
Dan Gohman91888f02007-07-31 20:11:57 +00001264def NOT16r : I<0xF7, MRM2r, (outs GR16:$dst), (ins GR16:$src), "not{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001265 [(set GR16:$dst, (not GR16:$src))]>, OpSize;
Dan Gohman91888f02007-07-31 20:11:57 +00001266def NOT32r : I<0xF7, MRM2r, (outs GR32:$dst), (ins GR32:$src), "not{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001267 [(set GR32:$dst, (not GR32:$src))]>;
Evan Chengc6cee682009-01-21 02:09:05 +00001268}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001269let isTwoAddress = 0 in {
Dan Gohman91888f02007-07-31 20:11:57 +00001270 def NOT8m : I<0xF6, MRM2m, (outs), (ins i8mem :$dst), "not{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001271 [(store (not (loadi8 addr:$dst)), addr:$dst)]>;
Dan Gohman91888f02007-07-31 20:11:57 +00001272 def NOT16m : I<0xF7, MRM2m, (outs), (ins i16mem:$dst), "not{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001273 [(store (not (loadi16 addr:$dst)), addr:$dst)]>, OpSize;
Dan Gohman91888f02007-07-31 20:11:57 +00001274 def NOT32m : I<0xF7, MRM2m, (outs), (ins i32mem:$dst), "not{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001275 [(store (not (loadi32 addr:$dst)), addr:$dst)]>;
1276}
1277} // CodeSize
1278
1279// TODO: inc/dec is slow for P4, but fast for Pentium-M.
Evan Cheng55687072007-09-14 21:48:26 +00001280let Defs = [EFLAGS] in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001281let CodeSize = 2 in
Dan Gohman91888f02007-07-31 20:11:57 +00001282def INC8r : I<0xFE, MRM0r, (outs GR8 :$dst), (ins GR8 :$src), "inc{b}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001283 [(set GR8:$dst, (add GR8:$src, 1)),
1284 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001285let isConvertibleToThreeAddress = 1, CodeSize = 1 in { // Can xform into LEA.
Dan Gohman91888f02007-07-31 20:11:57 +00001286def INC16r : I<0x40, AddRegFrm, (outs GR16:$dst), (ins GR16:$src), "inc{w}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001287 [(set GR16:$dst, (add GR16:$src, 1)),
1288 (implicit EFLAGS)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001289 OpSize, Requires<[In32BitMode]>;
Dan Gohman91888f02007-07-31 20:11:57 +00001290def INC32r : I<0x40, AddRegFrm, (outs GR32:$dst), (ins GR32:$src), "inc{l}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001291 [(set GR32:$dst, (add GR32:$src, 1)),
1292 (implicit EFLAGS)]>, Requires<[In32BitMode]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001293}
1294let isTwoAddress = 0, CodeSize = 2 in {
Dan Gohman91888f02007-07-31 20:11:57 +00001295 def INC8m : I<0xFE, MRM0m, (outs), (ins i8mem :$dst), "inc{b}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001296 [(store (add (loadi8 addr:$dst), 1), addr:$dst),
1297 (implicit EFLAGS)]>;
Dan Gohman91888f02007-07-31 20:11:57 +00001298 def INC16m : I<0xFF, MRM0m, (outs), (ins i16mem:$dst), "inc{w}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001299 [(store (add (loadi16 addr:$dst), 1), addr:$dst),
1300 (implicit EFLAGS)]>,
Evan Cheng4a7e72f2007-10-19 21:23:22 +00001301 OpSize, Requires<[In32BitMode]>;
Dan Gohman91888f02007-07-31 20:11:57 +00001302 def INC32m : I<0xFF, MRM0m, (outs), (ins i32mem:$dst), "inc{l}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001303 [(store (add (loadi32 addr:$dst), 1), addr:$dst),
1304 (implicit EFLAGS)]>,
Evan Cheng4a7e72f2007-10-19 21:23:22 +00001305 Requires<[In32BitMode]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001306}
1307
1308let CodeSize = 2 in
Dan Gohman91888f02007-07-31 20:11:57 +00001309def DEC8r : I<0xFE, MRM1r, (outs GR8 :$dst), (ins GR8 :$src), "dec{b}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001310 [(set GR8:$dst, (add GR8:$src, -1)),
1311 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001312let isConvertibleToThreeAddress = 1, CodeSize = 1 in { // Can xform into LEA.
Dan Gohman91888f02007-07-31 20:11:57 +00001313def DEC16r : I<0x48, AddRegFrm, (outs GR16:$dst), (ins GR16:$src), "dec{w}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001314 [(set GR16:$dst, (add GR16:$src, -1)),
1315 (implicit EFLAGS)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001316 OpSize, Requires<[In32BitMode]>;
Dan Gohman91888f02007-07-31 20:11:57 +00001317def DEC32r : I<0x48, AddRegFrm, (outs GR32:$dst), (ins GR32:$src), "dec{l}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001318 [(set GR32:$dst, (add GR32:$src, -1)),
1319 (implicit EFLAGS)]>, Requires<[In32BitMode]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001320}
1321
1322let isTwoAddress = 0, CodeSize = 2 in {
Dan Gohman91888f02007-07-31 20:11:57 +00001323 def DEC8m : I<0xFE, MRM1m, (outs), (ins i8mem :$dst), "dec{b}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001324 [(store (add (loadi8 addr:$dst), -1), addr:$dst),
1325 (implicit EFLAGS)]>;
Dan Gohman91888f02007-07-31 20:11:57 +00001326 def DEC16m : I<0xFF, MRM1m, (outs), (ins i16mem:$dst), "dec{w}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001327 [(store (add (loadi16 addr:$dst), -1), addr:$dst),
1328 (implicit EFLAGS)]>,
Evan Cheng4a7e72f2007-10-19 21:23:22 +00001329 OpSize, Requires<[In32BitMode]>;
Dan Gohman91888f02007-07-31 20:11:57 +00001330 def DEC32m : I<0xFF, MRM1m, (outs), (ins i32mem:$dst), "dec{l}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001331 [(store (add (loadi32 addr:$dst), -1), addr:$dst),
1332 (implicit EFLAGS)]>,
Evan Cheng4a7e72f2007-10-19 21:23:22 +00001333 Requires<[In32BitMode]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001334}
Evan Cheng55687072007-09-14 21:48:26 +00001335} // Defs = [EFLAGS]
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001336
1337// Logical operators...
Evan Cheng55687072007-09-14 21:48:26 +00001338let Defs = [EFLAGS] in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001339let isCommutable = 1 in { // X = AND Y, Z --> X = AND Z, Y
1340def AND8rr : I<0x20, MRMDestReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001341 (outs GR8 :$dst), (ins GR8 :$src1, GR8 :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001342 "and{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001343 [(set GR8:$dst, (and GR8:$src1, GR8:$src2)),
1344 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001345def AND16rr : I<0x21, MRMDestReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001346 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001347 "and{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001348 [(set GR16:$dst, (and GR16:$src1, GR16:$src2)),
1349 (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001350def AND32rr : I<0x21, MRMDestReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001351 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001352 "and{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001353 [(set GR32:$dst, (and GR32:$src1, GR32:$src2)),
1354 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001355}
1356
1357def AND8rm : I<0x22, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001358 (outs GR8 :$dst), (ins GR8 :$src1, i8mem :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001359 "and{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001360 [(set GR8:$dst, (and GR8:$src1, (load addr:$src2))),
1361 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001362def AND16rm : I<0x23, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001363 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001364 "and{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001365 [(set GR16:$dst, (and GR16:$src1, (load addr:$src2))),
1366 (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001367def AND32rm : I<0x23, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001368 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001369 "and{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001370 [(set GR32:$dst, (and GR32:$src1, (load addr:$src2))),
1371 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001372
1373def AND8ri : Ii8<0x80, MRM4r,
Evan Chengb783fa32007-07-19 01:14:50 +00001374 (outs GR8 :$dst), (ins GR8 :$src1, i8imm :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001375 "and{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001376 [(set GR8:$dst, (and GR8:$src1, imm:$src2)),
1377 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001378def AND16ri : Ii16<0x81, MRM4r,
Evan Chengb783fa32007-07-19 01:14:50 +00001379 (outs GR16:$dst), (ins GR16:$src1, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001380 "and{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001381 [(set GR16:$dst, (and GR16:$src1, imm:$src2)),
1382 (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001383def AND32ri : Ii32<0x81, MRM4r,
Evan Chengb783fa32007-07-19 01:14:50 +00001384 (outs GR32:$dst), (ins GR32:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001385 "and{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001386 [(set GR32:$dst, (and GR32:$src1, imm:$src2)),
1387 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001388def AND16ri8 : Ii8<0x83, MRM4r,
Evan Chengb783fa32007-07-19 01:14:50 +00001389 (outs GR16:$dst), (ins GR16:$src1, i16i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001390 "and{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001391 [(set GR16:$dst, (and GR16:$src1, i16immSExt8:$src2)),
1392 (implicit EFLAGS)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001393 OpSize;
1394def AND32ri8 : Ii8<0x83, MRM4r,
Evan Chengb783fa32007-07-19 01:14:50 +00001395 (outs GR32:$dst), (ins GR32:$src1, i32i8imm:$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, i32immSExt8:$src2)),
1398 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001399
1400let isTwoAddress = 0 in {
1401 def AND8mr : I<0x20, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001402 (outs), (ins i8mem :$dst, GR8 :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001403 "and{b}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001404 [(store (and (load addr:$dst), GR8:$src), addr:$dst),
1405 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001406 def AND16mr : I<0x21, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001407 (outs), (ins i16mem:$dst, GR16:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001408 "and{w}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001409 [(store (and (load addr:$dst), GR16:$src), addr:$dst),
1410 (implicit EFLAGS)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001411 OpSize;
1412 def AND32mr : I<0x21, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001413 (outs), (ins i32mem:$dst, GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001414 "and{l}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001415 [(store (and (load addr:$dst), GR32:$src), addr:$dst),
1416 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001417 def AND8mi : Ii8<0x80, MRM4m,
Evan Chengb783fa32007-07-19 01:14:50 +00001418 (outs), (ins i8mem :$dst, i8imm :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001419 "and{b}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001420 [(store (and (loadi8 addr:$dst), imm:$src), addr:$dst),
1421 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001422 def AND16mi : Ii16<0x81, MRM4m,
Evan Chengb783fa32007-07-19 01:14:50 +00001423 (outs), (ins i16mem:$dst, i16imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001424 "and{w}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001425 [(store (and (loadi16 addr:$dst), imm:$src), addr:$dst),
1426 (implicit EFLAGS)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001427 OpSize;
1428 def AND32mi : Ii32<0x81, MRM4m,
Evan Chengb783fa32007-07-19 01:14:50 +00001429 (outs), (ins i32mem:$dst, i32imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001430 "and{l}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001431 [(store (and (loadi32 addr:$dst), imm:$src), addr:$dst),
1432 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001433 def AND16mi8 : Ii8<0x83, MRM4m,
Evan Chengb783fa32007-07-19 01:14:50 +00001434 (outs), (ins i16mem:$dst, i16i8imm :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001435 "and{w}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001436 [(store (and (load addr:$dst), i16immSExt8:$src), addr:$dst),
1437 (implicit EFLAGS)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001438 OpSize;
1439 def AND32mi8 : Ii8<0x83, MRM4m,
Evan Chengb783fa32007-07-19 01:14:50 +00001440 (outs), (ins i32mem:$dst, i32i8imm :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001441 "and{l}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001442 [(store (and (load addr:$dst), i32immSExt8:$src), addr:$dst),
1443 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001444}
1445
1446
1447let isCommutable = 1 in { // X = OR Y, Z --> X = OR Z, Y
Evan Chengb783fa32007-07-19 01:14:50 +00001448def OR8rr : I<0x08, MRMDestReg, (outs GR8 :$dst), (ins GR8 :$src1, GR8 :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001449 "or{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001450 [(set GR8:$dst, (or GR8:$src1, GR8:$src2)),
1451 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001452def OR16rr : I<0x09, MRMDestReg, (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001453 "or{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001454 [(set GR16:$dst, (or GR16:$src1, GR16:$src2)),
1455 (implicit EFLAGS)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001456def OR32rr : I<0x09, MRMDestReg, (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001457 "or{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001458 [(set GR32:$dst, (or GR32:$src1, GR32:$src2)),
1459 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001460}
Evan Chengb783fa32007-07-19 01:14:50 +00001461def OR8rm : I<0x0A, MRMSrcMem , (outs GR8 :$dst), (ins GR8 :$src1, i8mem :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001462 "or{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001463 [(set GR8:$dst, (or GR8:$src1, (load addr:$src2))),
1464 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001465def OR16rm : I<0x0B, MRMSrcMem , (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001466 "or{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001467 [(set GR16:$dst, (or GR16:$src1, (load addr:$src2))),
1468 (implicit EFLAGS)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001469def OR32rm : I<0x0B, MRMSrcMem , (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001470 "or{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001471 [(set GR32:$dst, (or GR32:$src1, (load addr:$src2))),
1472 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001473
Evan Chengb783fa32007-07-19 01:14:50 +00001474def OR8ri : Ii8 <0x80, MRM1r, (outs GR8 :$dst), (ins GR8 :$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001475 "or{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001476 [(set GR8:$dst, (or GR8:$src1, imm:$src2)),
1477 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001478def OR16ri : Ii16<0x81, MRM1r, (outs GR16:$dst), (ins GR16:$src1, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001479 "or{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001480 [(set GR16:$dst, (or GR16:$src1, imm:$src2)),
1481 (implicit EFLAGS)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001482def OR32ri : Ii32<0x81, MRM1r, (outs GR32:$dst), (ins GR32:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001483 "or{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001484 [(set GR32:$dst, (or GR32:$src1, imm:$src2)),
1485 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001486
Evan Chengb783fa32007-07-19 01:14:50 +00001487def OR16ri8 : Ii8<0x83, MRM1r, (outs GR16:$dst), (ins GR16:$src1, i16i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001488 "or{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001489 [(set GR16:$dst, (or GR16:$src1, i16immSExt8:$src2)),
1490 (implicit EFLAGS)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001491def OR32ri8 : Ii8<0x83, MRM1r, (outs GR32:$dst), (ins GR32:$src1, i32i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001492 "or{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001493 [(set GR32:$dst, (or GR32:$src1, i32immSExt8:$src2)),
1494 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001495let isTwoAddress = 0 in {
Evan Chengb783fa32007-07-19 01:14:50 +00001496 def OR8mr : I<0x08, MRMDestMem, (outs), (ins i8mem:$dst, GR8:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001497 "or{b}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001498 [(store (or (load addr:$dst), GR8:$src), addr:$dst),
1499 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001500 def OR16mr : I<0x09, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001501 "or{w}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001502 [(store (or (load addr:$dst), GR16:$src), addr:$dst),
1503 (implicit EFLAGS)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001504 def OR32mr : I<0x09, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001505 "or{l}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001506 [(store (or (load addr:$dst), GR32:$src), addr:$dst),
1507 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001508 def OR8mi : Ii8<0x80, MRM1m, (outs), (ins i8mem :$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001509 "or{b}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001510 [(store (or (loadi8 addr:$dst), imm:$src), addr:$dst),
1511 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001512 def OR16mi : Ii16<0x81, MRM1m, (outs), (ins i16mem:$dst, i16imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001513 "or{w}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001514 [(store (or (loadi16 addr:$dst), imm:$src), addr:$dst),
1515 (implicit EFLAGS)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001516 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001517 def OR32mi : Ii32<0x81, MRM1m, (outs), (ins i32mem:$dst, i32imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001518 "or{l}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001519 [(store (or (loadi32 addr:$dst), imm:$src), addr:$dst),
1520 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001521 def OR16mi8 : Ii8<0x83, MRM1m, (outs), (ins i16mem:$dst, i16i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001522 "or{w}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001523 [(store (or (load addr:$dst), i16immSExt8:$src), addr:$dst),
1524 (implicit EFLAGS)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001525 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001526 def OR32mi8 : Ii8<0x83, MRM1m, (outs), (ins i32mem:$dst, i32i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001527 "or{l}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001528 [(store (or (load addr:$dst), i32immSExt8:$src), addr:$dst),
1529 (implicit EFLAGS)]>;
Bill Wendlingba5d5b02008-05-29 01:02:09 +00001530} // isTwoAddress = 0
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001531
1532
Evan Cheng6f26e8b2008-06-18 08:13:07 +00001533let isCommutable = 1 in { // X = XOR Y, Z --> X = XOR Z, Y
Bill Wendlingba5d5b02008-05-29 01:02:09 +00001534 def XOR8rr : I<0x30, MRMDestReg,
1535 (outs GR8 :$dst), (ins GR8 :$src1, GR8 :$src2),
1536 "xor{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001537 [(set GR8:$dst, (xor GR8:$src1, GR8:$src2)),
1538 (implicit EFLAGS)]>;
Bill Wendlingba5d5b02008-05-29 01:02:09 +00001539 def XOR16rr : I<0x31, MRMDestReg,
1540 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
1541 "xor{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001542 [(set GR16:$dst, (xor GR16:$src1, GR16:$src2)),
1543 (implicit EFLAGS)]>, OpSize;
Bill Wendlingba5d5b02008-05-29 01:02:09 +00001544 def XOR32rr : I<0x31, MRMDestReg,
1545 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
1546 "xor{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001547 [(set GR32:$dst, (xor GR32:$src1, GR32:$src2)),
1548 (implicit EFLAGS)]>;
Evan Cheng6f26e8b2008-06-18 08:13:07 +00001549} // isCommutable = 1
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001550
1551def XOR8rm : I<0x32, MRMSrcMem ,
Evan Chengb783fa32007-07-19 01:14:50 +00001552 (outs GR8 :$dst), (ins GR8:$src1, i8mem :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001553 "xor{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001554 [(set GR8:$dst, (xor GR8:$src1, (load addr:$src2))),
1555 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001556def XOR16rm : I<0x33, MRMSrcMem ,
Evan Chengb783fa32007-07-19 01:14:50 +00001557 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001558 "xor{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001559 [(set GR16:$dst, (xor GR16:$src1, (load addr:$src2))),
1560 (implicit EFLAGS)]>,
Bill Wendlingba5d5b02008-05-29 01:02:09 +00001561 OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001562def XOR32rm : I<0x33, MRMSrcMem ,
Evan Chengb783fa32007-07-19 01:14:50 +00001563 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001564 "xor{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001565 [(set GR32:$dst, (xor GR32:$src1, (load addr:$src2))),
1566 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001567
Bill Wendlingbac38eb2008-05-29 03:46:36 +00001568def XOR8ri : Ii8<0x80, MRM6r,
1569 (outs GR8:$dst), (ins GR8:$src1, i8imm:$src2),
1570 "xor{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001571 [(set GR8:$dst, (xor GR8:$src1, imm:$src2)),
1572 (implicit EFLAGS)]>;
Bill Wendlingbac38eb2008-05-29 03:46:36 +00001573def XOR16ri : Ii16<0x81, MRM6r,
1574 (outs GR16:$dst), (ins GR16:$src1, i16imm:$src2),
1575 "xor{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001576 [(set GR16:$dst, (xor GR16:$src1, imm:$src2)),
1577 (implicit EFLAGS)]>, OpSize;
Bill Wendlingbac38eb2008-05-29 03:46:36 +00001578def XOR32ri : Ii32<0x81, MRM6r,
1579 (outs GR32:$dst), (ins GR32:$src1, i32imm:$src2),
1580 "xor{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001581 [(set GR32:$dst, (xor GR32:$src1, imm:$src2)),
1582 (implicit EFLAGS)]>;
Bill Wendlingbac38eb2008-05-29 03:46:36 +00001583def XOR16ri8 : Ii8<0x83, MRM6r,
1584 (outs GR16:$dst), (ins GR16:$src1, i16i8imm:$src2),
1585 "xor{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001586 [(set GR16:$dst, (xor GR16:$src1, i16immSExt8:$src2)),
1587 (implicit EFLAGS)]>,
Bill Wendlingbac38eb2008-05-29 03:46:36 +00001588 OpSize;
1589def XOR32ri8 : Ii8<0x83, MRM6r,
1590 (outs GR32:$dst), (ins GR32:$src1, i32i8imm:$src2),
1591 "xor{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001592 [(set GR32:$dst, (xor GR32:$src1, i32immSExt8:$src2)),
1593 (implicit EFLAGS)]>;
Bill Wendlingba5d5b02008-05-29 01:02:09 +00001594
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001595let isTwoAddress = 0 in {
1596 def XOR8mr : I<0x30, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001597 (outs), (ins i8mem :$dst, GR8 :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001598 "xor{b}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001599 [(store (xor (load addr:$dst), GR8:$src), addr:$dst),
1600 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001601 def XOR16mr : I<0x31, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001602 (outs), (ins i16mem:$dst, GR16:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001603 "xor{w}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001604 [(store (xor (load addr:$dst), GR16:$src), addr:$dst),
1605 (implicit EFLAGS)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001606 OpSize;
1607 def XOR32mr : I<0x31, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001608 (outs), (ins i32mem:$dst, GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001609 "xor{l}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001610 [(store (xor (load addr:$dst), GR32:$src), addr:$dst),
1611 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001612 def XOR8mi : Ii8<0x80, MRM6m,
Evan Chengb783fa32007-07-19 01:14:50 +00001613 (outs), (ins i8mem :$dst, i8imm :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001614 "xor{b}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001615 [(store (xor (loadi8 addr:$dst), imm:$src), addr:$dst),
1616 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001617 def XOR16mi : Ii16<0x81, MRM6m,
Evan Chengb783fa32007-07-19 01:14:50 +00001618 (outs), (ins i16mem:$dst, i16imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001619 "xor{w}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001620 [(store (xor (loadi16 addr:$dst), imm:$src), addr:$dst),
1621 (implicit EFLAGS)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001622 OpSize;
1623 def XOR32mi : Ii32<0x81, MRM6m,
Evan Chengb783fa32007-07-19 01:14:50 +00001624 (outs), (ins i32mem:$dst, i32imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001625 "xor{l}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001626 [(store (xor (loadi32 addr:$dst), imm:$src), addr:$dst),
1627 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001628 def XOR16mi8 : Ii8<0x83, MRM6m,
Evan Chengb783fa32007-07-19 01:14:50 +00001629 (outs), (ins i16mem:$dst, i16i8imm :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001630 "xor{w}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001631 [(store (xor (load addr:$dst), i16immSExt8:$src), addr:$dst),
1632 (implicit EFLAGS)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001633 OpSize;
1634 def XOR32mi8 : Ii8<0x83, MRM6m,
Evan Chengb783fa32007-07-19 01:14:50 +00001635 (outs), (ins i32mem:$dst, i32i8imm :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001636 "xor{l}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001637 [(store (xor (load addr:$dst), i32immSExt8:$src), addr:$dst),
1638 (implicit EFLAGS)]>;
Bill Wendlingba5d5b02008-05-29 01:02:09 +00001639} // isTwoAddress = 0
Evan Cheng55687072007-09-14 21:48:26 +00001640} // Defs = [EFLAGS]
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001641
1642// Shift instructions
Evan Cheng55687072007-09-14 21:48:26 +00001643let Defs = [EFLAGS] in {
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001644let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00001645def SHL8rCL : I<0xD2, MRM4r, (outs GR8 :$dst), (ins GR8 :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001646 "shl{b}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001647 [(set GR8:$dst, (shl GR8:$src, CL))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001648def SHL16rCL : I<0xD3, MRM4r, (outs GR16:$dst), (ins GR16:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001649 "shl{w}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001650 [(set GR16:$dst, (shl GR16:$src, CL))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001651def SHL32rCL : I<0xD3, MRM4r, (outs GR32:$dst), (ins GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001652 "shl{l}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001653 [(set GR32:$dst, (shl GR32:$src, CL))]>;
Bill Wendlingba5d5b02008-05-29 01:02:09 +00001654} // Uses = [CL]
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001655
Evan Chengb783fa32007-07-19 01:14:50 +00001656def SHL8ri : Ii8<0xC0, MRM4r, (outs GR8 :$dst), (ins GR8 :$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001657 "shl{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001658 [(set GR8:$dst, (shl GR8:$src1, (i8 imm:$src2)))]>;
1659let isConvertibleToThreeAddress = 1 in { // Can transform into LEA.
Evan Chengb783fa32007-07-19 01:14:50 +00001660def SHL16ri : Ii8<0xC1, MRM4r, (outs GR16:$dst), (ins GR16:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001661 "shl{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001662 [(set GR16:$dst, (shl GR16:$src1, (i8 imm:$src2)))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001663def SHL32ri : Ii8<0xC1, MRM4r, (outs GR32:$dst), (ins GR32:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001664 "shl{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001665 [(set GR32:$dst, (shl GR32:$src1, (i8 imm:$src2)))]>;
Chris Lattnerf4005a82008-01-11 18:00:50 +00001666// NOTE: We don't use shifts of a register by one, because 'add reg,reg' is
1667// cheaper.
Bill Wendlingba5d5b02008-05-29 01:02:09 +00001668} // isConvertibleToThreeAddress = 1
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001669
1670let isTwoAddress = 0 in {
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001671 let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00001672 def SHL8mCL : I<0xD2, MRM4m, (outs), (ins i8mem :$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001673 "shl{b}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001674 [(store (shl (loadi8 addr:$dst), CL), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001675 def SHL16mCL : I<0xD3, MRM4m, (outs), (ins i16mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001676 "shl{w}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001677 [(store (shl (loadi16 addr:$dst), CL), addr:$dst)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001678 def SHL32mCL : I<0xD3, MRM4m, (outs), (ins i32mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001679 "shl{l}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001680 [(store (shl (loadi32 addr:$dst), CL), addr:$dst)]>;
1681 }
Evan Chengb783fa32007-07-19 01:14:50 +00001682 def SHL8mi : Ii8<0xC0, MRM4m, (outs), (ins i8mem :$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001683 "shl{b}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001684 [(store (shl (loadi8 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001685 def SHL16mi : Ii8<0xC1, MRM4m, (outs), (ins i16mem:$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001686 "shl{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001687 [(store (shl (loadi16 addr:$dst), (i8 imm:$src)), addr:$dst)]>,
1688 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001689 def SHL32mi : Ii8<0xC1, MRM4m, (outs), (ins i32mem:$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001690 "shl{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001691 [(store (shl (loadi32 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
1692
1693 // Shift by 1
Evan Chengb783fa32007-07-19 01:14:50 +00001694 def SHL8m1 : I<0xD0, MRM4m, (outs), (ins i8mem :$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001695 "shl{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001696 [(store (shl (loadi8 addr:$dst), (i8 1)), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001697 def SHL16m1 : I<0xD1, MRM4m, (outs), (ins i16mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001698 "shl{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001699 [(store (shl (loadi16 addr:$dst), (i8 1)), addr:$dst)]>,
1700 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001701 def SHL32m1 : I<0xD1, MRM4m, (outs), (ins i32mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001702 "shl{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001703 [(store (shl (loadi32 addr:$dst), (i8 1)), addr:$dst)]>;
1704}
1705
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001706let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00001707def SHR8rCL : I<0xD2, MRM5r, (outs GR8 :$dst), (ins GR8 :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001708 "shr{b}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001709 [(set GR8:$dst, (srl GR8:$src, CL))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001710def SHR16rCL : I<0xD3, MRM5r, (outs GR16:$dst), (ins GR16:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001711 "shr{w}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001712 [(set GR16:$dst, (srl GR16:$src, CL))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001713def SHR32rCL : I<0xD3, MRM5r, (outs GR32:$dst), (ins GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001714 "shr{l}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001715 [(set GR32:$dst, (srl GR32:$src, CL))]>;
1716}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001717
Evan Chengb783fa32007-07-19 01:14:50 +00001718def SHR8ri : Ii8<0xC0, MRM5r, (outs GR8:$dst), (ins GR8:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001719 "shr{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001720 [(set GR8:$dst, (srl GR8:$src1, (i8 imm:$src2)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001721def SHR16ri : Ii8<0xC1, MRM5r, (outs GR16:$dst), (ins GR16:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001722 "shr{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001723 [(set GR16:$dst, (srl GR16:$src1, (i8 imm:$src2)))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001724def SHR32ri : Ii8<0xC1, MRM5r, (outs GR32:$dst), (ins GR32:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001725 "shr{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001726 [(set GR32:$dst, (srl GR32:$src1, (i8 imm:$src2)))]>;
1727
1728// Shift by 1
Evan Chengb783fa32007-07-19 01:14:50 +00001729def SHR8r1 : I<0xD0, MRM5r, (outs GR8:$dst), (ins GR8:$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00001730 "shr{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001731 [(set GR8:$dst, (srl GR8:$src1, (i8 1)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001732def SHR16r1 : I<0xD1, MRM5r, (outs GR16:$dst), (ins GR16:$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00001733 "shr{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001734 [(set GR16:$dst, (srl GR16:$src1, (i8 1)))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001735def SHR32r1 : I<0xD1, MRM5r, (outs GR32:$dst), (ins GR32:$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00001736 "shr{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001737 [(set GR32:$dst, (srl GR32:$src1, (i8 1)))]>;
1738
1739let isTwoAddress = 0 in {
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001740 let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00001741 def SHR8mCL : I<0xD2, MRM5m, (outs), (ins i8mem :$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001742 "shr{b}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001743 [(store (srl (loadi8 addr:$dst), CL), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001744 def SHR16mCL : I<0xD3, MRM5m, (outs), (ins i16mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001745 "shr{w}\t{%cl, $dst|$dst, %CL}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001746 [(store (srl (loadi16 addr:$dst), CL), addr:$dst)]>,
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001747 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001748 def SHR32mCL : I<0xD3, MRM5m, (outs), (ins i32mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001749 "shr{l}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001750 [(store (srl (loadi32 addr:$dst), CL), addr:$dst)]>;
1751 }
Evan Chengb783fa32007-07-19 01:14:50 +00001752 def SHR8mi : Ii8<0xC0, MRM5m, (outs), (ins i8mem :$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001753 "shr{b}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001754 [(store (srl (loadi8 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001755 def SHR16mi : Ii8<0xC1, MRM5m, (outs), (ins i16mem:$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001756 "shr{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001757 [(store (srl (loadi16 addr:$dst), (i8 imm:$src)), addr:$dst)]>,
1758 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001759 def SHR32mi : Ii8<0xC1, MRM5m, (outs), (ins i32mem:$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001760 "shr{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001761 [(store (srl (loadi32 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
1762
1763 // Shift by 1
Evan Chengb783fa32007-07-19 01:14:50 +00001764 def SHR8m1 : I<0xD0, MRM5m, (outs), (ins i8mem :$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001765 "shr{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001766 [(store (srl (loadi8 addr:$dst), (i8 1)), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001767 def SHR16m1 : I<0xD1, MRM5m, (outs), (ins i16mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001768 "shr{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001769 [(store (srl (loadi16 addr:$dst), (i8 1)), addr:$dst)]>,OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001770 def SHR32m1 : I<0xD1, MRM5m, (outs), (ins i32mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001771 "shr{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001772 [(store (srl (loadi32 addr:$dst), (i8 1)), addr:$dst)]>;
1773}
1774
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001775let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00001776def SAR8rCL : I<0xD2, MRM7r, (outs GR8 :$dst), (ins GR8 :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001777 "sar{b}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001778 [(set GR8:$dst, (sra GR8:$src, CL))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001779def SAR16rCL : I<0xD3, MRM7r, (outs GR16:$dst), (ins GR16:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001780 "sar{w}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001781 [(set GR16:$dst, (sra GR16:$src, CL))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001782def SAR32rCL : I<0xD3, MRM7r, (outs GR32:$dst), (ins GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001783 "sar{l}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001784 [(set GR32:$dst, (sra GR32:$src, CL))]>;
1785}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001786
Evan Chengb783fa32007-07-19 01:14:50 +00001787def SAR8ri : Ii8<0xC0, MRM7r, (outs GR8 :$dst), (ins GR8 :$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001788 "sar{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001789 [(set GR8:$dst, (sra GR8:$src1, (i8 imm:$src2)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001790def SAR16ri : Ii8<0xC1, MRM7r, (outs GR16:$dst), (ins GR16:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001791 "sar{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001792 [(set GR16:$dst, (sra GR16:$src1, (i8 imm:$src2)))]>,
1793 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001794def SAR32ri : Ii8<0xC1, MRM7r, (outs GR32:$dst), (ins GR32:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001795 "sar{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001796 [(set GR32:$dst, (sra GR32:$src1, (i8 imm:$src2)))]>;
1797
1798// Shift by 1
Evan Chengb783fa32007-07-19 01:14:50 +00001799def SAR8r1 : I<0xD0, MRM7r, (outs GR8 :$dst), (ins GR8 :$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00001800 "sar{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001801 [(set GR8:$dst, (sra GR8:$src1, (i8 1)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001802def SAR16r1 : I<0xD1, MRM7r, (outs GR16:$dst), (ins GR16:$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00001803 "sar{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001804 [(set GR16:$dst, (sra GR16:$src1, (i8 1)))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001805def SAR32r1 : I<0xD1, MRM7r, (outs GR32:$dst), (ins GR32:$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00001806 "sar{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001807 [(set GR32:$dst, (sra GR32:$src1, (i8 1)))]>;
1808
1809let isTwoAddress = 0 in {
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001810 let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00001811 def SAR8mCL : I<0xD2, MRM7m, (outs), (ins i8mem :$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001812 "sar{b}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001813 [(store (sra (loadi8 addr:$dst), CL), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001814 def SAR16mCL : I<0xD3, MRM7m, (outs), (ins i16mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001815 "sar{w}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001816 [(store (sra (loadi16 addr:$dst), CL), addr:$dst)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001817 def SAR32mCL : I<0xD3, MRM7m, (outs), (ins i32mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001818 "sar{l}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001819 [(store (sra (loadi32 addr:$dst), CL), addr:$dst)]>;
1820 }
Evan Chengb783fa32007-07-19 01:14:50 +00001821 def SAR8mi : Ii8<0xC0, MRM7m, (outs), (ins i8mem :$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001822 "sar{b}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001823 [(store (sra (loadi8 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001824 def SAR16mi : Ii8<0xC1, MRM7m, (outs), (ins i16mem:$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001825 "sar{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001826 [(store (sra (loadi16 addr:$dst), (i8 imm:$src)), addr:$dst)]>,
1827 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001828 def SAR32mi : Ii8<0xC1, MRM7m, (outs), (ins i32mem:$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001829 "sar{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001830 [(store (sra (loadi32 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
1831
1832 // Shift by 1
Evan Chengb783fa32007-07-19 01:14:50 +00001833 def SAR8m1 : I<0xD0, MRM7m, (outs), (ins i8mem :$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001834 "sar{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001835 [(store (sra (loadi8 addr:$dst), (i8 1)), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001836 def SAR16m1 : I<0xD1, MRM7m, (outs), (ins i16mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001837 "sar{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001838 [(store (sra (loadi16 addr:$dst), (i8 1)), addr:$dst)]>,
1839 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001840 def SAR32m1 : I<0xD1, MRM7m, (outs), (ins i32mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001841 "sar{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001842 [(store (sra (loadi32 addr:$dst), (i8 1)), addr:$dst)]>;
1843}
1844
1845// Rotate instructions
1846// FIXME: provide shorter instructions when imm8 == 1
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001847let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00001848def ROL8rCL : I<0xD2, MRM0r, (outs GR8 :$dst), (ins GR8 :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001849 "rol{b}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001850 [(set GR8:$dst, (rotl GR8:$src, CL))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001851def ROL16rCL : I<0xD3, MRM0r, (outs GR16:$dst), (ins GR16:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001852 "rol{w}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001853 [(set GR16:$dst, (rotl GR16:$src, CL))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001854def ROL32rCL : I<0xD3, MRM0r, (outs GR32:$dst), (ins GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001855 "rol{l}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001856 [(set GR32:$dst, (rotl GR32:$src, CL))]>;
1857}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001858
Evan Chengb783fa32007-07-19 01:14:50 +00001859def ROL8ri : Ii8<0xC0, MRM0r, (outs GR8 :$dst), (ins GR8 :$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001860 "rol{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001861 [(set GR8:$dst, (rotl GR8:$src1, (i8 imm:$src2)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001862def ROL16ri : Ii8<0xC1, MRM0r, (outs GR16:$dst), (ins GR16:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001863 "rol{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001864 [(set GR16:$dst, (rotl GR16:$src1, (i8 imm:$src2)))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001865def ROL32ri : Ii8<0xC1, MRM0r, (outs GR32:$dst), (ins GR32:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001866 "rol{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001867 [(set GR32:$dst, (rotl GR32:$src1, (i8 imm:$src2)))]>;
1868
1869// Rotate by 1
Evan Chengb783fa32007-07-19 01:14:50 +00001870def ROL8r1 : I<0xD0, MRM0r, (outs GR8 :$dst), (ins GR8 :$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00001871 "rol{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001872 [(set GR8:$dst, (rotl GR8:$src1, (i8 1)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001873def ROL16r1 : I<0xD1, MRM0r, (outs GR16:$dst), (ins GR16:$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00001874 "rol{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001875 [(set GR16:$dst, (rotl GR16:$src1, (i8 1)))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001876def ROL32r1 : I<0xD1, MRM0r, (outs GR32:$dst), (ins GR32:$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00001877 "rol{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001878 [(set GR32:$dst, (rotl GR32:$src1, (i8 1)))]>;
1879
1880let isTwoAddress = 0 in {
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001881 let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00001882 def ROL8mCL : I<0xD2, MRM0m, (outs), (ins i8mem :$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001883 "rol{b}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001884 [(store (rotl (loadi8 addr:$dst), CL), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001885 def ROL16mCL : I<0xD3, MRM0m, (outs), (ins i16mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001886 "rol{w}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001887 [(store (rotl (loadi16 addr:$dst), CL), addr:$dst)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001888 def ROL32mCL : I<0xD3, MRM0m, (outs), (ins i32mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001889 "rol{l}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001890 [(store (rotl (loadi32 addr:$dst), CL), addr:$dst)]>;
1891 }
Evan Chengb783fa32007-07-19 01:14:50 +00001892 def ROL8mi : Ii8<0xC0, MRM0m, (outs), (ins i8mem :$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001893 "rol{b}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001894 [(store (rotl (loadi8 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001895 def ROL16mi : Ii8<0xC1, MRM0m, (outs), (ins i16mem:$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001896 "rol{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001897 [(store (rotl (loadi16 addr:$dst), (i8 imm:$src)), addr:$dst)]>,
1898 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001899 def ROL32mi : Ii8<0xC1, MRM0m, (outs), (ins i32mem:$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001900 "rol{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001901 [(store (rotl (loadi32 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
1902
1903 // Rotate by 1
Evan Chengb783fa32007-07-19 01:14:50 +00001904 def ROL8m1 : I<0xD0, MRM0m, (outs), (ins i8mem :$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001905 "rol{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001906 [(store (rotl (loadi8 addr:$dst), (i8 1)), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001907 def ROL16m1 : I<0xD1, MRM0m, (outs), (ins i16mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001908 "rol{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001909 [(store (rotl (loadi16 addr:$dst), (i8 1)), addr:$dst)]>,
1910 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001911 def ROL32m1 : I<0xD1, MRM0m, (outs), (ins i32mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001912 "rol{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001913 [(store (rotl (loadi32 addr:$dst), (i8 1)), addr:$dst)]>;
1914}
1915
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001916let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00001917def ROR8rCL : I<0xD2, MRM1r, (outs GR8 :$dst), (ins GR8 :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001918 "ror{b}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001919 [(set GR8:$dst, (rotr GR8:$src, CL))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001920def ROR16rCL : I<0xD3, MRM1r, (outs GR16:$dst), (ins GR16:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001921 "ror{w}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001922 [(set GR16:$dst, (rotr GR16:$src, CL))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001923def ROR32rCL : I<0xD3, MRM1r, (outs GR32:$dst), (ins GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001924 "ror{l}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001925 [(set GR32:$dst, (rotr GR32:$src, CL))]>;
1926}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001927
Evan Chengb783fa32007-07-19 01:14:50 +00001928def ROR8ri : Ii8<0xC0, MRM1r, (outs GR8 :$dst), (ins GR8 :$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001929 "ror{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001930 [(set GR8:$dst, (rotr GR8:$src1, (i8 imm:$src2)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001931def ROR16ri : Ii8<0xC1, MRM1r, (outs GR16:$dst), (ins GR16:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001932 "ror{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001933 [(set GR16:$dst, (rotr GR16:$src1, (i8 imm:$src2)))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001934def ROR32ri : Ii8<0xC1, MRM1r, (outs GR32:$dst), (ins GR32:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001935 "ror{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001936 [(set GR32:$dst, (rotr GR32:$src1, (i8 imm:$src2)))]>;
1937
1938// Rotate by 1
Evan Chengb783fa32007-07-19 01:14:50 +00001939def ROR8r1 : I<0xD0, MRM1r, (outs GR8 :$dst), (ins GR8 :$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00001940 "ror{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001941 [(set GR8:$dst, (rotr GR8:$src1, (i8 1)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001942def ROR16r1 : I<0xD1, MRM1r, (outs GR16:$dst), (ins GR16:$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00001943 "ror{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001944 [(set GR16:$dst, (rotr GR16:$src1, (i8 1)))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001945def ROR32r1 : I<0xD1, MRM1r, (outs GR32:$dst), (ins GR32:$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00001946 "ror{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001947 [(set GR32:$dst, (rotr GR32:$src1, (i8 1)))]>;
1948
1949let isTwoAddress = 0 in {
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001950 let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00001951 def ROR8mCL : I<0xD2, MRM1m, (outs), (ins i8mem :$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001952 "ror{b}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001953 [(store (rotr (loadi8 addr:$dst), CL), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001954 def ROR16mCL : I<0xD3, MRM1m, (outs), (ins i16mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001955 "ror{w}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001956 [(store (rotr (loadi16 addr:$dst), CL), addr:$dst)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001957 def ROR32mCL : I<0xD3, MRM1m, (outs), (ins i32mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001958 "ror{l}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001959 [(store (rotr (loadi32 addr:$dst), CL), addr:$dst)]>;
1960 }
Evan Chengb783fa32007-07-19 01:14:50 +00001961 def ROR8mi : Ii8<0xC0, MRM1m, (outs), (ins i8mem :$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001962 "ror{b}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001963 [(store (rotr (loadi8 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001964 def ROR16mi : Ii8<0xC1, MRM1m, (outs), (ins i16mem:$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001965 "ror{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001966 [(store (rotr (loadi16 addr:$dst), (i8 imm:$src)), addr:$dst)]>,
1967 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001968 def ROR32mi : Ii8<0xC1, MRM1m, (outs), (ins i32mem:$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001969 "ror{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001970 [(store (rotr (loadi32 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
1971
1972 // Rotate by 1
Evan Chengb783fa32007-07-19 01:14:50 +00001973 def ROR8m1 : I<0xD0, MRM1m, (outs), (ins i8mem :$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001974 "ror{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001975 [(store (rotr (loadi8 addr:$dst), (i8 1)), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001976 def ROR16m1 : I<0xD1, MRM1m, (outs), (ins i16mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001977 "ror{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001978 [(store (rotr (loadi16 addr:$dst), (i8 1)), addr:$dst)]>,
1979 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001980 def ROR32m1 : I<0xD1, MRM1m, (outs), (ins i32mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001981 "ror{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001982 [(store (rotr (loadi32 addr:$dst), (i8 1)), addr:$dst)]>;
1983}
1984
1985
1986
1987// Double shift instructions (generalizations of rotate)
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001988let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00001989def SHLD32rrCL : I<0xA5, MRMDestReg, (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001990 "shld{l}\t{%cl, $src2, $dst|$dst, $src2, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001991 [(set GR32:$dst, (X86shld GR32:$src1, GR32:$src2, CL))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00001992def SHRD32rrCL : I<0xAD, MRMDestReg, (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001993 "shrd{l}\t{%cl, $src2, $dst|$dst, $src2, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001994 [(set GR32:$dst, (X86shrd GR32:$src1, GR32:$src2, CL))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00001995def SHLD16rrCL : I<0xA5, MRMDestReg, (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001996 "shld{w}\t{%cl, $src2, $dst|$dst, $src2, %CL}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001997 [(set GR16:$dst, (X86shld GR16:$src1, GR16:$src2, CL))]>,
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001998 TB, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001999def SHRD16rrCL : I<0xAD, MRMDestReg, (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002000 "shrd{w}\t{%cl, $src2, $dst|$dst, $src2, %CL}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002001 [(set GR16:$dst, (X86shrd GR16:$src1, GR16:$src2, CL))]>,
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002002 TB, OpSize;
2003}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002004
2005let isCommutable = 1 in { // These instructions commute to each other.
2006def SHLD32rri8 : Ii8<0xA4, MRMDestReg,
Evan Chengb783fa32007-07-19 01:14:50 +00002007 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2, i8imm:$src3),
Dan Gohman91888f02007-07-31 20:11:57 +00002008 "shld{l}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002009 [(set GR32:$dst, (X86shld GR32:$src1, GR32:$src2,
2010 (i8 imm:$src3)))]>,
2011 TB;
2012def SHRD32rri8 : Ii8<0xAC, MRMDestReg,
Evan Chengb783fa32007-07-19 01:14:50 +00002013 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2, i8imm:$src3),
Dan Gohman91888f02007-07-31 20:11:57 +00002014 "shrd{l}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002015 [(set GR32:$dst, (X86shrd GR32:$src1, GR32:$src2,
2016 (i8 imm:$src3)))]>,
2017 TB;
2018def SHLD16rri8 : Ii8<0xA4, MRMDestReg,
Evan Chengb783fa32007-07-19 01:14:50 +00002019 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2, i8imm:$src3),
Dan Gohman91888f02007-07-31 20:11:57 +00002020 "shld{w}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002021 [(set GR16:$dst, (X86shld GR16:$src1, GR16:$src2,
2022 (i8 imm:$src3)))]>,
2023 TB, OpSize;
2024def SHRD16rri8 : Ii8<0xAC, MRMDestReg,
Evan Chengb783fa32007-07-19 01:14:50 +00002025 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2, i8imm:$src3),
Dan Gohman91888f02007-07-31 20:11:57 +00002026 "shrd{w}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002027 [(set GR16:$dst, (X86shrd GR16:$src1, GR16:$src2,
2028 (i8 imm:$src3)))]>,
2029 TB, OpSize;
2030}
2031
2032let isTwoAddress = 0 in {
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002033 let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00002034 def SHLD32mrCL : I<0xA5, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002035 "shld{l}\t{%cl, $src2, $dst|$dst, $src2, %CL}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002036 [(store (X86shld (loadi32 addr:$dst), GR32:$src2, CL),
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002037 addr:$dst)]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00002038 def SHRD32mrCL : I<0xAD, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002039 "shrd{l}\t{%cl, $src2, $dst|$dst, $src2, %CL}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002040 [(store (X86shrd (loadi32 addr:$dst), GR32:$src2, CL),
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002041 addr:$dst)]>, TB;
2042 }
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002043 def SHLD32mri8 : Ii8<0xA4, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00002044 (outs), (ins i32mem:$dst, GR32:$src2, i8imm:$src3),
Dan Gohman91888f02007-07-31 20:11:57 +00002045 "shld{l}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002046 [(store (X86shld (loadi32 addr:$dst), GR32:$src2,
2047 (i8 imm:$src3)), addr:$dst)]>,
2048 TB;
2049 def SHRD32mri8 : Ii8<0xAC, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00002050 (outs), (ins i32mem:$dst, GR32:$src2, i8imm:$src3),
Dan Gohman91888f02007-07-31 20:11:57 +00002051 "shrd{l}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002052 [(store (X86shrd (loadi32 addr:$dst), GR32:$src2,
2053 (i8 imm:$src3)), addr:$dst)]>,
2054 TB;
2055
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002056 let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00002057 def SHLD16mrCL : I<0xA5, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002058 "shld{w}\t{%cl, $src2, $dst|$dst, $src2, %CL}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002059 [(store (X86shld (loadi16 addr:$dst), GR16:$src2, CL),
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002060 addr:$dst)]>, TB, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002061 def SHRD16mrCL : I<0xAD, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002062 "shrd{w}\t{%cl, $src2, $dst|$dst, $src2, %CL}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002063 [(store (X86shrd (loadi16 addr:$dst), GR16:$src2, CL),
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002064 addr:$dst)]>, TB, OpSize;
2065 }
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002066 def SHLD16mri8 : Ii8<0xA4, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00002067 (outs), (ins i16mem:$dst, GR16:$src2, i8imm:$src3),
Dan Gohman91888f02007-07-31 20:11:57 +00002068 "shld{w}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002069 [(store (X86shld (loadi16 addr:$dst), GR16:$src2,
2070 (i8 imm:$src3)), addr:$dst)]>,
2071 TB, OpSize;
2072 def SHRD16mri8 : Ii8<0xAC, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00002073 (outs), (ins i16mem:$dst, GR16:$src2, i8imm:$src3),
Dan Gohman91888f02007-07-31 20:11:57 +00002074 "shrd{w}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002075 [(store (X86shrd (loadi16 addr:$dst), GR16:$src2,
2076 (i8 imm:$src3)), addr:$dst)]>,
2077 TB, OpSize;
2078}
Evan Cheng55687072007-09-14 21:48:26 +00002079} // Defs = [EFLAGS]
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002080
2081
2082// Arithmetic.
Evan Cheng55687072007-09-14 21:48:26 +00002083let Defs = [EFLAGS] in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002084let isCommutable = 1 in { // X = ADD Y, Z --> X = ADD Z, Y
Bill Wendlingae034ed2008-12-12 00:56:36 +00002085// Register-Register Addition
2086def ADD8rr : I<0x00, MRMDestReg, (outs GR8 :$dst),
2087 (ins GR8 :$src1, GR8 :$src2),
2088 "add{b}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002089 [(set GR8:$dst, (add GR8:$src1, GR8:$src2)),
Bill Wendlingae034ed2008-12-12 00:56:36 +00002090 (implicit EFLAGS)]>;
2091
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002092let isConvertibleToThreeAddress = 1 in { // Can transform into LEA.
Bill Wendlingae034ed2008-12-12 00:56:36 +00002093// Register-Register Addition
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002094def ADD16rr : I<0x01, MRMDestReg, (outs GR16:$dst),
2095 (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002096 "add{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002097 [(set GR16:$dst, (add GR16:$src1, GR16:$src2)),
2098 (implicit EFLAGS)]>, OpSize;
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002099def ADD32rr : I<0x01, MRMDestReg, (outs GR32:$dst),
2100 (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002101 "add{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002102 [(set GR32:$dst, (add GR32:$src1, GR32:$src2)),
2103 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002104} // end isConvertibleToThreeAddress
2105} // end isCommutable
Bill Wendlingae034ed2008-12-12 00:56:36 +00002106
2107// Register-Memory Addition
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002108def ADD8rm : I<0x02, MRMSrcMem, (outs GR8 :$dst),
2109 (ins GR8 :$src1, i8mem :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002110 "add{b}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002111 [(set GR8:$dst, (add GR8:$src1, (load addr:$src2))),
2112 (implicit EFLAGS)]>;
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002113def ADD16rm : I<0x03, MRMSrcMem, (outs GR16:$dst),
2114 (ins GR16:$src1, i16mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002115 "add{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002116 [(set GR16:$dst, (add GR16:$src1, (load addr:$src2))),
2117 (implicit EFLAGS)]>, OpSize;
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002118def ADD32rm : I<0x03, MRMSrcMem, (outs GR32:$dst),
2119 (ins GR32:$src1, i32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002120 "add{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002121 [(set GR32:$dst, (add GR32:$src1, (load addr:$src2))),
2122 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002123
Bill Wendlingae034ed2008-12-12 00:56:36 +00002124// Register-Integer Addition
2125def ADD8ri : Ii8<0x80, MRM0r, (outs GR8:$dst), (ins GR8:$src1, i8imm:$src2),
2126 "add{b}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002127 [(set GR8:$dst, (add GR8:$src1, imm:$src2)),
2128 (implicit EFLAGS)]>;
Bill Wendlingae034ed2008-12-12 00:56:36 +00002129
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002130let isConvertibleToThreeAddress = 1 in { // Can transform into LEA.
Bill Wendlingae034ed2008-12-12 00:56:36 +00002131// Register-Integer Addition
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002132def ADD16ri : Ii16<0x81, MRM0r, (outs GR16:$dst),
2133 (ins GR16:$src1, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002134 "add{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002135 [(set GR16:$dst, (add GR16:$src1, imm:$src2)),
2136 (implicit EFLAGS)]>, OpSize;
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002137def ADD32ri : Ii32<0x81, MRM0r, (outs GR32:$dst),
2138 (ins GR32:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002139 "add{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002140 [(set GR32:$dst, (add GR32:$src1, imm:$src2)),
2141 (implicit EFLAGS)]>;
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002142def ADD16ri8 : Ii8<0x83, MRM0r, (outs GR16:$dst),
2143 (ins GR16:$src1, i16i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002144 "add{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002145 [(set GR16:$dst, (add GR16:$src1, i16immSExt8:$src2)),
2146 (implicit EFLAGS)]>, OpSize;
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002147def ADD32ri8 : Ii8<0x83, MRM0r, (outs GR32:$dst),
2148 (ins GR32:$src1, i32i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002149 "add{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002150 [(set GR32:$dst, (add GR32:$src1, i32immSExt8:$src2)),
2151 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002152}
2153
2154let isTwoAddress = 0 in {
Bill Wendlingae034ed2008-12-12 00:56:36 +00002155 // Memory-Register Addition
Bill Wendlingf5399032008-12-12 21:15:41 +00002156 def ADD8mr : I<0x00, MRMDestMem, (outs), (ins i8mem:$dst, GR8:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002157 "add{b}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002158 [(store (add (load addr:$dst), GR8:$src2), addr:$dst),
2159 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002160 def ADD16mr : I<0x01, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002161 "add{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002162 [(store (add (load addr:$dst), GR16:$src2), addr:$dst),
2163 (implicit EFLAGS)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002164 def ADD32mr : I<0x01, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002165 "add{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002166 [(store (add (load addr:$dst), GR32:$src2), addr:$dst),
2167 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002168 def ADD8mi : Ii8<0x80, MRM0m, (outs), (ins i8mem :$dst, i8imm :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002169 "add{b}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002170 [(store (add (loadi8 addr:$dst), imm:$src2), addr:$dst),
2171 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002172 def ADD16mi : Ii16<0x81, MRM0m, (outs), (ins i16mem:$dst, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002173 "add{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002174 [(store (add (loadi16 addr:$dst), imm:$src2), addr:$dst),
2175 (implicit EFLAGS)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002176 def ADD32mi : Ii32<0x81, MRM0m, (outs), (ins i32mem:$dst, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002177 "add{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002178 [(store (add (loadi32 addr:$dst), imm:$src2), addr:$dst),
2179 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002180 def ADD16mi8 : Ii8<0x83, MRM0m, (outs), (ins i16mem:$dst, i16i8imm :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002181 "add{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002182 [(store (add (load addr:$dst), i16immSExt8:$src2),
2183 addr:$dst),
2184 (implicit EFLAGS)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002185 def ADD32mi8 : Ii8<0x83, MRM0m, (outs), (ins i32mem:$dst, i32i8imm :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002186 "add{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingae034ed2008-12-12 00:56:36 +00002187 [(store (add (load addr:$dst), i32immSExt8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00002188 addr:$dst),
2189 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002190}
2191
Evan Cheng259471d2007-10-05 17:59:57 +00002192let Uses = [EFLAGS] in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002193let isCommutable = 1 in { // X = ADC Y, Z --> X = ADC Z, Y
Evan Chengb783fa32007-07-19 01:14:50 +00002194def ADC32rr : I<0x11, MRMDestReg, (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002195 "adc{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingc0ca7f32008-12-01 23:44:08 +00002196 [(set GR32:$dst, (adde GR32:$src1, GR32:$src2))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002197}
Evan Chengb783fa32007-07-19 01:14:50 +00002198def ADC32rm : I<0x13, MRMSrcMem , (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002199 "adc{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingc0ca7f32008-12-01 23:44:08 +00002200 [(set GR32:$dst, (adde GR32:$src1, (load addr:$src2)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002201def ADC32ri : Ii32<0x81, MRM2r, (outs GR32:$dst), (ins GR32:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002202 "adc{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingc0ca7f32008-12-01 23:44:08 +00002203 [(set GR32:$dst, (adde GR32:$src1, imm:$src2))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002204def ADC32ri8 : Ii8<0x83, MRM2r, (outs GR32:$dst), (ins GR32:$src1, i32i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002205 "adc{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingc0ca7f32008-12-01 23:44:08 +00002206 [(set GR32:$dst, (adde GR32:$src1, i32immSExt8:$src2))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002207
2208let isTwoAddress = 0 in {
Evan Chengb783fa32007-07-19 01:14:50 +00002209 def ADC32mr : I<0x11, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002210 "adc{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingc0ca7f32008-12-01 23:44:08 +00002211 [(store (adde (load addr:$dst), GR32:$src2), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002212 def ADC32mi : Ii32<0x81, MRM2m, (outs), (ins i32mem:$dst, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002213 "adc{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingc0ca7f32008-12-01 23:44:08 +00002214 [(store (adde (loadi32 addr:$dst), imm:$src2), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002215 def ADC32mi8 : Ii8<0x83, MRM2m, (outs), (ins i32mem:$dst, i32i8imm :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002216 "adc{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendling0c52d0a2008-12-02 00:07:05 +00002217 [(store (adde (load addr:$dst), i32immSExt8:$src2), addr:$dst)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002218}
Evan Cheng259471d2007-10-05 17:59:57 +00002219} // Uses = [EFLAGS]
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002220
Bill Wendlingae034ed2008-12-12 00:56:36 +00002221// Register-Register Subtraction
2222def SUB8rr : I<0x28, MRMDestReg, (outs GR8:$dst), (ins GR8:$src1, GR8:$src2),
2223 "sub{b}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002224 [(set GR8:$dst, (sub GR8:$src1, GR8:$src2)),
2225 (implicit EFLAGS)]>;
Bill Wendlingae034ed2008-12-12 00:56:36 +00002226def SUB16rr : I<0x29, MRMDestReg, (outs GR16:$dst), (ins GR16:$src1,GR16:$src2),
2227 "sub{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002228 [(set GR16:$dst, (sub GR16:$src1, GR16:$src2)),
2229 (implicit EFLAGS)]>, OpSize;
Bill Wendlingae034ed2008-12-12 00:56:36 +00002230def SUB32rr : I<0x29, MRMDestReg, (outs GR32:$dst), (ins GR32:$src1,GR32:$src2),
2231 "sub{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002232 [(set GR32:$dst, (sub GR32:$src1, GR32:$src2)),
2233 (implicit EFLAGS)]>;
Bill Wendlingae034ed2008-12-12 00:56:36 +00002234
2235// Register-Memory Subtraction
2236def SUB8rm : I<0x2A, MRMSrcMem, (outs GR8 :$dst),
2237 (ins GR8 :$src1, i8mem :$src2),
2238 "sub{b}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002239 [(set GR8:$dst, (sub GR8:$src1, (load addr:$src2))),
2240 (implicit EFLAGS)]>;
Bill Wendlingae034ed2008-12-12 00:56:36 +00002241def SUB16rm : I<0x2B, MRMSrcMem, (outs GR16:$dst),
2242 (ins GR16:$src1, i16mem:$src2),
2243 "sub{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002244 [(set GR16:$dst, (sub GR16:$src1, (load addr:$src2))),
2245 (implicit EFLAGS)]>, OpSize;
Bill Wendlingae034ed2008-12-12 00:56:36 +00002246def SUB32rm : I<0x2B, MRMSrcMem, (outs GR32:$dst),
2247 (ins GR32:$src1, i32mem:$src2),
2248 "sub{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002249 [(set GR32:$dst, (sub GR32:$src1, (load addr:$src2))),
2250 (implicit EFLAGS)]>;
Bill Wendlingae034ed2008-12-12 00:56:36 +00002251
2252// Register-Integer Subtraction
2253def SUB8ri : Ii8 <0x80, MRM5r, (outs GR8:$dst),
2254 (ins GR8:$src1, i8imm:$src2),
2255 "sub{b}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002256 [(set GR8:$dst, (sub GR8:$src1, imm:$src2)),
2257 (implicit EFLAGS)]>;
Bill Wendlingae034ed2008-12-12 00:56:36 +00002258def SUB16ri : Ii16<0x81, MRM5r, (outs GR16:$dst),
2259 (ins GR16:$src1, i16imm:$src2),
2260 "sub{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002261 [(set GR16:$dst, (sub GR16:$src1, imm:$src2)),
2262 (implicit EFLAGS)]>, OpSize;
Bill Wendlingae034ed2008-12-12 00:56:36 +00002263def SUB32ri : Ii32<0x81, MRM5r, (outs GR32:$dst),
2264 (ins GR32:$src1, i32imm:$src2),
2265 "sub{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002266 [(set GR32:$dst, (sub GR32:$src1, imm:$src2)),
2267 (implicit EFLAGS)]>;
Bill Wendlingae034ed2008-12-12 00:56:36 +00002268def SUB16ri8 : Ii8<0x83, MRM5r, (outs GR16:$dst),
2269 (ins GR16:$src1, i16i8imm:$src2),
2270 "sub{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002271 [(set GR16:$dst, (sub GR16:$src1, i16immSExt8:$src2)),
2272 (implicit EFLAGS)]>, OpSize;
Bill Wendlingae034ed2008-12-12 00:56:36 +00002273def SUB32ri8 : Ii8<0x83, MRM5r, (outs GR32:$dst),
2274 (ins GR32:$src1, i32i8imm:$src2),
2275 "sub{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002276 [(set GR32:$dst, (sub GR32:$src1, i32immSExt8:$src2)),
2277 (implicit EFLAGS)]>;
Bill Wendlingae034ed2008-12-12 00:56:36 +00002278
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002279let isTwoAddress = 0 in {
Bill Wendlingae034ed2008-12-12 00:56:36 +00002280 // Memory-Register Subtraction
Evan Chengb783fa32007-07-19 01:14:50 +00002281 def SUB8mr : I<0x28, MRMDestMem, (outs), (ins i8mem :$dst, GR8 :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002282 "sub{b}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002283 [(store (sub (load addr:$dst), GR8:$src2), addr:$dst),
2284 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002285 def SUB16mr : I<0x29, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002286 "sub{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002287 [(store (sub (load addr:$dst), GR16:$src2), addr:$dst),
2288 (implicit EFLAGS)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002289 def SUB32mr : I<0x29, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002290 "sub{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002291 [(store (sub (load addr:$dst), GR32:$src2), addr:$dst),
2292 (implicit EFLAGS)]>;
Bill Wendlingae034ed2008-12-12 00:56:36 +00002293
2294 // Memory-Integer Subtraction
Evan Chengb783fa32007-07-19 01:14:50 +00002295 def SUB8mi : Ii8<0x80, MRM5m, (outs), (ins i8mem :$dst, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002296 "sub{b}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002297 [(store (sub (loadi8 addr:$dst), imm:$src2), addr:$dst),
2298 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002299 def SUB16mi : Ii16<0x81, MRM5m, (outs), (ins i16mem:$dst, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002300 "sub{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002301 [(store (sub (loadi16 addr:$dst), imm:$src2),addr:$dst),
2302 (implicit EFLAGS)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002303 def SUB32mi : Ii32<0x81, MRM5m, (outs), (ins i32mem:$dst, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002304 "sub{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002305 [(store (sub (loadi32 addr:$dst), imm:$src2),addr:$dst),
2306 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002307 def SUB16mi8 : Ii8<0x83, MRM5m, (outs), (ins i16mem:$dst, i16i8imm :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002308 "sub{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingae034ed2008-12-12 00:56:36 +00002309 [(store (sub (load addr:$dst), i16immSExt8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00002310 addr:$dst),
2311 (implicit EFLAGS)]>, OpSize;
Bill Wendlingae034ed2008-12-12 00:56:36 +00002312 def SUB32mi8 : Ii8<0x83, MRM5m, (outs), (ins i32mem:$dst, i32i8imm :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002313 "sub{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingae034ed2008-12-12 00:56:36 +00002314 [(store (sub (load addr:$dst), i32immSExt8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00002315 addr:$dst),
2316 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002317}
2318
Evan Cheng259471d2007-10-05 17:59:57 +00002319let Uses = [EFLAGS] in {
Evan Chengb783fa32007-07-19 01:14:50 +00002320def SBB32rr : I<0x19, MRMDestReg, (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002321 "sbb{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng55687072007-09-14 21:48:26 +00002322 [(set GR32:$dst, (sube GR32:$src1, GR32:$src2))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002323
2324let isTwoAddress = 0 in {
Evan Chengb783fa32007-07-19 01:14:50 +00002325 def SBB32mr : I<0x19, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002326 "sbb{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002327 [(store (sube (load addr:$dst), GR32:$src2), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002328 def SBB8mi : Ii32<0x80, MRM3m, (outs), (ins i8mem:$dst, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002329 "sbb{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002330 [(store (sube (loadi8 addr:$dst), imm:$src2), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002331 def SBB32mi : Ii32<0x81, MRM3m, (outs), (ins i32mem:$dst, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002332 "sbb{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002333 [(store (sube (loadi32 addr:$dst), imm:$src2), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002334 def SBB32mi8 : Ii8<0x83, MRM3m, (outs), (ins i32mem:$dst, i32i8imm :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002335 "sbb{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng55687072007-09-14 21:48:26 +00002336 [(store (sube (load addr:$dst), i32immSExt8:$src2), addr:$dst)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002337}
Evan Chengb783fa32007-07-19 01:14:50 +00002338def SBB32rm : I<0x1B, MRMSrcMem, (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002339 "sbb{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002340 [(set GR32:$dst, (sube GR32:$src1, (load addr:$src2)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002341def SBB32ri : Ii32<0x81, MRM3r, (outs GR32:$dst), (ins GR32:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002342 "sbb{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002343 [(set GR32:$dst, (sube GR32:$src1, imm:$src2))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002344def SBB32ri8 : Ii8<0x83, MRM3r, (outs GR32:$dst), (ins GR32:$src1, i32i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002345 "sbb{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002346 [(set GR32:$dst, (sube GR32:$src1, i32immSExt8:$src2))]>;
Evan Cheng259471d2007-10-05 17:59:57 +00002347} // Uses = [EFLAGS]
Evan Cheng55687072007-09-14 21:48:26 +00002348} // Defs = [EFLAGS]
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002349
Evan Cheng55687072007-09-14 21:48:26 +00002350let Defs = [EFLAGS] in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002351let isCommutable = 1 in { // X = IMUL Y, Z --> X = IMUL Z, Y
Bill Wendlingf5399032008-12-12 21:15:41 +00002352// Register-Register Signed Integer Multiply
Bill Wendlingae034ed2008-12-12 00:56:36 +00002353def IMUL16rr : I<0xAF, MRMSrcReg, (outs GR16:$dst), (ins GR16:$src1,GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002354 "imul{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002355 [(set GR16:$dst, (mul GR16:$src1, GR16:$src2)),
2356 (implicit EFLAGS)]>, TB, OpSize;
Bill Wendlingae034ed2008-12-12 00:56:36 +00002357def IMUL32rr : I<0xAF, MRMSrcReg, (outs GR32:$dst), (ins GR32:$src1,GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002358 "imul{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002359 [(set GR32:$dst, (mul GR32:$src1, GR32:$src2)),
2360 (implicit EFLAGS)]>, TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002361}
Bill Wendlingae034ed2008-12-12 00:56:36 +00002362
Bill Wendlingf5399032008-12-12 21:15:41 +00002363// Register-Memory Signed Integer Multiply
Bill Wendlingae034ed2008-12-12 00:56:36 +00002364def IMUL16rm : I<0xAF, MRMSrcMem, (outs GR16:$dst),
2365 (ins GR16:$src1, i16mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002366 "imul{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002367 [(set GR16:$dst, (mul GR16:$src1, (load addr:$src2))),
2368 (implicit EFLAGS)]>, TB, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002369def IMUL32rm : I<0xAF, MRMSrcMem, (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002370 "imul{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002371 [(set GR32:$dst, (mul GR32:$src1, (load addr:$src2))),
2372 (implicit EFLAGS)]>, TB;
Evan Cheng55687072007-09-14 21:48:26 +00002373} // Defs = [EFLAGS]
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002374} // end Two Address instructions
2375
2376// Suprisingly enough, these are not two address instructions!
Evan Cheng55687072007-09-14 21:48:26 +00002377let Defs = [EFLAGS] in {
Bill Wendlingf5399032008-12-12 21:15:41 +00002378// Register-Integer Signed Integer Multiply
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002379def IMUL16rri : Ii16<0x69, MRMSrcReg, // GR16 = GR16*I16
Evan Chengb783fa32007-07-19 01:14:50 +00002380 (outs GR16:$dst), (ins GR16:$src1, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002381 "imul{w}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002382 [(set GR16:$dst, (mul GR16:$src1, imm:$src2)),
2383 (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002384def IMUL32rri : Ii32<0x69, MRMSrcReg, // GR32 = GR32*I32
Evan Chengb783fa32007-07-19 01:14:50 +00002385 (outs GR32:$dst), (ins GR32:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002386 "imul{l}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002387 [(set GR32:$dst, (mul GR32:$src1, imm:$src2)),
2388 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002389def IMUL16rri8 : Ii8<0x6B, MRMSrcReg, // GR16 = GR16*I8
Evan Chengb783fa32007-07-19 01:14:50 +00002390 (outs GR16:$dst), (ins GR16:$src1, i16i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002391 "imul{w}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002392 [(set GR16:$dst, (mul GR16:$src1, i16immSExt8:$src2)),
2393 (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002394def IMUL32rri8 : Ii8<0x6B, MRMSrcReg, // GR32 = GR32*I8
Evan Chengb783fa32007-07-19 01:14:50 +00002395 (outs GR32:$dst), (ins GR32:$src1, i32i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002396 "imul{l}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002397 [(set GR32:$dst, (mul GR32:$src1, i32immSExt8:$src2)),
2398 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002399
Bill Wendlingf5399032008-12-12 21:15:41 +00002400// Memory-Integer Signed Integer Multiply
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002401def IMUL16rmi : Ii16<0x69, MRMSrcMem, // GR16 = [mem16]*I16
Evan Chengb783fa32007-07-19 01:14:50 +00002402 (outs GR16:$dst), (ins i16mem:$src1, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002403 "imul{w}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002404 [(set GR16:$dst, (mul (load addr:$src1), imm:$src2)),
2405 (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002406def IMUL32rmi : Ii32<0x69, MRMSrcMem, // GR32 = [mem32]*I32
Evan Chengb783fa32007-07-19 01:14:50 +00002407 (outs GR32:$dst), (ins i32mem:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002408 "imul{l}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002409 [(set GR32:$dst, (mul (load addr:$src1), imm:$src2)),
2410 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002411def IMUL16rmi8 : Ii8<0x6B, MRMSrcMem, // GR16 = [mem16]*I8
Evan Chengb783fa32007-07-19 01:14:50 +00002412 (outs GR16:$dst), (ins i16mem:$src1, i16i8imm :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002413 "imul{w}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Bill Wendlingae034ed2008-12-12 00:56:36 +00002414 [(set GR16:$dst, (mul (load addr:$src1),
Bill Wendlingf5399032008-12-12 21:15:41 +00002415 i16immSExt8:$src2)),
2416 (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002417def IMUL32rmi8 : Ii8<0x6B, MRMSrcMem, // GR32 = [mem32]*I8
Evan Chengb783fa32007-07-19 01:14:50 +00002418 (outs GR32:$dst), (ins i32mem:$src1, i32i8imm: $src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002419 "imul{l}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Bill Wendlingae034ed2008-12-12 00:56:36 +00002420 [(set GR32:$dst, (mul (load addr:$src1),
Bill Wendlingf5399032008-12-12 21:15:41 +00002421 i32immSExt8:$src2)),
2422 (implicit EFLAGS)]>;
Evan Cheng55687072007-09-14 21:48:26 +00002423} // Defs = [EFLAGS]
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002424
2425//===----------------------------------------------------------------------===//
2426// Test instructions are just like AND, except they don't generate a result.
2427//
Evan Cheng950aac02007-09-25 01:57:46 +00002428let Defs = [EFLAGS] in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002429let isCommutable = 1 in { // TEST X, Y --> TEST Y, X
Evan Chengb783fa32007-07-19 01:14:50 +00002430def TEST8rr : I<0x84, MRMDestReg, (outs), (ins GR8:$src1, GR8:$src2),
Evan Cheng621216e2007-09-29 00:00:36 +00002431 "test{b}\t{$src2, $src1|$src1, $src2}",
Chris Lattner21da6382008-02-19 17:37:35 +00002432 [(X86cmp (and_su GR8:$src1, GR8:$src2), 0),
Evan Cheng621216e2007-09-29 00:00:36 +00002433 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002434def TEST16rr : I<0x85, MRMDestReg, (outs), (ins GR16:$src1, GR16:$src2),
Evan Cheng621216e2007-09-29 00:00:36 +00002435 "test{w}\t{$src2, $src1|$src1, $src2}",
Chris Lattner21da6382008-02-19 17:37:35 +00002436 [(X86cmp (and_su GR16:$src1, GR16:$src2), 0),
Evan Cheng621216e2007-09-29 00:00:36 +00002437 (implicit EFLAGS)]>,
2438 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002439def TEST32rr : I<0x85, MRMDestReg, (outs), (ins GR32:$src1, GR32:$src2),
Evan Cheng621216e2007-09-29 00:00:36 +00002440 "test{l}\t{$src2, $src1|$src1, $src2}",
Chris Lattner21da6382008-02-19 17:37:35 +00002441 [(X86cmp (and_su GR32:$src1, GR32:$src2), 0),
Evan Cheng621216e2007-09-29 00:00:36 +00002442 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002443}
2444
Evan Chengb783fa32007-07-19 01:14:50 +00002445def TEST8rm : I<0x84, MRMSrcMem, (outs), (ins GR8 :$src1, i8mem :$src2),
Evan Cheng621216e2007-09-29 00:00:36 +00002446 "test{b}\t{$src2, $src1|$src1, $src2}",
2447 [(X86cmp (and GR8:$src1, (loadi8 addr:$src2)), 0),
2448 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002449def TEST16rm : I<0x85, MRMSrcMem, (outs), (ins GR16:$src1, i16mem:$src2),
Evan Cheng621216e2007-09-29 00:00:36 +00002450 "test{w}\t{$src2, $src1|$src1, $src2}",
2451 [(X86cmp (and GR16:$src1, (loadi16 addr:$src2)), 0),
2452 (implicit EFLAGS)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002453def TEST32rm : I<0x85, MRMSrcMem, (outs), (ins GR32:$src1, i32mem:$src2),
Evan Cheng621216e2007-09-29 00:00:36 +00002454 "test{l}\t{$src2, $src1|$src1, $src2}",
2455 [(X86cmp (and GR32:$src1, (loadi32 addr:$src2)), 0),
2456 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002457
2458def TEST8ri : Ii8 <0xF6, MRM0r, // flags = GR8 & imm8
Evan Chengb783fa32007-07-19 01:14:50 +00002459 (outs), (ins GR8:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002460 "test{b}\t{$src2, $src1|$src1, $src2}",
Chris Lattner21da6382008-02-19 17:37:35 +00002461 [(X86cmp (and_su GR8:$src1, imm:$src2), 0),
Evan Cheng621216e2007-09-29 00:00:36 +00002462 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002463def TEST16ri : Ii16<0xF7, MRM0r, // flags = GR16 & imm16
Evan Chengb783fa32007-07-19 01:14:50 +00002464 (outs), (ins GR16:$src1, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002465 "test{w}\t{$src2, $src1|$src1, $src2}",
Chris Lattner21da6382008-02-19 17:37:35 +00002466 [(X86cmp (and_su GR16:$src1, imm:$src2), 0),
Evan Cheng621216e2007-09-29 00:00:36 +00002467 (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002468def TEST32ri : Ii32<0xF7, MRM0r, // flags = GR32 & imm32
Evan Chengb783fa32007-07-19 01:14:50 +00002469 (outs), (ins GR32:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002470 "test{l}\t{$src2, $src1|$src1, $src2}",
Chris Lattner21da6382008-02-19 17:37:35 +00002471 [(X86cmp (and_su GR32:$src1, imm:$src2), 0),
Evan Cheng621216e2007-09-29 00:00:36 +00002472 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002473
Evan Cheng621216e2007-09-29 00:00:36 +00002474def TEST8mi : Ii8 <0xF6, MRM0m, // flags = [mem8] & imm8
Evan Chengb783fa32007-07-19 01:14:50 +00002475 (outs), (ins i8mem:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002476 "test{b}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002477 [(X86cmp (and (loadi8 addr:$src1), imm:$src2), 0),
2478 (implicit EFLAGS)]>;
2479def TEST16mi : Ii16<0xF7, MRM0m, // flags = [mem16] & imm16
Evan Chengb783fa32007-07-19 01:14:50 +00002480 (outs), (ins i16mem:$src1, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002481 "test{w}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002482 [(X86cmp (and (loadi16 addr:$src1), imm:$src2), 0),
2483 (implicit EFLAGS)]>, OpSize;
2484def TEST32mi : Ii32<0xF7, MRM0m, // flags = [mem32] & imm32
Evan Chengb783fa32007-07-19 01:14:50 +00002485 (outs), (ins i32mem:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002486 "test{l}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002487 [(X86cmp (and (loadi32 addr:$src1), imm:$src2), 0),
Evan Cheng950aac02007-09-25 01:57:46 +00002488 (implicit EFLAGS)]>;
2489} // Defs = [EFLAGS]
2490
2491
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002492// Condition code ops, incl. set if equal/not equal/...
Chris Lattnerc90ee9c2008-01-10 07:59:24 +00002493let Defs = [EFLAGS], Uses = [AH], neverHasSideEffects = 1 in
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002494def SAHF : I<0x9E, RawFrm, (outs), (ins), "sahf", []>; // flags = AH
Chris Lattnerc90ee9c2008-01-10 07:59:24 +00002495let Defs = [AH], Uses = [EFLAGS], neverHasSideEffects = 1 in
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002496def LAHF : I<0x9F, RawFrm, (outs), (ins), "lahf", []>; // AH = flags
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002497
Evan Cheng950aac02007-09-25 01:57:46 +00002498let Uses = [EFLAGS] in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002499def SETEr : I<0x94, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00002500 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002501 "sete\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002502 [(set GR8:$dst, (X86setcc X86_COND_E, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002503 TB; // GR8 = ==
2504def SETEm : I<0x94, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00002505 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002506 "sete\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002507 [(store (X86setcc X86_COND_E, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002508 TB; // [mem8] = ==
Bill Wendling0c52d0a2008-12-02 00:07:05 +00002509
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002510def SETNEr : I<0x95, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00002511 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002512 "setne\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002513 [(set GR8:$dst, (X86setcc X86_COND_NE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002514 TB; // GR8 = !=
2515def SETNEm : I<0x95, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00002516 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002517 "setne\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002518 [(store (X86setcc X86_COND_NE, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002519 TB; // [mem8] = !=
Bill Wendling0c52d0a2008-12-02 00:07:05 +00002520
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002521def SETLr : I<0x9C, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00002522 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002523 "setl\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002524 [(set GR8:$dst, (X86setcc X86_COND_L, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002525 TB; // GR8 = < signed
2526def SETLm : I<0x9C, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00002527 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002528 "setl\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002529 [(store (X86setcc X86_COND_L, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002530 TB; // [mem8] = < signed
Bill Wendling0c52d0a2008-12-02 00:07:05 +00002531
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002532def SETGEr : I<0x9D, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00002533 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002534 "setge\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002535 [(set GR8:$dst, (X86setcc X86_COND_GE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002536 TB; // GR8 = >= signed
2537def SETGEm : I<0x9D, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00002538 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002539 "setge\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002540 [(store (X86setcc X86_COND_GE, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002541 TB; // [mem8] = >= signed
Bill Wendling0c52d0a2008-12-02 00:07:05 +00002542
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002543def SETLEr : I<0x9E, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00002544 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002545 "setle\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002546 [(set GR8:$dst, (X86setcc X86_COND_LE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002547 TB; // GR8 = <= signed
2548def SETLEm : I<0x9E, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00002549 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002550 "setle\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002551 [(store (X86setcc X86_COND_LE, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002552 TB; // [mem8] = <= signed
Bill Wendling0c52d0a2008-12-02 00:07:05 +00002553
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002554def SETGr : I<0x9F, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00002555 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002556 "setg\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002557 [(set GR8:$dst, (X86setcc X86_COND_G, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002558 TB; // GR8 = > signed
2559def SETGm : I<0x9F, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00002560 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002561 "setg\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002562 [(store (X86setcc X86_COND_G, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002563 TB; // [mem8] = > signed
2564
2565def SETBr : I<0x92, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00002566 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002567 "setb\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002568 [(set GR8:$dst, (X86setcc X86_COND_B, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002569 TB; // GR8 = < unsign
2570def SETBm : I<0x92, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00002571 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002572 "setb\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002573 [(store (X86setcc X86_COND_B, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002574 TB; // [mem8] = < unsign
Bill Wendling0c52d0a2008-12-02 00:07:05 +00002575
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002576def SETAEr : I<0x93, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00002577 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002578 "setae\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002579 [(set GR8:$dst, (X86setcc X86_COND_AE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002580 TB; // GR8 = >= unsign
2581def SETAEm : I<0x93, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00002582 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002583 "setae\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002584 [(store (X86setcc X86_COND_AE, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002585 TB; // [mem8] = >= unsign
Bill Wendling0c52d0a2008-12-02 00:07:05 +00002586
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002587def SETBEr : I<0x96, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00002588 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002589 "setbe\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002590 [(set GR8:$dst, (X86setcc X86_COND_BE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002591 TB; // GR8 = <= unsign
2592def SETBEm : I<0x96, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00002593 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002594 "setbe\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002595 [(store (X86setcc X86_COND_BE, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002596 TB; // [mem8] = <= unsign
Bill Wendling0c52d0a2008-12-02 00:07:05 +00002597
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002598def SETAr : I<0x97, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00002599 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002600 "seta\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002601 [(set GR8:$dst, (X86setcc X86_COND_A, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002602 TB; // GR8 = > signed
2603def SETAm : I<0x97, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00002604 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002605 "seta\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002606 [(store (X86setcc X86_COND_A, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002607 TB; // [mem8] = > signed
2608
2609def SETSr : I<0x98, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00002610 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002611 "sets\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002612 [(set GR8:$dst, (X86setcc X86_COND_S, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002613 TB; // GR8 = <sign bit>
2614def SETSm : I<0x98, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00002615 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002616 "sets\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002617 [(store (X86setcc X86_COND_S, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002618 TB; // [mem8] = <sign bit>
2619def SETNSr : I<0x99, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00002620 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002621 "setns\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002622 [(set GR8:$dst, (X86setcc X86_COND_NS, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002623 TB; // GR8 = !<sign bit>
2624def SETNSm : I<0x99, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00002625 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002626 "setns\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002627 [(store (X86setcc X86_COND_NS, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002628 TB; // [mem8] = !<sign bit>
Bill Wendling0c52d0a2008-12-02 00:07:05 +00002629
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002630def SETPr : I<0x9A, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00002631 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002632 "setp\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002633 [(set GR8:$dst, (X86setcc X86_COND_P, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002634 TB; // GR8 = parity
2635def SETPm : I<0x9A, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00002636 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002637 "setp\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002638 [(store (X86setcc X86_COND_P, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002639 TB; // [mem8] = parity
2640def SETNPr : I<0x9B, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00002641 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002642 "setnp\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002643 [(set GR8:$dst, (X86setcc X86_COND_NP, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002644 TB; // GR8 = not parity
2645def SETNPm : I<0x9B, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00002646 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002647 "setnp\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002648 [(store (X86setcc X86_COND_NP, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002649 TB; // [mem8] = not parity
Bill Wendling0c52d0a2008-12-02 00:07:05 +00002650
2651def SETOr : I<0x90, MRM0r,
2652 (outs GR8 :$dst), (ins),
2653 "seto\t$dst",
2654 [(set GR8:$dst, (X86setcc X86_COND_O, EFLAGS))]>,
2655 TB; // GR8 = overflow
2656def SETOm : I<0x90, MRM0m,
2657 (outs), (ins i8mem:$dst),
2658 "seto\t$dst",
2659 [(store (X86setcc X86_COND_O, EFLAGS), addr:$dst)]>,
2660 TB; // [mem8] = overflow
2661def SETNOr : I<0x91, MRM0r,
2662 (outs GR8 :$dst), (ins),
2663 "setno\t$dst",
2664 [(set GR8:$dst, (X86setcc X86_COND_NO, EFLAGS))]>,
2665 TB; // GR8 = not overflow
2666def SETNOm : I<0x91, MRM0m,
2667 (outs), (ins i8mem:$dst),
2668 "setno\t$dst",
2669 [(store (X86setcc X86_COND_NO, EFLAGS), addr:$dst)]>,
2670 TB; // [mem8] = not overflow
Evan Cheng950aac02007-09-25 01:57:46 +00002671} // Uses = [EFLAGS]
2672
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002673
2674// Integer comparisons
Evan Cheng55687072007-09-14 21:48:26 +00002675let Defs = [EFLAGS] in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002676def CMP8rr : I<0x38, MRMDestReg,
Evan Chengb783fa32007-07-19 01:14:50 +00002677 (outs), (ins GR8 :$src1, GR8 :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002678 "cmp{b}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002679 [(X86cmp GR8:$src1, GR8:$src2), (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002680def CMP16rr : I<0x39, MRMDestReg,
Evan Chengb783fa32007-07-19 01:14:50 +00002681 (outs), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002682 "cmp{w}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002683 [(X86cmp GR16:$src1, GR16:$src2), (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002684def CMP32rr : I<0x39, MRMDestReg,
Evan Chengb783fa32007-07-19 01:14:50 +00002685 (outs), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002686 "cmp{l}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002687 [(X86cmp GR32:$src1, GR32:$src2), (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002688def CMP8mr : I<0x38, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00002689 (outs), (ins i8mem :$src1, GR8 :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002690 "cmp{b}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002691 [(X86cmp (loadi8 addr:$src1), GR8:$src2),
2692 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002693def CMP16mr : I<0x39, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00002694 (outs), (ins i16mem:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002695 "cmp{w}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002696 [(X86cmp (loadi16 addr:$src1), GR16:$src2),
2697 (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002698def CMP32mr : I<0x39, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00002699 (outs), (ins i32mem:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002700 "cmp{l}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002701 [(X86cmp (loadi32 addr:$src1), GR32:$src2),
2702 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002703def CMP8rm : I<0x3A, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00002704 (outs), (ins GR8 :$src1, i8mem :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002705 "cmp{b}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002706 [(X86cmp GR8:$src1, (loadi8 addr:$src2)),
2707 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002708def CMP16rm : I<0x3B, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00002709 (outs), (ins GR16:$src1, i16mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002710 "cmp{w}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002711 [(X86cmp GR16:$src1, (loadi16 addr:$src2)),
2712 (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002713def CMP32rm : I<0x3B, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00002714 (outs), (ins GR32:$src1, i32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002715 "cmp{l}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002716 [(X86cmp GR32:$src1, (loadi32 addr:$src2)),
2717 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002718def CMP8ri : Ii8<0x80, MRM7r,
Evan Chengb783fa32007-07-19 01:14:50 +00002719 (outs), (ins GR8:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002720 "cmp{b}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002721 [(X86cmp GR8:$src1, imm:$src2), (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002722def CMP16ri : Ii16<0x81, MRM7r,
Evan Chengb783fa32007-07-19 01:14:50 +00002723 (outs), (ins GR16:$src1, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002724 "cmp{w}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002725 [(X86cmp GR16:$src1, imm:$src2),
2726 (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002727def CMP32ri : Ii32<0x81, MRM7r,
Evan Chengb783fa32007-07-19 01:14:50 +00002728 (outs), (ins GR32:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002729 "cmp{l}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002730 [(X86cmp GR32:$src1, imm:$src2), (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002731def CMP8mi : Ii8 <0x80, MRM7m,
Evan Chengb783fa32007-07-19 01:14:50 +00002732 (outs), (ins i8mem :$src1, i8imm :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002733 "cmp{b}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002734 [(X86cmp (loadi8 addr:$src1), imm:$src2),
2735 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002736def CMP16mi : Ii16<0x81, MRM7m,
Evan Chengb783fa32007-07-19 01:14:50 +00002737 (outs), (ins i16mem:$src1, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002738 "cmp{w}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002739 [(X86cmp (loadi16 addr:$src1), imm:$src2),
2740 (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002741def CMP32mi : Ii32<0x81, MRM7m,
Evan Chengb783fa32007-07-19 01:14:50 +00002742 (outs), (ins i32mem:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002743 "cmp{l}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002744 [(X86cmp (loadi32 addr:$src1), imm:$src2),
2745 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002746def CMP16ri8 : Ii8<0x83, MRM7r,
Evan Chengb783fa32007-07-19 01:14:50 +00002747 (outs), (ins GR16:$src1, i16i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002748 "cmp{w}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002749 [(X86cmp GR16:$src1, i16immSExt8:$src2),
2750 (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002751def CMP16mi8 : Ii8<0x83, MRM7m,
Evan Chengb783fa32007-07-19 01:14:50 +00002752 (outs), (ins i16mem:$src1, i16i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002753 "cmp{w}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002754 [(X86cmp (loadi16 addr:$src1), i16immSExt8:$src2),
2755 (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002756def CMP32mi8 : Ii8<0x83, MRM7m,
Evan Chengb783fa32007-07-19 01:14:50 +00002757 (outs), (ins i32mem:$src1, i32i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002758 "cmp{l}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002759 [(X86cmp (loadi32 addr:$src1), i32immSExt8:$src2),
2760 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002761def CMP32ri8 : Ii8<0x83, MRM7r,
Evan Chengb783fa32007-07-19 01:14:50 +00002762 (outs), (ins GR32:$src1, i32i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002763 "cmp{l}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002764 [(X86cmp GR32:$src1, i32immSExt8:$src2),
Evan Cheng950aac02007-09-25 01:57:46 +00002765 (implicit EFLAGS)]>;
2766} // Defs = [EFLAGS]
2767
Dan Gohman7fe9b7f2008-12-23 22:45:23 +00002768// Bit tests.
Dan Gohman7fe9b7f2008-12-23 22:45:23 +00002769// TODO: BTC, BTR, and BTS
2770let Defs = [EFLAGS] in {
Dan Gohmanfc4eddb2009-01-13 20:32:45 +00002771def BT16rr : I<0xA3, MRMDestReg, (outs), (ins GR16:$src1, GR16:$src2),
Dan Gohman7fe9b7f2008-12-23 22:45:23 +00002772 "bt{w}\t{$src2, $src1|$src1, $src2}",
2773 [(X86bt GR16:$src1, GR16:$src2),
Chris Lattner5a95cde2008-12-25 01:32:49 +00002774 (implicit EFLAGS)]>, OpSize, TB;
Dan Gohmanfc4eddb2009-01-13 20:32:45 +00002775def BT32rr : I<0xA3, MRMDestReg, (outs), (ins GR32:$src1, GR32:$src2),
Dan Gohman7fe9b7f2008-12-23 22:45:23 +00002776 "bt{l}\t{$src2, $src1|$src1, $src2}",
2777 [(X86bt GR32:$src1, GR32:$src2),
Chris Lattner5a95cde2008-12-25 01:32:49 +00002778 (implicit EFLAGS)]>, TB;
Dan Gohman85a228c2009-01-13 23:23:30 +00002779
2780// Unlike with the register+register form, the memory+register form of the
2781// bt instruction does not ignore the high bits of the index. From ISel's
2782// perspective, this is pretty bizarre. Disable these instructions for now.
2783//def BT16mr : I<0xA3, MRMDestMem, (outs), (ins i16mem:$src1, GR16:$src2),
2784// "bt{w}\t{$src2, $src1|$src1, $src2}",
2785// [(X86bt (loadi16 addr:$src1), GR16:$src2),
2786// (implicit EFLAGS)]>, OpSize, TB, Requires<[FastBTMem]>;
2787//def BT32mr : I<0xA3, MRMDestMem, (outs), (ins i32mem:$src1, GR32:$src2),
2788// "bt{l}\t{$src2, $src1|$src1, $src2}",
2789// [(X86bt (loadi32 addr:$src1), GR32:$src2),
2790// (implicit EFLAGS)]>, TB, Requires<[FastBTMem]>;
Dan Gohman46fb1cf2009-01-13 20:33:23 +00002791
2792def BT16ri8 : Ii8<0xBA, MRM4r, (outs), (ins GR16:$src1, i16i8imm:$src2),
2793 "bt{w}\t{$src2, $src1|$src1, $src2}",
2794 [(X86bt GR16:$src1, i16immSExt8:$src2),
2795 (implicit EFLAGS)]>, OpSize, TB;
2796def BT32ri8 : Ii8<0xBA, MRM4r, (outs), (ins GR32:$src1, i32i8imm:$src2),
2797 "bt{l}\t{$src2, $src1|$src1, $src2}",
2798 [(X86bt GR32:$src1, i32immSExt8:$src2),
2799 (implicit EFLAGS)]>, TB;
2800// Note that these instructions don't need FastBTMem because that
2801// only applies when the other operand is in a register. When it's
2802// an immediate, bt is still fast.
2803def BT16mi8 : Ii8<0xBA, MRM4m, (outs), (ins i16mem:$src1, i16i8imm:$src2),
2804 "bt{w}\t{$src2, $src1|$src1, $src2}",
2805 [(X86bt (loadi16 addr:$src1), i16immSExt8:$src2),
2806 (implicit EFLAGS)]>, OpSize, TB;
2807def BT32mi8 : Ii8<0xBA, MRM4m, (outs), (ins i32mem:$src1, i32i8imm:$src2),
2808 "bt{l}\t{$src2, $src1|$src1, $src2}",
2809 [(X86bt (loadi32 addr:$src1), i32immSExt8:$src2),
2810 (implicit EFLAGS)]>, TB;
Dan Gohman7fe9b7f2008-12-23 22:45:23 +00002811} // Defs = [EFLAGS]
2812
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002813// Sign/Zero extenders
Dan Gohman9203ab42008-07-30 18:09:17 +00002814// Use movsbl intead of movsbw; we don't care about the high 16 bits
2815// of the register here. This has a smaller encoding and avoids a
2816// partial-register update.
Evan Chengb783fa32007-07-19 01:14:50 +00002817def MOVSX16rr8 : I<0xBE, MRMSrcReg, (outs GR16:$dst), (ins GR8 :$src),
Dan Gohman9203ab42008-07-30 18:09:17 +00002818 "movs{bl|x}\t{$src, ${dst:subreg32}|${dst:subreg32}, $src}",
2819 [(set GR16:$dst, (sext GR8:$src))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00002820def MOVSX16rm8 : I<0xBE, MRMSrcMem, (outs GR16:$dst), (ins i8mem :$src),
Dan Gohman9203ab42008-07-30 18:09:17 +00002821 "movs{bl|x}\t{$src, ${dst:subreg32}|${dst:subreg32}, $src}",
2822 [(set GR16:$dst, (sextloadi16i8 addr:$src))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00002823def MOVSX32rr8 : I<0xBE, MRMSrcReg, (outs GR32:$dst), (ins GR8 :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002824 "movs{bl|x}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002825 [(set GR32:$dst, (sext GR8:$src))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00002826def MOVSX32rm8 : I<0xBE, MRMSrcMem, (outs GR32:$dst), (ins i8mem :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002827 "movs{bl|x}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002828 [(set GR32:$dst, (sextloadi32i8 addr:$src))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00002829def MOVSX32rr16: I<0xBF, MRMSrcReg, (outs GR32:$dst), (ins GR16:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002830 "movs{wl|x}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002831 [(set GR32:$dst, (sext GR16:$src))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00002832def MOVSX32rm16: I<0xBF, MRMSrcMem, (outs GR32:$dst), (ins i16mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002833 "movs{wl|x}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002834 [(set GR32:$dst, (sextloadi32i16 addr:$src))]>, TB;
2835
Dan Gohman9203ab42008-07-30 18:09:17 +00002836// Use movzbl intead of movzbw; we don't care about the high 16 bits
2837// of the register here. This has a smaller encoding and avoids a
2838// partial-register update.
Evan Chengb783fa32007-07-19 01:14:50 +00002839def MOVZX16rr8 : I<0xB6, MRMSrcReg, (outs GR16:$dst), (ins GR8 :$src),
Dan Gohman9203ab42008-07-30 18:09:17 +00002840 "movz{bl|x}\t{$src, ${dst:subreg32}|${dst:subreg32}, $src}",
2841 [(set GR16:$dst, (zext GR8:$src))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00002842def MOVZX16rm8 : I<0xB6, MRMSrcMem, (outs GR16:$dst), (ins i8mem :$src),
Dan Gohman9203ab42008-07-30 18:09:17 +00002843 "movz{bl|x}\t{$src, ${dst:subreg32}|${dst:subreg32}, $src}",
2844 [(set GR16:$dst, (zextloadi16i8 addr:$src))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00002845def MOVZX32rr8 : I<0xB6, MRMSrcReg, (outs GR32:$dst), (ins GR8 :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002846 "movz{bl|x}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002847 [(set GR32:$dst, (zext GR8:$src))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00002848def MOVZX32rm8 : I<0xB6, MRMSrcMem, (outs GR32:$dst), (ins i8mem :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002849 "movz{bl|x}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002850 [(set GR32:$dst, (zextloadi32i8 addr:$src))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00002851def MOVZX32rr16: I<0xB7, MRMSrcReg, (outs GR32:$dst), (ins GR16:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002852 "movz{wl|x}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002853 [(set GR32:$dst, (zext GR16:$src))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00002854def MOVZX32rm16: I<0xB7, MRMSrcMem, (outs GR32:$dst), (ins i16mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002855 "movz{wl|x}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002856 [(set GR32:$dst, (zextloadi32i16 addr:$src))]>, TB;
2857
Chris Lattnerc90ee9c2008-01-10 07:59:24 +00002858let neverHasSideEffects = 1 in {
2859 let Defs = [AX], Uses = [AL] in
2860 def CBW : I<0x98, RawFrm, (outs), (ins),
2861 "{cbtw|cbw}", []>, OpSize; // AX = signext(AL)
2862 let Defs = [EAX], Uses = [AX] in
2863 def CWDE : I<0x98, RawFrm, (outs), (ins),
2864 "{cwtl|cwde}", []>; // EAX = signext(AX)
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002865
Chris Lattnerc90ee9c2008-01-10 07:59:24 +00002866 let Defs = [AX,DX], Uses = [AX] in
2867 def CWD : I<0x99, RawFrm, (outs), (ins),
2868 "{cwtd|cwd}", []>, OpSize; // DX:AX = signext(AX)
2869 let Defs = [EAX,EDX], Uses = [EAX] in
2870 def CDQ : I<0x99, RawFrm, (outs), (ins),
2871 "{cltd|cdq}", []>; // EDX:EAX = signext(EAX)
2872}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002873
2874//===----------------------------------------------------------------------===//
2875// Alias Instructions
2876//===----------------------------------------------------------------------===//
2877
2878// Alias instructions that map movr0 to xor.
2879// FIXME: remove when we can teach regalloc that xor reg, reg is ok.
Bill Wendlingba5d5b02008-05-29 01:02:09 +00002880let Defs = [EFLAGS], isReMaterializable = 1, isAsCheapAsAMove = 1 in {
Evan Chengb783fa32007-07-19 01:14:50 +00002881def MOV8r0 : I<0x30, MRMInitReg, (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002882 "xor{b}\t$dst, $dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002883 [(set GR8:$dst, 0)]>;
Dan Gohman9203ab42008-07-30 18:09:17 +00002884// Use xorl instead of xorw since we don't care about the high 16 bits,
2885// it's smaller, and it avoids a partial-register update.
Evan Chengb783fa32007-07-19 01:14:50 +00002886def MOV16r0 : I<0x31, MRMInitReg, (outs GR16:$dst), (ins),
Dan Gohman9203ab42008-07-30 18:09:17 +00002887 "xor{l}\t${dst:subreg32}, ${dst:subreg32}",
2888 [(set GR16:$dst, 0)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002889def MOV32r0 : I<0x31, MRMInitReg, (outs GR32:$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002890 "xor{l}\t$dst, $dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002891 [(set GR32:$dst, 0)]>;
Dan Gohman8aef09b2007-09-07 21:32:51 +00002892}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002893
2894// Basic operations on GR16 / GR32 subclasses GR16_ and GR32_ which contains only
2895// those registers that have GR8 sub-registers (i.e. AX - DX, EAX - EDX).
Evan Chengbd0ca9c2009-02-05 08:42:55 +00002896let neverHasSideEffects = 1, isAsCheapAsAMove = 1 in {
Evan Chengb783fa32007-07-19 01:14:50 +00002897def MOV16to16_ : I<0x89, MRMDestReg, (outs GR16_:$dst), (ins GR16:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002898 "mov{w}\t{$src, $dst|$dst, $src}", []>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002899def MOV32to32_ : I<0x89, MRMDestReg, (outs GR32_:$dst), (ins GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002900 "mov{l}\t{$src, $dst|$dst, $src}", []>;
Chris Lattnerc90ee9c2008-01-10 07:59:24 +00002901
Evan Chengb783fa32007-07-19 01:14:50 +00002902def MOV16_rr : I<0x89, MRMDestReg, (outs GR16_:$dst), (ins GR16_:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002903 "mov{w}\t{$src, $dst|$dst, $src}", []>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002904def MOV32_rr : I<0x89, MRMDestReg, (outs GR32_:$dst), (ins GR32_:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002905 "mov{l}\t{$src, $dst|$dst, $src}", []>;
Chris Lattnerc90ee9c2008-01-10 07:59:24 +00002906} // neverHasSideEffects
2907
Dan Gohman5574cc72008-12-03 18:15:48 +00002908let canFoldAsLoad = 1, mayLoad = 1, isReMaterializable = 1, mayHaveSideEffects = 1 in {
Evan Chengb783fa32007-07-19 01:14:50 +00002909def MOV16_rm : I<0x8B, MRMSrcMem, (outs GR16_:$dst), (ins i16mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002910 "mov{w}\t{$src, $dst|$dst, $src}", []>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002911def MOV32_rm : I<0x8B, MRMSrcMem, (outs GR32_:$dst), (ins i32mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002912 "mov{l}\t{$src, $dst|$dst, $src}", []>;
Evan Cheng4e84e452007-08-30 05:49:43 +00002913}
Chris Lattnerc90ee9c2008-01-10 07:59:24 +00002914let mayStore = 1, neverHasSideEffects = 1 in {
Evan Chengb783fa32007-07-19 01:14:50 +00002915def MOV16_mr : I<0x89, MRMDestMem, (outs), (ins i16mem:$dst, GR16_:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002916 "mov{w}\t{$src, $dst|$dst, $src}", []>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002917def MOV32_mr : I<0x89, MRMDestMem, (outs), (ins i32mem:$dst, GR32_:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002918 "mov{l}\t{$src, $dst|$dst, $src}", []>;
Chris Lattnerc90ee9c2008-01-10 07:59:24 +00002919}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002920
2921//===----------------------------------------------------------------------===//
2922// Thread Local Storage Instructions
2923//
2924
Rafael Espindolaeef9b4b2009-03-13 19:39:55 +00002925// FIXME: there is duplication with the non-TLS case.
2926// There is a suggestion on how to fix this at
2927// http://lists.cs.uiuc.edu/pipermail/llvm-commits/Week-of-Mon-20090309/075212.html
2928
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002929let Uses = [EBX] in
Anton Korobeynikov4fbf00b2008-05-04 21:36:32 +00002930def TLS_addr32 : I<0, Pseudo, (outs GR32:$dst), (ins i32imm:$sym),
2931 "leal\t${sym:mem}(,%ebx,1), $dst",
2932 [(set GR32:$dst, (X86tlsaddr tglobaltlsaddr:$sym))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002933
2934let AddedComplexity = 10 in
Anton Korobeynikov4fbf00b2008-05-04 21:36:32 +00002935def TLS_gs_rr : I<0, Pseudo, (outs GR32:$dst), (ins GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002936 "movl\t%gs:($src), $dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002937 [(set GR32:$dst, (load (add X86TLStp, GR32:$src)))]>;
2938
2939let AddedComplexity = 15 in
Nicolas Geoffray81580792008-10-25 15:22:06 +00002940def TLS_gs_ri : I<0x8B, Pseudo, (outs GR32:$dst), (ins i32imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002941 "movl\t%gs:${src:mem}, $dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002942 [(set GR32:$dst,
Nicolas Geoffray81580792008-10-25 15:22:06 +00002943 (load (add X86TLStp, (X86Wrapper tglobaltlsaddr:$src))))]>,
2944 SegGS;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002945
Rafael Espindola53ec6be2009-03-11 22:40:04 +00002946let AddedComplexity = 15 in
Rafael Espindolaeef9b4b2009-03-13 19:39:55 +00002947def TLS16_gs_ri : I<0x8B, Pseudo, (outs GR16:$dst), (ins i32imm:$src),
2948 "movw\t%gs:${src:mem}, $dst",
2949 [(set GR16:$dst,
2950 (load (add X86TLStp,
2951 (X86Wrapper tglobaltlsaddr:$src))))]>,
2952 SegGS;
2953
2954let AddedComplexity = 15 in
2955def TLS8_gs_ri : I<0x8B, Pseudo, (outs GR8:$dst), (ins i32imm:$src),
2956 "movb\t%gs:${src:mem}, $dst",
2957 [(set GR8:$dst,
2958 (load (add X86TLStp,
2959 (X86Wrapper tglobaltlsaddr:$src))))]>,
2960 SegGS;
2961
2962let AddedComplexity = 15 in
Rafael Espindola53ec6be2009-03-11 22:40:04 +00002963def TLS_ext16_gs_ri : I<0x8B, Pseudo, (outs GR32:$dst), (ins i32imm:$src),
2964 "movzwl\t%gs:${src:mem}, $dst",
2965 [(set GR32:$dst,
2966 (extloadi32i16
2967 (add X86TLStp,
2968 (X86Wrapper tglobaltlsaddr:$src))))]>,
2969 SegGS;
2970
2971let AddedComplexity = 15 in
Rafael Espindola24e7e312009-03-13 18:37:06 +00002972def TLS_sext16_gs_ri : I<0x8B, Pseudo, (outs GR32:$dst), (ins i32imm:$src),
2973 "movswl\t%gs:${src:mem}, $dst",
2974 [(set GR32:$dst,
2975 (sextloadi32i16
2976 (add X86TLStp,
2977 (X86Wrapper tglobaltlsaddr:$src))))]>,
2978 SegGS;
2979
2980let AddedComplexity = 15 in
2981def TLS_zext16_gs_ri : I<0x8B, Pseudo, (outs GR32:$dst), (ins i32imm:$src),
2982 "movzwl\t%gs:${src:mem}, $dst",
2983 [(set GR32:$dst,
2984 (zextloadi32i16
2985 (add X86TLStp,
2986 (X86Wrapper tglobaltlsaddr:$src))))]>,
2987 SegGS;
2988
2989let AddedComplexity = 15 in
Rafael Espindola53ec6be2009-03-11 22:40:04 +00002990def TLS_ext8_gs_ri : I<0x8B, Pseudo, (outs GR32:$dst), (ins i32imm:$src),
2991 "movzbl\t%gs:${src:mem}, $dst",
2992 [(set GR32:$dst,
2993 (extloadi32i8
2994 (add X86TLStp,
2995 (X86Wrapper tglobaltlsaddr:$src))))]>,
2996 SegGS;
2997
Rafael Espindola24e7e312009-03-13 18:37:06 +00002998let AddedComplexity = 15 in
2999def TLS_sext8_gs_ri : I<0x8B, Pseudo, (outs GR32:$dst), (ins i32imm:$src),
3000 "movsbl\t%gs:${src:mem}, $dst",
3001 [(set GR32:$dst,
3002 (sextloadi32i8
3003 (add X86TLStp,
3004 (X86Wrapper tglobaltlsaddr:$src))))]>,
3005 SegGS;
3006
3007let AddedComplexity = 15 in
3008def TLS_zext8_gs_ri : I<0x8B, Pseudo, (outs GR32:$dst), (ins i32imm:$src),
3009 "movzbl\t%gs:${src:mem}, $dst",
3010 [(set GR32:$dst,
3011 (zextloadi32i8
3012 (add X86TLStp,
3013 (X86Wrapper tglobaltlsaddr:$src))))]>,
3014 SegGS;
3015
Nicolas Geoffray81580792008-10-25 15:22:06 +00003016def TLS_tp : I<0x8B, Pseudo, (outs GR32:$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00003017 "movl\t%gs:0, $dst",
Nicolas Geoffray81580792008-10-25 15:22:06 +00003018 [(set GR32:$dst, X86TLStp)]>, SegGS;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003019
sampo9cc09a32009-01-26 01:24:32 +00003020let AddedComplexity = 5 in
3021def GS_MOV32rm : I<0x8B, MRMSrcMem, (outs GR32:$dst), (ins i32mem:$src),
3022 "movl\t%gs:$src, $dst",
3023 [(set GR32:$dst, (gsload addr:$src))]>, SegGS;
3024
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003025//===----------------------------------------------------------------------===//
3026// DWARF Pseudo Instructions
3027//
3028
Evan Chengb783fa32007-07-19 01:14:50 +00003029def DWARF_LOC : I<0, Pseudo, (outs),
3030 (ins i32imm:$line, i32imm:$col, i32imm:$file),
Dan Gohman77af4a82007-09-24 19:25:06 +00003031 ".loc\t${file:debug} ${line:debug} ${col:debug}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003032 [(dwarf_loc (i32 imm:$line), (i32 imm:$col),
3033 (i32 imm:$file))]>;
3034
3035//===----------------------------------------------------------------------===//
3036// EH Pseudo Instructions
3037//
3038let isTerminator = 1, isReturn = 1, isBarrier = 1,
Evan Cheng37e7c752007-07-21 00:34:19 +00003039 hasCtrlDep = 1 in {
Evan Chengb783fa32007-07-19 01:14:50 +00003040def EH_RETURN : I<0xC3, RawFrm, (outs), (ins GR32:$addr),
Dan Gohman91888f02007-07-31 20:11:57 +00003041 "ret\t#eh_return, addr: $addr",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003042 [(X86ehret GR32:$addr)]>;
3043
3044}
3045
3046//===----------------------------------------------------------------------===//
Andrew Lenharthe44f3902008-02-21 06:45:13 +00003047// Atomic support
3048//
Andrew Lenharth7a5a4b22008-03-01 13:37:02 +00003049
Evan Cheng3e171562008-04-19 01:20:30 +00003050// Atomic swap. These are just normal xchg instructions. But since a memory
3051// operand is referenced, the atomicity is ensured.
Dan Gohmana41a1c092008-08-06 15:52:50 +00003052let Constraints = "$val = $dst" in {
Evan Cheng3e171562008-04-19 01:20:30 +00003053def XCHG32rm : I<0x87, MRMSrcMem, (outs GR32:$dst), (ins i32mem:$ptr, GR32:$val),
3054 "xchg{l}\t{$val, $ptr|$ptr, $val}",
3055 [(set GR32:$dst, (atomic_swap_32 addr:$ptr, GR32:$val))]>;
3056def XCHG16rm : I<0x87, MRMSrcMem, (outs GR16:$dst), (ins i16mem:$ptr, GR16:$val),
3057 "xchg{w}\t{$val, $ptr|$ptr, $val}",
3058 [(set GR16:$dst, (atomic_swap_16 addr:$ptr, GR16:$val))]>,
3059 OpSize;
3060def XCHG8rm : I<0x86, MRMSrcMem, (outs GR8:$dst), (ins i8mem:$ptr, GR8:$val),
3061 "xchg{b}\t{$val, $ptr|$ptr, $val}",
3062 [(set GR8:$dst, (atomic_swap_8 addr:$ptr, GR8:$val))]>;
3063}
3064
Evan Chengd49dbb82008-04-18 20:55:36 +00003065// Atomic compare and swap.
Andrew Lenharth7dfe23f2008-03-01 21:52:34 +00003066let Defs = [EAX, EFLAGS], Uses = [EAX] in {
Evan Chengd49dbb82008-04-18 20:55:36 +00003067def LCMPXCHG32 : I<0xB1, MRMDestMem, (outs), (ins i32mem:$ptr, GR32:$swap),
Dale Johannesend20e4452008-08-19 18:47:28 +00003068 "lock\n\tcmpxchg{l}\t{$swap, $ptr|$ptr, $swap}",
Evan Cheng09fbdee2008-03-04 03:20:06 +00003069 [(X86cas addr:$ptr, GR32:$swap, 4)]>, TB, LOCK;
Andrew Lenharth7a5a4b22008-03-01 13:37:02 +00003070}
Dale Johannesenf160d802008-10-02 18:53:47 +00003071let Defs = [EAX, EDX, EFLAGS], Uses = [EAX, EBX, ECX, EDX] in {
Anton Korobeynikovc4067392008-07-22 16:22:48 +00003072def LCMPXCHG8B : I<0xC7, MRM1m, (outs), (ins i32mem:$ptr),
Dale Johannesend20e4452008-08-19 18:47:28 +00003073 "lock\n\tcmpxchg8b\t$ptr",
Andrew Lenharth81580822008-03-05 01:15:49 +00003074 [(X86cas8 addr:$ptr)]>, TB, LOCK;
3075}
Andrew Lenharth7dfe23f2008-03-01 21:52:34 +00003076
3077let Defs = [AX, EFLAGS], Uses = [AX] in {
Evan Chengd49dbb82008-04-18 20:55:36 +00003078def LCMPXCHG16 : I<0xB1, MRMDestMem, (outs), (ins i16mem:$ptr, GR16:$swap),
Dale Johannesend20e4452008-08-19 18:47:28 +00003079 "lock\n\tcmpxchg{w}\t{$swap, $ptr|$ptr, $swap}",
Evan Cheng09fbdee2008-03-04 03:20:06 +00003080 [(X86cas addr:$ptr, GR16:$swap, 2)]>, TB, OpSize, LOCK;
Andrew Lenharth7a5a4b22008-03-01 13:37:02 +00003081}
Andrew Lenharth7dfe23f2008-03-01 21:52:34 +00003082let Defs = [AL, EFLAGS], Uses = [AL] in {
Evan Chengd49dbb82008-04-18 20:55:36 +00003083def LCMPXCHG8 : I<0xB0, MRMDestMem, (outs), (ins i8mem:$ptr, GR8:$swap),
Dale Johannesend20e4452008-08-19 18:47:28 +00003084 "lock\n\tcmpxchg{b}\t{$swap, $ptr|$ptr, $swap}",
Evan Cheng09fbdee2008-03-04 03:20:06 +00003085 [(X86cas addr:$ptr, GR8:$swap, 1)]>, TB, LOCK;
Andrew Lenharth7a5a4b22008-03-01 13:37:02 +00003086}
3087
Evan Chengd49dbb82008-04-18 20:55:36 +00003088// Atomic exchange and add
3089let Constraints = "$val = $dst", Defs = [EFLAGS] in {
3090def LXADD32 : I<0xC1, MRMSrcMem, (outs GR32:$dst), (ins i32mem:$ptr, GR32:$val),
Dale Johannesend20e4452008-08-19 18:47:28 +00003091 "lock\n\txadd{l}\t{$val, $ptr|$ptr, $val}",
Mon P Wang6bde9ec2008-06-25 08:15:39 +00003092 [(set GR32:$dst, (atomic_load_add_32 addr:$ptr, GR32:$val))]>,
Evan Chengd49dbb82008-04-18 20:55:36 +00003093 TB, LOCK;
3094def LXADD16 : I<0xC1, MRMSrcMem, (outs GR16:$dst), (ins i16mem:$ptr, GR16:$val),
Dale Johannesend20e4452008-08-19 18:47:28 +00003095 "lock\n\txadd{w}\t{$val, $ptr|$ptr, $val}",
Mon P Wang6bde9ec2008-06-25 08:15:39 +00003096 [(set GR16:$dst, (atomic_load_add_16 addr:$ptr, GR16:$val))]>,
Evan Chengd49dbb82008-04-18 20:55:36 +00003097 TB, OpSize, LOCK;
3098def LXADD8 : I<0xC0, MRMSrcMem, (outs GR8:$dst), (ins i8mem:$ptr, GR8:$val),
Dale Johannesend20e4452008-08-19 18:47:28 +00003099 "lock\n\txadd{b}\t{$val, $ptr|$ptr, $val}",
Mon P Wang6bde9ec2008-06-25 08:15:39 +00003100 [(set GR8:$dst, (atomic_load_add_8 addr:$ptr, GR8:$val))]>,
Evan Chengd49dbb82008-04-18 20:55:36 +00003101 TB, LOCK;
Andrew Lenharth7a5a4b22008-03-01 13:37:02 +00003102}
3103
Mon P Wang6bde9ec2008-06-25 08:15:39 +00003104// Atomic exchange, and, or, xor
Mon P Wang078a62d2008-05-05 19:05:59 +00003105let Constraints = "$val = $dst", Defs = [EFLAGS],
3106 usesCustomDAGSchedInserter = 1 in {
Dan Gohman8aeb61f2008-05-12 20:22:45 +00003107def ATOMAND32 : I<0, Pseudo, (outs GR32:$dst),(ins i32mem:$ptr, GR32:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003108 "#ATOMAND32 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003109 [(set GR32:$dst, (atomic_load_and_32 addr:$ptr, GR32:$val))]>;
Dan Gohman8aeb61f2008-05-12 20:22:45 +00003110def ATOMOR32 : I<0, Pseudo, (outs GR32:$dst),(ins i32mem:$ptr, GR32:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003111 "#ATOMOR32 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003112 [(set GR32:$dst, (atomic_load_or_32 addr:$ptr, GR32:$val))]>;
Dan Gohman8aeb61f2008-05-12 20:22:45 +00003113def ATOMXOR32 : I<0, Pseudo,(outs GR32:$dst),(ins i32mem:$ptr, GR32:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003114 "#ATOMXOR32 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003115 [(set GR32:$dst, (atomic_load_xor_32 addr:$ptr, GR32:$val))]>;
Andrew Lenharthaf02d592008-06-14 05:48:15 +00003116def ATOMNAND32 : I<0, Pseudo,(outs GR32:$dst),(ins i32mem:$ptr, GR32:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003117 "#ATOMNAND32 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003118 [(set GR32:$dst, (atomic_load_nand_32 addr:$ptr, GR32:$val))]>;
Dan Gohman8aeb61f2008-05-12 20:22:45 +00003119def ATOMMIN32: I<0, Pseudo, (outs GR32:$dst), (ins i32mem:$ptr, GR32:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003120 "#ATOMMIN32 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003121 [(set GR32:$dst, (atomic_load_min_32 addr:$ptr, GR32:$val))]>;
Dan Gohman8aeb61f2008-05-12 20:22:45 +00003122def ATOMMAX32: I<0, Pseudo, (outs GR32:$dst),(ins i32mem:$ptr, GR32:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003123 "#ATOMMAX32 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003124 [(set GR32:$dst, (atomic_load_max_32 addr:$ptr, GR32:$val))]>;
Dan Gohman8aeb61f2008-05-12 20:22:45 +00003125def ATOMUMIN32: I<0, Pseudo, (outs GR32:$dst),(ins i32mem:$ptr, GR32:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003126 "#ATOMUMIN32 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003127 [(set GR32:$dst, (atomic_load_umin_32 addr:$ptr, GR32:$val))]>;
Dan Gohman8aeb61f2008-05-12 20:22:45 +00003128def ATOMUMAX32: I<0, Pseudo, (outs GR32:$dst),(ins i32mem:$ptr, GR32:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003129 "#ATOMUMAX32 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003130 [(set GR32:$dst, (atomic_load_umax_32 addr:$ptr, GR32:$val))]>;
Dale Johannesend20e4452008-08-19 18:47:28 +00003131
3132def ATOMAND16 : I<0, Pseudo, (outs GR16:$dst),(ins i16mem:$ptr, GR16:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003133 "#ATOMAND16 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003134 [(set GR16:$dst, (atomic_load_and_16 addr:$ptr, GR16:$val))]>;
Dale Johannesend20e4452008-08-19 18:47:28 +00003135def ATOMOR16 : I<0, Pseudo, (outs GR16:$dst),(ins i16mem:$ptr, GR16:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003136 "#ATOMOR16 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003137 [(set GR16:$dst, (atomic_load_or_16 addr:$ptr, GR16:$val))]>;
Dale Johannesend20e4452008-08-19 18:47:28 +00003138def ATOMXOR16 : I<0, Pseudo,(outs GR16:$dst),(ins i16mem:$ptr, GR16:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003139 "#ATOMXOR16 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003140 [(set GR16:$dst, (atomic_load_xor_16 addr:$ptr, GR16:$val))]>;
Dale Johannesend20e4452008-08-19 18:47:28 +00003141def ATOMNAND16 : I<0, Pseudo,(outs GR16:$dst),(ins i16mem:$ptr, GR16:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003142 "#ATOMNAND16 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003143 [(set GR16:$dst, (atomic_load_nand_16 addr:$ptr, GR16:$val))]>;
Dale Johannesend20e4452008-08-19 18:47:28 +00003144def ATOMMIN16: I<0, Pseudo, (outs GR16:$dst), (ins i16mem:$ptr, GR16:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003145 "#ATOMMIN16 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003146 [(set GR16:$dst, (atomic_load_min_16 addr:$ptr, GR16:$val))]>;
Dale Johannesend20e4452008-08-19 18:47:28 +00003147def ATOMMAX16: I<0, Pseudo, (outs GR16:$dst),(ins i16mem:$ptr, GR16:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003148 "#ATOMMAX16 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003149 [(set GR16:$dst, (atomic_load_max_16 addr:$ptr, GR16:$val))]>;
Dale Johannesend20e4452008-08-19 18:47:28 +00003150def ATOMUMIN16: I<0, Pseudo, (outs GR16:$dst),(ins i16mem:$ptr, GR16:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003151 "#ATOMUMIN16 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003152 [(set GR16:$dst, (atomic_load_umin_16 addr:$ptr, GR16:$val))]>;
Dale Johannesend20e4452008-08-19 18:47:28 +00003153def ATOMUMAX16: I<0, Pseudo, (outs GR16:$dst),(ins i16mem:$ptr, GR16:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003154 "#ATOMUMAX16 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003155 [(set GR16:$dst, (atomic_load_umax_16 addr:$ptr, GR16:$val))]>;
Dale Johannesend20e4452008-08-19 18:47:28 +00003156
3157def ATOMAND8 : I<0, Pseudo, (outs GR8:$dst),(ins i8mem:$ptr, GR8:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003158 "#ATOMAND8 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003159 [(set GR8:$dst, (atomic_load_and_8 addr:$ptr, GR8:$val))]>;
Dale Johannesend20e4452008-08-19 18:47:28 +00003160def ATOMOR8 : I<0, Pseudo, (outs GR8:$dst),(ins i8mem:$ptr, GR8:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003161 "#ATOMOR8 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003162 [(set GR8:$dst, (atomic_load_or_8 addr:$ptr, GR8:$val))]>;
Dale Johannesend20e4452008-08-19 18:47:28 +00003163def ATOMXOR8 : I<0, Pseudo,(outs GR8:$dst),(ins i8mem:$ptr, GR8:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003164 "#ATOMXOR8 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003165 [(set GR8:$dst, (atomic_load_xor_8 addr:$ptr, GR8:$val))]>;
Dale Johannesend20e4452008-08-19 18:47:28 +00003166def ATOMNAND8 : I<0, Pseudo,(outs GR8:$dst),(ins i8mem:$ptr, GR8:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003167 "#ATOMNAND8 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003168 [(set GR8:$dst, (atomic_load_nand_8 addr:$ptr, GR8:$val))]>;
Mon P Wang078a62d2008-05-05 19:05:59 +00003169}
3170
Dale Johannesenf160d802008-10-02 18:53:47 +00003171let Constraints = "$val1 = $dst1, $val2 = $dst2",
3172 Defs = [EFLAGS, EAX, EBX, ECX, EDX],
3173 Uses = [EAX, EBX, ECX, EDX],
Dale Johannesen44eb5372008-10-03 19:41:08 +00003174 mayLoad = 1, mayStore = 1,
Dale Johannesenf160d802008-10-02 18:53:47 +00003175 usesCustomDAGSchedInserter = 1 in {
3176def ATOMAND6432 : I<0, Pseudo, (outs GR32:$dst1, GR32:$dst2),
3177 (ins i64mem:$ptr, GR32:$val1, GR32:$val2),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003178 "#ATOMAND6432 PSEUDO!", []>;
Dale Johannesenf160d802008-10-02 18:53:47 +00003179def ATOMOR6432 : I<0, Pseudo, (outs GR32:$dst1, GR32:$dst2),
3180 (ins i64mem:$ptr, GR32:$val1, GR32:$val2),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003181 "#ATOMOR6432 PSEUDO!", []>;
Dale Johannesenf160d802008-10-02 18:53:47 +00003182def ATOMXOR6432 : I<0, Pseudo, (outs GR32:$dst1, GR32:$dst2),
3183 (ins i64mem:$ptr, GR32:$val1, GR32:$val2),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003184 "#ATOMXOR6432 PSEUDO!", []>;
Dale Johannesenf160d802008-10-02 18:53:47 +00003185def ATOMNAND6432 : I<0, Pseudo, (outs GR32:$dst1, GR32:$dst2),
3186 (ins i64mem:$ptr, GR32:$val1, GR32:$val2),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003187 "#ATOMNAND6432 PSEUDO!", []>;
Dale Johannesenf160d802008-10-02 18:53:47 +00003188def ATOMADD6432 : I<0, Pseudo, (outs GR32:$dst1, GR32:$dst2),
3189 (ins i64mem:$ptr, GR32:$val1, GR32:$val2),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003190 "#ATOMADD6432 PSEUDO!", []>;
Dale Johannesenf160d802008-10-02 18:53:47 +00003191def ATOMSUB6432 : I<0, Pseudo, (outs GR32:$dst1, GR32:$dst2),
3192 (ins i64mem:$ptr, GR32:$val1, GR32:$val2),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003193 "#ATOMSUB6432 PSEUDO!", []>;
Dale Johannesen51c58ee2008-10-03 22:25:52 +00003194def ATOMSWAP6432 : I<0, Pseudo, (outs GR32:$dst1, GR32:$dst2),
3195 (ins i64mem:$ptr, GR32:$val1, GR32:$val2),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003196 "#ATOMSWAP6432 PSEUDO!", []>;
Dale Johannesenf160d802008-10-02 18:53:47 +00003197}
3198
Andrew Lenharthe44f3902008-02-21 06:45:13 +00003199//===----------------------------------------------------------------------===//
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003200// Non-Instruction Patterns
3201//===----------------------------------------------------------------------===//
3202
Bill Wendlingfef06052008-09-16 21:48:12 +00003203// ConstantPool GlobalAddress, ExternalSymbol, and JumpTable
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003204def : Pat<(i32 (X86Wrapper tconstpool :$dst)), (MOV32ri tconstpool :$dst)>;
3205def : Pat<(i32 (X86Wrapper tjumptable :$dst)), (MOV32ri tjumptable :$dst)>;
Nate Begemanb52948972008-04-12 00:47:57 +00003206def : Pat<(i32 (X86Wrapper tglobaltlsaddr:$dst)),(MOV32ri tglobaltlsaddr:$dst)>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003207def : Pat<(i32 (X86Wrapper tglobaladdr :$dst)), (MOV32ri tglobaladdr :$dst)>;
3208def : Pat<(i32 (X86Wrapper texternalsym:$dst)), (MOV32ri texternalsym:$dst)>;
3209
3210def : Pat<(add GR32:$src1, (X86Wrapper tconstpool:$src2)),
3211 (ADD32ri GR32:$src1, tconstpool:$src2)>;
3212def : Pat<(add GR32:$src1, (X86Wrapper tjumptable:$src2)),
3213 (ADD32ri GR32:$src1, tjumptable:$src2)>;
3214def : Pat<(add GR32:$src1, (X86Wrapper tglobaladdr :$src2)),
3215 (ADD32ri GR32:$src1, tglobaladdr:$src2)>;
3216def : Pat<(add GR32:$src1, (X86Wrapper texternalsym:$src2)),
3217 (ADD32ri GR32:$src1, texternalsym:$src2)>;
3218
3219def : Pat<(store (i32 (X86Wrapper tglobaladdr:$src)), addr:$dst),
3220 (MOV32mi addr:$dst, tglobaladdr:$src)>;
3221def : Pat<(store (i32 (X86Wrapper texternalsym:$src)), addr:$dst),
3222 (MOV32mi addr:$dst, texternalsym:$src)>;
3223
3224// Calls
Arnold Schwaighofere2d6bbb2007-10-11 19:40:01 +00003225// tailcall stuff
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003226def : Pat<(X86tailcall GR32:$dst),
Arnold Schwaighofere2d6bbb2007-10-11 19:40:01 +00003227 (TAILCALL)>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003228
3229def : Pat<(X86tailcall (i32 tglobaladdr:$dst)),
Arnold Schwaighofere2d6bbb2007-10-11 19:40:01 +00003230 (TAILCALL)>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003231def : Pat<(X86tailcall (i32 texternalsym:$dst)),
Arnold Schwaighofere2d6bbb2007-10-11 19:40:01 +00003232 (TAILCALL)>;
3233
3234def : Pat<(X86tcret GR32:$dst, imm:$off),
3235 (TCRETURNri GR32:$dst, imm:$off)>;
3236
3237def : Pat<(X86tcret (i32 tglobaladdr:$dst), imm:$off),
3238 (TCRETURNdi texternalsym:$dst, imm:$off)>;
3239
3240def : Pat<(X86tcret (i32 texternalsym:$dst), imm:$off),
3241 (TCRETURNdi texternalsym:$dst, imm:$off)>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003242
3243def : Pat<(X86call (i32 tglobaladdr:$dst)),
3244 (CALLpcrel32 tglobaladdr:$dst)>;
3245def : Pat<(X86call (i32 texternalsym:$dst)),
3246 (CALLpcrel32 texternalsym:$dst)>;
3247
3248// X86 specific add which produces a flag.
3249def : Pat<(addc GR32:$src1, GR32:$src2),
3250 (ADD32rr GR32:$src1, GR32:$src2)>;
3251def : Pat<(addc GR32:$src1, (load addr:$src2)),
3252 (ADD32rm GR32:$src1, addr:$src2)>;
3253def : Pat<(addc GR32:$src1, imm:$src2),
3254 (ADD32ri GR32:$src1, imm:$src2)>;
3255def : Pat<(addc GR32:$src1, i32immSExt8:$src2),
3256 (ADD32ri8 GR32:$src1, i32immSExt8:$src2)>;
3257
3258def : Pat<(subc GR32:$src1, GR32:$src2),
3259 (SUB32rr GR32:$src1, GR32:$src2)>;
3260def : Pat<(subc GR32:$src1, (load addr:$src2)),
3261 (SUB32rm GR32:$src1, addr:$src2)>;
3262def : Pat<(subc GR32:$src1, imm:$src2),
3263 (SUB32ri GR32:$src1, imm:$src2)>;
3264def : Pat<(subc GR32:$src1, i32immSExt8:$src2),
3265 (SUB32ri8 GR32:$src1, i32immSExt8:$src2)>;
3266
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003267// Comparisons.
3268
3269// TEST R,R is smaller than CMP R,0
Evan Cheng621216e2007-09-29 00:00:36 +00003270def : Pat<(parallel (X86cmp GR8:$src1, 0), (implicit EFLAGS)),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003271 (TEST8rr GR8:$src1, GR8:$src1)>;
Evan Cheng621216e2007-09-29 00:00:36 +00003272def : Pat<(parallel (X86cmp GR16:$src1, 0), (implicit EFLAGS)),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003273 (TEST16rr GR16:$src1, GR16:$src1)>;
Evan Cheng621216e2007-09-29 00:00:36 +00003274def : Pat<(parallel (X86cmp GR32:$src1, 0), (implicit EFLAGS)),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003275 (TEST32rr GR32:$src1, GR32:$src1)>;
3276
Dan Gohman0a3c5222009-01-07 01:00:24 +00003277// Conditional moves with folded loads with operands swapped and conditions
3278// inverted.
3279def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_B, EFLAGS),
3280 (CMOVAE16rm GR16:$src2, addr:$src1)>;
3281def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_B, EFLAGS),
3282 (CMOVAE32rm GR32:$src2, addr:$src1)>;
3283def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_AE, EFLAGS),
3284 (CMOVB16rm GR16:$src2, addr:$src1)>;
3285def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_AE, EFLAGS),
3286 (CMOVB32rm GR32:$src2, addr:$src1)>;
3287def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_E, EFLAGS),
3288 (CMOVNE16rm GR16:$src2, addr:$src1)>;
3289def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_E, EFLAGS),
3290 (CMOVNE32rm GR32:$src2, addr:$src1)>;
3291def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_NE, EFLAGS),
3292 (CMOVE16rm GR16:$src2, addr:$src1)>;
3293def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_NE, EFLAGS),
3294 (CMOVE32rm GR32:$src2, addr:$src1)>;
3295def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_BE, EFLAGS),
3296 (CMOVA16rm GR16:$src2, addr:$src1)>;
3297def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_BE, EFLAGS),
3298 (CMOVA32rm GR32:$src2, addr:$src1)>;
3299def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_A, EFLAGS),
3300 (CMOVBE16rm GR16:$src2, addr:$src1)>;
3301def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_A, EFLAGS),
3302 (CMOVBE32rm GR32:$src2, addr:$src1)>;
3303def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_L, EFLAGS),
3304 (CMOVGE16rm GR16:$src2, addr:$src1)>;
3305def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_L, EFLAGS),
3306 (CMOVGE32rm GR32:$src2, addr:$src1)>;
3307def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_GE, EFLAGS),
3308 (CMOVL16rm GR16:$src2, addr:$src1)>;
3309def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_GE, EFLAGS),
3310 (CMOVL32rm GR32:$src2, addr:$src1)>;
3311def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_LE, EFLAGS),
3312 (CMOVG16rm GR16:$src2, addr:$src1)>;
3313def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_LE, EFLAGS),
3314 (CMOVG32rm GR32:$src2, addr:$src1)>;
3315def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_G, EFLAGS),
3316 (CMOVLE16rm GR16:$src2, addr:$src1)>;
3317def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_G, EFLAGS),
3318 (CMOVLE32rm GR32:$src2, addr:$src1)>;
3319def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_P, EFLAGS),
3320 (CMOVNP16rm GR16:$src2, addr:$src1)>;
3321def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_P, EFLAGS),
3322 (CMOVNP32rm GR32:$src2, addr:$src1)>;
3323def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_NP, EFLAGS),
3324 (CMOVP16rm GR16:$src2, addr:$src1)>;
3325def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_NP, EFLAGS),
3326 (CMOVP32rm GR32:$src2, addr:$src1)>;
3327def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_S, EFLAGS),
3328 (CMOVNS16rm GR16:$src2, addr:$src1)>;
3329def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_S, EFLAGS),
3330 (CMOVNS32rm GR32:$src2, addr:$src1)>;
3331def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_NS, EFLAGS),
3332 (CMOVS16rm GR16:$src2, addr:$src1)>;
3333def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_NS, EFLAGS),
3334 (CMOVS32rm GR32:$src2, addr:$src1)>;
3335def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_O, EFLAGS),
3336 (CMOVNO16rm GR16:$src2, addr:$src1)>;
3337def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_O, EFLAGS),
3338 (CMOVNO32rm GR32:$src2, addr:$src1)>;
3339def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_NO, EFLAGS),
3340 (CMOVO16rm GR16:$src2, addr:$src1)>;
3341def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_NO, EFLAGS),
3342 (CMOVO32rm GR32:$src2, addr:$src1)>;
3343
Duncan Sands082524c2008-01-23 20:39:46 +00003344// zextload bool -> zextload byte
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003345def : Pat<(zextloadi8i1 addr:$src), (MOV8rm addr:$src)>;
3346def : Pat<(zextloadi16i1 addr:$src), (MOVZX16rm8 addr:$src)>;
3347def : Pat<(zextloadi32i1 addr:$src), (MOVZX32rm8 addr:$src)>;
3348
3349// extload bool -> extload byte
3350def : Pat<(extloadi8i1 addr:$src), (MOV8rm addr:$src)>;
Bill Wendlingce1c5c12008-08-22 20:51:05 +00003351def : Pat<(extloadi16i1 addr:$src), (MOVZX16rm8 addr:$src)>,
3352 Requires<[In32BitMode]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003353def : Pat<(extloadi32i1 addr:$src), (MOVZX32rm8 addr:$src)>;
Bill Wendlingce1c5c12008-08-22 20:51:05 +00003354def : Pat<(extloadi16i8 addr:$src), (MOVZX16rm8 addr:$src)>,
3355 Requires<[In32BitMode]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003356def : Pat<(extloadi32i8 addr:$src), (MOVZX32rm8 addr:$src)>;
3357def : Pat<(extloadi32i16 addr:$src), (MOVZX32rm16 addr:$src)>;
3358
Dan Gohmandd612bb2008-08-20 21:27:32 +00003359// anyext
Bill Wendlingce1c5c12008-08-22 20:51:05 +00003360def : Pat<(i16 (anyext GR8 :$src)), (MOVZX16rr8 GR8 :$src)>,
3361 Requires<[In32BitMode]>;
3362def : Pat<(i32 (anyext GR8 :$src)), (MOVZX32rr8 GR8 :$src)>,
3363 Requires<[In32BitMode]>;
Dan Gohmandd612bb2008-08-20 21:27:32 +00003364def : Pat<(i32 (anyext GR16:$src)),
3365 (INSERT_SUBREG (i32 (IMPLICIT_DEF)), GR16:$src, x86_subreg_16bit)>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003366
Evan Chengf2abee72007-12-13 00:43:27 +00003367// (and (i32 load), 255) -> (zextload i8)
Evan Cheng1e5e5452008-09-29 17:26:18 +00003368def : Pat<(i32 (and (nvloadi32 addr:$src), (i32 255))),
3369 (MOVZX32rm8 addr:$src)>;
3370def : Pat<(i32 (and (nvloadi32 addr:$src), (i32 65535))),
3371 (MOVZX32rm16 addr:$src)>;
Evan Chengf2abee72007-12-13 00:43:27 +00003372
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003373//===----------------------------------------------------------------------===//
3374// Some peepholes
3375//===----------------------------------------------------------------------===//
3376
Dan Gohman5a5e6e92008-10-17 01:33:43 +00003377// Odd encoding trick: -128 fits into an 8-bit immediate field while
3378// +128 doesn't, so in this special case use a sub instead of an add.
3379def : Pat<(add GR16:$src1, 128),
3380 (SUB16ri8 GR16:$src1, -128)>;
3381def : Pat<(store (add (loadi16 addr:$dst), 128), addr:$dst),
3382 (SUB16mi8 addr:$dst, -128)>;
3383def : Pat<(add GR32:$src1, 128),
3384 (SUB32ri8 GR32:$src1, -128)>;
3385def : Pat<(store (add (loadi32 addr:$dst), 128), addr:$dst),
3386 (SUB32mi8 addr:$dst, -128)>;
3387
Dan Gohman9203ab42008-07-30 18:09:17 +00003388// r & (2^16-1) ==> movz
3389def : Pat<(and GR32:$src1, 0xffff),
Dan Gohmandd612bb2008-08-20 21:27:32 +00003390 (MOVZX32rr16 (i16 (EXTRACT_SUBREG GR32:$src1, x86_subreg_16bit)))>;
Dan Gohman5beb1ff2008-08-06 18:27:21 +00003391// r & (2^8-1) ==> movz
3392def : Pat<(and GR32:$src1, 0xff),
Dan Gohmandd612bb2008-08-20 21:27:32 +00003393 (MOVZX32rr8 (i8 (EXTRACT_SUBREG (MOV32to32_ GR32:$src1),
3394 x86_subreg_8bit)))>,
Dan Gohman5beb1ff2008-08-06 18:27:21 +00003395 Requires<[In32BitMode]>;
3396// r & (2^8-1) ==> movz
3397def : Pat<(and GR16:$src1, 0xff),
Dan Gohmandd612bb2008-08-20 21:27:32 +00003398 (MOVZX16rr8 (i8 (EXTRACT_SUBREG (MOV16to16_ GR16:$src1),
3399 x86_subreg_8bit)))>,
3400 Requires<[In32BitMode]>;
3401
3402// sext_inreg patterns
3403def : Pat<(sext_inreg GR32:$src, i16),
3404 (MOVSX32rr16 (i16 (EXTRACT_SUBREG GR32:$src, x86_subreg_16bit)))>;
3405def : Pat<(sext_inreg GR32:$src, i8),
3406 (MOVSX32rr8 (i8 (EXTRACT_SUBREG (MOV32to32_ GR32:$src),
3407 x86_subreg_8bit)))>,
3408 Requires<[In32BitMode]>;
3409def : Pat<(sext_inreg GR16:$src, i8),
3410 (MOVSX16rr8 (i8 (EXTRACT_SUBREG (MOV16to16_ GR16:$src),
3411 x86_subreg_8bit)))>,
3412 Requires<[In32BitMode]>;
3413
3414// trunc patterns
3415def : Pat<(i16 (trunc GR32:$src)),
3416 (i16 (EXTRACT_SUBREG GR32:$src, x86_subreg_16bit))>;
3417def : Pat<(i8 (trunc GR32:$src)),
3418 (i8 (EXTRACT_SUBREG (MOV32to32_ GR32:$src), x86_subreg_8bit))>,
3419 Requires<[In32BitMode]>;
3420def : Pat<(i8 (trunc GR16:$src)),
3421 (i8 (EXTRACT_SUBREG (MOV16to16_ GR16:$src), x86_subreg_8bit))>,
Dan Gohman5beb1ff2008-08-06 18:27:21 +00003422 Requires<[In32BitMode]>;
Dan Gohman9203ab42008-07-30 18:09:17 +00003423
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003424// (shl x, 1) ==> (add x, x)
3425def : Pat<(shl GR8 :$src1, (i8 1)), (ADD8rr GR8 :$src1, GR8 :$src1)>;
3426def : Pat<(shl GR16:$src1, (i8 1)), (ADD16rr GR16:$src1, GR16:$src1)>;
3427def : Pat<(shl GR32:$src1, (i8 1)), (ADD32rr GR32:$src1, GR32:$src1)>;
3428
Evan Cheng76a64c72008-08-30 02:03:58 +00003429// (shl x (and y, 31)) ==> (shl x, y)
3430def : Pat<(shl GR8:$src1, (and CL:$amt, 31)),
3431 (SHL8rCL GR8:$src1)>;
3432def : Pat<(shl GR16:$src1, (and CL:$amt, 31)),
3433 (SHL16rCL GR16:$src1)>;
3434def : Pat<(shl GR32:$src1, (and CL:$amt, 31)),
3435 (SHL32rCL GR32:$src1)>;
3436def : Pat<(store (shl (loadi8 addr:$dst), (and CL:$amt, 31)), addr:$dst),
3437 (SHL8mCL addr:$dst)>;
3438def : Pat<(store (shl (loadi16 addr:$dst), (and CL:$amt, 31)), addr:$dst),
3439 (SHL16mCL addr:$dst)>;
3440def : Pat<(store (shl (loadi32 addr:$dst), (and CL:$amt, 31)), addr:$dst),
3441 (SHL32mCL addr:$dst)>;
3442
3443def : Pat<(srl GR8:$src1, (and CL:$amt, 31)),
3444 (SHR8rCL GR8:$src1)>;
3445def : Pat<(srl GR16:$src1, (and CL:$amt, 31)),
3446 (SHR16rCL GR16:$src1)>;
3447def : Pat<(srl GR32:$src1, (and CL:$amt, 31)),
3448 (SHR32rCL GR32:$src1)>;
3449def : Pat<(store (srl (loadi8 addr:$dst), (and CL:$amt, 31)), addr:$dst),
3450 (SHR8mCL addr:$dst)>;
3451def : Pat<(store (srl (loadi16 addr:$dst), (and CL:$amt, 31)), addr:$dst),
3452 (SHR16mCL addr:$dst)>;
3453def : Pat<(store (srl (loadi32 addr:$dst), (and CL:$amt, 31)), addr:$dst),
3454 (SHR32mCL addr:$dst)>;
3455
3456def : Pat<(sra GR8:$src1, (and CL:$amt, 31)),
3457 (SAR8rCL GR8:$src1)>;
3458def : Pat<(sra GR16:$src1, (and CL:$amt, 31)),
3459 (SAR16rCL GR16:$src1)>;
3460def : Pat<(sra GR32:$src1, (and CL:$amt, 31)),
3461 (SAR32rCL GR32:$src1)>;
3462def : Pat<(store (sra (loadi8 addr:$dst), (and CL:$amt, 31)), addr:$dst),
3463 (SAR8mCL addr:$dst)>;
3464def : Pat<(store (sra (loadi16 addr:$dst), (and CL:$amt, 31)), addr:$dst),
3465 (SAR16mCL addr:$dst)>;
3466def : Pat<(store (sra (loadi32 addr:$dst), (and CL:$amt, 31)), addr:$dst),
3467 (SAR32mCL addr:$dst)>;
3468
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003469// (or (x >> c) | (y << (32 - c))) ==> (shrd32 x, y, c)
3470def : Pat<(or (srl GR32:$src1, CL:$amt),
3471 (shl GR32:$src2, (sub 32, CL:$amt))),
3472 (SHRD32rrCL GR32:$src1, GR32:$src2)>;
3473
3474def : Pat<(store (or (srl (loadi32 addr:$dst), CL:$amt),
3475 (shl GR32:$src2, (sub 32, CL:$amt))), addr:$dst),
3476 (SHRD32mrCL addr:$dst, GR32:$src2)>;
3477
Dan Gohman921581d2008-10-17 01:23:35 +00003478def : Pat<(or (srl GR32:$src1, (i8 (trunc ECX:$amt))),
3479 (shl GR32:$src2, (i8 (trunc (sub 32, ECX:$amt))))),
3480 (SHRD32rrCL GR32:$src1, GR32:$src2)>;
3481
3482def : Pat<(store (or (srl (loadi32 addr:$dst), (i8 (trunc ECX:$amt))),
3483 (shl GR32:$src2, (i8 (trunc (sub 32, ECX:$amt))))),
3484 addr:$dst),
3485 (SHRD32mrCL addr:$dst, GR32:$src2)>;
3486
3487def : Pat<(shrd GR32:$src1, (i8 imm:$amt1), GR32:$src2, (i8 imm:$amt2)),
3488 (SHRD32rri8 GR32:$src1, GR32:$src2, (i8 imm:$amt1))>;
3489
3490def : Pat<(store (shrd (loadi32 addr:$dst), (i8 imm:$amt1),
3491 GR32:$src2, (i8 imm:$amt2)), addr:$dst),
3492 (SHRD32mri8 addr:$dst, GR32:$src2, (i8 imm:$amt1))>;
3493
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003494// (or (x << c) | (y >> (32 - c))) ==> (shld32 x, y, c)
3495def : Pat<(or (shl GR32:$src1, CL:$amt),
3496 (srl GR32:$src2, (sub 32, CL:$amt))),
3497 (SHLD32rrCL GR32:$src1, GR32:$src2)>;
3498
3499def : Pat<(store (or (shl (loadi32 addr:$dst), CL:$amt),
3500 (srl GR32:$src2, (sub 32, CL:$amt))), addr:$dst),
3501 (SHLD32mrCL addr:$dst, GR32:$src2)>;
3502
Dan Gohman921581d2008-10-17 01:23:35 +00003503def : Pat<(or (shl GR32:$src1, (i8 (trunc ECX:$amt))),
3504 (srl GR32:$src2, (i8 (trunc (sub 32, ECX:$amt))))),
3505 (SHLD32rrCL GR32:$src1, GR32:$src2)>;
3506
3507def : Pat<(store (or (shl (loadi32 addr:$dst), (i8 (trunc ECX:$amt))),
3508 (srl GR32:$src2, (i8 (trunc (sub 32, ECX:$amt))))),
3509 addr:$dst),
3510 (SHLD32mrCL addr:$dst, GR32:$src2)>;
3511
3512def : Pat<(shld GR32:$src1, (i8 imm:$amt1), GR32:$src2, (i8 imm:$amt2)),
3513 (SHLD32rri8 GR32:$src1, GR32:$src2, (i8 imm:$amt1))>;
3514
3515def : Pat<(store (shld (loadi32 addr:$dst), (i8 imm:$amt1),
3516 GR32:$src2, (i8 imm:$amt2)), addr:$dst),
3517 (SHLD32mri8 addr:$dst, GR32:$src2, (i8 imm:$amt1))>;
3518
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003519// (or (x >> c) | (y << (16 - c))) ==> (shrd16 x, y, c)
3520def : Pat<(or (srl GR16:$src1, CL:$amt),
3521 (shl GR16:$src2, (sub 16, CL:$amt))),
3522 (SHRD16rrCL GR16:$src1, GR16:$src2)>;
3523
3524def : Pat<(store (or (srl (loadi16 addr:$dst), CL:$amt),
3525 (shl GR16:$src2, (sub 16, CL:$amt))), addr:$dst),
3526 (SHRD16mrCL addr:$dst, GR16:$src2)>;
3527
Dan Gohman921581d2008-10-17 01:23:35 +00003528def : Pat<(or (srl GR16:$src1, (i8 (trunc CX:$amt))),
3529 (shl GR16:$src2, (i8 (trunc (sub 16, CX:$amt))))),
3530 (SHRD16rrCL GR16:$src1, GR16:$src2)>;
3531
3532def : Pat<(store (or (srl (loadi16 addr:$dst), (i8 (trunc CX:$amt))),
3533 (shl GR16:$src2, (i8 (trunc (sub 16, CX:$amt))))),
3534 addr:$dst),
3535 (SHRD16mrCL addr:$dst, GR16:$src2)>;
3536
3537def : Pat<(shrd GR16:$src1, (i8 imm:$amt1), GR16:$src2, (i8 imm:$amt2)),
3538 (SHRD16rri8 GR16:$src1, GR16:$src2, (i8 imm:$amt1))>;
3539
3540def : Pat<(store (shrd (loadi16 addr:$dst), (i8 imm:$amt1),
3541 GR16:$src2, (i8 imm:$amt2)), addr:$dst),
3542 (SHRD16mri8 addr:$dst, GR16:$src2, (i8 imm:$amt1))>;
3543
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003544// (or (x << c) | (y >> (16 - c))) ==> (shld16 x, y, c)
3545def : Pat<(or (shl GR16:$src1, CL:$amt),
3546 (srl GR16:$src2, (sub 16, CL:$amt))),
3547 (SHLD16rrCL GR16:$src1, GR16:$src2)>;
3548
3549def : Pat<(store (or (shl (loadi16 addr:$dst), CL:$amt),
3550 (srl GR16:$src2, (sub 16, CL:$amt))), addr:$dst),
3551 (SHLD16mrCL addr:$dst, GR16:$src2)>;
3552
Dan Gohman921581d2008-10-17 01:23:35 +00003553def : Pat<(or (shl GR16:$src1, (i8 (trunc CX:$amt))),
3554 (srl GR16:$src2, (i8 (trunc (sub 16, CX:$amt))))),
3555 (SHLD16rrCL GR16:$src1, GR16:$src2)>;
3556
3557def : Pat<(store (or (shl (loadi16 addr:$dst), (i8 (trunc CX:$amt))),
3558 (srl GR16:$src2, (i8 (trunc (sub 16, CX:$amt))))),
3559 addr:$dst),
3560 (SHLD16mrCL addr:$dst, GR16:$src2)>;
3561
3562def : Pat<(shld GR16:$src1, (i8 imm:$amt1), GR16:$src2, (i8 imm:$amt2)),
3563 (SHLD16rri8 GR16:$src1, GR16:$src2, (i8 imm:$amt1))>;
3564
3565def : Pat<(store (shld (loadi16 addr:$dst), (i8 imm:$amt1),
3566 GR16:$src2, (i8 imm:$amt2)), addr:$dst),
3567 (SHLD16mri8 addr:$dst, GR16:$src2, (i8 imm:$amt1))>;
3568
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003569//===----------------------------------------------------------------------===//
Dan Gohman99a12192009-03-04 19:44:21 +00003570// EFLAGS-defining Patterns
Bill Wendlingf5399032008-12-12 21:15:41 +00003571//===----------------------------------------------------------------------===//
3572
Dan Gohman99a12192009-03-04 19:44:21 +00003573// Register-Register Addition with EFLAGS result
3574def : Pat<(parallel (X86add_flag GR8:$src1, GR8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003575 (implicit EFLAGS)),
3576 (ADD8rr GR8:$src1, GR8:$src2)>;
3577
Dan Gohman99a12192009-03-04 19:44:21 +00003578// Register-Register Addition with EFLAGS result
3579def : Pat<(parallel (X86add_flag GR16:$src1, GR16:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003580 (implicit EFLAGS)),
3581 (ADD16rr GR16:$src1, GR16:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003582def : Pat<(parallel (X86add_flag GR32:$src1, GR32:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003583 (implicit EFLAGS)),
3584 (ADD32rr GR32:$src1, GR32:$src2)>;
3585
Dan Gohman99a12192009-03-04 19:44:21 +00003586// Register-Memory Addition with EFLAGS result
3587def : Pat<(parallel (X86add_flag GR8:$src1, (loadi8 addr:$src2)),
Bill Wendlingf5399032008-12-12 21:15:41 +00003588 (implicit EFLAGS)),
3589 (ADD8rm GR8:$src1, addr:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003590def : Pat<(parallel (X86add_flag GR16:$src1, (loadi16 addr:$src2)),
Bill Wendlingf5399032008-12-12 21:15:41 +00003591 (implicit EFLAGS)),
3592 (ADD16rm GR16:$src1, addr:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003593def : Pat<(parallel (X86add_flag GR32:$src1, (loadi32 addr:$src2)),
Bill Wendlingf5399032008-12-12 21:15:41 +00003594 (implicit EFLAGS)),
3595 (ADD32rm GR32:$src1, addr:$src2)>;
3596
Dan Gohman99a12192009-03-04 19:44:21 +00003597// Register-Integer Addition with EFLAGS result
3598def : Pat<(parallel (X86add_flag GR8:$src1, imm:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003599 (implicit EFLAGS)),
3600 (ADD8ri GR8:$src1, imm:$src2)>;
3601
Dan Gohman99a12192009-03-04 19:44:21 +00003602// Register-Integer Addition with EFLAGS result
3603def : Pat<(parallel (X86add_flag GR16:$src1, imm:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003604 (implicit EFLAGS)),
3605 (ADD16ri GR16:$src1, imm:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003606def : Pat<(parallel (X86add_flag GR32:$src1, imm:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003607 (implicit EFLAGS)),
3608 (ADD32ri GR32:$src1, imm:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003609def : Pat<(parallel (X86add_flag GR16:$src1, i16immSExt8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003610 (implicit EFLAGS)),
3611 (ADD16ri8 GR16:$src1, i16immSExt8:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003612def : Pat<(parallel (X86add_flag GR32:$src1, i32immSExt8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003613 (implicit EFLAGS)),
3614 (ADD32ri8 GR32:$src1, i32immSExt8:$src2)>;
3615
Dan Gohman99a12192009-03-04 19:44:21 +00003616// Memory-Register Addition with EFLAGS result
3617def : Pat<(parallel (store (X86add_flag (loadi8 addr:$dst), GR8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003618 addr:$dst),
3619 (implicit EFLAGS)),
3620 (ADD8mr addr:$dst, GR8:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003621def : Pat<(parallel (store (X86add_flag (loadi16 addr:$dst), GR16:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003622 addr:$dst),
3623 (implicit EFLAGS)),
3624 (ADD16mr addr:$dst, GR16:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003625def : Pat<(parallel (store (X86add_flag (loadi32 addr:$dst), GR32:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003626 addr:$dst),
3627 (implicit EFLAGS)),
3628 (ADD32mr addr:$dst, GR32:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003629def : Pat<(parallel (store (X86add_flag (loadi8 addr:$dst), imm:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003630 addr:$dst),
3631 (implicit EFLAGS)),
3632 (ADD8mi addr:$dst, imm:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003633def : Pat<(parallel (store (X86add_flag (loadi16 addr:$dst), imm:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003634 addr:$dst),
3635 (implicit EFLAGS)),
3636 (ADD16mi addr:$dst, imm:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003637def : Pat<(parallel (store (X86add_flag (loadi32 addr:$dst), imm:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003638 addr:$dst),
3639 (implicit EFLAGS)),
3640 (ADD32mi addr:$dst, imm:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003641def : Pat<(parallel (store (X86add_flag (loadi16 addr:$dst), i16immSExt8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003642 addr:$dst),
3643 (implicit EFLAGS)),
3644 (ADD16mi8 addr:$dst, i16immSExt8:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003645def : Pat<(parallel (store (X86add_flag (loadi32 addr:$dst), i32immSExt8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003646 addr:$dst),
3647 (implicit EFLAGS)),
3648 (ADD32mi8 addr:$dst, i32immSExt8:$src2)>;
3649
Dan Gohman99a12192009-03-04 19:44:21 +00003650// Register-Register Subtraction with EFLAGS result
3651def : Pat<(parallel (X86sub_flag GR8:$src1, GR8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003652 (implicit EFLAGS)),
3653 (SUB8rr GR8:$src1, GR8:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003654def : Pat<(parallel (X86sub_flag GR16:$src1, GR16:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003655 (implicit EFLAGS)),
3656 (SUB16rr GR16:$src1, GR16:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003657def : Pat<(parallel (X86sub_flag GR32:$src1, GR32:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003658 (implicit EFLAGS)),
3659 (SUB32rr GR32:$src1, GR32:$src2)>;
3660
Dan Gohman99a12192009-03-04 19:44:21 +00003661// Register-Memory Subtraction with EFLAGS result
3662def : Pat<(parallel (X86sub_flag GR8:$src1, (loadi8 addr:$src2)),
Bill Wendlingf5399032008-12-12 21:15:41 +00003663 (implicit EFLAGS)),
3664 (SUB8rm GR8:$src1, addr:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003665def : Pat<(parallel (X86sub_flag GR16:$src1, (loadi16 addr:$src2)),
Bill Wendlingf5399032008-12-12 21:15:41 +00003666 (implicit EFLAGS)),
3667 (SUB16rm GR16:$src1, addr:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003668def : Pat<(parallel (X86sub_flag GR32:$src1, (loadi32 addr:$src2)),
Bill Wendlingf5399032008-12-12 21:15:41 +00003669 (implicit EFLAGS)),
3670 (SUB32rm GR32:$src1, addr:$src2)>;
3671
Dan Gohman99a12192009-03-04 19:44:21 +00003672// Register-Integer Subtraction with EFLAGS result
3673def : Pat<(parallel (X86sub_flag GR8:$src1, imm:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003674 (implicit EFLAGS)),
3675 (SUB8ri GR8:$src1, imm:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003676def : Pat<(parallel (X86sub_flag GR16:$src1, imm:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003677 (implicit EFLAGS)),
3678 (SUB16ri GR16:$src1, imm:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003679def : Pat<(parallel (X86sub_flag GR32:$src1, imm:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003680 (implicit EFLAGS)),
3681 (SUB32ri GR32:$src1, imm:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003682def : Pat<(parallel (X86sub_flag GR16:$src1, i16immSExt8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003683 (implicit EFLAGS)),
3684 (SUB16ri8 GR16:$src1, i16immSExt8:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003685def : Pat<(parallel (X86sub_flag GR32:$src1, i32immSExt8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003686 (implicit EFLAGS)),
3687 (SUB32ri8 GR32:$src1, i32immSExt8:$src2)>;
3688
Dan Gohman99a12192009-03-04 19:44:21 +00003689// Memory-Register Subtraction with EFLAGS result
3690def : Pat<(parallel (store (X86sub_flag (loadi8 addr:$dst), GR8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003691 addr:$dst),
3692 (implicit EFLAGS)),
3693 (SUB8mr addr:$dst, GR8:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003694def : Pat<(parallel (store (X86sub_flag (loadi16 addr:$dst), GR16:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003695 addr:$dst),
3696 (implicit EFLAGS)),
3697 (SUB16mr addr:$dst, GR16:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003698def : Pat<(parallel (store (X86sub_flag (loadi32 addr:$dst), GR32:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003699 addr:$dst),
3700 (implicit EFLAGS)),
3701 (SUB32mr addr:$dst, GR32:$src2)>;
3702
Dan Gohman99a12192009-03-04 19:44:21 +00003703// Memory-Integer Subtraction with EFLAGS result
3704def : Pat<(parallel (store (X86sub_flag (loadi8 addr:$dst), imm:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003705 addr:$dst),
3706 (implicit EFLAGS)),
3707 (SUB8mi addr:$dst, imm:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003708def : Pat<(parallel (store (X86sub_flag (loadi16 addr:$dst), imm:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003709 addr:$dst),
3710 (implicit EFLAGS)),
3711 (SUB16mi addr:$dst, imm:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003712def : Pat<(parallel (store (X86sub_flag (loadi32 addr:$dst), imm:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003713 addr:$dst),
3714 (implicit EFLAGS)),
3715 (SUB32mi addr:$dst, imm:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003716def : Pat<(parallel (store (X86sub_flag (loadi16 addr:$dst), i16immSExt8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003717 addr:$dst),
3718 (implicit EFLAGS)),
3719 (SUB16mi8 addr:$dst, i16immSExt8:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003720def : Pat<(parallel (store (X86sub_flag (loadi32 addr:$dst), i32immSExt8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003721 addr:$dst),
3722 (implicit EFLAGS)),
3723 (SUB32mi8 addr:$dst, i32immSExt8:$src2)>;
3724
3725
Dan Gohman99a12192009-03-04 19:44:21 +00003726// Register-Register Signed Integer Multiply with EFLAGS result
3727def : Pat<(parallel (X86smul_flag GR16:$src1, GR16:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003728 (implicit EFLAGS)),
3729 (IMUL16rr GR16:$src1, GR16:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003730def : Pat<(parallel (X86smul_flag GR32:$src1, GR32:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003731 (implicit EFLAGS)),
3732 (IMUL32rr GR32:$src1, GR32:$src2)>;
3733
Dan Gohman99a12192009-03-04 19:44:21 +00003734// Register-Memory Signed Integer Multiply with EFLAGS result
3735def : Pat<(parallel (X86smul_flag GR16:$src1, (loadi16 addr:$src2)),
Bill Wendlingf5399032008-12-12 21:15:41 +00003736 (implicit EFLAGS)),
3737 (IMUL16rm GR16:$src1, addr:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003738def : Pat<(parallel (X86smul_flag GR32:$src1, (loadi32 addr:$src2)),
Bill Wendlingf5399032008-12-12 21:15:41 +00003739 (implicit EFLAGS)),
3740 (IMUL32rm GR32:$src1, addr:$src2)>;
3741
Dan Gohman99a12192009-03-04 19:44:21 +00003742// Register-Integer Signed Integer Multiply with EFLAGS result
3743def : Pat<(parallel (X86smul_flag GR16:$src1, imm:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003744 (implicit EFLAGS)),
3745 (IMUL16rri GR16:$src1, imm:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003746def : Pat<(parallel (X86smul_flag GR32:$src1, imm:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003747 (implicit EFLAGS)),
3748 (IMUL32rri GR32:$src1, imm:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003749def : Pat<(parallel (X86smul_flag GR16:$src1, i16immSExt8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003750 (implicit EFLAGS)),
3751 (IMUL16rri8 GR16:$src1, i16immSExt8:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003752def : Pat<(parallel (X86smul_flag GR32:$src1, i32immSExt8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003753 (implicit EFLAGS)),
3754 (IMUL32rri8 GR32:$src1, i32immSExt8:$src2)>;
3755
Dan Gohman99a12192009-03-04 19:44:21 +00003756// Memory-Integer Signed Integer Multiply with EFLAGS result
3757def : Pat<(parallel (X86smul_flag (loadi16 addr:$src1), imm:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003758 (implicit EFLAGS)),
3759 (IMUL16rmi addr:$src1, imm:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003760def : Pat<(parallel (X86smul_flag (loadi32 addr:$src1), imm:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003761 (implicit EFLAGS)),
3762 (IMUL32rmi addr:$src1, imm:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003763def : Pat<(parallel (X86smul_flag (loadi16 addr:$src1), i16immSExt8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003764 (implicit EFLAGS)),
3765 (IMUL16rmi8 addr:$src1, i16immSExt8:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003766def : Pat<(parallel (X86smul_flag (loadi32 addr:$src1), i32immSExt8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003767 (implicit EFLAGS)),
3768 (IMUL32rmi8 addr:$src1, i32immSExt8:$src2)>;
3769
Dan Gohman99a12192009-03-04 19:44:21 +00003770// Optimize multiply by 2 with EFLAGS result.
Evan Cheng00cf7932009-01-27 03:30:42 +00003771let AddedComplexity = 2 in {
Dan Gohman99a12192009-03-04 19:44:21 +00003772def : Pat<(parallel (X86smul_flag GR16:$src1, 2),
Evan Cheng00cf7932009-01-27 03:30:42 +00003773 (implicit EFLAGS)),
3774 (ADD16rr GR16:$src1, GR16:$src1)>;
3775
Dan Gohman99a12192009-03-04 19:44:21 +00003776def : Pat<(parallel (X86smul_flag GR32:$src1, 2),
Evan Cheng00cf7932009-01-27 03:30:42 +00003777 (implicit EFLAGS)),
3778 (ADD32rr GR32:$src1, GR32:$src1)>;
3779}
3780
Dan Gohman99a12192009-03-04 19:44:21 +00003781// INC and DEC with EFLAGS result. Note that these do not set CF.
3782def : Pat<(parallel (X86inc_flag GR8:$src), (implicit EFLAGS)),
3783 (INC8r GR8:$src)>;
3784def : Pat<(parallel (store (i8 (X86inc_flag (loadi8 addr:$dst))), addr:$dst),
3785 (implicit EFLAGS)),
3786 (INC8m addr:$dst)>;
3787def : Pat<(parallel (X86dec_flag GR8:$src), (implicit EFLAGS)),
3788 (DEC8r GR8:$src)>;
3789def : Pat<(parallel (store (i8 (X86dec_flag (loadi8 addr:$dst))), addr:$dst),
3790 (implicit EFLAGS)),
3791 (DEC8m addr:$dst)>;
3792
3793def : Pat<(parallel (X86inc_flag GR16:$src), (implicit EFLAGS)),
Dan Gohmaneebcac72009-03-05 21:32:23 +00003794 (INC16r GR16:$src)>, Requires<[In32BitMode]>;
Dan Gohman99a12192009-03-04 19:44:21 +00003795def : Pat<(parallel (store (i16 (X86inc_flag (loadi16 addr:$dst))), addr:$dst),
3796 (implicit EFLAGS)),
Dan Gohmaneebcac72009-03-05 21:32:23 +00003797 (INC16m addr:$dst)>, Requires<[In32BitMode]>;
Dan Gohman99a12192009-03-04 19:44:21 +00003798def : Pat<(parallel (X86dec_flag GR16:$src), (implicit EFLAGS)),
Dan Gohmaneebcac72009-03-05 21:32:23 +00003799 (DEC16r GR16:$src)>, Requires<[In32BitMode]>;
Dan Gohman99a12192009-03-04 19:44:21 +00003800def : Pat<(parallel (store (i16 (X86dec_flag (loadi16 addr:$dst))), addr:$dst),
3801 (implicit EFLAGS)),
Dan Gohmaneebcac72009-03-05 21:32:23 +00003802 (DEC16m addr:$dst)>, Requires<[In32BitMode]>;
Dan Gohman99a12192009-03-04 19:44:21 +00003803
3804def : Pat<(parallel (X86inc_flag GR32:$src), (implicit EFLAGS)),
Dan Gohmaneebcac72009-03-05 21:32:23 +00003805 (INC32r GR32:$src)>, Requires<[In32BitMode]>;
Dan Gohman99a12192009-03-04 19:44:21 +00003806def : Pat<(parallel (store (i32 (X86inc_flag (loadi32 addr:$dst))), addr:$dst),
3807 (implicit EFLAGS)),
Dan Gohmaneebcac72009-03-05 21:32:23 +00003808 (INC32m addr:$dst)>, Requires<[In32BitMode]>;
Dan Gohman99a12192009-03-04 19:44:21 +00003809def : Pat<(parallel (X86dec_flag GR32:$src), (implicit EFLAGS)),
Dan Gohmaneebcac72009-03-05 21:32:23 +00003810 (DEC32r GR32:$src)>, Requires<[In32BitMode]>;
Dan Gohman99a12192009-03-04 19:44:21 +00003811def : Pat<(parallel (store (i32 (X86dec_flag (loadi32 addr:$dst))), addr:$dst),
3812 (implicit EFLAGS)),
Dan Gohmaneebcac72009-03-05 21:32:23 +00003813 (DEC32m addr:$dst)>, Requires<[In32BitMode]>;
Dan Gohman99a12192009-03-04 19:44:21 +00003814
Bill Wendlingf5399032008-12-12 21:15:41 +00003815//===----------------------------------------------------------------------===//
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003816// Floating Point Stack Support
3817//===----------------------------------------------------------------------===//
3818
3819include "X86InstrFPStack.td"
3820
3821//===----------------------------------------------------------------------===//
Evan Cheng86ab7d32007-07-31 08:04:03 +00003822// X86-64 Support
3823//===----------------------------------------------------------------------===//
3824
Chris Lattner2de8d2b2008-01-10 05:50:42 +00003825include "X86Instr64bit.td"
Evan Cheng86ab7d32007-07-31 08:04:03 +00003826
3827//===----------------------------------------------------------------------===//
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003828// XMM Floating point support (requires SSE / SSE2)
3829//===----------------------------------------------------------------------===//
3830
3831include "X86InstrSSE.td"
Evan Cheng5e4d1e72008-04-25 18:19:54 +00003832
3833//===----------------------------------------------------------------------===//
3834// MMX and XMM Packed Integer support (requires MMX, SSE, and SSE2)
3835//===----------------------------------------------------------------------===//
3836
3837include "X86InstrMMX.td"