blob: 6917a9db6480f5497a59db3722f154d43de5f0df [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
Eric Christopher30ef0e52010-06-03 04:07:48 +000075def SDT_X86TLSCALL : SDTypeProfile<0, 1, [SDTCisPtrTy<0>]>;
76
Rafael Espindola094fad32009-04-08 21:14:34 +000077def SDT_X86SegmentBaseAddress : SDTypeProfile<1, 1, [SDTCisPtrTy<0>]>;
Lauro Ramos Venanciob3a04172007-04-20 21:38:10 +000078
Anton Korobeynikov2365f512007-07-14 14:06:15 +000079def SDT_X86EHRET : SDTypeProfile<0, 1, [SDTCisInt<0>]>;
80
Arnold Schwaighoferc85e1712007-10-11 19:40:01 +000081def SDT_X86TCRET : SDTypeProfile<0, 2, [SDTCisPtrTy<0>, SDTCisVT<1, i32>]>;
82
Chris Lattnerd486d772010-03-28 05:07:17 +000083def X86bsf : SDNode<"X86ISD::BSF", SDTUnaryArithWithFlags>;
84def X86bsr : SDNode<"X86ISD::BSR", SDTUnaryArithWithFlags>;
Evan Chenge3413162006-01-09 18:33:28 +000085def X86shld : SDNode<"X86ISD::SHLD", SDTIntShiftDOp>;
86def X86shrd : SDNode<"X86ISD::SHRD", SDTIntShiftDOp>;
Evan Chengb077b842005-12-21 02:39:21 +000087
Evan Chenge5f62042007-09-29 00:00:36 +000088def X86cmp : SDNode<"X86ISD::CMP" , SDTX86CmpTest>;
Dan Gohmanc7a37d42008-12-23 22:45:23 +000089def X86bt : SDNode<"X86ISD::BT", SDTX86CmpTest>;
90
Evan Chenge5f62042007-09-29 00:00:36 +000091def X86cmov : SDNode<"X86ISD::CMOV", SDTX86Cmov>;
Evan Chenge3413162006-01-09 18:33:28 +000092def X86brcond : SDNode<"X86ISD::BRCOND", SDTX86BrCond,
Evan Cheng0488db92007-09-25 01:57:46 +000093 [SDNPHasChain]>;
Evan Chenge5f62042007-09-29 00:00:36 +000094def X86setcc : SDNode<"X86ISD::SETCC", SDTX86SetCC>;
Evan Cheng2e489c42009-12-16 00:53:11 +000095def X86setcc_c : SDNode<"X86ISD::SETCC_CARRY", SDTX86SetCC_C>;
Evan Chengb077b842005-12-21 02:39:21 +000096
Andrew Lenharth26ed8692008-03-01 21:52:34 +000097def X86cas : SDNode<"X86ISD::LCMPXCHG_DAG", SDTX86cas,
98 [SDNPHasChain, SDNPInFlag, SDNPOutFlag, SDNPMayStore,
99 SDNPMayLoad]>;
Andrew Lenharthd19189e2008-03-05 01:15:49 +0000100def X86cas8 : SDNode<"X86ISD::LCMPXCHG8_DAG", SDTX86cas8,
101 [SDNPHasChain, SDNPInFlag, SDNPOutFlag, SDNPMayStore,
102 SDNPMayLoad]>;
Dale Johannesen48c1bc22008-10-02 18:53:47 +0000103def X86AtomAdd64 : SDNode<"X86ISD::ATOMADD64_DAG", SDTX86atomicBinary,
104 [SDNPHasChain, SDNPMayStore,
105 SDNPMayLoad, SDNPMemOperand]>;
106def X86AtomSub64 : SDNode<"X86ISD::ATOMSUB64_DAG", SDTX86atomicBinary,
107 [SDNPHasChain, SDNPMayStore,
108 SDNPMayLoad, SDNPMemOperand]>;
109def X86AtomOr64 : SDNode<"X86ISD::ATOMOR64_DAG", SDTX86atomicBinary,
110 [SDNPHasChain, SDNPMayStore,
111 SDNPMayLoad, SDNPMemOperand]>;
112def X86AtomXor64 : SDNode<"X86ISD::ATOMXOR64_DAG", SDTX86atomicBinary,
113 [SDNPHasChain, SDNPMayStore,
114 SDNPMayLoad, SDNPMemOperand]>;
115def X86AtomAnd64 : SDNode<"X86ISD::ATOMAND64_DAG", SDTX86atomicBinary,
116 [SDNPHasChain, SDNPMayStore,
117 SDNPMayLoad, SDNPMemOperand]>;
118def X86AtomNand64 : SDNode<"X86ISD::ATOMNAND64_DAG", SDTX86atomicBinary,
119 [SDNPHasChain, SDNPMayStore,
120 SDNPMayLoad, SDNPMemOperand]>;
Dale Johannesen880ae362008-10-03 22:25:52 +0000121def X86AtomSwap64 : SDNode<"X86ISD::ATOMSWAP64_DAG", SDTX86atomicBinary,
122 [SDNPHasChain, SDNPMayStore,
123 SDNPMayLoad, SDNPMemOperand]>;
Evan Chenge3413162006-01-09 18:33:28 +0000124def X86retflag : SDNode<"X86ISD::RET_FLAG", SDTX86Ret,
Chris Lattnere8cabf32010-03-19 05:07:09 +0000125 [SDNPHasChain, SDNPOptInFlag, SDNPVariadic]>;
Evan Chengb077b842005-12-21 02:39:21 +0000126
Dan Gohmand6708ea2009-08-15 01:38:56 +0000127def X86vastart_save_xmm_regs :
128 SDNode<"X86ISD::VASTART_SAVE_XMM_REGS",
129 SDT_X86VASTART_SAVE_XMM_REGS,
Chris Lattnere8cabf32010-03-19 05:07:09 +0000130 [SDNPHasChain, SDNPVariadic]>;
Dan Gohmand6708ea2009-08-15 01:38:56 +0000131
Evan Chenge3413162006-01-09 18:33:28 +0000132def X86callseq_start :
133 SDNode<"ISD::CALLSEQ_START", SDT_X86CallSeqStart,
Evan Chengbb7b8442006-08-11 09:03:33 +0000134 [SDNPHasChain, SDNPOutFlag]>;
Evan Chenge3413162006-01-09 18:33:28 +0000135def X86callseq_end :
136 SDNode<"ISD::CALLSEQ_END", SDT_X86CallSeqEnd,
Arnold Schwaighoferc85e1712007-10-11 19:40:01 +0000137 [SDNPHasChain, SDNPOptInFlag, SDNPOutFlag]>;
Evan Chengb077b842005-12-21 02:39:21 +0000138
Evan Chenge3413162006-01-09 18:33:28 +0000139def X86call : SDNode<"X86ISD::CALL", SDT_X86Call,
Chris Lattnere8cabf32010-03-19 05:07:09 +0000140 [SDNPHasChain, SDNPOutFlag, SDNPOptInFlag,
141 SDNPVariadic]>;
Evan Chengaed7c722005-12-17 01:24:02 +0000142
Chris Lattnered52c8f2010-03-28 07:38:39 +0000143def X86rep_stos: SDNode<"X86ISD::REP_STOS", SDTX86RepStr,
Chris Lattner9b37aaf2008-01-10 05:12:37 +0000144 [SDNPHasChain, SDNPInFlag, SDNPOutFlag, SDNPMayStore]>;
Chris Lattnered52c8f2010-03-28 07:38:39 +0000145def X86rep_movs: SDNode<"X86ISD::REP_MOVS", SDTX86RepStr,
Chris Lattner9b37aaf2008-01-10 05:12:37 +0000146 [SDNPHasChain, SDNPInFlag, SDNPOutFlag, SDNPMayStore,
147 SDNPMayLoad]>;
Evan Cheng67f92a72006-01-11 22:15:48 +0000148
Anton Korobeynikov043f3c22010-03-06 19:32:29 +0000149def X86rdtsc : SDNode<"X86ISD::RDTSC_DAG", SDTX86Void,
Chris Lattnerba7e7562008-01-10 07:59:24 +0000150 [SDNPHasChain, SDNPOutFlag, SDNPSideEffect]>;
Evan Chengd90eb7f2006-01-05 00:27:02 +0000151
Evan Cheng0085a282006-11-30 21:55:46 +0000152def X86Wrapper : SDNode<"X86ISD::Wrapper", SDTX86Wrapper>;
153def X86WrapperRIP : SDNode<"X86ISD::WrapperRIP", SDTX86Wrapper>;
Evan Cheng71fb8342006-02-25 10:02:21 +0000154
Lauro Ramos Venanciob3a04172007-04-20 21:38:10 +0000155def X86tlsaddr : SDNode<"X86ISD::TLSADDR", SDT_X86TLSADDR,
Anton Korobeynikov6625eff2008-05-04 21:36:32 +0000156 [SDNPHasChain, SDNPOptInFlag, SDNPOutFlag]>;
Rafael Espindola094fad32009-04-08 21:14:34 +0000157def X86SegmentBaseAddress : SDNode<"X86ISD::SegmentBaseAddress",
158 SDT_X86SegmentBaseAddress, []>;
Lauro Ramos Venanciob3a04172007-04-20 21:38:10 +0000159
Anton Korobeynikov2365f512007-07-14 14:06:15 +0000160def X86ehret : SDNode<"X86ISD::EH_RETURN", SDT_X86EHRET,
161 [SDNPHasChain]>;
162
Arnold Schwaighoferc85e1712007-10-11 19:40:01 +0000163def X86tcret : SDNode<"X86ISD::TC_RETURN", SDT_X86TCRET,
Chris Lattnere8cabf32010-03-19 05:07:09 +0000164 [SDNPHasChain, SDNPOptInFlag, SDNPVariadic]>;
Lauro Ramos Venanciob3a04172007-04-20 21:38:10 +0000165
Dan Gohman43ffe672010-01-04 20:51:05 +0000166def X86add_flag : SDNode<"X86ISD::ADD", SDTBinaryArithWithFlags,
Dan Gohman4361bbf2010-01-05 00:44:20 +0000167 [SDNPCommutative]>;
Dan Gohman076aee32009-03-04 19:44:21 +0000168def X86sub_flag : SDNode<"X86ISD::SUB", SDTBinaryArithWithFlags>;
Dan Gohman43ffe672010-01-04 20:51:05 +0000169def X86smul_flag : SDNode<"X86ISD::SMUL", SDTBinaryArithWithFlags,
Dan Gohman4361bbf2010-01-05 00:44:20 +0000170 [SDNPCommutative]>;
Dan Gohman43ffe672010-01-04 20:51:05 +0000171def X86umul_flag : SDNode<"X86ISD::UMUL", SDTUnaryArithWithFlags,
Dan Gohman4361bbf2010-01-05 00:44:20 +0000172 [SDNPCommutative]>;
Chris Lattner74c8d672010-03-24 00:47:47 +0000173
Dan Gohman076aee32009-03-04 19:44:21 +0000174def X86inc_flag : SDNode<"X86ISD::INC", SDTUnaryArithWithFlags>;
175def X86dec_flag : SDNode<"X86ISD::DEC", SDTUnaryArithWithFlags>;
Dan Gohman43ffe672010-01-04 20:51:05 +0000176def X86or_flag : SDNode<"X86ISD::OR", SDTBinaryArithWithFlags,
Dan Gohman4361bbf2010-01-05 00:44:20 +0000177 [SDNPCommutative]>;
Dan Gohman43ffe672010-01-04 20:51:05 +0000178def X86xor_flag : SDNode<"X86ISD::XOR", SDTBinaryArithWithFlags,
Dan Gohman4361bbf2010-01-05 00:44:20 +0000179 [SDNPCommutative]>;
Dan Gohman43ffe672010-01-04 20:51:05 +0000180def X86and_flag : SDNode<"X86ISD::AND", SDTBinaryArithWithFlags,
Dan Gohman4361bbf2010-01-05 00:44:20 +0000181 [SDNPCommutative]>;
Bill Wendlingab55ebd2008-12-12 00:56:36 +0000182
Evan Cheng73f24c92009-03-30 21:36:47 +0000183def X86mul_imm : SDNode<"X86ISD::MUL_IMM", SDTIntBinOp>;
184
Anton Korobeynikov043f3c22010-03-06 19:32:29 +0000185def X86MingwAlloca : SDNode<"X86ISD::MINGW_ALLOCA", SDTX86Void,
186 [SDNPHasChain, SDNPInFlag, SDNPOutFlag]>;
Eric Christopher30ef0e52010-06-03 04:07:48 +0000187
188def X86TLSCall : SDNode<"X86ISD::TLSCALL", SDT_X86TLSCALL,
189 []>;
Anton Korobeynikov043f3c22010-03-06 19:32:29 +0000190
Evan Chengaed7c722005-12-17 01:24:02 +0000191//===----------------------------------------------------------------------===//
192// X86 Operand Definitions.
193//
194
Dan Gohmana4714e02009-07-30 01:56:29 +0000195// A version of ptr_rc which excludes SP, ESP, and RSP. This is used for
196// the index operand of an address, to conform to x86 encoding restrictions.
197def ptr_rc_nosp : PointerLikeRegClass<1>;
Chris Lattner7680e732009-06-20 19:34:09 +0000198
Chris Lattner66fa1dc2004-08-11 02:25:00 +0000199// *mem - Operand definitions for the funky X86 addressing mode operands.
200//
Daniel Dunbar338825c2009-08-10 18:41:10 +0000201def X86MemAsmOperand : AsmOperandClass {
202 let Name = "Mem";
Daniel Dunbar54ddf3d2010-05-22 21:02:29 +0000203 let SuperClasses = [];
Daniel Dunbar338825c2009-08-10 18:41:10 +0000204}
Daniel Dunbarc26ae5a2010-05-06 22:39:14 +0000205def X86AbsMemAsmOperand : AsmOperandClass {
206 let Name = "AbsMem";
Chris Lattner599b5312010-07-08 23:46:44 +0000207 let SuperClasses = [X86MemAsmOperand];
Daniel Dunbarc26ae5a2010-05-06 22:39:14 +0000208}
Evan Chengaf78ef52006-05-17 21:21:41 +0000209class X86MemOperand<string printMethod> : Operand<iPTR> {
Nate Begeman391c5d22005-11-30 18:54:35 +0000210 let PrintMethod = printMethod;
Dan Gohmana4714e02009-07-30 01:56:29 +0000211 let MIOperandInfo = (ops ptr_rc, i8imm, ptr_rc_nosp, i32imm, i8imm);
Daniel Dunbar338825c2009-08-10 18:41:10 +0000212 let ParserMatchClass = X86MemAsmOperand;
Chris Lattner66fa1dc2004-08-11 02:25:00 +0000213}
Nate Begeman391c5d22005-11-30 18:54:35 +0000214
Sean Callanan9947bbb2009-09-03 00:04:47 +0000215def opaque32mem : X86MemOperand<"printopaquemem">;
216def opaque48mem : X86MemOperand<"printopaquemem">;
217def opaque80mem : X86MemOperand<"printopaquemem">;
Sean Callanan108934c2009-12-18 00:01:26 +0000218def opaque512mem : X86MemOperand<"printopaquemem">;
219
Chris Lattner45432512005-12-17 19:47:05 +0000220def i8mem : X86MemOperand<"printi8mem">;
221def i16mem : X86MemOperand<"printi16mem">;
222def i32mem : X86MemOperand<"printi32mem">;
223def i64mem : X86MemOperand<"printi64mem">;
Evan Cheng470a6ad2006-02-22 02:26:30 +0000224def i128mem : X86MemOperand<"printi128mem">;
Bruno Cardoso Lopes94143ee2010-07-19 23:32:44 +0000225def i256mem : X86MemOperand<"printi256mem">;
Chris Lattner45432512005-12-17 19:47:05 +0000226def f32mem : X86MemOperand<"printf32mem">;
227def f64mem : X86MemOperand<"printf64mem">;
Dale Johannesen59a58732007-08-05 18:49:15 +0000228def f80mem : X86MemOperand<"printf80mem">;
Evan Cheng223547a2006-01-31 22:28:30 +0000229def f128mem : X86MemOperand<"printf128mem">;
Bruno Cardoso Lopese86b01c2010-07-09 18:27:43 +0000230def f256mem : X86MemOperand<"printf256mem">;
Nate Begeman391c5d22005-11-30 18:54:35 +0000231
Dan Gohman21e3dfb2009-04-13 16:09:41 +0000232// A version of i8mem for use on x86-64 that uses GR64_NOREX instead of
233// plain GR64, so that it doesn't potentially require a REX prefix.
234def i8mem_NOREX : Operand<i64> {
235 let PrintMethod = "printi8mem";
Dan Gohmana4714e02009-07-30 01:56:29 +0000236 let MIOperandInfo = (ops GR64_NOREX, i8imm, GR64_NOREX_NOSP, i32imm, i8imm);
Daniel Dunbar338825c2009-08-10 18:41:10 +0000237 let ParserMatchClass = X86MemAsmOperand;
Dan Gohman21e3dfb2009-04-13 16:09:41 +0000238}
239
Evan Chengf48ef032010-03-14 03:48:46 +0000240// Special i32mem for addresses of load folding tail calls. These are not
241// allowed to use callee-saved registers since they must be scheduled
242// after callee-saved register are popped.
243def i32mem_TC : Operand<i32> {
244 let PrintMethod = "printi32mem";
245 let MIOperandInfo = (ops GR32_TC, i8imm, GR32_TC, i32imm, i8imm);
246 let ParserMatchClass = X86MemAsmOperand;
247}
248
Evan Cheng25ab6902006-09-08 06:48:29 +0000249
Daniel Dunbarb834f5d2010-01-30 01:02:48 +0000250let ParserMatchClass = X86AbsMemAsmOperand,
251 PrintMethod = "print_pcrel_imm" in {
Daniel Dunbar728e5eb2010-01-30 00:24:12 +0000252def i32imm_pcrel : Operand<i32>;
Chris Lattner9fc05222010-07-07 22:27:31 +0000253def i16imm_pcrel : Operand<i16>;
Daniel Dunbar728e5eb2010-01-30 00:24:12 +0000254
255def offset8 : Operand<i64>;
256def offset16 : Operand<i64>;
257def offset32 : Operand<i64>;
258def offset64 : Operand<i64>;
259
260// Branch targets have OtherVT type and print as pc-relative values.
261def brtarget : Operand<OtherVT>;
262def brtarget8 : Operand<OtherVT>;
263
264}
265
Nate Begeman16b04f32005-07-15 00:38:55 +0000266def SSECC : Operand<i8> {
267 let PrintMethod = "printSSECC";
268}
Chris Lattner66fa1dc2004-08-11 02:25:00 +0000269
Daniel Dunbar62e4c672010-05-22 21:02:33 +0000270class ImmSExtAsmOperandClass : AsmOperandClass {
Daniel Dunbar54ddf3d2010-05-22 21:02:29 +0000271 let SuperClasses = [ImmAsmOperand];
Daniel Dunbar62e4c672010-05-22 21:02:33 +0000272 let RenderMethod = "addImmOperands";
Daniel Dunbar1fe591d2010-05-20 20:20:39 +0000273}
274
Daniel Dunbar62e4c672010-05-22 21:02:33 +0000275// Sign-extended immediate classes. We don't need to define the full lattice
276// here because there is no instruction with an ambiguity between ImmSExti64i32
277// and ImmSExti32i8.
278//
279// The strange ranges come from the fact that the assembler always works with
280// 64-bit immediates, but for a 16-bit target value we want to accept both "-1"
281// (which will be a -1ULL), and "0xFF" (-1 in 16-bits).
282
Chris Lattner599b5312010-07-08 23:46:44 +0000283// [0, 0x7FFFFFFF] |
284// [0xFFFFFFFF80000000, 0xFFFFFFFFFFFFFFFF]
Daniel Dunbar62e4c672010-05-22 21:02:33 +0000285def ImmSExti64i32AsmOperand : ImmSExtAsmOperandClass {
286 let Name = "ImmSExti64i32";
287}
288
Chris Lattner599b5312010-07-08 23:46:44 +0000289// [0, 0x0000007F] | [0x000000000000FF80, 0x000000000000FFFF] |
290// [0xFFFFFFFFFFFFFF80, 0xFFFFFFFFFFFFFFFF]
Daniel Dunbar62e4c672010-05-22 21:02:33 +0000291def ImmSExti16i8AsmOperand : ImmSExtAsmOperandClass {
292 let Name = "ImmSExti16i8";
293 let SuperClasses = [ImmSExti64i32AsmOperand];
294}
295
Chris Lattner599b5312010-07-08 23:46:44 +0000296// [0, 0x0000007F] | [0x00000000FFFFFF80, 0x00000000FFFFFFFF] |
297// [0xFFFFFFFFFFFFFF80, 0xFFFFFFFFFFFFFFFF]
Daniel Dunbar62e4c672010-05-22 21:02:33 +0000298def ImmSExti32i8AsmOperand : ImmSExtAsmOperandClass {
299 let Name = "ImmSExti32i8";
300}
301
Chris Lattner599b5312010-07-08 23:46:44 +0000302// [0, 0x0000007F] |
303// [0xFFFFFFFFFFFFFF80, 0xFFFFFFFFFFFFFFFF]
Daniel Dunbar62e4c672010-05-22 21:02:33 +0000304def ImmSExti64i8AsmOperand : ImmSExtAsmOperandClass {
305 let Name = "ImmSExti64i8";
Chris Lattner599b5312010-07-08 23:46:44 +0000306 let SuperClasses = [ImmSExti16i8AsmOperand, ImmSExti32i8AsmOperand,
307 ImmSExti64i32AsmOperand];
Daniel Dunbar338825c2009-08-10 18:41:10 +0000308}
309
Chris Lattnerf124d5e2005-11-18 01:04:42 +0000310// A couple of more descriptive operand definitions.
311// 16-bits but only 8 bits are significant.
Daniel Dunbar5fe63382009-08-09 07:20:21 +0000312def i16i8imm : Operand<i16> {
Daniel Dunbar62e4c672010-05-22 21:02:33 +0000313 let ParserMatchClass = ImmSExti16i8AsmOperand;
Daniel Dunbar5fe63382009-08-09 07:20:21 +0000314}
Chris Lattnerf124d5e2005-11-18 01:04:42 +0000315// 32-bits but only 8 bits are significant.
Daniel Dunbar5fe63382009-08-09 07:20:21 +0000316def i32i8imm : Operand<i32> {
Daniel Dunbar62e4c672010-05-22 21:02:33 +0000317 let ParserMatchClass = ImmSExti32i8AsmOperand;
Daniel Dunbar5fe63382009-08-09 07:20:21 +0000318}
Chris Lattnerf124d5e2005-11-18 01:04:42 +0000319
Evan Chengaed7c722005-12-17 01:24:02 +0000320//===----------------------------------------------------------------------===//
321// X86 Complex Pattern Definitions.
322//
323
Evan Chengec693f72005-12-08 02:01:35 +0000324// Define X86 specific addressing mode.
Rafael Espindola094fad32009-04-08 21:14:34 +0000325def addr : ComplexPattern<iPTR, 5, "SelectAddr", [], []>;
Chris Lattner599b5312010-07-08 23:46:44 +0000326def lea32addr : ComplexPattern<i32, 5, "SelectLEAAddr",
Dan Gohmana98634b2009-08-02 16:09:17 +0000327 [add, sub, mul, X86mul_imm, shl, or, frameindex],
328 []>;
Chris Lattner599b5312010-07-08 23:46:44 +0000329def tls32addr : ComplexPattern<i32, 5, "SelectTLSADDRAddr",
Chris Lattner5c0b16d2009-06-20 20:38:48 +0000330 [tglobaltlsaddr], []>;
Evan Chengec693f72005-12-08 02:01:35 +0000331
Evan Chengaed7c722005-12-17 01:24:02 +0000332//===----------------------------------------------------------------------===//
Evan Chengbbc8ddb2005-12-20 22:59:51 +0000333// X86 Instruction Predicate Definitions.
Chris Lattner314a1132010-03-14 18:31:44 +0000334def HasCMov : Predicate<"Subtarget->hasCMov()">;
335def NoCMov : Predicate<"!Subtarget->hasCMov()">;
Evan Cheng28b514392006-12-05 19:50:18 +0000336def HasMMX : Predicate<"Subtarget->hasMMX()">;
337def HasSSE1 : Predicate<"Subtarget->hasSSE1()">;
338def HasSSE2 : Predicate<"Subtarget->hasSSE2()">;
339def HasSSE3 : Predicate<"Subtarget->hasSSE3()">;
Bill Wendlingbb1ee052007-04-10 22:10:25 +0000340def HasSSSE3 : Predicate<"Subtarget->hasSSSE3()">;
Nate Begeman63ec90a2008-02-03 07:18:54 +0000341def HasSSE41 : Predicate<"Subtarget->hasSSE41()">;
342def HasSSE42 : Predicate<"Subtarget->hasSSE42()">;
David Greene343dadb2009-06-26 22:46:54 +0000343def HasSSE4A : Predicate<"Subtarget->hasSSE4A()">;
344def HasAVX : Predicate<"Subtarget->hasAVX()">;
345def HasFMA3 : Predicate<"Subtarget->hasFMA3()">;
346def HasFMA4 : Predicate<"Subtarget->hasFMA4()">;
Dale Johannesenf1fc3a82007-09-23 14:52:20 +0000347def FPStackf32 : Predicate<"!Subtarget->hasSSE1()">;
348def FPStackf64 : Predicate<"!Subtarget->hasSSE2()">;
Evan Cheng28b514392006-12-05 19:50:18 +0000349def In32BitMode : Predicate<"!Subtarget->is64Bit()">;
350def In64BitMode : Predicate<"Subtarget->is64Bit()">;
Anton Korobeynikovcf6b7392009-08-03 08:12:53 +0000351def IsWin64 : Predicate<"Subtarget->isTargetWin64()">;
352def NotWin64 : Predicate<"!Subtarget->isTargetWin64()">;
Anton Korobeynikovd7697d02009-08-06 11:23:24 +0000353def SmallCode : Predicate<"TM.getCodeModel() == CodeModel::Small">;
354def KernelCode : Predicate<"TM.getCodeModel() == CodeModel::Kernel">;
355def FarData : Predicate<"TM.getCodeModel() != CodeModel::Small &&"
Anton Korobeynikov186fa1d2009-08-06 09:11:19 +0000356 "TM.getCodeModel() != CodeModel::Kernel">;
Anton Korobeynikovd7697d02009-08-06 11:23:24 +0000357def NearData : Predicate<"TM.getCodeModel() == CodeModel::Small ||"
358 "TM.getCodeModel() == CodeModel::Kernel">;
Evan Cheng28b514392006-12-05 19:50:18 +0000359def IsStatic : Predicate<"TM.getRelocationModel() == Reloc::Static">;
Evan Chengcb0f06e2010-03-25 00:10:31 +0000360def IsNotPIC : Predicate<"TM.getRelocationModel() != Reloc::PIC_">;
Evan Chengb1f49812009-12-22 17:47:23 +0000361def OptForSize : Predicate<"OptForSize">;
Evan Chengb7a75a52008-09-26 23:41:32 +0000362def OptForSpeed : Predicate<"!OptForSize">;
Evan Chengccb69762009-01-02 05:35:45 +0000363def FastBTMem : Predicate<"!Subtarget->isBTMemSlow()">;
Evan Chengd7f666a2009-05-20 04:53:57 +0000364def CallImmAddr : Predicate<"Subtarget->IsLegalToCallImmediateAddr(TM)">;
Eric Christopher6d1cd1c2010-04-02 21:54:27 +0000365def HasAES : Predicate<"Subtarget->hasAES()">;
Evan Chengbbc8ddb2005-12-20 22:59:51 +0000366
367//===----------------------------------------------------------------------===//
Evan Chengc64a1a92007-07-31 08:04:03 +0000368// X86 Instruction Format Definitions.
Evan Chengaed7c722005-12-17 01:24:02 +0000369//
370
Evan Chengc64a1a92007-07-31 08:04:03 +0000371include "X86InstrFormats.td"
Chris Lattner1cca5e32003-08-03 21:54:21 +0000372
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +0000373//===----------------------------------------------------------------------===//
Chris Lattnerf124d5e2005-11-18 01:04:42 +0000374// Pattern fragments...
375//
Evan Chengd9558e02006-01-06 00:43:03 +0000376
377// X86 specific condition code. These correspond to CondCode in
Nate Begeman9a225302007-05-06 04:00:55 +0000378// X86InstrInfo.h. They must be kept in synch.
Dan Gohman653456c2009-01-07 00:15:08 +0000379def X86_COND_A : PatLeaf<(i8 0)>; // alt. COND_NBE
380def X86_COND_AE : PatLeaf<(i8 1)>; // alt. COND_NC
381def X86_COND_B : PatLeaf<(i8 2)>; // alt. COND_C
382def X86_COND_BE : PatLeaf<(i8 3)>; // alt. COND_NA
383def X86_COND_E : PatLeaf<(i8 4)>; // alt. COND_Z
384def X86_COND_G : PatLeaf<(i8 5)>; // alt. COND_NLE
385def X86_COND_GE : PatLeaf<(i8 6)>; // alt. COND_NL
386def X86_COND_L : PatLeaf<(i8 7)>; // alt. COND_NGE
387def X86_COND_LE : PatLeaf<(i8 8)>; // alt. COND_NG
388def X86_COND_NE : PatLeaf<(i8 9)>; // alt. COND_NZ
Evan Chengd9558e02006-01-06 00:43:03 +0000389def X86_COND_NO : PatLeaf<(i8 10)>;
Dan Gohman653456c2009-01-07 00:15:08 +0000390def X86_COND_NP : PatLeaf<(i8 11)>; // alt. COND_PO
Evan Chengd9558e02006-01-06 00:43:03 +0000391def X86_COND_NS : PatLeaf<(i8 12)>;
Dan Gohman653456c2009-01-07 00:15:08 +0000392def X86_COND_O : PatLeaf<(i8 13)>;
393def X86_COND_P : PatLeaf<(i8 14)>; // alt. COND_PE
394def X86_COND_S : PatLeaf<(i8 15)>;
Evan Chengd9558e02006-01-06 00:43:03 +0000395
Chris Lattner18409912010-03-03 01:45:01 +0000396def immSext8 : PatLeaf<(imm), [{
397 return N->getSExtValue() == (int8_t)N->getSExtValue();
Chris Lattnerf124d5e2005-11-18 01:04:42 +0000398}]>;
399
Chris Lattner18409912010-03-03 01:45:01 +0000400def i16immSExt8 : PatLeaf<(i16 immSext8)>;
401def i32immSExt8 : PatLeaf<(i32 immSext8)>;
Evan Chengb3558542005-12-13 00:01:09 +0000402
Chris Lattnerf85eff72010-03-03 01:52:59 +0000403/// Load patterns: these constraint the match to the right address space.
404def dsload : PatFrag<(ops node:$ptr), (load node:$ptr), [{
405 if (const Value *Src = cast<LoadSDNode>(N)->getSrcValue())
406 if (const PointerType *PT = dyn_cast<PointerType>(Src->getType()))
407 if (PT->getAddressSpace() > 255)
408 return false;
409 return true;
410}]>;
411
412def gsload : PatFrag<(ops node:$ptr), (load node:$ptr), [{
413 if (const Value *Src = cast<LoadSDNode>(N)->getSrcValue())
414 if (const PointerType *PT = dyn_cast<PointerType>(Src->getType()))
415 return PT->getAddressSpace() == 256;
416 return false;
417}]>;
418
419def fsload : PatFrag<(ops node:$ptr), (load node:$ptr), [{
420 if (const Value *Src = cast<LoadSDNode>(N)->getSrcValue())
421 if (const PointerType *PT = dyn_cast<PointerType>(Src->getType()))
422 return PT->getAddressSpace() == 257;
423 return false;
424}]>;
425
426
Evan Cheng605c4152005-12-13 01:57:51 +0000427// Helper fragments for loads.
Evan Chengb6564432008-05-13 18:59:59 +0000428// It's always safe to treat a anyext i16 load as a i32 load if the i16 is
429// known to be 32-bit aligned or better. Ditto for i8 to i16.
Dan Gohman33586292008-10-15 06:50:19 +0000430def loadi16 : PatFrag<(ops node:$ptr), (i16 (unindexedload node:$ptr)), [{
Dan Gohman67ca6be2008-08-20 15:24:22 +0000431 LoadSDNode *LD = cast<LoadSDNode>(N);
Chris Lattnerc2406f22009-04-10 00:16:23 +0000432 if (const Value *Src = LD->getSrcValue())
433 if (const PointerType *PT = dyn_cast<PointerType>(Src->getType()))
Mon P Wanga7e01d72009-04-27 07:22:10 +0000434 if (PT->getAddressSpace() > 255)
Chris Lattnerc2406f22009-04-10 00:16:23 +0000435 return false;
Dan Gohman67ca6be2008-08-20 15:24:22 +0000436 ISD::LoadExtType ExtType = LD->getExtensionType();
437 if (ExtType == ISD::NON_EXTLOAD)
438 return true;
439 if (ExtType == ISD::EXTLOAD)
440 return LD->getAlignment() >= 2 && !LD->isVolatile();
Evan Chengfa7fd332008-05-13 00:54:02 +0000441 return false;
442}]>;
443
Chris Lattnerf85eff72010-03-03 01:52:59 +0000444def loadi16_anyext : PatFrag<(ops node:$ptr), (i32 (unindexedload node:$ptr)),[{
Evan Chengca57f782008-09-24 23:27:55 +0000445 LoadSDNode *LD = cast<LoadSDNode>(N);
Chris Lattnerc2406f22009-04-10 00:16:23 +0000446 if (const Value *Src = LD->getSrcValue())
447 if (const PointerType *PT = dyn_cast<PointerType>(Src->getType()))
Mon P Wanga7e01d72009-04-27 07:22:10 +0000448 if (PT->getAddressSpace() > 255)
Chris Lattnerc2406f22009-04-10 00:16:23 +0000449 return false;
Evan Chengca57f782008-09-24 23:27:55 +0000450 ISD::LoadExtType ExtType = LD->getExtensionType();
451 if (ExtType == ISD::EXTLOAD)
452 return LD->getAlignment() >= 2 && !LD->isVolatile();
453 return false;
454}]>;
455
Dan Gohman33586292008-10-15 06:50:19 +0000456def loadi32 : PatFrag<(ops node:$ptr), (i32 (unindexedload node:$ptr)), [{
Dan Gohman67ca6be2008-08-20 15:24:22 +0000457 LoadSDNode *LD = cast<LoadSDNode>(N);
Chris Lattnerc2406f22009-04-10 00:16:23 +0000458 if (const Value *Src = LD->getSrcValue())
459 if (const PointerType *PT = dyn_cast<PointerType>(Src->getType()))
Mon P Wanga7e01d72009-04-27 07:22:10 +0000460 if (PT->getAddressSpace() > 255)
Chris Lattnerc2406f22009-04-10 00:16:23 +0000461 return false;
Dan Gohman67ca6be2008-08-20 15:24:22 +0000462 ISD::LoadExtType ExtType = LD->getExtensionType();
463 if (ExtType == ISD::NON_EXTLOAD)
464 return true;
465 if (ExtType == ISD::EXTLOAD)
466 return LD->getAlignment() >= 4 && !LD->isVolatile();
Evan Chengfa7fd332008-05-13 00:54:02 +0000467 return false;
468}]>;
469
Chris Lattnerf85eff72010-03-03 01:52:59 +0000470def loadi8 : PatFrag<(ops node:$ptr), (i8 (dsload node:$ptr))>;
471def loadi64 : PatFrag<(ops node:$ptr), (i64 (dsload node:$ptr))>;
472def loadf32 : PatFrag<(ops node:$ptr), (f32 (dsload node:$ptr))>;
473def loadf64 : PatFrag<(ops node:$ptr), (f64 (dsload node:$ptr))>;
474def loadf80 : PatFrag<(ops node:$ptr), (f80 (dsload node:$ptr))>;
Evan Cheng7a7e8372005-12-14 02:22:27 +0000475
Evan Cheng466685d2006-10-09 20:57:25 +0000476def sextloadi16i8 : PatFrag<(ops node:$ptr), (i16 (sextloadi8 node:$ptr))>;
477def sextloadi32i8 : PatFrag<(ops node:$ptr), (i32 (sextloadi8 node:$ptr))>;
478def sextloadi32i16 : PatFrag<(ops node:$ptr), (i32 (sextloadi16 node:$ptr))>;
Evan Cheng7a7e8372005-12-14 02:22:27 +0000479
Evan Cheng466685d2006-10-09 20:57:25 +0000480def zextloadi8i1 : PatFrag<(ops node:$ptr), (i8 (zextloadi1 node:$ptr))>;
481def zextloadi16i1 : PatFrag<(ops node:$ptr), (i16 (zextloadi1 node:$ptr))>;
482def zextloadi32i1 : PatFrag<(ops node:$ptr), (i32 (zextloadi1 node:$ptr))>;
483def zextloadi16i8 : PatFrag<(ops node:$ptr), (i16 (zextloadi8 node:$ptr))>;
484def zextloadi32i8 : PatFrag<(ops node:$ptr), (i32 (zextloadi8 node:$ptr))>;
485def zextloadi32i16 : PatFrag<(ops node:$ptr), (i32 (zextloadi16 node:$ptr))>;
Evan Cheng7a7e8372005-12-14 02:22:27 +0000486
Evan Cheng466685d2006-10-09 20:57:25 +0000487def extloadi8i1 : PatFrag<(ops node:$ptr), (i8 (extloadi1 node:$ptr))>;
488def extloadi16i1 : PatFrag<(ops node:$ptr), (i16 (extloadi1 node:$ptr))>;
489def extloadi32i1 : PatFrag<(ops node:$ptr), (i32 (extloadi1 node:$ptr))>;
490def extloadi16i8 : PatFrag<(ops node:$ptr), (i16 (extloadi8 node:$ptr))>;
491def extloadi32i8 : PatFrag<(ops node:$ptr), (i32 (extloadi8 node:$ptr))>;
492def extloadi32i16 : PatFrag<(ops node:$ptr), (i32 (extloadi16 node:$ptr))>;
Evan Cheng747a90d2006-02-21 02:24:38 +0000493
Chris Lattnerce2bcc82008-02-19 17:37:35 +0000494
495// An 'and' node with a single use.
496def and_su : PatFrag<(ops node:$lhs, node:$rhs), (and node:$lhs, node:$rhs), [{
Evan Cheng07b7ea12008-03-04 00:40:35 +0000497 return N->hasOneUse();
Chris Lattnerce2bcc82008-02-19 17:37:35 +0000498}]>;
Dan Gohman21e3dfb2009-04-13 16:09:41 +0000499// An 'srl' node with a single use.
500def srl_su : PatFrag<(ops node:$lhs, node:$rhs), (srl node:$lhs, node:$rhs), [{
501 return N->hasOneUse();
502}]>;
503// An 'trunc' node with a single use.
504def trunc_su : PatFrag<(ops node:$src), (trunc node:$src), [{
505 return N->hasOneUse();
506}]>;
Chris Lattnerce2bcc82008-02-19 17:37:35 +0000507
Evan Cheng4b0345b2010-01-11 17:03:47 +0000508// Treat an 'or' node is as an 'add' if the or'ed bits are known to be zero.
509def or_is_add : PatFrag<(ops node:$lhs, node:$rhs), (or node:$lhs, node:$rhs),[{
510 if (ConstantSDNode *CN = dyn_cast<ConstantSDNode>(N->getOperand(1)))
511 return CurDAG->MaskedValueIsZero(N->getOperand(0), CN->getAPIntValue());
Chris Lattnerfdac0b62010-03-24 00:12:57 +0000512
513 unsigned BitWidth = N->getValueType(0).getScalarType().getSizeInBits();
514 APInt Mask = APInt::getAllOnesValue(BitWidth);
515 APInt KnownZero0, KnownOne0;
516 CurDAG->ComputeMaskedBits(N->getOperand(0), Mask, KnownZero0, KnownOne0, 0);
517 APInt KnownZero1, KnownOne1;
518 CurDAG->ComputeMaskedBits(N->getOperand(1), Mask, KnownZero1, KnownOne1, 0);
519 return (~KnownZero0 & ~KnownZero1) == 0;
Evan Cheng4b0345b2010-01-11 17:03:47 +0000520}]>;
Evan Cheng4b0345b2010-01-11 17:03:47 +0000521
Chris Lattnerf124d5e2005-11-18 01:04:42 +0000522//===----------------------------------------------------------------------===//
Chris Lattner1cca5e32003-08-03 21:54:21 +0000523// Instruction list...
524//
525
Chris Lattnerf18c0742006-10-12 17:42:56 +0000526// ADJCALLSTACKDOWN/UP implicitly use/def ESP because they may be expanded into
527// a stack adjustment and the codegen must know that they may modify the stack
528// pointer before prolog-epilog rewriting occurs.
Chris Lattner447ff682008-03-11 03:23:40 +0000529// Pessimistically assume ADJCALLSTACKDOWN / ADJCALLSTACKUP will become
530// sub / add which can clobber EFLAGS.
Evan Cheng8decf6b2007-09-28 01:19:48 +0000531let Defs = [ESP, EFLAGS], Uses = [ESP] in {
Dan Gohman6d4b0522008-10-01 18:28:06 +0000532def ADJCALLSTACKDOWN32 : I<0, Pseudo, (outs), (ins i32imm:$amt),
533 "#ADJCALLSTACKDOWN",
Chris Lattnere563bbc2008-10-11 22:08:30 +0000534 [(X86callseq_start timm:$amt)]>,
Dan Gohman6d4b0522008-10-01 18:28:06 +0000535 Requires<[In32BitMode]>;
536def ADJCALLSTACKUP32 : I<0, Pseudo, (outs), (ins i32imm:$amt1, i32imm:$amt2),
537 "#ADJCALLSTACKUP",
Chris Lattnere563bbc2008-10-11 22:08:30 +0000538 [(X86callseq_end timm:$amt1, timm:$amt2)]>,
Dan Gohman6d4b0522008-10-01 18:28:06 +0000539 Requires<[In32BitMode]>;
Evan Cheng071a2792007-09-11 19:55:27 +0000540}
Evan Cheng4a460802006-01-11 00:33:36 +0000541
Dan Gohmand6708ea2009-08-15 01:38:56 +0000542// x86-64 va_start lowering magic.
Anton Korobeynikov043f3c22010-03-06 19:32:29 +0000543let usesCustomInserter = 1 in {
Dan Gohmand6708ea2009-08-15 01:38:56 +0000544def VASTART_SAVE_XMM_REGS : I<0, Pseudo,
545 (outs),
546 (ins GR8:$al,
547 i64imm:$regsavefi, i64imm:$offset,
548 variable_ops),
549 "#VASTART_SAVE_XMM_REGS $al, $regsavefi, $offset",
550 [(X86vastart_save_xmm_regs GR8:$al,
551 imm:$regsavefi,
552 imm:$offset)]>;
553
Anton Korobeynikove765f2b2010-03-06 20:07:32 +0000554// Dynamic stack allocation yields _alloca call for Cygwin/Mingw targets. Calls
555// to _alloca is needed to probe the stack when allocating more than 4k bytes in
556// one go. Touching the stack at 4K increments is necessary to ensure that the
557// guard pages used by the OS virtual memory manager are allocated in correct
558// sequence.
559// The main point of having separate instruction are extra unmodelled effects
560// (compared to ordinary calls) like stack pointer change.
561
Anton Korobeynikov043f3c22010-03-06 19:32:29 +0000562def MINGW_ALLOCA : I<0, Pseudo, (outs), (ins),
Anton Korobeynikove765f2b2010-03-06 20:07:32 +0000563 "# dynamic stack allocation",
Anton Korobeynikov043f3c22010-03-06 19:32:29 +0000564 [(X86MingwAlloca)]>;
565}
566
Evan Cheng4a460802006-01-11 00:33:36 +0000567// Nop
Sean Callanan74e52102009-07-23 23:39:34 +0000568let neverHasSideEffects = 1 in {
Chris Lattnerba7e7562008-01-10 07:59:24 +0000569 def NOOP : I<0x90, RawFrm, (outs), (ins), "nop", []>;
Sean Callanan108934c2009-12-18 00:01:26 +0000570 def NOOPW : I<0x1f, MRM0m, (outs), (ins i16mem:$zero),
571 "nop{w}\t$zero", []>, TB, OpSize;
Sean Callanan74e52102009-07-23 23:39:34 +0000572 def NOOPL : I<0x1f, MRM0m, (outs), (ins i32mem:$zero),
Sean Callanan108934c2009-12-18 00:01:26 +0000573 "nop{l}\t$zero", []>, TB;
Sean Callanan74e52102009-07-23 23:39:34 +0000574}
Evan Cheng4a460802006-01-11 00:33:36 +0000575
Sean Callanan1c5cf1b2009-08-11 01:09:06 +0000576// Trap
Kevin Enderbyc3ce05c2010-05-14 19:16:02 +0000577def INTO : I<0xce, RawFrm, (outs), (ins), "into", []>;
578def INT3 : I<0xcc, RawFrm, (outs), (ins), "int3", []>;
579// FIXME: need to make sure that "int $3" matches int3
580def INT : Ii8<0xcd, RawFrm, (outs), (ins i8imm:$trap), "int\t$trap", []>;
Sean Callanan108934c2009-12-18 00:01:26 +0000581def IRET16 : I<0xcf, RawFrm, (outs), (ins), "iret{w}", []>, OpSize;
582def IRET32 : I<0xcf, RawFrm, (outs), (ins), "iret{l}", []>;
Sean Callanan1c5cf1b2009-08-11 01:09:06 +0000583
Chris Lattner71c7ace2009-09-20 07:32:00 +0000584// PIC base construction. This expands to code that looks like this:
585// call $next_inst
586// popl %destreg"
Dan Gohman2662d552008-10-01 04:14:30 +0000587let neverHasSideEffects = 1, isNotDuplicable = 1, Uses = [ESP] in
Chris Lattnerb3c85472009-09-20 07:28:26 +0000588 def MOVPC32r : Ii32<0xE8, Pseudo, (outs GR32:$reg), (ins i32imm:$label),
Chris Lattner71c7ace2009-09-20 07:32:00 +0000589 "", []>;
Evan Cheng8f7f7122006-05-05 05:40:20 +0000590
Chris Lattner1cca5e32003-08-03 21:54:21 +0000591//===----------------------------------------------------------------------===//
Chris Lattnerbd13fb62010-02-11 19:25:55 +0000592// Control Flow Instructions.
Chris Lattner1cca5e32003-08-03 21:54:21 +0000593//
594
Chris Lattner1be48112005-05-13 17:56:48 +0000595// Return instructions.
Evan Cheng2b4ea792005-12-26 09:11:45 +0000596let isTerminator = 1, isReturn = 1, isBarrier = 1,
Jakob Stoklund Olesen70feca42010-03-25 18:52:01 +0000597 hasCtrlDep = 1, FPForm = SpecialFP in {
Dan Gohmane4c67cd2008-05-31 02:11:25 +0000598 def RET : I <0xC3, RawFrm, (outs), (ins variable_ops),
Chris Lattner447ff682008-03-11 03:23:40 +0000599 "ret",
Dan Gohmane4c67cd2008-05-31 02:11:25 +0000600 [(X86retflag 0)]>;
Chris Lattner447ff682008-03-11 03:23:40 +0000601 def RETI : Ii16<0xC2, RawFrm, (outs), (ins i16imm:$amt, variable_ops),
602 "ret\t$amt",
Dan Gohman2f67df72009-09-03 17:18:51 +0000603 [(X86retflag timm:$amt)]>;
Sean Callanan356aed52009-09-15 23:37:51 +0000604 def LRET : I <0xCB, RawFrm, (outs), (ins),
605 "lret", []>;
606 def LRETI : Ii16<0xCA, RawFrm, (outs), (ins i16imm:$amt),
607 "lret\t$amt", []>;
Evan Cheng171049d2005-12-23 22:14:32 +0000608}
Chris Lattner1cca5e32003-08-03 21:54:21 +0000609
Chris Lattnerbd13fb62010-02-11 19:25:55 +0000610// Unconditional branches.
Chris Lattnerb8db3312010-02-11 21:45:31 +0000611let isBarrier = 1, isBranch = 1, isTerminator = 1 in {
Chris Lattnera0331192010-02-12 22:27:07 +0000612 def JMP_4 : Ii32PCRel<0xE9, RawFrm, (outs), (ins brtarget:$dst),
613 "jmp\t$dst", [(br bb:$dst)]>;
614 def JMP_1 : Ii8PCRel<0xEB, RawFrm, (outs), (ins brtarget8:$dst),
615 "jmp\t$dst", []>;
Sean Callanan52925882009-07-22 01:05:20 +0000616}
Evan Cheng898101c2005-12-19 23:12:38 +0000617
Chris Lattnerbd13fb62010-02-11 19:25:55 +0000618// Conditional Branches.
619let isBranch = 1, isTerminator = 1, Uses = [EFLAGS] in {
620 multiclass ICBr<bits<8> opc1, bits<8> opc4, string asm, PatFrag Cond> {
Chris Lattnera0331192010-02-12 22:27:07 +0000621 def _1 : Ii8PCRel <opc1, RawFrm, (outs), (ins brtarget8:$dst), asm, []>;
622 def _4 : Ii32PCRel<opc4, RawFrm, (outs), (ins brtarget:$dst), asm,
623 [(X86brcond bb:$dst, Cond, EFLAGS)]>, TB;
Chris Lattnerbd13fb62010-02-11 19:25:55 +0000624 }
625}
626
627defm JO : ICBr<0x70, 0x80, "jo\t$dst" , X86_COND_O>;
Chris Lattner8b442a82010-02-11 19:52:11 +0000628defm JNO : ICBr<0x71, 0x81, "jno\t$dst" , X86_COND_NO>;
Chris Lattnerbd13fb62010-02-11 19:25:55 +0000629defm JB : ICBr<0x72, 0x82, "jb\t$dst" , X86_COND_B>;
630defm JAE : ICBr<0x73, 0x83, "jae\t$dst", X86_COND_AE>;
631defm JE : ICBr<0x74, 0x84, "je\t$dst" , X86_COND_E>;
632defm JNE : ICBr<0x75, 0x85, "jne\t$dst", X86_COND_NE>;
633defm JBE : ICBr<0x76, 0x86, "jbe\t$dst", X86_COND_BE>;
634defm JA : ICBr<0x77, 0x87, "ja\t$dst" , X86_COND_A>;
635defm JS : ICBr<0x78, 0x88, "js\t$dst" , X86_COND_S>;
636defm JNS : ICBr<0x79, 0x89, "jns\t$dst", X86_COND_NS>;
637defm JP : ICBr<0x7A, 0x8A, "jp\t$dst" , X86_COND_P>;
638defm JNP : ICBr<0x7B, 0x8B, "jnp\t$dst", X86_COND_NP>;
639defm JL : ICBr<0x7C, 0x8C, "jl\t$dst" , X86_COND_L>;
640defm JGE : ICBr<0x7D, 0x8D, "jge\t$dst", X86_COND_GE>;
641defm JLE : ICBr<0x7E, 0x8E, "jle\t$dst", X86_COND_LE>;
642defm JG : ICBr<0x7F, 0x8F, "jg\t$dst" , X86_COND_G>;
643
644// FIXME: What about the CX/RCX versions of this instruction?
Chris Lattnerb8db3312010-02-11 21:45:31 +0000645let Uses = [ECX], isBranch = 1, isTerminator = 1 in
Chris Lattnera0331192010-02-12 22:27:07 +0000646 def JCXZ8 : Ii8PCRel<0xE3, RawFrm, (outs), (ins brtarget8:$dst),
647 "jcxz\t$dst", []>;
Chris Lattnerbd13fb62010-02-11 19:25:55 +0000648
649
Owen Anderson20ab2902007-11-12 07:39:39 +0000650// Indirect branches
651let isBranch = 1, isTerminator = 1, isBarrier = 1, isIndirectBranch = 1 in {
Dan Gohmanb1576f52007-07-31 20:11:57 +0000652 def JMP32r : I<0xFF, MRM4r, (outs), (ins GR32:$dst), "jmp{l}\t{*}$dst",
Daniel Dunbar77e2dd72010-07-19 20:44:16 +0000653 [(brind GR32:$dst)]>, Requires<[In32BitMode]>;
Dan Gohmanb1576f52007-07-31 20:11:57 +0000654 def JMP32m : I<0xFF, MRM4m, (outs), (ins i32mem:$dst), "jmp{l}\t{*}$dst",
Daniel Dunbar77e2dd72010-07-19 20:44:16 +0000655 [(brind (loadi32 addr:$dst))]>, Requires<[In32BitMode]>;
Sean Callanan76f14be2009-09-15 00:35:17 +0000656
657 def FARJMP16i : Iseg16<0xEA, RawFrm, (outs),
658 (ins i16imm:$seg, i16imm:$off),
659 "ljmp{w}\t$seg, $off", []>, OpSize;
660 def FARJMP32i : Iseg32<0xEA, RawFrm, (outs),
661 (ins i16imm:$seg, i32imm:$off),
662 "ljmp{l}\t$seg, $off", []>;
663
664 def FARJMP16m : I<0xFF, MRM5m, (outs), (ins opaque32mem:$dst),
Sean Callanan9947bbb2009-09-03 00:04:47 +0000665 "ljmp{w}\t{*}$dst", []>, OpSize;
Sean Callanan76f14be2009-09-15 00:35:17 +0000666 def FARJMP32m : I<0xFF, MRM5m, (outs), (ins opaque48mem:$dst),
Sean Callanan9947bbb2009-09-03 00:04:47 +0000667 "ljmp{l}\t{*}$dst", []>;
Nate Begeman37efe672006-04-22 18:53:45 +0000668}
669
Chris Lattner1cca5e32003-08-03 21:54:21 +0000670
Sean Callanan7e6d7272009-09-16 21:50:07 +0000671// Loop instructions
672
Chris Lattner34b8a882010-03-18 20:50:06 +0000673def LOOP : I<0xE2, RawFrm, (outs), (ins brtarget8:$dst), "loop\t$dst", []>;
674def LOOPE : I<0xE1, RawFrm, (outs), (ins brtarget8:$dst), "loope\t$dst", []>;
675def LOOPNE : I<0xE0, RawFrm, (outs), (ins brtarget8:$dst), "loopne\t$dst", []>;
Sean Callanan7e6d7272009-09-16 21:50:07 +0000676
Chris Lattner1cca5e32003-08-03 21:54:21 +0000677//===----------------------------------------------------------------------===//
678// Call Instructions...
679//
Evan Chengffbacca2007-07-21 00:34:19 +0000680let isCall = 1 in
Dan Gohman6d4b0522008-10-01 18:28:06 +0000681 // All calls clobber the non-callee saved registers. ESP is marked as
682 // a use to prevent stack-pointer assignments that appear immediately
683 // before calls from potentially appearing dead. Uses for argument
684 // registers are added manually.
Nate Begemanf63be7d2005-07-06 18:59:04 +0000685 let Defs = [EAX, ECX, EDX, FP0, FP1, FP2, FP3, FP4, FP5, FP6, ST0,
Bill Wendling3f3a17d2007-04-25 21:31:48 +0000686 MM0, MM1, MM2, MM3, MM4, MM5, MM6, MM7,
Evan Cheng109a5622008-10-17 21:02:22 +0000687 XMM0, XMM1, XMM2, XMM3, XMM4, XMM5, XMM6, XMM7,
688 XMM8, XMM9, XMM10, XMM11, XMM12, XMM13, XMM14, XMM15, EFLAGS],
Dan Gohman2662d552008-10-01 04:14:30 +0000689 Uses = [ESP] in {
Chris Lattnera0331192010-02-12 22:27:07 +0000690 def CALLpcrel32 : Ii32PCRel<0xE8, RawFrm,
Chris Lattner7680e732009-06-20 19:34:09 +0000691 (outs), (ins i32imm_pcrel:$dst,variable_ops),
692 "call\t$dst", []>;
Evan Cheng64d80e32007-07-19 01:14:50 +0000693 def CALL32r : I<0xFF, MRM2r, (outs), (ins GR32:$dst, variable_ops),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000694 "call\t{*}$dst", [(X86call GR32:$dst)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +0000695 def CALL32m : I<0xFF, MRM2m, (outs), (ins i32mem:$dst, variable_ops),
Dan Gohmanb4106172008-05-29 21:50:34 +0000696 "call\t{*}$dst", [(X86call (loadi32 addr:$dst))]>;
Sean Callanan9947bbb2009-09-03 00:04:47 +0000697
Sean Callanan76f14be2009-09-15 00:35:17 +0000698 def FARCALL16i : Iseg16<0x9A, RawFrm, (outs),
699 (ins i16imm:$seg, i16imm:$off),
700 "lcall{w}\t$seg, $off", []>, OpSize;
701 def FARCALL32i : Iseg32<0x9A, RawFrm, (outs),
702 (ins i16imm:$seg, i32imm:$off),
703 "lcall{l}\t$seg, $off", []>;
704
705 def FARCALL16m : I<0xFF, MRM3m, (outs), (ins opaque32mem:$dst),
Sean Callanan9947bbb2009-09-03 00:04:47 +0000706 "lcall{w}\t{*}$dst", []>, OpSize;
Sean Callanan76f14be2009-09-15 00:35:17 +0000707 def FARCALL32m : I<0xFF, MRM3m, (outs), (ins opaque48mem:$dst),
Sean Callanan9947bbb2009-09-03 00:04:47 +0000708 "lcall{l}\t{*}$dst", []>;
Chris Lattner9fc05222010-07-07 22:27:31 +0000709
710 // callw for 16 bit code for the assembler.
711 let isAsmParserOnly = 1 in
712 def CALLpcrel16 : Ii16PCRel<0xE8, RawFrm,
713 (outs), (ins i16imm_pcrel:$dst, variable_ops),
714 "callw\t$dst", []>, OpSize;
Chris Lattner1cca5e32003-08-03 21:54:21 +0000715 }
716
Sean Callanan8d708542009-09-16 02:57:13 +0000717// Constructing a stack frame.
718
719def ENTER : I<0xC8, RawFrm, (outs), (ins i16imm:$len, i8imm:$lvl),
720 "enter\t$len, $lvl", []>;
721
Chris Lattner1e9448b2005-05-15 03:10:37 +0000722// Tail call stuff.
Arnold Schwaighoferc85e1712007-10-11 19:40:01 +0000723
Daniel Dunbare4c52a22010-07-19 07:21:04 +0000724let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1,
725 isCodeGenOnly = 1 in
Evan Chengf48ef032010-03-14 03:48:46 +0000726 let Defs = [EAX, ECX, EDX, FP0, FP1, FP2, FP3, FP4, FP5, FP6, ST0,
727 MM0, MM1, MM2, MM3, MM4, MM5, MM6, MM7,
728 XMM0, XMM1, XMM2, XMM3, XMM4, XMM5, XMM6, XMM7,
729 XMM8, XMM9, XMM10, XMM11, XMM12, XMM13, XMM14, XMM15, EFLAGS],
730 Uses = [ESP] in {
731 def TCRETURNdi : I<0, Pseudo, (outs),
732 (ins i32imm_pcrel:$dst, i32imm:$offset, variable_ops),
733 "#TC_RETURN $dst $offset", []>;
734 def TCRETURNri : I<0, Pseudo, (outs),
735 (ins GR32_TC:$dst, i32imm:$offset, variable_ops),
736 "#TC_RETURN $dst $offset", []>;
Dan Gohman7f357ec2010-05-14 16:34:55 +0000737 let mayLoad = 1 in
Evan Chengf48ef032010-03-14 03:48:46 +0000738 def TCRETURNmi : I<0, Pseudo, (outs),
739 (ins i32mem_TC:$dst, i32imm:$offset, variable_ops),
740 "#TC_RETURN $dst $offset", []>;
Arnold Schwaighoferc85e1712007-10-11 19:40:01 +0000741
Evan Chengf48ef032010-03-14 03:48:46 +0000742 // FIXME: The should be pseudo instructions that are lowered when going to
743 // mcinst.
Chris Lattner840e6372010-03-16 06:30:18 +0000744 def TAILJMPd : Ii32PCRel<0xE9, RawFrm, (outs),
745 (ins i32imm_pcrel:$dst, variable_ops),
Evan Chengaa92bec2010-01-31 07:28:44 +0000746 "jmp\t$dst # TAILCALL",
Evan Chengf10c17f2006-09-22 21:43:59 +0000747 []>;
Evan Chengf48ef032010-03-14 03:48:46 +0000748 def TAILJMPr : I<0xFF, MRM4r, (outs), (ins GR32_TC:$dst, variable_ops),
Chris Lattnerc5f56262010-07-09 00:49:41 +0000749 "", []>; // FIXME: Remove encoding when JIT is dead.
Dan Gohman7f357ec2010-05-14 16:34:55 +0000750 let mayLoad = 1 in
Evan Chengf48ef032010-03-14 03:48:46 +0000751 def TAILJMPm : I<0xFF, MRM4m, (outs), (ins i32mem_TC:$dst, variable_ops),
752 "jmp{l}\t{*}$dst # TAILCALL", []>;
753}
Chris Lattner1e9448b2005-05-15 03:10:37 +0000754
Chris Lattner1cca5e32003-08-03 21:54:21 +0000755//===----------------------------------------------------------------------===//
756// Miscellaneous Instructions...
757//
Chris Lattnerba7e7562008-01-10 07:59:24 +0000758let Defs = [EBP, ESP], Uses = [EBP, ESP], mayLoad = 1, neverHasSideEffects=1 in
Chris Lattner30bf2d82004-08-10 20:17:41 +0000759def LEAVE : I<0xC9, RawFrm,
Daniel Dunbardf4c47b2010-07-19 07:21:01 +0000760 (outs), (ins), "leave", []>, Requires<[In32BitMode]>;
Evan Cheng071a2792007-09-11 19:55:27 +0000761
Sean Callanan108934c2009-12-18 00:01:26 +0000762def POPCNT16rr : I<0xB8, MRMSrcReg, (outs GR16:$dst), (ins GR16:$src),
763 "popcnt{w}\t{$src, $dst|$dst, $src}", []>, OpSize, XS;
Dan Gohman7f357ec2010-05-14 16:34:55 +0000764let mayLoad = 1 in
Sean Callanan108934c2009-12-18 00:01:26 +0000765def POPCNT16rm : I<0xB8, MRMSrcMem, (outs GR16:$dst), (ins i16mem:$src),
766 "popcnt{w}\t{$src, $dst|$dst, $src}", []>, OpSize, XS;
767def POPCNT32rr : I<0xB8, MRMSrcReg, (outs GR32:$dst), (ins GR32:$src),
768 "popcnt{l}\t{$src, $dst|$dst, $src}", []>, XS;
Dan Gohman7f357ec2010-05-14 16:34:55 +0000769let mayLoad = 1 in
Sean Callanan108934c2009-12-18 00:01:26 +0000770def POPCNT32rm : I<0xB8, MRMSrcMem, (outs GR32:$dst), (ins i32mem:$src),
771 "popcnt{l}\t{$src, $dst|$dst, $src}", []>, XS;
772
Chris Lattnerba7e7562008-01-10 07:59:24 +0000773let Defs = [ESP], Uses = [ESP], neverHasSideEffects=1 in {
Sean Callanan1f24e012009-09-10 18:29:13 +0000774let mayLoad = 1 in {
775def POP16r : I<0x58, AddRegFrm, (outs GR16:$reg), (ins), "pop{w}\t$reg", []>,
776 OpSize;
777def POP32r : I<0x58, AddRegFrm, (outs GR32:$reg), (ins), "pop{l}\t$reg", []>;
778def POP16rmr: I<0x8F, MRM0r, (outs GR16:$reg), (ins), "pop{w}\t$reg", []>,
779 OpSize;
780def POP16rmm: I<0x8F, MRM0m, (outs i16mem:$dst), (ins), "pop{w}\t$dst", []>,
781 OpSize;
782def POP32rmr: I<0x8F, MRM0r, (outs GR32:$reg), (ins), "pop{l}\t$reg", []>;
783def POP32rmm: I<0x8F, MRM0m, (outs i32mem:$dst), (ins), "pop{l}\t$dst", []>;
784}
Chris Lattner1cca5e32003-08-03 21:54:21 +0000785
Sean Callanan1f24e012009-09-10 18:29:13 +0000786let mayStore = 1 in {
787def PUSH16r : I<0x50, AddRegFrm, (outs), (ins GR16:$reg), "push{w}\t$reg",[]>,
788 OpSize;
Evan Cheng2f245ba2007-09-26 01:29:06 +0000789def PUSH32r : I<0x50, AddRegFrm, (outs), (ins GR32:$reg), "push{l}\t$reg",[]>;
Sean Callanan1f24e012009-09-10 18:29:13 +0000790def PUSH16rmr: I<0xFF, MRM6r, (outs), (ins GR16:$reg), "push{w}\t$reg",[]>,
791 OpSize;
792def PUSH16rmm: I<0xFF, MRM6m, (outs), (ins i16mem:$src), "push{w}\t$src",[]>,
793 OpSize;
794def PUSH32rmr: I<0xFF, MRM6r, (outs), (ins GR32:$reg), "push{l}\t$reg",[]>;
795def PUSH32rmm: I<0xFF, MRM6m, (outs), (ins i32mem:$src), "push{l}\t$src",[]>;
796}
Evan Cheng071a2792007-09-11 19:55:27 +0000797}
Anton Korobeynikov57fc00d2007-04-17 09:20:00 +0000798
Bill Wendling453eb262009-06-15 19:39:04 +0000799let Defs = [ESP], Uses = [ESP], neverHasSideEffects = 1, mayStore = 1 in {
Kevin Enderby3c979b02010-05-03 20:45:05 +0000800def PUSHi8 : Ii8<0x6a, RawFrm, (outs), (ins i32i8imm:$imm),
Bill Wendling927788c2009-06-15 20:59:31 +0000801 "push{l}\t$imm", []>;
Kevin Enderby3c979b02010-05-03 20:45:05 +0000802def PUSHi16 : Ii16<0x68, RawFrm, (outs), (ins i16imm:$imm),
803 "push{w}\t$imm", []>, OpSize;
804def PUSHi32 : Ii32<0x68, RawFrm, (outs), (ins i32imm:$imm),
Bill Wendling927788c2009-06-15 20:59:31 +0000805 "push{l}\t$imm", []>;
Bill Wendling453eb262009-06-15 19:39:04 +0000806}
807
Sean Callanan108934c2009-12-18 00:01:26 +0000808let Defs = [ESP, EFLAGS], Uses = [ESP], mayLoad = 1, neverHasSideEffects=1 in {
Dan Gohmane5e4ff92010-05-20 16:16:00 +0000809def POPF16 : I<0x9D, RawFrm, (outs), (ins), "popf{w}", []>, OpSize;
810def POPF32 : I<0x9D, RawFrm, (outs), (ins), "popf{l|d}", []>,
811 Requires<[In32BitMode]>;
Sean Callanan108934c2009-12-18 00:01:26 +0000812}
813let Defs = [ESP], Uses = [ESP, EFLAGS], mayStore = 1, neverHasSideEffects=1 in {
Dan Gohmane5e4ff92010-05-20 16:16:00 +0000814def PUSHF16 : I<0x9C, RawFrm, (outs), (ins), "pushf{w}", []>, OpSize;
815def PUSHF32 : I<0x9C, RawFrm, (outs), (ins), "pushf{l|d}", []>,
816 Requires<[In32BitMode]>;
Sean Callanan108934c2009-12-18 00:01:26 +0000817}
Evan Cheng2f245ba2007-09-26 01:29:06 +0000818
Nico Weber50b9efc2010-06-23 20:00:58 +0000819let Defs = [EDI, ESI, EBP, EBX, EDX, ECX, EAX, ESP], Uses = [ESP],
820 mayLoad=1, neverHasSideEffects=1 in {
821def POPA32 : I<0x61, RawFrm, (outs), (ins), "popa{l}", []>,
822 Requires<[In32BitMode]>;
823}
824let Defs = [ESP], Uses = [EDI, ESI, EBP, EBX, EDX, ECX, EAX, ESP],
825 mayStore=1, neverHasSideEffects=1 in {
826def PUSHA32 : I<0x60, RawFrm, (outs), (ins), "pusha{l}", []>,
827 Requires<[In32BitMode]>;
828}
829
Eric Christophera938cfb2010-06-19 00:37:40 +0000830let Uses = [EFLAGS], Constraints = "$src = $dst" in // GR32 = bswap GR32
Chris Lattner30bf2d82004-08-10 20:17:41 +0000831 def BSWAP32r : I<0xC8, AddRegFrm,
Evan Cheng64d80e32007-07-19 01:14:50 +0000832 (outs GR32:$dst), (ins GR32:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000833 "bswap{l}\t$dst",
Evan Cheng069287d2006-05-16 07:21:53 +0000834 [(set GR32:$dst, (bswap GR32:$src))]>, TB;
Chris Lattner1cca5e32003-08-03 21:54:21 +0000835
Chris Lattner1cca5e32003-08-03 21:54:21 +0000836
Evan Cheng18efe262007-12-14 02:13:44 +0000837// Bit scan instructions.
838let Defs = [EFLAGS] in {
Evan Chengfd9e4732007-12-14 18:49:43 +0000839def BSF16rr : I<0xBC, MRMSrcReg, (outs GR16:$dst), (ins GR16:$src),
Dan Gohman1a8001e2007-12-14 15:10:00 +0000840 "bsf{w}\t{$src, $dst|$dst, $src}",
Kevin Enderby9ac72822010-04-28 23:20:40 +0000841 [(set GR16:$dst, EFLAGS, (X86bsf GR16:$src))]>, TB, OpSize;
Evan Cheng18efe262007-12-14 02:13:44 +0000842def BSF16rm : I<0xBC, MRMSrcMem, (outs GR16:$dst), (ins i16mem:$src),
Dan Gohman1a8001e2007-12-14 15:10:00 +0000843 "bsf{w}\t{$src, $dst|$dst, $src}",
Kevin Enderby9ac72822010-04-28 23:20:40 +0000844 [(set GR16:$dst, EFLAGS, (X86bsf (loadi16 addr:$src)))]>, TB,
845 OpSize;
Evan Chengfd9e4732007-12-14 18:49:43 +0000846def BSF32rr : I<0xBC, MRMSrcReg, (outs GR32:$dst), (ins GR32:$src),
Dan Gohman1a8001e2007-12-14 15:10:00 +0000847 "bsf{l}\t{$src, $dst|$dst, $src}",
Chris Lattnerd486d772010-03-28 05:07:17 +0000848 [(set GR32:$dst, EFLAGS, (X86bsf GR32:$src))]>, TB;
Evan Cheng18efe262007-12-14 02:13:44 +0000849def BSF32rm : I<0xBC, MRMSrcMem, (outs GR32:$dst), (ins i32mem:$src),
Dan Gohman1a8001e2007-12-14 15:10:00 +0000850 "bsf{l}\t{$src, $dst|$dst, $src}",
Chris Lattnerd486d772010-03-28 05:07:17 +0000851 [(set GR32:$dst, EFLAGS, (X86bsf (loadi32 addr:$src)))]>, TB;
Evan Cheng18efe262007-12-14 02:13:44 +0000852
Evan Chengfd9e4732007-12-14 18:49:43 +0000853def BSR16rr : I<0xBD, MRMSrcReg, (outs GR16:$dst), (ins GR16:$src),
Dan Gohman1a8001e2007-12-14 15:10:00 +0000854 "bsr{w}\t{$src, $dst|$dst, $src}",
Kevin Enderby9ac72822010-04-28 23:20:40 +0000855 [(set GR16:$dst, EFLAGS, (X86bsr GR16:$src))]>, TB, OpSize;
Evan Cheng18efe262007-12-14 02:13:44 +0000856def BSR16rm : I<0xBD, MRMSrcMem, (outs GR16:$dst), (ins i16mem:$src),
Dan Gohman1a8001e2007-12-14 15:10:00 +0000857 "bsr{w}\t{$src, $dst|$dst, $src}",
Kevin Enderby9ac72822010-04-28 23:20:40 +0000858 [(set GR16:$dst, EFLAGS, (X86bsr (loadi16 addr:$src)))]>, TB,
859 OpSize;
Evan Chengfd9e4732007-12-14 18:49:43 +0000860def BSR32rr : I<0xBD, MRMSrcReg, (outs GR32:$dst), (ins GR32:$src),
Dan Gohman1a8001e2007-12-14 15:10:00 +0000861 "bsr{l}\t{$src, $dst|$dst, $src}",
Chris Lattnerd486d772010-03-28 05:07:17 +0000862 [(set GR32:$dst, EFLAGS, (X86bsr GR32:$src))]>, TB;
Evan Cheng18efe262007-12-14 02:13:44 +0000863def BSR32rm : I<0xBD, MRMSrcMem, (outs GR32:$dst), (ins i32mem:$src),
Dan Gohman1a8001e2007-12-14 15:10:00 +0000864 "bsr{l}\t{$src, $dst|$dst, $src}",
Chris Lattnerd486d772010-03-28 05:07:17 +0000865 [(set GR32:$dst, EFLAGS, (X86bsr (loadi32 addr:$src)))]>, TB;
Evan Cheng18efe262007-12-14 02:13:44 +0000866} // Defs = [EFLAGS]
867
Chris Lattnerba7e7562008-01-10 07:59:24 +0000868let neverHasSideEffects = 1 in
Chris Lattner3a173df2004-10-03 20:35:00 +0000869def LEA16r : I<0x8D, MRMSrcMem,
Chris Lattner599b5312010-07-08 23:46:44 +0000870 (outs GR16:$dst), (ins i32mem:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000871 "lea{w}\t{$src|$dst}, {$dst|$src}", []>, OpSize;
Evan Chenge771ebd2008-03-27 01:41:09 +0000872let isReMaterializable = 1 in
Chris Lattner3a173df2004-10-03 20:35:00 +0000873def LEA32r : I<0x8D, MRMSrcMem,
Chris Lattner599b5312010-07-08 23:46:44 +0000874 (outs GR32:$dst), (ins i32mem:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000875 "lea{l}\t{$src|$dst}, {$dst|$src}",
Evan Cheng25ab6902006-09-08 06:48:29 +0000876 [(set GR32:$dst, lea32addr:$src)]>, Requires<[In32BitMode]>;
Chris Lattner1cca5e32003-08-03 21:54:21 +0000877
Kevin Enderby12ce0de2010-02-03 21:04:42 +0000878let Defs = [ECX,EDI,ESI], Uses = [ECX,EDI,ESI], isCodeGenOnly = 1 in {
Evan Cheng64d80e32007-07-19 01:14:50 +0000879def REP_MOVSB : I<0xA4, RawFrm, (outs), (ins), "{rep;movsb|rep movsb}",
Evan Cheng071a2792007-09-11 19:55:27 +0000880 [(X86rep_movs i8)]>, REP;
Evan Cheng64d80e32007-07-19 01:14:50 +0000881def REP_MOVSW : I<0xA5, RawFrm, (outs), (ins), "{rep;movsw|rep movsw}",
Evan Cheng071a2792007-09-11 19:55:27 +0000882 [(X86rep_movs i16)]>, REP, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +0000883def REP_MOVSD : I<0xA5, RawFrm, (outs), (ins), "{rep;movsl|rep movsd}",
Evan Cheng071a2792007-09-11 19:55:27 +0000884 [(X86rep_movs i32)]>, REP;
885}
Chris Lattner915e5e52004-02-12 17:53:22 +0000886
Kevin Enderby12ce0de2010-02-03 21:04:42 +0000887// These uses the DF flag in the EFLAGS register to inc or dec EDI and ESI
888let Defs = [EDI,ESI], Uses = [EDI,ESI,EFLAGS] in {
889def MOVSB : I<0xA4, RawFrm, (outs), (ins), "{movsb}", []>;
890def MOVSW : I<0xA5, RawFrm, (outs), (ins), "{movsw}", []>, OpSize;
891def MOVSD : I<0xA5, RawFrm, (outs), (ins), "{movsl|movsd}", []>;
892}
893
894let Defs = [ECX,EDI], Uses = [AL,ECX,EDI], isCodeGenOnly = 1 in
Evan Cheng64d80e32007-07-19 01:14:50 +0000895def REP_STOSB : I<0xAA, RawFrm, (outs), (ins), "{rep;stosb|rep stosb}",
Evan Cheng071a2792007-09-11 19:55:27 +0000896 [(X86rep_stos i8)]>, REP;
Kevin Enderby12ce0de2010-02-03 21:04:42 +0000897let Defs = [ECX,EDI], Uses = [AX,ECX,EDI], isCodeGenOnly = 1 in
Evan Cheng64d80e32007-07-19 01:14:50 +0000898def REP_STOSW : I<0xAB, RawFrm, (outs), (ins), "{rep;stosw|rep stosw}",
Evan Cheng071a2792007-09-11 19:55:27 +0000899 [(X86rep_stos i16)]>, REP, OpSize;
Kevin Enderby12ce0de2010-02-03 21:04:42 +0000900let Defs = [ECX,EDI], Uses = [EAX,ECX,EDI], isCodeGenOnly = 1 in
Evan Cheng64d80e32007-07-19 01:14:50 +0000901def REP_STOSD : I<0xAB, RawFrm, (outs), (ins), "{rep;stosl|rep stosd}",
Evan Cheng071a2792007-09-11 19:55:27 +0000902 [(X86rep_stos i32)]>, REP;
Chris Lattner30bf2d82004-08-10 20:17:41 +0000903
Kevin Enderby12ce0de2010-02-03 21:04:42 +0000904// These uses the DF flag in the EFLAGS register to inc or dec EDI and ESI
905let Defs = [EDI], Uses = [AL,EDI,EFLAGS] in
906def STOSB : I<0xAA, RawFrm, (outs), (ins), "{stosb}", []>;
907let Defs = [EDI], Uses = [AX,EDI,EFLAGS] in
908def STOSW : I<0xAB, RawFrm, (outs), (ins), "{stosw}", []>, OpSize;
909let Defs = [EDI], Uses = [EAX,EDI,EFLAGS] in
910def STOSD : I<0xAB, RawFrm, (outs), (ins), "{stosl|stosd}", []>;
911
Sean Callanana82e4652009-09-12 00:37:19 +0000912def SCAS8 : I<0xAE, RawFrm, (outs), (ins), "scas{b}", []>;
913def SCAS16 : I<0xAF, RawFrm, (outs), (ins), "scas{w}", []>, OpSize;
914def SCAS32 : I<0xAF, RawFrm, (outs), (ins), "scas{l}", []>;
915
Sean Callanan6f8f4622009-09-12 02:25:20 +0000916def CMPS8 : I<0xA6, RawFrm, (outs), (ins), "cmps{b}", []>;
917def CMPS16 : I<0xA7, RawFrm, (outs), (ins), "cmps{w}", []>, OpSize;
918def CMPS32 : I<0xA7, RawFrm, (outs), (ins), "cmps{l}", []>;
919
Evan Cheng071a2792007-09-11 19:55:27 +0000920let Defs = [RAX, RDX] in
Evan Cheng64d80e32007-07-19 01:14:50 +0000921def RDTSC : I<0x31, RawFrm, (outs), (ins), "rdtsc", [(X86rdtsc)]>,
Evan Cheng071a2792007-09-11 19:55:27 +0000922 TB;
Chris Lattnerb89abef2004-02-14 04:45:37 +0000923
Sean Callanancebe9552010-02-13 02:06:11 +0000924let Defs = [RAX, RCX, RDX] in
925def RDTSCP : I<0x01, MRM_F9, (outs), (ins), "rdtscp", []>, TB;
926
Dan Gohmaneffc8c52010-05-14 16:46:02 +0000927let isTerminator = 1, isBarrier = 1, hasCtrlDep = 1 in {
Chris Lattnerda68d302008-01-15 21:58:22 +0000928def TRAP : I<0x0B, RawFrm, (outs), (ins), "ud2", [(trap)]>, TB;
Anton Korobeynikov66fac792008-01-15 07:02:33 +0000929}
930
Chris Lattner02552de2009-08-11 16:58:39 +0000931def SYSCALL : I<0x05, RawFrm,
932 (outs), (ins), "syscall", []>, TB;
933def SYSRET : I<0x07, RawFrm,
934 (outs), (ins), "sysret", []>, TB;
935def SYSENTER : I<0x34, RawFrm,
936 (outs), (ins), "sysenter", []>, TB;
937def SYSEXIT : I<0x35, RawFrm,
Daniel Dunbardf4c47b2010-07-19 07:21:01 +0000938 (outs), (ins), "sysexit", []>, TB, Requires<[In32BitMode]>;
Chris Lattner02552de2009-08-11 16:58:39 +0000939
Sean Callanan2a46f362009-09-12 02:52:41 +0000940def WAIT : I<0x9B, RawFrm, (outs), (ins), "wait", []>;
Chris Lattner02552de2009-08-11 16:58:39 +0000941
942
Chris Lattner1cca5e32003-08-03 21:54:21 +0000943//===----------------------------------------------------------------------===//
John Criswell4ffff9e2004-04-08 20:31:47 +0000944// Input/Output Instructions...
945//
Evan Cheng071a2792007-09-11 19:55:27 +0000946let Defs = [AL], Uses = [DX] in
Evan Cheng64d80e32007-07-19 01:14:50 +0000947def IN8rr : I<0xEC, RawFrm, (outs), (ins),
Evan Cheng071a2792007-09-11 19:55:27 +0000948 "in{b}\t{%dx, %al|%AL, %DX}", []>;
949let Defs = [AX], Uses = [DX] in
Evan Cheng64d80e32007-07-19 01:14:50 +0000950def IN16rr : I<0xED, RawFrm, (outs), (ins),
Evan Cheng071a2792007-09-11 19:55:27 +0000951 "in{w}\t{%dx, %ax|%AX, %DX}", []>, OpSize;
952let Defs = [EAX], Uses = [DX] in
Evan Cheng64d80e32007-07-19 01:14:50 +0000953def IN32rr : I<0xED, RawFrm, (outs), (ins),
Evan Cheng071a2792007-09-11 19:55:27 +0000954 "in{l}\t{%dx, %eax|%EAX, %DX}", []>;
John Criswell4ffff9e2004-04-08 20:31:47 +0000955
Evan Cheng071a2792007-09-11 19:55:27 +0000956let Defs = [AL] in
Evan Cheng64d80e32007-07-19 01:14:50 +0000957def IN8ri : Ii8<0xE4, RawFrm, (outs), (ins i16i8imm:$port),
Evan Cheng071a2792007-09-11 19:55:27 +0000958 "in{b}\t{$port, %al|%AL, $port}", []>;
959let Defs = [AX] in
Evan Cheng64d80e32007-07-19 01:14:50 +0000960def IN16ri : Ii8<0xE5, RawFrm, (outs), (ins i16i8imm:$port),
Evan Cheng071a2792007-09-11 19:55:27 +0000961 "in{w}\t{$port, %ax|%AX, $port}", []>, OpSize;
962let Defs = [EAX] in
Evan Cheng64d80e32007-07-19 01:14:50 +0000963def IN32ri : Ii8<0xE5, RawFrm, (outs), (ins i16i8imm:$port),
Evan Cheng071a2792007-09-11 19:55:27 +0000964 "in{l}\t{$port, %eax|%EAX, $port}", []>;
Chris Lattner440bbc22004-04-13 17:19:31 +0000965
Evan Cheng071a2792007-09-11 19:55:27 +0000966let Uses = [DX, AL] in
Evan Cheng64d80e32007-07-19 01:14:50 +0000967def OUT8rr : I<0xEE, RawFrm, (outs), (ins),
Evan Cheng071a2792007-09-11 19:55:27 +0000968 "out{b}\t{%al, %dx|%DX, %AL}", []>;
969let Uses = [DX, AX] in
Evan Cheng64d80e32007-07-19 01:14:50 +0000970def OUT16rr : I<0xEF, RawFrm, (outs), (ins),
Evan Cheng071a2792007-09-11 19:55:27 +0000971 "out{w}\t{%ax, %dx|%DX, %AX}", []>, OpSize;
972let Uses = [DX, EAX] in
Evan Cheng64d80e32007-07-19 01:14:50 +0000973def OUT32rr : I<0xEF, RawFrm, (outs), (ins),
Evan Cheng071a2792007-09-11 19:55:27 +0000974 "out{l}\t{%eax, %dx|%DX, %EAX}", []>;
Chris Lattnerffff7082004-08-01 07:44:35 +0000975
Evan Cheng071a2792007-09-11 19:55:27 +0000976let Uses = [AL] in
Evan Cheng64d80e32007-07-19 01:14:50 +0000977def OUT8ir : Ii8<0xE6, RawFrm, (outs), (ins i16i8imm:$port),
Evan Cheng071a2792007-09-11 19:55:27 +0000978 "out{b}\t{%al, $port|$port, %AL}", []>;
979let Uses = [AX] in
Evan Cheng64d80e32007-07-19 01:14:50 +0000980def OUT16ir : Ii8<0xE7, RawFrm, (outs), (ins i16i8imm:$port),
Evan Cheng071a2792007-09-11 19:55:27 +0000981 "out{w}\t{%ax, $port|$port, %AX}", []>, OpSize;
982let Uses = [EAX] in
Evan Cheng64d80e32007-07-19 01:14:50 +0000983def OUT32ir : Ii8<0xE7, RawFrm, (outs), (ins i16i8imm:$port),
Evan Cheng071a2792007-09-11 19:55:27 +0000984 "out{l}\t{%eax, $port|$port, %EAX}", []>;
John Criswell4ffff9e2004-04-08 20:31:47 +0000985
Sean Callanan108934c2009-12-18 00:01:26 +0000986def IN8 : I<0x6C, RawFrm, (outs), (ins),
987 "ins{b}", []>;
988def IN16 : I<0x6D, RawFrm, (outs), (ins),
989 "ins{w}", []>, OpSize;
990def IN32 : I<0x6D, RawFrm, (outs), (ins),
991 "ins{l}", []>;
992
John Criswell4ffff9e2004-04-08 20:31:47 +0000993//===----------------------------------------------------------------------===//
Chris Lattner1cca5e32003-08-03 21:54:21 +0000994// Move Instructions...
995//
Chris Lattnerba7e7562008-01-10 07:59:24 +0000996let neverHasSideEffects = 1 in {
Evan Cheng64d80e32007-07-19 01:14:50 +0000997def MOV8rr : I<0x88, MRMDestReg, (outs GR8 :$dst), (ins GR8 :$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000998 "mov{b}\t{$src, $dst|$dst, $src}", []>;
Evan Cheng64d80e32007-07-19 01:14:50 +0000999def MOV16rr : I<0x89, MRMDestReg, (outs GR16:$dst), (ins GR16:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001000 "mov{w}\t{$src, $dst|$dst, $src}", []>, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00001001def MOV32rr : I<0x89, MRMDestReg, (outs GR32:$dst), (ins GR32:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001002 "mov{l}\t{$src, $dst|$dst, $src}", []>;
Chris Lattnerba7e7562008-01-10 07:59:24 +00001003}
Evan Cheng359e9372008-06-18 08:13:07 +00001004let isReMaterializable = 1, isAsCheapAsAMove = 1 in {
Evan Cheng64d80e32007-07-19 01:14:50 +00001005def MOV8ri : Ii8 <0xB0, AddRegFrm, (outs GR8 :$dst), (ins i8imm :$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001006 "mov{b}\t{$src, $dst|$dst, $src}",
Evan Cheng069287d2006-05-16 07:21:53 +00001007 [(set GR8:$dst, imm:$src)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00001008def MOV16ri : Ii16<0xB8, AddRegFrm, (outs GR16:$dst), (ins i16imm:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001009 "mov{w}\t{$src, $dst|$dst, $src}",
Evan Cheng069287d2006-05-16 07:21:53 +00001010 [(set GR16:$dst, imm:$src)]>, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00001011def MOV32ri : Ii32<0xB8, AddRegFrm, (outs GR32:$dst), (ins i32imm:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001012 "mov{l}\t{$src, $dst|$dst, $src}",
Evan Cheng069287d2006-05-16 07:21:53 +00001013 [(set GR32:$dst, imm:$src)]>;
Dan Gohmand45eddd2007-06-26 00:48:07 +00001014}
Kevin Enderby12ce0de2010-02-03 21:04:42 +00001015
Evan Cheng64d80e32007-07-19 01:14:50 +00001016def MOV8mi : Ii8 <0xC6, MRM0m, (outs), (ins i8mem :$dst, i8imm :$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001017 "mov{b}\t{$src, $dst|$dst, $src}",
Evan Chengb51a0592005-12-10 00:48:20 +00001018 [(store (i8 imm:$src), addr:$dst)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00001019def MOV16mi : Ii16<0xC7, MRM0m, (outs), (ins i16mem:$dst, i16imm:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001020 "mov{w}\t{$src, $dst|$dst, $src}",
Evan Chengb51a0592005-12-10 00:48:20 +00001021 [(store (i16 imm:$src), addr:$dst)]>, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00001022def MOV32mi : Ii32<0xC7, MRM0m, (outs), (ins i32mem:$dst, i32imm:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001023 "mov{l}\t{$src, $dst|$dst, $src}",
Evan Chengb51a0592005-12-10 00:48:20 +00001024 [(store (i32 imm:$src), addr:$dst)]>;
Chris Lattner1cca5e32003-08-03 21:54:21 +00001025
Chris Lattnerb5505d02010-05-13 00:02:47 +00001026/// moffs8, moffs16 and moffs32 versions of moves. The immediate is a
1027/// 32-bit offset from the PC. These are only valid in x86-32 mode.
Chris Lattner2745f6e2010-05-12 22:48:24 +00001028def MOV8o8a : Ii32 <0xA0, RawFrm, (outs), (ins offset8:$src),
Daniel Dunbar6c2c9a22010-07-19 06:14:44 +00001029 "mov{b}\t{$src, %al|%al, $src}", []>,
1030 Requires<[In32BitMode]>;
Chris Lattner2745f6e2010-05-12 22:48:24 +00001031def MOV16o16a : Ii32 <0xA1, RawFrm, (outs), (ins offset16:$src),
Daniel Dunbar6c2c9a22010-07-19 06:14:44 +00001032 "mov{w}\t{$src, %ax|%ax, $src}", []>, OpSize,
1033 Requires<[In32BitMode]>;
Sean Callanan108934c2009-12-18 00:01:26 +00001034def MOV32o32a : Ii32 <0xA1, RawFrm, (outs), (ins offset32:$src),
Daniel Dunbar6c2c9a22010-07-19 06:14:44 +00001035 "mov{l}\t{$src, %eax|%eax, $src}", []>,
1036 Requires<[In32BitMode]>;
Chris Lattner2745f6e2010-05-12 22:48:24 +00001037def MOV8ao8 : Ii32 <0xA2, RawFrm, (outs offset8:$dst), (ins),
Daniel Dunbar6c2c9a22010-07-19 06:14:44 +00001038 "mov{b}\t{%al, $dst|$dst, %al}", []>,
1039 Requires<[In32BitMode]>;
Chris Lattner2745f6e2010-05-12 22:48:24 +00001040def MOV16ao16 : Ii32 <0xA3, RawFrm, (outs offset16:$dst), (ins),
Daniel Dunbar6c2c9a22010-07-19 06:14:44 +00001041 "mov{w}\t{%ax, $dst|$dst, %ax}", []>, OpSize,
1042 Requires<[In32BitMode]>;
Sean Callanan108934c2009-12-18 00:01:26 +00001043def MOV32ao32 : Ii32 <0xA3, RawFrm, (outs offset32:$dst), (ins),
Daniel Dunbar6c2c9a22010-07-19 06:14:44 +00001044 "mov{l}\t{%eax, $dst|$dst, %eax}", []>,
1045 Requires<[In32BitMode]>;
Chris Lattnerb5505d02010-05-13 00:02:47 +00001046
Sean Callanan38fee0e2009-09-15 18:47:29 +00001047// Moves to and from segment registers
1048def MOV16rs : I<0x8C, MRMDestReg, (outs GR16:$dst), (ins SEGMENT_REG:$src),
Kevin Enderbyb1065432010-05-26 20:10:45 +00001049 "mov{w}\t{$src, $dst|$dst, $src}", []>, OpSize;
1050def MOV32rs : I<0x8C, MRMDestReg, (outs GR32:$dst), (ins SEGMENT_REG:$src),
1051 "mov{l}\t{$src, $dst|$dst, $src}", []>;
Sean Callanan38fee0e2009-09-15 18:47:29 +00001052def MOV16ms : I<0x8C, MRMDestMem, (outs i16mem:$dst), (ins SEGMENT_REG:$src),
Kevin Enderbyb1065432010-05-26 20:10:45 +00001053 "mov{w}\t{$src, $dst|$dst, $src}", []>, OpSize;
1054def MOV32ms : I<0x8C, MRMDestMem, (outs i32mem:$dst), (ins SEGMENT_REG:$src),
1055 "mov{l}\t{$src, $dst|$dst, $src}", []>;
Sean Callanan38fee0e2009-09-15 18:47:29 +00001056def MOV16sr : I<0x8E, MRMSrcReg, (outs SEGMENT_REG:$dst), (ins GR16:$src),
Kevin Enderbyb1065432010-05-26 20:10:45 +00001057 "mov{w}\t{$src, $dst|$dst, $src}", []>, OpSize;
1058def MOV32sr : I<0x8E, MRMSrcReg, (outs SEGMENT_REG:$dst), (ins GR32:$src),
1059 "mov{l}\t{$src, $dst|$dst, $src}", []>;
Sean Callanan38fee0e2009-09-15 18:47:29 +00001060def MOV16sm : I<0x8E, MRMSrcMem, (outs SEGMENT_REG:$dst), (ins i16mem:$src),
Kevin Enderbyb1065432010-05-26 20:10:45 +00001061 "mov{w}\t{$src, $dst|$dst, $src}", []>, OpSize;
1062def MOV32sm : I<0x8E, MRMSrcMem, (outs SEGMENT_REG:$dst), (ins i32mem:$src),
1063 "mov{l}\t{$src, $dst|$dst, $src}", []>;
Sean Callanan38fee0e2009-09-15 18:47:29 +00001064
Daniel Dunbardcbab9c2010-05-26 22:21:28 +00001065let isCodeGenOnly = 1 in {
Sean Callanan108934c2009-12-18 00:01:26 +00001066def MOV8rr_REV : I<0x8A, MRMSrcReg, (outs GR8:$dst), (ins GR8:$src),
1067 "mov{b}\t{$src, $dst|$dst, $src}", []>;
1068def MOV16rr_REV : I<0x8B, MRMSrcReg, (outs GR16:$dst), (ins GR16:$src),
1069 "mov{w}\t{$src, $dst|$dst, $src}", []>, OpSize;
1070def MOV32rr_REV : I<0x8B, MRMSrcReg, (outs GR32:$dst), (ins GR32:$src),
1071 "mov{l}\t{$src, $dst|$dst, $src}", []>;
Daniel Dunbardcbab9c2010-05-26 22:21:28 +00001072}
Sean Callanan108934c2009-12-18 00:01:26 +00001073
Dan Gohmanbc9d98b2010-02-27 23:47:46 +00001074let canFoldAsLoad = 1, isReMaterializable = 1 in {
Evan Cheng64d80e32007-07-19 01:14:50 +00001075def MOV8rm : I<0x8A, MRMSrcMem, (outs GR8 :$dst), (ins i8mem :$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001076 "mov{b}\t{$src, $dst|$dst, $src}",
Chris Lattnerc2406f22009-04-10 00:16:23 +00001077 [(set GR8:$dst, (loadi8 addr:$src))]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00001078def MOV16rm : I<0x8B, MRMSrcMem, (outs GR16:$dst), (ins i16mem:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001079 "mov{w}\t{$src, $dst|$dst, $src}",
Chris Lattnerc2406f22009-04-10 00:16:23 +00001080 [(set GR16:$dst, (loadi16 addr:$src))]>, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00001081def MOV32rm : I<0x8B, MRMSrcMem, (outs GR32:$dst), (ins i32mem:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001082 "mov{l}\t{$src, $dst|$dst, $src}",
Chris Lattnerc2406f22009-04-10 00:16:23 +00001083 [(set GR32:$dst, (loadi32 addr:$src))]>;
Evan Cheng2f394262007-08-30 05:49:43 +00001084}
Chris Lattner1cca5e32003-08-03 21:54:21 +00001085
Evan Cheng64d80e32007-07-19 01:14:50 +00001086def MOV8mr : I<0x88, MRMDestMem, (outs), (ins i8mem :$dst, GR8 :$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001087 "mov{b}\t{$src, $dst|$dst, $src}",
Evan Cheng069287d2006-05-16 07:21:53 +00001088 [(store GR8:$src, addr:$dst)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00001089def MOV16mr : I<0x89, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001090 "mov{w}\t{$src, $dst|$dst, $src}",
Evan Cheng069287d2006-05-16 07:21:53 +00001091 [(store GR16:$src, addr:$dst)]>, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00001092def MOV32mr : I<0x89, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001093 "mov{l}\t{$src, $dst|$dst, $src}",
Evan Cheng069287d2006-05-16 07:21:53 +00001094 [(store GR32:$src, addr:$dst)]>;
Dan Gohman21e3dfb2009-04-13 16:09:41 +00001095
Evan Chengf48ef032010-03-14 03:48:46 +00001096/// Versions of MOV32rr, MOV32rm, and MOV32mr for i32mem_TC and GR32_TC.
Daniel Dunbarcf246b72010-07-19 06:14:49 +00001097let isCodeGenOnly = 1 in {
Evan Chengf48ef032010-03-14 03:48:46 +00001098let neverHasSideEffects = 1 in
1099def MOV32rr_TC : I<0x89, MRMDestReg, (outs GR32_TC:$dst), (ins GR32_TC:$src),
1100 "mov{l}\t{$src, $dst|$dst, $src}", []>;
1101
1102let mayLoad = 1,
1103 canFoldAsLoad = 1, isReMaterializable = 1 in
1104def MOV32rm_TC : I<0x8B, MRMSrcMem, (outs GR32_TC:$dst), (ins i32mem_TC:$src),
1105 "mov{l}\t{$src, $dst|$dst, $src}",
1106 []>;
1107
1108let mayStore = 1 in
1109def MOV32mr_TC : I<0x89, MRMDestMem, (outs), (ins i32mem_TC:$dst, GR32_TC:$src),
1110 "mov{l}\t{$src, $dst|$dst, $src}",
1111 []>;
Daniel Dunbarcf246b72010-07-19 06:14:49 +00001112}
Evan Chengf48ef032010-03-14 03:48:46 +00001113
Dan Gohman4af325d2009-04-27 16:41:36 +00001114// Versions of MOV8rr, MOV8mr, and MOV8rm that use i8mem_NOREX and GR8_NOREX so
1115// that they can be used for copying and storing h registers, which can't be
1116// encoded when a REX prefix is present.
Daniel Dunbarcf246b72010-07-19 06:14:49 +00001117let isCodeGenOnly = 1 in {
Dan Gohman6d9305c2009-04-15 00:04:23 +00001118let neverHasSideEffects = 1 in
Dan Gohmandf7dfc72009-04-15 19:48:57 +00001119def MOV8rr_NOREX : I<0x88, MRMDestReg,
1120 (outs GR8_NOREX:$dst), (ins GR8_NOREX:$src),
Dan Gohman6d9305c2009-04-15 00:04:23 +00001121 "mov{b}\t{$src, $dst|$dst, $src} # NOREX", []>;
Evan Cheng8c147402009-04-30 00:58:57 +00001122let mayStore = 1 in
Dan Gohman6d9305c2009-04-15 00:04:23 +00001123def MOV8mr_NOREX : I<0x88, MRMDestMem,
1124 (outs), (ins i8mem_NOREX:$dst, GR8_NOREX:$src),
1125 "mov{b}\t{$src, $dst|$dst, $src} # NOREX", []>;
Evan Cheng8c147402009-04-30 00:58:57 +00001126let mayLoad = 1,
Dan Gohmanbc9d98b2010-02-27 23:47:46 +00001127 canFoldAsLoad = 1, isReMaterializable = 1 in
Dan Gohman4af325d2009-04-27 16:41:36 +00001128def MOV8rm_NOREX : I<0x8A, MRMSrcMem,
1129 (outs GR8_NOREX:$dst), (ins i8mem_NOREX:$src),
1130 "mov{b}\t{$src, $dst|$dst, $src} # NOREX", []>;
Daniel Dunbarcf246b72010-07-19 06:14:49 +00001131}
Dan Gohman21e3dfb2009-04-13 16:09:41 +00001132
Sean Callanan108934c2009-12-18 00:01:26 +00001133// Moves to and from debug registers
1134def MOV32rd : I<0x21, MRMDestReg, (outs GR32:$dst), (ins DEBUG_REG:$src),
1135 "mov{l}\t{$src, $dst|$dst, $src}", []>, TB;
1136def MOV32dr : I<0x23, MRMSrcReg, (outs DEBUG_REG:$dst), (ins GR32:$src),
1137 "mov{l}\t{$src, $dst|$dst, $src}", []>, TB;
1138
1139// Moves to and from control registers
Sean Callanan1a8b7892010-05-06 20:59:00 +00001140def MOV32rc : I<0x20, MRMDestReg, (outs GR32:$dst), (ins CONTROL_REG:$src),
1141 "mov{l}\t{$src, $dst|$dst, $src}", []>, TB;
1142def MOV32cr : I<0x22, MRMSrcReg, (outs CONTROL_REG:$dst), (ins GR32:$src),
1143 "mov{l}\t{$src, $dst|$dst, $src}", []>, TB;
Sean Callanan108934c2009-12-18 00:01:26 +00001144
Chris Lattner1cca5e32003-08-03 21:54:21 +00001145//===----------------------------------------------------------------------===//
1146// Fixed-Register Multiplication and Division Instructions...
1147//
Chris Lattner1cca5e32003-08-03 21:54:21 +00001148
Chris Lattnerc8f45872003-08-04 04:59:56 +00001149// Extra precision multiplication
Jakob Stoklund Olesen3cfe0102010-03-04 20:42:07 +00001150
1151// AL is really implied by AX, by the registers in Defs must match the
1152// SDNode results (i8, i32).
1153let Defs = [AL,EFLAGS,AX], Uses = [AL] in
Dan Gohmanb1576f52007-07-31 20:11:57 +00001154def MUL8r : I<0xF6, MRM4r, (outs), (ins GR8:$src), "mul{b}\t$src",
Evan Chengcf74a7c2006-01-15 10:05:20 +00001155 // FIXME: Used for 8-bit mul, ignore result upper 8 bits.
1156 // This probably ought to be moved to a def : Pat<> if the
1157 // syntax can be accepted.
Bill Wendlingd350e022008-12-12 21:15:41 +00001158 [(set AL, (mul AL, GR8:$src)),
1159 (implicit EFLAGS)]>; // AL,AH = AL*GR8
1160
Chris Lattnera731c9f2008-01-11 07:18:17 +00001161let Defs = [AX,DX,EFLAGS], Uses = [AX], neverHasSideEffects = 1 in
Bill Wendlingd350e022008-12-12 21:15:41 +00001162def MUL16r : I<0xF7, MRM4r, (outs), (ins GR16:$src),
1163 "mul{w}\t$src",
1164 []>, OpSize; // AX,DX = AX*GR16
1165
Chris Lattnera731c9f2008-01-11 07:18:17 +00001166let Defs = [EAX,EDX,EFLAGS], Uses = [EAX], neverHasSideEffects = 1 in
Bill Wendlingd350e022008-12-12 21:15:41 +00001167def MUL32r : I<0xF7, MRM4r, (outs), (ins GR32:$src),
1168 "mul{l}\t$src",
1169 []>; // EAX,EDX = EAX*GR32
1170
Jakob Stoklund Olesen3cfe0102010-03-04 20:42:07 +00001171let Defs = [AL,EFLAGS,AX], Uses = [AL] in
Evan Cheng64d80e32007-07-19 01:14:50 +00001172def MUL8m : I<0xF6, MRM4m, (outs), (ins i8mem :$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001173 "mul{b}\t$src",
Evan Chengcf74a7c2006-01-15 10:05:20 +00001174 // FIXME: Used for 8-bit mul, ignore result upper 8 bits.
1175 // This probably ought to be moved to a def : Pat<> if the
1176 // syntax can be accepted.
Bill Wendlingd350e022008-12-12 21:15:41 +00001177 [(set AL, (mul AL, (loadi8 addr:$src))),
1178 (implicit EFLAGS)]>; // AL,AH = AL*[mem8]
1179
Chris Lattnerba7e7562008-01-10 07:59:24 +00001180let mayLoad = 1, neverHasSideEffects = 1 in {
Evan Cheng24f2ea32007-09-14 21:48:26 +00001181let Defs = [AX,DX,EFLAGS], Uses = [AX] in
Evan Cheng64d80e32007-07-19 01:14:50 +00001182def MUL16m : I<0xF7, MRM4m, (outs), (ins i16mem:$src),
Bill Wendlingd350e022008-12-12 21:15:41 +00001183 "mul{w}\t$src",
1184 []>, OpSize; // AX,DX = AX*[mem16]
1185
Evan Cheng24f2ea32007-09-14 21:48:26 +00001186let Defs = [EAX,EDX,EFLAGS], Uses = [EAX] in
Evan Cheng64d80e32007-07-19 01:14:50 +00001187def MUL32m : I<0xF7, MRM4m, (outs), (ins i32mem:$src),
Bill Wendlingd350e022008-12-12 21:15:41 +00001188 "mul{l}\t$src",
1189 []>; // EAX,EDX = EAX*[mem32]
Chris Lattnerba7e7562008-01-10 07:59:24 +00001190}
Chris Lattner1cca5e32003-08-03 21:54:21 +00001191
Chris Lattnerba7e7562008-01-10 07:59:24 +00001192let neverHasSideEffects = 1 in {
Jakob Stoklund Olesen3cfe0102010-03-04 20:42:07 +00001193let Defs = [AL,EFLAGS,AX], Uses = [AL] in
Evan Cheng071a2792007-09-11 19:55:27 +00001194def IMUL8r : I<0xF6, MRM5r, (outs), (ins GR8:$src), "imul{b}\t$src", []>;
1195 // AL,AH = AL*GR8
Evan Cheng24f2ea32007-09-14 21:48:26 +00001196let Defs = [AX,DX,EFLAGS], Uses = [AX] in
Dan Gohmanb1576f52007-07-31 20:11:57 +00001197def IMUL16r : I<0xF7, MRM5r, (outs), (ins GR16:$src), "imul{w}\t$src", []>,
Evan Cheng071a2792007-09-11 19:55:27 +00001198 OpSize; // AX,DX = AX*GR16
Evan Cheng24f2ea32007-09-14 21:48:26 +00001199let Defs = [EAX,EDX,EFLAGS], Uses = [EAX] in
Evan Cheng071a2792007-09-11 19:55:27 +00001200def IMUL32r : I<0xF7, MRM5r, (outs), (ins GR32:$src), "imul{l}\t$src", []>;
1201 // EAX,EDX = EAX*GR32
Chris Lattnerba7e7562008-01-10 07:59:24 +00001202let mayLoad = 1 in {
Jakob Stoklund Olesen3cfe0102010-03-04 20:42:07 +00001203let Defs = [AL,EFLAGS,AX], Uses = [AL] in
Evan Cheng64d80e32007-07-19 01:14:50 +00001204def IMUL8m : I<0xF6, MRM5m, (outs), (ins i8mem :$src),
Evan Cheng071a2792007-09-11 19:55:27 +00001205 "imul{b}\t$src", []>; // AL,AH = AL*[mem8]
Evan Cheng24f2ea32007-09-14 21:48:26 +00001206let Defs = [AX,DX,EFLAGS], Uses = [AX] in
Evan Cheng64d80e32007-07-19 01:14:50 +00001207def IMUL16m : I<0xF7, MRM5m, (outs), (ins i16mem:$src),
Evan Cheng071a2792007-09-11 19:55:27 +00001208 "imul{w}\t$src", []>, OpSize; // AX,DX = AX*[mem16]
Eli Friedmanba7b1c42009-12-26 20:08:30 +00001209let Defs = [EAX,EDX,EFLAGS], Uses = [EAX] in
Evan Cheng64d80e32007-07-19 01:14:50 +00001210def IMUL32m : I<0xF7, MRM5m, (outs), (ins i32mem:$src),
Evan Cheng071a2792007-09-11 19:55:27 +00001211 "imul{l}\t$src", []>; // EAX,EDX = EAX*[mem32]
Chris Lattnerba7e7562008-01-10 07:59:24 +00001212}
Dan Gohmanc99da132008-11-18 21:29:14 +00001213} // neverHasSideEffects
Chris Lattner1e6a7152005-04-06 04:19:22 +00001214
Chris Lattnerc8f45872003-08-04 04:59:56 +00001215// unsigned division/remainder
Jakob Stoklund Olesen3cfe0102010-03-04 20:42:07 +00001216let Defs = [AL,EFLAGS,AX], Uses = [AX] in
Sean Callanan108934c2009-12-18 00:01:26 +00001217def DIV8r : I<0xF6, MRM6r, (outs), (ins GR8:$src), // AX/r8 = AL,AH
Evan Cheng071a2792007-09-11 19:55:27 +00001218 "div{b}\t$src", []>;
Evan Cheng24f2ea32007-09-14 21:48:26 +00001219let Defs = [AX,DX,EFLAGS], Uses = [AX,DX] in
Sean Callanan108934c2009-12-18 00:01:26 +00001220def DIV16r : I<0xF7, MRM6r, (outs), (ins GR16:$src), // DX:AX/r16 = AX,DX
Evan Cheng071a2792007-09-11 19:55:27 +00001221 "div{w}\t$src", []>, OpSize;
Evan Cheng24f2ea32007-09-14 21:48:26 +00001222let Defs = [EAX,EDX,EFLAGS], Uses = [EAX,EDX] in
Sean Callanan108934c2009-12-18 00:01:26 +00001223def DIV32r : I<0xF7, MRM6r, (outs), (ins GR32:$src), // EDX:EAX/r32 = EAX,EDX
Evan Cheng071a2792007-09-11 19:55:27 +00001224 "div{l}\t$src", []>;
Chris Lattnerba7e7562008-01-10 07:59:24 +00001225let mayLoad = 1 in {
Jakob Stoklund Olesen3cfe0102010-03-04 20:42:07 +00001226let Defs = [AL,EFLAGS,AX], Uses = [AX] in
Sean Callanan108934c2009-12-18 00:01:26 +00001227def DIV8m : I<0xF6, MRM6m, (outs), (ins i8mem:$src), // AX/[mem8] = AL,AH
Evan Cheng071a2792007-09-11 19:55:27 +00001228 "div{b}\t$src", []>;
Evan Cheng24f2ea32007-09-14 21:48:26 +00001229let Defs = [AX,DX,EFLAGS], Uses = [AX,DX] in
Sean Callanan108934c2009-12-18 00:01:26 +00001230def DIV16m : I<0xF7, MRM6m, (outs), (ins i16mem:$src), // DX:AX/[mem16] = AX,DX
Evan Cheng071a2792007-09-11 19:55:27 +00001231 "div{w}\t$src", []>, OpSize;
Evan Cheng24f2ea32007-09-14 21:48:26 +00001232let Defs = [EAX,EDX,EFLAGS], Uses = [EAX,EDX] in
Sean Callanan108934c2009-12-18 00:01:26 +00001233 // EDX:EAX/[mem32] = EAX,EDX
1234def DIV32m : I<0xF7, MRM6m, (outs), (ins i32mem:$src),
Evan Cheng071a2792007-09-11 19:55:27 +00001235 "div{l}\t$src", []>;
Chris Lattnerba7e7562008-01-10 07:59:24 +00001236}
Chris Lattner1cca5e32003-08-03 21:54:21 +00001237
Chris Lattnerfc752712004-08-01 09:52:59 +00001238// Signed division/remainder.
Jakob Stoklund Olesen3cfe0102010-03-04 20:42:07 +00001239let Defs = [AL,EFLAGS,AX], Uses = [AX] in
Sean Callanan108934c2009-12-18 00:01:26 +00001240def IDIV8r : I<0xF6, MRM7r, (outs), (ins GR8:$src), // AX/r8 = AL,AH
Evan Cheng071a2792007-09-11 19:55:27 +00001241 "idiv{b}\t$src", []>;
Evan Cheng24f2ea32007-09-14 21:48:26 +00001242let Defs = [AX,DX,EFLAGS], Uses = [AX,DX] in
Sean Callanan108934c2009-12-18 00:01:26 +00001243def IDIV16r: I<0xF7, MRM7r, (outs), (ins GR16:$src), // DX:AX/r16 = AX,DX
Evan Cheng071a2792007-09-11 19:55:27 +00001244 "idiv{w}\t$src", []>, OpSize;
Evan Cheng24f2ea32007-09-14 21:48:26 +00001245let Defs = [EAX,EDX,EFLAGS], Uses = [EAX,EDX] in
Sean Callanan108934c2009-12-18 00:01:26 +00001246def IDIV32r: I<0xF7, MRM7r, (outs), (ins GR32:$src), // EDX:EAX/r32 = EAX,EDX
Evan Cheng071a2792007-09-11 19:55:27 +00001247 "idiv{l}\t$src", []>;
Chris Lattnerba7e7562008-01-10 07:59:24 +00001248let mayLoad = 1, mayLoad = 1 in {
Jakob Stoklund Olesen3cfe0102010-03-04 20:42:07 +00001249let Defs = [AL,EFLAGS,AX], Uses = [AX] in
Sean Callanan108934c2009-12-18 00:01:26 +00001250def IDIV8m : I<0xF6, MRM7m, (outs), (ins i8mem:$src), // AX/[mem8] = AL,AH
Evan Cheng071a2792007-09-11 19:55:27 +00001251 "idiv{b}\t$src", []>;
Evan Cheng24f2ea32007-09-14 21:48:26 +00001252let Defs = [AX,DX,EFLAGS], Uses = [AX,DX] in
Sean Callanan108934c2009-12-18 00:01:26 +00001253def IDIV16m: I<0xF7, MRM7m, (outs), (ins i16mem:$src), // DX:AX/[mem16] = AX,DX
Evan Cheng071a2792007-09-11 19:55:27 +00001254 "idiv{w}\t$src", []>, OpSize;
Evan Cheng24f2ea32007-09-14 21:48:26 +00001255let Defs = [EAX,EDX,EFLAGS], Uses = [EAX,EDX] in
Sean Callanan108934c2009-12-18 00:01:26 +00001256def IDIV32m: I<0xF7, MRM7m, (outs), (ins i32mem:$src),
1257 // EDX:EAX/[mem32] = EAX,EDX
Evan Cheng071a2792007-09-11 19:55:27 +00001258 "idiv{l}\t$src", []>;
Chris Lattnerba7e7562008-01-10 07:59:24 +00001259}
Chris Lattner1cca5e32003-08-03 21:54:21 +00001260
Chris Lattner1cca5e32003-08-03 21:54:21 +00001261//===----------------------------------------------------------------------===//
Chris Lattnerba7e7562008-01-10 07:59:24 +00001262// Two address Instructions.
Chris Lattner1cca5e32003-08-03 21:54:21 +00001263//
Eric Christophera938cfb2010-06-19 00:37:40 +00001264let Constraints = "$src1 = $dst" in {
Chris Lattner1cca5e32003-08-03 21:54:21 +00001265
Alkis Evlogimenosa3f66842004-03-12 17:59:56 +00001266// Conditional moves
Evan Cheng0488db92007-09-25 01:57:46 +00001267let Uses = [EFLAGS] in {
Dan Gohmancbbea0f2009-08-27 00:14:12 +00001268
Chris Lattner314a1132010-03-14 18:31:44 +00001269let Predicates = [HasCMov] in {
Dan Gohmana4c5c332009-08-27 18:16:24 +00001270let isCommutable = 1 in {
Evan Cheng069287d2006-05-16 07:21:53 +00001271def CMOVB16rr : I<0x42, MRMSrcReg, // if <u, GR16 = GR16
Evan Cheng64d80e32007-07-19 01:14:50 +00001272 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Sean Callanan108934c2009-12-18 00:01:26 +00001273 "cmovb{w}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001274 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Chenge5f62042007-09-29 00:00:36 +00001275 X86_COND_B, EFLAGS))]>,
Evan Cheng71fb9ad2006-01-26 00:29:36 +00001276 TB, OpSize;
Evan Cheng069287d2006-05-16 07:21:53 +00001277def CMOVB32rr : I<0x42, MRMSrcReg, // if <u, GR32 = GR32
Evan Cheng64d80e32007-07-19 01:14:50 +00001278 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Sean Callanan108934c2009-12-18 00:01:26 +00001279 "cmovb{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001280 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Chenge5f62042007-09-29 00:00:36 +00001281 X86_COND_B, EFLAGS))]>,
Evan Cheng71fb9ad2006-01-26 00:29:36 +00001282 TB;
Evan Cheng069287d2006-05-16 07:21:53 +00001283def CMOVAE16rr: I<0x43, MRMSrcReg, // if >=u, GR16 = GR16
Evan Cheng64d80e32007-07-19 01:14:50 +00001284 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Sean Callanan108934c2009-12-18 00:01:26 +00001285 "cmovae{w}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001286 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Chenge5f62042007-09-29 00:00:36 +00001287 X86_COND_AE, EFLAGS))]>,
Evan Cheng71fb9ad2006-01-26 00:29:36 +00001288 TB, OpSize;
Evan Cheng069287d2006-05-16 07:21:53 +00001289def CMOVAE32rr: I<0x43, MRMSrcReg, // if >=u, GR32 = GR32
Evan Cheng64d80e32007-07-19 01:14:50 +00001290 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Sean Callanan108934c2009-12-18 00:01:26 +00001291 "cmovae{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001292 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Chenge5f62042007-09-29 00:00:36 +00001293 X86_COND_AE, EFLAGS))]>,
Evan Cheng71fb9ad2006-01-26 00:29:36 +00001294 TB;
Evan Cheng069287d2006-05-16 07:21:53 +00001295def CMOVE16rr : I<0x44, MRMSrcReg, // if ==, GR16 = GR16
Evan Cheng64d80e32007-07-19 01:14:50 +00001296 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Sean Callanan108934c2009-12-18 00:01:26 +00001297 "cmove{w}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001298 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Chenge5f62042007-09-29 00:00:36 +00001299 X86_COND_E, EFLAGS))]>,
Evan Cheng71fb9ad2006-01-26 00:29:36 +00001300 TB, OpSize;
Evan Cheng069287d2006-05-16 07:21:53 +00001301def CMOVE32rr : I<0x44, MRMSrcReg, // if ==, GR32 = GR32
Evan Cheng64d80e32007-07-19 01:14:50 +00001302 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Sean Callanan108934c2009-12-18 00:01:26 +00001303 "cmove{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001304 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Chenge5f62042007-09-29 00:00:36 +00001305 X86_COND_E, EFLAGS))]>,
Evan Cheng71fb9ad2006-01-26 00:29:36 +00001306 TB;
Evan Cheng069287d2006-05-16 07:21:53 +00001307def CMOVNE16rr: I<0x45, MRMSrcReg, // if !=, GR16 = GR16
Evan Cheng64d80e32007-07-19 01:14:50 +00001308 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Sean Callanan108934c2009-12-18 00:01:26 +00001309 "cmovne{w}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001310 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Chenge5f62042007-09-29 00:00:36 +00001311 X86_COND_NE, EFLAGS))]>,
Evan Cheng71fb9ad2006-01-26 00:29:36 +00001312 TB, OpSize;
Evan Cheng069287d2006-05-16 07:21:53 +00001313def CMOVNE32rr: I<0x45, MRMSrcReg, // if !=, GR32 = GR32
Evan Cheng64d80e32007-07-19 01:14:50 +00001314 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Sean Callanan108934c2009-12-18 00:01:26 +00001315 "cmovne{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001316 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Chenge5f62042007-09-29 00:00:36 +00001317 X86_COND_NE, EFLAGS))]>,
Evan Cheng71fb9ad2006-01-26 00:29:36 +00001318 TB;
Evan Cheng069287d2006-05-16 07:21:53 +00001319def CMOVBE16rr: I<0x46, MRMSrcReg, // if <=u, GR16 = GR16
Evan Cheng64d80e32007-07-19 01:14:50 +00001320 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Sean Callanan108934c2009-12-18 00:01:26 +00001321 "cmovbe{w}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001322 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Chenge5f62042007-09-29 00:00:36 +00001323 X86_COND_BE, EFLAGS))]>,
Evan Cheng71fb9ad2006-01-26 00:29:36 +00001324 TB, OpSize;
Evan Cheng069287d2006-05-16 07:21:53 +00001325def CMOVBE32rr: I<0x46, MRMSrcReg, // if <=u, GR32 = GR32
Evan Cheng64d80e32007-07-19 01:14:50 +00001326 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Sean Callanan108934c2009-12-18 00:01:26 +00001327 "cmovbe{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001328 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Chenge5f62042007-09-29 00:00:36 +00001329 X86_COND_BE, EFLAGS))]>,
Evan Cheng71fb9ad2006-01-26 00:29:36 +00001330 TB;
Evan Cheng069287d2006-05-16 07:21:53 +00001331def CMOVA16rr : I<0x47, MRMSrcReg, // if >u, GR16 = GR16
Evan Cheng64d80e32007-07-19 01:14:50 +00001332 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Sean Callanan108934c2009-12-18 00:01:26 +00001333 "cmova{w}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001334 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Chenge5f62042007-09-29 00:00:36 +00001335 X86_COND_A, EFLAGS))]>,
Evan Cheng71fb9ad2006-01-26 00:29:36 +00001336 TB, OpSize;
Evan Cheng069287d2006-05-16 07:21:53 +00001337def CMOVA32rr : I<0x47, MRMSrcReg, // if >u, GR32 = GR32
Evan Cheng64d80e32007-07-19 01:14:50 +00001338 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Sean Callanan108934c2009-12-18 00:01:26 +00001339 "cmova{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001340 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Chenge5f62042007-09-29 00:00:36 +00001341 X86_COND_A, EFLAGS))]>,
Evan Cheng71fb9ad2006-01-26 00:29:36 +00001342 TB;
Evan Cheng069287d2006-05-16 07:21:53 +00001343def CMOVL16rr : I<0x4C, MRMSrcReg, // if <s, GR16 = GR16
Evan Cheng64d80e32007-07-19 01:14:50 +00001344 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Sean Callanan108934c2009-12-18 00:01:26 +00001345 "cmovl{w}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001346 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Chenge5f62042007-09-29 00:00:36 +00001347 X86_COND_L, EFLAGS))]>,
Evan Cheng71fb9ad2006-01-26 00:29:36 +00001348 TB, OpSize;
Evan Cheng069287d2006-05-16 07:21:53 +00001349def CMOVL32rr : I<0x4C, MRMSrcReg, // if <s, GR32 = GR32
Evan Cheng64d80e32007-07-19 01:14:50 +00001350 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Sean Callanan108934c2009-12-18 00:01:26 +00001351 "cmovl{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001352 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Chenge5f62042007-09-29 00:00:36 +00001353 X86_COND_L, EFLAGS))]>,
Evan Cheng71fb9ad2006-01-26 00:29:36 +00001354 TB;
Evan Cheng069287d2006-05-16 07:21:53 +00001355def CMOVGE16rr: I<0x4D, MRMSrcReg, // if >=s, GR16 = GR16
Evan Cheng64d80e32007-07-19 01:14:50 +00001356 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Sean Callanan108934c2009-12-18 00:01:26 +00001357 "cmovge{w}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001358 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Chenge5f62042007-09-29 00:00:36 +00001359 X86_COND_GE, EFLAGS))]>,
Evan Cheng71fb9ad2006-01-26 00:29:36 +00001360 TB, OpSize;
Evan Cheng069287d2006-05-16 07:21:53 +00001361def CMOVGE32rr: I<0x4D, MRMSrcReg, // if >=s, GR32 = GR32
Evan Cheng64d80e32007-07-19 01:14:50 +00001362 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Sean Callanan108934c2009-12-18 00:01:26 +00001363 "cmovge{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001364 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Chenge5f62042007-09-29 00:00:36 +00001365 X86_COND_GE, EFLAGS))]>,
Evan Cheng71fb9ad2006-01-26 00:29:36 +00001366 TB;
Evan Cheng069287d2006-05-16 07:21:53 +00001367def CMOVLE16rr: I<0x4E, MRMSrcReg, // if <=s, GR16 = GR16
Evan Cheng64d80e32007-07-19 01:14:50 +00001368 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Sean Callanan108934c2009-12-18 00:01:26 +00001369 "cmovle{w}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001370 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Chenge5f62042007-09-29 00:00:36 +00001371 X86_COND_LE, EFLAGS))]>,
Evan Cheng71fb9ad2006-01-26 00:29:36 +00001372 TB, OpSize;
Evan Cheng069287d2006-05-16 07:21:53 +00001373def CMOVLE32rr: I<0x4E, MRMSrcReg, // if <=s, GR32 = GR32
Evan Cheng64d80e32007-07-19 01:14:50 +00001374 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Sean Callanan108934c2009-12-18 00:01:26 +00001375 "cmovle{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001376 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Chenge5f62042007-09-29 00:00:36 +00001377 X86_COND_LE, EFLAGS))]>,
Evan Cheng71fb9ad2006-01-26 00:29:36 +00001378 TB;
Evan Cheng069287d2006-05-16 07:21:53 +00001379def CMOVG16rr : I<0x4F, MRMSrcReg, // if >s, GR16 = GR16
Evan Cheng64d80e32007-07-19 01:14:50 +00001380 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Sean Callanan108934c2009-12-18 00:01:26 +00001381 "cmovg{w}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001382 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Chenge5f62042007-09-29 00:00:36 +00001383 X86_COND_G, EFLAGS))]>,
Evan Cheng71fb9ad2006-01-26 00:29:36 +00001384 TB, OpSize;
Evan Cheng069287d2006-05-16 07:21:53 +00001385def CMOVG32rr : I<0x4F, MRMSrcReg, // if >s, GR32 = GR32
Evan Cheng64d80e32007-07-19 01:14:50 +00001386 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Sean Callanan108934c2009-12-18 00:01:26 +00001387 "cmovg{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001388 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Chenge5f62042007-09-29 00:00:36 +00001389 X86_COND_G, EFLAGS))]>,
Evan Cheng71fb9ad2006-01-26 00:29:36 +00001390 TB;
Evan Cheng069287d2006-05-16 07:21:53 +00001391def CMOVS16rr : I<0x48, MRMSrcReg, // if signed, GR16 = GR16
Evan Cheng64d80e32007-07-19 01:14:50 +00001392 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Sean Callanan108934c2009-12-18 00:01:26 +00001393 "cmovs{w}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001394 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Chenge5f62042007-09-29 00:00:36 +00001395 X86_COND_S, EFLAGS))]>,
Evan Cheng71fb9ad2006-01-26 00:29:36 +00001396 TB, OpSize;
Evan Cheng069287d2006-05-16 07:21:53 +00001397def CMOVS32rr : I<0x48, MRMSrcReg, // if signed, GR32 = GR32
Evan Cheng64d80e32007-07-19 01:14:50 +00001398 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Sean Callanan108934c2009-12-18 00:01:26 +00001399 "cmovs{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001400 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Chenge5f62042007-09-29 00:00:36 +00001401 X86_COND_S, EFLAGS))]>,
Evan Cheng71fb9ad2006-01-26 00:29:36 +00001402 TB;
Evan Cheng069287d2006-05-16 07:21:53 +00001403def CMOVNS16rr: I<0x49, MRMSrcReg, // if !signed, GR16 = GR16
Evan Cheng64d80e32007-07-19 01:14:50 +00001404 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Sean Callanan108934c2009-12-18 00:01:26 +00001405 "cmovns{w}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001406 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Chenge5f62042007-09-29 00:00:36 +00001407 X86_COND_NS, EFLAGS))]>,
Evan Cheng71fb9ad2006-01-26 00:29:36 +00001408 TB, OpSize;
Evan Cheng069287d2006-05-16 07:21:53 +00001409def CMOVNS32rr: I<0x49, MRMSrcReg, // if !signed, GR32 = GR32
Evan Cheng64d80e32007-07-19 01:14:50 +00001410 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Sean Callanan108934c2009-12-18 00:01:26 +00001411 "cmovns{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001412 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Chenge5f62042007-09-29 00:00:36 +00001413 X86_COND_NS, EFLAGS))]>,
Evan Cheng71fb9ad2006-01-26 00:29:36 +00001414 TB;
Evan Cheng069287d2006-05-16 07:21:53 +00001415def CMOVP16rr : I<0x4A, MRMSrcReg, // if parity, GR16 = GR16
Evan Cheng64d80e32007-07-19 01:14:50 +00001416 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Sean Callanan108934c2009-12-18 00:01:26 +00001417 "cmovp{w}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001418 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Chenge5f62042007-09-29 00:00:36 +00001419 X86_COND_P, EFLAGS))]>,
Evan Cheng71fb9ad2006-01-26 00:29:36 +00001420 TB, OpSize;
Evan Cheng069287d2006-05-16 07:21:53 +00001421def CMOVP32rr : I<0x4A, MRMSrcReg, // if parity, GR32 = GR32
Evan Cheng64d80e32007-07-19 01:14:50 +00001422 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Sean Callanan108934c2009-12-18 00:01:26 +00001423 "cmovp{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001424 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Chenge5f62042007-09-29 00:00:36 +00001425 X86_COND_P, EFLAGS))]>,
Evan Cheng71fb9ad2006-01-26 00:29:36 +00001426 TB;
Evan Cheng069287d2006-05-16 07:21:53 +00001427def CMOVNP16rr : I<0x4B, MRMSrcReg, // if !parity, GR16 = GR16
Evan Cheng64d80e32007-07-19 01:14:50 +00001428 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Sean Callanan108934c2009-12-18 00:01:26 +00001429 "cmovnp{w}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001430 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Chenge5f62042007-09-29 00:00:36 +00001431 X86_COND_NP, EFLAGS))]>,
Evan Cheng71fb9ad2006-01-26 00:29:36 +00001432 TB, OpSize;
Evan Cheng069287d2006-05-16 07:21:53 +00001433def CMOVNP32rr : I<0x4B, MRMSrcReg, // if !parity, GR32 = GR32
Evan Cheng64d80e32007-07-19 01:14:50 +00001434 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Sean Callanan108934c2009-12-18 00:01:26 +00001435 "cmovnp{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001436 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Chenge5f62042007-09-29 00:00:36 +00001437 X86_COND_NP, EFLAGS))]>,
Evan Cheng71fb9ad2006-01-26 00:29:36 +00001438 TB;
Dan Gohman305fceb2009-01-07 00:35:10 +00001439def CMOVO16rr : I<0x40, MRMSrcReg, // if overflow, GR16 = GR16
1440 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Sean Callanan108934c2009-12-18 00:01:26 +00001441 "cmovo{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohman305fceb2009-01-07 00:35:10 +00001442 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
1443 X86_COND_O, EFLAGS))]>,
1444 TB, OpSize;
1445def CMOVO32rr : I<0x40, MRMSrcReg, // if overflow, GR32 = GR32
1446 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Sean Callanan108934c2009-12-18 00:01:26 +00001447 "cmovo{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohman305fceb2009-01-07 00:35:10 +00001448 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
1449 X86_COND_O, EFLAGS))]>,
Evan Cheng0488db92007-09-25 01:57:46 +00001450 TB;
Dan Gohman305fceb2009-01-07 00:35:10 +00001451def CMOVNO16rr : I<0x41, MRMSrcReg, // if !overflow, GR16 = GR16
1452 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Sean Callanan108934c2009-12-18 00:01:26 +00001453 "cmovno{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohman305fceb2009-01-07 00:35:10 +00001454 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
1455 X86_COND_NO, EFLAGS))]>,
1456 TB, OpSize;
1457def CMOVNO32rr : I<0x41, MRMSrcReg, // if !overflow, GR32 = GR32
1458 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Sean Callanan108934c2009-12-18 00:01:26 +00001459 "cmovno{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohman305fceb2009-01-07 00:35:10 +00001460 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
1461 X86_COND_NO, EFLAGS))]>,
1462 TB;
1463} // isCommutable = 1
Evan Cheng7ad42d92007-10-05 23:13:21 +00001464
1465def CMOVB16rm : I<0x42, MRMSrcMem, // if <u, GR16 = [mem16]
1466 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
Sean Callanan108934c2009-12-18 00:01:26 +00001467 "cmovb{w}\t{$src2, $dst|$dst, $src2}",
Evan Cheng7ad42d92007-10-05 23:13:21 +00001468 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1469 X86_COND_B, EFLAGS))]>,
1470 TB, OpSize;
1471def CMOVB32rm : I<0x42, MRMSrcMem, // if <u, GR32 = [mem32]
1472 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Sean Callanan108934c2009-12-18 00:01:26 +00001473 "cmovb{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng7ad42d92007-10-05 23:13:21 +00001474 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1475 X86_COND_B, EFLAGS))]>,
1476 TB;
1477def CMOVAE16rm: I<0x43, MRMSrcMem, // if >=u, GR16 = [mem16]
1478 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
Sean Callanan108934c2009-12-18 00:01:26 +00001479 "cmovae{w}\t{$src2, $dst|$dst, $src2}",
Evan Cheng7ad42d92007-10-05 23:13:21 +00001480 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1481 X86_COND_AE, EFLAGS))]>,
1482 TB, OpSize;
1483def CMOVAE32rm: I<0x43, MRMSrcMem, // if >=u, GR32 = [mem32]
1484 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Sean Callanan108934c2009-12-18 00:01:26 +00001485 "cmovae{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng7ad42d92007-10-05 23:13:21 +00001486 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1487 X86_COND_AE, EFLAGS))]>,
1488 TB;
1489def CMOVE16rm : I<0x44, MRMSrcMem, // if ==, GR16 = [mem16]
1490 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
Sean Callanan108934c2009-12-18 00:01:26 +00001491 "cmove{w}\t{$src2, $dst|$dst, $src2}",
Evan Cheng7ad42d92007-10-05 23:13:21 +00001492 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1493 X86_COND_E, EFLAGS))]>,
1494 TB, OpSize;
1495def CMOVE32rm : I<0x44, MRMSrcMem, // if ==, GR32 = [mem32]
1496 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Sean Callanan108934c2009-12-18 00:01:26 +00001497 "cmove{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng7ad42d92007-10-05 23:13:21 +00001498 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1499 X86_COND_E, EFLAGS))]>,
1500 TB;
1501def CMOVNE16rm: I<0x45, MRMSrcMem, // if !=, GR16 = [mem16]
1502 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
Sean Callanan108934c2009-12-18 00:01:26 +00001503 "cmovne{w}\t{$src2, $dst|$dst, $src2}",
Evan Cheng7ad42d92007-10-05 23:13:21 +00001504 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1505 X86_COND_NE, EFLAGS))]>,
1506 TB, OpSize;
1507def CMOVNE32rm: I<0x45, MRMSrcMem, // if !=, GR32 = [mem32]
1508 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Sean Callanan108934c2009-12-18 00:01:26 +00001509 "cmovne{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng7ad42d92007-10-05 23:13:21 +00001510 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1511 X86_COND_NE, EFLAGS))]>,
1512 TB;
1513def CMOVBE16rm: I<0x46, MRMSrcMem, // if <=u, GR16 = [mem16]
1514 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
Sean Callanan108934c2009-12-18 00:01:26 +00001515 "cmovbe{w}\t{$src2, $dst|$dst, $src2}",
Evan Cheng7ad42d92007-10-05 23:13:21 +00001516 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1517 X86_COND_BE, EFLAGS))]>,
1518 TB, OpSize;
1519def CMOVBE32rm: I<0x46, MRMSrcMem, // if <=u, GR32 = [mem32]
1520 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Sean Callanan108934c2009-12-18 00:01:26 +00001521 "cmovbe{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng7ad42d92007-10-05 23:13:21 +00001522 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1523 X86_COND_BE, EFLAGS))]>,
1524 TB;
1525def CMOVA16rm : I<0x47, MRMSrcMem, // if >u, GR16 = [mem16]
1526 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
Sean Callanan108934c2009-12-18 00:01:26 +00001527 "cmova{w}\t{$src2, $dst|$dst, $src2}",
Evan Cheng7ad42d92007-10-05 23:13:21 +00001528 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1529 X86_COND_A, EFLAGS))]>,
1530 TB, OpSize;
1531def CMOVA32rm : I<0x47, MRMSrcMem, // if >u, GR32 = [mem32]
1532 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Sean Callanan108934c2009-12-18 00:01:26 +00001533 "cmova{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng7ad42d92007-10-05 23:13:21 +00001534 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1535 X86_COND_A, EFLAGS))]>,
1536 TB;
1537def CMOVL16rm : I<0x4C, MRMSrcMem, // if <s, GR16 = [mem16]
1538 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
Sean Callanan108934c2009-12-18 00:01:26 +00001539 "cmovl{w}\t{$src2, $dst|$dst, $src2}",
Evan Cheng7ad42d92007-10-05 23:13:21 +00001540 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1541 X86_COND_L, EFLAGS))]>,
1542 TB, OpSize;
1543def CMOVL32rm : I<0x4C, MRMSrcMem, // if <s, GR32 = [mem32]
1544 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Sean Callanan108934c2009-12-18 00:01:26 +00001545 "cmovl{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng7ad42d92007-10-05 23:13:21 +00001546 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1547 X86_COND_L, EFLAGS))]>,
1548 TB;
1549def CMOVGE16rm: I<0x4D, MRMSrcMem, // if >=s, GR16 = [mem16]
1550 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
Sean Callanan108934c2009-12-18 00:01:26 +00001551 "cmovge{w}\t{$src2, $dst|$dst, $src2}",
Evan Cheng7ad42d92007-10-05 23:13:21 +00001552 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1553 X86_COND_GE, EFLAGS))]>,
1554 TB, OpSize;
1555def CMOVGE32rm: I<0x4D, MRMSrcMem, // if >=s, GR32 = [mem32]
1556 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Sean Callanan108934c2009-12-18 00:01:26 +00001557 "cmovge{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng7ad42d92007-10-05 23:13:21 +00001558 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1559 X86_COND_GE, EFLAGS))]>,
1560 TB;
1561def CMOVLE16rm: I<0x4E, MRMSrcMem, // if <=s, GR16 = [mem16]
1562 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
Sean Callanan108934c2009-12-18 00:01:26 +00001563 "cmovle{w}\t{$src2, $dst|$dst, $src2}",
Evan Cheng7ad42d92007-10-05 23:13:21 +00001564 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1565 X86_COND_LE, EFLAGS))]>,
1566 TB, OpSize;
1567def CMOVLE32rm: I<0x4E, MRMSrcMem, // if <=s, GR32 = [mem32]
1568 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Sean Callanan108934c2009-12-18 00:01:26 +00001569 "cmovle{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng7ad42d92007-10-05 23:13:21 +00001570 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1571 X86_COND_LE, EFLAGS))]>,
1572 TB;
1573def CMOVG16rm : I<0x4F, MRMSrcMem, // if >s, GR16 = [mem16]
1574 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
Sean Callanan108934c2009-12-18 00:01:26 +00001575 "cmovg{w}\t{$src2, $dst|$dst, $src2}",
Evan Cheng7ad42d92007-10-05 23:13:21 +00001576 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1577 X86_COND_G, EFLAGS))]>,
1578 TB, OpSize;
1579def CMOVG32rm : I<0x4F, MRMSrcMem, // if >s, GR32 = [mem32]
1580 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Sean Callanan108934c2009-12-18 00:01:26 +00001581 "cmovg{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng7ad42d92007-10-05 23:13:21 +00001582 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1583 X86_COND_G, EFLAGS))]>,
1584 TB;
1585def CMOVS16rm : I<0x48, MRMSrcMem, // if signed, GR16 = [mem16]
1586 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
Sean Callanan108934c2009-12-18 00:01:26 +00001587 "cmovs{w}\t{$src2, $dst|$dst, $src2}",
Evan Cheng7ad42d92007-10-05 23:13:21 +00001588 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1589 X86_COND_S, EFLAGS))]>,
1590 TB, OpSize;
1591def CMOVS32rm : I<0x48, MRMSrcMem, // if signed, GR32 = [mem32]
1592 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Sean Callanan108934c2009-12-18 00:01:26 +00001593 "cmovs{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng7ad42d92007-10-05 23:13:21 +00001594 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1595 X86_COND_S, EFLAGS))]>,
1596 TB;
1597def CMOVNS16rm: I<0x49, MRMSrcMem, // if !signed, GR16 = [mem16]
1598 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
Sean Callanan108934c2009-12-18 00:01:26 +00001599 "cmovns{w}\t{$src2, $dst|$dst, $src2}",
Evan Cheng7ad42d92007-10-05 23:13:21 +00001600 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1601 X86_COND_NS, EFLAGS))]>,
1602 TB, OpSize;
1603def CMOVNS32rm: I<0x49, MRMSrcMem, // if !signed, GR32 = [mem32]
1604 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Sean Callanan108934c2009-12-18 00:01:26 +00001605 "cmovns{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng7ad42d92007-10-05 23:13:21 +00001606 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1607 X86_COND_NS, EFLAGS))]>,
1608 TB;
1609def CMOVP16rm : I<0x4A, MRMSrcMem, // if parity, GR16 = [mem16]
1610 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
Sean Callanan108934c2009-12-18 00:01:26 +00001611 "cmovp{w}\t{$src2, $dst|$dst, $src2}",
Evan Cheng7ad42d92007-10-05 23:13:21 +00001612 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1613 X86_COND_P, EFLAGS))]>,
1614 TB, OpSize;
1615def CMOVP32rm : I<0x4A, MRMSrcMem, // if parity, GR32 = [mem32]
1616 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Sean Callanan108934c2009-12-18 00:01:26 +00001617 "cmovp{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng7ad42d92007-10-05 23:13:21 +00001618 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1619 X86_COND_P, EFLAGS))]>,
1620 TB;
1621def CMOVNP16rm : I<0x4B, MRMSrcMem, // if !parity, GR16 = [mem16]
1622 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
Sean Callanan108934c2009-12-18 00:01:26 +00001623 "cmovnp{w}\t{$src2, $dst|$dst, $src2}",
Evan Cheng7ad42d92007-10-05 23:13:21 +00001624 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1625 X86_COND_NP, EFLAGS))]>,
1626 TB, OpSize;
Dan Gohman305fceb2009-01-07 00:35:10 +00001627def CMOVNP32rm : I<0x4B, MRMSrcMem, // if !parity, GR32 = [mem32]
1628 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Sean Callanan108934c2009-12-18 00:01:26 +00001629 "cmovnp{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohman305fceb2009-01-07 00:35:10 +00001630 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1631 X86_COND_NP, EFLAGS))]>,
1632 TB;
1633def CMOVO16rm : I<0x40, MRMSrcMem, // if overflow, GR16 = [mem16]
1634 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
Sean Callanan108934c2009-12-18 00:01:26 +00001635 "cmovo{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohman305fceb2009-01-07 00:35:10 +00001636 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1637 X86_COND_O, EFLAGS))]>,
1638 TB, OpSize;
1639def CMOVO32rm : I<0x40, MRMSrcMem, // if overflow, GR32 = [mem32]
1640 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Sean Callanan108934c2009-12-18 00:01:26 +00001641 "cmovo{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohman305fceb2009-01-07 00:35:10 +00001642 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1643 X86_COND_O, EFLAGS))]>,
1644 TB;
1645def CMOVNO16rm : I<0x41, MRMSrcMem, // if !overflow, GR16 = [mem16]
1646 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
Sean Callanan108934c2009-12-18 00:01:26 +00001647 "cmovno{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohman305fceb2009-01-07 00:35:10 +00001648 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1649 X86_COND_NO, EFLAGS))]>,
1650 TB, OpSize;
1651def CMOVNO32rm : I<0x41, MRMSrcMem, // if !overflow, GR32 = [mem32]
1652 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Sean Callanan108934c2009-12-18 00:01:26 +00001653 "cmovno{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohman305fceb2009-01-07 00:35:10 +00001654 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1655 X86_COND_NO, EFLAGS))]>,
1656 TB;
Chris Lattner314a1132010-03-14 18:31:44 +00001657} // Predicates = [HasCMov]
1658
1659// X86 doesn't have 8-bit conditional moves. Use a customInserter to
1660// emit control flow. An alternative to this is to mark i8 SELECT as Promote,
1661// however that requires promoting the operands, and can induce additional
1662// i8 register pressure. Note that CMOV_GR8 is conservatively considered to
1663// clobber EFLAGS, because if one of the operands is zero, the expansion
1664// could involve an xor.
Eric Christophera938cfb2010-06-19 00:37:40 +00001665let usesCustomInserter = 1, Constraints = "", Defs = [EFLAGS] in {
Chris Lattner314a1132010-03-14 18:31:44 +00001666def CMOV_GR8 : I<0, Pseudo,
1667 (outs GR8:$dst), (ins GR8:$src1, GR8:$src2, i8imm:$cond),
1668 "#CMOV_GR8 PSEUDO!",
1669 [(set GR8:$dst, (X86cmov GR8:$src1, GR8:$src2,
1670 imm:$cond, EFLAGS))]>;
1671
1672let Predicates = [NoCMov] in {
1673def CMOV_GR32 : I<0, Pseudo,
1674 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2, i8imm:$cond),
1675 "#CMOV_GR32* PSEUDO!",
1676 [(set GR32:$dst,
1677 (X86cmov GR32:$src1, GR32:$src2, imm:$cond, EFLAGS))]>;
1678def CMOV_GR16 : I<0, Pseudo,
1679 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2, i8imm:$cond),
1680 "#CMOV_GR16* PSEUDO!",
1681 [(set GR16:$dst,
1682 (X86cmov GR16:$src1, GR16:$src2, imm:$cond, EFLAGS))]>;
1683def CMOV_RFP32 : I<0, Pseudo,
Eric Christophera938cfb2010-06-19 00:37:40 +00001684 (outs RFP32:$dst),
1685 (ins RFP32:$src1, RFP32:$src2, i8imm:$cond),
Chris Lattner314a1132010-03-14 18:31:44 +00001686 "#CMOV_RFP32 PSEUDO!",
Eric Christophera938cfb2010-06-19 00:37:40 +00001687 [(set RFP32:$dst,
1688 (X86cmov RFP32:$src1, RFP32:$src2, imm:$cond,
Chris Lattner314a1132010-03-14 18:31:44 +00001689 EFLAGS))]>;
1690def CMOV_RFP64 : I<0, Pseudo,
Eric Christophera938cfb2010-06-19 00:37:40 +00001691 (outs RFP64:$dst),
1692 (ins RFP64:$src1, RFP64:$src2, i8imm:$cond),
Chris Lattner314a1132010-03-14 18:31:44 +00001693 "#CMOV_RFP64 PSEUDO!",
Eric Christophera938cfb2010-06-19 00:37:40 +00001694 [(set RFP64:$dst,
1695 (X86cmov RFP64:$src1, RFP64:$src2, imm:$cond,
Chris Lattner314a1132010-03-14 18:31:44 +00001696 EFLAGS))]>;
1697def CMOV_RFP80 : I<0, Pseudo,
Eric Christophera938cfb2010-06-19 00:37:40 +00001698 (outs RFP80:$dst),
1699 (ins RFP80:$src1, RFP80:$src2, i8imm:$cond),
Chris Lattner314a1132010-03-14 18:31:44 +00001700 "#CMOV_RFP80 PSEUDO!",
Eric Christophera938cfb2010-06-19 00:37:40 +00001701 [(set RFP80:$dst,
1702 (X86cmov RFP80:$src1, RFP80:$src2, imm:$cond,
Chris Lattner314a1132010-03-14 18:31:44 +00001703 EFLAGS))]>;
1704} // Predicates = [NoCMov]
Eric Christophera938cfb2010-06-19 00:37:40 +00001705} // UsesCustomInserter = 1, Constraints = "", Defs = [EFLAGS]
Evan Cheng0488db92007-09-25 01:57:46 +00001706} // Uses = [EFLAGS]
1707
1708
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00001709// unary instructions
Evan Cheng1693e482006-07-19 00:27:29 +00001710let CodeSize = 2 in {
Evan Cheng24f2ea32007-09-14 21:48:26 +00001711let Defs = [EFLAGS] in {
Eric Christophera938cfb2010-06-19 00:37:40 +00001712def NEG8r : I<0xF6, MRM3r, (outs GR8 :$dst), (ins GR8 :$src1),
1713 "neg{b}\t$dst",
1714 [(set GR8:$dst, (ineg GR8:$src1)),
Dan Gohman09a2609e2009-03-03 19:53:46 +00001715 (implicit EFLAGS)]>;
Eric Christophera938cfb2010-06-19 00:37:40 +00001716def NEG16r : I<0xF7, MRM3r, (outs GR16:$dst), (ins GR16:$src1),
1717 "neg{w}\t$dst",
1718 [(set GR16:$dst, (ineg GR16:$src1)),
Dan Gohman09a2609e2009-03-03 19:53:46 +00001719 (implicit EFLAGS)]>, OpSize;
Eric Christophera938cfb2010-06-19 00:37:40 +00001720def NEG32r : I<0xF7, MRM3r, (outs GR32:$dst), (ins GR32:$src1),
1721 "neg{l}\t$dst",
1722 [(set GR32:$dst, (ineg GR32:$src1)),
Dan Gohman09a2609e2009-03-03 19:53:46 +00001723 (implicit EFLAGS)]>;
Eric Christophera938cfb2010-06-19 00:37:40 +00001724
1725let Constraints = "" in {
1726 def NEG8m : I<0xF6, MRM3m, (outs), (ins i8mem :$dst),
1727 "neg{b}\t$dst",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001728 [(store (ineg (loadi8 addr:$dst)), addr:$dst),
1729 (implicit EFLAGS)]>;
Eric Christophera938cfb2010-06-19 00:37:40 +00001730 def NEG16m : I<0xF7, MRM3m, (outs), (ins i16mem:$dst),
1731 "neg{w}\t$dst",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001732 [(store (ineg (loadi16 addr:$dst)), addr:$dst),
1733 (implicit EFLAGS)]>, OpSize;
Eric Christophera938cfb2010-06-19 00:37:40 +00001734 def NEG32m : I<0xF7, MRM3m, (outs), (ins i32mem:$dst),
1735 "neg{l}\t$dst",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001736 [(store (ineg (loadi32 addr:$dst)), addr:$dst),
1737 (implicit EFLAGS)]>;
Eric Christophera938cfb2010-06-19 00:37:40 +00001738} // Constraints = ""
Evan Cheng24f2ea32007-09-14 21:48:26 +00001739} // Defs = [EFLAGS]
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00001740
Evan Chengaaf414c2009-01-21 02:09:05 +00001741// Match xor -1 to not. Favors these over a move imm + xor to save code size.
1742let AddedComplexity = 15 in {
Eric Christophera938cfb2010-06-19 00:37:40 +00001743def NOT8r : I<0xF6, MRM2r, (outs GR8 :$dst), (ins GR8 :$src1),
1744 "not{b}\t$dst",
1745 [(set GR8:$dst, (not GR8:$src1))]>;
1746def NOT16r : I<0xF7, MRM2r, (outs GR16:$dst), (ins GR16:$src1),
1747 "not{w}\t$dst",
1748 [(set GR16:$dst, (not GR16:$src1))]>, OpSize;
1749def NOT32r : I<0xF7, MRM2r, (outs GR32:$dst), (ins GR32:$src1),
1750 "not{l}\t$dst",
1751 [(set GR32:$dst, (not GR32:$src1))]>;
Evan Chengaaf414c2009-01-21 02:09:05 +00001752}
Eric Christophera938cfb2010-06-19 00:37:40 +00001753let Constraints = "" in {
1754 def NOT8m : I<0xF6, MRM2m, (outs), (ins i8mem :$dst),
1755 "not{b}\t$dst",
Evan Cheng605c4152005-12-13 01:57:51 +00001756 [(store (not (loadi8 addr:$dst)), addr:$dst)]>;
Eric Christophera938cfb2010-06-19 00:37:40 +00001757 def NOT16m : I<0xF7, MRM2m, (outs), (ins i16mem:$dst),
1758 "not{w}\t$dst",
Evan Cheng605c4152005-12-13 01:57:51 +00001759 [(store (not (loadi16 addr:$dst)), addr:$dst)]>, OpSize;
Eric Christophera938cfb2010-06-19 00:37:40 +00001760 def NOT32m : I<0xF7, MRM2m, (outs), (ins i32mem:$dst),
1761 "not{l}\t$dst",
Evan Cheng605c4152005-12-13 01:57:51 +00001762 [(store (not (loadi32 addr:$dst)), addr:$dst)]>;
Eric Christophera938cfb2010-06-19 00:37:40 +00001763} // Constraints = ""
Evan Cheng1693e482006-07-19 00:27:29 +00001764} // CodeSize
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00001765
Evan Chengb51a0592005-12-10 00:48:20 +00001766// TODO: inc/dec is slow for P4, but fast for Pentium-M.
Evan Cheng24f2ea32007-09-14 21:48:26 +00001767let Defs = [EFLAGS] in {
Evan Cheng1693e482006-07-19 00:27:29 +00001768let CodeSize = 2 in
Eric Christophera938cfb2010-06-19 00:37:40 +00001769def INC8r : I<0xFE, MRM0r, (outs GR8 :$dst), (ins GR8 :$src1),
1770 "inc{b}\t$dst",
1771 [(set GR8:$dst, EFLAGS, (X86inc_flag GR8:$src1))]>;
Chris Lattnerc54a2f12010-03-24 01:02:12 +00001772
Evan Cheng1693e482006-07-19 00:27:29 +00001773let isConvertibleToThreeAddress = 1, CodeSize = 1 in { // Can xform into LEA.
Eric Christophera938cfb2010-06-19 00:37:40 +00001774def INC16r : I<0x40, AddRegFrm, (outs GR16:$dst), (ins GR16:$src1),
Sean Callanan108934c2009-12-18 00:01:26 +00001775 "inc{w}\t$dst",
Eric Christophera938cfb2010-06-19 00:37:40 +00001776 [(set GR16:$dst, EFLAGS, (X86inc_flag GR16:$src1))]>,
Evan Cheng25ab6902006-09-08 06:48:29 +00001777 OpSize, Requires<[In32BitMode]>;
Eric Christophera938cfb2010-06-19 00:37:40 +00001778def INC32r : I<0x40, AddRegFrm, (outs GR32:$dst), (ins GR32:$src1),
Sean Callanan108934c2009-12-18 00:01:26 +00001779 "inc{l}\t$dst",
Eric Christophera938cfb2010-06-19 00:37:40 +00001780 [(set GR32:$dst, EFLAGS, (X86inc_flag GR32:$src1))]>,
Chris Lattner589ad5d2010-03-25 05:44:01 +00001781 Requires<[In32BitMode]>;
Chris Lattnercc65bee2005-01-02 02:35:46 +00001782}
Eric Christophera938cfb2010-06-19 00:37:40 +00001783let Constraints = "", CodeSize = 2 in {
Dan Gohmanb1576f52007-07-31 20:11:57 +00001784 def INC8m : I<0xFE, MRM0m, (outs), (ins i8mem :$dst), "inc{b}\t$dst",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001785 [(store (add (loadi8 addr:$dst), 1), addr:$dst),
1786 (implicit EFLAGS)]>;
Dan Gohmanb1576f52007-07-31 20:11:57 +00001787 def INC16m : I<0xFF, MRM0m, (outs), (ins i16mem:$dst), "inc{w}\t$dst",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001788 [(store (add (loadi16 addr:$dst), 1), addr:$dst),
1789 (implicit EFLAGS)]>,
Evan Cheng66f71632007-10-19 21:23:22 +00001790 OpSize, Requires<[In32BitMode]>;
Dan Gohmanb1576f52007-07-31 20:11:57 +00001791 def INC32m : I<0xFF, MRM0m, (outs), (ins i32mem:$dst), "inc{l}\t$dst",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001792 [(store (add (loadi32 addr:$dst), 1), addr:$dst),
1793 (implicit EFLAGS)]>,
Evan Cheng66f71632007-10-19 21:23:22 +00001794 Requires<[In32BitMode]>;
Eric Christophera938cfb2010-06-19 00:37:40 +00001795} // Constraints = "", CodeSize = 2
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00001796
Evan Cheng1693e482006-07-19 00:27:29 +00001797let CodeSize = 2 in
Eric Christophera938cfb2010-06-19 00:37:40 +00001798def DEC8r : I<0xFE, MRM1r, (outs GR8 :$dst), (ins GR8 :$src1),
1799 "dec{b}\t$dst",
1800 [(set GR8:$dst, EFLAGS, (X86dec_flag GR8:$src1))]>;
Evan Cheng1693e482006-07-19 00:27:29 +00001801let isConvertibleToThreeAddress = 1, CodeSize = 1 in { // Can xform into LEA.
Eric Christophera938cfb2010-06-19 00:37:40 +00001802def DEC16r : I<0x48, AddRegFrm, (outs GR16:$dst), (ins GR16:$src1),
Sean Callanan108934c2009-12-18 00:01:26 +00001803 "dec{w}\t$dst",
Eric Christophera938cfb2010-06-19 00:37:40 +00001804 [(set GR16:$dst, EFLAGS, (X86dec_flag GR16:$src1))]>,
Evan Cheng25ab6902006-09-08 06:48:29 +00001805 OpSize, Requires<[In32BitMode]>;
Eric Christophera938cfb2010-06-19 00:37:40 +00001806def DEC32r : I<0x48, AddRegFrm, (outs GR32:$dst), (ins GR32:$src1),
Sean Callanan108934c2009-12-18 00:01:26 +00001807 "dec{l}\t$dst",
Eric Christophera938cfb2010-06-19 00:37:40 +00001808 [(set GR32:$dst, EFLAGS, (X86dec_flag GR32:$src1))]>,
Chris Lattner589ad5d2010-03-25 05:44:01 +00001809 Requires<[In32BitMode]>;
Eric Christophera938cfb2010-06-19 00:37:40 +00001810} // CodeSize = 2
Chris Lattner57a02302004-08-11 04:31:00 +00001811
Eric Christophera938cfb2010-06-19 00:37:40 +00001812let Constraints = "", CodeSize = 2 in {
Dan Gohmanb1576f52007-07-31 20:11:57 +00001813 def DEC8m : I<0xFE, MRM1m, (outs), (ins i8mem :$dst), "dec{b}\t$dst",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001814 [(store (add (loadi8 addr:$dst), -1), addr:$dst),
1815 (implicit EFLAGS)]>;
Dan Gohmanb1576f52007-07-31 20:11:57 +00001816 def DEC16m : I<0xFF, MRM1m, (outs), (ins i16mem:$dst), "dec{w}\t$dst",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001817 [(store (add (loadi16 addr:$dst), -1), addr:$dst),
1818 (implicit EFLAGS)]>,
Evan Cheng66f71632007-10-19 21:23:22 +00001819 OpSize, Requires<[In32BitMode]>;
Dan Gohmanb1576f52007-07-31 20:11:57 +00001820 def DEC32m : I<0xFF, MRM1m, (outs), (ins i32mem:$dst), "dec{l}\t$dst",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001821 [(store (add (loadi32 addr:$dst), -1), addr:$dst),
1822 (implicit EFLAGS)]>,
Evan Cheng66f71632007-10-19 21:23:22 +00001823 Requires<[In32BitMode]>;
Eric Christophera938cfb2010-06-19 00:37:40 +00001824} // Constraints = "", CodeSize = 2
Evan Cheng24f2ea32007-09-14 21:48:26 +00001825} // Defs = [EFLAGS]
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00001826
1827// Logical operators...
Evan Cheng24f2ea32007-09-14 21:48:26 +00001828let Defs = [EFLAGS] in {
Chris Lattnercc65bee2005-01-02 02:35:46 +00001829let isCommutable = 1 in { // X = AND Y, Z --> X = AND Z, Y
Chris Lattner589ad5d2010-03-25 05:44:01 +00001830def AND8rr : I<0x20, MRMDestReg,
1831 (outs GR8 :$dst), (ins GR8 :$src1, GR8 :$src2),
1832 "and{b}\t{$src2, $dst|$dst, $src2}",
1833 [(set GR8:$dst, EFLAGS, (X86and_flag GR8:$src1, GR8:$src2))]>;
1834def AND16rr : I<0x21, MRMDestReg,
1835 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
1836 "and{w}\t{$src2, $dst|$dst, $src2}",
1837 [(set GR16:$dst, EFLAGS, (X86and_flag GR16:$src1,
1838 GR16:$src2))]>, OpSize;
1839def AND32rr : I<0x21, MRMDestReg,
1840 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
1841 "and{l}\t{$src2, $dst|$dst, $src2}",
1842 [(set GR32:$dst, EFLAGS, (X86and_flag GR32:$src1,
1843 GR32:$src2))]>;
Chris Lattnercc65bee2005-01-02 02:35:46 +00001844}
Chris Lattner57a02302004-08-11 04:31:00 +00001845
Sean Callanan108934c2009-12-18 00:01:26 +00001846// AND instructions with the destination register in REG and the source register
1847// in R/M. Included for the disassembler.
Daniel Dunbardcbab9c2010-05-26 22:21:28 +00001848let isCodeGenOnly = 1 in {
Sean Callanan108934c2009-12-18 00:01:26 +00001849def AND8rr_REV : I<0x22, MRMSrcReg, (outs GR8:$dst), (ins GR8:$src1, GR8:$src2),
1850 "and{b}\t{$src2, $dst|$dst, $src2}", []>;
1851def AND16rr_REV : I<0x23, MRMSrcReg, (outs GR16:$dst),
1852 (ins GR16:$src1, GR16:$src2),
1853 "and{w}\t{$src2, $dst|$dst, $src2}", []>, OpSize;
1854def AND32rr_REV : I<0x23, MRMSrcReg, (outs GR32:$dst),
1855 (ins GR32:$src1, GR32:$src2),
1856 "and{l}\t{$src2, $dst|$dst, $src2}", []>;
Daniel Dunbardcbab9c2010-05-26 22:21:28 +00001857}
Sean Callanan108934c2009-12-18 00:01:26 +00001858
Chris Lattner3a173df2004-10-03 20:35:00 +00001859def AND8rm : I<0x22, MRMSrcMem,
Evan Cheng64d80e32007-07-19 01:14:50 +00001860 (outs GR8 :$dst), (ins GR8 :$src1, i8mem :$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001861 "and{b}\t{$src2, $dst|$dst, $src2}",
Chris Lattner589ad5d2010-03-25 05:44:01 +00001862 [(set GR8:$dst, EFLAGS, (X86and_flag GR8:$src1,
1863 (loadi8 addr:$src2)))]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00001864def AND16rm : I<0x23, MRMSrcMem,
Evan Cheng64d80e32007-07-19 01:14:50 +00001865 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001866 "and{w}\t{$src2, $dst|$dst, $src2}",
Chris Lattner589ad5d2010-03-25 05:44:01 +00001867 [(set GR16:$dst, EFLAGS, (X86and_flag GR16:$src1,
1868 (loadi16 addr:$src2)))]>,
1869 OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00001870def AND32rm : I<0x23, MRMSrcMem,
Evan Cheng64d80e32007-07-19 01:14:50 +00001871 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001872 "and{l}\t{$src2, $dst|$dst, $src2}",
Chris Lattner589ad5d2010-03-25 05:44:01 +00001873 [(set GR32:$dst, EFLAGS, (X86and_flag GR32:$src1,
1874 (loadi32 addr:$src2)))]>;
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00001875
Chris Lattner3a173df2004-10-03 20:35:00 +00001876def AND8ri : Ii8<0x80, MRM4r,
Evan Cheng64d80e32007-07-19 01:14:50 +00001877 (outs GR8 :$dst), (ins GR8 :$src1, i8imm :$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001878 "and{b}\t{$src2, $dst|$dst, $src2}",
Chris Lattner589ad5d2010-03-25 05:44:01 +00001879 [(set GR8:$dst, EFLAGS, (X86and_flag GR8:$src1,
1880 imm:$src2))]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00001881def AND16ri : Ii16<0x81, MRM4r,
Evan Cheng64d80e32007-07-19 01:14:50 +00001882 (outs GR16:$dst), (ins GR16:$src1, i16imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001883 "and{w}\t{$src2, $dst|$dst, $src2}",
Chris Lattner589ad5d2010-03-25 05:44:01 +00001884 [(set GR16:$dst, EFLAGS, (X86and_flag GR16:$src1,
1885 imm:$src2))]>, OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00001886def AND32ri : Ii32<0x81, MRM4r,
Evan Cheng64d80e32007-07-19 01:14:50 +00001887 (outs GR32:$dst), (ins GR32:$src1, i32imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001888 "and{l}\t{$src2, $dst|$dst, $src2}",
Chris Lattner589ad5d2010-03-25 05:44:01 +00001889 [(set GR32:$dst, EFLAGS, (X86and_flag GR32:$src1,
1890 imm:$src2))]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00001891def AND16ri8 : Ii8<0x83, MRM4r,
Evan Cheng64d80e32007-07-19 01:14:50 +00001892 (outs GR16:$dst), (ins GR16:$src1, i16i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001893 "and{w}\t{$src2, $dst|$dst, $src2}",
Chris Lattner589ad5d2010-03-25 05:44:01 +00001894 [(set GR16:$dst, EFLAGS, (X86and_flag GR16:$src1,
1895 i16immSExt8:$src2))]>,
Evan Cheng9b6b6422005-12-13 00:14:11 +00001896 OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00001897def AND32ri8 : Ii8<0x83, MRM4r,
Evan Cheng64d80e32007-07-19 01:14:50 +00001898 (outs GR32:$dst), (ins GR32:$src1, i32i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001899 "and{l}\t{$src2, $dst|$dst, $src2}",
Chris Lattner589ad5d2010-03-25 05:44:01 +00001900 [(set GR32:$dst, EFLAGS, (X86and_flag GR32:$src1,
1901 i32immSExt8:$src2))]>;
Chris Lattnerf29ed092004-08-11 05:07:25 +00001902
Eric Christophera938cfb2010-06-19 00:37:40 +00001903let Constraints = "" in {
Chris Lattner3a173df2004-10-03 20:35:00 +00001904 def AND8mr : I<0x20, MRMDestMem,
Evan Cheng64d80e32007-07-19 01:14:50 +00001905 (outs), (ins i8mem :$dst, GR8 :$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001906 "and{b}\t{$src, $dst|$dst, $src}",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001907 [(store (and (load addr:$dst), GR8:$src), addr:$dst),
1908 (implicit EFLAGS)]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00001909 def AND16mr : I<0x21, MRMDestMem,
Evan Cheng64d80e32007-07-19 01:14:50 +00001910 (outs), (ins i16mem:$dst, GR16:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001911 "and{w}\t{$src, $dst|$dst, $src}",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001912 [(store (and (load addr:$dst), GR16:$src), addr:$dst),
1913 (implicit EFLAGS)]>,
Evan Cheng0ef3a772005-12-13 01:41:36 +00001914 OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00001915 def AND32mr : I<0x21, MRMDestMem,
Evan Cheng64d80e32007-07-19 01:14:50 +00001916 (outs), (ins i32mem:$dst, GR32:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001917 "and{l}\t{$src, $dst|$dst, $src}",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001918 [(store (and (load addr:$dst), GR32:$src), addr:$dst),
1919 (implicit EFLAGS)]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00001920 def AND8mi : Ii8<0x80, MRM4m,
Evan Cheng64d80e32007-07-19 01:14:50 +00001921 (outs), (ins i8mem :$dst, i8imm :$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001922 "and{b}\t{$src, $dst|$dst, $src}",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001923 [(store (and (loadi8 addr:$dst), imm:$src), addr:$dst),
1924 (implicit EFLAGS)]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00001925 def AND16mi : Ii16<0x81, MRM4m,
Evan Cheng64d80e32007-07-19 01:14:50 +00001926 (outs), (ins i16mem:$dst, i16imm:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001927 "and{w}\t{$src, $dst|$dst, $src}",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001928 [(store (and (loadi16 addr:$dst), imm:$src), addr:$dst),
1929 (implicit EFLAGS)]>,
Evan Cheng0ef3a772005-12-13 01:41:36 +00001930 OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00001931 def AND32mi : Ii32<0x81, MRM4m,
Evan Cheng64d80e32007-07-19 01:14:50 +00001932 (outs), (ins i32mem:$dst, i32imm:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001933 "and{l}\t{$src, $dst|$dst, $src}",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001934 [(store (and (loadi32 addr:$dst), imm:$src), addr:$dst),
1935 (implicit EFLAGS)]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00001936 def AND16mi8 : Ii8<0x83, MRM4m,
Evan Cheng64d80e32007-07-19 01:14:50 +00001937 (outs), (ins i16mem:$dst, i16i8imm :$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001938 "and{w}\t{$src, $dst|$dst, $src}",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001939 [(store (and (load addr:$dst), i16immSExt8:$src), addr:$dst),
1940 (implicit EFLAGS)]>,
Evan Cheng0ef3a772005-12-13 01:41:36 +00001941 OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00001942 def AND32mi8 : Ii8<0x83, MRM4m,
Evan Cheng64d80e32007-07-19 01:14:50 +00001943 (outs), (ins i32mem:$dst, i32i8imm :$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001944 "and{l}\t{$src, $dst|$dst, $src}",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001945 [(store (and (load addr:$dst), i32immSExt8:$src), addr:$dst),
1946 (implicit EFLAGS)]>;
Sean Callanana09caa52009-09-02 00:55:49 +00001947
1948 def AND8i8 : Ii8<0x24, RawFrm, (outs), (ins i8imm:$src),
1949 "and{b}\t{$src, %al|%al, $src}", []>;
1950 def AND16i16 : Ii16<0x25, RawFrm, (outs), (ins i16imm:$src),
1951 "and{w}\t{$src, %ax|%ax, $src}", []>, OpSize;
1952 def AND32i32 : Ii32<0x25, RawFrm, (outs), (ins i32imm:$src),
1953 "and{l}\t{$src, %eax|%eax, $src}", []>;
1954
Eric Christophera938cfb2010-06-19 00:37:40 +00001955} // Constraints = ""
Chris Lattnerf29ed092004-08-11 05:07:25 +00001956
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00001957
Chris Lattnercc65bee2005-01-02 02:35:46 +00001958let isCommutable = 1 in { // X = OR Y, Z --> X = OR Z, Y
Sean Callanan108934c2009-12-18 00:01:26 +00001959def OR8rr : I<0x08, MRMDestReg, (outs GR8 :$dst),
1960 (ins GR8 :$src1, GR8 :$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001961 "or{b}\t{$src2, $dst|$dst, $src2}",
Chris Lattner589ad5d2010-03-25 05:44:01 +00001962 [(set GR8:$dst, EFLAGS, (X86or_flag GR8:$src1, GR8:$src2))]>;
Sean Callanan108934c2009-12-18 00:01:26 +00001963def OR16rr : I<0x09, MRMDestReg, (outs GR16:$dst),
1964 (ins GR16:$src1, GR16:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001965 "or{w}\t{$src2, $dst|$dst, $src2}",
Chris Lattner589ad5d2010-03-25 05:44:01 +00001966 [(set GR16:$dst, EFLAGS, (X86or_flag GR16:$src1,GR16:$src2))]>,
1967 OpSize;
Sean Callanan108934c2009-12-18 00:01:26 +00001968def OR32rr : I<0x09, MRMDestReg, (outs GR32:$dst),
1969 (ins GR32:$src1, GR32:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001970 "or{l}\t{$src2, $dst|$dst, $src2}",
Chris Lattner589ad5d2010-03-25 05:44:01 +00001971 [(set GR32:$dst, EFLAGS, (X86or_flag GR32:$src1,GR32:$src2))]>;
Chris Lattnercc65bee2005-01-02 02:35:46 +00001972}
Sean Callanan108934c2009-12-18 00:01:26 +00001973
1974// OR instructions with the destination register in REG and the source register
1975// in R/M. Included for the disassembler.
Daniel Dunbardcbab9c2010-05-26 22:21:28 +00001976let isCodeGenOnly = 1 in {
Sean Callanan108934c2009-12-18 00:01:26 +00001977def OR8rr_REV : I<0x0A, MRMSrcReg, (outs GR8:$dst), (ins GR8:$src1, GR8:$src2),
1978 "or{b}\t{$src2, $dst|$dst, $src2}", []>;
1979def OR16rr_REV : I<0x0B, MRMSrcReg, (outs GR16:$dst),
1980 (ins GR16:$src1, GR16:$src2),
1981 "or{w}\t{$src2, $dst|$dst, $src2}", []>, OpSize;
1982def OR32rr_REV : I<0x0B, MRMSrcReg, (outs GR32:$dst),
1983 (ins GR32:$src1, GR32:$src2),
1984 "or{l}\t{$src2, $dst|$dst, $src2}", []>;
Daniel Dunbardcbab9c2010-05-26 22:21:28 +00001985}
Sean Callanan108934c2009-12-18 00:01:26 +00001986
Chris Lattner589ad5d2010-03-25 05:44:01 +00001987def OR8rm : I<0x0A, MRMSrcMem, (outs GR8 :$dst),
Sean Callanan108934c2009-12-18 00:01:26 +00001988 (ins GR8 :$src1, i8mem :$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001989 "or{b}\t{$src2, $dst|$dst, $src2}",
Chris Lattner589ad5d2010-03-25 05:44:01 +00001990 [(set GR8:$dst, EFLAGS, (X86or_flag GR8:$src1,
1991 (load addr:$src2)))]>;
1992def OR16rm : I<0x0B, MRMSrcMem, (outs GR16:$dst),
Sean Callanan108934c2009-12-18 00:01:26 +00001993 (ins GR16:$src1, i16mem:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001994 "or{w}\t{$src2, $dst|$dst, $src2}",
Chris Lattner589ad5d2010-03-25 05:44:01 +00001995 [(set GR16:$dst, EFLAGS, (X86or_flag GR16:$src1,
1996 (load addr:$src2)))]>,
1997 OpSize;
1998def OR32rm : I<0x0B, MRMSrcMem, (outs GR32:$dst),
Sean Callanan108934c2009-12-18 00:01:26 +00001999 (ins GR32:$src1, i32mem:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002000 "or{l}\t{$src2, $dst|$dst, $src2}",
Chris Lattner589ad5d2010-03-25 05:44:01 +00002001 [(set GR32:$dst, EFLAGS, (X86or_flag GR32:$src1,
2002 (load addr:$src2)))]>;
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00002003
Sean Callanan108934c2009-12-18 00:01:26 +00002004def OR8ri : Ii8 <0x80, MRM1r, (outs GR8 :$dst),
2005 (ins GR8 :$src1, i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002006 "or{b}\t{$src2, $dst|$dst, $src2}",
Chris Lattner589ad5d2010-03-25 05:44:01 +00002007 [(set GR8:$dst,EFLAGS, (X86or_flag GR8:$src1, imm:$src2))]>;
Sean Callanan108934c2009-12-18 00:01:26 +00002008def OR16ri : Ii16<0x81, MRM1r, (outs GR16:$dst),
2009 (ins GR16:$src1, i16imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002010 "or{w}\t{$src2, $dst|$dst, $src2}",
Chris Lattner589ad5d2010-03-25 05:44:01 +00002011 [(set GR16:$dst, EFLAGS, (X86or_flag GR16:$src1,
2012 imm:$src2))]>, OpSize;
Sean Callanan108934c2009-12-18 00:01:26 +00002013def OR32ri : Ii32<0x81, MRM1r, (outs GR32:$dst),
2014 (ins GR32:$src1, i32imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002015 "or{l}\t{$src2, $dst|$dst, $src2}",
Chris Lattner589ad5d2010-03-25 05:44:01 +00002016 [(set GR32:$dst, EFLAGS, (X86or_flag GR32:$src1,
2017 imm:$src2))]>;
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00002018
Sean Callanan108934c2009-12-18 00:01:26 +00002019def OR16ri8 : Ii8<0x83, MRM1r, (outs GR16:$dst),
2020 (ins GR16:$src1, i16i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002021 "or{w}\t{$src2, $dst|$dst, $src2}",
Chris Lattner589ad5d2010-03-25 05:44:01 +00002022 [(set GR16:$dst, EFLAGS, (X86or_flag GR16:$src1,
2023 i16immSExt8:$src2))]>, OpSize;
Sean Callanan108934c2009-12-18 00:01:26 +00002024def OR32ri8 : Ii8<0x83, MRM1r, (outs GR32:$dst),
2025 (ins GR32:$src1, i32i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002026 "or{l}\t{$src2, $dst|$dst, $src2}",
Chris Lattner589ad5d2010-03-25 05:44:01 +00002027 [(set GR32:$dst, EFLAGS, (X86or_flag GR32:$src1,
2028 i32immSExt8:$src2))]>;
Eric Christophera938cfb2010-06-19 00:37:40 +00002029let Constraints = "" in {
Evan Cheng64d80e32007-07-19 01:14:50 +00002030 def OR8mr : I<0x08, MRMDestMem, (outs), (ins i8mem:$dst, GR8:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002031 "or{b}\t{$src, $dst|$dst, $src}",
Dan Gohman09a2609e2009-03-03 19:53:46 +00002032 [(store (or (load addr:$dst), GR8:$src), addr:$dst),
2033 (implicit EFLAGS)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00002034 def OR16mr : I<0x09, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002035 "or{w}\t{$src, $dst|$dst, $src}",
Dan Gohman09a2609e2009-03-03 19:53:46 +00002036 [(store (or (load addr:$dst), GR16:$src), addr:$dst),
2037 (implicit EFLAGS)]>, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00002038 def OR32mr : I<0x09, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002039 "or{l}\t{$src, $dst|$dst, $src}",
Dan Gohman09a2609e2009-03-03 19:53:46 +00002040 [(store (or (load addr:$dst), GR32:$src), addr:$dst),
2041 (implicit EFLAGS)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00002042 def OR8mi : Ii8<0x80, MRM1m, (outs), (ins i8mem :$dst, i8imm:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002043 "or{b}\t{$src, $dst|$dst, $src}",
Dan Gohman09a2609e2009-03-03 19:53:46 +00002044 [(store (or (loadi8 addr:$dst), imm:$src), addr:$dst),
2045 (implicit EFLAGS)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00002046 def OR16mi : Ii16<0x81, MRM1m, (outs), (ins i16mem:$dst, i16imm:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002047 "or{w}\t{$src, $dst|$dst, $src}",
Dan Gohman09a2609e2009-03-03 19:53:46 +00002048 [(store (or (loadi16 addr:$dst), imm:$src), addr:$dst),
2049 (implicit EFLAGS)]>,
Evan Cheng0ef3a772005-12-13 01:41:36 +00002050 OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00002051 def OR32mi : Ii32<0x81, MRM1m, (outs), (ins i32mem:$dst, i32imm:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002052 "or{l}\t{$src, $dst|$dst, $src}",
Dan Gohman09a2609e2009-03-03 19:53:46 +00002053 [(store (or (loadi32 addr:$dst), imm:$src), addr:$dst),
2054 (implicit EFLAGS)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00002055 def OR16mi8 : Ii8<0x83, MRM1m, (outs), (ins i16mem:$dst, i16i8imm:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002056 "or{w}\t{$src, $dst|$dst, $src}",
Dan Gohman09a2609e2009-03-03 19:53:46 +00002057 [(store (or (load addr:$dst), i16immSExt8:$src), addr:$dst),
2058 (implicit EFLAGS)]>,
Evan Cheng0ef3a772005-12-13 01:41:36 +00002059 OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00002060 def OR32mi8 : Ii8<0x83, MRM1m, (outs), (ins i32mem:$dst, i32i8imm:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002061 "or{l}\t{$src, $dst|$dst, $src}",
Dan Gohman09a2609e2009-03-03 19:53:46 +00002062 [(store (or (load addr:$dst), i32immSExt8:$src), addr:$dst),
2063 (implicit EFLAGS)]>;
Sean Callanand00025a2009-09-11 19:01:56 +00002064
2065 def OR8i8 : Ii8 <0x0C, RawFrm, (outs), (ins i8imm:$src),
2066 "or{b}\t{$src, %al|%al, $src}", []>;
2067 def OR16i16 : Ii16 <0x0D, RawFrm, (outs), (ins i16imm:$src),
2068 "or{w}\t{$src, %ax|%ax, $src}", []>, OpSize;
2069 def OR32i32 : Ii32 <0x0D, RawFrm, (outs), (ins i32imm:$src),
2070 "or{l}\t{$src, %eax|%eax, $src}", []>;
Eric Christophera938cfb2010-06-19 00:37:40 +00002071} // Constraints = ""
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00002072
2073
Evan Cheng359e9372008-06-18 08:13:07 +00002074let isCommutable = 1 in { // X = XOR Y, Z --> X = XOR Z, Y
Bill Wendlingbd0879d2008-05-29 01:02:09 +00002075 def XOR8rr : I<0x30, MRMDestReg,
2076 (outs GR8 :$dst), (ins GR8 :$src1, GR8 :$src2),
2077 "xor{b}\t{$src2, $dst|$dst, $src2}",
Chris Lattner589ad5d2010-03-25 05:44:01 +00002078 [(set GR8:$dst, EFLAGS, (X86xor_flag GR8:$src1,
2079 GR8:$src2))]>;
Bill Wendlingbd0879d2008-05-29 01:02:09 +00002080 def XOR16rr : I<0x31, MRMDestReg,
2081 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
2082 "xor{w}\t{$src2, $dst|$dst, $src2}",
Chris Lattner589ad5d2010-03-25 05:44:01 +00002083 [(set GR16:$dst, EFLAGS, (X86xor_flag GR16:$src1,
2084 GR16:$src2))]>, OpSize;
Bill Wendlingbd0879d2008-05-29 01:02:09 +00002085 def XOR32rr : I<0x31, MRMDestReg,
2086 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
2087 "xor{l}\t{$src2, $dst|$dst, $src2}",
Chris Lattner589ad5d2010-03-25 05:44:01 +00002088 [(set GR32:$dst, EFLAGS, (X86xor_flag GR32:$src1,
2089 GR32:$src2))]>;
Evan Cheng359e9372008-06-18 08:13:07 +00002090} // isCommutable = 1
Chris Lattnercc65bee2005-01-02 02:35:46 +00002091
Sean Callanan108934c2009-12-18 00:01:26 +00002092// XOR instructions with the destination register in REG and the source register
2093// in R/M. Included for the disassembler.
Daniel Dunbardcbab9c2010-05-26 22:21:28 +00002094let isCodeGenOnly = 1 in {
Sean Callanan108934c2009-12-18 00:01:26 +00002095def XOR8rr_REV : I<0x32, MRMSrcReg, (outs GR8:$dst), (ins GR8:$src1, GR8:$src2),
2096 "xor{b}\t{$src2, $dst|$dst, $src2}", []>;
2097def XOR16rr_REV : I<0x33, MRMSrcReg, (outs GR16:$dst),
2098 (ins GR16:$src1, GR16:$src2),
2099 "xor{w}\t{$src2, $dst|$dst, $src2}", []>, OpSize;
2100def XOR32rr_REV : I<0x33, MRMSrcReg, (outs GR32:$dst),
2101 (ins GR32:$src1, GR32:$src2),
2102 "xor{l}\t{$src2, $dst|$dst, $src2}", []>;
Daniel Dunbardcbab9c2010-05-26 22:21:28 +00002103}
Sean Callanan108934c2009-12-18 00:01:26 +00002104
Chris Lattner589ad5d2010-03-25 05:44:01 +00002105def XOR8rm : I<0x32, MRMSrcMem,
Evan Cheng64d80e32007-07-19 01:14:50 +00002106 (outs GR8 :$dst), (ins GR8:$src1, i8mem :$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002107 "xor{b}\t{$src2, $dst|$dst, $src2}",
Chris Lattner589ad5d2010-03-25 05:44:01 +00002108 [(set GR8:$dst, EFLAGS, (X86xor_flag GR8:$src1,
2109 (load addr:$src2)))]>;
2110def XOR16rm : I<0x33, MRMSrcMem,
Evan Cheng64d80e32007-07-19 01:14:50 +00002111 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002112 "xor{w}\t{$src2, $dst|$dst, $src2}",
Chris Lattner589ad5d2010-03-25 05:44:01 +00002113 [(set GR16:$dst, EFLAGS, (X86xor_flag GR16:$src1,
2114 (load addr:$src2)))]>,
Bill Wendlingbd0879d2008-05-29 01:02:09 +00002115 OpSize;
Chris Lattner589ad5d2010-03-25 05:44:01 +00002116def XOR32rm : I<0x33, MRMSrcMem,
Evan Cheng64d80e32007-07-19 01:14:50 +00002117 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002118 "xor{l}\t{$src2, $dst|$dst, $src2}",
Chris Lattner589ad5d2010-03-25 05:44:01 +00002119 [(set GR32:$dst, EFLAGS, (X86xor_flag GR32:$src1,
2120 (load addr:$src2)))]>;
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00002121
Chris Lattner589ad5d2010-03-25 05:44:01 +00002122def XOR8ri : Ii8<0x80, MRM6r,
2123 (outs GR8:$dst), (ins GR8:$src1, i8imm:$src2),
2124 "xor{b}\t{$src2, $dst|$dst, $src2}",
2125 [(set GR8:$dst, EFLAGS, (X86xor_flag GR8:$src1, imm:$src2))]>;
2126def XOR16ri : Ii16<0x81, MRM6r,
2127 (outs GR16:$dst), (ins GR16:$src1, i16imm:$src2),
2128 "xor{w}\t{$src2, $dst|$dst, $src2}",
2129 [(set GR16:$dst, EFLAGS, (X86xor_flag GR16:$src1,
2130 imm:$src2))]>, OpSize;
Bill Wendling75cf88f2008-05-29 03:46:36 +00002131def XOR32ri : Ii32<0x81, MRM6r,
2132 (outs GR32:$dst), (ins GR32:$src1, i32imm:$src2),
2133 "xor{l}\t{$src2, $dst|$dst, $src2}",
Chris Lattner589ad5d2010-03-25 05:44:01 +00002134 [(set GR32:$dst, EFLAGS, (X86xor_flag GR32:$src1,
2135 imm:$src2))]>;
Bill Wendling75cf88f2008-05-29 03:46:36 +00002136def XOR16ri8 : Ii8<0x83, MRM6r,
2137 (outs GR16:$dst), (ins GR16:$src1, i16i8imm:$src2),
2138 "xor{w}\t{$src2, $dst|$dst, $src2}",
Chris Lattner589ad5d2010-03-25 05:44:01 +00002139 [(set GR16:$dst, EFLAGS, (X86xor_flag GR16:$src1,
2140 i16immSExt8:$src2))]>,
Bill Wendling75cf88f2008-05-29 03:46:36 +00002141 OpSize;
2142def XOR32ri8 : Ii8<0x83, MRM6r,
2143 (outs GR32:$dst), (ins GR32:$src1, i32i8imm:$src2),
2144 "xor{l}\t{$src2, $dst|$dst, $src2}",
Chris Lattner589ad5d2010-03-25 05:44:01 +00002145 [(set GR32:$dst, EFLAGS, (X86xor_flag GR32:$src1,
2146 i32immSExt8:$src2))]>;
Bill Wendlingbd0879d2008-05-29 01:02:09 +00002147
Eric Christophera938cfb2010-06-19 00:37:40 +00002148let Constraints = "" in {
Chris Lattner3a173df2004-10-03 20:35:00 +00002149 def XOR8mr : I<0x30, MRMDestMem,
Evan Cheng64d80e32007-07-19 01:14:50 +00002150 (outs), (ins i8mem :$dst, GR8 :$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002151 "xor{b}\t{$src, $dst|$dst, $src}",
Dan Gohman09a2609e2009-03-03 19:53:46 +00002152 [(store (xor (load addr:$dst), GR8:$src), addr:$dst),
2153 (implicit EFLAGS)]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00002154 def XOR16mr : I<0x31, MRMDestMem,
Evan Cheng64d80e32007-07-19 01:14:50 +00002155 (outs), (ins i16mem:$dst, GR16:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002156 "xor{w}\t{$src, $dst|$dst, $src}",
Dan Gohman09a2609e2009-03-03 19:53:46 +00002157 [(store (xor (load addr:$dst), GR16:$src), addr:$dst),
2158 (implicit EFLAGS)]>,
Evan Cheng0ef3a772005-12-13 01:41:36 +00002159 OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00002160 def XOR32mr : I<0x31, MRMDestMem,
Evan Cheng64d80e32007-07-19 01:14:50 +00002161 (outs), (ins i32mem:$dst, GR32:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002162 "xor{l}\t{$src, $dst|$dst, $src}",
Dan Gohman09a2609e2009-03-03 19:53:46 +00002163 [(store (xor (load addr:$dst), GR32:$src), addr:$dst),
2164 (implicit EFLAGS)]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00002165 def XOR8mi : Ii8<0x80, MRM6m,
Evan Cheng64d80e32007-07-19 01:14:50 +00002166 (outs), (ins i8mem :$dst, i8imm :$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002167 "xor{b}\t{$src, $dst|$dst, $src}",
Dan Gohman09a2609e2009-03-03 19:53:46 +00002168 [(store (xor (loadi8 addr:$dst), imm:$src), addr:$dst),
2169 (implicit EFLAGS)]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00002170 def XOR16mi : Ii16<0x81, MRM6m,
Evan Cheng64d80e32007-07-19 01:14:50 +00002171 (outs), (ins i16mem:$dst, i16imm:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002172 "xor{w}\t{$src, $dst|$dst, $src}",
Dan Gohman09a2609e2009-03-03 19:53:46 +00002173 [(store (xor (loadi16 addr:$dst), imm:$src), addr:$dst),
2174 (implicit EFLAGS)]>,
Evan Cheng0ef3a772005-12-13 01:41:36 +00002175 OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00002176 def XOR32mi : Ii32<0x81, MRM6m,
Evan Cheng64d80e32007-07-19 01:14:50 +00002177 (outs), (ins i32mem:$dst, i32imm:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002178 "xor{l}\t{$src, $dst|$dst, $src}",
Dan Gohman09a2609e2009-03-03 19:53:46 +00002179 [(store (xor (loadi32 addr:$dst), imm:$src), addr:$dst),
2180 (implicit EFLAGS)]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00002181 def XOR16mi8 : Ii8<0x83, MRM6m,
Evan Cheng64d80e32007-07-19 01:14:50 +00002182 (outs), (ins i16mem:$dst, i16i8imm :$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002183 "xor{w}\t{$src, $dst|$dst, $src}",
Dan Gohman09a2609e2009-03-03 19:53:46 +00002184 [(store (xor (load addr:$dst), i16immSExt8:$src), addr:$dst),
2185 (implicit EFLAGS)]>,
Evan Cheng0ef3a772005-12-13 01:41:36 +00002186 OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00002187 def XOR32mi8 : Ii8<0x83, MRM6m,
Evan Cheng64d80e32007-07-19 01:14:50 +00002188 (outs), (ins i32mem:$dst, i32i8imm :$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002189 "xor{l}\t{$src, $dst|$dst, $src}",
Dan Gohman09a2609e2009-03-03 19:53:46 +00002190 [(store (xor (load addr:$dst), i32immSExt8:$src), addr:$dst),
2191 (implicit EFLAGS)]>;
Sean Callanan7893ec62009-09-10 19:52:26 +00002192
Chris Lattner589ad5d2010-03-25 05:44:01 +00002193 def XOR8i8 : Ii8 <0x34, RawFrm, (outs), (ins i8imm:$src),
2194 "xor{b}\t{$src, %al|%al, $src}", []>;
2195 def XOR16i16 : Ii16<0x35, RawFrm, (outs), (ins i16imm:$src),
2196 "xor{w}\t{$src, %ax|%ax, $src}", []>, OpSize;
2197 def XOR32i32 : Ii32<0x35, RawFrm, (outs), (ins i32imm:$src),
2198 "xor{l}\t{$src, %eax|%eax, $src}", []>;
Eric Christophera938cfb2010-06-19 00:37:40 +00002199} // Constraints = ""
Evan Cheng24f2ea32007-09-14 21:48:26 +00002200} // Defs = [EFLAGS]
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00002201
2202// Shift instructions
Evan Cheng24f2ea32007-09-14 21:48:26 +00002203let Defs = [EFLAGS] in {
Evan Cheng071a2792007-09-11 19:55:27 +00002204let Uses = [CL] in {
Eric Christophera938cfb2010-06-19 00:37:40 +00002205def SHL8rCL : I<0xD2, MRM4r, (outs GR8 :$dst), (ins GR8 :$src1),
Eli Friedmanaace4b12009-06-19 04:48:38 +00002206 "shl{b}\t{%cl, $dst|$dst, CL}",
Eric Christophera938cfb2010-06-19 00:37:40 +00002207 [(set GR8:$dst, (shl GR8:$src1, CL))]>;
2208def SHL16rCL : I<0xD3, MRM4r, (outs GR16:$dst), (ins GR16:$src1),
Eli Friedmanaace4b12009-06-19 04:48:38 +00002209 "shl{w}\t{%cl, $dst|$dst, CL}",
Eric Christophera938cfb2010-06-19 00:37:40 +00002210 [(set GR16:$dst, (shl GR16:$src1, CL))]>, OpSize;
2211def SHL32rCL : I<0xD3, MRM4r, (outs GR32:$dst), (ins GR32:$src1),
Eli Friedmanaace4b12009-06-19 04:48:38 +00002212 "shl{l}\t{%cl, $dst|$dst, CL}",
Eric Christophera938cfb2010-06-19 00:37:40 +00002213 [(set GR32:$dst, (shl GR32:$src1, CL))]>;
Bill Wendlingbd0879d2008-05-29 01:02:09 +00002214} // Uses = [CL]
Chris Lattnercc65bee2005-01-02 02:35:46 +00002215
Evan Cheng64d80e32007-07-19 01:14:50 +00002216def SHL8ri : Ii8<0xC0, MRM4r, (outs GR8 :$dst), (ins GR8 :$src1, i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002217 "shl{b}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00002218 [(set GR8:$dst, (shl GR8:$src1, (i8 imm:$src2)))]>;
Eric Christophera938cfb2010-06-19 00:37:40 +00002219
Chris Lattnercc65bee2005-01-02 02:35:46 +00002220let isConvertibleToThreeAddress = 1 in { // Can transform into LEA.
Evan Cheng64d80e32007-07-19 01:14:50 +00002221def SHL16ri : Ii8<0xC1, MRM4r, (outs GR16:$dst), (ins GR16:$src1, i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002222 "shl{w}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00002223 [(set GR16:$dst, (shl GR16:$src1, (i8 imm:$src2)))]>, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00002224def SHL32ri : Ii8<0xC1, MRM4r, (outs GR32:$dst), (ins GR32:$src1, i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002225 "shl{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00002226 [(set GR32:$dst, (shl GR32:$src1, (i8 imm:$src2)))]>;
Sean Callanan13cf8e92009-09-16 02:28:43 +00002227
2228// NOTE: We don't include patterns for shifts of a register by one, because
2229// 'add reg,reg' is cheaper.
2230
2231def SHL8r1 : I<0xD0, MRM4r, (outs GR8:$dst), (ins GR8:$src1),
2232 "shl{b}\t$dst", []>;
2233def SHL16r1 : I<0xD1, MRM4r, (outs GR16:$dst), (ins GR16:$src1),
2234 "shl{w}\t$dst", []>, OpSize;
2235def SHL32r1 : I<0xD1, MRM4r, (outs GR32:$dst), (ins GR32:$src1),
2236 "shl{l}\t$dst", []>;
2237
Bill Wendlingbd0879d2008-05-29 01:02:09 +00002238} // isConvertibleToThreeAddress = 1
Evan Cheng09c54572006-06-29 00:36:51 +00002239
Eric Christophera938cfb2010-06-19 00:37:40 +00002240let Constraints = "" in {
Evan Cheng071a2792007-09-11 19:55:27 +00002241 let Uses = [CL] in {
Evan Cheng64d80e32007-07-19 01:14:50 +00002242 def SHL8mCL : I<0xD2, MRM4m, (outs), (ins i8mem :$dst),
Eli Friedmanaace4b12009-06-19 04:48:38 +00002243 "shl{b}\t{%cl, $dst|$dst, CL}",
Evan Cheng071a2792007-09-11 19:55:27 +00002244 [(store (shl (loadi8 addr:$dst), CL), addr:$dst)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00002245 def SHL16mCL : I<0xD3, MRM4m, (outs), (ins i16mem:$dst),
Eli Friedmanaace4b12009-06-19 04:48:38 +00002246 "shl{w}\t{%cl, $dst|$dst, CL}",
Evan Cheng071a2792007-09-11 19:55:27 +00002247 [(store (shl (loadi16 addr:$dst), CL), addr:$dst)]>, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00002248 def SHL32mCL : I<0xD3, MRM4m, (outs), (ins i32mem:$dst),
Eli Friedmanaace4b12009-06-19 04:48:38 +00002249 "shl{l}\t{%cl, $dst|$dst, CL}",
Evan Cheng071a2792007-09-11 19:55:27 +00002250 [(store (shl (loadi32 addr:$dst), CL), addr:$dst)]>;
2251 }
Evan Cheng64d80e32007-07-19 01:14:50 +00002252 def SHL8mi : Ii8<0xC0, MRM4m, (outs), (ins i8mem :$dst, i8imm:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002253 "shl{b}\t{$src, $dst|$dst, $src}",
Evan Cheng763b0292005-12-13 02:34:51 +00002254 [(store (shl (loadi8 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00002255 def SHL16mi : Ii8<0xC1, MRM4m, (outs), (ins i16mem:$dst, i8imm:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002256 "shl{w}\t{$src, $dst|$dst, $src}",
Evan Cheng763b0292005-12-13 02:34:51 +00002257 [(store (shl (loadi16 addr:$dst), (i8 imm:$src)), addr:$dst)]>,
2258 OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00002259 def SHL32mi : Ii8<0xC1, MRM4m, (outs), (ins i32mem:$dst, i8imm:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002260 "shl{l}\t{$src, $dst|$dst, $src}",
Evan Cheng763b0292005-12-13 02:34:51 +00002261 [(store (shl (loadi32 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
Evan Cheng09c54572006-06-29 00:36:51 +00002262
2263 // Shift by 1
Evan Cheng64d80e32007-07-19 01:14:50 +00002264 def SHL8m1 : I<0xD0, MRM4m, (outs), (ins i8mem :$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002265 "shl{b}\t$dst",
Evan Cheng09c54572006-06-29 00:36:51 +00002266 [(store (shl (loadi8 addr:$dst), (i8 1)), addr:$dst)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00002267 def SHL16m1 : I<0xD1, MRM4m, (outs), (ins i16mem:$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002268 "shl{w}\t$dst",
Evan Cheng09c54572006-06-29 00:36:51 +00002269 [(store (shl (loadi16 addr:$dst), (i8 1)), addr:$dst)]>,
2270 OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00002271 def SHL32m1 : I<0xD1, MRM4m, (outs), (ins i32mem:$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002272 "shl{l}\t$dst",
Evan Cheng09c54572006-06-29 00:36:51 +00002273 [(store (shl (loadi32 addr:$dst), (i8 1)), addr:$dst)]>;
Eric Christophera938cfb2010-06-19 00:37:40 +00002274} // Constraints = ""
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00002275
Evan Cheng071a2792007-09-11 19:55:27 +00002276let Uses = [CL] in {
Eric Christophera938cfb2010-06-19 00:37:40 +00002277def SHR8rCL : I<0xD2, MRM5r, (outs GR8 :$dst), (ins GR8 :$src1),
Eli Friedmanaace4b12009-06-19 04:48:38 +00002278 "shr{b}\t{%cl, $dst|$dst, CL}",
Eric Christophera938cfb2010-06-19 00:37:40 +00002279 [(set GR8:$dst, (srl GR8:$src1, CL))]>;
2280def SHR16rCL : I<0xD3, MRM5r, (outs GR16:$dst), (ins GR16:$src1),
Eli Friedmanaace4b12009-06-19 04:48:38 +00002281 "shr{w}\t{%cl, $dst|$dst, CL}",
Eric Christophera938cfb2010-06-19 00:37:40 +00002282 [(set GR16:$dst, (srl GR16:$src1, CL))]>, OpSize;
2283def SHR32rCL : I<0xD3, MRM5r, (outs GR32:$dst), (ins GR32:$src1),
Eli Friedmanaace4b12009-06-19 04:48:38 +00002284 "shr{l}\t{%cl, $dst|$dst, CL}",
Eric Christophera938cfb2010-06-19 00:37:40 +00002285 [(set GR32:$dst, (srl GR32:$src1, CL))]>;
Evan Cheng071a2792007-09-11 19:55:27 +00002286}
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00002287
Evan Cheng64d80e32007-07-19 01:14:50 +00002288def SHR8ri : Ii8<0xC0, MRM5r, (outs GR8:$dst), (ins GR8:$src1, i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002289 "shr{b}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00002290 [(set GR8:$dst, (srl GR8:$src1, (i8 imm:$src2)))]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00002291def SHR16ri : Ii8<0xC1, MRM5r, (outs GR16:$dst), (ins GR16:$src1, i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002292 "shr{w}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00002293 [(set GR16:$dst, (srl GR16:$src1, (i8 imm:$src2)))]>, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00002294def SHR32ri : Ii8<0xC1, MRM5r, (outs GR32:$dst), (ins GR32:$src1, i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002295 "shr{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00002296 [(set GR32:$dst, (srl GR32:$src1, (i8 imm:$src2)))]>;
Chris Lattnerf29ed092004-08-11 05:07:25 +00002297
Evan Cheng09c54572006-06-29 00:36:51 +00002298// Shift by 1
Evan Cheng64d80e32007-07-19 01:14:50 +00002299def SHR8r1 : I<0xD0, MRM5r, (outs GR8:$dst), (ins GR8:$src1),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002300 "shr{b}\t$dst",
Evan Cheng09c54572006-06-29 00:36:51 +00002301 [(set GR8:$dst, (srl GR8:$src1, (i8 1)))]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00002302def SHR16r1 : I<0xD1, MRM5r, (outs GR16:$dst), (ins GR16:$src1),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002303 "shr{w}\t$dst",
Evan Cheng09c54572006-06-29 00:36:51 +00002304 [(set GR16:$dst, (srl GR16:$src1, (i8 1)))]>, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00002305def SHR32r1 : I<0xD1, MRM5r, (outs GR32:$dst), (ins GR32:$src1),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002306 "shr{l}\t$dst",
Evan Cheng09c54572006-06-29 00:36:51 +00002307 [(set GR32:$dst, (srl GR32:$src1, (i8 1)))]>;
2308
Eric Christophera938cfb2010-06-19 00:37:40 +00002309let Constraints = "" in {
Evan Cheng071a2792007-09-11 19:55:27 +00002310 let Uses = [CL] in {
Evan Cheng64d80e32007-07-19 01:14:50 +00002311 def SHR8mCL : I<0xD2, MRM5m, (outs), (ins i8mem :$dst),
Eli Friedmanaace4b12009-06-19 04:48:38 +00002312 "shr{b}\t{%cl, $dst|$dst, CL}",
Evan Cheng071a2792007-09-11 19:55:27 +00002313 [(store (srl (loadi8 addr:$dst), CL), addr:$dst)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00002314 def SHR16mCL : I<0xD3, MRM5m, (outs), (ins i16mem:$dst),
Eli Friedmanaace4b12009-06-19 04:48:38 +00002315 "shr{w}\t{%cl, $dst|$dst, CL}",
Evan Cheng85dd8892005-12-13 07:24:22 +00002316 [(store (srl (loadi16 addr:$dst), CL), addr:$dst)]>,
Evan Cheng071a2792007-09-11 19:55:27 +00002317 OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00002318 def SHR32mCL : I<0xD3, MRM5m, (outs), (ins i32mem:$dst),
Eli Friedmanaace4b12009-06-19 04:48:38 +00002319 "shr{l}\t{%cl, $dst|$dst, CL}",
Evan Cheng071a2792007-09-11 19:55:27 +00002320 [(store (srl (loadi32 addr:$dst), CL), addr:$dst)]>;
2321 }
Evan Cheng64d80e32007-07-19 01:14:50 +00002322 def SHR8mi : Ii8<0xC0, MRM5m, (outs), (ins i8mem :$dst, i8imm:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002323 "shr{b}\t{$src, $dst|$dst, $src}",
Evan Cheng85dd8892005-12-13 07:24:22 +00002324 [(store (srl (loadi8 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00002325 def SHR16mi : Ii8<0xC1, MRM5m, (outs), (ins i16mem:$dst, i8imm:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002326 "shr{w}\t{$src, $dst|$dst, $src}",
Evan Cheng85dd8892005-12-13 07:24:22 +00002327 [(store (srl (loadi16 addr:$dst), (i8 imm:$src)), addr:$dst)]>,
2328 OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00002329 def SHR32mi : Ii8<0xC1, MRM5m, (outs), (ins i32mem:$dst, i8imm:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002330 "shr{l}\t{$src, $dst|$dst, $src}",
Evan Cheng85dd8892005-12-13 07:24:22 +00002331 [(store (srl (loadi32 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
Evan Cheng09c54572006-06-29 00:36:51 +00002332
2333 // Shift by 1
Evan Cheng64d80e32007-07-19 01:14:50 +00002334 def SHR8m1 : I<0xD0, MRM5m, (outs), (ins i8mem :$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002335 "shr{b}\t$dst",
Evan Cheng09c54572006-06-29 00:36:51 +00002336 [(store (srl (loadi8 addr:$dst), (i8 1)), addr:$dst)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00002337 def SHR16m1 : I<0xD1, MRM5m, (outs), (ins i16mem:$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002338 "shr{w}\t$dst",
Evan Cheng09c54572006-06-29 00:36:51 +00002339 [(store (srl (loadi16 addr:$dst), (i8 1)), addr:$dst)]>,OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00002340 def SHR32m1 : I<0xD1, MRM5m, (outs), (ins i32mem:$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002341 "shr{l}\t$dst",
Evan Cheng09c54572006-06-29 00:36:51 +00002342 [(store (srl (loadi32 addr:$dst), (i8 1)), addr:$dst)]>;
Eric Christophera938cfb2010-06-19 00:37:40 +00002343} // Constraints = ""
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00002344
Evan Cheng071a2792007-09-11 19:55:27 +00002345let Uses = [CL] in {
Eric Christophera938cfb2010-06-19 00:37:40 +00002346def SAR8rCL : I<0xD2, MRM7r, (outs GR8 :$dst), (ins GR8 :$src1),
Eli Friedmanaace4b12009-06-19 04:48:38 +00002347 "sar{b}\t{%cl, $dst|$dst, CL}",
Eric Christophera938cfb2010-06-19 00:37:40 +00002348 [(set GR8:$dst, (sra GR8:$src1, CL))]>;
2349def SAR16rCL : I<0xD3, MRM7r, (outs GR16:$dst), (ins GR16:$src1),
Eli Friedmanaace4b12009-06-19 04:48:38 +00002350 "sar{w}\t{%cl, $dst|$dst, CL}",
Eric Christophera938cfb2010-06-19 00:37:40 +00002351 [(set GR16:$dst, (sra GR16:$src1, CL))]>, OpSize;
2352def SAR32rCL : I<0xD3, MRM7r, (outs GR32:$dst), (ins GR32:$src1),
Eli Friedmanaace4b12009-06-19 04:48:38 +00002353 "sar{l}\t{%cl, $dst|$dst, CL}",
Eric Christophera938cfb2010-06-19 00:37:40 +00002354 [(set GR32:$dst, (sra GR32:$src1, CL))]>;
Evan Cheng071a2792007-09-11 19:55:27 +00002355}
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00002356
Evan Cheng64d80e32007-07-19 01:14:50 +00002357def SAR8ri : Ii8<0xC0, MRM7r, (outs GR8 :$dst), (ins GR8 :$src1, i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002358 "sar{b}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00002359 [(set GR8:$dst, (sra GR8:$src1, (i8 imm:$src2)))]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00002360def SAR16ri : Ii8<0xC1, MRM7r, (outs GR16:$dst), (ins GR16:$src1, i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002361 "sar{w}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00002362 [(set GR16:$dst, (sra GR16:$src1, (i8 imm:$src2)))]>,
Chris Lattner3d36a9f2005-12-05 02:40:25 +00002363 OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00002364def SAR32ri : Ii8<0xC1, MRM7r, (outs GR32:$dst), (ins GR32:$src1, i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002365 "sar{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00002366 [(set GR32:$dst, (sra GR32:$src1, (i8 imm:$src2)))]>;
Evan Cheng09c54572006-06-29 00:36:51 +00002367
2368// Shift by 1
Evan Cheng64d80e32007-07-19 01:14:50 +00002369def SAR8r1 : I<0xD0, MRM7r, (outs GR8 :$dst), (ins GR8 :$src1),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002370 "sar{b}\t$dst",
Evan Cheng09c54572006-06-29 00:36:51 +00002371 [(set GR8:$dst, (sra GR8:$src1, (i8 1)))]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00002372def SAR16r1 : I<0xD1, MRM7r, (outs GR16:$dst), (ins GR16:$src1),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002373 "sar{w}\t$dst",
Evan Cheng09c54572006-06-29 00:36:51 +00002374 [(set GR16:$dst, (sra GR16:$src1, (i8 1)))]>, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00002375def SAR32r1 : I<0xD1, MRM7r, (outs GR32:$dst), (ins GR32:$src1),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002376 "sar{l}\t$dst",
Evan Cheng09c54572006-06-29 00:36:51 +00002377 [(set GR32:$dst, (sra GR32:$src1, (i8 1)))]>;
2378
Eric Christophera938cfb2010-06-19 00:37:40 +00002379let Constraints = "" in {
Evan Cheng071a2792007-09-11 19:55:27 +00002380 let Uses = [CL] in {
Evan Cheng64d80e32007-07-19 01:14:50 +00002381 def SAR8mCL : I<0xD2, MRM7m, (outs), (ins i8mem :$dst),
Eli Friedmanaace4b12009-06-19 04:48:38 +00002382 "sar{b}\t{%cl, $dst|$dst, CL}",
Evan Cheng071a2792007-09-11 19:55:27 +00002383 [(store (sra (loadi8 addr:$dst), CL), addr:$dst)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00002384 def SAR16mCL : I<0xD3, MRM7m, (outs), (ins i16mem:$dst),
Eli Friedmanaace4b12009-06-19 04:48:38 +00002385 "sar{w}\t{%cl, $dst|$dst, CL}",
Evan Cheng071a2792007-09-11 19:55:27 +00002386 [(store (sra (loadi16 addr:$dst), CL), addr:$dst)]>, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00002387 def SAR32mCL : I<0xD3, MRM7m, (outs), (ins i32mem:$dst),
Eli Friedmanaace4b12009-06-19 04:48:38 +00002388 "sar{l}\t{%cl, $dst|$dst, CL}",
Evan Cheng071a2792007-09-11 19:55:27 +00002389 [(store (sra (loadi32 addr:$dst), CL), addr:$dst)]>;
2390 }
Evan Cheng64d80e32007-07-19 01:14:50 +00002391 def SAR8mi : Ii8<0xC0, MRM7m, (outs), (ins i8mem :$dst, i8imm:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002392 "sar{b}\t{$src, $dst|$dst, $src}",
Evan Cheng85dd8892005-12-13 07:24:22 +00002393 [(store (sra (loadi8 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00002394 def SAR16mi : Ii8<0xC1, MRM7m, (outs), (ins i16mem:$dst, i8imm:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002395 "sar{w}\t{$src, $dst|$dst, $src}",
Evan Cheng85dd8892005-12-13 07:24:22 +00002396 [(store (sra (loadi16 addr:$dst), (i8 imm:$src)), addr:$dst)]>,
2397 OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00002398 def SAR32mi : Ii8<0xC1, MRM7m, (outs), (ins i32mem:$dst, i8imm:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002399 "sar{l}\t{$src, $dst|$dst, $src}",
Evan Cheng85dd8892005-12-13 07:24:22 +00002400 [(store (sra (loadi32 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
Evan Cheng09c54572006-06-29 00:36:51 +00002401
2402 // Shift by 1
Evan Cheng64d80e32007-07-19 01:14:50 +00002403 def SAR8m1 : I<0xD0, MRM7m, (outs), (ins i8mem :$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002404 "sar{b}\t$dst",
Evan Cheng09c54572006-06-29 00:36:51 +00002405 [(store (sra (loadi8 addr:$dst), (i8 1)), addr:$dst)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00002406 def SAR16m1 : I<0xD1, MRM7m, (outs), (ins i16mem:$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002407 "sar{w}\t$dst",
Evan Cheng09c54572006-06-29 00:36:51 +00002408 [(store (sra (loadi16 addr:$dst), (i8 1)), addr:$dst)]>,
2409 OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00002410 def SAR32m1 : I<0xD1, MRM7m, (outs), (ins i32mem:$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002411 "sar{l}\t$dst",
Evan Cheng09c54572006-06-29 00:36:51 +00002412 [(store (sra (loadi32 addr:$dst), (i8 1)), addr:$dst)]>;
Eric Christophera938cfb2010-06-19 00:37:40 +00002413} // Constraints = ""
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00002414
Chris Lattner40ff6332005-01-19 07:50:03 +00002415// Rotate instructions
Sean Callanana2dc2822009-09-18 19:35:23 +00002416
Eric Christophera938cfb2010-06-19 00:37:40 +00002417def RCL8r1 : I<0xD0, MRM2r, (outs GR8:$dst), (ins GR8:$src1),
Sean Callanana2dc2822009-09-18 19:35:23 +00002418 "rcl{b}\t{1, $dst|$dst, 1}", []>;
Sean Callanana2dc2822009-09-18 19:35:23 +00002419let Uses = [CL] in {
Eric Christophera938cfb2010-06-19 00:37:40 +00002420def RCL8rCL : I<0xD2, MRM2r, (outs GR8:$dst), (ins GR8:$src1),
Sean Callanana2dc2822009-09-18 19:35:23 +00002421 "rcl{b}\t{%cl, $dst|$dst, CL}", []>;
Sean Callanana2dc2822009-09-18 19:35:23 +00002422}
Eric Christophera938cfb2010-06-19 00:37:40 +00002423def RCL8ri : Ii8<0xC0, MRM2r, (outs GR8:$dst), (ins GR8:$src1, i8imm:$cnt),
Sean Callanana2dc2822009-09-18 19:35:23 +00002424 "rcl{b}\t{$cnt, $dst|$dst, $cnt}", []>;
Sean Callanana2dc2822009-09-18 19:35:23 +00002425
Eric Christophera938cfb2010-06-19 00:37:40 +00002426def RCL16r1 : I<0xD1, MRM2r, (outs GR16:$dst), (ins GR16:$src1),
Sean Callanana2dc2822009-09-18 19:35:23 +00002427 "rcl{w}\t{1, $dst|$dst, 1}", []>, OpSize;
Sean Callanana2dc2822009-09-18 19:35:23 +00002428let Uses = [CL] in {
Eric Christophera938cfb2010-06-19 00:37:40 +00002429def RCL16rCL : I<0xD3, MRM2r, (outs GR16:$dst), (ins GR16:$src1),
Sean Callanana2dc2822009-09-18 19:35:23 +00002430 "rcl{w}\t{%cl, $dst|$dst, CL}", []>, OpSize;
Sean Callanana2dc2822009-09-18 19:35:23 +00002431}
Eric Christophera938cfb2010-06-19 00:37:40 +00002432def RCL16ri : Ii8<0xC1, MRM2r, (outs GR16:$dst), (ins GR16:$src1, i8imm:$cnt),
Sean Callanana2dc2822009-09-18 19:35:23 +00002433 "rcl{w}\t{$cnt, $dst|$dst, $cnt}", []>, OpSize;
Sean Callanana2dc2822009-09-18 19:35:23 +00002434
Eric Christophera938cfb2010-06-19 00:37:40 +00002435def RCL32r1 : I<0xD1, MRM2r, (outs GR32:$dst), (ins GR32:$src1),
Sean Callanana2dc2822009-09-18 19:35:23 +00002436 "rcl{l}\t{1, $dst|$dst, 1}", []>;
Sean Callanana2dc2822009-09-18 19:35:23 +00002437let Uses = [CL] in {
Eric Christophera938cfb2010-06-19 00:37:40 +00002438def RCL32rCL : I<0xD3, MRM2r, (outs GR32:$dst), (ins GR32:$src1),
Sean Callanana2dc2822009-09-18 19:35:23 +00002439 "rcl{l}\t{%cl, $dst|$dst, CL}", []>;
Sean Callanana2dc2822009-09-18 19:35:23 +00002440}
Eric Christophera938cfb2010-06-19 00:37:40 +00002441def RCL32ri : Ii8<0xC1, MRM2r, (outs GR32:$dst), (ins GR32:$src1, i8imm:$cnt),
Sean Callanana2dc2822009-09-18 19:35:23 +00002442 "rcl{l}\t{$cnt, $dst|$dst, $cnt}", []>;
Sean Callanana2dc2822009-09-18 19:35:23 +00002443
Eric Christophera938cfb2010-06-19 00:37:40 +00002444def RCR8r1 : I<0xD0, MRM3r, (outs GR8:$dst), (ins GR8:$src1),
Sean Callanana2dc2822009-09-18 19:35:23 +00002445 "rcr{b}\t{1, $dst|$dst, 1}", []>;
Sean Callanana2dc2822009-09-18 19:35:23 +00002446let Uses = [CL] in {
Eric Christophera938cfb2010-06-19 00:37:40 +00002447def RCR8rCL : I<0xD2, MRM3r, (outs GR8:$dst), (ins GR8:$src1),
Sean Callanana2dc2822009-09-18 19:35:23 +00002448 "rcr{b}\t{%cl, $dst|$dst, CL}", []>;
Sean Callanana2dc2822009-09-18 19:35:23 +00002449}
Eric Christophera938cfb2010-06-19 00:37:40 +00002450def RCR8ri : Ii8<0xC0, MRM3r, (outs GR8:$dst), (ins GR8:$src1, i8imm:$cnt),
Sean Callanana2dc2822009-09-18 19:35:23 +00002451 "rcr{b}\t{$cnt, $dst|$dst, $cnt}", []>;
Sean Callanana2dc2822009-09-18 19:35:23 +00002452
Eric Christophera938cfb2010-06-19 00:37:40 +00002453def RCR16r1 : I<0xD1, MRM3r, (outs GR16:$dst), (ins GR16:$src1),
Sean Callanana2dc2822009-09-18 19:35:23 +00002454 "rcr{w}\t{1, $dst|$dst, 1}", []>, OpSize;
Sean Callanana2dc2822009-09-18 19:35:23 +00002455let Uses = [CL] in {
Eric Christophera938cfb2010-06-19 00:37:40 +00002456def RCR16rCL : I<0xD3, MRM3r, (outs GR16:$dst), (ins GR16:$src1),
Sean Callanana2dc2822009-09-18 19:35:23 +00002457 "rcr{w}\t{%cl, $dst|$dst, CL}", []>, OpSize;
Sean Callanana2dc2822009-09-18 19:35:23 +00002458}
Eric Christophera938cfb2010-06-19 00:37:40 +00002459def RCR16ri : Ii8<0xC1, MRM3r, (outs GR16:$dst), (ins GR16:$src1, i8imm:$cnt),
Sean Callanana2dc2822009-09-18 19:35:23 +00002460 "rcr{w}\t{$cnt, $dst|$dst, $cnt}", []>, OpSize;
Sean Callanana2dc2822009-09-18 19:35:23 +00002461
Eric Christophera938cfb2010-06-19 00:37:40 +00002462def RCR32r1 : I<0xD1, MRM3r, (outs GR32:$dst), (ins GR32:$src1),
Sean Callanana2dc2822009-09-18 19:35:23 +00002463 "rcr{l}\t{1, $dst|$dst, 1}", []>;
Sean Callanana2dc2822009-09-18 19:35:23 +00002464let Uses = [CL] in {
Eric Christophera938cfb2010-06-19 00:37:40 +00002465def RCR32rCL : I<0xD3, MRM3r, (outs GR32:$dst), (ins GR32:$src1),
Sean Callanana2dc2822009-09-18 19:35:23 +00002466 "rcr{l}\t{%cl, $dst|$dst, CL}", []>;
Sean Callanana2dc2822009-09-18 19:35:23 +00002467}
Eric Christophera938cfb2010-06-19 00:37:40 +00002468def RCR32ri : Ii8<0xC1, MRM3r, (outs GR32:$dst), (ins GR32:$src1, i8imm:$cnt),
Sean Callanana2dc2822009-09-18 19:35:23 +00002469 "rcr{l}\t{$cnt, $dst|$dst, $cnt}", []>;
Daniel Dunbarccfa1db2010-02-12 01:22:03 +00002470
Eric Christophera938cfb2010-06-19 00:37:40 +00002471let Constraints = "" in {
Daniel Dunbarccfa1db2010-02-12 01:22:03 +00002472def RCL8m1 : I<0xD0, MRM2m, (outs), (ins i8mem:$dst),
2473 "rcl{b}\t{1, $dst|$dst, 1}", []>;
2474def RCL8mi : Ii8<0xC0, MRM2m, (outs), (ins i8mem:$dst, i8imm:$cnt),
2475 "rcl{b}\t{$cnt, $dst|$dst, $cnt}", []>;
2476def RCL16m1 : I<0xD1, MRM2m, (outs), (ins i16mem:$dst),
2477 "rcl{w}\t{1, $dst|$dst, 1}", []>, OpSize;
2478def RCL16mi : Ii8<0xC1, MRM2m, (outs), (ins i16mem:$dst, i8imm:$cnt),
2479 "rcl{w}\t{$cnt, $dst|$dst, $cnt}", []>, OpSize;
2480def RCL32m1 : I<0xD1, MRM2m, (outs), (ins i32mem:$dst),
2481 "rcl{l}\t{1, $dst|$dst, 1}", []>;
2482def RCL32mi : Ii8<0xC1, MRM2m, (outs), (ins i32mem:$dst, i8imm:$cnt),
2483 "rcl{l}\t{$cnt, $dst|$dst, $cnt}", []>;
2484def RCR8m1 : I<0xD0, MRM3m, (outs), (ins i8mem:$dst),
2485 "rcr{b}\t{1, $dst|$dst, 1}", []>;
2486def RCR8mi : Ii8<0xC0, MRM3m, (outs), (ins i8mem:$dst, i8imm:$cnt),
2487 "rcr{b}\t{$cnt, $dst|$dst, $cnt}", []>;
2488def RCR16m1 : I<0xD1, MRM3m, (outs), (ins i16mem:$dst),
2489 "rcr{w}\t{1, $dst|$dst, 1}", []>, OpSize;
2490def RCR16mi : Ii8<0xC1, MRM3m, (outs), (ins i16mem:$dst, i8imm:$cnt),
2491 "rcr{w}\t{$cnt, $dst|$dst, $cnt}", []>, OpSize;
2492def RCR32m1 : I<0xD1, MRM3m, (outs), (ins i32mem:$dst),
2493 "rcr{l}\t{1, $dst|$dst, 1}", []>;
2494def RCR32mi : Ii8<0xC1, MRM3m, (outs), (ins i32mem:$dst, i8imm:$cnt),
Sean Callanana2dc2822009-09-18 19:35:23 +00002495 "rcr{l}\t{$cnt, $dst|$dst, $cnt}", []>;
2496
Daniel Dunbarccfa1db2010-02-12 01:22:03 +00002497let Uses = [CL] in {
2498def RCL8mCL : I<0xD2, MRM2m, (outs), (ins i8mem:$dst),
2499 "rcl{b}\t{%cl, $dst|$dst, CL}", []>;
2500def RCL16mCL : I<0xD3, MRM2m, (outs), (ins i16mem:$dst),
2501 "rcl{w}\t{%cl, $dst|$dst, CL}", []>, OpSize;
2502def RCL32mCL : I<0xD3, MRM2m, (outs), (ins i32mem:$dst),
2503 "rcl{l}\t{%cl, $dst|$dst, CL}", []>;
2504def RCR8mCL : I<0xD2, MRM3m, (outs), (ins i8mem:$dst),
2505 "rcr{b}\t{%cl, $dst|$dst, CL}", []>;
2506def RCR16mCL : I<0xD3, MRM3m, (outs), (ins i16mem:$dst),
2507 "rcr{w}\t{%cl, $dst|$dst, CL}", []>, OpSize;
2508def RCR32mCL : I<0xD3, MRM3m, (outs), (ins i32mem:$dst),
2509 "rcr{l}\t{%cl, $dst|$dst, CL}", []>;
2510}
Eric Christophera938cfb2010-06-19 00:37:40 +00002511} // Constraints = ""
Daniel Dunbarccfa1db2010-02-12 01:22:03 +00002512
Chris Lattner40ff6332005-01-19 07:50:03 +00002513// FIXME: provide shorter instructions when imm8 == 1
Evan Cheng071a2792007-09-11 19:55:27 +00002514let Uses = [CL] in {
Eric Christophera938cfb2010-06-19 00:37:40 +00002515def ROL8rCL : I<0xD2, MRM0r, (outs GR8 :$dst), (ins GR8 :$src1),
Eli Friedmanaace4b12009-06-19 04:48:38 +00002516 "rol{b}\t{%cl, $dst|$dst, CL}",
Eric Christophera938cfb2010-06-19 00:37:40 +00002517 [(set GR8:$dst, (rotl GR8:$src1, CL))]>;
2518def ROL16rCL : I<0xD3, MRM0r, (outs GR16:$dst), (ins GR16:$src1),
Eli Friedmanaace4b12009-06-19 04:48:38 +00002519 "rol{w}\t{%cl, $dst|$dst, CL}",
Eric Christophera938cfb2010-06-19 00:37:40 +00002520 [(set GR16:$dst, (rotl GR16:$src1, CL))]>, OpSize;
2521def ROL32rCL : I<0xD3, MRM0r, (outs GR32:$dst), (ins GR32:$src1),
Eli Friedmanaace4b12009-06-19 04:48:38 +00002522 "rol{l}\t{%cl, $dst|$dst, CL}",
Eric Christophera938cfb2010-06-19 00:37:40 +00002523 [(set GR32:$dst, (rotl GR32:$src1, CL))]>;
Evan Cheng071a2792007-09-11 19:55:27 +00002524}
Chris Lattner40ff6332005-01-19 07:50:03 +00002525
Evan Cheng64d80e32007-07-19 01:14:50 +00002526def ROL8ri : Ii8<0xC0, MRM0r, (outs GR8 :$dst), (ins GR8 :$src1, i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002527 "rol{b}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00002528 [(set GR8:$dst, (rotl GR8:$src1, (i8 imm:$src2)))]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00002529def ROL16ri : Ii8<0xC1, MRM0r, (outs GR16:$dst), (ins GR16:$src1, i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002530 "rol{w}\t{$src2, $dst|$dst, $src2}",
Sean Callanan108934c2009-12-18 00:01:26 +00002531 [(set GR16:$dst, (rotl GR16:$src1, (i8 imm:$src2)))]>,
2532 OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00002533def ROL32ri : Ii8<0xC1, MRM0r, (outs GR32:$dst), (ins GR32:$src1, i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002534 "rol{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00002535 [(set GR32:$dst, (rotl GR32:$src1, (i8 imm:$src2)))]>;
Chris Lattner40ff6332005-01-19 07:50:03 +00002536
Evan Cheng09c54572006-06-29 00:36:51 +00002537// Rotate by 1
Evan Cheng64d80e32007-07-19 01:14:50 +00002538def ROL8r1 : I<0xD0, MRM0r, (outs GR8 :$dst), (ins GR8 :$src1),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002539 "rol{b}\t$dst",
Evan Cheng09c54572006-06-29 00:36:51 +00002540 [(set GR8:$dst, (rotl GR8:$src1, (i8 1)))]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00002541def ROL16r1 : I<0xD1, MRM0r, (outs GR16:$dst), (ins GR16:$src1),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002542 "rol{w}\t$dst",
Evan Cheng09c54572006-06-29 00:36:51 +00002543 [(set GR16:$dst, (rotl GR16:$src1, (i8 1)))]>, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00002544def ROL32r1 : I<0xD1, MRM0r, (outs GR32:$dst), (ins GR32:$src1),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002545 "rol{l}\t$dst",
Evan Cheng09c54572006-06-29 00:36:51 +00002546 [(set GR32:$dst, (rotl GR32:$src1, (i8 1)))]>;
2547
Eric Christophera938cfb2010-06-19 00:37:40 +00002548let Constraints = "" in {
Evan Cheng071a2792007-09-11 19:55:27 +00002549 let Uses = [CL] in {
Evan Cheng64d80e32007-07-19 01:14:50 +00002550 def ROL8mCL : I<0xD2, MRM0m, (outs), (ins i8mem :$dst),
Eli Friedmanaace4b12009-06-19 04:48:38 +00002551 "rol{b}\t{%cl, $dst|$dst, CL}",
Evan Cheng071a2792007-09-11 19:55:27 +00002552 [(store (rotl (loadi8 addr:$dst), CL), addr:$dst)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00002553 def ROL16mCL : I<0xD3, MRM0m, (outs), (ins i16mem:$dst),
Eli Friedmanaace4b12009-06-19 04:48:38 +00002554 "rol{w}\t{%cl, $dst|$dst, CL}",
Evan Cheng071a2792007-09-11 19:55:27 +00002555 [(store (rotl (loadi16 addr:$dst), CL), addr:$dst)]>, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00002556 def ROL32mCL : I<0xD3, MRM0m, (outs), (ins i32mem:$dst),
Eli Friedmanaace4b12009-06-19 04:48:38 +00002557 "rol{l}\t{%cl, $dst|$dst, CL}",
Evan Cheng071a2792007-09-11 19:55:27 +00002558 [(store (rotl (loadi32 addr:$dst), CL), addr:$dst)]>;
2559 }
Evan Cheng64d80e32007-07-19 01:14:50 +00002560 def ROL8mi : Ii8<0xC0, MRM0m, (outs), (ins i8mem :$dst, i8imm:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002561 "rol{b}\t{$src, $dst|$dst, $src}",
Evan Chengeb422a72006-01-11 23:20:05 +00002562 [(store (rotl (loadi8 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00002563 def ROL16mi : Ii8<0xC1, MRM0m, (outs), (ins i16mem:$dst, i8imm:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002564 "rol{w}\t{$src, $dst|$dst, $src}",
Evan Chengeb422a72006-01-11 23:20:05 +00002565 [(store (rotl (loadi16 addr:$dst), (i8 imm:$src)), addr:$dst)]>,
2566 OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00002567 def ROL32mi : Ii8<0xC1, MRM0m, (outs), (ins i32mem:$dst, i8imm:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002568 "rol{l}\t{$src, $dst|$dst, $src}",
Evan Chengeb422a72006-01-11 23:20:05 +00002569 [(store (rotl (loadi32 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
Evan Cheng09c54572006-06-29 00:36:51 +00002570
2571 // Rotate by 1
Evan Cheng64d80e32007-07-19 01:14:50 +00002572 def ROL8m1 : I<0xD0, MRM0m, (outs), (ins i8mem :$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002573 "rol{b}\t$dst",
Evan Cheng09c54572006-06-29 00:36:51 +00002574 [(store (rotl (loadi8 addr:$dst), (i8 1)), addr:$dst)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00002575 def ROL16m1 : I<0xD1, MRM0m, (outs), (ins i16mem:$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002576 "rol{w}\t$dst",
Evan Cheng09c54572006-06-29 00:36:51 +00002577 [(store (rotl (loadi16 addr:$dst), (i8 1)), addr:$dst)]>,
2578 OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00002579 def ROL32m1 : I<0xD1, MRM0m, (outs), (ins i32mem:$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002580 "rol{l}\t$dst",
Evan Cheng09c54572006-06-29 00:36:51 +00002581 [(store (rotl (loadi32 addr:$dst), (i8 1)), addr:$dst)]>;
Eric Christophera938cfb2010-06-19 00:37:40 +00002582} // Constraints = ""
Chris Lattner40ff6332005-01-19 07:50:03 +00002583
Evan Cheng071a2792007-09-11 19:55:27 +00002584let Uses = [CL] in {
Eric Christophera938cfb2010-06-19 00:37:40 +00002585def ROR8rCL : I<0xD2, MRM1r, (outs GR8 :$dst), (ins GR8 :$src1),
Eli Friedmanaace4b12009-06-19 04:48:38 +00002586 "ror{b}\t{%cl, $dst|$dst, CL}",
Eric Christophera938cfb2010-06-19 00:37:40 +00002587 [(set GR8:$dst, (rotr GR8:$src1, CL))]>;
2588def ROR16rCL : I<0xD3, MRM1r, (outs GR16:$dst), (ins GR16:$src1),
Eli Friedmanaace4b12009-06-19 04:48:38 +00002589 "ror{w}\t{%cl, $dst|$dst, CL}",
Eric Christophera938cfb2010-06-19 00:37:40 +00002590 [(set GR16:$dst, (rotr GR16:$src1, CL))]>, OpSize;
2591def ROR32rCL : I<0xD3, MRM1r, (outs GR32:$dst), (ins GR32:$src1),
Eli Friedmanaace4b12009-06-19 04:48:38 +00002592 "ror{l}\t{%cl, $dst|$dst, CL}",
Eric Christophera938cfb2010-06-19 00:37:40 +00002593 [(set GR32:$dst, (rotr GR32:$src1, CL))]>;
Evan Cheng071a2792007-09-11 19:55:27 +00002594}
Chris Lattner40ff6332005-01-19 07:50:03 +00002595
Evan Cheng64d80e32007-07-19 01:14:50 +00002596def ROR8ri : Ii8<0xC0, MRM1r, (outs GR8 :$dst), (ins GR8 :$src1, i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002597 "ror{b}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00002598 [(set GR8:$dst, (rotr GR8:$src1, (i8 imm:$src2)))]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00002599def ROR16ri : Ii8<0xC1, MRM1r, (outs GR16:$dst), (ins GR16:$src1, i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002600 "ror{w}\t{$src2, $dst|$dst, $src2}",
Sean Callanan108934c2009-12-18 00:01:26 +00002601 [(set GR16:$dst, (rotr GR16:$src1, (i8 imm:$src2)))]>,
2602 OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00002603def ROR32ri : Ii8<0xC1, MRM1r, (outs GR32:$dst), (ins GR32:$src1, i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002604 "ror{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00002605 [(set GR32:$dst, (rotr GR32:$src1, (i8 imm:$src2)))]>;
Evan Cheng09c54572006-06-29 00:36:51 +00002606
2607// Rotate by 1
Evan Cheng64d80e32007-07-19 01:14:50 +00002608def ROR8r1 : I<0xD0, MRM1r, (outs GR8 :$dst), (ins GR8 :$src1),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002609 "ror{b}\t$dst",
Evan Cheng09c54572006-06-29 00:36:51 +00002610 [(set GR8:$dst, (rotr GR8:$src1, (i8 1)))]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00002611def ROR16r1 : I<0xD1, MRM1r, (outs GR16:$dst), (ins GR16:$src1),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002612 "ror{w}\t$dst",
Evan Cheng09c54572006-06-29 00:36:51 +00002613 [(set GR16:$dst, (rotr GR16:$src1, (i8 1)))]>, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00002614def ROR32r1 : I<0xD1, MRM1r, (outs GR32:$dst), (ins GR32:$src1),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002615 "ror{l}\t$dst",
Evan Cheng09c54572006-06-29 00:36:51 +00002616 [(set GR32:$dst, (rotr GR32:$src1, (i8 1)))]>;
2617
Eric Christophera938cfb2010-06-19 00:37:40 +00002618let Constraints = "" in {
Evan Cheng071a2792007-09-11 19:55:27 +00002619 let Uses = [CL] in {
Evan Cheng64d80e32007-07-19 01:14:50 +00002620 def ROR8mCL : I<0xD2, MRM1m, (outs), (ins i8mem :$dst),
Eli Friedmanaace4b12009-06-19 04:48:38 +00002621 "ror{b}\t{%cl, $dst|$dst, CL}",
Evan Cheng071a2792007-09-11 19:55:27 +00002622 [(store (rotr (loadi8 addr:$dst), CL), addr:$dst)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00002623 def ROR16mCL : I<0xD3, MRM1m, (outs), (ins i16mem:$dst),
Eli Friedmanaace4b12009-06-19 04:48:38 +00002624 "ror{w}\t{%cl, $dst|$dst, CL}",
Evan Cheng071a2792007-09-11 19:55:27 +00002625 [(store (rotr (loadi16 addr:$dst), CL), addr:$dst)]>, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00002626 def ROR32mCL : I<0xD3, MRM1m, (outs), (ins i32mem:$dst),
Eli Friedmanaace4b12009-06-19 04:48:38 +00002627 "ror{l}\t{%cl, $dst|$dst, CL}",
Evan Cheng071a2792007-09-11 19:55:27 +00002628 [(store (rotr (loadi32 addr:$dst), CL), addr:$dst)]>;
2629 }
Evan Cheng64d80e32007-07-19 01:14:50 +00002630 def ROR8mi : Ii8<0xC0, MRM1m, (outs), (ins i8mem :$dst, i8imm:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002631 "ror{b}\t{$src, $dst|$dst, $src}",
Evan Chengeb422a72006-01-11 23:20:05 +00002632 [(store (rotr (loadi8 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00002633 def ROR16mi : Ii8<0xC1, MRM1m, (outs), (ins i16mem:$dst, i8imm:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002634 "ror{w}\t{$src, $dst|$dst, $src}",
Evan Chengeb422a72006-01-11 23:20:05 +00002635 [(store (rotr (loadi16 addr:$dst), (i8 imm:$src)), addr:$dst)]>,
2636 OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00002637 def ROR32mi : Ii8<0xC1, MRM1m, (outs), (ins i32mem:$dst, i8imm:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002638 "ror{l}\t{$src, $dst|$dst, $src}",
Evan Chengeb422a72006-01-11 23:20:05 +00002639 [(store (rotr (loadi32 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
Evan Cheng09c54572006-06-29 00:36:51 +00002640
2641 // Rotate by 1
Evan Cheng64d80e32007-07-19 01:14:50 +00002642 def ROR8m1 : I<0xD0, MRM1m, (outs), (ins i8mem :$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002643 "ror{b}\t$dst",
Evan Cheng09c54572006-06-29 00:36:51 +00002644 [(store (rotr (loadi8 addr:$dst), (i8 1)), addr:$dst)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00002645 def ROR16m1 : I<0xD1, MRM1m, (outs), (ins i16mem:$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002646 "ror{w}\t$dst",
Evan Cheng09c54572006-06-29 00:36:51 +00002647 [(store (rotr (loadi16 addr:$dst), (i8 1)), addr:$dst)]>,
2648 OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00002649 def ROR32m1 : I<0xD1, MRM1m, (outs), (ins i32mem:$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002650 "ror{l}\t$dst",
Evan Cheng09c54572006-06-29 00:36:51 +00002651 [(store (rotr (loadi32 addr:$dst), (i8 1)), addr:$dst)]>;
Eric Christophera938cfb2010-06-19 00:37:40 +00002652} // Constraints = ""
Chris Lattner40ff6332005-01-19 07:50:03 +00002653
2654
2655// Double shift instructions (generalizations of rotate)
Evan Cheng071a2792007-09-11 19:55:27 +00002656let Uses = [CL] in {
Sean Callanan108934c2009-12-18 00:01:26 +00002657def SHLD32rrCL : I<0xA5, MRMDestReg, (outs GR32:$dst),
2658 (ins GR32:$src1, GR32:$src2),
Eli Friedmanaace4b12009-06-19 04:48:38 +00002659 "shld{l}\t{%cl, $src2, $dst|$dst, $src2, CL}",
Evan Cheng071a2792007-09-11 19:55:27 +00002660 [(set GR32:$dst, (X86shld GR32:$src1, GR32:$src2, CL))]>, TB;
Sean Callanan108934c2009-12-18 00:01:26 +00002661def SHRD32rrCL : I<0xAD, MRMDestReg, (outs GR32:$dst),
2662 (ins GR32:$src1, GR32:$src2),
Eli Friedmanaace4b12009-06-19 04:48:38 +00002663 "shrd{l}\t{%cl, $src2, $dst|$dst, $src2, CL}",
Evan Cheng071a2792007-09-11 19:55:27 +00002664 [(set GR32:$dst, (X86shrd GR32:$src1, GR32:$src2, CL))]>, TB;
Sean Callanan108934c2009-12-18 00:01:26 +00002665def SHLD16rrCL : I<0xA5, MRMDestReg, (outs GR16:$dst),
2666 (ins GR16:$src1, GR16:$src2),
Eli Friedmanaace4b12009-06-19 04:48:38 +00002667 "shld{w}\t{%cl, $src2, $dst|$dst, $src2, CL}",
Evan Cheng069287d2006-05-16 07:21:53 +00002668 [(set GR16:$dst, (X86shld GR16:$src1, GR16:$src2, CL))]>,
Evan Cheng071a2792007-09-11 19:55:27 +00002669 TB, OpSize;
Sean Callanan108934c2009-12-18 00:01:26 +00002670def SHRD16rrCL : I<0xAD, MRMDestReg, (outs GR16:$dst),
2671 (ins GR16:$src1, GR16:$src2),
Eli Friedmanaace4b12009-06-19 04:48:38 +00002672 "shrd{w}\t{%cl, $src2, $dst|$dst, $src2, CL}",
Evan Cheng069287d2006-05-16 07:21:53 +00002673 [(set GR16:$dst, (X86shrd GR16:$src1, GR16:$src2, CL))]>,
Evan Cheng071a2792007-09-11 19:55:27 +00002674 TB, OpSize;
2675}
Chris Lattner41e431b2005-01-19 07:11:01 +00002676
2677let isCommutable = 1 in { // These instructions commute to each other.
Chris Lattner3a173df2004-10-03 20:35:00 +00002678def SHLD32rri8 : Ii8<0xA4, MRMDestReg,
Sean Callanan108934c2009-12-18 00:01:26 +00002679 (outs GR32:$dst),
2680 (ins GR32:$src1, GR32:$src2, i8imm:$src3),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002681 "shld{l}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Evan Cheng069287d2006-05-16 07:21:53 +00002682 [(set GR32:$dst, (X86shld GR32:$src1, GR32:$src2,
Evan Chenge3413162006-01-09 18:33:28 +00002683 (i8 imm:$src3)))]>,
2684 TB;
Chris Lattner3a173df2004-10-03 20:35:00 +00002685def SHRD32rri8 : Ii8<0xAC, MRMDestReg,
Sean Callanan108934c2009-12-18 00:01:26 +00002686 (outs GR32:$dst),
2687 (ins GR32:$src1, GR32:$src2, i8imm:$src3),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002688 "shrd{l}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Evan Cheng069287d2006-05-16 07:21:53 +00002689 [(set GR32:$dst, (X86shrd GR32:$src1, GR32:$src2,
Evan Chenge3413162006-01-09 18:33:28 +00002690 (i8 imm:$src3)))]>,
2691 TB;
Chris Lattner0df53d22005-01-19 07:31:24 +00002692def SHLD16rri8 : Ii8<0xA4, MRMDestReg,
Sean Callanan108934c2009-12-18 00:01:26 +00002693 (outs GR16:$dst),
2694 (ins GR16:$src1, GR16:$src2, i8imm:$src3),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002695 "shld{w}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Evan Cheng069287d2006-05-16 07:21:53 +00002696 [(set GR16:$dst, (X86shld GR16:$src1, GR16:$src2,
Evan Chenge3413162006-01-09 18:33:28 +00002697 (i8 imm:$src3)))]>,
Chris Lattner0df53d22005-01-19 07:31:24 +00002698 TB, OpSize;
2699def SHRD16rri8 : Ii8<0xAC, MRMDestReg,
Sean Callanan108934c2009-12-18 00:01:26 +00002700 (outs GR16:$dst),
2701 (ins GR16:$src1, GR16:$src2, i8imm:$src3),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002702 "shrd{w}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Evan Cheng069287d2006-05-16 07:21:53 +00002703 [(set GR16:$dst, (X86shrd GR16:$src1, GR16:$src2,
Evan Chenge3413162006-01-09 18:33:28 +00002704 (i8 imm:$src3)))]>,
Chris Lattner0df53d22005-01-19 07:31:24 +00002705 TB, OpSize;
Chris Lattner41e431b2005-01-19 07:11:01 +00002706}
Chris Lattner0e967d42004-08-01 08:13:11 +00002707
Eric Christophera938cfb2010-06-19 00:37:40 +00002708let Constraints = "" in {
Evan Cheng071a2792007-09-11 19:55:27 +00002709 let Uses = [CL] in {
Evan Cheng64d80e32007-07-19 01:14:50 +00002710 def SHLD32mrCL : I<0xA5, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
Eli Friedmanaace4b12009-06-19 04:48:38 +00002711 "shld{l}\t{%cl, $src2, $dst|$dst, $src2, CL}",
Evan Cheng069287d2006-05-16 07:21:53 +00002712 [(store (X86shld (loadi32 addr:$dst), GR32:$src2, CL),
Evan Cheng071a2792007-09-11 19:55:27 +00002713 addr:$dst)]>, TB;
Evan Cheng64d80e32007-07-19 01:14:50 +00002714 def SHRD32mrCL : I<0xAD, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
Eli Friedmanaace4b12009-06-19 04:48:38 +00002715 "shrd{l}\t{%cl, $src2, $dst|$dst, $src2, CL}",
Evan Cheng069287d2006-05-16 07:21:53 +00002716 [(store (X86shrd (loadi32 addr:$dst), GR32:$src2, CL),
Evan Cheng071a2792007-09-11 19:55:27 +00002717 addr:$dst)]>, TB;
2718 }
Chris Lattner3a173df2004-10-03 20:35:00 +00002719 def SHLD32mri8 : Ii8<0xA4, MRMDestMem,
Evan Cheng64d80e32007-07-19 01:14:50 +00002720 (outs), (ins i32mem:$dst, GR32:$src2, i8imm:$src3),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002721 "shld{l}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Evan Cheng069287d2006-05-16 07:21:53 +00002722 [(store (X86shld (loadi32 addr:$dst), GR32:$src2,
Evan Chenge3413162006-01-09 18:33:28 +00002723 (i8 imm:$src3)), addr:$dst)]>,
Chris Lattnerf124d5e2005-11-18 01:04:42 +00002724 TB;
Chris Lattner3a173df2004-10-03 20:35:00 +00002725 def SHRD32mri8 : Ii8<0xAC, MRMDestMem,
Evan Cheng64d80e32007-07-19 01:14:50 +00002726 (outs), (ins i32mem:$dst, GR32:$src2, i8imm:$src3),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002727 "shrd{l}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Evan Cheng069287d2006-05-16 07:21:53 +00002728 [(store (X86shrd (loadi32 addr:$dst), GR32:$src2,
Evan Chenge3413162006-01-09 18:33:28 +00002729 (i8 imm:$src3)), addr:$dst)]>,
Chris Lattnerf124d5e2005-11-18 01:04:42 +00002730 TB;
Chris Lattner0df53d22005-01-19 07:31:24 +00002731
Evan Cheng071a2792007-09-11 19:55:27 +00002732 let Uses = [CL] in {
Evan Cheng64d80e32007-07-19 01:14:50 +00002733 def SHLD16mrCL : I<0xA5, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
Eli Friedmanaace4b12009-06-19 04:48:38 +00002734 "shld{w}\t{%cl, $src2, $dst|$dst, $src2, CL}",
Evan Cheng069287d2006-05-16 07:21:53 +00002735 [(store (X86shld (loadi16 addr:$dst), GR16:$src2, CL),
Evan Cheng071a2792007-09-11 19:55:27 +00002736 addr:$dst)]>, TB, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00002737 def SHRD16mrCL : I<0xAD, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
Eli Friedmanaace4b12009-06-19 04:48:38 +00002738 "shrd{w}\t{%cl, $src2, $dst|$dst, $src2, CL}",
Evan Cheng069287d2006-05-16 07:21:53 +00002739 [(store (X86shrd (loadi16 addr:$dst), GR16:$src2, CL),
Evan Cheng071a2792007-09-11 19:55:27 +00002740 addr:$dst)]>, TB, OpSize;
2741 }
Chris Lattner0df53d22005-01-19 07:31:24 +00002742 def SHLD16mri8 : Ii8<0xA4, MRMDestMem,
Evan Cheng64d80e32007-07-19 01:14:50 +00002743 (outs), (ins i16mem:$dst, GR16:$src2, i8imm:$src3),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002744 "shld{w}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Evan Cheng069287d2006-05-16 07:21:53 +00002745 [(store (X86shld (loadi16 addr:$dst), GR16:$src2,
Evan Chenge3413162006-01-09 18:33:28 +00002746 (i8 imm:$src3)), addr:$dst)]>,
Chris Lattner0df53d22005-01-19 07:31:24 +00002747 TB, OpSize;
2748 def SHRD16mri8 : Ii8<0xAC, MRMDestMem,
Evan Cheng64d80e32007-07-19 01:14:50 +00002749 (outs), (ins i16mem:$dst, GR16:$src2, i8imm:$src3),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002750 "shrd{w}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Evan Cheng069287d2006-05-16 07:21:53 +00002751 [(store (X86shrd (loadi16 addr:$dst), GR16:$src2,
Evan Chenge3413162006-01-09 18:33:28 +00002752 (i8 imm:$src3)), addr:$dst)]>,
Chris Lattner0df53d22005-01-19 07:31:24 +00002753 TB, OpSize;
Eric Christophera938cfb2010-06-19 00:37:40 +00002754} // Constraints = ""
Evan Cheng24f2ea32007-09-14 21:48:26 +00002755} // Defs = [EFLAGS]
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00002756
2757
Chris Lattnercc65bee2005-01-02 02:35:46 +00002758// Arithmetic.
Evan Cheng24f2ea32007-09-14 21:48:26 +00002759let Defs = [EFLAGS] in {
Chris Lattnercc65bee2005-01-02 02:35:46 +00002760let isCommutable = 1 in { // X = ADD Y, Z --> X = ADD Z, Y
Bill Wendlingab55ebd2008-12-12 00:56:36 +00002761// Register-Register Addition
2762def ADD8rr : I<0x00, MRMDestReg, (outs GR8 :$dst),
2763 (ins GR8 :$src1, GR8 :$src2),
2764 "add{b}\t{$src2, $dst|$dst, $src2}",
Chris Lattnerec856802010-03-27 00:45:04 +00002765 [(set GR8:$dst, EFLAGS, (X86add_flag GR8:$src1, GR8:$src2))]>;
Bill Wendlingab55ebd2008-12-12 00:56:36 +00002766
Chris Lattnercc65bee2005-01-02 02:35:46 +00002767let isConvertibleToThreeAddress = 1 in { // Can transform into LEA.
Bill Wendlingab55ebd2008-12-12 00:56:36 +00002768// Register-Register Addition
Evan Cheng071a2792007-09-11 19:55:27 +00002769def ADD16rr : I<0x01, MRMDestReg, (outs GR16:$dst),
2770 (ins GR16:$src1, GR16:$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, (X86add_flag GR16:$src1,
2773 GR16:$src2))]>, OpSize;
Evan Cheng071a2792007-09-11 19:55:27 +00002774def ADD32rr : I<0x01, MRMDestReg, (outs GR32:$dst),
2775 (ins GR32:$src1, GR32:$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, (X86add_flag GR32:$src1,
2778 GR32:$src2))]>;
Chris Lattnercc65bee2005-01-02 02:35:46 +00002779} // end isConvertibleToThreeAddress
2780} // end isCommutable
Bill Wendlingab55ebd2008-12-12 00:56:36 +00002781
Daniel Dunbarf291be32010-03-09 22:50:46 +00002782// These are alternate spellings for use by the disassembler, we mark them as
2783// code gen only to ensure they aren't matched by the assembler.
2784let isCodeGenOnly = 1 in {
2785 def ADD8rr_alt: I<0x02, MRMSrcReg, (outs GR8:$dst), (ins GR8:$src1, GR8:$src2),
2786 "add{b}\t{$src2, $dst|$dst, $src2}", []>;
2787 def ADD16rr_alt: I<0x03, MRMSrcReg,(outs GR16:$dst),(ins GR16:$src1, GR16:$src2),
2788 "add{w}\t{$src2, $dst|$dst, $src2}", []>, OpSize;
Evan Cheng18ac4102010-04-05 22:21:09 +00002789 def ADD32rr_alt: I<0x03, MRMSrcReg,(outs GR32:$dst),(ins GR32:$src1, GR32:$src2),
Daniel Dunbarf291be32010-03-09 22:50:46 +00002790 "add{l}\t{$src2, $dst|$dst, $src2}", []>;
2791}
2792
Bill Wendlingab55ebd2008-12-12 00:56:36 +00002793// Register-Memory Addition
Evan Cheng071a2792007-09-11 19:55:27 +00002794def ADD8rm : I<0x02, MRMSrcMem, (outs GR8 :$dst),
2795 (ins GR8 :$src1, i8mem :$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002796 "add{b}\t{$src2, $dst|$dst, $src2}",
Chris Lattnerec856802010-03-27 00:45:04 +00002797 [(set GR8:$dst, EFLAGS, (X86add_flag GR8:$src1,
2798 (load addr:$src2)))]>;
Evan Cheng071a2792007-09-11 19:55:27 +00002799def ADD16rm : I<0x03, MRMSrcMem, (outs GR16:$dst),
2800 (ins GR16:$src1, i16mem:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002801 "add{w}\t{$src2, $dst|$dst, $src2}",
Chris Lattnerec856802010-03-27 00:45:04 +00002802 [(set GR16:$dst, EFLAGS, (X86add_flag GR16:$src1,
2803 (load addr:$src2)))]>, OpSize;
Evan Cheng071a2792007-09-11 19:55:27 +00002804def ADD32rm : I<0x03, MRMSrcMem, (outs GR32:$dst),
2805 (ins GR32:$src1, i32mem:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002806 "add{l}\t{$src2, $dst|$dst, $src2}",
Chris Lattnerec856802010-03-27 00:45:04 +00002807 [(set GR32:$dst, EFLAGS, (X86add_flag GR32:$src1,
2808 (load addr:$src2)))]>;
Sean Callanan37be5902009-09-15 20:53:57 +00002809
Bill Wendlingab55ebd2008-12-12 00:56:36 +00002810// Register-Integer Addition
2811def ADD8ri : Ii8<0x80, MRM0r, (outs GR8:$dst), (ins GR8:$src1, i8imm:$src2),
2812 "add{b}\t{$src2, $dst|$dst, $src2}",
Chris Lattnerec856802010-03-27 00:45:04 +00002813 [(set GR8:$dst, EFLAGS,
2814 (X86add_flag GR8:$src1, imm:$src2))]>;
Bill Wendlingab55ebd2008-12-12 00:56:36 +00002815
Chris Lattnercc65bee2005-01-02 02:35:46 +00002816let isConvertibleToThreeAddress = 1 in { // Can transform into LEA.
Bill Wendlingab55ebd2008-12-12 00:56:36 +00002817// Register-Integer Addition
Evan Cheng071a2792007-09-11 19:55:27 +00002818def ADD16ri : Ii16<0x81, MRM0r, (outs GR16:$dst),
2819 (ins GR16:$src1, i16imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002820 "add{w}\t{$src2, $dst|$dst, $src2}",
Chris Lattnerec856802010-03-27 00:45:04 +00002821 [(set GR16:$dst, EFLAGS,
2822 (X86add_flag GR16:$src1, imm:$src2))]>, OpSize;
Evan Cheng071a2792007-09-11 19:55:27 +00002823def ADD32ri : Ii32<0x81, MRM0r, (outs GR32:$dst),
2824 (ins GR32:$src1, i32imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002825 "add{l}\t{$src2, $dst|$dst, $src2}",
Chris Lattnerec856802010-03-27 00:45:04 +00002826 [(set GR32:$dst, EFLAGS,
2827 (X86add_flag GR32:$src1, imm:$src2))]>;
Evan Cheng071a2792007-09-11 19:55:27 +00002828def ADD16ri8 : Ii8<0x83, MRM0r, (outs GR16:$dst),
2829 (ins GR16:$src1, i16i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002830 "add{w}\t{$src2, $dst|$dst, $src2}",
Chris Lattnerec856802010-03-27 00:45:04 +00002831 [(set GR16:$dst, EFLAGS,
2832 (X86add_flag GR16:$src1, i16immSExt8:$src2))]>, OpSize;
Evan Cheng071a2792007-09-11 19:55:27 +00002833def ADD32ri8 : Ii8<0x83, MRM0r, (outs GR32:$dst),
2834 (ins GR32:$src1, i32i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002835 "add{l}\t{$src2, $dst|$dst, $src2}",
Chris Lattnerec856802010-03-27 00:45:04 +00002836 [(set GR32:$dst, EFLAGS,
2837 (X86add_flag GR32:$src1, i32immSExt8:$src2))]>;
Evan Cheng09e3c802006-05-19 18:40:54 +00002838}
Chris Lattner57a02302004-08-11 04:31:00 +00002839
Eric Christophera938cfb2010-06-19 00:37:40 +00002840let Constraints = "" in {
Bill Wendlingab55ebd2008-12-12 00:56:36 +00002841 // Memory-Register Addition
Bill Wendlingd350e022008-12-12 21:15:41 +00002842 def ADD8mr : I<0x00, MRMDestMem, (outs), (ins i8mem:$dst, GR8:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002843 "add{b}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingd350e022008-12-12 21:15:41 +00002844 [(store (add (load addr:$dst), GR8:$src2), addr:$dst),
2845 (implicit EFLAGS)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00002846 def ADD16mr : I<0x01, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002847 "add{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingd350e022008-12-12 21:15:41 +00002848 [(store (add (load addr:$dst), GR16:$src2), addr:$dst),
2849 (implicit EFLAGS)]>, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00002850 def ADD32mr : I<0x01, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002851 "add{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingd350e022008-12-12 21:15:41 +00002852 [(store (add (load addr:$dst), GR32:$src2), addr:$dst),
2853 (implicit EFLAGS)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00002854 def ADD8mi : Ii8<0x80, MRM0m, (outs), (ins i8mem :$dst, i8imm :$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002855 "add{b}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingd350e022008-12-12 21:15:41 +00002856 [(store (add (loadi8 addr:$dst), imm:$src2), addr:$dst),
2857 (implicit EFLAGS)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00002858 def ADD16mi : Ii16<0x81, MRM0m, (outs), (ins i16mem:$dst, i16imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002859 "add{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingd350e022008-12-12 21:15:41 +00002860 [(store (add (loadi16 addr:$dst), imm:$src2), addr:$dst),
2861 (implicit EFLAGS)]>, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00002862 def ADD32mi : Ii32<0x81, MRM0m, (outs), (ins i32mem:$dst, i32imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002863 "add{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingd350e022008-12-12 21:15:41 +00002864 [(store (add (loadi32 addr:$dst), imm:$src2), addr:$dst),
2865 (implicit EFLAGS)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00002866 def ADD16mi8 : Ii8<0x83, MRM0m, (outs), (ins i16mem:$dst, i16i8imm :$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002867 "add{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingd350e022008-12-12 21:15:41 +00002868 [(store (add (load addr:$dst), i16immSExt8:$src2),
2869 addr:$dst),
2870 (implicit EFLAGS)]>, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00002871 def ADD32mi8 : Ii8<0x83, MRM0m, (outs), (ins i32mem:$dst, i32i8imm :$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002872 "add{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingab55ebd2008-12-12 00:56:36 +00002873 [(store (add (load addr:$dst), i32immSExt8:$src2),
Bill Wendlingd350e022008-12-12 21:15:41 +00002874 addr:$dst),
2875 (implicit EFLAGS)]>;
Sean Callananb08ae6b2009-08-11 21:26:06 +00002876
2877 // addition to rAX
2878 def ADD8i8 : Ii8<0x04, RawFrm, (outs), (ins i8imm:$src),
Sean Callanana09caa52009-09-02 00:55:49 +00002879 "add{b}\t{$src, %al|%al, $src}", []>;
Sean Callananb08ae6b2009-08-11 21:26:06 +00002880 def ADD16i16 : Ii16<0x05, RawFrm, (outs), (ins i16imm:$src),
Sean Callanana09caa52009-09-02 00:55:49 +00002881 "add{w}\t{$src, %ax|%ax, $src}", []>, OpSize;
Sean Callananb08ae6b2009-08-11 21:26:06 +00002882 def ADD32i32 : Ii32<0x05, RawFrm, (outs), (ins i32imm:$src),
Sean Callanana09caa52009-09-02 00:55:49 +00002883 "add{l}\t{$src, %eax|%eax, $src}", []>;
Eric Christophera938cfb2010-06-19 00:37:40 +00002884} // Constraints = ""
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00002885
Evan Cheng3154cb62007-10-05 17:59:57 +00002886let Uses = [EFLAGS] in {
Chris Lattner10197ff2005-01-03 01:27:59 +00002887let isCommutable = 1 in { // X = ADC Y, Z --> X = ADC Z, Y
Dale Johannesen874ae252009-06-02 03:12:52 +00002888def ADC8rr : I<0x10, MRMDestReg, (outs GR8:$dst), (ins GR8:$src1, GR8:$src2),
Dale Johannesenca11dae2009-05-18 17:44:15 +00002889 "adc{b}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen874ae252009-06-02 03:12:52 +00002890 [(set GR8:$dst, (adde GR8:$src1, GR8:$src2))]>;
Dale Johannesenca11dae2009-05-18 17:44:15 +00002891def ADC16rr : I<0x11, MRMDestReg, (outs GR16:$dst),
2892 (ins GR16:$src1, GR16:$src2),
2893 "adc{w}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen874ae252009-06-02 03:12:52 +00002894 [(set GR16:$dst, (adde GR16:$src1, GR16:$src2))]>, OpSize;
Dale Johannesenca11dae2009-05-18 17:44:15 +00002895def ADC32rr : I<0x11, MRMDestReg, (outs GR32:$dst),
2896 (ins GR32:$src1, GR32:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002897 "adc{l}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen874ae252009-06-02 03:12:52 +00002898 [(set GR32:$dst, (adde GR32:$src1, GR32:$src2))]>;
Chris Lattner10197ff2005-01-03 01:27:59 +00002899}
Sean Callanan108934c2009-12-18 00:01:26 +00002900
Daniel Dunbardcbab9c2010-05-26 22:21:28 +00002901let isCodeGenOnly = 1 in {
Sean Callanan108934c2009-12-18 00:01:26 +00002902def ADC8rr_REV : I<0x12, MRMSrcReg, (outs GR8:$dst), (ins GR8:$src1, GR8:$src2),
2903 "adc{b}\t{$src2, $dst|$dst, $src2}", []>;
2904def ADC16rr_REV : I<0x13, MRMSrcReg, (outs GR16:$dst),
2905 (ins GR16:$src1, GR16:$src2),
2906 "adc{w}\t{$src2, $dst|$dst, $src2}", []>, OpSize;
2907def ADC32rr_REV : I<0x13, MRMSrcReg, (outs GR32:$dst),
2908 (ins GR32:$src1, GR32:$src2),
2909 "adc{l}\t{$src2, $dst|$dst, $src2}", []>;
Daniel Dunbardcbab9c2010-05-26 22:21:28 +00002910}
Sean Callanan108934c2009-12-18 00:01:26 +00002911
Dale Johannesenca11dae2009-05-18 17:44:15 +00002912def ADC8rm : I<0x12, MRMSrcMem , (outs GR8:$dst),
2913 (ins GR8:$src1, i8mem:$src2),
2914 "adc{b}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen874ae252009-06-02 03:12:52 +00002915 [(set GR8:$dst, (adde GR8:$src1, (load addr:$src2)))]>;
Dale Johannesenca11dae2009-05-18 17:44:15 +00002916def ADC16rm : I<0x13, MRMSrcMem , (outs GR16:$dst),
2917 (ins GR16:$src1, i16mem:$src2),
2918 "adc{w}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen874ae252009-06-02 03:12:52 +00002919 [(set GR16:$dst, (adde GR16:$src1, (load addr:$src2)))]>,
Dale Johannesen94c9cd12009-05-18 21:41:59 +00002920 OpSize;
Dale Johannesenca11dae2009-05-18 17:44:15 +00002921def ADC32rm : I<0x13, MRMSrcMem , (outs GR32:$dst),
2922 (ins GR32:$src1, i32mem:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002923 "adc{l}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen874ae252009-06-02 03:12:52 +00002924 [(set GR32:$dst, (adde GR32:$src1, (load addr:$src2)))]>;
2925def ADC8ri : Ii8<0x80, MRM2r, (outs GR8:$dst), (ins GR8:$src1, i8imm:$src2),
Dale Johannesenca11dae2009-05-18 17:44:15 +00002926 "adc{b}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen874ae252009-06-02 03:12:52 +00002927 [(set GR8:$dst, (adde GR8:$src1, imm:$src2))]>;
Dale Johannesenca11dae2009-05-18 17:44:15 +00002928def ADC16ri : Ii16<0x81, MRM2r, (outs GR16:$dst),
2929 (ins GR16:$src1, i16imm:$src2),
2930 "adc{w}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen874ae252009-06-02 03:12:52 +00002931 [(set GR16:$dst, (adde GR16:$src1, imm:$src2))]>, OpSize;
Dale Johannesenca11dae2009-05-18 17:44:15 +00002932def ADC16ri8 : Ii8<0x83, MRM2r, (outs GR16:$dst),
2933 (ins GR16:$src1, i16i8imm:$src2),
2934 "adc{w}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen874ae252009-06-02 03:12:52 +00002935 [(set GR16:$dst, (adde GR16:$src1, i16immSExt8:$src2))]>,
2936 OpSize;
Dale Johannesenca11dae2009-05-18 17:44:15 +00002937def ADC32ri : Ii32<0x81, MRM2r, (outs GR32:$dst),
2938 (ins GR32:$src1, i32imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002939 "adc{l}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen874ae252009-06-02 03:12:52 +00002940 [(set GR32:$dst, (adde GR32:$src1, imm:$src2))]>;
Dale Johannesenca11dae2009-05-18 17:44:15 +00002941def ADC32ri8 : Ii8<0x83, MRM2r, (outs GR32:$dst),
2942 (ins GR32:$src1, i32i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002943 "adc{l}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen874ae252009-06-02 03:12:52 +00002944 [(set GR32:$dst, (adde GR32:$src1, i32immSExt8:$src2))]>;
Chris Lattner57a02302004-08-11 04:31:00 +00002945
Eric Christophera938cfb2010-06-19 00:37:40 +00002946let Constraints = "" in {
Dale Johannesen874ae252009-06-02 03:12:52 +00002947 def ADC8mr : I<0x10, MRMDestMem, (outs), (ins i8mem:$dst, GR8:$src2),
Dale Johannesenca11dae2009-05-18 17:44:15 +00002948 "adc{b}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen874ae252009-06-02 03:12:52 +00002949 [(store (adde (load addr:$dst), GR8:$src2), addr:$dst)]>;
2950 def ADC16mr : I<0x11, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
Dale Johannesenca11dae2009-05-18 17:44:15 +00002951 "adc{w}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen874ae252009-06-02 03:12:52 +00002952 [(store (adde (load addr:$dst), GR16:$src2), addr:$dst)]>,
2953 OpSize;
2954 def ADC32mr : I<0x11, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002955 "adc{l}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen874ae252009-06-02 03:12:52 +00002956 [(store (adde (load addr:$dst), GR32:$src2), addr:$dst)]>;
2957 def ADC8mi : Ii8<0x80, MRM2m, (outs), (ins i8mem:$dst, i8imm:$src2),
Dale Johannesenca11dae2009-05-18 17:44:15 +00002958 "adc{b}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen874ae252009-06-02 03:12:52 +00002959 [(store (adde (loadi8 addr:$dst), imm:$src2), addr:$dst)]>;
2960 def ADC16mi : Ii16<0x81, MRM2m, (outs), (ins i16mem:$dst, i16imm:$src2),
Dale Johannesenca11dae2009-05-18 17:44:15 +00002961 "adc{w}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen874ae252009-06-02 03:12:52 +00002962 [(store (adde (loadi16 addr:$dst), imm:$src2), addr:$dst)]>,
2963 OpSize;
2964 def ADC16mi8 : Ii8<0x83, MRM2m, (outs), (ins i16mem:$dst, i16i8imm :$src2),
Dale Johannesenca11dae2009-05-18 17:44:15 +00002965 "adc{w}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen874ae252009-06-02 03:12:52 +00002966 [(store (adde (load addr:$dst), i16immSExt8:$src2), addr:$dst)]>,
2967 OpSize;
2968 def ADC32mi : Ii32<0x81, MRM2m, (outs), (ins i32mem:$dst, i32imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002969 "adc{l}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen874ae252009-06-02 03:12:52 +00002970 [(store (adde (loadi32 addr:$dst), imm:$src2), addr:$dst)]>;
2971 def ADC32mi8 : Ii8<0x83, MRM2m, (outs), (ins i32mem:$dst, i32i8imm :$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002972 "adc{l}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen874ae252009-06-02 03:12:52 +00002973 [(store (adde (load addr:$dst), i32immSExt8:$src2), addr:$dst)]>;
Sean Callanand00025a2009-09-11 19:01:56 +00002974
2975 def ADC8i8 : Ii8<0x14, RawFrm, (outs), (ins i8imm:$src),
2976 "adc{b}\t{$src, %al|%al, $src}", []>;
2977 def ADC16i16 : Ii16<0x15, RawFrm, (outs), (ins i16imm:$src),
2978 "adc{w}\t{$src, %ax|%ax, $src}", []>, OpSize;
2979 def ADC32i32 : Ii32<0x15, RawFrm, (outs), (ins i32imm:$src),
2980 "adc{l}\t{$src, %eax|%eax, $src}", []>;
Eric Christophera938cfb2010-06-19 00:37:40 +00002981} // Constraints = ""
Evan Cheng3154cb62007-10-05 17:59:57 +00002982} // Uses = [EFLAGS]
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00002983
Bill Wendlingab55ebd2008-12-12 00:56:36 +00002984// Register-Register Subtraction
2985def SUB8rr : I<0x28, MRMDestReg, (outs GR8:$dst), (ins GR8:$src1, GR8:$src2),
2986 "sub{b}\t{$src2, $dst|$dst, $src2}",
Chris Lattnerec856802010-03-27 00:45:04 +00002987 [(set GR8:$dst, EFLAGS,
2988 (X86sub_flag GR8:$src1, GR8:$src2))]>;
Bill Wendlingab55ebd2008-12-12 00:56:36 +00002989def SUB16rr : I<0x29, MRMDestReg, (outs GR16:$dst), (ins GR16:$src1,GR16:$src2),
2990 "sub{w}\t{$src2, $dst|$dst, $src2}",
Chris Lattnerec856802010-03-27 00:45:04 +00002991 [(set GR16:$dst, EFLAGS,
2992 (X86sub_flag GR16:$src1, GR16:$src2))]>, OpSize;
Bill Wendlingab55ebd2008-12-12 00:56:36 +00002993def SUB32rr : I<0x29, MRMDestReg, (outs GR32:$dst), (ins GR32:$src1,GR32:$src2),
2994 "sub{l}\t{$src2, $dst|$dst, $src2}",
Chris Lattnerec856802010-03-27 00:45:04 +00002995 [(set GR32:$dst, EFLAGS,
2996 (X86sub_flag GR32:$src1, GR32:$src2))]>;
Bill Wendlingab55ebd2008-12-12 00:56:36 +00002997
Daniel Dunbardcbab9c2010-05-26 22:21:28 +00002998let isCodeGenOnly = 1 in {
Sean Callanan108934c2009-12-18 00:01:26 +00002999def SUB8rr_REV : I<0x2A, MRMSrcReg, (outs GR8:$dst), (ins GR8:$src1, GR8:$src2),
3000 "sub{b}\t{$src2, $dst|$dst, $src2}", []>;
3001def SUB16rr_REV : I<0x2B, MRMSrcReg, (outs GR16:$dst),
3002 (ins GR16:$src1, GR16:$src2),
3003 "sub{w}\t{$src2, $dst|$dst, $src2}", []>, OpSize;
3004def SUB32rr_REV : I<0x2B, MRMSrcReg, (outs GR32:$dst),
3005 (ins GR32:$src1, GR32:$src2),
3006 "sub{l}\t{$src2, $dst|$dst, $src2}", []>;
Daniel Dunbardcbab9c2010-05-26 22:21:28 +00003007}
Sean Callanan108934c2009-12-18 00:01:26 +00003008
Bill Wendlingab55ebd2008-12-12 00:56:36 +00003009// Register-Memory Subtraction
3010def SUB8rm : I<0x2A, MRMSrcMem, (outs GR8 :$dst),
3011 (ins GR8 :$src1, i8mem :$src2),
3012 "sub{b}\t{$src2, $dst|$dst, $src2}",
Chris Lattnerec856802010-03-27 00:45:04 +00003013 [(set GR8:$dst, EFLAGS,
3014 (X86sub_flag GR8:$src1, (load addr:$src2)))]>;
Bill Wendlingab55ebd2008-12-12 00:56:36 +00003015def SUB16rm : I<0x2B, MRMSrcMem, (outs GR16:$dst),
3016 (ins GR16:$src1, i16mem:$src2),
3017 "sub{w}\t{$src2, $dst|$dst, $src2}",
Chris Lattnerec856802010-03-27 00:45:04 +00003018 [(set GR16:$dst, EFLAGS,
3019 (X86sub_flag GR16:$src1, (load addr:$src2)))]>, OpSize;
Bill Wendlingab55ebd2008-12-12 00:56:36 +00003020def SUB32rm : I<0x2B, MRMSrcMem, (outs GR32:$dst),
3021 (ins GR32:$src1, i32mem:$src2),
3022 "sub{l}\t{$src2, $dst|$dst, $src2}",
Chris Lattnerec856802010-03-27 00:45:04 +00003023 [(set GR32:$dst, EFLAGS,
3024 (X86sub_flag GR32:$src1, (load addr:$src2)))]>;
Bill Wendlingab55ebd2008-12-12 00:56:36 +00003025
3026// Register-Integer Subtraction
3027def SUB8ri : Ii8 <0x80, MRM5r, (outs GR8:$dst),
3028 (ins GR8:$src1, i8imm:$src2),
3029 "sub{b}\t{$src2, $dst|$dst, $src2}",
Chris Lattnerec856802010-03-27 00:45:04 +00003030 [(set GR8:$dst, EFLAGS,
3031 (X86sub_flag GR8:$src1, imm:$src2))]>;
Bill Wendlingab55ebd2008-12-12 00:56:36 +00003032def SUB16ri : Ii16<0x81, MRM5r, (outs GR16:$dst),
3033 (ins GR16:$src1, i16imm:$src2),
3034 "sub{w}\t{$src2, $dst|$dst, $src2}",
Chris Lattnerec856802010-03-27 00:45:04 +00003035 [(set GR16:$dst, EFLAGS,
3036 (X86sub_flag GR16:$src1, imm:$src2))]>, OpSize;
Bill Wendlingab55ebd2008-12-12 00:56:36 +00003037def SUB32ri : Ii32<0x81, MRM5r, (outs GR32:$dst),
3038 (ins GR32:$src1, i32imm:$src2),
3039 "sub{l}\t{$src2, $dst|$dst, $src2}",
Chris Lattnerec856802010-03-27 00:45:04 +00003040 [(set GR32:$dst, EFLAGS,
3041 (X86sub_flag GR32:$src1, imm:$src2))]>;
Bill Wendlingab55ebd2008-12-12 00:56:36 +00003042def SUB16ri8 : Ii8<0x83, MRM5r, (outs GR16:$dst),
3043 (ins GR16:$src1, i16i8imm:$src2),
3044 "sub{w}\t{$src2, $dst|$dst, $src2}",
Chris Lattnerec856802010-03-27 00:45:04 +00003045 [(set GR16:$dst, EFLAGS,
3046 (X86sub_flag GR16:$src1, i16immSExt8:$src2))]>, OpSize;
Bill Wendlingab55ebd2008-12-12 00:56:36 +00003047def SUB32ri8 : Ii8<0x83, MRM5r, (outs GR32:$dst),
3048 (ins GR32:$src1, i32i8imm:$src2),
3049 "sub{l}\t{$src2, $dst|$dst, $src2}",
Chris Lattnerec856802010-03-27 00:45:04 +00003050 [(set GR32:$dst, EFLAGS,
3051 (X86sub_flag GR32:$src1, i32immSExt8:$src2))]>;
Bill Wendlingab55ebd2008-12-12 00:56:36 +00003052
Eric Christophera938cfb2010-06-19 00:37:40 +00003053let Constraints = "" in {
Bill Wendlingab55ebd2008-12-12 00:56:36 +00003054 // Memory-Register Subtraction
Evan Cheng64d80e32007-07-19 01:14:50 +00003055 def SUB8mr : I<0x28, MRMDestMem, (outs), (ins i8mem :$dst, GR8 :$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003056 "sub{b}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingd350e022008-12-12 21:15:41 +00003057 [(store (sub (load addr:$dst), GR8:$src2), addr:$dst),
3058 (implicit EFLAGS)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00003059 def SUB16mr : I<0x29, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003060 "sub{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingd350e022008-12-12 21:15:41 +00003061 [(store (sub (load addr:$dst), GR16:$src2), addr:$dst),
3062 (implicit EFLAGS)]>, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00003063 def SUB32mr : I<0x29, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003064 "sub{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingd350e022008-12-12 21:15:41 +00003065 [(store (sub (load addr:$dst), GR32:$src2), addr:$dst),
3066 (implicit EFLAGS)]>;
Bill Wendlingab55ebd2008-12-12 00:56:36 +00003067
3068 // Memory-Integer Subtraction
Evan Cheng64d80e32007-07-19 01:14:50 +00003069 def SUB8mi : Ii8<0x80, MRM5m, (outs), (ins i8mem :$dst, i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003070 "sub{b}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingd350e022008-12-12 21:15:41 +00003071 [(store (sub (loadi8 addr:$dst), imm:$src2), addr:$dst),
3072 (implicit EFLAGS)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00003073 def SUB16mi : Ii16<0x81, MRM5m, (outs), (ins i16mem:$dst, i16imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003074 "sub{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingd350e022008-12-12 21:15:41 +00003075 [(store (sub (loadi16 addr:$dst), imm:$src2),addr:$dst),
3076 (implicit EFLAGS)]>, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00003077 def SUB32mi : Ii32<0x81, MRM5m, (outs), (ins i32mem:$dst, i32imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003078 "sub{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingd350e022008-12-12 21:15:41 +00003079 [(store (sub (loadi32 addr:$dst), imm:$src2),addr:$dst),
3080 (implicit EFLAGS)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00003081 def SUB16mi8 : Ii8<0x83, MRM5m, (outs), (ins i16mem:$dst, i16i8imm :$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003082 "sub{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingab55ebd2008-12-12 00:56:36 +00003083 [(store (sub (load addr:$dst), i16immSExt8:$src2),
Bill Wendlingd350e022008-12-12 21:15:41 +00003084 addr:$dst),
3085 (implicit EFLAGS)]>, OpSize;
Bill Wendlingab55ebd2008-12-12 00:56:36 +00003086 def SUB32mi8 : Ii8<0x83, MRM5m, (outs), (ins i32mem:$dst, i32i8imm :$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003087 "sub{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingab55ebd2008-12-12 00:56:36 +00003088 [(store (sub (load addr:$dst), i32immSExt8:$src2),
Bill Wendlingd350e022008-12-12 21:15:41 +00003089 addr:$dst),
3090 (implicit EFLAGS)]>;
Sean Callanand00025a2009-09-11 19:01:56 +00003091
3092 def SUB8i8 : Ii8<0x2C, RawFrm, (outs), (ins i8imm:$src),
3093 "sub{b}\t{$src, %al|%al, $src}", []>;
3094 def SUB16i16 : Ii16<0x2D, RawFrm, (outs), (ins i16imm:$src),
3095 "sub{w}\t{$src, %ax|%ax, $src}", []>, OpSize;
3096 def SUB32i32 : Ii32<0x2D, RawFrm, (outs), (ins i32imm:$src),
3097 "sub{l}\t{$src, %eax|%eax, $src}", []>;
Eric Christophera938cfb2010-06-19 00:37:40 +00003098} // Constraints = ""
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00003099
Evan Cheng3154cb62007-10-05 17:59:57 +00003100let Uses = [EFLAGS] in {
Dale Johannesenca11dae2009-05-18 17:44:15 +00003101def SBB8rr : I<0x18, MRMDestReg, (outs GR8:$dst),
3102 (ins GR8:$src1, GR8:$src2),
3103 "sbb{b}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen874ae252009-06-02 03:12:52 +00003104 [(set GR8:$dst, (sube GR8:$src1, GR8:$src2))]>;
Dale Johannesenca11dae2009-05-18 17:44:15 +00003105def SBB16rr : I<0x19, MRMDestReg, (outs GR16:$dst),
3106 (ins GR16:$src1, GR16:$src2),
3107 "sbb{w}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen874ae252009-06-02 03:12:52 +00003108 [(set GR16:$dst, (sube GR16:$src1, GR16:$src2))]>, OpSize;
Dale Johannesenca11dae2009-05-18 17:44:15 +00003109def SBB32rr : I<0x19, MRMDestReg, (outs GR32:$dst),
3110 (ins GR32:$src1, GR32:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003111 "sbb{l}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen874ae252009-06-02 03:12:52 +00003112 [(set GR32:$dst, (sube GR32:$src1, GR32:$src2))]>;
Chris Lattnerd93d3b02004-10-06 04:01:02 +00003113
Eric Christophera938cfb2010-06-19 00:37:40 +00003114let Constraints = "" in {
Dale Johannesenca11dae2009-05-18 17:44:15 +00003115 def SBB8mr : I<0x18, MRMDestMem, (outs), (ins i8mem:$dst, GR8:$src2),
3116 "sbb{b}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen874ae252009-06-02 03:12:52 +00003117 [(store (sube (load addr:$dst), GR8:$src2), addr:$dst)]>;
Dale Johannesenca11dae2009-05-18 17:44:15 +00003118 def SBB16mr : I<0x19, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
3119 "sbb{w}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen874ae252009-06-02 03:12:52 +00003120 [(store (sube (load addr:$dst), GR16:$src2), addr:$dst)]>,
Dale Johannesen94c9cd12009-05-18 21:41:59 +00003121 OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00003122 def SBB32mr : I<0x19, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003123 "sbb{l}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen874ae252009-06-02 03:12:52 +00003124 [(store (sube (load addr:$dst), GR32:$src2), addr:$dst)]>;
Chris Lattner8f60e4d2010-02-05 22:56:11 +00003125 def SBB8mi : Ii8<0x80, MRM3m, (outs), (ins i8mem:$dst, i8imm:$src2),
3126 "sbb{b}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen874ae252009-06-02 03:12:52 +00003127 [(store (sube (loadi8 addr:$dst), imm:$src2), addr:$dst)]>;
Dale Johannesenca11dae2009-05-18 17:44:15 +00003128 def SBB16mi : Ii16<0x81, MRM3m, (outs), (ins i16mem:$dst, i16imm:$src2),
3129 "sbb{w}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen874ae252009-06-02 03:12:52 +00003130 [(store (sube (loadi16 addr:$dst), imm:$src2), addr:$dst)]>,
Dale Johannesen94c9cd12009-05-18 21:41:59 +00003131 OpSize;
Dale Johannesenca11dae2009-05-18 17:44:15 +00003132 def SBB16mi8 : Ii8<0x83, MRM3m, (outs), (ins i16mem:$dst, i16i8imm :$src2),
3133 "sbb{w}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen874ae252009-06-02 03:12:52 +00003134 [(store (sube (load addr:$dst), i16immSExt8:$src2), addr:$dst)]>,
Dale Johannesen94c9cd12009-05-18 21:41:59 +00003135 OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00003136 def SBB32mi : Ii32<0x81, MRM3m, (outs), (ins i32mem:$dst, i32imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003137 "sbb{l}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen874ae252009-06-02 03:12:52 +00003138 [(store (sube (loadi32 addr:$dst), imm:$src2), addr:$dst)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00003139 def SBB32mi8 : Ii8<0x83, MRM3m, (outs), (ins i32mem:$dst, i32i8imm :$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003140 "sbb{l}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen874ae252009-06-02 03:12:52 +00003141 [(store (sube (load addr:$dst), i32immSExt8:$src2), addr:$dst)]>;
Sean Callanand00025a2009-09-11 19:01:56 +00003142
3143 def SBB8i8 : Ii8<0x1C, RawFrm, (outs), (ins i8imm:$src),
3144 "sbb{b}\t{$src, %al|%al, $src}", []>;
3145 def SBB16i16 : Ii16<0x1D, RawFrm, (outs), (ins i16imm:$src),
3146 "sbb{w}\t{$src, %ax|%ax, $src}", []>, OpSize;
3147 def SBB32i32 : Ii32<0x1D, RawFrm, (outs), (ins i32imm:$src),
3148 "sbb{l}\t{$src, %eax|%eax, $src}", []>;
Eric Christophera938cfb2010-06-19 00:37:40 +00003149} // Constraints = ""
Sean Callanan108934c2009-12-18 00:01:26 +00003150
Daniel Dunbardcbab9c2010-05-26 22:21:28 +00003151let isCodeGenOnly = 1 in {
Sean Callanan108934c2009-12-18 00:01:26 +00003152def SBB8rr_REV : I<0x1A, MRMSrcReg, (outs GR8:$dst), (ins GR8:$src1, GR8:$src2),
3153 "sbb{b}\t{$src2, $dst|$dst, $src2}", []>;
3154def SBB16rr_REV : I<0x1B, MRMSrcReg, (outs GR16:$dst),
3155 (ins GR16:$src1, GR16:$src2),
3156 "sbb{w}\t{$src2, $dst|$dst, $src2}", []>, OpSize;
3157def SBB32rr_REV : I<0x1B, MRMSrcReg, (outs GR32:$dst),
3158 (ins GR32:$src1, GR32:$src2),
3159 "sbb{l}\t{$src2, $dst|$dst, $src2}", []>;
Daniel Dunbardcbab9c2010-05-26 22:21:28 +00003160}
Sean Callanan108934c2009-12-18 00:01:26 +00003161
Dale Johannesenca11dae2009-05-18 17:44:15 +00003162def SBB8rm : I<0x1A, MRMSrcMem, (outs GR8:$dst), (ins GR8:$src1, i8mem:$src2),
3163 "sbb{b}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen874ae252009-06-02 03:12:52 +00003164 [(set GR8:$dst, (sube GR8:$src1, (load addr:$src2)))]>;
Dale Johannesenca11dae2009-05-18 17:44:15 +00003165def SBB16rm : I<0x1B, MRMSrcMem, (outs GR16:$dst),
3166 (ins GR16:$src1, i16mem:$src2),
3167 "sbb{w}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen874ae252009-06-02 03:12:52 +00003168 [(set GR16:$dst, (sube GR16:$src1, (load addr:$src2)))]>,
Dale Johannesen94c9cd12009-05-18 21:41:59 +00003169 OpSize;
Dale Johannesenca11dae2009-05-18 17:44:15 +00003170def SBB32rm : I<0x1B, MRMSrcMem, (outs GR32:$dst),
3171 (ins GR32:$src1, i32mem:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003172 "sbb{l}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen874ae252009-06-02 03:12:52 +00003173 [(set GR32:$dst, (sube GR32:$src1, (load addr:$src2)))]>;
Dale Johannesenca11dae2009-05-18 17:44:15 +00003174def SBB8ri : Ii8<0x80, MRM3r, (outs GR8:$dst), (ins GR8:$src1, i8imm:$src2),
3175 "sbb{b}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen874ae252009-06-02 03:12:52 +00003176 [(set GR8:$dst, (sube GR8:$src1, imm:$src2))]>;
Dale Johannesenca11dae2009-05-18 17:44:15 +00003177def SBB16ri : Ii16<0x81, MRM3r, (outs GR16:$dst),
3178 (ins GR16:$src1, i16imm:$src2),
3179 "sbb{w}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen874ae252009-06-02 03:12:52 +00003180 [(set GR16:$dst, (sube GR16:$src1, imm:$src2))]>, OpSize;
Dale Johannesenca11dae2009-05-18 17:44:15 +00003181def SBB16ri8 : Ii8<0x83, MRM3r, (outs GR16:$dst),
3182 (ins GR16:$src1, i16i8imm:$src2),
3183 "sbb{w}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen874ae252009-06-02 03:12:52 +00003184 [(set GR16:$dst, (sube GR16:$src1, i16immSExt8:$src2))]>,
3185 OpSize;
Dale Johannesenca11dae2009-05-18 17:44:15 +00003186def SBB32ri : Ii32<0x81, MRM3r, (outs GR32:$dst),
3187 (ins GR32:$src1, i32imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003188 "sbb{l}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen874ae252009-06-02 03:12:52 +00003189 [(set GR32:$dst, (sube GR32:$src1, imm:$src2))]>;
Dale Johannesenca11dae2009-05-18 17:44:15 +00003190def SBB32ri8 : Ii8<0x83, MRM3r, (outs GR32:$dst),
3191 (ins GR32:$src1, i32i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003192 "sbb{l}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen874ae252009-06-02 03:12:52 +00003193 [(set GR32:$dst, (sube GR32:$src1, i32immSExt8:$src2))]>;
Evan Cheng3154cb62007-10-05 17:59:57 +00003194} // Uses = [EFLAGS]
Evan Cheng24f2ea32007-09-14 21:48:26 +00003195} // Defs = [EFLAGS]
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00003196
Evan Cheng24f2ea32007-09-14 21:48:26 +00003197let Defs = [EFLAGS] in {
Chris Lattner10197ff2005-01-03 01:27:59 +00003198let isCommutable = 1 in { // X = IMUL Y, Z --> X = IMUL Z, Y
Bill Wendlingd350e022008-12-12 21:15:41 +00003199// Register-Register Signed Integer Multiply
Bill Wendlingab55ebd2008-12-12 00:56:36 +00003200def IMUL16rr : I<0xAF, MRMSrcReg, (outs GR16:$dst), (ins GR16:$src1,GR16:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003201 "imul{w}\t{$src2, $dst|$dst, $src2}",
Chris Lattnerec856802010-03-27 00:45:04 +00003202 [(set GR16:$dst, EFLAGS,
3203 (X86smul_flag GR16:$src1, GR16:$src2))]>, TB, OpSize;
Bill Wendlingab55ebd2008-12-12 00:56:36 +00003204def IMUL32rr : I<0xAF, MRMSrcReg, (outs GR32:$dst), (ins GR32:$src1,GR32:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003205 "imul{l}\t{$src2, $dst|$dst, $src2}",
Chris Lattnerec856802010-03-27 00:45:04 +00003206 [(set GR32:$dst, EFLAGS,
3207 (X86smul_flag GR32:$src1, GR32:$src2))]>, TB;
Chris Lattner10197ff2005-01-03 01:27:59 +00003208}
Bill Wendlingab55ebd2008-12-12 00:56:36 +00003209
Bill Wendlingd350e022008-12-12 21:15:41 +00003210// Register-Memory Signed Integer Multiply
Bill Wendlingab55ebd2008-12-12 00:56:36 +00003211def IMUL16rm : I<0xAF, MRMSrcMem, (outs GR16:$dst),
3212 (ins GR16:$src1, i16mem:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003213 "imul{w}\t{$src2, $dst|$dst, $src2}",
Chris Lattnerec856802010-03-27 00:45:04 +00003214 [(set GR16:$dst, EFLAGS,
3215 (X86smul_flag GR16:$src1, (load addr:$src2)))]>,
3216 TB, OpSize;
Sean Callanan108934c2009-12-18 00:01:26 +00003217def IMUL32rm : I<0xAF, MRMSrcMem, (outs GR32:$dst),
3218 (ins GR32:$src1, i32mem:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003219 "imul{l}\t{$src2, $dst|$dst, $src2}",
Chris Lattnerec856802010-03-27 00:45:04 +00003220 [(set GR32:$dst, EFLAGS,
3221 (X86smul_flag GR32:$src1, (load addr:$src2)))]>, TB;
Evan Cheng24f2ea32007-09-14 21:48:26 +00003222} // Defs = [EFLAGS]
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00003223} // end Two Address instructions
3224
Chris Lattnerf5d3a832004-08-11 05:31:07 +00003225// Suprisingly enough, these are not two address instructions!
Evan Cheng24f2ea32007-09-14 21:48:26 +00003226let Defs = [EFLAGS] in {
Bill Wendlingd350e022008-12-12 21:15:41 +00003227// Register-Integer Signed Integer Multiply
Evan Cheng069287d2006-05-16 07:21:53 +00003228def IMUL16rri : Ii16<0x69, MRMSrcReg, // GR16 = GR16*I16
Evan Cheng64d80e32007-07-19 01:14:50 +00003229 (outs GR16:$dst), (ins GR16:$src1, i16imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003230 "imul{w}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Chris Lattnerec856802010-03-27 00:45:04 +00003231 [(set GR16:$dst, EFLAGS,
3232 (X86smul_flag GR16:$src1, imm:$src2))]>, OpSize;
Evan Cheng069287d2006-05-16 07:21:53 +00003233def IMUL32rri : Ii32<0x69, MRMSrcReg, // GR32 = GR32*I32
Evan Cheng64d80e32007-07-19 01:14:50 +00003234 (outs GR32:$dst), (ins GR32:$src1, i32imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003235 "imul{l}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Chris Lattnerec856802010-03-27 00:45:04 +00003236 [(set GR32:$dst, EFLAGS,
3237 (X86smul_flag GR32:$src1, imm:$src2))]>;
Evan Cheng069287d2006-05-16 07:21:53 +00003238def IMUL16rri8 : Ii8<0x6B, MRMSrcReg, // GR16 = GR16*I8
Evan Cheng64d80e32007-07-19 01:14:50 +00003239 (outs GR16:$dst), (ins GR16:$src1, i16i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003240 "imul{w}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Chris Lattnerec856802010-03-27 00:45:04 +00003241 [(set GR16:$dst, EFLAGS,
3242 (X86smul_flag GR16:$src1, i16immSExt8:$src2))]>,
3243 OpSize;
Evan Cheng069287d2006-05-16 07:21:53 +00003244def IMUL32rri8 : Ii8<0x6B, MRMSrcReg, // GR32 = GR32*I8
Evan Cheng64d80e32007-07-19 01:14:50 +00003245 (outs GR32:$dst), (ins GR32:$src1, i32i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003246 "imul{l}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Chris Lattnerec856802010-03-27 00:45:04 +00003247 [(set GR32:$dst, EFLAGS,
3248 (X86smul_flag GR32:$src1, i32immSExt8:$src2))]>;
Chris Lattnerf5d3a832004-08-11 05:31:07 +00003249
Bill Wendlingd350e022008-12-12 21:15:41 +00003250// Memory-Integer Signed Integer Multiply
Sean Callanan108934c2009-12-18 00:01:26 +00003251def IMUL16rmi : Ii16<0x69, MRMSrcMem, // GR16 = [mem16]*I16
Evan Cheng64d80e32007-07-19 01:14:50 +00003252 (outs GR16:$dst), (ins i16mem:$src1, i16imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003253 "imul{w}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Chris Lattnerec856802010-03-27 00:45:04 +00003254 [(set GR16:$dst, EFLAGS,
3255 (X86smul_flag (load addr:$src1), imm:$src2))]>,
3256 OpSize;
Sean Callanan108934c2009-12-18 00:01:26 +00003257def IMUL32rmi : Ii32<0x69, MRMSrcMem, // GR32 = [mem32]*I32
Evan Cheng64d80e32007-07-19 01:14:50 +00003258 (outs GR32:$dst), (ins i32mem:$src1, i32imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003259 "imul{l}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Chris Lattnerec856802010-03-27 00:45:04 +00003260 [(set GR32:$dst, EFLAGS,
3261 (X86smul_flag (load addr:$src1), imm:$src2))]>;
Evan Cheng069287d2006-05-16 07:21:53 +00003262def IMUL16rmi8 : Ii8<0x6B, MRMSrcMem, // GR16 = [mem16]*I8
Evan Cheng64d80e32007-07-19 01:14:50 +00003263 (outs GR16:$dst), (ins i16mem:$src1, i16i8imm :$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003264 "imul{w}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Chris Lattnerec856802010-03-27 00:45:04 +00003265 [(set GR16:$dst, EFLAGS,
3266 (X86smul_flag (load addr:$src1),
3267 i16immSExt8:$src2))]>, OpSize;
Evan Cheng069287d2006-05-16 07:21:53 +00003268def IMUL32rmi8 : Ii8<0x6B, MRMSrcMem, // GR32 = [mem32]*I8
Evan Cheng64d80e32007-07-19 01:14:50 +00003269 (outs GR32:$dst), (ins i32mem:$src1, i32i8imm: $src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003270 "imul{l}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Chris Lattnerec856802010-03-27 00:45:04 +00003271 [(set GR32:$dst, EFLAGS,
3272 (X86smul_flag (load addr:$src1),
3273 i32immSExt8:$src2))]>;
Evan Cheng24f2ea32007-09-14 21:48:26 +00003274} // Defs = [EFLAGS]
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00003275
3276//===----------------------------------------------------------------------===//
3277// Test instructions are just like AND, except they don't generate a result.
Chris Lattner3a173df2004-10-03 20:35:00 +00003278//
Evan Cheng0488db92007-09-25 01:57:46 +00003279let Defs = [EFLAGS] in {
Chris Lattnercc65bee2005-01-02 02:35:46 +00003280let isCommutable = 1 in { // TEST X, Y --> TEST Y, X
Daniel Dunbarb93c72c2010-03-08 21:10:36 +00003281def TEST8rr : I<0x84, MRMSrcReg, (outs), (ins GR8:$src1, GR8:$src2),
Evan Chenge5f62042007-09-29 00:00:36 +00003282 "test{b}\t{$src2, $src1|$src1, $src2}",
Chris Lattnere3486a42010-03-19 00:01:11 +00003283 [(set EFLAGS, (X86cmp (and_su GR8:$src1, GR8:$src2), 0))]>;
Daniel Dunbarb93c72c2010-03-08 21:10:36 +00003284def TEST16rr : I<0x85, MRMSrcReg, (outs), (ins GR16:$src1, GR16:$src2),
Evan Chenge5f62042007-09-29 00:00:36 +00003285 "test{w}\t{$src2, $src1|$src1, $src2}",
Chris Lattnere3486a42010-03-19 00:01:11 +00003286 [(set EFLAGS, (X86cmp (and_su GR16:$src1, GR16:$src2),
3287 0))]>,
Evan Chenge5f62042007-09-29 00:00:36 +00003288 OpSize;
Daniel Dunbarb93c72c2010-03-08 21:10:36 +00003289def TEST32rr : I<0x85, MRMSrcReg, (outs), (ins GR32:$src1, GR32:$src2),
Evan Chenge5f62042007-09-29 00:00:36 +00003290 "test{l}\t{$src2, $src1|$src1, $src2}",
Chris Lattnere3486a42010-03-19 00:01:11 +00003291 [(set EFLAGS, (X86cmp (and_su GR32:$src1, GR32:$src2),
3292 0))]>;
Chris Lattnercc65bee2005-01-02 02:35:46 +00003293}
Evan Cheng734503b2006-09-11 02:19:56 +00003294
Sean Callanan4a93b712009-09-01 18:14:18 +00003295def TEST8i8 : Ii8<0xA8, RawFrm, (outs), (ins i8imm:$src),
3296 "test{b}\t{$src, %al|%al, $src}", []>;
3297def TEST16i16 : Ii16<0xA9, RawFrm, (outs), (ins i16imm:$src),
3298 "test{w}\t{$src, %ax|%ax, $src}", []>, OpSize;
3299def TEST32i32 : Ii32<0xA9, RawFrm, (outs), (ins i32imm:$src),
3300 "test{l}\t{$src, %eax|%eax, $src}", []>;
3301
Evan Cheng64d80e32007-07-19 01:14:50 +00003302def TEST8rm : I<0x84, MRMSrcMem, (outs), (ins GR8 :$src1, i8mem :$src2),
Evan Chenge5f62042007-09-29 00:00:36 +00003303 "test{b}\t{$src2, $src1|$src1, $src2}",
Chris Lattnere3486a42010-03-19 00:01:11 +00003304 [(set EFLAGS, (X86cmp (and GR8:$src1, (loadi8 addr:$src2)),
3305 0))]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00003306def TEST16rm : I<0x85, MRMSrcMem, (outs), (ins GR16:$src1, i16mem:$src2),
Evan Chenge5f62042007-09-29 00:00:36 +00003307 "test{w}\t{$src2, $src1|$src1, $src2}",
Chris Lattnere3486a42010-03-19 00:01:11 +00003308 [(set EFLAGS, (X86cmp (and GR16:$src1,
3309 (loadi16 addr:$src2)), 0))]>, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00003310def TEST32rm : I<0x85, MRMSrcMem, (outs), (ins GR32:$src1, i32mem:$src2),
Evan Chenge5f62042007-09-29 00:00:36 +00003311 "test{l}\t{$src2, $src1|$src1, $src2}",
Chris Lattnere3486a42010-03-19 00:01:11 +00003312 [(set EFLAGS, (X86cmp (and GR32:$src1,
3313 (loadi32 addr:$src2)), 0))]>;
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00003314
Evan Cheng069287d2006-05-16 07:21:53 +00003315def TEST8ri : Ii8 <0xF6, MRM0r, // flags = GR8 & imm8
Evan Cheng64d80e32007-07-19 01:14:50 +00003316 (outs), (ins GR8:$src1, i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003317 "test{b}\t{$src2, $src1|$src1, $src2}",
Chris Lattnere3486a42010-03-19 00:01:11 +00003318 [(set EFLAGS, (X86cmp (and_su GR8:$src1, imm:$src2), 0))]>;
Evan Cheng069287d2006-05-16 07:21:53 +00003319def TEST16ri : Ii16<0xF7, MRM0r, // flags = GR16 & imm16
Evan Cheng64d80e32007-07-19 01:14:50 +00003320 (outs), (ins GR16:$src1, i16imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003321 "test{w}\t{$src2, $src1|$src1, $src2}",
Chris Lattnere3486a42010-03-19 00:01:11 +00003322 [(set EFLAGS, (X86cmp (and_su GR16:$src1, imm:$src2), 0))]>,
3323 OpSize;
Evan Cheng069287d2006-05-16 07:21:53 +00003324def TEST32ri : Ii32<0xF7, MRM0r, // flags = GR32 & imm32
Evan Cheng64d80e32007-07-19 01:14:50 +00003325 (outs), (ins GR32:$src1, i32imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003326 "test{l}\t{$src2, $src1|$src1, $src2}",
Chris Lattnere3486a42010-03-19 00:01:11 +00003327 [(set EFLAGS, (X86cmp (and_su GR32:$src1, imm:$src2), 0))]>;
Evan Cheng734503b2006-09-11 02:19:56 +00003328
Evan Chenge5f62042007-09-29 00:00:36 +00003329def TEST8mi : Ii8 <0xF6, MRM0m, // flags = [mem8] & imm8
Evan Cheng64d80e32007-07-19 01:14:50 +00003330 (outs), (ins i8mem:$src1, i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003331 "test{b}\t{$src2, $src1|$src1, $src2}",
Chris Lattnere3486a42010-03-19 00:01:11 +00003332 [(set EFLAGS, (X86cmp (and (loadi8 addr:$src1), imm:$src2),
3333 0))]>;
Evan Chenge5f62042007-09-29 00:00:36 +00003334def TEST16mi : Ii16<0xF7, MRM0m, // flags = [mem16] & imm16
Evan Cheng64d80e32007-07-19 01:14:50 +00003335 (outs), (ins i16mem:$src1, i16imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003336 "test{w}\t{$src2, $src1|$src1, $src2}",
Chris Lattnere3486a42010-03-19 00:01:11 +00003337 [(set EFLAGS, (X86cmp (and (loadi16 addr:$src1), imm:$src2),
3338 0))]>, OpSize;
Evan Chenge5f62042007-09-29 00:00:36 +00003339def TEST32mi : Ii32<0xF7, MRM0m, // flags = [mem32] & imm32
Evan Cheng64d80e32007-07-19 01:14:50 +00003340 (outs), (ins i32mem:$src1, i32imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003341 "test{l}\t{$src2, $src1|$src1, $src2}",
Chris Lattnere3486a42010-03-19 00:01:11 +00003342 [(set EFLAGS, (X86cmp (and (loadi32 addr:$src1), imm:$src2),
3343 0))]>;
Evan Cheng0488db92007-09-25 01:57:46 +00003344} // Defs = [EFLAGS]
3345
3346
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00003347// Condition code ops, incl. set if equal/not equal/...
Chris Lattnerba7e7562008-01-10 07:59:24 +00003348let Defs = [EFLAGS], Uses = [AH], neverHasSideEffects = 1 in
Evan Cheng071a2792007-09-11 19:55:27 +00003349def SAHF : I<0x9E, RawFrm, (outs), (ins), "sahf", []>; // flags = AH
Chris Lattnerba7e7562008-01-10 07:59:24 +00003350let Defs = [AH], Uses = [EFLAGS], neverHasSideEffects = 1 in
Evan Cheng071a2792007-09-11 19:55:27 +00003351def LAHF : I<0x9F, RawFrm, (outs), (ins), "lahf", []>; // AH = flags
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00003352
Evan Cheng0488db92007-09-25 01:57:46 +00003353let Uses = [EFLAGS] in {
Evan Chengad9c0a32009-12-15 00:53:42 +00003354// Use sbb to materialize carry bit.
Evan Chengad9c0a32009-12-15 00:53:42 +00003355let Defs = [EFLAGS], isCodeGenOnly = 1 in {
Chris Lattnerc74e3332010-02-05 21:13:48 +00003356// FIXME: These are pseudo ops that should be replaced with Pat<> patterns.
3357// However, Pat<> can't replicate the destination reg into the inputs of the
3358// result.
3359// FIXME: Change these to have encoding Pseudo when X86MCCodeEmitter replaces
3360// X86CodeEmitter.
3361def SETB_C8r : I<0x18, MRMInitReg, (outs GR8:$dst), (ins), "",
Evan Chengad9c0a32009-12-15 00:53:42 +00003362 [(set GR8:$dst, (X86setcc_c X86_COND_B, EFLAGS))]>;
Chris Lattnerc74e3332010-02-05 21:13:48 +00003363def SETB_C16r : I<0x19, MRMInitReg, (outs GR16:$dst), (ins), "",
Evan Cheng2e489c42009-12-16 00:53:11 +00003364 [(set GR16:$dst, (X86setcc_c X86_COND_B, EFLAGS))]>,
Evan Chengad9c0a32009-12-15 00:53:42 +00003365 OpSize;
Chris Lattnerc74e3332010-02-05 21:13:48 +00003366def SETB_C32r : I<0x19, MRMInitReg, (outs GR32:$dst), (ins), "",
Evan Cheng2e489c42009-12-16 00:53:11 +00003367 [(set GR32:$dst, (X86setcc_c X86_COND_B, EFLAGS))]>;
Evan Chengad9c0a32009-12-15 00:53:42 +00003368} // isCodeGenOnly
3369
Chris Lattner3a173df2004-10-03 20:35:00 +00003370def SETEr : I<0x94, MRM0r,
Evan Cheng64d80e32007-07-19 01:14:50 +00003371 (outs GR8 :$dst), (ins),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003372 "sete\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +00003373 [(set GR8:$dst, (X86setcc X86_COND_E, EFLAGS))]>,
Evan Cheng069287d2006-05-16 07:21:53 +00003374 TB; // GR8 = ==
Chris Lattner3a173df2004-10-03 20:35:00 +00003375def SETEm : I<0x94, MRM0m,
Evan Cheng64d80e32007-07-19 01:14:50 +00003376 (outs), (ins i8mem:$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003377 "sete\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +00003378 [(store (X86setcc X86_COND_E, EFLAGS), addr:$dst)]>,
Evan Chengd5781fc2005-12-21 20:21:51 +00003379 TB; // [mem8] = ==
Bill Wendling9f248742008-12-02 00:07:05 +00003380
Chris Lattner3a173df2004-10-03 20:35:00 +00003381def SETNEr : I<0x95, MRM0r,
Evan Cheng64d80e32007-07-19 01:14:50 +00003382 (outs GR8 :$dst), (ins),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003383 "setne\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +00003384 [(set GR8:$dst, (X86setcc X86_COND_NE, EFLAGS))]>,
Evan Cheng069287d2006-05-16 07:21:53 +00003385 TB; // GR8 = !=
Chris Lattner3a173df2004-10-03 20:35:00 +00003386def SETNEm : I<0x95, MRM0m,
Evan Cheng64d80e32007-07-19 01:14:50 +00003387 (outs), (ins i8mem:$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003388 "setne\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +00003389 [(store (X86setcc X86_COND_NE, EFLAGS), addr:$dst)]>,
Evan Chengd5781fc2005-12-21 20:21:51 +00003390 TB; // [mem8] = !=
Bill Wendling9f248742008-12-02 00:07:05 +00003391
Evan Chengd5781fc2005-12-21 20:21:51 +00003392def SETLr : I<0x9C, MRM0r,
Evan Cheng64d80e32007-07-19 01:14:50 +00003393 (outs GR8 :$dst), (ins),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003394 "setl\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +00003395 [(set GR8:$dst, (X86setcc X86_COND_L, EFLAGS))]>,
Evan Cheng069287d2006-05-16 07:21:53 +00003396 TB; // GR8 = < signed
Evan Chengd5781fc2005-12-21 20:21:51 +00003397def SETLm : I<0x9C, MRM0m,
Evan Cheng64d80e32007-07-19 01:14:50 +00003398 (outs), (ins i8mem:$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003399 "setl\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +00003400 [(store (X86setcc X86_COND_L, EFLAGS), addr:$dst)]>,
Evan Chengd5781fc2005-12-21 20:21:51 +00003401 TB; // [mem8] = < signed
Bill Wendling9f248742008-12-02 00:07:05 +00003402
Evan Chengd5781fc2005-12-21 20:21:51 +00003403def SETGEr : I<0x9D, MRM0r,
Evan Cheng64d80e32007-07-19 01:14:50 +00003404 (outs GR8 :$dst), (ins),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003405 "setge\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +00003406 [(set GR8:$dst, (X86setcc X86_COND_GE, EFLAGS))]>,
Evan Cheng069287d2006-05-16 07:21:53 +00003407 TB; // GR8 = >= signed
Evan Chengd5781fc2005-12-21 20:21:51 +00003408def SETGEm : I<0x9D, MRM0m,
Evan Cheng64d80e32007-07-19 01:14:50 +00003409 (outs), (ins i8mem:$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003410 "setge\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +00003411 [(store (X86setcc X86_COND_GE, EFLAGS), addr:$dst)]>,
Evan Chengd5781fc2005-12-21 20:21:51 +00003412 TB; // [mem8] = >= signed
Bill Wendling9f248742008-12-02 00:07:05 +00003413
Evan Chengd5781fc2005-12-21 20:21:51 +00003414def SETLEr : I<0x9E, MRM0r,
Evan Cheng64d80e32007-07-19 01:14:50 +00003415 (outs GR8 :$dst), (ins),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003416 "setle\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +00003417 [(set GR8:$dst, (X86setcc X86_COND_LE, EFLAGS))]>,
Evan Cheng069287d2006-05-16 07:21:53 +00003418 TB; // GR8 = <= signed
Evan Chengd5781fc2005-12-21 20:21:51 +00003419def SETLEm : I<0x9E, MRM0m,
Evan Cheng64d80e32007-07-19 01:14:50 +00003420 (outs), (ins i8mem:$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003421 "setle\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +00003422 [(store (X86setcc X86_COND_LE, EFLAGS), addr:$dst)]>,
Evan Chengd5781fc2005-12-21 20:21:51 +00003423 TB; // [mem8] = <= signed
Bill Wendling9f248742008-12-02 00:07:05 +00003424
Evan Chengd5781fc2005-12-21 20:21:51 +00003425def SETGr : I<0x9F, MRM0r,
Evan Cheng64d80e32007-07-19 01:14:50 +00003426 (outs GR8 :$dst), (ins),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003427 "setg\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +00003428 [(set GR8:$dst, (X86setcc X86_COND_G, EFLAGS))]>,
Evan Cheng069287d2006-05-16 07:21:53 +00003429 TB; // GR8 = > signed
Evan Chengd5781fc2005-12-21 20:21:51 +00003430def SETGm : I<0x9F, MRM0m,
Evan Cheng64d80e32007-07-19 01:14:50 +00003431 (outs), (ins i8mem:$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003432 "setg\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +00003433 [(store (X86setcc X86_COND_G, EFLAGS), addr:$dst)]>,
Evan Chengd5781fc2005-12-21 20:21:51 +00003434 TB; // [mem8] = > signed
3435
3436def SETBr : I<0x92, MRM0r,
Evan Cheng64d80e32007-07-19 01:14:50 +00003437 (outs GR8 :$dst), (ins),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003438 "setb\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +00003439 [(set GR8:$dst, (X86setcc X86_COND_B, EFLAGS))]>,
Evan Cheng069287d2006-05-16 07:21:53 +00003440 TB; // GR8 = < unsign
Evan Chengd5781fc2005-12-21 20:21:51 +00003441def SETBm : I<0x92, MRM0m,
Evan Cheng64d80e32007-07-19 01:14:50 +00003442 (outs), (ins i8mem:$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003443 "setb\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +00003444 [(store (X86setcc X86_COND_B, EFLAGS), addr:$dst)]>,
Evan Chengd5781fc2005-12-21 20:21:51 +00003445 TB; // [mem8] = < unsign
Bill Wendling9f248742008-12-02 00:07:05 +00003446
Evan Chengd5781fc2005-12-21 20:21:51 +00003447def SETAEr : I<0x93, MRM0r,
Evan Cheng64d80e32007-07-19 01:14:50 +00003448 (outs GR8 :$dst), (ins),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003449 "setae\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +00003450 [(set GR8:$dst, (X86setcc X86_COND_AE, EFLAGS))]>,
Evan Cheng069287d2006-05-16 07:21:53 +00003451 TB; // GR8 = >= unsign
Evan Chengd5781fc2005-12-21 20:21:51 +00003452def SETAEm : I<0x93, MRM0m,
Evan Cheng64d80e32007-07-19 01:14:50 +00003453 (outs), (ins i8mem:$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003454 "setae\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +00003455 [(store (X86setcc X86_COND_AE, EFLAGS), addr:$dst)]>,
Evan Chengd5781fc2005-12-21 20:21:51 +00003456 TB; // [mem8] = >= unsign
Bill Wendling9f248742008-12-02 00:07:05 +00003457
Chris Lattner3a173df2004-10-03 20:35:00 +00003458def SETBEr : I<0x96, MRM0r,
Evan Cheng64d80e32007-07-19 01:14:50 +00003459 (outs GR8 :$dst), (ins),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003460 "setbe\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +00003461 [(set GR8:$dst, (X86setcc X86_COND_BE, EFLAGS))]>,
Evan Cheng069287d2006-05-16 07:21:53 +00003462 TB; // GR8 = <= unsign
Chris Lattner3a173df2004-10-03 20:35:00 +00003463def SETBEm : I<0x96, MRM0m,
Evan Cheng64d80e32007-07-19 01:14:50 +00003464 (outs), (ins i8mem:$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003465 "setbe\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +00003466 [(store (X86setcc X86_COND_BE, EFLAGS), addr:$dst)]>,
Evan Chengd5781fc2005-12-21 20:21:51 +00003467 TB; // [mem8] = <= unsign
Bill Wendling9f248742008-12-02 00:07:05 +00003468
Chris Lattner3a173df2004-10-03 20:35:00 +00003469def SETAr : I<0x97, MRM0r,
Evan Cheng64d80e32007-07-19 01:14:50 +00003470 (outs GR8 :$dst), (ins),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003471 "seta\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +00003472 [(set GR8:$dst, (X86setcc X86_COND_A, EFLAGS))]>,
Evan Cheng069287d2006-05-16 07:21:53 +00003473 TB; // GR8 = > signed
Chris Lattner3a173df2004-10-03 20:35:00 +00003474def SETAm : I<0x97, MRM0m,
Evan Cheng64d80e32007-07-19 01:14:50 +00003475 (outs), (ins i8mem:$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003476 "seta\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +00003477 [(store (X86setcc X86_COND_A, EFLAGS), addr:$dst)]>,
Evan Chengd5781fc2005-12-21 20:21:51 +00003478 TB; // [mem8] = > signed
Evan Chengd9558e02006-01-06 00:43:03 +00003479
Chris Lattner3a173df2004-10-03 20:35:00 +00003480def SETSr : I<0x98, MRM0r,
Evan Cheng64d80e32007-07-19 01:14:50 +00003481 (outs GR8 :$dst), (ins),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003482 "sets\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +00003483 [(set GR8:$dst, (X86setcc X86_COND_S, EFLAGS))]>,
Evan Cheng069287d2006-05-16 07:21:53 +00003484 TB; // GR8 = <sign bit>
Chris Lattner3a173df2004-10-03 20:35:00 +00003485def SETSm : I<0x98, MRM0m,
Evan Cheng64d80e32007-07-19 01:14:50 +00003486 (outs), (ins i8mem:$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003487 "sets\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +00003488 [(store (X86setcc X86_COND_S, EFLAGS), addr:$dst)]>,
Evan Chengd9558e02006-01-06 00:43:03 +00003489 TB; // [mem8] = <sign bit>
Chris Lattner3a173df2004-10-03 20:35:00 +00003490def SETNSr : I<0x99, MRM0r,
Evan Cheng64d80e32007-07-19 01:14:50 +00003491 (outs GR8 :$dst), (ins),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003492 "setns\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +00003493 [(set GR8:$dst, (X86setcc X86_COND_NS, EFLAGS))]>,
Evan Cheng069287d2006-05-16 07:21:53 +00003494 TB; // GR8 = !<sign bit>
Chris Lattner3a173df2004-10-03 20:35:00 +00003495def SETNSm : I<0x99, MRM0m,
Evan Cheng64d80e32007-07-19 01:14:50 +00003496 (outs), (ins i8mem:$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003497 "setns\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +00003498 [(store (X86setcc X86_COND_NS, EFLAGS), addr:$dst)]>,
Evan Chengd9558e02006-01-06 00:43:03 +00003499 TB; // [mem8] = !<sign bit>
Bill Wendling9f248742008-12-02 00:07:05 +00003500
Chris Lattner3a173df2004-10-03 20:35:00 +00003501def SETPr : I<0x9A, MRM0r,
Evan Cheng64d80e32007-07-19 01:14:50 +00003502 (outs GR8 :$dst), (ins),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003503 "setp\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +00003504 [(set GR8:$dst, (X86setcc X86_COND_P, EFLAGS))]>,
Evan Cheng069287d2006-05-16 07:21:53 +00003505 TB; // GR8 = parity
Chris Lattner3a173df2004-10-03 20:35:00 +00003506def SETPm : I<0x9A, MRM0m,
Evan Cheng64d80e32007-07-19 01:14:50 +00003507 (outs), (ins i8mem:$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003508 "setp\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +00003509 [(store (X86setcc X86_COND_P, EFLAGS), addr:$dst)]>,
Evan Chengd9558e02006-01-06 00:43:03 +00003510 TB; // [mem8] = parity
Chris Lattnercc65bee2005-01-02 02:35:46 +00003511def SETNPr : I<0x9B, MRM0r,
Evan Cheng64d80e32007-07-19 01:14:50 +00003512 (outs GR8 :$dst), (ins),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003513 "setnp\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +00003514 [(set GR8:$dst, (X86setcc X86_COND_NP, EFLAGS))]>,
Evan Cheng069287d2006-05-16 07:21:53 +00003515 TB; // GR8 = not parity
Chris Lattnercc65bee2005-01-02 02:35:46 +00003516def SETNPm : I<0x9B, MRM0m,
Evan Cheng64d80e32007-07-19 01:14:50 +00003517 (outs), (ins i8mem:$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003518 "setnp\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +00003519 [(store (X86setcc X86_COND_NP, EFLAGS), addr:$dst)]>,
Evan Chengd9558e02006-01-06 00:43:03 +00003520 TB; // [mem8] = not parity
Bill Wendling9f248742008-12-02 00:07:05 +00003521
3522def SETOr : I<0x90, MRM0r,
3523 (outs GR8 :$dst), (ins),
3524 "seto\t$dst",
3525 [(set GR8:$dst, (X86setcc X86_COND_O, EFLAGS))]>,
3526 TB; // GR8 = overflow
3527def SETOm : I<0x90, MRM0m,
3528 (outs), (ins i8mem:$dst),
3529 "seto\t$dst",
3530 [(store (X86setcc X86_COND_O, EFLAGS), addr:$dst)]>,
3531 TB; // [mem8] = overflow
3532def SETNOr : I<0x91, MRM0r,
3533 (outs GR8 :$dst), (ins),
3534 "setno\t$dst",
3535 [(set GR8:$dst, (X86setcc X86_COND_NO, EFLAGS))]>,
3536 TB; // GR8 = not overflow
3537def SETNOm : I<0x91, MRM0m,
3538 (outs), (ins i8mem:$dst),
3539 "setno\t$dst",
3540 [(store (X86setcc X86_COND_NO, EFLAGS), addr:$dst)]>,
3541 TB; // [mem8] = not overflow
Evan Cheng0488db92007-09-25 01:57:46 +00003542} // Uses = [EFLAGS]
3543
Chris Lattner1cca5e32003-08-03 21:54:21 +00003544
3545// Integer comparisons
Evan Cheng24f2ea32007-09-14 21:48:26 +00003546let Defs = [EFLAGS] in {
Sean Callanana09caa52009-09-02 00:55:49 +00003547def CMP8i8 : Ii8<0x3C, RawFrm, (outs), (ins i8imm:$src),
3548 "cmp{b}\t{$src, %al|%al, $src}", []>;
3549def CMP16i16 : Ii16<0x3D, RawFrm, (outs), (ins i16imm:$src),
3550 "cmp{w}\t{$src, %ax|%ax, $src}", []>, OpSize;
3551def CMP32i32 : Ii32<0x3D, RawFrm, (outs), (ins i32imm:$src),
3552 "cmp{l}\t{$src, %eax|%eax, $src}", []>;
3553
Chris Lattner3a173df2004-10-03 20:35:00 +00003554def CMP8rr : I<0x38, MRMDestReg,
Evan Cheng64d80e32007-07-19 01:14:50 +00003555 (outs), (ins GR8 :$src1, GR8 :$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003556 "cmp{b}\t{$src2, $src1|$src1, $src2}",
Chris Lattnere3486a42010-03-19 00:01:11 +00003557 [(set EFLAGS, (X86cmp GR8:$src1, GR8:$src2))]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00003558def CMP16rr : I<0x39, MRMDestReg,
Evan Cheng64d80e32007-07-19 01:14:50 +00003559 (outs), (ins GR16:$src1, GR16:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003560 "cmp{w}\t{$src2, $src1|$src1, $src2}",
Chris Lattnere3486a42010-03-19 00:01:11 +00003561 [(set EFLAGS, (X86cmp GR16:$src1, GR16:$src2))]>, OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00003562def CMP32rr : I<0x39, MRMDestReg,
Evan Cheng64d80e32007-07-19 01:14:50 +00003563 (outs), (ins GR32:$src1, GR32:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003564 "cmp{l}\t{$src2, $src1|$src1, $src2}",
Chris Lattnere3486a42010-03-19 00:01:11 +00003565 [(set EFLAGS, (X86cmp GR32:$src1, GR32:$src2))]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00003566def CMP8mr : I<0x38, MRMDestMem,
Evan Cheng64d80e32007-07-19 01:14:50 +00003567 (outs), (ins i8mem :$src1, GR8 :$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003568 "cmp{b}\t{$src2, $src1|$src1, $src2}",
Chris Lattnere3486a42010-03-19 00:01:11 +00003569 [(set EFLAGS, (X86cmp (loadi8 addr:$src1), GR8:$src2))]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00003570def CMP16mr : I<0x39, MRMDestMem,
Evan Cheng64d80e32007-07-19 01:14:50 +00003571 (outs), (ins i16mem:$src1, GR16:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003572 "cmp{w}\t{$src2, $src1|$src1, $src2}",
Chris Lattnere3486a42010-03-19 00:01:11 +00003573 [(set EFLAGS, (X86cmp (loadi16 addr:$src1), GR16:$src2))]>,
3574 OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00003575def CMP32mr : I<0x39, MRMDestMem,
Evan Cheng64d80e32007-07-19 01:14:50 +00003576 (outs), (ins i32mem:$src1, GR32:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003577 "cmp{l}\t{$src2, $src1|$src1, $src2}",
Chris Lattnere3486a42010-03-19 00:01:11 +00003578 [(set EFLAGS, (X86cmp (loadi32 addr:$src1), GR32:$src2))]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00003579def CMP8rm : I<0x3A, MRMSrcMem,
Evan Cheng64d80e32007-07-19 01:14:50 +00003580 (outs), (ins GR8 :$src1, i8mem :$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003581 "cmp{b}\t{$src2, $src1|$src1, $src2}",
Chris Lattnere3486a42010-03-19 00:01:11 +00003582 [(set EFLAGS, (X86cmp GR8:$src1, (loadi8 addr:$src2)))]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00003583def CMP16rm : I<0x3B, MRMSrcMem,
Evan Cheng64d80e32007-07-19 01:14:50 +00003584 (outs), (ins GR16:$src1, i16mem:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003585 "cmp{w}\t{$src2, $src1|$src1, $src2}",
Chris Lattnere3486a42010-03-19 00:01:11 +00003586 [(set EFLAGS, (X86cmp GR16:$src1, (loadi16 addr:$src2)))]>,
3587 OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00003588def CMP32rm : I<0x3B, MRMSrcMem,
Evan Cheng64d80e32007-07-19 01:14:50 +00003589 (outs), (ins GR32:$src1, i32mem:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003590 "cmp{l}\t{$src2, $src1|$src1, $src2}",
Chris Lattnere3486a42010-03-19 00:01:11 +00003591 [(set EFLAGS, (X86cmp GR32:$src1, (loadi32 addr:$src2)))]>;
Daniel Dunbar1e8ee892010-03-09 22:50:40 +00003592
3593// These are alternate spellings for use by the disassembler, we mark them as
3594// code gen only to ensure they aren't matched by the assembler.
3595let isCodeGenOnly = 1 in {
3596 def CMP8rr_alt : I<0x3A, MRMSrcReg, (outs), (ins GR8:$src1, GR8:$src2),
3597 "cmp{b}\t{$src2, $src1|$src1, $src2}", []>;
3598 def CMP16rr_alt : I<0x3B, MRMSrcReg, (outs), (ins GR16:$src1, GR16:$src2),
3599 "cmp{w}\t{$src2, $src1|$src1, $src2}", []>, OpSize;
3600 def CMP32rr_alt : I<0x3B, MRMSrcReg, (outs), (ins GR32:$src1, GR32:$src2),
3601 "cmp{l}\t{$src2, $src1|$src1, $src2}", []>;
3602}
3603
Chris Lattner3a173df2004-10-03 20:35:00 +00003604def CMP8ri : Ii8<0x80, MRM7r,
Evan Cheng64d80e32007-07-19 01:14:50 +00003605 (outs), (ins GR8:$src1, i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003606 "cmp{b}\t{$src2, $src1|$src1, $src2}",
Chris Lattnere3486a42010-03-19 00:01:11 +00003607 [(set EFLAGS, (X86cmp GR8:$src1, imm:$src2))]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00003608def CMP16ri : Ii16<0x81, MRM7r,
Evan Cheng64d80e32007-07-19 01:14:50 +00003609 (outs), (ins GR16:$src1, i16imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003610 "cmp{w}\t{$src2, $src1|$src1, $src2}",
Chris Lattnere3486a42010-03-19 00:01:11 +00003611 [(set EFLAGS, (X86cmp GR16:$src1, imm:$src2))]>, OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00003612def CMP32ri : Ii32<0x81, MRM7r,
Evan Cheng64d80e32007-07-19 01:14:50 +00003613 (outs), (ins GR32:$src1, i32imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003614 "cmp{l}\t{$src2, $src1|$src1, $src2}",
Chris Lattnere3486a42010-03-19 00:01:11 +00003615 [(set EFLAGS, (X86cmp GR32:$src1, imm:$src2))]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00003616def CMP8mi : Ii8 <0x80, MRM7m,
Evan Cheng64d80e32007-07-19 01:14:50 +00003617 (outs), (ins i8mem :$src1, i8imm :$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003618 "cmp{b}\t{$src2, $src1|$src1, $src2}",
Chris Lattnere3486a42010-03-19 00:01:11 +00003619 [(set EFLAGS, (X86cmp (loadi8 addr:$src1), imm:$src2))]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00003620def CMP16mi : Ii16<0x81, MRM7m,
Evan Cheng64d80e32007-07-19 01:14:50 +00003621 (outs), (ins i16mem:$src1, i16imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003622 "cmp{w}\t{$src2, $src1|$src1, $src2}",
Chris Lattnere3486a42010-03-19 00:01:11 +00003623 [(set EFLAGS, (X86cmp (loadi16 addr:$src1), imm:$src2))]>,
3624 OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00003625def CMP32mi : Ii32<0x81, MRM7m,
Evan Cheng64d80e32007-07-19 01:14:50 +00003626 (outs), (ins i32mem:$src1, i32imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003627 "cmp{l}\t{$src2, $src1|$src1, $src2}",
Chris Lattnere3486a42010-03-19 00:01:11 +00003628 [(set EFLAGS, (X86cmp (loadi32 addr:$src1), imm:$src2))]>;
Chris Lattner29b4dd02006-03-23 16:13:50 +00003629def CMP16ri8 : Ii8<0x83, MRM7r,
Evan Cheng64d80e32007-07-19 01:14:50 +00003630 (outs), (ins GR16:$src1, i16i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003631 "cmp{w}\t{$src2, $src1|$src1, $src2}",
Chris Lattnere3486a42010-03-19 00:01:11 +00003632 [(set EFLAGS, (X86cmp GR16:$src1, i16immSExt8:$src2))]>,
3633 OpSize;
Chris Lattner29b4dd02006-03-23 16:13:50 +00003634def CMP16mi8 : Ii8<0x83, MRM7m,
Evan Cheng64d80e32007-07-19 01:14:50 +00003635 (outs), (ins i16mem:$src1, i16i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003636 "cmp{w}\t{$src2, $src1|$src1, $src2}",
Chris Lattnere3486a42010-03-19 00:01:11 +00003637 [(set EFLAGS, (X86cmp (loadi16 addr:$src1),
3638 i16immSExt8:$src2))]>, OpSize;
Chris Lattner29b4dd02006-03-23 16:13:50 +00003639def CMP32mi8 : Ii8<0x83, MRM7m,
Evan Cheng64d80e32007-07-19 01:14:50 +00003640 (outs), (ins i32mem:$src1, i32i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003641 "cmp{l}\t{$src2, $src1|$src1, $src2}",
Chris Lattnere3486a42010-03-19 00:01:11 +00003642 [(set EFLAGS, (X86cmp (loadi32 addr:$src1),
3643 i32immSExt8:$src2))]>;
Chris Lattner29b4dd02006-03-23 16:13:50 +00003644def CMP32ri8 : Ii8<0x83, MRM7r,
Evan Cheng64d80e32007-07-19 01:14:50 +00003645 (outs), (ins GR32:$src1, i32i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003646 "cmp{l}\t{$src2, $src1|$src1, $src2}",
Chris Lattnere3486a42010-03-19 00:01:11 +00003647 [(set EFLAGS, (X86cmp GR32:$src1, i32immSExt8:$src2))]>;
Evan Cheng0488db92007-09-25 01:57:46 +00003648} // Defs = [EFLAGS]
3649
Dan Gohmanc7a37d42008-12-23 22:45:23 +00003650// Bit tests.
Dan Gohmanc7a37d42008-12-23 22:45:23 +00003651// TODO: BTC, BTR, and BTS
3652let Defs = [EFLAGS] in {
Dan Gohman0c89b7e2009-01-13 20:32:45 +00003653def BT16rr : I<0xA3, MRMDestReg, (outs), (ins GR16:$src1, GR16:$src2),
Dan Gohmanc7a37d42008-12-23 22:45:23 +00003654 "bt{w}\t{$src2, $src1|$src1, $src2}",
Chris Lattnere3486a42010-03-19 00:01:11 +00003655 [(set EFLAGS, (X86bt GR16:$src1, GR16:$src2))]>, OpSize, TB;
Dan Gohman0c89b7e2009-01-13 20:32:45 +00003656def BT32rr : I<0xA3, MRMDestReg, (outs), (ins GR32:$src1, GR32:$src2),
Dan Gohmanc7a37d42008-12-23 22:45:23 +00003657 "bt{l}\t{$src2, $src1|$src1, $src2}",
Chris Lattnere3486a42010-03-19 00:01:11 +00003658 [(set EFLAGS, (X86bt GR32:$src1, GR32:$src2))]>, TB;
Dan Gohmanf31408d2009-01-13 23:23:30 +00003659
3660// Unlike with the register+register form, the memory+register form of the
3661// bt instruction does not ignore the high bits of the index. From ISel's
Sean Callanan108934c2009-12-18 00:01:26 +00003662// perspective, this is pretty bizarre. Make these instructions disassembly
3663// only for now.
3664
3665def BT16mr : I<0xA3, MRMDestMem, (outs), (ins i16mem:$src1, GR16:$src2),
3666 "bt{w}\t{$src2, $src1|$src1, $src2}",
Dan Gohmanf31408d2009-01-13 23:23:30 +00003667// [(X86bt (loadi16 addr:$src1), GR16:$src2),
Sean Callanan108934c2009-12-18 00:01:26 +00003668// (implicit EFLAGS)]
3669 []
3670 >, OpSize, TB, Requires<[FastBTMem]>;
3671def BT32mr : I<0xA3, MRMDestMem, (outs), (ins i32mem:$src1, GR32:$src2),
3672 "bt{l}\t{$src2, $src1|$src1, $src2}",
Dan Gohmanf31408d2009-01-13 23:23:30 +00003673// [(X86bt (loadi32 addr:$src1), GR32:$src2),
Sean Callanan108934c2009-12-18 00:01:26 +00003674// (implicit EFLAGS)]
3675 []
3676 >, TB, Requires<[FastBTMem]>;
Dan Gohman4afe15b2009-01-13 20:33:23 +00003677
3678def BT16ri8 : Ii8<0xBA, MRM4r, (outs), (ins GR16:$src1, i16i8imm:$src2),
3679 "bt{w}\t{$src2, $src1|$src1, $src2}",
Chris Lattnere3486a42010-03-19 00:01:11 +00003680 [(set EFLAGS, (X86bt GR16:$src1, i16immSExt8:$src2))]>,
3681 OpSize, TB;
Dan Gohman4afe15b2009-01-13 20:33:23 +00003682def BT32ri8 : Ii8<0xBA, MRM4r, (outs), (ins GR32:$src1, i32i8imm:$src2),
3683 "bt{l}\t{$src2, $src1|$src1, $src2}",
Chris Lattnere3486a42010-03-19 00:01:11 +00003684 [(set EFLAGS, (X86bt GR32:$src1, i32immSExt8:$src2))]>, TB;
Dan Gohman4afe15b2009-01-13 20:33:23 +00003685// Note that these instructions don't need FastBTMem because that
3686// only applies when the other operand is in a register. When it's
3687// an immediate, bt is still fast.
3688def BT16mi8 : Ii8<0xBA, MRM4m, (outs), (ins i16mem:$src1, i16i8imm:$src2),
3689 "bt{w}\t{$src2, $src1|$src1, $src2}",
Chris Lattnere3486a42010-03-19 00:01:11 +00003690 [(set EFLAGS, (X86bt (loadi16 addr:$src1), i16immSExt8:$src2))
3691 ]>, OpSize, TB;
Dan Gohman4afe15b2009-01-13 20:33:23 +00003692def BT32mi8 : Ii8<0xBA, MRM4m, (outs), (ins i32mem:$src1, i32i8imm:$src2),
3693 "bt{l}\t{$src2, $src1|$src1, $src2}",
Chris Lattnere3486a42010-03-19 00:01:11 +00003694 [(set EFLAGS, (X86bt (loadi32 addr:$src1), i32immSExt8:$src2))
3695 ]>, TB;
Sean Callanan108934c2009-12-18 00:01:26 +00003696
3697def BTC16rr : I<0xBB, MRMDestReg, (outs), (ins GR16:$src1, GR16:$src2),
3698 "btc{w}\t{$src2, $src1|$src1, $src2}", []>, OpSize, TB;
3699def BTC32rr : I<0xBB, MRMDestReg, (outs), (ins GR32:$src1, GR32:$src2),
3700 "btc{l}\t{$src2, $src1|$src1, $src2}", []>, TB;
3701def BTC16mr : I<0xBB, MRMDestMem, (outs), (ins i16mem:$src1, GR16:$src2),
3702 "btc{w}\t{$src2, $src1|$src1, $src2}", []>, OpSize, TB;
3703def BTC32mr : I<0xBB, MRMDestMem, (outs), (ins i32mem:$src1, GR32:$src2),
3704 "btc{l}\t{$src2, $src1|$src1, $src2}", []>, TB;
3705def BTC16ri8 : Ii8<0xBA, MRM7r, (outs), (ins GR16:$src1, i16i8imm:$src2),
3706 "btc{w}\t{$src2, $src1|$src1, $src2}", []>, OpSize, TB;
3707def BTC32ri8 : Ii8<0xBA, MRM7r, (outs), (ins GR32:$src1, i32i8imm:$src2),
3708 "btc{l}\t{$src2, $src1|$src1, $src2}", []>, TB;
3709def BTC16mi8 : Ii8<0xBA, MRM7m, (outs), (ins i16mem:$src1, i16i8imm:$src2),
3710 "btc{w}\t{$src2, $src1|$src1, $src2}", []>, OpSize, TB;
3711def BTC32mi8 : Ii8<0xBA, MRM7m, (outs), (ins i32mem:$src1, i32i8imm:$src2),
3712 "btc{l}\t{$src2, $src1|$src1, $src2}", []>, TB;
3713
3714def BTR16rr : I<0xB3, MRMDestReg, (outs), (ins GR16:$src1, GR16:$src2),
3715 "btr{w}\t{$src2, $src1|$src1, $src2}", []>, OpSize, TB;
3716def BTR32rr : I<0xB3, MRMDestReg, (outs), (ins GR32:$src1, GR32:$src2),
3717 "btr{l}\t{$src2, $src1|$src1, $src2}", []>, TB;
3718def BTR16mr : I<0xB3, MRMDestMem, (outs), (ins i16mem:$src1, GR16:$src2),
3719 "btr{w}\t{$src2, $src1|$src1, $src2}", []>, OpSize, TB;
3720def BTR32mr : I<0xB3, MRMDestMem, (outs), (ins i32mem:$src1, GR32:$src2),
3721 "btr{l}\t{$src2, $src1|$src1, $src2}", []>, TB;
3722def BTR16ri8 : Ii8<0xBA, MRM6r, (outs), (ins GR16:$src1, i16i8imm:$src2),
3723 "btr{w}\t{$src2, $src1|$src1, $src2}", []>, OpSize, TB;
3724def BTR32ri8 : Ii8<0xBA, MRM6r, (outs), (ins GR32:$src1, i32i8imm:$src2),
3725 "btr{l}\t{$src2, $src1|$src1, $src2}", []>, TB;
3726def BTR16mi8 : Ii8<0xBA, MRM6m, (outs), (ins i16mem:$src1, i16i8imm:$src2),
3727 "btr{w}\t{$src2, $src1|$src1, $src2}", []>, OpSize, TB;
3728def BTR32mi8 : Ii8<0xBA, MRM6m, (outs), (ins i32mem:$src1, i32i8imm:$src2),
3729 "btr{l}\t{$src2, $src1|$src1, $src2}", []>, TB;
3730
3731def BTS16rr : I<0xAB, MRMDestReg, (outs), (ins GR16:$src1, GR16:$src2),
3732 "bts{w}\t{$src2, $src1|$src1, $src2}", []>, OpSize, TB;
3733def BTS32rr : I<0xAB, MRMDestReg, (outs), (ins GR32:$src1, GR32:$src2),
3734 "bts{l}\t{$src2, $src1|$src1, $src2}", []>, TB;
3735def BTS16mr : I<0xAB, MRMDestMem, (outs), (ins i16mem:$src1, GR16:$src2),
3736 "bts{w}\t{$src2, $src1|$src1, $src2}", []>, OpSize, TB;
3737def BTS32mr : I<0xAB, MRMDestMem, (outs), (ins i32mem:$src1, GR32:$src2),
3738 "bts{l}\t{$src2, $src1|$src1, $src2}", []>, TB;
3739def BTS16ri8 : Ii8<0xBA, MRM5r, (outs), (ins GR16:$src1, i16i8imm:$src2),
3740 "bts{w}\t{$src2, $src1|$src1, $src2}", []>, OpSize, TB;
3741def BTS32ri8 : Ii8<0xBA, MRM5r, (outs), (ins GR32:$src1, i32i8imm:$src2),
3742 "bts{l}\t{$src2, $src1|$src1, $src2}", []>, TB;
3743def BTS16mi8 : Ii8<0xBA, MRM5m, (outs), (ins i16mem:$src1, i16i8imm:$src2),
3744 "bts{w}\t{$src2, $src1|$src1, $src2}", []>, OpSize, TB;
3745def BTS32mi8 : Ii8<0xBA, MRM5m, (outs), (ins i32mem:$src1, i32i8imm:$src2),
3746 "bts{l}\t{$src2, $src1|$src1, $src2}", []>, TB;
Dan Gohmanc7a37d42008-12-23 22:45:23 +00003747} // Defs = [EFLAGS]
3748
Chris Lattner1cca5e32003-08-03 21:54:21 +00003749// Sign/Zero extenders
Dan Gohman11ba3b12008-07-30 18:09:17 +00003750// Use movsbl intead of movsbw; we don't care about the high 16 bits
3751// of the register here. This has a smaller encoding and avoids a
Sean Callanan108934c2009-12-18 00:01:26 +00003752// partial-register update. Actual movsbw included for the disassembler.
3753def MOVSX16rr8W : I<0xBE, MRMSrcReg, (outs GR16:$dst), (ins GR8:$src),
3754 "movs{bw|x}\t{$src, $dst|$dst, $src}", []>, TB, OpSize;
3755def MOVSX16rm8W : I<0xBE, MRMSrcMem, (outs GR16:$dst), (ins i8mem:$src),
3756 "movs{bw|x}\t{$src, $dst|$dst, $src}", []>, TB, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00003757def MOVSX16rr8 : I<0xBE, MRMSrcReg, (outs GR16:$dst), (ins GR8 :$src),
Chris Lattner172862a2009-10-19 19:51:42 +00003758 "", [(set GR16:$dst, (sext GR8:$src))]>, TB;
Evan Cheng64d80e32007-07-19 01:14:50 +00003759def MOVSX16rm8 : I<0xBE, MRMSrcMem, (outs GR16:$dst), (ins i8mem :$src),
Chris Lattner172862a2009-10-19 19:51:42 +00003760 "", [(set GR16:$dst, (sextloadi16i8 addr:$src))]>, TB;
Evan Cheng64d80e32007-07-19 01:14:50 +00003761def MOVSX32rr8 : I<0xBE, MRMSrcReg, (outs GR32:$dst), (ins GR8 :$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003762 "movs{bl|x}\t{$src, $dst|$dst, $src}",
Evan Cheng069287d2006-05-16 07:21:53 +00003763 [(set GR32:$dst, (sext GR8:$src))]>, TB;
Evan Cheng64d80e32007-07-19 01:14:50 +00003764def MOVSX32rm8 : I<0xBE, MRMSrcMem, (outs GR32:$dst), (ins i8mem :$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003765 "movs{bl|x}\t{$src, $dst|$dst, $src}",
Evan Cheng069287d2006-05-16 07:21:53 +00003766 [(set GR32:$dst, (sextloadi32i8 addr:$src))]>, TB;
Evan Cheng64d80e32007-07-19 01:14:50 +00003767def MOVSX32rr16: I<0xBF, MRMSrcReg, (outs GR32:$dst), (ins GR16:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003768 "movs{wl|x}\t{$src, $dst|$dst, $src}",
Evan Cheng069287d2006-05-16 07:21:53 +00003769 [(set GR32:$dst, (sext GR16:$src))]>, TB;
Evan Cheng64d80e32007-07-19 01:14:50 +00003770def MOVSX32rm16: I<0xBF, MRMSrcMem, (outs GR32:$dst), (ins i16mem:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003771 "movs{wl|x}\t{$src, $dst|$dst, $src}",
Evan Cheng069287d2006-05-16 07:21:53 +00003772 [(set GR32:$dst, (sextloadi32i16 addr:$src))]>, TB;
Alkis Evlogimenosa7be9822004-02-17 09:14:23 +00003773
Dan Gohman11ba3b12008-07-30 18:09:17 +00003774// Use movzbl intead of movzbw; we don't care about the high 16 bits
3775// of the register here. This has a smaller encoding and avoids a
Sean Callanan108934c2009-12-18 00:01:26 +00003776// partial-register update. Actual movzbw included for the disassembler.
3777def MOVZX16rr8W : I<0xB6, MRMSrcReg, (outs GR16:$dst), (ins GR8:$src),
3778 "movz{bw|x}\t{$src, $dst|$dst, $src}", []>, TB, OpSize;
3779def MOVZX16rm8W : I<0xB6, MRMSrcMem, (outs GR16:$dst), (ins i8mem:$src),
3780 "movz{bw|x}\t{$src, $dst|$dst, $src}", []>, TB, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00003781def MOVZX16rr8 : I<0xB6, MRMSrcReg, (outs GR16:$dst), (ins GR8 :$src),
Chris Lattner172862a2009-10-19 19:51:42 +00003782 "", [(set GR16:$dst, (zext GR8:$src))]>, TB;
Evan Cheng64d80e32007-07-19 01:14:50 +00003783def MOVZX16rm8 : I<0xB6, MRMSrcMem, (outs GR16:$dst), (ins i8mem :$src),
Chris Lattner172862a2009-10-19 19:51:42 +00003784 "", [(set GR16:$dst, (zextloadi16i8 addr:$src))]>, TB;
Evan Cheng64d80e32007-07-19 01:14:50 +00003785def MOVZX32rr8 : I<0xB6, MRMSrcReg, (outs GR32:$dst), (ins GR8 :$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003786 "movz{bl|x}\t{$src, $dst|$dst, $src}",
Evan Cheng069287d2006-05-16 07:21:53 +00003787 [(set GR32:$dst, (zext GR8:$src))]>, TB;
Evan Cheng64d80e32007-07-19 01:14:50 +00003788def MOVZX32rm8 : I<0xB6, MRMSrcMem, (outs GR32:$dst), (ins i8mem :$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003789 "movz{bl|x}\t{$src, $dst|$dst, $src}",
Evan Cheng069287d2006-05-16 07:21:53 +00003790 [(set GR32:$dst, (zextloadi32i8 addr:$src))]>, TB;
Evan Cheng64d80e32007-07-19 01:14:50 +00003791def MOVZX32rr16: I<0xB7, MRMSrcReg, (outs GR32:$dst), (ins GR16:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003792 "movz{wl|x}\t{$src, $dst|$dst, $src}",
Evan Cheng069287d2006-05-16 07:21:53 +00003793 [(set GR32:$dst, (zext GR16:$src))]>, TB;
Evan Cheng64d80e32007-07-19 01:14:50 +00003794def MOVZX32rm16: I<0xB7, MRMSrcMem, (outs GR32:$dst), (ins i16mem:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003795 "movz{wl|x}\t{$src, $dst|$dst, $src}",
Evan Cheng069287d2006-05-16 07:21:53 +00003796 [(set GR32:$dst, (zextloadi32i16 addr:$src))]>, TB;
Evan Cheng7a7e8372005-12-14 02:22:27 +00003797
Dan Gohmanf451cb82010-02-10 16:03:48 +00003798// These are the same as the regular MOVZX32rr8 and MOVZX32rm8
Dan Gohman21e3dfb2009-04-13 16:09:41 +00003799// except that they use GR32_NOREX for the output operand register class
3800// instead of GR32. This allows them to operate on h registers on x86-64.
3801def MOVZX32_NOREXrr8 : I<0xB6, MRMSrcReg,
3802 (outs GR32_NOREX:$dst), (ins GR8:$src),
3803 "movz{bl|x}\t{$src, $dst|$dst, $src} # NOREX",
3804 []>, TB;
Dan Gohman78e04d42009-04-30 03:11:48 +00003805let mayLoad = 1 in
Dan Gohman21e3dfb2009-04-13 16:09:41 +00003806def MOVZX32_NOREXrm8 : I<0xB6, MRMSrcMem,
3807 (outs GR32_NOREX:$dst), (ins i8mem:$src),
3808 "movz{bl|x}\t{$src, $dst|$dst, $src} # NOREX",
3809 []>, TB;
3810
Chris Lattnerba7e7562008-01-10 07:59:24 +00003811let neverHasSideEffects = 1 in {
3812 let Defs = [AX], Uses = [AL] in
3813 def CBW : I<0x98, RawFrm, (outs), (ins),
3814 "{cbtw|cbw}", []>, OpSize; // AX = signext(AL)
3815 let Defs = [EAX], Uses = [AX] in
3816 def CWDE : I<0x98, RawFrm, (outs), (ins),
3817 "{cwtl|cwde}", []>; // EAX = signext(AX)
Evan Chengf91c1012006-05-31 22:05:11 +00003818
Chris Lattnerba7e7562008-01-10 07:59:24 +00003819 let Defs = [AX,DX], Uses = [AX] in
3820 def CWD : I<0x99, RawFrm, (outs), (ins),
3821 "{cwtd|cwd}", []>, OpSize; // DX:AX = signext(AX)
3822 let Defs = [EAX,EDX], Uses = [EAX] in
3823 def CDQ : I<0x99, RawFrm, (outs), (ins),
3824 "{cltd|cdq}", []>; // EDX:EAX = signext(EAX)
3825}
Evan Cheng747a90d2006-02-21 02:24:38 +00003826
Evan Cheng747a90d2006-02-21 02:24:38 +00003827//===----------------------------------------------------------------------===//
3828// Alias Instructions
3829//===----------------------------------------------------------------------===//
3830
3831// Alias instructions that map movr0 to xor.
3832// FIXME: remove when we can teach regalloc that xor reg, reg is ok.
Chris Lattner35e0e842010-02-05 21:21:06 +00003833// FIXME: Set encoding to pseudo.
Daniel Dunbar7417b762009-08-11 22:17:52 +00003834let Defs = [EFLAGS], isReMaterializable = 1, isAsCheapAsAMove = 1,
3835 isCodeGenOnly = 1 in {
Chris Lattner35e0e842010-02-05 21:21:06 +00003836def MOV8r0 : I<0x30, MRMInitReg, (outs GR8 :$dst), (ins), "",
Evan Cheng069287d2006-05-16 07:21:53 +00003837 [(set GR8:$dst, 0)]>;
Dan Gohmanf1b4d262010-01-12 04:42:54 +00003838
3839// We want to rewrite MOV16r0 in terms of MOV32r0, because it's a smaller
3840// encoding and avoids a partial-register update sometimes, but doing so
3841// at isel time interferes with rematerialization in the current register
3842// allocator. For now, this is rewritten when the instruction is lowered
3843// to an MCInst.
3844def MOV16r0 : I<0x31, MRMInitReg, (outs GR16:$dst), (ins),
3845 "",
3846 [(set GR16:$dst, 0)]>, OpSize;
Chris Lattner6a381822009-12-23 01:30:26 +00003847
Chris Lattner35e0e842010-02-05 21:21:06 +00003848// FIXME: Set encoding to pseudo.
3849def MOV32r0 : I<0x31, MRMInitReg, (outs GR32:$dst), (ins), "",
Chris Lattnerac105c42009-12-23 01:46:40 +00003850 [(set GR32:$dst, 0)]>;
3851}
Chris Lattner6a381822009-12-23 01:30:26 +00003852
Evan Cheng510e4782006-01-09 23:10:28 +00003853//===----------------------------------------------------------------------===//
Lauro Ramos Venanciob3a04172007-04-20 21:38:10 +00003854// Thread Local Storage Instructions
3855//
3856
Eric Christopher37106af2010-06-24 02:07:57 +00003857// ELF TLS Support
Rafael Espindola15f1b662009-04-24 12:59:40 +00003858// All calls clobber the non-callee saved registers. ESP is marked as
3859// a use to prevent stack-pointer assignments that appear immediately
3860// before calls from potentially appearing dead.
3861let Defs = [EAX, ECX, EDX, FP0, FP1, FP2, FP3, FP4, FP5, FP6, ST0,
3862 MM0, MM1, MM2, MM3, MM4, MM5, MM6, MM7,
3863 XMM0, XMM1, XMM2, XMM3, XMM4, XMM5, XMM6, XMM7,
3864 XMM8, XMM9, XMM10, XMM11, XMM12, XMM13, XMM14, XMM15, EFLAGS],
Chris Lattner5c0b16d2009-06-20 20:38:48 +00003865 Uses = [ESP] in
Chris Lattner599b5312010-07-08 23:46:44 +00003866def TLS_addr32 : I<0, Pseudo, (outs), (ins i32mem:$sym),
Chris Lattner5c0b16d2009-06-20 20:38:48 +00003867 "leal\t$sym, %eax; "
Dan Gohman4d47b9b2009-04-27 15:13:28 +00003868 "call\t___tls_get_addr@PLT",
Chris Lattner5c0b16d2009-06-20 20:38:48 +00003869 [(X86tlsaddr tls32addr:$sym)]>,
Rafael Espindola2ee3db32009-04-17 14:35:58 +00003870 Requires<[In32BitMode]>;
Lauro Ramos Venanciob3a04172007-04-20 21:38:10 +00003871
Eric Christopher37106af2010-06-24 02:07:57 +00003872// Darwin TLS Support
Eric Christopher18ebf742010-06-23 08:01:49 +00003873// For i386, the address of the thunk is passed on the stack, on return the
3874// address of the variable is in %eax. %ecx is trashed during the function
Eric Christopher749bb7e2010-06-23 20:49:35 +00003875// call. All other registers are preserved.
3876let Defs = [EAX, ECX],
3877 Uses = [ESP],
Eric Christopher30ef0e52010-06-03 04:07:48 +00003878 usesCustomInserter = 1 in
Eric Christopher54415362010-06-08 22:04:25 +00003879def TLSCall_32 : I<0, Pseudo, (outs), (ins i32mem:$sym),
Eric Christopher749bb7e2010-06-23 20:49:35 +00003880 "# TLSCall_32",
Eric Christopher54415362010-06-08 22:04:25 +00003881 [(X86TLSCall addr:$sym)]>,
Eric Christopher30ef0e52010-06-03 04:07:48 +00003882 Requires<[In32BitMode]>;
3883
Daniel Dunbar0c420fc2009-08-11 22:24:40 +00003884let AddedComplexity = 5, isCodeGenOnly = 1 in
Nate Begeman51a04372009-01-26 01:24:32 +00003885def GS_MOV32rm : I<0x8B, MRMSrcMem, (outs GR32:$dst), (ins i32mem:$src),
3886 "movl\t%gs:$src, $dst",
3887 [(set GR32:$dst, (gsload addr:$src))]>, SegGS;
3888
Daniel Dunbar0c420fc2009-08-11 22:24:40 +00003889let AddedComplexity = 5, isCodeGenOnly = 1 in
Chris Lattner1777d0c2009-05-05 18:52:19 +00003890def FS_MOV32rm : I<0x8B, MRMSrcMem, (outs GR32:$dst), (ins i32mem:$src),
3891 "movl\t%fs:$src, $dst",
3892 [(set GR32:$dst, (fsload addr:$src))]>, SegFS;
3893
Lauro Ramos Venanciob3a04172007-04-20 21:38:10 +00003894//===----------------------------------------------------------------------===//
Anton Korobeynikov2365f512007-07-14 14:06:15 +00003895// EH Pseudo Instructions
3896//
3897let isTerminator = 1, isReturn = 1, isBarrier = 1,
Daniel Dunbar1ca3a0b2009-08-27 07:58:05 +00003898 hasCtrlDep = 1, isCodeGenOnly = 1 in {
Evan Cheng64d80e32007-07-19 01:14:50 +00003899def EH_RETURN : I<0xC3, RawFrm, (outs), (ins GR32:$addr),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003900 "ret\t#eh_return, addr: $addr",
Anton Korobeynikov2365f512007-07-14 14:06:15 +00003901 [(X86ehret GR32:$addr)]>;
3902
3903}
3904
3905//===----------------------------------------------------------------------===//
Andrew Lenharthab0b9492008-02-21 06:45:13 +00003906// Atomic support
3907//
Andrew Lenharthea7da502008-03-01 13:37:02 +00003908
Evan Chengbb6939d2008-04-19 01:20:30 +00003909// Atomic swap. These are just normal xchg instructions. But since a memory
3910// operand is referenced, the atomicity is ensured.
Dan Gohman165660e2008-08-06 15:52:50 +00003911let Constraints = "$val = $dst" in {
Sean Callanan108934c2009-12-18 00:01:26 +00003912def XCHG32rm : I<0x87, MRMSrcMem, (outs GR32:$dst),
3913 (ins GR32:$val, i32mem:$ptr),
Evan Chengbb6939d2008-04-19 01:20:30 +00003914 "xchg{l}\t{$val, $ptr|$ptr, $val}",
3915 [(set GR32:$dst, (atomic_swap_32 addr:$ptr, GR32:$val))]>;
Sean Callanan108934c2009-12-18 00:01:26 +00003916def XCHG16rm : I<0x87, MRMSrcMem, (outs GR16:$dst),
3917 (ins GR16:$val, i16mem:$ptr),
Evan Chengbb6939d2008-04-19 01:20:30 +00003918 "xchg{w}\t{$val, $ptr|$ptr, $val}",
3919 [(set GR16:$dst, (atomic_swap_16 addr:$ptr, GR16:$val))]>,
3920 OpSize;
Sean Callanan108934c2009-12-18 00:01:26 +00003921def XCHG8rm : I<0x86, MRMSrcMem, (outs GR8:$dst), (ins GR8:$val, i8mem:$ptr),
Evan Chengbb6939d2008-04-19 01:20:30 +00003922 "xchg{b}\t{$val, $ptr|$ptr, $val}",
3923 [(set GR8:$dst, (atomic_swap_8 addr:$ptr, GR8:$val))]>;
Sean Callanan108934c2009-12-18 00:01:26 +00003924
3925def XCHG32rr : I<0x87, MRMSrcReg, (outs GR32:$dst), (ins GR32:$val, GR32:$src),
3926 "xchg{l}\t{$val, $src|$src, $val}", []>;
3927def XCHG16rr : I<0x87, MRMSrcReg, (outs GR16:$dst), (ins GR16:$val, GR16:$src),
3928 "xchg{w}\t{$val, $src|$src, $val}", []>, OpSize;
3929def XCHG8rr : I<0x86, MRMSrcReg, (outs GR8:$dst), (ins GR8:$val, GR8:$src),
3930 "xchg{b}\t{$val, $src|$src, $val}", []>;
Evan Chengbb6939d2008-04-19 01:20:30 +00003931}
3932
Sean Callanan108934c2009-12-18 00:01:26 +00003933def XCHG16ar : I<0x90, AddRegFrm, (outs), (ins GR16:$src),
3934 "xchg{w}\t{$src, %ax|%ax, $src}", []>, OpSize;
3935def XCHG32ar : I<0x90, AddRegFrm, (outs), (ins GR32:$src),
3936 "xchg{l}\t{$src, %eax|%eax, $src}", []>;
3937
Evan Cheng7e032802008-04-18 20:55:36 +00003938// Atomic compare and swap.
Andrew Lenharth26ed8692008-03-01 21:52:34 +00003939let Defs = [EAX, EFLAGS], Uses = [EAX] in {
Evan Cheng7e032802008-04-18 20:55:36 +00003940def LCMPXCHG32 : I<0xB1, MRMDestMem, (outs), (ins i32mem:$ptr, GR32:$swap),
Dan Gohman4d47b9b2009-04-27 15:13:28 +00003941 "lock\n\t"
3942 "cmpxchg{l}\t{$swap, $ptr|$ptr, $swap}",
Evan Cheng32967d22008-03-04 03:20:06 +00003943 [(X86cas addr:$ptr, GR32:$swap, 4)]>, TB, LOCK;
Andrew Lenharthea7da502008-03-01 13:37:02 +00003944}
Dale Johannesen48c1bc22008-10-02 18:53:47 +00003945let Defs = [EAX, EDX, EFLAGS], Uses = [EAX, EBX, ECX, EDX] in {
Evan Chengb093bd02010-01-08 01:29:19 +00003946def LCMPXCHG8B : I<0xC7, MRM1m, (outs), (ins i64mem:$ptr),
Dan Gohman4d47b9b2009-04-27 15:13:28 +00003947 "lock\n\t"
3948 "cmpxchg8b\t$ptr",
Andrew Lenharthd19189e2008-03-05 01:15:49 +00003949 [(X86cas8 addr:$ptr)]>, TB, LOCK;
3950}
Andrew Lenharth26ed8692008-03-01 21:52:34 +00003951
3952let Defs = [AX, EFLAGS], Uses = [AX] in {
Evan Cheng7e032802008-04-18 20:55:36 +00003953def LCMPXCHG16 : I<0xB1, MRMDestMem, (outs), (ins i16mem:$ptr, GR16:$swap),
Dan Gohman4d47b9b2009-04-27 15:13:28 +00003954 "lock\n\t"
3955 "cmpxchg{w}\t{$swap, $ptr|$ptr, $swap}",
Evan Cheng32967d22008-03-04 03:20:06 +00003956 [(X86cas addr:$ptr, GR16:$swap, 2)]>, TB, OpSize, LOCK;
Andrew Lenharthea7da502008-03-01 13:37:02 +00003957}
Andrew Lenharth26ed8692008-03-01 21:52:34 +00003958let Defs = [AL, EFLAGS], Uses = [AL] in {
Evan Cheng7e032802008-04-18 20:55:36 +00003959def LCMPXCHG8 : I<0xB0, MRMDestMem, (outs), (ins i8mem:$ptr, GR8:$swap),
Dan Gohman4d47b9b2009-04-27 15:13:28 +00003960 "lock\n\t"
3961 "cmpxchg{b}\t{$swap, $ptr|$ptr, $swap}",
Evan Cheng32967d22008-03-04 03:20:06 +00003962 [(X86cas addr:$ptr, GR8:$swap, 1)]>, TB, LOCK;
Andrew Lenharthea7da502008-03-01 13:37:02 +00003963}
3964
Evan Cheng7e032802008-04-18 20:55:36 +00003965// Atomic exchange and add
3966let Constraints = "$val = $dst", Defs = [EFLAGS] in {
Sean Callanan108934c2009-12-18 00:01:26 +00003967def LXADD32 : I<0xC1, MRMSrcMem, (outs GR32:$dst), (ins GR32:$val, i32mem:$ptr),
Dan Gohman4d47b9b2009-04-27 15:13:28 +00003968 "lock\n\t"
3969 "xadd{l}\t{$val, $ptr|$ptr, $val}",
Mon P Wang28873102008-06-25 08:15:39 +00003970 [(set GR32:$dst, (atomic_load_add_32 addr:$ptr, GR32:$val))]>,
Evan Cheng7e032802008-04-18 20:55:36 +00003971 TB, LOCK;
Sean Callanan108934c2009-12-18 00:01:26 +00003972def LXADD16 : I<0xC1, MRMSrcMem, (outs GR16:$dst), (ins GR16:$val, i16mem:$ptr),
Dan Gohman4d47b9b2009-04-27 15:13:28 +00003973 "lock\n\t"
3974 "xadd{w}\t{$val, $ptr|$ptr, $val}",
Mon P Wang28873102008-06-25 08:15:39 +00003975 [(set GR16:$dst, (atomic_load_add_16 addr:$ptr, GR16:$val))]>,
Evan Cheng7e032802008-04-18 20:55:36 +00003976 TB, OpSize, LOCK;
Sean Callanan108934c2009-12-18 00:01:26 +00003977def LXADD8 : I<0xC0, MRMSrcMem, (outs GR8:$dst), (ins GR8:$val, i8mem:$ptr),
Dan Gohman4d47b9b2009-04-27 15:13:28 +00003978 "lock\n\t"
3979 "xadd{b}\t{$val, $ptr|$ptr, $val}",
Mon P Wang28873102008-06-25 08:15:39 +00003980 [(set GR8:$dst, (atomic_load_add_8 addr:$ptr, GR8:$val))]>,
Evan Cheng7e032802008-04-18 20:55:36 +00003981 TB, LOCK;
Andrew Lenharthea7da502008-03-01 13:37:02 +00003982}
3983
Sean Callanan108934c2009-12-18 00:01:26 +00003984def XADD8rr : I<0xC0, MRMDestReg, (outs GR8:$dst), (ins GR8:$src),
3985 "xadd{b}\t{$src, $dst|$dst, $src}", []>, TB;
3986def XADD16rr : I<0xC1, MRMDestReg, (outs GR16:$dst), (ins GR16:$src),
3987 "xadd{w}\t{$src, $dst|$dst, $src}", []>, TB, OpSize;
3988def XADD32rr : I<0xC1, MRMDestReg, (outs GR32:$dst), (ins GR32:$src),
3989 "xadd{l}\t{$src, $dst|$dst, $src}", []>, TB;
3990
Dan Gohman7f357ec2010-05-14 16:34:55 +00003991let mayLoad = 1, mayStore = 1 in {
Sean Callanan108934c2009-12-18 00:01:26 +00003992def XADD8rm : I<0xC0, MRMDestMem, (outs), (ins i8mem:$dst, GR8:$src),
3993 "xadd{b}\t{$src, $dst|$dst, $src}", []>, TB;
3994def XADD16rm : I<0xC1, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src),
3995 "xadd{w}\t{$src, $dst|$dst, $src}", []>, TB, OpSize;
3996def XADD32rm : I<0xC1, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src),
3997 "xadd{l}\t{$src, $dst|$dst, $src}", []>, TB;
Dan Gohman7f357ec2010-05-14 16:34:55 +00003998}
Sean Callanan108934c2009-12-18 00:01:26 +00003999
4000def CMPXCHG8rr : I<0xB0, MRMDestReg, (outs GR8:$dst), (ins GR8:$src),
4001 "cmpxchg{b}\t{$src, $dst|$dst, $src}", []>, TB;
4002def CMPXCHG16rr : I<0xB1, MRMDestReg, (outs GR16:$dst), (ins GR16:$src),
4003 "cmpxchg{w}\t{$src, $dst|$dst, $src}", []>, TB, OpSize;
4004def CMPXCHG32rr : I<0xB1, MRMDestReg, (outs GR32:$dst), (ins GR32:$src),
4005 "cmpxchg{l}\t{$src, $dst|$dst, $src}", []>, TB;
4006
Dan Gohman7f357ec2010-05-14 16:34:55 +00004007let mayLoad = 1, mayStore = 1 in {
Sean Callanan108934c2009-12-18 00:01:26 +00004008def CMPXCHG8rm : I<0xB0, MRMDestMem, (outs), (ins i8mem:$dst, GR8:$src),
4009 "cmpxchg{b}\t{$src, $dst|$dst, $src}", []>, TB;
4010def CMPXCHG16rm : I<0xB1, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src),
4011 "cmpxchg{w}\t{$src, $dst|$dst, $src}", []>, TB, OpSize;
4012def CMPXCHG32rm : I<0xB1, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src),
4013 "cmpxchg{l}\t{$src, $dst|$dst, $src}", []>, TB;
Dan Gohman7f357ec2010-05-14 16:34:55 +00004014}
Sean Callanan108934c2009-12-18 00:01:26 +00004015
Evan Chengb093bd02010-01-08 01:29:19 +00004016let Defs = [EAX, EDX, EFLAGS], Uses = [EAX, EBX, ECX, EDX] in
Sean Callanan108934c2009-12-18 00:01:26 +00004017def CMPXCHG8B : I<0xC7, MRM1m, (outs), (ins i64mem:$dst),
4018 "cmpxchg8b\t$dst", []>, TB;
4019
Evan Cheng37b73872009-07-30 08:33:02 +00004020// Optimized codegen when the non-memory output is not used.
4021// FIXME: Use normal add / sub instructions and add lock prefix dynamically.
Dan Gohman7f357ec2010-05-14 16:34:55 +00004022let Defs = [EFLAGS], mayLoad = 1, mayStore = 1 in {
Evan Cheng37b73872009-07-30 08:33:02 +00004023def LOCK_ADD8mr : I<0x00, MRMDestMem, (outs), (ins i8mem:$dst, GR8:$src2),
4024 "lock\n\t"
4025 "add{b}\t{$src2, $dst|$dst, $src2}", []>, LOCK;
4026def LOCK_ADD16mr : I<0x01, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
4027 "lock\n\t"
4028 "add{w}\t{$src2, $dst|$dst, $src2}", []>, OpSize, LOCK;
4029def LOCK_ADD32mr : I<0x01, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
4030 "lock\n\t"
4031 "add{l}\t{$src2, $dst|$dst, $src2}", []>, LOCK;
4032def LOCK_ADD8mi : Ii8<0x80, MRM0m, (outs), (ins i8mem :$dst, i8imm :$src2),
4033 "lock\n\t"
4034 "add{b}\t{$src2, $dst|$dst, $src2}", []>, LOCK;
4035def LOCK_ADD16mi : Ii16<0x81, MRM0m, (outs), (ins i16mem:$dst, i16imm:$src2),
4036 "lock\n\t"
4037 "add{w}\t{$src2, $dst|$dst, $src2}", []>, LOCK;
4038def LOCK_ADD32mi : Ii32<0x81, MRM0m, (outs), (ins i32mem:$dst, i32imm:$src2),
4039 "lock\n\t"
4040 "add{l}\t{$src2, $dst|$dst, $src2}", []>, LOCK;
4041def LOCK_ADD16mi8 : Ii8<0x83, MRM0m, (outs), (ins i16mem:$dst, i16i8imm :$src2),
4042 "lock\n\t"
4043 "add{w}\t{$src2, $dst|$dst, $src2}", []>, OpSize, LOCK;
4044def LOCK_ADD32mi8 : Ii8<0x83, MRM0m, (outs), (ins i32mem:$dst, i32i8imm :$src2),
4045 "lock\n\t"
4046 "add{l}\t{$src2, $dst|$dst, $src2}", []>, LOCK;
4047
4048def LOCK_INC8m : I<0xFE, MRM0m, (outs), (ins i8mem :$dst),
4049 "lock\n\t"
4050 "inc{b}\t$dst", []>, LOCK;
4051def LOCK_INC16m : I<0xFF, MRM0m, (outs), (ins i16mem:$dst),
4052 "lock\n\t"
4053 "inc{w}\t$dst", []>, OpSize, LOCK;
4054def LOCK_INC32m : I<0xFF, MRM0m, (outs), (ins i32mem:$dst),
4055 "lock\n\t"
4056 "inc{l}\t$dst", []>, LOCK;
4057
4058def LOCK_SUB8mr : I<0x28, MRMDestMem, (outs), (ins i8mem :$dst, GR8 :$src2),
4059 "lock\n\t"
4060 "sub{b}\t{$src2, $dst|$dst, $src2}", []>, LOCK;
4061def LOCK_SUB16mr : I<0x29, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
4062 "lock\n\t"
4063 "sub{w}\t{$src2, $dst|$dst, $src2}", []>, OpSize, LOCK;
4064def LOCK_SUB32mr : I<0x29, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
4065 "lock\n\t"
4066 "sub{l}\t{$src2, $dst|$dst, $src2}", []>, LOCK;
4067def LOCK_SUB8mi : Ii8<0x80, MRM5m, (outs), (ins i8mem :$dst, i8imm:$src2),
4068 "lock\n\t"
4069 "sub{b}\t{$src2, $dst|$dst, $src2}", []>, LOCK;
4070def LOCK_SUB16mi : Ii16<0x81, MRM5m, (outs), (ins i16mem:$dst, i16imm:$src2),
4071 "lock\n\t"
4072 "sub{w}\t{$src2, $dst|$dst, $src2}", []>, OpSize, LOCK;
4073def LOCK_SUB32mi : Ii32<0x81, MRM5m, (outs), (ins i32mem:$dst, i32imm:$src2),
4074 "lock\n\t"
4075 "sub{l}\t{$src2, $dst|$dst, $src2}", []>, LOCK;
Sean Callanan108934c2009-12-18 00:01:26 +00004076def LOCK_SUB16mi8 : Ii8<0x83, MRM5m, (outs), (ins i16mem:$dst, i16i8imm :$src2),
Evan Cheng37b73872009-07-30 08:33:02 +00004077 "lock\n\t"
4078 "sub{w}\t{$src2, $dst|$dst, $src2}", []>, OpSize, LOCK;
4079def LOCK_SUB32mi8 : Ii8<0x83, MRM5m, (outs), (ins i32mem:$dst, i32i8imm :$src2),
4080 "lock\n\t"
4081 "sub{l}\t{$src2, $dst|$dst, $src2}", []>, LOCK;
4082
4083def LOCK_DEC8m : I<0xFE, MRM1m, (outs), (ins i8mem :$dst),
4084 "lock\n\t"
4085 "dec{b}\t$dst", []>, LOCK;
4086def LOCK_DEC16m : I<0xFF, MRM1m, (outs), (ins i16mem:$dst),
4087 "lock\n\t"
4088 "dec{w}\t$dst", []>, OpSize, LOCK;
4089def LOCK_DEC32m : I<0xFF, MRM1m, (outs), (ins i32mem:$dst),
4090 "lock\n\t"
4091 "dec{l}\t$dst", []>, LOCK;
Dan Gohmanbab42bd2009-10-20 18:14:49 +00004092}
Evan Cheng37b73872009-07-30 08:33:02 +00004093
Mon P Wang28873102008-06-25 08:15:39 +00004094// Atomic exchange, and, or, xor
Mon P Wang63307c32008-05-05 19:05:59 +00004095let Constraints = "$val = $dst", Defs = [EFLAGS],
Dan Gohman533297b2009-10-29 18:10:34 +00004096 usesCustomInserter = 1 in {
Dan Gohman9499b712008-05-12 20:22:45 +00004097def ATOMAND32 : I<0, Pseudo, (outs GR32:$dst),(ins i32mem:$ptr, GR32:$val),
Nick Lewycky6ecf5ce2008-12-07 03:49:52 +00004098 "#ATOMAND32 PSEUDO!",
Dale Johannesene00a8a22008-08-28 02:44:49 +00004099 [(set GR32:$dst, (atomic_load_and_32 addr:$ptr, GR32:$val))]>;
Dan Gohman9499b712008-05-12 20:22:45 +00004100def ATOMOR32 : I<0, Pseudo, (outs GR32:$dst),(ins i32mem:$ptr, GR32:$val),
Nick Lewycky6ecf5ce2008-12-07 03:49:52 +00004101 "#ATOMOR32 PSEUDO!",
Dale Johannesene00a8a22008-08-28 02:44:49 +00004102 [(set GR32:$dst, (atomic_load_or_32 addr:$ptr, GR32:$val))]>;
Dan Gohman9499b712008-05-12 20:22:45 +00004103def ATOMXOR32 : I<0, Pseudo,(outs GR32:$dst),(ins i32mem:$ptr, GR32:$val),
Nick Lewycky6ecf5ce2008-12-07 03:49:52 +00004104 "#ATOMXOR32 PSEUDO!",
Dale Johannesene00a8a22008-08-28 02:44:49 +00004105 [(set GR32:$dst, (atomic_load_xor_32 addr:$ptr, GR32:$val))]>;
Andrew Lenharth507a58a2008-06-14 05:48:15 +00004106def ATOMNAND32 : I<0, Pseudo,(outs GR32:$dst),(ins i32mem:$ptr, GR32:$val),
Nick Lewycky6ecf5ce2008-12-07 03:49:52 +00004107 "#ATOMNAND32 PSEUDO!",
Dale Johannesene00a8a22008-08-28 02:44:49 +00004108 [(set GR32:$dst, (atomic_load_nand_32 addr:$ptr, GR32:$val))]>;
Dan Gohman9499b712008-05-12 20:22:45 +00004109def ATOMMIN32: I<0, Pseudo, (outs GR32:$dst), (ins i32mem:$ptr, GR32:$val),
Nick Lewycky6ecf5ce2008-12-07 03:49:52 +00004110 "#ATOMMIN32 PSEUDO!",
Dale Johannesene00a8a22008-08-28 02:44:49 +00004111 [(set GR32:$dst, (atomic_load_min_32 addr:$ptr, GR32:$val))]>;
Dan Gohman9499b712008-05-12 20:22:45 +00004112def ATOMMAX32: I<0, Pseudo, (outs GR32:$dst),(ins i32mem:$ptr, GR32:$val),
Nick Lewycky6ecf5ce2008-12-07 03:49:52 +00004113 "#ATOMMAX32 PSEUDO!",
Dale Johannesene00a8a22008-08-28 02:44:49 +00004114 [(set GR32:$dst, (atomic_load_max_32 addr:$ptr, GR32:$val))]>;
Dan Gohman9499b712008-05-12 20:22:45 +00004115def ATOMUMIN32: I<0, Pseudo, (outs GR32:$dst),(ins i32mem:$ptr, GR32:$val),
Nick Lewycky6ecf5ce2008-12-07 03:49:52 +00004116 "#ATOMUMIN32 PSEUDO!",
Dale Johannesene00a8a22008-08-28 02:44:49 +00004117 [(set GR32:$dst, (atomic_load_umin_32 addr:$ptr, GR32:$val))]>;
Dan Gohman9499b712008-05-12 20:22:45 +00004118def ATOMUMAX32: I<0, Pseudo, (outs GR32:$dst),(ins i32mem:$ptr, GR32:$val),
Nick Lewycky6ecf5ce2008-12-07 03:49:52 +00004119 "#ATOMUMAX32 PSEUDO!",
Dale Johannesene00a8a22008-08-28 02:44:49 +00004120 [(set GR32:$dst, (atomic_load_umax_32 addr:$ptr, GR32:$val))]>;
Dale Johannesen140be2d2008-08-19 18:47:28 +00004121
4122def ATOMAND16 : I<0, Pseudo, (outs GR16:$dst),(ins i16mem:$ptr, GR16:$val),
Nick Lewycky6ecf5ce2008-12-07 03:49:52 +00004123 "#ATOMAND16 PSEUDO!",
Dale Johannesene00a8a22008-08-28 02:44:49 +00004124 [(set GR16:$dst, (atomic_load_and_16 addr:$ptr, GR16:$val))]>;
Dale Johannesen140be2d2008-08-19 18:47:28 +00004125def ATOMOR16 : I<0, Pseudo, (outs GR16:$dst),(ins i16mem:$ptr, GR16:$val),
Nick Lewycky6ecf5ce2008-12-07 03:49:52 +00004126 "#ATOMOR16 PSEUDO!",
Dale Johannesene00a8a22008-08-28 02:44:49 +00004127 [(set GR16:$dst, (atomic_load_or_16 addr:$ptr, GR16:$val))]>;
Dale Johannesen140be2d2008-08-19 18:47:28 +00004128def ATOMXOR16 : I<0, Pseudo,(outs GR16:$dst),(ins i16mem:$ptr, GR16:$val),
Nick Lewycky6ecf5ce2008-12-07 03:49:52 +00004129 "#ATOMXOR16 PSEUDO!",
Dale Johannesene00a8a22008-08-28 02:44:49 +00004130 [(set GR16:$dst, (atomic_load_xor_16 addr:$ptr, GR16:$val))]>;
Dale Johannesen140be2d2008-08-19 18:47:28 +00004131def ATOMNAND16 : I<0, Pseudo,(outs GR16:$dst),(ins i16mem:$ptr, GR16:$val),
Nick Lewycky6ecf5ce2008-12-07 03:49:52 +00004132 "#ATOMNAND16 PSEUDO!",
Dale Johannesene00a8a22008-08-28 02:44:49 +00004133 [(set GR16:$dst, (atomic_load_nand_16 addr:$ptr, GR16:$val))]>;
Dale Johannesen140be2d2008-08-19 18:47:28 +00004134def ATOMMIN16: I<0, Pseudo, (outs GR16:$dst), (ins i16mem:$ptr, GR16:$val),
Nick Lewycky6ecf5ce2008-12-07 03:49:52 +00004135 "#ATOMMIN16 PSEUDO!",
Dale Johannesene00a8a22008-08-28 02:44:49 +00004136 [(set GR16:$dst, (atomic_load_min_16 addr:$ptr, GR16:$val))]>;
Dale Johannesen140be2d2008-08-19 18:47:28 +00004137def ATOMMAX16: I<0, Pseudo, (outs GR16:$dst),(ins i16mem:$ptr, GR16:$val),
Nick Lewycky6ecf5ce2008-12-07 03:49:52 +00004138 "#ATOMMAX16 PSEUDO!",
Dale Johannesene00a8a22008-08-28 02:44:49 +00004139 [(set GR16:$dst, (atomic_load_max_16 addr:$ptr, GR16:$val))]>;
Dale Johannesen140be2d2008-08-19 18:47:28 +00004140def ATOMUMIN16: I<0, Pseudo, (outs GR16:$dst),(ins i16mem:$ptr, GR16:$val),
Nick Lewycky6ecf5ce2008-12-07 03:49:52 +00004141 "#ATOMUMIN16 PSEUDO!",
Dale Johannesene00a8a22008-08-28 02:44:49 +00004142 [(set GR16:$dst, (atomic_load_umin_16 addr:$ptr, GR16:$val))]>;
Dale Johannesen140be2d2008-08-19 18:47:28 +00004143def ATOMUMAX16: I<0, Pseudo, (outs GR16:$dst),(ins i16mem:$ptr, GR16:$val),
Nick Lewycky6ecf5ce2008-12-07 03:49:52 +00004144 "#ATOMUMAX16 PSEUDO!",
Dale Johannesene00a8a22008-08-28 02:44:49 +00004145 [(set GR16:$dst, (atomic_load_umax_16 addr:$ptr, GR16:$val))]>;
Dale Johannesen140be2d2008-08-19 18:47:28 +00004146
4147def ATOMAND8 : I<0, Pseudo, (outs GR8:$dst),(ins i8mem:$ptr, GR8:$val),
Nick Lewycky6ecf5ce2008-12-07 03:49:52 +00004148 "#ATOMAND8 PSEUDO!",
Dale Johannesene00a8a22008-08-28 02:44:49 +00004149 [(set GR8:$dst, (atomic_load_and_8 addr:$ptr, GR8:$val))]>;
Dale Johannesen140be2d2008-08-19 18:47:28 +00004150def ATOMOR8 : I<0, Pseudo, (outs GR8:$dst),(ins i8mem:$ptr, GR8:$val),
Nick Lewycky6ecf5ce2008-12-07 03:49:52 +00004151 "#ATOMOR8 PSEUDO!",
Dale Johannesene00a8a22008-08-28 02:44:49 +00004152 [(set GR8:$dst, (atomic_load_or_8 addr:$ptr, GR8:$val))]>;
Dale Johannesen140be2d2008-08-19 18:47:28 +00004153def ATOMXOR8 : I<0, Pseudo,(outs GR8:$dst),(ins i8mem:$ptr, GR8:$val),
Nick Lewycky6ecf5ce2008-12-07 03:49:52 +00004154 "#ATOMXOR8 PSEUDO!",
Dale Johannesene00a8a22008-08-28 02:44:49 +00004155 [(set GR8:$dst, (atomic_load_xor_8 addr:$ptr, GR8:$val))]>;
Dale Johannesen140be2d2008-08-19 18:47:28 +00004156def ATOMNAND8 : I<0, Pseudo,(outs GR8:$dst),(ins i8mem:$ptr, GR8:$val),
Nick Lewycky6ecf5ce2008-12-07 03:49:52 +00004157 "#ATOMNAND8 PSEUDO!",
Dale Johannesene00a8a22008-08-28 02:44:49 +00004158 [(set GR8:$dst, (atomic_load_nand_8 addr:$ptr, GR8:$val))]>;
Mon P Wang63307c32008-05-05 19:05:59 +00004159}
4160
Dale Johannesen48c1bc22008-10-02 18:53:47 +00004161let Constraints = "$val1 = $dst1, $val2 = $dst2",
4162 Defs = [EFLAGS, EAX, EBX, ECX, EDX],
4163 Uses = [EAX, EBX, ECX, EDX],
Dale Johannesen1b54c7f2008-10-03 19:41:08 +00004164 mayLoad = 1, mayStore = 1,
Dan Gohman533297b2009-10-29 18:10:34 +00004165 usesCustomInserter = 1 in {
Dale Johannesen48c1bc22008-10-02 18:53:47 +00004166def ATOMAND6432 : I<0, Pseudo, (outs GR32:$dst1, GR32:$dst2),
4167 (ins i64mem:$ptr, GR32:$val1, GR32:$val2),
Nick Lewycky6ecf5ce2008-12-07 03:49:52 +00004168 "#ATOMAND6432 PSEUDO!", []>;
Dale Johannesen48c1bc22008-10-02 18:53:47 +00004169def ATOMOR6432 : I<0, Pseudo, (outs GR32:$dst1, GR32:$dst2),
4170 (ins i64mem:$ptr, GR32:$val1, GR32:$val2),
Nick Lewycky6ecf5ce2008-12-07 03:49:52 +00004171 "#ATOMOR6432 PSEUDO!", []>;
Dale Johannesen48c1bc22008-10-02 18:53:47 +00004172def ATOMXOR6432 : I<0, Pseudo, (outs GR32:$dst1, GR32:$dst2),
4173 (ins i64mem:$ptr, GR32:$val1, GR32:$val2),
Nick Lewycky6ecf5ce2008-12-07 03:49:52 +00004174 "#ATOMXOR6432 PSEUDO!", []>;
Dale Johannesen48c1bc22008-10-02 18:53:47 +00004175def ATOMNAND6432 : I<0, Pseudo, (outs GR32:$dst1, GR32:$dst2),
4176 (ins i64mem:$ptr, GR32:$val1, GR32:$val2),
Nick Lewycky6ecf5ce2008-12-07 03:49:52 +00004177 "#ATOMNAND6432 PSEUDO!", []>;
Dale Johannesen48c1bc22008-10-02 18:53:47 +00004178def ATOMADD6432 : I<0, Pseudo, (outs GR32:$dst1, GR32:$dst2),
4179 (ins i64mem:$ptr, GR32:$val1, GR32:$val2),
Nick Lewycky6ecf5ce2008-12-07 03:49:52 +00004180 "#ATOMADD6432 PSEUDO!", []>;
Dale Johannesen48c1bc22008-10-02 18:53:47 +00004181def ATOMSUB6432 : I<0, Pseudo, (outs GR32:$dst1, GR32:$dst2),
4182 (ins i64mem:$ptr, GR32:$val1, GR32:$val2),
Nick Lewycky6ecf5ce2008-12-07 03:49:52 +00004183 "#ATOMSUB6432 PSEUDO!", []>;
Dale Johannesen880ae362008-10-03 22:25:52 +00004184def ATOMSWAP6432 : I<0, Pseudo, (outs GR32:$dst1, GR32:$dst2),
4185 (ins i64mem:$ptr, GR32:$val1, GR32:$val2),
Nick Lewycky6ecf5ce2008-12-07 03:49:52 +00004186 "#ATOMSWAP6432 PSEUDO!", []>;
Dale Johannesen48c1bc22008-10-02 18:53:47 +00004187}
4188
Sean Callanan358f1ef2009-09-16 21:55:34 +00004189// Segmentation support instructions.
4190
4191def LAR16rm : I<0x02, MRMSrcMem, (outs GR16:$dst), (ins i16mem:$src),
4192 "lar{w}\t{$src, $dst|$dst, $src}", []>, TB, OpSize;
4193def LAR16rr : I<0x02, MRMSrcReg, (outs GR16:$dst), (ins GR16:$src),
4194 "lar{w}\t{$src, $dst|$dst, $src}", []>, TB, OpSize;
4195
4196// i16mem operand in LAR32rm and GR32 operand in LAR32rr is not a typo.
4197def LAR32rm : I<0x02, MRMSrcMem, (outs GR32:$dst), (ins i16mem:$src),
4198 "lar{l}\t{$src, $dst|$dst, $src}", []>, TB;
4199def LAR32rr : I<0x02, MRMSrcReg, (outs GR32:$dst), (ins GR32:$src),
4200 "lar{l}\t{$src, $dst|$dst, $src}", []>, TB;
Sean Callanan108934c2009-12-18 00:01:26 +00004201
4202def LSL16rm : I<0x03, MRMSrcMem, (outs GR16:$dst), (ins i16mem:$src),
4203 "lsl{w}\t{$src, $dst|$dst, $src}", []>, TB, OpSize;
4204def LSL16rr : I<0x03, MRMSrcReg, (outs GR16:$dst), (ins GR16:$src),
4205 "lsl{w}\t{$src, $dst|$dst, $src}", []>, TB, OpSize;
4206def LSL32rm : I<0x03, MRMSrcMem, (outs GR32:$dst), (ins i32mem:$src),
4207 "lsl{l}\t{$src, $dst|$dst, $src}", []>, TB;
4208def LSL32rr : I<0x03, MRMSrcReg, (outs GR32:$dst), (ins GR32:$src),
4209 "lsl{l}\t{$src, $dst|$dst, $src}", []>, TB;
4210
Sean Callanan95a5a7d2010-02-13 01:48:34 +00004211def INVLPG : I<0x01, MRM7m, (outs), (ins i8mem:$addr), "invlpg\t$addr", []>, TB;
Sean Callanan108934c2009-12-18 00:01:26 +00004212
4213def STRr : I<0x00, MRM1r, (outs GR16:$dst), (ins),
4214 "str{w}\t{$dst}", []>, TB;
4215def STRm : I<0x00, MRM1m, (outs i16mem:$dst), (ins),
4216 "str{w}\t{$dst}", []>, TB;
4217def LTRr : I<0x00, MRM3r, (outs), (ins GR16:$src),
4218 "ltr{w}\t{$src}", []>, TB;
4219def LTRm : I<0x00, MRM3m, (outs), (ins i16mem:$src),
4220 "ltr{w}\t{$src}", []>, TB;
4221
4222def PUSHFS16 : I<0xa0, RawFrm, (outs), (ins),
4223 "push{w}\t%fs", []>, OpSize, TB;
4224def PUSHFS32 : I<0xa0, RawFrm, (outs), (ins),
4225 "push{l}\t%fs", []>, TB;
4226def PUSHGS16 : I<0xa8, RawFrm, (outs), (ins),
4227 "push{w}\t%gs", []>, OpSize, TB;
4228def PUSHGS32 : I<0xa8, RawFrm, (outs), (ins),
4229 "push{l}\t%gs", []>, TB;
4230
4231def POPFS16 : I<0xa1, RawFrm, (outs), (ins),
4232 "pop{w}\t%fs", []>, OpSize, TB;
4233def POPFS32 : I<0xa1, RawFrm, (outs), (ins),
4234 "pop{l}\t%fs", []>, TB;
4235def POPGS16 : I<0xa9, RawFrm, (outs), (ins),
4236 "pop{w}\t%gs", []>, OpSize, TB;
4237def POPGS32 : I<0xa9, RawFrm, (outs), (ins),
4238 "pop{l}\t%gs", []>, TB;
4239
4240def LDS16rm : I<0xc5, MRMSrcMem, (outs GR16:$dst), (ins opaque32mem:$src),
4241 "lds{w}\t{$src, $dst|$dst, $src}", []>, OpSize;
4242def LDS32rm : I<0xc5, MRMSrcMem, (outs GR32:$dst), (ins opaque48mem:$src),
4243 "lds{l}\t{$src, $dst|$dst, $src}", []>;
4244def LSS16rm : I<0xb2, MRMSrcMem, (outs GR16:$dst), (ins opaque32mem:$src),
4245 "lss{w}\t{$src, $dst|$dst, $src}", []>, TB, OpSize;
4246def LSS32rm : I<0xb2, MRMSrcMem, (outs GR32:$dst), (ins opaque48mem:$src),
4247 "lss{l}\t{$src, $dst|$dst, $src}", []>, TB;
4248def LES16rm : I<0xc4, MRMSrcMem, (outs GR16:$dst), (ins opaque32mem:$src),
4249 "les{w}\t{$src, $dst|$dst, $src}", []>, OpSize;
4250def LES32rm : I<0xc4, MRMSrcMem, (outs GR32:$dst), (ins opaque48mem:$src),
4251 "les{l}\t{$src, $dst|$dst, $src}", []>;
4252def LFS16rm : I<0xb4, MRMSrcMem, (outs GR16:$dst), (ins opaque32mem:$src),
4253 "lfs{w}\t{$src, $dst|$dst, $src}", []>, TB, OpSize;
4254def LFS32rm : I<0xb4, MRMSrcMem, (outs GR32:$dst), (ins opaque48mem:$src),
4255 "lfs{l}\t{$src, $dst|$dst, $src}", []>, TB;
4256def LGS16rm : I<0xb5, MRMSrcMem, (outs GR16:$dst), (ins opaque32mem:$src),
4257 "lgs{w}\t{$src, $dst|$dst, $src}", []>, TB, OpSize;
4258def LGS32rm : I<0xb5, MRMSrcMem, (outs GR32:$dst), (ins opaque48mem:$src),
4259 "lgs{l}\t{$src, $dst|$dst, $src}", []>, TB;
4260
4261def VERRr : I<0x00, MRM4r, (outs), (ins GR16:$seg),
4262 "verr\t$seg", []>, TB;
4263def VERRm : I<0x00, MRM4m, (outs), (ins i16mem:$seg),
4264 "verr\t$seg", []>, TB;
4265def VERWr : I<0x00, MRM5r, (outs), (ins GR16:$seg),
4266 "verw\t$seg", []>, TB;
4267def VERWm : I<0x00, MRM5m, (outs), (ins i16mem:$seg),
4268 "verw\t$seg", []>, TB;
4269
4270// Descriptor-table support instructions
4271
4272def SGDTm : I<0x01, MRM0m, (outs opaque48mem:$dst), (ins),
4273 "sgdt\t$dst", []>, TB;
4274def SIDTm : I<0x01, MRM1m, (outs opaque48mem:$dst), (ins),
4275 "sidt\t$dst", []>, TB;
4276def SLDT16r : I<0x00, MRM0r, (outs GR16:$dst), (ins),
4277 "sldt{w}\t$dst", []>, TB;
4278def SLDT16m : I<0x00, MRM0m, (outs i16mem:$dst), (ins),
4279 "sldt{w}\t$dst", []>, TB;
4280def LGDTm : I<0x01, MRM2m, (outs), (ins opaque48mem:$src),
4281 "lgdt\t$src", []>, TB;
4282def LIDTm : I<0x01, MRM3m, (outs), (ins opaque48mem:$src),
4283 "lidt\t$src", []>, TB;
4284def LLDT16r : I<0x00, MRM2r, (outs), (ins GR16:$src),
4285 "lldt{w}\t$src", []>, TB;
4286def LLDT16m : I<0x00, MRM2m, (outs), (ins i16mem:$src),
4287 "lldt{w}\t$src", []>, TB;
Sean Callanan9a86f102009-09-16 22:59:28 +00004288
Kevin Enderby12ce0de2010-02-03 21:04:42 +00004289// Lock instruction prefix
4290def LOCK_PREFIX : I<0xF0, RawFrm, (outs), (ins), "lock", []>;
4291
4292// Repeat string operation instruction prefixes
4293// These uses the DF flag in the EFLAGS register to inc or dec ECX
4294let Defs = [ECX], Uses = [ECX,EFLAGS] in {
4295// Repeat (used with INS, OUTS, MOVS, LODS and STOS)
4296def REP_PREFIX : I<0xF3, RawFrm, (outs), (ins), "rep", []>;
4297// Repeat while not equal (used with CMPS and SCAS)
4298def REPNE_PREFIX : I<0xF2, RawFrm, (outs), (ins), "repne", []>;
4299}
4300
4301// Segment override instruction prefixes
4302def CS_PREFIX : I<0x2E, RawFrm, (outs), (ins), "cs", []>;
4303def SS_PREFIX : I<0x36, RawFrm, (outs), (ins), "ss", []>;
4304def DS_PREFIX : I<0x3E, RawFrm, (outs), (ins), "ds", []>;
4305def ES_PREFIX : I<0x26, RawFrm, (outs), (ins), "es", []>;
4306def FS_PREFIX : I<0x64, RawFrm, (outs), (ins), "fs", []>;
4307def GS_PREFIX : I<0x65, RawFrm, (outs), (ins), "gs", []>;
4308
Sean Callanan9a86f102009-09-16 22:59:28 +00004309// String manipulation instructions
4310
4311def LODSB : I<0xAC, RawFrm, (outs), (ins), "lodsb", []>;
4312def LODSW : I<0xAD, RawFrm, (outs), (ins), "lodsw", []>, OpSize;
Sean Callanan108934c2009-12-18 00:01:26 +00004313def LODSD : I<0xAD, RawFrm, (outs), (ins), "lods{l|d}", []>;
4314
4315def OUTSB : I<0x6E, RawFrm, (outs), (ins), "outsb", []>;
4316def OUTSW : I<0x6F, RawFrm, (outs), (ins), "outsw", []>, OpSize;
4317def OUTSD : I<0x6F, RawFrm, (outs), (ins), "outs{l|d}", []>;
4318
4319// CPU flow control instructions
4320
4321def HLT : I<0xF4, RawFrm, (outs), (ins), "hlt", []>;
4322def RSM : I<0xAA, RawFrm, (outs), (ins), "rsm", []>, TB;
4323
4324// FPU control instructions
4325
4326def FNINIT : I<0xE3, RawFrm, (outs), (ins), "fninit", []>, DB;
4327
4328// Flag instructions
4329
4330def CLC : I<0xF8, RawFrm, (outs), (ins), "clc", []>;
4331def STC : I<0xF9, RawFrm, (outs), (ins), "stc", []>;
4332def CLI : I<0xFA, RawFrm, (outs), (ins), "cli", []>;
4333def STI : I<0xFB, RawFrm, (outs), (ins), "sti", []>;
4334def CLD : I<0xFC, RawFrm, (outs), (ins), "cld", []>;
4335def STD : I<0xFD, RawFrm, (outs), (ins), "std", []>;
4336def CMC : I<0xF5, RawFrm, (outs), (ins), "cmc", []>;
4337
4338def CLTS : I<0x06, RawFrm, (outs), (ins), "clts", []>, TB;
4339
4340// Table lookup instructions
4341
4342def XLAT : I<0xD7, RawFrm, (outs), (ins), "xlatb", []>;
4343
4344// Specialized register support
4345
4346def WRMSR : I<0x30, RawFrm, (outs), (ins), "wrmsr", []>, TB;
4347def RDMSR : I<0x32, RawFrm, (outs), (ins), "rdmsr", []>, TB;
4348def RDPMC : I<0x33, RawFrm, (outs), (ins), "rdpmc", []>, TB;
4349
4350def SMSW16r : I<0x01, MRM4r, (outs GR16:$dst), (ins),
4351 "smsw{w}\t$dst", []>, OpSize, TB;
4352def SMSW32r : I<0x01, MRM4r, (outs GR32:$dst), (ins),
4353 "smsw{l}\t$dst", []>, TB;
4354// For memory operands, there is only a 16-bit form
4355def SMSW16m : I<0x01, MRM4m, (outs i16mem:$dst), (ins),
4356 "smsw{w}\t$dst", []>, TB;
4357
4358def LMSW16r : I<0x01, MRM6r, (outs), (ins GR16:$src),
4359 "lmsw{w}\t$src", []>, TB;
4360def LMSW16m : I<0x01, MRM6m, (outs), (ins i16mem:$src),
4361 "lmsw{w}\t$src", []>, TB;
4362
4363def CPUID : I<0xA2, RawFrm, (outs), (ins), "cpuid", []>, TB;
4364
4365// Cache instructions
4366
4367def INVD : I<0x08, RawFrm, (outs), (ins), "invd", []>, TB;
4368def WBINVD : I<0x09, RawFrm, (outs), (ins), "wbinvd", []>, TB;
4369
4370// VMX instructions
4371
4372// 66 0F 38 80
Sean Callanan95a5a7d2010-02-13 01:48:34 +00004373def INVEPT : I<0x80, RawFrm, (outs), (ins), "invept", []>, OpSize, T8;
Sean Callanan108934c2009-12-18 00:01:26 +00004374// 66 0F 38 81
Sean Callanan95a5a7d2010-02-13 01:48:34 +00004375def INVVPID : I<0x81, RawFrm, (outs), (ins), "invvpid", []>, OpSize, T8;
Sean Callanan108934c2009-12-18 00:01:26 +00004376// 0F 01 C1
Chris Lattnerfdfeb692010-02-12 20:49:41 +00004377def VMCALL : I<0x01, MRM_C1, (outs), (ins), "vmcall", []>, TB;
Sean Callanan108934c2009-12-18 00:01:26 +00004378def VMCLEARm : I<0xC7, MRM6m, (outs), (ins i64mem:$vmcs),
4379 "vmclear\t$vmcs", []>, OpSize, TB;
4380// 0F 01 C2
Chris Lattnera599de22010-02-13 00:41:14 +00004381def VMLAUNCH : I<0x01, MRM_C2, (outs), (ins), "vmlaunch", []>, TB;
Sean Callanan108934c2009-12-18 00:01:26 +00004382// 0F 01 C3
Chris Lattnera599de22010-02-13 00:41:14 +00004383def VMRESUME : I<0x01, MRM_C3, (outs), (ins), "vmresume", []>, TB;
Sean Callanan108934c2009-12-18 00:01:26 +00004384def VMPTRLDm : I<0xC7, MRM6m, (outs), (ins i64mem:$vmcs),
4385 "vmptrld\t$vmcs", []>, TB;
4386def VMPTRSTm : I<0xC7, MRM7m, (outs i64mem:$vmcs), (ins),
4387 "vmptrst\t$vmcs", []>, TB;
4388def VMREAD64rm : I<0x78, MRMDestMem, (outs i64mem:$dst), (ins GR64:$src),
4389 "vmread{q}\t{$src, $dst|$dst, $src}", []>, TB;
4390def VMREAD64rr : I<0x78, MRMDestReg, (outs GR64:$dst), (ins GR64:$src),
4391 "vmread{q}\t{$src, $dst|$dst, $src}", []>, TB;
4392def VMREAD32rm : I<0x78, MRMDestMem, (outs i32mem:$dst), (ins GR32:$src),
4393 "vmread{l}\t{$src, $dst|$dst, $src}", []>, TB;
4394def VMREAD32rr : I<0x78, MRMDestReg, (outs GR32:$dst), (ins GR32:$src),
4395 "vmread{l}\t{$src, $dst|$dst, $src}", []>, TB;
4396def VMWRITE64rm : I<0x79, MRMSrcMem, (outs GR64:$dst), (ins i64mem:$src),
4397 "vmwrite{q}\t{$src, $dst|$dst, $src}", []>, TB;
4398def VMWRITE64rr : I<0x79, MRMSrcReg, (outs GR64:$dst), (ins GR64:$src),
4399 "vmwrite{q}\t{$src, $dst|$dst, $src}", []>, TB;
4400def VMWRITE32rm : I<0x79, MRMSrcMem, (outs GR32:$dst), (ins i32mem:$src),
4401 "vmwrite{l}\t{$src, $dst|$dst, $src}", []>, TB;
4402def VMWRITE32rr : I<0x79, MRMSrcReg, (outs GR32:$dst), (ins GR32:$src),
4403 "vmwrite{l}\t{$src, $dst|$dst, $src}", []>, TB;
4404// 0F 01 C4
Chris Lattnera599de22010-02-13 00:41:14 +00004405def VMXOFF : I<0x01, MRM_C4, (outs), (ins), "vmxoff", []>, TB;
Sean Callanan108934c2009-12-18 00:01:26 +00004406def VMXON : I<0xC7, MRM6m, (outs), (ins i64mem:$vmxon),
Kevin Enderby0e822402010-03-08 22:17:26 +00004407 "vmxon\t{$vmxon}", []>, XS;
Sean Callanan358f1ef2009-09-16 21:55:34 +00004408
Andrew Lenharthab0b9492008-02-21 06:45:13 +00004409//===----------------------------------------------------------------------===//
Evan Cheng510e4782006-01-09 23:10:28 +00004410// Non-Instruction Patterns
4411//===----------------------------------------------------------------------===//
4412
Bill Wendling056292f2008-09-16 21:48:12 +00004413// ConstantPool GlobalAddress, ExternalSymbol, and JumpTable
Evan Cheng71fb8342006-02-25 10:02:21 +00004414def : Pat<(i32 (X86Wrapper tconstpool :$dst)), (MOV32ri tconstpool :$dst)>;
Nate Begeman37efe672006-04-22 18:53:45 +00004415def : Pat<(i32 (X86Wrapper tjumptable :$dst)), (MOV32ri tjumptable :$dst)>;
Nate Begeman6795ebb2008-04-12 00:47:57 +00004416def : Pat<(i32 (X86Wrapper tglobaltlsaddr:$dst)),(MOV32ri tglobaltlsaddr:$dst)>;
Evan Cheng71fb8342006-02-25 10:02:21 +00004417def : Pat<(i32 (X86Wrapper tglobaladdr :$dst)), (MOV32ri tglobaladdr :$dst)>;
4418def : Pat<(i32 (X86Wrapper texternalsym:$dst)), (MOV32ri texternalsym:$dst)>;
Dan Gohmanf705adb2009-10-30 01:28:02 +00004419def : Pat<(i32 (X86Wrapper tblockaddress:$dst)), (MOV32ri tblockaddress:$dst)>;
Evan Cheng71fb8342006-02-25 10:02:21 +00004420
Evan Cheng069287d2006-05-16 07:21:53 +00004421def : Pat<(add GR32:$src1, (X86Wrapper tconstpool:$src2)),
4422 (ADD32ri GR32:$src1, tconstpool:$src2)>;
4423def : Pat<(add GR32:$src1, (X86Wrapper tjumptable:$src2)),
4424 (ADD32ri GR32:$src1, tjumptable:$src2)>;
4425def : Pat<(add GR32:$src1, (X86Wrapper tglobaladdr :$src2)),
4426 (ADD32ri GR32:$src1, tglobaladdr:$src2)>;
4427def : Pat<(add GR32:$src1, (X86Wrapper texternalsym:$src2)),
4428 (ADD32ri GR32:$src1, texternalsym:$src2)>;
Dan Gohmanf705adb2009-10-30 01:28:02 +00004429def : Pat<(add GR32:$src1, (X86Wrapper tblockaddress:$src2)),
4430 (ADD32ri GR32:$src1, tblockaddress:$src2)>;
Evan Cheng71fb8342006-02-25 10:02:21 +00004431
Evan Chengfc8feb12006-05-19 07:30:36 +00004432def : Pat<(store (i32 (X86Wrapper tglobaladdr:$src)), addr:$dst),
Evan Cheng71fb8342006-02-25 10:02:21 +00004433 (MOV32mi addr:$dst, tglobaladdr:$src)>;
Evan Chengfc8feb12006-05-19 07:30:36 +00004434def : Pat<(store (i32 (X86Wrapper texternalsym:$src)), addr:$dst),
Evan Cheng71fb8342006-02-25 10:02:21 +00004435 (MOV32mi addr:$dst, texternalsym:$src)>;
Dan Gohmanf705adb2009-10-30 01:28:02 +00004436def : Pat<(store (i32 (X86Wrapper tblockaddress:$src)), addr:$dst),
4437 (MOV32mi addr:$dst, tblockaddress:$src)>;
Evan Cheng71fb8342006-02-25 10:02:21 +00004438
Evan Cheng510e4782006-01-09 23:10:28 +00004439// Calls
Arnold Schwaighoferc85e1712007-10-11 19:40:01 +00004440// tailcall stuff
Evan Chengf48ef032010-03-14 03:48:46 +00004441def : Pat<(X86tcret GR32_TC:$dst, imm:$off),
4442 (TCRETURNri GR32_TC:$dst, imm:$off)>,
4443 Requires<[In32BitMode]>;
4444
Evan Chengcb0f06e2010-03-25 00:10:31 +00004445// FIXME: This is disabled for 32-bit PIC mode because the global base
4446// register which is part of the address mode may be assigned a
4447// callee-saved register.
Evan Chengf48ef032010-03-14 03:48:46 +00004448def : Pat<(X86tcret (load addr:$dst), imm:$off),
4449 (TCRETURNmi addr:$dst, imm:$off)>,
Evan Chengcb0f06e2010-03-25 00:10:31 +00004450 Requires<[In32BitMode, IsNotPIC]>;
Arnold Schwaighoferc85e1712007-10-11 19:40:01 +00004451
4452def : Pat<(X86tcret (i32 tglobaladdr:$dst), imm:$off),
Evan Chengf48ef032010-03-14 03:48:46 +00004453 (TCRETURNdi texternalsym:$dst, imm:$off)>,
4454 Requires<[In32BitMode]>;
Arnold Schwaighoferc85e1712007-10-11 19:40:01 +00004455
4456def : Pat<(X86tcret (i32 texternalsym:$dst), imm:$off),
Evan Chengf48ef032010-03-14 03:48:46 +00004457 (TCRETURNdi texternalsym:$dst, imm:$off)>,
4458 Requires<[In32BitMode]>;
Evan Chengfea89c12006-04-27 08:40:39 +00004459
Dan Gohmancadb2262009-08-02 16:10:01 +00004460// Normal calls, with various flavors of addresses.
Evan Cheng25ab6902006-09-08 06:48:29 +00004461def : Pat<(X86call (i32 tglobaladdr:$dst)),
Evan Cheng510e4782006-01-09 23:10:28 +00004462 (CALLpcrel32 tglobaladdr:$dst)>;
Evan Cheng25ab6902006-09-08 06:48:29 +00004463def : Pat<(X86call (i32 texternalsym:$dst)),
Evan Cheng8700e142006-01-11 06:09:51 +00004464 (CALLpcrel32 texternalsym:$dst)>;
Evan Chengd7f666a2009-05-20 04:53:57 +00004465def : Pat<(X86call (i32 imm:$dst)),
4466 (CALLpcrel32 imm:$dst)>, Requires<[CallImmAddr]>;
Evan Cheng510e4782006-01-09 23:10:28 +00004467
4468// X86 specific add which produces a flag.
Evan Cheng069287d2006-05-16 07:21:53 +00004469def : Pat<(addc GR32:$src1, GR32:$src2),
4470 (ADD32rr GR32:$src1, GR32:$src2)>;
4471def : Pat<(addc GR32:$src1, (load addr:$src2)),
4472 (ADD32rm GR32:$src1, addr:$src2)>;
4473def : Pat<(addc GR32:$src1, imm:$src2),
4474 (ADD32ri GR32:$src1, imm:$src2)>;
4475def : Pat<(addc GR32:$src1, i32immSExt8:$src2),
4476 (ADD32ri8 GR32:$src1, i32immSExt8:$src2)>;
Evan Cheng510e4782006-01-09 23:10:28 +00004477
Evan Cheng069287d2006-05-16 07:21:53 +00004478def : Pat<(subc GR32:$src1, GR32:$src2),
4479 (SUB32rr GR32:$src1, GR32:$src2)>;
4480def : Pat<(subc GR32:$src1, (load addr:$src2)),
4481 (SUB32rm GR32:$src1, addr:$src2)>;
4482def : Pat<(subc GR32:$src1, imm:$src2),
4483 (SUB32ri GR32:$src1, imm:$src2)>;
4484def : Pat<(subc GR32:$src1, i32immSExt8:$src2),
4485 (SUB32ri8 GR32:$src1, i32immSExt8:$src2)>;
Evan Cheng510e4782006-01-09 23:10:28 +00004486
Chris Lattnerffc0b262006-09-07 20:33:45 +00004487// Comparisons.
4488
4489// TEST R,R is smaller than CMP R,0
Chris Lattnere3486a42010-03-19 00:01:11 +00004490def : Pat<(X86cmp GR8:$src1, 0),
Chris Lattnerffc0b262006-09-07 20:33:45 +00004491 (TEST8rr GR8:$src1, GR8:$src1)>;
Chris Lattnere3486a42010-03-19 00:01:11 +00004492def : Pat<(X86cmp GR16:$src1, 0),
Chris Lattnerffc0b262006-09-07 20:33:45 +00004493 (TEST16rr GR16:$src1, GR16:$src1)>;
Chris Lattnere3486a42010-03-19 00:01:11 +00004494def : Pat<(X86cmp GR32:$src1, 0),
Chris Lattnerffc0b262006-09-07 20:33:45 +00004495 (TEST32rr GR32:$src1, GR32:$src1)>;
4496
Dan Gohmanfbb74862009-01-07 01:00:24 +00004497// Conditional moves with folded loads with operands swapped and conditions
4498// inverted.
4499def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_B, EFLAGS),
4500 (CMOVAE16rm GR16:$src2, addr:$src1)>;
4501def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_B, EFLAGS),
4502 (CMOVAE32rm GR32:$src2, addr:$src1)>;
4503def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_AE, EFLAGS),
4504 (CMOVB16rm GR16:$src2, addr:$src1)>;
4505def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_AE, EFLAGS),
4506 (CMOVB32rm GR32:$src2, addr:$src1)>;
4507def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_E, EFLAGS),
4508 (CMOVNE16rm GR16:$src2, addr:$src1)>;
4509def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_E, EFLAGS),
4510 (CMOVNE32rm GR32:$src2, addr:$src1)>;
4511def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_NE, EFLAGS),
4512 (CMOVE16rm GR16:$src2, addr:$src1)>;
4513def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_NE, EFLAGS),
4514 (CMOVE32rm GR32:$src2, addr:$src1)>;
4515def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_BE, EFLAGS),
4516 (CMOVA16rm GR16:$src2, addr:$src1)>;
4517def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_BE, EFLAGS),
4518 (CMOVA32rm GR32:$src2, addr:$src1)>;
4519def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_A, EFLAGS),
4520 (CMOVBE16rm GR16:$src2, addr:$src1)>;
4521def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_A, EFLAGS),
4522 (CMOVBE32rm GR32:$src2, addr:$src1)>;
4523def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_L, EFLAGS),
4524 (CMOVGE16rm GR16:$src2, addr:$src1)>;
4525def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_L, EFLAGS),
4526 (CMOVGE32rm GR32:$src2, addr:$src1)>;
4527def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_GE, EFLAGS),
4528 (CMOVL16rm GR16:$src2, addr:$src1)>;
4529def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_GE, EFLAGS),
4530 (CMOVL32rm GR32:$src2, addr:$src1)>;
4531def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_LE, EFLAGS),
4532 (CMOVG16rm GR16:$src2, addr:$src1)>;
4533def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_LE, EFLAGS),
4534 (CMOVG32rm GR32:$src2, addr:$src1)>;
4535def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_G, EFLAGS),
4536 (CMOVLE16rm GR16:$src2, addr:$src1)>;
4537def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_G, EFLAGS),
4538 (CMOVLE32rm GR32:$src2, addr:$src1)>;
4539def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_P, EFLAGS),
4540 (CMOVNP16rm GR16:$src2, addr:$src1)>;
4541def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_P, EFLAGS),
4542 (CMOVNP32rm GR32:$src2, addr:$src1)>;
4543def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_NP, EFLAGS),
4544 (CMOVP16rm GR16:$src2, addr:$src1)>;
4545def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_NP, EFLAGS),
4546 (CMOVP32rm GR32:$src2, addr:$src1)>;
4547def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_S, EFLAGS),
4548 (CMOVNS16rm GR16:$src2, addr:$src1)>;
4549def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_S, EFLAGS),
4550 (CMOVNS32rm GR32:$src2, addr:$src1)>;
4551def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_NS, EFLAGS),
4552 (CMOVS16rm GR16:$src2, addr:$src1)>;
4553def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_NS, EFLAGS),
4554 (CMOVS32rm GR32:$src2, addr:$src1)>;
4555def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_O, EFLAGS),
4556 (CMOVNO16rm GR16:$src2, addr:$src1)>;
4557def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_O, EFLAGS),
4558 (CMOVNO32rm GR32:$src2, addr:$src1)>;
4559def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_NO, EFLAGS),
4560 (CMOVO16rm GR16:$src2, addr:$src1)>;
4561def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_NO, EFLAGS),
4562 (CMOVO32rm GR32:$src2, addr:$src1)>;
4563
Duncan Sandsf9c98e62008-01-23 20:39:46 +00004564// zextload bool -> zextload byte
Evan Chenge5d93432006-01-17 07:02:46 +00004565def : Pat<(zextloadi8i1 addr:$src), (MOV8rm addr:$src)>;
Evan Cheng510e4782006-01-09 23:10:28 +00004566def : Pat<(zextloadi16i1 addr:$src), (MOVZX16rm8 addr:$src)>;
4567def : Pat<(zextloadi32i1 addr:$src), (MOVZX32rm8 addr:$src)>;
4568
4569// extload bool -> extload byte
Evan Cheng47137242006-05-05 08:23:07 +00004570def : Pat<(extloadi8i1 addr:$src), (MOV8rm addr:$src)>;
Dan Gohmanaf70e5c2009-08-26 14:59:13 +00004571def : Pat<(extloadi16i1 addr:$src), (MOVZX16rm8 addr:$src)>;
Evan Cheng47137242006-05-05 08:23:07 +00004572def : Pat<(extloadi32i1 addr:$src), (MOVZX32rm8 addr:$src)>;
Dan Gohmanaf70e5c2009-08-26 14:59:13 +00004573def : Pat<(extloadi16i8 addr:$src), (MOVZX16rm8 addr:$src)>;
Evan Cheng47137242006-05-05 08:23:07 +00004574def : Pat<(extloadi32i8 addr:$src), (MOVZX32rm8 addr:$src)>;
4575def : Pat<(extloadi32i16 addr:$src), (MOVZX32rm16 addr:$src)>;
Evan Cheng510e4782006-01-09 23:10:28 +00004576
Dan Gohmanaf70e5c2009-08-26 14:59:13 +00004577// anyext. Define these to do an explicit zero-extend to
4578// avoid partial-register updates.
4579def : Pat<(i16 (anyext GR8 :$src)), (MOVZX16rr8 GR8 :$src)>;
4580def : Pat<(i32 (anyext GR8 :$src)), (MOVZX32rr8 GR8 :$src)>;
Evan Cheng5528e7b2010-04-21 01:47:12 +00004581
Evan Cheng2bce5f4b2010-04-28 08:30:49 +00004582// Except for i16 -> i32 since isel expect i16 ops to be promoted to i32.
Evan Cheng5528e7b2010-04-21 01:47:12 +00004583def : Pat<(i32 (anyext GR16:$src)),
Jakob Stoklund Olesen3458e9e2010-05-24 14:48:17 +00004584 (INSERT_SUBREG (i32 (IMPLICIT_DEF)), GR16:$src, sub_16bit)>;
Evan Cheng5528e7b2010-04-21 01:47:12 +00004585
Evan Cheng510e4782006-01-09 23:10:28 +00004586
Evan Chengcfa260b2006-01-06 02:31:59 +00004587//===----------------------------------------------------------------------===//
4588// Some peepholes
4589//===----------------------------------------------------------------------===//
4590
Dan Gohman63f97202008-10-17 01:33:43 +00004591// Odd encoding trick: -128 fits into an 8-bit immediate field while
4592// +128 doesn't, so in this special case use a sub instead of an add.
4593def : Pat<(add GR16:$src1, 128),
4594 (SUB16ri8 GR16:$src1, -128)>;
4595def : Pat<(store (add (loadi16 addr:$dst), 128), addr:$dst),
4596 (SUB16mi8 addr:$dst, -128)>;
4597def : Pat<(add GR32:$src1, 128),
4598 (SUB32ri8 GR32:$src1, -128)>;
4599def : Pat<(store (add (loadi32 addr:$dst), 128), addr:$dst),
4600 (SUB32mi8 addr:$dst, -128)>;
4601
Dan Gohman11ba3b12008-07-30 18:09:17 +00004602// r & (2^16-1) ==> movz
4603def : Pat<(and GR32:$src1, 0xffff),
Jakob Stoklund Olesen3458e9e2010-05-24 14:48:17 +00004604 (MOVZX32rr16 (EXTRACT_SUBREG GR32:$src1, sub_16bit))>;
Dan Gohman8a1510d2008-08-06 18:27:21 +00004605// r & (2^8-1) ==> movz
4606def : Pat<(and GR32:$src1, 0xff),
Anton Korobeynikov3a639a02009-11-02 00:11:39 +00004607 (MOVZX32rr8 (EXTRACT_SUBREG (i32 (COPY_TO_REGCLASS GR32:$src1,
4608 GR32_ABCD)),
Jakob Stoklund Olesen3458e9e2010-05-24 14:48:17 +00004609 sub_8bit))>,
Dan Gohman8a1510d2008-08-06 18:27:21 +00004610 Requires<[In32BitMode]>;
4611// r & (2^8-1) ==> movz
4612def : Pat<(and GR16:$src1, 0xff),
Anton Korobeynikov3a639a02009-11-02 00:11:39 +00004613 (MOVZX16rr8 (EXTRACT_SUBREG (i16 (COPY_TO_REGCLASS GR16:$src1,
4614 GR16_ABCD)),
Jakob Stoklund Olesen3458e9e2010-05-24 14:48:17 +00004615 sub_8bit))>,
Dan Gohman0bfa1bf2008-08-20 21:27:32 +00004616 Requires<[In32BitMode]>;
4617
4618// sext_inreg patterns
4619def : Pat<(sext_inreg GR32:$src, i16),
Jakob Stoklund Olesen3458e9e2010-05-24 14:48:17 +00004620 (MOVSX32rr16 (EXTRACT_SUBREG GR32:$src, sub_16bit))>;
Dan Gohman0bfa1bf2008-08-20 21:27:32 +00004621def : Pat<(sext_inreg GR32:$src, i8),
Anton Korobeynikov3a639a02009-11-02 00:11:39 +00004622 (MOVSX32rr8 (EXTRACT_SUBREG (i32 (COPY_TO_REGCLASS GR32:$src,
4623 GR32_ABCD)),
Jakob Stoklund Olesen3458e9e2010-05-24 14:48:17 +00004624 sub_8bit))>,
Dan Gohman0bfa1bf2008-08-20 21:27:32 +00004625 Requires<[In32BitMode]>;
4626def : Pat<(sext_inreg GR16:$src, i8),
Anton Korobeynikov3a639a02009-11-02 00:11:39 +00004627 (MOVSX16rr8 (EXTRACT_SUBREG (i16 (COPY_TO_REGCLASS GR16:$src,
4628 GR16_ABCD)),
Jakob Stoklund Olesen3458e9e2010-05-24 14:48:17 +00004629 sub_8bit))>,
Dan Gohman0bfa1bf2008-08-20 21:27:32 +00004630 Requires<[In32BitMode]>;
4631
4632// trunc patterns
4633def : Pat<(i16 (trunc GR32:$src)),
Jakob Stoklund Olesen3458e9e2010-05-24 14:48:17 +00004634 (EXTRACT_SUBREG GR32:$src, sub_16bit)>;
Dan Gohman0bfa1bf2008-08-20 21:27:32 +00004635def : Pat<(i8 (trunc GR32:$src)),
Anton Korobeynikov3a639a02009-11-02 00:11:39 +00004636 (EXTRACT_SUBREG (i32 (COPY_TO_REGCLASS GR32:$src, GR32_ABCD)),
Jakob Stoklund Olesen3458e9e2010-05-24 14:48:17 +00004637 sub_8bit)>,
Dan Gohman0bfa1bf2008-08-20 21:27:32 +00004638 Requires<[In32BitMode]>;
4639def : Pat<(i8 (trunc GR16:$src)),
Anton Korobeynikov3a639a02009-11-02 00:11:39 +00004640 (EXTRACT_SUBREG (i16 (COPY_TO_REGCLASS GR16:$src, GR16_ABCD)),
Jakob Stoklund Olesen3458e9e2010-05-24 14:48:17 +00004641 sub_8bit)>,
Dan Gohman21e3dfb2009-04-13 16:09:41 +00004642 Requires<[In32BitMode]>;
4643
4644// h-register tricks
4645def : Pat<(i8 (trunc (srl_su GR16:$src, (i8 8)))),
Evan Cheng1c45acf2010-04-27 21:46:03 +00004646 (EXTRACT_SUBREG (i16 (COPY_TO_REGCLASS GR16:$src, GR16_ABCD)),
Jakob Stoklund Olesen3458e9e2010-05-24 14:48:17 +00004647 sub_8bit_hi)>,
Dan Gohman21e3dfb2009-04-13 16:09:41 +00004648 Requires<[In32BitMode]>;
4649def : Pat<(i8 (trunc (srl_su GR32:$src, (i8 8)))),
Evan Cheng1c45acf2010-04-27 21:46:03 +00004650 (EXTRACT_SUBREG (i32 (COPY_TO_REGCLASS GR32:$src, GR32_ABCD)),
Jakob Stoklund Olesen3458e9e2010-05-24 14:48:17 +00004651 sub_8bit_hi)>,
Dan Gohman21e3dfb2009-04-13 16:09:41 +00004652 Requires<[In32BitMode]>;
Dan Gohman7e0d64a2010-01-11 17:21:05 +00004653def : Pat<(srl GR16:$src, (i8 8)),
Dan Gohman21e3dfb2009-04-13 16:09:41 +00004654 (EXTRACT_SUBREG
4655 (MOVZX32rr8
Anton Korobeynikov3a639a02009-11-02 00:11:39 +00004656 (EXTRACT_SUBREG (i16 (COPY_TO_REGCLASS GR16:$src, GR16_ABCD)),
Jakob Stoklund Olesen3458e9e2010-05-24 14:48:17 +00004657 sub_8bit_hi)),
4658 sub_16bit)>,
Dan Gohman21e3dfb2009-04-13 16:09:41 +00004659 Requires<[In32BitMode]>;
Evan Chengcb219f02009-05-29 01:44:43 +00004660def : Pat<(i32 (zext (srl_su GR16:$src, (i8 8)))),
Sean Callanan108934c2009-12-18 00:01:26 +00004661 (MOVZX32rr8 (EXTRACT_SUBREG (i16 (COPY_TO_REGCLASS GR16:$src,
4662 GR16_ABCD)),
Jakob Stoklund Olesen3458e9e2010-05-24 14:48:17 +00004663 sub_8bit_hi))>,
Evan Chengcb219f02009-05-29 01:44:43 +00004664 Requires<[In32BitMode]>;
Dan Gohmanaf70e5c2009-08-26 14:59:13 +00004665def : Pat<(i32 (anyext (srl_su GR16:$src, (i8 8)))),
Sean Callanan108934c2009-12-18 00:01:26 +00004666 (MOVZX32rr8 (EXTRACT_SUBREG (i16 (COPY_TO_REGCLASS GR16:$src,
4667 GR16_ABCD)),
Jakob Stoklund Olesen3458e9e2010-05-24 14:48:17 +00004668 sub_8bit_hi))>,
Dan Gohmanaf70e5c2009-08-26 14:59:13 +00004669 Requires<[In32BitMode]>;
Dan Gohman21e3dfb2009-04-13 16:09:41 +00004670def : Pat<(and (srl_su GR32:$src, (i8 8)), (i32 255)),
Sean Callanan108934c2009-12-18 00:01:26 +00004671 (MOVZX32rr8 (EXTRACT_SUBREG (i32 (COPY_TO_REGCLASS GR32:$src,
4672 GR32_ABCD)),
Jakob Stoklund Olesen3458e9e2010-05-24 14:48:17 +00004673 sub_8bit_hi))>,
Dan Gohman8a1510d2008-08-06 18:27:21 +00004674 Requires<[In32BitMode]>;
Evan Cheng2bce5f4b2010-04-28 08:30:49 +00004675def : Pat<(srl (and_su GR32:$src, 0xff00), (i8 8)),
4676 (MOVZX32rr8 (EXTRACT_SUBREG (i32 (COPY_TO_REGCLASS GR32:$src,
4677 GR32_ABCD)),
Jakob Stoklund Olesen3458e9e2010-05-24 14:48:17 +00004678 sub_8bit_hi))>,
Evan Cheng2bce5f4b2010-04-28 08:30:49 +00004679 Requires<[In32BitMode]>;
Dan Gohman11ba3b12008-07-30 18:09:17 +00004680
Evan Chengcfa260b2006-01-06 02:31:59 +00004681// (shl x, 1) ==> (add x, x)
Evan Cheng069287d2006-05-16 07:21:53 +00004682def : Pat<(shl GR8 :$src1, (i8 1)), (ADD8rr GR8 :$src1, GR8 :$src1)>;
4683def : Pat<(shl GR16:$src1, (i8 1)), (ADD16rr GR16:$src1, GR16:$src1)>;
4684def : Pat<(shl GR32:$src1, (i8 1)), (ADD32rr GR32:$src1, GR32:$src1)>;
Evan Cheng68b951a2006-01-19 01:56:29 +00004685
Evan Chengeb9f8922008-08-30 02:03:58 +00004686// (shl x (and y, 31)) ==> (shl x, y)
Chris Lattner6d9f86b2010-02-23 06:54:29 +00004687def : Pat<(shl GR8:$src1, (and CL, 31)),
Evan Chengeb9f8922008-08-30 02:03:58 +00004688 (SHL8rCL GR8:$src1)>;
Chris Lattner6d9f86b2010-02-23 06:54:29 +00004689def : Pat<(shl GR16:$src1, (and CL, 31)),
Evan Chengeb9f8922008-08-30 02:03:58 +00004690 (SHL16rCL GR16:$src1)>;
Chris Lattner6d9f86b2010-02-23 06:54:29 +00004691def : Pat<(shl GR32:$src1, (and CL, 31)),
Evan Chengeb9f8922008-08-30 02:03:58 +00004692 (SHL32rCL GR32:$src1)>;
Chris Lattner6d9f86b2010-02-23 06:54:29 +00004693def : Pat<(store (shl (loadi8 addr:$dst), (and CL, 31)), addr:$dst),
Evan Chengeb9f8922008-08-30 02:03:58 +00004694 (SHL8mCL addr:$dst)>;
Chris Lattner6d9f86b2010-02-23 06:54:29 +00004695def : Pat<(store (shl (loadi16 addr:$dst), (and CL, 31)), addr:$dst),
Evan Chengeb9f8922008-08-30 02:03:58 +00004696 (SHL16mCL addr:$dst)>;
Chris Lattner6d9f86b2010-02-23 06:54:29 +00004697def : Pat<(store (shl (loadi32 addr:$dst), (and CL, 31)), addr:$dst),
Evan Chengeb9f8922008-08-30 02:03:58 +00004698 (SHL32mCL addr:$dst)>;
4699
Chris Lattner6d9f86b2010-02-23 06:54:29 +00004700def : Pat<(srl GR8:$src1, (and CL, 31)),
Evan Chengeb9f8922008-08-30 02:03:58 +00004701 (SHR8rCL GR8:$src1)>;
Chris Lattner6d9f86b2010-02-23 06:54:29 +00004702def : Pat<(srl GR16:$src1, (and CL, 31)),
Evan Chengeb9f8922008-08-30 02:03:58 +00004703 (SHR16rCL GR16:$src1)>;
Chris Lattner6d9f86b2010-02-23 06:54:29 +00004704def : Pat<(srl GR32:$src1, (and CL, 31)),
Evan Chengeb9f8922008-08-30 02:03:58 +00004705 (SHR32rCL GR32:$src1)>;
Chris Lattner6d9f86b2010-02-23 06:54:29 +00004706def : Pat<(store (srl (loadi8 addr:$dst), (and CL, 31)), addr:$dst),
Evan Chengeb9f8922008-08-30 02:03:58 +00004707 (SHR8mCL addr:$dst)>;
Chris Lattner6d9f86b2010-02-23 06:54:29 +00004708def : Pat<(store (srl (loadi16 addr:$dst), (and CL, 31)), addr:$dst),
Evan Chengeb9f8922008-08-30 02:03:58 +00004709 (SHR16mCL addr:$dst)>;
Chris Lattner6d9f86b2010-02-23 06:54:29 +00004710def : Pat<(store (srl (loadi32 addr:$dst), (and CL, 31)), addr:$dst),
Evan Chengeb9f8922008-08-30 02:03:58 +00004711 (SHR32mCL addr:$dst)>;
4712
Chris Lattner6d9f86b2010-02-23 06:54:29 +00004713def : Pat<(sra GR8:$src1, (and CL, 31)),
Evan Chengeb9f8922008-08-30 02:03:58 +00004714 (SAR8rCL GR8:$src1)>;
Chris Lattner6d9f86b2010-02-23 06:54:29 +00004715def : Pat<(sra GR16:$src1, (and CL, 31)),
Evan Chengeb9f8922008-08-30 02:03:58 +00004716 (SAR16rCL GR16:$src1)>;
Chris Lattner6d9f86b2010-02-23 06:54:29 +00004717def : Pat<(sra GR32:$src1, (and CL, 31)),
Evan Chengeb9f8922008-08-30 02:03:58 +00004718 (SAR32rCL GR32:$src1)>;
Chris Lattner6d9f86b2010-02-23 06:54:29 +00004719def : Pat<(store (sra (loadi8 addr:$dst), (and CL, 31)), addr:$dst),
Evan Chengeb9f8922008-08-30 02:03:58 +00004720 (SAR8mCL addr:$dst)>;
Chris Lattner6d9f86b2010-02-23 06:54:29 +00004721def : Pat<(store (sra (loadi16 addr:$dst), (and CL, 31)), addr:$dst),
Evan Chengeb9f8922008-08-30 02:03:58 +00004722 (SAR16mCL addr:$dst)>;
Chris Lattner6d9f86b2010-02-23 06:54:29 +00004723def : Pat<(store (sra (loadi32 addr:$dst), (and CL, 31)), addr:$dst),
Evan Chengeb9f8922008-08-30 02:03:58 +00004724 (SAR32mCL addr:$dst)>;
4725
Evan Cheng2e489c42009-12-16 00:53:11 +00004726// (anyext (setcc_carry)) -> (setcc_carry)
4727def : Pat<(i16 (anyext (i8 (X86setcc_c X86_COND_B, EFLAGS)))),
Evan Chengad9c0a32009-12-15 00:53:42 +00004728 (SETB_C16r)>;
Evan Cheng2e489c42009-12-16 00:53:11 +00004729def : Pat<(i32 (anyext (i8 (X86setcc_c X86_COND_B, EFLAGS)))),
Evan Chengad9c0a32009-12-15 00:53:42 +00004730 (SETB_C32r)>;
Evan Chenge5b51ac2010-04-17 06:13:15 +00004731def : Pat<(i32 (anyext (i16 (X86setcc_c X86_COND_B, EFLAGS)))),
4732 (SETB_C32r)>;
Evan Chengad9c0a32009-12-15 00:53:42 +00004733
Evan Cheng199c4242010-01-11 22:03:29 +00004734// (or x1, x2) -> (add x1, x2) if two operands are known not to share bits.
Evan Cheng3bda2012010-01-12 18:31:19 +00004735let AddedComplexity = 5 in { // Try this before the selecting to OR
Chris Lattnera0f70172010-03-24 00:15:23 +00004736def : Pat<(or_is_add GR16:$src1, imm:$src2),
Evan Cheng4b0345b2010-01-11 17:03:47 +00004737 (ADD16ri GR16:$src1, imm:$src2)>;
Chris Lattnera0f70172010-03-24 00:15:23 +00004738def : Pat<(or_is_add GR32:$src1, imm:$src2),
Evan Cheng4b0345b2010-01-11 17:03:47 +00004739 (ADD32ri GR32:$src1, imm:$src2)>;
Chris Lattnera0f70172010-03-24 00:15:23 +00004740def : Pat<(or_is_add GR16:$src1, i16immSExt8:$src2),
Evan Cheng4b0345b2010-01-11 17:03:47 +00004741 (ADD16ri8 GR16:$src1, i16immSExt8:$src2)>;
Chris Lattnera0f70172010-03-24 00:15:23 +00004742def : Pat<(or_is_add GR32:$src1, i32immSExt8:$src2),
Evan Cheng4b0345b2010-01-11 17:03:47 +00004743 (ADD32ri8 GR32:$src1, i32immSExt8:$src2)>;
Chris Lattnera0f70172010-03-24 00:15:23 +00004744def : Pat<(or_is_add GR16:$src1, GR16:$src2),
Evan Cheng199c4242010-01-11 22:03:29 +00004745 (ADD16rr GR16:$src1, GR16:$src2)>;
Chris Lattnera0f70172010-03-24 00:15:23 +00004746def : Pat<(or_is_add GR32:$src1, GR32:$src2),
Evan Cheng199c4242010-01-11 22:03:29 +00004747 (ADD32rr GR32:$src1, GR32:$src2)>;
Evan Cheng3bda2012010-01-12 18:31:19 +00004748} // AddedComplexity
Evan Cheng4b0345b2010-01-11 17:03:47 +00004749
Evan Cheng4e4c71e2006-02-21 20:00:20 +00004750//===----------------------------------------------------------------------===//
Dan Gohman076aee32009-03-04 19:44:21 +00004751// EFLAGS-defining Patterns
Bill Wendlingd350e022008-12-12 21:15:41 +00004752//===----------------------------------------------------------------------===//
4753
Chris Lattnerec856802010-03-27 00:45:04 +00004754// add reg, reg
4755def : Pat<(add GR8 :$src1, GR8 :$src2), (ADD8rr GR8 :$src1, GR8 :$src2)>;
4756def : Pat<(add GR16:$src1, GR16:$src2), (ADD16rr GR16:$src1, GR16:$src2)>;
4757def : Pat<(add GR32:$src1, GR32:$src2), (ADD32rr GR32:$src1, GR32:$src2)>;
Bill Wendlingd350e022008-12-12 21:15:41 +00004758
Chris Lattnerec856802010-03-27 00:45:04 +00004759// add reg, mem
4760def : Pat<(add GR8:$src1, (loadi8 addr:$src2)),
Bill Wendlingd350e022008-12-12 21:15:41 +00004761 (ADD8rm GR8:$src1, addr:$src2)>;
Chris Lattnerec856802010-03-27 00:45:04 +00004762def : Pat<(add GR16:$src1, (loadi16 addr:$src2)),
Bill Wendlingd350e022008-12-12 21:15:41 +00004763 (ADD16rm GR16:$src1, addr:$src2)>;
Chris Lattnerec856802010-03-27 00:45:04 +00004764def : Pat<(add GR32:$src1, (loadi32 addr:$src2)),
Bill Wendlingd350e022008-12-12 21:15:41 +00004765 (ADD32rm GR32:$src1, addr:$src2)>;
4766
Chris Lattnerec856802010-03-27 00:45:04 +00004767// add reg, imm
4768def : Pat<(add GR8 :$src1, imm:$src2), (ADD8ri GR8:$src1 , imm:$src2)>;
4769def : Pat<(add GR16:$src1, imm:$src2), (ADD16ri GR16:$src1, imm:$src2)>;
4770def : Pat<(add GR32:$src1, imm:$src2), (ADD32ri GR32:$src1, imm:$src2)>;
4771def : Pat<(add GR16:$src1, i16immSExt8:$src2),
Bill Wendlingd350e022008-12-12 21:15:41 +00004772 (ADD16ri8 GR16:$src1, i16immSExt8:$src2)>;
Chris Lattnerec856802010-03-27 00:45:04 +00004773def : Pat<(add GR32:$src1, i32immSExt8:$src2),
Bill Wendlingd350e022008-12-12 21:15:41 +00004774 (ADD32ri8 GR32:$src1, i32immSExt8:$src2)>;
4775
Chris Lattnerec856802010-03-27 00:45:04 +00004776// sub reg, reg
4777def : Pat<(sub GR8 :$src1, GR8 :$src2), (SUB8rr GR8 :$src1, GR8 :$src2)>;
4778def : Pat<(sub GR16:$src1, GR16:$src2), (SUB16rr GR16:$src1, GR16:$src2)>;
4779def : Pat<(sub GR32:$src1, GR32:$src2), (SUB32rr GR32:$src1, GR32:$src2)>;
Bill Wendlingd350e022008-12-12 21:15:41 +00004780
Chris Lattnerec856802010-03-27 00:45:04 +00004781// sub reg, mem
4782def : Pat<(sub GR8:$src1, (loadi8 addr:$src2)),
Bill Wendlingd350e022008-12-12 21:15:41 +00004783 (SUB8rm GR8:$src1, addr:$src2)>;
Chris Lattnerec856802010-03-27 00:45:04 +00004784def : Pat<(sub GR16:$src1, (loadi16 addr:$src2)),
Bill Wendlingd350e022008-12-12 21:15:41 +00004785 (SUB16rm GR16:$src1, addr:$src2)>;
Chris Lattnerec856802010-03-27 00:45:04 +00004786def : Pat<(sub GR32:$src1, (loadi32 addr:$src2)),
Bill Wendlingd350e022008-12-12 21:15:41 +00004787 (SUB32rm GR32:$src1, addr:$src2)>;
4788
Chris Lattnerec856802010-03-27 00:45:04 +00004789// sub reg, imm
4790def : Pat<(sub GR8:$src1, imm:$src2),
Bill Wendlingd350e022008-12-12 21:15:41 +00004791 (SUB8ri GR8:$src1, imm:$src2)>;
Chris Lattnerec856802010-03-27 00:45:04 +00004792def : Pat<(sub GR16:$src1, imm:$src2),
Bill Wendlingd350e022008-12-12 21:15:41 +00004793 (SUB16ri GR16:$src1, imm:$src2)>;
Chris Lattnerec856802010-03-27 00:45:04 +00004794def : Pat<(sub GR32:$src1, imm:$src2),
Bill Wendlingd350e022008-12-12 21:15:41 +00004795 (SUB32ri GR32:$src1, imm:$src2)>;
Chris Lattnerec856802010-03-27 00:45:04 +00004796def : Pat<(sub GR16:$src1, i16immSExt8:$src2),
Bill Wendlingd350e022008-12-12 21:15:41 +00004797 (SUB16ri8 GR16:$src1, i16immSExt8:$src2)>;
Chris Lattnerec856802010-03-27 00:45:04 +00004798def : Pat<(sub GR32:$src1, i32immSExt8:$src2),
Bill Wendlingd350e022008-12-12 21:15:41 +00004799 (SUB32ri8 GR32:$src1, i32immSExt8:$src2)>;
4800
Chris Lattnerec856802010-03-27 00:45:04 +00004801// mul reg, reg
4802def : Pat<(mul GR16:$src1, GR16:$src2),
Bill Wendlingd350e022008-12-12 21:15:41 +00004803 (IMUL16rr GR16:$src1, GR16:$src2)>;
Chris Lattnerec856802010-03-27 00:45:04 +00004804def : Pat<(mul GR32:$src1, GR32:$src2),
Bill Wendlingd350e022008-12-12 21:15:41 +00004805 (IMUL32rr GR32:$src1, GR32:$src2)>;
4806
Chris Lattnerec856802010-03-27 00:45:04 +00004807// mul reg, mem
4808def : Pat<(mul GR16:$src1, (loadi16 addr:$src2)),
Bill Wendlingd350e022008-12-12 21:15:41 +00004809 (IMUL16rm GR16:$src1, addr:$src2)>;
Chris Lattnerec856802010-03-27 00:45:04 +00004810def : Pat<(mul GR32:$src1, (loadi32 addr:$src2)),
Bill Wendlingd350e022008-12-12 21:15:41 +00004811 (IMUL32rm GR32:$src1, addr:$src2)>;
4812
Chris Lattnerec856802010-03-27 00:45:04 +00004813// mul reg, imm
4814def : Pat<(mul GR16:$src1, imm:$src2),
Bill Wendlingd350e022008-12-12 21:15:41 +00004815 (IMUL16rri GR16:$src1, imm:$src2)>;
Chris Lattnerec856802010-03-27 00:45:04 +00004816def : Pat<(mul GR32:$src1, imm:$src2),
Bill Wendlingd350e022008-12-12 21:15:41 +00004817 (IMUL32rri GR32:$src1, imm:$src2)>;
Chris Lattnerec856802010-03-27 00:45:04 +00004818def : Pat<(mul GR16:$src1, i16immSExt8:$src2),
Bill Wendlingd350e022008-12-12 21:15:41 +00004819 (IMUL16rri8 GR16:$src1, i16immSExt8:$src2)>;
Chris Lattnerec856802010-03-27 00:45:04 +00004820def : Pat<(mul GR32:$src1, i32immSExt8:$src2),
Bill Wendlingd350e022008-12-12 21:15:41 +00004821 (IMUL32rri8 GR32:$src1, i32immSExt8:$src2)>;
4822
Chris Lattnerec856802010-03-27 00:45:04 +00004823// reg = mul mem, imm
4824def : Pat<(mul (loadi16 addr:$src1), imm:$src2),
Bill Wendlingd350e022008-12-12 21:15:41 +00004825 (IMUL16rmi addr:$src1, imm:$src2)>;
Chris Lattnerec856802010-03-27 00:45:04 +00004826def : Pat<(mul (loadi32 addr:$src1), imm:$src2),
Bill Wendlingd350e022008-12-12 21:15:41 +00004827 (IMUL32rmi addr:$src1, imm:$src2)>;
Chris Lattnerec856802010-03-27 00:45:04 +00004828def : Pat<(mul (loadi16 addr:$src1), i16immSExt8:$src2),
Bill Wendlingd350e022008-12-12 21:15:41 +00004829 (IMUL16rmi8 addr:$src1, i16immSExt8:$src2)>;
Chris Lattnerec856802010-03-27 00:45:04 +00004830def : Pat<(mul (loadi32 addr:$src1), i32immSExt8:$src2),
Bill Wendlingd350e022008-12-12 21:15:41 +00004831 (IMUL32rmi8 addr:$src1, i32immSExt8:$src2)>;
4832
Dan Gohman076aee32009-03-04 19:44:21 +00004833// Optimize multiply by 2 with EFLAGS result.
Evan Cheng6a86bd72009-01-27 03:30:42 +00004834let AddedComplexity = 2 in {
Chris Lattnerbaba4bb2010-03-27 02:47:14 +00004835def : Pat<(X86smul_flag GR16:$src1, 2), (ADD16rr GR16:$src1, GR16:$src1)>;
4836def : Pat<(X86smul_flag GR32:$src1, 2), (ADD32rr GR32:$src1, GR32:$src1)>;
Evan Cheng6a86bd72009-01-27 03:30:42 +00004837}
4838
Chris Lattner589ad5d2010-03-25 05:44:01 +00004839// Patterns for nodes that do not produce flags, for instructions that do.
Chris Lattnerc54a2f12010-03-24 01:02:12 +00004840
Chris Lattner589ad5d2010-03-25 05:44:01 +00004841// Increment reg.
Eric Christophera938cfb2010-06-19 00:37:40 +00004842def : Pat<(add GR8:$src1 , 1), (INC8r GR8:$src1)>;
4843def : Pat<(add GR16:$src1, 1), (INC16r GR16:$src1)>, Requires<[In32BitMode]>;
4844def : Pat<(add GR32:$src1, 1), (INC32r GR32:$src1)>, Requires<[In32BitMode]>;
Dan Gohman076aee32009-03-04 19:44:21 +00004845
Chris Lattner589ad5d2010-03-25 05:44:01 +00004846// Decrement reg.
Eric Christophera938cfb2010-06-19 00:37:40 +00004847def : Pat<(add GR8:$src1 , -1), (DEC8r GR8:$src1)>;
4848def : Pat<(add GR16:$src1, -1), (DEC16r GR16:$src1)>, Requires<[In32BitMode]>;
4849def : Pat<(add GR32:$src1, -1), (DEC32r GR32:$src1)>, Requires<[In32BitMode]>;
Dan Gohman076aee32009-03-04 19:44:21 +00004850
Chris Lattner589ad5d2010-03-25 05:44:01 +00004851// or reg/reg.
4852def : Pat<(or GR8 :$src1, GR8 :$src2), (OR8rr GR8 :$src1, GR8 :$src2)>;
4853def : Pat<(or GR16:$src1, GR16:$src2), (OR16rr GR16:$src1, GR16:$src2)>;
4854def : Pat<(or GR32:$src1, GR32:$src2), (OR32rr GR32:$src1, GR32:$src2)>;
Dan Gohman076aee32009-03-04 19:44:21 +00004855
Chris Lattner589ad5d2010-03-25 05:44:01 +00004856// or reg/mem
4857def : Pat<(or GR8:$src1, (loadi8 addr:$src2)),
Dan Gohmane220c4b2009-09-18 19:59:53 +00004858 (OR8rm GR8:$src1, addr:$src2)>;
Chris Lattner589ad5d2010-03-25 05:44:01 +00004859def : Pat<(or GR16:$src1, (loadi16 addr:$src2)),
Dan Gohmane220c4b2009-09-18 19:59:53 +00004860 (OR16rm GR16:$src1, addr:$src2)>;
Chris Lattner589ad5d2010-03-25 05:44:01 +00004861def : Pat<(or GR32:$src1, (loadi32 addr:$src2)),
Dan Gohmane220c4b2009-09-18 19:59:53 +00004862 (OR32rm GR32:$src1, addr:$src2)>;
4863
Chris Lattner589ad5d2010-03-25 05:44:01 +00004864// or reg/imm
4865def : Pat<(or GR8:$src1 , imm:$src2), (OR8ri GR8 :$src1, imm:$src2)>;
4866def : Pat<(or GR16:$src1, imm:$src2), (OR16ri GR16:$src1, imm:$src2)>;
4867def : Pat<(or GR32:$src1, imm:$src2), (OR32ri GR32:$src1, imm:$src2)>;
4868def : Pat<(or GR16:$src1, i16immSExt8:$src2),
Dan Gohmane220c4b2009-09-18 19:59:53 +00004869 (OR16ri8 GR16:$src1, i16immSExt8:$src2)>;
Chris Lattner589ad5d2010-03-25 05:44:01 +00004870def : Pat<(or GR32:$src1, i32immSExt8:$src2),
Dan Gohmane220c4b2009-09-18 19:59:53 +00004871 (OR32ri8 GR32:$src1, i32immSExt8:$src2)>;
Dan Gohmane220c4b2009-09-18 19:59:53 +00004872
Chris Lattner589ad5d2010-03-25 05:44:01 +00004873// xor reg/reg
4874def : Pat<(xor GR8 :$src1, GR8 :$src2), (XOR8rr GR8 :$src1, GR8 :$src2)>;
4875def : Pat<(xor GR16:$src1, GR16:$src2), (XOR16rr GR16:$src1, GR16:$src2)>;
4876def : Pat<(xor GR32:$src1, GR32:$src2), (XOR32rr GR32:$src1, GR32:$src2)>;
Dan Gohmane220c4b2009-09-18 19:59:53 +00004877
Chris Lattner589ad5d2010-03-25 05:44:01 +00004878// xor reg/mem
4879def : Pat<(xor GR8:$src1, (loadi8 addr:$src2)),
Dan Gohmane220c4b2009-09-18 19:59:53 +00004880 (XOR8rm GR8:$src1, addr:$src2)>;
Chris Lattner589ad5d2010-03-25 05:44:01 +00004881def : Pat<(xor GR16:$src1, (loadi16 addr:$src2)),
Dan Gohmane220c4b2009-09-18 19:59:53 +00004882 (XOR16rm GR16:$src1, addr:$src2)>;
Chris Lattner589ad5d2010-03-25 05:44:01 +00004883def : Pat<(xor GR32:$src1, (loadi32 addr:$src2)),
Dan Gohmane220c4b2009-09-18 19:59:53 +00004884 (XOR32rm GR32:$src1, addr:$src2)>;
4885
Chris Lattner589ad5d2010-03-25 05:44:01 +00004886// xor reg/imm
4887def : Pat<(xor GR8:$src1, imm:$src2),
Dan Gohmane220c4b2009-09-18 19:59:53 +00004888 (XOR8ri GR8:$src1, imm:$src2)>;
Chris Lattner589ad5d2010-03-25 05:44:01 +00004889def : Pat<(xor GR16:$src1, imm:$src2),
Dan Gohmane220c4b2009-09-18 19:59:53 +00004890 (XOR16ri GR16:$src1, imm:$src2)>;
Chris Lattner589ad5d2010-03-25 05:44:01 +00004891def : Pat<(xor GR32:$src1, imm:$src2),
Dan Gohmane220c4b2009-09-18 19:59:53 +00004892 (XOR32ri GR32:$src1, imm:$src2)>;
Chris Lattner589ad5d2010-03-25 05:44:01 +00004893def : Pat<(xor GR16:$src1, i16immSExt8:$src2),
Dan Gohmane220c4b2009-09-18 19:59:53 +00004894 (XOR16ri8 GR16:$src1, i16immSExt8:$src2)>;
Chris Lattner589ad5d2010-03-25 05:44:01 +00004895def : Pat<(xor GR32:$src1, i32immSExt8:$src2),
Dan Gohmane220c4b2009-09-18 19:59:53 +00004896 (XOR32ri8 GR32:$src1, i32immSExt8:$src2)>;
4897
Chris Lattner589ad5d2010-03-25 05:44:01 +00004898// and reg/reg
4899def : Pat<(and GR8 :$src1, GR8 :$src2), (AND8rr GR8 :$src1, GR8 :$src2)>;
4900def : Pat<(and GR16:$src1, GR16:$src2), (AND16rr GR16:$src1, GR16:$src2)>;
4901def : Pat<(and GR32:$src1, GR32:$src2), (AND32rr GR32:$src1, GR32:$src2)>;
Dan Gohmane220c4b2009-09-18 19:59:53 +00004902
Chris Lattner589ad5d2010-03-25 05:44:01 +00004903// and reg/mem
4904def : Pat<(and GR8:$src1, (loadi8 addr:$src2)),
Dan Gohmane220c4b2009-09-18 19:59:53 +00004905 (AND8rm GR8:$src1, addr:$src2)>;
Chris Lattner589ad5d2010-03-25 05:44:01 +00004906def : Pat<(and GR16:$src1, (loadi16 addr:$src2)),
Dan Gohmane220c4b2009-09-18 19:59:53 +00004907 (AND16rm GR16:$src1, addr:$src2)>;
Chris Lattner589ad5d2010-03-25 05:44:01 +00004908def : Pat<(and GR32:$src1, (loadi32 addr:$src2)),
Dan Gohmane220c4b2009-09-18 19:59:53 +00004909 (AND32rm GR32:$src1, addr:$src2)>;
4910
Chris Lattner589ad5d2010-03-25 05:44:01 +00004911// and reg/imm
4912def : Pat<(and GR8:$src1, imm:$src2),
Dan Gohmane220c4b2009-09-18 19:59:53 +00004913 (AND8ri GR8:$src1, imm:$src2)>;
Chris Lattner589ad5d2010-03-25 05:44:01 +00004914def : Pat<(and GR16:$src1, imm:$src2),
Dan Gohmane220c4b2009-09-18 19:59:53 +00004915 (AND16ri GR16:$src1, imm:$src2)>;
Chris Lattner589ad5d2010-03-25 05:44:01 +00004916def : Pat<(and GR32:$src1, imm:$src2),
Dan Gohmane220c4b2009-09-18 19:59:53 +00004917 (AND32ri GR32:$src1, imm:$src2)>;
Chris Lattner589ad5d2010-03-25 05:44:01 +00004918def : Pat<(and GR16:$src1, i16immSExt8:$src2),
Dan Gohmane220c4b2009-09-18 19:59:53 +00004919 (AND16ri8 GR16:$src1, i16immSExt8:$src2)>;
Chris Lattner589ad5d2010-03-25 05:44:01 +00004920def : Pat<(and GR32:$src1, i32immSExt8:$src2),
Dan Gohmane220c4b2009-09-18 19:59:53 +00004921 (AND32ri8 GR32:$src1, i32immSExt8:$src2)>;
4922
Bill Wendlingd350e022008-12-12 21:15:41 +00004923//===----------------------------------------------------------------------===//
Evan Cheng4e4c71e2006-02-21 20:00:20 +00004924// Floating Point Stack Support
4925//===----------------------------------------------------------------------===//
4926
4927include "X86InstrFPStack.td"
4928
4929//===----------------------------------------------------------------------===//
Evan Chengc64a1a92007-07-31 08:04:03 +00004930// X86-64 Support
4931//===----------------------------------------------------------------------===//
4932
Chris Lattner36fe6d22008-01-10 05:50:42 +00004933include "X86Instr64bit.td"
Evan Chengc64a1a92007-07-31 08:04:03 +00004934
4935//===----------------------------------------------------------------------===//
David Greene51898d72010-02-09 23:52:19 +00004936// SIMD support (SSE, MMX and AVX)
4937//===----------------------------------------------------------------------===//
4938
4939include "X86InstrFragmentsSIMD.td"
4940
4941//===----------------------------------------------------------------------===//
Evan Cheng4e4c71e2006-02-21 20:00:20 +00004942// XMM Floating point support (requires SSE / SSE2)
4943//===----------------------------------------------------------------------===//
4944
4945include "X86InstrSSE.td"
Evan Cheng80f54042008-04-25 18:19:54 +00004946
4947//===----------------------------------------------------------------------===//
4948// MMX and XMM Packed Integer support (requires MMX, SSE, and SSE2)
4949//===----------------------------------------------------------------------===//
4950
4951include "X86InstrMMX.td"