blob: 6e73766c8cc18931b5dfd6aa09afd1f85cc8a7fe [file] [log] [blame]
Chris Lattner589ad5d2010-03-25 05:44:01 +00001//===----------------------------------------------------------------------===//
John Criswell856ba762003-10-21 15:17:13 +00002//
3// The LLVM Compiler Infrastructure
4//
Chris Lattner4ee451d2007-12-29 20:36:04 +00005// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
John Criswell856ba762003-10-21 15:17:13 +00007//
8//===----------------------------------------------------------------------===//
Chris Lattner1cca5e32003-08-03 21:54:21 +00009//
10// This file describes the X86 instruction set, defining the instructions, and
11// properties of the instructions which are needed for code generation, machine
12// code emission, and analysis.
13//
14//===----------------------------------------------------------------------===//
15
Evan Chengaed7c722005-12-17 01:24:02 +000016//===----------------------------------------------------------------------===//
17// X86 specific DAG Nodes.
18//
19
Evan Chenge3413162006-01-09 18:33:28 +000020def SDTIntShiftDOp: SDTypeProfile<1, 3,
21 [SDTCisSameAs<0, 1>, SDTCisSameAs<0, 2>,
22 SDTCisInt<0>, SDTCisInt<3>]>;
23
Chris Lattnere3486a42010-03-19 00:01:11 +000024def SDTX86CmpTest : SDTypeProfile<1, 2, [SDTCisVT<0, i32>, SDTCisSameAs<1, 2>]>;
Evan Chengaed7c722005-12-17 01:24:02 +000025
Evan Chenge5f62042007-09-29 00:00:36 +000026def SDTX86Cmov : SDTypeProfile<1, 4,
Evan Cheng0488db92007-09-25 01:57:46 +000027 [SDTCisSameAs<0, 1>, SDTCisSameAs<1, 2>,
28 SDTCisVT<3, i8>, SDTCisVT<4, i32>]>;
Evan Chengaed7c722005-12-17 01:24:02 +000029
Dan Gohman076aee32009-03-04 19:44:21 +000030// Unary and binary operator instructions that set EFLAGS as a side-effect.
Chris Lattner74c8d672010-03-24 00:47:47 +000031def SDTUnaryArithWithFlags : SDTypeProfile<2, 1,
32 [SDTCisInt<0>, SDTCisVT<1, i32>]>;
33
Chris Lattner1aec4d72010-03-24 00:49:29 +000034def SDTBinaryArithWithFlags : SDTypeProfile<2, 2,
35 [SDTCisSameAs<0, 2>,
36 SDTCisSameAs<0, 3>,
37 SDTCisInt<0>, SDTCisVT<1, i32>]>;
Evan Chenge5f62042007-09-29 00:00:36 +000038def SDTX86BrCond : SDTypeProfile<0, 3,
Evan Cheng0488db92007-09-25 01:57:46 +000039 [SDTCisVT<0, OtherVT>,
40 SDTCisVT<1, i8>, SDTCisVT<2, i32>]>;
Evan Chengaed7c722005-12-17 01:24:02 +000041
Evan Chenge5f62042007-09-29 00:00:36 +000042def SDTX86SetCC : SDTypeProfile<1, 2,
Evan Cheng0488db92007-09-25 01:57:46 +000043 [SDTCisVT<0, i8>,
44 SDTCisVT<1, i8>, SDTCisVT<2, i32>]>;
Evan Cheng2e489c42009-12-16 00:53:11 +000045def SDTX86SetCC_C : SDTypeProfile<1, 2,
46 [SDTCisInt<0>,
47 SDTCisVT<1, i8>, SDTCisVT<2, i32>]>;
Evan Chengd5781fc2005-12-21 20:21:51 +000048
Andrew Lenharth26ed8692008-03-01 21:52:34 +000049def SDTX86cas : SDTypeProfile<0, 3, [SDTCisPtrTy<0>, SDTCisInt<1>,
50 SDTCisVT<2, i8>]>;
Andrew Lenharthd19189e2008-03-05 01:15:49 +000051def SDTX86cas8 : SDTypeProfile<0, 1, [SDTCisPtrTy<0>]>;
Andrew Lenharth26ed8692008-03-01 21:52:34 +000052
Dale Johannesen48c1bc22008-10-02 18:53:47 +000053def SDTX86atomicBinary : SDTypeProfile<2, 3, [SDTCisInt<0>, SDTCisInt<1>,
54 SDTCisPtrTy<2>, SDTCisInt<3>,SDTCisInt<4>]>;
Chris Lattner447ff682008-03-11 03:23:40 +000055def SDTX86Ret : SDTypeProfile<0, -1, [SDTCisVT<0, i16>]>;
Evan Cheng898101c2005-12-19 23:12:38 +000056
Sean Callanan1c97ceb2009-06-23 23:25:37 +000057def SDT_X86CallSeqStart : SDCallSeqStart<[SDTCisVT<0, i32>]>;
58def SDT_X86CallSeqEnd : SDCallSeqEnd<[SDTCisVT<0, i32>,
59 SDTCisVT<1, i32>]>;
Evan Chenge3413162006-01-09 18:33:28 +000060
Dan Gohmand35121a2008-05-29 19:57:41 +000061def SDT_X86Call : SDTypeProfile<0, -1, [SDTCisVT<0, iPTR>]>;
Evan Chenge3413162006-01-09 18:33:28 +000062
Dan Gohmand6708ea2009-08-15 01:38:56 +000063def SDT_X86VASTART_SAVE_XMM_REGS : SDTypeProfile<0, -1, [SDTCisVT<0, i8>,
64 SDTCisVT<1, iPTR>,
65 SDTCisVT<2, iPTR>]>;
66
Chris Lattnered52c8f2010-03-28 07:38:39 +000067def SDTX86RepStr : SDTypeProfile<0, 1, [SDTCisVT<0, OtherVT>]>;
68
Anton Korobeynikov043f3c22010-03-06 19:32:29 +000069def SDTX86Void : SDTypeProfile<0, 0, []>;
Evan Chengd90eb7f2006-01-05 00:27:02 +000070
Evan Cheng71fb8342006-02-25 10:02:21 +000071def SDTX86Wrapper : SDTypeProfile<1, 1, [SDTCisSameAs<0, 1>, SDTCisPtrTy<0>]>;
72
Rafael Espindola2ee3db32009-04-17 14:35:58 +000073def SDT_X86TLSADDR : SDTypeProfile<0, 1, [SDTCisInt<0>]>;
Lauro Ramos Venanciob3a04172007-04-20 21:38:10 +000074
Rafael Espindola094fad32009-04-08 21:14:34 +000075def SDT_X86SegmentBaseAddress : SDTypeProfile<1, 1, [SDTCisPtrTy<0>]>;
Lauro Ramos Venanciob3a04172007-04-20 21:38:10 +000076
Anton Korobeynikov2365f512007-07-14 14:06:15 +000077def SDT_X86EHRET : SDTypeProfile<0, 1, [SDTCisInt<0>]>;
78
Arnold Schwaighoferc85e1712007-10-11 19:40:01 +000079def SDT_X86TCRET : SDTypeProfile<0, 2, [SDTCisPtrTy<0>, SDTCisVT<1, i32>]>;
80
Chris Lattnerd486d772010-03-28 05:07:17 +000081def X86bsf : SDNode<"X86ISD::BSF", SDTUnaryArithWithFlags>;
82def X86bsr : SDNode<"X86ISD::BSR", SDTUnaryArithWithFlags>;
Evan Chenge3413162006-01-09 18:33:28 +000083def X86shld : SDNode<"X86ISD::SHLD", SDTIntShiftDOp>;
84def X86shrd : SDNode<"X86ISD::SHRD", SDTIntShiftDOp>;
Evan Chengb077b842005-12-21 02:39:21 +000085
Evan Chenge5f62042007-09-29 00:00:36 +000086def X86cmp : SDNode<"X86ISD::CMP" , SDTX86CmpTest>;
Dan Gohmanc7a37d42008-12-23 22:45:23 +000087def X86bt : SDNode<"X86ISD::BT", SDTX86CmpTest>;
88
Evan Chenge5f62042007-09-29 00:00:36 +000089def X86cmov : SDNode<"X86ISD::CMOV", SDTX86Cmov>;
Evan Chenge3413162006-01-09 18:33:28 +000090def X86brcond : SDNode<"X86ISD::BRCOND", SDTX86BrCond,
Evan Cheng0488db92007-09-25 01:57:46 +000091 [SDNPHasChain]>;
Evan Chenge5f62042007-09-29 00:00:36 +000092def X86setcc : SDNode<"X86ISD::SETCC", SDTX86SetCC>;
Evan Cheng2e489c42009-12-16 00:53:11 +000093def X86setcc_c : SDNode<"X86ISD::SETCC_CARRY", SDTX86SetCC_C>;
Evan Chengb077b842005-12-21 02:39:21 +000094
Andrew Lenharth26ed8692008-03-01 21:52:34 +000095def X86cas : SDNode<"X86ISD::LCMPXCHG_DAG", SDTX86cas,
96 [SDNPHasChain, SDNPInFlag, SDNPOutFlag, SDNPMayStore,
97 SDNPMayLoad]>;
Andrew Lenharthd19189e2008-03-05 01:15:49 +000098def X86cas8 : SDNode<"X86ISD::LCMPXCHG8_DAG", SDTX86cas8,
99 [SDNPHasChain, SDNPInFlag, SDNPOutFlag, SDNPMayStore,
100 SDNPMayLoad]>;
Dale Johannesen48c1bc22008-10-02 18:53:47 +0000101def X86AtomAdd64 : SDNode<"X86ISD::ATOMADD64_DAG", SDTX86atomicBinary,
102 [SDNPHasChain, SDNPMayStore,
103 SDNPMayLoad, SDNPMemOperand]>;
104def X86AtomSub64 : SDNode<"X86ISD::ATOMSUB64_DAG", SDTX86atomicBinary,
105 [SDNPHasChain, SDNPMayStore,
106 SDNPMayLoad, SDNPMemOperand]>;
107def X86AtomOr64 : SDNode<"X86ISD::ATOMOR64_DAG", SDTX86atomicBinary,
108 [SDNPHasChain, SDNPMayStore,
109 SDNPMayLoad, SDNPMemOperand]>;
110def X86AtomXor64 : SDNode<"X86ISD::ATOMXOR64_DAG", SDTX86atomicBinary,
111 [SDNPHasChain, SDNPMayStore,
112 SDNPMayLoad, SDNPMemOperand]>;
113def X86AtomAnd64 : SDNode<"X86ISD::ATOMAND64_DAG", SDTX86atomicBinary,
114 [SDNPHasChain, SDNPMayStore,
115 SDNPMayLoad, SDNPMemOperand]>;
116def X86AtomNand64 : SDNode<"X86ISD::ATOMNAND64_DAG", SDTX86atomicBinary,
117 [SDNPHasChain, SDNPMayStore,
118 SDNPMayLoad, SDNPMemOperand]>;
Dale Johannesen880ae362008-10-03 22:25:52 +0000119def X86AtomSwap64 : SDNode<"X86ISD::ATOMSWAP64_DAG", SDTX86atomicBinary,
120 [SDNPHasChain, SDNPMayStore,
121 SDNPMayLoad, SDNPMemOperand]>;
Evan Chenge3413162006-01-09 18:33:28 +0000122def X86retflag : SDNode<"X86ISD::RET_FLAG", SDTX86Ret,
Chris Lattnere8cabf32010-03-19 05:07:09 +0000123 [SDNPHasChain, SDNPOptInFlag, SDNPVariadic]>;
Evan Chengb077b842005-12-21 02:39:21 +0000124
Dan Gohmand6708ea2009-08-15 01:38:56 +0000125def X86vastart_save_xmm_regs :
126 SDNode<"X86ISD::VASTART_SAVE_XMM_REGS",
127 SDT_X86VASTART_SAVE_XMM_REGS,
Chris Lattnere8cabf32010-03-19 05:07:09 +0000128 [SDNPHasChain, SDNPVariadic]>;
Dan Gohmand6708ea2009-08-15 01:38:56 +0000129
Evan Chenge3413162006-01-09 18:33:28 +0000130def X86callseq_start :
131 SDNode<"ISD::CALLSEQ_START", SDT_X86CallSeqStart,
Evan Chengbb7b8442006-08-11 09:03:33 +0000132 [SDNPHasChain, SDNPOutFlag]>;
Evan Chenge3413162006-01-09 18:33:28 +0000133def X86callseq_end :
134 SDNode<"ISD::CALLSEQ_END", SDT_X86CallSeqEnd,
Arnold Schwaighoferc85e1712007-10-11 19:40:01 +0000135 [SDNPHasChain, SDNPOptInFlag, SDNPOutFlag]>;
Evan Chengb077b842005-12-21 02:39:21 +0000136
Evan Chenge3413162006-01-09 18:33:28 +0000137def X86call : SDNode<"X86ISD::CALL", SDT_X86Call,
Chris Lattnere8cabf32010-03-19 05:07:09 +0000138 [SDNPHasChain, SDNPOutFlag, SDNPOptInFlag,
139 SDNPVariadic]>;
Evan Chengaed7c722005-12-17 01:24:02 +0000140
Chris Lattnered52c8f2010-03-28 07:38:39 +0000141def X86rep_stos: SDNode<"X86ISD::REP_STOS", SDTX86RepStr,
Chris Lattner9b37aaf2008-01-10 05:12:37 +0000142 [SDNPHasChain, SDNPInFlag, SDNPOutFlag, SDNPMayStore]>;
Chris Lattnered52c8f2010-03-28 07:38:39 +0000143def X86rep_movs: SDNode<"X86ISD::REP_MOVS", SDTX86RepStr,
Chris Lattner9b37aaf2008-01-10 05:12:37 +0000144 [SDNPHasChain, SDNPInFlag, SDNPOutFlag, SDNPMayStore,
145 SDNPMayLoad]>;
Evan Cheng67f92a72006-01-11 22:15:48 +0000146
Anton Korobeynikov043f3c22010-03-06 19:32:29 +0000147def X86rdtsc : SDNode<"X86ISD::RDTSC_DAG", SDTX86Void,
Chris Lattnerba7e7562008-01-10 07:59:24 +0000148 [SDNPHasChain, SDNPOutFlag, SDNPSideEffect]>;
Evan Chengd90eb7f2006-01-05 00:27:02 +0000149
Evan Cheng0085a282006-11-30 21:55:46 +0000150def X86Wrapper : SDNode<"X86ISD::Wrapper", SDTX86Wrapper>;
151def X86WrapperRIP : SDNode<"X86ISD::WrapperRIP", SDTX86Wrapper>;
Evan Cheng71fb8342006-02-25 10:02:21 +0000152
Lauro Ramos Venanciob3a04172007-04-20 21:38:10 +0000153def X86tlsaddr : SDNode<"X86ISD::TLSADDR", SDT_X86TLSADDR,
Anton Korobeynikov6625eff2008-05-04 21:36:32 +0000154 [SDNPHasChain, SDNPOptInFlag, SDNPOutFlag]>;
Rafael Espindola094fad32009-04-08 21:14:34 +0000155def X86SegmentBaseAddress : SDNode<"X86ISD::SegmentBaseAddress",
156 SDT_X86SegmentBaseAddress, []>;
Lauro Ramos Venanciob3a04172007-04-20 21:38:10 +0000157
Anton Korobeynikov2365f512007-07-14 14:06:15 +0000158def X86ehret : SDNode<"X86ISD::EH_RETURN", SDT_X86EHRET,
159 [SDNPHasChain]>;
160
Arnold Schwaighoferc85e1712007-10-11 19:40:01 +0000161def X86tcret : SDNode<"X86ISD::TC_RETURN", SDT_X86TCRET,
Chris Lattnere8cabf32010-03-19 05:07:09 +0000162 [SDNPHasChain, SDNPOptInFlag, SDNPVariadic]>;
Lauro Ramos Venanciob3a04172007-04-20 21:38:10 +0000163
Dan Gohman43ffe672010-01-04 20:51:05 +0000164def X86add_flag : SDNode<"X86ISD::ADD", SDTBinaryArithWithFlags,
Dan Gohman4361bbf2010-01-05 00:44:20 +0000165 [SDNPCommutative]>;
Dan Gohman076aee32009-03-04 19:44:21 +0000166def X86sub_flag : SDNode<"X86ISD::SUB", SDTBinaryArithWithFlags>;
Dan Gohman43ffe672010-01-04 20:51:05 +0000167def X86smul_flag : SDNode<"X86ISD::SMUL", SDTBinaryArithWithFlags,
Dan Gohman4361bbf2010-01-05 00:44:20 +0000168 [SDNPCommutative]>;
Dan Gohman43ffe672010-01-04 20:51:05 +0000169def X86umul_flag : SDNode<"X86ISD::UMUL", SDTUnaryArithWithFlags,
Dan Gohman4361bbf2010-01-05 00:44:20 +0000170 [SDNPCommutative]>;
Chris Lattner74c8d672010-03-24 00:47:47 +0000171
Dan Gohman076aee32009-03-04 19:44:21 +0000172def X86inc_flag : SDNode<"X86ISD::INC", SDTUnaryArithWithFlags>;
173def X86dec_flag : SDNode<"X86ISD::DEC", SDTUnaryArithWithFlags>;
Dan Gohman43ffe672010-01-04 20:51:05 +0000174def X86or_flag : SDNode<"X86ISD::OR", SDTBinaryArithWithFlags,
Dan Gohman4361bbf2010-01-05 00:44:20 +0000175 [SDNPCommutative]>;
Dan Gohman43ffe672010-01-04 20:51:05 +0000176def X86xor_flag : SDNode<"X86ISD::XOR", SDTBinaryArithWithFlags,
Dan Gohman4361bbf2010-01-05 00:44:20 +0000177 [SDNPCommutative]>;
Dan Gohman43ffe672010-01-04 20:51:05 +0000178def X86and_flag : SDNode<"X86ISD::AND", SDTBinaryArithWithFlags,
Dan Gohman4361bbf2010-01-05 00:44:20 +0000179 [SDNPCommutative]>;
Bill Wendlingab55ebd2008-12-12 00:56:36 +0000180
Evan Cheng73f24c92009-03-30 21:36:47 +0000181def X86mul_imm : SDNode<"X86ISD::MUL_IMM", SDTIntBinOp>;
182
Anton Korobeynikov043f3c22010-03-06 19:32:29 +0000183def X86MingwAlloca : SDNode<"X86ISD::MINGW_ALLOCA", SDTX86Void,
184 [SDNPHasChain, SDNPInFlag, SDNPOutFlag]>;
185
Evan Chengaed7c722005-12-17 01:24:02 +0000186//===----------------------------------------------------------------------===//
187// X86 Operand Definitions.
188//
189
Dan Gohmana4714e02009-07-30 01:56:29 +0000190// A version of ptr_rc which excludes SP, ESP, and RSP. This is used for
191// the index operand of an address, to conform to x86 encoding restrictions.
192def ptr_rc_nosp : PointerLikeRegClass<1>;
Chris Lattner7680e732009-06-20 19:34:09 +0000193
Chris Lattner66fa1dc2004-08-11 02:25:00 +0000194// *mem - Operand definitions for the funky X86 addressing mode operands.
195//
Daniel Dunbar338825c2009-08-10 18:41:10 +0000196def X86MemAsmOperand : AsmOperandClass {
197 let Name = "Mem";
Daniel Dunbar54ddf3d2010-05-22 21:02:29 +0000198 let SuperClasses = [];
Daniel Dunbar338825c2009-08-10 18:41:10 +0000199}
Daniel Dunbarec2b1f12010-01-30 00:24:00 +0000200def X86NoSegMemAsmOperand : AsmOperandClass {
201 let Name = "NoSegMem";
Daniel Dunbar54ddf3d2010-05-22 21:02:29 +0000202 let SuperClasses = [X86MemAsmOperand];
Daniel Dunbarec2b1f12010-01-30 00:24:00 +0000203}
Daniel Dunbarc26ae5a2010-05-06 22:39:14 +0000204def X86AbsMemAsmOperand : AsmOperandClass {
205 let Name = "AbsMem";
Daniel Dunbar54ddf3d2010-05-22 21:02:29 +0000206 let SuperClasses = [X86NoSegMemAsmOperand];
Daniel Dunbarc26ae5a2010-05-06 22:39:14 +0000207}
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 Dunbar62e4c672010-05-22 21:02:33 +0000273class ImmSExtAsmOperandClass : AsmOperandClass {
Daniel Dunbar54ddf3d2010-05-22 21:02:29 +0000274 let SuperClasses = [ImmAsmOperand];
Daniel Dunbar62e4c672010-05-22 21:02:33 +0000275 let RenderMethod = "addImmOperands";
Daniel Dunbar1fe591d2010-05-20 20:20:39 +0000276}
277
Daniel Dunbar62e4c672010-05-22 21:02:33 +0000278// Sign-extended immediate classes. We don't need to define the full lattice
279// here because there is no instruction with an ambiguity between ImmSExti64i32
280// and ImmSExti32i8.
281//
282// The strange ranges come from the fact that the assembler always works with
283// 64-bit immediates, but for a 16-bit target value we want to accept both "-1"
284// (which will be a -1ULL), and "0xFF" (-1 in 16-bits).
285
286// [0, 0x7FFFFFFF] | [0xFFFFFFFF80000000, 0xFFFFFFFFFFFFFFFF]
287def ImmSExti64i32AsmOperand : ImmSExtAsmOperandClass {
288 let Name = "ImmSExti64i32";
289}
290
291// [0, 0x0000007F] | [0x000000000000FF80, 0x000000000000FFFF] | [0xFFFFFFFFFFFFFF80, 0xFFFFFFFFFFFFFFFF]
292def ImmSExti16i8AsmOperand : ImmSExtAsmOperandClass {
293 let Name = "ImmSExti16i8";
294 let SuperClasses = [ImmSExti64i32AsmOperand];
295}
296
297// [0, 0x0000007F] | [0x00000000FFFFFF80, 0x00000000FFFFFFFF] | [0xFFFFFFFFFFFFFF80, 0xFFFFFFFFFFFFFFFF]
298def ImmSExti32i8AsmOperand : ImmSExtAsmOperandClass {
299 let Name = "ImmSExti32i8";
300}
301
302// [0, 0x0000007F] | [0xFFFFFFFFFFFFFF80, 0xFFFFFFFFFFFFFFFF]
303def ImmSExti64i8AsmOperand : ImmSExtAsmOperandClass {
304 let Name = "ImmSExti64i8";
305 let SuperClasses = [ImmSExti16i8AsmOperand, ImmSExti32i8AsmOperand, ImmSExti64i32AsmOperand];
Daniel Dunbar338825c2009-08-10 18:41:10 +0000306}
307
Chris Lattnerf124d5e2005-11-18 01:04:42 +0000308// A couple of more descriptive operand definitions.
309// 16-bits but only 8 bits are significant.
Daniel Dunbar5fe63382009-08-09 07:20:21 +0000310def i16i8imm : Operand<i16> {
Daniel Dunbar62e4c672010-05-22 21:02:33 +0000311 let ParserMatchClass = ImmSExti16i8AsmOperand;
Daniel Dunbar5fe63382009-08-09 07:20:21 +0000312}
Chris Lattnerf124d5e2005-11-18 01:04:42 +0000313// 32-bits but only 8 bits are significant.
Daniel Dunbar5fe63382009-08-09 07:20:21 +0000314def i32i8imm : Operand<i32> {
Daniel Dunbar62e4c672010-05-22 21:02:33 +0000315 let ParserMatchClass = ImmSExti32i8AsmOperand;
Daniel Dunbar5fe63382009-08-09 07:20:21 +0000316}
Chris Lattnerf124d5e2005-11-18 01:04:42 +0000317
Evan Chengaed7c722005-12-17 01:24:02 +0000318//===----------------------------------------------------------------------===//
319// X86 Complex Pattern Definitions.
320//
321
Evan Chengec693f72005-12-08 02:01:35 +0000322// Define X86 specific addressing mode.
Rafael Espindola094fad32009-04-08 21:14:34 +0000323def addr : ComplexPattern<iPTR, 5, "SelectAddr", [], []>;
Evan Cheng25ab6902006-09-08 06:48:29 +0000324def lea32addr : ComplexPattern<i32, 4, "SelectLEAAddr",
Dan Gohmana98634b2009-08-02 16:09:17 +0000325 [add, sub, mul, X86mul_imm, shl, or, frameindex],
326 []>;
Chris Lattner5c0b16d2009-06-20 20:38:48 +0000327def tls32addr : ComplexPattern<i32, 4, "SelectTLSADDRAddr",
328 [tglobaltlsaddr], []>;
Evan Chengec693f72005-12-08 02:01:35 +0000329
Evan Chengaed7c722005-12-17 01:24:02 +0000330//===----------------------------------------------------------------------===//
Evan Chengbbc8ddb2005-12-20 22:59:51 +0000331// X86 Instruction Predicate Definitions.
Chris Lattner314a1132010-03-14 18:31:44 +0000332def HasCMov : Predicate<"Subtarget->hasCMov()">;
333def NoCMov : Predicate<"!Subtarget->hasCMov()">;
Evan Cheng28b514392006-12-05 19:50:18 +0000334def HasMMX : Predicate<"Subtarget->hasMMX()">;
335def HasSSE1 : Predicate<"Subtarget->hasSSE1()">;
336def HasSSE2 : Predicate<"Subtarget->hasSSE2()">;
337def HasSSE3 : Predicate<"Subtarget->hasSSE3()">;
Bill Wendlingbb1ee052007-04-10 22:10:25 +0000338def HasSSSE3 : Predicate<"Subtarget->hasSSSE3()">;
Nate Begeman63ec90a2008-02-03 07:18:54 +0000339def HasSSE41 : Predicate<"Subtarget->hasSSE41()">;
340def HasSSE42 : Predicate<"Subtarget->hasSSE42()">;
David Greene343dadb2009-06-26 22:46:54 +0000341def HasSSE4A : Predicate<"Subtarget->hasSSE4A()">;
342def HasAVX : Predicate<"Subtarget->hasAVX()">;
343def HasFMA3 : Predicate<"Subtarget->hasFMA3()">;
344def HasFMA4 : Predicate<"Subtarget->hasFMA4()">;
Dale Johannesenf1fc3a82007-09-23 14:52:20 +0000345def FPStackf32 : Predicate<"!Subtarget->hasSSE1()">;
346def FPStackf64 : Predicate<"!Subtarget->hasSSE2()">;
Evan Cheng28b514392006-12-05 19:50:18 +0000347def In32BitMode : Predicate<"!Subtarget->is64Bit()">;
348def In64BitMode : Predicate<"Subtarget->is64Bit()">;
Anton Korobeynikovcf6b7392009-08-03 08:12:53 +0000349def IsWin64 : Predicate<"Subtarget->isTargetWin64()">;
350def NotWin64 : Predicate<"!Subtarget->isTargetWin64()">;
Anton Korobeynikovd7697d02009-08-06 11:23:24 +0000351def SmallCode : Predicate<"TM.getCodeModel() == CodeModel::Small">;
352def KernelCode : Predicate<"TM.getCodeModel() == CodeModel::Kernel">;
353def FarData : Predicate<"TM.getCodeModel() != CodeModel::Small &&"
Anton Korobeynikov186fa1d2009-08-06 09:11:19 +0000354 "TM.getCodeModel() != CodeModel::Kernel">;
Anton Korobeynikovd7697d02009-08-06 11:23:24 +0000355def NearData : Predicate<"TM.getCodeModel() == CodeModel::Small ||"
356 "TM.getCodeModel() == CodeModel::Kernel">;
Evan Cheng28b514392006-12-05 19:50:18 +0000357def IsStatic : Predicate<"TM.getRelocationModel() == Reloc::Static">;
Evan Chengcb0f06e2010-03-25 00:10:31 +0000358def IsNotPIC : Predicate<"TM.getRelocationModel() != Reloc::PIC_">;
Evan Chengb1f49812009-12-22 17:47:23 +0000359def OptForSize : Predicate<"OptForSize">;
Evan Chengb7a75a52008-09-26 23:41:32 +0000360def OptForSpeed : Predicate<"!OptForSize">;
Evan Chengccb69762009-01-02 05:35:45 +0000361def FastBTMem : Predicate<"!Subtarget->isBTMemSlow()">;
Evan Chengd7f666a2009-05-20 04:53:57 +0000362def CallImmAddr : Predicate<"Subtarget->IsLegalToCallImmediateAddr(TM)">;
Eric Christopher6d1cd1c2010-04-02 21:54:27 +0000363def HasAES : Predicate<"Subtarget->hasAES()">;
Evan Chengbbc8ddb2005-12-20 22:59:51 +0000364
365//===----------------------------------------------------------------------===//
Evan Chengc64a1a92007-07-31 08:04:03 +0000366// X86 Instruction Format Definitions.
Evan Chengaed7c722005-12-17 01:24:02 +0000367//
368
Evan Chengc64a1a92007-07-31 08:04:03 +0000369include "X86InstrFormats.td"
Chris Lattner1cca5e32003-08-03 21:54:21 +0000370
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +0000371//===----------------------------------------------------------------------===//
Chris Lattnerf124d5e2005-11-18 01:04:42 +0000372// Pattern fragments...
373//
Evan Chengd9558e02006-01-06 00:43:03 +0000374
375// X86 specific condition code. These correspond to CondCode in
Nate Begeman9a225302007-05-06 04:00:55 +0000376// X86InstrInfo.h. They must be kept in synch.
Dan Gohman653456c2009-01-07 00:15:08 +0000377def X86_COND_A : PatLeaf<(i8 0)>; // alt. COND_NBE
378def X86_COND_AE : PatLeaf<(i8 1)>; // alt. COND_NC
379def X86_COND_B : PatLeaf<(i8 2)>; // alt. COND_C
380def X86_COND_BE : PatLeaf<(i8 3)>; // alt. COND_NA
381def X86_COND_E : PatLeaf<(i8 4)>; // alt. COND_Z
382def X86_COND_G : PatLeaf<(i8 5)>; // alt. COND_NLE
383def X86_COND_GE : PatLeaf<(i8 6)>; // alt. COND_NL
384def X86_COND_L : PatLeaf<(i8 7)>; // alt. COND_NGE
385def X86_COND_LE : PatLeaf<(i8 8)>; // alt. COND_NG
386def X86_COND_NE : PatLeaf<(i8 9)>; // alt. COND_NZ
Evan Chengd9558e02006-01-06 00:43:03 +0000387def X86_COND_NO : PatLeaf<(i8 10)>;
Dan Gohman653456c2009-01-07 00:15:08 +0000388def X86_COND_NP : PatLeaf<(i8 11)>; // alt. COND_PO
Evan Chengd9558e02006-01-06 00:43:03 +0000389def X86_COND_NS : PatLeaf<(i8 12)>;
Dan Gohman653456c2009-01-07 00:15:08 +0000390def X86_COND_O : PatLeaf<(i8 13)>;
391def X86_COND_P : PatLeaf<(i8 14)>; // alt. COND_PE
392def X86_COND_S : PatLeaf<(i8 15)>;
Evan Chengd9558e02006-01-06 00:43:03 +0000393
Chris Lattner18409912010-03-03 01:45:01 +0000394def immSext8 : PatLeaf<(imm), [{
395 return N->getSExtValue() == (int8_t)N->getSExtValue();
Chris Lattnerf124d5e2005-11-18 01:04:42 +0000396}]>;
397
Chris Lattner18409912010-03-03 01:45:01 +0000398def i16immSExt8 : PatLeaf<(i16 immSext8)>;
399def i32immSExt8 : PatLeaf<(i32 immSext8)>;
Evan Chengb3558542005-12-13 00:01:09 +0000400
Chris Lattnerf85eff72010-03-03 01:52:59 +0000401/// Load patterns: these constraint the match to the right address space.
402def dsload : PatFrag<(ops node:$ptr), (load node:$ptr), [{
403 if (const Value *Src = cast<LoadSDNode>(N)->getSrcValue())
404 if (const PointerType *PT = dyn_cast<PointerType>(Src->getType()))
405 if (PT->getAddressSpace() > 255)
406 return false;
407 return true;
408}]>;
409
410def gsload : PatFrag<(ops node:$ptr), (load node:$ptr), [{
411 if (const Value *Src = cast<LoadSDNode>(N)->getSrcValue())
412 if (const PointerType *PT = dyn_cast<PointerType>(Src->getType()))
413 return PT->getAddressSpace() == 256;
414 return false;
415}]>;
416
417def fsload : PatFrag<(ops node:$ptr), (load node:$ptr), [{
418 if (const Value *Src = cast<LoadSDNode>(N)->getSrcValue())
419 if (const PointerType *PT = dyn_cast<PointerType>(Src->getType()))
420 return PT->getAddressSpace() == 257;
421 return false;
422}]>;
423
424
Evan Cheng605c4152005-12-13 01:57:51 +0000425// Helper fragments for loads.
Evan Chengb6564432008-05-13 18:59:59 +0000426// It's always safe to treat a anyext i16 load as a i32 load if the i16 is
427// known to be 32-bit aligned or better. Ditto for i8 to i16.
Dan Gohman33586292008-10-15 06:50:19 +0000428def loadi16 : PatFrag<(ops node:$ptr), (i16 (unindexedload node:$ptr)), [{
Dan Gohman67ca6be2008-08-20 15:24:22 +0000429 LoadSDNode *LD = cast<LoadSDNode>(N);
Chris Lattnerc2406f22009-04-10 00:16:23 +0000430 if (const Value *Src = LD->getSrcValue())
431 if (const PointerType *PT = dyn_cast<PointerType>(Src->getType()))
Mon P Wanga7e01d72009-04-27 07:22:10 +0000432 if (PT->getAddressSpace() > 255)
Chris Lattnerc2406f22009-04-10 00:16:23 +0000433 return false;
Dan Gohman67ca6be2008-08-20 15:24:22 +0000434 ISD::LoadExtType ExtType = LD->getExtensionType();
435 if (ExtType == ISD::NON_EXTLOAD)
436 return true;
437 if (ExtType == ISD::EXTLOAD)
438 return LD->getAlignment() >= 2 && !LD->isVolatile();
Evan Chengfa7fd332008-05-13 00:54:02 +0000439 return false;
440}]>;
441
Chris Lattnerf85eff72010-03-03 01:52:59 +0000442def loadi16_anyext : PatFrag<(ops node:$ptr), (i32 (unindexedload node:$ptr)),[{
Evan Chengca57f782008-09-24 23:27:55 +0000443 LoadSDNode *LD = cast<LoadSDNode>(N);
Chris Lattnerc2406f22009-04-10 00:16:23 +0000444 if (const Value *Src = LD->getSrcValue())
445 if (const PointerType *PT = dyn_cast<PointerType>(Src->getType()))
Mon P Wanga7e01d72009-04-27 07:22:10 +0000446 if (PT->getAddressSpace() > 255)
Chris Lattnerc2406f22009-04-10 00:16:23 +0000447 return false;
Evan Chengca57f782008-09-24 23:27:55 +0000448 ISD::LoadExtType ExtType = LD->getExtensionType();
449 if (ExtType == ISD::EXTLOAD)
450 return LD->getAlignment() >= 2 && !LD->isVolatile();
451 return false;
452}]>;
453
Dan Gohman33586292008-10-15 06:50:19 +0000454def loadi32 : PatFrag<(ops node:$ptr), (i32 (unindexedload node:$ptr)), [{
Dan Gohman67ca6be2008-08-20 15:24:22 +0000455 LoadSDNode *LD = cast<LoadSDNode>(N);
Chris Lattnerc2406f22009-04-10 00:16:23 +0000456 if (const Value *Src = LD->getSrcValue())
457 if (const PointerType *PT = dyn_cast<PointerType>(Src->getType()))
Mon P Wanga7e01d72009-04-27 07:22:10 +0000458 if (PT->getAddressSpace() > 255)
Chris Lattnerc2406f22009-04-10 00:16:23 +0000459 return false;
Dan Gohman67ca6be2008-08-20 15:24:22 +0000460 ISD::LoadExtType ExtType = LD->getExtensionType();
461 if (ExtType == ISD::NON_EXTLOAD)
462 return true;
463 if (ExtType == ISD::EXTLOAD)
464 return LD->getAlignment() >= 4 && !LD->isVolatile();
Evan Chengfa7fd332008-05-13 00:54:02 +0000465 return false;
466}]>;
467
Chris Lattnerf85eff72010-03-03 01:52:59 +0000468def loadi8 : PatFrag<(ops node:$ptr), (i8 (dsload node:$ptr))>;
469def loadi64 : PatFrag<(ops node:$ptr), (i64 (dsload node:$ptr))>;
470def loadf32 : PatFrag<(ops node:$ptr), (f32 (dsload node:$ptr))>;
471def loadf64 : PatFrag<(ops node:$ptr), (f64 (dsload node:$ptr))>;
472def loadf80 : PatFrag<(ops node:$ptr), (f80 (dsload node:$ptr))>;
Evan Cheng7a7e8372005-12-14 02:22:27 +0000473
Evan Cheng466685d2006-10-09 20:57:25 +0000474def sextloadi16i8 : PatFrag<(ops node:$ptr), (i16 (sextloadi8 node:$ptr))>;
475def sextloadi32i8 : PatFrag<(ops node:$ptr), (i32 (sextloadi8 node:$ptr))>;
476def sextloadi32i16 : PatFrag<(ops node:$ptr), (i32 (sextloadi16 node:$ptr))>;
Evan Cheng7a7e8372005-12-14 02:22:27 +0000477
Evan Cheng466685d2006-10-09 20:57:25 +0000478def zextloadi8i1 : PatFrag<(ops node:$ptr), (i8 (zextloadi1 node:$ptr))>;
479def zextloadi16i1 : PatFrag<(ops node:$ptr), (i16 (zextloadi1 node:$ptr))>;
480def zextloadi32i1 : PatFrag<(ops node:$ptr), (i32 (zextloadi1 node:$ptr))>;
481def zextloadi16i8 : PatFrag<(ops node:$ptr), (i16 (zextloadi8 node:$ptr))>;
482def zextloadi32i8 : PatFrag<(ops node:$ptr), (i32 (zextloadi8 node:$ptr))>;
483def zextloadi32i16 : PatFrag<(ops node:$ptr), (i32 (zextloadi16 node:$ptr))>;
Evan Cheng7a7e8372005-12-14 02:22:27 +0000484
Evan Cheng466685d2006-10-09 20:57:25 +0000485def extloadi8i1 : PatFrag<(ops node:$ptr), (i8 (extloadi1 node:$ptr))>;
486def extloadi16i1 : PatFrag<(ops node:$ptr), (i16 (extloadi1 node:$ptr))>;
487def extloadi32i1 : PatFrag<(ops node:$ptr), (i32 (extloadi1 node:$ptr))>;
488def extloadi16i8 : PatFrag<(ops node:$ptr), (i16 (extloadi8 node:$ptr))>;
489def extloadi32i8 : PatFrag<(ops node:$ptr), (i32 (extloadi8 node:$ptr))>;
490def extloadi32i16 : PatFrag<(ops node:$ptr), (i32 (extloadi16 node:$ptr))>;
Evan Cheng747a90d2006-02-21 02:24:38 +0000491
Chris Lattnerce2bcc82008-02-19 17:37:35 +0000492
493// An 'and' node with a single use.
494def and_su : PatFrag<(ops node:$lhs, node:$rhs), (and node:$lhs, node:$rhs), [{
Evan Cheng07b7ea12008-03-04 00:40:35 +0000495 return N->hasOneUse();
Chris Lattnerce2bcc82008-02-19 17:37:35 +0000496}]>;
Dan Gohman21e3dfb2009-04-13 16:09:41 +0000497// An 'srl' node with a single use.
498def srl_su : PatFrag<(ops node:$lhs, node:$rhs), (srl node:$lhs, node:$rhs), [{
499 return N->hasOneUse();
500}]>;
501// An 'trunc' node with a single use.
502def trunc_su : PatFrag<(ops node:$src), (trunc node:$src), [{
503 return N->hasOneUse();
504}]>;
Chris Lattnerce2bcc82008-02-19 17:37:35 +0000505
Evan Cheng4b0345b2010-01-11 17:03:47 +0000506// Treat an 'or' node is as an 'add' if the or'ed bits are known to be zero.
507def or_is_add : PatFrag<(ops node:$lhs, node:$rhs), (or node:$lhs, node:$rhs),[{
508 if (ConstantSDNode *CN = dyn_cast<ConstantSDNode>(N->getOperand(1)))
509 return CurDAG->MaskedValueIsZero(N->getOperand(0), CN->getAPIntValue());
Chris Lattnerfdac0b62010-03-24 00:12:57 +0000510
511 unsigned BitWidth = N->getValueType(0).getScalarType().getSizeInBits();
512 APInt Mask = APInt::getAllOnesValue(BitWidth);
513 APInt KnownZero0, KnownOne0;
514 CurDAG->ComputeMaskedBits(N->getOperand(0), Mask, KnownZero0, KnownOne0, 0);
515 APInt KnownZero1, KnownOne1;
516 CurDAG->ComputeMaskedBits(N->getOperand(1), Mask, KnownZero1, KnownOne1, 0);
517 return (~KnownZero0 & ~KnownZero1) == 0;
Evan Cheng4b0345b2010-01-11 17:03:47 +0000518}]>;
Evan Cheng4b0345b2010-01-11 17:03:47 +0000519
Chris Lattnerf124d5e2005-11-18 01:04:42 +0000520//===----------------------------------------------------------------------===//
Chris Lattner1cca5e32003-08-03 21:54:21 +0000521// Instruction list...
522//
523
Chris Lattnerf18c0742006-10-12 17:42:56 +0000524// ADJCALLSTACKDOWN/UP implicitly use/def ESP because they may be expanded into
525// a stack adjustment and the codegen must know that they may modify the stack
526// pointer before prolog-epilog rewriting occurs.
Chris Lattner447ff682008-03-11 03:23:40 +0000527// Pessimistically assume ADJCALLSTACKDOWN / ADJCALLSTACKUP will become
528// sub / add which can clobber EFLAGS.
Evan Cheng8decf6b2007-09-28 01:19:48 +0000529let Defs = [ESP, EFLAGS], Uses = [ESP] in {
Dan Gohman6d4b0522008-10-01 18:28:06 +0000530def ADJCALLSTACKDOWN32 : I<0, Pseudo, (outs), (ins i32imm:$amt),
531 "#ADJCALLSTACKDOWN",
Chris Lattnere563bbc2008-10-11 22:08:30 +0000532 [(X86callseq_start timm:$amt)]>,
Dan Gohman6d4b0522008-10-01 18:28:06 +0000533 Requires<[In32BitMode]>;
534def ADJCALLSTACKUP32 : I<0, Pseudo, (outs), (ins i32imm:$amt1, i32imm:$amt2),
535 "#ADJCALLSTACKUP",
Chris Lattnere563bbc2008-10-11 22:08:30 +0000536 [(X86callseq_end timm:$amt1, timm:$amt2)]>,
Dan Gohman6d4b0522008-10-01 18:28:06 +0000537 Requires<[In32BitMode]>;
Evan Cheng071a2792007-09-11 19:55:27 +0000538}
Evan Cheng4a460802006-01-11 00:33:36 +0000539
Dan Gohmand6708ea2009-08-15 01:38:56 +0000540// x86-64 va_start lowering magic.
Anton Korobeynikov043f3c22010-03-06 19:32:29 +0000541let usesCustomInserter = 1 in {
Dan Gohmand6708ea2009-08-15 01:38:56 +0000542def VASTART_SAVE_XMM_REGS : I<0, Pseudo,
543 (outs),
544 (ins GR8:$al,
545 i64imm:$regsavefi, i64imm:$offset,
546 variable_ops),
547 "#VASTART_SAVE_XMM_REGS $al, $regsavefi, $offset",
548 [(X86vastart_save_xmm_regs GR8:$al,
549 imm:$regsavefi,
550 imm:$offset)]>;
551
Anton Korobeynikove765f2b2010-03-06 20:07:32 +0000552// Dynamic stack allocation yields _alloca call for Cygwin/Mingw targets. Calls
553// to _alloca is needed to probe the stack when allocating more than 4k bytes in
554// one go. Touching the stack at 4K increments is necessary to ensure that the
555// guard pages used by the OS virtual memory manager are allocated in correct
556// sequence.
557// The main point of having separate instruction are extra unmodelled effects
558// (compared to ordinary calls) like stack pointer change.
559
Anton Korobeynikov043f3c22010-03-06 19:32:29 +0000560def MINGW_ALLOCA : I<0, Pseudo, (outs), (ins),
Anton Korobeynikove765f2b2010-03-06 20:07:32 +0000561 "# dynamic stack allocation",
Anton Korobeynikov043f3c22010-03-06 19:32:29 +0000562 [(X86MingwAlloca)]>;
563}
564
Evan Cheng4a460802006-01-11 00:33:36 +0000565// Nop
Sean Callanan74e52102009-07-23 23:39:34 +0000566let neverHasSideEffects = 1 in {
Chris Lattnerba7e7562008-01-10 07:59:24 +0000567 def NOOP : I<0x90, RawFrm, (outs), (ins), "nop", []>;
Sean Callanan108934c2009-12-18 00:01:26 +0000568 def NOOPW : I<0x1f, MRM0m, (outs), (ins i16mem:$zero),
569 "nop{w}\t$zero", []>, TB, OpSize;
Sean Callanan74e52102009-07-23 23:39:34 +0000570 def NOOPL : I<0x1f, MRM0m, (outs), (ins i32mem:$zero),
Sean Callanan108934c2009-12-18 00:01:26 +0000571 "nop{l}\t$zero", []>, TB;
Sean Callanan74e52102009-07-23 23:39:34 +0000572}
Evan Cheng4a460802006-01-11 00:33:36 +0000573
Sean Callanan1c5cf1b2009-08-11 01:09:06 +0000574// Trap
Kevin Enderbyc3ce05c2010-05-14 19:16:02 +0000575def INTO : I<0xce, RawFrm, (outs), (ins), "into", []>;
576def INT3 : I<0xcc, RawFrm, (outs), (ins), "int3", []>;
577// FIXME: need to make sure that "int $3" matches int3
578def INT : Ii8<0xcd, RawFrm, (outs), (ins i8imm:$trap), "int\t$trap", []>;
Sean Callanan108934c2009-12-18 00:01:26 +0000579def IRET16 : I<0xcf, RawFrm, (outs), (ins), "iret{w}", []>, OpSize;
580def IRET32 : I<0xcf, RawFrm, (outs), (ins), "iret{l}", []>;
Sean Callanan1c5cf1b2009-08-11 01:09:06 +0000581
Chris Lattner71c7ace2009-09-20 07:32:00 +0000582// PIC base construction. This expands to code that looks like this:
583// call $next_inst
584// popl %destreg"
Dan Gohman2662d552008-10-01 04:14:30 +0000585let neverHasSideEffects = 1, isNotDuplicable = 1, Uses = [ESP] in
Chris Lattnerb3c85472009-09-20 07:28:26 +0000586 def MOVPC32r : Ii32<0xE8, Pseudo, (outs GR32:$reg), (ins i32imm:$label),
Chris Lattner71c7ace2009-09-20 07:32:00 +0000587 "", []>;
Evan Cheng8f7f7122006-05-05 05:40:20 +0000588
Chris Lattner1cca5e32003-08-03 21:54:21 +0000589//===----------------------------------------------------------------------===//
Chris Lattnerbd13fb62010-02-11 19:25:55 +0000590// Control Flow Instructions.
Chris Lattner1cca5e32003-08-03 21:54:21 +0000591//
592
Chris Lattner1be48112005-05-13 17:56:48 +0000593// Return instructions.
Evan Cheng2b4ea792005-12-26 09:11:45 +0000594let isTerminator = 1, isReturn = 1, isBarrier = 1,
Jakob Stoklund Olesen70feca42010-03-25 18:52:01 +0000595 hasCtrlDep = 1, FPForm = SpecialFP in {
Dan Gohmane4c67cd2008-05-31 02:11:25 +0000596 def RET : I <0xC3, RawFrm, (outs), (ins variable_ops),
Chris Lattner447ff682008-03-11 03:23:40 +0000597 "ret",
Dan Gohmane4c67cd2008-05-31 02:11:25 +0000598 [(X86retflag 0)]>;
Chris Lattner447ff682008-03-11 03:23:40 +0000599 def RETI : Ii16<0xC2, RawFrm, (outs), (ins i16imm:$amt, variable_ops),
600 "ret\t$amt",
Dan Gohman2f67df72009-09-03 17:18:51 +0000601 [(X86retflag timm:$amt)]>;
Sean Callanan356aed52009-09-15 23:37:51 +0000602 def LRET : I <0xCB, RawFrm, (outs), (ins),
603 "lret", []>;
604 def LRETI : Ii16<0xCA, RawFrm, (outs), (ins i16imm:$amt),
605 "lret\t$amt", []>;
Evan Cheng171049d2005-12-23 22:14:32 +0000606}
Chris Lattner1cca5e32003-08-03 21:54:21 +0000607
Chris Lattnerbd13fb62010-02-11 19:25:55 +0000608// Unconditional branches.
Chris Lattnerb8db3312010-02-11 21:45:31 +0000609let isBarrier = 1, isBranch = 1, isTerminator = 1 in {
Chris Lattnera0331192010-02-12 22:27:07 +0000610 def JMP_4 : Ii32PCRel<0xE9, RawFrm, (outs), (ins brtarget:$dst),
611 "jmp\t$dst", [(br bb:$dst)]>;
612 def JMP_1 : Ii8PCRel<0xEB, RawFrm, (outs), (ins brtarget8:$dst),
613 "jmp\t$dst", []>;
Sean Callanan52925882009-07-22 01:05:20 +0000614}
Evan Cheng898101c2005-12-19 23:12:38 +0000615
Chris Lattnerbd13fb62010-02-11 19:25:55 +0000616// Conditional Branches.
617let isBranch = 1, isTerminator = 1, Uses = [EFLAGS] in {
618 multiclass ICBr<bits<8> opc1, bits<8> opc4, string asm, PatFrag Cond> {
Chris Lattnera0331192010-02-12 22:27:07 +0000619 def _1 : Ii8PCRel <opc1, RawFrm, (outs), (ins brtarget8:$dst), asm, []>;
620 def _4 : Ii32PCRel<opc4, RawFrm, (outs), (ins brtarget:$dst), asm,
621 [(X86brcond bb:$dst, Cond, EFLAGS)]>, TB;
Chris Lattnerbd13fb62010-02-11 19:25:55 +0000622 }
623}
624
625defm JO : ICBr<0x70, 0x80, "jo\t$dst" , X86_COND_O>;
Chris Lattner8b442a82010-02-11 19:52:11 +0000626defm JNO : ICBr<0x71, 0x81, "jno\t$dst" , X86_COND_NO>;
Chris Lattnerbd13fb62010-02-11 19:25:55 +0000627defm JB : ICBr<0x72, 0x82, "jb\t$dst" , X86_COND_B>;
628defm JAE : ICBr<0x73, 0x83, "jae\t$dst", X86_COND_AE>;
629defm JE : ICBr<0x74, 0x84, "je\t$dst" , X86_COND_E>;
630defm JNE : ICBr<0x75, 0x85, "jne\t$dst", X86_COND_NE>;
631defm JBE : ICBr<0x76, 0x86, "jbe\t$dst", X86_COND_BE>;
632defm JA : ICBr<0x77, 0x87, "ja\t$dst" , X86_COND_A>;
633defm JS : ICBr<0x78, 0x88, "js\t$dst" , X86_COND_S>;
634defm JNS : ICBr<0x79, 0x89, "jns\t$dst", X86_COND_NS>;
635defm JP : ICBr<0x7A, 0x8A, "jp\t$dst" , X86_COND_P>;
636defm JNP : ICBr<0x7B, 0x8B, "jnp\t$dst", X86_COND_NP>;
637defm JL : ICBr<0x7C, 0x8C, "jl\t$dst" , X86_COND_L>;
638defm JGE : ICBr<0x7D, 0x8D, "jge\t$dst", X86_COND_GE>;
639defm JLE : ICBr<0x7E, 0x8E, "jle\t$dst", X86_COND_LE>;
640defm JG : ICBr<0x7F, 0x8F, "jg\t$dst" , X86_COND_G>;
641
642// FIXME: What about the CX/RCX versions of this instruction?
Chris Lattnerb8db3312010-02-11 21:45:31 +0000643let Uses = [ECX], isBranch = 1, isTerminator = 1 in
Chris Lattnera0331192010-02-12 22:27:07 +0000644 def JCXZ8 : Ii8PCRel<0xE3, RawFrm, (outs), (ins brtarget8:$dst),
645 "jcxz\t$dst", []>;
Chris Lattnerbd13fb62010-02-11 19:25:55 +0000646
647
Owen Anderson20ab2902007-11-12 07:39:39 +0000648// Indirect branches
649let isBranch = 1, isTerminator = 1, isBarrier = 1, isIndirectBranch = 1 in {
Dan Gohmanb1576f52007-07-31 20:11:57 +0000650 def JMP32r : I<0xFF, MRM4r, (outs), (ins GR32:$dst), "jmp{l}\t{*}$dst",
Evan Cheng069287d2006-05-16 07:21:53 +0000651 [(brind GR32:$dst)]>;
Dan Gohmanb1576f52007-07-31 20:11:57 +0000652 def JMP32m : I<0xFF, MRM4m, (outs), (ins i32mem:$dst), "jmp{l}\t{*}$dst",
Evan Cheng25ab6902006-09-08 06:48:29 +0000653 [(brind (loadi32 addr:$dst))]>;
Sean Callanan76f14be2009-09-15 00:35:17 +0000654
655 def FARJMP16i : Iseg16<0xEA, RawFrm, (outs),
656 (ins i16imm:$seg, i16imm:$off),
657 "ljmp{w}\t$seg, $off", []>, OpSize;
658 def FARJMP32i : Iseg32<0xEA, RawFrm, (outs),
659 (ins i16imm:$seg, i32imm:$off),
660 "ljmp{l}\t$seg, $off", []>;
661
662 def FARJMP16m : I<0xFF, MRM5m, (outs), (ins opaque32mem:$dst),
Sean Callanan9947bbb2009-09-03 00:04:47 +0000663 "ljmp{w}\t{*}$dst", []>, OpSize;
Sean Callanan76f14be2009-09-15 00:35:17 +0000664 def FARJMP32m : I<0xFF, MRM5m, (outs), (ins opaque48mem:$dst),
Sean Callanan9947bbb2009-09-03 00:04:47 +0000665 "ljmp{l}\t{*}$dst", []>;
Nate Begeman37efe672006-04-22 18:53:45 +0000666}
667
Chris Lattner1cca5e32003-08-03 21:54:21 +0000668
Sean Callanan7e6d7272009-09-16 21:50:07 +0000669// Loop instructions
670
Chris Lattner34b8a882010-03-18 20:50:06 +0000671def LOOP : I<0xE2, RawFrm, (outs), (ins brtarget8:$dst), "loop\t$dst", []>;
672def LOOPE : I<0xE1, RawFrm, (outs), (ins brtarget8:$dst), "loope\t$dst", []>;
673def LOOPNE : I<0xE0, RawFrm, (outs), (ins brtarget8:$dst), "loopne\t$dst", []>;
Sean Callanan7e6d7272009-09-16 21:50:07 +0000674
Chris Lattner1cca5e32003-08-03 21:54:21 +0000675//===----------------------------------------------------------------------===//
676// Call Instructions...
677//
Evan Chengffbacca2007-07-21 00:34:19 +0000678let isCall = 1 in
Dan Gohman6d4b0522008-10-01 18:28:06 +0000679 // All calls clobber the non-callee saved registers. ESP is marked as
680 // a use to prevent stack-pointer assignments that appear immediately
681 // before calls from potentially appearing dead. Uses for argument
682 // registers are added manually.
Nate Begemanf63be7d2005-07-06 18:59:04 +0000683 let Defs = [EAX, ECX, EDX, FP0, FP1, FP2, FP3, FP4, FP5, FP6, ST0,
Bill Wendling3f3a17d2007-04-25 21:31:48 +0000684 MM0, MM1, MM2, MM3, MM4, MM5, MM6, MM7,
Evan Cheng109a5622008-10-17 21:02:22 +0000685 XMM0, XMM1, XMM2, XMM3, XMM4, XMM5, XMM6, XMM7,
686 XMM8, XMM9, XMM10, XMM11, XMM12, XMM13, XMM14, XMM15, EFLAGS],
Dan Gohman2662d552008-10-01 04:14:30 +0000687 Uses = [ESP] in {
Chris Lattnera0331192010-02-12 22:27:07 +0000688 def CALLpcrel32 : Ii32PCRel<0xE8, RawFrm,
Chris Lattner7680e732009-06-20 19:34:09 +0000689 (outs), (ins i32imm_pcrel:$dst,variable_ops),
690 "call\t$dst", []>;
Evan Cheng64d80e32007-07-19 01:14:50 +0000691 def CALL32r : I<0xFF, MRM2r, (outs), (ins GR32:$dst, variable_ops),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000692 "call\t{*}$dst", [(X86call GR32:$dst)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +0000693 def CALL32m : I<0xFF, MRM2m, (outs), (ins i32mem:$dst, variable_ops),
Dan Gohmanb4106172008-05-29 21:50:34 +0000694 "call\t{*}$dst", [(X86call (loadi32 addr:$dst))]>;
Sean Callanan9947bbb2009-09-03 00:04:47 +0000695
Sean Callanan76f14be2009-09-15 00:35:17 +0000696 def FARCALL16i : Iseg16<0x9A, RawFrm, (outs),
697 (ins i16imm:$seg, i16imm:$off),
698 "lcall{w}\t$seg, $off", []>, OpSize;
699 def FARCALL32i : Iseg32<0x9A, RawFrm, (outs),
700 (ins i16imm:$seg, i32imm:$off),
701 "lcall{l}\t$seg, $off", []>;
702
703 def FARCALL16m : I<0xFF, MRM3m, (outs), (ins opaque32mem:$dst),
Sean Callanan9947bbb2009-09-03 00:04:47 +0000704 "lcall{w}\t{*}$dst", []>, OpSize;
Sean Callanan76f14be2009-09-15 00:35:17 +0000705 def FARCALL32m : I<0xFF, MRM3m, (outs), (ins opaque48mem:$dst),
Sean Callanan9947bbb2009-09-03 00:04:47 +0000706 "lcall{l}\t{*}$dst", []>;
Chris Lattner1cca5e32003-08-03 21:54:21 +0000707 }
708
Sean Callanan8d708542009-09-16 02:57:13 +0000709// Constructing a stack frame.
710
711def ENTER : I<0xC8, RawFrm, (outs), (ins i16imm:$len, i8imm:$lvl),
712 "enter\t$len, $lvl", []>;
713
Chris Lattner1e9448b2005-05-15 03:10:37 +0000714// Tail call stuff.
Arnold Schwaighoferc85e1712007-10-11 19:40:01 +0000715
Evan Chengffbacca2007-07-21 00:34:19 +0000716let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1 in
Evan Chengf48ef032010-03-14 03:48:46 +0000717 let Defs = [EAX, ECX, EDX, FP0, FP1, FP2, FP3, FP4, FP5, FP6, ST0,
718 MM0, MM1, MM2, MM3, MM4, MM5, MM6, MM7,
719 XMM0, XMM1, XMM2, XMM3, XMM4, XMM5, XMM6, XMM7,
720 XMM8, XMM9, XMM10, XMM11, XMM12, XMM13, XMM14, XMM15, EFLAGS],
721 Uses = [ESP] in {
722 def TCRETURNdi : I<0, Pseudo, (outs),
723 (ins i32imm_pcrel:$dst, i32imm:$offset, variable_ops),
724 "#TC_RETURN $dst $offset", []>;
725 def TCRETURNri : I<0, Pseudo, (outs),
726 (ins GR32_TC:$dst, i32imm:$offset, variable_ops),
727 "#TC_RETURN $dst $offset", []>;
Dan Gohman7f357ec2010-05-14 16:34:55 +0000728 let mayLoad = 1 in
Evan Chengf48ef032010-03-14 03:48:46 +0000729 def TCRETURNmi : I<0, Pseudo, (outs),
730 (ins i32mem_TC:$dst, i32imm:$offset, variable_ops),
731 "#TC_RETURN $dst $offset", []>;
Arnold Schwaighoferc85e1712007-10-11 19:40:01 +0000732
Evan Chengf48ef032010-03-14 03:48:46 +0000733 // FIXME: The should be pseudo instructions that are lowered when going to
734 // mcinst.
Chris Lattner840e6372010-03-16 06:30:18 +0000735 def TAILJMPd : Ii32PCRel<0xE9, RawFrm, (outs),
736 (ins i32imm_pcrel:$dst, variable_ops),
Evan Chengaa92bec2010-01-31 07:28:44 +0000737 "jmp\t$dst # TAILCALL",
Evan Chengf10c17f2006-09-22 21:43:59 +0000738 []>;
Evan Chengf48ef032010-03-14 03:48:46 +0000739 def TAILJMPr : I<0xFF, MRM4r, (outs), (ins GR32_TC:$dst, variable_ops),
Sean Callanan108934c2009-12-18 00:01:26 +0000740 "jmp{l}\t{*}$dst # TAILCALL",
Arnold Schwaighoferc85e1712007-10-11 19:40:01 +0000741 []>;
Dan Gohman7f357ec2010-05-14 16:34:55 +0000742 let mayLoad = 1 in
Evan Chengf48ef032010-03-14 03:48:46 +0000743 def TAILJMPm : I<0xFF, MRM4m, (outs), (ins i32mem_TC:$dst, variable_ops),
744 "jmp{l}\t{*}$dst # TAILCALL", []>;
Daniel Dunbar52322e72010-05-19 15:26:43 +0000745
746 // FIXME: This is a hack so that MCInst lowering can preserve the TAILCALL
747 // marker on instructions, while still being able to relax.
748 let isCodeGenOnly = 1 in {
749 def TAILJMP_1 : Ii8PCRel<0xEB, RawFrm, (outs), (ins brtarget8:$dst),
750 "jmp\t$dst # TAILCALL", []>;
751 }
Evan Chengf48ef032010-03-14 03:48:46 +0000752}
Chris Lattner1e9448b2005-05-15 03:10:37 +0000753
Chris Lattner1cca5e32003-08-03 21:54:21 +0000754//===----------------------------------------------------------------------===//
755// Miscellaneous Instructions...
756//
Chris Lattnerba7e7562008-01-10 07:59:24 +0000757let Defs = [EBP, ESP], Uses = [EBP, ESP], mayLoad = 1, neverHasSideEffects=1 in
Chris Lattner30bf2d82004-08-10 20:17:41 +0000758def LEAVE : I<0xC9, RawFrm,
Evan Cheng071a2792007-09-11 19:55:27 +0000759 (outs), (ins), "leave", []>;
760
Sean Callanan108934c2009-12-18 00:01:26 +0000761def POPCNT16rr : I<0xB8, MRMSrcReg, (outs GR16:$dst), (ins GR16:$src),
762 "popcnt{w}\t{$src, $dst|$dst, $src}", []>, OpSize, XS;
Dan Gohman7f357ec2010-05-14 16:34:55 +0000763let mayLoad = 1 in
Sean Callanan108934c2009-12-18 00:01:26 +0000764def POPCNT16rm : I<0xB8, MRMSrcMem, (outs GR16:$dst), (ins i16mem:$src),
765 "popcnt{w}\t{$src, $dst|$dst, $src}", []>, OpSize, XS;
766def POPCNT32rr : I<0xB8, MRMSrcReg, (outs GR32:$dst), (ins GR32:$src),
767 "popcnt{l}\t{$src, $dst|$dst, $src}", []>, XS;
Dan Gohman7f357ec2010-05-14 16:34:55 +0000768let mayLoad = 1 in
Sean Callanan108934c2009-12-18 00:01:26 +0000769def POPCNT32rm : I<0xB8, MRMSrcMem, (outs GR32:$dst), (ins i32mem:$src),
770 "popcnt{l}\t{$src, $dst|$dst, $src}", []>, XS;
771
Chris Lattnerba7e7562008-01-10 07:59:24 +0000772let Defs = [ESP], Uses = [ESP], neverHasSideEffects=1 in {
Sean Callanan1f24e012009-09-10 18:29:13 +0000773let mayLoad = 1 in {
774def POP16r : I<0x58, AddRegFrm, (outs GR16:$reg), (ins), "pop{w}\t$reg", []>,
775 OpSize;
776def POP32r : I<0x58, AddRegFrm, (outs GR32:$reg), (ins), "pop{l}\t$reg", []>;
777def POP16rmr: I<0x8F, MRM0r, (outs GR16:$reg), (ins), "pop{w}\t$reg", []>,
778 OpSize;
779def POP16rmm: I<0x8F, MRM0m, (outs i16mem:$dst), (ins), "pop{w}\t$dst", []>,
780 OpSize;
781def POP32rmr: I<0x8F, MRM0r, (outs GR32:$reg), (ins), "pop{l}\t$reg", []>;
782def POP32rmm: I<0x8F, MRM0m, (outs i32mem:$dst), (ins), "pop{l}\t$dst", []>;
783}
Chris Lattner1cca5e32003-08-03 21:54:21 +0000784
Sean Callanan1f24e012009-09-10 18:29:13 +0000785let mayStore = 1 in {
786def PUSH16r : I<0x50, AddRegFrm, (outs), (ins GR16:$reg), "push{w}\t$reg",[]>,
787 OpSize;
Evan Cheng2f245ba2007-09-26 01:29:06 +0000788def PUSH32r : I<0x50, AddRegFrm, (outs), (ins GR32:$reg), "push{l}\t$reg",[]>;
Sean Callanan1f24e012009-09-10 18:29:13 +0000789def PUSH16rmr: I<0xFF, MRM6r, (outs), (ins GR16:$reg), "push{w}\t$reg",[]>,
790 OpSize;
791def PUSH16rmm: I<0xFF, MRM6m, (outs), (ins i16mem:$src), "push{w}\t$src",[]>,
792 OpSize;
793def PUSH32rmr: I<0xFF, MRM6r, (outs), (ins GR32:$reg), "push{l}\t$reg",[]>;
794def PUSH32rmm: I<0xFF, MRM6m, (outs), (ins i32mem:$src), "push{l}\t$src",[]>;
795}
Evan Cheng071a2792007-09-11 19:55:27 +0000796}
Anton Korobeynikov57fc00d2007-04-17 09:20:00 +0000797
Bill Wendling453eb262009-06-15 19:39:04 +0000798let Defs = [ESP], Uses = [ESP], neverHasSideEffects = 1, mayStore = 1 in {
Kevin Enderby3c979b02010-05-03 20:45:05 +0000799def PUSHi8 : Ii8<0x6a, RawFrm, (outs), (ins i32i8imm:$imm),
Bill Wendling927788c2009-06-15 20:59:31 +0000800 "push{l}\t$imm", []>;
Kevin Enderby3c979b02010-05-03 20:45:05 +0000801def PUSHi16 : Ii16<0x68, RawFrm, (outs), (ins i16imm:$imm),
802 "push{w}\t$imm", []>, OpSize;
803def PUSHi32 : Ii32<0x68, RawFrm, (outs), (ins i32imm:$imm),
Bill Wendling927788c2009-06-15 20:59:31 +0000804 "push{l}\t$imm", []>;
Bill Wendling453eb262009-06-15 19:39:04 +0000805}
806
Sean Callanan108934c2009-12-18 00:01:26 +0000807let Defs = [ESP, EFLAGS], Uses = [ESP], mayLoad = 1, neverHasSideEffects=1 in {
Dan Gohmane5e4ff92010-05-20 16:16:00 +0000808def POPF16 : I<0x9D, RawFrm, (outs), (ins), "popf{w}", []>, OpSize;
809def POPF32 : I<0x9D, RawFrm, (outs), (ins), "popf{l|d}", []>,
810 Requires<[In32BitMode]>;
Sean Callanan108934c2009-12-18 00:01:26 +0000811}
812let Defs = [ESP], Uses = [ESP, EFLAGS], mayStore = 1, neverHasSideEffects=1 in {
Dan Gohmane5e4ff92010-05-20 16:16:00 +0000813def PUSHF16 : I<0x9C, RawFrm, (outs), (ins), "pushf{w}", []>, OpSize;
814def PUSHF32 : I<0x9C, RawFrm, (outs), (ins), "pushf{l|d}", []>,
815 Requires<[In32BitMode]>;
Sean Callanan108934c2009-12-18 00:01:26 +0000816}
Evan Cheng2f245ba2007-09-26 01:29:06 +0000817
Evan Cheng069287d2006-05-16 07:21:53 +0000818let isTwoAddress = 1 in // GR32 = bswap GR32
Chris Lattner30bf2d82004-08-10 20:17:41 +0000819 def BSWAP32r : I<0xC8, AddRegFrm,
Evan Cheng64d80e32007-07-19 01:14:50 +0000820 (outs GR32:$dst), (ins GR32:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000821 "bswap{l}\t$dst",
Evan Cheng069287d2006-05-16 07:21:53 +0000822 [(set GR32:$dst, (bswap GR32:$src))]>, TB;
Chris Lattner1cca5e32003-08-03 21:54:21 +0000823
Chris Lattner1cca5e32003-08-03 21:54:21 +0000824
Evan Cheng18efe262007-12-14 02:13:44 +0000825// Bit scan instructions.
826let Defs = [EFLAGS] in {
Evan Chengfd9e4732007-12-14 18:49:43 +0000827def BSF16rr : I<0xBC, MRMSrcReg, (outs GR16:$dst), (ins GR16:$src),
Dan Gohman1a8001e2007-12-14 15:10:00 +0000828 "bsf{w}\t{$src, $dst|$dst, $src}",
Kevin Enderby9ac72822010-04-28 23:20:40 +0000829 [(set GR16:$dst, EFLAGS, (X86bsf GR16:$src))]>, TB, OpSize;
Evan Cheng18efe262007-12-14 02:13:44 +0000830def BSF16rm : I<0xBC, MRMSrcMem, (outs GR16:$dst), (ins i16mem:$src),
Dan Gohman1a8001e2007-12-14 15:10:00 +0000831 "bsf{w}\t{$src, $dst|$dst, $src}",
Kevin Enderby9ac72822010-04-28 23:20:40 +0000832 [(set GR16:$dst, EFLAGS, (X86bsf (loadi16 addr:$src)))]>, TB,
833 OpSize;
Evan Chengfd9e4732007-12-14 18:49:43 +0000834def BSF32rr : I<0xBC, MRMSrcReg, (outs GR32:$dst), (ins GR32:$src),
Dan Gohman1a8001e2007-12-14 15:10:00 +0000835 "bsf{l}\t{$src, $dst|$dst, $src}",
Chris Lattnerd486d772010-03-28 05:07:17 +0000836 [(set GR32:$dst, EFLAGS, (X86bsf GR32:$src))]>, TB;
Evan Cheng18efe262007-12-14 02:13:44 +0000837def BSF32rm : I<0xBC, MRMSrcMem, (outs GR32:$dst), (ins i32mem:$src),
Dan Gohman1a8001e2007-12-14 15:10:00 +0000838 "bsf{l}\t{$src, $dst|$dst, $src}",
Chris Lattnerd486d772010-03-28 05:07:17 +0000839 [(set GR32:$dst, EFLAGS, (X86bsf (loadi32 addr:$src)))]>, TB;
Evan Cheng18efe262007-12-14 02:13:44 +0000840
Evan Chengfd9e4732007-12-14 18:49:43 +0000841def BSR16rr : I<0xBD, MRMSrcReg, (outs GR16:$dst), (ins GR16:$src),
Dan Gohman1a8001e2007-12-14 15:10:00 +0000842 "bsr{w}\t{$src, $dst|$dst, $src}",
Kevin Enderby9ac72822010-04-28 23:20:40 +0000843 [(set GR16:$dst, EFLAGS, (X86bsr GR16:$src))]>, TB, OpSize;
Evan Cheng18efe262007-12-14 02:13:44 +0000844def BSR16rm : I<0xBD, MRMSrcMem, (outs GR16:$dst), (ins i16mem:$src),
Dan Gohman1a8001e2007-12-14 15:10:00 +0000845 "bsr{w}\t{$src, $dst|$dst, $src}",
Kevin Enderby9ac72822010-04-28 23:20:40 +0000846 [(set GR16:$dst, EFLAGS, (X86bsr (loadi16 addr:$src)))]>, TB,
847 OpSize;
Evan Chengfd9e4732007-12-14 18:49:43 +0000848def BSR32rr : I<0xBD, MRMSrcReg, (outs GR32:$dst), (ins GR32:$src),
Dan Gohman1a8001e2007-12-14 15:10:00 +0000849 "bsr{l}\t{$src, $dst|$dst, $src}",
Chris Lattnerd486d772010-03-28 05:07:17 +0000850 [(set GR32:$dst, EFLAGS, (X86bsr GR32:$src))]>, TB;
Evan Cheng18efe262007-12-14 02:13:44 +0000851def BSR32rm : I<0xBD, MRMSrcMem, (outs GR32:$dst), (ins i32mem:$src),
Dan Gohman1a8001e2007-12-14 15:10:00 +0000852 "bsr{l}\t{$src, $dst|$dst, $src}",
Chris Lattnerd486d772010-03-28 05:07:17 +0000853 [(set GR32:$dst, EFLAGS, (X86bsr (loadi32 addr:$src)))]>, TB;
Evan Cheng18efe262007-12-14 02:13:44 +0000854} // Defs = [EFLAGS]
855
Chris Lattnerba7e7562008-01-10 07:59:24 +0000856let neverHasSideEffects = 1 in
Chris Lattner3a173df2004-10-03 20:35:00 +0000857def LEA16r : I<0x8D, MRMSrcMem,
Evan Cheng15b0d972009-12-12 18:51:56 +0000858 (outs GR16:$dst), (ins lea32mem:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000859 "lea{w}\t{$src|$dst}, {$dst|$src}", []>, OpSize;
Evan Chenge771ebd2008-03-27 01:41:09 +0000860let isReMaterializable = 1 in
Chris Lattner3a173df2004-10-03 20:35:00 +0000861def LEA32r : I<0x8D, MRMSrcMem,
Evan Cheng64d80e32007-07-19 01:14:50 +0000862 (outs GR32:$dst), (ins lea32mem:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000863 "lea{l}\t{$src|$dst}, {$dst|$src}",
Evan Cheng25ab6902006-09-08 06:48:29 +0000864 [(set GR32:$dst, lea32addr:$src)]>, Requires<[In32BitMode]>;
Chris Lattner1cca5e32003-08-03 21:54:21 +0000865
Kevin Enderby12ce0de2010-02-03 21:04:42 +0000866let Defs = [ECX,EDI,ESI], Uses = [ECX,EDI,ESI], isCodeGenOnly = 1 in {
Evan Cheng64d80e32007-07-19 01:14:50 +0000867def REP_MOVSB : I<0xA4, RawFrm, (outs), (ins), "{rep;movsb|rep movsb}",
Evan Cheng071a2792007-09-11 19:55:27 +0000868 [(X86rep_movs i8)]>, REP;
Evan Cheng64d80e32007-07-19 01:14:50 +0000869def REP_MOVSW : I<0xA5, RawFrm, (outs), (ins), "{rep;movsw|rep movsw}",
Evan Cheng071a2792007-09-11 19:55:27 +0000870 [(X86rep_movs i16)]>, REP, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +0000871def REP_MOVSD : I<0xA5, RawFrm, (outs), (ins), "{rep;movsl|rep movsd}",
Evan Cheng071a2792007-09-11 19:55:27 +0000872 [(X86rep_movs i32)]>, REP;
873}
Chris Lattner915e5e52004-02-12 17:53:22 +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,ESI], Uses = [EDI,ESI,EFLAGS] in {
877def MOVSB : I<0xA4, RawFrm, (outs), (ins), "{movsb}", []>;
878def MOVSW : I<0xA5, RawFrm, (outs), (ins), "{movsw}", []>, OpSize;
879def MOVSD : I<0xA5, RawFrm, (outs), (ins), "{movsl|movsd}", []>;
880}
881
882let Defs = [ECX,EDI], Uses = [AL,ECX,EDI], isCodeGenOnly = 1 in
Evan Cheng64d80e32007-07-19 01:14:50 +0000883def REP_STOSB : I<0xAA, RawFrm, (outs), (ins), "{rep;stosb|rep stosb}",
Evan Cheng071a2792007-09-11 19:55:27 +0000884 [(X86rep_stos i8)]>, REP;
Kevin Enderby12ce0de2010-02-03 21:04:42 +0000885let Defs = [ECX,EDI], Uses = [AX,ECX,EDI], isCodeGenOnly = 1 in
Evan Cheng64d80e32007-07-19 01:14:50 +0000886def REP_STOSW : I<0xAB, RawFrm, (outs), (ins), "{rep;stosw|rep stosw}",
Evan Cheng071a2792007-09-11 19:55:27 +0000887 [(X86rep_stos i16)]>, REP, OpSize;
Kevin Enderby12ce0de2010-02-03 21:04:42 +0000888let Defs = [ECX,EDI], Uses = [EAX,ECX,EDI], isCodeGenOnly = 1 in
Evan Cheng64d80e32007-07-19 01:14:50 +0000889def REP_STOSD : I<0xAB, RawFrm, (outs), (ins), "{rep;stosl|rep stosd}",
Evan Cheng071a2792007-09-11 19:55:27 +0000890 [(X86rep_stos i32)]>, REP;
Chris Lattner30bf2d82004-08-10 20:17:41 +0000891
Kevin Enderby12ce0de2010-02-03 21:04:42 +0000892// These uses the DF flag in the EFLAGS register to inc or dec EDI and ESI
893let Defs = [EDI], Uses = [AL,EDI,EFLAGS] in
894def STOSB : I<0xAA, RawFrm, (outs), (ins), "{stosb}", []>;
895let Defs = [EDI], Uses = [AX,EDI,EFLAGS] in
896def STOSW : I<0xAB, RawFrm, (outs), (ins), "{stosw}", []>, OpSize;
897let Defs = [EDI], Uses = [EAX,EDI,EFLAGS] in
898def STOSD : I<0xAB, RawFrm, (outs), (ins), "{stosl|stosd}", []>;
899
Sean Callanana82e4652009-09-12 00:37:19 +0000900def SCAS8 : I<0xAE, RawFrm, (outs), (ins), "scas{b}", []>;
901def SCAS16 : I<0xAF, RawFrm, (outs), (ins), "scas{w}", []>, OpSize;
902def SCAS32 : I<0xAF, RawFrm, (outs), (ins), "scas{l}", []>;
903
Sean Callanan6f8f4622009-09-12 02:25:20 +0000904def CMPS8 : I<0xA6, RawFrm, (outs), (ins), "cmps{b}", []>;
905def CMPS16 : I<0xA7, RawFrm, (outs), (ins), "cmps{w}", []>, OpSize;
906def CMPS32 : I<0xA7, RawFrm, (outs), (ins), "cmps{l}", []>;
907
Evan Cheng071a2792007-09-11 19:55:27 +0000908let Defs = [RAX, RDX] in
Evan Cheng64d80e32007-07-19 01:14:50 +0000909def RDTSC : I<0x31, RawFrm, (outs), (ins), "rdtsc", [(X86rdtsc)]>,
Evan Cheng071a2792007-09-11 19:55:27 +0000910 TB;
Chris Lattnerb89abef2004-02-14 04:45:37 +0000911
Sean Callanancebe9552010-02-13 02:06:11 +0000912let Defs = [RAX, RCX, RDX] in
913def RDTSCP : I<0x01, MRM_F9, (outs), (ins), "rdtscp", []>, TB;
914
Dan Gohmaneffc8c52010-05-14 16:46:02 +0000915let isTerminator = 1, isBarrier = 1, hasCtrlDep = 1 in {
Chris Lattnerda68d302008-01-15 21:58:22 +0000916def TRAP : I<0x0B, RawFrm, (outs), (ins), "ud2", [(trap)]>, TB;
Anton Korobeynikov66fac792008-01-15 07:02:33 +0000917}
918
Chris Lattner02552de2009-08-11 16:58:39 +0000919def SYSCALL : I<0x05, RawFrm,
920 (outs), (ins), "syscall", []>, TB;
921def SYSRET : I<0x07, RawFrm,
922 (outs), (ins), "sysret", []>, TB;
923def SYSENTER : I<0x34, RawFrm,
924 (outs), (ins), "sysenter", []>, TB;
925def SYSEXIT : I<0x35, RawFrm,
926 (outs), (ins), "sysexit", []>, TB;
927
Sean Callanan2a46f362009-09-12 02:52:41 +0000928def WAIT : I<0x9B, RawFrm, (outs), (ins), "wait", []>;
Chris Lattner02552de2009-08-11 16:58:39 +0000929
930
Chris Lattner1cca5e32003-08-03 21:54:21 +0000931//===----------------------------------------------------------------------===//
John Criswell4ffff9e2004-04-08 20:31:47 +0000932// Input/Output Instructions...
933//
Evan Cheng071a2792007-09-11 19:55:27 +0000934let Defs = [AL], Uses = [DX] in
Evan Cheng64d80e32007-07-19 01:14:50 +0000935def IN8rr : I<0xEC, RawFrm, (outs), (ins),
Evan Cheng071a2792007-09-11 19:55:27 +0000936 "in{b}\t{%dx, %al|%AL, %DX}", []>;
937let Defs = [AX], Uses = [DX] in
Evan Cheng64d80e32007-07-19 01:14:50 +0000938def IN16rr : I<0xED, RawFrm, (outs), (ins),
Evan Cheng071a2792007-09-11 19:55:27 +0000939 "in{w}\t{%dx, %ax|%AX, %DX}", []>, OpSize;
940let Defs = [EAX], Uses = [DX] in
Evan Cheng64d80e32007-07-19 01:14:50 +0000941def IN32rr : I<0xED, RawFrm, (outs), (ins),
Evan Cheng071a2792007-09-11 19:55:27 +0000942 "in{l}\t{%dx, %eax|%EAX, %DX}", []>;
John Criswell4ffff9e2004-04-08 20:31:47 +0000943
Evan Cheng071a2792007-09-11 19:55:27 +0000944let Defs = [AL] in
Evan Cheng64d80e32007-07-19 01:14:50 +0000945def IN8ri : Ii8<0xE4, RawFrm, (outs), (ins i16i8imm:$port),
Evan Cheng071a2792007-09-11 19:55:27 +0000946 "in{b}\t{$port, %al|%AL, $port}", []>;
947let Defs = [AX] in
Evan Cheng64d80e32007-07-19 01:14:50 +0000948def IN16ri : Ii8<0xE5, RawFrm, (outs), (ins i16i8imm:$port),
Evan Cheng071a2792007-09-11 19:55:27 +0000949 "in{w}\t{$port, %ax|%AX, $port}", []>, OpSize;
950let Defs = [EAX] in
Evan Cheng64d80e32007-07-19 01:14:50 +0000951def IN32ri : Ii8<0xE5, RawFrm, (outs), (ins i16i8imm:$port),
Evan Cheng071a2792007-09-11 19:55:27 +0000952 "in{l}\t{$port, %eax|%EAX, $port}", []>;
Chris Lattner440bbc22004-04-13 17:19:31 +0000953
Evan Cheng071a2792007-09-11 19:55:27 +0000954let Uses = [DX, AL] in
Evan Cheng64d80e32007-07-19 01:14:50 +0000955def OUT8rr : I<0xEE, RawFrm, (outs), (ins),
Evan Cheng071a2792007-09-11 19:55:27 +0000956 "out{b}\t{%al, %dx|%DX, %AL}", []>;
957let Uses = [DX, AX] in
Evan Cheng64d80e32007-07-19 01:14:50 +0000958def OUT16rr : I<0xEF, RawFrm, (outs), (ins),
Evan Cheng071a2792007-09-11 19:55:27 +0000959 "out{w}\t{%ax, %dx|%DX, %AX}", []>, OpSize;
960let Uses = [DX, EAX] in
Evan Cheng64d80e32007-07-19 01:14:50 +0000961def OUT32rr : I<0xEF, RawFrm, (outs), (ins),
Evan Cheng071a2792007-09-11 19:55:27 +0000962 "out{l}\t{%eax, %dx|%DX, %EAX}", []>;
Chris Lattnerffff7082004-08-01 07:44:35 +0000963
Evan Cheng071a2792007-09-11 19:55:27 +0000964let Uses = [AL] in
Evan Cheng64d80e32007-07-19 01:14:50 +0000965def OUT8ir : Ii8<0xE6, RawFrm, (outs), (ins i16i8imm:$port),
Evan Cheng071a2792007-09-11 19:55:27 +0000966 "out{b}\t{%al, $port|$port, %AL}", []>;
967let Uses = [AX] in
Evan Cheng64d80e32007-07-19 01:14:50 +0000968def OUT16ir : Ii8<0xE7, RawFrm, (outs), (ins i16i8imm:$port),
Evan Cheng071a2792007-09-11 19:55:27 +0000969 "out{w}\t{%ax, $port|$port, %AX}", []>, OpSize;
970let Uses = [EAX] in
Evan Cheng64d80e32007-07-19 01:14:50 +0000971def OUT32ir : Ii8<0xE7, RawFrm, (outs), (ins i16i8imm:$port),
Evan Cheng071a2792007-09-11 19:55:27 +0000972 "out{l}\t{%eax, $port|$port, %EAX}", []>;
John Criswell4ffff9e2004-04-08 20:31:47 +0000973
Sean Callanan108934c2009-12-18 00:01:26 +0000974def IN8 : I<0x6C, RawFrm, (outs), (ins),
975 "ins{b}", []>;
976def IN16 : I<0x6D, RawFrm, (outs), (ins),
977 "ins{w}", []>, OpSize;
978def IN32 : I<0x6D, RawFrm, (outs), (ins),
979 "ins{l}", []>;
980
John Criswell4ffff9e2004-04-08 20:31:47 +0000981//===----------------------------------------------------------------------===//
Chris Lattner1cca5e32003-08-03 21:54:21 +0000982// Move Instructions...
983//
Chris Lattnerba7e7562008-01-10 07:59:24 +0000984let neverHasSideEffects = 1 in {
Evan Cheng64d80e32007-07-19 01:14:50 +0000985def MOV8rr : I<0x88, MRMDestReg, (outs GR8 :$dst), (ins GR8 :$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000986 "mov{b}\t{$src, $dst|$dst, $src}", []>;
Evan Cheng64d80e32007-07-19 01:14:50 +0000987def MOV16rr : I<0x89, MRMDestReg, (outs GR16:$dst), (ins GR16:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000988 "mov{w}\t{$src, $dst|$dst, $src}", []>, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +0000989def MOV32rr : I<0x89, MRMDestReg, (outs GR32:$dst), (ins GR32:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000990 "mov{l}\t{$src, $dst|$dst, $src}", []>;
Chris Lattnerba7e7562008-01-10 07:59:24 +0000991}
Evan Cheng359e9372008-06-18 08:13:07 +0000992let isReMaterializable = 1, isAsCheapAsAMove = 1 in {
Evan Cheng64d80e32007-07-19 01:14:50 +0000993def MOV8ri : Ii8 <0xB0, AddRegFrm, (outs GR8 :$dst), (ins i8imm :$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000994 "mov{b}\t{$src, $dst|$dst, $src}",
Evan Cheng069287d2006-05-16 07:21:53 +0000995 [(set GR8:$dst, imm:$src)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +0000996def MOV16ri : Ii16<0xB8, AddRegFrm, (outs GR16:$dst), (ins i16imm:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000997 "mov{w}\t{$src, $dst|$dst, $src}",
Evan Cheng069287d2006-05-16 07:21:53 +0000998 [(set GR16:$dst, imm:$src)]>, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +0000999def MOV32ri : Ii32<0xB8, AddRegFrm, (outs GR32:$dst), (ins i32imm:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001000 "mov{l}\t{$src, $dst|$dst, $src}",
Evan Cheng069287d2006-05-16 07:21:53 +00001001 [(set GR32:$dst, imm:$src)]>;
Dan Gohmand45eddd2007-06-26 00:48:07 +00001002}
Kevin Enderby12ce0de2010-02-03 21:04:42 +00001003
Evan Cheng64d80e32007-07-19 01:14:50 +00001004def MOV8mi : Ii8 <0xC6, MRM0m, (outs), (ins i8mem :$dst, i8imm :$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001005 "mov{b}\t{$src, $dst|$dst, $src}",
Evan Chengb51a0592005-12-10 00:48:20 +00001006 [(store (i8 imm:$src), addr:$dst)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00001007def MOV16mi : Ii16<0xC7, MRM0m, (outs), (ins i16mem:$dst, i16imm:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001008 "mov{w}\t{$src, $dst|$dst, $src}",
Evan Chengb51a0592005-12-10 00:48:20 +00001009 [(store (i16 imm:$src), addr:$dst)]>, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00001010def MOV32mi : Ii32<0xC7, MRM0m, (outs), (ins i32mem:$dst, i32imm:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001011 "mov{l}\t{$src, $dst|$dst, $src}",
Evan Chengb51a0592005-12-10 00:48:20 +00001012 [(store (i32 imm:$src), addr:$dst)]>;
Chris Lattner1cca5e32003-08-03 21:54:21 +00001013
Chris Lattnerb5505d02010-05-13 00:02:47 +00001014/// moffs8, moffs16 and moffs32 versions of moves. The immediate is a
1015/// 32-bit offset from the PC. These are only valid in x86-32 mode.
Chris Lattner2745f6e2010-05-12 22:48:24 +00001016def MOV8o8a : Ii32 <0xA0, RawFrm, (outs), (ins offset8:$src),
Sean Callanan2f34a132009-09-10 18:33:42 +00001017 "mov{b}\t{$src, %al|%al, $src}", []>;
Chris Lattner2745f6e2010-05-12 22:48:24 +00001018def MOV16o16a : Ii32 <0xA1, RawFrm, (outs), (ins offset16:$src),
Sean Callanan2f34a132009-09-10 18:33:42 +00001019 "mov{w}\t{$src, %ax|%ax, $src}", []>, OpSize;
Sean Callanan108934c2009-12-18 00:01:26 +00001020def MOV32o32a : Ii32 <0xA1, RawFrm, (outs), (ins offset32:$src),
Sean Callanan2f34a132009-09-10 18:33:42 +00001021 "mov{l}\t{$src, %eax|%eax, $src}", []>;
Chris Lattner2745f6e2010-05-12 22:48:24 +00001022def MOV8ao8 : Ii32 <0xA2, RawFrm, (outs offset8:$dst), (ins),
Sean Callanan2f34a132009-09-10 18:33:42 +00001023 "mov{b}\t{%al, $dst|$dst, %al}", []>;
Chris Lattner2745f6e2010-05-12 22:48:24 +00001024def MOV16ao16 : Ii32 <0xA3, RawFrm, (outs offset16:$dst), (ins),
Sean Callanan2f34a132009-09-10 18:33:42 +00001025 "mov{w}\t{%ax, $dst|$dst, %ax}", []>, OpSize;
Sean Callanan108934c2009-12-18 00:01:26 +00001026def MOV32ao32 : Ii32 <0xA3, RawFrm, (outs offset32:$dst), (ins),
Sean Callanan2f34a132009-09-10 18:33:42 +00001027 "mov{l}\t{%eax, $dst|$dst, %eax}", []>;
Chris Lattnerb5505d02010-05-13 00:02:47 +00001028
Sean Callanan38fee0e2009-09-15 18:47:29 +00001029// Moves to and from segment registers
1030def MOV16rs : I<0x8C, MRMDestReg, (outs GR16:$dst), (ins SEGMENT_REG:$src),
1031 "mov{w}\t{$src, $dst|$dst, $src}", []>;
1032def MOV16ms : I<0x8C, MRMDestMem, (outs i16mem:$dst), (ins SEGMENT_REG:$src),
1033 "mov{w}\t{$src, $dst|$dst, $src}", []>;
1034def MOV16sr : I<0x8E, MRMSrcReg, (outs SEGMENT_REG:$dst), (ins GR16:$src),
1035 "mov{w}\t{$src, $dst|$dst, $src}", []>;
1036def MOV16sm : I<0x8E, MRMSrcMem, (outs SEGMENT_REG:$dst), (ins i16mem:$src),
1037 "mov{w}\t{$src, $dst|$dst, $src}", []>;
1038
Sean Callanan108934c2009-12-18 00:01:26 +00001039def MOV8rr_REV : I<0x8A, MRMSrcReg, (outs GR8:$dst), (ins GR8:$src),
1040 "mov{b}\t{$src, $dst|$dst, $src}", []>;
1041def MOV16rr_REV : I<0x8B, MRMSrcReg, (outs GR16:$dst), (ins GR16:$src),
1042 "mov{w}\t{$src, $dst|$dst, $src}", []>, OpSize;
1043def MOV32rr_REV : I<0x8B, MRMSrcReg, (outs GR32:$dst), (ins GR32:$src),
1044 "mov{l}\t{$src, $dst|$dst, $src}", []>;
1045
Dan Gohmanbc9d98b2010-02-27 23:47:46 +00001046let canFoldAsLoad = 1, isReMaterializable = 1 in {
Evan Cheng64d80e32007-07-19 01:14:50 +00001047def MOV8rm : I<0x8A, MRMSrcMem, (outs GR8 :$dst), (ins i8mem :$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001048 "mov{b}\t{$src, $dst|$dst, $src}",
Chris Lattnerc2406f22009-04-10 00:16:23 +00001049 [(set GR8:$dst, (loadi8 addr:$src))]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00001050def MOV16rm : I<0x8B, MRMSrcMem, (outs GR16:$dst), (ins i16mem:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001051 "mov{w}\t{$src, $dst|$dst, $src}",
Chris Lattnerc2406f22009-04-10 00:16:23 +00001052 [(set GR16:$dst, (loadi16 addr:$src))]>, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00001053def MOV32rm : I<0x8B, MRMSrcMem, (outs GR32:$dst), (ins i32mem:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001054 "mov{l}\t{$src, $dst|$dst, $src}",
Chris Lattnerc2406f22009-04-10 00:16:23 +00001055 [(set GR32:$dst, (loadi32 addr:$src))]>;
Evan Cheng2f394262007-08-30 05:49:43 +00001056}
Chris Lattner1cca5e32003-08-03 21:54:21 +00001057
Evan Cheng64d80e32007-07-19 01:14:50 +00001058def MOV8mr : I<0x88, MRMDestMem, (outs), (ins i8mem :$dst, GR8 :$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001059 "mov{b}\t{$src, $dst|$dst, $src}",
Evan Cheng069287d2006-05-16 07:21:53 +00001060 [(store GR8:$src, addr:$dst)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00001061def MOV16mr : I<0x89, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001062 "mov{w}\t{$src, $dst|$dst, $src}",
Evan Cheng069287d2006-05-16 07:21:53 +00001063 [(store GR16:$src, addr:$dst)]>, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00001064def MOV32mr : I<0x89, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001065 "mov{l}\t{$src, $dst|$dst, $src}",
Evan Cheng069287d2006-05-16 07:21:53 +00001066 [(store GR32:$src, addr:$dst)]>;
Dan Gohman21e3dfb2009-04-13 16:09:41 +00001067
Evan Chengf48ef032010-03-14 03:48:46 +00001068/// Versions of MOV32rr, MOV32rm, and MOV32mr for i32mem_TC and GR32_TC.
1069let neverHasSideEffects = 1 in
1070def MOV32rr_TC : I<0x89, MRMDestReg, (outs GR32_TC:$dst), (ins GR32_TC:$src),
1071 "mov{l}\t{$src, $dst|$dst, $src}", []>;
1072
1073let mayLoad = 1,
1074 canFoldAsLoad = 1, isReMaterializable = 1 in
1075def MOV32rm_TC : I<0x8B, MRMSrcMem, (outs GR32_TC:$dst), (ins i32mem_TC:$src),
1076 "mov{l}\t{$src, $dst|$dst, $src}",
1077 []>;
1078
1079let mayStore = 1 in
1080def MOV32mr_TC : I<0x89, MRMDestMem, (outs), (ins i32mem_TC:$dst, GR32_TC:$src),
1081 "mov{l}\t{$src, $dst|$dst, $src}",
1082 []>;
1083
Dan Gohman4af325d2009-04-27 16:41:36 +00001084// Versions of MOV8rr, MOV8mr, and MOV8rm that use i8mem_NOREX and GR8_NOREX so
1085// that they can be used for copying and storing h registers, which can't be
1086// encoded when a REX prefix is present.
Dan Gohman6d9305c2009-04-15 00:04:23 +00001087let neverHasSideEffects = 1 in
Dan Gohmandf7dfc72009-04-15 19:48:57 +00001088def MOV8rr_NOREX : I<0x88, MRMDestReg,
1089 (outs GR8_NOREX:$dst), (ins GR8_NOREX:$src),
Dan Gohman6d9305c2009-04-15 00:04:23 +00001090 "mov{b}\t{$src, $dst|$dst, $src} # NOREX", []>;
Evan Cheng8c147402009-04-30 00:58:57 +00001091let mayStore = 1 in
Dan Gohman6d9305c2009-04-15 00:04:23 +00001092def MOV8mr_NOREX : I<0x88, MRMDestMem,
1093 (outs), (ins i8mem_NOREX:$dst, GR8_NOREX:$src),
1094 "mov{b}\t{$src, $dst|$dst, $src} # NOREX", []>;
Evan Cheng8c147402009-04-30 00:58:57 +00001095let mayLoad = 1,
Dan Gohmanbc9d98b2010-02-27 23:47:46 +00001096 canFoldAsLoad = 1, isReMaterializable = 1 in
Dan Gohman4af325d2009-04-27 16:41:36 +00001097def MOV8rm_NOREX : I<0x8A, MRMSrcMem,
1098 (outs GR8_NOREX:$dst), (ins i8mem_NOREX:$src),
1099 "mov{b}\t{$src, $dst|$dst, $src} # NOREX", []>;
Dan Gohman21e3dfb2009-04-13 16:09:41 +00001100
Sean Callanan108934c2009-12-18 00:01:26 +00001101// Moves to and from debug registers
1102def MOV32rd : I<0x21, MRMDestReg, (outs GR32:$dst), (ins DEBUG_REG:$src),
1103 "mov{l}\t{$src, $dst|$dst, $src}", []>, TB;
1104def MOV32dr : I<0x23, MRMSrcReg, (outs DEBUG_REG:$dst), (ins GR32:$src),
1105 "mov{l}\t{$src, $dst|$dst, $src}", []>, TB;
1106
1107// Moves to and from control registers
Sean Callanan1a8b7892010-05-06 20:59:00 +00001108def MOV32rc : I<0x20, MRMDestReg, (outs GR32:$dst), (ins CONTROL_REG:$src),
1109 "mov{l}\t{$src, $dst|$dst, $src}", []>, TB;
1110def MOV32cr : I<0x22, MRMSrcReg, (outs CONTROL_REG:$dst), (ins GR32:$src),
1111 "mov{l}\t{$src, $dst|$dst, $src}", []>, TB;
Sean Callanan108934c2009-12-18 00:01:26 +00001112
Chris Lattner1cca5e32003-08-03 21:54:21 +00001113//===----------------------------------------------------------------------===//
1114// Fixed-Register Multiplication and Division Instructions...
1115//
Chris Lattner1cca5e32003-08-03 21:54:21 +00001116
Chris Lattnerc8f45872003-08-04 04:59:56 +00001117// Extra precision multiplication
Jakob Stoklund Olesen3cfe0102010-03-04 20:42:07 +00001118
1119// AL is really implied by AX, by the registers in Defs must match the
1120// SDNode results (i8, i32).
1121let Defs = [AL,EFLAGS,AX], Uses = [AL] in
Dan Gohmanb1576f52007-07-31 20:11:57 +00001122def MUL8r : I<0xF6, MRM4r, (outs), (ins GR8:$src), "mul{b}\t$src",
Evan Chengcf74a7c2006-01-15 10:05:20 +00001123 // FIXME: Used for 8-bit mul, ignore result upper 8 bits.
1124 // This probably ought to be moved to a def : Pat<> if the
1125 // syntax can be accepted.
Bill Wendlingd350e022008-12-12 21:15:41 +00001126 [(set AL, (mul AL, GR8:$src)),
1127 (implicit EFLAGS)]>; // AL,AH = AL*GR8
1128
Chris Lattnera731c9f2008-01-11 07:18:17 +00001129let Defs = [AX,DX,EFLAGS], Uses = [AX], neverHasSideEffects = 1 in
Bill Wendlingd350e022008-12-12 21:15:41 +00001130def MUL16r : I<0xF7, MRM4r, (outs), (ins GR16:$src),
1131 "mul{w}\t$src",
1132 []>, OpSize; // AX,DX = AX*GR16
1133
Chris Lattnera731c9f2008-01-11 07:18:17 +00001134let Defs = [EAX,EDX,EFLAGS], Uses = [EAX], neverHasSideEffects = 1 in
Bill Wendlingd350e022008-12-12 21:15:41 +00001135def MUL32r : I<0xF7, MRM4r, (outs), (ins GR32:$src),
1136 "mul{l}\t$src",
1137 []>; // EAX,EDX = EAX*GR32
1138
Jakob Stoklund Olesen3cfe0102010-03-04 20:42:07 +00001139let Defs = [AL,EFLAGS,AX], Uses = [AL] in
Evan Cheng64d80e32007-07-19 01:14:50 +00001140def MUL8m : I<0xF6, MRM4m, (outs), (ins i8mem :$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001141 "mul{b}\t$src",
Evan Chengcf74a7c2006-01-15 10:05:20 +00001142 // FIXME: Used for 8-bit mul, ignore result upper 8 bits.
1143 // This probably ought to be moved to a def : Pat<> if the
1144 // syntax can be accepted.
Bill Wendlingd350e022008-12-12 21:15:41 +00001145 [(set AL, (mul AL, (loadi8 addr:$src))),
1146 (implicit EFLAGS)]>; // AL,AH = AL*[mem8]
1147
Chris Lattnerba7e7562008-01-10 07:59:24 +00001148let mayLoad = 1, neverHasSideEffects = 1 in {
Evan Cheng24f2ea32007-09-14 21:48:26 +00001149let Defs = [AX,DX,EFLAGS], Uses = [AX] in
Evan Cheng64d80e32007-07-19 01:14:50 +00001150def MUL16m : I<0xF7, MRM4m, (outs), (ins i16mem:$src),
Bill Wendlingd350e022008-12-12 21:15:41 +00001151 "mul{w}\t$src",
1152 []>, OpSize; // AX,DX = AX*[mem16]
1153
Evan Cheng24f2ea32007-09-14 21:48:26 +00001154let Defs = [EAX,EDX,EFLAGS], Uses = [EAX] in
Evan Cheng64d80e32007-07-19 01:14:50 +00001155def MUL32m : I<0xF7, MRM4m, (outs), (ins i32mem:$src),
Bill Wendlingd350e022008-12-12 21:15:41 +00001156 "mul{l}\t$src",
1157 []>; // EAX,EDX = EAX*[mem32]
Chris Lattnerba7e7562008-01-10 07:59:24 +00001158}
Chris Lattner1cca5e32003-08-03 21:54:21 +00001159
Chris Lattnerba7e7562008-01-10 07:59:24 +00001160let neverHasSideEffects = 1 in {
Jakob Stoklund Olesen3cfe0102010-03-04 20:42:07 +00001161let Defs = [AL,EFLAGS,AX], Uses = [AL] in
Evan Cheng071a2792007-09-11 19:55:27 +00001162def IMUL8r : I<0xF6, MRM5r, (outs), (ins GR8:$src), "imul{b}\t$src", []>;
1163 // AL,AH = AL*GR8
Evan Cheng24f2ea32007-09-14 21:48:26 +00001164let Defs = [AX,DX,EFLAGS], Uses = [AX] in
Dan Gohmanb1576f52007-07-31 20:11:57 +00001165def IMUL16r : I<0xF7, MRM5r, (outs), (ins GR16:$src), "imul{w}\t$src", []>,
Evan Cheng071a2792007-09-11 19:55:27 +00001166 OpSize; // AX,DX = AX*GR16
Evan Cheng24f2ea32007-09-14 21:48:26 +00001167let Defs = [EAX,EDX,EFLAGS], Uses = [EAX] in
Evan Cheng071a2792007-09-11 19:55:27 +00001168def IMUL32r : I<0xF7, MRM5r, (outs), (ins GR32:$src), "imul{l}\t$src", []>;
1169 // EAX,EDX = EAX*GR32
Chris Lattnerba7e7562008-01-10 07:59:24 +00001170let mayLoad = 1 in {
Jakob Stoklund Olesen3cfe0102010-03-04 20:42:07 +00001171let Defs = [AL,EFLAGS,AX], Uses = [AL] in
Evan Cheng64d80e32007-07-19 01:14:50 +00001172def IMUL8m : I<0xF6, MRM5m, (outs), (ins i8mem :$src),
Evan Cheng071a2792007-09-11 19:55:27 +00001173 "imul{b}\t$src", []>; // AL,AH = AL*[mem8]
Evan Cheng24f2ea32007-09-14 21:48:26 +00001174let Defs = [AX,DX,EFLAGS], Uses = [AX] in
Evan Cheng64d80e32007-07-19 01:14:50 +00001175def IMUL16m : I<0xF7, MRM5m, (outs), (ins i16mem:$src),
Evan Cheng071a2792007-09-11 19:55:27 +00001176 "imul{w}\t$src", []>, OpSize; // AX,DX = AX*[mem16]
Eli Friedmanba7b1c42009-12-26 20:08:30 +00001177let Defs = [EAX,EDX,EFLAGS], Uses = [EAX] in
Evan Cheng64d80e32007-07-19 01:14:50 +00001178def IMUL32m : I<0xF7, MRM5m, (outs), (ins i32mem:$src),
Evan Cheng071a2792007-09-11 19:55:27 +00001179 "imul{l}\t$src", []>; // EAX,EDX = EAX*[mem32]
Chris Lattnerba7e7562008-01-10 07:59:24 +00001180}
Dan Gohmanc99da132008-11-18 21:29:14 +00001181} // neverHasSideEffects
Chris Lattner1e6a7152005-04-06 04:19:22 +00001182
Chris Lattnerc8f45872003-08-04 04:59:56 +00001183// unsigned division/remainder
Jakob Stoklund Olesen3cfe0102010-03-04 20:42:07 +00001184let Defs = [AL,EFLAGS,AX], Uses = [AX] in
Sean Callanan108934c2009-12-18 00:01:26 +00001185def DIV8r : I<0xF6, MRM6r, (outs), (ins GR8:$src), // AX/r8 = AL,AH
Evan Cheng071a2792007-09-11 19:55:27 +00001186 "div{b}\t$src", []>;
Evan Cheng24f2ea32007-09-14 21:48:26 +00001187let Defs = [AX,DX,EFLAGS], Uses = [AX,DX] in
Sean Callanan108934c2009-12-18 00:01:26 +00001188def DIV16r : I<0xF7, MRM6r, (outs), (ins GR16:$src), // DX:AX/r16 = AX,DX
Evan Cheng071a2792007-09-11 19:55:27 +00001189 "div{w}\t$src", []>, OpSize;
Evan Cheng24f2ea32007-09-14 21:48:26 +00001190let Defs = [EAX,EDX,EFLAGS], Uses = [EAX,EDX] in
Sean Callanan108934c2009-12-18 00:01:26 +00001191def DIV32r : I<0xF7, MRM6r, (outs), (ins GR32:$src), // EDX:EAX/r32 = EAX,EDX
Evan Cheng071a2792007-09-11 19:55:27 +00001192 "div{l}\t$src", []>;
Chris Lattnerba7e7562008-01-10 07:59:24 +00001193let mayLoad = 1 in {
Jakob Stoklund Olesen3cfe0102010-03-04 20:42:07 +00001194let Defs = [AL,EFLAGS,AX], Uses = [AX] in
Sean Callanan108934c2009-12-18 00:01:26 +00001195def DIV8m : I<0xF6, MRM6m, (outs), (ins i8mem:$src), // AX/[mem8] = AL,AH
Evan Cheng071a2792007-09-11 19:55:27 +00001196 "div{b}\t$src", []>;
Evan Cheng24f2ea32007-09-14 21:48:26 +00001197let Defs = [AX,DX,EFLAGS], Uses = [AX,DX] in
Sean Callanan108934c2009-12-18 00:01:26 +00001198def DIV16m : I<0xF7, MRM6m, (outs), (ins i16mem:$src), // DX:AX/[mem16] = AX,DX
Evan Cheng071a2792007-09-11 19:55:27 +00001199 "div{w}\t$src", []>, OpSize;
Evan Cheng24f2ea32007-09-14 21:48:26 +00001200let Defs = [EAX,EDX,EFLAGS], Uses = [EAX,EDX] in
Sean Callanan108934c2009-12-18 00:01:26 +00001201 // EDX:EAX/[mem32] = EAX,EDX
1202def DIV32m : I<0xF7, MRM6m, (outs), (ins i32mem:$src),
Evan Cheng071a2792007-09-11 19:55:27 +00001203 "div{l}\t$src", []>;
Chris Lattnerba7e7562008-01-10 07:59:24 +00001204}
Chris Lattner1cca5e32003-08-03 21:54:21 +00001205
Chris Lattnerfc752712004-08-01 09:52:59 +00001206// Signed division/remainder.
Jakob Stoklund Olesen3cfe0102010-03-04 20:42:07 +00001207let Defs = [AL,EFLAGS,AX], Uses = [AX] in
Sean Callanan108934c2009-12-18 00:01:26 +00001208def IDIV8r : I<0xF6, MRM7r, (outs), (ins GR8:$src), // AX/r8 = AL,AH
Evan Cheng071a2792007-09-11 19:55:27 +00001209 "idiv{b}\t$src", []>;
Evan Cheng24f2ea32007-09-14 21:48:26 +00001210let Defs = [AX,DX,EFLAGS], Uses = [AX,DX] in
Sean Callanan108934c2009-12-18 00:01:26 +00001211def IDIV16r: I<0xF7, MRM7r, (outs), (ins GR16:$src), // DX:AX/r16 = AX,DX
Evan Cheng071a2792007-09-11 19:55:27 +00001212 "idiv{w}\t$src", []>, OpSize;
Evan Cheng24f2ea32007-09-14 21:48:26 +00001213let Defs = [EAX,EDX,EFLAGS], Uses = [EAX,EDX] in
Sean Callanan108934c2009-12-18 00:01:26 +00001214def IDIV32r: I<0xF7, MRM7r, (outs), (ins GR32:$src), // EDX:EAX/r32 = EAX,EDX
Evan Cheng071a2792007-09-11 19:55:27 +00001215 "idiv{l}\t$src", []>;
Chris Lattnerba7e7562008-01-10 07:59:24 +00001216let mayLoad = 1, mayLoad = 1 in {
Jakob Stoklund Olesen3cfe0102010-03-04 20:42:07 +00001217let Defs = [AL,EFLAGS,AX], Uses = [AX] in
Sean Callanan108934c2009-12-18 00:01:26 +00001218def IDIV8m : I<0xF6, MRM7m, (outs), (ins i8mem:$src), // AX/[mem8] = AL,AH
Evan Cheng071a2792007-09-11 19:55:27 +00001219 "idiv{b}\t$src", []>;
Evan Cheng24f2ea32007-09-14 21:48:26 +00001220let Defs = [AX,DX,EFLAGS], Uses = [AX,DX] in
Sean Callanan108934c2009-12-18 00:01:26 +00001221def IDIV16m: I<0xF7, MRM7m, (outs), (ins i16mem:$src), // DX:AX/[mem16] = AX,DX
Evan Cheng071a2792007-09-11 19:55:27 +00001222 "idiv{w}\t$src", []>, OpSize;
Evan Cheng24f2ea32007-09-14 21:48:26 +00001223let Defs = [EAX,EDX,EFLAGS], Uses = [EAX,EDX] in
Sean Callanan108934c2009-12-18 00:01:26 +00001224def IDIV32m: I<0xF7, MRM7m, (outs), (ins i32mem:$src),
1225 // EDX:EAX/[mem32] = EAX,EDX
Evan Cheng071a2792007-09-11 19:55:27 +00001226 "idiv{l}\t$src", []>;
Chris Lattnerba7e7562008-01-10 07:59:24 +00001227}
Chris Lattner1cca5e32003-08-03 21:54:21 +00001228
Chris Lattner1cca5e32003-08-03 21:54:21 +00001229//===----------------------------------------------------------------------===//
Chris Lattnerba7e7562008-01-10 07:59:24 +00001230// Two address Instructions.
Chris Lattner1cca5e32003-08-03 21:54:21 +00001231//
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00001232let isTwoAddress = 1 in {
Chris Lattner1cca5e32003-08-03 21:54:21 +00001233
Alkis Evlogimenosa3f66842004-03-12 17:59:56 +00001234// Conditional moves
Evan Cheng0488db92007-09-25 01:57:46 +00001235let Uses = [EFLAGS] in {
Dan Gohmancbbea0f2009-08-27 00:14:12 +00001236
Chris Lattner314a1132010-03-14 18:31:44 +00001237let Predicates = [HasCMov] in {
Dan Gohmana4c5c332009-08-27 18:16:24 +00001238let isCommutable = 1 in {
Evan Cheng069287d2006-05-16 07:21:53 +00001239def CMOVB16rr : I<0x42, MRMSrcReg, // if <u, GR16 = GR16
Evan Cheng64d80e32007-07-19 01:14:50 +00001240 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Sean Callanan108934c2009-12-18 00:01:26 +00001241 "cmovb{w}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001242 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Chenge5f62042007-09-29 00:00:36 +00001243 X86_COND_B, EFLAGS))]>,
Evan Cheng71fb9ad2006-01-26 00:29:36 +00001244 TB, OpSize;
Evan Cheng069287d2006-05-16 07:21:53 +00001245def CMOVB32rr : I<0x42, MRMSrcReg, // if <u, GR32 = GR32
Evan Cheng64d80e32007-07-19 01:14:50 +00001246 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Sean Callanan108934c2009-12-18 00:01:26 +00001247 "cmovb{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001248 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Chenge5f62042007-09-29 00:00:36 +00001249 X86_COND_B, EFLAGS))]>,
Evan Cheng71fb9ad2006-01-26 00:29:36 +00001250 TB;
Evan Cheng069287d2006-05-16 07:21:53 +00001251def CMOVAE16rr: I<0x43, MRMSrcReg, // if >=u, GR16 = GR16
Evan Cheng64d80e32007-07-19 01:14:50 +00001252 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Sean Callanan108934c2009-12-18 00:01:26 +00001253 "cmovae{w}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001254 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Chenge5f62042007-09-29 00:00:36 +00001255 X86_COND_AE, EFLAGS))]>,
Evan Cheng71fb9ad2006-01-26 00:29:36 +00001256 TB, OpSize;
Evan Cheng069287d2006-05-16 07:21:53 +00001257def CMOVAE32rr: I<0x43, MRMSrcReg, // if >=u, GR32 = GR32
Evan Cheng64d80e32007-07-19 01:14:50 +00001258 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Sean Callanan108934c2009-12-18 00:01:26 +00001259 "cmovae{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001260 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Chenge5f62042007-09-29 00:00:36 +00001261 X86_COND_AE, EFLAGS))]>,
Evan Cheng71fb9ad2006-01-26 00:29:36 +00001262 TB;
Evan Cheng069287d2006-05-16 07:21:53 +00001263def CMOVE16rr : I<0x44, MRMSrcReg, // if ==, GR16 = GR16
Evan Cheng64d80e32007-07-19 01:14:50 +00001264 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Sean Callanan108934c2009-12-18 00:01:26 +00001265 "cmove{w}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001266 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Chenge5f62042007-09-29 00:00:36 +00001267 X86_COND_E, EFLAGS))]>,
Evan Cheng71fb9ad2006-01-26 00:29:36 +00001268 TB, OpSize;
Evan Cheng069287d2006-05-16 07:21:53 +00001269def CMOVE32rr : I<0x44, MRMSrcReg, // if ==, GR32 = GR32
Evan Cheng64d80e32007-07-19 01:14:50 +00001270 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Sean Callanan108934c2009-12-18 00:01:26 +00001271 "cmove{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001272 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Chenge5f62042007-09-29 00:00:36 +00001273 X86_COND_E, EFLAGS))]>,
Evan Cheng71fb9ad2006-01-26 00:29:36 +00001274 TB;
Evan Cheng069287d2006-05-16 07:21:53 +00001275def CMOVNE16rr: I<0x45, MRMSrcReg, // if !=, GR16 = GR16
Evan Cheng64d80e32007-07-19 01:14:50 +00001276 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Sean Callanan108934c2009-12-18 00:01:26 +00001277 "cmovne{w}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001278 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Chenge5f62042007-09-29 00:00:36 +00001279 X86_COND_NE, EFLAGS))]>,
Evan Cheng71fb9ad2006-01-26 00:29:36 +00001280 TB, OpSize;
Evan Cheng069287d2006-05-16 07:21:53 +00001281def CMOVNE32rr: I<0x45, MRMSrcReg, // if !=, GR32 = GR32
Evan Cheng64d80e32007-07-19 01:14:50 +00001282 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Sean Callanan108934c2009-12-18 00:01:26 +00001283 "cmovne{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001284 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Chenge5f62042007-09-29 00:00:36 +00001285 X86_COND_NE, EFLAGS))]>,
Evan Cheng71fb9ad2006-01-26 00:29:36 +00001286 TB;
Evan Cheng069287d2006-05-16 07:21:53 +00001287def CMOVBE16rr: I<0x46, MRMSrcReg, // if <=u, GR16 = GR16
Evan Cheng64d80e32007-07-19 01:14:50 +00001288 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Sean Callanan108934c2009-12-18 00:01:26 +00001289 "cmovbe{w}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001290 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Chenge5f62042007-09-29 00:00:36 +00001291 X86_COND_BE, EFLAGS))]>,
Evan Cheng71fb9ad2006-01-26 00:29:36 +00001292 TB, OpSize;
Evan Cheng069287d2006-05-16 07:21:53 +00001293def CMOVBE32rr: I<0x46, MRMSrcReg, // if <=u, GR32 = GR32
Evan Cheng64d80e32007-07-19 01:14:50 +00001294 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Sean Callanan108934c2009-12-18 00:01:26 +00001295 "cmovbe{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001296 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Chenge5f62042007-09-29 00:00:36 +00001297 X86_COND_BE, EFLAGS))]>,
Evan Cheng71fb9ad2006-01-26 00:29:36 +00001298 TB;
Evan Cheng069287d2006-05-16 07:21:53 +00001299def CMOVA16rr : I<0x47, MRMSrcReg, // if >u, GR16 = GR16
Evan Cheng64d80e32007-07-19 01:14:50 +00001300 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Sean Callanan108934c2009-12-18 00:01:26 +00001301 "cmova{w}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001302 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Chenge5f62042007-09-29 00:00:36 +00001303 X86_COND_A, EFLAGS))]>,
Evan Cheng71fb9ad2006-01-26 00:29:36 +00001304 TB, OpSize;
Evan Cheng069287d2006-05-16 07:21:53 +00001305def CMOVA32rr : I<0x47, MRMSrcReg, // if >u, GR32 = GR32
Evan Cheng64d80e32007-07-19 01:14:50 +00001306 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Sean Callanan108934c2009-12-18 00:01:26 +00001307 "cmova{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001308 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Chenge5f62042007-09-29 00:00:36 +00001309 X86_COND_A, EFLAGS))]>,
Evan Cheng71fb9ad2006-01-26 00:29:36 +00001310 TB;
Evan Cheng069287d2006-05-16 07:21:53 +00001311def CMOVL16rr : I<0x4C, MRMSrcReg, // if <s, GR16 = GR16
Evan Cheng64d80e32007-07-19 01:14:50 +00001312 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Sean Callanan108934c2009-12-18 00:01:26 +00001313 "cmovl{w}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001314 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Chenge5f62042007-09-29 00:00:36 +00001315 X86_COND_L, EFLAGS))]>,
Evan Cheng71fb9ad2006-01-26 00:29:36 +00001316 TB, OpSize;
Evan Cheng069287d2006-05-16 07:21:53 +00001317def CMOVL32rr : I<0x4C, MRMSrcReg, // if <s, GR32 = GR32
Evan Cheng64d80e32007-07-19 01:14:50 +00001318 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Sean Callanan108934c2009-12-18 00:01:26 +00001319 "cmovl{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001320 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Chenge5f62042007-09-29 00:00:36 +00001321 X86_COND_L, EFLAGS))]>,
Evan Cheng71fb9ad2006-01-26 00:29:36 +00001322 TB;
Evan Cheng069287d2006-05-16 07:21:53 +00001323def CMOVGE16rr: I<0x4D, MRMSrcReg, // if >=s, GR16 = GR16
Evan Cheng64d80e32007-07-19 01:14:50 +00001324 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Sean Callanan108934c2009-12-18 00:01:26 +00001325 "cmovge{w}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001326 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Chenge5f62042007-09-29 00:00:36 +00001327 X86_COND_GE, EFLAGS))]>,
Evan Cheng71fb9ad2006-01-26 00:29:36 +00001328 TB, OpSize;
Evan Cheng069287d2006-05-16 07:21:53 +00001329def CMOVGE32rr: I<0x4D, MRMSrcReg, // if >=s, GR32 = GR32
Evan Cheng64d80e32007-07-19 01:14:50 +00001330 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Sean Callanan108934c2009-12-18 00:01:26 +00001331 "cmovge{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001332 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Chenge5f62042007-09-29 00:00:36 +00001333 X86_COND_GE, EFLAGS))]>,
Evan Cheng71fb9ad2006-01-26 00:29:36 +00001334 TB;
Evan Cheng069287d2006-05-16 07:21:53 +00001335def CMOVLE16rr: I<0x4E, MRMSrcReg, // if <=s, GR16 = GR16
Evan Cheng64d80e32007-07-19 01:14:50 +00001336 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Sean Callanan108934c2009-12-18 00:01:26 +00001337 "cmovle{w}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001338 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Chenge5f62042007-09-29 00:00:36 +00001339 X86_COND_LE, EFLAGS))]>,
Evan Cheng71fb9ad2006-01-26 00:29:36 +00001340 TB, OpSize;
Evan Cheng069287d2006-05-16 07:21:53 +00001341def CMOVLE32rr: I<0x4E, MRMSrcReg, // if <=s, GR32 = GR32
Evan Cheng64d80e32007-07-19 01:14:50 +00001342 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Sean Callanan108934c2009-12-18 00:01:26 +00001343 "cmovle{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001344 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Chenge5f62042007-09-29 00:00:36 +00001345 X86_COND_LE, EFLAGS))]>,
Evan Cheng71fb9ad2006-01-26 00:29:36 +00001346 TB;
Evan Cheng069287d2006-05-16 07:21:53 +00001347def CMOVG16rr : I<0x4F, MRMSrcReg, // if >s, GR16 = GR16
Evan Cheng64d80e32007-07-19 01:14:50 +00001348 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Sean Callanan108934c2009-12-18 00:01:26 +00001349 "cmovg{w}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001350 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Chenge5f62042007-09-29 00:00:36 +00001351 X86_COND_G, EFLAGS))]>,
Evan Cheng71fb9ad2006-01-26 00:29:36 +00001352 TB, OpSize;
Evan Cheng069287d2006-05-16 07:21:53 +00001353def CMOVG32rr : I<0x4F, MRMSrcReg, // if >s, GR32 = GR32
Evan Cheng64d80e32007-07-19 01:14:50 +00001354 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Sean Callanan108934c2009-12-18 00:01:26 +00001355 "cmovg{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001356 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Chenge5f62042007-09-29 00:00:36 +00001357 X86_COND_G, EFLAGS))]>,
Evan Cheng71fb9ad2006-01-26 00:29:36 +00001358 TB;
Evan Cheng069287d2006-05-16 07:21:53 +00001359def CMOVS16rr : I<0x48, MRMSrcReg, // if signed, GR16 = GR16
Evan Cheng64d80e32007-07-19 01:14:50 +00001360 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Sean Callanan108934c2009-12-18 00:01:26 +00001361 "cmovs{w}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001362 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Chenge5f62042007-09-29 00:00:36 +00001363 X86_COND_S, EFLAGS))]>,
Evan Cheng71fb9ad2006-01-26 00:29:36 +00001364 TB, OpSize;
Evan Cheng069287d2006-05-16 07:21:53 +00001365def CMOVS32rr : I<0x48, MRMSrcReg, // if signed, GR32 = GR32
Evan Cheng64d80e32007-07-19 01:14:50 +00001366 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Sean Callanan108934c2009-12-18 00:01:26 +00001367 "cmovs{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001368 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Chenge5f62042007-09-29 00:00:36 +00001369 X86_COND_S, EFLAGS))]>,
Evan Cheng71fb9ad2006-01-26 00:29:36 +00001370 TB;
Evan Cheng069287d2006-05-16 07:21:53 +00001371def CMOVNS16rr: I<0x49, MRMSrcReg, // if !signed, GR16 = GR16
Evan Cheng64d80e32007-07-19 01:14:50 +00001372 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Sean Callanan108934c2009-12-18 00:01:26 +00001373 "cmovns{w}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001374 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Chenge5f62042007-09-29 00:00:36 +00001375 X86_COND_NS, EFLAGS))]>,
Evan Cheng71fb9ad2006-01-26 00:29:36 +00001376 TB, OpSize;
Evan Cheng069287d2006-05-16 07:21:53 +00001377def CMOVNS32rr: I<0x49, MRMSrcReg, // if !signed, GR32 = GR32
Evan Cheng64d80e32007-07-19 01:14:50 +00001378 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Sean Callanan108934c2009-12-18 00:01:26 +00001379 "cmovns{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001380 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Chenge5f62042007-09-29 00:00:36 +00001381 X86_COND_NS, EFLAGS))]>,
Evan Cheng71fb9ad2006-01-26 00:29:36 +00001382 TB;
Evan Cheng069287d2006-05-16 07:21:53 +00001383def CMOVP16rr : I<0x4A, MRMSrcReg, // if parity, GR16 = GR16
Evan Cheng64d80e32007-07-19 01:14:50 +00001384 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Sean Callanan108934c2009-12-18 00:01:26 +00001385 "cmovp{w}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001386 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Chenge5f62042007-09-29 00:00:36 +00001387 X86_COND_P, EFLAGS))]>,
Evan Cheng71fb9ad2006-01-26 00:29:36 +00001388 TB, OpSize;
Evan Cheng069287d2006-05-16 07:21:53 +00001389def CMOVP32rr : I<0x4A, MRMSrcReg, // if parity, GR32 = GR32
Evan Cheng64d80e32007-07-19 01:14:50 +00001390 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Sean Callanan108934c2009-12-18 00:01:26 +00001391 "cmovp{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001392 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Chenge5f62042007-09-29 00:00:36 +00001393 X86_COND_P, EFLAGS))]>,
Evan Cheng71fb9ad2006-01-26 00:29:36 +00001394 TB;
Evan Cheng069287d2006-05-16 07:21:53 +00001395def CMOVNP16rr : I<0x4B, MRMSrcReg, // if !parity, GR16 = GR16
Evan Cheng64d80e32007-07-19 01:14:50 +00001396 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Sean Callanan108934c2009-12-18 00:01:26 +00001397 "cmovnp{w}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001398 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Chenge5f62042007-09-29 00:00:36 +00001399 X86_COND_NP, EFLAGS))]>,
Evan Cheng71fb9ad2006-01-26 00:29:36 +00001400 TB, OpSize;
Evan Cheng069287d2006-05-16 07:21:53 +00001401def CMOVNP32rr : I<0x4B, MRMSrcReg, // if !parity, GR32 = GR32
Evan Cheng64d80e32007-07-19 01:14:50 +00001402 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Sean Callanan108934c2009-12-18 00:01:26 +00001403 "cmovnp{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001404 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Chenge5f62042007-09-29 00:00:36 +00001405 X86_COND_NP, EFLAGS))]>,
Evan Cheng71fb9ad2006-01-26 00:29:36 +00001406 TB;
Dan Gohman305fceb2009-01-07 00:35:10 +00001407def CMOVO16rr : I<0x40, MRMSrcReg, // if overflow, GR16 = GR16
1408 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Sean Callanan108934c2009-12-18 00:01:26 +00001409 "cmovo{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohman305fceb2009-01-07 00:35:10 +00001410 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
1411 X86_COND_O, EFLAGS))]>,
1412 TB, OpSize;
1413def CMOVO32rr : I<0x40, MRMSrcReg, // if overflow, GR32 = GR32
1414 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Sean Callanan108934c2009-12-18 00:01:26 +00001415 "cmovo{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohman305fceb2009-01-07 00:35:10 +00001416 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
1417 X86_COND_O, EFLAGS))]>,
Evan Cheng0488db92007-09-25 01:57:46 +00001418 TB;
Dan Gohman305fceb2009-01-07 00:35:10 +00001419def CMOVNO16rr : I<0x41, MRMSrcReg, // if !overflow, GR16 = GR16
1420 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Sean Callanan108934c2009-12-18 00:01:26 +00001421 "cmovno{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohman305fceb2009-01-07 00:35:10 +00001422 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
1423 X86_COND_NO, EFLAGS))]>,
1424 TB, OpSize;
1425def CMOVNO32rr : I<0x41, MRMSrcReg, // if !overflow, GR32 = GR32
1426 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Sean Callanan108934c2009-12-18 00:01:26 +00001427 "cmovno{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohman305fceb2009-01-07 00:35:10 +00001428 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
1429 X86_COND_NO, EFLAGS))]>,
1430 TB;
1431} // isCommutable = 1
Evan Cheng7ad42d92007-10-05 23:13:21 +00001432
1433def CMOVB16rm : I<0x42, MRMSrcMem, // if <u, GR16 = [mem16]
1434 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
Sean Callanan108934c2009-12-18 00:01:26 +00001435 "cmovb{w}\t{$src2, $dst|$dst, $src2}",
Evan Cheng7ad42d92007-10-05 23:13:21 +00001436 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1437 X86_COND_B, EFLAGS))]>,
1438 TB, OpSize;
1439def CMOVB32rm : I<0x42, MRMSrcMem, // if <u, GR32 = [mem32]
1440 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Sean Callanan108934c2009-12-18 00:01:26 +00001441 "cmovb{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng7ad42d92007-10-05 23:13:21 +00001442 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1443 X86_COND_B, EFLAGS))]>,
1444 TB;
1445def CMOVAE16rm: I<0x43, MRMSrcMem, // if >=u, GR16 = [mem16]
1446 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
Sean Callanan108934c2009-12-18 00:01:26 +00001447 "cmovae{w}\t{$src2, $dst|$dst, $src2}",
Evan Cheng7ad42d92007-10-05 23:13:21 +00001448 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1449 X86_COND_AE, EFLAGS))]>,
1450 TB, OpSize;
1451def CMOVAE32rm: I<0x43, MRMSrcMem, // if >=u, GR32 = [mem32]
1452 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Sean Callanan108934c2009-12-18 00:01:26 +00001453 "cmovae{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng7ad42d92007-10-05 23:13:21 +00001454 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1455 X86_COND_AE, EFLAGS))]>,
1456 TB;
1457def CMOVE16rm : I<0x44, MRMSrcMem, // if ==, GR16 = [mem16]
1458 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
Sean Callanan108934c2009-12-18 00:01:26 +00001459 "cmove{w}\t{$src2, $dst|$dst, $src2}",
Evan Cheng7ad42d92007-10-05 23:13:21 +00001460 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1461 X86_COND_E, EFLAGS))]>,
1462 TB, OpSize;
1463def CMOVE32rm : I<0x44, MRMSrcMem, // if ==, GR32 = [mem32]
1464 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Sean Callanan108934c2009-12-18 00:01:26 +00001465 "cmove{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng7ad42d92007-10-05 23:13:21 +00001466 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1467 X86_COND_E, EFLAGS))]>,
1468 TB;
1469def CMOVNE16rm: I<0x45, MRMSrcMem, // if !=, GR16 = [mem16]
1470 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
Sean Callanan108934c2009-12-18 00:01:26 +00001471 "cmovne{w}\t{$src2, $dst|$dst, $src2}",
Evan Cheng7ad42d92007-10-05 23:13:21 +00001472 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1473 X86_COND_NE, EFLAGS))]>,
1474 TB, OpSize;
1475def CMOVNE32rm: I<0x45, MRMSrcMem, // if !=, GR32 = [mem32]
1476 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Sean Callanan108934c2009-12-18 00:01:26 +00001477 "cmovne{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng7ad42d92007-10-05 23:13:21 +00001478 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1479 X86_COND_NE, EFLAGS))]>,
1480 TB;
1481def CMOVBE16rm: I<0x46, MRMSrcMem, // if <=u, GR16 = [mem16]
1482 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
Sean Callanan108934c2009-12-18 00:01:26 +00001483 "cmovbe{w}\t{$src2, $dst|$dst, $src2}",
Evan Cheng7ad42d92007-10-05 23:13:21 +00001484 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1485 X86_COND_BE, EFLAGS))]>,
1486 TB, OpSize;
1487def CMOVBE32rm: I<0x46, MRMSrcMem, // if <=u, GR32 = [mem32]
1488 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Sean Callanan108934c2009-12-18 00:01:26 +00001489 "cmovbe{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng7ad42d92007-10-05 23:13:21 +00001490 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1491 X86_COND_BE, EFLAGS))]>,
1492 TB;
1493def CMOVA16rm : I<0x47, MRMSrcMem, // if >u, GR16 = [mem16]
1494 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
Sean Callanan108934c2009-12-18 00:01:26 +00001495 "cmova{w}\t{$src2, $dst|$dst, $src2}",
Evan Cheng7ad42d92007-10-05 23:13:21 +00001496 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1497 X86_COND_A, EFLAGS))]>,
1498 TB, OpSize;
1499def CMOVA32rm : I<0x47, MRMSrcMem, // if >u, GR32 = [mem32]
1500 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Sean Callanan108934c2009-12-18 00:01:26 +00001501 "cmova{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng7ad42d92007-10-05 23:13:21 +00001502 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1503 X86_COND_A, EFLAGS))]>,
1504 TB;
1505def CMOVL16rm : I<0x4C, MRMSrcMem, // if <s, GR16 = [mem16]
1506 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
Sean Callanan108934c2009-12-18 00:01:26 +00001507 "cmovl{w}\t{$src2, $dst|$dst, $src2}",
Evan Cheng7ad42d92007-10-05 23:13:21 +00001508 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1509 X86_COND_L, EFLAGS))]>,
1510 TB, OpSize;
1511def CMOVL32rm : I<0x4C, MRMSrcMem, // if <s, GR32 = [mem32]
1512 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Sean Callanan108934c2009-12-18 00:01:26 +00001513 "cmovl{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng7ad42d92007-10-05 23:13:21 +00001514 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1515 X86_COND_L, EFLAGS))]>,
1516 TB;
1517def CMOVGE16rm: I<0x4D, MRMSrcMem, // if >=s, GR16 = [mem16]
1518 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
Sean Callanan108934c2009-12-18 00:01:26 +00001519 "cmovge{w}\t{$src2, $dst|$dst, $src2}",
Evan Cheng7ad42d92007-10-05 23:13:21 +00001520 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1521 X86_COND_GE, EFLAGS))]>,
1522 TB, OpSize;
1523def CMOVGE32rm: I<0x4D, MRMSrcMem, // if >=s, GR32 = [mem32]
1524 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Sean Callanan108934c2009-12-18 00:01:26 +00001525 "cmovge{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng7ad42d92007-10-05 23:13:21 +00001526 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1527 X86_COND_GE, EFLAGS))]>,
1528 TB;
1529def CMOVLE16rm: I<0x4E, MRMSrcMem, // if <=s, GR16 = [mem16]
1530 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
Sean Callanan108934c2009-12-18 00:01:26 +00001531 "cmovle{w}\t{$src2, $dst|$dst, $src2}",
Evan Cheng7ad42d92007-10-05 23:13:21 +00001532 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1533 X86_COND_LE, EFLAGS))]>,
1534 TB, OpSize;
1535def CMOVLE32rm: I<0x4E, MRMSrcMem, // if <=s, GR32 = [mem32]
1536 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Sean Callanan108934c2009-12-18 00:01:26 +00001537 "cmovle{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng7ad42d92007-10-05 23:13:21 +00001538 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1539 X86_COND_LE, EFLAGS))]>,
1540 TB;
1541def CMOVG16rm : I<0x4F, MRMSrcMem, // if >s, GR16 = [mem16]
1542 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
Sean Callanan108934c2009-12-18 00:01:26 +00001543 "cmovg{w}\t{$src2, $dst|$dst, $src2}",
Evan Cheng7ad42d92007-10-05 23:13:21 +00001544 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1545 X86_COND_G, EFLAGS))]>,
1546 TB, OpSize;
1547def CMOVG32rm : I<0x4F, MRMSrcMem, // if >s, GR32 = [mem32]
1548 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Sean Callanan108934c2009-12-18 00:01:26 +00001549 "cmovg{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng7ad42d92007-10-05 23:13:21 +00001550 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1551 X86_COND_G, EFLAGS))]>,
1552 TB;
1553def CMOVS16rm : I<0x48, MRMSrcMem, // if signed, GR16 = [mem16]
1554 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
Sean Callanan108934c2009-12-18 00:01:26 +00001555 "cmovs{w}\t{$src2, $dst|$dst, $src2}",
Evan Cheng7ad42d92007-10-05 23:13:21 +00001556 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1557 X86_COND_S, EFLAGS))]>,
1558 TB, OpSize;
1559def CMOVS32rm : I<0x48, MRMSrcMem, // if signed, GR32 = [mem32]
1560 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Sean Callanan108934c2009-12-18 00:01:26 +00001561 "cmovs{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng7ad42d92007-10-05 23:13:21 +00001562 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1563 X86_COND_S, EFLAGS))]>,
1564 TB;
1565def CMOVNS16rm: I<0x49, MRMSrcMem, // if !signed, GR16 = [mem16]
1566 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
Sean Callanan108934c2009-12-18 00:01:26 +00001567 "cmovns{w}\t{$src2, $dst|$dst, $src2}",
Evan Cheng7ad42d92007-10-05 23:13:21 +00001568 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1569 X86_COND_NS, EFLAGS))]>,
1570 TB, OpSize;
1571def CMOVNS32rm: I<0x49, MRMSrcMem, // if !signed, GR32 = [mem32]
1572 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Sean Callanan108934c2009-12-18 00:01:26 +00001573 "cmovns{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng7ad42d92007-10-05 23:13:21 +00001574 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1575 X86_COND_NS, EFLAGS))]>,
1576 TB;
1577def CMOVP16rm : I<0x4A, MRMSrcMem, // if parity, GR16 = [mem16]
1578 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
Sean Callanan108934c2009-12-18 00:01:26 +00001579 "cmovp{w}\t{$src2, $dst|$dst, $src2}",
Evan Cheng7ad42d92007-10-05 23:13:21 +00001580 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1581 X86_COND_P, EFLAGS))]>,
1582 TB, OpSize;
1583def CMOVP32rm : I<0x4A, MRMSrcMem, // if parity, GR32 = [mem32]
1584 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Sean Callanan108934c2009-12-18 00:01:26 +00001585 "cmovp{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng7ad42d92007-10-05 23:13:21 +00001586 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1587 X86_COND_P, EFLAGS))]>,
1588 TB;
1589def CMOVNP16rm : I<0x4B, MRMSrcMem, // if !parity, GR16 = [mem16]
1590 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
Sean Callanan108934c2009-12-18 00:01:26 +00001591 "cmovnp{w}\t{$src2, $dst|$dst, $src2}",
Evan Cheng7ad42d92007-10-05 23:13:21 +00001592 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1593 X86_COND_NP, EFLAGS))]>,
1594 TB, OpSize;
Dan Gohman305fceb2009-01-07 00:35:10 +00001595def CMOVNP32rm : I<0x4B, MRMSrcMem, // if !parity, GR32 = [mem32]
1596 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Sean Callanan108934c2009-12-18 00:01:26 +00001597 "cmovnp{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohman305fceb2009-01-07 00:35:10 +00001598 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1599 X86_COND_NP, EFLAGS))]>,
1600 TB;
1601def CMOVO16rm : I<0x40, MRMSrcMem, // if overflow, GR16 = [mem16]
1602 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
Sean Callanan108934c2009-12-18 00:01:26 +00001603 "cmovo{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohman305fceb2009-01-07 00:35:10 +00001604 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1605 X86_COND_O, EFLAGS))]>,
1606 TB, OpSize;
1607def CMOVO32rm : I<0x40, MRMSrcMem, // if overflow, GR32 = [mem32]
1608 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Sean Callanan108934c2009-12-18 00:01:26 +00001609 "cmovo{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohman305fceb2009-01-07 00:35:10 +00001610 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1611 X86_COND_O, EFLAGS))]>,
1612 TB;
1613def CMOVNO16rm : I<0x41, MRMSrcMem, // if !overflow, GR16 = [mem16]
1614 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
Sean Callanan108934c2009-12-18 00:01:26 +00001615 "cmovno{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohman305fceb2009-01-07 00:35:10 +00001616 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1617 X86_COND_NO, EFLAGS))]>,
1618 TB, OpSize;
1619def CMOVNO32rm : I<0x41, MRMSrcMem, // if !overflow, GR32 = [mem32]
1620 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Sean Callanan108934c2009-12-18 00:01:26 +00001621 "cmovno{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohman305fceb2009-01-07 00:35:10 +00001622 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1623 X86_COND_NO, EFLAGS))]>,
1624 TB;
Chris Lattner314a1132010-03-14 18:31:44 +00001625} // Predicates = [HasCMov]
1626
1627// X86 doesn't have 8-bit conditional moves. Use a customInserter to
1628// emit control flow. An alternative to this is to mark i8 SELECT as Promote,
1629// however that requires promoting the operands, and can induce additional
1630// i8 register pressure. Note that CMOV_GR8 is conservatively considered to
1631// clobber EFLAGS, because if one of the operands is zero, the expansion
1632// could involve an xor.
1633let usesCustomInserter = 1, isTwoAddress = 0, Defs = [EFLAGS] in {
1634def CMOV_GR8 : I<0, Pseudo,
1635 (outs GR8:$dst), (ins GR8:$src1, GR8:$src2, i8imm:$cond),
1636 "#CMOV_GR8 PSEUDO!",
1637 [(set GR8:$dst, (X86cmov GR8:$src1, GR8:$src2,
1638 imm:$cond, EFLAGS))]>;
1639
1640let Predicates = [NoCMov] in {
1641def CMOV_GR32 : I<0, Pseudo,
1642 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2, i8imm:$cond),
1643 "#CMOV_GR32* PSEUDO!",
1644 [(set GR32:$dst,
1645 (X86cmov GR32:$src1, GR32:$src2, imm:$cond, EFLAGS))]>;
1646def CMOV_GR16 : I<0, Pseudo,
1647 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2, i8imm:$cond),
1648 "#CMOV_GR16* PSEUDO!",
1649 [(set GR16:$dst,
1650 (X86cmov GR16:$src1, GR16:$src2, imm:$cond, EFLAGS))]>;
1651def CMOV_RFP32 : I<0, Pseudo,
1652 (outs RFP32:$dst), (ins RFP32:$src1, RFP32:$src2, i8imm:$cond),
1653 "#CMOV_RFP32 PSEUDO!",
1654 [(set RFP32:$dst, (X86cmov RFP32:$src1, RFP32:$src2, imm:$cond,
1655 EFLAGS))]>;
1656def CMOV_RFP64 : I<0, Pseudo,
1657 (outs RFP64:$dst), (ins RFP64:$src1, RFP64:$src2, i8imm:$cond),
1658 "#CMOV_RFP64 PSEUDO!",
1659 [(set RFP64:$dst, (X86cmov RFP64:$src1, RFP64:$src2, imm:$cond,
1660 EFLAGS))]>;
1661def CMOV_RFP80 : I<0, Pseudo,
1662 (outs RFP80:$dst), (ins RFP80:$src1, RFP80:$src2, i8imm:$cond),
1663 "#CMOV_RFP80 PSEUDO!",
1664 [(set RFP80:$dst, (X86cmov RFP80:$src1, RFP80:$src2, imm:$cond,
1665 EFLAGS))]>;
1666} // Predicates = [NoCMov]
1667} // UsesCustomInserter = 1, isTwoAddress = 0, Defs = [EFLAGS]
Evan Cheng0488db92007-09-25 01:57:46 +00001668} // Uses = [EFLAGS]
1669
1670
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00001671// unary instructions
Evan Cheng1693e482006-07-19 00:27:29 +00001672let CodeSize = 2 in {
Evan Cheng24f2ea32007-09-14 21:48:26 +00001673let Defs = [EFLAGS] in {
Dan Gohmanb1576f52007-07-31 20:11:57 +00001674def NEG8r : I<0xF6, MRM3r, (outs GR8 :$dst), (ins GR8 :$src), "neg{b}\t$dst",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001675 [(set GR8:$dst, (ineg GR8:$src)),
1676 (implicit EFLAGS)]>;
Dan Gohmanb1576f52007-07-31 20:11:57 +00001677def NEG16r : I<0xF7, MRM3r, (outs GR16:$dst), (ins GR16:$src), "neg{w}\t$dst",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001678 [(set GR16:$dst, (ineg GR16:$src)),
1679 (implicit EFLAGS)]>, OpSize;
Dan Gohmanb1576f52007-07-31 20:11:57 +00001680def NEG32r : I<0xF7, MRM3r, (outs GR32:$dst), (ins GR32:$src), "neg{l}\t$dst",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001681 [(set GR32:$dst, (ineg GR32:$src)),
1682 (implicit EFLAGS)]>;
Chris Lattner57a02302004-08-11 04:31:00 +00001683let isTwoAddress = 0 in {
Dan Gohmanb1576f52007-07-31 20:11:57 +00001684 def NEG8m : I<0xF6, MRM3m, (outs), (ins i8mem :$dst), "neg{b}\t$dst",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001685 [(store (ineg (loadi8 addr:$dst)), addr:$dst),
1686 (implicit EFLAGS)]>;
Dan Gohmanb1576f52007-07-31 20:11:57 +00001687 def NEG16m : I<0xF7, MRM3m, (outs), (ins i16mem:$dst), "neg{w}\t$dst",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001688 [(store (ineg (loadi16 addr:$dst)), addr:$dst),
1689 (implicit EFLAGS)]>, OpSize;
Dan Gohmanb1576f52007-07-31 20:11:57 +00001690 def NEG32m : I<0xF7, MRM3m, (outs), (ins i32mem:$dst), "neg{l}\t$dst",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001691 [(store (ineg (loadi32 addr:$dst)), addr:$dst),
1692 (implicit EFLAGS)]>;
Chris Lattner57a02302004-08-11 04:31:00 +00001693}
Evan Cheng24f2ea32007-09-14 21:48:26 +00001694} // Defs = [EFLAGS]
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00001695
Evan Chengaaf414c2009-01-21 02:09:05 +00001696// Match xor -1 to not. Favors these over a move imm + xor to save code size.
1697let AddedComplexity = 15 in {
Dan Gohmanb1576f52007-07-31 20:11:57 +00001698def NOT8r : I<0xF6, MRM2r, (outs GR8 :$dst), (ins GR8 :$src), "not{b}\t$dst",
Evan Cheng069287d2006-05-16 07:21:53 +00001699 [(set GR8:$dst, (not GR8:$src))]>;
Dan Gohmanb1576f52007-07-31 20:11:57 +00001700def NOT16r : I<0xF7, MRM2r, (outs GR16:$dst), (ins GR16:$src), "not{w}\t$dst",
Evan Cheng069287d2006-05-16 07:21:53 +00001701 [(set GR16:$dst, (not GR16:$src))]>, OpSize;
Dan Gohmanb1576f52007-07-31 20:11:57 +00001702def NOT32r : I<0xF7, MRM2r, (outs GR32:$dst), (ins GR32:$src), "not{l}\t$dst",
Evan Cheng069287d2006-05-16 07:21:53 +00001703 [(set GR32:$dst, (not GR32:$src))]>;
Evan Chengaaf414c2009-01-21 02:09:05 +00001704}
Chris Lattner57a02302004-08-11 04:31:00 +00001705let isTwoAddress = 0 in {
Dan Gohmanb1576f52007-07-31 20:11:57 +00001706 def NOT8m : I<0xF6, MRM2m, (outs), (ins i8mem :$dst), "not{b}\t$dst",
Evan Cheng605c4152005-12-13 01:57:51 +00001707 [(store (not (loadi8 addr:$dst)), addr:$dst)]>;
Dan Gohmanb1576f52007-07-31 20:11:57 +00001708 def NOT16m : I<0xF7, MRM2m, (outs), (ins i16mem:$dst), "not{w}\t$dst",
Evan Cheng605c4152005-12-13 01:57:51 +00001709 [(store (not (loadi16 addr:$dst)), addr:$dst)]>, OpSize;
Dan Gohmanb1576f52007-07-31 20:11:57 +00001710 def NOT32m : I<0xF7, MRM2m, (outs), (ins i32mem:$dst), "not{l}\t$dst",
Evan Cheng605c4152005-12-13 01:57:51 +00001711 [(store (not (loadi32 addr:$dst)), addr:$dst)]>;
Chris Lattner57a02302004-08-11 04:31:00 +00001712}
Evan Cheng1693e482006-07-19 00:27:29 +00001713} // CodeSize
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00001714
Evan Chengb51a0592005-12-10 00:48:20 +00001715// TODO: inc/dec is slow for P4, but fast for Pentium-M.
Evan Cheng24f2ea32007-09-14 21:48:26 +00001716let Defs = [EFLAGS] in {
Evan Cheng1693e482006-07-19 00:27:29 +00001717let CodeSize = 2 in
Dan Gohmanb1576f52007-07-31 20:11:57 +00001718def INC8r : I<0xFE, MRM0r, (outs GR8 :$dst), (ins GR8 :$src), "inc{b}\t$dst",
Chris Lattnerc54a2f12010-03-24 01:02:12 +00001719 [(set GR8:$dst, EFLAGS, (X86inc_flag GR8:$src))]>;
1720
Evan Cheng1693e482006-07-19 00:27:29 +00001721let isConvertibleToThreeAddress = 1, CodeSize = 1 in { // Can xform into LEA.
Sean Callanan108934c2009-12-18 00:01:26 +00001722def INC16r : I<0x40, AddRegFrm, (outs GR16:$dst), (ins GR16:$src),
1723 "inc{w}\t$dst",
Chris Lattner589ad5d2010-03-25 05:44:01 +00001724 [(set GR16:$dst, EFLAGS, (X86inc_flag GR16:$src))]>,
Evan Cheng25ab6902006-09-08 06:48:29 +00001725 OpSize, Requires<[In32BitMode]>;
Sean Callanan108934c2009-12-18 00:01:26 +00001726def INC32r : I<0x40, AddRegFrm, (outs GR32:$dst), (ins GR32:$src),
1727 "inc{l}\t$dst",
Chris Lattner589ad5d2010-03-25 05:44:01 +00001728 [(set GR32:$dst, EFLAGS, (X86inc_flag GR32:$src))]>,
1729 Requires<[In32BitMode]>;
Chris Lattnercc65bee2005-01-02 02:35:46 +00001730}
Evan Cheng1693e482006-07-19 00:27:29 +00001731let isTwoAddress = 0, CodeSize = 2 in {
Dan Gohmanb1576f52007-07-31 20:11:57 +00001732 def INC8m : I<0xFE, MRM0m, (outs), (ins i8mem :$dst), "inc{b}\t$dst",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001733 [(store (add (loadi8 addr:$dst), 1), addr:$dst),
1734 (implicit EFLAGS)]>;
Dan Gohmanb1576f52007-07-31 20:11:57 +00001735 def INC16m : I<0xFF, MRM0m, (outs), (ins i16mem:$dst), "inc{w}\t$dst",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001736 [(store (add (loadi16 addr:$dst), 1), addr:$dst),
1737 (implicit EFLAGS)]>,
Evan Cheng66f71632007-10-19 21:23:22 +00001738 OpSize, Requires<[In32BitMode]>;
Dan Gohmanb1576f52007-07-31 20:11:57 +00001739 def INC32m : I<0xFF, MRM0m, (outs), (ins i32mem:$dst), "inc{l}\t$dst",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001740 [(store (add (loadi32 addr:$dst), 1), addr:$dst),
1741 (implicit EFLAGS)]>,
Evan Cheng66f71632007-10-19 21:23:22 +00001742 Requires<[In32BitMode]>;
Chris Lattner57a02302004-08-11 04:31:00 +00001743}
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00001744
Evan Cheng1693e482006-07-19 00:27:29 +00001745let CodeSize = 2 in
Dan Gohmanb1576f52007-07-31 20:11:57 +00001746def DEC8r : I<0xFE, MRM1r, (outs GR8 :$dst), (ins GR8 :$src), "dec{b}\t$dst",
Chris Lattner589ad5d2010-03-25 05:44:01 +00001747 [(set GR8:$dst, EFLAGS, (X86dec_flag GR8:$src))]>;
Evan Cheng1693e482006-07-19 00:27:29 +00001748let isConvertibleToThreeAddress = 1, CodeSize = 1 in { // Can xform into LEA.
Sean Callanan108934c2009-12-18 00:01:26 +00001749def DEC16r : I<0x48, AddRegFrm, (outs GR16:$dst), (ins GR16:$src),
1750 "dec{w}\t$dst",
Chris Lattner589ad5d2010-03-25 05:44:01 +00001751 [(set GR16:$dst, EFLAGS, (X86dec_flag GR16:$src))]>,
Evan Cheng25ab6902006-09-08 06:48:29 +00001752 OpSize, Requires<[In32BitMode]>;
Sean Callanan108934c2009-12-18 00:01:26 +00001753def DEC32r : I<0x48, AddRegFrm, (outs GR32:$dst), (ins GR32:$src),
1754 "dec{l}\t$dst",
Chris Lattner589ad5d2010-03-25 05:44:01 +00001755 [(set GR32:$dst, EFLAGS, (X86dec_flag GR32:$src))]>,
1756 Requires<[In32BitMode]>;
Chris Lattnercc65bee2005-01-02 02:35:46 +00001757}
Chris Lattner57a02302004-08-11 04:31:00 +00001758
Evan Cheng1693e482006-07-19 00:27:29 +00001759let isTwoAddress = 0, CodeSize = 2 in {
Dan Gohmanb1576f52007-07-31 20:11:57 +00001760 def DEC8m : I<0xFE, MRM1m, (outs), (ins i8mem :$dst), "dec{b}\t$dst",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001761 [(store (add (loadi8 addr:$dst), -1), addr:$dst),
1762 (implicit EFLAGS)]>;
Dan Gohmanb1576f52007-07-31 20:11:57 +00001763 def DEC16m : I<0xFF, MRM1m, (outs), (ins i16mem:$dst), "dec{w}\t$dst",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001764 [(store (add (loadi16 addr:$dst), -1), addr:$dst),
1765 (implicit EFLAGS)]>,
Evan Cheng66f71632007-10-19 21:23:22 +00001766 OpSize, Requires<[In32BitMode]>;
Dan Gohmanb1576f52007-07-31 20:11:57 +00001767 def DEC32m : I<0xFF, MRM1m, (outs), (ins i32mem:$dst), "dec{l}\t$dst",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001768 [(store (add (loadi32 addr:$dst), -1), addr:$dst),
1769 (implicit EFLAGS)]>,
Evan Cheng66f71632007-10-19 21:23:22 +00001770 Requires<[In32BitMode]>;
Chris Lattner57a02302004-08-11 04:31:00 +00001771}
Evan Cheng24f2ea32007-09-14 21:48:26 +00001772} // Defs = [EFLAGS]
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00001773
1774// Logical operators...
Evan Cheng24f2ea32007-09-14 21:48:26 +00001775let Defs = [EFLAGS] in {
Chris Lattnercc65bee2005-01-02 02:35:46 +00001776let isCommutable = 1 in { // X = AND Y, Z --> X = AND Z, Y
Chris Lattner589ad5d2010-03-25 05:44:01 +00001777def AND8rr : I<0x20, MRMDestReg,
1778 (outs GR8 :$dst), (ins GR8 :$src1, GR8 :$src2),
1779 "and{b}\t{$src2, $dst|$dst, $src2}",
1780 [(set GR8:$dst, EFLAGS, (X86and_flag GR8:$src1, GR8:$src2))]>;
1781def AND16rr : I<0x21, MRMDestReg,
1782 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
1783 "and{w}\t{$src2, $dst|$dst, $src2}",
1784 [(set GR16:$dst, EFLAGS, (X86and_flag GR16:$src1,
1785 GR16:$src2))]>, OpSize;
1786def AND32rr : I<0x21, MRMDestReg,
1787 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
1788 "and{l}\t{$src2, $dst|$dst, $src2}",
1789 [(set GR32:$dst, EFLAGS, (X86and_flag GR32:$src1,
1790 GR32:$src2))]>;
Chris Lattnercc65bee2005-01-02 02:35:46 +00001791}
Chris Lattner57a02302004-08-11 04:31:00 +00001792
Sean Callanan108934c2009-12-18 00:01:26 +00001793// AND instructions with the destination register in REG and the source register
1794// in R/M. Included for the disassembler.
1795def AND8rr_REV : I<0x22, MRMSrcReg, (outs GR8:$dst), (ins GR8:$src1, GR8:$src2),
1796 "and{b}\t{$src2, $dst|$dst, $src2}", []>;
1797def AND16rr_REV : I<0x23, MRMSrcReg, (outs GR16:$dst),
1798 (ins GR16:$src1, GR16:$src2),
1799 "and{w}\t{$src2, $dst|$dst, $src2}", []>, OpSize;
1800def AND32rr_REV : I<0x23, MRMSrcReg, (outs GR32:$dst),
1801 (ins GR32:$src1, GR32:$src2),
1802 "and{l}\t{$src2, $dst|$dst, $src2}", []>;
1803
Chris Lattner3a173df2004-10-03 20:35:00 +00001804def AND8rm : I<0x22, MRMSrcMem,
Evan Cheng64d80e32007-07-19 01:14:50 +00001805 (outs GR8 :$dst), (ins GR8 :$src1, i8mem :$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001806 "and{b}\t{$src2, $dst|$dst, $src2}",
Chris Lattner589ad5d2010-03-25 05:44:01 +00001807 [(set GR8:$dst, EFLAGS, (X86and_flag GR8:$src1,
1808 (loadi8 addr:$src2)))]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00001809def AND16rm : I<0x23, MRMSrcMem,
Evan Cheng64d80e32007-07-19 01:14:50 +00001810 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001811 "and{w}\t{$src2, $dst|$dst, $src2}",
Chris Lattner589ad5d2010-03-25 05:44:01 +00001812 [(set GR16:$dst, EFLAGS, (X86and_flag GR16:$src1,
1813 (loadi16 addr:$src2)))]>,
1814 OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00001815def AND32rm : I<0x23, MRMSrcMem,
Evan Cheng64d80e32007-07-19 01:14:50 +00001816 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001817 "and{l}\t{$src2, $dst|$dst, $src2}",
Chris Lattner589ad5d2010-03-25 05:44:01 +00001818 [(set GR32:$dst, EFLAGS, (X86and_flag GR32:$src1,
1819 (loadi32 addr:$src2)))]>;
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00001820
Chris Lattner3a173df2004-10-03 20:35:00 +00001821def AND8ri : Ii8<0x80, MRM4r,
Evan Cheng64d80e32007-07-19 01:14:50 +00001822 (outs GR8 :$dst), (ins GR8 :$src1, i8imm :$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001823 "and{b}\t{$src2, $dst|$dst, $src2}",
Chris Lattner589ad5d2010-03-25 05:44:01 +00001824 [(set GR8:$dst, EFLAGS, (X86and_flag GR8:$src1,
1825 imm:$src2))]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00001826def AND16ri : Ii16<0x81, MRM4r,
Evan Cheng64d80e32007-07-19 01:14:50 +00001827 (outs GR16:$dst), (ins GR16:$src1, i16imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001828 "and{w}\t{$src2, $dst|$dst, $src2}",
Chris Lattner589ad5d2010-03-25 05:44:01 +00001829 [(set GR16:$dst, EFLAGS, (X86and_flag GR16:$src1,
1830 imm:$src2))]>, OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00001831def AND32ri : Ii32<0x81, MRM4r,
Evan Cheng64d80e32007-07-19 01:14:50 +00001832 (outs GR32:$dst), (ins GR32:$src1, i32imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001833 "and{l}\t{$src2, $dst|$dst, $src2}",
Chris Lattner589ad5d2010-03-25 05:44:01 +00001834 [(set GR32:$dst, EFLAGS, (X86and_flag GR32:$src1,
1835 imm:$src2))]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00001836def AND16ri8 : Ii8<0x83, MRM4r,
Evan Cheng64d80e32007-07-19 01:14:50 +00001837 (outs GR16:$dst), (ins GR16:$src1, i16i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001838 "and{w}\t{$src2, $dst|$dst, $src2}",
Chris Lattner589ad5d2010-03-25 05:44:01 +00001839 [(set GR16:$dst, EFLAGS, (X86and_flag GR16:$src1,
1840 i16immSExt8:$src2))]>,
Evan Cheng9b6b6422005-12-13 00:14:11 +00001841 OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00001842def AND32ri8 : Ii8<0x83, MRM4r,
Evan Cheng64d80e32007-07-19 01:14:50 +00001843 (outs GR32:$dst), (ins GR32:$src1, i32i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001844 "and{l}\t{$src2, $dst|$dst, $src2}",
Chris Lattner589ad5d2010-03-25 05:44:01 +00001845 [(set GR32:$dst, EFLAGS, (X86and_flag GR32:$src1,
1846 i32immSExt8:$src2))]>;
Chris Lattnerf29ed092004-08-11 05:07:25 +00001847
1848let isTwoAddress = 0 in {
Chris Lattner3a173df2004-10-03 20:35:00 +00001849 def AND8mr : I<0x20, MRMDestMem,
Evan Cheng64d80e32007-07-19 01:14:50 +00001850 (outs), (ins i8mem :$dst, GR8 :$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001851 "and{b}\t{$src, $dst|$dst, $src}",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001852 [(store (and (load addr:$dst), GR8:$src), addr:$dst),
1853 (implicit EFLAGS)]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00001854 def AND16mr : I<0x21, MRMDestMem,
Evan Cheng64d80e32007-07-19 01:14:50 +00001855 (outs), (ins i16mem:$dst, GR16:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001856 "and{w}\t{$src, $dst|$dst, $src}",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001857 [(store (and (load addr:$dst), GR16:$src), addr:$dst),
1858 (implicit EFLAGS)]>,
Evan Cheng0ef3a772005-12-13 01:41:36 +00001859 OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00001860 def AND32mr : I<0x21, MRMDestMem,
Evan Cheng64d80e32007-07-19 01:14:50 +00001861 (outs), (ins i32mem:$dst, GR32:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001862 "and{l}\t{$src, $dst|$dst, $src}",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001863 [(store (and (load addr:$dst), GR32:$src), addr:$dst),
1864 (implicit EFLAGS)]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00001865 def AND8mi : Ii8<0x80, MRM4m,
Evan Cheng64d80e32007-07-19 01:14:50 +00001866 (outs), (ins i8mem :$dst, i8imm :$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001867 "and{b}\t{$src, $dst|$dst, $src}",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001868 [(store (and (loadi8 addr:$dst), imm:$src), addr:$dst),
1869 (implicit EFLAGS)]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00001870 def AND16mi : Ii16<0x81, MRM4m,
Evan Cheng64d80e32007-07-19 01:14:50 +00001871 (outs), (ins i16mem:$dst, i16imm:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001872 "and{w}\t{$src, $dst|$dst, $src}",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001873 [(store (and (loadi16 addr:$dst), imm:$src), addr:$dst),
1874 (implicit EFLAGS)]>,
Evan Cheng0ef3a772005-12-13 01:41:36 +00001875 OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00001876 def AND32mi : Ii32<0x81, MRM4m,
Evan Cheng64d80e32007-07-19 01:14:50 +00001877 (outs), (ins i32mem:$dst, i32imm:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001878 "and{l}\t{$src, $dst|$dst, $src}",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001879 [(store (and (loadi32 addr:$dst), imm:$src), addr:$dst),
1880 (implicit EFLAGS)]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00001881 def AND16mi8 : Ii8<0x83, MRM4m,
Evan Cheng64d80e32007-07-19 01:14:50 +00001882 (outs), (ins i16mem:$dst, i16i8imm :$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001883 "and{w}\t{$src, $dst|$dst, $src}",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001884 [(store (and (load addr:$dst), i16immSExt8:$src), addr:$dst),
1885 (implicit EFLAGS)]>,
Evan Cheng0ef3a772005-12-13 01:41:36 +00001886 OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00001887 def AND32mi8 : Ii8<0x83, MRM4m,
Evan Cheng64d80e32007-07-19 01:14:50 +00001888 (outs), (ins i32mem:$dst, i32i8imm :$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001889 "and{l}\t{$src, $dst|$dst, $src}",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001890 [(store (and (load addr:$dst), i32immSExt8:$src), addr:$dst),
1891 (implicit EFLAGS)]>;
Sean Callanana09caa52009-09-02 00:55:49 +00001892
1893 def AND8i8 : Ii8<0x24, RawFrm, (outs), (ins i8imm:$src),
1894 "and{b}\t{$src, %al|%al, $src}", []>;
1895 def AND16i16 : Ii16<0x25, RawFrm, (outs), (ins i16imm:$src),
1896 "and{w}\t{$src, %ax|%ax, $src}", []>, OpSize;
1897 def AND32i32 : Ii32<0x25, RawFrm, (outs), (ins i32imm:$src),
1898 "and{l}\t{$src, %eax|%eax, $src}", []>;
1899
Chris Lattnerf29ed092004-08-11 05:07:25 +00001900}
1901
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00001902
Chris Lattnercc65bee2005-01-02 02:35:46 +00001903let isCommutable = 1 in { // X = OR Y, Z --> X = OR Z, Y
Sean Callanan108934c2009-12-18 00:01:26 +00001904def OR8rr : I<0x08, MRMDestReg, (outs GR8 :$dst),
1905 (ins GR8 :$src1, GR8 :$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001906 "or{b}\t{$src2, $dst|$dst, $src2}",
Chris Lattner589ad5d2010-03-25 05:44:01 +00001907 [(set GR8:$dst, EFLAGS, (X86or_flag GR8:$src1, GR8:$src2))]>;
Sean Callanan108934c2009-12-18 00:01:26 +00001908def OR16rr : I<0x09, MRMDestReg, (outs GR16:$dst),
1909 (ins GR16:$src1, GR16:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001910 "or{w}\t{$src2, $dst|$dst, $src2}",
Chris Lattner589ad5d2010-03-25 05:44:01 +00001911 [(set GR16:$dst, EFLAGS, (X86or_flag GR16:$src1,GR16:$src2))]>,
1912 OpSize;
Sean Callanan108934c2009-12-18 00:01:26 +00001913def OR32rr : I<0x09, MRMDestReg, (outs GR32:$dst),
1914 (ins GR32:$src1, GR32:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001915 "or{l}\t{$src2, $dst|$dst, $src2}",
Chris Lattner589ad5d2010-03-25 05:44:01 +00001916 [(set GR32:$dst, EFLAGS, (X86or_flag GR32:$src1,GR32:$src2))]>;
Chris Lattnercc65bee2005-01-02 02:35:46 +00001917}
Sean Callanan108934c2009-12-18 00:01:26 +00001918
1919// OR instructions with the destination register in REG and the source register
1920// in R/M. Included for the disassembler.
1921def OR8rr_REV : I<0x0A, MRMSrcReg, (outs GR8:$dst), (ins GR8:$src1, GR8:$src2),
1922 "or{b}\t{$src2, $dst|$dst, $src2}", []>;
1923def OR16rr_REV : I<0x0B, MRMSrcReg, (outs GR16:$dst),
1924 (ins GR16:$src1, GR16:$src2),
1925 "or{w}\t{$src2, $dst|$dst, $src2}", []>, OpSize;
1926def OR32rr_REV : I<0x0B, MRMSrcReg, (outs GR32:$dst),
1927 (ins GR32:$src1, GR32:$src2),
1928 "or{l}\t{$src2, $dst|$dst, $src2}", []>;
1929
Chris Lattner589ad5d2010-03-25 05:44:01 +00001930def OR8rm : I<0x0A, MRMSrcMem, (outs GR8 :$dst),
Sean Callanan108934c2009-12-18 00:01:26 +00001931 (ins GR8 :$src1, i8mem :$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001932 "or{b}\t{$src2, $dst|$dst, $src2}",
Chris Lattner589ad5d2010-03-25 05:44:01 +00001933 [(set GR8:$dst, EFLAGS, (X86or_flag GR8:$src1,
1934 (load addr:$src2)))]>;
1935def OR16rm : I<0x0B, MRMSrcMem, (outs GR16:$dst),
Sean Callanan108934c2009-12-18 00:01:26 +00001936 (ins GR16:$src1, i16mem:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001937 "or{w}\t{$src2, $dst|$dst, $src2}",
Chris Lattner589ad5d2010-03-25 05:44:01 +00001938 [(set GR16:$dst, EFLAGS, (X86or_flag GR16:$src1,
1939 (load addr:$src2)))]>,
1940 OpSize;
1941def OR32rm : I<0x0B, MRMSrcMem, (outs GR32:$dst),
Sean Callanan108934c2009-12-18 00:01:26 +00001942 (ins GR32:$src1, i32mem:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001943 "or{l}\t{$src2, $dst|$dst, $src2}",
Chris Lattner589ad5d2010-03-25 05:44:01 +00001944 [(set GR32:$dst, EFLAGS, (X86or_flag GR32:$src1,
1945 (load addr:$src2)))]>;
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00001946
Sean Callanan108934c2009-12-18 00:01:26 +00001947def OR8ri : Ii8 <0x80, MRM1r, (outs GR8 :$dst),
1948 (ins GR8 :$src1, i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001949 "or{b}\t{$src2, $dst|$dst, $src2}",
Chris Lattner589ad5d2010-03-25 05:44:01 +00001950 [(set GR8:$dst,EFLAGS, (X86or_flag GR8:$src1, imm:$src2))]>;
Sean Callanan108934c2009-12-18 00:01:26 +00001951def OR16ri : Ii16<0x81, MRM1r, (outs GR16:$dst),
1952 (ins GR16:$src1, i16imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001953 "or{w}\t{$src2, $dst|$dst, $src2}",
Chris Lattner589ad5d2010-03-25 05:44:01 +00001954 [(set GR16:$dst, EFLAGS, (X86or_flag GR16:$src1,
1955 imm:$src2))]>, OpSize;
Sean Callanan108934c2009-12-18 00:01:26 +00001956def OR32ri : Ii32<0x81, MRM1r, (outs GR32:$dst),
1957 (ins GR32:$src1, i32imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001958 "or{l}\t{$src2, $dst|$dst, $src2}",
Chris Lattner589ad5d2010-03-25 05:44:01 +00001959 [(set GR32:$dst, EFLAGS, (X86or_flag GR32:$src1,
1960 imm:$src2))]>;
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00001961
Sean Callanan108934c2009-12-18 00:01:26 +00001962def OR16ri8 : Ii8<0x83, MRM1r, (outs GR16:$dst),
1963 (ins GR16:$src1, i16i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001964 "or{w}\t{$src2, $dst|$dst, $src2}",
Chris Lattner589ad5d2010-03-25 05:44:01 +00001965 [(set GR16:$dst, EFLAGS, (X86or_flag GR16:$src1,
1966 i16immSExt8:$src2))]>, OpSize;
Sean Callanan108934c2009-12-18 00:01:26 +00001967def OR32ri8 : Ii8<0x83, MRM1r, (outs GR32:$dst),
1968 (ins GR32:$src1, i32i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001969 "or{l}\t{$src2, $dst|$dst, $src2}",
Chris Lattner589ad5d2010-03-25 05:44:01 +00001970 [(set GR32:$dst, EFLAGS, (X86or_flag GR32:$src1,
1971 i32immSExt8:$src2))]>;
Chris Lattner57a02302004-08-11 04:31:00 +00001972let isTwoAddress = 0 in {
Evan Cheng64d80e32007-07-19 01:14:50 +00001973 def OR8mr : I<0x08, MRMDestMem, (outs), (ins i8mem:$dst, GR8:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001974 "or{b}\t{$src, $dst|$dst, $src}",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001975 [(store (or (load addr:$dst), GR8:$src), addr:$dst),
1976 (implicit EFLAGS)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00001977 def OR16mr : I<0x09, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001978 "or{w}\t{$src, $dst|$dst, $src}",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001979 [(store (or (load addr:$dst), GR16:$src), addr:$dst),
1980 (implicit EFLAGS)]>, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00001981 def OR32mr : I<0x09, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$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 (load addr:$dst), GR32:$src), addr:$dst),
1984 (implicit EFLAGS)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00001985 def OR8mi : Ii8<0x80, MRM1m, (outs), (ins i8mem :$dst, i8imm:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001986 "or{b}\t{$src, $dst|$dst, $src}",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001987 [(store (or (loadi8 addr:$dst), imm:$src), addr:$dst),
1988 (implicit EFLAGS)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00001989 def OR16mi : Ii16<0x81, MRM1m, (outs), (ins i16mem:$dst, i16imm:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001990 "or{w}\t{$src, $dst|$dst, $src}",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001991 [(store (or (loadi16 addr:$dst), imm:$src), addr:$dst),
1992 (implicit EFLAGS)]>,
Evan Cheng0ef3a772005-12-13 01:41:36 +00001993 OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00001994 def OR32mi : Ii32<0x81, MRM1m, (outs), (ins i32mem:$dst, i32imm:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001995 "or{l}\t{$src, $dst|$dst, $src}",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001996 [(store (or (loadi32 addr:$dst), imm:$src), addr:$dst),
1997 (implicit EFLAGS)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00001998 def OR16mi8 : Ii8<0x83, MRM1m, (outs), (ins i16mem:$dst, i16i8imm:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001999 "or{w}\t{$src, $dst|$dst, $src}",
Dan Gohman09a2609e2009-03-03 19:53:46 +00002000 [(store (or (load addr:$dst), i16immSExt8:$src), addr:$dst),
2001 (implicit EFLAGS)]>,
Evan Cheng0ef3a772005-12-13 01:41:36 +00002002 OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00002003 def OR32mi8 : Ii8<0x83, MRM1m, (outs), (ins i32mem:$dst, i32i8imm:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002004 "or{l}\t{$src, $dst|$dst, $src}",
Dan Gohman09a2609e2009-03-03 19:53:46 +00002005 [(store (or (load addr:$dst), i32immSExt8:$src), addr:$dst),
2006 (implicit EFLAGS)]>;
Sean Callanand00025a2009-09-11 19:01:56 +00002007
2008 def OR8i8 : Ii8 <0x0C, RawFrm, (outs), (ins i8imm:$src),
2009 "or{b}\t{$src, %al|%al, $src}", []>;
2010 def OR16i16 : Ii16 <0x0D, RawFrm, (outs), (ins i16imm:$src),
2011 "or{w}\t{$src, %ax|%ax, $src}", []>, OpSize;
2012 def OR32i32 : Ii32 <0x0D, RawFrm, (outs), (ins i32imm:$src),
2013 "or{l}\t{$src, %eax|%eax, $src}", []>;
Bill Wendlingbd0879d2008-05-29 01:02:09 +00002014} // isTwoAddress = 0
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00002015
2016
Evan Cheng359e9372008-06-18 08:13:07 +00002017let isCommutable = 1 in { // X = XOR Y, Z --> X = XOR Z, Y
Bill Wendlingbd0879d2008-05-29 01:02:09 +00002018 def XOR8rr : I<0x30, MRMDestReg,
2019 (outs GR8 :$dst), (ins GR8 :$src1, GR8 :$src2),
2020 "xor{b}\t{$src2, $dst|$dst, $src2}",
Chris Lattner589ad5d2010-03-25 05:44:01 +00002021 [(set GR8:$dst, EFLAGS, (X86xor_flag GR8:$src1,
2022 GR8:$src2))]>;
Bill Wendlingbd0879d2008-05-29 01:02:09 +00002023 def XOR16rr : I<0x31, MRMDestReg,
2024 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
2025 "xor{w}\t{$src2, $dst|$dst, $src2}",
Chris Lattner589ad5d2010-03-25 05:44:01 +00002026 [(set GR16:$dst, EFLAGS, (X86xor_flag GR16:$src1,
2027 GR16:$src2))]>, OpSize;
Bill Wendlingbd0879d2008-05-29 01:02:09 +00002028 def XOR32rr : I<0x31, MRMDestReg,
2029 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
2030 "xor{l}\t{$src2, $dst|$dst, $src2}",
Chris Lattner589ad5d2010-03-25 05:44:01 +00002031 [(set GR32:$dst, EFLAGS, (X86xor_flag GR32:$src1,
2032 GR32:$src2))]>;
Evan Cheng359e9372008-06-18 08:13:07 +00002033} // isCommutable = 1
Chris Lattnercc65bee2005-01-02 02:35:46 +00002034
Sean Callanan108934c2009-12-18 00:01:26 +00002035// XOR instructions with the destination register in REG and the source register
2036// in R/M. Included for the disassembler.
2037def XOR8rr_REV : I<0x32, MRMSrcReg, (outs GR8:$dst), (ins GR8:$src1, GR8:$src2),
2038 "xor{b}\t{$src2, $dst|$dst, $src2}", []>;
2039def XOR16rr_REV : I<0x33, MRMSrcReg, (outs GR16:$dst),
2040 (ins GR16:$src1, GR16:$src2),
2041 "xor{w}\t{$src2, $dst|$dst, $src2}", []>, OpSize;
2042def XOR32rr_REV : I<0x33, MRMSrcReg, (outs GR32:$dst),
2043 (ins GR32:$src1, GR32:$src2),
2044 "xor{l}\t{$src2, $dst|$dst, $src2}", []>;
2045
Chris Lattner589ad5d2010-03-25 05:44:01 +00002046def XOR8rm : I<0x32, MRMSrcMem,
Evan Cheng64d80e32007-07-19 01:14:50 +00002047 (outs GR8 :$dst), (ins GR8:$src1, i8mem :$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002048 "xor{b}\t{$src2, $dst|$dst, $src2}",
Chris Lattner589ad5d2010-03-25 05:44:01 +00002049 [(set GR8:$dst, EFLAGS, (X86xor_flag GR8:$src1,
2050 (load addr:$src2)))]>;
2051def XOR16rm : I<0x33, MRMSrcMem,
Evan Cheng64d80e32007-07-19 01:14:50 +00002052 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002053 "xor{w}\t{$src2, $dst|$dst, $src2}",
Chris Lattner589ad5d2010-03-25 05:44:01 +00002054 [(set GR16:$dst, EFLAGS, (X86xor_flag GR16:$src1,
2055 (load addr:$src2)))]>,
Bill Wendlingbd0879d2008-05-29 01:02:09 +00002056 OpSize;
Chris Lattner589ad5d2010-03-25 05:44:01 +00002057def XOR32rm : I<0x33, MRMSrcMem,
Evan Cheng64d80e32007-07-19 01:14:50 +00002058 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002059 "xor{l}\t{$src2, $dst|$dst, $src2}",
Chris Lattner589ad5d2010-03-25 05:44:01 +00002060 [(set GR32:$dst, EFLAGS, (X86xor_flag GR32:$src1,
2061 (load addr:$src2)))]>;
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00002062
Chris Lattner589ad5d2010-03-25 05:44:01 +00002063def XOR8ri : Ii8<0x80, MRM6r,
2064 (outs GR8:$dst), (ins GR8:$src1, i8imm:$src2),
2065 "xor{b}\t{$src2, $dst|$dst, $src2}",
2066 [(set GR8:$dst, EFLAGS, (X86xor_flag GR8:$src1, imm:$src2))]>;
2067def XOR16ri : Ii16<0x81, MRM6r,
2068 (outs GR16:$dst), (ins GR16:$src1, i16imm:$src2),
2069 "xor{w}\t{$src2, $dst|$dst, $src2}",
2070 [(set GR16:$dst, EFLAGS, (X86xor_flag GR16:$src1,
2071 imm:$src2))]>, OpSize;
Bill Wendling75cf88f2008-05-29 03:46:36 +00002072def XOR32ri : Ii32<0x81, MRM6r,
2073 (outs GR32:$dst), (ins GR32:$src1, i32imm:$src2),
2074 "xor{l}\t{$src2, $dst|$dst, $src2}",
Chris Lattner589ad5d2010-03-25 05:44:01 +00002075 [(set GR32:$dst, EFLAGS, (X86xor_flag GR32:$src1,
2076 imm:$src2))]>;
Bill Wendling75cf88f2008-05-29 03:46:36 +00002077def XOR16ri8 : Ii8<0x83, MRM6r,
2078 (outs GR16:$dst), (ins GR16:$src1, i16i8imm:$src2),
2079 "xor{w}\t{$src2, $dst|$dst, $src2}",
Chris Lattner589ad5d2010-03-25 05:44:01 +00002080 [(set GR16:$dst, EFLAGS, (X86xor_flag GR16:$src1,
2081 i16immSExt8:$src2))]>,
Bill Wendling75cf88f2008-05-29 03:46:36 +00002082 OpSize;
2083def XOR32ri8 : Ii8<0x83, MRM6r,
2084 (outs GR32:$dst), (ins GR32:$src1, i32i8imm:$src2),
2085 "xor{l}\t{$src2, $dst|$dst, $src2}",
Chris Lattner589ad5d2010-03-25 05:44:01 +00002086 [(set GR32:$dst, EFLAGS, (X86xor_flag GR32:$src1,
2087 i32immSExt8:$src2))]>;
Bill Wendlingbd0879d2008-05-29 01:02:09 +00002088
Chris Lattner57a02302004-08-11 04:31:00 +00002089let isTwoAddress = 0 in {
Chris Lattner3a173df2004-10-03 20:35:00 +00002090 def XOR8mr : I<0x30, MRMDestMem,
Evan Cheng64d80e32007-07-19 01:14:50 +00002091 (outs), (ins i8mem :$dst, GR8 :$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002092 "xor{b}\t{$src, $dst|$dst, $src}",
Dan Gohman09a2609e2009-03-03 19:53:46 +00002093 [(store (xor (load addr:$dst), GR8:$src), addr:$dst),
2094 (implicit EFLAGS)]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00002095 def XOR16mr : I<0x31, MRMDestMem,
Evan Cheng64d80e32007-07-19 01:14:50 +00002096 (outs), (ins i16mem:$dst, GR16:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002097 "xor{w}\t{$src, $dst|$dst, $src}",
Dan Gohman09a2609e2009-03-03 19:53:46 +00002098 [(store (xor (load addr:$dst), GR16:$src), addr:$dst),
2099 (implicit EFLAGS)]>,
Evan Cheng0ef3a772005-12-13 01:41:36 +00002100 OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00002101 def XOR32mr : I<0x31, MRMDestMem,
Evan Cheng64d80e32007-07-19 01:14:50 +00002102 (outs), (ins i32mem:$dst, GR32:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002103 "xor{l}\t{$src, $dst|$dst, $src}",
Dan Gohman09a2609e2009-03-03 19:53:46 +00002104 [(store (xor (load addr:$dst), GR32:$src), addr:$dst),
2105 (implicit EFLAGS)]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00002106 def XOR8mi : Ii8<0x80, MRM6m,
Evan Cheng64d80e32007-07-19 01:14:50 +00002107 (outs), (ins i8mem :$dst, i8imm :$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002108 "xor{b}\t{$src, $dst|$dst, $src}",
Dan Gohman09a2609e2009-03-03 19:53:46 +00002109 [(store (xor (loadi8 addr:$dst), imm:$src), addr:$dst),
2110 (implicit EFLAGS)]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00002111 def XOR16mi : Ii16<0x81, MRM6m,
Evan Cheng64d80e32007-07-19 01:14:50 +00002112 (outs), (ins i16mem:$dst, i16imm:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002113 "xor{w}\t{$src, $dst|$dst, $src}",
Dan Gohman09a2609e2009-03-03 19:53:46 +00002114 [(store (xor (loadi16 addr:$dst), imm:$src), addr:$dst),
2115 (implicit EFLAGS)]>,
Evan Cheng0ef3a772005-12-13 01:41:36 +00002116 OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00002117 def XOR32mi : Ii32<0x81, MRM6m,
Evan Cheng64d80e32007-07-19 01:14:50 +00002118 (outs), (ins i32mem:$dst, i32imm:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002119 "xor{l}\t{$src, $dst|$dst, $src}",
Dan Gohman09a2609e2009-03-03 19:53:46 +00002120 [(store (xor (loadi32 addr:$dst), imm:$src), addr:$dst),
2121 (implicit EFLAGS)]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00002122 def XOR16mi8 : Ii8<0x83, MRM6m,
Evan Cheng64d80e32007-07-19 01:14:50 +00002123 (outs), (ins i16mem:$dst, i16i8imm :$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002124 "xor{w}\t{$src, $dst|$dst, $src}",
Dan Gohman09a2609e2009-03-03 19:53:46 +00002125 [(store (xor (load addr:$dst), i16immSExt8:$src), addr:$dst),
2126 (implicit EFLAGS)]>,
Evan Cheng0ef3a772005-12-13 01:41:36 +00002127 OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00002128 def XOR32mi8 : Ii8<0x83, MRM6m,
Evan Cheng64d80e32007-07-19 01:14:50 +00002129 (outs), (ins i32mem:$dst, i32i8imm :$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002130 "xor{l}\t{$src, $dst|$dst, $src}",
Dan Gohman09a2609e2009-03-03 19:53:46 +00002131 [(store (xor (load addr:$dst), i32immSExt8:$src), addr:$dst),
2132 (implicit EFLAGS)]>;
Sean Callanan7893ec62009-09-10 19:52:26 +00002133
Chris Lattner589ad5d2010-03-25 05:44:01 +00002134 def XOR8i8 : Ii8 <0x34, RawFrm, (outs), (ins i8imm:$src),
2135 "xor{b}\t{$src, %al|%al, $src}", []>;
2136 def XOR16i16 : Ii16<0x35, RawFrm, (outs), (ins i16imm:$src),
2137 "xor{w}\t{$src, %ax|%ax, $src}", []>, OpSize;
2138 def XOR32i32 : Ii32<0x35, RawFrm, (outs), (ins i32imm:$src),
2139 "xor{l}\t{$src, %eax|%eax, $src}", []>;
Bill Wendlingbd0879d2008-05-29 01:02:09 +00002140} // isTwoAddress = 0
Evan Cheng24f2ea32007-09-14 21:48:26 +00002141} // Defs = [EFLAGS]
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00002142
2143// Shift instructions
Evan Cheng24f2ea32007-09-14 21:48:26 +00002144let Defs = [EFLAGS] in {
Evan Cheng071a2792007-09-11 19:55:27 +00002145let Uses = [CL] in {
Evan Cheng64d80e32007-07-19 01:14:50 +00002146def SHL8rCL : I<0xD2, MRM4r, (outs GR8 :$dst), (ins GR8 :$src),
Eli Friedmanaace4b12009-06-19 04:48:38 +00002147 "shl{b}\t{%cl, $dst|$dst, CL}",
Evan Cheng071a2792007-09-11 19:55:27 +00002148 [(set GR8:$dst, (shl GR8:$src, CL))]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00002149def SHL16rCL : I<0xD3, MRM4r, (outs GR16:$dst), (ins GR16:$src),
Eli Friedmanaace4b12009-06-19 04:48:38 +00002150 "shl{w}\t{%cl, $dst|$dst, CL}",
Evan Cheng071a2792007-09-11 19:55:27 +00002151 [(set GR16:$dst, (shl GR16:$src, CL))]>, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00002152def SHL32rCL : I<0xD3, MRM4r, (outs GR32:$dst), (ins GR32:$src),
Eli Friedmanaace4b12009-06-19 04:48:38 +00002153 "shl{l}\t{%cl, $dst|$dst, CL}",
Evan Cheng071a2792007-09-11 19:55:27 +00002154 [(set GR32:$dst, (shl GR32:$src, CL))]>;
Bill Wendlingbd0879d2008-05-29 01:02:09 +00002155} // Uses = [CL]
Chris Lattnercc65bee2005-01-02 02:35:46 +00002156
Evan Cheng64d80e32007-07-19 01:14:50 +00002157def SHL8ri : Ii8<0xC0, MRM4r, (outs GR8 :$dst), (ins GR8 :$src1, i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002158 "shl{b}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00002159 [(set GR8:$dst, (shl GR8:$src1, (i8 imm:$src2)))]>;
Chris Lattnercc65bee2005-01-02 02:35:46 +00002160let isConvertibleToThreeAddress = 1 in { // Can transform into LEA.
Evan Cheng64d80e32007-07-19 01:14:50 +00002161def SHL16ri : Ii8<0xC1, MRM4r, (outs GR16:$dst), (ins GR16:$src1, i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002162 "shl{w}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00002163 [(set GR16:$dst, (shl GR16:$src1, (i8 imm:$src2)))]>, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00002164def SHL32ri : Ii8<0xC1, MRM4r, (outs GR32:$dst), (ins GR32:$src1, i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002165 "shl{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00002166 [(set GR32:$dst, (shl GR32:$src1, (i8 imm:$src2)))]>;
Sean Callanan13cf8e92009-09-16 02:28:43 +00002167
2168// NOTE: We don't include patterns for shifts of a register by one, because
2169// 'add reg,reg' is cheaper.
2170
2171def SHL8r1 : I<0xD0, MRM4r, (outs GR8:$dst), (ins GR8:$src1),
2172 "shl{b}\t$dst", []>;
2173def SHL16r1 : I<0xD1, MRM4r, (outs GR16:$dst), (ins GR16:$src1),
2174 "shl{w}\t$dst", []>, OpSize;
2175def SHL32r1 : I<0xD1, MRM4r, (outs GR32:$dst), (ins GR32:$src1),
2176 "shl{l}\t$dst", []>;
2177
Bill Wendlingbd0879d2008-05-29 01:02:09 +00002178} // isConvertibleToThreeAddress = 1
Evan Cheng09c54572006-06-29 00:36:51 +00002179
Chris Lattnerf29ed092004-08-11 05:07:25 +00002180let isTwoAddress = 0 in {
Evan Cheng071a2792007-09-11 19:55:27 +00002181 let Uses = [CL] in {
Evan Cheng64d80e32007-07-19 01:14:50 +00002182 def SHL8mCL : I<0xD2, MRM4m, (outs), (ins i8mem :$dst),
Eli Friedmanaace4b12009-06-19 04:48:38 +00002183 "shl{b}\t{%cl, $dst|$dst, CL}",
Evan Cheng071a2792007-09-11 19:55:27 +00002184 [(store (shl (loadi8 addr:$dst), CL), addr:$dst)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00002185 def SHL16mCL : I<0xD3, MRM4m, (outs), (ins i16mem:$dst),
Eli Friedmanaace4b12009-06-19 04:48:38 +00002186 "shl{w}\t{%cl, $dst|$dst, CL}",
Evan Cheng071a2792007-09-11 19:55:27 +00002187 [(store (shl (loadi16 addr:$dst), CL), addr:$dst)]>, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00002188 def SHL32mCL : I<0xD3, MRM4m, (outs), (ins i32mem:$dst),
Eli Friedmanaace4b12009-06-19 04:48:38 +00002189 "shl{l}\t{%cl, $dst|$dst, CL}",
Evan Cheng071a2792007-09-11 19:55:27 +00002190 [(store (shl (loadi32 addr:$dst), CL), addr:$dst)]>;
2191 }
Evan Cheng64d80e32007-07-19 01:14:50 +00002192 def SHL8mi : Ii8<0xC0, MRM4m, (outs), (ins i8mem :$dst, i8imm:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002193 "shl{b}\t{$src, $dst|$dst, $src}",
Evan Cheng763b0292005-12-13 02:34:51 +00002194 [(store (shl (loadi8 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00002195 def SHL16mi : Ii8<0xC1, MRM4m, (outs), (ins i16mem:$dst, i8imm:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002196 "shl{w}\t{$src, $dst|$dst, $src}",
Evan Cheng763b0292005-12-13 02:34:51 +00002197 [(store (shl (loadi16 addr:$dst), (i8 imm:$src)), addr:$dst)]>,
2198 OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00002199 def SHL32mi : Ii8<0xC1, MRM4m, (outs), (ins i32mem:$dst, i8imm:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002200 "shl{l}\t{$src, $dst|$dst, $src}",
Evan Cheng763b0292005-12-13 02:34:51 +00002201 [(store (shl (loadi32 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
Evan Cheng09c54572006-06-29 00:36:51 +00002202
2203 // Shift by 1
Evan Cheng64d80e32007-07-19 01:14:50 +00002204 def SHL8m1 : I<0xD0, MRM4m, (outs), (ins i8mem :$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002205 "shl{b}\t$dst",
Evan Cheng09c54572006-06-29 00:36:51 +00002206 [(store (shl (loadi8 addr:$dst), (i8 1)), addr:$dst)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00002207 def SHL16m1 : I<0xD1, MRM4m, (outs), (ins i16mem:$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002208 "shl{w}\t$dst",
Evan Cheng09c54572006-06-29 00:36:51 +00002209 [(store (shl (loadi16 addr:$dst), (i8 1)), addr:$dst)]>,
2210 OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00002211 def SHL32m1 : I<0xD1, MRM4m, (outs), (ins i32mem:$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002212 "shl{l}\t$dst",
Evan Cheng09c54572006-06-29 00:36:51 +00002213 [(store (shl (loadi32 addr:$dst), (i8 1)), addr:$dst)]>;
Chris Lattnerf29ed092004-08-11 05:07:25 +00002214}
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00002215
Evan Cheng071a2792007-09-11 19:55:27 +00002216let Uses = [CL] in {
Evan Cheng64d80e32007-07-19 01:14:50 +00002217def SHR8rCL : I<0xD2, MRM5r, (outs GR8 :$dst), (ins GR8 :$src),
Eli Friedmanaace4b12009-06-19 04:48:38 +00002218 "shr{b}\t{%cl, $dst|$dst, CL}",
Evan Cheng071a2792007-09-11 19:55:27 +00002219 [(set GR8:$dst, (srl GR8:$src, CL))]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00002220def SHR16rCL : I<0xD3, MRM5r, (outs GR16:$dst), (ins GR16:$src),
Eli Friedmanaace4b12009-06-19 04:48:38 +00002221 "shr{w}\t{%cl, $dst|$dst, CL}",
Evan Cheng071a2792007-09-11 19:55:27 +00002222 [(set GR16:$dst, (srl GR16:$src, CL))]>, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00002223def SHR32rCL : I<0xD3, MRM5r, (outs GR32:$dst), (ins GR32:$src),
Eli Friedmanaace4b12009-06-19 04:48:38 +00002224 "shr{l}\t{%cl, $dst|$dst, CL}",
Evan Cheng071a2792007-09-11 19:55:27 +00002225 [(set GR32:$dst, (srl GR32:$src, CL))]>;
2226}
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00002227
Evan Cheng64d80e32007-07-19 01:14:50 +00002228def SHR8ri : Ii8<0xC0, MRM5r, (outs GR8:$dst), (ins GR8:$src1, i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002229 "shr{b}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00002230 [(set GR8:$dst, (srl GR8:$src1, (i8 imm:$src2)))]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00002231def SHR16ri : Ii8<0xC1, MRM5r, (outs GR16:$dst), (ins GR16:$src1, i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002232 "shr{w}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00002233 [(set GR16:$dst, (srl GR16:$src1, (i8 imm:$src2)))]>, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00002234def SHR32ri : Ii8<0xC1, MRM5r, (outs GR32:$dst), (ins GR32:$src1, i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002235 "shr{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00002236 [(set GR32:$dst, (srl GR32:$src1, (i8 imm:$src2)))]>;
Chris Lattnerf29ed092004-08-11 05:07:25 +00002237
Evan Cheng09c54572006-06-29 00:36:51 +00002238// Shift by 1
Evan Cheng64d80e32007-07-19 01:14:50 +00002239def SHR8r1 : I<0xD0, MRM5r, (outs GR8:$dst), (ins GR8:$src1),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002240 "shr{b}\t$dst",
Evan Cheng09c54572006-06-29 00:36:51 +00002241 [(set GR8:$dst, (srl GR8:$src1, (i8 1)))]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00002242def SHR16r1 : I<0xD1, MRM5r, (outs GR16:$dst), (ins GR16:$src1),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002243 "shr{w}\t$dst",
Evan Cheng09c54572006-06-29 00:36:51 +00002244 [(set GR16:$dst, (srl GR16:$src1, (i8 1)))]>, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00002245def SHR32r1 : I<0xD1, MRM5r, (outs GR32:$dst), (ins GR32:$src1),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002246 "shr{l}\t$dst",
Evan Cheng09c54572006-06-29 00:36:51 +00002247 [(set GR32:$dst, (srl GR32:$src1, (i8 1)))]>;
2248
Chris Lattner57a02302004-08-11 04:31:00 +00002249let isTwoAddress = 0 in {
Evan Cheng071a2792007-09-11 19:55:27 +00002250 let Uses = [CL] in {
Evan Cheng64d80e32007-07-19 01:14:50 +00002251 def SHR8mCL : I<0xD2, MRM5m, (outs), (ins i8mem :$dst),
Eli Friedmanaace4b12009-06-19 04:48:38 +00002252 "shr{b}\t{%cl, $dst|$dst, CL}",
Evan Cheng071a2792007-09-11 19:55:27 +00002253 [(store (srl (loadi8 addr:$dst), CL), addr:$dst)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00002254 def SHR16mCL : I<0xD3, MRM5m, (outs), (ins i16mem:$dst),
Eli Friedmanaace4b12009-06-19 04:48:38 +00002255 "shr{w}\t{%cl, $dst|$dst, CL}",
Evan Cheng85dd8892005-12-13 07:24:22 +00002256 [(store (srl (loadi16 addr:$dst), CL), addr:$dst)]>,
Evan Cheng071a2792007-09-11 19:55:27 +00002257 OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00002258 def SHR32mCL : I<0xD3, MRM5m, (outs), (ins i32mem:$dst),
Eli Friedmanaace4b12009-06-19 04:48:38 +00002259 "shr{l}\t{%cl, $dst|$dst, CL}",
Evan Cheng071a2792007-09-11 19:55:27 +00002260 [(store (srl (loadi32 addr:$dst), CL), addr:$dst)]>;
2261 }
Evan Cheng64d80e32007-07-19 01:14:50 +00002262 def SHR8mi : Ii8<0xC0, MRM5m, (outs), (ins i8mem :$dst, i8imm:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002263 "shr{b}\t{$src, $dst|$dst, $src}",
Evan Cheng85dd8892005-12-13 07:24:22 +00002264 [(store (srl (loadi8 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00002265 def SHR16mi : Ii8<0xC1, MRM5m, (outs), (ins i16mem:$dst, i8imm:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002266 "shr{w}\t{$src, $dst|$dst, $src}",
Evan Cheng85dd8892005-12-13 07:24:22 +00002267 [(store (srl (loadi16 addr:$dst), (i8 imm:$src)), addr:$dst)]>,
2268 OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00002269 def SHR32mi : Ii8<0xC1, MRM5m, (outs), (ins i32mem:$dst, i8imm:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002270 "shr{l}\t{$src, $dst|$dst, $src}",
Evan Cheng85dd8892005-12-13 07:24:22 +00002271 [(store (srl (loadi32 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
Evan Cheng09c54572006-06-29 00:36:51 +00002272
2273 // Shift by 1
Evan Cheng64d80e32007-07-19 01:14:50 +00002274 def SHR8m1 : I<0xD0, MRM5m, (outs), (ins i8mem :$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002275 "shr{b}\t$dst",
Evan Cheng09c54572006-06-29 00:36:51 +00002276 [(store (srl (loadi8 addr:$dst), (i8 1)), addr:$dst)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00002277 def SHR16m1 : I<0xD1, MRM5m, (outs), (ins i16mem:$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002278 "shr{w}\t$dst",
Evan Cheng09c54572006-06-29 00:36:51 +00002279 [(store (srl (loadi16 addr:$dst), (i8 1)), addr:$dst)]>,OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00002280 def SHR32m1 : I<0xD1, MRM5m, (outs), (ins i32mem:$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002281 "shr{l}\t$dst",
Evan Cheng09c54572006-06-29 00:36:51 +00002282 [(store (srl (loadi32 addr:$dst), (i8 1)), addr:$dst)]>;
Chris Lattner57a02302004-08-11 04:31:00 +00002283}
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00002284
Evan Cheng071a2792007-09-11 19:55:27 +00002285let Uses = [CL] in {
Evan Cheng64d80e32007-07-19 01:14:50 +00002286def SAR8rCL : I<0xD2, MRM7r, (outs GR8 :$dst), (ins GR8 :$src),
Eli Friedmanaace4b12009-06-19 04:48:38 +00002287 "sar{b}\t{%cl, $dst|$dst, CL}",
Evan Cheng071a2792007-09-11 19:55:27 +00002288 [(set GR8:$dst, (sra GR8:$src, CL))]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00002289def SAR16rCL : I<0xD3, MRM7r, (outs GR16:$dst), (ins GR16:$src),
Eli Friedmanaace4b12009-06-19 04:48:38 +00002290 "sar{w}\t{%cl, $dst|$dst, CL}",
Evan Cheng071a2792007-09-11 19:55:27 +00002291 [(set GR16:$dst, (sra GR16:$src, CL))]>, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00002292def SAR32rCL : I<0xD3, MRM7r, (outs GR32:$dst), (ins GR32:$src),
Eli Friedmanaace4b12009-06-19 04:48:38 +00002293 "sar{l}\t{%cl, $dst|$dst, CL}",
Evan Cheng071a2792007-09-11 19:55:27 +00002294 [(set GR32:$dst, (sra GR32:$src, CL))]>;
2295}
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00002296
Evan Cheng64d80e32007-07-19 01:14:50 +00002297def SAR8ri : Ii8<0xC0, MRM7r, (outs GR8 :$dst), (ins GR8 :$src1, i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002298 "sar{b}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00002299 [(set GR8:$dst, (sra GR8:$src1, (i8 imm:$src2)))]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00002300def SAR16ri : Ii8<0xC1, MRM7r, (outs GR16:$dst), (ins GR16:$src1, i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002301 "sar{w}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00002302 [(set GR16:$dst, (sra GR16:$src1, (i8 imm:$src2)))]>,
Chris Lattner3d36a9f2005-12-05 02:40:25 +00002303 OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00002304def SAR32ri : Ii8<0xC1, MRM7r, (outs GR32:$dst), (ins GR32:$src1, i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002305 "sar{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00002306 [(set GR32:$dst, (sra GR32:$src1, (i8 imm:$src2)))]>;
Evan Cheng09c54572006-06-29 00:36:51 +00002307
2308// Shift by 1
Evan Cheng64d80e32007-07-19 01:14:50 +00002309def SAR8r1 : I<0xD0, MRM7r, (outs GR8 :$dst), (ins GR8 :$src1),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002310 "sar{b}\t$dst",
Evan Cheng09c54572006-06-29 00:36:51 +00002311 [(set GR8:$dst, (sra GR8:$src1, (i8 1)))]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00002312def SAR16r1 : I<0xD1, MRM7r, (outs GR16:$dst), (ins GR16:$src1),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002313 "sar{w}\t$dst",
Evan Cheng09c54572006-06-29 00:36:51 +00002314 [(set GR16:$dst, (sra GR16:$src1, (i8 1)))]>, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00002315def SAR32r1 : I<0xD1, MRM7r, (outs GR32:$dst), (ins GR32:$src1),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002316 "sar{l}\t$dst",
Evan Cheng09c54572006-06-29 00:36:51 +00002317 [(set GR32:$dst, (sra GR32:$src1, (i8 1)))]>;
2318
Chris Lattnerf29ed092004-08-11 05:07:25 +00002319let isTwoAddress = 0 in {
Evan Cheng071a2792007-09-11 19:55:27 +00002320 let Uses = [CL] in {
Evan Cheng64d80e32007-07-19 01:14:50 +00002321 def SAR8mCL : I<0xD2, MRM7m, (outs), (ins i8mem :$dst),
Eli Friedmanaace4b12009-06-19 04:48:38 +00002322 "sar{b}\t{%cl, $dst|$dst, CL}",
Evan Cheng071a2792007-09-11 19:55:27 +00002323 [(store (sra (loadi8 addr:$dst), CL), addr:$dst)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00002324 def SAR16mCL : I<0xD3, MRM7m, (outs), (ins i16mem:$dst),
Eli Friedmanaace4b12009-06-19 04:48:38 +00002325 "sar{w}\t{%cl, $dst|$dst, CL}",
Evan Cheng071a2792007-09-11 19:55:27 +00002326 [(store (sra (loadi16 addr:$dst), CL), addr:$dst)]>, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00002327 def SAR32mCL : I<0xD3, MRM7m, (outs), (ins i32mem:$dst),
Eli Friedmanaace4b12009-06-19 04:48:38 +00002328 "sar{l}\t{%cl, $dst|$dst, CL}",
Evan Cheng071a2792007-09-11 19:55:27 +00002329 [(store (sra (loadi32 addr:$dst), CL), addr:$dst)]>;
2330 }
Evan Cheng64d80e32007-07-19 01:14:50 +00002331 def SAR8mi : Ii8<0xC0, MRM7m, (outs), (ins i8mem :$dst, i8imm:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002332 "sar{b}\t{$src, $dst|$dst, $src}",
Evan Cheng85dd8892005-12-13 07:24:22 +00002333 [(store (sra (loadi8 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00002334 def SAR16mi : Ii8<0xC1, MRM7m, (outs), (ins i16mem:$dst, i8imm:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002335 "sar{w}\t{$src, $dst|$dst, $src}",
Evan Cheng85dd8892005-12-13 07:24:22 +00002336 [(store (sra (loadi16 addr:$dst), (i8 imm:$src)), addr:$dst)]>,
2337 OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00002338 def SAR32mi : Ii8<0xC1, MRM7m, (outs), (ins i32mem:$dst, i8imm:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002339 "sar{l}\t{$src, $dst|$dst, $src}",
Evan Cheng85dd8892005-12-13 07:24:22 +00002340 [(store (sra (loadi32 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
Evan Cheng09c54572006-06-29 00:36:51 +00002341
2342 // Shift by 1
Evan Cheng64d80e32007-07-19 01:14:50 +00002343 def SAR8m1 : I<0xD0, MRM7m, (outs), (ins i8mem :$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002344 "sar{b}\t$dst",
Evan Cheng09c54572006-06-29 00:36:51 +00002345 [(store (sra (loadi8 addr:$dst), (i8 1)), addr:$dst)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00002346 def SAR16m1 : I<0xD1, MRM7m, (outs), (ins i16mem:$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002347 "sar{w}\t$dst",
Evan Cheng09c54572006-06-29 00:36:51 +00002348 [(store (sra (loadi16 addr:$dst), (i8 1)), addr:$dst)]>,
2349 OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00002350 def SAR32m1 : I<0xD1, MRM7m, (outs), (ins i32mem:$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002351 "sar{l}\t$dst",
Evan Cheng09c54572006-06-29 00:36:51 +00002352 [(store (sra (loadi32 addr:$dst), (i8 1)), addr:$dst)]>;
Chris Lattnerf29ed092004-08-11 05:07:25 +00002353}
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00002354
Chris Lattner40ff6332005-01-19 07:50:03 +00002355// Rotate instructions
Sean Callanana2dc2822009-09-18 19:35:23 +00002356
2357def RCL8r1 : I<0xD0, MRM2r, (outs GR8:$dst), (ins GR8:$src),
2358 "rcl{b}\t{1, $dst|$dst, 1}", []>;
Sean Callanana2dc2822009-09-18 19:35:23 +00002359let Uses = [CL] in {
2360def RCL8rCL : I<0xD2, MRM2r, (outs GR8:$dst), (ins GR8:$src),
2361 "rcl{b}\t{%cl, $dst|$dst, CL}", []>;
Sean Callanana2dc2822009-09-18 19:35:23 +00002362}
2363def RCL8ri : Ii8<0xC0, MRM2r, (outs GR8:$dst), (ins GR8:$src, i8imm:$cnt),
2364 "rcl{b}\t{$cnt, $dst|$dst, $cnt}", []>;
Sean Callanana2dc2822009-09-18 19:35:23 +00002365
2366def RCL16r1 : I<0xD1, MRM2r, (outs GR16:$dst), (ins GR16:$src),
2367 "rcl{w}\t{1, $dst|$dst, 1}", []>, OpSize;
Sean Callanana2dc2822009-09-18 19:35:23 +00002368let Uses = [CL] in {
2369def RCL16rCL : I<0xD3, MRM2r, (outs GR16:$dst), (ins GR16:$src),
2370 "rcl{w}\t{%cl, $dst|$dst, CL}", []>, OpSize;
Sean Callanana2dc2822009-09-18 19:35:23 +00002371}
2372def RCL16ri : Ii8<0xC1, MRM2r, (outs GR16:$dst), (ins GR16:$src, i8imm:$cnt),
2373 "rcl{w}\t{$cnt, $dst|$dst, $cnt}", []>, OpSize;
Sean Callanana2dc2822009-09-18 19:35:23 +00002374
2375def RCL32r1 : I<0xD1, MRM2r, (outs GR32:$dst), (ins GR32:$src),
2376 "rcl{l}\t{1, $dst|$dst, 1}", []>;
Sean Callanana2dc2822009-09-18 19:35:23 +00002377let Uses = [CL] in {
2378def RCL32rCL : I<0xD3, MRM2r, (outs GR32:$dst), (ins GR32:$src),
2379 "rcl{l}\t{%cl, $dst|$dst, CL}", []>;
Sean Callanana2dc2822009-09-18 19:35:23 +00002380}
2381def RCL32ri : Ii8<0xC1, MRM2r, (outs GR32:$dst), (ins GR32:$src, i8imm:$cnt),
2382 "rcl{l}\t{$cnt, $dst|$dst, $cnt}", []>;
Sean Callanana2dc2822009-09-18 19:35:23 +00002383
2384def RCR8r1 : I<0xD0, MRM3r, (outs GR8:$dst), (ins GR8:$src),
2385 "rcr{b}\t{1, $dst|$dst, 1}", []>;
Sean Callanana2dc2822009-09-18 19:35:23 +00002386let Uses = [CL] in {
2387def RCR8rCL : I<0xD2, MRM3r, (outs GR8:$dst), (ins GR8:$src),
2388 "rcr{b}\t{%cl, $dst|$dst, CL}", []>;
Sean Callanana2dc2822009-09-18 19:35:23 +00002389}
2390def RCR8ri : Ii8<0xC0, MRM3r, (outs GR8:$dst), (ins GR8:$src, i8imm:$cnt),
2391 "rcr{b}\t{$cnt, $dst|$dst, $cnt}", []>;
Sean Callanana2dc2822009-09-18 19:35:23 +00002392
2393def RCR16r1 : I<0xD1, MRM3r, (outs GR16:$dst), (ins GR16:$src),
2394 "rcr{w}\t{1, $dst|$dst, 1}", []>, OpSize;
Sean Callanana2dc2822009-09-18 19:35:23 +00002395let Uses = [CL] in {
2396def RCR16rCL : I<0xD3, MRM3r, (outs GR16:$dst), (ins GR16:$src),
2397 "rcr{w}\t{%cl, $dst|$dst, CL}", []>, OpSize;
Sean Callanana2dc2822009-09-18 19:35:23 +00002398}
2399def RCR16ri : Ii8<0xC1, MRM3r, (outs GR16:$dst), (ins GR16:$src, i8imm:$cnt),
2400 "rcr{w}\t{$cnt, $dst|$dst, $cnt}", []>, OpSize;
Sean Callanana2dc2822009-09-18 19:35:23 +00002401
2402def RCR32r1 : I<0xD1, MRM3r, (outs GR32:$dst), (ins GR32:$src),
2403 "rcr{l}\t{1, $dst|$dst, 1}", []>;
Sean Callanana2dc2822009-09-18 19:35:23 +00002404let Uses = [CL] in {
2405def RCR32rCL : I<0xD3, MRM3r, (outs GR32:$dst), (ins GR32:$src),
2406 "rcr{l}\t{%cl, $dst|$dst, CL}", []>;
Sean Callanana2dc2822009-09-18 19:35:23 +00002407}
2408def RCR32ri : Ii8<0xC1, MRM3r, (outs GR32:$dst), (ins GR32:$src, i8imm:$cnt),
2409 "rcr{l}\t{$cnt, $dst|$dst, $cnt}", []>;
Daniel Dunbarccfa1db2010-02-12 01:22:03 +00002410
2411let isTwoAddress = 0 in {
2412def RCL8m1 : I<0xD0, MRM2m, (outs), (ins i8mem:$dst),
2413 "rcl{b}\t{1, $dst|$dst, 1}", []>;
2414def RCL8mi : Ii8<0xC0, MRM2m, (outs), (ins i8mem:$dst, i8imm:$cnt),
2415 "rcl{b}\t{$cnt, $dst|$dst, $cnt}", []>;
2416def RCL16m1 : I<0xD1, MRM2m, (outs), (ins i16mem:$dst),
2417 "rcl{w}\t{1, $dst|$dst, 1}", []>, OpSize;
2418def RCL16mi : Ii8<0xC1, MRM2m, (outs), (ins i16mem:$dst, i8imm:$cnt),
2419 "rcl{w}\t{$cnt, $dst|$dst, $cnt}", []>, OpSize;
2420def RCL32m1 : I<0xD1, MRM2m, (outs), (ins i32mem:$dst),
2421 "rcl{l}\t{1, $dst|$dst, 1}", []>;
2422def RCL32mi : Ii8<0xC1, MRM2m, (outs), (ins i32mem:$dst, i8imm:$cnt),
2423 "rcl{l}\t{$cnt, $dst|$dst, $cnt}", []>;
2424def RCR8m1 : I<0xD0, MRM3m, (outs), (ins i8mem:$dst),
2425 "rcr{b}\t{1, $dst|$dst, 1}", []>;
2426def RCR8mi : Ii8<0xC0, MRM3m, (outs), (ins i8mem:$dst, i8imm:$cnt),
2427 "rcr{b}\t{$cnt, $dst|$dst, $cnt}", []>;
2428def RCR16m1 : I<0xD1, MRM3m, (outs), (ins i16mem:$dst),
2429 "rcr{w}\t{1, $dst|$dst, 1}", []>, OpSize;
2430def RCR16mi : Ii8<0xC1, MRM3m, (outs), (ins i16mem:$dst, i8imm:$cnt),
2431 "rcr{w}\t{$cnt, $dst|$dst, $cnt}", []>, OpSize;
2432def RCR32m1 : I<0xD1, MRM3m, (outs), (ins i32mem:$dst),
2433 "rcr{l}\t{1, $dst|$dst, 1}", []>;
2434def RCR32mi : Ii8<0xC1, MRM3m, (outs), (ins i32mem:$dst, i8imm:$cnt),
Sean Callanana2dc2822009-09-18 19:35:23 +00002435 "rcr{l}\t{$cnt, $dst|$dst, $cnt}", []>;
2436
Daniel Dunbarccfa1db2010-02-12 01:22:03 +00002437let Uses = [CL] in {
2438def RCL8mCL : I<0xD2, MRM2m, (outs), (ins i8mem:$dst),
2439 "rcl{b}\t{%cl, $dst|$dst, CL}", []>;
2440def RCL16mCL : I<0xD3, MRM2m, (outs), (ins i16mem:$dst),
2441 "rcl{w}\t{%cl, $dst|$dst, CL}", []>, OpSize;
2442def RCL32mCL : I<0xD3, MRM2m, (outs), (ins i32mem:$dst),
2443 "rcl{l}\t{%cl, $dst|$dst, CL}", []>;
2444def RCR8mCL : I<0xD2, MRM3m, (outs), (ins i8mem:$dst),
2445 "rcr{b}\t{%cl, $dst|$dst, CL}", []>;
2446def RCR16mCL : I<0xD3, MRM3m, (outs), (ins i16mem:$dst),
2447 "rcr{w}\t{%cl, $dst|$dst, CL}", []>, OpSize;
2448def RCR32mCL : I<0xD3, MRM3m, (outs), (ins i32mem:$dst),
2449 "rcr{l}\t{%cl, $dst|$dst, CL}", []>;
2450}
2451}
2452
Chris Lattner40ff6332005-01-19 07:50:03 +00002453// FIXME: provide shorter instructions when imm8 == 1
Evan Cheng071a2792007-09-11 19:55:27 +00002454let Uses = [CL] in {
Evan Cheng64d80e32007-07-19 01:14:50 +00002455def ROL8rCL : I<0xD2, MRM0r, (outs GR8 :$dst), (ins GR8 :$src),
Eli Friedmanaace4b12009-06-19 04:48:38 +00002456 "rol{b}\t{%cl, $dst|$dst, CL}",
Evan Cheng071a2792007-09-11 19:55:27 +00002457 [(set GR8:$dst, (rotl GR8:$src, CL))]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00002458def ROL16rCL : I<0xD3, MRM0r, (outs GR16:$dst), (ins GR16:$src),
Eli Friedmanaace4b12009-06-19 04:48:38 +00002459 "rol{w}\t{%cl, $dst|$dst, CL}",
Evan Cheng071a2792007-09-11 19:55:27 +00002460 [(set GR16:$dst, (rotl GR16:$src, CL))]>, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00002461def ROL32rCL : I<0xD3, MRM0r, (outs GR32:$dst), (ins GR32:$src),
Eli Friedmanaace4b12009-06-19 04:48:38 +00002462 "rol{l}\t{%cl, $dst|$dst, CL}",
Evan Cheng071a2792007-09-11 19:55:27 +00002463 [(set GR32:$dst, (rotl GR32:$src, CL))]>;
2464}
Chris Lattner40ff6332005-01-19 07:50:03 +00002465
Evan Cheng64d80e32007-07-19 01:14:50 +00002466def ROL8ri : Ii8<0xC0, MRM0r, (outs GR8 :$dst), (ins GR8 :$src1, i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002467 "rol{b}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00002468 [(set GR8:$dst, (rotl GR8:$src1, (i8 imm:$src2)))]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00002469def ROL16ri : Ii8<0xC1, MRM0r, (outs GR16:$dst), (ins GR16:$src1, i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002470 "rol{w}\t{$src2, $dst|$dst, $src2}",
Sean Callanan108934c2009-12-18 00:01:26 +00002471 [(set GR16:$dst, (rotl GR16:$src1, (i8 imm:$src2)))]>,
2472 OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00002473def ROL32ri : Ii8<0xC1, MRM0r, (outs GR32:$dst), (ins GR32:$src1, i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002474 "rol{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00002475 [(set GR32:$dst, (rotl GR32:$src1, (i8 imm:$src2)))]>;
Chris Lattner40ff6332005-01-19 07:50:03 +00002476
Evan Cheng09c54572006-06-29 00:36:51 +00002477// Rotate by 1
Evan Cheng64d80e32007-07-19 01:14:50 +00002478def ROL8r1 : I<0xD0, MRM0r, (outs GR8 :$dst), (ins GR8 :$src1),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002479 "rol{b}\t$dst",
Evan Cheng09c54572006-06-29 00:36:51 +00002480 [(set GR8:$dst, (rotl GR8:$src1, (i8 1)))]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00002481def ROL16r1 : I<0xD1, MRM0r, (outs GR16:$dst), (ins GR16:$src1),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002482 "rol{w}\t$dst",
Evan Cheng09c54572006-06-29 00:36:51 +00002483 [(set GR16:$dst, (rotl GR16:$src1, (i8 1)))]>, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00002484def ROL32r1 : I<0xD1, MRM0r, (outs GR32:$dst), (ins GR32:$src1),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002485 "rol{l}\t$dst",
Evan Cheng09c54572006-06-29 00:36:51 +00002486 [(set GR32:$dst, (rotl GR32:$src1, (i8 1)))]>;
2487
Chris Lattner40ff6332005-01-19 07:50:03 +00002488let isTwoAddress = 0 in {
Evan Cheng071a2792007-09-11 19:55:27 +00002489 let Uses = [CL] in {
Evan Cheng64d80e32007-07-19 01:14:50 +00002490 def ROL8mCL : I<0xD2, MRM0m, (outs), (ins i8mem :$dst),
Eli Friedmanaace4b12009-06-19 04:48:38 +00002491 "rol{b}\t{%cl, $dst|$dst, CL}",
Evan Cheng071a2792007-09-11 19:55:27 +00002492 [(store (rotl (loadi8 addr:$dst), CL), addr:$dst)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00002493 def ROL16mCL : I<0xD3, MRM0m, (outs), (ins i16mem:$dst),
Eli Friedmanaace4b12009-06-19 04:48:38 +00002494 "rol{w}\t{%cl, $dst|$dst, CL}",
Evan Cheng071a2792007-09-11 19:55:27 +00002495 [(store (rotl (loadi16 addr:$dst), CL), addr:$dst)]>, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00002496 def ROL32mCL : I<0xD3, MRM0m, (outs), (ins i32mem:$dst),
Eli Friedmanaace4b12009-06-19 04:48:38 +00002497 "rol{l}\t{%cl, $dst|$dst, CL}",
Evan Cheng071a2792007-09-11 19:55:27 +00002498 [(store (rotl (loadi32 addr:$dst), CL), addr:$dst)]>;
2499 }
Evan Cheng64d80e32007-07-19 01:14:50 +00002500 def ROL8mi : Ii8<0xC0, MRM0m, (outs), (ins i8mem :$dst, i8imm:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002501 "rol{b}\t{$src, $dst|$dst, $src}",
Evan Chengeb422a72006-01-11 23:20:05 +00002502 [(store (rotl (loadi8 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00002503 def ROL16mi : Ii8<0xC1, MRM0m, (outs), (ins i16mem:$dst, i8imm:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002504 "rol{w}\t{$src, $dst|$dst, $src}",
Evan Chengeb422a72006-01-11 23:20:05 +00002505 [(store (rotl (loadi16 addr:$dst), (i8 imm:$src)), addr:$dst)]>,
2506 OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00002507 def ROL32mi : Ii8<0xC1, MRM0m, (outs), (ins i32mem:$dst, i8imm:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002508 "rol{l}\t{$src, $dst|$dst, $src}",
Evan Chengeb422a72006-01-11 23:20:05 +00002509 [(store (rotl (loadi32 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
Evan Cheng09c54572006-06-29 00:36:51 +00002510
2511 // Rotate by 1
Evan Cheng64d80e32007-07-19 01:14:50 +00002512 def ROL8m1 : I<0xD0, MRM0m, (outs), (ins i8mem :$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002513 "rol{b}\t$dst",
Evan Cheng09c54572006-06-29 00:36:51 +00002514 [(store (rotl (loadi8 addr:$dst), (i8 1)), addr:$dst)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00002515 def ROL16m1 : I<0xD1, MRM0m, (outs), (ins i16mem:$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002516 "rol{w}\t$dst",
Evan Cheng09c54572006-06-29 00:36:51 +00002517 [(store (rotl (loadi16 addr:$dst), (i8 1)), addr:$dst)]>,
2518 OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00002519 def ROL32m1 : I<0xD1, MRM0m, (outs), (ins i32mem:$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002520 "rol{l}\t$dst",
Evan Cheng09c54572006-06-29 00:36:51 +00002521 [(store (rotl (loadi32 addr:$dst), (i8 1)), addr:$dst)]>;
Chris Lattner40ff6332005-01-19 07:50:03 +00002522}
2523
Evan Cheng071a2792007-09-11 19:55:27 +00002524let Uses = [CL] in {
Evan Cheng64d80e32007-07-19 01:14:50 +00002525def ROR8rCL : I<0xD2, MRM1r, (outs GR8 :$dst), (ins GR8 :$src),
Eli Friedmanaace4b12009-06-19 04:48:38 +00002526 "ror{b}\t{%cl, $dst|$dst, CL}",
Evan Cheng071a2792007-09-11 19:55:27 +00002527 [(set GR8:$dst, (rotr GR8:$src, CL))]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00002528def ROR16rCL : I<0xD3, MRM1r, (outs GR16:$dst), (ins GR16:$src),
Eli Friedmanaace4b12009-06-19 04:48:38 +00002529 "ror{w}\t{%cl, $dst|$dst, CL}",
Evan Cheng071a2792007-09-11 19:55:27 +00002530 [(set GR16:$dst, (rotr GR16:$src, CL))]>, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00002531def ROR32rCL : I<0xD3, MRM1r, (outs GR32:$dst), (ins GR32:$src),
Eli Friedmanaace4b12009-06-19 04:48:38 +00002532 "ror{l}\t{%cl, $dst|$dst, CL}",
Evan Cheng071a2792007-09-11 19:55:27 +00002533 [(set GR32:$dst, (rotr GR32:$src, CL))]>;
2534}
Chris Lattner40ff6332005-01-19 07:50:03 +00002535
Evan Cheng64d80e32007-07-19 01:14:50 +00002536def ROR8ri : Ii8<0xC0, MRM1r, (outs GR8 :$dst), (ins GR8 :$src1, i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002537 "ror{b}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00002538 [(set GR8:$dst, (rotr GR8:$src1, (i8 imm:$src2)))]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00002539def ROR16ri : Ii8<0xC1, MRM1r, (outs GR16:$dst), (ins GR16:$src1, i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002540 "ror{w}\t{$src2, $dst|$dst, $src2}",
Sean Callanan108934c2009-12-18 00:01:26 +00002541 [(set GR16:$dst, (rotr GR16:$src1, (i8 imm:$src2)))]>,
2542 OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00002543def ROR32ri : Ii8<0xC1, MRM1r, (outs GR32:$dst), (ins GR32:$src1, i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002544 "ror{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00002545 [(set GR32:$dst, (rotr GR32:$src1, (i8 imm:$src2)))]>;
Evan Cheng09c54572006-06-29 00:36:51 +00002546
2547// Rotate by 1
Evan Cheng64d80e32007-07-19 01:14:50 +00002548def ROR8r1 : I<0xD0, MRM1r, (outs GR8 :$dst), (ins GR8 :$src1),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002549 "ror{b}\t$dst",
Evan Cheng09c54572006-06-29 00:36:51 +00002550 [(set GR8:$dst, (rotr GR8:$src1, (i8 1)))]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00002551def ROR16r1 : I<0xD1, MRM1r, (outs GR16:$dst), (ins GR16:$src1),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002552 "ror{w}\t$dst",
Evan Cheng09c54572006-06-29 00:36:51 +00002553 [(set GR16:$dst, (rotr GR16:$src1, (i8 1)))]>, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00002554def ROR32r1 : I<0xD1, MRM1r, (outs GR32:$dst), (ins GR32:$src1),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002555 "ror{l}\t$dst",
Evan Cheng09c54572006-06-29 00:36:51 +00002556 [(set GR32:$dst, (rotr GR32:$src1, (i8 1)))]>;
2557
Chris Lattner40ff6332005-01-19 07:50:03 +00002558let isTwoAddress = 0 in {
Evan Cheng071a2792007-09-11 19:55:27 +00002559 let Uses = [CL] in {
Evan Cheng64d80e32007-07-19 01:14:50 +00002560 def ROR8mCL : I<0xD2, MRM1m, (outs), (ins i8mem :$dst),
Eli Friedmanaace4b12009-06-19 04:48:38 +00002561 "ror{b}\t{%cl, $dst|$dst, CL}",
Evan Cheng071a2792007-09-11 19:55:27 +00002562 [(store (rotr (loadi8 addr:$dst), CL), addr:$dst)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00002563 def ROR16mCL : I<0xD3, MRM1m, (outs), (ins i16mem:$dst),
Eli Friedmanaace4b12009-06-19 04:48:38 +00002564 "ror{w}\t{%cl, $dst|$dst, CL}",
Evan Cheng071a2792007-09-11 19:55:27 +00002565 [(store (rotr (loadi16 addr:$dst), CL), addr:$dst)]>, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00002566 def ROR32mCL : I<0xD3, MRM1m, (outs), (ins i32mem:$dst),
Eli Friedmanaace4b12009-06-19 04:48:38 +00002567 "ror{l}\t{%cl, $dst|$dst, CL}",
Evan Cheng071a2792007-09-11 19:55:27 +00002568 [(store (rotr (loadi32 addr:$dst), CL), addr:$dst)]>;
2569 }
Evan Cheng64d80e32007-07-19 01:14:50 +00002570 def ROR8mi : Ii8<0xC0, MRM1m, (outs), (ins i8mem :$dst, i8imm:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002571 "ror{b}\t{$src, $dst|$dst, $src}",
Evan Chengeb422a72006-01-11 23:20:05 +00002572 [(store (rotr (loadi8 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00002573 def ROR16mi : Ii8<0xC1, MRM1m, (outs), (ins i16mem:$dst, i8imm:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002574 "ror{w}\t{$src, $dst|$dst, $src}",
Evan Chengeb422a72006-01-11 23:20:05 +00002575 [(store (rotr (loadi16 addr:$dst), (i8 imm:$src)), addr:$dst)]>,
2576 OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00002577 def ROR32mi : Ii8<0xC1, MRM1m, (outs), (ins i32mem:$dst, i8imm:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002578 "ror{l}\t{$src, $dst|$dst, $src}",
Evan Chengeb422a72006-01-11 23:20:05 +00002579 [(store (rotr (loadi32 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
Evan Cheng09c54572006-06-29 00:36:51 +00002580
2581 // Rotate by 1
Evan Cheng64d80e32007-07-19 01:14:50 +00002582 def ROR8m1 : I<0xD0, MRM1m, (outs), (ins i8mem :$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002583 "ror{b}\t$dst",
Evan Cheng09c54572006-06-29 00:36:51 +00002584 [(store (rotr (loadi8 addr:$dst), (i8 1)), addr:$dst)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00002585 def ROR16m1 : I<0xD1, MRM1m, (outs), (ins i16mem:$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002586 "ror{w}\t$dst",
Evan Cheng09c54572006-06-29 00:36:51 +00002587 [(store (rotr (loadi16 addr:$dst), (i8 1)), addr:$dst)]>,
2588 OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00002589 def ROR32m1 : I<0xD1, MRM1m, (outs), (ins i32mem:$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002590 "ror{l}\t$dst",
Evan Cheng09c54572006-06-29 00:36:51 +00002591 [(store (rotr (loadi32 addr:$dst), (i8 1)), addr:$dst)]>;
Chris Lattner40ff6332005-01-19 07:50:03 +00002592}
2593
2594
2595
2596// Double shift instructions (generalizations of rotate)
Evan Cheng071a2792007-09-11 19:55:27 +00002597let Uses = [CL] in {
Sean Callanan108934c2009-12-18 00:01:26 +00002598def SHLD32rrCL : I<0xA5, MRMDestReg, (outs GR32:$dst),
2599 (ins GR32:$src1, GR32:$src2),
Eli Friedmanaace4b12009-06-19 04:48:38 +00002600 "shld{l}\t{%cl, $src2, $dst|$dst, $src2, CL}",
Evan Cheng071a2792007-09-11 19:55:27 +00002601 [(set GR32:$dst, (X86shld GR32:$src1, GR32:$src2, CL))]>, TB;
Sean Callanan108934c2009-12-18 00:01:26 +00002602def SHRD32rrCL : I<0xAD, MRMDestReg, (outs GR32:$dst),
2603 (ins GR32:$src1, GR32:$src2),
Eli Friedmanaace4b12009-06-19 04:48:38 +00002604 "shrd{l}\t{%cl, $src2, $dst|$dst, $src2, CL}",
Evan Cheng071a2792007-09-11 19:55:27 +00002605 [(set GR32:$dst, (X86shrd GR32:$src1, GR32:$src2, CL))]>, TB;
Sean Callanan108934c2009-12-18 00:01:26 +00002606def SHLD16rrCL : I<0xA5, MRMDestReg, (outs GR16:$dst),
2607 (ins GR16:$src1, GR16:$src2),
Eli Friedmanaace4b12009-06-19 04:48:38 +00002608 "shld{w}\t{%cl, $src2, $dst|$dst, $src2, CL}",
Evan Cheng069287d2006-05-16 07:21:53 +00002609 [(set GR16:$dst, (X86shld GR16:$src1, GR16:$src2, CL))]>,
Evan Cheng071a2792007-09-11 19:55:27 +00002610 TB, OpSize;
Sean Callanan108934c2009-12-18 00:01:26 +00002611def SHRD16rrCL : I<0xAD, MRMDestReg, (outs GR16:$dst),
2612 (ins GR16:$src1, GR16:$src2),
Eli Friedmanaace4b12009-06-19 04:48:38 +00002613 "shrd{w}\t{%cl, $src2, $dst|$dst, $src2, CL}",
Evan Cheng069287d2006-05-16 07:21:53 +00002614 [(set GR16:$dst, (X86shrd GR16:$src1, GR16:$src2, CL))]>,
Evan Cheng071a2792007-09-11 19:55:27 +00002615 TB, OpSize;
2616}
Chris Lattner41e431b2005-01-19 07:11:01 +00002617
2618let isCommutable = 1 in { // These instructions commute to each other.
Chris Lattner3a173df2004-10-03 20:35:00 +00002619def SHLD32rri8 : Ii8<0xA4, MRMDestReg,
Sean Callanan108934c2009-12-18 00:01:26 +00002620 (outs GR32:$dst),
2621 (ins GR32:$src1, GR32:$src2, i8imm:$src3),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002622 "shld{l}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Evan Cheng069287d2006-05-16 07:21:53 +00002623 [(set GR32:$dst, (X86shld GR32:$src1, GR32:$src2,
Evan Chenge3413162006-01-09 18:33:28 +00002624 (i8 imm:$src3)))]>,
2625 TB;
Chris Lattner3a173df2004-10-03 20:35:00 +00002626def SHRD32rri8 : Ii8<0xAC, MRMDestReg,
Sean Callanan108934c2009-12-18 00:01:26 +00002627 (outs GR32:$dst),
2628 (ins GR32:$src1, GR32:$src2, i8imm:$src3),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002629 "shrd{l}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Evan Cheng069287d2006-05-16 07:21:53 +00002630 [(set GR32:$dst, (X86shrd GR32:$src1, GR32:$src2,
Evan Chenge3413162006-01-09 18:33:28 +00002631 (i8 imm:$src3)))]>,
2632 TB;
Chris Lattner0df53d22005-01-19 07:31:24 +00002633def SHLD16rri8 : Ii8<0xA4, MRMDestReg,
Sean Callanan108934c2009-12-18 00:01:26 +00002634 (outs GR16:$dst),
2635 (ins GR16:$src1, GR16:$src2, i8imm:$src3),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002636 "shld{w}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Evan Cheng069287d2006-05-16 07:21:53 +00002637 [(set GR16:$dst, (X86shld GR16:$src1, GR16:$src2,
Evan Chenge3413162006-01-09 18:33:28 +00002638 (i8 imm:$src3)))]>,
Chris Lattner0df53d22005-01-19 07:31:24 +00002639 TB, OpSize;
2640def SHRD16rri8 : Ii8<0xAC, MRMDestReg,
Sean Callanan108934c2009-12-18 00:01:26 +00002641 (outs GR16:$dst),
2642 (ins GR16:$src1, GR16:$src2, i8imm:$src3),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002643 "shrd{w}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Evan Cheng069287d2006-05-16 07:21:53 +00002644 [(set GR16:$dst, (X86shrd GR16:$src1, GR16:$src2,
Evan Chenge3413162006-01-09 18:33:28 +00002645 (i8 imm:$src3)))]>,
Chris Lattner0df53d22005-01-19 07:31:24 +00002646 TB, OpSize;
Chris Lattner41e431b2005-01-19 07:11:01 +00002647}
Chris Lattner0e967d42004-08-01 08:13:11 +00002648
Chris Lattner57a02302004-08-11 04:31:00 +00002649let isTwoAddress = 0 in {
Evan Cheng071a2792007-09-11 19:55:27 +00002650 let Uses = [CL] in {
Evan Cheng64d80e32007-07-19 01:14:50 +00002651 def SHLD32mrCL : I<0xA5, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
Eli Friedmanaace4b12009-06-19 04:48:38 +00002652 "shld{l}\t{%cl, $src2, $dst|$dst, $src2, CL}",
Evan Cheng069287d2006-05-16 07:21:53 +00002653 [(store (X86shld (loadi32 addr:$dst), GR32:$src2, CL),
Evan Cheng071a2792007-09-11 19:55:27 +00002654 addr:$dst)]>, TB;
Evan Cheng64d80e32007-07-19 01:14:50 +00002655 def SHRD32mrCL : I<0xAD, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
Eli Friedmanaace4b12009-06-19 04:48:38 +00002656 "shrd{l}\t{%cl, $src2, $dst|$dst, $src2, CL}",
Evan Cheng069287d2006-05-16 07:21:53 +00002657 [(store (X86shrd (loadi32 addr:$dst), GR32:$src2, CL),
Evan Cheng071a2792007-09-11 19:55:27 +00002658 addr:$dst)]>, TB;
2659 }
Chris Lattner3a173df2004-10-03 20:35:00 +00002660 def SHLD32mri8 : Ii8<0xA4, MRMDestMem,
Evan Cheng64d80e32007-07-19 01:14:50 +00002661 (outs), (ins i32mem:$dst, GR32:$src2, i8imm:$src3),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002662 "shld{l}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Evan Cheng069287d2006-05-16 07:21:53 +00002663 [(store (X86shld (loadi32 addr:$dst), GR32:$src2,
Evan Chenge3413162006-01-09 18:33:28 +00002664 (i8 imm:$src3)), addr:$dst)]>,
Chris Lattnerf124d5e2005-11-18 01:04:42 +00002665 TB;
Chris Lattner3a173df2004-10-03 20:35:00 +00002666 def SHRD32mri8 : Ii8<0xAC, MRMDestMem,
Evan Cheng64d80e32007-07-19 01:14:50 +00002667 (outs), (ins i32mem:$dst, GR32:$src2, i8imm:$src3),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002668 "shrd{l}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Evan Cheng069287d2006-05-16 07:21:53 +00002669 [(store (X86shrd (loadi32 addr:$dst), GR32:$src2,
Evan Chenge3413162006-01-09 18:33:28 +00002670 (i8 imm:$src3)), addr:$dst)]>,
Chris Lattnerf124d5e2005-11-18 01:04:42 +00002671 TB;
Chris Lattner0df53d22005-01-19 07:31:24 +00002672
Evan Cheng071a2792007-09-11 19:55:27 +00002673 let Uses = [CL] in {
Evan Cheng64d80e32007-07-19 01:14:50 +00002674 def SHLD16mrCL : I<0xA5, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
Eli Friedmanaace4b12009-06-19 04:48:38 +00002675 "shld{w}\t{%cl, $src2, $dst|$dst, $src2, CL}",
Evan Cheng069287d2006-05-16 07:21:53 +00002676 [(store (X86shld (loadi16 addr:$dst), GR16:$src2, CL),
Evan Cheng071a2792007-09-11 19:55:27 +00002677 addr:$dst)]>, TB, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00002678 def SHRD16mrCL : I<0xAD, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
Eli Friedmanaace4b12009-06-19 04:48:38 +00002679 "shrd{w}\t{%cl, $src2, $dst|$dst, $src2, CL}",
Evan Cheng069287d2006-05-16 07:21:53 +00002680 [(store (X86shrd (loadi16 addr:$dst), GR16:$src2, CL),
Evan Cheng071a2792007-09-11 19:55:27 +00002681 addr:$dst)]>, TB, OpSize;
2682 }
Chris Lattner0df53d22005-01-19 07:31:24 +00002683 def SHLD16mri8 : Ii8<0xA4, MRMDestMem,
Evan Cheng64d80e32007-07-19 01:14:50 +00002684 (outs), (ins i16mem:$dst, GR16:$src2, i8imm:$src3),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002685 "shld{w}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Evan Cheng069287d2006-05-16 07:21:53 +00002686 [(store (X86shld (loadi16 addr:$dst), GR16:$src2,
Evan Chenge3413162006-01-09 18:33:28 +00002687 (i8 imm:$src3)), addr:$dst)]>,
Chris Lattner0df53d22005-01-19 07:31:24 +00002688 TB, OpSize;
2689 def SHRD16mri8 : Ii8<0xAC, MRMDestMem,
Evan Cheng64d80e32007-07-19 01:14:50 +00002690 (outs), (ins i16mem:$dst, GR16:$src2, i8imm:$src3),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002691 "shrd{w}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Evan Cheng069287d2006-05-16 07:21:53 +00002692 [(store (X86shrd (loadi16 addr:$dst), GR16:$src2,
Evan Chenge3413162006-01-09 18:33:28 +00002693 (i8 imm:$src3)), addr:$dst)]>,
Chris Lattner0df53d22005-01-19 07:31:24 +00002694 TB, OpSize;
Chris Lattner57a02302004-08-11 04:31:00 +00002695}
Evan Cheng24f2ea32007-09-14 21:48:26 +00002696} // Defs = [EFLAGS]
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00002697
2698
Chris Lattnercc65bee2005-01-02 02:35:46 +00002699// Arithmetic.
Evan Cheng24f2ea32007-09-14 21:48:26 +00002700let Defs = [EFLAGS] in {
Chris Lattnercc65bee2005-01-02 02:35:46 +00002701let isCommutable = 1 in { // X = ADD Y, Z --> X = ADD Z, Y
Bill Wendlingab55ebd2008-12-12 00:56:36 +00002702// Register-Register Addition
2703def ADD8rr : I<0x00, MRMDestReg, (outs GR8 :$dst),
2704 (ins GR8 :$src1, GR8 :$src2),
2705 "add{b}\t{$src2, $dst|$dst, $src2}",
Chris Lattnerec856802010-03-27 00:45:04 +00002706 [(set GR8:$dst, EFLAGS, (X86add_flag GR8:$src1, GR8:$src2))]>;
Bill Wendlingab55ebd2008-12-12 00:56:36 +00002707
Chris Lattnercc65bee2005-01-02 02:35:46 +00002708let isConvertibleToThreeAddress = 1 in { // Can transform into LEA.
Bill Wendlingab55ebd2008-12-12 00:56:36 +00002709// Register-Register Addition
Evan Cheng071a2792007-09-11 19:55:27 +00002710def ADD16rr : I<0x01, MRMDestReg, (outs GR16:$dst),
2711 (ins GR16:$src1, GR16:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002712 "add{w}\t{$src2, $dst|$dst, $src2}",
Chris Lattnerec856802010-03-27 00:45:04 +00002713 [(set GR16:$dst, EFLAGS, (X86add_flag GR16:$src1,
2714 GR16:$src2))]>, OpSize;
Evan Cheng071a2792007-09-11 19:55:27 +00002715def ADD32rr : I<0x01, MRMDestReg, (outs GR32:$dst),
2716 (ins GR32:$src1, GR32:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002717 "add{l}\t{$src2, $dst|$dst, $src2}",
Chris Lattnerec856802010-03-27 00:45:04 +00002718 [(set GR32:$dst, EFLAGS, (X86add_flag GR32:$src1,
2719 GR32:$src2))]>;
Chris Lattnercc65bee2005-01-02 02:35:46 +00002720} // end isConvertibleToThreeAddress
2721} // end isCommutable
Bill Wendlingab55ebd2008-12-12 00:56:36 +00002722
Daniel Dunbarf291be32010-03-09 22:50:46 +00002723// These are alternate spellings for use by the disassembler, we mark them as
2724// code gen only to ensure they aren't matched by the assembler.
2725let isCodeGenOnly = 1 in {
2726 def ADD8rr_alt: I<0x02, MRMSrcReg, (outs GR8:$dst), (ins GR8:$src1, GR8:$src2),
2727 "add{b}\t{$src2, $dst|$dst, $src2}", []>;
2728 def ADD16rr_alt: I<0x03, MRMSrcReg,(outs GR16:$dst),(ins GR16:$src1, GR16:$src2),
2729 "add{w}\t{$src2, $dst|$dst, $src2}", []>, OpSize;
Evan Cheng18ac4102010-04-05 22:21:09 +00002730 def ADD32rr_alt: I<0x03, MRMSrcReg,(outs GR32:$dst),(ins GR32:$src1, GR32:$src2),
Daniel Dunbarf291be32010-03-09 22:50:46 +00002731 "add{l}\t{$src2, $dst|$dst, $src2}", []>;
2732}
2733
Bill Wendlingab55ebd2008-12-12 00:56:36 +00002734// Register-Memory Addition
Evan Cheng071a2792007-09-11 19:55:27 +00002735def ADD8rm : I<0x02, MRMSrcMem, (outs GR8 :$dst),
2736 (ins GR8 :$src1, i8mem :$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002737 "add{b}\t{$src2, $dst|$dst, $src2}",
Chris Lattnerec856802010-03-27 00:45:04 +00002738 [(set GR8:$dst, EFLAGS, (X86add_flag GR8:$src1,
2739 (load addr:$src2)))]>;
Evan Cheng071a2792007-09-11 19:55:27 +00002740def ADD16rm : I<0x03, MRMSrcMem, (outs GR16:$dst),
2741 (ins GR16:$src1, i16mem:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002742 "add{w}\t{$src2, $dst|$dst, $src2}",
Chris Lattnerec856802010-03-27 00:45:04 +00002743 [(set GR16:$dst, EFLAGS, (X86add_flag GR16:$src1,
2744 (load addr:$src2)))]>, OpSize;
Evan Cheng071a2792007-09-11 19:55:27 +00002745def ADD32rm : I<0x03, MRMSrcMem, (outs GR32:$dst),
2746 (ins GR32:$src1, i32mem:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002747 "add{l}\t{$src2, $dst|$dst, $src2}",
Chris Lattnerec856802010-03-27 00:45:04 +00002748 [(set GR32:$dst, EFLAGS, (X86add_flag GR32:$src1,
2749 (load addr:$src2)))]>;
Sean Callanan37be5902009-09-15 20:53:57 +00002750
Bill Wendlingab55ebd2008-12-12 00:56:36 +00002751// Register-Integer Addition
2752def ADD8ri : Ii8<0x80, MRM0r, (outs GR8:$dst), (ins GR8:$src1, i8imm:$src2),
2753 "add{b}\t{$src2, $dst|$dst, $src2}",
Chris Lattnerec856802010-03-27 00:45:04 +00002754 [(set GR8:$dst, EFLAGS,
2755 (X86add_flag GR8:$src1, imm:$src2))]>;
Bill Wendlingab55ebd2008-12-12 00:56:36 +00002756
Chris Lattnercc65bee2005-01-02 02:35:46 +00002757let isConvertibleToThreeAddress = 1 in { // Can transform into LEA.
Bill Wendlingab55ebd2008-12-12 00:56:36 +00002758// Register-Integer Addition
Evan Cheng071a2792007-09-11 19:55:27 +00002759def ADD16ri : Ii16<0x81, MRM0r, (outs GR16:$dst),
2760 (ins GR16:$src1, i16imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002761 "add{w}\t{$src2, $dst|$dst, $src2}",
Chris Lattnerec856802010-03-27 00:45:04 +00002762 [(set GR16:$dst, EFLAGS,
2763 (X86add_flag GR16:$src1, imm:$src2))]>, OpSize;
Evan Cheng071a2792007-09-11 19:55:27 +00002764def ADD32ri : Ii32<0x81, MRM0r, (outs GR32:$dst),
2765 (ins GR32:$src1, i32imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002766 "add{l}\t{$src2, $dst|$dst, $src2}",
Chris Lattnerec856802010-03-27 00:45:04 +00002767 [(set GR32:$dst, EFLAGS,
2768 (X86add_flag GR32:$src1, imm:$src2))]>;
Evan Cheng071a2792007-09-11 19:55:27 +00002769def ADD16ri8 : Ii8<0x83, MRM0r, (outs GR16:$dst),
2770 (ins GR16:$src1, i16i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002771 "add{w}\t{$src2, $dst|$dst, $src2}",
Chris Lattnerec856802010-03-27 00:45:04 +00002772 [(set GR16:$dst, EFLAGS,
2773 (X86add_flag GR16:$src1, i16immSExt8:$src2))]>, OpSize;
Evan Cheng071a2792007-09-11 19:55:27 +00002774def ADD32ri8 : Ii8<0x83, MRM0r, (outs GR32:$dst),
2775 (ins GR32:$src1, i32i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002776 "add{l}\t{$src2, $dst|$dst, $src2}",
Chris Lattnerec856802010-03-27 00:45:04 +00002777 [(set GR32:$dst, EFLAGS,
2778 (X86add_flag GR32:$src1, i32immSExt8:$src2))]>;
Evan Cheng09e3c802006-05-19 18:40:54 +00002779}
Chris Lattner57a02302004-08-11 04:31:00 +00002780
2781let isTwoAddress = 0 in {
Bill Wendlingab55ebd2008-12-12 00:56:36 +00002782 // Memory-Register Addition
Bill Wendlingd350e022008-12-12 21:15:41 +00002783 def ADD8mr : I<0x00, MRMDestMem, (outs), (ins i8mem:$dst, GR8:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002784 "add{b}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingd350e022008-12-12 21:15:41 +00002785 [(store (add (load addr:$dst), GR8:$src2), addr:$dst),
2786 (implicit EFLAGS)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00002787 def ADD16mr : I<0x01, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002788 "add{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingd350e022008-12-12 21:15:41 +00002789 [(store (add (load addr:$dst), GR16:$src2), addr:$dst),
2790 (implicit EFLAGS)]>, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00002791 def ADD32mr : I<0x01, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002792 "add{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingd350e022008-12-12 21:15:41 +00002793 [(store (add (load addr:$dst), GR32:$src2), addr:$dst),
2794 (implicit EFLAGS)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00002795 def ADD8mi : Ii8<0x80, MRM0m, (outs), (ins i8mem :$dst, i8imm :$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002796 "add{b}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingd350e022008-12-12 21:15:41 +00002797 [(store (add (loadi8 addr:$dst), imm:$src2), addr:$dst),
2798 (implicit EFLAGS)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00002799 def ADD16mi : Ii16<0x81, MRM0m, (outs), (ins i16mem:$dst, i16imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002800 "add{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingd350e022008-12-12 21:15:41 +00002801 [(store (add (loadi16 addr:$dst), imm:$src2), addr:$dst),
2802 (implicit EFLAGS)]>, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00002803 def ADD32mi : Ii32<0x81, MRM0m, (outs), (ins i32mem:$dst, i32imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002804 "add{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingd350e022008-12-12 21:15:41 +00002805 [(store (add (loadi32 addr:$dst), imm:$src2), addr:$dst),
2806 (implicit EFLAGS)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00002807 def ADD16mi8 : Ii8<0x83, MRM0m, (outs), (ins i16mem:$dst, i16i8imm :$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002808 "add{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingd350e022008-12-12 21:15:41 +00002809 [(store (add (load addr:$dst), i16immSExt8:$src2),
2810 addr:$dst),
2811 (implicit EFLAGS)]>, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00002812 def ADD32mi8 : Ii8<0x83, MRM0m, (outs), (ins i32mem:$dst, i32i8imm :$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002813 "add{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingab55ebd2008-12-12 00:56:36 +00002814 [(store (add (load addr:$dst), i32immSExt8:$src2),
Bill Wendlingd350e022008-12-12 21:15:41 +00002815 addr:$dst),
2816 (implicit EFLAGS)]>;
Sean Callananb08ae6b2009-08-11 21:26:06 +00002817
2818 // addition to rAX
2819 def ADD8i8 : Ii8<0x04, RawFrm, (outs), (ins i8imm:$src),
Sean Callanana09caa52009-09-02 00:55:49 +00002820 "add{b}\t{$src, %al|%al, $src}", []>;
Sean Callananb08ae6b2009-08-11 21:26:06 +00002821 def ADD16i16 : Ii16<0x05, RawFrm, (outs), (ins i16imm:$src),
Sean Callanana09caa52009-09-02 00:55:49 +00002822 "add{w}\t{$src, %ax|%ax, $src}", []>, OpSize;
Sean Callananb08ae6b2009-08-11 21:26:06 +00002823 def ADD32i32 : Ii32<0x05, RawFrm, (outs), (ins i32imm:$src),
Sean Callanana09caa52009-09-02 00:55:49 +00002824 "add{l}\t{$src, %eax|%eax, $src}", []>;
Chris Lattner57a02302004-08-11 04:31:00 +00002825}
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00002826
Evan Cheng3154cb62007-10-05 17:59:57 +00002827let Uses = [EFLAGS] in {
Chris Lattner10197ff2005-01-03 01:27:59 +00002828let isCommutable = 1 in { // X = ADC Y, Z --> X = ADC Z, Y
Dale Johannesen874ae252009-06-02 03:12:52 +00002829def ADC8rr : I<0x10, MRMDestReg, (outs GR8:$dst), (ins GR8:$src1, GR8:$src2),
Dale Johannesenca11dae2009-05-18 17:44:15 +00002830 "adc{b}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen874ae252009-06-02 03:12:52 +00002831 [(set GR8:$dst, (adde GR8:$src1, GR8:$src2))]>;
Dale Johannesenca11dae2009-05-18 17:44:15 +00002832def ADC16rr : I<0x11, MRMDestReg, (outs GR16:$dst),
2833 (ins GR16:$src1, GR16:$src2),
2834 "adc{w}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen874ae252009-06-02 03:12:52 +00002835 [(set GR16:$dst, (adde GR16:$src1, GR16:$src2))]>, OpSize;
Dale Johannesenca11dae2009-05-18 17:44:15 +00002836def ADC32rr : I<0x11, MRMDestReg, (outs GR32:$dst),
2837 (ins GR32:$src1, GR32:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002838 "adc{l}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen874ae252009-06-02 03:12:52 +00002839 [(set GR32:$dst, (adde GR32:$src1, GR32:$src2))]>;
Chris Lattner10197ff2005-01-03 01:27:59 +00002840}
Sean Callanan108934c2009-12-18 00:01:26 +00002841
2842def ADC8rr_REV : I<0x12, MRMSrcReg, (outs GR8:$dst), (ins GR8:$src1, GR8:$src2),
2843 "adc{b}\t{$src2, $dst|$dst, $src2}", []>;
2844def ADC16rr_REV : I<0x13, MRMSrcReg, (outs GR16:$dst),
2845 (ins GR16:$src1, GR16:$src2),
2846 "adc{w}\t{$src2, $dst|$dst, $src2}", []>, OpSize;
2847def ADC32rr_REV : I<0x13, MRMSrcReg, (outs GR32:$dst),
2848 (ins GR32:$src1, GR32:$src2),
2849 "adc{l}\t{$src2, $dst|$dst, $src2}", []>;
2850
Dale Johannesenca11dae2009-05-18 17:44:15 +00002851def ADC8rm : I<0x12, MRMSrcMem , (outs GR8:$dst),
2852 (ins GR8:$src1, i8mem:$src2),
2853 "adc{b}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen874ae252009-06-02 03:12:52 +00002854 [(set GR8:$dst, (adde GR8:$src1, (load addr:$src2)))]>;
Dale Johannesenca11dae2009-05-18 17:44:15 +00002855def ADC16rm : I<0x13, MRMSrcMem , (outs GR16:$dst),
2856 (ins GR16:$src1, i16mem:$src2),
2857 "adc{w}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen874ae252009-06-02 03:12:52 +00002858 [(set GR16:$dst, (adde GR16:$src1, (load addr:$src2)))]>,
Dale Johannesen94c9cd12009-05-18 21:41:59 +00002859 OpSize;
Dale Johannesenca11dae2009-05-18 17:44:15 +00002860def ADC32rm : I<0x13, MRMSrcMem , (outs GR32:$dst),
2861 (ins GR32:$src1, i32mem:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002862 "adc{l}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen874ae252009-06-02 03:12:52 +00002863 [(set GR32:$dst, (adde GR32:$src1, (load addr:$src2)))]>;
2864def ADC8ri : Ii8<0x80, MRM2r, (outs GR8:$dst), (ins GR8:$src1, i8imm:$src2),
Dale Johannesenca11dae2009-05-18 17:44:15 +00002865 "adc{b}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen874ae252009-06-02 03:12:52 +00002866 [(set GR8:$dst, (adde GR8:$src1, imm:$src2))]>;
Dale Johannesenca11dae2009-05-18 17:44:15 +00002867def ADC16ri : Ii16<0x81, MRM2r, (outs GR16:$dst),
2868 (ins GR16:$src1, i16imm:$src2),
2869 "adc{w}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen874ae252009-06-02 03:12:52 +00002870 [(set GR16:$dst, (adde GR16:$src1, imm:$src2))]>, OpSize;
Dale Johannesenca11dae2009-05-18 17:44:15 +00002871def ADC16ri8 : Ii8<0x83, MRM2r, (outs GR16:$dst),
2872 (ins GR16:$src1, i16i8imm:$src2),
2873 "adc{w}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen874ae252009-06-02 03:12:52 +00002874 [(set GR16:$dst, (adde GR16:$src1, i16immSExt8:$src2))]>,
2875 OpSize;
Dale Johannesenca11dae2009-05-18 17:44:15 +00002876def ADC32ri : Ii32<0x81, MRM2r, (outs GR32:$dst),
2877 (ins GR32:$src1, i32imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002878 "adc{l}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen874ae252009-06-02 03:12:52 +00002879 [(set GR32:$dst, (adde GR32:$src1, imm:$src2))]>;
Dale Johannesenca11dae2009-05-18 17:44:15 +00002880def ADC32ri8 : Ii8<0x83, MRM2r, (outs GR32:$dst),
2881 (ins GR32:$src1, i32i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002882 "adc{l}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen874ae252009-06-02 03:12:52 +00002883 [(set GR32:$dst, (adde GR32:$src1, i32immSExt8:$src2))]>;
Chris Lattner57a02302004-08-11 04:31:00 +00002884
2885let isTwoAddress = 0 in {
Dale Johannesen874ae252009-06-02 03:12:52 +00002886 def ADC8mr : I<0x10, MRMDestMem, (outs), (ins i8mem:$dst, GR8:$src2),
Dale Johannesenca11dae2009-05-18 17:44:15 +00002887 "adc{b}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen874ae252009-06-02 03:12:52 +00002888 [(store (adde (load addr:$dst), GR8:$src2), addr:$dst)]>;
2889 def ADC16mr : I<0x11, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
Dale Johannesenca11dae2009-05-18 17:44:15 +00002890 "adc{w}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen874ae252009-06-02 03:12:52 +00002891 [(store (adde (load addr:$dst), GR16:$src2), addr:$dst)]>,
2892 OpSize;
2893 def ADC32mr : I<0x11, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002894 "adc{l}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen874ae252009-06-02 03:12:52 +00002895 [(store (adde (load addr:$dst), GR32:$src2), addr:$dst)]>;
2896 def ADC8mi : Ii8<0x80, MRM2m, (outs), (ins i8mem:$dst, i8imm:$src2),
Dale Johannesenca11dae2009-05-18 17:44:15 +00002897 "adc{b}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen874ae252009-06-02 03:12:52 +00002898 [(store (adde (loadi8 addr:$dst), imm:$src2), addr:$dst)]>;
2899 def ADC16mi : Ii16<0x81, MRM2m, (outs), (ins i16mem:$dst, i16imm:$src2),
Dale Johannesenca11dae2009-05-18 17:44:15 +00002900 "adc{w}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen874ae252009-06-02 03:12:52 +00002901 [(store (adde (loadi16 addr:$dst), imm:$src2), addr:$dst)]>,
2902 OpSize;
2903 def ADC16mi8 : Ii8<0x83, MRM2m, (outs), (ins i16mem:$dst, i16i8imm :$src2),
Dale Johannesenca11dae2009-05-18 17:44:15 +00002904 "adc{w}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen874ae252009-06-02 03:12:52 +00002905 [(store (adde (load addr:$dst), i16immSExt8:$src2), addr:$dst)]>,
2906 OpSize;
2907 def ADC32mi : Ii32<0x81, MRM2m, (outs), (ins i32mem:$dst, i32imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002908 "adc{l}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen874ae252009-06-02 03:12:52 +00002909 [(store (adde (loadi32 addr:$dst), imm:$src2), addr:$dst)]>;
2910 def ADC32mi8 : Ii8<0x83, MRM2m, (outs), (ins i32mem:$dst, i32i8imm :$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002911 "adc{l}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen874ae252009-06-02 03:12:52 +00002912 [(store (adde (load addr:$dst), i32immSExt8:$src2), addr:$dst)]>;
Sean Callanand00025a2009-09-11 19:01:56 +00002913
2914 def ADC8i8 : Ii8<0x14, RawFrm, (outs), (ins i8imm:$src),
2915 "adc{b}\t{$src, %al|%al, $src}", []>;
2916 def ADC16i16 : Ii16<0x15, RawFrm, (outs), (ins i16imm:$src),
2917 "adc{w}\t{$src, %ax|%ax, $src}", []>, OpSize;
2918 def ADC32i32 : Ii32<0x15, RawFrm, (outs), (ins i32imm:$src),
2919 "adc{l}\t{$src, %eax|%eax, $src}", []>;
Dale Johannesen874ae252009-06-02 03:12:52 +00002920}
Evan Cheng3154cb62007-10-05 17:59:57 +00002921} // Uses = [EFLAGS]
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00002922
Bill Wendlingab55ebd2008-12-12 00:56:36 +00002923// Register-Register Subtraction
2924def SUB8rr : I<0x28, MRMDestReg, (outs GR8:$dst), (ins GR8:$src1, GR8:$src2),
2925 "sub{b}\t{$src2, $dst|$dst, $src2}",
Chris Lattnerec856802010-03-27 00:45:04 +00002926 [(set GR8:$dst, EFLAGS,
2927 (X86sub_flag GR8:$src1, GR8:$src2))]>;
Bill Wendlingab55ebd2008-12-12 00:56:36 +00002928def SUB16rr : I<0x29, MRMDestReg, (outs GR16:$dst), (ins GR16:$src1,GR16:$src2),
2929 "sub{w}\t{$src2, $dst|$dst, $src2}",
Chris Lattnerec856802010-03-27 00:45:04 +00002930 [(set GR16:$dst, EFLAGS,
2931 (X86sub_flag GR16:$src1, GR16:$src2))]>, OpSize;
Bill Wendlingab55ebd2008-12-12 00:56:36 +00002932def SUB32rr : I<0x29, MRMDestReg, (outs GR32:$dst), (ins GR32:$src1,GR32:$src2),
2933 "sub{l}\t{$src2, $dst|$dst, $src2}",
Chris Lattnerec856802010-03-27 00:45:04 +00002934 [(set GR32:$dst, EFLAGS,
2935 (X86sub_flag GR32:$src1, GR32:$src2))]>;
Bill Wendlingab55ebd2008-12-12 00:56:36 +00002936
Sean Callanan108934c2009-12-18 00:01:26 +00002937def SUB8rr_REV : I<0x2A, MRMSrcReg, (outs GR8:$dst), (ins GR8:$src1, GR8:$src2),
2938 "sub{b}\t{$src2, $dst|$dst, $src2}", []>;
2939def SUB16rr_REV : I<0x2B, MRMSrcReg, (outs GR16:$dst),
2940 (ins GR16:$src1, GR16:$src2),
2941 "sub{w}\t{$src2, $dst|$dst, $src2}", []>, OpSize;
2942def SUB32rr_REV : I<0x2B, MRMSrcReg, (outs GR32:$dst),
2943 (ins GR32:$src1, GR32:$src2),
2944 "sub{l}\t{$src2, $dst|$dst, $src2}", []>;
2945
Bill Wendlingab55ebd2008-12-12 00:56:36 +00002946// Register-Memory Subtraction
2947def SUB8rm : I<0x2A, MRMSrcMem, (outs GR8 :$dst),
2948 (ins GR8 :$src1, i8mem :$src2),
2949 "sub{b}\t{$src2, $dst|$dst, $src2}",
Chris Lattnerec856802010-03-27 00:45:04 +00002950 [(set GR8:$dst, EFLAGS,
2951 (X86sub_flag GR8:$src1, (load addr:$src2)))]>;
Bill Wendlingab55ebd2008-12-12 00:56:36 +00002952def SUB16rm : I<0x2B, MRMSrcMem, (outs GR16:$dst),
2953 (ins GR16:$src1, i16mem:$src2),
2954 "sub{w}\t{$src2, $dst|$dst, $src2}",
Chris Lattnerec856802010-03-27 00:45:04 +00002955 [(set GR16:$dst, EFLAGS,
2956 (X86sub_flag GR16:$src1, (load addr:$src2)))]>, OpSize;
Bill Wendlingab55ebd2008-12-12 00:56:36 +00002957def SUB32rm : I<0x2B, MRMSrcMem, (outs GR32:$dst),
2958 (ins GR32:$src1, i32mem:$src2),
2959 "sub{l}\t{$src2, $dst|$dst, $src2}",
Chris Lattnerec856802010-03-27 00:45:04 +00002960 [(set GR32:$dst, EFLAGS,
2961 (X86sub_flag GR32:$src1, (load addr:$src2)))]>;
Bill Wendlingab55ebd2008-12-12 00:56:36 +00002962
2963// Register-Integer Subtraction
2964def SUB8ri : Ii8 <0x80, MRM5r, (outs GR8:$dst),
2965 (ins GR8:$src1, i8imm:$src2),
2966 "sub{b}\t{$src2, $dst|$dst, $src2}",
Chris Lattnerec856802010-03-27 00:45:04 +00002967 [(set GR8:$dst, EFLAGS,
2968 (X86sub_flag GR8:$src1, imm:$src2))]>;
Bill Wendlingab55ebd2008-12-12 00:56:36 +00002969def SUB16ri : Ii16<0x81, MRM5r, (outs GR16:$dst),
2970 (ins GR16:$src1, i16imm:$src2),
2971 "sub{w}\t{$src2, $dst|$dst, $src2}",
Chris Lattnerec856802010-03-27 00:45:04 +00002972 [(set GR16:$dst, EFLAGS,
2973 (X86sub_flag GR16:$src1, imm:$src2))]>, OpSize;
Bill Wendlingab55ebd2008-12-12 00:56:36 +00002974def SUB32ri : Ii32<0x81, MRM5r, (outs GR32:$dst),
2975 (ins GR32:$src1, i32imm:$src2),
2976 "sub{l}\t{$src2, $dst|$dst, $src2}",
Chris Lattnerec856802010-03-27 00:45:04 +00002977 [(set GR32:$dst, EFLAGS,
2978 (X86sub_flag GR32:$src1, imm:$src2))]>;
Bill Wendlingab55ebd2008-12-12 00:56:36 +00002979def SUB16ri8 : Ii8<0x83, MRM5r, (outs GR16:$dst),
2980 (ins GR16:$src1, i16i8imm:$src2),
2981 "sub{w}\t{$src2, $dst|$dst, $src2}",
Chris Lattnerec856802010-03-27 00:45:04 +00002982 [(set GR16:$dst, EFLAGS,
2983 (X86sub_flag GR16:$src1, i16immSExt8:$src2))]>, OpSize;
Bill Wendlingab55ebd2008-12-12 00:56:36 +00002984def SUB32ri8 : Ii8<0x83, MRM5r, (outs GR32:$dst),
2985 (ins GR32:$src1, i32i8imm:$src2),
2986 "sub{l}\t{$src2, $dst|$dst, $src2}",
Chris Lattnerec856802010-03-27 00:45:04 +00002987 [(set GR32:$dst, EFLAGS,
2988 (X86sub_flag GR32:$src1, i32immSExt8:$src2))]>;
Bill Wendlingab55ebd2008-12-12 00:56:36 +00002989
Chris Lattner57a02302004-08-11 04:31:00 +00002990let isTwoAddress = 0 in {
Bill Wendlingab55ebd2008-12-12 00:56:36 +00002991 // Memory-Register Subtraction
Evan Cheng64d80e32007-07-19 01:14:50 +00002992 def SUB8mr : I<0x28, MRMDestMem, (outs), (ins i8mem :$dst, GR8 :$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002993 "sub{b}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingd350e022008-12-12 21:15:41 +00002994 [(store (sub (load addr:$dst), GR8:$src2), addr:$dst),
2995 (implicit EFLAGS)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00002996 def SUB16mr : I<0x29, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002997 "sub{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingd350e022008-12-12 21:15:41 +00002998 [(store (sub (load addr:$dst), GR16:$src2), addr:$dst),
2999 (implicit EFLAGS)]>, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00003000 def SUB32mr : I<0x29, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003001 "sub{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingd350e022008-12-12 21:15:41 +00003002 [(store (sub (load addr:$dst), GR32:$src2), addr:$dst),
3003 (implicit EFLAGS)]>;
Bill Wendlingab55ebd2008-12-12 00:56:36 +00003004
3005 // Memory-Integer Subtraction
Evan Cheng64d80e32007-07-19 01:14:50 +00003006 def SUB8mi : Ii8<0x80, MRM5m, (outs), (ins i8mem :$dst, i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003007 "sub{b}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingd350e022008-12-12 21:15:41 +00003008 [(store (sub (loadi8 addr:$dst), imm:$src2), addr:$dst),
3009 (implicit EFLAGS)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00003010 def SUB16mi : Ii16<0x81, MRM5m, (outs), (ins i16mem:$dst, i16imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003011 "sub{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingd350e022008-12-12 21:15:41 +00003012 [(store (sub (loadi16 addr:$dst), imm:$src2),addr:$dst),
3013 (implicit EFLAGS)]>, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00003014 def SUB32mi : Ii32<0x81, MRM5m, (outs), (ins i32mem:$dst, i32imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003015 "sub{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingd350e022008-12-12 21:15:41 +00003016 [(store (sub (loadi32 addr:$dst), imm:$src2),addr:$dst),
3017 (implicit EFLAGS)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00003018 def SUB16mi8 : Ii8<0x83, MRM5m, (outs), (ins i16mem:$dst, i16i8imm :$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003019 "sub{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingab55ebd2008-12-12 00:56:36 +00003020 [(store (sub (load addr:$dst), i16immSExt8:$src2),
Bill Wendlingd350e022008-12-12 21:15:41 +00003021 addr:$dst),
3022 (implicit EFLAGS)]>, OpSize;
Bill Wendlingab55ebd2008-12-12 00:56:36 +00003023 def SUB32mi8 : Ii8<0x83, MRM5m, (outs), (ins i32mem:$dst, i32i8imm :$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003024 "sub{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingab55ebd2008-12-12 00:56:36 +00003025 [(store (sub (load addr:$dst), i32immSExt8:$src2),
Bill Wendlingd350e022008-12-12 21:15:41 +00003026 addr:$dst),
3027 (implicit EFLAGS)]>;
Sean Callanand00025a2009-09-11 19:01:56 +00003028
3029 def SUB8i8 : Ii8<0x2C, RawFrm, (outs), (ins i8imm:$src),
3030 "sub{b}\t{$src, %al|%al, $src}", []>;
3031 def SUB16i16 : Ii16<0x2D, RawFrm, (outs), (ins i16imm:$src),
3032 "sub{w}\t{$src, %ax|%ax, $src}", []>, OpSize;
3033 def SUB32i32 : Ii32<0x2D, RawFrm, (outs), (ins i32imm:$src),
3034 "sub{l}\t{$src, %eax|%eax, $src}", []>;
Chris Lattner57a02302004-08-11 04:31:00 +00003035}
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00003036
Evan Cheng3154cb62007-10-05 17:59:57 +00003037let Uses = [EFLAGS] in {
Dale Johannesenca11dae2009-05-18 17:44:15 +00003038def SBB8rr : I<0x18, MRMDestReg, (outs GR8:$dst),
3039 (ins GR8:$src1, GR8:$src2),
3040 "sbb{b}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen874ae252009-06-02 03:12:52 +00003041 [(set GR8:$dst, (sube GR8:$src1, GR8:$src2))]>;
Dale Johannesenca11dae2009-05-18 17:44:15 +00003042def SBB16rr : I<0x19, MRMDestReg, (outs GR16:$dst),
3043 (ins GR16:$src1, GR16:$src2),
3044 "sbb{w}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen874ae252009-06-02 03:12:52 +00003045 [(set GR16:$dst, (sube GR16:$src1, GR16:$src2))]>, OpSize;
Dale Johannesenca11dae2009-05-18 17:44:15 +00003046def SBB32rr : I<0x19, MRMDestReg, (outs GR32:$dst),
3047 (ins GR32:$src1, GR32:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003048 "sbb{l}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen874ae252009-06-02 03:12:52 +00003049 [(set GR32:$dst, (sube GR32:$src1, GR32:$src2))]>;
Chris Lattnerd93d3b02004-10-06 04:01:02 +00003050
Chris Lattner57a02302004-08-11 04:31:00 +00003051let isTwoAddress = 0 in {
Dale Johannesenca11dae2009-05-18 17:44:15 +00003052 def SBB8mr : I<0x18, MRMDestMem, (outs), (ins i8mem:$dst, GR8:$src2),
3053 "sbb{b}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen874ae252009-06-02 03:12:52 +00003054 [(store (sube (load addr:$dst), GR8:$src2), addr:$dst)]>;
Dale Johannesenca11dae2009-05-18 17:44:15 +00003055 def SBB16mr : I<0x19, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
3056 "sbb{w}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen874ae252009-06-02 03:12:52 +00003057 [(store (sube (load addr:$dst), GR16:$src2), addr:$dst)]>,
Dale Johannesen94c9cd12009-05-18 21:41:59 +00003058 OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00003059 def SBB32mr : I<0x19, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003060 "sbb{l}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen874ae252009-06-02 03:12:52 +00003061 [(store (sube (load addr:$dst), GR32:$src2), addr:$dst)]>;
Chris Lattner8f60e4d2010-02-05 22:56:11 +00003062 def SBB8mi : Ii8<0x80, MRM3m, (outs), (ins i8mem:$dst, i8imm:$src2),
3063 "sbb{b}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen874ae252009-06-02 03:12:52 +00003064 [(store (sube (loadi8 addr:$dst), imm:$src2), addr:$dst)]>;
Dale Johannesenca11dae2009-05-18 17:44:15 +00003065 def SBB16mi : Ii16<0x81, MRM3m, (outs), (ins i16mem:$dst, i16imm:$src2),
3066 "sbb{w}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen874ae252009-06-02 03:12:52 +00003067 [(store (sube (loadi16 addr:$dst), imm:$src2), addr:$dst)]>,
Dale Johannesen94c9cd12009-05-18 21:41:59 +00003068 OpSize;
Dale Johannesenca11dae2009-05-18 17:44:15 +00003069 def SBB16mi8 : Ii8<0x83, MRM3m, (outs), (ins i16mem:$dst, i16i8imm :$src2),
3070 "sbb{w}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen874ae252009-06-02 03:12:52 +00003071 [(store (sube (load addr:$dst), i16immSExt8:$src2), addr:$dst)]>,
Dale Johannesen94c9cd12009-05-18 21:41:59 +00003072 OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00003073 def SBB32mi : Ii32<0x81, MRM3m, (outs), (ins i32mem:$dst, i32imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003074 "sbb{l}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen874ae252009-06-02 03:12:52 +00003075 [(store (sube (loadi32 addr:$dst), imm:$src2), addr:$dst)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00003076 def SBB32mi8 : Ii8<0x83, MRM3m, (outs), (ins i32mem:$dst, i32i8imm :$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003077 "sbb{l}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen874ae252009-06-02 03:12:52 +00003078 [(store (sube (load addr:$dst), i32immSExt8:$src2), addr:$dst)]>;
Sean Callanand00025a2009-09-11 19:01:56 +00003079
3080 def SBB8i8 : Ii8<0x1C, RawFrm, (outs), (ins i8imm:$src),
3081 "sbb{b}\t{$src, %al|%al, $src}", []>;
3082 def SBB16i16 : Ii16<0x1D, RawFrm, (outs), (ins i16imm:$src),
3083 "sbb{w}\t{$src, %ax|%ax, $src}", []>, OpSize;
3084 def SBB32i32 : Ii32<0x1D, RawFrm, (outs), (ins i32imm:$src),
3085 "sbb{l}\t{$src, %eax|%eax, $src}", []>;
Chris Lattner57a02302004-08-11 04:31:00 +00003086}
Sean Callanan108934c2009-12-18 00:01:26 +00003087
3088def SBB8rr_REV : I<0x1A, MRMSrcReg, (outs GR8:$dst), (ins GR8:$src1, GR8:$src2),
3089 "sbb{b}\t{$src2, $dst|$dst, $src2}", []>;
3090def SBB16rr_REV : I<0x1B, MRMSrcReg, (outs GR16:$dst),
3091 (ins GR16:$src1, GR16:$src2),
3092 "sbb{w}\t{$src2, $dst|$dst, $src2}", []>, OpSize;
3093def SBB32rr_REV : I<0x1B, MRMSrcReg, (outs GR32:$dst),
3094 (ins GR32:$src1, GR32:$src2),
3095 "sbb{l}\t{$src2, $dst|$dst, $src2}", []>;
3096
Dale Johannesenca11dae2009-05-18 17:44:15 +00003097def SBB8rm : I<0x1A, MRMSrcMem, (outs GR8:$dst), (ins GR8:$src1, i8mem:$src2),
3098 "sbb{b}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen874ae252009-06-02 03:12:52 +00003099 [(set GR8:$dst, (sube GR8:$src1, (load addr:$src2)))]>;
Dale Johannesenca11dae2009-05-18 17:44:15 +00003100def SBB16rm : I<0x1B, MRMSrcMem, (outs GR16:$dst),
3101 (ins GR16:$src1, i16mem:$src2),
3102 "sbb{w}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen874ae252009-06-02 03:12:52 +00003103 [(set GR16:$dst, (sube GR16:$src1, (load addr:$src2)))]>,
Dale Johannesen94c9cd12009-05-18 21:41:59 +00003104 OpSize;
Dale Johannesenca11dae2009-05-18 17:44:15 +00003105def SBB32rm : I<0x1B, MRMSrcMem, (outs GR32:$dst),
3106 (ins GR32:$src1, i32mem:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003107 "sbb{l}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen874ae252009-06-02 03:12:52 +00003108 [(set GR32:$dst, (sube GR32:$src1, (load addr:$src2)))]>;
Dale Johannesenca11dae2009-05-18 17:44:15 +00003109def SBB8ri : Ii8<0x80, MRM3r, (outs GR8:$dst), (ins GR8:$src1, i8imm:$src2),
3110 "sbb{b}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen874ae252009-06-02 03:12:52 +00003111 [(set GR8:$dst, (sube GR8:$src1, imm:$src2))]>;
Dale Johannesenca11dae2009-05-18 17:44:15 +00003112def SBB16ri : Ii16<0x81, MRM3r, (outs GR16:$dst),
3113 (ins GR16:$src1, i16imm:$src2),
3114 "sbb{w}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen874ae252009-06-02 03:12:52 +00003115 [(set GR16:$dst, (sube GR16:$src1, imm:$src2))]>, OpSize;
Dale Johannesenca11dae2009-05-18 17:44:15 +00003116def SBB16ri8 : Ii8<0x83, MRM3r, (outs GR16:$dst),
3117 (ins GR16:$src1, i16i8imm:$src2),
3118 "sbb{w}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen874ae252009-06-02 03:12:52 +00003119 [(set GR16:$dst, (sube GR16:$src1, i16immSExt8:$src2))]>,
3120 OpSize;
Dale Johannesenca11dae2009-05-18 17:44:15 +00003121def SBB32ri : Ii32<0x81, MRM3r, (outs GR32:$dst),
3122 (ins GR32:$src1, i32imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003123 "sbb{l}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen874ae252009-06-02 03:12:52 +00003124 [(set GR32:$dst, (sube GR32:$src1, imm:$src2))]>;
Dale Johannesenca11dae2009-05-18 17:44:15 +00003125def SBB32ri8 : Ii8<0x83, MRM3r, (outs GR32:$dst),
3126 (ins GR32:$src1, i32i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003127 "sbb{l}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen874ae252009-06-02 03:12:52 +00003128 [(set GR32:$dst, (sube GR32:$src1, i32immSExt8:$src2))]>;
Evan Cheng3154cb62007-10-05 17:59:57 +00003129} // Uses = [EFLAGS]
Evan Cheng24f2ea32007-09-14 21:48:26 +00003130} // Defs = [EFLAGS]
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00003131
Evan Cheng24f2ea32007-09-14 21:48:26 +00003132let Defs = [EFLAGS] in {
Chris Lattner10197ff2005-01-03 01:27:59 +00003133let isCommutable = 1 in { // X = IMUL Y, Z --> X = IMUL Z, Y
Bill Wendlingd350e022008-12-12 21:15:41 +00003134// Register-Register Signed Integer Multiply
Bill Wendlingab55ebd2008-12-12 00:56:36 +00003135def IMUL16rr : I<0xAF, MRMSrcReg, (outs GR16:$dst), (ins GR16:$src1,GR16:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003136 "imul{w}\t{$src2, $dst|$dst, $src2}",
Chris Lattnerec856802010-03-27 00:45:04 +00003137 [(set GR16:$dst, EFLAGS,
3138 (X86smul_flag GR16:$src1, GR16:$src2))]>, TB, OpSize;
Bill Wendlingab55ebd2008-12-12 00:56:36 +00003139def IMUL32rr : I<0xAF, MRMSrcReg, (outs GR32:$dst), (ins GR32:$src1,GR32:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003140 "imul{l}\t{$src2, $dst|$dst, $src2}",
Chris Lattnerec856802010-03-27 00:45:04 +00003141 [(set GR32:$dst, EFLAGS,
3142 (X86smul_flag GR32:$src1, GR32:$src2))]>, TB;
Chris Lattner10197ff2005-01-03 01:27:59 +00003143}
Bill Wendlingab55ebd2008-12-12 00:56:36 +00003144
Bill Wendlingd350e022008-12-12 21:15:41 +00003145// Register-Memory Signed Integer Multiply
Bill Wendlingab55ebd2008-12-12 00:56:36 +00003146def IMUL16rm : I<0xAF, MRMSrcMem, (outs GR16:$dst),
3147 (ins GR16:$src1, i16mem:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003148 "imul{w}\t{$src2, $dst|$dst, $src2}",
Chris Lattnerec856802010-03-27 00:45:04 +00003149 [(set GR16:$dst, EFLAGS,
3150 (X86smul_flag GR16:$src1, (load addr:$src2)))]>,
3151 TB, OpSize;
Sean Callanan108934c2009-12-18 00:01:26 +00003152def IMUL32rm : I<0xAF, MRMSrcMem, (outs GR32:$dst),
3153 (ins GR32:$src1, i32mem:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003154 "imul{l}\t{$src2, $dst|$dst, $src2}",
Chris Lattnerec856802010-03-27 00:45:04 +00003155 [(set GR32:$dst, EFLAGS,
3156 (X86smul_flag GR32:$src1, (load addr:$src2)))]>, TB;
Evan Cheng24f2ea32007-09-14 21:48:26 +00003157} // Defs = [EFLAGS]
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00003158} // end Two Address instructions
3159
Chris Lattnerf5d3a832004-08-11 05:31:07 +00003160// Suprisingly enough, these are not two address instructions!
Evan Cheng24f2ea32007-09-14 21:48:26 +00003161let Defs = [EFLAGS] in {
Bill Wendlingd350e022008-12-12 21:15:41 +00003162// Register-Integer Signed Integer Multiply
Evan Cheng069287d2006-05-16 07:21:53 +00003163def IMUL16rri : Ii16<0x69, MRMSrcReg, // GR16 = GR16*I16
Evan Cheng64d80e32007-07-19 01:14:50 +00003164 (outs GR16:$dst), (ins GR16:$src1, i16imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003165 "imul{w}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Chris Lattnerec856802010-03-27 00:45:04 +00003166 [(set GR16:$dst, EFLAGS,
3167 (X86smul_flag GR16:$src1, imm:$src2))]>, OpSize;
Evan Cheng069287d2006-05-16 07:21:53 +00003168def IMUL32rri : Ii32<0x69, MRMSrcReg, // GR32 = GR32*I32
Evan Cheng64d80e32007-07-19 01:14:50 +00003169 (outs GR32:$dst), (ins GR32:$src1, i32imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003170 "imul{l}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Chris Lattnerec856802010-03-27 00:45:04 +00003171 [(set GR32:$dst, EFLAGS,
3172 (X86smul_flag GR32:$src1, imm:$src2))]>;
Evan Cheng069287d2006-05-16 07:21:53 +00003173def IMUL16rri8 : Ii8<0x6B, MRMSrcReg, // GR16 = GR16*I8
Evan Cheng64d80e32007-07-19 01:14:50 +00003174 (outs GR16:$dst), (ins GR16:$src1, i16i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003175 "imul{w}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Chris Lattnerec856802010-03-27 00:45:04 +00003176 [(set GR16:$dst, EFLAGS,
3177 (X86smul_flag GR16:$src1, i16immSExt8:$src2))]>,
3178 OpSize;
Evan Cheng069287d2006-05-16 07:21:53 +00003179def IMUL32rri8 : Ii8<0x6B, MRMSrcReg, // GR32 = GR32*I8
Evan Cheng64d80e32007-07-19 01:14:50 +00003180 (outs GR32:$dst), (ins GR32:$src1, i32i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003181 "imul{l}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Chris Lattnerec856802010-03-27 00:45:04 +00003182 [(set GR32:$dst, EFLAGS,
3183 (X86smul_flag GR32:$src1, i32immSExt8:$src2))]>;
Chris Lattnerf5d3a832004-08-11 05:31:07 +00003184
Bill Wendlingd350e022008-12-12 21:15:41 +00003185// Memory-Integer Signed Integer Multiply
Sean Callanan108934c2009-12-18 00:01:26 +00003186def IMUL16rmi : Ii16<0x69, MRMSrcMem, // GR16 = [mem16]*I16
Evan Cheng64d80e32007-07-19 01:14:50 +00003187 (outs GR16:$dst), (ins i16mem:$src1, i16imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003188 "imul{w}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Chris Lattnerec856802010-03-27 00:45:04 +00003189 [(set GR16:$dst, EFLAGS,
3190 (X86smul_flag (load addr:$src1), imm:$src2))]>,
3191 OpSize;
Sean Callanan108934c2009-12-18 00:01:26 +00003192def IMUL32rmi : Ii32<0x69, MRMSrcMem, // GR32 = [mem32]*I32
Evan Cheng64d80e32007-07-19 01:14:50 +00003193 (outs GR32:$dst), (ins i32mem:$src1, i32imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003194 "imul{l}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Chris Lattnerec856802010-03-27 00:45:04 +00003195 [(set GR32:$dst, EFLAGS,
3196 (X86smul_flag (load addr:$src1), imm:$src2))]>;
Evan Cheng069287d2006-05-16 07:21:53 +00003197def IMUL16rmi8 : Ii8<0x6B, MRMSrcMem, // GR16 = [mem16]*I8
Evan Cheng64d80e32007-07-19 01:14:50 +00003198 (outs GR16:$dst), (ins i16mem:$src1, i16i8imm :$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003199 "imul{w}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Chris Lattnerec856802010-03-27 00:45:04 +00003200 [(set GR16:$dst, EFLAGS,
3201 (X86smul_flag (load addr:$src1),
3202 i16immSExt8:$src2))]>, OpSize;
Evan Cheng069287d2006-05-16 07:21:53 +00003203def IMUL32rmi8 : Ii8<0x6B, MRMSrcMem, // GR32 = [mem32]*I8
Evan Cheng64d80e32007-07-19 01:14:50 +00003204 (outs GR32:$dst), (ins i32mem:$src1, i32i8imm: $src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003205 "imul{l}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Chris Lattnerec856802010-03-27 00:45:04 +00003206 [(set GR32:$dst, EFLAGS,
3207 (X86smul_flag (load addr:$src1),
3208 i32immSExt8:$src2))]>;
Evan Cheng24f2ea32007-09-14 21:48:26 +00003209} // Defs = [EFLAGS]
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00003210
3211//===----------------------------------------------------------------------===//
3212// Test instructions are just like AND, except they don't generate a result.
Chris Lattner3a173df2004-10-03 20:35:00 +00003213//
Evan Cheng0488db92007-09-25 01:57:46 +00003214let Defs = [EFLAGS] in {
Chris Lattnercc65bee2005-01-02 02:35:46 +00003215let isCommutable = 1 in { // TEST X, Y --> TEST Y, X
Daniel Dunbarb93c72c2010-03-08 21:10:36 +00003216def TEST8rr : I<0x84, MRMSrcReg, (outs), (ins GR8:$src1, GR8:$src2),
Evan Chenge5f62042007-09-29 00:00:36 +00003217 "test{b}\t{$src2, $src1|$src1, $src2}",
Chris Lattnere3486a42010-03-19 00:01:11 +00003218 [(set EFLAGS, (X86cmp (and_su GR8:$src1, GR8:$src2), 0))]>;
Daniel Dunbarb93c72c2010-03-08 21:10:36 +00003219def TEST16rr : I<0x85, MRMSrcReg, (outs), (ins GR16:$src1, GR16:$src2),
Evan Chenge5f62042007-09-29 00:00:36 +00003220 "test{w}\t{$src2, $src1|$src1, $src2}",
Chris Lattnere3486a42010-03-19 00:01:11 +00003221 [(set EFLAGS, (X86cmp (and_su GR16:$src1, GR16:$src2),
3222 0))]>,
Evan Chenge5f62042007-09-29 00:00:36 +00003223 OpSize;
Daniel Dunbarb93c72c2010-03-08 21:10:36 +00003224def TEST32rr : I<0x85, MRMSrcReg, (outs), (ins GR32:$src1, GR32:$src2),
Evan Chenge5f62042007-09-29 00:00:36 +00003225 "test{l}\t{$src2, $src1|$src1, $src2}",
Chris Lattnere3486a42010-03-19 00:01:11 +00003226 [(set EFLAGS, (X86cmp (and_su GR32:$src1, GR32:$src2),
3227 0))]>;
Chris Lattnercc65bee2005-01-02 02:35:46 +00003228}
Evan Cheng734503b2006-09-11 02:19:56 +00003229
Sean Callanan4a93b712009-09-01 18:14:18 +00003230def TEST8i8 : Ii8<0xA8, RawFrm, (outs), (ins i8imm:$src),
3231 "test{b}\t{$src, %al|%al, $src}", []>;
3232def TEST16i16 : Ii16<0xA9, RawFrm, (outs), (ins i16imm:$src),
3233 "test{w}\t{$src, %ax|%ax, $src}", []>, OpSize;
3234def TEST32i32 : Ii32<0xA9, RawFrm, (outs), (ins i32imm:$src),
3235 "test{l}\t{$src, %eax|%eax, $src}", []>;
3236
Evan Cheng64d80e32007-07-19 01:14:50 +00003237def TEST8rm : I<0x84, MRMSrcMem, (outs), (ins GR8 :$src1, i8mem :$src2),
Evan Chenge5f62042007-09-29 00:00:36 +00003238 "test{b}\t{$src2, $src1|$src1, $src2}",
Chris Lattnere3486a42010-03-19 00:01:11 +00003239 [(set EFLAGS, (X86cmp (and GR8:$src1, (loadi8 addr:$src2)),
3240 0))]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00003241def TEST16rm : I<0x85, MRMSrcMem, (outs), (ins GR16:$src1, i16mem:$src2),
Evan Chenge5f62042007-09-29 00:00:36 +00003242 "test{w}\t{$src2, $src1|$src1, $src2}",
Chris Lattnere3486a42010-03-19 00:01:11 +00003243 [(set EFLAGS, (X86cmp (and GR16:$src1,
3244 (loadi16 addr:$src2)), 0))]>, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00003245def TEST32rm : I<0x85, MRMSrcMem, (outs), (ins GR32:$src1, i32mem:$src2),
Evan Chenge5f62042007-09-29 00:00:36 +00003246 "test{l}\t{$src2, $src1|$src1, $src2}",
Chris Lattnere3486a42010-03-19 00:01:11 +00003247 [(set EFLAGS, (X86cmp (and GR32:$src1,
3248 (loadi32 addr:$src2)), 0))]>;
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00003249
Evan Cheng069287d2006-05-16 07:21:53 +00003250def TEST8ri : Ii8 <0xF6, MRM0r, // flags = GR8 & imm8
Evan Cheng64d80e32007-07-19 01:14:50 +00003251 (outs), (ins GR8:$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_su GR8:$src1, imm:$src2), 0))]>;
Evan Cheng069287d2006-05-16 07:21:53 +00003254def TEST16ri : Ii16<0xF7, MRM0r, // flags = GR16 & imm16
Evan Cheng64d80e32007-07-19 01:14:50 +00003255 (outs), (ins GR16:$src1, i16imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003256 "test{w}\t{$src2, $src1|$src1, $src2}",
Chris Lattnere3486a42010-03-19 00:01:11 +00003257 [(set EFLAGS, (X86cmp (and_su GR16:$src1, imm:$src2), 0))]>,
3258 OpSize;
Evan Cheng069287d2006-05-16 07:21:53 +00003259def TEST32ri : Ii32<0xF7, MRM0r, // flags = GR32 & imm32
Evan Cheng64d80e32007-07-19 01:14:50 +00003260 (outs), (ins GR32:$src1, i32imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003261 "test{l}\t{$src2, $src1|$src1, $src2}",
Chris Lattnere3486a42010-03-19 00:01:11 +00003262 [(set EFLAGS, (X86cmp (and_su GR32:$src1, imm:$src2), 0))]>;
Evan Cheng734503b2006-09-11 02:19:56 +00003263
Evan Chenge5f62042007-09-29 00:00:36 +00003264def TEST8mi : Ii8 <0xF6, MRM0m, // flags = [mem8] & imm8
Evan Cheng64d80e32007-07-19 01:14:50 +00003265 (outs), (ins i8mem:$src1, i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003266 "test{b}\t{$src2, $src1|$src1, $src2}",
Chris Lattnere3486a42010-03-19 00:01:11 +00003267 [(set EFLAGS, (X86cmp (and (loadi8 addr:$src1), imm:$src2),
3268 0))]>;
Evan Chenge5f62042007-09-29 00:00:36 +00003269def TEST16mi : Ii16<0xF7, MRM0m, // flags = [mem16] & imm16
Evan Cheng64d80e32007-07-19 01:14:50 +00003270 (outs), (ins i16mem:$src1, i16imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003271 "test{w}\t{$src2, $src1|$src1, $src2}",
Chris Lattnere3486a42010-03-19 00:01:11 +00003272 [(set EFLAGS, (X86cmp (and (loadi16 addr:$src1), imm:$src2),
3273 0))]>, OpSize;
Evan Chenge5f62042007-09-29 00:00:36 +00003274def TEST32mi : Ii32<0xF7, MRM0m, // flags = [mem32] & imm32
Evan Cheng64d80e32007-07-19 01:14:50 +00003275 (outs), (ins i32mem:$src1, i32imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003276 "test{l}\t{$src2, $src1|$src1, $src2}",
Chris Lattnere3486a42010-03-19 00:01:11 +00003277 [(set EFLAGS, (X86cmp (and (loadi32 addr:$src1), imm:$src2),
3278 0))]>;
Evan Cheng0488db92007-09-25 01:57:46 +00003279} // Defs = [EFLAGS]
3280
3281
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00003282// Condition code ops, incl. set if equal/not equal/...
Chris Lattnerba7e7562008-01-10 07:59:24 +00003283let Defs = [EFLAGS], Uses = [AH], neverHasSideEffects = 1 in
Evan Cheng071a2792007-09-11 19:55:27 +00003284def SAHF : I<0x9E, RawFrm, (outs), (ins), "sahf", []>; // flags = AH
Chris Lattnerba7e7562008-01-10 07:59:24 +00003285let Defs = [AH], Uses = [EFLAGS], neverHasSideEffects = 1 in
Evan Cheng071a2792007-09-11 19:55:27 +00003286def LAHF : I<0x9F, RawFrm, (outs), (ins), "lahf", []>; // AH = flags
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00003287
Evan Cheng0488db92007-09-25 01:57:46 +00003288let Uses = [EFLAGS] in {
Evan Chengad9c0a32009-12-15 00:53:42 +00003289// Use sbb to materialize carry bit.
Evan Chengad9c0a32009-12-15 00:53:42 +00003290let Defs = [EFLAGS], isCodeGenOnly = 1 in {
Chris Lattnerc74e3332010-02-05 21:13:48 +00003291// FIXME: These are pseudo ops that should be replaced with Pat<> patterns.
3292// However, Pat<> can't replicate the destination reg into the inputs of the
3293// result.
3294// FIXME: Change these to have encoding Pseudo when X86MCCodeEmitter replaces
3295// X86CodeEmitter.
3296def SETB_C8r : I<0x18, MRMInitReg, (outs GR8:$dst), (ins), "",
Evan Chengad9c0a32009-12-15 00:53:42 +00003297 [(set GR8:$dst, (X86setcc_c X86_COND_B, EFLAGS))]>;
Chris Lattnerc74e3332010-02-05 21:13:48 +00003298def SETB_C16r : I<0x19, MRMInitReg, (outs GR16:$dst), (ins), "",
Evan Cheng2e489c42009-12-16 00:53:11 +00003299 [(set GR16:$dst, (X86setcc_c X86_COND_B, EFLAGS))]>,
Evan Chengad9c0a32009-12-15 00:53:42 +00003300 OpSize;
Chris Lattnerc74e3332010-02-05 21:13:48 +00003301def SETB_C32r : I<0x19, MRMInitReg, (outs GR32:$dst), (ins), "",
Evan Cheng2e489c42009-12-16 00:53:11 +00003302 [(set GR32:$dst, (X86setcc_c X86_COND_B, EFLAGS))]>;
Evan Chengad9c0a32009-12-15 00:53:42 +00003303} // isCodeGenOnly
3304
Chris Lattner3a173df2004-10-03 20:35:00 +00003305def SETEr : I<0x94, MRM0r,
Evan Cheng64d80e32007-07-19 01:14:50 +00003306 (outs GR8 :$dst), (ins),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003307 "sete\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +00003308 [(set GR8:$dst, (X86setcc X86_COND_E, EFLAGS))]>,
Evan Cheng069287d2006-05-16 07:21:53 +00003309 TB; // GR8 = ==
Chris Lattner3a173df2004-10-03 20:35:00 +00003310def SETEm : I<0x94, MRM0m,
Evan Cheng64d80e32007-07-19 01:14:50 +00003311 (outs), (ins i8mem:$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003312 "sete\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +00003313 [(store (X86setcc X86_COND_E, EFLAGS), addr:$dst)]>,
Evan Chengd5781fc2005-12-21 20:21:51 +00003314 TB; // [mem8] = ==
Bill Wendling9f248742008-12-02 00:07:05 +00003315
Chris Lattner3a173df2004-10-03 20:35:00 +00003316def SETNEr : I<0x95, MRM0r,
Evan Cheng64d80e32007-07-19 01:14:50 +00003317 (outs GR8 :$dst), (ins),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003318 "setne\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +00003319 [(set GR8:$dst, (X86setcc X86_COND_NE, EFLAGS))]>,
Evan Cheng069287d2006-05-16 07:21:53 +00003320 TB; // GR8 = !=
Chris Lattner3a173df2004-10-03 20:35:00 +00003321def SETNEm : I<0x95, MRM0m,
Evan Cheng64d80e32007-07-19 01:14:50 +00003322 (outs), (ins i8mem:$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003323 "setne\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +00003324 [(store (X86setcc X86_COND_NE, EFLAGS), addr:$dst)]>,
Evan Chengd5781fc2005-12-21 20:21:51 +00003325 TB; // [mem8] = !=
Bill Wendling9f248742008-12-02 00:07:05 +00003326
Evan Chengd5781fc2005-12-21 20:21:51 +00003327def SETLr : I<0x9C, MRM0r,
Evan Cheng64d80e32007-07-19 01:14:50 +00003328 (outs GR8 :$dst), (ins),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003329 "setl\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +00003330 [(set GR8:$dst, (X86setcc X86_COND_L, EFLAGS))]>,
Evan Cheng069287d2006-05-16 07:21:53 +00003331 TB; // GR8 = < signed
Evan Chengd5781fc2005-12-21 20:21:51 +00003332def SETLm : I<0x9C, MRM0m,
Evan Cheng64d80e32007-07-19 01:14:50 +00003333 (outs), (ins i8mem:$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003334 "setl\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +00003335 [(store (X86setcc X86_COND_L, EFLAGS), addr:$dst)]>,
Evan Chengd5781fc2005-12-21 20:21:51 +00003336 TB; // [mem8] = < signed
Bill Wendling9f248742008-12-02 00:07:05 +00003337
Evan Chengd5781fc2005-12-21 20:21:51 +00003338def SETGEr : I<0x9D, MRM0r,
Evan Cheng64d80e32007-07-19 01:14:50 +00003339 (outs GR8 :$dst), (ins),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003340 "setge\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +00003341 [(set GR8:$dst, (X86setcc X86_COND_GE, EFLAGS))]>,
Evan Cheng069287d2006-05-16 07:21:53 +00003342 TB; // GR8 = >= signed
Evan Chengd5781fc2005-12-21 20:21:51 +00003343def SETGEm : I<0x9D, MRM0m,
Evan Cheng64d80e32007-07-19 01:14:50 +00003344 (outs), (ins i8mem:$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003345 "setge\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +00003346 [(store (X86setcc X86_COND_GE, EFLAGS), addr:$dst)]>,
Evan Chengd5781fc2005-12-21 20:21:51 +00003347 TB; // [mem8] = >= signed
Bill Wendling9f248742008-12-02 00:07:05 +00003348
Evan Chengd5781fc2005-12-21 20:21:51 +00003349def SETLEr : I<0x9E, MRM0r,
Evan Cheng64d80e32007-07-19 01:14:50 +00003350 (outs GR8 :$dst), (ins),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003351 "setle\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +00003352 [(set GR8:$dst, (X86setcc X86_COND_LE, EFLAGS))]>,
Evan Cheng069287d2006-05-16 07:21:53 +00003353 TB; // GR8 = <= signed
Evan Chengd5781fc2005-12-21 20:21:51 +00003354def SETLEm : I<0x9E, MRM0m,
Evan Cheng64d80e32007-07-19 01:14:50 +00003355 (outs), (ins i8mem:$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003356 "setle\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +00003357 [(store (X86setcc X86_COND_LE, EFLAGS), addr:$dst)]>,
Evan Chengd5781fc2005-12-21 20:21:51 +00003358 TB; // [mem8] = <= signed
Bill Wendling9f248742008-12-02 00:07:05 +00003359
Evan Chengd5781fc2005-12-21 20:21:51 +00003360def SETGr : I<0x9F, MRM0r,
Evan Cheng64d80e32007-07-19 01:14:50 +00003361 (outs GR8 :$dst), (ins),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003362 "setg\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +00003363 [(set GR8:$dst, (X86setcc X86_COND_G, EFLAGS))]>,
Evan Cheng069287d2006-05-16 07:21:53 +00003364 TB; // GR8 = > signed
Evan Chengd5781fc2005-12-21 20:21:51 +00003365def SETGm : I<0x9F, MRM0m,
Evan Cheng64d80e32007-07-19 01:14:50 +00003366 (outs), (ins i8mem:$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003367 "setg\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +00003368 [(store (X86setcc X86_COND_G, EFLAGS), addr:$dst)]>,
Evan Chengd5781fc2005-12-21 20:21:51 +00003369 TB; // [mem8] = > signed
3370
3371def SETBr : I<0x92, MRM0r,
Evan Cheng64d80e32007-07-19 01:14:50 +00003372 (outs GR8 :$dst), (ins),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003373 "setb\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +00003374 [(set GR8:$dst, (X86setcc X86_COND_B, EFLAGS))]>,
Evan Cheng069287d2006-05-16 07:21:53 +00003375 TB; // GR8 = < unsign
Evan Chengd5781fc2005-12-21 20:21:51 +00003376def SETBm : I<0x92, MRM0m,
Evan Cheng64d80e32007-07-19 01:14:50 +00003377 (outs), (ins i8mem:$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003378 "setb\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +00003379 [(store (X86setcc X86_COND_B, EFLAGS), addr:$dst)]>,
Evan Chengd5781fc2005-12-21 20:21:51 +00003380 TB; // [mem8] = < unsign
Bill Wendling9f248742008-12-02 00:07:05 +00003381
Evan Chengd5781fc2005-12-21 20:21:51 +00003382def SETAEr : I<0x93, MRM0r,
Evan Cheng64d80e32007-07-19 01:14:50 +00003383 (outs GR8 :$dst), (ins),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003384 "setae\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +00003385 [(set GR8:$dst, (X86setcc X86_COND_AE, EFLAGS))]>,
Evan Cheng069287d2006-05-16 07:21:53 +00003386 TB; // GR8 = >= unsign
Evan Chengd5781fc2005-12-21 20:21:51 +00003387def SETAEm : I<0x93, MRM0m,
Evan Cheng64d80e32007-07-19 01:14:50 +00003388 (outs), (ins i8mem:$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003389 "setae\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +00003390 [(store (X86setcc X86_COND_AE, EFLAGS), addr:$dst)]>,
Evan Chengd5781fc2005-12-21 20:21:51 +00003391 TB; // [mem8] = >= unsign
Bill Wendling9f248742008-12-02 00:07:05 +00003392
Chris Lattner3a173df2004-10-03 20:35:00 +00003393def SETBEr : I<0x96, MRM0r,
Evan Cheng64d80e32007-07-19 01:14:50 +00003394 (outs GR8 :$dst), (ins),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003395 "setbe\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +00003396 [(set GR8:$dst, (X86setcc X86_COND_BE, EFLAGS))]>,
Evan Cheng069287d2006-05-16 07:21:53 +00003397 TB; // GR8 = <= unsign
Chris Lattner3a173df2004-10-03 20:35:00 +00003398def SETBEm : I<0x96, MRM0m,
Evan Cheng64d80e32007-07-19 01:14:50 +00003399 (outs), (ins i8mem:$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003400 "setbe\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +00003401 [(store (X86setcc X86_COND_BE, EFLAGS), addr:$dst)]>,
Evan Chengd5781fc2005-12-21 20:21:51 +00003402 TB; // [mem8] = <= unsign
Bill Wendling9f248742008-12-02 00:07:05 +00003403
Chris Lattner3a173df2004-10-03 20:35:00 +00003404def SETAr : I<0x97, MRM0r,
Evan Cheng64d80e32007-07-19 01:14:50 +00003405 (outs GR8 :$dst), (ins),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003406 "seta\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +00003407 [(set GR8:$dst, (X86setcc X86_COND_A, EFLAGS))]>,
Evan Cheng069287d2006-05-16 07:21:53 +00003408 TB; // GR8 = > signed
Chris Lattner3a173df2004-10-03 20:35:00 +00003409def SETAm : I<0x97, MRM0m,
Evan Cheng64d80e32007-07-19 01:14:50 +00003410 (outs), (ins i8mem:$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003411 "seta\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +00003412 [(store (X86setcc X86_COND_A, EFLAGS), addr:$dst)]>,
Evan Chengd5781fc2005-12-21 20:21:51 +00003413 TB; // [mem8] = > signed
Evan Chengd9558e02006-01-06 00:43:03 +00003414
Chris Lattner3a173df2004-10-03 20:35:00 +00003415def SETSr : I<0x98, MRM0r,
Evan Cheng64d80e32007-07-19 01:14:50 +00003416 (outs GR8 :$dst), (ins),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003417 "sets\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +00003418 [(set GR8:$dst, (X86setcc X86_COND_S, EFLAGS))]>,
Evan Cheng069287d2006-05-16 07:21:53 +00003419 TB; // GR8 = <sign bit>
Chris Lattner3a173df2004-10-03 20:35:00 +00003420def SETSm : I<0x98, MRM0m,
Evan Cheng64d80e32007-07-19 01:14:50 +00003421 (outs), (ins i8mem:$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003422 "sets\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +00003423 [(store (X86setcc X86_COND_S, EFLAGS), addr:$dst)]>,
Evan Chengd9558e02006-01-06 00:43:03 +00003424 TB; // [mem8] = <sign bit>
Chris Lattner3a173df2004-10-03 20:35:00 +00003425def SETNSr : I<0x99, MRM0r,
Evan Cheng64d80e32007-07-19 01:14:50 +00003426 (outs GR8 :$dst), (ins),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003427 "setns\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +00003428 [(set GR8:$dst, (X86setcc X86_COND_NS, EFLAGS))]>,
Evan Cheng069287d2006-05-16 07:21:53 +00003429 TB; // GR8 = !<sign bit>
Chris Lattner3a173df2004-10-03 20:35:00 +00003430def SETNSm : I<0x99, MRM0m,
Evan Cheng64d80e32007-07-19 01:14:50 +00003431 (outs), (ins i8mem:$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003432 "setns\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +00003433 [(store (X86setcc X86_COND_NS, EFLAGS), addr:$dst)]>,
Evan Chengd9558e02006-01-06 00:43:03 +00003434 TB; // [mem8] = !<sign bit>
Bill Wendling9f248742008-12-02 00:07:05 +00003435
Chris Lattner3a173df2004-10-03 20:35:00 +00003436def SETPr : I<0x9A, MRM0r,
Evan Cheng64d80e32007-07-19 01:14:50 +00003437 (outs GR8 :$dst), (ins),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003438 "setp\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +00003439 [(set GR8:$dst, (X86setcc X86_COND_P, EFLAGS))]>,
Evan Cheng069287d2006-05-16 07:21:53 +00003440 TB; // GR8 = parity
Chris Lattner3a173df2004-10-03 20:35:00 +00003441def SETPm : I<0x9A, MRM0m,
Evan Cheng64d80e32007-07-19 01:14:50 +00003442 (outs), (ins i8mem:$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003443 "setp\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +00003444 [(store (X86setcc X86_COND_P, EFLAGS), addr:$dst)]>,
Evan Chengd9558e02006-01-06 00:43:03 +00003445 TB; // [mem8] = parity
Chris Lattnercc65bee2005-01-02 02:35:46 +00003446def SETNPr : I<0x9B, MRM0r,
Evan Cheng64d80e32007-07-19 01:14:50 +00003447 (outs GR8 :$dst), (ins),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003448 "setnp\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +00003449 [(set GR8:$dst, (X86setcc X86_COND_NP, EFLAGS))]>,
Evan Cheng069287d2006-05-16 07:21:53 +00003450 TB; // GR8 = not parity
Chris Lattnercc65bee2005-01-02 02:35:46 +00003451def SETNPm : I<0x9B, MRM0m,
Evan Cheng64d80e32007-07-19 01:14:50 +00003452 (outs), (ins i8mem:$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003453 "setnp\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +00003454 [(store (X86setcc X86_COND_NP, EFLAGS), addr:$dst)]>,
Evan Chengd9558e02006-01-06 00:43:03 +00003455 TB; // [mem8] = not parity
Bill Wendling9f248742008-12-02 00:07:05 +00003456
3457def SETOr : I<0x90, MRM0r,
3458 (outs GR8 :$dst), (ins),
3459 "seto\t$dst",
3460 [(set GR8:$dst, (X86setcc X86_COND_O, EFLAGS))]>,
3461 TB; // GR8 = overflow
3462def SETOm : I<0x90, MRM0m,
3463 (outs), (ins i8mem:$dst),
3464 "seto\t$dst",
3465 [(store (X86setcc X86_COND_O, EFLAGS), addr:$dst)]>,
3466 TB; // [mem8] = overflow
3467def SETNOr : I<0x91, MRM0r,
3468 (outs GR8 :$dst), (ins),
3469 "setno\t$dst",
3470 [(set GR8:$dst, (X86setcc X86_COND_NO, EFLAGS))]>,
3471 TB; // GR8 = not overflow
3472def SETNOm : I<0x91, MRM0m,
3473 (outs), (ins i8mem:$dst),
3474 "setno\t$dst",
3475 [(store (X86setcc X86_COND_NO, EFLAGS), addr:$dst)]>,
3476 TB; // [mem8] = not overflow
Evan Cheng0488db92007-09-25 01:57:46 +00003477} // Uses = [EFLAGS]
3478
Chris Lattner1cca5e32003-08-03 21:54:21 +00003479
3480// Integer comparisons
Evan Cheng24f2ea32007-09-14 21:48:26 +00003481let Defs = [EFLAGS] in {
Sean Callanana09caa52009-09-02 00:55:49 +00003482def CMP8i8 : Ii8<0x3C, RawFrm, (outs), (ins i8imm:$src),
3483 "cmp{b}\t{$src, %al|%al, $src}", []>;
3484def CMP16i16 : Ii16<0x3D, RawFrm, (outs), (ins i16imm:$src),
3485 "cmp{w}\t{$src, %ax|%ax, $src}", []>, OpSize;
3486def CMP32i32 : Ii32<0x3D, RawFrm, (outs), (ins i32imm:$src),
3487 "cmp{l}\t{$src, %eax|%eax, $src}", []>;
3488
Chris Lattner3a173df2004-10-03 20:35:00 +00003489def CMP8rr : I<0x38, MRMDestReg,
Evan Cheng64d80e32007-07-19 01:14:50 +00003490 (outs), (ins GR8 :$src1, GR8 :$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003491 "cmp{b}\t{$src2, $src1|$src1, $src2}",
Chris Lattnere3486a42010-03-19 00:01:11 +00003492 [(set EFLAGS, (X86cmp GR8:$src1, GR8:$src2))]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00003493def CMP16rr : I<0x39, MRMDestReg,
Evan Cheng64d80e32007-07-19 01:14:50 +00003494 (outs), (ins GR16:$src1, GR16:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003495 "cmp{w}\t{$src2, $src1|$src1, $src2}",
Chris Lattnere3486a42010-03-19 00:01:11 +00003496 [(set EFLAGS, (X86cmp GR16:$src1, GR16:$src2))]>, OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00003497def CMP32rr : I<0x39, MRMDestReg,
Evan Cheng64d80e32007-07-19 01:14:50 +00003498 (outs), (ins GR32:$src1, GR32:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003499 "cmp{l}\t{$src2, $src1|$src1, $src2}",
Chris Lattnere3486a42010-03-19 00:01:11 +00003500 [(set EFLAGS, (X86cmp GR32:$src1, GR32:$src2))]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00003501def CMP8mr : I<0x38, MRMDestMem,
Evan Cheng64d80e32007-07-19 01:14:50 +00003502 (outs), (ins i8mem :$src1, GR8 :$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003503 "cmp{b}\t{$src2, $src1|$src1, $src2}",
Chris Lattnere3486a42010-03-19 00:01:11 +00003504 [(set EFLAGS, (X86cmp (loadi8 addr:$src1), GR8:$src2))]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00003505def CMP16mr : I<0x39, MRMDestMem,
Evan Cheng64d80e32007-07-19 01:14:50 +00003506 (outs), (ins i16mem:$src1, GR16:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003507 "cmp{w}\t{$src2, $src1|$src1, $src2}",
Chris Lattnere3486a42010-03-19 00:01:11 +00003508 [(set EFLAGS, (X86cmp (loadi16 addr:$src1), GR16:$src2))]>,
3509 OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00003510def CMP32mr : I<0x39, MRMDestMem,
Evan Cheng64d80e32007-07-19 01:14:50 +00003511 (outs), (ins i32mem:$src1, GR32:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003512 "cmp{l}\t{$src2, $src1|$src1, $src2}",
Chris Lattnere3486a42010-03-19 00:01:11 +00003513 [(set EFLAGS, (X86cmp (loadi32 addr:$src1), GR32:$src2))]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00003514def CMP8rm : I<0x3A, MRMSrcMem,
Evan Cheng64d80e32007-07-19 01:14:50 +00003515 (outs), (ins GR8 :$src1, i8mem :$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003516 "cmp{b}\t{$src2, $src1|$src1, $src2}",
Chris Lattnere3486a42010-03-19 00:01:11 +00003517 [(set EFLAGS, (X86cmp GR8:$src1, (loadi8 addr:$src2)))]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00003518def CMP16rm : I<0x3B, MRMSrcMem,
Evan Cheng64d80e32007-07-19 01:14:50 +00003519 (outs), (ins GR16:$src1, i16mem:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003520 "cmp{w}\t{$src2, $src1|$src1, $src2}",
Chris Lattnere3486a42010-03-19 00:01:11 +00003521 [(set EFLAGS, (X86cmp GR16:$src1, (loadi16 addr:$src2)))]>,
3522 OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00003523def CMP32rm : I<0x3B, MRMSrcMem,
Evan Cheng64d80e32007-07-19 01:14:50 +00003524 (outs), (ins GR32:$src1, i32mem:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003525 "cmp{l}\t{$src2, $src1|$src1, $src2}",
Chris Lattnere3486a42010-03-19 00:01:11 +00003526 [(set EFLAGS, (X86cmp GR32:$src1, (loadi32 addr:$src2)))]>;
Daniel Dunbar1e8ee892010-03-09 22:50:40 +00003527
3528// These are alternate spellings for use by the disassembler, we mark them as
3529// code gen only to ensure they aren't matched by the assembler.
3530let isCodeGenOnly = 1 in {
3531 def CMP8rr_alt : I<0x3A, MRMSrcReg, (outs), (ins GR8:$src1, GR8:$src2),
3532 "cmp{b}\t{$src2, $src1|$src1, $src2}", []>;
3533 def CMP16rr_alt : I<0x3B, MRMSrcReg, (outs), (ins GR16:$src1, GR16:$src2),
3534 "cmp{w}\t{$src2, $src1|$src1, $src2}", []>, OpSize;
3535 def CMP32rr_alt : I<0x3B, MRMSrcReg, (outs), (ins GR32:$src1, GR32:$src2),
3536 "cmp{l}\t{$src2, $src1|$src1, $src2}", []>;
3537}
3538
Chris Lattner3a173df2004-10-03 20:35:00 +00003539def CMP8ri : Ii8<0x80, MRM7r,
Evan Cheng64d80e32007-07-19 01:14:50 +00003540 (outs), (ins GR8:$src1, i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003541 "cmp{b}\t{$src2, $src1|$src1, $src2}",
Chris Lattnere3486a42010-03-19 00:01:11 +00003542 [(set EFLAGS, (X86cmp GR8:$src1, imm:$src2))]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00003543def CMP16ri : Ii16<0x81, MRM7r,
Evan Cheng64d80e32007-07-19 01:14:50 +00003544 (outs), (ins GR16:$src1, i16imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003545 "cmp{w}\t{$src2, $src1|$src1, $src2}",
Chris Lattnere3486a42010-03-19 00:01:11 +00003546 [(set EFLAGS, (X86cmp GR16:$src1, imm:$src2))]>, OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00003547def CMP32ri : Ii32<0x81, MRM7r,
Evan Cheng64d80e32007-07-19 01:14:50 +00003548 (outs), (ins GR32:$src1, i32imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003549 "cmp{l}\t{$src2, $src1|$src1, $src2}",
Chris Lattnere3486a42010-03-19 00:01:11 +00003550 [(set EFLAGS, (X86cmp GR32:$src1, imm:$src2))]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00003551def CMP8mi : Ii8 <0x80, MRM7m,
Evan Cheng64d80e32007-07-19 01:14:50 +00003552 (outs), (ins i8mem :$src1, i8imm :$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003553 "cmp{b}\t{$src2, $src1|$src1, $src2}",
Chris Lattnere3486a42010-03-19 00:01:11 +00003554 [(set EFLAGS, (X86cmp (loadi8 addr:$src1), imm:$src2))]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00003555def CMP16mi : Ii16<0x81, MRM7m,
Evan Cheng64d80e32007-07-19 01:14:50 +00003556 (outs), (ins i16mem:$src1, i16imm:$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), imm:$src2))]>,
3559 OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00003560def CMP32mi : Ii32<0x81, MRM7m,
Evan Cheng64d80e32007-07-19 01:14:50 +00003561 (outs), (ins i32mem:$src1, i32imm:$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), imm:$src2))]>;
Chris Lattner29b4dd02006-03-23 16:13:50 +00003564def CMP16ri8 : Ii8<0x83, MRM7r,
Evan Cheng64d80e32007-07-19 01:14:50 +00003565 (outs), (ins GR16:$src1, i16i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003566 "cmp{w}\t{$src2, $src1|$src1, $src2}",
Chris Lattnere3486a42010-03-19 00:01:11 +00003567 [(set EFLAGS, (X86cmp GR16:$src1, i16immSExt8:$src2))]>,
3568 OpSize;
Chris Lattner29b4dd02006-03-23 16:13:50 +00003569def CMP16mi8 : Ii8<0x83, MRM7m,
Evan Cheng64d80e32007-07-19 01:14:50 +00003570 (outs), (ins i16mem:$src1, i16i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003571 "cmp{w}\t{$src2, $src1|$src1, $src2}",
Chris Lattnere3486a42010-03-19 00:01:11 +00003572 [(set EFLAGS, (X86cmp (loadi16 addr:$src1),
3573 i16immSExt8:$src2))]>, OpSize;
Chris Lattner29b4dd02006-03-23 16:13:50 +00003574def CMP32mi8 : Ii8<0x83, MRM7m,
Evan Cheng64d80e32007-07-19 01:14:50 +00003575 (outs), (ins i32mem:$src1, i32i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003576 "cmp{l}\t{$src2, $src1|$src1, $src2}",
Chris Lattnere3486a42010-03-19 00:01:11 +00003577 [(set EFLAGS, (X86cmp (loadi32 addr:$src1),
3578 i32immSExt8:$src2))]>;
Chris Lattner29b4dd02006-03-23 16:13:50 +00003579def CMP32ri8 : Ii8<0x83, MRM7r,
Evan Cheng64d80e32007-07-19 01:14:50 +00003580 (outs), (ins GR32:$src1, i32i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003581 "cmp{l}\t{$src2, $src1|$src1, $src2}",
Chris Lattnere3486a42010-03-19 00:01:11 +00003582 [(set EFLAGS, (X86cmp GR32:$src1, i32immSExt8:$src2))]>;
Evan Cheng0488db92007-09-25 01:57:46 +00003583} // Defs = [EFLAGS]
3584
Dan Gohmanc7a37d42008-12-23 22:45:23 +00003585// Bit tests.
Dan Gohmanc7a37d42008-12-23 22:45:23 +00003586// TODO: BTC, BTR, and BTS
3587let Defs = [EFLAGS] in {
Dan Gohman0c89b7e2009-01-13 20:32:45 +00003588def BT16rr : I<0xA3, MRMDestReg, (outs), (ins GR16:$src1, GR16:$src2),
Dan Gohmanc7a37d42008-12-23 22:45:23 +00003589 "bt{w}\t{$src2, $src1|$src1, $src2}",
Chris Lattnere3486a42010-03-19 00:01:11 +00003590 [(set EFLAGS, (X86bt GR16:$src1, GR16:$src2))]>, OpSize, TB;
Dan Gohman0c89b7e2009-01-13 20:32:45 +00003591def BT32rr : I<0xA3, MRMDestReg, (outs), (ins GR32:$src1, GR32:$src2),
Dan Gohmanc7a37d42008-12-23 22:45:23 +00003592 "bt{l}\t{$src2, $src1|$src1, $src2}",
Chris Lattnere3486a42010-03-19 00:01:11 +00003593 [(set EFLAGS, (X86bt GR32:$src1, GR32:$src2))]>, TB;
Dan Gohmanf31408d2009-01-13 23:23:30 +00003594
3595// Unlike with the register+register form, the memory+register form of the
3596// bt instruction does not ignore the high bits of the index. From ISel's
Sean Callanan108934c2009-12-18 00:01:26 +00003597// perspective, this is pretty bizarre. Make these instructions disassembly
3598// only for now.
3599
3600def BT16mr : I<0xA3, MRMDestMem, (outs), (ins i16mem:$src1, GR16:$src2),
3601 "bt{w}\t{$src2, $src1|$src1, $src2}",
Dan Gohmanf31408d2009-01-13 23:23:30 +00003602// [(X86bt (loadi16 addr:$src1), GR16:$src2),
Sean Callanan108934c2009-12-18 00:01:26 +00003603// (implicit EFLAGS)]
3604 []
3605 >, OpSize, TB, Requires<[FastBTMem]>;
3606def BT32mr : I<0xA3, MRMDestMem, (outs), (ins i32mem:$src1, GR32:$src2),
3607 "bt{l}\t{$src2, $src1|$src1, $src2}",
Dan Gohmanf31408d2009-01-13 23:23:30 +00003608// [(X86bt (loadi32 addr:$src1), GR32:$src2),
Sean Callanan108934c2009-12-18 00:01:26 +00003609// (implicit EFLAGS)]
3610 []
3611 >, TB, Requires<[FastBTMem]>;
Dan Gohman4afe15b2009-01-13 20:33:23 +00003612
3613def BT16ri8 : Ii8<0xBA, MRM4r, (outs), (ins GR16:$src1, i16i8imm:$src2),
3614 "bt{w}\t{$src2, $src1|$src1, $src2}",
Chris Lattnere3486a42010-03-19 00:01:11 +00003615 [(set EFLAGS, (X86bt GR16:$src1, i16immSExt8:$src2))]>,
3616 OpSize, TB;
Dan Gohman4afe15b2009-01-13 20:33:23 +00003617def BT32ri8 : Ii8<0xBA, MRM4r, (outs), (ins GR32:$src1, i32i8imm:$src2),
3618 "bt{l}\t{$src2, $src1|$src1, $src2}",
Chris Lattnere3486a42010-03-19 00:01:11 +00003619 [(set EFLAGS, (X86bt GR32:$src1, i32immSExt8:$src2))]>, TB;
Dan Gohman4afe15b2009-01-13 20:33:23 +00003620// Note that these instructions don't need FastBTMem because that
3621// only applies when the other operand is in a register. When it's
3622// an immediate, bt is still fast.
3623def BT16mi8 : Ii8<0xBA, MRM4m, (outs), (ins i16mem:$src1, i16i8imm:$src2),
3624 "bt{w}\t{$src2, $src1|$src1, $src2}",
Chris Lattnere3486a42010-03-19 00:01:11 +00003625 [(set EFLAGS, (X86bt (loadi16 addr:$src1), i16immSExt8:$src2))
3626 ]>, OpSize, TB;
Dan Gohman4afe15b2009-01-13 20:33:23 +00003627def BT32mi8 : Ii8<0xBA, MRM4m, (outs), (ins i32mem:$src1, i32i8imm:$src2),
3628 "bt{l}\t{$src2, $src1|$src1, $src2}",
Chris Lattnere3486a42010-03-19 00:01:11 +00003629 [(set EFLAGS, (X86bt (loadi32 addr:$src1), i32immSExt8:$src2))
3630 ]>, TB;
Sean Callanan108934c2009-12-18 00:01:26 +00003631
3632def BTC16rr : I<0xBB, MRMDestReg, (outs), (ins GR16:$src1, GR16:$src2),
3633 "btc{w}\t{$src2, $src1|$src1, $src2}", []>, OpSize, TB;
3634def BTC32rr : I<0xBB, MRMDestReg, (outs), (ins GR32:$src1, GR32:$src2),
3635 "btc{l}\t{$src2, $src1|$src1, $src2}", []>, TB;
3636def BTC16mr : I<0xBB, MRMDestMem, (outs), (ins i16mem:$src1, GR16:$src2),
3637 "btc{w}\t{$src2, $src1|$src1, $src2}", []>, OpSize, TB;
3638def BTC32mr : I<0xBB, MRMDestMem, (outs), (ins i32mem:$src1, GR32:$src2),
3639 "btc{l}\t{$src2, $src1|$src1, $src2}", []>, TB;
3640def BTC16ri8 : Ii8<0xBA, MRM7r, (outs), (ins GR16:$src1, i16i8imm:$src2),
3641 "btc{w}\t{$src2, $src1|$src1, $src2}", []>, OpSize, TB;
3642def BTC32ri8 : Ii8<0xBA, MRM7r, (outs), (ins GR32:$src1, i32i8imm:$src2),
3643 "btc{l}\t{$src2, $src1|$src1, $src2}", []>, TB;
3644def BTC16mi8 : Ii8<0xBA, MRM7m, (outs), (ins i16mem:$src1, i16i8imm:$src2),
3645 "btc{w}\t{$src2, $src1|$src1, $src2}", []>, OpSize, TB;
3646def BTC32mi8 : Ii8<0xBA, MRM7m, (outs), (ins i32mem:$src1, i32i8imm:$src2),
3647 "btc{l}\t{$src2, $src1|$src1, $src2}", []>, TB;
3648
3649def BTR16rr : I<0xB3, MRMDestReg, (outs), (ins GR16:$src1, GR16:$src2),
3650 "btr{w}\t{$src2, $src1|$src1, $src2}", []>, OpSize, TB;
3651def BTR32rr : I<0xB3, MRMDestReg, (outs), (ins GR32:$src1, GR32:$src2),
3652 "btr{l}\t{$src2, $src1|$src1, $src2}", []>, TB;
3653def BTR16mr : I<0xB3, MRMDestMem, (outs), (ins i16mem:$src1, GR16:$src2),
3654 "btr{w}\t{$src2, $src1|$src1, $src2}", []>, OpSize, TB;
3655def BTR32mr : I<0xB3, MRMDestMem, (outs), (ins i32mem:$src1, GR32:$src2),
3656 "btr{l}\t{$src2, $src1|$src1, $src2}", []>, TB;
3657def BTR16ri8 : Ii8<0xBA, MRM6r, (outs), (ins GR16:$src1, i16i8imm:$src2),
3658 "btr{w}\t{$src2, $src1|$src1, $src2}", []>, OpSize, TB;
3659def BTR32ri8 : Ii8<0xBA, MRM6r, (outs), (ins GR32:$src1, i32i8imm:$src2),
3660 "btr{l}\t{$src2, $src1|$src1, $src2}", []>, TB;
3661def BTR16mi8 : Ii8<0xBA, MRM6m, (outs), (ins i16mem:$src1, i16i8imm:$src2),
3662 "btr{w}\t{$src2, $src1|$src1, $src2}", []>, OpSize, TB;
3663def BTR32mi8 : Ii8<0xBA, MRM6m, (outs), (ins i32mem:$src1, i32i8imm:$src2),
3664 "btr{l}\t{$src2, $src1|$src1, $src2}", []>, TB;
3665
3666def BTS16rr : I<0xAB, MRMDestReg, (outs), (ins GR16:$src1, GR16:$src2),
3667 "bts{w}\t{$src2, $src1|$src1, $src2}", []>, OpSize, TB;
3668def BTS32rr : I<0xAB, MRMDestReg, (outs), (ins GR32:$src1, GR32:$src2),
3669 "bts{l}\t{$src2, $src1|$src1, $src2}", []>, TB;
3670def BTS16mr : I<0xAB, MRMDestMem, (outs), (ins i16mem:$src1, GR16:$src2),
3671 "bts{w}\t{$src2, $src1|$src1, $src2}", []>, OpSize, TB;
3672def BTS32mr : I<0xAB, MRMDestMem, (outs), (ins i32mem:$src1, GR32:$src2),
3673 "bts{l}\t{$src2, $src1|$src1, $src2}", []>, TB;
3674def BTS16ri8 : Ii8<0xBA, MRM5r, (outs), (ins GR16:$src1, i16i8imm:$src2),
3675 "bts{w}\t{$src2, $src1|$src1, $src2}", []>, OpSize, TB;
3676def BTS32ri8 : Ii8<0xBA, MRM5r, (outs), (ins GR32:$src1, i32i8imm:$src2),
3677 "bts{l}\t{$src2, $src1|$src1, $src2}", []>, TB;
3678def BTS16mi8 : Ii8<0xBA, MRM5m, (outs), (ins i16mem:$src1, i16i8imm:$src2),
3679 "bts{w}\t{$src2, $src1|$src1, $src2}", []>, OpSize, TB;
3680def BTS32mi8 : Ii8<0xBA, MRM5m, (outs), (ins i32mem:$src1, i32i8imm:$src2),
3681 "bts{l}\t{$src2, $src1|$src1, $src2}", []>, TB;
Dan Gohmanc7a37d42008-12-23 22:45:23 +00003682} // Defs = [EFLAGS]
3683
Chris Lattner1cca5e32003-08-03 21:54:21 +00003684// Sign/Zero extenders
Dan Gohman11ba3b12008-07-30 18:09:17 +00003685// Use movsbl intead of movsbw; we don't care about the high 16 bits
3686// of the register here. This has a smaller encoding and avoids a
Sean Callanan108934c2009-12-18 00:01:26 +00003687// partial-register update. Actual movsbw included for the disassembler.
3688def MOVSX16rr8W : I<0xBE, MRMSrcReg, (outs GR16:$dst), (ins GR8:$src),
3689 "movs{bw|x}\t{$src, $dst|$dst, $src}", []>, TB, OpSize;
3690def MOVSX16rm8W : I<0xBE, MRMSrcMem, (outs GR16:$dst), (ins i8mem:$src),
3691 "movs{bw|x}\t{$src, $dst|$dst, $src}", []>, TB, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00003692def MOVSX16rr8 : I<0xBE, MRMSrcReg, (outs GR16:$dst), (ins GR8 :$src),
Chris Lattner172862a2009-10-19 19:51:42 +00003693 "", [(set GR16:$dst, (sext GR8:$src))]>, TB;
Evan Cheng64d80e32007-07-19 01:14:50 +00003694def MOVSX16rm8 : I<0xBE, MRMSrcMem, (outs GR16:$dst), (ins i8mem :$src),
Chris Lattner172862a2009-10-19 19:51:42 +00003695 "", [(set GR16:$dst, (sextloadi16i8 addr:$src))]>, TB;
Evan Cheng64d80e32007-07-19 01:14:50 +00003696def MOVSX32rr8 : I<0xBE, MRMSrcReg, (outs GR32:$dst), (ins GR8 :$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003697 "movs{bl|x}\t{$src, $dst|$dst, $src}",
Evan Cheng069287d2006-05-16 07:21:53 +00003698 [(set GR32:$dst, (sext GR8:$src))]>, TB;
Evan Cheng64d80e32007-07-19 01:14:50 +00003699def MOVSX32rm8 : I<0xBE, MRMSrcMem, (outs GR32:$dst), (ins i8mem :$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003700 "movs{bl|x}\t{$src, $dst|$dst, $src}",
Evan Cheng069287d2006-05-16 07:21:53 +00003701 [(set GR32:$dst, (sextloadi32i8 addr:$src))]>, TB;
Evan Cheng64d80e32007-07-19 01:14:50 +00003702def MOVSX32rr16: I<0xBF, MRMSrcReg, (outs GR32:$dst), (ins GR16:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003703 "movs{wl|x}\t{$src, $dst|$dst, $src}",
Evan Cheng069287d2006-05-16 07:21:53 +00003704 [(set GR32:$dst, (sext GR16:$src))]>, TB;
Evan Cheng64d80e32007-07-19 01:14:50 +00003705def MOVSX32rm16: I<0xBF, MRMSrcMem, (outs GR32:$dst), (ins i16mem:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003706 "movs{wl|x}\t{$src, $dst|$dst, $src}",
Evan Cheng069287d2006-05-16 07:21:53 +00003707 [(set GR32:$dst, (sextloadi32i16 addr:$src))]>, TB;
Alkis Evlogimenosa7be9822004-02-17 09:14:23 +00003708
Dan Gohman11ba3b12008-07-30 18:09:17 +00003709// Use movzbl intead of movzbw; we don't care about the high 16 bits
3710// of the register here. This has a smaller encoding and avoids a
Sean Callanan108934c2009-12-18 00:01:26 +00003711// partial-register update. Actual movzbw included for the disassembler.
3712def MOVZX16rr8W : I<0xB6, MRMSrcReg, (outs GR16:$dst), (ins GR8:$src),
3713 "movz{bw|x}\t{$src, $dst|$dst, $src}", []>, TB, OpSize;
3714def MOVZX16rm8W : I<0xB6, MRMSrcMem, (outs GR16:$dst), (ins i8mem:$src),
3715 "movz{bw|x}\t{$src, $dst|$dst, $src}", []>, TB, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00003716def MOVZX16rr8 : I<0xB6, MRMSrcReg, (outs GR16:$dst), (ins GR8 :$src),
Chris Lattner172862a2009-10-19 19:51:42 +00003717 "", [(set GR16:$dst, (zext GR8:$src))]>, TB;
Evan Cheng64d80e32007-07-19 01:14:50 +00003718def MOVZX16rm8 : I<0xB6, MRMSrcMem, (outs GR16:$dst), (ins i8mem :$src),
Chris Lattner172862a2009-10-19 19:51:42 +00003719 "", [(set GR16:$dst, (zextloadi16i8 addr:$src))]>, TB;
Evan Cheng64d80e32007-07-19 01:14:50 +00003720def MOVZX32rr8 : I<0xB6, MRMSrcReg, (outs GR32:$dst), (ins GR8 :$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003721 "movz{bl|x}\t{$src, $dst|$dst, $src}",
Evan Cheng069287d2006-05-16 07:21:53 +00003722 [(set GR32:$dst, (zext GR8:$src))]>, TB;
Evan Cheng64d80e32007-07-19 01:14:50 +00003723def MOVZX32rm8 : I<0xB6, MRMSrcMem, (outs GR32:$dst), (ins i8mem :$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003724 "movz{bl|x}\t{$src, $dst|$dst, $src}",
Evan Cheng069287d2006-05-16 07:21:53 +00003725 [(set GR32:$dst, (zextloadi32i8 addr:$src))]>, TB;
Evan Cheng64d80e32007-07-19 01:14:50 +00003726def MOVZX32rr16: I<0xB7, MRMSrcReg, (outs GR32:$dst), (ins GR16:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003727 "movz{wl|x}\t{$src, $dst|$dst, $src}",
Evan Cheng069287d2006-05-16 07:21:53 +00003728 [(set GR32:$dst, (zext GR16:$src))]>, TB;
Evan Cheng64d80e32007-07-19 01:14:50 +00003729def MOVZX32rm16: I<0xB7, MRMSrcMem, (outs GR32:$dst), (ins i16mem:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003730 "movz{wl|x}\t{$src, $dst|$dst, $src}",
Evan Cheng069287d2006-05-16 07:21:53 +00003731 [(set GR32:$dst, (zextloadi32i16 addr:$src))]>, TB;
Evan Cheng7a7e8372005-12-14 02:22:27 +00003732
Dan Gohmanf451cb82010-02-10 16:03:48 +00003733// These are the same as the regular MOVZX32rr8 and MOVZX32rm8
Dan Gohman21e3dfb2009-04-13 16:09:41 +00003734// except that they use GR32_NOREX for the output operand register class
3735// instead of GR32. This allows them to operate on h registers on x86-64.
3736def MOVZX32_NOREXrr8 : I<0xB6, MRMSrcReg,
3737 (outs GR32_NOREX:$dst), (ins GR8:$src),
3738 "movz{bl|x}\t{$src, $dst|$dst, $src} # NOREX",
3739 []>, TB;
Dan Gohman78e04d42009-04-30 03:11:48 +00003740let mayLoad = 1 in
Dan Gohman21e3dfb2009-04-13 16:09:41 +00003741def MOVZX32_NOREXrm8 : I<0xB6, MRMSrcMem,
3742 (outs GR32_NOREX:$dst), (ins i8mem:$src),
3743 "movz{bl|x}\t{$src, $dst|$dst, $src} # NOREX",
3744 []>, TB;
3745
Chris Lattnerba7e7562008-01-10 07:59:24 +00003746let neverHasSideEffects = 1 in {
3747 let Defs = [AX], Uses = [AL] in
3748 def CBW : I<0x98, RawFrm, (outs), (ins),
3749 "{cbtw|cbw}", []>, OpSize; // AX = signext(AL)
3750 let Defs = [EAX], Uses = [AX] in
3751 def CWDE : I<0x98, RawFrm, (outs), (ins),
3752 "{cwtl|cwde}", []>; // EAX = signext(AX)
Evan Chengf91c1012006-05-31 22:05:11 +00003753
Chris Lattnerba7e7562008-01-10 07:59:24 +00003754 let Defs = [AX,DX], Uses = [AX] in
3755 def CWD : I<0x99, RawFrm, (outs), (ins),
3756 "{cwtd|cwd}", []>, OpSize; // DX:AX = signext(AX)
3757 let Defs = [EAX,EDX], Uses = [EAX] in
3758 def CDQ : I<0x99, RawFrm, (outs), (ins),
3759 "{cltd|cdq}", []>; // EDX:EAX = signext(EAX)
3760}
Evan Cheng747a90d2006-02-21 02:24:38 +00003761
Evan Cheng747a90d2006-02-21 02:24:38 +00003762//===----------------------------------------------------------------------===//
3763// Alias Instructions
3764//===----------------------------------------------------------------------===//
3765
3766// Alias instructions that map movr0 to xor.
3767// FIXME: remove when we can teach regalloc that xor reg, reg is ok.
Chris Lattner35e0e842010-02-05 21:21:06 +00003768// FIXME: Set encoding to pseudo.
Daniel Dunbar7417b762009-08-11 22:17:52 +00003769let Defs = [EFLAGS], isReMaterializable = 1, isAsCheapAsAMove = 1,
3770 isCodeGenOnly = 1 in {
Chris Lattner35e0e842010-02-05 21:21:06 +00003771def MOV8r0 : I<0x30, MRMInitReg, (outs GR8 :$dst), (ins), "",
Evan Cheng069287d2006-05-16 07:21:53 +00003772 [(set GR8:$dst, 0)]>;
Dan Gohmanf1b4d262010-01-12 04:42:54 +00003773
3774// We want to rewrite MOV16r0 in terms of MOV32r0, because it's a smaller
3775// encoding and avoids a partial-register update sometimes, but doing so
3776// at isel time interferes with rematerialization in the current register
3777// allocator. For now, this is rewritten when the instruction is lowered
3778// to an MCInst.
3779def MOV16r0 : I<0x31, MRMInitReg, (outs GR16:$dst), (ins),
3780 "",
3781 [(set GR16:$dst, 0)]>, OpSize;
Chris Lattner6a381822009-12-23 01:30:26 +00003782
Chris Lattner35e0e842010-02-05 21:21:06 +00003783// FIXME: Set encoding to pseudo.
3784def MOV32r0 : I<0x31, MRMInitReg, (outs GR32:$dst), (ins), "",
Chris Lattnerac105c42009-12-23 01:46:40 +00003785 [(set GR32:$dst, 0)]>;
3786}
Chris Lattner6a381822009-12-23 01:30:26 +00003787
Evan Cheng510e4782006-01-09 23:10:28 +00003788//===----------------------------------------------------------------------===//
Lauro Ramos Venanciob3a04172007-04-20 21:38:10 +00003789// Thread Local Storage Instructions
3790//
3791
Rafael Espindola15f1b662009-04-24 12:59:40 +00003792// All calls clobber the non-callee saved registers. ESP is marked as
3793// a use to prevent stack-pointer assignments that appear immediately
3794// before calls from potentially appearing dead.
3795let Defs = [EAX, ECX, EDX, FP0, FP1, FP2, FP3, FP4, FP5, FP6, ST0,
3796 MM0, MM1, MM2, MM3, MM4, MM5, MM6, MM7,
3797 XMM0, XMM1, XMM2, XMM3, XMM4, XMM5, XMM6, XMM7,
3798 XMM8, XMM9, XMM10, XMM11, XMM12, XMM13, XMM14, XMM15, EFLAGS],
Chris Lattner5c0b16d2009-06-20 20:38:48 +00003799 Uses = [ESP] in
3800def TLS_addr32 : I<0, Pseudo, (outs), (ins lea32mem:$sym),
3801 "leal\t$sym, %eax; "
Dan Gohman4d47b9b2009-04-27 15:13:28 +00003802 "call\t___tls_get_addr@PLT",
Chris Lattner5c0b16d2009-06-20 20:38:48 +00003803 [(X86tlsaddr tls32addr:$sym)]>,
Rafael Espindola2ee3db32009-04-17 14:35:58 +00003804 Requires<[In32BitMode]>;
Lauro Ramos Venanciob3a04172007-04-20 21:38:10 +00003805
Daniel Dunbar0c420fc2009-08-11 22:24:40 +00003806let AddedComplexity = 5, isCodeGenOnly = 1 in
Nate Begeman51a04372009-01-26 01:24:32 +00003807def GS_MOV32rm : I<0x8B, MRMSrcMem, (outs GR32:$dst), (ins i32mem:$src),
3808 "movl\t%gs:$src, $dst",
3809 [(set GR32:$dst, (gsload addr:$src))]>, SegGS;
3810
Daniel Dunbar0c420fc2009-08-11 22:24:40 +00003811let AddedComplexity = 5, isCodeGenOnly = 1 in
Chris Lattner1777d0c2009-05-05 18:52:19 +00003812def FS_MOV32rm : I<0x8B, MRMSrcMem, (outs GR32:$dst), (ins i32mem:$src),
3813 "movl\t%fs:$src, $dst",
3814 [(set GR32:$dst, (fsload addr:$src))]>, SegFS;
3815
Lauro Ramos Venanciob3a04172007-04-20 21:38:10 +00003816//===----------------------------------------------------------------------===//
Anton Korobeynikov2365f512007-07-14 14:06:15 +00003817// EH Pseudo Instructions
3818//
3819let isTerminator = 1, isReturn = 1, isBarrier = 1,
Daniel Dunbar1ca3a0b2009-08-27 07:58:05 +00003820 hasCtrlDep = 1, isCodeGenOnly = 1 in {
Evan Cheng64d80e32007-07-19 01:14:50 +00003821def EH_RETURN : I<0xC3, RawFrm, (outs), (ins GR32:$addr),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003822 "ret\t#eh_return, addr: $addr",
Anton Korobeynikov2365f512007-07-14 14:06:15 +00003823 [(X86ehret GR32:$addr)]>;
3824
3825}
3826
3827//===----------------------------------------------------------------------===//
Andrew Lenharthab0b9492008-02-21 06:45:13 +00003828// Atomic support
3829//
Andrew Lenharthea7da502008-03-01 13:37:02 +00003830
Evan Chengbb6939d2008-04-19 01:20:30 +00003831// Atomic swap. These are just normal xchg instructions. But since a memory
3832// operand is referenced, the atomicity is ensured.
Dan Gohman165660e2008-08-06 15:52:50 +00003833let Constraints = "$val = $dst" in {
Sean Callanan108934c2009-12-18 00:01:26 +00003834def XCHG32rm : I<0x87, MRMSrcMem, (outs GR32:$dst),
3835 (ins GR32:$val, i32mem:$ptr),
Evan Chengbb6939d2008-04-19 01:20:30 +00003836 "xchg{l}\t{$val, $ptr|$ptr, $val}",
3837 [(set GR32:$dst, (atomic_swap_32 addr:$ptr, GR32:$val))]>;
Sean Callanan108934c2009-12-18 00:01:26 +00003838def XCHG16rm : I<0x87, MRMSrcMem, (outs GR16:$dst),
3839 (ins GR16:$val, i16mem:$ptr),
Evan Chengbb6939d2008-04-19 01:20:30 +00003840 "xchg{w}\t{$val, $ptr|$ptr, $val}",
3841 [(set GR16:$dst, (atomic_swap_16 addr:$ptr, GR16:$val))]>,
3842 OpSize;
Sean Callanan108934c2009-12-18 00:01:26 +00003843def XCHG8rm : I<0x86, MRMSrcMem, (outs GR8:$dst), (ins GR8:$val, i8mem:$ptr),
Evan Chengbb6939d2008-04-19 01:20:30 +00003844 "xchg{b}\t{$val, $ptr|$ptr, $val}",
3845 [(set GR8:$dst, (atomic_swap_8 addr:$ptr, GR8:$val))]>;
Sean Callanan108934c2009-12-18 00:01:26 +00003846
3847def XCHG32rr : I<0x87, MRMSrcReg, (outs GR32:$dst), (ins GR32:$val, GR32:$src),
3848 "xchg{l}\t{$val, $src|$src, $val}", []>;
3849def XCHG16rr : I<0x87, MRMSrcReg, (outs GR16:$dst), (ins GR16:$val, GR16:$src),
3850 "xchg{w}\t{$val, $src|$src, $val}", []>, OpSize;
3851def XCHG8rr : I<0x86, MRMSrcReg, (outs GR8:$dst), (ins GR8:$val, GR8:$src),
3852 "xchg{b}\t{$val, $src|$src, $val}", []>;
Evan Chengbb6939d2008-04-19 01:20:30 +00003853}
3854
Sean Callanan108934c2009-12-18 00:01:26 +00003855def XCHG16ar : I<0x90, AddRegFrm, (outs), (ins GR16:$src),
3856 "xchg{w}\t{$src, %ax|%ax, $src}", []>, OpSize;
3857def XCHG32ar : I<0x90, AddRegFrm, (outs), (ins GR32:$src),
3858 "xchg{l}\t{$src, %eax|%eax, $src}", []>;
3859
Evan Cheng7e032802008-04-18 20:55:36 +00003860// Atomic compare and swap.
Andrew Lenharth26ed8692008-03-01 21:52:34 +00003861let Defs = [EAX, EFLAGS], Uses = [EAX] in {
Evan Cheng7e032802008-04-18 20:55:36 +00003862def LCMPXCHG32 : I<0xB1, MRMDestMem, (outs), (ins i32mem:$ptr, GR32:$swap),
Dan Gohman4d47b9b2009-04-27 15:13:28 +00003863 "lock\n\t"
3864 "cmpxchg{l}\t{$swap, $ptr|$ptr, $swap}",
Evan Cheng32967d22008-03-04 03:20:06 +00003865 [(X86cas addr:$ptr, GR32:$swap, 4)]>, TB, LOCK;
Andrew Lenharthea7da502008-03-01 13:37:02 +00003866}
Dale Johannesen48c1bc22008-10-02 18:53:47 +00003867let Defs = [EAX, EDX, EFLAGS], Uses = [EAX, EBX, ECX, EDX] in {
Evan Chengb093bd02010-01-08 01:29:19 +00003868def LCMPXCHG8B : I<0xC7, MRM1m, (outs), (ins i64mem:$ptr),
Dan Gohman4d47b9b2009-04-27 15:13:28 +00003869 "lock\n\t"
3870 "cmpxchg8b\t$ptr",
Andrew Lenharthd19189e2008-03-05 01:15:49 +00003871 [(X86cas8 addr:$ptr)]>, TB, LOCK;
3872}
Andrew Lenharth26ed8692008-03-01 21:52:34 +00003873
3874let Defs = [AX, EFLAGS], Uses = [AX] in {
Evan Cheng7e032802008-04-18 20:55:36 +00003875def LCMPXCHG16 : I<0xB1, MRMDestMem, (outs), (ins i16mem:$ptr, GR16:$swap),
Dan Gohman4d47b9b2009-04-27 15:13:28 +00003876 "lock\n\t"
3877 "cmpxchg{w}\t{$swap, $ptr|$ptr, $swap}",
Evan Cheng32967d22008-03-04 03:20:06 +00003878 [(X86cas addr:$ptr, GR16:$swap, 2)]>, TB, OpSize, LOCK;
Andrew Lenharthea7da502008-03-01 13:37:02 +00003879}
Andrew Lenharth26ed8692008-03-01 21:52:34 +00003880let Defs = [AL, EFLAGS], Uses = [AL] in {
Evan Cheng7e032802008-04-18 20:55:36 +00003881def LCMPXCHG8 : I<0xB0, MRMDestMem, (outs), (ins i8mem:$ptr, GR8:$swap),
Dan Gohman4d47b9b2009-04-27 15:13:28 +00003882 "lock\n\t"
3883 "cmpxchg{b}\t{$swap, $ptr|$ptr, $swap}",
Evan Cheng32967d22008-03-04 03:20:06 +00003884 [(X86cas addr:$ptr, GR8:$swap, 1)]>, TB, LOCK;
Andrew Lenharthea7da502008-03-01 13:37:02 +00003885}
3886
Evan Cheng7e032802008-04-18 20:55:36 +00003887// Atomic exchange and add
3888let Constraints = "$val = $dst", Defs = [EFLAGS] in {
Sean Callanan108934c2009-12-18 00:01:26 +00003889def LXADD32 : I<0xC1, MRMSrcMem, (outs GR32:$dst), (ins GR32:$val, i32mem:$ptr),
Dan Gohman4d47b9b2009-04-27 15:13:28 +00003890 "lock\n\t"
3891 "xadd{l}\t{$val, $ptr|$ptr, $val}",
Mon P Wang28873102008-06-25 08:15:39 +00003892 [(set GR32:$dst, (atomic_load_add_32 addr:$ptr, GR32:$val))]>,
Evan Cheng7e032802008-04-18 20:55:36 +00003893 TB, LOCK;
Sean Callanan108934c2009-12-18 00:01:26 +00003894def LXADD16 : I<0xC1, MRMSrcMem, (outs GR16:$dst), (ins GR16:$val, i16mem:$ptr),
Dan Gohman4d47b9b2009-04-27 15:13:28 +00003895 "lock\n\t"
3896 "xadd{w}\t{$val, $ptr|$ptr, $val}",
Mon P Wang28873102008-06-25 08:15:39 +00003897 [(set GR16:$dst, (atomic_load_add_16 addr:$ptr, GR16:$val))]>,
Evan Cheng7e032802008-04-18 20:55:36 +00003898 TB, OpSize, LOCK;
Sean Callanan108934c2009-12-18 00:01:26 +00003899def LXADD8 : I<0xC0, MRMSrcMem, (outs GR8:$dst), (ins GR8:$val, i8mem:$ptr),
Dan Gohman4d47b9b2009-04-27 15:13:28 +00003900 "lock\n\t"
3901 "xadd{b}\t{$val, $ptr|$ptr, $val}",
Mon P Wang28873102008-06-25 08:15:39 +00003902 [(set GR8:$dst, (atomic_load_add_8 addr:$ptr, GR8:$val))]>,
Evan Cheng7e032802008-04-18 20:55:36 +00003903 TB, LOCK;
Andrew Lenharthea7da502008-03-01 13:37:02 +00003904}
3905
Sean Callanan108934c2009-12-18 00:01:26 +00003906def XADD8rr : I<0xC0, MRMDestReg, (outs GR8:$dst), (ins GR8:$src),
3907 "xadd{b}\t{$src, $dst|$dst, $src}", []>, TB;
3908def XADD16rr : I<0xC1, MRMDestReg, (outs GR16:$dst), (ins GR16:$src),
3909 "xadd{w}\t{$src, $dst|$dst, $src}", []>, TB, OpSize;
3910def XADD32rr : I<0xC1, MRMDestReg, (outs GR32:$dst), (ins GR32:$src),
3911 "xadd{l}\t{$src, $dst|$dst, $src}", []>, TB;
3912
Dan Gohman7f357ec2010-05-14 16:34:55 +00003913let mayLoad = 1, mayStore = 1 in {
Sean Callanan108934c2009-12-18 00:01:26 +00003914def XADD8rm : I<0xC0, MRMDestMem, (outs), (ins i8mem:$dst, GR8:$src),
3915 "xadd{b}\t{$src, $dst|$dst, $src}", []>, TB;
3916def XADD16rm : I<0xC1, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src),
3917 "xadd{w}\t{$src, $dst|$dst, $src}", []>, TB, OpSize;
3918def XADD32rm : I<0xC1, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src),
3919 "xadd{l}\t{$src, $dst|$dst, $src}", []>, TB;
Dan Gohman7f357ec2010-05-14 16:34:55 +00003920}
Sean Callanan108934c2009-12-18 00:01:26 +00003921
3922def CMPXCHG8rr : I<0xB0, MRMDestReg, (outs GR8:$dst), (ins GR8:$src),
3923 "cmpxchg{b}\t{$src, $dst|$dst, $src}", []>, TB;
3924def CMPXCHG16rr : I<0xB1, MRMDestReg, (outs GR16:$dst), (ins GR16:$src),
3925 "cmpxchg{w}\t{$src, $dst|$dst, $src}", []>, TB, OpSize;
3926def CMPXCHG32rr : I<0xB1, MRMDestReg, (outs GR32:$dst), (ins GR32:$src),
3927 "cmpxchg{l}\t{$src, $dst|$dst, $src}", []>, TB;
3928
Dan Gohman7f357ec2010-05-14 16:34:55 +00003929let mayLoad = 1, mayStore = 1 in {
Sean Callanan108934c2009-12-18 00:01:26 +00003930def CMPXCHG8rm : I<0xB0, MRMDestMem, (outs), (ins i8mem:$dst, GR8:$src),
3931 "cmpxchg{b}\t{$src, $dst|$dst, $src}", []>, TB;
3932def CMPXCHG16rm : I<0xB1, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src),
3933 "cmpxchg{w}\t{$src, $dst|$dst, $src}", []>, TB, OpSize;
3934def CMPXCHG32rm : I<0xB1, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src),
3935 "cmpxchg{l}\t{$src, $dst|$dst, $src}", []>, TB;
Dan Gohman7f357ec2010-05-14 16:34:55 +00003936}
Sean Callanan108934c2009-12-18 00:01:26 +00003937
Evan Chengb093bd02010-01-08 01:29:19 +00003938let Defs = [EAX, EDX, EFLAGS], Uses = [EAX, EBX, ECX, EDX] in
Sean Callanan108934c2009-12-18 00:01:26 +00003939def CMPXCHG8B : I<0xC7, MRM1m, (outs), (ins i64mem:$dst),
3940 "cmpxchg8b\t$dst", []>, TB;
3941
Evan Cheng37b73872009-07-30 08:33:02 +00003942// Optimized codegen when the non-memory output is not used.
3943// FIXME: Use normal add / sub instructions and add lock prefix dynamically.
Dan Gohman7f357ec2010-05-14 16:34:55 +00003944let Defs = [EFLAGS], mayLoad = 1, mayStore = 1 in {
Evan Cheng37b73872009-07-30 08:33:02 +00003945def LOCK_ADD8mr : I<0x00, MRMDestMem, (outs), (ins i8mem:$dst, GR8:$src2),
3946 "lock\n\t"
3947 "add{b}\t{$src2, $dst|$dst, $src2}", []>, LOCK;
3948def LOCK_ADD16mr : I<0x01, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
3949 "lock\n\t"
3950 "add{w}\t{$src2, $dst|$dst, $src2}", []>, OpSize, LOCK;
3951def LOCK_ADD32mr : I<0x01, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
3952 "lock\n\t"
3953 "add{l}\t{$src2, $dst|$dst, $src2}", []>, LOCK;
3954def LOCK_ADD8mi : Ii8<0x80, MRM0m, (outs), (ins i8mem :$dst, i8imm :$src2),
3955 "lock\n\t"
3956 "add{b}\t{$src2, $dst|$dst, $src2}", []>, LOCK;
3957def LOCK_ADD16mi : Ii16<0x81, MRM0m, (outs), (ins i16mem:$dst, i16imm:$src2),
3958 "lock\n\t"
3959 "add{w}\t{$src2, $dst|$dst, $src2}", []>, LOCK;
3960def LOCK_ADD32mi : Ii32<0x81, MRM0m, (outs), (ins i32mem:$dst, i32imm:$src2),
3961 "lock\n\t"
3962 "add{l}\t{$src2, $dst|$dst, $src2}", []>, LOCK;
3963def LOCK_ADD16mi8 : Ii8<0x83, MRM0m, (outs), (ins i16mem:$dst, i16i8imm :$src2),
3964 "lock\n\t"
3965 "add{w}\t{$src2, $dst|$dst, $src2}", []>, OpSize, LOCK;
3966def LOCK_ADD32mi8 : Ii8<0x83, MRM0m, (outs), (ins i32mem:$dst, i32i8imm :$src2),
3967 "lock\n\t"
3968 "add{l}\t{$src2, $dst|$dst, $src2}", []>, LOCK;
3969
3970def LOCK_INC8m : I<0xFE, MRM0m, (outs), (ins i8mem :$dst),
3971 "lock\n\t"
3972 "inc{b}\t$dst", []>, LOCK;
3973def LOCK_INC16m : I<0xFF, MRM0m, (outs), (ins i16mem:$dst),
3974 "lock\n\t"
3975 "inc{w}\t$dst", []>, OpSize, LOCK;
3976def LOCK_INC32m : I<0xFF, MRM0m, (outs), (ins i32mem:$dst),
3977 "lock\n\t"
3978 "inc{l}\t$dst", []>, LOCK;
3979
3980def LOCK_SUB8mr : I<0x28, MRMDestMem, (outs), (ins i8mem :$dst, GR8 :$src2),
3981 "lock\n\t"
3982 "sub{b}\t{$src2, $dst|$dst, $src2}", []>, LOCK;
3983def LOCK_SUB16mr : I<0x29, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
3984 "lock\n\t"
3985 "sub{w}\t{$src2, $dst|$dst, $src2}", []>, OpSize, LOCK;
3986def LOCK_SUB32mr : I<0x29, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
3987 "lock\n\t"
3988 "sub{l}\t{$src2, $dst|$dst, $src2}", []>, LOCK;
3989def LOCK_SUB8mi : Ii8<0x80, MRM5m, (outs), (ins i8mem :$dst, i8imm:$src2),
3990 "lock\n\t"
3991 "sub{b}\t{$src2, $dst|$dst, $src2}", []>, LOCK;
3992def LOCK_SUB16mi : Ii16<0x81, MRM5m, (outs), (ins i16mem:$dst, i16imm:$src2),
3993 "lock\n\t"
3994 "sub{w}\t{$src2, $dst|$dst, $src2}", []>, OpSize, LOCK;
3995def LOCK_SUB32mi : Ii32<0x81, MRM5m, (outs), (ins i32mem:$dst, i32imm:$src2),
3996 "lock\n\t"
3997 "sub{l}\t{$src2, $dst|$dst, $src2}", []>, LOCK;
Sean Callanan108934c2009-12-18 00:01:26 +00003998def LOCK_SUB16mi8 : Ii8<0x83, MRM5m, (outs), (ins i16mem:$dst, i16i8imm :$src2),
Evan Cheng37b73872009-07-30 08:33:02 +00003999 "lock\n\t"
4000 "sub{w}\t{$src2, $dst|$dst, $src2}", []>, OpSize, LOCK;
4001def LOCK_SUB32mi8 : Ii8<0x83, MRM5m, (outs), (ins i32mem:$dst, i32i8imm :$src2),
4002 "lock\n\t"
4003 "sub{l}\t{$src2, $dst|$dst, $src2}", []>, LOCK;
4004
4005def LOCK_DEC8m : I<0xFE, MRM1m, (outs), (ins i8mem :$dst),
4006 "lock\n\t"
4007 "dec{b}\t$dst", []>, LOCK;
4008def LOCK_DEC16m : I<0xFF, MRM1m, (outs), (ins i16mem:$dst),
4009 "lock\n\t"
4010 "dec{w}\t$dst", []>, OpSize, LOCK;
4011def LOCK_DEC32m : I<0xFF, MRM1m, (outs), (ins i32mem:$dst),
4012 "lock\n\t"
4013 "dec{l}\t$dst", []>, LOCK;
Dan Gohmanbab42bd2009-10-20 18:14:49 +00004014}
Evan Cheng37b73872009-07-30 08:33:02 +00004015
Mon P Wang28873102008-06-25 08:15:39 +00004016// Atomic exchange, and, or, xor
Mon P Wang63307c32008-05-05 19:05:59 +00004017let Constraints = "$val = $dst", Defs = [EFLAGS],
Dan Gohman533297b2009-10-29 18:10:34 +00004018 usesCustomInserter = 1 in {
Dan Gohman9499b712008-05-12 20:22:45 +00004019def ATOMAND32 : I<0, Pseudo, (outs GR32:$dst),(ins i32mem:$ptr, GR32:$val),
Nick Lewycky6ecf5ce2008-12-07 03:49:52 +00004020 "#ATOMAND32 PSEUDO!",
Dale Johannesene00a8a22008-08-28 02:44:49 +00004021 [(set GR32:$dst, (atomic_load_and_32 addr:$ptr, GR32:$val))]>;
Dan Gohman9499b712008-05-12 20:22:45 +00004022def ATOMOR32 : I<0, Pseudo, (outs GR32:$dst),(ins i32mem:$ptr, GR32:$val),
Nick Lewycky6ecf5ce2008-12-07 03:49:52 +00004023 "#ATOMOR32 PSEUDO!",
Dale Johannesene00a8a22008-08-28 02:44:49 +00004024 [(set GR32:$dst, (atomic_load_or_32 addr:$ptr, GR32:$val))]>;
Dan Gohman9499b712008-05-12 20:22:45 +00004025def ATOMXOR32 : I<0, Pseudo,(outs GR32:$dst),(ins i32mem:$ptr, GR32:$val),
Nick Lewycky6ecf5ce2008-12-07 03:49:52 +00004026 "#ATOMXOR32 PSEUDO!",
Dale Johannesene00a8a22008-08-28 02:44:49 +00004027 [(set GR32:$dst, (atomic_load_xor_32 addr:$ptr, GR32:$val))]>;
Andrew Lenharth507a58a2008-06-14 05:48:15 +00004028def ATOMNAND32 : I<0, Pseudo,(outs GR32:$dst),(ins i32mem:$ptr, GR32:$val),
Nick Lewycky6ecf5ce2008-12-07 03:49:52 +00004029 "#ATOMNAND32 PSEUDO!",
Dale Johannesene00a8a22008-08-28 02:44:49 +00004030 [(set GR32:$dst, (atomic_load_nand_32 addr:$ptr, GR32:$val))]>;
Dan Gohman9499b712008-05-12 20:22:45 +00004031def ATOMMIN32: I<0, Pseudo, (outs GR32:$dst), (ins i32mem:$ptr, GR32:$val),
Nick Lewycky6ecf5ce2008-12-07 03:49:52 +00004032 "#ATOMMIN32 PSEUDO!",
Dale Johannesene00a8a22008-08-28 02:44:49 +00004033 [(set GR32:$dst, (atomic_load_min_32 addr:$ptr, GR32:$val))]>;
Dan Gohman9499b712008-05-12 20:22:45 +00004034def ATOMMAX32: I<0, Pseudo, (outs GR32:$dst),(ins i32mem:$ptr, GR32:$val),
Nick Lewycky6ecf5ce2008-12-07 03:49:52 +00004035 "#ATOMMAX32 PSEUDO!",
Dale Johannesene00a8a22008-08-28 02:44:49 +00004036 [(set GR32:$dst, (atomic_load_max_32 addr:$ptr, GR32:$val))]>;
Dan Gohman9499b712008-05-12 20:22:45 +00004037def ATOMUMIN32: I<0, Pseudo, (outs GR32:$dst),(ins i32mem:$ptr, GR32:$val),
Nick Lewycky6ecf5ce2008-12-07 03:49:52 +00004038 "#ATOMUMIN32 PSEUDO!",
Dale Johannesene00a8a22008-08-28 02:44:49 +00004039 [(set GR32:$dst, (atomic_load_umin_32 addr:$ptr, GR32:$val))]>;
Dan Gohman9499b712008-05-12 20:22:45 +00004040def ATOMUMAX32: I<0, Pseudo, (outs GR32:$dst),(ins i32mem:$ptr, GR32:$val),
Nick Lewycky6ecf5ce2008-12-07 03:49:52 +00004041 "#ATOMUMAX32 PSEUDO!",
Dale Johannesene00a8a22008-08-28 02:44:49 +00004042 [(set GR32:$dst, (atomic_load_umax_32 addr:$ptr, GR32:$val))]>;
Dale Johannesen140be2d2008-08-19 18:47:28 +00004043
4044def ATOMAND16 : I<0, Pseudo, (outs GR16:$dst),(ins i16mem:$ptr, GR16:$val),
Nick Lewycky6ecf5ce2008-12-07 03:49:52 +00004045 "#ATOMAND16 PSEUDO!",
Dale Johannesene00a8a22008-08-28 02:44:49 +00004046 [(set GR16:$dst, (atomic_load_and_16 addr:$ptr, GR16:$val))]>;
Dale Johannesen140be2d2008-08-19 18:47:28 +00004047def ATOMOR16 : I<0, Pseudo, (outs GR16:$dst),(ins i16mem:$ptr, GR16:$val),
Nick Lewycky6ecf5ce2008-12-07 03:49:52 +00004048 "#ATOMOR16 PSEUDO!",
Dale Johannesene00a8a22008-08-28 02:44:49 +00004049 [(set GR16:$dst, (atomic_load_or_16 addr:$ptr, GR16:$val))]>;
Dale Johannesen140be2d2008-08-19 18:47:28 +00004050def ATOMXOR16 : I<0, Pseudo,(outs GR16:$dst),(ins i16mem:$ptr, GR16:$val),
Nick Lewycky6ecf5ce2008-12-07 03:49:52 +00004051 "#ATOMXOR16 PSEUDO!",
Dale Johannesene00a8a22008-08-28 02:44:49 +00004052 [(set GR16:$dst, (atomic_load_xor_16 addr:$ptr, GR16:$val))]>;
Dale Johannesen140be2d2008-08-19 18:47:28 +00004053def ATOMNAND16 : I<0, Pseudo,(outs GR16:$dst),(ins i16mem:$ptr, GR16:$val),
Nick Lewycky6ecf5ce2008-12-07 03:49:52 +00004054 "#ATOMNAND16 PSEUDO!",
Dale Johannesene00a8a22008-08-28 02:44:49 +00004055 [(set GR16:$dst, (atomic_load_nand_16 addr:$ptr, GR16:$val))]>;
Dale Johannesen140be2d2008-08-19 18:47:28 +00004056def ATOMMIN16: I<0, Pseudo, (outs GR16:$dst), (ins i16mem:$ptr, GR16:$val),
Nick Lewycky6ecf5ce2008-12-07 03:49:52 +00004057 "#ATOMMIN16 PSEUDO!",
Dale Johannesene00a8a22008-08-28 02:44:49 +00004058 [(set GR16:$dst, (atomic_load_min_16 addr:$ptr, GR16:$val))]>;
Dale Johannesen140be2d2008-08-19 18:47:28 +00004059def ATOMMAX16: I<0, Pseudo, (outs GR16:$dst),(ins i16mem:$ptr, GR16:$val),
Nick Lewycky6ecf5ce2008-12-07 03:49:52 +00004060 "#ATOMMAX16 PSEUDO!",
Dale Johannesene00a8a22008-08-28 02:44:49 +00004061 [(set GR16:$dst, (atomic_load_max_16 addr:$ptr, GR16:$val))]>;
Dale Johannesen140be2d2008-08-19 18:47:28 +00004062def ATOMUMIN16: I<0, Pseudo, (outs GR16:$dst),(ins i16mem:$ptr, GR16:$val),
Nick Lewycky6ecf5ce2008-12-07 03:49:52 +00004063 "#ATOMUMIN16 PSEUDO!",
Dale Johannesene00a8a22008-08-28 02:44:49 +00004064 [(set GR16:$dst, (atomic_load_umin_16 addr:$ptr, GR16:$val))]>;
Dale Johannesen140be2d2008-08-19 18:47:28 +00004065def ATOMUMAX16: I<0, Pseudo, (outs GR16:$dst),(ins i16mem:$ptr, GR16:$val),
Nick Lewycky6ecf5ce2008-12-07 03:49:52 +00004066 "#ATOMUMAX16 PSEUDO!",
Dale Johannesene00a8a22008-08-28 02:44:49 +00004067 [(set GR16:$dst, (atomic_load_umax_16 addr:$ptr, GR16:$val))]>;
Dale Johannesen140be2d2008-08-19 18:47:28 +00004068
4069def ATOMAND8 : I<0, Pseudo, (outs GR8:$dst),(ins i8mem:$ptr, GR8:$val),
Nick Lewycky6ecf5ce2008-12-07 03:49:52 +00004070 "#ATOMAND8 PSEUDO!",
Dale Johannesene00a8a22008-08-28 02:44:49 +00004071 [(set GR8:$dst, (atomic_load_and_8 addr:$ptr, GR8:$val))]>;
Dale Johannesen140be2d2008-08-19 18:47:28 +00004072def ATOMOR8 : I<0, Pseudo, (outs GR8:$dst),(ins i8mem:$ptr, GR8:$val),
Nick Lewycky6ecf5ce2008-12-07 03:49:52 +00004073 "#ATOMOR8 PSEUDO!",
Dale Johannesene00a8a22008-08-28 02:44:49 +00004074 [(set GR8:$dst, (atomic_load_or_8 addr:$ptr, GR8:$val))]>;
Dale Johannesen140be2d2008-08-19 18:47:28 +00004075def ATOMXOR8 : I<0, Pseudo,(outs GR8:$dst),(ins i8mem:$ptr, GR8:$val),
Nick Lewycky6ecf5ce2008-12-07 03:49:52 +00004076 "#ATOMXOR8 PSEUDO!",
Dale Johannesene00a8a22008-08-28 02:44:49 +00004077 [(set GR8:$dst, (atomic_load_xor_8 addr:$ptr, GR8:$val))]>;
Dale Johannesen140be2d2008-08-19 18:47:28 +00004078def ATOMNAND8 : I<0, Pseudo,(outs GR8:$dst),(ins i8mem:$ptr, GR8:$val),
Nick Lewycky6ecf5ce2008-12-07 03:49:52 +00004079 "#ATOMNAND8 PSEUDO!",
Dale Johannesene00a8a22008-08-28 02:44:49 +00004080 [(set GR8:$dst, (atomic_load_nand_8 addr:$ptr, GR8:$val))]>;
Mon P Wang63307c32008-05-05 19:05:59 +00004081}
4082
Dale Johannesen48c1bc22008-10-02 18:53:47 +00004083let Constraints = "$val1 = $dst1, $val2 = $dst2",
4084 Defs = [EFLAGS, EAX, EBX, ECX, EDX],
4085 Uses = [EAX, EBX, ECX, EDX],
Dale Johannesen1b54c7f2008-10-03 19:41:08 +00004086 mayLoad = 1, mayStore = 1,
Dan Gohman533297b2009-10-29 18:10:34 +00004087 usesCustomInserter = 1 in {
Dale Johannesen48c1bc22008-10-02 18:53:47 +00004088def ATOMAND6432 : I<0, Pseudo, (outs GR32:$dst1, GR32:$dst2),
4089 (ins i64mem:$ptr, GR32:$val1, GR32:$val2),
Nick Lewycky6ecf5ce2008-12-07 03:49:52 +00004090 "#ATOMAND6432 PSEUDO!", []>;
Dale Johannesen48c1bc22008-10-02 18:53:47 +00004091def ATOMOR6432 : I<0, Pseudo, (outs GR32:$dst1, GR32:$dst2),
4092 (ins i64mem:$ptr, GR32:$val1, GR32:$val2),
Nick Lewycky6ecf5ce2008-12-07 03:49:52 +00004093 "#ATOMOR6432 PSEUDO!", []>;
Dale Johannesen48c1bc22008-10-02 18:53:47 +00004094def ATOMXOR6432 : I<0, Pseudo, (outs GR32:$dst1, GR32:$dst2),
4095 (ins i64mem:$ptr, GR32:$val1, GR32:$val2),
Nick Lewycky6ecf5ce2008-12-07 03:49:52 +00004096 "#ATOMXOR6432 PSEUDO!", []>;
Dale Johannesen48c1bc22008-10-02 18:53:47 +00004097def ATOMNAND6432 : I<0, Pseudo, (outs GR32:$dst1, GR32:$dst2),
4098 (ins i64mem:$ptr, GR32:$val1, GR32:$val2),
Nick Lewycky6ecf5ce2008-12-07 03:49:52 +00004099 "#ATOMNAND6432 PSEUDO!", []>;
Dale Johannesen48c1bc22008-10-02 18:53:47 +00004100def ATOMADD6432 : I<0, Pseudo, (outs GR32:$dst1, GR32:$dst2),
4101 (ins i64mem:$ptr, GR32:$val1, GR32:$val2),
Nick Lewycky6ecf5ce2008-12-07 03:49:52 +00004102 "#ATOMADD6432 PSEUDO!", []>;
Dale Johannesen48c1bc22008-10-02 18:53:47 +00004103def ATOMSUB6432 : I<0, Pseudo, (outs GR32:$dst1, GR32:$dst2),
4104 (ins i64mem:$ptr, GR32:$val1, GR32:$val2),
Nick Lewycky6ecf5ce2008-12-07 03:49:52 +00004105 "#ATOMSUB6432 PSEUDO!", []>;
Dale Johannesen880ae362008-10-03 22:25:52 +00004106def ATOMSWAP6432 : I<0, Pseudo, (outs GR32:$dst1, GR32:$dst2),
4107 (ins i64mem:$ptr, GR32:$val1, GR32:$val2),
Nick Lewycky6ecf5ce2008-12-07 03:49:52 +00004108 "#ATOMSWAP6432 PSEUDO!", []>;
Dale Johannesen48c1bc22008-10-02 18:53:47 +00004109}
4110
Sean Callanan358f1ef2009-09-16 21:55:34 +00004111// Segmentation support instructions.
4112
4113def LAR16rm : I<0x02, MRMSrcMem, (outs GR16:$dst), (ins i16mem:$src),
4114 "lar{w}\t{$src, $dst|$dst, $src}", []>, TB, OpSize;
4115def LAR16rr : I<0x02, MRMSrcReg, (outs GR16:$dst), (ins GR16:$src),
4116 "lar{w}\t{$src, $dst|$dst, $src}", []>, TB, OpSize;
4117
4118// i16mem operand in LAR32rm and GR32 operand in LAR32rr is not a typo.
4119def LAR32rm : I<0x02, MRMSrcMem, (outs GR32:$dst), (ins i16mem:$src),
4120 "lar{l}\t{$src, $dst|$dst, $src}", []>, TB;
4121def LAR32rr : I<0x02, MRMSrcReg, (outs GR32:$dst), (ins GR32:$src),
4122 "lar{l}\t{$src, $dst|$dst, $src}", []>, TB;
Sean Callanan108934c2009-12-18 00:01:26 +00004123
4124def LSL16rm : I<0x03, MRMSrcMem, (outs GR16:$dst), (ins i16mem:$src),
4125 "lsl{w}\t{$src, $dst|$dst, $src}", []>, TB, OpSize;
4126def LSL16rr : I<0x03, MRMSrcReg, (outs GR16:$dst), (ins GR16:$src),
4127 "lsl{w}\t{$src, $dst|$dst, $src}", []>, TB, OpSize;
4128def LSL32rm : I<0x03, MRMSrcMem, (outs GR32:$dst), (ins i32mem:$src),
4129 "lsl{l}\t{$src, $dst|$dst, $src}", []>, TB;
4130def LSL32rr : I<0x03, MRMSrcReg, (outs GR32:$dst), (ins GR32:$src),
4131 "lsl{l}\t{$src, $dst|$dst, $src}", []>, TB;
4132
Sean Callanan95a5a7d2010-02-13 01:48:34 +00004133def INVLPG : I<0x01, MRM7m, (outs), (ins i8mem:$addr), "invlpg\t$addr", []>, TB;
Sean Callanan108934c2009-12-18 00:01:26 +00004134
4135def STRr : I<0x00, MRM1r, (outs GR16:$dst), (ins),
4136 "str{w}\t{$dst}", []>, TB;
4137def STRm : I<0x00, MRM1m, (outs i16mem:$dst), (ins),
4138 "str{w}\t{$dst}", []>, TB;
4139def LTRr : I<0x00, MRM3r, (outs), (ins GR16:$src),
4140 "ltr{w}\t{$src}", []>, TB;
4141def LTRm : I<0x00, MRM3m, (outs), (ins i16mem:$src),
4142 "ltr{w}\t{$src}", []>, TB;
4143
4144def PUSHFS16 : I<0xa0, RawFrm, (outs), (ins),
4145 "push{w}\t%fs", []>, OpSize, TB;
4146def PUSHFS32 : I<0xa0, RawFrm, (outs), (ins),
4147 "push{l}\t%fs", []>, TB;
4148def PUSHGS16 : I<0xa8, RawFrm, (outs), (ins),
4149 "push{w}\t%gs", []>, OpSize, TB;
4150def PUSHGS32 : I<0xa8, RawFrm, (outs), (ins),
4151 "push{l}\t%gs", []>, TB;
4152
4153def POPFS16 : I<0xa1, RawFrm, (outs), (ins),
4154 "pop{w}\t%fs", []>, OpSize, TB;
4155def POPFS32 : I<0xa1, RawFrm, (outs), (ins),
4156 "pop{l}\t%fs", []>, TB;
4157def POPGS16 : I<0xa9, RawFrm, (outs), (ins),
4158 "pop{w}\t%gs", []>, OpSize, TB;
4159def POPGS32 : I<0xa9, RawFrm, (outs), (ins),
4160 "pop{l}\t%gs", []>, TB;
4161
4162def LDS16rm : I<0xc5, MRMSrcMem, (outs GR16:$dst), (ins opaque32mem:$src),
4163 "lds{w}\t{$src, $dst|$dst, $src}", []>, OpSize;
4164def LDS32rm : I<0xc5, MRMSrcMem, (outs GR32:$dst), (ins opaque48mem:$src),
4165 "lds{l}\t{$src, $dst|$dst, $src}", []>;
4166def LSS16rm : I<0xb2, MRMSrcMem, (outs GR16:$dst), (ins opaque32mem:$src),
4167 "lss{w}\t{$src, $dst|$dst, $src}", []>, TB, OpSize;
4168def LSS32rm : I<0xb2, MRMSrcMem, (outs GR32:$dst), (ins opaque48mem:$src),
4169 "lss{l}\t{$src, $dst|$dst, $src}", []>, TB;
4170def LES16rm : I<0xc4, MRMSrcMem, (outs GR16:$dst), (ins opaque32mem:$src),
4171 "les{w}\t{$src, $dst|$dst, $src}", []>, OpSize;
4172def LES32rm : I<0xc4, MRMSrcMem, (outs GR32:$dst), (ins opaque48mem:$src),
4173 "les{l}\t{$src, $dst|$dst, $src}", []>;
4174def LFS16rm : I<0xb4, MRMSrcMem, (outs GR16:$dst), (ins opaque32mem:$src),
4175 "lfs{w}\t{$src, $dst|$dst, $src}", []>, TB, OpSize;
4176def LFS32rm : I<0xb4, MRMSrcMem, (outs GR32:$dst), (ins opaque48mem:$src),
4177 "lfs{l}\t{$src, $dst|$dst, $src}", []>, TB;
4178def LGS16rm : I<0xb5, MRMSrcMem, (outs GR16:$dst), (ins opaque32mem:$src),
4179 "lgs{w}\t{$src, $dst|$dst, $src}", []>, TB, OpSize;
4180def LGS32rm : I<0xb5, MRMSrcMem, (outs GR32:$dst), (ins opaque48mem:$src),
4181 "lgs{l}\t{$src, $dst|$dst, $src}", []>, TB;
4182
4183def VERRr : I<0x00, MRM4r, (outs), (ins GR16:$seg),
4184 "verr\t$seg", []>, TB;
4185def VERRm : I<0x00, MRM4m, (outs), (ins i16mem:$seg),
4186 "verr\t$seg", []>, TB;
4187def VERWr : I<0x00, MRM5r, (outs), (ins GR16:$seg),
4188 "verw\t$seg", []>, TB;
4189def VERWm : I<0x00, MRM5m, (outs), (ins i16mem:$seg),
4190 "verw\t$seg", []>, TB;
4191
4192// Descriptor-table support instructions
4193
4194def SGDTm : I<0x01, MRM0m, (outs opaque48mem:$dst), (ins),
4195 "sgdt\t$dst", []>, TB;
4196def SIDTm : I<0x01, MRM1m, (outs opaque48mem:$dst), (ins),
4197 "sidt\t$dst", []>, TB;
4198def SLDT16r : I<0x00, MRM0r, (outs GR16:$dst), (ins),
4199 "sldt{w}\t$dst", []>, TB;
4200def SLDT16m : I<0x00, MRM0m, (outs i16mem:$dst), (ins),
4201 "sldt{w}\t$dst", []>, TB;
4202def LGDTm : I<0x01, MRM2m, (outs), (ins opaque48mem:$src),
4203 "lgdt\t$src", []>, TB;
4204def LIDTm : I<0x01, MRM3m, (outs), (ins opaque48mem:$src),
4205 "lidt\t$src", []>, TB;
4206def LLDT16r : I<0x00, MRM2r, (outs), (ins GR16:$src),
4207 "lldt{w}\t$src", []>, TB;
4208def LLDT16m : I<0x00, MRM2m, (outs), (ins i16mem:$src),
4209 "lldt{w}\t$src", []>, TB;
Sean Callanan9a86f102009-09-16 22:59:28 +00004210
Kevin Enderby12ce0de2010-02-03 21:04:42 +00004211// Lock instruction prefix
4212def LOCK_PREFIX : I<0xF0, RawFrm, (outs), (ins), "lock", []>;
4213
4214// Repeat string operation instruction prefixes
4215// These uses the DF flag in the EFLAGS register to inc or dec ECX
4216let Defs = [ECX], Uses = [ECX,EFLAGS] in {
4217// Repeat (used with INS, OUTS, MOVS, LODS and STOS)
4218def REP_PREFIX : I<0xF3, RawFrm, (outs), (ins), "rep", []>;
4219// Repeat while not equal (used with CMPS and SCAS)
4220def REPNE_PREFIX : I<0xF2, RawFrm, (outs), (ins), "repne", []>;
4221}
4222
4223// Segment override instruction prefixes
4224def CS_PREFIX : I<0x2E, RawFrm, (outs), (ins), "cs", []>;
4225def SS_PREFIX : I<0x36, RawFrm, (outs), (ins), "ss", []>;
4226def DS_PREFIX : I<0x3E, RawFrm, (outs), (ins), "ds", []>;
4227def ES_PREFIX : I<0x26, RawFrm, (outs), (ins), "es", []>;
4228def FS_PREFIX : I<0x64, RawFrm, (outs), (ins), "fs", []>;
4229def GS_PREFIX : I<0x65, RawFrm, (outs), (ins), "gs", []>;
4230
Sean Callanan9a86f102009-09-16 22:59:28 +00004231// String manipulation instructions
4232
4233def LODSB : I<0xAC, RawFrm, (outs), (ins), "lodsb", []>;
4234def LODSW : I<0xAD, RawFrm, (outs), (ins), "lodsw", []>, OpSize;
Sean Callanan108934c2009-12-18 00:01:26 +00004235def LODSD : I<0xAD, RawFrm, (outs), (ins), "lods{l|d}", []>;
4236
4237def OUTSB : I<0x6E, RawFrm, (outs), (ins), "outsb", []>;
4238def OUTSW : I<0x6F, RawFrm, (outs), (ins), "outsw", []>, OpSize;
4239def OUTSD : I<0x6F, RawFrm, (outs), (ins), "outs{l|d}", []>;
4240
4241// CPU flow control instructions
4242
4243def HLT : I<0xF4, RawFrm, (outs), (ins), "hlt", []>;
4244def RSM : I<0xAA, RawFrm, (outs), (ins), "rsm", []>, TB;
4245
4246// FPU control instructions
4247
4248def FNINIT : I<0xE3, RawFrm, (outs), (ins), "fninit", []>, DB;
4249
4250// Flag instructions
4251
4252def CLC : I<0xF8, RawFrm, (outs), (ins), "clc", []>;
4253def STC : I<0xF9, RawFrm, (outs), (ins), "stc", []>;
4254def CLI : I<0xFA, RawFrm, (outs), (ins), "cli", []>;
4255def STI : I<0xFB, RawFrm, (outs), (ins), "sti", []>;
4256def CLD : I<0xFC, RawFrm, (outs), (ins), "cld", []>;
4257def STD : I<0xFD, RawFrm, (outs), (ins), "std", []>;
4258def CMC : I<0xF5, RawFrm, (outs), (ins), "cmc", []>;
4259
4260def CLTS : I<0x06, RawFrm, (outs), (ins), "clts", []>, TB;
4261
4262// Table lookup instructions
4263
4264def XLAT : I<0xD7, RawFrm, (outs), (ins), "xlatb", []>;
4265
4266// Specialized register support
4267
4268def WRMSR : I<0x30, RawFrm, (outs), (ins), "wrmsr", []>, TB;
4269def RDMSR : I<0x32, RawFrm, (outs), (ins), "rdmsr", []>, TB;
4270def RDPMC : I<0x33, RawFrm, (outs), (ins), "rdpmc", []>, TB;
4271
4272def SMSW16r : I<0x01, MRM4r, (outs GR16:$dst), (ins),
4273 "smsw{w}\t$dst", []>, OpSize, TB;
4274def SMSW32r : I<0x01, MRM4r, (outs GR32:$dst), (ins),
4275 "smsw{l}\t$dst", []>, TB;
4276// For memory operands, there is only a 16-bit form
4277def SMSW16m : I<0x01, MRM4m, (outs i16mem:$dst), (ins),
4278 "smsw{w}\t$dst", []>, TB;
4279
4280def LMSW16r : I<0x01, MRM6r, (outs), (ins GR16:$src),
4281 "lmsw{w}\t$src", []>, TB;
4282def LMSW16m : I<0x01, MRM6m, (outs), (ins i16mem:$src),
4283 "lmsw{w}\t$src", []>, TB;
4284
4285def CPUID : I<0xA2, RawFrm, (outs), (ins), "cpuid", []>, TB;
4286
4287// Cache instructions
4288
4289def INVD : I<0x08, RawFrm, (outs), (ins), "invd", []>, TB;
4290def WBINVD : I<0x09, RawFrm, (outs), (ins), "wbinvd", []>, TB;
4291
4292// VMX instructions
4293
4294// 66 0F 38 80
Sean Callanan95a5a7d2010-02-13 01:48:34 +00004295def INVEPT : I<0x80, RawFrm, (outs), (ins), "invept", []>, OpSize, T8;
Sean Callanan108934c2009-12-18 00:01:26 +00004296// 66 0F 38 81
Sean Callanan95a5a7d2010-02-13 01:48:34 +00004297def INVVPID : I<0x81, RawFrm, (outs), (ins), "invvpid", []>, OpSize, T8;
Sean Callanan108934c2009-12-18 00:01:26 +00004298// 0F 01 C1
Chris Lattnerfdfeb692010-02-12 20:49:41 +00004299def VMCALL : I<0x01, MRM_C1, (outs), (ins), "vmcall", []>, TB;
Sean Callanan108934c2009-12-18 00:01:26 +00004300def VMCLEARm : I<0xC7, MRM6m, (outs), (ins i64mem:$vmcs),
4301 "vmclear\t$vmcs", []>, OpSize, TB;
4302// 0F 01 C2
Chris Lattnera599de22010-02-13 00:41:14 +00004303def VMLAUNCH : I<0x01, MRM_C2, (outs), (ins), "vmlaunch", []>, TB;
Sean Callanan108934c2009-12-18 00:01:26 +00004304// 0F 01 C3
Chris Lattnera599de22010-02-13 00:41:14 +00004305def VMRESUME : I<0x01, MRM_C3, (outs), (ins), "vmresume", []>, TB;
Sean Callanan108934c2009-12-18 00:01:26 +00004306def VMPTRLDm : I<0xC7, MRM6m, (outs), (ins i64mem:$vmcs),
4307 "vmptrld\t$vmcs", []>, TB;
4308def VMPTRSTm : I<0xC7, MRM7m, (outs i64mem:$vmcs), (ins),
4309 "vmptrst\t$vmcs", []>, TB;
4310def VMREAD64rm : I<0x78, MRMDestMem, (outs i64mem:$dst), (ins GR64:$src),
4311 "vmread{q}\t{$src, $dst|$dst, $src}", []>, TB;
4312def VMREAD64rr : I<0x78, MRMDestReg, (outs GR64:$dst), (ins GR64:$src),
4313 "vmread{q}\t{$src, $dst|$dst, $src}", []>, TB;
4314def VMREAD32rm : I<0x78, MRMDestMem, (outs i32mem:$dst), (ins GR32:$src),
4315 "vmread{l}\t{$src, $dst|$dst, $src}", []>, TB;
4316def VMREAD32rr : I<0x78, MRMDestReg, (outs GR32:$dst), (ins GR32:$src),
4317 "vmread{l}\t{$src, $dst|$dst, $src}", []>, TB;
4318def VMWRITE64rm : I<0x79, MRMSrcMem, (outs GR64:$dst), (ins i64mem:$src),
4319 "vmwrite{q}\t{$src, $dst|$dst, $src}", []>, TB;
4320def VMWRITE64rr : I<0x79, MRMSrcReg, (outs GR64:$dst), (ins GR64:$src),
4321 "vmwrite{q}\t{$src, $dst|$dst, $src}", []>, TB;
4322def VMWRITE32rm : I<0x79, MRMSrcMem, (outs GR32:$dst), (ins i32mem:$src),
4323 "vmwrite{l}\t{$src, $dst|$dst, $src}", []>, TB;
4324def VMWRITE32rr : I<0x79, MRMSrcReg, (outs GR32:$dst), (ins GR32:$src),
4325 "vmwrite{l}\t{$src, $dst|$dst, $src}", []>, TB;
4326// 0F 01 C4
Chris Lattnera599de22010-02-13 00:41:14 +00004327def VMXOFF : I<0x01, MRM_C4, (outs), (ins), "vmxoff", []>, TB;
Sean Callanan108934c2009-12-18 00:01:26 +00004328def VMXON : I<0xC7, MRM6m, (outs), (ins i64mem:$vmxon),
Kevin Enderby0e822402010-03-08 22:17:26 +00004329 "vmxon\t{$vmxon}", []>, XS;
Sean Callanan358f1ef2009-09-16 21:55:34 +00004330
Andrew Lenharthab0b9492008-02-21 06:45:13 +00004331//===----------------------------------------------------------------------===//
Evan Cheng510e4782006-01-09 23:10:28 +00004332// Non-Instruction Patterns
4333//===----------------------------------------------------------------------===//
4334
Bill Wendling056292f2008-09-16 21:48:12 +00004335// ConstantPool GlobalAddress, ExternalSymbol, and JumpTable
Evan Cheng71fb8342006-02-25 10:02:21 +00004336def : Pat<(i32 (X86Wrapper tconstpool :$dst)), (MOV32ri tconstpool :$dst)>;
Nate Begeman37efe672006-04-22 18:53:45 +00004337def : Pat<(i32 (X86Wrapper tjumptable :$dst)), (MOV32ri tjumptable :$dst)>;
Nate Begeman6795ebb2008-04-12 00:47:57 +00004338def : Pat<(i32 (X86Wrapper tglobaltlsaddr:$dst)),(MOV32ri tglobaltlsaddr:$dst)>;
Evan Cheng71fb8342006-02-25 10:02:21 +00004339def : Pat<(i32 (X86Wrapper tglobaladdr :$dst)), (MOV32ri tglobaladdr :$dst)>;
4340def : Pat<(i32 (X86Wrapper texternalsym:$dst)), (MOV32ri texternalsym:$dst)>;
Dan Gohmanf705adb2009-10-30 01:28:02 +00004341def : Pat<(i32 (X86Wrapper tblockaddress:$dst)), (MOV32ri tblockaddress:$dst)>;
Evan Cheng71fb8342006-02-25 10:02:21 +00004342
Evan Cheng069287d2006-05-16 07:21:53 +00004343def : Pat<(add GR32:$src1, (X86Wrapper tconstpool:$src2)),
4344 (ADD32ri GR32:$src1, tconstpool:$src2)>;
4345def : Pat<(add GR32:$src1, (X86Wrapper tjumptable:$src2)),
4346 (ADD32ri GR32:$src1, tjumptable:$src2)>;
4347def : Pat<(add GR32:$src1, (X86Wrapper tglobaladdr :$src2)),
4348 (ADD32ri GR32:$src1, tglobaladdr:$src2)>;
4349def : Pat<(add GR32:$src1, (X86Wrapper texternalsym:$src2)),
4350 (ADD32ri GR32:$src1, texternalsym:$src2)>;
Dan Gohmanf705adb2009-10-30 01:28:02 +00004351def : Pat<(add GR32:$src1, (X86Wrapper tblockaddress:$src2)),
4352 (ADD32ri GR32:$src1, tblockaddress:$src2)>;
Evan Cheng71fb8342006-02-25 10:02:21 +00004353
Evan Chengfc8feb12006-05-19 07:30:36 +00004354def : Pat<(store (i32 (X86Wrapper tglobaladdr:$src)), addr:$dst),
Evan Cheng71fb8342006-02-25 10:02:21 +00004355 (MOV32mi addr:$dst, tglobaladdr:$src)>;
Evan Chengfc8feb12006-05-19 07:30:36 +00004356def : Pat<(store (i32 (X86Wrapper texternalsym:$src)), addr:$dst),
Evan Cheng71fb8342006-02-25 10:02:21 +00004357 (MOV32mi addr:$dst, texternalsym:$src)>;
Dan Gohmanf705adb2009-10-30 01:28:02 +00004358def : Pat<(store (i32 (X86Wrapper tblockaddress:$src)), addr:$dst),
4359 (MOV32mi addr:$dst, tblockaddress:$src)>;
Evan Cheng71fb8342006-02-25 10:02:21 +00004360
Evan Cheng510e4782006-01-09 23:10:28 +00004361// Calls
Arnold Schwaighoferc85e1712007-10-11 19:40:01 +00004362// tailcall stuff
Evan Chengf48ef032010-03-14 03:48:46 +00004363def : Pat<(X86tcret GR32_TC:$dst, imm:$off),
4364 (TCRETURNri GR32_TC:$dst, imm:$off)>,
4365 Requires<[In32BitMode]>;
4366
Evan Chengcb0f06e2010-03-25 00:10:31 +00004367// FIXME: This is disabled for 32-bit PIC mode because the global base
4368// register which is part of the address mode may be assigned a
4369// callee-saved register.
Evan Chengf48ef032010-03-14 03:48:46 +00004370def : Pat<(X86tcret (load addr:$dst), imm:$off),
4371 (TCRETURNmi addr:$dst, imm:$off)>,
Evan Chengcb0f06e2010-03-25 00:10:31 +00004372 Requires<[In32BitMode, IsNotPIC]>;
Arnold Schwaighoferc85e1712007-10-11 19:40:01 +00004373
4374def : Pat<(X86tcret (i32 tglobaladdr:$dst), imm:$off),
Evan Chengf48ef032010-03-14 03:48:46 +00004375 (TCRETURNdi texternalsym:$dst, imm:$off)>,
4376 Requires<[In32BitMode]>;
Arnold Schwaighoferc85e1712007-10-11 19:40:01 +00004377
4378def : Pat<(X86tcret (i32 texternalsym:$dst), imm:$off),
Evan Chengf48ef032010-03-14 03:48:46 +00004379 (TCRETURNdi texternalsym:$dst, imm:$off)>,
4380 Requires<[In32BitMode]>;
Evan Chengfea89c12006-04-27 08:40:39 +00004381
Dan Gohmancadb2262009-08-02 16:10:01 +00004382// Normal calls, with various flavors of addresses.
Evan Cheng25ab6902006-09-08 06:48:29 +00004383def : Pat<(X86call (i32 tglobaladdr:$dst)),
Evan Cheng510e4782006-01-09 23:10:28 +00004384 (CALLpcrel32 tglobaladdr:$dst)>;
Evan Cheng25ab6902006-09-08 06:48:29 +00004385def : Pat<(X86call (i32 texternalsym:$dst)),
Evan Cheng8700e142006-01-11 06:09:51 +00004386 (CALLpcrel32 texternalsym:$dst)>;
Evan Chengd7f666a2009-05-20 04:53:57 +00004387def : Pat<(X86call (i32 imm:$dst)),
4388 (CALLpcrel32 imm:$dst)>, Requires<[CallImmAddr]>;
Evan Cheng510e4782006-01-09 23:10:28 +00004389
4390// X86 specific add which produces a flag.
Evan Cheng069287d2006-05-16 07:21:53 +00004391def : Pat<(addc GR32:$src1, GR32:$src2),
4392 (ADD32rr GR32:$src1, GR32:$src2)>;
4393def : Pat<(addc GR32:$src1, (load addr:$src2)),
4394 (ADD32rm GR32:$src1, addr:$src2)>;
4395def : Pat<(addc GR32:$src1, imm:$src2),
4396 (ADD32ri GR32:$src1, imm:$src2)>;
4397def : Pat<(addc GR32:$src1, i32immSExt8:$src2),
4398 (ADD32ri8 GR32:$src1, i32immSExt8:$src2)>;
Evan Cheng510e4782006-01-09 23:10:28 +00004399
Evan Cheng069287d2006-05-16 07:21:53 +00004400def : Pat<(subc GR32:$src1, GR32:$src2),
4401 (SUB32rr GR32:$src1, GR32:$src2)>;
4402def : Pat<(subc GR32:$src1, (load addr:$src2)),
4403 (SUB32rm GR32:$src1, addr:$src2)>;
4404def : Pat<(subc GR32:$src1, imm:$src2),
4405 (SUB32ri GR32:$src1, imm:$src2)>;
4406def : Pat<(subc GR32:$src1, i32immSExt8:$src2),
4407 (SUB32ri8 GR32:$src1, i32immSExt8:$src2)>;
Evan Cheng510e4782006-01-09 23:10:28 +00004408
Chris Lattnerffc0b262006-09-07 20:33:45 +00004409// Comparisons.
4410
4411// TEST R,R is smaller than CMP R,0
Chris Lattnere3486a42010-03-19 00:01:11 +00004412def : Pat<(X86cmp GR8:$src1, 0),
Chris Lattnerffc0b262006-09-07 20:33:45 +00004413 (TEST8rr GR8:$src1, GR8:$src1)>;
Chris Lattnere3486a42010-03-19 00:01:11 +00004414def : Pat<(X86cmp GR16:$src1, 0),
Chris Lattnerffc0b262006-09-07 20:33:45 +00004415 (TEST16rr GR16:$src1, GR16:$src1)>;
Chris Lattnere3486a42010-03-19 00:01:11 +00004416def : Pat<(X86cmp GR32:$src1, 0),
Chris Lattnerffc0b262006-09-07 20:33:45 +00004417 (TEST32rr GR32:$src1, GR32:$src1)>;
4418
Dan Gohmanfbb74862009-01-07 01:00:24 +00004419// Conditional moves with folded loads with operands swapped and conditions
4420// inverted.
4421def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_B, EFLAGS),
4422 (CMOVAE16rm GR16:$src2, addr:$src1)>;
4423def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_B, EFLAGS),
4424 (CMOVAE32rm GR32:$src2, addr:$src1)>;
4425def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_AE, EFLAGS),
4426 (CMOVB16rm GR16:$src2, addr:$src1)>;
4427def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_AE, EFLAGS),
4428 (CMOVB32rm GR32:$src2, addr:$src1)>;
4429def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_E, EFLAGS),
4430 (CMOVNE16rm GR16:$src2, addr:$src1)>;
4431def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_E, EFLAGS),
4432 (CMOVNE32rm GR32:$src2, addr:$src1)>;
4433def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_NE, EFLAGS),
4434 (CMOVE16rm GR16:$src2, addr:$src1)>;
4435def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_NE, EFLAGS),
4436 (CMOVE32rm GR32:$src2, addr:$src1)>;
4437def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_BE, EFLAGS),
4438 (CMOVA16rm GR16:$src2, addr:$src1)>;
4439def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_BE, EFLAGS),
4440 (CMOVA32rm GR32:$src2, addr:$src1)>;
4441def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_A, EFLAGS),
4442 (CMOVBE16rm GR16:$src2, addr:$src1)>;
4443def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_A, EFLAGS),
4444 (CMOVBE32rm GR32:$src2, addr:$src1)>;
4445def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_L, EFLAGS),
4446 (CMOVGE16rm GR16:$src2, addr:$src1)>;
4447def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_L, EFLAGS),
4448 (CMOVGE32rm GR32:$src2, addr:$src1)>;
4449def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_GE, EFLAGS),
4450 (CMOVL16rm GR16:$src2, addr:$src1)>;
4451def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_GE, EFLAGS),
4452 (CMOVL32rm GR32:$src2, addr:$src1)>;
4453def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_LE, EFLAGS),
4454 (CMOVG16rm GR16:$src2, addr:$src1)>;
4455def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_LE, EFLAGS),
4456 (CMOVG32rm GR32:$src2, addr:$src1)>;
4457def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_G, EFLAGS),
4458 (CMOVLE16rm GR16:$src2, addr:$src1)>;
4459def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_G, EFLAGS),
4460 (CMOVLE32rm GR32:$src2, addr:$src1)>;
4461def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_P, EFLAGS),
4462 (CMOVNP16rm GR16:$src2, addr:$src1)>;
4463def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_P, EFLAGS),
4464 (CMOVNP32rm GR32:$src2, addr:$src1)>;
4465def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_NP, EFLAGS),
4466 (CMOVP16rm GR16:$src2, addr:$src1)>;
4467def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_NP, EFLAGS),
4468 (CMOVP32rm GR32:$src2, addr:$src1)>;
4469def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_S, EFLAGS),
4470 (CMOVNS16rm GR16:$src2, addr:$src1)>;
4471def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_S, EFLAGS),
4472 (CMOVNS32rm GR32:$src2, addr:$src1)>;
4473def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_NS, EFLAGS),
4474 (CMOVS16rm GR16:$src2, addr:$src1)>;
4475def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_NS, EFLAGS),
4476 (CMOVS32rm GR32:$src2, addr:$src1)>;
4477def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_O, EFLAGS),
4478 (CMOVNO16rm GR16:$src2, addr:$src1)>;
4479def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_O, EFLAGS),
4480 (CMOVNO32rm GR32:$src2, addr:$src1)>;
4481def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_NO, EFLAGS),
4482 (CMOVO16rm GR16:$src2, addr:$src1)>;
4483def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_NO, EFLAGS),
4484 (CMOVO32rm GR32:$src2, addr:$src1)>;
4485
Duncan Sandsf9c98e62008-01-23 20:39:46 +00004486// zextload bool -> zextload byte
Evan Chenge5d93432006-01-17 07:02:46 +00004487def : Pat<(zextloadi8i1 addr:$src), (MOV8rm addr:$src)>;
Evan Cheng510e4782006-01-09 23:10:28 +00004488def : Pat<(zextloadi16i1 addr:$src), (MOVZX16rm8 addr:$src)>;
4489def : Pat<(zextloadi32i1 addr:$src), (MOVZX32rm8 addr:$src)>;
4490
4491// extload bool -> extload byte
Evan Cheng47137242006-05-05 08:23:07 +00004492def : Pat<(extloadi8i1 addr:$src), (MOV8rm addr:$src)>;
Dan Gohmanaf70e5c2009-08-26 14:59:13 +00004493def : Pat<(extloadi16i1 addr:$src), (MOVZX16rm8 addr:$src)>;
Evan Cheng47137242006-05-05 08:23:07 +00004494def : Pat<(extloadi32i1 addr:$src), (MOVZX32rm8 addr:$src)>;
Dan Gohmanaf70e5c2009-08-26 14:59:13 +00004495def : Pat<(extloadi16i8 addr:$src), (MOVZX16rm8 addr:$src)>;
Evan Cheng47137242006-05-05 08:23:07 +00004496def : Pat<(extloadi32i8 addr:$src), (MOVZX32rm8 addr:$src)>;
4497def : Pat<(extloadi32i16 addr:$src), (MOVZX32rm16 addr:$src)>;
Evan Cheng510e4782006-01-09 23:10:28 +00004498
Dan Gohmanaf70e5c2009-08-26 14:59:13 +00004499// anyext. Define these to do an explicit zero-extend to
4500// avoid partial-register updates.
4501def : Pat<(i16 (anyext GR8 :$src)), (MOVZX16rr8 GR8 :$src)>;
4502def : Pat<(i32 (anyext GR8 :$src)), (MOVZX32rr8 GR8 :$src)>;
Evan Cheng5528e7b2010-04-21 01:47:12 +00004503
Evan Cheng2bce5f4b2010-04-28 08:30:49 +00004504// Except for i16 -> i32 since isel expect i16 ops to be promoted to i32.
Evan Cheng5528e7b2010-04-21 01:47:12 +00004505def : Pat<(i32 (anyext GR16:$src)),
Evan Cheng2bce5f4b2010-04-28 08:30:49 +00004506 (INSERT_SUBREG (i32 (IMPLICIT_DEF)), GR16:$src, x86_subreg_16bit)>;
Evan Cheng5528e7b2010-04-21 01:47:12 +00004507
Evan Cheng510e4782006-01-09 23:10:28 +00004508
Evan Chengcfa260b2006-01-06 02:31:59 +00004509//===----------------------------------------------------------------------===//
4510// Some peepholes
4511//===----------------------------------------------------------------------===//
4512
Dan Gohman63f97202008-10-17 01:33:43 +00004513// Odd encoding trick: -128 fits into an 8-bit immediate field while
4514// +128 doesn't, so in this special case use a sub instead of an add.
4515def : Pat<(add GR16:$src1, 128),
4516 (SUB16ri8 GR16:$src1, -128)>;
4517def : Pat<(store (add (loadi16 addr:$dst), 128), addr:$dst),
4518 (SUB16mi8 addr:$dst, -128)>;
4519def : Pat<(add GR32:$src1, 128),
4520 (SUB32ri8 GR32:$src1, -128)>;
4521def : Pat<(store (add (loadi32 addr:$dst), 128), addr:$dst),
4522 (SUB32mi8 addr:$dst, -128)>;
4523
Dan Gohman11ba3b12008-07-30 18:09:17 +00004524// r & (2^16-1) ==> movz
4525def : Pat<(and GR32:$src1, 0xffff),
Dan Gohman21e3dfb2009-04-13 16:09:41 +00004526 (MOVZX32rr16 (EXTRACT_SUBREG GR32:$src1, x86_subreg_16bit))>;
Dan Gohman8a1510d2008-08-06 18:27:21 +00004527// r & (2^8-1) ==> movz
4528def : Pat<(and GR32:$src1, 0xff),
Anton Korobeynikov3a639a02009-11-02 00:11:39 +00004529 (MOVZX32rr8 (EXTRACT_SUBREG (i32 (COPY_TO_REGCLASS GR32:$src1,
4530 GR32_ABCD)),
Dan Gohman21e3dfb2009-04-13 16:09:41 +00004531 x86_subreg_8bit))>,
Dan Gohman8a1510d2008-08-06 18:27:21 +00004532 Requires<[In32BitMode]>;
4533// r & (2^8-1) ==> movz
4534def : Pat<(and GR16:$src1, 0xff),
Anton Korobeynikov3a639a02009-11-02 00:11:39 +00004535 (MOVZX16rr8 (EXTRACT_SUBREG (i16 (COPY_TO_REGCLASS GR16:$src1,
4536 GR16_ABCD)),
Dan Gohman21e3dfb2009-04-13 16:09:41 +00004537 x86_subreg_8bit))>,
Dan Gohman0bfa1bf2008-08-20 21:27:32 +00004538 Requires<[In32BitMode]>;
4539
4540// sext_inreg patterns
4541def : Pat<(sext_inreg GR32:$src, i16),
Dan Gohman21e3dfb2009-04-13 16:09:41 +00004542 (MOVSX32rr16 (EXTRACT_SUBREG GR32:$src, x86_subreg_16bit))>;
Dan Gohman0bfa1bf2008-08-20 21:27:32 +00004543def : Pat<(sext_inreg GR32:$src, i8),
Anton Korobeynikov3a639a02009-11-02 00:11:39 +00004544 (MOVSX32rr8 (EXTRACT_SUBREG (i32 (COPY_TO_REGCLASS GR32:$src,
4545 GR32_ABCD)),
Dan Gohman21e3dfb2009-04-13 16:09:41 +00004546 x86_subreg_8bit))>,
Dan Gohman0bfa1bf2008-08-20 21:27:32 +00004547 Requires<[In32BitMode]>;
4548def : Pat<(sext_inreg GR16:$src, i8),
Anton Korobeynikov3a639a02009-11-02 00:11:39 +00004549 (MOVSX16rr8 (EXTRACT_SUBREG (i16 (COPY_TO_REGCLASS GR16:$src,
4550 GR16_ABCD)),
Dan Gohman21e3dfb2009-04-13 16:09:41 +00004551 x86_subreg_8bit))>,
Dan Gohman0bfa1bf2008-08-20 21:27:32 +00004552 Requires<[In32BitMode]>;
4553
4554// trunc patterns
4555def : Pat<(i16 (trunc GR32:$src)),
Dan Gohman21e3dfb2009-04-13 16:09:41 +00004556 (EXTRACT_SUBREG GR32:$src, x86_subreg_16bit)>;
Dan Gohman0bfa1bf2008-08-20 21:27:32 +00004557def : Pat<(i8 (trunc GR32:$src)),
Anton Korobeynikov3a639a02009-11-02 00:11:39 +00004558 (EXTRACT_SUBREG (i32 (COPY_TO_REGCLASS GR32:$src, GR32_ABCD)),
Dan Gohman21e3dfb2009-04-13 16:09:41 +00004559 x86_subreg_8bit)>,
Dan Gohman0bfa1bf2008-08-20 21:27:32 +00004560 Requires<[In32BitMode]>;
4561def : Pat<(i8 (trunc GR16:$src)),
Anton Korobeynikov3a639a02009-11-02 00:11:39 +00004562 (EXTRACT_SUBREG (i16 (COPY_TO_REGCLASS GR16:$src, GR16_ABCD)),
Dan Gohman21e3dfb2009-04-13 16:09:41 +00004563 x86_subreg_8bit)>,
4564 Requires<[In32BitMode]>;
4565
4566// h-register tricks
4567def : Pat<(i8 (trunc (srl_su GR16:$src, (i8 8)))),
Evan Cheng1c45acf2010-04-27 21:46:03 +00004568 (EXTRACT_SUBREG (i16 (COPY_TO_REGCLASS GR16:$src, GR16_ABCD)),
Dan Gohman21e3dfb2009-04-13 16:09:41 +00004569 x86_subreg_8bit_hi)>,
4570 Requires<[In32BitMode]>;
4571def : Pat<(i8 (trunc (srl_su GR32:$src, (i8 8)))),
Evan Cheng1c45acf2010-04-27 21:46:03 +00004572 (EXTRACT_SUBREG (i32 (COPY_TO_REGCLASS GR32:$src, GR32_ABCD)),
Dan Gohman21e3dfb2009-04-13 16:09:41 +00004573 x86_subreg_8bit_hi)>,
4574 Requires<[In32BitMode]>;
Dan Gohman7e0d64a2010-01-11 17:21:05 +00004575def : Pat<(srl GR16:$src, (i8 8)),
Dan Gohman21e3dfb2009-04-13 16:09:41 +00004576 (EXTRACT_SUBREG
4577 (MOVZX32rr8
Anton Korobeynikov3a639a02009-11-02 00:11:39 +00004578 (EXTRACT_SUBREG (i16 (COPY_TO_REGCLASS GR16:$src, GR16_ABCD)),
Dan Gohman21e3dfb2009-04-13 16:09:41 +00004579 x86_subreg_8bit_hi)),
4580 x86_subreg_16bit)>,
4581 Requires<[In32BitMode]>;
Evan Chengcb219f02009-05-29 01:44:43 +00004582def : Pat<(i32 (zext (srl_su GR16:$src, (i8 8)))),
Sean Callanan108934c2009-12-18 00:01:26 +00004583 (MOVZX32rr8 (EXTRACT_SUBREG (i16 (COPY_TO_REGCLASS GR16:$src,
4584 GR16_ABCD)),
Evan Chengcb219f02009-05-29 01:44:43 +00004585 x86_subreg_8bit_hi))>,
4586 Requires<[In32BitMode]>;
Dan Gohmanaf70e5c2009-08-26 14:59:13 +00004587def : Pat<(i32 (anyext (srl_su GR16:$src, (i8 8)))),
Sean Callanan108934c2009-12-18 00:01:26 +00004588 (MOVZX32rr8 (EXTRACT_SUBREG (i16 (COPY_TO_REGCLASS GR16:$src,
4589 GR16_ABCD)),
Dan Gohmanaf70e5c2009-08-26 14:59:13 +00004590 x86_subreg_8bit_hi))>,
4591 Requires<[In32BitMode]>;
Dan Gohman21e3dfb2009-04-13 16:09:41 +00004592def : Pat<(and (srl_su GR32:$src, (i8 8)), (i32 255)),
Sean Callanan108934c2009-12-18 00:01:26 +00004593 (MOVZX32rr8 (EXTRACT_SUBREG (i32 (COPY_TO_REGCLASS GR32:$src,
4594 GR32_ABCD)),
Dan Gohman21e3dfb2009-04-13 16:09:41 +00004595 x86_subreg_8bit_hi))>,
Dan Gohman8a1510d2008-08-06 18:27:21 +00004596 Requires<[In32BitMode]>;
Evan Cheng2bce5f4b2010-04-28 08:30:49 +00004597def : Pat<(srl (and_su GR32:$src, 0xff00), (i8 8)),
4598 (MOVZX32rr8 (EXTRACT_SUBREG (i32 (COPY_TO_REGCLASS GR32:$src,
4599 GR32_ABCD)),
4600 x86_subreg_8bit_hi))>,
4601 Requires<[In32BitMode]>;
Dan Gohman11ba3b12008-07-30 18:09:17 +00004602
Evan Chengcfa260b2006-01-06 02:31:59 +00004603// (shl x, 1) ==> (add x, x)
Evan Cheng069287d2006-05-16 07:21:53 +00004604def : Pat<(shl GR8 :$src1, (i8 1)), (ADD8rr GR8 :$src1, GR8 :$src1)>;
4605def : Pat<(shl GR16:$src1, (i8 1)), (ADD16rr GR16:$src1, GR16:$src1)>;
4606def : Pat<(shl GR32:$src1, (i8 1)), (ADD32rr GR32:$src1, GR32:$src1)>;
Evan Cheng68b951a2006-01-19 01:56:29 +00004607
Evan Chengeb9f8922008-08-30 02:03:58 +00004608// (shl x (and y, 31)) ==> (shl x, y)
Chris Lattner6d9f86b2010-02-23 06:54:29 +00004609def : Pat<(shl GR8:$src1, (and CL, 31)),
Evan Chengeb9f8922008-08-30 02:03:58 +00004610 (SHL8rCL GR8:$src1)>;
Chris Lattner6d9f86b2010-02-23 06:54:29 +00004611def : Pat<(shl GR16:$src1, (and CL, 31)),
Evan Chengeb9f8922008-08-30 02:03:58 +00004612 (SHL16rCL GR16:$src1)>;
Chris Lattner6d9f86b2010-02-23 06:54:29 +00004613def : Pat<(shl GR32:$src1, (and CL, 31)),
Evan Chengeb9f8922008-08-30 02:03:58 +00004614 (SHL32rCL GR32:$src1)>;
Chris Lattner6d9f86b2010-02-23 06:54:29 +00004615def : Pat<(store (shl (loadi8 addr:$dst), (and CL, 31)), addr:$dst),
Evan Chengeb9f8922008-08-30 02:03:58 +00004616 (SHL8mCL addr:$dst)>;
Chris Lattner6d9f86b2010-02-23 06:54:29 +00004617def : Pat<(store (shl (loadi16 addr:$dst), (and CL, 31)), addr:$dst),
Evan Chengeb9f8922008-08-30 02:03:58 +00004618 (SHL16mCL addr:$dst)>;
Chris Lattner6d9f86b2010-02-23 06:54:29 +00004619def : Pat<(store (shl (loadi32 addr:$dst), (and CL, 31)), addr:$dst),
Evan Chengeb9f8922008-08-30 02:03:58 +00004620 (SHL32mCL addr:$dst)>;
4621
Chris Lattner6d9f86b2010-02-23 06:54:29 +00004622def : Pat<(srl GR8:$src1, (and CL, 31)),
Evan Chengeb9f8922008-08-30 02:03:58 +00004623 (SHR8rCL GR8:$src1)>;
Chris Lattner6d9f86b2010-02-23 06:54:29 +00004624def : Pat<(srl GR16:$src1, (and CL, 31)),
Evan Chengeb9f8922008-08-30 02:03:58 +00004625 (SHR16rCL GR16:$src1)>;
Chris Lattner6d9f86b2010-02-23 06:54:29 +00004626def : Pat<(srl GR32:$src1, (and CL, 31)),
Evan Chengeb9f8922008-08-30 02:03:58 +00004627 (SHR32rCL GR32:$src1)>;
Chris Lattner6d9f86b2010-02-23 06:54:29 +00004628def : Pat<(store (srl (loadi8 addr:$dst), (and CL, 31)), addr:$dst),
Evan Chengeb9f8922008-08-30 02:03:58 +00004629 (SHR8mCL addr:$dst)>;
Chris Lattner6d9f86b2010-02-23 06:54:29 +00004630def : Pat<(store (srl (loadi16 addr:$dst), (and CL, 31)), addr:$dst),
Evan Chengeb9f8922008-08-30 02:03:58 +00004631 (SHR16mCL addr:$dst)>;
Chris Lattner6d9f86b2010-02-23 06:54:29 +00004632def : Pat<(store (srl (loadi32 addr:$dst), (and CL, 31)), addr:$dst),
Evan Chengeb9f8922008-08-30 02:03:58 +00004633 (SHR32mCL addr:$dst)>;
4634
Chris Lattner6d9f86b2010-02-23 06:54:29 +00004635def : Pat<(sra GR8:$src1, (and CL, 31)),
Evan Chengeb9f8922008-08-30 02:03:58 +00004636 (SAR8rCL GR8:$src1)>;
Chris Lattner6d9f86b2010-02-23 06:54:29 +00004637def : Pat<(sra GR16:$src1, (and CL, 31)),
Evan Chengeb9f8922008-08-30 02:03:58 +00004638 (SAR16rCL GR16:$src1)>;
Chris Lattner6d9f86b2010-02-23 06:54:29 +00004639def : Pat<(sra GR32:$src1, (and CL, 31)),
Evan Chengeb9f8922008-08-30 02:03:58 +00004640 (SAR32rCL GR32:$src1)>;
Chris Lattner6d9f86b2010-02-23 06:54:29 +00004641def : Pat<(store (sra (loadi8 addr:$dst), (and CL, 31)), addr:$dst),
Evan Chengeb9f8922008-08-30 02:03:58 +00004642 (SAR8mCL addr:$dst)>;
Chris Lattner6d9f86b2010-02-23 06:54:29 +00004643def : Pat<(store (sra (loadi16 addr:$dst), (and CL, 31)), addr:$dst),
Evan Chengeb9f8922008-08-30 02:03:58 +00004644 (SAR16mCL addr:$dst)>;
Chris Lattner6d9f86b2010-02-23 06:54:29 +00004645def : Pat<(store (sra (loadi32 addr:$dst), (and CL, 31)), addr:$dst),
Evan Chengeb9f8922008-08-30 02:03:58 +00004646 (SAR32mCL addr:$dst)>;
4647
Evan Cheng2e489c42009-12-16 00:53:11 +00004648// (anyext (setcc_carry)) -> (setcc_carry)
4649def : Pat<(i16 (anyext (i8 (X86setcc_c X86_COND_B, EFLAGS)))),
Evan Chengad9c0a32009-12-15 00:53:42 +00004650 (SETB_C16r)>;
Evan Cheng2e489c42009-12-16 00:53:11 +00004651def : Pat<(i32 (anyext (i8 (X86setcc_c X86_COND_B, EFLAGS)))),
Evan Chengad9c0a32009-12-15 00:53:42 +00004652 (SETB_C32r)>;
Evan Chenge5b51ac2010-04-17 06:13:15 +00004653def : Pat<(i32 (anyext (i16 (X86setcc_c X86_COND_B, EFLAGS)))),
4654 (SETB_C32r)>;
Evan Chengad9c0a32009-12-15 00:53:42 +00004655
Evan Cheng199c4242010-01-11 22:03:29 +00004656// (or x1, x2) -> (add x1, x2) if two operands are known not to share bits.
Evan Cheng3bda2012010-01-12 18:31:19 +00004657let AddedComplexity = 5 in { // Try this before the selecting to OR
Chris Lattnera0f70172010-03-24 00:15:23 +00004658def : Pat<(or_is_add GR16:$src1, imm:$src2),
Evan Cheng4b0345b2010-01-11 17:03:47 +00004659 (ADD16ri GR16:$src1, imm:$src2)>;
Chris Lattnera0f70172010-03-24 00:15:23 +00004660def : Pat<(or_is_add GR32:$src1, imm:$src2),
Evan Cheng4b0345b2010-01-11 17:03:47 +00004661 (ADD32ri GR32:$src1, imm:$src2)>;
Chris Lattnera0f70172010-03-24 00:15:23 +00004662def : Pat<(or_is_add GR16:$src1, i16immSExt8:$src2),
Evan Cheng4b0345b2010-01-11 17:03:47 +00004663 (ADD16ri8 GR16:$src1, i16immSExt8:$src2)>;
Chris Lattnera0f70172010-03-24 00:15:23 +00004664def : Pat<(or_is_add GR32:$src1, i32immSExt8:$src2),
Evan Cheng4b0345b2010-01-11 17:03:47 +00004665 (ADD32ri8 GR32:$src1, i32immSExt8:$src2)>;
Chris Lattnera0f70172010-03-24 00:15:23 +00004666def : Pat<(or_is_add GR16:$src1, GR16:$src2),
Evan Cheng199c4242010-01-11 22:03:29 +00004667 (ADD16rr GR16:$src1, GR16:$src2)>;
Chris Lattnera0f70172010-03-24 00:15:23 +00004668def : Pat<(or_is_add GR32:$src1, GR32:$src2),
Evan Cheng199c4242010-01-11 22:03:29 +00004669 (ADD32rr GR32:$src1, GR32:$src2)>;
Evan Cheng3bda2012010-01-12 18:31:19 +00004670} // AddedComplexity
Evan Cheng4b0345b2010-01-11 17:03:47 +00004671
Evan Cheng4e4c71e2006-02-21 20:00:20 +00004672//===----------------------------------------------------------------------===//
Dan Gohman076aee32009-03-04 19:44:21 +00004673// EFLAGS-defining Patterns
Bill Wendlingd350e022008-12-12 21:15:41 +00004674//===----------------------------------------------------------------------===//
4675
Chris Lattnerec856802010-03-27 00:45:04 +00004676// add reg, reg
4677def : Pat<(add GR8 :$src1, GR8 :$src2), (ADD8rr GR8 :$src1, GR8 :$src2)>;
4678def : Pat<(add GR16:$src1, GR16:$src2), (ADD16rr GR16:$src1, GR16:$src2)>;
4679def : Pat<(add GR32:$src1, GR32:$src2), (ADD32rr GR32:$src1, GR32:$src2)>;
Bill Wendlingd350e022008-12-12 21:15:41 +00004680
Chris Lattnerec856802010-03-27 00:45:04 +00004681// add reg, mem
4682def : Pat<(add GR8:$src1, (loadi8 addr:$src2)),
Bill Wendlingd350e022008-12-12 21:15:41 +00004683 (ADD8rm GR8:$src1, addr:$src2)>;
Chris Lattnerec856802010-03-27 00:45:04 +00004684def : Pat<(add GR16:$src1, (loadi16 addr:$src2)),
Bill Wendlingd350e022008-12-12 21:15:41 +00004685 (ADD16rm GR16:$src1, addr:$src2)>;
Chris Lattnerec856802010-03-27 00:45:04 +00004686def : Pat<(add GR32:$src1, (loadi32 addr:$src2)),
Bill Wendlingd350e022008-12-12 21:15:41 +00004687 (ADD32rm GR32:$src1, addr:$src2)>;
4688
Chris Lattnerec856802010-03-27 00:45:04 +00004689// add reg, imm
4690def : Pat<(add GR8 :$src1, imm:$src2), (ADD8ri GR8:$src1 , imm:$src2)>;
4691def : Pat<(add GR16:$src1, imm:$src2), (ADD16ri GR16:$src1, imm:$src2)>;
4692def : Pat<(add GR32:$src1, imm:$src2), (ADD32ri GR32:$src1, imm:$src2)>;
4693def : Pat<(add GR16:$src1, i16immSExt8:$src2),
Bill Wendlingd350e022008-12-12 21:15:41 +00004694 (ADD16ri8 GR16:$src1, i16immSExt8:$src2)>;
Chris Lattnerec856802010-03-27 00:45:04 +00004695def : Pat<(add GR32:$src1, i32immSExt8:$src2),
Bill Wendlingd350e022008-12-12 21:15:41 +00004696 (ADD32ri8 GR32:$src1, i32immSExt8:$src2)>;
4697
Chris Lattnerec856802010-03-27 00:45:04 +00004698// sub reg, reg
4699def : Pat<(sub GR8 :$src1, GR8 :$src2), (SUB8rr GR8 :$src1, GR8 :$src2)>;
4700def : Pat<(sub GR16:$src1, GR16:$src2), (SUB16rr GR16:$src1, GR16:$src2)>;
4701def : Pat<(sub GR32:$src1, GR32:$src2), (SUB32rr GR32:$src1, GR32:$src2)>;
Bill Wendlingd350e022008-12-12 21:15:41 +00004702
Chris Lattnerec856802010-03-27 00:45:04 +00004703// sub reg, mem
4704def : Pat<(sub GR8:$src1, (loadi8 addr:$src2)),
Bill Wendlingd350e022008-12-12 21:15:41 +00004705 (SUB8rm GR8:$src1, addr:$src2)>;
Chris Lattnerec856802010-03-27 00:45:04 +00004706def : Pat<(sub GR16:$src1, (loadi16 addr:$src2)),
Bill Wendlingd350e022008-12-12 21:15:41 +00004707 (SUB16rm GR16:$src1, addr:$src2)>;
Chris Lattnerec856802010-03-27 00:45:04 +00004708def : Pat<(sub GR32:$src1, (loadi32 addr:$src2)),
Bill Wendlingd350e022008-12-12 21:15:41 +00004709 (SUB32rm GR32:$src1, addr:$src2)>;
4710
Chris Lattnerec856802010-03-27 00:45:04 +00004711// sub reg, imm
4712def : Pat<(sub GR8:$src1, imm:$src2),
Bill Wendlingd350e022008-12-12 21:15:41 +00004713 (SUB8ri GR8:$src1, imm:$src2)>;
Chris Lattnerec856802010-03-27 00:45:04 +00004714def : Pat<(sub GR16:$src1, imm:$src2),
Bill Wendlingd350e022008-12-12 21:15:41 +00004715 (SUB16ri GR16:$src1, imm:$src2)>;
Chris Lattnerec856802010-03-27 00:45:04 +00004716def : Pat<(sub GR32:$src1, imm:$src2),
Bill Wendlingd350e022008-12-12 21:15:41 +00004717 (SUB32ri GR32:$src1, imm:$src2)>;
Chris Lattnerec856802010-03-27 00:45:04 +00004718def : Pat<(sub GR16:$src1, i16immSExt8:$src2),
Bill Wendlingd350e022008-12-12 21:15:41 +00004719 (SUB16ri8 GR16:$src1, i16immSExt8:$src2)>;
Chris Lattnerec856802010-03-27 00:45:04 +00004720def : Pat<(sub GR32:$src1, i32immSExt8:$src2),
Bill Wendlingd350e022008-12-12 21:15:41 +00004721 (SUB32ri8 GR32:$src1, i32immSExt8:$src2)>;
4722
Chris Lattnerec856802010-03-27 00:45:04 +00004723// mul reg, reg
4724def : Pat<(mul GR16:$src1, GR16:$src2),
Bill Wendlingd350e022008-12-12 21:15:41 +00004725 (IMUL16rr GR16:$src1, GR16:$src2)>;
Chris Lattnerec856802010-03-27 00:45:04 +00004726def : Pat<(mul GR32:$src1, GR32:$src2),
Bill Wendlingd350e022008-12-12 21:15:41 +00004727 (IMUL32rr GR32:$src1, GR32:$src2)>;
4728
Chris Lattnerec856802010-03-27 00:45:04 +00004729// mul reg, mem
4730def : Pat<(mul GR16:$src1, (loadi16 addr:$src2)),
Bill Wendlingd350e022008-12-12 21:15:41 +00004731 (IMUL16rm GR16:$src1, addr:$src2)>;
Chris Lattnerec856802010-03-27 00:45:04 +00004732def : Pat<(mul GR32:$src1, (loadi32 addr:$src2)),
Bill Wendlingd350e022008-12-12 21:15:41 +00004733 (IMUL32rm GR32:$src1, addr:$src2)>;
4734
Chris Lattnerec856802010-03-27 00:45:04 +00004735// mul reg, imm
4736def : Pat<(mul GR16:$src1, imm:$src2),
Bill Wendlingd350e022008-12-12 21:15:41 +00004737 (IMUL16rri GR16:$src1, imm:$src2)>;
Chris Lattnerec856802010-03-27 00:45:04 +00004738def : Pat<(mul GR32:$src1, imm:$src2),
Bill Wendlingd350e022008-12-12 21:15:41 +00004739 (IMUL32rri GR32:$src1, imm:$src2)>;
Chris Lattnerec856802010-03-27 00:45:04 +00004740def : Pat<(mul GR16:$src1, i16immSExt8:$src2),
Bill Wendlingd350e022008-12-12 21:15:41 +00004741 (IMUL16rri8 GR16:$src1, i16immSExt8:$src2)>;
Chris Lattnerec856802010-03-27 00:45:04 +00004742def : Pat<(mul GR32:$src1, i32immSExt8:$src2),
Bill Wendlingd350e022008-12-12 21:15:41 +00004743 (IMUL32rri8 GR32:$src1, i32immSExt8:$src2)>;
4744
Chris Lattnerec856802010-03-27 00:45:04 +00004745// reg = mul mem, imm
4746def : Pat<(mul (loadi16 addr:$src1), imm:$src2),
Bill Wendlingd350e022008-12-12 21:15:41 +00004747 (IMUL16rmi addr:$src1, imm:$src2)>;
Chris Lattnerec856802010-03-27 00:45:04 +00004748def : Pat<(mul (loadi32 addr:$src1), imm:$src2),
Bill Wendlingd350e022008-12-12 21:15:41 +00004749 (IMUL32rmi addr:$src1, imm:$src2)>;
Chris Lattnerec856802010-03-27 00:45:04 +00004750def : Pat<(mul (loadi16 addr:$src1), i16immSExt8:$src2),
Bill Wendlingd350e022008-12-12 21:15:41 +00004751 (IMUL16rmi8 addr:$src1, i16immSExt8:$src2)>;
Chris Lattnerec856802010-03-27 00:45:04 +00004752def : Pat<(mul (loadi32 addr:$src1), i32immSExt8:$src2),
Bill Wendlingd350e022008-12-12 21:15:41 +00004753 (IMUL32rmi8 addr:$src1, i32immSExt8:$src2)>;
4754
Dan Gohman076aee32009-03-04 19:44:21 +00004755// Optimize multiply by 2 with EFLAGS result.
Evan Cheng6a86bd72009-01-27 03:30:42 +00004756let AddedComplexity = 2 in {
Chris Lattnerbaba4bb2010-03-27 02:47:14 +00004757def : Pat<(X86smul_flag GR16:$src1, 2), (ADD16rr GR16:$src1, GR16:$src1)>;
4758def : Pat<(X86smul_flag GR32:$src1, 2), (ADD32rr GR32:$src1, GR32:$src1)>;
Evan Cheng6a86bd72009-01-27 03:30:42 +00004759}
4760
Chris Lattner589ad5d2010-03-25 05:44:01 +00004761// Patterns for nodes that do not produce flags, for instructions that do.
Chris Lattnerc54a2f12010-03-24 01:02:12 +00004762
Chris Lattner589ad5d2010-03-25 05:44:01 +00004763// Increment reg.
4764def : Pat<(add GR8:$src , 1), (INC8r GR8:$src)>;
4765def : Pat<(add GR16:$src, 1), (INC16r GR16:$src)>, Requires<[In32BitMode]>;
4766def : Pat<(add GR32:$src, 1), (INC32r GR32:$src)>, Requires<[In32BitMode]>;
Dan Gohman076aee32009-03-04 19:44:21 +00004767
Chris Lattner589ad5d2010-03-25 05:44:01 +00004768// Decrement reg.
4769def : Pat<(add GR8:$src , -1), (DEC8r GR8:$src)>;
4770def : Pat<(add GR16:$src, -1), (DEC16r GR16:$src)>, Requires<[In32BitMode]>;
4771def : Pat<(add GR32:$src, -1), (DEC32r GR32:$src)>, Requires<[In32BitMode]>;
Dan Gohman076aee32009-03-04 19:44:21 +00004772
Chris Lattner589ad5d2010-03-25 05:44:01 +00004773// or reg/reg.
4774def : Pat<(or GR8 :$src1, GR8 :$src2), (OR8rr GR8 :$src1, GR8 :$src2)>;
4775def : Pat<(or GR16:$src1, GR16:$src2), (OR16rr GR16:$src1, GR16:$src2)>;
4776def : Pat<(or GR32:$src1, GR32:$src2), (OR32rr GR32:$src1, GR32:$src2)>;
Dan Gohman076aee32009-03-04 19:44:21 +00004777
Chris Lattner589ad5d2010-03-25 05:44:01 +00004778// or reg/mem
4779def : Pat<(or GR8:$src1, (loadi8 addr:$src2)),
Dan Gohmane220c4b2009-09-18 19:59:53 +00004780 (OR8rm GR8:$src1, addr:$src2)>;
Chris Lattner589ad5d2010-03-25 05:44:01 +00004781def : Pat<(or GR16:$src1, (loadi16 addr:$src2)),
Dan Gohmane220c4b2009-09-18 19:59:53 +00004782 (OR16rm GR16:$src1, addr:$src2)>;
Chris Lattner589ad5d2010-03-25 05:44:01 +00004783def : Pat<(or GR32:$src1, (loadi32 addr:$src2)),
Dan Gohmane220c4b2009-09-18 19:59:53 +00004784 (OR32rm GR32:$src1, addr:$src2)>;
4785
Chris Lattner589ad5d2010-03-25 05:44:01 +00004786// or reg/imm
4787def : Pat<(or GR8:$src1 , imm:$src2), (OR8ri GR8 :$src1, imm:$src2)>;
4788def : Pat<(or GR16:$src1, imm:$src2), (OR16ri GR16:$src1, imm:$src2)>;
4789def : Pat<(or GR32:$src1, imm:$src2), (OR32ri GR32:$src1, imm:$src2)>;
4790def : Pat<(or GR16:$src1, i16immSExt8:$src2),
Dan Gohmane220c4b2009-09-18 19:59:53 +00004791 (OR16ri8 GR16:$src1, i16immSExt8:$src2)>;
Chris Lattner589ad5d2010-03-25 05:44:01 +00004792def : Pat<(or GR32:$src1, i32immSExt8:$src2),
Dan Gohmane220c4b2009-09-18 19:59:53 +00004793 (OR32ri8 GR32:$src1, i32immSExt8:$src2)>;
Dan Gohmane220c4b2009-09-18 19:59:53 +00004794
Chris Lattner589ad5d2010-03-25 05:44:01 +00004795// xor reg/reg
4796def : Pat<(xor GR8 :$src1, GR8 :$src2), (XOR8rr GR8 :$src1, GR8 :$src2)>;
4797def : Pat<(xor GR16:$src1, GR16:$src2), (XOR16rr GR16:$src1, GR16:$src2)>;
4798def : Pat<(xor GR32:$src1, GR32:$src2), (XOR32rr GR32:$src1, GR32:$src2)>;
Dan Gohmane220c4b2009-09-18 19:59:53 +00004799
Chris Lattner589ad5d2010-03-25 05:44:01 +00004800// xor reg/mem
4801def : Pat<(xor GR8:$src1, (loadi8 addr:$src2)),
Dan Gohmane220c4b2009-09-18 19:59:53 +00004802 (XOR8rm GR8:$src1, addr:$src2)>;
Chris Lattner589ad5d2010-03-25 05:44:01 +00004803def : Pat<(xor GR16:$src1, (loadi16 addr:$src2)),
Dan Gohmane220c4b2009-09-18 19:59:53 +00004804 (XOR16rm GR16:$src1, addr:$src2)>;
Chris Lattner589ad5d2010-03-25 05:44:01 +00004805def : Pat<(xor GR32:$src1, (loadi32 addr:$src2)),
Dan Gohmane220c4b2009-09-18 19:59:53 +00004806 (XOR32rm GR32:$src1, addr:$src2)>;
4807
Chris Lattner589ad5d2010-03-25 05:44:01 +00004808// xor reg/imm
4809def : Pat<(xor GR8:$src1, imm:$src2),
Dan Gohmane220c4b2009-09-18 19:59:53 +00004810 (XOR8ri GR8:$src1, imm:$src2)>;
Chris Lattner589ad5d2010-03-25 05:44:01 +00004811def : Pat<(xor GR16:$src1, imm:$src2),
Dan Gohmane220c4b2009-09-18 19:59:53 +00004812 (XOR16ri GR16:$src1, imm:$src2)>;
Chris Lattner589ad5d2010-03-25 05:44:01 +00004813def : Pat<(xor GR32:$src1, imm:$src2),
Dan Gohmane220c4b2009-09-18 19:59:53 +00004814 (XOR32ri GR32:$src1, imm:$src2)>;
Chris Lattner589ad5d2010-03-25 05:44:01 +00004815def : Pat<(xor GR16:$src1, i16immSExt8:$src2),
Dan Gohmane220c4b2009-09-18 19:59:53 +00004816 (XOR16ri8 GR16:$src1, i16immSExt8:$src2)>;
Chris Lattner589ad5d2010-03-25 05:44:01 +00004817def : Pat<(xor GR32:$src1, i32immSExt8:$src2),
Dan Gohmane220c4b2009-09-18 19:59:53 +00004818 (XOR32ri8 GR32:$src1, i32immSExt8:$src2)>;
4819
Chris Lattner589ad5d2010-03-25 05:44:01 +00004820// and reg/reg
4821def : Pat<(and GR8 :$src1, GR8 :$src2), (AND8rr GR8 :$src1, GR8 :$src2)>;
4822def : Pat<(and GR16:$src1, GR16:$src2), (AND16rr GR16:$src1, GR16:$src2)>;
4823def : Pat<(and GR32:$src1, GR32:$src2), (AND32rr GR32:$src1, GR32:$src2)>;
Dan Gohmane220c4b2009-09-18 19:59:53 +00004824
Chris Lattner589ad5d2010-03-25 05:44:01 +00004825// and reg/mem
4826def : Pat<(and GR8:$src1, (loadi8 addr:$src2)),
Dan Gohmane220c4b2009-09-18 19:59:53 +00004827 (AND8rm GR8:$src1, addr:$src2)>;
Chris Lattner589ad5d2010-03-25 05:44:01 +00004828def : Pat<(and GR16:$src1, (loadi16 addr:$src2)),
Dan Gohmane220c4b2009-09-18 19:59:53 +00004829 (AND16rm GR16:$src1, addr:$src2)>;
Chris Lattner589ad5d2010-03-25 05:44:01 +00004830def : Pat<(and GR32:$src1, (loadi32 addr:$src2)),
Dan Gohmane220c4b2009-09-18 19:59:53 +00004831 (AND32rm GR32:$src1, addr:$src2)>;
4832
Chris Lattner589ad5d2010-03-25 05:44:01 +00004833// and reg/imm
4834def : Pat<(and GR8:$src1, imm:$src2),
Dan Gohmane220c4b2009-09-18 19:59:53 +00004835 (AND8ri GR8:$src1, imm:$src2)>;
Chris Lattner589ad5d2010-03-25 05:44:01 +00004836def : Pat<(and GR16:$src1, imm:$src2),
Dan Gohmane220c4b2009-09-18 19:59:53 +00004837 (AND16ri GR16:$src1, imm:$src2)>;
Chris Lattner589ad5d2010-03-25 05:44:01 +00004838def : Pat<(and GR32:$src1, imm:$src2),
Dan Gohmane220c4b2009-09-18 19:59:53 +00004839 (AND32ri GR32:$src1, imm:$src2)>;
Chris Lattner589ad5d2010-03-25 05:44:01 +00004840def : Pat<(and GR16:$src1, i16immSExt8:$src2),
Dan Gohmane220c4b2009-09-18 19:59:53 +00004841 (AND16ri8 GR16:$src1, i16immSExt8:$src2)>;
Chris Lattner589ad5d2010-03-25 05:44:01 +00004842def : Pat<(and GR32:$src1, i32immSExt8:$src2),
Dan Gohmane220c4b2009-09-18 19:59:53 +00004843 (AND32ri8 GR32:$src1, i32immSExt8:$src2)>;
4844
Bill Wendlingd350e022008-12-12 21:15:41 +00004845//===----------------------------------------------------------------------===//
Evan Cheng4e4c71e2006-02-21 20:00:20 +00004846// Floating Point Stack Support
4847//===----------------------------------------------------------------------===//
4848
4849include "X86InstrFPStack.td"
4850
4851//===----------------------------------------------------------------------===//
Evan Chengc64a1a92007-07-31 08:04:03 +00004852// X86-64 Support
4853//===----------------------------------------------------------------------===//
4854
Chris Lattner36fe6d22008-01-10 05:50:42 +00004855include "X86Instr64bit.td"
Evan Chengc64a1a92007-07-31 08:04:03 +00004856
4857//===----------------------------------------------------------------------===//
David Greene51898d72010-02-09 23:52:19 +00004858// SIMD support (SSE, MMX and AVX)
4859//===----------------------------------------------------------------------===//
4860
4861include "X86InstrFragmentsSIMD.td"
4862
4863//===----------------------------------------------------------------------===//
Evan Cheng4e4c71e2006-02-21 20:00:20 +00004864// XMM Floating point support (requires SSE / SSE2)
4865//===----------------------------------------------------------------------===//
4866
4867include "X86InstrSSE.td"
Evan Cheng80f54042008-04-25 18:19:54 +00004868
4869//===----------------------------------------------------------------------===//
4870// MMX and XMM Packed Integer support (requires MMX, SSE, and SSE2)
4871//===----------------------------------------------------------------------===//
4872
4873include "X86InstrMMX.td"