blob: 92ff279e4e016c93aa5992ea9d65c55ce5837abc [file] [log] [blame]
Sean Callanan108934c2009-12-18 00:01:26 +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
Evan Cheng67f92a72006-01-11 22:15:48 +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
Evan Cheng18efe262007-12-14 02:13:44 +000081def X86bsf : SDNode<"X86ISD::BSF", SDTIntUnaryOp>;
82def X86bsr : SDNode<"X86ISD::BSR", SDTIntUnaryOp>;
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
Evan Cheng67f92a72006-01-11 22:15:48 +0000141def X86rep_stos: SDNode<"X86ISD::REP_STOS", SDTX86RepStr,
Chris Lattner9b37aaf2008-01-10 05:12:37 +0000142 [SDNPHasChain, SDNPInFlag, SDNPOutFlag, SDNPMayStore]>;
Evan Cheng67f92a72006-01-11 22:15:48 +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 Chengb1f49812009-12-22 17:47:23 +0000328def OptForSize : Predicate<"OptForSize">;
Evan Chengb7a75a52008-09-26 23:41:32 +0000329def OptForSpeed : Predicate<"!OptForSize">;
Evan Chengccb69762009-01-02 05:35:45 +0000330def FastBTMem : Predicate<"!Subtarget->isBTMemSlow()">;
Evan Chengd7f666a2009-05-20 04:53:57 +0000331def CallImmAddr : Predicate<"Subtarget->IsLegalToCallImmediateAddr(TM)">;
Evan Chengbbc8ddb2005-12-20 22:59:51 +0000332
333//===----------------------------------------------------------------------===//
Evan Chengc64a1a92007-07-31 08:04:03 +0000334// X86 Instruction Format Definitions.
Evan Chengaed7c722005-12-17 01:24:02 +0000335//
336
Evan Chengc64a1a92007-07-31 08:04:03 +0000337include "X86InstrFormats.td"
Chris Lattner1cca5e32003-08-03 21:54:21 +0000338
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +0000339//===----------------------------------------------------------------------===//
Chris Lattnerf124d5e2005-11-18 01:04:42 +0000340// Pattern fragments...
341//
Evan Chengd9558e02006-01-06 00:43:03 +0000342
343// X86 specific condition code. These correspond to CondCode in
Nate Begeman9a225302007-05-06 04:00:55 +0000344// X86InstrInfo.h. They must be kept in synch.
Dan Gohman653456c2009-01-07 00:15:08 +0000345def X86_COND_A : PatLeaf<(i8 0)>; // alt. COND_NBE
346def X86_COND_AE : PatLeaf<(i8 1)>; // alt. COND_NC
347def X86_COND_B : PatLeaf<(i8 2)>; // alt. COND_C
348def X86_COND_BE : PatLeaf<(i8 3)>; // alt. COND_NA
349def X86_COND_E : PatLeaf<(i8 4)>; // alt. COND_Z
350def X86_COND_G : PatLeaf<(i8 5)>; // alt. COND_NLE
351def X86_COND_GE : PatLeaf<(i8 6)>; // alt. COND_NL
352def X86_COND_L : PatLeaf<(i8 7)>; // alt. COND_NGE
353def X86_COND_LE : PatLeaf<(i8 8)>; // alt. COND_NG
354def X86_COND_NE : PatLeaf<(i8 9)>; // alt. COND_NZ
Evan Chengd9558e02006-01-06 00:43:03 +0000355def X86_COND_NO : PatLeaf<(i8 10)>;
Dan Gohman653456c2009-01-07 00:15:08 +0000356def X86_COND_NP : PatLeaf<(i8 11)>; // alt. COND_PO
Evan Chengd9558e02006-01-06 00:43:03 +0000357def X86_COND_NS : PatLeaf<(i8 12)>;
Dan Gohman653456c2009-01-07 00:15:08 +0000358def X86_COND_O : PatLeaf<(i8 13)>;
359def X86_COND_P : PatLeaf<(i8 14)>; // alt. COND_PE
360def X86_COND_S : PatLeaf<(i8 15)>;
Evan Chengd9558e02006-01-06 00:43:03 +0000361
Chris Lattner18409912010-03-03 01:45:01 +0000362def immSext8 : PatLeaf<(imm), [{
363 return N->getSExtValue() == (int8_t)N->getSExtValue();
Chris Lattnerf124d5e2005-11-18 01:04:42 +0000364}]>;
365
Chris Lattner18409912010-03-03 01:45:01 +0000366def i16immSExt8 : PatLeaf<(i16 immSext8)>;
367def i32immSExt8 : PatLeaf<(i32 immSext8)>;
Evan Chengb3558542005-12-13 00:01:09 +0000368
Chris Lattnerf85eff72010-03-03 01:52:59 +0000369/// Load patterns: these constraint the match to the right address space.
370def dsload : PatFrag<(ops node:$ptr), (load node:$ptr), [{
371 if (const Value *Src = cast<LoadSDNode>(N)->getSrcValue())
372 if (const PointerType *PT = dyn_cast<PointerType>(Src->getType()))
373 if (PT->getAddressSpace() > 255)
374 return false;
375 return true;
376}]>;
377
378def gsload : PatFrag<(ops node:$ptr), (load node:$ptr), [{
379 if (const Value *Src = cast<LoadSDNode>(N)->getSrcValue())
380 if (const PointerType *PT = dyn_cast<PointerType>(Src->getType()))
381 return PT->getAddressSpace() == 256;
382 return false;
383}]>;
384
385def fsload : PatFrag<(ops node:$ptr), (load node:$ptr), [{
386 if (const Value *Src = cast<LoadSDNode>(N)->getSrcValue())
387 if (const PointerType *PT = dyn_cast<PointerType>(Src->getType()))
388 return PT->getAddressSpace() == 257;
389 return false;
390}]>;
391
392
Evan Cheng605c4152005-12-13 01:57:51 +0000393// Helper fragments for loads.
Evan Chengb6564432008-05-13 18:59:59 +0000394// It's always safe to treat a anyext i16 load as a i32 load if the i16 is
395// known to be 32-bit aligned or better. Ditto for i8 to i16.
Dan Gohman33586292008-10-15 06:50:19 +0000396def loadi16 : PatFrag<(ops node:$ptr), (i16 (unindexedload node:$ptr)), [{
Dan Gohman67ca6be2008-08-20 15:24:22 +0000397 LoadSDNode *LD = cast<LoadSDNode>(N);
Chris Lattnerc2406f22009-04-10 00:16:23 +0000398 if (const Value *Src = LD->getSrcValue())
399 if (const PointerType *PT = dyn_cast<PointerType>(Src->getType()))
Mon P Wanga7e01d72009-04-27 07:22:10 +0000400 if (PT->getAddressSpace() > 255)
Chris Lattnerc2406f22009-04-10 00:16:23 +0000401 return false;
Dan Gohman67ca6be2008-08-20 15:24:22 +0000402 ISD::LoadExtType ExtType = LD->getExtensionType();
403 if (ExtType == ISD::NON_EXTLOAD)
404 return true;
405 if (ExtType == ISD::EXTLOAD)
406 return LD->getAlignment() >= 2 && !LD->isVolatile();
Evan Chengfa7fd332008-05-13 00:54:02 +0000407 return false;
408}]>;
409
Chris Lattnerf85eff72010-03-03 01:52:59 +0000410def loadi16_anyext : PatFrag<(ops node:$ptr), (i32 (unindexedload node:$ptr)),[{
Evan Chengca57f782008-09-24 23:27:55 +0000411 LoadSDNode *LD = cast<LoadSDNode>(N);
Chris Lattnerc2406f22009-04-10 00:16:23 +0000412 if (const Value *Src = LD->getSrcValue())
413 if (const PointerType *PT = dyn_cast<PointerType>(Src->getType()))
Mon P Wanga7e01d72009-04-27 07:22:10 +0000414 if (PT->getAddressSpace() > 255)
Chris Lattnerc2406f22009-04-10 00:16:23 +0000415 return false;
Evan Chengca57f782008-09-24 23:27:55 +0000416 ISD::LoadExtType ExtType = LD->getExtensionType();
417 if (ExtType == ISD::EXTLOAD)
418 return LD->getAlignment() >= 2 && !LD->isVolatile();
419 return false;
420}]>;
421
Dan Gohman33586292008-10-15 06:50:19 +0000422def loadi32 : PatFrag<(ops node:$ptr), (i32 (unindexedload node:$ptr)), [{
Dan Gohman67ca6be2008-08-20 15:24:22 +0000423 LoadSDNode *LD = cast<LoadSDNode>(N);
Chris Lattnerc2406f22009-04-10 00:16:23 +0000424 if (const Value *Src = LD->getSrcValue())
425 if (const PointerType *PT = dyn_cast<PointerType>(Src->getType()))
Mon P Wanga7e01d72009-04-27 07:22:10 +0000426 if (PT->getAddressSpace() > 255)
Chris Lattnerc2406f22009-04-10 00:16:23 +0000427 return false;
Dan Gohman67ca6be2008-08-20 15:24:22 +0000428 ISD::LoadExtType ExtType = LD->getExtensionType();
429 if (ExtType == ISD::NON_EXTLOAD)
430 return true;
431 if (ExtType == ISD::EXTLOAD)
432 return LD->getAlignment() >= 4 && !LD->isVolatile();
Evan Chengfa7fd332008-05-13 00:54:02 +0000433 return false;
434}]>;
435
Chris Lattnerf85eff72010-03-03 01:52:59 +0000436def loadi8 : PatFrag<(ops node:$ptr), (i8 (dsload node:$ptr))>;
437def loadi64 : PatFrag<(ops node:$ptr), (i64 (dsload node:$ptr))>;
438def loadf32 : PatFrag<(ops node:$ptr), (f32 (dsload node:$ptr))>;
439def loadf64 : PatFrag<(ops node:$ptr), (f64 (dsload node:$ptr))>;
440def loadf80 : PatFrag<(ops node:$ptr), (f80 (dsload node:$ptr))>;
Evan Cheng7a7e8372005-12-14 02:22:27 +0000441
Evan Cheng466685d2006-10-09 20:57:25 +0000442def sextloadi16i8 : PatFrag<(ops node:$ptr), (i16 (sextloadi8 node:$ptr))>;
443def sextloadi32i8 : PatFrag<(ops node:$ptr), (i32 (sextloadi8 node:$ptr))>;
444def sextloadi32i16 : PatFrag<(ops node:$ptr), (i32 (sextloadi16 node:$ptr))>;
Evan Cheng7a7e8372005-12-14 02:22:27 +0000445
Evan Cheng466685d2006-10-09 20:57:25 +0000446def zextloadi8i1 : PatFrag<(ops node:$ptr), (i8 (zextloadi1 node:$ptr))>;
447def zextloadi16i1 : PatFrag<(ops node:$ptr), (i16 (zextloadi1 node:$ptr))>;
448def zextloadi32i1 : PatFrag<(ops node:$ptr), (i32 (zextloadi1 node:$ptr))>;
449def zextloadi16i8 : PatFrag<(ops node:$ptr), (i16 (zextloadi8 node:$ptr))>;
450def zextloadi32i8 : PatFrag<(ops node:$ptr), (i32 (zextloadi8 node:$ptr))>;
451def zextloadi32i16 : PatFrag<(ops node:$ptr), (i32 (zextloadi16 node:$ptr))>;
Evan Cheng7a7e8372005-12-14 02:22:27 +0000452
Evan Cheng466685d2006-10-09 20:57:25 +0000453def extloadi8i1 : PatFrag<(ops node:$ptr), (i8 (extloadi1 node:$ptr))>;
454def extloadi16i1 : PatFrag<(ops node:$ptr), (i16 (extloadi1 node:$ptr))>;
455def extloadi32i1 : PatFrag<(ops node:$ptr), (i32 (extloadi1 node:$ptr))>;
456def extloadi16i8 : PatFrag<(ops node:$ptr), (i16 (extloadi8 node:$ptr))>;
457def extloadi32i8 : PatFrag<(ops node:$ptr), (i32 (extloadi8 node:$ptr))>;
458def extloadi32i16 : PatFrag<(ops node:$ptr), (i32 (extloadi16 node:$ptr))>;
Evan Cheng747a90d2006-02-21 02:24:38 +0000459
Chris Lattnerce2bcc82008-02-19 17:37:35 +0000460
461// An 'and' node with a single use.
462def and_su : PatFrag<(ops node:$lhs, node:$rhs), (and node:$lhs, node:$rhs), [{
Evan Cheng07b7ea12008-03-04 00:40:35 +0000463 return N->hasOneUse();
Chris Lattnerce2bcc82008-02-19 17:37:35 +0000464}]>;
Dan Gohman21e3dfb2009-04-13 16:09:41 +0000465// An 'srl' node with a single use.
466def srl_su : PatFrag<(ops node:$lhs, node:$rhs), (srl node:$lhs, node:$rhs), [{
467 return N->hasOneUse();
468}]>;
469// An 'trunc' node with a single use.
470def trunc_su : PatFrag<(ops node:$src), (trunc node:$src), [{
471 return N->hasOneUse();
472}]>;
Chris Lattnerce2bcc82008-02-19 17:37:35 +0000473
Evan Cheng4b0345b2010-01-11 17:03:47 +0000474// Treat an 'or' node is as an 'add' if the or'ed bits are known to be zero.
475def or_is_add : PatFrag<(ops node:$lhs, node:$rhs), (or node:$lhs, node:$rhs),[{
476 if (ConstantSDNode *CN = dyn_cast<ConstantSDNode>(N->getOperand(1)))
477 return CurDAG->MaskedValueIsZero(N->getOperand(0), CN->getAPIntValue());
Chris Lattnerfdac0b62010-03-24 00:12:57 +0000478
479 unsigned BitWidth = N->getValueType(0).getScalarType().getSizeInBits();
480 APInt Mask = APInt::getAllOnesValue(BitWidth);
481 APInt KnownZero0, KnownOne0;
482 CurDAG->ComputeMaskedBits(N->getOperand(0), Mask, KnownZero0, KnownOne0, 0);
483 APInt KnownZero1, KnownOne1;
484 CurDAG->ComputeMaskedBits(N->getOperand(1), Mask, KnownZero1, KnownOne1, 0);
485 return (~KnownZero0 & ~KnownZero1) == 0;
Evan Cheng4b0345b2010-01-11 17:03:47 +0000486}]>;
Evan Cheng4b0345b2010-01-11 17:03:47 +0000487
Dan Gohman74feef22008-10-17 01:23:35 +0000488// 'shld' and 'shrd' instruction patterns. Note that even though these have
489// the srl and shl in their patterns, the C++ code must still check for them,
490// because predicates are tested before children nodes are explored.
491
492def shrd : PatFrag<(ops node:$src1, node:$amt1, node:$src2, node:$amt2),
493 (or (srl node:$src1, node:$amt1),
494 (shl node:$src2, node:$amt2)), [{
495 assert(N->getOpcode() == ISD::OR);
496 return N->getOperand(0).getOpcode() == ISD::SRL &&
497 N->getOperand(1).getOpcode() == ISD::SHL &&
498 isa<ConstantSDNode>(N->getOperand(0).getOperand(1)) &&
499 isa<ConstantSDNode>(N->getOperand(1).getOperand(1)) &&
500 N->getOperand(0).getConstantOperandVal(1) ==
501 N->getValueSizeInBits(0) - N->getOperand(1).getConstantOperandVal(1);
502}]>;
503
504def shld : PatFrag<(ops node:$src1, node:$amt1, node:$src2, node:$amt2),
505 (or (shl node:$src1, node:$amt1),
506 (srl node:$src2, node:$amt2)), [{
507 assert(N->getOpcode() == ISD::OR);
508 return N->getOperand(0).getOpcode() == ISD::SHL &&
509 N->getOperand(1).getOpcode() == ISD::SRL &&
510 isa<ConstantSDNode>(N->getOperand(0).getOperand(1)) &&
511 isa<ConstantSDNode>(N->getOperand(1).getOperand(1)) &&
512 N->getOperand(0).getConstantOperandVal(1) ==
513 N->getValueSizeInBits(0) - N->getOperand(1).getConstantOperandVal(1);
514}]>;
515
Chris Lattnerf124d5e2005-11-18 01:04:42 +0000516//===----------------------------------------------------------------------===//
Chris Lattner1cca5e32003-08-03 21:54:21 +0000517// Instruction list...
518//
519
Chris Lattnerf18c0742006-10-12 17:42:56 +0000520// ADJCALLSTACKDOWN/UP implicitly use/def ESP because they may be expanded into
521// a stack adjustment and the codegen must know that they may modify the stack
522// pointer before prolog-epilog rewriting occurs.
Chris Lattner447ff682008-03-11 03:23:40 +0000523// Pessimistically assume ADJCALLSTACKDOWN / ADJCALLSTACKUP will become
524// sub / add which can clobber EFLAGS.
Evan Cheng8decf6b2007-09-28 01:19:48 +0000525let Defs = [ESP, EFLAGS], Uses = [ESP] in {
Dan Gohman6d4b0522008-10-01 18:28:06 +0000526def ADJCALLSTACKDOWN32 : I<0, Pseudo, (outs), (ins i32imm:$amt),
527 "#ADJCALLSTACKDOWN",
Chris Lattnere563bbc2008-10-11 22:08:30 +0000528 [(X86callseq_start timm:$amt)]>,
Dan Gohman6d4b0522008-10-01 18:28:06 +0000529 Requires<[In32BitMode]>;
530def ADJCALLSTACKUP32 : I<0, Pseudo, (outs), (ins i32imm:$amt1, i32imm:$amt2),
531 "#ADJCALLSTACKUP",
Chris Lattnere563bbc2008-10-11 22:08:30 +0000532 [(X86callseq_end timm:$amt1, timm:$amt2)]>,
Dan Gohman6d4b0522008-10-01 18:28:06 +0000533 Requires<[In32BitMode]>;
Evan Cheng071a2792007-09-11 19:55:27 +0000534}
Evan Cheng4a460802006-01-11 00:33:36 +0000535
Dan Gohmand6708ea2009-08-15 01:38:56 +0000536// x86-64 va_start lowering magic.
Anton Korobeynikov043f3c22010-03-06 19:32:29 +0000537let usesCustomInserter = 1 in {
Dan Gohmand6708ea2009-08-15 01:38:56 +0000538def VASTART_SAVE_XMM_REGS : I<0, Pseudo,
539 (outs),
540 (ins GR8:$al,
541 i64imm:$regsavefi, i64imm:$offset,
542 variable_ops),
543 "#VASTART_SAVE_XMM_REGS $al, $regsavefi, $offset",
544 [(X86vastart_save_xmm_regs GR8:$al,
545 imm:$regsavefi,
546 imm:$offset)]>;
547
Anton Korobeynikove765f2b2010-03-06 20:07:32 +0000548// Dynamic stack allocation yields _alloca call for Cygwin/Mingw targets. Calls
549// to _alloca is needed to probe the stack when allocating more than 4k bytes in
550// one go. Touching the stack at 4K increments is necessary to ensure that the
551// guard pages used by the OS virtual memory manager are allocated in correct
552// sequence.
553// The main point of having separate instruction are extra unmodelled effects
554// (compared to ordinary calls) like stack pointer change.
555
Anton Korobeynikov043f3c22010-03-06 19:32:29 +0000556def MINGW_ALLOCA : I<0, Pseudo, (outs), (ins),
Anton Korobeynikove765f2b2010-03-06 20:07:32 +0000557 "# dynamic stack allocation",
Anton Korobeynikov043f3c22010-03-06 19:32:29 +0000558 [(X86MingwAlloca)]>;
559}
560
Evan Cheng4a460802006-01-11 00:33:36 +0000561// Nop
Sean Callanan74e52102009-07-23 23:39:34 +0000562let neverHasSideEffects = 1 in {
Chris Lattnerba7e7562008-01-10 07:59:24 +0000563 def NOOP : I<0x90, RawFrm, (outs), (ins), "nop", []>;
Sean Callanan108934c2009-12-18 00:01:26 +0000564 def NOOPW : I<0x1f, MRM0m, (outs), (ins i16mem:$zero),
565 "nop{w}\t$zero", []>, TB, OpSize;
Sean Callanan74e52102009-07-23 23:39:34 +0000566 def NOOPL : I<0x1f, MRM0m, (outs), (ins i32mem:$zero),
Sean Callanan108934c2009-12-18 00:01:26 +0000567 "nop{l}\t$zero", []>, TB;
Sean Callanan74e52102009-07-23 23:39:34 +0000568}
Evan Cheng4a460802006-01-11 00:33:36 +0000569
Sean Callanan1c5cf1b2009-08-11 01:09:06 +0000570// Trap
Dan Gohmane94975e2009-11-11 18:07:16 +0000571def INT3 : I<0xcc, RawFrm, (outs), (ins), "int\t3", []>;
Sean Callanan1c5cf1b2009-08-11 01:09:06 +0000572def INT : I<0xcd, RawFrm, (outs), (ins i8imm:$trap), "int\t$trap", []>;
Sean Callanan108934c2009-12-18 00:01:26 +0000573def IRET16 : I<0xcf, RawFrm, (outs), (ins), "iret{w}", []>, OpSize;
574def IRET32 : I<0xcf, RawFrm, (outs), (ins), "iret{l}", []>;
Sean Callanan1c5cf1b2009-08-11 01:09:06 +0000575
Chris Lattner71c7ace2009-09-20 07:32:00 +0000576// PIC base construction. This expands to code that looks like this:
577// call $next_inst
578// popl %destreg"
Dan Gohman2662d552008-10-01 04:14:30 +0000579let neverHasSideEffects = 1, isNotDuplicable = 1, Uses = [ESP] in
Chris Lattnerb3c85472009-09-20 07:28:26 +0000580 def MOVPC32r : Ii32<0xE8, Pseudo, (outs GR32:$reg), (ins i32imm:$label),
Chris Lattner71c7ace2009-09-20 07:32:00 +0000581 "", []>;
Evan Cheng8f7f7122006-05-05 05:40:20 +0000582
Chris Lattner1cca5e32003-08-03 21:54:21 +0000583//===----------------------------------------------------------------------===//
Chris Lattnerbd13fb62010-02-11 19:25:55 +0000584// Control Flow Instructions.
Chris Lattner1cca5e32003-08-03 21:54:21 +0000585//
586
Chris Lattner1be48112005-05-13 17:56:48 +0000587// Return instructions.
Evan Cheng2b4ea792005-12-26 09:11:45 +0000588let isTerminator = 1, isReturn = 1, isBarrier = 1,
Chris Lattner447ff682008-03-11 03:23:40 +0000589 hasCtrlDep = 1, FPForm = SpecialFP, FPFormBits = SpecialFP.Value in {
Dan Gohmane4c67cd2008-05-31 02:11:25 +0000590 def RET : I <0xC3, RawFrm, (outs), (ins variable_ops),
Chris Lattner447ff682008-03-11 03:23:40 +0000591 "ret",
Dan Gohmane4c67cd2008-05-31 02:11:25 +0000592 [(X86retflag 0)]>;
Chris Lattner447ff682008-03-11 03:23:40 +0000593 def RETI : Ii16<0xC2, RawFrm, (outs), (ins i16imm:$amt, variable_ops),
594 "ret\t$amt",
Dan Gohman2f67df72009-09-03 17:18:51 +0000595 [(X86retflag timm:$amt)]>;
Sean Callanan356aed52009-09-15 23:37:51 +0000596 def LRET : I <0xCB, RawFrm, (outs), (ins),
597 "lret", []>;
598 def LRETI : Ii16<0xCA, RawFrm, (outs), (ins i16imm:$amt),
599 "lret\t$amt", []>;
Evan Cheng171049d2005-12-23 22:14:32 +0000600}
Chris Lattner1cca5e32003-08-03 21:54:21 +0000601
Chris Lattnerbd13fb62010-02-11 19:25:55 +0000602// Unconditional branches.
Chris Lattnerb8db3312010-02-11 21:45:31 +0000603let isBarrier = 1, isBranch = 1, isTerminator = 1 in {
Chris Lattnera0331192010-02-12 22:27:07 +0000604 def JMP_4 : Ii32PCRel<0xE9, RawFrm, (outs), (ins brtarget:$dst),
605 "jmp\t$dst", [(br bb:$dst)]>;
606 def JMP_1 : Ii8PCRel<0xEB, RawFrm, (outs), (ins brtarget8:$dst),
607 "jmp\t$dst", []>;
Sean Callanan52925882009-07-22 01:05:20 +0000608}
Evan Cheng898101c2005-12-19 23:12:38 +0000609
Chris Lattnerbd13fb62010-02-11 19:25:55 +0000610// Conditional Branches.
611let isBranch = 1, isTerminator = 1, Uses = [EFLAGS] in {
612 multiclass ICBr<bits<8> opc1, bits<8> opc4, string asm, PatFrag Cond> {
Chris Lattnera0331192010-02-12 22:27:07 +0000613 def _1 : Ii8PCRel <opc1, RawFrm, (outs), (ins brtarget8:$dst), asm, []>;
614 def _4 : Ii32PCRel<opc4, RawFrm, (outs), (ins brtarget:$dst), asm,
615 [(X86brcond bb:$dst, Cond, EFLAGS)]>, TB;
Chris Lattnerbd13fb62010-02-11 19:25:55 +0000616 }
617}
618
619defm JO : ICBr<0x70, 0x80, "jo\t$dst" , X86_COND_O>;
Chris Lattner8b442a82010-02-11 19:52:11 +0000620defm JNO : ICBr<0x71, 0x81, "jno\t$dst" , X86_COND_NO>;
Chris Lattnerbd13fb62010-02-11 19:25:55 +0000621defm JB : ICBr<0x72, 0x82, "jb\t$dst" , X86_COND_B>;
622defm JAE : ICBr<0x73, 0x83, "jae\t$dst", X86_COND_AE>;
623defm JE : ICBr<0x74, 0x84, "je\t$dst" , X86_COND_E>;
624defm JNE : ICBr<0x75, 0x85, "jne\t$dst", X86_COND_NE>;
625defm JBE : ICBr<0x76, 0x86, "jbe\t$dst", X86_COND_BE>;
626defm JA : ICBr<0x77, 0x87, "ja\t$dst" , X86_COND_A>;
627defm JS : ICBr<0x78, 0x88, "js\t$dst" , X86_COND_S>;
628defm JNS : ICBr<0x79, 0x89, "jns\t$dst", X86_COND_NS>;
629defm JP : ICBr<0x7A, 0x8A, "jp\t$dst" , X86_COND_P>;
630defm JNP : ICBr<0x7B, 0x8B, "jnp\t$dst", X86_COND_NP>;
631defm JL : ICBr<0x7C, 0x8C, "jl\t$dst" , X86_COND_L>;
632defm JGE : ICBr<0x7D, 0x8D, "jge\t$dst", X86_COND_GE>;
633defm JLE : ICBr<0x7E, 0x8E, "jle\t$dst", X86_COND_LE>;
634defm JG : ICBr<0x7F, 0x8F, "jg\t$dst" , X86_COND_G>;
635
636// FIXME: What about the CX/RCX versions of this instruction?
Chris Lattnerb8db3312010-02-11 21:45:31 +0000637let Uses = [ECX], isBranch = 1, isTerminator = 1 in
Chris Lattnera0331192010-02-12 22:27:07 +0000638 def JCXZ8 : Ii8PCRel<0xE3, RawFrm, (outs), (ins brtarget8:$dst),
639 "jcxz\t$dst", []>;
Chris Lattnerbd13fb62010-02-11 19:25:55 +0000640
641
Owen Anderson20ab2902007-11-12 07:39:39 +0000642// Indirect branches
643let isBranch = 1, isTerminator = 1, isBarrier = 1, isIndirectBranch = 1 in {
Dan Gohmanb1576f52007-07-31 20:11:57 +0000644 def JMP32r : I<0xFF, MRM4r, (outs), (ins GR32:$dst), "jmp{l}\t{*}$dst",
Evan Cheng069287d2006-05-16 07:21:53 +0000645 [(brind GR32:$dst)]>;
Dan Gohmanb1576f52007-07-31 20:11:57 +0000646 def JMP32m : I<0xFF, MRM4m, (outs), (ins i32mem:$dst), "jmp{l}\t{*}$dst",
Evan Cheng25ab6902006-09-08 06:48:29 +0000647 [(brind (loadi32 addr:$dst))]>;
Sean Callanan76f14be2009-09-15 00:35:17 +0000648
649 def FARJMP16i : Iseg16<0xEA, RawFrm, (outs),
650 (ins i16imm:$seg, i16imm:$off),
651 "ljmp{w}\t$seg, $off", []>, OpSize;
652 def FARJMP32i : Iseg32<0xEA, RawFrm, (outs),
653 (ins i16imm:$seg, i32imm:$off),
654 "ljmp{l}\t$seg, $off", []>;
655
656 def FARJMP16m : I<0xFF, MRM5m, (outs), (ins opaque32mem:$dst),
Sean Callanan9947bbb2009-09-03 00:04:47 +0000657 "ljmp{w}\t{*}$dst", []>, OpSize;
Sean Callanan76f14be2009-09-15 00:35:17 +0000658 def FARJMP32m : I<0xFF, MRM5m, (outs), (ins opaque48mem:$dst),
Sean Callanan9947bbb2009-09-03 00:04:47 +0000659 "ljmp{l}\t{*}$dst", []>;
Nate Begeman37efe672006-04-22 18:53:45 +0000660}
661
Chris Lattner1cca5e32003-08-03 21:54:21 +0000662
Sean Callanan7e6d7272009-09-16 21:50:07 +0000663// Loop instructions
664
Chris Lattner34b8a882010-03-18 20:50:06 +0000665def LOOP : I<0xE2, RawFrm, (outs), (ins brtarget8:$dst), "loop\t$dst", []>;
666def LOOPE : I<0xE1, RawFrm, (outs), (ins brtarget8:$dst), "loope\t$dst", []>;
667def LOOPNE : I<0xE0, RawFrm, (outs), (ins brtarget8:$dst), "loopne\t$dst", []>;
Sean Callanan7e6d7272009-09-16 21:50:07 +0000668
Chris Lattner1cca5e32003-08-03 21:54:21 +0000669//===----------------------------------------------------------------------===//
670// Call Instructions...
671//
Evan Chengffbacca2007-07-21 00:34:19 +0000672let isCall = 1 in
Dan Gohman6d4b0522008-10-01 18:28:06 +0000673 // All calls clobber the non-callee saved registers. ESP is marked as
674 // a use to prevent stack-pointer assignments that appear immediately
675 // before calls from potentially appearing dead. Uses for argument
676 // registers are added manually.
Nate Begemanf63be7d2005-07-06 18:59:04 +0000677 let Defs = [EAX, ECX, EDX, FP0, FP1, FP2, FP3, FP4, FP5, FP6, ST0,
Bill Wendling3f3a17d2007-04-25 21:31:48 +0000678 MM0, MM1, MM2, MM3, MM4, MM5, MM6, MM7,
Evan Cheng109a5622008-10-17 21:02:22 +0000679 XMM0, XMM1, XMM2, XMM3, XMM4, XMM5, XMM6, XMM7,
680 XMM8, XMM9, XMM10, XMM11, XMM12, XMM13, XMM14, XMM15, EFLAGS],
Dan Gohman2662d552008-10-01 04:14:30 +0000681 Uses = [ESP] in {
Chris Lattnera0331192010-02-12 22:27:07 +0000682 def CALLpcrel32 : Ii32PCRel<0xE8, RawFrm,
Chris Lattner7680e732009-06-20 19:34:09 +0000683 (outs), (ins i32imm_pcrel:$dst,variable_ops),
684 "call\t$dst", []>;
Evan Cheng64d80e32007-07-19 01:14:50 +0000685 def CALL32r : I<0xFF, MRM2r, (outs), (ins GR32:$dst, variable_ops),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000686 "call\t{*}$dst", [(X86call GR32:$dst)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +0000687 def CALL32m : I<0xFF, MRM2m, (outs), (ins i32mem:$dst, variable_ops),
Dan Gohmanb4106172008-05-29 21:50:34 +0000688 "call\t{*}$dst", [(X86call (loadi32 addr:$dst))]>;
Sean Callanan9947bbb2009-09-03 00:04:47 +0000689
Sean Callanan76f14be2009-09-15 00:35:17 +0000690 def FARCALL16i : Iseg16<0x9A, RawFrm, (outs),
691 (ins i16imm:$seg, i16imm:$off),
692 "lcall{w}\t$seg, $off", []>, OpSize;
693 def FARCALL32i : Iseg32<0x9A, RawFrm, (outs),
694 (ins i16imm:$seg, i32imm:$off),
695 "lcall{l}\t$seg, $off", []>;
696
697 def FARCALL16m : I<0xFF, MRM3m, (outs), (ins opaque32mem:$dst),
Sean Callanan9947bbb2009-09-03 00:04:47 +0000698 "lcall{w}\t{*}$dst", []>, OpSize;
Sean Callanan76f14be2009-09-15 00:35:17 +0000699 def FARCALL32m : I<0xFF, MRM3m, (outs), (ins opaque48mem:$dst),
Sean Callanan9947bbb2009-09-03 00:04:47 +0000700 "lcall{l}\t{*}$dst", []>;
Chris Lattner1cca5e32003-08-03 21:54:21 +0000701 }
702
Sean Callanan8d708542009-09-16 02:57:13 +0000703// Constructing a stack frame.
704
705def ENTER : I<0xC8, RawFrm, (outs), (ins i16imm:$len, i8imm:$lvl),
706 "enter\t$len, $lvl", []>;
707
Chris Lattner1e9448b2005-05-15 03:10:37 +0000708// Tail call stuff.
Arnold Schwaighoferc85e1712007-10-11 19:40:01 +0000709
Evan Chengffbacca2007-07-21 00:34:19 +0000710let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1 in
Evan Chengf48ef032010-03-14 03:48:46 +0000711 let Defs = [EAX, ECX, EDX, FP0, FP1, FP2, FP3, FP4, FP5, FP6, ST0,
712 MM0, MM1, MM2, MM3, MM4, MM5, MM6, MM7,
713 XMM0, XMM1, XMM2, XMM3, XMM4, XMM5, XMM6, XMM7,
714 XMM8, XMM9, XMM10, XMM11, XMM12, XMM13, XMM14, XMM15, EFLAGS],
715 Uses = [ESP] in {
716 def TCRETURNdi : I<0, Pseudo, (outs),
717 (ins i32imm_pcrel:$dst, i32imm:$offset, variable_ops),
718 "#TC_RETURN $dst $offset", []>;
719 def TCRETURNri : I<0, Pseudo, (outs),
720 (ins GR32_TC:$dst, i32imm:$offset, variable_ops),
721 "#TC_RETURN $dst $offset", []>;
722 def TCRETURNmi : I<0, Pseudo, (outs),
723 (ins i32mem_TC:$dst, i32imm:$offset, variable_ops),
724 "#TC_RETURN $dst $offset", []>;
Arnold Schwaighoferc85e1712007-10-11 19:40:01 +0000725
Evan Chengf48ef032010-03-14 03:48:46 +0000726 // FIXME: The should be pseudo instructions that are lowered when going to
727 // mcinst.
Chris Lattner840e6372010-03-16 06:30:18 +0000728 def TAILJMPd : Ii32PCRel<0xE9, RawFrm, (outs),
729 (ins i32imm_pcrel:$dst, variable_ops),
Evan Chengaa92bec2010-01-31 07:28:44 +0000730 "jmp\t$dst # TAILCALL",
Evan Chengf10c17f2006-09-22 21:43:59 +0000731 []>;
Evan Chengf48ef032010-03-14 03:48:46 +0000732 def TAILJMPr : I<0xFF, MRM4r, (outs), (ins GR32_TC:$dst, variable_ops),
Sean Callanan108934c2009-12-18 00:01:26 +0000733 "jmp{l}\t{*}$dst # TAILCALL",
Arnold Schwaighoferc85e1712007-10-11 19:40:01 +0000734 []>;
Evan Chengf48ef032010-03-14 03:48:46 +0000735 def TAILJMPm : I<0xFF, MRM4m, (outs), (ins i32mem_TC:$dst, variable_ops),
736 "jmp{l}\t{*}$dst # TAILCALL", []>;
737}
Chris Lattner1e9448b2005-05-15 03:10:37 +0000738
Chris Lattner1cca5e32003-08-03 21:54:21 +0000739//===----------------------------------------------------------------------===//
740// Miscellaneous Instructions...
741//
Chris Lattnerba7e7562008-01-10 07:59:24 +0000742let Defs = [EBP, ESP], Uses = [EBP, ESP], mayLoad = 1, neverHasSideEffects=1 in
Chris Lattner30bf2d82004-08-10 20:17:41 +0000743def LEAVE : I<0xC9, RawFrm,
Evan Cheng071a2792007-09-11 19:55:27 +0000744 (outs), (ins), "leave", []>;
745
Sean Callanan108934c2009-12-18 00:01:26 +0000746def POPCNT16rr : I<0xB8, MRMSrcReg, (outs GR16:$dst), (ins GR16:$src),
747 "popcnt{w}\t{$src, $dst|$dst, $src}", []>, OpSize, XS;
748def POPCNT16rm : I<0xB8, MRMSrcMem, (outs GR16:$dst), (ins i16mem:$src),
749 "popcnt{w}\t{$src, $dst|$dst, $src}", []>, OpSize, XS;
750def POPCNT32rr : I<0xB8, MRMSrcReg, (outs GR32:$dst), (ins GR32:$src),
751 "popcnt{l}\t{$src, $dst|$dst, $src}", []>, XS;
752def POPCNT32rm : I<0xB8, MRMSrcMem, (outs GR32:$dst), (ins i32mem:$src),
753 "popcnt{l}\t{$src, $dst|$dst, $src}", []>, XS;
754
Chris Lattnerba7e7562008-01-10 07:59:24 +0000755let Defs = [ESP], Uses = [ESP], neverHasSideEffects=1 in {
Sean Callanan1f24e012009-09-10 18:29:13 +0000756let mayLoad = 1 in {
757def POP16r : I<0x58, AddRegFrm, (outs GR16:$reg), (ins), "pop{w}\t$reg", []>,
758 OpSize;
759def POP32r : I<0x58, AddRegFrm, (outs GR32:$reg), (ins), "pop{l}\t$reg", []>;
760def POP16rmr: I<0x8F, MRM0r, (outs GR16:$reg), (ins), "pop{w}\t$reg", []>,
761 OpSize;
762def POP16rmm: I<0x8F, MRM0m, (outs i16mem:$dst), (ins), "pop{w}\t$dst", []>,
763 OpSize;
764def POP32rmr: I<0x8F, MRM0r, (outs GR32:$reg), (ins), "pop{l}\t$reg", []>;
765def POP32rmm: I<0x8F, MRM0m, (outs i32mem:$dst), (ins), "pop{l}\t$dst", []>;
766}
Chris Lattner1cca5e32003-08-03 21:54:21 +0000767
Sean Callanan1f24e012009-09-10 18:29:13 +0000768let mayStore = 1 in {
769def PUSH16r : I<0x50, AddRegFrm, (outs), (ins GR16:$reg), "push{w}\t$reg",[]>,
770 OpSize;
Evan Cheng2f245ba2007-09-26 01:29:06 +0000771def PUSH32r : I<0x50, AddRegFrm, (outs), (ins GR32:$reg), "push{l}\t$reg",[]>;
Sean Callanan1f24e012009-09-10 18:29:13 +0000772def PUSH16rmr: I<0xFF, MRM6r, (outs), (ins GR16:$reg), "push{w}\t$reg",[]>,
773 OpSize;
774def PUSH16rmm: I<0xFF, MRM6m, (outs), (ins i16mem:$src), "push{w}\t$src",[]>,
775 OpSize;
776def PUSH32rmr: I<0xFF, MRM6r, (outs), (ins GR32:$reg), "push{l}\t$reg",[]>;
777def PUSH32rmm: I<0xFF, MRM6m, (outs), (ins i32mem:$src), "push{l}\t$src",[]>;
778}
Evan Cheng071a2792007-09-11 19:55:27 +0000779}
Anton Korobeynikov57fc00d2007-04-17 09:20:00 +0000780
Bill Wendling453eb262009-06-15 19:39:04 +0000781let Defs = [ESP], Uses = [ESP], neverHasSideEffects = 1, mayStore = 1 in {
782def PUSH32i8 : Ii8<0x6a, RawFrm, (outs), (ins i8imm:$imm),
Bill Wendling927788c2009-06-15 20:59:31 +0000783 "push{l}\t$imm", []>;
Bill Wendling453eb262009-06-15 19:39:04 +0000784def PUSH32i16 : Ii16<0x68, RawFrm, (outs), (ins i16imm:$imm),
Bill Wendling927788c2009-06-15 20:59:31 +0000785 "push{l}\t$imm", []>;
Bill Wendling453eb262009-06-15 19:39:04 +0000786def PUSH32i32 : Ii32<0x68, RawFrm, (outs), (ins i32imm:$imm),
Bill Wendling927788c2009-06-15 20:59:31 +0000787 "push{l}\t$imm", []>;
Bill Wendling453eb262009-06-15 19:39:04 +0000788}
789
Sean Callanan108934c2009-12-18 00:01:26 +0000790let Defs = [ESP, EFLAGS], Uses = [ESP], mayLoad = 1, neverHasSideEffects=1 in {
791def POPF : I<0x9D, RawFrm, (outs), (ins), "popf{w}", []>, OpSize;
792def POPFD : I<0x9D, RawFrm, (outs), (ins), "popf{l}", []>;
793}
794let Defs = [ESP], Uses = [ESP, EFLAGS], mayStore = 1, neverHasSideEffects=1 in {
795def PUSHF : I<0x9C, RawFrm, (outs), (ins), "pushf{w}", []>, OpSize;
796def PUSHFD : I<0x9C, RawFrm, (outs), (ins), "pushf{l}", []>;
797}
Evan Cheng2f245ba2007-09-26 01:29:06 +0000798
Evan Cheng069287d2006-05-16 07:21:53 +0000799let isTwoAddress = 1 in // GR32 = bswap GR32
Chris Lattner30bf2d82004-08-10 20:17:41 +0000800 def BSWAP32r : I<0xC8, AddRegFrm,
Evan Cheng64d80e32007-07-19 01:14:50 +0000801 (outs GR32:$dst), (ins GR32:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000802 "bswap{l}\t$dst",
Evan Cheng069287d2006-05-16 07:21:53 +0000803 [(set GR32:$dst, (bswap GR32:$src))]>, TB;
Chris Lattner1cca5e32003-08-03 21:54:21 +0000804
Chris Lattner1cca5e32003-08-03 21:54:21 +0000805
Evan Cheng18efe262007-12-14 02:13:44 +0000806// Bit scan instructions.
807let Defs = [EFLAGS] in {
Evan Chengfd9e4732007-12-14 18:49:43 +0000808def BSF16rr : I<0xBC, MRMSrcReg, (outs GR16:$dst), (ins GR16:$src),
Dan Gohman1a8001e2007-12-14 15:10:00 +0000809 "bsf{w}\t{$src, $dst|$dst, $src}",
Evan Cheng152804e2007-12-14 08:30:15 +0000810 [(set GR16:$dst, (X86bsf GR16:$src)), (implicit EFLAGS)]>, TB;
Evan Cheng18efe262007-12-14 02:13:44 +0000811def BSF16rm : I<0xBC, MRMSrcMem, (outs GR16:$dst), (ins i16mem:$src),
Dan Gohman1a8001e2007-12-14 15:10:00 +0000812 "bsf{w}\t{$src, $dst|$dst, $src}",
Evan Cheng152804e2007-12-14 08:30:15 +0000813 [(set GR16:$dst, (X86bsf (loadi16 addr:$src))),
814 (implicit EFLAGS)]>, TB;
Evan Chengfd9e4732007-12-14 18:49:43 +0000815def BSF32rr : I<0xBC, MRMSrcReg, (outs GR32:$dst), (ins GR32:$src),
Dan Gohman1a8001e2007-12-14 15:10:00 +0000816 "bsf{l}\t{$src, $dst|$dst, $src}",
Evan Cheng152804e2007-12-14 08:30:15 +0000817 [(set GR32:$dst, (X86bsf GR32:$src)), (implicit EFLAGS)]>, TB;
Evan Cheng18efe262007-12-14 02:13:44 +0000818def BSF32rm : I<0xBC, MRMSrcMem, (outs GR32:$dst), (ins i32mem:$src),
Dan Gohman1a8001e2007-12-14 15:10:00 +0000819 "bsf{l}\t{$src, $dst|$dst, $src}",
Evan Cheng152804e2007-12-14 08:30:15 +0000820 [(set GR32:$dst, (X86bsf (loadi32 addr:$src))),
821 (implicit EFLAGS)]>, 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}",
Evan Cheng152804e2007-12-14 08:30:15 +0000825 [(set GR16:$dst, (X86bsr GR16:$src)), (implicit EFLAGS)]>, 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}",
Evan Cheng152804e2007-12-14 08:30:15 +0000828 [(set GR16:$dst, (X86bsr (loadi16 addr:$src))),
829 (implicit EFLAGS)]>, TB;
Evan Chengfd9e4732007-12-14 18:49:43 +0000830def BSR32rr : I<0xBD, MRMSrcReg, (outs GR32:$dst), (ins GR32:$src),
Dan Gohman1a8001e2007-12-14 15:10:00 +0000831 "bsr{l}\t{$src, $dst|$dst, $src}",
Evan Cheng152804e2007-12-14 08:30:15 +0000832 [(set GR32:$dst, (X86bsr GR32:$src)), (implicit EFLAGS)]>, TB;
Evan Cheng18efe262007-12-14 02:13:44 +0000833def BSR32rm : I<0xBD, MRMSrcMem, (outs GR32:$dst), (ins i32mem:$src),
Dan Gohman1a8001e2007-12-14 15:10:00 +0000834 "bsr{l}\t{$src, $dst|$dst, $src}",
Evan Cheng152804e2007-12-14 08:30:15 +0000835 [(set GR32:$dst, (X86bsr (loadi32 addr:$src))),
836 (implicit EFLAGS)]>, TB;
Evan Cheng18efe262007-12-14 02:13:44 +0000837} // Defs = [EFLAGS]
838
Chris Lattnerba7e7562008-01-10 07:59:24 +0000839let neverHasSideEffects = 1 in
Chris Lattner3a173df2004-10-03 20:35:00 +0000840def LEA16r : I<0x8D, MRMSrcMem,
Evan Cheng15b0d972009-12-12 18:51:56 +0000841 (outs GR16:$dst), (ins lea32mem:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000842 "lea{w}\t{$src|$dst}, {$dst|$src}", []>, OpSize;
Evan Chenge771ebd2008-03-27 01:41:09 +0000843let isReMaterializable = 1 in
Chris Lattner3a173df2004-10-03 20:35:00 +0000844def LEA32r : I<0x8D, MRMSrcMem,
Evan Cheng64d80e32007-07-19 01:14:50 +0000845 (outs GR32:$dst), (ins lea32mem:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000846 "lea{l}\t{$src|$dst}, {$dst|$src}",
Evan Cheng25ab6902006-09-08 06:48:29 +0000847 [(set GR32:$dst, lea32addr:$src)]>, Requires<[In32BitMode]>;
Chris Lattner1cca5e32003-08-03 21:54:21 +0000848
Kevin Enderby12ce0de2010-02-03 21:04:42 +0000849let Defs = [ECX,EDI,ESI], Uses = [ECX,EDI,ESI], isCodeGenOnly = 1 in {
Evan Cheng64d80e32007-07-19 01:14:50 +0000850def REP_MOVSB : I<0xA4, RawFrm, (outs), (ins), "{rep;movsb|rep movsb}",
Evan Cheng071a2792007-09-11 19:55:27 +0000851 [(X86rep_movs i8)]>, REP;
Evan Cheng64d80e32007-07-19 01:14:50 +0000852def REP_MOVSW : I<0xA5, RawFrm, (outs), (ins), "{rep;movsw|rep movsw}",
Evan Cheng071a2792007-09-11 19:55:27 +0000853 [(X86rep_movs i16)]>, REP, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +0000854def REP_MOVSD : I<0xA5, RawFrm, (outs), (ins), "{rep;movsl|rep movsd}",
Evan Cheng071a2792007-09-11 19:55:27 +0000855 [(X86rep_movs i32)]>, REP;
856}
Chris Lattner915e5e52004-02-12 17:53:22 +0000857
Kevin Enderby12ce0de2010-02-03 21:04:42 +0000858// These uses the DF flag in the EFLAGS register to inc or dec EDI and ESI
859let Defs = [EDI,ESI], Uses = [EDI,ESI,EFLAGS] in {
860def MOVSB : I<0xA4, RawFrm, (outs), (ins), "{movsb}", []>;
861def MOVSW : I<0xA5, RawFrm, (outs), (ins), "{movsw}", []>, OpSize;
862def MOVSD : I<0xA5, RawFrm, (outs), (ins), "{movsl|movsd}", []>;
863}
864
865let Defs = [ECX,EDI], Uses = [AL,ECX,EDI], isCodeGenOnly = 1 in
Evan Cheng64d80e32007-07-19 01:14:50 +0000866def REP_STOSB : I<0xAA, RawFrm, (outs), (ins), "{rep;stosb|rep stosb}",
Evan Cheng071a2792007-09-11 19:55:27 +0000867 [(X86rep_stos i8)]>, REP;
Kevin Enderby12ce0de2010-02-03 21:04:42 +0000868let Defs = [ECX,EDI], Uses = [AX,ECX,EDI], isCodeGenOnly = 1 in
Evan Cheng64d80e32007-07-19 01:14:50 +0000869def REP_STOSW : I<0xAB, RawFrm, (outs), (ins), "{rep;stosw|rep stosw}",
Evan Cheng071a2792007-09-11 19:55:27 +0000870 [(X86rep_stos i16)]>, REP, OpSize;
Kevin Enderby12ce0de2010-02-03 21:04:42 +0000871let Defs = [ECX,EDI], Uses = [EAX,ECX,EDI], isCodeGenOnly = 1 in
Evan Cheng64d80e32007-07-19 01:14:50 +0000872def REP_STOSD : I<0xAB, RawFrm, (outs), (ins), "{rep;stosl|rep stosd}",
Evan Cheng071a2792007-09-11 19:55:27 +0000873 [(X86rep_stos i32)]>, REP;
Chris Lattner30bf2d82004-08-10 20:17:41 +0000874
Kevin Enderby12ce0de2010-02-03 21:04:42 +0000875// These uses the DF flag in the EFLAGS register to inc or dec EDI and ESI
876let Defs = [EDI], Uses = [AL,EDI,EFLAGS] in
877def STOSB : I<0xAA, RawFrm, (outs), (ins), "{stosb}", []>;
878let Defs = [EDI], Uses = [AX,EDI,EFLAGS] in
879def STOSW : I<0xAB, RawFrm, (outs), (ins), "{stosw}", []>, OpSize;
880let Defs = [EDI], Uses = [EAX,EDI,EFLAGS] in
881def STOSD : I<0xAB, RawFrm, (outs), (ins), "{stosl|stosd}", []>;
882
Sean Callanana82e4652009-09-12 00:37:19 +0000883def SCAS8 : I<0xAE, RawFrm, (outs), (ins), "scas{b}", []>;
884def SCAS16 : I<0xAF, RawFrm, (outs), (ins), "scas{w}", []>, OpSize;
885def SCAS32 : I<0xAF, RawFrm, (outs), (ins), "scas{l}", []>;
886
Sean Callanan6f8f4622009-09-12 02:25:20 +0000887def CMPS8 : I<0xA6, RawFrm, (outs), (ins), "cmps{b}", []>;
888def CMPS16 : I<0xA7, RawFrm, (outs), (ins), "cmps{w}", []>, OpSize;
889def CMPS32 : I<0xA7, RawFrm, (outs), (ins), "cmps{l}", []>;
890
Evan Cheng071a2792007-09-11 19:55:27 +0000891let Defs = [RAX, RDX] in
Evan Cheng64d80e32007-07-19 01:14:50 +0000892def RDTSC : I<0x31, RawFrm, (outs), (ins), "rdtsc", [(X86rdtsc)]>,
Evan Cheng071a2792007-09-11 19:55:27 +0000893 TB;
Chris Lattnerb89abef2004-02-14 04:45:37 +0000894
Sean Callanancebe9552010-02-13 02:06:11 +0000895let Defs = [RAX, RCX, RDX] in
896def RDTSCP : I<0x01, MRM_F9, (outs), (ins), "rdtscp", []>, TB;
897
Anton Korobeynikov66fac792008-01-15 07:02:33 +0000898let isBarrier = 1, hasCtrlDep = 1 in {
Chris Lattnerda68d302008-01-15 21:58:22 +0000899def TRAP : I<0x0B, RawFrm, (outs), (ins), "ud2", [(trap)]>, TB;
Anton Korobeynikov66fac792008-01-15 07:02:33 +0000900}
901
Chris Lattner02552de2009-08-11 16:58:39 +0000902def SYSCALL : I<0x05, RawFrm,
903 (outs), (ins), "syscall", []>, TB;
904def SYSRET : I<0x07, RawFrm,
905 (outs), (ins), "sysret", []>, TB;
906def SYSENTER : I<0x34, RawFrm,
907 (outs), (ins), "sysenter", []>, TB;
908def SYSEXIT : I<0x35, RawFrm,
909 (outs), (ins), "sysexit", []>, TB;
910
Sean Callanan2a46f362009-09-12 02:52:41 +0000911def WAIT : I<0x9B, RawFrm, (outs), (ins), "wait", []>;
Chris Lattner02552de2009-08-11 16:58:39 +0000912
913
Chris Lattner1cca5e32003-08-03 21:54:21 +0000914//===----------------------------------------------------------------------===//
John Criswell4ffff9e2004-04-08 20:31:47 +0000915// Input/Output Instructions...
916//
Evan Cheng071a2792007-09-11 19:55:27 +0000917let Defs = [AL], Uses = [DX] in
Evan Cheng64d80e32007-07-19 01:14:50 +0000918def IN8rr : I<0xEC, RawFrm, (outs), (ins),
Evan Cheng071a2792007-09-11 19:55:27 +0000919 "in{b}\t{%dx, %al|%AL, %DX}", []>;
920let Defs = [AX], Uses = [DX] in
Evan Cheng64d80e32007-07-19 01:14:50 +0000921def IN16rr : I<0xED, RawFrm, (outs), (ins),
Evan Cheng071a2792007-09-11 19:55:27 +0000922 "in{w}\t{%dx, %ax|%AX, %DX}", []>, OpSize;
923let Defs = [EAX], Uses = [DX] in
Evan Cheng64d80e32007-07-19 01:14:50 +0000924def IN32rr : I<0xED, RawFrm, (outs), (ins),
Evan Cheng071a2792007-09-11 19:55:27 +0000925 "in{l}\t{%dx, %eax|%EAX, %DX}", []>;
John Criswell4ffff9e2004-04-08 20:31:47 +0000926
Evan Cheng071a2792007-09-11 19:55:27 +0000927let Defs = [AL] in
Evan Cheng64d80e32007-07-19 01:14:50 +0000928def IN8ri : Ii8<0xE4, RawFrm, (outs), (ins i16i8imm:$port),
Evan Cheng071a2792007-09-11 19:55:27 +0000929 "in{b}\t{$port, %al|%AL, $port}", []>;
930let Defs = [AX] in
Evan Cheng64d80e32007-07-19 01:14:50 +0000931def IN16ri : Ii8<0xE5, RawFrm, (outs), (ins i16i8imm:$port),
Evan Cheng071a2792007-09-11 19:55:27 +0000932 "in{w}\t{$port, %ax|%AX, $port}", []>, OpSize;
933let Defs = [EAX] in
Evan Cheng64d80e32007-07-19 01:14:50 +0000934def IN32ri : Ii8<0xE5, RawFrm, (outs), (ins i16i8imm:$port),
Evan Cheng071a2792007-09-11 19:55:27 +0000935 "in{l}\t{$port, %eax|%EAX, $port}", []>;
Chris Lattner440bbc22004-04-13 17:19:31 +0000936
Evan Cheng071a2792007-09-11 19:55:27 +0000937let Uses = [DX, AL] in
Evan Cheng64d80e32007-07-19 01:14:50 +0000938def OUT8rr : I<0xEE, RawFrm, (outs), (ins),
Evan Cheng071a2792007-09-11 19:55:27 +0000939 "out{b}\t{%al, %dx|%DX, %AL}", []>;
940let Uses = [DX, AX] in
Evan Cheng64d80e32007-07-19 01:14:50 +0000941def OUT16rr : I<0xEF, RawFrm, (outs), (ins),
Evan Cheng071a2792007-09-11 19:55:27 +0000942 "out{w}\t{%ax, %dx|%DX, %AX}", []>, OpSize;
943let Uses = [DX, EAX] in
Evan Cheng64d80e32007-07-19 01:14:50 +0000944def OUT32rr : I<0xEF, RawFrm, (outs), (ins),
Evan Cheng071a2792007-09-11 19:55:27 +0000945 "out{l}\t{%eax, %dx|%DX, %EAX}", []>;
Chris Lattnerffff7082004-08-01 07:44:35 +0000946
Evan Cheng071a2792007-09-11 19:55:27 +0000947let Uses = [AL] in
Evan Cheng64d80e32007-07-19 01:14:50 +0000948def OUT8ir : Ii8<0xE6, RawFrm, (outs), (ins i16i8imm:$port),
Evan Cheng071a2792007-09-11 19:55:27 +0000949 "out{b}\t{%al, $port|$port, %AL}", []>;
950let Uses = [AX] in
Evan Cheng64d80e32007-07-19 01:14:50 +0000951def OUT16ir : Ii8<0xE7, RawFrm, (outs), (ins i16i8imm:$port),
Evan Cheng071a2792007-09-11 19:55:27 +0000952 "out{w}\t{%ax, $port|$port, %AX}", []>, OpSize;
953let Uses = [EAX] in
Evan Cheng64d80e32007-07-19 01:14:50 +0000954def OUT32ir : Ii8<0xE7, RawFrm, (outs), (ins i16i8imm:$port),
Evan Cheng071a2792007-09-11 19:55:27 +0000955 "out{l}\t{%eax, $port|$port, %EAX}", []>;
John Criswell4ffff9e2004-04-08 20:31:47 +0000956
Sean Callanan108934c2009-12-18 00:01:26 +0000957def IN8 : I<0x6C, RawFrm, (outs), (ins),
958 "ins{b}", []>;
959def IN16 : I<0x6D, RawFrm, (outs), (ins),
960 "ins{w}", []>, OpSize;
961def IN32 : I<0x6D, RawFrm, (outs), (ins),
962 "ins{l}", []>;
963
John Criswell4ffff9e2004-04-08 20:31:47 +0000964//===----------------------------------------------------------------------===//
Chris Lattner1cca5e32003-08-03 21:54:21 +0000965// Move Instructions...
966//
Chris Lattnerba7e7562008-01-10 07:59:24 +0000967let neverHasSideEffects = 1 in {
Evan Cheng64d80e32007-07-19 01:14:50 +0000968def MOV8rr : I<0x88, MRMDestReg, (outs GR8 :$dst), (ins GR8 :$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000969 "mov{b}\t{$src, $dst|$dst, $src}", []>;
Evan Cheng64d80e32007-07-19 01:14:50 +0000970def MOV16rr : I<0x89, MRMDestReg, (outs GR16:$dst), (ins GR16:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000971 "mov{w}\t{$src, $dst|$dst, $src}", []>, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +0000972def MOV32rr : I<0x89, MRMDestReg, (outs GR32:$dst), (ins GR32:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000973 "mov{l}\t{$src, $dst|$dst, $src}", []>;
Chris Lattnerba7e7562008-01-10 07:59:24 +0000974}
Evan Cheng359e9372008-06-18 08:13:07 +0000975let isReMaterializable = 1, isAsCheapAsAMove = 1 in {
Evan Cheng64d80e32007-07-19 01:14:50 +0000976def MOV8ri : Ii8 <0xB0, AddRegFrm, (outs GR8 :$dst), (ins i8imm :$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000977 "mov{b}\t{$src, $dst|$dst, $src}",
Evan Cheng069287d2006-05-16 07:21:53 +0000978 [(set GR8:$dst, imm:$src)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +0000979def MOV16ri : Ii16<0xB8, AddRegFrm, (outs GR16:$dst), (ins i16imm:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000980 "mov{w}\t{$src, $dst|$dst, $src}",
Evan Cheng069287d2006-05-16 07:21:53 +0000981 [(set GR16:$dst, imm:$src)]>, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +0000982def MOV32ri : Ii32<0xB8, AddRegFrm, (outs GR32:$dst), (ins i32imm:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000983 "mov{l}\t{$src, $dst|$dst, $src}",
Evan Cheng069287d2006-05-16 07:21:53 +0000984 [(set GR32:$dst, imm:$src)]>;
Dan Gohmand45eddd2007-06-26 00:48:07 +0000985}
Kevin Enderby12ce0de2010-02-03 21:04:42 +0000986
Evan Cheng64d80e32007-07-19 01:14:50 +0000987def MOV8mi : Ii8 <0xC6, MRM0m, (outs), (ins i8mem :$dst, i8imm :$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000988 "mov{b}\t{$src, $dst|$dst, $src}",
Evan Chengb51a0592005-12-10 00:48:20 +0000989 [(store (i8 imm:$src), addr:$dst)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +0000990def MOV16mi : Ii16<0xC7, MRM0m, (outs), (ins i16mem:$dst, i16imm:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000991 "mov{w}\t{$src, $dst|$dst, $src}",
Evan Chengb51a0592005-12-10 00:48:20 +0000992 [(store (i16 imm:$src), addr:$dst)]>, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +0000993def MOV32mi : Ii32<0xC7, MRM0m, (outs), (ins i32mem:$dst, i32imm:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000994 "mov{l}\t{$src, $dst|$dst, $src}",
Evan Chengb51a0592005-12-10 00:48:20 +0000995 [(store (i32 imm:$src), addr:$dst)]>;
Chris Lattner1cca5e32003-08-03 21:54:21 +0000996
Sean Callanan108934c2009-12-18 00:01:26 +0000997def MOV8o8a : Ii8 <0xA0, RawFrm, (outs), (ins offset8:$src),
Sean Callanan2f34a132009-09-10 18:33:42 +0000998 "mov{b}\t{$src, %al|%al, $src}", []>;
Sean Callanan108934c2009-12-18 00:01:26 +0000999def MOV16o16a : Ii16 <0xA1, RawFrm, (outs), (ins offset16:$src),
Sean Callanan2f34a132009-09-10 18:33:42 +00001000 "mov{w}\t{$src, %ax|%ax, $src}", []>, OpSize;
Sean Callanan108934c2009-12-18 00:01:26 +00001001def MOV32o32a : Ii32 <0xA1, RawFrm, (outs), (ins offset32:$src),
Sean Callanan2f34a132009-09-10 18:33:42 +00001002 "mov{l}\t{$src, %eax|%eax, $src}", []>;
1003
Sean Callanan108934c2009-12-18 00:01:26 +00001004def MOV8ao8 : Ii8 <0xA2, RawFrm, (outs offset8:$dst), (ins),
Sean Callanan2f34a132009-09-10 18:33:42 +00001005 "mov{b}\t{%al, $dst|$dst, %al}", []>;
Sean Callanan108934c2009-12-18 00:01:26 +00001006def MOV16ao16 : Ii16 <0xA3, RawFrm, (outs offset16:$dst), (ins),
Sean Callanan2f34a132009-09-10 18:33:42 +00001007 "mov{w}\t{%ax, $dst|$dst, %ax}", []>, OpSize;
Sean Callanan108934c2009-12-18 00:01:26 +00001008def MOV32ao32 : Ii32 <0xA3, RawFrm, (outs offset32:$dst), (ins),
Sean Callanan2f34a132009-09-10 18:33:42 +00001009 "mov{l}\t{%eax, $dst|$dst, %eax}", []>;
1010
Sean Callanan38fee0e2009-09-15 18:47:29 +00001011// Moves to and from segment registers
1012def MOV16rs : I<0x8C, MRMDestReg, (outs GR16:$dst), (ins SEGMENT_REG:$src),
1013 "mov{w}\t{$src, $dst|$dst, $src}", []>;
1014def MOV16ms : I<0x8C, MRMDestMem, (outs i16mem:$dst), (ins SEGMENT_REG:$src),
1015 "mov{w}\t{$src, $dst|$dst, $src}", []>;
1016def MOV16sr : I<0x8E, MRMSrcReg, (outs SEGMENT_REG:$dst), (ins GR16:$src),
1017 "mov{w}\t{$src, $dst|$dst, $src}", []>;
1018def MOV16sm : I<0x8E, MRMSrcMem, (outs SEGMENT_REG:$dst), (ins i16mem:$src),
1019 "mov{w}\t{$src, $dst|$dst, $src}", []>;
1020
Sean Callanan108934c2009-12-18 00:01:26 +00001021def MOV8rr_REV : I<0x8A, MRMSrcReg, (outs GR8:$dst), (ins GR8:$src),
1022 "mov{b}\t{$src, $dst|$dst, $src}", []>;
1023def MOV16rr_REV : I<0x8B, MRMSrcReg, (outs GR16:$dst), (ins GR16:$src),
1024 "mov{w}\t{$src, $dst|$dst, $src}", []>, OpSize;
1025def MOV32rr_REV : I<0x8B, MRMSrcReg, (outs GR32:$dst), (ins GR32:$src),
1026 "mov{l}\t{$src, $dst|$dst, $src}", []>;
1027
Dan Gohmanbc9d98b2010-02-27 23:47:46 +00001028let canFoldAsLoad = 1, isReMaterializable = 1 in {
Evan Cheng64d80e32007-07-19 01:14:50 +00001029def MOV8rm : I<0x8A, MRMSrcMem, (outs GR8 :$dst), (ins i8mem :$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001030 "mov{b}\t{$src, $dst|$dst, $src}",
Chris Lattnerc2406f22009-04-10 00:16:23 +00001031 [(set GR8:$dst, (loadi8 addr:$src))]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00001032def MOV16rm : I<0x8B, MRMSrcMem, (outs GR16:$dst), (ins i16mem:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001033 "mov{w}\t{$src, $dst|$dst, $src}",
Chris Lattnerc2406f22009-04-10 00:16:23 +00001034 [(set GR16:$dst, (loadi16 addr:$src))]>, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00001035def MOV32rm : I<0x8B, MRMSrcMem, (outs GR32:$dst), (ins i32mem:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001036 "mov{l}\t{$src, $dst|$dst, $src}",
Chris Lattnerc2406f22009-04-10 00:16:23 +00001037 [(set GR32:$dst, (loadi32 addr:$src))]>;
Evan Cheng2f394262007-08-30 05:49:43 +00001038}
Chris Lattner1cca5e32003-08-03 21:54:21 +00001039
Evan Cheng64d80e32007-07-19 01:14:50 +00001040def MOV8mr : I<0x88, MRMDestMem, (outs), (ins i8mem :$dst, GR8 :$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001041 "mov{b}\t{$src, $dst|$dst, $src}",
Evan Cheng069287d2006-05-16 07:21:53 +00001042 [(store GR8:$src, addr:$dst)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00001043def MOV16mr : I<0x89, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001044 "mov{w}\t{$src, $dst|$dst, $src}",
Evan Cheng069287d2006-05-16 07:21:53 +00001045 [(store GR16:$src, addr:$dst)]>, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00001046def MOV32mr : I<0x89, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001047 "mov{l}\t{$src, $dst|$dst, $src}",
Evan Cheng069287d2006-05-16 07:21:53 +00001048 [(store GR32:$src, addr:$dst)]>;
Dan Gohman21e3dfb2009-04-13 16:09:41 +00001049
Evan Chengf48ef032010-03-14 03:48:46 +00001050/// Versions of MOV32rr, MOV32rm, and MOV32mr for i32mem_TC and GR32_TC.
1051let neverHasSideEffects = 1 in
1052def MOV32rr_TC : I<0x89, MRMDestReg, (outs GR32_TC:$dst), (ins GR32_TC:$src),
1053 "mov{l}\t{$src, $dst|$dst, $src}", []>;
1054
1055let mayLoad = 1,
1056 canFoldAsLoad = 1, isReMaterializable = 1 in
1057def MOV32rm_TC : I<0x8B, MRMSrcMem, (outs GR32_TC:$dst), (ins i32mem_TC:$src),
1058 "mov{l}\t{$src, $dst|$dst, $src}",
1059 []>;
1060
1061let mayStore = 1 in
1062def MOV32mr_TC : I<0x89, MRMDestMem, (outs), (ins i32mem_TC:$dst, GR32_TC:$src),
1063 "mov{l}\t{$src, $dst|$dst, $src}",
1064 []>;
1065
Dan Gohman4af325d2009-04-27 16:41:36 +00001066// Versions of MOV8rr, MOV8mr, and MOV8rm that use i8mem_NOREX and GR8_NOREX so
1067// that they can be used for copying and storing h registers, which can't be
1068// encoded when a REX prefix is present.
Dan Gohman6d9305c2009-04-15 00:04:23 +00001069let neverHasSideEffects = 1 in
Dan Gohmandf7dfc72009-04-15 19:48:57 +00001070def MOV8rr_NOREX : I<0x88, MRMDestReg,
1071 (outs GR8_NOREX:$dst), (ins GR8_NOREX:$src),
Dan Gohman6d9305c2009-04-15 00:04:23 +00001072 "mov{b}\t{$src, $dst|$dst, $src} # NOREX", []>;
Evan Cheng8c147402009-04-30 00:58:57 +00001073let mayStore = 1 in
Dan Gohman6d9305c2009-04-15 00:04:23 +00001074def MOV8mr_NOREX : I<0x88, MRMDestMem,
1075 (outs), (ins i8mem_NOREX:$dst, GR8_NOREX:$src),
1076 "mov{b}\t{$src, $dst|$dst, $src} # NOREX", []>;
Evan Cheng8c147402009-04-30 00:58:57 +00001077let mayLoad = 1,
Dan Gohmanbc9d98b2010-02-27 23:47:46 +00001078 canFoldAsLoad = 1, isReMaterializable = 1 in
Dan Gohman4af325d2009-04-27 16:41:36 +00001079def MOV8rm_NOREX : I<0x8A, MRMSrcMem,
1080 (outs GR8_NOREX:$dst), (ins i8mem_NOREX:$src),
1081 "mov{b}\t{$src, $dst|$dst, $src} # NOREX", []>;
Dan Gohman21e3dfb2009-04-13 16:09:41 +00001082
Sean Callanan108934c2009-12-18 00:01:26 +00001083// Moves to and from debug registers
1084def MOV32rd : I<0x21, MRMDestReg, (outs GR32:$dst), (ins DEBUG_REG:$src),
1085 "mov{l}\t{$src, $dst|$dst, $src}", []>, TB;
1086def MOV32dr : I<0x23, MRMSrcReg, (outs DEBUG_REG:$dst), (ins GR32:$src),
1087 "mov{l}\t{$src, $dst|$dst, $src}", []>, TB;
1088
1089// Moves to and from control registers
1090def MOV32rc : I<0x20, MRMDestReg, (outs GR32:$dst), (ins CONTROL_REG_32:$src),
1091 "mov{q}\t{$src, $dst|$dst, $src}", []>, TB;
1092def MOV32cr : I<0x22, MRMSrcReg, (outs CONTROL_REG_32:$dst), (ins GR32:$src),
1093 "mov{q}\t{$src, $dst|$dst, $src}", []>, TB;
1094
Chris Lattner1cca5e32003-08-03 21:54:21 +00001095//===----------------------------------------------------------------------===//
1096// Fixed-Register Multiplication and Division Instructions...
1097//
Chris Lattner1cca5e32003-08-03 21:54:21 +00001098
Chris Lattnerc8f45872003-08-04 04:59:56 +00001099// Extra precision multiplication
Jakob Stoklund Olesen3cfe0102010-03-04 20:42:07 +00001100
1101// AL is really implied by AX, by the registers in Defs must match the
1102// SDNode results (i8, i32).
1103let Defs = [AL,EFLAGS,AX], Uses = [AL] in
Dan Gohmanb1576f52007-07-31 20:11:57 +00001104def MUL8r : I<0xF6, MRM4r, (outs), (ins GR8:$src), "mul{b}\t$src",
Evan Chengcf74a7c2006-01-15 10:05:20 +00001105 // FIXME: Used for 8-bit mul, ignore result upper 8 bits.
1106 // This probably ought to be moved to a def : Pat<> if the
1107 // syntax can be accepted.
Bill Wendlingd350e022008-12-12 21:15:41 +00001108 [(set AL, (mul AL, GR8:$src)),
1109 (implicit EFLAGS)]>; // AL,AH = AL*GR8
1110
Chris Lattnera731c9f2008-01-11 07:18:17 +00001111let Defs = [AX,DX,EFLAGS], Uses = [AX], neverHasSideEffects = 1 in
Bill Wendlingd350e022008-12-12 21:15:41 +00001112def MUL16r : I<0xF7, MRM4r, (outs), (ins GR16:$src),
1113 "mul{w}\t$src",
1114 []>, OpSize; // AX,DX = AX*GR16
1115
Chris Lattnera731c9f2008-01-11 07:18:17 +00001116let Defs = [EAX,EDX,EFLAGS], Uses = [EAX], neverHasSideEffects = 1 in
Bill Wendlingd350e022008-12-12 21:15:41 +00001117def MUL32r : I<0xF7, MRM4r, (outs), (ins GR32:$src),
1118 "mul{l}\t$src",
1119 []>; // EAX,EDX = EAX*GR32
1120
Jakob Stoklund Olesen3cfe0102010-03-04 20:42:07 +00001121let Defs = [AL,EFLAGS,AX], Uses = [AL] in
Evan Cheng64d80e32007-07-19 01:14:50 +00001122def MUL8m : I<0xF6, MRM4m, (outs), (ins i8mem :$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001123 "mul{b}\t$src",
Evan Chengcf74a7c2006-01-15 10:05:20 +00001124 // FIXME: Used for 8-bit mul, ignore result upper 8 bits.
1125 // This probably ought to be moved to a def : Pat<> if the
1126 // syntax can be accepted.
Bill Wendlingd350e022008-12-12 21:15:41 +00001127 [(set AL, (mul AL, (loadi8 addr:$src))),
1128 (implicit EFLAGS)]>; // AL,AH = AL*[mem8]
1129
Chris Lattnerba7e7562008-01-10 07:59:24 +00001130let mayLoad = 1, neverHasSideEffects = 1 in {
Evan Cheng24f2ea32007-09-14 21:48:26 +00001131let Defs = [AX,DX,EFLAGS], Uses = [AX] in
Evan Cheng64d80e32007-07-19 01:14:50 +00001132def MUL16m : I<0xF7, MRM4m, (outs), (ins i16mem:$src),
Bill Wendlingd350e022008-12-12 21:15:41 +00001133 "mul{w}\t$src",
1134 []>, OpSize; // AX,DX = AX*[mem16]
1135
Evan Cheng24f2ea32007-09-14 21:48:26 +00001136let Defs = [EAX,EDX,EFLAGS], Uses = [EAX] in
Evan Cheng64d80e32007-07-19 01:14:50 +00001137def MUL32m : I<0xF7, MRM4m, (outs), (ins i32mem:$src),
Bill Wendlingd350e022008-12-12 21:15:41 +00001138 "mul{l}\t$src",
1139 []>; // EAX,EDX = EAX*[mem32]
Chris Lattnerba7e7562008-01-10 07:59:24 +00001140}
Chris Lattner1cca5e32003-08-03 21:54:21 +00001141
Chris Lattnerba7e7562008-01-10 07:59:24 +00001142let neverHasSideEffects = 1 in {
Jakob Stoklund Olesen3cfe0102010-03-04 20:42:07 +00001143let Defs = [AL,EFLAGS,AX], Uses = [AL] in
Evan Cheng071a2792007-09-11 19:55:27 +00001144def IMUL8r : I<0xF6, MRM5r, (outs), (ins GR8:$src), "imul{b}\t$src", []>;
1145 // AL,AH = AL*GR8
Evan Cheng24f2ea32007-09-14 21:48:26 +00001146let Defs = [AX,DX,EFLAGS], Uses = [AX] in
Dan Gohmanb1576f52007-07-31 20:11:57 +00001147def IMUL16r : I<0xF7, MRM5r, (outs), (ins GR16:$src), "imul{w}\t$src", []>,
Evan Cheng071a2792007-09-11 19:55:27 +00001148 OpSize; // AX,DX = AX*GR16
Evan Cheng24f2ea32007-09-14 21:48:26 +00001149let Defs = [EAX,EDX,EFLAGS], Uses = [EAX] in
Evan Cheng071a2792007-09-11 19:55:27 +00001150def IMUL32r : I<0xF7, MRM5r, (outs), (ins GR32:$src), "imul{l}\t$src", []>;
1151 // EAX,EDX = EAX*GR32
Chris Lattnerba7e7562008-01-10 07:59:24 +00001152let mayLoad = 1 in {
Jakob Stoklund Olesen3cfe0102010-03-04 20:42:07 +00001153let Defs = [AL,EFLAGS,AX], Uses = [AL] in
Evan Cheng64d80e32007-07-19 01:14:50 +00001154def IMUL8m : I<0xF6, MRM5m, (outs), (ins i8mem :$src),
Evan Cheng071a2792007-09-11 19:55:27 +00001155 "imul{b}\t$src", []>; // AL,AH = AL*[mem8]
Evan Cheng24f2ea32007-09-14 21:48:26 +00001156let Defs = [AX,DX,EFLAGS], Uses = [AX] in
Evan Cheng64d80e32007-07-19 01:14:50 +00001157def IMUL16m : I<0xF7, MRM5m, (outs), (ins i16mem:$src),
Evan Cheng071a2792007-09-11 19:55:27 +00001158 "imul{w}\t$src", []>, OpSize; // AX,DX = AX*[mem16]
Eli Friedmanba7b1c42009-12-26 20:08:30 +00001159let Defs = [EAX,EDX,EFLAGS], Uses = [EAX] in
Evan Cheng64d80e32007-07-19 01:14:50 +00001160def IMUL32m : I<0xF7, MRM5m, (outs), (ins i32mem:$src),
Evan Cheng071a2792007-09-11 19:55:27 +00001161 "imul{l}\t$src", []>; // EAX,EDX = EAX*[mem32]
Chris Lattnerba7e7562008-01-10 07:59:24 +00001162}
Dan Gohmanc99da132008-11-18 21:29:14 +00001163} // neverHasSideEffects
Chris Lattner1e6a7152005-04-06 04:19:22 +00001164
Chris Lattnerc8f45872003-08-04 04:59:56 +00001165// unsigned division/remainder
Jakob Stoklund Olesen3cfe0102010-03-04 20:42:07 +00001166let Defs = [AL,EFLAGS,AX], Uses = [AX] in
Sean Callanan108934c2009-12-18 00:01:26 +00001167def DIV8r : I<0xF6, MRM6r, (outs), (ins GR8:$src), // AX/r8 = AL,AH
Evan Cheng071a2792007-09-11 19:55:27 +00001168 "div{b}\t$src", []>;
Evan Cheng24f2ea32007-09-14 21:48:26 +00001169let Defs = [AX,DX,EFLAGS], Uses = [AX,DX] in
Sean Callanan108934c2009-12-18 00:01:26 +00001170def DIV16r : I<0xF7, MRM6r, (outs), (ins GR16:$src), // DX:AX/r16 = AX,DX
Evan Cheng071a2792007-09-11 19:55:27 +00001171 "div{w}\t$src", []>, OpSize;
Evan Cheng24f2ea32007-09-14 21:48:26 +00001172let Defs = [EAX,EDX,EFLAGS], Uses = [EAX,EDX] in
Sean Callanan108934c2009-12-18 00:01:26 +00001173def DIV32r : I<0xF7, MRM6r, (outs), (ins GR32:$src), // EDX:EAX/r32 = EAX,EDX
Evan Cheng071a2792007-09-11 19:55:27 +00001174 "div{l}\t$src", []>;
Chris Lattnerba7e7562008-01-10 07:59:24 +00001175let mayLoad = 1 in {
Jakob Stoklund Olesen3cfe0102010-03-04 20:42:07 +00001176let Defs = [AL,EFLAGS,AX], Uses = [AX] in
Sean Callanan108934c2009-12-18 00:01:26 +00001177def DIV8m : I<0xF6, MRM6m, (outs), (ins i8mem:$src), // AX/[mem8] = AL,AH
Evan Cheng071a2792007-09-11 19:55:27 +00001178 "div{b}\t$src", []>;
Evan Cheng24f2ea32007-09-14 21:48:26 +00001179let Defs = [AX,DX,EFLAGS], Uses = [AX,DX] in
Sean Callanan108934c2009-12-18 00:01:26 +00001180def DIV16m : I<0xF7, MRM6m, (outs), (ins i16mem:$src), // DX:AX/[mem16] = AX,DX
Evan Cheng071a2792007-09-11 19:55:27 +00001181 "div{w}\t$src", []>, OpSize;
Evan Cheng24f2ea32007-09-14 21:48:26 +00001182let Defs = [EAX,EDX,EFLAGS], Uses = [EAX,EDX] in
Sean Callanan108934c2009-12-18 00:01:26 +00001183 // EDX:EAX/[mem32] = EAX,EDX
1184def DIV32m : I<0xF7, MRM6m, (outs), (ins i32mem:$src),
Evan Cheng071a2792007-09-11 19:55:27 +00001185 "div{l}\t$src", []>;
Chris Lattnerba7e7562008-01-10 07:59:24 +00001186}
Chris Lattner1cca5e32003-08-03 21:54:21 +00001187
Chris Lattnerfc752712004-08-01 09:52:59 +00001188// Signed division/remainder.
Jakob Stoklund Olesen3cfe0102010-03-04 20:42:07 +00001189let Defs = [AL,EFLAGS,AX], Uses = [AX] in
Sean Callanan108934c2009-12-18 00:01:26 +00001190def IDIV8r : I<0xF6, MRM7r, (outs), (ins GR8:$src), // AX/r8 = AL,AH
Evan Cheng071a2792007-09-11 19:55:27 +00001191 "idiv{b}\t$src", []>;
Evan Cheng24f2ea32007-09-14 21:48:26 +00001192let Defs = [AX,DX,EFLAGS], Uses = [AX,DX] in
Sean Callanan108934c2009-12-18 00:01:26 +00001193def IDIV16r: I<0xF7, MRM7r, (outs), (ins GR16:$src), // DX:AX/r16 = AX,DX
Evan Cheng071a2792007-09-11 19:55:27 +00001194 "idiv{w}\t$src", []>, OpSize;
Evan Cheng24f2ea32007-09-14 21:48:26 +00001195let Defs = [EAX,EDX,EFLAGS], Uses = [EAX,EDX] in
Sean Callanan108934c2009-12-18 00:01:26 +00001196def IDIV32r: I<0xF7, MRM7r, (outs), (ins GR32:$src), // EDX:EAX/r32 = EAX,EDX
Evan Cheng071a2792007-09-11 19:55:27 +00001197 "idiv{l}\t$src", []>;
Chris Lattnerba7e7562008-01-10 07:59:24 +00001198let mayLoad = 1, mayLoad = 1 in {
Jakob Stoklund Olesen3cfe0102010-03-04 20:42:07 +00001199let Defs = [AL,EFLAGS,AX], Uses = [AX] in
Sean Callanan108934c2009-12-18 00:01:26 +00001200def IDIV8m : I<0xF6, MRM7m, (outs), (ins i8mem:$src), // AX/[mem8] = AL,AH
Evan Cheng071a2792007-09-11 19:55:27 +00001201 "idiv{b}\t$src", []>;
Evan Cheng24f2ea32007-09-14 21:48:26 +00001202let Defs = [AX,DX,EFLAGS], Uses = [AX,DX] in
Sean Callanan108934c2009-12-18 00:01:26 +00001203def IDIV16m: I<0xF7, MRM7m, (outs), (ins i16mem:$src), // DX:AX/[mem16] = AX,DX
Evan Cheng071a2792007-09-11 19:55:27 +00001204 "idiv{w}\t$src", []>, OpSize;
Evan Cheng24f2ea32007-09-14 21:48:26 +00001205let Defs = [EAX,EDX,EFLAGS], Uses = [EAX,EDX] in
Sean Callanan108934c2009-12-18 00:01:26 +00001206def IDIV32m: I<0xF7, MRM7m, (outs), (ins i32mem:$src),
1207 // EDX:EAX/[mem32] = EAX,EDX
Evan Cheng071a2792007-09-11 19:55:27 +00001208 "idiv{l}\t$src", []>;
Chris Lattnerba7e7562008-01-10 07:59:24 +00001209}
Chris Lattner1cca5e32003-08-03 21:54:21 +00001210
Chris Lattner1cca5e32003-08-03 21:54:21 +00001211//===----------------------------------------------------------------------===//
Chris Lattnerba7e7562008-01-10 07:59:24 +00001212// Two address Instructions.
Chris Lattner1cca5e32003-08-03 21:54:21 +00001213//
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00001214let isTwoAddress = 1 in {
Chris Lattner1cca5e32003-08-03 21:54:21 +00001215
Alkis Evlogimenosa3f66842004-03-12 17:59:56 +00001216// Conditional moves
Evan Cheng0488db92007-09-25 01:57:46 +00001217let Uses = [EFLAGS] in {
Dan Gohmancbbea0f2009-08-27 00:14:12 +00001218
Chris Lattner314a1132010-03-14 18:31:44 +00001219let Predicates = [HasCMov] in {
Dan Gohmana4c5c332009-08-27 18:16:24 +00001220let isCommutable = 1 in {
Evan Cheng069287d2006-05-16 07:21:53 +00001221def CMOVB16rr : I<0x42, MRMSrcReg, // if <u, GR16 = GR16
Evan Cheng64d80e32007-07-19 01:14:50 +00001222 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Sean Callanan108934c2009-12-18 00:01:26 +00001223 "cmovb{w}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001224 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Chenge5f62042007-09-29 00:00:36 +00001225 X86_COND_B, EFLAGS))]>,
Evan Cheng71fb9ad2006-01-26 00:29:36 +00001226 TB, OpSize;
Evan Cheng069287d2006-05-16 07:21:53 +00001227def CMOVB32rr : I<0x42, MRMSrcReg, // if <u, GR32 = GR32
Evan Cheng64d80e32007-07-19 01:14:50 +00001228 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Sean Callanan108934c2009-12-18 00:01:26 +00001229 "cmovb{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001230 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Chenge5f62042007-09-29 00:00:36 +00001231 X86_COND_B, EFLAGS))]>,
Evan Cheng71fb9ad2006-01-26 00:29:36 +00001232 TB;
Evan Cheng069287d2006-05-16 07:21:53 +00001233def CMOVAE16rr: I<0x43, MRMSrcReg, // if >=u, GR16 = GR16
Evan Cheng64d80e32007-07-19 01:14:50 +00001234 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Sean Callanan108934c2009-12-18 00:01:26 +00001235 "cmovae{w}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001236 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Chenge5f62042007-09-29 00:00:36 +00001237 X86_COND_AE, EFLAGS))]>,
Evan Cheng71fb9ad2006-01-26 00:29:36 +00001238 TB, OpSize;
Evan Cheng069287d2006-05-16 07:21:53 +00001239def CMOVAE32rr: I<0x43, MRMSrcReg, // if >=u, GR32 = GR32
Evan Cheng64d80e32007-07-19 01:14:50 +00001240 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Sean Callanan108934c2009-12-18 00:01:26 +00001241 "cmovae{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001242 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Chenge5f62042007-09-29 00:00:36 +00001243 X86_COND_AE, EFLAGS))]>,
Evan Cheng71fb9ad2006-01-26 00:29:36 +00001244 TB;
Evan Cheng069287d2006-05-16 07:21:53 +00001245def CMOVE16rr : I<0x44, MRMSrcReg, // if ==, GR16 = GR16
Evan Cheng64d80e32007-07-19 01:14:50 +00001246 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Sean Callanan108934c2009-12-18 00:01:26 +00001247 "cmove{w}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001248 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Chenge5f62042007-09-29 00:00:36 +00001249 X86_COND_E, EFLAGS))]>,
Evan Cheng71fb9ad2006-01-26 00:29:36 +00001250 TB, OpSize;
Evan Cheng069287d2006-05-16 07:21:53 +00001251def CMOVE32rr : I<0x44, MRMSrcReg, // if ==, GR32 = GR32
Evan Cheng64d80e32007-07-19 01:14:50 +00001252 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Sean Callanan108934c2009-12-18 00:01:26 +00001253 "cmove{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001254 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Chenge5f62042007-09-29 00:00:36 +00001255 X86_COND_E, EFLAGS))]>,
Evan Cheng71fb9ad2006-01-26 00:29:36 +00001256 TB;
Evan Cheng069287d2006-05-16 07:21:53 +00001257def CMOVNE16rr: I<0x45, MRMSrcReg, // if !=, GR16 = GR16
Evan Cheng64d80e32007-07-19 01:14:50 +00001258 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Sean Callanan108934c2009-12-18 00:01:26 +00001259 "cmovne{w}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001260 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Chenge5f62042007-09-29 00:00:36 +00001261 X86_COND_NE, EFLAGS))]>,
Evan Cheng71fb9ad2006-01-26 00:29:36 +00001262 TB, OpSize;
Evan Cheng069287d2006-05-16 07:21:53 +00001263def CMOVNE32rr: I<0x45, MRMSrcReg, // if !=, GR32 = GR32
Evan Cheng64d80e32007-07-19 01:14:50 +00001264 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Sean Callanan108934c2009-12-18 00:01:26 +00001265 "cmovne{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001266 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Chenge5f62042007-09-29 00:00:36 +00001267 X86_COND_NE, EFLAGS))]>,
Evan Cheng71fb9ad2006-01-26 00:29:36 +00001268 TB;
Evan Cheng069287d2006-05-16 07:21:53 +00001269def CMOVBE16rr: I<0x46, MRMSrcReg, // if <=u, GR16 = GR16
Evan Cheng64d80e32007-07-19 01:14:50 +00001270 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Sean Callanan108934c2009-12-18 00:01:26 +00001271 "cmovbe{w}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001272 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Chenge5f62042007-09-29 00:00:36 +00001273 X86_COND_BE, EFLAGS))]>,
Evan Cheng71fb9ad2006-01-26 00:29:36 +00001274 TB, OpSize;
Evan Cheng069287d2006-05-16 07:21:53 +00001275def CMOVBE32rr: I<0x46, MRMSrcReg, // if <=u, GR32 = GR32
Evan Cheng64d80e32007-07-19 01:14:50 +00001276 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Sean Callanan108934c2009-12-18 00:01:26 +00001277 "cmovbe{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001278 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Chenge5f62042007-09-29 00:00:36 +00001279 X86_COND_BE, EFLAGS))]>,
Evan Cheng71fb9ad2006-01-26 00:29:36 +00001280 TB;
Evan Cheng069287d2006-05-16 07:21:53 +00001281def CMOVA16rr : I<0x47, MRMSrcReg, // if >u, GR16 = GR16
Evan Cheng64d80e32007-07-19 01:14:50 +00001282 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Sean Callanan108934c2009-12-18 00:01:26 +00001283 "cmova{w}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001284 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Chenge5f62042007-09-29 00:00:36 +00001285 X86_COND_A, EFLAGS))]>,
Evan Cheng71fb9ad2006-01-26 00:29:36 +00001286 TB, OpSize;
Evan Cheng069287d2006-05-16 07:21:53 +00001287def CMOVA32rr : I<0x47, MRMSrcReg, // if >u, GR32 = GR32
Evan Cheng64d80e32007-07-19 01:14:50 +00001288 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Sean Callanan108934c2009-12-18 00:01:26 +00001289 "cmova{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001290 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Chenge5f62042007-09-29 00:00:36 +00001291 X86_COND_A, EFLAGS))]>,
Evan Cheng71fb9ad2006-01-26 00:29:36 +00001292 TB;
Evan Cheng069287d2006-05-16 07:21:53 +00001293def CMOVL16rr : I<0x4C, MRMSrcReg, // if <s, GR16 = GR16
Evan Cheng64d80e32007-07-19 01:14:50 +00001294 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Sean Callanan108934c2009-12-18 00:01:26 +00001295 "cmovl{w}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001296 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Chenge5f62042007-09-29 00:00:36 +00001297 X86_COND_L, EFLAGS))]>,
Evan Cheng71fb9ad2006-01-26 00:29:36 +00001298 TB, OpSize;
Evan Cheng069287d2006-05-16 07:21:53 +00001299def CMOVL32rr : I<0x4C, MRMSrcReg, // if <s, GR32 = GR32
Evan Cheng64d80e32007-07-19 01:14:50 +00001300 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Sean Callanan108934c2009-12-18 00:01:26 +00001301 "cmovl{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001302 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Chenge5f62042007-09-29 00:00:36 +00001303 X86_COND_L, EFLAGS))]>,
Evan Cheng71fb9ad2006-01-26 00:29:36 +00001304 TB;
Evan Cheng069287d2006-05-16 07:21:53 +00001305def CMOVGE16rr: I<0x4D, MRMSrcReg, // if >=s, GR16 = GR16
Evan Cheng64d80e32007-07-19 01:14:50 +00001306 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Sean Callanan108934c2009-12-18 00:01:26 +00001307 "cmovge{w}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001308 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Chenge5f62042007-09-29 00:00:36 +00001309 X86_COND_GE, EFLAGS))]>,
Evan Cheng71fb9ad2006-01-26 00:29:36 +00001310 TB, OpSize;
Evan Cheng069287d2006-05-16 07:21:53 +00001311def CMOVGE32rr: I<0x4D, MRMSrcReg, // if >=s, GR32 = GR32
Evan Cheng64d80e32007-07-19 01:14:50 +00001312 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Sean Callanan108934c2009-12-18 00:01:26 +00001313 "cmovge{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001314 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Chenge5f62042007-09-29 00:00:36 +00001315 X86_COND_GE, EFLAGS))]>,
Evan Cheng71fb9ad2006-01-26 00:29:36 +00001316 TB;
Evan Cheng069287d2006-05-16 07:21:53 +00001317def CMOVLE16rr: I<0x4E, MRMSrcReg, // if <=s, GR16 = GR16
Evan Cheng64d80e32007-07-19 01:14:50 +00001318 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Sean Callanan108934c2009-12-18 00:01:26 +00001319 "cmovle{w}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001320 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Chenge5f62042007-09-29 00:00:36 +00001321 X86_COND_LE, EFLAGS))]>,
Evan Cheng71fb9ad2006-01-26 00:29:36 +00001322 TB, OpSize;
Evan Cheng069287d2006-05-16 07:21:53 +00001323def CMOVLE32rr: I<0x4E, MRMSrcReg, // if <=s, GR32 = GR32
Evan Cheng64d80e32007-07-19 01:14:50 +00001324 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Sean Callanan108934c2009-12-18 00:01:26 +00001325 "cmovle{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001326 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Chenge5f62042007-09-29 00:00:36 +00001327 X86_COND_LE, EFLAGS))]>,
Evan Cheng71fb9ad2006-01-26 00:29:36 +00001328 TB;
Evan Cheng069287d2006-05-16 07:21:53 +00001329def CMOVG16rr : I<0x4F, MRMSrcReg, // if >s, GR16 = GR16
Evan Cheng64d80e32007-07-19 01:14:50 +00001330 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Sean Callanan108934c2009-12-18 00:01:26 +00001331 "cmovg{w}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001332 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Chenge5f62042007-09-29 00:00:36 +00001333 X86_COND_G, EFLAGS))]>,
Evan Cheng71fb9ad2006-01-26 00:29:36 +00001334 TB, OpSize;
Evan Cheng069287d2006-05-16 07:21:53 +00001335def CMOVG32rr : I<0x4F, MRMSrcReg, // if >s, GR32 = GR32
Evan Cheng64d80e32007-07-19 01:14:50 +00001336 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Sean Callanan108934c2009-12-18 00:01:26 +00001337 "cmovg{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001338 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Chenge5f62042007-09-29 00:00:36 +00001339 X86_COND_G, EFLAGS))]>,
Evan Cheng71fb9ad2006-01-26 00:29:36 +00001340 TB;
Evan Cheng069287d2006-05-16 07:21:53 +00001341def CMOVS16rr : I<0x48, MRMSrcReg, // if signed, GR16 = GR16
Evan Cheng64d80e32007-07-19 01:14:50 +00001342 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Sean Callanan108934c2009-12-18 00:01:26 +00001343 "cmovs{w}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001344 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Chenge5f62042007-09-29 00:00:36 +00001345 X86_COND_S, EFLAGS))]>,
Evan Cheng71fb9ad2006-01-26 00:29:36 +00001346 TB, OpSize;
Evan Cheng069287d2006-05-16 07:21:53 +00001347def CMOVS32rr : I<0x48, MRMSrcReg, // if signed, GR32 = GR32
Evan Cheng64d80e32007-07-19 01:14:50 +00001348 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Sean Callanan108934c2009-12-18 00:01:26 +00001349 "cmovs{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001350 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Chenge5f62042007-09-29 00:00:36 +00001351 X86_COND_S, EFLAGS))]>,
Evan Cheng71fb9ad2006-01-26 00:29:36 +00001352 TB;
Evan Cheng069287d2006-05-16 07:21:53 +00001353def CMOVNS16rr: I<0x49, MRMSrcReg, // if !signed, GR16 = GR16
Evan Cheng64d80e32007-07-19 01:14:50 +00001354 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Sean Callanan108934c2009-12-18 00:01:26 +00001355 "cmovns{w}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001356 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Chenge5f62042007-09-29 00:00:36 +00001357 X86_COND_NS, EFLAGS))]>,
Evan Cheng71fb9ad2006-01-26 00:29:36 +00001358 TB, OpSize;
Evan Cheng069287d2006-05-16 07:21:53 +00001359def CMOVNS32rr: I<0x49, MRMSrcReg, // if !signed, GR32 = GR32
Evan Cheng64d80e32007-07-19 01:14:50 +00001360 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Sean Callanan108934c2009-12-18 00:01:26 +00001361 "cmovns{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001362 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Chenge5f62042007-09-29 00:00:36 +00001363 X86_COND_NS, EFLAGS))]>,
Evan Cheng71fb9ad2006-01-26 00:29:36 +00001364 TB;
Evan Cheng069287d2006-05-16 07:21:53 +00001365def CMOVP16rr : I<0x4A, MRMSrcReg, // if parity, GR16 = GR16
Evan Cheng64d80e32007-07-19 01:14:50 +00001366 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Sean Callanan108934c2009-12-18 00:01:26 +00001367 "cmovp{w}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001368 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Chenge5f62042007-09-29 00:00:36 +00001369 X86_COND_P, EFLAGS))]>,
Evan Cheng71fb9ad2006-01-26 00:29:36 +00001370 TB, OpSize;
Evan Cheng069287d2006-05-16 07:21:53 +00001371def CMOVP32rr : I<0x4A, MRMSrcReg, // if parity, GR32 = GR32
Evan Cheng64d80e32007-07-19 01:14:50 +00001372 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Sean Callanan108934c2009-12-18 00:01:26 +00001373 "cmovp{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001374 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Chenge5f62042007-09-29 00:00:36 +00001375 X86_COND_P, EFLAGS))]>,
Evan Cheng71fb9ad2006-01-26 00:29:36 +00001376 TB;
Evan Cheng069287d2006-05-16 07:21:53 +00001377def CMOVNP16rr : I<0x4B, MRMSrcReg, // if !parity, GR16 = GR16
Evan Cheng64d80e32007-07-19 01:14:50 +00001378 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Sean Callanan108934c2009-12-18 00:01:26 +00001379 "cmovnp{w}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001380 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Chenge5f62042007-09-29 00:00:36 +00001381 X86_COND_NP, EFLAGS))]>,
Evan Cheng71fb9ad2006-01-26 00:29:36 +00001382 TB, OpSize;
Evan Cheng069287d2006-05-16 07:21:53 +00001383def CMOVNP32rr : I<0x4B, MRMSrcReg, // if !parity, GR32 = GR32
Evan Cheng64d80e32007-07-19 01:14:50 +00001384 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Sean Callanan108934c2009-12-18 00:01:26 +00001385 "cmovnp{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001386 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Chenge5f62042007-09-29 00:00:36 +00001387 X86_COND_NP, EFLAGS))]>,
Evan Cheng71fb9ad2006-01-26 00:29:36 +00001388 TB;
Dan Gohman305fceb2009-01-07 00:35:10 +00001389def CMOVO16rr : I<0x40, MRMSrcReg, // if overflow, GR16 = GR16
1390 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Sean Callanan108934c2009-12-18 00:01:26 +00001391 "cmovo{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohman305fceb2009-01-07 00:35:10 +00001392 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
1393 X86_COND_O, EFLAGS))]>,
1394 TB, OpSize;
1395def CMOVO32rr : I<0x40, MRMSrcReg, // if overflow, GR32 = GR32
1396 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Sean Callanan108934c2009-12-18 00:01:26 +00001397 "cmovo{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohman305fceb2009-01-07 00:35:10 +00001398 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
1399 X86_COND_O, EFLAGS))]>,
Evan Cheng0488db92007-09-25 01:57:46 +00001400 TB;
Dan Gohman305fceb2009-01-07 00:35:10 +00001401def CMOVNO16rr : I<0x41, MRMSrcReg, // if !overflow, GR16 = GR16
1402 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Sean Callanan108934c2009-12-18 00:01:26 +00001403 "cmovno{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohman305fceb2009-01-07 00:35:10 +00001404 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
1405 X86_COND_NO, EFLAGS))]>,
1406 TB, OpSize;
1407def CMOVNO32rr : I<0x41, MRMSrcReg, // if !overflow, GR32 = GR32
1408 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Sean Callanan108934c2009-12-18 00:01:26 +00001409 "cmovno{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohman305fceb2009-01-07 00:35:10 +00001410 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
1411 X86_COND_NO, EFLAGS))]>,
1412 TB;
1413} // isCommutable = 1
Evan Cheng7ad42d92007-10-05 23:13:21 +00001414
1415def CMOVB16rm : I<0x42, MRMSrcMem, // if <u, GR16 = [mem16]
1416 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
Sean Callanan108934c2009-12-18 00:01:26 +00001417 "cmovb{w}\t{$src2, $dst|$dst, $src2}",
Evan Cheng7ad42d92007-10-05 23:13:21 +00001418 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1419 X86_COND_B, EFLAGS))]>,
1420 TB, OpSize;
1421def CMOVB32rm : I<0x42, MRMSrcMem, // if <u, GR32 = [mem32]
1422 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Sean Callanan108934c2009-12-18 00:01:26 +00001423 "cmovb{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng7ad42d92007-10-05 23:13:21 +00001424 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1425 X86_COND_B, EFLAGS))]>,
1426 TB;
1427def CMOVAE16rm: I<0x43, MRMSrcMem, // if >=u, GR16 = [mem16]
1428 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
Sean Callanan108934c2009-12-18 00:01:26 +00001429 "cmovae{w}\t{$src2, $dst|$dst, $src2}",
Evan Cheng7ad42d92007-10-05 23:13:21 +00001430 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1431 X86_COND_AE, EFLAGS))]>,
1432 TB, OpSize;
1433def CMOVAE32rm: I<0x43, MRMSrcMem, // if >=u, GR32 = [mem32]
1434 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Sean Callanan108934c2009-12-18 00:01:26 +00001435 "cmovae{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng7ad42d92007-10-05 23:13:21 +00001436 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1437 X86_COND_AE, EFLAGS))]>,
1438 TB;
1439def CMOVE16rm : I<0x44, MRMSrcMem, // if ==, GR16 = [mem16]
1440 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
Sean Callanan108934c2009-12-18 00:01:26 +00001441 "cmove{w}\t{$src2, $dst|$dst, $src2}",
Evan Cheng7ad42d92007-10-05 23:13:21 +00001442 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1443 X86_COND_E, EFLAGS))]>,
1444 TB, OpSize;
1445def CMOVE32rm : I<0x44, MRMSrcMem, // if ==, GR32 = [mem32]
1446 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Sean Callanan108934c2009-12-18 00:01:26 +00001447 "cmove{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng7ad42d92007-10-05 23:13:21 +00001448 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1449 X86_COND_E, EFLAGS))]>,
1450 TB;
1451def CMOVNE16rm: I<0x45, MRMSrcMem, // if !=, GR16 = [mem16]
1452 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
Sean Callanan108934c2009-12-18 00:01:26 +00001453 "cmovne{w}\t{$src2, $dst|$dst, $src2}",
Evan Cheng7ad42d92007-10-05 23:13:21 +00001454 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1455 X86_COND_NE, EFLAGS))]>,
1456 TB, OpSize;
1457def CMOVNE32rm: I<0x45, MRMSrcMem, // if !=, GR32 = [mem32]
1458 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Sean Callanan108934c2009-12-18 00:01:26 +00001459 "cmovne{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng7ad42d92007-10-05 23:13:21 +00001460 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1461 X86_COND_NE, EFLAGS))]>,
1462 TB;
1463def CMOVBE16rm: I<0x46, MRMSrcMem, // if <=u, GR16 = [mem16]
1464 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
Sean Callanan108934c2009-12-18 00:01:26 +00001465 "cmovbe{w}\t{$src2, $dst|$dst, $src2}",
Evan Cheng7ad42d92007-10-05 23:13:21 +00001466 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1467 X86_COND_BE, EFLAGS))]>,
1468 TB, OpSize;
1469def CMOVBE32rm: I<0x46, MRMSrcMem, // if <=u, GR32 = [mem32]
1470 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Sean Callanan108934c2009-12-18 00:01:26 +00001471 "cmovbe{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng7ad42d92007-10-05 23:13:21 +00001472 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1473 X86_COND_BE, EFLAGS))]>,
1474 TB;
1475def CMOVA16rm : I<0x47, MRMSrcMem, // if >u, GR16 = [mem16]
1476 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
Sean Callanan108934c2009-12-18 00:01:26 +00001477 "cmova{w}\t{$src2, $dst|$dst, $src2}",
Evan Cheng7ad42d92007-10-05 23:13:21 +00001478 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1479 X86_COND_A, EFLAGS))]>,
1480 TB, OpSize;
1481def CMOVA32rm : I<0x47, MRMSrcMem, // if >u, GR32 = [mem32]
1482 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Sean Callanan108934c2009-12-18 00:01:26 +00001483 "cmova{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng7ad42d92007-10-05 23:13:21 +00001484 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1485 X86_COND_A, EFLAGS))]>,
1486 TB;
1487def CMOVL16rm : I<0x4C, MRMSrcMem, // if <s, GR16 = [mem16]
1488 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
Sean Callanan108934c2009-12-18 00:01:26 +00001489 "cmovl{w}\t{$src2, $dst|$dst, $src2}",
Evan Cheng7ad42d92007-10-05 23:13:21 +00001490 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1491 X86_COND_L, EFLAGS))]>,
1492 TB, OpSize;
1493def CMOVL32rm : I<0x4C, MRMSrcMem, // if <s, GR32 = [mem32]
1494 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Sean Callanan108934c2009-12-18 00:01:26 +00001495 "cmovl{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng7ad42d92007-10-05 23:13:21 +00001496 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1497 X86_COND_L, EFLAGS))]>,
1498 TB;
1499def CMOVGE16rm: I<0x4D, MRMSrcMem, // if >=s, GR16 = [mem16]
1500 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
Sean Callanan108934c2009-12-18 00:01:26 +00001501 "cmovge{w}\t{$src2, $dst|$dst, $src2}",
Evan Cheng7ad42d92007-10-05 23:13:21 +00001502 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1503 X86_COND_GE, EFLAGS))]>,
1504 TB, OpSize;
1505def CMOVGE32rm: I<0x4D, MRMSrcMem, // if >=s, GR32 = [mem32]
1506 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Sean Callanan108934c2009-12-18 00:01:26 +00001507 "cmovge{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng7ad42d92007-10-05 23:13:21 +00001508 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1509 X86_COND_GE, EFLAGS))]>,
1510 TB;
1511def CMOVLE16rm: I<0x4E, MRMSrcMem, // if <=s, GR16 = [mem16]
1512 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
Sean Callanan108934c2009-12-18 00:01:26 +00001513 "cmovle{w}\t{$src2, $dst|$dst, $src2}",
Evan Cheng7ad42d92007-10-05 23:13:21 +00001514 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1515 X86_COND_LE, EFLAGS))]>,
1516 TB, OpSize;
1517def CMOVLE32rm: I<0x4E, MRMSrcMem, // if <=s, GR32 = [mem32]
1518 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Sean Callanan108934c2009-12-18 00:01:26 +00001519 "cmovle{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng7ad42d92007-10-05 23:13:21 +00001520 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1521 X86_COND_LE, EFLAGS))]>,
1522 TB;
1523def CMOVG16rm : I<0x4F, MRMSrcMem, // if >s, GR16 = [mem16]
1524 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
Sean Callanan108934c2009-12-18 00:01:26 +00001525 "cmovg{w}\t{$src2, $dst|$dst, $src2}",
Evan Cheng7ad42d92007-10-05 23:13:21 +00001526 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1527 X86_COND_G, EFLAGS))]>,
1528 TB, OpSize;
1529def CMOVG32rm : I<0x4F, MRMSrcMem, // if >s, GR32 = [mem32]
1530 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Sean Callanan108934c2009-12-18 00:01:26 +00001531 "cmovg{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng7ad42d92007-10-05 23:13:21 +00001532 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1533 X86_COND_G, EFLAGS))]>,
1534 TB;
1535def CMOVS16rm : I<0x48, MRMSrcMem, // if signed, GR16 = [mem16]
1536 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
Sean Callanan108934c2009-12-18 00:01:26 +00001537 "cmovs{w}\t{$src2, $dst|$dst, $src2}",
Evan Cheng7ad42d92007-10-05 23:13:21 +00001538 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1539 X86_COND_S, EFLAGS))]>,
1540 TB, OpSize;
1541def CMOVS32rm : I<0x48, MRMSrcMem, // if signed, GR32 = [mem32]
1542 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Sean Callanan108934c2009-12-18 00:01:26 +00001543 "cmovs{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng7ad42d92007-10-05 23:13:21 +00001544 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1545 X86_COND_S, EFLAGS))]>,
1546 TB;
1547def CMOVNS16rm: I<0x49, MRMSrcMem, // if !signed, GR16 = [mem16]
1548 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
Sean Callanan108934c2009-12-18 00:01:26 +00001549 "cmovns{w}\t{$src2, $dst|$dst, $src2}",
Evan Cheng7ad42d92007-10-05 23:13:21 +00001550 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1551 X86_COND_NS, EFLAGS))]>,
1552 TB, OpSize;
1553def CMOVNS32rm: I<0x49, MRMSrcMem, // if !signed, GR32 = [mem32]
1554 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Sean Callanan108934c2009-12-18 00:01:26 +00001555 "cmovns{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng7ad42d92007-10-05 23:13:21 +00001556 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1557 X86_COND_NS, EFLAGS))]>,
1558 TB;
1559def CMOVP16rm : I<0x4A, MRMSrcMem, // if parity, GR16 = [mem16]
1560 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
Sean Callanan108934c2009-12-18 00:01:26 +00001561 "cmovp{w}\t{$src2, $dst|$dst, $src2}",
Evan Cheng7ad42d92007-10-05 23:13:21 +00001562 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1563 X86_COND_P, EFLAGS))]>,
1564 TB, OpSize;
1565def CMOVP32rm : I<0x4A, MRMSrcMem, // if parity, GR32 = [mem32]
1566 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Sean Callanan108934c2009-12-18 00:01:26 +00001567 "cmovp{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng7ad42d92007-10-05 23:13:21 +00001568 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1569 X86_COND_P, EFLAGS))]>,
1570 TB;
1571def CMOVNP16rm : I<0x4B, MRMSrcMem, // if !parity, GR16 = [mem16]
1572 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
Sean Callanan108934c2009-12-18 00:01:26 +00001573 "cmovnp{w}\t{$src2, $dst|$dst, $src2}",
Evan Cheng7ad42d92007-10-05 23:13:21 +00001574 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1575 X86_COND_NP, EFLAGS))]>,
1576 TB, OpSize;
Dan Gohman305fceb2009-01-07 00:35:10 +00001577def CMOVNP32rm : I<0x4B, MRMSrcMem, // if !parity, GR32 = [mem32]
1578 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Sean Callanan108934c2009-12-18 00:01:26 +00001579 "cmovnp{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohman305fceb2009-01-07 00:35:10 +00001580 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1581 X86_COND_NP, EFLAGS))]>,
1582 TB;
1583def CMOVO16rm : I<0x40, MRMSrcMem, // if overflow, GR16 = [mem16]
1584 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
Sean Callanan108934c2009-12-18 00:01:26 +00001585 "cmovo{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohman305fceb2009-01-07 00:35:10 +00001586 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1587 X86_COND_O, EFLAGS))]>,
1588 TB, OpSize;
1589def CMOVO32rm : I<0x40, MRMSrcMem, // if overflow, GR32 = [mem32]
1590 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Sean Callanan108934c2009-12-18 00:01:26 +00001591 "cmovo{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohman305fceb2009-01-07 00:35:10 +00001592 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1593 X86_COND_O, EFLAGS))]>,
1594 TB;
1595def CMOVNO16rm : I<0x41, MRMSrcMem, // if !overflow, GR16 = [mem16]
1596 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
Sean Callanan108934c2009-12-18 00:01:26 +00001597 "cmovno{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohman305fceb2009-01-07 00:35:10 +00001598 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1599 X86_COND_NO, EFLAGS))]>,
1600 TB, OpSize;
1601def CMOVNO32rm : I<0x41, MRMSrcMem, // if !overflow, GR32 = [mem32]
1602 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Sean Callanan108934c2009-12-18 00:01:26 +00001603 "cmovno{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohman305fceb2009-01-07 00:35:10 +00001604 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1605 X86_COND_NO, EFLAGS))]>,
1606 TB;
Chris Lattner314a1132010-03-14 18:31:44 +00001607} // Predicates = [HasCMov]
1608
1609// X86 doesn't have 8-bit conditional moves. Use a customInserter to
1610// emit control flow. An alternative to this is to mark i8 SELECT as Promote,
1611// however that requires promoting the operands, and can induce additional
1612// i8 register pressure. Note that CMOV_GR8 is conservatively considered to
1613// clobber EFLAGS, because if one of the operands is zero, the expansion
1614// could involve an xor.
1615let usesCustomInserter = 1, isTwoAddress = 0, Defs = [EFLAGS] in {
1616def CMOV_GR8 : I<0, Pseudo,
1617 (outs GR8:$dst), (ins GR8:$src1, GR8:$src2, i8imm:$cond),
1618 "#CMOV_GR8 PSEUDO!",
1619 [(set GR8:$dst, (X86cmov GR8:$src1, GR8:$src2,
1620 imm:$cond, EFLAGS))]>;
1621
1622let Predicates = [NoCMov] in {
1623def CMOV_GR32 : I<0, Pseudo,
1624 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2, i8imm:$cond),
1625 "#CMOV_GR32* PSEUDO!",
1626 [(set GR32:$dst,
1627 (X86cmov GR32:$src1, GR32:$src2, imm:$cond, EFLAGS))]>;
1628def CMOV_GR16 : I<0, Pseudo,
1629 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2, i8imm:$cond),
1630 "#CMOV_GR16* PSEUDO!",
1631 [(set GR16:$dst,
1632 (X86cmov GR16:$src1, GR16:$src2, imm:$cond, EFLAGS))]>;
1633def CMOV_RFP32 : I<0, Pseudo,
1634 (outs RFP32:$dst), (ins RFP32:$src1, RFP32:$src2, i8imm:$cond),
1635 "#CMOV_RFP32 PSEUDO!",
1636 [(set RFP32:$dst, (X86cmov RFP32:$src1, RFP32:$src2, imm:$cond,
1637 EFLAGS))]>;
1638def CMOV_RFP64 : I<0, Pseudo,
1639 (outs RFP64:$dst), (ins RFP64:$src1, RFP64:$src2, i8imm:$cond),
1640 "#CMOV_RFP64 PSEUDO!",
1641 [(set RFP64:$dst, (X86cmov RFP64:$src1, RFP64:$src2, imm:$cond,
1642 EFLAGS))]>;
1643def CMOV_RFP80 : I<0, Pseudo,
1644 (outs RFP80:$dst), (ins RFP80:$src1, RFP80:$src2, i8imm:$cond),
1645 "#CMOV_RFP80 PSEUDO!",
1646 [(set RFP80:$dst, (X86cmov RFP80:$src1, RFP80:$src2, imm:$cond,
1647 EFLAGS))]>;
1648} // Predicates = [NoCMov]
1649} // UsesCustomInserter = 1, isTwoAddress = 0, Defs = [EFLAGS]
Evan Cheng0488db92007-09-25 01:57:46 +00001650} // Uses = [EFLAGS]
1651
1652
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00001653// unary instructions
Evan Cheng1693e482006-07-19 00:27:29 +00001654let CodeSize = 2 in {
Evan Cheng24f2ea32007-09-14 21:48:26 +00001655let Defs = [EFLAGS] in {
Dan Gohmanb1576f52007-07-31 20:11:57 +00001656def NEG8r : I<0xF6, MRM3r, (outs GR8 :$dst), (ins GR8 :$src), "neg{b}\t$dst",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001657 [(set GR8:$dst, (ineg GR8:$src)),
1658 (implicit EFLAGS)]>;
Dan Gohmanb1576f52007-07-31 20:11:57 +00001659def NEG16r : I<0xF7, MRM3r, (outs GR16:$dst), (ins GR16:$src), "neg{w}\t$dst",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001660 [(set GR16:$dst, (ineg GR16:$src)),
1661 (implicit EFLAGS)]>, OpSize;
Dan Gohmanb1576f52007-07-31 20:11:57 +00001662def NEG32r : I<0xF7, MRM3r, (outs GR32:$dst), (ins GR32:$src), "neg{l}\t$dst",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001663 [(set GR32:$dst, (ineg GR32:$src)),
1664 (implicit EFLAGS)]>;
Chris Lattner57a02302004-08-11 04:31:00 +00001665let isTwoAddress = 0 in {
Dan Gohmanb1576f52007-07-31 20:11:57 +00001666 def NEG8m : I<0xF6, MRM3m, (outs), (ins i8mem :$dst), "neg{b}\t$dst",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001667 [(store (ineg (loadi8 addr:$dst)), addr:$dst),
1668 (implicit EFLAGS)]>;
Dan Gohmanb1576f52007-07-31 20:11:57 +00001669 def NEG16m : I<0xF7, MRM3m, (outs), (ins i16mem:$dst), "neg{w}\t$dst",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001670 [(store (ineg (loadi16 addr:$dst)), addr:$dst),
1671 (implicit EFLAGS)]>, OpSize;
Dan Gohmanb1576f52007-07-31 20:11:57 +00001672 def NEG32m : I<0xF7, MRM3m, (outs), (ins i32mem:$dst), "neg{l}\t$dst",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001673 [(store (ineg (loadi32 addr:$dst)), addr:$dst),
1674 (implicit EFLAGS)]>;
Chris Lattner57a02302004-08-11 04:31:00 +00001675}
Evan Cheng24f2ea32007-09-14 21:48:26 +00001676} // Defs = [EFLAGS]
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00001677
Evan Chengaaf414c2009-01-21 02:09:05 +00001678// Match xor -1 to not. Favors these over a move imm + xor to save code size.
1679let AddedComplexity = 15 in {
Dan Gohmanb1576f52007-07-31 20:11:57 +00001680def NOT8r : I<0xF6, MRM2r, (outs GR8 :$dst), (ins GR8 :$src), "not{b}\t$dst",
Evan Cheng069287d2006-05-16 07:21:53 +00001681 [(set GR8:$dst, (not GR8:$src))]>;
Dan Gohmanb1576f52007-07-31 20:11:57 +00001682def NOT16r : I<0xF7, MRM2r, (outs GR16:$dst), (ins GR16:$src), "not{w}\t$dst",
Evan Cheng069287d2006-05-16 07:21:53 +00001683 [(set GR16:$dst, (not GR16:$src))]>, OpSize;
Dan Gohmanb1576f52007-07-31 20:11:57 +00001684def NOT32r : I<0xF7, MRM2r, (outs GR32:$dst), (ins GR32:$src), "not{l}\t$dst",
Evan Cheng069287d2006-05-16 07:21:53 +00001685 [(set GR32:$dst, (not GR32:$src))]>;
Evan Chengaaf414c2009-01-21 02:09:05 +00001686}
Chris Lattner57a02302004-08-11 04:31:00 +00001687let isTwoAddress = 0 in {
Dan Gohmanb1576f52007-07-31 20:11:57 +00001688 def NOT8m : I<0xF6, MRM2m, (outs), (ins i8mem :$dst), "not{b}\t$dst",
Evan Cheng605c4152005-12-13 01:57:51 +00001689 [(store (not (loadi8 addr:$dst)), addr:$dst)]>;
Dan Gohmanb1576f52007-07-31 20:11:57 +00001690 def NOT16m : I<0xF7, MRM2m, (outs), (ins i16mem:$dst), "not{w}\t$dst",
Evan Cheng605c4152005-12-13 01:57:51 +00001691 [(store (not (loadi16 addr:$dst)), addr:$dst)]>, OpSize;
Dan Gohmanb1576f52007-07-31 20:11:57 +00001692 def NOT32m : I<0xF7, MRM2m, (outs), (ins i32mem:$dst), "not{l}\t$dst",
Evan Cheng605c4152005-12-13 01:57:51 +00001693 [(store (not (loadi32 addr:$dst)), addr:$dst)]>;
Chris Lattner57a02302004-08-11 04:31:00 +00001694}
Evan Cheng1693e482006-07-19 00:27:29 +00001695} // CodeSize
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00001696
Evan Chengb51a0592005-12-10 00:48:20 +00001697// TODO: inc/dec is slow for P4, but fast for Pentium-M.
Evan Cheng24f2ea32007-09-14 21:48:26 +00001698let Defs = [EFLAGS] in {
Evan Cheng1693e482006-07-19 00:27:29 +00001699let CodeSize = 2 in
Dan Gohmanb1576f52007-07-31 20:11:57 +00001700def INC8r : I<0xFE, MRM0r, (outs GR8 :$dst), (ins GR8 :$src), "inc{b}\t$dst",
Chris Lattnerc54a2f12010-03-24 01:02:12 +00001701 [(set GR8:$dst, EFLAGS, (X86inc_flag GR8:$src))]>;
1702
Evan Cheng1693e482006-07-19 00:27:29 +00001703let isConvertibleToThreeAddress = 1, CodeSize = 1 in { // Can xform into LEA.
Sean Callanan108934c2009-12-18 00:01:26 +00001704def INC16r : I<0x40, AddRegFrm, (outs GR16:$dst), (ins GR16:$src),
1705 "inc{w}\t$dst",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001706 [(set GR16:$dst, (add GR16:$src, 1)),
1707 (implicit EFLAGS)]>,
Evan Cheng25ab6902006-09-08 06:48:29 +00001708 OpSize, Requires<[In32BitMode]>;
Sean Callanan108934c2009-12-18 00:01:26 +00001709def INC32r : I<0x40, AddRegFrm, (outs GR32:$dst), (ins GR32:$src),
1710 "inc{l}\t$dst",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001711 [(set GR32:$dst, (add GR32:$src, 1)),
1712 (implicit EFLAGS)]>, Requires<[In32BitMode]>;
Chris Lattnercc65bee2005-01-02 02:35:46 +00001713}
Evan Cheng1693e482006-07-19 00:27:29 +00001714let isTwoAddress = 0, CodeSize = 2 in {
Dan Gohmanb1576f52007-07-31 20:11:57 +00001715 def INC8m : I<0xFE, MRM0m, (outs), (ins i8mem :$dst), "inc{b}\t$dst",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001716 [(store (add (loadi8 addr:$dst), 1), addr:$dst),
1717 (implicit EFLAGS)]>;
Dan Gohmanb1576f52007-07-31 20:11:57 +00001718 def INC16m : I<0xFF, MRM0m, (outs), (ins i16mem:$dst), "inc{w}\t$dst",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001719 [(store (add (loadi16 addr:$dst), 1), addr:$dst),
1720 (implicit EFLAGS)]>,
Evan Cheng66f71632007-10-19 21:23:22 +00001721 OpSize, Requires<[In32BitMode]>;
Dan Gohmanb1576f52007-07-31 20:11:57 +00001722 def INC32m : I<0xFF, MRM0m, (outs), (ins i32mem:$dst), "inc{l}\t$dst",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001723 [(store (add (loadi32 addr:$dst), 1), addr:$dst),
1724 (implicit EFLAGS)]>,
Evan Cheng66f71632007-10-19 21:23:22 +00001725 Requires<[In32BitMode]>;
Chris Lattner57a02302004-08-11 04:31:00 +00001726}
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00001727
Evan Cheng1693e482006-07-19 00:27:29 +00001728let CodeSize = 2 in
Dan Gohmanb1576f52007-07-31 20:11:57 +00001729def DEC8r : I<0xFE, MRM1r, (outs GR8 :$dst), (ins GR8 :$src), "dec{b}\t$dst",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001730 [(set GR8:$dst, (add GR8:$src, -1)),
1731 (implicit EFLAGS)]>;
Evan Cheng1693e482006-07-19 00:27:29 +00001732let isConvertibleToThreeAddress = 1, CodeSize = 1 in { // Can xform into LEA.
Sean Callanan108934c2009-12-18 00:01:26 +00001733def DEC16r : I<0x48, AddRegFrm, (outs GR16:$dst), (ins GR16:$src),
1734 "dec{w}\t$dst",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001735 [(set GR16:$dst, (add GR16:$src, -1)),
1736 (implicit EFLAGS)]>,
Evan Cheng25ab6902006-09-08 06:48:29 +00001737 OpSize, Requires<[In32BitMode]>;
Sean Callanan108934c2009-12-18 00:01:26 +00001738def DEC32r : I<0x48, AddRegFrm, (outs GR32:$dst), (ins GR32:$src),
1739 "dec{l}\t$dst",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001740 [(set GR32:$dst, (add GR32:$src, -1)),
1741 (implicit EFLAGS)]>, Requires<[In32BitMode]>;
Chris Lattnercc65bee2005-01-02 02:35:46 +00001742}
Chris Lattner57a02302004-08-11 04:31:00 +00001743
Evan Cheng1693e482006-07-19 00:27:29 +00001744let isTwoAddress = 0, CodeSize = 2 in {
Dan Gohmanb1576f52007-07-31 20:11:57 +00001745 def DEC8m : I<0xFE, MRM1m, (outs), (ins i8mem :$dst), "dec{b}\t$dst",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001746 [(store (add (loadi8 addr:$dst), -1), addr:$dst),
1747 (implicit EFLAGS)]>;
Dan Gohmanb1576f52007-07-31 20:11:57 +00001748 def DEC16m : I<0xFF, MRM1m, (outs), (ins i16mem:$dst), "dec{w}\t$dst",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001749 [(store (add (loadi16 addr:$dst), -1), addr:$dst),
1750 (implicit EFLAGS)]>,
Evan Cheng66f71632007-10-19 21:23:22 +00001751 OpSize, Requires<[In32BitMode]>;
Dan Gohmanb1576f52007-07-31 20:11:57 +00001752 def DEC32m : I<0xFF, MRM1m, (outs), (ins i32mem:$dst), "dec{l}\t$dst",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001753 [(store (add (loadi32 addr:$dst), -1), addr:$dst),
1754 (implicit EFLAGS)]>,
Evan Cheng66f71632007-10-19 21:23:22 +00001755 Requires<[In32BitMode]>;
Chris Lattner57a02302004-08-11 04:31:00 +00001756}
Evan Cheng24f2ea32007-09-14 21:48:26 +00001757} // Defs = [EFLAGS]
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00001758
1759// Logical operators...
Evan Cheng24f2ea32007-09-14 21:48:26 +00001760let Defs = [EFLAGS] in {
Chris Lattnercc65bee2005-01-02 02:35:46 +00001761let isCommutable = 1 in { // X = AND Y, Z --> X = AND Z, Y
Chris Lattner3a173df2004-10-03 20:35:00 +00001762def AND8rr : I<0x20, MRMDestReg,
Evan Cheng64d80e32007-07-19 01:14:50 +00001763 (outs GR8 :$dst), (ins GR8 :$src1, GR8 :$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001764 "and{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001765 [(set GR8:$dst, (and GR8:$src1, GR8:$src2)),
1766 (implicit EFLAGS)]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00001767def AND16rr : I<0x21, MRMDestReg,
Evan Cheng64d80e32007-07-19 01:14:50 +00001768 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001769 "and{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001770 [(set GR16:$dst, (and GR16:$src1, GR16:$src2)),
1771 (implicit EFLAGS)]>, OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00001772def AND32rr : I<0x21, MRMDestReg,
Evan Cheng64d80e32007-07-19 01:14:50 +00001773 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001774 "and{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001775 [(set GR32:$dst, (and GR32:$src1, GR32:$src2)),
1776 (implicit EFLAGS)]>;
Chris Lattnercc65bee2005-01-02 02:35:46 +00001777}
Chris Lattner57a02302004-08-11 04:31:00 +00001778
Sean Callanan108934c2009-12-18 00:01:26 +00001779// AND instructions with the destination register in REG and the source register
1780// in R/M. Included for the disassembler.
1781def AND8rr_REV : I<0x22, MRMSrcReg, (outs GR8:$dst), (ins GR8:$src1, GR8:$src2),
1782 "and{b}\t{$src2, $dst|$dst, $src2}", []>;
1783def AND16rr_REV : I<0x23, MRMSrcReg, (outs GR16:$dst),
1784 (ins GR16:$src1, GR16:$src2),
1785 "and{w}\t{$src2, $dst|$dst, $src2}", []>, OpSize;
1786def AND32rr_REV : I<0x23, MRMSrcReg, (outs GR32:$dst),
1787 (ins GR32:$src1, GR32:$src2),
1788 "and{l}\t{$src2, $dst|$dst, $src2}", []>;
1789
Chris Lattner3a173df2004-10-03 20:35:00 +00001790def AND8rm : I<0x22, MRMSrcMem,
Evan Cheng64d80e32007-07-19 01:14:50 +00001791 (outs GR8 :$dst), (ins GR8 :$src1, i8mem :$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001792 "and{b}\t{$src2, $dst|$dst, $src2}",
Chris Lattnerc2406f22009-04-10 00:16:23 +00001793 [(set GR8:$dst, (and GR8:$src1, (loadi8 addr:$src2))),
Dan Gohman09a2609e2009-03-03 19:53:46 +00001794 (implicit EFLAGS)]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00001795def AND16rm : I<0x23, MRMSrcMem,
Evan Cheng64d80e32007-07-19 01:14:50 +00001796 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001797 "and{w}\t{$src2, $dst|$dst, $src2}",
Chris Lattnerc2406f22009-04-10 00:16:23 +00001798 [(set GR16:$dst, (and GR16:$src1, (loadi16 addr:$src2))),
Dan Gohman09a2609e2009-03-03 19:53:46 +00001799 (implicit EFLAGS)]>, OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00001800def AND32rm : I<0x23, MRMSrcMem,
Evan Cheng64d80e32007-07-19 01:14:50 +00001801 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001802 "and{l}\t{$src2, $dst|$dst, $src2}",
Chris Lattnerc2406f22009-04-10 00:16:23 +00001803 [(set GR32:$dst, (and GR32:$src1, (loadi32 addr:$src2))),
Dan Gohman09a2609e2009-03-03 19:53:46 +00001804 (implicit EFLAGS)]>;
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00001805
Chris Lattner3a173df2004-10-03 20:35:00 +00001806def AND8ri : Ii8<0x80, MRM4r,
Evan Cheng64d80e32007-07-19 01:14:50 +00001807 (outs GR8 :$dst), (ins GR8 :$src1, i8imm :$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001808 "and{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001809 [(set GR8:$dst, (and GR8:$src1, imm:$src2)),
1810 (implicit EFLAGS)]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00001811def AND16ri : Ii16<0x81, MRM4r,
Evan Cheng64d80e32007-07-19 01:14:50 +00001812 (outs GR16:$dst), (ins GR16:$src1, i16imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001813 "and{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001814 [(set GR16:$dst, (and GR16:$src1, imm:$src2)),
1815 (implicit EFLAGS)]>, OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00001816def AND32ri : Ii32<0x81, MRM4r,
Evan Cheng64d80e32007-07-19 01:14:50 +00001817 (outs GR32:$dst), (ins GR32:$src1, i32imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001818 "and{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001819 [(set GR32:$dst, (and GR32:$src1, imm:$src2)),
1820 (implicit EFLAGS)]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00001821def AND16ri8 : Ii8<0x83, MRM4r,
Evan Cheng64d80e32007-07-19 01:14:50 +00001822 (outs GR16:$dst), (ins GR16:$src1, i16i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001823 "and{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001824 [(set GR16:$dst, (and GR16:$src1, i16immSExt8:$src2)),
1825 (implicit EFLAGS)]>,
Evan Cheng9b6b6422005-12-13 00:14:11 +00001826 OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00001827def AND32ri8 : Ii8<0x83, MRM4r,
Evan Cheng64d80e32007-07-19 01:14:50 +00001828 (outs GR32:$dst), (ins GR32:$src1, i32i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001829 "and{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001830 [(set GR32:$dst, (and GR32:$src1, i32immSExt8:$src2)),
1831 (implicit EFLAGS)]>;
Chris Lattnerf29ed092004-08-11 05:07:25 +00001832
1833let isTwoAddress = 0 in {
Chris Lattner3a173df2004-10-03 20:35:00 +00001834 def AND8mr : I<0x20, MRMDestMem,
Evan Cheng64d80e32007-07-19 01:14:50 +00001835 (outs), (ins i8mem :$dst, GR8 :$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001836 "and{b}\t{$src, $dst|$dst, $src}",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001837 [(store (and (load addr:$dst), GR8:$src), addr:$dst),
1838 (implicit EFLAGS)]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00001839 def AND16mr : I<0x21, MRMDestMem,
Evan Cheng64d80e32007-07-19 01:14:50 +00001840 (outs), (ins i16mem:$dst, GR16:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001841 "and{w}\t{$src, $dst|$dst, $src}",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001842 [(store (and (load addr:$dst), GR16:$src), addr:$dst),
1843 (implicit EFLAGS)]>,
Evan Cheng0ef3a772005-12-13 01:41:36 +00001844 OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00001845 def AND32mr : I<0x21, MRMDestMem,
Evan Cheng64d80e32007-07-19 01:14:50 +00001846 (outs), (ins i32mem:$dst, GR32:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001847 "and{l}\t{$src, $dst|$dst, $src}",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001848 [(store (and (load addr:$dst), GR32:$src), addr:$dst),
1849 (implicit EFLAGS)]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00001850 def AND8mi : Ii8<0x80, MRM4m,
Evan Cheng64d80e32007-07-19 01:14:50 +00001851 (outs), (ins i8mem :$dst, i8imm :$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001852 "and{b}\t{$src, $dst|$dst, $src}",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001853 [(store (and (loadi8 addr:$dst), imm:$src), addr:$dst),
1854 (implicit EFLAGS)]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00001855 def AND16mi : Ii16<0x81, MRM4m,
Evan Cheng64d80e32007-07-19 01:14:50 +00001856 (outs), (ins i16mem:$dst, i16imm:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001857 "and{w}\t{$src, $dst|$dst, $src}",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001858 [(store (and (loadi16 addr:$dst), imm:$src), addr:$dst),
1859 (implicit EFLAGS)]>,
Evan Cheng0ef3a772005-12-13 01:41:36 +00001860 OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00001861 def AND32mi : Ii32<0x81, MRM4m,
Evan Cheng64d80e32007-07-19 01:14:50 +00001862 (outs), (ins i32mem:$dst, i32imm:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001863 "and{l}\t{$src, $dst|$dst, $src}",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001864 [(store (and (loadi32 addr:$dst), imm:$src), addr:$dst),
1865 (implicit EFLAGS)]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00001866 def AND16mi8 : Ii8<0x83, MRM4m,
Evan Cheng64d80e32007-07-19 01:14:50 +00001867 (outs), (ins i16mem:$dst, i16i8imm :$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001868 "and{w}\t{$src, $dst|$dst, $src}",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001869 [(store (and (load addr:$dst), i16immSExt8:$src), addr:$dst),
1870 (implicit EFLAGS)]>,
Evan Cheng0ef3a772005-12-13 01:41:36 +00001871 OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00001872 def AND32mi8 : Ii8<0x83, MRM4m,
Evan Cheng64d80e32007-07-19 01:14:50 +00001873 (outs), (ins i32mem:$dst, i32i8imm :$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001874 "and{l}\t{$src, $dst|$dst, $src}",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001875 [(store (and (load addr:$dst), i32immSExt8:$src), addr:$dst),
1876 (implicit EFLAGS)]>;
Sean Callanana09caa52009-09-02 00:55:49 +00001877
1878 def AND8i8 : Ii8<0x24, RawFrm, (outs), (ins i8imm:$src),
1879 "and{b}\t{$src, %al|%al, $src}", []>;
1880 def AND16i16 : Ii16<0x25, RawFrm, (outs), (ins i16imm:$src),
1881 "and{w}\t{$src, %ax|%ax, $src}", []>, OpSize;
1882 def AND32i32 : Ii32<0x25, RawFrm, (outs), (ins i32imm:$src),
1883 "and{l}\t{$src, %eax|%eax, $src}", []>;
1884
Chris Lattnerf29ed092004-08-11 05:07:25 +00001885}
1886
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00001887
Chris Lattnercc65bee2005-01-02 02:35:46 +00001888let isCommutable = 1 in { // X = OR Y, Z --> X = OR Z, Y
Sean Callanan108934c2009-12-18 00:01:26 +00001889def OR8rr : I<0x08, MRMDestReg, (outs GR8 :$dst),
1890 (ins GR8 :$src1, GR8 :$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001891 "or{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001892 [(set GR8:$dst, (or GR8:$src1, GR8:$src2)),
1893 (implicit EFLAGS)]>;
Sean Callanan108934c2009-12-18 00:01:26 +00001894def OR16rr : I<0x09, MRMDestReg, (outs GR16:$dst),
1895 (ins GR16:$src1, GR16:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001896 "or{w}\t{$src2, $dst|$dst, $src2}",
Evan Cheng3bda2012010-01-12 18:31:19 +00001897 [(set GR16:$dst, (or GR16:$src1, GR16:$src2)),
Dan Gohman09a2609e2009-03-03 19:53:46 +00001898 (implicit EFLAGS)]>, OpSize;
Sean Callanan108934c2009-12-18 00:01:26 +00001899def OR32rr : I<0x09, MRMDestReg, (outs GR32:$dst),
1900 (ins GR32:$src1, GR32:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001901 "or{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng3bda2012010-01-12 18:31:19 +00001902 [(set GR32:$dst, (or GR32:$src1, GR32:$src2)),
Dan Gohman09a2609e2009-03-03 19:53:46 +00001903 (implicit EFLAGS)]>;
Chris Lattnercc65bee2005-01-02 02:35:46 +00001904}
Sean Callanan108934c2009-12-18 00:01:26 +00001905
1906// OR instructions with the destination register in REG and the source register
1907// in R/M. Included for the disassembler.
1908def OR8rr_REV : I<0x0A, MRMSrcReg, (outs GR8:$dst), (ins GR8:$src1, GR8:$src2),
1909 "or{b}\t{$src2, $dst|$dst, $src2}", []>;
1910def OR16rr_REV : I<0x0B, MRMSrcReg, (outs GR16:$dst),
1911 (ins GR16:$src1, GR16:$src2),
1912 "or{w}\t{$src2, $dst|$dst, $src2}", []>, OpSize;
1913def OR32rr_REV : I<0x0B, MRMSrcReg, (outs GR32:$dst),
1914 (ins GR32:$src1, GR32:$src2),
1915 "or{l}\t{$src2, $dst|$dst, $src2}", []>;
1916
1917def OR8rm : I<0x0A, MRMSrcMem , (outs GR8 :$dst),
1918 (ins GR8 :$src1, i8mem :$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001919 "or{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001920 [(set GR8:$dst, (or GR8:$src1, (load addr:$src2))),
1921 (implicit EFLAGS)]>;
Sean Callanan108934c2009-12-18 00:01:26 +00001922def OR16rm : I<0x0B, MRMSrcMem , (outs GR16:$dst),
1923 (ins GR16:$src1, i16mem:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001924 "or{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001925 [(set GR16:$dst, (or GR16:$src1, (load addr:$src2))),
1926 (implicit EFLAGS)]>, OpSize;
Sean Callanan108934c2009-12-18 00:01:26 +00001927def OR32rm : I<0x0B, MRMSrcMem , (outs GR32:$dst),
1928 (ins GR32:$src1, i32mem:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001929 "or{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001930 [(set GR32:$dst, (or GR32:$src1, (load addr:$src2))),
1931 (implicit EFLAGS)]>;
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00001932
Sean Callanan108934c2009-12-18 00:01:26 +00001933def OR8ri : Ii8 <0x80, MRM1r, (outs GR8 :$dst),
1934 (ins GR8 :$src1, i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001935 "or{b}\t{$src2, $dst|$dst, $src2}",
Evan Chengac000fa2010-01-11 20:18:04 +00001936 [(set GR8:$dst, (or GR8:$src1, imm:$src2)),
Dan Gohman09a2609e2009-03-03 19:53:46 +00001937 (implicit EFLAGS)]>;
Sean Callanan108934c2009-12-18 00:01:26 +00001938def OR16ri : Ii16<0x81, MRM1r, (outs GR16:$dst),
1939 (ins GR16:$src1, i16imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001940 "or{w}\t{$src2, $dst|$dst, $src2}",
Evan Cheng3bda2012010-01-12 18:31:19 +00001941 [(set GR16:$dst, (or GR16:$src1, imm:$src2)),
Dan Gohman09a2609e2009-03-03 19:53:46 +00001942 (implicit EFLAGS)]>, OpSize;
Sean Callanan108934c2009-12-18 00:01:26 +00001943def OR32ri : Ii32<0x81, MRM1r, (outs GR32:$dst),
1944 (ins GR32:$src1, i32imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001945 "or{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng3bda2012010-01-12 18:31:19 +00001946 [(set GR32:$dst, (or GR32:$src1, imm:$src2)),
Dan Gohman09a2609e2009-03-03 19:53:46 +00001947 (implicit EFLAGS)]>;
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00001948
Sean Callanan108934c2009-12-18 00:01:26 +00001949def OR16ri8 : Ii8<0x83, MRM1r, (outs GR16:$dst),
1950 (ins GR16:$src1, i16i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001951 "or{w}\t{$src2, $dst|$dst, $src2}",
Evan Cheng3bda2012010-01-12 18:31:19 +00001952 [(set GR16:$dst, (or GR16:$src1, i16immSExt8:$src2)),
Dan Gohman09a2609e2009-03-03 19:53:46 +00001953 (implicit EFLAGS)]>, OpSize;
Sean Callanan108934c2009-12-18 00:01:26 +00001954def OR32ri8 : Ii8<0x83, MRM1r, (outs GR32:$dst),
1955 (ins GR32:$src1, i32i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001956 "or{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng3bda2012010-01-12 18:31:19 +00001957 [(set GR32:$dst, (or GR32:$src1, i32immSExt8:$src2)),
Dan Gohman09a2609e2009-03-03 19:53:46 +00001958 (implicit EFLAGS)]>;
Chris Lattner57a02302004-08-11 04:31:00 +00001959let isTwoAddress = 0 in {
Evan Cheng64d80e32007-07-19 01:14:50 +00001960 def OR8mr : I<0x08, MRMDestMem, (outs), (ins i8mem:$dst, GR8:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001961 "or{b}\t{$src, $dst|$dst, $src}",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001962 [(store (or (load addr:$dst), GR8:$src), addr:$dst),
1963 (implicit EFLAGS)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00001964 def OR16mr : I<0x09, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001965 "or{w}\t{$src, $dst|$dst, $src}",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001966 [(store (or (load addr:$dst), GR16:$src), addr:$dst),
1967 (implicit EFLAGS)]>, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00001968 def OR32mr : I<0x09, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001969 "or{l}\t{$src, $dst|$dst, $src}",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001970 [(store (or (load addr:$dst), GR32:$src), addr:$dst),
1971 (implicit EFLAGS)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00001972 def OR8mi : Ii8<0x80, MRM1m, (outs), (ins i8mem :$dst, i8imm:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001973 "or{b}\t{$src, $dst|$dst, $src}",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001974 [(store (or (loadi8 addr:$dst), imm:$src), addr:$dst),
1975 (implicit EFLAGS)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00001976 def OR16mi : Ii16<0x81, MRM1m, (outs), (ins i16mem:$dst, i16imm:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001977 "or{w}\t{$src, $dst|$dst, $src}",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001978 [(store (or (loadi16 addr:$dst), imm:$src), addr:$dst),
1979 (implicit EFLAGS)]>,
Evan Cheng0ef3a772005-12-13 01:41:36 +00001980 OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00001981 def OR32mi : Ii32<0x81, MRM1m, (outs), (ins i32mem:$dst, i32imm:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001982 "or{l}\t{$src, $dst|$dst, $src}",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001983 [(store (or (loadi32 addr:$dst), imm:$src), addr:$dst),
1984 (implicit EFLAGS)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00001985 def OR16mi8 : Ii8<0x83, MRM1m, (outs), (ins i16mem:$dst, i16i8imm:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001986 "or{w}\t{$src, $dst|$dst, $src}",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001987 [(store (or (load addr:$dst), i16immSExt8:$src), addr:$dst),
1988 (implicit EFLAGS)]>,
Evan Cheng0ef3a772005-12-13 01:41:36 +00001989 OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00001990 def OR32mi8 : Ii8<0x83, MRM1m, (outs), (ins i32mem:$dst, i32i8imm:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001991 "or{l}\t{$src, $dst|$dst, $src}",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001992 [(store (or (load addr:$dst), i32immSExt8:$src), addr:$dst),
1993 (implicit EFLAGS)]>;
Sean Callanand00025a2009-09-11 19:01:56 +00001994
1995 def OR8i8 : Ii8 <0x0C, RawFrm, (outs), (ins i8imm:$src),
1996 "or{b}\t{$src, %al|%al, $src}", []>;
1997 def OR16i16 : Ii16 <0x0D, RawFrm, (outs), (ins i16imm:$src),
1998 "or{w}\t{$src, %ax|%ax, $src}", []>, OpSize;
1999 def OR32i32 : Ii32 <0x0D, RawFrm, (outs), (ins i32imm:$src),
2000 "or{l}\t{$src, %eax|%eax, $src}", []>;
Bill Wendlingbd0879d2008-05-29 01:02:09 +00002001} // isTwoAddress = 0
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00002002
2003
Evan Cheng359e9372008-06-18 08:13:07 +00002004let isCommutable = 1 in { // X = XOR Y, Z --> X = XOR Z, Y
Bill Wendlingbd0879d2008-05-29 01:02:09 +00002005 def XOR8rr : I<0x30, MRMDestReg,
2006 (outs GR8 :$dst), (ins GR8 :$src1, GR8 :$src2),
2007 "xor{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohman09a2609e2009-03-03 19:53:46 +00002008 [(set GR8:$dst, (xor GR8:$src1, GR8:$src2)),
2009 (implicit EFLAGS)]>;
Bill Wendlingbd0879d2008-05-29 01:02:09 +00002010 def XOR16rr : I<0x31, MRMDestReg,
2011 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
2012 "xor{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohman09a2609e2009-03-03 19:53:46 +00002013 [(set GR16:$dst, (xor GR16:$src1, GR16:$src2)),
2014 (implicit EFLAGS)]>, OpSize;
Bill Wendlingbd0879d2008-05-29 01:02:09 +00002015 def XOR32rr : I<0x31, MRMDestReg,
2016 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
2017 "xor{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohman09a2609e2009-03-03 19:53:46 +00002018 [(set GR32:$dst, (xor GR32:$src1, GR32:$src2)),
2019 (implicit EFLAGS)]>;
Evan Cheng359e9372008-06-18 08:13:07 +00002020} // isCommutable = 1
Chris Lattnercc65bee2005-01-02 02:35:46 +00002021
Sean Callanan108934c2009-12-18 00:01:26 +00002022// XOR instructions with the destination register in REG and the source register
2023// in R/M. Included for the disassembler.
2024def XOR8rr_REV : I<0x32, MRMSrcReg, (outs GR8:$dst), (ins GR8:$src1, GR8:$src2),
2025 "xor{b}\t{$src2, $dst|$dst, $src2}", []>;
2026def XOR16rr_REV : I<0x33, MRMSrcReg, (outs GR16:$dst),
2027 (ins GR16:$src1, GR16:$src2),
2028 "xor{w}\t{$src2, $dst|$dst, $src2}", []>, OpSize;
2029def XOR32rr_REV : I<0x33, MRMSrcReg, (outs GR32:$dst),
2030 (ins GR32:$src1, GR32:$src2),
2031 "xor{l}\t{$src2, $dst|$dst, $src2}", []>;
2032
Chris Lattner3a173df2004-10-03 20:35:00 +00002033def XOR8rm : I<0x32, MRMSrcMem ,
Evan Cheng64d80e32007-07-19 01:14:50 +00002034 (outs GR8 :$dst), (ins GR8:$src1, i8mem :$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002035 "xor{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohman09a2609e2009-03-03 19:53:46 +00002036 [(set GR8:$dst, (xor GR8:$src1, (load addr:$src2))),
2037 (implicit EFLAGS)]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00002038def XOR16rm : I<0x33, MRMSrcMem ,
Evan Cheng64d80e32007-07-19 01:14:50 +00002039 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002040 "xor{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohman09a2609e2009-03-03 19:53:46 +00002041 [(set GR16:$dst, (xor GR16:$src1, (load addr:$src2))),
2042 (implicit EFLAGS)]>,
Bill Wendlingbd0879d2008-05-29 01:02:09 +00002043 OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00002044def XOR32rm : I<0x33, MRMSrcMem ,
Evan Cheng64d80e32007-07-19 01:14:50 +00002045 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002046 "xor{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohman09a2609e2009-03-03 19:53:46 +00002047 [(set GR32:$dst, (xor GR32:$src1, (load addr:$src2))),
2048 (implicit EFLAGS)]>;
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00002049
Bill Wendling75cf88f2008-05-29 03:46:36 +00002050def XOR8ri : Ii8<0x80, MRM6r,
2051 (outs GR8:$dst), (ins GR8:$src1, i8imm:$src2),
2052 "xor{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohman09a2609e2009-03-03 19:53:46 +00002053 [(set GR8:$dst, (xor GR8:$src1, imm:$src2)),
2054 (implicit EFLAGS)]>;
Bill Wendling75cf88f2008-05-29 03:46:36 +00002055def XOR16ri : Ii16<0x81, MRM6r,
2056 (outs GR16:$dst), (ins GR16:$src1, i16imm:$src2),
2057 "xor{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohman09a2609e2009-03-03 19:53:46 +00002058 [(set GR16:$dst, (xor GR16:$src1, imm:$src2)),
2059 (implicit EFLAGS)]>, OpSize;
Bill Wendling75cf88f2008-05-29 03:46:36 +00002060def XOR32ri : Ii32<0x81, MRM6r,
2061 (outs GR32:$dst), (ins GR32:$src1, i32imm:$src2),
2062 "xor{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohman09a2609e2009-03-03 19:53:46 +00002063 [(set GR32:$dst, (xor GR32:$src1, imm:$src2)),
2064 (implicit EFLAGS)]>;
Bill Wendling75cf88f2008-05-29 03:46:36 +00002065def XOR16ri8 : Ii8<0x83, MRM6r,
2066 (outs GR16:$dst), (ins GR16:$src1, i16i8imm:$src2),
2067 "xor{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohman09a2609e2009-03-03 19:53:46 +00002068 [(set GR16:$dst, (xor GR16:$src1, i16immSExt8:$src2)),
2069 (implicit EFLAGS)]>,
Bill Wendling75cf88f2008-05-29 03:46:36 +00002070 OpSize;
2071def XOR32ri8 : Ii8<0x83, MRM6r,
2072 (outs GR32:$dst), (ins GR32:$src1, i32i8imm:$src2),
2073 "xor{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohman09a2609e2009-03-03 19:53:46 +00002074 [(set GR32:$dst, (xor GR32:$src1, i32immSExt8:$src2)),
2075 (implicit EFLAGS)]>;
Bill Wendlingbd0879d2008-05-29 01:02:09 +00002076
Chris Lattner57a02302004-08-11 04:31:00 +00002077let isTwoAddress = 0 in {
Chris Lattner3a173df2004-10-03 20:35:00 +00002078 def XOR8mr : I<0x30, MRMDestMem,
Evan Cheng64d80e32007-07-19 01:14:50 +00002079 (outs), (ins i8mem :$dst, GR8 :$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002080 "xor{b}\t{$src, $dst|$dst, $src}",
Dan Gohman09a2609e2009-03-03 19:53:46 +00002081 [(store (xor (load addr:$dst), GR8:$src), addr:$dst),
2082 (implicit EFLAGS)]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00002083 def XOR16mr : I<0x31, MRMDestMem,
Evan Cheng64d80e32007-07-19 01:14:50 +00002084 (outs), (ins i16mem:$dst, GR16:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002085 "xor{w}\t{$src, $dst|$dst, $src}",
Dan Gohman09a2609e2009-03-03 19:53:46 +00002086 [(store (xor (load addr:$dst), GR16:$src), addr:$dst),
2087 (implicit EFLAGS)]>,
Evan Cheng0ef3a772005-12-13 01:41:36 +00002088 OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00002089 def XOR32mr : I<0x31, MRMDestMem,
Evan Cheng64d80e32007-07-19 01:14:50 +00002090 (outs), (ins i32mem:$dst, GR32:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002091 "xor{l}\t{$src, $dst|$dst, $src}",
Dan Gohman09a2609e2009-03-03 19:53:46 +00002092 [(store (xor (load addr:$dst), GR32:$src), addr:$dst),
2093 (implicit EFLAGS)]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00002094 def XOR8mi : Ii8<0x80, MRM6m,
Evan Cheng64d80e32007-07-19 01:14:50 +00002095 (outs), (ins i8mem :$dst, i8imm :$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002096 "xor{b}\t{$src, $dst|$dst, $src}",
Dan Gohman09a2609e2009-03-03 19:53:46 +00002097 [(store (xor (loadi8 addr:$dst), imm:$src), addr:$dst),
2098 (implicit EFLAGS)]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00002099 def XOR16mi : Ii16<0x81, MRM6m,
Evan Cheng64d80e32007-07-19 01:14:50 +00002100 (outs), (ins i16mem:$dst, i16imm:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002101 "xor{w}\t{$src, $dst|$dst, $src}",
Dan Gohman09a2609e2009-03-03 19:53:46 +00002102 [(store (xor (loadi16 addr:$dst), imm:$src), addr:$dst),
2103 (implicit EFLAGS)]>,
Evan Cheng0ef3a772005-12-13 01:41:36 +00002104 OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00002105 def XOR32mi : Ii32<0x81, MRM6m,
Evan Cheng64d80e32007-07-19 01:14:50 +00002106 (outs), (ins i32mem:$dst, i32imm:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002107 "xor{l}\t{$src, $dst|$dst, $src}",
Dan Gohman09a2609e2009-03-03 19:53:46 +00002108 [(store (xor (loadi32 addr:$dst), imm:$src), addr:$dst),
2109 (implicit EFLAGS)]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00002110 def XOR16mi8 : Ii8<0x83, MRM6m,
Evan Cheng64d80e32007-07-19 01:14:50 +00002111 (outs), (ins i16mem:$dst, i16i8imm :$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002112 "xor{w}\t{$src, $dst|$dst, $src}",
Dan Gohman09a2609e2009-03-03 19:53:46 +00002113 [(store (xor (load addr:$dst), i16immSExt8:$src), addr:$dst),
2114 (implicit EFLAGS)]>,
Evan Cheng0ef3a772005-12-13 01:41:36 +00002115 OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00002116 def XOR32mi8 : Ii8<0x83, MRM6m,
Evan Cheng64d80e32007-07-19 01:14:50 +00002117 (outs), (ins i32mem:$dst, i32i8imm :$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002118 "xor{l}\t{$src, $dst|$dst, $src}",
Dan Gohman09a2609e2009-03-03 19:53:46 +00002119 [(store (xor (load addr:$dst), i32immSExt8:$src), addr:$dst),
2120 (implicit EFLAGS)]>;
Sean Callanan7893ec62009-09-10 19:52:26 +00002121
2122 def XOR8i8 : Ii8 <0x34, RawFrm, (outs), (ins i8imm:$src),
2123 "xor{b}\t{$src, %al|%al, $src}", []>;
2124 def XOR16i16 : Ii16 <0x35, RawFrm, (outs), (ins i16imm:$src),
2125 "xor{w}\t{$src, %ax|%ax, $src}", []>, OpSize;
2126 def XOR32i32 : Ii32 <0x35, RawFrm, (outs), (ins i32imm:$src),
2127 "xor{l}\t{$src, %eax|%eax, $src}", []>;
Bill Wendlingbd0879d2008-05-29 01:02:09 +00002128} // isTwoAddress = 0
Evan Cheng24f2ea32007-09-14 21:48:26 +00002129} // Defs = [EFLAGS]
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00002130
2131// Shift instructions
Evan Cheng24f2ea32007-09-14 21:48:26 +00002132let Defs = [EFLAGS] in {
Evan Cheng071a2792007-09-11 19:55:27 +00002133let Uses = [CL] in {
Evan Cheng64d80e32007-07-19 01:14:50 +00002134def SHL8rCL : I<0xD2, MRM4r, (outs GR8 :$dst), (ins GR8 :$src),
Eli Friedmanaace4b12009-06-19 04:48:38 +00002135 "shl{b}\t{%cl, $dst|$dst, CL}",
Evan Cheng071a2792007-09-11 19:55:27 +00002136 [(set GR8:$dst, (shl GR8:$src, CL))]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00002137def SHL16rCL : I<0xD3, MRM4r, (outs GR16:$dst), (ins GR16:$src),
Eli Friedmanaace4b12009-06-19 04:48:38 +00002138 "shl{w}\t{%cl, $dst|$dst, CL}",
Evan Cheng071a2792007-09-11 19:55:27 +00002139 [(set GR16:$dst, (shl GR16:$src, CL))]>, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00002140def SHL32rCL : I<0xD3, MRM4r, (outs GR32:$dst), (ins GR32:$src),
Eli Friedmanaace4b12009-06-19 04:48:38 +00002141 "shl{l}\t{%cl, $dst|$dst, CL}",
Evan Cheng071a2792007-09-11 19:55:27 +00002142 [(set GR32:$dst, (shl GR32:$src, CL))]>;
Bill Wendlingbd0879d2008-05-29 01:02:09 +00002143} // Uses = [CL]
Chris Lattnercc65bee2005-01-02 02:35:46 +00002144
Evan Cheng64d80e32007-07-19 01:14:50 +00002145def SHL8ri : Ii8<0xC0, MRM4r, (outs GR8 :$dst), (ins GR8 :$src1, i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002146 "shl{b}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00002147 [(set GR8:$dst, (shl GR8:$src1, (i8 imm:$src2)))]>;
Chris Lattnercc65bee2005-01-02 02:35:46 +00002148let isConvertibleToThreeAddress = 1 in { // Can transform into LEA.
Evan Cheng64d80e32007-07-19 01:14:50 +00002149def SHL16ri : Ii8<0xC1, MRM4r, (outs GR16:$dst), (ins GR16:$src1, i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002150 "shl{w}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00002151 [(set GR16:$dst, (shl GR16:$src1, (i8 imm:$src2)))]>, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00002152def SHL32ri : Ii8<0xC1, MRM4r, (outs GR32:$dst), (ins GR32:$src1, i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002153 "shl{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00002154 [(set GR32:$dst, (shl GR32:$src1, (i8 imm:$src2)))]>;
Sean Callanan13cf8e92009-09-16 02:28:43 +00002155
2156// NOTE: We don't include patterns for shifts of a register by one, because
2157// 'add reg,reg' is cheaper.
2158
2159def SHL8r1 : I<0xD0, MRM4r, (outs GR8:$dst), (ins GR8:$src1),
2160 "shl{b}\t$dst", []>;
2161def SHL16r1 : I<0xD1, MRM4r, (outs GR16:$dst), (ins GR16:$src1),
2162 "shl{w}\t$dst", []>, OpSize;
2163def SHL32r1 : I<0xD1, MRM4r, (outs GR32:$dst), (ins GR32:$src1),
2164 "shl{l}\t$dst", []>;
2165
Bill Wendlingbd0879d2008-05-29 01:02:09 +00002166} // isConvertibleToThreeAddress = 1
Evan Cheng09c54572006-06-29 00:36:51 +00002167
Chris Lattnerf29ed092004-08-11 05:07:25 +00002168let isTwoAddress = 0 in {
Evan Cheng071a2792007-09-11 19:55:27 +00002169 let Uses = [CL] in {
Evan Cheng64d80e32007-07-19 01:14:50 +00002170 def SHL8mCL : I<0xD2, MRM4m, (outs), (ins i8mem :$dst),
Eli Friedmanaace4b12009-06-19 04:48:38 +00002171 "shl{b}\t{%cl, $dst|$dst, CL}",
Evan Cheng071a2792007-09-11 19:55:27 +00002172 [(store (shl (loadi8 addr:$dst), CL), addr:$dst)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00002173 def SHL16mCL : I<0xD3, MRM4m, (outs), (ins i16mem:$dst),
Eli Friedmanaace4b12009-06-19 04:48:38 +00002174 "shl{w}\t{%cl, $dst|$dst, CL}",
Evan Cheng071a2792007-09-11 19:55:27 +00002175 [(store (shl (loadi16 addr:$dst), CL), addr:$dst)]>, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00002176 def SHL32mCL : I<0xD3, MRM4m, (outs), (ins i32mem:$dst),
Eli Friedmanaace4b12009-06-19 04:48:38 +00002177 "shl{l}\t{%cl, $dst|$dst, CL}",
Evan Cheng071a2792007-09-11 19:55:27 +00002178 [(store (shl (loadi32 addr:$dst), CL), addr:$dst)]>;
2179 }
Evan Cheng64d80e32007-07-19 01:14:50 +00002180 def SHL8mi : Ii8<0xC0, MRM4m, (outs), (ins i8mem :$dst, i8imm:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002181 "shl{b}\t{$src, $dst|$dst, $src}",
Evan Cheng763b0292005-12-13 02:34:51 +00002182 [(store (shl (loadi8 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00002183 def SHL16mi : Ii8<0xC1, MRM4m, (outs), (ins i16mem:$dst, i8imm:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002184 "shl{w}\t{$src, $dst|$dst, $src}",
Evan Cheng763b0292005-12-13 02:34:51 +00002185 [(store (shl (loadi16 addr:$dst), (i8 imm:$src)), addr:$dst)]>,
2186 OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00002187 def SHL32mi : Ii8<0xC1, MRM4m, (outs), (ins i32mem:$dst, i8imm:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002188 "shl{l}\t{$src, $dst|$dst, $src}",
Evan Cheng763b0292005-12-13 02:34:51 +00002189 [(store (shl (loadi32 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
Evan Cheng09c54572006-06-29 00:36:51 +00002190
2191 // Shift by 1
Evan Cheng64d80e32007-07-19 01:14:50 +00002192 def SHL8m1 : I<0xD0, MRM4m, (outs), (ins i8mem :$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002193 "shl{b}\t$dst",
Evan Cheng09c54572006-06-29 00:36:51 +00002194 [(store (shl (loadi8 addr:$dst), (i8 1)), addr:$dst)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00002195 def SHL16m1 : I<0xD1, MRM4m, (outs), (ins i16mem:$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002196 "shl{w}\t$dst",
Evan Cheng09c54572006-06-29 00:36:51 +00002197 [(store (shl (loadi16 addr:$dst), (i8 1)), addr:$dst)]>,
2198 OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00002199 def SHL32m1 : I<0xD1, MRM4m, (outs), (ins i32mem:$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002200 "shl{l}\t$dst",
Evan Cheng09c54572006-06-29 00:36:51 +00002201 [(store (shl (loadi32 addr:$dst), (i8 1)), addr:$dst)]>;
Chris Lattnerf29ed092004-08-11 05:07:25 +00002202}
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00002203
Evan Cheng071a2792007-09-11 19:55:27 +00002204let Uses = [CL] in {
Evan Cheng64d80e32007-07-19 01:14:50 +00002205def SHR8rCL : I<0xD2, MRM5r, (outs GR8 :$dst), (ins GR8 :$src),
Eli Friedmanaace4b12009-06-19 04:48:38 +00002206 "shr{b}\t{%cl, $dst|$dst, CL}",
Evan Cheng071a2792007-09-11 19:55:27 +00002207 [(set GR8:$dst, (srl GR8:$src, CL))]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00002208def SHR16rCL : I<0xD3, MRM5r, (outs GR16:$dst), (ins GR16:$src),
Eli Friedmanaace4b12009-06-19 04:48:38 +00002209 "shr{w}\t{%cl, $dst|$dst, CL}",
Evan Cheng071a2792007-09-11 19:55:27 +00002210 [(set GR16:$dst, (srl GR16:$src, CL))]>, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00002211def SHR32rCL : I<0xD3, MRM5r, (outs GR32:$dst), (ins GR32:$src),
Eli Friedmanaace4b12009-06-19 04:48:38 +00002212 "shr{l}\t{%cl, $dst|$dst, CL}",
Evan Cheng071a2792007-09-11 19:55:27 +00002213 [(set GR32:$dst, (srl GR32:$src, CL))]>;
2214}
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00002215
Evan Cheng64d80e32007-07-19 01:14:50 +00002216def SHR8ri : Ii8<0xC0, MRM5r, (outs GR8:$dst), (ins GR8:$src1, i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002217 "shr{b}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00002218 [(set GR8:$dst, (srl GR8:$src1, (i8 imm:$src2)))]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00002219def SHR16ri : Ii8<0xC1, MRM5r, (outs GR16:$dst), (ins GR16:$src1, i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002220 "shr{w}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00002221 [(set GR16:$dst, (srl GR16:$src1, (i8 imm:$src2)))]>, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00002222def SHR32ri : Ii8<0xC1, MRM5r, (outs GR32:$dst), (ins GR32:$src1, i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002223 "shr{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00002224 [(set GR32:$dst, (srl GR32:$src1, (i8 imm:$src2)))]>;
Chris Lattnerf29ed092004-08-11 05:07:25 +00002225
Evan Cheng09c54572006-06-29 00:36:51 +00002226// Shift by 1
Evan Cheng64d80e32007-07-19 01:14:50 +00002227def SHR8r1 : I<0xD0, MRM5r, (outs GR8:$dst), (ins GR8:$src1),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002228 "shr{b}\t$dst",
Evan Cheng09c54572006-06-29 00:36:51 +00002229 [(set GR8:$dst, (srl GR8:$src1, (i8 1)))]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00002230def SHR16r1 : I<0xD1, MRM5r, (outs GR16:$dst), (ins GR16:$src1),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002231 "shr{w}\t$dst",
Evan Cheng09c54572006-06-29 00:36:51 +00002232 [(set GR16:$dst, (srl GR16:$src1, (i8 1)))]>, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00002233def SHR32r1 : I<0xD1, MRM5r, (outs GR32:$dst), (ins GR32:$src1),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002234 "shr{l}\t$dst",
Evan Cheng09c54572006-06-29 00:36:51 +00002235 [(set GR32:$dst, (srl GR32:$src1, (i8 1)))]>;
2236
Chris Lattner57a02302004-08-11 04:31:00 +00002237let isTwoAddress = 0 in {
Evan Cheng071a2792007-09-11 19:55:27 +00002238 let Uses = [CL] in {
Evan Cheng64d80e32007-07-19 01:14:50 +00002239 def SHR8mCL : I<0xD2, MRM5m, (outs), (ins i8mem :$dst),
Eli Friedmanaace4b12009-06-19 04:48:38 +00002240 "shr{b}\t{%cl, $dst|$dst, CL}",
Evan Cheng071a2792007-09-11 19:55:27 +00002241 [(store (srl (loadi8 addr:$dst), CL), addr:$dst)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00002242 def SHR16mCL : I<0xD3, MRM5m, (outs), (ins i16mem:$dst),
Eli Friedmanaace4b12009-06-19 04:48:38 +00002243 "shr{w}\t{%cl, $dst|$dst, CL}",
Evan Cheng85dd8892005-12-13 07:24:22 +00002244 [(store (srl (loadi16 addr:$dst), CL), addr:$dst)]>,
Evan Cheng071a2792007-09-11 19:55:27 +00002245 OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00002246 def SHR32mCL : I<0xD3, MRM5m, (outs), (ins i32mem:$dst),
Eli Friedmanaace4b12009-06-19 04:48:38 +00002247 "shr{l}\t{%cl, $dst|$dst, CL}",
Evan Cheng071a2792007-09-11 19:55:27 +00002248 [(store (srl (loadi32 addr:$dst), CL), addr:$dst)]>;
2249 }
Evan Cheng64d80e32007-07-19 01:14:50 +00002250 def SHR8mi : Ii8<0xC0, MRM5m, (outs), (ins i8mem :$dst, i8imm:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002251 "shr{b}\t{$src, $dst|$dst, $src}",
Evan Cheng85dd8892005-12-13 07:24:22 +00002252 [(store (srl (loadi8 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00002253 def SHR16mi : Ii8<0xC1, MRM5m, (outs), (ins i16mem:$dst, i8imm:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002254 "shr{w}\t{$src, $dst|$dst, $src}",
Evan Cheng85dd8892005-12-13 07:24:22 +00002255 [(store (srl (loadi16 addr:$dst), (i8 imm:$src)), addr:$dst)]>,
2256 OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00002257 def SHR32mi : Ii8<0xC1, MRM5m, (outs), (ins i32mem:$dst, i8imm:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002258 "shr{l}\t{$src, $dst|$dst, $src}",
Evan Cheng85dd8892005-12-13 07:24:22 +00002259 [(store (srl (loadi32 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
Evan Cheng09c54572006-06-29 00:36:51 +00002260
2261 // Shift by 1
Evan Cheng64d80e32007-07-19 01:14:50 +00002262 def SHR8m1 : I<0xD0, MRM5m, (outs), (ins i8mem :$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002263 "shr{b}\t$dst",
Evan Cheng09c54572006-06-29 00:36:51 +00002264 [(store (srl (loadi8 addr:$dst), (i8 1)), addr:$dst)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00002265 def SHR16m1 : I<0xD1, MRM5m, (outs), (ins i16mem:$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002266 "shr{w}\t$dst",
Evan Cheng09c54572006-06-29 00:36:51 +00002267 [(store (srl (loadi16 addr:$dst), (i8 1)), addr:$dst)]>,OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00002268 def SHR32m1 : I<0xD1, MRM5m, (outs), (ins i32mem:$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002269 "shr{l}\t$dst",
Evan Cheng09c54572006-06-29 00:36:51 +00002270 [(store (srl (loadi32 addr:$dst), (i8 1)), addr:$dst)]>;
Chris Lattner57a02302004-08-11 04:31:00 +00002271}
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00002272
Evan Cheng071a2792007-09-11 19:55:27 +00002273let Uses = [CL] in {
Evan Cheng64d80e32007-07-19 01:14:50 +00002274def SAR8rCL : I<0xD2, MRM7r, (outs GR8 :$dst), (ins GR8 :$src),
Eli Friedmanaace4b12009-06-19 04:48:38 +00002275 "sar{b}\t{%cl, $dst|$dst, CL}",
Evan Cheng071a2792007-09-11 19:55:27 +00002276 [(set GR8:$dst, (sra GR8:$src, CL))]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00002277def SAR16rCL : I<0xD3, MRM7r, (outs GR16:$dst), (ins GR16:$src),
Eli Friedmanaace4b12009-06-19 04:48:38 +00002278 "sar{w}\t{%cl, $dst|$dst, CL}",
Evan Cheng071a2792007-09-11 19:55:27 +00002279 [(set GR16:$dst, (sra GR16:$src, CL))]>, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00002280def SAR32rCL : I<0xD3, MRM7r, (outs GR32:$dst), (ins GR32:$src),
Eli Friedmanaace4b12009-06-19 04:48:38 +00002281 "sar{l}\t{%cl, $dst|$dst, CL}",
Evan Cheng071a2792007-09-11 19:55:27 +00002282 [(set GR32:$dst, (sra GR32:$src, CL))]>;
2283}
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00002284
Evan Cheng64d80e32007-07-19 01:14:50 +00002285def SAR8ri : Ii8<0xC0, MRM7r, (outs GR8 :$dst), (ins GR8 :$src1, i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002286 "sar{b}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00002287 [(set GR8:$dst, (sra GR8:$src1, (i8 imm:$src2)))]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00002288def SAR16ri : Ii8<0xC1, MRM7r, (outs GR16:$dst), (ins GR16:$src1, i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002289 "sar{w}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00002290 [(set GR16:$dst, (sra GR16:$src1, (i8 imm:$src2)))]>,
Chris Lattner3d36a9f2005-12-05 02:40:25 +00002291 OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00002292def SAR32ri : Ii8<0xC1, MRM7r, (outs GR32:$dst), (ins GR32:$src1, i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002293 "sar{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00002294 [(set GR32:$dst, (sra GR32:$src1, (i8 imm:$src2)))]>;
Evan Cheng09c54572006-06-29 00:36:51 +00002295
2296// Shift by 1
Evan Cheng64d80e32007-07-19 01:14:50 +00002297def SAR8r1 : I<0xD0, MRM7r, (outs GR8 :$dst), (ins GR8 :$src1),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002298 "sar{b}\t$dst",
Evan Cheng09c54572006-06-29 00:36:51 +00002299 [(set GR8:$dst, (sra GR8:$src1, (i8 1)))]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00002300def SAR16r1 : I<0xD1, MRM7r, (outs GR16:$dst), (ins GR16:$src1),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002301 "sar{w}\t$dst",
Evan Cheng09c54572006-06-29 00:36:51 +00002302 [(set GR16:$dst, (sra GR16:$src1, (i8 1)))]>, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00002303def SAR32r1 : I<0xD1, MRM7r, (outs GR32:$dst), (ins GR32:$src1),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002304 "sar{l}\t$dst",
Evan Cheng09c54572006-06-29 00:36:51 +00002305 [(set GR32:$dst, (sra GR32:$src1, (i8 1)))]>;
2306
Chris Lattnerf29ed092004-08-11 05:07:25 +00002307let isTwoAddress = 0 in {
Evan Cheng071a2792007-09-11 19:55:27 +00002308 let Uses = [CL] in {
Evan Cheng64d80e32007-07-19 01:14:50 +00002309 def SAR8mCL : I<0xD2, MRM7m, (outs), (ins i8mem :$dst),
Eli Friedmanaace4b12009-06-19 04:48:38 +00002310 "sar{b}\t{%cl, $dst|$dst, CL}",
Evan Cheng071a2792007-09-11 19:55:27 +00002311 [(store (sra (loadi8 addr:$dst), CL), addr:$dst)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00002312 def SAR16mCL : I<0xD3, MRM7m, (outs), (ins i16mem:$dst),
Eli Friedmanaace4b12009-06-19 04:48:38 +00002313 "sar{w}\t{%cl, $dst|$dst, CL}",
Evan Cheng071a2792007-09-11 19:55:27 +00002314 [(store (sra (loadi16 addr:$dst), CL), addr:$dst)]>, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00002315 def SAR32mCL : I<0xD3, MRM7m, (outs), (ins i32mem:$dst),
Eli Friedmanaace4b12009-06-19 04:48:38 +00002316 "sar{l}\t{%cl, $dst|$dst, CL}",
Evan Cheng071a2792007-09-11 19:55:27 +00002317 [(store (sra (loadi32 addr:$dst), CL), addr:$dst)]>;
2318 }
Evan Cheng64d80e32007-07-19 01:14:50 +00002319 def SAR8mi : Ii8<0xC0, MRM7m, (outs), (ins i8mem :$dst, i8imm:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002320 "sar{b}\t{$src, $dst|$dst, $src}",
Evan Cheng85dd8892005-12-13 07:24:22 +00002321 [(store (sra (loadi8 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00002322 def SAR16mi : Ii8<0xC1, MRM7m, (outs), (ins i16mem:$dst, i8imm:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002323 "sar{w}\t{$src, $dst|$dst, $src}",
Evan Cheng85dd8892005-12-13 07:24:22 +00002324 [(store (sra (loadi16 addr:$dst), (i8 imm:$src)), addr:$dst)]>,
2325 OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00002326 def SAR32mi : Ii8<0xC1, MRM7m, (outs), (ins i32mem:$dst, i8imm:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002327 "sar{l}\t{$src, $dst|$dst, $src}",
Evan Cheng85dd8892005-12-13 07:24:22 +00002328 [(store (sra (loadi32 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
Evan Cheng09c54572006-06-29 00:36:51 +00002329
2330 // Shift by 1
Evan Cheng64d80e32007-07-19 01:14:50 +00002331 def SAR8m1 : I<0xD0, MRM7m, (outs), (ins i8mem :$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002332 "sar{b}\t$dst",
Evan Cheng09c54572006-06-29 00:36:51 +00002333 [(store (sra (loadi8 addr:$dst), (i8 1)), addr:$dst)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00002334 def SAR16m1 : I<0xD1, MRM7m, (outs), (ins i16mem:$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002335 "sar{w}\t$dst",
Evan Cheng09c54572006-06-29 00:36:51 +00002336 [(store (sra (loadi16 addr:$dst), (i8 1)), addr:$dst)]>,
2337 OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00002338 def SAR32m1 : I<0xD1, MRM7m, (outs), (ins i32mem:$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002339 "sar{l}\t$dst",
Evan Cheng09c54572006-06-29 00:36:51 +00002340 [(store (sra (loadi32 addr:$dst), (i8 1)), addr:$dst)]>;
Chris Lattnerf29ed092004-08-11 05:07:25 +00002341}
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00002342
Chris Lattner40ff6332005-01-19 07:50:03 +00002343// Rotate instructions
Sean Callanana2dc2822009-09-18 19:35:23 +00002344
2345def RCL8r1 : I<0xD0, MRM2r, (outs GR8:$dst), (ins GR8:$src),
2346 "rcl{b}\t{1, $dst|$dst, 1}", []>;
Sean Callanana2dc2822009-09-18 19:35:23 +00002347let Uses = [CL] in {
2348def RCL8rCL : I<0xD2, MRM2r, (outs GR8:$dst), (ins GR8:$src),
2349 "rcl{b}\t{%cl, $dst|$dst, CL}", []>;
Sean Callanana2dc2822009-09-18 19:35:23 +00002350}
2351def RCL8ri : Ii8<0xC0, MRM2r, (outs GR8:$dst), (ins GR8:$src, i8imm:$cnt),
2352 "rcl{b}\t{$cnt, $dst|$dst, $cnt}", []>;
Sean Callanana2dc2822009-09-18 19:35:23 +00002353
2354def RCL16r1 : I<0xD1, MRM2r, (outs GR16:$dst), (ins GR16:$src),
2355 "rcl{w}\t{1, $dst|$dst, 1}", []>, OpSize;
Sean Callanana2dc2822009-09-18 19:35:23 +00002356let Uses = [CL] in {
2357def RCL16rCL : I<0xD3, MRM2r, (outs GR16:$dst), (ins GR16:$src),
2358 "rcl{w}\t{%cl, $dst|$dst, CL}", []>, OpSize;
Sean Callanana2dc2822009-09-18 19:35:23 +00002359}
2360def RCL16ri : Ii8<0xC1, MRM2r, (outs GR16:$dst), (ins GR16:$src, i8imm:$cnt),
2361 "rcl{w}\t{$cnt, $dst|$dst, $cnt}", []>, OpSize;
Sean Callanana2dc2822009-09-18 19:35:23 +00002362
2363def RCL32r1 : I<0xD1, MRM2r, (outs GR32:$dst), (ins GR32:$src),
2364 "rcl{l}\t{1, $dst|$dst, 1}", []>;
Sean Callanana2dc2822009-09-18 19:35:23 +00002365let Uses = [CL] in {
2366def RCL32rCL : I<0xD3, MRM2r, (outs GR32:$dst), (ins GR32:$src),
2367 "rcl{l}\t{%cl, $dst|$dst, CL}", []>;
Sean Callanana2dc2822009-09-18 19:35:23 +00002368}
2369def RCL32ri : Ii8<0xC1, MRM2r, (outs GR32:$dst), (ins GR32:$src, i8imm:$cnt),
2370 "rcl{l}\t{$cnt, $dst|$dst, $cnt}", []>;
Sean Callanana2dc2822009-09-18 19:35:23 +00002371
2372def RCR8r1 : I<0xD0, MRM3r, (outs GR8:$dst), (ins GR8:$src),
2373 "rcr{b}\t{1, $dst|$dst, 1}", []>;
Sean Callanana2dc2822009-09-18 19:35:23 +00002374let Uses = [CL] in {
2375def RCR8rCL : I<0xD2, MRM3r, (outs GR8:$dst), (ins GR8:$src),
2376 "rcr{b}\t{%cl, $dst|$dst, CL}", []>;
Sean Callanana2dc2822009-09-18 19:35:23 +00002377}
2378def RCR8ri : Ii8<0xC0, MRM3r, (outs GR8:$dst), (ins GR8:$src, i8imm:$cnt),
2379 "rcr{b}\t{$cnt, $dst|$dst, $cnt}", []>;
Sean Callanana2dc2822009-09-18 19:35:23 +00002380
2381def RCR16r1 : I<0xD1, MRM3r, (outs GR16:$dst), (ins GR16:$src),
2382 "rcr{w}\t{1, $dst|$dst, 1}", []>, OpSize;
Sean Callanana2dc2822009-09-18 19:35:23 +00002383let Uses = [CL] in {
2384def RCR16rCL : I<0xD3, MRM3r, (outs GR16:$dst), (ins GR16:$src),
2385 "rcr{w}\t{%cl, $dst|$dst, CL}", []>, OpSize;
Sean Callanana2dc2822009-09-18 19:35:23 +00002386}
2387def RCR16ri : Ii8<0xC1, MRM3r, (outs GR16:$dst), (ins GR16:$src, i8imm:$cnt),
2388 "rcr{w}\t{$cnt, $dst|$dst, $cnt}", []>, OpSize;
Sean Callanana2dc2822009-09-18 19:35:23 +00002389
2390def RCR32r1 : I<0xD1, MRM3r, (outs GR32:$dst), (ins GR32:$src),
2391 "rcr{l}\t{1, $dst|$dst, 1}", []>;
Sean Callanana2dc2822009-09-18 19:35:23 +00002392let Uses = [CL] in {
2393def RCR32rCL : I<0xD3, MRM3r, (outs GR32:$dst), (ins GR32:$src),
2394 "rcr{l}\t{%cl, $dst|$dst, CL}", []>;
Sean Callanana2dc2822009-09-18 19:35:23 +00002395}
2396def RCR32ri : Ii8<0xC1, MRM3r, (outs GR32:$dst), (ins GR32:$src, i8imm:$cnt),
2397 "rcr{l}\t{$cnt, $dst|$dst, $cnt}", []>;
Daniel Dunbarccfa1db2010-02-12 01:22:03 +00002398
2399let isTwoAddress = 0 in {
2400def RCL8m1 : I<0xD0, MRM2m, (outs), (ins i8mem:$dst),
2401 "rcl{b}\t{1, $dst|$dst, 1}", []>;
2402def RCL8mi : Ii8<0xC0, MRM2m, (outs), (ins i8mem:$dst, i8imm:$cnt),
2403 "rcl{b}\t{$cnt, $dst|$dst, $cnt}", []>;
2404def RCL16m1 : I<0xD1, MRM2m, (outs), (ins i16mem:$dst),
2405 "rcl{w}\t{1, $dst|$dst, 1}", []>, OpSize;
2406def RCL16mi : Ii8<0xC1, MRM2m, (outs), (ins i16mem:$dst, i8imm:$cnt),
2407 "rcl{w}\t{$cnt, $dst|$dst, $cnt}", []>, OpSize;
2408def RCL32m1 : I<0xD1, MRM2m, (outs), (ins i32mem:$dst),
2409 "rcl{l}\t{1, $dst|$dst, 1}", []>;
2410def RCL32mi : Ii8<0xC1, MRM2m, (outs), (ins i32mem:$dst, i8imm:$cnt),
2411 "rcl{l}\t{$cnt, $dst|$dst, $cnt}", []>;
2412def RCR8m1 : I<0xD0, MRM3m, (outs), (ins i8mem:$dst),
2413 "rcr{b}\t{1, $dst|$dst, 1}", []>;
2414def RCR8mi : Ii8<0xC0, MRM3m, (outs), (ins i8mem:$dst, i8imm:$cnt),
2415 "rcr{b}\t{$cnt, $dst|$dst, $cnt}", []>;
2416def RCR16m1 : I<0xD1, MRM3m, (outs), (ins i16mem:$dst),
2417 "rcr{w}\t{1, $dst|$dst, 1}", []>, OpSize;
2418def RCR16mi : Ii8<0xC1, MRM3m, (outs), (ins i16mem:$dst, i8imm:$cnt),
2419 "rcr{w}\t{$cnt, $dst|$dst, $cnt}", []>, OpSize;
2420def RCR32m1 : I<0xD1, MRM3m, (outs), (ins i32mem:$dst),
2421 "rcr{l}\t{1, $dst|$dst, 1}", []>;
2422def RCR32mi : Ii8<0xC1, MRM3m, (outs), (ins i32mem:$dst, i8imm:$cnt),
Sean Callanana2dc2822009-09-18 19:35:23 +00002423 "rcr{l}\t{$cnt, $dst|$dst, $cnt}", []>;
2424
Daniel Dunbarccfa1db2010-02-12 01:22:03 +00002425let Uses = [CL] in {
2426def RCL8mCL : I<0xD2, MRM2m, (outs), (ins i8mem:$dst),
2427 "rcl{b}\t{%cl, $dst|$dst, CL}", []>;
2428def RCL16mCL : I<0xD3, MRM2m, (outs), (ins i16mem:$dst),
2429 "rcl{w}\t{%cl, $dst|$dst, CL}", []>, OpSize;
2430def RCL32mCL : I<0xD3, MRM2m, (outs), (ins i32mem:$dst),
2431 "rcl{l}\t{%cl, $dst|$dst, CL}", []>;
2432def RCR8mCL : I<0xD2, MRM3m, (outs), (ins i8mem:$dst),
2433 "rcr{b}\t{%cl, $dst|$dst, CL}", []>;
2434def RCR16mCL : I<0xD3, MRM3m, (outs), (ins i16mem:$dst),
2435 "rcr{w}\t{%cl, $dst|$dst, CL}", []>, OpSize;
2436def RCR32mCL : I<0xD3, MRM3m, (outs), (ins i32mem:$dst),
2437 "rcr{l}\t{%cl, $dst|$dst, CL}", []>;
2438}
2439}
2440
Chris Lattner40ff6332005-01-19 07:50:03 +00002441// FIXME: provide shorter instructions when imm8 == 1
Evan Cheng071a2792007-09-11 19:55:27 +00002442let Uses = [CL] in {
Evan Cheng64d80e32007-07-19 01:14:50 +00002443def ROL8rCL : I<0xD2, MRM0r, (outs GR8 :$dst), (ins GR8 :$src),
Eli Friedmanaace4b12009-06-19 04:48:38 +00002444 "rol{b}\t{%cl, $dst|$dst, CL}",
Evan Cheng071a2792007-09-11 19:55:27 +00002445 [(set GR8:$dst, (rotl GR8:$src, CL))]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00002446def ROL16rCL : I<0xD3, MRM0r, (outs GR16:$dst), (ins GR16:$src),
Eli Friedmanaace4b12009-06-19 04:48:38 +00002447 "rol{w}\t{%cl, $dst|$dst, CL}",
Evan Cheng071a2792007-09-11 19:55:27 +00002448 [(set GR16:$dst, (rotl GR16:$src, CL))]>, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00002449def ROL32rCL : I<0xD3, MRM0r, (outs GR32:$dst), (ins GR32:$src),
Eli Friedmanaace4b12009-06-19 04:48:38 +00002450 "rol{l}\t{%cl, $dst|$dst, CL}",
Evan Cheng071a2792007-09-11 19:55:27 +00002451 [(set GR32:$dst, (rotl GR32:$src, CL))]>;
2452}
Chris Lattner40ff6332005-01-19 07:50:03 +00002453
Evan Cheng64d80e32007-07-19 01:14:50 +00002454def ROL8ri : Ii8<0xC0, MRM0r, (outs GR8 :$dst), (ins GR8 :$src1, i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002455 "rol{b}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00002456 [(set GR8:$dst, (rotl GR8:$src1, (i8 imm:$src2)))]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00002457def ROL16ri : Ii8<0xC1, MRM0r, (outs GR16:$dst), (ins GR16:$src1, i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002458 "rol{w}\t{$src2, $dst|$dst, $src2}",
Sean Callanan108934c2009-12-18 00:01:26 +00002459 [(set GR16:$dst, (rotl GR16:$src1, (i8 imm:$src2)))]>,
2460 OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00002461def ROL32ri : Ii8<0xC1, MRM0r, (outs GR32:$dst), (ins GR32:$src1, i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002462 "rol{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00002463 [(set GR32:$dst, (rotl GR32:$src1, (i8 imm:$src2)))]>;
Chris Lattner40ff6332005-01-19 07:50:03 +00002464
Evan Cheng09c54572006-06-29 00:36:51 +00002465// Rotate by 1
Evan Cheng64d80e32007-07-19 01:14:50 +00002466def ROL8r1 : I<0xD0, MRM0r, (outs GR8 :$dst), (ins GR8 :$src1),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002467 "rol{b}\t$dst",
Evan Cheng09c54572006-06-29 00:36:51 +00002468 [(set GR8:$dst, (rotl GR8:$src1, (i8 1)))]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00002469def ROL16r1 : I<0xD1, MRM0r, (outs GR16:$dst), (ins GR16:$src1),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002470 "rol{w}\t$dst",
Evan Cheng09c54572006-06-29 00:36:51 +00002471 [(set GR16:$dst, (rotl GR16:$src1, (i8 1)))]>, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00002472def ROL32r1 : I<0xD1, MRM0r, (outs GR32:$dst), (ins GR32:$src1),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002473 "rol{l}\t$dst",
Evan Cheng09c54572006-06-29 00:36:51 +00002474 [(set GR32:$dst, (rotl GR32:$src1, (i8 1)))]>;
2475
Chris Lattner40ff6332005-01-19 07:50:03 +00002476let isTwoAddress = 0 in {
Evan Cheng071a2792007-09-11 19:55:27 +00002477 let Uses = [CL] in {
Evan Cheng64d80e32007-07-19 01:14:50 +00002478 def ROL8mCL : I<0xD2, MRM0m, (outs), (ins i8mem :$dst),
Eli Friedmanaace4b12009-06-19 04:48:38 +00002479 "rol{b}\t{%cl, $dst|$dst, CL}",
Evan Cheng071a2792007-09-11 19:55:27 +00002480 [(store (rotl (loadi8 addr:$dst), CL), addr:$dst)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00002481 def ROL16mCL : I<0xD3, MRM0m, (outs), (ins i16mem:$dst),
Eli Friedmanaace4b12009-06-19 04:48:38 +00002482 "rol{w}\t{%cl, $dst|$dst, CL}",
Evan Cheng071a2792007-09-11 19:55:27 +00002483 [(store (rotl (loadi16 addr:$dst), CL), addr:$dst)]>, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00002484 def ROL32mCL : I<0xD3, MRM0m, (outs), (ins i32mem:$dst),
Eli Friedmanaace4b12009-06-19 04:48:38 +00002485 "rol{l}\t{%cl, $dst|$dst, CL}",
Evan Cheng071a2792007-09-11 19:55:27 +00002486 [(store (rotl (loadi32 addr:$dst), CL), addr:$dst)]>;
2487 }
Evan Cheng64d80e32007-07-19 01:14:50 +00002488 def ROL8mi : Ii8<0xC0, MRM0m, (outs), (ins i8mem :$dst, i8imm:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002489 "rol{b}\t{$src, $dst|$dst, $src}",
Evan Chengeb422a72006-01-11 23:20:05 +00002490 [(store (rotl (loadi8 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00002491 def ROL16mi : Ii8<0xC1, MRM0m, (outs), (ins i16mem:$dst, i8imm:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002492 "rol{w}\t{$src, $dst|$dst, $src}",
Evan Chengeb422a72006-01-11 23:20:05 +00002493 [(store (rotl (loadi16 addr:$dst), (i8 imm:$src)), addr:$dst)]>,
2494 OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00002495 def ROL32mi : Ii8<0xC1, MRM0m, (outs), (ins i32mem:$dst, i8imm:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002496 "rol{l}\t{$src, $dst|$dst, $src}",
Evan Chengeb422a72006-01-11 23:20:05 +00002497 [(store (rotl (loadi32 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
Evan Cheng09c54572006-06-29 00:36:51 +00002498
2499 // Rotate by 1
Evan Cheng64d80e32007-07-19 01:14:50 +00002500 def ROL8m1 : I<0xD0, MRM0m, (outs), (ins i8mem :$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002501 "rol{b}\t$dst",
Evan Cheng09c54572006-06-29 00:36:51 +00002502 [(store (rotl (loadi8 addr:$dst), (i8 1)), addr:$dst)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00002503 def ROL16m1 : I<0xD1, MRM0m, (outs), (ins i16mem:$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002504 "rol{w}\t$dst",
Evan Cheng09c54572006-06-29 00:36:51 +00002505 [(store (rotl (loadi16 addr:$dst), (i8 1)), addr:$dst)]>,
2506 OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00002507 def ROL32m1 : I<0xD1, MRM0m, (outs), (ins i32mem:$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002508 "rol{l}\t$dst",
Evan Cheng09c54572006-06-29 00:36:51 +00002509 [(store (rotl (loadi32 addr:$dst), (i8 1)), addr:$dst)]>;
Chris Lattner40ff6332005-01-19 07:50:03 +00002510}
2511
Evan Cheng071a2792007-09-11 19:55:27 +00002512let Uses = [CL] in {
Evan Cheng64d80e32007-07-19 01:14:50 +00002513def ROR8rCL : I<0xD2, MRM1r, (outs GR8 :$dst), (ins GR8 :$src),
Eli Friedmanaace4b12009-06-19 04:48:38 +00002514 "ror{b}\t{%cl, $dst|$dst, CL}",
Evan Cheng071a2792007-09-11 19:55:27 +00002515 [(set GR8:$dst, (rotr GR8:$src, CL))]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00002516def ROR16rCL : I<0xD3, MRM1r, (outs GR16:$dst), (ins GR16:$src),
Eli Friedmanaace4b12009-06-19 04:48:38 +00002517 "ror{w}\t{%cl, $dst|$dst, CL}",
Evan Cheng071a2792007-09-11 19:55:27 +00002518 [(set GR16:$dst, (rotr GR16:$src, CL))]>, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00002519def ROR32rCL : I<0xD3, MRM1r, (outs GR32:$dst), (ins GR32:$src),
Eli Friedmanaace4b12009-06-19 04:48:38 +00002520 "ror{l}\t{%cl, $dst|$dst, CL}",
Evan Cheng071a2792007-09-11 19:55:27 +00002521 [(set GR32:$dst, (rotr GR32:$src, CL))]>;
2522}
Chris Lattner40ff6332005-01-19 07:50:03 +00002523
Evan Cheng64d80e32007-07-19 01:14:50 +00002524def ROR8ri : Ii8<0xC0, MRM1r, (outs GR8 :$dst), (ins GR8 :$src1, i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002525 "ror{b}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00002526 [(set GR8:$dst, (rotr GR8:$src1, (i8 imm:$src2)))]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00002527def ROR16ri : Ii8<0xC1, MRM1r, (outs GR16:$dst), (ins GR16:$src1, i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002528 "ror{w}\t{$src2, $dst|$dst, $src2}",
Sean Callanan108934c2009-12-18 00:01:26 +00002529 [(set GR16:$dst, (rotr GR16:$src1, (i8 imm:$src2)))]>,
2530 OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00002531def ROR32ri : Ii8<0xC1, MRM1r, (outs GR32:$dst), (ins GR32:$src1, i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002532 "ror{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00002533 [(set GR32:$dst, (rotr GR32:$src1, (i8 imm:$src2)))]>;
Evan Cheng09c54572006-06-29 00:36:51 +00002534
2535// Rotate by 1
Evan Cheng64d80e32007-07-19 01:14:50 +00002536def ROR8r1 : I<0xD0, MRM1r, (outs GR8 :$dst), (ins GR8 :$src1),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002537 "ror{b}\t$dst",
Evan Cheng09c54572006-06-29 00:36:51 +00002538 [(set GR8:$dst, (rotr GR8:$src1, (i8 1)))]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00002539def ROR16r1 : I<0xD1, MRM1r, (outs GR16:$dst), (ins GR16:$src1),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002540 "ror{w}\t$dst",
Evan Cheng09c54572006-06-29 00:36:51 +00002541 [(set GR16:$dst, (rotr GR16:$src1, (i8 1)))]>, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00002542def ROR32r1 : I<0xD1, MRM1r, (outs GR32:$dst), (ins GR32:$src1),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002543 "ror{l}\t$dst",
Evan Cheng09c54572006-06-29 00:36:51 +00002544 [(set GR32:$dst, (rotr GR32:$src1, (i8 1)))]>;
2545
Chris Lattner40ff6332005-01-19 07:50:03 +00002546let isTwoAddress = 0 in {
Evan Cheng071a2792007-09-11 19:55:27 +00002547 let Uses = [CL] in {
Evan Cheng64d80e32007-07-19 01:14:50 +00002548 def ROR8mCL : I<0xD2, MRM1m, (outs), (ins i8mem :$dst),
Eli Friedmanaace4b12009-06-19 04:48:38 +00002549 "ror{b}\t{%cl, $dst|$dst, CL}",
Evan Cheng071a2792007-09-11 19:55:27 +00002550 [(store (rotr (loadi8 addr:$dst), CL), addr:$dst)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00002551 def ROR16mCL : I<0xD3, MRM1m, (outs), (ins i16mem:$dst),
Eli Friedmanaace4b12009-06-19 04:48:38 +00002552 "ror{w}\t{%cl, $dst|$dst, CL}",
Evan Cheng071a2792007-09-11 19:55:27 +00002553 [(store (rotr (loadi16 addr:$dst), CL), addr:$dst)]>, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00002554 def ROR32mCL : I<0xD3, MRM1m, (outs), (ins i32mem:$dst),
Eli Friedmanaace4b12009-06-19 04:48:38 +00002555 "ror{l}\t{%cl, $dst|$dst, CL}",
Evan Cheng071a2792007-09-11 19:55:27 +00002556 [(store (rotr (loadi32 addr:$dst), CL), addr:$dst)]>;
2557 }
Evan Cheng64d80e32007-07-19 01:14:50 +00002558 def ROR8mi : Ii8<0xC0, MRM1m, (outs), (ins i8mem :$dst, i8imm:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002559 "ror{b}\t{$src, $dst|$dst, $src}",
Evan Chengeb422a72006-01-11 23:20:05 +00002560 [(store (rotr (loadi8 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00002561 def ROR16mi : Ii8<0xC1, MRM1m, (outs), (ins i16mem:$dst, i8imm:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002562 "ror{w}\t{$src, $dst|$dst, $src}",
Evan Chengeb422a72006-01-11 23:20:05 +00002563 [(store (rotr (loadi16 addr:$dst), (i8 imm:$src)), addr:$dst)]>,
2564 OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00002565 def ROR32mi : Ii8<0xC1, MRM1m, (outs), (ins i32mem:$dst, i8imm:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002566 "ror{l}\t{$src, $dst|$dst, $src}",
Evan Chengeb422a72006-01-11 23:20:05 +00002567 [(store (rotr (loadi32 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
Evan Cheng09c54572006-06-29 00:36:51 +00002568
2569 // Rotate by 1
Evan Cheng64d80e32007-07-19 01:14:50 +00002570 def ROR8m1 : I<0xD0, MRM1m, (outs), (ins i8mem :$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002571 "ror{b}\t$dst",
Evan Cheng09c54572006-06-29 00:36:51 +00002572 [(store (rotr (loadi8 addr:$dst), (i8 1)), addr:$dst)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00002573 def ROR16m1 : I<0xD1, MRM1m, (outs), (ins i16mem:$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002574 "ror{w}\t$dst",
Evan Cheng09c54572006-06-29 00:36:51 +00002575 [(store (rotr (loadi16 addr:$dst), (i8 1)), addr:$dst)]>,
2576 OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00002577 def ROR32m1 : I<0xD1, MRM1m, (outs), (ins i32mem:$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002578 "ror{l}\t$dst",
Evan Cheng09c54572006-06-29 00:36:51 +00002579 [(store (rotr (loadi32 addr:$dst), (i8 1)), addr:$dst)]>;
Chris Lattner40ff6332005-01-19 07:50:03 +00002580}
2581
2582
2583
2584// Double shift instructions (generalizations of rotate)
Evan Cheng071a2792007-09-11 19:55:27 +00002585let Uses = [CL] in {
Sean Callanan108934c2009-12-18 00:01:26 +00002586def SHLD32rrCL : I<0xA5, MRMDestReg, (outs GR32:$dst),
2587 (ins GR32:$src1, GR32:$src2),
Eli Friedmanaace4b12009-06-19 04:48:38 +00002588 "shld{l}\t{%cl, $src2, $dst|$dst, $src2, CL}",
Evan Cheng071a2792007-09-11 19:55:27 +00002589 [(set GR32:$dst, (X86shld GR32:$src1, GR32:$src2, CL))]>, TB;
Sean Callanan108934c2009-12-18 00:01:26 +00002590def SHRD32rrCL : I<0xAD, MRMDestReg, (outs GR32:$dst),
2591 (ins GR32:$src1, GR32:$src2),
Eli Friedmanaace4b12009-06-19 04:48:38 +00002592 "shrd{l}\t{%cl, $src2, $dst|$dst, $src2, CL}",
Evan Cheng071a2792007-09-11 19:55:27 +00002593 [(set GR32:$dst, (X86shrd GR32:$src1, GR32:$src2, CL))]>, TB;
Sean Callanan108934c2009-12-18 00:01:26 +00002594def SHLD16rrCL : I<0xA5, MRMDestReg, (outs GR16:$dst),
2595 (ins GR16:$src1, GR16:$src2),
Eli Friedmanaace4b12009-06-19 04:48:38 +00002596 "shld{w}\t{%cl, $src2, $dst|$dst, $src2, CL}",
Evan Cheng069287d2006-05-16 07:21:53 +00002597 [(set GR16:$dst, (X86shld GR16:$src1, GR16:$src2, CL))]>,
Evan Cheng071a2792007-09-11 19:55:27 +00002598 TB, OpSize;
Sean Callanan108934c2009-12-18 00:01:26 +00002599def SHRD16rrCL : I<0xAD, MRMDestReg, (outs GR16:$dst),
2600 (ins GR16:$src1, GR16:$src2),
Eli Friedmanaace4b12009-06-19 04:48:38 +00002601 "shrd{w}\t{%cl, $src2, $dst|$dst, $src2, CL}",
Evan Cheng069287d2006-05-16 07:21:53 +00002602 [(set GR16:$dst, (X86shrd GR16:$src1, GR16:$src2, CL))]>,
Evan Cheng071a2792007-09-11 19:55:27 +00002603 TB, OpSize;
2604}
Chris Lattner41e431b2005-01-19 07:11:01 +00002605
2606let isCommutable = 1 in { // These instructions commute to each other.
Chris Lattner3a173df2004-10-03 20:35:00 +00002607def SHLD32rri8 : Ii8<0xA4, MRMDestReg,
Sean Callanan108934c2009-12-18 00:01:26 +00002608 (outs GR32:$dst),
2609 (ins GR32:$src1, GR32:$src2, i8imm:$src3),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002610 "shld{l}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Evan Cheng069287d2006-05-16 07:21:53 +00002611 [(set GR32:$dst, (X86shld GR32:$src1, GR32:$src2,
Evan Chenge3413162006-01-09 18:33:28 +00002612 (i8 imm:$src3)))]>,
2613 TB;
Chris Lattner3a173df2004-10-03 20:35:00 +00002614def SHRD32rri8 : Ii8<0xAC, MRMDestReg,
Sean Callanan108934c2009-12-18 00:01:26 +00002615 (outs GR32:$dst),
2616 (ins GR32:$src1, GR32:$src2, i8imm:$src3),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002617 "shrd{l}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Evan Cheng069287d2006-05-16 07:21:53 +00002618 [(set GR32:$dst, (X86shrd GR32:$src1, GR32:$src2,
Evan Chenge3413162006-01-09 18:33:28 +00002619 (i8 imm:$src3)))]>,
2620 TB;
Chris Lattner0df53d22005-01-19 07:31:24 +00002621def SHLD16rri8 : Ii8<0xA4, MRMDestReg,
Sean Callanan108934c2009-12-18 00:01:26 +00002622 (outs GR16:$dst),
2623 (ins GR16:$src1, GR16:$src2, i8imm:$src3),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002624 "shld{w}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Evan Cheng069287d2006-05-16 07:21:53 +00002625 [(set GR16:$dst, (X86shld GR16:$src1, GR16:$src2,
Evan Chenge3413162006-01-09 18:33:28 +00002626 (i8 imm:$src3)))]>,
Chris Lattner0df53d22005-01-19 07:31:24 +00002627 TB, OpSize;
2628def SHRD16rri8 : Ii8<0xAC, MRMDestReg,
Sean Callanan108934c2009-12-18 00:01:26 +00002629 (outs GR16:$dst),
2630 (ins GR16:$src1, GR16:$src2, i8imm:$src3),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002631 "shrd{w}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Evan Cheng069287d2006-05-16 07:21:53 +00002632 [(set GR16:$dst, (X86shrd GR16:$src1, GR16:$src2,
Evan Chenge3413162006-01-09 18:33:28 +00002633 (i8 imm:$src3)))]>,
Chris Lattner0df53d22005-01-19 07:31:24 +00002634 TB, OpSize;
Chris Lattner41e431b2005-01-19 07:11:01 +00002635}
Chris Lattner0e967d42004-08-01 08:13:11 +00002636
Chris Lattner57a02302004-08-11 04:31:00 +00002637let isTwoAddress = 0 in {
Evan Cheng071a2792007-09-11 19:55:27 +00002638 let Uses = [CL] in {
Evan Cheng64d80e32007-07-19 01:14:50 +00002639 def SHLD32mrCL : I<0xA5, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
Eli Friedmanaace4b12009-06-19 04:48:38 +00002640 "shld{l}\t{%cl, $src2, $dst|$dst, $src2, CL}",
Evan Cheng069287d2006-05-16 07:21:53 +00002641 [(store (X86shld (loadi32 addr:$dst), GR32:$src2, CL),
Evan Cheng071a2792007-09-11 19:55:27 +00002642 addr:$dst)]>, TB;
Evan Cheng64d80e32007-07-19 01:14:50 +00002643 def SHRD32mrCL : I<0xAD, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
Eli Friedmanaace4b12009-06-19 04:48:38 +00002644 "shrd{l}\t{%cl, $src2, $dst|$dst, $src2, CL}",
Evan Cheng069287d2006-05-16 07:21:53 +00002645 [(store (X86shrd (loadi32 addr:$dst), GR32:$src2, CL),
Evan Cheng071a2792007-09-11 19:55:27 +00002646 addr:$dst)]>, TB;
2647 }
Chris Lattner3a173df2004-10-03 20:35:00 +00002648 def SHLD32mri8 : Ii8<0xA4, MRMDestMem,
Evan Cheng64d80e32007-07-19 01:14:50 +00002649 (outs), (ins i32mem:$dst, GR32:$src2, i8imm:$src3),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002650 "shld{l}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Evan Cheng069287d2006-05-16 07:21:53 +00002651 [(store (X86shld (loadi32 addr:$dst), GR32:$src2,
Evan Chenge3413162006-01-09 18:33:28 +00002652 (i8 imm:$src3)), addr:$dst)]>,
Chris Lattnerf124d5e2005-11-18 01:04:42 +00002653 TB;
Chris Lattner3a173df2004-10-03 20:35:00 +00002654 def SHRD32mri8 : Ii8<0xAC, MRMDestMem,
Evan Cheng64d80e32007-07-19 01:14:50 +00002655 (outs), (ins i32mem:$dst, GR32:$src2, i8imm:$src3),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002656 "shrd{l}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Evan Cheng069287d2006-05-16 07:21:53 +00002657 [(store (X86shrd (loadi32 addr:$dst), GR32:$src2,
Evan Chenge3413162006-01-09 18:33:28 +00002658 (i8 imm:$src3)), addr:$dst)]>,
Chris Lattnerf124d5e2005-11-18 01:04:42 +00002659 TB;
Chris Lattner0df53d22005-01-19 07:31:24 +00002660
Evan Cheng071a2792007-09-11 19:55:27 +00002661 let Uses = [CL] in {
Evan Cheng64d80e32007-07-19 01:14:50 +00002662 def SHLD16mrCL : I<0xA5, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
Eli Friedmanaace4b12009-06-19 04:48:38 +00002663 "shld{w}\t{%cl, $src2, $dst|$dst, $src2, CL}",
Evan Cheng069287d2006-05-16 07:21:53 +00002664 [(store (X86shld (loadi16 addr:$dst), GR16:$src2, CL),
Evan Cheng071a2792007-09-11 19:55:27 +00002665 addr:$dst)]>, TB, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00002666 def SHRD16mrCL : I<0xAD, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
Eli Friedmanaace4b12009-06-19 04:48:38 +00002667 "shrd{w}\t{%cl, $src2, $dst|$dst, $src2, CL}",
Evan Cheng069287d2006-05-16 07:21:53 +00002668 [(store (X86shrd (loadi16 addr:$dst), GR16:$src2, CL),
Evan Cheng071a2792007-09-11 19:55:27 +00002669 addr:$dst)]>, TB, OpSize;
2670 }
Chris Lattner0df53d22005-01-19 07:31:24 +00002671 def SHLD16mri8 : Ii8<0xA4, MRMDestMem,
Evan Cheng64d80e32007-07-19 01:14:50 +00002672 (outs), (ins i16mem:$dst, GR16:$src2, i8imm:$src3),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002673 "shld{w}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Evan Cheng069287d2006-05-16 07:21:53 +00002674 [(store (X86shld (loadi16 addr:$dst), GR16:$src2,
Evan Chenge3413162006-01-09 18:33:28 +00002675 (i8 imm:$src3)), addr:$dst)]>,
Chris Lattner0df53d22005-01-19 07:31:24 +00002676 TB, OpSize;
2677 def SHRD16mri8 : Ii8<0xAC, MRMDestMem,
Evan Cheng64d80e32007-07-19 01:14:50 +00002678 (outs), (ins i16mem:$dst, GR16:$src2, i8imm:$src3),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002679 "shrd{w}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Evan Cheng069287d2006-05-16 07:21:53 +00002680 [(store (X86shrd (loadi16 addr:$dst), GR16:$src2,
Evan Chenge3413162006-01-09 18:33:28 +00002681 (i8 imm:$src3)), addr:$dst)]>,
Chris Lattner0df53d22005-01-19 07:31:24 +00002682 TB, OpSize;
Chris Lattner57a02302004-08-11 04:31:00 +00002683}
Evan Cheng24f2ea32007-09-14 21:48:26 +00002684} // Defs = [EFLAGS]
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00002685
2686
Chris Lattnercc65bee2005-01-02 02:35:46 +00002687// Arithmetic.
Evan Cheng24f2ea32007-09-14 21:48:26 +00002688let Defs = [EFLAGS] in {
Chris Lattnercc65bee2005-01-02 02:35:46 +00002689let isCommutable = 1 in { // X = ADD Y, Z --> X = ADD Z, Y
Bill Wendlingab55ebd2008-12-12 00:56:36 +00002690// Register-Register Addition
2691def ADD8rr : I<0x00, MRMDestReg, (outs GR8 :$dst),
2692 (ins GR8 :$src1, GR8 :$src2),
2693 "add{b}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingd350e022008-12-12 21:15:41 +00002694 [(set GR8:$dst, (add GR8:$src1, GR8:$src2)),
Bill Wendlingab55ebd2008-12-12 00:56:36 +00002695 (implicit EFLAGS)]>;
2696
Chris Lattnercc65bee2005-01-02 02:35:46 +00002697let isConvertibleToThreeAddress = 1 in { // Can transform into LEA.
Bill Wendlingab55ebd2008-12-12 00:56:36 +00002698// Register-Register Addition
Evan Cheng071a2792007-09-11 19:55:27 +00002699def ADD16rr : I<0x01, MRMDestReg, (outs GR16:$dst),
2700 (ins GR16:$src1, GR16:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002701 "add{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingd350e022008-12-12 21:15:41 +00002702 [(set GR16:$dst, (add GR16:$src1, GR16:$src2)),
2703 (implicit EFLAGS)]>, OpSize;
Evan Cheng071a2792007-09-11 19:55:27 +00002704def ADD32rr : I<0x01, MRMDestReg, (outs GR32:$dst),
2705 (ins GR32:$src1, GR32:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002706 "add{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingd350e022008-12-12 21:15:41 +00002707 [(set GR32:$dst, (add GR32:$src1, GR32:$src2)),
2708 (implicit EFLAGS)]>;
Chris Lattnercc65bee2005-01-02 02:35:46 +00002709} // end isConvertibleToThreeAddress
2710} // end isCommutable
Bill Wendlingab55ebd2008-12-12 00:56:36 +00002711
Daniel Dunbarf291be32010-03-09 22:50:46 +00002712// These are alternate spellings for use by the disassembler, we mark them as
2713// code gen only to ensure they aren't matched by the assembler.
2714let isCodeGenOnly = 1 in {
2715 def ADD8rr_alt: I<0x02, MRMSrcReg, (outs GR8:$dst), (ins GR8:$src1, GR8:$src2),
2716 "add{b}\t{$src2, $dst|$dst, $src2}", []>;
2717 def ADD16rr_alt: I<0x03, MRMSrcReg,(outs GR16:$dst),(ins GR16:$src1, GR16:$src2),
2718 "add{w}\t{$src2, $dst|$dst, $src2}", []>, OpSize;
2719 def ADD32rr_alt: I<0x03, MRMSrcReg,(outs GR16:$dst),(ins GR16:$src1, GR16:$src2),
2720 "add{l}\t{$src2, $dst|$dst, $src2}", []>;
2721}
2722
Bill Wendlingab55ebd2008-12-12 00:56:36 +00002723// Register-Memory Addition
Evan Cheng071a2792007-09-11 19:55:27 +00002724def ADD8rm : I<0x02, MRMSrcMem, (outs GR8 :$dst),
2725 (ins GR8 :$src1, i8mem :$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002726 "add{b}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingd350e022008-12-12 21:15:41 +00002727 [(set GR8:$dst, (add GR8:$src1, (load addr:$src2))),
2728 (implicit EFLAGS)]>;
Evan Cheng071a2792007-09-11 19:55:27 +00002729def ADD16rm : I<0x03, MRMSrcMem, (outs GR16:$dst),
2730 (ins GR16:$src1, i16mem:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002731 "add{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingd350e022008-12-12 21:15:41 +00002732 [(set GR16:$dst, (add GR16:$src1, (load addr:$src2))),
2733 (implicit EFLAGS)]>, OpSize;
Evan Cheng071a2792007-09-11 19:55:27 +00002734def ADD32rm : I<0x03, MRMSrcMem, (outs GR32:$dst),
2735 (ins GR32:$src1, i32mem:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002736 "add{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingd350e022008-12-12 21:15:41 +00002737 [(set GR32:$dst, (add GR32:$src1, (load addr:$src2))),
2738 (implicit EFLAGS)]>;
Sean Callanan37be5902009-09-15 20:53:57 +00002739
Bill Wendlingab55ebd2008-12-12 00:56:36 +00002740// Register-Integer Addition
2741def ADD8ri : Ii8<0x80, MRM0r, (outs GR8:$dst), (ins GR8:$src1, i8imm:$src2),
2742 "add{b}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingd350e022008-12-12 21:15:41 +00002743 [(set GR8:$dst, (add GR8:$src1, imm:$src2)),
2744 (implicit EFLAGS)]>;
Bill Wendlingab55ebd2008-12-12 00:56:36 +00002745
Chris Lattnercc65bee2005-01-02 02:35:46 +00002746let isConvertibleToThreeAddress = 1 in { // Can transform into LEA.
Bill Wendlingab55ebd2008-12-12 00:56:36 +00002747// Register-Integer Addition
Evan Cheng071a2792007-09-11 19:55:27 +00002748def ADD16ri : Ii16<0x81, MRM0r, (outs GR16:$dst),
2749 (ins GR16:$src1, i16imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002750 "add{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingd350e022008-12-12 21:15:41 +00002751 [(set GR16:$dst, (add GR16:$src1, imm:$src2)),
2752 (implicit EFLAGS)]>, OpSize;
Evan Cheng071a2792007-09-11 19:55:27 +00002753def ADD32ri : Ii32<0x81, MRM0r, (outs GR32:$dst),
2754 (ins GR32:$src1, i32imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002755 "add{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingd350e022008-12-12 21:15:41 +00002756 [(set GR32:$dst, (add GR32:$src1, imm:$src2)),
2757 (implicit EFLAGS)]>;
Evan Cheng071a2792007-09-11 19:55:27 +00002758def ADD16ri8 : Ii8<0x83, MRM0r, (outs GR16:$dst),
2759 (ins GR16:$src1, i16i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002760 "add{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingd350e022008-12-12 21:15:41 +00002761 [(set GR16:$dst, (add GR16:$src1, i16immSExt8:$src2)),
2762 (implicit EFLAGS)]>, OpSize;
Evan Cheng071a2792007-09-11 19:55:27 +00002763def ADD32ri8 : Ii8<0x83, MRM0r, (outs GR32:$dst),
2764 (ins GR32:$src1, i32i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002765 "add{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingd350e022008-12-12 21:15:41 +00002766 [(set GR32:$dst, (add GR32:$src1, i32immSExt8:$src2)),
2767 (implicit EFLAGS)]>;
Evan Cheng09e3c802006-05-19 18:40:54 +00002768}
Chris Lattner57a02302004-08-11 04:31:00 +00002769
2770let isTwoAddress = 0 in {
Bill Wendlingab55ebd2008-12-12 00:56:36 +00002771 // Memory-Register Addition
Bill Wendlingd350e022008-12-12 21:15:41 +00002772 def ADD8mr : I<0x00, MRMDestMem, (outs), (ins i8mem:$dst, GR8:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002773 "add{b}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingd350e022008-12-12 21:15:41 +00002774 [(store (add (load addr:$dst), GR8:$src2), addr:$dst),
2775 (implicit EFLAGS)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00002776 def ADD16mr : I<0x01, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002777 "add{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingd350e022008-12-12 21:15:41 +00002778 [(store (add (load addr:$dst), GR16:$src2), addr:$dst),
2779 (implicit EFLAGS)]>, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00002780 def ADD32mr : I<0x01, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002781 "add{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingd350e022008-12-12 21:15:41 +00002782 [(store (add (load addr:$dst), GR32:$src2), addr:$dst),
2783 (implicit EFLAGS)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00002784 def ADD8mi : Ii8<0x80, MRM0m, (outs), (ins i8mem :$dst, i8imm :$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002785 "add{b}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingd350e022008-12-12 21:15:41 +00002786 [(store (add (loadi8 addr:$dst), imm:$src2), addr:$dst),
2787 (implicit EFLAGS)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00002788 def ADD16mi : Ii16<0x81, MRM0m, (outs), (ins i16mem:$dst, i16imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002789 "add{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingd350e022008-12-12 21:15:41 +00002790 [(store (add (loadi16 addr:$dst), imm:$src2), addr:$dst),
2791 (implicit EFLAGS)]>, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00002792 def ADD32mi : Ii32<0x81, MRM0m, (outs), (ins i32mem:$dst, i32imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002793 "add{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingd350e022008-12-12 21:15:41 +00002794 [(store (add (loadi32 addr:$dst), imm:$src2), addr:$dst),
2795 (implicit EFLAGS)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00002796 def ADD16mi8 : Ii8<0x83, MRM0m, (outs), (ins i16mem:$dst, i16i8imm :$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002797 "add{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingd350e022008-12-12 21:15:41 +00002798 [(store (add (load addr:$dst), i16immSExt8:$src2),
2799 addr:$dst),
2800 (implicit EFLAGS)]>, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00002801 def ADD32mi8 : Ii8<0x83, MRM0m, (outs), (ins i32mem:$dst, i32i8imm :$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002802 "add{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingab55ebd2008-12-12 00:56:36 +00002803 [(store (add (load addr:$dst), i32immSExt8:$src2),
Bill Wendlingd350e022008-12-12 21:15:41 +00002804 addr:$dst),
2805 (implicit EFLAGS)]>;
Sean Callananb08ae6b2009-08-11 21:26:06 +00002806
2807 // addition to rAX
2808 def ADD8i8 : Ii8<0x04, RawFrm, (outs), (ins i8imm:$src),
Sean Callanana09caa52009-09-02 00:55:49 +00002809 "add{b}\t{$src, %al|%al, $src}", []>;
Sean Callananb08ae6b2009-08-11 21:26:06 +00002810 def ADD16i16 : Ii16<0x05, RawFrm, (outs), (ins i16imm:$src),
Sean Callanana09caa52009-09-02 00:55:49 +00002811 "add{w}\t{$src, %ax|%ax, $src}", []>, OpSize;
Sean Callananb08ae6b2009-08-11 21:26:06 +00002812 def ADD32i32 : Ii32<0x05, RawFrm, (outs), (ins i32imm:$src),
Sean Callanana09caa52009-09-02 00:55:49 +00002813 "add{l}\t{$src, %eax|%eax, $src}", []>;
Chris Lattner57a02302004-08-11 04:31:00 +00002814}
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00002815
Evan Cheng3154cb62007-10-05 17:59:57 +00002816let Uses = [EFLAGS] in {
Chris Lattner10197ff2005-01-03 01:27:59 +00002817let isCommutable = 1 in { // X = ADC Y, Z --> X = ADC Z, Y
Dale Johannesen874ae252009-06-02 03:12:52 +00002818def ADC8rr : I<0x10, MRMDestReg, (outs GR8:$dst), (ins GR8:$src1, GR8:$src2),
Dale Johannesenca11dae2009-05-18 17:44:15 +00002819 "adc{b}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen874ae252009-06-02 03:12:52 +00002820 [(set GR8:$dst, (adde GR8:$src1, GR8:$src2))]>;
Dale Johannesenca11dae2009-05-18 17:44:15 +00002821def ADC16rr : I<0x11, MRMDestReg, (outs GR16:$dst),
2822 (ins GR16:$src1, GR16:$src2),
2823 "adc{w}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen874ae252009-06-02 03:12:52 +00002824 [(set GR16:$dst, (adde GR16:$src1, GR16:$src2))]>, OpSize;
Dale Johannesenca11dae2009-05-18 17:44:15 +00002825def ADC32rr : I<0x11, MRMDestReg, (outs GR32:$dst),
2826 (ins GR32:$src1, GR32:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002827 "adc{l}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen874ae252009-06-02 03:12:52 +00002828 [(set GR32:$dst, (adde GR32:$src1, GR32:$src2))]>;
Chris Lattner10197ff2005-01-03 01:27:59 +00002829}
Sean Callanan108934c2009-12-18 00:01:26 +00002830
2831def ADC8rr_REV : I<0x12, MRMSrcReg, (outs GR8:$dst), (ins GR8:$src1, GR8:$src2),
2832 "adc{b}\t{$src2, $dst|$dst, $src2}", []>;
2833def ADC16rr_REV : I<0x13, MRMSrcReg, (outs GR16:$dst),
2834 (ins GR16:$src1, GR16:$src2),
2835 "adc{w}\t{$src2, $dst|$dst, $src2}", []>, OpSize;
2836def ADC32rr_REV : I<0x13, MRMSrcReg, (outs GR32:$dst),
2837 (ins GR32:$src1, GR32:$src2),
2838 "adc{l}\t{$src2, $dst|$dst, $src2}", []>;
2839
Dale Johannesenca11dae2009-05-18 17:44:15 +00002840def ADC8rm : I<0x12, MRMSrcMem , (outs GR8:$dst),
2841 (ins GR8:$src1, i8mem:$src2),
2842 "adc{b}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen874ae252009-06-02 03:12:52 +00002843 [(set GR8:$dst, (adde GR8:$src1, (load addr:$src2)))]>;
Dale Johannesenca11dae2009-05-18 17:44:15 +00002844def ADC16rm : I<0x13, MRMSrcMem , (outs GR16:$dst),
2845 (ins GR16:$src1, i16mem:$src2),
2846 "adc{w}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen874ae252009-06-02 03:12:52 +00002847 [(set GR16:$dst, (adde GR16:$src1, (load addr:$src2)))]>,
Dale Johannesen94c9cd12009-05-18 21:41:59 +00002848 OpSize;
Dale Johannesenca11dae2009-05-18 17:44:15 +00002849def ADC32rm : I<0x13, MRMSrcMem , (outs GR32:$dst),
2850 (ins GR32:$src1, i32mem:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002851 "adc{l}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen874ae252009-06-02 03:12:52 +00002852 [(set GR32:$dst, (adde GR32:$src1, (load addr:$src2)))]>;
2853def ADC8ri : Ii8<0x80, MRM2r, (outs GR8:$dst), (ins GR8:$src1, i8imm:$src2),
Dale Johannesenca11dae2009-05-18 17:44:15 +00002854 "adc{b}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen874ae252009-06-02 03:12:52 +00002855 [(set GR8:$dst, (adde GR8:$src1, imm:$src2))]>;
Dale Johannesenca11dae2009-05-18 17:44:15 +00002856def ADC16ri : Ii16<0x81, MRM2r, (outs GR16:$dst),
2857 (ins GR16:$src1, i16imm:$src2),
2858 "adc{w}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen874ae252009-06-02 03:12:52 +00002859 [(set GR16:$dst, (adde GR16:$src1, imm:$src2))]>, OpSize;
Dale Johannesenca11dae2009-05-18 17:44:15 +00002860def ADC16ri8 : Ii8<0x83, MRM2r, (outs GR16:$dst),
2861 (ins GR16:$src1, i16i8imm:$src2),
2862 "adc{w}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen874ae252009-06-02 03:12:52 +00002863 [(set GR16:$dst, (adde GR16:$src1, i16immSExt8:$src2))]>,
2864 OpSize;
Dale Johannesenca11dae2009-05-18 17:44:15 +00002865def ADC32ri : Ii32<0x81, MRM2r, (outs GR32:$dst),
2866 (ins GR32:$src1, i32imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002867 "adc{l}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen874ae252009-06-02 03:12:52 +00002868 [(set GR32:$dst, (adde GR32:$src1, imm:$src2))]>;
Dale Johannesenca11dae2009-05-18 17:44:15 +00002869def ADC32ri8 : Ii8<0x83, MRM2r, (outs GR32:$dst),
2870 (ins GR32:$src1, i32i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002871 "adc{l}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen874ae252009-06-02 03:12:52 +00002872 [(set GR32:$dst, (adde GR32:$src1, i32immSExt8:$src2))]>;
Chris Lattner57a02302004-08-11 04:31:00 +00002873
2874let isTwoAddress = 0 in {
Dale Johannesen874ae252009-06-02 03:12:52 +00002875 def ADC8mr : I<0x10, MRMDestMem, (outs), (ins i8mem:$dst, GR8:$src2),
Dale Johannesenca11dae2009-05-18 17:44:15 +00002876 "adc{b}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen874ae252009-06-02 03:12:52 +00002877 [(store (adde (load addr:$dst), GR8:$src2), addr:$dst)]>;
2878 def ADC16mr : I<0x11, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
Dale Johannesenca11dae2009-05-18 17:44:15 +00002879 "adc{w}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen874ae252009-06-02 03:12:52 +00002880 [(store (adde (load addr:$dst), GR16:$src2), addr:$dst)]>,
2881 OpSize;
2882 def ADC32mr : I<0x11, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002883 "adc{l}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen874ae252009-06-02 03:12:52 +00002884 [(store (adde (load addr:$dst), GR32:$src2), addr:$dst)]>;
2885 def ADC8mi : Ii8<0x80, MRM2m, (outs), (ins i8mem:$dst, i8imm:$src2),
Dale Johannesenca11dae2009-05-18 17:44:15 +00002886 "adc{b}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen874ae252009-06-02 03:12:52 +00002887 [(store (adde (loadi8 addr:$dst), imm:$src2), addr:$dst)]>;
2888 def ADC16mi : Ii16<0x81, MRM2m, (outs), (ins i16mem:$dst, i16imm:$src2),
Dale Johannesenca11dae2009-05-18 17:44:15 +00002889 "adc{w}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen874ae252009-06-02 03:12:52 +00002890 [(store (adde (loadi16 addr:$dst), imm:$src2), addr:$dst)]>,
2891 OpSize;
2892 def ADC16mi8 : Ii8<0x83, MRM2m, (outs), (ins i16mem:$dst, i16i8imm :$src2),
Dale Johannesenca11dae2009-05-18 17:44:15 +00002893 "adc{w}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen874ae252009-06-02 03:12:52 +00002894 [(store (adde (load addr:$dst), i16immSExt8:$src2), addr:$dst)]>,
2895 OpSize;
2896 def ADC32mi : Ii32<0x81, MRM2m, (outs), (ins i32mem:$dst, i32imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002897 "adc{l}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen874ae252009-06-02 03:12:52 +00002898 [(store (adde (loadi32 addr:$dst), imm:$src2), addr:$dst)]>;
2899 def ADC32mi8 : Ii8<0x83, MRM2m, (outs), (ins i32mem:$dst, i32i8imm :$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002900 "adc{l}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen874ae252009-06-02 03:12:52 +00002901 [(store (adde (load addr:$dst), i32immSExt8:$src2), addr:$dst)]>;
Sean Callanand00025a2009-09-11 19:01:56 +00002902
2903 def ADC8i8 : Ii8<0x14, RawFrm, (outs), (ins i8imm:$src),
2904 "adc{b}\t{$src, %al|%al, $src}", []>;
2905 def ADC16i16 : Ii16<0x15, RawFrm, (outs), (ins i16imm:$src),
2906 "adc{w}\t{$src, %ax|%ax, $src}", []>, OpSize;
2907 def ADC32i32 : Ii32<0x15, RawFrm, (outs), (ins i32imm:$src),
2908 "adc{l}\t{$src, %eax|%eax, $src}", []>;
Dale Johannesen874ae252009-06-02 03:12:52 +00002909}
Evan Cheng3154cb62007-10-05 17:59:57 +00002910} // Uses = [EFLAGS]
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00002911
Bill Wendlingab55ebd2008-12-12 00:56:36 +00002912// Register-Register Subtraction
2913def SUB8rr : I<0x28, MRMDestReg, (outs GR8:$dst), (ins GR8:$src1, GR8:$src2),
2914 "sub{b}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingd350e022008-12-12 21:15:41 +00002915 [(set GR8:$dst, (sub GR8:$src1, GR8:$src2)),
2916 (implicit EFLAGS)]>;
Bill Wendlingab55ebd2008-12-12 00:56:36 +00002917def SUB16rr : I<0x29, MRMDestReg, (outs GR16:$dst), (ins GR16:$src1,GR16:$src2),
2918 "sub{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingd350e022008-12-12 21:15:41 +00002919 [(set GR16:$dst, (sub GR16:$src1, GR16:$src2)),
2920 (implicit EFLAGS)]>, OpSize;
Bill Wendlingab55ebd2008-12-12 00:56:36 +00002921def SUB32rr : I<0x29, MRMDestReg, (outs GR32:$dst), (ins GR32:$src1,GR32:$src2),
2922 "sub{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingd350e022008-12-12 21:15:41 +00002923 [(set GR32:$dst, (sub GR32:$src1, GR32:$src2)),
2924 (implicit EFLAGS)]>;
Bill Wendlingab55ebd2008-12-12 00:56:36 +00002925
Sean Callanan108934c2009-12-18 00:01:26 +00002926def SUB8rr_REV : I<0x2A, MRMSrcReg, (outs GR8:$dst), (ins GR8:$src1, GR8:$src2),
2927 "sub{b}\t{$src2, $dst|$dst, $src2}", []>;
2928def SUB16rr_REV : I<0x2B, MRMSrcReg, (outs GR16:$dst),
2929 (ins GR16:$src1, GR16:$src2),
2930 "sub{w}\t{$src2, $dst|$dst, $src2}", []>, OpSize;
2931def SUB32rr_REV : I<0x2B, MRMSrcReg, (outs GR32:$dst),
2932 (ins GR32:$src1, GR32:$src2),
2933 "sub{l}\t{$src2, $dst|$dst, $src2}", []>;
2934
Bill Wendlingab55ebd2008-12-12 00:56:36 +00002935// Register-Memory Subtraction
2936def SUB8rm : I<0x2A, MRMSrcMem, (outs GR8 :$dst),
2937 (ins GR8 :$src1, i8mem :$src2),
2938 "sub{b}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingd350e022008-12-12 21:15:41 +00002939 [(set GR8:$dst, (sub GR8:$src1, (load addr:$src2))),
2940 (implicit EFLAGS)]>;
Bill Wendlingab55ebd2008-12-12 00:56:36 +00002941def SUB16rm : I<0x2B, MRMSrcMem, (outs GR16:$dst),
2942 (ins GR16:$src1, i16mem:$src2),
2943 "sub{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingd350e022008-12-12 21:15:41 +00002944 [(set GR16:$dst, (sub GR16:$src1, (load addr:$src2))),
2945 (implicit EFLAGS)]>, OpSize;
Bill Wendlingab55ebd2008-12-12 00:56:36 +00002946def SUB32rm : I<0x2B, MRMSrcMem, (outs GR32:$dst),
2947 (ins GR32:$src1, i32mem:$src2),
2948 "sub{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingd350e022008-12-12 21:15:41 +00002949 [(set GR32:$dst, (sub GR32:$src1, (load addr:$src2))),
2950 (implicit EFLAGS)]>;
Bill Wendlingab55ebd2008-12-12 00:56:36 +00002951
2952// Register-Integer Subtraction
2953def SUB8ri : Ii8 <0x80, MRM5r, (outs GR8:$dst),
2954 (ins GR8:$src1, i8imm:$src2),
2955 "sub{b}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingd350e022008-12-12 21:15:41 +00002956 [(set GR8:$dst, (sub GR8:$src1, imm:$src2)),
2957 (implicit EFLAGS)]>;
Bill Wendlingab55ebd2008-12-12 00:56:36 +00002958def SUB16ri : Ii16<0x81, MRM5r, (outs GR16:$dst),
2959 (ins GR16:$src1, i16imm:$src2),
2960 "sub{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingd350e022008-12-12 21:15:41 +00002961 [(set GR16:$dst, (sub GR16:$src1, imm:$src2)),
2962 (implicit EFLAGS)]>, OpSize;
Bill Wendlingab55ebd2008-12-12 00:56:36 +00002963def SUB32ri : Ii32<0x81, MRM5r, (outs GR32:$dst),
2964 (ins GR32:$src1, i32imm:$src2),
2965 "sub{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingd350e022008-12-12 21:15:41 +00002966 [(set GR32:$dst, (sub GR32:$src1, imm:$src2)),
2967 (implicit EFLAGS)]>;
Bill Wendlingab55ebd2008-12-12 00:56:36 +00002968def SUB16ri8 : Ii8<0x83, MRM5r, (outs GR16:$dst),
2969 (ins GR16:$src1, i16i8imm:$src2),
2970 "sub{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingd350e022008-12-12 21:15:41 +00002971 [(set GR16:$dst, (sub GR16:$src1, i16immSExt8:$src2)),
2972 (implicit EFLAGS)]>, OpSize;
Bill Wendlingab55ebd2008-12-12 00:56:36 +00002973def SUB32ri8 : Ii8<0x83, MRM5r, (outs GR32:$dst),
2974 (ins GR32:$src1, i32i8imm:$src2),
2975 "sub{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingd350e022008-12-12 21:15:41 +00002976 [(set GR32:$dst, (sub GR32:$src1, i32immSExt8:$src2)),
2977 (implicit EFLAGS)]>;
Bill Wendlingab55ebd2008-12-12 00:56:36 +00002978
Chris Lattner57a02302004-08-11 04:31:00 +00002979let isTwoAddress = 0 in {
Bill Wendlingab55ebd2008-12-12 00:56:36 +00002980 // Memory-Register Subtraction
Evan Cheng64d80e32007-07-19 01:14:50 +00002981 def SUB8mr : I<0x28, MRMDestMem, (outs), (ins i8mem :$dst, GR8 :$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002982 "sub{b}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingd350e022008-12-12 21:15:41 +00002983 [(store (sub (load addr:$dst), GR8:$src2), addr:$dst),
2984 (implicit EFLAGS)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00002985 def SUB16mr : I<0x29, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002986 "sub{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingd350e022008-12-12 21:15:41 +00002987 [(store (sub (load addr:$dst), GR16:$src2), addr:$dst),
2988 (implicit EFLAGS)]>, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00002989 def SUB32mr : I<0x29, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002990 "sub{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingd350e022008-12-12 21:15:41 +00002991 [(store (sub (load addr:$dst), GR32:$src2), addr:$dst),
2992 (implicit EFLAGS)]>;
Bill Wendlingab55ebd2008-12-12 00:56:36 +00002993
2994 // Memory-Integer Subtraction
Evan Cheng64d80e32007-07-19 01:14:50 +00002995 def SUB8mi : Ii8<0x80, MRM5m, (outs), (ins i8mem :$dst, i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002996 "sub{b}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingd350e022008-12-12 21:15:41 +00002997 [(store (sub (loadi8 addr:$dst), imm:$src2), addr:$dst),
2998 (implicit EFLAGS)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00002999 def SUB16mi : Ii16<0x81, MRM5m, (outs), (ins i16mem:$dst, i16imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003000 "sub{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingd350e022008-12-12 21:15:41 +00003001 [(store (sub (loadi16 addr:$dst), imm:$src2),addr:$dst),
3002 (implicit EFLAGS)]>, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00003003 def SUB32mi : Ii32<0x81, MRM5m, (outs), (ins i32mem:$dst, i32imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003004 "sub{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingd350e022008-12-12 21:15:41 +00003005 [(store (sub (loadi32 addr:$dst), imm:$src2),addr:$dst),
3006 (implicit EFLAGS)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00003007 def SUB16mi8 : Ii8<0x83, MRM5m, (outs), (ins i16mem:$dst, i16i8imm :$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003008 "sub{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingab55ebd2008-12-12 00:56:36 +00003009 [(store (sub (load addr:$dst), i16immSExt8:$src2),
Bill Wendlingd350e022008-12-12 21:15:41 +00003010 addr:$dst),
3011 (implicit EFLAGS)]>, OpSize;
Bill Wendlingab55ebd2008-12-12 00:56:36 +00003012 def SUB32mi8 : Ii8<0x83, MRM5m, (outs), (ins i32mem:$dst, i32i8imm :$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003013 "sub{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingab55ebd2008-12-12 00:56:36 +00003014 [(store (sub (load addr:$dst), i32immSExt8:$src2),
Bill Wendlingd350e022008-12-12 21:15:41 +00003015 addr:$dst),
3016 (implicit EFLAGS)]>;
Sean Callanand00025a2009-09-11 19:01:56 +00003017
3018 def SUB8i8 : Ii8<0x2C, RawFrm, (outs), (ins i8imm:$src),
3019 "sub{b}\t{$src, %al|%al, $src}", []>;
3020 def SUB16i16 : Ii16<0x2D, RawFrm, (outs), (ins i16imm:$src),
3021 "sub{w}\t{$src, %ax|%ax, $src}", []>, OpSize;
3022 def SUB32i32 : Ii32<0x2D, RawFrm, (outs), (ins i32imm:$src),
3023 "sub{l}\t{$src, %eax|%eax, $src}", []>;
Chris Lattner57a02302004-08-11 04:31:00 +00003024}
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00003025
Evan Cheng3154cb62007-10-05 17:59:57 +00003026let Uses = [EFLAGS] in {
Dale Johannesenca11dae2009-05-18 17:44:15 +00003027def SBB8rr : I<0x18, MRMDestReg, (outs GR8:$dst),
3028 (ins GR8:$src1, GR8:$src2),
3029 "sbb{b}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen874ae252009-06-02 03:12:52 +00003030 [(set GR8:$dst, (sube GR8:$src1, GR8:$src2))]>;
Dale Johannesenca11dae2009-05-18 17:44:15 +00003031def SBB16rr : I<0x19, MRMDestReg, (outs GR16:$dst),
3032 (ins GR16:$src1, GR16:$src2),
3033 "sbb{w}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen874ae252009-06-02 03:12:52 +00003034 [(set GR16:$dst, (sube GR16:$src1, GR16:$src2))]>, OpSize;
Dale Johannesenca11dae2009-05-18 17:44:15 +00003035def SBB32rr : I<0x19, MRMDestReg, (outs GR32:$dst),
3036 (ins GR32:$src1, GR32:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003037 "sbb{l}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen874ae252009-06-02 03:12:52 +00003038 [(set GR32:$dst, (sube GR32:$src1, GR32:$src2))]>;
Chris Lattnerd93d3b02004-10-06 04:01:02 +00003039
Chris Lattner57a02302004-08-11 04:31:00 +00003040let isTwoAddress = 0 in {
Dale Johannesenca11dae2009-05-18 17:44:15 +00003041 def SBB8mr : I<0x18, MRMDestMem, (outs), (ins i8mem:$dst, GR8:$src2),
3042 "sbb{b}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen874ae252009-06-02 03:12:52 +00003043 [(store (sube (load addr:$dst), GR8:$src2), addr:$dst)]>;
Dale Johannesenca11dae2009-05-18 17:44:15 +00003044 def SBB16mr : I<0x19, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
3045 "sbb{w}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen874ae252009-06-02 03:12:52 +00003046 [(store (sube (load addr:$dst), GR16:$src2), addr:$dst)]>,
Dale Johannesen94c9cd12009-05-18 21:41:59 +00003047 OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00003048 def SBB32mr : I<0x19, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003049 "sbb{l}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen874ae252009-06-02 03:12:52 +00003050 [(store (sube (load addr:$dst), GR32:$src2), addr:$dst)]>;
Chris Lattner8f60e4d2010-02-05 22:56:11 +00003051 def SBB8mi : Ii8<0x80, MRM3m, (outs), (ins i8mem:$dst, i8imm:$src2),
3052 "sbb{b}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen874ae252009-06-02 03:12:52 +00003053 [(store (sube (loadi8 addr:$dst), imm:$src2), addr:$dst)]>;
Dale Johannesenca11dae2009-05-18 17:44:15 +00003054 def SBB16mi : Ii16<0x81, MRM3m, (outs), (ins i16mem:$dst, i16imm:$src2),
3055 "sbb{w}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen874ae252009-06-02 03:12:52 +00003056 [(store (sube (loadi16 addr:$dst), imm:$src2), addr:$dst)]>,
Dale Johannesen94c9cd12009-05-18 21:41:59 +00003057 OpSize;
Dale Johannesenca11dae2009-05-18 17:44:15 +00003058 def SBB16mi8 : Ii8<0x83, MRM3m, (outs), (ins i16mem:$dst, i16i8imm :$src2),
3059 "sbb{w}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen874ae252009-06-02 03:12:52 +00003060 [(store (sube (load addr:$dst), i16immSExt8:$src2), addr:$dst)]>,
Dale Johannesen94c9cd12009-05-18 21:41:59 +00003061 OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00003062 def SBB32mi : Ii32<0x81, MRM3m, (outs), (ins i32mem:$dst, i32imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003063 "sbb{l}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen874ae252009-06-02 03:12:52 +00003064 [(store (sube (loadi32 addr:$dst), imm:$src2), addr:$dst)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00003065 def SBB32mi8 : Ii8<0x83, MRM3m, (outs), (ins i32mem:$dst, i32i8imm :$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003066 "sbb{l}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen874ae252009-06-02 03:12:52 +00003067 [(store (sube (load addr:$dst), i32immSExt8:$src2), addr:$dst)]>;
Sean Callanand00025a2009-09-11 19:01:56 +00003068
3069 def SBB8i8 : Ii8<0x1C, RawFrm, (outs), (ins i8imm:$src),
3070 "sbb{b}\t{$src, %al|%al, $src}", []>;
3071 def SBB16i16 : Ii16<0x1D, RawFrm, (outs), (ins i16imm:$src),
3072 "sbb{w}\t{$src, %ax|%ax, $src}", []>, OpSize;
3073 def SBB32i32 : Ii32<0x1D, RawFrm, (outs), (ins i32imm:$src),
3074 "sbb{l}\t{$src, %eax|%eax, $src}", []>;
Chris Lattner57a02302004-08-11 04:31:00 +00003075}
Sean Callanan108934c2009-12-18 00:01:26 +00003076
3077def SBB8rr_REV : I<0x1A, MRMSrcReg, (outs GR8:$dst), (ins GR8:$src1, GR8:$src2),
3078 "sbb{b}\t{$src2, $dst|$dst, $src2}", []>;
3079def SBB16rr_REV : I<0x1B, MRMSrcReg, (outs GR16:$dst),
3080 (ins GR16:$src1, GR16:$src2),
3081 "sbb{w}\t{$src2, $dst|$dst, $src2}", []>, OpSize;
3082def SBB32rr_REV : I<0x1B, MRMSrcReg, (outs GR32:$dst),
3083 (ins GR32:$src1, GR32:$src2),
3084 "sbb{l}\t{$src2, $dst|$dst, $src2}", []>;
3085
Dale Johannesenca11dae2009-05-18 17:44:15 +00003086def SBB8rm : I<0x1A, MRMSrcMem, (outs GR8:$dst), (ins GR8:$src1, i8mem:$src2),
3087 "sbb{b}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen874ae252009-06-02 03:12:52 +00003088 [(set GR8:$dst, (sube GR8:$src1, (load addr:$src2)))]>;
Dale Johannesenca11dae2009-05-18 17:44:15 +00003089def SBB16rm : I<0x1B, MRMSrcMem, (outs GR16:$dst),
3090 (ins GR16:$src1, i16mem:$src2),
3091 "sbb{w}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen874ae252009-06-02 03:12:52 +00003092 [(set GR16:$dst, (sube GR16:$src1, (load addr:$src2)))]>,
Dale Johannesen94c9cd12009-05-18 21:41:59 +00003093 OpSize;
Dale Johannesenca11dae2009-05-18 17:44:15 +00003094def SBB32rm : I<0x1B, MRMSrcMem, (outs GR32:$dst),
3095 (ins GR32:$src1, i32mem:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003096 "sbb{l}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen874ae252009-06-02 03:12:52 +00003097 [(set GR32:$dst, (sube GR32:$src1, (load addr:$src2)))]>;
Dale Johannesenca11dae2009-05-18 17:44:15 +00003098def SBB8ri : Ii8<0x80, MRM3r, (outs GR8:$dst), (ins GR8:$src1, i8imm:$src2),
3099 "sbb{b}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen874ae252009-06-02 03:12:52 +00003100 [(set GR8:$dst, (sube GR8:$src1, imm:$src2))]>;
Dale Johannesenca11dae2009-05-18 17:44:15 +00003101def SBB16ri : Ii16<0x81, MRM3r, (outs GR16:$dst),
3102 (ins GR16:$src1, i16imm:$src2),
3103 "sbb{w}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen874ae252009-06-02 03:12:52 +00003104 [(set GR16:$dst, (sube GR16:$src1, imm:$src2))]>, OpSize;
Dale Johannesenca11dae2009-05-18 17:44:15 +00003105def SBB16ri8 : Ii8<0x83, MRM3r, (outs GR16:$dst),
3106 (ins GR16:$src1, i16i8imm:$src2),
3107 "sbb{w}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen874ae252009-06-02 03:12:52 +00003108 [(set GR16:$dst, (sube GR16:$src1, i16immSExt8:$src2))]>,
3109 OpSize;
Dale Johannesenca11dae2009-05-18 17:44:15 +00003110def SBB32ri : Ii32<0x81, MRM3r, (outs GR32:$dst),
3111 (ins GR32:$src1, i32imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003112 "sbb{l}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen874ae252009-06-02 03:12:52 +00003113 [(set GR32:$dst, (sube GR32:$src1, imm:$src2))]>;
Dale Johannesenca11dae2009-05-18 17:44:15 +00003114def SBB32ri8 : Ii8<0x83, MRM3r, (outs GR32:$dst),
3115 (ins GR32:$src1, i32i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003116 "sbb{l}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen874ae252009-06-02 03:12:52 +00003117 [(set GR32:$dst, (sube GR32:$src1, i32immSExt8:$src2))]>;
Evan Cheng3154cb62007-10-05 17:59:57 +00003118} // Uses = [EFLAGS]
Evan Cheng24f2ea32007-09-14 21:48:26 +00003119} // Defs = [EFLAGS]
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00003120
Evan Cheng24f2ea32007-09-14 21:48:26 +00003121let Defs = [EFLAGS] in {
Chris Lattner10197ff2005-01-03 01:27:59 +00003122let isCommutable = 1 in { // X = IMUL Y, Z --> X = IMUL Z, Y
Bill Wendlingd350e022008-12-12 21:15:41 +00003123// Register-Register Signed Integer Multiply
Bill Wendlingab55ebd2008-12-12 00:56:36 +00003124def IMUL16rr : I<0xAF, MRMSrcReg, (outs GR16:$dst), (ins GR16:$src1,GR16:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003125 "imul{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingd350e022008-12-12 21:15:41 +00003126 [(set GR16:$dst, (mul GR16:$src1, GR16:$src2)),
3127 (implicit EFLAGS)]>, TB, OpSize;
Bill Wendlingab55ebd2008-12-12 00:56:36 +00003128def IMUL32rr : I<0xAF, MRMSrcReg, (outs GR32:$dst), (ins GR32:$src1,GR32:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003129 "imul{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingd350e022008-12-12 21:15:41 +00003130 [(set GR32:$dst, (mul GR32:$src1, GR32:$src2)),
3131 (implicit EFLAGS)]>, TB;
Chris Lattner10197ff2005-01-03 01:27:59 +00003132}
Bill Wendlingab55ebd2008-12-12 00:56:36 +00003133
Bill Wendlingd350e022008-12-12 21:15:41 +00003134// Register-Memory Signed Integer Multiply
Bill Wendlingab55ebd2008-12-12 00:56:36 +00003135def IMUL16rm : I<0xAF, MRMSrcMem, (outs GR16:$dst),
3136 (ins GR16:$src1, i16mem:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003137 "imul{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingd350e022008-12-12 21:15:41 +00003138 [(set GR16:$dst, (mul GR16:$src1, (load addr:$src2))),
3139 (implicit EFLAGS)]>, TB, OpSize;
Sean Callanan108934c2009-12-18 00:01:26 +00003140def IMUL32rm : I<0xAF, MRMSrcMem, (outs GR32:$dst),
3141 (ins GR32:$src1, i32mem:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003142 "imul{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingd350e022008-12-12 21:15:41 +00003143 [(set GR32:$dst, (mul GR32:$src1, (load addr:$src2))),
3144 (implicit EFLAGS)]>, TB;
Evan Cheng24f2ea32007-09-14 21:48:26 +00003145} // Defs = [EFLAGS]
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00003146} // end Two Address instructions
3147
Chris Lattnerf5d3a832004-08-11 05:31:07 +00003148// Suprisingly enough, these are not two address instructions!
Evan Cheng24f2ea32007-09-14 21:48:26 +00003149let Defs = [EFLAGS] in {
Bill Wendlingd350e022008-12-12 21:15:41 +00003150// Register-Integer Signed Integer Multiply
Evan Cheng069287d2006-05-16 07:21:53 +00003151def IMUL16rri : Ii16<0x69, MRMSrcReg, // GR16 = GR16*I16
Evan Cheng64d80e32007-07-19 01:14:50 +00003152 (outs GR16:$dst), (ins GR16:$src1, i16imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003153 "imul{w}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Bill Wendlingd350e022008-12-12 21:15:41 +00003154 [(set GR16:$dst, (mul GR16:$src1, imm:$src2)),
3155 (implicit EFLAGS)]>, OpSize;
Evan Cheng069287d2006-05-16 07:21:53 +00003156def IMUL32rri : Ii32<0x69, MRMSrcReg, // GR32 = GR32*I32
Evan Cheng64d80e32007-07-19 01:14:50 +00003157 (outs GR32:$dst), (ins GR32:$src1, i32imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003158 "imul{l}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Bill Wendlingd350e022008-12-12 21:15:41 +00003159 [(set GR32:$dst, (mul GR32:$src1, imm:$src2)),
3160 (implicit EFLAGS)]>;
Evan Cheng069287d2006-05-16 07:21:53 +00003161def IMUL16rri8 : Ii8<0x6B, MRMSrcReg, // GR16 = GR16*I8
Evan Cheng64d80e32007-07-19 01:14:50 +00003162 (outs GR16:$dst), (ins GR16:$src1, i16i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003163 "imul{w}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Bill Wendlingd350e022008-12-12 21:15:41 +00003164 [(set GR16:$dst, (mul GR16:$src1, i16immSExt8:$src2)),
3165 (implicit EFLAGS)]>, OpSize;
Evan Cheng069287d2006-05-16 07:21:53 +00003166def IMUL32rri8 : Ii8<0x6B, MRMSrcReg, // GR32 = GR32*I8
Evan Cheng64d80e32007-07-19 01:14:50 +00003167 (outs GR32:$dst), (ins GR32:$src1, i32i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003168 "imul{l}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Bill Wendlingd350e022008-12-12 21:15:41 +00003169 [(set GR32:$dst, (mul GR32:$src1, i32immSExt8:$src2)),
3170 (implicit EFLAGS)]>;
Chris Lattnerf5d3a832004-08-11 05:31:07 +00003171
Bill Wendlingd350e022008-12-12 21:15:41 +00003172// Memory-Integer Signed Integer Multiply
Sean Callanan108934c2009-12-18 00:01:26 +00003173def IMUL16rmi : Ii16<0x69, MRMSrcMem, // GR16 = [mem16]*I16
Evan Cheng64d80e32007-07-19 01:14:50 +00003174 (outs GR16:$dst), (ins i16mem:$src1, i16imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003175 "imul{w}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Bill Wendlingd350e022008-12-12 21:15:41 +00003176 [(set GR16:$dst, (mul (load addr:$src1), imm:$src2)),
3177 (implicit EFLAGS)]>, OpSize;
Sean Callanan108934c2009-12-18 00:01:26 +00003178def IMUL32rmi : Ii32<0x69, MRMSrcMem, // GR32 = [mem32]*I32
Evan Cheng64d80e32007-07-19 01:14:50 +00003179 (outs GR32:$dst), (ins i32mem:$src1, i32imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003180 "imul{l}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Bill Wendlingd350e022008-12-12 21:15:41 +00003181 [(set GR32:$dst, (mul (load addr:$src1), imm:$src2)),
3182 (implicit EFLAGS)]>;
Evan Cheng069287d2006-05-16 07:21:53 +00003183def IMUL16rmi8 : Ii8<0x6B, MRMSrcMem, // GR16 = [mem16]*I8
Evan Cheng64d80e32007-07-19 01:14:50 +00003184 (outs GR16:$dst), (ins i16mem:$src1, i16i8imm :$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003185 "imul{w}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Bill Wendlingab55ebd2008-12-12 00:56:36 +00003186 [(set GR16:$dst, (mul (load addr:$src1),
Bill Wendlingd350e022008-12-12 21:15:41 +00003187 i16immSExt8:$src2)),
3188 (implicit EFLAGS)]>, OpSize;
Evan Cheng069287d2006-05-16 07:21:53 +00003189def IMUL32rmi8 : Ii8<0x6B, MRMSrcMem, // GR32 = [mem32]*I8
Evan Cheng64d80e32007-07-19 01:14:50 +00003190 (outs GR32:$dst), (ins i32mem:$src1, i32i8imm: $src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003191 "imul{l}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Bill Wendlingab55ebd2008-12-12 00:56:36 +00003192 [(set GR32:$dst, (mul (load addr:$src1),
Bill Wendlingd350e022008-12-12 21:15:41 +00003193 i32immSExt8:$src2)),
3194 (implicit EFLAGS)]>;
Evan Cheng24f2ea32007-09-14 21:48:26 +00003195} // Defs = [EFLAGS]
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00003196
3197//===----------------------------------------------------------------------===//
3198// Test instructions are just like AND, except they don't generate a result.
Chris Lattner3a173df2004-10-03 20:35:00 +00003199//
Evan Cheng0488db92007-09-25 01:57:46 +00003200let Defs = [EFLAGS] in {
Chris Lattnercc65bee2005-01-02 02:35:46 +00003201let isCommutable = 1 in { // TEST X, Y --> TEST Y, X
Daniel Dunbarb93c72c2010-03-08 21:10:36 +00003202def TEST8rr : I<0x84, MRMSrcReg, (outs), (ins GR8:$src1, GR8:$src2),
Evan Chenge5f62042007-09-29 00:00:36 +00003203 "test{b}\t{$src2, $src1|$src1, $src2}",
Chris Lattnere3486a42010-03-19 00:01:11 +00003204 [(set EFLAGS, (X86cmp (and_su GR8:$src1, GR8:$src2), 0))]>;
Daniel Dunbarb93c72c2010-03-08 21:10:36 +00003205def TEST16rr : I<0x85, MRMSrcReg, (outs), (ins GR16:$src1, GR16:$src2),
Evan Chenge5f62042007-09-29 00:00:36 +00003206 "test{w}\t{$src2, $src1|$src1, $src2}",
Chris Lattnere3486a42010-03-19 00:01:11 +00003207 [(set EFLAGS, (X86cmp (and_su GR16:$src1, GR16:$src2),
3208 0))]>,
Evan Chenge5f62042007-09-29 00:00:36 +00003209 OpSize;
Daniel Dunbarb93c72c2010-03-08 21:10:36 +00003210def TEST32rr : I<0x85, MRMSrcReg, (outs), (ins GR32:$src1, GR32:$src2),
Evan Chenge5f62042007-09-29 00:00:36 +00003211 "test{l}\t{$src2, $src1|$src1, $src2}",
Chris Lattnere3486a42010-03-19 00:01:11 +00003212 [(set EFLAGS, (X86cmp (and_su GR32:$src1, GR32:$src2),
3213 0))]>;
Chris Lattnercc65bee2005-01-02 02:35:46 +00003214}
Evan Cheng734503b2006-09-11 02:19:56 +00003215
Sean Callanan4a93b712009-09-01 18:14:18 +00003216def TEST8i8 : Ii8<0xA8, RawFrm, (outs), (ins i8imm:$src),
3217 "test{b}\t{$src, %al|%al, $src}", []>;
3218def TEST16i16 : Ii16<0xA9, RawFrm, (outs), (ins i16imm:$src),
3219 "test{w}\t{$src, %ax|%ax, $src}", []>, OpSize;
3220def TEST32i32 : Ii32<0xA9, RawFrm, (outs), (ins i32imm:$src),
3221 "test{l}\t{$src, %eax|%eax, $src}", []>;
3222
Evan Cheng64d80e32007-07-19 01:14:50 +00003223def TEST8rm : I<0x84, MRMSrcMem, (outs), (ins GR8 :$src1, i8mem :$src2),
Evan Chenge5f62042007-09-29 00:00:36 +00003224 "test{b}\t{$src2, $src1|$src1, $src2}",
Chris Lattnere3486a42010-03-19 00:01:11 +00003225 [(set EFLAGS, (X86cmp (and GR8:$src1, (loadi8 addr:$src2)),
3226 0))]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00003227def TEST16rm : I<0x85, MRMSrcMem, (outs), (ins GR16:$src1, i16mem:$src2),
Evan Chenge5f62042007-09-29 00:00:36 +00003228 "test{w}\t{$src2, $src1|$src1, $src2}",
Chris Lattnere3486a42010-03-19 00:01:11 +00003229 [(set EFLAGS, (X86cmp (and GR16:$src1,
3230 (loadi16 addr:$src2)), 0))]>, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00003231def TEST32rm : I<0x85, MRMSrcMem, (outs), (ins GR32:$src1, i32mem:$src2),
Evan Chenge5f62042007-09-29 00:00:36 +00003232 "test{l}\t{$src2, $src1|$src1, $src2}",
Chris Lattnere3486a42010-03-19 00:01:11 +00003233 [(set EFLAGS, (X86cmp (and GR32:$src1,
3234 (loadi32 addr:$src2)), 0))]>;
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00003235
Evan Cheng069287d2006-05-16 07:21:53 +00003236def TEST8ri : Ii8 <0xF6, MRM0r, // flags = GR8 & imm8
Evan Cheng64d80e32007-07-19 01:14:50 +00003237 (outs), (ins GR8:$src1, i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003238 "test{b}\t{$src2, $src1|$src1, $src2}",
Chris Lattnere3486a42010-03-19 00:01:11 +00003239 [(set EFLAGS, (X86cmp (and_su GR8:$src1, imm:$src2), 0))]>;
Evan Cheng069287d2006-05-16 07:21:53 +00003240def TEST16ri : Ii16<0xF7, MRM0r, // flags = GR16 & imm16
Evan Cheng64d80e32007-07-19 01:14:50 +00003241 (outs), (ins GR16:$src1, i16imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003242 "test{w}\t{$src2, $src1|$src1, $src2}",
Chris Lattnere3486a42010-03-19 00:01:11 +00003243 [(set EFLAGS, (X86cmp (and_su GR16:$src1, imm:$src2), 0))]>,
3244 OpSize;
Evan Cheng069287d2006-05-16 07:21:53 +00003245def TEST32ri : Ii32<0xF7, MRM0r, // flags = GR32 & imm32
Evan Cheng64d80e32007-07-19 01:14:50 +00003246 (outs), (ins GR32:$src1, i32imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003247 "test{l}\t{$src2, $src1|$src1, $src2}",
Chris Lattnere3486a42010-03-19 00:01:11 +00003248 [(set EFLAGS, (X86cmp (and_su GR32:$src1, imm:$src2), 0))]>;
Evan Cheng734503b2006-09-11 02:19:56 +00003249
Evan Chenge5f62042007-09-29 00:00:36 +00003250def TEST8mi : Ii8 <0xF6, MRM0m, // flags = [mem8] & imm8
Evan Cheng64d80e32007-07-19 01:14:50 +00003251 (outs), (ins i8mem:$src1, i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003252 "test{b}\t{$src2, $src1|$src1, $src2}",
Chris Lattnere3486a42010-03-19 00:01:11 +00003253 [(set EFLAGS, (X86cmp (and (loadi8 addr:$src1), imm:$src2),
3254 0))]>;
Evan Chenge5f62042007-09-29 00:00:36 +00003255def TEST16mi : Ii16<0xF7, MRM0m, // flags = [mem16] & imm16
Evan Cheng64d80e32007-07-19 01:14:50 +00003256 (outs), (ins i16mem:$src1, i16imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003257 "test{w}\t{$src2, $src1|$src1, $src2}",
Chris Lattnere3486a42010-03-19 00:01:11 +00003258 [(set EFLAGS, (X86cmp (and (loadi16 addr:$src1), imm:$src2),
3259 0))]>, OpSize;
Evan Chenge5f62042007-09-29 00:00:36 +00003260def TEST32mi : Ii32<0xF7, MRM0m, // flags = [mem32] & imm32
Evan Cheng64d80e32007-07-19 01:14:50 +00003261 (outs), (ins i32mem:$src1, i32imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003262 "test{l}\t{$src2, $src1|$src1, $src2}",
Chris Lattnere3486a42010-03-19 00:01:11 +00003263 [(set EFLAGS, (X86cmp (and (loadi32 addr:$src1), imm:$src2),
3264 0))]>;
Evan Cheng0488db92007-09-25 01:57:46 +00003265} // Defs = [EFLAGS]
3266
3267
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00003268// Condition code ops, incl. set if equal/not equal/...
Chris Lattnerba7e7562008-01-10 07:59:24 +00003269let Defs = [EFLAGS], Uses = [AH], neverHasSideEffects = 1 in
Evan Cheng071a2792007-09-11 19:55:27 +00003270def SAHF : I<0x9E, RawFrm, (outs), (ins), "sahf", []>; // flags = AH
Chris Lattnerba7e7562008-01-10 07:59:24 +00003271let Defs = [AH], Uses = [EFLAGS], neverHasSideEffects = 1 in
Evan Cheng071a2792007-09-11 19:55:27 +00003272def LAHF : I<0x9F, RawFrm, (outs), (ins), "lahf", []>; // AH = flags
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00003273
Evan Cheng0488db92007-09-25 01:57:46 +00003274let Uses = [EFLAGS] in {
Evan Chengad9c0a32009-12-15 00:53:42 +00003275// Use sbb to materialize carry bit.
Evan Chengad9c0a32009-12-15 00:53:42 +00003276let Defs = [EFLAGS], isCodeGenOnly = 1 in {
Chris Lattnerc74e3332010-02-05 21:13:48 +00003277// FIXME: These are pseudo ops that should be replaced with Pat<> patterns.
3278// However, Pat<> can't replicate the destination reg into the inputs of the
3279// result.
3280// FIXME: Change these to have encoding Pseudo when X86MCCodeEmitter replaces
3281// X86CodeEmitter.
3282def SETB_C8r : I<0x18, MRMInitReg, (outs GR8:$dst), (ins), "",
Evan Chengad9c0a32009-12-15 00:53:42 +00003283 [(set GR8:$dst, (X86setcc_c X86_COND_B, EFLAGS))]>;
Chris Lattnerc74e3332010-02-05 21:13:48 +00003284def SETB_C16r : I<0x19, MRMInitReg, (outs GR16:$dst), (ins), "",
Evan Cheng2e489c42009-12-16 00:53:11 +00003285 [(set GR16:$dst, (X86setcc_c X86_COND_B, EFLAGS))]>,
Evan Chengad9c0a32009-12-15 00:53:42 +00003286 OpSize;
Chris Lattnerc74e3332010-02-05 21:13:48 +00003287def SETB_C32r : I<0x19, MRMInitReg, (outs GR32:$dst), (ins), "",
Evan Cheng2e489c42009-12-16 00:53:11 +00003288 [(set GR32:$dst, (X86setcc_c X86_COND_B, EFLAGS))]>;
Evan Chengad9c0a32009-12-15 00:53:42 +00003289} // isCodeGenOnly
3290
Chris Lattner3a173df2004-10-03 20:35:00 +00003291def SETEr : I<0x94, MRM0r,
Evan Cheng64d80e32007-07-19 01:14:50 +00003292 (outs GR8 :$dst), (ins),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003293 "sete\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +00003294 [(set GR8:$dst, (X86setcc X86_COND_E, EFLAGS))]>,
Evan Cheng069287d2006-05-16 07:21:53 +00003295 TB; // GR8 = ==
Chris Lattner3a173df2004-10-03 20:35:00 +00003296def SETEm : I<0x94, MRM0m,
Evan Cheng64d80e32007-07-19 01:14:50 +00003297 (outs), (ins i8mem:$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003298 "sete\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +00003299 [(store (X86setcc X86_COND_E, EFLAGS), addr:$dst)]>,
Evan Chengd5781fc2005-12-21 20:21:51 +00003300 TB; // [mem8] = ==
Bill Wendling9f248742008-12-02 00:07:05 +00003301
Chris Lattner3a173df2004-10-03 20:35:00 +00003302def SETNEr : I<0x95, MRM0r,
Evan Cheng64d80e32007-07-19 01:14:50 +00003303 (outs GR8 :$dst), (ins),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003304 "setne\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +00003305 [(set GR8:$dst, (X86setcc X86_COND_NE, EFLAGS))]>,
Evan Cheng069287d2006-05-16 07:21:53 +00003306 TB; // GR8 = !=
Chris Lattner3a173df2004-10-03 20:35:00 +00003307def SETNEm : I<0x95, MRM0m,
Evan Cheng64d80e32007-07-19 01:14:50 +00003308 (outs), (ins i8mem:$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003309 "setne\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +00003310 [(store (X86setcc X86_COND_NE, EFLAGS), addr:$dst)]>,
Evan Chengd5781fc2005-12-21 20:21:51 +00003311 TB; // [mem8] = !=
Bill Wendling9f248742008-12-02 00:07:05 +00003312
Evan Chengd5781fc2005-12-21 20:21:51 +00003313def SETLr : I<0x9C, MRM0r,
Evan Cheng64d80e32007-07-19 01:14:50 +00003314 (outs GR8 :$dst), (ins),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003315 "setl\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +00003316 [(set GR8:$dst, (X86setcc X86_COND_L, EFLAGS))]>,
Evan Cheng069287d2006-05-16 07:21:53 +00003317 TB; // GR8 = < signed
Evan Chengd5781fc2005-12-21 20:21:51 +00003318def SETLm : I<0x9C, MRM0m,
Evan Cheng64d80e32007-07-19 01:14:50 +00003319 (outs), (ins i8mem:$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003320 "setl\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +00003321 [(store (X86setcc X86_COND_L, EFLAGS), addr:$dst)]>,
Evan Chengd5781fc2005-12-21 20:21:51 +00003322 TB; // [mem8] = < signed
Bill Wendling9f248742008-12-02 00:07:05 +00003323
Evan Chengd5781fc2005-12-21 20:21:51 +00003324def SETGEr : I<0x9D, MRM0r,
Evan Cheng64d80e32007-07-19 01:14:50 +00003325 (outs GR8 :$dst), (ins),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003326 "setge\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +00003327 [(set GR8:$dst, (X86setcc X86_COND_GE, EFLAGS))]>,
Evan Cheng069287d2006-05-16 07:21:53 +00003328 TB; // GR8 = >= signed
Evan Chengd5781fc2005-12-21 20:21:51 +00003329def SETGEm : I<0x9D, MRM0m,
Evan Cheng64d80e32007-07-19 01:14:50 +00003330 (outs), (ins i8mem:$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003331 "setge\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +00003332 [(store (X86setcc X86_COND_GE, EFLAGS), addr:$dst)]>,
Evan Chengd5781fc2005-12-21 20:21:51 +00003333 TB; // [mem8] = >= signed
Bill Wendling9f248742008-12-02 00:07:05 +00003334
Evan Chengd5781fc2005-12-21 20:21:51 +00003335def SETLEr : I<0x9E, MRM0r,
Evan Cheng64d80e32007-07-19 01:14:50 +00003336 (outs GR8 :$dst), (ins),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003337 "setle\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +00003338 [(set GR8:$dst, (X86setcc X86_COND_LE, EFLAGS))]>,
Evan Cheng069287d2006-05-16 07:21:53 +00003339 TB; // GR8 = <= signed
Evan Chengd5781fc2005-12-21 20:21:51 +00003340def SETLEm : I<0x9E, MRM0m,
Evan Cheng64d80e32007-07-19 01:14:50 +00003341 (outs), (ins i8mem:$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003342 "setle\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +00003343 [(store (X86setcc X86_COND_LE, EFLAGS), addr:$dst)]>,
Evan Chengd5781fc2005-12-21 20:21:51 +00003344 TB; // [mem8] = <= signed
Bill Wendling9f248742008-12-02 00:07:05 +00003345
Evan Chengd5781fc2005-12-21 20:21:51 +00003346def SETGr : I<0x9F, MRM0r,
Evan Cheng64d80e32007-07-19 01:14:50 +00003347 (outs GR8 :$dst), (ins),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003348 "setg\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +00003349 [(set GR8:$dst, (X86setcc X86_COND_G, EFLAGS))]>,
Evan Cheng069287d2006-05-16 07:21:53 +00003350 TB; // GR8 = > signed
Evan Chengd5781fc2005-12-21 20:21:51 +00003351def SETGm : I<0x9F, MRM0m,
Evan Cheng64d80e32007-07-19 01:14:50 +00003352 (outs), (ins i8mem:$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003353 "setg\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +00003354 [(store (X86setcc X86_COND_G, EFLAGS), addr:$dst)]>,
Evan Chengd5781fc2005-12-21 20:21:51 +00003355 TB; // [mem8] = > signed
3356
3357def SETBr : I<0x92, MRM0r,
Evan Cheng64d80e32007-07-19 01:14:50 +00003358 (outs GR8 :$dst), (ins),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003359 "setb\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +00003360 [(set GR8:$dst, (X86setcc X86_COND_B, EFLAGS))]>,
Evan Cheng069287d2006-05-16 07:21:53 +00003361 TB; // GR8 = < unsign
Evan Chengd5781fc2005-12-21 20:21:51 +00003362def SETBm : I<0x92, MRM0m,
Evan Cheng64d80e32007-07-19 01:14:50 +00003363 (outs), (ins i8mem:$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003364 "setb\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +00003365 [(store (X86setcc X86_COND_B, EFLAGS), addr:$dst)]>,
Evan Chengd5781fc2005-12-21 20:21:51 +00003366 TB; // [mem8] = < unsign
Bill Wendling9f248742008-12-02 00:07:05 +00003367
Evan Chengd5781fc2005-12-21 20:21:51 +00003368def SETAEr : I<0x93, MRM0r,
Evan Cheng64d80e32007-07-19 01:14:50 +00003369 (outs GR8 :$dst), (ins),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003370 "setae\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +00003371 [(set GR8:$dst, (X86setcc X86_COND_AE, EFLAGS))]>,
Evan Cheng069287d2006-05-16 07:21:53 +00003372 TB; // GR8 = >= unsign
Evan Chengd5781fc2005-12-21 20:21:51 +00003373def SETAEm : I<0x93, MRM0m,
Evan Cheng64d80e32007-07-19 01:14:50 +00003374 (outs), (ins i8mem:$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003375 "setae\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +00003376 [(store (X86setcc X86_COND_AE, EFLAGS), addr:$dst)]>,
Evan Chengd5781fc2005-12-21 20:21:51 +00003377 TB; // [mem8] = >= unsign
Bill Wendling9f248742008-12-02 00:07:05 +00003378
Chris Lattner3a173df2004-10-03 20:35:00 +00003379def SETBEr : I<0x96, MRM0r,
Evan Cheng64d80e32007-07-19 01:14:50 +00003380 (outs GR8 :$dst), (ins),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003381 "setbe\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +00003382 [(set GR8:$dst, (X86setcc X86_COND_BE, EFLAGS))]>,
Evan Cheng069287d2006-05-16 07:21:53 +00003383 TB; // GR8 = <= unsign
Chris Lattner3a173df2004-10-03 20:35:00 +00003384def SETBEm : I<0x96, MRM0m,
Evan Cheng64d80e32007-07-19 01:14:50 +00003385 (outs), (ins i8mem:$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003386 "setbe\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +00003387 [(store (X86setcc X86_COND_BE, EFLAGS), addr:$dst)]>,
Evan Chengd5781fc2005-12-21 20:21:51 +00003388 TB; // [mem8] = <= unsign
Bill Wendling9f248742008-12-02 00:07:05 +00003389
Chris Lattner3a173df2004-10-03 20:35:00 +00003390def SETAr : I<0x97, MRM0r,
Evan Cheng64d80e32007-07-19 01:14:50 +00003391 (outs GR8 :$dst), (ins),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003392 "seta\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +00003393 [(set GR8:$dst, (X86setcc X86_COND_A, EFLAGS))]>,
Evan Cheng069287d2006-05-16 07:21:53 +00003394 TB; // GR8 = > signed
Chris Lattner3a173df2004-10-03 20:35:00 +00003395def SETAm : I<0x97, MRM0m,
Evan Cheng64d80e32007-07-19 01:14:50 +00003396 (outs), (ins i8mem:$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003397 "seta\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +00003398 [(store (X86setcc X86_COND_A, EFLAGS), addr:$dst)]>,
Evan Chengd5781fc2005-12-21 20:21:51 +00003399 TB; // [mem8] = > signed
Evan Chengd9558e02006-01-06 00:43:03 +00003400
Chris Lattner3a173df2004-10-03 20:35:00 +00003401def SETSr : I<0x98, MRM0r,
Evan Cheng64d80e32007-07-19 01:14:50 +00003402 (outs GR8 :$dst), (ins),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003403 "sets\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +00003404 [(set GR8:$dst, (X86setcc X86_COND_S, EFLAGS))]>,
Evan Cheng069287d2006-05-16 07:21:53 +00003405 TB; // GR8 = <sign bit>
Chris Lattner3a173df2004-10-03 20:35:00 +00003406def SETSm : I<0x98, MRM0m,
Evan Cheng64d80e32007-07-19 01:14:50 +00003407 (outs), (ins i8mem:$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003408 "sets\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +00003409 [(store (X86setcc X86_COND_S, EFLAGS), addr:$dst)]>,
Evan Chengd9558e02006-01-06 00:43:03 +00003410 TB; // [mem8] = <sign bit>
Chris Lattner3a173df2004-10-03 20:35:00 +00003411def SETNSr : I<0x99, MRM0r,
Evan Cheng64d80e32007-07-19 01:14:50 +00003412 (outs GR8 :$dst), (ins),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003413 "setns\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +00003414 [(set GR8:$dst, (X86setcc X86_COND_NS, EFLAGS))]>,
Evan Cheng069287d2006-05-16 07:21:53 +00003415 TB; // GR8 = !<sign bit>
Chris Lattner3a173df2004-10-03 20:35:00 +00003416def SETNSm : I<0x99, MRM0m,
Evan Cheng64d80e32007-07-19 01:14:50 +00003417 (outs), (ins i8mem:$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003418 "setns\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +00003419 [(store (X86setcc X86_COND_NS, EFLAGS), addr:$dst)]>,
Evan Chengd9558e02006-01-06 00:43:03 +00003420 TB; // [mem8] = !<sign bit>
Bill Wendling9f248742008-12-02 00:07:05 +00003421
Chris Lattner3a173df2004-10-03 20:35:00 +00003422def SETPr : I<0x9A, MRM0r,
Evan Cheng64d80e32007-07-19 01:14:50 +00003423 (outs GR8 :$dst), (ins),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003424 "setp\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +00003425 [(set GR8:$dst, (X86setcc X86_COND_P, EFLAGS))]>,
Evan Cheng069287d2006-05-16 07:21:53 +00003426 TB; // GR8 = parity
Chris Lattner3a173df2004-10-03 20:35:00 +00003427def SETPm : I<0x9A, MRM0m,
Evan Cheng64d80e32007-07-19 01:14:50 +00003428 (outs), (ins i8mem:$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003429 "setp\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +00003430 [(store (X86setcc X86_COND_P, EFLAGS), addr:$dst)]>,
Evan Chengd9558e02006-01-06 00:43:03 +00003431 TB; // [mem8] = parity
Chris Lattnercc65bee2005-01-02 02:35:46 +00003432def SETNPr : I<0x9B, MRM0r,
Evan Cheng64d80e32007-07-19 01:14:50 +00003433 (outs GR8 :$dst), (ins),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003434 "setnp\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +00003435 [(set GR8:$dst, (X86setcc X86_COND_NP, EFLAGS))]>,
Evan Cheng069287d2006-05-16 07:21:53 +00003436 TB; // GR8 = not parity
Chris Lattnercc65bee2005-01-02 02:35:46 +00003437def SETNPm : I<0x9B, MRM0m,
Evan Cheng64d80e32007-07-19 01:14:50 +00003438 (outs), (ins i8mem:$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003439 "setnp\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +00003440 [(store (X86setcc X86_COND_NP, EFLAGS), addr:$dst)]>,
Evan Chengd9558e02006-01-06 00:43:03 +00003441 TB; // [mem8] = not parity
Bill Wendling9f248742008-12-02 00:07:05 +00003442
3443def SETOr : I<0x90, MRM0r,
3444 (outs GR8 :$dst), (ins),
3445 "seto\t$dst",
3446 [(set GR8:$dst, (X86setcc X86_COND_O, EFLAGS))]>,
3447 TB; // GR8 = overflow
3448def SETOm : I<0x90, MRM0m,
3449 (outs), (ins i8mem:$dst),
3450 "seto\t$dst",
3451 [(store (X86setcc X86_COND_O, EFLAGS), addr:$dst)]>,
3452 TB; // [mem8] = overflow
3453def SETNOr : I<0x91, MRM0r,
3454 (outs GR8 :$dst), (ins),
3455 "setno\t$dst",
3456 [(set GR8:$dst, (X86setcc X86_COND_NO, EFLAGS))]>,
3457 TB; // GR8 = not overflow
3458def SETNOm : I<0x91, MRM0m,
3459 (outs), (ins i8mem:$dst),
3460 "setno\t$dst",
3461 [(store (X86setcc X86_COND_NO, EFLAGS), addr:$dst)]>,
3462 TB; // [mem8] = not overflow
Evan Cheng0488db92007-09-25 01:57:46 +00003463} // Uses = [EFLAGS]
3464
Chris Lattner1cca5e32003-08-03 21:54:21 +00003465
3466// Integer comparisons
Evan Cheng24f2ea32007-09-14 21:48:26 +00003467let Defs = [EFLAGS] in {
Sean Callanana09caa52009-09-02 00:55:49 +00003468def CMP8i8 : Ii8<0x3C, RawFrm, (outs), (ins i8imm:$src),
3469 "cmp{b}\t{$src, %al|%al, $src}", []>;
3470def CMP16i16 : Ii16<0x3D, RawFrm, (outs), (ins i16imm:$src),
3471 "cmp{w}\t{$src, %ax|%ax, $src}", []>, OpSize;
3472def CMP32i32 : Ii32<0x3D, RawFrm, (outs), (ins i32imm:$src),
3473 "cmp{l}\t{$src, %eax|%eax, $src}", []>;
3474
Chris Lattner3a173df2004-10-03 20:35:00 +00003475def CMP8rr : I<0x38, MRMDestReg,
Evan Cheng64d80e32007-07-19 01:14:50 +00003476 (outs), (ins GR8 :$src1, GR8 :$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003477 "cmp{b}\t{$src2, $src1|$src1, $src2}",
Chris Lattnere3486a42010-03-19 00:01:11 +00003478 [(set EFLAGS, (X86cmp GR8:$src1, GR8:$src2))]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00003479def CMP16rr : I<0x39, MRMDestReg,
Evan Cheng64d80e32007-07-19 01:14:50 +00003480 (outs), (ins GR16:$src1, GR16:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003481 "cmp{w}\t{$src2, $src1|$src1, $src2}",
Chris Lattnere3486a42010-03-19 00:01:11 +00003482 [(set EFLAGS, (X86cmp GR16:$src1, GR16:$src2))]>, OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00003483def CMP32rr : I<0x39, MRMDestReg,
Evan Cheng64d80e32007-07-19 01:14:50 +00003484 (outs), (ins GR32:$src1, GR32:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003485 "cmp{l}\t{$src2, $src1|$src1, $src2}",
Chris Lattnere3486a42010-03-19 00:01:11 +00003486 [(set EFLAGS, (X86cmp GR32:$src1, GR32:$src2))]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00003487def CMP8mr : I<0x38, MRMDestMem,
Evan Cheng64d80e32007-07-19 01:14:50 +00003488 (outs), (ins i8mem :$src1, GR8 :$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003489 "cmp{b}\t{$src2, $src1|$src1, $src2}",
Chris Lattnere3486a42010-03-19 00:01:11 +00003490 [(set EFLAGS, (X86cmp (loadi8 addr:$src1), GR8:$src2))]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00003491def CMP16mr : I<0x39, MRMDestMem,
Evan Cheng64d80e32007-07-19 01:14:50 +00003492 (outs), (ins i16mem:$src1, GR16:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003493 "cmp{w}\t{$src2, $src1|$src1, $src2}",
Chris Lattnere3486a42010-03-19 00:01:11 +00003494 [(set EFLAGS, (X86cmp (loadi16 addr:$src1), GR16:$src2))]>,
3495 OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00003496def CMP32mr : I<0x39, MRMDestMem,
Evan Cheng64d80e32007-07-19 01:14:50 +00003497 (outs), (ins i32mem:$src1, GR32:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003498 "cmp{l}\t{$src2, $src1|$src1, $src2}",
Chris Lattnere3486a42010-03-19 00:01:11 +00003499 [(set EFLAGS, (X86cmp (loadi32 addr:$src1), GR32:$src2))]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00003500def CMP8rm : I<0x3A, MRMSrcMem,
Evan Cheng64d80e32007-07-19 01:14:50 +00003501 (outs), (ins GR8 :$src1, i8mem :$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003502 "cmp{b}\t{$src2, $src1|$src1, $src2}",
Chris Lattnere3486a42010-03-19 00:01:11 +00003503 [(set EFLAGS, (X86cmp GR8:$src1, (loadi8 addr:$src2)))]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00003504def CMP16rm : I<0x3B, MRMSrcMem,
Evan Cheng64d80e32007-07-19 01:14:50 +00003505 (outs), (ins GR16:$src1, i16mem:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003506 "cmp{w}\t{$src2, $src1|$src1, $src2}",
Chris Lattnere3486a42010-03-19 00:01:11 +00003507 [(set EFLAGS, (X86cmp GR16:$src1, (loadi16 addr:$src2)))]>,
3508 OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00003509def CMP32rm : I<0x3B, MRMSrcMem,
Evan Cheng64d80e32007-07-19 01:14:50 +00003510 (outs), (ins GR32:$src1, i32mem:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003511 "cmp{l}\t{$src2, $src1|$src1, $src2}",
Chris Lattnere3486a42010-03-19 00:01:11 +00003512 [(set EFLAGS, (X86cmp GR32:$src1, (loadi32 addr:$src2)))]>;
Daniel Dunbar1e8ee892010-03-09 22:50:40 +00003513
3514// These are alternate spellings for use by the disassembler, we mark them as
3515// code gen only to ensure they aren't matched by the assembler.
3516let isCodeGenOnly = 1 in {
3517 def CMP8rr_alt : I<0x3A, MRMSrcReg, (outs), (ins GR8:$src1, GR8:$src2),
3518 "cmp{b}\t{$src2, $src1|$src1, $src2}", []>;
3519 def CMP16rr_alt : I<0x3B, MRMSrcReg, (outs), (ins GR16:$src1, GR16:$src2),
3520 "cmp{w}\t{$src2, $src1|$src1, $src2}", []>, OpSize;
3521 def CMP32rr_alt : I<0x3B, MRMSrcReg, (outs), (ins GR32:$src1, GR32:$src2),
3522 "cmp{l}\t{$src2, $src1|$src1, $src2}", []>;
3523}
3524
Chris Lattner3a173df2004-10-03 20:35:00 +00003525def CMP8ri : Ii8<0x80, MRM7r,
Evan Cheng64d80e32007-07-19 01:14:50 +00003526 (outs), (ins GR8:$src1, i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003527 "cmp{b}\t{$src2, $src1|$src1, $src2}",
Chris Lattnere3486a42010-03-19 00:01:11 +00003528 [(set EFLAGS, (X86cmp GR8:$src1, imm:$src2))]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00003529def CMP16ri : Ii16<0x81, MRM7r,
Evan Cheng64d80e32007-07-19 01:14:50 +00003530 (outs), (ins GR16:$src1, i16imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003531 "cmp{w}\t{$src2, $src1|$src1, $src2}",
Chris Lattnere3486a42010-03-19 00:01:11 +00003532 [(set EFLAGS, (X86cmp GR16:$src1, imm:$src2))]>, OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00003533def CMP32ri : Ii32<0x81, MRM7r,
Evan Cheng64d80e32007-07-19 01:14:50 +00003534 (outs), (ins GR32:$src1, i32imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003535 "cmp{l}\t{$src2, $src1|$src1, $src2}",
Chris Lattnere3486a42010-03-19 00:01:11 +00003536 [(set EFLAGS, (X86cmp GR32:$src1, imm:$src2))]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00003537def CMP8mi : Ii8 <0x80, MRM7m,
Evan Cheng64d80e32007-07-19 01:14:50 +00003538 (outs), (ins i8mem :$src1, i8imm :$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003539 "cmp{b}\t{$src2, $src1|$src1, $src2}",
Chris Lattnere3486a42010-03-19 00:01:11 +00003540 [(set EFLAGS, (X86cmp (loadi8 addr:$src1), imm:$src2))]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00003541def CMP16mi : Ii16<0x81, MRM7m,
Evan Cheng64d80e32007-07-19 01:14:50 +00003542 (outs), (ins i16mem:$src1, i16imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003543 "cmp{w}\t{$src2, $src1|$src1, $src2}",
Chris Lattnere3486a42010-03-19 00:01:11 +00003544 [(set EFLAGS, (X86cmp (loadi16 addr:$src1), imm:$src2))]>,
3545 OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00003546def CMP32mi : Ii32<0x81, MRM7m,
Evan Cheng64d80e32007-07-19 01:14:50 +00003547 (outs), (ins i32mem:$src1, i32imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003548 "cmp{l}\t{$src2, $src1|$src1, $src2}",
Chris Lattnere3486a42010-03-19 00:01:11 +00003549 [(set EFLAGS, (X86cmp (loadi32 addr:$src1), imm:$src2))]>;
Chris Lattner29b4dd02006-03-23 16:13:50 +00003550def CMP16ri8 : Ii8<0x83, MRM7r,
Evan Cheng64d80e32007-07-19 01:14:50 +00003551 (outs), (ins GR16:$src1, i16i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003552 "cmp{w}\t{$src2, $src1|$src1, $src2}",
Chris Lattnere3486a42010-03-19 00:01:11 +00003553 [(set EFLAGS, (X86cmp GR16:$src1, i16immSExt8:$src2))]>,
3554 OpSize;
Chris Lattner29b4dd02006-03-23 16:13:50 +00003555def CMP16mi8 : Ii8<0x83, MRM7m,
Evan Cheng64d80e32007-07-19 01:14:50 +00003556 (outs), (ins i16mem:$src1, i16i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003557 "cmp{w}\t{$src2, $src1|$src1, $src2}",
Chris Lattnere3486a42010-03-19 00:01:11 +00003558 [(set EFLAGS, (X86cmp (loadi16 addr:$src1),
3559 i16immSExt8:$src2))]>, OpSize;
Chris Lattner29b4dd02006-03-23 16:13:50 +00003560def CMP32mi8 : Ii8<0x83, MRM7m,
Evan Cheng64d80e32007-07-19 01:14:50 +00003561 (outs), (ins i32mem:$src1, i32i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003562 "cmp{l}\t{$src2, $src1|$src1, $src2}",
Chris Lattnere3486a42010-03-19 00:01:11 +00003563 [(set EFLAGS, (X86cmp (loadi32 addr:$src1),
3564 i32immSExt8:$src2))]>;
Chris Lattner29b4dd02006-03-23 16:13:50 +00003565def CMP32ri8 : Ii8<0x83, MRM7r,
Evan Cheng64d80e32007-07-19 01:14:50 +00003566 (outs), (ins GR32:$src1, i32i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003567 "cmp{l}\t{$src2, $src1|$src1, $src2}",
Chris Lattnere3486a42010-03-19 00:01:11 +00003568 [(set EFLAGS, (X86cmp GR32:$src1, i32immSExt8:$src2))]>;
Evan Cheng0488db92007-09-25 01:57:46 +00003569} // Defs = [EFLAGS]
3570
Dan Gohmanc7a37d42008-12-23 22:45:23 +00003571// Bit tests.
Dan Gohmanc7a37d42008-12-23 22:45:23 +00003572// TODO: BTC, BTR, and BTS
3573let Defs = [EFLAGS] in {
Dan Gohman0c89b7e2009-01-13 20:32:45 +00003574def BT16rr : I<0xA3, MRMDestReg, (outs), (ins GR16:$src1, GR16:$src2),
Dan Gohmanc7a37d42008-12-23 22:45:23 +00003575 "bt{w}\t{$src2, $src1|$src1, $src2}",
Chris Lattnere3486a42010-03-19 00:01:11 +00003576 [(set EFLAGS, (X86bt GR16:$src1, GR16:$src2))]>, OpSize, TB;
Dan Gohman0c89b7e2009-01-13 20:32:45 +00003577def BT32rr : I<0xA3, MRMDestReg, (outs), (ins GR32:$src1, GR32:$src2),
Dan Gohmanc7a37d42008-12-23 22:45:23 +00003578 "bt{l}\t{$src2, $src1|$src1, $src2}",
Chris Lattnere3486a42010-03-19 00:01:11 +00003579 [(set EFLAGS, (X86bt GR32:$src1, GR32:$src2))]>, TB;
Dan Gohmanf31408d2009-01-13 23:23:30 +00003580
3581// Unlike with the register+register form, the memory+register form of the
3582// bt instruction does not ignore the high bits of the index. From ISel's
Sean Callanan108934c2009-12-18 00:01:26 +00003583// perspective, this is pretty bizarre. Make these instructions disassembly
3584// only for now.
3585
3586def BT16mr : I<0xA3, MRMDestMem, (outs), (ins i16mem:$src1, GR16:$src2),
3587 "bt{w}\t{$src2, $src1|$src1, $src2}",
Dan Gohmanf31408d2009-01-13 23:23:30 +00003588// [(X86bt (loadi16 addr:$src1), GR16:$src2),
Sean Callanan108934c2009-12-18 00:01:26 +00003589// (implicit EFLAGS)]
3590 []
3591 >, OpSize, TB, Requires<[FastBTMem]>;
3592def BT32mr : I<0xA3, MRMDestMem, (outs), (ins i32mem:$src1, GR32:$src2),
3593 "bt{l}\t{$src2, $src1|$src1, $src2}",
Dan Gohmanf31408d2009-01-13 23:23:30 +00003594// [(X86bt (loadi32 addr:$src1), GR32:$src2),
Sean Callanan108934c2009-12-18 00:01:26 +00003595// (implicit EFLAGS)]
3596 []
3597 >, TB, Requires<[FastBTMem]>;
Dan Gohman4afe15b2009-01-13 20:33:23 +00003598
3599def BT16ri8 : Ii8<0xBA, MRM4r, (outs), (ins GR16:$src1, i16i8imm:$src2),
3600 "bt{w}\t{$src2, $src1|$src1, $src2}",
Chris Lattnere3486a42010-03-19 00:01:11 +00003601 [(set EFLAGS, (X86bt GR16:$src1, i16immSExt8:$src2))]>,
3602 OpSize, TB;
Dan Gohman4afe15b2009-01-13 20:33:23 +00003603def BT32ri8 : Ii8<0xBA, MRM4r, (outs), (ins GR32:$src1, i32i8imm:$src2),
3604 "bt{l}\t{$src2, $src1|$src1, $src2}",
Chris Lattnere3486a42010-03-19 00:01:11 +00003605 [(set EFLAGS, (X86bt GR32:$src1, i32immSExt8:$src2))]>, TB;
Dan Gohman4afe15b2009-01-13 20:33:23 +00003606// Note that these instructions don't need FastBTMem because that
3607// only applies when the other operand is in a register. When it's
3608// an immediate, bt is still fast.
3609def BT16mi8 : Ii8<0xBA, MRM4m, (outs), (ins i16mem:$src1, i16i8imm:$src2),
3610 "bt{w}\t{$src2, $src1|$src1, $src2}",
Chris Lattnere3486a42010-03-19 00:01:11 +00003611 [(set EFLAGS, (X86bt (loadi16 addr:$src1), i16immSExt8:$src2))
3612 ]>, OpSize, TB;
Dan Gohman4afe15b2009-01-13 20:33:23 +00003613def BT32mi8 : Ii8<0xBA, MRM4m, (outs), (ins i32mem:$src1, i32i8imm:$src2),
3614 "bt{l}\t{$src2, $src1|$src1, $src2}",
Chris Lattnere3486a42010-03-19 00:01:11 +00003615 [(set EFLAGS, (X86bt (loadi32 addr:$src1), i32immSExt8:$src2))
3616 ]>, TB;
Sean Callanan108934c2009-12-18 00:01:26 +00003617
3618def BTC16rr : I<0xBB, MRMDestReg, (outs), (ins GR16:$src1, GR16:$src2),
3619 "btc{w}\t{$src2, $src1|$src1, $src2}", []>, OpSize, TB;
3620def BTC32rr : I<0xBB, MRMDestReg, (outs), (ins GR32:$src1, GR32:$src2),
3621 "btc{l}\t{$src2, $src1|$src1, $src2}", []>, TB;
3622def BTC16mr : I<0xBB, MRMDestMem, (outs), (ins i16mem:$src1, GR16:$src2),
3623 "btc{w}\t{$src2, $src1|$src1, $src2}", []>, OpSize, TB;
3624def BTC32mr : I<0xBB, MRMDestMem, (outs), (ins i32mem:$src1, GR32:$src2),
3625 "btc{l}\t{$src2, $src1|$src1, $src2}", []>, TB;
3626def BTC16ri8 : Ii8<0xBA, MRM7r, (outs), (ins GR16:$src1, i16i8imm:$src2),
3627 "btc{w}\t{$src2, $src1|$src1, $src2}", []>, OpSize, TB;
3628def BTC32ri8 : Ii8<0xBA, MRM7r, (outs), (ins GR32:$src1, i32i8imm:$src2),
3629 "btc{l}\t{$src2, $src1|$src1, $src2}", []>, TB;
3630def BTC16mi8 : Ii8<0xBA, MRM7m, (outs), (ins i16mem:$src1, i16i8imm:$src2),
3631 "btc{w}\t{$src2, $src1|$src1, $src2}", []>, OpSize, TB;
3632def BTC32mi8 : Ii8<0xBA, MRM7m, (outs), (ins i32mem:$src1, i32i8imm:$src2),
3633 "btc{l}\t{$src2, $src1|$src1, $src2}", []>, TB;
3634
3635def BTR16rr : I<0xB3, MRMDestReg, (outs), (ins GR16:$src1, GR16:$src2),
3636 "btr{w}\t{$src2, $src1|$src1, $src2}", []>, OpSize, TB;
3637def BTR32rr : I<0xB3, MRMDestReg, (outs), (ins GR32:$src1, GR32:$src2),
3638 "btr{l}\t{$src2, $src1|$src1, $src2}", []>, TB;
3639def BTR16mr : I<0xB3, MRMDestMem, (outs), (ins i16mem:$src1, GR16:$src2),
3640 "btr{w}\t{$src2, $src1|$src1, $src2}", []>, OpSize, TB;
3641def BTR32mr : I<0xB3, MRMDestMem, (outs), (ins i32mem:$src1, GR32:$src2),
3642 "btr{l}\t{$src2, $src1|$src1, $src2}", []>, TB;
3643def BTR16ri8 : Ii8<0xBA, MRM6r, (outs), (ins GR16:$src1, i16i8imm:$src2),
3644 "btr{w}\t{$src2, $src1|$src1, $src2}", []>, OpSize, TB;
3645def BTR32ri8 : Ii8<0xBA, MRM6r, (outs), (ins GR32:$src1, i32i8imm:$src2),
3646 "btr{l}\t{$src2, $src1|$src1, $src2}", []>, TB;
3647def BTR16mi8 : Ii8<0xBA, MRM6m, (outs), (ins i16mem:$src1, i16i8imm:$src2),
3648 "btr{w}\t{$src2, $src1|$src1, $src2}", []>, OpSize, TB;
3649def BTR32mi8 : Ii8<0xBA, MRM6m, (outs), (ins i32mem:$src1, i32i8imm:$src2),
3650 "btr{l}\t{$src2, $src1|$src1, $src2}", []>, TB;
3651
3652def BTS16rr : I<0xAB, MRMDestReg, (outs), (ins GR16:$src1, GR16:$src2),
3653 "bts{w}\t{$src2, $src1|$src1, $src2}", []>, OpSize, TB;
3654def BTS32rr : I<0xAB, MRMDestReg, (outs), (ins GR32:$src1, GR32:$src2),
3655 "bts{l}\t{$src2, $src1|$src1, $src2}", []>, TB;
3656def BTS16mr : I<0xAB, MRMDestMem, (outs), (ins i16mem:$src1, GR16:$src2),
3657 "bts{w}\t{$src2, $src1|$src1, $src2}", []>, OpSize, TB;
3658def BTS32mr : I<0xAB, MRMDestMem, (outs), (ins i32mem:$src1, GR32:$src2),
3659 "bts{l}\t{$src2, $src1|$src1, $src2}", []>, TB;
3660def BTS16ri8 : Ii8<0xBA, MRM5r, (outs), (ins GR16:$src1, i16i8imm:$src2),
3661 "bts{w}\t{$src2, $src1|$src1, $src2}", []>, OpSize, TB;
3662def BTS32ri8 : Ii8<0xBA, MRM5r, (outs), (ins GR32:$src1, i32i8imm:$src2),
3663 "bts{l}\t{$src2, $src1|$src1, $src2}", []>, TB;
3664def BTS16mi8 : Ii8<0xBA, MRM5m, (outs), (ins i16mem:$src1, i16i8imm:$src2),
3665 "bts{w}\t{$src2, $src1|$src1, $src2}", []>, OpSize, TB;
3666def BTS32mi8 : Ii8<0xBA, MRM5m, (outs), (ins i32mem:$src1, i32i8imm:$src2),
3667 "bts{l}\t{$src2, $src1|$src1, $src2}", []>, TB;
Dan Gohmanc7a37d42008-12-23 22:45:23 +00003668} // Defs = [EFLAGS]
3669
Chris Lattner1cca5e32003-08-03 21:54:21 +00003670// Sign/Zero extenders
Dan Gohman11ba3b12008-07-30 18:09:17 +00003671// Use movsbl intead of movsbw; we don't care about the high 16 bits
3672// of the register here. This has a smaller encoding and avoids a
Sean Callanan108934c2009-12-18 00:01:26 +00003673// partial-register update. Actual movsbw included for the disassembler.
3674def MOVSX16rr8W : I<0xBE, MRMSrcReg, (outs GR16:$dst), (ins GR8:$src),
3675 "movs{bw|x}\t{$src, $dst|$dst, $src}", []>, TB, OpSize;
3676def MOVSX16rm8W : I<0xBE, MRMSrcMem, (outs GR16:$dst), (ins i8mem:$src),
3677 "movs{bw|x}\t{$src, $dst|$dst, $src}", []>, TB, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00003678def MOVSX16rr8 : I<0xBE, MRMSrcReg, (outs GR16:$dst), (ins GR8 :$src),
Chris Lattner172862a2009-10-19 19:51:42 +00003679 "", [(set GR16:$dst, (sext GR8:$src))]>, TB;
Evan Cheng64d80e32007-07-19 01:14:50 +00003680def MOVSX16rm8 : I<0xBE, MRMSrcMem, (outs GR16:$dst), (ins i8mem :$src),
Chris Lattner172862a2009-10-19 19:51:42 +00003681 "", [(set GR16:$dst, (sextloadi16i8 addr:$src))]>, TB;
Evan Cheng64d80e32007-07-19 01:14:50 +00003682def MOVSX32rr8 : I<0xBE, MRMSrcReg, (outs GR32:$dst), (ins GR8 :$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003683 "movs{bl|x}\t{$src, $dst|$dst, $src}",
Evan Cheng069287d2006-05-16 07:21:53 +00003684 [(set GR32:$dst, (sext GR8:$src))]>, TB;
Evan Cheng64d80e32007-07-19 01:14:50 +00003685def MOVSX32rm8 : I<0xBE, MRMSrcMem, (outs GR32:$dst), (ins i8mem :$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003686 "movs{bl|x}\t{$src, $dst|$dst, $src}",
Evan Cheng069287d2006-05-16 07:21:53 +00003687 [(set GR32:$dst, (sextloadi32i8 addr:$src))]>, TB;
Evan Cheng64d80e32007-07-19 01:14:50 +00003688def MOVSX32rr16: I<0xBF, MRMSrcReg, (outs GR32:$dst), (ins GR16:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003689 "movs{wl|x}\t{$src, $dst|$dst, $src}",
Evan Cheng069287d2006-05-16 07:21:53 +00003690 [(set GR32:$dst, (sext GR16:$src))]>, TB;
Evan Cheng64d80e32007-07-19 01:14:50 +00003691def MOVSX32rm16: I<0xBF, MRMSrcMem, (outs GR32:$dst), (ins i16mem:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003692 "movs{wl|x}\t{$src, $dst|$dst, $src}",
Evan Cheng069287d2006-05-16 07:21:53 +00003693 [(set GR32:$dst, (sextloadi32i16 addr:$src))]>, TB;
Alkis Evlogimenosa7be9822004-02-17 09:14:23 +00003694
Dan Gohman11ba3b12008-07-30 18:09:17 +00003695// Use movzbl intead of movzbw; we don't care about the high 16 bits
3696// of the register here. This has a smaller encoding and avoids a
Sean Callanan108934c2009-12-18 00:01:26 +00003697// partial-register update. Actual movzbw included for the disassembler.
3698def MOVZX16rr8W : I<0xB6, MRMSrcReg, (outs GR16:$dst), (ins GR8:$src),
3699 "movz{bw|x}\t{$src, $dst|$dst, $src}", []>, TB, OpSize;
3700def MOVZX16rm8W : I<0xB6, MRMSrcMem, (outs GR16:$dst), (ins i8mem:$src),
3701 "movz{bw|x}\t{$src, $dst|$dst, $src}", []>, TB, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00003702def MOVZX16rr8 : I<0xB6, MRMSrcReg, (outs GR16:$dst), (ins GR8 :$src),
Chris Lattner172862a2009-10-19 19:51:42 +00003703 "", [(set GR16:$dst, (zext GR8:$src))]>, TB;
Evan Cheng64d80e32007-07-19 01:14:50 +00003704def MOVZX16rm8 : I<0xB6, MRMSrcMem, (outs GR16:$dst), (ins i8mem :$src),
Chris Lattner172862a2009-10-19 19:51:42 +00003705 "", [(set GR16:$dst, (zextloadi16i8 addr:$src))]>, TB;
Evan Cheng64d80e32007-07-19 01:14:50 +00003706def MOVZX32rr8 : I<0xB6, MRMSrcReg, (outs GR32:$dst), (ins GR8 :$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003707 "movz{bl|x}\t{$src, $dst|$dst, $src}",
Evan Cheng069287d2006-05-16 07:21:53 +00003708 [(set GR32:$dst, (zext GR8:$src))]>, TB;
Evan Cheng64d80e32007-07-19 01:14:50 +00003709def MOVZX32rm8 : I<0xB6, MRMSrcMem, (outs GR32:$dst), (ins i8mem :$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003710 "movz{bl|x}\t{$src, $dst|$dst, $src}",
Evan Cheng069287d2006-05-16 07:21:53 +00003711 [(set GR32:$dst, (zextloadi32i8 addr:$src))]>, TB;
Evan Cheng64d80e32007-07-19 01:14:50 +00003712def MOVZX32rr16: I<0xB7, MRMSrcReg, (outs GR32:$dst), (ins GR16:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003713 "movz{wl|x}\t{$src, $dst|$dst, $src}",
Evan Cheng069287d2006-05-16 07:21:53 +00003714 [(set GR32:$dst, (zext GR16:$src))]>, TB;
Evan Cheng64d80e32007-07-19 01:14:50 +00003715def MOVZX32rm16: I<0xB7, MRMSrcMem, (outs GR32:$dst), (ins i16mem:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003716 "movz{wl|x}\t{$src, $dst|$dst, $src}",
Evan Cheng069287d2006-05-16 07:21:53 +00003717 [(set GR32:$dst, (zextloadi32i16 addr:$src))]>, TB;
Evan Cheng7a7e8372005-12-14 02:22:27 +00003718
Dan Gohmanf451cb82010-02-10 16:03:48 +00003719// These are the same as the regular MOVZX32rr8 and MOVZX32rm8
Dan Gohman21e3dfb2009-04-13 16:09:41 +00003720// except that they use GR32_NOREX for the output operand register class
3721// instead of GR32. This allows them to operate on h registers on x86-64.
3722def MOVZX32_NOREXrr8 : I<0xB6, MRMSrcReg,
3723 (outs GR32_NOREX:$dst), (ins GR8:$src),
3724 "movz{bl|x}\t{$src, $dst|$dst, $src} # NOREX",
3725 []>, TB;
Dan Gohman78e04d42009-04-30 03:11:48 +00003726let mayLoad = 1 in
Dan Gohman21e3dfb2009-04-13 16:09:41 +00003727def MOVZX32_NOREXrm8 : I<0xB6, MRMSrcMem,
3728 (outs GR32_NOREX:$dst), (ins i8mem:$src),
3729 "movz{bl|x}\t{$src, $dst|$dst, $src} # NOREX",
3730 []>, TB;
3731
Chris Lattnerba7e7562008-01-10 07:59:24 +00003732let neverHasSideEffects = 1 in {
3733 let Defs = [AX], Uses = [AL] in
3734 def CBW : I<0x98, RawFrm, (outs), (ins),
3735 "{cbtw|cbw}", []>, OpSize; // AX = signext(AL)
3736 let Defs = [EAX], Uses = [AX] in
3737 def CWDE : I<0x98, RawFrm, (outs), (ins),
3738 "{cwtl|cwde}", []>; // EAX = signext(AX)
Evan Chengf91c1012006-05-31 22:05:11 +00003739
Chris Lattnerba7e7562008-01-10 07:59:24 +00003740 let Defs = [AX,DX], Uses = [AX] in
3741 def CWD : I<0x99, RawFrm, (outs), (ins),
3742 "{cwtd|cwd}", []>, OpSize; // DX:AX = signext(AX)
3743 let Defs = [EAX,EDX], Uses = [EAX] in
3744 def CDQ : I<0x99, RawFrm, (outs), (ins),
3745 "{cltd|cdq}", []>; // EDX:EAX = signext(EAX)
3746}
Evan Cheng747a90d2006-02-21 02:24:38 +00003747
Evan Cheng747a90d2006-02-21 02:24:38 +00003748//===----------------------------------------------------------------------===//
3749// Alias Instructions
3750//===----------------------------------------------------------------------===//
3751
3752// Alias instructions that map movr0 to xor.
3753// FIXME: remove when we can teach regalloc that xor reg, reg is ok.
Chris Lattner35e0e842010-02-05 21:21:06 +00003754// FIXME: Set encoding to pseudo.
Daniel Dunbar7417b762009-08-11 22:17:52 +00003755let Defs = [EFLAGS], isReMaterializable = 1, isAsCheapAsAMove = 1,
3756 isCodeGenOnly = 1 in {
Chris Lattner35e0e842010-02-05 21:21:06 +00003757def MOV8r0 : I<0x30, MRMInitReg, (outs GR8 :$dst), (ins), "",
Evan Cheng069287d2006-05-16 07:21:53 +00003758 [(set GR8:$dst, 0)]>;
Dan Gohmanf1b4d262010-01-12 04:42:54 +00003759
3760// We want to rewrite MOV16r0 in terms of MOV32r0, because it's a smaller
3761// encoding and avoids a partial-register update sometimes, but doing so
3762// at isel time interferes with rematerialization in the current register
3763// allocator. For now, this is rewritten when the instruction is lowered
3764// to an MCInst.
3765def MOV16r0 : I<0x31, MRMInitReg, (outs GR16:$dst), (ins),
3766 "",
3767 [(set GR16:$dst, 0)]>, OpSize;
Chris Lattner6a381822009-12-23 01:30:26 +00003768
Chris Lattner35e0e842010-02-05 21:21:06 +00003769// FIXME: Set encoding to pseudo.
3770def MOV32r0 : I<0x31, MRMInitReg, (outs GR32:$dst), (ins), "",
Chris Lattnerac105c42009-12-23 01:46:40 +00003771 [(set GR32:$dst, 0)]>;
3772}
Chris Lattner6a381822009-12-23 01:30:26 +00003773
Evan Cheng510e4782006-01-09 23:10:28 +00003774//===----------------------------------------------------------------------===//
Lauro Ramos Venanciob3a04172007-04-20 21:38:10 +00003775// Thread Local Storage Instructions
3776//
3777
Rafael Espindola15f1b662009-04-24 12:59:40 +00003778// All calls clobber the non-callee saved registers. ESP is marked as
3779// a use to prevent stack-pointer assignments that appear immediately
3780// before calls from potentially appearing dead.
3781let Defs = [EAX, ECX, EDX, FP0, FP1, FP2, FP3, FP4, FP5, FP6, ST0,
3782 MM0, MM1, MM2, MM3, MM4, MM5, MM6, MM7,
3783 XMM0, XMM1, XMM2, XMM3, XMM4, XMM5, XMM6, XMM7,
3784 XMM8, XMM9, XMM10, XMM11, XMM12, XMM13, XMM14, XMM15, EFLAGS],
Chris Lattner5c0b16d2009-06-20 20:38:48 +00003785 Uses = [ESP] in
3786def TLS_addr32 : I<0, Pseudo, (outs), (ins lea32mem:$sym),
3787 "leal\t$sym, %eax; "
Dan Gohman4d47b9b2009-04-27 15:13:28 +00003788 "call\t___tls_get_addr@PLT",
Chris Lattner5c0b16d2009-06-20 20:38:48 +00003789 [(X86tlsaddr tls32addr:$sym)]>,
Rafael Espindola2ee3db32009-04-17 14:35:58 +00003790 Requires<[In32BitMode]>;
Lauro Ramos Venanciob3a04172007-04-20 21:38:10 +00003791
Daniel Dunbar0c420fc2009-08-11 22:24:40 +00003792let AddedComplexity = 5, isCodeGenOnly = 1 in
Nate Begeman51a04372009-01-26 01:24:32 +00003793def GS_MOV32rm : I<0x8B, MRMSrcMem, (outs GR32:$dst), (ins i32mem:$src),
3794 "movl\t%gs:$src, $dst",
3795 [(set GR32:$dst, (gsload addr:$src))]>, SegGS;
3796
Daniel Dunbar0c420fc2009-08-11 22:24:40 +00003797let AddedComplexity = 5, isCodeGenOnly = 1 in
Chris Lattner1777d0c2009-05-05 18:52:19 +00003798def FS_MOV32rm : I<0x8B, MRMSrcMem, (outs GR32:$dst), (ins i32mem:$src),
3799 "movl\t%fs:$src, $dst",
3800 [(set GR32:$dst, (fsload addr:$src))]>, SegFS;
3801
Lauro Ramos Venanciob3a04172007-04-20 21:38:10 +00003802//===----------------------------------------------------------------------===//
Anton Korobeynikov2365f512007-07-14 14:06:15 +00003803// EH Pseudo Instructions
3804//
3805let isTerminator = 1, isReturn = 1, isBarrier = 1,
Daniel Dunbar1ca3a0b2009-08-27 07:58:05 +00003806 hasCtrlDep = 1, isCodeGenOnly = 1 in {
Evan Cheng64d80e32007-07-19 01:14:50 +00003807def EH_RETURN : I<0xC3, RawFrm, (outs), (ins GR32:$addr),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003808 "ret\t#eh_return, addr: $addr",
Anton Korobeynikov2365f512007-07-14 14:06:15 +00003809 [(X86ehret GR32:$addr)]>;
3810
3811}
3812
3813//===----------------------------------------------------------------------===//
Andrew Lenharthab0b9492008-02-21 06:45:13 +00003814// Atomic support
3815//
Andrew Lenharthea7da502008-03-01 13:37:02 +00003816
Evan Chengbb6939d2008-04-19 01:20:30 +00003817// Atomic swap. These are just normal xchg instructions. But since a memory
3818// operand is referenced, the atomicity is ensured.
Dan Gohman165660e2008-08-06 15:52:50 +00003819let Constraints = "$val = $dst" in {
Sean Callanan108934c2009-12-18 00:01:26 +00003820def XCHG32rm : I<0x87, MRMSrcMem, (outs GR32:$dst),
3821 (ins GR32:$val, i32mem:$ptr),
Evan Chengbb6939d2008-04-19 01:20:30 +00003822 "xchg{l}\t{$val, $ptr|$ptr, $val}",
3823 [(set GR32:$dst, (atomic_swap_32 addr:$ptr, GR32:$val))]>;
Sean Callanan108934c2009-12-18 00:01:26 +00003824def XCHG16rm : I<0x87, MRMSrcMem, (outs GR16:$dst),
3825 (ins GR16:$val, i16mem:$ptr),
Evan Chengbb6939d2008-04-19 01:20:30 +00003826 "xchg{w}\t{$val, $ptr|$ptr, $val}",
3827 [(set GR16:$dst, (atomic_swap_16 addr:$ptr, GR16:$val))]>,
3828 OpSize;
Sean Callanan108934c2009-12-18 00:01:26 +00003829def XCHG8rm : I<0x86, MRMSrcMem, (outs GR8:$dst), (ins GR8:$val, i8mem:$ptr),
Evan Chengbb6939d2008-04-19 01:20:30 +00003830 "xchg{b}\t{$val, $ptr|$ptr, $val}",
3831 [(set GR8:$dst, (atomic_swap_8 addr:$ptr, GR8:$val))]>;
Sean Callanan108934c2009-12-18 00:01:26 +00003832
3833def XCHG32rr : I<0x87, MRMSrcReg, (outs GR32:$dst), (ins GR32:$val, GR32:$src),
3834 "xchg{l}\t{$val, $src|$src, $val}", []>;
3835def XCHG16rr : I<0x87, MRMSrcReg, (outs GR16:$dst), (ins GR16:$val, GR16:$src),
3836 "xchg{w}\t{$val, $src|$src, $val}", []>, OpSize;
3837def XCHG8rr : I<0x86, MRMSrcReg, (outs GR8:$dst), (ins GR8:$val, GR8:$src),
3838 "xchg{b}\t{$val, $src|$src, $val}", []>;
Evan Chengbb6939d2008-04-19 01:20:30 +00003839}
3840
Sean Callanan108934c2009-12-18 00:01:26 +00003841def XCHG16ar : I<0x90, AddRegFrm, (outs), (ins GR16:$src),
3842 "xchg{w}\t{$src, %ax|%ax, $src}", []>, OpSize;
3843def XCHG32ar : I<0x90, AddRegFrm, (outs), (ins GR32:$src),
3844 "xchg{l}\t{$src, %eax|%eax, $src}", []>;
3845
Evan Cheng7e032802008-04-18 20:55:36 +00003846// Atomic compare and swap.
Andrew Lenharth26ed8692008-03-01 21:52:34 +00003847let Defs = [EAX, EFLAGS], Uses = [EAX] in {
Evan Cheng7e032802008-04-18 20:55:36 +00003848def LCMPXCHG32 : I<0xB1, MRMDestMem, (outs), (ins i32mem:$ptr, GR32:$swap),
Dan Gohman4d47b9b2009-04-27 15:13:28 +00003849 "lock\n\t"
3850 "cmpxchg{l}\t{$swap, $ptr|$ptr, $swap}",
Evan Cheng32967d22008-03-04 03:20:06 +00003851 [(X86cas addr:$ptr, GR32:$swap, 4)]>, TB, LOCK;
Andrew Lenharthea7da502008-03-01 13:37:02 +00003852}
Dale Johannesen48c1bc22008-10-02 18:53:47 +00003853let Defs = [EAX, EDX, EFLAGS], Uses = [EAX, EBX, ECX, EDX] in {
Evan Chengb093bd02010-01-08 01:29:19 +00003854def LCMPXCHG8B : I<0xC7, MRM1m, (outs), (ins i64mem:$ptr),
Dan Gohman4d47b9b2009-04-27 15:13:28 +00003855 "lock\n\t"
3856 "cmpxchg8b\t$ptr",
Andrew Lenharthd19189e2008-03-05 01:15:49 +00003857 [(X86cas8 addr:$ptr)]>, TB, LOCK;
3858}
Andrew Lenharth26ed8692008-03-01 21:52:34 +00003859
3860let Defs = [AX, EFLAGS], Uses = [AX] in {
Evan Cheng7e032802008-04-18 20:55:36 +00003861def LCMPXCHG16 : I<0xB1, MRMDestMem, (outs), (ins i16mem:$ptr, GR16:$swap),
Dan Gohman4d47b9b2009-04-27 15:13:28 +00003862 "lock\n\t"
3863 "cmpxchg{w}\t{$swap, $ptr|$ptr, $swap}",
Evan Cheng32967d22008-03-04 03:20:06 +00003864 [(X86cas addr:$ptr, GR16:$swap, 2)]>, TB, OpSize, LOCK;
Andrew Lenharthea7da502008-03-01 13:37:02 +00003865}
Andrew Lenharth26ed8692008-03-01 21:52:34 +00003866let Defs = [AL, EFLAGS], Uses = [AL] in {
Evan Cheng7e032802008-04-18 20:55:36 +00003867def LCMPXCHG8 : I<0xB0, MRMDestMem, (outs), (ins i8mem:$ptr, GR8:$swap),
Dan Gohman4d47b9b2009-04-27 15:13:28 +00003868 "lock\n\t"
3869 "cmpxchg{b}\t{$swap, $ptr|$ptr, $swap}",
Evan Cheng32967d22008-03-04 03:20:06 +00003870 [(X86cas addr:$ptr, GR8:$swap, 1)]>, TB, LOCK;
Andrew Lenharthea7da502008-03-01 13:37:02 +00003871}
3872
Evan Cheng7e032802008-04-18 20:55:36 +00003873// Atomic exchange and add
3874let Constraints = "$val = $dst", Defs = [EFLAGS] in {
Sean Callanan108934c2009-12-18 00:01:26 +00003875def LXADD32 : I<0xC1, MRMSrcMem, (outs GR32:$dst), (ins GR32:$val, i32mem:$ptr),
Dan Gohman4d47b9b2009-04-27 15:13:28 +00003876 "lock\n\t"
3877 "xadd{l}\t{$val, $ptr|$ptr, $val}",
Mon P Wang28873102008-06-25 08:15:39 +00003878 [(set GR32:$dst, (atomic_load_add_32 addr:$ptr, GR32:$val))]>,
Evan Cheng7e032802008-04-18 20:55:36 +00003879 TB, LOCK;
Sean Callanan108934c2009-12-18 00:01:26 +00003880def LXADD16 : I<0xC1, MRMSrcMem, (outs GR16:$dst), (ins GR16:$val, i16mem:$ptr),
Dan Gohman4d47b9b2009-04-27 15:13:28 +00003881 "lock\n\t"
3882 "xadd{w}\t{$val, $ptr|$ptr, $val}",
Mon P Wang28873102008-06-25 08:15:39 +00003883 [(set GR16:$dst, (atomic_load_add_16 addr:$ptr, GR16:$val))]>,
Evan Cheng7e032802008-04-18 20:55:36 +00003884 TB, OpSize, LOCK;
Sean Callanan108934c2009-12-18 00:01:26 +00003885def LXADD8 : I<0xC0, MRMSrcMem, (outs GR8:$dst), (ins GR8:$val, i8mem:$ptr),
Dan Gohman4d47b9b2009-04-27 15:13:28 +00003886 "lock\n\t"
3887 "xadd{b}\t{$val, $ptr|$ptr, $val}",
Mon P Wang28873102008-06-25 08:15:39 +00003888 [(set GR8:$dst, (atomic_load_add_8 addr:$ptr, GR8:$val))]>,
Evan Cheng7e032802008-04-18 20:55:36 +00003889 TB, LOCK;
Andrew Lenharthea7da502008-03-01 13:37:02 +00003890}
3891
Sean Callanan108934c2009-12-18 00:01:26 +00003892def XADD8rr : I<0xC0, MRMDestReg, (outs GR8:$dst), (ins GR8:$src),
3893 "xadd{b}\t{$src, $dst|$dst, $src}", []>, TB;
3894def XADD16rr : I<0xC1, MRMDestReg, (outs GR16:$dst), (ins GR16:$src),
3895 "xadd{w}\t{$src, $dst|$dst, $src}", []>, TB, OpSize;
3896def XADD32rr : I<0xC1, MRMDestReg, (outs GR32:$dst), (ins GR32:$src),
3897 "xadd{l}\t{$src, $dst|$dst, $src}", []>, TB;
3898
3899def XADD8rm : I<0xC0, MRMDestMem, (outs), (ins i8mem:$dst, GR8:$src),
3900 "xadd{b}\t{$src, $dst|$dst, $src}", []>, TB;
3901def XADD16rm : I<0xC1, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src),
3902 "xadd{w}\t{$src, $dst|$dst, $src}", []>, TB, OpSize;
3903def XADD32rm : I<0xC1, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src),
3904 "xadd{l}\t{$src, $dst|$dst, $src}", []>, TB;
3905
3906def CMPXCHG8rr : I<0xB0, MRMDestReg, (outs GR8:$dst), (ins GR8:$src),
3907 "cmpxchg{b}\t{$src, $dst|$dst, $src}", []>, TB;
3908def CMPXCHG16rr : I<0xB1, MRMDestReg, (outs GR16:$dst), (ins GR16:$src),
3909 "cmpxchg{w}\t{$src, $dst|$dst, $src}", []>, TB, OpSize;
3910def CMPXCHG32rr : I<0xB1, MRMDestReg, (outs GR32:$dst), (ins GR32:$src),
3911 "cmpxchg{l}\t{$src, $dst|$dst, $src}", []>, TB;
3912
3913def CMPXCHG8rm : I<0xB0, MRMDestMem, (outs), (ins i8mem:$dst, GR8:$src),
3914 "cmpxchg{b}\t{$src, $dst|$dst, $src}", []>, TB;
3915def CMPXCHG16rm : I<0xB1, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src),
3916 "cmpxchg{w}\t{$src, $dst|$dst, $src}", []>, TB, OpSize;
3917def CMPXCHG32rm : I<0xB1, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src),
3918 "cmpxchg{l}\t{$src, $dst|$dst, $src}", []>, TB;
3919
Evan Chengb093bd02010-01-08 01:29:19 +00003920let Defs = [EAX, EDX, EFLAGS], Uses = [EAX, EBX, ECX, EDX] in
Sean Callanan108934c2009-12-18 00:01:26 +00003921def CMPXCHG8B : I<0xC7, MRM1m, (outs), (ins i64mem:$dst),
3922 "cmpxchg8b\t$dst", []>, TB;
3923
Evan Cheng37b73872009-07-30 08:33:02 +00003924// Optimized codegen when the non-memory output is not used.
3925// FIXME: Use normal add / sub instructions and add lock prefix dynamically.
Dan Gohmanbab42bd2009-10-20 18:14:49 +00003926let Defs = [EFLAGS] in {
Evan Cheng37b73872009-07-30 08:33:02 +00003927def LOCK_ADD8mr : I<0x00, MRMDestMem, (outs), (ins i8mem:$dst, GR8:$src2),
3928 "lock\n\t"
3929 "add{b}\t{$src2, $dst|$dst, $src2}", []>, LOCK;
3930def LOCK_ADD16mr : I<0x01, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
3931 "lock\n\t"
3932 "add{w}\t{$src2, $dst|$dst, $src2}", []>, OpSize, LOCK;
3933def LOCK_ADD32mr : I<0x01, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
3934 "lock\n\t"
3935 "add{l}\t{$src2, $dst|$dst, $src2}", []>, LOCK;
3936def LOCK_ADD8mi : Ii8<0x80, MRM0m, (outs), (ins i8mem :$dst, i8imm :$src2),
3937 "lock\n\t"
3938 "add{b}\t{$src2, $dst|$dst, $src2}", []>, LOCK;
3939def LOCK_ADD16mi : Ii16<0x81, MRM0m, (outs), (ins i16mem:$dst, i16imm:$src2),
3940 "lock\n\t"
3941 "add{w}\t{$src2, $dst|$dst, $src2}", []>, LOCK;
3942def LOCK_ADD32mi : Ii32<0x81, MRM0m, (outs), (ins i32mem:$dst, i32imm:$src2),
3943 "lock\n\t"
3944 "add{l}\t{$src2, $dst|$dst, $src2}", []>, LOCK;
3945def LOCK_ADD16mi8 : Ii8<0x83, MRM0m, (outs), (ins i16mem:$dst, i16i8imm :$src2),
3946 "lock\n\t"
3947 "add{w}\t{$src2, $dst|$dst, $src2}", []>, OpSize, LOCK;
3948def LOCK_ADD32mi8 : Ii8<0x83, MRM0m, (outs), (ins i32mem:$dst, i32i8imm :$src2),
3949 "lock\n\t"
3950 "add{l}\t{$src2, $dst|$dst, $src2}", []>, LOCK;
3951
3952def LOCK_INC8m : I<0xFE, MRM0m, (outs), (ins i8mem :$dst),
3953 "lock\n\t"
3954 "inc{b}\t$dst", []>, LOCK;
3955def LOCK_INC16m : I<0xFF, MRM0m, (outs), (ins i16mem:$dst),
3956 "lock\n\t"
3957 "inc{w}\t$dst", []>, OpSize, LOCK;
3958def LOCK_INC32m : I<0xFF, MRM0m, (outs), (ins i32mem:$dst),
3959 "lock\n\t"
3960 "inc{l}\t$dst", []>, LOCK;
3961
3962def LOCK_SUB8mr : I<0x28, MRMDestMem, (outs), (ins i8mem :$dst, GR8 :$src2),
3963 "lock\n\t"
3964 "sub{b}\t{$src2, $dst|$dst, $src2}", []>, LOCK;
3965def LOCK_SUB16mr : I<0x29, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
3966 "lock\n\t"
3967 "sub{w}\t{$src2, $dst|$dst, $src2}", []>, OpSize, LOCK;
3968def LOCK_SUB32mr : I<0x29, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
3969 "lock\n\t"
3970 "sub{l}\t{$src2, $dst|$dst, $src2}", []>, LOCK;
3971def LOCK_SUB8mi : Ii8<0x80, MRM5m, (outs), (ins i8mem :$dst, i8imm:$src2),
3972 "lock\n\t"
3973 "sub{b}\t{$src2, $dst|$dst, $src2}", []>, LOCK;
3974def LOCK_SUB16mi : Ii16<0x81, MRM5m, (outs), (ins i16mem:$dst, i16imm:$src2),
3975 "lock\n\t"
3976 "sub{w}\t{$src2, $dst|$dst, $src2}", []>, OpSize, LOCK;
3977def LOCK_SUB32mi : Ii32<0x81, MRM5m, (outs), (ins i32mem:$dst, i32imm:$src2),
3978 "lock\n\t"
3979 "sub{l}\t{$src2, $dst|$dst, $src2}", []>, LOCK;
Sean Callanan108934c2009-12-18 00:01:26 +00003980def LOCK_SUB16mi8 : Ii8<0x83, MRM5m, (outs), (ins i16mem:$dst, i16i8imm :$src2),
Evan Cheng37b73872009-07-30 08:33:02 +00003981 "lock\n\t"
3982 "sub{w}\t{$src2, $dst|$dst, $src2}", []>, OpSize, LOCK;
3983def LOCK_SUB32mi8 : Ii8<0x83, MRM5m, (outs), (ins i32mem:$dst, i32i8imm :$src2),
3984 "lock\n\t"
3985 "sub{l}\t{$src2, $dst|$dst, $src2}", []>, LOCK;
3986
3987def LOCK_DEC8m : I<0xFE, MRM1m, (outs), (ins i8mem :$dst),
3988 "lock\n\t"
3989 "dec{b}\t$dst", []>, LOCK;
3990def LOCK_DEC16m : I<0xFF, MRM1m, (outs), (ins i16mem:$dst),
3991 "lock\n\t"
3992 "dec{w}\t$dst", []>, OpSize, LOCK;
3993def LOCK_DEC32m : I<0xFF, MRM1m, (outs), (ins i32mem:$dst),
3994 "lock\n\t"
3995 "dec{l}\t$dst", []>, LOCK;
Dan Gohmanbab42bd2009-10-20 18:14:49 +00003996}
Evan Cheng37b73872009-07-30 08:33:02 +00003997
Mon P Wang28873102008-06-25 08:15:39 +00003998// Atomic exchange, and, or, xor
Mon P Wang63307c32008-05-05 19:05:59 +00003999let Constraints = "$val = $dst", Defs = [EFLAGS],
Dan Gohman533297b2009-10-29 18:10:34 +00004000 usesCustomInserter = 1 in {
Dan Gohman9499b712008-05-12 20:22:45 +00004001def ATOMAND32 : I<0, Pseudo, (outs GR32:$dst),(ins i32mem:$ptr, GR32:$val),
Nick Lewycky6ecf5ce2008-12-07 03:49:52 +00004002 "#ATOMAND32 PSEUDO!",
Dale Johannesene00a8a22008-08-28 02:44:49 +00004003 [(set GR32:$dst, (atomic_load_and_32 addr:$ptr, GR32:$val))]>;
Dan Gohman9499b712008-05-12 20:22:45 +00004004def ATOMOR32 : I<0, Pseudo, (outs GR32:$dst),(ins i32mem:$ptr, GR32:$val),
Nick Lewycky6ecf5ce2008-12-07 03:49:52 +00004005 "#ATOMOR32 PSEUDO!",
Dale Johannesene00a8a22008-08-28 02:44:49 +00004006 [(set GR32:$dst, (atomic_load_or_32 addr:$ptr, GR32:$val))]>;
Dan Gohman9499b712008-05-12 20:22:45 +00004007def ATOMXOR32 : I<0, Pseudo,(outs GR32:$dst),(ins i32mem:$ptr, GR32:$val),
Nick Lewycky6ecf5ce2008-12-07 03:49:52 +00004008 "#ATOMXOR32 PSEUDO!",
Dale Johannesene00a8a22008-08-28 02:44:49 +00004009 [(set GR32:$dst, (atomic_load_xor_32 addr:$ptr, GR32:$val))]>;
Andrew Lenharth507a58a2008-06-14 05:48:15 +00004010def ATOMNAND32 : I<0, Pseudo,(outs GR32:$dst),(ins i32mem:$ptr, GR32:$val),
Nick Lewycky6ecf5ce2008-12-07 03:49:52 +00004011 "#ATOMNAND32 PSEUDO!",
Dale Johannesene00a8a22008-08-28 02:44:49 +00004012 [(set GR32:$dst, (atomic_load_nand_32 addr:$ptr, GR32:$val))]>;
Dan Gohman9499b712008-05-12 20:22:45 +00004013def ATOMMIN32: I<0, Pseudo, (outs GR32:$dst), (ins i32mem:$ptr, GR32:$val),
Nick Lewycky6ecf5ce2008-12-07 03:49:52 +00004014 "#ATOMMIN32 PSEUDO!",
Dale Johannesene00a8a22008-08-28 02:44:49 +00004015 [(set GR32:$dst, (atomic_load_min_32 addr:$ptr, GR32:$val))]>;
Dan Gohman9499b712008-05-12 20:22:45 +00004016def ATOMMAX32: I<0, Pseudo, (outs GR32:$dst),(ins i32mem:$ptr, GR32:$val),
Nick Lewycky6ecf5ce2008-12-07 03:49:52 +00004017 "#ATOMMAX32 PSEUDO!",
Dale Johannesene00a8a22008-08-28 02:44:49 +00004018 [(set GR32:$dst, (atomic_load_max_32 addr:$ptr, GR32:$val))]>;
Dan Gohman9499b712008-05-12 20:22:45 +00004019def ATOMUMIN32: I<0, Pseudo, (outs GR32:$dst),(ins i32mem:$ptr, GR32:$val),
Nick Lewycky6ecf5ce2008-12-07 03:49:52 +00004020 "#ATOMUMIN32 PSEUDO!",
Dale Johannesene00a8a22008-08-28 02:44:49 +00004021 [(set GR32:$dst, (atomic_load_umin_32 addr:$ptr, GR32:$val))]>;
Dan Gohman9499b712008-05-12 20:22:45 +00004022def ATOMUMAX32: I<0, Pseudo, (outs GR32:$dst),(ins i32mem:$ptr, GR32:$val),
Nick Lewycky6ecf5ce2008-12-07 03:49:52 +00004023 "#ATOMUMAX32 PSEUDO!",
Dale Johannesene00a8a22008-08-28 02:44:49 +00004024 [(set GR32:$dst, (atomic_load_umax_32 addr:$ptr, GR32:$val))]>;
Dale Johannesen140be2d2008-08-19 18:47:28 +00004025
4026def ATOMAND16 : I<0, Pseudo, (outs GR16:$dst),(ins i16mem:$ptr, GR16:$val),
Nick Lewycky6ecf5ce2008-12-07 03:49:52 +00004027 "#ATOMAND16 PSEUDO!",
Dale Johannesene00a8a22008-08-28 02:44:49 +00004028 [(set GR16:$dst, (atomic_load_and_16 addr:$ptr, GR16:$val))]>;
Dale Johannesen140be2d2008-08-19 18:47:28 +00004029def ATOMOR16 : I<0, Pseudo, (outs GR16:$dst),(ins i16mem:$ptr, GR16:$val),
Nick Lewycky6ecf5ce2008-12-07 03:49:52 +00004030 "#ATOMOR16 PSEUDO!",
Dale Johannesene00a8a22008-08-28 02:44:49 +00004031 [(set GR16:$dst, (atomic_load_or_16 addr:$ptr, GR16:$val))]>;
Dale Johannesen140be2d2008-08-19 18:47:28 +00004032def ATOMXOR16 : I<0, Pseudo,(outs GR16:$dst),(ins i16mem:$ptr, GR16:$val),
Nick Lewycky6ecf5ce2008-12-07 03:49:52 +00004033 "#ATOMXOR16 PSEUDO!",
Dale Johannesene00a8a22008-08-28 02:44:49 +00004034 [(set GR16:$dst, (atomic_load_xor_16 addr:$ptr, GR16:$val))]>;
Dale Johannesen140be2d2008-08-19 18:47:28 +00004035def ATOMNAND16 : I<0, Pseudo,(outs GR16:$dst),(ins i16mem:$ptr, GR16:$val),
Nick Lewycky6ecf5ce2008-12-07 03:49:52 +00004036 "#ATOMNAND16 PSEUDO!",
Dale Johannesene00a8a22008-08-28 02:44:49 +00004037 [(set GR16:$dst, (atomic_load_nand_16 addr:$ptr, GR16:$val))]>;
Dale Johannesen140be2d2008-08-19 18:47:28 +00004038def ATOMMIN16: I<0, Pseudo, (outs GR16:$dst), (ins i16mem:$ptr, GR16:$val),
Nick Lewycky6ecf5ce2008-12-07 03:49:52 +00004039 "#ATOMMIN16 PSEUDO!",
Dale Johannesene00a8a22008-08-28 02:44:49 +00004040 [(set GR16:$dst, (atomic_load_min_16 addr:$ptr, GR16:$val))]>;
Dale Johannesen140be2d2008-08-19 18:47:28 +00004041def ATOMMAX16: I<0, Pseudo, (outs GR16:$dst),(ins i16mem:$ptr, GR16:$val),
Nick Lewycky6ecf5ce2008-12-07 03:49:52 +00004042 "#ATOMMAX16 PSEUDO!",
Dale Johannesene00a8a22008-08-28 02:44:49 +00004043 [(set GR16:$dst, (atomic_load_max_16 addr:$ptr, GR16:$val))]>;
Dale Johannesen140be2d2008-08-19 18:47:28 +00004044def ATOMUMIN16: I<0, Pseudo, (outs GR16:$dst),(ins i16mem:$ptr, GR16:$val),
Nick Lewycky6ecf5ce2008-12-07 03:49:52 +00004045 "#ATOMUMIN16 PSEUDO!",
Dale Johannesene00a8a22008-08-28 02:44:49 +00004046 [(set GR16:$dst, (atomic_load_umin_16 addr:$ptr, GR16:$val))]>;
Dale Johannesen140be2d2008-08-19 18:47:28 +00004047def ATOMUMAX16: I<0, Pseudo, (outs GR16:$dst),(ins i16mem:$ptr, GR16:$val),
Nick Lewycky6ecf5ce2008-12-07 03:49:52 +00004048 "#ATOMUMAX16 PSEUDO!",
Dale Johannesene00a8a22008-08-28 02:44:49 +00004049 [(set GR16:$dst, (atomic_load_umax_16 addr:$ptr, GR16:$val))]>;
Dale Johannesen140be2d2008-08-19 18:47:28 +00004050
4051def ATOMAND8 : I<0, Pseudo, (outs GR8:$dst),(ins i8mem:$ptr, GR8:$val),
Nick Lewycky6ecf5ce2008-12-07 03:49:52 +00004052 "#ATOMAND8 PSEUDO!",
Dale Johannesene00a8a22008-08-28 02:44:49 +00004053 [(set GR8:$dst, (atomic_load_and_8 addr:$ptr, GR8:$val))]>;
Dale Johannesen140be2d2008-08-19 18:47:28 +00004054def ATOMOR8 : I<0, Pseudo, (outs GR8:$dst),(ins i8mem:$ptr, GR8:$val),
Nick Lewycky6ecf5ce2008-12-07 03:49:52 +00004055 "#ATOMOR8 PSEUDO!",
Dale Johannesene00a8a22008-08-28 02:44:49 +00004056 [(set GR8:$dst, (atomic_load_or_8 addr:$ptr, GR8:$val))]>;
Dale Johannesen140be2d2008-08-19 18:47:28 +00004057def ATOMXOR8 : I<0, Pseudo,(outs GR8:$dst),(ins i8mem:$ptr, GR8:$val),
Nick Lewycky6ecf5ce2008-12-07 03:49:52 +00004058 "#ATOMXOR8 PSEUDO!",
Dale Johannesene00a8a22008-08-28 02:44:49 +00004059 [(set GR8:$dst, (atomic_load_xor_8 addr:$ptr, GR8:$val))]>;
Dale Johannesen140be2d2008-08-19 18:47:28 +00004060def ATOMNAND8 : I<0, Pseudo,(outs GR8:$dst),(ins i8mem:$ptr, GR8:$val),
Nick Lewycky6ecf5ce2008-12-07 03:49:52 +00004061 "#ATOMNAND8 PSEUDO!",
Dale Johannesene00a8a22008-08-28 02:44:49 +00004062 [(set GR8:$dst, (atomic_load_nand_8 addr:$ptr, GR8:$val))]>;
Mon P Wang63307c32008-05-05 19:05:59 +00004063}
4064
Dale Johannesen48c1bc22008-10-02 18:53:47 +00004065let Constraints = "$val1 = $dst1, $val2 = $dst2",
4066 Defs = [EFLAGS, EAX, EBX, ECX, EDX],
4067 Uses = [EAX, EBX, ECX, EDX],
Dale Johannesen1b54c7f2008-10-03 19:41:08 +00004068 mayLoad = 1, mayStore = 1,
Dan Gohman533297b2009-10-29 18:10:34 +00004069 usesCustomInserter = 1 in {
Dale Johannesen48c1bc22008-10-02 18:53:47 +00004070def ATOMAND6432 : I<0, Pseudo, (outs GR32:$dst1, GR32:$dst2),
4071 (ins i64mem:$ptr, GR32:$val1, GR32:$val2),
Nick Lewycky6ecf5ce2008-12-07 03:49:52 +00004072 "#ATOMAND6432 PSEUDO!", []>;
Dale Johannesen48c1bc22008-10-02 18:53:47 +00004073def ATOMOR6432 : I<0, Pseudo, (outs GR32:$dst1, GR32:$dst2),
4074 (ins i64mem:$ptr, GR32:$val1, GR32:$val2),
Nick Lewycky6ecf5ce2008-12-07 03:49:52 +00004075 "#ATOMOR6432 PSEUDO!", []>;
Dale Johannesen48c1bc22008-10-02 18:53:47 +00004076def ATOMXOR6432 : I<0, Pseudo, (outs GR32:$dst1, GR32:$dst2),
4077 (ins i64mem:$ptr, GR32:$val1, GR32:$val2),
Nick Lewycky6ecf5ce2008-12-07 03:49:52 +00004078 "#ATOMXOR6432 PSEUDO!", []>;
Dale Johannesen48c1bc22008-10-02 18:53:47 +00004079def ATOMNAND6432 : I<0, Pseudo, (outs GR32:$dst1, GR32:$dst2),
4080 (ins i64mem:$ptr, GR32:$val1, GR32:$val2),
Nick Lewycky6ecf5ce2008-12-07 03:49:52 +00004081 "#ATOMNAND6432 PSEUDO!", []>;
Dale Johannesen48c1bc22008-10-02 18:53:47 +00004082def ATOMADD6432 : I<0, Pseudo, (outs GR32:$dst1, GR32:$dst2),
4083 (ins i64mem:$ptr, GR32:$val1, GR32:$val2),
Nick Lewycky6ecf5ce2008-12-07 03:49:52 +00004084 "#ATOMADD6432 PSEUDO!", []>;
Dale Johannesen48c1bc22008-10-02 18:53:47 +00004085def ATOMSUB6432 : I<0, Pseudo, (outs GR32:$dst1, GR32:$dst2),
4086 (ins i64mem:$ptr, GR32:$val1, GR32:$val2),
Nick Lewycky6ecf5ce2008-12-07 03:49:52 +00004087 "#ATOMSUB6432 PSEUDO!", []>;
Dale Johannesen880ae362008-10-03 22:25:52 +00004088def ATOMSWAP6432 : I<0, Pseudo, (outs GR32:$dst1, GR32:$dst2),
4089 (ins i64mem:$ptr, GR32:$val1, GR32:$val2),
Nick Lewycky6ecf5ce2008-12-07 03:49:52 +00004090 "#ATOMSWAP6432 PSEUDO!", []>;
Dale Johannesen48c1bc22008-10-02 18:53:47 +00004091}
4092
Sean Callanan358f1ef2009-09-16 21:55:34 +00004093// Segmentation support instructions.
4094
4095def LAR16rm : I<0x02, MRMSrcMem, (outs GR16:$dst), (ins i16mem:$src),
4096 "lar{w}\t{$src, $dst|$dst, $src}", []>, TB, OpSize;
4097def LAR16rr : I<0x02, MRMSrcReg, (outs GR16:$dst), (ins GR16:$src),
4098 "lar{w}\t{$src, $dst|$dst, $src}", []>, TB, OpSize;
4099
4100// i16mem operand in LAR32rm and GR32 operand in LAR32rr is not a typo.
4101def LAR32rm : I<0x02, MRMSrcMem, (outs GR32:$dst), (ins i16mem:$src),
4102 "lar{l}\t{$src, $dst|$dst, $src}", []>, TB;
4103def LAR32rr : I<0x02, MRMSrcReg, (outs GR32:$dst), (ins GR32:$src),
4104 "lar{l}\t{$src, $dst|$dst, $src}", []>, TB;
Sean Callanan108934c2009-12-18 00:01:26 +00004105
4106def LSL16rm : I<0x03, MRMSrcMem, (outs GR16:$dst), (ins i16mem:$src),
4107 "lsl{w}\t{$src, $dst|$dst, $src}", []>, TB, OpSize;
4108def LSL16rr : I<0x03, MRMSrcReg, (outs GR16:$dst), (ins GR16:$src),
4109 "lsl{w}\t{$src, $dst|$dst, $src}", []>, TB, OpSize;
4110def LSL32rm : I<0x03, MRMSrcMem, (outs GR32:$dst), (ins i32mem:$src),
4111 "lsl{l}\t{$src, $dst|$dst, $src}", []>, TB;
4112def LSL32rr : I<0x03, MRMSrcReg, (outs GR32:$dst), (ins GR32:$src),
4113 "lsl{l}\t{$src, $dst|$dst, $src}", []>, TB;
4114
Sean Callanan95a5a7d2010-02-13 01:48:34 +00004115def INVLPG : I<0x01, MRM7m, (outs), (ins i8mem:$addr), "invlpg\t$addr", []>, TB;
Sean Callanan108934c2009-12-18 00:01:26 +00004116
4117def STRr : I<0x00, MRM1r, (outs GR16:$dst), (ins),
4118 "str{w}\t{$dst}", []>, TB;
4119def STRm : I<0x00, MRM1m, (outs i16mem:$dst), (ins),
4120 "str{w}\t{$dst}", []>, TB;
4121def LTRr : I<0x00, MRM3r, (outs), (ins GR16:$src),
4122 "ltr{w}\t{$src}", []>, TB;
4123def LTRm : I<0x00, MRM3m, (outs), (ins i16mem:$src),
4124 "ltr{w}\t{$src}", []>, TB;
4125
4126def PUSHFS16 : I<0xa0, RawFrm, (outs), (ins),
4127 "push{w}\t%fs", []>, OpSize, TB;
4128def PUSHFS32 : I<0xa0, RawFrm, (outs), (ins),
4129 "push{l}\t%fs", []>, TB;
4130def PUSHGS16 : I<0xa8, RawFrm, (outs), (ins),
4131 "push{w}\t%gs", []>, OpSize, TB;
4132def PUSHGS32 : I<0xa8, RawFrm, (outs), (ins),
4133 "push{l}\t%gs", []>, TB;
4134
4135def POPFS16 : I<0xa1, RawFrm, (outs), (ins),
4136 "pop{w}\t%fs", []>, OpSize, TB;
4137def POPFS32 : I<0xa1, RawFrm, (outs), (ins),
4138 "pop{l}\t%fs", []>, TB;
4139def POPGS16 : I<0xa9, RawFrm, (outs), (ins),
4140 "pop{w}\t%gs", []>, OpSize, TB;
4141def POPGS32 : I<0xa9, RawFrm, (outs), (ins),
4142 "pop{l}\t%gs", []>, TB;
4143
4144def LDS16rm : I<0xc5, MRMSrcMem, (outs GR16:$dst), (ins opaque32mem:$src),
4145 "lds{w}\t{$src, $dst|$dst, $src}", []>, OpSize;
4146def LDS32rm : I<0xc5, MRMSrcMem, (outs GR32:$dst), (ins opaque48mem:$src),
4147 "lds{l}\t{$src, $dst|$dst, $src}", []>;
4148def LSS16rm : I<0xb2, MRMSrcMem, (outs GR16:$dst), (ins opaque32mem:$src),
4149 "lss{w}\t{$src, $dst|$dst, $src}", []>, TB, OpSize;
4150def LSS32rm : I<0xb2, MRMSrcMem, (outs GR32:$dst), (ins opaque48mem:$src),
4151 "lss{l}\t{$src, $dst|$dst, $src}", []>, TB;
4152def LES16rm : I<0xc4, MRMSrcMem, (outs GR16:$dst), (ins opaque32mem:$src),
4153 "les{w}\t{$src, $dst|$dst, $src}", []>, OpSize;
4154def LES32rm : I<0xc4, MRMSrcMem, (outs GR32:$dst), (ins opaque48mem:$src),
4155 "les{l}\t{$src, $dst|$dst, $src}", []>;
4156def LFS16rm : I<0xb4, MRMSrcMem, (outs GR16:$dst), (ins opaque32mem:$src),
4157 "lfs{w}\t{$src, $dst|$dst, $src}", []>, TB, OpSize;
4158def LFS32rm : I<0xb4, MRMSrcMem, (outs GR32:$dst), (ins opaque48mem:$src),
4159 "lfs{l}\t{$src, $dst|$dst, $src}", []>, TB;
4160def LGS16rm : I<0xb5, MRMSrcMem, (outs GR16:$dst), (ins opaque32mem:$src),
4161 "lgs{w}\t{$src, $dst|$dst, $src}", []>, TB, OpSize;
4162def LGS32rm : I<0xb5, MRMSrcMem, (outs GR32:$dst), (ins opaque48mem:$src),
4163 "lgs{l}\t{$src, $dst|$dst, $src}", []>, TB;
4164
4165def VERRr : I<0x00, MRM4r, (outs), (ins GR16:$seg),
4166 "verr\t$seg", []>, TB;
4167def VERRm : I<0x00, MRM4m, (outs), (ins i16mem:$seg),
4168 "verr\t$seg", []>, TB;
4169def VERWr : I<0x00, MRM5r, (outs), (ins GR16:$seg),
4170 "verw\t$seg", []>, TB;
4171def VERWm : I<0x00, MRM5m, (outs), (ins i16mem:$seg),
4172 "verw\t$seg", []>, TB;
4173
4174// Descriptor-table support instructions
4175
4176def SGDTm : I<0x01, MRM0m, (outs opaque48mem:$dst), (ins),
4177 "sgdt\t$dst", []>, TB;
4178def SIDTm : I<0x01, MRM1m, (outs opaque48mem:$dst), (ins),
4179 "sidt\t$dst", []>, TB;
4180def SLDT16r : I<0x00, MRM0r, (outs GR16:$dst), (ins),
4181 "sldt{w}\t$dst", []>, TB;
4182def SLDT16m : I<0x00, MRM0m, (outs i16mem:$dst), (ins),
4183 "sldt{w}\t$dst", []>, TB;
4184def LGDTm : I<0x01, MRM2m, (outs), (ins opaque48mem:$src),
4185 "lgdt\t$src", []>, TB;
4186def LIDTm : I<0x01, MRM3m, (outs), (ins opaque48mem:$src),
4187 "lidt\t$src", []>, TB;
4188def LLDT16r : I<0x00, MRM2r, (outs), (ins GR16:$src),
4189 "lldt{w}\t$src", []>, TB;
4190def LLDT16m : I<0x00, MRM2m, (outs), (ins i16mem:$src),
4191 "lldt{w}\t$src", []>, TB;
Sean Callanan9a86f102009-09-16 22:59:28 +00004192
Kevin Enderby12ce0de2010-02-03 21:04:42 +00004193// Lock instruction prefix
4194def LOCK_PREFIX : I<0xF0, RawFrm, (outs), (ins), "lock", []>;
4195
4196// Repeat string operation instruction prefixes
4197// These uses the DF flag in the EFLAGS register to inc or dec ECX
4198let Defs = [ECX], Uses = [ECX,EFLAGS] in {
4199// Repeat (used with INS, OUTS, MOVS, LODS and STOS)
4200def REP_PREFIX : I<0xF3, RawFrm, (outs), (ins), "rep", []>;
4201// Repeat while not equal (used with CMPS and SCAS)
4202def REPNE_PREFIX : I<0xF2, RawFrm, (outs), (ins), "repne", []>;
4203}
4204
4205// Segment override instruction prefixes
4206def CS_PREFIX : I<0x2E, RawFrm, (outs), (ins), "cs", []>;
4207def SS_PREFIX : I<0x36, RawFrm, (outs), (ins), "ss", []>;
4208def DS_PREFIX : I<0x3E, RawFrm, (outs), (ins), "ds", []>;
4209def ES_PREFIX : I<0x26, RawFrm, (outs), (ins), "es", []>;
4210def FS_PREFIX : I<0x64, RawFrm, (outs), (ins), "fs", []>;
4211def GS_PREFIX : I<0x65, RawFrm, (outs), (ins), "gs", []>;
4212
Sean Callanan9a86f102009-09-16 22:59:28 +00004213// String manipulation instructions
4214
4215def LODSB : I<0xAC, RawFrm, (outs), (ins), "lodsb", []>;
4216def LODSW : I<0xAD, RawFrm, (outs), (ins), "lodsw", []>, OpSize;
Sean Callanan108934c2009-12-18 00:01:26 +00004217def LODSD : I<0xAD, RawFrm, (outs), (ins), "lods{l|d}", []>;
4218
4219def OUTSB : I<0x6E, RawFrm, (outs), (ins), "outsb", []>;
4220def OUTSW : I<0x6F, RawFrm, (outs), (ins), "outsw", []>, OpSize;
4221def OUTSD : I<0x6F, RawFrm, (outs), (ins), "outs{l|d}", []>;
4222
4223// CPU flow control instructions
4224
4225def HLT : I<0xF4, RawFrm, (outs), (ins), "hlt", []>;
4226def RSM : I<0xAA, RawFrm, (outs), (ins), "rsm", []>, TB;
4227
4228// FPU control instructions
4229
4230def FNINIT : I<0xE3, RawFrm, (outs), (ins), "fninit", []>, DB;
4231
4232// Flag instructions
4233
4234def CLC : I<0xF8, RawFrm, (outs), (ins), "clc", []>;
4235def STC : I<0xF9, RawFrm, (outs), (ins), "stc", []>;
4236def CLI : I<0xFA, RawFrm, (outs), (ins), "cli", []>;
4237def STI : I<0xFB, RawFrm, (outs), (ins), "sti", []>;
4238def CLD : I<0xFC, RawFrm, (outs), (ins), "cld", []>;
4239def STD : I<0xFD, RawFrm, (outs), (ins), "std", []>;
4240def CMC : I<0xF5, RawFrm, (outs), (ins), "cmc", []>;
4241
4242def CLTS : I<0x06, RawFrm, (outs), (ins), "clts", []>, TB;
4243
4244// Table lookup instructions
4245
4246def XLAT : I<0xD7, RawFrm, (outs), (ins), "xlatb", []>;
4247
4248// Specialized register support
4249
4250def WRMSR : I<0x30, RawFrm, (outs), (ins), "wrmsr", []>, TB;
4251def RDMSR : I<0x32, RawFrm, (outs), (ins), "rdmsr", []>, TB;
4252def RDPMC : I<0x33, RawFrm, (outs), (ins), "rdpmc", []>, TB;
4253
4254def SMSW16r : I<0x01, MRM4r, (outs GR16:$dst), (ins),
4255 "smsw{w}\t$dst", []>, OpSize, TB;
4256def SMSW32r : I<0x01, MRM4r, (outs GR32:$dst), (ins),
4257 "smsw{l}\t$dst", []>, TB;
4258// For memory operands, there is only a 16-bit form
4259def SMSW16m : I<0x01, MRM4m, (outs i16mem:$dst), (ins),
4260 "smsw{w}\t$dst", []>, TB;
4261
4262def LMSW16r : I<0x01, MRM6r, (outs), (ins GR16:$src),
4263 "lmsw{w}\t$src", []>, TB;
4264def LMSW16m : I<0x01, MRM6m, (outs), (ins i16mem:$src),
4265 "lmsw{w}\t$src", []>, TB;
4266
4267def CPUID : I<0xA2, RawFrm, (outs), (ins), "cpuid", []>, TB;
4268
4269// Cache instructions
4270
4271def INVD : I<0x08, RawFrm, (outs), (ins), "invd", []>, TB;
4272def WBINVD : I<0x09, RawFrm, (outs), (ins), "wbinvd", []>, TB;
4273
4274// VMX instructions
4275
4276// 66 0F 38 80
Sean Callanan95a5a7d2010-02-13 01:48:34 +00004277def INVEPT : I<0x80, RawFrm, (outs), (ins), "invept", []>, OpSize, T8;
Sean Callanan108934c2009-12-18 00:01:26 +00004278// 66 0F 38 81
Sean Callanan95a5a7d2010-02-13 01:48:34 +00004279def INVVPID : I<0x81, RawFrm, (outs), (ins), "invvpid", []>, OpSize, T8;
Sean Callanan108934c2009-12-18 00:01:26 +00004280// 0F 01 C1
Chris Lattnerfdfeb692010-02-12 20:49:41 +00004281def VMCALL : I<0x01, MRM_C1, (outs), (ins), "vmcall", []>, TB;
Sean Callanan108934c2009-12-18 00:01:26 +00004282def VMCLEARm : I<0xC7, MRM6m, (outs), (ins i64mem:$vmcs),
4283 "vmclear\t$vmcs", []>, OpSize, TB;
4284// 0F 01 C2
Chris Lattnera599de22010-02-13 00:41:14 +00004285def VMLAUNCH : I<0x01, MRM_C2, (outs), (ins), "vmlaunch", []>, TB;
Sean Callanan108934c2009-12-18 00:01:26 +00004286// 0F 01 C3
Chris Lattnera599de22010-02-13 00:41:14 +00004287def VMRESUME : I<0x01, MRM_C3, (outs), (ins), "vmresume", []>, TB;
Sean Callanan108934c2009-12-18 00:01:26 +00004288def VMPTRLDm : I<0xC7, MRM6m, (outs), (ins i64mem:$vmcs),
4289 "vmptrld\t$vmcs", []>, TB;
4290def VMPTRSTm : I<0xC7, MRM7m, (outs i64mem:$vmcs), (ins),
4291 "vmptrst\t$vmcs", []>, TB;
4292def VMREAD64rm : I<0x78, MRMDestMem, (outs i64mem:$dst), (ins GR64:$src),
4293 "vmread{q}\t{$src, $dst|$dst, $src}", []>, TB;
4294def VMREAD64rr : I<0x78, MRMDestReg, (outs GR64:$dst), (ins GR64:$src),
4295 "vmread{q}\t{$src, $dst|$dst, $src}", []>, TB;
4296def VMREAD32rm : I<0x78, MRMDestMem, (outs i32mem:$dst), (ins GR32:$src),
4297 "vmread{l}\t{$src, $dst|$dst, $src}", []>, TB;
4298def VMREAD32rr : I<0x78, MRMDestReg, (outs GR32:$dst), (ins GR32:$src),
4299 "vmread{l}\t{$src, $dst|$dst, $src}", []>, TB;
4300def VMWRITE64rm : I<0x79, MRMSrcMem, (outs GR64:$dst), (ins i64mem:$src),
4301 "vmwrite{q}\t{$src, $dst|$dst, $src}", []>, TB;
4302def VMWRITE64rr : I<0x79, MRMSrcReg, (outs GR64:$dst), (ins GR64:$src),
4303 "vmwrite{q}\t{$src, $dst|$dst, $src}", []>, TB;
4304def VMWRITE32rm : I<0x79, MRMSrcMem, (outs GR32:$dst), (ins i32mem:$src),
4305 "vmwrite{l}\t{$src, $dst|$dst, $src}", []>, TB;
4306def VMWRITE32rr : I<0x79, MRMSrcReg, (outs GR32:$dst), (ins GR32:$src),
4307 "vmwrite{l}\t{$src, $dst|$dst, $src}", []>, TB;
4308// 0F 01 C4
Chris Lattnera599de22010-02-13 00:41:14 +00004309def VMXOFF : I<0x01, MRM_C4, (outs), (ins), "vmxoff", []>, TB;
Sean Callanan108934c2009-12-18 00:01:26 +00004310def VMXON : I<0xC7, MRM6m, (outs), (ins i64mem:$vmxon),
Kevin Enderby0e822402010-03-08 22:17:26 +00004311 "vmxon\t{$vmxon}", []>, XS;
Sean Callanan358f1ef2009-09-16 21:55:34 +00004312
Andrew Lenharthab0b9492008-02-21 06:45:13 +00004313//===----------------------------------------------------------------------===//
Evan Cheng510e4782006-01-09 23:10:28 +00004314// Non-Instruction Patterns
4315//===----------------------------------------------------------------------===//
4316
Bill Wendling056292f2008-09-16 21:48:12 +00004317// ConstantPool GlobalAddress, ExternalSymbol, and JumpTable
Evan Cheng71fb8342006-02-25 10:02:21 +00004318def : Pat<(i32 (X86Wrapper tconstpool :$dst)), (MOV32ri tconstpool :$dst)>;
Nate Begeman37efe672006-04-22 18:53:45 +00004319def : Pat<(i32 (X86Wrapper tjumptable :$dst)), (MOV32ri tjumptable :$dst)>;
Nate Begeman6795ebb2008-04-12 00:47:57 +00004320def : Pat<(i32 (X86Wrapper tglobaltlsaddr:$dst)),(MOV32ri tglobaltlsaddr:$dst)>;
Evan Cheng71fb8342006-02-25 10:02:21 +00004321def : Pat<(i32 (X86Wrapper tglobaladdr :$dst)), (MOV32ri tglobaladdr :$dst)>;
4322def : Pat<(i32 (X86Wrapper texternalsym:$dst)), (MOV32ri texternalsym:$dst)>;
Dan Gohmanf705adb2009-10-30 01:28:02 +00004323def : Pat<(i32 (X86Wrapper tblockaddress:$dst)), (MOV32ri tblockaddress:$dst)>;
Evan Cheng71fb8342006-02-25 10:02:21 +00004324
Evan Cheng069287d2006-05-16 07:21:53 +00004325def : Pat<(add GR32:$src1, (X86Wrapper tconstpool:$src2)),
4326 (ADD32ri GR32:$src1, tconstpool:$src2)>;
4327def : Pat<(add GR32:$src1, (X86Wrapper tjumptable:$src2)),
4328 (ADD32ri GR32:$src1, tjumptable:$src2)>;
4329def : Pat<(add GR32:$src1, (X86Wrapper tglobaladdr :$src2)),
4330 (ADD32ri GR32:$src1, tglobaladdr:$src2)>;
4331def : Pat<(add GR32:$src1, (X86Wrapper texternalsym:$src2)),
4332 (ADD32ri GR32:$src1, texternalsym:$src2)>;
Dan Gohmanf705adb2009-10-30 01:28:02 +00004333def : Pat<(add GR32:$src1, (X86Wrapper tblockaddress:$src2)),
4334 (ADD32ri GR32:$src1, tblockaddress:$src2)>;
Evan Cheng71fb8342006-02-25 10:02:21 +00004335
Evan Chengfc8feb12006-05-19 07:30:36 +00004336def : Pat<(store (i32 (X86Wrapper tglobaladdr:$src)), addr:$dst),
Evan Cheng71fb8342006-02-25 10:02:21 +00004337 (MOV32mi addr:$dst, tglobaladdr:$src)>;
Evan Chengfc8feb12006-05-19 07:30:36 +00004338def : Pat<(store (i32 (X86Wrapper texternalsym:$src)), addr:$dst),
Evan Cheng71fb8342006-02-25 10:02:21 +00004339 (MOV32mi addr:$dst, texternalsym:$src)>;
Dan Gohmanf705adb2009-10-30 01:28:02 +00004340def : Pat<(store (i32 (X86Wrapper tblockaddress:$src)), addr:$dst),
4341 (MOV32mi addr:$dst, tblockaddress:$src)>;
Evan Cheng71fb8342006-02-25 10:02:21 +00004342
Evan Cheng510e4782006-01-09 23:10:28 +00004343// Calls
Arnold Schwaighoferc85e1712007-10-11 19:40:01 +00004344// tailcall stuff
Evan Chengf48ef032010-03-14 03:48:46 +00004345def : Pat<(X86tcret GR32_TC:$dst, imm:$off),
4346 (TCRETURNri GR32_TC:$dst, imm:$off)>,
4347 Requires<[In32BitMode]>;
4348
4349def : Pat<(X86tcret (load addr:$dst), imm:$off),
4350 (TCRETURNmi addr:$dst, imm:$off)>,
4351 Requires<[In32BitMode]>;
Arnold Schwaighoferc85e1712007-10-11 19:40:01 +00004352
4353def : Pat<(X86tcret (i32 tglobaladdr:$dst), imm:$off),
Evan Chengf48ef032010-03-14 03:48:46 +00004354 (TCRETURNdi texternalsym:$dst, imm:$off)>,
4355 Requires<[In32BitMode]>;
Arnold Schwaighoferc85e1712007-10-11 19:40:01 +00004356
4357def : Pat<(X86tcret (i32 texternalsym:$dst), imm:$off),
Evan Chengf48ef032010-03-14 03:48:46 +00004358 (TCRETURNdi texternalsym:$dst, imm:$off)>,
4359 Requires<[In32BitMode]>;
Evan Chengfea89c12006-04-27 08:40:39 +00004360
Dan Gohmancadb2262009-08-02 16:10:01 +00004361// Normal calls, with various flavors of addresses.
Evan Cheng25ab6902006-09-08 06:48:29 +00004362def : Pat<(X86call (i32 tglobaladdr:$dst)),
Evan Cheng510e4782006-01-09 23:10:28 +00004363 (CALLpcrel32 tglobaladdr:$dst)>;
Evan Cheng25ab6902006-09-08 06:48:29 +00004364def : Pat<(X86call (i32 texternalsym:$dst)),
Evan Cheng8700e142006-01-11 06:09:51 +00004365 (CALLpcrel32 texternalsym:$dst)>;
Evan Chengd7f666a2009-05-20 04:53:57 +00004366def : Pat<(X86call (i32 imm:$dst)),
4367 (CALLpcrel32 imm:$dst)>, Requires<[CallImmAddr]>;
Evan Cheng510e4782006-01-09 23:10:28 +00004368
4369// X86 specific add which produces a flag.
Evan Cheng069287d2006-05-16 07:21:53 +00004370def : Pat<(addc GR32:$src1, GR32:$src2),
4371 (ADD32rr GR32:$src1, GR32:$src2)>;
4372def : Pat<(addc GR32:$src1, (load addr:$src2)),
4373 (ADD32rm GR32:$src1, addr:$src2)>;
4374def : Pat<(addc GR32:$src1, imm:$src2),
4375 (ADD32ri GR32:$src1, imm:$src2)>;
4376def : Pat<(addc GR32:$src1, i32immSExt8:$src2),
4377 (ADD32ri8 GR32:$src1, i32immSExt8:$src2)>;
Evan Cheng510e4782006-01-09 23:10:28 +00004378
Evan Cheng069287d2006-05-16 07:21:53 +00004379def : Pat<(subc GR32:$src1, GR32:$src2),
4380 (SUB32rr GR32:$src1, GR32:$src2)>;
4381def : Pat<(subc GR32:$src1, (load addr:$src2)),
4382 (SUB32rm GR32:$src1, addr:$src2)>;
4383def : Pat<(subc GR32:$src1, imm:$src2),
4384 (SUB32ri GR32:$src1, imm:$src2)>;
4385def : Pat<(subc GR32:$src1, i32immSExt8:$src2),
4386 (SUB32ri8 GR32:$src1, i32immSExt8:$src2)>;
Evan Cheng510e4782006-01-09 23:10:28 +00004387
Chris Lattnerffc0b262006-09-07 20:33:45 +00004388// Comparisons.
4389
4390// TEST R,R is smaller than CMP R,0
Chris Lattnere3486a42010-03-19 00:01:11 +00004391def : Pat<(X86cmp GR8:$src1, 0),
Chris Lattnerffc0b262006-09-07 20:33:45 +00004392 (TEST8rr GR8:$src1, GR8:$src1)>;
Chris Lattnere3486a42010-03-19 00:01:11 +00004393def : Pat<(X86cmp GR16:$src1, 0),
Chris Lattnerffc0b262006-09-07 20:33:45 +00004394 (TEST16rr GR16:$src1, GR16:$src1)>;
Chris Lattnere3486a42010-03-19 00:01:11 +00004395def : Pat<(X86cmp GR32:$src1, 0),
Chris Lattnerffc0b262006-09-07 20:33:45 +00004396 (TEST32rr GR32:$src1, GR32:$src1)>;
4397
Dan Gohmanfbb74862009-01-07 01:00:24 +00004398// Conditional moves with folded loads with operands swapped and conditions
4399// inverted.
4400def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_B, EFLAGS),
4401 (CMOVAE16rm GR16:$src2, addr:$src1)>;
4402def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_B, EFLAGS),
4403 (CMOVAE32rm GR32:$src2, addr:$src1)>;
4404def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_AE, EFLAGS),
4405 (CMOVB16rm GR16:$src2, addr:$src1)>;
4406def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_AE, EFLAGS),
4407 (CMOVB32rm GR32:$src2, addr:$src1)>;
4408def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_E, EFLAGS),
4409 (CMOVNE16rm GR16:$src2, addr:$src1)>;
4410def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_E, EFLAGS),
4411 (CMOVNE32rm GR32:$src2, addr:$src1)>;
4412def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_NE, EFLAGS),
4413 (CMOVE16rm GR16:$src2, addr:$src1)>;
4414def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_NE, EFLAGS),
4415 (CMOVE32rm GR32:$src2, addr:$src1)>;
4416def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_BE, EFLAGS),
4417 (CMOVA16rm GR16:$src2, addr:$src1)>;
4418def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_BE, EFLAGS),
4419 (CMOVA32rm GR32:$src2, addr:$src1)>;
4420def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_A, EFLAGS),
4421 (CMOVBE16rm GR16:$src2, addr:$src1)>;
4422def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_A, EFLAGS),
4423 (CMOVBE32rm GR32:$src2, addr:$src1)>;
4424def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_L, EFLAGS),
4425 (CMOVGE16rm GR16:$src2, addr:$src1)>;
4426def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_L, EFLAGS),
4427 (CMOVGE32rm GR32:$src2, addr:$src1)>;
4428def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_GE, EFLAGS),
4429 (CMOVL16rm GR16:$src2, addr:$src1)>;
4430def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_GE, EFLAGS),
4431 (CMOVL32rm GR32:$src2, addr:$src1)>;
4432def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_LE, EFLAGS),
4433 (CMOVG16rm GR16:$src2, addr:$src1)>;
4434def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_LE, EFLAGS),
4435 (CMOVG32rm GR32:$src2, addr:$src1)>;
4436def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_G, EFLAGS),
4437 (CMOVLE16rm GR16:$src2, addr:$src1)>;
4438def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_G, EFLAGS),
4439 (CMOVLE32rm GR32:$src2, addr:$src1)>;
4440def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_P, EFLAGS),
4441 (CMOVNP16rm GR16:$src2, addr:$src1)>;
4442def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_P, EFLAGS),
4443 (CMOVNP32rm GR32:$src2, addr:$src1)>;
4444def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_NP, EFLAGS),
4445 (CMOVP16rm GR16:$src2, addr:$src1)>;
4446def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_NP, EFLAGS),
4447 (CMOVP32rm GR32:$src2, addr:$src1)>;
4448def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_S, EFLAGS),
4449 (CMOVNS16rm GR16:$src2, addr:$src1)>;
4450def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_S, EFLAGS),
4451 (CMOVNS32rm GR32:$src2, addr:$src1)>;
4452def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_NS, EFLAGS),
4453 (CMOVS16rm GR16:$src2, addr:$src1)>;
4454def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_NS, EFLAGS),
4455 (CMOVS32rm GR32:$src2, addr:$src1)>;
4456def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_O, EFLAGS),
4457 (CMOVNO16rm GR16:$src2, addr:$src1)>;
4458def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_O, EFLAGS),
4459 (CMOVNO32rm GR32:$src2, addr:$src1)>;
4460def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_NO, EFLAGS),
4461 (CMOVO16rm GR16:$src2, addr:$src1)>;
4462def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_NO, EFLAGS),
4463 (CMOVO32rm GR32:$src2, addr:$src1)>;
4464
Duncan Sandsf9c98e62008-01-23 20:39:46 +00004465// zextload bool -> zextload byte
Evan Chenge5d93432006-01-17 07:02:46 +00004466def : Pat<(zextloadi8i1 addr:$src), (MOV8rm addr:$src)>;
Evan Cheng510e4782006-01-09 23:10:28 +00004467def : Pat<(zextloadi16i1 addr:$src), (MOVZX16rm8 addr:$src)>;
4468def : Pat<(zextloadi32i1 addr:$src), (MOVZX32rm8 addr:$src)>;
4469
4470// extload bool -> extload byte
Evan Cheng47137242006-05-05 08:23:07 +00004471def : Pat<(extloadi8i1 addr:$src), (MOV8rm addr:$src)>;
Dan Gohmanaf70e5c2009-08-26 14:59:13 +00004472def : Pat<(extloadi16i1 addr:$src), (MOVZX16rm8 addr:$src)>;
Evan Cheng47137242006-05-05 08:23:07 +00004473def : Pat<(extloadi32i1 addr:$src), (MOVZX32rm8 addr:$src)>;
Dan Gohmanaf70e5c2009-08-26 14:59:13 +00004474def : Pat<(extloadi16i8 addr:$src), (MOVZX16rm8 addr:$src)>;
Evan Cheng47137242006-05-05 08:23:07 +00004475def : Pat<(extloadi32i8 addr:$src), (MOVZX32rm8 addr:$src)>;
4476def : Pat<(extloadi32i16 addr:$src), (MOVZX32rm16 addr:$src)>;
Evan Cheng510e4782006-01-09 23:10:28 +00004477
Dan Gohmanaf70e5c2009-08-26 14:59:13 +00004478// anyext. Define these to do an explicit zero-extend to
4479// avoid partial-register updates.
4480def : Pat<(i16 (anyext GR8 :$src)), (MOVZX16rr8 GR8 :$src)>;
4481def : Pat<(i32 (anyext GR8 :$src)), (MOVZX32rr8 GR8 :$src)>;
4482def : Pat<(i32 (anyext GR16:$src)), (MOVZX32rr16 GR16:$src)>;
Evan Cheng510e4782006-01-09 23:10:28 +00004483
Evan Chengcfa260b2006-01-06 02:31:59 +00004484//===----------------------------------------------------------------------===//
4485// Some peepholes
4486//===----------------------------------------------------------------------===//
4487
Dan Gohman63f97202008-10-17 01:33:43 +00004488// Odd encoding trick: -128 fits into an 8-bit immediate field while
4489// +128 doesn't, so in this special case use a sub instead of an add.
4490def : Pat<(add GR16:$src1, 128),
4491 (SUB16ri8 GR16:$src1, -128)>;
4492def : Pat<(store (add (loadi16 addr:$dst), 128), addr:$dst),
4493 (SUB16mi8 addr:$dst, -128)>;
4494def : Pat<(add GR32:$src1, 128),
4495 (SUB32ri8 GR32:$src1, -128)>;
4496def : Pat<(store (add (loadi32 addr:$dst), 128), addr:$dst),
4497 (SUB32mi8 addr:$dst, -128)>;
4498
Dan Gohman11ba3b12008-07-30 18:09:17 +00004499// r & (2^16-1) ==> movz
4500def : Pat<(and GR32:$src1, 0xffff),
Dan Gohman21e3dfb2009-04-13 16:09:41 +00004501 (MOVZX32rr16 (EXTRACT_SUBREG GR32:$src1, x86_subreg_16bit))>;
Dan Gohman8a1510d2008-08-06 18:27:21 +00004502// r & (2^8-1) ==> movz
4503def : Pat<(and GR32:$src1, 0xff),
Anton Korobeynikov3a639a02009-11-02 00:11:39 +00004504 (MOVZX32rr8 (EXTRACT_SUBREG (i32 (COPY_TO_REGCLASS GR32:$src1,
4505 GR32_ABCD)),
Dan Gohman21e3dfb2009-04-13 16:09:41 +00004506 x86_subreg_8bit))>,
Dan Gohman8a1510d2008-08-06 18:27:21 +00004507 Requires<[In32BitMode]>;
4508// r & (2^8-1) ==> movz
4509def : Pat<(and GR16:$src1, 0xff),
Anton Korobeynikov3a639a02009-11-02 00:11:39 +00004510 (MOVZX16rr8 (EXTRACT_SUBREG (i16 (COPY_TO_REGCLASS GR16:$src1,
4511 GR16_ABCD)),
Dan Gohman21e3dfb2009-04-13 16:09:41 +00004512 x86_subreg_8bit))>,
Dan Gohman0bfa1bf2008-08-20 21:27:32 +00004513 Requires<[In32BitMode]>;
4514
4515// sext_inreg patterns
4516def : Pat<(sext_inreg GR32:$src, i16),
Dan Gohman21e3dfb2009-04-13 16:09:41 +00004517 (MOVSX32rr16 (EXTRACT_SUBREG GR32:$src, x86_subreg_16bit))>;
Dan Gohman0bfa1bf2008-08-20 21:27:32 +00004518def : Pat<(sext_inreg GR32:$src, i8),
Anton Korobeynikov3a639a02009-11-02 00:11:39 +00004519 (MOVSX32rr8 (EXTRACT_SUBREG (i32 (COPY_TO_REGCLASS GR32:$src,
4520 GR32_ABCD)),
Dan Gohman21e3dfb2009-04-13 16:09:41 +00004521 x86_subreg_8bit))>,
Dan Gohman0bfa1bf2008-08-20 21:27:32 +00004522 Requires<[In32BitMode]>;
4523def : Pat<(sext_inreg GR16:$src, i8),
Anton Korobeynikov3a639a02009-11-02 00:11:39 +00004524 (MOVSX16rr8 (EXTRACT_SUBREG (i16 (COPY_TO_REGCLASS GR16:$src,
4525 GR16_ABCD)),
Dan Gohman21e3dfb2009-04-13 16:09:41 +00004526 x86_subreg_8bit))>,
Dan Gohman0bfa1bf2008-08-20 21:27:32 +00004527 Requires<[In32BitMode]>;
4528
4529// trunc patterns
4530def : Pat<(i16 (trunc GR32:$src)),
Dan Gohman21e3dfb2009-04-13 16:09:41 +00004531 (EXTRACT_SUBREG GR32:$src, x86_subreg_16bit)>;
Dan Gohman0bfa1bf2008-08-20 21:27:32 +00004532def : Pat<(i8 (trunc GR32:$src)),
Anton Korobeynikov3a639a02009-11-02 00:11:39 +00004533 (EXTRACT_SUBREG (i32 (COPY_TO_REGCLASS GR32:$src, GR32_ABCD)),
Dan Gohman21e3dfb2009-04-13 16:09:41 +00004534 x86_subreg_8bit)>,
Dan Gohman0bfa1bf2008-08-20 21:27:32 +00004535 Requires<[In32BitMode]>;
4536def : Pat<(i8 (trunc GR16:$src)),
Anton Korobeynikov3a639a02009-11-02 00:11:39 +00004537 (EXTRACT_SUBREG (i16 (COPY_TO_REGCLASS GR16:$src, GR16_ABCD)),
Dan Gohman21e3dfb2009-04-13 16:09:41 +00004538 x86_subreg_8bit)>,
4539 Requires<[In32BitMode]>;
4540
4541// h-register tricks
4542def : Pat<(i8 (trunc (srl_su GR16:$src, (i8 8)))),
Anton Korobeynikov3a639a02009-11-02 00:11:39 +00004543 (EXTRACT_SUBREG (i32 (COPY_TO_REGCLASS GR16:$src, GR16_ABCD)),
Dan Gohman21e3dfb2009-04-13 16:09:41 +00004544 x86_subreg_8bit_hi)>,
4545 Requires<[In32BitMode]>;
4546def : Pat<(i8 (trunc (srl_su GR32:$src, (i8 8)))),
Anton Korobeynikov3a639a02009-11-02 00:11:39 +00004547 (EXTRACT_SUBREG (i16 (COPY_TO_REGCLASS GR32:$src, GR32_ABCD)),
Dan Gohman21e3dfb2009-04-13 16:09:41 +00004548 x86_subreg_8bit_hi)>,
4549 Requires<[In32BitMode]>;
Dan Gohman7e0d64a2010-01-11 17:21:05 +00004550def : Pat<(srl GR16:$src, (i8 8)),
Dan Gohman21e3dfb2009-04-13 16:09:41 +00004551 (EXTRACT_SUBREG
4552 (MOVZX32rr8
Anton Korobeynikov3a639a02009-11-02 00:11:39 +00004553 (EXTRACT_SUBREG (i16 (COPY_TO_REGCLASS GR16:$src, GR16_ABCD)),
Dan Gohman21e3dfb2009-04-13 16:09:41 +00004554 x86_subreg_8bit_hi)),
4555 x86_subreg_16bit)>,
4556 Requires<[In32BitMode]>;
Evan Chengcb219f02009-05-29 01:44:43 +00004557def : Pat<(i32 (zext (srl_su GR16:$src, (i8 8)))),
Sean Callanan108934c2009-12-18 00:01:26 +00004558 (MOVZX32rr8 (EXTRACT_SUBREG (i16 (COPY_TO_REGCLASS GR16:$src,
4559 GR16_ABCD)),
Evan Chengcb219f02009-05-29 01:44:43 +00004560 x86_subreg_8bit_hi))>,
4561 Requires<[In32BitMode]>;
Dan Gohmanaf70e5c2009-08-26 14:59:13 +00004562def : Pat<(i32 (anyext (srl_su GR16:$src, (i8 8)))),
Sean Callanan108934c2009-12-18 00:01:26 +00004563 (MOVZX32rr8 (EXTRACT_SUBREG (i16 (COPY_TO_REGCLASS GR16:$src,
4564 GR16_ABCD)),
Dan Gohmanaf70e5c2009-08-26 14:59:13 +00004565 x86_subreg_8bit_hi))>,
4566 Requires<[In32BitMode]>;
Dan Gohman21e3dfb2009-04-13 16:09:41 +00004567def : Pat<(and (srl_su GR32:$src, (i8 8)), (i32 255)),
Sean Callanan108934c2009-12-18 00:01:26 +00004568 (MOVZX32rr8 (EXTRACT_SUBREG (i32 (COPY_TO_REGCLASS GR32:$src,
4569 GR32_ABCD)),
Dan Gohman21e3dfb2009-04-13 16:09:41 +00004570 x86_subreg_8bit_hi))>,
Dan Gohman8a1510d2008-08-06 18:27:21 +00004571 Requires<[In32BitMode]>;
Dan Gohman11ba3b12008-07-30 18:09:17 +00004572
Evan Chengcfa260b2006-01-06 02:31:59 +00004573// (shl x, 1) ==> (add x, x)
Evan Cheng069287d2006-05-16 07:21:53 +00004574def : Pat<(shl GR8 :$src1, (i8 1)), (ADD8rr GR8 :$src1, GR8 :$src1)>;
4575def : Pat<(shl GR16:$src1, (i8 1)), (ADD16rr GR16:$src1, GR16:$src1)>;
4576def : Pat<(shl GR32:$src1, (i8 1)), (ADD32rr GR32:$src1, GR32:$src1)>;
Evan Cheng68b951a2006-01-19 01:56:29 +00004577
Evan Chengeb9f8922008-08-30 02:03:58 +00004578// (shl x (and y, 31)) ==> (shl x, y)
Chris Lattner6d9f86b2010-02-23 06:54:29 +00004579def : Pat<(shl GR8:$src1, (and CL, 31)),
Evan Chengeb9f8922008-08-30 02:03:58 +00004580 (SHL8rCL GR8:$src1)>;
Chris Lattner6d9f86b2010-02-23 06:54:29 +00004581def : Pat<(shl GR16:$src1, (and CL, 31)),
Evan Chengeb9f8922008-08-30 02:03:58 +00004582 (SHL16rCL GR16:$src1)>;
Chris Lattner6d9f86b2010-02-23 06:54:29 +00004583def : Pat<(shl GR32:$src1, (and CL, 31)),
Evan Chengeb9f8922008-08-30 02:03:58 +00004584 (SHL32rCL GR32:$src1)>;
Chris Lattner6d9f86b2010-02-23 06:54:29 +00004585def : Pat<(store (shl (loadi8 addr:$dst), (and CL, 31)), addr:$dst),
Evan Chengeb9f8922008-08-30 02:03:58 +00004586 (SHL8mCL addr:$dst)>;
Chris Lattner6d9f86b2010-02-23 06:54:29 +00004587def : Pat<(store (shl (loadi16 addr:$dst), (and CL, 31)), addr:$dst),
Evan Chengeb9f8922008-08-30 02:03:58 +00004588 (SHL16mCL addr:$dst)>;
Chris Lattner6d9f86b2010-02-23 06:54:29 +00004589def : Pat<(store (shl (loadi32 addr:$dst), (and CL, 31)), addr:$dst),
Evan Chengeb9f8922008-08-30 02:03:58 +00004590 (SHL32mCL addr:$dst)>;
4591
Chris Lattner6d9f86b2010-02-23 06:54:29 +00004592def : Pat<(srl GR8:$src1, (and CL, 31)),
Evan Chengeb9f8922008-08-30 02:03:58 +00004593 (SHR8rCL GR8:$src1)>;
Chris Lattner6d9f86b2010-02-23 06:54:29 +00004594def : Pat<(srl GR16:$src1, (and CL, 31)),
Evan Chengeb9f8922008-08-30 02:03:58 +00004595 (SHR16rCL GR16:$src1)>;
Chris Lattner6d9f86b2010-02-23 06:54:29 +00004596def : Pat<(srl GR32:$src1, (and CL, 31)),
Evan Chengeb9f8922008-08-30 02:03:58 +00004597 (SHR32rCL GR32:$src1)>;
Chris Lattner6d9f86b2010-02-23 06:54:29 +00004598def : Pat<(store (srl (loadi8 addr:$dst), (and CL, 31)), addr:$dst),
Evan Chengeb9f8922008-08-30 02:03:58 +00004599 (SHR8mCL addr:$dst)>;
Chris Lattner6d9f86b2010-02-23 06:54:29 +00004600def : Pat<(store (srl (loadi16 addr:$dst), (and CL, 31)), addr:$dst),
Evan Chengeb9f8922008-08-30 02:03:58 +00004601 (SHR16mCL addr:$dst)>;
Chris Lattner6d9f86b2010-02-23 06:54:29 +00004602def : Pat<(store (srl (loadi32 addr:$dst), (and CL, 31)), addr:$dst),
Evan Chengeb9f8922008-08-30 02:03:58 +00004603 (SHR32mCL addr:$dst)>;
4604
Chris Lattner6d9f86b2010-02-23 06:54:29 +00004605def : Pat<(sra GR8:$src1, (and CL, 31)),
Evan Chengeb9f8922008-08-30 02:03:58 +00004606 (SAR8rCL GR8:$src1)>;
Chris Lattner6d9f86b2010-02-23 06:54:29 +00004607def : Pat<(sra GR16:$src1, (and CL, 31)),
Evan Chengeb9f8922008-08-30 02:03:58 +00004608 (SAR16rCL GR16:$src1)>;
Chris Lattner6d9f86b2010-02-23 06:54:29 +00004609def : Pat<(sra GR32:$src1, (and CL, 31)),
Evan Chengeb9f8922008-08-30 02:03:58 +00004610 (SAR32rCL GR32:$src1)>;
Chris Lattner6d9f86b2010-02-23 06:54:29 +00004611def : Pat<(store (sra (loadi8 addr:$dst), (and CL, 31)), addr:$dst),
Evan Chengeb9f8922008-08-30 02:03:58 +00004612 (SAR8mCL addr:$dst)>;
Chris Lattner6d9f86b2010-02-23 06:54:29 +00004613def : Pat<(store (sra (loadi16 addr:$dst), (and CL, 31)), addr:$dst),
Evan Chengeb9f8922008-08-30 02:03:58 +00004614 (SAR16mCL addr:$dst)>;
Chris Lattner6d9f86b2010-02-23 06:54:29 +00004615def : Pat<(store (sra (loadi32 addr:$dst), (and CL, 31)), addr:$dst),
Evan Chengeb9f8922008-08-30 02:03:58 +00004616 (SAR32mCL addr:$dst)>;
4617
Evan Cheng956044c2006-01-19 23:26:24 +00004618// (or (x >> c) | (y << (32 - c))) ==> (shrd32 x, y, c)
Evan Cheng069287d2006-05-16 07:21:53 +00004619def : Pat<(or (srl GR32:$src1, CL:$amt),
4620 (shl GR32:$src2, (sub 32, CL:$amt))),
4621 (SHRD32rrCL GR32:$src1, GR32:$src2)>;
Evan Cheng68b951a2006-01-19 01:56:29 +00004622
Evan Cheng21d54432006-01-20 01:13:30 +00004623def : Pat<(store (or (srl (loadi32 addr:$dst), CL:$amt),
Evan Cheng069287d2006-05-16 07:21:53 +00004624 (shl GR32:$src2, (sub 32, CL:$amt))), addr:$dst),
4625 (SHRD32mrCL addr:$dst, GR32:$src2)>;
Evan Cheng21d54432006-01-20 01:13:30 +00004626
Dan Gohman74feef22008-10-17 01:23:35 +00004627def : Pat<(or (srl GR32:$src1, (i8 (trunc ECX:$amt))),
4628 (shl GR32:$src2, (i8 (trunc (sub 32, ECX:$amt))))),
4629 (SHRD32rrCL GR32:$src1, GR32:$src2)>;
4630
4631def : Pat<(store (or (srl (loadi32 addr:$dst), (i8 (trunc ECX:$amt))),
4632 (shl GR32:$src2, (i8 (trunc (sub 32, ECX:$amt))))),
4633 addr:$dst),
4634 (SHRD32mrCL addr:$dst, GR32:$src2)>;
4635
Chris Lattner6d9f86b2010-02-23 06:54:29 +00004636def : Pat<(shrd GR32:$src1, (i8 imm:$amt1), GR32:$src2, (i8 imm/*:$amt2*/)),
Dan Gohman74feef22008-10-17 01:23:35 +00004637 (SHRD32rri8 GR32:$src1, GR32:$src2, (i8 imm:$amt1))>;
4638
4639def : Pat<(store (shrd (loadi32 addr:$dst), (i8 imm:$amt1),
Chris Lattner6d9f86b2010-02-23 06:54:29 +00004640 GR32:$src2, (i8 imm/*:$amt2*/)), addr:$dst),
Dan Gohman74feef22008-10-17 01:23:35 +00004641 (SHRD32mri8 addr:$dst, GR32:$src2, (i8 imm:$amt1))>;
4642
Evan Cheng956044c2006-01-19 23:26:24 +00004643// (or (x << c) | (y >> (32 - c))) ==> (shld32 x, y, c)
Evan Cheng069287d2006-05-16 07:21:53 +00004644def : Pat<(or (shl GR32:$src1, CL:$amt),
4645 (srl GR32:$src2, (sub 32, CL:$amt))),
4646 (SHLD32rrCL GR32:$src1, GR32:$src2)>;
Evan Cheng956044c2006-01-19 23:26:24 +00004647
Evan Cheng21d54432006-01-20 01:13:30 +00004648def : Pat<(store (or (shl (loadi32 addr:$dst), CL:$amt),
Evan Cheng069287d2006-05-16 07:21:53 +00004649 (srl GR32:$src2, (sub 32, CL:$amt))), addr:$dst),
4650 (SHLD32mrCL addr:$dst, GR32:$src2)>;
Evan Cheng21d54432006-01-20 01:13:30 +00004651
Dan Gohman74feef22008-10-17 01:23:35 +00004652def : Pat<(or (shl GR32:$src1, (i8 (trunc ECX:$amt))),
4653 (srl GR32:$src2, (i8 (trunc (sub 32, ECX:$amt))))),
4654 (SHLD32rrCL GR32:$src1, GR32:$src2)>;
4655
4656def : Pat<(store (or (shl (loadi32 addr:$dst), (i8 (trunc ECX:$amt))),
4657 (srl GR32:$src2, (i8 (trunc (sub 32, ECX:$amt))))),
4658 addr:$dst),
4659 (SHLD32mrCL addr:$dst, GR32:$src2)>;
4660
Chris Lattner6d9f86b2010-02-23 06:54:29 +00004661def : Pat<(shld GR32:$src1, (i8 imm:$amt1), GR32:$src2, (i8 imm/*:$amt2*/)),
Dan Gohman74feef22008-10-17 01:23:35 +00004662 (SHLD32rri8 GR32:$src1, GR32:$src2, (i8 imm:$amt1))>;
4663
4664def : Pat<(store (shld (loadi32 addr:$dst), (i8 imm:$amt1),
Chris Lattner6d9f86b2010-02-23 06:54:29 +00004665 GR32:$src2, (i8 imm/*:$amt2*/)), addr:$dst),
Dan Gohman74feef22008-10-17 01:23:35 +00004666 (SHLD32mri8 addr:$dst, GR32:$src2, (i8 imm:$amt1))>;
4667
Evan Cheng956044c2006-01-19 23:26:24 +00004668// (or (x >> c) | (y << (16 - c))) ==> (shrd16 x, y, c)
Evan Cheng069287d2006-05-16 07:21:53 +00004669def : Pat<(or (srl GR16:$src1, CL:$amt),
4670 (shl GR16:$src2, (sub 16, CL:$amt))),
4671 (SHRD16rrCL GR16:$src1, GR16:$src2)>;
Evan Cheng956044c2006-01-19 23:26:24 +00004672
Evan Cheng21d54432006-01-20 01:13:30 +00004673def : Pat<(store (or (srl (loadi16 addr:$dst), CL:$amt),
Evan Cheng069287d2006-05-16 07:21:53 +00004674 (shl GR16:$src2, (sub 16, CL:$amt))), addr:$dst),
4675 (SHRD16mrCL addr:$dst, GR16:$src2)>;
Evan Cheng21d54432006-01-20 01:13:30 +00004676
Dan Gohman74feef22008-10-17 01:23:35 +00004677def : Pat<(or (srl GR16:$src1, (i8 (trunc CX:$amt))),
4678 (shl GR16:$src2, (i8 (trunc (sub 16, CX:$amt))))),
4679 (SHRD16rrCL GR16:$src1, GR16:$src2)>;
4680
4681def : Pat<(store (or (srl (loadi16 addr:$dst), (i8 (trunc CX:$amt))),
4682 (shl GR16:$src2, (i8 (trunc (sub 16, CX:$amt))))),
4683 addr:$dst),
4684 (SHRD16mrCL addr:$dst, GR16:$src2)>;
4685
Chris Lattner6d9f86b2010-02-23 06:54:29 +00004686def : Pat<(shrd GR16:$src1, (i8 imm:$amt1), GR16:$src2, (i8 imm/*:$amt2*/)),
Dan Gohman74feef22008-10-17 01:23:35 +00004687 (SHRD16rri8 GR16:$src1, GR16:$src2, (i8 imm:$amt1))>;
4688
4689def : Pat<(store (shrd (loadi16 addr:$dst), (i8 imm:$amt1),
Chris Lattner6d9f86b2010-02-23 06:54:29 +00004690 GR16:$src2, (i8 imm/*:$amt2*/)), addr:$dst),
Dan Gohman74feef22008-10-17 01:23:35 +00004691 (SHRD16mri8 addr:$dst, GR16:$src2, (i8 imm:$amt1))>;
4692
Evan Cheng956044c2006-01-19 23:26:24 +00004693// (or (x << c) | (y >> (16 - c))) ==> (shld16 x, y, c)
Evan Cheng069287d2006-05-16 07:21:53 +00004694def : Pat<(or (shl GR16:$src1, CL:$amt),
4695 (srl GR16:$src2, (sub 16, CL:$amt))),
4696 (SHLD16rrCL GR16:$src1, GR16:$src2)>;
Evan Cheng21d54432006-01-20 01:13:30 +00004697
4698def : Pat<(store (or (shl (loadi16 addr:$dst), CL:$amt),
Evan Cheng069287d2006-05-16 07:21:53 +00004699 (srl GR16:$src2, (sub 16, CL:$amt))), addr:$dst),
4700 (SHLD16mrCL addr:$dst, GR16:$src2)>;
Evan Cheng4e4c71e2006-02-21 20:00:20 +00004701
Dan Gohman74feef22008-10-17 01:23:35 +00004702def : Pat<(or (shl GR16:$src1, (i8 (trunc CX:$amt))),
4703 (srl GR16:$src2, (i8 (trunc (sub 16, CX:$amt))))),
4704 (SHLD16rrCL GR16:$src1, GR16:$src2)>;
4705
4706def : Pat<(store (or (shl (loadi16 addr:$dst), (i8 (trunc CX:$amt))),
4707 (srl GR16:$src2, (i8 (trunc (sub 16, CX:$amt))))),
4708 addr:$dst),
4709 (SHLD16mrCL addr:$dst, GR16:$src2)>;
4710
Chris Lattner6d9f86b2010-02-23 06:54:29 +00004711def : Pat<(shld GR16:$src1, (i8 imm:$amt1), GR16:$src2, (i8 imm/*:$amt2*/)),
Dan Gohman74feef22008-10-17 01:23:35 +00004712 (SHLD16rri8 GR16:$src1, GR16:$src2, (i8 imm:$amt1))>;
4713
4714def : Pat<(store (shld (loadi16 addr:$dst), (i8 imm:$amt1),
Chris Lattner6d9f86b2010-02-23 06:54:29 +00004715 GR16:$src2, (i8 imm/*:$amt2*/)), addr:$dst),
Dan Gohman74feef22008-10-17 01:23:35 +00004716 (SHLD16mri8 addr:$dst, GR16:$src2, (i8 imm:$amt1))>;
4717
Evan Cheng2e489c42009-12-16 00:53:11 +00004718// (anyext (setcc_carry)) -> (setcc_carry)
4719def : Pat<(i16 (anyext (i8 (X86setcc_c X86_COND_B, EFLAGS)))),
Evan Chengad9c0a32009-12-15 00:53:42 +00004720 (SETB_C16r)>;
Evan Cheng2e489c42009-12-16 00:53:11 +00004721def : Pat<(i32 (anyext (i8 (X86setcc_c X86_COND_B, EFLAGS)))),
Evan Chengad9c0a32009-12-15 00:53:42 +00004722 (SETB_C32r)>;
4723
Evan Cheng199c4242010-01-11 22:03:29 +00004724// (or x1, x2) -> (add x1, x2) if two operands are known not to share bits.
Evan Cheng3bda2012010-01-12 18:31:19 +00004725let AddedComplexity = 5 in { // Try this before the selecting to OR
Chris Lattnera0f70172010-03-24 00:15:23 +00004726def : Pat<(or_is_add GR16:$src1, imm:$src2),
Evan Cheng4b0345b2010-01-11 17:03:47 +00004727 (ADD16ri GR16:$src1, imm:$src2)>;
Chris Lattnera0f70172010-03-24 00:15:23 +00004728def : Pat<(or_is_add GR32:$src1, imm:$src2),
Evan Cheng4b0345b2010-01-11 17:03:47 +00004729 (ADD32ri GR32:$src1, imm:$src2)>;
Chris Lattnera0f70172010-03-24 00:15:23 +00004730def : Pat<(or_is_add GR16:$src1, i16immSExt8:$src2),
Evan Cheng4b0345b2010-01-11 17:03:47 +00004731 (ADD16ri8 GR16:$src1, i16immSExt8:$src2)>;
Chris Lattnera0f70172010-03-24 00:15:23 +00004732def : Pat<(or_is_add GR32:$src1, i32immSExt8:$src2),
Evan Cheng4b0345b2010-01-11 17:03:47 +00004733 (ADD32ri8 GR32:$src1, i32immSExt8:$src2)>;
Chris Lattnera0f70172010-03-24 00:15:23 +00004734def : Pat<(or_is_add GR16:$src1, GR16:$src2),
Evan Cheng199c4242010-01-11 22:03:29 +00004735 (ADD16rr GR16:$src1, GR16:$src2)>;
Chris Lattnera0f70172010-03-24 00:15:23 +00004736def : Pat<(or_is_add GR32:$src1, GR32:$src2),
Evan Cheng199c4242010-01-11 22:03:29 +00004737 (ADD32rr GR32:$src1, GR32:$src2)>;
Evan Cheng3bda2012010-01-12 18:31:19 +00004738} // AddedComplexity
Evan Cheng4b0345b2010-01-11 17:03:47 +00004739
Evan Cheng4e4c71e2006-02-21 20:00:20 +00004740//===----------------------------------------------------------------------===//
Dan Gohman076aee32009-03-04 19:44:21 +00004741// EFLAGS-defining Patterns
Bill Wendlingd350e022008-12-12 21:15:41 +00004742//===----------------------------------------------------------------------===//
4743
Dan Gohman076aee32009-03-04 19:44:21 +00004744// Register-Register Addition with EFLAGS result
4745def : Pat<(parallel (X86add_flag GR8:$src1, GR8:$src2),
Bill Wendlingd350e022008-12-12 21:15:41 +00004746 (implicit EFLAGS)),
4747 (ADD8rr GR8:$src1, GR8:$src2)>;
Dan Gohman076aee32009-03-04 19:44:21 +00004748def : Pat<(parallel (X86add_flag GR16:$src1, GR16:$src2),
Bill Wendlingd350e022008-12-12 21:15:41 +00004749 (implicit EFLAGS)),
4750 (ADD16rr GR16:$src1, GR16:$src2)>;
Dan Gohman076aee32009-03-04 19:44:21 +00004751def : Pat<(parallel (X86add_flag GR32:$src1, GR32:$src2),
Bill Wendlingd350e022008-12-12 21:15:41 +00004752 (implicit EFLAGS)),
4753 (ADD32rr GR32:$src1, GR32:$src2)>;
4754
Dan Gohman076aee32009-03-04 19:44:21 +00004755// Register-Memory Addition with EFLAGS result
4756def : Pat<(parallel (X86add_flag GR8:$src1, (loadi8 addr:$src2)),
Bill Wendlingd350e022008-12-12 21:15:41 +00004757 (implicit EFLAGS)),
4758 (ADD8rm GR8:$src1, addr:$src2)>;
Dan Gohman076aee32009-03-04 19:44:21 +00004759def : Pat<(parallel (X86add_flag GR16:$src1, (loadi16 addr:$src2)),
Bill Wendlingd350e022008-12-12 21:15:41 +00004760 (implicit EFLAGS)),
4761 (ADD16rm GR16:$src1, addr:$src2)>;
Dan Gohman076aee32009-03-04 19:44:21 +00004762def : Pat<(parallel (X86add_flag GR32:$src1, (loadi32 addr:$src2)),
Bill Wendlingd350e022008-12-12 21:15:41 +00004763 (implicit EFLAGS)),
4764 (ADD32rm GR32:$src1, addr:$src2)>;
4765
Dan Gohman076aee32009-03-04 19:44:21 +00004766// Register-Integer Addition with EFLAGS result
4767def : Pat<(parallel (X86add_flag GR8:$src1, imm:$src2),
Bill Wendlingd350e022008-12-12 21:15:41 +00004768 (implicit EFLAGS)),
4769 (ADD8ri GR8:$src1, imm:$src2)>;
Dan Gohman076aee32009-03-04 19:44:21 +00004770def : Pat<(parallel (X86add_flag GR16:$src1, imm:$src2),
Bill Wendlingd350e022008-12-12 21:15:41 +00004771 (implicit EFLAGS)),
4772 (ADD16ri GR16:$src1, imm:$src2)>;
Dan Gohman076aee32009-03-04 19:44:21 +00004773def : Pat<(parallel (X86add_flag GR32:$src1, imm:$src2),
Bill Wendlingd350e022008-12-12 21:15:41 +00004774 (implicit EFLAGS)),
4775 (ADD32ri GR32:$src1, imm:$src2)>;
Dan Gohman076aee32009-03-04 19:44:21 +00004776def : Pat<(parallel (X86add_flag GR16:$src1, i16immSExt8:$src2),
Bill Wendlingd350e022008-12-12 21:15:41 +00004777 (implicit EFLAGS)),
4778 (ADD16ri8 GR16:$src1, i16immSExt8:$src2)>;
Dan Gohman076aee32009-03-04 19:44:21 +00004779def : Pat<(parallel (X86add_flag GR32:$src1, i32immSExt8:$src2),
Bill Wendlingd350e022008-12-12 21:15:41 +00004780 (implicit EFLAGS)),
4781 (ADD32ri8 GR32:$src1, i32immSExt8:$src2)>;
4782
Dan Gohman076aee32009-03-04 19:44:21 +00004783// Register-Register Subtraction with EFLAGS result
4784def : Pat<(parallel (X86sub_flag GR8:$src1, GR8:$src2),
Bill Wendlingd350e022008-12-12 21:15:41 +00004785 (implicit EFLAGS)),
4786 (SUB8rr GR8:$src1, GR8:$src2)>;
Dan Gohman076aee32009-03-04 19:44:21 +00004787def : Pat<(parallel (X86sub_flag GR16:$src1, GR16:$src2),
Bill Wendlingd350e022008-12-12 21:15:41 +00004788 (implicit EFLAGS)),
4789 (SUB16rr GR16:$src1, GR16:$src2)>;
Dan Gohman076aee32009-03-04 19:44:21 +00004790def : Pat<(parallel (X86sub_flag GR32:$src1, GR32:$src2),
Bill Wendlingd350e022008-12-12 21:15:41 +00004791 (implicit EFLAGS)),
4792 (SUB32rr GR32:$src1, GR32:$src2)>;
4793
Dan Gohman076aee32009-03-04 19:44:21 +00004794// Register-Memory Subtraction with EFLAGS result
4795def : Pat<(parallel (X86sub_flag GR8:$src1, (loadi8 addr:$src2)),
Bill Wendlingd350e022008-12-12 21:15:41 +00004796 (implicit EFLAGS)),
4797 (SUB8rm GR8:$src1, addr:$src2)>;
Dan Gohman076aee32009-03-04 19:44:21 +00004798def : Pat<(parallel (X86sub_flag GR16:$src1, (loadi16 addr:$src2)),
Bill Wendlingd350e022008-12-12 21:15:41 +00004799 (implicit EFLAGS)),
4800 (SUB16rm GR16:$src1, addr:$src2)>;
Dan Gohman076aee32009-03-04 19:44:21 +00004801def : Pat<(parallel (X86sub_flag GR32:$src1, (loadi32 addr:$src2)),
Bill Wendlingd350e022008-12-12 21:15:41 +00004802 (implicit EFLAGS)),
4803 (SUB32rm GR32:$src1, addr:$src2)>;
4804
Dan Gohman076aee32009-03-04 19:44:21 +00004805// Register-Integer Subtraction with EFLAGS result
4806def : Pat<(parallel (X86sub_flag GR8:$src1, imm:$src2),
Bill Wendlingd350e022008-12-12 21:15:41 +00004807 (implicit EFLAGS)),
4808 (SUB8ri GR8:$src1, imm:$src2)>;
Dan Gohman076aee32009-03-04 19:44:21 +00004809def : Pat<(parallel (X86sub_flag GR16:$src1, imm:$src2),
Bill Wendlingd350e022008-12-12 21:15:41 +00004810 (implicit EFLAGS)),
4811 (SUB16ri GR16:$src1, imm:$src2)>;
Dan Gohman076aee32009-03-04 19:44:21 +00004812def : Pat<(parallel (X86sub_flag GR32:$src1, imm:$src2),
Bill Wendlingd350e022008-12-12 21:15:41 +00004813 (implicit EFLAGS)),
4814 (SUB32ri GR32:$src1, imm:$src2)>;
Dan Gohman076aee32009-03-04 19:44:21 +00004815def : Pat<(parallel (X86sub_flag GR16:$src1, i16immSExt8:$src2),
Bill Wendlingd350e022008-12-12 21:15:41 +00004816 (implicit EFLAGS)),
4817 (SUB16ri8 GR16:$src1, i16immSExt8:$src2)>;
Dan Gohman076aee32009-03-04 19:44:21 +00004818def : Pat<(parallel (X86sub_flag GR32:$src1, i32immSExt8:$src2),
Bill Wendlingd350e022008-12-12 21:15:41 +00004819 (implicit EFLAGS)),
4820 (SUB32ri8 GR32:$src1, i32immSExt8:$src2)>;
4821
Dan Gohman076aee32009-03-04 19:44:21 +00004822// Register-Register Signed Integer Multiply with EFLAGS result
4823def : Pat<(parallel (X86smul_flag GR16:$src1, GR16:$src2),
Bill Wendlingd350e022008-12-12 21:15:41 +00004824 (implicit EFLAGS)),
4825 (IMUL16rr GR16:$src1, GR16:$src2)>;
Dan Gohman076aee32009-03-04 19:44:21 +00004826def : Pat<(parallel (X86smul_flag GR32:$src1, GR32:$src2),
Bill Wendlingd350e022008-12-12 21:15:41 +00004827 (implicit EFLAGS)),
4828 (IMUL32rr GR32:$src1, GR32:$src2)>;
4829
Dan Gohman076aee32009-03-04 19:44:21 +00004830// Register-Memory Signed Integer Multiply with EFLAGS result
4831def : Pat<(parallel (X86smul_flag GR16:$src1, (loadi16 addr:$src2)),
Bill Wendlingd350e022008-12-12 21:15:41 +00004832 (implicit EFLAGS)),
4833 (IMUL16rm GR16:$src1, addr:$src2)>;
Dan Gohman076aee32009-03-04 19:44:21 +00004834def : Pat<(parallel (X86smul_flag GR32:$src1, (loadi32 addr:$src2)),
Bill Wendlingd350e022008-12-12 21:15:41 +00004835 (implicit EFLAGS)),
4836 (IMUL32rm GR32:$src1, addr:$src2)>;
4837
Dan Gohman076aee32009-03-04 19:44:21 +00004838// Register-Integer Signed Integer Multiply with EFLAGS result
4839def : Pat<(parallel (X86smul_flag GR16:$src1, imm:$src2),
Bill Wendlingd350e022008-12-12 21:15:41 +00004840 (implicit EFLAGS)),
4841 (IMUL16rri GR16:$src1, imm:$src2)>;
Dan Gohman076aee32009-03-04 19:44:21 +00004842def : Pat<(parallel (X86smul_flag GR32:$src1, imm:$src2),
Bill Wendlingd350e022008-12-12 21:15:41 +00004843 (implicit EFLAGS)),
4844 (IMUL32rri GR32:$src1, imm:$src2)>;
Dan Gohman076aee32009-03-04 19:44:21 +00004845def : Pat<(parallel (X86smul_flag GR16:$src1, i16immSExt8:$src2),
Bill Wendlingd350e022008-12-12 21:15:41 +00004846 (implicit EFLAGS)),
4847 (IMUL16rri8 GR16:$src1, i16immSExt8:$src2)>;
Dan Gohman076aee32009-03-04 19:44:21 +00004848def : Pat<(parallel (X86smul_flag GR32:$src1, i32immSExt8:$src2),
Bill Wendlingd350e022008-12-12 21:15:41 +00004849 (implicit EFLAGS)),
4850 (IMUL32rri8 GR32:$src1, i32immSExt8:$src2)>;
4851
Dan Gohman076aee32009-03-04 19:44:21 +00004852// Memory-Integer Signed Integer Multiply with EFLAGS result
4853def : Pat<(parallel (X86smul_flag (loadi16 addr:$src1), imm:$src2),
Bill Wendlingd350e022008-12-12 21:15:41 +00004854 (implicit EFLAGS)),
4855 (IMUL16rmi addr:$src1, imm:$src2)>;
Dan Gohman076aee32009-03-04 19:44:21 +00004856def : Pat<(parallel (X86smul_flag (loadi32 addr:$src1), imm:$src2),
Bill Wendlingd350e022008-12-12 21:15:41 +00004857 (implicit EFLAGS)),
4858 (IMUL32rmi addr:$src1, imm:$src2)>;
Dan Gohman076aee32009-03-04 19:44:21 +00004859def : Pat<(parallel (X86smul_flag (loadi16 addr:$src1), i16immSExt8:$src2),
Bill Wendlingd350e022008-12-12 21:15:41 +00004860 (implicit EFLAGS)),
4861 (IMUL16rmi8 addr:$src1, i16immSExt8:$src2)>;
Dan Gohman076aee32009-03-04 19:44:21 +00004862def : Pat<(parallel (X86smul_flag (loadi32 addr:$src1), i32immSExt8:$src2),
Bill Wendlingd350e022008-12-12 21:15:41 +00004863 (implicit EFLAGS)),
4864 (IMUL32rmi8 addr:$src1, i32immSExt8:$src2)>;
4865
Dan Gohman076aee32009-03-04 19:44:21 +00004866// Optimize multiply by 2 with EFLAGS result.
Evan Cheng6a86bd72009-01-27 03:30:42 +00004867let AddedComplexity = 2 in {
Dan Gohman076aee32009-03-04 19:44:21 +00004868def : Pat<(parallel (X86smul_flag GR16:$src1, 2),
Evan Cheng6a86bd72009-01-27 03:30:42 +00004869 (implicit EFLAGS)),
4870 (ADD16rr GR16:$src1, GR16:$src1)>;
4871
Dan Gohman076aee32009-03-04 19:44:21 +00004872def : Pat<(parallel (X86smul_flag GR32:$src1, 2),
Evan Cheng6a86bd72009-01-27 03:30:42 +00004873 (implicit EFLAGS)),
4874 (ADD32rr GR32:$src1, GR32:$src1)>;
4875}
4876
Dan Gohman076aee32009-03-04 19:44:21 +00004877// INC and DEC with EFLAGS result. Note that these do not set CF.
Chris Lattnerc54a2f12010-03-24 01:02:12 +00004878def : Pat<(add GR8:$src, 1), (INC8r GR8:$src)>;
4879
Dan Gohman076aee32009-03-04 19:44:21 +00004880def : Pat<(parallel (X86dec_flag GR8:$src), (implicit EFLAGS)),
4881 (DEC8r GR8:$src)>;
Dan Gohman076aee32009-03-04 19:44:21 +00004882
4883def : Pat<(parallel (X86inc_flag GR16:$src), (implicit EFLAGS)),
Dan Gohman1f4af262009-03-05 21:32:23 +00004884 (INC16r GR16:$src)>, Requires<[In32BitMode]>;
Dan Gohman076aee32009-03-04 19:44:21 +00004885def : Pat<(parallel (X86dec_flag GR16:$src), (implicit EFLAGS)),
Dan Gohman1f4af262009-03-05 21:32:23 +00004886 (DEC16r GR16:$src)>, Requires<[In32BitMode]>;
Dan Gohman076aee32009-03-04 19:44:21 +00004887
4888def : Pat<(parallel (X86inc_flag GR32:$src), (implicit EFLAGS)),
Dan Gohman1f4af262009-03-05 21:32:23 +00004889 (INC32r GR32:$src)>, Requires<[In32BitMode]>;
Dan Gohman076aee32009-03-04 19:44:21 +00004890def : Pat<(parallel (X86dec_flag GR32:$src), (implicit EFLAGS)),
Dan Gohman1f4af262009-03-05 21:32:23 +00004891 (DEC32r GR32:$src)>, Requires<[In32BitMode]>;
Dan Gohman076aee32009-03-04 19:44:21 +00004892
Dan Gohmane220c4b2009-09-18 19:59:53 +00004893// Register-Register Or with EFLAGS result
4894def : Pat<(parallel (X86or_flag GR8:$src1, GR8:$src2),
4895 (implicit EFLAGS)),
4896 (OR8rr GR8:$src1, GR8:$src2)>;
4897def : Pat<(parallel (X86or_flag GR16:$src1, GR16:$src2),
4898 (implicit EFLAGS)),
4899 (OR16rr GR16:$src1, GR16:$src2)>;
4900def : Pat<(parallel (X86or_flag GR32:$src1, GR32:$src2),
4901 (implicit EFLAGS)),
4902 (OR32rr GR32:$src1, GR32:$src2)>;
4903
4904// Register-Memory Or with EFLAGS result
4905def : Pat<(parallel (X86or_flag GR8:$src1, (loadi8 addr:$src2)),
4906 (implicit EFLAGS)),
4907 (OR8rm GR8:$src1, addr:$src2)>;
4908def : Pat<(parallel (X86or_flag GR16:$src1, (loadi16 addr:$src2)),
4909 (implicit EFLAGS)),
4910 (OR16rm GR16:$src1, addr:$src2)>;
4911def : Pat<(parallel (X86or_flag GR32:$src1, (loadi32 addr:$src2)),
4912 (implicit EFLAGS)),
4913 (OR32rm GR32:$src1, addr:$src2)>;
4914
4915// Register-Integer Or with EFLAGS result
4916def : Pat<(parallel (X86or_flag GR8:$src1, imm:$src2),
4917 (implicit EFLAGS)),
4918 (OR8ri GR8:$src1, imm:$src2)>;
4919def : Pat<(parallel (X86or_flag GR16:$src1, imm:$src2),
4920 (implicit EFLAGS)),
4921 (OR16ri GR16:$src1, imm:$src2)>;
4922def : Pat<(parallel (X86or_flag GR32:$src1, imm:$src2),
4923 (implicit EFLAGS)),
4924 (OR32ri GR32:$src1, imm:$src2)>;
4925def : Pat<(parallel (X86or_flag GR16:$src1, i16immSExt8:$src2),
4926 (implicit EFLAGS)),
4927 (OR16ri8 GR16:$src1, i16immSExt8:$src2)>;
4928def : Pat<(parallel (X86or_flag GR32:$src1, i32immSExt8:$src2),
4929 (implicit EFLAGS)),
4930 (OR32ri8 GR32:$src1, i32immSExt8:$src2)>;
Dan Gohmane220c4b2009-09-18 19:59:53 +00004931
4932// Register-Register XOr with EFLAGS result
4933def : Pat<(parallel (X86xor_flag GR8:$src1, GR8:$src2),
4934 (implicit EFLAGS)),
4935 (XOR8rr GR8:$src1, GR8:$src2)>;
4936def : Pat<(parallel (X86xor_flag GR16:$src1, GR16:$src2),
4937 (implicit EFLAGS)),
4938 (XOR16rr GR16:$src1, GR16:$src2)>;
4939def : Pat<(parallel (X86xor_flag GR32:$src1, GR32:$src2),
4940 (implicit EFLAGS)),
4941 (XOR32rr GR32:$src1, GR32:$src2)>;
4942
4943// Register-Memory XOr with EFLAGS result
4944def : Pat<(parallel (X86xor_flag GR8:$src1, (loadi8 addr:$src2)),
4945 (implicit EFLAGS)),
4946 (XOR8rm GR8:$src1, addr:$src2)>;
4947def : Pat<(parallel (X86xor_flag GR16:$src1, (loadi16 addr:$src2)),
4948 (implicit EFLAGS)),
4949 (XOR16rm GR16:$src1, addr:$src2)>;
4950def : Pat<(parallel (X86xor_flag GR32:$src1, (loadi32 addr:$src2)),
4951 (implicit EFLAGS)),
4952 (XOR32rm GR32:$src1, addr:$src2)>;
4953
4954// Register-Integer XOr with EFLAGS result
4955def : Pat<(parallel (X86xor_flag GR8:$src1, imm:$src2),
4956 (implicit EFLAGS)),
4957 (XOR8ri GR8:$src1, imm:$src2)>;
4958def : Pat<(parallel (X86xor_flag GR16:$src1, imm:$src2),
4959 (implicit EFLAGS)),
4960 (XOR16ri GR16:$src1, imm:$src2)>;
4961def : Pat<(parallel (X86xor_flag GR32:$src1, imm:$src2),
4962 (implicit EFLAGS)),
4963 (XOR32ri GR32:$src1, imm:$src2)>;
4964def : Pat<(parallel (X86xor_flag GR16:$src1, i16immSExt8:$src2),
4965 (implicit EFLAGS)),
4966 (XOR16ri8 GR16:$src1, i16immSExt8:$src2)>;
4967def : Pat<(parallel (X86xor_flag GR32:$src1, i32immSExt8:$src2),
4968 (implicit EFLAGS)),
4969 (XOR32ri8 GR32:$src1, i32immSExt8:$src2)>;
4970
Dan Gohmane220c4b2009-09-18 19:59:53 +00004971// Register-Register And with EFLAGS result
4972def : Pat<(parallel (X86and_flag GR8:$src1, GR8:$src2),
4973 (implicit EFLAGS)),
4974 (AND8rr GR8:$src1, GR8:$src2)>;
4975def : Pat<(parallel (X86and_flag GR16:$src1, GR16:$src2),
4976 (implicit EFLAGS)),
4977 (AND16rr GR16:$src1, GR16:$src2)>;
4978def : Pat<(parallel (X86and_flag GR32:$src1, GR32:$src2),
4979 (implicit EFLAGS)),
4980 (AND32rr GR32:$src1, GR32:$src2)>;
4981
4982// Register-Memory And with EFLAGS result
4983def : Pat<(parallel (X86and_flag GR8:$src1, (loadi8 addr:$src2)),
4984 (implicit EFLAGS)),
4985 (AND8rm GR8:$src1, addr:$src2)>;
4986def : Pat<(parallel (X86and_flag GR16:$src1, (loadi16 addr:$src2)),
4987 (implicit EFLAGS)),
4988 (AND16rm GR16:$src1, addr:$src2)>;
4989def : Pat<(parallel (X86and_flag GR32:$src1, (loadi32 addr:$src2)),
4990 (implicit EFLAGS)),
4991 (AND32rm GR32:$src1, addr:$src2)>;
4992
4993// Register-Integer And with EFLAGS result
4994def : Pat<(parallel (X86and_flag GR8:$src1, imm:$src2),
4995 (implicit EFLAGS)),
4996 (AND8ri GR8:$src1, imm:$src2)>;
4997def : Pat<(parallel (X86and_flag GR16:$src1, imm:$src2),
4998 (implicit EFLAGS)),
4999 (AND16ri GR16:$src1, imm:$src2)>;
5000def : Pat<(parallel (X86and_flag GR32:$src1, imm:$src2),
5001 (implicit EFLAGS)),
5002 (AND32ri GR32:$src1, imm:$src2)>;
5003def : Pat<(parallel (X86and_flag GR16:$src1, i16immSExt8:$src2),
5004 (implicit EFLAGS)),
5005 (AND16ri8 GR16:$src1, i16immSExt8:$src2)>;
5006def : Pat<(parallel (X86and_flag GR32:$src1, i32immSExt8:$src2),
5007 (implicit EFLAGS)),
5008 (AND32ri8 GR32:$src1, i32immSExt8:$src2)>;
5009
Dan Gohman2f67df72009-09-03 17:18:51 +00005010// -disable-16bit support.
Chris Lattner341b2742010-03-08 18:55:15 +00005011def : Pat<(truncstorei16 (i16 imm:$src), addr:$dst),
Dan Gohman2f67df72009-09-03 17:18:51 +00005012 (MOV16mi addr:$dst, imm:$src)>;
5013def : Pat<(truncstorei16 GR32:$src, addr:$dst),
5014 (MOV16mr addr:$dst, (EXTRACT_SUBREG GR32:$src, x86_subreg_16bit))>;
5015def : Pat<(i32 (sextloadi16 addr:$dst)),
5016 (MOVSX32rm16 addr:$dst)>;
5017def : Pat<(i32 (zextloadi16 addr:$dst)),
5018 (MOVZX32rm16 addr:$dst)>;
5019def : Pat<(i32 (extloadi16 addr:$dst)),
5020 (MOVZX32rm16 addr:$dst)>;
5021
Bill Wendlingd350e022008-12-12 21:15:41 +00005022//===----------------------------------------------------------------------===//
Evan Cheng4e4c71e2006-02-21 20:00:20 +00005023// Floating Point Stack Support
5024//===----------------------------------------------------------------------===//
5025
5026include "X86InstrFPStack.td"
5027
5028//===----------------------------------------------------------------------===//
Evan Chengc64a1a92007-07-31 08:04:03 +00005029// X86-64 Support
5030//===----------------------------------------------------------------------===//
5031
Chris Lattner36fe6d22008-01-10 05:50:42 +00005032include "X86Instr64bit.td"
Evan Chengc64a1a92007-07-31 08:04:03 +00005033
5034//===----------------------------------------------------------------------===//
David Greene51898d72010-02-09 23:52:19 +00005035// SIMD support (SSE, MMX and AVX)
5036//===----------------------------------------------------------------------===//
5037
5038include "X86InstrFragmentsSIMD.td"
5039
5040//===----------------------------------------------------------------------===//
Evan Cheng4e4c71e2006-02-21 20:00:20 +00005041// XMM Floating point support (requires SSE / SSE2)
5042//===----------------------------------------------------------------------===//
5043
5044include "X86InstrSSE.td"
Evan Cheng80f54042008-04-25 18:19:54 +00005045
5046//===----------------------------------------------------------------------===//
5047// MMX and XMM Packed Integer support (requires MMX, SSE, and SSE2)
5048//===----------------------------------------------------------------------===//
5049
5050include "X86InstrMMX.td"