blob: c4db58829086bc04c575e227940f3d23e1d0ca37 [file] [log] [blame]
Arnold Schwaighofer48abc5c2007-10-12 21:30:57 +00001//===- X86InstrInfo.td - Describe the X86 Instruction Set --*- tablegen -*-===//
John Criswell856ba762003-10-21 15:17:13 +00002//
3// The LLVM Compiler Infrastructure
4//
Chris Lattner4ee451d2007-12-29 20:36:04 +00005// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
John Criswell856ba762003-10-21 15:17:13 +00007//
8//===----------------------------------------------------------------------===//
Chris Lattner1cca5e32003-08-03 21:54:21 +00009//
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
Evan Chengaed7c722005-12-17 01:24:02 +000016//===----------------------------------------------------------------------===//
17// X86 specific DAG Nodes.
18//
19
Evan Chenge3413162006-01-09 18:33:28 +000020def SDTIntShiftDOp: SDTypeProfile<1, 3,
21 [SDTCisSameAs<0, 1>, SDTCisSameAs<0, 2>,
22 SDTCisInt<0>, SDTCisInt<3>]>;
23
Evan Cheng71fb9ad2006-01-26 00:29:36 +000024def SDTX86CmpTest : SDTypeProfile<0, 2, [SDTCisSameAs<0, 1>]>;
Evan Chengaed7c722005-12-17 01:24:02 +000025
Evan Chenge5f62042007-09-29 00:00:36 +000026def SDTX86Cmov : SDTypeProfile<1, 4,
Evan Cheng0488db92007-09-25 01:57:46 +000027 [SDTCisSameAs<0, 1>, SDTCisSameAs<1, 2>,
28 SDTCisVT<3, i8>, SDTCisVT<4, i32>]>;
Evan Chengaed7c722005-12-17 01:24:02 +000029
Evan Chenge5f62042007-09-29 00:00:36 +000030def SDTX86BrCond : SDTypeProfile<0, 3,
Evan Cheng0488db92007-09-25 01:57:46 +000031 [SDTCisVT<0, OtherVT>,
32 SDTCisVT<1, i8>, SDTCisVT<2, i32>]>;
Evan Chengaed7c722005-12-17 01:24:02 +000033
Evan Chenge5f62042007-09-29 00:00:36 +000034def SDTX86SetCC : SDTypeProfile<1, 2,
Evan Cheng0488db92007-09-25 01:57:46 +000035 [SDTCisVT<0, i8>,
36 SDTCisVT<1, i8>, SDTCisVT<2, i32>]>;
Evan Chengd5781fc2005-12-21 20:21:51 +000037
Andrew Lenharth26ed8692008-03-01 21:52:34 +000038def SDTX86cas : SDTypeProfile<0, 3, [SDTCisPtrTy<0>, SDTCisInt<1>,
39 SDTCisVT<2, i8>]>;
Andrew Lenharthd19189e2008-03-05 01:15:49 +000040def SDTX86cas8 : SDTypeProfile<0, 1, [SDTCisPtrTy<0>]>;
Andrew Lenharth26ed8692008-03-01 21:52:34 +000041
Chris Lattner447ff682008-03-11 03:23:40 +000042def SDTX86Ret : SDTypeProfile<0, -1, [SDTCisVT<0, i16>]>;
Evan Cheng898101c2005-12-19 23:12:38 +000043
Bill Wendlingc69107c2007-11-13 09:19:02 +000044def SDT_X86CallSeqStart : SDCallSeqStart<[ SDTCisVT<0, i32> ]>;
45def SDT_X86CallSeqEnd : SDCallSeqEnd<[ SDTCisVT<0, i32>,
46 SDTCisVT<1, i32> ]>;
Evan Chenge3413162006-01-09 18:33:28 +000047
Dan Gohmand35121a2008-05-29 19:57:41 +000048def SDT_X86Call : SDTypeProfile<0, -1, [SDTCisVT<0, iPTR>]>;
Evan Chenge3413162006-01-09 18:33:28 +000049
Evan Cheng67f92a72006-01-11 22:15:48 +000050def SDTX86RepStr : SDTypeProfile<0, 1, [SDTCisVT<0, OtherVT>]>;
51
Evan Chenge3413162006-01-09 18:33:28 +000052def SDTX86RdTsc : SDTypeProfile<0, 0, []>;
Evan Chengd90eb7f2006-01-05 00:27:02 +000053
Evan Cheng71fb8342006-02-25 10:02:21 +000054def SDTX86Wrapper : SDTypeProfile<1, 1, [SDTCisSameAs<0, 1>, SDTCisPtrTy<0>]>;
55
Lauro Ramos Venanciob3a04172007-04-20 21:38:10 +000056def SDT_X86TLSADDR : SDTypeProfile<1, 1, [SDTCisPtrTy<0>, SDTCisInt<1>]>;
57
58def SDT_X86TLSTP : SDTypeProfile<1, 0, [SDTCisPtrTy<0>]>;
59
Anton Korobeynikov2365f512007-07-14 14:06:15 +000060def SDT_X86EHRET : SDTypeProfile<0, 1, [SDTCisInt<0>]>;
61
Arnold Schwaighoferc85e1712007-10-11 19:40:01 +000062def SDT_X86TCRET : SDTypeProfile<0, 2, [SDTCisPtrTy<0>, SDTCisVT<1, i32>]>;
63
Evan Cheng18efe262007-12-14 02:13:44 +000064def X86bsf : SDNode<"X86ISD::BSF", SDTIntUnaryOp>;
65def X86bsr : SDNode<"X86ISD::BSR", SDTIntUnaryOp>;
Evan Chenge3413162006-01-09 18:33:28 +000066def X86shld : SDNode<"X86ISD::SHLD", SDTIntShiftDOp>;
67def X86shrd : SDNode<"X86ISD::SHRD", SDTIntShiftDOp>;
Evan Chengb077b842005-12-21 02:39:21 +000068
Evan Chenge5f62042007-09-29 00:00:36 +000069def X86cmp : SDNode<"X86ISD::CMP" , SDTX86CmpTest>;
Evan Chengb077b842005-12-21 02:39:21 +000070
Evan Chenge5f62042007-09-29 00:00:36 +000071def X86cmov : SDNode<"X86ISD::CMOV", SDTX86Cmov>;
Evan Chenge3413162006-01-09 18:33:28 +000072def X86brcond : SDNode<"X86ISD::BRCOND", SDTX86BrCond,
Evan Cheng0488db92007-09-25 01:57:46 +000073 [SDNPHasChain]>;
Evan Chenge5f62042007-09-29 00:00:36 +000074def X86setcc : SDNode<"X86ISD::SETCC", SDTX86SetCC>;
Evan Chengb077b842005-12-21 02:39:21 +000075
Andrew Lenharth26ed8692008-03-01 21:52:34 +000076def X86cas : SDNode<"X86ISD::LCMPXCHG_DAG", SDTX86cas,
77 [SDNPHasChain, SDNPInFlag, SDNPOutFlag, SDNPMayStore,
78 SDNPMayLoad]>;
Andrew Lenharthd19189e2008-03-05 01:15:49 +000079def X86cas8 : SDNode<"X86ISD::LCMPXCHG8_DAG", SDTX86cas8,
80 [SDNPHasChain, SDNPInFlag, SDNPOutFlag, SDNPMayStore,
81 SDNPMayLoad]>;
Andrew Lenharth26ed8692008-03-01 21:52:34 +000082
Evan Chenge3413162006-01-09 18:33:28 +000083def X86retflag : SDNode<"X86ISD::RET_FLAG", SDTX86Ret,
84 [SDNPHasChain, SDNPOptInFlag]>;
Evan Chengb077b842005-12-21 02:39:21 +000085
Evan Chenge3413162006-01-09 18:33:28 +000086def X86callseq_start :
87 SDNode<"ISD::CALLSEQ_START", SDT_X86CallSeqStart,
Evan Chengbb7b8442006-08-11 09:03:33 +000088 [SDNPHasChain, SDNPOutFlag]>;
Evan Chenge3413162006-01-09 18:33:28 +000089def X86callseq_end :
90 SDNode<"ISD::CALLSEQ_END", SDT_X86CallSeqEnd,
Arnold Schwaighoferc85e1712007-10-11 19:40:01 +000091 [SDNPHasChain, SDNPOptInFlag, SDNPOutFlag]>;
Evan Chengb077b842005-12-21 02:39:21 +000092
Evan Chenge3413162006-01-09 18:33:28 +000093def X86call : SDNode<"X86ISD::CALL", SDT_X86Call,
94 [SDNPHasChain, SDNPOutFlag, SDNPOptInFlag]>;
Evan Chengaed7c722005-12-17 01:24:02 +000095
Evan Chengfb914c42006-05-20 01:40:16 +000096def X86tailcall: SDNode<"X86ISD::TAILCALL", SDT_X86Call,
Evan Chengfea89c12006-04-27 08:40:39 +000097 [SDNPHasChain, SDNPOutFlag, SDNPOptInFlag]>;
98
Evan Cheng67f92a72006-01-11 22:15:48 +000099def X86rep_stos: SDNode<"X86ISD::REP_STOS", SDTX86RepStr,
Chris Lattner9b37aaf2008-01-10 05:12:37 +0000100 [SDNPHasChain, SDNPInFlag, SDNPOutFlag, SDNPMayStore]>;
Evan Cheng67f92a72006-01-11 22:15:48 +0000101def X86rep_movs: SDNode<"X86ISD::REP_MOVS", SDTX86RepStr,
Chris Lattner9b37aaf2008-01-10 05:12:37 +0000102 [SDNPHasChain, SDNPInFlag, SDNPOutFlag, SDNPMayStore,
103 SDNPMayLoad]>;
Evan Cheng67f92a72006-01-11 22:15:48 +0000104
Evan Chenge3413162006-01-09 18:33:28 +0000105def X86rdtsc : SDNode<"X86ISD::RDTSC_DAG",SDTX86RdTsc,
Chris Lattnerba7e7562008-01-10 07:59:24 +0000106 [SDNPHasChain, SDNPOutFlag, SDNPSideEffect]>;
Evan Chengd90eb7f2006-01-05 00:27:02 +0000107
Evan Cheng0085a282006-11-30 21:55:46 +0000108def X86Wrapper : SDNode<"X86ISD::Wrapper", SDTX86Wrapper>;
109def X86WrapperRIP : SDNode<"X86ISD::WrapperRIP", SDTX86Wrapper>;
Evan Cheng71fb8342006-02-25 10:02:21 +0000110
Lauro Ramos Venanciob3a04172007-04-20 21:38:10 +0000111def X86tlsaddr : SDNode<"X86ISD::TLSADDR", SDT_X86TLSADDR,
Anton Korobeynikov6625eff2008-05-04 21:36:32 +0000112 [SDNPHasChain, SDNPOptInFlag, SDNPOutFlag]>;
Lauro Ramos Venanciob3a04172007-04-20 21:38:10 +0000113def X86TLStp : SDNode<"X86ISD::THREAD_POINTER", SDT_X86TLSTP, []>;
114
Anton Korobeynikov2365f512007-07-14 14:06:15 +0000115def X86ehret : SDNode<"X86ISD::EH_RETURN", SDT_X86EHRET,
116 [SDNPHasChain]>;
117
Arnold Schwaighoferc85e1712007-10-11 19:40:01 +0000118def X86tcret : SDNode<"X86ISD::TC_RETURN", SDT_X86TCRET,
119 [SDNPHasChain, SDNPOptInFlag]>;
Lauro Ramos Venanciob3a04172007-04-20 21:38:10 +0000120
Evan Chengaed7c722005-12-17 01:24:02 +0000121//===----------------------------------------------------------------------===//
122// X86 Operand Definitions.
123//
124
Chris Lattner66fa1dc2004-08-11 02:25:00 +0000125// *mem - Operand definitions for the funky X86 addressing mode operands.
126//
Evan Chengaf78ef52006-05-17 21:21:41 +0000127class X86MemOperand<string printMethod> : Operand<iPTR> {
Nate Begeman391c5d22005-11-30 18:54:35 +0000128 let PrintMethod = printMethod;
Evan Cheng25ab6902006-09-08 06:48:29 +0000129 let MIOperandInfo = (ops ptr_rc, i8imm, ptr_rc, i32imm);
Chris Lattner66fa1dc2004-08-11 02:25:00 +0000130}
Nate Begeman391c5d22005-11-30 18:54:35 +0000131
Chris Lattner45432512005-12-17 19:47:05 +0000132def i8mem : X86MemOperand<"printi8mem">;
133def i16mem : X86MemOperand<"printi16mem">;
134def i32mem : X86MemOperand<"printi32mem">;
135def i64mem : X86MemOperand<"printi64mem">;
Evan Cheng470a6ad2006-02-22 02:26:30 +0000136def i128mem : X86MemOperand<"printi128mem">;
Chris Lattner45432512005-12-17 19:47:05 +0000137def f32mem : X86MemOperand<"printf32mem">;
138def f64mem : X86MemOperand<"printf64mem">;
Dale Johannesen59a58732007-08-05 18:49:15 +0000139def f80mem : X86MemOperand<"printf80mem">;
Evan Cheng223547a2006-01-31 22:28:30 +0000140def f128mem : X86MemOperand<"printf128mem">;
Nate Begeman391c5d22005-11-30 18:54:35 +0000141
Evan Cheng25ab6902006-09-08 06:48:29 +0000142def lea32mem : Operand<i32> {
143 let PrintMethod = "printi32mem";
Evan Cheng25ab6902006-09-08 06:48:29 +0000144 let MIOperandInfo = (ops GR32, i8imm, GR32, i32imm);
145}
146
Nate Begeman16b04f32005-07-15 00:38:55 +0000147def SSECC : Operand<i8> {
148 let PrintMethod = "printSSECC";
149}
Chris Lattner66fa1dc2004-08-11 02:25:00 +0000150
Evan Cheng7ccced62006-02-18 00:15:05 +0000151def piclabel: Operand<i32> {
152 let PrintMethod = "printPICLabel";
153}
154
Chris Lattnerf124d5e2005-11-18 01:04:42 +0000155// A couple of more descriptive operand definitions.
156// 16-bits but only 8 bits are significant.
157def i16i8imm : Operand<i16>;
158// 32-bits but only 8 bits are significant.
159def i32i8imm : Operand<i32>;
160
Evan Chengd35b8c12005-12-04 08:19:43 +0000161// Branch targets have OtherVT type.
162def brtarget : Operand<OtherVT>;
163
Evan Chengaed7c722005-12-17 01:24:02 +0000164//===----------------------------------------------------------------------===//
165// X86 Complex Pattern Definitions.
166//
167
Evan Chengec693f72005-12-08 02:01:35 +0000168// Define X86 specific addressing mode.
Evan Chengaf9db752006-10-11 21:03:53 +0000169def addr : ComplexPattern<iPTR, 4, "SelectAddr", [], []>;
Evan Cheng25ab6902006-09-08 06:48:29 +0000170def lea32addr : ComplexPattern<i32, 4, "SelectLEAAddr",
Evan Chengaf9db752006-10-11 21:03:53 +0000171 [add, mul, shl, or, frameindex], []>;
Evan Chengec693f72005-12-08 02:01:35 +0000172
Evan Chengaed7c722005-12-17 01:24:02 +0000173//===----------------------------------------------------------------------===//
Evan Chengbbc8ddb2005-12-20 22:59:51 +0000174// X86 Instruction Predicate Definitions.
Evan Cheng28b514392006-12-05 19:50:18 +0000175def HasMMX : Predicate<"Subtarget->hasMMX()">;
176def HasSSE1 : Predicate<"Subtarget->hasSSE1()">;
177def HasSSE2 : Predicate<"Subtarget->hasSSE2()">;
178def HasSSE3 : Predicate<"Subtarget->hasSSE3()">;
Bill Wendlingbb1ee052007-04-10 22:10:25 +0000179def HasSSSE3 : Predicate<"Subtarget->hasSSSE3()">;
Nate Begeman63ec90a2008-02-03 07:18:54 +0000180def HasSSE41 : Predicate<"Subtarget->hasSSE41()">;
181def HasSSE42 : Predicate<"Subtarget->hasSSE42()">;
Dale Johannesenf1fc3a82007-09-23 14:52:20 +0000182def FPStackf32 : Predicate<"!Subtarget->hasSSE1()">;
183def FPStackf64 : Predicate<"!Subtarget->hasSSE2()">;
Evan Cheng28b514392006-12-05 19:50:18 +0000184def In32BitMode : Predicate<"!Subtarget->is64Bit()">;
185def In64BitMode : Predicate<"Subtarget->is64Bit()">;
186def SmallCode : Predicate<"TM.getCodeModel() == CodeModel::Small">;
187def NotSmallCode : Predicate<"TM.getCodeModel() != CodeModel::Small">;
188def IsStatic : Predicate<"TM.getRelocationModel() == Reloc::Static">;
Evan Chengbbc8ddb2005-12-20 22:59:51 +0000189
190//===----------------------------------------------------------------------===//
Evan Chengc64a1a92007-07-31 08:04:03 +0000191// X86 Instruction Format Definitions.
Evan Chengaed7c722005-12-17 01:24:02 +0000192//
193
Evan Chengc64a1a92007-07-31 08:04:03 +0000194include "X86InstrFormats.td"
Chris Lattner1cca5e32003-08-03 21:54:21 +0000195
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +0000196//===----------------------------------------------------------------------===//
Chris Lattnerf124d5e2005-11-18 01:04:42 +0000197// Pattern fragments...
198//
Evan Chengd9558e02006-01-06 00:43:03 +0000199
200// X86 specific condition code. These correspond to CondCode in
Nate Begeman9a225302007-05-06 04:00:55 +0000201// X86InstrInfo.h. They must be kept in synch.
Evan Chengd9558e02006-01-06 00:43:03 +0000202def X86_COND_A : PatLeaf<(i8 0)>;
203def X86_COND_AE : PatLeaf<(i8 1)>;
204def X86_COND_B : PatLeaf<(i8 2)>;
205def X86_COND_BE : PatLeaf<(i8 3)>;
206def X86_COND_E : PatLeaf<(i8 4)>;
207def X86_COND_G : PatLeaf<(i8 5)>;
208def X86_COND_GE : PatLeaf<(i8 6)>;
209def X86_COND_L : PatLeaf<(i8 7)>;
210def X86_COND_LE : PatLeaf<(i8 8)>;
211def X86_COND_NE : PatLeaf<(i8 9)>;
212def X86_COND_NO : PatLeaf<(i8 10)>;
213def X86_COND_NP : PatLeaf<(i8 11)>;
214def X86_COND_NS : PatLeaf<(i8 12)>;
215def X86_COND_O : PatLeaf<(i8 13)>;
216def X86_COND_P : PatLeaf<(i8 14)>;
217def X86_COND_S : PatLeaf<(i8 15)>;
218
Evan Cheng9b6b6422005-12-13 00:14:11 +0000219def i16immSExt8 : PatLeaf<(i16 imm), [{
220 // i16immSExt8 predicate - True if the 16-bit immediate fits in a 8-bit
Evan Chengb3558542005-12-13 00:01:09 +0000221 // sign extended field.
Evan Cheng09e3c802006-05-19 18:40:54 +0000222 return (int16_t)N->getValue() == (int8_t)N->getValue();
Chris Lattnerf124d5e2005-11-18 01:04:42 +0000223}]>;
224
Evan Cheng9b6b6422005-12-13 00:14:11 +0000225def i32immSExt8 : PatLeaf<(i32 imm), [{
226 // i32immSExt8 predicate - True if the 32-bit immediate fits in a 8-bit
Evan Chengb3558542005-12-13 00:01:09 +0000227 // sign extended field.
Evan Cheng09e3c802006-05-19 18:40:54 +0000228 return (int32_t)N->getValue() == (int8_t)N->getValue();
Evan Chengb3558542005-12-13 00:01:09 +0000229}]>;
230
Evan Cheng605c4152005-12-13 01:57:51 +0000231// Helper fragments for loads.
Evan Chengb6564432008-05-13 18:59:59 +0000232// It's always safe to treat a anyext i16 load as a i32 load if the i16 is
233// known to be 32-bit aligned or better. Ditto for i8 to i16.
Evan Chengfa7fd332008-05-13 00:54:02 +0000234def loadi16 : PatFrag<(ops node:$ptr), (i16 (ld node:$ptr)), [{
235 if (LoadSDNode *LD = dyn_cast<LoadSDNode>(N)) {
236 if (LD->getAddressingMode() != ISD::UNINDEXED)
237 return false;
238 ISD::LoadExtType ExtType = LD->getExtensionType();
239 if (ExtType == ISD::NON_EXTLOAD)
240 return true;
241 if (ExtType == ISD::EXTLOAD)
Evan Cheng6bf87702008-05-14 02:49:43 +0000242 return LD->getAlignment() >= 2 && !LD->isVolatile();
Evan Chengfa7fd332008-05-13 00:54:02 +0000243 }
244 return false;
245}]>;
246
247def loadi32 : PatFrag<(ops node:$ptr), (i32 (ld node:$ptr)), [{
248 if (LoadSDNode *LD = dyn_cast<LoadSDNode>(N)) {
249 if (LD->getAddressingMode() != ISD::UNINDEXED)
250 return false;
251 ISD::LoadExtType ExtType = LD->getExtensionType();
252 if (ExtType == ISD::NON_EXTLOAD)
253 return true;
254 if (ExtType == ISD::EXTLOAD)
Evan Cheng6bf87702008-05-14 02:49:43 +0000255 return LD->getAlignment() >= 4 && !LD->isVolatile();
Evan Chengfa7fd332008-05-13 00:54:02 +0000256 }
257 return false;
258}]>;
259
Evan Cheng7a7e8372005-12-14 02:22:27 +0000260def loadi8 : PatFrag<(ops node:$ptr), (i8 (load node:$ptr))>;
Evan Cheng11e15b32006-04-03 20:53:28 +0000261def loadi64 : PatFrag<(ops node:$ptr), (i64 (load node:$ptr))>;
Evan Cheng06a8aa12006-03-17 19:55:52 +0000262
Evan Chengbbc8ddb2005-12-20 22:59:51 +0000263def loadf32 : PatFrag<(ops node:$ptr), (f32 (load node:$ptr))>;
264def loadf64 : PatFrag<(ops node:$ptr), (f64 (load node:$ptr))>;
Dale Johannesen59a58732007-08-05 18:49:15 +0000265def loadf80 : PatFrag<(ops node:$ptr), (f80 (load node:$ptr))>;
Evan Cheng7a7e8372005-12-14 02:22:27 +0000266
Evan Cheng466685d2006-10-09 20:57:25 +0000267def sextloadi16i8 : PatFrag<(ops node:$ptr), (i16 (sextloadi8 node:$ptr))>;
268def sextloadi32i8 : PatFrag<(ops node:$ptr), (i32 (sextloadi8 node:$ptr))>;
269def sextloadi32i16 : PatFrag<(ops node:$ptr), (i32 (sextloadi16 node:$ptr))>;
Evan Cheng7a7e8372005-12-14 02:22:27 +0000270
Evan Cheng466685d2006-10-09 20:57:25 +0000271def zextloadi8i1 : PatFrag<(ops node:$ptr), (i8 (zextloadi1 node:$ptr))>;
272def zextloadi16i1 : PatFrag<(ops node:$ptr), (i16 (zextloadi1 node:$ptr))>;
273def zextloadi32i1 : PatFrag<(ops node:$ptr), (i32 (zextloadi1 node:$ptr))>;
274def zextloadi16i8 : PatFrag<(ops node:$ptr), (i16 (zextloadi8 node:$ptr))>;
275def zextloadi32i8 : PatFrag<(ops node:$ptr), (i32 (zextloadi8 node:$ptr))>;
276def zextloadi32i16 : PatFrag<(ops node:$ptr), (i32 (zextloadi16 node:$ptr))>;
Evan Cheng7a7e8372005-12-14 02:22:27 +0000277
Evan Cheng466685d2006-10-09 20:57:25 +0000278def extloadi8i1 : PatFrag<(ops node:$ptr), (i8 (extloadi1 node:$ptr))>;
279def extloadi16i1 : PatFrag<(ops node:$ptr), (i16 (extloadi1 node:$ptr))>;
280def extloadi32i1 : PatFrag<(ops node:$ptr), (i32 (extloadi1 node:$ptr))>;
281def extloadi16i8 : PatFrag<(ops node:$ptr), (i16 (extloadi8 node:$ptr))>;
282def extloadi32i8 : PatFrag<(ops node:$ptr), (i32 (extloadi8 node:$ptr))>;
283def extloadi32i16 : PatFrag<(ops node:$ptr), (i32 (extloadi16 node:$ptr))>;
Evan Cheng747a90d2006-02-21 02:24:38 +0000284
Chris Lattnerce2bcc82008-02-19 17:37:35 +0000285
286// An 'and' node with a single use.
287def and_su : PatFrag<(ops node:$lhs, node:$rhs), (and node:$lhs, node:$rhs), [{
Evan Cheng07b7ea12008-03-04 00:40:35 +0000288 return N->hasOneUse();
Chris Lattnerce2bcc82008-02-19 17:37:35 +0000289}]>;
290
Chris Lattnerf124d5e2005-11-18 01:04:42 +0000291//===----------------------------------------------------------------------===//
Chris Lattner1cca5e32003-08-03 21:54:21 +0000292// Instruction list...
293//
294
Chris Lattnerf18c0742006-10-12 17:42:56 +0000295// ADJCALLSTACKDOWN/UP implicitly use/def ESP because they may be expanded into
296// a stack adjustment and the codegen must know that they may modify the stack
297// pointer before prolog-epilog rewriting occurs.
Chris Lattner447ff682008-03-11 03:23:40 +0000298// Pessimistically assume ADJCALLSTACKDOWN / ADJCALLSTACKUP will become
299// sub / add which can clobber EFLAGS.
Evan Cheng8decf6b2007-09-28 01:19:48 +0000300let Defs = [ESP, EFLAGS], Uses = [ESP] in {
Bill Wendling0f8d9c02007-11-13 00:44:25 +0000301def ADJCALLSTACKDOWN : I<0, Pseudo, (outs), (ins i32imm:$amt),
302 "#ADJCALLSTACKDOWN",
Evan Cheng071a2792007-09-11 19:55:27 +0000303 [(X86callseq_start imm:$amt)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +0000304def ADJCALLSTACKUP : I<0, Pseudo, (outs), (ins i32imm:$amt1, i32imm:$amt2),
Evan Chengd90eb7f2006-01-05 00:27:02 +0000305 "#ADJCALLSTACKUP",
Evan Cheng071a2792007-09-11 19:55:27 +0000306 [(X86callseq_end imm:$amt1, imm:$amt2)]>;
307}
Evan Cheng4a460802006-01-11 00:33:36 +0000308
309// Nop
Chris Lattnerba7e7562008-01-10 07:59:24 +0000310let neverHasSideEffects = 1 in
311 def NOOP : I<0x90, RawFrm, (outs), (ins), "nop", []>;
Evan Cheng4a460802006-01-11 00:33:36 +0000312
Evan Cheng0475ab52008-01-05 00:41:47 +0000313// PIC base
Chris Lattnerba7e7562008-01-10 07:59:24 +0000314let neverHasSideEffects = 1, isNotDuplicable = 1 in
315 def MOVPC32r : Ii32<0xE8, Pseudo, (outs GR32:$reg), (ins piclabel:$label),
316 "call\t$label\n\tpop{l}\t$reg", []>;
Evan Cheng8f7f7122006-05-05 05:40:20 +0000317
Chris Lattner1cca5e32003-08-03 21:54:21 +0000318//===----------------------------------------------------------------------===//
319// Control Flow Instructions...
320//
321
Chris Lattner1be48112005-05-13 17:56:48 +0000322// Return instructions.
Evan Cheng2b4ea792005-12-26 09:11:45 +0000323let isTerminator = 1, isReturn = 1, isBarrier = 1,
Chris Lattner447ff682008-03-11 03:23:40 +0000324 hasCtrlDep = 1, FPForm = SpecialFP, FPFormBits = SpecialFP.Value in {
Dan Gohmane4c67cd2008-05-31 02:11:25 +0000325 def RET : I <0xC3, RawFrm, (outs), (ins variable_ops),
Chris Lattner447ff682008-03-11 03:23:40 +0000326 "ret",
Dan Gohmane4c67cd2008-05-31 02:11:25 +0000327 [(X86retflag 0)]>;
Chris Lattner447ff682008-03-11 03:23:40 +0000328 def RETI : Ii16<0xC2, RawFrm, (outs), (ins i16imm:$amt, variable_ops),
329 "ret\t$amt",
Evan Chenge3413162006-01-09 18:33:28 +0000330 [(X86retflag imm:$amt)]>;
Evan Cheng171049d2005-12-23 22:14:32 +0000331}
Chris Lattner1cca5e32003-08-03 21:54:21 +0000332
333// All branches are RawFrm, Void, Branch, and Terminators
Evan Chengffbacca2007-07-21 00:34:19 +0000334let isBranch = 1, isTerminator = 1 in
Evan Cheng64d80e32007-07-19 01:14:50 +0000335 class IBr<bits<8> opcode, dag ins, string asm, list<dag> pattern> :
336 I<opcode, RawFrm, (outs), ins, asm, pattern>;
Chris Lattner1cca5e32003-08-03 21:54:21 +0000337
Evan Chengec3bc392006-09-07 19:03:48 +0000338let isBranch = 1, isBarrier = 1 in
Dan Gohmanb1576f52007-07-31 20:11:57 +0000339 def JMP : IBr<0xE9, (ins brtarget:$dst), "jmp\t$dst", [(br bb:$dst)]>;
Evan Cheng898101c2005-12-19 23:12:38 +0000340
Owen Anderson20ab2902007-11-12 07:39:39 +0000341// Indirect branches
342let isBranch = 1, isTerminator = 1, isBarrier = 1, isIndirectBranch = 1 in {
Dan Gohmanb1576f52007-07-31 20:11:57 +0000343 def JMP32r : I<0xFF, MRM4r, (outs), (ins GR32:$dst), "jmp{l}\t{*}$dst",
Evan Cheng069287d2006-05-16 07:21:53 +0000344 [(brind GR32:$dst)]>;
Dan Gohmanb1576f52007-07-31 20:11:57 +0000345 def JMP32m : I<0xFF, MRM4m, (outs), (ins i32mem:$dst), "jmp{l}\t{*}$dst",
Evan Cheng25ab6902006-09-08 06:48:29 +0000346 [(brind (loadi32 addr:$dst))]>;
Nate Begeman37efe672006-04-22 18:53:45 +0000347}
348
349// Conditional branches
Evan Cheng0488db92007-09-25 01:57:46 +0000350let Uses = [EFLAGS] in {
Dan Gohmanb1576f52007-07-31 20:11:57 +0000351def JE : IBr<0x84, (ins brtarget:$dst), "je\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +0000352 [(X86brcond bb:$dst, X86_COND_E, EFLAGS)]>, TB;
Dan Gohmanb1576f52007-07-31 20:11:57 +0000353def JNE : IBr<0x85, (ins brtarget:$dst), "jne\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +0000354 [(X86brcond bb:$dst, X86_COND_NE, EFLAGS)]>, TB;
Dan Gohmanb1576f52007-07-31 20:11:57 +0000355def JL : IBr<0x8C, (ins brtarget:$dst), "jl\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +0000356 [(X86brcond bb:$dst, X86_COND_L, EFLAGS)]>, TB;
Dan Gohmanb1576f52007-07-31 20:11:57 +0000357def JLE : IBr<0x8E, (ins brtarget:$dst), "jle\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +0000358 [(X86brcond bb:$dst, X86_COND_LE, EFLAGS)]>, TB;
Dan Gohmanb1576f52007-07-31 20:11:57 +0000359def JG : IBr<0x8F, (ins brtarget:$dst), "jg\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +0000360 [(X86brcond bb:$dst, X86_COND_G, EFLAGS)]>, TB;
Dan Gohmanb1576f52007-07-31 20:11:57 +0000361def JGE : IBr<0x8D, (ins brtarget:$dst), "jge\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +0000362 [(X86brcond bb:$dst, X86_COND_GE, EFLAGS)]>, TB;
Evan Cheng898101c2005-12-19 23:12:38 +0000363
Dan Gohmanb1576f52007-07-31 20:11:57 +0000364def JB : IBr<0x82, (ins brtarget:$dst), "jb\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +0000365 [(X86brcond bb:$dst, X86_COND_B, EFLAGS)]>, TB;
Dan Gohmanb1576f52007-07-31 20:11:57 +0000366def JBE : IBr<0x86, (ins brtarget:$dst), "jbe\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +0000367 [(X86brcond bb:$dst, X86_COND_BE, EFLAGS)]>, TB;
Dan Gohmanb1576f52007-07-31 20:11:57 +0000368def JA : IBr<0x87, (ins brtarget:$dst), "ja\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +0000369 [(X86brcond bb:$dst, X86_COND_A, EFLAGS)]>, TB;
Dan Gohmanb1576f52007-07-31 20:11:57 +0000370def JAE : IBr<0x83, (ins brtarget:$dst), "jae\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +0000371 [(X86brcond bb:$dst, X86_COND_AE, EFLAGS)]>, TB;
Evan Cheng898101c2005-12-19 23:12:38 +0000372
Dan Gohmanb1576f52007-07-31 20:11:57 +0000373def JS : IBr<0x88, (ins brtarget:$dst), "js\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +0000374 [(X86brcond bb:$dst, X86_COND_S, EFLAGS)]>, TB;
Dan Gohmanb1576f52007-07-31 20:11:57 +0000375def JNS : IBr<0x89, (ins brtarget:$dst), "jns\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +0000376 [(X86brcond bb:$dst, X86_COND_NS, EFLAGS)]>, TB;
Dan Gohmanb1576f52007-07-31 20:11:57 +0000377def JP : IBr<0x8A, (ins brtarget:$dst), "jp\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +0000378 [(X86brcond bb:$dst, X86_COND_P, EFLAGS)]>, TB;
Dan Gohmanb1576f52007-07-31 20:11:57 +0000379def JNP : IBr<0x8B, (ins brtarget:$dst), "jnp\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +0000380 [(X86brcond bb:$dst, X86_COND_NP, EFLAGS)]>, TB;
Dan Gohmanb1576f52007-07-31 20:11:57 +0000381def JO : IBr<0x80, (ins brtarget:$dst), "jo\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +0000382 [(X86brcond bb:$dst, X86_COND_O, EFLAGS)]>, TB;
Dan Gohmanb1576f52007-07-31 20:11:57 +0000383def JNO : IBr<0x81, (ins brtarget:$dst), "jno\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +0000384 [(X86brcond bb:$dst, X86_COND_NO, EFLAGS)]>, TB;
Evan Cheng0488db92007-09-25 01:57:46 +0000385} // Uses = [EFLAGS]
Chris Lattner1cca5e32003-08-03 21:54:21 +0000386
387//===----------------------------------------------------------------------===//
388// Call Instructions...
389//
Evan Chengffbacca2007-07-21 00:34:19 +0000390let isCall = 1 in
Chris Lattner1cca5e32003-08-03 21:54:21 +0000391 // All calls clobber the non-callee saved registers...
Nate Begemanf63be7d2005-07-06 18:59:04 +0000392 let Defs = [EAX, ECX, EDX, FP0, FP1, FP2, FP3, FP4, FP5, FP6, ST0,
Bill Wendling3f3a17d2007-04-25 21:31:48 +0000393 MM0, MM1, MM2, MM3, MM4, MM5, MM6, MM7,
Evan Cheng0488db92007-09-25 01:57:46 +0000394 XMM0, XMM1, XMM2, XMM3, XMM4, XMM5, XMM6, XMM7, EFLAGS] in {
Evan Chengf02ca692007-12-22 02:26:46 +0000395 def CALLpcrel32 : Ii32<0xE8, RawFrm, (outs), (ins i32imm:$dst,variable_ops),
396 "call\t${dst:call}", []>;
Evan Cheng64d80e32007-07-19 01:14:50 +0000397 def CALL32r : I<0xFF, MRM2r, (outs), (ins GR32:$dst, variable_ops),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000398 "call\t{*}$dst", [(X86call GR32:$dst)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +0000399 def CALL32m : I<0xFF, MRM2m, (outs), (ins i32mem:$dst, variable_ops),
Dan Gohmanb4106172008-05-29 21:50:34 +0000400 "call\t{*}$dst", [(X86call (loadi32 addr:$dst))]>;
Chris Lattner1cca5e32003-08-03 21:54:21 +0000401 }
402
Chris Lattner1e9448b2005-05-15 03:10:37 +0000403// Tail call stuff.
Arnold Schwaighoferc85e1712007-10-11 19:40:01 +0000404
Chris Lattner447ff682008-03-11 03:23:40 +0000405def TAILCALL : I<0, Pseudo, (outs), (ins),
Arnold Schwaighoferc85e1712007-10-11 19:40:01 +0000406 "#TAILCALL",
407 []>;
408
Evan Chengffbacca2007-07-21 00:34:19 +0000409let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1 in
Arnold Schwaighofer4fe30732008-03-19 16:39:45 +0000410def TCRETURNdi : I<0, Pseudo, (outs), (ins i32imm:$dst, i32imm:$offset, variable_ops),
Arnold Schwaighoferc85e1712007-10-11 19:40:01 +0000411 "#TC_RETURN $dst $offset",
412 []>;
413
414let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1 in
Arnold Schwaighofer4fe30732008-03-19 16:39:45 +0000415def TCRETURNri : I<0, Pseudo, (outs), (ins GR32:$dst, i32imm:$offset, variable_ops),
Arnold Schwaighoferc85e1712007-10-11 19:40:01 +0000416 "#TC_RETURN $dst $offset",
417 []>;
418
419let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1 in
Arnold Schwaighofer30e62c02008-04-30 09:16:33 +0000420
Arnold Schwaighoferc85e1712007-10-11 19:40:01 +0000421 def TAILJMPd : IBr<0xE9, (ins i32imm:$dst), "jmp\t${dst:call} # TAILCALL",
Evan Chengf10c17f2006-09-22 21:43:59 +0000422 []>;
Evan Chengffbacca2007-07-21 00:34:19 +0000423let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1 in
Arnold Schwaighoferc85e1712007-10-11 19:40:01 +0000424 def TAILJMPr : I<0xFF, MRM4r, (outs), (ins GR32:$dst), "jmp{l}\t{*}$dst # TAILCALL",
425 []>;
Evan Chengffbacca2007-07-21 00:34:19 +0000426let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1 in
Evan Cheng64d80e32007-07-19 01:14:50 +0000427 def TAILJMPm : I<0xFF, MRM4m, (outs), (ins i32mem:$dst),
Arnold Schwaighoferc85e1712007-10-11 19:40:01 +0000428 "jmp\t{*}$dst # TAILCALL", []>;
Chris Lattner1e9448b2005-05-15 03:10:37 +0000429
Chris Lattner1cca5e32003-08-03 21:54:21 +0000430//===----------------------------------------------------------------------===//
431// Miscellaneous Instructions...
432//
Chris Lattnerba7e7562008-01-10 07:59:24 +0000433let Defs = [EBP, ESP], Uses = [EBP, ESP], mayLoad = 1, neverHasSideEffects=1 in
Chris Lattner30bf2d82004-08-10 20:17:41 +0000434def LEAVE : I<0xC9, RawFrm,
Evan Cheng071a2792007-09-11 19:55:27 +0000435 (outs), (ins), "leave", []>;
436
Chris Lattnerba7e7562008-01-10 07:59:24 +0000437let Defs = [ESP], Uses = [ESP], neverHasSideEffects=1 in {
438let mayLoad = 1 in
Evan Cheng2f245ba2007-09-26 01:29:06 +0000439def POP32r : I<0x58, AddRegFrm, (outs GR32:$reg), (ins), "pop{l}\t$reg", []>;
Chris Lattner1cca5e32003-08-03 21:54:21 +0000440
Chris Lattnerba7e7562008-01-10 07:59:24 +0000441let mayStore = 1 in
Evan Cheng2f245ba2007-09-26 01:29:06 +0000442def PUSH32r : I<0x50, AddRegFrm, (outs), (ins GR32:$reg), "push{l}\t$reg",[]>;
Evan Cheng071a2792007-09-11 19:55:27 +0000443}
Anton Korobeynikov57fc00d2007-04-17 09:20:00 +0000444
Chris Lattnerba7e7562008-01-10 07:59:24 +0000445let Defs = [ESP, EFLAGS], Uses = [ESP], mayLoad = 1, neverHasSideEffects=1 in
Evan Chengbf4f89d2007-09-26 21:28:00 +0000446def POPFD : I<0x9D, RawFrm, (outs), (ins), "popf", []>;
Chris Lattnerba7e7562008-01-10 07:59:24 +0000447let Defs = [ESP], Uses = [ESP, EFLAGS], mayStore = 1, neverHasSideEffects=1 in
Evan Chengbf4f89d2007-09-26 21:28:00 +0000448def PUSHFD : I<0x9C, RawFrm, (outs), (ins), "pushf", []>;
Evan Cheng2f245ba2007-09-26 01:29:06 +0000449
Evan Cheng069287d2006-05-16 07:21:53 +0000450let isTwoAddress = 1 in // GR32 = bswap GR32
Chris Lattner30bf2d82004-08-10 20:17:41 +0000451 def BSWAP32r : I<0xC8, AddRegFrm,
Evan Cheng64d80e32007-07-19 01:14:50 +0000452 (outs GR32:$dst), (ins GR32:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000453 "bswap{l}\t$dst",
Evan Cheng069287d2006-05-16 07:21:53 +0000454 [(set GR32:$dst, (bswap GR32:$src))]>, TB;
Chris Lattner1cca5e32003-08-03 21:54:21 +0000455
Chris Lattner1cca5e32003-08-03 21:54:21 +0000456
Evan Cheng18efe262007-12-14 02:13:44 +0000457// Bit scan instructions.
458let Defs = [EFLAGS] in {
Evan Chengfd9e4732007-12-14 18:49:43 +0000459def BSF16rr : I<0xBC, MRMSrcReg, (outs GR16:$dst), (ins GR16:$src),
Dan Gohman1a8001e2007-12-14 15:10:00 +0000460 "bsf{w}\t{$src, $dst|$dst, $src}",
Evan Cheng152804e2007-12-14 08:30:15 +0000461 [(set GR16:$dst, (X86bsf GR16:$src)), (implicit EFLAGS)]>, TB;
Evan Cheng18efe262007-12-14 02:13:44 +0000462def BSF16rm : I<0xBC, MRMSrcMem, (outs GR16:$dst), (ins i16mem:$src),
Dan Gohman1a8001e2007-12-14 15:10:00 +0000463 "bsf{w}\t{$src, $dst|$dst, $src}",
Evan Cheng152804e2007-12-14 08:30:15 +0000464 [(set GR16:$dst, (X86bsf (loadi16 addr:$src))),
465 (implicit EFLAGS)]>, TB;
Evan Chengfd9e4732007-12-14 18:49:43 +0000466def BSF32rr : I<0xBC, MRMSrcReg, (outs GR32:$dst), (ins GR32:$src),
Dan Gohman1a8001e2007-12-14 15:10:00 +0000467 "bsf{l}\t{$src, $dst|$dst, $src}",
Evan Cheng152804e2007-12-14 08:30:15 +0000468 [(set GR32:$dst, (X86bsf GR32:$src)), (implicit EFLAGS)]>, TB;
Evan Cheng18efe262007-12-14 02:13:44 +0000469def BSF32rm : I<0xBC, MRMSrcMem, (outs GR32:$dst), (ins i32mem:$src),
Dan Gohman1a8001e2007-12-14 15:10:00 +0000470 "bsf{l}\t{$src, $dst|$dst, $src}",
Evan Cheng152804e2007-12-14 08:30:15 +0000471 [(set GR32:$dst, (X86bsf (loadi32 addr:$src))),
472 (implicit EFLAGS)]>, TB;
Evan Cheng18efe262007-12-14 02:13:44 +0000473
Evan Chengfd9e4732007-12-14 18:49:43 +0000474def BSR16rr : I<0xBD, MRMSrcReg, (outs GR16:$dst), (ins GR16:$src),
Dan Gohman1a8001e2007-12-14 15:10:00 +0000475 "bsr{w}\t{$src, $dst|$dst, $src}",
Evan Cheng152804e2007-12-14 08:30:15 +0000476 [(set GR16:$dst, (X86bsr GR16:$src)), (implicit EFLAGS)]>, TB;
Evan Cheng18efe262007-12-14 02:13:44 +0000477def BSR16rm : I<0xBD, MRMSrcMem, (outs GR16:$dst), (ins i16mem:$src),
Dan Gohman1a8001e2007-12-14 15:10:00 +0000478 "bsr{w}\t{$src, $dst|$dst, $src}",
Evan Cheng152804e2007-12-14 08:30:15 +0000479 [(set GR16:$dst, (X86bsr (loadi16 addr:$src))),
480 (implicit EFLAGS)]>, TB;
Evan Chengfd9e4732007-12-14 18:49:43 +0000481def BSR32rr : I<0xBD, MRMSrcReg, (outs GR32:$dst), (ins GR32:$src),
Dan Gohman1a8001e2007-12-14 15:10:00 +0000482 "bsr{l}\t{$src, $dst|$dst, $src}",
Evan Cheng152804e2007-12-14 08:30:15 +0000483 [(set GR32:$dst, (X86bsr GR32:$src)), (implicit EFLAGS)]>, TB;
Evan Cheng18efe262007-12-14 02:13:44 +0000484def BSR32rm : I<0xBD, MRMSrcMem, (outs GR32:$dst), (ins i32mem:$src),
Dan Gohman1a8001e2007-12-14 15:10:00 +0000485 "bsr{l}\t{$src, $dst|$dst, $src}",
Evan Cheng152804e2007-12-14 08:30:15 +0000486 [(set GR32:$dst, (X86bsr (loadi32 addr:$src))),
487 (implicit EFLAGS)]>, TB;
Evan Cheng18efe262007-12-14 02:13:44 +0000488} // Defs = [EFLAGS]
489
Chris Lattnerba7e7562008-01-10 07:59:24 +0000490let neverHasSideEffects = 1 in
Chris Lattner3a173df2004-10-03 20:35:00 +0000491def LEA16r : I<0x8D, MRMSrcMem,
Evan Cheng64d80e32007-07-19 01:14:50 +0000492 (outs GR16:$dst), (ins i32mem:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000493 "lea{w}\t{$src|$dst}, {$dst|$src}", []>, OpSize;
Evan Chenge771ebd2008-03-27 01:41:09 +0000494let isReMaterializable = 1 in
Chris Lattner3a173df2004-10-03 20:35:00 +0000495def LEA32r : I<0x8D, MRMSrcMem,
Evan Cheng64d80e32007-07-19 01:14:50 +0000496 (outs GR32:$dst), (ins lea32mem:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000497 "lea{l}\t{$src|$dst}, {$dst|$src}",
Evan Cheng25ab6902006-09-08 06:48:29 +0000498 [(set GR32:$dst, lea32addr:$src)]>, Requires<[In32BitMode]>;
Chris Lattner1cca5e32003-08-03 21:54:21 +0000499
Evan Cheng071a2792007-09-11 19:55:27 +0000500let Defs = [ECX,EDI,ESI], Uses = [ECX,EDI,ESI] in {
Evan Cheng64d80e32007-07-19 01:14:50 +0000501def REP_MOVSB : I<0xA4, RawFrm, (outs), (ins), "{rep;movsb|rep movsb}",
Evan Cheng071a2792007-09-11 19:55:27 +0000502 [(X86rep_movs i8)]>, REP;
Evan Cheng64d80e32007-07-19 01:14:50 +0000503def REP_MOVSW : I<0xA5, RawFrm, (outs), (ins), "{rep;movsw|rep movsw}",
Evan Cheng071a2792007-09-11 19:55:27 +0000504 [(X86rep_movs i16)]>, REP, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +0000505def REP_MOVSD : I<0xA5, RawFrm, (outs), (ins), "{rep;movsl|rep movsd}",
Evan Cheng071a2792007-09-11 19:55:27 +0000506 [(X86rep_movs i32)]>, REP;
507}
Chris Lattner915e5e52004-02-12 17:53:22 +0000508
Evan Cheng071a2792007-09-11 19:55:27 +0000509let Defs = [ECX,EDI], Uses = [AL,ECX,EDI] in
Evan Cheng64d80e32007-07-19 01:14:50 +0000510def REP_STOSB : I<0xAA, RawFrm, (outs), (ins), "{rep;stosb|rep stosb}",
Evan Cheng071a2792007-09-11 19:55:27 +0000511 [(X86rep_stos i8)]>, REP;
512let Defs = [ECX,EDI], Uses = [AX,ECX,EDI] in
Evan Cheng64d80e32007-07-19 01:14:50 +0000513def REP_STOSW : I<0xAB, RawFrm, (outs), (ins), "{rep;stosw|rep stosw}",
Evan Cheng071a2792007-09-11 19:55:27 +0000514 [(X86rep_stos i16)]>, REP, OpSize;
515let Defs = [ECX,EDI], Uses = [EAX,ECX,EDI] in
Evan Cheng64d80e32007-07-19 01:14:50 +0000516def REP_STOSD : I<0xAB, RawFrm, (outs), (ins), "{rep;stosl|rep stosd}",
Evan Cheng071a2792007-09-11 19:55:27 +0000517 [(X86rep_stos i32)]>, REP;
Chris Lattner30bf2d82004-08-10 20:17:41 +0000518
Evan Cheng071a2792007-09-11 19:55:27 +0000519let Defs = [RAX, RDX] in
Evan Cheng64d80e32007-07-19 01:14:50 +0000520def RDTSC : I<0x31, RawFrm, (outs), (ins), "rdtsc", [(X86rdtsc)]>,
Evan Cheng071a2792007-09-11 19:55:27 +0000521 TB;
Chris Lattnerb89abef2004-02-14 04:45:37 +0000522
Anton Korobeynikov66fac792008-01-15 07:02:33 +0000523let isBarrier = 1, hasCtrlDep = 1 in {
Chris Lattnerda68d302008-01-15 21:58:22 +0000524def TRAP : I<0x0B, RawFrm, (outs), (ins), "ud2", [(trap)]>, TB;
Anton Korobeynikov66fac792008-01-15 07:02:33 +0000525}
526
Chris Lattner1cca5e32003-08-03 21:54:21 +0000527//===----------------------------------------------------------------------===//
John Criswell4ffff9e2004-04-08 20:31:47 +0000528// Input/Output Instructions...
529//
Evan Cheng071a2792007-09-11 19:55:27 +0000530let Defs = [AL], Uses = [DX] in
Evan Cheng64d80e32007-07-19 01:14:50 +0000531def IN8rr : I<0xEC, RawFrm, (outs), (ins),
Evan Cheng071a2792007-09-11 19:55:27 +0000532 "in{b}\t{%dx, %al|%AL, %DX}", []>;
533let Defs = [AX], Uses = [DX] in
Evan Cheng64d80e32007-07-19 01:14:50 +0000534def IN16rr : I<0xED, RawFrm, (outs), (ins),
Evan Cheng071a2792007-09-11 19:55:27 +0000535 "in{w}\t{%dx, %ax|%AX, %DX}", []>, OpSize;
536let Defs = [EAX], Uses = [DX] in
Evan Cheng64d80e32007-07-19 01:14:50 +0000537def IN32rr : I<0xED, RawFrm, (outs), (ins),
Evan Cheng071a2792007-09-11 19:55:27 +0000538 "in{l}\t{%dx, %eax|%EAX, %DX}", []>;
John Criswell4ffff9e2004-04-08 20:31:47 +0000539
Evan Cheng071a2792007-09-11 19:55:27 +0000540let Defs = [AL] in
Evan Cheng64d80e32007-07-19 01:14:50 +0000541def IN8ri : Ii8<0xE4, RawFrm, (outs), (ins i16i8imm:$port),
Evan Cheng071a2792007-09-11 19:55:27 +0000542 "in{b}\t{$port, %al|%AL, $port}", []>;
543let Defs = [AX] in
Evan Cheng64d80e32007-07-19 01:14:50 +0000544def IN16ri : Ii8<0xE5, RawFrm, (outs), (ins i16i8imm:$port),
Evan Cheng071a2792007-09-11 19:55:27 +0000545 "in{w}\t{$port, %ax|%AX, $port}", []>, OpSize;
546let Defs = [EAX] in
Evan Cheng64d80e32007-07-19 01:14:50 +0000547def IN32ri : Ii8<0xE5, RawFrm, (outs), (ins i16i8imm:$port),
Evan Cheng071a2792007-09-11 19:55:27 +0000548 "in{l}\t{$port, %eax|%EAX, $port}", []>;
Chris Lattner440bbc22004-04-13 17:19:31 +0000549
Evan Cheng071a2792007-09-11 19:55:27 +0000550let Uses = [DX, AL] in
Evan Cheng64d80e32007-07-19 01:14:50 +0000551def OUT8rr : I<0xEE, RawFrm, (outs), (ins),
Evan Cheng071a2792007-09-11 19:55:27 +0000552 "out{b}\t{%al, %dx|%DX, %AL}", []>;
553let Uses = [DX, AX] in
Evan Cheng64d80e32007-07-19 01:14:50 +0000554def OUT16rr : I<0xEF, RawFrm, (outs), (ins),
Evan Cheng071a2792007-09-11 19:55:27 +0000555 "out{w}\t{%ax, %dx|%DX, %AX}", []>, OpSize;
556let Uses = [DX, EAX] in
Evan Cheng64d80e32007-07-19 01:14:50 +0000557def OUT32rr : I<0xEF, RawFrm, (outs), (ins),
Evan Cheng071a2792007-09-11 19:55:27 +0000558 "out{l}\t{%eax, %dx|%DX, %EAX}", []>;
Chris Lattnerffff7082004-08-01 07:44:35 +0000559
Evan Cheng071a2792007-09-11 19:55:27 +0000560let Uses = [AL] in
Evan Cheng64d80e32007-07-19 01:14:50 +0000561def OUT8ir : Ii8<0xE6, RawFrm, (outs), (ins i16i8imm:$port),
Evan Cheng071a2792007-09-11 19:55:27 +0000562 "out{b}\t{%al, $port|$port, %AL}", []>;
563let Uses = [AX] in
Evan Cheng64d80e32007-07-19 01:14:50 +0000564def OUT16ir : Ii8<0xE7, RawFrm, (outs), (ins i16i8imm:$port),
Evan Cheng071a2792007-09-11 19:55:27 +0000565 "out{w}\t{%ax, $port|$port, %AX}", []>, OpSize;
566let Uses = [EAX] in
Evan Cheng64d80e32007-07-19 01:14:50 +0000567def OUT32ir : Ii8<0xE7, RawFrm, (outs), (ins i16i8imm:$port),
Evan Cheng071a2792007-09-11 19:55:27 +0000568 "out{l}\t{%eax, $port|$port, %EAX}", []>;
John Criswell4ffff9e2004-04-08 20:31:47 +0000569
570//===----------------------------------------------------------------------===//
Chris Lattner1cca5e32003-08-03 21:54:21 +0000571// Move Instructions...
572//
Chris Lattnerba7e7562008-01-10 07:59:24 +0000573let neverHasSideEffects = 1 in {
Evan Cheng64d80e32007-07-19 01:14:50 +0000574def MOV8rr : I<0x88, MRMDestReg, (outs GR8 :$dst), (ins GR8 :$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000575 "mov{b}\t{$src, $dst|$dst, $src}", []>;
Evan Cheng64d80e32007-07-19 01:14:50 +0000576def MOV16rr : I<0x89, MRMDestReg, (outs GR16:$dst), (ins GR16:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000577 "mov{w}\t{$src, $dst|$dst, $src}", []>, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +0000578def MOV32rr : I<0x89, MRMDestReg, (outs GR32:$dst), (ins GR32:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000579 "mov{l}\t{$src, $dst|$dst, $src}", []>;
Chris Lattnerba7e7562008-01-10 07:59:24 +0000580}
Evan Cheng359e9372008-06-18 08:13:07 +0000581let isReMaterializable = 1, isAsCheapAsAMove = 1 in {
Evan Cheng64d80e32007-07-19 01:14:50 +0000582def MOV8ri : Ii8 <0xB0, AddRegFrm, (outs GR8 :$dst), (ins i8imm :$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000583 "mov{b}\t{$src, $dst|$dst, $src}",
Evan Cheng069287d2006-05-16 07:21:53 +0000584 [(set GR8:$dst, imm:$src)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +0000585def MOV16ri : Ii16<0xB8, AddRegFrm, (outs GR16:$dst), (ins i16imm:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000586 "mov{w}\t{$src, $dst|$dst, $src}",
Evan Cheng069287d2006-05-16 07:21:53 +0000587 [(set GR16:$dst, imm:$src)]>, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +0000588def MOV32ri : Ii32<0xB8, AddRegFrm, (outs GR32:$dst), (ins i32imm:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000589 "mov{l}\t{$src, $dst|$dst, $src}",
Evan Cheng069287d2006-05-16 07:21:53 +0000590 [(set GR32:$dst, imm:$src)]>;
Dan Gohmand45eddd2007-06-26 00:48:07 +0000591}
Evan Cheng64d80e32007-07-19 01:14:50 +0000592def MOV8mi : Ii8 <0xC6, MRM0m, (outs), (ins i8mem :$dst, i8imm :$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000593 "mov{b}\t{$src, $dst|$dst, $src}",
Evan Chengb51a0592005-12-10 00:48:20 +0000594 [(store (i8 imm:$src), addr:$dst)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +0000595def MOV16mi : Ii16<0xC7, MRM0m, (outs), (ins i16mem:$dst, i16imm:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000596 "mov{w}\t{$src, $dst|$dst, $src}",
Evan Chengb51a0592005-12-10 00:48:20 +0000597 [(store (i16 imm:$src), addr:$dst)]>, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +0000598def MOV32mi : Ii32<0xC7, MRM0m, (outs), (ins i32mem:$dst, i32imm:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000599 "mov{l}\t{$src, $dst|$dst, $src}",
Evan Chengb51a0592005-12-10 00:48:20 +0000600 [(store (i32 imm:$src), addr:$dst)]>;
Chris Lattner1cca5e32003-08-03 21:54:21 +0000601
Chris Lattner834f1ce2008-01-06 23:38:27 +0000602let isSimpleLoad = 1, isReMaterializable = 1, mayHaveSideEffects = 1 in {
Evan Cheng64d80e32007-07-19 01:14:50 +0000603def MOV8rm : I<0x8A, MRMSrcMem, (outs GR8 :$dst), (ins i8mem :$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000604 "mov{b}\t{$src, $dst|$dst, $src}",
Evan Cheng069287d2006-05-16 07:21:53 +0000605 [(set GR8:$dst, (load addr:$src))]>;
Evan Cheng64d80e32007-07-19 01:14:50 +0000606def MOV16rm : I<0x8B, MRMSrcMem, (outs GR16:$dst), (ins i16mem:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000607 "mov{w}\t{$src, $dst|$dst, $src}",
Evan Cheng069287d2006-05-16 07:21:53 +0000608 [(set GR16:$dst, (load addr:$src))]>, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +0000609def MOV32rm : I<0x8B, MRMSrcMem, (outs GR32:$dst), (ins i32mem:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000610 "mov{l}\t{$src, $dst|$dst, $src}",
Evan Cheng069287d2006-05-16 07:21:53 +0000611 [(set GR32:$dst, (load addr:$src))]>;
Evan Cheng2f394262007-08-30 05:49:43 +0000612}
Chris Lattner1cca5e32003-08-03 21:54:21 +0000613
Evan Cheng64d80e32007-07-19 01:14:50 +0000614def MOV8mr : I<0x88, MRMDestMem, (outs), (ins i8mem :$dst, GR8 :$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000615 "mov{b}\t{$src, $dst|$dst, $src}",
Evan Cheng069287d2006-05-16 07:21:53 +0000616 [(store GR8:$src, addr:$dst)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +0000617def MOV16mr : I<0x89, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000618 "mov{w}\t{$src, $dst|$dst, $src}",
Evan Cheng069287d2006-05-16 07:21:53 +0000619 [(store GR16:$src, addr:$dst)]>, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +0000620def MOV32mr : I<0x89, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000621 "mov{l}\t{$src, $dst|$dst, $src}",
Evan Cheng069287d2006-05-16 07:21:53 +0000622 [(store GR32:$src, addr:$dst)]>;
Nate Begemanf1702ac2005-06-27 21:20:31 +0000623
Chris Lattner1cca5e32003-08-03 21:54:21 +0000624//===----------------------------------------------------------------------===//
625// Fixed-Register Multiplication and Division Instructions...
626//
Chris Lattner1cca5e32003-08-03 21:54:21 +0000627
Chris Lattnerc8f45872003-08-04 04:59:56 +0000628// Extra precision multiplication
Evan Cheng24f2ea32007-09-14 21:48:26 +0000629let Defs = [AL,AH,EFLAGS], Uses = [AL] in
Dan Gohmanb1576f52007-07-31 20:11:57 +0000630def MUL8r : I<0xF6, MRM4r, (outs), (ins GR8:$src), "mul{b}\t$src",
Evan Chengcf74a7c2006-01-15 10:05:20 +0000631 // FIXME: Used for 8-bit mul, ignore result upper 8 bits.
632 // This probably ought to be moved to a def : Pat<> if the
633 // syntax can be accepted.
Evan Cheng071a2792007-09-11 19:55:27 +0000634 [(set AL, (mul AL, GR8:$src))]>; // AL,AH = AL*GR8
Chris Lattnera731c9f2008-01-11 07:18:17 +0000635let Defs = [AX,DX,EFLAGS], Uses = [AX], neverHasSideEffects = 1 in
Dan Gohmanb1576f52007-07-31 20:11:57 +0000636def MUL16r : I<0xF7, MRM4r, (outs), (ins GR16:$src), "mul{w}\t$src", []>,
Evan Cheng071a2792007-09-11 19:55:27 +0000637 OpSize; // AX,DX = AX*GR16
Chris Lattnera731c9f2008-01-11 07:18:17 +0000638let Defs = [EAX,EDX,EFLAGS], Uses = [EAX], neverHasSideEffects = 1 in
Evan Cheng071a2792007-09-11 19:55:27 +0000639def MUL32r : I<0xF7, MRM4r, (outs), (ins GR32:$src), "mul{l}\t$src", []>;
640 // EAX,EDX = EAX*GR32
Evan Cheng24f2ea32007-09-14 21:48:26 +0000641let Defs = [AL,AH,EFLAGS], Uses = [AL] in
Evan Cheng64d80e32007-07-19 01:14:50 +0000642def MUL8m : I<0xF6, MRM4m, (outs), (ins i8mem :$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000643 "mul{b}\t$src",
Evan Chengcf74a7c2006-01-15 10:05:20 +0000644 // FIXME: Used for 8-bit mul, ignore result upper 8 bits.
645 // This probably ought to be moved to a def : Pat<> if the
646 // syntax can be accepted.
Evan Cheng071a2792007-09-11 19:55:27 +0000647 [(set AL, (mul AL, (loadi8 addr:$src)))]>; // AL,AH = AL*[mem8]
Chris Lattnerba7e7562008-01-10 07:59:24 +0000648let mayLoad = 1, neverHasSideEffects = 1 in {
Evan Cheng24f2ea32007-09-14 21:48:26 +0000649let Defs = [AX,DX,EFLAGS], Uses = [AX] in
Evan Cheng64d80e32007-07-19 01:14:50 +0000650def MUL16m : I<0xF7, MRM4m, (outs), (ins i16mem:$src),
Evan Cheng071a2792007-09-11 19:55:27 +0000651 "mul{w}\t$src", []>, OpSize; // AX,DX = AX*[mem16]
Evan Cheng24f2ea32007-09-14 21:48:26 +0000652let Defs = [EAX,EDX,EFLAGS], Uses = [EAX] in
Evan Cheng64d80e32007-07-19 01:14:50 +0000653def MUL32m : I<0xF7, MRM4m, (outs), (ins i32mem:$src),
Evan Cheng071a2792007-09-11 19:55:27 +0000654 "mul{l}\t$src", []>; // EAX,EDX = EAX*[mem32]
Chris Lattnerba7e7562008-01-10 07:59:24 +0000655}
Chris Lattner1cca5e32003-08-03 21:54:21 +0000656
Chris Lattnerba7e7562008-01-10 07:59:24 +0000657let neverHasSideEffects = 1 in {
Evan Cheng24f2ea32007-09-14 21:48:26 +0000658let Defs = [AL,AH,EFLAGS], Uses = [AL] in
Evan Cheng071a2792007-09-11 19:55:27 +0000659def IMUL8r : I<0xF6, MRM5r, (outs), (ins GR8:$src), "imul{b}\t$src", []>;
660 // AL,AH = AL*GR8
Evan Cheng24f2ea32007-09-14 21:48:26 +0000661let Defs = [AX,DX,EFLAGS], Uses = [AX] in
Dan Gohmanb1576f52007-07-31 20:11:57 +0000662def IMUL16r : I<0xF7, MRM5r, (outs), (ins GR16:$src), "imul{w}\t$src", []>,
Evan Cheng071a2792007-09-11 19:55:27 +0000663 OpSize; // AX,DX = AX*GR16
Evan Cheng24f2ea32007-09-14 21:48:26 +0000664let Defs = [EAX,EDX,EFLAGS], Uses = [EAX] in
Evan Cheng071a2792007-09-11 19:55:27 +0000665def IMUL32r : I<0xF7, MRM5r, (outs), (ins GR32:$src), "imul{l}\t$src", []>;
666 // EAX,EDX = EAX*GR32
Chris Lattnerba7e7562008-01-10 07:59:24 +0000667let mayLoad = 1 in {
Evan Cheng24f2ea32007-09-14 21:48:26 +0000668let Defs = [AL,AH,EFLAGS], Uses = [AL] in
Evan Cheng64d80e32007-07-19 01:14:50 +0000669def IMUL8m : I<0xF6, MRM5m, (outs), (ins i8mem :$src),
Evan Cheng071a2792007-09-11 19:55:27 +0000670 "imul{b}\t$src", []>; // AL,AH = AL*[mem8]
Evan Cheng24f2ea32007-09-14 21:48:26 +0000671let Defs = [AX,DX,EFLAGS], Uses = [AX] in
Evan Cheng64d80e32007-07-19 01:14:50 +0000672def IMUL16m : I<0xF7, MRM5m, (outs), (ins i16mem:$src),
Evan Cheng071a2792007-09-11 19:55:27 +0000673 "imul{w}\t$src", []>, OpSize; // AX,DX = AX*[mem16]
674let Defs = [EAX,EDX], Uses = [EAX] in
Evan Cheng64d80e32007-07-19 01:14:50 +0000675def IMUL32m : I<0xF7, MRM5m, (outs), (ins i32mem:$src),
Evan Cheng071a2792007-09-11 19:55:27 +0000676 "imul{l}\t$src", []>; // EAX,EDX = EAX*[mem32]
Chris Lattnerba7e7562008-01-10 07:59:24 +0000677}
Chris Lattner1e6a7152005-04-06 04:19:22 +0000678
Chris Lattnerc8f45872003-08-04 04:59:56 +0000679// unsigned division/remainder
Evan Cheng24f2ea32007-09-14 21:48:26 +0000680let Defs = [AX,EFLAGS], Uses = [AL,AH] in
Evan Cheng64d80e32007-07-19 01:14:50 +0000681def DIV8r : I<0xF6, MRM6r, (outs), (ins GR8:$src), // AX/r8 = AL,AH
Evan Cheng071a2792007-09-11 19:55:27 +0000682 "div{b}\t$src", []>;
Evan Cheng24f2ea32007-09-14 21:48:26 +0000683let Defs = [AX,DX,EFLAGS], Uses = [AX,DX] in
Evan Cheng64d80e32007-07-19 01:14:50 +0000684def DIV16r : I<0xF7, MRM6r, (outs), (ins GR16:$src), // DX:AX/r16 = AX,DX
Evan Cheng071a2792007-09-11 19:55:27 +0000685 "div{w}\t$src", []>, OpSize;
Evan Cheng24f2ea32007-09-14 21:48:26 +0000686let Defs = [EAX,EDX,EFLAGS], Uses = [EAX,EDX] in
Evan Cheng64d80e32007-07-19 01:14:50 +0000687def DIV32r : I<0xF7, MRM6r, (outs), (ins GR32:$src), // EDX:EAX/r32 = EAX,EDX
Evan Cheng071a2792007-09-11 19:55:27 +0000688 "div{l}\t$src", []>;
Chris Lattnerba7e7562008-01-10 07:59:24 +0000689let mayLoad = 1 in {
Evan Cheng24f2ea32007-09-14 21:48:26 +0000690let Defs = [AX,EFLAGS], Uses = [AL,AH] in
Evan Cheng64d80e32007-07-19 01:14:50 +0000691def DIV8m : I<0xF6, MRM6m, (outs), (ins i8mem:$src), // AX/[mem8] = AL,AH
Evan Cheng071a2792007-09-11 19:55:27 +0000692 "div{b}\t$src", []>;
Evan Cheng24f2ea32007-09-14 21:48:26 +0000693let Defs = [AX,DX,EFLAGS], Uses = [AX,DX] in
Evan Cheng64d80e32007-07-19 01:14:50 +0000694def DIV16m : I<0xF7, MRM6m, (outs), (ins i16mem:$src), // DX:AX/[mem16] = AX,DX
Evan Cheng071a2792007-09-11 19:55:27 +0000695 "div{w}\t$src", []>, OpSize;
Evan Cheng24f2ea32007-09-14 21:48:26 +0000696let Defs = [EAX,EDX,EFLAGS], Uses = [EAX,EDX] in
Evan Cheng64d80e32007-07-19 01:14:50 +0000697def DIV32m : I<0xF7, MRM6m, (outs), (ins i32mem:$src), // EDX:EAX/[mem32] = EAX,EDX
Evan Cheng071a2792007-09-11 19:55:27 +0000698 "div{l}\t$src", []>;
Chris Lattnerba7e7562008-01-10 07:59:24 +0000699}
Chris Lattner1cca5e32003-08-03 21:54:21 +0000700
Chris Lattnerfc752712004-08-01 09:52:59 +0000701// Signed division/remainder.
Evan Cheng24f2ea32007-09-14 21:48:26 +0000702let Defs = [AX,EFLAGS], Uses = [AL,AH] in
Evan Cheng64d80e32007-07-19 01:14:50 +0000703def IDIV8r : I<0xF6, MRM7r, (outs), (ins GR8:$src), // AX/r8 = AL,AH
Evan Cheng071a2792007-09-11 19:55:27 +0000704 "idiv{b}\t$src", []>;
Evan Cheng24f2ea32007-09-14 21:48:26 +0000705let Defs = [AX,DX,EFLAGS], Uses = [AX,DX] in
Evan Cheng64d80e32007-07-19 01:14:50 +0000706def IDIV16r: I<0xF7, MRM7r, (outs), (ins GR16:$src), // DX:AX/r16 = AX,DX
Evan Cheng071a2792007-09-11 19:55:27 +0000707 "idiv{w}\t$src", []>, OpSize;
Evan Cheng24f2ea32007-09-14 21:48:26 +0000708let Defs = [EAX,EDX,EFLAGS], Uses = [EAX,EDX] in
Evan Cheng64d80e32007-07-19 01:14:50 +0000709def IDIV32r: I<0xF7, MRM7r, (outs), (ins GR32:$src), // EDX:EAX/r32 = EAX,EDX
Evan Cheng071a2792007-09-11 19:55:27 +0000710 "idiv{l}\t$src", []>;
Chris Lattnerba7e7562008-01-10 07:59:24 +0000711let mayLoad = 1, mayLoad = 1 in {
Evan Cheng24f2ea32007-09-14 21:48:26 +0000712let Defs = [AX,EFLAGS], Uses = [AL,AH] in
Evan Cheng64d80e32007-07-19 01:14:50 +0000713def IDIV8m : I<0xF6, MRM7m, (outs), (ins i8mem:$src), // AX/[mem8] = AL,AH
Evan Cheng071a2792007-09-11 19:55:27 +0000714 "idiv{b}\t$src", []>;
Evan Cheng24f2ea32007-09-14 21:48:26 +0000715let Defs = [AX,DX,EFLAGS], Uses = [AX,DX] in
Evan Cheng64d80e32007-07-19 01:14:50 +0000716def IDIV16m: I<0xF7, MRM7m, (outs), (ins i16mem:$src), // DX:AX/[mem16] = AX,DX
Evan Cheng071a2792007-09-11 19:55:27 +0000717 "idiv{w}\t$src", []>, OpSize;
Evan Cheng24f2ea32007-09-14 21:48:26 +0000718let Defs = [EAX,EDX,EFLAGS], Uses = [EAX,EDX] in
Evan Cheng64d80e32007-07-19 01:14:50 +0000719def IDIV32m: I<0xF7, MRM7m, (outs), (ins i32mem:$src), // EDX:EAX/[mem32] = EAX,EDX
Evan Cheng071a2792007-09-11 19:55:27 +0000720 "idiv{l}\t$src", []>;
Chris Lattnerba7e7562008-01-10 07:59:24 +0000721}
722} // neverHasSideEffects
Chris Lattner1cca5e32003-08-03 21:54:21 +0000723
Chris Lattner1cca5e32003-08-03 21:54:21 +0000724//===----------------------------------------------------------------------===//
Chris Lattnerba7e7562008-01-10 07:59:24 +0000725// Two address Instructions.
Chris Lattner1cca5e32003-08-03 21:54:21 +0000726//
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +0000727let isTwoAddress = 1 in {
Chris Lattner1cca5e32003-08-03 21:54:21 +0000728
Alkis Evlogimenosa3f66842004-03-12 17:59:56 +0000729// Conditional moves
Evan Cheng0488db92007-09-25 01:57:46 +0000730let Uses = [EFLAGS] in {
Evan Cheng7ad42d92007-10-05 23:13:21 +0000731let isCommutable = 1 in {
Evan Cheng069287d2006-05-16 07:21:53 +0000732def CMOVB16rr : I<0x42, MRMSrcReg, // if <u, GR16 = GR16
Evan Cheng64d80e32007-07-19 01:14:50 +0000733 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000734 "cmovb\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +0000735 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Chenge5f62042007-09-29 00:00:36 +0000736 X86_COND_B, EFLAGS))]>,
Evan Cheng71fb9ad2006-01-26 00:29:36 +0000737 TB, OpSize;
Evan Cheng069287d2006-05-16 07:21:53 +0000738def CMOVB32rr : I<0x42, MRMSrcReg, // if <u, GR32 = GR32
Evan Cheng64d80e32007-07-19 01:14:50 +0000739 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000740 "cmovb\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +0000741 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Chenge5f62042007-09-29 00:00:36 +0000742 X86_COND_B, EFLAGS))]>,
Evan Cheng71fb9ad2006-01-26 00:29:36 +0000743 TB;
Alkis Evlogimenosa3f66842004-03-12 17:59:56 +0000744
Evan Cheng069287d2006-05-16 07:21:53 +0000745def CMOVAE16rr: I<0x43, MRMSrcReg, // if >=u, GR16 = GR16
Evan Cheng64d80e32007-07-19 01:14:50 +0000746 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000747 "cmovae\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +0000748 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Chenge5f62042007-09-29 00:00:36 +0000749 X86_COND_AE, EFLAGS))]>,
Evan Cheng71fb9ad2006-01-26 00:29:36 +0000750 TB, OpSize;
Evan Cheng069287d2006-05-16 07:21:53 +0000751def CMOVAE32rr: I<0x43, MRMSrcReg, // if >=u, GR32 = GR32
Evan Cheng64d80e32007-07-19 01:14:50 +0000752 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000753 "cmovae\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +0000754 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Chenge5f62042007-09-29 00:00:36 +0000755 X86_COND_AE, EFLAGS))]>,
Evan Cheng71fb9ad2006-01-26 00:29:36 +0000756 TB;
Evan Cheng069287d2006-05-16 07:21:53 +0000757def CMOVE16rr : I<0x44, MRMSrcReg, // if ==, GR16 = GR16
Evan Cheng64d80e32007-07-19 01:14:50 +0000758 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000759 "cmove\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +0000760 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Chenge5f62042007-09-29 00:00:36 +0000761 X86_COND_E, EFLAGS))]>,
Evan Cheng71fb9ad2006-01-26 00:29:36 +0000762 TB, OpSize;
Evan Cheng069287d2006-05-16 07:21:53 +0000763def CMOVE32rr : I<0x44, MRMSrcReg, // if ==, GR32 = GR32
Evan Cheng64d80e32007-07-19 01:14:50 +0000764 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000765 "cmove\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +0000766 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Chenge5f62042007-09-29 00:00:36 +0000767 X86_COND_E, EFLAGS))]>,
Evan Cheng71fb9ad2006-01-26 00:29:36 +0000768 TB;
Evan Cheng069287d2006-05-16 07:21:53 +0000769def CMOVNE16rr: I<0x45, MRMSrcReg, // if !=, GR16 = GR16
Evan Cheng64d80e32007-07-19 01:14:50 +0000770 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000771 "cmovne\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +0000772 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Chenge5f62042007-09-29 00:00:36 +0000773 X86_COND_NE, EFLAGS))]>,
Evan Cheng71fb9ad2006-01-26 00:29:36 +0000774 TB, OpSize;
Evan Cheng069287d2006-05-16 07:21:53 +0000775def CMOVNE32rr: I<0x45, MRMSrcReg, // if !=, GR32 = GR32
Evan Cheng64d80e32007-07-19 01:14:50 +0000776 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000777 "cmovne\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +0000778 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Chenge5f62042007-09-29 00:00:36 +0000779 X86_COND_NE, EFLAGS))]>,
Evan Cheng71fb9ad2006-01-26 00:29:36 +0000780 TB;
Evan Cheng069287d2006-05-16 07:21:53 +0000781def CMOVBE16rr: I<0x46, MRMSrcReg, // if <=u, GR16 = GR16
Evan Cheng64d80e32007-07-19 01:14:50 +0000782 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000783 "cmovbe\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +0000784 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Chenge5f62042007-09-29 00:00:36 +0000785 X86_COND_BE, EFLAGS))]>,
Evan Cheng71fb9ad2006-01-26 00:29:36 +0000786 TB, OpSize;
Evan Cheng069287d2006-05-16 07:21:53 +0000787def CMOVBE32rr: I<0x46, MRMSrcReg, // if <=u, GR32 = GR32
Evan Cheng64d80e32007-07-19 01:14:50 +0000788 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000789 "cmovbe\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +0000790 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Chenge5f62042007-09-29 00:00:36 +0000791 X86_COND_BE, EFLAGS))]>,
Evan Cheng71fb9ad2006-01-26 00:29:36 +0000792 TB;
Evan Cheng069287d2006-05-16 07:21:53 +0000793def CMOVA16rr : I<0x47, MRMSrcReg, // if >u, GR16 = GR16
Evan Cheng64d80e32007-07-19 01:14:50 +0000794 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000795 "cmova\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +0000796 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Chenge5f62042007-09-29 00:00:36 +0000797 X86_COND_A, EFLAGS))]>,
Evan Cheng71fb9ad2006-01-26 00:29:36 +0000798 TB, OpSize;
Evan Cheng069287d2006-05-16 07:21:53 +0000799def CMOVA32rr : I<0x47, MRMSrcReg, // if >u, GR32 = GR32
Evan Cheng64d80e32007-07-19 01:14:50 +0000800 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000801 "cmova\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +0000802 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Chenge5f62042007-09-29 00:00:36 +0000803 X86_COND_A, EFLAGS))]>,
Evan Cheng71fb9ad2006-01-26 00:29:36 +0000804 TB;
Evan Cheng069287d2006-05-16 07:21:53 +0000805def CMOVL16rr : I<0x4C, MRMSrcReg, // if <s, GR16 = GR16
Evan Cheng64d80e32007-07-19 01:14:50 +0000806 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000807 "cmovl\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +0000808 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Chenge5f62042007-09-29 00:00:36 +0000809 X86_COND_L, EFLAGS))]>,
Evan Cheng71fb9ad2006-01-26 00:29:36 +0000810 TB, OpSize;
Evan Cheng069287d2006-05-16 07:21:53 +0000811def CMOVL32rr : I<0x4C, MRMSrcReg, // if <s, GR32 = GR32
Evan Cheng64d80e32007-07-19 01:14:50 +0000812 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000813 "cmovl\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +0000814 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Chenge5f62042007-09-29 00:00:36 +0000815 X86_COND_L, EFLAGS))]>,
Evan Cheng71fb9ad2006-01-26 00:29:36 +0000816 TB;
Evan Cheng069287d2006-05-16 07:21:53 +0000817def CMOVGE16rr: I<0x4D, MRMSrcReg, // if >=s, GR16 = GR16
Evan Cheng64d80e32007-07-19 01:14:50 +0000818 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000819 "cmovge\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +0000820 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Chenge5f62042007-09-29 00:00:36 +0000821 X86_COND_GE, EFLAGS))]>,
Evan Cheng71fb9ad2006-01-26 00:29:36 +0000822 TB, OpSize;
Evan Cheng069287d2006-05-16 07:21:53 +0000823def CMOVGE32rr: I<0x4D, MRMSrcReg, // if >=s, GR32 = GR32
Evan Cheng64d80e32007-07-19 01:14:50 +0000824 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000825 "cmovge\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +0000826 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Chenge5f62042007-09-29 00:00:36 +0000827 X86_COND_GE, EFLAGS))]>,
Evan Cheng71fb9ad2006-01-26 00:29:36 +0000828 TB;
Evan Cheng069287d2006-05-16 07:21:53 +0000829def CMOVLE16rr: I<0x4E, MRMSrcReg, // if <=s, GR16 = GR16
Evan Cheng64d80e32007-07-19 01:14:50 +0000830 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000831 "cmovle\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +0000832 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Chenge5f62042007-09-29 00:00:36 +0000833 X86_COND_LE, EFLAGS))]>,
Evan Cheng71fb9ad2006-01-26 00:29:36 +0000834 TB, OpSize;
Evan Cheng069287d2006-05-16 07:21:53 +0000835def CMOVLE32rr: I<0x4E, MRMSrcReg, // if <=s, GR32 = GR32
Evan Cheng64d80e32007-07-19 01:14:50 +0000836 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000837 "cmovle\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +0000838 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Chenge5f62042007-09-29 00:00:36 +0000839 X86_COND_LE, EFLAGS))]>,
Evan Cheng71fb9ad2006-01-26 00:29:36 +0000840 TB;
Evan Cheng069287d2006-05-16 07:21:53 +0000841def CMOVG16rr : I<0x4F, MRMSrcReg, // if >s, GR16 = GR16
Evan Cheng64d80e32007-07-19 01:14:50 +0000842 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000843 "cmovg\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +0000844 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Chenge5f62042007-09-29 00:00:36 +0000845 X86_COND_G, EFLAGS))]>,
Evan Cheng71fb9ad2006-01-26 00:29:36 +0000846 TB, OpSize;
Evan Cheng069287d2006-05-16 07:21:53 +0000847def CMOVG32rr : I<0x4F, MRMSrcReg, // if >s, GR32 = GR32
Evan Cheng64d80e32007-07-19 01:14:50 +0000848 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000849 "cmovg\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +0000850 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Chenge5f62042007-09-29 00:00:36 +0000851 X86_COND_G, EFLAGS))]>,
Evan Cheng71fb9ad2006-01-26 00:29:36 +0000852 TB;
Evan Cheng069287d2006-05-16 07:21:53 +0000853def CMOVS16rr : I<0x48, MRMSrcReg, // if signed, GR16 = GR16
Evan Cheng64d80e32007-07-19 01:14:50 +0000854 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000855 "cmovs\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +0000856 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Chenge5f62042007-09-29 00:00:36 +0000857 X86_COND_S, EFLAGS))]>,
Evan Cheng71fb9ad2006-01-26 00:29:36 +0000858 TB, OpSize;
Evan Cheng069287d2006-05-16 07:21:53 +0000859def CMOVS32rr : I<0x48, MRMSrcReg, // if signed, GR32 = GR32
Evan Cheng64d80e32007-07-19 01:14:50 +0000860 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000861 "cmovs\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +0000862 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Chenge5f62042007-09-29 00:00:36 +0000863 X86_COND_S, EFLAGS))]>,
Evan Cheng71fb9ad2006-01-26 00:29:36 +0000864 TB;
Evan Cheng069287d2006-05-16 07:21:53 +0000865def CMOVNS16rr: I<0x49, MRMSrcReg, // if !signed, GR16 = GR16
Evan Cheng64d80e32007-07-19 01:14:50 +0000866 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000867 "cmovns\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +0000868 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Chenge5f62042007-09-29 00:00:36 +0000869 X86_COND_NS, EFLAGS))]>,
Evan Cheng71fb9ad2006-01-26 00:29:36 +0000870 TB, OpSize;
Evan Cheng069287d2006-05-16 07:21:53 +0000871def CMOVNS32rr: I<0x49, MRMSrcReg, // if !signed, GR32 = GR32
Evan Cheng64d80e32007-07-19 01:14:50 +0000872 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000873 "cmovns\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +0000874 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Chenge5f62042007-09-29 00:00:36 +0000875 X86_COND_NS, EFLAGS))]>,
Evan Cheng71fb9ad2006-01-26 00:29:36 +0000876 TB;
Evan Cheng069287d2006-05-16 07:21:53 +0000877def CMOVP16rr : I<0x4A, MRMSrcReg, // if parity, GR16 = GR16
Evan Cheng64d80e32007-07-19 01:14:50 +0000878 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000879 "cmovp\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +0000880 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Chenge5f62042007-09-29 00:00:36 +0000881 X86_COND_P, EFLAGS))]>,
Evan Cheng71fb9ad2006-01-26 00:29:36 +0000882 TB, OpSize;
Evan Cheng069287d2006-05-16 07:21:53 +0000883def CMOVP32rr : I<0x4A, MRMSrcReg, // if parity, GR32 = GR32
Evan Cheng64d80e32007-07-19 01:14:50 +0000884 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000885 "cmovp\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +0000886 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Chenge5f62042007-09-29 00:00:36 +0000887 X86_COND_P, EFLAGS))]>,
Evan Cheng71fb9ad2006-01-26 00:29:36 +0000888 TB;
Evan Cheng069287d2006-05-16 07:21:53 +0000889def CMOVNP16rr : I<0x4B, MRMSrcReg, // if !parity, GR16 = GR16
Evan Cheng64d80e32007-07-19 01:14:50 +0000890 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000891 "cmovnp\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +0000892 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Chenge5f62042007-09-29 00:00:36 +0000893 X86_COND_NP, EFLAGS))]>,
Evan Cheng71fb9ad2006-01-26 00:29:36 +0000894 TB, OpSize;
Evan Cheng069287d2006-05-16 07:21:53 +0000895def CMOVNP32rr : I<0x4B, MRMSrcReg, // if !parity, GR32 = GR32
Evan Cheng64d80e32007-07-19 01:14:50 +0000896 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000897 "cmovnp\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +0000898 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Chenge5f62042007-09-29 00:00:36 +0000899 X86_COND_NP, EFLAGS))]>,
Evan Cheng71fb9ad2006-01-26 00:29:36 +0000900 TB;
Evan Cheng7ad42d92007-10-05 23:13:21 +0000901} // isCommutable = 1
902
Evan Cheng069287d2006-05-16 07:21:53 +0000903def CMOVNP32rm : I<0x4B, MRMSrcMem, // if !parity, GR32 = [mem32]
Evan Cheng64d80e32007-07-19 01:14:50 +0000904 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000905 "cmovnp\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +0000906 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
Evan Cheng0488db92007-09-25 01:57:46 +0000907 X86_COND_NP, EFLAGS))]>,
908 TB;
Evan Cheng7ad42d92007-10-05 23:13:21 +0000909
910def CMOVB16rm : I<0x42, MRMSrcMem, // if <u, GR16 = [mem16]
911 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
912 "cmovb\t{$src2, $dst|$dst, $src2}",
913 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
914 X86_COND_B, EFLAGS))]>,
915 TB, OpSize;
916def CMOVB32rm : I<0x42, MRMSrcMem, // if <u, GR32 = [mem32]
917 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
918 "cmovb\t{$src2, $dst|$dst, $src2}",
919 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
920 X86_COND_B, EFLAGS))]>,
921 TB;
922def CMOVAE16rm: I<0x43, MRMSrcMem, // if >=u, GR16 = [mem16]
923 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
924 "cmovae\t{$src2, $dst|$dst, $src2}",
925 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
926 X86_COND_AE, EFLAGS))]>,
927 TB, OpSize;
928def CMOVAE32rm: I<0x43, MRMSrcMem, // if >=u, GR32 = [mem32]
929 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
930 "cmovae\t{$src2, $dst|$dst, $src2}",
931 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
932 X86_COND_AE, EFLAGS))]>,
933 TB;
934def CMOVE16rm : I<0x44, MRMSrcMem, // if ==, GR16 = [mem16]
935 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
936 "cmove\t{$src2, $dst|$dst, $src2}",
937 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
938 X86_COND_E, EFLAGS))]>,
939 TB, OpSize;
940def CMOVE32rm : I<0x44, MRMSrcMem, // if ==, GR32 = [mem32]
941 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
942 "cmove\t{$src2, $dst|$dst, $src2}",
943 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
944 X86_COND_E, EFLAGS))]>,
945 TB;
946def CMOVNE16rm: I<0x45, MRMSrcMem, // if !=, GR16 = [mem16]
947 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
948 "cmovne\t{$src2, $dst|$dst, $src2}",
949 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
950 X86_COND_NE, EFLAGS))]>,
951 TB, OpSize;
952def CMOVNE32rm: I<0x45, MRMSrcMem, // if !=, GR32 = [mem32]
953 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
954 "cmovne\t{$src2, $dst|$dst, $src2}",
955 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
956 X86_COND_NE, EFLAGS))]>,
957 TB;
958def CMOVBE16rm: I<0x46, MRMSrcMem, // if <=u, GR16 = [mem16]
959 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
960 "cmovbe\t{$src2, $dst|$dst, $src2}",
961 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
962 X86_COND_BE, EFLAGS))]>,
963 TB, OpSize;
964def CMOVBE32rm: I<0x46, MRMSrcMem, // if <=u, GR32 = [mem32]
965 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
966 "cmovbe\t{$src2, $dst|$dst, $src2}",
967 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
968 X86_COND_BE, EFLAGS))]>,
969 TB;
970def CMOVA16rm : I<0x47, MRMSrcMem, // if >u, GR16 = [mem16]
971 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
972 "cmova\t{$src2, $dst|$dst, $src2}",
973 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
974 X86_COND_A, EFLAGS))]>,
975 TB, OpSize;
976def CMOVA32rm : I<0x47, MRMSrcMem, // if >u, GR32 = [mem32]
977 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
978 "cmova\t{$src2, $dst|$dst, $src2}",
979 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
980 X86_COND_A, EFLAGS))]>,
981 TB;
982def CMOVL16rm : I<0x4C, MRMSrcMem, // if <s, GR16 = [mem16]
983 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
984 "cmovl\t{$src2, $dst|$dst, $src2}",
985 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
986 X86_COND_L, EFLAGS))]>,
987 TB, OpSize;
988def CMOVL32rm : I<0x4C, MRMSrcMem, // if <s, GR32 = [mem32]
989 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
990 "cmovl\t{$src2, $dst|$dst, $src2}",
991 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
992 X86_COND_L, EFLAGS))]>,
993 TB;
994def CMOVGE16rm: I<0x4D, MRMSrcMem, // if >=s, GR16 = [mem16]
995 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
996 "cmovge\t{$src2, $dst|$dst, $src2}",
997 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
998 X86_COND_GE, EFLAGS))]>,
999 TB, OpSize;
1000def CMOVGE32rm: I<0x4D, MRMSrcMem, // if >=s, GR32 = [mem32]
1001 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1002 "cmovge\t{$src2, $dst|$dst, $src2}",
1003 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1004 X86_COND_GE, EFLAGS))]>,
1005 TB;
1006def CMOVLE16rm: I<0x4E, MRMSrcMem, // if <=s, GR16 = [mem16]
1007 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1008 "cmovle\t{$src2, $dst|$dst, $src2}",
1009 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1010 X86_COND_LE, EFLAGS))]>,
1011 TB, OpSize;
1012def CMOVLE32rm: I<0x4E, MRMSrcMem, // if <=s, GR32 = [mem32]
1013 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1014 "cmovle\t{$src2, $dst|$dst, $src2}",
1015 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1016 X86_COND_LE, EFLAGS))]>,
1017 TB;
1018def CMOVG16rm : I<0x4F, MRMSrcMem, // if >s, GR16 = [mem16]
1019 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1020 "cmovg\t{$src2, $dst|$dst, $src2}",
1021 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1022 X86_COND_G, EFLAGS))]>,
1023 TB, OpSize;
1024def CMOVG32rm : I<0x4F, MRMSrcMem, // if >s, GR32 = [mem32]
1025 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1026 "cmovg\t{$src2, $dst|$dst, $src2}",
1027 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1028 X86_COND_G, EFLAGS))]>,
1029 TB;
1030def CMOVS16rm : I<0x48, MRMSrcMem, // if signed, GR16 = [mem16]
1031 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1032 "cmovs\t{$src2, $dst|$dst, $src2}",
1033 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1034 X86_COND_S, EFLAGS))]>,
1035 TB, OpSize;
1036def CMOVS32rm : I<0x48, MRMSrcMem, // if signed, GR32 = [mem32]
1037 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1038 "cmovs\t{$src2, $dst|$dst, $src2}",
1039 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1040 X86_COND_S, EFLAGS))]>,
1041 TB;
1042def CMOVNS16rm: I<0x49, MRMSrcMem, // if !signed, GR16 = [mem16]
1043 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1044 "cmovns\t{$src2, $dst|$dst, $src2}",
1045 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1046 X86_COND_NS, EFLAGS))]>,
1047 TB, OpSize;
1048def CMOVNS32rm: I<0x49, MRMSrcMem, // if !signed, GR32 = [mem32]
1049 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1050 "cmovns\t{$src2, $dst|$dst, $src2}",
1051 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1052 X86_COND_NS, EFLAGS))]>,
1053 TB;
1054def CMOVP16rm : I<0x4A, MRMSrcMem, // if parity, GR16 = [mem16]
1055 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1056 "cmovp\t{$src2, $dst|$dst, $src2}",
1057 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1058 X86_COND_P, EFLAGS))]>,
1059 TB, OpSize;
1060def CMOVP32rm : I<0x4A, MRMSrcMem, // if parity, GR32 = [mem32]
1061 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1062 "cmovp\t{$src2, $dst|$dst, $src2}",
1063 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1064 X86_COND_P, EFLAGS))]>,
1065 TB;
1066def CMOVNP16rm : I<0x4B, MRMSrcMem, // if !parity, GR16 = [mem16]
1067 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1068 "cmovnp\t{$src2, $dst|$dst, $src2}",
1069 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1070 X86_COND_NP, EFLAGS))]>,
1071 TB, OpSize;
Evan Cheng0488db92007-09-25 01:57:46 +00001072} // Uses = [EFLAGS]
1073
1074
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00001075// unary instructions
Evan Cheng1693e482006-07-19 00:27:29 +00001076let CodeSize = 2 in {
Evan Cheng24f2ea32007-09-14 21:48:26 +00001077let Defs = [EFLAGS] in {
Dan Gohmanb1576f52007-07-31 20:11:57 +00001078def NEG8r : I<0xF6, MRM3r, (outs GR8 :$dst), (ins GR8 :$src), "neg{b}\t$dst",
Evan Cheng069287d2006-05-16 07:21:53 +00001079 [(set GR8:$dst, (ineg GR8:$src))]>;
Dan Gohmanb1576f52007-07-31 20:11:57 +00001080def NEG16r : I<0xF7, MRM3r, (outs GR16:$dst), (ins GR16:$src), "neg{w}\t$dst",
Evan Cheng069287d2006-05-16 07:21:53 +00001081 [(set GR16:$dst, (ineg GR16:$src))]>, OpSize;
Dan Gohmanb1576f52007-07-31 20:11:57 +00001082def NEG32r : I<0xF7, MRM3r, (outs GR32:$dst), (ins GR32:$src), "neg{l}\t$dst",
Evan Cheng069287d2006-05-16 07:21:53 +00001083 [(set GR32:$dst, (ineg GR32:$src))]>;
Chris Lattner57a02302004-08-11 04:31:00 +00001084let isTwoAddress = 0 in {
Dan Gohmanb1576f52007-07-31 20:11:57 +00001085 def NEG8m : I<0xF6, MRM3m, (outs), (ins i8mem :$dst), "neg{b}\t$dst",
Evan Cheng605c4152005-12-13 01:57:51 +00001086 [(store (ineg (loadi8 addr:$dst)), addr:$dst)]>;
Dan Gohmanb1576f52007-07-31 20:11:57 +00001087 def NEG16m : I<0xF7, MRM3m, (outs), (ins i16mem:$dst), "neg{w}\t$dst",
Evan Cheng605c4152005-12-13 01:57:51 +00001088 [(store (ineg (loadi16 addr:$dst)), addr:$dst)]>, OpSize;
Dan Gohmanb1576f52007-07-31 20:11:57 +00001089 def NEG32m : I<0xF7, MRM3m, (outs), (ins i32mem:$dst), "neg{l}\t$dst",
Evan Cheng605c4152005-12-13 01:57:51 +00001090 [(store (ineg (loadi32 addr:$dst)), addr:$dst)]>;
1091
Chris Lattner57a02302004-08-11 04:31:00 +00001092}
Evan Cheng24f2ea32007-09-14 21:48:26 +00001093} // Defs = [EFLAGS]
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00001094
Dan Gohmanb1576f52007-07-31 20:11:57 +00001095def NOT8r : I<0xF6, MRM2r, (outs GR8 :$dst), (ins GR8 :$src), "not{b}\t$dst",
Evan Cheng069287d2006-05-16 07:21:53 +00001096 [(set GR8:$dst, (not GR8:$src))]>;
Dan Gohmanb1576f52007-07-31 20:11:57 +00001097def NOT16r : I<0xF7, MRM2r, (outs GR16:$dst), (ins GR16:$src), "not{w}\t$dst",
Evan Cheng069287d2006-05-16 07:21:53 +00001098 [(set GR16:$dst, (not GR16:$src))]>, OpSize;
Dan Gohmanb1576f52007-07-31 20:11:57 +00001099def NOT32r : I<0xF7, MRM2r, (outs GR32:$dst), (ins GR32:$src), "not{l}\t$dst",
Evan Cheng069287d2006-05-16 07:21:53 +00001100 [(set GR32:$dst, (not GR32:$src))]>;
Chris Lattner57a02302004-08-11 04:31:00 +00001101let isTwoAddress = 0 in {
Dan Gohmanb1576f52007-07-31 20:11:57 +00001102 def NOT8m : I<0xF6, MRM2m, (outs), (ins i8mem :$dst), "not{b}\t$dst",
Evan Cheng605c4152005-12-13 01:57:51 +00001103 [(store (not (loadi8 addr:$dst)), addr:$dst)]>;
Dan Gohmanb1576f52007-07-31 20:11:57 +00001104 def NOT16m : I<0xF7, MRM2m, (outs), (ins i16mem:$dst), "not{w}\t$dst",
Evan Cheng605c4152005-12-13 01:57:51 +00001105 [(store (not (loadi16 addr:$dst)), addr:$dst)]>, OpSize;
Dan Gohmanb1576f52007-07-31 20:11:57 +00001106 def NOT32m : I<0xF7, MRM2m, (outs), (ins i32mem:$dst), "not{l}\t$dst",
Evan Cheng605c4152005-12-13 01:57:51 +00001107 [(store (not (loadi32 addr:$dst)), addr:$dst)]>;
Chris Lattner57a02302004-08-11 04:31:00 +00001108}
Evan Cheng1693e482006-07-19 00:27:29 +00001109} // CodeSize
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00001110
Evan Chengb51a0592005-12-10 00:48:20 +00001111// TODO: inc/dec is slow for P4, but fast for Pentium-M.
Evan Cheng24f2ea32007-09-14 21:48:26 +00001112let Defs = [EFLAGS] in {
Evan Cheng1693e482006-07-19 00:27:29 +00001113let CodeSize = 2 in
Dan Gohmanb1576f52007-07-31 20:11:57 +00001114def INC8r : I<0xFE, MRM0r, (outs GR8 :$dst), (ins GR8 :$src), "inc{b}\t$dst",
Evan Cheng069287d2006-05-16 07:21:53 +00001115 [(set GR8:$dst, (add GR8:$src, 1))]>;
Evan Cheng1693e482006-07-19 00:27:29 +00001116let isConvertibleToThreeAddress = 1, CodeSize = 1 in { // Can xform into LEA.
Dan Gohmanb1576f52007-07-31 20:11:57 +00001117def INC16r : I<0x40, AddRegFrm, (outs GR16:$dst), (ins GR16:$src), "inc{w}\t$dst",
Evan Cheng25ab6902006-09-08 06:48:29 +00001118 [(set GR16:$dst, (add GR16:$src, 1))]>,
1119 OpSize, Requires<[In32BitMode]>;
Dan Gohmanb1576f52007-07-31 20:11:57 +00001120def INC32r : I<0x40, AddRegFrm, (outs GR32:$dst), (ins GR32:$src), "inc{l}\t$dst",
Evan Cheng25ab6902006-09-08 06:48:29 +00001121 [(set GR32:$dst, (add GR32:$src, 1))]>, Requires<[In32BitMode]>;
Chris Lattnercc65bee2005-01-02 02:35:46 +00001122}
Evan Cheng1693e482006-07-19 00:27:29 +00001123let isTwoAddress = 0, CodeSize = 2 in {
Dan Gohmanb1576f52007-07-31 20:11:57 +00001124 def INC8m : I<0xFE, MRM0m, (outs), (ins i8mem :$dst), "inc{b}\t$dst",
Evan Cheng605c4152005-12-13 01:57:51 +00001125 [(store (add (loadi8 addr:$dst), 1), addr:$dst)]>;
Dan Gohmanb1576f52007-07-31 20:11:57 +00001126 def INC16m : I<0xFF, MRM0m, (outs), (ins i16mem:$dst), "inc{w}\t$dst",
Evan Cheng66f71632007-10-19 21:23:22 +00001127 [(store (add (loadi16 addr:$dst), 1), addr:$dst)]>,
1128 OpSize, Requires<[In32BitMode]>;
Dan Gohmanb1576f52007-07-31 20:11:57 +00001129 def INC32m : I<0xFF, MRM0m, (outs), (ins i32mem:$dst), "inc{l}\t$dst",
Evan Cheng66f71632007-10-19 21:23:22 +00001130 [(store (add (loadi32 addr:$dst), 1), addr:$dst)]>,
1131 Requires<[In32BitMode]>;
Chris Lattner57a02302004-08-11 04:31:00 +00001132}
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00001133
Evan Cheng1693e482006-07-19 00:27:29 +00001134let CodeSize = 2 in
Dan Gohmanb1576f52007-07-31 20:11:57 +00001135def DEC8r : I<0xFE, MRM1r, (outs GR8 :$dst), (ins GR8 :$src), "dec{b}\t$dst",
Evan Cheng069287d2006-05-16 07:21:53 +00001136 [(set GR8:$dst, (add GR8:$src, -1))]>;
Evan Cheng1693e482006-07-19 00:27:29 +00001137let isConvertibleToThreeAddress = 1, CodeSize = 1 in { // Can xform into LEA.
Dan Gohmanb1576f52007-07-31 20:11:57 +00001138def DEC16r : I<0x48, AddRegFrm, (outs GR16:$dst), (ins GR16:$src), "dec{w}\t$dst",
Evan Cheng25ab6902006-09-08 06:48:29 +00001139 [(set GR16:$dst, (add GR16:$src, -1))]>,
1140 OpSize, Requires<[In32BitMode]>;
Dan Gohmanb1576f52007-07-31 20:11:57 +00001141def DEC32r : I<0x48, AddRegFrm, (outs GR32:$dst), (ins GR32:$src), "dec{l}\t$dst",
Evan Cheng25ab6902006-09-08 06:48:29 +00001142 [(set GR32:$dst, (add GR32:$src, -1))]>, Requires<[In32BitMode]>;
Chris Lattnercc65bee2005-01-02 02:35:46 +00001143}
Chris Lattner57a02302004-08-11 04:31:00 +00001144
Evan Cheng1693e482006-07-19 00:27:29 +00001145let isTwoAddress = 0, CodeSize = 2 in {
Dan Gohmanb1576f52007-07-31 20:11:57 +00001146 def DEC8m : I<0xFE, MRM1m, (outs), (ins i8mem :$dst), "dec{b}\t$dst",
Evan Cheng605c4152005-12-13 01:57:51 +00001147 [(store (add (loadi8 addr:$dst), -1), addr:$dst)]>;
Dan Gohmanb1576f52007-07-31 20:11:57 +00001148 def DEC16m : I<0xFF, MRM1m, (outs), (ins i16mem:$dst), "dec{w}\t$dst",
Evan Cheng66f71632007-10-19 21:23:22 +00001149 [(store (add (loadi16 addr:$dst), -1), addr:$dst)]>,
1150 OpSize, Requires<[In32BitMode]>;
Dan Gohmanb1576f52007-07-31 20:11:57 +00001151 def DEC32m : I<0xFF, MRM1m, (outs), (ins i32mem:$dst), "dec{l}\t$dst",
Evan Cheng66f71632007-10-19 21:23:22 +00001152 [(store (add (loadi32 addr:$dst), -1), addr:$dst)]>,
1153 Requires<[In32BitMode]>;
Chris Lattner57a02302004-08-11 04:31:00 +00001154}
Evan Cheng24f2ea32007-09-14 21:48:26 +00001155} // Defs = [EFLAGS]
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00001156
1157// Logical operators...
Evan Cheng24f2ea32007-09-14 21:48:26 +00001158let Defs = [EFLAGS] in {
Chris Lattnercc65bee2005-01-02 02:35:46 +00001159let isCommutable = 1 in { // X = AND Y, Z --> X = AND Z, Y
Chris Lattner3a173df2004-10-03 20:35:00 +00001160def AND8rr : I<0x20, MRMDestReg,
Evan Cheng64d80e32007-07-19 01:14:50 +00001161 (outs GR8 :$dst), (ins GR8 :$src1, GR8 :$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001162 "and{b}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001163 [(set GR8:$dst, (and GR8:$src1, GR8:$src2))]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00001164def AND16rr : I<0x21, MRMDestReg,
Evan Cheng64d80e32007-07-19 01:14:50 +00001165 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001166 "and{w}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001167 [(set GR16:$dst, (and GR16:$src1, GR16:$src2))]>, OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00001168def AND32rr : I<0x21, MRMDestReg,
Evan Cheng64d80e32007-07-19 01:14:50 +00001169 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001170 "and{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001171 [(set GR32:$dst, (and GR32:$src1, GR32:$src2))]>;
Chris Lattnercc65bee2005-01-02 02:35:46 +00001172}
Chris Lattner57a02302004-08-11 04:31:00 +00001173
Chris Lattner3a173df2004-10-03 20:35:00 +00001174def AND8rm : I<0x22, MRMSrcMem,
Evan Cheng64d80e32007-07-19 01:14:50 +00001175 (outs GR8 :$dst), (ins GR8 :$src1, i8mem :$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001176 "and{b}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001177 [(set GR8:$dst, (and GR8:$src1, (load addr:$src2)))]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00001178def AND16rm : I<0x23, MRMSrcMem,
Evan Cheng64d80e32007-07-19 01:14:50 +00001179 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001180 "and{w}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001181 [(set GR16:$dst, (and GR16:$src1, (load addr:$src2)))]>, OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00001182def AND32rm : I<0x23, MRMSrcMem,
Evan Cheng64d80e32007-07-19 01:14:50 +00001183 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001184 "and{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001185 [(set GR32:$dst, (and GR32:$src1, (load addr:$src2)))]>;
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00001186
Chris Lattner3a173df2004-10-03 20:35:00 +00001187def AND8ri : Ii8<0x80, MRM4r,
Evan Cheng64d80e32007-07-19 01:14:50 +00001188 (outs GR8 :$dst), (ins GR8 :$src1, i8imm :$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001189 "and{b}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001190 [(set GR8:$dst, (and GR8:$src1, imm:$src2))]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00001191def AND16ri : Ii16<0x81, MRM4r,
Evan Cheng64d80e32007-07-19 01:14:50 +00001192 (outs GR16:$dst), (ins GR16:$src1, i16imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001193 "and{w}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001194 [(set GR16:$dst, (and GR16:$src1, imm:$src2))]>, OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00001195def AND32ri : Ii32<0x81, MRM4r,
Evan Cheng64d80e32007-07-19 01:14:50 +00001196 (outs GR32:$dst), (ins GR32:$src1, i32imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001197 "and{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001198 [(set GR32:$dst, (and GR32:$src1, imm:$src2))]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00001199def AND16ri8 : Ii8<0x83, MRM4r,
Evan Cheng64d80e32007-07-19 01:14:50 +00001200 (outs GR16:$dst), (ins GR16:$src1, i16i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001201 "and{w}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001202 [(set GR16:$dst, (and GR16:$src1, i16immSExt8:$src2))]>,
Evan Cheng9b6b6422005-12-13 00:14:11 +00001203 OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00001204def AND32ri8 : Ii8<0x83, MRM4r,
Evan Cheng64d80e32007-07-19 01:14:50 +00001205 (outs GR32:$dst), (ins GR32:$src1, i32i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001206 "and{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001207 [(set GR32:$dst, (and GR32:$src1, i32immSExt8:$src2))]>;
Chris Lattnerf29ed092004-08-11 05:07:25 +00001208
1209let isTwoAddress = 0 in {
Chris Lattner3a173df2004-10-03 20:35:00 +00001210 def AND8mr : I<0x20, MRMDestMem,
Evan Cheng64d80e32007-07-19 01:14:50 +00001211 (outs), (ins i8mem :$dst, GR8 :$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001212 "and{b}\t{$src, $dst|$dst, $src}",
Evan Cheng069287d2006-05-16 07:21:53 +00001213 [(store (and (load addr:$dst), GR8:$src), addr:$dst)]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00001214 def AND16mr : I<0x21, MRMDestMem,
Evan Cheng64d80e32007-07-19 01:14:50 +00001215 (outs), (ins i16mem:$dst, GR16:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001216 "and{w}\t{$src, $dst|$dst, $src}",
Evan Cheng069287d2006-05-16 07:21:53 +00001217 [(store (and (load addr:$dst), GR16:$src), addr:$dst)]>,
Evan Cheng0ef3a772005-12-13 01:41:36 +00001218 OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00001219 def AND32mr : I<0x21, MRMDestMem,
Evan Cheng64d80e32007-07-19 01:14:50 +00001220 (outs), (ins i32mem:$dst, GR32:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001221 "and{l}\t{$src, $dst|$dst, $src}",
Evan Cheng069287d2006-05-16 07:21:53 +00001222 [(store (and (load addr:$dst), GR32:$src), addr:$dst)]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00001223 def AND8mi : Ii8<0x80, MRM4m,
Evan Cheng64d80e32007-07-19 01:14:50 +00001224 (outs), (ins i8mem :$dst, i8imm :$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001225 "and{b}\t{$src, $dst|$dst, $src}",
Evan Chengc937ffa2005-12-13 02:40:18 +00001226 [(store (and (loadi8 addr:$dst), imm:$src), addr:$dst)]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00001227 def AND16mi : Ii16<0x81, MRM4m,
Evan Cheng64d80e32007-07-19 01:14:50 +00001228 (outs), (ins i16mem:$dst, i16imm:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001229 "and{w}\t{$src, $dst|$dst, $src}",
Evan Chengc937ffa2005-12-13 02:40:18 +00001230 [(store (and (loadi16 addr:$dst), imm:$src), addr:$dst)]>,
Evan Cheng0ef3a772005-12-13 01:41:36 +00001231 OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00001232 def AND32mi : Ii32<0x81, MRM4m,
Evan Cheng64d80e32007-07-19 01:14:50 +00001233 (outs), (ins i32mem:$dst, i32imm:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001234 "and{l}\t{$src, $dst|$dst, $src}",
Evan Chengc937ffa2005-12-13 02:40:18 +00001235 [(store (and (loadi32 addr:$dst), imm:$src), addr:$dst)]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00001236 def AND16mi8 : Ii8<0x83, MRM4m,
Evan Cheng64d80e32007-07-19 01:14:50 +00001237 (outs), (ins i16mem:$dst, i16i8imm :$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001238 "and{w}\t{$src, $dst|$dst, $src}",
Evan Cheng0ef3a772005-12-13 01:41:36 +00001239 [(store (and (load addr:$dst), i16immSExt8:$src), addr:$dst)]>,
1240 OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00001241 def AND32mi8 : Ii8<0x83, MRM4m,
Evan Cheng64d80e32007-07-19 01:14:50 +00001242 (outs), (ins i32mem:$dst, i32i8imm :$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001243 "and{l}\t{$src, $dst|$dst, $src}",
Evan Chenge3703d42006-01-14 01:18:49 +00001244 [(store (and (load addr:$dst), i32immSExt8:$src), addr:$dst)]>;
Chris Lattnerf29ed092004-08-11 05:07:25 +00001245}
1246
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00001247
Chris Lattnercc65bee2005-01-02 02:35:46 +00001248let isCommutable = 1 in { // X = OR Y, Z --> X = OR Z, Y
Evan Cheng64d80e32007-07-19 01:14:50 +00001249def OR8rr : I<0x08, MRMDestReg, (outs GR8 :$dst), (ins GR8 :$src1, GR8 :$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001250 "or{b}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001251 [(set GR8:$dst, (or GR8:$src1, GR8:$src2))]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00001252def OR16rr : I<0x09, MRMDestReg, (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001253 "or{w}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001254 [(set GR16:$dst, (or GR16:$src1, GR16:$src2))]>, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00001255def OR32rr : I<0x09, MRMDestReg, (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001256 "or{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001257 [(set GR32:$dst, (or GR32:$src1, GR32:$src2))]>;
Chris Lattnercc65bee2005-01-02 02:35:46 +00001258}
Evan Cheng64d80e32007-07-19 01:14:50 +00001259def OR8rm : I<0x0A, MRMSrcMem , (outs GR8 :$dst), (ins GR8 :$src1, i8mem :$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001260 "or{b}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001261 [(set GR8:$dst, (or GR8:$src1, (load addr:$src2)))]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00001262def OR16rm : I<0x0B, MRMSrcMem , (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001263 "or{w}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001264 [(set GR16:$dst, (or GR16:$src1, (load addr:$src2)))]>, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00001265def OR32rm : I<0x0B, MRMSrcMem , (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001266 "or{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001267 [(set GR32:$dst, (or GR32:$src1, (load addr:$src2)))]>;
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00001268
Evan Cheng64d80e32007-07-19 01:14:50 +00001269def OR8ri : Ii8 <0x80, MRM1r, (outs GR8 :$dst), (ins GR8 :$src1, i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001270 "or{b}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001271 [(set GR8:$dst, (or GR8:$src1, imm:$src2))]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00001272def OR16ri : Ii16<0x81, MRM1r, (outs GR16:$dst), (ins GR16:$src1, i16imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001273 "or{w}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001274 [(set GR16:$dst, (or GR16:$src1, imm:$src2))]>, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00001275def OR32ri : Ii32<0x81, MRM1r, (outs GR32:$dst), (ins GR32:$src1, i32imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001276 "or{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001277 [(set GR32:$dst, (or GR32:$src1, imm:$src2))]>;
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00001278
Evan Cheng64d80e32007-07-19 01:14:50 +00001279def OR16ri8 : Ii8<0x83, MRM1r, (outs GR16:$dst), (ins GR16:$src1, i16i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001280 "or{w}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001281 [(set GR16:$dst, (or GR16:$src1, i16immSExt8:$src2))]>, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00001282def OR32ri8 : Ii8<0x83, MRM1r, (outs GR32:$dst), (ins GR32:$src1, i32i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001283 "or{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001284 [(set GR32:$dst, (or GR32:$src1, i32immSExt8:$src2))]>;
Chris Lattner57a02302004-08-11 04:31:00 +00001285let isTwoAddress = 0 in {
Evan Cheng64d80e32007-07-19 01:14:50 +00001286 def OR8mr : I<0x08, MRMDestMem, (outs), (ins i8mem:$dst, GR8:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001287 "or{b}\t{$src, $dst|$dst, $src}",
Evan Cheng069287d2006-05-16 07:21:53 +00001288 [(store (or (load addr:$dst), GR8:$src), addr:$dst)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00001289 def OR16mr : I<0x09, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001290 "or{w}\t{$src, $dst|$dst, $src}",
Evan Cheng069287d2006-05-16 07:21:53 +00001291 [(store (or (load addr:$dst), GR16:$src), addr:$dst)]>, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00001292 def OR32mr : I<0x09, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001293 "or{l}\t{$src, $dst|$dst, $src}",
Evan Cheng069287d2006-05-16 07:21:53 +00001294 [(store (or (load addr:$dst), GR32:$src), addr:$dst)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00001295 def OR8mi : Ii8<0x80, MRM1m, (outs), (ins i8mem :$dst, i8imm:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001296 "or{b}\t{$src, $dst|$dst, $src}",
Evan Chengc937ffa2005-12-13 02:40:18 +00001297 [(store (or (loadi8 addr:$dst), imm:$src), addr:$dst)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00001298 def OR16mi : Ii16<0x81, MRM1m, (outs), (ins i16mem:$dst, i16imm:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001299 "or{w}\t{$src, $dst|$dst, $src}",
Evan Chengc937ffa2005-12-13 02:40:18 +00001300 [(store (or (loadi16 addr:$dst), imm:$src), addr:$dst)]>,
Evan Cheng0ef3a772005-12-13 01:41:36 +00001301 OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00001302 def OR32mi : Ii32<0x81, MRM1m, (outs), (ins i32mem:$dst, i32imm:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001303 "or{l}\t{$src, $dst|$dst, $src}",
Evan Chengc937ffa2005-12-13 02:40:18 +00001304 [(store (or (loadi32 addr:$dst), imm:$src), addr:$dst)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00001305 def OR16mi8 : Ii8<0x83, MRM1m, (outs), (ins i16mem:$dst, i16i8imm:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001306 "or{w}\t{$src, $dst|$dst, $src}",
Evan Cheng0ef3a772005-12-13 01:41:36 +00001307 [(store (or (load addr:$dst), i16immSExt8:$src), addr:$dst)]>,
1308 OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00001309 def OR32mi8 : Ii8<0x83, MRM1m, (outs), (ins i32mem:$dst, i32i8imm:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001310 "or{l}\t{$src, $dst|$dst, $src}",
Evan Cheng0ef3a772005-12-13 01:41:36 +00001311 [(store (or (load addr:$dst), i32immSExt8:$src), addr:$dst)]>;
Bill Wendlingbd0879d2008-05-29 01:02:09 +00001312} // isTwoAddress = 0
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00001313
1314
Evan Cheng359e9372008-06-18 08:13:07 +00001315let isCommutable = 1 in { // X = XOR Y, Z --> X = XOR Z, Y
Bill Wendlingbd0879d2008-05-29 01:02:09 +00001316 def XOR8rr : I<0x30, MRMDestReg,
1317 (outs GR8 :$dst), (ins GR8 :$src1, GR8 :$src2),
1318 "xor{b}\t{$src2, $dst|$dst, $src2}",
1319 [(set GR8:$dst, (xor GR8:$src1, GR8:$src2))]>;
1320 def XOR16rr : I<0x31, MRMDestReg,
1321 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
1322 "xor{w}\t{$src2, $dst|$dst, $src2}",
1323 [(set GR16:$dst, (xor GR16:$src1, GR16:$src2))]>, OpSize;
1324 def XOR32rr : I<0x31, MRMDestReg,
1325 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
1326 "xor{l}\t{$src2, $dst|$dst, $src2}",
1327 [(set GR32:$dst, (xor GR32:$src1, GR32:$src2))]>;
Evan Cheng359e9372008-06-18 08:13:07 +00001328} // isCommutable = 1
Chris Lattnercc65bee2005-01-02 02:35:46 +00001329
Chris Lattner3a173df2004-10-03 20:35:00 +00001330def XOR8rm : I<0x32, MRMSrcMem ,
Evan Cheng64d80e32007-07-19 01:14:50 +00001331 (outs GR8 :$dst), (ins GR8:$src1, i8mem :$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001332 "xor{b}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001333 [(set GR8:$dst, (xor GR8:$src1, (load addr:$src2)))]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00001334def XOR16rm : I<0x33, MRMSrcMem ,
Evan Cheng64d80e32007-07-19 01:14:50 +00001335 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001336 "xor{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingbd0879d2008-05-29 01:02:09 +00001337 [(set GR16:$dst, (xor GR16:$src1, (load addr:$src2)))]>,
1338 OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00001339def XOR32rm : I<0x33, MRMSrcMem ,
Evan Cheng64d80e32007-07-19 01:14:50 +00001340 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001341 "xor{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001342 [(set GR32:$dst, (xor GR32:$src1, (load addr:$src2)))]>;
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00001343
Bill Wendling75cf88f2008-05-29 03:46:36 +00001344def XOR8ri : Ii8<0x80, MRM6r,
1345 (outs GR8:$dst), (ins GR8:$src1, i8imm:$src2),
1346 "xor{b}\t{$src2, $dst|$dst, $src2}",
1347 [(set GR8:$dst, (xor GR8:$src1, imm:$src2))]>;
1348def XOR16ri : Ii16<0x81, MRM6r,
1349 (outs GR16:$dst), (ins GR16:$src1, i16imm:$src2),
1350 "xor{w}\t{$src2, $dst|$dst, $src2}",
1351 [(set GR16:$dst, (xor GR16:$src1, imm:$src2))]>, OpSize;
1352def XOR32ri : Ii32<0x81, MRM6r,
1353 (outs GR32:$dst), (ins GR32:$src1, i32imm:$src2),
1354 "xor{l}\t{$src2, $dst|$dst, $src2}",
1355 [(set GR32:$dst, (xor GR32:$src1, imm:$src2))]>;
1356def XOR16ri8 : Ii8<0x83, MRM6r,
1357 (outs GR16:$dst), (ins GR16:$src1, i16i8imm:$src2),
1358 "xor{w}\t{$src2, $dst|$dst, $src2}",
1359 [(set GR16:$dst, (xor GR16:$src1, i16immSExt8:$src2))]>,
1360 OpSize;
1361def XOR32ri8 : Ii8<0x83, MRM6r,
1362 (outs GR32:$dst), (ins GR32:$src1, i32i8imm:$src2),
1363 "xor{l}\t{$src2, $dst|$dst, $src2}",
1364 [(set GR32:$dst, (xor GR32:$src1, i32immSExt8:$src2))]>;
Bill Wendlingbd0879d2008-05-29 01:02:09 +00001365
Chris Lattner57a02302004-08-11 04:31:00 +00001366let isTwoAddress = 0 in {
Chris Lattner3a173df2004-10-03 20:35:00 +00001367 def XOR8mr : I<0x30, MRMDestMem,
Evan Cheng64d80e32007-07-19 01:14:50 +00001368 (outs), (ins i8mem :$dst, GR8 :$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001369 "xor{b}\t{$src, $dst|$dst, $src}",
Evan Cheng069287d2006-05-16 07:21:53 +00001370 [(store (xor (load addr:$dst), GR8:$src), addr:$dst)]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00001371 def XOR16mr : I<0x31, MRMDestMem,
Evan Cheng64d80e32007-07-19 01:14:50 +00001372 (outs), (ins i16mem:$dst, GR16:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001373 "xor{w}\t{$src, $dst|$dst, $src}",
Evan Cheng069287d2006-05-16 07:21:53 +00001374 [(store (xor (load addr:$dst), GR16:$src), addr:$dst)]>,
Evan Cheng0ef3a772005-12-13 01:41:36 +00001375 OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00001376 def XOR32mr : I<0x31, MRMDestMem,
Evan Cheng64d80e32007-07-19 01:14:50 +00001377 (outs), (ins i32mem:$dst, GR32:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001378 "xor{l}\t{$src, $dst|$dst, $src}",
Evan Cheng069287d2006-05-16 07:21:53 +00001379 [(store (xor (load addr:$dst), GR32:$src), addr:$dst)]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00001380 def XOR8mi : Ii8<0x80, MRM6m,
Evan Cheng64d80e32007-07-19 01:14:50 +00001381 (outs), (ins i8mem :$dst, i8imm :$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001382 "xor{b}\t{$src, $dst|$dst, $src}",
Evan Chengc937ffa2005-12-13 02:40:18 +00001383 [(store (xor (loadi8 addr:$dst), imm:$src), addr:$dst)]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00001384 def XOR16mi : Ii16<0x81, MRM6m,
Evan Cheng64d80e32007-07-19 01:14:50 +00001385 (outs), (ins i16mem:$dst, i16imm:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001386 "xor{w}\t{$src, $dst|$dst, $src}",
Evan Chengc937ffa2005-12-13 02:40:18 +00001387 [(store (xor (loadi16 addr:$dst), imm:$src), addr:$dst)]>,
Evan Cheng0ef3a772005-12-13 01:41:36 +00001388 OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00001389 def XOR32mi : Ii32<0x81, MRM6m,
Evan Cheng64d80e32007-07-19 01:14:50 +00001390 (outs), (ins i32mem:$dst, i32imm:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001391 "xor{l}\t{$src, $dst|$dst, $src}",
Evan Chengc937ffa2005-12-13 02:40:18 +00001392 [(store (xor (loadi32 addr:$dst), imm:$src), addr:$dst)]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00001393 def XOR16mi8 : Ii8<0x83, MRM6m,
Evan Cheng64d80e32007-07-19 01:14:50 +00001394 (outs), (ins i16mem:$dst, i16i8imm :$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001395 "xor{w}\t{$src, $dst|$dst, $src}",
Evan Cheng0ef3a772005-12-13 01:41:36 +00001396 [(store (xor (load addr:$dst), i16immSExt8:$src), addr:$dst)]>,
1397 OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00001398 def XOR32mi8 : Ii8<0x83, MRM6m,
Evan Cheng64d80e32007-07-19 01:14:50 +00001399 (outs), (ins i32mem:$dst, i32i8imm :$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001400 "xor{l}\t{$src, $dst|$dst, $src}",
Evan Cheng0ef3a772005-12-13 01:41:36 +00001401 [(store (xor (load addr:$dst), i32immSExt8:$src), addr:$dst)]>;
Bill Wendlingbd0879d2008-05-29 01:02:09 +00001402} // isTwoAddress = 0
Evan Cheng24f2ea32007-09-14 21:48:26 +00001403} // Defs = [EFLAGS]
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00001404
1405// Shift instructions
Evan Cheng24f2ea32007-09-14 21:48:26 +00001406let Defs = [EFLAGS] in {
Evan Cheng071a2792007-09-11 19:55:27 +00001407let Uses = [CL] in {
Evan Cheng64d80e32007-07-19 01:14:50 +00001408def SHL8rCL : I<0xD2, MRM4r, (outs GR8 :$dst), (ins GR8 :$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001409 "shl{b}\t{%cl, $dst|$dst, %CL}",
Evan Cheng071a2792007-09-11 19:55:27 +00001410 [(set GR8:$dst, (shl GR8:$src, CL))]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00001411def SHL16rCL : I<0xD3, MRM4r, (outs GR16:$dst), (ins GR16:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001412 "shl{w}\t{%cl, $dst|$dst, %CL}",
Evan Cheng071a2792007-09-11 19:55:27 +00001413 [(set GR16:$dst, (shl GR16:$src, CL))]>, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00001414def SHL32rCL : I<0xD3, MRM4r, (outs GR32:$dst), (ins GR32:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001415 "shl{l}\t{%cl, $dst|$dst, %CL}",
Evan Cheng071a2792007-09-11 19:55:27 +00001416 [(set GR32:$dst, (shl GR32:$src, CL))]>;
Bill Wendlingbd0879d2008-05-29 01:02:09 +00001417} // Uses = [CL]
Chris Lattnercc65bee2005-01-02 02:35:46 +00001418
Evan Cheng64d80e32007-07-19 01:14:50 +00001419def SHL8ri : Ii8<0xC0, MRM4r, (outs GR8 :$dst), (ins GR8 :$src1, i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001420 "shl{b}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001421 [(set GR8:$dst, (shl GR8:$src1, (i8 imm:$src2)))]>;
Chris Lattnercc65bee2005-01-02 02:35:46 +00001422let isConvertibleToThreeAddress = 1 in { // Can transform into LEA.
Evan Cheng64d80e32007-07-19 01:14:50 +00001423def SHL16ri : Ii8<0xC1, MRM4r, (outs GR16:$dst), (ins GR16:$src1, i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001424 "shl{w}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001425 [(set GR16:$dst, (shl GR16:$src1, (i8 imm:$src2)))]>, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00001426def SHL32ri : Ii8<0xC1, MRM4r, (outs GR32:$dst), (ins GR32:$src1, i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001427 "shl{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001428 [(set GR32:$dst, (shl GR32:$src1, (i8 imm:$src2)))]>;
Chris Lattnerf9b3f372008-01-11 18:00:50 +00001429// NOTE: We don't use shifts of a register by one, because 'add reg,reg' is
1430// cheaper.
Bill Wendlingbd0879d2008-05-29 01:02:09 +00001431} // isConvertibleToThreeAddress = 1
Evan Cheng09c54572006-06-29 00:36:51 +00001432
Chris Lattnerf29ed092004-08-11 05:07:25 +00001433let isTwoAddress = 0 in {
Evan Cheng071a2792007-09-11 19:55:27 +00001434 let Uses = [CL] in {
Evan Cheng64d80e32007-07-19 01:14:50 +00001435 def SHL8mCL : I<0xD2, MRM4m, (outs), (ins i8mem :$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001436 "shl{b}\t{%cl, $dst|$dst, %CL}",
Evan Cheng071a2792007-09-11 19:55:27 +00001437 [(store (shl (loadi8 addr:$dst), CL), addr:$dst)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00001438 def SHL16mCL : I<0xD3, MRM4m, (outs), (ins i16mem:$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001439 "shl{w}\t{%cl, $dst|$dst, %CL}",
Evan Cheng071a2792007-09-11 19:55:27 +00001440 [(store (shl (loadi16 addr:$dst), CL), addr:$dst)]>, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00001441 def SHL32mCL : I<0xD3, MRM4m, (outs), (ins i32mem:$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001442 "shl{l}\t{%cl, $dst|$dst, %CL}",
Evan Cheng071a2792007-09-11 19:55:27 +00001443 [(store (shl (loadi32 addr:$dst), CL), addr:$dst)]>;
1444 }
Evan Cheng64d80e32007-07-19 01:14:50 +00001445 def SHL8mi : Ii8<0xC0, MRM4m, (outs), (ins i8mem :$dst, i8imm:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001446 "shl{b}\t{$src, $dst|$dst, $src}",
Evan Cheng763b0292005-12-13 02:34:51 +00001447 [(store (shl (loadi8 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00001448 def SHL16mi : Ii8<0xC1, MRM4m, (outs), (ins i16mem:$dst, i8imm:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001449 "shl{w}\t{$src, $dst|$dst, $src}",
Evan Cheng763b0292005-12-13 02:34:51 +00001450 [(store (shl (loadi16 addr:$dst), (i8 imm:$src)), addr:$dst)]>,
1451 OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00001452 def SHL32mi : Ii8<0xC1, MRM4m, (outs), (ins i32mem:$dst, i8imm:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001453 "shl{l}\t{$src, $dst|$dst, $src}",
Evan Cheng763b0292005-12-13 02:34:51 +00001454 [(store (shl (loadi32 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
Evan Cheng09c54572006-06-29 00:36:51 +00001455
1456 // Shift by 1
Evan Cheng64d80e32007-07-19 01:14:50 +00001457 def SHL8m1 : I<0xD0, MRM4m, (outs), (ins i8mem :$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001458 "shl{b}\t$dst",
Evan Cheng09c54572006-06-29 00:36:51 +00001459 [(store (shl (loadi8 addr:$dst), (i8 1)), addr:$dst)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00001460 def SHL16m1 : I<0xD1, MRM4m, (outs), (ins i16mem:$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001461 "shl{w}\t$dst",
Evan Cheng09c54572006-06-29 00:36:51 +00001462 [(store (shl (loadi16 addr:$dst), (i8 1)), addr:$dst)]>,
1463 OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00001464 def SHL32m1 : I<0xD1, MRM4m, (outs), (ins i32mem:$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001465 "shl{l}\t$dst",
Evan Cheng09c54572006-06-29 00:36:51 +00001466 [(store (shl (loadi32 addr:$dst), (i8 1)), addr:$dst)]>;
Chris Lattnerf29ed092004-08-11 05:07:25 +00001467}
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00001468
Evan Cheng071a2792007-09-11 19:55:27 +00001469let Uses = [CL] in {
Evan Cheng64d80e32007-07-19 01:14:50 +00001470def SHR8rCL : I<0xD2, MRM5r, (outs GR8 :$dst), (ins GR8 :$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001471 "shr{b}\t{%cl, $dst|$dst, %CL}",
Evan Cheng071a2792007-09-11 19:55:27 +00001472 [(set GR8:$dst, (srl GR8:$src, CL))]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00001473def SHR16rCL : I<0xD3, MRM5r, (outs GR16:$dst), (ins GR16:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001474 "shr{w}\t{%cl, $dst|$dst, %CL}",
Evan Cheng071a2792007-09-11 19:55:27 +00001475 [(set GR16:$dst, (srl GR16:$src, CL))]>, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00001476def SHR32rCL : I<0xD3, MRM5r, (outs GR32:$dst), (ins GR32:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001477 "shr{l}\t{%cl, $dst|$dst, %CL}",
Evan Cheng071a2792007-09-11 19:55:27 +00001478 [(set GR32:$dst, (srl GR32:$src, CL))]>;
1479}
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00001480
Evan Cheng64d80e32007-07-19 01:14:50 +00001481def SHR8ri : Ii8<0xC0, MRM5r, (outs GR8:$dst), (ins GR8:$src1, i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001482 "shr{b}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001483 [(set GR8:$dst, (srl GR8:$src1, (i8 imm:$src2)))]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00001484def SHR16ri : Ii8<0xC1, MRM5r, (outs GR16:$dst), (ins GR16:$src1, i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001485 "shr{w}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001486 [(set GR16:$dst, (srl GR16:$src1, (i8 imm:$src2)))]>, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00001487def SHR32ri : Ii8<0xC1, MRM5r, (outs GR32:$dst), (ins GR32:$src1, i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001488 "shr{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001489 [(set GR32:$dst, (srl GR32:$src1, (i8 imm:$src2)))]>;
Chris Lattnerf29ed092004-08-11 05:07:25 +00001490
Evan Cheng09c54572006-06-29 00:36:51 +00001491// Shift by 1
Evan Cheng64d80e32007-07-19 01:14:50 +00001492def SHR8r1 : I<0xD0, MRM5r, (outs GR8:$dst), (ins GR8:$src1),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001493 "shr{b}\t$dst",
Evan Cheng09c54572006-06-29 00:36:51 +00001494 [(set GR8:$dst, (srl GR8:$src1, (i8 1)))]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00001495def SHR16r1 : I<0xD1, MRM5r, (outs GR16:$dst), (ins GR16:$src1),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001496 "shr{w}\t$dst",
Evan Cheng09c54572006-06-29 00:36:51 +00001497 [(set GR16:$dst, (srl GR16:$src1, (i8 1)))]>, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00001498def SHR32r1 : I<0xD1, MRM5r, (outs GR32:$dst), (ins GR32:$src1),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001499 "shr{l}\t$dst",
Evan Cheng09c54572006-06-29 00:36:51 +00001500 [(set GR32:$dst, (srl GR32:$src1, (i8 1)))]>;
1501
Chris Lattner57a02302004-08-11 04:31:00 +00001502let isTwoAddress = 0 in {
Evan Cheng071a2792007-09-11 19:55:27 +00001503 let Uses = [CL] in {
Evan Cheng64d80e32007-07-19 01:14:50 +00001504 def SHR8mCL : I<0xD2, MRM5m, (outs), (ins i8mem :$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001505 "shr{b}\t{%cl, $dst|$dst, %CL}",
Evan Cheng071a2792007-09-11 19:55:27 +00001506 [(store (srl (loadi8 addr:$dst), CL), addr:$dst)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00001507 def SHR16mCL : I<0xD3, MRM5m, (outs), (ins i16mem:$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001508 "shr{w}\t{%cl, $dst|$dst, %CL}",
Evan Cheng85dd8892005-12-13 07:24:22 +00001509 [(store (srl (loadi16 addr:$dst), CL), addr:$dst)]>,
Evan Cheng071a2792007-09-11 19:55:27 +00001510 OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00001511 def SHR32mCL : I<0xD3, MRM5m, (outs), (ins i32mem:$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001512 "shr{l}\t{%cl, $dst|$dst, %CL}",
Evan Cheng071a2792007-09-11 19:55:27 +00001513 [(store (srl (loadi32 addr:$dst), CL), addr:$dst)]>;
1514 }
Evan Cheng64d80e32007-07-19 01:14:50 +00001515 def SHR8mi : Ii8<0xC0, MRM5m, (outs), (ins i8mem :$dst, i8imm:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001516 "shr{b}\t{$src, $dst|$dst, $src}",
Evan Cheng85dd8892005-12-13 07:24:22 +00001517 [(store (srl (loadi8 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00001518 def SHR16mi : Ii8<0xC1, MRM5m, (outs), (ins i16mem:$dst, i8imm:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001519 "shr{w}\t{$src, $dst|$dst, $src}",
Evan Cheng85dd8892005-12-13 07:24:22 +00001520 [(store (srl (loadi16 addr:$dst), (i8 imm:$src)), addr:$dst)]>,
1521 OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00001522 def SHR32mi : Ii8<0xC1, MRM5m, (outs), (ins i32mem:$dst, i8imm:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001523 "shr{l}\t{$src, $dst|$dst, $src}",
Evan Cheng85dd8892005-12-13 07:24:22 +00001524 [(store (srl (loadi32 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
Evan Cheng09c54572006-06-29 00:36:51 +00001525
1526 // Shift by 1
Evan Cheng64d80e32007-07-19 01:14:50 +00001527 def SHR8m1 : I<0xD0, MRM5m, (outs), (ins i8mem :$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001528 "shr{b}\t$dst",
Evan Cheng09c54572006-06-29 00:36:51 +00001529 [(store (srl (loadi8 addr:$dst), (i8 1)), addr:$dst)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00001530 def SHR16m1 : I<0xD1, MRM5m, (outs), (ins i16mem:$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001531 "shr{w}\t$dst",
Evan Cheng09c54572006-06-29 00:36:51 +00001532 [(store (srl (loadi16 addr:$dst), (i8 1)), addr:$dst)]>,OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00001533 def SHR32m1 : I<0xD1, MRM5m, (outs), (ins i32mem:$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001534 "shr{l}\t$dst",
Evan Cheng09c54572006-06-29 00:36:51 +00001535 [(store (srl (loadi32 addr:$dst), (i8 1)), addr:$dst)]>;
Chris Lattner57a02302004-08-11 04:31:00 +00001536}
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00001537
Evan Cheng071a2792007-09-11 19:55:27 +00001538let Uses = [CL] in {
Evan Cheng64d80e32007-07-19 01:14:50 +00001539def SAR8rCL : I<0xD2, MRM7r, (outs GR8 :$dst), (ins GR8 :$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001540 "sar{b}\t{%cl, $dst|$dst, %CL}",
Evan Cheng071a2792007-09-11 19:55:27 +00001541 [(set GR8:$dst, (sra GR8:$src, CL))]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00001542def SAR16rCL : I<0xD3, MRM7r, (outs GR16:$dst), (ins GR16:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001543 "sar{w}\t{%cl, $dst|$dst, %CL}",
Evan Cheng071a2792007-09-11 19:55:27 +00001544 [(set GR16:$dst, (sra GR16:$src, CL))]>, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00001545def SAR32rCL : I<0xD3, MRM7r, (outs GR32:$dst), (ins GR32:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001546 "sar{l}\t{%cl, $dst|$dst, %CL}",
Evan Cheng071a2792007-09-11 19:55:27 +00001547 [(set GR32:$dst, (sra GR32:$src, CL))]>;
1548}
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00001549
Evan Cheng64d80e32007-07-19 01:14:50 +00001550def SAR8ri : Ii8<0xC0, MRM7r, (outs GR8 :$dst), (ins GR8 :$src1, i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001551 "sar{b}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001552 [(set GR8:$dst, (sra GR8:$src1, (i8 imm:$src2)))]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00001553def SAR16ri : Ii8<0xC1, MRM7r, (outs GR16:$dst), (ins GR16:$src1, i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001554 "sar{w}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001555 [(set GR16:$dst, (sra GR16:$src1, (i8 imm:$src2)))]>,
Chris Lattner3d36a9f2005-12-05 02:40:25 +00001556 OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00001557def SAR32ri : Ii8<0xC1, MRM7r, (outs GR32:$dst), (ins GR32:$src1, i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001558 "sar{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001559 [(set GR32:$dst, (sra GR32:$src1, (i8 imm:$src2)))]>;
Evan Cheng09c54572006-06-29 00:36:51 +00001560
1561// Shift by 1
Evan Cheng64d80e32007-07-19 01:14:50 +00001562def SAR8r1 : I<0xD0, MRM7r, (outs GR8 :$dst), (ins GR8 :$src1),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001563 "sar{b}\t$dst",
Evan Cheng09c54572006-06-29 00:36:51 +00001564 [(set GR8:$dst, (sra GR8:$src1, (i8 1)))]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00001565def SAR16r1 : I<0xD1, MRM7r, (outs GR16:$dst), (ins GR16:$src1),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001566 "sar{w}\t$dst",
Evan Cheng09c54572006-06-29 00:36:51 +00001567 [(set GR16:$dst, (sra GR16:$src1, (i8 1)))]>, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00001568def SAR32r1 : I<0xD1, MRM7r, (outs GR32:$dst), (ins GR32:$src1),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001569 "sar{l}\t$dst",
Evan Cheng09c54572006-06-29 00:36:51 +00001570 [(set GR32:$dst, (sra GR32:$src1, (i8 1)))]>;
1571
Chris Lattnerf29ed092004-08-11 05:07:25 +00001572let isTwoAddress = 0 in {
Evan Cheng071a2792007-09-11 19:55:27 +00001573 let Uses = [CL] in {
Evan Cheng64d80e32007-07-19 01:14:50 +00001574 def SAR8mCL : I<0xD2, MRM7m, (outs), (ins i8mem :$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001575 "sar{b}\t{%cl, $dst|$dst, %CL}",
Evan Cheng071a2792007-09-11 19:55:27 +00001576 [(store (sra (loadi8 addr:$dst), CL), addr:$dst)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00001577 def SAR16mCL : I<0xD3, MRM7m, (outs), (ins i16mem:$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001578 "sar{w}\t{%cl, $dst|$dst, %CL}",
Evan Cheng071a2792007-09-11 19:55:27 +00001579 [(store (sra (loadi16 addr:$dst), CL), addr:$dst)]>, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00001580 def SAR32mCL : I<0xD3, MRM7m, (outs), (ins i32mem:$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001581 "sar{l}\t{%cl, $dst|$dst, %CL}",
Evan Cheng071a2792007-09-11 19:55:27 +00001582 [(store (sra (loadi32 addr:$dst), CL), addr:$dst)]>;
1583 }
Evan Cheng64d80e32007-07-19 01:14:50 +00001584 def SAR8mi : Ii8<0xC0, MRM7m, (outs), (ins i8mem :$dst, i8imm:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001585 "sar{b}\t{$src, $dst|$dst, $src}",
Evan Cheng85dd8892005-12-13 07:24:22 +00001586 [(store (sra (loadi8 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00001587 def SAR16mi : Ii8<0xC1, MRM7m, (outs), (ins i16mem:$dst, i8imm:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001588 "sar{w}\t{$src, $dst|$dst, $src}",
Evan Cheng85dd8892005-12-13 07:24:22 +00001589 [(store (sra (loadi16 addr:$dst), (i8 imm:$src)), addr:$dst)]>,
1590 OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00001591 def SAR32mi : Ii8<0xC1, MRM7m, (outs), (ins i32mem:$dst, i8imm:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001592 "sar{l}\t{$src, $dst|$dst, $src}",
Evan Cheng85dd8892005-12-13 07:24:22 +00001593 [(store (sra (loadi32 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
Evan Cheng09c54572006-06-29 00:36:51 +00001594
1595 // Shift by 1
Evan Cheng64d80e32007-07-19 01:14:50 +00001596 def SAR8m1 : I<0xD0, MRM7m, (outs), (ins i8mem :$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001597 "sar{b}\t$dst",
Evan Cheng09c54572006-06-29 00:36:51 +00001598 [(store (sra (loadi8 addr:$dst), (i8 1)), addr:$dst)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00001599 def SAR16m1 : I<0xD1, MRM7m, (outs), (ins i16mem:$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001600 "sar{w}\t$dst",
Evan Cheng09c54572006-06-29 00:36:51 +00001601 [(store (sra (loadi16 addr:$dst), (i8 1)), addr:$dst)]>,
1602 OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00001603 def SAR32m1 : I<0xD1, MRM7m, (outs), (ins i32mem:$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001604 "sar{l}\t$dst",
Evan Cheng09c54572006-06-29 00:36:51 +00001605 [(store (sra (loadi32 addr:$dst), (i8 1)), addr:$dst)]>;
Chris Lattnerf29ed092004-08-11 05:07:25 +00001606}
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00001607
Chris Lattner40ff6332005-01-19 07:50:03 +00001608// Rotate instructions
1609// FIXME: provide shorter instructions when imm8 == 1
Evan Cheng071a2792007-09-11 19:55:27 +00001610let Uses = [CL] in {
Evan Cheng64d80e32007-07-19 01:14:50 +00001611def ROL8rCL : I<0xD2, MRM0r, (outs GR8 :$dst), (ins GR8 :$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001612 "rol{b}\t{%cl, $dst|$dst, %CL}",
Evan Cheng071a2792007-09-11 19:55:27 +00001613 [(set GR8:$dst, (rotl GR8:$src, CL))]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00001614def ROL16rCL : I<0xD3, MRM0r, (outs GR16:$dst), (ins GR16:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001615 "rol{w}\t{%cl, $dst|$dst, %CL}",
Evan Cheng071a2792007-09-11 19:55:27 +00001616 [(set GR16:$dst, (rotl GR16:$src, CL))]>, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00001617def ROL32rCL : I<0xD3, MRM0r, (outs GR32:$dst), (ins GR32:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001618 "rol{l}\t{%cl, $dst|$dst, %CL}",
Evan Cheng071a2792007-09-11 19:55:27 +00001619 [(set GR32:$dst, (rotl GR32:$src, CL))]>;
1620}
Chris Lattner40ff6332005-01-19 07:50:03 +00001621
Evan Cheng64d80e32007-07-19 01:14:50 +00001622def ROL8ri : Ii8<0xC0, MRM0r, (outs GR8 :$dst), (ins GR8 :$src1, i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001623 "rol{b}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001624 [(set GR8:$dst, (rotl GR8:$src1, (i8 imm:$src2)))]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00001625def ROL16ri : Ii8<0xC1, MRM0r, (outs GR16:$dst), (ins GR16:$src1, i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001626 "rol{w}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001627 [(set GR16:$dst, (rotl GR16:$src1, (i8 imm:$src2)))]>, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00001628def ROL32ri : Ii8<0xC1, MRM0r, (outs GR32:$dst), (ins GR32:$src1, i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001629 "rol{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001630 [(set GR32:$dst, (rotl GR32:$src1, (i8 imm:$src2)))]>;
Chris Lattner40ff6332005-01-19 07:50:03 +00001631
Evan Cheng09c54572006-06-29 00:36:51 +00001632// Rotate by 1
Evan Cheng64d80e32007-07-19 01:14:50 +00001633def ROL8r1 : I<0xD0, MRM0r, (outs GR8 :$dst), (ins GR8 :$src1),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001634 "rol{b}\t$dst",
Evan Cheng09c54572006-06-29 00:36:51 +00001635 [(set GR8:$dst, (rotl GR8:$src1, (i8 1)))]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00001636def ROL16r1 : I<0xD1, MRM0r, (outs GR16:$dst), (ins GR16:$src1),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001637 "rol{w}\t$dst",
Evan Cheng09c54572006-06-29 00:36:51 +00001638 [(set GR16:$dst, (rotl GR16:$src1, (i8 1)))]>, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00001639def ROL32r1 : I<0xD1, MRM0r, (outs GR32:$dst), (ins GR32:$src1),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001640 "rol{l}\t$dst",
Evan Cheng09c54572006-06-29 00:36:51 +00001641 [(set GR32:$dst, (rotl GR32:$src1, (i8 1)))]>;
1642
Chris Lattner40ff6332005-01-19 07:50:03 +00001643let isTwoAddress = 0 in {
Evan Cheng071a2792007-09-11 19:55:27 +00001644 let Uses = [CL] in {
Evan Cheng64d80e32007-07-19 01:14:50 +00001645 def ROL8mCL : I<0xD2, MRM0m, (outs), (ins i8mem :$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001646 "rol{b}\t{%cl, $dst|$dst, %CL}",
Evan Cheng071a2792007-09-11 19:55:27 +00001647 [(store (rotl (loadi8 addr:$dst), CL), addr:$dst)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00001648 def ROL16mCL : I<0xD3, MRM0m, (outs), (ins i16mem:$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001649 "rol{w}\t{%cl, $dst|$dst, %CL}",
Evan Cheng071a2792007-09-11 19:55:27 +00001650 [(store (rotl (loadi16 addr:$dst), CL), addr:$dst)]>, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00001651 def ROL32mCL : I<0xD3, MRM0m, (outs), (ins i32mem:$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001652 "rol{l}\t{%cl, $dst|$dst, %CL}",
Evan Cheng071a2792007-09-11 19:55:27 +00001653 [(store (rotl (loadi32 addr:$dst), CL), addr:$dst)]>;
1654 }
Evan Cheng64d80e32007-07-19 01:14:50 +00001655 def ROL8mi : Ii8<0xC0, MRM0m, (outs), (ins i8mem :$dst, i8imm:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001656 "rol{b}\t{$src, $dst|$dst, $src}",
Evan Chengeb422a72006-01-11 23:20:05 +00001657 [(store (rotl (loadi8 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00001658 def ROL16mi : Ii8<0xC1, MRM0m, (outs), (ins i16mem:$dst, i8imm:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001659 "rol{w}\t{$src, $dst|$dst, $src}",
Evan Chengeb422a72006-01-11 23:20:05 +00001660 [(store (rotl (loadi16 addr:$dst), (i8 imm:$src)), addr:$dst)]>,
1661 OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00001662 def ROL32mi : Ii8<0xC1, MRM0m, (outs), (ins i32mem:$dst, i8imm:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001663 "rol{l}\t{$src, $dst|$dst, $src}",
Evan Chengeb422a72006-01-11 23:20:05 +00001664 [(store (rotl (loadi32 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
Evan Cheng09c54572006-06-29 00:36:51 +00001665
1666 // Rotate by 1
Evan Cheng64d80e32007-07-19 01:14:50 +00001667 def ROL8m1 : I<0xD0, MRM0m, (outs), (ins i8mem :$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001668 "rol{b}\t$dst",
Evan Cheng09c54572006-06-29 00:36:51 +00001669 [(store (rotl (loadi8 addr:$dst), (i8 1)), addr:$dst)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00001670 def ROL16m1 : I<0xD1, MRM0m, (outs), (ins i16mem:$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001671 "rol{w}\t$dst",
Evan Cheng09c54572006-06-29 00:36:51 +00001672 [(store (rotl (loadi16 addr:$dst), (i8 1)), addr:$dst)]>,
1673 OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00001674 def ROL32m1 : I<0xD1, MRM0m, (outs), (ins i32mem:$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001675 "rol{l}\t$dst",
Evan Cheng09c54572006-06-29 00:36:51 +00001676 [(store (rotl (loadi32 addr:$dst), (i8 1)), addr:$dst)]>;
Chris Lattner40ff6332005-01-19 07:50:03 +00001677}
1678
Evan Cheng071a2792007-09-11 19:55:27 +00001679let Uses = [CL] in {
Evan Cheng64d80e32007-07-19 01:14:50 +00001680def ROR8rCL : I<0xD2, MRM1r, (outs GR8 :$dst), (ins GR8 :$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001681 "ror{b}\t{%cl, $dst|$dst, %CL}",
Evan Cheng071a2792007-09-11 19:55:27 +00001682 [(set GR8:$dst, (rotr GR8:$src, CL))]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00001683def ROR16rCL : I<0xD3, MRM1r, (outs GR16:$dst), (ins GR16:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001684 "ror{w}\t{%cl, $dst|$dst, %CL}",
Evan Cheng071a2792007-09-11 19:55:27 +00001685 [(set GR16:$dst, (rotr GR16:$src, CL))]>, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00001686def ROR32rCL : I<0xD3, MRM1r, (outs GR32:$dst), (ins GR32:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001687 "ror{l}\t{%cl, $dst|$dst, %CL}",
Evan Cheng071a2792007-09-11 19:55:27 +00001688 [(set GR32:$dst, (rotr GR32:$src, CL))]>;
1689}
Chris Lattner40ff6332005-01-19 07:50:03 +00001690
Evan Cheng64d80e32007-07-19 01:14:50 +00001691def ROR8ri : Ii8<0xC0, MRM1r, (outs GR8 :$dst), (ins GR8 :$src1, i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001692 "ror{b}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001693 [(set GR8:$dst, (rotr GR8:$src1, (i8 imm:$src2)))]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00001694def ROR16ri : Ii8<0xC1, MRM1r, (outs GR16:$dst), (ins GR16:$src1, i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001695 "ror{w}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001696 [(set GR16:$dst, (rotr GR16:$src1, (i8 imm:$src2)))]>, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00001697def ROR32ri : Ii8<0xC1, MRM1r, (outs GR32:$dst), (ins GR32:$src1, i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001698 "ror{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001699 [(set GR32:$dst, (rotr GR32:$src1, (i8 imm:$src2)))]>;
Evan Cheng09c54572006-06-29 00:36:51 +00001700
1701// Rotate by 1
Evan Cheng64d80e32007-07-19 01:14:50 +00001702def ROR8r1 : I<0xD0, MRM1r, (outs GR8 :$dst), (ins GR8 :$src1),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001703 "ror{b}\t$dst",
Evan Cheng09c54572006-06-29 00:36:51 +00001704 [(set GR8:$dst, (rotr GR8:$src1, (i8 1)))]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00001705def ROR16r1 : I<0xD1, MRM1r, (outs GR16:$dst), (ins GR16:$src1),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001706 "ror{w}\t$dst",
Evan Cheng09c54572006-06-29 00:36:51 +00001707 [(set GR16:$dst, (rotr GR16:$src1, (i8 1)))]>, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00001708def ROR32r1 : I<0xD1, MRM1r, (outs GR32:$dst), (ins GR32:$src1),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001709 "ror{l}\t$dst",
Evan Cheng09c54572006-06-29 00:36:51 +00001710 [(set GR32:$dst, (rotr GR32:$src1, (i8 1)))]>;
1711
Chris Lattner40ff6332005-01-19 07:50:03 +00001712let isTwoAddress = 0 in {
Evan Cheng071a2792007-09-11 19:55:27 +00001713 let Uses = [CL] in {
Evan Cheng64d80e32007-07-19 01:14:50 +00001714 def ROR8mCL : I<0xD2, MRM1m, (outs), (ins i8mem :$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001715 "ror{b}\t{%cl, $dst|$dst, %CL}",
Evan Cheng071a2792007-09-11 19:55:27 +00001716 [(store (rotr (loadi8 addr:$dst), CL), addr:$dst)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00001717 def ROR16mCL : I<0xD3, MRM1m, (outs), (ins i16mem:$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001718 "ror{w}\t{%cl, $dst|$dst, %CL}",
Evan Cheng071a2792007-09-11 19:55:27 +00001719 [(store (rotr (loadi16 addr:$dst), CL), addr:$dst)]>, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00001720 def ROR32mCL : I<0xD3, MRM1m, (outs), (ins i32mem:$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001721 "ror{l}\t{%cl, $dst|$dst, %CL}",
Evan Cheng071a2792007-09-11 19:55:27 +00001722 [(store (rotr (loadi32 addr:$dst), CL), addr:$dst)]>;
1723 }
Evan Cheng64d80e32007-07-19 01:14:50 +00001724 def ROR8mi : Ii8<0xC0, MRM1m, (outs), (ins i8mem :$dst, i8imm:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001725 "ror{b}\t{$src, $dst|$dst, $src}",
Evan Chengeb422a72006-01-11 23:20:05 +00001726 [(store (rotr (loadi8 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00001727 def ROR16mi : Ii8<0xC1, MRM1m, (outs), (ins i16mem:$dst, i8imm:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001728 "ror{w}\t{$src, $dst|$dst, $src}",
Evan Chengeb422a72006-01-11 23:20:05 +00001729 [(store (rotr (loadi16 addr:$dst), (i8 imm:$src)), addr:$dst)]>,
1730 OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00001731 def ROR32mi : Ii8<0xC1, MRM1m, (outs), (ins i32mem:$dst, i8imm:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001732 "ror{l}\t{$src, $dst|$dst, $src}",
Evan Chengeb422a72006-01-11 23:20:05 +00001733 [(store (rotr (loadi32 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
Evan Cheng09c54572006-06-29 00:36:51 +00001734
1735 // Rotate by 1
Evan Cheng64d80e32007-07-19 01:14:50 +00001736 def ROR8m1 : I<0xD0, MRM1m, (outs), (ins i8mem :$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001737 "ror{b}\t$dst",
Evan Cheng09c54572006-06-29 00:36:51 +00001738 [(store (rotr (loadi8 addr:$dst), (i8 1)), addr:$dst)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00001739 def ROR16m1 : I<0xD1, MRM1m, (outs), (ins i16mem:$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001740 "ror{w}\t$dst",
Evan Cheng09c54572006-06-29 00:36:51 +00001741 [(store (rotr (loadi16 addr:$dst), (i8 1)), addr:$dst)]>,
1742 OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00001743 def ROR32m1 : I<0xD1, MRM1m, (outs), (ins i32mem:$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001744 "ror{l}\t$dst",
Evan Cheng09c54572006-06-29 00:36:51 +00001745 [(store (rotr (loadi32 addr:$dst), (i8 1)), addr:$dst)]>;
Chris Lattner40ff6332005-01-19 07:50:03 +00001746}
1747
1748
1749
1750// Double shift instructions (generalizations of rotate)
Evan Cheng071a2792007-09-11 19:55:27 +00001751let Uses = [CL] in {
Evan Cheng64d80e32007-07-19 01:14:50 +00001752def SHLD32rrCL : I<0xA5, MRMDestReg, (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001753 "shld{l}\t{%cl, $src2, $dst|$dst, $src2, %CL}",
Evan Cheng071a2792007-09-11 19:55:27 +00001754 [(set GR32:$dst, (X86shld GR32:$src1, GR32:$src2, CL))]>, TB;
Evan Cheng64d80e32007-07-19 01:14:50 +00001755def SHRD32rrCL : I<0xAD, MRMDestReg, (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001756 "shrd{l}\t{%cl, $src2, $dst|$dst, $src2, %CL}",
Evan Cheng071a2792007-09-11 19:55:27 +00001757 [(set GR32:$dst, (X86shrd GR32:$src1, GR32:$src2, CL))]>, TB;
Evan Cheng64d80e32007-07-19 01:14:50 +00001758def SHLD16rrCL : I<0xA5, MRMDestReg, (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001759 "shld{w}\t{%cl, $src2, $dst|$dst, $src2, %CL}",
Evan Cheng069287d2006-05-16 07:21:53 +00001760 [(set GR16:$dst, (X86shld GR16:$src1, GR16:$src2, CL))]>,
Evan Cheng071a2792007-09-11 19:55:27 +00001761 TB, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00001762def SHRD16rrCL : I<0xAD, MRMDestReg, (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001763 "shrd{w}\t{%cl, $src2, $dst|$dst, $src2, %CL}",
Evan Cheng069287d2006-05-16 07:21:53 +00001764 [(set GR16:$dst, (X86shrd GR16:$src1, GR16:$src2, CL))]>,
Evan Cheng071a2792007-09-11 19:55:27 +00001765 TB, OpSize;
1766}
Chris Lattner41e431b2005-01-19 07:11:01 +00001767
1768let isCommutable = 1 in { // These instructions commute to each other.
Chris Lattner3a173df2004-10-03 20:35:00 +00001769def SHLD32rri8 : Ii8<0xA4, MRMDestReg,
Evan Cheng64d80e32007-07-19 01:14:50 +00001770 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2, i8imm:$src3),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001771 "shld{l}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Evan Cheng069287d2006-05-16 07:21:53 +00001772 [(set GR32:$dst, (X86shld GR32:$src1, GR32:$src2,
Evan Chenge3413162006-01-09 18:33:28 +00001773 (i8 imm:$src3)))]>,
1774 TB;
Chris Lattner3a173df2004-10-03 20:35:00 +00001775def SHRD32rri8 : Ii8<0xAC, MRMDestReg,
Evan Cheng64d80e32007-07-19 01:14:50 +00001776 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2, i8imm:$src3),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001777 "shrd{l}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Evan Cheng069287d2006-05-16 07:21:53 +00001778 [(set GR32:$dst, (X86shrd GR32:$src1, GR32:$src2,
Evan Chenge3413162006-01-09 18:33:28 +00001779 (i8 imm:$src3)))]>,
1780 TB;
Chris Lattner0df53d22005-01-19 07:31:24 +00001781def SHLD16rri8 : Ii8<0xA4, MRMDestReg,
Evan Cheng64d80e32007-07-19 01:14:50 +00001782 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2, i8imm:$src3),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001783 "shld{w}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Evan Cheng069287d2006-05-16 07:21:53 +00001784 [(set GR16:$dst, (X86shld GR16:$src1, GR16:$src2,
Evan Chenge3413162006-01-09 18:33:28 +00001785 (i8 imm:$src3)))]>,
Chris Lattner0df53d22005-01-19 07:31:24 +00001786 TB, OpSize;
1787def SHRD16rri8 : Ii8<0xAC, MRMDestReg,
Evan Cheng64d80e32007-07-19 01:14:50 +00001788 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2, i8imm:$src3),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001789 "shrd{w}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Evan Cheng069287d2006-05-16 07:21:53 +00001790 [(set GR16:$dst, (X86shrd GR16:$src1, GR16:$src2,
Evan Chenge3413162006-01-09 18:33:28 +00001791 (i8 imm:$src3)))]>,
Chris Lattner0df53d22005-01-19 07:31:24 +00001792 TB, OpSize;
Chris Lattner41e431b2005-01-19 07:11:01 +00001793}
Chris Lattner0e967d42004-08-01 08:13:11 +00001794
Chris Lattner57a02302004-08-11 04:31:00 +00001795let isTwoAddress = 0 in {
Evan Cheng071a2792007-09-11 19:55:27 +00001796 let Uses = [CL] in {
Evan Cheng64d80e32007-07-19 01:14:50 +00001797 def SHLD32mrCL : I<0xA5, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001798 "shld{l}\t{%cl, $src2, $dst|$dst, $src2, %CL}",
Evan Cheng069287d2006-05-16 07:21:53 +00001799 [(store (X86shld (loadi32 addr:$dst), GR32:$src2, CL),
Evan Cheng071a2792007-09-11 19:55:27 +00001800 addr:$dst)]>, TB;
Evan Cheng64d80e32007-07-19 01:14:50 +00001801 def SHRD32mrCL : I<0xAD, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001802 "shrd{l}\t{%cl, $src2, $dst|$dst, $src2, %CL}",
Evan Cheng069287d2006-05-16 07:21:53 +00001803 [(store (X86shrd (loadi32 addr:$dst), GR32:$src2, CL),
Evan Cheng071a2792007-09-11 19:55:27 +00001804 addr:$dst)]>, TB;
1805 }
Chris Lattner3a173df2004-10-03 20:35:00 +00001806 def SHLD32mri8 : Ii8<0xA4, MRMDestMem,
Evan Cheng64d80e32007-07-19 01:14:50 +00001807 (outs), (ins i32mem:$dst, GR32:$src2, i8imm:$src3),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001808 "shld{l}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Evan Cheng069287d2006-05-16 07:21:53 +00001809 [(store (X86shld (loadi32 addr:$dst), GR32:$src2,
Evan Chenge3413162006-01-09 18:33:28 +00001810 (i8 imm:$src3)), addr:$dst)]>,
Chris Lattnerf124d5e2005-11-18 01:04:42 +00001811 TB;
Chris Lattner3a173df2004-10-03 20:35:00 +00001812 def SHRD32mri8 : Ii8<0xAC, MRMDestMem,
Evan Cheng64d80e32007-07-19 01:14:50 +00001813 (outs), (ins i32mem:$dst, GR32:$src2, i8imm:$src3),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001814 "shrd{l}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Evan Cheng069287d2006-05-16 07:21:53 +00001815 [(store (X86shrd (loadi32 addr:$dst), GR32:$src2,
Evan Chenge3413162006-01-09 18:33:28 +00001816 (i8 imm:$src3)), addr:$dst)]>,
Chris Lattnerf124d5e2005-11-18 01:04:42 +00001817 TB;
Chris Lattner0df53d22005-01-19 07:31:24 +00001818
Evan Cheng071a2792007-09-11 19:55:27 +00001819 let Uses = [CL] in {
Evan Cheng64d80e32007-07-19 01:14:50 +00001820 def SHLD16mrCL : I<0xA5, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001821 "shld{w}\t{%cl, $src2, $dst|$dst, $src2, %CL}",
Evan Cheng069287d2006-05-16 07:21:53 +00001822 [(store (X86shld (loadi16 addr:$dst), GR16:$src2, CL),
Evan Cheng071a2792007-09-11 19:55:27 +00001823 addr:$dst)]>, TB, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00001824 def SHRD16mrCL : I<0xAD, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001825 "shrd{w}\t{%cl, $src2, $dst|$dst, $src2, %CL}",
Evan Cheng069287d2006-05-16 07:21:53 +00001826 [(store (X86shrd (loadi16 addr:$dst), GR16:$src2, CL),
Evan Cheng071a2792007-09-11 19:55:27 +00001827 addr:$dst)]>, TB, OpSize;
1828 }
Chris Lattner0df53d22005-01-19 07:31:24 +00001829 def SHLD16mri8 : Ii8<0xA4, MRMDestMem,
Evan Cheng64d80e32007-07-19 01:14:50 +00001830 (outs), (ins i16mem:$dst, GR16:$src2, i8imm:$src3),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001831 "shld{w}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Evan Cheng069287d2006-05-16 07:21:53 +00001832 [(store (X86shld (loadi16 addr:$dst), GR16:$src2,
Evan Chenge3413162006-01-09 18:33:28 +00001833 (i8 imm:$src3)), addr:$dst)]>,
Chris Lattner0df53d22005-01-19 07:31:24 +00001834 TB, OpSize;
1835 def SHRD16mri8 : Ii8<0xAC, MRMDestMem,
Evan Cheng64d80e32007-07-19 01:14:50 +00001836 (outs), (ins i16mem:$dst, GR16:$src2, i8imm:$src3),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001837 "shrd{w}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Evan Cheng069287d2006-05-16 07:21:53 +00001838 [(store (X86shrd (loadi16 addr:$dst), GR16:$src2,
Evan Chenge3413162006-01-09 18:33:28 +00001839 (i8 imm:$src3)), addr:$dst)]>,
Chris Lattner0df53d22005-01-19 07:31:24 +00001840 TB, OpSize;
Chris Lattner57a02302004-08-11 04:31:00 +00001841}
Evan Cheng24f2ea32007-09-14 21:48:26 +00001842} // Defs = [EFLAGS]
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00001843
1844
Chris Lattnercc65bee2005-01-02 02:35:46 +00001845// Arithmetic.
Evan Cheng24f2ea32007-09-14 21:48:26 +00001846let Defs = [EFLAGS] in {
Chris Lattnercc65bee2005-01-02 02:35:46 +00001847let isCommutable = 1 in { // X = ADD Y, Z --> X = ADD Z, Y
Evan Cheng071a2792007-09-11 19:55:27 +00001848def ADD8rr : I<0x00, MRMDestReg, (outs GR8 :$dst),
1849 (ins GR8 :$src1, GR8 :$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001850 "add{b}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001851 [(set GR8:$dst, (add GR8:$src1, GR8:$src2))]>;
Chris Lattnercc65bee2005-01-02 02:35:46 +00001852let isConvertibleToThreeAddress = 1 in { // Can transform into LEA.
Evan Cheng071a2792007-09-11 19:55:27 +00001853def ADD16rr : I<0x01, MRMDestReg, (outs GR16:$dst),
1854 (ins GR16:$src1, GR16:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001855 "add{w}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001856 [(set GR16:$dst, (add GR16:$src1, GR16:$src2))]>, OpSize;
Evan Cheng071a2792007-09-11 19:55:27 +00001857def ADD32rr : I<0x01, MRMDestReg, (outs GR32:$dst),
1858 (ins GR32:$src1, GR32:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001859 "add{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001860 [(set GR32:$dst, (add GR32:$src1, GR32:$src2))]>;
Chris Lattnercc65bee2005-01-02 02:35:46 +00001861} // end isConvertibleToThreeAddress
1862} // end isCommutable
Evan Cheng071a2792007-09-11 19:55:27 +00001863def ADD8rm : I<0x02, MRMSrcMem, (outs GR8 :$dst),
1864 (ins GR8 :$src1, i8mem :$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001865 "add{b}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001866 [(set GR8:$dst, (add GR8:$src1, (load addr:$src2)))]>;
Evan Cheng071a2792007-09-11 19:55:27 +00001867def ADD16rm : I<0x03, MRMSrcMem, (outs GR16:$dst),
1868 (ins GR16:$src1, i16mem:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001869 "add{w}\t{$src2, $dst|$dst, $src2}",
Evan Cheng071a2792007-09-11 19:55:27 +00001870 [(set GR16:$dst, (add GR16:$src1, (load addr:$src2)))]>,OpSize;
1871def ADD32rm : I<0x03, MRMSrcMem, (outs GR32:$dst),
1872 (ins GR32:$src1, i32mem:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001873 "add{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001874 [(set GR32:$dst, (add GR32:$src1, (load addr:$src2)))]>;
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00001875
Evan Cheng64d80e32007-07-19 01:14:50 +00001876def ADD8ri : Ii8<0x80, MRM0r, (outs GR8:$dst), (ins GR8:$src1, i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001877 "add{b}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001878 [(set GR8:$dst, (add GR8:$src1, imm:$src2))]>;
Chris Lattnercc65bee2005-01-02 02:35:46 +00001879
1880let isConvertibleToThreeAddress = 1 in { // Can transform into LEA.
Evan Cheng071a2792007-09-11 19:55:27 +00001881def ADD16ri : Ii16<0x81, MRM0r, (outs GR16:$dst),
1882 (ins GR16:$src1, i16imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001883 "add{w}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001884 [(set GR16:$dst, (add GR16:$src1, imm:$src2))]>, OpSize;
Evan Cheng071a2792007-09-11 19:55:27 +00001885def ADD32ri : Ii32<0x81, MRM0r, (outs GR32:$dst),
1886 (ins GR32:$src1, i32imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001887 "add{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001888 [(set GR32:$dst, (add GR32:$src1, imm:$src2))]>;
Evan Cheng071a2792007-09-11 19:55:27 +00001889def ADD16ri8 : Ii8<0x83, MRM0r, (outs GR16:$dst),
1890 (ins GR16:$src1, i16i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001891 "add{w}\t{$src2, $dst|$dst, $src2}",
Evan Cheng071a2792007-09-11 19:55:27 +00001892 [(set GR16:$dst, (add GR16:$src1, i16immSExt8:$src2))]>, OpSize;
1893def ADD32ri8 : Ii8<0x83, MRM0r, (outs GR32:$dst),
1894 (ins GR32:$src1, i32i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001895 "add{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng071a2792007-09-11 19:55:27 +00001896 [(set GR32:$dst, (add GR32:$src1, i32immSExt8:$src2))]>;
Evan Cheng09e3c802006-05-19 18:40:54 +00001897}
Chris Lattner57a02302004-08-11 04:31:00 +00001898
1899let isTwoAddress = 0 in {
Evan Cheng64d80e32007-07-19 01:14:50 +00001900 def ADD8mr : I<0x00, MRMDestMem, (outs), (ins i8mem :$dst, GR8 :$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001901 "add{b}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001902 [(store (add (load addr:$dst), GR8:$src2), addr:$dst)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00001903 def ADD16mr : I<0x01, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001904 "add{w}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001905 [(store (add (load addr:$dst), GR16:$src2), addr:$dst)]>,
Evan Cheng24f2ea32007-09-14 21:48:26 +00001906 OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00001907 def ADD32mr : I<0x01, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001908 "add{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001909 [(store (add (load addr:$dst), GR32:$src2), addr:$dst)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00001910 def ADD8mi : Ii8<0x80, MRM0m, (outs), (ins i8mem :$dst, i8imm :$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001911 "add{b}\t{$src2, $dst|$dst, $src2}",
Evan Chengc937ffa2005-12-13 02:40:18 +00001912 [(store (add (loadi8 addr:$dst), imm:$src2), addr:$dst)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00001913 def ADD16mi : Ii16<0x81, MRM0m, (outs), (ins i16mem:$dst, i16imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001914 "add{w}\t{$src2, $dst|$dst, $src2}",
Evan Chengc937ffa2005-12-13 02:40:18 +00001915 [(store (add (loadi16 addr:$dst), imm:$src2), addr:$dst)]>,
Evan Cheng24f2ea32007-09-14 21:48:26 +00001916 OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00001917 def ADD32mi : Ii32<0x81, MRM0m, (outs), (ins i32mem:$dst, i32imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001918 "add{l}\t{$src2, $dst|$dst, $src2}",
Evan Chengc937ffa2005-12-13 02:40:18 +00001919 [(store (add (loadi32 addr:$dst), imm:$src2), addr:$dst)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00001920 def ADD16mi8 : Ii8<0x83, MRM0m, (outs), (ins i16mem:$dst, i16i8imm :$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001921 "add{w}\t{$src2, $dst|$dst, $src2}",
Evan Cheng9b6b6422005-12-13 00:14:11 +00001922 [(store (add (load addr:$dst), i16immSExt8:$src2), addr:$dst)]>,
Evan Cheng24f2ea32007-09-14 21:48:26 +00001923 OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00001924 def ADD32mi8 : Ii8<0x83, MRM0m, (outs), (ins i32mem:$dst, i32i8imm :$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001925 "add{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng9b6b6422005-12-13 00:14:11 +00001926 [(store (add (load addr:$dst), i32immSExt8:$src2), addr:$dst)]>;
Chris Lattner57a02302004-08-11 04:31:00 +00001927}
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00001928
Evan Cheng3154cb62007-10-05 17:59:57 +00001929let Uses = [EFLAGS] in {
Chris Lattner10197ff2005-01-03 01:27:59 +00001930let isCommutable = 1 in { // X = ADC Y, Z --> X = ADC Z, Y
Evan Cheng64d80e32007-07-19 01:14:50 +00001931def ADC32rr : I<0x11, MRMDestReg, (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001932 "adc{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001933 [(set GR32:$dst, (adde GR32:$src1, GR32:$src2))]>;
Chris Lattner10197ff2005-01-03 01:27:59 +00001934}
Evan Cheng64d80e32007-07-19 01:14:50 +00001935def ADC32rm : I<0x13, MRMSrcMem , (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001936 "adc{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001937 [(set GR32:$dst, (adde GR32:$src1, (load addr:$src2)))]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00001938def ADC32ri : Ii32<0x81, MRM2r, (outs GR32:$dst), (ins GR32:$src1, i32imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001939 "adc{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001940 [(set GR32:$dst, (adde GR32:$src1, imm:$src2))]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00001941def ADC32ri8 : Ii8<0x83, MRM2r, (outs GR32:$dst), (ins GR32:$src1, i32i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001942 "adc{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001943 [(set GR32:$dst, (adde GR32:$src1, i32immSExt8:$src2))]>;
Chris Lattner57a02302004-08-11 04:31:00 +00001944
1945let isTwoAddress = 0 in {
Evan Cheng64d80e32007-07-19 01:14:50 +00001946 def ADC32mr : I<0x11, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001947 "adc{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001948 [(store (adde (load addr:$dst), GR32:$src2), addr:$dst)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00001949 def ADC32mi : Ii32<0x81, MRM2m, (outs), (ins i32mem:$dst, i32imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001950 "adc{l}\t{$src2, $dst|$dst, $src2}",
Nate Begeman551bf3f2006-02-17 05:43:56 +00001951 [(store (adde (loadi32 addr:$dst), imm:$src2), addr:$dst)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00001952 def ADC32mi8 : Ii8<0x83, MRM2m, (outs), (ins i32mem:$dst, i32i8imm :$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001953 "adc{l}\t{$src2, $dst|$dst, $src2}",
Nate Begeman551bf3f2006-02-17 05:43:56 +00001954 [(store (adde (load addr:$dst), i32immSExt8:$src2), addr:$dst)]>;
Chris Lattner57a02302004-08-11 04:31:00 +00001955}
Evan Cheng3154cb62007-10-05 17:59:57 +00001956} // Uses = [EFLAGS]
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00001957
Evan Cheng64d80e32007-07-19 01:14:50 +00001958def SUB8rr : I<0x28, MRMDestReg, (outs GR8 :$dst), (ins GR8 :$src1, GR8 :$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001959 "sub{b}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001960 [(set GR8:$dst, (sub GR8:$src1, GR8:$src2))]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00001961def SUB16rr : I<0x29, MRMDestReg, (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001962 "sub{w}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001963 [(set GR16:$dst, (sub GR16:$src1, GR16:$src2))]>, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00001964def SUB32rr : I<0x29, MRMDestReg, (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001965 "sub{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001966 [(set GR32:$dst, (sub GR32:$src1, GR32:$src2))]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00001967def SUB8rm : I<0x2A, MRMSrcMem, (outs GR8 :$dst), (ins GR8 :$src1, i8mem :$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001968 "sub{b}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001969 [(set GR8:$dst, (sub GR8:$src1, (load addr:$src2)))]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00001970def SUB16rm : I<0x2B, MRMSrcMem, (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001971 "sub{w}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001972 [(set GR16:$dst, (sub GR16:$src1, (load addr:$src2)))]>, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00001973def SUB32rm : I<0x2B, MRMSrcMem, (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001974 "sub{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001975 [(set GR32:$dst, (sub GR32:$src1, (load addr:$src2)))]>;
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00001976
Evan Cheng64d80e32007-07-19 01:14:50 +00001977def SUB8ri : Ii8 <0x80, MRM5r, (outs GR8:$dst), (ins GR8:$src1, i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001978 "sub{b}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001979 [(set GR8:$dst, (sub GR8:$src1, imm:$src2))]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00001980def SUB16ri : Ii16<0x81, MRM5r, (outs GR16:$dst), (ins GR16:$src1, i16imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001981 "sub{w}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001982 [(set GR16:$dst, (sub GR16:$src1, imm:$src2))]>, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00001983def SUB32ri : Ii32<0x81, MRM5r, (outs GR32:$dst), (ins GR32:$src1, i32imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001984 "sub{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001985 [(set GR32:$dst, (sub GR32:$src1, imm:$src2))]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00001986def SUB16ri8 : Ii8<0x83, MRM5r, (outs GR16:$dst), (ins GR16:$src1, i16i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001987 "sub{w}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001988 [(set GR16:$dst, (sub GR16:$src1, i16immSExt8:$src2))]>,
Evan Cheng24f2ea32007-09-14 21:48:26 +00001989 OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00001990def SUB32ri8 : Ii8<0x83, MRM5r, (outs GR32:$dst), (ins GR32:$src1, i32i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001991 "sub{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001992 [(set GR32:$dst, (sub GR32:$src1, i32immSExt8:$src2))]>;
Chris Lattner57a02302004-08-11 04:31:00 +00001993let isTwoAddress = 0 in {
Evan Cheng64d80e32007-07-19 01:14:50 +00001994 def SUB8mr : I<0x28, MRMDestMem, (outs), (ins i8mem :$dst, GR8 :$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001995 "sub{b}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001996 [(store (sub (load addr:$dst), GR8:$src2), addr:$dst)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00001997 def SUB16mr : I<0x29, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001998 "sub{w}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001999 [(store (sub (load addr:$dst), GR16:$src2), addr:$dst)]>,
Evan Cheng24f2ea32007-09-14 21:48:26 +00002000 OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00002001 def SUB32mr : I<0x29, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002002 "sub{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00002003 [(store (sub (load addr:$dst), GR32:$src2), addr:$dst)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00002004 def SUB8mi : Ii8<0x80, MRM5m, (outs), (ins i8mem :$dst, i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002005 "sub{b}\t{$src2, $dst|$dst, $src2}",
Evan Chengc937ffa2005-12-13 02:40:18 +00002006 [(store (sub (loadi8 addr:$dst), imm:$src2), addr:$dst)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00002007 def SUB16mi : Ii16<0x81, MRM5m, (outs), (ins i16mem:$dst, i16imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002008 "sub{w}\t{$src2, $dst|$dst, $src2}",
Evan Chengc937ffa2005-12-13 02:40:18 +00002009 [(store (sub (loadi16 addr:$dst), imm:$src2), addr:$dst)]>,
Evan Cheng24f2ea32007-09-14 21:48:26 +00002010 OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00002011 def SUB32mi : Ii32<0x81, MRM5m, (outs), (ins i32mem:$dst, i32imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002012 "sub{l}\t{$src2, $dst|$dst, $src2}",
Evan Chengc937ffa2005-12-13 02:40:18 +00002013 [(store (sub (loadi32 addr:$dst), imm:$src2), addr:$dst)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00002014 def SUB16mi8 : Ii8<0x83, MRM5m, (outs), (ins i16mem:$dst, i16i8imm :$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002015 "sub{w}\t{$src2, $dst|$dst, $src2}",
Evan Cheng9b6b6422005-12-13 00:14:11 +00002016 [(store (sub (load addr:$dst), i16immSExt8:$src2), addr:$dst)]>,
Evan Cheng24f2ea32007-09-14 21:48:26 +00002017 OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00002018 def SUB32mi8 : Ii8<0x83, MRM5m, (outs), (ins i32mem:$dst, i32i8imm :$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002019 "sub{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng9b6b6422005-12-13 00:14:11 +00002020 [(store (sub (load addr:$dst), i32immSExt8:$src2), addr:$dst)]>;
Chris Lattner57a02302004-08-11 04:31:00 +00002021}
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00002022
Evan Cheng3154cb62007-10-05 17:59:57 +00002023let Uses = [EFLAGS] in {
Evan Cheng64d80e32007-07-19 01:14:50 +00002024def SBB32rr : I<0x19, MRMDestReg, (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002025 "sbb{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng24f2ea32007-09-14 21:48:26 +00002026 [(set GR32:$dst, (sube GR32:$src1, GR32:$src2))]>;
Chris Lattnerd93d3b02004-10-06 04:01:02 +00002027
Chris Lattner57a02302004-08-11 04:31:00 +00002028let isTwoAddress = 0 in {
Evan Cheng64d80e32007-07-19 01:14:50 +00002029 def SBB32mr : I<0x19, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002030 "sbb{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00002031 [(store (sube (load addr:$dst), GR32:$src2), addr:$dst)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00002032 def SBB8mi : Ii32<0x80, MRM3m, (outs), (ins i8mem:$dst, i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002033 "sbb{b}\t{$src2, $dst|$dst, $src2}",
Nate Begeman551bf3f2006-02-17 05:43:56 +00002034 [(store (sube (loadi8 addr:$dst), imm:$src2), addr:$dst)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00002035 def SBB32mi : Ii32<0x81, MRM3m, (outs), (ins i32mem:$dst, i32imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002036 "sbb{l}\t{$src2, $dst|$dst, $src2}",
Nate Begeman551bf3f2006-02-17 05:43:56 +00002037 [(store (sube (loadi32 addr:$dst), imm:$src2), addr:$dst)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00002038 def SBB32mi8 : Ii8<0x83, MRM3m, (outs), (ins i32mem:$dst, i32i8imm :$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002039 "sbb{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng24f2ea32007-09-14 21:48:26 +00002040 [(store (sube (load addr:$dst), i32immSExt8:$src2), addr:$dst)]>;
Chris Lattner57a02302004-08-11 04:31:00 +00002041}
Evan Cheng64d80e32007-07-19 01:14:50 +00002042def SBB32rm : I<0x1B, MRMSrcMem, (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002043 "sbb{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00002044 [(set GR32:$dst, (sube GR32:$src1, (load addr:$src2)))]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00002045def SBB32ri : Ii32<0x81, MRM3r, (outs GR32:$dst), (ins GR32:$src1, i32imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002046 "sbb{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00002047 [(set GR32:$dst, (sube GR32:$src1, imm:$src2))]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00002048def SBB32ri8 : Ii8<0x83, MRM3r, (outs GR32:$dst), (ins GR32:$src1, i32i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002049 "sbb{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00002050 [(set GR32:$dst, (sube GR32:$src1, i32immSExt8:$src2))]>;
Evan Cheng3154cb62007-10-05 17:59:57 +00002051} // Uses = [EFLAGS]
Evan Cheng24f2ea32007-09-14 21:48:26 +00002052} // Defs = [EFLAGS]
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00002053
Evan Cheng24f2ea32007-09-14 21:48:26 +00002054let Defs = [EFLAGS] in {
Chris Lattner10197ff2005-01-03 01:27:59 +00002055let isCommutable = 1 in { // X = IMUL Y, Z --> X = IMUL Z, Y
Evan Cheng64d80e32007-07-19 01:14:50 +00002056def IMUL16rr : I<0xAF, MRMSrcReg, (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002057 "imul{w}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00002058 [(set GR16:$dst, (mul GR16:$src1, GR16:$src2))]>, TB, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00002059def IMUL32rr : I<0xAF, MRMSrcReg, (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002060 "imul{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00002061 [(set GR32:$dst, (mul GR32:$src1, GR32:$src2))]>, TB;
Chris Lattner10197ff2005-01-03 01:27:59 +00002062}
Evan Cheng64d80e32007-07-19 01:14:50 +00002063def IMUL16rm : I<0xAF, MRMSrcMem, (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002064 "imul{w}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00002065 [(set GR16:$dst, (mul GR16:$src1, (load addr:$src2)))]>,
Evan Cheng9b6b6422005-12-13 00:14:11 +00002066 TB, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00002067def IMUL32rm : I<0xAF, MRMSrcMem, (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002068 "imul{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00002069 [(set GR32:$dst, (mul GR32:$src1, (load addr:$src2)))]>, TB;
Evan Cheng24f2ea32007-09-14 21:48:26 +00002070} // Defs = [EFLAGS]
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00002071} // end Two Address instructions
2072
Chris Lattnerf5d3a832004-08-11 05:31:07 +00002073// Suprisingly enough, these are not two address instructions!
Evan Cheng24f2ea32007-09-14 21:48:26 +00002074let Defs = [EFLAGS] in {
Evan Cheng069287d2006-05-16 07:21:53 +00002075def IMUL16rri : Ii16<0x69, MRMSrcReg, // GR16 = GR16*I16
Evan Cheng64d80e32007-07-19 01:14:50 +00002076 (outs GR16:$dst), (ins GR16:$src1, i16imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002077 "imul{w}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00002078 [(set GR16:$dst, (mul GR16:$src1, imm:$src2))]>, OpSize;
2079def IMUL32rri : Ii32<0x69, MRMSrcReg, // GR32 = GR32*I32
Evan Cheng64d80e32007-07-19 01:14:50 +00002080 (outs GR32:$dst), (ins GR32:$src1, i32imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002081 "imul{l}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00002082 [(set GR32:$dst, (mul GR32:$src1, imm:$src2))]>;
2083def IMUL16rri8 : Ii8<0x6B, MRMSrcReg, // GR16 = GR16*I8
Evan Cheng64d80e32007-07-19 01:14:50 +00002084 (outs GR16:$dst), (ins GR16:$src1, i16i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002085 "imul{w}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00002086 [(set GR16:$dst, (mul GR16:$src1, i16immSExt8:$src2))]>,
Evan Cheng9b6b6422005-12-13 00:14:11 +00002087 OpSize;
Evan Cheng069287d2006-05-16 07:21:53 +00002088def IMUL32rri8 : Ii8<0x6B, MRMSrcReg, // GR32 = GR32*I8
Evan Cheng64d80e32007-07-19 01:14:50 +00002089 (outs GR32:$dst), (ins GR32:$src1, i32i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002090 "imul{l}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00002091 [(set GR32:$dst, (mul GR32:$src1, i32immSExt8:$src2))]>;
Chris Lattnerf5d3a832004-08-11 05:31:07 +00002092
Evan Cheng069287d2006-05-16 07:21:53 +00002093def IMUL16rmi : Ii16<0x69, MRMSrcMem, // GR16 = [mem16]*I16
Evan Cheng64d80e32007-07-19 01:14:50 +00002094 (outs GR16:$dst), (ins i16mem:$src1, i16imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002095 "imul{w}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00002096 [(set GR16:$dst, (mul (load addr:$src1), imm:$src2))]>,
Evan Chengf281e022005-12-12 23:47:46 +00002097 OpSize;
Evan Cheng069287d2006-05-16 07:21:53 +00002098def IMUL32rmi : Ii32<0x69, MRMSrcMem, // GR32 = [mem32]*I32
Evan Cheng64d80e32007-07-19 01:14:50 +00002099 (outs GR32:$dst), (ins i32mem:$src1, i32imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002100 "imul{l}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00002101 [(set GR32:$dst, (mul (load addr:$src1), imm:$src2))]>;
2102def IMUL16rmi8 : Ii8<0x6B, MRMSrcMem, // GR16 = [mem16]*I8
Evan Cheng64d80e32007-07-19 01:14:50 +00002103 (outs GR16:$dst), (ins i16mem:$src1, i16i8imm :$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002104 "imul{w}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00002105 [(set GR16:$dst, (mul (load addr:$src1), i16immSExt8:$src2))]>,
Evan Cheng9b6b6422005-12-13 00:14:11 +00002106 OpSize;
Evan Cheng069287d2006-05-16 07:21:53 +00002107def IMUL32rmi8 : Ii8<0x6B, MRMSrcMem, // GR32 = [mem32]*I8
Evan Cheng64d80e32007-07-19 01:14:50 +00002108 (outs GR32:$dst), (ins i32mem:$src1, i32i8imm: $src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002109 "imul{l}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00002110 [(set GR32:$dst, (mul (load addr:$src1), i32immSExt8:$src2))]>;
Evan Cheng24f2ea32007-09-14 21:48:26 +00002111} // Defs = [EFLAGS]
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00002112
2113//===----------------------------------------------------------------------===//
2114// Test instructions are just like AND, except they don't generate a result.
Chris Lattner3a173df2004-10-03 20:35:00 +00002115//
Evan Cheng0488db92007-09-25 01:57:46 +00002116let Defs = [EFLAGS] in {
Chris Lattnercc65bee2005-01-02 02:35:46 +00002117let isCommutable = 1 in { // TEST X, Y --> TEST Y, X
Evan Cheng64d80e32007-07-19 01:14:50 +00002118def TEST8rr : I<0x84, MRMDestReg, (outs), (ins GR8:$src1, GR8:$src2),
Evan Chenge5f62042007-09-29 00:00:36 +00002119 "test{b}\t{$src2, $src1|$src1, $src2}",
Chris Lattnerce2bcc82008-02-19 17:37:35 +00002120 [(X86cmp (and_su GR8:$src1, GR8:$src2), 0),
Evan Chenge5f62042007-09-29 00:00:36 +00002121 (implicit EFLAGS)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00002122def TEST16rr : I<0x85, MRMDestReg, (outs), (ins GR16:$src1, GR16:$src2),
Evan Chenge5f62042007-09-29 00:00:36 +00002123 "test{w}\t{$src2, $src1|$src1, $src2}",
Chris Lattnerce2bcc82008-02-19 17:37:35 +00002124 [(X86cmp (and_su GR16:$src1, GR16:$src2), 0),
Evan Chenge5f62042007-09-29 00:00:36 +00002125 (implicit EFLAGS)]>,
2126 OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00002127def TEST32rr : I<0x85, MRMDestReg, (outs), (ins GR32:$src1, GR32:$src2),
Evan Chenge5f62042007-09-29 00:00:36 +00002128 "test{l}\t{$src2, $src1|$src1, $src2}",
Chris Lattnerce2bcc82008-02-19 17:37:35 +00002129 [(X86cmp (and_su GR32:$src1, GR32:$src2), 0),
Evan Chenge5f62042007-09-29 00:00:36 +00002130 (implicit EFLAGS)]>;
Chris Lattnercc65bee2005-01-02 02:35:46 +00002131}
Evan Cheng734503b2006-09-11 02:19:56 +00002132
Evan Cheng64d80e32007-07-19 01:14:50 +00002133def TEST8rm : I<0x84, MRMSrcMem, (outs), (ins GR8 :$src1, i8mem :$src2),
Evan Chenge5f62042007-09-29 00:00:36 +00002134 "test{b}\t{$src2, $src1|$src1, $src2}",
2135 [(X86cmp (and GR8:$src1, (loadi8 addr:$src2)), 0),
2136 (implicit EFLAGS)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00002137def TEST16rm : I<0x85, MRMSrcMem, (outs), (ins GR16:$src1, i16mem:$src2),
Evan Chenge5f62042007-09-29 00:00:36 +00002138 "test{w}\t{$src2, $src1|$src1, $src2}",
2139 [(X86cmp (and GR16:$src1, (loadi16 addr:$src2)), 0),
2140 (implicit EFLAGS)]>, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00002141def TEST32rm : I<0x85, MRMSrcMem, (outs), (ins GR32:$src1, i32mem:$src2),
Evan Chenge5f62042007-09-29 00:00:36 +00002142 "test{l}\t{$src2, $src1|$src1, $src2}",
2143 [(X86cmp (and GR32:$src1, (loadi32 addr:$src2)), 0),
2144 (implicit EFLAGS)]>;
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00002145
Evan Cheng069287d2006-05-16 07:21:53 +00002146def TEST8ri : Ii8 <0xF6, MRM0r, // flags = GR8 & imm8
Evan Cheng64d80e32007-07-19 01:14:50 +00002147 (outs), (ins GR8:$src1, i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002148 "test{b}\t{$src2, $src1|$src1, $src2}",
Chris Lattnerce2bcc82008-02-19 17:37:35 +00002149 [(X86cmp (and_su GR8:$src1, imm:$src2), 0),
Evan Chenge5f62042007-09-29 00:00:36 +00002150 (implicit EFLAGS)]>;
Evan Cheng069287d2006-05-16 07:21:53 +00002151def TEST16ri : Ii16<0xF7, MRM0r, // flags = GR16 & imm16
Evan Cheng64d80e32007-07-19 01:14:50 +00002152 (outs), (ins GR16:$src1, i16imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002153 "test{w}\t{$src2, $src1|$src1, $src2}",
Chris Lattnerce2bcc82008-02-19 17:37:35 +00002154 [(X86cmp (and_su GR16:$src1, imm:$src2), 0),
Evan Chenge5f62042007-09-29 00:00:36 +00002155 (implicit EFLAGS)]>, OpSize;
Evan Cheng069287d2006-05-16 07:21:53 +00002156def TEST32ri : Ii32<0xF7, MRM0r, // flags = GR32 & imm32
Evan Cheng64d80e32007-07-19 01:14:50 +00002157 (outs), (ins GR32:$src1, i32imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002158 "test{l}\t{$src2, $src1|$src1, $src2}",
Chris Lattnerce2bcc82008-02-19 17:37:35 +00002159 [(X86cmp (and_su GR32:$src1, imm:$src2), 0),
Evan Chenge5f62042007-09-29 00:00:36 +00002160 (implicit EFLAGS)]>;
Evan Cheng734503b2006-09-11 02:19:56 +00002161
Evan Chenge5f62042007-09-29 00:00:36 +00002162def TEST8mi : Ii8 <0xF6, MRM0m, // flags = [mem8] & imm8
Evan Cheng64d80e32007-07-19 01:14:50 +00002163 (outs), (ins i8mem:$src1, i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002164 "test{b}\t{$src2, $src1|$src1, $src2}",
Evan Chenge5f62042007-09-29 00:00:36 +00002165 [(X86cmp (and (loadi8 addr:$src1), imm:$src2), 0),
2166 (implicit EFLAGS)]>;
2167def TEST16mi : Ii16<0xF7, MRM0m, // flags = [mem16] & imm16
Evan Cheng64d80e32007-07-19 01:14:50 +00002168 (outs), (ins i16mem:$src1, i16imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002169 "test{w}\t{$src2, $src1|$src1, $src2}",
Evan Chenge5f62042007-09-29 00:00:36 +00002170 [(X86cmp (and (loadi16 addr:$src1), imm:$src2), 0),
2171 (implicit EFLAGS)]>, OpSize;
2172def TEST32mi : Ii32<0xF7, MRM0m, // flags = [mem32] & imm32
Evan Cheng64d80e32007-07-19 01:14:50 +00002173 (outs), (ins i32mem:$src1, i32imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002174 "test{l}\t{$src2, $src1|$src1, $src2}",
Evan Chenge5f62042007-09-29 00:00:36 +00002175 [(X86cmp (and (loadi32 addr:$src1), imm:$src2), 0),
Evan Cheng0488db92007-09-25 01:57:46 +00002176 (implicit EFLAGS)]>;
2177} // Defs = [EFLAGS]
2178
2179
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00002180// Condition code ops, incl. set if equal/not equal/...
Chris Lattnerba7e7562008-01-10 07:59:24 +00002181let Defs = [EFLAGS], Uses = [AH], neverHasSideEffects = 1 in
Evan Cheng071a2792007-09-11 19:55:27 +00002182def SAHF : I<0x9E, RawFrm, (outs), (ins), "sahf", []>; // flags = AH
Chris Lattnerba7e7562008-01-10 07:59:24 +00002183let Defs = [AH], Uses = [EFLAGS], neverHasSideEffects = 1 in
Evan Cheng071a2792007-09-11 19:55:27 +00002184def LAHF : I<0x9F, RawFrm, (outs), (ins), "lahf", []>; // AH = flags
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00002185
Evan Cheng0488db92007-09-25 01:57:46 +00002186let Uses = [EFLAGS] in {
Chris Lattner3a173df2004-10-03 20:35:00 +00002187def SETEr : I<0x94, MRM0r,
Evan Cheng64d80e32007-07-19 01:14:50 +00002188 (outs GR8 :$dst), (ins),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002189 "sete\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +00002190 [(set GR8:$dst, (X86setcc X86_COND_E, EFLAGS))]>,
Evan Cheng069287d2006-05-16 07:21:53 +00002191 TB; // GR8 = ==
Chris Lattner3a173df2004-10-03 20:35:00 +00002192def SETEm : I<0x94, MRM0m,
Evan Cheng64d80e32007-07-19 01:14:50 +00002193 (outs), (ins i8mem:$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002194 "sete\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +00002195 [(store (X86setcc X86_COND_E, EFLAGS), addr:$dst)]>,
Evan Chengd5781fc2005-12-21 20:21:51 +00002196 TB; // [mem8] = ==
Chris Lattner3a173df2004-10-03 20:35:00 +00002197def SETNEr : I<0x95, MRM0r,
Evan Cheng64d80e32007-07-19 01:14:50 +00002198 (outs GR8 :$dst), (ins),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002199 "setne\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +00002200 [(set GR8:$dst, (X86setcc X86_COND_NE, EFLAGS))]>,
Evan Cheng069287d2006-05-16 07:21:53 +00002201 TB; // GR8 = !=
Chris Lattner3a173df2004-10-03 20:35:00 +00002202def SETNEm : I<0x95, MRM0m,
Evan Cheng64d80e32007-07-19 01:14:50 +00002203 (outs), (ins i8mem:$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002204 "setne\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +00002205 [(store (X86setcc X86_COND_NE, EFLAGS), addr:$dst)]>,
Evan Chengd5781fc2005-12-21 20:21:51 +00002206 TB; // [mem8] = !=
2207def SETLr : I<0x9C, MRM0r,
Evan Cheng64d80e32007-07-19 01:14:50 +00002208 (outs GR8 :$dst), (ins),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002209 "setl\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +00002210 [(set GR8:$dst, (X86setcc X86_COND_L, EFLAGS))]>,
Evan Cheng069287d2006-05-16 07:21:53 +00002211 TB; // GR8 = < signed
Evan Chengd5781fc2005-12-21 20:21:51 +00002212def SETLm : I<0x9C, MRM0m,
Evan Cheng64d80e32007-07-19 01:14:50 +00002213 (outs), (ins i8mem:$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002214 "setl\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +00002215 [(store (X86setcc X86_COND_L, EFLAGS), addr:$dst)]>,
Evan Chengd5781fc2005-12-21 20:21:51 +00002216 TB; // [mem8] = < signed
2217def SETGEr : I<0x9D, MRM0r,
Evan Cheng64d80e32007-07-19 01:14:50 +00002218 (outs GR8 :$dst), (ins),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002219 "setge\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +00002220 [(set GR8:$dst, (X86setcc X86_COND_GE, EFLAGS))]>,
Evan Cheng069287d2006-05-16 07:21:53 +00002221 TB; // GR8 = >= signed
Evan Chengd5781fc2005-12-21 20:21:51 +00002222def SETGEm : I<0x9D, MRM0m,
Evan Cheng64d80e32007-07-19 01:14:50 +00002223 (outs), (ins i8mem:$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002224 "setge\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +00002225 [(store (X86setcc X86_COND_GE, EFLAGS), addr:$dst)]>,
Evan Chengd5781fc2005-12-21 20:21:51 +00002226 TB; // [mem8] = >= signed
2227def SETLEr : I<0x9E, MRM0r,
Evan Cheng64d80e32007-07-19 01:14:50 +00002228 (outs GR8 :$dst), (ins),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002229 "setle\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +00002230 [(set GR8:$dst, (X86setcc X86_COND_LE, EFLAGS))]>,
Evan Cheng069287d2006-05-16 07:21:53 +00002231 TB; // GR8 = <= signed
Evan Chengd5781fc2005-12-21 20:21:51 +00002232def SETLEm : I<0x9E, MRM0m,
Evan Cheng64d80e32007-07-19 01:14:50 +00002233 (outs), (ins i8mem:$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002234 "setle\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +00002235 [(store (X86setcc X86_COND_LE, EFLAGS), addr:$dst)]>,
Evan Chengd5781fc2005-12-21 20:21:51 +00002236 TB; // [mem8] = <= signed
2237def SETGr : I<0x9F, MRM0r,
Evan Cheng64d80e32007-07-19 01:14:50 +00002238 (outs GR8 :$dst), (ins),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002239 "setg\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +00002240 [(set GR8:$dst, (X86setcc X86_COND_G, EFLAGS))]>,
Evan Cheng069287d2006-05-16 07:21:53 +00002241 TB; // GR8 = > signed
Evan Chengd5781fc2005-12-21 20:21:51 +00002242def SETGm : I<0x9F, MRM0m,
Evan Cheng64d80e32007-07-19 01:14:50 +00002243 (outs), (ins i8mem:$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002244 "setg\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +00002245 [(store (X86setcc X86_COND_G, EFLAGS), addr:$dst)]>,
Evan Chengd5781fc2005-12-21 20:21:51 +00002246 TB; // [mem8] = > signed
2247
2248def SETBr : I<0x92, MRM0r,
Evan Cheng64d80e32007-07-19 01:14:50 +00002249 (outs GR8 :$dst), (ins),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002250 "setb\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +00002251 [(set GR8:$dst, (X86setcc X86_COND_B, EFLAGS))]>,
Evan Cheng069287d2006-05-16 07:21:53 +00002252 TB; // GR8 = < unsign
Evan Chengd5781fc2005-12-21 20:21:51 +00002253def SETBm : I<0x92, MRM0m,
Evan Cheng64d80e32007-07-19 01:14:50 +00002254 (outs), (ins i8mem:$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002255 "setb\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +00002256 [(store (X86setcc X86_COND_B, EFLAGS), addr:$dst)]>,
Evan Chengd5781fc2005-12-21 20:21:51 +00002257 TB; // [mem8] = < unsign
2258def SETAEr : I<0x93, MRM0r,
Evan Cheng64d80e32007-07-19 01:14:50 +00002259 (outs GR8 :$dst), (ins),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002260 "setae\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +00002261 [(set GR8:$dst, (X86setcc X86_COND_AE, EFLAGS))]>,
Evan Cheng069287d2006-05-16 07:21:53 +00002262 TB; // GR8 = >= unsign
Evan Chengd5781fc2005-12-21 20:21:51 +00002263def SETAEm : I<0x93, MRM0m,
Evan Cheng64d80e32007-07-19 01:14:50 +00002264 (outs), (ins i8mem:$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002265 "setae\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +00002266 [(store (X86setcc X86_COND_AE, EFLAGS), addr:$dst)]>,
Evan Chengd5781fc2005-12-21 20:21:51 +00002267 TB; // [mem8] = >= unsign
Chris Lattner3a173df2004-10-03 20:35:00 +00002268def SETBEr : I<0x96, MRM0r,
Evan Cheng64d80e32007-07-19 01:14:50 +00002269 (outs GR8 :$dst), (ins),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002270 "setbe\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +00002271 [(set GR8:$dst, (X86setcc X86_COND_BE, EFLAGS))]>,
Evan Cheng069287d2006-05-16 07:21:53 +00002272 TB; // GR8 = <= unsign
Chris Lattner3a173df2004-10-03 20:35:00 +00002273def SETBEm : I<0x96, MRM0m,
Evan Cheng64d80e32007-07-19 01:14:50 +00002274 (outs), (ins i8mem:$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002275 "setbe\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +00002276 [(store (X86setcc X86_COND_BE, EFLAGS), addr:$dst)]>,
Evan Chengd5781fc2005-12-21 20:21:51 +00002277 TB; // [mem8] = <= unsign
Chris Lattner3a173df2004-10-03 20:35:00 +00002278def SETAr : I<0x97, MRM0r,
Evan Cheng64d80e32007-07-19 01:14:50 +00002279 (outs GR8 :$dst), (ins),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002280 "seta\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +00002281 [(set GR8:$dst, (X86setcc X86_COND_A, EFLAGS))]>,
Evan Cheng069287d2006-05-16 07:21:53 +00002282 TB; // GR8 = > signed
Chris Lattner3a173df2004-10-03 20:35:00 +00002283def SETAm : I<0x97, MRM0m,
Evan Cheng64d80e32007-07-19 01:14:50 +00002284 (outs), (ins i8mem:$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002285 "seta\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +00002286 [(store (X86setcc X86_COND_A, EFLAGS), addr:$dst)]>,
Evan Chengd5781fc2005-12-21 20:21:51 +00002287 TB; // [mem8] = > signed
Evan Chengd9558e02006-01-06 00:43:03 +00002288
Chris Lattner3a173df2004-10-03 20:35:00 +00002289def SETSr : I<0x98, MRM0r,
Evan Cheng64d80e32007-07-19 01:14:50 +00002290 (outs GR8 :$dst), (ins),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002291 "sets\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +00002292 [(set GR8:$dst, (X86setcc X86_COND_S, EFLAGS))]>,
Evan Cheng069287d2006-05-16 07:21:53 +00002293 TB; // GR8 = <sign bit>
Chris Lattner3a173df2004-10-03 20:35:00 +00002294def SETSm : I<0x98, MRM0m,
Evan Cheng64d80e32007-07-19 01:14:50 +00002295 (outs), (ins i8mem:$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002296 "sets\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +00002297 [(store (X86setcc X86_COND_S, EFLAGS), addr:$dst)]>,
Evan Chengd9558e02006-01-06 00:43:03 +00002298 TB; // [mem8] = <sign bit>
Chris Lattner3a173df2004-10-03 20:35:00 +00002299def SETNSr : I<0x99, MRM0r,
Evan Cheng64d80e32007-07-19 01:14:50 +00002300 (outs GR8 :$dst), (ins),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002301 "setns\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +00002302 [(set GR8:$dst, (X86setcc X86_COND_NS, EFLAGS))]>,
Evan Cheng069287d2006-05-16 07:21:53 +00002303 TB; // GR8 = !<sign bit>
Chris Lattner3a173df2004-10-03 20:35:00 +00002304def SETNSm : I<0x99, MRM0m,
Evan Cheng64d80e32007-07-19 01:14:50 +00002305 (outs), (ins i8mem:$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002306 "setns\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +00002307 [(store (X86setcc X86_COND_NS, EFLAGS), addr:$dst)]>,
Evan Chengd9558e02006-01-06 00:43:03 +00002308 TB; // [mem8] = !<sign bit>
Chris Lattner3a173df2004-10-03 20:35:00 +00002309def SETPr : I<0x9A, MRM0r,
Evan Cheng64d80e32007-07-19 01:14:50 +00002310 (outs GR8 :$dst), (ins),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002311 "setp\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +00002312 [(set GR8:$dst, (X86setcc X86_COND_P, EFLAGS))]>,
Evan Cheng069287d2006-05-16 07:21:53 +00002313 TB; // GR8 = parity
Chris Lattner3a173df2004-10-03 20:35:00 +00002314def SETPm : I<0x9A, MRM0m,
Evan Cheng64d80e32007-07-19 01:14:50 +00002315 (outs), (ins i8mem:$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002316 "setp\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +00002317 [(store (X86setcc X86_COND_P, EFLAGS), addr:$dst)]>,
Evan Chengd9558e02006-01-06 00:43:03 +00002318 TB; // [mem8] = parity
Chris Lattnercc65bee2005-01-02 02:35:46 +00002319def SETNPr : I<0x9B, MRM0r,
Evan Cheng64d80e32007-07-19 01:14:50 +00002320 (outs GR8 :$dst), (ins),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002321 "setnp\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +00002322 [(set GR8:$dst, (X86setcc X86_COND_NP, EFLAGS))]>,
Evan Cheng069287d2006-05-16 07:21:53 +00002323 TB; // GR8 = not parity
Chris Lattnercc65bee2005-01-02 02:35:46 +00002324def SETNPm : I<0x9B, MRM0m,
Evan Cheng64d80e32007-07-19 01:14:50 +00002325 (outs), (ins i8mem:$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002326 "setnp\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +00002327 [(store (X86setcc X86_COND_NP, EFLAGS), addr:$dst)]>,
Evan Chengd9558e02006-01-06 00:43:03 +00002328 TB; // [mem8] = not parity
Evan Cheng0488db92007-09-25 01:57:46 +00002329} // Uses = [EFLAGS]
2330
Chris Lattner1cca5e32003-08-03 21:54:21 +00002331
2332// Integer comparisons
Evan Cheng24f2ea32007-09-14 21:48:26 +00002333let Defs = [EFLAGS] in {
Chris Lattner3a173df2004-10-03 20:35:00 +00002334def CMP8rr : I<0x38, MRMDestReg,
Evan Cheng64d80e32007-07-19 01:14:50 +00002335 (outs), (ins GR8 :$src1, GR8 :$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002336 "cmp{b}\t{$src2, $src1|$src1, $src2}",
Evan Chenge5f62042007-09-29 00:00:36 +00002337 [(X86cmp GR8:$src1, GR8:$src2), (implicit EFLAGS)]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00002338def CMP16rr : I<0x39, MRMDestReg,
Evan Cheng64d80e32007-07-19 01:14:50 +00002339 (outs), (ins GR16:$src1, GR16:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002340 "cmp{w}\t{$src2, $src1|$src1, $src2}",
Evan Chenge5f62042007-09-29 00:00:36 +00002341 [(X86cmp GR16:$src1, GR16:$src2), (implicit EFLAGS)]>, OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00002342def CMP32rr : I<0x39, MRMDestReg,
Evan Cheng64d80e32007-07-19 01:14:50 +00002343 (outs), (ins GR32:$src1, GR32:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002344 "cmp{l}\t{$src2, $src1|$src1, $src2}",
Evan Chenge5f62042007-09-29 00:00:36 +00002345 [(X86cmp GR32:$src1, GR32:$src2), (implicit EFLAGS)]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00002346def CMP8mr : I<0x38, MRMDestMem,
Evan Cheng64d80e32007-07-19 01:14:50 +00002347 (outs), (ins i8mem :$src1, GR8 :$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002348 "cmp{b}\t{$src2, $src1|$src1, $src2}",
Evan Chenge5f62042007-09-29 00:00:36 +00002349 [(X86cmp (loadi8 addr:$src1), GR8:$src2),
2350 (implicit EFLAGS)]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00002351def CMP16mr : I<0x39, MRMDestMem,
Evan Cheng64d80e32007-07-19 01:14:50 +00002352 (outs), (ins i16mem:$src1, GR16:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002353 "cmp{w}\t{$src2, $src1|$src1, $src2}",
Evan Chenge5f62042007-09-29 00:00:36 +00002354 [(X86cmp (loadi16 addr:$src1), GR16:$src2),
2355 (implicit EFLAGS)]>, OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00002356def CMP32mr : I<0x39, MRMDestMem,
Evan Cheng64d80e32007-07-19 01:14:50 +00002357 (outs), (ins i32mem:$src1, GR32:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002358 "cmp{l}\t{$src2, $src1|$src1, $src2}",
Evan Chenge5f62042007-09-29 00:00:36 +00002359 [(X86cmp (loadi32 addr:$src1), GR32:$src2),
2360 (implicit EFLAGS)]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00002361def CMP8rm : I<0x3A, MRMSrcMem,
Evan Cheng64d80e32007-07-19 01:14:50 +00002362 (outs), (ins GR8 :$src1, i8mem :$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002363 "cmp{b}\t{$src2, $src1|$src1, $src2}",
Evan Chenge5f62042007-09-29 00:00:36 +00002364 [(X86cmp GR8:$src1, (loadi8 addr:$src2)),
2365 (implicit EFLAGS)]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00002366def CMP16rm : I<0x3B, MRMSrcMem,
Evan Cheng64d80e32007-07-19 01:14:50 +00002367 (outs), (ins GR16:$src1, i16mem:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002368 "cmp{w}\t{$src2, $src1|$src1, $src2}",
Evan Chenge5f62042007-09-29 00:00:36 +00002369 [(X86cmp GR16:$src1, (loadi16 addr:$src2)),
2370 (implicit EFLAGS)]>, OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00002371def CMP32rm : I<0x3B, MRMSrcMem,
Evan Cheng64d80e32007-07-19 01:14:50 +00002372 (outs), (ins GR32:$src1, i32mem:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002373 "cmp{l}\t{$src2, $src1|$src1, $src2}",
Evan Chenge5f62042007-09-29 00:00:36 +00002374 [(X86cmp GR32:$src1, (loadi32 addr:$src2)),
2375 (implicit EFLAGS)]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00002376def CMP8ri : Ii8<0x80, MRM7r,
Evan Cheng64d80e32007-07-19 01:14:50 +00002377 (outs), (ins GR8:$src1, i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002378 "cmp{b}\t{$src2, $src1|$src1, $src2}",
Evan Chenge5f62042007-09-29 00:00:36 +00002379 [(X86cmp GR8:$src1, imm:$src2), (implicit EFLAGS)]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00002380def CMP16ri : Ii16<0x81, MRM7r,
Evan Cheng64d80e32007-07-19 01:14:50 +00002381 (outs), (ins GR16:$src1, i16imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002382 "cmp{w}\t{$src2, $src1|$src1, $src2}",
Evan Chenge5f62042007-09-29 00:00:36 +00002383 [(X86cmp GR16:$src1, imm:$src2),
2384 (implicit EFLAGS)]>, OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00002385def CMP32ri : Ii32<0x81, MRM7r,
Evan Cheng64d80e32007-07-19 01:14:50 +00002386 (outs), (ins GR32:$src1, i32imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002387 "cmp{l}\t{$src2, $src1|$src1, $src2}",
Evan Chenge5f62042007-09-29 00:00:36 +00002388 [(X86cmp GR32:$src1, imm:$src2), (implicit EFLAGS)]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00002389def CMP8mi : Ii8 <0x80, MRM7m,
Evan Cheng64d80e32007-07-19 01:14:50 +00002390 (outs), (ins i8mem :$src1, i8imm :$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002391 "cmp{b}\t{$src2, $src1|$src1, $src2}",
Evan Chenge5f62042007-09-29 00:00:36 +00002392 [(X86cmp (loadi8 addr:$src1), imm:$src2),
2393 (implicit EFLAGS)]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00002394def CMP16mi : Ii16<0x81, MRM7m,
Evan Cheng64d80e32007-07-19 01:14:50 +00002395 (outs), (ins i16mem:$src1, i16imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002396 "cmp{w}\t{$src2, $src1|$src1, $src2}",
Evan Chenge5f62042007-09-29 00:00:36 +00002397 [(X86cmp (loadi16 addr:$src1), imm:$src2),
2398 (implicit EFLAGS)]>, OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00002399def CMP32mi : Ii32<0x81, MRM7m,
Evan Cheng64d80e32007-07-19 01:14:50 +00002400 (outs), (ins i32mem:$src1, i32imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002401 "cmp{l}\t{$src2, $src1|$src1, $src2}",
Evan Chenge5f62042007-09-29 00:00:36 +00002402 [(X86cmp (loadi32 addr:$src1), imm:$src2),
2403 (implicit EFLAGS)]>;
Chris Lattner29b4dd02006-03-23 16:13:50 +00002404def CMP16ri8 : Ii8<0x83, MRM7r,
Evan Cheng64d80e32007-07-19 01:14:50 +00002405 (outs), (ins GR16:$src1, i16i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002406 "cmp{w}\t{$src2, $src1|$src1, $src2}",
Evan Chenge5f62042007-09-29 00:00:36 +00002407 [(X86cmp GR16:$src1, i16immSExt8:$src2),
2408 (implicit EFLAGS)]>, OpSize;
Chris Lattner29b4dd02006-03-23 16:13:50 +00002409def CMP16mi8 : Ii8<0x83, MRM7m,
Evan Cheng64d80e32007-07-19 01:14:50 +00002410 (outs), (ins i16mem:$src1, i16i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002411 "cmp{w}\t{$src2, $src1|$src1, $src2}",
Evan Chenge5f62042007-09-29 00:00:36 +00002412 [(X86cmp (loadi16 addr:$src1), i16immSExt8:$src2),
2413 (implicit EFLAGS)]>, OpSize;
Chris Lattner29b4dd02006-03-23 16:13:50 +00002414def CMP32mi8 : Ii8<0x83, MRM7m,
Evan Cheng64d80e32007-07-19 01:14:50 +00002415 (outs), (ins i32mem:$src1, i32i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002416 "cmp{l}\t{$src2, $src1|$src1, $src2}",
Evan Chenge5f62042007-09-29 00:00:36 +00002417 [(X86cmp (loadi32 addr:$src1), i32immSExt8:$src2),
2418 (implicit EFLAGS)]>;
Chris Lattner29b4dd02006-03-23 16:13:50 +00002419def CMP32ri8 : Ii8<0x83, MRM7r,
Evan Cheng64d80e32007-07-19 01:14:50 +00002420 (outs), (ins GR32:$src1, i32i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002421 "cmp{l}\t{$src2, $src1|$src1, $src2}",
Evan Chenge5f62042007-09-29 00:00:36 +00002422 [(X86cmp GR32:$src1, i32immSExt8:$src2),
Evan Cheng0488db92007-09-25 01:57:46 +00002423 (implicit EFLAGS)]>;
2424} // Defs = [EFLAGS]
2425
Chris Lattner1cca5e32003-08-03 21:54:21 +00002426// Sign/Zero extenders
Dan Gohman11ba3b12008-07-30 18:09:17 +00002427// Use movsbl intead of movsbw; we don't care about the high 16 bits
2428// of the register here. This has a smaller encoding and avoids a
2429// partial-register update.
Evan Cheng64d80e32007-07-19 01:14:50 +00002430def MOVSX16rr8 : I<0xBE, MRMSrcReg, (outs GR16:$dst), (ins GR8 :$src),
Dan Gohman11ba3b12008-07-30 18:09:17 +00002431 "movs{bl|x}\t{$src, ${dst:subreg32}|${dst:subreg32}, $src}",
2432 [(set GR16:$dst, (sext GR8:$src))]>, TB;
Evan Cheng64d80e32007-07-19 01:14:50 +00002433def MOVSX16rm8 : I<0xBE, MRMSrcMem, (outs GR16:$dst), (ins i8mem :$src),
Dan Gohman11ba3b12008-07-30 18:09:17 +00002434 "movs{bl|x}\t{$src, ${dst:subreg32}|${dst:subreg32}, $src}",
2435 [(set GR16:$dst, (sextloadi16i8 addr:$src))]>, TB;
Evan Cheng64d80e32007-07-19 01:14:50 +00002436def MOVSX32rr8 : I<0xBE, MRMSrcReg, (outs GR32:$dst), (ins GR8 :$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002437 "movs{bl|x}\t{$src, $dst|$dst, $src}",
Evan Cheng069287d2006-05-16 07:21:53 +00002438 [(set GR32:$dst, (sext GR8:$src))]>, TB;
Evan Cheng64d80e32007-07-19 01:14:50 +00002439def MOVSX32rm8 : I<0xBE, MRMSrcMem, (outs GR32:$dst), (ins i8mem :$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002440 "movs{bl|x}\t{$src, $dst|$dst, $src}",
Evan Cheng069287d2006-05-16 07:21:53 +00002441 [(set GR32:$dst, (sextloadi32i8 addr:$src))]>, TB;
Evan Cheng64d80e32007-07-19 01:14:50 +00002442def MOVSX32rr16: I<0xBF, MRMSrcReg, (outs GR32:$dst), (ins GR16:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002443 "movs{wl|x}\t{$src, $dst|$dst, $src}",
Evan Cheng069287d2006-05-16 07:21:53 +00002444 [(set GR32:$dst, (sext GR16:$src))]>, TB;
Evan Cheng64d80e32007-07-19 01:14:50 +00002445def MOVSX32rm16: I<0xBF, MRMSrcMem, (outs GR32:$dst), (ins i16mem:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002446 "movs{wl|x}\t{$src, $dst|$dst, $src}",
Evan Cheng069287d2006-05-16 07:21:53 +00002447 [(set GR32:$dst, (sextloadi32i16 addr:$src))]>, TB;
Alkis Evlogimenosa7be9822004-02-17 09:14:23 +00002448
Dan Gohman11ba3b12008-07-30 18:09:17 +00002449// Use movzbl intead of movzbw; we don't care about the high 16 bits
2450// of the register here. This has a smaller encoding and avoids a
2451// partial-register update.
Evan Cheng64d80e32007-07-19 01:14:50 +00002452def MOVZX16rr8 : I<0xB6, MRMSrcReg, (outs GR16:$dst), (ins GR8 :$src),
Dan Gohman11ba3b12008-07-30 18:09:17 +00002453 "movz{bl|x}\t{$src, ${dst:subreg32}|${dst:subreg32}, $src}",
2454 [(set GR16:$dst, (zext GR8:$src))]>, TB;
Evan Cheng64d80e32007-07-19 01:14:50 +00002455def MOVZX16rm8 : I<0xB6, MRMSrcMem, (outs GR16:$dst), (ins i8mem :$src),
Dan Gohman11ba3b12008-07-30 18:09:17 +00002456 "movz{bl|x}\t{$src, ${dst:subreg32}|${dst:subreg32}, $src}",
2457 [(set GR16:$dst, (zextloadi16i8 addr:$src))]>, TB;
Evan Cheng64d80e32007-07-19 01:14:50 +00002458def MOVZX32rr8 : I<0xB6, MRMSrcReg, (outs GR32:$dst), (ins GR8 :$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002459 "movz{bl|x}\t{$src, $dst|$dst, $src}",
Evan Cheng069287d2006-05-16 07:21:53 +00002460 [(set GR32:$dst, (zext GR8:$src))]>, TB;
Evan Cheng64d80e32007-07-19 01:14:50 +00002461def MOVZX32rm8 : I<0xB6, MRMSrcMem, (outs GR32:$dst), (ins i8mem :$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002462 "movz{bl|x}\t{$src, $dst|$dst, $src}",
Evan Cheng069287d2006-05-16 07:21:53 +00002463 [(set GR32:$dst, (zextloadi32i8 addr:$src))]>, TB;
Evan Cheng64d80e32007-07-19 01:14:50 +00002464def MOVZX32rr16: I<0xB7, MRMSrcReg, (outs GR32:$dst), (ins GR16:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002465 "movz{wl|x}\t{$src, $dst|$dst, $src}",
Evan Cheng069287d2006-05-16 07:21:53 +00002466 [(set GR32:$dst, (zext GR16:$src))]>, TB;
Evan Cheng64d80e32007-07-19 01:14:50 +00002467def MOVZX32rm16: I<0xB7, MRMSrcMem, (outs GR32:$dst), (ins i16mem:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002468 "movz{wl|x}\t{$src, $dst|$dst, $src}",
Evan Cheng069287d2006-05-16 07:21:53 +00002469 [(set GR32:$dst, (zextloadi32i16 addr:$src))]>, TB;
Evan Cheng7a7e8372005-12-14 02:22:27 +00002470
Chris Lattnerba7e7562008-01-10 07:59:24 +00002471let neverHasSideEffects = 1 in {
2472 let Defs = [AX], Uses = [AL] in
2473 def CBW : I<0x98, RawFrm, (outs), (ins),
2474 "{cbtw|cbw}", []>, OpSize; // AX = signext(AL)
2475 let Defs = [EAX], Uses = [AX] in
2476 def CWDE : I<0x98, RawFrm, (outs), (ins),
2477 "{cwtl|cwde}", []>; // EAX = signext(AX)
Evan Chengf91c1012006-05-31 22:05:11 +00002478
Chris Lattnerba7e7562008-01-10 07:59:24 +00002479 let Defs = [AX,DX], Uses = [AX] in
2480 def CWD : I<0x99, RawFrm, (outs), (ins),
2481 "{cwtd|cwd}", []>, OpSize; // DX:AX = signext(AX)
2482 let Defs = [EAX,EDX], Uses = [EAX] in
2483 def CDQ : I<0x99, RawFrm, (outs), (ins),
2484 "{cltd|cdq}", []>; // EDX:EAX = signext(EAX)
2485}
Evan Cheng747a90d2006-02-21 02:24:38 +00002486
Evan Cheng747a90d2006-02-21 02:24:38 +00002487//===----------------------------------------------------------------------===//
2488// Alias Instructions
2489//===----------------------------------------------------------------------===//
2490
2491// Alias instructions that map movr0 to xor.
2492// FIXME: remove when we can teach regalloc that xor reg, reg is ok.
Bill Wendlingbd0879d2008-05-29 01:02:09 +00002493let Defs = [EFLAGS], isReMaterializable = 1, isAsCheapAsAMove = 1 in {
Evan Cheng64d80e32007-07-19 01:14:50 +00002494def MOV8r0 : I<0x30, MRMInitReg, (outs GR8 :$dst), (ins),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002495 "xor{b}\t$dst, $dst",
Evan Cheng069287d2006-05-16 07:21:53 +00002496 [(set GR8:$dst, 0)]>;
Dan Gohman11ba3b12008-07-30 18:09:17 +00002497// Use xorl instead of xorw since we don't care about the high 16 bits,
2498// it's smaller, and it avoids a partial-register update.
Evan Cheng64d80e32007-07-19 01:14:50 +00002499def MOV16r0 : I<0x31, MRMInitReg, (outs GR16:$dst), (ins),
Dan Gohman11ba3b12008-07-30 18:09:17 +00002500 "xor{l}\t${dst:subreg32}, ${dst:subreg32}",
2501 [(set GR16:$dst, 0)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00002502def MOV32r0 : I<0x31, MRMInitReg, (outs GR32:$dst), (ins),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002503 "xor{l}\t$dst, $dst",
Evan Cheng069287d2006-05-16 07:21:53 +00002504 [(set GR32:$dst, 0)]>;
Dan Gohman1ab79892007-09-07 21:32:51 +00002505}
Evan Cheng747a90d2006-02-21 02:24:38 +00002506
Evan Cheng069287d2006-05-16 07:21:53 +00002507// Basic operations on GR16 / GR32 subclasses GR16_ and GR32_ which contains only
2508// those registers that have GR8 sub-registers (i.e. AX - DX, EAX - EDX).
Chris Lattnerba7e7562008-01-10 07:59:24 +00002509let neverHasSideEffects = 1 in {
Evan Cheng64d80e32007-07-19 01:14:50 +00002510def MOV16to16_ : I<0x89, MRMDestReg, (outs GR16_:$dst), (ins GR16:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002511 "mov{w}\t{$src, $dst|$dst, $src}", []>, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00002512def MOV32to32_ : I<0x89, MRMDestReg, (outs GR32_:$dst), (ins GR32:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002513 "mov{l}\t{$src, $dst|$dst, $src}", []>;
Chris Lattnerba7e7562008-01-10 07:59:24 +00002514
Evan Cheng64d80e32007-07-19 01:14:50 +00002515def MOV16_rr : I<0x89, MRMDestReg, (outs GR16_:$dst), (ins GR16_:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002516 "mov{w}\t{$src, $dst|$dst, $src}", []>, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00002517def MOV32_rr : I<0x89, MRMDestReg, (outs GR32_:$dst), (ins GR32_:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002518 "mov{l}\t{$src, $dst|$dst, $src}", []>;
Chris Lattnerba7e7562008-01-10 07:59:24 +00002519} // neverHasSideEffects
2520
2521let isSimpleLoad = 1, mayLoad = 1, isReMaterializable = 1, mayHaveSideEffects = 1 in {
Evan Cheng64d80e32007-07-19 01:14:50 +00002522def MOV16_rm : I<0x8B, MRMSrcMem, (outs GR16_:$dst), (ins i16mem:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002523 "mov{w}\t{$src, $dst|$dst, $src}", []>, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00002524def MOV32_rm : I<0x8B, MRMSrcMem, (outs GR32_:$dst), (ins i32mem:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002525 "mov{l}\t{$src, $dst|$dst, $src}", []>;
Evan Cheng2f394262007-08-30 05:49:43 +00002526}
Chris Lattnerba7e7562008-01-10 07:59:24 +00002527let mayStore = 1, neverHasSideEffects = 1 in {
Evan Cheng64d80e32007-07-19 01:14:50 +00002528def MOV16_mr : I<0x89, MRMDestMem, (outs), (ins i16mem:$dst, GR16_:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002529 "mov{w}\t{$src, $dst|$dst, $src}", []>, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00002530def MOV32_mr : I<0x89, MRMDestMem, (outs), (ins i32mem:$dst, GR32_:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002531 "mov{l}\t{$src, $dst|$dst, $src}", []>;
Chris Lattnerba7e7562008-01-10 07:59:24 +00002532}
Evan Cheng403be7e2006-05-08 08:01:26 +00002533
Evan Cheng510e4782006-01-09 23:10:28 +00002534//===----------------------------------------------------------------------===//
Lauro Ramos Venanciob3a04172007-04-20 21:38:10 +00002535// Thread Local Storage Instructions
2536//
2537
Evan Cheng071a2792007-09-11 19:55:27 +00002538let Uses = [EBX] in
Anton Korobeynikov6625eff2008-05-04 21:36:32 +00002539def TLS_addr32 : I<0, Pseudo, (outs GR32:$dst), (ins i32imm:$sym),
2540 "leal\t${sym:mem}(,%ebx,1), $dst",
2541 [(set GR32:$dst, (X86tlsaddr tglobaltlsaddr:$sym))]>;
Lauro Ramos Venanciob3a04172007-04-20 21:38:10 +00002542
Lauro Ramos Venancio7d2cc2b2007-04-22 22:50:52 +00002543let AddedComplexity = 10 in
Anton Korobeynikov6625eff2008-05-04 21:36:32 +00002544def TLS_gs_rr : I<0, Pseudo, (outs GR32:$dst), (ins GR32:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002545 "movl\t%gs:($src), $dst",
Lauro Ramos Venancioede1d782007-04-23 01:28:10 +00002546 [(set GR32:$dst, (load (add X86TLStp, GR32:$src)))]>;
2547
2548let AddedComplexity = 15 in
Evan Cheng64d80e32007-07-19 01:14:50 +00002549def TLS_gs_ri : I<0, Pseudo, (outs GR32:$dst), (ins i32imm:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002550 "movl\t%gs:${src:mem}, $dst",
Lauro Ramos Venancioede1d782007-04-23 01:28:10 +00002551 [(set GR32:$dst,
2552 (load (add X86TLStp, (X86Wrapper tglobaltlsaddr:$src))))]>;
Lauro Ramos Venancio7d2cc2b2007-04-22 22:50:52 +00002553
Evan Cheng64d80e32007-07-19 01:14:50 +00002554def TLS_tp : I<0, Pseudo, (outs GR32:$dst), (ins),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002555 "movl\t%gs:0, $dst",
Lauro Ramos Venanciob3a04172007-04-20 21:38:10 +00002556 [(set GR32:$dst, X86TLStp)]>;
2557
2558//===----------------------------------------------------------------------===//
Evan Cheng3c992d22006-03-07 02:02:57 +00002559// DWARF Pseudo Instructions
2560//
2561
Evan Cheng64d80e32007-07-19 01:14:50 +00002562def DWARF_LOC : I<0, Pseudo, (outs),
2563 (ins i32imm:$line, i32imm:$col, i32imm:$file),
Dan Gohman6b5766e2007-09-24 19:25:06 +00002564 ".loc\t${file:debug} ${line:debug} ${col:debug}",
Evan Cheng3c992d22006-03-07 02:02:57 +00002565 [(dwarf_loc (i32 imm:$line), (i32 imm:$col),
2566 (i32 imm:$file))]>;
2567
Evan Cheng3c992d22006-03-07 02:02:57 +00002568//===----------------------------------------------------------------------===//
Anton Korobeynikov2365f512007-07-14 14:06:15 +00002569// EH Pseudo Instructions
2570//
2571let isTerminator = 1, isReturn = 1, isBarrier = 1,
Evan Chengffbacca2007-07-21 00:34:19 +00002572 hasCtrlDep = 1 in {
Evan Cheng64d80e32007-07-19 01:14:50 +00002573def EH_RETURN : I<0xC3, RawFrm, (outs), (ins GR32:$addr),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002574 "ret\t#eh_return, addr: $addr",
Anton Korobeynikov2365f512007-07-14 14:06:15 +00002575 [(X86ehret GR32:$addr)]>;
2576
2577}
2578
2579//===----------------------------------------------------------------------===//
Andrew Lenharthab0b9492008-02-21 06:45:13 +00002580// Atomic support
2581//
Andrew Lenharthea7da502008-03-01 13:37:02 +00002582
Evan Chengbb6939d2008-04-19 01:20:30 +00002583// Atomic swap. These are just normal xchg instructions. But since a memory
2584// operand is referenced, the atomicity is ensured.
Dan Gohman165660e2008-08-06 15:52:50 +00002585let Constraints = "$val = $dst" in {
Evan Chengbb6939d2008-04-19 01:20:30 +00002586def XCHG32rm : I<0x87, MRMSrcMem, (outs GR32:$dst), (ins i32mem:$ptr, GR32:$val),
2587 "xchg{l}\t{$val, $ptr|$ptr, $val}",
2588 [(set GR32:$dst, (atomic_swap_32 addr:$ptr, GR32:$val))]>;
2589def XCHG16rm : I<0x87, MRMSrcMem, (outs GR16:$dst), (ins i16mem:$ptr, GR16:$val),
2590 "xchg{w}\t{$val, $ptr|$ptr, $val}",
2591 [(set GR16:$dst, (atomic_swap_16 addr:$ptr, GR16:$val))]>,
2592 OpSize;
2593def XCHG8rm : I<0x86, MRMSrcMem, (outs GR8:$dst), (ins i8mem:$ptr, GR8:$val),
2594 "xchg{b}\t{$val, $ptr|$ptr, $val}",
2595 [(set GR8:$dst, (atomic_swap_8 addr:$ptr, GR8:$val))]>;
2596}
2597
Evan Cheng7e032802008-04-18 20:55:36 +00002598// Atomic compare and swap.
Andrew Lenharth26ed8692008-03-01 21:52:34 +00002599let Defs = [EAX, EFLAGS], Uses = [EAX] in {
Evan Cheng7e032802008-04-18 20:55:36 +00002600def LCMPXCHG32 : I<0xB1, MRMDestMem, (outs), (ins i32mem:$ptr, GR32:$swap),
Evan Cheng3f73bea2008-04-17 23:35:10 +00002601 "lock cmpxchg{l}\t{$swap, $ptr|$ptr, $swap}",
Evan Cheng32967d22008-03-04 03:20:06 +00002602 [(X86cas addr:$ptr, GR32:$swap, 4)]>, TB, LOCK;
Andrew Lenharthea7da502008-03-01 13:37:02 +00002603}
Andrew Lenharthd19189e2008-03-05 01:15:49 +00002604let Defs = [EAX, EBX, ECX, EDX, EFLAGS], Uses = [EAX, EBX, ECX, EDX] in {
Anton Korobeynikovf88a6fa2008-07-22 16:22:48 +00002605def LCMPXCHG8B : I<0xC7, MRM1m, (outs), (ins i32mem:$ptr),
Evan Cheng3f73bea2008-04-17 23:35:10 +00002606 "lock cmpxchg8b\t$ptr",
Andrew Lenharthd19189e2008-03-05 01:15:49 +00002607 [(X86cas8 addr:$ptr)]>, TB, LOCK;
2608}
Andrew Lenharth26ed8692008-03-01 21:52:34 +00002609
2610let Defs = [AX, EFLAGS], Uses = [AX] in {
Evan Cheng7e032802008-04-18 20:55:36 +00002611def LCMPXCHG16 : I<0xB1, MRMDestMem, (outs), (ins i16mem:$ptr, GR16:$swap),
Evan Cheng3f73bea2008-04-17 23:35:10 +00002612 "lock cmpxchg{w}\t{$swap, $ptr|$ptr, $swap}",
Evan Cheng32967d22008-03-04 03:20:06 +00002613 [(X86cas addr:$ptr, GR16:$swap, 2)]>, TB, OpSize, LOCK;
Andrew Lenharthea7da502008-03-01 13:37:02 +00002614}
Andrew Lenharth26ed8692008-03-01 21:52:34 +00002615let Defs = [AL, EFLAGS], Uses = [AL] in {
Evan Cheng7e032802008-04-18 20:55:36 +00002616def LCMPXCHG8 : I<0xB0, MRMDestMem, (outs), (ins i8mem:$ptr, GR8:$swap),
Evan Cheng3f73bea2008-04-17 23:35:10 +00002617 "lock cmpxchg{b}\t{$swap, $ptr|$ptr, $swap}",
Evan Cheng32967d22008-03-04 03:20:06 +00002618 [(X86cas addr:$ptr, GR8:$swap, 1)]>, TB, LOCK;
Andrew Lenharthea7da502008-03-01 13:37:02 +00002619}
2620
Evan Cheng7e032802008-04-18 20:55:36 +00002621// Atomic exchange and add
2622let Constraints = "$val = $dst", Defs = [EFLAGS] in {
2623def LXADD32 : I<0xC1, MRMSrcMem, (outs GR32:$dst), (ins i32mem:$ptr, GR32:$val),
2624 "lock xadd{l}\t{$val, $ptr|$ptr, $val}",
Mon P Wang28873102008-06-25 08:15:39 +00002625 [(set GR32:$dst, (atomic_load_add_32 addr:$ptr, GR32:$val))]>,
Evan Cheng7e032802008-04-18 20:55:36 +00002626 TB, LOCK;
2627def LXADD16 : I<0xC1, MRMSrcMem, (outs GR16:$dst), (ins i16mem:$ptr, GR16:$val),
2628 "lock xadd{w}\t{$val, $ptr|$ptr, $val}",
Mon P Wang28873102008-06-25 08:15:39 +00002629 [(set GR16:$dst, (atomic_load_add_16 addr:$ptr, GR16:$val))]>,
Evan Cheng7e032802008-04-18 20:55:36 +00002630 TB, OpSize, LOCK;
2631def LXADD8 : I<0xC0, MRMSrcMem, (outs GR8:$dst), (ins i8mem:$ptr, GR8:$val),
2632 "lock xadd{b}\t{$val, $ptr|$ptr, $val}",
Mon P Wang28873102008-06-25 08:15:39 +00002633 [(set GR8:$dst, (atomic_load_add_8 addr:$ptr, GR8:$val))]>,
Evan Cheng7e032802008-04-18 20:55:36 +00002634 TB, LOCK;
Andrew Lenharthea7da502008-03-01 13:37:02 +00002635}
2636
Mon P Wang28873102008-06-25 08:15:39 +00002637// Atomic exchange, and, or, xor
Mon P Wang63307c32008-05-05 19:05:59 +00002638let Constraints = "$val = $dst", Defs = [EFLAGS],
2639 usesCustomDAGSchedInserter = 1 in {
Dan Gohman9499b712008-05-12 20:22:45 +00002640def ATOMAND32 : I<0, Pseudo, (outs GR32:$dst),(ins i32mem:$ptr, GR32:$val),
Mon P Wang63307c32008-05-05 19:05:59 +00002641 "#ATOMAND32 PSUEDO!",
Dan Gohman9499b712008-05-12 20:22:45 +00002642 [(set GR32:$dst, (atomic_load_and addr:$ptr, GR32:$val))]>;
Dan Gohman9499b712008-05-12 20:22:45 +00002643def ATOMOR32 : I<0, Pseudo, (outs GR32:$dst),(ins i32mem:$ptr, GR32:$val),
Mon P Wang63307c32008-05-05 19:05:59 +00002644 "#ATOMOR32 PSUEDO!",
Dan Gohman9499b712008-05-12 20:22:45 +00002645 [(set GR32:$dst, (atomic_load_or addr:$ptr, GR32:$val))]>;
Dan Gohman9499b712008-05-12 20:22:45 +00002646def ATOMXOR32 : I<0, Pseudo,(outs GR32:$dst),(ins i32mem:$ptr, GR32:$val),
Mon P Wang63307c32008-05-05 19:05:59 +00002647 "#ATOMXOR32 PSUEDO!",
Dan Gohman9499b712008-05-12 20:22:45 +00002648 [(set GR32:$dst, (atomic_load_xor addr:$ptr, GR32:$val))]>;
Andrew Lenharth507a58a2008-06-14 05:48:15 +00002649def ATOMNAND32 : I<0, Pseudo,(outs GR32:$dst),(ins i32mem:$ptr, GR32:$val),
Mon P Wang28873102008-06-25 08:15:39 +00002650 "#ATOMNAND32 PSUEDO!",
Andrew Lenharth507a58a2008-06-14 05:48:15 +00002651 [(set GR32:$dst, (atomic_load_nand addr:$ptr, GR32:$val))]>;
Mon P Wang63307c32008-05-05 19:05:59 +00002652
Dan Gohman9499b712008-05-12 20:22:45 +00002653def ATOMMIN32: I<0, Pseudo, (outs GR32:$dst), (ins i32mem:$ptr, GR32:$val),
Mon P Wang63307c32008-05-05 19:05:59 +00002654 "#ATOMMIN32 PSUEDO!",
Dan Gohman9499b712008-05-12 20:22:45 +00002655 [(set GR32:$dst, (atomic_load_min addr:$ptr, GR32:$val))]>;
Dan Gohman9499b712008-05-12 20:22:45 +00002656def ATOMMAX32: I<0, Pseudo, (outs GR32:$dst),(ins i32mem:$ptr, GR32:$val),
Mon P Wang63307c32008-05-05 19:05:59 +00002657 "#ATOMMAX32 PSUEDO!",
Dan Gohman9499b712008-05-12 20:22:45 +00002658 [(set GR32:$dst, (atomic_load_max addr:$ptr, GR32:$val))]>;
Dan Gohman9499b712008-05-12 20:22:45 +00002659def ATOMUMIN32: I<0, Pseudo, (outs GR32:$dst),(ins i32mem:$ptr, GR32:$val),
Mon P Wang63307c32008-05-05 19:05:59 +00002660 "#ATOMUMIN32 PSUEDO!",
Dan Gohman9499b712008-05-12 20:22:45 +00002661 [(set GR32:$dst, (atomic_load_umin addr:$ptr, GR32:$val))]>;
Dan Gohman9499b712008-05-12 20:22:45 +00002662def ATOMUMAX32: I<0, Pseudo, (outs GR32:$dst),(ins i32mem:$ptr, GR32:$val),
Mon P Wang63307c32008-05-05 19:05:59 +00002663 "#ATOMUMAX32 PSUEDO!",
Dan Gohman9499b712008-05-12 20:22:45 +00002664 [(set GR32:$dst, (atomic_load_umax addr:$ptr, GR32:$val))]>;
Mon P Wang63307c32008-05-05 19:05:59 +00002665}
2666
Andrew Lenharthab0b9492008-02-21 06:45:13 +00002667//===----------------------------------------------------------------------===//
Evan Cheng510e4782006-01-09 23:10:28 +00002668// Non-Instruction Patterns
2669//===----------------------------------------------------------------------===//
2670
Evan Cheng25ab6902006-09-08 06:48:29 +00002671// ConstantPool GlobalAddress, ExternalSymbol, and JumpTable
Evan Cheng71fb8342006-02-25 10:02:21 +00002672def : Pat<(i32 (X86Wrapper tconstpool :$dst)), (MOV32ri tconstpool :$dst)>;
Nate Begeman37efe672006-04-22 18:53:45 +00002673def : Pat<(i32 (X86Wrapper tjumptable :$dst)), (MOV32ri tjumptable :$dst)>;
Nate Begeman6795ebb2008-04-12 00:47:57 +00002674def : Pat<(i32 (X86Wrapper tglobaltlsaddr:$dst)),(MOV32ri tglobaltlsaddr:$dst)>;
Evan Cheng71fb8342006-02-25 10:02:21 +00002675def : Pat<(i32 (X86Wrapper tglobaladdr :$dst)), (MOV32ri tglobaladdr :$dst)>;
2676def : Pat<(i32 (X86Wrapper texternalsym:$dst)), (MOV32ri texternalsym:$dst)>;
2677
Evan Cheng069287d2006-05-16 07:21:53 +00002678def : Pat<(add GR32:$src1, (X86Wrapper tconstpool:$src2)),
2679 (ADD32ri GR32:$src1, tconstpool:$src2)>;
2680def : Pat<(add GR32:$src1, (X86Wrapper tjumptable:$src2)),
2681 (ADD32ri GR32:$src1, tjumptable:$src2)>;
2682def : Pat<(add GR32:$src1, (X86Wrapper tglobaladdr :$src2)),
2683 (ADD32ri GR32:$src1, tglobaladdr:$src2)>;
2684def : Pat<(add GR32:$src1, (X86Wrapper texternalsym:$src2)),
2685 (ADD32ri GR32:$src1, texternalsym:$src2)>;
Evan Cheng71fb8342006-02-25 10:02:21 +00002686
Evan Chengfc8feb12006-05-19 07:30:36 +00002687def : Pat<(store (i32 (X86Wrapper tglobaladdr:$src)), addr:$dst),
Evan Cheng71fb8342006-02-25 10:02:21 +00002688 (MOV32mi addr:$dst, tglobaladdr:$src)>;
Evan Chengfc8feb12006-05-19 07:30:36 +00002689def : Pat<(store (i32 (X86Wrapper texternalsym:$src)), addr:$dst),
Evan Cheng71fb8342006-02-25 10:02:21 +00002690 (MOV32mi addr:$dst, texternalsym:$src)>;
2691
Evan Cheng510e4782006-01-09 23:10:28 +00002692// Calls
Arnold Schwaighoferc85e1712007-10-11 19:40:01 +00002693// tailcall stuff
Evan Cheng069287d2006-05-16 07:21:53 +00002694def : Pat<(X86tailcall GR32:$dst),
Arnold Schwaighoferc85e1712007-10-11 19:40:01 +00002695 (TAILCALL)>;
Evan Chengfea89c12006-04-27 08:40:39 +00002696
Evan Cheng25ab6902006-09-08 06:48:29 +00002697def : Pat<(X86tailcall (i32 tglobaladdr:$dst)),
Arnold Schwaighoferc85e1712007-10-11 19:40:01 +00002698 (TAILCALL)>;
Evan Cheng25ab6902006-09-08 06:48:29 +00002699def : Pat<(X86tailcall (i32 texternalsym:$dst)),
Arnold Schwaighoferc85e1712007-10-11 19:40:01 +00002700 (TAILCALL)>;
2701
2702def : Pat<(X86tcret GR32:$dst, imm:$off),
2703 (TCRETURNri GR32:$dst, imm:$off)>;
2704
2705def : Pat<(X86tcret (i32 tglobaladdr:$dst), imm:$off),
2706 (TCRETURNdi texternalsym:$dst, imm:$off)>;
2707
2708def : Pat<(X86tcret (i32 texternalsym:$dst), imm:$off),
2709 (TCRETURNdi texternalsym:$dst, imm:$off)>;
Evan Chengfea89c12006-04-27 08:40:39 +00002710
Evan Cheng25ab6902006-09-08 06:48:29 +00002711def : Pat<(X86call (i32 tglobaladdr:$dst)),
Evan Cheng510e4782006-01-09 23:10:28 +00002712 (CALLpcrel32 tglobaladdr:$dst)>;
Evan Cheng25ab6902006-09-08 06:48:29 +00002713def : Pat<(X86call (i32 texternalsym:$dst)),
Evan Cheng8700e142006-01-11 06:09:51 +00002714 (CALLpcrel32 texternalsym:$dst)>;
Evan Cheng510e4782006-01-09 23:10:28 +00002715
2716// X86 specific add which produces a flag.
Evan Cheng069287d2006-05-16 07:21:53 +00002717def : Pat<(addc GR32:$src1, GR32:$src2),
2718 (ADD32rr GR32:$src1, GR32:$src2)>;
2719def : Pat<(addc GR32:$src1, (load addr:$src2)),
2720 (ADD32rm GR32:$src1, addr:$src2)>;
2721def : Pat<(addc GR32:$src1, imm:$src2),
2722 (ADD32ri GR32:$src1, imm:$src2)>;
2723def : Pat<(addc GR32:$src1, i32immSExt8:$src2),
2724 (ADD32ri8 GR32:$src1, i32immSExt8:$src2)>;
Evan Cheng510e4782006-01-09 23:10:28 +00002725
Evan Cheng069287d2006-05-16 07:21:53 +00002726def : Pat<(subc GR32:$src1, GR32:$src2),
2727 (SUB32rr GR32:$src1, GR32:$src2)>;
2728def : Pat<(subc GR32:$src1, (load addr:$src2)),
2729 (SUB32rm GR32:$src1, addr:$src2)>;
2730def : Pat<(subc GR32:$src1, imm:$src2),
2731 (SUB32ri GR32:$src1, imm:$src2)>;
2732def : Pat<(subc GR32:$src1, i32immSExt8:$src2),
2733 (SUB32ri8 GR32:$src1, i32immSExt8:$src2)>;
Evan Cheng510e4782006-01-09 23:10:28 +00002734
Chris Lattnerffc0b262006-09-07 20:33:45 +00002735// Comparisons.
2736
2737// TEST R,R is smaller than CMP R,0
Evan Chenge5f62042007-09-29 00:00:36 +00002738def : Pat<(parallel (X86cmp GR8:$src1, 0), (implicit EFLAGS)),
Chris Lattnerffc0b262006-09-07 20:33:45 +00002739 (TEST8rr GR8:$src1, GR8:$src1)>;
Evan Chenge5f62042007-09-29 00:00:36 +00002740def : Pat<(parallel (X86cmp GR16:$src1, 0), (implicit EFLAGS)),
Chris Lattnerffc0b262006-09-07 20:33:45 +00002741 (TEST16rr GR16:$src1, GR16:$src1)>;
Evan Chenge5f62042007-09-29 00:00:36 +00002742def : Pat<(parallel (X86cmp GR32:$src1, 0), (implicit EFLAGS)),
Chris Lattnerffc0b262006-09-07 20:33:45 +00002743 (TEST32rr GR32:$src1, GR32:$src1)>;
2744
Duncan Sandsf9c98e62008-01-23 20:39:46 +00002745// zextload bool -> zextload byte
Evan Chenge5d93432006-01-17 07:02:46 +00002746def : Pat<(zextloadi8i1 addr:$src), (MOV8rm addr:$src)>;
Evan Cheng510e4782006-01-09 23:10:28 +00002747def : Pat<(zextloadi16i1 addr:$src), (MOVZX16rm8 addr:$src)>;
2748def : Pat<(zextloadi32i1 addr:$src), (MOVZX32rm8 addr:$src)>;
2749
2750// extload bool -> extload byte
Evan Cheng47137242006-05-05 08:23:07 +00002751def : Pat<(extloadi8i1 addr:$src), (MOV8rm addr:$src)>;
2752def : Pat<(extloadi16i1 addr:$src), (MOVZX16rm8 addr:$src)>;
2753def : Pat<(extloadi32i1 addr:$src), (MOVZX32rm8 addr:$src)>;
2754def : Pat<(extloadi16i8 addr:$src), (MOVZX16rm8 addr:$src)>;
2755def : Pat<(extloadi32i8 addr:$src), (MOVZX32rm8 addr:$src)>;
2756def : Pat<(extloadi32i16 addr:$src), (MOVZX32rm16 addr:$src)>;
Evan Cheng510e4782006-01-09 23:10:28 +00002757
2758// anyext -> zext
Evan Cheng069287d2006-05-16 07:21:53 +00002759def : Pat<(i16 (anyext GR8 :$src)), (MOVZX16rr8 GR8 :$src)>;
2760def : Pat<(i32 (anyext GR8 :$src)), (MOVZX32rr8 GR8 :$src)>;
2761def : Pat<(i32 (anyext GR16:$src)), (MOVZX32rr16 GR16:$src)>;
Evan Cheng6e16ee52006-03-25 09:45:48 +00002762def : Pat<(i16 (anyext (loadi8 addr:$src))), (MOVZX16rm8 addr:$src)>;
2763def : Pat<(i32 (anyext (loadi8 addr:$src))), (MOVZX32rm8 addr:$src)>;
2764def : Pat<(i32 (anyext (loadi16 addr:$src))), (MOVZX32rm16 addr:$src)>;
Evan Cheng510e4782006-01-09 23:10:28 +00002765
Evan Cheng1314b002007-12-13 00:43:27 +00002766// (and (i32 load), 255) -> (zextload i8)
2767def : Pat<(i32 (and (loadi32 addr:$src), (i32 255))), (MOVZX32rm8 addr:$src)>;
2768def : Pat<(i32 (and (loadi32 addr:$src), (i32 65535))),(MOVZX32rm16 addr:$src)>;
2769
Evan Chengcfa260b2006-01-06 02:31:59 +00002770//===----------------------------------------------------------------------===//
2771// Some peepholes
2772//===----------------------------------------------------------------------===//
2773
Dan Gohman11ba3b12008-07-30 18:09:17 +00002774// r & (2^16-1) ==> movz
2775def : Pat<(and GR32:$src1, 0xffff),
2776 (MOVZX32rr16 (i16 (EXTRACT_SUBREG GR32:$src1, x86_subreg_16bit)))>;
Dan Gohman8a1510d2008-08-06 18:27:21 +00002777// r & (2^8-1) ==> movz
2778def : Pat<(and GR32:$src1, 0xff),
2779 (MOVZX32rr8 (i8 (EXTRACT_SUBREG (MOV32to32_ GR32:$src1),
2780 x86_subreg_8bit)))>,
2781 Requires<[In32BitMode]>;
2782// r & (2^8-1) ==> movz
2783def : Pat<(and GR16:$src1, 0xff),
2784 (MOVZX16rr8 (i8 (EXTRACT_SUBREG (MOV16to16_ GR16:$src1),
2785 x86_subreg_8bit)))>,
2786 Requires<[In32BitMode]>;
Dan Gohman11ba3b12008-07-30 18:09:17 +00002787
Evan Chengcfa260b2006-01-06 02:31:59 +00002788// (shl x, 1) ==> (add x, x)
Evan Cheng069287d2006-05-16 07:21:53 +00002789def : Pat<(shl GR8 :$src1, (i8 1)), (ADD8rr GR8 :$src1, GR8 :$src1)>;
2790def : Pat<(shl GR16:$src1, (i8 1)), (ADD16rr GR16:$src1, GR16:$src1)>;
2791def : Pat<(shl GR32:$src1, (i8 1)), (ADD32rr GR32:$src1, GR32:$src1)>;
Evan Cheng68b951a2006-01-19 01:56:29 +00002792
Evan Cheng956044c2006-01-19 23:26:24 +00002793// (or (x >> c) | (y << (32 - c))) ==> (shrd32 x, y, c)
Evan Cheng069287d2006-05-16 07:21:53 +00002794def : Pat<(or (srl GR32:$src1, CL:$amt),
2795 (shl GR32:$src2, (sub 32, CL:$amt))),
2796 (SHRD32rrCL GR32:$src1, GR32:$src2)>;
Evan Cheng68b951a2006-01-19 01:56:29 +00002797
Evan Cheng21d54432006-01-20 01:13:30 +00002798def : Pat<(store (or (srl (loadi32 addr:$dst), CL:$amt),
Evan Cheng069287d2006-05-16 07:21:53 +00002799 (shl GR32:$src2, (sub 32, CL:$amt))), addr:$dst),
2800 (SHRD32mrCL addr:$dst, GR32:$src2)>;
Evan Cheng21d54432006-01-20 01:13:30 +00002801
Evan Cheng956044c2006-01-19 23:26:24 +00002802// (or (x << c) | (y >> (32 - c))) ==> (shld32 x, y, c)
Evan Cheng069287d2006-05-16 07:21:53 +00002803def : Pat<(or (shl GR32:$src1, CL:$amt),
2804 (srl GR32:$src2, (sub 32, CL:$amt))),
2805 (SHLD32rrCL GR32:$src1, GR32:$src2)>;
Evan Cheng956044c2006-01-19 23:26:24 +00002806
Evan Cheng21d54432006-01-20 01:13:30 +00002807def : Pat<(store (or (shl (loadi32 addr:$dst), CL:$amt),
Evan Cheng069287d2006-05-16 07:21:53 +00002808 (srl GR32:$src2, (sub 32, CL:$amt))), addr:$dst),
2809 (SHLD32mrCL addr:$dst, GR32:$src2)>;
Evan Cheng21d54432006-01-20 01:13:30 +00002810
Evan Cheng956044c2006-01-19 23:26:24 +00002811// (or (x >> c) | (y << (16 - c))) ==> (shrd16 x, y, c)
Evan Cheng069287d2006-05-16 07:21:53 +00002812def : Pat<(or (srl GR16:$src1, CL:$amt),
2813 (shl GR16:$src2, (sub 16, CL:$amt))),
2814 (SHRD16rrCL GR16:$src1, GR16:$src2)>;
Evan Cheng956044c2006-01-19 23:26:24 +00002815
Evan Cheng21d54432006-01-20 01:13:30 +00002816def : Pat<(store (or (srl (loadi16 addr:$dst), CL:$amt),
Evan Cheng069287d2006-05-16 07:21:53 +00002817 (shl GR16:$src2, (sub 16, CL:$amt))), addr:$dst),
2818 (SHRD16mrCL addr:$dst, GR16:$src2)>;
Evan Cheng21d54432006-01-20 01:13:30 +00002819
Evan Cheng956044c2006-01-19 23:26:24 +00002820// (or (x << c) | (y >> (16 - c))) ==> (shld16 x, y, c)
Evan Cheng069287d2006-05-16 07:21:53 +00002821def : Pat<(or (shl GR16:$src1, CL:$amt),
2822 (srl GR16:$src2, (sub 16, CL:$amt))),
2823 (SHLD16rrCL GR16:$src1, GR16:$src2)>;
Evan Cheng21d54432006-01-20 01:13:30 +00002824
2825def : Pat<(store (or (shl (loadi16 addr:$dst), CL:$amt),
Evan Cheng069287d2006-05-16 07:21:53 +00002826 (srl GR16:$src2, (sub 16, CL:$amt))), addr:$dst),
2827 (SHLD16mrCL addr:$dst, GR16:$src2)>;
Evan Cheng4e4c71e2006-02-21 20:00:20 +00002828
Evan Cheng4e4c71e2006-02-21 20:00:20 +00002829//===----------------------------------------------------------------------===//
2830// Floating Point Stack Support
2831//===----------------------------------------------------------------------===//
2832
2833include "X86InstrFPStack.td"
2834
2835//===----------------------------------------------------------------------===//
Evan Chengc64a1a92007-07-31 08:04:03 +00002836// X86-64 Support
2837//===----------------------------------------------------------------------===//
2838
Chris Lattner36fe6d22008-01-10 05:50:42 +00002839include "X86Instr64bit.td"
Evan Chengc64a1a92007-07-31 08:04:03 +00002840
2841//===----------------------------------------------------------------------===//
Evan Cheng4e4c71e2006-02-21 20:00:20 +00002842// XMM Floating point support (requires SSE / SSE2)
2843//===----------------------------------------------------------------------===//
2844
2845include "X86InstrSSE.td"
Evan Cheng80f54042008-04-25 18:19:54 +00002846
2847//===----------------------------------------------------------------------===//
2848// MMX and XMM Packed Integer support (requires MMX, SSE, and SSE2)
2849//===----------------------------------------------------------------------===//
2850
2851include "X86InstrMMX.td"