blob: 0d762ba357147f2c9d761e5d1393e80963244388 [file] [log] [blame]
Chris Lattner589ad5d2010-03-25 05:44:01 +00001//===----------------------------------------------------------------------===//
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
Chris Lattnere3486a42010-03-19 00:01:11 +000024def SDTX86CmpTest : SDTypeProfile<1, 2, [SDTCisVT<0, i32>, SDTCisSameAs<1, 2>]>;
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.
Chris Lattner74c8d672010-03-24 00:47:47 +000031def SDTUnaryArithWithFlags : SDTypeProfile<2, 1,
32 [SDTCisInt<0>, SDTCisVT<1, i32>]>;
33
Chris Lattner1aec4d72010-03-24 00:49:29 +000034def SDTBinaryArithWithFlags : SDTypeProfile<2, 2,
35 [SDTCisSameAs<0, 2>,
36 SDTCisSameAs<0, 3>,
37 SDTCisInt<0>, SDTCisVT<1, i32>]>;
Evan Chenge5f62042007-09-29 00:00:36 +000038def SDTX86BrCond : SDTypeProfile<0, 3,
Evan Cheng0488db92007-09-25 01:57:46 +000039 [SDTCisVT<0, OtherVT>,
40 SDTCisVT<1, i8>, SDTCisVT<2, i32>]>;
Evan Chengaed7c722005-12-17 01:24:02 +000041
Evan Chenge5f62042007-09-29 00:00:36 +000042def SDTX86SetCC : SDTypeProfile<1, 2,
Evan Cheng0488db92007-09-25 01:57:46 +000043 [SDTCisVT<0, i8>,
44 SDTCisVT<1, i8>, SDTCisVT<2, i32>]>;
Evan Cheng2e489c42009-12-16 00:53:11 +000045def SDTX86SetCC_C : SDTypeProfile<1, 2,
46 [SDTCisInt<0>,
47 SDTCisVT<1, i8>, SDTCisVT<2, i32>]>;
Evan Chengd5781fc2005-12-21 20:21:51 +000048
Andrew Lenharth26ed8692008-03-01 21:52:34 +000049def SDTX86cas : SDTypeProfile<0, 3, [SDTCisPtrTy<0>, SDTCisInt<1>,
50 SDTCisVT<2, i8>]>;
Andrew Lenharthd19189e2008-03-05 01:15:49 +000051def SDTX86cas8 : SDTypeProfile<0, 1, [SDTCisPtrTy<0>]>;
Andrew Lenharth26ed8692008-03-01 21:52:34 +000052
Dale Johannesen48c1bc22008-10-02 18:53:47 +000053def SDTX86atomicBinary : SDTypeProfile<2, 3, [SDTCisInt<0>, SDTCisInt<1>,
54 SDTCisPtrTy<2>, SDTCisInt<3>,SDTCisInt<4>]>;
Chris Lattner447ff682008-03-11 03:23:40 +000055def SDTX86Ret : SDTypeProfile<0, -1, [SDTCisVT<0, i16>]>;
Evan Cheng898101c2005-12-19 23:12:38 +000056
Sean Callanan1c97ceb2009-06-23 23:25:37 +000057def SDT_X86CallSeqStart : SDCallSeqStart<[SDTCisVT<0, i32>]>;
58def SDT_X86CallSeqEnd : SDCallSeqEnd<[SDTCisVT<0, i32>,
59 SDTCisVT<1, i32>]>;
Evan Chenge3413162006-01-09 18:33:28 +000060
Dan Gohmand35121a2008-05-29 19:57:41 +000061def SDT_X86Call : SDTypeProfile<0, -1, [SDTCisVT<0, iPTR>]>;
Evan Chenge3413162006-01-09 18:33:28 +000062
Dan Gohmand6708ea2009-08-15 01:38:56 +000063def SDT_X86VASTART_SAVE_XMM_REGS : SDTypeProfile<0, -1, [SDTCisVT<0, i8>,
64 SDTCisVT<1, iPTR>,
65 SDTCisVT<2, iPTR>]>;
66
Chris Lattnered52c8f2010-03-28 07:38:39 +000067def SDTX86RepStr : SDTypeProfile<0, 1, [SDTCisVT<0, OtherVT>]>;
68
Anton Korobeynikov043f3c22010-03-06 19:32:29 +000069def SDTX86Void : SDTypeProfile<0, 0, []>;
Evan Chengd90eb7f2006-01-05 00:27:02 +000070
Evan Cheng71fb8342006-02-25 10:02:21 +000071def SDTX86Wrapper : SDTypeProfile<1, 1, [SDTCisSameAs<0, 1>, SDTCisPtrTy<0>]>;
72
Rafael Espindola2ee3db32009-04-17 14:35:58 +000073def SDT_X86TLSADDR : SDTypeProfile<0, 1, [SDTCisInt<0>]>;
Lauro Ramos Venanciob3a04172007-04-20 21:38:10 +000074
Rafael Espindola094fad32009-04-08 21:14:34 +000075def SDT_X86SegmentBaseAddress : SDTypeProfile<1, 1, [SDTCisPtrTy<0>]>;
Lauro Ramos Venanciob3a04172007-04-20 21:38:10 +000076
Anton Korobeynikov2365f512007-07-14 14:06:15 +000077def SDT_X86EHRET : SDTypeProfile<0, 1, [SDTCisInt<0>]>;
78
Arnold Schwaighoferc85e1712007-10-11 19:40:01 +000079def SDT_X86TCRET : SDTypeProfile<0, 2, [SDTCisPtrTy<0>, SDTCisVT<1, i32>]>;
80
Chris Lattnerd486d772010-03-28 05:07:17 +000081def X86bsf : SDNode<"X86ISD::BSF", SDTUnaryArithWithFlags>;
82def X86bsr : SDNode<"X86ISD::BSR", SDTUnaryArithWithFlags>;
Evan Chenge3413162006-01-09 18:33:28 +000083def X86shld : SDNode<"X86ISD::SHLD", SDTIntShiftDOp>;
84def X86shrd : SDNode<"X86ISD::SHRD", SDTIntShiftDOp>;
Evan Chengb077b842005-12-21 02:39:21 +000085
Evan Chenge5f62042007-09-29 00:00:36 +000086def X86cmp : SDNode<"X86ISD::CMP" , SDTX86CmpTest>;
Dan Gohmanc7a37d42008-12-23 22:45:23 +000087def X86bt : SDNode<"X86ISD::BT", SDTX86CmpTest>;
88
Evan Chenge5f62042007-09-29 00:00:36 +000089def X86cmov : SDNode<"X86ISD::CMOV", SDTX86Cmov>;
Evan Chenge3413162006-01-09 18:33:28 +000090def X86brcond : SDNode<"X86ISD::BRCOND", SDTX86BrCond,
Evan Cheng0488db92007-09-25 01:57:46 +000091 [SDNPHasChain]>;
Evan Chenge5f62042007-09-29 00:00:36 +000092def X86setcc : SDNode<"X86ISD::SETCC", SDTX86SetCC>;
Evan Cheng2e489c42009-12-16 00:53:11 +000093def X86setcc_c : SDNode<"X86ISD::SETCC_CARRY", SDTX86SetCC_C>;
Evan Chengb077b842005-12-21 02:39:21 +000094
Andrew Lenharth26ed8692008-03-01 21:52:34 +000095def X86cas : SDNode<"X86ISD::LCMPXCHG_DAG", SDTX86cas,
96 [SDNPHasChain, SDNPInFlag, SDNPOutFlag, SDNPMayStore,
97 SDNPMayLoad]>;
Andrew Lenharthd19189e2008-03-05 01:15:49 +000098def X86cas8 : SDNode<"X86ISD::LCMPXCHG8_DAG", SDTX86cas8,
99 [SDNPHasChain, SDNPInFlag, SDNPOutFlag, SDNPMayStore,
100 SDNPMayLoad]>;
Dale Johannesen48c1bc22008-10-02 18:53:47 +0000101def X86AtomAdd64 : SDNode<"X86ISD::ATOMADD64_DAG", SDTX86atomicBinary,
102 [SDNPHasChain, SDNPMayStore,
103 SDNPMayLoad, SDNPMemOperand]>;
104def X86AtomSub64 : SDNode<"X86ISD::ATOMSUB64_DAG", SDTX86atomicBinary,
105 [SDNPHasChain, SDNPMayStore,
106 SDNPMayLoad, SDNPMemOperand]>;
107def X86AtomOr64 : SDNode<"X86ISD::ATOMOR64_DAG", SDTX86atomicBinary,
108 [SDNPHasChain, SDNPMayStore,
109 SDNPMayLoad, SDNPMemOperand]>;
110def X86AtomXor64 : SDNode<"X86ISD::ATOMXOR64_DAG", SDTX86atomicBinary,
111 [SDNPHasChain, SDNPMayStore,
112 SDNPMayLoad, SDNPMemOperand]>;
113def X86AtomAnd64 : SDNode<"X86ISD::ATOMAND64_DAG", SDTX86atomicBinary,
114 [SDNPHasChain, SDNPMayStore,
115 SDNPMayLoad, SDNPMemOperand]>;
116def X86AtomNand64 : SDNode<"X86ISD::ATOMNAND64_DAG", SDTX86atomicBinary,
117 [SDNPHasChain, SDNPMayStore,
118 SDNPMayLoad, SDNPMemOperand]>;
Dale Johannesen880ae362008-10-03 22:25:52 +0000119def X86AtomSwap64 : SDNode<"X86ISD::ATOMSWAP64_DAG", SDTX86atomicBinary,
120 [SDNPHasChain, SDNPMayStore,
121 SDNPMayLoad, SDNPMemOperand]>;
Evan Chenge3413162006-01-09 18:33:28 +0000122def X86retflag : SDNode<"X86ISD::RET_FLAG", SDTX86Ret,
Chris Lattnere8cabf32010-03-19 05:07:09 +0000123 [SDNPHasChain, SDNPOptInFlag, SDNPVariadic]>;
Evan Chengb077b842005-12-21 02:39:21 +0000124
Dan Gohmand6708ea2009-08-15 01:38:56 +0000125def X86vastart_save_xmm_regs :
126 SDNode<"X86ISD::VASTART_SAVE_XMM_REGS",
127 SDT_X86VASTART_SAVE_XMM_REGS,
Chris Lattnere8cabf32010-03-19 05:07:09 +0000128 [SDNPHasChain, SDNPVariadic]>;
Dan Gohmand6708ea2009-08-15 01:38:56 +0000129
Evan Chenge3413162006-01-09 18:33:28 +0000130def X86callseq_start :
131 SDNode<"ISD::CALLSEQ_START", SDT_X86CallSeqStart,
Evan Chengbb7b8442006-08-11 09:03:33 +0000132 [SDNPHasChain, SDNPOutFlag]>;
Evan Chenge3413162006-01-09 18:33:28 +0000133def X86callseq_end :
134 SDNode<"ISD::CALLSEQ_END", SDT_X86CallSeqEnd,
Arnold Schwaighoferc85e1712007-10-11 19:40:01 +0000135 [SDNPHasChain, SDNPOptInFlag, SDNPOutFlag]>;
Evan Chengb077b842005-12-21 02:39:21 +0000136
Evan Chenge3413162006-01-09 18:33:28 +0000137def X86call : SDNode<"X86ISD::CALL", SDT_X86Call,
Chris Lattnere8cabf32010-03-19 05:07:09 +0000138 [SDNPHasChain, SDNPOutFlag, SDNPOptInFlag,
139 SDNPVariadic]>;
Evan Chengaed7c722005-12-17 01:24:02 +0000140
Chris Lattnered52c8f2010-03-28 07:38:39 +0000141def X86rep_stos: SDNode<"X86ISD::REP_STOS", SDTX86RepStr,
Chris Lattner9b37aaf2008-01-10 05:12:37 +0000142 [SDNPHasChain, SDNPInFlag, SDNPOutFlag, SDNPMayStore]>;
Chris Lattnered52c8f2010-03-28 07:38:39 +0000143def X86rep_movs: SDNode<"X86ISD::REP_MOVS", SDTX86RepStr,
Chris Lattner9b37aaf2008-01-10 05:12:37 +0000144 [SDNPHasChain, SDNPInFlag, SDNPOutFlag, SDNPMayStore,
145 SDNPMayLoad]>;
Evan Cheng67f92a72006-01-11 22:15:48 +0000146
Anton Korobeynikov043f3c22010-03-06 19:32:29 +0000147def X86rdtsc : SDNode<"X86ISD::RDTSC_DAG", SDTX86Void,
Chris Lattnerba7e7562008-01-10 07:59:24 +0000148 [SDNPHasChain, SDNPOutFlag, SDNPSideEffect]>;
Evan Chengd90eb7f2006-01-05 00:27:02 +0000149
Evan Cheng0085a282006-11-30 21:55:46 +0000150def X86Wrapper : SDNode<"X86ISD::Wrapper", SDTX86Wrapper>;
151def X86WrapperRIP : SDNode<"X86ISD::WrapperRIP", SDTX86Wrapper>;
Evan Cheng71fb8342006-02-25 10:02:21 +0000152
Lauro Ramos Venanciob3a04172007-04-20 21:38:10 +0000153def X86tlsaddr : SDNode<"X86ISD::TLSADDR", SDT_X86TLSADDR,
Anton Korobeynikov6625eff2008-05-04 21:36:32 +0000154 [SDNPHasChain, SDNPOptInFlag, SDNPOutFlag]>;
Rafael Espindola094fad32009-04-08 21:14:34 +0000155def X86SegmentBaseAddress : SDNode<"X86ISD::SegmentBaseAddress",
156 SDT_X86SegmentBaseAddress, []>;
Lauro Ramos Venanciob3a04172007-04-20 21:38:10 +0000157
Anton Korobeynikov2365f512007-07-14 14:06:15 +0000158def X86ehret : SDNode<"X86ISD::EH_RETURN", SDT_X86EHRET,
159 [SDNPHasChain]>;
160
Arnold Schwaighoferc85e1712007-10-11 19:40:01 +0000161def X86tcret : SDNode<"X86ISD::TC_RETURN", SDT_X86TCRET,
Chris Lattnere8cabf32010-03-19 05:07:09 +0000162 [SDNPHasChain, SDNPOptInFlag, SDNPVariadic]>;
Lauro Ramos Venanciob3a04172007-04-20 21:38:10 +0000163
Dan Gohman43ffe672010-01-04 20:51:05 +0000164def X86add_flag : SDNode<"X86ISD::ADD", SDTBinaryArithWithFlags,
Dan Gohman4361bbf2010-01-05 00:44:20 +0000165 [SDNPCommutative]>;
Dan Gohman076aee32009-03-04 19:44:21 +0000166def X86sub_flag : SDNode<"X86ISD::SUB", SDTBinaryArithWithFlags>;
Dan Gohman43ffe672010-01-04 20:51:05 +0000167def X86smul_flag : SDNode<"X86ISD::SMUL", SDTBinaryArithWithFlags,
Dan Gohman4361bbf2010-01-05 00:44:20 +0000168 [SDNPCommutative]>;
Dan Gohman43ffe672010-01-04 20:51:05 +0000169def X86umul_flag : SDNode<"X86ISD::UMUL", SDTUnaryArithWithFlags,
Dan Gohman4361bbf2010-01-05 00:44:20 +0000170 [SDNPCommutative]>;
Chris Lattner74c8d672010-03-24 00:47:47 +0000171
Dan Gohman076aee32009-03-04 19:44:21 +0000172def X86inc_flag : SDNode<"X86ISD::INC", SDTUnaryArithWithFlags>;
173def X86dec_flag : SDNode<"X86ISD::DEC", SDTUnaryArithWithFlags>;
Dan Gohman43ffe672010-01-04 20:51:05 +0000174def X86or_flag : SDNode<"X86ISD::OR", SDTBinaryArithWithFlags,
Dan Gohman4361bbf2010-01-05 00:44:20 +0000175 [SDNPCommutative]>;
Dan Gohman43ffe672010-01-04 20:51:05 +0000176def X86xor_flag : SDNode<"X86ISD::XOR", SDTBinaryArithWithFlags,
Dan Gohman4361bbf2010-01-05 00:44:20 +0000177 [SDNPCommutative]>;
Dan Gohman43ffe672010-01-04 20:51:05 +0000178def X86and_flag : SDNode<"X86ISD::AND", SDTBinaryArithWithFlags,
Dan Gohman4361bbf2010-01-05 00:44:20 +0000179 [SDNPCommutative]>;
Bill Wendlingab55ebd2008-12-12 00:56:36 +0000180
Evan Cheng73f24c92009-03-30 21:36:47 +0000181def X86mul_imm : SDNode<"X86ISD::MUL_IMM", SDTIntBinOp>;
182
Anton Korobeynikov043f3c22010-03-06 19:32:29 +0000183def X86MingwAlloca : SDNode<"X86ISD::MINGW_ALLOCA", SDTX86Void,
184 [SDNPHasChain, SDNPInFlag, SDNPOutFlag]>;
185
Evan Chengaed7c722005-12-17 01:24:02 +0000186//===----------------------------------------------------------------------===//
187// X86 Operand Definitions.
188//
189
Dan Gohmana4714e02009-07-30 01:56:29 +0000190// A version of ptr_rc which excludes SP, ESP, and RSP. This is used for
191// the index operand of an address, to conform to x86 encoding restrictions.
192def ptr_rc_nosp : PointerLikeRegClass<1>;
Chris Lattner7680e732009-06-20 19:34:09 +0000193
Chris Lattner66fa1dc2004-08-11 02:25:00 +0000194// *mem - Operand definitions for the funky X86 addressing mode operands.
195//
Daniel Dunbar338825c2009-08-10 18:41:10 +0000196def X86MemAsmOperand : AsmOperandClass {
197 let Name = "Mem";
Daniel Dunbar8e001172009-08-10 19:08:02 +0000198 let SuperClass = ?;
Daniel Dunbar338825c2009-08-10 18:41:10 +0000199}
Daniel Dunbarb834f5d2010-01-30 01:02:48 +0000200def X86AbsMemAsmOperand : AsmOperandClass {
201 let Name = "AbsMem";
202 let SuperClass = X86MemAsmOperand;
203}
Daniel Dunbarec2b1f12010-01-30 00:24:00 +0000204def X86NoSegMemAsmOperand : AsmOperandClass {
205 let Name = "NoSegMem";
206 let SuperClass = X86MemAsmOperand;
207}
Evan Chengaf78ef52006-05-17 21:21:41 +0000208class X86MemOperand<string printMethod> : Operand<iPTR> {
Nate Begeman391c5d22005-11-30 18:54:35 +0000209 let PrintMethod = printMethod;
Dan Gohmana4714e02009-07-30 01:56:29 +0000210 let MIOperandInfo = (ops ptr_rc, i8imm, ptr_rc_nosp, i32imm, i8imm);
Daniel Dunbar338825c2009-08-10 18:41:10 +0000211 let ParserMatchClass = X86MemAsmOperand;
Chris Lattner66fa1dc2004-08-11 02:25:00 +0000212}
Nate Begeman391c5d22005-11-30 18:54:35 +0000213
Sean Callanan9947bbb2009-09-03 00:04:47 +0000214def opaque32mem : X86MemOperand<"printopaquemem">;
215def opaque48mem : X86MemOperand<"printopaquemem">;
216def opaque80mem : X86MemOperand<"printopaquemem">;
Sean Callanan108934c2009-12-18 00:01:26 +0000217def opaque512mem : X86MemOperand<"printopaquemem">;
218
Chris Lattner45432512005-12-17 19:47:05 +0000219def i8mem : X86MemOperand<"printi8mem">;
220def i16mem : X86MemOperand<"printi16mem">;
221def i32mem : X86MemOperand<"printi32mem">;
222def i64mem : X86MemOperand<"printi64mem">;
Evan Cheng470a6ad2006-02-22 02:26:30 +0000223def i128mem : X86MemOperand<"printi128mem">;
Chris Lattnere895c612009-09-20 07:17:49 +0000224//def i256mem : X86MemOperand<"printi256mem">;
Chris Lattner45432512005-12-17 19:47:05 +0000225def f32mem : X86MemOperand<"printf32mem">;
226def f64mem : X86MemOperand<"printf64mem">;
Dale Johannesen59a58732007-08-05 18:49:15 +0000227def f80mem : X86MemOperand<"printf80mem">;
Evan Cheng223547a2006-01-31 22:28:30 +0000228def f128mem : X86MemOperand<"printf128mem">;
Chris Lattnere895c612009-09-20 07:17:49 +0000229//def f256mem : X86MemOperand<"printf256mem">;
Nate Begeman391c5d22005-11-30 18:54:35 +0000230
Dan Gohman21e3dfb2009-04-13 16:09:41 +0000231// A version of i8mem for use on x86-64 that uses GR64_NOREX instead of
232// plain GR64, so that it doesn't potentially require a REX prefix.
233def i8mem_NOREX : Operand<i64> {
234 let PrintMethod = "printi8mem";
Dan Gohmana4714e02009-07-30 01:56:29 +0000235 let MIOperandInfo = (ops GR64_NOREX, i8imm, GR64_NOREX_NOSP, i32imm, i8imm);
Daniel Dunbar338825c2009-08-10 18:41:10 +0000236 let ParserMatchClass = X86MemAsmOperand;
Dan Gohman21e3dfb2009-04-13 16:09:41 +0000237}
238
Evan Chengf48ef032010-03-14 03:48:46 +0000239// Special i32mem for addresses of load folding tail calls. These are not
240// allowed to use callee-saved registers since they must be scheduled
241// after callee-saved register are popped.
242def i32mem_TC : Operand<i32> {
243 let PrintMethod = "printi32mem";
244 let MIOperandInfo = (ops GR32_TC, i8imm, GR32_TC, i32imm, i8imm);
245 let ParserMatchClass = X86MemAsmOperand;
246}
247
Evan Cheng25ab6902006-09-08 06:48:29 +0000248def lea32mem : Operand<i32> {
Rafael Espindola094fad32009-04-08 21:14:34 +0000249 let PrintMethod = "printlea32mem";
Dan Gohman74f6f9a2009-08-05 17:40:24 +0000250 let MIOperandInfo = (ops GR32, i8imm, GR32_NOSP, i32imm);
Daniel Dunbarec2b1f12010-01-30 00:24:00 +0000251 let ParserMatchClass = X86NoSegMemAsmOperand;
Evan Cheng25ab6902006-09-08 06:48:29 +0000252}
253
Daniel Dunbarb834f5d2010-01-30 01:02:48 +0000254let ParserMatchClass = X86AbsMemAsmOperand,
255 PrintMethod = "print_pcrel_imm" in {
Daniel Dunbar728e5eb2010-01-30 00:24:12 +0000256def i32imm_pcrel : Operand<i32>;
257
258def offset8 : Operand<i64>;
259def offset16 : Operand<i64>;
260def offset32 : Operand<i64>;
261def offset64 : Operand<i64>;
262
263// Branch targets have OtherVT type and print as pc-relative values.
264def brtarget : Operand<OtherVT>;
265def brtarget8 : Operand<OtherVT>;
266
267}
268
Nate Begeman16b04f32005-07-15 00:38:55 +0000269def SSECC : Operand<i8> {
270 let PrintMethod = "printSSECC";
271}
Chris Lattner66fa1dc2004-08-11 02:25:00 +0000272
Daniel Dunbar338825c2009-08-10 18:41:10 +0000273def ImmSExt8AsmOperand : AsmOperandClass {
274 let Name = "ImmSExt8";
275 let SuperClass = ImmAsmOperand;
276}
277
Chris Lattnerf124d5e2005-11-18 01:04:42 +0000278// A couple of more descriptive operand definitions.
279// 16-bits but only 8 bits are significant.
Daniel Dunbar5fe63382009-08-09 07:20:21 +0000280def i16i8imm : Operand<i16> {
Daniel Dunbar338825c2009-08-10 18:41:10 +0000281 let ParserMatchClass = ImmSExt8AsmOperand;
Daniel Dunbar5fe63382009-08-09 07:20:21 +0000282}
Chris Lattnerf124d5e2005-11-18 01:04:42 +0000283// 32-bits but only 8 bits are significant.
Daniel Dunbar5fe63382009-08-09 07:20:21 +0000284def i32i8imm : Operand<i32> {
Daniel Dunbar338825c2009-08-10 18:41:10 +0000285 let ParserMatchClass = ImmSExt8AsmOperand;
Daniel Dunbar5fe63382009-08-09 07:20:21 +0000286}
Chris Lattnerf124d5e2005-11-18 01:04:42 +0000287
Evan Chengaed7c722005-12-17 01:24:02 +0000288//===----------------------------------------------------------------------===//
289// X86 Complex Pattern Definitions.
290//
291
Evan Chengec693f72005-12-08 02:01:35 +0000292// Define X86 specific addressing mode.
Rafael Espindola094fad32009-04-08 21:14:34 +0000293def addr : ComplexPattern<iPTR, 5, "SelectAddr", [], []>;
Evan Cheng25ab6902006-09-08 06:48:29 +0000294def lea32addr : ComplexPattern<i32, 4, "SelectLEAAddr",
Dan Gohmana98634b2009-08-02 16:09:17 +0000295 [add, sub, mul, X86mul_imm, shl, or, frameindex],
296 []>;
Chris Lattner5c0b16d2009-06-20 20:38:48 +0000297def tls32addr : ComplexPattern<i32, 4, "SelectTLSADDRAddr",
298 [tglobaltlsaddr], []>;
Evan Chengec693f72005-12-08 02:01:35 +0000299
Evan Chengaed7c722005-12-17 01:24:02 +0000300//===----------------------------------------------------------------------===//
Evan Chengbbc8ddb2005-12-20 22:59:51 +0000301// X86 Instruction Predicate Definitions.
Chris Lattner314a1132010-03-14 18:31:44 +0000302def HasCMov : Predicate<"Subtarget->hasCMov()">;
303def NoCMov : Predicate<"!Subtarget->hasCMov()">;
Evan Cheng28b514392006-12-05 19:50:18 +0000304def HasMMX : Predicate<"Subtarget->hasMMX()">;
305def HasSSE1 : Predicate<"Subtarget->hasSSE1()">;
306def HasSSE2 : Predicate<"Subtarget->hasSSE2()">;
307def HasSSE3 : Predicate<"Subtarget->hasSSE3()">;
Bill Wendlingbb1ee052007-04-10 22:10:25 +0000308def HasSSSE3 : Predicate<"Subtarget->hasSSSE3()">;
Nate Begeman63ec90a2008-02-03 07:18:54 +0000309def HasSSE41 : Predicate<"Subtarget->hasSSE41()">;
310def HasSSE42 : Predicate<"Subtarget->hasSSE42()">;
David Greene343dadb2009-06-26 22:46:54 +0000311def HasSSE4A : Predicate<"Subtarget->hasSSE4A()">;
312def HasAVX : Predicate<"Subtarget->hasAVX()">;
313def HasFMA3 : Predicate<"Subtarget->hasFMA3()">;
314def HasFMA4 : Predicate<"Subtarget->hasFMA4()">;
Dale Johannesenf1fc3a82007-09-23 14:52:20 +0000315def FPStackf32 : Predicate<"!Subtarget->hasSSE1()">;
316def FPStackf64 : Predicate<"!Subtarget->hasSSE2()">;
Evan Cheng28b514392006-12-05 19:50:18 +0000317def In32BitMode : Predicate<"!Subtarget->is64Bit()">;
318def In64BitMode : Predicate<"Subtarget->is64Bit()">;
Anton Korobeynikovcf6b7392009-08-03 08:12:53 +0000319def IsWin64 : Predicate<"Subtarget->isTargetWin64()">;
320def NotWin64 : Predicate<"!Subtarget->isTargetWin64()">;
Anton Korobeynikovd7697d02009-08-06 11:23:24 +0000321def SmallCode : Predicate<"TM.getCodeModel() == CodeModel::Small">;
322def KernelCode : Predicate<"TM.getCodeModel() == CodeModel::Kernel">;
323def FarData : Predicate<"TM.getCodeModel() != CodeModel::Small &&"
Anton Korobeynikov186fa1d2009-08-06 09:11:19 +0000324 "TM.getCodeModel() != CodeModel::Kernel">;
Anton Korobeynikovd7697d02009-08-06 11:23:24 +0000325def NearData : Predicate<"TM.getCodeModel() == CodeModel::Small ||"
326 "TM.getCodeModel() == CodeModel::Kernel">;
Evan Cheng28b514392006-12-05 19:50:18 +0000327def IsStatic : Predicate<"TM.getRelocationModel() == Reloc::Static">;
Evan Chengcb0f06e2010-03-25 00:10:31 +0000328def IsNotPIC : Predicate<"TM.getRelocationModel() != Reloc::PIC_">;
Evan Chengb1f49812009-12-22 17:47:23 +0000329def OptForSize : Predicate<"OptForSize">;
Evan Chengb7a75a52008-09-26 23:41:32 +0000330def OptForSpeed : Predicate<"!OptForSize">;
Evan Chengccb69762009-01-02 05:35:45 +0000331def FastBTMem : Predicate<"!Subtarget->isBTMemSlow()">;
Evan Chengd7f666a2009-05-20 04:53:57 +0000332def CallImmAddr : Predicate<"Subtarget->IsLegalToCallImmediateAddr(TM)">;
Eric Christopher6d1cd1c2010-04-02 21:54:27 +0000333def HasAES : Predicate<"Subtarget->hasAES()">;
Evan Chengbbc8ddb2005-12-20 22:59:51 +0000334
335//===----------------------------------------------------------------------===//
Evan Chengc64a1a92007-07-31 08:04:03 +0000336// X86 Instruction Format Definitions.
Evan Chengaed7c722005-12-17 01:24:02 +0000337//
338
Evan Chengc64a1a92007-07-31 08:04:03 +0000339include "X86InstrFormats.td"
Chris Lattner1cca5e32003-08-03 21:54:21 +0000340
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +0000341//===----------------------------------------------------------------------===//
Chris Lattnerf124d5e2005-11-18 01:04:42 +0000342// Pattern fragments...
343//
Evan Chengd9558e02006-01-06 00:43:03 +0000344
345// X86 specific condition code. These correspond to CondCode in
Nate Begeman9a225302007-05-06 04:00:55 +0000346// X86InstrInfo.h. They must be kept in synch.
Dan Gohman653456c2009-01-07 00:15:08 +0000347def X86_COND_A : PatLeaf<(i8 0)>; // alt. COND_NBE
348def X86_COND_AE : PatLeaf<(i8 1)>; // alt. COND_NC
349def X86_COND_B : PatLeaf<(i8 2)>; // alt. COND_C
350def X86_COND_BE : PatLeaf<(i8 3)>; // alt. COND_NA
351def X86_COND_E : PatLeaf<(i8 4)>; // alt. COND_Z
352def X86_COND_G : PatLeaf<(i8 5)>; // alt. COND_NLE
353def X86_COND_GE : PatLeaf<(i8 6)>; // alt. COND_NL
354def X86_COND_L : PatLeaf<(i8 7)>; // alt. COND_NGE
355def X86_COND_LE : PatLeaf<(i8 8)>; // alt. COND_NG
356def X86_COND_NE : PatLeaf<(i8 9)>; // alt. COND_NZ
Evan Chengd9558e02006-01-06 00:43:03 +0000357def X86_COND_NO : PatLeaf<(i8 10)>;
Dan Gohman653456c2009-01-07 00:15:08 +0000358def X86_COND_NP : PatLeaf<(i8 11)>; // alt. COND_PO
Evan Chengd9558e02006-01-06 00:43:03 +0000359def X86_COND_NS : PatLeaf<(i8 12)>;
Dan Gohman653456c2009-01-07 00:15:08 +0000360def X86_COND_O : PatLeaf<(i8 13)>;
361def X86_COND_P : PatLeaf<(i8 14)>; // alt. COND_PE
362def X86_COND_S : PatLeaf<(i8 15)>;
Evan Chengd9558e02006-01-06 00:43:03 +0000363
Chris Lattner18409912010-03-03 01:45:01 +0000364def immSext8 : PatLeaf<(imm), [{
365 return N->getSExtValue() == (int8_t)N->getSExtValue();
Chris Lattnerf124d5e2005-11-18 01:04:42 +0000366}]>;
367
Chris Lattner18409912010-03-03 01:45:01 +0000368def i16immSExt8 : PatLeaf<(i16 immSext8)>;
369def i32immSExt8 : PatLeaf<(i32 immSext8)>;
Evan Chengb3558542005-12-13 00:01:09 +0000370
Chris Lattnerf85eff72010-03-03 01:52:59 +0000371/// Load patterns: these constraint the match to the right address space.
372def dsload : PatFrag<(ops node:$ptr), (load node:$ptr), [{
373 if (const Value *Src = cast<LoadSDNode>(N)->getSrcValue())
374 if (const PointerType *PT = dyn_cast<PointerType>(Src->getType()))
375 if (PT->getAddressSpace() > 255)
376 return false;
377 return true;
378}]>;
379
380def gsload : PatFrag<(ops node:$ptr), (load node:$ptr), [{
381 if (const Value *Src = cast<LoadSDNode>(N)->getSrcValue())
382 if (const PointerType *PT = dyn_cast<PointerType>(Src->getType()))
383 return PT->getAddressSpace() == 256;
384 return false;
385}]>;
386
387def fsload : PatFrag<(ops node:$ptr), (load node:$ptr), [{
388 if (const Value *Src = cast<LoadSDNode>(N)->getSrcValue())
389 if (const PointerType *PT = dyn_cast<PointerType>(Src->getType()))
390 return PT->getAddressSpace() == 257;
391 return false;
392}]>;
393
394
Evan Cheng605c4152005-12-13 01:57:51 +0000395// Helper fragments for loads.
Evan Chengb6564432008-05-13 18:59:59 +0000396// It's always safe to treat a anyext i16 load as a i32 load if the i16 is
397// known to be 32-bit aligned or better. Ditto for i8 to i16.
Dan Gohman33586292008-10-15 06:50:19 +0000398def loadi16 : PatFrag<(ops node:$ptr), (i16 (unindexedload node:$ptr)), [{
Dan Gohman67ca6be2008-08-20 15:24:22 +0000399 LoadSDNode *LD = cast<LoadSDNode>(N);
Chris Lattnerc2406f22009-04-10 00:16:23 +0000400 if (const Value *Src = LD->getSrcValue())
401 if (const PointerType *PT = dyn_cast<PointerType>(Src->getType()))
Mon P Wanga7e01d72009-04-27 07:22:10 +0000402 if (PT->getAddressSpace() > 255)
Chris Lattnerc2406f22009-04-10 00:16:23 +0000403 return false;
Dan Gohman67ca6be2008-08-20 15:24:22 +0000404 ISD::LoadExtType ExtType = LD->getExtensionType();
405 if (ExtType == ISD::NON_EXTLOAD)
406 return true;
407 if (ExtType == ISD::EXTLOAD)
408 return LD->getAlignment() >= 2 && !LD->isVolatile();
Evan Chengfa7fd332008-05-13 00:54:02 +0000409 return false;
410}]>;
411
Chris Lattnerf85eff72010-03-03 01:52:59 +0000412def loadi16_anyext : PatFrag<(ops node:$ptr), (i32 (unindexedload node:$ptr)),[{
Evan Chengca57f782008-09-24 23:27:55 +0000413 LoadSDNode *LD = cast<LoadSDNode>(N);
Chris Lattnerc2406f22009-04-10 00:16:23 +0000414 if (const Value *Src = LD->getSrcValue())
415 if (const PointerType *PT = dyn_cast<PointerType>(Src->getType()))
Mon P Wanga7e01d72009-04-27 07:22:10 +0000416 if (PT->getAddressSpace() > 255)
Chris Lattnerc2406f22009-04-10 00:16:23 +0000417 return false;
Evan Chengca57f782008-09-24 23:27:55 +0000418 ISD::LoadExtType ExtType = LD->getExtensionType();
419 if (ExtType == ISD::EXTLOAD)
420 return LD->getAlignment() >= 2 && !LD->isVolatile();
421 return false;
422}]>;
423
Dan Gohman33586292008-10-15 06:50:19 +0000424def loadi32 : PatFrag<(ops node:$ptr), (i32 (unindexedload node:$ptr)), [{
Dan Gohman67ca6be2008-08-20 15:24:22 +0000425 LoadSDNode *LD = cast<LoadSDNode>(N);
Chris Lattnerc2406f22009-04-10 00:16:23 +0000426 if (const Value *Src = LD->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;
Dan Gohman67ca6be2008-08-20 15:24:22 +0000430 ISD::LoadExtType ExtType = LD->getExtensionType();
431 if (ExtType == ISD::NON_EXTLOAD)
432 return true;
433 if (ExtType == ISD::EXTLOAD)
434 return LD->getAlignment() >= 4 && !LD->isVolatile();
Evan Chengfa7fd332008-05-13 00:54:02 +0000435 return false;
436}]>;
437
Chris Lattnerf85eff72010-03-03 01:52:59 +0000438def loadi8 : PatFrag<(ops node:$ptr), (i8 (dsload node:$ptr))>;
439def loadi64 : PatFrag<(ops node:$ptr), (i64 (dsload node:$ptr))>;
440def loadf32 : PatFrag<(ops node:$ptr), (f32 (dsload node:$ptr))>;
441def loadf64 : PatFrag<(ops node:$ptr), (f64 (dsload node:$ptr))>;
442def loadf80 : PatFrag<(ops node:$ptr), (f80 (dsload node:$ptr))>;
Evan Cheng7a7e8372005-12-14 02:22:27 +0000443
Evan Cheng466685d2006-10-09 20:57:25 +0000444def sextloadi16i8 : PatFrag<(ops node:$ptr), (i16 (sextloadi8 node:$ptr))>;
445def sextloadi32i8 : PatFrag<(ops node:$ptr), (i32 (sextloadi8 node:$ptr))>;
446def sextloadi32i16 : PatFrag<(ops node:$ptr), (i32 (sextloadi16 node:$ptr))>;
Evan Cheng7a7e8372005-12-14 02:22:27 +0000447
Evan Cheng466685d2006-10-09 20:57:25 +0000448def zextloadi8i1 : PatFrag<(ops node:$ptr), (i8 (zextloadi1 node:$ptr))>;
449def zextloadi16i1 : PatFrag<(ops node:$ptr), (i16 (zextloadi1 node:$ptr))>;
450def zextloadi32i1 : PatFrag<(ops node:$ptr), (i32 (zextloadi1 node:$ptr))>;
451def zextloadi16i8 : PatFrag<(ops node:$ptr), (i16 (zextloadi8 node:$ptr))>;
452def zextloadi32i8 : PatFrag<(ops node:$ptr), (i32 (zextloadi8 node:$ptr))>;
453def zextloadi32i16 : PatFrag<(ops node:$ptr), (i32 (zextloadi16 node:$ptr))>;
Evan Cheng7a7e8372005-12-14 02:22:27 +0000454
Evan Cheng466685d2006-10-09 20:57:25 +0000455def extloadi8i1 : PatFrag<(ops node:$ptr), (i8 (extloadi1 node:$ptr))>;
456def extloadi16i1 : PatFrag<(ops node:$ptr), (i16 (extloadi1 node:$ptr))>;
457def extloadi32i1 : PatFrag<(ops node:$ptr), (i32 (extloadi1 node:$ptr))>;
458def extloadi16i8 : PatFrag<(ops node:$ptr), (i16 (extloadi8 node:$ptr))>;
459def extloadi32i8 : PatFrag<(ops node:$ptr), (i32 (extloadi8 node:$ptr))>;
460def extloadi32i16 : PatFrag<(ops node:$ptr), (i32 (extloadi16 node:$ptr))>;
Evan Cheng747a90d2006-02-21 02:24:38 +0000461
Chris Lattnerce2bcc82008-02-19 17:37:35 +0000462
463// An 'and' node with a single use.
464def and_su : PatFrag<(ops node:$lhs, node:$rhs), (and node:$lhs, node:$rhs), [{
Evan Cheng07b7ea12008-03-04 00:40:35 +0000465 return N->hasOneUse();
Chris Lattnerce2bcc82008-02-19 17:37:35 +0000466}]>;
Dan Gohman21e3dfb2009-04-13 16:09:41 +0000467// An 'srl' node with a single use.
468def srl_su : PatFrag<(ops node:$lhs, node:$rhs), (srl node:$lhs, node:$rhs), [{
469 return N->hasOneUse();
470}]>;
471// An 'trunc' node with a single use.
472def trunc_su : PatFrag<(ops node:$src), (trunc node:$src), [{
473 return N->hasOneUse();
474}]>;
Chris Lattnerce2bcc82008-02-19 17:37:35 +0000475
Evan Cheng4b0345b2010-01-11 17:03:47 +0000476// Treat an 'or' node is as an 'add' if the or'ed bits are known to be zero.
477def or_is_add : PatFrag<(ops node:$lhs, node:$rhs), (or node:$lhs, node:$rhs),[{
478 if (ConstantSDNode *CN = dyn_cast<ConstantSDNode>(N->getOperand(1)))
479 return CurDAG->MaskedValueIsZero(N->getOperand(0), CN->getAPIntValue());
Chris Lattnerfdac0b62010-03-24 00:12:57 +0000480
481 unsigned BitWidth = N->getValueType(0).getScalarType().getSizeInBits();
482 APInt Mask = APInt::getAllOnesValue(BitWidth);
483 APInt KnownZero0, KnownOne0;
484 CurDAG->ComputeMaskedBits(N->getOperand(0), Mask, KnownZero0, KnownOne0, 0);
485 APInt KnownZero1, KnownOne1;
486 CurDAG->ComputeMaskedBits(N->getOperand(1), Mask, KnownZero1, KnownOne1, 0);
487 return (~KnownZero0 & ~KnownZero1) == 0;
Evan Cheng4b0345b2010-01-11 17:03:47 +0000488}]>;
Evan Cheng4b0345b2010-01-11 17:03:47 +0000489
Dan Gohman74feef22008-10-17 01:23:35 +0000490// 'shld' and 'shrd' instruction patterns. Note that even though these have
491// the srl and shl in their patterns, the C++ code must still check for them,
492// because predicates are tested before children nodes are explored.
493
494def shrd : PatFrag<(ops node:$src1, node:$amt1, node:$src2, node:$amt2),
495 (or (srl node:$src1, node:$amt1),
496 (shl node:$src2, node:$amt2)), [{
497 assert(N->getOpcode() == ISD::OR);
498 return N->getOperand(0).getOpcode() == ISD::SRL &&
499 N->getOperand(1).getOpcode() == ISD::SHL &&
500 isa<ConstantSDNode>(N->getOperand(0).getOperand(1)) &&
501 isa<ConstantSDNode>(N->getOperand(1).getOperand(1)) &&
502 N->getOperand(0).getConstantOperandVal(1) ==
503 N->getValueSizeInBits(0) - N->getOperand(1).getConstantOperandVal(1);
504}]>;
505
506def shld : PatFrag<(ops node:$src1, node:$amt1, node:$src2, node:$amt2),
507 (or (shl node:$src1, node:$amt1),
508 (srl node:$src2, node:$amt2)), [{
509 assert(N->getOpcode() == ISD::OR);
510 return N->getOperand(0).getOpcode() == ISD::SHL &&
511 N->getOperand(1).getOpcode() == ISD::SRL &&
512 isa<ConstantSDNode>(N->getOperand(0).getOperand(1)) &&
513 isa<ConstantSDNode>(N->getOperand(1).getOperand(1)) &&
514 N->getOperand(0).getConstantOperandVal(1) ==
515 N->getValueSizeInBits(0) - N->getOperand(1).getConstantOperandVal(1);
516}]>;
517
Chris Lattnerf124d5e2005-11-18 01:04:42 +0000518//===----------------------------------------------------------------------===//
Chris Lattner1cca5e32003-08-03 21:54:21 +0000519// Instruction list...
520//
521
Chris Lattnerf18c0742006-10-12 17:42:56 +0000522// ADJCALLSTACKDOWN/UP implicitly use/def ESP because they may be expanded into
523// a stack adjustment and the codegen must know that they may modify the stack
524// pointer before prolog-epilog rewriting occurs.
Chris Lattner447ff682008-03-11 03:23:40 +0000525// Pessimistically assume ADJCALLSTACKDOWN / ADJCALLSTACKUP will become
526// sub / add which can clobber EFLAGS.
Evan Cheng8decf6b2007-09-28 01:19:48 +0000527let Defs = [ESP, EFLAGS], Uses = [ESP] in {
Dan Gohman6d4b0522008-10-01 18:28:06 +0000528def ADJCALLSTACKDOWN32 : I<0, Pseudo, (outs), (ins i32imm:$amt),
529 "#ADJCALLSTACKDOWN",
Chris Lattnere563bbc2008-10-11 22:08:30 +0000530 [(X86callseq_start timm:$amt)]>,
Dan Gohman6d4b0522008-10-01 18:28:06 +0000531 Requires<[In32BitMode]>;
532def ADJCALLSTACKUP32 : I<0, Pseudo, (outs), (ins i32imm:$amt1, i32imm:$amt2),
533 "#ADJCALLSTACKUP",
Chris Lattnere563bbc2008-10-11 22:08:30 +0000534 [(X86callseq_end timm:$amt1, timm:$amt2)]>,
Dan Gohman6d4b0522008-10-01 18:28:06 +0000535 Requires<[In32BitMode]>;
Evan Cheng071a2792007-09-11 19:55:27 +0000536}
Evan Cheng4a460802006-01-11 00:33:36 +0000537
Dan Gohmand6708ea2009-08-15 01:38:56 +0000538// x86-64 va_start lowering magic.
Anton Korobeynikov043f3c22010-03-06 19:32:29 +0000539let usesCustomInserter = 1 in {
Dan Gohmand6708ea2009-08-15 01:38:56 +0000540def VASTART_SAVE_XMM_REGS : I<0, Pseudo,
541 (outs),
542 (ins GR8:$al,
543 i64imm:$regsavefi, i64imm:$offset,
544 variable_ops),
545 "#VASTART_SAVE_XMM_REGS $al, $regsavefi, $offset",
546 [(X86vastart_save_xmm_regs GR8:$al,
547 imm:$regsavefi,
548 imm:$offset)]>;
549
Anton Korobeynikove765f2b2010-03-06 20:07:32 +0000550// Dynamic stack allocation yields _alloca call for Cygwin/Mingw targets. Calls
551// to _alloca is needed to probe the stack when allocating more than 4k bytes in
552// one go. Touching the stack at 4K increments is necessary to ensure that the
553// guard pages used by the OS virtual memory manager are allocated in correct
554// sequence.
555// The main point of having separate instruction are extra unmodelled effects
556// (compared to ordinary calls) like stack pointer change.
557
Anton Korobeynikov043f3c22010-03-06 19:32:29 +0000558def MINGW_ALLOCA : I<0, Pseudo, (outs), (ins),
Anton Korobeynikove765f2b2010-03-06 20:07:32 +0000559 "# dynamic stack allocation",
Anton Korobeynikov043f3c22010-03-06 19:32:29 +0000560 [(X86MingwAlloca)]>;
561}
562
Evan Cheng4a460802006-01-11 00:33:36 +0000563// Nop
Sean Callanan74e52102009-07-23 23:39:34 +0000564let neverHasSideEffects = 1 in {
Chris Lattnerba7e7562008-01-10 07:59:24 +0000565 def NOOP : I<0x90, RawFrm, (outs), (ins), "nop", []>;
Sean Callanan108934c2009-12-18 00:01:26 +0000566 def NOOPW : I<0x1f, MRM0m, (outs), (ins i16mem:$zero),
567 "nop{w}\t$zero", []>, TB, OpSize;
Sean Callanan74e52102009-07-23 23:39:34 +0000568 def NOOPL : I<0x1f, MRM0m, (outs), (ins i32mem:$zero),
Sean Callanan108934c2009-12-18 00:01:26 +0000569 "nop{l}\t$zero", []>, TB;
Sean Callanan74e52102009-07-23 23:39:34 +0000570}
Evan Cheng4a460802006-01-11 00:33:36 +0000571
Sean Callanan1c5cf1b2009-08-11 01:09:06 +0000572// Trap
Dan Gohmane94975e2009-11-11 18:07:16 +0000573def INT3 : I<0xcc, RawFrm, (outs), (ins), "int\t3", []>;
Sean Callanan1c5cf1b2009-08-11 01:09:06 +0000574def INT : I<0xcd, RawFrm, (outs), (ins i8imm:$trap), "int\t$trap", []>;
Sean Callanan108934c2009-12-18 00:01:26 +0000575def IRET16 : I<0xcf, RawFrm, (outs), (ins), "iret{w}", []>, OpSize;
576def IRET32 : I<0xcf, RawFrm, (outs), (ins), "iret{l}", []>;
Sean Callanan1c5cf1b2009-08-11 01:09:06 +0000577
Chris Lattner71c7ace2009-09-20 07:32:00 +0000578// PIC base construction. This expands to code that looks like this:
579// call $next_inst
580// popl %destreg"
Dan Gohman2662d552008-10-01 04:14:30 +0000581let neverHasSideEffects = 1, isNotDuplicable = 1, Uses = [ESP] in
Chris Lattnerb3c85472009-09-20 07:28:26 +0000582 def MOVPC32r : Ii32<0xE8, Pseudo, (outs GR32:$reg), (ins i32imm:$label),
Chris Lattner71c7ace2009-09-20 07:32:00 +0000583 "", []>;
Evan Cheng8f7f7122006-05-05 05:40:20 +0000584
Chris Lattner1cca5e32003-08-03 21:54:21 +0000585//===----------------------------------------------------------------------===//
Chris Lattnerbd13fb62010-02-11 19:25:55 +0000586// Control Flow Instructions.
Chris Lattner1cca5e32003-08-03 21:54:21 +0000587//
588
Chris Lattner1be48112005-05-13 17:56:48 +0000589// Return instructions.
Evan Cheng2b4ea792005-12-26 09:11:45 +0000590let isTerminator = 1, isReturn = 1, isBarrier = 1,
Jakob Stoklund Olesen70feca42010-03-25 18:52:01 +0000591 hasCtrlDep = 1, FPForm = SpecialFP in {
Dan Gohmane4c67cd2008-05-31 02:11:25 +0000592 def RET : I <0xC3, RawFrm, (outs), (ins variable_ops),
Chris Lattner447ff682008-03-11 03:23:40 +0000593 "ret",
Dan Gohmane4c67cd2008-05-31 02:11:25 +0000594 [(X86retflag 0)]>;
Chris Lattner447ff682008-03-11 03:23:40 +0000595 def RETI : Ii16<0xC2, RawFrm, (outs), (ins i16imm:$amt, variable_ops),
596 "ret\t$amt",
Dan Gohman2f67df72009-09-03 17:18:51 +0000597 [(X86retflag timm:$amt)]>;
Sean Callanan356aed52009-09-15 23:37:51 +0000598 def LRET : I <0xCB, RawFrm, (outs), (ins),
599 "lret", []>;
600 def LRETI : Ii16<0xCA, RawFrm, (outs), (ins i16imm:$amt),
601 "lret\t$amt", []>;
Evan Cheng171049d2005-12-23 22:14:32 +0000602}
Chris Lattner1cca5e32003-08-03 21:54:21 +0000603
Chris Lattnerbd13fb62010-02-11 19:25:55 +0000604// Unconditional branches.
Chris Lattnerb8db3312010-02-11 21:45:31 +0000605let isBarrier = 1, isBranch = 1, isTerminator = 1 in {
Chris Lattnera0331192010-02-12 22:27:07 +0000606 def JMP_4 : Ii32PCRel<0xE9, RawFrm, (outs), (ins brtarget:$dst),
607 "jmp\t$dst", [(br bb:$dst)]>;
608 def JMP_1 : Ii8PCRel<0xEB, RawFrm, (outs), (ins brtarget8:$dst),
609 "jmp\t$dst", []>;
Sean Callanan52925882009-07-22 01:05:20 +0000610}
Evan Cheng898101c2005-12-19 23:12:38 +0000611
Chris Lattnerbd13fb62010-02-11 19:25:55 +0000612// Conditional Branches.
613let isBranch = 1, isTerminator = 1, Uses = [EFLAGS] in {
614 multiclass ICBr<bits<8> opc1, bits<8> opc4, string asm, PatFrag Cond> {
Chris Lattnera0331192010-02-12 22:27:07 +0000615 def _1 : Ii8PCRel <opc1, RawFrm, (outs), (ins brtarget8:$dst), asm, []>;
616 def _4 : Ii32PCRel<opc4, RawFrm, (outs), (ins brtarget:$dst), asm,
617 [(X86brcond bb:$dst, Cond, EFLAGS)]>, TB;
Chris Lattnerbd13fb62010-02-11 19:25:55 +0000618 }
619}
620
621defm JO : ICBr<0x70, 0x80, "jo\t$dst" , X86_COND_O>;
Chris Lattner8b442a82010-02-11 19:52:11 +0000622defm JNO : ICBr<0x71, 0x81, "jno\t$dst" , X86_COND_NO>;
Chris Lattnerbd13fb62010-02-11 19:25:55 +0000623defm JB : ICBr<0x72, 0x82, "jb\t$dst" , X86_COND_B>;
624defm JAE : ICBr<0x73, 0x83, "jae\t$dst", X86_COND_AE>;
625defm JE : ICBr<0x74, 0x84, "je\t$dst" , X86_COND_E>;
626defm JNE : ICBr<0x75, 0x85, "jne\t$dst", X86_COND_NE>;
627defm JBE : ICBr<0x76, 0x86, "jbe\t$dst", X86_COND_BE>;
628defm JA : ICBr<0x77, 0x87, "ja\t$dst" , X86_COND_A>;
629defm JS : ICBr<0x78, 0x88, "js\t$dst" , X86_COND_S>;
630defm JNS : ICBr<0x79, 0x89, "jns\t$dst", X86_COND_NS>;
631defm JP : ICBr<0x7A, 0x8A, "jp\t$dst" , X86_COND_P>;
632defm JNP : ICBr<0x7B, 0x8B, "jnp\t$dst", X86_COND_NP>;
633defm JL : ICBr<0x7C, 0x8C, "jl\t$dst" , X86_COND_L>;
634defm JGE : ICBr<0x7D, 0x8D, "jge\t$dst", X86_COND_GE>;
635defm JLE : ICBr<0x7E, 0x8E, "jle\t$dst", X86_COND_LE>;
636defm JG : ICBr<0x7F, 0x8F, "jg\t$dst" , X86_COND_G>;
637
638// FIXME: What about the CX/RCX versions of this instruction?
Chris Lattnerb8db3312010-02-11 21:45:31 +0000639let Uses = [ECX], isBranch = 1, isTerminator = 1 in
Chris Lattnera0331192010-02-12 22:27:07 +0000640 def JCXZ8 : Ii8PCRel<0xE3, RawFrm, (outs), (ins brtarget8:$dst),
641 "jcxz\t$dst", []>;
Chris Lattnerbd13fb62010-02-11 19:25:55 +0000642
643
Owen Anderson20ab2902007-11-12 07:39:39 +0000644// Indirect branches
645let isBranch = 1, isTerminator = 1, isBarrier = 1, isIndirectBranch = 1 in {
Dan Gohmanb1576f52007-07-31 20:11:57 +0000646 def JMP32r : I<0xFF, MRM4r, (outs), (ins GR32:$dst), "jmp{l}\t{*}$dst",
Evan Cheng069287d2006-05-16 07:21:53 +0000647 [(brind GR32:$dst)]>;
Dan Gohmanb1576f52007-07-31 20:11:57 +0000648 def JMP32m : I<0xFF, MRM4m, (outs), (ins i32mem:$dst), "jmp{l}\t{*}$dst",
Evan Cheng25ab6902006-09-08 06:48:29 +0000649 [(brind (loadi32 addr:$dst))]>;
Sean Callanan76f14be2009-09-15 00:35:17 +0000650
651 def FARJMP16i : Iseg16<0xEA, RawFrm, (outs),
652 (ins i16imm:$seg, i16imm:$off),
653 "ljmp{w}\t$seg, $off", []>, OpSize;
654 def FARJMP32i : Iseg32<0xEA, RawFrm, (outs),
655 (ins i16imm:$seg, i32imm:$off),
656 "ljmp{l}\t$seg, $off", []>;
657
658 def FARJMP16m : I<0xFF, MRM5m, (outs), (ins opaque32mem:$dst),
Sean Callanan9947bbb2009-09-03 00:04:47 +0000659 "ljmp{w}\t{*}$dst", []>, OpSize;
Sean Callanan76f14be2009-09-15 00:35:17 +0000660 def FARJMP32m : I<0xFF, MRM5m, (outs), (ins opaque48mem:$dst),
Sean Callanan9947bbb2009-09-03 00:04:47 +0000661 "ljmp{l}\t{*}$dst", []>;
Nate Begeman37efe672006-04-22 18:53:45 +0000662}
663
Chris Lattner1cca5e32003-08-03 21:54:21 +0000664
Sean Callanan7e6d7272009-09-16 21:50:07 +0000665// Loop instructions
666
Chris Lattner34b8a882010-03-18 20:50:06 +0000667def LOOP : I<0xE2, RawFrm, (outs), (ins brtarget8:$dst), "loop\t$dst", []>;
668def LOOPE : I<0xE1, RawFrm, (outs), (ins brtarget8:$dst), "loope\t$dst", []>;
669def LOOPNE : I<0xE0, RawFrm, (outs), (ins brtarget8:$dst), "loopne\t$dst", []>;
Sean Callanan7e6d7272009-09-16 21:50:07 +0000670
Chris Lattner1cca5e32003-08-03 21:54:21 +0000671//===----------------------------------------------------------------------===//
672// Call Instructions...
673//
Evan Chengffbacca2007-07-21 00:34:19 +0000674let isCall = 1 in
Dan Gohman6d4b0522008-10-01 18:28:06 +0000675 // All calls clobber the non-callee saved registers. ESP is marked as
676 // a use to prevent stack-pointer assignments that appear immediately
677 // before calls from potentially appearing dead. Uses for argument
678 // registers are added manually.
Nate Begemanf63be7d2005-07-06 18:59:04 +0000679 let Defs = [EAX, ECX, EDX, FP0, FP1, FP2, FP3, FP4, FP5, FP6, ST0,
Bill Wendling3f3a17d2007-04-25 21:31:48 +0000680 MM0, MM1, MM2, MM3, MM4, MM5, MM6, MM7,
Evan Cheng109a5622008-10-17 21:02:22 +0000681 XMM0, XMM1, XMM2, XMM3, XMM4, XMM5, XMM6, XMM7,
682 XMM8, XMM9, XMM10, XMM11, XMM12, XMM13, XMM14, XMM15, EFLAGS],
Dan Gohman2662d552008-10-01 04:14:30 +0000683 Uses = [ESP] in {
Chris Lattnera0331192010-02-12 22:27:07 +0000684 def CALLpcrel32 : Ii32PCRel<0xE8, RawFrm,
Chris Lattner7680e732009-06-20 19:34:09 +0000685 (outs), (ins i32imm_pcrel:$dst,variable_ops),
686 "call\t$dst", []>;
Evan Cheng64d80e32007-07-19 01:14:50 +0000687 def CALL32r : I<0xFF, MRM2r, (outs), (ins GR32:$dst, variable_ops),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000688 "call\t{*}$dst", [(X86call GR32:$dst)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +0000689 def CALL32m : I<0xFF, MRM2m, (outs), (ins i32mem:$dst, variable_ops),
Dan Gohmanb4106172008-05-29 21:50:34 +0000690 "call\t{*}$dst", [(X86call (loadi32 addr:$dst))]>;
Sean Callanan9947bbb2009-09-03 00:04:47 +0000691
Sean Callanan76f14be2009-09-15 00:35:17 +0000692 def FARCALL16i : Iseg16<0x9A, RawFrm, (outs),
693 (ins i16imm:$seg, i16imm:$off),
694 "lcall{w}\t$seg, $off", []>, OpSize;
695 def FARCALL32i : Iseg32<0x9A, RawFrm, (outs),
696 (ins i16imm:$seg, i32imm:$off),
697 "lcall{l}\t$seg, $off", []>;
698
699 def FARCALL16m : I<0xFF, MRM3m, (outs), (ins opaque32mem:$dst),
Sean Callanan9947bbb2009-09-03 00:04:47 +0000700 "lcall{w}\t{*}$dst", []>, OpSize;
Sean Callanan76f14be2009-09-15 00:35:17 +0000701 def FARCALL32m : I<0xFF, MRM3m, (outs), (ins opaque48mem:$dst),
Sean Callanan9947bbb2009-09-03 00:04:47 +0000702 "lcall{l}\t{*}$dst", []>;
Chris Lattner1cca5e32003-08-03 21:54:21 +0000703 }
704
Sean Callanan8d708542009-09-16 02:57:13 +0000705// Constructing a stack frame.
706
707def ENTER : I<0xC8, RawFrm, (outs), (ins i16imm:$len, i8imm:$lvl),
708 "enter\t$len, $lvl", []>;
709
Chris Lattner1e9448b2005-05-15 03:10:37 +0000710// Tail call stuff.
Arnold Schwaighoferc85e1712007-10-11 19:40:01 +0000711
Evan Chengffbacca2007-07-21 00:34:19 +0000712let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1 in
Evan Chengf48ef032010-03-14 03:48:46 +0000713 let Defs = [EAX, ECX, EDX, FP0, FP1, FP2, FP3, FP4, FP5, FP6, ST0,
714 MM0, MM1, MM2, MM3, MM4, MM5, MM6, MM7,
715 XMM0, XMM1, XMM2, XMM3, XMM4, XMM5, XMM6, XMM7,
716 XMM8, XMM9, XMM10, XMM11, XMM12, XMM13, XMM14, XMM15, EFLAGS],
717 Uses = [ESP] in {
718 def TCRETURNdi : I<0, Pseudo, (outs),
719 (ins i32imm_pcrel:$dst, i32imm:$offset, variable_ops),
720 "#TC_RETURN $dst $offset", []>;
721 def TCRETURNri : I<0, Pseudo, (outs),
722 (ins GR32_TC:$dst, i32imm:$offset, variable_ops),
723 "#TC_RETURN $dst $offset", []>;
724 def TCRETURNmi : I<0, Pseudo, (outs),
725 (ins i32mem_TC:$dst, i32imm:$offset, variable_ops),
726 "#TC_RETURN $dst $offset", []>;
Arnold Schwaighoferc85e1712007-10-11 19:40:01 +0000727
Evan Chengf48ef032010-03-14 03:48:46 +0000728 // FIXME: The should be pseudo instructions that are lowered when going to
729 // mcinst.
Chris Lattner840e6372010-03-16 06:30:18 +0000730 def TAILJMPd : Ii32PCRel<0xE9, RawFrm, (outs),
731 (ins i32imm_pcrel:$dst, variable_ops),
Evan Chengaa92bec2010-01-31 07:28:44 +0000732 "jmp\t$dst # TAILCALL",
Evan Chengf10c17f2006-09-22 21:43:59 +0000733 []>;
Evan Chengf48ef032010-03-14 03:48:46 +0000734 def TAILJMPr : I<0xFF, MRM4r, (outs), (ins GR32_TC:$dst, variable_ops),
Sean Callanan108934c2009-12-18 00:01:26 +0000735 "jmp{l}\t{*}$dst # TAILCALL",
Arnold Schwaighoferc85e1712007-10-11 19:40:01 +0000736 []>;
Evan Chengf48ef032010-03-14 03:48:46 +0000737 def TAILJMPm : I<0xFF, MRM4m, (outs), (ins i32mem_TC:$dst, variable_ops),
738 "jmp{l}\t{*}$dst # TAILCALL", []>;
739}
Chris Lattner1e9448b2005-05-15 03:10:37 +0000740
Chris Lattner1cca5e32003-08-03 21:54:21 +0000741//===----------------------------------------------------------------------===//
742// Miscellaneous Instructions...
743//
Chris Lattnerba7e7562008-01-10 07:59:24 +0000744let Defs = [EBP, ESP], Uses = [EBP, ESP], mayLoad = 1, neverHasSideEffects=1 in
Chris Lattner30bf2d82004-08-10 20:17:41 +0000745def LEAVE : I<0xC9, RawFrm,
Evan Cheng071a2792007-09-11 19:55:27 +0000746 (outs), (ins), "leave", []>;
747
Sean Callanan108934c2009-12-18 00:01:26 +0000748def POPCNT16rr : I<0xB8, MRMSrcReg, (outs GR16:$dst), (ins GR16:$src),
749 "popcnt{w}\t{$src, $dst|$dst, $src}", []>, OpSize, XS;
750def POPCNT16rm : I<0xB8, MRMSrcMem, (outs GR16:$dst), (ins i16mem:$src),
751 "popcnt{w}\t{$src, $dst|$dst, $src}", []>, OpSize, XS;
752def POPCNT32rr : I<0xB8, MRMSrcReg, (outs GR32:$dst), (ins GR32:$src),
753 "popcnt{l}\t{$src, $dst|$dst, $src}", []>, XS;
754def POPCNT32rm : I<0xB8, MRMSrcMem, (outs GR32:$dst), (ins i32mem:$src),
755 "popcnt{l}\t{$src, $dst|$dst, $src}", []>, XS;
756
Chris Lattnerba7e7562008-01-10 07:59:24 +0000757let Defs = [ESP], Uses = [ESP], neverHasSideEffects=1 in {
Sean Callanan1f24e012009-09-10 18:29:13 +0000758let mayLoad = 1 in {
759def POP16r : I<0x58, AddRegFrm, (outs GR16:$reg), (ins), "pop{w}\t$reg", []>,
760 OpSize;
761def POP32r : I<0x58, AddRegFrm, (outs GR32:$reg), (ins), "pop{l}\t$reg", []>;
762def POP16rmr: I<0x8F, MRM0r, (outs GR16:$reg), (ins), "pop{w}\t$reg", []>,
763 OpSize;
764def POP16rmm: I<0x8F, MRM0m, (outs i16mem:$dst), (ins), "pop{w}\t$dst", []>,
765 OpSize;
766def POP32rmr: I<0x8F, MRM0r, (outs GR32:$reg), (ins), "pop{l}\t$reg", []>;
767def POP32rmm: I<0x8F, MRM0m, (outs i32mem:$dst), (ins), "pop{l}\t$dst", []>;
768}
Chris Lattner1cca5e32003-08-03 21:54:21 +0000769
Sean Callanan1f24e012009-09-10 18:29:13 +0000770let mayStore = 1 in {
771def PUSH16r : I<0x50, AddRegFrm, (outs), (ins GR16:$reg), "push{w}\t$reg",[]>,
772 OpSize;
Evan Cheng2f245ba2007-09-26 01:29:06 +0000773def PUSH32r : I<0x50, AddRegFrm, (outs), (ins GR32:$reg), "push{l}\t$reg",[]>;
Sean Callanan1f24e012009-09-10 18:29:13 +0000774def PUSH16rmr: I<0xFF, MRM6r, (outs), (ins GR16:$reg), "push{w}\t$reg",[]>,
775 OpSize;
776def PUSH16rmm: I<0xFF, MRM6m, (outs), (ins i16mem:$src), "push{w}\t$src",[]>,
777 OpSize;
778def PUSH32rmr: I<0xFF, MRM6r, (outs), (ins GR32:$reg), "push{l}\t$reg",[]>;
779def PUSH32rmm: I<0xFF, MRM6m, (outs), (ins i32mem:$src), "push{l}\t$src",[]>;
780}
Evan Cheng071a2792007-09-11 19:55:27 +0000781}
Anton Korobeynikov57fc00d2007-04-17 09:20:00 +0000782
Bill Wendling453eb262009-06-15 19:39:04 +0000783let Defs = [ESP], Uses = [ESP], neverHasSideEffects = 1, mayStore = 1 in {
784def PUSH32i8 : Ii8<0x6a, RawFrm, (outs), (ins i8imm:$imm),
Bill Wendling927788c2009-06-15 20:59:31 +0000785 "push{l}\t$imm", []>;
Bill Wendling453eb262009-06-15 19:39:04 +0000786def PUSH32i16 : Ii16<0x68, RawFrm, (outs), (ins i16imm:$imm),
Bill Wendling927788c2009-06-15 20:59:31 +0000787 "push{l}\t$imm", []>;
Bill Wendling453eb262009-06-15 19:39:04 +0000788def PUSH32i32 : Ii32<0x68, RawFrm, (outs), (ins i32imm:$imm),
Bill Wendling927788c2009-06-15 20:59:31 +0000789 "push{l}\t$imm", []>;
Bill Wendling453eb262009-06-15 19:39:04 +0000790}
791
Sean Callanan108934c2009-12-18 00:01:26 +0000792let Defs = [ESP, EFLAGS], Uses = [ESP], mayLoad = 1, neverHasSideEffects=1 in {
793def POPF : I<0x9D, RawFrm, (outs), (ins), "popf{w}", []>, OpSize;
794def POPFD : I<0x9D, RawFrm, (outs), (ins), "popf{l}", []>;
795}
796let Defs = [ESP], Uses = [ESP, EFLAGS], mayStore = 1, neverHasSideEffects=1 in {
797def PUSHF : I<0x9C, RawFrm, (outs), (ins), "pushf{w}", []>, OpSize;
798def PUSHFD : I<0x9C, RawFrm, (outs), (ins), "pushf{l}", []>;
799}
Evan Cheng2f245ba2007-09-26 01:29:06 +0000800
Evan Cheng069287d2006-05-16 07:21:53 +0000801let isTwoAddress = 1 in // GR32 = bswap GR32
Chris Lattner30bf2d82004-08-10 20:17:41 +0000802 def BSWAP32r : I<0xC8, AddRegFrm,
Evan Cheng64d80e32007-07-19 01:14:50 +0000803 (outs GR32:$dst), (ins GR32:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000804 "bswap{l}\t$dst",
Evan Cheng069287d2006-05-16 07:21:53 +0000805 [(set GR32:$dst, (bswap GR32:$src))]>, TB;
Chris Lattner1cca5e32003-08-03 21:54:21 +0000806
Chris Lattner1cca5e32003-08-03 21:54:21 +0000807
Evan Cheng18efe262007-12-14 02:13:44 +0000808// Bit scan instructions.
809let Defs = [EFLAGS] in {
Evan Chengfd9e4732007-12-14 18:49:43 +0000810def BSF16rr : I<0xBC, MRMSrcReg, (outs GR16:$dst), (ins GR16:$src),
Dan Gohman1a8001e2007-12-14 15:10:00 +0000811 "bsf{w}\t{$src, $dst|$dst, $src}",
Chris Lattnerd486d772010-03-28 05:07:17 +0000812 [(set GR16:$dst, EFLAGS, (X86bsf GR16:$src))]>, TB;
Evan Cheng18efe262007-12-14 02:13:44 +0000813def BSF16rm : I<0xBC, MRMSrcMem, (outs GR16:$dst), (ins i16mem:$src),
Dan Gohman1a8001e2007-12-14 15:10:00 +0000814 "bsf{w}\t{$src, $dst|$dst, $src}",
Chris Lattnerd486d772010-03-28 05:07:17 +0000815 [(set GR16:$dst, EFLAGS, (X86bsf (loadi16 addr:$src)))]>, TB;
Evan Chengfd9e4732007-12-14 18:49:43 +0000816def BSF32rr : I<0xBC, MRMSrcReg, (outs GR32:$dst), (ins GR32:$src),
Dan Gohman1a8001e2007-12-14 15:10:00 +0000817 "bsf{l}\t{$src, $dst|$dst, $src}",
Chris Lattnerd486d772010-03-28 05:07:17 +0000818 [(set GR32:$dst, EFLAGS, (X86bsf GR32:$src))]>, TB;
Evan Cheng18efe262007-12-14 02:13:44 +0000819def BSF32rm : I<0xBC, MRMSrcMem, (outs GR32:$dst), (ins i32mem:$src),
Dan Gohman1a8001e2007-12-14 15:10:00 +0000820 "bsf{l}\t{$src, $dst|$dst, $src}",
Chris Lattnerd486d772010-03-28 05:07:17 +0000821 [(set GR32:$dst, EFLAGS, (X86bsf (loadi32 addr:$src)))]>, TB;
Evan Cheng18efe262007-12-14 02:13:44 +0000822
Evan Chengfd9e4732007-12-14 18:49:43 +0000823def BSR16rr : I<0xBD, MRMSrcReg, (outs GR16:$dst), (ins GR16:$src),
Dan Gohman1a8001e2007-12-14 15:10:00 +0000824 "bsr{w}\t{$src, $dst|$dst, $src}",
Chris Lattnerd486d772010-03-28 05:07:17 +0000825 [(set GR16:$dst, EFLAGS, (X86bsr GR16:$src))]>, TB;
Evan Cheng18efe262007-12-14 02:13:44 +0000826def BSR16rm : I<0xBD, MRMSrcMem, (outs GR16:$dst), (ins i16mem:$src),
Dan Gohman1a8001e2007-12-14 15:10:00 +0000827 "bsr{w}\t{$src, $dst|$dst, $src}",
Chris Lattnerd486d772010-03-28 05:07:17 +0000828 [(set GR16:$dst, EFLAGS, (X86bsr (loadi16 addr:$src)))]>, TB;
Evan Chengfd9e4732007-12-14 18:49:43 +0000829def BSR32rr : I<0xBD, MRMSrcReg, (outs GR32:$dst), (ins GR32:$src),
Dan Gohman1a8001e2007-12-14 15:10:00 +0000830 "bsr{l}\t{$src, $dst|$dst, $src}",
Chris Lattnerd486d772010-03-28 05:07:17 +0000831 [(set GR32:$dst, EFLAGS, (X86bsr GR32:$src))]>, TB;
Evan Cheng18efe262007-12-14 02:13:44 +0000832def BSR32rm : I<0xBD, MRMSrcMem, (outs GR32:$dst), (ins i32mem:$src),
Dan Gohman1a8001e2007-12-14 15:10:00 +0000833 "bsr{l}\t{$src, $dst|$dst, $src}",
Chris Lattnerd486d772010-03-28 05:07:17 +0000834 [(set GR32:$dst, EFLAGS, (X86bsr (loadi32 addr:$src)))]>, TB;
Evan Cheng18efe262007-12-14 02:13:44 +0000835} // Defs = [EFLAGS]
836
Chris Lattnerba7e7562008-01-10 07:59:24 +0000837let neverHasSideEffects = 1 in
Chris Lattner3a173df2004-10-03 20:35:00 +0000838def LEA16r : I<0x8D, MRMSrcMem,
Evan Cheng15b0d972009-12-12 18:51:56 +0000839 (outs GR16:$dst), (ins lea32mem:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000840 "lea{w}\t{$src|$dst}, {$dst|$src}", []>, OpSize;
Evan Chenge771ebd2008-03-27 01:41:09 +0000841let isReMaterializable = 1 in
Chris Lattner3a173df2004-10-03 20:35:00 +0000842def LEA32r : I<0x8D, MRMSrcMem,
Evan Cheng64d80e32007-07-19 01:14:50 +0000843 (outs GR32:$dst), (ins lea32mem:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000844 "lea{l}\t{$src|$dst}, {$dst|$src}",
Evan Cheng25ab6902006-09-08 06:48:29 +0000845 [(set GR32:$dst, lea32addr:$src)]>, Requires<[In32BitMode]>;
Chris Lattner1cca5e32003-08-03 21:54:21 +0000846
Kevin Enderby12ce0de2010-02-03 21:04:42 +0000847let Defs = [ECX,EDI,ESI], Uses = [ECX,EDI,ESI], isCodeGenOnly = 1 in {
Evan Cheng64d80e32007-07-19 01:14:50 +0000848def REP_MOVSB : I<0xA4, RawFrm, (outs), (ins), "{rep;movsb|rep movsb}",
Evan Cheng071a2792007-09-11 19:55:27 +0000849 [(X86rep_movs i8)]>, REP;
Evan Cheng64d80e32007-07-19 01:14:50 +0000850def REP_MOVSW : I<0xA5, RawFrm, (outs), (ins), "{rep;movsw|rep movsw}",
Evan Cheng071a2792007-09-11 19:55:27 +0000851 [(X86rep_movs i16)]>, REP, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +0000852def REP_MOVSD : I<0xA5, RawFrm, (outs), (ins), "{rep;movsl|rep movsd}",
Evan Cheng071a2792007-09-11 19:55:27 +0000853 [(X86rep_movs i32)]>, REP;
854}
Chris Lattner915e5e52004-02-12 17:53:22 +0000855
Kevin Enderby12ce0de2010-02-03 21:04:42 +0000856// These uses the DF flag in the EFLAGS register to inc or dec EDI and ESI
857let Defs = [EDI,ESI], Uses = [EDI,ESI,EFLAGS] in {
858def MOVSB : I<0xA4, RawFrm, (outs), (ins), "{movsb}", []>;
859def MOVSW : I<0xA5, RawFrm, (outs), (ins), "{movsw}", []>, OpSize;
860def MOVSD : I<0xA5, RawFrm, (outs), (ins), "{movsl|movsd}", []>;
861}
862
863let Defs = [ECX,EDI], Uses = [AL,ECX,EDI], isCodeGenOnly = 1 in
Evan Cheng64d80e32007-07-19 01:14:50 +0000864def REP_STOSB : I<0xAA, RawFrm, (outs), (ins), "{rep;stosb|rep stosb}",
Evan Cheng071a2792007-09-11 19:55:27 +0000865 [(X86rep_stos i8)]>, REP;
Kevin Enderby12ce0de2010-02-03 21:04:42 +0000866let Defs = [ECX,EDI], Uses = [AX,ECX,EDI], isCodeGenOnly = 1 in
Evan Cheng64d80e32007-07-19 01:14:50 +0000867def REP_STOSW : I<0xAB, RawFrm, (outs), (ins), "{rep;stosw|rep stosw}",
Evan Cheng071a2792007-09-11 19:55:27 +0000868 [(X86rep_stos i16)]>, REP, OpSize;
Kevin Enderby12ce0de2010-02-03 21:04:42 +0000869let Defs = [ECX,EDI], Uses = [EAX,ECX,EDI], isCodeGenOnly = 1 in
Evan Cheng64d80e32007-07-19 01:14:50 +0000870def REP_STOSD : I<0xAB, RawFrm, (outs), (ins), "{rep;stosl|rep stosd}",
Evan Cheng071a2792007-09-11 19:55:27 +0000871 [(X86rep_stos i32)]>, REP;
Chris Lattner30bf2d82004-08-10 20:17:41 +0000872
Kevin Enderby12ce0de2010-02-03 21:04:42 +0000873// These uses the DF flag in the EFLAGS register to inc or dec EDI and ESI
874let Defs = [EDI], Uses = [AL,EDI,EFLAGS] in
875def STOSB : I<0xAA, RawFrm, (outs), (ins), "{stosb}", []>;
876let Defs = [EDI], Uses = [AX,EDI,EFLAGS] in
877def STOSW : I<0xAB, RawFrm, (outs), (ins), "{stosw}", []>, OpSize;
878let Defs = [EDI], Uses = [EAX,EDI,EFLAGS] in
879def STOSD : I<0xAB, RawFrm, (outs), (ins), "{stosl|stosd}", []>;
880
Sean Callanana82e4652009-09-12 00:37:19 +0000881def SCAS8 : I<0xAE, RawFrm, (outs), (ins), "scas{b}", []>;
882def SCAS16 : I<0xAF, RawFrm, (outs), (ins), "scas{w}", []>, OpSize;
883def SCAS32 : I<0xAF, RawFrm, (outs), (ins), "scas{l}", []>;
884
Sean Callanan6f8f4622009-09-12 02:25:20 +0000885def CMPS8 : I<0xA6, RawFrm, (outs), (ins), "cmps{b}", []>;
886def CMPS16 : I<0xA7, RawFrm, (outs), (ins), "cmps{w}", []>, OpSize;
887def CMPS32 : I<0xA7, RawFrm, (outs), (ins), "cmps{l}", []>;
888
Evan Cheng071a2792007-09-11 19:55:27 +0000889let Defs = [RAX, RDX] in
Evan Cheng64d80e32007-07-19 01:14:50 +0000890def RDTSC : I<0x31, RawFrm, (outs), (ins), "rdtsc", [(X86rdtsc)]>,
Evan Cheng071a2792007-09-11 19:55:27 +0000891 TB;
Chris Lattnerb89abef2004-02-14 04:45:37 +0000892
Sean Callanancebe9552010-02-13 02:06:11 +0000893let Defs = [RAX, RCX, RDX] in
894def RDTSCP : I<0x01, MRM_F9, (outs), (ins), "rdtscp", []>, TB;
895
Anton Korobeynikov66fac792008-01-15 07:02:33 +0000896let isBarrier = 1, hasCtrlDep = 1 in {
Chris Lattnerda68d302008-01-15 21:58:22 +0000897def TRAP : I<0x0B, RawFrm, (outs), (ins), "ud2", [(trap)]>, TB;
Anton Korobeynikov66fac792008-01-15 07:02:33 +0000898}
899
Chris Lattner02552de2009-08-11 16:58:39 +0000900def SYSCALL : I<0x05, RawFrm,
901 (outs), (ins), "syscall", []>, TB;
902def SYSRET : I<0x07, RawFrm,
903 (outs), (ins), "sysret", []>, TB;
904def SYSENTER : I<0x34, RawFrm,
905 (outs), (ins), "sysenter", []>, TB;
906def SYSEXIT : I<0x35, RawFrm,
907 (outs), (ins), "sysexit", []>, TB;
908
Sean Callanan2a46f362009-09-12 02:52:41 +0000909def WAIT : I<0x9B, RawFrm, (outs), (ins), "wait", []>;
Chris Lattner02552de2009-08-11 16:58:39 +0000910
911
Chris Lattner1cca5e32003-08-03 21:54:21 +0000912//===----------------------------------------------------------------------===//
John Criswell4ffff9e2004-04-08 20:31:47 +0000913// Input/Output Instructions...
914//
Evan Cheng071a2792007-09-11 19:55:27 +0000915let Defs = [AL], Uses = [DX] in
Evan Cheng64d80e32007-07-19 01:14:50 +0000916def IN8rr : I<0xEC, RawFrm, (outs), (ins),
Evan Cheng071a2792007-09-11 19:55:27 +0000917 "in{b}\t{%dx, %al|%AL, %DX}", []>;
918let Defs = [AX], Uses = [DX] in
Evan Cheng64d80e32007-07-19 01:14:50 +0000919def IN16rr : I<0xED, RawFrm, (outs), (ins),
Evan Cheng071a2792007-09-11 19:55:27 +0000920 "in{w}\t{%dx, %ax|%AX, %DX}", []>, OpSize;
921let Defs = [EAX], Uses = [DX] in
Evan Cheng64d80e32007-07-19 01:14:50 +0000922def IN32rr : I<0xED, RawFrm, (outs), (ins),
Evan Cheng071a2792007-09-11 19:55:27 +0000923 "in{l}\t{%dx, %eax|%EAX, %DX}", []>;
John Criswell4ffff9e2004-04-08 20:31:47 +0000924
Evan Cheng071a2792007-09-11 19:55:27 +0000925let Defs = [AL] in
Evan Cheng64d80e32007-07-19 01:14:50 +0000926def IN8ri : Ii8<0xE4, RawFrm, (outs), (ins i16i8imm:$port),
Evan Cheng071a2792007-09-11 19:55:27 +0000927 "in{b}\t{$port, %al|%AL, $port}", []>;
928let Defs = [AX] in
Evan Cheng64d80e32007-07-19 01:14:50 +0000929def IN16ri : Ii8<0xE5, RawFrm, (outs), (ins i16i8imm:$port),
Evan Cheng071a2792007-09-11 19:55:27 +0000930 "in{w}\t{$port, %ax|%AX, $port}", []>, OpSize;
931let Defs = [EAX] in
Evan Cheng64d80e32007-07-19 01:14:50 +0000932def IN32ri : Ii8<0xE5, RawFrm, (outs), (ins i16i8imm:$port),
Evan Cheng071a2792007-09-11 19:55:27 +0000933 "in{l}\t{$port, %eax|%EAX, $port}", []>;
Chris Lattner440bbc22004-04-13 17:19:31 +0000934
Evan Cheng071a2792007-09-11 19:55:27 +0000935let Uses = [DX, AL] in
Evan Cheng64d80e32007-07-19 01:14:50 +0000936def OUT8rr : I<0xEE, RawFrm, (outs), (ins),
Evan Cheng071a2792007-09-11 19:55:27 +0000937 "out{b}\t{%al, %dx|%DX, %AL}", []>;
938let Uses = [DX, AX] in
Evan Cheng64d80e32007-07-19 01:14:50 +0000939def OUT16rr : I<0xEF, RawFrm, (outs), (ins),
Evan Cheng071a2792007-09-11 19:55:27 +0000940 "out{w}\t{%ax, %dx|%DX, %AX}", []>, OpSize;
941let Uses = [DX, EAX] in
Evan Cheng64d80e32007-07-19 01:14:50 +0000942def OUT32rr : I<0xEF, RawFrm, (outs), (ins),
Evan Cheng071a2792007-09-11 19:55:27 +0000943 "out{l}\t{%eax, %dx|%DX, %EAX}", []>;
Chris Lattnerffff7082004-08-01 07:44:35 +0000944
Evan Cheng071a2792007-09-11 19:55:27 +0000945let Uses = [AL] in
Evan Cheng64d80e32007-07-19 01:14:50 +0000946def OUT8ir : Ii8<0xE6, RawFrm, (outs), (ins i16i8imm:$port),
Evan Cheng071a2792007-09-11 19:55:27 +0000947 "out{b}\t{%al, $port|$port, %AL}", []>;
948let Uses = [AX] in
Evan Cheng64d80e32007-07-19 01:14:50 +0000949def OUT16ir : Ii8<0xE7, RawFrm, (outs), (ins i16i8imm:$port),
Evan Cheng071a2792007-09-11 19:55:27 +0000950 "out{w}\t{%ax, $port|$port, %AX}", []>, OpSize;
951let Uses = [EAX] in
Evan Cheng64d80e32007-07-19 01:14:50 +0000952def OUT32ir : Ii8<0xE7, RawFrm, (outs), (ins i16i8imm:$port),
Evan Cheng071a2792007-09-11 19:55:27 +0000953 "out{l}\t{%eax, $port|$port, %EAX}", []>;
John Criswell4ffff9e2004-04-08 20:31:47 +0000954
Sean Callanan108934c2009-12-18 00:01:26 +0000955def IN8 : I<0x6C, RawFrm, (outs), (ins),
956 "ins{b}", []>;
957def IN16 : I<0x6D, RawFrm, (outs), (ins),
958 "ins{w}", []>, OpSize;
959def IN32 : I<0x6D, RawFrm, (outs), (ins),
960 "ins{l}", []>;
961
John Criswell4ffff9e2004-04-08 20:31:47 +0000962//===----------------------------------------------------------------------===//
Chris Lattner1cca5e32003-08-03 21:54:21 +0000963// Move Instructions...
964//
Chris Lattnerba7e7562008-01-10 07:59:24 +0000965let neverHasSideEffects = 1 in {
Evan Cheng64d80e32007-07-19 01:14:50 +0000966def MOV8rr : I<0x88, MRMDestReg, (outs GR8 :$dst), (ins GR8 :$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000967 "mov{b}\t{$src, $dst|$dst, $src}", []>;
Evan Cheng64d80e32007-07-19 01:14:50 +0000968def MOV16rr : I<0x89, MRMDestReg, (outs GR16:$dst), (ins GR16:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000969 "mov{w}\t{$src, $dst|$dst, $src}", []>, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +0000970def MOV32rr : I<0x89, MRMDestReg, (outs GR32:$dst), (ins GR32:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000971 "mov{l}\t{$src, $dst|$dst, $src}", []>;
Chris Lattnerba7e7562008-01-10 07:59:24 +0000972}
Evan Cheng359e9372008-06-18 08:13:07 +0000973let isReMaterializable = 1, isAsCheapAsAMove = 1 in {
Evan Cheng64d80e32007-07-19 01:14:50 +0000974def MOV8ri : Ii8 <0xB0, AddRegFrm, (outs GR8 :$dst), (ins i8imm :$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000975 "mov{b}\t{$src, $dst|$dst, $src}",
Evan Cheng069287d2006-05-16 07:21:53 +0000976 [(set GR8:$dst, imm:$src)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +0000977def MOV16ri : Ii16<0xB8, AddRegFrm, (outs GR16:$dst), (ins i16imm:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000978 "mov{w}\t{$src, $dst|$dst, $src}",
Evan Cheng069287d2006-05-16 07:21:53 +0000979 [(set GR16:$dst, imm:$src)]>, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +0000980def MOV32ri : Ii32<0xB8, AddRegFrm, (outs GR32:$dst), (ins i32imm:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000981 "mov{l}\t{$src, $dst|$dst, $src}",
Evan Cheng069287d2006-05-16 07:21:53 +0000982 [(set GR32:$dst, imm:$src)]>;
Dan Gohmand45eddd2007-06-26 00:48:07 +0000983}
Kevin Enderby12ce0de2010-02-03 21:04:42 +0000984
Evan Cheng64d80e32007-07-19 01:14:50 +0000985def MOV8mi : Ii8 <0xC6, MRM0m, (outs), (ins i8mem :$dst, i8imm :$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000986 "mov{b}\t{$src, $dst|$dst, $src}",
Evan Chengb51a0592005-12-10 00:48:20 +0000987 [(store (i8 imm:$src), addr:$dst)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +0000988def MOV16mi : Ii16<0xC7, MRM0m, (outs), (ins i16mem:$dst, i16imm:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000989 "mov{w}\t{$src, $dst|$dst, $src}",
Evan Chengb51a0592005-12-10 00:48:20 +0000990 [(store (i16 imm:$src), addr:$dst)]>, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +0000991def MOV32mi : Ii32<0xC7, MRM0m, (outs), (ins i32mem:$dst, i32imm:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000992 "mov{l}\t{$src, $dst|$dst, $src}",
Evan Chengb51a0592005-12-10 00:48:20 +0000993 [(store (i32 imm:$src), addr:$dst)]>;
Chris Lattner1cca5e32003-08-03 21:54:21 +0000994
Sean Callanan108934c2009-12-18 00:01:26 +0000995def MOV8o8a : Ii8 <0xA0, RawFrm, (outs), (ins offset8:$src),
Sean Callanan2f34a132009-09-10 18:33:42 +0000996 "mov{b}\t{$src, %al|%al, $src}", []>;
Sean Callanan108934c2009-12-18 00:01:26 +0000997def MOV16o16a : Ii16 <0xA1, RawFrm, (outs), (ins offset16:$src),
Sean Callanan2f34a132009-09-10 18:33:42 +0000998 "mov{w}\t{$src, %ax|%ax, $src}", []>, OpSize;
Sean Callanan108934c2009-12-18 00:01:26 +0000999def MOV32o32a : Ii32 <0xA1, RawFrm, (outs), (ins offset32:$src),
Sean Callanan2f34a132009-09-10 18:33:42 +00001000 "mov{l}\t{$src, %eax|%eax, $src}", []>;
1001
Sean Callanan108934c2009-12-18 00:01:26 +00001002def MOV8ao8 : Ii8 <0xA2, RawFrm, (outs offset8:$dst), (ins),
Sean Callanan2f34a132009-09-10 18:33:42 +00001003 "mov{b}\t{%al, $dst|$dst, %al}", []>;
Sean Callanan108934c2009-12-18 00:01:26 +00001004def MOV16ao16 : Ii16 <0xA3, RawFrm, (outs offset16:$dst), (ins),
Sean Callanan2f34a132009-09-10 18:33:42 +00001005 "mov{w}\t{%ax, $dst|$dst, %ax}", []>, OpSize;
Sean Callanan108934c2009-12-18 00:01:26 +00001006def MOV32ao32 : Ii32 <0xA3, RawFrm, (outs offset32:$dst), (ins),
Sean Callanan2f34a132009-09-10 18:33:42 +00001007 "mov{l}\t{%eax, $dst|$dst, %eax}", []>;
1008
Sean Callanan38fee0e2009-09-15 18:47:29 +00001009// Moves to and from segment registers
1010def MOV16rs : I<0x8C, MRMDestReg, (outs GR16:$dst), (ins SEGMENT_REG:$src),
1011 "mov{w}\t{$src, $dst|$dst, $src}", []>;
1012def MOV16ms : I<0x8C, MRMDestMem, (outs i16mem:$dst), (ins SEGMENT_REG:$src),
1013 "mov{w}\t{$src, $dst|$dst, $src}", []>;
1014def MOV16sr : I<0x8E, MRMSrcReg, (outs SEGMENT_REG:$dst), (ins GR16:$src),
1015 "mov{w}\t{$src, $dst|$dst, $src}", []>;
1016def MOV16sm : I<0x8E, MRMSrcMem, (outs SEGMENT_REG:$dst), (ins i16mem:$src),
1017 "mov{w}\t{$src, $dst|$dst, $src}", []>;
1018
Sean Callanan108934c2009-12-18 00:01:26 +00001019def MOV8rr_REV : I<0x8A, MRMSrcReg, (outs GR8:$dst), (ins GR8:$src),
1020 "mov{b}\t{$src, $dst|$dst, $src}", []>;
1021def MOV16rr_REV : I<0x8B, MRMSrcReg, (outs GR16:$dst), (ins GR16:$src),
1022 "mov{w}\t{$src, $dst|$dst, $src}", []>, OpSize;
1023def MOV32rr_REV : I<0x8B, MRMSrcReg, (outs GR32:$dst), (ins GR32:$src),
1024 "mov{l}\t{$src, $dst|$dst, $src}", []>;
1025
Dan Gohmanbc9d98b2010-02-27 23:47:46 +00001026let canFoldAsLoad = 1, isReMaterializable = 1 in {
Evan Cheng64d80e32007-07-19 01:14:50 +00001027def MOV8rm : I<0x8A, MRMSrcMem, (outs GR8 :$dst), (ins i8mem :$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001028 "mov{b}\t{$src, $dst|$dst, $src}",
Chris Lattnerc2406f22009-04-10 00:16:23 +00001029 [(set GR8:$dst, (loadi8 addr:$src))]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00001030def MOV16rm : I<0x8B, MRMSrcMem, (outs GR16:$dst), (ins i16mem:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001031 "mov{w}\t{$src, $dst|$dst, $src}",
Chris Lattnerc2406f22009-04-10 00:16:23 +00001032 [(set GR16:$dst, (loadi16 addr:$src))]>, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00001033def MOV32rm : I<0x8B, MRMSrcMem, (outs GR32:$dst), (ins i32mem:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001034 "mov{l}\t{$src, $dst|$dst, $src}",
Chris Lattnerc2406f22009-04-10 00:16:23 +00001035 [(set GR32:$dst, (loadi32 addr:$src))]>;
Evan Cheng2f394262007-08-30 05:49:43 +00001036}
Chris Lattner1cca5e32003-08-03 21:54:21 +00001037
Evan Cheng64d80e32007-07-19 01:14:50 +00001038def MOV8mr : I<0x88, MRMDestMem, (outs), (ins i8mem :$dst, GR8 :$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001039 "mov{b}\t{$src, $dst|$dst, $src}",
Evan Cheng069287d2006-05-16 07:21:53 +00001040 [(store GR8:$src, addr:$dst)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00001041def MOV16mr : I<0x89, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001042 "mov{w}\t{$src, $dst|$dst, $src}",
Evan Cheng069287d2006-05-16 07:21:53 +00001043 [(store GR16:$src, addr:$dst)]>, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00001044def MOV32mr : I<0x89, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001045 "mov{l}\t{$src, $dst|$dst, $src}",
Evan Cheng069287d2006-05-16 07:21:53 +00001046 [(store GR32:$src, addr:$dst)]>;
Dan Gohman21e3dfb2009-04-13 16:09:41 +00001047
Evan Chengf48ef032010-03-14 03:48:46 +00001048/// Versions of MOV32rr, MOV32rm, and MOV32mr for i32mem_TC and GR32_TC.
1049let neverHasSideEffects = 1 in
1050def MOV32rr_TC : I<0x89, MRMDestReg, (outs GR32_TC:$dst), (ins GR32_TC:$src),
1051 "mov{l}\t{$src, $dst|$dst, $src}", []>;
1052
1053let mayLoad = 1,
1054 canFoldAsLoad = 1, isReMaterializable = 1 in
1055def MOV32rm_TC : I<0x8B, MRMSrcMem, (outs GR32_TC:$dst), (ins i32mem_TC:$src),
1056 "mov{l}\t{$src, $dst|$dst, $src}",
1057 []>;
1058
1059let mayStore = 1 in
1060def MOV32mr_TC : I<0x89, MRMDestMem, (outs), (ins i32mem_TC:$dst, GR32_TC:$src),
1061 "mov{l}\t{$src, $dst|$dst, $src}",
1062 []>;
1063
Dan Gohman4af325d2009-04-27 16:41:36 +00001064// Versions of MOV8rr, MOV8mr, and MOV8rm that use i8mem_NOREX and GR8_NOREX so
1065// that they can be used for copying and storing h registers, which can't be
1066// encoded when a REX prefix is present.
Dan Gohman6d9305c2009-04-15 00:04:23 +00001067let neverHasSideEffects = 1 in
Dan Gohmandf7dfc72009-04-15 19:48:57 +00001068def MOV8rr_NOREX : I<0x88, MRMDestReg,
1069 (outs GR8_NOREX:$dst), (ins GR8_NOREX:$src),
Dan Gohman6d9305c2009-04-15 00:04:23 +00001070 "mov{b}\t{$src, $dst|$dst, $src} # NOREX", []>;
Evan Cheng8c147402009-04-30 00:58:57 +00001071let mayStore = 1 in
Dan Gohman6d9305c2009-04-15 00:04:23 +00001072def MOV8mr_NOREX : I<0x88, MRMDestMem,
1073 (outs), (ins i8mem_NOREX:$dst, GR8_NOREX:$src),
1074 "mov{b}\t{$src, $dst|$dst, $src} # NOREX", []>;
Evan Cheng8c147402009-04-30 00:58:57 +00001075let mayLoad = 1,
Dan Gohmanbc9d98b2010-02-27 23:47:46 +00001076 canFoldAsLoad = 1, isReMaterializable = 1 in
Dan Gohman4af325d2009-04-27 16:41:36 +00001077def MOV8rm_NOREX : I<0x8A, MRMSrcMem,
1078 (outs GR8_NOREX:$dst), (ins i8mem_NOREX:$src),
1079 "mov{b}\t{$src, $dst|$dst, $src} # NOREX", []>;
Dan Gohman21e3dfb2009-04-13 16:09:41 +00001080
Sean Callanan108934c2009-12-18 00:01:26 +00001081// Moves to and from debug registers
1082def MOV32rd : I<0x21, MRMDestReg, (outs GR32:$dst), (ins DEBUG_REG:$src),
1083 "mov{l}\t{$src, $dst|$dst, $src}", []>, TB;
1084def MOV32dr : I<0x23, MRMSrcReg, (outs DEBUG_REG:$dst), (ins GR32:$src),
1085 "mov{l}\t{$src, $dst|$dst, $src}", []>, TB;
1086
1087// Moves to and from control registers
1088def MOV32rc : I<0x20, MRMDestReg, (outs GR32:$dst), (ins CONTROL_REG_32:$src),
1089 "mov{q}\t{$src, $dst|$dst, $src}", []>, TB;
1090def MOV32cr : I<0x22, MRMSrcReg, (outs CONTROL_REG_32:$dst), (ins GR32:$src),
1091 "mov{q}\t{$src, $dst|$dst, $src}", []>, TB;
1092
Chris Lattner1cca5e32003-08-03 21:54:21 +00001093//===----------------------------------------------------------------------===//
1094// Fixed-Register Multiplication and Division Instructions...
1095//
Chris Lattner1cca5e32003-08-03 21:54:21 +00001096
Chris Lattnerc8f45872003-08-04 04:59:56 +00001097// Extra precision multiplication
Jakob Stoklund Olesen3cfe0102010-03-04 20:42:07 +00001098
1099// AL is really implied by AX, by the registers in Defs must match the
1100// SDNode results (i8, i32).
1101let Defs = [AL,EFLAGS,AX], Uses = [AL] in
Dan Gohmanb1576f52007-07-31 20:11:57 +00001102def MUL8r : I<0xF6, MRM4r, (outs), (ins GR8:$src), "mul{b}\t$src",
Evan Chengcf74a7c2006-01-15 10:05:20 +00001103 // FIXME: Used for 8-bit mul, ignore result upper 8 bits.
1104 // This probably ought to be moved to a def : Pat<> if the
1105 // syntax can be accepted.
Bill Wendlingd350e022008-12-12 21:15:41 +00001106 [(set AL, (mul AL, GR8:$src)),
1107 (implicit EFLAGS)]>; // AL,AH = AL*GR8
1108
Chris Lattnera731c9f2008-01-11 07:18:17 +00001109let Defs = [AX,DX,EFLAGS], Uses = [AX], neverHasSideEffects = 1 in
Bill Wendlingd350e022008-12-12 21:15:41 +00001110def MUL16r : I<0xF7, MRM4r, (outs), (ins GR16:$src),
1111 "mul{w}\t$src",
1112 []>, OpSize; // AX,DX = AX*GR16
1113
Chris Lattnera731c9f2008-01-11 07:18:17 +00001114let Defs = [EAX,EDX,EFLAGS], Uses = [EAX], neverHasSideEffects = 1 in
Bill Wendlingd350e022008-12-12 21:15:41 +00001115def MUL32r : I<0xF7, MRM4r, (outs), (ins GR32:$src),
1116 "mul{l}\t$src",
1117 []>; // EAX,EDX = EAX*GR32
1118
Jakob Stoklund Olesen3cfe0102010-03-04 20:42:07 +00001119let Defs = [AL,EFLAGS,AX], Uses = [AL] in
Evan Cheng64d80e32007-07-19 01:14:50 +00001120def MUL8m : I<0xF6, MRM4m, (outs), (ins i8mem :$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001121 "mul{b}\t$src",
Evan Chengcf74a7c2006-01-15 10:05:20 +00001122 // FIXME: Used for 8-bit mul, ignore result upper 8 bits.
1123 // This probably ought to be moved to a def : Pat<> if the
1124 // syntax can be accepted.
Bill Wendlingd350e022008-12-12 21:15:41 +00001125 [(set AL, (mul AL, (loadi8 addr:$src))),
1126 (implicit EFLAGS)]>; // AL,AH = AL*[mem8]
1127
Chris Lattnerba7e7562008-01-10 07:59:24 +00001128let mayLoad = 1, neverHasSideEffects = 1 in {
Evan Cheng24f2ea32007-09-14 21:48:26 +00001129let Defs = [AX,DX,EFLAGS], Uses = [AX] in
Evan Cheng64d80e32007-07-19 01:14:50 +00001130def MUL16m : I<0xF7, MRM4m, (outs), (ins i16mem:$src),
Bill Wendlingd350e022008-12-12 21:15:41 +00001131 "mul{w}\t$src",
1132 []>, OpSize; // AX,DX = AX*[mem16]
1133
Evan Cheng24f2ea32007-09-14 21:48:26 +00001134let Defs = [EAX,EDX,EFLAGS], Uses = [EAX] in
Evan Cheng64d80e32007-07-19 01:14:50 +00001135def MUL32m : I<0xF7, MRM4m, (outs), (ins i32mem:$src),
Bill Wendlingd350e022008-12-12 21:15:41 +00001136 "mul{l}\t$src",
1137 []>; // EAX,EDX = EAX*[mem32]
Chris Lattnerba7e7562008-01-10 07:59:24 +00001138}
Chris Lattner1cca5e32003-08-03 21:54:21 +00001139
Chris Lattnerba7e7562008-01-10 07:59:24 +00001140let neverHasSideEffects = 1 in {
Jakob Stoklund Olesen3cfe0102010-03-04 20:42:07 +00001141let Defs = [AL,EFLAGS,AX], Uses = [AL] in
Evan Cheng071a2792007-09-11 19:55:27 +00001142def IMUL8r : I<0xF6, MRM5r, (outs), (ins GR8:$src), "imul{b}\t$src", []>;
1143 // AL,AH = AL*GR8
Evan Cheng24f2ea32007-09-14 21:48:26 +00001144let Defs = [AX,DX,EFLAGS], Uses = [AX] in
Dan Gohmanb1576f52007-07-31 20:11:57 +00001145def IMUL16r : I<0xF7, MRM5r, (outs), (ins GR16:$src), "imul{w}\t$src", []>,
Evan Cheng071a2792007-09-11 19:55:27 +00001146 OpSize; // AX,DX = AX*GR16
Evan Cheng24f2ea32007-09-14 21:48:26 +00001147let Defs = [EAX,EDX,EFLAGS], Uses = [EAX] in
Evan Cheng071a2792007-09-11 19:55:27 +00001148def IMUL32r : I<0xF7, MRM5r, (outs), (ins GR32:$src), "imul{l}\t$src", []>;
1149 // EAX,EDX = EAX*GR32
Chris Lattnerba7e7562008-01-10 07:59:24 +00001150let mayLoad = 1 in {
Jakob Stoklund Olesen3cfe0102010-03-04 20:42:07 +00001151let Defs = [AL,EFLAGS,AX], Uses = [AL] in
Evan Cheng64d80e32007-07-19 01:14:50 +00001152def IMUL8m : I<0xF6, MRM5m, (outs), (ins i8mem :$src),
Evan Cheng071a2792007-09-11 19:55:27 +00001153 "imul{b}\t$src", []>; // AL,AH = AL*[mem8]
Evan Cheng24f2ea32007-09-14 21:48:26 +00001154let Defs = [AX,DX,EFLAGS], Uses = [AX] in
Evan Cheng64d80e32007-07-19 01:14:50 +00001155def IMUL16m : I<0xF7, MRM5m, (outs), (ins i16mem:$src),
Evan Cheng071a2792007-09-11 19:55:27 +00001156 "imul{w}\t$src", []>, OpSize; // AX,DX = AX*[mem16]
Eli Friedmanba7b1c42009-12-26 20:08:30 +00001157let Defs = [EAX,EDX,EFLAGS], Uses = [EAX] in
Evan Cheng64d80e32007-07-19 01:14:50 +00001158def IMUL32m : I<0xF7, MRM5m, (outs), (ins i32mem:$src),
Evan Cheng071a2792007-09-11 19:55:27 +00001159 "imul{l}\t$src", []>; // EAX,EDX = EAX*[mem32]
Chris Lattnerba7e7562008-01-10 07:59:24 +00001160}
Dan Gohmanc99da132008-11-18 21:29:14 +00001161} // neverHasSideEffects
Chris Lattner1e6a7152005-04-06 04:19:22 +00001162
Chris Lattnerc8f45872003-08-04 04:59:56 +00001163// unsigned division/remainder
Jakob Stoklund Olesen3cfe0102010-03-04 20:42:07 +00001164let Defs = [AL,EFLAGS,AX], Uses = [AX] in
Sean Callanan108934c2009-12-18 00:01:26 +00001165def DIV8r : I<0xF6, MRM6r, (outs), (ins GR8:$src), // AX/r8 = AL,AH
Evan Cheng071a2792007-09-11 19:55:27 +00001166 "div{b}\t$src", []>;
Evan Cheng24f2ea32007-09-14 21:48:26 +00001167let Defs = [AX,DX,EFLAGS], Uses = [AX,DX] in
Sean Callanan108934c2009-12-18 00:01:26 +00001168def DIV16r : I<0xF7, MRM6r, (outs), (ins GR16:$src), // DX:AX/r16 = AX,DX
Evan Cheng071a2792007-09-11 19:55:27 +00001169 "div{w}\t$src", []>, OpSize;
Evan Cheng24f2ea32007-09-14 21:48:26 +00001170let Defs = [EAX,EDX,EFLAGS], Uses = [EAX,EDX] in
Sean Callanan108934c2009-12-18 00:01:26 +00001171def DIV32r : I<0xF7, MRM6r, (outs), (ins GR32:$src), // EDX:EAX/r32 = EAX,EDX
Evan Cheng071a2792007-09-11 19:55:27 +00001172 "div{l}\t$src", []>;
Chris Lattnerba7e7562008-01-10 07:59:24 +00001173let mayLoad = 1 in {
Jakob Stoklund Olesen3cfe0102010-03-04 20:42:07 +00001174let Defs = [AL,EFLAGS,AX], Uses = [AX] in
Sean Callanan108934c2009-12-18 00:01:26 +00001175def DIV8m : I<0xF6, MRM6m, (outs), (ins i8mem:$src), // AX/[mem8] = AL,AH
Evan Cheng071a2792007-09-11 19:55:27 +00001176 "div{b}\t$src", []>;
Evan Cheng24f2ea32007-09-14 21:48:26 +00001177let Defs = [AX,DX,EFLAGS], Uses = [AX,DX] in
Sean Callanan108934c2009-12-18 00:01:26 +00001178def DIV16m : I<0xF7, MRM6m, (outs), (ins i16mem:$src), // DX:AX/[mem16] = AX,DX
Evan Cheng071a2792007-09-11 19:55:27 +00001179 "div{w}\t$src", []>, OpSize;
Evan Cheng24f2ea32007-09-14 21:48:26 +00001180let Defs = [EAX,EDX,EFLAGS], Uses = [EAX,EDX] in
Sean Callanan108934c2009-12-18 00:01:26 +00001181 // EDX:EAX/[mem32] = EAX,EDX
1182def DIV32m : I<0xF7, MRM6m, (outs), (ins i32mem:$src),
Evan Cheng071a2792007-09-11 19:55:27 +00001183 "div{l}\t$src", []>;
Chris Lattnerba7e7562008-01-10 07:59:24 +00001184}
Chris Lattner1cca5e32003-08-03 21:54:21 +00001185
Chris Lattnerfc752712004-08-01 09:52:59 +00001186// Signed division/remainder.
Jakob Stoklund Olesen3cfe0102010-03-04 20:42:07 +00001187let Defs = [AL,EFLAGS,AX], Uses = [AX] in
Sean Callanan108934c2009-12-18 00:01:26 +00001188def IDIV8r : I<0xF6, MRM7r, (outs), (ins GR8:$src), // AX/r8 = AL,AH
Evan Cheng071a2792007-09-11 19:55:27 +00001189 "idiv{b}\t$src", []>;
Evan Cheng24f2ea32007-09-14 21:48:26 +00001190let Defs = [AX,DX,EFLAGS], Uses = [AX,DX] in
Sean Callanan108934c2009-12-18 00:01:26 +00001191def IDIV16r: I<0xF7, MRM7r, (outs), (ins GR16:$src), // DX:AX/r16 = AX,DX
Evan Cheng071a2792007-09-11 19:55:27 +00001192 "idiv{w}\t$src", []>, OpSize;
Evan Cheng24f2ea32007-09-14 21:48:26 +00001193let Defs = [EAX,EDX,EFLAGS], Uses = [EAX,EDX] in
Sean Callanan108934c2009-12-18 00:01:26 +00001194def IDIV32r: I<0xF7, MRM7r, (outs), (ins GR32:$src), // EDX:EAX/r32 = EAX,EDX
Evan Cheng071a2792007-09-11 19:55:27 +00001195 "idiv{l}\t$src", []>;
Chris Lattnerba7e7562008-01-10 07:59:24 +00001196let mayLoad = 1, mayLoad = 1 in {
Jakob Stoklund Olesen3cfe0102010-03-04 20:42:07 +00001197let Defs = [AL,EFLAGS,AX], Uses = [AX] in
Sean Callanan108934c2009-12-18 00:01:26 +00001198def IDIV8m : I<0xF6, MRM7m, (outs), (ins i8mem:$src), // AX/[mem8] = AL,AH
Evan Cheng071a2792007-09-11 19:55:27 +00001199 "idiv{b}\t$src", []>;
Evan Cheng24f2ea32007-09-14 21:48:26 +00001200let Defs = [AX,DX,EFLAGS], Uses = [AX,DX] in
Sean Callanan108934c2009-12-18 00:01:26 +00001201def IDIV16m: I<0xF7, MRM7m, (outs), (ins i16mem:$src), // DX:AX/[mem16] = AX,DX
Evan Cheng071a2792007-09-11 19:55:27 +00001202 "idiv{w}\t$src", []>, OpSize;
Evan Cheng24f2ea32007-09-14 21:48:26 +00001203let Defs = [EAX,EDX,EFLAGS], Uses = [EAX,EDX] in
Sean Callanan108934c2009-12-18 00:01:26 +00001204def IDIV32m: I<0xF7, MRM7m, (outs), (ins i32mem:$src),
1205 // EDX:EAX/[mem32] = EAX,EDX
Evan Cheng071a2792007-09-11 19:55:27 +00001206 "idiv{l}\t$src", []>;
Chris Lattnerba7e7562008-01-10 07:59:24 +00001207}
Chris Lattner1cca5e32003-08-03 21:54:21 +00001208
Chris Lattner1cca5e32003-08-03 21:54:21 +00001209//===----------------------------------------------------------------------===//
Chris Lattnerba7e7562008-01-10 07:59:24 +00001210// Two address Instructions.
Chris Lattner1cca5e32003-08-03 21:54:21 +00001211//
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00001212let isTwoAddress = 1 in {
Chris Lattner1cca5e32003-08-03 21:54:21 +00001213
Alkis Evlogimenosa3f66842004-03-12 17:59:56 +00001214// Conditional moves
Evan Cheng0488db92007-09-25 01:57:46 +00001215let Uses = [EFLAGS] in {
Dan Gohmancbbea0f2009-08-27 00:14:12 +00001216
Chris Lattner314a1132010-03-14 18:31:44 +00001217let Predicates = [HasCMov] in {
Dan Gohmana4c5c332009-08-27 18:16:24 +00001218let isCommutable = 1 in {
Evan Cheng069287d2006-05-16 07:21:53 +00001219def CMOVB16rr : I<0x42, MRMSrcReg, // if <u, GR16 = GR16
Evan Cheng64d80e32007-07-19 01:14:50 +00001220 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Sean Callanan108934c2009-12-18 00:01:26 +00001221 "cmovb{w}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001222 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Chenge5f62042007-09-29 00:00:36 +00001223 X86_COND_B, EFLAGS))]>,
Evan Cheng71fb9ad2006-01-26 00:29:36 +00001224 TB, OpSize;
Evan Cheng069287d2006-05-16 07:21:53 +00001225def CMOVB32rr : I<0x42, MRMSrcReg, // if <u, GR32 = GR32
Evan Cheng64d80e32007-07-19 01:14:50 +00001226 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Sean Callanan108934c2009-12-18 00:01:26 +00001227 "cmovb{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001228 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Chenge5f62042007-09-29 00:00:36 +00001229 X86_COND_B, EFLAGS))]>,
Evan Cheng71fb9ad2006-01-26 00:29:36 +00001230 TB;
Evan Cheng069287d2006-05-16 07:21:53 +00001231def CMOVAE16rr: I<0x43, MRMSrcReg, // if >=u, GR16 = GR16
Evan Cheng64d80e32007-07-19 01:14:50 +00001232 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Sean Callanan108934c2009-12-18 00:01:26 +00001233 "cmovae{w}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001234 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Chenge5f62042007-09-29 00:00:36 +00001235 X86_COND_AE, EFLAGS))]>,
Evan Cheng71fb9ad2006-01-26 00:29:36 +00001236 TB, OpSize;
Evan Cheng069287d2006-05-16 07:21:53 +00001237def CMOVAE32rr: I<0x43, MRMSrcReg, // if >=u, GR32 = GR32
Evan Cheng64d80e32007-07-19 01:14:50 +00001238 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Sean Callanan108934c2009-12-18 00:01:26 +00001239 "cmovae{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001240 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Chenge5f62042007-09-29 00:00:36 +00001241 X86_COND_AE, EFLAGS))]>,
Evan Cheng71fb9ad2006-01-26 00:29:36 +00001242 TB;
Evan Cheng069287d2006-05-16 07:21:53 +00001243def CMOVE16rr : I<0x44, MRMSrcReg, // if ==, GR16 = GR16
Evan Cheng64d80e32007-07-19 01:14:50 +00001244 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Sean Callanan108934c2009-12-18 00:01:26 +00001245 "cmove{w}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001246 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Chenge5f62042007-09-29 00:00:36 +00001247 X86_COND_E, EFLAGS))]>,
Evan Cheng71fb9ad2006-01-26 00:29:36 +00001248 TB, OpSize;
Evan Cheng069287d2006-05-16 07:21:53 +00001249def CMOVE32rr : I<0x44, MRMSrcReg, // if ==, GR32 = GR32
Evan Cheng64d80e32007-07-19 01:14:50 +00001250 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Sean Callanan108934c2009-12-18 00:01:26 +00001251 "cmove{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001252 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Chenge5f62042007-09-29 00:00:36 +00001253 X86_COND_E, EFLAGS))]>,
Evan Cheng71fb9ad2006-01-26 00:29:36 +00001254 TB;
Evan Cheng069287d2006-05-16 07:21:53 +00001255def CMOVNE16rr: I<0x45, MRMSrcReg, // if !=, GR16 = GR16
Evan Cheng64d80e32007-07-19 01:14:50 +00001256 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Sean Callanan108934c2009-12-18 00:01:26 +00001257 "cmovne{w}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001258 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Chenge5f62042007-09-29 00:00:36 +00001259 X86_COND_NE, EFLAGS))]>,
Evan Cheng71fb9ad2006-01-26 00:29:36 +00001260 TB, OpSize;
Evan Cheng069287d2006-05-16 07:21:53 +00001261def CMOVNE32rr: I<0x45, MRMSrcReg, // if !=, GR32 = GR32
Evan Cheng64d80e32007-07-19 01:14:50 +00001262 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Sean Callanan108934c2009-12-18 00:01:26 +00001263 "cmovne{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001264 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Chenge5f62042007-09-29 00:00:36 +00001265 X86_COND_NE, EFLAGS))]>,
Evan Cheng71fb9ad2006-01-26 00:29:36 +00001266 TB;
Evan Cheng069287d2006-05-16 07:21:53 +00001267def CMOVBE16rr: I<0x46, MRMSrcReg, // if <=u, GR16 = GR16
Evan Cheng64d80e32007-07-19 01:14:50 +00001268 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Sean Callanan108934c2009-12-18 00:01:26 +00001269 "cmovbe{w}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001270 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Chenge5f62042007-09-29 00:00:36 +00001271 X86_COND_BE, EFLAGS))]>,
Evan Cheng71fb9ad2006-01-26 00:29:36 +00001272 TB, OpSize;
Evan Cheng069287d2006-05-16 07:21:53 +00001273def CMOVBE32rr: I<0x46, MRMSrcReg, // if <=u, GR32 = GR32
Evan Cheng64d80e32007-07-19 01:14:50 +00001274 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Sean Callanan108934c2009-12-18 00:01:26 +00001275 "cmovbe{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001276 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Chenge5f62042007-09-29 00:00:36 +00001277 X86_COND_BE, EFLAGS))]>,
Evan Cheng71fb9ad2006-01-26 00:29:36 +00001278 TB;
Evan Cheng069287d2006-05-16 07:21:53 +00001279def CMOVA16rr : I<0x47, MRMSrcReg, // if >u, GR16 = GR16
Evan Cheng64d80e32007-07-19 01:14:50 +00001280 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Sean Callanan108934c2009-12-18 00:01:26 +00001281 "cmova{w}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001282 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Chenge5f62042007-09-29 00:00:36 +00001283 X86_COND_A, EFLAGS))]>,
Evan Cheng71fb9ad2006-01-26 00:29:36 +00001284 TB, OpSize;
Evan Cheng069287d2006-05-16 07:21:53 +00001285def CMOVA32rr : I<0x47, MRMSrcReg, // if >u, GR32 = GR32
Evan Cheng64d80e32007-07-19 01:14:50 +00001286 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Sean Callanan108934c2009-12-18 00:01:26 +00001287 "cmova{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001288 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Chenge5f62042007-09-29 00:00:36 +00001289 X86_COND_A, EFLAGS))]>,
Evan Cheng71fb9ad2006-01-26 00:29:36 +00001290 TB;
Evan Cheng069287d2006-05-16 07:21:53 +00001291def CMOVL16rr : I<0x4C, MRMSrcReg, // if <s, GR16 = GR16
Evan Cheng64d80e32007-07-19 01:14:50 +00001292 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Sean Callanan108934c2009-12-18 00:01:26 +00001293 "cmovl{w}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001294 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Chenge5f62042007-09-29 00:00:36 +00001295 X86_COND_L, EFLAGS))]>,
Evan Cheng71fb9ad2006-01-26 00:29:36 +00001296 TB, OpSize;
Evan Cheng069287d2006-05-16 07:21:53 +00001297def CMOVL32rr : I<0x4C, MRMSrcReg, // if <s, GR32 = GR32
Evan Cheng64d80e32007-07-19 01:14:50 +00001298 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Sean Callanan108934c2009-12-18 00:01:26 +00001299 "cmovl{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001300 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Chenge5f62042007-09-29 00:00:36 +00001301 X86_COND_L, EFLAGS))]>,
Evan Cheng71fb9ad2006-01-26 00:29:36 +00001302 TB;
Evan Cheng069287d2006-05-16 07:21:53 +00001303def CMOVGE16rr: I<0x4D, MRMSrcReg, // if >=s, GR16 = GR16
Evan Cheng64d80e32007-07-19 01:14:50 +00001304 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Sean Callanan108934c2009-12-18 00:01:26 +00001305 "cmovge{w}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001306 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Chenge5f62042007-09-29 00:00:36 +00001307 X86_COND_GE, EFLAGS))]>,
Evan Cheng71fb9ad2006-01-26 00:29:36 +00001308 TB, OpSize;
Evan Cheng069287d2006-05-16 07:21:53 +00001309def CMOVGE32rr: I<0x4D, MRMSrcReg, // if >=s, GR32 = GR32
Evan Cheng64d80e32007-07-19 01:14:50 +00001310 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Sean Callanan108934c2009-12-18 00:01:26 +00001311 "cmovge{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001312 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Chenge5f62042007-09-29 00:00:36 +00001313 X86_COND_GE, EFLAGS))]>,
Evan Cheng71fb9ad2006-01-26 00:29:36 +00001314 TB;
Evan Cheng069287d2006-05-16 07:21:53 +00001315def CMOVLE16rr: I<0x4E, MRMSrcReg, // if <=s, GR16 = GR16
Evan Cheng64d80e32007-07-19 01:14:50 +00001316 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Sean Callanan108934c2009-12-18 00:01:26 +00001317 "cmovle{w}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001318 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Chenge5f62042007-09-29 00:00:36 +00001319 X86_COND_LE, EFLAGS))]>,
Evan Cheng71fb9ad2006-01-26 00:29:36 +00001320 TB, OpSize;
Evan Cheng069287d2006-05-16 07:21:53 +00001321def CMOVLE32rr: I<0x4E, MRMSrcReg, // if <=s, GR32 = GR32
Evan Cheng64d80e32007-07-19 01:14:50 +00001322 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Sean Callanan108934c2009-12-18 00:01:26 +00001323 "cmovle{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001324 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Chenge5f62042007-09-29 00:00:36 +00001325 X86_COND_LE, EFLAGS))]>,
Evan Cheng71fb9ad2006-01-26 00:29:36 +00001326 TB;
Evan Cheng069287d2006-05-16 07:21:53 +00001327def CMOVG16rr : I<0x4F, MRMSrcReg, // if >s, GR16 = GR16
Evan Cheng64d80e32007-07-19 01:14:50 +00001328 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Sean Callanan108934c2009-12-18 00:01:26 +00001329 "cmovg{w}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001330 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Chenge5f62042007-09-29 00:00:36 +00001331 X86_COND_G, EFLAGS))]>,
Evan Cheng71fb9ad2006-01-26 00:29:36 +00001332 TB, OpSize;
Evan Cheng069287d2006-05-16 07:21:53 +00001333def CMOVG32rr : I<0x4F, MRMSrcReg, // if >s, GR32 = GR32
Evan Cheng64d80e32007-07-19 01:14:50 +00001334 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Sean Callanan108934c2009-12-18 00:01:26 +00001335 "cmovg{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001336 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Chenge5f62042007-09-29 00:00:36 +00001337 X86_COND_G, EFLAGS))]>,
Evan Cheng71fb9ad2006-01-26 00:29:36 +00001338 TB;
Evan Cheng069287d2006-05-16 07:21:53 +00001339def CMOVS16rr : I<0x48, MRMSrcReg, // if signed, GR16 = GR16
Evan Cheng64d80e32007-07-19 01:14:50 +00001340 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Sean Callanan108934c2009-12-18 00:01:26 +00001341 "cmovs{w}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001342 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Chenge5f62042007-09-29 00:00:36 +00001343 X86_COND_S, EFLAGS))]>,
Evan Cheng71fb9ad2006-01-26 00:29:36 +00001344 TB, OpSize;
Evan Cheng069287d2006-05-16 07:21:53 +00001345def CMOVS32rr : I<0x48, MRMSrcReg, // if signed, GR32 = GR32
Evan Cheng64d80e32007-07-19 01:14:50 +00001346 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Sean Callanan108934c2009-12-18 00:01:26 +00001347 "cmovs{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001348 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Chenge5f62042007-09-29 00:00:36 +00001349 X86_COND_S, EFLAGS))]>,
Evan Cheng71fb9ad2006-01-26 00:29:36 +00001350 TB;
Evan Cheng069287d2006-05-16 07:21:53 +00001351def CMOVNS16rr: I<0x49, MRMSrcReg, // if !signed, GR16 = GR16
Evan Cheng64d80e32007-07-19 01:14:50 +00001352 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Sean Callanan108934c2009-12-18 00:01:26 +00001353 "cmovns{w}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001354 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Chenge5f62042007-09-29 00:00:36 +00001355 X86_COND_NS, EFLAGS))]>,
Evan Cheng71fb9ad2006-01-26 00:29:36 +00001356 TB, OpSize;
Evan Cheng069287d2006-05-16 07:21:53 +00001357def CMOVNS32rr: I<0x49, MRMSrcReg, // if !signed, GR32 = GR32
Evan Cheng64d80e32007-07-19 01:14:50 +00001358 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Sean Callanan108934c2009-12-18 00:01:26 +00001359 "cmovns{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001360 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Chenge5f62042007-09-29 00:00:36 +00001361 X86_COND_NS, EFLAGS))]>,
Evan Cheng71fb9ad2006-01-26 00:29:36 +00001362 TB;
Evan Cheng069287d2006-05-16 07:21:53 +00001363def CMOVP16rr : I<0x4A, MRMSrcReg, // if parity, GR16 = GR16
Evan Cheng64d80e32007-07-19 01:14:50 +00001364 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Sean Callanan108934c2009-12-18 00:01:26 +00001365 "cmovp{w}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001366 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Chenge5f62042007-09-29 00:00:36 +00001367 X86_COND_P, EFLAGS))]>,
Evan Cheng71fb9ad2006-01-26 00:29:36 +00001368 TB, OpSize;
Evan Cheng069287d2006-05-16 07:21:53 +00001369def CMOVP32rr : I<0x4A, MRMSrcReg, // if parity, GR32 = GR32
Evan Cheng64d80e32007-07-19 01:14:50 +00001370 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Sean Callanan108934c2009-12-18 00:01:26 +00001371 "cmovp{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001372 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Chenge5f62042007-09-29 00:00:36 +00001373 X86_COND_P, EFLAGS))]>,
Evan Cheng71fb9ad2006-01-26 00:29:36 +00001374 TB;
Evan Cheng069287d2006-05-16 07:21:53 +00001375def CMOVNP16rr : I<0x4B, MRMSrcReg, // if !parity, GR16 = GR16
Evan Cheng64d80e32007-07-19 01:14:50 +00001376 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Sean Callanan108934c2009-12-18 00:01:26 +00001377 "cmovnp{w}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001378 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Chenge5f62042007-09-29 00:00:36 +00001379 X86_COND_NP, EFLAGS))]>,
Evan Cheng71fb9ad2006-01-26 00:29:36 +00001380 TB, OpSize;
Evan Cheng069287d2006-05-16 07:21:53 +00001381def CMOVNP32rr : I<0x4B, MRMSrcReg, // if !parity, GR32 = GR32
Evan Cheng64d80e32007-07-19 01:14:50 +00001382 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Sean Callanan108934c2009-12-18 00:01:26 +00001383 "cmovnp{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001384 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Chenge5f62042007-09-29 00:00:36 +00001385 X86_COND_NP, EFLAGS))]>,
Evan Cheng71fb9ad2006-01-26 00:29:36 +00001386 TB;
Dan Gohman305fceb2009-01-07 00:35:10 +00001387def CMOVO16rr : I<0x40, MRMSrcReg, // if overflow, GR16 = GR16
1388 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Sean Callanan108934c2009-12-18 00:01:26 +00001389 "cmovo{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohman305fceb2009-01-07 00:35:10 +00001390 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
1391 X86_COND_O, EFLAGS))]>,
1392 TB, OpSize;
1393def CMOVO32rr : I<0x40, MRMSrcReg, // if overflow, GR32 = GR32
1394 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Sean Callanan108934c2009-12-18 00:01:26 +00001395 "cmovo{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohman305fceb2009-01-07 00:35:10 +00001396 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
1397 X86_COND_O, EFLAGS))]>,
Evan Cheng0488db92007-09-25 01:57:46 +00001398 TB;
Dan Gohman305fceb2009-01-07 00:35:10 +00001399def CMOVNO16rr : I<0x41, MRMSrcReg, // if !overflow, GR16 = GR16
1400 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Sean Callanan108934c2009-12-18 00:01:26 +00001401 "cmovno{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohman305fceb2009-01-07 00:35:10 +00001402 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
1403 X86_COND_NO, EFLAGS))]>,
1404 TB, OpSize;
1405def CMOVNO32rr : I<0x41, MRMSrcReg, // if !overflow, GR32 = GR32
1406 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Sean Callanan108934c2009-12-18 00:01:26 +00001407 "cmovno{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohman305fceb2009-01-07 00:35:10 +00001408 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
1409 X86_COND_NO, EFLAGS))]>,
1410 TB;
1411} // isCommutable = 1
Evan Cheng7ad42d92007-10-05 23:13:21 +00001412
1413def CMOVB16rm : I<0x42, MRMSrcMem, // if <u, GR16 = [mem16]
1414 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
Sean Callanan108934c2009-12-18 00:01:26 +00001415 "cmovb{w}\t{$src2, $dst|$dst, $src2}",
Evan Cheng7ad42d92007-10-05 23:13:21 +00001416 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1417 X86_COND_B, EFLAGS))]>,
1418 TB, OpSize;
1419def CMOVB32rm : I<0x42, MRMSrcMem, // if <u, GR32 = [mem32]
1420 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Sean Callanan108934c2009-12-18 00:01:26 +00001421 "cmovb{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng7ad42d92007-10-05 23:13:21 +00001422 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1423 X86_COND_B, EFLAGS))]>,
1424 TB;
1425def CMOVAE16rm: I<0x43, MRMSrcMem, // if >=u, GR16 = [mem16]
1426 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
Sean Callanan108934c2009-12-18 00:01:26 +00001427 "cmovae{w}\t{$src2, $dst|$dst, $src2}",
Evan Cheng7ad42d92007-10-05 23:13:21 +00001428 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1429 X86_COND_AE, EFLAGS))]>,
1430 TB, OpSize;
1431def CMOVAE32rm: I<0x43, MRMSrcMem, // if >=u, GR32 = [mem32]
1432 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Sean Callanan108934c2009-12-18 00:01:26 +00001433 "cmovae{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng7ad42d92007-10-05 23:13:21 +00001434 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1435 X86_COND_AE, EFLAGS))]>,
1436 TB;
1437def CMOVE16rm : I<0x44, MRMSrcMem, // if ==, GR16 = [mem16]
1438 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
Sean Callanan108934c2009-12-18 00:01:26 +00001439 "cmove{w}\t{$src2, $dst|$dst, $src2}",
Evan Cheng7ad42d92007-10-05 23:13:21 +00001440 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1441 X86_COND_E, EFLAGS))]>,
1442 TB, OpSize;
1443def CMOVE32rm : I<0x44, MRMSrcMem, // if ==, GR32 = [mem32]
1444 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Sean Callanan108934c2009-12-18 00:01:26 +00001445 "cmove{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng7ad42d92007-10-05 23:13:21 +00001446 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1447 X86_COND_E, EFLAGS))]>,
1448 TB;
1449def CMOVNE16rm: I<0x45, MRMSrcMem, // if !=, GR16 = [mem16]
1450 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
Sean Callanan108934c2009-12-18 00:01:26 +00001451 "cmovne{w}\t{$src2, $dst|$dst, $src2}",
Evan Cheng7ad42d92007-10-05 23:13:21 +00001452 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1453 X86_COND_NE, EFLAGS))]>,
1454 TB, OpSize;
1455def CMOVNE32rm: I<0x45, MRMSrcMem, // if !=, GR32 = [mem32]
1456 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Sean Callanan108934c2009-12-18 00:01:26 +00001457 "cmovne{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng7ad42d92007-10-05 23:13:21 +00001458 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1459 X86_COND_NE, EFLAGS))]>,
1460 TB;
1461def CMOVBE16rm: I<0x46, MRMSrcMem, // if <=u, GR16 = [mem16]
1462 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
Sean Callanan108934c2009-12-18 00:01:26 +00001463 "cmovbe{w}\t{$src2, $dst|$dst, $src2}",
Evan Cheng7ad42d92007-10-05 23:13:21 +00001464 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1465 X86_COND_BE, EFLAGS))]>,
1466 TB, OpSize;
1467def CMOVBE32rm: I<0x46, MRMSrcMem, // if <=u, GR32 = [mem32]
1468 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Sean Callanan108934c2009-12-18 00:01:26 +00001469 "cmovbe{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng7ad42d92007-10-05 23:13:21 +00001470 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1471 X86_COND_BE, EFLAGS))]>,
1472 TB;
1473def CMOVA16rm : I<0x47, MRMSrcMem, // if >u, GR16 = [mem16]
1474 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
Sean Callanan108934c2009-12-18 00:01:26 +00001475 "cmova{w}\t{$src2, $dst|$dst, $src2}",
Evan Cheng7ad42d92007-10-05 23:13:21 +00001476 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1477 X86_COND_A, EFLAGS))]>,
1478 TB, OpSize;
1479def CMOVA32rm : I<0x47, MRMSrcMem, // if >u, GR32 = [mem32]
1480 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Sean Callanan108934c2009-12-18 00:01:26 +00001481 "cmova{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng7ad42d92007-10-05 23:13:21 +00001482 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1483 X86_COND_A, EFLAGS))]>,
1484 TB;
1485def CMOVL16rm : I<0x4C, MRMSrcMem, // if <s, GR16 = [mem16]
1486 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
Sean Callanan108934c2009-12-18 00:01:26 +00001487 "cmovl{w}\t{$src2, $dst|$dst, $src2}",
Evan Cheng7ad42d92007-10-05 23:13:21 +00001488 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1489 X86_COND_L, EFLAGS))]>,
1490 TB, OpSize;
1491def CMOVL32rm : I<0x4C, MRMSrcMem, // if <s, GR32 = [mem32]
1492 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Sean Callanan108934c2009-12-18 00:01:26 +00001493 "cmovl{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng7ad42d92007-10-05 23:13:21 +00001494 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1495 X86_COND_L, EFLAGS))]>,
1496 TB;
1497def CMOVGE16rm: I<0x4D, MRMSrcMem, // if >=s, GR16 = [mem16]
1498 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
Sean Callanan108934c2009-12-18 00:01:26 +00001499 "cmovge{w}\t{$src2, $dst|$dst, $src2}",
Evan Cheng7ad42d92007-10-05 23:13:21 +00001500 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1501 X86_COND_GE, EFLAGS))]>,
1502 TB, OpSize;
1503def CMOVGE32rm: I<0x4D, MRMSrcMem, // if >=s, GR32 = [mem32]
1504 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Sean Callanan108934c2009-12-18 00:01:26 +00001505 "cmovge{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng7ad42d92007-10-05 23:13:21 +00001506 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1507 X86_COND_GE, EFLAGS))]>,
1508 TB;
1509def CMOVLE16rm: I<0x4E, MRMSrcMem, // if <=s, GR16 = [mem16]
1510 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
Sean Callanan108934c2009-12-18 00:01:26 +00001511 "cmovle{w}\t{$src2, $dst|$dst, $src2}",
Evan Cheng7ad42d92007-10-05 23:13:21 +00001512 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1513 X86_COND_LE, EFLAGS))]>,
1514 TB, OpSize;
1515def CMOVLE32rm: I<0x4E, MRMSrcMem, // if <=s, GR32 = [mem32]
1516 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Sean Callanan108934c2009-12-18 00:01:26 +00001517 "cmovle{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng7ad42d92007-10-05 23:13:21 +00001518 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1519 X86_COND_LE, EFLAGS))]>,
1520 TB;
1521def CMOVG16rm : I<0x4F, MRMSrcMem, // if >s, GR16 = [mem16]
1522 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
Sean Callanan108934c2009-12-18 00:01:26 +00001523 "cmovg{w}\t{$src2, $dst|$dst, $src2}",
Evan Cheng7ad42d92007-10-05 23:13:21 +00001524 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1525 X86_COND_G, EFLAGS))]>,
1526 TB, OpSize;
1527def CMOVG32rm : I<0x4F, MRMSrcMem, // if >s, GR32 = [mem32]
1528 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Sean Callanan108934c2009-12-18 00:01:26 +00001529 "cmovg{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng7ad42d92007-10-05 23:13:21 +00001530 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1531 X86_COND_G, EFLAGS))]>,
1532 TB;
1533def CMOVS16rm : I<0x48, MRMSrcMem, // if signed, GR16 = [mem16]
1534 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
Sean Callanan108934c2009-12-18 00:01:26 +00001535 "cmovs{w}\t{$src2, $dst|$dst, $src2}",
Evan Cheng7ad42d92007-10-05 23:13:21 +00001536 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1537 X86_COND_S, EFLAGS))]>,
1538 TB, OpSize;
1539def CMOVS32rm : I<0x48, MRMSrcMem, // if signed, GR32 = [mem32]
1540 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Sean Callanan108934c2009-12-18 00:01:26 +00001541 "cmovs{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng7ad42d92007-10-05 23:13:21 +00001542 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1543 X86_COND_S, EFLAGS))]>,
1544 TB;
1545def CMOVNS16rm: I<0x49, MRMSrcMem, // if !signed, GR16 = [mem16]
1546 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
Sean Callanan108934c2009-12-18 00:01:26 +00001547 "cmovns{w}\t{$src2, $dst|$dst, $src2}",
Evan Cheng7ad42d92007-10-05 23:13:21 +00001548 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1549 X86_COND_NS, EFLAGS))]>,
1550 TB, OpSize;
1551def CMOVNS32rm: I<0x49, MRMSrcMem, // if !signed, GR32 = [mem32]
1552 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Sean Callanan108934c2009-12-18 00:01:26 +00001553 "cmovns{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng7ad42d92007-10-05 23:13:21 +00001554 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1555 X86_COND_NS, EFLAGS))]>,
1556 TB;
1557def CMOVP16rm : I<0x4A, MRMSrcMem, // if parity, GR16 = [mem16]
1558 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
Sean Callanan108934c2009-12-18 00:01:26 +00001559 "cmovp{w}\t{$src2, $dst|$dst, $src2}",
Evan Cheng7ad42d92007-10-05 23:13:21 +00001560 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1561 X86_COND_P, EFLAGS))]>,
1562 TB, OpSize;
1563def CMOVP32rm : I<0x4A, MRMSrcMem, // if parity, GR32 = [mem32]
1564 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Sean Callanan108934c2009-12-18 00:01:26 +00001565 "cmovp{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng7ad42d92007-10-05 23:13:21 +00001566 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1567 X86_COND_P, EFLAGS))]>,
1568 TB;
1569def CMOVNP16rm : I<0x4B, MRMSrcMem, // if !parity, GR16 = [mem16]
1570 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
Sean Callanan108934c2009-12-18 00:01:26 +00001571 "cmovnp{w}\t{$src2, $dst|$dst, $src2}",
Evan Cheng7ad42d92007-10-05 23:13:21 +00001572 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1573 X86_COND_NP, EFLAGS))]>,
1574 TB, OpSize;
Dan Gohman305fceb2009-01-07 00:35:10 +00001575def CMOVNP32rm : I<0x4B, MRMSrcMem, // if !parity, GR32 = [mem32]
1576 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Sean Callanan108934c2009-12-18 00:01:26 +00001577 "cmovnp{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohman305fceb2009-01-07 00:35:10 +00001578 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1579 X86_COND_NP, EFLAGS))]>,
1580 TB;
1581def CMOVO16rm : I<0x40, MRMSrcMem, // if overflow, GR16 = [mem16]
1582 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
Sean Callanan108934c2009-12-18 00:01:26 +00001583 "cmovo{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohman305fceb2009-01-07 00:35:10 +00001584 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1585 X86_COND_O, EFLAGS))]>,
1586 TB, OpSize;
1587def CMOVO32rm : I<0x40, MRMSrcMem, // if overflow, GR32 = [mem32]
1588 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Sean Callanan108934c2009-12-18 00:01:26 +00001589 "cmovo{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohman305fceb2009-01-07 00:35:10 +00001590 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1591 X86_COND_O, EFLAGS))]>,
1592 TB;
1593def CMOVNO16rm : I<0x41, MRMSrcMem, // if !overflow, GR16 = [mem16]
1594 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
Sean Callanan108934c2009-12-18 00:01:26 +00001595 "cmovno{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohman305fceb2009-01-07 00:35:10 +00001596 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1597 X86_COND_NO, EFLAGS))]>,
1598 TB, OpSize;
1599def CMOVNO32rm : I<0x41, MRMSrcMem, // if !overflow, GR32 = [mem32]
1600 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Sean Callanan108934c2009-12-18 00:01:26 +00001601 "cmovno{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohman305fceb2009-01-07 00:35:10 +00001602 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1603 X86_COND_NO, EFLAGS))]>,
1604 TB;
Chris Lattner314a1132010-03-14 18:31:44 +00001605} // Predicates = [HasCMov]
1606
1607// X86 doesn't have 8-bit conditional moves. Use a customInserter to
1608// emit control flow. An alternative to this is to mark i8 SELECT as Promote,
1609// however that requires promoting the operands, and can induce additional
1610// i8 register pressure. Note that CMOV_GR8 is conservatively considered to
1611// clobber EFLAGS, because if one of the operands is zero, the expansion
1612// could involve an xor.
1613let usesCustomInserter = 1, isTwoAddress = 0, Defs = [EFLAGS] in {
1614def CMOV_GR8 : I<0, Pseudo,
1615 (outs GR8:$dst), (ins GR8:$src1, GR8:$src2, i8imm:$cond),
1616 "#CMOV_GR8 PSEUDO!",
1617 [(set GR8:$dst, (X86cmov GR8:$src1, GR8:$src2,
1618 imm:$cond, EFLAGS))]>;
1619
1620let Predicates = [NoCMov] in {
1621def CMOV_GR32 : I<0, Pseudo,
1622 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2, i8imm:$cond),
1623 "#CMOV_GR32* PSEUDO!",
1624 [(set GR32:$dst,
1625 (X86cmov GR32:$src1, GR32:$src2, imm:$cond, EFLAGS))]>;
1626def CMOV_GR16 : I<0, Pseudo,
1627 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2, i8imm:$cond),
1628 "#CMOV_GR16* PSEUDO!",
1629 [(set GR16:$dst,
1630 (X86cmov GR16:$src1, GR16:$src2, imm:$cond, EFLAGS))]>;
1631def CMOV_RFP32 : I<0, Pseudo,
1632 (outs RFP32:$dst), (ins RFP32:$src1, RFP32:$src2, i8imm:$cond),
1633 "#CMOV_RFP32 PSEUDO!",
1634 [(set RFP32:$dst, (X86cmov RFP32:$src1, RFP32:$src2, imm:$cond,
1635 EFLAGS))]>;
1636def CMOV_RFP64 : I<0, Pseudo,
1637 (outs RFP64:$dst), (ins RFP64:$src1, RFP64:$src2, i8imm:$cond),
1638 "#CMOV_RFP64 PSEUDO!",
1639 [(set RFP64:$dst, (X86cmov RFP64:$src1, RFP64:$src2, imm:$cond,
1640 EFLAGS))]>;
1641def CMOV_RFP80 : I<0, Pseudo,
1642 (outs RFP80:$dst), (ins RFP80:$src1, RFP80:$src2, i8imm:$cond),
1643 "#CMOV_RFP80 PSEUDO!",
1644 [(set RFP80:$dst, (X86cmov RFP80:$src1, RFP80:$src2, imm:$cond,
1645 EFLAGS))]>;
1646} // Predicates = [NoCMov]
1647} // UsesCustomInserter = 1, isTwoAddress = 0, Defs = [EFLAGS]
Evan Cheng0488db92007-09-25 01:57:46 +00001648} // Uses = [EFLAGS]
1649
1650
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00001651// unary instructions
Evan Cheng1693e482006-07-19 00:27:29 +00001652let CodeSize = 2 in {
Evan Cheng24f2ea32007-09-14 21:48:26 +00001653let Defs = [EFLAGS] in {
Dan Gohmanb1576f52007-07-31 20:11:57 +00001654def NEG8r : I<0xF6, MRM3r, (outs GR8 :$dst), (ins GR8 :$src), "neg{b}\t$dst",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001655 [(set GR8:$dst, (ineg GR8:$src)),
1656 (implicit EFLAGS)]>;
Dan Gohmanb1576f52007-07-31 20:11:57 +00001657def NEG16r : I<0xF7, MRM3r, (outs GR16:$dst), (ins GR16:$src), "neg{w}\t$dst",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001658 [(set GR16:$dst, (ineg GR16:$src)),
1659 (implicit EFLAGS)]>, OpSize;
Dan Gohmanb1576f52007-07-31 20:11:57 +00001660def NEG32r : I<0xF7, MRM3r, (outs GR32:$dst), (ins GR32:$src), "neg{l}\t$dst",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001661 [(set GR32:$dst, (ineg GR32:$src)),
1662 (implicit EFLAGS)]>;
Chris Lattner57a02302004-08-11 04:31:00 +00001663let isTwoAddress = 0 in {
Dan Gohmanb1576f52007-07-31 20:11:57 +00001664 def NEG8m : I<0xF6, MRM3m, (outs), (ins i8mem :$dst), "neg{b}\t$dst",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001665 [(store (ineg (loadi8 addr:$dst)), addr:$dst),
1666 (implicit EFLAGS)]>;
Dan Gohmanb1576f52007-07-31 20:11:57 +00001667 def NEG16m : I<0xF7, MRM3m, (outs), (ins i16mem:$dst), "neg{w}\t$dst",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001668 [(store (ineg (loadi16 addr:$dst)), addr:$dst),
1669 (implicit EFLAGS)]>, OpSize;
Dan Gohmanb1576f52007-07-31 20:11:57 +00001670 def NEG32m : I<0xF7, MRM3m, (outs), (ins i32mem:$dst), "neg{l}\t$dst",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001671 [(store (ineg (loadi32 addr:$dst)), addr:$dst),
1672 (implicit EFLAGS)]>;
Chris Lattner57a02302004-08-11 04:31:00 +00001673}
Evan Cheng24f2ea32007-09-14 21:48:26 +00001674} // Defs = [EFLAGS]
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00001675
Evan Chengaaf414c2009-01-21 02:09:05 +00001676// Match xor -1 to not. Favors these over a move imm + xor to save code size.
1677let AddedComplexity = 15 in {
Dan Gohmanb1576f52007-07-31 20:11:57 +00001678def NOT8r : I<0xF6, MRM2r, (outs GR8 :$dst), (ins GR8 :$src), "not{b}\t$dst",
Evan Cheng069287d2006-05-16 07:21:53 +00001679 [(set GR8:$dst, (not GR8:$src))]>;
Dan Gohmanb1576f52007-07-31 20:11:57 +00001680def NOT16r : I<0xF7, MRM2r, (outs GR16:$dst), (ins GR16:$src), "not{w}\t$dst",
Evan Cheng069287d2006-05-16 07:21:53 +00001681 [(set GR16:$dst, (not GR16:$src))]>, OpSize;
Dan Gohmanb1576f52007-07-31 20:11:57 +00001682def NOT32r : I<0xF7, MRM2r, (outs GR32:$dst), (ins GR32:$src), "not{l}\t$dst",
Evan Cheng069287d2006-05-16 07:21:53 +00001683 [(set GR32:$dst, (not GR32:$src))]>;
Evan Chengaaf414c2009-01-21 02:09:05 +00001684}
Chris Lattner57a02302004-08-11 04:31:00 +00001685let isTwoAddress = 0 in {
Dan Gohmanb1576f52007-07-31 20:11:57 +00001686 def NOT8m : I<0xF6, MRM2m, (outs), (ins i8mem :$dst), "not{b}\t$dst",
Evan Cheng605c4152005-12-13 01:57:51 +00001687 [(store (not (loadi8 addr:$dst)), addr:$dst)]>;
Dan Gohmanb1576f52007-07-31 20:11:57 +00001688 def NOT16m : I<0xF7, MRM2m, (outs), (ins i16mem:$dst), "not{w}\t$dst",
Evan Cheng605c4152005-12-13 01:57:51 +00001689 [(store (not (loadi16 addr:$dst)), addr:$dst)]>, OpSize;
Dan Gohmanb1576f52007-07-31 20:11:57 +00001690 def NOT32m : I<0xF7, MRM2m, (outs), (ins i32mem:$dst), "not{l}\t$dst",
Evan Cheng605c4152005-12-13 01:57:51 +00001691 [(store (not (loadi32 addr:$dst)), addr:$dst)]>;
Chris Lattner57a02302004-08-11 04:31:00 +00001692}
Evan Cheng1693e482006-07-19 00:27:29 +00001693} // CodeSize
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00001694
Evan Chengb51a0592005-12-10 00:48:20 +00001695// TODO: inc/dec is slow for P4, but fast for Pentium-M.
Evan Cheng24f2ea32007-09-14 21:48:26 +00001696let Defs = [EFLAGS] in {
Evan Cheng1693e482006-07-19 00:27:29 +00001697let CodeSize = 2 in
Dan Gohmanb1576f52007-07-31 20:11:57 +00001698def INC8r : I<0xFE, MRM0r, (outs GR8 :$dst), (ins GR8 :$src), "inc{b}\t$dst",
Chris Lattnerc54a2f12010-03-24 01:02:12 +00001699 [(set GR8:$dst, EFLAGS, (X86inc_flag GR8:$src))]>;
1700
Evan Cheng1693e482006-07-19 00:27:29 +00001701let isConvertibleToThreeAddress = 1, CodeSize = 1 in { // Can xform into LEA.
Sean Callanan108934c2009-12-18 00:01:26 +00001702def INC16r : I<0x40, AddRegFrm, (outs GR16:$dst), (ins GR16:$src),
1703 "inc{w}\t$dst",
Chris Lattner589ad5d2010-03-25 05:44:01 +00001704 [(set GR16:$dst, EFLAGS, (X86inc_flag GR16:$src))]>,
Evan Cheng25ab6902006-09-08 06:48:29 +00001705 OpSize, Requires<[In32BitMode]>;
Sean Callanan108934c2009-12-18 00:01:26 +00001706def INC32r : I<0x40, AddRegFrm, (outs GR32:$dst), (ins GR32:$src),
1707 "inc{l}\t$dst",
Chris Lattner589ad5d2010-03-25 05:44:01 +00001708 [(set GR32:$dst, EFLAGS, (X86inc_flag GR32:$src))]>,
1709 Requires<[In32BitMode]>;
Chris Lattnercc65bee2005-01-02 02:35:46 +00001710}
Evan Cheng1693e482006-07-19 00:27:29 +00001711let isTwoAddress = 0, CodeSize = 2 in {
Dan Gohmanb1576f52007-07-31 20:11:57 +00001712 def INC8m : I<0xFE, MRM0m, (outs), (ins i8mem :$dst), "inc{b}\t$dst",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001713 [(store (add (loadi8 addr:$dst), 1), addr:$dst),
1714 (implicit EFLAGS)]>;
Dan Gohmanb1576f52007-07-31 20:11:57 +00001715 def INC16m : I<0xFF, MRM0m, (outs), (ins i16mem:$dst), "inc{w}\t$dst",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001716 [(store (add (loadi16 addr:$dst), 1), addr:$dst),
1717 (implicit EFLAGS)]>,
Evan Cheng66f71632007-10-19 21:23:22 +00001718 OpSize, Requires<[In32BitMode]>;
Dan Gohmanb1576f52007-07-31 20:11:57 +00001719 def INC32m : I<0xFF, MRM0m, (outs), (ins i32mem:$dst), "inc{l}\t$dst",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001720 [(store (add (loadi32 addr:$dst), 1), addr:$dst),
1721 (implicit EFLAGS)]>,
Evan Cheng66f71632007-10-19 21:23:22 +00001722 Requires<[In32BitMode]>;
Chris Lattner57a02302004-08-11 04:31:00 +00001723}
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00001724
Evan Cheng1693e482006-07-19 00:27:29 +00001725let CodeSize = 2 in
Dan Gohmanb1576f52007-07-31 20:11:57 +00001726def DEC8r : I<0xFE, MRM1r, (outs GR8 :$dst), (ins GR8 :$src), "dec{b}\t$dst",
Chris Lattner589ad5d2010-03-25 05:44:01 +00001727 [(set GR8:$dst, EFLAGS, (X86dec_flag GR8:$src))]>;
Evan Cheng1693e482006-07-19 00:27:29 +00001728let isConvertibleToThreeAddress = 1, CodeSize = 1 in { // Can xform into LEA.
Sean Callanan108934c2009-12-18 00:01:26 +00001729def DEC16r : I<0x48, AddRegFrm, (outs GR16:$dst), (ins GR16:$src),
1730 "dec{w}\t$dst",
Chris Lattner589ad5d2010-03-25 05:44:01 +00001731 [(set GR16:$dst, EFLAGS, (X86dec_flag GR16:$src))]>,
Evan Cheng25ab6902006-09-08 06:48:29 +00001732 OpSize, Requires<[In32BitMode]>;
Sean Callanan108934c2009-12-18 00:01:26 +00001733def DEC32r : I<0x48, AddRegFrm, (outs GR32:$dst), (ins GR32:$src),
1734 "dec{l}\t$dst",
Chris Lattner589ad5d2010-03-25 05:44:01 +00001735 [(set GR32:$dst, EFLAGS, (X86dec_flag GR32:$src))]>,
1736 Requires<[In32BitMode]>;
Chris Lattnercc65bee2005-01-02 02:35:46 +00001737}
Chris Lattner57a02302004-08-11 04:31:00 +00001738
Evan Cheng1693e482006-07-19 00:27:29 +00001739let isTwoAddress = 0, CodeSize = 2 in {
Dan Gohmanb1576f52007-07-31 20:11:57 +00001740 def DEC8m : I<0xFE, MRM1m, (outs), (ins i8mem :$dst), "dec{b}\t$dst",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001741 [(store (add (loadi8 addr:$dst), -1), addr:$dst),
1742 (implicit EFLAGS)]>;
Dan Gohmanb1576f52007-07-31 20:11:57 +00001743 def DEC16m : I<0xFF, MRM1m, (outs), (ins i16mem:$dst), "dec{w}\t$dst",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001744 [(store (add (loadi16 addr:$dst), -1), addr:$dst),
1745 (implicit EFLAGS)]>,
Evan Cheng66f71632007-10-19 21:23:22 +00001746 OpSize, Requires<[In32BitMode]>;
Dan Gohmanb1576f52007-07-31 20:11:57 +00001747 def DEC32m : I<0xFF, MRM1m, (outs), (ins i32mem:$dst), "dec{l}\t$dst",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001748 [(store (add (loadi32 addr:$dst), -1), addr:$dst),
1749 (implicit EFLAGS)]>,
Evan Cheng66f71632007-10-19 21:23:22 +00001750 Requires<[In32BitMode]>;
Chris Lattner57a02302004-08-11 04:31:00 +00001751}
Evan Cheng24f2ea32007-09-14 21:48:26 +00001752} // Defs = [EFLAGS]
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00001753
1754// Logical operators...
Evan Cheng24f2ea32007-09-14 21:48:26 +00001755let Defs = [EFLAGS] in {
Chris Lattnercc65bee2005-01-02 02:35:46 +00001756let isCommutable = 1 in { // X = AND Y, Z --> X = AND Z, Y
Chris Lattner589ad5d2010-03-25 05:44:01 +00001757def AND8rr : I<0x20, MRMDestReg,
1758 (outs GR8 :$dst), (ins GR8 :$src1, GR8 :$src2),
1759 "and{b}\t{$src2, $dst|$dst, $src2}",
1760 [(set GR8:$dst, EFLAGS, (X86and_flag GR8:$src1, GR8:$src2))]>;
1761def AND16rr : I<0x21, MRMDestReg,
1762 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
1763 "and{w}\t{$src2, $dst|$dst, $src2}",
1764 [(set GR16:$dst, EFLAGS, (X86and_flag GR16:$src1,
1765 GR16:$src2))]>, OpSize;
1766def AND32rr : I<0x21, MRMDestReg,
1767 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
1768 "and{l}\t{$src2, $dst|$dst, $src2}",
1769 [(set GR32:$dst, EFLAGS, (X86and_flag GR32:$src1,
1770 GR32:$src2))]>;
Chris Lattnercc65bee2005-01-02 02:35:46 +00001771}
Chris Lattner57a02302004-08-11 04:31:00 +00001772
Sean Callanan108934c2009-12-18 00:01:26 +00001773// AND instructions with the destination register in REG and the source register
1774// in R/M. Included for the disassembler.
1775def AND8rr_REV : I<0x22, MRMSrcReg, (outs GR8:$dst), (ins GR8:$src1, GR8:$src2),
1776 "and{b}\t{$src2, $dst|$dst, $src2}", []>;
1777def AND16rr_REV : I<0x23, MRMSrcReg, (outs GR16:$dst),
1778 (ins GR16:$src1, GR16:$src2),
1779 "and{w}\t{$src2, $dst|$dst, $src2}", []>, OpSize;
1780def AND32rr_REV : I<0x23, MRMSrcReg, (outs GR32:$dst),
1781 (ins GR32:$src1, GR32:$src2),
1782 "and{l}\t{$src2, $dst|$dst, $src2}", []>;
1783
Chris Lattner3a173df2004-10-03 20:35:00 +00001784def AND8rm : I<0x22, MRMSrcMem,
Evan Cheng64d80e32007-07-19 01:14:50 +00001785 (outs GR8 :$dst), (ins GR8 :$src1, i8mem :$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001786 "and{b}\t{$src2, $dst|$dst, $src2}",
Chris Lattner589ad5d2010-03-25 05:44:01 +00001787 [(set GR8:$dst, EFLAGS, (X86and_flag GR8:$src1,
1788 (loadi8 addr:$src2)))]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00001789def AND16rm : I<0x23, MRMSrcMem,
Evan Cheng64d80e32007-07-19 01:14:50 +00001790 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001791 "and{w}\t{$src2, $dst|$dst, $src2}",
Chris Lattner589ad5d2010-03-25 05:44:01 +00001792 [(set GR16:$dst, EFLAGS, (X86and_flag GR16:$src1,
1793 (loadi16 addr:$src2)))]>,
1794 OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00001795def AND32rm : I<0x23, MRMSrcMem,
Evan Cheng64d80e32007-07-19 01:14:50 +00001796 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001797 "and{l}\t{$src2, $dst|$dst, $src2}",
Chris Lattner589ad5d2010-03-25 05:44:01 +00001798 [(set GR32:$dst, EFLAGS, (X86and_flag GR32:$src1,
1799 (loadi32 addr:$src2)))]>;
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00001800
Chris Lattner3a173df2004-10-03 20:35:00 +00001801def AND8ri : Ii8<0x80, MRM4r,
Evan Cheng64d80e32007-07-19 01:14:50 +00001802 (outs GR8 :$dst), (ins GR8 :$src1, i8imm :$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001803 "and{b}\t{$src2, $dst|$dst, $src2}",
Chris Lattner589ad5d2010-03-25 05:44:01 +00001804 [(set GR8:$dst, EFLAGS, (X86and_flag GR8:$src1,
1805 imm:$src2))]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00001806def AND16ri : Ii16<0x81, MRM4r,
Evan Cheng64d80e32007-07-19 01:14:50 +00001807 (outs GR16:$dst), (ins GR16:$src1, i16imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001808 "and{w}\t{$src2, $dst|$dst, $src2}",
Chris Lattner589ad5d2010-03-25 05:44:01 +00001809 [(set GR16:$dst, EFLAGS, (X86and_flag GR16:$src1,
1810 imm:$src2))]>, OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00001811def AND32ri : Ii32<0x81, MRM4r,
Evan Cheng64d80e32007-07-19 01:14:50 +00001812 (outs GR32:$dst), (ins GR32:$src1, i32imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001813 "and{l}\t{$src2, $dst|$dst, $src2}",
Chris Lattner589ad5d2010-03-25 05:44:01 +00001814 [(set GR32:$dst, EFLAGS, (X86and_flag GR32:$src1,
1815 imm:$src2))]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00001816def AND16ri8 : Ii8<0x83, MRM4r,
Evan Cheng64d80e32007-07-19 01:14:50 +00001817 (outs GR16:$dst), (ins GR16:$src1, i16i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001818 "and{w}\t{$src2, $dst|$dst, $src2}",
Chris Lattner589ad5d2010-03-25 05:44:01 +00001819 [(set GR16:$dst, EFLAGS, (X86and_flag GR16:$src1,
1820 i16immSExt8:$src2))]>,
Evan Cheng9b6b6422005-12-13 00:14:11 +00001821 OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00001822def AND32ri8 : Ii8<0x83, MRM4r,
Evan Cheng64d80e32007-07-19 01:14:50 +00001823 (outs GR32:$dst), (ins GR32:$src1, i32i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001824 "and{l}\t{$src2, $dst|$dst, $src2}",
Chris Lattner589ad5d2010-03-25 05:44:01 +00001825 [(set GR32:$dst, EFLAGS, (X86and_flag GR32:$src1,
1826 i32immSExt8:$src2))]>;
Chris Lattnerf29ed092004-08-11 05:07:25 +00001827
1828let isTwoAddress = 0 in {
Chris Lattner3a173df2004-10-03 20:35:00 +00001829 def AND8mr : I<0x20, MRMDestMem,
Evan Cheng64d80e32007-07-19 01:14:50 +00001830 (outs), (ins i8mem :$dst, GR8 :$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001831 "and{b}\t{$src, $dst|$dst, $src}",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001832 [(store (and (load addr:$dst), GR8:$src), addr:$dst),
1833 (implicit EFLAGS)]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00001834 def AND16mr : I<0x21, MRMDestMem,
Evan Cheng64d80e32007-07-19 01:14:50 +00001835 (outs), (ins i16mem:$dst, GR16:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001836 "and{w}\t{$src, $dst|$dst, $src}",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001837 [(store (and (load addr:$dst), GR16:$src), addr:$dst),
1838 (implicit EFLAGS)]>,
Evan Cheng0ef3a772005-12-13 01:41:36 +00001839 OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00001840 def AND32mr : I<0x21, MRMDestMem,
Evan Cheng64d80e32007-07-19 01:14:50 +00001841 (outs), (ins i32mem:$dst, GR32:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001842 "and{l}\t{$src, $dst|$dst, $src}",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001843 [(store (and (load addr:$dst), GR32:$src), addr:$dst),
1844 (implicit EFLAGS)]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00001845 def AND8mi : Ii8<0x80, MRM4m,
Evan Cheng64d80e32007-07-19 01:14:50 +00001846 (outs), (ins i8mem :$dst, i8imm :$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001847 "and{b}\t{$src, $dst|$dst, $src}",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001848 [(store (and (loadi8 addr:$dst), imm:$src), addr:$dst),
1849 (implicit EFLAGS)]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00001850 def AND16mi : Ii16<0x81, MRM4m,
Evan Cheng64d80e32007-07-19 01:14:50 +00001851 (outs), (ins i16mem:$dst, i16imm:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001852 "and{w}\t{$src, $dst|$dst, $src}",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001853 [(store (and (loadi16 addr:$dst), imm:$src), addr:$dst),
1854 (implicit EFLAGS)]>,
Evan Cheng0ef3a772005-12-13 01:41:36 +00001855 OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00001856 def AND32mi : Ii32<0x81, MRM4m,
Evan Cheng64d80e32007-07-19 01:14:50 +00001857 (outs), (ins i32mem:$dst, i32imm:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001858 "and{l}\t{$src, $dst|$dst, $src}",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001859 [(store (and (loadi32 addr:$dst), imm:$src), addr:$dst),
1860 (implicit EFLAGS)]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00001861 def AND16mi8 : Ii8<0x83, MRM4m,
Evan Cheng64d80e32007-07-19 01:14:50 +00001862 (outs), (ins i16mem:$dst, i16i8imm :$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001863 "and{w}\t{$src, $dst|$dst, $src}",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001864 [(store (and (load addr:$dst), i16immSExt8:$src), addr:$dst),
1865 (implicit EFLAGS)]>,
Evan Cheng0ef3a772005-12-13 01:41:36 +00001866 OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00001867 def AND32mi8 : Ii8<0x83, MRM4m,
Evan Cheng64d80e32007-07-19 01:14:50 +00001868 (outs), (ins i32mem:$dst, i32i8imm :$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001869 "and{l}\t{$src, $dst|$dst, $src}",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001870 [(store (and (load addr:$dst), i32immSExt8:$src), addr:$dst),
1871 (implicit EFLAGS)]>;
Sean Callanana09caa52009-09-02 00:55:49 +00001872
1873 def AND8i8 : Ii8<0x24, RawFrm, (outs), (ins i8imm:$src),
1874 "and{b}\t{$src, %al|%al, $src}", []>;
1875 def AND16i16 : Ii16<0x25, RawFrm, (outs), (ins i16imm:$src),
1876 "and{w}\t{$src, %ax|%ax, $src}", []>, OpSize;
1877 def AND32i32 : Ii32<0x25, RawFrm, (outs), (ins i32imm:$src),
1878 "and{l}\t{$src, %eax|%eax, $src}", []>;
1879
Chris Lattnerf29ed092004-08-11 05:07:25 +00001880}
1881
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00001882
Chris Lattnercc65bee2005-01-02 02:35:46 +00001883let isCommutable = 1 in { // X = OR Y, Z --> X = OR Z, Y
Sean Callanan108934c2009-12-18 00:01:26 +00001884def OR8rr : I<0x08, MRMDestReg, (outs GR8 :$dst),
1885 (ins GR8 :$src1, GR8 :$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001886 "or{b}\t{$src2, $dst|$dst, $src2}",
Chris Lattner589ad5d2010-03-25 05:44:01 +00001887 [(set GR8:$dst, EFLAGS, (X86or_flag GR8:$src1, GR8:$src2))]>;
Sean Callanan108934c2009-12-18 00:01:26 +00001888def OR16rr : I<0x09, MRMDestReg, (outs GR16:$dst),
1889 (ins GR16:$src1, GR16:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001890 "or{w}\t{$src2, $dst|$dst, $src2}",
Chris Lattner589ad5d2010-03-25 05:44:01 +00001891 [(set GR16:$dst, EFLAGS, (X86or_flag GR16:$src1,GR16:$src2))]>,
1892 OpSize;
Sean Callanan108934c2009-12-18 00:01:26 +00001893def OR32rr : I<0x09, MRMDestReg, (outs GR32:$dst),
1894 (ins GR32:$src1, GR32:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001895 "or{l}\t{$src2, $dst|$dst, $src2}",
Chris Lattner589ad5d2010-03-25 05:44:01 +00001896 [(set GR32:$dst, EFLAGS, (X86or_flag GR32:$src1,GR32:$src2))]>;
Chris Lattnercc65bee2005-01-02 02:35:46 +00001897}
Sean Callanan108934c2009-12-18 00:01:26 +00001898
1899// OR instructions with the destination register in REG and the source register
1900// in R/M. Included for the disassembler.
1901def OR8rr_REV : I<0x0A, MRMSrcReg, (outs GR8:$dst), (ins GR8:$src1, GR8:$src2),
1902 "or{b}\t{$src2, $dst|$dst, $src2}", []>;
1903def OR16rr_REV : I<0x0B, MRMSrcReg, (outs GR16:$dst),
1904 (ins GR16:$src1, GR16:$src2),
1905 "or{w}\t{$src2, $dst|$dst, $src2}", []>, OpSize;
1906def OR32rr_REV : I<0x0B, MRMSrcReg, (outs GR32:$dst),
1907 (ins GR32:$src1, GR32:$src2),
1908 "or{l}\t{$src2, $dst|$dst, $src2}", []>;
1909
Chris Lattner589ad5d2010-03-25 05:44:01 +00001910def OR8rm : I<0x0A, MRMSrcMem, (outs GR8 :$dst),
Sean Callanan108934c2009-12-18 00:01:26 +00001911 (ins GR8 :$src1, i8mem :$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001912 "or{b}\t{$src2, $dst|$dst, $src2}",
Chris Lattner589ad5d2010-03-25 05:44:01 +00001913 [(set GR8:$dst, EFLAGS, (X86or_flag GR8:$src1,
1914 (load addr:$src2)))]>;
1915def OR16rm : I<0x0B, MRMSrcMem, (outs GR16:$dst),
Sean Callanan108934c2009-12-18 00:01:26 +00001916 (ins GR16:$src1, i16mem:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001917 "or{w}\t{$src2, $dst|$dst, $src2}",
Chris Lattner589ad5d2010-03-25 05:44:01 +00001918 [(set GR16:$dst, EFLAGS, (X86or_flag GR16:$src1,
1919 (load addr:$src2)))]>,
1920 OpSize;
1921def OR32rm : I<0x0B, MRMSrcMem, (outs GR32:$dst),
Sean Callanan108934c2009-12-18 00:01:26 +00001922 (ins GR32:$src1, i32mem:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001923 "or{l}\t{$src2, $dst|$dst, $src2}",
Chris Lattner589ad5d2010-03-25 05:44:01 +00001924 [(set GR32:$dst, EFLAGS, (X86or_flag GR32:$src1,
1925 (load addr:$src2)))]>;
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00001926
Sean Callanan108934c2009-12-18 00:01:26 +00001927def OR8ri : Ii8 <0x80, MRM1r, (outs GR8 :$dst),
1928 (ins GR8 :$src1, i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001929 "or{b}\t{$src2, $dst|$dst, $src2}",
Chris Lattner589ad5d2010-03-25 05:44:01 +00001930 [(set GR8:$dst,EFLAGS, (X86or_flag GR8:$src1, imm:$src2))]>;
Sean Callanan108934c2009-12-18 00:01:26 +00001931def OR16ri : Ii16<0x81, MRM1r, (outs GR16:$dst),
1932 (ins GR16:$src1, i16imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001933 "or{w}\t{$src2, $dst|$dst, $src2}",
Chris Lattner589ad5d2010-03-25 05:44:01 +00001934 [(set GR16:$dst, EFLAGS, (X86or_flag GR16:$src1,
1935 imm:$src2))]>, OpSize;
Sean Callanan108934c2009-12-18 00:01:26 +00001936def OR32ri : Ii32<0x81, MRM1r, (outs GR32:$dst),
1937 (ins GR32:$src1, i32imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001938 "or{l}\t{$src2, $dst|$dst, $src2}",
Chris Lattner589ad5d2010-03-25 05:44:01 +00001939 [(set GR32:$dst, EFLAGS, (X86or_flag GR32:$src1,
1940 imm:$src2))]>;
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00001941
Sean Callanan108934c2009-12-18 00:01:26 +00001942def OR16ri8 : Ii8<0x83, MRM1r, (outs GR16:$dst),
1943 (ins GR16:$src1, i16i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001944 "or{w}\t{$src2, $dst|$dst, $src2}",
Chris Lattner589ad5d2010-03-25 05:44:01 +00001945 [(set GR16:$dst, EFLAGS, (X86or_flag GR16:$src1,
1946 i16immSExt8:$src2))]>, OpSize;
Sean Callanan108934c2009-12-18 00:01:26 +00001947def OR32ri8 : Ii8<0x83, MRM1r, (outs GR32:$dst),
1948 (ins GR32:$src1, i32i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001949 "or{l}\t{$src2, $dst|$dst, $src2}",
Chris Lattner589ad5d2010-03-25 05:44:01 +00001950 [(set GR32:$dst, EFLAGS, (X86or_flag GR32:$src1,
1951 i32immSExt8:$src2))]>;
Chris Lattner57a02302004-08-11 04:31:00 +00001952let isTwoAddress = 0 in {
Evan Cheng64d80e32007-07-19 01:14:50 +00001953 def OR8mr : I<0x08, MRMDestMem, (outs), (ins i8mem:$dst, GR8:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001954 "or{b}\t{$src, $dst|$dst, $src}",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001955 [(store (or (load addr:$dst), GR8:$src), addr:$dst),
1956 (implicit EFLAGS)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00001957 def OR16mr : I<0x09, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001958 "or{w}\t{$src, $dst|$dst, $src}",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001959 [(store (or (load addr:$dst), GR16:$src), addr:$dst),
1960 (implicit EFLAGS)]>, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00001961 def OR32mr : I<0x09, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001962 "or{l}\t{$src, $dst|$dst, $src}",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001963 [(store (or (load addr:$dst), GR32:$src), addr:$dst),
1964 (implicit EFLAGS)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00001965 def OR8mi : Ii8<0x80, MRM1m, (outs), (ins i8mem :$dst, i8imm:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001966 "or{b}\t{$src, $dst|$dst, $src}",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001967 [(store (or (loadi8 addr:$dst), imm:$src), addr:$dst),
1968 (implicit EFLAGS)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00001969 def OR16mi : Ii16<0x81, MRM1m, (outs), (ins i16mem:$dst, i16imm:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001970 "or{w}\t{$src, $dst|$dst, $src}",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001971 [(store (or (loadi16 addr:$dst), imm:$src), addr:$dst),
1972 (implicit EFLAGS)]>,
Evan Cheng0ef3a772005-12-13 01:41:36 +00001973 OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00001974 def OR32mi : Ii32<0x81, MRM1m, (outs), (ins i32mem:$dst, i32imm:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001975 "or{l}\t{$src, $dst|$dst, $src}",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001976 [(store (or (loadi32 addr:$dst), imm:$src), addr:$dst),
1977 (implicit EFLAGS)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00001978 def OR16mi8 : Ii8<0x83, MRM1m, (outs), (ins i16mem:$dst, i16i8imm:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001979 "or{w}\t{$src, $dst|$dst, $src}",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001980 [(store (or (load addr:$dst), i16immSExt8:$src), addr:$dst),
1981 (implicit EFLAGS)]>,
Evan Cheng0ef3a772005-12-13 01:41:36 +00001982 OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00001983 def OR32mi8 : Ii8<0x83, MRM1m, (outs), (ins i32mem:$dst, i32i8imm:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001984 "or{l}\t{$src, $dst|$dst, $src}",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001985 [(store (or (load addr:$dst), i32immSExt8:$src), addr:$dst),
1986 (implicit EFLAGS)]>;
Sean Callanand00025a2009-09-11 19:01:56 +00001987
1988 def OR8i8 : Ii8 <0x0C, RawFrm, (outs), (ins i8imm:$src),
1989 "or{b}\t{$src, %al|%al, $src}", []>;
1990 def OR16i16 : Ii16 <0x0D, RawFrm, (outs), (ins i16imm:$src),
1991 "or{w}\t{$src, %ax|%ax, $src}", []>, OpSize;
1992 def OR32i32 : Ii32 <0x0D, RawFrm, (outs), (ins i32imm:$src),
1993 "or{l}\t{$src, %eax|%eax, $src}", []>;
Bill Wendlingbd0879d2008-05-29 01:02:09 +00001994} // isTwoAddress = 0
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00001995
1996
Evan Cheng359e9372008-06-18 08:13:07 +00001997let isCommutable = 1 in { // X = XOR Y, Z --> X = XOR Z, Y
Bill Wendlingbd0879d2008-05-29 01:02:09 +00001998 def XOR8rr : I<0x30, MRMDestReg,
1999 (outs GR8 :$dst), (ins GR8 :$src1, GR8 :$src2),
2000 "xor{b}\t{$src2, $dst|$dst, $src2}",
Chris Lattner589ad5d2010-03-25 05:44:01 +00002001 [(set GR8:$dst, EFLAGS, (X86xor_flag GR8:$src1,
2002 GR8:$src2))]>;
Bill Wendlingbd0879d2008-05-29 01:02:09 +00002003 def XOR16rr : I<0x31, MRMDestReg,
2004 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
2005 "xor{w}\t{$src2, $dst|$dst, $src2}",
Chris Lattner589ad5d2010-03-25 05:44:01 +00002006 [(set GR16:$dst, EFLAGS, (X86xor_flag GR16:$src1,
2007 GR16:$src2))]>, OpSize;
Bill Wendlingbd0879d2008-05-29 01:02:09 +00002008 def XOR32rr : I<0x31, MRMDestReg,
2009 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
2010 "xor{l}\t{$src2, $dst|$dst, $src2}",
Chris Lattner589ad5d2010-03-25 05:44:01 +00002011 [(set GR32:$dst, EFLAGS, (X86xor_flag GR32:$src1,
2012 GR32:$src2))]>;
Evan Cheng359e9372008-06-18 08:13:07 +00002013} // isCommutable = 1
Chris Lattnercc65bee2005-01-02 02:35:46 +00002014
Sean Callanan108934c2009-12-18 00:01:26 +00002015// XOR instructions with the destination register in REG and the source register
2016// in R/M. Included for the disassembler.
2017def XOR8rr_REV : I<0x32, MRMSrcReg, (outs GR8:$dst), (ins GR8:$src1, GR8:$src2),
2018 "xor{b}\t{$src2, $dst|$dst, $src2}", []>;
2019def XOR16rr_REV : I<0x33, MRMSrcReg, (outs GR16:$dst),
2020 (ins GR16:$src1, GR16:$src2),
2021 "xor{w}\t{$src2, $dst|$dst, $src2}", []>, OpSize;
2022def XOR32rr_REV : I<0x33, MRMSrcReg, (outs GR32:$dst),
2023 (ins GR32:$src1, GR32:$src2),
2024 "xor{l}\t{$src2, $dst|$dst, $src2}", []>;
2025
Chris Lattner589ad5d2010-03-25 05:44:01 +00002026def XOR8rm : I<0x32, MRMSrcMem,
Evan Cheng64d80e32007-07-19 01:14:50 +00002027 (outs GR8 :$dst), (ins GR8:$src1, i8mem :$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002028 "xor{b}\t{$src2, $dst|$dst, $src2}",
Chris Lattner589ad5d2010-03-25 05:44:01 +00002029 [(set GR8:$dst, EFLAGS, (X86xor_flag GR8:$src1,
2030 (load addr:$src2)))]>;
2031def XOR16rm : I<0x33, MRMSrcMem,
Evan Cheng64d80e32007-07-19 01:14:50 +00002032 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002033 "xor{w}\t{$src2, $dst|$dst, $src2}",
Chris Lattner589ad5d2010-03-25 05:44:01 +00002034 [(set GR16:$dst, EFLAGS, (X86xor_flag GR16:$src1,
2035 (load addr:$src2)))]>,
Bill Wendlingbd0879d2008-05-29 01:02:09 +00002036 OpSize;
Chris Lattner589ad5d2010-03-25 05:44:01 +00002037def XOR32rm : I<0x33, MRMSrcMem,
Evan Cheng64d80e32007-07-19 01:14:50 +00002038 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002039 "xor{l}\t{$src2, $dst|$dst, $src2}",
Chris Lattner589ad5d2010-03-25 05:44:01 +00002040 [(set GR32:$dst, EFLAGS, (X86xor_flag GR32:$src1,
2041 (load addr:$src2)))]>;
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00002042
Chris Lattner589ad5d2010-03-25 05:44:01 +00002043def XOR8ri : Ii8<0x80, MRM6r,
2044 (outs GR8:$dst), (ins GR8:$src1, i8imm:$src2),
2045 "xor{b}\t{$src2, $dst|$dst, $src2}",
2046 [(set GR8:$dst, EFLAGS, (X86xor_flag GR8:$src1, imm:$src2))]>;
2047def XOR16ri : Ii16<0x81, MRM6r,
2048 (outs GR16:$dst), (ins GR16:$src1, i16imm:$src2),
2049 "xor{w}\t{$src2, $dst|$dst, $src2}",
2050 [(set GR16:$dst, EFLAGS, (X86xor_flag GR16:$src1,
2051 imm:$src2))]>, OpSize;
Bill Wendling75cf88f2008-05-29 03:46:36 +00002052def XOR32ri : Ii32<0x81, MRM6r,
2053 (outs GR32:$dst), (ins GR32:$src1, i32imm:$src2),
2054 "xor{l}\t{$src2, $dst|$dst, $src2}",
Chris Lattner589ad5d2010-03-25 05:44:01 +00002055 [(set GR32:$dst, EFLAGS, (X86xor_flag GR32:$src1,
2056 imm:$src2))]>;
Bill Wendling75cf88f2008-05-29 03:46:36 +00002057def XOR16ri8 : Ii8<0x83, MRM6r,
2058 (outs GR16:$dst), (ins GR16:$src1, i16i8imm:$src2),
2059 "xor{w}\t{$src2, $dst|$dst, $src2}",
Chris Lattner589ad5d2010-03-25 05:44:01 +00002060 [(set GR16:$dst, EFLAGS, (X86xor_flag GR16:$src1,
2061 i16immSExt8:$src2))]>,
Bill Wendling75cf88f2008-05-29 03:46:36 +00002062 OpSize;
2063def XOR32ri8 : Ii8<0x83, MRM6r,
2064 (outs GR32:$dst), (ins GR32:$src1, i32i8imm:$src2),
2065 "xor{l}\t{$src2, $dst|$dst, $src2}",
Chris Lattner589ad5d2010-03-25 05:44:01 +00002066 [(set GR32:$dst, EFLAGS, (X86xor_flag GR32:$src1,
2067 i32immSExt8:$src2))]>;
Bill Wendlingbd0879d2008-05-29 01:02:09 +00002068
Chris Lattner57a02302004-08-11 04:31:00 +00002069let isTwoAddress = 0 in {
Chris Lattner3a173df2004-10-03 20:35:00 +00002070 def XOR8mr : I<0x30, MRMDestMem,
Evan Cheng64d80e32007-07-19 01:14:50 +00002071 (outs), (ins i8mem :$dst, GR8 :$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002072 "xor{b}\t{$src, $dst|$dst, $src}",
Dan Gohman09a2609e2009-03-03 19:53:46 +00002073 [(store (xor (load addr:$dst), GR8:$src), addr:$dst),
2074 (implicit EFLAGS)]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00002075 def XOR16mr : I<0x31, MRMDestMem,
Evan Cheng64d80e32007-07-19 01:14:50 +00002076 (outs), (ins i16mem:$dst, GR16:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002077 "xor{w}\t{$src, $dst|$dst, $src}",
Dan Gohman09a2609e2009-03-03 19:53:46 +00002078 [(store (xor (load addr:$dst), GR16:$src), addr:$dst),
2079 (implicit EFLAGS)]>,
Evan Cheng0ef3a772005-12-13 01:41:36 +00002080 OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00002081 def XOR32mr : I<0x31, MRMDestMem,
Evan Cheng64d80e32007-07-19 01:14:50 +00002082 (outs), (ins i32mem:$dst, GR32:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002083 "xor{l}\t{$src, $dst|$dst, $src}",
Dan Gohman09a2609e2009-03-03 19:53:46 +00002084 [(store (xor (load addr:$dst), GR32:$src), addr:$dst),
2085 (implicit EFLAGS)]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00002086 def XOR8mi : Ii8<0x80, MRM6m,
Evan Cheng64d80e32007-07-19 01:14:50 +00002087 (outs), (ins i8mem :$dst, i8imm :$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002088 "xor{b}\t{$src, $dst|$dst, $src}",
Dan Gohman09a2609e2009-03-03 19:53:46 +00002089 [(store (xor (loadi8 addr:$dst), imm:$src), addr:$dst),
2090 (implicit EFLAGS)]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00002091 def XOR16mi : Ii16<0x81, MRM6m,
Evan Cheng64d80e32007-07-19 01:14:50 +00002092 (outs), (ins i16mem:$dst, i16imm:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002093 "xor{w}\t{$src, $dst|$dst, $src}",
Dan Gohman09a2609e2009-03-03 19:53:46 +00002094 [(store (xor (loadi16 addr:$dst), imm:$src), addr:$dst),
2095 (implicit EFLAGS)]>,
Evan Cheng0ef3a772005-12-13 01:41:36 +00002096 OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00002097 def XOR32mi : Ii32<0x81, MRM6m,
Evan Cheng64d80e32007-07-19 01:14:50 +00002098 (outs), (ins i32mem:$dst, i32imm:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002099 "xor{l}\t{$src, $dst|$dst, $src}",
Dan Gohman09a2609e2009-03-03 19:53:46 +00002100 [(store (xor (loadi32 addr:$dst), imm:$src), addr:$dst),
2101 (implicit EFLAGS)]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00002102 def XOR16mi8 : Ii8<0x83, MRM6m,
Evan Cheng64d80e32007-07-19 01:14:50 +00002103 (outs), (ins i16mem:$dst, i16i8imm :$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002104 "xor{w}\t{$src, $dst|$dst, $src}",
Dan Gohman09a2609e2009-03-03 19:53:46 +00002105 [(store (xor (load addr:$dst), i16immSExt8:$src), addr:$dst),
2106 (implicit EFLAGS)]>,
Evan Cheng0ef3a772005-12-13 01:41:36 +00002107 OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00002108 def XOR32mi8 : Ii8<0x83, MRM6m,
Evan Cheng64d80e32007-07-19 01:14:50 +00002109 (outs), (ins i32mem:$dst, i32i8imm :$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002110 "xor{l}\t{$src, $dst|$dst, $src}",
Dan Gohman09a2609e2009-03-03 19:53:46 +00002111 [(store (xor (load addr:$dst), i32immSExt8:$src), addr:$dst),
2112 (implicit EFLAGS)]>;
Sean Callanan7893ec62009-09-10 19:52:26 +00002113
Chris Lattner589ad5d2010-03-25 05:44:01 +00002114 def XOR8i8 : Ii8 <0x34, RawFrm, (outs), (ins i8imm:$src),
2115 "xor{b}\t{$src, %al|%al, $src}", []>;
2116 def XOR16i16 : Ii16<0x35, RawFrm, (outs), (ins i16imm:$src),
2117 "xor{w}\t{$src, %ax|%ax, $src}", []>, OpSize;
2118 def XOR32i32 : Ii32<0x35, RawFrm, (outs), (ins i32imm:$src),
2119 "xor{l}\t{$src, %eax|%eax, $src}", []>;
Bill Wendlingbd0879d2008-05-29 01:02:09 +00002120} // isTwoAddress = 0
Evan Cheng24f2ea32007-09-14 21:48:26 +00002121} // Defs = [EFLAGS]
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00002122
2123// Shift instructions
Evan Cheng24f2ea32007-09-14 21:48:26 +00002124let Defs = [EFLAGS] in {
Evan Cheng071a2792007-09-11 19:55:27 +00002125let Uses = [CL] in {
Evan Cheng64d80e32007-07-19 01:14:50 +00002126def SHL8rCL : I<0xD2, MRM4r, (outs GR8 :$dst), (ins GR8 :$src),
Eli Friedmanaace4b12009-06-19 04:48:38 +00002127 "shl{b}\t{%cl, $dst|$dst, CL}",
Evan Cheng071a2792007-09-11 19:55:27 +00002128 [(set GR8:$dst, (shl GR8:$src, CL))]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00002129def SHL16rCL : I<0xD3, MRM4r, (outs GR16:$dst), (ins GR16:$src),
Eli Friedmanaace4b12009-06-19 04:48:38 +00002130 "shl{w}\t{%cl, $dst|$dst, CL}",
Evan Cheng071a2792007-09-11 19:55:27 +00002131 [(set GR16:$dst, (shl GR16:$src, CL))]>, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00002132def SHL32rCL : I<0xD3, MRM4r, (outs GR32:$dst), (ins GR32:$src),
Eli Friedmanaace4b12009-06-19 04:48:38 +00002133 "shl{l}\t{%cl, $dst|$dst, CL}",
Evan Cheng071a2792007-09-11 19:55:27 +00002134 [(set GR32:$dst, (shl GR32:$src, CL))]>;
Bill Wendlingbd0879d2008-05-29 01:02:09 +00002135} // Uses = [CL]
Chris Lattnercc65bee2005-01-02 02:35:46 +00002136
Evan Cheng64d80e32007-07-19 01:14:50 +00002137def SHL8ri : Ii8<0xC0, MRM4r, (outs GR8 :$dst), (ins GR8 :$src1, i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002138 "shl{b}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00002139 [(set GR8:$dst, (shl GR8:$src1, (i8 imm:$src2)))]>;
Chris Lattnercc65bee2005-01-02 02:35:46 +00002140let isConvertibleToThreeAddress = 1 in { // Can transform into LEA.
Evan Cheng64d80e32007-07-19 01:14:50 +00002141def SHL16ri : Ii8<0xC1, MRM4r, (outs GR16:$dst), (ins GR16:$src1, i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002142 "shl{w}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00002143 [(set GR16:$dst, (shl GR16:$src1, (i8 imm:$src2)))]>, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00002144def SHL32ri : Ii8<0xC1, MRM4r, (outs GR32:$dst), (ins GR32:$src1, i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002145 "shl{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00002146 [(set GR32:$dst, (shl GR32:$src1, (i8 imm:$src2)))]>;
Sean Callanan13cf8e92009-09-16 02:28:43 +00002147
2148// NOTE: We don't include patterns for shifts of a register by one, because
2149// 'add reg,reg' is cheaper.
2150
2151def SHL8r1 : I<0xD0, MRM4r, (outs GR8:$dst), (ins GR8:$src1),
2152 "shl{b}\t$dst", []>;
2153def SHL16r1 : I<0xD1, MRM4r, (outs GR16:$dst), (ins GR16:$src1),
2154 "shl{w}\t$dst", []>, OpSize;
2155def SHL32r1 : I<0xD1, MRM4r, (outs GR32:$dst), (ins GR32:$src1),
2156 "shl{l}\t$dst", []>;
2157
Bill Wendlingbd0879d2008-05-29 01:02:09 +00002158} // isConvertibleToThreeAddress = 1
Evan Cheng09c54572006-06-29 00:36:51 +00002159
Chris Lattnerf29ed092004-08-11 05:07:25 +00002160let isTwoAddress = 0 in {
Evan Cheng071a2792007-09-11 19:55:27 +00002161 let Uses = [CL] in {
Evan Cheng64d80e32007-07-19 01:14:50 +00002162 def SHL8mCL : I<0xD2, MRM4m, (outs), (ins i8mem :$dst),
Eli Friedmanaace4b12009-06-19 04:48:38 +00002163 "shl{b}\t{%cl, $dst|$dst, CL}",
Evan Cheng071a2792007-09-11 19:55:27 +00002164 [(store (shl (loadi8 addr:$dst), CL), addr:$dst)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00002165 def SHL16mCL : I<0xD3, MRM4m, (outs), (ins i16mem:$dst),
Eli Friedmanaace4b12009-06-19 04:48:38 +00002166 "shl{w}\t{%cl, $dst|$dst, CL}",
Evan Cheng071a2792007-09-11 19:55:27 +00002167 [(store (shl (loadi16 addr:$dst), CL), addr:$dst)]>, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00002168 def SHL32mCL : I<0xD3, MRM4m, (outs), (ins i32mem:$dst),
Eli Friedmanaace4b12009-06-19 04:48:38 +00002169 "shl{l}\t{%cl, $dst|$dst, CL}",
Evan Cheng071a2792007-09-11 19:55:27 +00002170 [(store (shl (loadi32 addr:$dst), CL), addr:$dst)]>;
2171 }
Evan Cheng64d80e32007-07-19 01:14:50 +00002172 def SHL8mi : Ii8<0xC0, MRM4m, (outs), (ins i8mem :$dst, i8imm:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002173 "shl{b}\t{$src, $dst|$dst, $src}",
Evan Cheng763b0292005-12-13 02:34:51 +00002174 [(store (shl (loadi8 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00002175 def SHL16mi : Ii8<0xC1, MRM4m, (outs), (ins i16mem:$dst, i8imm:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002176 "shl{w}\t{$src, $dst|$dst, $src}",
Evan Cheng763b0292005-12-13 02:34:51 +00002177 [(store (shl (loadi16 addr:$dst), (i8 imm:$src)), addr:$dst)]>,
2178 OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00002179 def SHL32mi : Ii8<0xC1, MRM4m, (outs), (ins i32mem:$dst, i8imm:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002180 "shl{l}\t{$src, $dst|$dst, $src}",
Evan Cheng763b0292005-12-13 02:34:51 +00002181 [(store (shl (loadi32 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
Evan Cheng09c54572006-06-29 00:36:51 +00002182
2183 // Shift by 1
Evan Cheng64d80e32007-07-19 01:14:50 +00002184 def SHL8m1 : I<0xD0, MRM4m, (outs), (ins i8mem :$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002185 "shl{b}\t$dst",
Evan Cheng09c54572006-06-29 00:36:51 +00002186 [(store (shl (loadi8 addr:$dst), (i8 1)), addr:$dst)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00002187 def SHL16m1 : I<0xD1, MRM4m, (outs), (ins i16mem:$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002188 "shl{w}\t$dst",
Evan Cheng09c54572006-06-29 00:36:51 +00002189 [(store (shl (loadi16 addr:$dst), (i8 1)), addr:$dst)]>,
2190 OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00002191 def SHL32m1 : I<0xD1, MRM4m, (outs), (ins i32mem:$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002192 "shl{l}\t$dst",
Evan Cheng09c54572006-06-29 00:36:51 +00002193 [(store (shl (loadi32 addr:$dst), (i8 1)), addr:$dst)]>;
Chris Lattnerf29ed092004-08-11 05:07:25 +00002194}
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00002195
Evan Cheng071a2792007-09-11 19:55:27 +00002196let Uses = [CL] in {
Evan Cheng64d80e32007-07-19 01:14:50 +00002197def SHR8rCL : I<0xD2, MRM5r, (outs GR8 :$dst), (ins GR8 :$src),
Eli Friedmanaace4b12009-06-19 04:48:38 +00002198 "shr{b}\t{%cl, $dst|$dst, CL}",
Evan Cheng071a2792007-09-11 19:55:27 +00002199 [(set GR8:$dst, (srl GR8:$src, CL))]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00002200def SHR16rCL : I<0xD3, MRM5r, (outs GR16:$dst), (ins GR16:$src),
Eli Friedmanaace4b12009-06-19 04:48:38 +00002201 "shr{w}\t{%cl, $dst|$dst, CL}",
Evan Cheng071a2792007-09-11 19:55:27 +00002202 [(set GR16:$dst, (srl GR16:$src, CL))]>, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00002203def SHR32rCL : I<0xD3, MRM5r, (outs GR32:$dst), (ins GR32:$src),
Eli Friedmanaace4b12009-06-19 04:48:38 +00002204 "shr{l}\t{%cl, $dst|$dst, CL}",
Evan Cheng071a2792007-09-11 19:55:27 +00002205 [(set GR32:$dst, (srl GR32:$src, CL))]>;
2206}
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00002207
Evan Cheng64d80e32007-07-19 01:14:50 +00002208def SHR8ri : Ii8<0xC0, MRM5r, (outs GR8:$dst), (ins GR8:$src1, i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002209 "shr{b}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00002210 [(set GR8:$dst, (srl GR8:$src1, (i8 imm:$src2)))]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00002211def SHR16ri : Ii8<0xC1, MRM5r, (outs GR16:$dst), (ins GR16:$src1, i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002212 "shr{w}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00002213 [(set GR16:$dst, (srl GR16:$src1, (i8 imm:$src2)))]>, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00002214def SHR32ri : Ii8<0xC1, MRM5r, (outs GR32:$dst), (ins GR32:$src1, i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002215 "shr{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00002216 [(set GR32:$dst, (srl GR32:$src1, (i8 imm:$src2)))]>;
Chris Lattnerf29ed092004-08-11 05:07:25 +00002217
Evan Cheng09c54572006-06-29 00:36:51 +00002218// Shift by 1
Evan Cheng64d80e32007-07-19 01:14:50 +00002219def SHR8r1 : I<0xD0, MRM5r, (outs GR8:$dst), (ins GR8:$src1),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002220 "shr{b}\t$dst",
Evan Cheng09c54572006-06-29 00:36:51 +00002221 [(set GR8:$dst, (srl GR8:$src1, (i8 1)))]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00002222def SHR16r1 : I<0xD1, MRM5r, (outs GR16:$dst), (ins GR16:$src1),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002223 "shr{w}\t$dst",
Evan Cheng09c54572006-06-29 00:36:51 +00002224 [(set GR16:$dst, (srl GR16:$src1, (i8 1)))]>, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00002225def SHR32r1 : I<0xD1, MRM5r, (outs GR32:$dst), (ins GR32:$src1),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002226 "shr{l}\t$dst",
Evan Cheng09c54572006-06-29 00:36:51 +00002227 [(set GR32:$dst, (srl GR32:$src1, (i8 1)))]>;
2228
Chris Lattner57a02302004-08-11 04:31:00 +00002229let isTwoAddress = 0 in {
Evan Cheng071a2792007-09-11 19:55:27 +00002230 let Uses = [CL] in {
Evan Cheng64d80e32007-07-19 01:14:50 +00002231 def SHR8mCL : I<0xD2, MRM5m, (outs), (ins i8mem :$dst),
Eli Friedmanaace4b12009-06-19 04:48:38 +00002232 "shr{b}\t{%cl, $dst|$dst, CL}",
Evan Cheng071a2792007-09-11 19:55:27 +00002233 [(store (srl (loadi8 addr:$dst), CL), addr:$dst)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00002234 def SHR16mCL : I<0xD3, MRM5m, (outs), (ins i16mem:$dst),
Eli Friedmanaace4b12009-06-19 04:48:38 +00002235 "shr{w}\t{%cl, $dst|$dst, CL}",
Evan Cheng85dd8892005-12-13 07:24:22 +00002236 [(store (srl (loadi16 addr:$dst), CL), addr:$dst)]>,
Evan Cheng071a2792007-09-11 19:55:27 +00002237 OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00002238 def SHR32mCL : I<0xD3, MRM5m, (outs), (ins i32mem:$dst),
Eli Friedmanaace4b12009-06-19 04:48:38 +00002239 "shr{l}\t{%cl, $dst|$dst, CL}",
Evan Cheng071a2792007-09-11 19:55:27 +00002240 [(store (srl (loadi32 addr:$dst), CL), addr:$dst)]>;
2241 }
Evan Cheng64d80e32007-07-19 01:14:50 +00002242 def SHR8mi : Ii8<0xC0, MRM5m, (outs), (ins i8mem :$dst, i8imm:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002243 "shr{b}\t{$src, $dst|$dst, $src}",
Evan Cheng85dd8892005-12-13 07:24:22 +00002244 [(store (srl (loadi8 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00002245 def SHR16mi : Ii8<0xC1, MRM5m, (outs), (ins i16mem:$dst, i8imm:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002246 "shr{w}\t{$src, $dst|$dst, $src}",
Evan Cheng85dd8892005-12-13 07:24:22 +00002247 [(store (srl (loadi16 addr:$dst), (i8 imm:$src)), addr:$dst)]>,
2248 OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00002249 def SHR32mi : Ii8<0xC1, MRM5m, (outs), (ins i32mem:$dst, i8imm:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002250 "shr{l}\t{$src, $dst|$dst, $src}",
Evan Cheng85dd8892005-12-13 07:24:22 +00002251 [(store (srl (loadi32 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
Evan Cheng09c54572006-06-29 00:36:51 +00002252
2253 // Shift by 1
Evan Cheng64d80e32007-07-19 01:14:50 +00002254 def SHR8m1 : I<0xD0, MRM5m, (outs), (ins i8mem :$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002255 "shr{b}\t$dst",
Evan Cheng09c54572006-06-29 00:36:51 +00002256 [(store (srl (loadi8 addr:$dst), (i8 1)), addr:$dst)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00002257 def SHR16m1 : I<0xD1, MRM5m, (outs), (ins i16mem:$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002258 "shr{w}\t$dst",
Evan Cheng09c54572006-06-29 00:36:51 +00002259 [(store (srl (loadi16 addr:$dst), (i8 1)), addr:$dst)]>,OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00002260 def SHR32m1 : I<0xD1, MRM5m, (outs), (ins i32mem:$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002261 "shr{l}\t$dst",
Evan Cheng09c54572006-06-29 00:36:51 +00002262 [(store (srl (loadi32 addr:$dst), (i8 1)), addr:$dst)]>;
Chris Lattner57a02302004-08-11 04:31:00 +00002263}
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00002264
Evan Cheng071a2792007-09-11 19:55:27 +00002265let Uses = [CL] in {
Evan Cheng64d80e32007-07-19 01:14:50 +00002266def SAR8rCL : I<0xD2, MRM7r, (outs GR8 :$dst), (ins GR8 :$src),
Eli Friedmanaace4b12009-06-19 04:48:38 +00002267 "sar{b}\t{%cl, $dst|$dst, CL}",
Evan Cheng071a2792007-09-11 19:55:27 +00002268 [(set GR8:$dst, (sra GR8:$src, CL))]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00002269def SAR16rCL : I<0xD3, MRM7r, (outs GR16:$dst), (ins GR16:$src),
Eli Friedmanaace4b12009-06-19 04:48:38 +00002270 "sar{w}\t{%cl, $dst|$dst, CL}",
Evan Cheng071a2792007-09-11 19:55:27 +00002271 [(set GR16:$dst, (sra GR16:$src, CL))]>, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00002272def SAR32rCL : I<0xD3, MRM7r, (outs GR32:$dst), (ins GR32:$src),
Eli Friedmanaace4b12009-06-19 04:48:38 +00002273 "sar{l}\t{%cl, $dst|$dst, CL}",
Evan Cheng071a2792007-09-11 19:55:27 +00002274 [(set GR32:$dst, (sra GR32:$src, CL))]>;
2275}
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00002276
Evan Cheng64d80e32007-07-19 01:14:50 +00002277def SAR8ri : Ii8<0xC0, MRM7r, (outs GR8 :$dst), (ins GR8 :$src1, i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002278 "sar{b}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00002279 [(set GR8:$dst, (sra GR8:$src1, (i8 imm:$src2)))]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00002280def SAR16ri : Ii8<0xC1, MRM7r, (outs GR16:$dst), (ins GR16:$src1, i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002281 "sar{w}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00002282 [(set GR16:$dst, (sra GR16:$src1, (i8 imm:$src2)))]>,
Chris Lattner3d36a9f2005-12-05 02:40:25 +00002283 OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00002284def SAR32ri : Ii8<0xC1, MRM7r, (outs GR32:$dst), (ins GR32:$src1, i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002285 "sar{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00002286 [(set GR32:$dst, (sra GR32:$src1, (i8 imm:$src2)))]>;
Evan Cheng09c54572006-06-29 00:36:51 +00002287
2288// Shift by 1
Evan Cheng64d80e32007-07-19 01:14:50 +00002289def SAR8r1 : I<0xD0, MRM7r, (outs GR8 :$dst), (ins GR8 :$src1),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002290 "sar{b}\t$dst",
Evan Cheng09c54572006-06-29 00:36:51 +00002291 [(set GR8:$dst, (sra GR8:$src1, (i8 1)))]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00002292def SAR16r1 : I<0xD1, MRM7r, (outs GR16:$dst), (ins GR16:$src1),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002293 "sar{w}\t$dst",
Evan Cheng09c54572006-06-29 00:36:51 +00002294 [(set GR16:$dst, (sra GR16:$src1, (i8 1)))]>, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00002295def SAR32r1 : I<0xD1, MRM7r, (outs GR32:$dst), (ins GR32:$src1),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002296 "sar{l}\t$dst",
Evan Cheng09c54572006-06-29 00:36:51 +00002297 [(set GR32:$dst, (sra GR32:$src1, (i8 1)))]>;
2298
Chris Lattnerf29ed092004-08-11 05:07:25 +00002299let isTwoAddress = 0 in {
Evan Cheng071a2792007-09-11 19:55:27 +00002300 let Uses = [CL] in {
Evan Cheng64d80e32007-07-19 01:14:50 +00002301 def SAR8mCL : I<0xD2, MRM7m, (outs), (ins i8mem :$dst),
Eli Friedmanaace4b12009-06-19 04:48:38 +00002302 "sar{b}\t{%cl, $dst|$dst, CL}",
Evan Cheng071a2792007-09-11 19:55:27 +00002303 [(store (sra (loadi8 addr:$dst), CL), addr:$dst)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00002304 def SAR16mCL : I<0xD3, MRM7m, (outs), (ins i16mem:$dst),
Eli Friedmanaace4b12009-06-19 04:48:38 +00002305 "sar{w}\t{%cl, $dst|$dst, CL}",
Evan Cheng071a2792007-09-11 19:55:27 +00002306 [(store (sra (loadi16 addr:$dst), CL), addr:$dst)]>, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00002307 def SAR32mCL : I<0xD3, MRM7m, (outs), (ins i32mem:$dst),
Eli Friedmanaace4b12009-06-19 04:48:38 +00002308 "sar{l}\t{%cl, $dst|$dst, CL}",
Evan Cheng071a2792007-09-11 19:55:27 +00002309 [(store (sra (loadi32 addr:$dst), CL), addr:$dst)]>;
2310 }
Evan Cheng64d80e32007-07-19 01:14:50 +00002311 def SAR8mi : Ii8<0xC0, MRM7m, (outs), (ins i8mem :$dst, i8imm:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002312 "sar{b}\t{$src, $dst|$dst, $src}",
Evan Cheng85dd8892005-12-13 07:24:22 +00002313 [(store (sra (loadi8 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00002314 def SAR16mi : Ii8<0xC1, MRM7m, (outs), (ins i16mem:$dst, i8imm:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002315 "sar{w}\t{$src, $dst|$dst, $src}",
Evan Cheng85dd8892005-12-13 07:24:22 +00002316 [(store (sra (loadi16 addr:$dst), (i8 imm:$src)), addr:$dst)]>,
2317 OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00002318 def SAR32mi : Ii8<0xC1, MRM7m, (outs), (ins i32mem:$dst, i8imm:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002319 "sar{l}\t{$src, $dst|$dst, $src}",
Evan Cheng85dd8892005-12-13 07:24:22 +00002320 [(store (sra (loadi32 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
Evan Cheng09c54572006-06-29 00:36:51 +00002321
2322 // Shift by 1
Evan Cheng64d80e32007-07-19 01:14:50 +00002323 def SAR8m1 : I<0xD0, MRM7m, (outs), (ins i8mem :$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002324 "sar{b}\t$dst",
Evan Cheng09c54572006-06-29 00:36:51 +00002325 [(store (sra (loadi8 addr:$dst), (i8 1)), addr:$dst)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00002326 def SAR16m1 : I<0xD1, MRM7m, (outs), (ins i16mem:$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002327 "sar{w}\t$dst",
Evan Cheng09c54572006-06-29 00:36:51 +00002328 [(store (sra (loadi16 addr:$dst), (i8 1)), addr:$dst)]>,
2329 OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00002330 def SAR32m1 : I<0xD1, MRM7m, (outs), (ins i32mem:$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002331 "sar{l}\t$dst",
Evan Cheng09c54572006-06-29 00:36:51 +00002332 [(store (sra (loadi32 addr:$dst), (i8 1)), addr:$dst)]>;
Chris Lattnerf29ed092004-08-11 05:07:25 +00002333}
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00002334
Chris Lattner40ff6332005-01-19 07:50:03 +00002335// Rotate instructions
Sean Callanana2dc2822009-09-18 19:35:23 +00002336
2337def RCL8r1 : I<0xD0, MRM2r, (outs GR8:$dst), (ins GR8:$src),
2338 "rcl{b}\t{1, $dst|$dst, 1}", []>;
Sean Callanana2dc2822009-09-18 19:35:23 +00002339let Uses = [CL] in {
2340def RCL8rCL : I<0xD2, MRM2r, (outs GR8:$dst), (ins GR8:$src),
2341 "rcl{b}\t{%cl, $dst|$dst, CL}", []>;
Sean Callanana2dc2822009-09-18 19:35:23 +00002342}
2343def RCL8ri : Ii8<0xC0, MRM2r, (outs GR8:$dst), (ins GR8:$src, i8imm:$cnt),
2344 "rcl{b}\t{$cnt, $dst|$dst, $cnt}", []>;
Sean Callanana2dc2822009-09-18 19:35:23 +00002345
2346def RCL16r1 : I<0xD1, MRM2r, (outs GR16:$dst), (ins GR16:$src),
2347 "rcl{w}\t{1, $dst|$dst, 1}", []>, OpSize;
Sean Callanana2dc2822009-09-18 19:35:23 +00002348let Uses = [CL] in {
2349def RCL16rCL : I<0xD3, MRM2r, (outs GR16:$dst), (ins GR16:$src),
2350 "rcl{w}\t{%cl, $dst|$dst, CL}", []>, OpSize;
Sean Callanana2dc2822009-09-18 19:35:23 +00002351}
2352def RCL16ri : Ii8<0xC1, MRM2r, (outs GR16:$dst), (ins GR16:$src, i8imm:$cnt),
2353 "rcl{w}\t{$cnt, $dst|$dst, $cnt}", []>, OpSize;
Sean Callanana2dc2822009-09-18 19:35:23 +00002354
2355def RCL32r1 : I<0xD1, MRM2r, (outs GR32:$dst), (ins GR32:$src),
2356 "rcl{l}\t{1, $dst|$dst, 1}", []>;
Sean Callanana2dc2822009-09-18 19:35:23 +00002357let Uses = [CL] in {
2358def RCL32rCL : I<0xD3, MRM2r, (outs GR32:$dst), (ins GR32:$src),
2359 "rcl{l}\t{%cl, $dst|$dst, CL}", []>;
Sean Callanana2dc2822009-09-18 19:35:23 +00002360}
2361def RCL32ri : Ii8<0xC1, MRM2r, (outs GR32:$dst), (ins GR32:$src, i8imm:$cnt),
2362 "rcl{l}\t{$cnt, $dst|$dst, $cnt}", []>;
Sean Callanana2dc2822009-09-18 19:35:23 +00002363
2364def RCR8r1 : I<0xD0, MRM3r, (outs GR8:$dst), (ins GR8:$src),
2365 "rcr{b}\t{1, $dst|$dst, 1}", []>;
Sean Callanana2dc2822009-09-18 19:35:23 +00002366let Uses = [CL] in {
2367def RCR8rCL : I<0xD2, MRM3r, (outs GR8:$dst), (ins GR8:$src),
2368 "rcr{b}\t{%cl, $dst|$dst, CL}", []>;
Sean Callanana2dc2822009-09-18 19:35:23 +00002369}
2370def RCR8ri : Ii8<0xC0, MRM3r, (outs GR8:$dst), (ins GR8:$src, i8imm:$cnt),
2371 "rcr{b}\t{$cnt, $dst|$dst, $cnt}", []>;
Sean Callanana2dc2822009-09-18 19:35:23 +00002372
2373def RCR16r1 : I<0xD1, MRM3r, (outs GR16:$dst), (ins GR16:$src),
2374 "rcr{w}\t{1, $dst|$dst, 1}", []>, OpSize;
Sean Callanana2dc2822009-09-18 19:35:23 +00002375let Uses = [CL] in {
2376def RCR16rCL : I<0xD3, MRM3r, (outs GR16:$dst), (ins GR16:$src),
2377 "rcr{w}\t{%cl, $dst|$dst, CL}", []>, OpSize;
Sean Callanana2dc2822009-09-18 19:35:23 +00002378}
2379def RCR16ri : Ii8<0xC1, MRM3r, (outs GR16:$dst), (ins GR16:$src, i8imm:$cnt),
2380 "rcr{w}\t{$cnt, $dst|$dst, $cnt}", []>, OpSize;
Sean Callanana2dc2822009-09-18 19:35:23 +00002381
2382def RCR32r1 : I<0xD1, MRM3r, (outs GR32:$dst), (ins GR32:$src),
2383 "rcr{l}\t{1, $dst|$dst, 1}", []>;
Sean Callanana2dc2822009-09-18 19:35:23 +00002384let Uses = [CL] in {
2385def RCR32rCL : I<0xD3, MRM3r, (outs GR32:$dst), (ins GR32:$src),
2386 "rcr{l}\t{%cl, $dst|$dst, CL}", []>;
Sean Callanana2dc2822009-09-18 19:35:23 +00002387}
2388def RCR32ri : Ii8<0xC1, MRM3r, (outs GR32:$dst), (ins GR32:$src, i8imm:$cnt),
2389 "rcr{l}\t{$cnt, $dst|$dst, $cnt}", []>;
Daniel Dunbarccfa1db2010-02-12 01:22:03 +00002390
2391let isTwoAddress = 0 in {
2392def RCL8m1 : I<0xD0, MRM2m, (outs), (ins i8mem:$dst),
2393 "rcl{b}\t{1, $dst|$dst, 1}", []>;
2394def RCL8mi : Ii8<0xC0, MRM2m, (outs), (ins i8mem:$dst, i8imm:$cnt),
2395 "rcl{b}\t{$cnt, $dst|$dst, $cnt}", []>;
2396def RCL16m1 : I<0xD1, MRM2m, (outs), (ins i16mem:$dst),
2397 "rcl{w}\t{1, $dst|$dst, 1}", []>, OpSize;
2398def RCL16mi : Ii8<0xC1, MRM2m, (outs), (ins i16mem:$dst, i8imm:$cnt),
2399 "rcl{w}\t{$cnt, $dst|$dst, $cnt}", []>, OpSize;
2400def RCL32m1 : I<0xD1, MRM2m, (outs), (ins i32mem:$dst),
2401 "rcl{l}\t{1, $dst|$dst, 1}", []>;
2402def RCL32mi : Ii8<0xC1, MRM2m, (outs), (ins i32mem:$dst, i8imm:$cnt),
2403 "rcl{l}\t{$cnt, $dst|$dst, $cnt}", []>;
2404def RCR8m1 : I<0xD0, MRM3m, (outs), (ins i8mem:$dst),
2405 "rcr{b}\t{1, $dst|$dst, 1}", []>;
2406def RCR8mi : Ii8<0xC0, MRM3m, (outs), (ins i8mem:$dst, i8imm:$cnt),
2407 "rcr{b}\t{$cnt, $dst|$dst, $cnt}", []>;
2408def RCR16m1 : I<0xD1, MRM3m, (outs), (ins i16mem:$dst),
2409 "rcr{w}\t{1, $dst|$dst, 1}", []>, OpSize;
2410def RCR16mi : Ii8<0xC1, MRM3m, (outs), (ins i16mem:$dst, i8imm:$cnt),
2411 "rcr{w}\t{$cnt, $dst|$dst, $cnt}", []>, OpSize;
2412def RCR32m1 : I<0xD1, MRM3m, (outs), (ins i32mem:$dst),
2413 "rcr{l}\t{1, $dst|$dst, 1}", []>;
2414def RCR32mi : Ii8<0xC1, MRM3m, (outs), (ins i32mem:$dst, i8imm:$cnt),
Sean Callanana2dc2822009-09-18 19:35:23 +00002415 "rcr{l}\t{$cnt, $dst|$dst, $cnt}", []>;
2416
Daniel Dunbarccfa1db2010-02-12 01:22:03 +00002417let Uses = [CL] in {
2418def RCL8mCL : I<0xD2, MRM2m, (outs), (ins i8mem:$dst),
2419 "rcl{b}\t{%cl, $dst|$dst, CL}", []>;
2420def RCL16mCL : I<0xD3, MRM2m, (outs), (ins i16mem:$dst),
2421 "rcl{w}\t{%cl, $dst|$dst, CL}", []>, OpSize;
2422def RCL32mCL : I<0xD3, MRM2m, (outs), (ins i32mem:$dst),
2423 "rcl{l}\t{%cl, $dst|$dst, CL}", []>;
2424def RCR8mCL : I<0xD2, MRM3m, (outs), (ins i8mem:$dst),
2425 "rcr{b}\t{%cl, $dst|$dst, CL}", []>;
2426def RCR16mCL : I<0xD3, MRM3m, (outs), (ins i16mem:$dst),
2427 "rcr{w}\t{%cl, $dst|$dst, CL}", []>, OpSize;
2428def RCR32mCL : I<0xD3, MRM3m, (outs), (ins i32mem:$dst),
2429 "rcr{l}\t{%cl, $dst|$dst, CL}", []>;
2430}
2431}
2432
Chris Lattner40ff6332005-01-19 07:50:03 +00002433// FIXME: provide shorter instructions when imm8 == 1
Evan Cheng071a2792007-09-11 19:55:27 +00002434let Uses = [CL] in {
Evan Cheng64d80e32007-07-19 01:14:50 +00002435def ROL8rCL : I<0xD2, MRM0r, (outs GR8 :$dst), (ins GR8 :$src),
Eli Friedmanaace4b12009-06-19 04:48:38 +00002436 "rol{b}\t{%cl, $dst|$dst, CL}",
Evan Cheng071a2792007-09-11 19:55:27 +00002437 [(set GR8:$dst, (rotl GR8:$src, CL))]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00002438def ROL16rCL : I<0xD3, MRM0r, (outs GR16:$dst), (ins GR16:$src),
Eli Friedmanaace4b12009-06-19 04:48:38 +00002439 "rol{w}\t{%cl, $dst|$dst, CL}",
Evan Cheng071a2792007-09-11 19:55:27 +00002440 [(set GR16:$dst, (rotl GR16:$src, CL))]>, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00002441def ROL32rCL : I<0xD3, MRM0r, (outs GR32:$dst), (ins GR32:$src),
Eli Friedmanaace4b12009-06-19 04:48:38 +00002442 "rol{l}\t{%cl, $dst|$dst, CL}",
Evan Cheng071a2792007-09-11 19:55:27 +00002443 [(set GR32:$dst, (rotl GR32:$src, CL))]>;
2444}
Chris Lattner40ff6332005-01-19 07:50:03 +00002445
Evan Cheng64d80e32007-07-19 01:14:50 +00002446def ROL8ri : Ii8<0xC0, MRM0r, (outs GR8 :$dst), (ins GR8 :$src1, i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002447 "rol{b}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00002448 [(set GR8:$dst, (rotl GR8:$src1, (i8 imm:$src2)))]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00002449def ROL16ri : Ii8<0xC1, MRM0r, (outs GR16:$dst), (ins GR16:$src1, i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002450 "rol{w}\t{$src2, $dst|$dst, $src2}",
Sean Callanan108934c2009-12-18 00:01:26 +00002451 [(set GR16:$dst, (rotl GR16:$src1, (i8 imm:$src2)))]>,
2452 OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00002453def ROL32ri : Ii8<0xC1, MRM0r, (outs GR32:$dst), (ins GR32:$src1, i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002454 "rol{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00002455 [(set GR32:$dst, (rotl GR32:$src1, (i8 imm:$src2)))]>;
Chris Lattner40ff6332005-01-19 07:50:03 +00002456
Evan Cheng09c54572006-06-29 00:36:51 +00002457// Rotate by 1
Evan Cheng64d80e32007-07-19 01:14:50 +00002458def ROL8r1 : I<0xD0, MRM0r, (outs GR8 :$dst), (ins GR8 :$src1),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002459 "rol{b}\t$dst",
Evan Cheng09c54572006-06-29 00:36:51 +00002460 [(set GR8:$dst, (rotl GR8:$src1, (i8 1)))]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00002461def ROL16r1 : I<0xD1, MRM0r, (outs GR16:$dst), (ins GR16:$src1),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002462 "rol{w}\t$dst",
Evan Cheng09c54572006-06-29 00:36:51 +00002463 [(set GR16:$dst, (rotl GR16:$src1, (i8 1)))]>, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00002464def ROL32r1 : I<0xD1, MRM0r, (outs GR32:$dst), (ins GR32:$src1),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002465 "rol{l}\t$dst",
Evan Cheng09c54572006-06-29 00:36:51 +00002466 [(set GR32:$dst, (rotl GR32:$src1, (i8 1)))]>;
2467
Chris Lattner40ff6332005-01-19 07:50:03 +00002468let isTwoAddress = 0 in {
Evan Cheng071a2792007-09-11 19:55:27 +00002469 let Uses = [CL] in {
Evan Cheng64d80e32007-07-19 01:14:50 +00002470 def ROL8mCL : I<0xD2, MRM0m, (outs), (ins i8mem :$dst),
Eli Friedmanaace4b12009-06-19 04:48:38 +00002471 "rol{b}\t{%cl, $dst|$dst, CL}",
Evan Cheng071a2792007-09-11 19:55:27 +00002472 [(store (rotl (loadi8 addr:$dst), CL), addr:$dst)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00002473 def ROL16mCL : I<0xD3, MRM0m, (outs), (ins i16mem:$dst),
Eli Friedmanaace4b12009-06-19 04:48:38 +00002474 "rol{w}\t{%cl, $dst|$dst, CL}",
Evan Cheng071a2792007-09-11 19:55:27 +00002475 [(store (rotl (loadi16 addr:$dst), CL), addr:$dst)]>, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00002476 def ROL32mCL : I<0xD3, MRM0m, (outs), (ins i32mem:$dst),
Eli Friedmanaace4b12009-06-19 04:48:38 +00002477 "rol{l}\t{%cl, $dst|$dst, CL}",
Evan Cheng071a2792007-09-11 19:55:27 +00002478 [(store (rotl (loadi32 addr:$dst), CL), addr:$dst)]>;
2479 }
Evan Cheng64d80e32007-07-19 01:14:50 +00002480 def ROL8mi : Ii8<0xC0, MRM0m, (outs), (ins i8mem :$dst, i8imm:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002481 "rol{b}\t{$src, $dst|$dst, $src}",
Evan Chengeb422a72006-01-11 23:20:05 +00002482 [(store (rotl (loadi8 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00002483 def ROL16mi : Ii8<0xC1, MRM0m, (outs), (ins i16mem:$dst, i8imm:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002484 "rol{w}\t{$src, $dst|$dst, $src}",
Evan Chengeb422a72006-01-11 23:20:05 +00002485 [(store (rotl (loadi16 addr:$dst), (i8 imm:$src)), addr:$dst)]>,
2486 OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00002487 def ROL32mi : Ii8<0xC1, MRM0m, (outs), (ins i32mem:$dst, i8imm:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002488 "rol{l}\t{$src, $dst|$dst, $src}",
Evan Chengeb422a72006-01-11 23:20:05 +00002489 [(store (rotl (loadi32 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
Evan Cheng09c54572006-06-29 00:36:51 +00002490
2491 // Rotate by 1
Evan Cheng64d80e32007-07-19 01:14:50 +00002492 def ROL8m1 : I<0xD0, MRM0m, (outs), (ins i8mem :$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002493 "rol{b}\t$dst",
Evan Cheng09c54572006-06-29 00:36:51 +00002494 [(store (rotl (loadi8 addr:$dst), (i8 1)), addr:$dst)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00002495 def ROL16m1 : I<0xD1, MRM0m, (outs), (ins i16mem:$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002496 "rol{w}\t$dst",
Evan Cheng09c54572006-06-29 00:36:51 +00002497 [(store (rotl (loadi16 addr:$dst), (i8 1)), addr:$dst)]>,
2498 OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00002499 def ROL32m1 : I<0xD1, MRM0m, (outs), (ins i32mem:$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002500 "rol{l}\t$dst",
Evan Cheng09c54572006-06-29 00:36:51 +00002501 [(store (rotl (loadi32 addr:$dst), (i8 1)), addr:$dst)]>;
Chris Lattner40ff6332005-01-19 07:50:03 +00002502}
2503
Evan Cheng071a2792007-09-11 19:55:27 +00002504let Uses = [CL] in {
Evan Cheng64d80e32007-07-19 01:14:50 +00002505def ROR8rCL : I<0xD2, MRM1r, (outs GR8 :$dst), (ins GR8 :$src),
Eli Friedmanaace4b12009-06-19 04:48:38 +00002506 "ror{b}\t{%cl, $dst|$dst, CL}",
Evan Cheng071a2792007-09-11 19:55:27 +00002507 [(set GR8:$dst, (rotr GR8:$src, CL))]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00002508def ROR16rCL : I<0xD3, MRM1r, (outs GR16:$dst), (ins GR16:$src),
Eli Friedmanaace4b12009-06-19 04:48:38 +00002509 "ror{w}\t{%cl, $dst|$dst, CL}",
Evan Cheng071a2792007-09-11 19:55:27 +00002510 [(set GR16:$dst, (rotr GR16:$src, CL))]>, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00002511def ROR32rCL : I<0xD3, MRM1r, (outs GR32:$dst), (ins GR32:$src),
Eli Friedmanaace4b12009-06-19 04:48:38 +00002512 "ror{l}\t{%cl, $dst|$dst, CL}",
Evan Cheng071a2792007-09-11 19:55:27 +00002513 [(set GR32:$dst, (rotr GR32:$src, CL))]>;
2514}
Chris Lattner40ff6332005-01-19 07:50:03 +00002515
Evan Cheng64d80e32007-07-19 01:14:50 +00002516def ROR8ri : Ii8<0xC0, MRM1r, (outs GR8 :$dst), (ins GR8 :$src1, i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002517 "ror{b}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00002518 [(set GR8:$dst, (rotr GR8:$src1, (i8 imm:$src2)))]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00002519def ROR16ri : Ii8<0xC1, MRM1r, (outs GR16:$dst), (ins GR16:$src1, i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002520 "ror{w}\t{$src2, $dst|$dst, $src2}",
Sean Callanan108934c2009-12-18 00:01:26 +00002521 [(set GR16:$dst, (rotr GR16:$src1, (i8 imm:$src2)))]>,
2522 OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00002523def ROR32ri : Ii8<0xC1, MRM1r, (outs GR32:$dst), (ins GR32:$src1, i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002524 "ror{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00002525 [(set GR32:$dst, (rotr GR32:$src1, (i8 imm:$src2)))]>;
Evan Cheng09c54572006-06-29 00:36:51 +00002526
2527// Rotate by 1
Evan Cheng64d80e32007-07-19 01:14:50 +00002528def ROR8r1 : I<0xD0, MRM1r, (outs GR8 :$dst), (ins GR8 :$src1),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002529 "ror{b}\t$dst",
Evan Cheng09c54572006-06-29 00:36:51 +00002530 [(set GR8:$dst, (rotr GR8:$src1, (i8 1)))]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00002531def ROR16r1 : I<0xD1, MRM1r, (outs GR16:$dst), (ins GR16:$src1),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002532 "ror{w}\t$dst",
Evan Cheng09c54572006-06-29 00:36:51 +00002533 [(set GR16:$dst, (rotr GR16:$src1, (i8 1)))]>, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00002534def ROR32r1 : I<0xD1, MRM1r, (outs GR32:$dst), (ins GR32:$src1),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002535 "ror{l}\t$dst",
Evan Cheng09c54572006-06-29 00:36:51 +00002536 [(set GR32:$dst, (rotr GR32:$src1, (i8 1)))]>;
2537
Chris Lattner40ff6332005-01-19 07:50:03 +00002538let isTwoAddress = 0 in {
Evan Cheng071a2792007-09-11 19:55:27 +00002539 let Uses = [CL] in {
Evan Cheng64d80e32007-07-19 01:14:50 +00002540 def ROR8mCL : I<0xD2, MRM1m, (outs), (ins i8mem :$dst),
Eli Friedmanaace4b12009-06-19 04:48:38 +00002541 "ror{b}\t{%cl, $dst|$dst, CL}",
Evan Cheng071a2792007-09-11 19:55:27 +00002542 [(store (rotr (loadi8 addr:$dst), CL), addr:$dst)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00002543 def ROR16mCL : I<0xD3, MRM1m, (outs), (ins i16mem:$dst),
Eli Friedmanaace4b12009-06-19 04:48:38 +00002544 "ror{w}\t{%cl, $dst|$dst, CL}",
Evan Cheng071a2792007-09-11 19:55:27 +00002545 [(store (rotr (loadi16 addr:$dst), CL), addr:$dst)]>, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00002546 def ROR32mCL : I<0xD3, MRM1m, (outs), (ins i32mem:$dst),
Eli Friedmanaace4b12009-06-19 04:48:38 +00002547 "ror{l}\t{%cl, $dst|$dst, CL}",
Evan Cheng071a2792007-09-11 19:55:27 +00002548 [(store (rotr (loadi32 addr:$dst), CL), addr:$dst)]>;
2549 }
Evan Cheng64d80e32007-07-19 01:14:50 +00002550 def ROR8mi : Ii8<0xC0, MRM1m, (outs), (ins i8mem :$dst, i8imm:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002551 "ror{b}\t{$src, $dst|$dst, $src}",
Evan Chengeb422a72006-01-11 23:20:05 +00002552 [(store (rotr (loadi8 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00002553 def ROR16mi : Ii8<0xC1, MRM1m, (outs), (ins i16mem:$dst, i8imm:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002554 "ror{w}\t{$src, $dst|$dst, $src}",
Evan Chengeb422a72006-01-11 23:20:05 +00002555 [(store (rotr (loadi16 addr:$dst), (i8 imm:$src)), addr:$dst)]>,
2556 OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00002557 def ROR32mi : Ii8<0xC1, MRM1m, (outs), (ins i32mem:$dst, i8imm:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002558 "ror{l}\t{$src, $dst|$dst, $src}",
Evan Chengeb422a72006-01-11 23:20:05 +00002559 [(store (rotr (loadi32 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
Evan Cheng09c54572006-06-29 00:36:51 +00002560
2561 // Rotate by 1
Evan Cheng64d80e32007-07-19 01:14:50 +00002562 def ROR8m1 : I<0xD0, MRM1m, (outs), (ins i8mem :$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002563 "ror{b}\t$dst",
Evan Cheng09c54572006-06-29 00:36:51 +00002564 [(store (rotr (loadi8 addr:$dst), (i8 1)), addr:$dst)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00002565 def ROR16m1 : I<0xD1, MRM1m, (outs), (ins i16mem:$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002566 "ror{w}\t$dst",
Evan Cheng09c54572006-06-29 00:36:51 +00002567 [(store (rotr (loadi16 addr:$dst), (i8 1)), addr:$dst)]>,
2568 OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00002569 def ROR32m1 : I<0xD1, MRM1m, (outs), (ins i32mem:$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002570 "ror{l}\t$dst",
Evan Cheng09c54572006-06-29 00:36:51 +00002571 [(store (rotr (loadi32 addr:$dst), (i8 1)), addr:$dst)]>;
Chris Lattner40ff6332005-01-19 07:50:03 +00002572}
2573
2574
2575
2576// Double shift instructions (generalizations of rotate)
Evan Cheng071a2792007-09-11 19:55:27 +00002577let Uses = [CL] in {
Sean Callanan108934c2009-12-18 00:01:26 +00002578def SHLD32rrCL : I<0xA5, MRMDestReg, (outs GR32:$dst),
2579 (ins GR32:$src1, GR32:$src2),
Eli Friedmanaace4b12009-06-19 04:48:38 +00002580 "shld{l}\t{%cl, $src2, $dst|$dst, $src2, CL}",
Evan Cheng071a2792007-09-11 19:55:27 +00002581 [(set GR32:$dst, (X86shld GR32:$src1, GR32:$src2, CL))]>, TB;
Sean Callanan108934c2009-12-18 00:01:26 +00002582def SHRD32rrCL : I<0xAD, MRMDestReg, (outs GR32:$dst),
2583 (ins GR32:$src1, GR32:$src2),
Eli Friedmanaace4b12009-06-19 04:48:38 +00002584 "shrd{l}\t{%cl, $src2, $dst|$dst, $src2, CL}",
Evan Cheng071a2792007-09-11 19:55:27 +00002585 [(set GR32:$dst, (X86shrd GR32:$src1, GR32:$src2, CL))]>, TB;
Sean Callanan108934c2009-12-18 00:01:26 +00002586def SHLD16rrCL : I<0xA5, MRMDestReg, (outs GR16:$dst),
2587 (ins GR16:$src1, GR16:$src2),
Eli Friedmanaace4b12009-06-19 04:48:38 +00002588 "shld{w}\t{%cl, $src2, $dst|$dst, $src2, CL}",
Evan Cheng069287d2006-05-16 07:21:53 +00002589 [(set GR16:$dst, (X86shld GR16:$src1, GR16:$src2, CL))]>,
Evan Cheng071a2792007-09-11 19:55:27 +00002590 TB, OpSize;
Sean Callanan108934c2009-12-18 00:01:26 +00002591def SHRD16rrCL : I<0xAD, MRMDestReg, (outs GR16:$dst),
2592 (ins GR16:$src1, GR16:$src2),
Eli Friedmanaace4b12009-06-19 04:48:38 +00002593 "shrd{w}\t{%cl, $src2, $dst|$dst, $src2, CL}",
Evan Cheng069287d2006-05-16 07:21:53 +00002594 [(set GR16:$dst, (X86shrd GR16:$src1, GR16:$src2, CL))]>,
Evan Cheng071a2792007-09-11 19:55:27 +00002595 TB, OpSize;
2596}
Chris Lattner41e431b2005-01-19 07:11:01 +00002597
2598let isCommutable = 1 in { // These instructions commute to each other.
Chris Lattner3a173df2004-10-03 20:35:00 +00002599def SHLD32rri8 : Ii8<0xA4, MRMDestReg,
Sean Callanan108934c2009-12-18 00:01:26 +00002600 (outs GR32:$dst),
2601 (ins GR32:$src1, GR32:$src2, i8imm:$src3),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002602 "shld{l}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Evan Cheng069287d2006-05-16 07:21:53 +00002603 [(set GR32:$dst, (X86shld GR32:$src1, GR32:$src2,
Evan Chenge3413162006-01-09 18:33:28 +00002604 (i8 imm:$src3)))]>,
2605 TB;
Chris Lattner3a173df2004-10-03 20:35:00 +00002606def SHRD32rri8 : Ii8<0xAC, MRMDestReg,
Sean Callanan108934c2009-12-18 00:01:26 +00002607 (outs GR32:$dst),
2608 (ins GR32:$src1, GR32:$src2, i8imm:$src3),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002609 "shrd{l}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Evan Cheng069287d2006-05-16 07:21:53 +00002610 [(set GR32:$dst, (X86shrd GR32:$src1, GR32:$src2,
Evan Chenge3413162006-01-09 18:33:28 +00002611 (i8 imm:$src3)))]>,
2612 TB;
Chris Lattner0df53d22005-01-19 07:31:24 +00002613def SHLD16rri8 : Ii8<0xA4, MRMDestReg,
Sean Callanan108934c2009-12-18 00:01:26 +00002614 (outs GR16:$dst),
2615 (ins GR16:$src1, GR16:$src2, i8imm:$src3),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002616 "shld{w}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Evan Cheng069287d2006-05-16 07:21:53 +00002617 [(set GR16:$dst, (X86shld GR16:$src1, GR16:$src2,
Evan Chenge3413162006-01-09 18:33:28 +00002618 (i8 imm:$src3)))]>,
Chris Lattner0df53d22005-01-19 07:31:24 +00002619 TB, OpSize;
2620def SHRD16rri8 : Ii8<0xAC, MRMDestReg,
Sean Callanan108934c2009-12-18 00:01:26 +00002621 (outs GR16:$dst),
2622 (ins GR16:$src1, GR16:$src2, i8imm:$src3),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002623 "shrd{w}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Evan Cheng069287d2006-05-16 07:21:53 +00002624 [(set GR16:$dst, (X86shrd GR16:$src1, GR16:$src2,
Evan Chenge3413162006-01-09 18:33:28 +00002625 (i8 imm:$src3)))]>,
Chris Lattner0df53d22005-01-19 07:31:24 +00002626 TB, OpSize;
Chris Lattner41e431b2005-01-19 07:11:01 +00002627}
Chris Lattner0e967d42004-08-01 08:13:11 +00002628
Chris Lattner57a02302004-08-11 04:31:00 +00002629let isTwoAddress = 0 in {
Evan Cheng071a2792007-09-11 19:55:27 +00002630 let Uses = [CL] in {
Evan Cheng64d80e32007-07-19 01:14:50 +00002631 def SHLD32mrCL : I<0xA5, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
Eli Friedmanaace4b12009-06-19 04:48:38 +00002632 "shld{l}\t{%cl, $src2, $dst|$dst, $src2, CL}",
Evan Cheng069287d2006-05-16 07:21:53 +00002633 [(store (X86shld (loadi32 addr:$dst), GR32:$src2, CL),
Evan Cheng071a2792007-09-11 19:55:27 +00002634 addr:$dst)]>, TB;
Evan Cheng64d80e32007-07-19 01:14:50 +00002635 def SHRD32mrCL : I<0xAD, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
Eli Friedmanaace4b12009-06-19 04:48:38 +00002636 "shrd{l}\t{%cl, $src2, $dst|$dst, $src2, CL}",
Evan Cheng069287d2006-05-16 07:21:53 +00002637 [(store (X86shrd (loadi32 addr:$dst), GR32:$src2, CL),
Evan Cheng071a2792007-09-11 19:55:27 +00002638 addr:$dst)]>, TB;
2639 }
Chris Lattner3a173df2004-10-03 20:35:00 +00002640 def SHLD32mri8 : Ii8<0xA4, MRMDestMem,
Evan Cheng64d80e32007-07-19 01:14:50 +00002641 (outs), (ins i32mem:$dst, GR32:$src2, i8imm:$src3),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002642 "shld{l}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Evan Cheng069287d2006-05-16 07:21:53 +00002643 [(store (X86shld (loadi32 addr:$dst), GR32:$src2,
Evan Chenge3413162006-01-09 18:33:28 +00002644 (i8 imm:$src3)), addr:$dst)]>,
Chris Lattnerf124d5e2005-11-18 01:04:42 +00002645 TB;
Chris Lattner3a173df2004-10-03 20:35:00 +00002646 def SHRD32mri8 : Ii8<0xAC, MRMDestMem,
Evan Cheng64d80e32007-07-19 01:14:50 +00002647 (outs), (ins i32mem:$dst, GR32:$src2, i8imm:$src3),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002648 "shrd{l}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Evan Cheng069287d2006-05-16 07:21:53 +00002649 [(store (X86shrd (loadi32 addr:$dst), GR32:$src2,
Evan Chenge3413162006-01-09 18:33:28 +00002650 (i8 imm:$src3)), addr:$dst)]>,
Chris Lattnerf124d5e2005-11-18 01:04:42 +00002651 TB;
Chris Lattner0df53d22005-01-19 07:31:24 +00002652
Evan Cheng071a2792007-09-11 19:55:27 +00002653 let Uses = [CL] in {
Evan Cheng64d80e32007-07-19 01:14:50 +00002654 def SHLD16mrCL : I<0xA5, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
Eli Friedmanaace4b12009-06-19 04:48:38 +00002655 "shld{w}\t{%cl, $src2, $dst|$dst, $src2, CL}",
Evan Cheng069287d2006-05-16 07:21:53 +00002656 [(store (X86shld (loadi16 addr:$dst), GR16:$src2, CL),
Evan Cheng071a2792007-09-11 19:55:27 +00002657 addr:$dst)]>, TB, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00002658 def SHRD16mrCL : I<0xAD, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
Eli Friedmanaace4b12009-06-19 04:48:38 +00002659 "shrd{w}\t{%cl, $src2, $dst|$dst, $src2, CL}",
Evan Cheng069287d2006-05-16 07:21:53 +00002660 [(store (X86shrd (loadi16 addr:$dst), GR16:$src2, CL),
Evan Cheng071a2792007-09-11 19:55:27 +00002661 addr:$dst)]>, TB, OpSize;
2662 }
Chris Lattner0df53d22005-01-19 07:31:24 +00002663 def SHLD16mri8 : Ii8<0xA4, MRMDestMem,
Evan Cheng64d80e32007-07-19 01:14:50 +00002664 (outs), (ins i16mem:$dst, GR16:$src2, i8imm:$src3),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002665 "shld{w}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Evan Cheng069287d2006-05-16 07:21:53 +00002666 [(store (X86shld (loadi16 addr:$dst), GR16:$src2,
Evan Chenge3413162006-01-09 18:33:28 +00002667 (i8 imm:$src3)), addr:$dst)]>,
Chris Lattner0df53d22005-01-19 07:31:24 +00002668 TB, OpSize;
2669 def SHRD16mri8 : Ii8<0xAC, MRMDestMem,
Evan Cheng64d80e32007-07-19 01:14:50 +00002670 (outs), (ins i16mem:$dst, GR16:$src2, i8imm:$src3),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002671 "shrd{w}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Evan Cheng069287d2006-05-16 07:21:53 +00002672 [(store (X86shrd (loadi16 addr:$dst), GR16:$src2,
Evan Chenge3413162006-01-09 18:33:28 +00002673 (i8 imm:$src3)), addr:$dst)]>,
Chris Lattner0df53d22005-01-19 07:31:24 +00002674 TB, OpSize;
Chris Lattner57a02302004-08-11 04:31:00 +00002675}
Evan Cheng24f2ea32007-09-14 21:48:26 +00002676} // Defs = [EFLAGS]
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00002677
2678
Chris Lattnercc65bee2005-01-02 02:35:46 +00002679// Arithmetic.
Evan Cheng24f2ea32007-09-14 21:48:26 +00002680let Defs = [EFLAGS] in {
Chris Lattnercc65bee2005-01-02 02:35:46 +00002681let isCommutable = 1 in { // X = ADD Y, Z --> X = ADD Z, Y
Bill Wendlingab55ebd2008-12-12 00:56:36 +00002682// Register-Register Addition
2683def ADD8rr : I<0x00, MRMDestReg, (outs GR8 :$dst),
2684 (ins GR8 :$src1, GR8 :$src2),
2685 "add{b}\t{$src2, $dst|$dst, $src2}",
Chris Lattnerec856802010-03-27 00:45:04 +00002686 [(set GR8:$dst, EFLAGS, (X86add_flag GR8:$src1, GR8:$src2))]>;
Bill Wendlingab55ebd2008-12-12 00:56:36 +00002687
Chris Lattnercc65bee2005-01-02 02:35:46 +00002688let isConvertibleToThreeAddress = 1 in { // Can transform into LEA.
Bill Wendlingab55ebd2008-12-12 00:56:36 +00002689// Register-Register Addition
Evan Cheng071a2792007-09-11 19:55:27 +00002690def ADD16rr : I<0x01, MRMDestReg, (outs GR16:$dst),
2691 (ins GR16:$src1, GR16:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002692 "add{w}\t{$src2, $dst|$dst, $src2}",
Chris Lattnerec856802010-03-27 00:45:04 +00002693 [(set GR16:$dst, EFLAGS, (X86add_flag GR16:$src1,
2694 GR16:$src2))]>, OpSize;
Evan Cheng071a2792007-09-11 19:55:27 +00002695def ADD32rr : I<0x01, MRMDestReg, (outs GR32:$dst),
2696 (ins GR32:$src1, GR32:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002697 "add{l}\t{$src2, $dst|$dst, $src2}",
Chris Lattnerec856802010-03-27 00:45:04 +00002698 [(set GR32:$dst, EFLAGS, (X86add_flag GR32:$src1,
2699 GR32:$src2))]>;
Chris Lattnercc65bee2005-01-02 02:35:46 +00002700} // end isConvertibleToThreeAddress
2701} // end isCommutable
Bill Wendlingab55ebd2008-12-12 00:56:36 +00002702
Daniel Dunbarf291be32010-03-09 22:50:46 +00002703// These are alternate spellings for use by the disassembler, we mark them as
2704// code gen only to ensure they aren't matched by the assembler.
2705let isCodeGenOnly = 1 in {
2706 def ADD8rr_alt: I<0x02, MRMSrcReg, (outs GR8:$dst), (ins GR8:$src1, GR8:$src2),
2707 "add{b}\t{$src2, $dst|$dst, $src2}", []>;
2708 def ADD16rr_alt: I<0x03, MRMSrcReg,(outs GR16:$dst),(ins GR16:$src1, GR16:$src2),
2709 "add{w}\t{$src2, $dst|$dst, $src2}", []>, OpSize;
Evan Cheng18ac4102010-04-05 22:21:09 +00002710 def ADD32rr_alt: I<0x03, MRMSrcReg,(outs GR32:$dst),(ins GR32:$src1, GR32:$src2),
Daniel Dunbarf291be32010-03-09 22:50:46 +00002711 "add{l}\t{$src2, $dst|$dst, $src2}", []>;
2712}
2713
Bill Wendlingab55ebd2008-12-12 00:56:36 +00002714// Register-Memory Addition
Evan Cheng071a2792007-09-11 19:55:27 +00002715def ADD8rm : I<0x02, MRMSrcMem, (outs GR8 :$dst),
2716 (ins GR8 :$src1, i8mem :$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002717 "add{b}\t{$src2, $dst|$dst, $src2}",
Chris Lattnerec856802010-03-27 00:45:04 +00002718 [(set GR8:$dst, EFLAGS, (X86add_flag GR8:$src1,
2719 (load addr:$src2)))]>;
Evan Cheng071a2792007-09-11 19:55:27 +00002720def ADD16rm : I<0x03, MRMSrcMem, (outs GR16:$dst),
2721 (ins GR16:$src1, i16mem:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002722 "add{w}\t{$src2, $dst|$dst, $src2}",
Chris Lattnerec856802010-03-27 00:45:04 +00002723 [(set GR16:$dst, EFLAGS, (X86add_flag GR16:$src1,
2724 (load addr:$src2)))]>, OpSize;
Evan Cheng071a2792007-09-11 19:55:27 +00002725def ADD32rm : I<0x03, MRMSrcMem, (outs GR32:$dst),
2726 (ins GR32:$src1, i32mem:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002727 "add{l}\t{$src2, $dst|$dst, $src2}",
Chris Lattnerec856802010-03-27 00:45:04 +00002728 [(set GR32:$dst, EFLAGS, (X86add_flag GR32:$src1,
2729 (load addr:$src2)))]>;
Sean Callanan37be5902009-09-15 20:53:57 +00002730
Bill Wendlingab55ebd2008-12-12 00:56:36 +00002731// Register-Integer Addition
2732def ADD8ri : Ii8<0x80, MRM0r, (outs GR8:$dst), (ins GR8:$src1, i8imm:$src2),
2733 "add{b}\t{$src2, $dst|$dst, $src2}",
Chris Lattnerec856802010-03-27 00:45:04 +00002734 [(set GR8:$dst, EFLAGS,
2735 (X86add_flag GR8:$src1, imm:$src2))]>;
Bill Wendlingab55ebd2008-12-12 00:56:36 +00002736
Chris Lattnercc65bee2005-01-02 02:35:46 +00002737let isConvertibleToThreeAddress = 1 in { // Can transform into LEA.
Bill Wendlingab55ebd2008-12-12 00:56:36 +00002738// Register-Integer Addition
Evan Cheng071a2792007-09-11 19:55:27 +00002739def ADD16ri : Ii16<0x81, MRM0r, (outs GR16:$dst),
2740 (ins GR16:$src1, i16imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002741 "add{w}\t{$src2, $dst|$dst, $src2}",
Chris Lattnerec856802010-03-27 00:45:04 +00002742 [(set GR16:$dst, EFLAGS,
2743 (X86add_flag GR16:$src1, imm:$src2))]>, OpSize;
Evan Cheng071a2792007-09-11 19:55:27 +00002744def ADD32ri : Ii32<0x81, MRM0r, (outs GR32:$dst),
2745 (ins GR32:$src1, i32imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002746 "add{l}\t{$src2, $dst|$dst, $src2}",
Chris Lattnerec856802010-03-27 00:45:04 +00002747 [(set GR32:$dst, EFLAGS,
2748 (X86add_flag GR32:$src1, imm:$src2))]>;
Evan Cheng071a2792007-09-11 19:55:27 +00002749def ADD16ri8 : Ii8<0x83, MRM0r, (outs GR16:$dst),
2750 (ins GR16:$src1, i16i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002751 "add{w}\t{$src2, $dst|$dst, $src2}",
Chris Lattnerec856802010-03-27 00:45:04 +00002752 [(set GR16:$dst, EFLAGS,
2753 (X86add_flag GR16:$src1, i16immSExt8:$src2))]>, OpSize;
Evan Cheng071a2792007-09-11 19:55:27 +00002754def ADD32ri8 : Ii8<0x83, MRM0r, (outs GR32:$dst),
2755 (ins GR32:$src1, i32i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002756 "add{l}\t{$src2, $dst|$dst, $src2}",
Chris Lattnerec856802010-03-27 00:45:04 +00002757 [(set GR32:$dst, EFLAGS,
2758 (X86add_flag GR32:$src1, i32immSExt8:$src2))]>;
Evan Cheng09e3c802006-05-19 18:40:54 +00002759}
Chris Lattner57a02302004-08-11 04:31:00 +00002760
2761let isTwoAddress = 0 in {
Bill Wendlingab55ebd2008-12-12 00:56:36 +00002762 // Memory-Register Addition
Bill Wendlingd350e022008-12-12 21:15:41 +00002763 def ADD8mr : I<0x00, MRMDestMem, (outs), (ins i8mem:$dst, GR8:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002764 "add{b}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingd350e022008-12-12 21:15:41 +00002765 [(store (add (load addr:$dst), GR8:$src2), addr:$dst),
2766 (implicit EFLAGS)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00002767 def ADD16mr : I<0x01, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002768 "add{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingd350e022008-12-12 21:15:41 +00002769 [(store (add (load addr:$dst), GR16:$src2), addr:$dst),
2770 (implicit EFLAGS)]>, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00002771 def ADD32mr : I<0x01, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002772 "add{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingd350e022008-12-12 21:15:41 +00002773 [(store (add (load addr:$dst), GR32:$src2), addr:$dst),
2774 (implicit EFLAGS)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00002775 def ADD8mi : Ii8<0x80, MRM0m, (outs), (ins i8mem :$dst, i8imm :$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002776 "add{b}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingd350e022008-12-12 21:15:41 +00002777 [(store (add (loadi8 addr:$dst), imm:$src2), addr:$dst),
2778 (implicit EFLAGS)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00002779 def ADD16mi : Ii16<0x81, MRM0m, (outs), (ins i16mem:$dst, i16imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002780 "add{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingd350e022008-12-12 21:15:41 +00002781 [(store (add (loadi16 addr:$dst), imm:$src2), addr:$dst),
2782 (implicit EFLAGS)]>, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00002783 def ADD32mi : Ii32<0x81, MRM0m, (outs), (ins i32mem:$dst, i32imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002784 "add{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingd350e022008-12-12 21:15:41 +00002785 [(store (add (loadi32 addr:$dst), imm:$src2), addr:$dst),
2786 (implicit EFLAGS)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00002787 def ADD16mi8 : Ii8<0x83, MRM0m, (outs), (ins i16mem:$dst, i16i8imm :$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002788 "add{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingd350e022008-12-12 21:15:41 +00002789 [(store (add (load addr:$dst), i16immSExt8:$src2),
2790 addr:$dst),
2791 (implicit EFLAGS)]>, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00002792 def ADD32mi8 : Ii8<0x83, MRM0m, (outs), (ins i32mem:$dst, i32i8imm :$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002793 "add{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingab55ebd2008-12-12 00:56:36 +00002794 [(store (add (load addr:$dst), i32immSExt8:$src2),
Bill Wendlingd350e022008-12-12 21:15:41 +00002795 addr:$dst),
2796 (implicit EFLAGS)]>;
Sean Callananb08ae6b2009-08-11 21:26:06 +00002797
2798 // addition to rAX
2799 def ADD8i8 : Ii8<0x04, RawFrm, (outs), (ins i8imm:$src),
Sean Callanana09caa52009-09-02 00:55:49 +00002800 "add{b}\t{$src, %al|%al, $src}", []>;
Sean Callananb08ae6b2009-08-11 21:26:06 +00002801 def ADD16i16 : Ii16<0x05, RawFrm, (outs), (ins i16imm:$src),
Sean Callanana09caa52009-09-02 00:55:49 +00002802 "add{w}\t{$src, %ax|%ax, $src}", []>, OpSize;
Sean Callananb08ae6b2009-08-11 21:26:06 +00002803 def ADD32i32 : Ii32<0x05, RawFrm, (outs), (ins i32imm:$src),
Sean Callanana09caa52009-09-02 00:55:49 +00002804 "add{l}\t{$src, %eax|%eax, $src}", []>;
Chris Lattner57a02302004-08-11 04:31:00 +00002805}
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00002806
Evan Cheng3154cb62007-10-05 17:59:57 +00002807let Uses = [EFLAGS] in {
Chris Lattner10197ff2005-01-03 01:27:59 +00002808let isCommutable = 1 in { // X = ADC Y, Z --> X = ADC Z, Y
Dale Johannesen874ae252009-06-02 03:12:52 +00002809def ADC8rr : I<0x10, MRMDestReg, (outs GR8:$dst), (ins GR8:$src1, GR8:$src2),
Dale Johannesenca11dae2009-05-18 17:44:15 +00002810 "adc{b}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen874ae252009-06-02 03:12:52 +00002811 [(set GR8:$dst, (adde GR8:$src1, GR8:$src2))]>;
Dale Johannesenca11dae2009-05-18 17:44:15 +00002812def ADC16rr : I<0x11, MRMDestReg, (outs GR16:$dst),
2813 (ins GR16:$src1, GR16:$src2),
2814 "adc{w}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen874ae252009-06-02 03:12:52 +00002815 [(set GR16:$dst, (adde GR16:$src1, GR16:$src2))]>, OpSize;
Dale Johannesenca11dae2009-05-18 17:44:15 +00002816def ADC32rr : I<0x11, MRMDestReg, (outs GR32:$dst),
2817 (ins GR32:$src1, GR32:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002818 "adc{l}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen874ae252009-06-02 03:12:52 +00002819 [(set GR32:$dst, (adde GR32:$src1, GR32:$src2))]>;
Chris Lattner10197ff2005-01-03 01:27:59 +00002820}
Sean Callanan108934c2009-12-18 00:01:26 +00002821
2822def ADC8rr_REV : I<0x12, MRMSrcReg, (outs GR8:$dst), (ins GR8:$src1, GR8:$src2),
2823 "adc{b}\t{$src2, $dst|$dst, $src2}", []>;
2824def ADC16rr_REV : I<0x13, MRMSrcReg, (outs GR16:$dst),
2825 (ins GR16:$src1, GR16:$src2),
2826 "adc{w}\t{$src2, $dst|$dst, $src2}", []>, OpSize;
2827def ADC32rr_REV : I<0x13, MRMSrcReg, (outs GR32:$dst),
2828 (ins GR32:$src1, GR32:$src2),
2829 "adc{l}\t{$src2, $dst|$dst, $src2}", []>;
2830
Dale Johannesenca11dae2009-05-18 17:44:15 +00002831def ADC8rm : I<0x12, MRMSrcMem , (outs GR8:$dst),
2832 (ins GR8:$src1, i8mem:$src2),
2833 "adc{b}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen874ae252009-06-02 03:12:52 +00002834 [(set GR8:$dst, (adde GR8:$src1, (load addr:$src2)))]>;
Dale Johannesenca11dae2009-05-18 17:44:15 +00002835def ADC16rm : I<0x13, MRMSrcMem , (outs GR16:$dst),
2836 (ins GR16:$src1, i16mem:$src2),
2837 "adc{w}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen874ae252009-06-02 03:12:52 +00002838 [(set GR16:$dst, (adde GR16:$src1, (load addr:$src2)))]>,
Dale Johannesen94c9cd12009-05-18 21:41:59 +00002839 OpSize;
Dale Johannesenca11dae2009-05-18 17:44:15 +00002840def ADC32rm : I<0x13, MRMSrcMem , (outs GR32:$dst),
2841 (ins GR32:$src1, i32mem:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002842 "adc{l}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen874ae252009-06-02 03:12:52 +00002843 [(set GR32:$dst, (adde GR32:$src1, (load addr:$src2)))]>;
2844def ADC8ri : Ii8<0x80, MRM2r, (outs GR8:$dst), (ins GR8:$src1, i8imm:$src2),
Dale Johannesenca11dae2009-05-18 17:44:15 +00002845 "adc{b}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen874ae252009-06-02 03:12:52 +00002846 [(set GR8:$dst, (adde GR8:$src1, imm:$src2))]>;
Dale Johannesenca11dae2009-05-18 17:44:15 +00002847def ADC16ri : Ii16<0x81, MRM2r, (outs GR16:$dst),
2848 (ins GR16:$src1, i16imm:$src2),
2849 "adc{w}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen874ae252009-06-02 03:12:52 +00002850 [(set GR16:$dst, (adde GR16:$src1, imm:$src2))]>, OpSize;
Dale Johannesenca11dae2009-05-18 17:44:15 +00002851def ADC16ri8 : Ii8<0x83, MRM2r, (outs GR16:$dst),
2852 (ins GR16:$src1, i16i8imm:$src2),
2853 "adc{w}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen874ae252009-06-02 03:12:52 +00002854 [(set GR16:$dst, (adde GR16:$src1, i16immSExt8:$src2))]>,
2855 OpSize;
Dale Johannesenca11dae2009-05-18 17:44:15 +00002856def ADC32ri : Ii32<0x81, MRM2r, (outs GR32:$dst),
2857 (ins GR32:$src1, i32imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002858 "adc{l}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen874ae252009-06-02 03:12:52 +00002859 [(set GR32:$dst, (adde GR32:$src1, imm:$src2))]>;
Dale Johannesenca11dae2009-05-18 17:44:15 +00002860def ADC32ri8 : Ii8<0x83, MRM2r, (outs GR32:$dst),
2861 (ins GR32:$src1, i32i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002862 "adc{l}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen874ae252009-06-02 03:12:52 +00002863 [(set GR32:$dst, (adde GR32:$src1, i32immSExt8:$src2))]>;
Chris Lattner57a02302004-08-11 04:31:00 +00002864
2865let isTwoAddress = 0 in {
Dale Johannesen874ae252009-06-02 03:12:52 +00002866 def ADC8mr : I<0x10, MRMDestMem, (outs), (ins i8mem:$dst, GR8:$src2),
Dale Johannesenca11dae2009-05-18 17:44:15 +00002867 "adc{b}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen874ae252009-06-02 03:12:52 +00002868 [(store (adde (load addr:$dst), GR8:$src2), addr:$dst)]>;
2869 def ADC16mr : I<0x11, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
Dale Johannesenca11dae2009-05-18 17:44:15 +00002870 "adc{w}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen874ae252009-06-02 03:12:52 +00002871 [(store (adde (load addr:$dst), GR16:$src2), addr:$dst)]>,
2872 OpSize;
2873 def ADC32mr : I<0x11, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002874 "adc{l}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen874ae252009-06-02 03:12:52 +00002875 [(store (adde (load addr:$dst), GR32:$src2), addr:$dst)]>;
2876 def ADC8mi : Ii8<0x80, MRM2m, (outs), (ins i8mem:$dst, i8imm:$src2),
Dale Johannesenca11dae2009-05-18 17:44:15 +00002877 "adc{b}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen874ae252009-06-02 03:12:52 +00002878 [(store (adde (loadi8 addr:$dst), imm:$src2), addr:$dst)]>;
2879 def ADC16mi : Ii16<0x81, MRM2m, (outs), (ins i16mem:$dst, i16imm:$src2),
Dale Johannesenca11dae2009-05-18 17:44:15 +00002880 "adc{w}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen874ae252009-06-02 03:12:52 +00002881 [(store (adde (loadi16 addr:$dst), imm:$src2), addr:$dst)]>,
2882 OpSize;
2883 def ADC16mi8 : Ii8<0x83, MRM2m, (outs), (ins i16mem:$dst, i16i8imm :$src2),
Dale Johannesenca11dae2009-05-18 17:44:15 +00002884 "adc{w}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen874ae252009-06-02 03:12:52 +00002885 [(store (adde (load addr:$dst), i16immSExt8:$src2), addr:$dst)]>,
2886 OpSize;
2887 def ADC32mi : Ii32<0x81, MRM2m, (outs), (ins i32mem:$dst, i32imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002888 "adc{l}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen874ae252009-06-02 03:12:52 +00002889 [(store (adde (loadi32 addr:$dst), imm:$src2), addr:$dst)]>;
2890 def ADC32mi8 : Ii8<0x83, MRM2m, (outs), (ins i32mem:$dst, i32i8imm :$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002891 "adc{l}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen874ae252009-06-02 03:12:52 +00002892 [(store (adde (load addr:$dst), i32immSExt8:$src2), addr:$dst)]>;
Sean Callanand00025a2009-09-11 19:01:56 +00002893
2894 def ADC8i8 : Ii8<0x14, RawFrm, (outs), (ins i8imm:$src),
2895 "adc{b}\t{$src, %al|%al, $src}", []>;
2896 def ADC16i16 : Ii16<0x15, RawFrm, (outs), (ins i16imm:$src),
2897 "adc{w}\t{$src, %ax|%ax, $src}", []>, OpSize;
2898 def ADC32i32 : Ii32<0x15, RawFrm, (outs), (ins i32imm:$src),
2899 "adc{l}\t{$src, %eax|%eax, $src}", []>;
Dale Johannesen874ae252009-06-02 03:12:52 +00002900}
Evan Cheng3154cb62007-10-05 17:59:57 +00002901} // Uses = [EFLAGS]
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00002902
Bill Wendlingab55ebd2008-12-12 00:56:36 +00002903// Register-Register Subtraction
2904def SUB8rr : I<0x28, MRMDestReg, (outs GR8:$dst), (ins GR8:$src1, GR8:$src2),
2905 "sub{b}\t{$src2, $dst|$dst, $src2}",
Chris Lattnerec856802010-03-27 00:45:04 +00002906 [(set GR8:$dst, EFLAGS,
2907 (X86sub_flag GR8:$src1, GR8:$src2))]>;
Bill Wendlingab55ebd2008-12-12 00:56:36 +00002908def SUB16rr : I<0x29, MRMDestReg, (outs GR16:$dst), (ins GR16:$src1,GR16:$src2),
2909 "sub{w}\t{$src2, $dst|$dst, $src2}",
Chris Lattnerec856802010-03-27 00:45:04 +00002910 [(set GR16:$dst, EFLAGS,
2911 (X86sub_flag GR16:$src1, GR16:$src2))]>, OpSize;
Bill Wendlingab55ebd2008-12-12 00:56:36 +00002912def SUB32rr : I<0x29, MRMDestReg, (outs GR32:$dst), (ins GR32:$src1,GR32:$src2),
2913 "sub{l}\t{$src2, $dst|$dst, $src2}",
Chris Lattnerec856802010-03-27 00:45:04 +00002914 [(set GR32:$dst, EFLAGS,
2915 (X86sub_flag GR32:$src1, GR32:$src2))]>;
Bill Wendlingab55ebd2008-12-12 00:56:36 +00002916
Sean Callanan108934c2009-12-18 00:01:26 +00002917def SUB8rr_REV : I<0x2A, MRMSrcReg, (outs GR8:$dst), (ins GR8:$src1, GR8:$src2),
2918 "sub{b}\t{$src2, $dst|$dst, $src2}", []>;
2919def SUB16rr_REV : I<0x2B, MRMSrcReg, (outs GR16:$dst),
2920 (ins GR16:$src1, GR16:$src2),
2921 "sub{w}\t{$src2, $dst|$dst, $src2}", []>, OpSize;
2922def SUB32rr_REV : I<0x2B, MRMSrcReg, (outs GR32:$dst),
2923 (ins GR32:$src1, GR32:$src2),
2924 "sub{l}\t{$src2, $dst|$dst, $src2}", []>;
2925
Bill Wendlingab55ebd2008-12-12 00:56:36 +00002926// Register-Memory Subtraction
2927def SUB8rm : I<0x2A, MRMSrcMem, (outs GR8 :$dst),
2928 (ins GR8 :$src1, i8mem :$src2),
2929 "sub{b}\t{$src2, $dst|$dst, $src2}",
Chris Lattnerec856802010-03-27 00:45:04 +00002930 [(set GR8:$dst, EFLAGS,
2931 (X86sub_flag GR8:$src1, (load addr:$src2)))]>;
Bill Wendlingab55ebd2008-12-12 00:56:36 +00002932def SUB16rm : I<0x2B, MRMSrcMem, (outs GR16:$dst),
2933 (ins GR16:$src1, i16mem:$src2),
2934 "sub{w}\t{$src2, $dst|$dst, $src2}",
Chris Lattnerec856802010-03-27 00:45:04 +00002935 [(set GR16:$dst, EFLAGS,
2936 (X86sub_flag GR16:$src1, (load addr:$src2)))]>, OpSize;
Bill Wendlingab55ebd2008-12-12 00:56:36 +00002937def SUB32rm : I<0x2B, MRMSrcMem, (outs GR32:$dst),
2938 (ins GR32:$src1, i32mem:$src2),
2939 "sub{l}\t{$src2, $dst|$dst, $src2}",
Chris Lattnerec856802010-03-27 00:45:04 +00002940 [(set GR32:$dst, EFLAGS,
2941 (X86sub_flag GR32:$src1, (load addr:$src2)))]>;
Bill Wendlingab55ebd2008-12-12 00:56:36 +00002942
2943// Register-Integer Subtraction
2944def SUB8ri : Ii8 <0x80, MRM5r, (outs GR8:$dst),
2945 (ins GR8:$src1, i8imm:$src2),
2946 "sub{b}\t{$src2, $dst|$dst, $src2}",
Chris Lattnerec856802010-03-27 00:45:04 +00002947 [(set GR8:$dst, EFLAGS,
2948 (X86sub_flag GR8:$src1, imm:$src2))]>;
Bill Wendlingab55ebd2008-12-12 00:56:36 +00002949def SUB16ri : Ii16<0x81, MRM5r, (outs GR16:$dst),
2950 (ins GR16:$src1, i16imm:$src2),
2951 "sub{w}\t{$src2, $dst|$dst, $src2}",
Chris Lattnerec856802010-03-27 00:45:04 +00002952 [(set GR16:$dst, EFLAGS,
2953 (X86sub_flag GR16:$src1, imm:$src2))]>, OpSize;
Bill Wendlingab55ebd2008-12-12 00:56:36 +00002954def SUB32ri : Ii32<0x81, MRM5r, (outs GR32:$dst),
2955 (ins GR32:$src1, i32imm:$src2),
2956 "sub{l}\t{$src2, $dst|$dst, $src2}",
Chris Lattnerec856802010-03-27 00:45:04 +00002957 [(set GR32:$dst, EFLAGS,
2958 (X86sub_flag GR32:$src1, imm:$src2))]>;
Bill Wendlingab55ebd2008-12-12 00:56:36 +00002959def SUB16ri8 : Ii8<0x83, MRM5r, (outs GR16:$dst),
2960 (ins GR16:$src1, i16i8imm:$src2),
2961 "sub{w}\t{$src2, $dst|$dst, $src2}",
Chris Lattnerec856802010-03-27 00:45:04 +00002962 [(set GR16:$dst, EFLAGS,
2963 (X86sub_flag GR16:$src1, i16immSExt8:$src2))]>, OpSize;
Bill Wendlingab55ebd2008-12-12 00:56:36 +00002964def SUB32ri8 : Ii8<0x83, MRM5r, (outs GR32:$dst),
2965 (ins GR32:$src1, i32i8imm:$src2),
2966 "sub{l}\t{$src2, $dst|$dst, $src2}",
Chris Lattnerec856802010-03-27 00:45:04 +00002967 [(set GR32:$dst, EFLAGS,
2968 (X86sub_flag GR32:$src1, i32immSExt8:$src2))]>;
Bill Wendlingab55ebd2008-12-12 00:56:36 +00002969
Chris Lattner57a02302004-08-11 04:31:00 +00002970let isTwoAddress = 0 in {
Bill Wendlingab55ebd2008-12-12 00:56:36 +00002971 // Memory-Register Subtraction
Evan Cheng64d80e32007-07-19 01:14:50 +00002972 def SUB8mr : I<0x28, MRMDestMem, (outs), (ins i8mem :$dst, GR8 :$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002973 "sub{b}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingd350e022008-12-12 21:15:41 +00002974 [(store (sub (load addr:$dst), GR8:$src2), addr:$dst),
2975 (implicit EFLAGS)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00002976 def SUB16mr : I<0x29, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002977 "sub{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingd350e022008-12-12 21:15:41 +00002978 [(store (sub (load addr:$dst), GR16:$src2), addr:$dst),
2979 (implicit EFLAGS)]>, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00002980 def SUB32mr : I<0x29, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002981 "sub{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingd350e022008-12-12 21:15:41 +00002982 [(store (sub (load addr:$dst), GR32:$src2), addr:$dst),
2983 (implicit EFLAGS)]>;
Bill Wendlingab55ebd2008-12-12 00:56:36 +00002984
2985 // Memory-Integer Subtraction
Evan Cheng64d80e32007-07-19 01:14:50 +00002986 def SUB8mi : Ii8<0x80, MRM5m, (outs), (ins i8mem :$dst, i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002987 "sub{b}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingd350e022008-12-12 21:15:41 +00002988 [(store (sub (loadi8 addr:$dst), imm:$src2), addr:$dst),
2989 (implicit EFLAGS)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00002990 def SUB16mi : Ii16<0x81, MRM5m, (outs), (ins i16mem:$dst, i16imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002991 "sub{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingd350e022008-12-12 21:15:41 +00002992 [(store (sub (loadi16 addr:$dst), imm:$src2),addr:$dst),
2993 (implicit EFLAGS)]>, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00002994 def SUB32mi : Ii32<0x81, MRM5m, (outs), (ins i32mem:$dst, i32imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002995 "sub{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingd350e022008-12-12 21:15:41 +00002996 [(store (sub (loadi32 addr:$dst), imm:$src2),addr:$dst),
2997 (implicit EFLAGS)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00002998 def SUB16mi8 : Ii8<0x83, MRM5m, (outs), (ins i16mem:$dst, i16i8imm :$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002999 "sub{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingab55ebd2008-12-12 00:56:36 +00003000 [(store (sub (load addr:$dst), i16immSExt8:$src2),
Bill Wendlingd350e022008-12-12 21:15:41 +00003001 addr:$dst),
3002 (implicit EFLAGS)]>, OpSize;
Bill Wendlingab55ebd2008-12-12 00:56:36 +00003003 def SUB32mi8 : Ii8<0x83, MRM5m, (outs), (ins i32mem:$dst, i32i8imm :$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003004 "sub{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingab55ebd2008-12-12 00:56:36 +00003005 [(store (sub (load addr:$dst), i32immSExt8:$src2),
Bill Wendlingd350e022008-12-12 21:15:41 +00003006 addr:$dst),
3007 (implicit EFLAGS)]>;
Sean Callanand00025a2009-09-11 19:01:56 +00003008
3009 def SUB8i8 : Ii8<0x2C, RawFrm, (outs), (ins i8imm:$src),
3010 "sub{b}\t{$src, %al|%al, $src}", []>;
3011 def SUB16i16 : Ii16<0x2D, RawFrm, (outs), (ins i16imm:$src),
3012 "sub{w}\t{$src, %ax|%ax, $src}", []>, OpSize;
3013 def SUB32i32 : Ii32<0x2D, RawFrm, (outs), (ins i32imm:$src),
3014 "sub{l}\t{$src, %eax|%eax, $src}", []>;
Chris Lattner57a02302004-08-11 04:31:00 +00003015}
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00003016
Evan Cheng3154cb62007-10-05 17:59:57 +00003017let Uses = [EFLAGS] in {
Dale Johannesenca11dae2009-05-18 17:44:15 +00003018def SBB8rr : I<0x18, MRMDestReg, (outs GR8:$dst),
3019 (ins GR8:$src1, GR8:$src2),
3020 "sbb{b}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen874ae252009-06-02 03:12:52 +00003021 [(set GR8:$dst, (sube GR8:$src1, GR8:$src2))]>;
Dale Johannesenca11dae2009-05-18 17:44:15 +00003022def SBB16rr : I<0x19, MRMDestReg, (outs GR16:$dst),
3023 (ins GR16:$src1, GR16:$src2),
3024 "sbb{w}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen874ae252009-06-02 03:12:52 +00003025 [(set GR16:$dst, (sube GR16:$src1, GR16:$src2))]>, OpSize;
Dale Johannesenca11dae2009-05-18 17:44:15 +00003026def SBB32rr : I<0x19, MRMDestReg, (outs GR32:$dst),
3027 (ins GR32:$src1, GR32:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003028 "sbb{l}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen874ae252009-06-02 03:12:52 +00003029 [(set GR32:$dst, (sube GR32:$src1, GR32:$src2))]>;
Chris Lattnerd93d3b02004-10-06 04:01:02 +00003030
Chris Lattner57a02302004-08-11 04:31:00 +00003031let isTwoAddress = 0 in {
Dale Johannesenca11dae2009-05-18 17:44:15 +00003032 def SBB8mr : I<0x18, MRMDestMem, (outs), (ins i8mem:$dst, GR8:$src2),
3033 "sbb{b}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen874ae252009-06-02 03:12:52 +00003034 [(store (sube (load addr:$dst), GR8:$src2), addr:$dst)]>;
Dale Johannesenca11dae2009-05-18 17:44:15 +00003035 def SBB16mr : I<0x19, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
3036 "sbb{w}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen874ae252009-06-02 03:12:52 +00003037 [(store (sube (load addr:$dst), GR16:$src2), addr:$dst)]>,
Dale Johannesen94c9cd12009-05-18 21:41:59 +00003038 OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00003039 def SBB32mr : I<0x19, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003040 "sbb{l}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen874ae252009-06-02 03:12:52 +00003041 [(store (sube (load addr:$dst), GR32:$src2), addr:$dst)]>;
Chris Lattner8f60e4d2010-02-05 22:56:11 +00003042 def SBB8mi : Ii8<0x80, MRM3m, (outs), (ins i8mem:$dst, i8imm:$src2),
3043 "sbb{b}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen874ae252009-06-02 03:12:52 +00003044 [(store (sube (loadi8 addr:$dst), imm:$src2), addr:$dst)]>;
Dale Johannesenca11dae2009-05-18 17:44:15 +00003045 def SBB16mi : Ii16<0x81, MRM3m, (outs), (ins i16mem:$dst, i16imm:$src2),
3046 "sbb{w}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen874ae252009-06-02 03:12:52 +00003047 [(store (sube (loadi16 addr:$dst), imm:$src2), addr:$dst)]>,
Dale Johannesen94c9cd12009-05-18 21:41:59 +00003048 OpSize;
Dale Johannesenca11dae2009-05-18 17:44:15 +00003049 def SBB16mi8 : Ii8<0x83, MRM3m, (outs), (ins i16mem:$dst, i16i8imm :$src2),
3050 "sbb{w}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen874ae252009-06-02 03:12:52 +00003051 [(store (sube (load addr:$dst), i16immSExt8:$src2), addr:$dst)]>,
Dale Johannesen94c9cd12009-05-18 21:41:59 +00003052 OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00003053 def SBB32mi : Ii32<0x81, MRM3m, (outs), (ins i32mem:$dst, i32imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003054 "sbb{l}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen874ae252009-06-02 03:12:52 +00003055 [(store (sube (loadi32 addr:$dst), imm:$src2), addr:$dst)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00003056 def SBB32mi8 : Ii8<0x83, MRM3m, (outs), (ins i32mem:$dst, i32i8imm :$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003057 "sbb{l}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen874ae252009-06-02 03:12:52 +00003058 [(store (sube (load addr:$dst), i32immSExt8:$src2), addr:$dst)]>;
Sean Callanand00025a2009-09-11 19:01:56 +00003059
3060 def SBB8i8 : Ii8<0x1C, RawFrm, (outs), (ins i8imm:$src),
3061 "sbb{b}\t{$src, %al|%al, $src}", []>;
3062 def SBB16i16 : Ii16<0x1D, RawFrm, (outs), (ins i16imm:$src),
3063 "sbb{w}\t{$src, %ax|%ax, $src}", []>, OpSize;
3064 def SBB32i32 : Ii32<0x1D, RawFrm, (outs), (ins i32imm:$src),
3065 "sbb{l}\t{$src, %eax|%eax, $src}", []>;
Chris Lattner57a02302004-08-11 04:31:00 +00003066}
Sean Callanan108934c2009-12-18 00:01:26 +00003067
3068def SBB8rr_REV : I<0x1A, MRMSrcReg, (outs GR8:$dst), (ins GR8:$src1, GR8:$src2),
3069 "sbb{b}\t{$src2, $dst|$dst, $src2}", []>;
3070def SBB16rr_REV : I<0x1B, MRMSrcReg, (outs GR16:$dst),
3071 (ins GR16:$src1, GR16:$src2),
3072 "sbb{w}\t{$src2, $dst|$dst, $src2}", []>, OpSize;
3073def SBB32rr_REV : I<0x1B, MRMSrcReg, (outs GR32:$dst),
3074 (ins GR32:$src1, GR32:$src2),
3075 "sbb{l}\t{$src2, $dst|$dst, $src2}", []>;
3076
Dale Johannesenca11dae2009-05-18 17:44:15 +00003077def SBB8rm : I<0x1A, MRMSrcMem, (outs GR8:$dst), (ins GR8:$src1, i8mem:$src2),
3078 "sbb{b}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen874ae252009-06-02 03:12:52 +00003079 [(set GR8:$dst, (sube GR8:$src1, (load addr:$src2)))]>;
Dale Johannesenca11dae2009-05-18 17:44:15 +00003080def SBB16rm : I<0x1B, MRMSrcMem, (outs GR16:$dst),
3081 (ins GR16:$src1, i16mem:$src2),
3082 "sbb{w}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen874ae252009-06-02 03:12:52 +00003083 [(set GR16:$dst, (sube GR16:$src1, (load addr:$src2)))]>,
Dale Johannesen94c9cd12009-05-18 21:41:59 +00003084 OpSize;
Dale Johannesenca11dae2009-05-18 17:44:15 +00003085def SBB32rm : I<0x1B, MRMSrcMem, (outs GR32:$dst),
3086 (ins GR32:$src1, i32mem:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003087 "sbb{l}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen874ae252009-06-02 03:12:52 +00003088 [(set GR32:$dst, (sube GR32:$src1, (load addr:$src2)))]>;
Dale Johannesenca11dae2009-05-18 17:44:15 +00003089def SBB8ri : Ii8<0x80, MRM3r, (outs GR8:$dst), (ins GR8:$src1, i8imm:$src2),
3090 "sbb{b}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen874ae252009-06-02 03:12:52 +00003091 [(set GR8:$dst, (sube GR8:$src1, imm:$src2))]>;
Dale Johannesenca11dae2009-05-18 17:44:15 +00003092def SBB16ri : Ii16<0x81, MRM3r, (outs GR16:$dst),
3093 (ins GR16:$src1, i16imm:$src2),
3094 "sbb{w}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen874ae252009-06-02 03:12:52 +00003095 [(set GR16:$dst, (sube GR16:$src1, imm:$src2))]>, OpSize;
Dale Johannesenca11dae2009-05-18 17:44:15 +00003096def SBB16ri8 : Ii8<0x83, MRM3r, (outs GR16:$dst),
3097 (ins GR16:$src1, i16i8imm:$src2),
3098 "sbb{w}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen874ae252009-06-02 03:12:52 +00003099 [(set GR16:$dst, (sube GR16:$src1, i16immSExt8:$src2))]>,
3100 OpSize;
Dale Johannesenca11dae2009-05-18 17:44:15 +00003101def SBB32ri : Ii32<0x81, MRM3r, (outs GR32:$dst),
3102 (ins GR32:$src1, i32imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003103 "sbb{l}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen874ae252009-06-02 03:12:52 +00003104 [(set GR32:$dst, (sube GR32:$src1, imm:$src2))]>;
Dale Johannesenca11dae2009-05-18 17:44:15 +00003105def SBB32ri8 : Ii8<0x83, MRM3r, (outs GR32:$dst),
3106 (ins GR32:$src1, i32i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003107 "sbb{l}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen874ae252009-06-02 03:12:52 +00003108 [(set GR32:$dst, (sube GR32:$src1, i32immSExt8:$src2))]>;
Evan Cheng3154cb62007-10-05 17:59:57 +00003109} // Uses = [EFLAGS]
Evan Cheng24f2ea32007-09-14 21:48:26 +00003110} // Defs = [EFLAGS]
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00003111
Evan Cheng24f2ea32007-09-14 21:48:26 +00003112let Defs = [EFLAGS] in {
Chris Lattner10197ff2005-01-03 01:27:59 +00003113let isCommutable = 1 in { // X = IMUL Y, Z --> X = IMUL Z, Y
Bill Wendlingd350e022008-12-12 21:15:41 +00003114// Register-Register Signed Integer Multiply
Bill Wendlingab55ebd2008-12-12 00:56:36 +00003115def IMUL16rr : I<0xAF, MRMSrcReg, (outs GR16:$dst), (ins GR16:$src1,GR16:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003116 "imul{w}\t{$src2, $dst|$dst, $src2}",
Chris Lattnerec856802010-03-27 00:45:04 +00003117 [(set GR16:$dst, EFLAGS,
3118 (X86smul_flag GR16:$src1, GR16:$src2))]>, TB, OpSize;
Bill Wendlingab55ebd2008-12-12 00:56:36 +00003119def IMUL32rr : I<0xAF, MRMSrcReg, (outs GR32:$dst), (ins GR32:$src1,GR32:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003120 "imul{l}\t{$src2, $dst|$dst, $src2}",
Chris Lattnerec856802010-03-27 00:45:04 +00003121 [(set GR32:$dst, EFLAGS,
3122 (X86smul_flag GR32:$src1, GR32:$src2))]>, TB;
Chris Lattner10197ff2005-01-03 01:27:59 +00003123}
Bill Wendlingab55ebd2008-12-12 00:56:36 +00003124
Bill Wendlingd350e022008-12-12 21:15:41 +00003125// Register-Memory Signed Integer Multiply
Bill Wendlingab55ebd2008-12-12 00:56:36 +00003126def IMUL16rm : I<0xAF, MRMSrcMem, (outs GR16:$dst),
3127 (ins GR16:$src1, i16mem:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003128 "imul{w}\t{$src2, $dst|$dst, $src2}",
Chris Lattnerec856802010-03-27 00:45:04 +00003129 [(set GR16:$dst, EFLAGS,
3130 (X86smul_flag GR16:$src1, (load addr:$src2)))]>,
3131 TB, OpSize;
Sean Callanan108934c2009-12-18 00:01:26 +00003132def IMUL32rm : I<0xAF, MRMSrcMem, (outs GR32:$dst),
3133 (ins GR32:$src1, i32mem:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003134 "imul{l}\t{$src2, $dst|$dst, $src2}",
Chris Lattnerec856802010-03-27 00:45:04 +00003135 [(set GR32:$dst, EFLAGS,
3136 (X86smul_flag GR32:$src1, (load addr:$src2)))]>, TB;
Evan Cheng24f2ea32007-09-14 21:48:26 +00003137} // Defs = [EFLAGS]
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00003138} // end Two Address instructions
3139
Chris Lattnerf5d3a832004-08-11 05:31:07 +00003140// Suprisingly enough, these are not two address instructions!
Evan Cheng24f2ea32007-09-14 21:48:26 +00003141let Defs = [EFLAGS] in {
Bill Wendlingd350e022008-12-12 21:15:41 +00003142// Register-Integer Signed Integer Multiply
Evan Cheng069287d2006-05-16 07:21:53 +00003143def IMUL16rri : Ii16<0x69, MRMSrcReg, // GR16 = GR16*I16
Evan Cheng64d80e32007-07-19 01:14:50 +00003144 (outs GR16:$dst), (ins GR16:$src1, i16imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003145 "imul{w}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Chris Lattnerec856802010-03-27 00:45:04 +00003146 [(set GR16:$dst, EFLAGS,
3147 (X86smul_flag GR16:$src1, imm:$src2))]>, OpSize;
Evan Cheng069287d2006-05-16 07:21:53 +00003148def IMUL32rri : Ii32<0x69, MRMSrcReg, // GR32 = GR32*I32
Evan Cheng64d80e32007-07-19 01:14:50 +00003149 (outs GR32:$dst), (ins GR32:$src1, i32imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003150 "imul{l}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Chris Lattnerec856802010-03-27 00:45:04 +00003151 [(set GR32:$dst, EFLAGS,
3152 (X86smul_flag GR32:$src1, imm:$src2))]>;
Evan Cheng069287d2006-05-16 07:21:53 +00003153def IMUL16rri8 : Ii8<0x6B, MRMSrcReg, // GR16 = GR16*I8
Evan Cheng64d80e32007-07-19 01:14:50 +00003154 (outs GR16:$dst), (ins GR16:$src1, i16i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003155 "imul{w}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Chris Lattnerec856802010-03-27 00:45:04 +00003156 [(set GR16:$dst, EFLAGS,
3157 (X86smul_flag GR16:$src1, i16immSExt8:$src2))]>,
3158 OpSize;
Evan Cheng069287d2006-05-16 07:21:53 +00003159def IMUL32rri8 : Ii8<0x6B, MRMSrcReg, // GR32 = GR32*I8
Evan Cheng64d80e32007-07-19 01:14:50 +00003160 (outs GR32:$dst), (ins GR32:$src1, i32i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003161 "imul{l}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Chris Lattnerec856802010-03-27 00:45:04 +00003162 [(set GR32:$dst, EFLAGS,
3163 (X86smul_flag GR32:$src1, i32immSExt8:$src2))]>;
Chris Lattnerf5d3a832004-08-11 05:31:07 +00003164
Bill Wendlingd350e022008-12-12 21:15:41 +00003165// Memory-Integer Signed Integer Multiply
Sean Callanan108934c2009-12-18 00:01:26 +00003166def IMUL16rmi : Ii16<0x69, MRMSrcMem, // GR16 = [mem16]*I16
Evan Cheng64d80e32007-07-19 01:14:50 +00003167 (outs GR16:$dst), (ins i16mem:$src1, i16imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003168 "imul{w}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Chris Lattnerec856802010-03-27 00:45:04 +00003169 [(set GR16:$dst, EFLAGS,
3170 (X86smul_flag (load addr:$src1), imm:$src2))]>,
3171 OpSize;
Sean Callanan108934c2009-12-18 00:01:26 +00003172def IMUL32rmi : Ii32<0x69, MRMSrcMem, // GR32 = [mem32]*I32
Evan Cheng64d80e32007-07-19 01:14:50 +00003173 (outs GR32:$dst), (ins i32mem:$src1, i32imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003174 "imul{l}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Chris Lattnerec856802010-03-27 00:45:04 +00003175 [(set GR32:$dst, EFLAGS,
3176 (X86smul_flag (load addr:$src1), imm:$src2))]>;
Evan Cheng069287d2006-05-16 07:21:53 +00003177def IMUL16rmi8 : Ii8<0x6B, MRMSrcMem, // GR16 = [mem16]*I8
Evan Cheng64d80e32007-07-19 01:14:50 +00003178 (outs GR16:$dst), (ins i16mem:$src1, i16i8imm :$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003179 "imul{w}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Chris Lattnerec856802010-03-27 00:45:04 +00003180 [(set GR16:$dst, EFLAGS,
3181 (X86smul_flag (load addr:$src1),
3182 i16immSExt8:$src2))]>, OpSize;
Evan Cheng069287d2006-05-16 07:21:53 +00003183def IMUL32rmi8 : Ii8<0x6B, MRMSrcMem, // GR32 = [mem32]*I8
Evan Cheng64d80e32007-07-19 01:14:50 +00003184 (outs GR32:$dst), (ins i32mem:$src1, i32i8imm: $src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003185 "imul{l}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Chris Lattnerec856802010-03-27 00:45:04 +00003186 [(set GR32:$dst, EFLAGS,
3187 (X86smul_flag (load addr:$src1),
3188 i32immSExt8:$src2))]>;
Evan Cheng24f2ea32007-09-14 21:48:26 +00003189} // Defs = [EFLAGS]
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00003190
3191//===----------------------------------------------------------------------===//
3192// Test instructions are just like AND, except they don't generate a result.
Chris Lattner3a173df2004-10-03 20:35:00 +00003193//
Evan Cheng0488db92007-09-25 01:57:46 +00003194let Defs = [EFLAGS] in {
Chris Lattnercc65bee2005-01-02 02:35:46 +00003195let isCommutable = 1 in { // TEST X, Y --> TEST Y, X
Daniel Dunbarb93c72c2010-03-08 21:10:36 +00003196def TEST8rr : I<0x84, MRMSrcReg, (outs), (ins GR8:$src1, GR8:$src2),
Evan Chenge5f62042007-09-29 00:00:36 +00003197 "test{b}\t{$src2, $src1|$src1, $src2}",
Chris Lattnere3486a42010-03-19 00:01:11 +00003198 [(set EFLAGS, (X86cmp (and_su GR8:$src1, GR8:$src2), 0))]>;
Daniel Dunbarb93c72c2010-03-08 21:10:36 +00003199def TEST16rr : I<0x85, MRMSrcReg, (outs), (ins GR16:$src1, GR16:$src2),
Evan Chenge5f62042007-09-29 00:00:36 +00003200 "test{w}\t{$src2, $src1|$src1, $src2}",
Chris Lattnere3486a42010-03-19 00:01:11 +00003201 [(set EFLAGS, (X86cmp (and_su GR16:$src1, GR16:$src2),
3202 0))]>,
Evan Chenge5f62042007-09-29 00:00:36 +00003203 OpSize;
Daniel Dunbarb93c72c2010-03-08 21:10:36 +00003204def TEST32rr : I<0x85, MRMSrcReg, (outs), (ins GR32:$src1, GR32:$src2),
Evan Chenge5f62042007-09-29 00:00:36 +00003205 "test{l}\t{$src2, $src1|$src1, $src2}",
Chris Lattnere3486a42010-03-19 00:01:11 +00003206 [(set EFLAGS, (X86cmp (and_su GR32:$src1, GR32:$src2),
3207 0))]>;
Chris Lattnercc65bee2005-01-02 02:35:46 +00003208}
Evan Cheng734503b2006-09-11 02:19:56 +00003209
Sean Callanan4a93b712009-09-01 18:14:18 +00003210def TEST8i8 : Ii8<0xA8, RawFrm, (outs), (ins i8imm:$src),
3211 "test{b}\t{$src, %al|%al, $src}", []>;
3212def TEST16i16 : Ii16<0xA9, RawFrm, (outs), (ins i16imm:$src),
3213 "test{w}\t{$src, %ax|%ax, $src}", []>, OpSize;
3214def TEST32i32 : Ii32<0xA9, RawFrm, (outs), (ins i32imm:$src),
3215 "test{l}\t{$src, %eax|%eax, $src}", []>;
3216
Evan Cheng64d80e32007-07-19 01:14:50 +00003217def TEST8rm : I<0x84, MRMSrcMem, (outs), (ins GR8 :$src1, i8mem :$src2),
Evan Chenge5f62042007-09-29 00:00:36 +00003218 "test{b}\t{$src2, $src1|$src1, $src2}",
Chris Lattnere3486a42010-03-19 00:01:11 +00003219 [(set EFLAGS, (X86cmp (and GR8:$src1, (loadi8 addr:$src2)),
3220 0))]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00003221def TEST16rm : I<0x85, MRMSrcMem, (outs), (ins GR16:$src1, i16mem:$src2),
Evan Chenge5f62042007-09-29 00:00:36 +00003222 "test{w}\t{$src2, $src1|$src1, $src2}",
Chris Lattnere3486a42010-03-19 00:01:11 +00003223 [(set EFLAGS, (X86cmp (and GR16:$src1,
3224 (loadi16 addr:$src2)), 0))]>, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00003225def TEST32rm : I<0x85, MRMSrcMem, (outs), (ins GR32:$src1, i32mem:$src2),
Evan Chenge5f62042007-09-29 00:00:36 +00003226 "test{l}\t{$src2, $src1|$src1, $src2}",
Chris Lattnere3486a42010-03-19 00:01:11 +00003227 [(set EFLAGS, (X86cmp (and GR32:$src1,
3228 (loadi32 addr:$src2)), 0))]>;
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00003229
Evan Cheng069287d2006-05-16 07:21:53 +00003230def TEST8ri : Ii8 <0xF6, MRM0r, // flags = GR8 & imm8
Evan Cheng64d80e32007-07-19 01:14:50 +00003231 (outs), (ins GR8:$src1, i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003232 "test{b}\t{$src2, $src1|$src1, $src2}",
Chris Lattnere3486a42010-03-19 00:01:11 +00003233 [(set EFLAGS, (X86cmp (and_su GR8:$src1, imm:$src2), 0))]>;
Evan Cheng069287d2006-05-16 07:21:53 +00003234def TEST16ri : Ii16<0xF7, MRM0r, // flags = GR16 & imm16
Evan Cheng64d80e32007-07-19 01:14:50 +00003235 (outs), (ins GR16:$src1, i16imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003236 "test{w}\t{$src2, $src1|$src1, $src2}",
Chris Lattnere3486a42010-03-19 00:01:11 +00003237 [(set EFLAGS, (X86cmp (and_su GR16:$src1, imm:$src2), 0))]>,
3238 OpSize;
Evan Cheng069287d2006-05-16 07:21:53 +00003239def TEST32ri : Ii32<0xF7, MRM0r, // flags = GR32 & imm32
Evan Cheng64d80e32007-07-19 01:14:50 +00003240 (outs), (ins GR32:$src1, i32imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003241 "test{l}\t{$src2, $src1|$src1, $src2}",
Chris Lattnere3486a42010-03-19 00:01:11 +00003242 [(set EFLAGS, (X86cmp (and_su GR32:$src1, imm:$src2), 0))]>;
Evan Cheng734503b2006-09-11 02:19:56 +00003243
Evan Chenge5f62042007-09-29 00:00:36 +00003244def TEST8mi : Ii8 <0xF6, MRM0m, // flags = [mem8] & imm8
Evan Cheng64d80e32007-07-19 01:14:50 +00003245 (outs), (ins i8mem:$src1, i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003246 "test{b}\t{$src2, $src1|$src1, $src2}",
Chris Lattnere3486a42010-03-19 00:01:11 +00003247 [(set EFLAGS, (X86cmp (and (loadi8 addr:$src1), imm:$src2),
3248 0))]>;
Evan Chenge5f62042007-09-29 00:00:36 +00003249def TEST16mi : Ii16<0xF7, MRM0m, // flags = [mem16] & imm16
Evan Cheng64d80e32007-07-19 01:14:50 +00003250 (outs), (ins i16mem:$src1, i16imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003251 "test{w}\t{$src2, $src1|$src1, $src2}",
Chris Lattnere3486a42010-03-19 00:01:11 +00003252 [(set EFLAGS, (X86cmp (and (loadi16 addr:$src1), imm:$src2),
3253 0))]>, OpSize;
Evan Chenge5f62042007-09-29 00:00:36 +00003254def TEST32mi : Ii32<0xF7, MRM0m, // flags = [mem32] & imm32
Evan Cheng64d80e32007-07-19 01:14:50 +00003255 (outs), (ins i32mem:$src1, i32imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003256 "test{l}\t{$src2, $src1|$src1, $src2}",
Chris Lattnere3486a42010-03-19 00:01:11 +00003257 [(set EFLAGS, (X86cmp (and (loadi32 addr:$src1), imm:$src2),
3258 0))]>;
Evan Cheng0488db92007-09-25 01:57:46 +00003259} // Defs = [EFLAGS]
3260
3261
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00003262// Condition code ops, incl. set if equal/not equal/...
Chris Lattnerba7e7562008-01-10 07:59:24 +00003263let Defs = [EFLAGS], Uses = [AH], neverHasSideEffects = 1 in
Evan Cheng071a2792007-09-11 19:55:27 +00003264def SAHF : I<0x9E, RawFrm, (outs), (ins), "sahf", []>; // flags = AH
Chris Lattnerba7e7562008-01-10 07:59:24 +00003265let Defs = [AH], Uses = [EFLAGS], neverHasSideEffects = 1 in
Evan Cheng071a2792007-09-11 19:55:27 +00003266def LAHF : I<0x9F, RawFrm, (outs), (ins), "lahf", []>; // AH = flags
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00003267
Evan Cheng0488db92007-09-25 01:57:46 +00003268let Uses = [EFLAGS] in {
Evan Chengad9c0a32009-12-15 00:53:42 +00003269// Use sbb to materialize carry bit.
Evan Chengad9c0a32009-12-15 00:53:42 +00003270let Defs = [EFLAGS], isCodeGenOnly = 1 in {
Chris Lattnerc74e3332010-02-05 21:13:48 +00003271// FIXME: These are pseudo ops that should be replaced with Pat<> patterns.
3272// However, Pat<> can't replicate the destination reg into the inputs of the
3273// result.
3274// FIXME: Change these to have encoding Pseudo when X86MCCodeEmitter replaces
3275// X86CodeEmitter.
3276def SETB_C8r : I<0x18, MRMInitReg, (outs GR8:$dst), (ins), "",
Evan Chengad9c0a32009-12-15 00:53:42 +00003277 [(set GR8:$dst, (X86setcc_c X86_COND_B, EFLAGS))]>;
Chris Lattnerc74e3332010-02-05 21:13:48 +00003278def SETB_C16r : I<0x19, MRMInitReg, (outs GR16:$dst), (ins), "",
Evan Cheng2e489c42009-12-16 00:53:11 +00003279 [(set GR16:$dst, (X86setcc_c X86_COND_B, EFLAGS))]>,
Evan Chengad9c0a32009-12-15 00:53:42 +00003280 OpSize;
Chris Lattnerc74e3332010-02-05 21:13:48 +00003281def SETB_C32r : I<0x19, MRMInitReg, (outs GR32:$dst), (ins), "",
Evan Cheng2e489c42009-12-16 00:53:11 +00003282 [(set GR32:$dst, (X86setcc_c X86_COND_B, EFLAGS))]>;
Evan Chengad9c0a32009-12-15 00:53:42 +00003283} // isCodeGenOnly
3284
Chris Lattner3a173df2004-10-03 20:35:00 +00003285def SETEr : I<0x94, MRM0r,
Evan Cheng64d80e32007-07-19 01:14:50 +00003286 (outs GR8 :$dst), (ins),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003287 "sete\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +00003288 [(set GR8:$dst, (X86setcc X86_COND_E, EFLAGS))]>,
Evan Cheng069287d2006-05-16 07:21:53 +00003289 TB; // GR8 = ==
Chris Lattner3a173df2004-10-03 20:35:00 +00003290def SETEm : I<0x94, MRM0m,
Evan Cheng64d80e32007-07-19 01:14:50 +00003291 (outs), (ins i8mem:$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003292 "sete\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +00003293 [(store (X86setcc X86_COND_E, EFLAGS), addr:$dst)]>,
Evan Chengd5781fc2005-12-21 20:21:51 +00003294 TB; // [mem8] = ==
Bill Wendling9f248742008-12-02 00:07:05 +00003295
Chris Lattner3a173df2004-10-03 20:35:00 +00003296def SETNEr : I<0x95, MRM0r,
Evan Cheng64d80e32007-07-19 01:14:50 +00003297 (outs GR8 :$dst), (ins),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003298 "setne\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +00003299 [(set GR8:$dst, (X86setcc X86_COND_NE, EFLAGS))]>,
Evan Cheng069287d2006-05-16 07:21:53 +00003300 TB; // GR8 = !=
Chris Lattner3a173df2004-10-03 20:35:00 +00003301def SETNEm : I<0x95, MRM0m,
Evan Cheng64d80e32007-07-19 01:14:50 +00003302 (outs), (ins i8mem:$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003303 "setne\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +00003304 [(store (X86setcc X86_COND_NE, EFLAGS), addr:$dst)]>,
Evan Chengd5781fc2005-12-21 20:21:51 +00003305 TB; // [mem8] = !=
Bill Wendling9f248742008-12-02 00:07:05 +00003306
Evan Chengd5781fc2005-12-21 20:21:51 +00003307def SETLr : I<0x9C, MRM0r,
Evan Cheng64d80e32007-07-19 01:14:50 +00003308 (outs GR8 :$dst), (ins),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003309 "setl\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +00003310 [(set GR8:$dst, (X86setcc X86_COND_L, EFLAGS))]>,
Evan Cheng069287d2006-05-16 07:21:53 +00003311 TB; // GR8 = < signed
Evan Chengd5781fc2005-12-21 20:21:51 +00003312def SETLm : I<0x9C, MRM0m,
Evan Cheng64d80e32007-07-19 01:14:50 +00003313 (outs), (ins i8mem:$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003314 "setl\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +00003315 [(store (X86setcc X86_COND_L, EFLAGS), addr:$dst)]>,
Evan Chengd5781fc2005-12-21 20:21:51 +00003316 TB; // [mem8] = < signed
Bill Wendling9f248742008-12-02 00:07:05 +00003317
Evan Chengd5781fc2005-12-21 20:21:51 +00003318def SETGEr : I<0x9D, MRM0r,
Evan Cheng64d80e32007-07-19 01:14:50 +00003319 (outs GR8 :$dst), (ins),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003320 "setge\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +00003321 [(set GR8:$dst, (X86setcc X86_COND_GE, EFLAGS))]>,
Evan Cheng069287d2006-05-16 07:21:53 +00003322 TB; // GR8 = >= signed
Evan Chengd5781fc2005-12-21 20:21:51 +00003323def SETGEm : I<0x9D, MRM0m,
Evan Cheng64d80e32007-07-19 01:14:50 +00003324 (outs), (ins i8mem:$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003325 "setge\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +00003326 [(store (X86setcc X86_COND_GE, EFLAGS), addr:$dst)]>,
Evan Chengd5781fc2005-12-21 20:21:51 +00003327 TB; // [mem8] = >= signed
Bill Wendling9f248742008-12-02 00:07:05 +00003328
Evan Chengd5781fc2005-12-21 20:21:51 +00003329def SETLEr : I<0x9E, MRM0r,
Evan Cheng64d80e32007-07-19 01:14:50 +00003330 (outs GR8 :$dst), (ins),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003331 "setle\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +00003332 [(set GR8:$dst, (X86setcc X86_COND_LE, EFLAGS))]>,
Evan Cheng069287d2006-05-16 07:21:53 +00003333 TB; // GR8 = <= signed
Evan Chengd5781fc2005-12-21 20:21:51 +00003334def SETLEm : I<0x9E, MRM0m,
Evan Cheng64d80e32007-07-19 01:14:50 +00003335 (outs), (ins i8mem:$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003336 "setle\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +00003337 [(store (X86setcc X86_COND_LE, EFLAGS), addr:$dst)]>,
Evan Chengd5781fc2005-12-21 20:21:51 +00003338 TB; // [mem8] = <= signed
Bill Wendling9f248742008-12-02 00:07:05 +00003339
Evan Chengd5781fc2005-12-21 20:21:51 +00003340def SETGr : I<0x9F, MRM0r,
Evan Cheng64d80e32007-07-19 01:14:50 +00003341 (outs GR8 :$dst), (ins),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003342 "setg\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +00003343 [(set GR8:$dst, (X86setcc X86_COND_G, EFLAGS))]>,
Evan Cheng069287d2006-05-16 07:21:53 +00003344 TB; // GR8 = > signed
Evan Chengd5781fc2005-12-21 20:21:51 +00003345def SETGm : I<0x9F, MRM0m,
Evan Cheng64d80e32007-07-19 01:14:50 +00003346 (outs), (ins i8mem:$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003347 "setg\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +00003348 [(store (X86setcc X86_COND_G, EFLAGS), addr:$dst)]>,
Evan Chengd5781fc2005-12-21 20:21:51 +00003349 TB; // [mem8] = > signed
3350
3351def SETBr : I<0x92, MRM0r,
Evan Cheng64d80e32007-07-19 01:14:50 +00003352 (outs GR8 :$dst), (ins),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003353 "setb\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +00003354 [(set GR8:$dst, (X86setcc X86_COND_B, EFLAGS))]>,
Evan Cheng069287d2006-05-16 07:21:53 +00003355 TB; // GR8 = < unsign
Evan Chengd5781fc2005-12-21 20:21:51 +00003356def SETBm : I<0x92, MRM0m,
Evan Cheng64d80e32007-07-19 01:14:50 +00003357 (outs), (ins i8mem:$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003358 "setb\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +00003359 [(store (X86setcc X86_COND_B, EFLAGS), addr:$dst)]>,
Evan Chengd5781fc2005-12-21 20:21:51 +00003360 TB; // [mem8] = < unsign
Bill Wendling9f248742008-12-02 00:07:05 +00003361
Evan Chengd5781fc2005-12-21 20:21:51 +00003362def SETAEr : I<0x93, MRM0r,
Evan Cheng64d80e32007-07-19 01:14:50 +00003363 (outs GR8 :$dst), (ins),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003364 "setae\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +00003365 [(set GR8:$dst, (X86setcc X86_COND_AE, EFLAGS))]>,
Evan Cheng069287d2006-05-16 07:21:53 +00003366 TB; // GR8 = >= unsign
Evan Chengd5781fc2005-12-21 20:21:51 +00003367def SETAEm : I<0x93, MRM0m,
Evan Cheng64d80e32007-07-19 01:14:50 +00003368 (outs), (ins i8mem:$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003369 "setae\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +00003370 [(store (X86setcc X86_COND_AE, EFLAGS), addr:$dst)]>,
Evan Chengd5781fc2005-12-21 20:21:51 +00003371 TB; // [mem8] = >= unsign
Bill Wendling9f248742008-12-02 00:07:05 +00003372
Chris Lattner3a173df2004-10-03 20:35:00 +00003373def SETBEr : I<0x96, MRM0r,
Evan Cheng64d80e32007-07-19 01:14:50 +00003374 (outs GR8 :$dst), (ins),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003375 "setbe\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +00003376 [(set GR8:$dst, (X86setcc X86_COND_BE, EFLAGS))]>,
Evan Cheng069287d2006-05-16 07:21:53 +00003377 TB; // GR8 = <= unsign
Chris Lattner3a173df2004-10-03 20:35:00 +00003378def SETBEm : I<0x96, MRM0m,
Evan Cheng64d80e32007-07-19 01:14:50 +00003379 (outs), (ins i8mem:$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003380 "setbe\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +00003381 [(store (X86setcc X86_COND_BE, EFLAGS), addr:$dst)]>,
Evan Chengd5781fc2005-12-21 20:21:51 +00003382 TB; // [mem8] = <= unsign
Bill Wendling9f248742008-12-02 00:07:05 +00003383
Chris Lattner3a173df2004-10-03 20:35:00 +00003384def SETAr : I<0x97, MRM0r,
Evan Cheng64d80e32007-07-19 01:14:50 +00003385 (outs GR8 :$dst), (ins),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003386 "seta\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +00003387 [(set GR8:$dst, (X86setcc X86_COND_A, EFLAGS))]>,
Evan Cheng069287d2006-05-16 07:21:53 +00003388 TB; // GR8 = > signed
Chris Lattner3a173df2004-10-03 20:35:00 +00003389def SETAm : I<0x97, MRM0m,
Evan Cheng64d80e32007-07-19 01:14:50 +00003390 (outs), (ins i8mem:$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003391 "seta\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +00003392 [(store (X86setcc X86_COND_A, EFLAGS), addr:$dst)]>,
Evan Chengd5781fc2005-12-21 20:21:51 +00003393 TB; // [mem8] = > signed
Evan Chengd9558e02006-01-06 00:43:03 +00003394
Chris Lattner3a173df2004-10-03 20:35:00 +00003395def SETSr : I<0x98, MRM0r,
Evan Cheng64d80e32007-07-19 01:14:50 +00003396 (outs GR8 :$dst), (ins),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003397 "sets\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +00003398 [(set GR8:$dst, (X86setcc X86_COND_S, EFLAGS))]>,
Evan Cheng069287d2006-05-16 07:21:53 +00003399 TB; // GR8 = <sign bit>
Chris Lattner3a173df2004-10-03 20:35:00 +00003400def SETSm : I<0x98, MRM0m,
Evan Cheng64d80e32007-07-19 01:14:50 +00003401 (outs), (ins i8mem:$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003402 "sets\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +00003403 [(store (X86setcc X86_COND_S, EFLAGS), addr:$dst)]>,
Evan Chengd9558e02006-01-06 00:43:03 +00003404 TB; // [mem8] = <sign bit>
Chris Lattner3a173df2004-10-03 20:35:00 +00003405def SETNSr : I<0x99, MRM0r,
Evan Cheng64d80e32007-07-19 01:14:50 +00003406 (outs GR8 :$dst), (ins),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003407 "setns\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +00003408 [(set GR8:$dst, (X86setcc X86_COND_NS, EFLAGS))]>,
Evan Cheng069287d2006-05-16 07:21:53 +00003409 TB; // GR8 = !<sign bit>
Chris Lattner3a173df2004-10-03 20:35:00 +00003410def SETNSm : I<0x99, MRM0m,
Evan Cheng64d80e32007-07-19 01:14:50 +00003411 (outs), (ins i8mem:$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003412 "setns\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +00003413 [(store (X86setcc X86_COND_NS, EFLAGS), addr:$dst)]>,
Evan Chengd9558e02006-01-06 00:43:03 +00003414 TB; // [mem8] = !<sign bit>
Bill Wendling9f248742008-12-02 00:07:05 +00003415
Chris Lattner3a173df2004-10-03 20:35:00 +00003416def SETPr : I<0x9A, MRM0r,
Evan Cheng64d80e32007-07-19 01:14:50 +00003417 (outs GR8 :$dst), (ins),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003418 "setp\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +00003419 [(set GR8:$dst, (X86setcc X86_COND_P, EFLAGS))]>,
Evan Cheng069287d2006-05-16 07:21:53 +00003420 TB; // GR8 = parity
Chris Lattner3a173df2004-10-03 20:35:00 +00003421def SETPm : I<0x9A, MRM0m,
Evan Cheng64d80e32007-07-19 01:14:50 +00003422 (outs), (ins i8mem:$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003423 "setp\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +00003424 [(store (X86setcc X86_COND_P, EFLAGS), addr:$dst)]>,
Evan Chengd9558e02006-01-06 00:43:03 +00003425 TB; // [mem8] = parity
Chris Lattnercc65bee2005-01-02 02:35:46 +00003426def SETNPr : I<0x9B, MRM0r,
Evan Cheng64d80e32007-07-19 01:14:50 +00003427 (outs GR8 :$dst), (ins),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003428 "setnp\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +00003429 [(set GR8:$dst, (X86setcc X86_COND_NP, EFLAGS))]>,
Evan Cheng069287d2006-05-16 07:21:53 +00003430 TB; // GR8 = not parity
Chris Lattnercc65bee2005-01-02 02:35:46 +00003431def SETNPm : I<0x9B, MRM0m,
Evan Cheng64d80e32007-07-19 01:14:50 +00003432 (outs), (ins i8mem:$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003433 "setnp\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +00003434 [(store (X86setcc X86_COND_NP, EFLAGS), addr:$dst)]>,
Evan Chengd9558e02006-01-06 00:43:03 +00003435 TB; // [mem8] = not parity
Bill Wendling9f248742008-12-02 00:07:05 +00003436
3437def SETOr : I<0x90, MRM0r,
3438 (outs GR8 :$dst), (ins),
3439 "seto\t$dst",
3440 [(set GR8:$dst, (X86setcc X86_COND_O, EFLAGS))]>,
3441 TB; // GR8 = overflow
3442def SETOm : I<0x90, MRM0m,
3443 (outs), (ins i8mem:$dst),
3444 "seto\t$dst",
3445 [(store (X86setcc X86_COND_O, EFLAGS), addr:$dst)]>,
3446 TB; // [mem8] = overflow
3447def SETNOr : I<0x91, MRM0r,
3448 (outs GR8 :$dst), (ins),
3449 "setno\t$dst",
3450 [(set GR8:$dst, (X86setcc X86_COND_NO, EFLAGS))]>,
3451 TB; // GR8 = not overflow
3452def SETNOm : I<0x91, MRM0m,
3453 (outs), (ins i8mem:$dst),
3454 "setno\t$dst",
3455 [(store (X86setcc X86_COND_NO, EFLAGS), addr:$dst)]>,
3456 TB; // [mem8] = not overflow
Evan Cheng0488db92007-09-25 01:57:46 +00003457} // Uses = [EFLAGS]
3458
Chris Lattner1cca5e32003-08-03 21:54:21 +00003459
3460// Integer comparisons
Evan Cheng24f2ea32007-09-14 21:48:26 +00003461let Defs = [EFLAGS] in {
Sean Callanana09caa52009-09-02 00:55:49 +00003462def CMP8i8 : Ii8<0x3C, RawFrm, (outs), (ins i8imm:$src),
3463 "cmp{b}\t{$src, %al|%al, $src}", []>;
3464def CMP16i16 : Ii16<0x3D, RawFrm, (outs), (ins i16imm:$src),
3465 "cmp{w}\t{$src, %ax|%ax, $src}", []>, OpSize;
3466def CMP32i32 : Ii32<0x3D, RawFrm, (outs), (ins i32imm:$src),
3467 "cmp{l}\t{$src, %eax|%eax, $src}", []>;
3468
Chris Lattner3a173df2004-10-03 20:35:00 +00003469def CMP8rr : I<0x38, MRMDestReg,
Evan Cheng64d80e32007-07-19 01:14:50 +00003470 (outs), (ins GR8 :$src1, GR8 :$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003471 "cmp{b}\t{$src2, $src1|$src1, $src2}",
Chris Lattnere3486a42010-03-19 00:01:11 +00003472 [(set EFLAGS, (X86cmp GR8:$src1, GR8:$src2))]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00003473def CMP16rr : I<0x39, MRMDestReg,
Evan Cheng64d80e32007-07-19 01:14:50 +00003474 (outs), (ins GR16:$src1, GR16:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003475 "cmp{w}\t{$src2, $src1|$src1, $src2}",
Chris Lattnere3486a42010-03-19 00:01:11 +00003476 [(set EFLAGS, (X86cmp GR16:$src1, GR16:$src2))]>, OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00003477def CMP32rr : I<0x39, MRMDestReg,
Evan Cheng64d80e32007-07-19 01:14:50 +00003478 (outs), (ins GR32:$src1, GR32:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003479 "cmp{l}\t{$src2, $src1|$src1, $src2}",
Chris Lattnere3486a42010-03-19 00:01:11 +00003480 [(set EFLAGS, (X86cmp GR32:$src1, GR32:$src2))]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00003481def CMP8mr : I<0x38, MRMDestMem,
Evan Cheng64d80e32007-07-19 01:14:50 +00003482 (outs), (ins i8mem :$src1, GR8 :$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003483 "cmp{b}\t{$src2, $src1|$src1, $src2}",
Chris Lattnere3486a42010-03-19 00:01:11 +00003484 [(set EFLAGS, (X86cmp (loadi8 addr:$src1), GR8:$src2))]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00003485def CMP16mr : I<0x39, MRMDestMem,
Evan Cheng64d80e32007-07-19 01:14:50 +00003486 (outs), (ins i16mem:$src1, GR16:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003487 "cmp{w}\t{$src2, $src1|$src1, $src2}",
Chris Lattnere3486a42010-03-19 00:01:11 +00003488 [(set EFLAGS, (X86cmp (loadi16 addr:$src1), GR16:$src2))]>,
3489 OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00003490def CMP32mr : I<0x39, MRMDestMem,
Evan Cheng64d80e32007-07-19 01:14:50 +00003491 (outs), (ins i32mem:$src1, GR32:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003492 "cmp{l}\t{$src2, $src1|$src1, $src2}",
Chris Lattnere3486a42010-03-19 00:01:11 +00003493 [(set EFLAGS, (X86cmp (loadi32 addr:$src1), GR32:$src2))]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00003494def CMP8rm : I<0x3A, MRMSrcMem,
Evan Cheng64d80e32007-07-19 01:14:50 +00003495 (outs), (ins GR8 :$src1, i8mem :$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003496 "cmp{b}\t{$src2, $src1|$src1, $src2}",
Chris Lattnere3486a42010-03-19 00:01:11 +00003497 [(set EFLAGS, (X86cmp GR8:$src1, (loadi8 addr:$src2)))]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00003498def CMP16rm : I<0x3B, MRMSrcMem,
Evan Cheng64d80e32007-07-19 01:14:50 +00003499 (outs), (ins GR16:$src1, i16mem:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003500 "cmp{w}\t{$src2, $src1|$src1, $src2}",
Chris Lattnere3486a42010-03-19 00:01:11 +00003501 [(set EFLAGS, (X86cmp GR16:$src1, (loadi16 addr:$src2)))]>,
3502 OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00003503def CMP32rm : I<0x3B, MRMSrcMem,
Evan Cheng64d80e32007-07-19 01:14:50 +00003504 (outs), (ins GR32:$src1, i32mem:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003505 "cmp{l}\t{$src2, $src1|$src1, $src2}",
Chris Lattnere3486a42010-03-19 00:01:11 +00003506 [(set EFLAGS, (X86cmp GR32:$src1, (loadi32 addr:$src2)))]>;
Daniel Dunbar1e8ee892010-03-09 22:50:40 +00003507
3508// These are alternate spellings for use by the disassembler, we mark them as
3509// code gen only to ensure they aren't matched by the assembler.
3510let isCodeGenOnly = 1 in {
3511 def CMP8rr_alt : I<0x3A, MRMSrcReg, (outs), (ins GR8:$src1, GR8:$src2),
3512 "cmp{b}\t{$src2, $src1|$src1, $src2}", []>;
3513 def CMP16rr_alt : I<0x3B, MRMSrcReg, (outs), (ins GR16:$src1, GR16:$src2),
3514 "cmp{w}\t{$src2, $src1|$src1, $src2}", []>, OpSize;
3515 def CMP32rr_alt : I<0x3B, MRMSrcReg, (outs), (ins GR32:$src1, GR32:$src2),
3516 "cmp{l}\t{$src2, $src1|$src1, $src2}", []>;
3517}
3518
Chris Lattner3a173df2004-10-03 20:35:00 +00003519def CMP8ri : Ii8<0x80, MRM7r,
Evan Cheng64d80e32007-07-19 01:14:50 +00003520 (outs), (ins GR8:$src1, i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003521 "cmp{b}\t{$src2, $src1|$src1, $src2}",
Chris Lattnere3486a42010-03-19 00:01:11 +00003522 [(set EFLAGS, (X86cmp GR8:$src1, imm:$src2))]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00003523def CMP16ri : Ii16<0x81, MRM7r,
Evan Cheng64d80e32007-07-19 01:14:50 +00003524 (outs), (ins GR16:$src1, i16imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003525 "cmp{w}\t{$src2, $src1|$src1, $src2}",
Chris Lattnere3486a42010-03-19 00:01:11 +00003526 [(set EFLAGS, (X86cmp GR16:$src1, imm:$src2))]>, OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00003527def CMP32ri : Ii32<0x81, MRM7r,
Evan Cheng64d80e32007-07-19 01:14:50 +00003528 (outs), (ins GR32:$src1, i32imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003529 "cmp{l}\t{$src2, $src1|$src1, $src2}",
Chris Lattnere3486a42010-03-19 00:01:11 +00003530 [(set EFLAGS, (X86cmp GR32:$src1, imm:$src2))]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00003531def CMP8mi : Ii8 <0x80, MRM7m,
Evan Cheng64d80e32007-07-19 01:14:50 +00003532 (outs), (ins i8mem :$src1, i8imm :$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003533 "cmp{b}\t{$src2, $src1|$src1, $src2}",
Chris Lattnere3486a42010-03-19 00:01:11 +00003534 [(set EFLAGS, (X86cmp (loadi8 addr:$src1), imm:$src2))]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00003535def CMP16mi : Ii16<0x81, MRM7m,
Evan Cheng64d80e32007-07-19 01:14:50 +00003536 (outs), (ins i16mem:$src1, i16imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003537 "cmp{w}\t{$src2, $src1|$src1, $src2}",
Chris Lattnere3486a42010-03-19 00:01:11 +00003538 [(set EFLAGS, (X86cmp (loadi16 addr:$src1), imm:$src2))]>,
3539 OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00003540def CMP32mi : Ii32<0x81, MRM7m,
Evan Cheng64d80e32007-07-19 01:14:50 +00003541 (outs), (ins i32mem:$src1, i32imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003542 "cmp{l}\t{$src2, $src1|$src1, $src2}",
Chris Lattnere3486a42010-03-19 00:01:11 +00003543 [(set EFLAGS, (X86cmp (loadi32 addr:$src1), imm:$src2))]>;
Chris Lattner29b4dd02006-03-23 16:13:50 +00003544def CMP16ri8 : Ii8<0x83, MRM7r,
Evan Cheng64d80e32007-07-19 01:14:50 +00003545 (outs), (ins GR16:$src1, i16i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003546 "cmp{w}\t{$src2, $src1|$src1, $src2}",
Chris Lattnere3486a42010-03-19 00:01:11 +00003547 [(set EFLAGS, (X86cmp GR16:$src1, i16immSExt8:$src2))]>,
3548 OpSize;
Chris Lattner29b4dd02006-03-23 16:13:50 +00003549def CMP16mi8 : Ii8<0x83, MRM7m,
Evan Cheng64d80e32007-07-19 01:14:50 +00003550 (outs), (ins i16mem:$src1, i16i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003551 "cmp{w}\t{$src2, $src1|$src1, $src2}",
Chris Lattnere3486a42010-03-19 00:01:11 +00003552 [(set EFLAGS, (X86cmp (loadi16 addr:$src1),
3553 i16immSExt8:$src2))]>, OpSize;
Chris Lattner29b4dd02006-03-23 16:13:50 +00003554def CMP32mi8 : Ii8<0x83, MRM7m,
Evan Cheng64d80e32007-07-19 01:14:50 +00003555 (outs), (ins i32mem:$src1, i32i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003556 "cmp{l}\t{$src2, $src1|$src1, $src2}",
Chris Lattnere3486a42010-03-19 00:01:11 +00003557 [(set EFLAGS, (X86cmp (loadi32 addr:$src1),
3558 i32immSExt8:$src2))]>;
Chris Lattner29b4dd02006-03-23 16:13:50 +00003559def CMP32ri8 : Ii8<0x83, MRM7r,
Evan Cheng64d80e32007-07-19 01:14:50 +00003560 (outs), (ins GR32:$src1, i32i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003561 "cmp{l}\t{$src2, $src1|$src1, $src2}",
Chris Lattnere3486a42010-03-19 00:01:11 +00003562 [(set EFLAGS, (X86cmp GR32:$src1, i32immSExt8:$src2))]>;
Evan Cheng0488db92007-09-25 01:57:46 +00003563} // Defs = [EFLAGS]
3564
Dan Gohmanc7a37d42008-12-23 22:45:23 +00003565// Bit tests.
Dan Gohmanc7a37d42008-12-23 22:45:23 +00003566// TODO: BTC, BTR, and BTS
3567let Defs = [EFLAGS] in {
Dan Gohman0c89b7e2009-01-13 20:32:45 +00003568def BT16rr : I<0xA3, MRMDestReg, (outs), (ins GR16:$src1, GR16:$src2),
Dan Gohmanc7a37d42008-12-23 22:45:23 +00003569 "bt{w}\t{$src2, $src1|$src1, $src2}",
Chris Lattnere3486a42010-03-19 00:01:11 +00003570 [(set EFLAGS, (X86bt GR16:$src1, GR16:$src2))]>, OpSize, TB;
Dan Gohman0c89b7e2009-01-13 20:32:45 +00003571def BT32rr : I<0xA3, MRMDestReg, (outs), (ins GR32:$src1, GR32:$src2),
Dan Gohmanc7a37d42008-12-23 22:45:23 +00003572 "bt{l}\t{$src2, $src1|$src1, $src2}",
Chris Lattnere3486a42010-03-19 00:01:11 +00003573 [(set EFLAGS, (X86bt GR32:$src1, GR32:$src2))]>, TB;
Dan Gohmanf31408d2009-01-13 23:23:30 +00003574
3575// Unlike with the register+register form, the memory+register form of the
3576// bt instruction does not ignore the high bits of the index. From ISel's
Sean Callanan108934c2009-12-18 00:01:26 +00003577// perspective, this is pretty bizarre. Make these instructions disassembly
3578// only for now.
3579
3580def BT16mr : I<0xA3, MRMDestMem, (outs), (ins i16mem:$src1, GR16:$src2),
3581 "bt{w}\t{$src2, $src1|$src1, $src2}",
Dan Gohmanf31408d2009-01-13 23:23:30 +00003582// [(X86bt (loadi16 addr:$src1), GR16:$src2),
Sean Callanan108934c2009-12-18 00:01:26 +00003583// (implicit EFLAGS)]
3584 []
3585 >, OpSize, TB, Requires<[FastBTMem]>;
3586def BT32mr : I<0xA3, MRMDestMem, (outs), (ins i32mem:$src1, GR32:$src2),
3587 "bt{l}\t{$src2, $src1|$src1, $src2}",
Dan Gohmanf31408d2009-01-13 23:23:30 +00003588// [(X86bt (loadi32 addr:$src1), GR32:$src2),
Sean Callanan108934c2009-12-18 00:01:26 +00003589// (implicit EFLAGS)]
3590 []
3591 >, TB, Requires<[FastBTMem]>;
Dan Gohman4afe15b2009-01-13 20:33:23 +00003592
3593def BT16ri8 : Ii8<0xBA, MRM4r, (outs), (ins GR16:$src1, i16i8imm:$src2),
3594 "bt{w}\t{$src2, $src1|$src1, $src2}",
Chris Lattnere3486a42010-03-19 00:01:11 +00003595 [(set EFLAGS, (X86bt GR16:$src1, i16immSExt8:$src2))]>,
3596 OpSize, TB;
Dan Gohman4afe15b2009-01-13 20:33:23 +00003597def BT32ri8 : Ii8<0xBA, MRM4r, (outs), (ins GR32:$src1, i32i8imm:$src2),
3598 "bt{l}\t{$src2, $src1|$src1, $src2}",
Chris Lattnere3486a42010-03-19 00:01:11 +00003599 [(set EFLAGS, (X86bt GR32:$src1, i32immSExt8:$src2))]>, TB;
Dan Gohman4afe15b2009-01-13 20:33:23 +00003600// Note that these instructions don't need FastBTMem because that
3601// only applies when the other operand is in a register. When it's
3602// an immediate, bt is still fast.
3603def BT16mi8 : Ii8<0xBA, MRM4m, (outs), (ins i16mem:$src1, i16i8imm:$src2),
3604 "bt{w}\t{$src2, $src1|$src1, $src2}",
Chris Lattnere3486a42010-03-19 00:01:11 +00003605 [(set EFLAGS, (X86bt (loadi16 addr:$src1), i16immSExt8:$src2))
3606 ]>, OpSize, TB;
Dan Gohman4afe15b2009-01-13 20:33:23 +00003607def BT32mi8 : Ii8<0xBA, MRM4m, (outs), (ins i32mem:$src1, i32i8imm:$src2),
3608 "bt{l}\t{$src2, $src1|$src1, $src2}",
Chris Lattnere3486a42010-03-19 00:01:11 +00003609 [(set EFLAGS, (X86bt (loadi32 addr:$src1), i32immSExt8:$src2))
3610 ]>, TB;
Sean Callanan108934c2009-12-18 00:01:26 +00003611
3612def BTC16rr : I<0xBB, MRMDestReg, (outs), (ins GR16:$src1, GR16:$src2),
3613 "btc{w}\t{$src2, $src1|$src1, $src2}", []>, OpSize, TB;
3614def BTC32rr : I<0xBB, MRMDestReg, (outs), (ins GR32:$src1, GR32:$src2),
3615 "btc{l}\t{$src2, $src1|$src1, $src2}", []>, TB;
3616def BTC16mr : I<0xBB, MRMDestMem, (outs), (ins i16mem:$src1, GR16:$src2),
3617 "btc{w}\t{$src2, $src1|$src1, $src2}", []>, OpSize, TB;
3618def BTC32mr : I<0xBB, MRMDestMem, (outs), (ins i32mem:$src1, GR32:$src2),
3619 "btc{l}\t{$src2, $src1|$src1, $src2}", []>, TB;
3620def BTC16ri8 : Ii8<0xBA, MRM7r, (outs), (ins GR16:$src1, i16i8imm:$src2),
3621 "btc{w}\t{$src2, $src1|$src1, $src2}", []>, OpSize, TB;
3622def BTC32ri8 : Ii8<0xBA, MRM7r, (outs), (ins GR32:$src1, i32i8imm:$src2),
3623 "btc{l}\t{$src2, $src1|$src1, $src2}", []>, TB;
3624def BTC16mi8 : Ii8<0xBA, MRM7m, (outs), (ins i16mem:$src1, i16i8imm:$src2),
3625 "btc{w}\t{$src2, $src1|$src1, $src2}", []>, OpSize, TB;
3626def BTC32mi8 : Ii8<0xBA, MRM7m, (outs), (ins i32mem:$src1, i32i8imm:$src2),
3627 "btc{l}\t{$src2, $src1|$src1, $src2}", []>, TB;
3628
3629def BTR16rr : I<0xB3, MRMDestReg, (outs), (ins GR16:$src1, GR16:$src2),
3630 "btr{w}\t{$src2, $src1|$src1, $src2}", []>, OpSize, TB;
3631def BTR32rr : I<0xB3, MRMDestReg, (outs), (ins GR32:$src1, GR32:$src2),
3632 "btr{l}\t{$src2, $src1|$src1, $src2}", []>, TB;
3633def BTR16mr : I<0xB3, MRMDestMem, (outs), (ins i16mem:$src1, GR16:$src2),
3634 "btr{w}\t{$src2, $src1|$src1, $src2}", []>, OpSize, TB;
3635def BTR32mr : I<0xB3, MRMDestMem, (outs), (ins i32mem:$src1, GR32:$src2),
3636 "btr{l}\t{$src2, $src1|$src1, $src2}", []>, TB;
3637def BTR16ri8 : Ii8<0xBA, MRM6r, (outs), (ins GR16:$src1, i16i8imm:$src2),
3638 "btr{w}\t{$src2, $src1|$src1, $src2}", []>, OpSize, TB;
3639def BTR32ri8 : Ii8<0xBA, MRM6r, (outs), (ins GR32:$src1, i32i8imm:$src2),
3640 "btr{l}\t{$src2, $src1|$src1, $src2}", []>, TB;
3641def BTR16mi8 : Ii8<0xBA, MRM6m, (outs), (ins i16mem:$src1, i16i8imm:$src2),
3642 "btr{w}\t{$src2, $src1|$src1, $src2}", []>, OpSize, TB;
3643def BTR32mi8 : Ii8<0xBA, MRM6m, (outs), (ins i32mem:$src1, i32i8imm:$src2),
3644 "btr{l}\t{$src2, $src1|$src1, $src2}", []>, TB;
3645
3646def BTS16rr : I<0xAB, MRMDestReg, (outs), (ins GR16:$src1, GR16:$src2),
3647 "bts{w}\t{$src2, $src1|$src1, $src2}", []>, OpSize, TB;
3648def BTS32rr : I<0xAB, MRMDestReg, (outs), (ins GR32:$src1, GR32:$src2),
3649 "bts{l}\t{$src2, $src1|$src1, $src2}", []>, TB;
3650def BTS16mr : I<0xAB, MRMDestMem, (outs), (ins i16mem:$src1, GR16:$src2),
3651 "bts{w}\t{$src2, $src1|$src1, $src2}", []>, OpSize, TB;
3652def BTS32mr : I<0xAB, MRMDestMem, (outs), (ins i32mem:$src1, GR32:$src2),
3653 "bts{l}\t{$src2, $src1|$src1, $src2}", []>, TB;
3654def BTS16ri8 : Ii8<0xBA, MRM5r, (outs), (ins GR16:$src1, i16i8imm:$src2),
3655 "bts{w}\t{$src2, $src1|$src1, $src2}", []>, OpSize, TB;
3656def BTS32ri8 : Ii8<0xBA, MRM5r, (outs), (ins GR32:$src1, i32i8imm:$src2),
3657 "bts{l}\t{$src2, $src1|$src1, $src2}", []>, TB;
3658def BTS16mi8 : Ii8<0xBA, MRM5m, (outs), (ins i16mem:$src1, i16i8imm:$src2),
3659 "bts{w}\t{$src2, $src1|$src1, $src2}", []>, OpSize, TB;
3660def BTS32mi8 : Ii8<0xBA, MRM5m, (outs), (ins i32mem:$src1, i32i8imm:$src2),
3661 "bts{l}\t{$src2, $src1|$src1, $src2}", []>, TB;
Dan Gohmanc7a37d42008-12-23 22:45:23 +00003662} // Defs = [EFLAGS]
3663
Chris Lattner1cca5e32003-08-03 21:54:21 +00003664// Sign/Zero extenders
Dan Gohman11ba3b12008-07-30 18:09:17 +00003665// Use movsbl intead of movsbw; we don't care about the high 16 bits
3666// of the register here. This has a smaller encoding and avoids a
Sean Callanan108934c2009-12-18 00:01:26 +00003667// partial-register update. Actual movsbw included for the disassembler.
3668def MOVSX16rr8W : I<0xBE, MRMSrcReg, (outs GR16:$dst), (ins GR8:$src),
3669 "movs{bw|x}\t{$src, $dst|$dst, $src}", []>, TB, OpSize;
3670def MOVSX16rm8W : I<0xBE, MRMSrcMem, (outs GR16:$dst), (ins i8mem:$src),
3671 "movs{bw|x}\t{$src, $dst|$dst, $src}", []>, TB, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00003672def MOVSX16rr8 : I<0xBE, MRMSrcReg, (outs GR16:$dst), (ins GR8 :$src),
Chris Lattner172862a2009-10-19 19:51:42 +00003673 "", [(set GR16:$dst, (sext GR8:$src))]>, TB;
Evan Cheng64d80e32007-07-19 01:14:50 +00003674def MOVSX16rm8 : I<0xBE, MRMSrcMem, (outs GR16:$dst), (ins i8mem :$src),
Chris Lattner172862a2009-10-19 19:51:42 +00003675 "", [(set GR16:$dst, (sextloadi16i8 addr:$src))]>, TB;
Evan Cheng64d80e32007-07-19 01:14:50 +00003676def MOVSX32rr8 : I<0xBE, MRMSrcReg, (outs GR32:$dst), (ins GR8 :$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003677 "movs{bl|x}\t{$src, $dst|$dst, $src}",
Evan Cheng069287d2006-05-16 07:21:53 +00003678 [(set GR32:$dst, (sext GR8:$src))]>, TB;
Evan Cheng64d80e32007-07-19 01:14:50 +00003679def MOVSX32rm8 : I<0xBE, MRMSrcMem, (outs GR32:$dst), (ins i8mem :$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003680 "movs{bl|x}\t{$src, $dst|$dst, $src}",
Evan Cheng069287d2006-05-16 07:21:53 +00003681 [(set GR32:$dst, (sextloadi32i8 addr:$src))]>, TB;
Evan Cheng64d80e32007-07-19 01:14:50 +00003682def MOVSX32rr16: I<0xBF, MRMSrcReg, (outs GR32:$dst), (ins GR16:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003683 "movs{wl|x}\t{$src, $dst|$dst, $src}",
Evan Cheng069287d2006-05-16 07:21:53 +00003684 [(set GR32:$dst, (sext GR16:$src))]>, TB;
Evan Cheng64d80e32007-07-19 01:14:50 +00003685def MOVSX32rm16: I<0xBF, MRMSrcMem, (outs GR32:$dst), (ins i16mem:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003686 "movs{wl|x}\t{$src, $dst|$dst, $src}",
Evan Cheng069287d2006-05-16 07:21:53 +00003687 [(set GR32:$dst, (sextloadi32i16 addr:$src))]>, TB;
Alkis Evlogimenosa7be9822004-02-17 09:14:23 +00003688
Dan Gohman11ba3b12008-07-30 18:09:17 +00003689// Use movzbl intead of movzbw; we don't care about the high 16 bits
3690// of the register here. This has a smaller encoding and avoids a
Sean Callanan108934c2009-12-18 00:01:26 +00003691// partial-register update. Actual movzbw included for the disassembler.
3692def MOVZX16rr8W : I<0xB6, MRMSrcReg, (outs GR16:$dst), (ins GR8:$src),
3693 "movz{bw|x}\t{$src, $dst|$dst, $src}", []>, TB, OpSize;
3694def MOVZX16rm8W : I<0xB6, MRMSrcMem, (outs GR16:$dst), (ins i8mem:$src),
3695 "movz{bw|x}\t{$src, $dst|$dst, $src}", []>, TB, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00003696def MOVZX16rr8 : I<0xB6, MRMSrcReg, (outs GR16:$dst), (ins GR8 :$src),
Chris Lattner172862a2009-10-19 19:51:42 +00003697 "", [(set GR16:$dst, (zext GR8:$src))]>, TB;
Evan Cheng64d80e32007-07-19 01:14:50 +00003698def MOVZX16rm8 : I<0xB6, MRMSrcMem, (outs GR16:$dst), (ins i8mem :$src),
Chris Lattner172862a2009-10-19 19:51:42 +00003699 "", [(set GR16:$dst, (zextloadi16i8 addr:$src))]>, TB;
Evan Cheng64d80e32007-07-19 01:14:50 +00003700def MOVZX32rr8 : I<0xB6, MRMSrcReg, (outs GR32:$dst), (ins GR8 :$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003701 "movz{bl|x}\t{$src, $dst|$dst, $src}",
Evan Cheng069287d2006-05-16 07:21:53 +00003702 [(set GR32:$dst, (zext GR8:$src))]>, TB;
Evan Cheng64d80e32007-07-19 01:14:50 +00003703def MOVZX32rm8 : I<0xB6, MRMSrcMem, (outs GR32:$dst), (ins i8mem :$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003704 "movz{bl|x}\t{$src, $dst|$dst, $src}",
Evan Cheng069287d2006-05-16 07:21:53 +00003705 [(set GR32:$dst, (zextloadi32i8 addr:$src))]>, TB;
Evan Cheng64d80e32007-07-19 01:14:50 +00003706def MOVZX32rr16: I<0xB7, MRMSrcReg, (outs GR32:$dst), (ins GR16:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003707 "movz{wl|x}\t{$src, $dst|$dst, $src}",
Evan Cheng069287d2006-05-16 07:21:53 +00003708 [(set GR32:$dst, (zext GR16:$src))]>, TB;
Evan Cheng64d80e32007-07-19 01:14:50 +00003709def MOVZX32rm16: I<0xB7, MRMSrcMem, (outs GR32:$dst), (ins i16mem:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003710 "movz{wl|x}\t{$src, $dst|$dst, $src}",
Evan Cheng069287d2006-05-16 07:21:53 +00003711 [(set GR32:$dst, (zextloadi32i16 addr:$src))]>, TB;
Evan Cheng7a7e8372005-12-14 02:22:27 +00003712
Dan Gohmanf451cb82010-02-10 16:03:48 +00003713// These are the same as the regular MOVZX32rr8 and MOVZX32rm8
Dan Gohman21e3dfb2009-04-13 16:09:41 +00003714// except that they use GR32_NOREX for the output operand register class
3715// instead of GR32. This allows them to operate on h registers on x86-64.
3716def MOVZX32_NOREXrr8 : I<0xB6, MRMSrcReg,
3717 (outs GR32_NOREX:$dst), (ins GR8:$src),
3718 "movz{bl|x}\t{$src, $dst|$dst, $src} # NOREX",
3719 []>, TB;
Dan Gohman78e04d42009-04-30 03:11:48 +00003720let mayLoad = 1 in
Dan Gohman21e3dfb2009-04-13 16:09:41 +00003721def MOVZX32_NOREXrm8 : I<0xB6, MRMSrcMem,
3722 (outs GR32_NOREX:$dst), (ins i8mem:$src),
3723 "movz{bl|x}\t{$src, $dst|$dst, $src} # NOREX",
3724 []>, TB;
3725
Chris Lattnerba7e7562008-01-10 07:59:24 +00003726let neverHasSideEffects = 1 in {
3727 let Defs = [AX], Uses = [AL] in
3728 def CBW : I<0x98, RawFrm, (outs), (ins),
3729 "{cbtw|cbw}", []>, OpSize; // AX = signext(AL)
3730 let Defs = [EAX], Uses = [AX] in
3731 def CWDE : I<0x98, RawFrm, (outs), (ins),
3732 "{cwtl|cwde}", []>; // EAX = signext(AX)
Evan Chengf91c1012006-05-31 22:05:11 +00003733
Chris Lattnerba7e7562008-01-10 07:59:24 +00003734 let Defs = [AX,DX], Uses = [AX] in
3735 def CWD : I<0x99, RawFrm, (outs), (ins),
3736 "{cwtd|cwd}", []>, OpSize; // DX:AX = signext(AX)
3737 let Defs = [EAX,EDX], Uses = [EAX] in
3738 def CDQ : I<0x99, RawFrm, (outs), (ins),
3739 "{cltd|cdq}", []>; // EDX:EAX = signext(EAX)
3740}
Evan Cheng747a90d2006-02-21 02:24:38 +00003741
Evan Cheng747a90d2006-02-21 02:24:38 +00003742//===----------------------------------------------------------------------===//
3743// Alias Instructions
3744//===----------------------------------------------------------------------===//
3745
3746// Alias instructions that map movr0 to xor.
3747// FIXME: remove when we can teach regalloc that xor reg, reg is ok.
Chris Lattner35e0e842010-02-05 21:21:06 +00003748// FIXME: Set encoding to pseudo.
Daniel Dunbar7417b762009-08-11 22:17:52 +00003749let Defs = [EFLAGS], isReMaterializable = 1, isAsCheapAsAMove = 1,
3750 isCodeGenOnly = 1 in {
Chris Lattner35e0e842010-02-05 21:21:06 +00003751def MOV8r0 : I<0x30, MRMInitReg, (outs GR8 :$dst), (ins), "",
Evan Cheng069287d2006-05-16 07:21:53 +00003752 [(set GR8:$dst, 0)]>;
Dan Gohmanf1b4d262010-01-12 04:42:54 +00003753
3754// We want to rewrite MOV16r0 in terms of MOV32r0, because it's a smaller
3755// encoding and avoids a partial-register update sometimes, but doing so
3756// at isel time interferes with rematerialization in the current register
3757// allocator. For now, this is rewritten when the instruction is lowered
3758// to an MCInst.
3759def MOV16r0 : I<0x31, MRMInitReg, (outs GR16:$dst), (ins),
3760 "",
3761 [(set GR16:$dst, 0)]>, OpSize;
Chris Lattner6a381822009-12-23 01:30:26 +00003762
Chris Lattner35e0e842010-02-05 21:21:06 +00003763// FIXME: Set encoding to pseudo.
3764def MOV32r0 : I<0x31, MRMInitReg, (outs GR32:$dst), (ins), "",
Chris Lattnerac105c42009-12-23 01:46:40 +00003765 [(set GR32:$dst, 0)]>;
3766}
Chris Lattner6a381822009-12-23 01:30:26 +00003767
Evan Cheng510e4782006-01-09 23:10:28 +00003768//===----------------------------------------------------------------------===//
Lauro Ramos Venanciob3a04172007-04-20 21:38:10 +00003769// Thread Local Storage Instructions
3770//
3771
Rafael Espindola15f1b662009-04-24 12:59:40 +00003772// All calls clobber the non-callee saved registers. ESP is marked as
3773// a use to prevent stack-pointer assignments that appear immediately
3774// before calls from potentially appearing dead.
3775let Defs = [EAX, ECX, EDX, FP0, FP1, FP2, FP3, FP4, FP5, FP6, ST0,
3776 MM0, MM1, MM2, MM3, MM4, MM5, MM6, MM7,
3777 XMM0, XMM1, XMM2, XMM3, XMM4, XMM5, XMM6, XMM7,
3778 XMM8, XMM9, XMM10, XMM11, XMM12, XMM13, XMM14, XMM15, EFLAGS],
Chris Lattner5c0b16d2009-06-20 20:38:48 +00003779 Uses = [ESP] in
3780def TLS_addr32 : I<0, Pseudo, (outs), (ins lea32mem:$sym),
3781 "leal\t$sym, %eax; "
Dan Gohman4d47b9b2009-04-27 15:13:28 +00003782 "call\t___tls_get_addr@PLT",
Chris Lattner5c0b16d2009-06-20 20:38:48 +00003783 [(X86tlsaddr tls32addr:$sym)]>,
Rafael Espindola2ee3db32009-04-17 14:35:58 +00003784 Requires<[In32BitMode]>;
Lauro Ramos Venanciob3a04172007-04-20 21:38:10 +00003785
Daniel Dunbar0c420fc2009-08-11 22:24:40 +00003786let AddedComplexity = 5, isCodeGenOnly = 1 in
Nate Begeman51a04372009-01-26 01:24:32 +00003787def GS_MOV32rm : I<0x8B, MRMSrcMem, (outs GR32:$dst), (ins i32mem:$src),
3788 "movl\t%gs:$src, $dst",
3789 [(set GR32:$dst, (gsload addr:$src))]>, SegGS;
3790
Daniel Dunbar0c420fc2009-08-11 22:24:40 +00003791let AddedComplexity = 5, isCodeGenOnly = 1 in
Chris Lattner1777d0c2009-05-05 18:52:19 +00003792def FS_MOV32rm : I<0x8B, MRMSrcMem, (outs GR32:$dst), (ins i32mem:$src),
3793 "movl\t%fs:$src, $dst",
3794 [(set GR32:$dst, (fsload addr:$src))]>, SegFS;
3795
Lauro Ramos Venanciob3a04172007-04-20 21:38:10 +00003796//===----------------------------------------------------------------------===//
Anton Korobeynikov2365f512007-07-14 14:06:15 +00003797// EH Pseudo Instructions
3798//
3799let isTerminator = 1, isReturn = 1, isBarrier = 1,
Daniel Dunbar1ca3a0b2009-08-27 07:58:05 +00003800 hasCtrlDep = 1, isCodeGenOnly = 1 in {
Evan Cheng64d80e32007-07-19 01:14:50 +00003801def EH_RETURN : I<0xC3, RawFrm, (outs), (ins GR32:$addr),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003802 "ret\t#eh_return, addr: $addr",
Anton Korobeynikov2365f512007-07-14 14:06:15 +00003803 [(X86ehret GR32:$addr)]>;
3804
3805}
3806
3807//===----------------------------------------------------------------------===//
Andrew Lenharthab0b9492008-02-21 06:45:13 +00003808// Atomic support
3809//
Andrew Lenharthea7da502008-03-01 13:37:02 +00003810
Evan Chengbb6939d2008-04-19 01:20:30 +00003811// Atomic swap. These are just normal xchg instructions. But since a memory
3812// operand is referenced, the atomicity is ensured.
Dan Gohman165660e2008-08-06 15:52:50 +00003813let Constraints = "$val = $dst" in {
Sean Callanan108934c2009-12-18 00:01:26 +00003814def XCHG32rm : I<0x87, MRMSrcMem, (outs GR32:$dst),
3815 (ins GR32:$val, i32mem:$ptr),
Evan Chengbb6939d2008-04-19 01:20:30 +00003816 "xchg{l}\t{$val, $ptr|$ptr, $val}",
3817 [(set GR32:$dst, (atomic_swap_32 addr:$ptr, GR32:$val))]>;
Sean Callanan108934c2009-12-18 00:01:26 +00003818def XCHG16rm : I<0x87, MRMSrcMem, (outs GR16:$dst),
3819 (ins GR16:$val, i16mem:$ptr),
Evan Chengbb6939d2008-04-19 01:20:30 +00003820 "xchg{w}\t{$val, $ptr|$ptr, $val}",
3821 [(set GR16:$dst, (atomic_swap_16 addr:$ptr, GR16:$val))]>,
3822 OpSize;
Sean Callanan108934c2009-12-18 00:01:26 +00003823def XCHG8rm : I<0x86, MRMSrcMem, (outs GR8:$dst), (ins GR8:$val, i8mem:$ptr),
Evan Chengbb6939d2008-04-19 01:20:30 +00003824 "xchg{b}\t{$val, $ptr|$ptr, $val}",
3825 [(set GR8:$dst, (atomic_swap_8 addr:$ptr, GR8:$val))]>;
Sean Callanan108934c2009-12-18 00:01:26 +00003826
3827def XCHG32rr : I<0x87, MRMSrcReg, (outs GR32:$dst), (ins GR32:$val, GR32:$src),
3828 "xchg{l}\t{$val, $src|$src, $val}", []>;
3829def XCHG16rr : I<0x87, MRMSrcReg, (outs GR16:$dst), (ins GR16:$val, GR16:$src),
3830 "xchg{w}\t{$val, $src|$src, $val}", []>, OpSize;
3831def XCHG8rr : I<0x86, MRMSrcReg, (outs GR8:$dst), (ins GR8:$val, GR8:$src),
3832 "xchg{b}\t{$val, $src|$src, $val}", []>;
Evan Chengbb6939d2008-04-19 01:20:30 +00003833}
3834
Sean Callanan108934c2009-12-18 00:01:26 +00003835def XCHG16ar : I<0x90, AddRegFrm, (outs), (ins GR16:$src),
3836 "xchg{w}\t{$src, %ax|%ax, $src}", []>, OpSize;
3837def XCHG32ar : I<0x90, AddRegFrm, (outs), (ins GR32:$src),
3838 "xchg{l}\t{$src, %eax|%eax, $src}", []>;
3839
Evan Cheng7e032802008-04-18 20:55:36 +00003840// Atomic compare and swap.
Andrew Lenharth26ed8692008-03-01 21:52:34 +00003841let Defs = [EAX, EFLAGS], Uses = [EAX] in {
Evan Cheng7e032802008-04-18 20:55:36 +00003842def LCMPXCHG32 : I<0xB1, MRMDestMem, (outs), (ins i32mem:$ptr, GR32:$swap),
Dan Gohman4d47b9b2009-04-27 15:13:28 +00003843 "lock\n\t"
3844 "cmpxchg{l}\t{$swap, $ptr|$ptr, $swap}",
Evan Cheng32967d22008-03-04 03:20:06 +00003845 [(X86cas addr:$ptr, GR32:$swap, 4)]>, TB, LOCK;
Andrew Lenharthea7da502008-03-01 13:37:02 +00003846}
Dale Johannesen48c1bc22008-10-02 18:53:47 +00003847let Defs = [EAX, EDX, EFLAGS], Uses = [EAX, EBX, ECX, EDX] in {
Evan Chengb093bd02010-01-08 01:29:19 +00003848def LCMPXCHG8B : I<0xC7, MRM1m, (outs), (ins i64mem:$ptr),
Dan Gohman4d47b9b2009-04-27 15:13:28 +00003849 "lock\n\t"
3850 "cmpxchg8b\t$ptr",
Andrew Lenharthd19189e2008-03-05 01:15:49 +00003851 [(X86cas8 addr:$ptr)]>, TB, LOCK;
3852}
Andrew Lenharth26ed8692008-03-01 21:52:34 +00003853
3854let Defs = [AX, EFLAGS], Uses = [AX] in {
Evan Cheng7e032802008-04-18 20:55:36 +00003855def LCMPXCHG16 : I<0xB1, MRMDestMem, (outs), (ins i16mem:$ptr, GR16:$swap),
Dan Gohman4d47b9b2009-04-27 15:13:28 +00003856 "lock\n\t"
3857 "cmpxchg{w}\t{$swap, $ptr|$ptr, $swap}",
Evan Cheng32967d22008-03-04 03:20:06 +00003858 [(X86cas addr:$ptr, GR16:$swap, 2)]>, TB, OpSize, LOCK;
Andrew Lenharthea7da502008-03-01 13:37:02 +00003859}
Andrew Lenharth26ed8692008-03-01 21:52:34 +00003860let Defs = [AL, EFLAGS], Uses = [AL] in {
Evan Cheng7e032802008-04-18 20:55:36 +00003861def LCMPXCHG8 : I<0xB0, MRMDestMem, (outs), (ins i8mem:$ptr, GR8:$swap),
Dan Gohman4d47b9b2009-04-27 15:13:28 +00003862 "lock\n\t"
3863 "cmpxchg{b}\t{$swap, $ptr|$ptr, $swap}",
Evan Cheng32967d22008-03-04 03:20:06 +00003864 [(X86cas addr:$ptr, GR8:$swap, 1)]>, TB, LOCK;
Andrew Lenharthea7da502008-03-01 13:37:02 +00003865}
3866
Evan Cheng7e032802008-04-18 20:55:36 +00003867// Atomic exchange and add
3868let Constraints = "$val = $dst", Defs = [EFLAGS] in {
Sean Callanan108934c2009-12-18 00:01:26 +00003869def LXADD32 : I<0xC1, MRMSrcMem, (outs GR32:$dst), (ins GR32:$val, i32mem:$ptr),
Dan Gohman4d47b9b2009-04-27 15:13:28 +00003870 "lock\n\t"
3871 "xadd{l}\t{$val, $ptr|$ptr, $val}",
Mon P Wang28873102008-06-25 08:15:39 +00003872 [(set GR32:$dst, (atomic_load_add_32 addr:$ptr, GR32:$val))]>,
Evan Cheng7e032802008-04-18 20:55:36 +00003873 TB, LOCK;
Sean Callanan108934c2009-12-18 00:01:26 +00003874def LXADD16 : I<0xC1, MRMSrcMem, (outs GR16:$dst), (ins GR16:$val, i16mem:$ptr),
Dan Gohman4d47b9b2009-04-27 15:13:28 +00003875 "lock\n\t"
3876 "xadd{w}\t{$val, $ptr|$ptr, $val}",
Mon P Wang28873102008-06-25 08:15:39 +00003877 [(set GR16:$dst, (atomic_load_add_16 addr:$ptr, GR16:$val))]>,
Evan Cheng7e032802008-04-18 20:55:36 +00003878 TB, OpSize, LOCK;
Sean Callanan108934c2009-12-18 00:01:26 +00003879def LXADD8 : I<0xC0, MRMSrcMem, (outs GR8:$dst), (ins GR8:$val, i8mem:$ptr),
Dan Gohman4d47b9b2009-04-27 15:13:28 +00003880 "lock\n\t"
3881 "xadd{b}\t{$val, $ptr|$ptr, $val}",
Mon P Wang28873102008-06-25 08:15:39 +00003882 [(set GR8:$dst, (atomic_load_add_8 addr:$ptr, GR8:$val))]>,
Evan Cheng7e032802008-04-18 20:55:36 +00003883 TB, LOCK;
Andrew Lenharthea7da502008-03-01 13:37:02 +00003884}
3885
Sean Callanan108934c2009-12-18 00:01:26 +00003886def XADD8rr : I<0xC0, MRMDestReg, (outs GR8:$dst), (ins GR8:$src),
3887 "xadd{b}\t{$src, $dst|$dst, $src}", []>, TB;
3888def XADD16rr : I<0xC1, MRMDestReg, (outs GR16:$dst), (ins GR16:$src),
3889 "xadd{w}\t{$src, $dst|$dst, $src}", []>, TB, OpSize;
3890def XADD32rr : I<0xC1, MRMDestReg, (outs GR32:$dst), (ins GR32:$src),
3891 "xadd{l}\t{$src, $dst|$dst, $src}", []>, TB;
3892
3893def XADD8rm : I<0xC0, MRMDestMem, (outs), (ins i8mem:$dst, GR8:$src),
3894 "xadd{b}\t{$src, $dst|$dst, $src}", []>, TB;
3895def XADD16rm : I<0xC1, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src),
3896 "xadd{w}\t{$src, $dst|$dst, $src}", []>, TB, OpSize;
3897def XADD32rm : I<0xC1, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src),
3898 "xadd{l}\t{$src, $dst|$dst, $src}", []>, TB;
3899
3900def CMPXCHG8rr : I<0xB0, MRMDestReg, (outs GR8:$dst), (ins GR8:$src),
3901 "cmpxchg{b}\t{$src, $dst|$dst, $src}", []>, TB;
3902def CMPXCHG16rr : I<0xB1, MRMDestReg, (outs GR16:$dst), (ins GR16:$src),
3903 "cmpxchg{w}\t{$src, $dst|$dst, $src}", []>, TB, OpSize;
3904def CMPXCHG32rr : I<0xB1, MRMDestReg, (outs GR32:$dst), (ins GR32:$src),
3905 "cmpxchg{l}\t{$src, $dst|$dst, $src}", []>, TB;
3906
3907def CMPXCHG8rm : I<0xB0, MRMDestMem, (outs), (ins i8mem:$dst, GR8:$src),
3908 "cmpxchg{b}\t{$src, $dst|$dst, $src}", []>, TB;
3909def CMPXCHG16rm : I<0xB1, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src),
3910 "cmpxchg{w}\t{$src, $dst|$dst, $src}", []>, TB, OpSize;
3911def CMPXCHG32rm : I<0xB1, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src),
3912 "cmpxchg{l}\t{$src, $dst|$dst, $src}", []>, TB;
3913
Evan Chengb093bd02010-01-08 01:29:19 +00003914let Defs = [EAX, EDX, EFLAGS], Uses = [EAX, EBX, ECX, EDX] in
Sean Callanan108934c2009-12-18 00:01:26 +00003915def CMPXCHG8B : I<0xC7, MRM1m, (outs), (ins i64mem:$dst),
3916 "cmpxchg8b\t$dst", []>, TB;
3917
Evan Cheng37b73872009-07-30 08:33:02 +00003918// Optimized codegen when the non-memory output is not used.
3919// FIXME: Use normal add / sub instructions and add lock prefix dynamically.
Dan Gohmanbab42bd2009-10-20 18:14:49 +00003920let Defs = [EFLAGS] in {
Evan Cheng37b73872009-07-30 08:33:02 +00003921def LOCK_ADD8mr : I<0x00, MRMDestMem, (outs), (ins i8mem:$dst, GR8:$src2),
3922 "lock\n\t"
3923 "add{b}\t{$src2, $dst|$dst, $src2}", []>, LOCK;
3924def LOCK_ADD16mr : I<0x01, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
3925 "lock\n\t"
3926 "add{w}\t{$src2, $dst|$dst, $src2}", []>, OpSize, LOCK;
3927def LOCK_ADD32mr : I<0x01, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
3928 "lock\n\t"
3929 "add{l}\t{$src2, $dst|$dst, $src2}", []>, LOCK;
3930def LOCK_ADD8mi : Ii8<0x80, MRM0m, (outs), (ins i8mem :$dst, i8imm :$src2),
3931 "lock\n\t"
3932 "add{b}\t{$src2, $dst|$dst, $src2}", []>, LOCK;
3933def LOCK_ADD16mi : Ii16<0x81, MRM0m, (outs), (ins i16mem:$dst, i16imm:$src2),
3934 "lock\n\t"
3935 "add{w}\t{$src2, $dst|$dst, $src2}", []>, LOCK;
3936def LOCK_ADD32mi : Ii32<0x81, MRM0m, (outs), (ins i32mem:$dst, i32imm:$src2),
3937 "lock\n\t"
3938 "add{l}\t{$src2, $dst|$dst, $src2}", []>, LOCK;
3939def LOCK_ADD16mi8 : Ii8<0x83, MRM0m, (outs), (ins i16mem:$dst, i16i8imm :$src2),
3940 "lock\n\t"
3941 "add{w}\t{$src2, $dst|$dst, $src2}", []>, OpSize, LOCK;
3942def LOCK_ADD32mi8 : Ii8<0x83, MRM0m, (outs), (ins i32mem:$dst, i32i8imm :$src2),
3943 "lock\n\t"
3944 "add{l}\t{$src2, $dst|$dst, $src2}", []>, LOCK;
3945
3946def LOCK_INC8m : I<0xFE, MRM0m, (outs), (ins i8mem :$dst),
3947 "lock\n\t"
3948 "inc{b}\t$dst", []>, LOCK;
3949def LOCK_INC16m : I<0xFF, MRM0m, (outs), (ins i16mem:$dst),
3950 "lock\n\t"
3951 "inc{w}\t$dst", []>, OpSize, LOCK;
3952def LOCK_INC32m : I<0xFF, MRM0m, (outs), (ins i32mem:$dst),
3953 "lock\n\t"
3954 "inc{l}\t$dst", []>, LOCK;
3955
3956def LOCK_SUB8mr : I<0x28, MRMDestMem, (outs), (ins i8mem :$dst, GR8 :$src2),
3957 "lock\n\t"
3958 "sub{b}\t{$src2, $dst|$dst, $src2}", []>, LOCK;
3959def LOCK_SUB16mr : I<0x29, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
3960 "lock\n\t"
3961 "sub{w}\t{$src2, $dst|$dst, $src2}", []>, OpSize, LOCK;
3962def LOCK_SUB32mr : I<0x29, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
3963 "lock\n\t"
3964 "sub{l}\t{$src2, $dst|$dst, $src2}", []>, LOCK;
3965def LOCK_SUB8mi : Ii8<0x80, MRM5m, (outs), (ins i8mem :$dst, i8imm:$src2),
3966 "lock\n\t"
3967 "sub{b}\t{$src2, $dst|$dst, $src2}", []>, LOCK;
3968def LOCK_SUB16mi : Ii16<0x81, MRM5m, (outs), (ins i16mem:$dst, i16imm:$src2),
3969 "lock\n\t"
3970 "sub{w}\t{$src2, $dst|$dst, $src2}", []>, OpSize, LOCK;
3971def LOCK_SUB32mi : Ii32<0x81, MRM5m, (outs), (ins i32mem:$dst, i32imm:$src2),
3972 "lock\n\t"
3973 "sub{l}\t{$src2, $dst|$dst, $src2}", []>, LOCK;
Sean Callanan108934c2009-12-18 00:01:26 +00003974def LOCK_SUB16mi8 : Ii8<0x83, MRM5m, (outs), (ins i16mem:$dst, i16i8imm :$src2),
Evan Cheng37b73872009-07-30 08:33:02 +00003975 "lock\n\t"
3976 "sub{w}\t{$src2, $dst|$dst, $src2}", []>, OpSize, LOCK;
3977def LOCK_SUB32mi8 : Ii8<0x83, MRM5m, (outs), (ins i32mem:$dst, i32i8imm :$src2),
3978 "lock\n\t"
3979 "sub{l}\t{$src2, $dst|$dst, $src2}", []>, LOCK;
3980
3981def LOCK_DEC8m : I<0xFE, MRM1m, (outs), (ins i8mem :$dst),
3982 "lock\n\t"
3983 "dec{b}\t$dst", []>, LOCK;
3984def LOCK_DEC16m : I<0xFF, MRM1m, (outs), (ins i16mem:$dst),
3985 "lock\n\t"
3986 "dec{w}\t$dst", []>, OpSize, LOCK;
3987def LOCK_DEC32m : I<0xFF, MRM1m, (outs), (ins i32mem:$dst),
3988 "lock\n\t"
3989 "dec{l}\t$dst", []>, LOCK;
Dan Gohmanbab42bd2009-10-20 18:14:49 +00003990}
Evan Cheng37b73872009-07-30 08:33:02 +00003991
Mon P Wang28873102008-06-25 08:15:39 +00003992// Atomic exchange, and, or, xor
Mon P Wang63307c32008-05-05 19:05:59 +00003993let Constraints = "$val = $dst", Defs = [EFLAGS],
Dan Gohman533297b2009-10-29 18:10:34 +00003994 usesCustomInserter = 1 in {
Dan Gohman9499b712008-05-12 20:22:45 +00003995def ATOMAND32 : I<0, Pseudo, (outs GR32:$dst),(ins i32mem:$ptr, GR32:$val),
Nick Lewycky6ecf5ce2008-12-07 03:49:52 +00003996 "#ATOMAND32 PSEUDO!",
Dale Johannesene00a8a22008-08-28 02:44:49 +00003997 [(set GR32:$dst, (atomic_load_and_32 addr:$ptr, GR32:$val))]>;
Dan Gohman9499b712008-05-12 20:22:45 +00003998def ATOMOR32 : I<0, Pseudo, (outs GR32:$dst),(ins i32mem:$ptr, GR32:$val),
Nick Lewycky6ecf5ce2008-12-07 03:49:52 +00003999 "#ATOMOR32 PSEUDO!",
Dale Johannesene00a8a22008-08-28 02:44:49 +00004000 [(set GR32:$dst, (atomic_load_or_32 addr:$ptr, GR32:$val))]>;
Dan Gohman9499b712008-05-12 20:22:45 +00004001def ATOMXOR32 : I<0, Pseudo,(outs GR32:$dst),(ins i32mem:$ptr, GR32:$val),
Nick Lewycky6ecf5ce2008-12-07 03:49:52 +00004002 "#ATOMXOR32 PSEUDO!",
Dale Johannesene00a8a22008-08-28 02:44:49 +00004003 [(set GR32:$dst, (atomic_load_xor_32 addr:$ptr, GR32:$val))]>;
Andrew Lenharth507a58a2008-06-14 05:48:15 +00004004def ATOMNAND32 : I<0, Pseudo,(outs GR32:$dst),(ins i32mem:$ptr, GR32:$val),
Nick Lewycky6ecf5ce2008-12-07 03:49:52 +00004005 "#ATOMNAND32 PSEUDO!",
Dale Johannesene00a8a22008-08-28 02:44:49 +00004006 [(set GR32:$dst, (atomic_load_nand_32 addr:$ptr, GR32:$val))]>;
Dan Gohman9499b712008-05-12 20:22:45 +00004007def ATOMMIN32: I<0, Pseudo, (outs GR32:$dst), (ins i32mem:$ptr, GR32:$val),
Nick Lewycky6ecf5ce2008-12-07 03:49:52 +00004008 "#ATOMMIN32 PSEUDO!",
Dale Johannesene00a8a22008-08-28 02:44:49 +00004009 [(set GR32:$dst, (atomic_load_min_32 addr:$ptr, GR32:$val))]>;
Dan Gohman9499b712008-05-12 20:22:45 +00004010def ATOMMAX32: I<0, Pseudo, (outs GR32:$dst),(ins i32mem:$ptr, GR32:$val),
Nick Lewycky6ecf5ce2008-12-07 03:49:52 +00004011 "#ATOMMAX32 PSEUDO!",
Dale Johannesene00a8a22008-08-28 02:44:49 +00004012 [(set GR32:$dst, (atomic_load_max_32 addr:$ptr, GR32:$val))]>;
Dan Gohman9499b712008-05-12 20:22:45 +00004013def ATOMUMIN32: I<0, Pseudo, (outs GR32:$dst),(ins i32mem:$ptr, GR32:$val),
Nick Lewycky6ecf5ce2008-12-07 03:49:52 +00004014 "#ATOMUMIN32 PSEUDO!",
Dale Johannesene00a8a22008-08-28 02:44:49 +00004015 [(set GR32:$dst, (atomic_load_umin_32 addr:$ptr, GR32:$val))]>;
Dan Gohman9499b712008-05-12 20:22:45 +00004016def ATOMUMAX32: I<0, Pseudo, (outs GR32:$dst),(ins i32mem:$ptr, GR32:$val),
Nick Lewycky6ecf5ce2008-12-07 03:49:52 +00004017 "#ATOMUMAX32 PSEUDO!",
Dale Johannesene00a8a22008-08-28 02:44:49 +00004018 [(set GR32:$dst, (atomic_load_umax_32 addr:$ptr, GR32:$val))]>;
Dale Johannesen140be2d2008-08-19 18:47:28 +00004019
4020def ATOMAND16 : I<0, Pseudo, (outs GR16:$dst),(ins i16mem:$ptr, GR16:$val),
Nick Lewycky6ecf5ce2008-12-07 03:49:52 +00004021 "#ATOMAND16 PSEUDO!",
Dale Johannesene00a8a22008-08-28 02:44:49 +00004022 [(set GR16:$dst, (atomic_load_and_16 addr:$ptr, GR16:$val))]>;
Dale Johannesen140be2d2008-08-19 18:47:28 +00004023def ATOMOR16 : I<0, Pseudo, (outs GR16:$dst),(ins i16mem:$ptr, GR16:$val),
Nick Lewycky6ecf5ce2008-12-07 03:49:52 +00004024 "#ATOMOR16 PSEUDO!",
Dale Johannesene00a8a22008-08-28 02:44:49 +00004025 [(set GR16:$dst, (atomic_load_or_16 addr:$ptr, GR16:$val))]>;
Dale Johannesen140be2d2008-08-19 18:47:28 +00004026def ATOMXOR16 : I<0, Pseudo,(outs GR16:$dst),(ins i16mem:$ptr, GR16:$val),
Nick Lewycky6ecf5ce2008-12-07 03:49:52 +00004027 "#ATOMXOR16 PSEUDO!",
Dale Johannesene00a8a22008-08-28 02:44:49 +00004028 [(set GR16:$dst, (atomic_load_xor_16 addr:$ptr, GR16:$val))]>;
Dale Johannesen140be2d2008-08-19 18:47:28 +00004029def ATOMNAND16 : I<0, Pseudo,(outs GR16:$dst),(ins i16mem:$ptr, GR16:$val),
Nick Lewycky6ecf5ce2008-12-07 03:49:52 +00004030 "#ATOMNAND16 PSEUDO!",
Dale Johannesene00a8a22008-08-28 02:44:49 +00004031 [(set GR16:$dst, (atomic_load_nand_16 addr:$ptr, GR16:$val))]>;
Dale Johannesen140be2d2008-08-19 18:47:28 +00004032def ATOMMIN16: I<0, Pseudo, (outs GR16:$dst), (ins i16mem:$ptr, GR16:$val),
Nick Lewycky6ecf5ce2008-12-07 03:49:52 +00004033 "#ATOMMIN16 PSEUDO!",
Dale Johannesene00a8a22008-08-28 02:44:49 +00004034 [(set GR16:$dst, (atomic_load_min_16 addr:$ptr, GR16:$val))]>;
Dale Johannesen140be2d2008-08-19 18:47:28 +00004035def ATOMMAX16: I<0, Pseudo, (outs GR16:$dst),(ins i16mem:$ptr, GR16:$val),
Nick Lewycky6ecf5ce2008-12-07 03:49:52 +00004036 "#ATOMMAX16 PSEUDO!",
Dale Johannesene00a8a22008-08-28 02:44:49 +00004037 [(set GR16:$dst, (atomic_load_max_16 addr:$ptr, GR16:$val))]>;
Dale Johannesen140be2d2008-08-19 18:47:28 +00004038def ATOMUMIN16: I<0, Pseudo, (outs GR16:$dst),(ins i16mem:$ptr, GR16:$val),
Nick Lewycky6ecf5ce2008-12-07 03:49:52 +00004039 "#ATOMUMIN16 PSEUDO!",
Dale Johannesene00a8a22008-08-28 02:44:49 +00004040 [(set GR16:$dst, (atomic_load_umin_16 addr:$ptr, GR16:$val))]>;
Dale Johannesen140be2d2008-08-19 18:47:28 +00004041def ATOMUMAX16: I<0, Pseudo, (outs GR16:$dst),(ins i16mem:$ptr, GR16:$val),
Nick Lewycky6ecf5ce2008-12-07 03:49:52 +00004042 "#ATOMUMAX16 PSEUDO!",
Dale Johannesene00a8a22008-08-28 02:44:49 +00004043 [(set GR16:$dst, (atomic_load_umax_16 addr:$ptr, GR16:$val))]>;
Dale Johannesen140be2d2008-08-19 18:47:28 +00004044
4045def ATOMAND8 : I<0, Pseudo, (outs GR8:$dst),(ins i8mem:$ptr, GR8:$val),
Nick Lewycky6ecf5ce2008-12-07 03:49:52 +00004046 "#ATOMAND8 PSEUDO!",
Dale Johannesene00a8a22008-08-28 02:44:49 +00004047 [(set GR8:$dst, (atomic_load_and_8 addr:$ptr, GR8:$val))]>;
Dale Johannesen140be2d2008-08-19 18:47:28 +00004048def ATOMOR8 : I<0, Pseudo, (outs GR8:$dst),(ins i8mem:$ptr, GR8:$val),
Nick Lewycky6ecf5ce2008-12-07 03:49:52 +00004049 "#ATOMOR8 PSEUDO!",
Dale Johannesene00a8a22008-08-28 02:44:49 +00004050 [(set GR8:$dst, (atomic_load_or_8 addr:$ptr, GR8:$val))]>;
Dale Johannesen140be2d2008-08-19 18:47:28 +00004051def ATOMXOR8 : I<0, Pseudo,(outs GR8:$dst),(ins i8mem:$ptr, GR8:$val),
Nick Lewycky6ecf5ce2008-12-07 03:49:52 +00004052 "#ATOMXOR8 PSEUDO!",
Dale Johannesene00a8a22008-08-28 02:44:49 +00004053 [(set GR8:$dst, (atomic_load_xor_8 addr:$ptr, GR8:$val))]>;
Dale Johannesen140be2d2008-08-19 18:47:28 +00004054def ATOMNAND8 : I<0, Pseudo,(outs GR8:$dst),(ins i8mem:$ptr, GR8:$val),
Nick Lewycky6ecf5ce2008-12-07 03:49:52 +00004055 "#ATOMNAND8 PSEUDO!",
Dale Johannesene00a8a22008-08-28 02:44:49 +00004056 [(set GR8:$dst, (atomic_load_nand_8 addr:$ptr, GR8:$val))]>;
Mon P Wang63307c32008-05-05 19:05:59 +00004057}
4058
Dale Johannesen48c1bc22008-10-02 18:53:47 +00004059let Constraints = "$val1 = $dst1, $val2 = $dst2",
4060 Defs = [EFLAGS, EAX, EBX, ECX, EDX],
4061 Uses = [EAX, EBX, ECX, EDX],
Dale Johannesen1b54c7f2008-10-03 19:41:08 +00004062 mayLoad = 1, mayStore = 1,
Dan Gohman533297b2009-10-29 18:10:34 +00004063 usesCustomInserter = 1 in {
Dale Johannesen48c1bc22008-10-02 18:53:47 +00004064def ATOMAND6432 : I<0, Pseudo, (outs GR32:$dst1, GR32:$dst2),
4065 (ins i64mem:$ptr, GR32:$val1, GR32:$val2),
Nick Lewycky6ecf5ce2008-12-07 03:49:52 +00004066 "#ATOMAND6432 PSEUDO!", []>;
Dale Johannesen48c1bc22008-10-02 18:53:47 +00004067def ATOMOR6432 : I<0, Pseudo, (outs GR32:$dst1, GR32:$dst2),
4068 (ins i64mem:$ptr, GR32:$val1, GR32:$val2),
Nick Lewycky6ecf5ce2008-12-07 03:49:52 +00004069 "#ATOMOR6432 PSEUDO!", []>;
Dale Johannesen48c1bc22008-10-02 18:53:47 +00004070def ATOMXOR6432 : I<0, Pseudo, (outs GR32:$dst1, GR32:$dst2),
4071 (ins i64mem:$ptr, GR32:$val1, GR32:$val2),
Nick Lewycky6ecf5ce2008-12-07 03:49:52 +00004072 "#ATOMXOR6432 PSEUDO!", []>;
Dale Johannesen48c1bc22008-10-02 18:53:47 +00004073def ATOMNAND6432 : I<0, Pseudo, (outs GR32:$dst1, GR32:$dst2),
4074 (ins i64mem:$ptr, GR32:$val1, GR32:$val2),
Nick Lewycky6ecf5ce2008-12-07 03:49:52 +00004075 "#ATOMNAND6432 PSEUDO!", []>;
Dale Johannesen48c1bc22008-10-02 18:53:47 +00004076def ATOMADD6432 : I<0, Pseudo, (outs GR32:$dst1, GR32:$dst2),
4077 (ins i64mem:$ptr, GR32:$val1, GR32:$val2),
Nick Lewycky6ecf5ce2008-12-07 03:49:52 +00004078 "#ATOMADD6432 PSEUDO!", []>;
Dale Johannesen48c1bc22008-10-02 18:53:47 +00004079def ATOMSUB6432 : I<0, Pseudo, (outs GR32:$dst1, GR32:$dst2),
4080 (ins i64mem:$ptr, GR32:$val1, GR32:$val2),
Nick Lewycky6ecf5ce2008-12-07 03:49:52 +00004081 "#ATOMSUB6432 PSEUDO!", []>;
Dale Johannesen880ae362008-10-03 22:25:52 +00004082def ATOMSWAP6432 : I<0, Pseudo, (outs GR32:$dst1, GR32:$dst2),
4083 (ins i64mem:$ptr, GR32:$val1, GR32:$val2),
Nick Lewycky6ecf5ce2008-12-07 03:49:52 +00004084 "#ATOMSWAP6432 PSEUDO!", []>;
Dale Johannesen48c1bc22008-10-02 18:53:47 +00004085}
4086
Sean Callanan358f1ef2009-09-16 21:55:34 +00004087// Segmentation support instructions.
4088
4089def LAR16rm : I<0x02, MRMSrcMem, (outs GR16:$dst), (ins i16mem:$src),
4090 "lar{w}\t{$src, $dst|$dst, $src}", []>, TB, OpSize;
4091def LAR16rr : I<0x02, MRMSrcReg, (outs GR16:$dst), (ins GR16:$src),
4092 "lar{w}\t{$src, $dst|$dst, $src}", []>, TB, OpSize;
4093
4094// i16mem operand in LAR32rm and GR32 operand in LAR32rr is not a typo.
4095def LAR32rm : I<0x02, MRMSrcMem, (outs GR32:$dst), (ins i16mem:$src),
4096 "lar{l}\t{$src, $dst|$dst, $src}", []>, TB;
4097def LAR32rr : I<0x02, MRMSrcReg, (outs GR32:$dst), (ins GR32:$src),
4098 "lar{l}\t{$src, $dst|$dst, $src}", []>, TB;
Sean Callanan108934c2009-12-18 00:01:26 +00004099
4100def LSL16rm : I<0x03, MRMSrcMem, (outs GR16:$dst), (ins i16mem:$src),
4101 "lsl{w}\t{$src, $dst|$dst, $src}", []>, TB, OpSize;
4102def LSL16rr : I<0x03, MRMSrcReg, (outs GR16:$dst), (ins GR16:$src),
4103 "lsl{w}\t{$src, $dst|$dst, $src}", []>, TB, OpSize;
4104def LSL32rm : I<0x03, MRMSrcMem, (outs GR32:$dst), (ins i32mem:$src),
4105 "lsl{l}\t{$src, $dst|$dst, $src}", []>, TB;
4106def LSL32rr : I<0x03, MRMSrcReg, (outs GR32:$dst), (ins GR32:$src),
4107 "lsl{l}\t{$src, $dst|$dst, $src}", []>, TB;
4108
Sean Callanan95a5a7d2010-02-13 01:48:34 +00004109def INVLPG : I<0x01, MRM7m, (outs), (ins i8mem:$addr), "invlpg\t$addr", []>, TB;
Sean Callanan108934c2009-12-18 00:01:26 +00004110
4111def STRr : I<0x00, MRM1r, (outs GR16:$dst), (ins),
4112 "str{w}\t{$dst}", []>, TB;
4113def STRm : I<0x00, MRM1m, (outs i16mem:$dst), (ins),
4114 "str{w}\t{$dst}", []>, TB;
4115def LTRr : I<0x00, MRM3r, (outs), (ins GR16:$src),
4116 "ltr{w}\t{$src}", []>, TB;
4117def LTRm : I<0x00, MRM3m, (outs), (ins i16mem:$src),
4118 "ltr{w}\t{$src}", []>, TB;
4119
4120def PUSHFS16 : I<0xa0, RawFrm, (outs), (ins),
4121 "push{w}\t%fs", []>, OpSize, TB;
4122def PUSHFS32 : I<0xa0, RawFrm, (outs), (ins),
4123 "push{l}\t%fs", []>, TB;
4124def PUSHGS16 : I<0xa8, RawFrm, (outs), (ins),
4125 "push{w}\t%gs", []>, OpSize, TB;
4126def PUSHGS32 : I<0xa8, RawFrm, (outs), (ins),
4127 "push{l}\t%gs", []>, TB;
4128
4129def POPFS16 : I<0xa1, RawFrm, (outs), (ins),
4130 "pop{w}\t%fs", []>, OpSize, TB;
4131def POPFS32 : I<0xa1, RawFrm, (outs), (ins),
4132 "pop{l}\t%fs", []>, TB;
4133def POPGS16 : I<0xa9, RawFrm, (outs), (ins),
4134 "pop{w}\t%gs", []>, OpSize, TB;
4135def POPGS32 : I<0xa9, RawFrm, (outs), (ins),
4136 "pop{l}\t%gs", []>, TB;
4137
4138def LDS16rm : I<0xc5, MRMSrcMem, (outs GR16:$dst), (ins opaque32mem:$src),
4139 "lds{w}\t{$src, $dst|$dst, $src}", []>, OpSize;
4140def LDS32rm : I<0xc5, MRMSrcMem, (outs GR32:$dst), (ins opaque48mem:$src),
4141 "lds{l}\t{$src, $dst|$dst, $src}", []>;
4142def LSS16rm : I<0xb2, MRMSrcMem, (outs GR16:$dst), (ins opaque32mem:$src),
4143 "lss{w}\t{$src, $dst|$dst, $src}", []>, TB, OpSize;
4144def LSS32rm : I<0xb2, MRMSrcMem, (outs GR32:$dst), (ins opaque48mem:$src),
4145 "lss{l}\t{$src, $dst|$dst, $src}", []>, TB;
4146def LES16rm : I<0xc4, MRMSrcMem, (outs GR16:$dst), (ins opaque32mem:$src),
4147 "les{w}\t{$src, $dst|$dst, $src}", []>, OpSize;
4148def LES32rm : I<0xc4, MRMSrcMem, (outs GR32:$dst), (ins opaque48mem:$src),
4149 "les{l}\t{$src, $dst|$dst, $src}", []>;
4150def LFS16rm : I<0xb4, MRMSrcMem, (outs GR16:$dst), (ins opaque32mem:$src),
4151 "lfs{w}\t{$src, $dst|$dst, $src}", []>, TB, OpSize;
4152def LFS32rm : I<0xb4, MRMSrcMem, (outs GR32:$dst), (ins opaque48mem:$src),
4153 "lfs{l}\t{$src, $dst|$dst, $src}", []>, TB;
4154def LGS16rm : I<0xb5, MRMSrcMem, (outs GR16:$dst), (ins opaque32mem:$src),
4155 "lgs{w}\t{$src, $dst|$dst, $src}", []>, TB, OpSize;
4156def LGS32rm : I<0xb5, MRMSrcMem, (outs GR32:$dst), (ins opaque48mem:$src),
4157 "lgs{l}\t{$src, $dst|$dst, $src}", []>, TB;
4158
4159def VERRr : I<0x00, MRM4r, (outs), (ins GR16:$seg),
4160 "verr\t$seg", []>, TB;
4161def VERRm : I<0x00, MRM4m, (outs), (ins i16mem:$seg),
4162 "verr\t$seg", []>, TB;
4163def VERWr : I<0x00, MRM5r, (outs), (ins GR16:$seg),
4164 "verw\t$seg", []>, TB;
4165def VERWm : I<0x00, MRM5m, (outs), (ins i16mem:$seg),
4166 "verw\t$seg", []>, TB;
4167
4168// Descriptor-table support instructions
4169
4170def SGDTm : I<0x01, MRM0m, (outs opaque48mem:$dst), (ins),
4171 "sgdt\t$dst", []>, TB;
4172def SIDTm : I<0x01, MRM1m, (outs opaque48mem:$dst), (ins),
4173 "sidt\t$dst", []>, TB;
4174def SLDT16r : I<0x00, MRM0r, (outs GR16:$dst), (ins),
4175 "sldt{w}\t$dst", []>, TB;
4176def SLDT16m : I<0x00, MRM0m, (outs i16mem:$dst), (ins),
4177 "sldt{w}\t$dst", []>, TB;
4178def LGDTm : I<0x01, MRM2m, (outs), (ins opaque48mem:$src),
4179 "lgdt\t$src", []>, TB;
4180def LIDTm : I<0x01, MRM3m, (outs), (ins opaque48mem:$src),
4181 "lidt\t$src", []>, TB;
4182def LLDT16r : I<0x00, MRM2r, (outs), (ins GR16:$src),
4183 "lldt{w}\t$src", []>, TB;
4184def LLDT16m : I<0x00, MRM2m, (outs), (ins i16mem:$src),
4185 "lldt{w}\t$src", []>, TB;
Sean Callanan9a86f102009-09-16 22:59:28 +00004186
Kevin Enderby12ce0de2010-02-03 21:04:42 +00004187// Lock instruction prefix
4188def LOCK_PREFIX : I<0xF0, RawFrm, (outs), (ins), "lock", []>;
4189
4190// Repeat string operation instruction prefixes
4191// These uses the DF flag in the EFLAGS register to inc or dec ECX
4192let Defs = [ECX], Uses = [ECX,EFLAGS] in {
4193// Repeat (used with INS, OUTS, MOVS, LODS and STOS)
4194def REP_PREFIX : I<0xF3, RawFrm, (outs), (ins), "rep", []>;
4195// Repeat while not equal (used with CMPS and SCAS)
4196def REPNE_PREFIX : I<0xF2, RawFrm, (outs), (ins), "repne", []>;
4197}
4198
4199// Segment override instruction prefixes
4200def CS_PREFIX : I<0x2E, RawFrm, (outs), (ins), "cs", []>;
4201def SS_PREFIX : I<0x36, RawFrm, (outs), (ins), "ss", []>;
4202def DS_PREFIX : I<0x3E, RawFrm, (outs), (ins), "ds", []>;
4203def ES_PREFIX : I<0x26, RawFrm, (outs), (ins), "es", []>;
4204def FS_PREFIX : I<0x64, RawFrm, (outs), (ins), "fs", []>;
4205def GS_PREFIX : I<0x65, RawFrm, (outs), (ins), "gs", []>;
4206
Sean Callanan9a86f102009-09-16 22:59:28 +00004207// String manipulation instructions
4208
4209def LODSB : I<0xAC, RawFrm, (outs), (ins), "lodsb", []>;
4210def LODSW : I<0xAD, RawFrm, (outs), (ins), "lodsw", []>, OpSize;
Sean Callanan108934c2009-12-18 00:01:26 +00004211def LODSD : I<0xAD, RawFrm, (outs), (ins), "lods{l|d}", []>;
4212
4213def OUTSB : I<0x6E, RawFrm, (outs), (ins), "outsb", []>;
4214def OUTSW : I<0x6F, RawFrm, (outs), (ins), "outsw", []>, OpSize;
4215def OUTSD : I<0x6F, RawFrm, (outs), (ins), "outs{l|d}", []>;
4216
4217// CPU flow control instructions
4218
4219def HLT : I<0xF4, RawFrm, (outs), (ins), "hlt", []>;
4220def RSM : I<0xAA, RawFrm, (outs), (ins), "rsm", []>, TB;
4221
4222// FPU control instructions
4223
4224def FNINIT : I<0xE3, RawFrm, (outs), (ins), "fninit", []>, DB;
4225
4226// Flag instructions
4227
4228def CLC : I<0xF8, RawFrm, (outs), (ins), "clc", []>;
4229def STC : I<0xF9, RawFrm, (outs), (ins), "stc", []>;
4230def CLI : I<0xFA, RawFrm, (outs), (ins), "cli", []>;
4231def STI : I<0xFB, RawFrm, (outs), (ins), "sti", []>;
4232def CLD : I<0xFC, RawFrm, (outs), (ins), "cld", []>;
4233def STD : I<0xFD, RawFrm, (outs), (ins), "std", []>;
4234def CMC : I<0xF5, RawFrm, (outs), (ins), "cmc", []>;
4235
4236def CLTS : I<0x06, RawFrm, (outs), (ins), "clts", []>, TB;
4237
4238// Table lookup instructions
4239
4240def XLAT : I<0xD7, RawFrm, (outs), (ins), "xlatb", []>;
4241
4242// Specialized register support
4243
4244def WRMSR : I<0x30, RawFrm, (outs), (ins), "wrmsr", []>, TB;
4245def RDMSR : I<0x32, RawFrm, (outs), (ins), "rdmsr", []>, TB;
4246def RDPMC : I<0x33, RawFrm, (outs), (ins), "rdpmc", []>, TB;
4247
4248def SMSW16r : I<0x01, MRM4r, (outs GR16:$dst), (ins),
4249 "smsw{w}\t$dst", []>, OpSize, TB;
4250def SMSW32r : I<0x01, MRM4r, (outs GR32:$dst), (ins),
4251 "smsw{l}\t$dst", []>, TB;
4252// For memory operands, there is only a 16-bit form
4253def SMSW16m : I<0x01, MRM4m, (outs i16mem:$dst), (ins),
4254 "smsw{w}\t$dst", []>, TB;
4255
4256def LMSW16r : I<0x01, MRM6r, (outs), (ins GR16:$src),
4257 "lmsw{w}\t$src", []>, TB;
4258def LMSW16m : I<0x01, MRM6m, (outs), (ins i16mem:$src),
4259 "lmsw{w}\t$src", []>, TB;
4260
4261def CPUID : I<0xA2, RawFrm, (outs), (ins), "cpuid", []>, TB;
4262
4263// Cache instructions
4264
4265def INVD : I<0x08, RawFrm, (outs), (ins), "invd", []>, TB;
4266def WBINVD : I<0x09, RawFrm, (outs), (ins), "wbinvd", []>, TB;
4267
4268// VMX instructions
4269
4270// 66 0F 38 80
Sean Callanan95a5a7d2010-02-13 01:48:34 +00004271def INVEPT : I<0x80, RawFrm, (outs), (ins), "invept", []>, OpSize, T8;
Sean Callanan108934c2009-12-18 00:01:26 +00004272// 66 0F 38 81
Sean Callanan95a5a7d2010-02-13 01:48:34 +00004273def INVVPID : I<0x81, RawFrm, (outs), (ins), "invvpid", []>, OpSize, T8;
Sean Callanan108934c2009-12-18 00:01:26 +00004274// 0F 01 C1
Chris Lattnerfdfeb692010-02-12 20:49:41 +00004275def VMCALL : I<0x01, MRM_C1, (outs), (ins), "vmcall", []>, TB;
Sean Callanan108934c2009-12-18 00:01:26 +00004276def VMCLEARm : I<0xC7, MRM6m, (outs), (ins i64mem:$vmcs),
4277 "vmclear\t$vmcs", []>, OpSize, TB;
4278// 0F 01 C2
Chris Lattnera599de22010-02-13 00:41:14 +00004279def VMLAUNCH : I<0x01, MRM_C2, (outs), (ins), "vmlaunch", []>, TB;
Sean Callanan108934c2009-12-18 00:01:26 +00004280// 0F 01 C3
Chris Lattnera599de22010-02-13 00:41:14 +00004281def VMRESUME : I<0x01, MRM_C3, (outs), (ins), "vmresume", []>, TB;
Sean Callanan108934c2009-12-18 00:01:26 +00004282def VMPTRLDm : I<0xC7, MRM6m, (outs), (ins i64mem:$vmcs),
4283 "vmptrld\t$vmcs", []>, TB;
4284def VMPTRSTm : I<0xC7, MRM7m, (outs i64mem:$vmcs), (ins),
4285 "vmptrst\t$vmcs", []>, TB;
4286def VMREAD64rm : I<0x78, MRMDestMem, (outs i64mem:$dst), (ins GR64:$src),
4287 "vmread{q}\t{$src, $dst|$dst, $src}", []>, TB;
4288def VMREAD64rr : I<0x78, MRMDestReg, (outs GR64:$dst), (ins GR64:$src),
4289 "vmread{q}\t{$src, $dst|$dst, $src}", []>, TB;
4290def VMREAD32rm : I<0x78, MRMDestMem, (outs i32mem:$dst), (ins GR32:$src),
4291 "vmread{l}\t{$src, $dst|$dst, $src}", []>, TB;
4292def VMREAD32rr : I<0x78, MRMDestReg, (outs GR32:$dst), (ins GR32:$src),
4293 "vmread{l}\t{$src, $dst|$dst, $src}", []>, TB;
4294def VMWRITE64rm : I<0x79, MRMSrcMem, (outs GR64:$dst), (ins i64mem:$src),
4295 "vmwrite{q}\t{$src, $dst|$dst, $src}", []>, TB;
4296def VMWRITE64rr : I<0x79, MRMSrcReg, (outs GR64:$dst), (ins GR64:$src),
4297 "vmwrite{q}\t{$src, $dst|$dst, $src}", []>, TB;
4298def VMWRITE32rm : I<0x79, MRMSrcMem, (outs GR32:$dst), (ins i32mem:$src),
4299 "vmwrite{l}\t{$src, $dst|$dst, $src}", []>, TB;
4300def VMWRITE32rr : I<0x79, MRMSrcReg, (outs GR32:$dst), (ins GR32:$src),
4301 "vmwrite{l}\t{$src, $dst|$dst, $src}", []>, TB;
4302// 0F 01 C4
Chris Lattnera599de22010-02-13 00:41:14 +00004303def VMXOFF : I<0x01, MRM_C4, (outs), (ins), "vmxoff", []>, TB;
Sean Callanan108934c2009-12-18 00:01:26 +00004304def VMXON : I<0xC7, MRM6m, (outs), (ins i64mem:$vmxon),
Kevin Enderby0e822402010-03-08 22:17:26 +00004305 "vmxon\t{$vmxon}", []>, XS;
Sean Callanan358f1ef2009-09-16 21:55:34 +00004306
Andrew Lenharthab0b9492008-02-21 06:45:13 +00004307//===----------------------------------------------------------------------===//
Evan Cheng510e4782006-01-09 23:10:28 +00004308// Non-Instruction Patterns
4309//===----------------------------------------------------------------------===//
4310
Bill Wendling056292f2008-09-16 21:48:12 +00004311// ConstantPool GlobalAddress, ExternalSymbol, and JumpTable
Evan Cheng71fb8342006-02-25 10:02:21 +00004312def : Pat<(i32 (X86Wrapper tconstpool :$dst)), (MOV32ri tconstpool :$dst)>;
Nate Begeman37efe672006-04-22 18:53:45 +00004313def : Pat<(i32 (X86Wrapper tjumptable :$dst)), (MOV32ri tjumptable :$dst)>;
Nate Begeman6795ebb2008-04-12 00:47:57 +00004314def : Pat<(i32 (X86Wrapper tglobaltlsaddr:$dst)),(MOV32ri tglobaltlsaddr:$dst)>;
Evan Cheng71fb8342006-02-25 10:02:21 +00004315def : Pat<(i32 (X86Wrapper tglobaladdr :$dst)), (MOV32ri tglobaladdr :$dst)>;
4316def : Pat<(i32 (X86Wrapper texternalsym:$dst)), (MOV32ri texternalsym:$dst)>;
Dan Gohmanf705adb2009-10-30 01:28:02 +00004317def : Pat<(i32 (X86Wrapper tblockaddress:$dst)), (MOV32ri tblockaddress:$dst)>;
Evan Cheng71fb8342006-02-25 10:02:21 +00004318
Evan Cheng069287d2006-05-16 07:21:53 +00004319def : Pat<(add GR32:$src1, (X86Wrapper tconstpool:$src2)),
4320 (ADD32ri GR32:$src1, tconstpool:$src2)>;
4321def : Pat<(add GR32:$src1, (X86Wrapper tjumptable:$src2)),
4322 (ADD32ri GR32:$src1, tjumptable:$src2)>;
4323def : Pat<(add GR32:$src1, (X86Wrapper tglobaladdr :$src2)),
4324 (ADD32ri GR32:$src1, tglobaladdr:$src2)>;
4325def : Pat<(add GR32:$src1, (X86Wrapper texternalsym:$src2)),
4326 (ADD32ri GR32:$src1, texternalsym:$src2)>;
Dan Gohmanf705adb2009-10-30 01:28:02 +00004327def : Pat<(add GR32:$src1, (X86Wrapper tblockaddress:$src2)),
4328 (ADD32ri GR32:$src1, tblockaddress:$src2)>;
Evan Cheng71fb8342006-02-25 10:02:21 +00004329
Evan Chengfc8feb12006-05-19 07:30:36 +00004330def : Pat<(store (i32 (X86Wrapper tglobaladdr:$src)), addr:$dst),
Evan Cheng71fb8342006-02-25 10:02:21 +00004331 (MOV32mi addr:$dst, tglobaladdr:$src)>;
Evan Chengfc8feb12006-05-19 07:30:36 +00004332def : Pat<(store (i32 (X86Wrapper texternalsym:$src)), addr:$dst),
Evan Cheng71fb8342006-02-25 10:02:21 +00004333 (MOV32mi addr:$dst, texternalsym:$src)>;
Dan Gohmanf705adb2009-10-30 01:28:02 +00004334def : Pat<(store (i32 (X86Wrapper tblockaddress:$src)), addr:$dst),
4335 (MOV32mi addr:$dst, tblockaddress:$src)>;
Evan Cheng71fb8342006-02-25 10:02:21 +00004336
Evan Cheng510e4782006-01-09 23:10:28 +00004337// Calls
Arnold Schwaighoferc85e1712007-10-11 19:40:01 +00004338// tailcall stuff
Evan Chengf48ef032010-03-14 03:48:46 +00004339def : Pat<(X86tcret GR32_TC:$dst, imm:$off),
4340 (TCRETURNri GR32_TC:$dst, imm:$off)>,
4341 Requires<[In32BitMode]>;
4342
Evan Chengcb0f06e2010-03-25 00:10:31 +00004343// FIXME: This is disabled for 32-bit PIC mode because the global base
4344// register which is part of the address mode may be assigned a
4345// callee-saved register.
Evan Chengf48ef032010-03-14 03:48:46 +00004346def : Pat<(X86tcret (load addr:$dst), imm:$off),
4347 (TCRETURNmi addr:$dst, imm:$off)>,
Evan Chengcb0f06e2010-03-25 00:10:31 +00004348 Requires<[In32BitMode, IsNotPIC]>;
Arnold Schwaighoferc85e1712007-10-11 19:40:01 +00004349
4350def : Pat<(X86tcret (i32 tglobaladdr:$dst), imm:$off),
Evan Chengf48ef032010-03-14 03:48:46 +00004351 (TCRETURNdi texternalsym:$dst, imm:$off)>,
4352 Requires<[In32BitMode]>;
Arnold Schwaighoferc85e1712007-10-11 19:40:01 +00004353
4354def : Pat<(X86tcret (i32 texternalsym:$dst), imm:$off),
Evan Chengf48ef032010-03-14 03:48:46 +00004355 (TCRETURNdi texternalsym:$dst, imm:$off)>,
4356 Requires<[In32BitMode]>;
Evan Chengfea89c12006-04-27 08:40:39 +00004357
Dan Gohmancadb2262009-08-02 16:10:01 +00004358// Normal calls, with various flavors of addresses.
Evan Cheng25ab6902006-09-08 06:48:29 +00004359def : Pat<(X86call (i32 tglobaladdr:$dst)),
Evan Cheng510e4782006-01-09 23:10:28 +00004360 (CALLpcrel32 tglobaladdr:$dst)>;
Evan Cheng25ab6902006-09-08 06:48:29 +00004361def : Pat<(X86call (i32 texternalsym:$dst)),
Evan Cheng8700e142006-01-11 06:09:51 +00004362 (CALLpcrel32 texternalsym:$dst)>;
Evan Chengd7f666a2009-05-20 04:53:57 +00004363def : Pat<(X86call (i32 imm:$dst)),
4364 (CALLpcrel32 imm:$dst)>, Requires<[CallImmAddr]>;
Evan Cheng510e4782006-01-09 23:10:28 +00004365
4366// X86 specific add which produces a flag.
Evan Cheng069287d2006-05-16 07:21:53 +00004367def : Pat<(addc GR32:$src1, GR32:$src2),
4368 (ADD32rr GR32:$src1, GR32:$src2)>;
4369def : Pat<(addc GR32:$src1, (load addr:$src2)),
4370 (ADD32rm GR32:$src1, addr:$src2)>;
4371def : Pat<(addc GR32:$src1, imm:$src2),
4372 (ADD32ri GR32:$src1, imm:$src2)>;
4373def : Pat<(addc GR32:$src1, i32immSExt8:$src2),
4374 (ADD32ri8 GR32:$src1, i32immSExt8:$src2)>;
Evan Cheng510e4782006-01-09 23:10:28 +00004375
Evan Cheng069287d2006-05-16 07:21:53 +00004376def : Pat<(subc GR32:$src1, GR32:$src2),
4377 (SUB32rr GR32:$src1, GR32:$src2)>;
4378def : Pat<(subc GR32:$src1, (load addr:$src2)),
4379 (SUB32rm GR32:$src1, addr:$src2)>;
4380def : Pat<(subc GR32:$src1, imm:$src2),
4381 (SUB32ri GR32:$src1, imm:$src2)>;
4382def : Pat<(subc GR32:$src1, i32immSExt8:$src2),
4383 (SUB32ri8 GR32:$src1, i32immSExt8:$src2)>;
Evan Cheng510e4782006-01-09 23:10:28 +00004384
Chris Lattnerffc0b262006-09-07 20:33:45 +00004385// Comparisons.
4386
4387// TEST R,R is smaller than CMP R,0
Chris Lattnere3486a42010-03-19 00:01:11 +00004388def : Pat<(X86cmp GR8:$src1, 0),
Chris Lattnerffc0b262006-09-07 20:33:45 +00004389 (TEST8rr GR8:$src1, GR8:$src1)>;
Chris Lattnere3486a42010-03-19 00:01:11 +00004390def : Pat<(X86cmp GR16:$src1, 0),
Chris Lattnerffc0b262006-09-07 20:33:45 +00004391 (TEST16rr GR16:$src1, GR16:$src1)>;
Chris Lattnere3486a42010-03-19 00:01:11 +00004392def : Pat<(X86cmp GR32:$src1, 0),
Chris Lattnerffc0b262006-09-07 20:33:45 +00004393 (TEST32rr GR32:$src1, GR32:$src1)>;
4394
Dan Gohmanfbb74862009-01-07 01:00:24 +00004395// Conditional moves with folded loads with operands swapped and conditions
4396// inverted.
4397def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_B, EFLAGS),
4398 (CMOVAE16rm GR16:$src2, addr:$src1)>;
4399def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_B, EFLAGS),
4400 (CMOVAE32rm GR32:$src2, addr:$src1)>;
4401def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_AE, EFLAGS),
4402 (CMOVB16rm GR16:$src2, addr:$src1)>;
4403def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_AE, EFLAGS),
4404 (CMOVB32rm GR32:$src2, addr:$src1)>;
4405def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_E, EFLAGS),
4406 (CMOVNE16rm GR16:$src2, addr:$src1)>;
4407def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_E, EFLAGS),
4408 (CMOVNE32rm GR32:$src2, addr:$src1)>;
4409def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_NE, EFLAGS),
4410 (CMOVE16rm GR16:$src2, addr:$src1)>;
4411def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_NE, EFLAGS),
4412 (CMOVE32rm GR32:$src2, addr:$src1)>;
4413def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_BE, EFLAGS),
4414 (CMOVA16rm GR16:$src2, addr:$src1)>;
4415def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_BE, EFLAGS),
4416 (CMOVA32rm GR32:$src2, addr:$src1)>;
4417def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_A, EFLAGS),
4418 (CMOVBE16rm GR16:$src2, addr:$src1)>;
4419def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_A, EFLAGS),
4420 (CMOVBE32rm GR32:$src2, addr:$src1)>;
4421def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_L, EFLAGS),
4422 (CMOVGE16rm GR16:$src2, addr:$src1)>;
4423def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_L, EFLAGS),
4424 (CMOVGE32rm GR32:$src2, addr:$src1)>;
4425def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_GE, EFLAGS),
4426 (CMOVL16rm GR16:$src2, addr:$src1)>;
4427def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_GE, EFLAGS),
4428 (CMOVL32rm GR32:$src2, addr:$src1)>;
4429def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_LE, EFLAGS),
4430 (CMOVG16rm GR16:$src2, addr:$src1)>;
4431def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_LE, EFLAGS),
4432 (CMOVG32rm GR32:$src2, addr:$src1)>;
4433def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_G, EFLAGS),
4434 (CMOVLE16rm GR16:$src2, addr:$src1)>;
4435def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_G, EFLAGS),
4436 (CMOVLE32rm GR32:$src2, addr:$src1)>;
4437def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_P, EFLAGS),
4438 (CMOVNP16rm GR16:$src2, addr:$src1)>;
4439def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_P, EFLAGS),
4440 (CMOVNP32rm GR32:$src2, addr:$src1)>;
4441def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_NP, EFLAGS),
4442 (CMOVP16rm GR16:$src2, addr:$src1)>;
4443def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_NP, EFLAGS),
4444 (CMOVP32rm GR32:$src2, addr:$src1)>;
4445def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_S, EFLAGS),
4446 (CMOVNS16rm GR16:$src2, addr:$src1)>;
4447def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_S, EFLAGS),
4448 (CMOVNS32rm GR32:$src2, addr:$src1)>;
4449def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_NS, EFLAGS),
4450 (CMOVS16rm GR16:$src2, addr:$src1)>;
4451def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_NS, EFLAGS),
4452 (CMOVS32rm GR32:$src2, addr:$src1)>;
4453def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_O, EFLAGS),
4454 (CMOVNO16rm GR16:$src2, addr:$src1)>;
4455def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_O, EFLAGS),
4456 (CMOVNO32rm GR32:$src2, addr:$src1)>;
4457def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_NO, EFLAGS),
4458 (CMOVO16rm GR16:$src2, addr:$src1)>;
4459def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_NO, EFLAGS),
4460 (CMOVO32rm GR32:$src2, addr:$src1)>;
4461
Duncan Sandsf9c98e62008-01-23 20:39:46 +00004462// zextload bool -> zextload byte
Evan Chenge5d93432006-01-17 07:02:46 +00004463def : Pat<(zextloadi8i1 addr:$src), (MOV8rm addr:$src)>;
Evan Cheng510e4782006-01-09 23:10:28 +00004464def : Pat<(zextloadi16i1 addr:$src), (MOVZX16rm8 addr:$src)>;
4465def : Pat<(zextloadi32i1 addr:$src), (MOVZX32rm8 addr:$src)>;
4466
4467// extload bool -> extload byte
Evan Cheng47137242006-05-05 08:23:07 +00004468def : Pat<(extloadi8i1 addr:$src), (MOV8rm addr:$src)>;
Dan Gohmanaf70e5c2009-08-26 14:59:13 +00004469def : Pat<(extloadi16i1 addr:$src), (MOVZX16rm8 addr:$src)>;
Evan Cheng47137242006-05-05 08:23:07 +00004470def : Pat<(extloadi32i1 addr:$src), (MOVZX32rm8 addr:$src)>;
Dan Gohmanaf70e5c2009-08-26 14:59:13 +00004471def : Pat<(extloadi16i8 addr:$src), (MOVZX16rm8 addr:$src)>;
Evan Cheng47137242006-05-05 08:23:07 +00004472def : Pat<(extloadi32i8 addr:$src), (MOVZX32rm8 addr:$src)>;
4473def : Pat<(extloadi32i16 addr:$src), (MOVZX32rm16 addr:$src)>;
Evan Cheng510e4782006-01-09 23:10:28 +00004474
Dan Gohmanaf70e5c2009-08-26 14:59:13 +00004475// anyext. Define these to do an explicit zero-extend to
4476// avoid partial-register updates.
4477def : Pat<(i16 (anyext GR8 :$src)), (MOVZX16rr8 GR8 :$src)>;
4478def : Pat<(i32 (anyext GR8 :$src)), (MOVZX32rr8 GR8 :$src)>;
4479def : Pat<(i32 (anyext GR16:$src)), (MOVZX32rr16 GR16:$src)>;
Evan Cheng510e4782006-01-09 23:10:28 +00004480
Evan Chengcfa260b2006-01-06 02:31:59 +00004481//===----------------------------------------------------------------------===//
4482// Some peepholes
4483//===----------------------------------------------------------------------===//
4484
Dan Gohman63f97202008-10-17 01:33:43 +00004485// Odd encoding trick: -128 fits into an 8-bit immediate field while
4486// +128 doesn't, so in this special case use a sub instead of an add.
4487def : Pat<(add GR16:$src1, 128),
4488 (SUB16ri8 GR16:$src1, -128)>;
4489def : Pat<(store (add (loadi16 addr:$dst), 128), addr:$dst),
4490 (SUB16mi8 addr:$dst, -128)>;
4491def : Pat<(add GR32:$src1, 128),
4492 (SUB32ri8 GR32:$src1, -128)>;
4493def : Pat<(store (add (loadi32 addr:$dst), 128), addr:$dst),
4494 (SUB32mi8 addr:$dst, -128)>;
4495
Dan Gohman11ba3b12008-07-30 18:09:17 +00004496// r & (2^16-1) ==> movz
4497def : Pat<(and GR32:$src1, 0xffff),
Dan Gohman21e3dfb2009-04-13 16:09:41 +00004498 (MOVZX32rr16 (EXTRACT_SUBREG GR32:$src1, x86_subreg_16bit))>;
Dan Gohman8a1510d2008-08-06 18:27:21 +00004499// r & (2^8-1) ==> movz
4500def : Pat<(and GR32:$src1, 0xff),
Anton Korobeynikov3a639a02009-11-02 00:11:39 +00004501 (MOVZX32rr8 (EXTRACT_SUBREG (i32 (COPY_TO_REGCLASS GR32:$src1,
4502 GR32_ABCD)),
Dan Gohman21e3dfb2009-04-13 16:09:41 +00004503 x86_subreg_8bit))>,
Dan Gohman8a1510d2008-08-06 18:27:21 +00004504 Requires<[In32BitMode]>;
4505// r & (2^8-1) ==> movz
4506def : Pat<(and GR16:$src1, 0xff),
Anton Korobeynikov3a639a02009-11-02 00:11:39 +00004507 (MOVZX16rr8 (EXTRACT_SUBREG (i16 (COPY_TO_REGCLASS GR16:$src1,
4508 GR16_ABCD)),
Dan Gohman21e3dfb2009-04-13 16:09:41 +00004509 x86_subreg_8bit))>,
Dan Gohman0bfa1bf2008-08-20 21:27:32 +00004510 Requires<[In32BitMode]>;
4511
4512// sext_inreg patterns
4513def : Pat<(sext_inreg GR32:$src, i16),
Dan Gohman21e3dfb2009-04-13 16:09:41 +00004514 (MOVSX32rr16 (EXTRACT_SUBREG GR32:$src, x86_subreg_16bit))>;
Dan Gohman0bfa1bf2008-08-20 21:27:32 +00004515def : Pat<(sext_inreg GR32:$src, i8),
Anton Korobeynikov3a639a02009-11-02 00:11:39 +00004516 (MOVSX32rr8 (EXTRACT_SUBREG (i32 (COPY_TO_REGCLASS GR32:$src,
4517 GR32_ABCD)),
Dan Gohman21e3dfb2009-04-13 16:09:41 +00004518 x86_subreg_8bit))>,
Dan Gohman0bfa1bf2008-08-20 21:27:32 +00004519 Requires<[In32BitMode]>;
4520def : Pat<(sext_inreg GR16:$src, i8),
Anton Korobeynikov3a639a02009-11-02 00:11:39 +00004521 (MOVSX16rr8 (EXTRACT_SUBREG (i16 (COPY_TO_REGCLASS GR16:$src,
4522 GR16_ABCD)),
Dan Gohman21e3dfb2009-04-13 16:09:41 +00004523 x86_subreg_8bit))>,
Dan Gohman0bfa1bf2008-08-20 21:27:32 +00004524 Requires<[In32BitMode]>;
4525
4526// trunc patterns
4527def : Pat<(i16 (trunc GR32:$src)),
Dan Gohman21e3dfb2009-04-13 16:09:41 +00004528 (EXTRACT_SUBREG GR32:$src, x86_subreg_16bit)>;
Dan Gohman0bfa1bf2008-08-20 21:27:32 +00004529def : Pat<(i8 (trunc GR32:$src)),
Anton Korobeynikov3a639a02009-11-02 00:11:39 +00004530 (EXTRACT_SUBREG (i32 (COPY_TO_REGCLASS GR32:$src, GR32_ABCD)),
Dan Gohman21e3dfb2009-04-13 16:09:41 +00004531 x86_subreg_8bit)>,
Dan Gohman0bfa1bf2008-08-20 21:27:32 +00004532 Requires<[In32BitMode]>;
4533def : Pat<(i8 (trunc GR16:$src)),
Anton Korobeynikov3a639a02009-11-02 00:11:39 +00004534 (EXTRACT_SUBREG (i16 (COPY_TO_REGCLASS GR16:$src, GR16_ABCD)),
Dan Gohman21e3dfb2009-04-13 16:09:41 +00004535 x86_subreg_8bit)>,
4536 Requires<[In32BitMode]>;
4537
4538// h-register tricks
4539def : Pat<(i8 (trunc (srl_su GR16:$src, (i8 8)))),
Anton Korobeynikov3a639a02009-11-02 00:11:39 +00004540 (EXTRACT_SUBREG (i32 (COPY_TO_REGCLASS GR16:$src, GR16_ABCD)),
Dan Gohman21e3dfb2009-04-13 16:09:41 +00004541 x86_subreg_8bit_hi)>,
4542 Requires<[In32BitMode]>;
4543def : Pat<(i8 (trunc (srl_su GR32:$src, (i8 8)))),
Anton Korobeynikov3a639a02009-11-02 00:11:39 +00004544 (EXTRACT_SUBREG (i16 (COPY_TO_REGCLASS GR32:$src, GR32_ABCD)),
Dan Gohman21e3dfb2009-04-13 16:09:41 +00004545 x86_subreg_8bit_hi)>,
4546 Requires<[In32BitMode]>;
Dan Gohman7e0d64a2010-01-11 17:21:05 +00004547def : Pat<(srl GR16:$src, (i8 8)),
Dan Gohman21e3dfb2009-04-13 16:09:41 +00004548 (EXTRACT_SUBREG
4549 (MOVZX32rr8
Anton Korobeynikov3a639a02009-11-02 00:11:39 +00004550 (EXTRACT_SUBREG (i16 (COPY_TO_REGCLASS GR16:$src, GR16_ABCD)),
Dan Gohman21e3dfb2009-04-13 16:09:41 +00004551 x86_subreg_8bit_hi)),
4552 x86_subreg_16bit)>,
4553 Requires<[In32BitMode]>;
Evan Chengcb219f02009-05-29 01:44:43 +00004554def : Pat<(i32 (zext (srl_su GR16:$src, (i8 8)))),
Sean Callanan108934c2009-12-18 00:01:26 +00004555 (MOVZX32rr8 (EXTRACT_SUBREG (i16 (COPY_TO_REGCLASS GR16:$src,
4556 GR16_ABCD)),
Evan Chengcb219f02009-05-29 01:44:43 +00004557 x86_subreg_8bit_hi))>,
4558 Requires<[In32BitMode]>;
Dan Gohmanaf70e5c2009-08-26 14:59:13 +00004559def : Pat<(i32 (anyext (srl_su GR16:$src, (i8 8)))),
Sean Callanan108934c2009-12-18 00:01:26 +00004560 (MOVZX32rr8 (EXTRACT_SUBREG (i16 (COPY_TO_REGCLASS GR16:$src,
4561 GR16_ABCD)),
Dan Gohmanaf70e5c2009-08-26 14:59:13 +00004562 x86_subreg_8bit_hi))>,
4563 Requires<[In32BitMode]>;
Dan Gohman21e3dfb2009-04-13 16:09:41 +00004564def : Pat<(and (srl_su GR32:$src, (i8 8)), (i32 255)),
Sean Callanan108934c2009-12-18 00:01:26 +00004565 (MOVZX32rr8 (EXTRACT_SUBREG (i32 (COPY_TO_REGCLASS GR32:$src,
4566 GR32_ABCD)),
Dan Gohman21e3dfb2009-04-13 16:09:41 +00004567 x86_subreg_8bit_hi))>,
Dan Gohman8a1510d2008-08-06 18:27:21 +00004568 Requires<[In32BitMode]>;
Dan Gohman11ba3b12008-07-30 18:09:17 +00004569
Evan Chengcfa260b2006-01-06 02:31:59 +00004570// (shl x, 1) ==> (add x, x)
Evan Cheng069287d2006-05-16 07:21:53 +00004571def : Pat<(shl GR8 :$src1, (i8 1)), (ADD8rr GR8 :$src1, GR8 :$src1)>;
4572def : Pat<(shl GR16:$src1, (i8 1)), (ADD16rr GR16:$src1, GR16:$src1)>;
4573def : Pat<(shl GR32:$src1, (i8 1)), (ADD32rr GR32:$src1, GR32:$src1)>;
Evan Cheng68b951a2006-01-19 01:56:29 +00004574
Evan Chengeb9f8922008-08-30 02:03:58 +00004575// (shl x (and y, 31)) ==> (shl x, y)
Chris Lattner6d9f86b2010-02-23 06:54:29 +00004576def : Pat<(shl GR8:$src1, (and CL, 31)),
Evan Chengeb9f8922008-08-30 02:03:58 +00004577 (SHL8rCL GR8:$src1)>;
Chris Lattner6d9f86b2010-02-23 06:54:29 +00004578def : Pat<(shl GR16:$src1, (and CL, 31)),
Evan Chengeb9f8922008-08-30 02:03:58 +00004579 (SHL16rCL GR16:$src1)>;
Chris Lattner6d9f86b2010-02-23 06:54:29 +00004580def : Pat<(shl GR32:$src1, (and CL, 31)),
Evan Chengeb9f8922008-08-30 02:03:58 +00004581 (SHL32rCL GR32:$src1)>;
Chris Lattner6d9f86b2010-02-23 06:54:29 +00004582def : Pat<(store (shl (loadi8 addr:$dst), (and CL, 31)), addr:$dst),
Evan Chengeb9f8922008-08-30 02:03:58 +00004583 (SHL8mCL addr:$dst)>;
Chris Lattner6d9f86b2010-02-23 06:54:29 +00004584def : Pat<(store (shl (loadi16 addr:$dst), (and CL, 31)), addr:$dst),
Evan Chengeb9f8922008-08-30 02:03:58 +00004585 (SHL16mCL addr:$dst)>;
Chris Lattner6d9f86b2010-02-23 06:54:29 +00004586def : Pat<(store (shl (loadi32 addr:$dst), (and CL, 31)), addr:$dst),
Evan Chengeb9f8922008-08-30 02:03:58 +00004587 (SHL32mCL addr:$dst)>;
4588
Chris Lattner6d9f86b2010-02-23 06:54:29 +00004589def : Pat<(srl GR8:$src1, (and CL, 31)),
Evan Chengeb9f8922008-08-30 02:03:58 +00004590 (SHR8rCL GR8:$src1)>;
Chris Lattner6d9f86b2010-02-23 06:54:29 +00004591def : Pat<(srl GR16:$src1, (and CL, 31)),
Evan Chengeb9f8922008-08-30 02:03:58 +00004592 (SHR16rCL GR16:$src1)>;
Chris Lattner6d9f86b2010-02-23 06:54:29 +00004593def : Pat<(srl GR32:$src1, (and CL, 31)),
Evan Chengeb9f8922008-08-30 02:03:58 +00004594 (SHR32rCL GR32:$src1)>;
Chris Lattner6d9f86b2010-02-23 06:54:29 +00004595def : Pat<(store (srl (loadi8 addr:$dst), (and CL, 31)), addr:$dst),
Evan Chengeb9f8922008-08-30 02:03:58 +00004596 (SHR8mCL addr:$dst)>;
Chris Lattner6d9f86b2010-02-23 06:54:29 +00004597def : Pat<(store (srl (loadi16 addr:$dst), (and CL, 31)), addr:$dst),
Evan Chengeb9f8922008-08-30 02:03:58 +00004598 (SHR16mCL addr:$dst)>;
Chris Lattner6d9f86b2010-02-23 06:54:29 +00004599def : Pat<(store (srl (loadi32 addr:$dst), (and CL, 31)), addr:$dst),
Evan Chengeb9f8922008-08-30 02:03:58 +00004600 (SHR32mCL addr:$dst)>;
4601
Chris Lattner6d9f86b2010-02-23 06:54:29 +00004602def : Pat<(sra GR8:$src1, (and CL, 31)),
Evan Chengeb9f8922008-08-30 02:03:58 +00004603 (SAR8rCL GR8:$src1)>;
Chris Lattner6d9f86b2010-02-23 06:54:29 +00004604def : Pat<(sra GR16:$src1, (and CL, 31)),
Evan Chengeb9f8922008-08-30 02:03:58 +00004605 (SAR16rCL GR16:$src1)>;
Chris Lattner6d9f86b2010-02-23 06:54:29 +00004606def : Pat<(sra GR32:$src1, (and CL, 31)),
Evan Chengeb9f8922008-08-30 02:03:58 +00004607 (SAR32rCL GR32:$src1)>;
Chris Lattner6d9f86b2010-02-23 06:54:29 +00004608def : Pat<(store (sra (loadi8 addr:$dst), (and CL, 31)), addr:$dst),
Evan Chengeb9f8922008-08-30 02:03:58 +00004609 (SAR8mCL addr:$dst)>;
Chris Lattner6d9f86b2010-02-23 06:54:29 +00004610def : Pat<(store (sra (loadi16 addr:$dst), (and CL, 31)), addr:$dst),
Evan Chengeb9f8922008-08-30 02:03:58 +00004611 (SAR16mCL addr:$dst)>;
Chris Lattner6d9f86b2010-02-23 06:54:29 +00004612def : Pat<(store (sra (loadi32 addr:$dst), (and CL, 31)), addr:$dst),
Evan Chengeb9f8922008-08-30 02:03:58 +00004613 (SAR32mCL addr:$dst)>;
4614
Evan Cheng956044c2006-01-19 23:26:24 +00004615// (or (x >> c) | (y << (32 - c))) ==> (shrd32 x, y, c)
Evan Cheng069287d2006-05-16 07:21:53 +00004616def : Pat<(or (srl GR32:$src1, CL:$amt),
4617 (shl GR32:$src2, (sub 32, CL:$amt))),
4618 (SHRD32rrCL GR32:$src1, GR32:$src2)>;
Evan Cheng68b951a2006-01-19 01:56:29 +00004619
Evan Cheng21d54432006-01-20 01:13:30 +00004620def : Pat<(store (or (srl (loadi32 addr:$dst), CL:$amt),
Evan Cheng069287d2006-05-16 07:21:53 +00004621 (shl GR32:$src2, (sub 32, CL:$amt))), addr:$dst),
4622 (SHRD32mrCL addr:$dst, GR32:$src2)>;
Evan Cheng21d54432006-01-20 01:13:30 +00004623
Dan Gohman74feef22008-10-17 01:23:35 +00004624def : Pat<(or (srl GR32:$src1, (i8 (trunc ECX:$amt))),
4625 (shl GR32:$src2, (i8 (trunc (sub 32, ECX:$amt))))),
4626 (SHRD32rrCL GR32:$src1, GR32:$src2)>;
4627
4628def : Pat<(store (or (srl (loadi32 addr:$dst), (i8 (trunc ECX:$amt))),
4629 (shl GR32:$src2, (i8 (trunc (sub 32, ECX:$amt))))),
4630 addr:$dst),
4631 (SHRD32mrCL addr:$dst, GR32:$src2)>;
4632
Chris Lattner6d9f86b2010-02-23 06:54:29 +00004633def : Pat<(shrd GR32:$src1, (i8 imm:$amt1), GR32:$src2, (i8 imm/*:$amt2*/)),
Dan Gohman74feef22008-10-17 01:23:35 +00004634 (SHRD32rri8 GR32:$src1, GR32:$src2, (i8 imm:$amt1))>;
4635
4636def : Pat<(store (shrd (loadi32 addr:$dst), (i8 imm:$amt1),
Chris Lattner6d9f86b2010-02-23 06:54:29 +00004637 GR32:$src2, (i8 imm/*:$amt2*/)), addr:$dst),
Dan Gohman74feef22008-10-17 01:23:35 +00004638 (SHRD32mri8 addr:$dst, GR32:$src2, (i8 imm:$amt1))>;
4639
Evan Cheng956044c2006-01-19 23:26:24 +00004640// (or (x << c) | (y >> (32 - c))) ==> (shld32 x, y, c)
Evan Cheng069287d2006-05-16 07:21:53 +00004641def : Pat<(or (shl GR32:$src1, CL:$amt),
4642 (srl GR32:$src2, (sub 32, CL:$amt))),
4643 (SHLD32rrCL GR32:$src1, GR32:$src2)>;
Evan Cheng956044c2006-01-19 23:26:24 +00004644
Evan Cheng21d54432006-01-20 01:13:30 +00004645def : Pat<(store (or (shl (loadi32 addr:$dst), CL:$amt),
Evan Cheng069287d2006-05-16 07:21:53 +00004646 (srl GR32:$src2, (sub 32, CL:$amt))), addr:$dst),
4647 (SHLD32mrCL addr:$dst, GR32:$src2)>;
Evan Cheng21d54432006-01-20 01:13:30 +00004648
Dan Gohman74feef22008-10-17 01:23:35 +00004649def : Pat<(or (shl GR32:$src1, (i8 (trunc ECX:$amt))),
4650 (srl GR32:$src2, (i8 (trunc (sub 32, ECX:$amt))))),
4651 (SHLD32rrCL GR32:$src1, GR32:$src2)>;
4652
4653def : Pat<(store (or (shl (loadi32 addr:$dst), (i8 (trunc ECX:$amt))),
4654 (srl GR32:$src2, (i8 (trunc (sub 32, ECX:$amt))))),
4655 addr:$dst),
4656 (SHLD32mrCL addr:$dst, GR32:$src2)>;
4657
Chris Lattner6d9f86b2010-02-23 06:54:29 +00004658def : Pat<(shld GR32:$src1, (i8 imm:$amt1), GR32:$src2, (i8 imm/*:$amt2*/)),
Dan Gohman74feef22008-10-17 01:23:35 +00004659 (SHLD32rri8 GR32:$src1, GR32:$src2, (i8 imm:$amt1))>;
4660
4661def : Pat<(store (shld (loadi32 addr:$dst), (i8 imm:$amt1),
Chris Lattner6d9f86b2010-02-23 06:54:29 +00004662 GR32:$src2, (i8 imm/*:$amt2*/)), addr:$dst),
Dan Gohman74feef22008-10-17 01:23:35 +00004663 (SHLD32mri8 addr:$dst, GR32:$src2, (i8 imm:$amt1))>;
4664
Evan Cheng956044c2006-01-19 23:26:24 +00004665// (or (x >> c) | (y << (16 - c))) ==> (shrd16 x, y, c)
Evan Cheng069287d2006-05-16 07:21:53 +00004666def : Pat<(or (srl GR16:$src1, CL:$amt),
4667 (shl GR16:$src2, (sub 16, CL:$amt))),
4668 (SHRD16rrCL GR16:$src1, GR16:$src2)>;
Evan Cheng956044c2006-01-19 23:26:24 +00004669
Evan Cheng21d54432006-01-20 01:13:30 +00004670def : Pat<(store (or (srl (loadi16 addr:$dst), CL:$amt),
Evan Cheng069287d2006-05-16 07:21:53 +00004671 (shl GR16:$src2, (sub 16, CL:$amt))), addr:$dst),
4672 (SHRD16mrCL addr:$dst, GR16:$src2)>;
Evan Cheng21d54432006-01-20 01:13:30 +00004673
Dan Gohman74feef22008-10-17 01:23:35 +00004674def : Pat<(or (srl GR16:$src1, (i8 (trunc CX:$amt))),
4675 (shl GR16:$src2, (i8 (trunc (sub 16, CX:$amt))))),
4676 (SHRD16rrCL GR16:$src1, GR16:$src2)>;
4677
4678def : Pat<(store (or (srl (loadi16 addr:$dst), (i8 (trunc CX:$amt))),
4679 (shl GR16:$src2, (i8 (trunc (sub 16, CX:$amt))))),
4680 addr:$dst),
4681 (SHRD16mrCL addr:$dst, GR16:$src2)>;
4682
Chris Lattner6d9f86b2010-02-23 06:54:29 +00004683def : Pat<(shrd GR16:$src1, (i8 imm:$amt1), GR16:$src2, (i8 imm/*:$amt2*/)),
Dan Gohman74feef22008-10-17 01:23:35 +00004684 (SHRD16rri8 GR16:$src1, GR16:$src2, (i8 imm:$amt1))>;
4685
4686def : Pat<(store (shrd (loadi16 addr:$dst), (i8 imm:$amt1),
Chris Lattner6d9f86b2010-02-23 06:54:29 +00004687 GR16:$src2, (i8 imm/*:$amt2*/)), addr:$dst),
Dan Gohman74feef22008-10-17 01:23:35 +00004688 (SHRD16mri8 addr:$dst, GR16:$src2, (i8 imm:$amt1))>;
4689
Evan Cheng956044c2006-01-19 23:26:24 +00004690// (or (x << c) | (y >> (16 - c))) ==> (shld16 x, y, c)
Evan Cheng069287d2006-05-16 07:21:53 +00004691def : Pat<(or (shl GR16:$src1, CL:$amt),
4692 (srl GR16:$src2, (sub 16, CL:$amt))),
4693 (SHLD16rrCL GR16:$src1, GR16:$src2)>;
Evan Cheng21d54432006-01-20 01:13:30 +00004694
4695def : Pat<(store (or (shl (loadi16 addr:$dst), CL:$amt),
Evan Cheng069287d2006-05-16 07:21:53 +00004696 (srl GR16:$src2, (sub 16, CL:$amt))), addr:$dst),
4697 (SHLD16mrCL addr:$dst, GR16:$src2)>;
Evan Cheng4e4c71e2006-02-21 20:00:20 +00004698
Dan Gohman74feef22008-10-17 01:23:35 +00004699def : Pat<(or (shl GR16:$src1, (i8 (trunc CX:$amt))),
4700 (srl GR16:$src2, (i8 (trunc (sub 16, CX:$amt))))),
4701 (SHLD16rrCL GR16:$src1, GR16:$src2)>;
4702
4703def : Pat<(store (or (shl (loadi16 addr:$dst), (i8 (trunc CX:$amt))),
4704 (srl GR16:$src2, (i8 (trunc (sub 16, CX:$amt))))),
4705 addr:$dst),
4706 (SHLD16mrCL addr:$dst, GR16:$src2)>;
4707
Chris Lattner6d9f86b2010-02-23 06:54:29 +00004708def : Pat<(shld GR16:$src1, (i8 imm:$amt1), GR16:$src2, (i8 imm/*:$amt2*/)),
Dan Gohman74feef22008-10-17 01:23:35 +00004709 (SHLD16rri8 GR16:$src1, GR16:$src2, (i8 imm:$amt1))>;
4710
4711def : Pat<(store (shld (loadi16 addr:$dst), (i8 imm:$amt1),
Chris Lattner6d9f86b2010-02-23 06:54:29 +00004712 GR16:$src2, (i8 imm/*:$amt2*/)), addr:$dst),
Dan Gohman74feef22008-10-17 01:23:35 +00004713 (SHLD16mri8 addr:$dst, GR16:$src2, (i8 imm:$amt1))>;
4714
Evan Cheng2e489c42009-12-16 00:53:11 +00004715// (anyext (setcc_carry)) -> (setcc_carry)
4716def : Pat<(i16 (anyext (i8 (X86setcc_c X86_COND_B, EFLAGS)))),
Evan Chengad9c0a32009-12-15 00:53:42 +00004717 (SETB_C16r)>;
Evan Cheng2e489c42009-12-16 00:53:11 +00004718def : Pat<(i32 (anyext (i8 (X86setcc_c X86_COND_B, EFLAGS)))),
Evan Chengad9c0a32009-12-15 00:53:42 +00004719 (SETB_C32r)>;
Evan Chenge5b51ac2010-04-17 06:13:15 +00004720def : Pat<(i32 (anyext (i16 (X86setcc_c X86_COND_B, EFLAGS)))),
4721 (SETB_C32r)>;
Evan Chengad9c0a32009-12-15 00:53:42 +00004722
Evan Cheng199c4242010-01-11 22:03:29 +00004723// (or x1, x2) -> (add x1, x2) if two operands are known not to share bits.
Evan Cheng3bda2012010-01-12 18:31:19 +00004724let AddedComplexity = 5 in { // Try this before the selecting to OR
Chris Lattnera0f70172010-03-24 00:15:23 +00004725def : Pat<(or_is_add GR16:$src1, imm:$src2),
Evan Cheng4b0345b2010-01-11 17:03:47 +00004726 (ADD16ri GR16:$src1, imm:$src2)>;
Chris Lattnera0f70172010-03-24 00:15:23 +00004727def : Pat<(or_is_add GR32:$src1, imm:$src2),
Evan Cheng4b0345b2010-01-11 17:03:47 +00004728 (ADD32ri GR32:$src1, imm:$src2)>;
Chris Lattnera0f70172010-03-24 00:15:23 +00004729def : Pat<(or_is_add GR16:$src1, i16immSExt8:$src2),
Evan Cheng4b0345b2010-01-11 17:03:47 +00004730 (ADD16ri8 GR16:$src1, i16immSExt8:$src2)>;
Chris Lattnera0f70172010-03-24 00:15:23 +00004731def : Pat<(or_is_add GR32:$src1, i32immSExt8:$src2),
Evan Cheng4b0345b2010-01-11 17:03:47 +00004732 (ADD32ri8 GR32:$src1, i32immSExt8:$src2)>;
Chris Lattnera0f70172010-03-24 00:15:23 +00004733def : Pat<(or_is_add GR16:$src1, GR16:$src2),
Evan Cheng199c4242010-01-11 22:03:29 +00004734 (ADD16rr GR16:$src1, GR16:$src2)>;
Chris Lattnera0f70172010-03-24 00:15:23 +00004735def : Pat<(or_is_add GR32:$src1, GR32:$src2),
Evan Cheng199c4242010-01-11 22:03:29 +00004736 (ADD32rr GR32:$src1, GR32:$src2)>;
Evan Cheng3bda2012010-01-12 18:31:19 +00004737} // AddedComplexity
Evan Cheng4b0345b2010-01-11 17:03:47 +00004738
Evan Cheng4e4c71e2006-02-21 20:00:20 +00004739//===----------------------------------------------------------------------===//
Dan Gohman076aee32009-03-04 19:44:21 +00004740// EFLAGS-defining Patterns
Bill Wendlingd350e022008-12-12 21:15:41 +00004741//===----------------------------------------------------------------------===//
4742
Chris Lattnerec856802010-03-27 00:45:04 +00004743// add reg, reg
4744def : Pat<(add GR8 :$src1, GR8 :$src2), (ADD8rr GR8 :$src1, GR8 :$src2)>;
4745def : Pat<(add GR16:$src1, GR16:$src2), (ADD16rr GR16:$src1, GR16:$src2)>;
4746def : Pat<(add GR32:$src1, GR32:$src2), (ADD32rr GR32:$src1, GR32:$src2)>;
Bill Wendlingd350e022008-12-12 21:15:41 +00004747
Chris Lattnerec856802010-03-27 00:45:04 +00004748// add reg, mem
4749def : Pat<(add GR8:$src1, (loadi8 addr:$src2)),
Bill Wendlingd350e022008-12-12 21:15:41 +00004750 (ADD8rm GR8:$src1, addr:$src2)>;
Chris Lattnerec856802010-03-27 00:45:04 +00004751def : Pat<(add GR16:$src1, (loadi16 addr:$src2)),
Bill Wendlingd350e022008-12-12 21:15:41 +00004752 (ADD16rm GR16:$src1, addr:$src2)>;
Chris Lattnerec856802010-03-27 00:45:04 +00004753def : Pat<(add GR32:$src1, (loadi32 addr:$src2)),
Bill Wendlingd350e022008-12-12 21:15:41 +00004754 (ADD32rm GR32:$src1, addr:$src2)>;
4755
Chris Lattnerec856802010-03-27 00:45:04 +00004756// add reg, imm
4757def : Pat<(add GR8 :$src1, imm:$src2), (ADD8ri GR8:$src1 , imm:$src2)>;
4758def : Pat<(add GR16:$src1, imm:$src2), (ADD16ri GR16:$src1, imm:$src2)>;
4759def : Pat<(add GR32:$src1, imm:$src2), (ADD32ri GR32:$src1, imm:$src2)>;
4760def : Pat<(add GR16:$src1, i16immSExt8:$src2),
Bill Wendlingd350e022008-12-12 21:15:41 +00004761 (ADD16ri8 GR16:$src1, i16immSExt8:$src2)>;
Chris Lattnerec856802010-03-27 00:45:04 +00004762def : Pat<(add GR32:$src1, i32immSExt8:$src2),
Bill Wendlingd350e022008-12-12 21:15:41 +00004763 (ADD32ri8 GR32:$src1, i32immSExt8:$src2)>;
4764
Chris Lattnerec856802010-03-27 00:45:04 +00004765// sub reg, reg
4766def : Pat<(sub GR8 :$src1, GR8 :$src2), (SUB8rr GR8 :$src1, GR8 :$src2)>;
4767def : Pat<(sub GR16:$src1, GR16:$src2), (SUB16rr GR16:$src1, GR16:$src2)>;
4768def : Pat<(sub GR32:$src1, GR32:$src2), (SUB32rr GR32:$src1, GR32:$src2)>;
Bill Wendlingd350e022008-12-12 21:15:41 +00004769
Chris Lattnerec856802010-03-27 00:45:04 +00004770// sub reg, mem
4771def : Pat<(sub GR8:$src1, (loadi8 addr:$src2)),
Bill Wendlingd350e022008-12-12 21:15:41 +00004772 (SUB8rm GR8:$src1, addr:$src2)>;
Chris Lattnerec856802010-03-27 00:45:04 +00004773def : Pat<(sub GR16:$src1, (loadi16 addr:$src2)),
Bill Wendlingd350e022008-12-12 21:15:41 +00004774 (SUB16rm GR16:$src1, addr:$src2)>;
Chris Lattnerec856802010-03-27 00:45:04 +00004775def : Pat<(sub GR32:$src1, (loadi32 addr:$src2)),
Bill Wendlingd350e022008-12-12 21:15:41 +00004776 (SUB32rm GR32:$src1, addr:$src2)>;
4777
Chris Lattnerec856802010-03-27 00:45:04 +00004778// sub reg, imm
4779def : Pat<(sub GR8:$src1, imm:$src2),
Bill Wendlingd350e022008-12-12 21:15:41 +00004780 (SUB8ri GR8:$src1, imm:$src2)>;
Chris Lattnerec856802010-03-27 00:45:04 +00004781def : Pat<(sub GR16:$src1, imm:$src2),
Bill Wendlingd350e022008-12-12 21:15:41 +00004782 (SUB16ri GR16:$src1, imm:$src2)>;
Chris Lattnerec856802010-03-27 00:45:04 +00004783def : Pat<(sub GR32:$src1, imm:$src2),
Bill Wendlingd350e022008-12-12 21:15:41 +00004784 (SUB32ri GR32:$src1, imm:$src2)>;
Chris Lattnerec856802010-03-27 00:45:04 +00004785def : Pat<(sub GR16:$src1, i16immSExt8:$src2),
Bill Wendlingd350e022008-12-12 21:15:41 +00004786 (SUB16ri8 GR16:$src1, i16immSExt8:$src2)>;
Chris Lattnerec856802010-03-27 00:45:04 +00004787def : Pat<(sub GR32:$src1, i32immSExt8:$src2),
Bill Wendlingd350e022008-12-12 21:15:41 +00004788 (SUB32ri8 GR32:$src1, i32immSExt8:$src2)>;
4789
Chris Lattnerec856802010-03-27 00:45:04 +00004790// mul reg, reg
4791def : Pat<(mul GR16:$src1, GR16:$src2),
Bill Wendlingd350e022008-12-12 21:15:41 +00004792 (IMUL16rr GR16:$src1, GR16:$src2)>;
Chris Lattnerec856802010-03-27 00:45:04 +00004793def : Pat<(mul GR32:$src1, GR32:$src2),
Bill Wendlingd350e022008-12-12 21:15:41 +00004794 (IMUL32rr GR32:$src1, GR32:$src2)>;
4795
Chris Lattnerec856802010-03-27 00:45:04 +00004796// mul reg, mem
4797def : Pat<(mul GR16:$src1, (loadi16 addr:$src2)),
Bill Wendlingd350e022008-12-12 21:15:41 +00004798 (IMUL16rm GR16:$src1, addr:$src2)>;
Chris Lattnerec856802010-03-27 00:45:04 +00004799def : Pat<(mul GR32:$src1, (loadi32 addr:$src2)),
Bill Wendlingd350e022008-12-12 21:15:41 +00004800 (IMUL32rm GR32:$src1, addr:$src2)>;
4801
Chris Lattnerec856802010-03-27 00:45:04 +00004802// mul reg, imm
4803def : Pat<(mul GR16:$src1, imm:$src2),
Bill Wendlingd350e022008-12-12 21:15:41 +00004804 (IMUL16rri GR16:$src1, imm:$src2)>;
Chris Lattnerec856802010-03-27 00:45:04 +00004805def : Pat<(mul GR32:$src1, imm:$src2),
Bill Wendlingd350e022008-12-12 21:15:41 +00004806 (IMUL32rri GR32:$src1, imm:$src2)>;
Chris Lattnerec856802010-03-27 00:45:04 +00004807def : Pat<(mul GR16:$src1, i16immSExt8:$src2),
Bill Wendlingd350e022008-12-12 21:15:41 +00004808 (IMUL16rri8 GR16:$src1, i16immSExt8:$src2)>;
Chris Lattnerec856802010-03-27 00:45:04 +00004809def : Pat<(mul GR32:$src1, i32immSExt8:$src2),
Bill Wendlingd350e022008-12-12 21:15:41 +00004810 (IMUL32rri8 GR32:$src1, i32immSExt8:$src2)>;
4811
Chris Lattnerec856802010-03-27 00:45:04 +00004812// reg = mul mem, imm
4813def : Pat<(mul (loadi16 addr:$src1), imm:$src2),
Bill Wendlingd350e022008-12-12 21:15:41 +00004814 (IMUL16rmi addr:$src1, imm:$src2)>;
Chris Lattnerec856802010-03-27 00:45:04 +00004815def : Pat<(mul (loadi32 addr:$src1), imm:$src2),
Bill Wendlingd350e022008-12-12 21:15:41 +00004816 (IMUL32rmi addr:$src1, imm:$src2)>;
Chris Lattnerec856802010-03-27 00:45:04 +00004817def : Pat<(mul (loadi16 addr:$src1), i16immSExt8:$src2),
Bill Wendlingd350e022008-12-12 21:15:41 +00004818 (IMUL16rmi8 addr:$src1, i16immSExt8:$src2)>;
Chris Lattnerec856802010-03-27 00:45:04 +00004819def : Pat<(mul (loadi32 addr:$src1), i32immSExt8:$src2),
Bill Wendlingd350e022008-12-12 21:15:41 +00004820 (IMUL32rmi8 addr:$src1, i32immSExt8:$src2)>;
4821
Dan Gohman076aee32009-03-04 19:44:21 +00004822// Optimize multiply by 2 with EFLAGS result.
Evan Cheng6a86bd72009-01-27 03:30:42 +00004823let AddedComplexity = 2 in {
Chris Lattnerbaba4bb2010-03-27 02:47:14 +00004824def : Pat<(X86smul_flag GR16:$src1, 2), (ADD16rr GR16:$src1, GR16:$src1)>;
4825def : Pat<(X86smul_flag GR32:$src1, 2), (ADD32rr GR32:$src1, GR32:$src1)>;
Evan Cheng6a86bd72009-01-27 03:30:42 +00004826}
4827
Chris Lattner589ad5d2010-03-25 05:44:01 +00004828// Patterns for nodes that do not produce flags, for instructions that do.
Chris Lattnerc54a2f12010-03-24 01:02:12 +00004829
Chris Lattner589ad5d2010-03-25 05:44:01 +00004830// Increment reg.
4831def : Pat<(add GR8:$src , 1), (INC8r GR8:$src)>;
4832def : Pat<(add GR16:$src, 1), (INC16r GR16:$src)>, Requires<[In32BitMode]>;
4833def : Pat<(add GR32:$src, 1), (INC32r GR32:$src)>, Requires<[In32BitMode]>;
Dan Gohman076aee32009-03-04 19:44:21 +00004834
Chris Lattner589ad5d2010-03-25 05:44:01 +00004835// Decrement reg.
4836def : Pat<(add GR8:$src , -1), (DEC8r GR8:$src)>;
4837def : Pat<(add GR16:$src, -1), (DEC16r GR16:$src)>, Requires<[In32BitMode]>;
4838def : Pat<(add GR32:$src, -1), (DEC32r GR32:$src)>, Requires<[In32BitMode]>;
Dan Gohman076aee32009-03-04 19:44:21 +00004839
Chris Lattner589ad5d2010-03-25 05:44:01 +00004840// or reg/reg.
4841def : Pat<(or GR8 :$src1, GR8 :$src2), (OR8rr GR8 :$src1, GR8 :$src2)>;
4842def : Pat<(or GR16:$src1, GR16:$src2), (OR16rr GR16:$src1, GR16:$src2)>;
4843def : Pat<(or GR32:$src1, GR32:$src2), (OR32rr GR32:$src1, GR32:$src2)>;
Dan Gohman076aee32009-03-04 19:44:21 +00004844
Chris Lattner589ad5d2010-03-25 05:44:01 +00004845// or reg/mem
4846def : Pat<(or GR8:$src1, (loadi8 addr:$src2)),
Dan Gohmane220c4b2009-09-18 19:59:53 +00004847 (OR8rm GR8:$src1, addr:$src2)>;
Chris Lattner589ad5d2010-03-25 05:44:01 +00004848def : Pat<(or GR16:$src1, (loadi16 addr:$src2)),
Dan Gohmane220c4b2009-09-18 19:59:53 +00004849 (OR16rm GR16:$src1, addr:$src2)>;
Chris Lattner589ad5d2010-03-25 05:44:01 +00004850def : Pat<(or GR32:$src1, (loadi32 addr:$src2)),
Dan Gohmane220c4b2009-09-18 19:59:53 +00004851 (OR32rm GR32:$src1, addr:$src2)>;
4852
Chris Lattner589ad5d2010-03-25 05:44:01 +00004853// or reg/imm
4854def : Pat<(or GR8:$src1 , imm:$src2), (OR8ri GR8 :$src1, imm:$src2)>;
4855def : Pat<(or GR16:$src1, imm:$src2), (OR16ri GR16:$src1, imm:$src2)>;
4856def : Pat<(or GR32:$src1, imm:$src2), (OR32ri GR32:$src1, imm:$src2)>;
4857def : Pat<(or GR16:$src1, i16immSExt8:$src2),
Dan Gohmane220c4b2009-09-18 19:59:53 +00004858 (OR16ri8 GR16:$src1, i16immSExt8:$src2)>;
Chris Lattner589ad5d2010-03-25 05:44:01 +00004859def : Pat<(or GR32:$src1, i32immSExt8:$src2),
Dan Gohmane220c4b2009-09-18 19:59:53 +00004860 (OR32ri8 GR32:$src1, i32immSExt8:$src2)>;
Dan Gohmane220c4b2009-09-18 19:59:53 +00004861
Chris Lattner589ad5d2010-03-25 05:44:01 +00004862// xor reg/reg
4863def : Pat<(xor GR8 :$src1, GR8 :$src2), (XOR8rr GR8 :$src1, GR8 :$src2)>;
4864def : Pat<(xor GR16:$src1, GR16:$src2), (XOR16rr GR16:$src1, GR16:$src2)>;
4865def : Pat<(xor GR32:$src1, GR32:$src2), (XOR32rr GR32:$src1, GR32:$src2)>;
Dan Gohmane220c4b2009-09-18 19:59:53 +00004866
Chris Lattner589ad5d2010-03-25 05:44:01 +00004867// xor reg/mem
4868def : Pat<(xor GR8:$src1, (loadi8 addr:$src2)),
Dan Gohmane220c4b2009-09-18 19:59:53 +00004869 (XOR8rm GR8:$src1, addr:$src2)>;
Chris Lattner589ad5d2010-03-25 05:44:01 +00004870def : Pat<(xor GR16:$src1, (loadi16 addr:$src2)),
Dan Gohmane220c4b2009-09-18 19:59:53 +00004871 (XOR16rm GR16:$src1, addr:$src2)>;
Chris Lattner589ad5d2010-03-25 05:44:01 +00004872def : Pat<(xor GR32:$src1, (loadi32 addr:$src2)),
Dan Gohmane220c4b2009-09-18 19:59:53 +00004873 (XOR32rm GR32:$src1, addr:$src2)>;
4874
Chris Lattner589ad5d2010-03-25 05:44:01 +00004875// xor reg/imm
4876def : Pat<(xor GR8:$src1, imm:$src2),
Dan Gohmane220c4b2009-09-18 19:59:53 +00004877 (XOR8ri GR8:$src1, imm:$src2)>;
Chris Lattner589ad5d2010-03-25 05:44:01 +00004878def : Pat<(xor GR16:$src1, imm:$src2),
Dan Gohmane220c4b2009-09-18 19:59:53 +00004879 (XOR16ri GR16:$src1, imm:$src2)>;
Chris Lattner589ad5d2010-03-25 05:44:01 +00004880def : Pat<(xor GR32:$src1, imm:$src2),
Dan Gohmane220c4b2009-09-18 19:59:53 +00004881 (XOR32ri GR32:$src1, imm:$src2)>;
Chris Lattner589ad5d2010-03-25 05:44:01 +00004882def : Pat<(xor GR16:$src1, i16immSExt8:$src2),
Dan Gohmane220c4b2009-09-18 19:59:53 +00004883 (XOR16ri8 GR16:$src1, i16immSExt8:$src2)>;
Chris Lattner589ad5d2010-03-25 05:44:01 +00004884def : Pat<(xor GR32:$src1, i32immSExt8:$src2),
Dan Gohmane220c4b2009-09-18 19:59:53 +00004885 (XOR32ri8 GR32:$src1, i32immSExt8:$src2)>;
4886
Chris Lattner589ad5d2010-03-25 05:44:01 +00004887// and reg/reg
4888def : Pat<(and GR8 :$src1, GR8 :$src2), (AND8rr GR8 :$src1, GR8 :$src2)>;
4889def : Pat<(and GR16:$src1, GR16:$src2), (AND16rr GR16:$src1, GR16:$src2)>;
4890def : Pat<(and GR32:$src1, GR32:$src2), (AND32rr GR32:$src1, GR32:$src2)>;
Dan Gohmane220c4b2009-09-18 19:59:53 +00004891
Chris Lattner589ad5d2010-03-25 05:44:01 +00004892// and reg/mem
4893def : Pat<(and GR8:$src1, (loadi8 addr:$src2)),
Dan Gohmane220c4b2009-09-18 19:59:53 +00004894 (AND8rm GR8:$src1, addr:$src2)>;
Chris Lattner589ad5d2010-03-25 05:44:01 +00004895def : Pat<(and GR16:$src1, (loadi16 addr:$src2)),
Dan Gohmane220c4b2009-09-18 19:59:53 +00004896 (AND16rm GR16:$src1, addr:$src2)>;
Chris Lattner589ad5d2010-03-25 05:44:01 +00004897def : Pat<(and GR32:$src1, (loadi32 addr:$src2)),
Dan Gohmane220c4b2009-09-18 19:59:53 +00004898 (AND32rm GR32:$src1, addr:$src2)>;
4899
Chris Lattner589ad5d2010-03-25 05:44:01 +00004900// and reg/imm
4901def : Pat<(and GR8:$src1, imm:$src2),
Dan Gohmane220c4b2009-09-18 19:59:53 +00004902 (AND8ri GR8:$src1, imm:$src2)>;
Chris Lattner589ad5d2010-03-25 05:44:01 +00004903def : Pat<(and GR16:$src1, imm:$src2),
Dan Gohmane220c4b2009-09-18 19:59:53 +00004904 (AND16ri GR16:$src1, imm:$src2)>;
Chris Lattner589ad5d2010-03-25 05:44:01 +00004905def : Pat<(and GR32:$src1, imm:$src2),
Dan Gohmane220c4b2009-09-18 19:59:53 +00004906 (AND32ri GR32:$src1, imm:$src2)>;
Chris Lattner589ad5d2010-03-25 05:44:01 +00004907def : Pat<(and GR16:$src1, i16immSExt8:$src2),
Dan Gohmane220c4b2009-09-18 19:59:53 +00004908 (AND16ri8 GR16:$src1, i16immSExt8:$src2)>;
Chris Lattner589ad5d2010-03-25 05:44:01 +00004909def : Pat<(and GR32:$src1, i32immSExt8:$src2),
Dan Gohmane220c4b2009-09-18 19:59:53 +00004910 (AND32ri8 GR32:$src1, i32immSExt8:$src2)>;
4911
Dan Gohman2f67df72009-09-03 17:18:51 +00004912// -disable-16bit support.
Chris Lattner341b2742010-03-08 18:55:15 +00004913def : Pat<(truncstorei16 (i16 imm:$src), addr:$dst),
Dan Gohman2f67df72009-09-03 17:18:51 +00004914 (MOV16mi addr:$dst, imm:$src)>;
4915def : Pat<(truncstorei16 GR32:$src, addr:$dst),
4916 (MOV16mr addr:$dst, (EXTRACT_SUBREG GR32:$src, x86_subreg_16bit))>;
4917def : Pat<(i32 (sextloadi16 addr:$dst)),
4918 (MOVSX32rm16 addr:$dst)>;
4919def : Pat<(i32 (zextloadi16 addr:$dst)),
4920 (MOVZX32rm16 addr:$dst)>;
4921def : Pat<(i32 (extloadi16 addr:$dst)),
4922 (MOVZX32rm16 addr:$dst)>;
4923
Bill Wendlingd350e022008-12-12 21:15:41 +00004924//===----------------------------------------------------------------------===//
Evan Cheng4e4c71e2006-02-21 20:00:20 +00004925// Floating Point Stack Support
4926//===----------------------------------------------------------------------===//
4927
4928include "X86InstrFPStack.td"
4929
4930//===----------------------------------------------------------------------===//
Evan Chengc64a1a92007-07-31 08:04:03 +00004931// X86-64 Support
4932//===----------------------------------------------------------------------===//
4933
Chris Lattner36fe6d22008-01-10 05:50:42 +00004934include "X86Instr64bit.td"
Evan Chengc64a1a92007-07-31 08:04:03 +00004935
4936//===----------------------------------------------------------------------===//
David Greene51898d72010-02-09 23:52:19 +00004937// SIMD support (SSE, MMX and AVX)
4938//===----------------------------------------------------------------------===//
4939
4940include "X86InstrFragmentsSIMD.td"
4941
4942//===----------------------------------------------------------------------===//
Evan Cheng4e4c71e2006-02-21 20:00:20 +00004943// XMM Floating point support (requires SSE / SSE2)
4944//===----------------------------------------------------------------------===//
4945
4946include "X86InstrSSE.td"
Evan Cheng80f54042008-04-25 18:19:54 +00004947
4948//===----------------------------------------------------------------------===//
4949// MMX and XMM Packed Integer support (requires MMX, SSE, and SSE2)
4950//===----------------------------------------------------------------------===//
4951
4952include "X86InstrMMX.td"