blob: c8815c0fb66d53a5f928d9e01408ae3dff88793e [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>]>;
Evan Chenge5f62042007-09-29 00:00:36 +000037def SDTX86BrCond : SDTypeProfile<0, 3,
Evan Cheng0488db92007-09-25 01:57:46 +000038 [SDTCisVT<0, OtherVT>,
39 SDTCisVT<1, i8>, SDTCisVT<2, i32>]>;
Evan Chengaed7c722005-12-17 01:24:02 +000040
Evan Chenge5f62042007-09-29 00:00:36 +000041def SDTX86SetCC : SDTypeProfile<1, 2,
Evan Cheng0488db92007-09-25 01:57:46 +000042 [SDTCisVT<0, i8>,
43 SDTCisVT<1, i8>, SDTCisVT<2, i32>]>;
Evan Chengd5781fc2005-12-21 20:21:51 +000044
Andrew Lenharth26ed8692008-03-01 21:52:34 +000045def SDTX86cas : SDTypeProfile<0, 3, [SDTCisPtrTy<0>, SDTCisInt<1>,
46 SDTCisVT<2, i8>]>;
Andrew Lenharthd19189e2008-03-05 01:15:49 +000047def SDTX86cas8 : SDTypeProfile<0, 1, [SDTCisPtrTy<0>]>;
Andrew Lenharth26ed8692008-03-01 21:52:34 +000048
Dale Johannesen48c1bc22008-10-02 18:53:47 +000049def SDTX86atomicBinary : SDTypeProfile<2, 3, [SDTCisInt<0>, SDTCisInt<1>,
50 SDTCisPtrTy<2>, SDTCisInt<3>,SDTCisInt<4>]>;
Chris Lattner447ff682008-03-11 03:23:40 +000051def SDTX86Ret : SDTypeProfile<0, -1, [SDTCisVT<0, i16>]>;
Evan Cheng898101c2005-12-19 23:12:38 +000052
Sean Callanan1c97ceb2009-06-23 23:25:37 +000053def SDT_X86CallSeqStart : SDCallSeqStart<[SDTCisVT<0, i32>]>;
54def SDT_X86CallSeqEnd : SDCallSeqEnd<[SDTCisVT<0, i32>,
55 SDTCisVT<1, i32>]>;
Evan Chenge3413162006-01-09 18:33:28 +000056
Dan Gohmand35121a2008-05-29 19:57:41 +000057def SDT_X86Call : SDTypeProfile<0, -1, [SDTCisVT<0, iPTR>]>;
Evan Chenge3413162006-01-09 18:33:28 +000058
Dan Gohmand6708ea2009-08-15 01:38:56 +000059def SDT_X86VASTART_SAVE_XMM_REGS : SDTypeProfile<0, -1, [SDTCisVT<0, i8>,
60 SDTCisVT<1, iPTR>,
61 SDTCisVT<2, iPTR>]>;
62
Evan Cheng67f92a72006-01-11 22:15:48 +000063def SDTX86RepStr : SDTypeProfile<0, 1, [SDTCisVT<0, OtherVT>]>;
64
Evan Chenge3413162006-01-09 18:33:28 +000065def SDTX86RdTsc : SDTypeProfile<0, 0, []>;
Evan Chengd90eb7f2006-01-05 00:27:02 +000066
Evan Cheng71fb8342006-02-25 10:02:21 +000067def SDTX86Wrapper : SDTypeProfile<1, 1, [SDTCisSameAs<0, 1>, SDTCisPtrTy<0>]>;
68
Rafael Espindola2ee3db32009-04-17 14:35:58 +000069def SDT_X86TLSADDR : SDTypeProfile<0, 1, [SDTCisInt<0>]>;
Lauro Ramos Venanciob3a04172007-04-20 21:38:10 +000070
Rafael Espindola094fad32009-04-08 21:14:34 +000071def SDT_X86SegmentBaseAddress : SDTypeProfile<1, 1, [SDTCisPtrTy<0>]>;
Lauro Ramos Venanciob3a04172007-04-20 21:38:10 +000072
Anton Korobeynikov2365f512007-07-14 14:06:15 +000073def SDT_X86EHRET : SDTypeProfile<0, 1, [SDTCisInt<0>]>;
74
Arnold Schwaighoferc85e1712007-10-11 19:40:01 +000075def SDT_X86TCRET : SDTypeProfile<0, 2, [SDTCisPtrTy<0>, SDTCisVT<1, i32>]>;
76
Evan Cheng18efe262007-12-14 02:13:44 +000077def X86bsf : SDNode<"X86ISD::BSF", SDTIntUnaryOp>;
78def X86bsr : SDNode<"X86ISD::BSR", SDTIntUnaryOp>;
Evan Chenge3413162006-01-09 18:33:28 +000079def X86shld : SDNode<"X86ISD::SHLD", SDTIntShiftDOp>;
80def X86shrd : SDNode<"X86ISD::SHRD", SDTIntShiftDOp>;
Evan Chengb077b842005-12-21 02:39:21 +000081
Evan Chenge5f62042007-09-29 00:00:36 +000082def X86cmp : SDNode<"X86ISD::CMP" , SDTX86CmpTest>;
Evan Chengb077b842005-12-21 02:39:21 +000083
Dan Gohmanc7a37d42008-12-23 22:45:23 +000084def X86bt : SDNode<"X86ISD::BT", SDTX86CmpTest>;
85
Evan Chenge5f62042007-09-29 00:00:36 +000086def X86cmov : SDNode<"X86ISD::CMOV", SDTX86Cmov>;
Evan Chenge3413162006-01-09 18:33:28 +000087def X86brcond : SDNode<"X86ISD::BRCOND", SDTX86BrCond,
Evan Cheng0488db92007-09-25 01:57:46 +000088 [SDNPHasChain]>;
Evan Chenge5f62042007-09-29 00:00:36 +000089def X86setcc : SDNode<"X86ISD::SETCC", SDTX86SetCC>;
Evan Chengb077b842005-12-21 02:39:21 +000090
Andrew Lenharth26ed8692008-03-01 21:52:34 +000091def X86cas : SDNode<"X86ISD::LCMPXCHG_DAG", SDTX86cas,
92 [SDNPHasChain, SDNPInFlag, SDNPOutFlag, SDNPMayStore,
93 SDNPMayLoad]>;
Andrew Lenharthd19189e2008-03-05 01:15:49 +000094def X86cas8 : SDNode<"X86ISD::LCMPXCHG8_DAG", SDTX86cas8,
95 [SDNPHasChain, SDNPInFlag, SDNPOutFlag, SDNPMayStore,
96 SDNPMayLoad]>;
Dale Johannesen48c1bc22008-10-02 18:53:47 +000097def X86AtomAdd64 : SDNode<"X86ISD::ATOMADD64_DAG", SDTX86atomicBinary,
98 [SDNPHasChain, SDNPMayStore,
99 SDNPMayLoad, SDNPMemOperand]>;
100def X86AtomSub64 : SDNode<"X86ISD::ATOMSUB64_DAG", SDTX86atomicBinary,
101 [SDNPHasChain, SDNPMayStore,
102 SDNPMayLoad, SDNPMemOperand]>;
103def X86AtomOr64 : SDNode<"X86ISD::ATOMOR64_DAG", SDTX86atomicBinary,
104 [SDNPHasChain, SDNPMayStore,
105 SDNPMayLoad, SDNPMemOperand]>;
106def X86AtomXor64 : SDNode<"X86ISD::ATOMXOR64_DAG", SDTX86atomicBinary,
107 [SDNPHasChain, SDNPMayStore,
108 SDNPMayLoad, SDNPMemOperand]>;
109def X86AtomAnd64 : SDNode<"X86ISD::ATOMAND64_DAG", SDTX86atomicBinary,
110 [SDNPHasChain, SDNPMayStore,
111 SDNPMayLoad, SDNPMemOperand]>;
112def X86AtomNand64 : SDNode<"X86ISD::ATOMNAND64_DAG", SDTX86atomicBinary,
113 [SDNPHasChain, SDNPMayStore,
114 SDNPMayLoad, SDNPMemOperand]>;
Dale Johannesen880ae362008-10-03 22:25:52 +0000115def X86AtomSwap64 : SDNode<"X86ISD::ATOMSWAP64_DAG", SDTX86atomicBinary,
116 [SDNPHasChain, SDNPMayStore,
117 SDNPMayLoad, SDNPMemOperand]>;
Evan Chenge3413162006-01-09 18:33:28 +0000118def X86retflag : SDNode<"X86ISD::RET_FLAG", SDTX86Ret,
119 [SDNPHasChain, SDNPOptInFlag]>;
Evan Chengb077b842005-12-21 02:39:21 +0000120
Dan Gohmand6708ea2009-08-15 01:38:56 +0000121def X86vastart_save_xmm_regs :
122 SDNode<"X86ISD::VASTART_SAVE_XMM_REGS",
123 SDT_X86VASTART_SAVE_XMM_REGS,
124 [SDNPHasChain]>;
125
Evan Chenge3413162006-01-09 18:33:28 +0000126def X86callseq_start :
127 SDNode<"ISD::CALLSEQ_START", SDT_X86CallSeqStart,
Evan Chengbb7b8442006-08-11 09:03:33 +0000128 [SDNPHasChain, SDNPOutFlag]>;
Evan Chenge3413162006-01-09 18:33:28 +0000129def X86callseq_end :
130 SDNode<"ISD::CALLSEQ_END", SDT_X86CallSeqEnd,
Arnold Schwaighoferc85e1712007-10-11 19:40:01 +0000131 [SDNPHasChain, SDNPOptInFlag, SDNPOutFlag]>;
Evan Chengb077b842005-12-21 02:39:21 +0000132
Evan Chenge3413162006-01-09 18:33:28 +0000133def X86call : SDNode<"X86ISD::CALL", SDT_X86Call,
134 [SDNPHasChain, SDNPOutFlag, SDNPOptInFlag]>;
Evan Chengaed7c722005-12-17 01:24:02 +0000135
Evan Cheng67f92a72006-01-11 22:15:48 +0000136def X86rep_stos: SDNode<"X86ISD::REP_STOS", SDTX86RepStr,
Chris Lattner9b37aaf2008-01-10 05:12:37 +0000137 [SDNPHasChain, SDNPInFlag, SDNPOutFlag, SDNPMayStore]>;
Evan Cheng67f92a72006-01-11 22:15:48 +0000138def X86rep_movs: SDNode<"X86ISD::REP_MOVS", SDTX86RepStr,
Chris Lattner9b37aaf2008-01-10 05:12:37 +0000139 [SDNPHasChain, SDNPInFlag, SDNPOutFlag, SDNPMayStore,
140 SDNPMayLoad]>;
Evan Cheng67f92a72006-01-11 22:15:48 +0000141
Evan Chenge3413162006-01-09 18:33:28 +0000142def X86rdtsc : SDNode<"X86ISD::RDTSC_DAG",SDTX86RdTsc,
Chris Lattnerba7e7562008-01-10 07:59:24 +0000143 [SDNPHasChain, SDNPOutFlag, SDNPSideEffect]>;
Evan Chengd90eb7f2006-01-05 00:27:02 +0000144
Evan Cheng0085a282006-11-30 21:55:46 +0000145def X86Wrapper : SDNode<"X86ISD::Wrapper", SDTX86Wrapper>;
146def X86WrapperRIP : SDNode<"X86ISD::WrapperRIP", SDTX86Wrapper>;
Evan Cheng71fb8342006-02-25 10:02:21 +0000147
Lauro Ramos Venanciob3a04172007-04-20 21:38:10 +0000148def X86tlsaddr : SDNode<"X86ISD::TLSADDR", SDT_X86TLSADDR,
Anton Korobeynikov6625eff2008-05-04 21:36:32 +0000149 [SDNPHasChain, SDNPOptInFlag, SDNPOutFlag]>;
Rafael Espindola094fad32009-04-08 21:14:34 +0000150def X86SegmentBaseAddress : SDNode<"X86ISD::SegmentBaseAddress",
151 SDT_X86SegmentBaseAddress, []>;
Lauro Ramos Venanciob3a04172007-04-20 21:38:10 +0000152
Anton Korobeynikov2365f512007-07-14 14:06:15 +0000153def X86ehret : SDNode<"X86ISD::EH_RETURN", SDT_X86EHRET,
154 [SDNPHasChain]>;
155
Arnold Schwaighoferc85e1712007-10-11 19:40:01 +0000156def X86tcret : SDNode<"X86ISD::TC_RETURN", SDT_X86TCRET,
157 [SDNPHasChain, SDNPOptInFlag]>;
Lauro Ramos Venanciob3a04172007-04-20 21:38:10 +0000158
Dan Gohman076aee32009-03-04 19:44:21 +0000159def X86add_flag : SDNode<"X86ISD::ADD", SDTBinaryArithWithFlags>;
160def X86sub_flag : SDNode<"X86ISD::SUB", SDTBinaryArithWithFlags>;
161def X86smul_flag : SDNode<"X86ISD::SMUL", SDTBinaryArithWithFlags>;
162def X86umul_flag : SDNode<"X86ISD::UMUL", SDTUnaryArithWithFlags>;
163def X86inc_flag : SDNode<"X86ISD::INC", SDTUnaryArithWithFlags>;
164def X86dec_flag : SDNode<"X86ISD::DEC", SDTUnaryArithWithFlags>;
Bill Wendlingab55ebd2008-12-12 00:56:36 +0000165
Evan Cheng73f24c92009-03-30 21:36:47 +0000166def X86mul_imm : SDNode<"X86ISD::MUL_IMM", SDTIntBinOp>;
167
Evan Chengaed7c722005-12-17 01:24:02 +0000168//===----------------------------------------------------------------------===//
169// X86 Operand Definitions.
170//
171
Chris Lattner7680e732009-06-20 19:34:09 +0000172def i32imm_pcrel : Operand<i32> {
173 let PrintMethod = "print_pcrel_imm";
174}
175
Dan Gohmana4714e02009-07-30 01:56:29 +0000176// A version of ptr_rc which excludes SP, ESP, and RSP. This is used for
177// the index operand of an address, to conform to x86 encoding restrictions.
178def ptr_rc_nosp : PointerLikeRegClass<1>;
Chris Lattner7680e732009-06-20 19:34:09 +0000179
Chris Lattner66fa1dc2004-08-11 02:25:00 +0000180// *mem - Operand definitions for the funky X86 addressing mode operands.
181//
Daniel Dunbar338825c2009-08-10 18:41:10 +0000182def X86MemAsmOperand : AsmOperandClass {
183 let Name = "Mem";
Daniel Dunbar8e001172009-08-10 19:08:02 +0000184 let SuperClass = ?;
Daniel Dunbar338825c2009-08-10 18:41:10 +0000185}
Evan Chengaf78ef52006-05-17 21:21:41 +0000186class X86MemOperand<string printMethod> : Operand<iPTR> {
Nate Begeman391c5d22005-11-30 18:54:35 +0000187 let PrintMethod = printMethod;
Dan Gohmana4714e02009-07-30 01:56:29 +0000188 let MIOperandInfo = (ops ptr_rc, i8imm, ptr_rc_nosp, i32imm, i8imm);
Daniel Dunbar338825c2009-08-10 18:41:10 +0000189 let ParserMatchClass = X86MemAsmOperand;
Chris Lattner66fa1dc2004-08-11 02:25:00 +0000190}
Nate Begeman391c5d22005-11-30 18:54:35 +0000191
Sean Callanan9947bbb2009-09-03 00:04:47 +0000192def opaque32mem : X86MemOperand<"printopaquemem">;
193def opaque48mem : X86MemOperand<"printopaquemem">;
194def opaque80mem : X86MemOperand<"printopaquemem">;
195
Chris Lattner45432512005-12-17 19:47:05 +0000196def i8mem : X86MemOperand<"printi8mem">;
197def i16mem : X86MemOperand<"printi16mem">;
198def i32mem : X86MemOperand<"printi32mem">;
199def i64mem : X86MemOperand<"printi64mem">;
Evan Cheng470a6ad2006-02-22 02:26:30 +0000200def i128mem : X86MemOperand<"printi128mem">;
David Greenef0c3d022009-06-30 19:24:59 +0000201def i256mem : X86MemOperand<"printi256mem">;
Chris Lattner45432512005-12-17 19:47:05 +0000202def f32mem : X86MemOperand<"printf32mem">;
203def f64mem : X86MemOperand<"printf64mem">;
Dale Johannesen59a58732007-08-05 18:49:15 +0000204def f80mem : X86MemOperand<"printf80mem">;
Evan Cheng223547a2006-01-31 22:28:30 +0000205def f128mem : X86MemOperand<"printf128mem">;
David Greenef0c3d022009-06-30 19:24:59 +0000206def f256mem : X86MemOperand<"printf256mem">;
Nate Begeman391c5d22005-11-30 18:54:35 +0000207
Dan Gohman21e3dfb2009-04-13 16:09:41 +0000208// A version of i8mem for use on x86-64 that uses GR64_NOREX instead of
209// plain GR64, so that it doesn't potentially require a REX prefix.
210def i8mem_NOREX : Operand<i64> {
211 let PrintMethod = "printi8mem";
Dan Gohmana4714e02009-07-30 01:56:29 +0000212 let MIOperandInfo = (ops GR64_NOREX, i8imm, GR64_NOREX_NOSP, i32imm, i8imm);
Daniel Dunbar338825c2009-08-10 18:41:10 +0000213 let ParserMatchClass = X86MemAsmOperand;
Dan Gohman21e3dfb2009-04-13 16:09:41 +0000214}
215
Evan Cheng25ab6902006-09-08 06:48:29 +0000216def lea32mem : Operand<i32> {
Rafael Espindola094fad32009-04-08 21:14:34 +0000217 let PrintMethod = "printlea32mem";
Dan Gohman74f6f9a2009-08-05 17:40:24 +0000218 let MIOperandInfo = (ops GR32, i8imm, GR32_NOSP, i32imm);
Daniel Dunbar338825c2009-08-10 18:41:10 +0000219 let ParserMatchClass = X86MemAsmOperand;
Evan Cheng25ab6902006-09-08 06:48:29 +0000220}
221
Nate Begeman16b04f32005-07-15 00:38:55 +0000222def SSECC : Operand<i8> {
223 let PrintMethod = "printSSECC";
224}
Chris Lattner66fa1dc2004-08-11 02:25:00 +0000225
Evan Cheng7ccced62006-02-18 00:15:05 +0000226def piclabel: Operand<i32> {
227 let PrintMethod = "printPICLabel";
228}
229
Daniel Dunbar338825c2009-08-10 18:41:10 +0000230def ImmSExt8AsmOperand : AsmOperandClass {
231 let Name = "ImmSExt8";
232 let SuperClass = ImmAsmOperand;
233}
234
Chris Lattnerf124d5e2005-11-18 01:04:42 +0000235// A couple of more descriptive operand definitions.
236// 16-bits but only 8 bits are significant.
Daniel Dunbar5fe63382009-08-09 07:20:21 +0000237def i16i8imm : Operand<i16> {
Daniel Dunbar338825c2009-08-10 18:41:10 +0000238 let ParserMatchClass = ImmSExt8AsmOperand;
Daniel Dunbar5fe63382009-08-09 07:20:21 +0000239}
Chris Lattnerf124d5e2005-11-18 01:04:42 +0000240// 32-bits but only 8 bits are significant.
Daniel Dunbar5fe63382009-08-09 07:20:21 +0000241def i32i8imm : Operand<i32> {
Daniel Dunbar338825c2009-08-10 18:41:10 +0000242 let ParserMatchClass = ImmSExt8AsmOperand;
Daniel Dunbar5fe63382009-08-09 07:20:21 +0000243}
Chris Lattnerf124d5e2005-11-18 01:04:42 +0000244
Chris Lattner7680e732009-06-20 19:34:09 +0000245// Branch targets have OtherVT type and print as pc-relative values.
246def brtarget : Operand<OtherVT> {
247 let PrintMethod = "print_pcrel_imm";
248}
Evan Chengd35b8c12005-12-04 08:19:43 +0000249
Evan Cheng77159e32009-07-21 06:00:18 +0000250def brtarget8 : Operand<OtherVT> {
251 let PrintMethod = "print_pcrel_imm";
252}
253
Evan Chengaed7c722005-12-17 01:24:02 +0000254//===----------------------------------------------------------------------===//
255// X86 Complex Pattern Definitions.
256//
257
Evan Chengec693f72005-12-08 02:01:35 +0000258// Define X86 specific addressing mode.
Rafael Espindola094fad32009-04-08 21:14:34 +0000259def addr : ComplexPattern<iPTR, 5, "SelectAddr", [], []>;
Evan Cheng25ab6902006-09-08 06:48:29 +0000260def lea32addr : ComplexPattern<i32, 4, "SelectLEAAddr",
Dan Gohmana98634b2009-08-02 16:09:17 +0000261 [add, sub, mul, X86mul_imm, shl, or, frameindex],
262 []>;
Chris Lattner5c0b16d2009-06-20 20:38:48 +0000263def tls32addr : ComplexPattern<i32, 4, "SelectTLSADDRAddr",
264 [tglobaltlsaddr], []>;
Evan Chengec693f72005-12-08 02:01:35 +0000265
Evan Chengaed7c722005-12-17 01:24:02 +0000266//===----------------------------------------------------------------------===//
Evan Chengbbc8ddb2005-12-20 22:59:51 +0000267// X86 Instruction Predicate Definitions.
Evan Cheng28b514392006-12-05 19:50:18 +0000268def HasMMX : Predicate<"Subtarget->hasMMX()">;
269def HasSSE1 : Predicate<"Subtarget->hasSSE1()">;
270def HasSSE2 : Predicate<"Subtarget->hasSSE2()">;
271def HasSSE3 : Predicate<"Subtarget->hasSSE3()">;
Bill Wendlingbb1ee052007-04-10 22:10:25 +0000272def HasSSSE3 : Predicate<"Subtarget->hasSSSE3()">;
Nate Begeman63ec90a2008-02-03 07:18:54 +0000273def HasSSE41 : Predicate<"Subtarget->hasSSE41()">;
274def HasSSE42 : Predicate<"Subtarget->hasSSE42()">;
David Greene343dadb2009-06-26 22:46:54 +0000275def HasSSE4A : Predicate<"Subtarget->hasSSE4A()">;
276def HasAVX : Predicate<"Subtarget->hasAVX()">;
277def HasFMA3 : Predicate<"Subtarget->hasFMA3()">;
278def HasFMA4 : Predicate<"Subtarget->hasFMA4()">;
Dale Johannesenf1fc3a82007-09-23 14:52:20 +0000279def FPStackf32 : Predicate<"!Subtarget->hasSSE1()">;
280def FPStackf64 : Predicate<"!Subtarget->hasSSE2()">;
Evan Cheng28b514392006-12-05 19:50:18 +0000281def In32BitMode : Predicate<"!Subtarget->is64Bit()">;
282def In64BitMode : Predicate<"Subtarget->is64Bit()">;
Anton Korobeynikovcf6b7392009-08-03 08:12:53 +0000283def IsWin64 : Predicate<"Subtarget->isTargetWin64()">;
284def NotWin64 : Predicate<"!Subtarget->isTargetWin64()">;
Anton Korobeynikovd7697d02009-08-06 11:23:24 +0000285def SmallCode : Predicate<"TM.getCodeModel() == CodeModel::Small">;
286def KernelCode : Predicate<"TM.getCodeModel() == CodeModel::Kernel">;
287def FarData : Predicate<"TM.getCodeModel() != CodeModel::Small &&"
Anton Korobeynikov186fa1d2009-08-06 09:11:19 +0000288 "TM.getCodeModel() != CodeModel::Kernel">;
Anton Korobeynikovd7697d02009-08-06 11:23:24 +0000289def NearData : Predicate<"TM.getCodeModel() == CodeModel::Small ||"
290 "TM.getCodeModel() == CodeModel::Kernel">;
Evan Cheng28b514392006-12-05 19:50:18 +0000291def IsStatic : Predicate<"TM.getRelocationModel() == Reloc::Static">;
Evan Chengb7a75a52008-09-26 23:41:32 +0000292def OptForSpeed : Predicate<"!OptForSize">;
Evan Chengccb69762009-01-02 05:35:45 +0000293def FastBTMem : Predicate<"!Subtarget->isBTMemSlow()">;
Evan Chengd7f666a2009-05-20 04:53:57 +0000294def CallImmAddr : Predicate<"Subtarget->IsLegalToCallImmediateAddr(TM)">;
Evan Chengbbc8ddb2005-12-20 22:59:51 +0000295
296//===----------------------------------------------------------------------===//
Evan Chengc64a1a92007-07-31 08:04:03 +0000297// X86 Instruction Format Definitions.
Evan Chengaed7c722005-12-17 01:24:02 +0000298//
299
Evan Chengc64a1a92007-07-31 08:04:03 +0000300include "X86InstrFormats.td"
Chris Lattner1cca5e32003-08-03 21:54:21 +0000301
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +0000302//===----------------------------------------------------------------------===//
Chris Lattnerf124d5e2005-11-18 01:04:42 +0000303// Pattern fragments...
304//
Evan Chengd9558e02006-01-06 00:43:03 +0000305
306// X86 specific condition code. These correspond to CondCode in
Nate Begeman9a225302007-05-06 04:00:55 +0000307// X86InstrInfo.h. They must be kept in synch.
Dan Gohman653456c2009-01-07 00:15:08 +0000308def X86_COND_A : PatLeaf<(i8 0)>; // alt. COND_NBE
309def X86_COND_AE : PatLeaf<(i8 1)>; // alt. COND_NC
310def X86_COND_B : PatLeaf<(i8 2)>; // alt. COND_C
311def X86_COND_BE : PatLeaf<(i8 3)>; // alt. COND_NA
312def X86_COND_E : PatLeaf<(i8 4)>; // alt. COND_Z
313def X86_COND_G : PatLeaf<(i8 5)>; // alt. COND_NLE
314def X86_COND_GE : PatLeaf<(i8 6)>; // alt. COND_NL
315def X86_COND_L : PatLeaf<(i8 7)>; // alt. COND_NGE
316def X86_COND_LE : PatLeaf<(i8 8)>; // alt. COND_NG
317def X86_COND_NE : PatLeaf<(i8 9)>; // alt. COND_NZ
Evan Chengd9558e02006-01-06 00:43:03 +0000318def X86_COND_NO : PatLeaf<(i8 10)>;
Dan Gohman653456c2009-01-07 00:15:08 +0000319def X86_COND_NP : PatLeaf<(i8 11)>; // alt. COND_PO
Evan Chengd9558e02006-01-06 00:43:03 +0000320def X86_COND_NS : PatLeaf<(i8 12)>;
Dan Gohman653456c2009-01-07 00:15:08 +0000321def X86_COND_O : PatLeaf<(i8 13)>;
322def X86_COND_P : PatLeaf<(i8 14)>; // alt. COND_PE
323def X86_COND_S : PatLeaf<(i8 15)>;
Evan Chengd9558e02006-01-06 00:43:03 +0000324
Evan Cheng9b6b6422005-12-13 00:14:11 +0000325def i16immSExt8 : PatLeaf<(i16 imm), [{
326 // i16immSExt8 predicate - True if the 16-bit immediate fits in a 8-bit
Evan Chengb3558542005-12-13 00:01:09 +0000327 // sign extended field.
Dan Gohmanf5aeb1a2008-09-12 16:56:44 +0000328 return (int16_t)N->getZExtValue() == (int8_t)N->getZExtValue();
Chris Lattnerf124d5e2005-11-18 01:04:42 +0000329}]>;
330
Evan Cheng9b6b6422005-12-13 00:14:11 +0000331def i32immSExt8 : PatLeaf<(i32 imm), [{
332 // i32immSExt8 predicate - True if the 32-bit immediate fits in a 8-bit
Evan Chengb3558542005-12-13 00:01:09 +0000333 // sign extended field.
Dan Gohmanf5aeb1a2008-09-12 16:56:44 +0000334 return (int32_t)N->getZExtValue() == (int8_t)N->getZExtValue();
Evan Chengb3558542005-12-13 00:01:09 +0000335}]>;
336
Evan Cheng605c4152005-12-13 01:57:51 +0000337// Helper fragments for loads.
Evan Chengb6564432008-05-13 18:59:59 +0000338// It's always safe to treat a anyext i16 load as a i32 load if the i16 is
339// known to be 32-bit aligned or better. Ditto for i8 to i16.
Dan Gohman33586292008-10-15 06:50:19 +0000340def loadi16 : PatFrag<(ops node:$ptr), (i16 (unindexedload node:$ptr)), [{
Dan Gohman67ca6be2008-08-20 15:24:22 +0000341 LoadSDNode *LD = cast<LoadSDNode>(N);
Chris Lattnerc2406f22009-04-10 00:16:23 +0000342 if (const Value *Src = LD->getSrcValue())
343 if (const PointerType *PT = dyn_cast<PointerType>(Src->getType()))
Mon P Wanga7e01d72009-04-27 07:22:10 +0000344 if (PT->getAddressSpace() > 255)
Chris Lattnerc2406f22009-04-10 00:16:23 +0000345 return false;
Dan Gohman67ca6be2008-08-20 15:24:22 +0000346 ISD::LoadExtType ExtType = LD->getExtensionType();
347 if (ExtType == ISD::NON_EXTLOAD)
348 return true;
349 if (ExtType == ISD::EXTLOAD)
350 return LD->getAlignment() >= 2 && !LD->isVolatile();
Evan Chengfa7fd332008-05-13 00:54:02 +0000351 return false;
352}]>;
353
Dan Gohman33586292008-10-15 06:50:19 +0000354def loadi16_anyext : PatFrag<(ops node:$ptr), (i32 (unindexedload node:$ptr)), [{
Evan Chengca57f782008-09-24 23:27:55 +0000355 LoadSDNode *LD = cast<LoadSDNode>(N);
Chris Lattnerc2406f22009-04-10 00:16:23 +0000356 if (const Value *Src = LD->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;
Evan Chengca57f782008-09-24 23:27:55 +0000360 ISD::LoadExtType ExtType = LD->getExtensionType();
361 if (ExtType == ISD::EXTLOAD)
362 return LD->getAlignment() >= 2 && !LD->isVolatile();
363 return false;
364}]>;
365
Dan Gohman33586292008-10-15 06:50:19 +0000366def loadi32 : PatFrag<(ops node:$ptr), (i32 (unindexedload node:$ptr)), [{
Dan Gohman67ca6be2008-08-20 15:24:22 +0000367 LoadSDNode *LD = cast<LoadSDNode>(N);
Chris Lattnerc2406f22009-04-10 00:16:23 +0000368 if (const Value *Src = LD->getSrcValue())
369 if (const PointerType *PT = dyn_cast<PointerType>(Src->getType()))
Mon P Wanga7e01d72009-04-27 07:22:10 +0000370 if (PT->getAddressSpace() > 255)
Chris Lattnerc2406f22009-04-10 00:16:23 +0000371 return false;
Dan Gohman67ca6be2008-08-20 15:24:22 +0000372 ISD::LoadExtType ExtType = LD->getExtensionType();
373 if (ExtType == ISD::NON_EXTLOAD)
374 return true;
375 if (ExtType == ISD::EXTLOAD)
376 return LD->getAlignment() >= 4 && !LD->isVolatile();
Evan Chengfa7fd332008-05-13 00:54:02 +0000377 return false;
378}]>;
379
Dan Gohman33586292008-10-15 06:50:19 +0000380def nvloadi32 : PatFrag<(ops node:$ptr), (i32 (unindexedload node:$ptr)), [{
Evan Chengd47e0b62008-09-29 17:26:18 +0000381 LoadSDNode *LD = cast<LoadSDNode>(N);
Chris Lattnerc2406f22009-04-10 00:16:23 +0000382 if (const Value *Src = LD->getSrcValue())
383 if (const PointerType *PT = dyn_cast<PointerType>(Src->getType()))
Mon P Wanga7e01d72009-04-27 07:22:10 +0000384 if (PT->getAddressSpace() > 255)
Chris Lattnerc2406f22009-04-10 00:16:23 +0000385 return false;
Evan Chengd47e0b62008-09-29 17:26:18 +0000386 if (LD->isVolatile())
387 return false;
Evan Chengd47e0b62008-09-29 17:26:18 +0000388 ISD::LoadExtType ExtType = LD->getExtensionType();
389 if (ExtType == ISD::NON_EXTLOAD)
390 return true;
391 if (ExtType == ISD::EXTLOAD)
392 return LD->getAlignment() >= 4;
393 return false;
394}]>;
395
Nate Begeman51a04372009-01-26 01:24:32 +0000396def gsload : PatFrag<(ops node:$ptr), (load node:$ptr), [{
Chris Lattnerc2406f22009-04-10 00:16:23 +0000397 if (const Value *Src = cast<LoadSDNode>(N)->getSrcValue())
398 if (const PointerType *PT = dyn_cast<PointerType>(Src->getType()))
399 return PT->getAddressSpace() == 256;
Nate Begeman51a04372009-01-26 01:24:32 +0000400 return false;
401}]>;
402
Chris Lattner1777d0c2009-05-05 18:52:19 +0000403def fsload : PatFrag<(ops node:$ptr), (load node:$ptr), [{
404 if (const Value *Src = cast<LoadSDNode>(N)->getSrcValue())
405 if (const PointerType *PT = dyn_cast<PointerType>(Src->getType()))
406 return PT->getAddressSpace() == 257;
407 return false;
408}]>;
409
Chris Lattnerc2406f22009-04-10 00:16:23 +0000410def loadi8 : PatFrag<(ops node:$ptr), (i8 (load node:$ptr)), [{
411 if (const Value *Src = cast<LoadSDNode>(N)->getSrcValue())
412 if (const PointerType *PT = dyn_cast<PointerType>(Src->getType()))
Mon P Wanga7e01d72009-04-27 07:22:10 +0000413 if (PT->getAddressSpace() > 255)
Chris Lattnerc2406f22009-04-10 00:16:23 +0000414 return false;
415 return true;
416}]>;
417def loadi64 : PatFrag<(ops node:$ptr), (i64 (load node:$ptr)), [{
418 if (const Value *Src = cast<LoadSDNode>(N)->getSrcValue())
419 if (const PointerType *PT = dyn_cast<PointerType>(Src->getType()))
Mon P Wanga7e01d72009-04-27 07:22:10 +0000420 if (PT->getAddressSpace() > 255)
Chris Lattnerc2406f22009-04-10 00:16:23 +0000421 return false;
422 return true;
423}]>;
Evan Cheng06a8aa12006-03-17 19:55:52 +0000424
Chris Lattnerc2406f22009-04-10 00:16:23 +0000425def loadf32 : PatFrag<(ops node:$ptr), (f32 (load node:$ptr)), [{
426 if (const Value *Src = cast<LoadSDNode>(N)->getSrcValue())
427 if (const PointerType *PT = dyn_cast<PointerType>(Src->getType()))
Mon P Wanga7e01d72009-04-27 07:22:10 +0000428 if (PT->getAddressSpace() > 255)
Chris Lattnerc2406f22009-04-10 00:16:23 +0000429 return false;
430 return true;
431}]>;
432def loadf64 : PatFrag<(ops node:$ptr), (f64 (load node:$ptr)), [{
433 if (const Value *Src = cast<LoadSDNode>(N)->getSrcValue())
434 if (const PointerType *PT = dyn_cast<PointerType>(Src->getType()))
Mon P Wanga7e01d72009-04-27 07:22:10 +0000435 if (PT->getAddressSpace() > 255)
Chris Lattnerc2406f22009-04-10 00:16:23 +0000436 return false;
437 return true;
438}]>;
439def loadf80 : PatFrag<(ops node:$ptr), (f80 (load node:$ptr)), [{
440 if (const Value *Src = cast<LoadSDNode>(N)->getSrcValue())
441 if (const PointerType *PT = dyn_cast<PointerType>(Src->getType()))
Mon P Wanga7e01d72009-04-27 07:22:10 +0000442 if (PT->getAddressSpace() > 255)
Chris Lattnerc2406f22009-04-10 00:16:23 +0000443 return false;
444 return true;
445}]>;
Evan Cheng7a7e8372005-12-14 02:22:27 +0000446
Evan Cheng466685d2006-10-09 20:57:25 +0000447def sextloadi16i8 : PatFrag<(ops node:$ptr), (i16 (sextloadi8 node:$ptr))>;
448def sextloadi32i8 : PatFrag<(ops node:$ptr), (i32 (sextloadi8 node:$ptr))>;
449def sextloadi32i16 : PatFrag<(ops node:$ptr), (i32 (sextloadi16 node:$ptr))>;
Evan Cheng7a7e8372005-12-14 02:22:27 +0000450
Evan Cheng466685d2006-10-09 20:57:25 +0000451def zextloadi8i1 : PatFrag<(ops node:$ptr), (i8 (zextloadi1 node:$ptr))>;
452def zextloadi16i1 : PatFrag<(ops node:$ptr), (i16 (zextloadi1 node:$ptr))>;
453def zextloadi32i1 : PatFrag<(ops node:$ptr), (i32 (zextloadi1 node:$ptr))>;
454def zextloadi16i8 : PatFrag<(ops node:$ptr), (i16 (zextloadi8 node:$ptr))>;
455def zextloadi32i8 : PatFrag<(ops node:$ptr), (i32 (zextloadi8 node:$ptr))>;
456def zextloadi32i16 : PatFrag<(ops node:$ptr), (i32 (zextloadi16 node:$ptr))>;
Evan Cheng7a7e8372005-12-14 02:22:27 +0000457
Evan Cheng466685d2006-10-09 20:57:25 +0000458def extloadi8i1 : PatFrag<(ops node:$ptr), (i8 (extloadi1 node:$ptr))>;
459def extloadi16i1 : PatFrag<(ops node:$ptr), (i16 (extloadi1 node:$ptr))>;
460def extloadi32i1 : PatFrag<(ops node:$ptr), (i32 (extloadi1 node:$ptr))>;
461def extloadi16i8 : PatFrag<(ops node:$ptr), (i16 (extloadi8 node:$ptr))>;
462def extloadi32i8 : PatFrag<(ops node:$ptr), (i32 (extloadi8 node:$ptr))>;
463def extloadi32i16 : PatFrag<(ops node:$ptr), (i32 (extloadi16 node:$ptr))>;
Evan Cheng747a90d2006-02-21 02:24:38 +0000464
Chris Lattnerce2bcc82008-02-19 17:37:35 +0000465
466// An 'and' node with a single use.
467def and_su : PatFrag<(ops node:$lhs, node:$rhs), (and node:$lhs, node:$rhs), [{
Evan Cheng07b7ea12008-03-04 00:40:35 +0000468 return N->hasOneUse();
Chris Lattnerce2bcc82008-02-19 17:37:35 +0000469}]>;
Dan Gohman21e3dfb2009-04-13 16:09:41 +0000470// An 'srl' node with a single use.
471def srl_su : PatFrag<(ops node:$lhs, node:$rhs), (srl node:$lhs, node:$rhs), [{
472 return N->hasOneUse();
473}]>;
474// An 'trunc' node with a single use.
475def trunc_su : PatFrag<(ops node:$src), (trunc node:$src), [{
476 return N->hasOneUse();
477}]>;
Chris Lattnerce2bcc82008-02-19 17:37:35 +0000478
Dan Gohman74feef22008-10-17 01:23:35 +0000479// 'shld' and 'shrd' instruction patterns. Note that even though these have
480// the srl and shl in their patterns, the C++ code must still check for them,
481// because predicates are tested before children nodes are explored.
482
483def shrd : PatFrag<(ops node:$src1, node:$amt1, node:$src2, node:$amt2),
484 (or (srl node:$src1, node:$amt1),
485 (shl node:$src2, node:$amt2)), [{
486 assert(N->getOpcode() == ISD::OR);
487 return N->getOperand(0).getOpcode() == ISD::SRL &&
488 N->getOperand(1).getOpcode() == ISD::SHL &&
489 isa<ConstantSDNode>(N->getOperand(0).getOperand(1)) &&
490 isa<ConstantSDNode>(N->getOperand(1).getOperand(1)) &&
491 N->getOperand(0).getConstantOperandVal(1) ==
492 N->getValueSizeInBits(0) - N->getOperand(1).getConstantOperandVal(1);
493}]>;
494
495def shld : PatFrag<(ops node:$src1, node:$amt1, node:$src2, node:$amt2),
496 (or (shl node:$src1, node:$amt1),
497 (srl node:$src2, node:$amt2)), [{
498 assert(N->getOpcode() == ISD::OR);
499 return N->getOperand(0).getOpcode() == ISD::SHL &&
500 N->getOperand(1).getOpcode() == ISD::SRL &&
501 isa<ConstantSDNode>(N->getOperand(0).getOperand(1)) &&
502 isa<ConstantSDNode>(N->getOperand(1).getOperand(1)) &&
503 N->getOperand(0).getConstantOperandVal(1) ==
504 N->getValueSizeInBits(0) - N->getOperand(1).getConstantOperandVal(1);
505}]>;
506
Chris Lattnerf124d5e2005-11-18 01:04:42 +0000507//===----------------------------------------------------------------------===//
Chris Lattner1cca5e32003-08-03 21:54:21 +0000508// Instruction list...
509//
510
Chris Lattnerf18c0742006-10-12 17:42:56 +0000511// ADJCALLSTACKDOWN/UP implicitly use/def ESP because they may be expanded into
512// a stack adjustment and the codegen must know that they may modify the stack
513// pointer before prolog-epilog rewriting occurs.
Chris Lattner447ff682008-03-11 03:23:40 +0000514// Pessimistically assume ADJCALLSTACKDOWN / ADJCALLSTACKUP will become
515// sub / add which can clobber EFLAGS.
Evan Cheng8decf6b2007-09-28 01:19:48 +0000516let Defs = [ESP, EFLAGS], Uses = [ESP] in {
Dan Gohman6d4b0522008-10-01 18:28:06 +0000517def ADJCALLSTACKDOWN32 : I<0, Pseudo, (outs), (ins i32imm:$amt),
518 "#ADJCALLSTACKDOWN",
Chris Lattnere563bbc2008-10-11 22:08:30 +0000519 [(X86callseq_start timm:$amt)]>,
Dan Gohman6d4b0522008-10-01 18:28:06 +0000520 Requires<[In32BitMode]>;
521def ADJCALLSTACKUP32 : I<0, Pseudo, (outs), (ins i32imm:$amt1, i32imm:$amt2),
522 "#ADJCALLSTACKUP",
Chris Lattnere563bbc2008-10-11 22:08:30 +0000523 [(X86callseq_end timm:$amt1, timm:$amt2)]>,
Dan Gohman6d4b0522008-10-01 18:28:06 +0000524 Requires<[In32BitMode]>;
Evan Cheng071a2792007-09-11 19:55:27 +0000525}
Evan Cheng4a460802006-01-11 00:33:36 +0000526
Dan Gohmand6708ea2009-08-15 01:38:56 +0000527// x86-64 va_start lowering magic.
528let usesCustomDAGSchedInserter = 1 in
529def VASTART_SAVE_XMM_REGS : I<0, Pseudo,
530 (outs),
531 (ins GR8:$al,
532 i64imm:$regsavefi, i64imm:$offset,
533 variable_ops),
534 "#VASTART_SAVE_XMM_REGS $al, $regsavefi, $offset",
535 [(X86vastart_save_xmm_regs GR8:$al,
536 imm:$regsavefi,
537 imm:$offset)]>;
538
Evan Cheng4a460802006-01-11 00:33:36 +0000539// Nop
Sean Callanan74e52102009-07-23 23:39:34 +0000540let neverHasSideEffects = 1 in {
Chris Lattnerba7e7562008-01-10 07:59:24 +0000541 def NOOP : I<0x90, RawFrm, (outs), (ins), "nop", []>;
Sean Callanan74e52102009-07-23 23:39:34 +0000542 def NOOPL : I<0x1f, MRM0m, (outs), (ins i32mem:$zero),
543 "nopl\t$zero", []>, TB;
544}
Evan Cheng4a460802006-01-11 00:33:36 +0000545
Sean Callanan1c5cf1b2009-08-11 01:09:06 +0000546// Trap
547def INT3 : I<0xcc, RawFrm, (outs), (ins), "int 3", []>;
548def INT : I<0xcd, RawFrm, (outs), (ins i8imm:$trap), "int\t$trap", []>;
549
Evan Cheng0475ab52008-01-05 00:41:47 +0000550// PIC base
Dan Gohman2662d552008-10-01 04:14:30 +0000551let neverHasSideEffects = 1, isNotDuplicable = 1, Uses = [ESP] in
Chris Lattnerba7e7562008-01-10 07:59:24 +0000552 def MOVPC32r : Ii32<0xE8, Pseudo, (outs GR32:$reg), (ins piclabel:$label),
Dan Gohman4d47b9b2009-04-27 15:13:28 +0000553 "call\t$label\n\t"
554 "pop{l}\t$reg", []>;
Evan Cheng8f7f7122006-05-05 05:40:20 +0000555
Chris Lattner1cca5e32003-08-03 21:54:21 +0000556//===----------------------------------------------------------------------===//
557// Control Flow Instructions...
558//
559
Chris Lattner1be48112005-05-13 17:56:48 +0000560// Return instructions.
Evan Cheng2b4ea792005-12-26 09:11:45 +0000561let isTerminator = 1, isReturn = 1, isBarrier = 1,
Chris Lattner447ff682008-03-11 03:23:40 +0000562 hasCtrlDep = 1, FPForm = SpecialFP, FPFormBits = SpecialFP.Value in {
Dan Gohmane4c67cd2008-05-31 02:11:25 +0000563 def RET : I <0xC3, RawFrm, (outs), (ins variable_ops),
Chris Lattner447ff682008-03-11 03:23:40 +0000564 "ret",
Dan Gohmane4c67cd2008-05-31 02:11:25 +0000565 [(X86retflag 0)]>;
Chris Lattner447ff682008-03-11 03:23:40 +0000566 def RETI : Ii16<0xC2, RawFrm, (outs), (ins i16imm:$amt, variable_ops),
567 "ret\t$amt",
Evan Chenge3413162006-01-09 18:33:28 +0000568 [(X86retflag imm:$amt)]>;
Evan Cheng171049d2005-12-23 22:14:32 +0000569}
Chris Lattner1cca5e32003-08-03 21:54:21 +0000570
571// All branches are RawFrm, Void, Branch, and Terminators
Evan Chengffbacca2007-07-21 00:34:19 +0000572let isBranch = 1, isTerminator = 1 in
Evan Cheng64d80e32007-07-19 01:14:50 +0000573 class IBr<bits<8> opcode, dag ins, string asm, list<dag> pattern> :
574 I<opcode, RawFrm, (outs), ins, asm, pattern>;
Chris Lattner1cca5e32003-08-03 21:54:21 +0000575
Sean Callanan52925882009-07-22 01:05:20 +0000576let isBranch = 1, isBarrier = 1 in {
Dan Gohmanb1576f52007-07-31 20:11:57 +0000577 def JMP : IBr<0xE9, (ins brtarget:$dst), "jmp\t$dst", [(br bb:$dst)]>;
Sean Callanan52925882009-07-22 01:05:20 +0000578 def JMP8 : IBr<0xEB, (ins brtarget8:$dst), "jmp\t$dst", []>;
579}
Evan Cheng898101c2005-12-19 23:12:38 +0000580
Owen Anderson20ab2902007-11-12 07:39:39 +0000581// Indirect branches
582let isBranch = 1, isTerminator = 1, isBarrier = 1, isIndirectBranch = 1 in {
Dan Gohmanb1576f52007-07-31 20:11:57 +0000583 def JMP32r : I<0xFF, MRM4r, (outs), (ins GR32:$dst), "jmp{l}\t{*}$dst",
Evan Cheng069287d2006-05-16 07:21:53 +0000584 [(brind GR32:$dst)]>;
Dan Gohmanb1576f52007-07-31 20:11:57 +0000585 def JMP32m : I<0xFF, MRM4m, (outs), (ins i32mem:$dst), "jmp{l}\t{*}$dst",
Evan Cheng25ab6902006-09-08 06:48:29 +0000586 [(brind (loadi32 addr:$dst))]>;
Sean Callanan9947bbb2009-09-03 00:04:47 +0000587 def FARJMP16 : I<0xFF, MRM5m, (outs), (ins opaque32mem:$dst),
588 "ljmp{w}\t{*}$dst", []>, OpSize;
589 def FARJMP32 : I<0xFF, MRM5m, (outs), (ins opaque48mem:$dst),
590 "ljmp{l}\t{*}$dst", []>;
Nate Begeman37efe672006-04-22 18:53:45 +0000591}
592
593// Conditional branches
Evan Cheng0488db92007-09-25 01:57:46 +0000594let Uses = [EFLAGS] in {
Evan Cheng77159e32009-07-21 06:00:18 +0000595// Short conditional jumps
596def JO8 : IBr<0x70, (ins brtarget8:$dst), "jo\t$dst", []>;
597def JNO8 : IBr<0x71, (ins brtarget8:$dst), "jno\t$dst", []>;
598def JB8 : IBr<0x72, (ins brtarget8:$dst), "jb\t$dst", []>;
599def JAE8 : IBr<0x73, (ins brtarget8:$dst), "jae\t$dst", []>;
600def JE8 : IBr<0x74, (ins brtarget8:$dst), "je\t$dst", []>;
601def JNE8 : IBr<0x75, (ins brtarget8:$dst), "jne\t$dst", []>;
602def JBE8 : IBr<0x76, (ins brtarget8:$dst), "jbe\t$dst", []>;
603def JA8 : IBr<0x77, (ins brtarget8:$dst), "ja\t$dst", []>;
604def JS8 : IBr<0x78, (ins brtarget8:$dst), "js\t$dst", []>;
605def JNS8 : IBr<0x79, (ins brtarget8:$dst), "jns\t$dst", []>;
606def JP8 : IBr<0x7A, (ins brtarget8:$dst), "jp\t$dst", []>;
607def JNP8 : IBr<0x7B, (ins brtarget8:$dst), "jnp\t$dst", []>;
608def JL8 : IBr<0x7C, (ins brtarget8:$dst), "jl\t$dst", []>;
609def JGE8 : IBr<0x7D, (ins brtarget8:$dst), "jge\t$dst", []>;
610def JLE8 : IBr<0x7E, (ins brtarget8:$dst), "jle\t$dst", []>;
611def JG8 : IBr<0x7F, (ins brtarget8:$dst), "jg\t$dst", []>;
612
613def JCXZ8 : IBr<0xE3, (ins brtarget8:$dst), "jcxz\t$dst", []>;
614
Dan Gohmanb1576f52007-07-31 20:11:57 +0000615def JE : IBr<0x84, (ins brtarget:$dst), "je\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +0000616 [(X86brcond bb:$dst, X86_COND_E, EFLAGS)]>, TB;
Dan Gohmanb1576f52007-07-31 20:11:57 +0000617def JNE : IBr<0x85, (ins brtarget:$dst), "jne\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +0000618 [(X86brcond bb:$dst, X86_COND_NE, EFLAGS)]>, TB;
Dan Gohmanb1576f52007-07-31 20:11:57 +0000619def JL : IBr<0x8C, (ins brtarget:$dst), "jl\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +0000620 [(X86brcond bb:$dst, X86_COND_L, EFLAGS)]>, TB;
Dan Gohmanb1576f52007-07-31 20:11:57 +0000621def JLE : IBr<0x8E, (ins brtarget:$dst), "jle\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +0000622 [(X86brcond bb:$dst, X86_COND_LE, EFLAGS)]>, TB;
Dan Gohmanb1576f52007-07-31 20:11:57 +0000623def JG : IBr<0x8F, (ins brtarget:$dst), "jg\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +0000624 [(X86brcond bb:$dst, X86_COND_G, EFLAGS)]>, TB;
Dan Gohmanb1576f52007-07-31 20:11:57 +0000625def JGE : IBr<0x8D, (ins brtarget:$dst), "jge\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +0000626 [(X86brcond bb:$dst, X86_COND_GE, EFLAGS)]>, TB;
Evan Cheng898101c2005-12-19 23:12:38 +0000627
Dan Gohmanb1576f52007-07-31 20:11:57 +0000628def JB : IBr<0x82, (ins brtarget:$dst), "jb\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +0000629 [(X86brcond bb:$dst, X86_COND_B, EFLAGS)]>, TB;
Dan Gohmanb1576f52007-07-31 20:11:57 +0000630def JBE : IBr<0x86, (ins brtarget:$dst), "jbe\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +0000631 [(X86brcond bb:$dst, X86_COND_BE, EFLAGS)]>, TB;
Dan Gohmanb1576f52007-07-31 20:11:57 +0000632def JA : IBr<0x87, (ins brtarget:$dst), "ja\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +0000633 [(X86brcond bb:$dst, X86_COND_A, EFLAGS)]>, TB;
Dan Gohmanb1576f52007-07-31 20:11:57 +0000634def JAE : IBr<0x83, (ins brtarget:$dst), "jae\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +0000635 [(X86brcond bb:$dst, X86_COND_AE, EFLAGS)]>, TB;
Evan Cheng898101c2005-12-19 23:12:38 +0000636
Dan Gohmanb1576f52007-07-31 20:11:57 +0000637def JS : IBr<0x88, (ins brtarget:$dst), "js\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +0000638 [(X86brcond bb:$dst, X86_COND_S, EFLAGS)]>, TB;
Dan Gohmanb1576f52007-07-31 20:11:57 +0000639def JNS : IBr<0x89, (ins brtarget:$dst), "jns\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +0000640 [(X86brcond bb:$dst, X86_COND_NS, EFLAGS)]>, TB;
Dan Gohmanb1576f52007-07-31 20:11:57 +0000641def JP : IBr<0x8A, (ins brtarget:$dst), "jp\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +0000642 [(X86brcond bb:$dst, X86_COND_P, EFLAGS)]>, TB;
Dan Gohmanb1576f52007-07-31 20:11:57 +0000643def JNP : IBr<0x8B, (ins brtarget:$dst), "jnp\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +0000644 [(X86brcond bb:$dst, X86_COND_NP, EFLAGS)]>, TB;
Dan Gohmanb1576f52007-07-31 20:11:57 +0000645def JO : IBr<0x80, (ins brtarget:$dst), "jo\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +0000646 [(X86brcond bb:$dst, X86_COND_O, EFLAGS)]>, TB;
Dan Gohmanb1576f52007-07-31 20:11:57 +0000647def JNO : IBr<0x81, (ins brtarget:$dst), "jno\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +0000648 [(X86brcond bb:$dst, X86_COND_NO, EFLAGS)]>, TB;
Evan Cheng0488db92007-09-25 01:57:46 +0000649} // Uses = [EFLAGS]
Chris Lattner1cca5e32003-08-03 21:54:21 +0000650
651//===----------------------------------------------------------------------===//
652// Call Instructions...
653//
Evan Chengffbacca2007-07-21 00:34:19 +0000654let isCall = 1 in
Dan Gohman6d4b0522008-10-01 18:28:06 +0000655 // All calls clobber the non-callee saved registers. ESP is marked as
656 // a use to prevent stack-pointer assignments that appear immediately
657 // before calls from potentially appearing dead. Uses for argument
658 // registers are added manually.
Nate Begemanf63be7d2005-07-06 18:59:04 +0000659 let Defs = [EAX, ECX, EDX, FP0, FP1, FP2, FP3, FP4, FP5, FP6, ST0,
Bill Wendling3f3a17d2007-04-25 21:31:48 +0000660 MM0, MM1, MM2, MM3, MM4, MM5, MM6, MM7,
Evan Cheng109a5622008-10-17 21:02:22 +0000661 XMM0, XMM1, XMM2, XMM3, XMM4, XMM5, XMM6, XMM7,
662 XMM8, XMM9, XMM10, XMM11, XMM12, XMM13, XMM14, XMM15, EFLAGS],
Dan Gohman2662d552008-10-01 04:14:30 +0000663 Uses = [ESP] in {
Chris Lattner7680e732009-06-20 19:34:09 +0000664 def CALLpcrel32 : Ii32<0xE8, RawFrm,
665 (outs), (ins i32imm_pcrel:$dst,variable_ops),
666 "call\t$dst", []>;
Evan Cheng64d80e32007-07-19 01:14:50 +0000667 def CALL32r : I<0xFF, MRM2r, (outs), (ins GR32:$dst, variable_ops),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000668 "call\t{*}$dst", [(X86call GR32:$dst)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +0000669 def CALL32m : I<0xFF, MRM2m, (outs), (ins i32mem:$dst, variable_ops),
Dan Gohmanb4106172008-05-29 21:50:34 +0000670 "call\t{*}$dst", [(X86call (loadi32 addr:$dst))]>;
Sean Callanan9947bbb2009-09-03 00:04:47 +0000671
672 def FARCALL16 : I<0xFF, MRM3m, (outs), (ins opaque32mem:$dst),
673 "lcall{w}\t{*}$dst", []>, OpSize;
674 def FARCALL32 : I<0xFF, MRM3m, (outs), (ins opaque48mem:$dst),
675 "lcall{l}\t{*}$dst", []>;
Chris Lattner1cca5e32003-08-03 21:54:21 +0000676 }
677
Chris Lattner1e9448b2005-05-15 03:10:37 +0000678// Tail call stuff.
Arnold Schwaighoferc85e1712007-10-11 19:40:01 +0000679
Evan Chengffbacca2007-07-21 00:34:19 +0000680let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1 in
Arnold Schwaighofer4fe30732008-03-19 16:39:45 +0000681def TCRETURNdi : I<0, Pseudo, (outs), (ins i32imm:$dst, i32imm:$offset, variable_ops),
Arnold Schwaighoferc85e1712007-10-11 19:40:01 +0000682 "#TC_RETURN $dst $offset",
683 []>;
684
685let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1 in
Arnold Schwaighofer4fe30732008-03-19 16:39:45 +0000686def TCRETURNri : I<0, Pseudo, (outs), (ins GR32:$dst, i32imm:$offset, variable_ops),
Arnold Schwaighoferc85e1712007-10-11 19:40:01 +0000687 "#TC_RETURN $dst $offset",
688 []>;
689
690let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1 in
Arnold Schwaighofer30e62c02008-04-30 09:16:33 +0000691
Chris Lattner7680e732009-06-20 19:34:09 +0000692 def TAILJMPd : IBr<0xE9, (ins i32imm_pcrel:$dst), "jmp\t$dst # TAILCALL",
Evan Chengf10c17f2006-09-22 21:43:59 +0000693 []>;
Evan Chengffbacca2007-07-21 00:34:19 +0000694let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1 in
Arnold Schwaighoferc85e1712007-10-11 19:40:01 +0000695 def TAILJMPr : I<0xFF, MRM4r, (outs), (ins GR32:$dst), "jmp{l}\t{*}$dst # TAILCALL",
696 []>;
Evan Chengffbacca2007-07-21 00:34:19 +0000697let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1 in
Evan Cheng64d80e32007-07-19 01:14:50 +0000698 def TAILJMPm : I<0xFF, MRM4m, (outs), (ins i32mem:$dst),
Arnold Schwaighoferc85e1712007-10-11 19:40:01 +0000699 "jmp\t{*}$dst # TAILCALL", []>;
Chris Lattner1e9448b2005-05-15 03:10:37 +0000700
Chris Lattner1cca5e32003-08-03 21:54:21 +0000701//===----------------------------------------------------------------------===//
702// Miscellaneous Instructions...
703//
Chris Lattnerba7e7562008-01-10 07:59:24 +0000704let Defs = [EBP, ESP], Uses = [EBP, ESP], mayLoad = 1, neverHasSideEffects=1 in
Chris Lattner30bf2d82004-08-10 20:17:41 +0000705def LEAVE : I<0xC9, RawFrm,
Evan Cheng071a2792007-09-11 19:55:27 +0000706 (outs), (ins), "leave", []>;
707
Chris Lattnerba7e7562008-01-10 07:59:24 +0000708let Defs = [ESP], Uses = [ESP], neverHasSideEffects=1 in {
709let mayLoad = 1 in
Evan Cheng2f245ba2007-09-26 01:29:06 +0000710def POP32r : I<0x58, AddRegFrm, (outs GR32:$reg), (ins), "pop{l}\t$reg", []>;
Chris Lattner1cca5e32003-08-03 21:54:21 +0000711
Chris Lattnerba7e7562008-01-10 07:59:24 +0000712let mayStore = 1 in
Evan Cheng2f245ba2007-09-26 01:29:06 +0000713def PUSH32r : I<0x50, AddRegFrm, (outs), (ins GR32:$reg), "push{l}\t$reg",[]>;
Evan Cheng071a2792007-09-11 19:55:27 +0000714}
Anton Korobeynikov57fc00d2007-04-17 09:20:00 +0000715
Bill Wendling453eb262009-06-15 19:39:04 +0000716let Defs = [ESP], Uses = [ESP], neverHasSideEffects = 1, mayStore = 1 in {
717def PUSH32i8 : Ii8<0x6a, RawFrm, (outs), (ins i8imm:$imm),
Bill Wendling927788c2009-06-15 20:59:31 +0000718 "push{l}\t$imm", []>;
Bill Wendling453eb262009-06-15 19:39:04 +0000719def PUSH32i16 : Ii16<0x68, RawFrm, (outs), (ins i16imm:$imm),
Bill Wendling927788c2009-06-15 20:59:31 +0000720 "push{l}\t$imm", []>;
Bill Wendling453eb262009-06-15 19:39:04 +0000721def PUSH32i32 : Ii32<0x68, RawFrm, (outs), (ins i32imm:$imm),
Bill Wendling927788c2009-06-15 20:59:31 +0000722 "push{l}\t$imm", []>;
Bill Wendling453eb262009-06-15 19:39:04 +0000723}
724
Chris Lattnerba7e7562008-01-10 07:59:24 +0000725let Defs = [ESP, EFLAGS], Uses = [ESP], mayLoad = 1, neverHasSideEffects=1 in
Evan Chengbf4f89d2007-09-26 21:28:00 +0000726def POPFD : I<0x9D, RawFrm, (outs), (ins), "popf", []>;
Chris Lattnerba7e7562008-01-10 07:59:24 +0000727let Defs = [ESP], Uses = [ESP, EFLAGS], mayStore = 1, neverHasSideEffects=1 in
Evan Chengbf4f89d2007-09-26 21:28:00 +0000728def PUSHFD : I<0x9C, RawFrm, (outs), (ins), "pushf", []>;
Evan Cheng2f245ba2007-09-26 01:29:06 +0000729
Evan Cheng069287d2006-05-16 07:21:53 +0000730let isTwoAddress = 1 in // GR32 = bswap GR32
Chris Lattner30bf2d82004-08-10 20:17:41 +0000731 def BSWAP32r : I<0xC8, AddRegFrm,
Evan Cheng64d80e32007-07-19 01:14:50 +0000732 (outs GR32:$dst), (ins GR32:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000733 "bswap{l}\t$dst",
Evan Cheng069287d2006-05-16 07:21:53 +0000734 [(set GR32:$dst, (bswap GR32:$src))]>, TB;
Chris Lattner1cca5e32003-08-03 21:54:21 +0000735
Chris Lattner1cca5e32003-08-03 21:54:21 +0000736
Evan Cheng18efe262007-12-14 02:13:44 +0000737// Bit scan instructions.
738let Defs = [EFLAGS] in {
Evan Chengfd9e4732007-12-14 18:49:43 +0000739def BSF16rr : I<0xBC, MRMSrcReg, (outs GR16:$dst), (ins GR16:$src),
Dan Gohman1a8001e2007-12-14 15:10:00 +0000740 "bsf{w}\t{$src, $dst|$dst, $src}",
Evan Cheng152804e2007-12-14 08:30:15 +0000741 [(set GR16:$dst, (X86bsf GR16:$src)), (implicit EFLAGS)]>, TB;
Evan Cheng18efe262007-12-14 02:13:44 +0000742def BSF16rm : I<0xBC, MRMSrcMem, (outs GR16:$dst), (ins i16mem:$src),
Dan Gohman1a8001e2007-12-14 15:10:00 +0000743 "bsf{w}\t{$src, $dst|$dst, $src}",
Evan Cheng152804e2007-12-14 08:30:15 +0000744 [(set GR16:$dst, (X86bsf (loadi16 addr:$src))),
745 (implicit EFLAGS)]>, TB;
Evan Chengfd9e4732007-12-14 18:49:43 +0000746def BSF32rr : I<0xBC, MRMSrcReg, (outs GR32:$dst), (ins GR32:$src),
Dan Gohman1a8001e2007-12-14 15:10:00 +0000747 "bsf{l}\t{$src, $dst|$dst, $src}",
Evan Cheng152804e2007-12-14 08:30:15 +0000748 [(set GR32:$dst, (X86bsf GR32:$src)), (implicit EFLAGS)]>, TB;
Evan Cheng18efe262007-12-14 02:13:44 +0000749def BSF32rm : I<0xBC, MRMSrcMem, (outs GR32:$dst), (ins i32mem:$src),
Dan Gohman1a8001e2007-12-14 15:10:00 +0000750 "bsf{l}\t{$src, $dst|$dst, $src}",
Evan Cheng152804e2007-12-14 08:30:15 +0000751 [(set GR32:$dst, (X86bsf (loadi32 addr:$src))),
752 (implicit EFLAGS)]>, TB;
Evan Cheng18efe262007-12-14 02:13:44 +0000753
Evan Chengfd9e4732007-12-14 18:49:43 +0000754def BSR16rr : I<0xBD, MRMSrcReg, (outs GR16:$dst), (ins GR16:$src),
Dan Gohman1a8001e2007-12-14 15:10:00 +0000755 "bsr{w}\t{$src, $dst|$dst, $src}",
Evan Cheng152804e2007-12-14 08:30:15 +0000756 [(set GR16:$dst, (X86bsr GR16:$src)), (implicit EFLAGS)]>, TB;
Evan Cheng18efe262007-12-14 02:13:44 +0000757def BSR16rm : I<0xBD, MRMSrcMem, (outs GR16:$dst), (ins i16mem:$src),
Dan Gohman1a8001e2007-12-14 15:10:00 +0000758 "bsr{w}\t{$src, $dst|$dst, $src}",
Evan Cheng152804e2007-12-14 08:30:15 +0000759 [(set GR16:$dst, (X86bsr (loadi16 addr:$src))),
760 (implicit EFLAGS)]>, TB;
Evan Chengfd9e4732007-12-14 18:49:43 +0000761def BSR32rr : I<0xBD, MRMSrcReg, (outs GR32:$dst), (ins GR32:$src),
Dan Gohman1a8001e2007-12-14 15:10:00 +0000762 "bsr{l}\t{$src, $dst|$dst, $src}",
Evan Cheng152804e2007-12-14 08:30:15 +0000763 [(set GR32:$dst, (X86bsr GR32:$src)), (implicit EFLAGS)]>, TB;
Evan Cheng18efe262007-12-14 02:13:44 +0000764def BSR32rm : I<0xBD, MRMSrcMem, (outs GR32:$dst), (ins i32mem:$src),
Dan Gohman1a8001e2007-12-14 15:10:00 +0000765 "bsr{l}\t{$src, $dst|$dst, $src}",
Evan Cheng152804e2007-12-14 08:30:15 +0000766 [(set GR32:$dst, (X86bsr (loadi32 addr:$src))),
767 (implicit EFLAGS)]>, TB;
Evan Cheng18efe262007-12-14 02:13:44 +0000768} // Defs = [EFLAGS]
769
Chris Lattnerba7e7562008-01-10 07:59:24 +0000770let neverHasSideEffects = 1 in
Chris Lattner3a173df2004-10-03 20:35:00 +0000771def LEA16r : I<0x8D, MRMSrcMem,
Evan Cheng64d80e32007-07-19 01:14:50 +0000772 (outs GR16:$dst), (ins i32mem:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000773 "lea{w}\t{$src|$dst}, {$dst|$src}", []>, OpSize;
Evan Chenge771ebd2008-03-27 01:41:09 +0000774let isReMaterializable = 1 in
Chris Lattner3a173df2004-10-03 20:35:00 +0000775def LEA32r : I<0x8D, MRMSrcMem,
Evan Cheng64d80e32007-07-19 01:14:50 +0000776 (outs GR32:$dst), (ins lea32mem:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000777 "lea{l}\t{$src|$dst}, {$dst|$src}",
Evan Cheng25ab6902006-09-08 06:48:29 +0000778 [(set GR32:$dst, lea32addr:$src)]>, Requires<[In32BitMode]>;
Chris Lattner1cca5e32003-08-03 21:54:21 +0000779
Evan Cheng071a2792007-09-11 19:55:27 +0000780let Defs = [ECX,EDI,ESI], Uses = [ECX,EDI,ESI] in {
Evan Cheng64d80e32007-07-19 01:14:50 +0000781def REP_MOVSB : I<0xA4, RawFrm, (outs), (ins), "{rep;movsb|rep movsb}",
Evan Cheng071a2792007-09-11 19:55:27 +0000782 [(X86rep_movs i8)]>, REP;
Evan Cheng64d80e32007-07-19 01:14:50 +0000783def REP_MOVSW : I<0xA5, RawFrm, (outs), (ins), "{rep;movsw|rep movsw}",
Evan Cheng071a2792007-09-11 19:55:27 +0000784 [(X86rep_movs i16)]>, REP, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +0000785def REP_MOVSD : I<0xA5, RawFrm, (outs), (ins), "{rep;movsl|rep movsd}",
Evan Cheng071a2792007-09-11 19:55:27 +0000786 [(X86rep_movs i32)]>, REP;
787}
Chris Lattner915e5e52004-02-12 17:53:22 +0000788
Evan Cheng071a2792007-09-11 19:55:27 +0000789let Defs = [ECX,EDI], Uses = [AL,ECX,EDI] in
Evan Cheng64d80e32007-07-19 01:14:50 +0000790def REP_STOSB : I<0xAA, RawFrm, (outs), (ins), "{rep;stosb|rep stosb}",
Evan Cheng071a2792007-09-11 19:55:27 +0000791 [(X86rep_stos i8)]>, REP;
792let Defs = [ECX,EDI], Uses = [AX,ECX,EDI] in
Evan Cheng64d80e32007-07-19 01:14:50 +0000793def REP_STOSW : I<0xAB, RawFrm, (outs), (ins), "{rep;stosw|rep stosw}",
Evan Cheng071a2792007-09-11 19:55:27 +0000794 [(X86rep_stos i16)]>, REP, OpSize;
795let Defs = [ECX,EDI], Uses = [EAX,ECX,EDI] in
Evan Cheng64d80e32007-07-19 01:14:50 +0000796def REP_STOSD : I<0xAB, RawFrm, (outs), (ins), "{rep;stosl|rep stosd}",
Evan Cheng071a2792007-09-11 19:55:27 +0000797 [(X86rep_stos i32)]>, REP;
Chris Lattner30bf2d82004-08-10 20:17:41 +0000798
Evan Cheng071a2792007-09-11 19:55:27 +0000799let Defs = [RAX, RDX] in
Evan Cheng64d80e32007-07-19 01:14:50 +0000800def RDTSC : I<0x31, RawFrm, (outs), (ins), "rdtsc", [(X86rdtsc)]>,
Evan Cheng071a2792007-09-11 19:55:27 +0000801 TB;
Chris Lattnerb89abef2004-02-14 04:45:37 +0000802
Anton Korobeynikov66fac792008-01-15 07:02:33 +0000803let isBarrier = 1, hasCtrlDep = 1 in {
Chris Lattnerda68d302008-01-15 21:58:22 +0000804def TRAP : I<0x0B, RawFrm, (outs), (ins), "ud2", [(trap)]>, TB;
Anton Korobeynikov66fac792008-01-15 07:02:33 +0000805}
806
Chris Lattner02552de2009-08-11 16:58:39 +0000807def SYSCALL : I<0x05, RawFrm,
808 (outs), (ins), "syscall", []>, TB;
809def SYSRET : I<0x07, RawFrm,
810 (outs), (ins), "sysret", []>, TB;
811def SYSENTER : I<0x34, RawFrm,
812 (outs), (ins), "sysenter", []>, TB;
813def SYSEXIT : I<0x35, RawFrm,
814 (outs), (ins), "sysexit", []>, TB;
815
816
817
Chris Lattner1cca5e32003-08-03 21:54:21 +0000818//===----------------------------------------------------------------------===//
John Criswell4ffff9e2004-04-08 20:31:47 +0000819// Input/Output Instructions...
820//
Evan Cheng071a2792007-09-11 19:55:27 +0000821let Defs = [AL], Uses = [DX] in
Evan Cheng64d80e32007-07-19 01:14:50 +0000822def IN8rr : I<0xEC, RawFrm, (outs), (ins),
Evan Cheng071a2792007-09-11 19:55:27 +0000823 "in{b}\t{%dx, %al|%AL, %DX}", []>;
824let Defs = [AX], Uses = [DX] in
Evan Cheng64d80e32007-07-19 01:14:50 +0000825def IN16rr : I<0xED, RawFrm, (outs), (ins),
Evan Cheng071a2792007-09-11 19:55:27 +0000826 "in{w}\t{%dx, %ax|%AX, %DX}", []>, OpSize;
827let Defs = [EAX], Uses = [DX] in
Evan Cheng64d80e32007-07-19 01:14:50 +0000828def IN32rr : I<0xED, RawFrm, (outs), (ins),
Evan Cheng071a2792007-09-11 19:55:27 +0000829 "in{l}\t{%dx, %eax|%EAX, %DX}", []>;
John Criswell4ffff9e2004-04-08 20:31:47 +0000830
Evan Cheng071a2792007-09-11 19:55:27 +0000831let Defs = [AL] in
Evan Cheng64d80e32007-07-19 01:14:50 +0000832def IN8ri : Ii8<0xE4, RawFrm, (outs), (ins i16i8imm:$port),
Evan Cheng071a2792007-09-11 19:55:27 +0000833 "in{b}\t{$port, %al|%AL, $port}", []>;
834let Defs = [AX] in
Evan Cheng64d80e32007-07-19 01:14:50 +0000835def IN16ri : Ii8<0xE5, RawFrm, (outs), (ins i16i8imm:$port),
Evan Cheng071a2792007-09-11 19:55:27 +0000836 "in{w}\t{$port, %ax|%AX, $port}", []>, OpSize;
837let Defs = [EAX] in
Evan Cheng64d80e32007-07-19 01:14:50 +0000838def IN32ri : Ii8<0xE5, RawFrm, (outs), (ins i16i8imm:$port),
Evan Cheng071a2792007-09-11 19:55:27 +0000839 "in{l}\t{$port, %eax|%EAX, $port}", []>;
Chris Lattner440bbc22004-04-13 17:19:31 +0000840
Evan Cheng071a2792007-09-11 19:55:27 +0000841let Uses = [DX, AL] in
Evan Cheng64d80e32007-07-19 01:14:50 +0000842def OUT8rr : I<0xEE, RawFrm, (outs), (ins),
Evan Cheng071a2792007-09-11 19:55:27 +0000843 "out{b}\t{%al, %dx|%DX, %AL}", []>;
844let Uses = [DX, AX] in
Evan Cheng64d80e32007-07-19 01:14:50 +0000845def OUT16rr : I<0xEF, RawFrm, (outs), (ins),
Evan Cheng071a2792007-09-11 19:55:27 +0000846 "out{w}\t{%ax, %dx|%DX, %AX}", []>, OpSize;
847let Uses = [DX, EAX] in
Evan Cheng64d80e32007-07-19 01:14:50 +0000848def OUT32rr : I<0xEF, RawFrm, (outs), (ins),
Evan Cheng071a2792007-09-11 19:55:27 +0000849 "out{l}\t{%eax, %dx|%DX, %EAX}", []>;
Chris Lattnerffff7082004-08-01 07:44:35 +0000850
Evan Cheng071a2792007-09-11 19:55:27 +0000851let Uses = [AL] in
Evan Cheng64d80e32007-07-19 01:14:50 +0000852def OUT8ir : Ii8<0xE6, RawFrm, (outs), (ins i16i8imm:$port),
Evan Cheng071a2792007-09-11 19:55:27 +0000853 "out{b}\t{%al, $port|$port, %AL}", []>;
854let Uses = [AX] in
Evan Cheng64d80e32007-07-19 01:14:50 +0000855def OUT16ir : Ii8<0xE7, RawFrm, (outs), (ins i16i8imm:$port),
Evan Cheng071a2792007-09-11 19:55:27 +0000856 "out{w}\t{%ax, $port|$port, %AX}", []>, OpSize;
857let Uses = [EAX] in
Evan Cheng64d80e32007-07-19 01:14:50 +0000858def OUT32ir : Ii8<0xE7, RawFrm, (outs), (ins i16i8imm:$port),
Evan Cheng071a2792007-09-11 19:55:27 +0000859 "out{l}\t{%eax, $port|$port, %EAX}", []>;
John Criswell4ffff9e2004-04-08 20:31:47 +0000860
861//===----------------------------------------------------------------------===//
Chris Lattner1cca5e32003-08-03 21:54:21 +0000862// Move Instructions...
863//
Chris Lattnerba7e7562008-01-10 07:59:24 +0000864let neverHasSideEffects = 1 in {
Evan Cheng64d80e32007-07-19 01:14:50 +0000865def MOV8rr : I<0x88, MRMDestReg, (outs GR8 :$dst), (ins GR8 :$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000866 "mov{b}\t{$src, $dst|$dst, $src}", []>;
Evan Cheng64d80e32007-07-19 01:14:50 +0000867def MOV16rr : I<0x89, MRMDestReg, (outs GR16:$dst), (ins GR16:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000868 "mov{w}\t{$src, $dst|$dst, $src}", []>, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +0000869def MOV32rr : I<0x89, MRMDestReg, (outs GR32:$dst), (ins GR32:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000870 "mov{l}\t{$src, $dst|$dst, $src}", []>;
Chris Lattnerba7e7562008-01-10 07:59:24 +0000871}
Evan Cheng359e9372008-06-18 08:13:07 +0000872let isReMaterializable = 1, isAsCheapAsAMove = 1 in {
Evan Cheng64d80e32007-07-19 01:14:50 +0000873def MOV8ri : Ii8 <0xB0, AddRegFrm, (outs GR8 :$dst), (ins i8imm :$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000874 "mov{b}\t{$src, $dst|$dst, $src}",
Evan Cheng069287d2006-05-16 07:21:53 +0000875 [(set GR8:$dst, imm:$src)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +0000876def MOV16ri : Ii16<0xB8, AddRegFrm, (outs GR16:$dst), (ins i16imm:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000877 "mov{w}\t{$src, $dst|$dst, $src}",
Evan Cheng069287d2006-05-16 07:21:53 +0000878 [(set GR16:$dst, imm:$src)]>, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +0000879def MOV32ri : Ii32<0xB8, AddRegFrm, (outs GR32:$dst), (ins i32imm:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000880 "mov{l}\t{$src, $dst|$dst, $src}",
Evan Cheng069287d2006-05-16 07:21:53 +0000881 [(set GR32:$dst, imm:$src)]>;
Dan Gohmand45eddd2007-06-26 00:48:07 +0000882}
Evan Cheng64d80e32007-07-19 01:14:50 +0000883def MOV8mi : Ii8 <0xC6, MRM0m, (outs), (ins i8mem :$dst, i8imm :$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000884 "mov{b}\t{$src, $dst|$dst, $src}",
Evan Chengb51a0592005-12-10 00:48:20 +0000885 [(store (i8 imm:$src), addr:$dst)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +0000886def MOV16mi : Ii16<0xC7, MRM0m, (outs), (ins i16mem:$dst, i16imm:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000887 "mov{w}\t{$src, $dst|$dst, $src}",
Evan Chengb51a0592005-12-10 00:48:20 +0000888 [(store (i16 imm:$src), addr:$dst)]>, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +0000889def MOV32mi : Ii32<0xC7, MRM0m, (outs), (ins i32mem:$dst, i32imm:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000890 "mov{l}\t{$src, $dst|$dst, $src}",
Evan Chengb51a0592005-12-10 00:48:20 +0000891 [(store (i32 imm:$src), addr:$dst)]>;
Chris Lattner1cca5e32003-08-03 21:54:21 +0000892
Dan Gohman15511cf2008-12-03 18:15:48 +0000893let canFoldAsLoad = 1, isReMaterializable = 1, mayHaveSideEffects = 1 in {
Evan Cheng64d80e32007-07-19 01:14:50 +0000894def MOV8rm : I<0x8A, MRMSrcMem, (outs GR8 :$dst), (ins i8mem :$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000895 "mov{b}\t{$src, $dst|$dst, $src}",
Chris Lattnerc2406f22009-04-10 00:16:23 +0000896 [(set GR8:$dst, (loadi8 addr:$src))]>;
Evan Cheng64d80e32007-07-19 01:14:50 +0000897def MOV16rm : I<0x8B, MRMSrcMem, (outs GR16:$dst), (ins i16mem:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000898 "mov{w}\t{$src, $dst|$dst, $src}",
Chris Lattnerc2406f22009-04-10 00:16:23 +0000899 [(set GR16:$dst, (loadi16 addr:$src))]>, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +0000900def MOV32rm : I<0x8B, MRMSrcMem, (outs GR32:$dst), (ins i32mem:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000901 "mov{l}\t{$src, $dst|$dst, $src}",
Chris Lattnerc2406f22009-04-10 00:16:23 +0000902 [(set GR32:$dst, (loadi32 addr:$src))]>;
Evan Cheng2f394262007-08-30 05:49:43 +0000903}
Chris Lattner1cca5e32003-08-03 21:54:21 +0000904
Evan Cheng64d80e32007-07-19 01:14:50 +0000905def MOV8mr : I<0x88, MRMDestMem, (outs), (ins i8mem :$dst, GR8 :$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000906 "mov{b}\t{$src, $dst|$dst, $src}",
Evan Cheng069287d2006-05-16 07:21:53 +0000907 [(store GR8:$src, addr:$dst)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +0000908def MOV16mr : I<0x89, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000909 "mov{w}\t{$src, $dst|$dst, $src}",
Evan Cheng069287d2006-05-16 07:21:53 +0000910 [(store GR16:$src, addr:$dst)]>, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +0000911def MOV32mr : I<0x89, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000912 "mov{l}\t{$src, $dst|$dst, $src}",
Evan Cheng069287d2006-05-16 07:21:53 +0000913 [(store GR32:$src, addr:$dst)]>;
Dan Gohman21e3dfb2009-04-13 16:09:41 +0000914
Dan Gohman4af325d2009-04-27 16:41:36 +0000915// Versions of MOV8rr, MOV8mr, and MOV8rm that use i8mem_NOREX and GR8_NOREX so
916// that they can be used for copying and storing h registers, which can't be
917// encoded when a REX prefix is present.
Dan Gohman6d9305c2009-04-15 00:04:23 +0000918let neverHasSideEffects = 1 in
Dan Gohmandf7dfc72009-04-15 19:48:57 +0000919def MOV8rr_NOREX : I<0x88, MRMDestReg,
920 (outs GR8_NOREX:$dst), (ins GR8_NOREX:$src),
Dan Gohman6d9305c2009-04-15 00:04:23 +0000921 "mov{b}\t{$src, $dst|$dst, $src} # NOREX", []>;
Evan Cheng8c147402009-04-30 00:58:57 +0000922let mayStore = 1 in
Dan Gohman6d9305c2009-04-15 00:04:23 +0000923def MOV8mr_NOREX : I<0x88, MRMDestMem,
924 (outs), (ins i8mem_NOREX:$dst, GR8_NOREX:$src),
925 "mov{b}\t{$src, $dst|$dst, $src} # NOREX", []>;
Evan Cheng8c147402009-04-30 00:58:57 +0000926let mayLoad = 1,
927 canFoldAsLoad = 1, isReMaterializable = 1, mayHaveSideEffects = 1 in
Dan Gohman4af325d2009-04-27 16:41:36 +0000928def MOV8rm_NOREX : I<0x8A, MRMSrcMem,
929 (outs GR8_NOREX:$dst), (ins i8mem_NOREX:$src),
930 "mov{b}\t{$src, $dst|$dst, $src} # NOREX", []>;
Dan Gohman21e3dfb2009-04-13 16:09:41 +0000931
Chris Lattner1cca5e32003-08-03 21:54:21 +0000932//===----------------------------------------------------------------------===//
933// Fixed-Register Multiplication and Division Instructions...
934//
Chris Lattner1cca5e32003-08-03 21:54:21 +0000935
Chris Lattnerc8f45872003-08-04 04:59:56 +0000936// Extra precision multiplication
Evan Cheng24f2ea32007-09-14 21:48:26 +0000937let Defs = [AL,AH,EFLAGS], Uses = [AL] in
Dan Gohmanb1576f52007-07-31 20:11:57 +0000938def MUL8r : I<0xF6, MRM4r, (outs), (ins GR8:$src), "mul{b}\t$src",
Evan Chengcf74a7c2006-01-15 10:05:20 +0000939 // FIXME: Used for 8-bit mul, ignore result upper 8 bits.
940 // This probably ought to be moved to a def : Pat<> if the
941 // syntax can be accepted.
Bill Wendlingd350e022008-12-12 21:15:41 +0000942 [(set AL, (mul AL, GR8:$src)),
943 (implicit EFLAGS)]>; // AL,AH = AL*GR8
944
Chris Lattnera731c9f2008-01-11 07:18:17 +0000945let Defs = [AX,DX,EFLAGS], Uses = [AX], neverHasSideEffects = 1 in
Bill Wendlingd350e022008-12-12 21:15:41 +0000946def MUL16r : I<0xF7, MRM4r, (outs), (ins GR16:$src),
947 "mul{w}\t$src",
948 []>, OpSize; // AX,DX = AX*GR16
949
Chris Lattnera731c9f2008-01-11 07:18:17 +0000950let Defs = [EAX,EDX,EFLAGS], Uses = [EAX], neverHasSideEffects = 1 in
Bill Wendlingd350e022008-12-12 21:15:41 +0000951def MUL32r : I<0xF7, MRM4r, (outs), (ins GR32:$src),
952 "mul{l}\t$src",
953 []>; // EAX,EDX = EAX*GR32
954
Evan Cheng24f2ea32007-09-14 21:48:26 +0000955let Defs = [AL,AH,EFLAGS], Uses = [AL] in
Evan Cheng64d80e32007-07-19 01:14:50 +0000956def MUL8m : I<0xF6, MRM4m, (outs), (ins i8mem :$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000957 "mul{b}\t$src",
Evan Chengcf74a7c2006-01-15 10:05:20 +0000958 // FIXME: Used for 8-bit mul, ignore result upper 8 bits.
959 // This probably ought to be moved to a def : Pat<> if the
960 // syntax can be accepted.
Bill Wendlingd350e022008-12-12 21:15:41 +0000961 [(set AL, (mul AL, (loadi8 addr:$src))),
962 (implicit EFLAGS)]>; // AL,AH = AL*[mem8]
963
Chris Lattnerba7e7562008-01-10 07:59:24 +0000964let mayLoad = 1, neverHasSideEffects = 1 in {
Evan Cheng24f2ea32007-09-14 21:48:26 +0000965let Defs = [AX,DX,EFLAGS], Uses = [AX] in
Evan Cheng64d80e32007-07-19 01:14:50 +0000966def MUL16m : I<0xF7, MRM4m, (outs), (ins i16mem:$src),
Bill Wendlingd350e022008-12-12 21:15:41 +0000967 "mul{w}\t$src",
968 []>, OpSize; // AX,DX = AX*[mem16]
969
Evan Cheng24f2ea32007-09-14 21:48:26 +0000970let Defs = [EAX,EDX,EFLAGS], Uses = [EAX] in
Evan Cheng64d80e32007-07-19 01:14:50 +0000971def MUL32m : I<0xF7, MRM4m, (outs), (ins i32mem:$src),
Bill Wendlingd350e022008-12-12 21:15:41 +0000972 "mul{l}\t$src",
973 []>; // EAX,EDX = EAX*[mem32]
Chris Lattnerba7e7562008-01-10 07:59:24 +0000974}
Chris Lattner1cca5e32003-08-03 21:54:21 +0000975
Chris Lattnerba7e7562008-01-10 07:59:24 +0000976let neverHasSideEffects = 1 in {
Evan Cheng24f2ea32007-09-14 21:48:26 +0000977let Defs = [AL,AH,EFLAGS], Uses = [AL] in
Evan Cheng071a2792007-09-11 19:55:27 +0000978def IMUL8r : I<0xF6, MRM5r, (outs), (ins GR8:$src), "imul{b}\t$src", []>;
979 // AL,AH = AL*GR8
Evan Cheng24f2ea32007-09-14 21:48:26 +0000980let Defs = [AX,DX,EFLAGS], Uses = [AX] in
Dan Gohmanb1576f52007-07-31 20:11:57 +0000981def IMUL16r : I<0xF7, MRM5r, (outs), (ins GR16:$src), "imul{w}\t$src", []>,
Evan Cheng071a2792007-09-11 19:55:27 +0000982 OpSize; // AX,DX = AX*GR16
Evan Cheng24f2ea32007-09-14 21:48:26 +0000983let Defs = [EAX,EDX,EFLAGS], Uses = [EAX] in
Evan Cheng071a2792007-09-11 19:55:27 +0000984def IMUL32r : I<0xF7, MRM5r, (outs), (ins GR32:$src), "imul{l}\t$src", []>;
985 // EAX,EDX = EAX*GR32
Chris Lattnerba7e7562008-01-10 07:59:24 +0000986let mayLoad = 1 in {
Evan Cheng24f2ea32007-09-14 21:48:26 +0000987let Defs = [AL,AH,EFLAGS], Uses = [AL] in
Evan Cheng64d80e32007-07-19 01:14:50 +0000988def IMUL8m : I<0xF6, MRM5m, (outs), (ins i8mem :$src),
Evan Cheng071a2792007-09-11 19:55:27 +0000989 "imul{b}\t$src", []>; // AL,AH = AL*[mem8]
Evan Cheng24f2ea32007-09-14 21:48:26 +0000990let Defs = [AX,DX,EFLAGS], Uses = [AX] in
Evan Cheng64d80e32007-07-19 01:14:50 +0000991def IMUL16m : I<0xF7, MRM5m, (outs), (ins i16mem:$src),
Evan Cheng071a2792007-09-11 19:55:27 +0000992 "imul{w}\t$src", []>, OpSize; // AX,DX = AX*[mem16]
993let Defs = [EAX,EDX], Uses = [EAX] in
Evan Cheng64d80e32007-07-19 01:14:50 +0000994def IMUL32m : I<0xF7, MRM5m, (outs), (ins i32mem:$src),
Evan Cheng071a2792007-09-11 19:55:27 +0000995 "imul{l}\t$src", []>; // EAX,EDX = EAX*[mem32]
Chris Lattnerba7e7562008-01-10 07:59:24 +0000996}
Dan Gohmanc99da132008-11-18 21:29:14 +0000997} // neverHasSideEffects
Chris Lattner1e6a7152005-04-06 04:19:22 +0000998
Chris Lattnerc8f45872003-08-04 04:59:56 +0000999// unsigned division/remainder
Dale Johannesen2cb48ea2008-10-07 18:54:28 +00001000let Defs = [AL,AH,EFLAGS], Uses = [AX] in
Evan Cheng64d80e32007-07-19 01:14:50 +00001001def DIV8r : I<0xF6, MRM6r, (outs), (ins GR8:$src), // AX/r8 = AL,AH
Evan Cheng071a2792007-09-11 19:55:27 +00001002 "div{b}\t$src", []>;
Evan Cheng24f2ea32007-09-14 21:48:26 +00001003let Defs = [AX,DX,EFLAGS], Uses = [AX,DX] in
Evan Cheng64d80e32007-07-19 01:14:50 +00001004def DIV16r : I<0xF7, MRM6r, (outs), (ins GR16:$src), // DX:AX/r16 = AX,DX
Evan Cheng071a2792007-09-11 19:55:27 +00001005 "div{w}\t$src", []>, OpSize;
Evan Cheng24f2ea32007-09-14 21:48:26 +00001006let Defs = [EAX,EDX,EFLAGS], Uses = [EAX,EDX] in
Evan Cheng64d80e32007-07-19 01:14:50 +00001007def DIV32r : I<0xF7, MRM6r, (outs), (ins GR32:$src), // EDX:EAX/r32 = EAX,EDX
Evan Cheng071a2792007-09-11 19:55:27 +00001008 "div{l}\t$src", []>;
Chris Lattnerba7e7562008-01-10 07:59:24 +00001009let mayLoad = 1 in {
Dale Johannesen2cb48ea2008-10-07 18:54:28 +00001010let Defs = [AL,AH,EFLAGS], Uses = [AX] in
Evan Cheng64d80e32007-07-19 01:14:50 +00001011def DIV8m : I<0xF6, MRM6m, (outs), (ins i8mem:$src), // AX/[mem8] = AL,AH
Evan Cheng071a2792007-09-11 19:55:27 +00001012 "div{b}\t$src", []>;
Evan Cheng24f2ea32007-09-14 21:48:26 +00001013let Defs = [AX,DX,EFLAGS], Uses = [AX,DX] in
Evan Cheng64d80e32007-07-19 01:14:50 +00001014def DIV16m : I<0xF7, MRM6m, (outs), (ins i16mem:$src), // DX:AX/[mem16] = AX,DX
Evan Cheng071a2792007-09-11 19:55:27 +00001015 "div{w}\t$src", []>, OpSize;
Evan Cheng24f2ea32007-09-14 21:48:26 +00001016let Defs = [EAX,EDX,EFLAGS], Uses = [EAX,EDX] in
Evan Cheng64d80e32007-07-19 01:14:50 +00001017def DIV32m : I<0xF7, MRM6m, (outs), (ins i32mem:$src), // EDX:EAX/[mem32] = EAX,EDX
Evan Cheng071a2792007-09-11 19:55:27 +00001018 "div{l}\t$src", []>;
Chris Lattnerba7e7562008-01-10 07:59:24 +00001019}
Chris Lattner1cca5e32003-08-03 21:54:21 +00001020
Chris Lattnerfc752712004-08-01 09:52:59 +00001021// Signed division/remainder.
Dale Johannesen2cb48ea2008-10-07 18:54:28 +00001022let Defs = [AL,AH,EFLAGS], Uses = [AX] in
Evan Cheng64d80e32007-07-19 01:14:50 +00001023def IDIV8r : I<0xF6, MRM7r, (outs), (ins GR8:$src), // AX/r8 = AL,AH
Evan Cheng071a2792007-09-11 19:55:27 +00001024 "idiv{b}\t$src", []>;
Evan Cheng24f2ea32007-09-14 21:48:26 +00001025let Defs = [AX,DX,EFLAGS], Uses = [AX,DX] in
Evan Cheng64d80e32007-07-19 01:14:50 +00001026def IDIV16r: I<0xF7, MRM7r, (outs), (ins GR16:$src), // DX:AX/r16 = AX,DX
Evan Cheng071a2792007-09-11 19:55:27 +00001027 "idiv{w}\t$src", []>, OpSize;
Evan Cheng24f2ea32007-09-14 21:48:26 +00001028let Defs = [EAX,EDX,EFLAGS], Uses = [EAX,EDX] in
Evan Cheng64d80e32007-07-19 01:14:50 +00001029def IDIV32r: I<0xF7, MRM7r, (outs), (ins GR32:$src), // EDX:EAX/r32 = EAX,EDX
Evan Cheng071a2792007-09-11 19:55:27 +00001030 "idiv{l}\t$src", []>;
Chris Lattnerba7e7562008-01-10 07:59:24 +00001031let mayLoad = 1, mayLoad = 1 in {
Dale Johannesen2cb48ea2008-10-07 18:54:28 +00001032let Defs = [AL,AH,EFLAGS], Uses = [AX] in
Evan Cheng64d80e32007-07-19 01:14:50 +00001033def IDIV8m : I<0xF6, MRM7m, (outs), (ins i8mem:$src), // AX/[mem8] = AL,AH
Evan Cheng071a2792007-09-11 19:55:27 +00001034 "idiv{b}\t$src", []>;
Evan Cheng24f2ea32007-09-14 21:48:26 +00001035let Defs = [AX,DX,EFLAGS], Uses = [AX,DX] in
Evan Cheng64d80e32007-07-19 01:14:50 +00001036def IDIV16m: I<0xF7, MRM7m, (outs), (ins i16mem:$src), // DX:AX/[mem16] = AX,DX
Evan Cheng071a2792007-09-11 19:55:27 +00001037 "idiv{w}\t$src", []>, OpSize;
Evan Cheng24f2ea32007-09-14 21:48:26 +00001038let Defs = [EAX,EDX,EFLAGS], Uses = [EAX,EDX] in
Evan Cheng64d80e32007-07-19 01:14:50 +00001039def IDIV32m: I<0xF7, MRM7m, (outs), (ins i32mem:$src), // EDX:EAX/[mem32] = EAX,EDX
Evan Cheng071a2792007-09-11 19:55:27 +00001040 "idiv{l}\t$src", []>;
Chris Lattnerba7e7562008-01-10 07:59:24 +00001041}
Chris Lattner1cca5e32003-08-03 21:54:21 +00001042
Chris Lattner1cca5e32003-08-03 21:54:21 +00001043//===----------------------------------------------------------------------===//
Chris Lattnerba7e7562008-01-10 07:59:24 +00001044// Two address Instructions.
Chris Lattner1cca5e32003-08-03 21:54:21 +00001045//
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00001046let isTwoAddress = 1 in {
Chris Lattner1cca5e32003-08-03 21:54:21 +00001047
Alkis Evlogimenosa3f66842004-03-12 17:59:56 +00001048// Conditional moves
Evan Cheng0488db92007-09-25 01:57:46 +00001049let Uses = [EFLAGS] in {
Dan Gohmancbbea0f2009-08-27 00:14:12 +00001050
1051// X86 doesn't have 8-bit conditional moves. Use a customDAGSchedInserter to
1052// emit control flow. An alternative to this is to mark i8 SELECT as Promote,
1053// however that requires promoting the operands, and can induce additional
Dan Gohman71a258c2009-08-29 22:19:15 +00001054// i8 register pressure. Note that CMOV_GR8 is conservatively considered to
1055// clobber EFLAGS, because if one of the operands is zero, the expansion
1056// could involve an xor.
1057let usesCustomDAGSchedInserter = 1, isTwoAddress = 0, Defs = [EFLAGS] in
Dan Gohmancbbea0f2009-08-27 00:14:12 +00001058def CMOV_GR8 : I<0, Pseudo,
1059 (outs GR8:$dst), (ins GR8:$src1, GR8:$src2, i8imm:$cond),
1060 "#CMOV_GR8 PSEUDO!",
1061 [(set GR8:$dst, (X86cmov GR8:$src1, GR8:$src2,
1062 imm:$cond, EFLAGS))]>;
1063
Dan Gohmana4c5c332009-08-27 18:16:24 +00001064let isCommutable = 1 in {
Evan Cheng069287d2006-05-16 07:21:53 +00001065def CMOVB16rr : I<0x42, MRMSrcReg, // if <u, GR16 = GR16
Evan Cheng64d80e32007-07-19 01:14:50 +00001066 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001067 "cmovb\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001068 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Chenge5f62042007-09-29 00:00:36 +00001069 X86_COND_B, EFLAGS))]>,
Evan Cheng71fb9ad2006-01-26 00:29:36 +00001070 TB, OpSize;
Evan Cheng069287d2006-05-16 07:21:53 +00001071def CMOVB32rr : I<0x42, MRMSrcReg, // if <u, GR32 = GR32
Evan Cheng64d80e32007-07-19 01:14:50 +00001072 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001073 "cmovb\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001074 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Chenge5f62042007-09-29 00:00:36 +00001075 X86_COND_B, EFLAGS))]>,
Evan Cheng71fb9ad2006-01-26 00:29:36 +00001076 TB;
Evan Cheng069287d2006-05-16 07:21:53 +00001077def CMOVAE16rr: I<0x43, MRMSrcReg, // if >=u, GR16 = GR16
Evan Cheng64d80e32007-07-19 01:14:50 +00001078 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001079 "cmovae\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001080 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Chenge5f62042007-09-29 00:00:36 +00001081 X86_COND_AE, EFLAGS))]>,
Evan Cheng71fb9ad2006-01-26 00:29:36 +00001082 TB, OpSize;
Evan Cheng069287d2006-05-16 07:21:53 +00001083def CMOVAE32rr: I<0x43, MRMSrcReg, // if >=u, GR32 = GR32
Evan Cheng64d80e32007-07-19 01:14:50 +00001084 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001085 "cmovae\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001086 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Chenge5f62042007-09-29 00:00:36 +00001087 X86_COND_AE, EFLAGS))]>,
Evan Cheng71fb9ad2006-01-26 00:29:36 +00001088 TB;
Evan Cheng069287d2006-05-16 07:21:53 +00001089def CMOVE16rr : I<0x44, MRMSrcReg, // if ==, GR16 = GR16
Evan Cheng64d80e32007-07-19 01:14:50 +00001090 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001091 "cmove\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001092 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Chenge5f62042007-09-29 00:00:36 +00001093 X86_COND_E, EFLAGS))]>,
Evan Cheng71fb9ad2006-01-26 00:29:36 +00001094 TB, OpSize;
Evan Cheng069287d2006-05-16 07:21:53 +00001095def CMOVE32rr : I<0x44, MRMSrcReg, // if ==, GR32 = GR32
Evan Cheng64d80e32007-07-19 01:14:50 +00001096 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001097 "cmove\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001098 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Chenge5f62042007-09-29 00:00:36 +00001099 X86_COND_E, EFLAGS))]>,
Evan Cheng71fb9ad2006-01-26 00:29:36 +00001100 TB;
Evan Cheng069287d2006-05-16 07:21:53 +00001101def CMOVNE16rr: I<0x45, MRMSrcReg, // if !=, GR16 = GR16
Evan Cheng64d80e32007-07-19 01:14:50 +00001102 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001103 "cmovne\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001104 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Chenge5f62042007-09-29 00:00:36 +00001105 X86_COND_NE, EFLAGS))]>,
Evan Cheng71fb9ad2006-01-26 00:29:36 +00001106 TB, OpSize;
Evan Cheng069287d2006-05-16 07:21:53 +00001107def CMOVNE32rr: I<0x45, MRMSrcReg, // if !=, GR32 = GR32
Evan Cheng64d80e32007-07-19 01:14:50 +00001108 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001109 "cmovne\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001110 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Chenge5f62042007-09-29 00:00:36 +00001111 X86_COND_NE, EFLAGS))]>,
Evan Cheng71fb9ad2006-01-26 00:29:36 +00001112 TB;
Evan Cheng069287d2006-05-16 07:21:53 +00001113def CMOVBE16rr: I<0x46, MRMSrcReg, // if <=u, GR16 = GR16
Evan Cheng64d80e32007-07-19 01:14:50 +00001114 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001115 "cmovbe\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001116 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Chenge5f62042007-09-29 00:00:36 +00001117 X86_COND_BE, EFLAGS))]>,
Evan Cheng71fb9ad2006-01-26 00:29:36 +00001118 TB, OpSize;
Evan Cheng069287d2006-05-16 07:21:53 +00001119def CMOVBE32rr: I<0x46, MRMSrcReg, // if <=u, GR32 = GR32
Evan Cheng64d80e32007-07-19 01:14:50 +00001120 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001121 "cmovbe\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001122 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Chenge5f62042007-09-29 00:00:36 +00001123 X86_COND_BE, EFLAGS))]>,
Evan Cheng71fb9ad2006-01-26 00:29:36 +00001124 TB;
Evan Cheng069287d2006-05-16 07:21:53 +00001125def CMOVA16rr : I<0x47, MRMSrcReg, // if >u, GR16 = GR16
Evan Cheng64d80e32007-07-19 01:14:50 +00001126 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001127 "cmova\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001128 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Chenge5f62042007-09-29 00:00:36 +00001129 X86_COND_A, EFLAGS))]>,
Evan Cheng71fb9ad2006-01-26 00:29:36 +00001130 TB, OpSize;
Evan Cheng069287d2006-05-16 07:21:53 +00001131def CMOVA32rr : I<0x47, MRMSrcReg, // if >u, GR32 = GR32
Evan Cheng64d80e32007-07-19 01:14:50 +00001132 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001133 "cmova\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001134 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Chenge5f62042007-09-29 00:00:36 +00001135 X86_COND_A, EFLAGS))]>,
Evan Cheng71fb9ad2006-01-26 00:29:36 +00001136 TB;
Evan Cheng069287d2006-05-16 07:21:53 +00001137def CMOVL16rr : I<0x4C, MRMSrcReg, // if <s, GR16 = GR16
Evan Cheng64d80e32007-07-19 01:14:50 +00001138 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001139 "cmovl\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001140 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Chenge5f62042007-09-29 00:00:36 +00001141 X86_COND_L, EFLAGS))]>,
Evan Cheng71fb9ad2006-01-26 00:29:36 +00001142 TB, OpSize;
Evan Cheng069287d2006-05-16 07:21:53 +00001143def CMOVL32rr : I<0x4C, MRMSrcReg, // if <s, GR32 = GR32
Evan Cheng64d80e32007-07-19 01:14:50 +00001144 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001145 "cmovl\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001146 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Chenge5f62042007-09-29 00:00:36 +00001147 X86_COND_L, EFLAGS))]>,
Evan Cheng71fb9ad2006-01-26 00:29:36 +00001148 TB;
Evan Cheng069287d2006-05-16 07:21:53 +00001149def CMOVGE16rr: I<0x4D, MRMSrcReg, // if >=s, GR16 = GR16
Evan Cheng64d80e32007-07-19 01:14:50 +00001150 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001151 "cmovge\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001152 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Chenge5f62042007-09-29 00:00:36 +00001153 X86_COND_GE, EFLAGS))]>,
Evan Cheng71fb9ad2006-01-26 00:29:36 +00001154 TB, OpSize;
Evan Cheng069287d2006-05-16 07:21:53 +00001155def CMOVGE32rr: I<0x4D, MRMSrcReg, // if >=s, GR32 = GR32
Evan Cheng64d80e32007-07-19 01:14:50 +00001156 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001157 "cmovge\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001158 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Chenge5f62042007-09-29 00:00:36 +00001159 X86_COND_GE, EFLAGS))]>,
Evan Cheng71fb9ad2006-01-26 00:29:36 +00001160 TB;
Evan Cheng069287d2006-05-16 07:21:53 +00001161def CMOVLE16rr: I<0x4E, MRMSrcReg, // if <=s, GR16 = GR16
Evan Cheng64d80e32007-07-19 01:14:50 +00001162 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001163 "cmovle\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001164 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Chenge5f62042007-09-29 00:00:36 +00001165 X86_COND_LE, EFLAGS))]>,
Evan Cheng71fb9ad2006-01-26 00:29:36 +00001166 TB, OpSize;
Evan Cheng069287d2006-05-16 07:21:53 +00001167def CMOVLE32rr: I<0x4E, MRMSrcReg, // if <=s, GR32 = GR32
Evan Cheng64d80e32007-07-19 01:14:50 +00001168 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001169 "cmovle\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001170 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Chenge5f62042007-09-29 00:00:36 +00001171 X86_COND_LE, EFLAGS))]>,
Evan Cheng71fb9ad2006-01-26 00:29:36 +00001172 TB;
Evan Cheng069287d2006-05-16 07:21:53 +00001173def CMOVG16rr : I<0x4F, MRMSrcReg, // if >s, GR16 = GR16
Evan Cheng64d80e32007-07-19 01:14:50 +00001174 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001175 "cmovg\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001176 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Chenge5f62042007-09-29 00:00:36 +00001177 X86_COND_G, EFLAGS))]>,
Evan Cheng71fb9ad2006-01-26 00:29:36 +00001178 TB, OpSize;
Evan Cheng069287d2006-05-16 07:21:53 +00001179def CMOVG32rr : I<0x4F, MRMSrcReg, // if >s, GR32 = GR32
Evan Cheng64d80e32007-07-19 01:14:50 +00001180 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001181 "cmovg\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001182 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Chenge5f62042007-09-29 00:00:36 +00001183 X86_COND_G, EFLAGS))]>,
Evan Cheng71fb9ad2006-01-26 00:29:36 +00001184 TB;
Evan Cheng069287d2006-05-16 07:21:53 +00001185def CMOVS16rr : I<0x48, MRMSrcReg, // if signed, GR16 = GR16
Evan Cheng64d80e32007-07-19 01:14:50 +00001186 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001187 "cmovs\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001188 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Chenge5f62042007-09-29 00:00:36 +00001189 X86_COND_S, EFLAGS))]>,
Evan Cheng71fb9ad2006-01-26 00:29:36 +00001190 TB, OpSize;
Evan Cheng069287d2006-05-16 07:21:53 +00001191def CMOVS32rr : I<0x48, MRMSrcReg, // if signed, GR32 = GR32
Evan Cheng64d80e32007-07-19 01:14:50 +00001192 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001193 "cmovs\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001194 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Chenge5f62042007-09-29 00:00:36 +00001195 X86_COND_S, EFLAGS))]>,
Evan Cheng71fb9ad2006-01-26 00:29:36 +00001196 TB;
Evan Cheng069287d2006-05-16 07:21:53 +00001197def CMOVNS16rr: I<0x49, MRMSrcReg, // if !signed, GR16 = GR16
Evan Cheng64d80e32007-07-19 01:14:50 +00001198 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001199 "cmovns\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001200 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Chenge5f62042007-09-29 00:00:36 +00001201 X86_COND_NS, EFLAGS))]>,
Evan Cheng71fb9ad2006-01-26 00:29:36 +00001202 TB, OpSize;
Evan Cheng069287d2006-05-16 07:21:53 +00001203def CMOVNS32rr: I<0x49, MRMSrcReg, // if !signed, GR32 = GR32
Evan Cheng64d80e32007-07-19 01:14:50 +00001204 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001205 "cmovns\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001206 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Chenge5f62042007-09-29 00:00:36 +00001207 X86_COND_NS, EFLAGS))]>,
Evan Cheng71fb9ad2006-01-26 00:29:36 +00001208 TB;
Evan Cheng069287d2006-05-16 07:21:53 +00001209def CMOVP16rr : I<0x4A, MRMSrcReg, // if parity, GR16 = GR16
Evan Cheng64d80e32007-07-19 01:14:50 +00001210 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001211 "cmovp\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001212 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Chenge5f62042007-09-29 00:00:36 +00001213 X86_COND_P, EFLAGS))]>,
Evan Cheng71fb9ad2006-01-26 00:29:36 +00001214 TB, OpSize;
Evan Cheng069287d2006-05-16 07:21:53 +00001215def CMOVP32rr : I<0x4A, MRMSrcReg, // if parity, GR32 = GR32
Evan Cheng64d80e32007-07-19 01:14:50 +00001216 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001217 "cmovp\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001218 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Chenge5f62042007-09-29 00:00:36 +00001219 X86_COND_P, EFLAGS))]>,
Evan Cheng71fb9ad2006-01-26 00:29:36 +00001220 TB;
Evan Cheng069287d2006-05-16 07:21:53 +00001221def CMOVNP16rr : I<0x4B, MRMSrcReg, // if !parity, GR16 = GR16
Evan Cheng64d80e32007-07-19 01:14:50 +00001222 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001223 "cmovnp\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001224 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Chenge5f62042007-09-29 00:00:36 +00001225 X86_COND_NP, EFLAGS))]>,
Evan Cheng71fb9ad2006-01-26 00:29:36 +00001226 TB, OpSize;
Evan Cheng069287d2006-05-16 07:21:53 +00001227def CMOVNP32rr : I<0x4B, MRMSrcReg, // if !parity, GR32 = GR32
Evan Cheng64d80e32007-07-19 01:14:50 +00001228 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001229 "cmovnp\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001230 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Chenge5f62042007-09-29 00:00:36 +00001231 X86_COND_NP, EFLAGS))]>,
Evan Cheng71fb9ad2006-01-26 00:29:36 +00001232 TB;
Dan Gohman305fceb2009-01-07 00:35:10 +00001233def CMOVO16rr : I<0x40, MRMSrcReg, // if overflow, GR16 = GR16
1234 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
1235 "cmovo\t{$src2, $dst|$dst, $src2}",
1236 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
1237 X86_COND_O, EFLAGS))]>,
1238 TB, OpSize;
1239def CMOVO32rr : I<0x40, MRMSrcReg, // if overflow, GR32 = GR32
1240 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
1241 "cmovo\t{$src2, $dst|$dst, $src2}",
1242 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
1243 X86_COND_O, EFLAGS))]>,
Evan Cheng0488db92007-09-25 01:57:46 +00001244 TB;
Dan Gohman305fceb2009-01-07 00:35:10 +00001245def CMOVNO16rr : I<0x41, MRMSrcReg, // if !overflow, GR16 = GR16
1246 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
1247 "cmovno\t{$src2, $dst|$dst, $src2}",
1248 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
1249 X86_COND_NO, EFLAGS))]>,
1250 TB, OpSize;
1251def CMOVNO32rr : I<0x41, MRMSrcReg, // if !overflow, GR32 = GR32
1252 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
1253 "cmovno\t{$src2, $dst|$dst, $src2}",
1254 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
1255 X86_COND_NO, EFLAGS))]>,
1256 TB;
1257} // isCommutable = 1
Evan Cheng7ad42d92007-10-05 23:13:21 +00001258
1259def CMOVB16rm : I<0x42, MRMSrcMem, // if <u, GR16 = [mem16]
1260 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1261 "cmovb\t{$src2, $dst|$dst, $src2}",
1262 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1263 X86_COND_B, EFLAGS))]>,
1264 TB, OpSize;
1265def CMOVB32rm : I<0x42, MRMSrcMem, // if <u, GR32 = [mem32]
1266 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1267 "cmovb\t{$src2, $dst|$dst, $src2}",
1268 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1269 X86_COND_B, EFLAGS))]>,
1270 TB;
1271def CMOVAE16rm: I<0x43, MRMSrcMem, // if >=u, GR16 = [mem16]
1272 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1273 "cmovae\t{$src2, $dst|$dst, $src2}",
1274 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1275 X86_COND_AE, EFLAGS))]>,
1276 TB, OpSize;
1277def CMOVAE32rm: I<0x43, MRMSrcMem, // if >=u, GR32 = [mem32]
1278 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1279 "cmovae\t{$src2, $dst|$dst, $src2}",
1280 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1281 X86_COND_AE, EFLAGS))]>,
1282 TB;
1283def CMOVE16rm : I<0x44, MRMSrcMem, // if ==, GR16 = [mem16]
1284 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1285 "cmove\t{$src2, $dst|$dst, $src2}",
1286 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1287 X86_COND_E, EFLAGS))]>,
1288 TB, OpSize;
1289def CMOVE32rm : I<0x44, MRMSrcMem, // if ==, GR32 = [mem32]
1290 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1291 "cmove\t{$src2, $dst|$dst, $src2}",
1292 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1293 X86_COND_E, EFLAGS))]>,
1294 TB;
1295def CMOVNE16rm: I<0x45, MRMSrcMem, // if !=, GR16 = [mem16]
1296 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1297 "cmovne\t{$src2, $dst|$dst, $src2}",
1298 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1299 X86_COND_NE, EFLAGS))]>,
1300 TB, OpSize;
1301def CMOVNE32rm: I<0x45, MRMSrcMem, // if !=, GR32 = [mem32]
1302 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1303 "cmovne\t{$src2, $dst|$dst, $src2}",
1304 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1305 X86_COND_NE, EFLAGS))]>,
1306 TB;
1307def CMOVBE16rm: I<0x46, MRMSrcMem, // if <=u, GR16 = [mem16]
1308 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1309 "cmovbe\t{$src2, $dst|$dst, $src2}",
1310 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1311 X86_COND_BE, EFLAGS))]>,
1312 TB, OpSize;
1313def CMOVBE32rm: I<0x46, MRMSrcMem, // if <=u, GR32 = [mem32]
1314 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1315 "cmovbe\t{$src2, $dst|$dst, $src2}",
1316 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1317 X86_COND_BE, EFLAGS))]>,
1318 TB;
1319def CMOVA16rm : I<0x47, MRMSrcMem, // if >u, GR16 = [mem16]
1320 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1321 "cmova\t{$src2, $dst|$dst, $src2}",
1322 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1323 X86_COND_A, EFLAGS))]>,
1324 TB, OpSize;
1325def CMOVA32rm : I<0x47, MRMSrcMem, // if >u, GR32 = [mem32]
1326 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1327 "cmova\t{$src2, $dst|$dst, $src2}",
1328 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1329 X86_COND_A, EFLAGS))]>,
1330 TB;
1331def CMOVL16rm : I<0x4C, MRMSrcMem, // if <s, GR16 = [mem16]
1332 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1333 "cmovl\t{$src2, $dst|$dst, $src2}",
1334 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1335 X86_COND_L, EFLAGS))]>,
1336 TB, OpSize;
1337def CMOVL32rm : I<0x4C, MRMSrcMem, // if <s, GR32 = [mem32]
1338 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1339 "cmovl\t{$src2, $dst|$dst, $src2}",
1340 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1341 X86_COND_L, EFLAGS))]>,
1342 TB;
1343def CMOVGE16rm: I<0x4D, MRMSrcMem, // if >=s, GR16 = [mem16]
1344 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1345 "cmovge\t{$src2, $dst|$dst, $src2}",
1346 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1347 X86_COND_GE, EFLAGS))]>,
1348 TB, OpSize;
1349def CMOVGE32rm: I<0x4D, MRMSrcMem, // if >=s, GR32 = [mem32]
1350 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1351 "cmovge\t{$src2, $dst|$dst, $src2}",
1352 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1353 X86_COND_GE, EFLAGS))]>,
1354 TB;
1355def CMOVLE16rm: I<0x4E, MRMSrcMem, // if <=s, GR16 = [mem16]
1356 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1357 "cmovle\t{$src2, $dst|$dst, $src2}",
1358 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1359 X86_COND_LE, EFLAGS))]>,
1360 TB, OpSize;
1361def CMOVLE32rm: I<0x4E, MRMSrcMem, // if <=s, GR32 = [mem32]
1362 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1363 "cmovle\t{$src2, $dst|$dst, $src2}",
1364 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1365 X86_COND_LE, EFLAGS))]>,
1366 TB;
1367def CMOVG16rm : I<0x4F, MRMSrcMem, // if >s, GR16 = [mem16]
1368 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1369 "cmovg\t{$src2, $dst|$dst, $src2}",
1370 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1371 X86_COND_G, EFLAGS))]>,
1372 TB, OpSize;
1373def CMOVG32rm : I<0x4F, MRMSrcMem, // if >s, GR32 = [mem32]
1374 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1375 "cmovg\t{$src2, $dst|$dst, $src2}",
1376 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1377 X86_COND_G, EFLAGS))]>,
1378 TB;
1379def CMOVS16rm : I<0x48, MRMSrcMem, // if signed, GR16 = [mem16]
1380 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1381 "cmovs\t{$src2, $dst|$dst, $src2}",
1382 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1383 X86_COND_S, EFLAGS))]>,
1384 TB, OpSize;
1385def CMOVS32rm : I<0x48, MRMSrcMem, // if signed, GR32 = [mem32]
1386 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1387 "cmovs\t{$src2, $dst|$dst, $src2}",
1388 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1389 X86_COND_S, EFLAGS))]>,
1390 TB;
1391def CMOVNS16rm: I<0x49, MRMSrcMem, // if !signed, GR16 = [mem16]
1392 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1393 "cmovns\t{$src2, $dst|$dst, $src2}",
1394 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1395 X86_COND_NS, EFLAGS))]>,
1396 TB, OpSize;
1397def CMOVNS32rm: I<0x49, MRMSrcMem, // if !signed, GR32 = [mem32]
1398 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1399 "cmovns\t{$src2, $dst|$dst, $src2}",
1400 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1401 X86_COND_NS, EFLAGS))]>,
1402 TB;
1403def CMOVP16rm : I<0x4A, MRMSrcMem, // if parity, GR16 = [mem16]
1404 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1405 "cmovp\t{$src2, $dst|$dst, $src2}",
1406 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1407 X86_COND_P, EFLAGS))]>,
1408 TB, OpSize;
1409def CMOVP32rm : I<0x4A, MRMSrcMem, // if parity, GR32 = [mem32]
1410 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1411 "cmovp\t{$src2, $dst|$dst, $src2}",
1412 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1413 X86_COND_P, EFLAGS))]>,
1414 TB;
1415def CMOVNP16rm : I<0x4B, MRMSrcMem, // if !parity, GR16 = [mem16]
1416 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1417 "cmovnp\t{$src2, $dst|$dst, $src2}",
1418 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1419 X86_COND_NP, EFLAGS))]>,
1420 TB, OpSize;
Dan Gohman305fceb2009-01-07 00:35:10 +00001421def CMOVNP32rm : I<0x4B, MRMSrcMem, // if !parity, GR32 = [mem32]
1422 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1423 "cmovnp\t{$src2, $dst|$dst, $src2}",
1424 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1425 X86_COND_NP, EFLAGS))]>,
1426 TB;
1427def CMOVO16rm : I<0x40, MRMSrcMem, // if overflow, GR16 = [mem16]
1428 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1429 "cmovo\t{$src2, $dst|$dst, $src2}",
1430 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1431 X86_COND_O, EFLAGS))]>,
1432 TB, OpSize;
1433def CMOVO32rm : I<0x40, MRMSrcMem, // if overflow, GR32 = [mem32]
1434 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1435 "cmovo\t{$src2, $dst|$dst, $src2}",
1436 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1437 X86_COND_O, EFLAGS))]>,
1438 TB;
1439def CMOVNO16rm : I<0x41, MRMSrcMem, // if !overflow, GR16 = [mem16]
1440 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1441 "cmovno\t{$src2, $dst|$dst, $src2}",
1442 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1443 X86_COND_NO, EFLAGS))]>,
1444 TB, OpSize;
1445def CMOVNO32rm : I<0x41, MRMSrcMem, // if !overflow, GR32 = [mem32]
1446 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1447 "cmovno\t{$src2, $dst|$dst, $src2}",
1448 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1449 X86_COND_NO, EFLAGS))]>,
1450 TB;
Evan Cheng0488db92007-09-25 01:57:46 +00001451} // Uses = [EFLAGS]
1452
1453
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00001454// unary instructions
Evan Cheng1693e482006-07-19 00:27:29 +00001455let CodeSize = 2 in {
Evan Cheng24f2ea32007-09-14 21:48:26 +00001456let Defs = [EFLAGS] in {
Dan Gohmanb1576f52007-07-31 20:11:57 +00001457def NEG8r : I<0xF6, MRM3r, (outs GR8 :$dst), (ins GR8 :$src), "neg{b}\t$dst",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001458 [(set GR8:$dst, (ineg GR8:$src)),
1459 (implicit EFLAGS)]>;
Dan Gohmanb1576f52007-07-31 20:11:57 +00001460def NEG16r : I<0xF7, MRM3r, (outs GR16:$dst), (ins GR16:$src), "neg{w}\t$dst",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001461 [(set GR16:$dst, (ineg GR16:$src)),
1462 (implicit EFLAGS)]>, OpSize;
Dan Gohmanb1576f52007-07-31 20:11:57 +00001463def NEG32r : I<0xF7, MRM3r, (outs GR32:$dst), (ins GR32:$src), "neg{l}\t$dst",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001464 [(set GR32:$dst, (ineg GR32:$src)),
1465 (implicit EFLAGS)]>;
Chris Lattner57a02302004-08-11 04:31:00 +00001466let isTwoAddress = 0 in {
Dan Gohmanb1576f52007-07-31 20:11:57 +00001467 def NEG8m : I<0xF6, MRM3m, (outs), (ins i8mem :$dst), "neg{b}\t$dst",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001468 [(store (ineg (loadi8 addr:$dst)), addr:$dst),
1469 (implicit EFLAGS)]>;
Dan Gohmanb1576f52007-07-31 20:11:57 +00001470 def NEG16m : I<0xF7, MRM3m, (outs), (ins i16mem:$dst), "neg{w}\t$dst",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001471 [(store (ineg (loadi16 addr:$dst)), addr:$dst),
1472 (implicit EFLAGS)]>, OpSize;
Dan Gohmanb1576f52007-07-31 20:11:57 +00001473 def NEG32m : I<0xF7, MRM3m, (outs), (ins i32mem:$dst), "neg{l}\t$dst",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001474 [(store (ineg (loadi32 addr:$dst)), addr:$dst),
1475 (implicit EFLAGS)]>;
Chris Lattner57a02302004-08-11 04:31:00 +00001476}
Evan Cheng24f2ea32007-09-14 21:48:26 +00001477} // Defs = [EFLAGS]
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00001478
Evan Chengaaf414c2009-01-21 02:09:05 +00001479// Match xor -1 to not. Favors these over a move imm + xor to save code size.
1480let AddedComplexity = 15 in {
Dan Gohmanb1576f52007-07-31 20:11:57 +00001481def NOT8r : I<0xF6, MRM2r, (outs GR8 :$dst), (ins GR8 :$src), "not{b}\t$dst",
Evan Cheng069287d2006-05-16 07:21:53 +00001482 [(set GR8:$dst, (not GR8:$src))]>;
Dan Gohmanb1576f52007-07-31 20:11:57 +00001483def NOT16r : I<0xF7, MRM2r, (outs GR16:$dst), (ins GR16:$src), "not{w}\t$dst",
Evan Cheng069287d2006-05-16 07:21:53 +00001484 [(set GR16:$dst, (not GR16:$src))]>, OpSize;
Dan Gohmanb1576f52007-07-31 20:11:57 +00001485def NOT32r : I<0xF7, MRM2r, (outs GR32:$dst), (ins GR32:$src), "not{l}\t$dst",
Evan Cheng069287d2006-05-16 07:21:53 +00001486 [(set GR32:$dst, (not GR32:$src))]>;
Evan Chengaaf414c2009-01-21 02:09:05 +00001487}
Chris Lattner57a02302004-08-11 04:31:00 +00001488let isTwoAddress = 0 in {
Dan Gohmanb1576f52007-07-31 20:11:57 +00001489 def NOT8m : I<0xF6, MRM2m, (outs), (ins i8mem :$dst), "not{b}\t$dst",
Evan Cheng605c4152005-12-13 01:57:51 +00001490 [(store (not (loadi8 addr:$dst)), addr:$dst)]>;
Dan Gohmanb1576f52007-07-31 20:11:57 +00001491 def NOT16m : I<0xF7, MRM2m, (outs), (ins i16mem:$dst), "not{w}\t$dst",
Evan Cheng605c4152005-12-13 01:57:51 +00001492 [(store (not (loadi16 addr:$dst)), addr:$dst)]>, OpSize;
Dan Gohmanb1576f52007-07-31 20:11:57 +00001493 def NOT32m : I<0xF7, MRM2m, (outs), (ins i32mem:$dst), "not{l}\t$dst",
Evan Cheng605c4152005-12-13 01:57:51 +00001494 [(store (not (loadi32 addr:$dst)), addr:$dst)]>;
Chris Lattner57a02302004-08-11 04:31:00 +00001495}
Evan Cheng1693e482006-07-19 00:27:29 +00001496} // CodeSize
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00001497
Evan Chengb51a0592005-12-10 00:48:20 +00001498// TODO: inc/dec is slow for P4, but fast for Pentium-M.
Evan Cheng24f2ea32007-09-14 21:48:26 +00001499let Defs = [EFLAGS] in {
Evan Cheng1693e482006-07-19 00:27:29 +00001500let CodeSize = 2 in
Dan Gohmanb1576f52007-07-31 20:11:57 +00001501def INC8r : I<0xFE, MRM0r, (outs GR8 :$dst), (ins GR8 :$src), "inc{b}\t$dst",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001502 [(set GR8:$dst, (add GR8:$src, 1)),
1503 (implicit EFLAGS)]>;
Evan Cheng1693e482006-07-19 00:27:29 +00001504let isConvertibleToThreeAddress = 1, CodeSize = 1 in { // Can xform into LEA.
Dan Gohmanb1576f52007-07-31 20:11:57 +00001505def INC16r : I<0x40, AddRegFrm, (outs GR16:$dst), (ins GR16:$src), "inc{w}\t$dst",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001506 [(set GR16:$dst, (add GR16:$src, 1)),
1507 (implicit EFLAGS)]>,
Evan Cheng25ab6902006-09-08 06:48:29 +00001508 OpSize, Requires<[In32BitMode]>;
Dan Gohmanb1576f52007-07-31 20:11:57 +00001509def INC32r : I<0x40, AddRegFrm, (outs GR32:$dst), (ins GR32:$src), "inc{l}\t$dst",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001510 [(set GR32:$dst, (add GR32:$src, 1)),
1511 (implicit EFLAGS)]>, Requires<[In32BitMode]>;
Chris Lattnercc65bee2005-01-02 02:35:46 +00001512}
Evan Cheng1693e482006-07-19 00:27:29 +00001513let isTwoAddress = 0, CodeSize = 2 in {
Dan Gohmanb1576f52007-07-31 20:11:57 +00001514 def INC8m : I<0xFE, MRM0m, (outs), (ins i8mem :$dst), "inc{b}\t$dst",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001515 [(store (add (loadi8 addr:$dst), 1), addr:$dst),
1516 (implicit EFLAGS)]>;
Dan Gohmanb1576f52007-07-31 20:11:57 +00001517 def INC16m : I<0xFF, MRM0m, (outs), (ins i16mem:$dst), "inc{w}\t$dst",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001518 [(store (add (loadi16 addr:$dst), 1), addr:$dst),
1519 (implicit EFLAGS)]>,
Evan Cheng66f71632007-10-19 21:23:22 +00001520 OpSize, Requires<[In32BitMode]>;
Dan Gohmanb1576f52007-07-31 20:11:57 +00001521 def INC32m : I<0xFF, MRM0m, (outs), (ins i32mem:$dst), "inc{l}\t$dst",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001522 [(store (add (loadi32 addr:$dst), 1), addr:$dst),
1523 (implicit EFLAGS)]>,
Evan Cheng66f71632007-10-19 21:23:22 +00001524 Requires<[In32BitMode]>;
Chris Lattner57a02302004-08-11 04:31:00 +00001525}
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00001526
Evan Cheng1693e482006-07-19 00:27:29 +00001527let CodeSize = 2 in
Dan Gohmanb1576f52007-07-31 20:11:57 +00001528def DEC8r : I<0xFE, MRM1r, (outs GR8 :$dst), (ins GR8 :$src), "dec{b}\t$dst",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001529 [(set GR8:$dst, (add GR8:$src, -1)),
1530 (implicit EFLAGS)]>;
Evan Cheng1693e482006-07-19 00:27:29 +00001531let isConvertibleToThreeAddress = 1, CodeSize = 1 in { // Can xform into LEA.
Dan Gohmanb1576f52007-07-31 20:11:57 +00001532def DEC16r : I<0x48, AddRegFrm, (outs GR16:$dst), (ins GR16:$src), "dec{w}\t$dst",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001533 [(set GR16:$dst, (add GR16:$src, -1)),
1534 (implicit EFLAGS)]>,
Evan Cheng25ab6902006-09-08 06:48:29 +00001535 OpSize, Requires<[In32BitMode]>;
Dan Gohmanb1576f52007-07-31 20:11:57 +00001536def DEC32r : I<0x48, AddRegFrm, (outs GR32:$dst), (ins GR32:$src), "dec{l}\t$dst",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001537 [(set GR32:$dst, (add GR32:$src, -1)),
1538 (implicit EFLAGS)]>, Requires<[In32BitMode]>;
Chris Lattnercc65bee2005-01-02 02:35:46 +00001539}
Chris Lattner57a02302004-08-11 04:31:00 +00001540
Evan Cheng1693e482006-07-19 00:27:29 +00001541let isTwoAddress = 0, CodeSize = 2 in {
Dan Gohmanb1576f52007-07-31 20:11:57 +00001542 def DEC8m : I<0xFE, MRM1m, (outs), (ins i8mem :$dst), "dec{b}\t$dst",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001543 [(store (add (loadi8 addr:$dst), -1), addr:$dst),
1544 (implicit EFLAGS)]>;
Dan Gohmanb1576f52007-07-31 20:11:57 +00001545 def DEC16m : I<0xFF, MRM1m, (outs), (ins i16mem:$dst), "dec{w}\t$dst",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001546 [(store (add (loadi16 addr:$dst), -1), addr:$dst),
1547 (implicit EFLAGS)]>,
Evan Cheng66f71632007-10-19 21:23:22 +00001548 OpSize, Requires<[In32BitMode]>;
Dan Gohmanb1576f52007-07-31 20:11:57 +00001549 def DEC32m : I<0xFF, MRM1m, (outs), (ins i32mem:$dst), "dec{l}\t$dst",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001550 [(store (add (loadi32 addr:$dst), -1), addr:$dst),
1551 (implicit EFLAGS)]>,
Evan Cheng66f71632007-10-19 21:23:22 +00001552 Requires<[In32BitMode]>;
Chris Lattner57a02302004-08-11 04:31:00 +00001553}
Evan Cheng24f2ea32007-09-14 21:48:26 +00001554} // Defs = [EFLAGS]
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00001555
1556// Logical operators...
Evan Cheng24f2ea32007-09-14 21:48:26 +00001557let Defs = [EFLAGS] in {
Chris Lattnercc65bee2005-01-02 02:35:46 +00001558let isCommutable = 1 in { // X = AND Y, Z --> X = AND Z, Y
Chris Lattner3a173df2004-10-03 20:35:00 +00001559def AND8rr : I<0x20, MRMDestReg,
Evan Cheng64d80e32007-07-19 01:14:50 +00001560 (outs GR8 :$dst), (ins GR8 :$src1, GR8 :$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001561 "and{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001562 [(set GR8:$dst, (and GR8:$src1, GR8:$src2)),
1563 (implicit EFLAGS)]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00001564def AND16rr : I<0x21, MRMDestReg,
Evan Cheng64d80e32007-07-19 01:14:50 +00001565 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001566 "and{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001567 [(set GR16:$dst, (and GR16:$src1, GR16:$src2)),
1568 (implicit EFLAGS)]>, OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00001569def AND32rr : I<0x21, MRMDestReg,
Evan Cheng64d80e32007-07-19 01:14:50 +00001570 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001571 "and{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001572 [(set GR32:$dst, (and GR32:$src1, GR32:$src2)),
1573 (implicit EFLAGS)]>;
Chris Lattnercc65bee2005-01-02 02:35:46 +00001574}
Chris Lattner57a02302004-08-11 04:31:00 +00001575
Chris Lattner3a173df2004-10-03 20:35:00 +00001576def AND8rm : I<0x22, MRMSrcMem,
Evan Cheng64d80e32007-07-19 01:14:50 +00001577 (outs GR8 :$dst), (ins GR8 :$src1, i8mem :$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001578 "and{b}\t{$src2, $dst|$dst, $src2}",
Chris Lattnerc2406f22009-04-10 00:16:23 +00001579 [(set GR8:$dst, (and GR8:$src1, (loadi8 addr:$src2))),
Dan Gohman09a2609e2009-03-03 19:53:46 +00001580 (implicit EFLAGS)]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00001581def AND16rm : I<0x23, MRMSrcMem,
Evan Cheng64d80e32007-07-19 01:14:50 +00001582 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001583 "and{w}\t{$src2, $dst|$dst, $src2}",
Chris Lattnerc2406f22009-04-10 00:16:23 +00001584 [(set GR16:$dst, (and GR16:$src1, (loadi16 addr:$src2))),
Dan Gohman09a2609e2009-03-03 19:53:46 +00001585 (implicit EFLAGS)]>, OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00001586def AND32rm : I<0x23, MRMSrcMem,
Evan Cheng64d80e32007-07-19 01:14:50 +00001587 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001588 "and{l}\t{$src2, $dst|$dst, $src2}",
Chris Lattnerc2406f22009-04-10 00:16:23 +00001589 [(set GR32:$dst, (and GR32:$src1, (loadi32 addr:$src2))),
Dan Gohman09a2609e2009-03-03 19:53:46 +00001590 (implicit EFLAGS)]>;
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00001591
Chris Lattner3a173df2004-10-03 20:35:00 +00001592def AND8ri : Ii8<0x80, MRM4r,
Evan Cheng64d80e32007-07-19 01:14:50 +00001593 (outs GR8 :$dst), (ins GR8 :$src1, i8imm :$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001594 "and{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001595 [(set GR8:$dst, (and GR8:$src1, imm:$src2)),
1596 (implicit EFLAGS)]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00001597def AND16ri : Ii16<0x81, MRM4r,
Evan Cheng64d80e32007-07-19 01:14:50 +00001598 (outs GR16:$dst), (ins GR16:$src1, i16imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001599 "and{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001600 [(set GR16:$dst, (and GR16:$src1, imm:$src2)),
1601 (implicit EFLAGS)]>, OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00001602def AND32ri : Ii32<0x81, MRM4r,
Evan Cheng64d80e32007-07-19 01:14:50 +00001603 (outs GR32:$dst), (ins GR32:$src1, i32imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001604 "and{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001605 [(set GR32:$dst, (and GR32:$src1, imm:$src2)),
1606 (implicit EFLAGS)]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00001607def AND16ri8 : Ii8<0x83, MRM4r,
Evan Cheng64d80e32007-07-19 01:14:50 +00001608 (outs GR16:$dst), (ins GR16:$src1, i16i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001609 "and{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001610 [(set GR16:$dst, (and GR16:$src1, i16immSExt8:$src2)),
1611 (implicit EFLAGS)]>,
Evan Cheng9b6b6422005-12-13 00:14:11 +00001612 OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00001613def AND32ri8 : Ii8<0x83, MRM4r,
Evan Cheng64d80e32007-07-19 01:14:50 +00001614 (outs GR32:$dst), (ins GR32:$src1, i32i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001615 "and{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001616 [(set GR32:$dst, (and GR32:$src1, i32immSExt8:$src2)),
1617 (implicit EFLAGS)]>;
Chris Lattnerf29ed092004-08-11 05:07:25 +00001618
1619let isTwoAddress = 0 in {
Chris Lattner3a173df2004-10-03 20:35:00 +00001620 def AND8mr : I<0x20, MRMDestMem,
Evan Cheng64d80e32007-07-19 01:14:50 +00001621 (outs), (ins i8mem :$dst, GR8 :$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001622 "and{b}\t{$src, $dst|$dst, $src}",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001623 [(store (and (load addr:$dst), GR8:$src), addr:$dst),
1624 (implicit EFLAGS)]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00001625 def AND16mr : I<0x21, MRMDestMem,
Evan Cheng64d80e32007-07-19 01:14:50 +00001626 (outs), (ins i16mem:$dst, GR16:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001627 "and{w}\t{$src, $dst|$dst, $src}",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001628 [(store (and (load addr:$dst), GR16:$src), addr:$dst),
1629 (implicit EFLAGS)]>,
Evan Cheng0ef3a772005-12-13 01:41:36 +00001630 OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00001631 def AND32mr : I<0x21, MRMDestMem,
Evan Cheng64d80e32007-07-19 01:14:50 +00001632 (outs), (ins i32mem:$dst, GR32:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001633 "and{l}\t{$src, $dst|$dst, $src}",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001634 [(store (and (load addr:$dst), GR32:$src), addr:$dst),
1635 (implicit EFLAGS)]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00001636 def AND8mi : Ii8<0x80, MRM4m,
Evan Cheng64d80e32007-07-19 01:14:50 +00001637 (outs), (ins i8mem :$dst, i8imm :$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001638 "and{b}\t{$src, $dst|$dst, $src}",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001639 [(store (and (loadi8 addr:$dst), imm:$src), addr:$dst),
1640 (implicit EFLAGS)]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00001641 def AND16mi : Ii16<0x81, MRM4m,
Evan Cheng64d80e32007-07-19 01:14:50 +00001642 (outs), (ins i16mem:$dst, i16imm:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001643 "and{w}\t{$src, $dst|$dst, $src}",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001644 [(store (and (loadi16 addr:$dst), imm:$src), addr:$dst),
1645 (implicit EFLAGS)]>,
Evan Cheng0ef3a772005-12-13 01:41:36 +00001646 OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00001647 def AND32mi : Ii32<0x81, MRM4m,
Evan Cheng64d80e32007-07-19 01:14:50 +00001648 (outs), (ins i32mem:$dst, i32imm:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001649 "and{l}\t{$src, $dst|$dst, $src}",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001650 [(store (and (loadi32 addr:$dst), imm:$src), addr:$dst),
1651 (implicit EFLAGS)]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00001652 def AND16mi8 : Ii8<0x83, MRM4m,
Evan Cheng64d80e32007-07-19 01:14:50 +00001653 (outs), (ins i16mem:$dst, i16i8imm :$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001654 "and{w}\t{$src, $dst|$dst, $src}",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001655 [(store (and (load addr:$dst), i16immSExt8:$src), addr:$dst),
1656 (implicit EFLAGS)]>,
Evan Cheng0ef3a772005-12-13 01:41:36 +00001657 OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00001658 def AND32mi8 : Ii8<0x83, MRM4m,
Evan Cheng64d80e32007-07-19 01:14:50 +00001659 (outs), (ins i32mem:$dst, i32i8imm :$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001660 "and{l}\t{$src, $dst|$dst, $src}",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001661 [(store (and (load addr:$dst), i32immSExt8:$src), addr:$dst),
1662 (implicit EFLAGS)]>;
Sean Callanana09caa52009-09-02 00:55:49 +00001663
1664 def AND8i8 : Ii8<0x24, RawFrm, (outs), (ins i8imm:$src),
1665 "and{b}\t{$src, %al|%al, $src}", []>;
1666 def AND16i16 : Ii16<0x25, RawFrm, (outs), (ins i16imm:$src),
1667 "and{w}\t{$src, %ax|%ax, $src}", []>, OpSize;
1668 def AND32i32 : Ii32<0x25, RawFrm, (outs), (ins i32imm:$src),
1669 "and{l}\t{$src, %eax|%eax, $src}", []>;
1670
Chris Lattnerf29ed092004-08-11 05:07:25 +00001671}
1672
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00001673
Chris Lattnercc65bee2005-01-02 02:35:46 +00001674let isCommutable = 1 in { // X = OR Y, Z --> X = OR Z, Y
Evan Cheng64d80e32007-07-19 01:14:50 +00001675def OR8rr : I<0x08, MRMDestReg, (outs GR8 :$dst), (ins GR8 :$src1, GR8 :$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001676 "or{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001677 [(set GR8:$dst, (or GR8:$src1, GR8:$src2)),
1678 (implicit EFLAGS)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00001679def OR16rr : I<0x09, MRMDestReg, (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001680 "or{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001681 [(set GR16:$dst, (or GR16:$src1, GR16:$src2)),
1682 (implicit EFLAGS)]>, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00001683def OR32rr : I<0x09, MRMDestReg, (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001684 "or{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001685 [(set GR32:$dst, (or GR32:$src1, GR32:$src2)),
1686 (implicit EFLAGS)]>;
Chris Lattnercc65bee2005-01-02 02:35:46 +00001687}
Evan Cheng64d80e32007-07-19 01:14:50 +00001688def OR8rm : I<0x0A, MRMSrcMem , (outs GR8 :$dst), (ins GR8 :$src1, i8mem :$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001689 "or{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001690 [(set GR8:$dst, (or GR8:$src1, (load addr:$src2))),
1691 (implicit EFLAGS)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00001692def OR16rm : I<0x0B, MRMSrcMem , (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001693 "or{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001694 [(set GR16:$dst, (or GR16:$src1, (load addr:$src2))),
1695 (implicit EFLAGS)]>, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00001696def OR32rm : I<0x0B, MRMSrcMem , (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001697 "or{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001698 [(set GR32:$dst, (or GR32:$src1, (load addr:$src2))),
1699 (implicit EFLAGS)]>;
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00001700
Evan Cheng64d80e32007-07-19 01:14:50 +00001701def OR8ri : Ii8 <0x80, MRM1r, (outs GR8 :$dst), (ins GR8 :$src1, i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001702 "or{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001703 [(set GR8:$dst, (or GR8:$src1, imm:$src2)),
1704 (implicit EFLAGS)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00001705def OR16ri : Ii16<0x81, MRM1r, (outs GR16:$dst), (ins GR16:$src1, i16imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001706 "or{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001707 [(set GR16:$dst, (or GR16:$src1, imm:$src2)),
1708 (implicit EFLAGS)]>, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00001709def OR32ri : Ii32<0x81, MRM1r, (outs GR32:$dst), (ins GR32:$src1, i32imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001710 "or{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001711 [(set GR32:$dst, (or GR32:$src1, imm:$src2)),
1712 (implicit EFLAGS)]>;
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00001713
Evan Cheng64d80e32007-07-19 01:14:50 +00001714def OR16ri8 : Ii8<0x83, MRM1r, (outs GR16:$dst), (ins GR16:$src1, i16i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001715 "or{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001716 [(set GR16:$dst, (or GR16:$src1, i16immSExt8:$src2)),
1717 (implicit EFLAGS)]>, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00001718def OR32ri8 : Ii8<0x83, MRM1r, (outs GR32:$dst), (ins GR32:$src1, i32i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001719 "or{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001720 [(set GR32:$dst, (or GR32:$src1, i32immSExt8:$src2)),
1721 (implicit EFLAGS)]>;
Chris Lattner57a02302004-08-11 04:31:00 +00001722let isTwoAddress = 0 in {
Evan Cheng64d80e32007-07-19 01:14:50 +00001723 def OR8mr : I<0x08, MRMDestMem, (outs), (ins i8mem:$dst, GR8:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001724 "or{b}\t{$src, $dst|$dst, $src}",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001725 [(store (or (load addr:$dst), GR8:$src), addr:$dst),
1726 (implicit EFLAGS)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00001727 def OR16mr : I<0x09, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001728 "or{w}\t{$src, $dst|$dst, $src}",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001729 [(store (or (load addr:$dst), GR16:$src), addr:$dst),
1730 (implicit EFLAGS)]>, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00001731 def OR32mr : I<0x09, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001732 "or{l}\t{$src, $dst|$dst, $src}",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001733 [(store (or (load addr:$dst), GR32:$src), addr:$dst),
1734 (implicit EFLAGS)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00001735 def OR8mi : Ii8<0x80, MRM1m, (outs), (ins i8mem :$dst, i8imm:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001736 "or{b}\t{$src, $dst|$dst, $src}",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001737 [(store (or (loadi8 addr:$dst), imm:$src), addr:$dst),
1738 (implicit EFLAGS)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00001739 def OR16mi : Ii16<0x81, MRM1m, (outs), (ins i16mem:$dst, i16imm:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001740 "or{w}\t{$src, $dst|$dst, $src}",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001741 [(store (or (loadi16 addr:$dst), imm:$src), addr:$dst),
1742 (implicit EFLAGS)]>,
Evan Cheng0ef3a772005-12-13 01:41:36 +00001743 OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00001744 def OR32mi : Ii32<0x81, MRM1m, (outs), (ins i32mem:$dst, i32imm:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001745 "or{l}\t{$src, $dst|$dst, $src}",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001746 [(store (or (loadi32 addr:$dst), imm:$src), addr:$dst),
1747 (implicit EFLAGS)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00001748 def OR16mi8 : Ii8<0x83, MRM1m, (outs), (ins i16mem:$dst, i16i8imm:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001749 "or{w}\t{$src, $dst|$dst, $src}",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001750 [(store (or (load addr:$dst), i16immSExt8:$src), addr:$dst),
1751 (implicit EFLAGS)]>,
Evan Cheng0ef3a772005-12-13 01:41:36 +00001752 OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00001753 def OR32mi8 : Ii8<0x83, MRM1m, (outs), (ins i32mem:$dst, i32i8imm:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001754 "or{l}\t{$src, $dst|$dst, $src}",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001755 [(store (or (load addr:$dst), i32immSExt8:$src), addr:$dst),
1756 (implicit EFLAGS)]>;
Bill Wendlingbd0879d2008-05-29 01:02:09 +00001757} // isTwoAddress = 0
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00001758
1759
Evan Cheng359e9372008-06-18 08:13:07 +00001760let isCommutable = 1 in { // X = XOR Y, Z --> X = XOR Z, Y
Bill Wendlingbd0879d2008-05-29 01:02:09 +00001761 def XOR8rr : I<0x30, MRMDestReg,
1762 (outs GR8 :$dst), (ins GR8 :$src1, GR8 :$src2),
1763 "xor{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001764 [(set GR8:$dst, (xor GR8:$src1, GR8:$src2)),
1765 (implicit EFLAGS)]>;
Bill Wendlingbd0879d2008-05-29 01:02:09 +00001766 def XOR16rr : I<0x31, MRMDestReg,
1767 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
1768 "xor{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001769 [(set GR16:$dst, (xor GR16:$src1, GR16:$src2)),
1770 (implicit EFLAGS)]>, OpSize;
Bill Wendlingbd0879d2008-05-29 01:02:09 +00001771 def XOR32rr : I<0x31, MRMDestReg,
1772 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
1773 "xor{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001774 [(set GR32:$dst, (xor GR32:$src1, GR32:$src2)),
1775 (implicit EFLAGS)]>;
Evan Cheng359e9372008-06-18 08:13:07 +00001776} // isCommutable = 1
Chris Lattnercc65bee2005-01-02 02:35:46 +00001777
Chris Lattner3a173df2004-10-03 20:35:00 +00001778def XOR8rm : I<0x32, MRMSrcMem ,
Evan Cheng64d80e32007-07-19 01:14:50 +00001779 (outs GR8 :$dst), (ins GR8:$src1, i8mem :$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001780 "xor{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001781 [(set GR8:$dst, (xor GR8:$src1, (load addr:$src2))),
1782 (implicit EFLAGS)]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00001783def XOR16rm : I<0x33, MRMSrcMem ,
Evan Cheng64d80e32007-07-19 01:14:50 +00001784 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001785 "xor{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001786 [(set GR16:$dst, (xor GR16:$src1, (load addr:$src2))),
1787 (implicit EFLAGS)]>,
Bill Wendlingbd0879d2008-05-29 01:02:09 +00001788 OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00001789def XOR32rm : I<0x33, MRMSrcMem ,
Evan Cheng64d80e32007-07-19 01:14:50 +00001790 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001791 "xor{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001792 [(set GR32:$dst, (xor GR32:$src1, (load addr:$src2))),
1793 (implicit EFLAGS)]>;
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00001794
Bill Wendling75cf88f2008-05-29 03:46:36 +00001795def XOR8ri : Ii8<0x80, MRM6r,
1796 (outs GR8:$dst), (ins GR8:$src1, i8imm:$src2),
1797 "xor{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001798 [(set GR8:$dst, (xor GR8:$src1, imm:$src2)),
1799 (implicit EFLAGS)]>;
Bill Wendling75cf88f2008-05-29 03:46:36 +00001800def XOR16ri : Ii16<0x81, MRM6r,
1801 (outs GR16:$dst), (ins GR16:$src1, i16imm:$src2),
1802 "xor{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001803 [(set GR16:$dst, (xor GR16:$src1, imm:$src2)),
1804 (implicit EFLAGS)]>, OpSize;
Bill Wendling75cf88f2008-05-29 03:46:36 +00001805def XOR32ri : Ii32<0x81, MRM6r,
1806 (outs GR32:$dst), (ins GR32:$src1, i32imm:$src2),
1807 "xor{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001808 [(set GR32:$dst, (xor GR32:$src1, imm:$src2)),
1809 (implicit EFLAGS)]>;
Bill Wendling75cf88f2008-05-29 03:46:36 +00001810def XOR16ri8 : Ii8<0x83, MRM6r,
1811 (outs GR16:$dst), (ins GR16:$src1, i16i8imm:$src2),
1812 "xor{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001813 [(set GR16:$dst, (xor GR16:$src1, i16immSExt8:$src2)),
1814 (implicit EFLAGS)]>,
Bill Wendling75cf88f2008-05-29 03:46:36 +00001815 OpSize;
1816def XOR32ri8 : Ii8<0x83, MRM6r,
1817 (outs GR32:$dst), (ins GR32:$src1, i32i8imm:$src2),
1818 "xor{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001819 [(set GR32:$dst, (xor GR32:$src1, i32immSExt8:$src2)),
1820 (implicit EFLAGS)]>;
Bill Wendlingbd0879d2008-05-29 01:02:09 +00001821
Chris Lattner57a02302004-08-11 04:31:00 +00001822let isTwoAddress = 0 in {
Chris Lattner3a173df2004-10-03 20:35:00 +00001823 def XOR8mr : I<0x30, MRMDestMem,
Evan Cheng64d80e32007-07-19 01:14:50 +00001824 (outs), (ins i8mem :$dst, GR8 :$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001825 "xor{b}\t{$src, $dst|$dst, $src}",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001826 [(store (xor (load addr:$dst), GR8:$src), addr:$dst),
1827 (implicit EFLAGS)]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00001828 def XOR16mr : I<0x31, MRMDestMem,
Evan Cheng64d80e32007-07-19 01:14:50 +00001829 (outs), (ins i16mem:$dst, GR16:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001830 "xor{w}\t{$src, $dst|$dst, $src}",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001831 [(store (xor (load addr:$dst), GR16:$src), addr:$dst),
1832 (implicit EFLAGS)]>,
Evan Cheng0ef3a772005-12-13 01:41:36 +00001833 OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00001834 def XOR32mr : I<0x31, MRMDestMem,
Evan Cheng64d80e32007-07-19 01:14:50 +00001835 (outs), (ins i32mem:$dst, GR32:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001836 "xor{l}\t{$src, $dst|$dst, $src}",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001837 [(store (xor (load addr:$dst), GR32:$src), addr:$dst),
1838 (implicit EFLAGS)]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00001839 def XOR8mi : Ii8<0x80, MRM6m,
Evan Cheng64d80e32007-07-19 01:14:50 +00001840 (outs), (ins i8mem :$dst, i8imm :$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001841 "xor{b}\t{$src, $dst|$dst, $src}",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001842 [(store (xor (loadi8 addr:$dst), imm:$src), addr:$dst),
1843 (implicit EFLAGS)]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00001844 def XOR16mi : Ii16<0x81, MRM6m,
Evan Cheng64d80e32007-07-19 01:14:50 +00001845 (outs), (ins i16mem:$dst, i16imm:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001846 "xor{w}\t{$src, $dst|$dst, $src}",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001847 [(store (xor (loadi16 addr:$dst), imm:$src), addr:$dst),
1848 (implicit EFLAGS)]>,
Evan Cheng0ef3a772005-12-13 01:41:36 +00001849 OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00001850 def XOR32mi : Ii32<0x81, MRM6m,
Evan Cheng64d80e32007-07-19 01:14:50 +00001851 (outs), (ins i32mem:$dst, i32imm:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001852 "xor{l}\t{$src, $dst|$dst, $src}",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001853 [(store (xor (loadi32 addr:$dst), imm:$src), addr:$dst),
1854 (implicit EFLAGS)]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00001855 def XOR16mi8 : Ii8<0x83, MRM6m,
Evan Cheng64d80e32007-07-19 01:14:50 +00001856 (outs), (ins i16mem:$dst, i16i8imm :$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001857 "xor{w}\t{$src, $dst|$dst, $src}",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001858 [(store (xor (load addr:$dst), i16immSExt8:$src), addr:$dst),
1859 (implicit EFLAGS)]>,
Evan Cheng0ef3a772005-12-13 01:41:36 +00001860 OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00001861 def XOR32mi8 : Ii8<0x83, MRM6m,
Evan Cheng64d80e32007-07-19 01:14:50 +00001862 (outs), (ins i32mem:$dst, i32i8imm :$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001863 "xor{l}\t{$src, $dst|$dst, $src}",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001864 [(store (xor (load addr:$dst), i32immSExt8:$src), addr:$dst),
1865 (implicit EFLAGS)]>;
Bill Wendlingbd0879d2008-05-29 01:02:09 +00001866} // isTwoAddress = 0
Evan Cheng24f2ea32007-09-14 21:48:26 +00001867} // Defs = [EFLAGS]
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00001868
1869// Shift instructions
Evan Cheng24f2ea32007-09-14 21:48:26 +00001870let Defs = [EFLAGS] in {
Evan Cheng071a2792007-09-11 19:55:27 +00001871let Uses = [CL] in {
Evan Cheng64d80e32007-07-19 01:14:50 +00001872def SHL8rCL : I<0xD2, MRM4r, (outs GR8 :$dst), (ins GR8 :$src),
Eli Friedmanaace4b12009-06-19 04:48:38 +00001873 "shl{b}\t{%cl, $dst|$dst, CL}",
Evan Cheng071a2792007-09-11 19:55:27 +00001874 [(set GR8:$dst, (shl GR8:$src, CL))]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00001875def SHL16rCL : I<0xD3, MRM4r, (outs GR16:$dst), (ins GR16:$src),
Eli Friedmanaace4b12009-06-19 04:48:38 +00001876 "shl{w}\t{%cl, $dst|$dst, CL}",
Evan Cheng071a2792007-09-11 19:55:27 +00001877 [(set GR16:$dst, (shl GR16:$src, CL))]>, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00001878def SHL32rCL : I<0xD3, MRM4r, (outs GR32:$dst), (ins GR32:$src),
Eli Friedmanaace4b12009-06-19 04:48:38 +00001879 "shl{l}\t{%cl, $dst|$dst, CL}",
Evan Cheng071a2792007-09-11 19:55:27 +00001880 [(set GR32:$dst, (shl GR32:$src, CL))]>;
Bill Wendlingbd0879d2008-05-29 01:02:09 +00001881} // Uses = [CL]
Chris Lattnercc65bee2005-01-02 02:35:46 +00001882
Evan Cheng64d80e32007-07-19 01:14:50 +00001883def SHL8ri : Ii8<0xC0, MRM4r, (outs GR8 :$dst), (ins GR8 :$src1, i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001884 "shl{b}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001885 [(set GR8:$dst, (shl GR8:$src1, (i8 imm:$src2)))]>;
Chris Lattnercc65bee2005-01-02 02:35:46 +00001886let isConvertibleToThreeAddress = 1 in { // Can transform into LEA.
Evan Cheng64d80e32007-07-19 01:14:50 +00001887def SHL16ri : Ii8<0xC1, MRM4r, (outs GR16:$dst), (ins GR16:$src1, i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001888 "shl{w}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001889 [(set GR16:$dst, (shl GR16:$src1, (i8 imm:$src2)))]>, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00001890def SHL32ri : Ii8<0xC1, MRM4r, (outs GR32:$dst), (ins GR32:$src1, i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001891 "shl{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001892 [(set GR32:$dst, (shl GR32:$src1, (i8 imm:$src2)))]>;
Chris Lattnerf9b3f372008-01-11 18:00:50 +00001893// NOTE: We don't use shifts of a register by one, because 'add reg,reg' is
1894// cheaper.
Bill Wendlingbd0879d2008-05-29 01:02:09 +00001895} // isConvertibleToThreeAddress = 1
Evan Cheng09c54572006-06-29 00:36:51 +00001896
Chris Lattnerf29ed092004-08-11 05:07:25 +00001897let isTwoAddress = 0 in {
Evan Cheng071a2792007-09-11 19:55:27 +00001898 let Uses = [CL] in {
Evan Cheng64d80e32007-07-19 01:14:50 +00001899 def SHL8mCL : I<0xD2, MRM4m, (outs), (ins i8mem :$dst),
Eli Friedmanaace4b12009-06-19 04:48:38 +00001900 "shl{b}\t{%cl, $dst|$dst, CL}",
Evan Cheng071a2792007-09-11 19:55:27 +00001901 [(store (shl (loadi8 addr:$dst), CL), addr:$dst)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00001902 def SHL16mCL : I<0xD3, MRM4m, (outs), (ins i16mem:$dst),
Eli Friedmanaace4b12009-06-19 04:48:38 +00001903 "shl{w}\t{%cl, $dst|$dst, CL}",
Evan Cheng071a2792007-09-11 19:55:27 +00001904 [(store (shl (loadi16 addr:$dst), CL), addr:$dst)]>, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00001905 def SHL32mCL : I<0xD3, MRM4m, (outs), (ins i32mem:$dst),
Eli Friedmanaace4b12009-06-19 04:48:38 +00001906 "shl{l}\t{%cl, $dst|$dst, CL}",
Evan Cheng071a2792007-09-11 19:55:27 +00001907 [(store (shl (loadi32 addr:$dst), CL), addr:$dst)]>;
1908 }
Evan Cheng64d80e32007-07-19 01:14:50 +00001909 def SHL8mi : Ii8<0xC0, MRM4m, (outs), (ins i8mem :$dst, i8imm:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001910 "shl{b}\t{$src, $dst|$dst, $src}",
Evan Cheng763b0292005-12-13 02:34:51 +00001911 [(store (shl (loadi8 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00001912 def SHL16mi : Ii8<0xC1, MRM4m, (outs), (ins i16mem:$dst, i8imm:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001913 "shl{w}\t{$src, $dst|$dst, $src}",
Evan Cheng763b0292005-12-13 02:34:51 +00001914 [(store (shl (loadi16 addr:$dst), (i8 imm:$src)), addr:$dst)]>,
1915 OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00001916 def SHL32mi : Ii8<0xC1, MRM4m, (outs), (ins i32mem:$dst, i8imm:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001917 "shl{l}\t{$src, $dst|$dst, $src}",
Evan Cheng763b0292005-12-13 02:34:51 +00001918 [(store (shl (loadi32 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
Evan Cheng09c54572006-06-29 00:36:51 +00001919
1920 // Shift by 1
Evan Cheng64d80e32007-07-19 01:14:50 +00001921 def SHL8m1 : I<0xD0, MRM4m, (outs), (ins i8mem :$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001922 "shl{b}\t$dst",
Evan Cheng09c54572006-06-29 00:36:51 +00001923 [(store (shl (loadi8 addr:$dst), (i8 1)), addr:$dst)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00001924 def SHL16m1 : I<0xD1, MRM4m, (outs), (ins i16mem:$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001925 "shl{w}\t$dst",
Evan Cheng09c54572006-06-29 00:36:51 +00001926 [(store (shl (loadi16 addr:$dst), (i8 1)), addr:$dst)]>,
1927 OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00001928 def SHL32m1 : I<0xD1, MRM4m, (outs), (ins i32mem:$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001929 "shl{l}\t$dst",
Evan Cheng09c54572006-06-29 00:36:51 +00001930 [(store (shl (loadi32 addr:$dst), (i8 1)), addr:$dst)]>;
Chris Lattnerf29ed092004-08-11 05:07:25 +00001931}
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00001932
Evan Cheng071a2792007-09-11 19:55:27 +00001933let Uses = [CL] in {
Evan Cheng64d80e32007-07-19 01:14:50 +00001934def SHR8rCL : I<0xD2, MRM5r, (outs GR8 :$dst), (ins GR8 :$src),
Eli Friedmanaace4b12009-06-19 04:48:38 +00001935 "shr{b}\t{%cl, $dst|$dst, CL}",
Evan Cheng071a2792007-09-11 19:55:27 +00001936 [(set GR8:$dst, (srl GR8:$src, CL))]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00001937def SHR16rCL : I<0xD3, MRM5r, (outs GR16:$dst), (ins GR16:$src),
Eli Friedmanaace4b12009-06-19 04:48:38 +00001938 "shr{w}\t{%cl, $dst|$dst, CL}",
Evan Cheng071a2792007-09-11 19:55:27 +00001939 [(set GR16:$dst, (srl GR16:$src, CL))]>, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00001940def SHR32rCL : I<0xD3, MRM5r, (outs GR32:$dst), (ins GR32:$src),
Eli Friedmanaace4b12009-06-19 04:48:38 +00001941 "shr{l}\t{%cl, $dst|$dst, CL}",
Evan Cheng071a2792007-09-11 19:55:27 +00001942 [(set GR32:$dst, (srl GR32:$src, CL))]>;
1943}
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00001944
Evan Cheng64d80e32007-07-19 01:14:50 +00001945def SHR8ri : Ii8<0xC0, MRM5r, (outs GR8:$dst), (ins GR8:$src1, i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001946 "shr{b}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001947 [(set GR8:$dst, (srl GR8:$src1, (i8 imm:$src2)))]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00001948def SHR16ri : Ii8<0xC1, MRM5r, (outs GR16:$dst), (ins GR16:$src1, i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001949 "shr{w}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001950 [(set GR16:$dst, (srl GR16:$src1, (i8 imm:$src2)))]>, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00001951def SHR32ri : Ii8<0xC1, MRM5r, (outs GR32:$dst), (ins GR32:$src1, i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001952 "shr{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001953 [(set GR32:$dst, (srl GR32:$src1, (i8 imm:$src2)))]>;
Chris Lattnerf29ed092004-08-11 05:07:25 +00001954
Evan Cheng09c54572006-06-29 00:36:51 +00001955// Shift by 1
Evan Cheng64d80e32007-07-19 01:14:50 +00001956def SHR8r1 : I<0xD0, MRM5r, (outs GR8:$dst), (ins GR8:$src1),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001957 "shr{b}\t$dst",
Evan Cheng09c54572006-06-29 00:36:51 +00001958 [(set GR8:$dst, (srl GR8:$src1, (i8 1)))]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00001959def SHR16r1 : I<0xD1, MRM5r, (outs GR16:$dst), (ins GR16:$src1),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001960 "shr{w}\t$dst",
Evan Cheng09c54572006-06-29 00:36:51 +00001961 [(set GR16:$dst, (srl GR16:$src1, (i8 1)))]>, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00001962def SHR32r1 : I<0xD1, MRM5r, (outs GR32:$dst), (ins GR32:$src1),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001963 "shr{l}\t$dst",
Evan Cheng09c54572006-06-29 00:36:51 +00001964 [(set GR32:$dst, (srl GR32:$src1, (i8 1)))]>;
1965
Chris Lattner57a02302004-08-11 04:31:00 +00001966let isTwoAddress = 0 in {
Evan Cheng071a2792007-09-11 19:55:27 +00001967 let Uses = [CL] in {
Evan Cheng64d80e32007-07-19 01:14:50 +00001968 def SHR8mCL : I<0xD2, MRM5m, (outs), (ins i8mem :$dst),
Eli Friedmanaace4b12009-06-19 04:48:38 +00001969 "shr{b}\t{%cl, $dst|$dst, CL}",
Evan Cheng071a2792007-09-11 19:55:27 +00001970 [(store (srl (loadi8 addr:$dst), CL), addr:$dst)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00001971 def SHR16mCL : I<0xD3, MRM5m, (outs), (ins i16mem:$dst),
Eli Friedmanaace4b12009-06-19 04:48:38 +00001972 "shr{w}\t{%cl, $dst|$dst, CL}",
Evan Cheng85dd8892005-12-13 07:24:22 +00001973 [(store (srl (loadi16 addr:$dst), CL), addr:$dst)]>,
Evan Cheng071a2792007-09-11 19:55:27 +00001974 OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00001975 def SHR32mCL : I<0xD3, MRM5m, (outs), (ins i32mem:$dst),
Eli Friedmanaace4b12009-06-19 04:48:38 +00001976 "shr{l}\t{%cl, $dst|$dst, CL}",
Evan Cheng071a2792007-09-11 19:55:27 +00001977 [(store (srl (loadi32 addr:$dst), CL), addr:$dst)]>;
1978 }
Evan Cheng64d80e32007-07-19 01:14:50 +00001979 def SHR8mi : Ii8<0xC0, MRM5m, (outs), (ins i8mem :$dst, i8imm:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001980 "shr{b}\t{$src, $dst|$dst, $src}",
Evan Cheng85dd8892005-12-13 07:24:22 +00001981 [(store (srl (loadi8 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00001982 def SHR16mi : Ii8<0xC1, MRM5m, (outs), (ins i16mem:$dst, i8imm:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001983 "shr{w}\t{$src, $dst|$dst, $src}",
Evan Cheng85dd8892005-12-13 07:24:22 +00001984 [(store (srl (loadi16 addr:$dst), (i8 imm:$src)), addr:$dst)]>,
1985 OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00001986 def SHR32mi : Ii8<0xC1, MRM5m, (outs), (ins i32mem:$dst, i8imm:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001987 "shr{l}\t{$src, $dst|$dst, $src}",
Evan Cheng85dd8892005-12-13 07:24:22 +00001988 [(store (srl (loadi32 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
Evan Cheng09c54572006-06-29 00:36:51 +00001989
1990 // Shift by 1
Evan Cheng64d80e32007-07-19 01:14:50 +00001991 def SHR8m1 : I<0xD0, MRM5m, (outs), (ins i8mem :$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001992 "shr{b}\t$dst",
Evan Cheng09c54572006-06-29 00:36:51 +00001993 [(store (srl (loadi8 addr:$dst), (i8 1)), addr:$dst)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00001994 def SHR16m1 : I<0xD1, MRM5m, (outs), (ins i16mem:$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001995 "shr{w}\t$dst",
Evan Cheng09c54572006-06-29 00:36:51 +00001996 [(store (srl (loadi16 addr:$dst), (i8 1)), addr:$dst)]>,OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00001997 def SHR32m1 : I<0xD1, MRM5m, (outs), (ins i32mem:$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001998 "shr{l}\t$dst",
Evan Cheng09c54572006-06-29 00:36:51 +00001999 [(store (srl (loadi32 addr:$dst), (i8 1)), addr:$dst)]>;
Chris Lattner57a02302004-08-11 04:31:00 +00002000}
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00002001
Evan Cheng071a2792007-09-11 19:55:27 +00002002let Uses = [CL] in {
Evan Cheng64d80e32007-07-19 01:14:50 +00002003def SAR8rCL : I<0xD2, MRM7r, (outs GR8 :$dst), (ins GR8 :$src),
Eli Friedmanaace4b12009-06-19 04:48:38 +00002004 "sar{b}\t{%cl, $dst|$dst, CL}",
Evan Cheng071a2792007-09-11 19:55:27 +00002005 [(set GR8:$dst, (sra GR8:$src, CL))]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00002006def SAR16rCL : I<0xD3, MRM7r, (outs GR16:$dst), (ins GR16:$src),
Eli Friedmanaace4b12009-06-19 04:48:38 +00002007 "sar{w}\t{%cl, $dst|$dst, CL}",
Evan Cheng071a2792007-09-11 19:55:27 +00002008 [(set GR16:$dst, (sra GR16:$src, CL))]>, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00002009def SAR32rCL : I<0xD3, MRM7r, (outs GR32:$dst), (ins GR32:$src),
Eli Friedmanaace4b12009-06-19 04:48:38 +00002010 "sar{l}\t{%cl, $dst|$dst, CL}",
Evan Cheng071a2792007-09-11 19:55:27 +00002011 [(set GR32:$dst, (sra GR32:$src, CL))]>;
2012}
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00002013
Evan Cheng64d80e32007-07-19 01:14:50 +00002014def SAR8ri : Ii8<0xC0, MRM7r, (outs GR8 :$dst), (ins GR8 :$src1, i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002015 "sar{b}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00002016 [(set GR8:$dst, (sra GR8:$src1, (i8 imm:$src2)))]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00002017def SAR16ri : Ii8<0xC1, MRM7r, (outs GR16:$dst), (ins GR16:$src1, i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002018 "sar{w}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00002019 [(set GR16:$dst, (sra GR16:$src1, (i8 imm:$src2)))]>,
Chris Lattner3d36a9f2005-12-05 02:40:25 +00002020 OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00002021def SAR32ri : Ii8<0xC1, MRM7r, (outs GR32:$dst), (ins GR32:$src1, i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002022 "sar{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00002023 [(set GR32:$dst, (sra GR32:$src1, (i8 imm:$src2)))]>;
Evan Cheng09c54572006-06-29 00:36:51 +00002024
2025// Shift by 1
Evan Cheng64d80e32007-07-19 01:14:50 +00002026def SAR8r1 : I<0xD0, MRM7r, (outs GR8 :$dst), (ins GR8 :$src1),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002027 "sar{b}\t$dst",
Evan Cheng09c54572006-06-29 00:36:51 +00002028 [(set GR8:$dst, (sra GR8:$src1, (i8 1)))]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00002029def SAR16r1 : I<0xD1, MRM7r, (outs GR16:$dst), (ins GR16:$src1),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002030 "sar{w}\t$dst",
Evan Cheng09c54572006-06-29 00:36:51 +00002031 [(set GR16:$dst, (sra GR16:$src1, (i8 1)))]>, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00002032def SAR32r1 : I<0xD1, MRM7r, (outs GR32:$dst), (ins GR32:$src1),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002033 "sar{l}\t$dst",
Evan Cheng09c54572006-06-29 00:36:51 +00002034 [(set GR32:$dst, (sra GR32:$src1, (i8 1)))]>;
2035
Chris Lattnerf29ed092004-08-11 05:07:25 +00002036let isTwoAddress = 0 in {
Evan Cheng071a2792007-09-11 19:55:27 +00002037 let Uses = [CL] in {
Evan Cheng64d80e32007-07-19 01:14:50 +00002038 def SAR8mCL : I<0xD2, MRM7m, (outs), (ins i8mem :$dst),
Eli Friedmanaace4b12009-06-19 04:48:38 +00002039 "sar{b}\t{%cl, $dst|$dst, CL}",
Evan Cheng071a2792007-09-11 19:55:27 +00002040 [(store (sra (loadi8 addr:$dst), CL), addr:$dst)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00002041 def SAR16mCL : I<0xD3, MRM7m, (outs), (ins i16mem:$dst),
Eli Friedmanaace4b12009-06-19 04:48:38 +00002042 "sar{w}\t{%cl, $dst|$dst, CL}",
Evan Cheng071a2792007-09-11 19:55:27 +00002043 [(store (sra (loadi16 addr:$dst), CL), addr:$dst)]>, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00002044 def SAR32mCL : I<0xD3, MRM7m, (outs), (ins i32mem:$dst),
Eli Friedmanaace4b12009-06-19 04:48:38 +00002045 "sar{l}\t{%cl, $dst|$dst, CL}",
Evan Cheng071a2792007-09-11 19:55:27 +00002046 [(store (sra (loadi32 addr:$dst), CL), addr:$dst)]>;
2047 }
Evan Cheng64d80e32007-07-19 01:14:50 +00002048 def SAR8mi : Ii8<0xC0, MRM7m, (outs), (ins i8mem :$dst, i8imm:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002049 "sar{b}\t{$src, $dst|$dst, $src}",
Evan Cheng85dd8892005-12-13 07:24:22 +00002050 [(store (sra (loadi8 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00002051 def SAR16mi : Ii8<0xC1, MRM7m, (outs), (ins i16mem:$dst, i8imm:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002052 "sar{w}\t{$src, $dst|$dst, $src}",
Evan Cheng85dd8892005-12-13 07:24:22 +00002053 [(store (sra (loadi16 addr:$dst), (i8 imm:$src)), addr:$dst)]>,
2054 OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00002055 def SAR32mi : Ii8<0xC1, MRM7m, (outs), (ins i32mem:$dst, i8imm:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002056 "sar{l}\t{$src, $dst|$dst, $src}",
Evan Cheng85dd8892005-12-13 07:24:22 +00002057 [(store (sra (loadi32 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
Evan Cheng09c54572006-06-29 00:36:51 +00002058
2059 // Shift by 1
Evan Cheng64d80e32007-07-19 01:14:50 +00002060 def SAR8m1 : I<0xD0, MRM7m, (outs), (ins i8mem :$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002061 "sar{b}\t$dst",
Evan Cheng09c54572006-06-29 00:36:51 +00002062 [(store (sra (loadi8 addr:$dst), (i8 1)), addr:$dst)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00002063 def SAR16m1 : I<0xD1, MRM7m, (outs), (ins i16mem:$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002064 "sar{w}\t$dst",
Evan Cheng09c54572006-06-29 00:36:51 +00002065 [(store (sra (loadi16 addr:$dst), (i8 1)), addr:$dst)]>,
2066 OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00002067 def SAR32m1 : I<0xD1, MRM7m, (outs), (ins i32mem:$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002068 "sar{l}\t$dst",
Evan Cheng09c54572006-06-29 00:36:51 +00002069 [(store (sra (loadi32 addr:$dst), (i8 1)), addr:$dst)]>;
Chris Lattnerf29ed092004-08-11 05:07:25 +00002070}
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00002071
Chris Lattner40ff6332005-01-19 07:50:03 +00002072// Rotate instructions
2073// FIXME: provide shorter instructions when imm8 == 1
Evan Cheng071a2792007-09-11 19:55:27 +00002074let Uses = [CL] in {
Evan Cheng64d80e32007-07-19 01:14:50 +00002075def ROL8rCL : I<0xD2, MRM0r, (outs GR8 :$dst), (ins GR8 :$src),
Eli Friedmanaace4b12009-06-19 04:48:38 +00002076 "rol{b}\t{%cl, $dst|$dst, CL}",
Evan Cheng071a2792007-09-11 19:55:27 +00002077 [(set GR8:$dst, (rotl GR8:$src, CL))]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00002078def ROL16rCL : I<0xD3, MRM0r, (outs GR16:$dst), (ins GR16:$src),
Eli Friedmanaace4b12009-06-19 04:48:38 +00002079 "rol{w}\t{%cl, $dst|$dst, CL}",
Evan Cheng071a2792007-09-11 19:55:27 +00002080 [(set GR16:$dst, (rotl GR16:$src, CL))]>, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00002081def ROL32rCL : I<0xD3, MRM0r, (outs GR32:$dst), (ins GR32:$src),
Eli Friedmanaace4b12009-06-19 04:48:38 +00002082 "rol{l}\t{%cl, $dst|$dst, CL}",
Evan Cheng071a2792007-09-11 19:55:27 +00002083 [(set GR32:$dst, (rotl GR32:$src, CL))]>;
2084}
Chris Lattner40ff6332005-01-19 07:50:03 +00002085
Evan Cheng64d80e32007-07-19 01:14:50 +00002086def ROL8ri : Ii8<0xC0, MRM0r, (outs GR8 :$dst), (ins GR8 :$src1, i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002087 "rol{b}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00002088 [(set GR8:$dst, (rotl GR8:$src1, (i8 imm:$src2)))]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00002089def ROL16ri : Ii8<0xC1, MRM0r, (outs GR16:$dst), (ins GR16:$src1, i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002090 "rol{w}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00002091 [(set GR16:$dst, (rotl GR16:$src1, (i8 imm:$src2)))]>, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00002092def ROL32ri : Ii8<0xC1, MRM0r, (outs GR32:$dst), (ins GR32:$src1, i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002093 "rol{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00002094 [(set GR32:$dst, (rotl GR32:$src1, (i8 imm:$src2)))]>;
Chris Lattner40ff6332005-01-19 07:50:03 +00002095
Evan Cheng09c54572006-06-29 00:36:51 +00002096// Rotate by 1
Evan Cheng64d80e32007-07-19 01:14:50 +00002097def ROL8r1 : I<0xD0, MRM0r, (outs GR8 :$dst), (ins GR8 :$src1),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002098 "rol{b}\t$dst",
Evan Cheng09c54572006-06-29 00:36:51 +00002099 [(set GR8:$dst, (rotl GR8:$src1, (i8 1)))]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00002100def ROL16r1 : I<0xD1, MRM0r, (outs GR16:$dst), (ins GR16:$src1),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002101 "rol{w}\t$dst",
Evan Cheng09c54572006-06-29 00:36:51 +00002102 [(set GR16:$dst, (rotl GR16:$src1, (i8 1)))]>, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00002103def ROL32r1 : I<0xD1, MRM0r, (outs GR32:$dst), (ins GR32:$src1),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002104 "rol{l}\t$dst",
Evan Cheng09c54572006-06-29 00:36:51 +00002105 [(set GR32:$dst, (rotl GR32:$src1, (i8 1)))]>;
2106
Chris Lattner40ff6332005-01-19 07:50:03 +00002107let isTwoAddress = 0 in {
Evan Cheng071a2792007-09-11 19:55:27 +00002108 let Uses = [CL] in {
Evan Cheng64d80e32007-07-19 01:14:50 +00002109 def ROL8mCL : I<0xD2, MRM0m, (outs), (ins i8mem :$dst),
Eli Friedmanaace4b12009-06-19 04:48:38 +00002110 "rol{b}\t{%cl, $dst|$dst, CL}",
Evan Cheng071a2792007-09-11 19:55:27 +00002111 [(store (rotl (loadi8 addr:$dst), CL), addr:$dst)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00002112 def ROL16mCL : I<0xD3, MRM0m, (outs), (ins i16mem:$dst),
Eli Friedmanaace4b12009-06-19 04:48:38 +00002113 "rol{w}\t{%cl, $dst|$dst, CL}",
Evan Cheng071a2792007-09-11 19:55:27 +00002114 [(store (rotl (loadi16 addr:$dst), CL), addr:$dst)]>, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00002115 def ROL32mCL : I<0xD3, MRM0m, (outs), (ins i32mem:$dst),
Eli Friedmanaace4b12009-06-19 04:48:38 +00002116 "rol{l}\t{%cl, $dst|$dst, CL}",
Evan Cheng071a2792007-09-11 19:55:27 +00002117 [(store (rotl (loadi32 addr:$dst), CL), addr:$dst)]>;
2118 }
Evan Cheng64d80e32007-07-19 01:14:50 +00002119 def ROL8mi : Ii8<0xC0, MRM0m, (outs), (ins i8mem :$dst, i8imm:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002120 "rol{b}\t{$src, $dst|$dst, $src}",
Evan Chengeb422a72006-01-11 23:20:05 +00002121 [(store (rotl (loadi8 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00002122 def ROL16mi : Ii8<0xC1, MRM0m, (outs), (ins i16mem:$dst, i8imm:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002123 "rol{w}\t{$src, $dst|$dst, $src}",
Evan Chengeb422a72006-01-11 23:20:05 +00002124 [(store (rotl (loadi16 addr:$dst), (i8 imm:$src)), addr:$dst)]>,
2125 OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00002126 def ROL32mi : Ii8<0xC1, MRM0m, (outs), (ins i32mem:$dst, i8imm:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002127 "rol{l}\t{$src, $dst|$dst, $src}",
Evan Chengeb422a72006-01-11 23:20:05 +00002128 [(store (rotl (loadi32 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
Evan Cheng09c54572006-06-29 00:36:51 +00002129
2130 // Rotate by 1
Evan Cheng64d80e32007-07-19 01:14:50 +00002131 def ROL8m1 : I<0xD0, MRM0m, (outs), (ins i8mem :$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002132 "rol{b}\t$dst",
Evan Cheng09c54572006-06-29 00:36:51 +00002133 [(store (rotl (loadi8 addr:$dst), (i8 1)), addr:$dst)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00002134 def ROL16m1 : I<0xD1, MRM0m, (outs), (ins i16mem:$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002135 "rol{w}\t$dst",
Evan Cheng09c54572006-06-29 00:36:51 +00002136 [(store (rotl (loadi16 addr:$dst), (i8 1)), addr:$dst)]>,
2137 OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00002138 def ROL32m1 : I<0xD1, MRM0m, (outs), (ins i32mem:$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002139 "rol{l}\t$dst",
Evan Cheng09c54572006-06-29 00:36:51 +00002140 [(store (rotl (loadi32 addr:$dst), (i8 1)), addr:$dst)]>;
Chris Lattner40ff6332005-01-19 07:50:03 +00002141}
2142
Evan Cheng071a2792007-09-11 19:55:27 +00002143let Uses = [CL] in {
Evan Cheng64d80e32007-07-19 01:14:50 +00002144def ROR8rCL : I<0xD2, MRM1r, (outs GR8 :$dst), (ins GR8 :$src),
Eli Friedmanaace4b12009-06-19 04:48:38 +00002145 "ror{b}\t{%cl, $dst|$dst, CL}",
Evan Cheng071a2792007-09-11 19:55:27 +00002146 [(set GR8:$dst, (rotr GR8:$src, CL))]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00002147def ROR16rCL : I<0xD3, MRM1r, (outs GR16:$dst), (ins GR16:$src),
Eli Friedmanaace4b12009-06-19 04:48:38 +00002148 "ror{w}\t{%cl, $dst|$dst, CL}",
Evan Cheng071a2792007-09-11 19:55:27 +00002149 [(set GR16:$dst, (rotr GR16:$src, CL))]>, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00002150def ROR32rCL : I<0xD3, MRM1r, (outs GR32:$dst), (ins GR32:$src),
Eli Friedmanaace4b12009-06-19 04:48:38 +00002151 "ror{l}\t{%cl, $dst|$dst, CL}",
Evan Cheng071a2792007-09-11 19:55:27 +00002152 [(set GR32:$dst, (rotr GR32:$src, CL))]>;
2153}
Chris Lattner40ff6332005-01-19 07:50:03 +00002154
Evan Cheng64d80e32007-07-19 01:14:50 +00002155def ROR8ri : Ii8<0xC0, MRM1r, (outs GR8 :$dst), (ins GR8 :$src1, i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002156 "ror{b}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00002157 [(set GR8:$dst, (rotr GR8:$src1, (i8 imm:$src2)))]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00002158def ROR16ri : Ii8<0xC1, MRM1r, (outs GR16:$dst), (ins GR16:$src1, i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002159 "ror{w}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00002160 [(set GR16:$dst, (rotr GR16:$src1, (i8 imm:$src2)))]>, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00002161def ROR32ri : Ii8<0xC1, MRM1r, (outs GR32:$dst), (ins GR32:$src1, i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002162 "ror{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00002163 [(set GR32:$dst, (rotr GR32:$src1, (i8 imm:$src2)))]>;
Evan Cheng09c54572006-06-29 00:36:51 +00002164
2165// Rotate by 1
Evan Cheng64d80e32007-07-19 01:14:50 +00002166def ROR8r1 : I<0xD0, MRM1r, (outs GR8 :$dst), (ins GR8 :$src1),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002167 "ror{b}\t$dst",
Evan Cheng09c54572006-06-29 00:36:51 +00002168 [(set GR8:$dst, (rotr GR8:$src1, (i8 1)))]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00002169def ROR16r1 : I<0xD1, MRM1r, (outs GR16:$dst), (ins GR16:$src1),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002170 "ror{w}\t$dst",
Evan Cheng09c54572006-06-29 00:36:51 +00002171 [(set GR16:$dst, (rotr GR16:$src1, (i8 1)))]>, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00002172def ROR32r1 : I<0xD1, MRM1r, (outs GR32:$dst), (ins GR32:$src1),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002173 "ror{l}\t$dst",
Evan Cheng09c54572006-06-29 00:36:51 +00002174 [(set GR32:$dst, (rotr GR32:$src1, (i8 1)))]>;
2175
Chris Lattner40ff6332005-01-19 07:50:03 +00002176let isTwoAddress = 0 in {
Evan Cheng071a2792007-09-11 19:55:27 +00002177 let Uses = [CL] in {
Evan Cheng64d80e32007-07-19 01:14:50 +00002178 def ROR8mCL : I<0xD2, MRM1m, (outs), (ins i8mem :$dst),
Eli Friedmanaace4b12009-06-19 04:48:38 +00002179 "ror{b}\t{%cl, $dst|$dst, CL}",
Evan Cheng071a2792007-09-11 19:55:27 +00002180 [(store (rotr (loadi8 addr:$dst), CL), addr:$dst)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00002181 def ROR16mCL : I<0xD3, MRM1m, (outs), (ins i16mem:$dst),
Eli Friedmanaace4b12009-06-19 04:48:38 +00002182 "ror{w}\t{%cl, $dst|$dst, CL}",
Evan Cheng071a2792007-09-11 19:55:27 +00002183 [(store (rotr (loadi16 addr:$dst), CL), addr:$dst)]>, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00002184 def ROR32mCL : I<0xD3, MRM1m, (outs), (ins i32mem:$dst),
Eli Friedmanaace4b12009-06-19 04:48:38 +00002185 "ror{l}\t{%cl, $dst|$dst, CL}",
Evan Cheng071a2792007-09-11 19:55:27 +00002186 [(store (rotr (loadi32 addr:$dst), CL), addr:$dst)]>;
2187 }
Evan Cheng64d80e32007-07-19 01:14:50 +00002188 def ROR8mi : Ii8<0xC0, MRM1m, (outs), (ins i8mem :$dst, i8imm:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002189 "ror{b}\t{$src, $dst|$dst, $src}",
Evan Chengeb422a72006-01-11 23:20:05 +00002190 [(store (rotr (loadi8 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00002191 def ROR16mi : Ii8<0xC1, MRM1m, (outs), (ins i16mem:$dst, i8imm:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002192 "ror{w}\t{$src, $dst|$dst, $src}",
Evan Chengeb422a72006-01-11 23:20:05 +00002193 [(store (rotr (loadi16 addr:$dst), (i8 imm:$src)), addr:$dst)]>,
2194 OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00002195 def ROR32mi : Ii8<0xC1, MRM1m, (outs), (ins i32mem:$dst, i8imm:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002196 "ror{l}\t{$src, $dst|$dst, $src}",
Evan Chengeb422a72006-01-11 23:20:05 +00002197 [(store (rotr (loadi32 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
Evan Cheng09c54572006-06-29 00:36:51 +00002198
2199 // Rotate by 1
Evan Cheng64d80e32007-07-19 01:14:50 +00002200 def ROR8m1 : I<0xD0, MRM1m, (outs), (ins i8mem :$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002201 "ror{b}\t$dst",
Evan Cheng09c54572006-06-29 00:36:51 +00002202 [(store (rotr (loadi8 addr:$dst), (i8 1)), addr:$dst)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00002203 def ROR16m1 : I<0xD1, MRM1m, (outs), (ins i16mem:$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002204 "ror{w}\t$dst",
Evan Cheng09c54572006-06-29 00:36:51 +00002205 [(store (rotr (loadi16 addr:$dst), (i8 1)), addr:$dst)]>,
2206 OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00002207 def ROR32m1 : I<0xD1, MRM1m, (outs), (ins i32mem:$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002208 "ror{l}\t$dst",
Evan Cheng09c54572006-06-29 00:36:51 +00002209 [(store (rotr (loadi32 addr:$dst), (i8 1)), addr:$dst)]>;
Chris Lattner40ff6332005-01-19 07:50:03 +00002210}
2211
2212
2213
2214// Double shift instructions (generalizations of rotate)
Evan Cheng071a2792007-09-11 19:55:27 +00002215let Uses = [CL] in {
Evan Cheng64d80e32007-07-19 01:14:50 +00002216def SHLD32rrCL : I<0xA5, MRMDestReg, (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Eli Friedmanaace4b12009-06-19 04:48:38 +00002217 "shld{l}\t{%cl, $src2, $dst|$dst, $src2, CL}",
Evan Cheng071a2792007-09-11 19:55:27 +00002218 [(set GR32:$dst, (X86shld GR32:$src1, GR32:$src2, CL))]>, TB;
Evan Cheng64d80e32007-07-19 01:14:50 +00002219def SHRD32rrCL : I<0xAD, MRMDestReg, (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Eli Friedmanaace4b12009-06-19 04:48:38 +00002220 "shrd{l}\t{%cl, $src2, $dst|$dst, $src2, CL}",
Evan Cheng071a2792007-09-11 19:55:27 +00002221 [(set GR32:$dst, (X86shrd GR32:$src1, GR32:$src2, CL))]>, TB;
Evan Cheng64d80e32007-07-19 01:14:50 +00002222def SHLD16rrCL : I<0xA5, MRMDestReg, (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Eli Friedmanaace4b12009-06-19 04:48:38 +00002223 "shld{w}\t{%cl, $src2, $dst|$dst, $src2, CL}",
Evan Cheng069287d2006-05-16 07:21:53 +00002224 [(set GR16:$dst, (X86shld GR16:$src1, GR16:$src2, CL))]>,
Evan Cheng071a2792007-09-11 19:55:27 +00002225 TB, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00002226def SHRD16rrCL : I<0xAD, MRMDestReg, (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Eli Friedmanaace4b12009-06-19 04:48:38 +00002227 "shrd{w}\t{%cl, $src2, $dst|$dst, $src2, CL}",
Evan Cheng069287d2006-05-16 07:21:53 +00002228 [(set GR16:$dst, (X86shrd GR16:$src1, GR16:$src2, CL))]>,
Evan Cheng071a2792007-09-11 19:55:27 +00002229 TB, OpSize;
2230}
Chris Lattner41e431b2005-01-19 07:11:01 +00002231
2232let isCommutable = 1 in { // These instructions commute to each other.
Chris Lattner3a173df2004-10-03 20:35:00 +00002233def SHLD32rri8 : Ii8<0xA4, MRMDestReg,
Evan Cheng64d80e32007-07-19 01:14:50 +00002234 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2, i8imm:$src3),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002235 "shld{l}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Evan Cheng069287d2006-05-16 07:21:53 +00002236 [(set GR32:$dst, (X86shld GR32:$src1, GR32:$src2,
Evan Chenge3413162006-01-09 18:33:28 +00002237 (i8 imm:$src3)))]>,
2238 TB;
Chris Lattner3a173df2004-10-03 20:35:00 +00002239def SHRD32rri8 : Ii8<0xAC, MRMDestReg,
Evan Cheng64d80e32007-07-19 01:14:50 +00002240 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2, i8imm:$src3),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002241 "shrd{l}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Evan Cheng069287d2006-05-16 07:21:53 +00002242 [(set GR32:$dst, (X86shrd GR32:$src1, GR32:$src2,
Evan Chenge3413162006-01-09 18:33:28 +00002243 (i8 imm:$src3)))]>,
2244 TB;
Chris Lattner0df53d22005-01-19 07:31:24 +00002245def SHLD16rri8 : Ii8<0xA4, MRMDestReg,
Evan Cheng64d80e32007-07-19 01:14:50 +00002246 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2, i8imm:$src3),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002247 "shld{w}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Evan Cheng069287d2006-05-16 07:21:53 +00002248 [(set GR16:$dst, (X86shld GR16:$src1, GR16:$src2,
Evan Chenge3413162006-01-09 18:33:28 +00002249 (i8 imm:$src3)))]>,
Chris Lattner0df53d22005-01-19 07:31:24 +00002250 TB, OpSize;
2251def SHRD16rri8 : Ii8<0xAC, MRMDestReg,
Evan Cheng64d80e32007-07-19 01:14:50 +00002252 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2, i8imm:$src3),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002253 "shrd{w}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Evan Cheng069287d2006-05-16 07:21:53 +00002254 [(set GR16:$dst, (X86shrd GR16:$src1, GR16:$src2,
Evan Chenge3413162006-01-09 18:33:28 +00002255 (i8 imm:$src3)))]>,
Chris Lattner0df53d22005-01-19 07:31:24 +00002256 TB, OpSize;
Chris Lattner41e431b2005-01-19 07:11:01 +00002257}
Chris Lattner0e967d42004-08-01 08:13:11 +00002258
Chris Lattner57a02302004-08-11 04:31:00 +00002259let isTwoAddress = 0 in {
Evan Cheng071a2792007-09-11 19:55:27 +00002260 let Uses = [CL] in {
Evan Cheng64d80e32007-07-19 01:14:50 +00002261 def SHLD32mrCL : I<0xA5, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
Eli Friedmanaace4b12009-06-19 04:48:38 +00002262 "shld{l}\t{%cl, $src2, $dst|$dst, $src2, CL}",
Evan Cheng069287d2006-05-16 07:21:53 +00002263 [(store (X86shld (loadi32 addr:$dst), GR32:$src2, CL),
Evan Cheng071a2792007-09-11 19:55:27 +00002264 addr:$dst)]>, TB;
Evan Cheng64d80e32007-07-19 01:14:50 +00002265 def SHRD32mrCL : I<0xAD, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
Eli Friedmanaace4b12009-06-19 04:48:38 +00002266 "shrd{l}\t{%cl, $src2, $dst|$dst, $src2, CL}",
Evan Cheng069287d2006-05-16 07:21:53 +00002267 [(store (X86shrd (loadi32 addr:$dst), GR32:$src2, CL),
Evan Cheng071a2792007-09-11 19:55:27 +00002268 addr:$dst)]>, TB;
2269 }
Chris Lattner3a173df2004-10-03 20:35:00 +00002270 def SHLD32mri8 : Ii8<0xA4, MRMDestMem,
Evan Cheng64d80e32007-07-19 01:14:50 +00002271 (outs), (ins i32mem:$dst, GR32:$src2, i8imm:$src3),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002272 "shld{l}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Evan Cheng069287d2006-05-16 07:21:53 +00002273 [(store (X86shld (loadi32 addr:$dst), GR32:$src2,
Evan Chenge3413162006-01-09 18:33:28 +00002274 (i8 imm:$src3)), addr:$dst)]>,
Chris Lattnerf124d5e2005-11-18 01:04:42 +00002275 TB;
Chris Lattner3a173df2004-10-03 20:35:00 +00002276 def SHRD32mri8 : Ii8<0xAC, MRMDestMem,
Evan Cheng64d80e32007-07-19 01:14:50 +00002277 (outs), (ins i32mem:$dst, GR32:$src2, i8imm:$src3),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002278 "shrd{l}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Evan Cheng069287d2006-05-16 07:21:53 +00002279 [(store (X86shrd (loadi32 addr:$dst), GR32:$src2,
Evan Chenge3413162006-01-09 18:33:28 +00002280 (i8 imm:$src3)), addr:$dst)]>,
Chris Lattnerf124d5e2005-11-18 01:04:42 +00002281 TB;
Chris Lattner0df53d22005-01-19 07:31:24 +00002282
Evan Cheng071a2792007-09-11 19:55:27 +00002283 let Uses = [CL] in {
Evan Cheng64d80e32007-07-19 01:14:50 +00002284 def SHLD16mrCL : I<0xA5, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
Eli Friedmanaace4b12009-06-19 04:48:38 +00002285 "shld{w}\t{%cl, $src2, $dst|$dst, $src2, CL}",
Evan Cheng069287d2006-05-16 07:21:53 +00002286 [(store (X86shld (loadi16 addr:$dst), GR16:$src2, CL),
Evan Cheng071a2792007-09-11 19:55:27 +00002287 addr:$dst)]>, TB, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00002288 def SHRD16mrCL : I<0xAD, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
Eli Friedmanaace4b12009-06-19 04:48:38 +00002289 "shrd{w}\t{%cl, $src2, $dst|$dst, $src2, CL}",
Evan Cheng069287d2006-05-16 07:21:53 +00002290 [(store (X86shrd (loadi16 addr:$dst), GR16:$src2, CL),
Evan Cheng071a2792007-09-11 19:55:27 +00002291 addr:$dst)]>, TB, OpSize;
2292 }
Chris Lattner0df53d22005-01-19 07:31:24 +00002293 def SHLD16mri8 : Ii8<0xA4, MRMDestMem,
Evan Cheng64d80e32007-07-19 01:14:50 +00002294 (outs), (ins i16mem:$dst, GR16:$src2, i8imm:$src3),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002295 "shld{w}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Evan Cheng069287d2006-05-16 07:21:53 +00002296 [(store (X86shld (loadi16 addr:$dst), GR16:$src2,
Evan Chenge3413162006-01-09 18:33:28 +00002297 (i8 imm:$src3)), addr:$dst)]>,
Chris Lattner0df53d22005-01-19 07:31:24 +00002298 TB, OpSize;
2299 def SHRD16mri8 : Ii8<0xAC, MRMDestMem,
Evan Cheng64d80e32007-07-19 01:14:50 +00002300 (outs), (ins i16mem:$dst, GR16:$src2, i8imm:$src3),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002301 "shrd{w}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Evan Cheng069287d2006-05-16 07:21:53 +00002302 [(store (X86shrd (loadi16 addr:$dst), GR16:$src2,
Evan Chenge3413162006-01-09 18:33:28 +00002303 (i8 imm:$src3)), addr:$dst)]>,
Chris Lattner0df53d22005-01-19 07:31:24 +00002304 TB, OpSize;
Chris Lattner57a02302004-08-11 04:31:00 +00002305}
Evan Cheng24f2ea32007-09-14 21:48:26 +00002306} // Defs = [EFLAGS]
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00002307
2308
Chris Lattnercc65bee2005-01-02 02:35:46 +00002309// Arithmetic.
Evan Cheng24f2ea32007-09-14 21:48:26 +00002310let Defs = [EFLAGS] in {
Chris Lattnercc65bee2005-01-02 02:35:46 +00002311let isCommutable = 1 in { // X = ADD Y, Z --> X = ADD Z, Y
Bill Wendlingab55ebd2008-12-12 00:56:36 +00002312// Register-Register Addition
2313def ADD8rr : I<0x00, MRMDestReg, (outs GR8 :$dst),
2314 (ins GR8 :$src1, GR8 :$src2),
2315 "add{b}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingd350e022008-12-12 21:15:41 +00002316 [(set GR8:$dst, (add GR8:$src1, GR8:$src2)),
Bill Wendlingab55ebd2008-12-12 00:56:36 +00002317 (implicit EFLAGS)]>;
2318
Chris Lattnercc65bee2005-01-02 02:35:46 +00002319let isConvertibleToThreeAddress = 1 in { // Can transform into LEA.
Bill Wendlingab55ebd2008-12-12 00:56:36 +00002320// Register-Register Addition
Evan Cheng071a2792007-09-11 19:55:27 +00002321def ADD16rr : I<0x01, MRMDestReg, (outs GR16:$dst),
2322 (ins GR16:$src1, GR16:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002323 "add{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingd350e022008-12-12 21:15:41 +00002324 [(set GR16:$dst, (add GR16:$src1, GR16:$src2)),
2325 (implicit EFLAGS)]>, OpSize;
Evan Cheng071a2792007-09-11 19:55:27 +00002326def ADD32rr : I<0x01, MRMDestReg, (outs GR32:$dst),
2327 (ins GR32:$src1, GR32:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002328 "add{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingd350e022008-12-12 21:15:41 +00002329 [(set GR32:$dst, (add GR32:$src1, GR32:$src2)),
2330 (implicit EFLAGS)]>;
Chris Lattnercc65bee2005-01-02 02:35:46 +00002331} // end isConvertibleToThreeAddress
2332} // end isCommutable
Bill Wendlingab55ebd2008-12-12 00:56:36 +00002333
2334// Register-Memory Addition
Evan Cheng071a2792007-09-11 19:55:27 +00002335def ADD8rm : I<0x02, MRMSrcMem, (outs GR8 :$dst),
2336 (ins GR8 :$src1, i8mem :$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002337 "add{b}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingd350e022008-12-12 21:15:41 +00002338 [(set GR8:$dst, (add GR8:$src1, (load addr:$src2))),
2339 (implicit EFLAGS)]>;
Evan Cheng071a2792007-09-11 19:55:27 +00002340def ADD16rm : I<0x03, MRMSrcMem, (outs GR16:$dst),
2341 (ins GR16:$src1, i16mem:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002342 "add{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingd350e022008-12-12 21:15:41 +00002343 [(set GR16:$dst, (add GR16:$src1, (load addr:$src2))),
2344 (implicit EFLAGS)]>, OpSize;
Evan Cheng071a2792007-09-11 19:55:27 +00002345def ADD32rm : I<0x03, MRMSrcMem, (outs GR32:$dst),
2346 (ins GR32:$src1, i32mem:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002347 "add{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingd350e022008-12-12 21:15:41 +00002348 [(set GR32:$dst, (add GR32:$src1, (load addr:$src2))),
2349 (implicit EFLAGS)]>;
Chris Lattnercc65bee2005-01-02 02:35:46 +00002350
Bill Wendlingab55ebd2008-12-12 00:56:36 +00002351// Register-Integer Addition
2352def ADD8ri : Ii8<0x80, MRM0r, (outs GR8:$dst), (ins GR8:$src1, i8imm:$src2),
2353 "add{b}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingd350e022008-12-12 21:15:41 +00002354 [(set GR8:$dst, (add GR8:$src1, imm:$src2)),
2355 (implicit EFLAGS)]>;
Bill Wendlingab55ebd2008-12-12 00:56:36 +00002356
Chris Lattnercc65bee2005-01-02 02:35:46 +00002357let isConvertibleToThreeAddress = 1 in { // Can transform into LEA.
Bill Wendlingab55ebd2008-12-12 00:56:36 +00002358// Register-Integer Addition
Evan Cheng071a2792007-09-11 19:55:27 +00002359def ADD16ri : Ii16<0x81, MRM0r, (outs GR16:$dst),
2360 (ins GR16:$src1, i16imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002361 "add{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingd350e022008-12-12 21:15:41 +00002362 [(set GR16:$dst, (add GR16:$src1, imm:$src2)),
2363 (implicit EFLAGS)]>, OpSize;
Evan Cheng071a2792007-09-11 19:55:27 +00002364def ADD32ri : Ii32<0x81, MRM0r, (outs GR32:$dst),
2365 (ins GR32:$src1, i32imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002366 "add{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingd350e022008-12-12 21:15:41 +00002367 [(set GR32:$dst, (add GR32:$src1, imm:$src2)),
2368 (implicit EFLAGS)]>;
Evan Cheng071a2792007-09-11 19:55:27 +00002369def ADD16ri8 : Ii8<0x83, MRM0r, (outs GR16:$dst),
2370 (ins GR16:$src1, i16i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002371 "add{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingd350e022008-12-12 21:15:41 +00002372 [(set GR16:$dst, (add GR16:$src1, i16immSExt8:$src2)),
2373 (implicit EFLAGS)]>, OpSize;
Evan Cheng071a2792007-09-11 19:55:27 +00002374def ADD32ri8 : Ii8<0x83, MRM0r, (outs GR32:$dst),
2375 (ins GR32:$src1, i32i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002376 "add{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingd350e022008-12-12 21:15:41 +00002377 [(set GR32:$dst, (add GR32:$src1, i32immSExt8:$src2)),
2378 (implicit EFLAGS)]>;
Evan Cheng09e3c802006-05-19 18:40:54 +00002379}
Chris Lattner57a02302004-08-11 04:31:00 +00002380
2381let isTwoAddress = 0 in {
Bill Wendlingab55ebd2008-12-12 00:56:36 +00002382 // Memory-Register Addition
Bill Wendlingd350e022008-12-12 21:15:41 +00002383 def ADD8mr : I<0x00, MRMDestMem, (outs), (ins i8mem:$dst, GR8:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002384 "add{b}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingd350e022008-12-12 21:15:41 +00002385 [(store (add (load addr:$dst), GR8:$src2), addr:$dst),
2386 (implicit EFLAGS)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00002387 def ADD16mr : I<0x01, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002388 "add{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingd350e022008-12-12 21:15:41 +00002389 [(store (add (load addr:$dst), GR16:$src2), addr:$dst),
2390 (implicit EFLAGS)]>, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00002391 def ADD32mr : I<0x01, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002392 "add{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingd350e022008-12-12 21:15:41 +00002393 [(store (add (load addr:$dst), GR32:$src2), addr:$dst),
2394 (implicit EFLAGS)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00002395 def ADD8mi : Ii8<0x80, MRM0m, (outs), (ins i8mem :$dst, i8imm :$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002396 "add{b}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingd350e022008-12-12 21:15:41 +00002397 [(store (add (loadi8 addr:$dst), imm:$src2), addr:$dst),
2398 (implicit EFLAGS)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00002399 def ADD16mi : Ii16<0x81, MRM0m, (outs), (ins i16mem:$dst, i16imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002400 "add{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingd350e022008-12-12 21:15:41 +00002401 [(store (add (loadi16 addr:$dst), imm:$src2), addr:$dst),
2402 (implicit EFLAGS)]>, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00002403 def ADD32mi : Ii32<0x81, MRM0m, (outs), (ins i32mem:$dst, i32imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002404 "add{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingd350e022008-12-12 21:15:41 +00002405 [(store (add (loadi32 addr:$dst), imm:$src2), addr:$dst),
2406 (implicit EFLAGS)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00002407 def ADD16mi8 : Ii8<0x83, MRM0m, (outs), (ins i16mem:$dst, i16i8imm :$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002408 "add{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingd350e022008-12-12 21:15:41 +00002409 [(store (add (load addr:$dst), i16immSExt8:$src2),
2410 addr:$dst),
2411 (implicit EFLAGS)]>, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00002412 def ADD32mi8 : Ii8<0x83, MRM0m, (outs), (ins i32mem:$dst, i32i8imm :$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002413 "add{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingab55ebd2008-12-12 00:56:36 +00002414 [(store (add (load addr:$dst), i32immSExt8:$src2),
Bill Wendlingd350e022008-12-12 21:15:41 +00002415 addr:$dst),
2416 (implicit EFLAGS)]>;
Sean Callananb08ae6b2009-08-11 21:26:06 +00002417
2418 // addition to rAX
2419 def ADD8i8 : Ii8<0x04, RawFrm, (outs), (ins i8imm:$src),
Sean Callanana09caa52009-09-02 00:55:49 +00002420 "add{b}\t{$src, %al|%al, $src}", []>;
Sean Callananb08ae6b2009-08-11 21:26:06 +00002421 def ADD16i16 : Ii16<0x05, RawFrm, (outs), (ins i16imm:$src),
Sean Callanana09caa52009-09-02 00:55:49 +00002422 "add{w}\t{$src, %ax|%ax, $src}", []>, OpSize;
Sean Callananb08ae6b2009-08-11 21:26:06 +00002423 def ADD32i32 : Ii32<0x05, RawFrm, (outs), (ins i32imm:$src),
Sean Callanana09caa52009-09-02 00:55:49 +00002424 "add{l}\t{$src, %eax|%eax, $src}", []>;
Chris Lattner57a02302004-08-11 04:31:00 +00002425}
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00002426
Evan Cheng3154cb62007-10-05 17:59:57 +00002427let Uses = [EFLAGS] in {
Chris Lattner10197ff2005-01-03 01:27:59 +00002428let isCommutable = 1 in { // X = ADC Y, Z --> X = ADC Z, Y
Dale Johannesen874ae252009-06-02 03:12:52 +00002429def ADC8rr : I<0x10, MRMDestReg, (outs GR8:$dst), (ins GR8:$src1, GR8:$src2),
Dale Johannesenca11dae2009-05-18 17:44:15 +00002430 "adc{b}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen874ae252009-06-02 03:12:52 +00002431 [(set GR8:$dst, (adde GR8:$src1, GR8:$src2))]>;
Dale Johannesenca11dae2009-05-18 17:44:15 +00002432def ADC16rr : I<0x11, MRMDestReg, (outs GR16:$dst),
2433 (ins GR16:$src1, GR16:$src2),
2434 "adc{w}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen874ae252009-06-02 03:12:52 +00002435 [(set GR16:$dst, (adde GR16:$src1, GR16:$src2))]>, OpSize;
Dale Johannesenca11dae2009-05-18 17:44:15 +00002436def ADC32rr : I<0x11, MRMDestReg, (outs GR32:$dst),
2437 (ins GR32:$src1, GR32:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002438 "adc{l}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen874ae252009-06-02 03:12:52 +00002439 [(set GR32:$dst, (adde GR32:$src1, GR32:$src2))]>;
Chris Lattner10197ff2005-01-03 01:27:59 +00002440}
Dale Johannesenca11dae2009-05-18 17:44:15 +00002441def ADC8rm : I<0x12, MRMSrcMem , (outs GR8:$dst),
2442 (ins GR8:$src1, i8mem:$src2),
2443 "adc{b}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen874ae252009-06-02 03:12:52 +00002444 [(set GR8:$dst, (adde GR8:$src1, (load addr:$src2)))]>;
Dale Johannesenca11dae2009-05-18 17:44:15 +00002445def ADC16rm : I<0x13, MRMSrcMem , (outs GR16:$dst),
2446 (ins GR16:$src1, i16mem:$src2),
2447 "adc{w}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen874ae252009-06-02 03:12:52 +00002448 [(set GR16:$dst, (adde GR16:$src1, (load addr:$src2)))]>,
Dale Johannesen94c9cd12009-05-18 21:41:59 +00002449 OpSize;
Dale Johannesenca11dae2009-05-18 17:44:15 +00002450def ADC32rm : I<0x13, MRMSrcMem , (outs GR32:$dst),
2451 (ins GR32:$src1, i32mem:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002452 "adc{l}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen874ae252009-06-02 03:12:52 +00002453 [(set GR32:$dst, (adde GR32:$src1, (load addr:$src2)))]>;
2454def ADC8ri : Ii8<0x80, MRM2r, (outs GR8:$dst), (ins GR8:$src1, i8imm:$src2),
Dale Johannesenca11dae2009-05-18 17:44:15 +00002455 "adc{b}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen874ae252009-06-02 03:12:52 +00002456 [(set GR8:$dst, (adde GR8:$src1, imm:$src2))]>;
Dale Johannesenca11dae2009-05-18 17:44:15 +00002457def ADC16ri : Ii16<0x81, MRM2r, (outs GR16:$dst),
2458 (ins GR16:$src1, i16imm:$src2),
2459 "adc{w}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen874ae252009-06-02 03:12:52 +00002460 [(set GR16:$dst, (adde GR16:$src1, imm:$src2))]>, OpSize;
Dale Johannesenca11dae2009-05-18 17:44:15 +00002461def ADC16ri8 : Ii8<0x83, MRM2r, (outs GR16:$dst),
2462 (ins GR16:$src1, i16i8imm:$src2),
2463 "adc{w}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen874ae252009-06-02 03:12:52 +00002464 [(set GR16:$dst, (adde GR16:$src1, i16immSExt8:$src2))]>,
2465 OpSize;
Dale Johannesenca11dae2009-05-18 17:44:15 +00002466def ADC32ri : Ii32<0x81, MRM2r, (outs GR32:$dst),
2467 (ins GR32:$src1, i32imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002468 "adc{l}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen874ae252009-06-02 03:12:52 +00002469 [(set GR32:$dst, (adde GR32:$src1, imm:$src2))]>;
Dale Johannesenca11dae2009-05-18 17:44:15 +00002470def ADC32ri8 : Ii8<0x83, MRM2r, (outs GR32:$dst),
2471 (ins GR32:$src1, i32i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002472 "adc{l}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen874ae252009-06-02 03:12:52 +00002473 [(set GR32:$dst, (adde GR32:$src1, i32immSExt8:$src2))]>;
Chris Lattner57a02302004-08-11 04:31:00 +00002474
2475let isTwoAddress = 0 in {
Dale Johannesen874ae252009-06-02 03:12:52 +00002476 def ADC8mr : I<0x10, MRMDestMem, (outs), (ins i8mem:$dst, GR8:$src2),
Dale Johannesenca11dae2009-05-18 17:44:15 +00002477 "adc{b}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen874ae252009-06-02 03:12:52 +00002478 [(store (adde (load addr:$dst), GR8:$src2), addr:$dst)]>;
2479 def ADC16mr : I<0x11, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
Dale Johannesenca11dae2009-05-18 17:44:15 +00002480 "adc{w}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen874ae252009-06-02 03:12:52 +00002481 [(store (adde (load addr:$dst), GR16:$src2), addr:$dst)]>,
2482 OpSize;
2483 def ADC32mr : I<0x11, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002484 "adc{l}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen874ae252009-06-02 03:12:52 +00002485 [(store (adde (load addr:$dst), GR32:$src2), addr:$dst)]>;
2486 def ADC8mi : Ii8<0x80, MRM2m, (outs), (ins i8mem:$dst, i8imm:$src2),
Dale Johannesenca11dae2009-05-18 17:44:15 +00002487 "adc{b}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen874ae252009-06-02 03:12:52 +00002488 [(store (adde (loadi8 addr:$dst), imm:$src2), addr:$dst)]>;
2489 def ADC16mi : Ii16<0x81, MRM2m, (outs), (ins i16mem:$dst, i16imm:$src2),
Dale Johannesenca11dae2009-05-18 17:44:15 +00002490 "adc{w}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen874ae252009-06-02 03:12:52 +00002491 [(store (adde (loadi16 addr:$dst), imm:$src2), addr:$dst)]>,
2492 OpSize;
2493 def ADC16mi8 : Ii8<0x83, MRM2m, (outs), (ins i16mem:$dst, i16i8imm :$src2),
Dale Johannesenca11dae2009-05-18 17:44:15 +00002494 "adc{w}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen874ae252009-06-02 03:12:52 +00002495 [(store (adde (load addr:$dst), i16immSExt8:$src2), addr:$dst)]>,
2496 OpSize;
2497 def ADC32mi : Ii32<0x81, MRM2m, (outs), (ins i32mem:$dst, i32imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002498 "adc{l}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen874ae252009-06-02 03:12:52 +00002499 [(store (adde (loadi32 addr:$dst), imm:$src2), addr:$dst)]>;
2500 def ADC32mi8 : Ii8<0x83, MRM2m, (outs), (ins i32mem:$dst, i32i8imm :$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002501 "adc{l}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen874ae252009-06-02 03:12:52 +00002502 [(store (adde (load addr:$dst), i32immSExt8:$src2), addr:$dst)]>;
2503}
Evan Cheng3154cb62007-10-05 17:59:57 +00002504} // Uses = [EFLAGS]
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00002505
Bill Wendlingab55ebd2008-12-12 00:56:36 +00002506// Register-Register Subtraction
2507def SUB8rr : I<0x28, MRMDestReg, (outs GR8:$dst), (ins GR8:$src1, GR8:$src2),
2508 "sub{b}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingd350e022008-12-12 21:15:41 +00002509 [(set GR8:$dst, (sub GR8:$src1, GR8:$src2)),
2510 (implicit EFLAGS)]>;
Bill Wendlingab55ebd2008-12-12 00:56:36 +00002511def SUB16rr : I<0x29, MRMDestReg, (outs GR16:$dst), (ins GR16:$src1,GR16:$src2),
2512 "sub{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingd350e022008-12-12 21:15:41 +00002513 [(set GR16:$dst, (sub GR16:$src1, GR16:$src2)),
2514 (implicit EFLAGS)]>, OpSize;
Bill Wendlingab55ebd2008-12-12 00:56:36 +00002515def SUB32rr : I<0x29, MRMDestReg, (outs GR32:$dst), (ins GR32:$src1,GR32:$src2),
2516 "sub{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingd350e022008-12-12 21:15:41 +00002517 [(set GR32:$dst, (sub GR32:$src1, GR32:$src2)),
2518 (implicit EFLAGS)]>;
Bill Wendlingab55ebd2008-12-12 00:56:36 +00002519
2520// Register-Memory Subtraction
2521def SUB8rm : I<0x2A, MRMSrcMem, (outs GR8 :$dst),
2522 (ins GR8 :$src1, i8mem :$src2),
2523 "sub{b}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingd350e022008-12-12 21:15:41 +00002524 [(set GR8:$dst, (sub GR8:$src1, (load addr:$src2))),
2525 (implicit EFLAGS)]>;
Bill Wendlingab55ebd2008-12-12 00:56:36 +00002526def SUB16rm : I<0x2B, MRMSrcMem, (outs GR16:$dst),
2527 (ins GR16:$src1, i16mem:$src2),
2528 "sub{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingd350e022008-12-12 21:15:41 +00002529 [(set GR16:$dst, (sub GR16:$src1, (load addr:$src2))),
2530 (implicit EFLAGS)]>, OpSize;
Bill Wendlingab55ebd2008-12-12 00:56:36 +00002531def SUB32rm : I<0x2B, MRMSrcMem, (outs GR32:$dst),
2532 (ins GR32:$src1, i32mem:$src2),
2533 "sub{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingd350e022008-12-12 21:15:41 +00002534 [(set GR32:$dst, (sub GR32:$src1, (load addr:$src2))),
2535 (implicit EFLAGS)]>;
Bill Wendlingab55ebd2008-12-12 00:56:36 +00002536
2537// Register-Integer Subtraction
2538def SUB8ri : Ii8 <0x80, MRM5r, (outs GR8:$dst),
2539 (ins GR8:$src1, i8imm:$src2),
2540 "sub{b}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingd350e022008-12-12 21:15:41 +00002541 [(set GR8:$dst, (sub GR8:$src1, imm:$src2)),
2542 (implicit EFLAGS)]>;
Bill Wendlingab55ebd2008-12-12 00:56:36 +00002543def SUB16ri : Ii16<0x81, MRM5r, (outs GR16:$dst),
2544 (ins GR16:$src1, i16imm:$src2),
2545 "sub{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingd350e022008-12-12 21:15:41 +00002546 [(set GR16:$dst, (sub GR16:$src1, imm:$src2)),
2547 (implicit EFLAGS)]>, OpSize;
Bill Wendlingab55ebd2008-12-12 00:56:36 +00002548def SUB32ri : Ii32<0x81, MRM5r, (outs GR32:$dst),
2549 (ins GR32:$src1, i32imm:$src2),
2550 "sub{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingd350e022008-12-12 21:15:41 +00002551 [(set GR32:$dst, (sub GR32:$src1, imm:$src2)),
2552 (implicit EFLAGS)]>;
Bill Wendlingab55ebd2008-12-12 00:56:36 +00002553def SUB16ri8 : Ii8<0x83, MRM5r, (outs GR16:$dst),
2554 (ins GR16:$src1, i16i8imm:$src2),
2555 "sub{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingd350e022008-12-12 21:15:41 +00002556 [(set GR16:$dst, (sub GR16:$src1, i16immSExt8:$src2)),
2557 (implicit EFLAGS)]>, OpSize;
Bill Wendlingab55ebd2008-12-12 00:56:36 +00002558def SUB32ri8 : Ii8<0x83, MRM5r, (outs GR32:$dst),
2559 (ins GR32:$src1, i32i8imm:$src2),
2560 "sub{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingd350e022008-12-12 21:15:41 +00002561 [(set GR32:$dst, (sub GR32:$src1, i32immSExt8:$src2)),
2562 (implicit EFLAGS)]>;
Bill Wendlingab55ebd2008-12-12 00:56:36 +00002563
Chris Lattner57a02302004-08-11 04:31:00 +00002564let isTwoAddress = 0 in {
Bill Wendlingab55ebd2008-12-12 00:56:36 +00002565 // Memory-Register Subtraction
Evan Cheng64d80e32007-07-19 01:14:50 +00002566 def SUB8mr : I<0x28, MRMDestMem, (outs), (ins i8mem :$dst, GR8 :$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002567 "sub{b}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingd350e022008-12-12 21:15:41 +00002568 [(store (sub (load addr:$dst), GR8:$src2), addr:$dst),
2569 (implicit EFLAGS)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00002570 def SUB16mr : I<0x29, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002571 "sub{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingd350e022008-12-12 21:15:41 +00002572 [(store (sub (load addr:$dst), GR16:$src2), addr:$dst),
2573 (implicit EFLAGS)]>, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00002574 def SUB32mr : I<0x29, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002575 "sub{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingd350e022008-12-12 21:15:41 +00002576 [(store (sub (load addr:$dst), GR32:$src2), addr:$dst),
2577 (implicit EFLAGS)]>;
Bill Wendlingab55ebd2008-12-12 00:56:36 +00002578
2579 // Memory-Integer Subtraction
Evan Cheng64d80e32007-07-19 01:14:50 +00002580 def SUB8mi : Ii8<0x80, MRM5m, (outs), (ins i8mem :$dst, i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002581 "sub{b}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingd350e022008-12-12 21:15:41 +00002582 [(store (sub (loadi8 addr:$dst), imm:$src2), addr:$dst),
2583 (implicit EFLAGS)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00002584 def SUB16mi : Ii16<0x81, MRM5m, (outs), (ins i16mem:$dst, i16imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002585 "sub{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingd350e022008-12-12 21:15:41 +00002586 [(store (sub (loadi16 addr:$dst), imm:$src2),addr:$dst),
2587 (implicit EFLAGS)]>, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00002588 def SUB32mi : Ii32<0x81, MRM5m, (outs), (ins i32mem:$dst, i32imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002589 "sub{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingd350e022008-12-12 21:15:41 +00002590 [(store (sub (loadi32 addr:$dst), imm:$src2),addr:$dst),
2591 (implicit EFLAGS)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00002592 def SUB16mi8 : Ii8<0x83, MRM5m, (outs), (ins i16mem:$dst, i16i8imm :$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002593 "sub{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingab55ebd2008-12-12 00:56:36 +00002594 [(store (sub (load addr:$dst), i16immSExt8:$src2),
Bill Wendlingd350e022008-12-12 21:15:41 +00002595 addr:$dst),
2596 (implicit EFLAGS)]>, OpSize;
Bill Wendlingab55ebd2008-12-12 00:56:36 +00002597 def SUB32mi8 : Ii8<0x83, MRM5m, (outs), (ins i32mem:$dst, i32i8imm :$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002598 "sub{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingab55ebd2008-12-12 00:56:36 +00002599 [(store (sub (load addr:$dst), i32immSExt8:$src2),
Bill Wendlingd350e022008-12-12 21:15:41 +00002600 addr:$dst),
2601 (implicit EFLAGS)]>;
Chris Lattner57a02302004-08-11 04:31:00 +00002602}
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00002603
Evan Cheng3154cb62007-10-05 17:59:57 +00002604let Uses = [EFLAGS] in {
Dale Johannesenca11dae2009-05-18 17:44:15 +00002605def SBB8rr : I<0x18, MRMDestReg, (outs GR8:$dst),
2606 (ins GR8:$src1, GR8:$src2),
2607 "sbb{b}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen874ae252009-06-02 03:12:52 +00002608 [(set GR8:$dst, (sube GR8:$src1, GR8:$src2))]>;
Dale Johannesenca11dae2009-05-18 17:44:15 +00002609def SBB16rr : I<0x19, MRMDestReg, (outs GR16:$dst),
2610 (ins GR16:$src1, GR16:$src2),
2611 "sbb{w}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen874ae252009-06-02 03:12:52 +00002612 [(set GR16:$dst, (sube GR16:$src1, GR16:$src2))]>, OpSize;
Dale Johannesenca11dae2009-05-18 17:44:15 +00002613def SBB32rr : I<0x19, MRMDestReg, (outs GR32:$dst),
2614 (ins GR32:$src1, GR32:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002615 "sbb{l}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen874ae252009-06-02 03:12:52 +00002616 [(set GR32:$dst, (sube GR32:$src1, GR32:$src2))]>;
Chris Lattnerd93d3b02004-10-06 04:01:02 +00002617
Chris Lattner57a02302004-08-11 04:31:00 +00002618let isTwoAddress = 0 in {
Dale Johannesenca11dae2009-05-18 17:44:15 +00002619 def SBB8mr : I<0x18, MRMDestMem, (outs), (ins i8mem:$dst, GR8:$src2),
2620 "sbb{b}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen874ae252009-06-02 03:12:52 +00002621 [(store (sube (load addr:$dst), GR8:$src2), addr:$dst)]>;
Dale Johannesenca11dae2009-05-18 17:44:15 +00002622 def SBB16mr : I<0x19, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
2623 "sbb{w}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen874ae252009-06-02 03:12:52 +00002624 [(store (sube (load addr:$dst), GR16:$src2), addr:$dst)]>,
Dale Johannesen94c9cd12009-05-18 21:41:59 +00002625 OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00002626 def SBB32mr : I<0x19, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002627 "sbb{l}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen874ae252009-06-02 03:12:52 +00002628 [(store (sube (load addr:$dst), GR32:$src2), addr:$dst)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00002629 def SBB8mi : Ii32<0x80, MRM3m, (outs), (ins i8mem:$dst, i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002630 "sbb{b}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen874ae252009-06-02 03:12:52 +00002631 [(store (sube (loadi8 addr:$dst), imm:$src2), addr:$dst)]>;
Dale Johannesenca11dae2009-05-18 17:44:15 +00002632 def SBB16mi : Ii16<0x81, MRM3m, (outs), (ins i16mem:$dst, i16imm:$src2),
2633 "sbb{w}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen874ae252009-06-02 03:12:52 +00002634 [(store (sube (loadi16 addr:$dst), imm:$src2), addr:$dst)]>,
Dale Johannesen94c9cd12009-05-18 21:41:59 +00002635 OpSize;
Dale Johannesenca11dae2009-05-18 17:44:15 +00002636 def SBB16mi8 : Ii8<0x83, MRM3m, (outs), (ins i16mem:$dst, i16i8imm :$src2),
2637 "sbb{w}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen874ae252009-06-02 03:12:52 +00002638 [(store (sube (load addr:$dst), i16immSExt8:$src2), addr:$dst)]>,
Dale Johannesen94c9cd12009-05-18 21:41:59 +00002639 OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00002640 def SBB32mi : Ii32<0x81, MRM3m, (outs), (ins i32mem:$dst, i32imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002641 "sbb{l}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen874ae252009-06-02 03:12:52 +00002642 [(store (sube (loadi32 addr:$dst), imm:$src2), addr:$dst)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00002643 def SBB32mi8 : Ii8<0x83, MRM3m, (outs), (ins i32mem:$dst, i32i8imm :$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002644 "sbb{l}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen874ae252009-06-02 03:12:52 +00002645 [(store (sube (load addr:$dst), i32immSExt8:$src2), addr:$dst)]>;
Chris Lattner57a02302004-08-11 04:31:00 +00002646}
Dale Johannesenca11dae2009-05-18 17:44:15 +00002647def SBB8rm : I<0x1A, MRMSrcMem, (outs GR8:$dst), (ins GR8:$src1, i8mem:$src2),
2648 "sbb{b}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen874ae252009-06-02 03:12:52 +00002649 [(set GR8:$dst, (sube GR8:$src1, (load addr:$src2)))]>;
Dale Johannesenca11dae2009-05-18 17:44:15 +00002650def SBB16rm : I<0x1B, MRMSrcMem, (outs GR16:$dst),
2651 (ins GR16:$src1, i16mem:$src2),
2652 "sbb{w}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen874ae252009-06-02 03:12:52 +00002653 [(set GR16:$dst, (sube GR16:$src1, (load addr:$src2)))]>,
Dale Johannesen94c9cd12009-05-18 21:41:59 +00002654 OpSize;
Dale Johannesenca11dae2009-05-18 17:44:15 +00002655def SBB32rm : I<0x1B, MRMSrcMem, (outs GR32:$dst),
2656 (ins GR32:$src1, i32mem:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002657 "sbb{l}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen874ae252009-06-02 03:12:52 +00002658 [(set GR32:$dst, (sube GR32:$src1, (load addr:$src2)))]>;
Dale Johannesenca11dae2009-05-18 17:44:15 +00002659def SBB8ri : Ii8<0x80, MRM3r, (outs GR8:$dst), (ins GR8:$src1, i8imm:$src2),
2660 "sbb{b}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen874ae252009-06-02 03:12:52 +00002661 [(set GR8:$dst, (sube GR8:$src1, imm:$src2))]>;
Dale Johannesenca11dae2009-05-18 17:44:15 +00002662def SBB16ri : Ii16<0x81, MRM3r, (outs GR16:$dst),
2663 (ins GR16:$src1, i16imm:$src2),
2664 "sbb{w}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen874ae252009-06-02 03:12:52 +00002665 [(set GR16:$dst, (sube GR16:$src1, imm:$src2))]>, OpSize;
Dale Johannesenca11dae2009-05-18 17:44:15 +00002666def SBB16ri8 : Ii8<0x83, MRM3r, (outs GR16:$dst),
2667 (ins GR16:$src1, i16i8imm:$src2),
2668 "sbb{w}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen874ae252009-06-02 03:12:52 +00002669 [(set GR16:$dst, (sube GR16:$src1, i16immSExt8:$src2))]>,
2670 OpSize;
Dale Johannesenca11dae2009-05-18 17:44:15 +00002671def SBB32ri : Ii32<0x81, MRM3r, (outs GR32:$dst),
2672 (ins GR32:$src1, i32imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002673 "sbb{l}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen874ae252009-06-02 03:12:52 +00002674 [(set GR32:$dst, (sube GR32:$src1, imm:$src2))]>;
Dale Johannesenca11dae2009-05-18 17:44:15 +00002675def SBB32ri8 : Ii8<0x83, MRM3r, (outs GR32:$dst),
2676 (ins GR32:$src1, i32i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002677 "sbb{l}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen874ae252009-06-02 03:12:52 +00002678 [(set GR32:$dst, (sube GR32:$src1, i32immSExt8:$src2))]>;
Evan Cheng3154cb62007-10-05 17:59:57 +00002679} // Uses = [EFLAGS]
Evan Cheng24f2ea32007-09-14 21:48:26 +00002680} // Defs = [EFLAGS]
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00002681
Evan Cheng24f2ea32007-09-14 21:48:26 +00002682let Defs = [EFLAGS] in {
Chris Lattner10197ff2005-01-03 01:27:59 +00002683let isCommutable = 1 in { // X = IMUL Y, Z --> X = IMUL Z, Y
Bill Wendlingd350e022008-12-12 21:15:41 +00002684// Register-Register Signed Integer Multiply
Bill Wendlingab55ebd2008-12-12 00:56:36 +00002685def IMUL16rr : I<0xAF, MRMSrcReg, (outs GR16:$dst), (ins GR16:$src1,GR16:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002686 "imul{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingd350e022008-12-12 21:15:41 +00002687 [(set GR16:$dst, (mul GR16:$src1, GR16:$src2)),
2688 (implicit EFLAGS)]>, TB, OpSize;
Bill Wendlingab55ebd2008-12-12 00:56:36 +00002689def IMUL32rr : I<0xAF, MRMSrcReg, (outs GR32:$dst), (ins GR32:$src1,GR32:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002690 "imul{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingd350e022008-12-12 21:15:41 +00002691 [(set GR32:$dst, (mul GR32:$src1, GR32:$src2)),
2692 (implicit EFLAGS)]>, TB;
Chris Lattner10197ff2005-01-03 01:27:59 +00002693}
Bill Wendlingab55ebd2008-12-12 00:56:36 +00002694
Bill Wendlingd350e022008-12-12 21:15:41 +00002695// Register-Memory Signed Integer Multiply
Bill Wendlingab55ebd2008-12-12 00:56:36 +00002696def IMUL16rm : I<0xAF, MRMSrcMem, (outs GR16:$dst),
2697 (ins GR16:$src1, i16mem:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002698 "imul{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingd350e022008-12-12 21:15:41 +00002699 [(set GR16:$dst, (mul GR16:$src1, (load addr:$src2))),
2700 (implicit EFLAGS)]>, TB, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00002701def IMUL32rm : I<0xAF, MRMSrcMem, (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002702 "imul{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingd350e022008-12-12 21:15:41 +00002703 [(set GR32:$dst, (mul GR32:$src1, (load addr:$src2))),
2704 (implicit EFLAGS)]>, TB;
Evan Cheng24f2ea32007-09-14 21:48:26 +00002705} // Defs = [EFLAGS]
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00002706} // end Two Address instructions
2707
Chris Lattnerf5d3a832004-08-11 05:31:07 +00002708// Suprisingly enough, these are not two address instructions!
Evan Cheng24f2ea32007-09-14 21:48:26 +00002709let Defs = [EFLAGS] in {
Bill Wendlingd350e022008-12-12 21:15:41 +00002710// Register-Integer Signed Integer Multiply
Evan Cheng069287d2006-05-16 07:21:53 +00002711def IMUL16rri : Ii16<0x69, MRMSrcReg, // GR16 = GR16*I16
Evan Cheng64d80e32007-07-19 01:14:50 +00002712 (outs GR16:$dst), (ins GR16:$src1, i16imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002713 "imul{w}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Bill Wendlingd350e022008-12-12 21:15:41 +00002714 [(set GR16:$dst, (mul GR16:$src1, imm:$src2)),
2715 (implicit EFLAGS)]>, OpSize;
Evan Cheng069287d2006-05-16 07:21:53 +00002716def IMUL32rri : Ii32<0x69, MRMSrcReg, // GR32 = GR32*I32
Evan Cheng64d80e32007-07-19 01:14:50 +00002717 (outs GR32:$dst), (ins GR32:$src1, i32imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002718 "imul{l}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Bill Wendlingd350e022008-12-12 21:15:41 +00002719 [(set GR32:$dst, (mul GR32:$src1, imm:$src2)),
2720 (implicit EFLAGS)]>;
Evan Cheng069287d2006-05-16 07:21:53 +00002721def IMUL16rri8 : Ii8<0x6B, MRMSrcReg, // GR16 = GR16*I8
Evan Cheng64d80e32007-07-19 01:14:50 +00002722 (outs GR16:$dst), (ins GR16:$src1, i16i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002723 "imul{w}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Bill Wendlingd350e022008-12-12 21:15:41 +00002724 [(set GR16:$dst, (mul GR16:$src1, i16immSExt8:$src2)),
2725 (implicit EFLAGS)]>, OpSize;
Evan Cheng069287d2006-05-16 07:21:53 +00002726def IMUL32rri8 : Ii8<0x6B, MRMSrcReg, // GR32 = GR32*I8
Evan Cheng64d80e32007-07-19 01:14:50 +00002727 (outs GR32:$dst), (ins GR32:$src1, i32i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002728 "imul{l}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Bill Wendlingd350e022008-12-12 21:15:41 +00002729 [(set GR32:$dst, (mul GR32:$src1, i32immSExt8:$src2)),
2730 (implicit EFLAGS)]>;
Chris Lattnerf5d3a832004-08-11 05:31:07 +00002731
Bill Wendlingd350e022008-12-12 21:15:41 +00002732// Memory-Integer Signed Integer Multiply
Evan Cheng069287d2006-05-16 07:21:53 +00002733def IMUL16rmi : Ii16<0x69, MRMSrcMem, // GR16 = [mem16]*I16
Evan Cheng64d80e32007-07-19 01:14:50 +00002734 (outs GR16:$dst), (ins i16mem:$src1, i16imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002735 "imul{w}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Bill Wendlingd350e022008-12-12 21:15:41 +00002736 [(set GR16:$dst, (mul (load addr:$src1), imm:$src2)),
2737 (implicit EFLAGS)]>, OpSize;
Evan Cheng069287d2006-05-16 07:21:53 +00002738def IMUL32rmi : Ii32<0x69, MRMSrcMem, // GR32 = [mem32]*I32
Evan Cheng64d80e32007-07-19 01:14:50 +00002739 (outs GR32:$dst), (ins i32mem:$src1, i32imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002740 "imul{l}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Bill Wendlingd350e022008-12-12 21:15:41 +00002741 [(set GR32:$dst, (mul (load addr:$src1), imm:$src2)),
2742 (implicit EFLAGS)]>;
Evan Cheng069287d2006-05-16 07:21:53 +00002743def IMUL16rmi8 : Ii8<0x6B, MRMSrcMem, // GR16 = [mem16]*I8
Evan Cheng64d80e32007-07-19 01:14:50 +00002744 (outs GR16:$dst), (ins i16mem:$src1, i16i8imm :$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002745 "imul{w}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Bill Wendlingab55ebd2008-12-12 00:56:36 +00002746 [(set GR16:$dst, (mul (load addr:$src1),
Bill Wendlingd350e022008-12-12 21:15:41 +00002747 i16immSExt8:$src2)),
2748 (implicit EFLAGS)]>, OpSize;
Evan Cheng069287d2006-05-16 07:21:53 +00002749def IMUL32rmi8 : Ii8<0x6B, MRMSrcMem, // GR32 = [mem32]*I8
Evan Cheng64d80e32007-07-19 01:14:50 +00002750 (outs GR32:$dst), (ins i32mem:$src1, i32i8imm: $src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002751 "imul{l}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Bill Wendlingab55ebd2008-12-12 00:56:36 +00002752 [(set GR32:$dst, (mul (load addr:$src1),
Bill Wendlingd350e022008-12-12 21:15:41 +00002753 i32immSExt8:$src2)),
2754 (implicit EFLAGS)]>;
Evan Cheng24f2ea32007-09-14 21:48:26 +00002755} // Defs = [EFLAGS]
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00002756
2757//===----------------------------------------------------------------------===//
2758// Test instructions are just like AND, except they don't generate a result.
Chris Lattner3a173df2004-10-03 20:35:00 +00002759//
Evan Cheng0488db92007-09-25 01:57:46 +00002760let Defs = [EFLAGS] in {
Chris Lattnercc65bee2005-01-02 02:35:46 +00002761let isCommutable = 1 in { // TEST X, Y --> TEST Y, X
Evan Cheng64d80e32007-07-19 01:14:50 +00002762def TEST8rr : I<0x84, MRMDestReg, (outs), (ins GR8:$src1, GR8:$src2),
Evan Chenge5f62042007-09-29 00:00:36 +00002763 "test{b}\t{$src2, $src1|$src1, $src2}",
Chris Lattnerce2bcc82008-02-19 17:37:35 +00002764 [(X86cmp (and_su GR8:$src1, GR8:$src2), 0),
Evan Chenge5f62042007-09-29 00:00:36 +00002765 (implicit EFLAGS)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00002766def TEST16rr : I<0x85, MRMDestReg, (outs), (ins GR16:$src1, GR16:$src2),
Evan Chenge5f62042007-09-29 00:00:36 +00002767 "test{w}\t{$src2, $src1|$src1, $src2}",
Chris Lattnerce2bcc82008-02-19 17:37:35 +00002768 [(X86cmp (and_su GR16:$src1, GR16:$src2), 0),
Evan Chenge5f62042007-09-29 00:00:36 +00002769 (implicit EFLAGS)]>,
2770 OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00002771def TEST32rr : I<0x85, MRMDestReg, (outs), (ins GR32:$src1, GR32:$src2),
Evan Chenge5f62042007-09-29 00:00:36 +00002772 "test{l}\t{$src2, $src1|$src1, $src2}",
Chris Lattnerce2bcc82008-02-19 17:37:35 +00002773 [(X86cmp (and_su GR32:$src1, GR32:$src2), 0),
Evan Chenge5f62042007-09-29 00:00:36 +00002774 (implicit EFLAGS)]>;
Chris Lattnercc65bee2005-01-02 02:35:46 +00002775}
Evan Cheng734503b2006-09-11 02:19:56 +00002776
Sean Callanan4a93b712009-09-01 18:14:18 +00002777def TEST8i8 : Ii8<0xA8, RawFrm, (outs), (ins i8imm:$src),
2778 "test{b}\t{$src, %al|%al, $src}", []>;
2779def TEST16i16 : Ii16<0xA9, RawFrm, (outs), (ins i16imm:$src),
2780 "test{w}\t{$src, %ax|%ax, $src}", []>, OpSize;
2781def TEST32i32 : Ii32<0xA9, RawFrm, (outs), (ins i32imm:$src),
2782 "test{l}\t{$src, %eax|%eax, $src}", []>;
2783
Evan Cheng64d80e32007-07-19 01:14:50 +00002784def TEST8rm : I<0x84, MRMSrcMem, (outs), (ins GR8 :$src1, i8mem :$src2),
Evan Chenge5f62042007-09-29 00:00:36 +00002785 "test{b}\t{$src2, $src1|$src1, $src2}",
2786 [(X86cmp (and GR8:$src1, (loadi8 addr:$src2)), 0),
2787 (implicit EFLAGS)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00002788def TEST16rm : I<0x85, MRMSrcMem, (outs), (ins GR16:$src1, i16mem:$src2),
Evan Chenge5f62042007-09-29 00:00:36 +00002789 "test{w}\t{$src2, $src1|$src1, $src2}",
2790 [(X86cmp (and GR16:$src1, (loadi16 addr:$src2)), 0),
2791 (implicit EFLAGS)]>, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00002792def TEST32rm : I<0x85, MRMSrcMem, (outs), (ins GR32:$src1, i32mem:$src2),
Evan Chenge5f62042007-09-29 00:00:36 +00002793 "test{l}\t{$src2, $src1|$src1, $src2}",
2794 [(X86cmp (and GR32:$src1, (loadi32 addr:$src2)), 0),
2795 (implicit EFLAGS)]>;
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00002796
Evan Cheng069287d2006-05-16 07:21:53 +00002797def TEST8ri : Ii8 <0xF6, MRM0r, // flags = GR8 & imm8
Evan Cheng64d80e32007-07-19 01:14:50 +00002798 (outs), (ins GR8:$src1, i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002799 "test{b}\t{$src2, $src1|$src1, $src2}",
Chris Lattnerce2bcc82008-02-19 17:37:35 +00002800 [(X86cmp (and_su GR8:$src1, imm:$src2), 0),
Evan Chenge5f62042007-09-29 00:00:36 +00002801 (implicit EFLAGS)]>;
Evan Cheng069287d2006-05-16 07:21:53 +00002802def TEST16ri : Ii16<0xF7, MRM0r, // flags = GR16 & imm16
Evan Cheng64d80e32007-07-19 01:14:50 +00002803 (outs), (ins GR16:$src1, i16imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002804 "test{w}\t{$src2, $src1|$src1, $src2}",
Chris Lattnerce2bcc82008-02-19 17:37:35 +00002805 [(X86cmp (and_su GR16:$src1, imm:$src2), 0),
Evan Chenge5f62042007-09-29 00:00:36 +00002806 (implicit EFLAGS)]>, OpSize;
Evan Cheng069287d2006-05-16 07:21:53 +00002807def TEST32ri : Ii32<0xF7, MRM0r, // flags = GR32 & imm32
Evan Cheng64d80e32007-07-19 01:14:50 +00002808 (outs), (ins GR32:$src1, i32imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002809 "test{l}\t{$src2, $src1|$src1, $src2}",
Chris Lattnerce2bcc82008-02-19 17:37:35 +00002810 [(X86cmp (and_su GR32:$src1, imm:$src2), 0),
Evan Chenge5f62042007-09-29 00:00:36 +00002811 (implicit EFLAGS)]>;
Evan Cheng734503b2006-09-11 02:19:56 +00002812
Evan Chenge5f62042007-09-29 00:00:36 +00002813def TEST8mi : Ii8 <0xF6, MRM0m, // flags = [mem8] & imm8
Evan Cheng64d80e32007-07-19 01:14:50 +00002814 (outs), (ins i8mem:$src1, i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002815 "test{b}\t{$src2, $src1|$src1, $src2}",
Evan Chenge5f62042007-09-29 00:00:36 +00002816 [(X86cmp (and (loadi8 addr:$src1), imm:$src2), 0),
2817 (implicit EFLAGS)]>;
2818def TEST16mi : Ii16<0xF7, MRM0m, // flags = [mem16] & imm16
Evan Cheng64d80e32007-07-19 01:14:50 +00002819 (outs), (ins i16mem:$src1, i16imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002820 "test{w}\t{$src2, $src1|$src1, $src2}",
Evan Chenge5f62042007-09-29 00:00:36 +00002821 [(X86cmp (and (loadi16 addr:$src1), imm:$src2), 0),
2822 (implicit EFLAGS)]>, OpSize;
2823def TEST32mi : Ii32<0xF7, MRM0m, // flags = [mem32] & imm32
Evan Cheng64d80e32007-07-19 01:14:50 +00002824 (outs), (ins i32mem:$src1, i32imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002825 "test{l}\t{$src2, $src1|$src1, $src2}",
Evan Chenge5f62042007-09-29 00:00:36 +00002826 [(X86cmp (and (loadi32 addr:$src1), imm:$src2), 0),
Evan Cheng0488db92007-09-25 01:57:46 +00002827 (implicit EFLAGS)]>;
2828} // Defs = [EFLAGS]
2829
2830
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00002831// Condition code ops, incl. set if equal/not equal/...
Chris Lattnerba7e7562008-01-10 07:59:24 +00002832let Defs = [EFLAGS], Uses = [AH], neverHasSideEffects = 1 in
Evan Cheng071a2792007-09-11 19:55:27 +00002833def SAHF : I<0x9E, RawFrm, (outs), (ins), "sahf", []>; // flags = AH
Chris Lattnerba7e7562008-01-10 07:59:24 +00002834let Defs = [AH], Uses = [EFLAGS], neverHasSideEffects = 1 in
Evan Cheng071a2792007-09-11 19:55:27 +00002835def LAHF : I<0x9F, RawFrm, (outs), (ins), "lahf", []>; // AH = flags
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00002836
Evan Cheng0488db92007-09-25 01:57:46 +00002837let Uses = [EFLAGS] in {
Chris Lattner3a173df2004-10-03 20:35:00 +00002838def SETEr : I<0x94, MRM0r,
Evan Cheng64d80e32007-07-19 01:14:50 +00002839 (outs GR8 :$dst), (ins),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002840 "sete\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +00002841 [(set GR8:$dst, (X86setcc X86_COND_E, EFLAGS))]>,
Evan Cheng069287d2006-05-16 07:21:53 +00002842 TB; // GR8 = ==
Chris Lattner3a173df2004-10-03 20:35:00 +00002843def SETEm : I<0x94, MRM0m,
Evan Cheng64d80e32007-07-19 01:14:50 +00002844 (outs), (ins i8mem:$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002845 "sete\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +00002846 [(store (X86setcc X86_COND_E, EFLAGS), addr:$dst)]>,
Evan Chengd5781fc2005-12-21 20:21:51 +00002847 TB; // [mem8] = ==
Bill Wendling9f248742008-12-02 00:07:05 +00002848
Chris Lattner3a173df2004-10-03 20:35:00 +00002849def SETNEr : I<0x95, MRM0r,
Evan Cheng64d80e32007-07-19 01:14:50 +00002850 (outs GR8 :$dst), (ins),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002851 "setne\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +00002852 [(set GR8:$dst, (X86setcc X86_COND_NE, EFLAGS))]>,
Evan Cheng069287d2006-05-16 07:21:53 +00002853 TB; // GR8 = !=
Chris Lattner3a173df2004-10-03 20:35:00 +00002854def SETNEm : I<0x95, MRM0m,
Evan Cheng64d80e32007-07-19 01:14:50 +00002855 (outs), (ins i8mem:$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002856 "setne\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +00002857 [(store (X86setcc X86_COND_NE, EFLAGS), addr:$dst)]>,
Evan Chengd5781fc2005-12-21 20:21:51 +00002858 TB; // [mem8] = !=
Bill Wendling9f248742008-12-02 00:07:05 +00002859
Evan Chengd5781fc2005-12-21 20:21:51 +00002860def SETLr : I<0x9C, MRM0r,
Evan Cheng64d80e32007-07-19 01:14:50 +00002861 (outs GR8 :$dst), (ins),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002862 "setl\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +00002863 [(set GR8:$dst, (X86setcc X86_COND_L, EFLAGS))]>,
Evan Cheng069287d2006-05-16 07:21:53 +00002864 TB; // GR8 = < signed
Evan Chengd5781fc2005-12-21 20:21:51 +00002865def SETLm : I<0x9C, MRM0m,
Evan Cheng64d80e32007-07-19 01:14:50 +00002866 (outs), (ins i8mem:$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002867 "setl\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +00002868 [(store (X86setcc X86_COND_L, EFLAGS), addr:$dst)]>,
Evan Chengd5781fc2005-12-21 20:21:51 +00002869 TB; // [mem8] = < signed
Bill Wendling9f248742008-12-02 00:07:05 +00002870
Evan Chengd5781fc2005-12-21 20:21:51 +00002871def SETGEr : I<0x9D, MRM0r,
Evan Cheng64d80e32007-07-19 01:14:50 +00002872 (outs GR8 :$dst), (ins),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002873 "setge\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +00002874 [(set GR8:$dst, (X86setcc X86_COND_GE, EFLAGS))]>,
Evan Cheng069287d2006-05-16 07:21:53 +00002875 TB; // GR8 = >= signed
Evan Chengd5781fc2005-12-21 20:21:51 +00002876def SETGEm : I<0x9D, MRM0m,
Evan Cheng64d80e32007-07-19 01:14:50 +00002877 (outs), (ins i8mem:$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002878 "setge\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +00002879 [(store (X86setcc X86_COND_GE, EFLAGS), addr:$dst)]>,
Evan Chengd5781fc2005-12-21 20:21:51 +00002880 TB; // [mem8] = >= signed
Bill Wendling9f248742008-12-02 00:07:05 +00002881
Evan Chengd5781fc2005-12-21 20:21:51 +00002882def SETLEr : I<0x9E, MRM0r,
Evan Cheng64d80e32007-07-19 01:14:50 +00002883 (outs GR8 :$dst), (ins),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002884 "setle\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +00002885 [(set GR8:$dst, (X86setcc X86_COND_LE, EFLAGS))]>,
Evan Cheng069287d2006-05-16 07:21:53 +00002886 TB; // GR8 = <= signed
Evan Chengd5781fc2005-12-21 20:21:51 +00002887def SETLEm : I<0x9E, MRM0m,
Evan Cheng64d80e32007-07-19 01:14:50 +00002888 (outs), (ins i8mem:$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002889 "setle\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +00002890 [(store (X86setcc X86_COND_LE, EFLAGS), addr:$dst)]>,
Evan Chengd5781fc2005-12-21 20:21:51 +00002891 TB; // [mem8] = <= signed
Bill Wendling9f248742008-12-02 00:07:05 +00002892
Evan Chengd5781fc2005-12-21 20:21:51 +00002893def SETGr : I<0x9F, MRM0r,
Evan Cheng64d80e32007-07-19 01:14:50 +00002894 (outs GR8 :$dst), (ins),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002895 "setg\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +00002896 [(set GR8:$dst, (X86setcc X86_COND_G, EFLAGS))]>,
Evan Cheng069287d2006-05-16 07:21:53 +00002897 TB; // GR8 = > signed
Evan Chengd5781fc2005-12-21 20:21:51 +00002898def SETGm : I<0x9F, MRM0m,
Evan Cheng64d80e32007-07-19 01:14:50 +00002899 (outs), (ins i8mem:$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002900 "setg\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +00002901 [(store (X86setcc X86_COND_G, EFLAGS), addr:$dst)]>,
Evan Chengd5781fc2005-12-21 20:21:51 +00002902 TB; // [mem8] = > signed
2903
2904def SETBr : I<0x92, MRM0r,
Evan Cheng64d80e32007-07-19 01:14:50 +00002905 (outs GR8 :$dst), (ins),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002906 "setb\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +00002907 [(set GR8:$dst, (X86setcc X86_COND_B, EFLAGS))]>,
Evan Cheng069287d2006-05-16 07:21:53 +00002908 TB; // GR8 = < unsign
Evan Chengd5781fc2005-12-21 20:21:51 +00002909def SETBm : I<0x92, MRM0m,
Evan Cheng64d80e32007-07-19 01:14:50 +00002910 (outs), (ins i8mem:$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002911 "setb\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +00002912 [(store (X86setcc X86_COND_B, EFLAGS), addr:$dst)]>,
Evan Chengd5781fc2005-12-21 20:21:51 +00002913 TB; // [mem8] = < unsign
Bill Wendling9f248742008-12-02 00:07:05 +00002914
Evan Chengd5781fc2005-12-21 20:21:51 +00002915def SETAEr : I<0x93, MRM0r,
Evan Cheng64d80e32007-07-19 01:14:50 +00002916 (outs GR8 :$dst), (ins),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002917 "setae\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +00002918 [(set GR8:$dst, (X86setcc X86_COND_AE, EFLAGS))]>,
Evan Cheng069287d2006-05-16 07:21:53 +00002919 TB; // GR8 = >= unsign
Evan Chengd5781fc2005-12-21 20:21:51 +00002920def SETAEm : I<0x93, MRM0m,
Evan Cheng64d80e32007-07-19 01:14:50 +00002921 (outs), (ins i8mem:$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002922 "setae\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +00002923 [(store (X86setcc X86_COND_AE, EFLAGS), addr:$dst)]>,
Evan Chengd5781fc2005-12-21 20:21:51 +00002924 TB; // [mem8] = >= unsign
Bill Wendling9f248742008-12-02 00:07:05 +00002925
Chris Lattner3a173df2004-10-03 20:35:00 +00002926def SETBEr : I<0x96, MRM0r,
Evan Cheng64d80e32007-07-19 01:14:50 +00002927 (outs GR8 :$dst), (ins),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002928 "setbe\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +00002929 [(set GR8:$dst, (X86setcc X86_COND_BE, EFLAGS))]>,
Evan Cheng069287d2006-05-16 07:21:53 +00002930 TB; // GR8 = <= unsign
Chris Lattner3a173df2004-10-03 20:35:00 +00002931def SETBEm : I<0x96, MRM0m,
Evan Cheng64d80e32007-07-19 01:14:50 +00002932 (outs), (ins i8mem:$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002933 "setbe\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +00002934 [(store (X86setcc X86_COND_BE, EFLAGS), addr:$dst)]>,
Evan Chengd5781fc2005-12-21 20:21:51 +00002935 TB; // [mem8] = <= unsign
Bill Wendling9f248742008-12-02 00:07:05 +00002936
Chris Lattner3a173df2004-10-03 20:35:00 +00002937def SETAr : I<0x97, MRM0r,
Evan Cheng64d80e32007-07-19 01:14:50 +00002938 (outs GR8 :$dst), (ins),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002939 "seta\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +00002940 [(set GR8:$dst, (X86setcc X86_COND_A, EFLAGS))]>,
Evan Cheng069287d2006-05-16 07:21:53 +00002941 TB; // GR8 = > signed
Chris Lattner3a173df2004-10-03 20:35:00 +00002942def SETAm : I<0x97, MRM0m,
Evan Cheng64d80e32007-07-19 01:14:50 +00002943 (outs), (ins i8mem:$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002944 "seta\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +00002945 [(store (X86setcc X86_COND_A, EFLAGS), addr:$dst)]>,
Evan Chengd5781fc2005-12-21 20:21:51 +00002946 TB; // [mem8] = > signed
Evan Chengd9558e02006-01-06 00:43:03 +00002947
Chris Lattner3a173df2004-10-03 20:35:00 +00002948def SETSr : I<0x98, MRM0r,
Evan Cheng64d80e32007-07-19 01:14:50 +00002949 (outs GR8 :$dst), (ins),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002950 "sets\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +00002951 [(set GR8:$dst, (X86setcc X86_COND_S, EFLAGS))]>,
Evan Cheng069287d2006-05-16 07:21:53 +00002952 TB; // GR8 = <sign bit>
Chris Lattner3a173df2004-10-03 20:35:00 +00002953def SETSm : I<0x98, MRM0m,
Evan Cheng64d80e32007-07-19 01:14:50 +00002954 (outs), (ins i8mem:$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002955 "sets\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +00002956 [(store (X86setcc X86_COND_S, EFLAGS), addr:$dst)]>,
Evan Chengd9558e02006-01-06 00:43:03 +00002957 TB; // [mem8] = <sign bit>
Chris Lattner3a173df2004-10-03 20:35:00 +00002958def SETNSr : I<0x99, MRM0r,
Evan Cheng64d80e32007-07-19 01:14:50 +00002959 (outs GR8 :$dst), (ins),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002960 "setns\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +00002961 [(set GR8:$dst, (X86setcc X86_COND_NS, EFLAGS))]>,
Evan Cheng069287d2006-05-16 07:21:53 +00002962 TB; // GR8 = !<sign bit>
Chris Lattner3a173df2004-10-03 20:35:00 +00002963def SETNSm : I<0x99, MRM0m,
Evan Cheng64d80e32007-07-19 01:14:50 +00002964 (outs), (ins i8mem:$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002965 "setns\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +00002966 [(store (X86setcc X86_COND_NS, EFLAGS), addr:$dst)]>,
Evan Chengd9558e02006-01-06 00:43:03 +00002967 TB; // [mem8] = !<sign bit>
Bill Wendling9f248742008-12-02 00:07:05 +00002968
Chris Lattner3a173df2004-10-03 20:35:00 +00002969def SETPr : I<0x9A, MRM0r,
Evan Cheng64d80e32007-07-19 01:14:50 +00002970 (outs GR8 :$dst), (ins),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002971 "setp\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +00002972 [(set GR8:$dst, (X86setcc X86_COND_P, EFLAGS))]>,
Evan Cheng069287d2006-05-16 07:21:53 +00002973 TB; // GR8 = parity
Chris Lattner3a173df2004-10-03 20:35:00 +00002974def SETPm : I<0x9A, MRM0m,
Evan Cheng64d80e32007-07-19 01:14:50 +00002975 (outs), (ins i8mem:$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002976 "setp\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +00002977 [(store (X86setcc X86_COND_P, EFLAGS), addr:$dst)]>,
Evan Chengd9558e02006-01-06 00:43:03 +00002978 TB; // [mem8] = parity
Chris Lattnercc65bee2005-01-02 02:35:46 +00002979def SETNPr : I<0x9B, MRM0r,
Evan Cheng64d80e32007-07-19 01:14:50 +00002980 (outs GR8 :$dst), (ins),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002981 "setnp\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +00002982 [(set GR8:$dst, (X86setcc X86_COND_NP, EFLAGS))]>,
Evan Cheng069287d2006-05-16 07:21:53 +00002983 TB; // GR8 = not parity
Chris Lattnercc65bee2005-01-02 02:35:46 +00002984def SETNPm : I<0x9B, MRM0m,
Evan Cheng64d80e32007-07-19 01:14:50 +00002985 (outs), (ins i8mem:$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002986 "setnp\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +00002987 [(store (X86setcc X86_COND_NP, EFLAGS), addr:$dst)]>,
Evan Chengd9558e02006-01-06 00:43:03 +00002988 TB; // [mem8] = not parity
Bill Wendling9f248742008-12-02 00:07:05 +00002989
2990def SETOr : I<0x90, MRM0r,
2991 (outs GR8 :$dst), (ins),
2992 "seto\t$dst",
2993 [(set GR8:$dst, (X86setcc X86_COND_O, EFLAGS))]>,
2994 TB; // GR8 = overflow
2995def SETOm : I<0x90, MRM0m,
2996 (outs), (ins i8mem:$dst),
2997 "seto\t$dst",
2998 [(store (X86setcc X86_COND_O, EFLAGS), addr:$dst)]>,
2999 TB; // [mem8] = overflow
3000def SETNOr : I<0x91, MRM0r,
3001 (outs GR8 :$dst), (ins),
3002 "setno\t$dst",
3003 [(set GR8:$dst, (X86setcc X86_COND_NO, EFLAGS))]>,
3004 TB; // GR8 = not overflow
3005def SETNOm : I<0x91, MRM0m,
3006 (outs), (ins i8mem:$dst),
3007 "setno\t$dst",
3008 [(store (X86setcc X86_COND_NO, EFLAGS), addr:$dst)]>,
3009 TB; // [mem8] = not overflow
Evan Cheng0488db92007-09-25 01:57:46 +00003010} // Uses = [EFLAGS]
3011
Chris Lattner1cca5e32003-08-03 21:54:21 +00003012
3013// Integer comparisons
Evan Cheng24f2ea32007-09-14 21:48:26 +00003014let Defs = [EFLAGS] in {
Sean Callanana09caa52009-09-02 00:55:49 +00003015def CMP8i8 : Ii8<0x3C, RawFrm, (outs), (ins i8imm:$src),
3016 "cmp{b}\t{$src, %al|%al, $src}", []>;
3017def CMP16i16 : Ii16<0x3D, RawFrm, (outs), (ins i16imm:$src),
3018 "cmp{w}\t{$src, %ax|%ax, $src}", []>, OpSize;
3019def CMP32i32 : Ii32<0x3D, RawFrm, (outs), (ins i32imm:$src),
3020 "cmp{l}\t{$src, %eax|%eax, $src}", []>;
3021
Chris Lattner3a173df2004-10-03 20:35:00 +00003022def CMP8rr : I<0x38, MRMDestReg,
Evan Cheng64d80e32007-07-19 01:14:50 +00003023 (outs), (ins GR8 :$src1, GR8 :$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003024 "cmp{b}\t{$src2, $src1|$src1, $src2}",
Evan Chenge5f62042007-09-29 00:00:36 +00003025 [(X86cmp GR8:$src1, GR8:$src2), (implicit EFLAGS)]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00003026def CMP16rr : I<0x39, MRMDestReg,
Evan Cheng64d80e32007-07-19 01:14:50 +00003027 (outs), (ins GR16:$src1, GR16:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003028 "cmp{w}\t{$src2, $src1|$src1, $src2}",
Evan Chenge5f62042007-09-29 00:00:36 +00003029 [(X86cmp GR16:$src1, GR16:$src2), (implicit EFLAGS)]>, OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00003030def CMP32rr : I<0x39, MRMDestReg,
Evan Cheng64d80e32007-07-19 01:14:50 +00003031 (outs), (ins GR32:$src1, GR32:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003032 "cmp{l}\t{$src2, $src1|$src1, $src2}",
Evan Chenge5f62042007-09-29 00:00:36 +00003033 [(X86cmp GR32:$src1, GR32:$src2), (implicit EFLAGS)]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00003034def CMP8mr : I<0x38, MRMDestMem,
Evan Cheng64d80e32007-07-19 01:14:50 +00003035 (outs), (ins i8mem :$src1, GR8 :$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003036 "cmp{b}\t{$src2, $src1|$src1, $src2}",
Evan Chenge5f62042007-09-29 00:00:36 +00003037 [(X86cmp (loadi8 addr:$src1), GR8:$src2),
3038 (implicit EFLAGS)]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00003039def CMP16mr : I<0x39, MRMDestMem,
Evan Cheng64d80e32007-07-19 01:14:50 +00003040 (outs), (ins i16mem:$src1, GR16:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003041 "cmp{w}\t{$src2, $src1|$src1, $src2}",
Evan Chenge5f62042007-09-29 00:00:36 +00003042 [(X86cmp (loadi16 addr:$src1), GR16:$src2),
3043 (implicit EFLAGS)]>, OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00003044def CMP32mr : I<0x39, MRMDestMem,
Evan Cheng64d80e32007-07-19 01:14:50 +00003045 (outs), (ins i32mem:$src1, GR32:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003046 "cmp{l}\t{$src2, $src1|$src1, $src2}",
Evan Chenge5f62042007-09-29 00:00:36 +00003047 [(X86cmp (loadi32 addr:$src1), GR32:$src2),
3048 (implicit EFLAGS)]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00003049def CMP8rm : I<0x3A, MRMSrcMem,
Evan Cheng64d80e32007-07-19 01:14:50 +00003050 (outs), (ins GR8 :$src1, i8mem :$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003051 "cmp{b}\t{$src2, $src1|$src1, $src2}",
Evan Chenge5f62042007-09-29 00:00:36 +00003052 [(X86cmp GR8:$src1, (loadi8 addr:$src2)),
3053 (implicit EFLAGS)]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00003054def CMP16rm : I<0x3B, MRMSrcMem,
Evan Cheng64d80e32007-07-19 01:14:50 +00003055 (outs), (ins GR16:$src1, i16mem:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003056 "cmp{w}\t{$src2, $src1|$src1, $src2}",
Evan Chenge5f62042007-09-29 00:00:36 +00003057 [(X86cmp GR16:$src1, (loadi16 addr:$src2)),
3058 (implicit EFLAGS)]>, OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00003059def CMP32rm : I<0x3B, MRMSrcMem,
Evan Cheng64d80e32007-07-19 01:14:50 +00003060 (outs), (ins GR32:$src1, i32mem:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003061 "cmp{l}\t{$src2, $src1|$src1, $src2}",
Evan Chenge5f62042007-09-29 00:00:36 +00003062 [(X86cmp GR32:$src1, (loadi32 addr:$src2)),
3063 (implicit EFLAGS)]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00003064def CMP8ri : Ii8<0x80, MRM7r,
Evan Cheng64d80e32007-07-19 01:14:50 +00003065 (outs), (ins GR8:$src1, i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003066 "cmp{b}\t{$src2, $src1|$src1, $src2}",
Evan Chenge5f62042007-09-29 00:00:36 +00003067 [(X86cmp GR8:$src1, imm:$src2), (implicit EFLAGS)]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00003068def CMP16ri : Ii16<0x81, MRM7r,
Evan Cheng64d80e32007-07-19 01:14:50 +00003069 (outs), (ins GR16:$src1, i16imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003070 "cmp{w}\t{$src2, $src1|$src1, $src2}",
Evan Chenge5f62042007-09-29 00:00:36 +00003071 [(X86cmp GR16:$src1, imm:$src2),
3072 (implicit EFLAGS)]>, OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00003073def CMP32ri : Ii32<0x81, MRM7r,
Evan Cheng64d80e32007-07-19 01:14:50 +00003074 (outs), (ins GR32:$src1, i32imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003075 "cmp{l}\t{$src2, $src1|$src1, $src2}",
Evan Chenge5f62042007-09-29 00:00:36 +00003076 [(X86cmp GR32:$src1, imm:$src2), (implicit EFLAGS)]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00003077def CMP8mi : Ii8 <0x80, MRM7m,
Evan Cheng64d80e32007-07-19 01:14:50 +00003078 (outs), (ins i8mem :$src1, i8imm :$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003079 "cmp{b}\t{$src2, $src1|$src1, $src2}",
Evan Chenge5f62042007-09-29 00:00:36 +00003080 [(X86cmp (loadi8 addr:$src1), imm:$src2),
3081 (implicit EFLAGS)]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00003082def CMP16mi : Ii16<0x81, MRM7m,
Evan Cheng64d80e32007-07-19 01:14:50 +00003083 (outs), (ins i16mem:$src1, i16imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003084 "cmp{w}\t{$src2, $src1|$src1, $src2}",
Evan Chenge5f62042007-09-29 00:00:36 +00003085 [(X86cmp (loadi16 addr:$src1), imm:$src2),
3086 (implicit EFLAGS)]>, OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00003087def CMP32mi : Ii32<0x81, MRM7m,
Evan Cheng64d80e32007-07-19 01:14:50 +00003088 (outs), (ins i32mem:$src1, i32imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003089 "cmp{l}\t{$src2, $src1|$src1, $src2}",
Evan Chenge5f62042007-09-29 00:00:36 +00003090 [(X86cmp (loadi32 addr:$src1), imm:$src2),
3091 (implicit EFLAGS)]>;
Chris Lattner29b4dd02006-03-23 16:13:50 +00003092def CMP16ri8 : Ii8<0x83, MRM7r,
Evan Cheng64d80e32007-07-19 01:14:50 +00003093 (outs), (ins GR16:$src1, i16i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003094 "cmp{w}\t{$src2, $src1|$src1, $src2}",
Evan Chenge5f62042007-09-29 00:00:36 +00003095 [(X86cmp GR16:$src1, i16immSExt8:$src2),
3096 (implicit EFLAGS)]>, OpSize;
Chris Lattner29b4dd02006-03-23 16:13:50 +00003097def CMP16mi8 : Ii8<0x83, MRM7m,
Evan Cheng64d80e32007-07-19 01:14:50 +00003098 (outs), (ins i16mem:$src1, i16i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003099 "cmp{w}\t{$src2, $src1|$src1, $src2}",
Evan Chenge5f62042007-09-29 00:00:36 +00003100 [(X86cmp (loadi16 addr:$src1), i16immSExt8:$src2),
3101 (implicit EFLAGS)]>, OpSize;
Chris Lattner29b4dd02006-03-23 16:13:50 +00003102def CMP32mi8 : Ii8<0x83, MRM7m,
Evan Cheng64d80e32007-07-19 01:14:50 +00003103 (outs), (ins i32mem:$src1, i32i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003104 "cmp{l}\t{$src2, $src1|$src1, $src2}",
Evan Chenge5f62042007-09-29 00:00:36 +00003105 [(X86cmp (loadi32 addr:$src1), i32immSExt8:$src2),
3106 (implicit EFLAGS)]>;
Chris Lattner29b4dd02006-03-23 16:13:50 +00003107def CMP32ri8 : Ii8<0x83, MRM7r,
Evan Cheng64d80e32007-07-19 01:14:50 +00003108 (outs), (ins GR32:$src1, i32i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003109 "cmp{l}\t{$src2, $src1|$src1, $src2}",
Evan Chenge5f62042007-09-29 00:00:36 +00003110 [(X86cmp GR32:$src1, i32immSExt8:$src2),
Evan Cheng0488db92007-09-25 01:57:46 +00003111 (implicit EFLAGS)]>;
3112} // Defs = [EFLAGS]
3113
Dan Gohmanc7a37d42008-12-23 22:45:23 +00003114// Bit tests.
Dan Gohmanc7a37d42008-12-23 22:45:23 +00003115// TODO: BTC, BTR, and BTS
3116let Defs = [EFLAGS] in {
Dan Gohman0c89b7e2009-01-13 20:32:45 +00003117def BT16rr : I<0xA3, MRMDestReg, (outs), (ins GR16:$src1, GR16:$src2),
Dan Gohmanc7a37d42008-12-23 22:45:23 +00003118 "bt{w}\t{$src2, $src1|$src1, $src2}",
3119 [(X86bt GR16:$src1, GR16:$src2),
Chris Lattnerf1e9fd52008-12-25 01:32:49 +00003120 (implicit EFLAGS)]>, OpSize, TB;
Dan Gohman0c89b7e2009-01-13 20:32:45 +00003121def BT32rr : I<0xA3, MRMDestReg, (outs), (ins GR32:$src1, GR32:$src2),
Dan Gohmanc7a37d42008-12-23 22:45:23 +00003122 "bt{l}\t{$src2, $src1|$src1, $src2}",
3123 [(X86bt GR32:$src1, GR32:$src2),
Chris Lattnerf1e9fd52008-12-25 01:32:49 +00003124 (implicit EFLAGS)]>, TB;
Dan Gohmanf31408d2009-01-13 23:23:30 +00003125
3126// Unlike with the register+register form, the memory+register form of the
3127// bt instruction does not ignore the high bits of the index. From ISel's
3128// perspective, this is pretty bizarre. Disable these instructions for now.
3129//def BT16mr : I<0xA3, MRMDestMem, (outs), (ins i16mem:$src1, GR16:$src2),
3130// "bt{w}\t{$src2, $src1|$src1, $src2}",
3131// [(X86bt (loadi16 addr:$src1), GR16:$src2),
3132// (implicit EFLAGS)]>, OpSize, TB, Requires<[FastBTMem]>;
3133//def BT32mr : I<0xA3, MRMDestMem, (outs), (ins i32mem:$src1, GR32:$src2),
3134// "bt{l}\t{$src2, $src1|$src1, $src2}",
3135// [(X86bt (loadi32 addr:$src1), GR32:$src2),
3136// (implicit EFLAGS)]>, TB, Requires<[FastBTMem]>;
Dan Gohman4afe15b2009-01-13 20:33:23 +00003137
3138def BT16ri8 : Ii8<0xBA, MRM4r, (outs), (ins GR16:$src1, i16i8imm:$src2),
3139 "bt{w}\t{$src2, $src1|$src1, $src2}",
3140 [(X86bt GR16:$src1, i16immSExt8:$src2),
3141 (implicit EFLAGS)]>, OpSize, TB;
3142def BT32ri8 : Ii8<0xBA, MRM4r, (outs), (ins GR32:$src1, i32i8imm:$src2),
3143 "bt{l}\t{$src2, $src1|$src1, $src2}",
3144 [(X86bt GR32:$src1, i32immSExt8:$src2),
3145 (implicit EFLAGS)]>, TB;
3146// Note that these instructions don't need FastBTMem because that
3147// only applies when the other operand is in a register. When it's
3148// an immediate, bt is still fast.
3149def BT16mi8 : Ii8<0xBA, MRM4m, (outs), (ins i16mem:$src1, i16i8imm:$src2),
3150 "bt{w}\t{$src2, $src1|$src1, $src2}",
3151 [(X86bt (loadi16 addr:$src1), i16immSExt8:$src2),
3152 (implicit EFLAGS)]>, OpSize, TB;
3153def BT32mi8 : Ii8<0xBA, MRM4m, (outs), (ins i32mem:$src1, i32i8imm:$src2),
3154 "bt{l}\t{$src2, $src1|$src1, $src2}",
3155 [(X86bt (loadi32 addr:$src1), i32immSExt8:$src2),
3156 (implicit EFLAGS)]>, TB;
Dan Gohmanc7a37d42008-12-23 22:45:23 +00003157} // Defs = [EFLAGS]
3158
Chris Lattner1cca5e32003-08-03 21:54:21 +00003159// Sign/Zero extenders
Dan Gohman11ba3b12008-07-30 18:09:17 +00003160// Use movsbl intead of movsbw; we don't care about the high 16 bits
3161// of the register here. This has a smaller encoding and avoids a
3162// partial-register update.
Evan Cheng64d80e32007-07-19 01:14:50 +00003163def MOVSX16rr8 : I<0xBE, MRMSrcReg, (outs GR16:$dst), (ins GR8 :$src),
Dan Gohman11ba3b12008-07-30 18:09:17 +00003164 "movs{bl|x}\t{$src, ${dst:subreg32}|${dst:subreg32}, $src}",
3165 [(set GR16:$dst, (sext GR8:$src))]>, TB;
Evan Cheng64d80e32007-07-19 01:14:50 +00003166def MOVSX16rm8 : I<0xBE, MRMSrcMem, (outs GR16:$dst), (ins i8mem :$src),
Dan Gohman11ba3b12008-07-30 18:09:17 +00003167 "movs{bl|x}\t{$src, ${dst:subreg32}|${dst:subreg32}, $src}",
3168 [(set GR16:$dst, (sextloadi16i8 addr:$src))]>, TB;
Evan Cheng64d80e32007-07-19 01:14:50 +00003169def MOVSX32rr8 : I<0xBE, MRMSrcReg, (outs GR32:$dst), (ins GR8 :$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003170 "movs{bl|x}\t{$src, $dst|$dst, $src}",
Evan Cheng069287d2006-05-16 07:21:53 +00003171 [(set GR32:$dst, (sext GR8:$src))]>, TB;
Evan Cheng64d80e32007-07-19 01:14:50 +00003172def MOVSX32rm8 : I<0xBE, MRMSrcMem, (outs GR32:$dst), (ins i8mem :$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003173 "movs{bl|x}\t{$src, $dst|$dst, $src}",
Evan Cheng069287d2006-05-16 07:21:53 +00003174 [(set GR32:$dst, (sextloadi32i8 addr:$src))]>, TB;
Evan Cheng64d80e32007-07-19 01:14:50 +00003175def MOVSX32rr16: I<0xBF, MRMSrcReg, (outs GR32:$dst), (ins GR16:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003176 "movs{wl|x}\t{$src, $dst|$dst, $src}",
Evan Cheng069287d2006-05-16 07:21:53 +00003177 [(set GR32:$dst, (sext GR16:$src))]>, TB;
Evan Cheng64d80e32007-07-19 01:14:50 +00003178def MOVSX32rm16: I<0xBF, MRMSrcMem, (outs GR32:$dst), (ins i16mem:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003179 "movs{wl|x}\t{$src, $dst|$dst, $src}",
Evan Cheng069287d2006-05-16 07:21:53 +00003180 [(set GR32:$dst, (sextloadi32i16 addr:$src))]>, TB;
Alkis Evlogimenosa7be9822004-02-17 09:14:23 +00003181
Dan Gohman11ba3b12008-07-30 18:09:17 +00003182// Use movzbl intead of movzbw; we don't care about the high 16 bits
3183// of the register here. This has a smaller encoding and avoids a
3184// partial-register update.
Evan Cheng64d80e32007-07-19 01:14:50 +00003185def MOVZX16rr8 : I<0xB6, MRMSrcReg, (outs GR16:$dst), (ins GR8 :$src),
Dan Gohman11ba3b12008-07-30 18:09:17 +00003186 "movz{bl|x}\t{$src, ${dst:subreg32}|${dst:subreg32}, $src}",
3187 [(set GR16:$dst, (zext GR8:$src))]>, TB;
Evan Cheng64d80e32007-07-19 01:14:50 +00003188def MOVZX16rm8 : I<0xB6, MRMSrcMem, (outs GR16:$dst), (ins i8mem :$src),
Dan Gohman11ba3b12008-07-30 18:09:17 +00003189 "movz{bl|x}\t{$src, ${dst:subreg32}|${dst:subreg32}, $src}",
3190 [(set GR16:$dst, (zextloadi16i8 addr:$src))]>, TB;
Evan Cheng64d80e32007-07-19 01:14:50 +00003191def MOVZX32rr8 : I<0xB6, MRMSrcReg, (outs GR32:$dst), (ins GR8 :$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003192 "movz{bl|x}\t{$src, $dst|$dst, $src}",
Evan Cheng069287d2006-05-16 07:21:53 +00003193 [(set GR32:$dst, (zext GR8:$src))]>, TB;
Evan Cheng64d80e32007-07-19 01:14:50 +00003194def MOVZX32rm8 : I<0xB6, MRMSrcMem, (outs GR32:$dst), (ins i8mem :$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003195 "movz{bl|x}\t{$src, $dst|$dst, $src}",
Evan Cheng069287d2006-05-16 07:21:53 +00003196 [(set GR32:$dst, (zextloadi32i8 addr:$src))]>, TB;
Evan Cheng64d80e32007-07-19 01:14:50 +00003197def MOVZX32rr16: I<0xB7, MRMSrcReg, (outs GR32:$dst), (ins GR16:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003198 "movz{wl|x}\t{$src, $dst|$dst, $src}",
Evan Cheng069287d2006-05-16 07:21:53 +00003199 [(set GR32:$dst, (zext GR16:$src))]>, TB;
Evan Cheng64d80e32007-07-19 01:14:50 +00003200def MOVZX32rm16: I<0xB7, MRMSrcMem, (outs GR32:$dst), (ins i16mem:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003201 "movz{wl|x}\t{$src, $dst|$dst, $src}",
Evan Cheng069287d2006-05-16 07:21:53 +00003202 [(set GR32:$dst, (zextloadi32i16 addr:$src))]>, TB;
Evan Cheng7a7e8372005-12-14 02:22:27 +00003203
Dan Gohman21e3dfb2009-04-13 16:09:41 +00003204// These are the same as the regular regular MOVZX32rr8 and MOVZX32rm8
3205// except that they use GR32_NOREX for the output operand register class
3206// instead of GR32. This allows them to operate on h registers on x86-64.
3207def MOVZX32_NOREXrr8 : I<0xB6, MRMSrcReg,
3208 (outs GR32_NOREX:$dst), (ins GR8:$src),
3209 "movz{bl|x}\t{$src, $dst|$dst, $src} # NOREX",
3210 []>, TB;
Dan Gohman78e04d42009-04-30 03:11:48 +00003211let mayLoad = 1 in
Dan Gohman21e3dfb2009-04-13 16:09:41 +00003212def MOVZX32_NOREXrm8 : I<0xB6, MRMSrcMem,
3213 (outs GR32_NOREX:$dst), (ins i8mem:$src),
3214 "movz{bl|x}\t{$src, $dst|$dst, $src} # NOREX",
3215 []>, TB;
3216
Chris Lattnerba7e7562008-01-10 07:59:24 +00003217let neverHasSideEffects = 1 in {
3218 let Defs = [AX], Uses = [AL] in
3219 def CBW : I<0x98, RawFrm, (outs), (ins),
3220 "{cbtw|cbw}", []>, OpSize; // AX = signext(AL)
3221 let Defs = [EAX], Uses = [AX] in
3222 def CWDE : I<0x98, RawFrm, (outs), (ins),
3223 "{cwtl|cwde}", []>; // EAX = signext(AX)
Evan Chengf91c1012006-05-31 22:05:11 +00003224
Chris Lattnerba7e7562008-01-10 07:59:24 +00003225 let Defs = [AX,DX], Uses = [AX] in
3226 def CWD : I<0x99, RawFrm, (outs), (ins),
3227 "{cwtd|cwd}", []>, OpSize; // DX:AX = signext(AX)
3228 let Defs = [EAX,EDX], Uses = [EAX] in
3229 def CDQ : I<0x99, RawFrm, (outs), (ins),
3230 "{cltd|cdq}", []>; // EDX:EAX = signext(EAX)
3231}
Evan Cheng747a90d2006-02-21 02:24:38 +00003232
Evan Cheng747a90d2006-02-21 02:24:38 +00003233//===----------------------------------------------------------------------===//
3234// Alias Instructions
3235//===----------------------------------------------------------------------===//
3236
3237// Alias instructions that map movr0 to xor.
3238// FIXME: remove when we can teach regalloc that xor reg, reg is ok.
Daniel Dunbar7417b762009-08-11 22:17:52 +00003239let Defs = [EFLAGS], isReMaterializable = 1, isAsCheapAsAMove = 1,
3240 isCodeGenOnly = 1 in {
Evan Cheng64d80e32007-07-19 01:14:50 +00003241def MOV8r0 : I<0x30, MRMInitReg, (outs GR8 :$dst), (ins),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003242 "xor{b}\t$dst, $dst",
Evan Cheng069287d2006-05-16 07:21:53 +00003243 [(set GR8:$dst, 0)]>;
Dan Gohman11ba3b12008-07-30 18:09:17 +00003244// Use xorl instead of xorw since we don't care about the high 16 bits,
3245// it's smaller, and it avoids a partial-register update.
Evan Cheng64d80e32007-07-19 01:14:50 +00003246def MOV16r0 : I<0x31, MRMInitReg, (outs GR16:$dst), (ins),
Dan Gohman11ba3b12008-07-30 18:09:17 +00003247 "xor{l}\t${dst:subreg32}, ${dst:subreg32}",
3248 [(set GR16:$dst, 0)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00003249def MOV32r0 : I<0x31, MRMInitReg, (outs GR32:$dst), (ins),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003250 "xor{l}\t$dst, $dst",
Evan Cheng069287d2006-05-16 07:21:53 +00003251 [(set GR32:$dst, 0)]>;
Dan Gohman1ab79892007-09-07 21:32:51 +00003252}
Evan Cheng747a90d2006-02-21 02:24:38 +00003253
Evan Cheng510e4782006-01-09 23:10:28 +00003254//===----------------------------------------------------------------------===//
Lauro Ramos Venanciob3a04172007-04-20 21:38:10 +00003255// Thread Local Storage Instructions
3256//
3257
Rafael Espindola15f1b662009-04-24 12:59:40 +00003258// All calls clobber the non-callee saved registers. ESP is marked as
3259// a use to prevent stack-pointer assignments that appear immediately
3260// before calls from potentially appearing dead.
3261let Defs = [EAX, ECX, EDX, FP0, FP1, FP2, FP3, FP4, FP5, FP6, ST0,
3262 MM0, MM1, MM2, MM3, MM4, MM5, MM6, MM7,
3263 XMM0, XMM1, XMM2, XMM3, XMM4, XMM5, XMM6, XMM7,
3264 XMM8, XMM9, XMM10, XMM11, XMM12, XMM13, XMM14, XMM15, EFLAGS],
Chris Lattner5c0b16d2009-06-20 20:38:48 +00003265 Uses = [ESP] in
3266def TLS_addr32 : I<0, Pseudo, (outs), (ins lea32mem:$sym),
3267 "leal\t$sym, %eax; "
Dan Gohman4d47b9b2009-04-27 15:13:28 +00003268 "call\t___tls_get_addr@PLT",
Chris Lattner5c0b16d2009-06-20 20:38:48 +00003269 [(X86tlsaddr tls32addr:$sym)]>,
Rafael Espindola2ee3db32009-04-17 14:35:58 +00003270 Requires<[In32BitMode]>;
Lauro Ramos Venanciob3a04172007-04-20 21:38:10 +00003271
Daniel Dunbar0c420fc2009-08-11 22:24:40 +00003272let AddedComplexity = 5, isCodeGenOnly = 1 in
Nate Begeman51a04372009-01-26 01:24:32 +00003273def GS_MOV32rm : I<0x8B, MRMSrcMem, (outs GR32:$dst), (ins i32mem:$src),
3274 "movl\t%gs:$src, $dst",
3275 [(set GR32:$dst, (gsload addr:$src))]>, SegGS;
3276
Daniel Dunbar0c420fc2009-08-11 22:24:40 +00003277let AddedComplexity = 5, isCodeGenOnly = 1 in
Chris Lattner1777d0c2009-05-05 18:52:19 +00003278def FS_MOV32rm : I<0x8B, MRMSrcMem, (outs GR32:$dst), (ins i32mem:$src),
3279 "movl\t%fs:$src, $dst",
3280 [(set GR32:$dst, (fsload addr:$src))]>, SegFS;
3281
Lauro Ramos Venanciob3a04172007-04-20 21:38:10 +00003282//===----------------------------------------------------------------------===//
Evan Cheng3c992d22006-03-07 02:02:57 +00003283// DWARF Pseudo Instructions
3284//
3285
Evan Cheng64d80e32007-07-19 01:14:50 +00003286def DWARF_LOC : I<0, Pseudo, (outs),
3287 (ins i32imm:$line, i32imm:$col, i32imm:$file),
Chris Lattner226b6082009-07-10 22:34:11 +00003288 ".loc\t$file $line $col",
Evan Cheng3c992d22006-03-07 02:02:57 +00003289 [(dwarf_loc (i32 imm:$line), (i32 imm:$col),
3290 (i32 imm:$file))]>;
3291
Evan Cheng3c992d22006-03-07 02:02:57 +00003292//===----------------------------------------------------------------------===//
Anton Korobeynikov2365f512007-07-14 14:06:15 +00003293// EH Pseudo Instructions
3294//
3295let isTerminator = 1, isReturn = 1, isBarrier = 1,
Daniel Dunbar1ca3a0b2009-08-27 07:58:05 +00003296 hasCtrlDep = 1, isCodeGenOnly = 1 in {
Evan Cheng64d80e32007-07-19 01:14:50 +00003297def EH_RETURN : I<0xC3, RawFrm, (outs), (ins GR32:$addr),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003298 "ret\t#eh_return, addr: $addr",
Anton Korobeynikov2365f512007-07-14 14:06:15 +00003299 [(X86ehret GR32:$addr)]>;
3300
3301}
3302
3303//===----------------------------------------------------------------------===//
Andrew Lenharthab0b9492008-02-21 06:45:13 +00003304// Atomic support
3305//
Andrew Lenharthea7da502008-03-01 13:37:02 +00003306
Evan Chengbb6939d2008-04-19 01:20:30 +00003307// Atomic swap. These are just normal xchg instructions. But since a memory
3308// operand is referenced, the atomicity is ensured.
Dan Gohman165660e2008-08-06 15:52:50 +00003309let Constraints = "$val = $dst" in {
Evan Chengbb6939d2008-04-19 01:20:30 +00003310def XCHG32rm : I<0x87, MRMSrcMem, (outs GR32:$dst), (ins i32mem:$ptr, GR32:$val),
3311 "xchg{l}\t{$val, $ptr|$ptr, $val}",
3312 [(set GR32:$dst, (atomic_swap_32 addr:$ptr, GR32:$val))]>;
3313def XCHG16rm : I<0x87, MRMSrcMem, (outs GR16:$dst), (ins i16mem:$ptr, GR16:$val),
3314 "xchg{w}\t{$val, $ptr|$ptr, $val}",
3315 [(set GR16:$dst, (atomic_swap_16 addr:$ptr, GR16:$val))]>,
3316 OpSize;
3317def XCHG8rm : I<0x86, MRMSrcMem, (outs GR8:$dst), (ins i8mem:$ptr, GR8:$val),
3318 "xchg{b}\t{$val, $ptr|$ptr, $val}",
3319 [(set GR8:$dst, (atomic_swap_8 addr:$ptr, GR8:$val))]>;
3320}
3321
Evan Cheng7e032802008-04-18 20:55:36 +00003322// Atomic compare and swap.
Andrew Lenharth26ed8692008-03-01 21:52:34 +00003323let Defs = [EAX, EFLAGS], Uses = [EAX] in {
Evan Cheng7e032802008-04-18 20:55:36 +00003324def LCMPXCHG32 : I<0xB1, MRMDestMem, (outs), (ins i32mem:$ptr, GR32:$swap),
Dan Gohman4d47b9b2009-04-27 15:13:28 +00003325 "lock\n\t"
3326 "cmpxchg{l}\t{$swap, $ptr|$ptr, $swap}",
Evan Cheng32967d22008-03-04 03:20:06 +00003327 [(X86cas addr:$ptr, GR32:$swap, 4)]>, TB, LOCK;
Andrew Lenharthea7da502008-03-01 13:37:02 +00003328}
Dale Johannesen48c1bc22008-10-02 18:53:47 +00003329let Defs = [EAX, EDX, EFLAGS], Uses = [EAX, EBX, ECX, EDX] in {
Anton Korobeynikovf88a6fa2008-07-22 16:22:48 +00003330def LCMPXCHG8B : I<0xC7, MRM1m, (outs), (ins i32mem:$ptr),
Dan Gohman4d47b9b2009-04-27 15:13:28 +00003331 "lock\n\t"
3332 "cmpxchg8b\t$ptr",
Andrew Lenharthd19189e2008-03-05 01:15:49 +00003333 [(X86cas8 addr:$ptr)]>, TB, LOCK;
3334}
Andrew Lenharth26ed8692008-03-01 21:52:34 +00003335
3336let Defs = [AX, EFLAGS], Uses = [AX] in {
Evan Cheng7e032802008-04-18 20:55:36 +00003337def LCMPXCHG16 : I<0xB1, MRMDestMem, (outs), (ins i16mem:$ptr, GR16:$swap),
Dan Gohman4d47b9b2009-04-27 15:13:28 +00003338 "lock\n\t"
3339 "cmpxchg{w}\t{$swap, $ptr|$ptr, $swap}",
Evan Cheng32967d22008-03-04 03:20:06 +00003340 [(X86cas addr:$ptr, GR16:$swap, 2)]>, TB, OpSize, LOCK;
Andrew Lenharthea7da502008-03-01 13:37:02 +00003341}
Andrew Lenharth26ed8692008-03-01 21:52:34 +00003342let Defs = [AL, EFLAGS], Uses = [AL] in {
Evan Cheng7e032802008-04-18 20:55:36 +00003343def LCMPXCHG8 : I<0xB0, MRMDestMem, (outs), (ins i8mem:$ptr, GR8:$swap),
Dan Gohman4d47b9b2009-04-27 15:13:28 +00003344 "lock\n\t"
3345 "cmpxchg{b}\t{$swap, $ptr|$ptr, $swap}",
Evan Cheng32967d22008-03-04 03:20:06 +00003346 [(X86cas addr:$ptr, GR8:$swap, 1)]>, TB, LOCK;
Andrew Lenharthea7da502008-03-01 13:37:02 +00003347}
3348
Evan Cheng7e032802008-04-18 20:55:36 +00003349// Atomic exchange and add
3350let Constraints = "$val = $dst", Defs = [EFLAGS] in {
3351def LXADD32 : I<0xC1, MRMSrcMem, (outs GR32:$dst), (ins i32mem:$ptr, GR32:$val),
Dan Gohman4d47b9b2009-04-27 15:13:28 +00003352 "lock\n\t"
3353 "xadd{l}\t{$val, $ptr|$ptr, $val}",
Mon P Wang28873102008-06-25 08:15:39 +00003354 [(set GR32:$dst, (atomic_load_add_32 addr:$ptr, GR32:$val))]>,
Evan Cheng7e032802008-04-18 20:55:36 +00003355 TB, LOCK;
3356def LXADD16 : I<0xC1, MRMSrcMem, (outs GR16:$dst), (ins i16mem:$ptr, GR16:$val),
Dan Gohman4d47b9b2009-04-27 15:13:28 +00003357 "lock\n\t"
3358 "xadd{w}\t{$val, $ptr|$ptr, $val}",
Mon P Wang28873102008-06-25 08:15:39 +00003359 [(set GR16:$dst, (atomic_load_add_16 addr:$ptr, GR16:$val))]>,
Evan Cheng7e032802008-04-18 20:55:36 +00003360 TB, OpSize, LOCK;
3361def LXADD8 : I<0xC0, MRMSrcMem, (outs GR8:$dst), (ins i8mem:$ptr, GR8:$val),
Dan Gohman4d47b9b2009-04-27 15:13:28 +00003362 "lock\n\t"
3363 "xadd{b}\t{$val, $ptr|$ptr, $val}",
Mon P Wang28873102008-06-25 08:15:39 +00003364 [(set GR8:$dst, (atomic_load_add_8 addr:$ptr, GR8:$val))]>,
Evan Cheng7e032802008-04-18 20:55:36 +00003365 TB, LOCK;
Andrew Lenharthea7da502008-03-01 13:37:02 +00003366}
3367
Evan Cheng37b73872009-07-30 08:33:02 +00003368// Optimized codegen when the non-memory output is not used.
3369// FIXME: Use normal add / sub instructions and add lock prefix dynamically.
3370def LOCK_ADD8mr : I<0x00, MRMDestMem, (outs), (ins i8mem:$dst, GR8:$src2),
3371 "lock\n\t"
3372 "add{b}\t{$src2, $dst|$dst, $src2}", []>, LOCK;
3373def LOCK_ADD16mr : I<0x01, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
3374 "lock\n\t"
3375 "add{w}\t{$src2, $dst|$dst, $src2}", []>, OpSize, LOCK;
3376def LOCK_ADD32mr : I<0x01, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
3377 "lock\n\t"
3378 "add{l}\t{$src2, $dst|$dst, $src2}", []>, LOCK;
3379def LOCK_ADD8mi : Ii8<0x80, MRM0m, (outs), (ins i8mem :$dst, i8imm :$src2),
3380 "lock\n\t"
3381 "add{b}\t{$src2, $dst|$dst, $src2}", []>, LOCK;
3382def LOCK_ADD16mi : Ii16<0x81, MRM0m, (outs), (ins i16mem:$dst, i16imm:$src2),
3383 "lock\n\t"
3384 "add{w}\t{$src2, $dst|$dst, $src2}", []>, LOCK;
3385def LOCK_ADD32mi : Ii32<0x81, MRM0m, (outs), (ins i32mem:$dst, i32imm:$src2),
3386 "lock\n\t"
3387 "add{l}\t{$src2, $dst|$dst, $src2}", []>, LOCK;
3388def LOCK_ADD16mi8 : Ii8<0x83, MRM0m, (outs), (ins i16mem:$dst, i16i8imm :$src2),
3389 "lock\n\t"
3390 "add{w}\t{$src2, $dst|$dst, $src2}", []>, OpSize, LOCK;
3391def LOCK_ADD32mi8 : Ii8<0x83, MRM0m, (outs), (ins i32mem:$dst, i32i8imm :$src2),
3392 "lock\n\t"
3393 "add{l}\t{$src2, $dst|$dst, $src2}", []>, LOCK;
3394
3395def LOCK_INC8m : I<0xFE, MRM0m, (outs), (ins i8mem :$dst),
3396 "lock\n\t"
3397 "inc{b}\t$dst", []>, LOCK;
3398def LOCK_INC16m : I<0xFF, MRM0m, (outs), (ins i16mem:$dst),
3399 "lock\n\t"
3400 "inc{w}\t$dst", []>, OpSize, LOCK;
3401def LOCK_INC32m : I<0xFF, MRM0m, (outs), (ins i32mem:$dst),
3402 "lock\n\t"
3403 "inc{l}\t$dst", []>, LOCK;
3404
3405def LOCK_SUB8mr : I<0x28, MRMDestMem, (outs), (ins i8mem :$dst, GR8 :$src2),
3406 "lock\n\t"
3407 "sub{b}\t{$src2, $dst|$dst, $src2}", []>, LOCK;
3408def LOCK_SUB16mr : I<0x29, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
3409 "lock\n\t"
3410 "sub{w}\t{$src2, $dst|$dst, $src2}", []>, OpSize, LOCK;
3411def LOCK_SUB32mr : I<0x29, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
3412 "lock\n\t"
3413 "sub{l}\t{$src2, $dst|$dst, $src2}", []>, LOCK;
3414def LOCK_SUB8mi : Ii8<0x80, MRM5m, (outs), (ins i8mem :$dst, i8imm:$src2),
3415 "lock\n\t"
3416 "sub{b}\t{$src2, $dst|$dst, $src2}", []>, LOCK;
3417def LOCK_SUB16mi : Ii16<0x81, MRM5m, (outs), (ins i16mem:$dst, i16imm:$src2),
3418 "lock\n\t"
3419 "sub{w}\t{$src2, $dst|$dst, $src2}", []>, OpSize, LOCK;
3420def LOCK_SUB32mi : Ii32<0x81, MRM5m, (outs), (ins i32mem:$dst, i32imm:$src2),
3421 "lock\n\t"
3422 "sub{l}\t{$src2, $dst|$dst, $src2}", []>, LOCK;
3423def LOCK_SUB16mi8 : Ii8<0x83, MRM5m, (outs), (ins i16mem:$dst, i16i8imm :$src2),
3424 "lock\n\t"
3425 "sub{w}\t{$src2, $dst|$dst, $src2}", []>, OpSize, LOCK;
3426def LOCK_SUB32mi8 : Ii8<0x83, MRM5m, (outs), (ins i32mem:$dst, i32i8imm :$src2),
3427 "lock\n\t"
3428 "sub{l}\t{$src2, $dst|$dst, $src2}", []>, LOCK;
3429
3430def LOCK_DEC8m : I<0xFE, MRM1m, (outs), (ins i8mem :$dst),
3431 "lock\n\t"
3432 "dec{b}\t$dst", []>, LOCK;
3433def LOCK_DEC16m : I<0xFF, MRM1m, (outs), (ins i16mem:$dst),
3434 "lock\n\t"
3435 "dec{w}\t$dst", []>, OpSize, LOCK;
3436def LOCK_DEC32m : I<0xFF, MRM1m, (outs), (ins i32mem:$dst),
3437 "lock\n\t"
3438 "dec{l}\t$dst", []>, LOCK;
3439
Mon P Wang28873102008-06-25 08:15:39 +00003440// Atomic exchange, and, or, xor
Mon P Wang63307c32008-05-05 19:05:59 +00003441let Constraints = "$val = $dst", Defs = [EFLAGS],
3442 usesCustomDAGSchedInserter = 1 in {
Dan Gohman9499b712008-05-12 20:22:45 +00003443def ATOMAND32 : I<0, Pseudo, (outs GR32:$dst),(ins i32mem:$ptr, GR32:$val),
Nick Lewycky6ecf5ce2008-12-07 03:49:52 +00003444 "#ATOMAND32 PSEUDO!",
Dale Johannesene00a8a22008-08-28 02:44:49 +00003445 [(set GR32:$dst, (atomic_load_and_32 addr:$ptr, GR32:$val))]>;
Dan Gohman9499b712008-05-12 20:22:45 +00003446def ATOMOR32 : I<0, Pseudo, (outs GR32:$dst),(ins i32mem:$ptr, GR32:$val),
Nick Lewycky6ecf5ce2008-12-07 03:49:52 +00003447 "#ATOMOR32 PSEUDO!",
Dale Johannesene00a8a22008-08-28 02:44:49 +00003448 [(set GR32:$dst, (atomic_load_or_32 addr:$ptr, GR32:$val))]>;
Dan Gohman9499b712008-05-12 20:22:45 +00003449def ATOMXOR32 : I<0, Pseudo,(outs GR32:$dst),(ins i32mem:$ptr, GR32:$val),
Nick Lewycky6ecf5ce2008-12-07 03:49:52 +00003450 "#ATOMXOR32 PSEUDO!",
Dale Johannesene00a8a22008-08-28 02:44:49 +00003451 [(set GR32:$dst, (atomic_load_xor_32 addr:$ptr, GR32:$val))]>;
Andrew Lenharth507a58a2008-06-14 05:48:15 +00003452def ATOMNAND32 : I<0, Pseudo,(outs GR32:$dst),(ins i32mem:$ptr, GR32:$val),
Nick Lewycky6ecf5ce2008-12-07 03:49:52 +00003453 "#ATOMNAND32 PSEUDO!",
Dale Johannesene00a8a22008-08-28 02:44:49 +00003454 [(set GR32:$dst, (atomic_load_nand_32 addr:$ptr, GR32:$val))]>;
Dan Gohman9499b712008-05-12 20:22:45 +00003455def ATOMMIN32: I<0, Pseudo, (outs GR32:$dst), (ins i32mem:$ptr, GR32:$val),
Nick Lewycky6ecf5ce2008-12-07 03:49:52 +00003456 "#ATOMMIN32 PSEUDO!",
Dale Johannesene00a8a22008-08-28 02:44:49 +00003457 [(set GR32:$dst, (atomic_load_min_32 addr:$ptr, GR32:$val))]>;
Dan Gohman9499b712008-05-12 20:22:45 +00003458def ATOMMAX32: I<0, Pseudo, (outs GR32:$dst),(ins i32mem:$ptr, GR32:$val),
Nick Lewycky6ecf5ce2008-12-07 03:49:52 +00003459 "#ATOMMAX32 PSEUDO!",
Dale Johannesene00a8a22008-08-28 02:44:49 +00003460 [(set GR32:$dst, (atomic_load_max_32 addr:$ptr, GR32:$val))]>;
Dan Gohman9499b712008-05-12 20:22:45 +00003461def ATOMUMIN32: I<0, Pseudo, (outs GR32:$dst),(ins i32mem:$ptr, GR32:$val),
Nick Lewycky6ecf5ce2008-12-07 03:49:52 +00003462 "#ATOMUMIN32 PSEUDO!",
Dale Johannesene00a8a22008-08-28 02:44:49 +00003463 [(set GR32:$dst, (atomic_load_umin_32 addr:$ptr, GR32:$val))]>;
Dan Gohman9499b712008-05-12 20:22:45 +00003464def ATOMUMAX32: I<0, Pseudo, (outs GR32:$dst),(ins i32mem:$ptr, GR32:$val),
Nick Lewycky6ecf5ce2008-12-07 03:49:52 +00003465 "#ATOMUMAX32 PSEUDO!",
Dale Johannesene00a8a22008-08-28 02:44:49 +00003466 [(set GR32:$dst, (atomic_load_umax_32 addr:$ptr, GR32:$val))]>;
Dale Johannesen140be2d2008-08-19 18:47:28 +00003467
3468def ATOMAND16 : I<0, Pseudo, (outs GR16:$dst),(ins i16mem:$ptr, GR16:$val),
Nick Lewycky6ecf5ce2008-12-07 03:49:52 +00003469 "#ATOMAND16 PSEUDO!",
Dale Johannesene00a8a22008-08-28 02:44:49 +00003470 [(set GR16:$dst, (atomic_load_and_16 addr:$ptr, GR16:$val))]>;
Dale Johannesen140be2d2008-08-19 18:47:28 +00003471def ATOMOR16 : I<0, Pseudo, (outs GR16:$dst),(ins i16mem:$ptr, GR16:$val),
Nick Lewycky6ecf5ce2008-12-07 03:49:52 +00003472 "#ATOMOR16 PSEUDO!",
Dale Johannesene00a8a22008-08-28 02:44:49 +00003473 [(set GR16:$dst, (atomic_load_or_16 addr:$ptr, GR16:$val))]>;
Dale Johannesen140be2d2008-08-19 18:47:28 +00003474def ATOMXOR16 : I<0, Pseudo,(outs GR16:$dst),(ins i16mem:$ptr, GR16:$val),
Nick Lewycky6ecf5ce2008-12-07 03:49:52 +00003475 "#ATOMXOR16 PSEUDO!",
Dale Johannesene00a8a22008-08-28 02:44:49 +00003476 [(set GR16:$dst, (atomic_load_xor_16 addr:$ptr, GR16:$val))]>;
Dale Johannesen140be2d2008-08-19 18:47:28 +00003477def ATOMNAND16 : I<0, Pseudo,(outs GR16:$dst),(ins i16mem:$ptr, GR16:$val),
Nick Lewycky6ecf5ce2008-12-07 03:49:52 +00003478 "#ATOMNAND16 PSEUDO!",
Dale Johannesene00a8a22008-08-28 02:44:49 +00003479 [(set GR16:$dst, (atomic_load_nand_16 addr:$ptr, GR16:$val))]>;
Dale Johannesen140be2d2008-08-19 18:47:28 +00003480def ATOMMIN16: I<0, Pseudo, (outs GR16:$dst), (ins i16mem:$ptr, GR16:$val),
Nick Lewycky6ecf5ce2008-12-07 03:49:52 +00003481 "#ATOMMIN16 PSEUDO!",
Dale Johannesene00a8a22008-08-28 02:44:49 +00003482 [(set GR16:$dst, (atomic_load_min_16 addr:$ptr, GR16:$val))]>;
Dale Johannesen140be2d2008-08-19 18:47:28 +00003483def ATOMMAX16: I<0, Pseudo, (outs GR16:$dst),(ins i16mem:$ptr, GR16:$val),
Nick Lewycky6ecf5ce2008-12-07 03:49:52 +00003484 "#ATOMMAX16 PSEUDO!",
Dale Johannesene00a8a22008-08-28 02:44:49 +00003485 [(set GR16:$dst, (atomic_load_max_16 addr:$ptr, GR16:$val))]>;
Dale Johannesen140be2d2008-08-19 18:47:28 +00003486def ATOMUMIN16: I<0, Pseudo, (outs GR16:$dst),(ins i16mem:$ptr, GR16:$val),
Nick Lewycky6ecf5ce2008-12-07 03:49:52 +00003487 "#ATOMUMIN16 PSEUDO!",
Dale Johannesene00a8a22008-08-28 02:44:49 +00003488 [(set GR16:$dst, (atomic_load_umin_16 addr:$ptr, GR16:$val))]>;
Dale Johannesen140be2d2008-08-19 18:47:28 +00003489def ATOMUMAX16: I<0, Pseudo, (outs GR16:$dst),(ins i16mem:$ptr, GR16:$val),
Nick Lewycky6ecf5ce2008-12-07 03:49:52 +00003490 "#ATOMUMAX16 PSEUDO!",
Dale Johannesene00a8a22008-08-28 02:44:49 +00003491 [(set GR16:$dst, (atomic_load_umax_16 addr:$ptr, GR16:$val))]>;
Dale Johannesen140be2d2008-08-19 18:47:28 +00003492
3493def ATOMAND8 : I<0, Pseudo, (outs GR8:$dst),(ins i8mem:$ptr, GR8:$val),
Nick Lewycky6ecf5ce2008-12-07 03:49:52 +00003494 "#ATOMAND8 PSEUDO!",
Dale Johannesene00a8a22008-08-28 02:44:49 +00003495 [(set GR8:$dst, (atomic_load_and_8 addr:$ptr, GR8:$val))]>;
Dale Johannesen140be2d2008-08-19 18:47:28 +00003496def ATOMOR8 : I<0, Pseudo, (outs GR8:$dst),(ins i8mem:$ptr, GR8:$val),
Nick Lewycky6ecf5ce2008-12-07 03:49:52 +00003497 "#ATOMOR8 PSEUDO!",
Dale Johannesene00a8a22008-08-28 02:44:49 +00003498 [(set GR8:$dst, (atomic_load_or_8 addr:$ptr, GR8:$val))]>;
Dale Johannesen140be2d2008-08-19 18:47:28 +00003499def ATOMXOR8 : I<0, Pseudo,(outs GR8:$dst),(ins i8mem:$ptr, GR8:$val),
Nick Lewycky6ecf5ce2008-12-07 03:49:52 +00003500 "#ATOMXOR8 PSEUDO!",
Dale Johannesene00a8a22008-08-28 02:44:49 +00003501 [(set GR8:$dst, (atomic_load_xor_8 addr:$ptr, GR8:$val))]>;
Dale Johannesen140be2d2008-08-19 18:47:28 +00003502def ATOMNAND8 : I<0, Pseudo,(outs GR8:$dst),(ins i8mem:$ptr, GR8:$val),
Nick Lewycky6ecf5ce2008-12-07 03:49:52 +00003503 "#ATOMNAND8 PSEUDO!",
Dale Johannesene00a8a22008-08-28 02:44:49 +00003504 [(set GR8:$dst, (atomic_load_nand_8 addr:$ptr, GR8:$val))]>;
Mon P Wang63307c32008-05-05 19:05:59 +00003505}
3506
Dale Johannesen48c1bc22008-10-02 18:53:47 +00003507let Constraints = "$val1 = $dst1, $val2 = $dst2",
3508 Defs = [EFLAGS, EAX, EBX, ECX, EDX],
3509 Uses = [EAX, EBX, ECX, EDX],
Dale Johannesen1b54c7f2008-10-03 19:41:08 +00003510 mayLoad = 1, mayStore = 1,
Dale Johannesen48c1bc22008-10-02 18:53:47 +00003511 usesCustomDAGSchedInserter = 1 in {
3512def ATOMAND6432 : I<0, Pseudo, (outs GR32:$dst1, GR32:$dst2),
3513 (ins i64mem:$ptr, GR32:$val1, GR32:$val2),
Nick Lewycky6ecf5ce2008-12-07 03:49:52 +00003514 "#ATOMAND6432 PSEUDO!", []>;
Dale Johannesen48c1bc22008-10-02 18:53:47 +00003515def ATOMOR6432 : I<0, Pseudo, (outs GR32:$dst1, GR32:$dst2),
3516 (ins i64mem:$ptr, GR32:$val1, GR32:$val2),
Nick Lewycky6ecf5ce2008-12-07 03:49:52 +00003517 "#ATOMOR6432 PSEUDO!", []>;
Dale Johannesen48c1bc22008-10-02 18:53:47 +00003518def ATOMXOR6432 : I<0, Pseudo, (outs GR32:$dst1, GR32:$dst2),
3519 (ins i64mem:$ptr, GR32:$val1, GR32:$val2),
Nick Lewycky6ecf5ce2008-12-07 03:49:52 +00003520 "#ATOMXOR6432 PSEUDO!", []>;
Dale Johannesen48c1bc22008-10-02 18:53:47 +00003521def ATOMNAND6432 : I<0, Pseudo, (outs GR32:$dst1, GR32:$dst2),
3522 (ins i64mem:$ptr, GR32:$val1, GR32:$val2),
Nick Lewycky6ecf5ce2008-12-07 03:49:52 +00003523 "#ATOMNAND6432 PSEUDO!", []>;
Dale Johannesen48c1bc22008-10-02 18:53:47 +00003524def ATOMADD6432 : I<0, Pseudo, (outs GR32:$dst1, GR32:$dst2),
3525 (ins i64mem:$ptr, GR32:$val1, GR32:$val2),
Nick Lewycky6ecf5ce2008-12-07 03:49:52 +00003526 "#ATOMADD6432 PSEUDO!", []>;
Dale Johannesen48c1bc22008-10-02 18:53:47 +00003527def ATOMSUB6432 : I<0, Pseudo, (outs GR32:$dst1, GR32:$dst2),
3528 (ins i64mem:$ptr, GR32:$val1, GR32:$val2),
Nick Lewycky6ecf5ce2008-12-07 03:49:52 +00003529 "#ATOMSUB6432 PSEUDO!", []>;
Dale Johannesen880ae362008-10-03 22:25:52 +00003530def ATOMSWAP6432 : I<0, Pseudo, (outs GR32:$dst1, GR32:$dst2),
3531 (ins i64mem:$ptr, GR32:$val1, GR32:$val2),
Nick Lewycky6ecf5ce2008-12-07 03:49:52 +00003532 "#ATOMSWAP6432 PSEUDO!", []>;
Dale Johannesen48c1bc22008-10-02 18:53:47 +00003533}
3534
Andrew Lenharthab0b9492008-02-21 06:45:13 +00003535//===----------------------------------------------------------------------===//
Evan Cheng510e4782006-01-09 23:10:28 +00003536// Non-Instruction Patterns
3537//===----------------------------------------------------------------------===//
3538
Bill Wendling056292f2008-09-16 21:48:12 +00003539// ConstantPool GlobalAddress, ExternalSymbol, and JumpTable
Evan Cheng71fb8342006-02-25 10:02:21 +00003540def : Pat<(i32 (X86Wrapper tconstpool :$dst)), (MOV32ri tconstpool :$dst)>;
Nate Begeman37efe672006-04-22 18:53:45 +00003541def : Pat<(i32 (X86Wrapper tjumptable :$dst)), (MOV32ri tjumptable :$dst)>;
Nate Begeman6795ebb2008-04-12 00:47:57 +00003542def : Pat<(i32 (X86Wrapper tglobaltlsaddr:$dst)),(MOV32ri tglobaltlsaddr:$dst)>;
Evan Cheng71fb8342006-02-25 10:02:21 +00003543def : Pat<(i32 (X86Wrapper tglobaladdr :$dst)), (MOV32ri tglobaladdr :$dst)>;
3544def : Pat<(i32 (X86Wrapper texternalsym:$dst)), (MOV32ri texternalsym:$dst)>;
3545
Evan Cheng069287d2006-05-16 07:21:53 +00003546def : Pat<(add GR32:$src1, (X86Wrapper tconstpool:$src2)),
3547 (ADD32ri GR32:$src1, tconstpool:$src2)>;
3548def : Pat<(add GR32:$src1, (X86Wrapper tjumptable:$src2)),
3549 (ADD32ri GR32:$src1, tjumptable:$src2)>;
3550def : Pat<(add GR32:$src1, (X86Wrapper tglobaladdr :$src2)),
3551 (ADD32ri GR32:$src1, tglobaladdr:$src2)>;
3552def : Pat<(add GR32:$src1, (X86Wrapper texternalsym:$src2)),
3553 (ADD32ri GR32:$src1, texternalsym:$src2)>;
Evan Cheng71fb8342006-02-25 10:02:21 +00003554
Evan Chengfc8feb12006-05-19 07:30:36 +00003555def : Pat<(store (i32 (X86Wrapper tglobaladdr:$src)), addr:$dst),
Evan Cheng71fb8342006-02-25 10:02:21 +00003556 (MOV32mi addr:$dst, tglobaladdr:$src)>;
Evan Chengfc8feb12006-05-19 07:30:36 +00003557def : Pat<(store (i32 (X86Wrapper texternalsym:$src)), addr:$dst),
Evan Cheng71fb8342006-02-25 10:02:21 +00003558 (MOV32mi addr:$dst, texternalsym:$src)>;
3559
Evan Cheng510e4782006-01-09 23:10:28 +00003560// Calls
Arnold Schwaighoferc85e1712007-10-11 19:40:01 +00003561// tailcall stuff
Arnold Schwaighoferc85e1712007-10-11 19:40:01 +00003562def : Pat<(X86tcret GR32:$dst, imm:$off),
3563 (TCRETURNri GR32:$dst, imm:$off)>;
3564
3565def : Pat<(X86tcret (i32 tglobaladdr:$dst), imm:$off),
3566 (TCRETURNdi texternalsym:$dst, imm:$off)>;
3567
3568def : Pat<(X86tcret (i32 texternalsym:$dst), imm:$off),
3569 (TCRETURNdi texternalsym:$dst, imm:$off)>;
Evan Chengfea89c12006-04-27 08:40:39 +00003570
Dan Gohmancadb2262009-08-02 16:10:01 +00003571// Normal calls, with various flavors of addresses.
Evan Cheng25ab6902006-09-08 06:48:29 +00003572def : Pat<(X86call (i32 tglobaladdr:$dst)),
Evan Cheng510e4782006-01-09 23:10:28 +00003573 (CALLpcrel32 tglobaladdr:$dst)>;
Evan Cheng25ab6902006-09-08 06:48:29 +00003574def : Pat<(X86call (i32 texternalsym:$dst)),
Evan Cheng8700e142006-01-11 06:09:51 +00003575 (CALLpcrel32 texternalsym:$dst)>;
Evan Chengd7f666a2009-05-20 04:53:57 +00003576def : Pat<(X86call (i32 imm:$dst)),
3577 (CALLpcrel32 imm:$dst)>, Requires<[CallImmAddr]>;
Evan Cheng510e4782006-01-09 23:10:28 +00003578
3579// X86 specific add which produces a flag.
Evan Cheng069287d2006-05-16 07:21:53 +00003580def : Pat<(addc GR32:$src1, GR32:$src2),
3581 (ADD32rr GR32:$src1, GR32:$src2)>;
3582def : Pat<(addc GR32:$src1, (load addr:$src2)),
3583 (ADD32rm GR32:$src1, addr:$src2)>;
3584def : Pat<(addc GR32:$src1, imm:$src2),
3585 (ADD32ri GR32:$src1, imm:$src2)>;
3586def : Pat<(addc GR32:$src1, i32immSExt8:$src2),
3587 (ADD32ri8 GR32:$src1, i32immSExt8:$src2)>;
Evan Cheng510e4782006-01-09 23:10:28 +00003588
Evan Cheng069287d2006-05-16 07:21:53 +00003589def : Pat<(subc GR32:$src1, GR32:$src2),
3590 (SUB32rr GR32:$src1, GR32:$src2)>;
3591def : Pat<(subc GR32:$src1, (load addr:$src2)),
3592 (SUB32rm GR32:$src1, addr:$src2)>;
3593def : Pat<(subc GR32:$src1, imm:$src2),
3594 (SUB32ri GR32:$src1, imm:$src2)>;
3595def : Pat<(subc GR32:$src1, i32immSExt8:$src2),
3596 (SUB32ri8 GR32:$src1, i32immSExt8:$src2)>;
Evan Cheng510e4782006-01-09 23:10:28 +00003597
Chris Lattnerffc0b262006-09-07 20:33:45 +00003598// Comparisons.
3599
3600// TEST R,R is smaller than CMP R,0
Evan Chenge5f62042007-09-29 00:00:36 +00003601def : Pat<(parallel (X86cmp GR8:$src1, 0), (implicit EFLAGS)),
Chris Lattnerffc0b262006-09-07 20:33:45 +00003602 (TEST8rr GR8:$src1, GR8:$src1)>;
Evan Chenge5f62042007-09-29 00:00:36 +00003603def : Pat<(parallel (X86cmp GR16:$src1, 0), (implicit EFLAGS)),
Chris Lattnerffc0b262006-09-07 20:33:45 +00003604 (TEST16rr GR16:$src1, GR16:$src1)>;
Evan Chenge5f62042007-09-29 00:00:36 +00003605def : Pat<(parallel (X86cmp GR32:$src1, 0), (implicit EFLAGS)),
Chris Lattnerffc0b262006-09-07 20:33:45 +00003606 (TEST32rr GR32:$src1, GR32:$src1)>;
3607
Dan Gohmanfbb74862009-01-07 01:00:24 +00003608// Conditional moves with folded loads with operands swapped and conditions
3609// inverted.
3610def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_B, EFLAGS),
3611 (CMOVAE16rm GR16:$src2, addr:$src1)>;
3612def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_B, EFLAGS),
3613 (CMOVAE32rm GR32:$src2, addr:$src1)>;
3614def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_AE, EFLAGS),
3615 (CMOVB16rm GR16:$src2, addr:$src1)>;
3616def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_AE, EFLAGS),
3617 (CMOVB32rm GR32:$src2, addr:$src1)>;
3618def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_E, EFLAGS),
3619 (CMOVNE16rm GR16:$src2, addr:$src1)>;
3620def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_E, EFLAGS),
3621 (CMOVNE32rm GR32:$src2, addr:$src1)>;
3622def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_NE, EFLAGS),
3623 (CMOVE16rm GR16:$src2, addr:$src1)>;
3624def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_NE, EFLAGS),
3625 (CMOVE32rm GR32:$src2, addr:$src1)>;
3626def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_BE, EFLAGS),
3627 (CMOVA16rm GR16:$src2, addr:$src1)>;
3628def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_BE, EFLAGS),
3629 (CMOVA32rm GR32:$src2, addr:$src1)>;
3630def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_A, EFLAGS),
3631 (CMOVBE16rm GR16:$src2, addr:$src1)>;
3632def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_A, EFLAGS),
3633 (CMOVBE32rm GR32:$src2, addr:$src1)>;
3634def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_L, EFLAGS),
3635 (CMOVGE16rm GR16:$src2, addr:$src1)>;
3636def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_L, EFLAGS),
3637 (CMOVGE32rm GR32:$src2, addr:$src1)>;
3638def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_GE, EFLAGS),
3639 (CMOVL16rm GR16:$src2, addr:$src1)>;
3640def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_GE, EFLAGS),
3641 (CMOVL32rm GR32:$src2, addr:$src1)>;
3642def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_LE, EFLAGS),
3643 (CMOVG16rm GR16:$src2, addr:$src1)>;
3644def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_LE, EFLAGS),
3645 (CMOVG32rm GR32:$src2, addr:$src1)>;
3646def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_G, EFLAGS),
3647 (CMOVLE16rm GR16:$src2, addr:$src1)>;
3648def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_G, EFLAGS),
3649 (CMOVLE32rm GR32:$src2, addr:$src1)>;
3650def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_P, EFLAGS),
3651 (CMOVNP16rm GR16:$src2, addr:$src1)>;
3652def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_P, EFLAGS),
3653 (CMOVNP32rm GR32:$src2, addr:$src1)>;
3654def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_NP, EFLAGS),
3655 (CMOVP16rm GR16:$src2, addr:$src1)>;
3656def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_NP, EFLAGS),
3657 (CMOVP32rm GR32:$src2, addr:$src1)>;
3658def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_S, EFLAGS),
3659 (CMOVNS16rm GR16:$src2, addr:$src1)>;
3660def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_S, EFLAGS),
3661 (CMOVNS32rm GR32:$src2, addr:$src1)>;
3662def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_NS, EFLAGS),
3663 (CMOVS16rm GR16:$src2, addr:$src1)>;
3664def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_NS, EFLAGS),
3665 (CMOVS32rm GR32:$src2, addr:$src1)>;
3666def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_O, EFLAGS),
3667 (CMOVNO16rm GR16:$src2, addr:$src1)>;
3668def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_O, EFLAGS),
3669 (CMOVNO32rm GR32:$src2, addr:$src1)>;
3670def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_NO, EFLAGS),
3671 (CMOVO16rm GR16:$src2, addr:$src1)>;
3672def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_NO, EFLAGS),
3673 (CMOVO32rm GR32:$src2, addr:$src1)>;
3674
Duncan Sandsf9c98e62008-01-23 20:39:46 +00003675// zextload bool -> zextload byte
Evan Chenge5d93432006-01-17 07:02:46 +00003676def : Pat<(zextloadi8i1 addr:$src), (MOV8rm addr:$src)>;
Evan Cheng510e4782006-01-09 23:10:28 +00003677def : Pat<(zextloadi16i1 addr:$src), (MOVZX16rm8 addr:$src)>;
3678def : Pat<(zextloadi32i1 addr:$src), (MOVZX32rm8 addr:$src)>;
3679
3680// extload bool -> extload byte
Evan Cheng47137242006-05-05 08:23:07 +00003681def : Pat<(extloadi8i1 addr:$src), (MOV8rm addr:$src)>;
Dan Gohmanaf70e5c2009-08-26 14:59:13 +00003682def : Pat<(extloadi16i1 addr:$src), (MOVZX16rm8 addr:$src)>;
Evan Cheng47137242006-05-05 08:23:07 +00003683def : Pat<(extloadi32i1 addr:$src), (MOVZX32rm8 addr:$src)>;
Dan Gohmanaf70e5c2009-08-26 14:59:13 +00003684def : Pat<(extloadi16i8 addr:$src), (MOVZX16rm8 addr:$src)>;
Evan Cheng47137242006-05-05 08:23:07 +00003685def : Pat<(extloadi32i8 addr:$src), (MOVZX32rm8 addr:$src)>;
3686def : Pat<(extloadi32i16 addr:$src), (MOVZX32rm16 addr:$src)>;
Evan Cheng510e4782006-01-09 23:10:28 +00003687
Dan Gohmanaf70e5c2009-08-26 14:59:13 +00003688// anyext. Define these to do an explicit zero-extend to
3689// avoid partial-register updates.
3690def : Pat<(i16 (anyext GR8 :$src)), (MOVZX16rr8 GR8 :$src)>;
3691def : Pat<(i32 (anyext GR8 :$src)), (MOVZX32rr8 GR8 :$src)>;
3692def : Pat<(i32 (anyext GR16:$src)), (MOVZX32rr16 GR16:$src)>;
Evan Cheng510e4782006-01-09 23:10:28 +00003693
Evan Cheng1314b002007-12-13 00:43:27 +00003694// (and (i32 load), 255) -> (zextload i8)
Evan Chengd47e0b62008-09-29 17:26:18 +00003695def : Pat<(i32 (and (nvloadi32 addr:$src), (i32 255))),
3696 (MOVZX32rm8 addr:$src)>;
3697def : Pat<(i32 (and (nvloadi32 addr:$src), (i32 65535))),
3698 (MOVZX32rm16 addr:$src)>;
Evan Cheng1314b002007-12-13 00:43:27 +00003699
Evan Chengcfa260b2006-01-06 02:31:59 +00003700//===----------------------------------------------------------------------===//
3701// Some peepholes
3702//===----------------------------------------------------------------------===//
3703
Dan Gohman63f97202008-10-17 01:33:43 +00003704// Odd encoding trick: -128 fits into an 8-bit immediate field while
3705// +128 doesn't, so in this special case use a sub instead of an add.
3706def : Pat<(add GR16:$src1, 128),
3707 (SUB16ri8 GR16:$src1, -128)>;
3708def : Pat<(store (add (loadi16 addr:$dst), 128), addr:$dst),
3709 (SUB16mi8 addr:$dst, -128)>;
3710def : Pat<(add GR32:$src1, 128),
3711 (SUB32ri8 GR32:$src1, -128)>;
3712def : Pat<(store (add (loadi32 addr:$dst), 128), addr:$dst),
3713 (SUB32mi8 addr:$dst, -128)>;
3714
Dan Gohman11ba3b12008-07-30 18:09:17 +00003715// r & (2^16-1) ==> movz
3716def : Pat<(and GR32:$src1, 0xffff),
Dan Gohman21e3dfb2009-04-13 16:09:41 +00003717 (MOVZX32rr16 (EXTRACT_SUBREG GR32:$src1, x86_subreg_16bit))>;
Dan Gohman8a1510d2008-08-06 18:27:21 +00003718// r & (2^8-1) ==> movz
3719def : Pat<(and GR32:$src1, 0xff),
Dan Gohman62417622009-04-27 16:33:14 +00003720 (MOVZX32rr8 (EXTRACT_SUBREG (COPY_TO_REGCLASS GR32:$src1, GR32_ABCD),
Dan Gohman21e3dfb2009-04-13 16:09:41 +00003721 x86_subreg_8bit))>,
Dan Gohman8a1510d2008-08-06 18:27:21 +00003722 Requires<[In32BitMode]>;
3723// r & (2^8-1) ==> movz
3724def : Pat<(and GR16:$src1, 0xff),
Dan Gohman62417622009-04-27 16:33:14 +00003725 (MOVZX16rr8 (EXTRACT_SUBREG (COPY_TO_REGCLASS GR16:$src1, GR16_ABCD),
Dan Gohman21e3dfb2009-04-13 16:09:41 +00003726 x86_subreg_8bit))>,
Dan Gohman0bfa1bf2008-08-20 21:27:32 +00003727 Requires<[In32BitMode]>;
3728
3729// sext_inreg patterns
3730def : Pat<(sext_inreg GR32:$src, i16),
Dan Gohman21e3dfb2009-04-13 16:09:41 +00003731 (MOVSX32rr16 (EXTRACT_SUBREG GR32:$src, x86_subreg_16bit))>;
Dan Gohman0bfa1bf2008-08-20 21:27:32 +00003732def : Pat<(sext_inreg GR32:$src, i8),
Dan Gohman62417622009-04-27 16:33:14 +00003733 (MOVSX32rr8 (EXTRACT_SUBREG (COPY_TO_REGCLASS GR32:$src, GR32_ABCD),
Dan Gohman21e3dfb2009-04-13 16:09:41 +00003734 x86_subreg_8bit))>,
Dan Gohman0bfa1bf2008-08-20 21:27:32 +00003735 Requires<[In32BitMode]>;
3736def : Pat<(sext_inreg GR16:$src, i8),
Dan Gohman62417622009-04-27 16:33:14 +00003737 (MOVSX16rr8 (EXTRACT_SUBREG (COPY_TO_REGCLASS GR16:$src, GR16_ABCD),
Dan Gohman21e3dfb2009-04-13 16:09:41 +00003738 x86_subreg_8bit))>,
Dan Gohman0bfa1bf2008-08-20 21:27:32 +00003739 Requires<[In32BitMode]>;
3740
3741// trunc patterns
3742def : Pat<(i16 (trunc GR32:$src)),
Dan Gohman21e3dfb2009-04-13 16:09:41 +00003743 (EXTRACT_SUBREG GR32:$src, x86_subreg_16bit)>;
Dan Gohman0bfa1bf2008-08-20 21:27:32 +00003744def : Pat<(i8 (trunc GR32:$src)),
Dan Gohman62417622009-04-27 16:33:14 +00003745 (EXTRACT_SUBREG (COPY_TO_REGCLASS GR32:$src, GR32_ABCD),
Dan Gohman21e3dfb2009-04-13 16:09:41 +00003746 x86_subreg_8bit)>,
Dan Gohman0bfa1bf2008-08-20 21:27:32 +00003747 Requires<[In32BitMode]>;
3748def : Pat<(i8 (trunc GR16:$src)),
Dan Gohman62417622009-04-27 16:33:14 +00003749 (EXTRACT_SUBREG (COPY_TO_REGCLASS GR16:$src, GR16_ABCD),
Dan Gohman21e3dfb2009-04-13 16:09:41 +00003750 x86_subreg_8bit)>,
3751 Requires<[In32BitMode]>;
3752
3753// h-register tricks
3754def : Pat<(i8 (trunc (srl_su GR16:$src, (i8 8)))),
Dan Gohman62417622009-04-27 16:33:14 +00003755 (EXTRACT_SUBREG (COPY_TO_REGCLASS GR16:$src, GR16_ABCD),
Dan Gohman21e3dfb2009-04-13 16:09:41 +00003756 x86_subreg_8bit_hi)>,
3757 Requires<[In32BitMode]>;
3758def : Pat<(i8 (trunc (srl_su GR32:$src, (i8 8)))),
Dan Gohman62417622009-04-27 16:33:14 +00003759 (EXTRACT_SUBREG (COPY_TO_REGCLASS GR32:$src, GR32_ABCD),
Dan Gohman21e3dfb2009-04-13 16:09:41 +00003760 x86_subreg_8bit_hi)>,
3761 Requires<[In32BitMode]>;
3762def : Pat<(srl_su GR16:$src, (i8 8)),
3763 (EXTRACT_SUBREG
3764 (MOVZX32rr8
Dan Gohman62417622009-04-27 16:33:14 +00003765 (EXTRACT_SUBREG (COPY_TO_REGCLASS GR16:$src, GR16_ABCD),
Dan Gohman21e3dfb2009-04-13 16:09:41 +00003766 x86_subreg_8bit_hi)),
3767 x86_subreg_16bit)>,
3768 Requires<[In32BitMode]>;
Evan Chengcb219f02009-05-29 01:44:43 +00003769def : Pat<(i32 (zext (srl_su GR16:$src, (i8 8)))),
3770 (MOVZX32rr8 (EXTRACT_SUBREG (COPY_TO_REGCLASS GR16:$src, GR16_ABCD),
3771 x86_subreg_8bit_hi))>,
3772 Requires<[In32BitMode]>;
Dan Gohmanaf70e5c2009-08-26 14:59:13 +00003773def : Pat<(i32 (anyext (srl_su GR16:$src, (i8 8)))),
3774 (MOVZX32rr8 (EXTRACT_SUBREG (COPY_TO_REGCLASS GR16:$src, GR16_ABCD),
3775 x86_subreg_8bit_hi))>,
3776 Requires<[In32BitMode]>;
Dan Gohman21e3dfb2009-04-13 16:09:41 +00003777def : Pat<(and (srl_su GR32:$src, (i8 8)), (i32 255)),
Dan Gohman62417622009-04-27 16:33:14 +00003778 (MOVZX32rr8 (EXTRACT_SUBREG (COPY_TO_REGCLASS GR32:$src, GR32_ABCD),
Dan Gohman21e3dfb2009-04-13 16:09:41 +00003779 x86_subreg_8bit_hi))>,
Dan Gohman8a1510d2008-08-06 18:27:21 +00003780 Requires<[In32BitMode]>;
Dan Gohman11ba3b12008-07-30 18:09:17 +00003781
Evan Chengcfa260b2006-01-06 02:31:59 +00003782// (shl x, 1) ==> (add x, x)
Evan Cheng069287d2006-05-16 07:21:53 +00003783def : Pat<(shl GR8 :$src1, (i8 1)), (ADD8rr GR8 :$src1, GR8 :$src1)>;
3784def : Pat<(shl GR16:$src1, (i8 1)), (ADD16rr GR16:$src1, GR16:$src1)>;
3785def : Pat<(shl GR32:$src1, (i8 1)), (ADD32rr GR32:$src1, GR32:$src1)>;
Evan Cheng68b951a2006-01-19 01:56:29 +00003786
Evan Chengeb9f8922008-08-30 02:03:58 +00003787// (shl x (and y, 31)) ==> (shl x, y)
3788def : Pat<(shl GR8:$src1, (and CL:$amt, 31)),
3789 (SHL8rCL GR8:$src1)>;
3790def : Pat<(shl GR16:$src1, (and CL:$amt, 31)),
3791 (SHL16rCL GR16:$src1)>;
3792def : Pat<(shl GR32:$src1, (and CL:$amt, 31)),
3793 (SHL32rCL GR32:$src1)>;
3794def : Pat<(store (shl (loadi8 addr:$dst), (and CL:$amt, 31)), addr:$dst),
3795 (SHL8mCL addr:$dst)>;
3796def : Pat<(store (shl (loadi16 addr:$dst), (and CL:$amt, 31)), addr:$dst),
3797 (SHL16mCL addr:$dst)>;
3798def : Pat<(store (shl (loadi32 addr:$dst), (and CL:$amt, 31)), addr:$dst),
3799 (SHL32mCL addr:$dst)>;
3800
3801def : Pat<(srl GR8:$src1, (and CL:$amt, 31)),
3802 (SHR8rCL GR8:$src1)>;
3803def : Pat<(srl GR16:$src1, (and CL:$amt, 31)),
3804 (SHR16rCL GR16:$src1)>;
3805def : Pat<(srl GR32:$src1, (and CL:$amt, 31)),
3806 (SHR32rCL GR32:$src1)>;
3807def : Pat<(store (srl (loadi8 addr:$dst), (and CL:$amt, 31)), addr:$dst),
3808 (SHR8mCL addr:$dst)>;
3809def : Pat<(store (srl (loadi16 addr:$dst), (and CL:$amt, 31)), addr:$dst),
3810 (SHR16mCL addr:$dst)>;
3811def : Pat<(store (srl (loadi32 addr:$dst), (and CL:$amt, 31)), addr:$dst),
3812 (SHR32mCL addr:$dst)>;
3813
3814def : Pat<(sra GR8:$src1, (and CL:$amt, 31)),
3815 (SAR8rCL GR8:$src1)>;
3816def : Pat<(sra GR16:$src1, (and CL:$amt, 31)),
3817 (SAR16rCL GR16:$src1)>;
3818def : Pat<(sra GR32:$src1, (and CL:$amt, 31)),
3819 (SAR32rCL GR32:$src1)>;
3820def : Pat<(store (sra (loadi8 addr:$dst), (and CL:$amt, 31)), addr:$dst),
3821 (SAR8mCL addr:$dst)>;
3822def : Pat<(store (sra (loadi16 addr:$dst), (and CL:$amt, 31)), addr:$dst),
3823 (SAR16mCL addr:$dst)>;
3824def : Pat<(store (sra (loadi32 addr:$dst), (and CL:$amt, 31)), addr:$dst),
3825 (SAR32mCL addr:$dst)>;
3826
Evan Cheng956044c2006-01-19 23:26:24 +00003827// (or (x >> c) | (y << (32 - c))) ==> (shrd32 x, y, c)
Evan Cheng069287d2006-05-16 07:21:53 +00003828def : Pat<(or (srl GR32:$src1, CL:$amt),
3829 (shl GR32:$src2, (sub 32, CL:$amt))),
3830 (SHRD32rrCL GR32:$src1, GR32:$src2)>;
Evan Cheng68b951a2006-01-19 01:56:29 +00003831
Evan Cheng21d54432006-01-20 01:13:30 +00003832def : Pat<(store (or (srl (loadi32 addr:$dst), CL:$amt),
Evan Cheng069287d2006-05-16 07:21:53 +00003833 (shl GR32:$src2, (sub 32, CL:$amt))), addr:$dst),
3834 (SHRD32mrCL addr:$dst, GR32:$src2)>;
Evan Cheng21d54432006-01-20 01:13:30 +00003835
Dan Gohman74feef22008-10-17 01:23:35 +00003836def : Pat<(or (srl GR32:$src1, (i8 (trunc ECX:$amt))),
3837 (shl GR32:$src2, (i8 (trunc (sub 32, ECX:$amt))))),
3838 (SHRD32rrCL GR32:$src1, GR32:$src2)>;
3839
3840def : Pat<(store (or (srl (loadi32 addr:$dst), (i8 (trunc ECX:$amt))),
3841 (shl GR32:$src2, (i8 (trunc (sub 32, ECX:$amt))))),
3842 addr:$dst),
3843 (SHRD32mrCL addr:$dst, GR32:$src2)>;
3844
3845def : Pat<(shrd GR32:$src1, (i8 imm:$amt1), GR32:$src2, (i8 imm:$amt2)),
3846 (SHRD32rri8 GR32:$src1, GR32:$src2, (i8 imm:$amt1))>;
3847
3848def : Pat<(store (shrd (loadi32 addr:$dst), (i8 imm:$amt1),
3849 GR32:$src2, (i8 imm:$amt2)), addr:$dst),
3850 (SHRD32mri8 addr:$dst, GR32:$src2, (i8 imm:$amt1))>;
3851
Evan Cheng956044c2006-01-19 23:26:24 +00003852// (or (x << c) | (y >> (32 - c))) ==> (shld32 x, y, c)
Evan Cheng069287d2006-05-16 07:21:53 +00003853def : Pat<(or (shl GR32:$src1, CL:$amt),
3854 (srl GR32:$src2, (sub 32, CL:$amt))),
3855 (SHLD32rrCL GR32:$src1, GR32:$src2)>;
Evan Cheng956044c2006-01-19 23:26:24 +00003856
Evan Cheng21d54432006-01-20 01:13:30 +00003857def : Pat<(store (or (shl (loadi32 addr:$dst), CL:$amt),
Evan Cheng069287d2006-05-16 07:21:53 +00003858 (srl GR32:$src2, (sub 32, CL:$amt))), addr:$dst),
3859 (SHLD32mrCL addr:$dst, GR32:$src2)>;
Evan Cheng21d54432006-01-20 01:13:30 +00003860
Dan Gohman74feef22008-10-17 01:23:35 +00003861def : Pat<(or (shl GR32:$src1, (i8 (trunc ECX:$amt))),
3862 (srl GR32:$src2, (i8 (trunc (sub 32, ECX:$amt))))),
3863 (SHLD32rrCL GR32:$src1, GR32:$src2)>;
3864
3865def : Pat<(store (or (shl (loadi32 addr:$dst), (i8 (trunc ECX:$amt))),
3866 (srl GR32:$src2, (i8 (trunc (sub 32, ECX:$amt))))),
3867 addr:$dst),
3868 (SHLD32mrCL addr:$dst, GR32:$src2)>;
3869
3870def : Pat<(shld GR32:$src1, (i8 imm:$amt1), GR32:$src2, (i8 imm:$amt2)),
3871 (SHLD32rri8 GR32:$src1, GR32:$src2, (i8 imm:$amt1))>;
3872
3873def : Pat<(store (shld (loadi32 addr:$dst), (i8 imm:$amt1),
3874 GR32:$src2, (i8 imm:$amt2)), addr:$dst),
3875 (SHLD32mri8 addr:$dst, GR32:$src2, (i8 imm:$amt1))>;
3876
Evan Cheng956044c2006-01-19 23:26:24 +00003877// (or (x >> c) | (y << (16 - c))) ==> (shrd16 x, y, c)
Evan Cheng069287d2006-05-16 07:21:53 +00003878def : Pat<(or (srl GR16:$src1, CL:$amt),
3879 (shl GR16:$src2, (sub 16, CL:$amt))),
3880 (SHRD16rrCL GR16:$src1, GR16:$src2)>;
Evan Cheng956044c2006-01-19 23:26:24 +00003881
Evan Cheng21d54432006-01-20 01:13:30 +00003882def : Pat<(store (or (srl (loadi16 addr:$dst), CL:$amt),
Evan Cheng069287d2006-05-16 07:21:53 +00003883 (shl GR16:$src2, (sub 16, CL:$amt))), addr:$dst),
3884 (SHRD16mrCL addr:$dst, GR16:$src2)>;
Evan Cheng21d54432006-01-20 01:13:30 +00003885
Dan Gohman74feef22008-10-17 01:23:35 +00003886def : Pat<(or (srl GR16:$src1, (i8 (trunc CX:$amt))),
3887 (shl GR16:$src2, (i8 (trunc (sub 16, CX:$amt))))),
3888 (SHRD16rrCL GR16:$src1, GR16:$src2)>;
3889
3890def : Pat<(store (or (srl (loadi16 addr:$dst), (i8 (trunc CX:$amt))),
3891 (shl GR16:$src2, (i8 (trunc (sub 16, CX:$amt))))),
3892 addr:$dst),
3893 (SHRD16mrCL addr:$dst, GR16:$src2)>;
3894
3895def : Pat<(shrd GR16:$src1, (i8 imm:$amt1), GR16:$src2, (i8 imm:$amt2)),
3896 (SHRD16rri8 GR16:$src1, GR16:$src2, (i8 imm:$amt1))>;
3897
3898def : Pat<(store (shrd (loadi16 addr:$dst), (i8 imm:$amt1),
3899 GR16:$src2, (i8 imm:$amt2)), addr:$dst),
3900 (SHRD16mri8 addr:$dst, GR16:$src2, (i8 imm:$amt1))>;
3901
Evan Cheng956044c2006-01-19 23:26:24 +00003902// (or (x << c) | (y >> (16 - c))) ==> (shld16 x, y, c)
Evan Cheng069287d2006-05-16 07:21:53 +00003903def : Pat<(or (shl GR16:$src1, CL:$amt),
3904 (srl GR16:$src2, (sub 16, CL:$amt))),
3905 (SHLD16rrCL GR16:$src1, GR16:$src2)>;
Evan Cheng21d54432006-01-20 01:13:30 +00003906
3907def : Pat<(store (or (shl (loadi16 addr:$dst), CL:$amt),
Evan Cheng069287d2006-05-16 07:21:53 +00003908 (srl GR16:$src2, (sub 16, CL:$amt))), addr:$dst),
3909 (SHLD16mrCL addr:$dst, GR16:$src2)>;
Evan Cheng4e4c71e2006-02-21 20:00:20 +00003910
Dan Gohman74feef22008-10-17 01:23:35 +00003911def : Pat<(or (shl GR16:$src1, (i8 (trunc CX:$amt))),
3912 (srl GR16:$src2, (i8 (trunc (sub 16, CX:$amt))))),
3913 (SHLD16rrCL GR16:$src1, GR16:$src2)>;
3914
3915def : Pat<(store (or (shl (loadi16 addr:$dst), (i8 (trunc CX:$amt))),
3916 (srl GR16:$src2, (i8 (trunc (sub 16, CX:$amt))))),
3917 addr:$dst),
3918 (SHLD16mrCL addr:$dst, GR16:$src2)>;
3919
3920def : Pat<(shld GR16:$src1, (i8 imm:$amt1), GR16:$src2, (i8 imm:$amt2)),
3921 (SHLD16rri8 GR16:$src1, GR16:$src2, (i8 imm:$amt1))>;
3922
3923def : Pat<(store (shld (loadi16 addr:$dst), (i8 imm:$amt1),
3924 GR16:$src2, (i8 imm:$amt2)), addr:$dst),
3925 (SHLD16mri8 addr:$dst, GR16:$src2, (i8 imm:$amt1))>;
3926
Evan Cheng4e4c71e2006-02-21 20:00:20 +00003927//===----------------------------------------------------------------------===//
Dan Gohman076aee32009-03-04 19:44:21 +00003928// EFLAGS-defining Patterns
Bill Wendlingd350e022008-12-12 21:15:41 +00003929//===----------------------------------------------------------------------===//
3930
Dan Gohman076aee32009-03-04 19:44:21 +00003931// Register-Register Addition with EFLAGS result
3932def : Pat<(parallel (X86add_flag GR8:$src1, GR8:$src2),
Bill Wendlingd350e022008-12-12 21:15:41 +00003933 (implicit EFLAGS)),
3934 (ADD8rr GR8:$src1, GR8:$src2)>;
Dan Gohman076aee32009-03-04 19:44:21 +00003935def : Pat<(parallel (X86add_flag GR16:$src1, GR16:$src2),
Bill Wendlingd350e022008-12-12 21:15:41 +00003936 (implicit EFLAGS)),
3937 (ADD16rr GR16:$src1, GR16:$src2)>;
Dan Gohman076aee32009-03-04 19:44:21 +00003938def : Pat<(parallel (X86add_flag GR32:$src1, GR32:$src2),
Bill Wendlingd350e022008-12-12 21:15:41 +00003939 (implicit EFLAGS)),
3940 (ADD32rr GR32:$src1, GR32:$src2)>;
3941
Dan Gohman076aee32009-03-04 19:44:21 +00003942// Register-Memory Addition with EFLAGS result
3943def : Pat<(parallel (X86add_flag GR8:$src1, (loadi8 addr:$src2)),
Bill Wendlingd350e022008-12-12 21:15:41 +00003944 (implicit EFLAGS)),
3945 (ADD8rm GR8:$src1, addr:$src2)>;
Dan Gohman076aee32009-03-04 19:44:21 +00003946def : Pat<(parallel (X86add_flag GR16:$src1, (loadi16 addr:$src2)),
Bill Wendlingd350e022008-12-12 21:15:41 +00003947 (implicit EFLAGS)),
3948 (ADD16rm GR16:$src1, addr:$src2)>;
Dan Gohman076aee32009-03-04 19:44:21 +00003949def : Pat<(parallel (X86add_flag GR32:$src1, (loadi32 addr:$src2)),
Bill Wendlingd350e022008-12-12 21:15:41 +00003950 (implicit EFLAGS)),
3951 (ADD32rm GR32:$src1, addr:$src2)>;
3952
Dan Gohman076aee32009-03-04 19:44:21 +00003953// Register-Integer Addition with EFLAGS result
3954def : Pat<(parallel (X86add_flag GR8:$src1, imm:$src2),
Bill Wendlingd350e022008-12-12 21:15:41 +00003955 (implicit EFLAGS)),
3956 (ADD8ri GR8:$src1, imm:$src2)>;
Dan Gohman076aee32009-03-04 19:44:21 +00003957def : Pat<(parallel (X86add_flag GR16:$src1, imm:$src2),
Bill Wendlingd350e022008-12-12 21:15:41 +00003958 (implicit EFLAGS)),
3959 (ADD16ri GR16:$src1, imm:$src2)>;
Dan Gohman076aee32009-03-04 19:44:21 +00003960def : Pat<(parallel (X86add_flag GR32:$src1, imm:$src2),
Bill Wendlingd350e022008-12-12 21:15:41 +00003961 (implicit EFLAGS)),
3962 (ADD32ri GR32:$src1, imm:$src2)>;
Dan Gohman076aee32009-03-04 19:44:21 +00003963def : Pat<(parallel (X86add_flag GR16:$src1, i16immSExt8:$src2),
Bill Wendlingd350e022008-12-12 21:15:41 +00003964 (implicit EFLAGS)),
3965 (ADD16ri8 GR16:$src1, i16immSExt8:$src2)>;
Dan Gohman076aee32009-03-04 19:44:21 +00003966def : Pat<(parallel (X86add_flag GR32:$src1, i32immSExt8:$src2),
Bill Wendlingd350e022008-12-12 21:15:41 +00003967 (implicit EFLAGS)),
3968 (ADD32ri8 GR32:$src1, i32immSExt8:$src2)>;
3969
Dan Gohman076aee32009-03-04 19:44:21 +00003970// Memory-Register Addition with EFLAGS result
3971def : Pat<(parallel (store (X86add_flag (loadi8 addr:$dst), GR8:$src2),
Bill Wendlingd350e022008-12-12 21:15:41 +00003972 addr:$dst),
3973 (implicit EFLAGS)),
3974 (ADD8mr addr:$dst, GR8:$src2)>;
Dan Gohman076aee32009-03-04 19:44:21 +00003975def : Pat<(parallel (store (X86add_flag (loadi16 addr:$dst), GR16:$src2),
Bill Wendlingd350e022008-12-12 21:15:41 +00003976 addr:$dst),
3977 (implicit EFLAGS)),
3978 (ADD16mr addr:$dst, GR16:$src2)>;
Dan Gohman076aee32009-03-04 19:44:21 +00003979def : Pat<(parallel (store (X86add_flag (loadi32 addr:$dst), GR32:$src2),
Bill Wendlingd350e022008-12-12 21:15:41 +00003980 addr:$dst),
3981 (implicit EFLAGS)),
3982 (ADD32mr addr:$dst, GR32:$src2)>;
Dale Johannesenca11dae2009-05-18 17:44:15 +00003983
3984// Memory-Integer Addition with EFLAGS result
Dan Gohman076aee32009-03-04 19:44:21 +00003985def : Pat<(parallel (store (X86add_flag (loadi8 addr:$dst), imm:$src2),
Bill Wendlingd350e022008-12-12 21:15:41 +00003986 addr:$dst),
3987 (implicit EFLAGS)),
3988 (ADD8mi addr:$dst, imm:$src2)>;
Dan Gohman076aee32009-03-04 19:44:21 +00003989def : Pat<(parallel (store (X86add_flag (loadi16 addr:$dst), imm:$src2),
Bill Wendlingd350e022008-12-12 21:15:41 +00003990 addr:$dst),
3991 (implicit EFLAGS)),
3992 (ADD16mi addr:$dst, imm:$src2)>;
Dan Gohman076aee32009-03-04 19:44:21 +00003993def : Pat<(parallel (store (X86add_flag (loadi32 addr:$dst), imm:$src2),
Bill Wendlingd350e022008-12-12 21:15:41 +00003994 addr:$dst),
3995 (implicit EFLAGS)),
3996 (ADD32mi addr:$dst, imm:$src2)>;
Dan Gohman076aee32009-03-04 19:44:21 +00003997def : Pat<(parallel (store (X86add_flag (loadi16 addr:$dst), i16immSExt8:$src2),
Bill Wendlingd350e022008-12-12 21:15:41 +00003998 addr:$dst),
3999 (implicit EFLAGS)),
4000 (ADD16mi8 addr:$dst, i16immSExt8:$src2)>;
Dan Gohman076aee32009-03-04 19:44:21 +00004001def : Pat<(parallel (store (X86add_flag (loadi32 addr:$dst), i32immSExt8:$src2),
Bill Wendlingd350e022008-12-12 21:15:41 +00004002 addr:$dst),
4003 (implicit EFLAGS)),
4004 (ADD32mi8 addr:$dst, i32immSExt8:$src2)>;
4005
Dan Gohman076aee32009-03-04 19:44:21 +00004006// Register-Register Subtraction with EFLAGS result
4007def : Pat<(parallel (X86sub_flag GR8:$src1, GR8:$src2),
Bill Wendlingd350e022008-12-12 21:15:41 +00004008 (implicit EFLAGS)),
4009 (SUB8rr GR8:$src1, GR8:$src2)>;
Dan Gohman076aee32009-03-04 19:44:21 +00004010def : Pat<(parallel (X86sub_flag GR16:$src1, GR16:$src2),
Bill Wendlingd350e022008-12-12 21:15:41 +00004011 (implicit EFLAGS)),
4012 (SUB16rr GR16:$src1, GR16:$src2)>;
Dan Gohman076aee32009-03-04 19:44:21 +00004013def : Pat<(parallel (X86sub_flag GR32:$src1, GR32:$src2),
Bill Wendlingd350e022008-12-12 21:15:41 +00004014 (implicit EFLAGS)),
4015 (SUB32rr GR32:$src1, GR32:$src2)>;
4016
Dan Gohman076aee32009-03-04 19:44:21 +00004017// Register-Memory Subtraction with EFLAGS result
4018def : Pat<(parallel (X86sub_flag GR8:$src1, (loadi8 addr:$src2)),
Bill Wendlingd350e022008-12-12 21:15:41 +00004019 (implicit EFLAGS)),
4020 (SUB8rm GR8:$src1, addr:$src2)>;
Dan Gohman076aee32009-03-04 19:44:21 +00004021def : Pat<(parallel (X86sub_flag GR16:$src1, (loadi16 addr:$src2)),
Bill Wendlingd350e022008-12-12 21:15:41 +00004022 (implicit EFLAGS)),
4023 (SUB16rm GR16:$src1, addr:$src2)>;
Dan Gohman076aee32009-03-04 19:44:21 +00004024def : Pat<(parallel (X86sub_flag GR32:$src1, (loadi32 addr:$src2)),
Bill Wendlingd350e022008-12-12 21:15:41 +00004025 (implicit EFLAGS)),
4026 (SUB32rm GR32:$src1, addr:$src2)>;
4027
Dan Gohman076aee32009-03-04 19:44:21 +00004028// Register-Integer Subtraction with EFLAGS result
4029def : Pat<(parallel (X86sub_flag GR8:$src1, imm:$src2),
Bill Wendlingd350e022008-12-12 21:15:41 +00004030 (implicit EFLAGS)),
4031 (SUB8ri GR8:$src1, imm:$src2)>;
Dan Gohman076aee32009-03-04 19:44:21 +00004032def : Pat<(parallel (X86sub_flag GR16:$src1, imm:$src2),
Bill Wendlingd350e022008-12-12 21:15:41 +00004033 (implicit EFLAGS)),
4034 (SUB16ri GR16:$src1, imm:$src2)>;
Dan Gohman076aee32009-03-04 19:44:21 +00004035def : Pat<(parallel (X86sub_flag GR32:$src1, imm:$src2),
Bill Wendlingd350e022008-12-12 21:15:41 +00004036 (implicit EFLAGS)),
4037 (SUB32ri GR32:$src1, imm:$src2)>;
Dan Gohman076aee32009-03-04 19:44:21 +00004038def : Pat<(parallel (X86sub_flag GR16:$src1, i16immSExt8:$src2),
Bill Wendlingd350e022008-12-12 21:15:41 +00004039 (implicit EFLAGS)),
4040 (SUB16ri8 GR16:$src1, i16immSExt8:$src2)>;
Dan Gohman076aee32009-03-04 19:44:21 +00004041def : Pat<(parallel (X86sub_flag GR32:$src1, i32immSExt8:$src2),
Bill Wendlingd350e022008-12-12 21:15:41 +00004042 (implicit EFLAGS)),
4043 (SUB32ri8 GR32:$src1, i32immSExt8:$src2)>;
4044
Dan Gohman076aee32009-03-04 19:44:21 +00004045// Memory-Register Subtraction with EFLAGS result
4046def : Pat<(parallel (store (X86sub_flag (loadi8 addr:$dst), GR8:$src2),
Bill Wendlingd350e022008-12-12 21:15:41 +00004047 addr:$dst),
4048 (implicit EFLAGS)),
4049 (SUB8mr addr:$dst, GR8:$src2)>;
Dan Gohman076aee32009-03-04 19:44:21 +00004050def : Pat<(parallel (store (X86sub_flag (loadi16 addr:$dst), GR16:$src2),
Bill Wendlingd350e022008-12-12 21:15:41 +00004051 addr:$dst),
4052 (implicit EFLAGS)),
4053 (SUB16mr addr:$dst, GR16:$src2)>;
Dan Gohman076aee32009-03-04 19:44:21 +00004054def : Pat<(parallel (store (X86sub_flag (loadi32 addr:$dst), GR32:$src2),
Bill Wendlingd350e022008-12-12 21:15:41 +00004055 addr:$dst),
4056 (implicit EFLAGS)),
4057 (SUB32mr addr:$dst, GR32:$src2)>;
4058
Dan Gohman076aee32009-03-04 19:44:21 +00004059// Memory-Integer Subtraction with EFLAGS result
4060def : Pat<(parallel (store (X86sub_flag (loadi8 addr:$dst), imm:$src2),
Bill Wendlingd350e022008-12-12 21:15:41 +00004061 addr:$dst),
4062 (implicit EFLAGS)),
4063 (SUB8mi addr:$dst, imm:$src2)>;
Dan Gohman076aee32009-03-04 19:44:21 +00004064def : Pat<(parallel (store (X86sub_flag (loadi16 addr:$dst), imm:$src2),
Bill Wendlingd350e022008-12-12 21:15:41 +00004065 addr:$dst),
4066 (implicit EFLAGS)),
4067 (SUB16mi addr:$dst, imm:$src2)>;
Dan Gohman076aee32009-03-04 19:44:21 +00004068def : Pat<(parallel (store (X86sub_flag (loadi32 addr:$dst), imm:$src2),
Bill Wendlingd350e022008-12-12 21:15:41 +00004069 addr:$dst),
4070 (implicit EFLAGS)),
4071 (SUB32mi addr:$dst, imm:$src2)>;
Dan Gohman076aee32009-03-04 19:44:21 +00004072def : Pat<(parallel (store (X86sub_flag (loadi16 addr:$dst), i16immSExt8:$src2),
Bill Wendlingd350e022008-12-12 21:15:41 +00004073 addr:$dst),
4074 (implicit EFLAGS)),
4075 (SUB16mi8 addr:$dst, i16immSExt8:$src2)>;
Dan Gohman076aee32009-03-04 19:44:21 +00004076def : Pat<(parallel (store (X86sub_flag (loadi32 addr:$dst), i32immSExt8:$src2),
Bill Wendlingd350e022008-12-12 21:15:41 +00004077 addr:$dst),
4078 (implicit EFLAGS)),
4079 (SUB32mi8 addr:$dst, i32immSExt8:$src2)>;
4080
4081
Dan Gohman076aee32009-03-04 19:44:21 +00004082// Register-Register Signed Integer Multiply with EFLAGS result
4083def : Pat<(parallel (X86smul_flag GR16:$src1, GR16:$src2),
Bill Wendlingd350e022008-12-12 21:15:41 +00004084 (implicit EFLAGS)),
4085 (IMUL16rr GR16:$src1, GR16:$src2)>;
Dan Gohman076aee32009-03-04 19:44:21 +00004086def : Pat<(parallel (X86smul_flag GR32:$src1, GR32:$src2),
Bill Wendlingd350e022008-12-12 21:15:41 +00004087 (implicit EFLAGS)),
4088 (IMUL32rr GR32:$src1, GR32:$src2)>;
4089
Dan Gohman076aee32009-03-04 19:44:21 +00004090// Register-Memory Signed Integer Multiply with EFLAGS result
4091def : Pat<(parallel (X86smul_flag GR16:$src1, (loadi16 addr:$src2)),
Bill Wendlingd350e022008-12-12 21:15:41 +00004092 (implicit EFLAGS)),
4093 (IMUL16rm GR16:$src1, addr:$src2)>;
Dan Gohman076aee32009-03-04 19:44:21 +00004094def : Pat<(parallel (X86smul_flag GR32:$src1, (loadi32 addr:$src2)),
Bill Wendlingd350e022008-12-12 21:15:41 +00004095 (implicit EFLAGS)),
4096 (IMUL32rm GR32:$src1, addr:$src2)>;
4097
Dan Gohman076aee32009-03-04 19:44:21 +00004098// Register-Integer Signed Integer Multiply with EFLAGS result
4099def : Pat<(parallel (X86smul_flag GR16:$src1, imm:$src2),
Bill Wendlingd350e022008-12-12 21:15:41 +00004100 (implicit EFLAGS)),
4101 (IMUL16rri GR16:$src1, imm:$src2)>;
Dan Gohman076aee32009-03-04 19:44:21 +00004102def : Pat<(parallel (X86smul_flag GR32:$src1, imm:$src2),
Bill Wendlingd350e022008-12-12 21:15:41 +00004103 (implicit EFLAGS)),
4104 (IMUL32rri GR32:$src1, imm:$src2)>;
Dan Gohman076aee32009-03-04 19:44:21 +00004105def : Pat<(parallel (X86smul_flag GR16:$src1, i16immSExt8:$src2),
Bill Wendlingd350e022008-12-12 21:15:41 +00004106 (implicit EFLAGS)),
4107 (IMUL16rri8 GR16:$src1, i16immSExt8:$src2)>;
Dan Gohman076aee32009-03-04 19:44:21 +00004108def : Pat<(parallel (X86smul_flag GR32:$src1, i32immSExt8:$src2),
Bill Wendlingd350e022008-12-12 21:15:41 +00004109 (implicit EFLAGS)),
4110 (IMUL32rri8 GR32:$src1, i32immSExt8:$src2)>;
4111
Dan Gohman076aee32009-03-04 19:44:21 +00004112// Memory-Integer Signed Integer Multiply with EFLAGS result
4113def : Pat<(parallel (X86smul_flag (loadi16 addr:$src1), imm:$src2),
Bill Wendlingd350e022008-12-12 21:15:41 +00004114 (implicit EFLAGS)),
4115 (IMUL16rmi addr:$src1, imm:$src2)>;
Dan Gohman076aee32009-03-04 19:44:21 +00004116def : Pat<(parallel (X86smul_flag (loadi32 addr:$src1), imm:$src2),
Bill Wendlingd350e022008-12-12 21:15:41 +00004117 (implicit EFLAGS)),
4118 (IMUL32rmi addr:$src1, imm:$src2)>;
Dan Gohman076aee32009-03-04 19:44:21 +00004119def : Pat<(parallel (X86smul_flag (loadi16 addr:$src1), i16immSExt8:$src2),
Bill Wendlingd350e022008-12-12 21:15:41 +00004120 (implicit EFLAGS)),
4121 (IMUL16rmi8 addr:$src1, i16immSExt8:$src2)>;
Dan Gohman076aee32009-03-04 19:44:21 +00004122def : Pat<(parallel (X86smul_flag (loadi32 addr:$src1), i32immSExt8:$src2),
Bill Wendlingd350e022008-12-12 21:15:41 +00004123 (implicit EFLAGS)),
4124 (IMUL32rmi8 addr:$src1, i32immSExt8:$src2)>;
4125
Dan Gohman076aee32009-03-04 19:44:21 +00004126// Optimize multiply by 2 with EFLAGS result.
Evan Cheng6a86bd72009-01-27 03:30:42 +00004127let AddedComplexity = 2 in {
Dan Gohman076aee32009-03-04 19:44:21 +00004128def : Pat<(parallel (X86smul_flag GR16:$src1, 2),
Evan Cheng6a86bd72009-01-27 03:30:42 +00004129 (implicit EFLAGS)),
4130 (ADD16rr GR16:$src1, GR16:$src1)>;
4131
Dan Gohman076aee32009-03-04 19:44:21 +00004132def : Pat<(parallel (X86smul_flag GR32:$src1, 2),
Evan Cheng6a86bd72009-01-27 03:30:42 +00004133 (implicit EFLAGS)),
4134 (ADD32rr GR32:$src1, GR32:$src1)>;
4135}
4136
Dan Gohman076aee32009-03-04 19:44:21 +00004137// INC and DEC with EFLAGS result. Note that these do not set CF.
4138def : Pat<(parallel (X86inc_flag GR8:$src), (implicit EFLAGS)),
4139 (INC8r GR8:$src)>;
4140def : Pat<(parallel (store (i8 (X86inc_flag (loadi8 addr:$dst))), addr:$dst),
4141 (implicit EFLAGS)),
4142 (INC8m addr:$dst)>;
4143def : Pat<(parallel (X86dec_flag GR8:$src), (implicit EFLAGS)),
4144 (DEC8r GR8:$src)>;
4145def : Pat<(parallel (store (i8 (X86dec_flag (loadi8 addr:$dst))), addr:$dst),
4146 (implicit EFLAGS)),
4147 (DEC8m addr:$dst)>;
4148
4149def : Pat<(parallel (X86inc_flag GR16:$src), (implicit EFLAGS)),
Dan Gohman1f4af262009-03-05 21:32:23 +00004150 (INC16r GR16:$src)>, Requires<[In32BitMode]>;
Dan Gohman076aee32009-03-04 19:44:21 +00004151def : Pat<(parallel (store (i16 (X86inc_flag (loadi16 addr:$dst))), addr:$dst),
4152 (implicit EFLAGS)),
Dan Gohman1f4af262009-03-05 21:32:23 +00004153 (INC16m addr:$dst)>, Requires<[In32BitMode]>;
Dan Gohman076aee32009-03-04 19:44:21 +00004154def : Pat<(parallel (X86dec_flag GR16:$src), (implicit EFLAGS)),
Dan Gohman1f4af262009-03-05 21:32:23 +00004155 (DEC16r GR16:$src)>, Requires<[In32BitMode]>;
Dan Gohman076aee32009-03-04 19:44:21 +00004156def : Pat<(parallel (store (i16 (X86dec_flag (loadi16 addr:$dst))), addr:$dst),
4157 (implicit EFLAGS)),
Dan Gohman1f4af262009-03-05 21:32:23 +00004158 (DEC16m addr:$dst)>, Requires<[In32BitMode]>;
Dan Gohman076aee32009-03-04 19:44:21 +00004159
4160def : Pat<(parallel (X86inc_flag GR32:$src), (implicit EFLAGS)),
Dan Gohman1f4af262009-03-05 21:32:23 +00004161 (INC32r GR32:$src)>, Requires<[In32BitMode]>;
Dan Gohman076aee32009-03-04 19:44:21 +00004162def : Pat<(parallel (store (i32 (X86inc_flag (loadi32 addr:$dst))), addr:$dst),
4163 (implicit EFLAGS)),
Dan Gohman1f4af262009-03-05 21:32:23 +00004164 (INC32m addr:$dst)>, Requires<[In32BitMode]>;
Dan Gohman076aee32009-03-04 19:44:21 +00004165def : Pat<(parallel (X86dec_flag GR32:$src), (implicit EFLAGS)),
Dan Gohman1f4af262009-03-05 21:32:23 +00004166 (DEC32r GR32:$src)>, Requires<[In32BitMode]>;
Dan Gohman076aee32009-03-04 19:44:21 +00004167def : Pat<(parallel (store (i32 (X86dec_flag (loadi32 addr:$dst))), addr:$dst),
4168 (implicit EFLAGS)),
Dan Gohman1f4af262009-03-05 21:32:23 +00004169 (DEC32m addr:$dst)>, Requires<[In32BitMode]>;
Dan Gohman076aee32009-03-04 19:44:21 +00004170
Bill Wendlingd350e022008-12-12 21:15:41 +00004171//===----------------------------------------------------------------------===//
Evan Cheng4e4c71e2006-02-21 20:00:20 +00004172// Floating Point Stack Support
4173//===----------------------------------------------------------------------===//
4174
4175include "X86InstrFPStack.td"
4176
4177//===----------------------------------------------------------------------===//
Evan Chengc64a1a92007-07-31 08:04:03 +00004178// X86-64 Support
4179//===----------------------------------------------------------------------===//
4180
Chris Lattner36fe6d22008-01-10 05:50:42 +00004181include "X86Instr64bit.td"
Evan Chengc64a1a92007-07-31 08:04:03 +00004182
4183//===----------------------------------------------------------------------===//
Evan Cheng4e4c71e2006-02-21 20:00:20 +00004184// XMM Floating point support (requires SSE / SSE2)
4185//===----------------------------------------------------------------------===//
4186
4187include "X86InstrSSE.td"
Evan Cheng80f54042008-04-25 18:19:54 +00004188
4189//===----------------------------------------------------------------------===//
4190// MMX and XMM Packed Integer support (requires MMX, SSE, and SSE2)
4191//===----------------------------------------------------------------------===//
4192
4193include "X86InstrMMX.td"