blob: c8f986a659e261db5e9a526efaaf56d9952bf8e8 [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
Dan Gohman076aee32009-03-04 19:44:21 +000030// Unary and binary operator instructions that set EFLAGS as a side-effect.
31def SDTUnaryArithWithFlags : SDTypeProfile<1, 1,
32 [SDTCisInt<0>]>;
33def SDTBinaryArithWithFlags : SDTypeProfile<1, 2,
34 [SDTCisSameAs<0, 1>,
35 SDTCisSameAs<0, 2>,
36 SDTCisInt<0>]>;
Bill Wendlingab55ebd2008-12-12 00:56:36 +000037
Evan Chenge5f62042007-09-29 00:00:36 +000038def SDTX86BrCond : SDTypeProfile<0, 3,
Evan Cheng0488db92007-09-25 01:57:46 +000039 [SDTCisVT<0, OtherVT>,
40 SDTCisVT<1, i8>, SDTCisVT<2, i32>]>;
Evan Chengaed7c722005-12-17 01:24:02 +000041
Evan Chenge5f62042007-09-29 00:00:36 +000042def SDTX86SetCC : SDTypeProfile<1, 2,
Evan Cheng0488db92007-09-25 01:57:46 +000043 [SDTCisVT<0, i8>,
44 SDTCisVT<1, i8>, SDTCisVT<2, i32>]>;
Evan Chengd5781fc2005-12-21 20:21:51 +000045
Andrew Lenharth26ed8692008-03-01 21:52:34 +000046def SDTX86cas : SDTypeProfile<0, 3, [SDTCisPtrTy<0>, SDTCisInt<1>,
47 SDTCisVT<2, i8>]>;
Andrew Lenharthd19189e2008-03-05 01:15:49 +000048def SDTX86cas8 : SDTypeProfile<0, 1, [SDTCisPtrTy<0>]>;
Andrew Lenharth26ed8692008-03-01 21:52:34 +000049
Dale Johannesen48c1bc22008-10-02 18:53:47 +000050def SDTX86atomicBinary : SDTypeProfile<2, 3, [SDTCisInt<0>, SDTCisInt<1>,
51 SDTCisPtrTy<2>, SDTCisInt<3>,SDTCisInt<4>]>;
Chris Lattner447ff682008-03-11 03:23:40 +000052def SDTX86Ret : SDTypeProfile<0, -1, [SDTCisVT<0, i16>]>;
Evan Cheng898101c2005-12-19 23:12:38 +000053
Bill Wendlingc69107c2007-11-13 09:19:02 +000054def SDT_X86CallSeqStart : SDCallSeqStart<[ SDTCisVT<0, i32> ]>;
55def SDT_X86CallSeqEnd : SDCallSeqEnd<[ SDTCisVT<0, i32>,
56 SDTCisVT<1, i32> ]>;
Evan Chenge3413162006-01-09 18:33:28 +000057
Dan Gohmand35121a2008-05-29 19:57:41 +000058def SDT_X86Call : SDTypeProfile<0, -1, [SDTCisVT<0, iPTR>]>;
Evan Chenge3413162006-01-09 18:33:28 +000059
Evan Cheng67f92a72006-01-11 22:15:48 +000060def SDTX86RepStr : SDTypeProfile<0, 1, [SDTCisVT<0, OtherVT>]>;
61
Evan Chenge3413162006-01-09 18:33:28 +000062def SDTX86RdTsc : SDTypeProfile<0, 0, []>;
Evan Chengd90eb7f2006-01-05 00:27:02 +000063
Evan Cheng71fb8342006-02-25 10:02:21 +000064def SDTX86Wrapper : SDTypeProfile<1, 1, [SDTCisSameAs<0, 1>, SDTCisPtrTy<0>]>;
65
Rafael Espindola2ee3db32009-04-17 14:35:58 +000066def SDT_X86TLSADDR : SDTypeProfile<0, 1, [SDTCisInt<0>]>;
Lauro Ramos Venanciob3a04172007-04-20 21:38:10 +000067
Rafael Espindola094fad32009-04-08 21:14:34 +000068def SDT_X86SegmentBaseAddress : SDTypeProfile<1, 1, [SDTCisPtrTy<0>]>;
Lauro Ramos Venanciob3a04172007-04-20 21:38:10 +000069
Anton Korobeynikov2365f512007-07-14 14:06:15 +000070def SDT_X86EHRET : SDTypeProfile<0, 1, [SDTCisInt<0>]>;
71
Arnold Schwaighoferc85e1712007-10-11 19:40:01 +000072def SDT_X86TCRET : SDTypeProfile<0, 2, [SDTCisPtrTy<0>, SDTCisVT<1, i32>]>;
73
Evan Cheng18efe262007-12-14 02:13:44 +000074def X86bsf : SDNode<"X86ISD::BSF", SDTIntUnaryOp>;
75def X86bsr : SDNode<"X86ISD::BSR", SDTIntUnaryOp>;
Evan Chenge3413162006-01-09 18:33:28 +000076def X86shld : SDNode<"X86ISD::SHLD", SDTIntShiftDOp>;
77def X86shrd : SDNode<"X86ISD::SHRD", SDTIntShiftDOp>;
Evan Chengb077b842005-12-21 02:39:21 +000078
Evan Chenge5f62042007-09-29 00:00:36 +000079def X86cmp : SDNode<"X86ISD::CMP" , SDTX86CmpTest>;
Evan Chengb077b842005-12-21 02:39:21 +000080
Dan Gohmanc7a37d42008-12-23 22:45:23 +000081def X86bt : SDNode<"X86ISD::BT", SDTX86CmpTest>;
82
Evan Chenge5f62042007-09-29 00:00:36 +000083def X86cmov : SDNode<"X86ISD::CMOV", SDTX86Cmov>;
Evan Chenge3413162006-01-09 18:33:28 +000084def X86brcond : SDNode<"X86ISD::BRCOND", SDTX86BrCond,
Evan Cheng0488db92007-09-25 01:57:46 +000085 [SDNPHasChain]>;
Evan Chenge5f62042007-09-29 00:00:36 +000086def X86setcc : SDNode<"X86ISD::SETCC", SDTX86SetCC>;
Evan Chengb077b842005-12-21 02:39:21 +000087
Andrew Lenharth26ed8692008-03-01 21:52:34 +000088def X86cas : SDNode<"X86ISD::LCMPXCHG_DAG", SDTX86cas,
89 [SDNPHasChain, SDNPInFlag, SDNPOutFlag, SDNPMayStore,
90 SDNPMayLoad]>;
Andrew Lenharthd19189e2008-03-05 01:15:49 +000091def X86cas8 : SDNode<"X86ISD::LCMPXCHG8_DAG", SDTX86cas8,
92 [SDNPHasChain, SDNPInFlag, SDNPOutFlag, SDNPMayStore,
93 SDNPMayLoad]>;
Dale Johannesen48c1bc22008-10-02 18:53:47 +000094def X86AtomAdd64 : SDNode<"X86ISD::ATOMADD64_DAG", SDTX86atomicBinary,
95 [SDNPHasChain, SDNPMayStore,
96 SDNPMayLoad, SDNPMemOperand]>;
97def X86AtomSub64 : SDNode<"X86ISD::ATOMSUB64_DAG", SDTX86atomicBinary,
98 [SDNPHasChain, SDNPMayStore,
99 SDNPMayLoad, SDNPMemOperand]>;
100def X86AtomOr64 : SDNode<"X86ISD::ATOMOR64_DAG", SDTX86atomicBinary,
101 [SDNPHasChain, SDNPMayStore,
102 SDNPMayLoad, SDNPMemOperand]>;
103def X86AtomXor64 : SDNode<"X86ISD::ATOMXOR64_DAG", SDTX86atomicBinary,
104 [SDNPHasChain, SDNPMayStore,
105 SDNPMayLoad, SDNPMemOperand]>;
106def X86AtomAnd64 : SDNode<"X86ISD::ATOMAND64_DAG", SDTX86atomicBinary,
107 [SDNPHasChain, SDNPMayStore,
108 SDNPMayLoad, SDNPMemOperand]>;
109def X86AtomNand64 : SDNode<"X86ISD::ATOMNAND64_DAG", SDTX86atomicBinary,
110 [SDNPHasChain, SDNPMayStore,
111 SDNPMayLoad, SDNPMemOperand]>;
Dale Johannesen880ae362008-10-03 22:25:52 +0000112def X86AtomSwap64 : SDNode<"X86ISD::ATOMSWAP64_DAG", SDTX86atomicBinary,
113 [SDNPHasChain, SDNPMayStore,
114 SDNPMayLoad, SDNPMemOperand]>;
Evan Chenge3413162006-01-09 18:33:28 +0000115def X86retflag : SDNode<"X86ISD::RET_FLAG", SDTX86Ret,
116 [SDNPHasChain, SDNPOptInFlag]>;
Evan Chengb077b842005-12-21 02:39:21 +0000117
Evan Chenge3413162006-01-09 18:33:28 +0000118def X86callseq_start :
119 SDNode<"ISD::CALLSEQ_START", SDT_X86CallSeqStart,
Evan Chengbb7b8442006-08-11 09:03:33 +0000120 [SDNPHasChain, SDNPOutFlag]>;
Evan Chenge3413162006-01-09 18:33:28 +0000121def X86callseq_end :
122 SDNode<"ISD::CALLSEQ_END", SDT_X86CallSeqEnd,
Arnold Schwaighoferc85e1712007-10-11 19:40:01 +0000123 [SDNPHasChain, SDNPOptInFlag, SDNPOutFlag]>;
Evan Chengb077b842005-12-21 02:39:21 +0000124
Evan Chenge3413162006-01-09 18:33:28 +0000125def X86call : SDNode<"X86ISD::CALL", SDT_X86Call,
126 [SDNPHasChain, SDNPOutFlag, SDNPOptInFlag]>;
Evan Chengaed7c722005-12-17 01:24:02 +0000127
Evan Chengfb914c42006-05-20 01:40:16 +0000128def X86tailcall: SDNode<"X86ISD::TAILCALL", SDT_X86Call,
Evan Chengfea89c12006-04-27 08:40:39 +0000129 [SDNPHasChain, SDNPOutFlag, SDNPOptInFlag]>;
130
Evan Cheng67f92a72006-01-11 22:15:48 +0000131def X86rep_stos: SDNode<"X86ISD::REP_STOS", SDTX86RepStr,
Chris Lattner9b37aaf2008-01-10 05:12:37 +0000132 [SDNPHasChain, SDNPInFlag, SDNPOutFlag, SDNPMayStore]>;
Evan Cheng67f92a72006-01-11 22:15:48 +0000133def X86rep_movs: SDNode<"X86ISD::REP_MOVS", SDTX86RepStr,
Chris Lattner9b37aaf2008-01-10 05:12:37 +0000134 [SDNPHasChain, SDNPInFlag, SDNPOutFlag, SDNPMayStore,
135 SDNPMayLoad]>;
Evan Cheng67f92a72006-01-11 22:15:48 +0000136
Evan Chenge3413162006-01-09 18:33:28 +0000137def X86rdtsc : SDNode<"X86ISD::RDTSC_DAG",SDTX86RdTsc,
Chris Lattnerba7e7562008-01-10 07:59:24 +0000138 [SDNPHasChain, SDNPOutFlag, SDNPSideEffect]>;
Evan Chengd90eb7f2006-01-05 00:27:02 +0000139
Evan Cheng0085a282006-11-30 21:55:46 +0000140def X86Wrapper : SDNode<"X86ISD::Wrapper", SDTX86Wrapper>;
141def X86WrapperRIP : SDNode<"X86ISD::WrapperRIP", SDTX86Wrapper>;
Evan Cheng71fb8342006-02-25 10:02:21 +0000142
Lauro Ramos Venanciob3a04172007-04-20 21:38:10 +0000143def X86tlsaddr : SDNode<"X86ISD::TLSADDR", SDT_X86TLSADDR,
Anton Korobeynikov6625eff2008-05-04 21:36:32 +0000144 [SDNPHasChain, SDNPOptInFlag, SDNPOutFlag]>;
Rafael Espindola094fad32009-04-08 21:14:34 +0000145def X86SegmentBaseAddress : SDNode<"X86ISD::SegmentBaseAddress",
146 SDT_X86SegmentBaseAddress, []>;
Lauro Ramos Venanciob3a04172007-04-20 21:38:10 +0000147
Anton Korobeynikov2365f512007-07-14 14:06:15 +0000148def X86ehret : SDNode<"X86ISD::EH_RETURN", SDT_X86EHRET,
149 [SDNPHasChain]>;
150
Arnold Schwaighoferc85e1712007-10-11 19:40:01 +0000151def X86tcret : SDNode<"X86ISD::TC_RETURN", SDT_X86TCRET,
152 [SDNPHasChain, SDNPOptInFlag]>;
Lauro Ramos Venanciob3a04172007-04-20 21:38:10 +0000153
Dan Gohman076aee32009-03-04 19:44:21 +0000154def X86add_flag : SDNode<"X86ISD::ADD", SDTBinaryArithWithFlags>;
155def X86sub_flag : SDNode<"X86ISD::SUB", SDTBinaryArithWithFlags>;
156def X86smul_flag : SDNode<"X86ISD::SMUL", SDTBinaryArithWithFlags>;
157def X86umul_flag : SDNode<"X86ISD::UMUL", SDTUnaryArithWithFlags>;
158def X86inc_flag : SDNode<"X86ISD::INC", SDTUnaryArithWithFlags>;
159def X86dec_flag : SDNode<"X86ISD::DEC", SDTUnaryArithWithFlags>;
Bill Wendlingab55ebd2008-12-12 00:56:36 +0000160
Evan Cheng73f24c92009-03-30 21:36:47 +0000161def X86mul_imm : SDNode<"X86ISD::MUL_IMM", SDTIntBinOp>;
162
Evan Chengaed7c722005-12-17 01:24:02 +0000163//===----------------------------------------------------------------------===//
164// X86 Operand Definitions.
165//
166
Chris Lattner66fa1dc2004-08-11 02:25:00 +0000167// *mem - Operand definitions for the funky X86 addressing mode operands.
168//
Evan Chengaf78ef52006-05-17 21:21:41 +0000169class X86MemOperand<string printMethod> : Operand<iPTR> {
Nate Begeman391c5d22005-11-30 18:54:35 +0000170 let PrintMethod = printMethod;
Rafael Espindola094fad32009-04-08 21:14:34 +0000171 let MIOperandInfo = (ops ptr_rc, i8imm, ptr_rc, i32imm, i8imm);
Chris Lattner66fa1dc2004-08-11 02:25:00 +0000172}
Nate Begeman391c5d22005-11-30 18:54:35 +0000173
Chris Lattner45432512005-12-17 19:47:05 +0000174def i8mem : X86MemOperand<"printi8mem">;
175def i16mem : X86MemOperand<"printi16mem">;
176def i32mem : X86MemOperand<"printi32mem">;
177def i64mem : X86MemOperand<"printi64mem">;
Evan Cheng470a6ad2006-02-22 02:26:30 +0000178def i128mem : X86MemOperand<"printi128mem">;
Chris Lattner45432512005-12-17 19:47:05 +0000179def f32mem : X86MemOperand<"printf32mem">;
180def f64mem : X86MemOperand<"printf64mem">;
Dale Johannesen59a58732007-08-05 18:49:15 +0000181def f80mem : X86MemOperand<"printf80mem">;
Evan Cheng223547a2006-01-31 22:28:30 +0000182def f128mem : X86MemOperand<"printf128mem">;
Nate Begeman391c5d22005-11-30 18:54:35 +0000183
Dan Gohman21e3dfb2009-04-13 16:09:41 +0000184// A version of i8mem for use on x86-64 that uses GR64_NOREX instead of
185// plain GR64, so that it doesn't potentially require a REX prefix.
186def i8mem_NOREX : Operand<i64> {
187 let PrintMethod = "printi8mem";
188 let MIOperandInfo = (ops GR64_NOREX, i8imm, GR64_NOREX, i32imm, i8imm);
189}
190
Evan Cheng25ab6902006-09-08 06:48:29 +0000191def lea32mem : Operand<i32> {
Rafael Espindola094fad32009-04-08 21:14:34 +0000192 let PrintMethod = "printlea32mem";
Evan Cheng25ab6902006-09-08 06:48:29 +0000193 let MIOperandInfo = (ops GR32, i8imm, GR32, i32imm);
194}
195
Nate Begeman16b04f32005-07-15 00:38:55 +0000196def SSECC : Operand<i8> {
197 let PrintMethod = "printSSECC";
198}
Chris Lattner66fa1dc2004-08-11 02:25:00 +0000199
Evan Cheng7ccced62006-02-18 00:15:05 +0000200def piclabel: Operand<i32> {
201 let PrintMethod = "printPICLabel";
202}
203
Chris Lattnerf124d5e2005-11-18 01:04:42 +0000204// A couple of more descriptive operand definitions.
205// 16-bits but only 8 bits are significant.
206def i16i8imm : Operand<i16>;
207// 32-bits but only 8 bits are significant.
208def i32i8imm : Operand<i32>;
209
Evan Chengd35b8c12005-12-04 08:19:43 +0000210// Branch targets have OtherVT type.
211def brtarget : Operand<OtherVT>;
212
Evan Chengaed7c722005-12-17 01:24:02 +0000213//===----------------------------------------------------------------------===//
214// X86 Complex Pattern Definitions.
215//
216
Evan Chengec693f72005-12-08 02:01:35 +0000217// Define X86 specific addressing mode.
Rafael Espindola094fad32009-04-08 21:14:34 +0000218def addr : ComplexPattern<iPTR, 5, "SelectAddr", [], []>;
Evan Cheng25ab6902006-09-08 06:48:29 +0000219def lea32addr : ComplexPattern<i32, 4, "SelectLEAAddr",
Evan Chengaf9db752006-10-11 21:03:53 +0000220 [add, mul, shl, or, frameindex], []>;
Evan Chengec693f72005-12-08 02:01:35 +0000221
Evan Chengaed7c722005-12-17 01:24:02 +0000222//===----------------------------------------------------------------------===//
Evan Chengbbc8ddb2005-12-20 22:59:51 +0000223// X86 Instruction Predicate Definitions.
Evan Cheng28b514392006-12-05 19:50:18 +0000224def HasMMX : Predicate<"Subtarget->hasMMX()">;
225def HasSSE1 : Predicate<"Subtarget->hasSSE1()">;
226def HasSSE2 : Predicate<"Subtarget->hasSSE2()">;
227def HasSSE3 : Predicate<"Subtarget->hasSSE3()">;
Bill Wendlingbb1ee052007-04-10 22:10:25 +0000228def HasSSSE3 : Predicate<"Subtarget->hasSSSE3()">;
Nate Begeman63ec90a2008-02-03 07:18:54 +0000229def HasSSE41 : Predicate<"Subtarget->hasSSE41()">;
230def HasSSE42 : Predicate<"Subtarget->hasSSE42()">;
Dale Johannesenf1fc3a82007-09-23 14:52:20 +0000231def FPStackf32 : Predicate<"!Subtarget->hasSSE1()">;
232def FPStackf64 : Predicate<"!Subtarget->hasSSE2()">;
Evan Cheng28b514392006-12-05 19:50:18 +0000233def In32BitMode : Predicate<"!Subtarget->is64Bit()">;
234def In64BitMode : Predicate<"Subtarget->is64Bit()">;
235def SmallCode : Predicate<"TM.getCodeModel() == CodeModel::Small">;
236def NotSmallCode : Predicate<"TM.getCodeModel() != CodeModel::Small">;
237def IsStatic : Predicate<"TM.getRelocationModel() == Reloc::Static">;
Evan Chengb7a75a52008-09-26 23:41:32 +0000238def OptForSpeed : Predicate<"!OptForSize">;
Evan Chengccb69762009-01-02 05:35:45 +0000239def FastBTMem : Predicate<"!Subtarget->isBTMemSlow()">;
Evan Chengbbc8ddb2005-12-20 22:59:51 +0000240
241//===----------------------------------------------------------------------===//
Evan Chengc64a1a92007-07-31 08:04:03 +0000242// X86 Instruction Format Definitions.
Evan Chengaed7c722005-12-17 01:24:02 +0000243//
244
Evan Chengc64a1a92007-07-31 08:04:03 +0000245include "X86InstrFormats.td"
Chris Lattner1cca5e32003-08-03 21:54:21 +0000246
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +0000247//===----------------------------------------------------------------------===//
Chris Lattnerf124d5e2005-11-18 01:04:42 +0000248// Pattern fragments...
249//
Evan Chengd9558e02006-01-06 00:43:03 +0000250
251// X86 specific condition code. These correspond to CondCode in
Nate Begeman9a225302007-05-06 04:00:55 +0000252// X86InstrInfo.h. They must be kept in synch.
Dan Gohman653456c2009-01-07 00:15:08 +0000253def X86_COND_A : PatLeaf<(i8 0)>; // alt. COND_NBE
254def X86_COND_AE : PatLeaf<(i8 1)>; // alt. COND_NC
255def X86_COND_B : PatLeaf<(i8 2)>; // alt. COND_C
256def X86_COND_BE : PatLeaf<(i8 3)>; // alt. COND_NA
257def X86_COND_E : PatLeaf<(i8 4)>; // alt. COND_Z
258def X86_COND_G : PatLeaf<(i8 5)>; // alt. COND_NLE
259def X86_COND_GE : PatLeaf<(i8 6)>; // alt. COND_NL
260def X86_COND_L : PatLeaf<(i8 7)>; // alt. COND_NGE
261def X86_COND_LE : PatLeaf<(i8 8)>; // alt. COND_NG
262def X86_COND_NE : PatLeaf<(i8 9)>; // alt. COND_NZ
Evan Chengd9558e02006-01-06 00:43:03 +0000263def X86_COND_NO : PatLeaf<(i8 10)>;
Dan Gohman653456c2009-01-07 00:15:08 +0000264def X86_COND_NP : PatLeaf<(i8 11)>; // alt. COND_PO
Evan Chengd9558e02006-01-06 00:43:03 +0000265def X86_COND_NS : PatLeaf<(i8 12)>;
Dan Gohman653456c2009-01-07 00:15:08 +0000266def X86_COND_O : PatLeaf<(i8 13)>;
267def X86_COND_P : PatLeaf<(i8 14)>; // alt. COND_PE
268def X86_COND_S : PatLeaf<(i8 15)>;
Evan Chengd9558e02006-01-06 00:43:03 +0000269
Evan Cheng9b6b6422005-12-13 00:14:11 +0000270def i16immSExt8 : PatLeaf<(i16 imm), [{
271 // i16immSExt8 predicate - True if the 16-bit immediate fits in a 8-bit
Evan Chengb3558542005-12-13 00:01:09 +0000272 // sign extended field.
Dan Gohmanf5aeb1a2008-09-12 16:56:44 +0000273 return (int16_t)N->getZExtValue() == (int8_t)N->getZExtValue();
Chris Lattnerf124d5e2005-11-18 01:04:42 +0000274}]>;
275
Evan Cheng9b6b6422005-12-13 00:14:11 +0000276def i32immSExt8 : PatLeaf<(i32 imm), [{
277 // i32immSExt8 predicate - True if the 32-bit immediate fits in a 8-bit
Evan Chengb3558542005-12-13 00:01:09 +0000278 // sign extended field.
Dan Gohmanf5aeb1a2008-09-12 16:56:44 +0000279 return (int32_t)N->getZExtValue() == (int8_t)N->getZExtValue();
Evan Chengb3558542005-12-13 00:01:09 +0000280}]>;
281
Evan Cheng605c4152005-12-13 01:57:51 +0000282// Helper fragments for loads.
Evan Chengb6564432008-05-13 18:59:59 +0000283// It's always safe to treat a anyext i16 load as a i32 load if the i16 is
284// known to be 32-bit aligned or better. Ditto for i8 to i16.
Dan Gohman33586292008-10-15 06:50:19 +0000285def loadi16 : PatFrag<(ops node:$ptr), (i16 (unindexedload node:$ptr)), [{
Dan Gohman67ca6be2008-08-20 15:24:22 +0000286 LoadSDNode *LD = cast<LoadSDNode>(N);
Chris Lattnerc2406f22009-04-10 00:16:23 +0000287 if (const Value *Src = LD->getSrcValue())
288 if (const PointerType *PT = dyn_cast<PointerType>(Src->getType()))
Mon P Wanga7e01d72009-04-27 07:22:10 +0000289 if (PT->getAddressSpace() > 255)
Chris Lattnerc2406f22009-04-10 00:16:23 +0000290 return false;
Dan Gohman67ca6be2008-08-20 15:24:22 +0000291 ISD::LoadExtType ExtType = LD->getExtensionType();
292 if (ExtType == ISD::NON_EXTLOAD)
293 return true;
294 if (ExtType == ISD::EXTLOAD)
295 return LD->getAlignment() >= 2 && !LD->isVolatile();
Evan Chengfa7fd332008-05-13 00:54:02 +0000296 return false;
297}]>;
298
Dan Gohman33586292008-10-15 06:50:19 +0000299def loadi16_anyext : PatFrag<(ops node:$ptr), (i32 (unindexedload node:$ptr)), [{
Evan Chengca57f782008-09-24 23:27:55 +0000300 LoadSDNode *LD = cast<LoadSDNode>(N);
Chris Lattnerc2406f22009-04-10 00:16:23 +0000301 if (const Value *Src = LD->getSrcValue())
302 if (const PointerType *PT = dyn_cast<PointerType>(Src->getType()))
Mon P Wanga7e01d72009-04-27 07:22:10 +0000303 if (PT->getAddressSpace() > 255)
Chris Lattnerc2406f22009-04-10 00:16:23 +0000304 return false;
Evan Chengca57f782008-09-24 23:27:55 +0000305 ISD::LoadExtType ExtType = LD->getExtensionType();
306 if (ExtType == ISD::EXTLOAD)
307 return LD->getAlignment() >= 2 && !LD->isVolatile();
308 return false;
309}]>;
310
Dan Gohman33586292008-10-15 06:50:19 +0000311def loadi32 : PatFrag<(ops node:$ptr), (i32 (unindexedload node:$ptr)), [{
Dan Gohman67ca6be2008-08-20 15:24:22 +0000312 LoadSDNode *LD = cast<LoadSDNode>(N);
Chris Lattnerc2406f22009-04-10 00:16:23 +0000313 if (const Value *Src = LD->getSrcValue())
314 if (const PointerType *PT = dyn_cast<PointerType>(Src->getType()))
Mon P Wanga7e01d72009-04-27 07:22:10 +0000315 if (PT->getAddressSpace() > 255)
Chris Lattnerc2406f22009-04-10 00:16:23 +0000316 return false;
Dan Gohman67ca6be2008-08-20 15:24:22 +0000317 ISD::LoadExtType ExtType = LD->getExtensionType();
318 if (ExtType == ISD::NON_EXTLOAD)
319 return true;
320 if (ExtType == ISD::EXTLOAD)
321 return LD->getAlignment() >= 4 && !LD->isVolatile();
Evan Chengfa7fd332008-05-13 00:54:02 +0000322 return false;
323}]>;
324
Dan Gohman33586292008-10-15 06:50:19 +0000325def nvloadi32 : PatFrag<(ops node:$ptr), (i32 (unindexedload node:$ptr)), [{
Evan Chengd47e0b62008-09-29 17:26:18 +0000326 LoadSDNode *LD = cast<LoadSDNode>(N);
Chris Lattnerc2406f22009-04-10 00:16:23 +0000327 if (const Value *Src = LD->getSrcValue())
328 if (const PointerType *PT = dyn_cast<PointerType>(Src->getType()))
Mon P Wanga7e01d72009-04-27 07:22:10 +0000329 if (PT->getAddressSpace() > 255)
Chris Lattnerc2406f22009-04-10 00:16:23 +0000330 return false;
Evan Chengd47e0b62008-09-29 17:26:18 +0000331 if (LD->isVolatile())
332 return false;
Evan Chengd47e0b62008-09-29 17:26:18 +0000333 ISD::LoadExtType ExtType = LD->getExtensionType();
334 if (ExtType == ISD::NON_EXTLOAD)
335 return true;
336 if (ExtType == ISD::EXTLOAD)
337 return LD->getAlignment() >= 4;
338 return false;
339}]>;
340
Nate Begeman51a04372009-01-26 01:24:32 +0000341def gsload : PatFrag<(ops node:$ptr), (load node:$ptr), [{
Chris Lattnerc2406f22009-04-10 00:16:23 +0000342 if (const Value *Src = cast<LoadSDNode>(N)->getSrcValue())
343 if (const PointerType *PT = dyn_cast<PointerType>(Src->getType()))
344 return PT->getAddressSpace() == 256;
Nate Begeman51a04372009-01-26 01:24:32 +0000345 return false;
346}]>;
347
Chris Lattnerc2406f22009-04-10 00:16:23 +0000348def loadi8 : PatFrag<(ops node:$ptr), (i8 (load node:$ptr)), [{
349 if (const Value *Src = cast<LoadSDNode>(N)->getSrcValue())
350 if (const PointerType *PT = dyn_cast<PointerType>(Src->getType()))
Mon P Wanga7e01d72009-04-27 07:22:10 +0000351 if (PT->getAddressSpace() > 255)
Chris Lattnerc2406f22009-04-10 00:16:23 +0000352 return false;
353 return true;
354}]>;
355def loadi64 : PatFrag<(ops node:$ptr), (i64 (load node:$ptr)), [{
356 if (const Value *Src = cast<LoadSDNode>(N)->getSrcValue())
357 if (const PointerType *PT = dyn_cast<PointerType>(Src->getType()))
Mon P Wanga7e01d72009-04-27 07:22:10 +0000358 if (PT->getAddressSpace() > 255)
Chris Lattnerc2406f22009-04-10 00:16:23 +0000359 return false;
360 return true;
361}]>;
Evan Cheng06a8aa12006-03-17 19:55:52 +0000362
Chris Lattnerc2406f22009-04-10 00:16:23 +0000363def loadf32 : PatFrag<(ops node:$ptr), (f32 (load node:$ptr)), [{
364 if (const Value *Src = cast<LoadSDNode>(N)->getSrcValue())
365 if (const PointerType *PT = dyn_cast<PointerType>(Src->getType()))
Mon P Wanga7e01d72009-04-27 07:22:10 +0000366 if (PT->getAddressSpace() > 255)
Chris Lattnerc2406f22009-04-10 00:16:23 +0000367 return false;
368 return true;
369}]>;
370def loadf64 : PatFrag<(ops node:$ptr), (f64 (load node:$ptr)), [{
371 if (const Value *Src = cast<LoadSDNode>(N)->getSrcValue())
372 if (const PointerType *PT = dyn_cast<PointerType>(Src->getType()))
Mon P Wanga7e01d72009-04-27 07:22:10 +0000373 if (PT->getAddressSpace() > 255)
Chris Lattnerc2406f22009-04-10 00:16:23 +0000374 return false;
375 return true;
376}]>;
377def loadf80 : PatFrag<(ops node:$ptr), (f80 (load node:$ptr)), [{
378 if (const Value *Src = cast<LoadSDNode>(N)->getSrcValue())
379 if (const PointerType *PT = dyn_cast<PointerType>(Src->getType()))
Mon P Wanga7e01d72009-04-27 07:22:10 +0000380 if (PT->getAddressSpace() > 255)
Chris Lattnerc2406f22009-04-10 00:16:23 +0000381 return false;
382 return true;
383}]>;
Evan Cheng7a7e8372005-12-14 02:22:27 +0000384
Evan Cheng466685d2006-10-09 20:57:25 +0000385def sextloadi16i8 : PatFrag<(ops node:$ptr), (i16 (sextloadi8 node:$ptr))>;
386def sextloadi32i8 : PatFrag<(ops node:$ptr), (i32 (sextloadi8 node:$ptr))>;
387def sextloadi32i16 : PatFrag<(ops node:$ptr), (i32 (sextloadi16 node:$ptr))>;
Evan Cheng7a7e8372005-12-14 02:22:27 +0000388
Evan Cheng466685d2006-10-09 20:57:25 +0000389def zextloadi8i1 : PatFrag<(ops node:$ptr), (i8 (zextloadi1 node:$ptr))>;
390def zextloadi16i1 : PatFrag<(ops node:$ptr), (i16 (zextloadi1 node:$ptr))>;
391def zextloadi32i1 : PatFrag<(ops node:$ptr), (i32 (zextloadi1 node:$ptr))>;
392def zextloadi16i8 : PatFrag<(ops node:$ptr), (i16 (zextloadi8 node:$ptr))>;
393def zextloadi32i8 : PatFrag<(ops node:$ptr), (i32 (zextloadi8 node:$ptr))>;
394def zextloadi32i16 : PatFrag<(ops node:$ptr), (i32 (zextloadi16 node:$ptr))>;
Evan Cheng7a7e8372005-12-14 02:22:27 +0000395
Evan Cheng466685d2006-10-09 20:57:25 +0000396def extloadi8i1 : PatFrag<(ops node:$ptr), (i8 (extloadi1 node:$ptr))>;
397def extloadi16i1 : PatFrag<(ops node:$ptr), (i16 (extloadi1 node:$ptr))>;
398def extloadi32i1 : PatFrag<(ops node:$ptr), (i32 (extloadi1 node:$ptr))>;
399def extloadi16i8 : PatFrag<(ops node:$ptr), (i16 (extloadi8 node:$ptr))>;
400def extloadi32i8 : PatFrag<(ops node:$ptr), (i32 (extloadi8 node:$ptr))>;
401def extloadi32i16 : PatFrag<(ops node:$ptr), (i32 (extloadi16 node:$ptr))>;
Evan Cheng747a90d2006-02-21 02:24:38 +0000402
Chris Lattnerce2bcc82008-02-19 17:37:35 +0000403
404// An 'and' node with a single use.
405def and_su : PatFrag<(ops node:$lhs, node:$rhs), (and node:$lhs, node:$rhs), [{
Evan Cheng07b7ea12008-03-04 00:40:35 +0000406 return N->hasOneUse();
Chris Lattnerce2bcc82008-02-19 17:37:35 +0000407}]>;
Dan Gohman21e3dfb2009-04-13 16:09:41 +0000408// An 'srl' node with a single use.
409def srl_su : PatFrag<(ops node:$lhs, node:$rhs), (srl node:$lhs, node:$rhs), [{
410 return N->hasOneUse();
411}]>;
412// An 'trunc' node with a single use.
413def trunc_su : PatFrag<(ops node:$src), (trunc node:$src), [{
414 return N->hasOneUse();
415}]>;
Chris Lattnerce2bcc82008-02-19 17:37:35 +0000416
Dan Gohman74feef22008-10-17 01:23:35 +0000417// 'shld' and 'shrd' instruction patterns. Note that even though these have
418// the srl and shl in their patterns, the C++ code must still check for them,
419// because predicates are tested before children nodes are explored.
420
421def shrd : PatFrag<(ops node:$src1, node:$amt1, node:$src2, node:$amt2),
422 (or (srl node:$src1, node:$amt1),
423 (shl node:$src2, node:$amt2)), [{
424 assert(N->getOpcode() == ISD::OR);
425 return N->getOperand(0).getOpcode() == ISD::SRL &&
426 N->getOperand(1).getOpcode() == ISD::SHL &&
427 isa<ConstantSDNode>(N->getOperand(0).getOperand(1)) &&
428 isa<ConstantSDNode>(N->getOperand(1).getOperand(1)) &&
429 N->getOperand(0).getConstantOperandVal(1) ==
430 N->getValueSizeInBits(0) - N->getOperand(1).getConstantOperandVal(1);
431}]>;
432
433def shld : PatFrag<(ops node:$src1, node:$amt1, node:$src2, node:$amt2),
434 (or (shl node:$src1, node:$amt1),
435 (srl node:$src2, node:$amt2)), [{
436 assert(N->getOpcode() == ISD::OR);
437 return N->getOperand(0).getOpcode() == ISD::SHL &&
438 N->getOperand(1).getOpcode() == ISD::SRL &&
439 isa<ConstantSDNode>(N->getOperand(0).getOperand(1)) &&
440 isa<ConstantSDNode>(N->getOperand(1).getOperand(1)) &&
441 N->getOperand(0).getConstantOperandVal(1) ==
442 N->getValueSizeInBits(0) - N->getOperand(1).getConstantOperandVal(1);
443}]>;
444
Chris Lattnerf124d5e2005-11-18 01:04:42 +0000445//===----------------------------------------------------------------------===//
Chris Lattner1cca5e32003-08-03 21:54:21 +0000446// Instruction list...
447//
448
Chris Lattnerf18c0742006-10-12 17:42:56 +0000449// ADJCALLSTACKDOWN/UP implicitly use/def ESP because they may be expanded into
450// a stack adjustment and the codegen must know that they may modify the stack
451// pointer before prolog-epilog rewriting occurs.
Chris Lattner447ff682008-03-11 03:23:40 +0000452// Pessimistically assume ADJCALLSTACKDOWN / ADJCALLSTACKUP will become
453// sub / add which can clobber EFLAGS.
Evan Cheng8decf6b2007-09-28 01:19:48 +0000454let Defs = [ESP, EFLAGS], Uses = [ESP] in {
Dan Gohman6d4b0522008-10-01 18:28:06 +0000455def ADJCALLSTACKDOWN32 : I<0, Pseudo, (outs), (ins i32imm:$amt),
456 "#ADJCALLSTACKDOWN",
Chris Lattnere563bbc2008-10-11 22:08:30 +0000457 [(X86callseq_start timm:$amt)]>,
Dan Gohman6d4b0522008-10-01 18:28:06 +0000458 Requires<[In32BitMode]>;
459def ADJCALLSTACKUP32 : I<0, Pseudo, (outs), (ins i32imm:$amt1, i32imm:$amt2),
460 "#ADJCALLSTACKUP",
Chris Lattnere563bbc2008-10-11 22:08:30 +0000461 [(X86callseq_end timm:$amt1, timm:$amt2)]>,
Dan Gohman6d4b0522008-10-01 18:28:06 +0000462 Requires<[In32BitMode]>;
Evan Cheng071a2792007-09-11 19:55:27 +0000463}
Evan Cheng4a460802006-01-11 00:33:36 +0000464
465// Nop
Chris Lattnerba7e7562008-01-10 07:59:24 +0000466let neverHasSideEffects = 1 in
467 def NOOP : I<0x90, RawFrm, (outs), (ins), "nop", []>;
Evan Cheng4a460802006-01-11 00:33:36 +0000468
Evan Cheng0475ab52008-01-05 00:41:47 +0000469// PIC base
Dan Gohman2662d552008-10-01 04:14:30 +0000470let neverHasSideEffects = 1, isNotDuplicable = 1, Uses = [ESP] in
Chris Lattnerba7e7562008-01-10 07:59:24 +0000471 def MOVPC32r : Ii32<0xE8, Pseudo, (outs GR32:$reg), (ins piclabel:$label),
Dan Gohman4d47b9b2009-04-27 15:13:28 +0000472 "call\t$label\n\t"
473 "pop{l}\t$reg", []>;
Evan Cheng8f7f7122006-05-05 05:40:20 +0000474
Chris Lattner1cca5e32003-08-03 21:54:21 +0000475//===----------------------------------------------------------------------===//
476// Control Flow Instructions...
477//
478
Chris Lattner1be48112005-05-13 17:56:48 +0000479// Return instructions.
Evan Cheng2b4ea792005-12-26 09:11:45 +0000480let isTerminator = 1, isReturn = 1, isBarrier = 1,
Chris Lattner447ff682008-03-11 03:23:40 +0000481 hasCtrlDep = 1, FPForm = SpecialFP, FPFormBits = SpecialFP.Value in {
Dan Gohmane4c67cd2008-05-31 02:11:25 +0000482 def RET : I <0xC3, RawFrm, (outs), (ins variable_ops),
Chris Lattner447ff682008-03-11 03:23:40 +0000483 "ret",
Dan Gohmane4c67cd2008-05-31 02:11:25 +0000484 [(X86retflag 0)]>;
Chris Lattner447ff682008-03-11 03:23:40 +0000485 def RETI : Ii16<0xC2, RawFrm, (outs), (ins i16imm:$amt, variable_ops),
486 "ret\t$amt",
Evan Chenge3413162006-01-09 18:33:28 +0000487 [(X86retflag imm:$amt)]>;
Evan Cheng171049d2005-12-23 22:14:32 +0000488}
Chris Lattner1cca5e32003-08-03 21:54:21 +0000489
490// All branches are RawFrm, Void, Branch, and Terminators
Evan Chengffbacca2007-07-21 00:34:19 +0000491let isBranch = 1, isTerminator = 1 in
Evan Cheng64d80e32007-07-19 01:14:50 +0000492 class IBr<bits<8> opcode, dag ins, string asm, list<dag> pattern> :
493 I<opcode, RawFrm, (outs), ins, asm, pattern>;
Chris Lattner1cca5e32003-08-03 21:54:21 +0000494
Evan Chengec3bc392006-09-07 19:03:48 +0000495let isBranch = 1, isBarrier = 1 in
Dan Gohmanb1576f52007-07-31 20:11:57 +0000496 def JMP : IBr<0xE9, (ins brtarget:$dst), "jmp\t$dst", [(br bb:$dst)]>;
Evan Cheng898101c2005-12-19 23:12:38 +0000497
Owen Anderson20ab2902007-11-12 07:39:39 +0000498// Indirect branches
499let isBranch = 1, isTerminator = 1, isBarrier = 1, isIndirectBranch = 1 in {
Dan Gohmanb1576f52007-07-31 20:11:57 +0000500 def JMP32r : I<0xFF, MRM4r, (outs), (ins GR32:$dst), "jmp{l}\t{*}$dst",
Evan Cheng069287d2006-05-16 07:21:53 +0000501 [(brind GR32:$dst)]>;
Dan Gohmanb1576f52007-07-31 20:11:57 +0000502 def JMP32m : I<0xFF, MRM4m, (outs), (ins i32mem:$dst), "jmp{l}\t{*}$dst",
Evan Cheng25ab6902006-09-08 06:48:29 +0000503 [(brind (loadi32 addr:$dst))]>;
Nate Begeman37efe672006-04-22 18:53:45 +0000504}
505
506// Conditional branches
Evan Cheng0488db92007-09-25 01:57:46 +0000507let Uses = [EFLAGS] in {
Dan Gohmanb1576f52007-07-31 20:11:57 +0000508def JE : IBr<0x84, (ins brtarget:$dst), "je\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +0000509 [(X86brcond bb:$dst, X86_COND_E, EFLAGS)]>, TB;
Dan Gohmanb1576f52007-07-31 20:11:57 +0000510def JNE : IBr<0x85, (ins brtarget:$dst), "jne\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +0000511 [(X86brcond bb:$dst, X86_COND_NE, EFLAGS)]>, TB;
Dan Gohmanb1576f52007-07-31 20:11:57 +0000512def JL : IBr<0x8C, (ins brtarget:$dst), "jl\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +0000513 [(X86brcond bb:$dst, X86_COND_L, EFLAGS)]>, TB;
Dan Gohmanb1576f52007-07-31 20:11:57 +0000514def JLE : IBr<0x8E, (ins brtarget:$dst), "jle\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +0000515 [(X86brcond bb:$dst, X86_COND_LE, EFLAGS)]>, TB;
Dan Gohmanb1576f52007-07-31 20:11:57 +0000516def JG : IBr<0x8F, (ins brtarget:$dst), "jg\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +0000517 [(X86brcond bb:$dst, X86_COND_G, EFLAGS)]>, TB;
Dan Gohmanb1576f52007-07-31 20:11:57 +0000518def JGE : IBr<0x8D, (ins brtarget:$dst), "jge\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +0000519 [(X86brcond bb:$dst, X86_COND_GE, EFLAGS)]>, TB;
Evan Cheng898101c2005-12-19 23:12:38 +0000520
Dan Gohmanb1576f52007-07-31 20:11:57 +0000521def JB : IBr<0x82, (ins brtarget:$dst), "jb\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +0000522 [(X86brcond bb:$dst, X86_COND_B, EFLAGS)]>, TB;
Dan Gohmanb1576f52007-07-31 20:11:57 +0000523def JBE : IBr<0x86, (ins brtarget:$dst), "jbe\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +0000524 [(X86brcond bb:$dst, X86_COND_BE, EFLAGS)]>, TB;
Dan Gohmanb1576f52007-07-31 20:11:57 +0000525def JA : IBr<0x87, (ins brtarget:$dst), "ja\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +0000526 [(X86brcond bb:$dst, X86_COND_A, EFLAGS)]>, TB;
Dan Gohmanb1576f52007-07-31 20:11:57 +0000527def JAE : IBr<0x83, (ins brtarget:$dst), "jae\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +0000528 [(X86brcond bb:$dst, X86_COND_AE, EFLAGS)]>, TB;
Evan Cheng898101c2005-12-19 23:12:38 +0000529
Dan Gohmanb1576f52007-07-31 20:11:57 +0000530def JS : IBr<0x88, (ins brtarget:$dst), "js\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +0000531 [(X86brcond bb:$dst, X86_COND_S, EFLAGS)]>, TB;
Dan Gohmanb1576f52007-07-31 20:11:57 +0000532def JNS : IBr<0x89, (ins brtarget:$dst), "jns\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +0000533 [(X86brcond bb:$dst, X86_COND_NS, EFLAGS)]>, TB;
Dan Gohmanb1576f52007-07-31 20:11:57 +0000534def JP : IBr<0x8A, (ins brtarget:$dst), "jp\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +0000535 [(X86brcond bb:$dst, X86_COND_P, EFLAGS)]>, TB;
Dan Gohmanb1576f52007-07-31 20:11:57 +0000536def JNP : IBr<0x8B, (ins brtarget:$dst), "jnp\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +0000537 [(X86brcond bb:$dst, X86_COND_NP, EFLAGS)]>, TB;
Dan Gohmanb1576f52007-07-31 20:11:57 +0000538def JO : IBr<0x80, (ins brtarget:$dst), "jo\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +0000539 [(X86brcond bb:$dst, X86_COND_O, EFLAGS)]>, TB;
Dan Gohmanb1576f52007-07-31 20:11:57 +0000540def JNO : IBr<0x81, (ins brtarget:$dst), "jno\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +0000541 [(X86brcond bb:$dst, X86_COND_NO, EFLAGS)]>, TB;
Evan Cheng0488db92007-09-25 01:57:46 +0000542} // Uses = [EFLAGS]
Chris Lattner1cca5e32003-08-03 21:54:21 +0000543
544//===----------------------------------------------------------------------===//
545// Call Instructions...
546//
Evan Chengffbacca2007-07-21 00:34:19 +0000547let isCall = 1 in
Dan Gohman6d4b0522008-10-01 18:28:06 +0000548 // All calls clobber the non-callee saved registers. ESP is marked as
549 // a use to prevent stack-pointer assignments that appear immediately
550 // before calls from potentially appearing dead. Uses for argument
551 // registers are added manually.
Nate Begemanf63be7d2005-07-06 18:59:04 +0000552 let Defs = [EAX, ECX, EDX, FP0, FP1, FP2, FP3, FP4, FP5, FP6, ST0,
Bill Wendling3f3a17d2007-04-25 21:31:48 +0000553 MM0, MM1, MM2, MM3, MM4, MM5, MM6, MM7,
Evan Cheng109a5622008-10-17 21:02:22 +0000554 XMM0, XMM1, XMM2, XMM3, XMM4, XMM5, XMM6, XMM7,
555 XMM8, XMM9, XMM10, XMM11, XMM12, XMM13, XMM14, XMM15, EFLAGS],
Dan Gohman2662d552008-10-01 04:14:30 +0000556 Uses = [ESP] in {
Evan Chengf02ca692007-12-22 02:26:46 +0000557 def CALLpcrel32 : Ii32<0xE8, RawFrm, (outs), (ins i32imm:$dst,variable_ops),
Evan Chenga0652002009-03-12 18:15:39 +0000558 "call\t${dst:call}", [(X86call imm:$dst)]>,
559 Requires<[In32BitMode]>;
Evan Cheng64d80e32007-07-19 01:14:50 +0000560 def CALL32r : I<0xFF, MRM2r, (outs), (ins GR32:$dst, variable_ops),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000561 "call\t{*}$dst", [(X86call GR32:$dst)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +0000562 def CALL32m : I<0xFF, MRM2m, (outs), (ins i32mem:$dst, variable_ops),
Dan Gohmanb4106172008-05-29 21:50:34 +0000563 "call\t{*}$dst", [(X86call (loadi32 addr:$dst))]>;
Chris Lattner1cca5e32003-08-03 21:54:21 +0000564 }
565
Chris Lattner1e9448b2005-05-15 03:10:37 +0000566// Tail call stuff.
Arnold Schwaighoferc85e1712007-10-11 19:40:01 +0000567
Chris Lattner447ff682008-03-11 03:23:40 +0000568def TAILCALL : I<0, Pseudo, (outs), (ins),
Arnold Schwaighoferc85e1712007-10-11 19:40:01 +0000569 "#TAILCALL",
570 []>;
571
Evan Chengffbacca2007-07-21 00:34:19 +0000572let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1 in
Arnold Schwaighofer4fe30732008-03-19 16:39:45 +0000573def TCRETURNdi : I<0, Pseudo, (outs), (ins i32imm:$dst, i32imm:$offset, variable_ops),
Arnold Schwaighoferc85e1712007-10-11 19:40:01 +0000574 "#TC_RETURN $dst $offset",
575 []>;
576
577let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1 in
Arnold Schwaighofer4fe30732008-03-19 16:39:45 +0000578def TCRETURNri : I<0, Pseudo, (outs), (ins GR32:$dst, i32imm:$offset, variable_ops),
Arnold Schwaighoferc85e1712007-10-11 19:40:01 +0000579 "#TC_RETURN $dst $offset",
580 []>;
581
582let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1 in
Arnold Schwaighofer30e62c02008-04-30 09:16:33 +0000583
Arnold Schwaighoferc85e1712007-10-11 19:40:01 +0000584 def TAILJMPd : IBr<0xE9, (ins i32imm:$dst), "jmp\t${dst:call} # TAILCALL",
Evan Chengf10c17f2006-09-22 21:43:59 +0000585 []>;
Evan Chengffbacca2007-07-21 00:34:19 +0000586let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1 in
Arnold Schwaighoferc85e1712007-10-11 19:40:01 +0000587 def TAILJMPr : I<0xFF, MRM4r, (outs), (ins GR32:$dst), "jmp{l}\t{*}$dst # TAILCALL",
588 []>;
Evan Chengffbacca2007-07-21 00:34:19 +0000589let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1 in
Evan Cheng64d80e32007-07-19 01:14:50 +0000590 def TAILJMPm : I<0xFF, MRM4m, (outs), (ins i32mem:$dst),
Arnold Schwaighoferc85e1712007-10-11 19:40:01 +0000591 "jmp\t{*}$dst # TAILCALL", []>;
Chris Lattner1e9448b2005-05-15 03:10:37 +0000592
Chris Lattner1cca5e32003-08-03 21:54:21 +0000593//===----------------------------------------------------------------------===//
594// Miscellaneous Instructions...
595//
Chris Lattnerba7e7562008-01-10 07:59:24 +0000596let Defs = [EBP, ESP], Uses = [EBP, ESP], mayLoad = 1, neverHasSideEffects=1 in
Chris Lattner30bf2d82004-08-10 20:17:41 +0000597def LEAVE : I<0xC9, RawFrm,
Evan Cheng071a2792007-09-11 19:55:27 +0000598 (outs), (ins), "leave", []>;
599
Chris Lattnerba7e7562008-01-10 07:59:24 +0000600let Defs = [ESP], Uses = [ESP], neverHasSideEffects=1 in {
601let mayLoad = 1 in
Evan Cheng2f245ba2007-09-26 01:29:06 +0000602def POP32r : I<0x58, AddRegFrm, (outs GR32:$reg), (ins), "pop{l}\t$reg", []>;
Chris Lattner1cca5e32003-08-03 21:54:21 +0000603
Chris Lattnerba7e7562008-01-10 07:59:24 +0000604let mayStore = 1 in
Evan Cheng2f245ba2007-09-26 01:29:06 +0000605def PUSH32r : I<0x50, AddRegFrm, (outs), (ins GR32:$reg), "push{l}\t$reg",[]>;
Evan Cheng071a2792007-09-11 19:55:27 +0000606}
Anton Korobeynikov57fc00d2007-04-17 09:20:00 +0000607
Chris Lattnerba7e7562008-01-10 07:59:24 +0000608let Defs = [ESP, EFLAGS], Uses = [ESP], mayLoad = 1, neverHasSideEffects=1 in
Evan Chengbf4f89d2007-09-26 21:28:00 +0000609def POPFD : I<0x9D, RawFrm, (outs), (ins), "popf", []>;
Chris Lattnerba7e7562008-01-10 07:59:24 +0000610let Defs = [ESP], Uses = [ESP, EFLAGS], mayStore = 1, neverHasSideEffects=1 in
Evan Chengbf4f89d2007-09-26 21:28:00 +0000611def PUSHFD : I<0x9C, RawFrm, (outs), (ins), "pushf", []>;
Evan Cheng2f245ba2007-09-26 01:29:06 +0000612
Evan Cheng069287d2006-05-16 07:21:53 +0000613let isTwoAddress = 1 in // GR32 = bswap GR32
Chris Lattner30bf2d82004-08-10 20:17:41 +0000614 def BSWAP32r : I<0xC8, AddRegFrm,
Evan Cheng64d80e32007-07-19 01:14:50 +0000615 (outs GR32:$dst), (ins GR32:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000616 "bswap{l}\t$dst",
Evan Cheng069287d2006-05-16 07:21:53 +0000617 [(set GR32:$dst, (bswap GR32:$src))]>, TB;
Chris Lattner1cca5e32003-08-03 21:54:21 +0000618
Chris Lattner1cca5e32003-08-03 21:54:21 +0000619
Evan Cheng18efe262007-12-14 02:13:44 +0000620// Bit scan instructions.
621let Defs = [EFLAGS] in {
Evan Chengfd9e4732007-12-14 18:49:43 +0000622def BSF16rr : I<0xBC, MRMSrcReg, (outs GR16:$dst), (ins GR16:$src),
Dan Gohman1a8001e2007-12-14 15:10:00 +0000623 "bsf{w}\t{$src, $dst|$dst, $src}",
Evan Cheng152804e2007-12-14 08:30:15 +0000624 [(set GR16:$dst, (X86bsf GR16:$src)), (implicit EFLAGS)]>, TB;
Evan Cheng18efe262007-12-14 02:13:44 +0000625def BSF16rm : I<0xBC, MRMSrcMem, (outs GR16:$dst), (ins i16mem:$src),
Dan Gohman1a8001e2007-12-14 15:10:00 +0000626 "bsf{w}\t{$src, $dst|$dst, $src}",
Evan Cheng152804e2007-12-14 08:30:15 +0000627 [(set GR16:$dst, (X86bsf (loadi16 addr:$src))),
628 (implicit EFLAGS)]>, TB;
Evan Chengfd9e4732007-12-14 18:49:43 +0000629def BSF32rr : I<0xBC, MRMSrcReg, (outs GR32:$dst), (ins GR32:$src),
Dan Gohman1a8001e2007-12-14 15:10:00 +0000630 "bsf{l}\t{$src, $dst|$dst, $src}",
Evan Cheng152804e2007-12-14 08:30:15 +0000631 [(set GR32:$dst, (X86bsf GR32:$src)), (implicit EFLAGS)]>, TB;
Evan Cheng18efe262007-12-14 02:13:44 +0000632def BSF32rm : I<0xBC, MRMSrcMem, (outs GR32:$dst), (ins i32mem:$src),
Dan Gohman1a8001e2007-12-14 15:10:00 +0000633 "bsf{l}\t{$src, $dst|$dst, $src}",
Evan Cheng152804e2007-12-14 08:30:15 +0000634 [(set GR32:$dst, (X86bsf (loadi32 addr:$src))),
635 (implicit EFLAGS)]>, TB;
Evan Cheng18efe262007-12-14 02:13:44 +0000636
Evan Chengfd9e4732007-12-14 18:49:43 +0000637def BSR16rr : I<0xBD, MRMSrcReg, (outs GR16:$dst), (ins GR16:$src),
Dan Gohman1a8001e2007-12-14 15:10:00 +0000638 "bsr{w}\t{$src, $dst|$dst, $src}",
Evan Cheng152804e2007-12-14 08:30:15 +0000639 [(set GR16:$dst, (X86bsr GR16:$src)), (implicit EFLAGS)]>, TB;
Evan Cheng18efe262007-12-14 02:13:44 +0000640def BSR16rm : I<0xBD, MRMSrcMem, (outs GR16:$dst), (ins i16mem:$src),
Dan Gohman1a8001e2007-12-14 15:10:00 +0000641 "bsr{w}\t{$src, $dst|$dst, $src}",
Evan Cheng152804e2007-12-14 08:30:15 +0000642 [(set GR16:$dst, (X86bsr (loadi16 addr:$src))),
643 (implicit EFLAGS)]>, TB;
Evan Chengfd9e4732007-12-14 18:49:43 +0000644def BSR32rr : I<0xBD, MRMSrcReg, (outs GR32:$dst), (ins GR32:$src),
Dan Gohman1a8001e2007-12-14 15:10:00 +0000645 "bsr{l}\t{$src, $dst|$dst, $src}",
Evan Cheng152804e2007-12-14 08:30:15 +0000646 [(set GR32:$dst, (X86bsr GR32:$src)), (implicit EFLAGS)]>, TB;
Evan Cheng18efe262007-12-14 02:13:44 +0000647def BSR32rm : I<0xBD, MRMSrcMem, (outs GR32:$dst), (ins i32mem:$src),
Dan Gohman1a8001e2007-12-14 15:10:00 +0000648 "bsr{l}\t{$src, $dst|$dst, $src}",
Evan Cheng152804e2007-12-14 08:30:15 +0000649 [(set GR32:$dst, (X86bsr (loadi32 addr:$src))),
650 (implicit EFLAGS)]>, TB;
Evan Cheng18efe262007-12-14 02:13:44 +0000651} // Defs = [EFLAGS]
652
Chris Lattnerba7e7562008-01-10 07:59:24 +0000653let neverHasSideEffects = 1 in
Chris Lattner3a173df2004-10-03 20:35:00 +0000654def LEA16r : I<0x8D, MRMSrcMem,
Evan Cheng64d80e32007-07-19 01:14:50 +0000655 (outs GR16:$dst), (ins i32mem:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000656 "lea{w}\t{$src|$dst}, {$dst|$src}", []>, OpSize;
Evan Chenge771ebd2008-03-27 01:41:09 +0000657let isReMaterializable = 1 in
Chris Lattner3a173df2004-10-03 20:35:00 +0000658def LEA32r : I<0x8D, MRMSrcMem,
Evan Cheng64d80e32007-07-19 01:14:50 +0000659 (outs GR32:$dst), (ins lea32mem:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000660 "lea{l}\t{$src|$dst}, {$dst|$src}",
Evan Cheng25ab6902006-09-08 06:48:29 +0000661 [(set GR32:$dst, lea32addr:$src)]>, Requires<[In32BitMode]>;
Chris Lattner1cca5e32003-08-03 21:54:21 +0000662
Evan Cheng071a2792007-09-11 19:55:27 +0000663let Defs = [ECX,EDI,ESI], Uses = [ECX,EDI,ESI] in {
Evan Cheng64d80e32007-07-19 01:14:50 +0000664def REP_MOVSB : I<0xA4, RawFrm, (outs), (ins), "{rep;movsb|rep movsb}",
Evan Cheng071a2792007-09-11 19:55:27 +0000665 [(X86rep_movs i8)]>, REP;
Evan Cheng64d80e32007-07-19 01:14:50 +0000666def REP_MOVSW : I<0xA5, RawFrm, (outs), (ins), "{rep;movsw|rep movsw}",
Evan Cheng071a2792007-09-11 19:55:27 +0000667 [(X86rep_movs i16)]>, REP, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +0000668def REP_MOVSD : I<0xA5, RawFrm, (outs), (ins), "{rep;movsl|rep movsd}",
Evan Cheng071a2792007-09-11 19:55:27 +0000669 [(X86rep_movs i32)]>, REP;
670}
Chris Lattner915e5e52004-02-12 17:53:22 +0000671
Evan Cheng071a2792007-09-11 19:55:27 +0000672let Defs = [ECX,EDI], Uses = [AL,ECX,EDI] in
Evan Cheng64d80e32007-07-19 01:14:50 +0000673def REP_STOSB : I<0xAA, RawFrm, (outs), (ins), "{rep;stosb|rep stosb}",
Evan Cheng071a2792007-09-11 19:55:27 +0000674 [(X86rep_stos i8)]>, REP;
675let Defs = [ECX,EDI], Uses = [AX,ECX,EDI] in
Evan Cheng64d80e32007-07-19 01:14:50 +0000676def REP_STOSW : I<0xAB, RawFrm, (outs), (ins), "{rep;stosw|rep stosw}",
Evan Cheng071a2792007-09-11 19:55:27 +0000677 [(X86rep_stos i16)]>, REP, OpSize;
678let Defs = [ECX,EDI], Uses = [EAX,ECX,EDI] in
Evan Cheng64d80e32007-07-19 01:14:50 +0000679def REP_STOSD : I<0xAB, RawFrm, (outs), (ins), "{rep;stosl|rep stosd}",
Evan Cheng071a2792007-09-11 19:55:27 +0000680 [(X86rep_stos i32)]>, REP;
Chris Lattner30bf2d82004-08-10 20:17:41 +0000681
Evan Cheng071a2792007-09-11 19:55:27 +0000682let Defs = [RAX, RDX] in
Evan Cheng64d80e32007-07-19 01:14:50 +0000683def RDTSC : I<0x31, RawFrm, (outs), (ins), "rdtsc", [(X86rdtsc)]>,
Evan Cheng071a2792007-09-11 19:55:27 +0000684 TB;
Chris Lattnerb89abef2004-02-14 04:45:37 +0000685
Anton Korobeynikov66fac792008-01-15 07:02:33 +0000686let isBarrier = 1, hasCtrlDep = 1 in {
Chris Lattnerda68d302008-01-15 21:58:22 +0000687def TRAP : I<0x0B, RawFrm, (outs), (ins), "ud2", [(trap)]>, TB;
Anton Korobeynikov66fac792008-01-15 07:02:33 +0000688}
689
Chris Lattner1cca5e32003-08-03 21:54:21 +0000690//===----------------------------------------------------------------------===//
John Criswell4ffff9e2004-04-08 20:31:47 +0000691// Input/Output Instructions...
692//
Evan Cheng071a2792007-09-11 19:55:27 +0000693let Defs = [AL], Uses = [DX] in
Evan Cheng64d80e32007-07-19 01:14:50 +0000694def IN8rr : I<0xEC, RawFrm, (outs), (ins),
Evan Cheng071a2792007-09-11 19:55:27 +0000695 "in{b}\t{%dx, %al|%AL, %DX}", []>;
696let Defs = [AX], Uses = [DX] in
Evan Cheng64d80e32007-07-19 01:14:50 +0000697def IN16rr : I<0xED, RawFrm, (outs), (ins),
Evan Cheng071a2792007-09-11 19:55:27 +0000698 "in{w}\t{%dx, %ax|%AX, %DX}", []>, OpSize;
699let Defs = [EAX], Uses = [DX] in
Evan Cheng64d80e32007-07-19 01:14:50 +0000700def IN32rr : I<0xED, RawFrm, (outs), (ins),
Evan Cheng071a2792007-09-11 19:55:27 +0000701 "in{l}\t{%dx, %eax|%EAX, %DX}", []>;
John Criswell4ffff9e2004-04-08 20:31:47 +0000702
Evan Cheng071a2792007-09-11 19:55:27 +0000703let Defs = [AL] in
Evan Cheng64d80e32007-07-19 01:14:50 +0000704def IN8ri : Ii8<0xE4, RawFrm, (outs), (ins i16i8imm:$port),
Evan Cheng071a2792007-09-11 19:55:27 +0000705 "in{b}\t{$port, %al|%AL, $port}", []>;
706let Defs = [AX] in
Evan Cheng64d80e32007-07-19 01:14:50 +0000707def IN16ri : Ii8<0xE5, RawFrm, (outs), (ins i16i8imm:$port),
Evan Cheng071a2792007-09-11 19:55:27 +0000708 "in{w}\t{$port, %ax|%AX, $port}", []>, OpSize;
709let Defs = [EAX] in
Evan Cheng64d80e32007-07-19 01:14:50 +0000710def IN32ri : Ii8<0xE5, RawFrm, (outs), (ins i16i8imm:$port),
Evan Cheng071a2792007-09-11 19:55:27 +0000711 "in{l}\t{$port, %eax|%EAX, $port}", []>;
Chris Lattner440bbc22004-04-13 17:19:31 +0000712
Evan Cheng071a2792007-09-11 19:55:27 +0000713let Uses = [DX, AL] in
Evan Cheng64d80e32007-07-19 01:14:50 +0000714def OUT8rr : I<0xEE, RawFrm, (outs), (ins),
Evan Cheng071a2792007-09-11 19:55:27 +0000715 "out{b}\t{%al, %dx|%DX, %AL}", []>;
716let Uses = [DX, AX] in
Evan Cheng64d80e32007-07-19 01:14:50 +0000717def OUT16rr : I<0xEF, RawFrm, (outs), (ins),
Evan Cheng071a2792007-09-11 19:55:27 +0000718 "out{w}\t{%ax, %dx|%DX, %AX}", []>, OpSize;
719let Uses = [DX, EAX] in
Evan Cheng64d80e32007-07-19 01:14:50 +0000720def OUT32rr : I<0xEF, RawFrm, (outs), (ins),
Evan Cheng071a2792007-09-11 19:55:27 +0000721 "out{l}\t{%eax, %dx|%DX, %EAX}", []>;
Chris Lattnerffff7082004-08-01 07:44:35 +0000722
Evan Cheng071a2792007-09-11 19:55:27 +0000723let Uses = [AL] in
Evan Cheng64d80e32007-07-19 01:14:50 +0000724def OUT8ir : Ii8<0xE6, RawFrm, (outs), (ins i16i8imm:$port),
Evan Cheng071a2792007-09-11 19:55:27 +0000725 "out{b}\t{%al, $port|$port, %AL}", []>;
726let Uses = [AX] in
Evan Cheng64d80e32007-07-19 01:14:50 +0000727def OUT16ir : Ii8<0xE7, RawFrm, (outs), (ins i16i8imm:$port),
Evan Cheng071a2792007-09-11 19:55:27 +0000728 "out{w}\t{%ax, $port|$port, %AX}", []>, OpSize;
729let Uses = [EAX] in
Evan Cheng64d80e32007-07-19 01:14:50 +0000730def OUT32ir : Ii8<0xE7, RawFrm, (outs), (ins i16i8imm:$port),
Evan Cheng071a2792007-09-11 19:55:27 +0000731 "out{l}\t{%eax, $port|$port, %EAX}", []>;
John Criswell4ffff9e2004-04-08 20:31:47 +0000732
733//===----------------------------------------------------------------------===//
Chris Lattner1cca5e32003-08-03 21:54:21 +0000734// Move Instructions...
735//
Chris Lattnerba7e7562008-01-10 07:59:24 +0000736let neverHasSideEffects = 1 in {
Evan Cheng64d80e32007-07-19 01:14:50 +0000737def MOV8rr : I<0x88, MRMDestReg, (outs GR8 :$dst), (ins GR8 :$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000738 "mov{b}\t{$src, $dst|$dst, $src}", []>;
Evan Cheng64d80e32007-07-19 01:14:50 +0000739def MOV16rr : I<0x89, MRMDestReg, (outs GR16:$dst), (ins GR16:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000740 "mov{w}\t{$src, $dst|$dst, $src}", []>, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +0000741def MOV32rr : I<0x89, MRMDestReg, (outs GR32:$dst), (ins GR32:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000742 "mov{l}\t{$src, $dst|$dst, $src}", []>;
Chris Lattnerba7e7562008-01-10 07:59:24 +0000743}
Evan Cheng359e9372008-06-18 08:13:07 +0000744let isReMaterializable = 1, isAsCheapAsAMove = 1 in {
Evan Cheng64d80e32007-07-19 01:14:50 +0000745def MOV8ri : Ii8 <0xB0, AddRegFrm, (outs GR8 :$dst), (ins i8imm :$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000746 "mov{b}\t{$src, $dst|$dst, $src}",
Evan Cheng069287d2006-05-16 07:21:53 +0000747 [(set GR8:$dst, imm:$src)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +0000748def MOV16ri : Ii16<0xB8, AddRegFrm, (outs GR16:$dst), (ins i16imm:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000749 "mov{w}\t{$src, $dst|$dst, $src}",
Evan Cheng069287d2006-05-16 07:21:53 +0000750 [(set GR16:$dst, imm:$src)]>, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +0000751def MOV32ri : Ii32<0xB8, AddRegFrm, (outs GR32:$dst), (ins i32imm:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000752 "mov{l}\t{$src, $dst|$dst, $src}",
Evan Cheng069287d2006-05-16 07:21:53 +0000753 [(set GR32:$dst, imm:$src)]>;
Dan Gohmand45eddd2007-06-26 00:48:07 +0000754}
Evan Cheng64d80e32007-07-19 01:14:50 +0000755def MOV8mi : Ii8 <0xC6, MRM0m, (outs), (ins i8mem :$dst, i8imm :$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000756 "mov{b}\t{$src, $dst|$dst, $src}",
Evan Chengb51a0592005-12-10 00:48:20 +0000757 [(store (i8 imm:$src), addr:$dst)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +0000758def MOV16mi : Ii16<0xC7, MRM0m, (outs), (ins i16mem:$dst, i16imm:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000759 "mov{w}\t{$src, $dst|$dst, $src}",
Evan Chengb51a0592005-12-10 00:48:20 +0000760 [(store (i16 imm:$src), addr:$dst)]>, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +0000761def MOV32mi : Ii32<0xC7, MRM0m, (outs), (ins i32mem:$dst, i32imm:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000762 "mov{l}\t{$src, $dst|$dst, $src}",
Evan Chengb51a0592005-12-10 00:48:20 +0000763 [(store (i32 imm:$src), addr:$dst)]>;
Chris Lattner1cca5e32003-08-03 21:54:21 +0000764
Dan Gohman15511cf2008-12-03 18:15:48 +0000765let canFoldAsLoad = 1, isReMaterializable = 1, mayHaveSideEffects = 1 in {
Evan Cheng64d80e32007-07-19 01:14:50 +0000766def MOV8rm : I<0x8A, MRMSrcMem, (outs GR8 :$dst), (ins i8mem :$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000767 "mov{b}\t{$src, $dst|$dst, $src}",
Chris Lattnerc2406f22009-04-10 00:16:23 +0000768 [(set GR8:$dst, (loadi8 addr:$src))]>;
Evan Cheng64d80e32007-07-19 01:14:50 +0000769def MOV16rm : I<0x8B, MRMSrcMem, (outs GR16:$dst), (ins i16mem:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000770 "mov{w}\t{$src, $dst|$dst, $src}",
Chris Lattnerc2406f22009-04-10 00:16:23 +0000771 [(set GR16:$dst, (loadi16 addr:$src))]>, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +0000772def MOV32rm : I<0x8B, MRMSrcMem, (outs GR32:$dst), (ins i32mem:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000773 "mov{l}\t{$src, $dst|$dst, $src}",
Chris Lattnerc2406f22009-04-10 00:16:23 +0000774 [(set GR32:$dst, (loadi32 addr:$src))]>;
Evan Cheng2f394262007-08-30 05:49:43 +0000775}
Chris Lattner1cca5e32003-08-03 21:54:21 +0000776
Evan Cheng64d80e32007-07-19 01:14:50 +0000777def MOV8mr : I<0x88, MRMDestMem, (outs), (ins i8mem :$dst, GR8 :$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000778 "mov{b}\t{$src, $dst|$dst, $src}",
Evan Cheng069287d2006-05-16 07:21:53 +0000779 [(store GR8:$src, addr:$dst)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +0000780def MOV16mr : I<0x89, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000781 "mov{w}\t{$src, $dst|$dst, $src}",
Evan Cheng069287d2006-05-16 07:21:53 +0000782 [(store GR16:$src, addr:$dst)]>, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +0000783def MOV32mr : I<0x89, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000784 "mov{l}\t{$src, $dst|$dst, $src}",
Evan Cheng069287d2006-05-16 07:21:53 +0000785 [(store GR32:$src, addr:$dst)]>;
Dan Gohman21e3dfb2009-04-13 16:09:41 +0000786
Dan Gohman6d9305c2009-04-15 00:04:23 +0000787// Versions of MOV8rr and MOV8mr that use i8mem_NOREX and GR8_NOREX so that they
788// can be used for copying and storing h registers, which can't be encoded when
789// a REX prefix is present.
790let neverHasSideEffects = 1 in
Dan Gohmandf7dfc72009-04-15 19:48:57 +0000791def MOV8rr_NOREX : I<0x88, MRMDestReg,
792 (outs GR8_NOREX:$dst), (ins GR8_NOREX:$src),
Dan Gohman6d9305c2009-04-15 00:04:23 +0000793 "mov{b}\t{$src, $dst|$dst, $src} # NOREX", []>;
794def MOV8mr_NOREX : I<0x88, MRMDestMem,
795 (outs), (ins i8mem_NOREX:$dst, GR8_NOREX:$src),
796 "mov{b}\t{$src, $dst|$dst, $src} # NOREX", []>;
Dan Gohman21e3dfb2009-04-13 16:09:41 +0000797
Chris Lattner1cca5e32003-08-03 21:54:21 +0000798//===----------------------------------------------------------------------===//
799// Fixed-Register Multiplication and Division Instructions...
800//
Chris Lattner1cca5e32003-08-03 21:54:21 +0000801
Chris Lattnerc8f45872003-08-04 04:59:56 +0000802// Extra precision multiplication
Evan Cheng24f2ea32007-09-14 21:48:26 +0000803let Defs = [AL,AH,EFLAGS], Uses = [AL] in
Dan Gohmanb1576f52007-07-31 20:11:57 +0000804def MUL8r : I<0xF6, MRM4r, (outs), (ins GR8:$src), "mul{b}\t$src",
Evan Chengcf74a7c2006-01-15 10:05:20 +0000805 // FIXME: Used for 8-bit mul, ignore result upper 8 bits.
806 // This probably ought to be moved to a def : Pat<> if the
807 // syntax can be accepted.
Bill Wendlingd350e022008-12-12 21:15:41 +0000808 [(set AL, (mul AL, GR8:$src)),
809 (implicit EFLAGS)]>; // AL,AH = AL*GR8
810
Chris Lattnera731c9f2008-01-11 07:18:17 +0000811let Defs = [AX,DX,EFLAGS], Uses = [AX], neverHasSideEffects = 1 in
Bill Wendlingd350e022008-12-12 21:15:41 +0000812def MUL16r : I<0xF7, MRM4r, (outs), (ins GR16:$src),
813 "mul{w}\t$src",
814 []>, OpSize; // AX,DX = AX*GR16
815
Chris Lattnera731c9f2008-01-11 07:18:17 +0000816let Defs = [EAX,EDX,EFLAGS], Uses = [EAX], neverHasSideEffects = 1 in
Bill Wendlingd350e022008-12-12 21:15:41 +0000817def MUL32r : I<0xF7, MRM4r, (outs), (ins GR32:$src),
818 "mul{l}\t$src",
819 []>; // EAX,EDX = EAX*GR32
820
Evan Cheng24f2ea32007-09-14 21:48:26 +0000821let Defs = [AL,AH,EFLAGS], Uses = [AL] in
Evan Cheng64d80e32007-07-19 01:14:50 +0000822def MUL8m : I<0xF6, MRM4m, (outs), (ins i8mem :$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000823 "mul{b}\t$src",
Evan Chengcf74a7c2006-01-15 10:05:20 +0000824 // FIXME: Used for 8-bit mul, ignore result upper 8 bits.
825 // This probably ought to be moved to a def : Pat<> if the
826 // syntax can be accepted.
Bill Wendlingd350e022008-12-12 21:15:41 +0000827 [(set AL, (mul AL, (loadi8 addr:$src))),
828 (implicit EFLAGS)]>; // AL,AH = AL*[mem8]
829
Chris Lattnerba7e7562008-01-10 07:59:24 +0000830let mayLoad = 1, neverHasSideEffects = 1 in {
Evan Cheng24f2ea32007-09-14 21:48:26 +0000831let Defs = [AX,DX,EFLAGS], Uses = [AX] in
Evan Cheng64d80e32007-07-19 01:14:50 +0000832def MUL16m : I<0xF7, MRM4m, (outs), (ins i16mem:$src),
Bill Wendlingd350e022008-12-12 21:15:41 +0000833 "mul{w}\t$src",
834 []>, OpSize; // AX,DX = AX*[mem16]
835
Evan Cheng24f2ea32007-09-14 21:48:26 +0000836let Defs = [EAX,EDX,EFLAGS], Uses = [EAX] in
Evan Cheng64d80e32007-07-19 01:14:50 +0000837def MUL32m : I<0xF7, MRM4m, (outs), (ins i32mem:$src),
Bill Wendlingd350e022008-12-12 21:15:41 +0000838 "mul{l}\t$src",
839 []>; // EAX,EDX = EAX*[mem32]
Chris Lattnerba7e7562008-01-10 07:59:24 +0000840}
Chris Lattner1cca5e32003-08-03 21:54:21 +0000841
Chris Lattnerba7e7562008-01-10 07:59:24 +0000842let neverHasSideEffects = 1 in {
Evan Cheng24f2ea32007-09-14 21:48:26 +0000843let Defs = [AL,AH,EFLAGS], Uses = [AL] in
Evan Cheng071a2792007-09-11 19:55:27 +0000844def IMUL8r : I<0xF6, MRM5r, (outs), (ins GR8:$src), "imul{b}\t$src", []>;
845 // AL,AH = AL*GR8
Evan Cheng24f2ea32007-09-14 21:48:26 +0000846let Defs = [AX,DX,EFLAGS], Uses = [AX] in
Dan Gohmanb1576f52007-07-31 20:11:57 +0000847def IMUL16r : I<0xF7, MRM5r, (outs), (ins GR16:$src), "imul{w}\t$src", []>,
Evan Cheng071a2792007-09-11 19:55:27 +0000848 OpSize; // AX,DX = AX*GR16
Evan Cheng24f2ea32007-09-14 21:48:26 +0000849let Defs = [EAX,EDX,EFLAGS], Uses = [EAX] in
Evan Cheng071a2792007-09-11 19:55:27 +0000850def IMUL32r : I<0xF7, MRM5r, (outs), (ins GR32:$src), "imul{l}\t$src", []>;
851 // EAX,EDX = EAX*GR32
Chris Lattnerba7e7562008-01-10 07:59:24 +0000852let mayLoad = 1 in {
Evan Cheng24f2ea32007-09-14 21:48:26 +0000853let Defs = [AL,AH,EFLAGS], Uses = [AL] in
Evan Cheng64d80e32007-07-19 01:14:50 +0000854def IMUL8m : I<0xF6, MRM5m, (outs), (ins i8mem :$src),
Evan Cheng071a2792007-09-11 19:55:27 +0000855 "imul{b}\t$src", []>; // AL,AH = AL*[mem8]
Evan Cheng24f2ea32007-09-14 21:48:26 +0000856let Defs = [AX,DX,EFLAGS], Uses = [AX] in
Evan Cheng64d80e32007-07-19 01:14:50 +0000857def IMUL16m : I<0xF7, MRM5m, (outs), (ins i16mem:$src),
Evan Cheng071a2792007-09-11 19:55:27 +0000858 "imul{w}\t$src", []>, OpSize; // AX,DX = AX*[mem16]
859let Defs = [EAX,EDX], Uses = [EAX] in
Evan Cheng64d80e32007-07-19 01:14:50 +0000860def IMUL32m : I<0xF7, MRM5m, (outs), (ins i32mem:$src),
Evan Cheng071a2792007-09-11 19:55:27 +0000861 "imul{l}\t$src", []>; // EAX,EDX = EAX*[mem32]
Chris Lattnerba7e7562008-01-10 07:59:24 +0000862}
Dan Gohmanc99da132008-11-18 21:29:14 +0000863} // neverHasSideEffects
Chris Lattner1e6a7152005-04-06 04:19:22 +0000864
Chris Lattnerc8f45872003-08-04 04:59:56 +0000865// unsigned division/remainder
Dale Johannesen2cb48ea2008-10-07 18:54:28 +0000866let Defs = [AL,AH,EFLAGS], Uses = [AX] in
Evan Cheng64d80e32007-07-19 01:14:50 +0000867def DIV8r : I<0xF6, MRM6r, (outs), (ins GR8:$src), // AX/r8 = AL,AH
Evan Cheng071a2792007-09-11 19:55:27 +0000868 "div{b}\t$src", []>;
Evan Cheng24f2ea32007-09-14 21:48:26 +0000869let Defs = [AX,DX,EFLAGS], Uses = [AX,DX] in
Evan Cheng64d80e32007-07-19 01:14:50 +0000870def DIV16r : I<0xF7, MRM6r, (outs), (ins GR16:$src), // DX:AX/r16 = AX,DX
Evan Cheng071a2792007-09-11 19:55:27 +0000871 "div{w}\t$src", []>, OpSize;
Evan Cheng24f2ea32007-09-14 21:48:26 +0000872let Defs = [EAX,EDX,EFLAGS], Uses = [EAX,EDX] in
Evan Cheng64d80e32007-07-19 01:14:50 +0000873def DIV32r : I<0xF7, MRM6r, (outs), (ins GR32:$src), // EDX:EAX/r32 = EAX,EDX
Evan Cheng071a2792007-09-11 19:55:27 +0000874 "div{l}\t$src", []>;
Chris Lattnerba7e7562008-01-10 07:59:24 +0000875let mayLoad = 1 in {
Dale Johannesen2cb48ea2008-10-07 18:54:28 +0000876let Defs = [AL,AH,EFLAGS], Uses = [AX] in
Evan Cheng64d80e32007-07-19 01:14:50 +0000877def DIV8m : I<0xF6, MRM6m, (outs), (ins i8mem:$src), // AX/[mem8] = AL,AH
Evan Cheng071a2792007-09-11 19:55:27 +0000878 "div{b}\t$src", []>;
Evan Cheng24f2ea32007-09-14 21:48:26 +0000879let Defs = [AX,DX,EFLAGS], Uses = [AX,DX] in
Evan Cheng64d80e32007-07-19 01:14:50 +0000880def DIV16m : I<0xF7, MRM6m, (outs), (ins i16mem:$src), // DX:AX/[mem16] = AX,DX
Evan Cheng071a2792007-09-11 19:55:27 +0000881 "div{w}\t$src", []>, OpSize;
Evan Cheng24f2ea32007-09-14 21:48:26 +0000882let Defs = [EAX,EDX,EFLAGS], Uses = [EAX,EDX] in
Evan Cheng64d80e32007-07-19 01:14:50 +0000883def DIV32m : I<0xF7, MRM6m, (outs), (ins i32mem:$src), // EDX:EAX/[mem32] = EAX,EDX
Evan Cheng071a2792007-09-11 19:55:27 +0000884 "div{l}\t$src", []>;
Chris Lattnerba7e7562008-01-10 07:59:24 +0000885}
Chris Lattner1cca5e32003-08-03 21:54:21 +0000886
Chris Lattnerfc752712004-08-01 09:52:59 +0000887// Signed division/remainder.
Dale Johannesen2cb48ea2008-10-07 18:54:28 +0000888let Defs = [AL,AH,EFLAGS], Uses = [AX] in
Evan Cheng64d80e32007-07-19 01:14:50 +0000889def IDIV8r : I<0xF6, MRM7r, (outs), (ins GR8:$src), // AX/r8 = AL,AH
Evan Cheng071a2792007-09-11 19:55:27 +0000890 "idiv{b}\t$src", []>;
Evan Cheng24f2ea32007-09-14 21:48:26 +0000891let Defs = [AX,DX,EFLAGS], Uses = [AX,DX] in
Evan Cheng64d80e32007-07-19 01:14:50 +0000892def IDIV16r: I<0xF7, MRM7r, (outs), (ins GR16:$src), // DX:AX/r16 = AX,DX
Evan Cheng071a2792007-09-11 19:55:27 +0000893 "idiv{w}\t$src", []>, OpSize;
Evan Cheng24f2ea32007-09-14 21:48:26 +0000894let Defs = [EAX,EDX,EFLAGS], Uses = [EAX,EDX] in
Evan Cheng64d80e32007-07-19 01:14:50 +0000895def IDIV32r: I<0xF7, MRM7r, (outs), (ins GR32:$src), // EDX:EAX/r32 = EAX,EDX
Evan Cheng071a2792007-09-11 19:55:27 +0000896 "idiv{l}\t$src", []>;
Chris Lattnerba7e7562008-01-10 07:59:24 +0000897let mayLoad = 1, mayLoad = 1 in {
Dale Johannesen2cb48ea2008-10-07 18:54:28 +0000898let Defs = [AL,AH,EFLAGS], Uses = [AX] in
Evan Cheng64d80e32007-07-19 01:14:50 +0000899def IDIV8m : I<0xF6, MRM7m, (outs), (ins i8mem:$src), // AX/[mem8] = AL,AH
Evan Cheng071a2792007-09-11 19:55:27 +0000900 "idiv{b}\t$src", []>;
Evan Cheng24f2ea32007-09-14 21:48:26 +0000901let Defs = [AX,DX,EFLAGS], Uses = [AX,DX] in
Evan Cheng64d80e32007-07-19 01:14:50 +0000902def IDIV16m: I<0xF7, MRM7m, (outs), (ins i16mem:$src), // DX:AX/[mem16] = AX,DX
Evan Cheng071a2792007-09-11 19:55:27 +0000903 "idiv{w}\t$src", []>, OpSize;
Evan Cheng24f2ea32007-09-14 21:48:26 +0000904let Defs = [EAX,EDX,EFLAGS], Uses = [EAX,EDX] in
Evan Cheng64d80e32007-07-19 01:14:50 +0000905def IDIV32m: I<0xF7, MRM7m, (outs), (ins i32mem:$src), // EDX:EAX/[mem32] = EAX,EDX
Evan Cheng071a2792007-09-11 19:55:27 +0000906 "idiv{l}\t$src", []>;
Chris Lattnerba7e7562008-01-10 07:59:24 +0000907}
Chris Lattner1cca5e32003-08-03 21:54:21 +0000908
Chris Lattner1cca5e32003-08-03 21:54:21 +0000909//===----------------------------------------------------------------------===//
Chris Lattnerba7e7562008-01-10 07:59:24 +0000910// Two address Instructions.
Chris Lattner1cca5e32003-08-03 21:54:21 +0000911//
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +0000912let isTwoAddress = 1 in {
Chris Lattner1cca5e32003-08-03 21:54:21 +0000913
Alkis Evlogimenosa3f66842004-03-12 17:59:56 +0000914// Conditional moves
Evan Cheng0488db92007-09-25 01:57:46 +0000915let Uses = [EFLAGS] in {
Evan Cheng7ad42d92007-10-05 23:13:21 +0000916let isCommutable = 1 in {
Evan Cheng069287d2006-05-16 07:21:53 +0000917def CMOVB16rr : I<0x42, MRMSrcReg, // if <u, GR16 = GR16
Evan Cheng64d80e32007-07-19 01:14:50 +0000918 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000919 "cmovb\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +0000920 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Chenge5f62042007-09-29 00:00:36 +0000921 X86_COND_B, EFLAGS))]>,
Evan Cheng71fb9ad2006-01-26 00:29:36 +0000922 TB, OpSize;
Evan Cheng069287d2006-05-16 07:21:53 +0000923def CMOVB32rr : I<0x42, MRMSrcReg, // if <u, GR32 = GR32
Evan Cheng64d80e32007-07-19 01:14:50 +0000924 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000925 "cmovb\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +0000926 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Chenge5f62042007-09-29 00:00:36 +0000927 X86_COND_B, EFLAGS))]>,
Evan Cheng71fb9ad2006-01-26 00:29:36 +0000928 TB;
Evan Cheng069287d2006-05-16 07:21:53 +0000929def CMOVAE16rr: I<0x43, MRMSrcReg, // if >=u, GR16 = GR16
Evan Cheng64d80e32007-07-19 01:14:50 +0000930 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000931 "cmovae\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +0000932 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Chenge5f62042007-09-29 00:00:36 +0000933 X86_COND_AE, EFLAGS))]>,
Evan Cheng71fb9ad2006-01-26 00:29:36 +0000934 TB, OpSize;
Evan Cheng069287d2006-05-16 07:21:53 +0000935def CMOVAE32rr: I<0x43, MRMSrcReg, // if >=u, GR32 = GR32
Evan Cheng64d80e32007-07-19 01:14:50 +0000936 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000937 "cmovae\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +0000938 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Chenge5f62042007-09-29 00:00:36 +0000939 X86_COND_AE, EFLAGS))]>,
Evan Cheng71fb9ad2006-01-26 00:29:36 +0000940 TB;
Evan Cheng069287d2006-05-16 07:21:53 +0000941def CMOVE16rr : I<0x44, MRMSrcReg, // if ==, GR16 = GR16
Evan Cheng64d80e32007-07-19 01:14:50 +0000942 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000943 "cmove\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +0000944 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Chenge5f62042007-09-29 00:00:36 +0000945 X86_COND_E, EFLAGS))]>,
Evan Cheng71fb9ad2006-01-26 00:29:36 +0000946 TB, OpSize;
Evan Cheng069287d2006-05-16 07:21:53 +0000947def CMOVE32rr : I<0x44, MRMSrcReg, // if ==, GR32 = GR32
Evan Cheng64d80e32007-07-19 01:14:50 +0000948 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000949 "cmove\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +0000950 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Chenge5f62042007-09-29 00:00:36 +0000951 X86_COND_E, EFLAGS))]>,
Evan Cheng71fb9ad2006-01-26 00:29:36 +0000952 TB;
Evan Cheng069287d2006-05-16 07:21:53 +0000953def CMOVNE16rr: I<0x45, MRMSrcReg, // if !=, GR16 = GR16
Evan Cheng64d80e32007-07-19 01:14:50 +0000954 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000955 "cmovne\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +0000956 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Chenge5f62042007-09-29 00:00:36 +0000957 X86_COND_NE, EFLAGS))]>,
Evan Cheng71fb9ad2006-01-26 00:29:36 +0000958 TB, OpSize;
Evan Cheng069287d2006-05-16 07:21:53 +0000959def CMOVNE32rr: I<0x45, MRMSrcReg, // if !=, GR32 = GR32
Evan Cheng64d80e32007-07-19 01:14:50 +0000960 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000961 "cmovne\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +0000962 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Chenge5f62042007-09-29 00:00:36 +0000963 X86_COND_NE, EFLAGS))]>,
Evan Cheng71fb9ad2006-01-26 00:29:36 +0000964 TB;
Evan Cheng069287d2006-05-16 07:21:53 +0000965def CMOVBE16rr: I<0x46, MRMSrcReg, // if <=u, GR16 = GR16
Evan Cheng64d80e32007-07-19 01:14:50 +0000966 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000967 "cmovbe\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +0000968 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Chenge5f62042007-09-29 00:00:36 +0000969 X86_COND_BE, EFLAGS))]>,
Evan Cheng71fb9ad2006-01-26 00:29:36 +0000970 TB, OpSize;
Evan Cheng069287d2006-05-16 07:21:53 +0000971def CMOVBE32rr: I<0x46, MRMSrcReg, // if <=u, GR32 = GR32
Evan Cheng64d80e32007-07-19 01:14:50 +0000972 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000973 "cmovbe\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +0000974 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Chenge5f62042007-09-29 00:00:36 +0000975 X86_COND_BE, EFLAGS))]>,
Evan Cheng71fb9ad2006-01-26 00:29:36 +0000976 TB;
Evan Cheng069287d2006-05-16 07:21:53 +0000977def CMOVA16rr : I<0x47, MRMSrcReg, // if >u, GR16 = GR16
Evan Cheng64d80e32007-07-19 01:14:50 +0000978 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000979 "cmova\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +0000980 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Chenge5f62042007-09-29 00:00:36 +0000981 X86_COND_A, EFLAGS))]>,
Evan Cheng71fb9ad2006-01-26 00:29:36 +0000982 TB, OpSize;
Evan Cheng069287d2006-05-16 07:21:53 +0000983def CMOVA32rr : I<0x47, MRMSrcReg, // if >u, GR32 = GR32
Evan Cheng64d80e32007-07-19 01:14:50 +0000984 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000985 "cmova\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +0000986 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Chenge5f62042007-09-29 00:00:36 +0000987 X86_COND_A, EFLAGS))]>,
Evan Cheng71fb9ad2006-01-26 00:29:36 +0000988 TB;
Evan Cheng069287d2006-05-16 07:21:53 +0000989def CMOVL16rr : I<0x4C, MRMSrcReg, // if <s, GR16 = GR16
Evan Cheng64d80e32007-07-19 01:14:50 +0000990 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000991 "cmovl\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +0000992 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Chenge5f62042007-09-29 00:00:36 +0000993 X86_COND_L, EFLAGS))]>,
Evan Cheng71fb9ad2006-01-26 00:29:36 +0000994 TB, OpSize;
Evan Cheng069287d2006-05-16 07:21:53 +0000995def CMOVL32rr : I<0x4C, MRMSrcReg, // if <s, GR32 = GR32
Evan Cheng64d80e32007-07-19 01:14:50 +0000996 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000997 "cmovl\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +0000998 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Chenge5f62042007-09-29 00:00:36 +0000999 X86_COND_L, EFLAGS))]>,
Evan Cheng71fb9ad2006-01-26 00:29:36 +00001000 TB;
Evan Cheng069287d2006-05-16 07:21:53 +00001001def CMOVGE16rr: I<0x4D, MRMSrcReg, // if >=s, GR16 = GR16
Evan Cheng64d80e32007-07-19 01:14:50 +00001002 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001003 "cmovge\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001004 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Chenge5f62042007-09-29 00:00:36 +00001005 X86_COND_GE, EFLAGS))]>,
Evan Cheng71fb9ad2006-01-26 00:29:36 +00001006 TB, OpSize;
Evan Cheng069287d2006-05-16 07:21:53 +00001007def CMOVGE32rr: I<0x4D, MRMSrcReg, // if >=s, GR32 = GR32
Evan Cheng64d80e32007-07-19 01:14:50 +00001008 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001009 "cmovge\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001010 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Chenge5f62042007-09-29 00:00:36 +00001011 X86_COND_GE, EFLAGS))]>,
Evan Cheng71fb9ad2006-01-26 00:29:36 +00001012 TB;
Evan Cheng069287d2006-05-16 07:21:53 +00001013def CMOVLE16rr: I<0x4E, MRMSrcReg, // if <=s, GR16 = GR16
Evan Cheng64d80e32007-07-19 01:14:50 +00001014 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001015 "cmovle\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001016 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Chenge5f62042007-09-29 00:00:36 +00001017 X86_COND_LE, EFLAGS))]>,
Evan Cheng71fb9ad2006-01-26 00:29:36 +00001018 TB, OpSize;
Evan Cheng069287d2006-05-16 07:21:53 +00001019def CMOVLE32rr: I<0x4E, MRMSrcReg, // if <=s, GR32 = GR32
Evan Cheng64d80e32007-07-19 01:14:50 +00001020 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001021 "cmovle\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001022 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Chenge5f62042007-09-29 00:00:36 +00001023 X86_COND_LE, EFLAGS))]>,
Evan Cheng71fb9ad2006-01-26 00:29:36 +00001024 TB;
Evan Cheng069287d2006-05-16 07:21:53 +00001025def CMOVG16rr : I<0x4F, MRMSrcReg, // if >s, GR16 = GR16
Evan Cheng64d80e32007-07-19 01:14:50 +00001026 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001027 "cmovg\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001028 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Chenge5f62042007-09-29 00:00:36 +00001029 X86_COND_G, EFLAGS))]>,
Evan Cheng71fb9ad2006-01-26 00:29:36 +00001030 TB, OpSize;
Evan Cheng069287d2006-05-16 07:21:53 +00001031def CMOVG32rr : I<0x4F, MRMSrcReg, // if >s, GR32 = GR32
Evan Cheng64d80e32007-07-19 01:14:50 +00001032 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001033 "cmovg\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001034 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Chenge5f62042007-09-29 00:00:36 +00001035 X86_COND_G, EFLAGS))]>,
Evan Cheng71fb9ad2006-01-26 00:29:36 +00001036 TB;
Evan Cheng069287d2006-05-16 07:21:53 +00001037def CMOVS16rr : I<0x48, MRMSrcReg, // if signed, GR16 = GR16
Evan Cheng64d80e32007-07-19 01:14:50 +00001038 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001039 "cmovs\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001040 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Chenge5f62042007-09-29 00:00:36 +00001041 X86_COND_S, EFLAGS))]>,
Evan Cheng71fb9ad2006-01-26 00:29:36 +00001042 TB, OpSize;
Evan Cheng069287d2006-05-16 07:21:53 +00001043def CMOVS32rr : I<0x48, MRMSrcReg, // if signed, GR32 = GR32
Evan Cheng64d80e32007-07-19 01:14:50 +00001044 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001045 "cmovs\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001046 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Chenge5f62042007-09-29 00:00:36 +00001047 X86_COND_S, EFLAGS))]>,
Evan Cheng71fb9ad2006-01-26 00:29:36 +00001048 TB;
Evan Cheng069287d2006-05-16 07:21:53 +00001049def CMOVNS16rr: I<0x49, MRMSrcReg, // if !signed, GR16 = GR16
Evan Cheng64d80e32007-07-19 01:14:50 +00001050 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001051 "cmovns\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001052 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Chenge5f62042007-09-29 00:00:36 +00001053 X86_COND_NS, EFLAGS))]>,
Evan Cheng71fb9ad2006-01-26 00:29:36 +00001054 TB, OpSize;
Evan Cheng069287d2006-05-16 07:21:53 +00001055def CMOVNS32rr: I<0x49, MRMSrcReg, // if !signed, GR32 = GR32
Evan Cheng64d80e32007-07-19 01:14:50 +00001056 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001057 "cmovns\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001058 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Chenge5f62042007-09-29 00:00:36 +00001059 X86_COND_NS, EFLAGS))]>,
Evan Cheng71fb9ad2006-01-26 00:29:36 +00001060 TB;
Evan Cheng069287d2006-05-16 07:21:53 +00001061def CMOVP16rr : I<0x4A, MRMSrcReg, // if parity, GR16 = GR16
Evan Cheng64d80e32007-07-19 01:14:50 +00001062 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001063 "cmovp\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001064 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Chenge5f62042007-09-29 00:00:36 +00001065 X86_COND_P, EFLAGS))]>,
Evan Cheng71fb9ad2006-01-26 00:29:36 +00001066 TB, OpSize;
Evan Cheng069287d2006-05-16 07:21:53 +00001067def CMOVP32rr : I<0x4A, MRMSrcReg, // if parity, GR32 = GR32
Evan Cheng64d80e32007-07-19 01:14:50 +00001068 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001069 "cmovp\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001070 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Chenge5f62042007-09-29 00:00:36 +00001071 X86_COND_P, EFLAGS))]>,
Evan Cheng71fb9ad2006-01-26 00:29:36 +00001072 TB;
Evan Cheng069287d2006-05-16 07:21:53 +00001073def CMOVNP16rr : I<0x4B, MRMSrcReg, // if !parity, GR16 = GR16
Evan Cheng64d80e32007-07-19 01:14:50 +00001074 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001075 "cmovnp\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001076 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Chenge5f62042007-09-29 00:00:36 +00001077 X86_COND_NP, EFLAGS))]>,
Evan Cheng71fb9ad2006-01-26 00:29:36 +00001078 TB, OpSize;
Evan Cheng069287d2006-05-16 07:21:53 +00001079def CMOVNP32rr : I<0x4B, MRMSrcReg, // if !parity, GR32 = GR32
Evan Cheng64d80e32007-07-19 01:14:50 +00001080 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001081 "cmovnp\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001082 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Chenge5f62042007-09-29 00:00:36 +00001083 X86_COND_NP, EFLAGS))]>,
Evan Cheng71fb9ad2006-01-26 00:29:36 +00001084 TB;
Dan Gohman305fceb2009-01-07 00:35:10 +00001085def CMOVO16rr : I<0x40, MRMSrcReg, // if overflow, GR16 = GR16
1086 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
1087 "cmovo\t{$src2, $dst|$dst, $src2}",
1088 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
1089 X86_COND_O, EFLAGS))]>,
1090 TB, OpSize;
1091def CMOVO32rr : I<0x40, MRMSrcReg, // if overflow, GR32 = GR32
1092 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
1093 "cmovo\t{$src2, $dst|$dst, $src2}",
1094 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
1095 X86_COND_O, EFLAGS))]>,
Evan Cheng0488db92007-09-25 01:57:46 +00001096 TB;
Dan Gohman305fceb2009-01-07 00:35:10 +00001097def CMOVNO16rr : I<0x41, MRMSrcReg, // if !overflow, GR16 = GR16
1098 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
1099 "cmovno\t{$src2, $dst|$dst, $src2}",
1100 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
1101 X86_COND_NO, EFLAGS))]>,
1102 TB, OpSize;
1103def CMOVNO32rr : I<0x41, MRMSrcReg, // if !overflow, GR32 = GR32
1104 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
1105 "cmovno\t{$src2, $dst|$dst, $src2}",
1106 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
1107 X86_COND_NO, EFLAGS))]>,
1108 TB;
1109} // isCommutable = 1
Evan Cheng7ad42d92007-10-05 23:13:21 +00001110
1111def CMOVB16rm : I<0x42, MRMSrcMem, // if <u, GR16 = [mem16]
1112 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1113 "cmovb\t{$src2, $dst|$dst, $src2}",
1114 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1115 X86_COND_B, EFLAGS))]>,
1116 TB, OpSize;
1117def CMOVB32rm : I<0x42, MRMSrcMem, // if <u, GR32 = [mem32]
1118 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1119 "cmovb\t{$src2, $dst|$dst, $src2}",
1120 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1121 X86_COND_B, EFLAGS))]>,
1122 TB;
1123def CMOVAE16rm: I<0x43, MRMSrcMem, // if >=u, GR16 = [mem16]
1124 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1125 "cmovae\t{$src2, $dst|$dst, $src2}",
1126 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1127 X86_COND_AE, EFLAGS))]>,
1128 TB, OpSize;
1129def CMOVAE32rm: I<0x43, MRMSrcMem, // if >=u, GR32 = [mem32]
1130 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1131 "cmovae\t{$src2, $dst|$dst, $src2}",
1132 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1133 X86_COND_AE, EFLAGS))]>,
1134 TB;
1135def CMOVE16rm : I<0x44, MRMSrcMem, // if ==, GR16 = [mem16]
1136 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1137 "cmove\t{$src2, $dst|$dst, $src2}",
1138 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1139 X86_COND_E, EFLAGS))]>,
1140 TB, OpSize;
1141def CMOVE32rm : I<0x44, MRMSrcMem, // if ==, GR32 = [mem32]
1142 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1143 "cmove\t{$src2, $dst|$dst, $src2}",
1144 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1145 X86_COND_E, EFLAGS))]>,
1146 TB;
1147def CMOVNE16rm: I<0x45, MRMSrcMem, // if !=, GR16 = [mem16]
1148 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1149 "cmovne\t{$src2, $dst|$dst, $src2}",
1150 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1151 X86_COND_NE, EFLAGS))]>,
1152 TB, OpSize;
1153def CMOVNE32rm: I<0x45, MRMSrcMem, // if !=, GR32 = [mem32]
1154 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1155 "cmovne\t{$src2, $dst|$dst, $src2}",
1156 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1157 X86_COND_NE, EFLAGS))]>,
1158 TB;
1159def CMOVBE16rm: I<0x46, MRMSrcMem, // if <=u, GR16 = [mem16]
1160 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1161 "cmovbe\t{$src2, $dst|$dst, $src2}",
1162 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1163 X86_COND_BE, EFLAGS))]>,
1164 TB, OpSize;
1165def CMOVBE32rm: I<0x46, MRMSrcMem, // if <=u, GR32 = [mem32]
1166 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1167 "cmovbe\t{$src2, $dst|$dst, $src2}",
1168 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1169 X86_COND_BE, EFLAGS))]>,
1170 TB;
1171def CMOVA16rm : I<0x47, MRMSrcMem, // if >u, GR16 = [mem16]
1172 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1173 "cmova\t{$src2, $dst|$dst, $src2}",
1174 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1175 X86_COND_A, EFLAGS))]>,
1176 TB, OpSize;
1177def CMOVA32rm : I<0x47, MRMSrcMem, // if >u, GR32 = [mem32]
1178 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1179 "cmova\t{$src2, $dst|$dst, $src2}",
1180 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1181 X86_COND_A, EFLAGS))]>,
1182 TB;
1183def CMOVL16rm : I<0x4C, MRMSrcMem, // if <s, GR16 = [mem16]
1184 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1185 "cmovl\t{$src2, $dst|$dst, $src2}",
1186 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1187 X86_COND_L, EFLAGS))]>,
1188 TB, OpSize;
1189def CMOVL32rm : I<0x4C, MRMSrcMem, // if <s, GR32 = [mem32]
1190 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1191 "cmovl\t{$src2, $dst|$dst, $src2}",
1192 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1193 X86_COND_L, EFLAGS))]>,
1194 TB;
1195def CMOVGE16rm: I<0x4D, MRMSrcMem, // if >=s, GR16 = [mem16]
1196 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1197 "cmovge\t{$src2, $dst|$dst, $src2}",
1198 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1199 X86_COND_GE, EFLAGS))]>,
1200 TB, OpSize;
1201def CMOVGE32rm: I<0x4D, MRMSrcMem, // if >=s, GR32 = [mem32]
1202 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1203 "cmovge\t{$src2, $dst|$dst, $src2}",
1204 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1205 X86_COND_GE, EFLAGS))]>,
1206 TB;
1207def CMOVLE16rm: I<0x4E, MRMSrcMem, // if <=s, GR16 = [mem16]
1208 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1209 "cmovle\t{$src2, $dst|$dst, $src2}",
1210 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1211 X86_COND_LE, EFLAGS))]>,
1212 TB, OpSize;
1213def CMOVLE32rm: I<0x4E, MRMSrcMem, // if <=s, GR32 = [mem32]
1214 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1215 "cmovle\t{$src2, $dst|$dst, $src2}",
1216 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1217 X86_COND_LE, EFLAGS))]>,
1218 TB;
1219def CMOVG16rm : I<0x4F, MRMSrcMem, // if >s, GR16 = [mem16]
1220 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1221 "cmovg\t{$src2, $dst|$dst, $src2}",
1222 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1223 X86_COND_G, EFLAGS))]>,
1224 TB, OpSize;
1225def CMOVG32rm : I<0x4F, MRMSrcMem, // if >s, GR32 = [mem32]
1226 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1227 "cmovg\t{$src2, $dst|$dst, $src2}",
1228 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1229 X86_COND_G, EFLAGS))]>,
1230 TB;
1231def CMOVS16rm : I<0x48, MRMSrcMem, // if signed, GR16 = [mem16]
1232 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1233 "cmovs\t{$src2, $dst|$dst, $src2}",
1234 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1235 X86_COND_S, EFLAGS))]>,
1236 TB, OpSize;
1237def CMOVS32rm : I<0x48, MRMSrcMem, // if signed, GR32 = [mem32]
1238 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1239 "cmovs\t{$src2, $dst|$dst, $src2}",
1240 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1241 X86_COND_S, EFLAGS))]>,
1242 TB;
1243def CMOVNS16rm: I<0x49, MRMSrcMem, // if !signed, GR16 = [mem16]
1244 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1245 "cmovns\t{$src2, $dst|$dst, $src2}",
1246 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1247 X86_COND_NS, EFLAGS))]>,
1248 TB, OpSize;
1249def CMOVNS32rm: I<0x49, MRMSrcMem, // if !signed, GR32 = [mem32]
1250 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1251 "cmovns\t{$src2, $dst|$dst, $src2}",
1252 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1253 X86_COND_NS, EFLAGS))]>,
1254 TB;
1255def CMOVP16rm : I<0x4A, MRMSrcMem, // if parity, GR16 = [mem16]
1256 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1257 "cmovp\t{$src2, $dst|$dst, $src2}",
1258 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1259 X86_COND_P, EFLAGS))]>,
1260 TB, OpSize;
1261def CMOVP32rm : I<0x4A, MRMSrcMem, // if parity, GR32 = [mem32]
1262 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1263 "cmovp\t{$src2, $dst|$dst, $src2}",
1264 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1265 X86_COND_P, EFLAGS))]>,
1266 TB;
1267def CMOVNP16rm : I<0x4B, MRMSrcMem, // if !parity, GR16 = [mem16]
1268 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1269 "cmovnp\t{$src2, $dst|$dst, $src2}",
1270 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1271 X86_COND_NP, EFLAGS))]>,
1272 TB, OpSize;
Dan Gohman305fceb2009-01-07 00:35:10 +00001273def CMOVNP32rm : I<0x4B, MRMSrcMem, // if !parity, GR32 = [mem32]
1274 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1275 "cmovnp\t{$src2, $dst|$dst, $src2}",
1276 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1277 X86_COND_NP, EFLAGS))]>,
1278 TB;
1279def CMOVO16rm : I<0x40, MRMSrcMem, // if overflow, GR16 = [mem16]
1280 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1281 "cmovo\t{$src2, $dst|$dst, $src2}",
1282 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1283 X86_COND_O, EFLAGS))]>,
1284 TB, OpSize;
1285def CMOVO32rm : I<0x40, MRMSrcMem, // if overflow, GR32 = [mem32]
1286 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1287 "cmovo\t{$src2, $dst|$dst, $src2}",
1288 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1289 X86_COND_O, EFLAGS))]>,
1290 TB;
1291def CMOVNO16rm : I<0x41, MRMSrcMem, // if !overflow, GR16 = [mem16]
1292 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1293 "cmovno\t{$src2, $dst|$dst, $src2}",
1294 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1295 X86_COND_NO, EFLAGS))]>,
1296 TB, OpSize;
1297def CMOVNO32rm : I<0x41, MRMSrcMem, // if !overflow, GR32 = [mem32]
1298 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1299 "cmovno\t{$src2, $dst|$dst, $src2}",
1300 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1301 X86_COND_NO, EFLAGS))]>,
1302 TB;
Evan Cheng0488db92007-09-25 01:57:46 +00001303} // Uses = [EFLAGS]
1304
1305
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00001306// unary instructions
Evan Cheng1693e482006-07-19 00:27:29 +00001307let CodeSize = 2 in {
Evan Cheng24f2ea32007-09-14 21:48:26 +00001308let Defs = [EFLAGS] in {
Dan Gohmanb1576f52007-07-31 20:11:57 +00001309def NEG8r : I<0xF6, MRM3r, (outs GR8 :$dst), (ins GR8 :$src), "neg{b}\t$dst",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001310 [(set GR8:$dst, (ineg GR8:$src)),
1311 (implicit EFLAGS)]>;
Dan Gohmanb1576f52007-07-31 20:11:57 +00001312def NEG16r : I<0xF7, MRM3r, (outs GR16:$dst), (ins GR16:$src), "neg{w}\t$dst",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001313 [(set GR16:$dst, (ineg GR16:$src)),
1314 (implicit EFLAGS)]>, OpSize;
Dan Gohmanb1576f52007-07-31 20:11:57 +00001315def NEG32r : I<0xF7, MRM3r, (outs GR32:$dst), (ins GR32:$src), "neg{l}\t$dst",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001316 [(set GR32:$dst, (ineg GR32:$src)),
1317 (implicit EFLAGS)]>;
Chris Lattner57a02302004-08-11 04:31:00 +00001318let isTwoAddress = 0 in {
Dan Gohmanb1576f52007-07-31 20:11:57 +00001319 def NEG8m : I<0xF6, MRM3m, (outs), (ins i8mem :$dst), "neg{b}\t$dst",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001320 [(store (ineg (loadi8 addr:$dst)), addr:$dst),
1321 (implicit EFLAGS)]>;
Dan Gohmanb1576f52007-07-31 20:11:57 +00001322 def NEG16m : I<0xF7, MRM3m, (outs), (ins i16mem:$dst), "neg{w}\t$dst",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001323 [(store (ineg (loadi16 addr:$dst)), addr:$dst),
1324 (implicit EFLAGS)]>, OpSize;
Dan Gohmanb1576f52007-07-31 20:11:57 +00001325 def NEG32m : I<0xF7, MRM3m, (outs), (ins i32mem:$dst), "neg{l}\t$dst",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001326 [(store (ineg (loadi32 addr:$dst)), addr:$dst),
1327 (implicit EFLAGS)]>;
Chris Lattner57a02302004-08-11 04:31:00 +00001328}
Evan Cheng24f2ea32007-09-14 21:48:26 +00001329} // Defs = [EFLAGS]
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00001330
Evan Chengaaf414c2009-01-21 02:09:05 +00001331// Match xor -1 to not. Favors these over a move imm + xor to save code size.
1332let AddedComplexity = 15 in {
Dan Gohmanb1576f52007-07-31 20:11:57 +00001333def NOT8r : I<0xF6, MRM2r, (outs GR8 :$dst), (ins GR8 :$src), "not{b}\t$dst",
Evan Cheng069287d2006-05-16 07:21:53 +00001334 [(set GR8:$dst, (not GR8:$src))]>;
Dan Gohmanb1576f52007-07-31 20:11:57 +00001335def NOT16r : I<0xF7, MRM2r, (outs GR16:$dst), (ins GR16:$src), "not{w}\t$dst",
Evan Cheng069287d2006-05-16 07:21:53 +00001336 [(set GR16:$dst, (not GR16:$src))]>, OpSize;
Dan Gohmanb1576f52007-07-31 20:11:57 +00001337def NOT32r : I<0xF7, MRM2r, (outs GR32:$dst), (ins GR32:$src), "not{l}\t$dst",
Evan Cheng069287d2006-05-16 07:21:53 +00001338 [(set GR32:$dst, (not GR32:$src))]>;
Evan Chengaaf414c2009-01-21 02:09:05 +00001339}
Chris Lattner57a02302004-08-11 04:31:00 +00001340let isTwoAddress = 0 in {
Dan Gohmanb1576f52007-07-31 20:11:57 +00001341 def NOT8m : I<0xF6, MRM2m, (outs), (ins i8mem :$dst), "not{b}\t$dst",
Evan Cheng605c4152005-12-13 01:57:51 +00001342 [(store (not (loadi8 addr:$dst)), addr:$dst)]>;
Dan Gohmanb1576f52007-07-31 20:11:57 +00001343 def NOT16m : I<0xF7, MRM2m, (outs), (ins i16mem:$dst), "not{w}\t$dst",
Evan Cheng605c4152005-12-13 01:57:51 +00001344 [(store (not (loadi16 addr:$dst)), addr:$dst)]>, OpSize;
Dan Gohmanb1576f52007-07-31 20:11:57 +00001345 def NOT32m : I<0xF7, MRM2m, (outs), (ins i32mem:$dst), "not{l}\t$dst",
Evan Cheng605c4152005-12-13 01:57:51 +00001346 [(store (not (loadi32 addr:$dst)), addr:$dst)]>;
Chris Lattner57a02302004-08-11 04:31:00 +00001347}
Evan Cheng1693e482006-07-19 00:27:29 +00001348} // CodeSize
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00001349
Evan Chengb51a0592005-12-10 00:48:20 +00001350// TODO: inc/dec is slow for P4, but fast for Pentium-M.
Evan Cheng24f2ea32007-09-14 21:48:26 +00001351let Defs = [EFLAGS] in {
Evan Cheng1693e482006-07-19 00:27:29 +00001352let CodeSize = 2 in
Dan Gohmanb1576f52007-07-31 20:11:57 +00001353def INC8r : I<0xFE, MRM0r, (outs GR8 :$dst), (ins GR8 :$src), "inc{b}\t$dst",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001354 [(set GR8:$dst, (add GR8:$src, 1)),
1355 (implicit EFLAGS)]>;
Evan Cheng1693e482006-07-19 00:27:29 +00001356let isConvertibleToThreeAddress = 1, CodeSize = 1 in { // Can xform into LEA.
Dan Gohmanb1576f52007-07-31 20:11:57 +00001357def INC16r : I<0x40, AddRegFrm, (outs GR16:$dst), (ins GR16:$src), "inc{w}\t$dst",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001358 [(set GR16:$dst, (add GR16:$src, 1)),
1359 (implicit EFLAGS)]>,
Evan Cheng25ab6902006-09-08 06:48:29 +00001360 OpSize, Requires<[In32BitMode]>;
Dan Gohmanb1576f52007-07-31 20:11:57 +00001361def INC32r : I<0x40, AddRegFrm, (outs GR32:$dst), (ins GR32:$src), "inc{l}\t$dst",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001362 [(set GR32:$dst, (add GR32:$src, 1)),
1363 (implicit EFLAGS)]>, Requires<[In32BitMode]>;
Chris Lattnercc65bee2005-01-02 02:35:46 +00001364}
Evan Cheng1693e482006-07-19 00:27:29 +00001365let isTwoAddress = 0, CodeSize = 2 in {
Dan Gohmanb1576f52007-07-31 20:11:57 +00001366 def INC8m : I<0xFE, MRM0m, (outs), (ins i8mem :$dst), "inc{b}\t$dst",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001367 [(store (add (loadi8 addr:$dst), 1), addr:$dst),
1368 (implicit EFLAGS)]>;
Dan Gohmanb1576f52007-07-31 20:11:57 +00001369 def INC16m : I<0xFF, MRM0m, (outs), (ins i16mem:$dst), "inc{w}\t$dst",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001370 [(store (add (loadi16 addr:$dst), 1), addr:$dst),
1371 (implicit EFLAGS)]>,
Evan Cheng66f71632007-10-19 21:23:22 +00001372 OpSize, Requires<[In32BitMode]>;
Dan Gohmanb1576f52007-07-31 20:11:57 +00001373 def INC32m : I<0xFF, MRM0m, (outs), (ins i32mem:$dst), "inc{l}\t$dst",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001374 [(store (add (loadi32 addr:$dst), 1), addr:$dst),
1375 (implicit EFLAGS)]>,
Evan Cheng66f71632007-10-19 21:23:22 +00001376 Requires<[In32BitMode]>;
Chris Lattner57a02302004-08-11 04:31:00 +00001377}
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00001378
Evan Cheng1693e482006-07-19 00:27:29 +00001379let CodeSize = 2 in
Dan Gohmanb1576f52007-07-31 20:11:57 +00001380def DEC8r : I<0xFE, MRM1r, (outs GR8 :$dst), (ins GR8 :$src), "dec{b}\t$dst",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001381 [(set GR8:$dst, (add GR8:$src, -1)),
1382 (implicit EFLAGS)]>;
Evan Cheng1693e482006-07-19 00:27:29 +00001383let isConvertibleToThreeAddress = 1, CodeSize = 1 in { // Can xform into LEA.
Dan Gohmanb1576f52007-07-31 20:11:57 +00001384def DEC16r : I<0x48, AddRegFrm, (outs GR16:$dst), (ins GR16:$src), "dec{w}\t$dst",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001385 [(set GR16:$dst, (add GR16:$src, -1)),
1386 (implicit EFLAGS)]>,
Evan Cheng25ab6902006-09-08 06:48:29 +00001387 OpSize, Requires<[In32BitMode]>;
Dan Gohmanb1576f52007-07-31 20:11:57 +00001388def DEC32r : I<0x48, AddRegFrm, (outs GR32:$dst), (ins GR32:$src), "dec{l}\t$dst",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001389 [(set GR32:$dst, (add GR32:$src, -1)),
1390 (implicit EFLAGS)]>, Requires<[In32BitMode]>;
Chris Lattnercc65bee2005-01-02 02:35:46 +00001391}
Chris Lattner57a02302004-08-11 04:31:00 +00001392
Evan Cheng1693e482006-07-19 00:27:29 +00001393let isTwoAddress = 0, CodeSize = 2 in {
Dan Gohmanb1576f52007-07-31 20:11:57 +00001394 def DEC8m : I<0xFE, MRM1m, (outs), (ins i8mem :$dst), "dec{b}\t$dst",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001395 [(store (add (loadi8 addr:$dst), -1), addr:$dst),
1396 (implicit EFLAGS)]>;
Dan Gohmanb1576f52007-07-31 20:11:57 +00001397 def DEC16m : I<0xFF, MRM1m, (outs), (ins i16mem:$dst), "dec{w}\t$dst",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001398 [(store (add (loadi16 addr:$dst), -1), addr:$dst),
1399 (implicit EFLAGS)]>,
Evan Cheng66f71632007-10-19 21:23:22 +00001400 OpSize, Requires<[In32BitMode]>;
Dan Gohmanb1576f52007-07-31 20:11:57 +00001401 def DEC32m : I<0xFF, MRM1m, (outs), (ins i32mem:$dst), "dec{l}\t$dst",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001402 [(store (add (loadi32 addr:$dst), -1), addr:$dst),
1403 (implicit EFLAGS)]>,
Evan Cheng66f71632007-10-19 21:23:22 +00001404 Requires<[In32BitMode]>;
Chris Lattner57a02302004-08-11 04:31:00 +00001405}
Evan Cheng24f2ea32007-09-14 21:48:26 +00001406} // Defs = [EFLAGS]
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00001407
1408// Logical operators...
Evan Cheng24f2ea32007-09-14 21:48:26 +00001409let Defs = [EFLAGS] in {
Chris Lattnercc65bee2005-01-02 02:35:46 +00001410let isCommutable = 1 in { // X = AND Y, Z --> X = AND Z, Y
Chris Lattner3a173df2004-10-03 20:35:00 +00001411def AND8rr : I<0x20, MRMDestReg,
Evan Cheng64d80e32007-07-19 01:14:50 +00001412 (outs GR8 :$dst), (ins GR8 :$src1, GR8 :$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001413 "and{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001414 [(set GR8:$dst, (and GR8:$src1, GR8:$src2)),
1415 (implicit EFLAGS)]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00001416def AND16rr : I<0x21, MRMDestReg,
Evan Cheng64d80e32007-07-19 01:14:50 +00001417 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001418 "and{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001419 [(set GR16:$dst, (and GR16:$src1, GR16:$src2)),
1420 (implicit EFLAGS)]>, OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00001421def AND32rr : I<0x21, MRMDestReg,
Evan Cheng64d80e32007-07-19 01:14:50 +00001422 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001423 "and{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001424 [(set GR32:$dst, (and GR32:$src1, GR32:$src2)),
1425 (implicit EFLAGS)]>;
Chris Lattnercc65bee2005-01-02 02:35:46 +00001426}
Chris Lattner57a02302004-08-11 04:31:00 +00001427
Chris Lattner3a173df2004-10-03 20:35:00 +00001428def AND8rm : I<0x22, MRMSrcMem,
Evan Cheng64d80e32007-07-19 01:14:50 +00001429 (outs GR8 :$dst), (ins GR8 :$src1, i8mem :$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001430 "and{b}\t{$src2, $dst|$dst, $src2}",
Chris Lattnerc2406f22009-04-10 00:16:23 +00001431 [(set GR8:$dst, (and GR8:$src1, (loadi8 addr:$src2))),
Dan Gohman09a2609e2009-03-03 19:53:46 +00001432 (implicit EFLAGS)]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00001433def AND16rm : I<0x23, MRMSrcMem,
Evan Cheng64d80e32007-07-19 01:14:50 +00001434 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001435 "and{w}\t{$src2, $dst|$dst, $src2}",
Chris Lattnerc2406f22009-04-10 00:16:23 +00001436 [(set GR16:$dst, (and GR16:$src1, (loadi16 addr:$src2))),
Dan Gohman09a2609e2009-03-03 19:53:46 +00001437 (implicit EFLAGS)]>, OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00001438def AND32rm : I<0x23, MRMSrcMem,
Evan Cheng64d80e32007-07-19 01:14:50 +00001439 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001440 "and{l}\t{$src2, $dst|$dst, $src2}",
Chris Lattnerc2406f22009-04-10 00:16:23 +00001441 [(set GR32:$dst, (and GR32:$src1, (loadi32 addr:$src2))),
Dan Gohman09a2609e2009-03-03 19:53:46 +00001442 (implicit EFLAGS)]>;
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00001443
Chris Lattner3a173df2004-10-03 20:35:00 +00001444def AND8ri : Ii8<0x80, MRM4r,
Evan Cheng64d80e32007-07-19 01:14:50 +00001445 (outs GR8 :$dst), (ins GR8 :$src1, i8imm :$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001446 "and{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001447 [(set GR8:$dst, (and GR8:$src1, imm:$src2)),
1448 (implicit EFLAGS)]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00001449def AND16ri : Ii16<0x81, MRM4r,
Evan Cheng64d80e32007-07-19 01:14:50 +00001450 (outs GR16:$dst), (ins GR16:$src1, i16imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001451 "and{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001452 [(set GR16:$dst, (and GR16:$src1, imm:$src2)),
1453 (implicit EFLAGS)]>, OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00001454def AND32ri : Ii32<0x81, MRM4r,
Evan Cheng64d80e32007-07-19 01:14:50 +00001455 (outs GR32:$dst), (ins GR32:$src1, i32imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001456 "and{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001457 [(set GR32:$dst, (and GR32:$src1, imm:$src2)),
1458 (implicit EFLAGS)]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00001459def AND16ri8 : Ii8<0x83, MRM4r,
Evan Cheng64d80e32007-07-19 01:14:50 +00001460 (outs GR16:$dst), (ins GR16:$src1, i16i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001461 "and{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001462 [(set GR16:$dst, (and GR16:$src1, i16immSExt8:$src2)),
1463 (implicit EFLAGS)]>,
Evan Cheng9b6b6422005-12-13 00:14:11 +00001464 OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00001465def AND32ri8 : Ii8<0x83, MRM4r,
Evan Cheng64d80e32007-07-19 01:14:50 +00001466 (outs GR32:$dst), (ins GR32:$src1, i32i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001467 "and{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001468 [(set GR32:$dst, (and GR32:$src1, i32immSExt8:$src2)),
1469 (implicit EFLAGS)]>;
Chris Lattnerf29ed092004-08-11 05:07:25 +00001470
1471let isTwoAddress = 0 in {
Chris Lattner3a173df2004-10-03 20:35:00 +00001472 def AND8mr : I<0x20, MRMDestMem,
Evan Cheng64d80e32007-07-19 01:14:50 +00001473 (outs), (ins i8mem :$dst, GR8 :$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001474 "and{b}\t{$src, $dst|$dst, $src}",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001475 [(store (and (load addr:$dst), GR8:$src), addr:$dst),
1476 (implicit EFLAGS)]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00001477 def AND16mr : I<0x21, MRMDestMem,
Evan Cheng64d80e32007-07-19 01:14:50 +00001478 (outs), (ins i16mem:$dst, GR16:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001479 "and{w}\t{$src, $dst|$dst, $src}",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001480 [(store (and (load addr:$dst), GR16:$src), addr:$dst),
1481 (implicit EFLAGS)]>,
Evan Cheng0ef3a772005-12-13 01:41:36 +00001482 OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00001483 def AND32mr : I<0x21, MRMDestMem,
Evan Cheng64d80e32007-07-19 01:14:50 +00001484 (outs), (ins i32mem:$dst, GR32:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001485 "and{l}\t{$src, $dst|$dst, $src}",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001486 [(store (and (load addr:$dst), GR32:$src), addr:$dst),
1487 (implicit EFLAGS)]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00001488 def AND8mi : Ii8<0x80, MRM4m,
Evan Cheng64d80e32007-07-19 01:14:50 +00001489 (outs), (ins i8mem :$dst, i8imm :$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001490 "and{b}\t{$src, $dst|$dst, $src}",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001491 [(store (and (loadi8 addr:$dst), imm:$src), addr:$dst),
1492 (implicit EFLAGS)]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00001493 def AND16mi : Ii16<0x81, MRM4m,
Evan Cheng64d80e32007-07-19 01:14:50 +00001494 (outs), (ins i16mem:$dst, i16imm:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001495 "and{w}\t{$src, $dst|$dst, $src}",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001496 [(store (and (loadi16 addr:$dst), imm:$src), addr:$dst),
1497 (implicit EFLAGS)]>,
Evan Cheng0ef3a772005-12-13 01:41:36 +00001498 OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00001499 def AND32mi : Ii32<0x81, MRM4m,
Evan Cheng64d80e32007-07-19 01:14:50 +00001500 (outs), (ins i32mem:$dst, i32imm:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001501 "and{l}\t{$src, $dst|$dst, $src}",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001502 [(store (and (loadi32 addr:$dst), imm:$src), addr:$dst),
1503 (implicit EFLAGS)]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00001504 def AND16mi8 : Ii8<0x83, MRM4m,
Evan Cheng64d80e32007-07-19 01:14:50 +00001505 (outs), (ins i16mem:$dst, i16i8imm :$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001506 "and{w}\t{$src, $dst|$dst, $src}",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001507 [(store (and (load addr:$dst), i16immSExt8:$src), addr:$dst),
1508 (implicit EFLAGS)]>,
Evan Cheng0ef3a772005-12-13 01:41:36 +00001509 OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00001510 def AND32mi8 : Ii8<0x83, MRM4m,
Evan Cheng64d80e32007-07-19 01:14:50 +00001511 (outs), (ins i32mem:$dst, i32i8imm :$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001512 "and{l}\t{$src, $dst|$dst, $src}",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001513 [(store (and (load addr:$dst), i32immSExt8:$src), addr:$dst),
1514 (implicit EFLAGS)]>;
Chris Lattnerf29ed092004-08-11 05:07:25 +00001515}
1516
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00001517
Chris Lattnercc65bee2005-01-02 02:35:46 +00001518let isCommutable = 1 in { // X = OR Y, Z --> X = OR Z, Y
Evan Cheng64d80e32007-07-19 01:14:50 +00001519def OR8rr : I<0x08, MRMDestReg, (outs GR8 :$dst), (ins GR8 :$src1, GR8 :$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001520 "or{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001521 [(set GR8:$dst, (or GR8:$src1, GR8:$src2)),
1522 (implicit EFLAGS)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00001523def OR16rr : I<0x09, MRMDestReg, (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001524 "or{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001525 [(set GR16:$dst, (or GR16:$src1, GR16:$src2)),
1526 (implicit EFLAGS)]>, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00001527def OR32rr : I<0x09, MRMDestReg, (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001528 "or{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001529 [(set GR32:$dst, (or GR32:$src1, GR32:$src2)),
1530 (implicit EFLAGS)]>;
Chris Lattnercc65bee2005-01-02 02:35:46 +00001531}
Evan Cheng64d80e32007-07-19 01:14:50 +00001532def OR8rm : I<0x0A, MRMSrcMem , (outs GR8 :$dst), (ins GR8 :$src1, i8mem :$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001533 "or{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001534 [(set GR8:$dst, (or GR8:$src1, (load addr:$src2))),
1535 (implicit EFLAGS)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00001536def OR16rm : I<0x0B, MRMSrcMem , (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001537 "or{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001538 [(set GR16:$dst, (or GR16:$src1, (load addr:$src2))),
1539 (implicit EFLAGS)]>, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00001540def OR32rm : I<0x0B, MRMSrcMem , (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001541 "or{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001542 [(set GR32:$dst, (or GR32:$src1, (load addr:$src2))),
1543 (implicit EFLAGS)]>;
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00001544
Evan Cheng64d80e32007-07-19 01:14:50 +00001545def OR8ri : Ii8 <0x80, MRM1r, (outs GR8 :$dst), (ins GR8 :$src1, i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001546 "or{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001547 [(set GR8:$dst, (or GR8:$src1, imm:$src2)),
1548 (implicit EFLAGS)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00001549def OR16ri : Ii16<0x81, MRM1r, (outs GR16:$dst), (ins GR16:$src1, i16imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001550 "or{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001551 [(set GR16:$dst, (or GR16:$src1, imm:$src2)),
1552 (implicit EFLAGS)]>, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00001553def OR32ri : Ii32<0x81, MRM1r, (outs GR32:$dst), (ins GR32:$src1, i32imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001554 "or{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001555 [(set GR32:$dst, (or GR32:$src1, imm:$src2)),
1556 (implicit EFLAGS)]>;
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00001557
Evan Cheng64d80e32007-07-19 01:14:50 +00001558def OR16ri8 : Ii8<0x83, MRM1r, (outs GR16:$dst), (ins GR16:$src1, i16i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001559 "or{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001560 [(set GR16:$dst, (or GR16:$src1, i16immSExt8:$src2)),
1561 (implicit EFLAGS)]>, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00001562def OR32ri8 : Ii8<0x83, MRM1r, (outs GR32:$dst), (ins GR32:$src1, i32i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001563 "or{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001564 [(set GR32:$dst, (or GR32:$src1, i32immSExt8:$src2)),
1565 (implicit EFLAGS)]>;
Chris Lattner57a02302004-08-11 04:31:00 +00001566let isTwoAddress = 0 in {
Evan Cheng64d80e32007-07-19 01:14:50 +00001567 def OR8mr : I<0x08, MRMDestMem, (outs), (ins i8mem:$dst, GR8:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001568 "or{b}\t{$src, $dst|$dst, $src}",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001569 [(store (or (load addr:$dst), GR8:$src), addr:$dst),
1570 (implicit EFLAGS)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00001571 def OR16mr : I<0x09, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001572 "or{w}\t{$src, $dst|$dst, $src}",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001573 [(store (or (load addr:$dst), GR16:$src), addr:$dst),
1574 (implicit EFLAGS)]>, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00001575 def OR32mr : I<0x09, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001576 "or{l}\t{$src, $dst|$dst, $src}",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001577 [(store (or (load addr:$dst), GR32:$src), addr:$dst),
1578 (implicit EFLAGS)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00001579 def OR8mi : Ii8<0x80, MRM1m, (outs), (ins i8mem :$dst, i8imm:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001580 "or{b}\t{$src, $dst|$dst, $src}",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001581 [(store (or (loadi8 addr:$dst), imm:$src), addr:$dst),
1582 (implicit EFLAGS)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00001583 def OR16mi : Ii16<0x81, MRM1m, (outs), (ins i16mem:$dst, i16imm:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001584 "or{w}\t{$src, $dst|$dst, $src}",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001585 [(store (or (loadi16 addr:$dst), imm:$src), addr:$dst),
1586 (implicit EFLAGS)]>,
Evan Cheng0ef3a772005-12-13 01:41:36 +00001587 OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00001588 def OR32mi : Ii32<0x81, MRM1m, (outs), (ins i32mem:$dst, i32imm:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001589 "or{l}\t{$src, $dst|$dst, $src}",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001590 [(store (or (loadi32 addr:$dst), imm:$src), addr:$dst),
1591 (implicit EFLAGS)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00001592 def OR16mi8 : Ii8<0x83, MRM1m, (outs), (ins i16mem:$dst, i16i8imm:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001593 "or{w}\t{$src, $dst|$dst, $src}",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001594 [(store (or (load addr:$dst), i16immSExt8:$src), addr:$dst),
1595 (implicit EFLAGS)]>,
Evan Cheng0ef3a772005-12-13 01:41:36 +00001596 OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00001597 def OR32mi8 : Ii8<0x83, MRM1m, (outs), (ins i32mem:$dst, i32i8imm:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001598 "or{l}\t{$src, $dst|$dst, $src}",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001599 [(store (or (load addr:$dst), i32immSExt8:$src), addr:$dst),
1600 (implicit EFLAGS)]>;
Bill Wendlingbd0879d2008-05-29 01:02:09 +00001601} // isTwoAddress = 0
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00001602
1603
Evan Cheng359e9372008-06-18 08:13:07 +00001604let isCommutable = 1 in { // X = XOR Y, Z --> X = XOR Z, Y
Bill Wendlingbd0879d2008-05-29 01:02:09 +00001605 def XOR8rr : I<0x30, MRMDestReg,
1606 (outs GR8 :$dst), (ins GR8 :$src1, GR8 :$src2),
1607 "xor{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001608 [(set GR8:$dst, (xor GR8:$src1, GR8:$src2)),
1609 (implicit EFLAGS)]>;
Bill Wendlingbd0879d2008-05-29 01:02:09 +00001610 def XOR16rr : I<0x31, MRMDestReg,
1611 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
1612 "xor{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001613 [(set GR16:$dst, (xor GR16:$src1, GR16:$src2)),
1614 (implicit EFLAGS)]>, OpSize;
Bill Wendlingbd0879d2008-05-29 01:02:09 +00001615 def XOR32rr : I<0x31, MRMDestReg,
1616 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
1617 "xor{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001618 [(set GR32:$dst, (xor GR32:$src1, GR32:$src2)),
1619 (implicit EFLAGS)]>;
Evan Cheng359e9372008-06-18 08:13:07 +00001620} // isCommutable = 1
Chris Lattnercc65bee2005-01-02 02:35:46 +00001621
Chris Lattner3a173df2004-10-03 20:35:00 +00001622def XOR8rm : I<0x32, MRMSrcMem ,
Evan Cheng64d80e32007-07-19 01:14:50 +00001623 (outs GR8 :$dst), (ins GR8:$src1, i8mem :$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001624 "xor{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001625 [(set GR8:$dst, (xor GR8:$src1, (load addr:$src2))),
1626 (implicit EFLAGS)]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00001627def XOR16rm : I<0x33, MRMSrcMem ,
Evan Cheng64d80e32007-07-19 01:14:50 +00001628 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001629 "xor{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001630 [(set GR16:$dst, (xor GR16:$src1, (load addr:$src2))),
1631 (implicit EFLAGS)]>,
Bill Wendlingbd0879d2008-05-29 01:02:09 +00001632 OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00001633def XOR32rm : I<0x33, MRMSrcMem ,
Evan Cheng64d80e32007-07-19 01:14:50 +00001634 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001635 "xor{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001636 [(set GR32:$dst, (xor GR32:$src1, (load addr:$src2))),
1637 (implicit EFLAGS)]>;
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00001638
Bill Wendling75cf88f2008-05-29 03:46:36 +00001639def XOR8ri : Ii8<0x80, MRM6r,
1640 (outs GR8:$dst), (ins GR8:$src1, i8imm:$src2),
1641 "xor{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001642 [(set GR8:$dst, (xor GR8:$src1, imm:$src2)),
1643 (implicit EFLAGS)]>;
Bill Wendling75cf88f2008-05-29 03:46:36 +00001644def XOR16ri : Ii16<0x81, MRM6r,
1645 (outs GR16:$dst), (ins GR16:$src1, i16imm:$src2),
1646 "xor{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001647 [(set GR16:$dst, (xor GR16:$src1, imm:$src2)),
1648 (implicit EFLAGS)]>, OpSize;
Bill Wendling75cf88f2008-05-29 03:46:36 +00001649def XOR32ri : Ii32<0x81, MRM6r,
1650 (outs GR32:$dst), (ins GR32:$src1, i32imm:$src2),
1651 "xor{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001652 [(set GR32:$dst, (xor GR32:$src1, imm:$src2)),
1653 (implicit EFLAGS)]>;
Bill Wendling75cf88f2008-05-29 03:46:36 +00001654def XOR16ri8 : Ii8<0x83, MRM6r,
1655 (outs GR16:$dst), (ins GR16:$src1, i16i8imm:$src2),
1656 "xor{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001657 [(set GR16:$dst, (xor GR16:$src1, i16immSExt8:$src2)),
1658 (implicit EFLAGS)]>,
Bill Wendling75cf88f2008-05-29 03:46:36 +00001659 OpSize;
1660def XOR32ri8 : Ii8<0x83, MRM6r,
1661 (outs GR32:$dst), (ins GR32:$src1, i32i8imm:$src2),
1662 "xor{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001663 [(set GR32:$dst, (xor GR32:$src1, i32immSExt8:$src2)),
1664 (implicit EFLAGS)]>;
Bill Wendlingbd0879d2008-05-29 01:02:09 +00001665
Chris Lattner57a02302004-08-11 04:31:00 +00001666let isTwoAddress = 0 in {
Chris Lattner3a173df2004-10-03 20:35:00 +00001667 def XOR8mr : I<0x30, MRMDestMem,
Evan Cheng64d80e32007-07-19 01:14:50 +00001668 (outs), (ins i8mem :$dst, GR8 :$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001669 "xor{b}\t{$src, $dst|$dst, $src}",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001670 [(store (xor (load addr:$dst), GR8:$src), addr:$dst),
1671 (implicit EFLAGS)]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00001672 def XOR16mr : I<0x31, MRMDestMem,
Evan Cheng64d80e32007-07-19 01:14:50 +00001673 (outs), (ins i16mem:$dst, GR16:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001674 "xor{w}\t{$src, $dst|$dst, $src}",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001675 [(store (xor (load addr:$dst), GR16:$src), addr:$dst),
1676 (implicit EFLAGS)]>,
Evan Cheng0ef3a772005-12-13 01:41:36 +00001677 OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00001678 def XOR32mr : I<0x31, MRMDestMem,
Evan Cheng64d80e32007-07-19 01:14:50 +00001679 (outs), (ins i32mem:$dst, GR32:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001680 "xor{l}\t{$src, $dst|$dst, $src}",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001681 [(store (xor (load addr:$dst), GR32:$src), addr:$dst),
1682 (implicit EFLAGS)]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00001683 def XOR8mi : Ii8<0x80, MRM6m,
Evan Cheng64d80e32007-07-19 01:14:50 +00001684 (outs), (ins i8mem :$dst, i8imm :$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001685 "xor{b}\t{$src, $dst|$dst, $src}",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001686 [(store (xor (loadi8 addr:$dst), imm:$src), addr:$dst),
1687 (implicit EFLAGS)]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00001688 def XOR16mi : Ii16<0x81, MRM6m,
Evan Cheng64d80e32007-07-19 01:14:50 +00001689 (outs), (ins i16mem:$dst, i16imm:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001690 "xor{w}\t{$src, $dst|$dst, $src}",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001691 [(store (xor (loadi16 addr:$dst), imm:$src), addr:$dst),
1692 (implicit EFLAGS)]>,
Evan Cheng0ef3a772005-12-13 01:41:36 +00001693 OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00001694 def XOR32mi : Ii32<0x81, MRM6m,
Evan Cheng64d80e32007-07-19 01:14:50 +00001695 (outs), (ins i32mem:$dst, i32imm:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001696 "xor{l}\t{$src, $dst|$dst, $src}",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001697 [(store (xor (loadi32 addr:$dst), imm:$src), addr:$dst),
1698 (implicit EFLAGS)]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00001699 def XOR16mi8 : Ii8<0x83, MRM6m,
Evan Cheng64d80e32007-07-19 01:14:50 +00001700 (outs), (ins i16mem:$dst, i16i8imm :$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001701 "xor{w}\t{$src, $dst|$dst, $src}",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001702 [(store (xor (load addr:$dst), i16immSExt8:$src), addr:$dst),
1703 (implicit EFLAGS)]>,
Evan Cheng0ef3a772005-12-13 01:41:36 +00001704 OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00001705 def XOR32mi8 : Ii8<0x83, MRM6m,
Evan Cheng64d80e32007-07-19 01:14:50 +00001706 (outs), (ins i32mem:$dst, i32i8imm :$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001707 "xor{l}\t{$src, $dst|$dst, $src}",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001708 [(store (xor (load addr:$dst), i32immSExt8:$src), addr:$dst),
1709 (implicit EFLAGS)]>;
Bill Wendlingbd0879d2008-05-29 01:02:09 +00001710} // isTwoAddress = 0
Evan Cheng24f2ea32007-09-14 21:48:26 +00001711} // Defs = [EFLAGS]
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00001712
1713// Shift instructions
Evan Cheng24f2ea32007-09-14 21:48:26 +00001714let Defs = [EFLAGS] in {
Evan Cheng071a2792007-09-11 19:55:27 +00001715let Uses = [CL] in {
Evan Cheng64d80e32007-07-19 01:14:50 +00001716def SHL8rCL : I<0xD2, MRM4r, (outs GR8 :$dst), (ins GR8 :$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001717 "shl{b}\t{%cl, $dst|$dst, %CL}",
Evan Cheng071a2792007-09-11 19:55:27 +00001718 [(set GR8:$dst, (shl GR8:$src, CL))]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00001719def SHL16rCL : I<0xD3, MRM4r, (outs GR16:$dst), (ins GR16:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001720 "shl{w}\t{%cl, $dst|$dst, %CL}",
Evan Cheng071a2792007-09-11 19:55:27 +00001721 [(set GR16:$dst, (shl GR16:$src, CL))]>, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00001722def SHL32rCL : I<0xD3, MRM4r, (outs GR32:$dst), (ins GR32:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001723 "shl{l}\t{%cl, $dst|$dst, %CL}",
Evan Cheng071a2792007-09-11 19:55:27 +00001724 [(set GR32:$dst, (shl GR32:$src, CL))]>;
Bill Wendlingbd0879d2008-05-29 01:02:09 +00001725} // Uses = [CL]
Chris Lattnercc65bee2005-01-02 02:35:46 +00001726
Evan Cheng64d80e32007-07-19 01:14:50 +00001727def SHL8ri : Ii8<0xC0, MRM4r, (outs GR8 :$dst), (ins GR8 :$src1, i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001728 "shl{b}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001729 [(set GR8:$dst, (shl GR8:$src1, (i8 imm:$src2)))]>;
Chris Lattnercc65bee2005-01-02 02:35:46 +00001730let isConvertibleToThreeAddress = 1 in { // Can transform into LEA.
Evan Cheng64d80e32007-07-19 01:14:50 +00001731def SHL16ri : Ii8<0xC1, MRM4r, (outs GR16:$dst), (ins GR16:$src1, i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001732 "shl{w}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001733 [(set GR16:$dst, (shl GR16:$src1, (i8 imm:$src2)))]>, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00001734def SHL32ri : Ii8<0xC1, MRM4r, (outs GR32:$dst), (ins GR32:$src1, i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001735 "shl{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001736 [(set GR32:$dst, (shl GR32:$src1, (i8 imm:$src2)))]>;
Chris Lattnerf9b3f372008-01-11 18:00:50 +00001737// NOTE: We don't use shifts of a register by one, because 'add reg,reg' is
1738// cheaper.
Bill Wendlingbd0879d2008-05-29 01:02:09 +00001739} // isConvertibleToThreeAddress = 1
Evan Cheng09c54572006-06-29 00:36:51 +00001740
Chris Lattnerf29ed092004-08-11 05:07:25 +00001741let isTwoAddress = 0 in {
Evan Cheng071a2792007-09-11 19:55:27 +00001742 let Uses = [CL] in {
Evan Cheng64d80e32007-07-19 01:14:50 +00001743 def SHL8mCL : I<0xD2, MRM4m, (outs), (ins i8mem :$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001744 "shl{b}\t{%cl, $dst|$dst, %CL}",
Evan Cheng071a2792007-09-11 19:55:27 +00001745 [(store (shl (loadi8 addr:$dst), CL), addr:$dst)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00001746 def SHL16mCL : I<0xD3, MRM4m, (outs), (ins i16mem:$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001747 "shl{w}\t{%cl, $dst|$dst, %CL}",
Evan Cheng071a2792007-09-11 19:55:27 +00001748 [(store (shl (loadi16 addr:$dst), CL), addr:$dst)]>, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00001749 def SHL32mCL : I<0xD3, MRM4m, (outs), (ins i32mem:$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001750 "shl{l}\t{%cl, $dst|$dst, %CL}",
Evan Cheng071a2792007-09-11 19:55:27 +00001751 [(store (shl (loadi32 addr:$dst), CL), addr:$dst)]>;
1752 }
Evan Cheng64d80e32007-07-19 01:14:50 +00001753 def SHL8mi : Ii8<0xC0, MRM4m, (outs), (ins i8mem :$dst, i8imm:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001754 "shl{b}\t{$src, $dst|$dst, $src}",
Evan Cheng763b0292005-12-13 02:34:51 +00001755 [(store (shl (loadi8 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00001756 def SHL16mi : Ii8<0xC1, MRM4m, (outs), (ins i16mem:$dst, i8imm:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001757 "shl{w}\t{$src, $dst|$dst, $src}",
Evan Cheng763b0292005-12-13 02:34:51 +00001758 [(store (shl (loadi16 addr:$dst), (i8 imm:$src)), addr:$dst)]>,
1759 OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00001760 def SHL32mi : Ii8<0xC1, MRM4m, (outs), (ins i32mem:$dst, i8imm:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001761 "shl{l}\t{$src, $dst|$dst, $src}",
Evan Cheng763b0292005-12-13 02:34:51 +00001762 [(store (shl (loadi32 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
Evan Cheng09c54572006-06-29 00:36:51 +00001763
1764 // Shift by 1
Evan Cheng64d80e32007-07-19 01:14:50 +00001765 def SHL8m1 : I<0xD0, MRM4m, (outs), (ins i8mem :$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001766 "shl{b}\t$dst",
Evan Cheng09c54572006-06-29 00:36:51 +00001767 [(store (shl (loadi8 addr:$dst), (i8 1)), addr:$dst)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00001768 def SHL16m1 : I<0xD1, MRM4m, (outs), (ins i16mem:$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001769 "shl{w}\t$dst",
Evan Cheng09c54572006-06-29 00:36:51 +00001770 [(store (shl (loadi16 addr:$dst), (i8 1)), addr:$dst)]>,
1771 OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00001772 def SHL32m1 : I<0xD1, MRM4m, (outs), (ins i32mem:$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001773 "shl{l}\t$dst",
Evan Cheng09c54572006-06-29 00:36:51 +00001774 [(store (shl (loadi32 addr:$dst), (i8 1)), addr:$dst)]>;
Chris Lattnerf29ed092004-08-11 05:07:25 +00001775}
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00001776
Evan Cheng071a2792007-09-11 19:55:27 +00001777let Uses = [CL] in {
Evan Cheng64d80e32007-07-19 01:14:50 +00001778def SHR8rCL : I<0xD2, MRM5r, (outs GR8 :$dst), (ins GR8 :$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001779 "shr{b}\t{%cl, $dst|$dst, %CL}",
Evan Cheng071a2792007-09-11 19:55:27 +00001780 [(set GR8:$dst, (srl GR8:$src, CL))]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00001781def SHR16rCL : I<0xD3, MRM5r, (outs GR16:$dst), (ins GR16:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001782 "shr{w}\t{%cl, $dst|$dst, %CL}",
Evan Cheng071a2792007-09-11 19:55:27 +00001783 [(set GR16:$dst, (srl GR16:$src, CL))]>, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00001784def SHR32rCL : I<0xD3, MRM5r, (outs GR32:$dst), (ins GR32:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001785 "shr{l}\t{%cl, $dst|$dst, %CL}",
Evan Cheng071a2792007-09-11 19:55:27 +00001786 [(set GR32:$dst, (srl GR32:$src, CL))]>;
1787}
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00001788
Evan Cheng64d80e32007-07-19 01:14:50 +00001789def SHR8ri : Ii8<0xC0, MRM5r, (outs GR8:$dst), (ins GR8:$src1, i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001790 "shr{b}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001791 [(set GR8:$dst, (srl GR8:$src1, (i8 imm:$src2)))]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00001792def SHR16ri : Ii8<0xC1, MRM5r, (outs GR16:$dst), (ins GR16:$src1, i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001793 "shr{w}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001794 [(set GR16:$dst, (srl GR16:$src1, (i8 imm:$src2)))]>, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00001795def SHR32ri : Ii8<0xC1, MRM5r, (outs GR32:$dst), (ins GR32:$src1, i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001796 "shr{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001797 [(set GR32:$dst, (srl GR32:$src1, (i8 imm:$src2)))]>;
Chris Lattnerf29ed092004-08-11 05:07:25 +00001798
Evan Cheng09c54572006-06-29 00:36:51 +00001799// Shift by 1
Evan Cheng64d80e32007-07-19 01:14:50 +00001800def SHR8r1 : I<0xD0, MRM5r, (outs GR8:$dst), (ins GR8:$src1),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001801 "shr{b}\t$dst",
Evan Cheng09c54572006-06-29 00:36:51 +00001802 [(set GR8:$dst, (srl GR8:$src1, (i8 1)))]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00001803def SHR16r1 : I<0xD1, MRM5r, (outs GR16:$dst), (ins GR16:$src1),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001804 "shr{w}\t$dst",
Evan Cheng09c54572006-06-29 00:36:51 +00001805 [(set GR16:$dst, (srl GR16:$src1, (i8 1)))]>, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00001806def SHR32r1 : I<0xD1, MRM5r, (outs GR32:$dst), (ins GR32:$src1),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001807 "shr{l}\t$dst",
Evan Cheng09c54572006-06-29 00:36:51 +00001808 [(set GR32:$dst, (srl GR32:$src1, (i8 1)))]>;
1809
Chris Lattner57a02302004-08-11 04:31:00 +00001810let isTwoAddress = 0 in {
Evan Cheng071a2792007-09-11 19:55:27 +00001811 let Uses = [CL] in {
Evan Cheng64d80e32007-07-19 01:14:50 +00001812 def SHR8mCL : I<0xD2, MRM5m, (outs), (ins i8mem :$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001813 "shr{b}\t{%cl, $dst|$dst, %CL}",
Evan Cheng071a2792007-09-11 19:55:27 +00001814 [(store (srl (loadi8 addr:$dst), CL), addr:$dst)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00001815 def SHR16mCL : I<0xD3, MRM5m, (outs), (ins i16mem:$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001816 "shr{w}\t{%cl, $dst|$dst, %CL}",
Evan Cheng85dd8892005-12-13 07:24:22 +00001817 [(store (srl (loadi16 addr:$dst), CL), addr:$dst)]>,
Evan Cheng071a2792007-09-11 19:55:27 +00001818 OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00001819 def SHR32mCL : I<0xD3, MRM5m, (outs), (ins i32mem:$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001820 "shr{l}\t{%cl, $dst|$dst, %CL}",
Evan Cheng071a2792007-09-11 19:55:27 +00001821 [(store (srl (loadi32 addr:$dst), CL), addr:$dst)]>;
1822 }
Evan Cheng64d80e32007-07-19 01:14:50 +00001823 def SHR8mi : Ii8<0xC0, MRM5m, (outs), (ins i8mem :$dst, i8imm:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001824 "shr{b}\t{$src, $dst|$dst, $src}",
Evan Cheng85dd8892005-12-13 07:24:22 +00001825 [(store (srl (loadi8 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00001826 def SHR16mi : Ii8<0xC1, MRM5m, (outs), (ins i16mem:$dst, i8imm:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001827 "shr{w}\t{$src, $dst|$dst, $src}",
Evan Cheng85dd8892005-12-13 07:24:22 +00001828 [(store (srl (loadi16 addr:$dst), (i8 imm:$src)), addr:$dst)]>,
1829 OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00001830 def SHR32mi : Ii8<0xC1, MRM5m, (outs), (ins i32mem:$dst, i8imm:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001831 "shr{l}\t{$src, $dst|$dst, $src}",
Evan Cheng85dd8892005-12-13 07:24:22 +00001832 [(store (srl (loadi32 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
Evan Cheng09c54572006-06-29 00:36:51 +00001833
1834 // Shift by 1
Evan Cheng64d80e32007-07-19 01:14:50 +00001835 def SHR8m1 : I<0xD0, MRM5m, (outs), (ins i8mem :$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001836 "shr{b}\t$dst",
Evan Cheng09c54572006-06-29 00:36:51 +00001837 [(store (srl (loadi8 addr:$dst), (i8 1)), addr:$dst)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00001838 def SHR16m1 : I<0xD1, MRM5m, (outs), (ins i16mem:$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001839 "shr{w}\t$dst",
Evan Cheng09c54572006-06-29 00:36:51 +00001840 [(store (srl (loadi16 addr:$dst), (i8 1)), addr:$dst)]>,OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00001841 def SHR32m1 : I<0xD1, MRM5m, (outs), (ins i32mem:$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001842 "shr{l}\t$dst",
Evan Cheng09c54572006-06-29 00:36:51 +00001843 [(store (srl (loadi32 addr:$dst), (i8 1)), addr:$dst)]>;
Chris Lattner57a02302004-08-11 04:31:00 +00001844}
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00001845
Evan Cheng071a2792007-09-11 19:55:27 +00001846let Uses = [CL] in {
Evan Cheng64d80e32007-07-19 01:14:50 +00001847def SAR8rCL : I<0xD2, MRM7r, (outs GR8 :$dst), (ins GR8 :$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001848 "sar{b}\t{%cl, $dst|$dst, %CL}",
Evan Cheng071a2792007-09-11 19:55:27 +00001849 [(set GR8:$dst, (sra GR8:$src, CL))]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00001850def SAR16rCL : I<0xD3, MRM7r, (outs GR16:$dst), (ins GR16:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001851 "sar{w}\t{%cl, $dst|$dst, %CL}",
Evan Cheng071a2792007-09-11 19:55:27 +00001852 [(set GR16:$dst, (sra GR16:$src, CL))]>, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00001853def SAR32rCL : I<0xD3, MRM7r, (outs GR32:$dst), (ins GR32:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001854 "sar{l}\t{%cl, $dst|$dst, %CL}",
Evan Cheng071a2792007-09-11 19:55:27 +00001855 [(set GR32:$dst, (sra GR32:$src, CL))]>;
1856}
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00001857
Evan Cheng64d80e32007-07-19 01:14:50 +00001858def SAR8ri : Ii8<0xC0, MRM7r, (outs GR8 :$dst), (ins GR8 :$src1, i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001859 "sar{b}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001860 [(set GR8:$dst, (sra GR8:$src1, (i8 imm:$src2)))]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00001861def SAR16ri : Ii8<0xC1, MRM7r, (outs GR16:$dst), (ins GR16:$src1, i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001862 "sar{w}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001863 [(set GR16:$dst, (sra GR16:$src1, (i8 imm:$src2)))]>,
Chris Lattner3d36a9f2005-12-05 02:40:25 +00001864 OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00001865def SAR32ri : Ii8<0xC1, MRM7r, (outs GR32:$dst), (ins GR32:$src1, i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001866 "sar{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001867 [(set GR32:$dst, (sra GR32:$src1, (i8 imm:$src2)))]>;
Evan Cheng09c54572006-06-29 00:36:51 +00001868
1869// Shift by 1
Evan Cheng64d80e32007-07-19 01:14:50 +00001870def SAR8r1 : I<0xD0, MRM7r, (outs GR8 :$dst), (ins GR8 :$src1),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001871 "sar{b}\t$dst",
Evan Cheng09c54572006-06-29 00:36:51 +00001872 [(set GR8:$dst, (sra GR8:$src1, (i8 1)))]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00001873def SAR16r1 : I<0xD1, MRM7r, (outs GR16:$dst), (ins GR16:$src1),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001874 "sar{w}\t$dst",
Evan Cheng09c54572006-06-29 00:36:51 +00001875 [(set GR16:$dst, (sra GR16:$src1, (i8 1)))]>, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00001876def SAR32r1 : I<0xD1, MRM7r, (outs GR32:$dst), (ins GR32:$src1),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001877 "sar{l}\t$dst",
Evan Cheng09c54572006-06-29 00:36:51 +00001878 [(set GR32:$dst, (sra GR32:$src1, (i8 1)))]>;
1879
Chris Lattnerf29ed092004-08-11 05:07:25 +00001880let isTwoAddress = 0 in {
Evan Cheng071a2792007-09-11 19:55:27 +00001881 let Uses = [CL] in {
Evan Cheng64d80e32007-07-19 01:14:50 +00001882 def SAR8mCL : I<0xD2, MRM7m, (outs), (ins i8mem :$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001883 "sar{b}\t{%cl, $dst|$dst, %CL}",
Evan Cheng071a2792007-09-11 19:55:27 +00001884 [(store (sra (loadi8 addr:$dst), CL), addr:$dst)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00001885 def SAR16mCL : I<0xD3, MRM7m, (outs), (ins i16mem:$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001886 "sar{w}\t{%cl, $dst|$dst, %CL}",
Evan Cheng071a2792007-09-11 19:55:27 +00001887 [(store (sra (loadi16 addr:$dst), CL), addr:$dst)]>, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00001888 def SAR32mCL : I<0xD3, MRM7m, (outs), (ins i32mem:$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001889 "sar{l}\t{%cl, $dst|$dst, %CL}",
Evan Cheng071a2792007-09-11 19:55:27 +00001890 [(store (sra (loadi32 addr:$dst), CL), addr:$dst)]>;
1891 }
Evan Cheng64d80e32007-07-19 01:14:50 +00001892 def SAR8mi : Ii8<0xC0, MRM7m, (outs), (ins i8mem :$dst, i8imm:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001893 "sar{b}\t{$src, $dst|$dst, $src}",
Evan Cheng85dd8892005-12-13 07:24:22 +00001894 [(store (sra (loadi8 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00001895 def SAR16mi : Ii8<0xC1, MRM7m, (outs), (ins i16mem:$dst, i8imm:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001896 "sar{w}\t{$src, $dst|$dst, $src}",
Evan Cheng85dd8892005-12-13 07:24:22 +00001897 [(store (sra (loadi16 addr:$dst), (i8 imm:$src)), addr:$dst)]>,
1898 OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00001899 def SAR32mi : Ii8<0xC1, MRM7m, (outs), (ins i32mem:$dst, i8imm:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001900 "sar{l}\t{$src, $dst|$dst, $src}",
Evan Cheng85dd8892005-12-13 07:24:22 +00001901 [(store (sra (loadi32 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
Evan Cheng09c54572006-06-29 00:36:51 +00001902
1903 // Shift by 1
Evan Cheng64d80e32007-07-19 01:14:50 +00001904 def SAR8m1 : I<0xD0, MRM7m, (outs), (ins i8mem :$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001905 "sar{b}\t$dst",
Evan Cheng09c54572006-06-29 00:36:51 +00001906 [(store (sra (loadi8 addr:$dst), (i8 1)), addr:$dst)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00001907 def SAR16m1 : I<0xD1, MRM7m, (outs), (ins i16mem:$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001908 "sar{w}\t$dst",
Evan Cheng09c54572006-06-29 00:36:51 +00001909 [(store (sra (loadi16 addr:$dst), (i8 1)), addr:$dst)]>,
1910 OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00001911 def SAR32m1 : I<0xD1, MRM7m, (outs), (ins i32mem:$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001912 "sar{l}\t$dst",
Evan Cheng09c54572006-06-29 00:36:51 +00001913 [(store (sra (loadi32 addr:$dst), (i8 1)), addr:$dst)]>;
Chris Lattnerf29ed092004-08-11 05:07:25 +00001914}
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00001915
Chris Lattner40ff6332005-01-19 07:50:03 +00001916// Rotate instructions
1917// FIXME: provide shorter instructions when imm8 == 1
Evan Cheng071a2792007-09-11 19:55:27 +00001918let Uses = [CL] in {
Evan Cheng64d80e32007-07-19 01:14:50 +00001919def ROL8rCL : I<0xD2, MRM0r, (outs GR8 :$dst), (ins GR8 :$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001920 "rol{b}\t{%cl, $dst|$dst, %CL}",
Evan Cheng071a2792007-09-11 19:55:27 +00001921 [(set GR8:$dst, (rotl GR8:$src, CL))]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00001922def ROL16rCL : I<0xD3, MRM0r, (outs GR16:$dst), (ins GR16:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001923 "rol{w}\t{%cl, $dst|$dst, %CL}",
Evan Cheng071a2792007-09-11 19:55:27 +00001924 [(set GR16:$dst, (rotl GR16:$src, CL))]>, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00001925def ROL32rCL : I<0xD3, MRM0r, (outs GR32:$dst), (ins GR32:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001926 "rol{l}\t{%cl, $dst|$dst, %CL}",
Evan Cheng071a2792007-09-11 19:55:27 +00001927 [(set GR32:$dst, (rotl GR32:$src, CL))]>;
1928}
Chris Lattner40ff6332005-01-19 07:50:03 +00001929
Evan Cheng64d80e32007-07-19 01:14:50 +00001930def ROL8ri : Ii8<0xC0, MRM0r, (outs GR8 :$dst), (ins GR8 :$src1, i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001931 "rol{b}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001932 [(set GR8:$dst, (rotl GR8:$src1, (i8 imm:$src2)))]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00001933def ROL16ri : Ii8<0xC1, MRM0r, (outs GR16:$dst), (ins GR16:$src1, i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001934 "rol{w}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001935 [(set GR16:$dst, (rotl GR16:$src1, (i8 imm:$src2)))]>, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00001936def ROL32ri : Ii8<0xC1, MRM0r, (outs GR32:$dst), (ins GR32:$src1, i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001937 "rol{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001938 [(set GR32:$dst, (rotl GR32:$src1, (i8 imm:$src2)))]>;
Chris Lattner40ff6332005-01-19 07:50:03 +00001939
Evan Cheng09c54572006-06-29 00:36:51 +00001940// Rotate by 1
Evan Cheng64d80e32007-07-19 01:14:50 +00001941def ROL8r1 : I<0xD0, MRM0r, (outs GR8 :$dst), (ins GR8 :$src1),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001942 "rol{b}\t$dst",
Evan Cheng09c54572006-06-29 00:36:51 +00001943 [(set GR8:$dst, (rotl GR8:$src1, (i8 1)))]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00001944def ROL16r1 : I<0xD1, MRM0r, (outs GR16:$dst), (ins GR16:$src1),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001945 "rol{w}\t$dst",
Evan Cheng09c54572006-06-29 00:36:51 +00001946 [(set GR16:$dst, (rotl GR16:$src1, (i8 1)))]>, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00001947def ROL32r1 : I<0xD1, MRM0r, (outs GR32:$dst), (ins GR32:$src1),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001948 "rol{l}\t$dst",
Evan Cheng09c54572006-06-29 00:36:51 +00001949 [(set GR32:$dst, (rotl GR32:$src1, (i8 1)))]>;
1950
Chris Lattner40ff6332005-01-19 07:50:03 +00001951let isTwoAddress = 0 in {
Evan Cheng071a2792007-09-11 19:55:27 +00001952 let Uses = [CL] in {
Evan Cheng64d80e32007-07-19 01:14:50 +00001953 def ROL8mCL : I<0xD2, MRM0m, (outs), (ins i8mem :$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001954 "rol{b}\t{%cl, $dst|$dst, %CL}",
Evan Cheng071a2792007-09-11 19:55:27 +00001955 [(store (rotl (loadi8 addr:$dst), CL), addr:$dst)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00001956 def ROL16mCL : I<0xD3, MRM0m, (outs), (ins i16mem:$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001957 "rol{w}\t{%cl, $dst|$dst, %CL}",
Evan Cheng071a2792007-09-11 19:55:27 +00001958 [(store (rotl (loadi16 addr:$dst), CL), addr:$dst)]>, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00001959 def ROL32mCL : I<0xD3, MRM0m, (outs), (ins i32mem:$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001960 "rol{l}\t{%cl, $dst|$dst, %CL}",
Evan Cheng071a2792007-09-11 19:55:27 +00001961 [(store (rotl (loadi32 addr:$dst), CL), addr:$dst)]>;
1962 }
Evan Cheng64d80e32007-07-19 01:14:50 +00001963 def ROL8mi : Ii8<0xC0, MRM0m, (outs), (ins i8mem :$dst, i8imm:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001964 "rol{b}\t{$src, $dst|$dst, $src}",
Evan Chengeb422a72006-01-11 23:20:05 +00001965 [(store (rotl (loadi8 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00001966 def ROL16mi : Ii8<0xC1, MRM0m, (outs), (ins i16mem:$dst, i8imm:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001967 "rol{w}\t{$src, $dst|$dst, $src}",
Evan Chengeb422a72006-01-11 23:20:05 +00001968 [(store (rotl (loadi16 addr:$dst), (i8 imm:$src)), addr:$dst)]>,
1969 OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00001970 def ROL32mi : Ii8<0xC1, MRM0m, (outs), (ins i32mem:$dst, i8imm:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001971 "rol{l}\t{$src, $dst|$dst, $src}",
Evan Chengeb422a72006-01-11 23:20:05 +00001972 [(store (rotl (loadi32 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
Evan Cheng09c54572006-06-29 00:36:51 +00001973
1974 // Rotate by 1
Evan Cheng64d80e32007-07-19 01:14:50 +00001975 def ROL8m1 : I<0xD0, MRM0m, (outs), (ins i8mem :$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001976 "rol{b}\t$dst",
Evan Cheng09c54572006-06-29 00:36:51 +00001977 [(store (rotl (loadi8 addr:$dst), (i8 1)), addr:$dst)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00001978 def ROL16m1 : I<0xD1, MRM0m, (outs), (ins i16mem:$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001979 "rol{w}\t$dst",
Evan Cheng09c54572006-06-29 00:36:51 +00001980 [(store (rotl (loadi16 addr:$dst), (i8 1)), addr:$dst)]>,
1981 OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00001982 def ROL32m1 : I<0xD1, MRM0m, (outs), (ins i32mem:$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001983 "rol{l}\t$dst",
Evan Cheng09c54572006-06-29 00:36:51 +00001984 [(store (rotl (loadi32 addr:$dst), (i8 1)), addr:$dst)]>;
Chris Lattner40ff6332005-01-19 07:50:03 +00001985}
1986
Evan Cheng071a2792007-09-11 19:55:27 +00001987let Uses = [CL] in {
Evan Cheng64d80e32007-07-19 01:14:50 +00001988def ROR8rCL : I<0xD2, MRM1r, (outs GR8 :$dst), (ins GR8 :$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001989 "ror{b}\t{%cl, $dst|$dst, %CL}",
Evan Cheng071a2792007-09-11 19:55:27 +00001990 [(set GR8:$dst, (rotr GR8:$src, CL))]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00001991def ROR16rCL : I<0xD3, MRM1r, (outs GR16:$dst), (ins GR16:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001992 "ror{w}\t{%cl, $dst|$dst, %CL}",
Evan Cheng071a2792007-09-11 19:55:27 +00001993 [(set GR16:$dst, (rotr GR16:$src, CL))]>, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00001994def ROR32rCL : I<0xD3, MRM1r, (outs GR32:$dst), (ins GR32:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001995 "ror{l}\t{%cl, $dst|$dst, %CL}",
Evan Cheng071a2792007-09-11 19:55:27 +00001996 [(set GR32:$dst, (rotr GR32:$src, CL))]>;
1997}
Chris Lattner40ff6332005-01-19 07:50:03 +00001998
Evan Cheng64d80e32007-07-19 01:14:50 +00001999def ROR8ri : Ii8<0xC0, MRM1r, (outs GR8 :$dst), (ins GR8 :$src1, i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002000 "ror{b}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00002001 [(set GR8:$dst, (rotr GR8:$src1, (i8 imm:$src2)))]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00002002def ROR16ri : Ii8<0xC1, MRM1r, (outs GR16:$dst), (ins GR16:$src1, i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002003 "ror{w}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00002004 [(set GR16:$dst, (rotr GR16:$src1, (i8 imm:$src2)))]>, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00002005def ROR32ri : Ii8<0xC1, MRM1r, (outs GR32:$dst), (ins GR32:$src1, i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002006 "ror{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00002007 [(set GR32:$dst, (rotr GR32:$src1, (i8 imm:$src2)))]>;
Evan Cheng09c54572006-06-29 00:36:51 +00002008
2009// Rotate by 1
Evan Cheng64d80e32007-07-19 01:14:50 +00002010def ROR8r1 : I<0xD0, MRM1r, (outs GR8 :$dst), (ins GR8 :$src1),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002011 "ror{b}\t$dst",
Evan Cheng09c54572006-06-29 00:36:51 +00002012 [(set GR8:$dst, (rotr GR8:$src1, (i8 1)))]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00002013def ROR16r1 : I<0xD1, MRM1r, (outs GR16:$dst), (ins GR16:$src1),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002014 "ror{w}\t$dst",
Evan Cheng09c54572006-06-29 00:36:51 +00002015 [(set GR16:$dst, (rotr GR16:$src1, (i8 1)))]>, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00002016def ROR32r1 : I<0xD1, MRM1r, (outs GR32:$dst), (ins GR32:$src1),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002017 "ror{l}\t$dst",
Evan Cheng09c54572006-06-29 00:36:51 +00002018 [(set GR32:$dst, (rotr GR32:$src1, (i8 1)))]>;
2019
Chris Lattner40ff6332005-01-19 07:50:03 +00002020let isTwoAddress = 0 in {
Evan Cheng071a2792007-09-11 19:55:27 +00002021 let Uses = [CL] in {
Evan Cheng64d80e32007-07-19 01:14:50 +00002022 def ROR8mCL : I<0xD2, MRM1m, (outs), (ins i8mem :$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002023 "ror{b}\t{%cl, $dst|$dst, %CL}",
Evan Cheng071a2792007-09-11 19:55:27 +00002024 [(store (rotr (loadi8 addr:$dst), CL), addr:$dst)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00002025 def ROR16mCL : I<0xD3, MRM1m, (outs), (ins i16mem:$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002026 "ror{w}\t{%cl, $dst|$dst, %CL}",
Evan Cheng071a2792007-09-11 19:55:27 +00002027 [(store (rotr (loadi16 addr:$dst), CL), addr:$dst)]>, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00002028 def ROR32mCL : I<0xD3, MRM1m, (outs), (ins i32mem:$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002029 "ror{l}\t{%cl, $dst|$dst, %CL}",
Evan Cheng071a2792007-09-11 19:55:27 +00002030 [(store (rotr (loadi32 addr:$dst), CL), addr:$dst)]>;
2031 }
Evan Cheng64d80e32007-07-19 01:14:50 +00002032 def ROR8mi : Ii8<0xC0, MRM1m, (outs), (ins i8mem :$dst, i8imm:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002033 "ror{b}\t{$src, $dst|$dst, $src}",
Evan Chengeb422a72006-01-11 23:20:05 +00002034 [(store (rotr (loadi8 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00002035 def ROR16mi : Ii8<0xC1, MRM1m, (outs), (ins i16mem:$dst, i8imm:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002036 "ror{w}\t{$src, $dst|$dst, $src}",
Evan Chengeb422a72006-01-11 23:20:05 +00002037 [(store (rotr (loadi16 addr:$dst), (i8 imm:$src)), addr:$dst)]>,
2038 OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00002039 def ROR32mi : Ii8<0xC1, MRM1m, (outs), (ins i32mem:$dst, i8imm:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002040 "ror{l}\t{$src, $dst|$dst, $src}",
Evan Chengeb422a72006-01-11 23:20:05 +00002041 [(store (rotr (loadi32 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
Evan Cheng09c54572006-06-29 00:36:51 +00002042
2043 // Rotate by 1
Evan Cheng64d80e32007-07-19 01:14:50 +00002044 def ROR8m1 : I<0xD0, MRM1m, (outs), (ins i8mem :$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002045 "ror{b}\t$dst",
Evan Cheng09c54572006-06-29 00:36:51 +00002046 [(store (rotr (loadi8 addr:$dst), (i8 1)), addr:$dst)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00002047 def ROR16m1 : I<0xD1, MRM1m, (outs), (ins i16mem:$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002048 "ror{w}\t$dst",
Evan Cheng09c54572006-06-29 00:36:51 +00002049 [(store (rotr (loadi16 addr:$dst), (i8 1)), addr:$dst)]>,
2050 OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00002051 def ROR32m1 : I<0xD1, MRM1m, (outs), (ins i32mem:$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002052 "ror{l}\t$dst",
Evan Cheng09c54572006-06-29 00:36:51 +00002053 [(store (rotr (loadi32 addr:$dst), (i8 1)), addr:$dst)]>;
Chris Lattner40ff6332005-01-19 07:50:03 +00002054}
2055
2056
2057
2058// Double shift instructions (generalizations of rotate)
Evan Cheng071a2792007-09-11 19:55:27 +00002059let Uses = [CL] in {
Evan Cheng64d80e32007-07-19 01:14:50 +00002060def SHLD32rrCL : I<0xA5, MRMDestReg, (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002061 "shld{l}\t{%cl, $src2, $dst|$dst, $src2, %CL}",
Evan Cheng071a2792007-09-11 19:55:27 +00002062 [(set GR32:$dst, (X86shld GR32:$src1, GR32:$src2, CL))]>, TB;
Evan Cheng64d80e32007-07-19 01:14:50 +00002063def SHRD32rrCL : I<0xAD, MRMDestReg, (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002064 "shrd{l}\t{%cl, $src2, $dst|$dst, $src2, %CL}",
Evan Cheng071a2792007-09-11 19:55:27 +00002065 [(set GR32:$dst, (X86shrd GR32:$src1, GR32:$src2, CL))]>, TB;
Evan Cheng64d80e32007-07-19 01:14:50 +00002066def SHLD16rrCL : I<0xA5, MRMDestReg, (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002067 "shld{w}\t{%cl, $src2, $dst|$dst, $src2, %CL}",
Evan Cheng069287d2006-05-16 07:21:53 +00002068 [(set GR16:$dst, (X86shld GR16:$src1, GR16:$src2, CL))]>,
Evan Cheng071a2792007-09-11 19:55:27 +00002069 TB, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00002070def SHRD16rrCL : I<0xAD, MRMDestReg, (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002071 "shrd{w}\t{%cl, $src2, $dst|$dst, $src2, %CL}",
Evan Cheng069287d2006-05-16 07:21:53 +00002072 [(set GR16:$dst, (X86shrd GR16:$src1, GR16:$src2, CL))]>,
Evan Cheng071a2792007-09-11 19:55:27 +00002073 TB, OpSize;
2074}
Chris Lattner41e431b2005-01-19 07:11:01 +00002075
2076let isCommutable = 1 in { // These instructions commute to each other.
Chris Lattner3a173df2004-10-03 20:35:00 +00002077def SHLD32rri8 : Ii8<0xA4, MRMDestReg,
Evan Cheng64d80e32007-07-19 01:14:50 +00002078 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2, i8imm:$src3),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002079 "shld{l}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Evan Cheng069287d2006-05-16 07:21:53 +00002080 [(set GR32:$dst, (X86shld GR32:$src1, GR32:$src2,
Evan Chenge3413162006-01-09 18:33:28 +00002081 (i8 imm:$src3)))]>,
2082 TB;
Chris Lattner3a173df2004-10-03 20:35:00 +00002083def SHRD32rri8 : Ii8<0xAC, MRMDestReg,
Evan Cheng64d80e32007-07-19 01:14:50 +00002084 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2, i8imm:$src3),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002085 "shrd{l}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Evan Cheng069287d2006-05-16 07:21:53 +00002086 [(set GR32:$dst, (X86shrd GR32:$src1, GR32:$src2,
Evan Chenge3413162006-01-09 18:33:28 +00002087 (i8 imm:$src3)))]>,
2088 TB;
Chris Lattner0df53d22005-01-19 07:31:24 +00002089def SHLD16rri8 : Ii8<0xA4, MRMDestReg,
Evan Cheng64d80e32007-07-19 01:14:50 +00002090 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2, i8imm:$src3),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002091 "shld{w}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Evan Cheng069287d2006-05-16 07:21:53 +00002092 [(set GR16:$dst, (X86shld GR16:$src1, GR16:$src2,
Evan Chenge3413162006-01-09 18:33:28 +00002093 (i8 imm:$src3)))]>,
Chris Lattner0df53d22005-01-19 07:31:24 +00002094 TB, OpSize;
2095def SHRD16rri8 : Ii8<0xAC, MRMDestReg,
Evan Cheng64d80e32007-07-19 01:14:50 +00002096 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2, i8imm:$src3),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002097 "shrd{w}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Evan Cheng069287d2006-05-16 07:21:53 +00002098 [(set GR16:$dst, (X86shrd GR16:$src1, GR16:$src2,
Evan Chenge3413162006-01-09 18:33:28 +00002099 (i8 imm:$src3)))]>,
Chris Lattner0df53d22005-01-19 07:31:24 +00002100 TB, OpSize;
Chris Lattner41e431b2005-01-19 07:11:01 +00002101}
Chris Lattner0e967d42004-08-01 08:13:11 +00002102
Chris Lattner57a02302004-08-11 04:31:00 +00002103let isTwoAddress = 0 in {
Evan Cheng071a2792007-09-11 19:55:27 +00002104 let Uses = [CL] in {
Evan Cheng64d80e32007-07-19 01:14:50 +00002105 def SHLD32mrCL : I<0xA5, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002106 "shld{l}\t{%cl, $src2, $dst|$dst, $src2, %CL}",
Evan Cheng069287d2006-05-16 07:21:53 +00002107 [(store (X86shld (loadi32 addr:$dst), GR32:$src2, CL),
Evan Cheng071a2792007-09-11 19:55:27 +00002108 addr:$dst)]>, TB;
Evan Cheng64d80e32007-07-19 01:14:50 +00002109 def SHRD32mrCL : I<0xAD, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002110 "shrd{l}\t{%cl, $src2, $dst|$dst, $src2, %CL}",
Evan Cheng069287d2006-05-16 07:21:53 +00002111 [(store (X86shrd (loadi32 addr:$dst), GR32:$src2, CL),
Evan Cheng071a2792007-09-11 19:55:27 +00002112 addr:$dst)]>, TB;
2113 }
Chris Lattner3a173df2004-10-03 20:35:00 +00002114 def SHLD32mri8 : Ii8<0xA4, MRMDestMem,
Evan Cheng64d80e32007-07-19 01:14:50 +00002115 (outs), (ins i32mem:$dst, GR32:$src2, i8imm:$src3),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002116 "shld{l}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Evan Cheng069287d2006-05-16 07:21:53 +00002117 [(store (X86shld (loadi32 addr:$dst), GR32:$src2,
Evan Chenge3413162006-01-09 18:33:28 +00002118 (i8 imm:$src3)), addr:$dst)]>,
Chris Lattnerf124d5e2005-11-18 01:04:42 +00002119 TB;
Chris Lattner3a173df2004-10-03 20:35:00 +00002120 def SHRD32mri8 : Ii8<0xAC, MRMDestMem,
Evan Cheng64d80e32007-07-19 01:14:50 +00002121 (outs), (ins i32mem:$dst, GR32:$src2, i8imm:$src3),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002122 "shrd{l}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Evan Cheng069287d2006-05-16 07:21:53 +00002123 [(store (X86shrd (loadi32 addr:$dst), GR32:$src2,
Evan Chenge3413162006-01-09 18:33:28 +00002124 (i8 imm:$src3)), addr:$dst)]>,
Chris Lattnerf124d5e2005-11-18 01:04:42 +00002125 TB;
Chris Lattner0df53d22005-01-19 07:31:24 +00002126
Evan Cheng071a2792007-09-11 19:55:27 +00002127 let Uses = [CL] in {
Evan Cheng64d80e32007-07-19 01:14:50 +00002128 def SHLD16mrCL : I<0xA5, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002129 "shld{w}\t{%cl, $src2, $dst|$dst, $src2, %CL}",
Evan Cheng069287d2006-05-16 07:21:53 +00002130 [(store (X86shld (loadi16 addr:$dst), GR16:$src2, CL),
Evan Cheng071a2792007-09-11 19:55:27 +00002131 addr:$dst)]>, TB, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00002132 def SHRD16mrCL : I<0xAD, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002133 "shrd{w}\t{%cl, $src2, $dst|$dst, $src2, %CL}",
Evan Cheng069287d2006-05-16 07:21:53 +00002134 [(store (X86shrd (loadi16 addr:$dst), GR16:$src2, CL),
Evan Cheng071a2792007-09-11 19:55:27 +00002135 addr:$dst)]>, TB, OpSize;
2136 }
Chris Lattner0df53d22005-01-19 07:31:24 +00002137 def SHLD16mri8 : Ii8<0xA4, MRMDestMem,
Evan Cheng64d80e32007-07-19 01:14:50 +00002138 (outs), (ins i16mem:$dst, GR16:$src2, i8imm:$src3),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002139 "shld{w}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Evan Cheng069287d2006-05-16 07:21:53 +00002140 [(store (X86shld (loadi16 addr:$dst), GR16:$src2,
Evan Chenge3413162006-01-09 18:33:28 +00002141 (i8 imm:$src3)), addr:$dst)]>,
Chris Lattner0df53d22005-01-19 07:31:24 +00002142 TB, OpSize;
2143 def SHRD16mri8 : Ii8<0xAC, MRMDestMem,
Evan Cheng64d80e32007-07-19 01:14:50 +00002144 (outs), (ins i16mem:$dst, GR16:$src2, i8imm:$src3),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002145 "shrd{w}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Evan Cheng069287d2006-05-16 07:21:53 +00002146 [(store (X86shrd (loadi16 addr:$dst), GR16:$src2,
Evan Chenge3413162006-01-09 18:33:28 +00002147 (i8 imm:$src3)), addr:$dst)]>,
Chris Lattner0df53d22005-01-19 07:31:24 +00002148 TB, OpSize;
Chris Lattner57a02302004-08-11 04:31:00 +00002149}
Evan Cheng24f2ea32007-09-14 21:48:26 +00002150} // Defs = [EFLAGS]
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00002151
2152
Chris Lattnercc65bee2005-01-02 02:35:46 +00002153// Arithmetic.
Evan Cheng24f2ea32007-09-14 21:48:26 +00002154let Defs = [EFLAGS] in {
Chris Lattnercc65bee2005-01-02 02:35:46 +00002155let isCommutable = 1 in { // X = ADD Y, Z --> X = ADD Z, Y
Bill Wendlingab55ebd2008-12-12 00:56:36 +00002156// Register-Register Addition
2157def ADD8rr : I<0x00, MRMDestReg, (outs GR8 :$dst),
2158 (ins GR8 :$src1, GR8 :$src2),
2159 "add{b}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingd350e022008-12-12 21:15:41 +00002160 [(set GR8:$dst, (add GR8:$src1, GR8:$src2)),
Bill Wendlingab55ebd2008-12-12 00:56:36 +00002161 (implicit EFLAGS)]>;
2162
Chris Lattnercc65bee2005-01-02 02:35:46 +00002163let isConvertibleToThreeAddress = 1 in { // Can transform into LEA.
Bill Wendlingab55ebd2008-12-12 00:56:36 +00002164// Register-Register Addition
Evan Cheng071a2792007-09-11 19:55:27 +00002165def ADD16rr : I<0x01, MRMDestReg, (outs GR16:$dst),
2166 (ins GR16:$src1, GR16:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002167 "add{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingd350e022008-12-12 21:15:41 +00002168 [(set GR16:$dst, (add GR16:$src1, GR16:$src2)),
2169 (implicit EFLAGS)]>, OpSize;
Evan Cheng071a2792007-09-11 19:55:27 +00002170def ADD32rr : I<0x01, MRMDestReg, (outs GR32:$dst),
2171 (ins GR32:$src1, GR32:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002172 "add{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingd350e022008-12-12 21:15:41 +00002173 [(set GR32:$dst, (add GR32:$src1, GR32:$src2)),
2174 (implicit EFLAGS)]>;
Chris Lattnercc65bee2005-01-02 02:35:46 +00002175} // end isConvertibleToThreeAddress
2176} // end isCommutable
Bill Wendlingab55ebd2008-12-12 00:56:36 +00002177
2178// Register-Memory Addition
Evan Cheng071a2792007-09-11 19:55:27 +00002179def ADD8rm : I<0x02, MRMSrcMem, (outs GR8 :$dst),
2180 (ins GR8 :$src1, i8mem :$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002181 "add{b}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingd350e022008-12-12 21:15:41 +00002182 [(set GR8:$dst, (add GR8:$src1, (load addr:$src2))),
2183 (implicit EFLAGS)]>;
Evan Cheng071a2792007-09-11 19:55:27 +00002184def ADD16rm : I<0x03, MRMSrcMem, (outs GR16:$dst),
2185 (ins GR16:$src1, i16mem:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002186 "add{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingd350e022008-12-12 21:15:41 +00002187 [(set GR16:$dst, (add GR16:$src1, (load addr:$src2))),
2188 (implicit EFLAGS)]>, OpSize;
Evan Cheng071a2792007-09-11 19:55:27 +00002189def ADD32rm : I<0x03, MRMSrcMem, (outs GR32:$dst),
2190 (ins GR32:$src1, i32mem:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002191 "add{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingd350e022008-12-12 21:15:41 +00002192 [(set GR32:$dst, (add GR32:$src1, (load addr:$src2))),
2193 (implicit EFLAGS)]>;
Chris Lattnercc65bee2005-01-02 02:35:46 +00002194
Bill Wendlingab55ebd2008-12-12 00:56:36 +00002195// Register-Integer Addition
2196def ADD8ri : Ii8<0x80, MRM0r, (outs GR8:$dst), (ins GR8:$src1, i8imm:$src2),
2197 "add{b}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingd350e022008-12-12 21:15:41 +00002198 [(set GR8:$dst, (add GR8:$src1, imm:$src2)),
2199 (implicit EFLAGS)]>;
Bill Wendlingab55ebd2008-12-12 00:56:36 +00002200
Chris Lattnercc65bee2005-01-02 02:35:46 +00002201let isConvertibleToThreeAddress = 1 in { // Can transform into LEA.
Bill Wendlingab55ebd2008-12-12 00:56:36 +00002202// Register-Integer Addition
Evan Cheng071a2792007-09-11 19:55:27 +00002203def ADD16ri : Ii16<0x81, MRM0r, (outs GR16:$dst),
2204 (ins GR16:$src1, i16imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002205 "add{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingd350e022008-12-12 21:15:41 +00002206 [(set GR16:$dst, (add GR16:$src1, imm:$src2)),
2207 (implicit EFLAGS)]>, OpSize;
Evan Cheng071a2792007-09-11 19:55:27 +00002208def ADD32ri : Ii32<0x81, MRM0r, (outs GR32:$dst),
2209 (ins GR32:$src1, i32imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002210 "add{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingd350e022008-12-12 21:15:41 +00002211 [(set GR32:$dst, (add GR32:$src1, imm:$src2)),
2212 (implicit EFLAGS)]>;
Evan Cheng071a2792007-09-11 19:55:27 +00002213def ADD16ri8 : Ii8<0x83, MRM0r, (outs GR16:$dst),
2214 (ins GR16:$src1, i16i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002215 "add{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingd350e022008-12-12 21:15:41 +00002216 [(set GR16:$dst, (add GR16:$src1, i16immSExt8:$src2)),
2217 (implicit EFLAGS)]>, OpSize;
Evan Cheng071a2792007-09-11 19:55:27 +00002218def ADD32ri8 : Ii8<0x83, MRM0r, (outs GR32:$dst),
2219 (ins GR32:$src1, i32i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002220 "add{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingd350e022008-12-12 21:15:41 +00002221 [(set GR32:$dst, (add GR32:$src1, i32immSExt8:$src2)),
2222 (implicit EFLAGS)]>;
Evan Cheng09e3c802006-05-19 18:40:54 +00002223}
Chris Lattner57a02302004-08-11 04:31:00 +00002224
2225let isTwoAddress = 0 in {
Bill Wendlingab55ebd2008-12-12 00:56:36 +00002226 // Memory-Register Addition
Bill Wendlingd350e022008-12-12 21:15:41 +00002227 def ADD8mr : I<0x00, MRMDestMem, (outs), (ins i8mem:$dst, GR8:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002228 "add{b}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingd350e022008-12-12 21:15:41 +00002229 [(store (add (load addr:$dst), GR8:$src2), addr:$dst),
2230 (implicit EFLAGS)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00002231 def ADD16mr : I<0x01, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002232 "add{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingd350e022008-12-12 21:15:41 +00002233 [(store (add (load addr:$dst), GR16:$src2), addr:$dst),
2234 (implicit EFLAGS)]>, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00002235 def ADD32mr : I<0x01, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002236 "add{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingd350e022008-12-12 21:15:41 +00002237 [(store (add (load addr:$dst), GR32:$src2), addr:$dst),
2238 (implicit EFLAGS)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00002239 def ADD8mi : Ii8<0x80, MRM0m, (outs), (ins i8mem :$dst, i8imm :$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002240 "add{b}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingd350e022008-12-12 21:15:41 +00002241 [(store (add (loadi8 addr:$dst), imm:$src2), addr:$dst),
2242 (implicit EFLAGS)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00002243 def ADD16mi : Ii16<0x81, MRM0m, (outs), (ins i16mem:$dst, i16imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002244 "add{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingd350e022008-12-12 21:15:41 +00002245 [(store (add (loadi16 addr:$dst), imm:$src2), addr:$dst),
2246 (implicit EFLAGS)]>, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00002247 def ADD32mi : Ii32<0x81, MRM0m, (outs), (ins i32mem:$dst, i32imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002248 "add{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingd350e022008-12-12 21:15:41 +00002249 [(store (add (loadi32 addr:$dst), imm:$src2), addr:$dst),
2250 (implicit EFLAGS)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00002251 def ADD16mi8 : Ii8<0x83, MRM0m, (outs), (ins i16mem:$dst, i16i8imm :$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002252 "add{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingd350e022008-12-12 21:15:41 +00002253 [(store (add (load addr:$dst), i16immSExt8:$src2),
2254 addr:$dst),
2255 (implicit EFLAGS)]>, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00002256 def ADD32mi8 : Ii8<0x83, MRM0m, (outs), (ins i32mem:$dst, i32i8imm :$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002257 "add{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingab55ebd2008-12-12 00:56:36 +00002258 [(store (add (load addr:$dst), i32immSExt8:$src2),
Bill Wendlingd350e022008-12-12 21:15:41 +00002259 addr:$dst),
2260 (implicit EFLAGS)]>;
Chris Lattner57a02302004-08-11 04:31:00 +00002261}
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00002262
Evan Cheng3154cb62007-10-05 17:59:57 +00002263let Uses = [EFLAGS] in {
Chris Lattner10197ff2005-01-03 01:27:59 +00002264let isCommutable = 1 in { // X = ADC Y, Z --> X = ADC Z, Y
Evan Cheng64d80e32007-07-19 01:14:50 +00002265def ADC32rr : I<0x11, MRMDestReg, (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002266 "adc{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlinge3b3c002008-12-01 23:44:08 +00002267 [(set GR32:$dst, (adde GR32:$src1, GR32:$src2))]>;
Chris Lattner10197ff2005-01-03 01:27:59 +00002268}
Evan Cheng64d80e32007-07-19 01:14:50 +00002269def ADC32rm : I<0x13, MRMSrcMem , (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002270 "adc{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlinge3b3c002008-12-01 23:44:08 +00002271 [(set GR32:$dst, (adde GR32:$src1, (load addr:$src2)))]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00002272def ADC32ri : Ii32<0x81, MRM2r, (outs GR32:$dst), (ins GR32:$src1, i32imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002273 "adc{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlinge3b3c002008-12-01 23:44:08 +00002274 [(set GR32:$dst, (adde GR32:$src1, imm:$src2))]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00002275def ADC32ri8 : Ii8<0x83, MRM2r, (outs GR32:$dst), (ins GR32:$src1, i32i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002276 "adc{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlinge3b3c002008-12-01 23:44:08 +00002277 [(set GR32:$dst, (adde GR32:$src1, i32immSExt8:$src2))]>;
Chris Lattner57a02302004-08-11 04:31:00 +00002278
2279let isTwoAddress = 0 in {
Evan Cheng64d80e32007-07-19 01:14:50 +00002280 def ADC32mr : I<0x11, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002281 "adc{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlinge3b3c002008-12-01 23:44:08 +00002282 [(store (adde (load addr:$dst), GR32:$src2), addr:$dst)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00002283 def ADC32mi : Ii32<0x81, MRM2m, (outs), (ins i32mem:$dst, i32imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002284 "adc{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlinge3b3c002008-12-01 23:44:08 +00002285 [(store (adde (loadi32 addr:$dst), imm:$src2), addr:$dst)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00002286 def ADC32mi8 : Ii8<0x83, MRM2m, (outs), (ins i32mem:$dst, i32i8imm :$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002287 "adc{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendling9f248742008-12-02 00:07:05 +00002288 [(store (adde (load addr:$dst), i32immSExt8:$src2), addr:$dst)]>;
Chris Lattner57a02302004-08-11 04:31:00 +00002289}
Evan Cheng3154cb62007-10-05 17:59:57 +00002290} // Uses = [EFLAGS]
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00002291
Bill Wendlingab55ebd2008-12-12 00:56:36 +00002292// Register-Register Subtraction
2293def SUB8rr : I<0x28, MRMDestReg, (outs GR8:$dst), (ins GR8:$src1, GR8:$src2),
2294 "sub{b}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingd350e022008-12-12 21:15:41 +00002295 [(set GR8:$dst, (sub GR8:$src1, GR8:$src2)),
2296 (implicit EFLAGS)]>;
Bill Wendlingab55ebd2008-12-12 00:56:36 +00002297def SUB16rr : I<0x29, MRMDestReg, (outs GR16:$dst), (ins GR16:$src1,GR16:$src2),
2298 "sub{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingd350e022008-12-12 21:15:41 +00002299 [(set GR16:$dst, (sub GR16:$src1, GR16:$src2)),
2300 (implicit EFLAGS)]>, OpSize;
Bill Wendlingab55ebd2008-12-12 00:56:36 +00002301def SUB32rr : I<0x29, MRMDestReg, (outs GR32:$dst), (ins GR32:$src1,GR32:$src2),
2302 "sub{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingd350e022008-12-12 21:15:41 +00002303 [(set GR32:$dst, (sub GR32:$src1, GR32:$src2)),
2304 (implicit EFLAGS)]>;
Bill Wendlingab55ebd2008-12-12 00:56:36 +00002305
2306// Register-Memory Subtraction
2307def SUB8rm : I<0x2A, MRMSrcMem, (outs GR8 :$dst),
2308 (ins GR8 :$src1, i8mem :$src2),
2309 "sub{b}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingd350e022008-12-12 21:15:41 +00002310 [(set GR8:$dst, (sub GR8:$src1, (load addr:$src2))),
2311 (implicit EFLAGS)]>;
Bill Wendlingab55ebd2008-12-12 00:56:36 +00002312def SUB16rm : I<0x2B, MRMSrcMem, (outs GR16:$dst),
2313 (ins GR16:$src1, i16mem:$src2),
2314 "sub{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingd350e022008-12-12 21:15:41 +00002315 [(set GR16:$dst, (sub GR16:$src1, (load addr:$src2))),
2316 (implicit EFLAGS)]>, OpSize;
Bill Wendlingab55ebd2008-12-12 00:56:36 +00002317def SUB32rm : I<0x2B, MRMSrcMem, (outs GR32:$dst),
2318 (ins GR32:$src1, i32mem:$src2),
2319 "sub{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingd350e022008-12-12 21:15:41 +00002320 [(set GR32:$dst, (sub GR32:$src1, (load addr:$src2))),
2321 (implicit EFLAGS)]>;
Bill Wendlingab55ebd2008-12-12 00:56:36 +00002322
2323// Register-Integer Subtraction
2324def SUB8ri : Ii8 <0x80, MRM5r, (outs GR8:$dst),
2325 (ins GR8:$src1, i8imm:$src2),
2326 "sub{b}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingd350e022008-12-12 21:15:41 +00002327 [(set GR8:$dst, (sub GR8:$src1, imm:$src2)),
2328 (implicit EFLAGS)]>;
Bill Wendlingab55ebd2008-12-12 00:56:36 +00002329def SUB16ri : Ii16<0x81, MRM5r, (outs GR16:$dst),
2330 (ins GR16:$src1, i16imm:$src2),
2331 "sub{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingd350e022008-12-12 21:15:41 +00002332 [(set GR16:$dst, (sub GR16:$src1, imm:$src2)),
2333 (implicit EFLAGS)]>, OpSize;
Bill Wendlingab55ebd2008-12-12 00:56:36 +00002334def SUB32ri : Ii32<0x81, MRM5r, (outs GR32:$dst),
2335 (ins GR32:$src1, i32imm:$src2),
2336 "sub{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingd350e022008-12-12 21:15:41 +00002337 [(set GR32:$dst, (sub GR32:$src1, imm:$src2)),
2338 (implicit EFLAGS)]>;
Bill Wendlingab55ebd2008-12-12 00:56:36 +00002339def SUB16ri8 : Ii8<0x83, MRM5r, (outs GR16:$dst),
2340 (ins GR16:$src1, i16i8imm:$src2),
2341 "sub{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingd350e022008-12-12 21:15:41 +00002342 [(set GR16:$dst, (sub GR16:$src1, i16immSExt8:$src2)),
2343 (implicit EFLAGS)]>, OpSize;
Bill Wendlingab55ebd2008-12-12 00:56:36 +00002344def SUB32ri8 : Ii8<0x83, MRM5r, (outs GR32:$dst),
2345 (ins GR32:$src1, i32i8imm:$src2),
2346 "sub{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingd350e022008-12-12 21:15:41 +00002347 [(set GR32:$dst, (sub GR32:$src1, i32immSExt8:$src2)),
2348 (implicit EFLAGS)]>;
Bill Wendlingab55ebd2008-12-12 00:56:36 +00002349
Chris Lattner57a02302004-08-11 04:31:00 +00002350let isTwoAddress = 0 in {
Bill Wendlingab55ebd2008-12-12 00:56:36 +00002351 // Memory-Register Subtraction
Evan Cheng64d80e32007-07-19 01:14:50 +00002352 def SUB8mr : I<0x28, MRMDestMem, (outs), (ins i8mem :$dst, GR8 :$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002353 "sub{b}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingd350e022008-12-12 21:15:41 +00002354 [(store (sub (load addr:$dst), GR8:$src2), addr:$dst),
2355 (implicit EFLAGS)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00002356 def SUB16mr : I<0x29, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002357 "sub{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingd350e022008-12-12 21:15:41 +00002358 [(store (sub (load addr:$dst), GR16:$src2), addr:$dst),
2359 (implicit EFLAGS)]>, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00002360 def SUB32mr : I<0x29, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002361 "sub{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingd350e022008-12-12 21:15:41 +00002362 [(store (sub (load addr:$dst), GR32:$src2), addr:$dst),
2363 (implicit EFLAGS)]>;
Bill Wendlingab55ebd2008-12-12 00:56:36 +00002364
2365 // Memory-Integer Subtraction
Evan Cheng64d80e32007-07-19 01:14:50 +00002366 def SUB8mi : Ii8<0x80, MRM5m, (outs), (ins i8mem :$dst, i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002367 "sub{b}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingd350e022008-12-12 21:15:41 +00002368 [(store (sub (loadi8 addr:$dst), imm:$src2), addr:$dst),
2369 (implicit EFLAGS)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00002370 def SUB16mi : Ii16<0x81, MRM5m, (outs), (ins i16mem:$dst, i16imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002371 "sub{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingd350e022008-12-12 21:15:41 +00002372 [(store (sub (loadi16 addr:$dst), imm:$src2),addr:$dst),
2373 (implicit EFLAGS)]>, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00002374 def SUB32mi : Ii32<0x81, MRM5m, (outs), (ins i32mem:$dst, i32imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002375 "sub{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingd350e022008-12-12 21:15:41 +00002376 [(store (sub (loadi32 addr:$dst), imm:$src2),addr:$dst),
2377 (implicit EFLAGS)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00002378 def SUB16mi8 : Ii8<0x83, MRM5m, (outs), (ins i16mem:$dst, i16i8imm :$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002379 "sub{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingab55ebd2008-12-12 00:56:36 +00002380 [(store (sub (load addr:$dst), i16immSExt8:$src2),
Bill Wendlingd350e022008-12-12 21:15:41 +00002381 addr:$dst),
2382 (implicit EFLAGS)]>, OpSize;
Bill Wendlingab55ebd2008-12-12 00:56:36 +00002383 def SUB32mi8 : Ii8<0x83, MRM5m, (outs), (ins i32mem:$dst, i32i8imm :$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002384 "sub{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingab55ebd2008-12-12 00:56:36 +00002385 [(store (sub (load addr:$dst), i32immSExt8:$src2),
Bill Wendlingd350e022008-12-12 21:15:41 +00002386 addr:$dst),
2387 (implicit EFLAGS)]>;
Chris Lattner57a02302004-08-11 04:31:00 +00002388}
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00002389
Evan Cheng3154cb62007-10-05 17:59:57 +00002390let Uses = [EFLAGS] in {
Evan Cheng64d80e32007-07-19 01:14:50 +00002391def SBB32rr : I<0x19, MRMDestReg, (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002392 "sbb{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng24f2ea32007-09-14 21:48:26 +00002393 [(set GR32:$dst, (sube GR32:$src1, GR32:$src2))]>;
Chris Lattnerd93d3b02004-10-06 04:01:02 +00002394
Chris Lattner57a02302004-08-11 04:31:00 +00002395let isTwoAddress = 0 in {
Evan Cheng64d80e32007-07-19 01:14:50 +00002396 def SBB32mr : I<0x19, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002397 "sbb{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00002398 [(store (sube (load addr:$dst), GR32:$src2), addr:$dst)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00002399 def SBB8mi : Ii32<0x80, MRM3m, (outs), (ins i8mem:$dst, i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002400 "sbb{b}\t{$src2, $dst|$dst, $src2}",
Nate Begeman551bf3f2006-02-17 05:43:56 +00002401 [(store (sube (loadi8 addr:$dst), imm:$src2), addr:$dst)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00002402 def SBB32mi : Ii32<0x81, MRM3m, (outs), (ins i32mem:$dst, i32imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002403 "sbb{l}\t{$src2, $dst|$dst, $src2}",
Nate Begeman551bf3f2006-02-17 05:43:56 +00002404 [(store (sube (loadi32 addr:$dst), imm:$src2), addr:$dst)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00002405 def SBB32mi8 : Ii8<0x83, MRM3m, (outs), (ins i32mem:$dst, i32i8imm :$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002406 "sbb{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng24f2ea32007-09-14 21:48:26 +00002407 [(store (sube (load addr:$dst), i32immSExt8:$src2), addr:$dst)]>;
Chris Lattner57a02302004-08-11 04:31:00 +00002408}
Evan Cheng64d80e32007-07-19 01:14:50 +00002409def SBB32rm : I<0x1B, MRMSrcMem, (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002410 "sbb{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00002411 [(set GR32:$dst, (sube GR32:$src1, (load addr:$src2)))]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00002412def SBB32ri : Ii32<0x81, MRM3r, (outs GR32:$dst), (ins GR32:$src1, i32imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002413 "sbb{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00002414 [(set GR32:$dst, (sube GR32:$src1, imm:$src2))]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00002415def SBB32ri8 : Ii8<0x83, MRM3r, (outs GR32:$dst), (ins GR32:$src1, i32i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002416 "sbb{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00002417 [(set GR32:$dst, (sube GR32:$src1, i32immSExt8:$src2))]>;
Evan Cheng3154cb62007-10-05 17:59:57 +00002418} // Uses = [EFLAGS]
Evan Cheng24f2ea32007-09-14 21:48:26 +00002419} // Defs = [EFLAGS]
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00002420
Evan Cheng24f2ea32007-09-14 21:48:26 +00002421let Defs = [EFLAGS] in {
Chris Lattner10197ff2005-01-03 01:27:59 +00002422let isCommutable = 1 in { // X = IMUL Y, Z --> X = IMUL Z, Y
Bill Wendlingd350e022008-12-12 21:15:41 +00002423// Register-Register Signed Integer Multiply
Bill Wendlingab55ebd2008-12-12 00:56:36 +00002424def IMUL16rr : I<0xAF, MRMSrcReg, (outs GR16:$dst), (ins GR16:$src1,GR16:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002425 "imul{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingd350e022008-12-12 21:15:41 +00002426 [(set GR16:$dst, (mul GR16:$src1, GR16:$src2)),
2427 (implicit EFLAGS)]>, TB, OpSize;
Bill Wendlingab55ebd2008-12-12 00:56:36 +00002428def IMUL32rr : I<0xAF, MRMSrcReg, (outs GR32:$dst), (ins GR32:$src1,GR32:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002429 "imul{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingd350e022008-12-12 21:15:41 +00002430 [(set GR32:$dst, (mul GR32:$src1, GR32:$src2)),
2431 (implicit EFLAGS)]>, TB;
Chris Lattner10197ff2005-01-03 01:27:59 +00002432}
Bill Wendlingab55ebd2008-12-12 00:56:36 +00002433
Bill Wendlingd350e022008-12-12 21:15:41 +00002434// Register-Memory Signed Integer Multiply
Bill Wendlingab55ebd2008-12-12 00:56:36 +00002435def IMUL16rm : I<0xAF, MRMSrcMem, (outs GR16:$dst),
2436 (ins GR16:$src1, i16mem:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002437 "imul{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingd350e022008-12-12 21:15:41 +00002438 [(set GR16:$dst, (mul GR16:$src1, (load addr:$src2))),
2439 (implicit EFLAGS)]>, TB, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00002440def IMUL32rm : I<0xAF, MRMSrcMem, (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002441 "imul{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingd350e022008-12-12 21:15:41 +00002442 [(set GR32:$dst, (mul GR32:$src1, (load addr:$src2))),
2443 (implicit EFLAGS)]>, TB;
Evan Cheng24f2ea32007-09-14 21:48:26 +00002444} // Defs = [EFLAGS]
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00002445} // end Two Address instructions
2446
Chris Lattnerf5d3a832004-08-11 05:31:07 +00002447// Suprisingly enough, these are not two address instructions!
Evan Cheng24f2ea32007-09-14 21:48:26 +00002448let Defs = [EFLAGS] in {
Bill Wendlingd350e022008-12-12 21:15:41 +00002449// Register-Integer Signed Integer Multiply
Evan Cheng069287d2006-05-16 07:21:53 +00002450def IMUL16rri : Ii16<0x69, MRMSrcReg, // GR16 = GR16*I16
Evan Cheng64d80e32007-07-19 01:14:50 +00002451 (outs GR16:$dst), (ins GR16:$src1, i16imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002452 "imul{w}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Bill Wendlingd350e022008-12-12 21:15:41 +00002453 [(set GR16:$dst, (mul GR16:$src1, imm:$src2)),
2454 (implicit EFLAGS)]>, OpSize;
Evan Cheng069287d2006-05-16 07:21:53 +00002455def IMUL32rri : Ii32<0x69, MRMSrcReg, // GR32 = GR32*I32
Evan Cheng64d80e32007-07-19 01:14:50 +00002456 (outs GR32:$dst), (ins GR32:$src1, i32imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002457 "imul{l}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Bill Wendlingd350e022008-12-12 21:15:41 +00002458 [(set GR32:$dst, (mul GR32:$src1, imm:$src2)),
2459 (implicit EFLAGS)]>;
Evan Cheng069287d2006-05-16 07:21:53 +00002460def IMUL16rri8 : Ii8<0x6B, MRMSrcReg, // GR16 = GR16*I8
Evan Cheng64d80e32007-07-19 01:14:50 +00002461 (outs GR16:$dst), (ins GR16:$src1, i16i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002462 "imul{w}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Bill Wendlingd350e022008-12-12 21:15:41 +00002463 [(set GR16:$dst, (mul GR16:$src1, i16immSExt8:$src2)),
2464 (implicit EFLAGS)]>, OpSize;
Evan Cheng069287d2006-05-16 07:21:53 +00002465def IMUL32rri8 : Ii8<0x6B, MRMSrcReg, // GR32 = GR32*I8
Evan Cheng64d80e32007-07-19 01:14:50 +00002466 (outs GR32:$dst), (ins GR32:$src1, i32i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002467 "imul{l}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Bill Wendlingd350e022008-12-12 21:15:41 +00002468 [(set GR32:$dst, (mul GR32:$src1, i32immSExt8:$src2)),
2469 (implicit EFLAGS)]>;
Chris Lattnerf5d3a832004-08-11 05:31:07 +00002470
Bill Wendlingd350e022008-12-12 21:15:41 +00002471// Memory-Integer Signed Integer Multiply
Evan Cheng069287d2006-05-16 07:21:53 +00002472def IMUL16rmi : Ii16<0x69, MRMSrcMem, // GR16 = [mem16]*I16
Evan Cheng64d80e32007-07-19 01:14:50 +00002473 (outs GR16:$dst), (ins i16mem:$src1, i16imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002474 "imul{w}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Bill Wendlingd350e022008-12-12 21:15:41 +00002475 [(set GR16:$dst, (mul (load addr:$src1), imm:$src2)),
2476 (implicit EFLAGS)]>, OpSize;
Evan Cheng069287d2006-05-16 07:21:53 +00002477def IMUL32rmi : Ii32<0x69, MRMSrcMem, // GR32 = [mem32]*I32
Evan Cheng64d80e32007-07-19 01:14:50 +00002478 (outs GR32:$dst), (ins i32mem:$src1, i32imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002479 "imul{l}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Bill Wendlingd350e022008-12-12 21:15:41 +00002480 [(set GR32:$dst, (mul (load addr:$src1), imm:$src2)),
2481 (implicit EFLAGS)]>;
Evan Cheng069287d2006-05-16 07:21:53 +00002482def IMUL16rmi8 : Ii8<0x6B, MRMSrcMem, // GR16 = [mem16]*I8
Evan Cheng64d80e32007-07-19 01:14:50 +00002483 (outs GR16:$dst), (ins i16mem:$src1, i16i8imm :$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002484 "imul{w}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Bill Wendlingab55ebd2008-12-12 00:56:36 +00002485 [(set GR16:$dst, (mul (load addr:$src1),
Bill Wendlingd350e022008-12-12 21:15:41 +00002486 i16immSExt8:$src2)),
2487 (implicit EFLAGS)]>, OpSize;
Evan Cheng069287d2006-05-16 07:21:53 +00002488def IMUL32rmi8 : Ii8<0x6B, MRMSrcMem, // GR32 = [mem32]*I8
Evan Cheng64d80e32007-07-19 01:14:50 +00002489 (outs GR32:$dst), (ins i32mem:$src1, i32i8imm: $src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002490 "imul{l}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Bill Wendlingab55ebd2008-12-12 00:56:36 +00002491 [(set GR32:$dst, (mul (load addr:$src1),
Bill Wendlingd350e022008-12-12 21:15:41 +00002492 i32immSExt8:$src2)),
2493 (implicit EFLAGS)]>;
Evan Cheng24f2ea32007-09-14 21:48:26 +00002494} // Defs = [EFLAGS]
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00002495
2496//===----------------------------------------------------------------------===//
2497// Test instructions are just like AND, except they don't generate a result.
Chris Lattner3a173df2004-10-03 20:35:00 +00002498//
Evan Cheng0488db92007-09-25 01:57:46 +00002499let Defs = [EFLAGS] in {
Chris Lattnercc65bee2005-01-02 02:35:46 +00002500let isCommutable = 1 in { // TEST X, Y --> TEST Y, X
Evan Cheng64d80e32007-07-19 01:14:50 +00002501def TEST8rr : I<0x84, MRMDestReg, (outs), (ins GR8:$src1, GR8:$src2),
Evan Chenge5f62042007-09-29 00:00:36 +00002502 "test{b}\t{$src2, $src1|$src1, $src2}",
Chris Lattnerce2bcc82008-02-19 17:37:35 +00002503 [(X86cmp (and_su GR8:$src1, GR8:$src2), 0),
Evan Chenge5f62042007-09-29 00:00:36 +00002504 (implicit EFLAGS)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00002505def TEST16rr : I<0x85, MRMDestReg, (outs), (ins GR16:$src1, GR16:$src2),
Evan Chenge5f62042007-09-29 00:00:36 +00002506 "test{w}\t{$src2, $src1|$src1, $src2}",
Chris Lattnerce2bcc82008-02-19 17:37:35 +00002507 [(X86cmp (and_su GR16:$src1, GR16:$src2), 0),
Evan Chenge5f62042007-09-29 00:00:36 +00002508 (implicit EFLAGS)]>,
2509 OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00002510def TEST32rr : I<0x85, MRMDestReg, (outs), (ins GR32:$src1, GR32:$src2),
Evan Chenge5f62042007-09-29 00:00:36 +00002511 "test{l}\t{$src2, $src1|$src1, $src2}",
Chris Lattnerce2bcc82008-02-19 17:37:35 +00002512 [(X86cmp (and_su GR32:$src1, GR32:$src2), 0),
Evan Chenge5f62042007-09-29 00:00:36 +00002513 (implicit EFLAGS)]>;
Chris Lattnercc65bee2005-01-02 02:35:46 +00002514}
Evan Cheng734503b2006-09-11 02:19:56 +00002515
Evan Cheng64d80e32007-07-19 01:14:50 +00002516def TEST8rm : I<0x84, MRMSrcMem, (outs), (ins GR8 :$src1, i8mem :$src2),
Evan Chenge5f62042007-09-29 00:00:36 +00002517 "test{b}\t{$src2, $src1|$src1, $src2}",
2518 [(X86cmp (and GR8:$src1, (loadi8 addr:$src2)), 0),
2519 (implicit EFLAGS)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00002520def TEST16rm : I<0x85, MRMSrcMem, (outs), (ins GR16:$src1, i16mem:$src2),
Evan Chenge5f62042007-09-29 00:00:36 +00002521 "test{w}\t{$src2, $src1|$src1, $src2}",
2522 [(X86cmp (and GR16:$src1, (loadi16 addr:$src2)), 0),
2523 (implicit EFLAGS)]>, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00002524def TEST32rm : I<0x85, MRMSrcMem, (outs), (ins GR32:$src1, i32mem:$src2),
Evan Chenge5f62042007-09-29 00:00:36 +00002525 "test{l}\t{$src2, $src1|$src1, $src2}",
2526 [(X86cmp (and GR32:$src1, (loadi32 addr:$src2)), 0),
2527 (implicit EFLAGS)]>;
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00002528
Evan Cheng069287d2006-05-16 07:21:53 +00002529def TEST8ri : Ii8 <0xF6, MRM0r, // flags = GR8 & imm8
Evan Cheng64d80e32007-07-19 01:14:50 +00002530 (outs), (ins GR8:$src1, i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002531 "test{b}\t{$src2, $src1|$src1, $src2}",
Chris Lattnerce2bcc82008-02-19 17:37:35 +00002532 [(X86cmp (and_su GR8:$src1, imm:$src2), 0),
Evan Chenge5f62042007-09-29 00:00:36 +00002533 (implicit EFLAGS)]>;
Evan Cheng069287d2006-05-16 07:21:53 +00002534def TEST16ri : Ii16<0xF7, MRM0r, // flags = GR16 & imm16
Evan Cheng64d80e32007-07-19 01:14:50 +00002535 (outs), (ins GR16:$src1, i16imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002536 "test{w}\t{$src2, $src1|$src1, $src2}",
Chris Lattnerce2bcc82008-02-19 17:37:35 +00002537 [(X86cmp (and_su GR16:$src1, imm:$src2), 0),
Evan Chenge5f62042007-09-29 00:00:36 +00002538 (implicit EFLAGS)]>, OpSize;
Evan Cheng069287d2006-05-16 07:21:53 +00002539def TEST32ri : Ii32<0xF7, MRM0r, // flags = GR32 & imm32
Evan Cheng64d80e32007-07-19 01:14:50 +00002540 (outs), (ins GR32:$src1, i32imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002541 "test{l}\t{$src2, $src1|$src1, $src2}",
Chris Lattnerce2bcc82008-02-19 17:37:35 +00002542 [(X86cmp (and_su GR32:$src1, imm:$src2), 0),
Evan Chenge5f62042007-09-29 00:00:36 +00002543 (implicit EFLAGS)]>;
Evan Cheng734503b2006-09-11 02:19:56 +00002544
Evan Chenge5f62042007-09-29 00:00:36 +00002545def TEST8mi : Ii8 <0xF6, MRM0m, // flags = [mem8] & imm8
Evan Cheng64d80e32007-07-19 01:14:50 +00002546 (outs), (ins i8mem:$src1, i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002547 "test{b}\t{$src2, $src1|$src1, $src2}",
Evan Chenge5f62042007-09-29 00:00:36 +00002548 [(X86cmp (and (loadi8 addr:$src1), imm:$src2), 0),
2549 (implicit EFLAGS)]>;
2550def TEST16mi : Ii16<0xF7, MRM0m, // flags = [mem16] & imm16
Evan Cheng64d80e32007-07-19 01:14:50 +00002551 (outs), (ins i16mem:$src1, i16imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002552 "test{w}\t{$src2, $src1|$src1, $src2}",
Evan Chenge5f62042007-09-29 00:00:36 +00002553 [(X86cmp (and (loadi16 addr:$src1), imm:$src2), 0),
2554 (implicit EFLAGS)]>, OpSize;
2555def TEST32mi : Ii32<0xF7, MRM0m, // flags = [mem32] & imm32
Evan Cheng64d80e32007-07-19 01:14:50 +00002556 (outs), (ins i32mem:$src1, i32imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002557 "test{l}\t{$src2, $src1|$src1, $src2}",
Evan Chenge5f62042007-09-29 00:00:36 +00002558 [(X86cmp (and (loadi32 addr:$src1), imm:$src2), 0),
Evan Cheng0488db92007-09-25 01:57:46 +00002559 (implicit EFLAGS)]>;
2560} // Defs = [EFLAGS]
2561
2562
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00002563// Condition code ops, incl. set if equal/not equal/...
Chris Lattnerba7e7562008-01-10 07:59:24 +00002564let Defs = [EFLAGS], Uses = [AH], neverHasSideEffects = 1 in
Evan Cheng071a2792007-09-11 19:55:27 +00002565def SAHF : I<0x9E, RawFrm, (outs), (ins), "sahf", []>; // flags = AH
Chris Lattnerba7e7562008-01-10 07:59:24 +00002566let Defs = [AH], Uses = [EFLAGS], neverHasSideEffects = 1 in
Evan Cheng071a2792007-09-11 19:55:27 +00002567def LAHF : I<0x9F, RawFrm, (outs), (ins), "lahf", []>; // AH = flags
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00002568
Evan Cheng0488db92007-09-25 01:57:46 +00002569let Uses = [EFLAGS] in {
Chris Lattner3a173df2004-10-03 20:35:00 +00002570def SETEr : I<0x94, MRM0r,
Evan Cheng64d80e32007-07-19 01:14:50 +00002571 (outs GR8 :$dst), (ins),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002572 "sete\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +00002573 [(set GR8:$dst, (X86setcc X86_COND_E, EFLAGS))]>,
Evan Cheng069287d2006-05-16 07:21:53 +00002574 TB; // GR8 = ==
Chris Lattner3a173df2004-10-03 20:35:00 +00002575def SETEm : I<0x94, MRM0m,
Evan Cheng64d80e32007-07-19 01:14:50 +00002576 (outs), (ins i8mem:$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002577 "sete\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +00002578 [(store (X86setcc X86_COND_E, EFLAGS), addr:$dst)]>,
Evan Chengd5781fc2005-12-21 20:21:51 +00002579 TB; // [mem8] = ==
Bill Wendling9f248742008-12-02 00:07:05 +00002580
Chris Lattner3a173df2004-10-03 20:35:00 +00002581def SETNEr : I<0x95, MRM0r,
Evan Cheng64d80e32007-07-19 01:14:50 +00002582 (outs GR8 :$dst), (ins),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002583 "setne\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +00002584 [(set GR8:$dst, (X86setcc X86_COND_NE, EFLAGS))]>,
Evan Cheng069287d2006-05-16 07:21:53 +00002585 TB; // GR8 = !=
Chris Lattner3a173df2004-10-03 20:35:00 +00002586def SETNEm : I<0x95, MRM0m,
Evan Cheng64d80e32007-07-19 01:14:50 +00002587 (outs), (ins i8mem:$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002588 "setne\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +00002589 [(store (X86setcc X86_COND_NE, EFLAGS), addr:$dst)]>,
Evan Chengd5781fc2005-12-21 20:21:51 +00002590 TB; // [mem8] = !=
Bill Wendling9f248742008-12-02 00:07:05 +00002591
Evan Chengd5781fc2005-12-21 20:21:51 +00002592def SETLr : I<0x9C, MRM0r,
Evan Cheng64d80e32007-07-19 01:14:50 +00002593 (outs GR8 :$dst), (ins),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002594 "setl\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +00002595 [(set GR8:$dst, (X86setcc X86_COND_L, EFLAGS))]>,
Evan Cheng069287d2006-05-16 07:21:53 +00002596 TB; // GR8 = < signed
Evan Chengd5781fc2005-12-21 20:21:51 +00002597def SETLm : I<0x9C, MRM0m,
Evan Cheng64d80e32007-07-19 01:14:50 +00002598 (outs), (ins i8mem:$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002599 "setl\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +00002600 [(store (X86setcc X86_COND_L, EFLAGS), addr:$dst)]>,
Evan Chengd5781fc2005-12-21 20:21:51 +00002601 TB; // [mem8] = < signed
Bill Wendling9f248742008-12-02 00:07:05 +00002602
Evan Chengd5781fc2005-12-21 20:21:51 +00002603def SETGEr : I<0x9D, MRM0r,
Evan Cheng64d80e32007-07-19 01:14:50 +00002604 (outs GR8 :$dst), (ins),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002605 "setge\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +00002606 [(set GR8:$dst, (X86setcc X86_COND_GE, EFLAGS))]>,
Evan Cheng069287d2006-05-16 07:21:53 +00002607 TB; // GR8 = >= signed
Evan Chengd5781fc2005-12-21 20:21:51 +00002608def SETGEm : I<0x9D, MRM0m,
Evan Cheng64d80e32007-07-19 01:14:50 +00002609 (outs), (ins i8mem:$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002610 "setge\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +00002611 [(store (X86setcc X86_COND_GE, EFLAGS), addr:$dst)]>,
Evan Chengd5781fc2005-12-21 20:21:51 +00002612 TB; // [mem8] = >= signed
Bill Wendling9f248742008-12-02 00:07:05 +00002613
Evan Chengd5781fc2005-12-21 20:21:51 +00002614def SETLEr : I<0x9E, MRM0r,
Evan Cheng64d80e32007-07-19 01:14:50 +00002615 (outs GR8 :$dst), (ins),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002616 "setle\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +00002617 [(set GR8:$dst, (X86setcc X86_COND_LE, EFLAGS))]>,
Evan Cheng069287d2006-05-16 07:21:53 +00002618 TB; // GR8 = <= signed
Evan Chengd5781fc2005-12-21 20:21:51 +00002619def SETLEm : I<0x9E, MRM0m,
Evan Cheng64d80e32007-07-19 01:14:50 +00002620 (outs), (ins i8mem:$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002621 "setle\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +00002622 [(store (X86setcc X86_COND_LE, EFLAGS), addr:$dst)]>,
Evan Chengd5781fc2005-12-21 20:21:51 +00002623 TB; // [mem8] = <= signed
Bill Wendling9f248742008-12-02 00:07:05 +00002624
Evan Chengd5781fc2005-12-21 20:21:51 +00002625def SETGr : I<0x9F, MRM0r,
Evan Cheng64d80e32007-07-19 01:14:50 +00002626 (outs GR8 :$dst), (ins),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002627 "setg\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +00002628 [(set GR8:$dst, (X86setcc X86_COND_G, EFLAGS))]>,
Evan Cheng069287d2006-05-16 07:21:53 +00002629 TB; // GR8 = > signed
Evan Chengd5781fc2005-12-21 20:21:51 +00002630def SETGm : I<0x9F, MRM0m,
Evan Cheng64d80e32007-07-19 01:14:50 +00002631 (outs), (ins i8mem:$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002632 "setg\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +00002633 [(store (X86setcc X86_COND_G, EFLAGS), addr:$dst)]>,
Evan Chengd5781fc2005-12-21 20:21:51 +00002634 TB; // [mem8] = > signed
2635
2636def SETBr : I<0x92, MRM0r,
Evan Cheng64d80e32007-07-19 01:14:50 +00002637 (outs GR8 :$dst), (ins),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002638 "setb\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +00002639 [(set GR8:$dst, (X86setcc X86_COND_B, EFLAGS))]>,
Evan Cheng069287d2006-05-16 07:21:53 +00002640 TB; // GR8 = < unsign
Evan Chengd5781fc2005-12-21 20:21:51 +00002641def SETBm : I<0x92, MRM0m,
Evan Cheng64d80e32007-07-19 01:14:50 +00002642 (outs), (ins i8mem:$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002643 "setb\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +00002644 [(store (X86setcc X86_COND_B, EFLAGS), addr:$dst)]>,
Evan Chengd5781fc2005-12-21 20:21:51 +00002645 TB; // [mem8] = < unsign
Bill Wendling9f248742008-12-02 00:07:05 +00002646
Evan Chengd5781fc2005-12-21 20:21:51 +00002647def SETAEr : I<0x93, MRM0r,
Evan Cheng64d80e32007-07-19 01:14:50 +00002648 (outs GR8 :$dst), (ins),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002649 "setae\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +00002650 [(set GR8:$dst, (X86setcc X86_COND_AE, EFLAGS))]>,
Evan Cheng069287d2006-05-16 07:21:53 +00002651 TB; // GR8 = >= unsign
Evan Chengd5781fc2005-12-21 20:21:51 +00002652def SETAEm : I<0x93, MRM0m,
Evan Cheng64d80e32007-07-19 01:14:50 +00002653 (outs), (ins i8mem:$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002654 "setae\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +00002655 [(store (X86setcc X86_COND_AE, EFLAGS), addr:$dst)]>,
Evan Chengd5781fc2005-12-21 20:21:51 +00002656 TB; // [mem8] = >= unsign
Bill Wendling9f248742008-12-02 00:07:05 +00002657
Chris Lattner3a173df2004-10-03 20:35:00 +00002658def SETBEr : I<0x96, MRM0r,
Evan Cheng64d80e32007-07-19 01:14:50 +00002659 (outs GR8 :$dst), (ins),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002660 "setbe\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +00002661 [(set GR8:$dst, (X86setcc X86_COND_BE, EFLAGS))]>,
Evan Cheng069287d2006-05-16 07:21:53 +00002662 TB; // GR8 = <= unsign
Chris Lattner3a173df2004-10-03 20:35:00 +00002663def SETBEm : I<0x96, MRM0m,
Evan Cheng64d80e32007-07-19 01:14:50 +00002664 (outs), (ins i8mem:$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002665 "setbe\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +00002666 [(store (X86setcc X86_COND_BE, EFLAGS), addr:$dst)]>,
Evan Chengd5781fc2005-12-21 20:21:51 +00002667 TB; // [mem8] = <= unsign
Bill Wendling9f248742008-12-02 00:07:05 +00002668
Chris Lattner3a173df2004-10-03 20:35:00 +00002669def SETAr : I<0x97, MRM0r,
Evan Cheng64d80e32007-07-19 01:14:50 +00002670 (outs GR8 :$dst), (ins),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002671 "seta\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +00002672 [(set GR8:$dst, (X86setcc X86_COND_A, EFLAGS))]>,
Evan Cheng069287d2006-05-16 07:21:53 +00002673 TB; // GR8 = > signed
Chris Lattner3a173df2004-10-03 20:35:00 +00002674def SETAm : I<0x97, MRM0m,
Evan Cheng64d80e32007-07-19 01:14:50 +00002675 (outs), (ins i8mem:$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002676 "seta\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +00002677 [(store (X86setcc X86_COND_A, EFLAGS), addr:$dst)]>,
Evan Chengd5781fc2005-12-21 20:21:51 +00002678 TB; // [mem8] = > signed
Evan Chengd9558e02006-01-06 00:43:03 +00002679
Chris Lattner3a173df2004-10-03 20:35:00 +00002680def SETSr : I<0x98, MRM0r,
Evan Cheng64d80e32007-07-19 01:14:50 +00002681 (outs GR8 :$dst), (ins),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002682 "sets\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +00002683 [(set GR8:$dst, (X86setcc X86_COND_S, EFLAGS))]>,
Evan Cheng069287d2006-05-16 07:21:53 +00002684 TB; // GR8 = <sign bit>
Chris Lattner3a173df2004-10-03 20:35:00 +00002685def SETSm : I<0x98, MRM0m,
Evan Cheng64d80e32007-07-19 01:14:50 +00002686 (outs), (ins i8mem:$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002687 "sets\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +00002688 [(store (X86setcc X86_COND_S, EFLAGS), addr:$dst)]>,
Evan Chengd9558e02006-01-06 00:43:03 +00002689 TB; // [mem8] = <sign bit>
Chris Lattner3a173df2004-10-03 20:35:00 +00002690def SETNSr : I<0x99, MRM0r,
Evan Cheng64d80e32007-07-19 01:14:50 +00002691 (outs GR8 :$dst), (ins),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002692 "setns\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +00002693 [(set GR8:$dst, (X86setcc X86_COND_NS, EFLAGS))]>,
Evan Cheng069287d2006-05-16 07:21:53 +00002694 TB; // GR8 = !<sign bit>
Chris Lattner3a173df2004-10-03 20:35:00 +00002695def SETNSm : I<0x99, MRM0m,
Evan Cheng64d80e32007-07-19 01:14:50 +00002696 (outs), (ins i8mem:$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002697 "setns\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +00002698 [(store (X86setcc X86_COND_NS, EFLAGS), addr:$dst)]>,
Evan Chengd9558e02006-01-06 00:43:03 +00002699 TB; // [mem8] = !<sign bit>
Bill Wendling9f248742008-12-02 00:07:05 +00002700
Chris Lattner3a173df2004-10-03 20:35:00 +00002701def SETPr : I<0x9A, MRM0r,
Evan Cheng64d80e32007-07-19 01:14:50 +00002702 (outs GR8 :$dst), (ins),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002703 "setp\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +00002704 [(set GR8:$dst, (X86setcc X86_COND_P, EFLAGS))]>,
Evan Cheng069287d2006-05-16 07:21:53 +00002705 TB; // GR8 = parity
Chris Lattner3a173df2004-10-03 20:35:00 +00002706def SETPm : I<0x9A, MRM0m,
Evan Cheng64d80e32007-07-19 01:14:50 +00002707 (outs), (ins i8mem:$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002708 "setp\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +00002709 [(store (X86setcc X86_COND_P, EFLAGS), addr:$dst)]>,
Evan Chengd9558e02006-01-06 00:43:03 +00002710 TB; // [mem8] = parity
Chris Lattnercc65bee2005-01-02 02:35:46 +00002711def SETNPr : I<0x9B, MRM0r,
Evan Cheng64d80e32007-07-19 01:14:50 +00002712 (outs GR8 :$dst), (ins),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002713 "setnp\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +00002714 [(set GR8:$dst, (X86setcc X86_COND_NP, EFLAGS))]>,
Evan Cheng069287d2006-05-16 07:21:53 +00002715 TB; // GR8 = not parity
Chris Lattnercc65bee2005-01-02 02:35:46 +00002716def SETNPm : I<0x9B, MRM0m,
Evan Cheng64d80e32007-07-19 01:14:50 +00002717 (outs), (ins i8mem:$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002718 "setnp\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +00002719 [(store (X86setcc X86_COND_NP, EFLAGS), addr:$dst)]>,
Evan Chengd9558e02006-01-06 00:43:03 +00002720 TB; // [mem8] = not parity
Bill Wendling9f248742008-12-02 00:07:05 +00002721
2722def SETOr : I<0x90, MRM0r,
2723 (outs GR8 :$dst), (ins),
2724 "seto\t$dst",
2725 [(set GR8:$dst, (X86setcc X86_COND_O, EFLAGS))]>,
2726 TB; // GR8 = overflow
2727def SETOm : I<0x90, MRM0m,
2728 (outs), (ins i8mem:$dst),
2729 "seto\t$dst",
2730 [(store (X86setcc X86_COND_O, EFLAGS), addr:$dst)]>,
2731 TB; // [mem8] = overflow
2732def SETNOr : I<0x91, MRM0r,
2733 (outs GR8 :$dst), (ins),
2734 "setno\t$dst",
2735 [(set GR8:$dst, (X86setcc X86_COND_NO, EFLAGS))]>,
2736 TB; // GR8 = not overflow
2737def SETNOm : I<0x91, MRM0m,
2738 (outs), (ins i8mem:$dst),
2739 "setno\t$dst",
2740 [(store (X86setcc X86_COND_NO, EFLAGS), addr:$dst)]>,
2741 TB; // [mem8] = not overflow
Evan Cheng0488db92007-09-25 01:57:46 +00002742} // Uses = [EFLAGS]
2743
Chris Lattner1cca5e32003-08-03 21:54:21 +00002744
2745// Integer comparisons
Evan Cheng24f2ea32007-09-14 21:48:26 +00002746let Defs = [EFLAGS] in {
Chris Lattner3a173df2004-10-03 20:35:00 +00002747def CMP8rr : I<0x38, MRMDestReg,
Evan Cheng64d80e32007-07-19 01:14:50 +00002748 (outs), (ins GR8 :$src1, GR8 :$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002749 "cmp{b}\t{$src2, $src1|$src1, $src2}",
Evan Chenge5f62042007-09-29 00:00:36 +00002750 [(X86cmp GR8:$src1, GR8:$src2), (implicit EFLAGS)]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00002751def CMP16rr : I<0x39, MRMDestReg,
Evan Cheng64d80e32007-07-19 01:14:50 +00002752 (outs), (ins GR16:$src1, GR16:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002753 "cmp{w}\t{$src2, $src1|$src1, $src2}",
Evan Chenge5f62042007-09-29 00:00:36 +00002754 [(X86cmp GR16:$src1, GR16:$src2), (implicit EFLAGS)]>, OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00002755def CMP32rr : I<0x39, MRMDestReg,
Evan Cheng64d80e32007-07-19 01:14:50 +00002756 (outs), (ins GR32:$src1, GR32:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002757 "cmp{l}\t{$src2, $src1|$src1, $src2}",
Evan Chenge5f62042007-09-29 00:00:36 +00002758 [(X86cmp GR32:$src1, GR32:$src2), (implicit EFLAGS)]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00002759def CMP8mr : I<0x38, MRMDestMem,
Evan Cheng64d80e32007-07-19 01:14:50 +00002760 (outs), (ins i8mem :$src1, GR8 :$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002761 "cmp{b}\t{$src2, $src1|$src1, $src2}",
Evan Chenge5f62042007-09-29 00:00:36 +00002762 [(X86cmp (loadi8 addr:$src1), GR8:$src2),
2763 (implicit EFLAGS)]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00002764def CMP16mr : I<0x39, MRMDestMem,
Evan Cheng64d80e32007-07-19 01:14:50 +00002765 (outs), (ins i16mem:$src1, GR16:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002766 "cmp{w}\t{$src2, $src1|$src1, $src2}",
Evan Chenge5f62042007-09-29 00:00:36 +00002767 [(X86cmp (loadi16 addr:$src1), GR16:$src2),
2768 (implicit EFLAGS)]>, OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00002769def CMP32mr : I<0x39, MRMDestMem,
Evan Cheng64d80e32007-07-19 01:14:50 +00002770 (outs), (ins i32mem:$src1, GR32:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002771 "cmp{l}\t{$src2, $src1|$src1, $src2}",
Evan Chenge5f62042007-09-29 00:00:36 +00002772 [(X86cmp (loadi32 addr:$src1), GR32:$src2),
2773 (implicit EFLAGS)]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00002774def CMP8rm : I<0x3A, MRMSrcMem,
Evan Cheng64d80e32007-07-19 01:14:50 +00002775 (outs), (ins GR8 :$src1, i8mem :$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002776 "cmp{b}\t{$src2, $src1|$src1, $src2}",
Evan Chenge5f62042007-09-29 00:00:36 +00002777 [(X86cmp GR8:$src1, (loadi8 addr:$src2)),
2778 (implicit EFLAGS)]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00002779def CMP16rm : I<0x3B, MRMSrcMem,
Evan Cheng64d80e32007-07-19 01:14:50 +00002780 (outs), (ins GR16:$src1, i16mem:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002781 "cmp{w}\t{$src2, $src1|$src1, $src2}",
Evan Chenge5f62042007-09-29 00:00:36 +00002782 [(X86cmp GR16:$src1, (loadi16 addr:$src2)),
2783 (implicit EFLAGS)]>, OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00002784def CMP32rm : I<0x3B, MRMSrcMem,
Evan Cheng64d80e32007-07-19 01:14:50 +00002785 (outs), (ins GR32:$src1, i32mem:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002786 "cmp{l}\t{$src2, $src1|$src1, $src2}",
Evan Chenge5f62042007-09-29 00:00:36 +00002787 [(X86cmp GR32:$src1, (loadi32 addr:$src2)),
2788 (implicit EFLAGS)]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00002789def CMP8ri : Ii8<0x80, MRM7r,
Evan Cheng64d80e32007-07-19 01:14:50 +00002790 (outs), (ins GR8:$src1, i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002791 "cmp{b}\t{$src2, $src1|$src1, $src2}",
Evan Chenge5f62042007-09-29 00:00:36 +00002792 [(X86cmp GR8:$src1, imm:$src2), (implicit EFLAGS)]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00002793def CMP16ri : Ii16<0x81, MRM7r,
Evan Cheng64d80e32007-07-19 01:14:50 +00002794 (outs), (ins GR16:$src1, i16imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002795 "cmp{w}\t{$src2, $src1|$src1, $src2}",
Evan Chenge5f62042007-09-29 00:00:36 +00002796 [(X86cmp GR16:$src1, imm:$src2),
2797 (implicit EFLAGS)]>, OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00002798def CMP32ri : Ii32<0x81, MRM7r,
Evan Cheng64d80e32007-07-19 01:14:50 +00002799 (outs), (ins GR32:$src1, i32imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002800 "cmp{l}\t{$src2, $src1|$src1, $src2}",
Evan Chenge5f62042007-09-29 00:00:36 +00002801 [(X86cmp GR32:$src1, imm:$src2), (implicit EFLAGS)]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00002802def CMP8mi : Ii8 <0x80, MRM7m,
Evan Cheng64d80e32007-07-19 01:14:50 +00002803 (outs), (ins i8mem :$src1, i8imm :$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002804 "cmp{b}\t{$src2, $src1|$src1, $src2}",
Evan Chenge5f62042007-09-29 00:00:36 +00002805 [(X86cmp (loadi8 addr:$src1), imm:$src2),
2806 (implicit EFLAGS)]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00002807def CMP16mi : Ii16<0x81, MRM7m,
Evan Cheng64d80e32007-07-19 01:14:50 +00002808 (outs), (ins i16mem:$src1, i16imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002809 "cmp{w}\t{$src2, $src1|$src1, $src2}",
Evan Chenge5f62042007-09-29 00:00:36 +00002810 [(X86cmp (loadi16 addr:$src1), imm:$src2),
2811 (implicit EFLAGS)]>, OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00002812def CMP32mi : Ii32<0x81, MRM7m,
Evan Cheng64d80e32007-07-19 01:14:50 +00002813 (outs), (ins i32mem:$src1, i32imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002814 "cmp{l}\t{$src2, $src1|$src1, $src2}",
Evan Chenge5f62042007-09-29 00:00:36 +00002815 [(X86cmp (loadi32 addr:$src1), imm:$src2),
2816 (implicit EFLAGS)]>;
Chris Lattner29b4dd02006-03-23 16:13:50 +00002817def CMP16ri8 : Ii8<0x83, MRM7r,
Evan Cheng64d80e32007-07-19 01:14:50 +00002818 (outs), (ins GR16:$src1, i16i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002819 "cmp{w}\t{$src2, $src1|$src1, $src2}",
Evan Chenge5f62042007-09-29 00:00:36 +00002820 [(X86cmp GR16:$src1, i16immSExt8:$src2),
2821 (implicit EFLAGS)]>, OpSize;
Chris Lattner29b4dd02006-03-23 16:13:50 +00002822def CMP16mi8 : Ii8<0x83, MRM7m,
Evan Cheng64d80e32007-07-19 01:14:50 +00002823 (outs), (ins i16mem:$src1, i16i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002824 "cmp{w}\t{$src2, $src1|$src1, $src2}",
Evan Chenge5f62042007-09-29 00:00:36 +00002825 [(X86cmp (loadi16 addr:$src1), i16immSExt8:$src2),
2826 (implicit EFLAGS)]>, OpSize;
Chris Lattner29b4dd02006-03-23 16:13:50 +00002827def CMP32mi8 : Ii8<0x83, MRM7m,
Evan Cheng64d80e32007-07-19 01:14:50 +00002828 (outs), (ins i32mem:$src1, i32i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002829 "cmp{l}\t{$src2, $src1|$src1, $src2}",
Evan Chenge5f62042007-09-29 00:00:36 +00002830 [(X86cmp (loadi32 addr:$src1), i32immSExt8:$src2),
2831 (implicit EFLAGS)]>;
Chris Lattner29b4dd02006-03-23 16:13:50 +00002832def CMP32ri8 : Ii8<0x83, MRM7r,
Evan Cheng64d80e32007-07-19 01:14:50 +00002833 (outs), (ins GR32:$src1, i32i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002834 "cmp{l}\t{$src2, $src1|$src1, $src2}",
Evan Chenge5f62042007-09-29 00:00:36 +00002835 [(X86cmp GR32:$src1, i32immSExt8:$src2),
Evan Cheng0488db92007-09-25 01:57:46 +00002836 (implicit EFLAGS)]>;
2837} // Defs = [EFLAGS]
2838
Dan Gohmanc7a37d42008-12-23 22:45:23 +00002839// Bit tests.
Dan Gohmanc7a37d42008-12-23 22:45:23 +00002840// TODO: BTC, BTR, and BTS
2841let Defs = [EFLAGS] in {
Dan Gohman0c89b7e2009-01-13 20:32:45 +00002842def BT16rr : I<0xA3, MRMDestReg, (outs), (ins GR16:$src1, GR16:$src2),
Dan Gohmanc7a37d42008-12-23 22:45:23 +00002843 "bt{w}\t{$src2, $src1|$src1, $src2}",
2844 [(X86bt GR16:$src1, GR16:$src2),
Chris Lattnerf1e9fd52008-12-25 01:32:49 +00002845 (implicit EFLAGS)]>, OpSize, TB;
Dan Gohman0c89b7e2009-01-13 20:32:45 +00002846def BT32rr : I<0xA3, MRMDestReg, (outs), (ins GR32:$src1, GR32:$src2),
Dan Gohmanc7a37d42008-12-23 22:45:23 +00002847 "bt{l}\t{$src2, $src1|$src1, $src2}",
2848 [(X86bt GR32:$src1, GR32:$src2),
Chris Lattnerf1e9fd52008-12-25 01:32:49 +00002849 (implicit EFLAGS)]>, TB;
Dan Gohmanf31408d2009-01-13 23:23:30 +00002850
2851// Unlike with the register+register form, the memory+register form of the
2852// bt instruction does not ignore the high bits of the index. From ISel's
2853// perspective, this is pretty bizarre. Disable these instructions for now.
2854//def BT16mr : I<0xA3, MRMDestMem, (outs), (ins i16mem:$src1, GR16:$src2),
2855// "bt{w}\t{$src2, $src1|$src1, $src2}",
2856// [(X86bt (loadi16 addr:$src1), GR16:$src2),
2857// (implicit EFLAGS)]>, OpSize, TB, Requires<[FastBTMem]>;
2858//def BT32mr : I<0xA3, MRMDestMem, (outs), (ins i32mem:$src1, GR32:$src2),
2859// "bt{l}\t{$src2, $src1|$src1, $src2}",
2860// [(X86bt (loadi32 addr:$src1), GR32:$src2),
2861// (implicit EFLAGS)]>, TB, Requires<[FastBTMem]>;
Dan Gohman4afe15b2009-01-13 20:33:23 +00002862
2863def BT16ri8 : Ii8<0xBA, MRM4r, (outs), (ins GR16:$src1, i16i8imm:$src2),
2864 "bt{w}\t{$src2, $src1|$src1, $src2}",
2865 [(X86bt GR16:$src1, i16immSExt8:$src2),
2866 (implicit EFLAGS)]>, OpSize, TB;
2867def BT32ri8 : Ii8<0xBA, MRM4r, (outs), (ins GR32:$src1, i32i8imm:$src2),
2868 "bt{l}\t{$src2, $src1|$src1, $src2}",
2869 [(X86bt GR32:$src1, i32immSExt8:$src2),
2870 (implicit EFLAGS)]>, TB;
2871// Note that these instructions don't need FastBTMem because that
2872// only applies when the other operand is in a register. When it's
2873// an immediate, bt is still fast.
2874def BT16mi8 : Ii8<0xBA, MRM4m, (outs), (ins i16mem:$src1, i16i8imm:$src2),
2875 "bt{w}\t{$src2, $src1|$src1, $src2}",
2876 [(X86bt (loadi16 addr:$src1), i16immSExt8:$src2),
2877 (implicit EFLAGS)]>, OpSize, TB;
2878def BT32mi8 : Ii8<0xBA, MRM4m, (outs), (ins i32mem:$src1, i32i8imm:$src2),
2879 "bt{l}\t{$src2, $src1|$src1, $src2}",
2880 [(X86bt (loadi32 addr:$src1), i32immSExt8:$src2),
2881 (implicit EFLAGS)]>, TB;
Dan Gohmanc7a37d42008-12-23 22:45:23 +00002882} // Defs = [EFLAGS]
2883
Chris Lattner1cca5e32003-08-03 21:54:21 +00002884// Sign/Zero extenders
Dan Gohman11ba3b12008-07-30 18:09:17 +00002885// Use movsbl intead of movsbw; we don't care about the high 16 bits
2886// of the register here. This has a smaller encoding and avoids a
2887// partial-register update.
Evan Cheng64d80e32007-07-19 01:14:50 +00002888def MOVSX16rr8 : I<0xBE, MRMSrcReg, (outs GR16:$dst), (ins GR8 :$src),
Dan Gohman11ba3b12008-07-30 18:09:17 +00002889 "movs{bl|x}\t{$src, ${dst:subreg32}|${dst:subreg32}, $src}",
2890 [(set GR16:$dst, (sext GR8:$src))]>, TB;
Evan Cheng64d80e32007-07-19 01:14:50 +00002891def MOVSX16rm8 : I<0xBE, MRMSrcMem, (outs GR16:$dst), (ins i8mem :$src),
Dan Gohman11ba3b12008-07-30 18:09:17 +00002892 "movs{bl|x}\t{$src, ${dst:subreg32}|${dst:subreg32}, $src}",
2893 [(set GR16:$dst, (sextloadi16i8 addr:$src))]>, TB;
Evan Cheng64d80e32007-07-19 01:14:50 +00002894def MOVSX32rr8 : I<0xBE, MRMSrcReg, (outs GR32:$dst), (ins GR8 :$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002895 "movs{bl|x}\t{$src, $dst|$dst, $src}",
Evan Cheng069287d2006-05-16 07:21:53 +00002896 [(set GR32:$dst, (sext GR8:$src))]>, TB;
Evan Cheng64d80e32007-07-19 01:14:50 +00002897def MOVSX32rm8 : I<0xBE, MRMSrcMem, (outs GR32:$dst), (ins i8mem :$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002898 "movs{bl|x}\t{$src, $dst|$dst, $src}",
Evan Cheng069287d2006-05-16 07:21:53 +00002899 [(set GR32:$dst, (sextloadi32i8 addr:$src))]>, TB;
Evan Cheng64d80e32007-07-19 01:14:50 +00002900def MOVSX32rr16: I<0xBF, MRMSrcReg, (outs GR32:$dst), (ins GR16:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002901 "movs{wl|x}\t{$src, $dst|$dst, $src}",
Evan Cheng069287d2006-05-16 07:21:53 +00002902 [(set GR32:$dst, (sext GR16:$src))]>, TB;
Evan Cheng64d80e32007-07-19 01:14:50 +00002903def MOVSX32rm16: I<0xBF, MRMSrcMem, (outs GR32:$dst), (ins i16mem:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002904 "movs{wl|x}\t{$src, $dst|$dst, $src}",
Evan Cheng069287d2006-05-16 07:21:53 +00002905 [(set GR32:$dst, (sextloadi32i16 addr:$src))]>, TB;
Alkis Evlogimenosa7be9822004-02-17 09:14:23 +00002906
Dan Gohman11ba3b12008-07-30 18:09:17 +00002907// Use movzbl intead of movzbw; we don't care about the high 16 bits
2908// of the register here. This has a smaller encoding and avoids a
2909// partial-register update.
Evan Cheng64d80e32007-07-19 01:14:50 +00002910def MOVZX16rr8 : I<0xB6, MRMSrcReg, (outs GR16:$dst), (ins GR8 :$src),
Dan Gohman11ba3b12008-07-30 18:09:17 +00002911 "movz{bl|x}\t{$src, ${dst:subreg32}|${dst:subreg32}, $src}",
2912 [(set GR16:$dst, (zext GR8:$src))]>, TB;
Evan Cheng64d80e32007-07-19 01:14:50 +00002913def MOVZX16rm8 : I<0xB6, MRMSrcMem, (outs GR16:$dst), (ins i8mem :$src),
Dan Gohman11ba3b12008-07-30 18:09:17 +00002914 "movz{bl|x}\t{$src, ${dst:subreg32}|${dst:subreg32}, $src}",
2915 [(set GR16:$dst, (zextloadi16i8 addr:$src))]>, TB;
Evan Cheng64d80e32007-07-19 01:14:50 +00002916def MOVZX32rr8 : I<0xB6, MRMSrcReg, (outs GR32:$dst), (ins GR8 :$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002917 "movz{bl|x}\t{$src, $dst|$dst, $src}",
Evan Cheng069287d2006-05-16 07:21:53 +00002918 [(set GR32:$dst, (zext GR8:$src))]>, TB;
Evan Cheng64d80e32007-07-19 01:14:50 +00002919def MOVZX32rm8 : I<0xB6, MRMSrcMem, (outs GR32:$dst), (ins i8mem :$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002920 "movz{bl|x}\t{$src, $dst|$dst, $src}",
Evan Cheng069287d2006-05-16 07:21:53 +00002921 [(set GR32:$dst, (zextloadi32i8 addr:$src))]>, TB;
Evan Cheng64d80e32007-07-19 01:14:50 +00002922def MOVZX32rr16: I<0xB7, MRMSrcReg, (outs GR32:$dst), (ins GR16:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002923 "movz{wl|x}\t{$src, $dst|$dst, $src}",
Evan Cheng069287d2006-05-16 07:21:53 +00002924 [(set GR32:$dst, (zext GR16:$src))]>, TB;
Evan Cheng64d80e32007-07-19 01:14:50 +00002925def MOVZX32rm16: I<0xB7, MRMSrcMem, (outs GR32:$dst), (ins i16mem:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002926 "movz{wl|x}\t{$src, $dst|$dst, $src}",
Evan Cheng069287d2006-05-16 07:21:53 +00002927 [(set GR32:$dst, (zextloadi32i16 addr:$src))]>, TB;
Evan Cheng7a7e8372005-12-14 02:22:27 +00002928
Dan Gohman21e3dfb2009-04-13 16:09:41 +00002929// These are the same as the regular regular MOVZX32rr8 and MOVZX32rm8
2930// except that they use GR32_NOREX for the output operand register class
2931// instead of GR32. This allows them to operate on h registers on x86-64.
2932def MOVZX32_NOREXrr8 : I<0xB6, MRMSrcReg,
2933 (outs GR32_NOREX:$dst), (ins GR8:$src),
2934 "movz{bl|x}\t{$src, $dst|$dst, $src} # NOREX",
2935 []>, TB;
2936def MOVZX32_NOREXrm8 : I<0xB6, MRMSrcMem,
2937 (outs GR32_NOREX:$dst), (ins i8mem:$src),
2938 "movz{bl|x}\t{$src, $dst|$dst, $src} # NOREX",
2939 []>, TB;
2940
Chris Lattnerba7e7562008-01-10 07:59:24 +00002941let neverHasSideEffects = 1 in {
2942 let Defs = [AX], Uses = [AL] in
2943 def CBW : I<0x98, RawFrm, (outs), (ins),
2944 "{cbtw|cbw}", []>, OpSize; // AX = signext(AL)
2945 let Defs = [EAX], Uses = [AX] in
2946 def CWDE : I<0x98, RawFrm, (outs), (ins),
2947 "{cwtl|cwde}", []>; // EAX = signext(AX)
Evan Chengf91c1012006-05-31 22:05:11 +00002948
Chris Lattnerba7e7562008-01-10 07:59:24 +00002949 let Defs = [AX,DX], Uses = [AX] in
2950 def CWD : I<0x99, RawFrm, (outs), (ins),
2951 "{cwtd|cwd}", []>, OpSize; // DX:AX = signext(AX)
2952 let Defs = [EAX,EDX], Uses = [EAX] in
2953 def CDQ : I<0x99, RawFrm, (outs), (ins),
2954 "{cltd|cdq}", []>; // EDX:EAX = signext(EAX)
2955}
Evan Cheng747a90d2006-02-21 02:24:38 +00002956
Evan Cheng747a90d2006-02-21 02:24:38 +00002957//===----------------------------------------------------------------------===//
2958// Alias Instructions
2959//===----------------------------------------------------------------------===//
2960
2961// Alias instructions that map movr0 to xor.
2962// FIXME: remove when we can teach regalloc that xor reg, reg is ok.
Bill Wendlingbd0879d2008-05-29 01:02:09 +00002963let Defs = [EFLAGS], isReMaterializable = 1, isAsCheapAsAMove = 1 in {
Evan Cheng64d80e32007-07-19 01:14:50 +00002964def MOV8r0 : I<0x30, MRMInitReg, (outs GR8 :$dst), (ins),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002965 "xor{b}\t$dst, $dst",
Evan Cheng069287d2006-05-16 07:21:53 +00002966 [(set GR8:$dst, 0)]>;
Dan Gohman11ba3b12008-07-30 18:09:17 +00002967// Use xorl instead of xorw since we don't care about the high 16 bits,
2968// it's smaller, and it avoids a partial-register update.
Evan Cheng64d80e32007-07-19 01:14:50 +00002969def MOV16r0 : I<0x31, MRMInitReg, (outs GR16:$dst), (ins),
Dan Gohman11ba3b12008-07-30 18:09:17 +00002970 "xor{l}\t${dst:subreg32}, ${dst:subreg32}",
2971 [(set GR16:$dst, 0)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00002972def MOV32r0 : I<0x31, MRMInitReg, (outs GR32:$dst), (ins),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002973 "xor{l}\t$dst, $dst",
Evan Cheng069287d2006-05-16 07:21:53 +00002974 [(set GR32:$dst, 0)]>;
Dan Gohman1ab79892007-09-07 21:32:51 +00002975}
Evan Cheng747a90d2006-02-21 02:24:38 +00002976
Evan Cheng510e4782006-01-09 23:10:28 +00002977//===----------------------------------------------------------------------===//
Lauro Ramos Venanciob3a04172007-04-20 21:38:10 +00002978// Thread Local Storage Instructions
2979//
2980
Rafael Espindola15f1b662009-04-24 12:59:40 +00002981// All calls clobber the non-callee saved registers. ESP is marked as
2982// a use to prevent stack-pointer assignments that appear immediately
2983// before calls from potentially appearing dead.
2984let Defs = [EAX, ECX, EDX, FP0, FP1, FP2, FP3, FP4, FP5, FP6, ST0,
2985 MM0, MM1, MM2, MM3, MM4, MM5, MM6, MM7,
2986 XMM0, XMM1, XMM2, XMM3, XMM4, XMM5, XMM6, XMM7,
2987 XMM8, XMM9, XMM10, XMM11, XMM12, XMM13, XMM14, XMM15, EFLAGS],
2988 Uses = [ESP, EBX] in
Rafael Espindola2ee3db32009-04-17 14:35:58 +00002989def TLS_addr32 : I<0, Pseudo, (outs), (ins i32imm:$sym),
Dan Gohman4d47b9b2009-04-27 15:13:28 +00002990 "leal\t${sym:mem}(,%ebx,1), %eax; "
2991 "call\t___tls_get_addr@PLT",
Rafael Espindola2ee3db32009-04-17 14:35:58 +00002992 [(X86tlsaddr tglobaltlsaddr:$sym)]>,
2993 Requires<[In32BitMode]>;
Lauro Ramos Venanciob3a04172007-04-20 21:38:10 +00002994
Nate Begeman51a04372009-01-26 01:24:32 +00002995let AddedComplexity = 5 in
2996def GS_MOV32rm : I<0x8B, MRMSrcMem, (outs GR32:$dst), (ins i32mem:$src),
2997 "movl\t%gs:$src, $dst",
2998 [(set GR32:$dst, (gsload addr:$src))]>, SegGS;
2999
Lauro Ramos Venanciob3a04172007-04-20 21:38:10 +00003000//===----------------------------------------------------------------------===//
Evan Cheng3c992d22006-03-07 02:02:57 +00003001// DWARF Pseudo Instructions
3002//
3003
Evan Cheng64d80e32007-07-19 01:14:50 +00003004def DWARF_LOC : I<0, Pseudo, (outs),
3005 (ins i32imm:$line, i32imm:$col, i32imm:$file),
Dan Gohman6b5766e2007-09-24 19:25:06 +00003006 ".loc\t${file:debug} ${line:debug} ${col:debug}",
Evan Cheng3c992d22006-03-07 02:02:57 +00003007 [(dwarf_loc (i32 imm:$line), (i32 imm:$col),
3008 (i32 imm:$file))]>;
3009
Evan Cheng3c992d22006-03-07 02:02:57 +00003010//===----------------------------------------------------------------------===//
Anton Korobeynikov2365f512007-07-14 14:06:15 +00003011// EH Pseudo Instructions
3012//
3013let isTerminator = 1, isReturn = 1, isBarrier = 1,
Evan Chengffbacca2007-07-21 00:34:19 +00003014 hasCtrlDep = 1 in {
Evan Cheng64d80e32007-07-19 01:14:50 +00003015def EH_RETURN : I<0xC3, RawFrm, (outs), (ins GR32:$addr),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003016 "ret\t#eh_return, addr: $addr",
Anton Korobeynikov2365f512007-07-14 14:06:15 +00003017 [(X86ehret GR32:$addr)]>;
3018
3019}
3020
3021//===----------------------------------------------------------------------===//
Andrew Lenharthab0b9492008-02-21 06:45:13 +00003022// Atomic support
3023//
Andrew Lenharthea7da502008-03-01 13:37:02 +00003024
Evan Chengbb6939d2008-04-19 01:20:30 +00003025// Atomic swap. These are just normal xchg instructions. But since a memory
3026// operand is referenced, the atomicity is ensured.
Dan Gohman165660e2008-08-06 15:52:50 +00003027let Constraints = "$val = $dst" in {
Evan Chengbb6939d2008-04-19 01:20:30 +00003028def XCHG32rm : I<0x87, MRMSrcMem, (outs GR32:$dst), (ins i32mem:$ptr, GR32:$val),
3029 "xchg{l}\t{$val, $ptr|$ptr, $val}",
3030 [(set GR32:$dst, (atomic_swap_32 addr:$ptr, GR32:$val))]>;
3031def XCHG16rm : I<0x87, MRMSrcMem, (outs GR16:$dst), (ins i16mem:$ptr, GR16:$val),
3032 "xchg{w}\t{$val, $ptr|$ptr, $val}",
3033 [(set GR16:$dst, (atomic_swap_16 addr:$ptr, GR16:$val))]>,
3034 OpSize;
3035def XCHG8rm : I<0x86, MRMSrcMem, (outs GR8:$dst), (ins i8mem:$ptr, GR8:$val),
3036 "xchg{b}\t{$val, $ptr|$ptr, $val}",
3037 [(set GR8:$dst, (atomic_swap_8 addr:$ptr, GR8:$val))]>;
3038}
3039
Evan Cheng7e032802008-04-18 20:55:36 +00003040// Atomic compare and swap.
Andrew Lenharth26ed8692008-03-01 21:52:34 +00003041let Defs = [EAX, EFLAGS], Uses = [EAX] in {
Evan Cheng7e032802008-04-18 20:55:36 +00003042def LCMPXCHG32 : I<0xB1, MRMDestMem, (outs), (ins i32mem:$ptr, GR32:$swap),
Dan Gohman4d47b9b2009-04-27 15:13:28 +00003043 "lock\n\t"
3044 "cmpxchg{l}\t{$swap, $ptr|$ptr, $swap}",
Evan Cheng32967d22008-03-04 03:20:06 +00003045 [(X86cas addr:$ptr, GR32:$swap, 4)]>, TB, LOCK;
Andrew Lenharthea7da502008-03-01 13:37:02 +00003046}
Dale Johannesen48c1bc22008-10-02 18:53:47 +00003047let Defs = [EAX, EDX, EFLAGS], Uses = [EAX, EBX, ECX, EDX] in {
Anton Korobeynikovf88a6fa2008-07-22 16:22:48 +00003048def LCMPXCHG8B : I<0xC7, MRM1m, (outs), (ins i32mem:$ptr),
Dan Gohman4d47b9b2009-04-27 15:13:28 +00003049 "lock\n\t"
3050 "cmpxchg8b\t$ptr",
Andrew Lenharthd19189e2008-03-05 01:15:49 +00003051 [(X86cas8 addr:$ptr)]>, TB, LOCK;
3052}
Andrew Lenharth26ed8692008-03-01 21:52:34 +00003053
3054let Defs = [AX, EFLAGS], Uses = [AX] in {
Evan Cheng7e032802008-04-18 20:55:36 +00003055def LCMPXCHG16 : I<0xB1, MRMDestMem, (outs), (ins i16mem:$ptr, GR16:$swap),
Dan Gohman4d47b9b2009-04-27 15:13:28 +00003056 "lock\n\t"
3057 "cmpxchg{w}\t{$swap, $ptr|$ptr, $swap}",
Evan Cheng32967d22008-03-04 03:20:06 +00003058 [(X86cas addr:$ptr, GR16:$swap, 2)]>, TB, OpSize, LOCK;
Andrew Lenharthea7da502008-03-01 13:37:02 +00003059}
Andrew Lenharth26ed8692008-03-01 21:52:34 +00003060let Defs = [AL, EFLAGS], Uses = [AL] in {
Evan Cheng7e032802008-04-18 20:55:36 +00003061def LCMPXCHG8 : I<0xB0, MRMDestMem, (outs), (ins i8mem:$ptr, GR8:$swap),
Dan Gohman4d47b9b2009-04-27 15:13:28 +00003062 "lock\n\t"
3063 "cmpxchg{b}\t{$swap, $ptr|$ptr, $swap}",
Evan Cheng32967d22008-03-04 03:20:06 +00003064 [(X86cas addr:$ptr, GR8:$swap, 1)]>, TB, LOCK;
Andrew Lenharthea7da502008-03-01 13:37:02 +00003065}
3066
Evan Cheng7e032802008-04-18 20:55:36 +00003067// Atomic exchange and add
3068let Constraints = "$val = $dst", Defs = [EFLAGS] in {
3069def LXADD32 : I<0xC1, MRMSrcMem, (outs GR32:$dst), (ins i32mem:$ptr, GR32:$val),
Dan Gohman4d47b9b2009-04-27 15:13:28 +00003070 "lock\n\t"
3071 "xadd{l}\t{$val, $ptr|$ptr, $val}",
Mon P Wang28873102008-06-25 08:15:39 +00003072 [(set GR32:$dst, (atomic_load_add_32 addr:$ptr, GR32:$val))]>,
Evan Cheng7e032802008-04-18 20:55:36 +00003073 TB, LOCK;
3074def LXADD16 : I<0xC1, MRMSrcMem, (outs GR16:$dst), (ins i16mem:$ptr, GR16:$val),
Dan Gohman4d47b9b2009-04-27 15:13:28 +00003075 "lock\n\t"
3076 "xadd{w}\t{$val, $ptr|$ptr, $val}",
Mon P Wang28873102008-06-25 08:15:39 +00003077 [(set GR16:$dst, (atomic_load_add_16 addr:$ptr, GR16:$val))]>,
Evan Cheng7e032802008-04-18 20:55:36 +00003078 TB, OpSize, LOCK;
3079def LXADD8 : I<0xC0, MRMSrcMem, (outs GR8:$dst), (ins i8mem:$ptr, GR8:$val),
Dan Gohman4d47b9b2009-04-27 15:13:28 +00003080 "lock\n\t"
3081 "xadd{b}\t{$val, $ptr|$ptr, $val}",
Mon P Wang28873102008-06-25 08:15:39 +00003082 [(set GR8:$dst, (atomic_load_add_8 addr:$ptr, GR8:$val))]>,
Evan Cheng7e032802008-04-18 20:55:36 +00003083 TB, LOCK;
Andrew Lenharthea7da502008-03-01 13:37:02 +00003084}
3085
Mon P Wang28873102008-06-25 08:15:39 +00003086// Atomic exchange, and, or, xor
Mon P Wang63307c32008-05-05 19:05:59 +00003087let Constraints = "$val = $dst", Defs = [EFLAGS],
3088 usesCustomDAGSchedInserter = 1 in {
Dan Gohman9499b712008-05-12 20:22:45 +00003089def ATOMAND32 : I<0, Pseudo, (outs GR32:$dst),(ins i32mem:$ptr, GR32:$val),
Nick Lewycky6ecf5ce2008-12-07 03:49:52 +00003090 "#ATOMAND32 PSEUDO!",
Dale Johannesene00a8a22008-08-28 02:44:49 +00003091 [(set GR32:$dst, (atomic_load_and_32 addr:$ptr, GR32:$val))]>;
Dan Gohman9499b712008-05-12 20:22:45 +00003092def ATOMOR32 : I<0, Pseudo, (outs GR32:$dst),(ins i32mem:$ptr, GR32:$val),
Nick Lewycky6ecf5ce2008-12-07 03:49:52 +00003093 "#ATOMOR32 PSEUDO!",
Dale Johannesene00a8a22008-08-28 02:44:49 +00003094 [(set GR32:$dst, (atomic_load_or_32 addr:$ptr, GR32:$val))]>;
Dan Gohman9499b712008-05-12 20:22:45 +00003095def ATOMXOR32 : I<0, Pseudo,(outs GR32:$dst),(ins i32mem:$ptr, GR32:$val),
Nick Lewycky6ecf5ce2008-12-07 03:49:52 +00003096 "#ATOMXOR32 PSEUDO!",
Dale Johannesene00a8a22008-08-28 02:44:49 +00003097 [(set GR32:$dst, (atomic_load_xor_32 addr:$ptr, GR32:$val))]>;
Andrew Lenharth507a58a2008-06-14 05:48:15 +00003098def ATOMNAND32 : I<0, Pseudo,(outs GR32:$dst),(ins i32mem:$ptr, GR32:$val),
Nick Lewycky6ecf5ce2008-12-07 03:49:52 +00003099 "#ATOMNAND32 PSEUDO!",
Dale Johannesene00a8a22008-08-28 02:44:49 +00003100 [(set GR32:$dst, (atomic_load_nand_32 addr:$ptr, GR32:$val))]>;
Dan Gohman9499b712008-05-12 20:22:45 +00003101def ATOMMIN32: I<0, Pseudo, (outs GR32:$dst), (ins i32mem:$ptr, GR32:$val),
Nick Lewycky6ecf5ce2008-12-07 03:49:52 +00003102 "#ATOMMIN32 PSEUDO!",
Dale Johannesene00a8a22008-08-28 02:44:49 +00003103 [(set GR32:$dst, (atomic_load_min_32 addr:$ptr, GR32:$val))]>;
Dan Gohman9499b712008-05-12 20:22:45 +00003104def ATOMMAX32: I<0, Pseudo, (outs GR32:$dst),(ins i32mem:$ptr, GR32:$val),
Nick Lewycky6ecf5ce2008-12-07 03:49:52 +00003105 "#ATOMMAX32 PSEUDO!",
Dale Johannesene00a8a22008-08-28 02:44:49 +00003106 [(set GR32:$dst, (atomic_load_max_32 addr:$ptr, GR32:$val))]>;
Dan Gohman9499b712008-05-12 20:22:45 +00003107def ATOMUMIN32: I<0, Pseudo, (outs GR32:$dst),(ins i32mem:$ptr, GR32:$val),
Nick Lewycky6ecf5ce2008-12-07 03:49:52 +00003108 "#ATOMUMIN32 PSEUDO!",
Dale Johannesene00a8a22008-08-28 02:44:49 +00003109 [(set GR32:$dst, (atomic_load_umin_32 addr:$ptr, GR32:$val))]>;
Dan Gohman9499b712008-05-12 20:22:45 +00003110def ATOMUMAX32: I<0, Pseudo, (outs GR32:$dst),(ins i32mem:$ptr, GR32:$val),
Nick Lewycky6ecf5ce2008-12-07 03:49:52 +00003111 "#ATOMUMAX32 PSEUDO!",
Dale Johannesene00a8a22008-08-28 02:44:49 +00003112 [(set GR32:$dst, (atomic_load_umax_32 addr:$ptr, GR32:$val))]>;
Dale Johannesen140be2d2008-08-19 18:47:28 +00003113
3114def ATOMAND16 : I<0, Pseudo, (outs GR16:$dst),(ins i16mem:$ptr, GR16:$val),
Nick Lewycky6ecf5ce2008-12-07 03:49:52 +00003115 "#ATOMAND16 PSEUDO!",
Dale Johannesene00a8a22008-08-28 02:44:49 +00003116 [(set GR16:$dst, (atomic_load_and_16 addr:$ptr, GR16:$val))]>;
Dale Johannesen140be2d2008-08-19 18:47:28 +00003117def ATOMOR16 : I<0, Pseudo, (outs GR16:$dst),(ins i16mem:$ptr, GR16:$val),
Nick Lewycky6ecf5ce2008-12-07 03:49:52 +00003118 "#ATOMOR16 PSEUDO!",
Dale Johannesene00a8a22008-08-28 02:44:49 +00003119 [(set GR16:$dst, (atomic_load_or_16 addr:$ptr, GR16:$val))]>;
Dale Johannesen140be2d2008-08-19 18:47:28 +00003120def ATOMXOR16 : I<0, Pseudo,(outs GR16:$dst),(ins i16mem:$ptr, GR16:$val),
Nick Lewycky6ecf5ce2008-12-07 03:49:52 +00003121 "#ATOMXOR16 PSEUDO!",
Dale Johannesene00a8a22008-08-28 02:44:49 +00003122 [(set GR16:$dst, (atomic_load_xor_16 addr:$ptr, GR16:$val))]>;
Dale Johannesen140be2d2008-08-19 18:47:28 +00003123def ATOMNAND16 : I<0, Pseudo,(outs GR16:$dst),(ins i16mem:$ptr, GR16:$val),
Nick Lewycky6ecf5ce2008-12-07 03:49:52 +00003124 "#ATOMNAND16 PSEUDO!",
Dale Johannesene00a8a22008-08-28 02:44:49 +00003125 [(set GR16:$dst, (atomic_load_nand_16 addr:$ptr, GR16:$val))]>;
Dale Johannesen140be2d2008-08-19 18:47:28 +00003126def ATOMMIN16: I<0, Pseudo, (outs GR16:$dst), (ins i16mem:$ptr, GR16:$val),
Nick Lewycky6ecf5ce2008-12-07 03:49:52 +00003127 "#ATOMMIN16 PSEUDO!",
Dale Johannesene00a8a22008-08-28 02:44:49 +00003128 [(set GR16:$dst, (atomic_load_min_16 addr:$ptr, GR16:$val))]>;
Dale Johannesen140be2d2008-08-19 18:47:28 +00003129def ATOMMAX16: I<0, Pseudo, (outs GR16:$dst),(ins i16mem:$ptr, GR16:$val),
Nick Lewycky6ecf5ce2008-12-07 03:49:52 +00003130 "#ATOMMAX16 PSEUDO!",
Dale Johannesene00a8a22008-08-28 02:44:49 +00003131 [(set GR16:$dst, (atomic_load_max_16 addr:$ptr, GR16:$val))]>;
Dale Johannesen140be2d2008-08-19 18:47:28 +00003132def ATOMUMIN16: I<0, Pseudo, (outs GR16:$dst),(ins i16mem:$ptr, GR16:$val),
Nick Lewycky6ecf5ce2008-12-07 03:49:52 +00003133 "#ATOMUMIN16 PSEUDO!",
Dale Johannesene00a8a22008-08-28 02:44:49 +00003134 [(set GR16:$dst, (atomic_load_umin_16 addr:$ptr, GR16:$val))]>;
Dale Johannesen140be2d2008-08-19 18:47:28 +00003135def ATOMUMAX16: I<0, Pseudo, (outs GR16:$dst),(ins i16mem:$ptr, GR16:$val),
Nick Lewycky6ecf5ce2008-12-07 03:49:52 +00003136 "#ATOMUMAX16 PSEUDO!",
Dale Johannesene00a8a22008-08-28 02:44:49 +00003137 [(set GR16:$dst, (atomic_load_umax_16 addr:$ptr, GR16:$val))]>;
Dale Johannesen140be2d2008-08-19 18:47:28 +00003138
3139def ATOMAND8 : I<0, Pseudo, (outs GR8:$dst),(ins i8mem:$ptr, GR8:$val),
Nick Lewycky6ecf5ce2008-12-07 03:49:52 +00003140 "#ATOMAND8 PSEUDO!",
Dale Johannesene00a8a22008-08-28 02:44:49 +00003141 [(set GR8:$dst, (atomic_load_and_8 addr:$ptr, GR8:$val))]>;
Dale Johannesen140be2d2008-08-19 18:47:28 +00003142def ATOMOR8 : I<0, Pseudo, (outs GR8:$dst),(ins i8mem:$ptr, GR8:$val),
Nick Lewycky6ecf5ce2008-12-07 03:49:52 +00003143 "#ATOMOR8 PSEUDO!",
Dale Johannesene00a8a22008-08-28 02:44:49 +00003144 [(set GR8:$dst, (atomic_load_or_8 addr:$ptr, GR8:$val))]>;
Dale Johannesen140be2d2008-08-19 18:47:28 +00003145def ATOMXOR8 : I<0, Pseudo,(outs GR8:$dst),(ins i8mem:$ptr, GR8:$val),
Nick Lewycky6ecf5ce2008-12-07 03:49:52 +00003146 "#ATOMXOR8 PSEUDO!",
Dale Johannesene00a8a22008-08-28 02:44:49 +00003147 [(set GR8:$dst, (atomic_load_xor_8 addr:$ptr, GR8:$val))]>;
Dale Johannesen140be2d2008-08-19 18:47:28 +00003148def ATOMNAND8 : I<0, Pseudo,(outs GR8:$dst),(ins i8mem:$ptr, GR8:$val),
Nick Lewycky6ecf5ce2008-12-07 03:49:52 +00003149 "#ATOMNAND8 PSEUDO!",
Dale Johannesene00a8a22008-08-28 02:44:49 +00003150 [(set GR8:$dst, (atomic_load_nand_8 addr:$ptr, GR8:$val))]>;
Mon P Wang63307c32008-05-05 19:05:59 +00003151}
3152
Dale Johannesen48c1bc22008-10-02 18:53:47 +00003153let Constraints = "$val1 = $dst1, $val2 = $dst2",
3154 Defs = [EFLAGS, EAX, EBX, ECX, EDX],
3155 Uses = [EAX, EBX, ECX, EDX],
Dale Johannesen1b54c7f2008-10-03 19:41:08 +00003156 mayLoad = 1, mayStore = 1,
Dale Johannesen48c1bc22008-10-02 18:53:47 +00003157 usesCustomDAGSchedInserter = 1 in {
3158def ATOMAND6432 : I<0, Pseudo, (outs GR32:$dst1, GR32:$dst2),
3159 (ins i64mem:$ptr, GR32:$val1, GR32:$val2),
Nick Lewycky6ecf5ce2008-12-07 03:49:52 +00003160 "#ATOMAND6432 PSEUDO!", []>;
Dale Johannesen48c1bc22008-10-02 18:53:47 +00003161def ATOMOR6432 : I<0, Pseudo, (outs GR32:$dst1, GR32:$dst2),
3162 (ins i64mem:$ptr, GR32:$val1, GR32:$val2),
Nick Lewycky6ecf5ce2008-12-07 03:49:52 +00003163 "#ATOMOR6432 PSEUDO!", []>;
Dale Johannesen48c1bc22008-10-02 18:53:47 +00003164def ATOMXOR6432 : I<0, Pseudo, (outs GR32:$dst1, GR32:$dst2),
3165 (ins i64mem:$ptr, GR32:$val1, GR32:$val2),
Nick Lewycky6ecf5ce2008-12-07 03:49:52 +00003166 "#ATOMXOR6432 PSEUDO!", []>;
Dale Johannesen48c1bc22008-10-02 18:53:47 +00003167def ATOMNAND6432 : I<0, Pseudo, (outs GR32:$dst1, GR32:$dst2),
3168 (ins i64mem:$ptr, GR32:$val1, GR32:$val2),
Nick Lewycky6ecf5ce2008-12-07 03:49:52 +00003169 "#ATOMNAND6432 PSEUDO!", []>;
Dale Johannesen48c1bc22008-10-02 18:53:47 +00003170def ATOMADD6432 : I<0, Pseudo, (outs GR32:$dst1, GR32:$dst2),
3171 (ins i64mem:$ptr, GR32:$val1, GR32:$val2),
Nick Lewycky6ecf5ce2008-12-07 03:49:52 +00003172 "#ATOMADD6432 PSEUDO!", []>;
Dale Johannesen48c1bc22008-10-02 18:53:47 +00003173def ATOMSUB6432 : I<0, Pseudo, (outs GR32:$dst1, GR32:$dst2),
3174 (ins i64mem:$ptr, GR32:$val1, GR32:$val2),
Nick Lewycky6ecf5ce2008-12-07 03:49:52 +00003175 "#ATOMSUB6432 PSEUDO!", []>;
Dale Johannesen880ae362008-10-03 22:25:52 +00003176def ATOMSWAP6432 : I<0, Pseudo, (outs GR32:$dst1, GR32:$dst2),
3177 (ins i64mem:$ptr, GR32:$val1, GR32:$val2),
Nick Lewycky6ecf5ce2008-12-07 03:49:52 +00003178 "#ATOMSWAP6432 PSEUDO!", []>;
Dale Johannesen48c1bc22008-10-02 18:53:47 +00003179}
3180
Andrew Lenharthab0b9492008-02-21 06:45:13 +00003181//===----------------------------------------------------------------------===//
Evan Cheng510e4782006-01-09 23:10:28 +00003182// Non-Instruction Patterns
3183//===----------------------------------------------------------------------===//
3184
Bill Wendling056292f2008-09-16 21:48:12 +00003185// ConstantPool GlobalAddress, ExternalSymbol, and JumpTable
Evan Cheng71fb8342006-02-25 10:02:21 +00003186def : Pat<(i32 (X86Wrapper tconstpool :$dst)), (MOV32ri tconstpool :$dst)>;
Nate Begeman37efe672006-04-22 18:53:45 +00003187def : Pat<(i32 (X86Wrapper tjumptable :$dst)), (MOV32ri tjumptable :$dst)>;
Nate Begeman6795ebb2008-04-12 00:47:57 +00003188def : Pat<(i32 (X86Wrapper tglobaltlsaddr:$dst)),(MOV32ri tglobaltlsaddr:$dst)>;
Evan Cheng71fb8342006-02-25 10:02:21 +00003189def : Pat<(i32 (X86Wrapper tglobaladdr :$dst)), (MOV32ri tglobaladdr :$dst)>;
3190def : Pat<(i32 (X86Wrapper texternalsym:$dst)), (MOV32ri texternalsym:$dst)>;
3191
Evan Cheng069287d2006-05-16 07:21:53 +00003192def : Pat<(add GR32:$src1, (X86Wrapper tconstpool:$src2)),
3193 (ADD32ri GR32:$src1, tconstpool:$src2)>;
3194def : Pat<(add GR32:$src1, (X86Wrapper tjumptable:$src2)),
3195 (ADD32ri GR32:$src1, tjumptable:$src2)>;
3196def : Pat<(add GR32:$src1, (X86Wrapper tglobaladdr :$src2)),
3197 (ADD32ri GR32:$src1, tglobaladdr:$src2)>;
3198def : Pat<(add GR32:$src1, (X86Wrapper texternalsym:$src2)),
3199 (ADD32ri GR32:$src1, texternalsym:$src2)>;
Evan Cheng71fb8342006-02-25 10:02:21 +00003200
Evan Chengfc8feb12006-05-19 07:30:36 +00003201def : Pat<(store (i32 (X86Wrapper tglobaladdr:$src)), addr:$dst),
Evan Cheng71fb8342006-02-25 10:02:21 +00003202 (MOV32mi addr:$dst, tglobaladdr:$src)>;
Evan Chengfc8feb12006-05-19 07:30:36 +00003203def : Pat<(store (i32 (X86Wrapper texternalsym:$src)), addr:$dst),
Evan Cheng71fb8342006-02-25 10:02:21 +00003204 (MOV32mi addr:$dst, texternalsym:$src)>;
3205
Evan Cheng510e4782006-01-09 23:10:28 +00003206// Calls
Arnold Schwaighoferc85e1712007-10-11 19:40:01 +00003207// tailcall stuff
Evan Cheng069287d2006-05-16 07:21:53 +00003208def : Pat<(X86tailcall GR32:$dst),
Arnold Schwaighoferc85e1712007-10-11 19:40:01 +00003209 (TAILCALL)>;
Evan Chengfea89c12006-04-27 08:40:39 +00003210
Evan Cheng25ab6902006-09-08 06:48:29 +00003211def : Pat<(X86tailcall (i32 tglobaladdr:$dst)),
Arnold Schwaighoferc85e1712007-10-11 19:40:01 +00003212 (TAILCALL)>;
Evan Cheng25ab6902006-09-08 06:48:29 +00003213def : Pat<(X86tailcall (i32 texternalsym:$dst)),
Arnold Schwaighoferc85e1712007-10-11 19:40:01 +00003214 (TAILCALL)>;
3215
3216def : Pat<(X86tcret GR32:$dst, imm:$off),
3217 (TCRETURNri GR32:$dst, imm:$off)>;
3218
3219def : Pat<(X86tcret (i32 tglobaladdr:$dst), imm:$off),
3220 (TCRETURNdi texternalsym:$dst, imm:$off)>;
3221
3222def : Pat<(X86tcret (i32 texternalsym:$dst), imm:$off),
3223 (TCRETURNdi texternalsym:$dst, imm:$off)>;
Evan Chengfea89c12006-04-27 08:40:39 +00003224
Evan Cheng25ab6902006-09-08 06:48:29 +00003225def : Pat<(X86call (i32 tglobaladdr:$dst)),
Evan Cheng510e4782006-01-09 23:10:28 +00003226 (CALLpcrel32 tglobaladdr:$dst)>;
Evan Cheng25ab6902006-09-08 06:48:29 +00003227def : Pat<(X86call (i32 texternalsym:$dst)),
Evan Cheng8700e142006-01-11 06:09:51 +00003228 (CALLpcrel32 texternalsym:$dst)>;
Evan Cheng510e4782006-01-09 23:10:28 +00003229
3230// X86 specific add which produces a flag.
Evan Cheng069287d2006-05-16 07:21:53 +00003231def : Pat<(addc GR32:$src1, GR32:$src2),
3232 (ADD32rr GR32:$src1, GR32:$src2)>;
3233def : Pat<(addc GR32:$src1, (load addr:$src2)),
3234 (ADD32rm GR32:$src1, addr:$src2)>;
3235def : Pat<(addc GR32:$src1, imm:$src2),
3236 (ADD32ri GR32:$src1, imm:$src2)>;
3237def : Pat<(addc GR32:$src1, i32immSExt8:$src2),
3238 (ADD32ri8 GR32:$src1, i32immSExt8:$src2)>;
Evan Cheng510e4782006-01-09 23:10:28 +00003239
Evan Cheng069287d2006-05-16 07:21:53 +00003240def : Pat<(subc GR32:$src1, GR32:$src2),
3241 (SUB32rr GR32:$src1, GR32:$src2)>;
3242def : Pat<(subc GR32:$src1, (load addr:$src2)),
3243 (SUB32rm GR32:$src1, addr:$src2)>;
3244def : Pat<(subc GR32:$src1, imm:$src2),
3245 (SUB32ri GR32:$src1, imm:$src2)>;
3246def : Pat<(subc GR32:$src1, i32immSExt8:$src2),
3247 (SUB32ri8 GR32:$src1, i32immSExt8:$src2)>;
Evan Cheng510e4782006-01-09 23:10:28 +00003248
Chris Lattnerffc0b262006-09-07 20:33:45 +00003249// Comparisons.
3250
3251// TEST R,R is smaller than CMP R,0
Evan Chenge5f62042007-09-29 00:00:36 +00003252def : Pat<(parallel (X86cmp GR8:$src1, 0), (implicit EFLAGS)),
Chris Lattnerffc0b262006-09-07 20:33:45 +00003253 (TEST8rr GR8:$src1, GR8:$src1)>;
Evan Chenge5f62042007-09-29 00:00:36 +00003254def : Pat<(parallel (X86cmp GR16:$src1, 0), (implicit EFLAGS)),
Chris Lattnerffc0b262006-09-07 20:33:45 +00003255 (TEST16rr GR16:$src1, GR16:$src1)>;
Evan Chenge5f62042007-09-29 00:00:36 +00003256def : Pat<(parallel (X86cmp GR32:$src1, 0), (implicit EFLAGS)),
Chris Lattnerffc0b262006-09-07 20:33:45 +00003257 (TEST32rr GR32:$src1, GR32:$src1)>;
3258
Dan Gohmanfbb74862009-01-07 01:00:24 +00003259// Conditional moves with folded loads with operands swapped and conditions
3260// inverted.
3261def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_B, EFLAGS),
3262 (CMOVAE16rm GR16:$src2, addr:$src1)>;
3263def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_B, EFLAGS),
3264 (CMOVAE32rm GR32:$src2, addr:$src1)>;
3265def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_AE, EFLAGS),
3266 (CMOVB16rm GR16:$src2, addr:$src1)>;
3267def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_AE, EFLAGS),
3268 (CMOVB32rm GR32:$src2, addr:$src1)>;
3269def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_E, EFLAGS),
3270 (CMOVNE16rm GR16:$src2, addr:$src1)>;
3271def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_E, EFLAGS),
3272 (CMOVNE32rm GR32:$src2, addr:$src1)>;
3273def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_NE, EFLAGS),
3274 (CMOVE16rm GR16:$src2, addr:$src1)>;
3275def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_NE, EFLAGS),
3276 (CMOVE32rm GR32:$src2, addr:$src1)>;
3277def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_BE, EFLAGS),
3278 (CMOVA16rm GR16:$src2, addr:$src1)>;
3279def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_BE, EFLAGS),
3280 (CMOVA32rm GR32:$src2, addr:$src1)>;
3281def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_A, EFLAGS),
3282 (CMOVBE16rm GR16:$src2, addr:$src1)>;
3283def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_A, EFLAGS),
3284 (CMOVBE32rm GR32:$src2, addr:$src1)>;
3285def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_L, EFLAGS),
3286 (CMOVGE16rm GR16:$src2, addr:$src1)>;
3287def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_L, EFLAGS),
3288 (CMOVGE32rm GR32:$src2, addr:$src1)>;
3289def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_GE, EFLAGS),
3290 (CMOVL16rm GR16:$src2, addr:$src1)>;
3291def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_GE, EFLAGS),
3292 (CMOVL32rm GR32:$src2, addr:$src1)>;
3293def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_LE, EFLAGS),
3294 (CMOVG16rm GR16:$src2, addr:$src1)>;
3295def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_LE, EFLAGS),
3296 (CMOVG32rm GR32:$src2, addr:$src1)>;
3297def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_G, EFLAGS),
3298 (CMOVLE16rm GR16:$src2, addr:$src1)>;
3299def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_G, EFLAGS),
3300 (CMOVLE32rm GR32:$src2, addr:$src1)>;
3301def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_P, EFLAGS),
3302 (CMOVNP16rm GR16:$src2, addr:$src1)>;
3303def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_P, EFLAGS),
3304 (CMOVNP32rm GR32:$src2, addr:$src1)>;
3305def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_NP, EFLAGS),
3306 (CMOVP16rm GR16:$src2, addr:$src1)>;
3307def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_NP, EFLAGS),
3308 (CMOVP32rm GR32:$src2, addr:$src1)>;
3309def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_S, EFLAGS),
3310 (CMOVNS16rm GR16:$src2, addr:$src1)>;
3311def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_S, EFLAGS),
3312 (CMOVNS32rm GR32:$src2, addr:$src1)>;
3313def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_NS, EFLAGS),
3314 (CMOVS16rm GR16:$src2, addr:$src1)>;
3315def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_NS, EFLAGS),
3316 (CMOVS32rm GR32:$src2, addr:$src1)>;
3317def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_O, EFLAGS),
3318 (CMOVNO16rm GR16:$src2, addr:$src1)>;
3319def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_O, EFLAGS),
3320 (CMOVNO32rm GR32:$src2, addr:$src1)>;
3321def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_NO, EFLAGS),
3322 (CMOVO16rm GR16:$src2, addr:$src1)>;
3323def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_NO, EFLAGS),
3324 (CMOVO32rm GR32:$src2, addr:$src1)>;
3325
Duncan Sandsf9c98e62008-01-23 20:39:46 +00003326// zextload bool -> zextload byte
Evan Chenge5d93432006-01-17 07:02:46 +00003327def : Pat<(zextloadi8i1 addr:$src), (MOV8rm addr:$src)>;
Evan Cheng510e4782006-01-09 23:10:28 +00003328def : Pat<(zextloadi16i1 addr:$src), (MOVZX16rm8 addr:$src)>;
3329def : Pat<(zextloadi32i1 addr:$src), (MOVZX32rm8 addr:$src)>;
3330
3331// extload bool -> extload byte
Evan Cheng47137242006-05-05 08:23:07 +00003332def : Pat<(extloadi8i1 addr:$src), (MOV8rm addr:$src)>;
Bill Wendling449416d2008-08-22 20:51:05 +00003333def : Pat<(extloadi16i1 addr:$src), (MOVZX16rm8 addr:$src)>,
3334 Requires<[In32BitMode]>;
Evan Cheng47137242006-05-05 08:23:07 +00003335def : Pat<(extloadi32i1 addr:$src), (MOVZX32rm8 addr:$src)>;
Bill Wendling449416d2008-08-22 20:51:05 +00003336def : Pat<(extloadi16i8 addr:$src), (MOVZX16rm8 addr:$src)>,
3337 Requires<[In32BitMode]>;
Evan Cheng47137242006-05-05 08:23:07 +00003338def : Pat<(extloadi32i8 addr:$src), (MOVZX32rm8 addr:$src)>;
3339def : Pat<(extloadi32i16 addr:$src), (MOVZX32rm16 addr:$src)>;
Evan Cheng510e4782006-01-09 23:10:28 +00003340
Dan Gohman0bfa1bf2008-08-20 21:27:32 +00003341// anyext
Bill Wendling449416d2008-08-22 20:51:05 +00003342def : Pat<(i16 (anyext GR8 :$src)), (MOVZX16rr8 GR8 :$src)>,
3343 Requires<[In32BitMode]>;
3344def : Pat<(i32 (anyext GR8 :$src)), (MOVZX32rr8 GR8 :$src)>,
3345 Requires<[In32BitMode]>;
Dan Gohman0bfa1bf2008-08-20 21:27:32 +00003346def : Pat<(i32 (anyext GR16:$src)),
3347 (INSERT_SUBREG (i32 (IMPLICIT_DEF)), GR16:$src, x86_subreg_16bit)>;
Evan Cheng510e4782006-01-09 23:10:28 +00003348
Evan Cheng1314b002007-12-13 00:43:27 +00003349// (and (i32 load), 255) -> (zextload i8)
Evan Chengd47e0b62008-09-29 17:26:18 +00003350def : Pat<(i32 (and (nvloadi32 addr:$src), (i32 255))),
3351 (MOVZX32rm8 addr:$src)>;
3352def : Pat<(i32 (and (nvloadi32 addr:$src), (i32 65535))),
3353 (MOVZX32rm16 addr:$src)>;
Evan Cheng1314b002007-12-13 00:43:27 +00003354
Evan Chengcfa260b2006-01-06 02:31:59 +00003355//===----------------------------------------------------------------------===//
3356// Some peepholes
3357//===----------------------------------------------------------------------===//
3358
Dan Gohman63f97202008-10-17 01:33:43 +00003359// Odd encoding trick: -128 fits into an 8-bit immediate field while
3360// +128 doesn't, so in this special case use a sub instead of an add.
3361def : Pat<(add GR16:$src1, 128),
3362 (SUB16ri8 GR16:$src1, -128)>;
3363def : Pat<(store (add (loadi16 addr:$dst), 128), addr:$dst),
3364 (SUB16mi8 addr:$dst, -128)>;
3365def : Pat<(add GR32:$src1, 128),
3366 (SUB32ri8 GR32:$src1, -128)>;
3367def : Pat<(store (add (loadi32 addr:$dst), 128), addr:$dst),
3368 (SUB32mi8 addr:$dst, -128)>;
3369
Dan Gohman11ba3b12008-07-30 18:09:17 +00003370// r & (2^16-1) ==> movz
3371def : Pat<(and GR32:$src1, 0xffff),
Dan Gohman21e3dfb2009-04-13 16:09:41 +00003372 (MOVZX32rr16 (EXTRACT_SUBREG GR32:$src1, x86_subreg_16bit))>;
Dan Gohman8a1510d2008-08-06 18:27:21 +00003373// r & (2^8-1) ==> movz
3374def : Pat<(and GR32:$src1, 0xff),
Dan Gohman88c7af02009-04-13 21:06:25 +00003375 (MOVZX32rr8 (EXTRACT_SUBREG (COPY_TO_REGCLASS GR32:$src1, GR32_),
Dan Gohman21e3dfb2009-04-13 16:09:41 +00003376 x86_subreg_8bit))>,
Dan Gohman8a1510d2008-08-06 18:27:21 +00003377 Requires<[In32BitMode]>;
3378// r & (2^8-1) ==> movz
3379def : Pat<(and GR16:$src1, 0xff),
Dan Gohman88c7af02009-04-13 21:06:25 +00003380 (MOVZX16rr8 (EXTRACT_SUBREG (COPY_TO_REGCLASS GR16:$src1, GR16_),
Dan Gohman21e3dfb2009-04-13 16:09:41 +00003381 x86_subreg_8bit))>,
Dan Gohman0bfa1bf2008-08-20 21:27:32 +00003382 Requires<[In32BitMode]>;
3383
3384// sext_inreg patterns
3385def : Pat<(sext_inreg GR32:$src, i16),
Dan Gohman21e3dfb2009-04-13 16:09:41 +00003386 (MOVSX32rr16 (EXTRACT_SUBREG GR32:$src, x86_subreg_16bit))>;
Dan Gohman0bfa1bf2008-08-20 21:27:32 +00003387def : Pat<(sext_inreg GR32:$src, i8),
Dan Gohman88c7af02009-04-13 21:06:25 +00003388 (MOVSX32rr8 (EXTRACT_SUBREG (COPY_TO_REGCLASS GR32:$src, GR32_),
Dan Gohman21e3dfb2009-04-13 16:09:41 +00003389 x86_subreg_8bit))>,
Dan Gohman0bfa1bf2008-08-20 21:27:32 +00003390 Requires<[In32BitMode]>;
3391def : Pat<(sext_inreg GR16:$src, i8),
Dan Gohman88c7af02009-04-13 21:06:25 +00003392 (MOVSX16rr8 (EXTRACT_SUBREG (COPY_TO_REGCLASS GR16:$src, GR16_),
Dan Gohman21e3dfb2009-04-13 16:09:41 +00003393 x86_subreg_8bit))>,
Dan Gohman0bfa1bf2008-08-20 21:27:32 +00003394 Requires<[In32BitMode]>;
3395
3396// trunc patterns
3397def : Pat<(i16 (trunc GR32:$src)),
Dan Gohman21e3dfb2009-04-13 16:09:41 +00003398 (EXTRACT_SUBREG GR32:$src, x86_subreg_16bit)>;
Dan Gohman0bfa1bf2008-08-20 21:27:32 +00003399def : Pat<(i8 (trunc GR32:$src)),
Dan Gohman88c7af02009-04-13 21:06:25 +00003400 (EXTRACT_SUBREG (COPY_TO_REGCLASS GR32:$src, GR32_),
Dan Gohman21e3dfb2009-04-13 16:09:41 +00003401 x86_subreg_8bit)>,
Dan Gohman0bfa1bf2008-08-20 21:27:32 +00003402 Requires<[In32BitMode]>;
3403def : Pat<(i8 (trunc GR16:$src)),
Dan Gohman88c7af02009-04-13 21:06:25 +00003404 (EXTRACT_SUBREG (COPY_TO_REGCLASS GR16:$src, GR16_),
Dan Gohman21e3dfb2009-04-13 16:09:41 +00003405 x86_subreg_8bit)>,
3406 Requires<[In32BitMode]>;
3407
3408// h-register tricks
3409def : Pat<(i8 (trunc (srl_su GR16:$src, (i8 8)))),
Dan Gohman88c7af02009-04-13 21:06:25 +00003410 (EXTRACT_SUBREG (COPY_TO_REGCLASS GR16:$src, GR16_),
Dan Gohman21e3dfb2009-04-13 16:09:41 +00003411 x86_subreg_8bit_hi)>,
3412 Requires<[In32BitMode]>;
3413def : Pat<(i8 (trunc (srl_su GR32:$src, (i8 8)))),
Dan Gohman88c7af02009-04-13 21:06:25 +00003414 (EXTRACT_SUBREG (COPY_TO_REGCLASS GR32:$src, GR32_),
Dan Gohman21e3dfb2009-04-13 16:09:41 +00003415 x86_subreg_8bit_hi)>,
3416 Requires<[In32BitMode]>;
3417def : Pat<(srl_su GR16:$src, (i8 8)),
3418 (EXTRACT_SUBREG
3419 (MOVZX32rr8
Dan Gohman88c7af02009-04-13 21:06:25 +00003420 (EXTRACT_SUBREG (COPY_TO_REGCLASS GR16:$src, GR16_),
Dan Gohman21e3dfb2009-04-13 16:09:41 +00003421 x86_subreg_8bit_hi)),
3422 x86_subreg_16bit)>,
3423 Requires<[In32BitMode]>;
3424def : Pat<(and (srl_su GR32:$src, (i8 8)), (i32 255)),
Dan Gohman88c7af02009-04-13 21:06:25 +00003425 (MOVZX32rr8 (EXTRACT_SUBREG (COPY_TO_REGCLASS GR32:$src, GR32_),
Dan Gohman21e3dfb2009-04-13 16:09:41 +00003426 x86_subreg_8bit_hi))>,
Dan Gohman8a1510d2008-08-06 18:27:21 +00003427 Requires<[In32BitMode]>;
Dan Gohman11ba3b12008-07-30 18:09:17 +00003428
Evan Chengcfa260b2006-01-06 02:31:59 +00003429// (shl x, 1) ==> (add x, x)
Evan Cheng069287d2006-05-16 07:21:53 +00003430def : Pat<(shl GR8 :$src1, (i8 1)), (ADD8rr GR8 :$src1, GR8 :$src1)>;
3431def : Pat<(shl GR16:$src1, (i8 1)), (ADD16rr GR16:$src1, GR16:$src1)>;
3432def : Pat<(shl GR32:$src1, (i8 1)), (ADD32rr GR32:$src1, GR32:$src1)>;
Evan Cheng68b951a2006-01-19 01:56:29 +00003433
Evan Chengeb9f8922008-08-30 02:03:58 +00003434// (shl x (and y, 31)) ==> (shl x, y)
3435def : Pat<(shl GR8:$src1, (and CL:$amt, 31)),
3436 (SHL8rCL GR8:$src1)>;
3437def : Pat<(shl GR16:$src1, (and CL:$amt, 31)),
3438 (SHL16rCL GR16:$src1)>;
3439def : Pat<(shl GR32:$src1, (and CL:$amt, 31)),
3440 (SHL32rCL GR32:$src1)>;
3441def : Pat<(store (shl (loadi8 addr:$dst), (and CL:$amt, 31)), addr:$dst),
3442 (SHL8mCL addr:$dst)>;
3443def : Pat<(store (shl (loadi16 addr:$dst), (and CL:$amt, 31)), addr:$dst),
3444 (SHL16mCL addr:$dst)>;
3445def : Pat<(store (shl (loadi32 addr:$dst), (and CL:$amt, 31)), addr:$dst),
3446 (SHL32mCL addr:$dst)>;
3447
3448def : Pat<(srl GR8:$src1, (and CL:$amt, 31)),
3449 (SHR8rCL GR8:$src1)>;
3450def : Pat<(srl GR16:$src1, (and CL:$amt, 31)),
3451 (SHR16rCL GR16:$src1)>;
3452def : Pat<(srl GR32:$src1, (and CL:$amt, 31)),
3453 (SHR32rCL GR32:$src1)>;
3454def : Pat<(store (srl (loadi8 addr:$dst), (and CL:$amt, 31)), addr:$dst),
3455 (SHR8mCL addr:$dst)>;
3456def : Pat<(store (srl (loadi16 addr:$dst), (and CL:$amt, 31)), addr:$dst),
3457 (SHR16mCL addr:$dst)>;
3458def : Pat<(store (srl (loadi32 addr:$dst), (and CL:$amt, 31)), addr:$dst),
3459 (SHR32mCL addr:$dst)>;
3460
3461def : Pat<(sra GR8:$src1, (and CL:$amt, 31)),
3462 (SAR8rCL GR8:$src1)>;
3463def : Pat<(sra GR16:$src1, (and CL:$amt, 31)),
3464 (SAR16rCL GR16:$src1)>;
3465def : Pat<(sra GR32:$src1, (and CL:$amt, 31)),
3466 (SAR32rCL GR32:$src1)>;
3467def : Pat<(store (sra (loadi8 addr:$dst), (and CL:$amt, 31)), addr:$dst),
3468 (SAR8mCL addr:$dst)>;
3469def : Pat<(store (sra (loadi16 addr:$dst), (and CL:$amt, 31)), addr:$dst),
3470 (SAR16mCL addr:$dst)>;
3471def : Pat<(store (sra (loadi32 addr:$dst), (and CL:$amt, 31)), addr:$dst),
3472 (SAR32mCL addr:$dst)>;
3473
Evan Cheng956044c2006-01-19 23:26:24 +00003474// (or (x >> c) | (y << (32 - c))) ==> (shrd32 x, y, c)
Evan Cheng069287d2006-05-16 07:21:53 +00003475def : Pat<(or (srl GR32:$src1, CL:$amt),
3476 (shl GR32:$src2, (sub 32, CL:$amt))),
3477 (SHRD32rrCL GR32:$src1, GR32:$src2)>;
Evan Cheng68b951a2006-01-19 01:56:29 +00003478
Evan Cheng21d54432006-01-20 01:13:30 +00003479def : Pat<(store (or (srl (loadi32 addr:$dst), CL:$amt),
Evan Cheng069287d2006-05-16 07:21:53 +00003480 (shl GR32:$src2, (sub 32, CL:$amt))), addr:$dst),
3481 (SHRD32mrCL addr:$dst, GR32:$src2)>;
Evan Cheng21d54432006-01-20 01:13:30 +00003482
Dan Gohman74feef22008-10-17 01:23:35 +00003483def : Pat<(or (srl GR32:$src1, (i8 (trunc ECX:$amt))),
3484 (shl GR32:$src2, (i8 (trunc (sub 32, ECX:$amt))))),
3485 (SHRD32rrCL GR32:$src1, GR32:$src2)>;
3486
3487def : Pat<(store (or (srl (loadi32 addr:$dst), (i8 (trunc ECX:$amt))),
3488 (shl GR32:$src2, (i8 (trunc (sub 32, ECX:$amt))))),
3489 addr:$dst),
3490 (SHRD32mrCL addr:$dst, GR32:$src2)>;
3491
3492def : Pat<(shrd GR32:$src1, (i8 imm:$amt1), GR32:$src2, (i8 imm:$amt2)),
3493 (SHRD32rri8 GR32:$src1, GR32:$src2, (i8 imm:$amt1))>;
3494
3495def : Pat<(store (shrd (loadi32 addr:$dst), (i8 imm:$amt1),
3496 GR32:$src2, (i8 imm:$amt2)), addr:$dst),
3497 (SHRD32mri8 addr:$dst, GR32:$src2, (i8 imm:$amt1))>;
3498
Evan Cheng956044c2006-01-19 23:26:24 +00003499// (or (x << c) | (y >> (32 - c))) ==> (shld32 x, y, c)
Evan Cheng069287d2006-05-16 07:21:53 +00003500def : Pat<(or (shl GR32:$src1, CL:$amt),
3501 (srl GR32:$src2, (sub 32, CL:$amt))),
3502 (SHLD32rrCL GR32:$src1, GR32:$src2)>;
Evan Cheng956044c2006-01-19 23:26:24 +00003503
Evan Cheng21d54432006-01-20 01:13:30 +00003504def : Pat<(store (or (shl (loadi32 addr:$dst), CL:$amt),
Evan Cheng069287d2006-05-16 07:21:53 +00003505 (srl GR32:$src2, (sub 32, CL:$amt))), addr:$dst),
3506 (SHLD32mrCL addr:$dst, GR32:$src2)>;
Evan Cheng21d54432006-01-20 01:13:30 +00003507
Dan Gohman74feef22008-10-17 01:23:35 +00003508def : Pat<(or (shl GR32:$src1, (i8 (trunc ECX:$amt))),
3509 (srl GR32:$src2, (i8 (trunc (sub 32, ECX:$amt))))),
3510 (SHLD32rrCL GR32:$src1, GR32:$src2)>;
3511
3512def : Pat<(store (or (shl (loadi32 addr:$dst), (i8 (trunc ECX:$amt))),
3513 (srl GR32:$src2, (i8 (trunc (sub 32, ECX:$amt))))),
3514 addr:$dst),
3515 (SHLD32mrCL addr:$dst, GR32:$src2)>;
3516
3517def : Pat<(shld GR32:$src1, (i8 imm:$amt1), GR32:$src2, (i8 imm:$amt2)),
3518 (SHLD32rri8 GR32:$src1, GR32:$src2, (i8 imm:$amt1))>;
3519
3520def : Pat<(store (shld (loadi32 addr:$dst), (i8 imm:$amt1),
3521 GR32:$src2, (i8 imm:$amt2)), addr:$dst),
3522 (SHLD32mri8 addr:$dst, GR32:$src2, (i8 imm:$amt1))>;
3523
Evan Cheng956044c2006-01-19 23:26:24 +00003524// (or (x >> c) | (y << (16 - c))) ==> (shrd16 x, y, c)
Evan Cheng069287d2006-05-16 07:21:53 +00003525def : Pat<(or (srl GR16:$src1, CL:$amt),
3526 (shl GR16:$src2, (sub 16, CL:$amt))),
3527 (SHRD16rrCL GR16:$src1, GR16:$src2)>;
Evan Cheng956044c2006-01-19 23:26:24 +00003528
Evan Cheng21d54432006-01-20 01:13:30 +00003529def : Pat<(store (or (srl (loadi16 addr:$dst), CL:$amt),
Evan Cheng069287d2006-05-16 07:21:53 +00003530 (shl GR16:$src2, (sub 16, CL:$amt))), addr:$dst),
3531 (SHRD16mrCL addr:$dst, GR16:$src2)>;
Evan Cheng21d54432006-01-20 01:13:30 +00003532
Dan Gohman74feef22008-10-17 01:23:35 +00003533def : Pat<(or (srl GR16:$src1, (i8 (trunc CX:$amt))),
3534 (shl GR16:$src2, (i8 (trunc (sub 16, CX:$amt))))),
3535 (SHRD16rrCL GR16:$src1, GR16:$src2)>;
3536
3537def : Pat<(store (or (srl (loadi16 addr:$dst), (i8 (trunc CX:$amt))),
3538 (shl GR16:$src2, (i8 (trunc (sub 16, CX:$amt))))),
3539 addr:$dst),
3540 (SHRD16mrCL addr:$dst, GR16:$src2)>;
3541
3542def : Pat<(shrd GR16:$src1, (i8 imm:$amt1), GR16:$src2, (i8 imm:$amt2)),
3543 (SHRD16rri8 GR16:$src1, GR16:$src2, (i8 imm:$amt1))>;
3544
3545def : Pat<(store (shrd (loadi16 addr:$dst), (i8 imm:$amt1),
3546 GR16:$src2, (i8 imm:$amt2)), addr:$dst),
3547 (SHRD16mri8 addr:$dst, GR16:$src2, (i8 imm:$amt1))>;
3548
Evan Cheng956044c2006-01-19 23:26:24 +00003549// (or (x << c) | (y >> (16 - c))) ==> (shld16 x, y, c)
Evan Cheng069287d2006-05-16 07:21:53 +00003550def : Pat<(or (shl GR16:$src1, CL:$amt),
3551 (srl GR16:$src2, (sub 16, CL:$amt))),
3552 (SHLD16rrCL GR16:$src1, GR16:$src2)>;
Evan Cheng21d54432006-01-20 01:13:30 +00003553
3554def : Pat<(store (or (shl (loadi16 addr:$dst), CL:$amt),
Evan Cheng069287d2006-05-16 07:21:53 +00003555 (srl GR16:$src2, (sub 16, CL:$amt))), addr:$dst),
3556 (SHLD16mrCL addr:$dst, GR16:$src2)>;
Evan Cheng4e4c71e2006-02-21 20:00:20 +00003557
Dan Gohman74feef22008-10-17 01:23:35 +00003558def : Pat<(or (shl GR16:$src1, (i8 (trunc CX:$amt))),
3559 (srl GR16:$src2, (i8 (trunc (sub 16, CX:$amt))))),
3560 (SHLD16rrCL GR16:$src1, GR16:$src2)>;
3561
3562def : Pat<(store (or (shl (loadi16 addr:$dst), (i8 (trunc CX:$amt))),
3563 (srl GR16:$src2, (i8 (trunc (sub 16, CX:$amt))))),
3564 addr:$dst),
3565 (SHLD16mrCL addr:$dst, GR16:$src2)>;
3566
3567def : Pat<(shld GR16:$src1, (i8 imm:$amt1), GR16:$src2, (i8 imm:$amt2)),
3568 (SHLD16rri8 GR16:$src1, GR16:$src2, (i8 imm:$amt1))>;
3569
3570def : Pat<(store (shld (loadi16 addr:$dst), (i8 imm:$amt1),
3571 GR16:$src2, (i8 imm:$amt2)), addr:$dst),
3572 (SHLD16mri8 addr:$dst, GR16:$src2, (i8 imm:$amt1))>;
3573
Evan Cheng4e4c71e2006-02-21 20:00:20 +00003574//===----------------------------------------------------------------------===//
Dan Gohman076aee32009-03-04 19:44:21 +00003575// EFLAGS-defining Patterns
Bill Wendlingd350e022008-12-12 21:15:41 +00003576//===----------------------------------------------------------------------===//
3577
Dan Gohman076aee32009-03-04 19:44:21 +00003578// Register-Register Addition with EFLAGS result
3579def : Pat<(parallel (X86add_flag GR8:$src1, GR8:$src2),
Bill Wendlingd350e022008-12-12 21:15:41 +00003580 (implicit EFLAGS)),
3581 (ADD8rr GR8:$src1, GR8:$src2)>;
3582
Dan Gohman076aee32009-03-04 19:44:21 +00003583// Register-Register Addition with EFLAGS result
3584def : Pat<(parallel (X86add_flag GR16:$src1, GR16:$src2),
Bill Wendlingd350e022008-12-12 21:15:41 +00003585 (implicit EFLAGS)),
3586 (ADD16rr GR16:$src1, GR16:$src2)>;
Dan Gohman076aee32009-03-04 19:44:21 +00003587def : Pat<(parallel (X86add_flag GR32:$src1, GR32:$src2),
Bill Wendlingd350e022008-12-12 21:15:41 +00003588 (implicit EFLAGS)),
3589 (ADD32rr GR32:$src1, GR32:$src2)>;
3590
Dan Gohman076aee32009-03-04 19:44:21 +00003591// Register-Memory Addition with EFLAGS result
3592def : Pat<(parallel (X86add_flag GR8:$src1, (loadi8 addr:$src2)),
Bill Wendlingd350e022008-12-12 21:15:41 +00003593 (implicit EFLAGS)),
3594 (ADD8rm GR8:$src1, addr:$src2)>;
Dan Gohman076aee32009-03-04 19:44:21 +00003595def : Pat<(parallel (X86add_flag GR16:$src1, (loadi16 addr:$src2)),
Bill Wendlingd350e022008-12-12 21:15:41 +00003596 (implicit EFLAGS)),
3597 (ADD16rm GR16:$src1, addr:$src2)>;
Dan Gohman076aee32009-03-04 19:44:21 +00003598def : Pat<(parallel (X86add_flag GR32:$src1, (loadi32 addr:$src2)),
Bill Wendlingd350e022008-12-12 21:15:41 +00003599 (implicit EFLAGS)),
3600 (ADD32rm GR32:$src1, addr:$src2)>;
3601
Dan Gohman076aee32009-03-04 19:44:21 +00003602// Register-Integer Addition with EFLAGS result
3603def : Pat<(parallel (X86add_flag GR8:$src1, imm:$src2),
Bill Wendlingd350e022008-12-12 21:15:41 +00003604 (implicit EFLAGS)),
3605 (ADD8ri GR8:$src1, imm:$src2)>;
3606
Dan Gohman076aee32009-03-04 19:44:21 +00003607// Register-Integer Addition with EFLAGS result
3608def : Pat<(parallel (X86add_flag GR16:$src1, imm:$src2),
Bill Wendlingd350e022008-12-12 21:15:41 +00003609 (implicit EFLAGS)),
3610 (ADD16ri GR16:$src1, imm:$src2)>;
Dan Gohman076aee32009-03-04 19:44:21 +00003611def : Pat<(parallel (X86add_flag GR32:$src1, imm:$src2),
Bill Wendlingd350e022008-12-12 21:15:41 +00003612 (implicit EFLAGS)),
3613 (ADD32ri GR32:$src1, imm:$src2)>;
Dan Gohman076aee32009-03-04 19:44:21 +00003614def : Pat<(parallel (X86add_flag GR16:$src1, i16immSExt8:$src2),
Bill Wendlingd350e022008-12-12 21:15:41 +00003615 (implicit EFLAGS)),
3616 (ADD16ri8 GR16:$src1, i16immSExt8:$src2)>;
Dan Gohman076aee32009-03-04 19:44:21 +00003617def : Pat<(parallel (X86add_flag GR32:$src1, i32immSExt8:$src2),
Bill Wendlingd350e022008-12-12 21:15:41 +00003618 (implicit EFLAGS)),
3619 (ADD32ri8 GR32:$src1, i32immSExt8:$src2)>;
3620
Dan Gohman076aee32009-03-04 19:44:21 +00003621// Memory-Register Addition with EFLAGS result
3622def : Pat<(parallel (store (X86add_flag (loadi8 addr:$dst), GR8:$src2),
Bill Wendlingd350e022008-12-12 21:15:41 +00003623 addr:$dst),
3624 (implicit EFLAGS)),
3625 (ADD8mr addr:$dst, GR8:$src2)>;
Dan Gohman076aee32009-03-04 19:44:21 +00003626def : Pat<(parallel (store (X86add_flag (loadi16 addr:$dst), GR16:$src2),
Bill Wendlingd350e022008-12-12 21:15:41 +00003627 addr:$dst),
3628 (implicit EFLAGS)),
3629 (ADD16mr addr:$dst, GR16:$src2)>;
Dan Gohman076aee32009-03-04 19:44:21 +00003630def : Pat<(parallel (store (X86add_flag (loadi32 addr:$dst), GR32:$src2),
Bill Wendlingd350e022008-12-12 21:15:41 +00003631 addr:$dst),
3632 (implicit EFLAGS)),
3633 (ADD32mr addr:$dst, GR32:$src2)>;
Dan Gohman076aee32009-03-04 19:44:21 +00003634def : Pat<(parallel (store (X86add_flag (loadi8 addr:$dst), imm:$src2),
Bill Wendlingd350e022008-12-12 21:15:41 +00003635 addr:$dst),
3636 (implicit EFLAGS)),
3637 (ADD8mi addr:$dst, imm:$src2)>;
Dan Gohman076aee32009-03-04 19:44:21 +00003638def : Pat<(parallel (store (X86add_flag (loadi16 addr:$dst), imm:$src2),
Bill Wendlingd350e022008-12-12 21:15:41 +00003639 addr:$dst),
3640 (implicit EFLAGS)),
3641 (ADD16mi addr:$dst, imm:$src2)>;
Dan Gohman076aee32009-03-04 19:44:21 +00003642def : Pat<(parallel (store (X86add_flag (loadi32 addr:$dst), imm:$src2),
Bill Wendlingd350e022008-12-12 21:15:41 +00003643 addr:$dst),
3644 (implicit EFLAGS)),
3645 (ADD32mi addr:$dst, imm:$src2)>;
Dan Gohman076aee32009-03-04 19:44:21 +00003646def : Pat<(parallel (store (X86add_flag (loadi16 addr:$dst), i16immSExt8:$src2),
Bill Wendlingd350e022008-12-12 21:15:41 +00003647 addr:$dst),
3648 (implicit EFLAGS)),
3649 (ADD16mi8 addr:$dst, i16immSExt8:$src2)>;
Dan Gohman076aee32009-03-04 19:44:21 +00003650def : Pat<(parallel (store (X86add_flag (loadi32 addr:$dst), i32immSExt8:$src2),
Bill Wendlingd350e022008-12-12 21:15:41 +00003651 addr:$dst),
3652 (implicit EFLAGS)),
3653 (ADD32mi8 addr:$dst, i32immSExt8:$src2)>;
3654
Dan Gohman076aee32009-03-04 19:44:21 +00003655// Register-Register Subtraction with EFLAGS result
3656def : Pat<(parallel (X86sub_flag GR8:$src1, GR8:$src2),
Bill Wendlingd350e022008-12-12 21:15:41 +00003657 (implicit EFLAGS)),
3658 (SUB8rr GR8:$src1, GR8:$src2)>;
Dan Gohman076aee32009-03-04 19:44:21 +00003659def : Pat<(parallel (X86sub_flag GR16:$src1, GR16:$src2),
Bill Wendlingd350e022008-12-12 21:15:41 +00003660 (implicit EFLAGS)),
3661 (SUB16rr GR16:$src1, GR16:$src2)>;
Dan Gohman076aee32009-03-04 19:44:21 +00003662def : Pat<(parallel (X86sub_flag GR32:$src1, GR32:$src2),
Bill Wendlingd350e022008-12-12 21:15:41 +00003663 (implicit EFLAGS)),
3664 (SUB32rr GR32:$src1, GR32:$src2)>;
3665
Dan Gohman076aee32009-03-04 19:44:21 +00003666// Register-Memory Subtraction with EFLAGS result
3667def : Pat<(parallel (X86sub_flag GR8:$src1, (loadi8 addr:$src2)),
Bill Wendlingd350e022008-12-12 21:15:41 +00003668 (implicit EFLAGS)),
3669 (SUB8rm GR8:$src1, addr:$src2)>;
Dan Gohman076aee32009-03-04 19:44:21 +00003670def : Pat<(parallel (X86sub_flag GR16:$src1, (loadi16 addr:$src2)),
Bill Wendlingd350e022008-12-12 21:15:41 +00003671 (implicit EFLAGS)),
3672 (SUB16rm GR16:$src1, addr:$src2)>;
Dan Gohman076aee32009-03-04 19:44:21 +00003673def : Pat<(parallel (X86sub_flag GR32:$src1, (loadi32 addr:$src2)),
Bill Wendlingd350e022008-12-12 21:15:41 +00003674 (implicit EFLAGS)),
3675 (SUB32rm GR32:$src1, addr:$src2)>;
3676
Dan Gohman076aee32009-03-04 19:44:21 +00003677// Register-Integer Subtraction with EFLAGS result
3678def : Pat<(parallel (X86sub_flag GR8:$src1, imm:$src2),
Bill Wendlingd350e022008-12-12 21:15:41 +00003679 (implicit EFLAGS)),
3680 (SUB8ri GR8:$src1, imm:$src2)>;
Dan Gohman076aee32009-03-04 19:44:21 +00003681def : Pat<(parallel (X86sub_flag GR16:$src1, imm:$src2),
Bill Wendlingd350e022008-12-12 21:15:41 +00003682 (implicit EFLAGS)),
3683 (SUB16ri GR16:$src1, imm:$src2)>;
Dan Gohman076aee32009-03-04 19:44:21 +00003684def : Pat<(parallel (X86sub_flag GR32:$src1, imm:$src2),
Bill Wendlingd350e022008-12-12 21:15:41 +00003685 (implicit EFLAGS)),
3686 (SUB32ri GR32:$src1, imm:$src2)>;
Dan Gohman076aee32009-03-04 19:44:21 +00003687def : Pat<(parallel (X86sub_flag GR16:$src1, i16immSExt8:$src2),
Bill Wendlingd350e022008-12-12 21:15:41 +00003688 (implicit EFLAGS)),
3689 (SUB16ri8 GR16:$src1, i16immSExt8:$src2)>;
Dan Gohman076aee32009-03-04 19:44:21 +00003690def : Pat<(parallel (X86sub_flag GR32:$src1, i32immSExt8:$src2),
Bill Wendlingd350e022008-12-12 21:15:41 +00003691 (implicit EFLAGS)),
3692 (SUB32ri8 GR32:$src1, i32immSExt8:$src2)>;
3693
Dan Gohman076aee32009-03-04 19:44:21 +00003694// Memory-Register Subtraction with EFLAGS result
3695def : Pat<(parallel (store (X86sub_flag (loadi8 addr:$dst), GR8:$src2),
Bill Wendlingd350e022008-12-12 21:15:41 +00003696 addr:$dst),
3697 (implicit EFLAGS)),
3698 (SUB8mr addr:$dst, GR8:$src2)>;
Dan Gohman076aee32009-03-04 19:44:21 +00003699def : Pat<(parallel (store (X86sub_flag (loadi16 addr:$dst), GR16:$src2),
Bill Wendlingd350e022008-12-12 21:15:41 +00003700 addr:$dst),
3701 (implicit EFLAGS)),
3702 (SUB16mr addr:$dst, GR16:$src2)>;
Dan Gohman076aee32009-03-04 19:44:21 +00003703def : Pat<(parallel (store (X86sub_flag (loadi32 addr:$dst), GR32:$src2),
Bill Wendlingd350e022008-12-12 21:15:41 +00003704 addr:$dst),
3705 (implicit EFLAGS)),
3706 (SUB32mr addr:$dst, GR32:$src2)>;
3707
Dan Gohman076aee32009-03-04 19:44:21 +00003708// Memory-Integer Subtraction with EFLAGS result
3709def : Pat<(parallel (store (X86sub_flag (loadi8 addr:$dst), imm:$src2),
Bill Wendlingd350e022008-12-12 21:15:41 +00003710 addr:$dst),
3711 (implicit EFLAGS)),
3712 (SUB8mi addr:$dst, imm:$src2)>;
Dan Gohman076aee32009-03-04 19:44:21 +00003713def : Pat<(parallel (store (X86sub_flag (loadi16 addr:$dst), imm:$src2),
Bill Wendlingd350e022008-12-12 21:15:41 +00003714 addr:$dst),
3715 (implicit EFLAGS)),
3716 (SUB16mi addr:$dst, imm:$src2)>;
Dan Gohman076aee32009-03-04 19:44:21 +00003717def : Pat<(parallel (store (X86sub_flag (loadi32 addr:$dst), imm:$src2),
Bill Wendlingd350e022008-12-12 21:15:41 +00003718 addr:$dst),
3719 (implicit EFLAGS)),
3720 (SUB32mi addr:$dst, imm:$src2)>;
Dan Gohman076aee32009-03-04 19:44:21 +00003721def : Pat<(parallel (store (X86sub_flag (loadi16 addr:$dst), i16immSExt8:$src2),
Bill Wendlingd350e022008-12-12 21:15:41 +00003722 addr:$dst),
3723 (implicit EFLAGS)),
3724 (SUB16mi8 addr:$dst, i16immSExt8:$src2)>;
Dan Gohman076aee32009-03-04 19:44:21 +00003725def : Pat<(parallel (store (X86sub_flag (loadi32 addr:$dst), i32immSExt8:$src2),
Bill Wendlingd350e022008-12-12 21:15:41 +00003726 addr:$dst),
3727 (implicit EFLAGS)),
3728 (SUB32mi8 addr:$dst, i32immSExt8:$src2)>;
3729
3730
Dan Gohman076aee32009-03-04 19:44:21 +00003731// Register-Register Signed Integer Multiply with EFLAGS result
3732def : Pat<(parallel (X86smul_flag GR16:$src1, GR16:$src2),
Bill Wendlingd350e022008-12-12 21:15:41 +00003733 (implicit EFLAGS)),
3734 (IMUL16rr GR16:$src1, GR16:$src2)>;
Dan Gohman076aee32009-03-04 19:44:21 +00003735def : Pat<(parallel (X86smul_flag GR32:$src1, GR32:$src2),
Bill Wendlingd350e022008-12-12 21:15:41 +00003736 (implicit EFLAGS)),
3737 (IMUL32rr GR32:$src1, GR32:$src2)>;
3738
Dan Gohman076aee32009-03-04 19:44:21 +00003739// Register-Memory Signed Integer Multiply with EFLAGS result
3740def : Pat<(parallel (X86smul_flag GR16:$src1, (loadi16 addr:$src2)),
Bill Wendlingd350e022008-12-12 21:15:41 +00003741 (implicit EFLAGS)),
3742 (IMUL16rm GR16:$src1, addr:$src2)>;
Dan Gohman076aee32009-03-04 19:44:21 +00003743def : Pat<(parallel (X86smul_flag GR32:$src1, (loadi32 addr:$src2)),
Bill Wendlingd350e022008-12-12 21:15:41 +00003744 (implicit EFLAGS)),
3745 (IMUL32rm GR32:$src1, addr:$src2)>;
3746
Dan Gohman076aee32009-03-04 19:44:21 +00003747// Register-Integer Signed Integer Multiply with EFLAGS result
3748def : Pat<(parallel (X86smul_flag GR16:$src1, imm:$src2),
Bill Wendlingd350e022008-12-12 21:15:41 +00003749 (implicit EFLAGS)),
3750 (IMUL16rri GR16:$src1, imm:$src2)>;
Dan Gohman076aee32009-03-04 19:44:21 +00003751def : Pat<(parallel (X86smul_flag GR32:$src1, imm:$src2),
Bill Wendlingd350e022008-12-12 21:15:41 +00003752 (implicit EFLAGS)),
3753 (IMUL32rri GR32:$src1, imm:$src2)>;
Dan Gohman076aee32009-03-04 19:44:21 +00003754def : Pat<(parallel (X86smul_flag GR16:$src1, i16immSExt8:$src2),
Bill Wendlingd350e022008-12-12 21:15:41 +00003755 (implicit EFLAGS)),
3756 (IMUL16rri8 GR16:$src1, i16immSExt8:$src2)>;
Dan Gohman076aee32009-03-04 19:44:21 +00003757def : Pat<(parallel (X86smul_flag GR32:$src1, i32immSExt8:$src2),
Bill Wendlingd350e022008-12-12 21:15:41 +00003758 (implicit EFLAGS)),
3759 (IMUL32rri8 GR32:$src1, i32immSExt8:$src2)>;
3760
Dan Gohman076aee32009-03-04 19:44:21 +00003761// Memory-Integer Signed Integer Multiply with EFLAGS result
3762def : Pat<(parallel (X86smul_flag (loadi16 addr:$src1), imm:$src2),
Bill Wendlingd350e022008-12-12 21:15:41 +00003763 (implicit EFLAGS)),
3764 (IMUL16rmi addr:$src1, imm:$src2)>;
Dan Gohman076aee32009-03-04 19:44:21 +00003765def : Pat<(parallel (X86smul_flag (loadi32 addr:$src1), imm:$src2),
Bill Wendlingd350e022008-12-12 21:15:41 +00003766 (implicit EFLAGS)),
3767 (IMUL32rmi addr:$src1, imm:$src2)>;
Dan Gohman076aee32009-03-04 19:44:21 +00003768def : Pat<(parallel (X86smul_flag (loadi16 addr:$src1), i16immSExt8:$src2),
Bill Wendlingd350e022008-12-12 21:15:41 +00003769 (implicit EFLAGS)),
3770 (IMUL16rmi8 addr:$src1, i16immSExt8:$src2)>;
Dan Gohman076aee32009-03-04 19:44:21 +00003771def : Pat<(parallel (X86smul_flag (loadi32 addr:$src1), i32immSExt8:$src2),
Bill Wendlingd350e022008-12-12 21:15:41 +00003772 (implicit EFLAGS)),
3773 (IMUL32rmi8 addr:$src1, i32immSExt8:$src2)>;
3774
Dan Gohman076aee32009-03-04 19:44:21 +00003775// Optimize multiply by 2 with EFLAGS result.
Evan Cheng6a86bd72009-01-27 03:30:42 +00003776let AddedComplexity = 2 in {
Dan Gohman076aee32009-03-04 19:44:21 +00003777def : Pat<(parallel (X86smul_flag GR16:$src1, 2),
Evan Cheng6a86bd72009-01-27 03:30:42 +00003778 (implicit EFLAGS)),
3779 (ADD16rr GR16:$src1, GR16:$src1)>;
3780
Dan Gohman076aee32009-03-04 19:44:21 +00003781def : Pat<(parallel (X86smul_flag GR32:$src1, 2),
Evan Cheng6a86bd72009-01-27 03:30:42 +00003782 (implicit EFLAGS)),
3783 (ADD32rr GR32:$src1, GR32:$src1)>;
3784}
3785
Dan Gohman076aee32009-03-04 19:44:21 +00003786// INC and DEC with EFLAGS result. Note that these do not set CF.
3787def : Pat<(parallel (X86inc_flag GR8:$src), (implicit EFLAGS)),
3788 (INC8r GR8:$src)>;
3789def : Pat<(parallel (store (i8 (X86inc_flag (loadi8 addr:$dst))), addr:$dst),
3790 (implicit EFLAGS)),
3791 (INC8m addr:$dst)>;
3792def : Pat<(parallel (X86dec_flag GR8:$src), (implicit EFLAGS)),
3793 (DEC8r GR8:$src)>;
3794def : Pat<(parallel (store (i8 (X86dec_flag (loadi8 addr:$dst))), addr:$dst),
3795 (implicit EFLAGS)),
3796 (DEC8m addr:$dst)>;
3797
3798def : Pat<(parallel (X86inc_flag GR16:$src), (implicit EFLAGS)),
Dan Gohman1f4af262009-03-05 21:32:23 +00003799 (INC16r GR16:$src)>, Requires<[In32BitMode]>;
Dan Gohman076aee32009-03-04 19:44:21 +00003800def : Pat<(parallel (store (i16 (X86inc_flag (loadi16 addr:$dst))), addr:$dst),
3801 (implicit EFLAGS)),
Dan Gohman1f4af262009-03-05 21:32:23 +00003802 (INC16m addr:$dst)>, Requires<[In32BitMode]>;
Dan Gohman076aee32009-03-04 19:44:21 +00003803def : Pat<(parallel (X86dec_flag GR16:$src), (implicit EFLAGS)),
Dan Gohman1f4af262009-03-05 21:32:23 +00003804 (DEC16r GR16:$src)>, Requires<[In32BitMode]>;
Dan Gohman076aee32009-03-04 19:44:21 +00003805def : Pat<(parallel (store (i16 (X86dec_flag (loadi16 addr:$dst))), addr:$dst),
3806 (implicit EFLAGS)),
Dan Gohman1f4af262009-03-05 21:32:23 +00003807 (DEC16m addr:$dst)>, Requires<[In32BitMode]>;
Dan Gohman076aee32009-03-04 19:44:21 +00003808
3809def : Pat<(parallel (X86inc_flag GR32:$src), (implicit EFLAGS)),
Dan Gohman1f4af262009-03-05 21:32:23 +00003810 (INC32r GR32:$src)>, Requires<[In32BitMode]>;
Dan Gohman076aee32009-03-04 19:44:21 +00003811def : Pat<(parallel (store (i32 (X86inc_flag (loadi32 addr:$dst))), addr:$dst),
3812 (implicit EFLAGS)),
Dan Gohman1f4af262009-03-05 21:32:23 +00003813 (INC32m addr:$dst)>, Requires<[In32BitMode]>;
Dan Gohman076aee32009-03-04 19:44:21 +00003814def : Pat<(parallel (X86dec_flag GR32:$src), (implicit EFLAGS)),
Dan Gohman1f4af262009-03-05 21:32:23 +00003815 (DEC32r GR32:$src)>, Requires<[In32BitMode]>;
Dan Gohman076aee32009-03-04 19:44:21 +00003816def : Pat<(parallel (store (i32 (X86dec_flag (loadi32 addr:$dst))), addr:$dst),
3817 (implicit EFLAGS)),
Dan Gohman1f4af262009-03-05 21:32:23 +00003818 (DEC32m addr:$dst)>, Requires<[In32BitMode]>;
Dan Gohman076aee32009-03-04 19:44:21 +00003819
Bill Wendlingd350e022008-12-12 21:15:41 +00003820//===----------------------------------------------------------------------===//
Evan Cheng4e4c71e2006-02-21 20:00:20 +00003821// Floating Point Stack Support
3822//===----------------------------------------------------------------------===//
3823
3824include "X86InstrFPStack.td"
3825
3826//===----------------------------------------------------------------------===//
Evan Chengc64a1a92007-07-31 08:04:03 +00003827// X86-64 Support
3828//===----------------------------------------------------------------------===//
3829
Chris Lattner36fe6d22008-01-10 05:50:42 +00003830include "X86Instr64bit.td"
Evan Chengc64a1a92007-07-31 08:04:03 +00003831
3832//===----------------------------------------------------------------------===//
Evan Cheng4e4c71e2006-02-21 20:00:20 +00003833// XMM Floating point support (requires SSE / SSE2)
3834//===----------------------------------------------------------------------===//
3835
3836include "X86InstrSSE.td"
Evan Cheng80f54042008-04-25 18:19:54 +00003837
3838//===----------------------------------------------------------------------===//
3839// MMX and XMM Packed Integer support (requires MMX, SSE, and SSE2)
3840//===----------------------------------------------------------------------===//
3841
3842include "X86InstrMMX.td"