blob: 367e29c77a6c0c59fe4b61b81a147267ea469cb6 [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
Eric Christopher9a9d2752010-07-22 02:48:34 +000083def SDT_X86MEMBARRIER : SDTypeProfile<0, 0, []>;
84def SDT_X86MEMBARRIERNoSSE : SDTypeProfile<0, 1, [SDTCisInt<0>]>;
85
86def X86MemBarrier : SDNode<"X86ISD::MEMBARRIER", SDT_X86MEMBARRIER,
87 [SDNPHasChain]>;
88def X86MemBarrierNoSSE : SDNode<"X86ISD::MEMBARRIER", SDT_X86MEMBARRIERNoSSE,
89 [SDNPHasChain]>;
90def X86MFence : SDNode<"X86ISD::MFENCE", SDT_X86MEMBARRIER,
91 [SDNPHasChain]>;
92def X86SFence : SDNode<"X86ISD::SFENCE", SDT_X86MEMBARRIER,
93 [SDNPHasChain]>;
94def X86LFence : SDNode<"X86ISD::LFENCE", SDT_X86MEMBARRIER,
95 [SDNPHasChain]>;
96
97
Chris Lattnerd486d772010-03-28 05:07:17 +000098def X86bsf : SDNode<"X86ISD::BSF", SDTUnaryArithWithFlags>;
99def X86bsr : SDNode<"X86ISD::BSR", SDTUnaryArithWithFlags>;
Evan Chenge3413162006-01-09 18:33:28 +0000100def X86shld : SDNode<"X86ISD::SHLD", SDTIntShiftDOp>;
101def X86shrd : SDNode<"X86ISD::SHRD", SDTIntShiftDOp>;
Evan Chengb077b842005-12-21 02:39:21 +0000102
Evan Chenge5f62042007-09-29 00:00:36 +0000103def X86cmp : SDNode<"X86ISD::CMP" , SDTX86CmpTest>;
Dan Gohmanc7a37d42008-12-23 22:45:23 +0000104def X86bt : SDNode<"X86ISD::BT", SDTX86CmpTest>;
105
Evan Chenge5f62042007-09-29 00:00:36 +0000106def X86cmov : SDNode<"X86ISD::CMOV", SDTX86Cmov>;
Evan Chenge3413162006-01-09 18:33:28 +0000107def X86brcond : SDNode<"X86ISD::BRCOND", SDTX86BrCond,
Evan Cheng0488db92007-09-25 01:57:46 +0000108 [SDNPHasChain]>;
Evan Chenge5f62042007-09-29 00:00:36 +0000109def X86setcc : SDNode<"X86ISD::SETCC", SDTX86SetCC>;
Evan Cheng2e489c42009-12-16 00:53:11 +0000110def X86setcc_c : SDNode<"X86ISD::SETCC_CARRY", SDTX86SetCC_C>;
Evan Chengb077b842005-12-21 02:39:21 +0000111
Andrew Lenharth26ed8692008-03-01 21:52:34 +0000112def X86cas : SDNode<"X86ISD::LCMPXCHG_DAG", SDTX86cas,
113 [SDNPHasChain, SDNPInFlag, SDNPOutFlag, SDNPMayStore,
114 SDNPMayLoad]>;
Andrew Lenharthd19189e2008-03-05 01:15:49 +0000115def X86cas8 : SDNode<"X86ISD::LCMPXCHG8_DAG", SDTX86cas8,
116 [SDNPHasChain, SDNPInFlag, SDNPOutFlag, SDNPMayStore,
117 SDNPMayLoad]>;
Dale Johannesen48c1bc22008-10-02 18:53:47 +0000118def X86AtomAdd64 : SDNode<"X86ISD::ATOMADD64_DAG", SDTX86atomicBinary,
119 [SDNPHasChain, SDNPMayStore,
120 SDNPMayLoad, SDNPMemOperand]>;
121def X86AtomSub64 : SDNode<"X86ISD::ATOMSUB64_DAG", SDTX86atomicBinary,
122 [SDNPHasChain, SDNPMayStore,
123 SDNPMayLoad, SDNPMemOperand]>;
124def X86AtomOr64 : SDNode<"X86ISD::ATOMOR64_DAG", SDTX86atomicBinary,
125 [SDNPHasChain, SDNPMayStore,
126 SDNPMayLoad, SDNPMemOperand]>;
127def X86AtomXor64 : SDNode<"X86ISD::ATOMXOR64_DAG", SDTX86atomicBinary,
128 [SDNPHasChain, SDNPMayStore,
129 SDNPMayLoad, SDNPMemOperand]>;
130def X86AtomAnd64 : SDNode<"X86ISD::ATOMAND64_DAG", SDTX86atomicBinary,
131 [SDNPHasChain, SDNPMayStore,
132 SDNPMayLoad, SDNPMemOperand]>;
133def X86AtomNand64 : SDNode<"X86ISD::ATOMNAND64_DAG", SDTX86atomicBinary,
134 [SDNPHasChain, SDNPMayStore,
135 SDNPMayLoad, SDNPMemOperand]>;
Dale Johannesen880ae362008-10-03 22:25:52 +0000136def X86AtomSwap64 : SDNode<"X86ISD::ATOMSWAP64_DAG", SDTX86atomicBinary,
137 [SDNPHasChain, SDNPMayStore,
138 SDNPMayLoad, SDNPMemOperand]>;
Evan Chenge3413162006-01-09 18:33:28 +0000139def X86retflag : SDNode<"X86ISD::RET_FLAG", SDTX86Ret,
Chris Lattnere8cabf32010-03-19 05:07:09 +0000140 [SDNPHasChain, SDNPOptInFlag, SDNPVariadic]>;
Evan Chengb077b842005-12-21 02:39:21 +0000141
Dan Gohmand6708ea2009-08-15 01:38:56 +0000142def X86vastart_save_xmm_regs :
143 SDNode<"X86ISD::VASTART_SAVE_XMM_REGS",
144 SDT_X86VASTART_SAVE_XMM_REGS,
Chris Lattnere8cabf32010-03-19 05:07:09 +0000145 [SDNPHasChain, SDNPVariadic]>;
Dan Gohmand6708ea2009-08-15 01:38:56 +0000146
Evan Chenge3413162006-01-09 18:33:28 +0000147def X86callseq_start :
148 SDNode<"ISD::CALLSEQ_START", SDT_X86CallSeqStart,
Evan Chengbb7b8442006-08-11 09:03:33 +0000149 [SDNPHasChain, SDNPOutFlag]>;
Evan Chenge3413162006-01-09 18:33:28 +0000150def X86callseq_end :
151 SDNode<"ISD::CALLSEQ_END", SDT_X86CallSeqEnd,
Arnold Schwaighoferc85e1712007-10-11 19:40:01 +0000152 [SDNPHasChain, SDNPOptInFlag, SDNPOutFlag]>;
Evan Chengb077b842005-12-21 02:39:21 +0000153
Evan Chenge3413162006-01-09 18:33:28 +0000154def X86call : SDNode<"X86ISD::CALL", SDT_X86Call,
Chris Lattnere8cabf32010-03-19 05:07:09 +0000155 [SDNPHasChain, SDNPOutFlag, SDNPOptInFlag,
156 SDNPVariadic]>;
Evan Chengaed7c722005-12-17 01:24:02 +0000157
Chris Lattnered52c8f2010-03-28 07:38:39 +0000158def X86rep_stos: SDNode<"X86ISD::REP_STOS", SDTX86RepStr,
Chris Lattner9b37aaf2008-01-10 05:12:37 +0000159 [SDNPHasChain, SDNPInFlag, SDNPOutFlag, SDNPMayStore]>;
Chris Lattnered52c8f2010-03-28 07:38:39 +0000160def X86rep_movs: SDNode<"X86ISD::REP_MOVS", SDTX86RepStr,
Chris Lattner9b37aaf2008-01-10 05:12:37 +0000161 [SDNPHasChain, SDNPInFlag, SDNPOutFlag, SDNPMayStore,
162 SDNPMayLoad]>;
Evan Cheng67f92a72006-01-11 22:15:48 +0000163
Anton Korobeynikov043f3c22010-03-06 19:32:29 +0000164def X86rdtsc : SDNode<"X86ISD::RDTSC_DAG", SDTX86Void,
Chris Lattnerba7e7562008-01-10 07:59:24 +0000165 [SDNPHasChain, SDNPOutFlag, SDNPSideEffect]>;
Evan Chengd90eb7f2006-01-05 00:27:02 +0000166
Evan Cheng0085a282006-11-30 21:55:46 +0000167def X86Wrapper : SDNode<"X86ISD::Wrapper", SDTX86Wrapper>;
168def X86WrapperRIP : SDNode<"X86ISD::WrapperRIP", SDTX86Wrapper>;
Evan Cheng71fb8342006-02-25 10:02:21 +0000169
Lauro Ramos Venanciob3a04172007-04-20 21:38:10 +0000170def X86tlsaddr : SDNode<"X86ISD::TLSADDR", SDT_X86TLSADDR,
Anton Korobeynikov6625eff2008-05-04 21:36:32 +0000171 [SDNPHasChain, SDNPOptInFlag, SDNPOutFlag]>;
Rafael Espindola094fad32009-04-08 21:14:34 +0000172def X86SegmentBaseAddress : SDNode<"X86ISD::SegmentBaseAddress",
173 SDT_X86SegmentBaseAddress, []>;
Lauro Ramos Venanciob3a04172007-04-20 21:38:10 +0000174
Anton Korobeynikov2365f512007-07-14 14:06:15 +0000175def X86ehret : SDNode<"X86ISD::EH_RETURN", SDT_X86EHRET,
176 [SDNPHasChain]>;
177
Arnold Schwaighoferc85e1712007-10-11 19:40:01 +0000178def X86tcret : SDNode<"X86ISD::TC_RETURN", SDT_X86TCRET,
Chris Lattnere8cabf32010-03-19 05:07:09 +0000179 [SDNPHasChain, SDNPOptInFlag, SDNPVariadic]>;
Lauro Ramos Venanciob3a04172007-04-20 21:38:10 +0000180
Dan Gohman43ffe672010-01-04 20:51:05 +0000181def X86add_flag : SDNode<"X86ISD::ADD", SDTBinaryArithWithFlags,
Dan Gohman4361bbf2010-01-05 00:44:20 +0000182 [SDNPCommutative]>;
Dan Gohman076aee32009-03-04 19:44:21 +0000183def X86sub_flag : SDNode<"X86ISD::SUB", SDTBinaryArithWithFlags>;
Dan Gohman43ffe672010-01-04 20:51:05 +0000184def X86smul_flag : SDNode<"X86ISD::SMUL", SDTBinaryArithWithFlags,
Dan Gohman4361bbf2010-01-05 00:44:20 +0000185 [SDNPCommutative]>;
Dan Gohman43ffe672010-01-04 20:51:05 +0000186def X86umul_flag : SDNode<"X86ISD::UMUL", SDTUnaryArithWithFlags,
Dan Gohman4361bbf2010-01-05 00:44:20 +0000187 [SDNPCommutative]>;
Chris Lattner74c8d672010-03-24 00:47:47 +0000188
Dan Gohman076aee32009-03-04 19:44:21 +0000189def X86inc_flag : SDNode<"X86ISD::INC", SDTUnaryArithWithFlags>;
190def X86dec_flag : SDNode<"X86ISD::DEC", SDTUnaryArithWithFlags>;
Dan Gohman43ffe672010-01-04 20:51:05 +0000191def X86or_flag : SDNode<"X86ISD::OR", SDTBinaryArithWithFlags,
Dan Gohman4361bbf2010-01-05 00:44:20 +0000192 [SDNPCommutative]>;
Dan Gohman43ffe672010-01-04 20:51:05 +0000193def X86xor_flag : SDNode<"X86ISD::XOR", SDTBinaryArithWithFlags,
Dan Gohman4361bbf2010-01-05 00:44:20 +0000194 [SDNPCommutative]>;
Dan Gohman43ffe672010-01-04 20:51:05 +0000195def X86and_flag : SDNode<"X86ISD::AND", SDTBinaryArithWithFlags,
Dan Gohman4361bbf2010-01-05 00:44:20 +0000196 [SDNPCommutative]>;
Bill Wendlingab55ebd2008-12-12 00:56:36 +0000197
Evan Cheng73f24c92009-03-30 21:36:47 +0000198def X86mul_imm : SDNode<"X86ISD::MUL_IMM", SDTIntBinOp>;
199
Anton Korobeynikov043f3c22010-03-06 19:32:29 +0000200def X86MingwAlloca : SDNode<"X86ISD::MINGW_ALLOCA", SDTX86Void,
201 [SDNPHasChain, SDNPInFlag, SDNPOutFlag]>;
Eric Christopher30ef0e52010-06-03 04:07:48 +0000202
203def X86TLSCall : SDNode<"X86ISD::TLSCALL", SDT_X86TLSCALL,
204 []>;
Anton Korobeynikov043f3c22010-03-06 19:32:29 +0000205
Evan Chengaed7c722005-12-17 01:24:02 +0000206//===----------------------------------------------------------------------===//
207// X86 Operand Definitions.
208//
209
Dan Gohmana4714e02009-07-30 01:56:29 +0000210// A version of ptr_rc which excludes SP, ESP, and RSP. This is used for
211// the index operand of an address, to conform to x86 encoding restrictions.
212def ptr_rc_nosp : PointerLikeRegClass<1>;
Chris Lattner7680e732009-06-20 19:34:09 +0000213
Chris Lattner66fa1dc2004-08-11 02:25:00 +0000214// *mem - Operand definitions for the funky X86 addressing mode operands.
215//
Daniel Dunbar338825c2009-08-10 18:41:10 +0000216def X86MemAsmOperand : AsmOperandClass {
217 let Name = "Mem";
Daniel Dunbar54ddf3d2010-05-22 21:02:29 +0000218 let SuperClasses = [];
Daniel Dunbar338825c2009-08-10 18:41:10 +0000219}
Daniel Dunbarc26ae5a2010-05-06 22:39:14 +0000220def X86AbsMemAsmOperand : AsmOperandClass {
221 let Name = "AbsMem";
Chris Lattner599b5312010-07-08 23:46:44 +0000222 let SuperClasses = [X86MemAsmOperand];
Daniel Dunbarc26ae5a2010-05-06 22:39:14 +0000223}
Evan Chengaf78ef52006-05-17 21:21:41 +0000224class X86MemOperand<string printMethod> : Operand<iPTR> {
Nate Begeman391c5d22005-11-30 18:54:35 +0000225 let PrintMethod = printMethod;
Dan Gohmana4714e02009-07-30 01:56:29 +0000226 let MIOperandInfo = (ops ptr_rc, i8imm, ptr_rc_nosp, i32imm, i8imm);
Daniel Dunbar338825c2009-08-10 18:41:10 +0000227 let ParserMatchClass = X86MemAsmOperand;
Chris Lattner66fa1dc2004-08-11 02:25:00 +0000228}
Nate Begeman391c5d22005-11-30 18:54:35 +0000229
Sean Callanan9947bbb2009-09-03 00:04:47 +0000230def opaque32mem : X86MemOperand<"printopaquemem">;
231def opaque48mem : X86MemOperand<"printopaquemem">;
232def opaque80mem : X86MemOperand<"printopaquemem">;
Sean Callanan108934c2009-12-18 00:01:26 +0000233def opaque512mem : X86MemOperand<"printopaquemem">;
234
Chris Lattner45432512005-12-17 19:47:05 +0000235def i8mem : X86MemOperand<"printi8mem">;
236def i16mem : X86MemOperand<"printi16mem">;
237def i32mem : X86MemOperand<"printi32mem">;
238def i64mem : X86MemOperand<"printi64mem">;
Evan Cheng470a6ad2006-02-22 02:26:30 +0000239def i128mem : X86MemOperand<"printi128mem">;
Bruno Cardoso Lopes94143ee2010-07-19 23:32:44 +0000240def i256mem : X86MemOperand<"printi256mem">;
Chris Lattner45432512005-12-17 19:47:05 +0000241def f32mem : X86MemOperand<"printf32mem">;
242def f64mem : X86MemOperand<"printf64mem">;
Dale Johannesen59a58732007-08-05 18:49:15 +0000243def f80mem : X86MemOperand<"printf80mem">;
Evan Cheng223547a2006-01-31 22:28:30 +0000244def f128mem : X86MemOperand<"printf128mem">;
Bruno Cardoso Lopese86b01c2010-07-09 18:27:43 +0000245def f256mem : X86MemOperand<"printf256mem">;
Nate Begeman391c5d22005-11-30 18:54:35 +0000246
Dan Gohman21e3dfb2009-04-13 16:09:41 +0000247// A version of i8mem for use on x86-64 that uses GR64_NOREX instead of
248// plain GR64, so that it doesn't potentially require a REX prefix.
249def i8mem_NOREX : Operand<i64> {
250 let PrintMethod = "printi8mem";
Dan Gohmana4714e02009-07-30 01:56:29 +0000251 let MIOperandInfo = (ops GR64_NOREX, i8imm, GR64_NOREX_NOSP, i32imm, i8imm);
Daniel Dunbar338825c2009-08-10 18:41:10 +0000252 let ParserMatchClass = X86MemAsmOperand;
Dan Gohman21e3dfb2009-04-13 16:09:41 +0000253}
254
Evan Chengf48ef032010-03-14 03:48:46 +0000255// Special i32mem for addresses of load folding tail calls. These are not
256// allowed to use callee-saved registers since they must be scheduled
257// after callee-saved register are popped.
258def i32mem_TC : Operand<i32> {
259 let PrintMethod = "printi32mem";
260 let MIOperandInfo = (ops GR32_TC, i8imm, GR32_TC, i32imm, i8imm);
261 let ParserMatchClass = X86MemAsmOperand;
262}
263
Evan Cheng25ab6902006-09-08 06:48:29 +0000264
Daniel Dunbarb834f5d2010-01-30 01:02:48 +0000265let ParserMatchClass = X86AbsMemAsmOperand,
266 PrintMethod = "print_pcrel_imm" in {
Daniel Dunbar728e5eb2010-01-30 00:24:12 +0000267def i32imm_pcrel : Operand<i32>;
Chris Lattner9fc05222010-07-07 22:27:31 +0000268def i16imm_pcrel : Operand<i16>;
Daniel Dunbar728e5eb2010-01-30 00:24:12 +0000269
270def offset8 : Operand<i64>;
271def offset16 : Operand<i64>;
272def offset32 : Operand<i64>;
273def offset64 : Operand<i64>;
274
275// Branch targets have OtherVT type and print as pc-relative values.
276def brtarget : Operand<OtherVT>;
277def brtarget8 : Operand<OtherVT>;
278
279}
280
Nate Begeman16b04f32005-07-15 00:38:55 +0000281def SSECC : Operand<i8> {
282 let PrintMethod = "printSSECC";
283}
Chris Lattner66fa1dc2004-08-11 02:25:00 +0000284
Daniel Dunbar62e4c672010-05-22 21:02:33 +0000285class ImmSExtAsmOperandClass : AsmOperandClass {
Daniel Dunbar54ddf3d2010-05-22 21:02:29 +0000286 let SuperClasses = [ImmAsmOperand];
Daniel Dunbar62e4c672010-05-22 21:02:33 +0000287 let RenderMethod = "addImmOperands";
Daniel Dunbar1fe591d2010-05-20 20:20:39 +0000288}
289
Daniel Dunbar62e4c672010-05-22 21:02:33 +0000290// Sign-extended immediate classes. We don't need to define the full lattice
291// here because there is no instruction with an ambiguity between ImmSExti64i32
292// and ImmSExti32i8.
293//
294// The strange ranges come from the fact that the assembler always works with
295// 64-bit immediates, but for a 16-bit target value we want to accept both "-1"
296// (which will be a -1ULL), and "0xFF" (-1 in 16-bits).
297
Chris Lattner599b5312010-07-08 23:46:44 +0000298// [0, 0x7FFFFFFF] |
299// [0xFFFFFFFF80000000, 0xFFFFFFFFFFFFFFFF]
Daniel Dunbar62e4c672010-05-22 21:02:33 +0000300def ImmSExti64i32AsmOperand : ImmSExtAsmOperandClass {
301 let Name = "ImmSExti64i32";
302}
303
Chris Lattner599b5312010-07-08 23:46:44 +0000304// [0, 0x0000007F] | [0x000000000000FF80, 0x000000000000FFFF] |
305// [0xFFFFFFFFFFFFFF80, 0xFFFFFFFFFFFFFFFF]
Daniel Dunbar62e4c672010-05-22 21:02:33 +0000306def ImmSExti16i8AsmOperand : ImmSExtAsmOperandClass {
307 let Name = "ImmSExti16i8";
308 let SuperClasses = [ImmSExti64i32AsmOperand];
309}
310
Chris Lattner599b5312010-07-08 23:46:44 +0000311// [0, 0x0000007F] | [0x00000000FFFFFF80, 0x00000000FFFFFFFF] |
312// [0xFFFFFFFFFFFFFF80, 0xFFFFFFFFFFFFFFFF]
Daniel Dunbar62e4c672010-05-22 21:02:33 +0000313def ImmSExti32i8AsmOperand : ImmSExtAsmOperandClass {
314 let Name = "ImmSExti32i8";
315}
316
Chris Lattner599b5312010-07-08 23:46:44 +0000317// [0, 0x0000007F] |
318// [0xFFFFFFFFFFFFFF80, 0xFFFFFFFFFFFFFFFF]
Daniel Dunbar62e4c672010-05-22 21:02:33 +0000319def ImmSExti64i8AsmOperand : ImmSExtAsmOperandClass {
320 let Name = "ImmSExti64i8";
Chris Lattner599b5312010-07-08 23:46:44 +0000321 let SuperClasses = [ImmSExti16i8AsmOperand, ImmSExti32i8AsmOperand,
322 ImmSExti64i32AsmOperand];
Daniel Dunbar338825c2009-08-10 18:41:10 +0000323}
324
Chris Lattnerf124d5e2005-11-18 01:04:42 +0000325// A couple of more descriptive operand definitions.
326// 16-bits but only 8 bits are significant.
Daniel Dunbar5fe63382009-08-09 07:20:21 +0000327def i16i8imm : Operand<i16> {
Daniel Dunbar62e4c672010-05-22 21:02:33 +0000328 let ParserMatchClass = ImmSExti16i8AsmOperand;
Daniel Dunbar5fe63382009-08-09 07:20:21 +0000329}
Chris Lattnerf124d5e2005-11-18 01:04:42 +0000330// 32-bits but only 8 bits are significant.
Daniel Dunbar5fe63382009-08-09 07:20:21 +0000331def i32i8imm : Operand<i32> {
Daniel Dunbar62e4c672010-05-22 21:02:33 +0000332 let ParserMatchClass = ImmSExti32i8AsmOperand;
Daniel Dunbar5fe63382009-08-09 07:20:21 +0000333}
Chris Lattnerf124d5e2005-11-18 01:04:42 +0000334
Evan Chengaed7c722005-12-17 01:24:02 +0000335//===----------------------------------------------------------------------===//
336// X86 Complex Pattern Definitions.
337//
338
Evan Chengec693f72005-12-08 02:01:35 +0000339// Define X86 specific addressing mode.
Rafael Espindola094fad32009-04-08 21:14:34 +0000340def addr : ComplexPattern<iPTR, 5, "SelectAddr", [], []>;
Chris Lattner599b5312010-07-08 23:46:44 +0000341def lea32addr : ComplexPattern<i32, 5, "SelectLEAAddr",
Dan Gohmana98634b2009-08-02 16:09:17 +0000342 [add, sub, mul, X86mul_imm, shl, or, frameindex],
343 []>;
Chris Lattner599b5312010-07-08 23:46:44 +0000344def tls32addr : ComplexPattern<i32, 5, "SelectTLSADDRAddr",
Chris Lattner5c0b16d2009-06-20 20:38:48 +0000345 [tglobaltlsaddr], []>;
Evan Chengec693f72005-12-08 02:01:35 +0000346
Evan Chengaed7c722005-12-17 01:24:02 +0000347//===----------------------------------------------------------------------===//
Evan Chengbbc8ddb2005-12-20 22:59:51 +0000348// X86 Instruction Predicate Definitions.
Chris Lattner314a1132010-03-14 18:31:44 +0000349def HasCMov : Predicate<"Subtarget->hasCMov()">;
350def NoCMov : Predicate<"!Subtarget->hasCMov()">;
Bruno Cardoso Lopes3c457342010-07-26 21:01:18 +0000351
352// FIXME: temporary hack to let codegen assert or generate poor code in case
353// no AVX version of the desired intructions is present, this is better for
354// incremental dev (without fallbacks it's easier to spot what's missing)
Bruno Cardoso Lopes5b7dab82010-07-30 19:41:24 +0000355def HasMMX : Predicate<"Subtarget->hasMMX() && !Subtarget->hasAVX()">;
356def HasSSE1 : Predicate<"Subtarget->hasSSE1() && !Subtarget->hasAVX()">;
357def HasSSE2 : Predicate<"Subtarget->hasSSE2() && !Subtarget->hasAVX()">;
358def HasSSE3 : Predicate<"Subtarget->hasSSE3() && !Subtarget->hasAVX()">;
359def HasSSSE3 : Predicate<"Subtarget->hasSSSE3() && !Subtarget->hasAVX()">;
360def HasSSE41 : Predicate<"Subtarget->hasSSE41() && !Subtarget->hasAVX()">;
361def HasSSE42 : Predicate<"Subtarget->hasSSE42() && !Subtarget->hasAVX()">;
362def HasSSE4A : Predicate<"Subtarget->hasSSE4A() && !Subtarget->hasAVX()">;
Bruno Cardoso Lopes3c457342010-07-26 21:01:18 +0000363
David Greene343dadb2009-06-26 22:46:54 +0000364def HasAVX : Predicate<"Subtarget->hasAVX()">;
Bruno Cardoso Lopescdae7e82010-07-23 01:17:51 +0000365def HasCLMUL : Predicate<"Subtarget->hasCLMUL()">;
David Greene343dadb2009-06-26 22:46:54 +0000366def HasFMA3 : Predicate<"Subtarget->hasFMA3()">;
367def HasFMA4 : Predicate<"Subtarget->hasFMA4()">;
Dale Johannesenf1fc3a82007-09-23 14:52:20 +0000368def FPStackf32 : Predicate<"!Subtarget->hasSSE1()">;
369def FPStackf64 : Predicate<"!Subtarget->hasSSE2()">;
Evan Cheng28b514392006-12-05 19:50:18 +0000370def In32BitMode : Predicate<"!Subtarget->is64Bit()">;
371def In64BitMode : Predicate<"Subtarget->is64Bit()">;
Anton Korobeynikovcf6b7392009-08-03 08:12:53 +0000372def IsWin64 : Predicate<"Subtarget->isTargetWin64()">;
373def NotWin64 : Predicate<"!Subtarget->isTargetWin64()">;
Anton Korobeynikovd7697d02009-08-06 11:23:24 +0000374def SmallCode : Predicate<"TM.getCodeModel() == CodeModel::Small">;
375def KernelCode : Predicate<"TM.getCodeModel() == CodeModel::Kernel">;
376def FarData : Predicate<"TM.getCodeModel() != CodeModel::Small &&"
Anton Korobeynikov186fa1d2009-08-06 09:11:19 +0000377 "TM.getCodeModel() != CodeModel::Kernel">;
Anton Korobeynikovd7697d02009-08-06 11:23:24 +0000378def NearData : Predicate<"TM.getCodeModel() == CodeModel::Small ||"
379 "TM.getCodeModel() == CodeModel::Kernel">;
Evan Cheng28b514392006-12-05 19:50:18 +0000380def IsStatic : Predicate<"TM.getRelocationModel() == Reloc::Static">;
Evan Chengcb0f06e2010-03-25 00:10:31 +0000381def IsNotPIC : Predicate<"TM.getRelocationModel() != Reloc::PIC_">;
Evan Chengb1f49812009-12-22 17:47:23 +0000382def OptForSize : Predicate<"OptForSize">;
Evan Chengb7a75a52008-09-26 23:41:32 +0000383def OptForSpeed : Predicate<"!OptForSize">;
Evan Chengccb69762009-01-02 05:35:45 +0000384def FastBTMem : Predicate<"!Subtarget->isBTMemSlow()">;
Evan Chengd7f666a2009-05-20 04:53:57 +0000385def CallImmAddr : Predicate<"Subtarget->IsLegalToCallImmediateAddr(TM)">;
Eric Christopher6d1cd1c2010-04-02 21:54:27 +0000386def HasAES : Predicate<"Subtarget->hasAES()">;
Evan Chengbbc8ddb2005-12-20 22:59:51 +0000387
388//===----------------------------------------------------------------------===//
Evan Chengc64a1a92007-07-31 08:04:03 +0000389// X86 Instruction Format Definitions.
Evan Chengaed7c722005-12-17 01:24:02 +0000390//
391
Evan Chengc64a1a92007-07-31 08:04:03 +0000392include "X86InstrFormats.td"
Chris Lattner1cca5e32003-08-03 21:54:21 +0000393
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +0000394//===----------------------------------------------------------------------===//
Chris Lattnerf124d5e2005-11-18 01:04:42 +0000395// Pattern fragments...
396//
Evan Chengd9558e02006-01-06 00:43:03 +0000397
398// X86 specific condition code. These correspond to CondCode in
Nate Begeman9a225302007-05-06 04:00:55 +0000399// X86InstrInfo.h. They must be kept in synch.
Dan Gohman653456c2009-01-07 00:15:08 +0000400def X86_COND_A : PatLeaf<(i8 0)>; // alt. COND_NBE
401def X86_COND_AE : PatLeaf<(i8 1)>; // alt. COND_NC
402def X86_COND_B : PatLeaf<(i8 2)>; // alt. COND_C
403def X86_COND_BE : PatLeaf<(i8 3)>; // alt. COND_NA
404def X86_COND_E : PatLeaf<(i8 4)>; // alt. COND_Z
405def X86_COND_G : PatLeaf<(i8 5)>; // alt. COND_NLE
406def X86_COND_GE : PatLeaf<(i8 6)>; // alt. COND_NL
407def X86_COND_L : PatLeaf<(i8 7)>; // alt. COND_NGE
408def X86_COND_LE : PatLeaf<(i8 8)>; // alt. COND_NG
409def X86_COND_NE : PatLeaf<(i8 9)>; // alt. COND_NZ
Evan Chengd9558e02006-01-06 00:43:03 +0000410def X86_COND_NO : PatLeaf<(i8 10)>;
Dan Gohman653456c2009-01-07 00:15:08 +0000411def X86_COND_NP : PatLeaf<(i8 11)>; // alt. COND_PO
Evan Chengd9558e02006-01-06 00:43:03 +0000412def X86_COND_NS : PatLeaf<(i8 12)>;
Dan Gohman653456c2009-01-07 00:15:08 +0000413def X86_COND_O : PatLeaf<(i8 13)>;
414def X86_COND_P : PatLeaf<(i8 14)>; // alt. COND_PE
415def X86_COND_S : PatLeaf<(i8 15)>;
Evan Chengd9558e02006-01-06 00:43:03 +0000416
Chris Lattner18409912010-03-03 01:45:01 +0000417def immSext8 : PatLeaf<(imm), [{
418 return N->getSExtValue() == (int8_t)N->getSExtValue();
Chris Lattnerf124d5e2005-11-18 01:04:42 +0000419}]>;
420
Chris Lattner18409912010-03-03 01:45:01 +0000421def i16immSExt8 : PatLeaf<(i16 immSext8)>;
422def i32immSExt8 : PatLeaf<(i32 immSext8)>;
Evan Chengb3558542005-12-13 00:01:09 +0000423
Chris Lattnerf85eff72010-03-03 01:52:59 +0000424/// Load patterns: these constraint the match to the right address space.
425def dsload : PatFrag<(ops node:$ptr), (load node:$ptr), [{
426 if (const Value *Src = cast<LoadSDNode>(N)->getSrcValue())
427 if (const PointerType *PT = dyn_cast<PointerType>(Src->getType()))
428 if (PT->getAddressSpace() > 255)
429 return false;
430 return true;
431}]>;
432
433def gsload : PatFrag<(ops node:$ptr), (load node:$ptr), [{
434 if (const Value *Src = cast<LoadSDNode>(N)->getSrcValue())
435 if (const PointerType *PT = dyn_cast<PointerType>(Src->getType()))
436 return PT->getAddressSpace() == 256;
437 return false;
438}]>;
439
440def fsload : PatFrag<(ops node:$ptr), (load node:$ptr), [{
441 if (const Value *Src = cast<LoadSDNode>(N)->getSrcValue())
442 if (const PointerType *PT = dyn_cast<PointerType>(Src->getType()))
443 return PT->getAddressSpace() == 257;
444 return false;
445}]>;
446
447
Evan Cheng605c4152005-12-13 01:57:51 +0000448// Helper fragments for loads.
Evan Chengb6564432008-05-13 18:59:59 +0000449// It's always safe to treat a anyext i16 load as a i32 load if the i16 is
450// known to be 32-bit aligned or better. Ditto for i8 to i16.
Dan Gohman33586292008-10-15 06:50:19 +0000451def loadi16 : PatFrag<(ops node:$ptr), (i16 (unindexedload node:$ptr)), [{
Dan Gohman67ca6be2008-08-20 15:24:22 +0000452 LoadSDNode *LD = cast<LoadSDNode>(N);
Chris Lattnerc2406f22009-04-10 00:16:23 +0000453 if (const Value *Src = LD->getSrcValue())
454 if (const PointerType *PT = dyn_cast<PointerType>(Src->getType()))
Mon P Wanga7e01d72009-04-27 07:22:10 +0000455 if (PT->getAddressSpace() > 255)
Chris Lattnerc2406f22009-04-10 00:16:23 +0000456 return false;
Dan Gohman67ca6be2008-08-20 15:24:22 +0000457 ISD::LoadExtType ExtType = LD->getExtensionType();
458 if (ExtType == ISD::NON_EXTLOAD)
459 return true;
460 if (ExtType == ISD::EXTLOAD)
461 return LD->getAlignment() >= 2 && !LD->isVolatile();
Evan Chengfa7fd332008-05-13 00:54:02 +0000462 return false;
463}]>;
464
Chris Lattnerf85eff72010-03-03 01:52:59 +0000465def loadi16_anyext : PatFrag<(ops node:$ptr), (i32 (unindexedload node:$ptr)),[{
Evan Chengca57f782008-09-24 23:27:55 +0000466 LoadSDNode *LD = cast<LoadSDNode>(N);
Chris Lattnerc2406f22009-04-10 00:16:23 +0000467 if (const Value *Src = LD->getSrcValue())
468 if (const PointerType *PT = dyn_cast<PointerType>(Src->getType()))
Mon P Wanga7e01d72009-04-27 07:22:10 +0000469 if (PT->getAddressSpace() > 255)
Chris Lattnerc2406f22009-04-10 00:16:23 +0000470 return false;
Evan Chengca57f782008-09-24 23:27:55 +0000471 ISD::LoadExtType ExtType = LD->getExtensionType();
472 if (ExtType == ISD::EXTLOAD)
473 return LD->getAlignment() >= 2 && !LD->isVolatile();
474 return false;
475}]>;
476
Dan Gohman33586292008-10-15 06:50:19 +0000477def loadi32 : PatFrag<(ops node:$ptr), (i32 (unindexedload node:$ptr)), [{
Dan Gohman67ca6be2008-08-20 15:24:22 +0000478 LoadSDNode *LD = cast<LoadSDNode>(N);
Chris Lattnerc2406f22009-04-10 00:16:23 +0000479 if (const Value *Src = LD->getSrcValue())
480 if (const PointerType *PT = dyn_cast<PointerType>(Src->getType()))
Mon P Wanga7e01d72009-04-27 07:22:10 +0000481 if (PT->getAddressSpace() > 255)
Chris Lattnerc2406f22009-04-10 00:16:23 +0000482 return false;
Dan Gohman67ca6be2008-08-20 15:24:22 +0000483 ISD::LoadExtType ExtType = LD->getExtensionType();
484 if (ExtType == ISD::NON_EXTLOAD)
485 return true;
486 if (ExtType == ISD::EXTLOAD)
487 return LD->getAlignment() >= 4 && !LD->isVolatile();
Evan Chengfa7fd332008-05-13 00:54:02 +0000488 return false;
489}]>;
490
Chris Lattnerf85eff72010-03-03 01:52:59 +0000491def loadi8 : PatFrag<(ops node:$ptr), (i8 (dsload node:$ptr))>;
492def loadi64 : PatFrag<(ops node:$ptr), (i64 (dsload node:$ptr))>;
493def loadf32 : PatFrag<(ops node:$ptr), (f32 (dsload node:$ptr))>;
494def loadf64 : PatFrag<(ops node:$ptr), (f64 (dsload node:$ptr))>;
495def loadf80 : PatFrag<(ops node:$ptr), (f80 (dsload node:$ptr))>;
Evan Cheng7a7e8372005-12-14 02:22:27 +0000496
Evan Cheng466685d2006-10-09 20:57:25 +0000497def sextloadi16i8 : PatFrag<(ops node:$ptr), (i16 (sextloadi8 node:$ptr))>;
498def sextloadi32i8 : PatFrag<(ops node:$ptr), (i32 (sextloadi8 node:$ptr))>;
499def sextloadi32i16 : PatFrag<(ops node:$ptr), (i32 (sextloadi16 node:$ptr))>;
Evan Cheng7a7e8372005-12-14 02:22:27 +0000500
Evan Cheng466685d2006-10-09 20:57:25 +0000501def zextloadi8i1 : PatFrag<(ops node:$ptr), (i8 (zextloadi1 node:$ptr))>;
502def zextloadi16i1 : PatFrag<(ops node:$ptr), (i16 (zextloadi1 node:$ptr))>;
503def zextloadi32i1 : PatFrag<(ops node:$ptr), (i32 (zextloadi1 node:$ptr))>;
504def zextloadi16i8 : PatFrag<(ops node:$ptr), (i16 (zextloadi8 node:$ptr))>;
505def zextloadi32i8 : PatFrag<(ops node:$ptr), (i32 (zextloadi8 node:$ptr))>;
506def zextloadi32i16 : PatFrag<(ops node:$ptr), (i32 (zextloadi16 node:$ptr))>;
Evan Cheng7a7e8372005-12-14 02:22:27 +0000507
Evan Cheng466685d2006-10-09 20:57:25 +0000508def extloadi8i1 : PatFrag<(ops node:$ptr), (i8 (extloadi1 node:$ptr))>;
509def extloadi16i1 : PatFrag<(ops node:$ptr), (i16 (extloadi1 node:$ptr))>;
510def extloadi32i1 : PatFrag<(ops node:$ptr), (i32 (extloadi1 node:$ptr))>;
511def extloadi16i8 : PatFrag<(ops node:$ptr), (i16 (extloadi8 node:$ptr))>;
512def extloadi32i8 : PatFrag<(ops node:$ptr), (i32 (extloadi8 node:$ptr))>;
513def extloadi32i16 : PatFrag<(ops node:$ptr), (i32 (extloadi16 node:$ptr))>;
Evan Cheng747a90d2006-02-21 02:24:38 +0000514
Chris Lattnerce2bcc82008-02-19 17:37:35 +0000515
516// An 'and' node with a single use.
517def and_su : PatFrag<(ops node:$lhs, node:$rhs), (and node:$lhs, node:$rhs), [{
Evan Cheng07b7ea12008-03-04 00:40:35 +0000518 return N->hasOneUse();
Chris Lattnerce2bcc82008-02-19 17:37:35 +0000519}]>;
Dan Gohman21e3dfb2009-04-13 16:09:41 +0000520// An 'srl' node with a single use.
521def srl_su : PatFrag<(ops node:$lhs, node:$rhs), (srl node:$lhs, node:$rhs), [{
522 return N->hasOneUse();
523}]>;
524// An 'trunc' node with a single use.
525def trunc_su : PatFrag<(ops node:$src), (trunc node:$src), [{
526 return N->hasOneUse();
527}]>;
Chris Lattnerce2bcc82008-02-19 17:37:35 +0000528
Evan Cheng4b0345b2010-01-11 17:03:47 +0000529// Treat an 'or' node is as an 'add' if the or'ed bits are known to be zero.
530def or_is_add : PatFrag<(ops node:$lhs, node:$rhs), (or node:$lhs, node:$rhs),[{
531 if (ConstantSDNode *CN = dyn_cast<ConstantSDNode>(N->getOperand(1)))
532 return CurDAG->MaskedValueIsZero(N->getOperand(0), CN->getAPIntValue());
Chris Lattnerfdac0b62010-03-24 00:12:57 +0000533
534 unsigned BitWidth = N->getValueType(0).getScalarType().getSizeInBits();
535 APInt Mask = APInt::getAllOnesValue(BitWidth);
536 APInt KnownZero0, KnownOne0;
537 CurDAG->ComputeMaskedBits(N->getOperand(0), Mask, KnownZero0, KnownOne0, 0);
538 APInt KnownZero1, KnownOne1;
539 CurDAG->ComputeMaskedBits(N->getOperand(1), Mask, KnownZero1, KnownOne1, 0);
540 return (~KnownZero0 & ~KnownZero1) == 0;
Evan Cheng4b0345b2010-01-11 17:03:47 +0000541}]>;
Evan Cheng4b0345b2010-01-11 17:03:47 +0000542
Chris Lattnerf124d5e2005-11-18 01:04:42 +0000543//===----------------------------------------------------------------------===//
Chris Lattner1cca5e32003-08-03 21:54:21 +0000544// Instruction list...
545//
546
Chris Lattnerf18c0742006-10-12 17:42:56 +0000547// ADJCALLSTACKDOWN/UP implicitly use/def ESP because they may be expanded into
548// a stack adjustment and the codegen must know that they may modify the stack
549// pointer before prolog-epilog rewriting occurs.
Chris Lattner447ff682008-03-11 03:23:40 +0000550// Pessimistically assume ADJCALLSTACKDOWN / ADJCALLSTACKUP will become
551// sub / add which can clobber EFLAGS.
Evan Cheng8decf6b2007-09-28 01:19:48 +0000552let Defs = [ESP, EFLAGS], Uses = [ESP] in {
Dan Gohman6d4b0522008-10-01 18:28:06 +0000553def ADJCALLSTACKDOWN32 : I<0, Pseudo, (outs), (ins i32imm:$amt),
554 "#ADJCALLSTACKDOWN",
Chris Lattnere563bbc2008-10-11 22:08:30 +0000555 [(X86callseq_start timm:$amt)]>,
Dan Gohman6d4b0522008-10-01 18:28:06 +0000556 Requires<[In32BitMode]>;
557def ADJCALLSTACKUP32 : I<0, Pseudo, (outs), (ins i32imm:$amt1, i32imm:$amt2),
558 "#ADJCALLSTACKUP",
Chris Lattnere563bbc2008-10-11 22:08:30 +0000559 [(X86callseq_end timm:$amt1, timm:$amt2)]>,
Dan Gohman6d4b0522008-10-01 18:28:06 +0000560 Requires<[In32BitMode]>;
Evan Cheng071a2792007-09-11 19:55:27 +0000561}
Evan Cheng4a460802006-01-11 00:33:36 +0000562
Dan Gohmand6708ea2009-08-15 01:38:56 +0000563// x86-64 va_start lowering magic.
Anton Korobeynikov043f3c22010-03-06 19:32:29 +0000564let usesCustomInserter = 1 in {
Dan Gohmand6708ea2009-08-15 01:38:56 +0000565def VASTART_SAVE_XMM_REGS : I<0, Pseudo,
566 (outs),
567 (ins GR8:$al,
568 i64imm:$regsavefi, i64imm:$offset,
569 variable_ops),
570 "#VASTART_SAVE_XMM_REGS $al, $regsavefi, $offset",
571 [(X86vastart_save_xmm_regs GR8:$al,
572 imm:$regsavefi,
573 imm:$offset)]>;
574
Anton Korobeynikove765f2b2010-03-06 20:07:32 +0000575// Dynamic stack allocation yields _alloca call for Cygwin/Mingw targets. Calls
576// to _alloca is needed to probe the stack when allocating more than 4k bytes in
577// one go. Touching the stack at 4K increments is necessary to ensure that the
578// guard pages used by the OS virtual memory manager are allocated in correct
579// sequence.
580// The main point of having separate instruction are extra unmodelled effects
581// (compared to ordinary calls) like stack pointer change.
582
Anton Korobeynikov043f3c22010-03-06 19:32:29 +0000583def MINGW_ALLOCA : I<0, Pseudo, (outs), (ins),
Anton Korobeynikove765f2b2010-03-06 20:07:32 +0000584 "# dynamic stack allocation",
Anton Korobeynikov043f3c22010-03-06 19:32:29 +0000585 [(X86MingwAlloca)]>;
586}
587
Evan Cheng4a460802006-01-11 00:33:36 +0000588// Nop
Sean Callanan74e52102009-07-23 23:39:34 +0000589let neverHasSideEffects = 1 in {
Chris Lattnerba7e7562008-01-10 07:59:24 +0000590 def NOOP : I<0x90, RawFrm, (outs), (ins), "nop", []>;
Sean Callanan108934c2009-12-18 00:01:26 +0000591 def NOOPW : I<0x1f, MRM0m, (outs), (ins i16mem:$zero),
592 "nop{w}\t$zero", []>, TB, OpSize;
Sean Callanan74e52102009-07-23 23:39:34 +0000593 def NOOPL : I<0x1f, MRM0m, (outs), (ins i32mem:$zero),
Sean Callanan108934c2009-12-18 00:01:26 +0000594 "nop{l}\t$zero", []>, TB;
Sean Callanan74e52102009-07-23 23:39:34 +0000595}
Evan Cheng4a460802006-01-11 00:33:36 +0000596
Sean Callanan1c5cf1b2009-08-11 01:09:06 +0000597// Trap
Kevin Enderbyc3ce05c2010-05-14 19:16:02 +0000598def INTO : I<0xce, RawFrm, (outs), (ins), "into", []>;
599def INT3 : I<0xcc, RawFrm, (outs), (ins), "int3", []>;
600// FIXME: need to make sure that "int $3" matches int3
601def INT : Ii8<0xcd, RawFrm, (outs), (ins i8imm:$trap), "int\t$trap", []>;
Sean Callanan108934c2009-12-18 00:01:26 +0000602def IRET16 : I<0xcf, RawFrm, (outs), (ins), "iret{w}", []>, OpSize;
603def IRET32 : I<0xcf, RawFrm, (outs), (ins), "iret{l}", []>;
Sean Callanan1c5cf1b2009-08-11 01:09:06 +0000604
Chris Lattner71c7ace2009-09-20 07:32:00 +0000605// PIC base construction. This expands to code that looks like this:
606// call $next_inst
607// popl %destreg"
Dan Gohman2662d552008-10-01 04:14:30 +0000608let neverHasSideEffects = 1, isNotDuplicable = 1, Uses = [ESP] in
Chris Lattnerb3c85472009-09-20 07:28:26 +0000609 def MOVPC32r : Ii32<0xE8, Pseudo, (outs GR32:$reg), (ins i32imm:$label),
Chris Lattner71c7ace2009-09-20 07:32:00 +0000610 "", []>;
Evan Cheng8f7f7122006-05-05 05:40:20 +0000611
Chris Lattner1cca5e32003-08-03 21:54:21 +0000612//===----------------------------------------------------------------------===//
Chris Lattnerbd13fb62010-02-11 19:25:55 +0000613// Control Flow Instructions.
Chris Lattner1cca5e32003-08-03 21:54:21 +0000614//
615
Chris Lattner1be48112005-05-13 17:56:48 +0000616// Return instructions.
Evan Cheng2b4ea792005-12-26 09:11:45 +0000617let isTerminator = 1, isReturn = 1, isBarrier = 1,
Jakob Stoklund Olesen70feca42010-03-25 18:52:01 +0000618 hasCtrlDep = 1, FPForm = SpecialFP in {
Dan Gohmane4c67cd2008-05-31 02:11:25 +0000619 def RET : I <0xC3, RawFrm, (outs), (ins variable_ops),
Chris Lattner447ff682008-03-11 03:23:40 +0000620 "ret",
Dan Gohmane4c67cd2008-05-31 02:11:25 +0000621 [(X86retflag 0)]>;
Chris Lattner447ff682008-03-11 03:23:40 +0000622 def RETI : Ii16<0xC2, RawFrm, (outs), (ins i16imm:$amt, variable_ops),
623 "ret\t$amt",
Dan Gohman2f67df72009-09-03 17:18:51 +0000624 [(X86retflag timm:$amt)]>;
Sean Callanan356aed52009-09-15 23:37:51 +0000625 def LRET : I <0xCB, RawFrm, (outs), (ins),
626 "lret", []>;
627 def LRETI : Ii16<0xCA, RawFrm, (outs), (ins i16imm:$amt),
628 "lret\t$amt", []>;
Evan Cheng171049d2005-12-23 22:14:32 +0000629}
Chris Lattner1cca5e32003-08-03 21:54:21 +0000630
Chris Lattnerbd13fb62010-02-11 19:25:55 +0000631// Unconditional branches.
Chris Lattnerb8db3312010-02-11 21:45:31 +0000632let isBarrier = 1, isBranch = 1, isTerminator = 1 in {
Chris Lattnera0331192010-02-12 22:27:07 +0000633 def JMP_4 : Ii32PCRel<0xE9, RawFrm, (outs), (ins brtarget:$dst),
634 "jmp\t$dst", [(br bb:$dst)]>;
635 def JMP_1 : Ii8PCRel<0xEB, RawFrm, (outs), (ins brtarget8:$dst),
636 "jmp\t$dst", []>;
Sean Callanan52925882009-07-22 01:05:20 +0000637}
Evan Cheng898101c2005-12-19 23:12:38 +0000638
Chris Lattnerbd13fb62010-02-11 19:25:55 +0000639// Conditional Branches.
640let isBranch = 1, isTerminator = 1, Uses = [EFLAGS] in {
641 multiclass ICBr<bits<8> opc1, bits<8> opc4, string asm, PatFrag Cond> {
Chris Lattnera0331192010-02-12 22:27:07 +0000642 def _1 : Ii8PCRel <opc1, RawFrm, (outs), (ins brtarget8:$dst), asm, []>;
643 def _4 : Ii32PCRel<opc4, RawFrm, (outs), (ins brtarget:$dst), asm,
644 [(X86brcond bb:$dst, Cond, EFLAGS)]>, TB;
Chris Lattnerbd13fb62010-02-11 19:25:55 +0000645 }
646}
647
648defm JO : ICBr<0x70, 0x80, "jo\t$dst" , X86_COND_O>;
Chris Lattner8b442a82010-02-11 19:52:11 +0000649defm JNO : ICBr<0x71, 0x81, "jno\t$dst" , X86_COND_NO>;
Chris Lattnerbd13fb62010-02-11 19:25:55 +0000650defm JB : ICBr<0x72, 0x82, "jb\t$dst" , X86_COND_B>;
651defm JAE : ICBr<0x73, 0x83, "jae\t$dst", X86_COND_AE>;
652defm JE : ICBr<0x74, 0x84, "je\t$dst" , X86_COND_E>;
653defm JNE : ICBr<0x75, 0x85, "jne\t$dst", X86_COND_NE>;
654defm JBE : ICBr<0x76, 0x86, "jbe\t$dst", X86_COND_BE>;
655defm JA : ICBr<0x77, 0x87, "ja\t$dst" , X86_COND_A>;
656defm JS : ICBr<0x78, 0x88, "js\t$dst" , X86_COND_S>;
657defm JNS : ICBr<0x79, 0x89, "jns\t$dst", X86_COND_NS>;
658defm JP : ICBr<0x7A, 0x8A, "jp\t$dst" , X86_COND_P>;
659defm JNP : ICBr<0x7B, 0x8B, "jnp\t$dst", X86_COND_NP>;
660defm JL : ICBr<0x7C, 0x8C, "jl\t$dst" , X86_COND_L>;
661defm JGE : ICBr<0x7D, 0x8D, "jge\t$dst", X86_COND_GE>;
662defm JLE : ICBr<0x7E, 0x8E, "jle\t$dst", X86_COND_LE>;
663defm JG : ICBr<0x7F, 0x8F, "jg\t$dst" , X86_COND_G>;
664
665// FIXME: What about the CX/RCX versions of this instruction?
Chris Lattnerb8db3312010-02-11 21:45:31 +0000666let Uses = [ECX], isBranch = 1, isTerminator = 1 in
Chris Lattnera0331192010-02-12 22:27:07 +0000667 def JCXZ8 : Ii8PCRel<0xE3, RawFrm, (outs), (ins brtarget8:$dst),
668 "jcxz\t$dst", []>;
Chris Lattnerbd13fb62010-02-11 19:25:55 +0000669
670
Owen Anderson20ab2902007-11-12 07:39:39 +0000671// Indirect branches
672let isBranch = 1, isTerminator = 1, isBarrier = 1, isIndirectBranch = 1 in {
Dan Gohmanb1576f52007-07-31 20:11:57 +0000673 def JMP32r : I<0xFF, MRM4r, (outs), (ins GR32:$dst), "jmp{l}\t{*}$dst",
Daniel Dunbar77e2dd72010-07-19 20:44:16 +0000674 [(brind GR32:$dst)]>, Requires<[In32BitMode]>;
Dan Gohmanb1576f52007-07-31 20:11:57 +0000675 def JMP32m : I<0xFF, MRM4m, (outs), (ins i32mem:$dst), "jmp{l}\t{*}$dst",
Daniel Dunbar77e2dd72010-07-19 20:44:16 +0000676 [(brind (loadi32 addr:$dst))]>, Requires<[In32BitMode]>;
Sean Callanan76f14be2009-09-15 00:35:17 +0000677
678 def FARJMP16i : Iseg16<0xEA, RawFrm, (outs),
679 (ins i16imm:$seg, i16imm:$off),
680 "ljmp{w}\t$seg, $off", []>, OpSize;
681 def FARJMP32i : Iseg32<0xEA, RawFrm, (outs),
682 (ins i16imm:$seg, i32imm:$off),
683 "ljmp{l}\t$seg, $off", []>;
684
685 def FARJMP16m : I<0xFF, MRM5m, (outs), (ins opaque32mem:$dst),
Sean Callanan9947bbb2009-09-03 00:04:47 +0000686 "ljmp{w}\t{*}$dst", []>, OpSize;
Sean Callanan76f14be2009-09-15 00:35:17 +0000687 def FARJMP32m : I<0xFF, MRM5m, (outs), (ins opaque48mem:$dst),
Sean Callanan9947bbb2009-09-03 00:04:47 +0000688 "ljmp{l}\t{*}$dst", []>;
Nate Begeman37efe672006-04-22 18:53:45 +0000689}
690
Chris Lattner1cca5e32003-08-03 21:54:21 +0000691
Sean Callanan7e6d7272009-09-16 21:50:07 +0000692// Loop instructions
693
Chris Lattner34b8a882010-03-18 20:50:06 +0000694def LOOP : I<0xE2, RawFrm, (outs), (ins brtarget8:$dst), "loop\t$dst", []>;
695def LOOPE : I<0xE1, RawFrm, (outs), (ins brtarget8:$dst), "loope\t$dst", []>;
696def LOOPNE : I<0xE0, RawFrm, (outs), (ins brtarget8:$dst), "loopne\t$dst", []>;
Sean Callanan7e6d7272009-09-16 21:50:07 +0000697
Chris Lattner1cca5e32003-08-03 21:54:21 +0000698//===----------------------------------------------------------------------===//
699// Call Instructions...
700//
Evan Chengffbacca2007-07-21 00:34:19 +0000701let isCall = 1 in
Dan Gohman6d4b0522008-10-01 18:28:06 +0000702 // All calls clobber the non-callee saved registers. ESP is marked as
703 // a use to prevent stack-pointer assignments that appear immediately
704 // before calls from potentially appearing dead. Uses for argument
705 // registers are added manually.
Nate Begemanf63be7d2005-07-06 18:59:04 +0000706 let Defs = [EAX, ECX, EDX, FP0, FP1, FP2, FP3, FP4, FP5, FP6, ST0,
Bill Wendling3f3a17d2007-04-25 21:31:48 +0000707 MM0, MM1, MM2, MM3, MM4, MM5, MM6, MM7,
Evan Cheng109a5622008-10-17 21:02:22 +0000708 XMM0, XMM1, XMM2, XMM3, XMM4, XMM5, XMM6, XMM7,
709 XMM8, XMM9, XMM10, XMM11, XMM12, XMM13, XMM14, XMM15, EFLAGS],
Dan Gohman2662d552008-10-01 04:14:30 +0000710 Uses = [ESP] in {
Chris Lattnera0331192010-02-12 22:27:07 +0000711 def CALLpcrel32 : Ii32PCRel<0xE8, RawFrm,
Chris Lattner7680e732009-06-20 19:34:09 +0000712 (outs), (ins i32imm_pcrel:$dst,variable_ops),
713 "call\t$dst", []>;
Evan Cheng64d80e32007-07-19 01:14:50 +0000714 def CALL32r : I<0xFF, MRM2r, (outs), (ins GR32:$dst, variable_ops),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000715 "call\t{*}$dst", [(X86call GR32:$dst)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +0000716 def CALL32m : I<0xFF, MRM2m, (outs), (ins i32mem:$dst, variable_ops),
Dan Gohmanb4106172008-05-29 21:50:34 +0000717 "call\t{*}$dst", [(X86call (loadi32 addr:$dst))]>;
Sean Callanan9947bbb2009-09-03 00:04:47 +0000718
Sean Callanan76f14be2009-09-15 00:35:17 +0000719 def FARCALL16i : Iseg16<0x9A, RawFrm, (outs),
720 (ins i16imm:$seg, i16imm:$off),
721 "lcall{w}\t$seg, $off", []>, OpSize;
722 def FARCALL32i : Iseg32<0x9A, RawFrm, (outs),
723 (ins i16imm:$seg, i32imm:$off),
724 "lcall{l}\t$seg, $off", []>;
725
726 def FARCALL16m : I<0xFF, MRM3m, (outs), (ins opaque32mem:$dst),
Sean Callanan9947bbb2009-09-03 00:04:47 +0000727 "lcall{w}\t{*}$dst", []>, OpSize;
Sean Callanan76f14be2009-09-15 00:35:17 +0000728 def FARCALL32m : I<0xFF, MRM3m, (outs), (ins opaque48mem:$dst),
Sean Callanan9947bbb2009-09-03 00:04:47 +0000729 "lcall{l}\t{*}$dst", []>;
Chris Lattner9fc05222010-07-07 22:27:31 +0000730
731 // callw for 16 bit code for the assembler.
732 let isAsmParserOnly = 1 in
733 def CALLpcrel16 : Ii16PCRel<0xE8, RawFrm,
734 (outs), (ins i16imm_pcrel:$dst, variable_ops),
735 "callw\t$dst", []>, OpSize;
Chris Lattner1cca5e32003-08-03 21:54:21 +0000736 }
737
Sean Callanan8d708542009-09-16 02:57:13 +0000738// Constructing a stack frame.
739
740def ENTER : I<0xC8, RawFrm, (outs), (ins i16imm:$len, i8imm:$lvl),
741 "enter\t$len, $lvl", []>;
742
Chris Lattner1e9448b2005-05-15 03:10:37 +0000743// Tail call stuff.
Arnold Schwaighoferc85e1712007-10-11 19:40:01 +0000744
Daniel Dunbare4c52a22010-07-19 07:21:04 +0000745let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1,
746 isCodeGenOnly = 1 in
Evan Chengf48ef032010-03-14 03:48:46 +0000747 let Defs = [EAX, ECX, EDX, FP0, FP1, FP2, FP3, FP4, FP5, FP6, ST0,
748 MM0, MM1, MM2, MM3, MM4, MM5, MM6, MM7,
749 XMM0, XMM1, XMM2, XMM3, XMM4, XMM5, XMM6, XMM7,
750 XMM8, XMM9, XMM10, XMM11, XMM12, XMM13, XMM14, XMM15, EFLAGS],
751 Uses = [ESP] in {
752 def TCRETURNdi : I<0, Pseudo, (outs),
753 (ins i32imm_pcrel:$dst, i32imm:$offset, variable_ops),
754 "#TC_RETURN $dst $offset", []>;
755 def TCRETURNri : I<0, Pseudo, (outs),
756 (ins GR32_TC:$dst, i32imm:$offset, variable_ops),
757 "#TC_RETURN $dst $offset", []>;
Dan Gohman7f357ec2010-05-14 16:34:55 +0000758 let mayLoad = 1 in
Evan Chengf48ef032010-03-14 03:48:46 +0000759 def TCRETURNmi : I<0, Pseudo, (outs),
760 (ins i32mem_TC:$dst, i32imm:$offset, variable_ops),
761 "#TC_RETURN $dst $offset", []>;
Arnold Schwaighoferc85e1712007-10-11 19:40:01 +0000762
Evan Chengf48ef032010-03-14 03:48:46 +0000763 // FIXME: The should be pseudo instructions that are lowered when going to
764 // mcinst.
Chris Lattner840e6372010-03-16 06:30:18 +0000765 def TAILJMPd : Ii32PCRel<0xE9, RawFrm, (outs),
766 (ins i32imm_pcrel:$dst, variable_ops),
Evan Chengaa92bec2010-01-31 07:28:44 +0000767 "jmp\t$dst # TAILCALL",
Evan Chengf10c17f2006-09-22 21:43:59 +0000768 []>;
Evan Chengf48ef032010-03-14 03:48:46 +0000769 def TAILJMPr : I<0xFF, MRM4r, (outs), (ins GR32_TC:$dst, variable_ops),
Chris Lattnerc5f56262010-07-09 00:49:41 +0000770 "", []>; // FIXME: Remove encoding when JIT is dead.
Dan Gohman7f357ec2010-05-14 16:34:55 +0000771 let mayLoad = 1 in
Evan Chengf48ef032010-03-14 03:48:46 +0000772 def TAILJMPm : I<0xFF, MRM4m, (outs), (ins i32mem_TC:$dst, variable_ops),
773 "jmp{l}\t{*}$dst # TAILCALL", []>;
774}
Chris Lattner1e9448b2005-05-15 03:10:37 +0000775
Chris Lattner1cca5e32003-08-03 21:54:21 +0000776//===----------------------------------------------------------------------===//
777// Miscellaneous Instructions...
778//
Chris Lattnerba7e7562008-01-10 07:59:24 +0000779let Defs = [EBP, ESP], Uses = [EBP, ESP], mayLoad = 1, neverHasSideEffects=1 in
Chris Lattner30bf2d82004-08-10 20:17:41 +0000780def LEAVE : I<0xC9, RawFrm,
Daniel Dunbardf4c47b2010-07-19 07:21:01 +0000781 (outs), (ins), "leave", []>, Requires<[In32BitMode]>;
Evan Cheng071a2792007-09-11 19:55:27 +0000782
Sean Callanan108934c2009-12-18 00:01:26 +0000783def POPCNT16rr : I<0xB8, MRMSrcReg, (outs GR16:$dst), (ins GR16:$src),
784 "popcnt{w}\t{$src, $dst|$dst, $src}", []>, OpSize, XS;
Dan Gohman7f357ec2010-05-14 16:34:55 +0000785let mayLoad = 1 in
Sean Callanan108934c2009-12-18 00:01:26 +0000786def POPCNT16rm : I<0xB8, MRMSrcMem, (outs GR16:$dst), (ins i16mem:$src),
787 "popcnt{w}\t{$src, $dst|$dst, $src}", []>, OpSize, XS;
788def POPCNT32rr : I<0xB8, MRMSrcReg, (outs GR32:$dst), (ins GR32:$src),
789 "popcnt{l}\t{$src, $dst|$dst, $src}", []>, XS;
Dan Gohman7f357ec2010-05-14 16:34:55 +0000790let mayLoad = 1 in
Sean Callanan108934c2009-12-18 00:01:26 +0000791def POPCNT32rm : I<0xB8, MRMSrcMem, (outs GR32:$dst), (ins i32mem:$src),
792 "popcnt{l}\t{$src, $dst|$dst, $src}", []>, XS;
793
Chris Lattnerba7e7562008-01-10 07:59:24 +0000794let Defs = [ESP], Uses = [ESP], neverHasSideEffects=1 in {
Sean Callanan1f24e012009-09-10 18:29:13 +0000795let mayLoad = 1 in {
796def POP16r : I<0x58, AddRegFrm, (outs GR16:$reg), (ins), "pop{w}\t$reg", []>,
797 OpSize;
798def POP32r : I<0x58, AddRegFrm, (outs GR32:$reg), (ins), "pop{l}\t$reg", []>;
799def POP16rmr: I<0x8F, MRM0r, (outs GR16:$reg), (ins), "pop{w}\t$reg", []>,
800 OpSize;
801def POP16rmm: I<0x8F, MRM0m, (outs i16mem:$dst), (ins), "pop{w}\t$dst", []>,
802 OpSize;
803def POP32rmr: I<0x8F, MRM0r, (outs GR32:$reg), (ins), "pop{l}\t$reg", []>;
804def POP32rmm: I<0x8F, MRM0m, (outs i32mem:$dst), (ins), "pop{l}\t$dst", []>;
805}
Chris Lattner1cca5e32003-08-03 21:54:21 +0000806
Sean Callanan1f24e012009-09-10 18:29:13 +0000807let mayStore = 1 in {
808def PUSH16r : I<0x50, AddRegFrm, (outs), (ins GR16:$reg), "push{w}\t$reg",[]>,
809 OpSize;
Evan Cheng2f245ba2007-09-26 01:29:06 +0000810def PUSH32r : I<0x50, AddRegFrm, (outs), (ins GR32:$reg), "push{l}\t$reg",[]>;
Sean Callanan1f24e012009-09-10 18:29:13 +0000811def PUSH16rmr: I<0xFF, MRM6r, (outs), (ins GR16:$reg), "push{w}\t$reg",[]>,
812 OpSize;
813def PUSH16rmm: I<0xFF, MRM6m, (outs), (ins i16mem:$src), "push{w}\t$src",[]>,
814 OpSize;
815def PUSH32rmr: I<0xFF, MRM6r, (outs), (ins GR32:$reg), "push{l}\t$reg",[]>;
816def PUSH32rmm: I<0xFF, MRM6m, (outs), (ins i32mem:$src), "push{l}\t$src",[]>;
817}
Evan Cheng071a2792007-09-11 19:55:27 +0000818}
Anton Korobeynikov57fc00d2007-04-17 09:20:00 +0000819
Bill Wendling453eb262009-06-15 19:39:04 +0000820let Defs = [ESP], Uses = [ESP], neverHasSideEffects = 1, mayStore = 1 in {
Kevin Enderby3c979b02010-05-03 20:45:05 +0000821def PUSHi8 : Ii8<0x6a, RawFrm, (outs), (ins i32i8imm:$imm),
Bill Wendling927788c2009-06-15 20:59:31 +0000822 "push{l}\t$imm", []>;
Kevin Enderby3c979b02010-05-03 20:45:05 +0000823def PUSHi16 : Ii16<0x68, RawFrm, (outs), (ins i16imm:$imm),
824 "push{w}\t$imm", []>, OpSize;
825def PUSHi32 : Ii32<0x68, RawFrm, (outs), (ins i32imm:$imm),
Bill Wendling927788c2009-06-15 20:59:31 +0000826 "push{l}\t$imm", []>;
Bill Wendling453eb262009-06-15 19:39:04 +0000827}
828
Sean Callanan108934c2009-12-18 00:01:26 +0000829let Defs = [ESP, EFLAGS], Uses = [ESP], mayLoad = 1, neverHasSideEffects=1 in {
Dan Gohmane5e4ff92010-05-20 16:16:00 +0000830def POPF16 : I<0x9D, RawFrm, (outs), (ins), "popf{w}", []>, OpSize;
831def POPF32 : I<0x9D, RawFrm, (outs), (ins), "popf{l|d}", []>,
832 Requires<[In32BitMode]>;
Sean Callanan108934c2009-12-18 00:01:26 +0000833}
834let Defs = [ESP], Uses = [ESP, EFLAGS], mayStore = 1, neverHasSideEffects=1 in {
Dan Gohmane5e4ff92010-05-20 16:16:00 +0000835def PUSHF16 : I<0x9C, RawFrm, (outs), (ins), "pushf{w}", []>, OpSize;
836def PUSHF32 : I<0x9C, RawFrm, (outs), (ins), "pushf{l|d}", []>,
837 Requires<[In32BitMode]>;
Sean Callanan108934c2009-12-18 00:01:26 +0000838}
Evan Cheng2f245ba2007-09-26 01:29:06 +0000839
Nico Weber50b9efc2010-06-23 20:00:58 +0000840let Defs = [EDI, ESI, EBP, EBX, EDX, ECX, EAX, ESP], Uses = [ESP],
841 mayLoad=1, neverHasSideEffects=1 in {
842def POPA32 : I<0x61, RawFrm, (outs), (ins), "popa{l}", []>,
843 Requires<[In32BitMode]>;
844}
845let Defs = [ESP], Uses = [EDI, ESI, EBP, EBX, EDX, ECX, EAX, ESP],
846 mayStore=1, neverHasSideEffects=1 in {
847def PUSHA32 : I<0x60, RawFrm, (outs), (ins), "pusha{l}", []>,
848 Requires<[In32BitMode]>;
849}
850
Eric Christophera938cfb2010-06-19 00:37:40 +0000851let Uses = [EFLAGS], Constraints = "$src = $dst" in // GR32 = bswap GR32
Chris Lattner30bf2d82004-08-10 20:17:41 +0000852 def BSWAP32r : I<0xC8, AddRegFrm,
Evan Cheng64d80e32007-07-19 01:14:50 +0000853 (outs GR32:$dst), (ins GR32:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000854 "bswap{l}\t$dst",
Evan Cheng069287d2006-05-16 07:21:53 +0000855 [(set GR32:$dst, (bswap GR32:$src))]>, TB;
Chris Lattner1cca5e32003-08-03 21:54:21 +0000856
Chris Lattner1cca5e32003-08-03 21:54:21 +0000857
Evan Cheng18efe262007-12-14 02:13:44 +0000858// Bit scan instructions.
859let Defs = [EFLAGS] in {
Evan Chengfd9e4732007-12-14 18:49:43 +0000860def BSF16rr : I<0xBC, MRMSrcReg, (outs GR16:$dst), (ins GR16:$src),
Dan Gohman1a8001e2007-12-14 15:10:00 +0000861 "bsf{w}\t{$src, $dst|$dst, $src}",
Kevin Enderby9ac72822010-04-28 23:20:40 +0000862 [(set GR16:$dst, EFLAGS, (X86bsf GR16:$src))]>, TB, OpSize;
Evan Cheng18efe262007-12-14 02:13:44 +0000863def BSF16rm : I<0xBC, MRMSrcMem, (outs GR16:$dst), (ins i16mem:$src),
Dan Gohman1a8001e2007-12-14 15:10:00 +0000864 "bsf{w}\t{$src, $dst|$dst, $src}",
Kevin Enderby9ac72822010-04-28 23:20:40 +0000865 [(set GR16:$dst, EFLAGS, (X86bsf (loadi16 addr:$src)))]>, TB,
866 OpSize;
Evan Chengfd9e4732007-12-14 18:49:43 +0000867def BSF32rr : I<0xBC, MRMSrcReg, (outs GR32:$dst), (ins GR32:$src),
Dan Gohman1a8001e2007-12-14 15:10:00 +0000868 "bsf{l}\t{$src, $dst|$dst, $src}",
Chris Lattnerd486d772010-03-28 05:07:17 +0000869 [(set GR32:$dst, EFLAGS, (X86bsf GR32:$src))]>, TB;
Evan Cheng18efe262007-12-14 02:13:44 +0000870def BSF32rm : I<0xBC, MRMSrcMem, (outs GR32:$dst), (ins i32mem:$src),
Dan Gohman1a8001e2007-12-14 15:10:00 +0000871 "bsf{l}\t{$src, $dst|$dst, $src}",
Chris Lattnerd486d772010-03-28 05:07:17 +0000872 [(set GR32:$dst, EFLAGS, (X86bsf (loadi32 addr:$src)))]>, TB;
Evan Cheng18efe262007-12-14 02:13:44 +0000873
Evan Chengfd9e4732007-12-14 18:49:43 +0000874def BSR16rr : I<0xBD, MRMSrcReg, (outs GR16:$dst), (ins GR16:$src),
Dan Gohman1a8001e2007-12-14 15:10:00 +0000875 "bsr{w}\t{$src, $dst|$dst, $src}",
Kevin Enderby9ac72822010-04-28 23:20:40 +0000876 [(set GR16:$dst, EFLAGS, (X86bsr GR16:$src))]>, TB, OpSize;
Evan Cheng18efe262007-12-14 02:13:44 +0000877def BSR16rm : I<0xBD, MRMSrcMem, (outs GR16:$dst), (ins i16mem:$src),
Dan Gohman1a8001e2007-12-14 15:10:00 +0000878 "bsr{w}\t{$src, $dst|$dst, $src}",
Kevin Enderby9ac72822010-04-28 23:20:40 +0000879 [(set GR16:$dst, EFLAGS, (X86bsr (loadi16 addr:$src)))]>, TB,
880 OpSize;
Evan Chengfd9e4732007-12-14 18:49:43 +0000881def BSR32rr : I<0xBD, MRMSrcReg, (outs GR32:$dst), (ins GR32:$src),
Dan Gohman1a8001e2007-12-14 15:10:00 +0000882 "bsr{l}\t{$src, $dst|$dst, $src}",
Chris Lattnerd486d772010-03-28 05:07:17 +0000883 [(set GR32:$dst, EFLAGS, (X86bsr GR32:$src))]>, TB;
Evan Cheng18efe262007-12-14 02:13:44 +0000884def BSR32rm : I<0xBD, MRMSrcMem, (outs GR32:$dst), (ins i32mem:$src),
Dan Gohman1a8001e2007-12-14 15:10:00 +0000885 "bsr{l}\t{$src, $dst|$dst, $src}",
Chris Lattnerd486d772010-03-28 05:07:17 +0000886 [(set GR32:$dst, EFLAGS, (X86bsr (loadi32 addr:$src)))]>, TB;
Evan Cheng18efe262007-12-14 02:13:44 +0000887} // Defs = [EFLAGS]
888
Chris Lattnerba7e7562008-01-10 07:59:24 +0000889let neverHasSideEffects = 1 in
Chris Lattner3a173df2004-10-03 20:35:00 +0000890def LEA16r : I<0x8D, MRMSrcMem,
Chris Lattner599b5312010-07-08 23:46:44 +0000891 (outs GR16:$dst), (ins i32mem:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000892 "lea{w}\t{$src|$dst}, {$dst|$src}", []>, OpSize;
Evan Chenge771ebd2008-03-27 01:41:09 +0000893let isReMaterializable = 1 in
Chris Lattner3a173df2004-10-03 20:35:00 +0000894def LEA32r : I<0x8D, MRMSrcMem,
Chris Lattner599b5312010-07-08 23:46:44 +0000895 (outs GR32:$dst), (ins i32mem:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000896 "lea{l}\t{$src|$dst}, {$dst|$src}",
Evan Cheng25ab6902006-09-08 06:48:29 +0000897 [(set GR32:$dst, lea32addr:$src)]>, Requires<[In32BitMode]>;
Chris Lattner1cca5e32003-08-03 21:54:21 +0000898
Kevin Enderby12ce0de2010-02-03 21:04:42 +0000899let Defs = [ECX,EDI,ESI], Uses = [ECX,EDI,ESI], isCodeGenOnly = 1 in {
Evan Cheng64d80e32007-07-19 01:14:50 +0000900def REP_MOVSB : I<0xA4, RawFrm, (outs), (ins), "{rep;movsb|rep movsb}",
Evan Cheng071a2792007-09-11 19:55:27 +0000901 [(X86rep_movs i8)]>, REP;
Evan Cheng64d80e32007-07-19 01:14:50 +0000902def REP_MOVSW : I<0xA5, RawFrm, (outs), (ins), "{rep;movsw|rep movsw}",
Evan Cheng071a2792007-09-11 19:55:27 +0000903 [(X86rep_movs i16)]>, REP, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +0000904def REP_MOVSD : I<0xA5, RawFrm, (outs), (ins), "{rep;movsl|rep movsd}",
Evan Cheng071a2792007-09-11 19:55:27 +0000905 [(X86rep_movs i32)]>, REP;
906}
Chris Lattner915e5e52004-02-12 17:53:22 +0000907
Kevin Enderby12ce0de2010-02-03 21:04:42 +0000908// These uses the DF flag in the EFLAGS register to inc or dec EDI and ESI
909let Defs = [EDI,ESI], Uses = [EDI,ESI,EFLAGS] in {
910def MOVSB : I<0xA4, RawFrm, (outs), (ins), "{movsb}", []>;
911def MOVSW : I<0xA5, RawFrm, (outs), (ins), "{movsw}", []>, OpSize;
912def MOVSD : I<0xA5, RawFrm, (outs), (ins), "{movsl|movsd}", []>;
913}
914
915let Defs = [ECX,EDI], Uses = [AL,ECX,EDI], isCodeGenOnly = 1 in
Evan Cheng64d80e32007-07-19 01:14:50 +0000916def REP_STOSB : I<0xAA, RawFrm, (outs), (ins), "{rep;stosb|rep stosb}",
Evan Cheng071a2792007-09-11 19:55:27 +0000917 [(X86rep_stos i8)]>, REP;
Kevin Enderby12ce0de2010-02-03 21:04:42 +0000918let Defs = [ECX,EDI], Uses = [AX,ECX,EDI], isCodeGenOnly = 1 in
Evan Cheng64d80e32007-07-19 01:14:50 +0000919def REP_STOSW : I<0xAB, RawFrm, (outs), (ins), "{rep;stosw|rep stosw}",
Evan Cheng071a2792007-09-11 19:55:27 +0000920 [(X86rep_stos i16)]>, REP, OpSize;
Kevin Enderby12ce0de2010-02-03 21:04:42 +0000921let Defs = [ECX,EDI], Uses = [EAX,ECX,EDI], isCodeGenOnly = 1 in
Evan Cheng64d80e32007-07-19 01:14:50 +0000922def REP_STOSD : I<0xAB, RawFrm, (outs), (ins), "{rep;stosl|rep stosd}",
Evan Cheng071a2792007-09-11 19:55:27 +0000923 [(X86rep_stos i32)]>, REP;
Chris Lattner30bf2d82004-08-10 20:17:41 +0000924
Kevin Enderby12ce0de2010-02-03 21:04:42 +0000925// These uses the DF flag in the EFLAGS register to inc or dec EDI and ESI
926let Defs = [EDI], Uses = [AL,EDI,EFLAGS] in
927def STOSB : I<0xAA, RawFrm, (outs), (ins), "{stosb}", []>;
928let Defs = [EDI], Uses = [AX,EDI,EFLAGS] in
929def STOSW : I<0xAB, RawFrm, (outs), (ins), "{stosw}", []>, OpSize;
930let Defs = [EDI], Uses = [EAX,EDI,EFLAGS] in
931def STOSD : I<0xAB, RawFrm, (outs), (ins), "{stosl|stosd}", []>;
932
Sean Callanana82e4652009-09-12 00:37:19 +0000933def SCAS8 : I<0xAE, RawFrm, (outs), (ins), "scas{b}", []>;
934def SCAS16 : I<0xAF, RawFrm, (outs), (ins), "scas{w}", []>, OpSize;
935def SCAS32 : I<0xAF, RawFrm, (outs), (ins), "scas{l}", []>;
936
Sean Callanan6f8f4622009-09-12 02:25:20 +0000937def CMPS8 : I<0xA6, RawFrm, (outs), (ins), "cmps{b}", []>;
938def CMPS16 : I<0xA7, RawFrm, (outs), (ins), "cmps{w}", []>, OpSize;
939def CMPS32 : I<0xA7, RawFrm, (outs), (ins), "cmps{l}", []>;
940
Evan Cheng071a2792007-09-11 19:55:27 +0000941let Defs = [RAX, RDX] in
Evan Cheng64d80e32007-07-19 01:14:50 +0000942def RDTSC : I<0x31, RawFrm, (outs), (ins), "rdtsc", [(X86rdtsc)]>,
Evan Cheng071a2792007-09-11 19:55:27 +0000943 TB;
Chris Lattnerb89abef2004-02-14 04:45:37 +0000944
Sean Callanancebe9552010-02-13 02:06:11 +0000945let Defs = [RAX, RCX, RDX] in
946def RDTSCP : I<0x01, MRM_F9, (outs), (ins), "rdtscp", []>, TB;
947
Dan Gohmaneffc8c52010-05-14 16:46:02 +0000948let isTerminator = 1, isBarrier = 1, hasCtrlDep = 1 in {
Chris Lattnerda68d302008-01-15 21:58:22 +0000949def TRAP : I<0x0B, RawFrm, (outs), (ins), "ud2", [(trap)]>, TB;
Anton Korobeynikov66fac792008-01-15 07:02:33 +0000950}
951
Chris Lattner02552de2009-08-11 16:58:39 +0000952def SYSCALL : I<0x05, RawFrm,
953 (outs), (ins), "syscall", []>, TB;
954def SYSRET : I<0x07, RawFrm,
955 (outs), (ins), "sysret", []>, TB;
956def SYSENTER : I<0x34, RawFrm,
957 (outs), (ins), "sysenter", []>, TB;
958def SYSEXIT : I<0x35, RawFrm,
Daniel Dunbardf4c47b2010-07-19 07:21:01 +0000959 (outs), (ins), "sysexit", []>, TB, Requires<[In32BitMode]>;
Chris Lattner02552de2009-08-11 16:58:39 +0000960
Sean Callanan2a46f362009-09-12 02:52:41 +0000961def WAIT : I<0x9B, RawFrm, (outs), (ins), "wait", []>;
Chris Lattner02552de2009-08-11 16:58:39 +0000962
963
Chris Lattner1cca5e32003-08-03 21:54:21 +0000964//===----------------------------------------------------------------------===//
John Criswell4ffff9e2004-04-08 20:31:47 +0000965// Input/Output Instructions...
966//
Evan Cheng071a2792007-09-11 19:55:27 +0000967let Defs = [AL], Uses = [DX] in
Evan Cheng64d80e32007-07-19 01:14:50 +0000968def IN8rr : I<0xEC, RawFrm, (outs), (ins),
Evan Cheng071a2792007-09-11 19:55:27 +0000969 "in{b}\t{%dx, %al|%AL, %DX}", []>;
970let Defs = [AX], Uses = [DX] in
Evan Cheng64d80e32007-07-19 01:14:50 +0000971def IN16rr : I<0xED, RawFrm, (outs), (ins),
Evan Cheng071a2792007-09-11 19:55:27 +0000972 "in{w}\t{%dx, %ax|%AX, %DX}", []>, OpSize;
973let Defs = [EAX], Uses = [DX] in
Evan Cheng64d80e32007-07-19 01:14:50 +0000974def IN32rr : I<0xED, RawFrm, (outs), (ins),
Evan Cheng071a2792007-09-11 19:55:27 +0000975 "in{l}\t{%dx, %eax|%EAX, %DX}", []>;
John Criswell4ffff9e2004-04-08 20:31:47 +0000976
Evan Cheng071a2792007-09-11 19:55:27 +0000977let Defs = [AL] in
Evan Cheng64d80e32007-07-19 01:14:50 +0000978def IN8ri : Ii8<0xE4, RawFrm, (outs), (ins i16i8imm:$port),
Evan Cheng071a2792007-09-11 19:55:27 +0000979 "in{b}\t{$port, %al|%AL, $port}", []>;
980let Defs = [AX] in
Evan Cheng64d80e32007-07-19 01:14:50 +0000981def IN16ri : Ii8<0xE5, RawFrm, (outs), (ins i16i8imm:$port),
Evan Cheng071a2792007-09-11 19:55:27 +0000982 "in{w}\t{$port, %ax|%AX, $port}", []>, OpSize;
983let Defs = [EAX] in
Evan Cheng64d80e32007-07-19 01:14:50 +0000984def IN32ri : Ii8<0xE5, RawFrm, (outs), (ins i16i8imm:$port),
Evan Cheng071a2792007-09-11 19:55:27 +0000985 "in{l}\t{$port, %eax|%EAX, $port}", []>;
Chris Lattner440bbc22004-04-13 17:19:31 +0000986
Evan Cheng071a2792007-09-11 19:55:27 +0000987let Uses = [DX, AL] in
Evan Cheng64d80e32007-07-19 01:14:50 +0000988def OUT8rr : I<0xEE, RawFrm, (outs), (ins),
Evan Cheng071a2792007-09-11 19:55:27 +0000989 "out{b}\t{%al, %dx|%DX, %AL}", []>;
990let Uses = [DX, AX] in
Evan Cheng64d80e32007-07-19 01:14:50 +0000991def OUT16rr : I<0xEF, RawFrm, (outs), (ins),
Evan Cheng071a2792007-09-11 19:55:27 +0000992 "out{w}\t{%ax, %dx|%DX, %AX}", []>, OpSize;
993let Uses = [DX, EAX] in
Evan Cheng64d80e32007-07-19 01:14:50 +0000994def OUT32rr : I<0xEF, RawFrm, (outs), (ins),
Evan Cheng071a2792007-09-11 19:55:27 +0000995 "out{l}\t{%eax, %dx|%DX, %EAX}", []>;
Chris Lattnerffff7082004-08-01 07:44:35 +0000996
Evan Cheng071a2792007-09-11 19:55:27 +0000997let Uses = [AL] in
Evan Cheng64d80e32007-07-19 01:14:50 +0000998def OUT8ir : Ii8<0xE6, RawFrm, (outs), (ins i16i8imm:$port),
Evan Cheng071a2792007-09-11 19:55:27 +0000999 "out{b}\t{%al, $port|$port, %AL}", []>;
1000let Uses = [AX] in
Evan Cheng64d80e32007-07-19 01:14:50 +00001001def OUT16ir : Ii8<0xE7, RawFrm, (outs), (ins i16i8imm:$port),
Evan Cheng071a2792007-09-11 19:55:27 +00001002 "out{w}\t{%ax, $port|$port, %AX}", []>, OpSize;
1003let Uses = [EAX] in
Evan Cheng64d80e32007-07-19 01:14:50 +00001004def OUT32ir : Ii8<0xE7, RawFrm, (outs), (ins i16i8imm:$port),
Evan Cheng071a2792007-09-11 19:55:27 +00001005 "out{l}\t{%eax, $port|$port, %EAX}", []>;
John Criswell4ffff9e2004-04-08 20:31:47 +00001006
Sean Callanan108934c2009-12-18 00:01:26 +00001007def IN8 : I<0x6C, RawFrm, (outs), (ins),
1008 "ins{b}", []>;
1009def IN16 : I<0x6D, RawFrm, (outs), (ins),
1010 "ins{w}", []>, OpSize;
1011def IN32 : I<0x6D, RawFrm, (outs), (ins),
1012 "ins{l}", []>;
1013
John Criswell4ffff9e2004-04-08 20:31:47 +00001014//===----------------------------------------------------------------------===//
Chris Lattner1cca5e32003-08-03 21:54:21 +00001015// Move Instructions...
1016//
Chris Lattnerba7e7562008-01-10 07:59:24 +00001017let neverHasSideEffects = 1 in {
Evan Cheng64d80e32007-07-19 01:14:50 +00001018def MOV8rr : I<0x88, MRMDestReg, (outs GR8 :$dst), (ins GR8 :$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001019 "mov{b}\t{$src, $dst|$dst, $src}", []>;
Evan Cheng64d80e32007-07-19 01:14:50 +00001020def MOV16rr : I<0x89, MRMDestReg, (outs GR16:$dst), (ins GR16:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001021 "mov{w}\t{$src, $dst|$dst, $src}", []>, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00001022def MOV32rr : I<0x89, MRMDestReg, (outs GR32:$dst), (ins GR32:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001023 "mov{l}\t{$src, $dst|$dst, $src}", []>;
Chris Lattnerba7e7562008-01-10 07:59:24 +00001024}
Evan Cheng359e9372008-06-18 08:13:07 +00001025let isReMaterializable = 1, isAsCheapAsAMove = 1 in {
Evan Cheng64d80e32007-07-19 01:14:50 +00001026def MOV8ri : Ii8 <0xB0, AddRegFrm, (outs GR8 :$dst), (ins i8imm :$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001027 "mov{b}\t{$src, $dst|$dst, $src}",
Evan Cheng069287d2006-05-16 07:21:53 +00001028 [(set GR8:$dst, imm:$src)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00001029def MOV16ri : Ii16<0xB8, AddRegFrm, (outs GR16:$dst), (ins i16imm:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001030 "mov{w}\t{$src, $dst|$dst, $src}",
Evan Cheng069287d2006-05-16 07:21:53 +00001031 [(set GR16:$dst, imm:$src)]>, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00001032def MOV32ri : Ii32<0xB8, AddRegFrm, (outs GR32:$dst), (ins i32imm:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001033 "mov{l}\t{$src, $dst|$dst, $src}",
Evan Cheng069287d2006-05-16 07:21:53 +00001034 [(set GR32:$dst, imm:$src)]>;
Dan Gohmand45eddd2007-06-26 00:48:07 +00001035}
Kevin Enderby12ce0de2010-02-03 21:04:42 +00001036
Evan Cheng64d80e32007-07-19 01:14:50 +00001037def MOV8mi : Ii8 <0xC6, MRM0m, (outs), (ins i8mem :$dst, i8imm :$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001038 "mov{b}\t{$src, $dst|$dst, $src}",
Evan Chengb51a0592005-12-10 00:48:20 +00001039 [(store (i8 imm:$src), addr:$dst)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00001040def MOV16mi : Ii16<0xC7, MRM0m, (outs), (ins i16mem:$dst, i16imm:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001041 "mov{w}\t{$src, $dst|$dst, $src}",
Evan Chengb51a0592005-12-10 00:48:20 +00001042 [(store (i16 imm:$src), addr:$dst)]>, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00001043def MOV32mi : Ii32<0xC7, MRM0m, (outs), (ins i32mem:$dst, i32imm:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001044 "mov{l}\t{$src, $dst|$dst, $src}",
Evan Chengb51a0592005-12-10 00:48:20 +00001045 [(store (i32 imm:$src), addr:$dst)]>;
Chris Lattner1cca5e32003-08-03 21:54:21 +00001046
Chris Lattnerb5505d02010-05-13 00:02:47 +00001047/// moffs8, moffs16 and moffs32 versions of moves. The immediate is a
1048/// 32-bit offset from the PC. These are only valid in x86-32 mode.
Chris Lattner2745f6e2010-05-12 22:48:24 +00001049def MOV8o8a : Ii32 <0xA0, RawFrm, (outs), (ins offset8:$src),
Daniel Dunbar6c2c9a22010-07-19 06:14:44 +00001050 "mov{b}\t{$src, %al|%al, $src}", []>,
1051 Requires<[In32BitMode]>;
Chris Lattner2745f6e2010-05-12 22:48:24 +00001052def MOV16o16a : Ii32 <0xA1, RawFrm, (outs), (ins offset16:$src),
Daniel Dunbar6c2c9a22010-07-19 06:14:44 +00001053 "mov{w}\t{$src, %ax|%ax, $src}", []>, OpSize,
1054 Requires<[In32BitMode]>;
Sean Callanan108934c2009-12-18 00:01:26 +00001055def MOV32o32a : Ii32 <0xA1, RawFrm, (outs), (ins offset32:$src),
Daniel Dunbar6c2c9a22010-07-19 06:14:44 +00001056 "mov{l}\t{$src, %eax|%eax, $src}", []>,
1057 Requires<[In32BitMode]>;
Chris Lattner2745f6e2010-05-12 22:48:24 +00001058def MOV8ao8 : Ii32 <0xA2, RawFrm, (outs offset8:$dst), (ins),
Daniel Dunbar6c2c9a22010-07-19 06:14:44 +00001059 "mov{b}\t{%al, $dst|$dst, %al}", []>,
1060 Requires<[In32BitMode]>;
Chris Lattner2745f6e2010-05-12 22:48:24 +00001061def MOV16ao16 : Ii32 <0xA3, RawFrm, (outs offset16:$dst), (ins),
Daniel Dunbar6c2c9a22010-07-19 06:14:44 +00001062 "mov{w}\t{%ax, $dst|$dst, %ax}", []>, OpSize,
1063 Requires<[In32BitMode]>;
Sean Callanan108934c2009-12-18 00:01:26 +00001064def MOV32ao32 : Ii32 <0xA3, RawFrm, (outs offset32:$dst), (ins),
Daniel Dunbar6c2c9a22010-07-19 06:14:44 +00001065 "mov{l}\t{%eax, $dst|$dst, %eax}", []>,
1066 Requires<[In32BitMode]>;
Chris Lattnerb5505d02010-05-13 00:02:47 +00001067
Sean Callanan38fee0e2009-09-15 18:47:29 +00001068// Moves to and from segment registers
1069def MOV16rs : I<0x8C, MRMDestReg, (outs GR16:$dst), (ins SEGMENT_REG:$src),
Kevin Enderbyb1065432010-05-26 20:10:45 +00001070 "mov{w}\t{$src, $dst|$dst, $src}", []>, OpSize;
1071def MOV32rs : I<0x8C, MRMDestReg, (outs GR32:$dst), (ins SEGMENT_REG:$src),
1072 "mov{l}\t{$src, $dst|$dst, $src}", []>;
Sean Callanan38fee0e2009-09-15 18:47:29 +00001073def MOV16ms : I<0x8C, MRMDestMem, (outs i16mem:$dst), (ins SEGMENT_REG:$src),
Kevin Enderbyb1065432010-05-26 20:10:45 +00001074 "mov{w}\t{$src, $dst|$dst, $src}", []>, OpSize;
1075def MOV32ms : I<0x8C, MRMDestMem, (outs i32mem:$dst), (ins SEGMENT_REG:$src),
1076 "mov{l}\t{$src, $dst|$dst, $src}", []>;
Sean Callanan38fee0e2009-09-15 18:47:29 +00001077def MOV16sr : I<0x8E, MRMSrcReg, (outs SEGMENT_REG:$dst), (ins GR16:$src),
Kevin Enderbyb1065432010-05-26 20:10:45 +00001078 "mov{w}\t{$src, $dst|$dst, $src}", []>, OpSize;
1079def MOV32sr : I<0x8E, MRMSrcReg, (outs SEGMENT_REG:$dst), (ins GR32:$src),
1080 "mov{l}\t{$src, $dst|$dst, $src}", []>;
Sean Callanan38fee0e2009-09-15 18:47:29 +00001081def MOV16sm : I<0x8E, MRMSrcMem, (outs SEGMENT_REG:$dst), (ins i16mem:$src),
Kevin Enderbyb1065432010-05-26 20:10:45 +00001082 "mov{w}\t{$src, $dst|$dst, $src}", []>, OpSize;
1083def MOV32sm : I<0x8E, MRMSrcMem, (outs SEGMENT_REG:$dst), (ins i32mem:$src),
1084 "mov{l}\t{$src, $dst|$dst, $src}", []>;
Sean Callanan38fee0e2009-09-15 18:47:29 +00001085
Daniel Dunbardcbab9c2010-05-26 22:21:28 +00001086let isCodeGenOnly = 1 in {
Sean Callanan108934c2009-12-18 00:01:26 +00001087def MOV8rr_REV : I<0x8A, MRMSrcReg, (outs GR8:$dst), (ins GR8:$src),
1088 "mov{b}\t{$src, $dst|$dst, $src}", []>;
1089def MOV16rr_REV : I<0x8B, MRMSrcReg, (outs GR16:$dst), (ins GR16:$src),
1090 "mov{w}\t{$src, $dst|$dst, $src}", []>, OpSize;
1091def MOV32rr_REV : I<0x8B, MRMSrcReg, (outs GR32:$dst), (ins GR32:$src),
1092 "mov{l}\t{$src, $dst|$dst, $src}", []>;
Daniel Dunbardcbab9c2010-05-26 22:21:28 +00001093}
Sean Callanan108934c2009-12-18 00:01:26 +00001094
Dan Gohmanbc9d98b2010-02-27 23:47:46 +00001095let canFoldAsLoad = 1, isReMaterializable = 1 in {
Evan Cheng64d80e32007-07-19 01:14:50 +00001096def MOV8rm : I<0x8A, MRMSrcMem, (outs GR8 :$dst), (ins i8mem :$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001097 "mov{b}\t{$src, $dst|$dst, $src}",
Chris Lattnerc2406f22009-04-10 00:16:23 +00001098 [(set GR8:$dst, (loadi8 addr:$src))]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00001099def MOV16rm : I<0x8B, MRMSrcMem, (outs GR16:$dst), (ins i16mem:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001100 "mov{w}\t{$src, $dst|$dst, $src}",
Chris Lattnerc2406f22009-04-10 00:16:23 +00001101 [(set GR16:$dst, (loadi16 addr:$src))]>, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00001102def MOV32rm : I<0x8B, MRMSrcMem, (outs GR32:$dst), (ins i32mem:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001103 "mov{l}\t{$src, $dst|$dst, $src}",
Chris Lattnerc2406f22009-04-10 00:16:23 +00001104 [(set GR32:$dst, (loadi32 addr:$src))]>;
Evan Cheng2f394262007-08-30 05:49:43 +00001105}
Chris Lattner1cca5e32003-08-03 21:54:21 +00001106
Evan Cheng64d80e32007-07-19 01:14:50 +00001107def MOV8mr : I<0x88, MRMDestMem, (outs), (ins i8mem :$dst, GR8 :$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001108 "mov{b}\t{$src, $dst|$dst, $src}",
Evan Cheng069287d2006-05-16 07:21:53 +00001109 [(store GR8:$src, addr:$dst)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00001110def MOV16mr : I<0x89, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001111 "mov{w}\t{$src, $dst|$dst, $src}",
Evan Cheng069287d2006-05-16 07:21:53 +00001112 [(store GR16:$src, addr:$dst)]>, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00001113def MOV32mr : I<0x89, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001114 "mov{l}\t{$src, $dst|$dst, $src}",
Evan Cheng069287d2006-05-16 07:21:53 +00001115 [(store GR32:$src, addr:$dst)]>;
Dan Gohman21e3dfb2009-04-13 16:09:41 +00001116
Evan Chengf48ef032010-03-14 03:48:46 +00001117/// Versions of MOV32rr, MOV32rm, and MOV32mr for i32mem_TC and GR32_TC.
Daniel Dunbarcf246b72010-07-19 06:14:49 +00001118let isCodeGenOnly = 1 in {
Evan Chengf48ef032010-03-14 03:48:46 +00001119let neverHasSideEffects = 1 in
1120def MOV32rr_TC : I<0x89, MRMDestReg, (outs GR32_TC:$dst), (ins GR32_TC:$src),
1121 "mov{l}\t{$src, $dst|$dst, $src}", []>;
1122
1123let mayLoad = 1,
1124 canFoldAsLoad = 1, isReMaterializable = 1 in
1125def MOV32rm_TC : I<0x8B, MRMSrcMem, (outs GR32_TC:$dst), (ins i32mem_TC:$src),
1126 "mov{l}\t{$src, $dst|$dst, $src}",
1127 []>;
1128
1129let mayStore = 1 in
1130def MOV32mr_TC : I<0x89, MRMDestMem, (outs), (ins i32mem_TC:$dst, GR32_TC:$src),
1131 "mov{l}\t{$src, $dst|$dst, $src}",
1132 []>;
Daniel Dunbarcf246b72010-07-19 06:14:49 +00001133}
Evan Chengf48ef032010-03-14 03:48:46 +00001134
Dan Gohman4af325d2009-04-27 16:41:36 +00001135// Versions of MOV8rr, MOV8mr, and MOV8rm that use i8mem_NOREX and GR8_NOREX so
1136// that they can be used for copying and storing h registers, which can't be
1137// encoded when a REX prefix is present.
Daniel Dunbarcf246b72010-07-19 06:14:49 +00001138let isCodeGenOnly = 1 in {
Dan Gohman6d9305c2009-04-15 00:04:23 +00001139let neverHasSideEffects = 1 in
Dan Gohmandf7dfc72009-04-15 19:48:57 +00001140def MOV8rr_NOREX : I<0x88, MRMDestReg,
1141 (outs GR8_NOREX:$dst), (ins GR8_NOREX:$src),
Dan Gohman6d9305c2009-04-15 00:04:23 +00001142 "mov{b}\t{$src, $dst|$dst, $src} # NOREX", []>;
Evan Cheng8c147402009-04-30 00:58:57 +00001143let mayStore = 1 in
Dan Gohman6d9305c2009-04-15 00:04:23 +00001144def MOV8mr_NOREX : I<0x88, MRMDestMem,
1145 (outs), (ins i8mem_NOREX:$dst, GR8_NOREX:$src),
1146 "mov{b}\t{$src, $dst|$dst, $src} # NOREX", []>;
Evan Cheng8c147402009-04-30 00:58:57 +00001147let mayLoad = 1,
Dan Gohmanbc9d98b2010-02-27 23:47:46 +00001148 canFoldAsLoad = 1, isReMaterializable = 1 in
Dan Gohman4af325d2009-04-27 16:41:36 +00001149def MOV8rm_NOREX : I<0x8A, MRMSrcMem,
1150 (outs GR8_NOREX:$dst), (ins i8mem_NOREX:$src),
1151 "mov{b}\t{$src, $dst|$dst, $src} # NOREX", []>;
Daniel Dunbarcf246b72010-07-19 06:14:49 +00001152}
Dan Gohman21e3dfb2009-04-13 16:09:41 +00001153
Sean Callanan108934c2009-12-18 00:01:26 +00001154// Moves to and from debug registers
1155def MOV32rd : I<0x21, MRMDestReg, (outs GR32:$dst), (ins DEBUG_REG:$src),
1156 "mov{l}\t{$src, $dst|$dst, $src}", []>, TB;
1157def MOV32dr : I<0x23, MRMSrcReg, (outs DEBUG_REG:$dst), (ins GR32:$src),
1158 "mov{l}\t{$src, $dst|$dst, $src}", []>, TB;
1159
1160// Moves to and from control registers
Sean Callanan1a8b7892010-05-06 20:59:00 +00001161def MOV32rc : I<0x20, MRMDestReg, (outs GR32:$dst), (ins CONTROL_REG:$src),
1162 "mov{l}\t{$src, $dst|$dst, $src}", []>, TB;
1163def MOV32cr : I<0x22, MRMSrcReg, (outs CONTROL_REG:$dst), (ins GR32:$src),
1164 "mov{l}\t{$src, $dst|$dst, $src}", []>, TB;
Sean Callanan108934c2009-12-18 00:01:26 +00001165
Chris Lattner1cca5e32003-08-03 21:54:21 +00001166//===----------------------------------------------------------------------===//
1167// Fixed-Register Multiplication and Division Instructions...
1168//
Chris Lattner1cca5e32003-08-03 21:54:21 +00001169
Chris Lattnerc8f45872003-08-04 04:59:56 +00001170// Extra precision multiplication
Jakob Stoklund Olesen3cfe0102010-03-04 20:42:07 +00001171
1172// AL is really implied by AX, by the registers in Defs must match the
1173// SDNode results (i8, i32).
1174let Defs = [AL,EFLAGS,AX], Uses = [AL] in
Dan Gohmanb1576f52007-07-31 20:11:57 +00001175def MUL8r : I<0xF6, MRM4r, (outs), (ins GR8:$src), "mul{b}\t$src",
Evan Chengcf74a7c2006-01-15 10:05:20 +00001176 // FIXME: Used for 8-bit mul, ignore result upper 8 bits.
1177 // This probably ought to be moved to a def : Pat<> if the
1178 // syntax can be accepted.
Bill Wendlingd350e022008-12-12 21:15:41 +00001179 [(set AL, (mul AL, GR8:$src)),
1180 (implicit EFLAGS)]>; // AL,AH = AL*GR8
1181
Chris Lattnera731c9f2008-01-11 07:18:17 +00001182let Defs = [AX,DX,EFLAGS], Uses = [AX], neverHasSideEffects = 1 in
Bill Wendlingd350e022008-12-12 21:15:41 +00001183def MUL16r : I<0xF7, MRM4r, (outs), (ins GR16:$src),
1184 "mul{w}\t$src",
1185 []>, OpSize; // AX,DX = AX*GR16
1186
Chris Lattnera731c9f2008-01-11 07:18:17 +00001187let Defs = [EAX,EDX,EFLAGS], Uses = [EAX], neverHasSideEffects = 1 in
Bill Wendlingd350e022008-12-12 21:15:41 +00001188def MUL32r : I<0xF7, MRM4r, (outs), (ins GR32:$src),
1189 "mul{l}\t$src",
1190 []>; // EAX,EDX = EAX*GR32
1191
Jakob Stoklund Olesen3cfe0102010-03-04 20:42:07 +00001192let Defs = [AL,EFLAGS,AX], Uses = [AL] in
Evan Cheng64d80e32007-07-19 01:14:50 +00001193def MUL8m : I<0xF6, MRM4m, (outs), (ins i8mem :$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001194 "mul{b}\t$src",
Evan Chengcf74a7c2006-01-15 10:05:20 +00001195 // FIXME: Used for 8-bit mul, ignore result upper 8 bits.
1196 // This probably ought to be moved to a def : Pat<> if the
1197 // syntax can be accepted.
Bill Wendlingd350e022008-12-12 21:15:41 +00001198 [(set AL, (mul AL, (loadi8 addr:$src))),
1199 (implicit EFLAGS)]>; // AL,AH = AL*[mem8]
1200
Chris Lattnerba7e7562008-01-10 07:59:24 +00001201let mayLoad = 1, neverHasSideEffects = 1 in {
Evan Cheng24f2ea32007-09-14 21:48:26 +00001202let Defs = [AX,DX,EFLAGS], Uses = [AX] in
Evan Cheng64d80e32007-07-19 01:14:50 +00001203def MUL16m : I<0xF7, MRM4m, (outs), (ins i16mem:$src),
Bill Wendlingd350e022008-12-12 21:15:41 +00001204 "mul{w}\t$src",
1205 []>, OpSize; // AX,DX = AX*[mem16]
1206
Evan Cheng24f2ea32007-09-14 21:48:26 +00001207let Defs = [EAX,EDX,EFLAGS], Uses = [EAX] in
Evan Cheng64d80e32007-07-19 01:14:50 +00001208def MUL32m : I<0xF7, MRM4m, (outs), (ins i32mem:$src),
Bill Wendlingd350e022008-12-12 21:15:41 +00001209 "mul{l}\t$src",
1210 []>; // EAX,EDX = EAX*[mem32]
Chris Lattnerba7e7562008-01-10 07:59:24 +00001211}
Chris Lattner1cca5e32003-08-03 21:54:21 +00001212
Chris Lattnerba7e7562008-01-10 07:59:24 +00001213let neverHasSideEffects = 1 in {
Jakob Stoklund Olesen3cfe0102010-03-04 20:42:07 +00001214let Defs = [AL,EFLAGS,AX], Uses = [AL] in
Evan Cheng071a2792007-09-11 19:55:27 +00001215def IMUL8r : I<0xF6, MRM5r, (outs), (ins GR8:$src), "imul{b}\t$src", []>;
1216 // AL,AH = AL*GR8
Evan Cheng24f2ea32007-09-14 21:48:26 +00001217let Defs = [AX,DX,EFLAGS], Uses = [AX] in
Dan Gohmanb1576f52007-07-31 20:11:57 +00001218def IMUL16r : I<0xF7, MRM5r, (outs), (ins GR16:$src), "imul{w}\t$src", []>,
Evan Cheng071a2792007-09-11 19:55:27 +00001219 OpSize; // AX,DX = AX*GR16
Evan Cheng24f2ea32007-09-14 21:48:26 +00001220let Defs = [EAX,EDX,EFLAGS], Uses = [EAX] in
Evan Cheng071a2792007-09-11 19:55:27 +00001221def IMUL32r : I<0xF7, MRM5r, (outs), (ins GR32:$src), "imul{l}\t$src", []>;
1222 // EAX,EDX = EAX*GR32
Chris Lattnerba7e7562008-01-10 07:59:24 +00001223let mayLoad = 1 in {
Jakob Stoklund Olesen3cfe0102010-03-04 20:42:07 +00001224let Defs = [AL,EFLAGS,AX], Uses = [AL] in
Evan Cheng64d80e32007-07-19 01:14:50 +00001225def IMUL8m : I<0xF6, MRM5m, (outs), (ins i8mem :$src),
Evan Cheng071a2792007-09-11 19:55:27 +00001226 "imul{b}\t$src", []>; // AL,AH = AL*[mem8]
Evan Cheng24f2ea32007-09-14 21:48:26 +00001227let Defs = [AX,DX,EFLAGS], Uses = [AX] in
Evan Cheng64d80e32007-07-19 01:14:50 +00001228def IMUL16m : I<0xF7, MRM5m, (outs), (ins i16mem:$src),
Evan Cheng071a2792007-09-11 19:55:27 +00001229 "imul{w}\t$src", []>, OpSize; // AX,DX = AX*[mem16]
Eli Friedmanba7b1c42009-12-26 20:08:30 +00001230let Defs = [EAX,EDX,EFLAGS], Uses = [EAX] in
Evan Cheng64d80e32007-07-19 01:14:50 +00001231def IMUL32m : I<0xF7, MRM5m, (outs), (ins i32mem:$src),
Evan Cheng071a2792007-09-11 19:55:27 +00001232 "imul{l}\t$src", []>; // EAX,EDX = EAX*[mem32]
Chris Lattnerba7e7562008-01-10 07:59:24 +00001233}
Dan Gohmanc99da132008-11-18 21:29:14 +00001234} // neverHasSideEffects
Chris Lattner1e6a7152005-04-06 04:19:22 +00001235
Chris Lattnerc8f45872003-08-04 04:59:56 +00001236// unsigned division/remainder
Jakob Stoklund Olesen3cfe0102010-03-04 20:42:07 +00001237let Defs = [AL,EFLAGS,AX], Uses = [AX] in
Sean Callanan108934c2009-12-18 00:01:26 +00001238def DIV8r : I<0xF6, MRM6r, (outs), (ins GR8:$src), // AX/r8 = AL,AH
Evan Cheng071a2792007-09-11 19:55:27 +00001239 "div{b}\t$src", []>;
Evan Cheng24f2ea32007-09-14 21:48:26 +00001240let Defs = [AX,DX,EFLAGS], Uses = [AX,DX] in
Sean Callanan108934c2009-12-18 00:01:26 +00001241def DIV16r : I<0xF7, MRM6r, (outs), (ins GR16:$src), // DX:AX/r16 = AX,DX
Evan Cheng071a2792007-09-11 19:55:27 +00001242 "div{w}\t$src", []>, OpSize;
Evan Cheng24f2ea32007-09-14 21:48:26 +00001243let Defs = [EAX,EDX,EFLAGS], Uses = [EAX,EDX] in
Sean Callanan108934c2009-12-18 00:01:26 +00001244def DIV32r : I<0xF7, MRM6r, (outs), (ins GR32:$src), // EDX:EAX/r32 = EAX,EDX
Evan Cheng071a2792007-09-11 19:55:27 +00001245 "div{l}\t$src", []>;
Chris Lattnerba7e7562008-01-10 07:59:24 +00001246let mayLoad = 1 in {
Jakob Stoklund Olesen3cfe0102010-03-04 20:42:07 +00001247let Defs = [AL,EFLAGS,AX], Uses = [AX] in
Sean Callanan108934c2009-12-18 00:01:26 +00001248def DIV8m : I<0xF6, MRM6m, (outs), (ins i8mem:$src), // AX/[mem8] = AL,AH
Evan Cheng071a2792007-09-11 19:55:27 +00001249 "div{b}\t$src", []>;
Evan Cheng24f2ea32007-09-14 21:48:26 +00001250let Defs = [AX,DX,EFLAGS], Uses = [AX,DX] in
Sean Callanan108934c2009-12-18 00:01:26 +00001251def DIV16m : I<0xF7, MRM6m, (outs), (ins i16mem:$src), // DX:AX/[mem16] = AX,DX
Evan Cheng071a2792007-09-11 19:55:27 +00001252 "div{w}\t$src", []>, OpSize;
Evan Cheng24f2ea32007-09-14 21:48:26 +00001253let Defs = [EAX,EDX,EFLAGS], Uses = [EAX,EDX] in
Sean Callanan108934c2009-12-18 00:01:26 +00001254 // EDX:EAX/[mem32] = EAX,EDX
1255def DIV32m : I<0xF7, MRM6m, (outs), (ins i32mem:$src),
Evan Cheng071a2792007-09-11 19:55:27 +00001256 "div{l}\t$src", []>;
Chris Lattnerba7e7562008-01-10 07:59:24 +00001257}
Chris Lattner1cca5e32003-08-03 21:54:21 +00001258
Chris Lattnerfc752712004-08-01 09:52:59 +00001259// Signed division/remainder.
Jakob Stoklund Olesen3cfe0102010-03-04 20:42:07 +00001260let Defs = [AL,EFLAGS,AX], Uses = [AX] in
Sean Callanan108934c2009-12-18 00:01:26 +00001261def IDIV8r : I<0xF6, MRM7r, (outs), (ins GR8:$src), // AX/r8 = AL,AH
Evan Cheng071a2792007-09-11 19:55:27 +00001262 "idiv{b}\t$src", []>;
Evan Cheng24f2ea32007-09-14 21:48:26 +00001263let Defs = [AX,DX,EFLAGS], Uses = [AX,DX] in
Sean Callanan108934c2009-12-18 00:01:26 +00001264def IDIV16r: I<0xF7, MRM7r, (outs), (ins GR16:$src), // DX:AX/r16 = AX,DX
Evan Cheng071a2792007-09-11 19:55:27 +00001265 "idiv{w}\t$src", []>, OpSize;
Evan Cheng24f2ea32007-09-14 21:48:26 +00001266let Defs = [EAX,EDX,EFLAGS], Uses = [EAX,EDX] in
Sean Callanan108934c2009-12-18 00:01:26 +00001267def IDIV32r: I<0xF7, MRM7r, (outs), (ins GR32:$src), // EDX:EAX/r32 = EAX,EDX
Evan Cheng071a2792007-09-11 19:55:27 +00001268 "idiv{l}\t$src", []>;
Chris Lattnerba7e7562008-01-10 07:59:24 +00001269let mayLoad = 1, mayLoad = 1 in {
Jakob Stoklund Olesen3cfe0102010-03-04 20:42:07 +00001270let Defs = [AL,EFLAGS,AX], Uses = [AX] in
Sean Callanan108934c2009-12-18 00:01:26 +00001271def IDIV8m : I<0xF6, MRM7m, (outs), (ins i8mem:$src), // AX/[mem8] = AL,AH
Evan Cheng071a2792007-09-11 19:55:27 +00001272 "idiv{b}\t$src", []>;
Evan Cheng24f2ea32007-09-14 21:48:26 +00001273let Defs = [AX,DX,EFLAGS], Uses = [AX,DX] in
Sean Callanan108934c2009-12-18 00:01:26 +00001274def IDIV16m: I<0xF7, MRM7m, (outs), (ins i16mem:$src), // DX:AX/[mem16] = AX,DX
Evan Cheng071a2792007-09-11 19:55:27 +00001275 "idiv{w}\t$src", []>, OpSize;
Evan Cheng24f2ea32007-09-14 21:48:26 +00001276let Defs = [EAX,EDX,EFLAGS], Uses = [EAX,EDX] in
Sean Callanan108934c2009-12-18 00:01:26 +00001277def IDIV32m: I<0xF7, MRM7m, (outs), (ins i32mem:$src),
1278 // EDX:EAX/[mem32] = EAX,EDX
Evan Cheng071a2792007-09-11 19:55:27 +00001279 "idiv{l}\t$src", []>;
Chris Lattnerba7e7562008-01-10 07:59:24 +00001280}
Chris Lattner1cca5e32003-08-03 21:54:21 +00001281
Chris Lattner1cca5e32003-08-03 21:54:21 +00001282//===----------------------------------------------------------------------===//
Chris Lattnerba7e7562008-01-10 07:59:24 +00001283// Two address Instructions.
Chris Lattner1cca5e32003-08-03 21:54:21 +00001284//
Eric Christophera938cfb2010-06-19 00:37:40 +00001285let Constraints = "$src1 = $dst" in {
Chris Lattner1cca5e32003-08-03 21:54:21 +00001286
Alkis Evlogimenosa3f66842004-03-12 17:59:56 +00001287// Conditional moves
Evan Cheng0488db92007-09-25 01:57:46 +00001288let Uses = [EFLAGS] in {
Dan Gohmancbbea0f2009-08-27 00:14:12 +00001289
Chris Lattner314a1132010-03-14 18:31:44 +00001290let Predicates = [HasCMov] in {
Dan Gohmana4c5c332009-08-27 18:16:24 +00001291let isCommutable = 1 in {
Evan Cheng069287d2006-05-16 07:21:53 +00001292def CMOVB16rr : I<0x42, MRMSrcReg, // if <u, GR16 = GR16
Evan Cheng64d80e32007-07-19 01:14:50 +00001293 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Sean Callanan108934c2009-12-18 00:01:26 +00001294 "cmovb{w}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001295 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Chenge5f62042007-09-29 00:00:36 +00001296 X86_COND_B, EFLAGS))]>,
Evan Cheng71fb9ad2006-01-26 00:29:36 +00001297 TB, OpSize;
Evan Cheng069287d2006-05-16 07:21:53 +00001298def CMOVB32rr : I<0x42, MRMSrcReg, // if <u, GR32 = GR32
Evan Cheng64d80e32007-07-19 01:14:50 +00001299 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Sean Callanan108934c2009-12-18 00:01:26 +00001300 "cmovb{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001301 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Chenge5f62042007-09-29 00:00:36 +00001302 X86_COND_B, EFLAGS))]>,
Evan Cheng71fb9ad2006-01-26 00:29:36 +00001303 TB;
Evan Cheng069287d2006-05-16 07:21:53 +00001304def CMOVAE16rr: I<0x43, MRMSrcReg, // if >=u, GR16 = GR16
Evan Cheng64d80e32007-07-19 01:14:50 +00001305 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Sean Callanan108934c2009-12-18 00:01:26 +00001306 "cmovae{w}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001307 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Chenge5f62042007-09-29 00:00:36 +00001308 X86_COND_AE, EFLAGS))]>,
Evan Cheng71fb9ad2006-01-26 00:29:36 +00001309 TB, OpSize;
Evan Cheng069287d2006-05-16 07:21:53 +00001310def CMOVAE32rr: I<0x43, MRMSrcReg, // if >=u, GR32 = GR32
Evan Cheng64d80e32007-07-19 01:14:50 +00001311 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Sean Callanan108934c2009-12-18 00:01:26 +00001312 "cmovae{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001313 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Chenge5f62042007-09-29 00:00:36 +00001314 X86_COND_AE, EFLAGS))]>,
Evan Cheng71fb9ad2006-01-26 00:29:36 +00001315 TB;
Evan Cheng069287d2006-05-16 07:21:53 +00001316def CMOVE16rr : I<0x44, MRMSrcReg, // if ==, GR16 = GR16
Evan Cheng64d80e32007-07-19 01:14:50 +00001317 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Sean Callanan108934c2009-12-18 00:01:26 +00001318 "cmove{w}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001319 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Chenge5f62042007-09-29 00:00:36 +00001320 X86_COND_E, EFLAGS))]>,
Evan Cheng71fb9ad2006-01-26 00:29:36 +00001321 TB, OpSize;
Evan Cheng069287d2006-05-16 07:21:53 +00001322def CMOVE32rr : I<0x44, MRMSrcReg, // if ==, GR32 = GR32
Evan Cheng64d80e32007-07-19 01:14:50 +00001323 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Sean Callanan108934c2009-12-18 00:01:26 +00001324 "cmove{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001325 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Chenge5f62042007-09-29 00:00:36 +00001326 X86_COND_E, EFLAGS))]>,
Evan Cheng71fb9ad2006-01-26 00:29:36 +00001327 TB;
Evan Cheng069287d2006-05-16 07:21:53 +00001328def CMOVNE16rr: I<0x45, MRMSrcReg, // if !=, GR16 = GR16
Evan Cheng64d80e32007-07-19 01:14:50 +00001329 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Sean Callanan108934c2009-12-18 00:01:26 +00001330 "cmovne{w}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001331 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Chenge5f62042007-09-29 00:00:36 +00001332 X86_COND_NE, EFLAGS))]>,
Evan Cheng71fb9ad2006-01-26 00:29:36 +00001333 TB, OpSize;
Evan Cheng069287d2006-05-16 07:21:53 +00001334def CMOVNE32rr: I<0x45, MRMSrcReg, // if !=, GR32 = GR32
Evan Cheng64d80e32007-07-19 01:14:50 +00001335 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Sean Callanan108934c2009-12-18 00:01:26 +00001336 "cmovne{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001337 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Chenge5f62042007-09-29 00:00:36 +00001338 X86_COND_NE, EFLAGS))]>,
Evan Cheng71fb9ad2006-01-26 00:29:36 +00001339 TB;
Evan Cheng069287d2006-05-16 07:21:53 +00001340def CMOVBE16rr: I<0x46, MRMSrcReg, // if <=u, GR16 = GR16
Evan Cheng64d80e32007-07-19 01:14:50 +00001341 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Sean Callanan108934c2009-12-18 00:01:26 +00001342 "cmovbe{w}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001343 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Chenge5f62042007-09-29 00:00:36 +00001344 X86_COND_BE, EFLAGS))]>,
Evan Cheng71fb9ad2006-01-26 00:29:36 +00001345 TB, OpSize;
Evan Cheng069287d2006-05-16 07:21:53 +00001346def CMOVBE32rr: I<0x46, MRMSrcReg, // if <=u, GR32 = GR32
Evan Cheng64d80e32007-07-19 01:14:50 +00001347 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Sean Callanan108934c2009-12-18 00:01:26 +00001348 "cmovbe{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001349 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Chenge5f62042007-09-29 00:00:36 +00001350 X86_COND_BE, EFLAGS))]>,
Evan Cheng71fb9ad2006-01-26 00:29:36 +00001351 TB;
Evan Cheng069287d2006-05-16 07:21:53 +00001352def CMOVA16rr : I<0x47, MRMSrcReg, // if >u, GR16 = GR16
Evan Cheng64d80e32007-07-19 01:14:50 +00001353 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Sean Callanan108934c2009-12-18 00:01:26 +00001354 "cmova{w}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001355 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Chenge5f62042007-09-29 00:00:36 +00001356 X86_COND_A, EFLAGS))]>,
Evan Cheng71fb9ad2006-01-26 00:29:36 +00001357 TB, OpSize;
Evan Cheng069287d2006-05-16 07:21:53 +00001358def CMOVA32rr : I<0x47, MRMSrcReg, // if >u, GR32 = GR32
Evan Cheng64d80e32007-07-19 01:14:50 +00001359 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Sean Callanan108934c2009-12-18 00:01:26 +00001360 "cmova{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001361 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Chenge5f62042007-09-29 00:00:36 +00001362 X86_COND_A, EFLAGS))]>,
Evan Cheng71fb9ad2006-01-26 00:29:36 +00001363 TB;
Evan Cheng069287d2006-05-16 07:21:53 +00001364def CMOVL16rr : I<0x4C, MRMSrcReg, // if <s, GR16 = GR16
Evan Cheng64d80e32007-07-19 01:14:50 +00001365 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Sean Callanan108934c2009-12-18 00:01:26 +00001366 "cmovl{w}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001367 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Chenge5f62042007-09-29 00:00:36 +00001368 X86_COND_L, EFLAGS))]>,
Evan Cheng71fb9ad2006-01-26 00:29:36 +00001369 TB, OpSize;
Evan Cheng069287d2006-05-16 07:21:53 +00001370def CMOVL32rr : I<0x4C, MRMSrcReg, // if <s, GR32 = GR32
Evan Cheng64d80e32007-07-19 01:14:50 +00001371 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Sean Callanan108934c2009-12-18 00:01:26 +00001372 "cmovl{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001373 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Chenge5f62042007-09-29 00:00:36 +00001374 X86_COND_L, EFLAGS))]>,
Evan Cheng71fb9ad2006-01-26 00:29:36 +00001375 TB;
Evan Cheng069287d2006-05-16 07:21:53 +00001376def CMOVGE16rr: I<0x4D, MRMSrcReg, // if >=s, GR16 = GR16
Evan Cheng64d80e32007-07-19 01:14:50 +00001377 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Sean Callanan108934c2009-12-18 00:01:26 +00001378 "cmovge{w}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001379 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Chenge5f62042007-09-29 00:00:36 +00001380 X86_COND_GE, EFLAGS))]>,
Evan Cheng71fb9ad2006-01-26 00:29:36 +00001381 TB, OpSize;
Evan Cheng069287d2006-05-16 07:21:53 +00001382def CMOVGE32rr: I<0x4D, MRMSrcReg, // if >=s, GR32 = GR32
Evan Cheng64d80e32007-07-19 01:14:50 +00001383 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Sean Callanan108934c2009-12-18 00:01:26 +00001384 "cmovge{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001385 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Chenge5f62042007-09-29 00:00:36 +00001386 X86_COND_GE, EFLAGS))]>,
Evan Cheng71fb9ad2006-01-26 00:29:36 +00001387 TB;
Evan Cheng069287d2006-05-16 07:21:53 +00001388def CMOVLE16rr: I<0x4E, MRMSrcReg, // if <=s, GR16 = GR16
Evan Cheng64d80e32007-07-19 01:14:50 +00001389 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Sean Callanan108934c2009-12-18 00:01:26 +00001390 "cmovle{w}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001391 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Chenge5f62042007-09-29 00:00:36 +00001392 X86_COND_LE, EFLAGS))]>,
Evan Cheng71fb9ad2006-01-26 00:29:36 +00001393 TB, OpSize;
Evan Cheng069287d2006-05-16 07:21:53 +00001394def CMOVLE32rr: I<0x4E, MRMSrcReg, // if <=s, GR32 = GR32
Evan Cheng64d80e32007-07-19 01:14:50 +00001395 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Sean Callanan108934c2009-12-18 00:01:26 +00001396 "cmovle{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001397 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Chenge5f62042007-09-29 00:00:36 +00001398 X86_COND_LE, EFLAGS))]>,
Evan Cheng71fb9ad2006-01-26 00:29:36 +00001399 TB;
Evan Cheng069287d2006-05-16 07:21:53 +00001400def CMOVG16rr : I<0x4F, MRMSrcReg, // if >s, GR16 = GR16
Evan Cheng64d80e32007-07-19 01:14:50 +00001401 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Sean Callanan108934c2009-12-18 00:01:26 +00001402 "cmovg{w}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001403 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Chenge5f62042007-09-29 00:00:36 +00001404 X86_COND_G, EFLAGS))]>,
Evan Cheng71fb9ad2006-01-26 00:29:36 +00001405 TB, OpSize;
Evan Cheng069287d2006-05-16 07:21:53 +00001406def CMOVG32rr : I<0x4F, MRMSrcReg, // if >s, GR32 = GR32
Evan Cheng64d80e32007-07-19 01:14:50 +00001407 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Sean Callanan108934c2009-12-18 00:01:26 +00001408 "cmovg{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001409 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Chenge5f62042007-09-29 00:00:36 +00001410 X86_COND_G, EFLAGS))]>,
Evan Cheng71fb9ad2006-01-26 00:29:36 +00001411 TB;
Evan Cheng069287d2006-05-16 07:21:53 +00001412def CMOVS16rr : I<0x48, MRMSrcReg, // if signed, GR16 = GR16
Evan Cheng64d80e32007-07-19 01:14:50 +00001413 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Sean Callanan108934c2009-12-18 00:01:26 +00001414 "cmovs{w}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001415 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Chenge5f62042007-09-29 00:00:36 +00001416 X86_COND_S, EFLAGS))]>,
Evan Cheng71fb9ad2006-01-26 00:29:36 +00001417 TB, OpSize;
Evan Cheng069287d2006-05-16 07:21:53 +00001418def CMOVS32rr : I<0x48, MRMSrcReg, // if signed, GR32 = GR32
Evan Cheng64d80e32007-07-19 01:14:50 +00001419 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Sean Callanan108934c2009-12-18 00:01:26 +00001420 "cmovs{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001421 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Chenge5f62042007-09-29 00:00:36 +00001422 X86_COND_S, EFLAGS))]>,
Evan Cheng71fb9ad2006-01-26 00:29:36 +00001423 TB;
Evan Cheng069287d2006-05-16 07:21:53 +00001424def CMOVNS16rr: I<0x49, MRMSrcReg, // if !signed, GR16 = GR16
Evan Cheng64d80e32007-07-19 01:14:50 +00001425 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Sean Callanan108934c2009-12-18 00:01:26 +00001426 "cmovns{w}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001427 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Chenge5f62042007-09-29 00:00:36 +00001428 X86_COND_NS, EFLAGS))]>,
Evan Cheng71fb9ad2006-01-26 00:29:36 +00001429 TB, OpSize;
Evan Cheng069287d2006-05-16 07:21:53 +00001430def CMOVNS32rr: I<0x49, MRMSrcReg, // if !signed, GR32 = GR32
Evan Cheng64d80e32007-07-19 01:14:50 +00001431 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Sean Callanan108934c2009-12-18 00:01:26 +00001432 "cmovns{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001433 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Chenge5f62042007-09-29 00:00:36 +00001434 X86_COND_NS, EFLAGS))]>,
Evan Cheng71fb9ad2006-01-26 00:29:36 +00001435 TB;
Evan Cheng069287d2006-05-16 07:21:53 +00001436def CMOVP16rr : I<0x4A, MRMSrcReg, // if parity, GR16 = GR16
Evan Cheng64d80e32007-07-19 01:14:50 +00001437 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Sean Callanan108934c2009-12-18 00:01:26 +00001438 "cmovp{w}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001439 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Chenge5f62042007-09-29 00:00:36 +00001440 X86_COND_P, EFLAGS))]>,
Evan Cheng71fb9ad2006-01-26 00:29:36 +00001441 TB, OpSize;
Evan Cheng069287d2006-05-16 07:21:53 +00001442def CMOVP32rr : I<0x4A, MRMSrcReg, // if parity, GR32 = GR32
Evan Cheng64d80e32007-07-19 01:14:50 +00001443 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Sean Callanan108934c2009-12-18 00:01:26 +00001444 "cmovp{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001445 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Chenge5f62042007-09-29 00:00:36 +00001446 X86_COND_P, EFLAGS))]>,
Evan Cheng71fb9ad2006-01-26 00:29:36 +00001447 TB;
Evan Cheng069287d2006-05-16 07:21:53 +00001448def CMOVNP16rr : I<0x4B, MRMSrcReg, // if !parity, GR16 = GR16
Evan Cheng64d80e32007-07-19 01:14:50 +00001449 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Sean Callanan108934c2009-12-18 00:01:26 +00001450 "cmovnp{w}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001451 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Chenge5f62042007-09-29 00:00:36 +00001452 X86_COND_NP, EFLAGS))]>,
Evan Cheng71fb9ad2006-01-26 00:29:36 +00001453 TB, OpSize;
Evan Cheng069287d2006-05-16 07:21:53 +00001454def CMOVNP32rr : I<0x4B, MRMSrcReg, // if !parity, GR32 = GR32
Evan Cheng64d80e32007-07-19 01:14:50 +00001455 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Sean Callanan108934c2009-12-18 00:01:26 +00001456 "cmovnp{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001457 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Chenge5f62042007-09-29 00:00:36 +00001458 X86_COND_NP, EFLAGS))]>,
Evan Cheng71fb9ad2006-01-26 00:29:36 +00001459 TB;
Dan Gohman305fceb2009-01-07 00:35:10 +00001460def CMOVO16rr : I<0x40, MRMSrcReg, // if overflow, GR16 = GR16
1461 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Sean Callanan108934c2009-12-18 00:01:26 +00001462 "cmovo{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohman305fceb2009-01-07 00:35:10 +00001463 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
1464 X86_COND_O, EFLAGS))]>,
1465 TB, OpSize;
1466def CMOVO32rr : I<0x40, MRMSrcReg, // if overflow, GR32 = GR32
1467 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Sean Callanan108934c2009-12-18 00:01:26 +00001468 "cmovo{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohman305fceb2009-01-07 00:35:10 +00001469 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
1470 X86_COND_O, EFLAGS))]>,
Evan Cheng0488db92007-09-25 01:57:46 +00001471 TB;
Dan Gohman305fceb2009-01-07 00:35:10 +00001472def CMOVNO16rr : I<0x41, MRMSrcReg, // if !overflow, GR16 = GR16
1473 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Sean Callanan108934c2009-12-18 00:01:26 +00001474 "cmovno{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohman305fceb2009-01-07 00:35:10 +00001475 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
1476 X86_COND_NO, EFLAGS))]>,
1477 TB, OpSize;
1478def CMOVNO32rr : I<0x41, MRMSrcReg, // if !overflow, GR32 = GR32
1479 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Sean Callanan108934c2009-12-18 00:01:26 +00001480 "cmovno{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohman305fceb2009-01-07 00:35:10 +00001481 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
1482 X86_COND_NO, EFLAGS))]>,
1483 TB;
1484} // isCommutable = 1
Evan Cheng7ad42d92007-10-05 23:13:21 +00001485
1486def CMOVB16rm : I<0x42, MRMSrcMem, // if <u, GR16 = [mem16]
1487 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
Sean Callanan108934c2009-12-18 00:01:26 +00001488 "cmovb{w}\t{$src2, $dst|$dst, $src2}",
Evan Cheng7ad42d92007-10-05 23:13:21 +00001489 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1490 X86_COND_B, EFLAGS))]>,
1491 TB, OpSize;
1492def CMOVB32rm : I<0x42, MRMSrcMem, // if <u, GR32 = [mem32]
1493 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Sean Callanan108934c2009-12-18 00:01:26 +00001494 "cmovb{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng7ad42d92007-10-05 23:13:21 +00001495 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1496 X86_COND_B, EFLAGS))]>,
1497 TB;
1498def CMOVAE16rm: I<0x43, MRMSrcMem, // if >=u, GR16 = [mem16]
1499 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
Sean Callanan108934c2009-12-18 00:01:26 +00001500 "cmovae{w}\t{$src2, $dst|$dst, $src2}",
Evan Cheng7ad42d92007-10-05 23:13:21 +00001501 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1502 X86_COND_AE, EFLAGS))]>,
1503 TB, OpSize;
1504def CMOVAE32rm: I<0x43, MRMSrcMem, // if >=u, GR32 = [mem32]
1505 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Sean Callanan108934c2009-12-18 00:01:26 +00001506 "cmovae{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng7ad42d92007-10-05 23:13:21 +00001507 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1508 X86_COND_AE, EFLAGS))]>,
1509 TB;
1510def CMOVE16rm : I<0x44, MRMSrcMem, // if ==, GR16 = [mem16]
1511 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
Sean Callanan108934c2009-12-18 00:01:26 +00001512 "cmove{w}\t{$src2, $dst|$dst, $src2}",
Evan Cheng7ad42d92007-10-05 23:13:21 +00001513 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1514 X86_COND_E, EFLAGS))]>,
1515 TB, OpSize;
1516def CMOVE32rm : I<0x44, MRMSrcMem, // if ==, GR32 = [mem32]
1517 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Sean Callanan108934c2009-12-18 00:01:26 +00001518 "cmove{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng7ad42d92007-10-05 23:13:21 +00001519 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1520 X86_COND_E, EFLAGS))]>,
1521 TB;
1522def CMOVNE16rm: I<0x45, MRMSrcMem, // if !=, GR16 = [mem16]
1523 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
Sean Callanan108934c2009-12-18 00:01:26 +00001524 "cmovne{w}\t{$src2, $dst|$dst, $src2}",
Evan Cheng7ad42d92007-10-05 23:13:21 +00001525 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1526 X86_COND_NE, EFLAGS))]>,
1527 TB, OpSize;
1528def CMOVNE32rm: I<0x45, MRMSrcMem, // if !=, GR32 = [mem32]
1529 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Sean Callanan108934c2009-12-18 00:01:26 +00001530 "cmovne{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng7ad42d92007-10-05 23:13:21 +00001531 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1532 X86_COND_NE, EFLAGS))]>,
1533 TB;
1534def CMOVBE16rm: I<0x46, MRMSrcMem, // if <=u, GR16 = [mem16]
1535 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
Sean Callanan108934c2009-12-18 00:01:26 +00001536 "cmovbe{w}\t{$src2, $dst|$dst, $src2}",
Evan Cheng7ad42d92007-10-05 23:13:21 +00001537 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1538 X86_COND_BE, EFLAGS))]>,
1539 TB, OpSize;
1540def CMOVBE32rm: I<0x46, MRMSrcMem, // if <=u, GR32 = [mem32]
1541 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Sean Callanan108934c2009-12-18 00:01:26 +00001542 "cmovbe{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng7ad42d92007-10-05 23:13:21 +00001543 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1544 X86_COND_BE, EFLAGS))]>,
1545 TB;
1546def CMOVA16rm : I<0x47, MRMSrcMem, // if >u, GR16 = [mem16]
1547 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
Sean Callanan108934c2009-12-18 00:01:26 +00001548 "cmova{w}\t{$src2, $dst|$dst, $src2}",
Evan Cheng7ad42d92007-10-05 23:13:21 +00001549 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1550 X86_COND_A, EFLAGS))]>,
1551 TB, OpSize;
1552def CMOVA32rm : I<0x47, MRMSrcMem, // if >u, GR32 = [mem32]
1553 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Sean Callanan108934c2009-12-18 00:01:26 +00001554 "cmova{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng7ad42d92007-10-05 23:13:21 +00001555 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1556 X86_COND_A, EFLAGS))]>,
1557 TB;
1558def CMOVL16rm : I<0x4C, MRMSrcMem, // if <s, GR16 = [mem16]
1559 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
Sean Callanan108934c2009-12-18 00:01:26 +00001560 "cmovl{w}\t{$src2, $dst|$dst, $src2}",
Evan Cheng7ad42d92007-10-05 23:13:21 +00001561 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1562 X86_COND_L, EFLAGS))]>,
1563 TB, OpSize;
1564def CMOVL32rm : I<0x4C, MRMSrcMem, // if <s, GR32 = [mem32]
1565 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Sean Callanan108934c2009-12-18 00:01:26 +00001566 "cmovl{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng7ad42d92007-10-05 23:13:21 +00001567 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1568 X86_COND_L, EFLAGS))]>,
1569 TB;
1570def CMOVGE16rm: I<0x4D, MRMSrcMem, // if >=s, GR16 = [mem16]
1571 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
Sean Callanan108934c2009-12-18 00:01:26 +00001572 "cmovge{w}\t{$src2, $dst|$dst, $src2}",
Evan Cheng7ad42d92007-10-05 23:13:21 +00001573 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1574 X86_COND_GE, EFLAGS))]>,
1575 TB, OpSize;
1576def CMOVGE32rm: I<0x4D, MRMSrcMem, // if >=s, GR32 = [mem32]
1577 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Sean Callanan108934c2009-12-18 00:01:26 +00001578 "cmovge{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng7ad42d92007-10-05 23:13:21 +00001579 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1580 X86_COND_GE, EFLAGS))]>,
1581 TB;
1582def CMOVLE16rm: I<0x4E, MRMSrcMem, // if <=s, GR16 = [mem16]
1583 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
Sean Callanan108934c2009-12-18 00:01:26 +00001584 "cmovle{w}\t{$src2, $dst|$dst, $src2}",
Evan Cheng7ad42d92007-10-05 23:13:21 +00001585 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1586 X86_COND_LE, EFLAGS))]>,
1587 TB, OpSize;
1588def CMOVLE32rm: I<0x4E, MRMSrcMem, // if <=s, GR32 = [mem32]
1589 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Sean Callanan108934c2009-12-18 00:01:26 +00001590 "cmovle{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng7ad42d92007-10-05 23:13:21 +00001591 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1592 X86_COND_LE, EFLAGS))]>,
1593 TB;
1594def CMOVG16rm : I<0x4F, MRMSrcMem, // if >s, GR16 = [mem16]
1595 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
Sean Callanan108934c2009-12-18 00:01:26 +00001596 "cmovg{w}\t{$src2, $dst|$dst, $src2}",
Evan Cheng7ad42d92007-10-05 23:13:21 +00001597 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1598 X86_COND_G, EFLAGS))]>,
1599 TB, OpSize;
1600def CMOVG32rm : I<0x4F, MRMSrcMem, // if >s, GR32 = [mem32]
1601 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Sean Callanan108934c2009-12-18 00:01:26 +00001602 "cmovg{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng7ad42d92007-10-05 23:13:21 +00001603 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1604 X86_COND_G, EFLAGS))]>,
1605 TB;
1606def CMOVS16rm : I<0x48, MRMSrcMem, // if signed, GR16 = [mem16]
1607 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
Sean Callanan108934c2009-12-18 00:01:26 +00001608 "cmovs{w}\t{$src2, $dst|$dst, $src2}",
Evan Cheng7ad42d92007-10-05 23:13:21 +00001609 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1610 X86_COND_S, EFLAGS))]>,
1611 TB, OpSize;
1612def CMOVS32rm : I<0x48, MRMSrcMem, // if signed, GR32 = [mem32]
1613 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Sean Callanan108934c2009-12-18 00:01:26 +00001614 "cmovs{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng7ad42d92007-10-05 23:13:21 +00001615 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1616 X86_COND_S, EFLAGS))]>,
1617 TB;
1618def CMOVNS16rm: I<0x49, MRMSrcMem, // if !signed, GR16 = [mem16]
1619 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
Sean Callanan108934c2009-12-18 00:01:26 +00001620 "cmovns{w}\t{$src2, $dst|$dst, $src2}",
Evan Cheng7ad42d92007-10-05 23:13:21 +00001621 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1622 X86_COND_NS, EFLAGS))]>,
1623 TB, OpSize;
1624def CMOVNS32rm: I<0x49, MRMSrcMem, // if !signed, GR32 = [mem32]
1625 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Sean Callanan108934c2009-12-18 00:01:26 +00001626 "cmovns{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng7ad42d92007-10-05 23:13:21 +00001627 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1628 X86_COND_NS, EFLAGS))]>,
1629 TB;
1630def CMOVP16rm : I<0x4A, MRMSrcMem, // if parity, GR16 = [mem16]
1631 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
Sean Callanan108934c2009-12-18 00:01:26 +00001632 "cmovp{w}\t{$src2, $dst|$dst, $src2}",
Evan Cheng7ad42d92007-10-05 23:13:21 +00001633 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1634 X86_COND_P, EFLAGS))]>,
1635 TB, OpSize;
1636def CMOVP32rm : I<0x4A, MRMSrcMem, // if parity, GR32 = [mem32]
1637 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Sean Callanan108934c2009-12-18 00:01:26 +00001638 "cmovp{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng7ad42d92007-10-05 23:13:21 +00001639 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1640 X86_COND_P, EFLAGS))]>,
1641 TB;
1642def CMOVNP16rm : I<0x4B, MRMSrcMem, // if !parity, GR16 = [mem16]
1643 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
Sean Callanan108934c2009-12-18 00:01:26 +00001644 "cmovnp{w}\t{$src2, $dst|$dst, $src2}",
Evan Cheng7ad42d92007-10-05 23:13:21 +00001645 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1646 X86_COND_NP, EFLAGS))]>,
1647 TB, OpSize;
Dan Gohman305fceb2009-01-07 00:35:10 +00001648def CMOVNP32rm : I<0x4B, MRMSrcMem, // if !parity, GR32 = [mem32]
1649 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Sean Callanan108934c2009-12-18 00:01:26 +00001650 "cmovnp{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohman305fceb2009-01-07 00:35:10 +00001651 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1652 X86_COND_NP, EFLAGS))]>,
1653 TB;
1654def CMOVO16rm : I<0x40, MRMSrcMem, // if overflow, GR16 = [mem16]
1655 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
Sean Callanan108934c2009-12-18 00:01:26 +00001656 "cmovo{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohman305fceb2009-01-07 00:35:10 +00001657 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1658 X86_COND_O, EFLAGS))]>,
1659 TB, OpSize;
1660def CMOVO32rm : I<0x40, MRMSrcMem, // if overflow, GR32 = [mem32]
1661 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Sean Callanan108934c2009-12-18 00:01:26 +00001662 "cmovo{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohman305fceb2009-01-07 00:35:10 +00001663 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1664 X86_COND_O, EFLAGS))]>,
1665 TB;
1666def CMOVNO16rm : I<0x41, MRMSrcMem, // if !overflow, GR16 = [mem16]
1667 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
Sean Callanan108934c2009-12-18 00:01:26 +00001668 "cmovno{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohman305fceb2009-01-07 00:35:10 +00001669 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1670 X86_COND_NO, EFLAGS))]>,
1671 TB, OpSize;
1672def CMOVNO32rm : I<0x41, MRMSrcMem, // if !overflow, GR32 = [mem32]
1673 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Sean Callanan108934c2009-12-18 00:01:26 +00001674 "cmovno{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohman305fceb2009-01-07 00:35:10 +00001675 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1676 X86_COND_NO, EFLAGS))]>,
1677 TB;
Chris Lattner314a1132010-03-14 18:31:44 +00001678} // Predicates = [HasCMov]
1679
1680// X86 doesn't have 8-bit conditional moves. Use a customInserter to
1681// emit control flow. An alternative to this is to mark i8 SELECT as Promote,
1682// however that requires promoting the operands, and can induce additional
1683// i8 register pressure. Note that CMOV_GR8 is conservatively considered to
1684// clobber EFLAGS, because if one of the operands is zero, the expansion
1685// could involve an xor.
Eric Christophera938cfb2010-06-19 00:37:40 +00001686let usesCustomInserter = 1, Constraints = "", Defs = [EFLAGS] in {
Chris Lattner314a1132010-03-14 18:31:44 +00001687def CMOV_GR8 : I<0, Pseudo,
1688 (outs GR8:$dst), (ins GR8:$src1, GR8:$src2, i8imm:$cond),
1689 "#CMOV_GR8 PSEUDO!",
1690 [(set GR8:$dst, (X86cmov GR8:$src1, GR8:$src2,
1691 imm:$cond, EFLAGS))]>;
1692
1693let Predicates = [NoCMov] in {
1694def CMOV_GR32 : I<0, Pseudo,
1695 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2, i8imm:$cond),
1696 "#CMOV_GR32* PSEUDO!",
1697 [(set GR32:$dst,
1698 (X86cmov GR32:$src1, GR32:$src2, imm:$cond, EFLAGS))]>;
1699def CMOV_GR16 : I<0, Pseudo,
1700 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2, i8imm:$cond),
1701 "#CMOV_GR16* PSEUDO!",
1702 [(set GR16:$dst,
1703 (X86cmov GR16:$src1, GR16:$src2, imm:$cond, EFLAGS))]>;
1704def CMOV_RFP32 : I<0, Pseudo,
Eric Christophera938cfb2010-06-19 00:37:40 +00001705 (outs RFP32:$dst),
1706 (ins RFP32:$src1, RFP32:$src2, i8imm:$cond),
Chris Lattner314a1132010-03-14 18:31:44 +00001707 "#CMOV_RFP32 PSEUDO!",
Eric Christophera938cfb2010-06-19 00:37:40 +00001708 [(set RFP32:$dst,
1709 (X86cmov RFP32:$src1, RFP32:$src2, imm:$cond,
Chris Lattner314a1132010-03-14 18:31:44 +00001710 EFLAGS))]>;
1711def CMOV_RFP64 : I<0, Pseudo,
Eric Christophera938cfb2010-06-19 00:37:40 +00001712 (outs RFP64:$dst),
1713 (ins RFP64:$src1, RFP64:$src2, i8imm:$cond),
Chris Lattner314a1132010-03-14 18:31:44 +00001714 "#CMOV_RFP64 PSEUDO!",
Eric Christophera938cfb2010-06-19 00:37:40 +00001715 [(set RFP64:$dst,
1716 (X86cmov RFP64:$src1, RFP64:$src2, imm:$cond,
Chris Lattner314a1132010-03-14 18:31:44 +00001717 EFLAGS))]>;
1718def CMOV_RFP80 : I<0, Pseudo,
Eric Christophera938cfb2010-06-19 00:37:40 +00001719 (outs RFP80:$dst),
1720 (ins RFP80:$src1, RFP80:$src2, i8imm:$cond),
Chris Lattner314a1132010-03-14 18:31:44 +00001721 "#CMOV_RFP80 PSEUDO!",
Eric Christophera938cfb2010-06-19 00:37:40 +00001722 [(set RFP80:$dst,
1723 (X86cmov RFP80:$src1, RFP80:$src2, imm:$cond,
Chris Lattner314a1132010-03-14 18:31:44 +00001724 EFLAGS))]>;
1725} // Predicates = [NoCMov]
Eric Christophera938cfb2010-06-19 00:37:40 +00001726} // UsesCustomInserter = 1, Constraints = "", Defs = [EFLAGS]
Evan Cheng0488db92007-09-25 01:57:46 +00001727} // Uses = [EFLAGS]
1728
1729
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00001730// unary instructions
Evan Cheng1693e482006-07-19 00:27:29 +00001731let CodeSize = 2 in {
Evan Cheng24f2ea32007-09-14 21:48:26 +00001732let Defs = [EFLAGS] in {
Eric Christophera938cfb2010-06-19 00:37:40 +00001733def NEG8r : I<0xF6, MRM3r, (outs GR8 :$dst), (ins GR8 :$src1),
1734 "neg{b}\t$dst",
1735 [(set GR8:$dst, (ineg GR8:$src1)),
Dan Gohman09a2609e2009-03-03 19:53:46 +00001736 (implicit EFLAGS)]>;
Eric Christophera938cfb2010-06-19 00:37:40 +00001737def NEG16r : I<0xF7, MRM3r, (outs GR16:$dst), (ins GR16:$src1),
1738 "neg{w}\t$dst",
1739 [(set GR16:$dst, (ineg GR16:$src1)),
Dan Gohman09a2609e2009-03-03 19:53:46 +00001740 (implicit EFLAGS)]>, OpSize;
Eric Christophera938cfb2010-06-19 00:37:40 +00001741def NEG32r : I<0xF7, MRM3r, (outs GR32:$dst), (ins GR32:$src1),
1742 "neg{l}\t$dst",
1743 [(set GR32:$dst, (ineg GR32:$src1)),
Dan Gohman09a2609e2009-03-03 19:53:46 +00001744 (implicit EFLAGS)]>;
Eric Christophera938cfb2010-06-19 00:37:40 +00001745
1746let Constraints = "" in {
1747 def NEG8m : I<0xF6, MRM3m, (outs), (ins i8mem :$dst),
1748 "neg{b}\t$dst",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001749 [(store (ineg (loadi8 addr:$dst)), addr:$dst),
1750 (implicit EFLAGS)]>;
Eric Christophera938cfb2010-06-19 00:37:40 +00001751 def NEG16m : I<0xF7, MRM3m, (outs), (ins i16mem:$dst),
1752 "neg{w}\t$dst",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001753 [(store (ineg (loadi16 addr:$dst)), addr:$dst),
1754 (implicit EFLAGS)]>, OpSize;
Eric Christophera938cfb2010-06-19 00:37:40 +00001755 def NEG32m : I<0xF7, MRM3m, (outs), (ins i32mem:$dst),
1756 "neg{l}\t$dst",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001757 [(store (ineg (loadi32 addr:$dst)), addr:$dst),
1758 (implicit EFLAGS)]>;
Eric Christophera938cfb2010-06-19 00:37:40 +00001759} // Constraints = ""
Evan Cheng24f2ea32007-09-14 21:48:26 +00001760} // Defs = [EFLAGS]
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00001761
Evan Chengaaf414c2009-01-21 02:09:05 +00001762// Match xor -1 to not. Favors these over a move imm + xor to save code size.
1763let AddedComplexity = 15 in {
Eric Christophera938cfb2010-06-19 00:37:40 +00001764def NOT8r : I<0xF6, MRM2r, (outs GR8 :$dst), (ins GR8 :$src1),
1765 "not{b}\t$dst",
1766 [(set GR8:$dst, (not GR8:$src1))]>;
1767def NOT16r : I<0xF7, MRM2r, (outs GR16:$dst), (ins GR16:$src1),
1768 "not{w}\t$dst",
1769 [(set GR16:$dst, (not GR16:$src1))]>, OpSize;
1770def NOT32r : I<0xF7, MRM2r, (outs GR32:$dst), (ins GR32:$src1),
1771 "not{l}\t$dst",
1772 [(set GR32:$dst, (not GR32:$src1))]>;
Evan Chengaaf414c2009-01-21 02:09:05 +00001773}
Eric Christophera938cfb2010-06-19 00:37:40 +00001774let Constraints = "" in {
1775 def NOT8m : I<0xF6, MRM2m, (outs), (ins i8mem :$dst),
1776 "not{b}\t$dst",
Evan Cheng605c4152005-12-13 01:57:51 +00001777 [(store (not (loadi8 addr:$dst)), addr:$dst)]>;
Eric Christophera938cfb2010-06-19 00:37:40 +00001778 def NOT16m : I<0xF7, MRM2m, (outs), (ins i16mem:$dst),
1779 "not{w}\t$dst",
Evan Cheng605c4152005-12-13 01:57:51 +00001780 [(store (not (loadi16 addr:$dst)), addr:$dst)]>, OpSize;
Eric Christophera938cfb2010-06-19 00:37:40 +00001781 def NOT32m : I<0xF7, MRM2m, (outs), (ins i32mem:$dst),
1782 "not{l}\t$dst",
Evan Cheng605c4152005-12-13 01:57:51 +00001783 [(store (not (loadi32 addr:$dst)), addr:$dst)]>;
Eric Christophera938cfb2010-06-19 00:37:40 +00001784} // Constraints = ""
Evan Cheng1693e482006-07-19 00:27:29 +00001785} // CodeSize
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00001786
Evan Chengb51a0592005-12-10 00:48:20 +00001787// TODO: inc/dec is slow for P4, but fast for Pentium-M.
Evan Cheng24f2ea32007-09-14 21:48:26 +00001788let Defs = [EFLAGS] in {
Evan Cheng1693e482006-07-19 00:27:29 +00001789let CodeSize = 2 in
Eric Christophera938cfb2010-06-19 00:37:40 +00001790def INC8r : I<0xFE, MRM0r, (outs GR8 :$dst), (ins GR8 :$src1),
1791 "inc{b}\t$dst",
1792 [(set GR8:$dst, EFLAGS, (X86inc_flag GR8:$src1))]>;
Chris Lattnerc54a2f12010-03-24 01:02:12 +00001793
Evan Cheng1693e482006-07-19 00:27:29 +00001794let isConvertibleToThreeAddress = 1, CodeSize = 1 in { // Can xform into LEA.
Eric Christophera938cfb2010-06-19 00:37:40 +00001795def INC16r : I<0x40, AddRegFrm, (outs GR16:$dst), (ins GR16:$src1),
Sean Callanan108934c2009-12-18 00:01:26 +00001796 "inc{w}\t$dst",
Eric Christophera938cfb2010-06-19 00:37:40 +00001797 [(set GR16:$dst, EFLAGS, (X86inc_flag GR16:$src1))]>,
Evan Cheng25ab6902006-09-08 06:48:29 +00001798 OpSize, Requires<[In32BitMode]>;
Eric Christophera938cfb2010-06-19 00:37:40 +00001799def INC32r : I<0x40, AddRegFrm, (outs GR32:$dst), (ins GR32:$src1),
Sean Callanan108934c2009-12-18 00:01:26 +00001800 "inc{l}\t$dst",
Eric Christophera938cfb2010-06-19 00:37:40 +00001801 [(set GR32:$dst, EFLAGS, (X86inc_flag GR32:$src1))]>,
Chris Lattner589ad5d2010-03-25 05:44:01 +00001802 Requires<[In32BitMode]>;
Chris Lattnercc65bee2005-01-02 02:35:46 +00001803}
Eric Christophera938cfb2010-06-19 00:37:40 +00001804let Constraints = "", CodeSize = 2 in {
Dan Gohmanb1576f52007-07-31 20:11:57 +00001805 def INC8m : I<0xFE, MRM0m, (outs), (ins i8mem :$dst), "inc{b}\t$dst",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001806 [(store (add (loadi8 addr:$dst), 1), addr:$dst),
1807 (implicit EFLAGS)]>;
Dan Gohmanb1576f52007-07-31 20:11:57 +00001808 def INC16m : I<0xFF, MRM0m, (outs), (ins i16mem:$dst), "inc{w}\t$dst",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001809 [(store (add (loadi16 addr:$dst), 1), addr:$dst),
1810 (implicit EFLAGS)]>,
Evan Cheng66f71632007-10-19 21:23:22 +00001811 OpSize, Requires<[In32BitMode]>;
Dan Gohmanb1576f52007-07-31 20:11:57 +00001812 def INC32m : I<0xFF, MRM0m, (outs), (ins i32mem:$dst), "inc{l}\t$dst",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001813 [(store (add (loadi32 addr:$dst), 1), addr:$dst),
1814 (implicit EFLAGS)]>,
Evan Cheng66f71632007-10-19 21:23:22 +00001815 Requires<[In32BitMode]>;
Eric Christophera938cfb2010-06-19 00:37:40 +00001816} // Constraints = "", CodeSize = 2
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00001817
Evan Cheng1693e482006-07-19 00:27:29 +00001818let CodeSize = 2 in
Eric Christophera938cfb2010-06-19 00:37:40 +00001819def DEC8r : I<0xFE, MRM1r, (outs GR8 :$dst), (ins GR8 :$src1),
1820 "dec{b}\t$dst",
1821 [(set GR8:$dst, EFLAGS, (X86dec_flag GR8:$src1))]>;
Evan Cheng1693e482006-07-19 00:27:29 +00001822let isConvertibleToThreeAddress = 1, CodeSize = 1 in { // Can xform into LEA.
Eric Christophera938cfb2010-06-19 00:37:40 +00001823def DEC16r : I<0x48, AddRegFrm, (outs GR16:$dst), (ins GR16:$src1),
Sean Callanan108934c2009-12-18 00:01:26 +00001824 "dec{w}\t$dst",
Eric Christophera938cfb2010-06-19 00:37:40 +00001825 [(set GR16:$dst, EFLAGS, (X86dec_flag GR16:$src1))]>,
Evan Cheng25ab6902006-09-08 06:48:29 +00001826 OpSize, Requires<[In32BitMode]>;
Eric Christophera938cfb2010-06-19 00:37:40 +00001827def DEC32r : I<0x48, AddRegFrm, (outs GR32:$dst), (ins GR32:$src1),
Sean Callanan108934c2009-12-18 00:01:26 +00001828 "dec{l}\t$dst",
Eric Christophera938cfb2010-06-19 00:37:40 +00001829 [(set GR32:$dst, EFLAGS, (X86dec_flag GR32:$src1))]>,
Chris Lattner589ad5d2010-03-25 05:44:01 +00001830 Requires<[In32BitMode]>;
Eric Christophera938cfb2010-06-19 00:37:40 +00001831} // CodeSize = 2
Chris Lattner57a02302004-08-11 04:31:00 +00001832
Eric Christophera938cfb2010-06-19 00:37:40 +00001833let Constraints = "", CodeSize = 2 in {
Dan Gohmanb1576f52007-07-31 20:11:57 +00001834 def DEC8m : I<0xFE, MRM1m, (outs), (ins i8mem :$dst), "dec{b}\t$dst",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001835 [(store (add (loadi8 addr:$dst), -1), addr:$dst),
1836 (implicit EFLAGS)]>;
Dan Gohmanb1576f52007-07-31 20:11:57 +00001837 def DEC16m : I<0xFF, MRM1m, (outs), (ins i16mem:$dst), "dec{w}\t$dst",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001838 [(store (add (loadi16 addr:$dst), -1), addr:$dst),
1839 (implicit EFLAGS)]>,
Evan Cheng66f71632007-10-19 21:23:22 +00001840 OpSize, Requires<[In32BitMode]>;
Dan Gohmanb1576f52007-07-31 20:11:57 +00001841 def DEC32m : I<0xFF, MRM1m, (outs), (ins i32mem:$dst), "dec{l}\t$dst",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001842 [(store (add (loadi32 addr:$dst), -1), addr:$dst),
1843 (implicit EFLAGS)]>,
Evan Cheng66f71632007-10-19 21:23:22 +00001844 Requires<[In32BitMode]>;
Eric Christophera938cfb2010-06-19 00:37:40 +00001845} // Constraints = "", CodeSize = 2
Evan Cheng24f2ea32007-09-14 21:48:26 +00001846} // Defs = [EFLAGS]
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00001847
1848// Logical operators...
Evan Cheng24f2ea32007-09-14 21:48:26 +00001849let Defs = [EFLAGS] in {
Chris Lattnercc65bee2005-01-02 02:35:46 +00001850let isCommutable = 1 in { // X = AND Y, Z --> X = AND Z, Y
Chris Lattner589ad5d2010-03-25 05:44:01 +00001851def AND8rr : I<0x20, MRMDestReg,
1852 (outs GR8 :$dst), (ins GR8 :$src1, GR8 :$src2),
1853 "and{b}\t{$src2, $dst|$dst, $src2}",
1854 [(set GR8:$dst, EFLAGS, (X86and_flag GR8:$src1, GR8:$src2))]>;
1855def AND16rr : I<0x21, MRMDestReg,
1856 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
1857 "and{w}\t{$src2, $dst|$dst, $src2}",
1858 [(set GR16:$dst, EFLAGS, (X86and_flag GR16:$src1,
1859 GR16:$src2))]>, OpSize;
1860def AND32rr : I<0x21, MRMDestReg,
1861 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
1862 "and{l}\t{$src2, $dst|$dst, $src2}",
1863 [(set GR32:$dst, EFLAGS, (X86and_flag GR32:$src1,
1864 GR32:$src2))]>;
Chris Lattnercc65bee2005-01-02 02:35:46 +00001865}
Chris Lattner57a02302004-08-11 04:31:00 +00001866
Sean Callanan108934c2009-12-18 00:01:26 +00001867// AND instructions with the destination register in REG and the source register
1868// in R/M. Included for the disassembler.
Daniel Dunbardcbab9c2010-05-26 22:21:28 +00001869let isCodeGenOnly = 1 in {
Sean Callanan108934c2009-12-18 00:01:26 +00001870def AND8rr_REV : I<0x22, MRMSrcReg, (outs GR8:$dst), (ins GR8:$src1, GR8:$src2),
1871 "and{b}\t{$src2, $dst|$dst, $src2}", []>;
1872def AND16rr_REV : I<0x23, MRMSrcReg, (outs GR16:$dst),
1873 (ins GR16:$src1, GR16:$src2),
1874 "and{w}\t{$src2, $dst|$dst, $src2}", []>, OpSize;
1875def AND32rr_REV : I<0x23, MRMSrcReg, (outs GR32:$dst),
1876 (ins GR32:$src1, GR32:$src2),
1877 "and{l}\t{$src2, $dst|$dst, $src2}", []>;
Daniel Dunbardcbab9c2010-05-26 22:21:28 +00001878}
Sean Callanan108934c2009-12-18 00:01:26 +00001879
Chris Lattner3a173df2004-10-03 20:35:00 +00001880def AND8rm : I<0x22, MRMSrcMem,
Evan Cheng64d80e32007-07-19 01:14:50 +00001881 (outs GR8 :$dst), (ins GR8 :$src1, i8mem :$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001882 "and{b}\t{$src2, $dst|$dst, $src2}",
Chris Lattner589ad5d2010-03-25 05:44:01 +00001883 [(set GR8:$dst, EFLAGS, (X86and_flag GR8:$src1,
1884 (loadi8 addr:$src2)))]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00001885def AND16rm : I<0x23, MRMSrcMem,
Evan Cheng64d80e32007-07-19 01:14:50 +00001886 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001887 "and{w}\t{$src2, $dst|$dst, $src2}",
Chris Lattner589ad5d2010-03-25 05:44:01 +00001888 [(set GR16:$dst, EFLAGS, (X86and_flag GR16:$src1,
1889 (loadi16 addr:$src2)))]>,
1890 OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00001891def AND32rm : I<0x23, MRMSrcMem,
Evan Cheng64d80e32007-07-19 01:14:50 +00001892 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001893 "and{l}\t{$src2, $dst|$dst, $src2}",
Chris Lattner589ad5d2010-03-25 05:44:01 +00001894 [(set GR32:$dst, EFLAGS, (X86and_flag GR32:$src1,
1895 (loadi32 addr:$src2)))]>;
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00001896
Chris Lattner3a173df2004-10-03 20:35:00 +00001897def AND8ri : Ii8<0x80, MRM4r,
Evan Cheng64d80e32007-07-19 01:14:50 +00001898 (outs GR8 :$dst), (ins GR8 :$src1, i8imm :$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001899 "and{b}\t{$src2, $dst|$dst, $src2}",
Chris Lattner589ad5d2010-03-25 05:44:01 +00001900 [(set GR8:$dst, EFLAGS, (X86and_flag GR8:$src1,
1901 imm:$src2))]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00001902def AND16ri : Ii16<0x81, MRM4r,
Evan Cheng64d80e32007-07-19 01:14:50 +00001903 (outs GR16:$dst), (ins GR16:$src1, i16imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001904 "and{w}\t{$src2, $dst|$dst, $src2}",
Chris Lattner589ad5d2010-03-25 05:44:01 +00001905 [(set GR16:$dst, EFLAGS, (X86and_flag GR16:$src1,
1906 imm:$src2))]>, OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00001907def AND32ri : Ii32<0x81, MRM4r,
Evan Cheng64d80e32007-07-19 01:14:50 +00001908 (outs GR32:$dst), (ins GR32:$src1, i32imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001909 "and{l}\t{$src2, $dst|$dst, $src2}",
Chris Lattner589ad5d2010-03-25 05:44:01 +00001910 [(set GR32:$dst, EFLAGS, (X86and_flag GR32:$src1,
1911 imm:$src2))]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00001912def AND16ri8 : Ii8<0x83, MRM4r,
Evan Cheng64d80e32007-07-19 01:14:50 +00001913 (outs GR16:$dst), (ins GR16:$src1, i16i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001914 "and{w}\t{$src2, $dst|$dst, $src2}",
Chris Lattner589ad5d2010-03-25 05:44:01 +00001915 [(set GR16:$dst, EFLAGS, (X86and_flag GR16:$src1,
1916 i16immSExt8:$src2))]>,
Evan Cheng9b6b6422005-12-13 00:14:11 +00001917 OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00001918def AND32ri8 : Ii8<0x83, MRM4r,
Evan Cheng64d80e32007-07-19 01:14:50 +00001919 (outs GR32:$dst), (ins GR32:$src1, i32i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001920 "and{l}\t{$src2, $dst|$dst, $src2}",
Chris Lattner589ad5d2010-03-25 05:44:01 +00001921 [(set GR32:$dst, EFLAGS, (X86and_flag GR32:$src1,
1922 i32immSExt8:$src2))]>;
Chris Lattnerf29ed092004-08-11 05:07:25 +00001923
Eric Christophera938cfb2010-06-19 00:37:40 +00001924let Constraints = "" in {
Chris Lattner3a173df2004-10-03 20:35:00 +00001925 def AND8mr : I<0x20, MRMDestMem,
Evan Cheng64d80e32007-07-19 01:14:50 +00001926 (outs), (ins i8mem :$dst, GR8 :$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001927 "and{b}\t{$src, $dst|$dst, $src}",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001928 [(store (and (load addr:$dst), GR8:$src), addr:$dst),
1929 (implicit EFLAGS)]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00001930 def AND16mr : I<0x21, MRMDestMem,
Evan Cheng64d80e32007-07-19 01:14:50 +00001931 (outs), (ins i16mem:$dst, GR16:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001932 "and{w}\t{$src, $dst|$dst, $src}",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001933 [(store (and (load addr:$dst), GR16:$src), addr:$dst),
1934 (implicit EFLAGS)]>,
Evan Cheng0ef3a772005-12-13 01:41:36 +00001935 OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00001936 def AND32mr : I<0x21, MRMDestMem,
Evan Cheng64d80e32007-07-19 01:14:50 +00001937 (outs), (ins i32mem:$dst, GR32:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001938 "and{l}\t{$src, $dst|$dst, $src}",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001939 [(store (and (load addr:$dst), GR32:$src), addr:$dst),
1940 (implicit EFLAGS)]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00001941 def AND8mi : Ii8<0x80, MRM4m,
Evan Cheng64d80e32007-07-19 01:14:50 +00001942 (outs), (ins i8mem :$dst, i8imm :$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001943 "and{b}\t{$src, $dst|$dst, $src}",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001944 [(store (and (loadi8 addr:$dst), imm:$src), addr:$dst),
1945 (implicit EFLAGS)]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00001946 def AND16mi : Ii16<0x81, MRM4m,
Evan Cheng64d80e32007-07-19 01:14:50 +00001947 (outs), (ins i16mem:$dst, i16imm:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001948 "and{w}\t{$src, $dst|$dst, $src}",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001949 [(store (and (loadi16 addr:$dst), imm:$src), addr:$dst),
1950 (implicit EFLAGS)]>,
Evan Cheng0ef3a772005-12-13 01:41:36 +00001951 OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00001952 def AND32mi : Ii32<0x81, MRM4m,
Evan Cheng64d80e32007-07-19 01:14:50 +00001953 (outs), (ins i32mem:$dst, i32imm:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001954 "and{l}\t{$src, $dst|$dst, $src}",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001955 [(store (and (loadi32 addr:$dst), imm:$src), addr:$dst),
1956 (implicit EFLAGS)]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00001957 def AND16mi8 : Ii8<0x83, MRM4m,
Evan Cheng64d80e32007-07-19 01:14:50 +00001958 (outs), (ins i16mem:$dst, i16i8imm :$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001959 "and{w}\t{$src, $dst|$dst, $src}",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001960 [(store (and (load addr:$dst), i16immSExt8:$src), addr:$dst),
1961 (implicit EFLAGS)]>,
Evan Cheng0ef3a772005-12-13 01:41:36 +00001962 OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00001963 def AND32mi8 : Ii8<0x83, MRM4m,
Evan Cheng64d80e32007-07-19 01:14:50 +00001964 (outs), (ins i32mem:$dst, i32i8imm :$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001965 "and{l}\t{$src, $dst|$dst, $src}",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001966 [(store (and (load addr:$dst), i32immSExt8:$src), addr:$dst),
1967 (implicit EFLAGS)]>;
Sean Callanana09caa52009-09-02 00:55:49 +00001968
1969 def AND8i8 : Ii8<0x24, RawFrm, (outs), (ins i8imm:$src),
1970 "and{b}\t{$src, %al|%al, $src}", []>;
1971 def AND16i16 : Ii16<0x25, RawFrm, (outs), (ins i16imm:$src),
1972 "and{w}\t{$src, %ax|%ax, $src}", []>, OpSize;
1973 def AND32i32 : Ii32<0x25, RawFrm, (outs), (ins i32imm:$src),
1974 "and{l}\t{$src, %eax|%eax, $src}", []>;
1975
Eric Christophera938cfb2010-06-19 00:37:40 +00001976} // Constraints = ""
Chris Lattnerf29ed092004-08-11 05:07:25 +00001977
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00001978
Chris Lattnercc65bee2005-01-02 02:35:46 +00001979let isCommutable = 1 in { // X = OR Y, Z --> X = OR Z, Y
Sean Callanan108934c2009-12-18 00:01:26 +00001980def OR8rr : I<0x08, MRMDestReg, (outs GR8 :$dst),
1981 (ins GR8 :$src1, GR8 :$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001982 "or{b}\t{$src2, $dst|$dst, $src2}",
Chris Lattner589ad5d2010-03-25 05:44:01 +00001983 [(set GR8:$dst, EFLAGS, (X86or_flag GR8:$src1, GR8:$src2))]>;
Sean Callanan108934c2009-12-18 00:01:26 +00001984def OR16rr : I<0x09, MRMDestReg, (outs GR16:$dst),
1985 (ins GR16:$src1, GR16:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001986 "or{w}\t{$src2, $dst|$dst, $src2}",
Chris Lattner589ad5d2010-03-25 05:44:01 +00001987 [(set GR16:$dst, EFLAGS, (X86or_flag GR16:$src1,GR16:$src2))]>,
1988 OpSize;
Sean Callanan108934c2009-12-18 00:01:26 +00001989def OR32rr : I<0x09, MRMDestReg, (outs GR32:$dst),
1990 (ins GR32:$src1, GR32:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001991 "or{l}\t{$src2, $dst|$dst, $src2}",
Chris Lattner589ad5d2010-03-25 05:44:01 +00001992 [(set GR32:$dst, EFLAGS, (X86or_flag GR32:$src1,GR32:$src2))]>;
Chris Lattnercc65bee2005-01-02 02:35:46 +00001993}
Sean Callanan108934c2009-12-18 00:01:26 +00001994
1995// OR instructions with the destination register in REG and the source register
1996// in R/M. Included for the disassembler.
Daniel Dunbardcbab9c2010-05-26 22:21:28 +00001997let isCodeGenOnly = 1 in {
Sean Callanan108934c2009-12-18 00:01:26 +00001998def OR8rr_REV : I<0x0A, MRMSrcReg, (outs GR8:$dst), (ins GR8:$src1, GR8:$src2),
1999 "or{b}\t{$src2, $dst|$dst, $src2}", []>;
2000def OR16rr_REV : I<0x0B, MRMSrcReg, (outs GR16:$dst),
2001 (ins GR16:$src1, GR16:$src2),
2002 "or{w}\t{$src2, $dst|$dst, $src2}", []>, OpSize;
2003def OR32rr_REV : I<0x0B, MRMSrcReg, (outs GR32:$dst),
2004 (ins GR32:$src1, GR32:$src2),
2005 "or{l}\t{$src2, $dst|$dst, $src2}", []>;
Daniel Dunbardcbab9c2010-05-26 22:21:28 +00002006}
Sean Callanan108934c2009-12-18 00:01:26 +00002007
Chris Lattner589ad5d2010-03-25 05:44:01 +00002008def OR8rm : I<0x0A, MRMSrcMem, (outs GR8 :$dst),
Sean Callanan108934c2009-12-18 00:01:26 +00002009 (ins GR8 :$src1, i8mem :$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002010 "or{b}\t{$src2, $dst|$dst, $src2}",
Chris Lattner589ad5d2010-03-25 05:44:01 +00002011 [(set GR8:$dst, EFLAGS, (X86or_flag GR8:$src1,
2012 (load addr:$src2)))]>;
2013def OR16rm : I<0x0B, MRMSrcMem, (outs GR16:$dst),
Sean Callanan108934c2009-12-18 00:01:26 +00002014 (ins GR16:$src1, i16mem:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002015 "or{w}\t{$src2, $dst|$dst, $src2}",
Chris Lattner589ad5d2010-03-25 05:44:01 +00002016 [(set GR16:$dst, EFLAGS, (X86or_flag GR16:$src1,
2017 (load addr:$src2)))]>,
2018 OpSize;
2019def OR32rm : I<0x0B, MRMSrcMem, (outs GR32:$dst),
Sean Callanan108934c2009-12-18 00:01:26 +00002020 (ins GR32:$src1, i32mem:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002021 "or{l}\t{$src2, $dst|$dst, $src2}",
Chris Lattner589ad5d2010-03-25 05:44:01 +00002022 [(set GR32:$dst, EFLAGS, (X86or_flag GR32:$src1,
2023 (load addr:$src2)))]>;
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00002024
Sean Callanan108934c2009-12-18 00:01:26 +00002025def OR8ri : Ii8 <0x80, MRM1r, (outs GR8 :$dst),
2026 (ins GR8 :$src1, i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002027 "or{b}\t{$src2, $dst|$dst, $src2}",
Chris Lattner589ad5d2010-03-25 05:44:01 +00002028 [(set GR8:$dst,EFLAGS, (X86or_flag GR8:$src1, imm:$src2))]>;
Sean Callanan108934c2009-12-18 00:01:26 +00002029def OR16ri : Ii16<0x81, MRM1r, (outs GR16:$dst),
2030 (ins GR16:$src1, i16imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002031 "or{w}\t{$src2, $dst|$dst, $src2}",
Chris Lattner589ad5d2010-03-25 05:44:01 +00002032 [(set GR16:$dst, EFLAGS, (X86or_flag GR16:$src1,
2033 imm:$src2))]>, OpSize;
Sean Callanan108934c2009-12-18 00:01:26 +00002034def OR32ri : Ii32<0x81, MRM1r, (outs GR32:$dst),
2035 (ins GR32:$src1, i32imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002036 "or{l}\t{$src2, $dst|$dst, $src2}",
Chris Lattner589ad5d2010-03-25 05:44:01 +00002037 [(set GR32:$dst, EFLAGS, (X86or_flag GR32:$src1,
2038 imm:$src2))]>;
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00002039
Sean Callanan108934c2009-12-18 00:01:26 +00002040def OR16ri8 : Ii8<0x83, MRM1r, (outs GR16:$dst),
2041 (ins GR16:$src1, i16i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002042 "or{w}\t{$src2, $dst|$dst, $src2}",
Chris Lattner589ad5d2010-03-25 05:44:01 +00002043 [(set GR16:$dst, EFLAGS, (X86or_flag GR16:$src1,
2044 i16immSExt8:$src2))]>, OpSize;
Sean Callanan108934c2009-12-18 00:01:26 +00002045def OR32ri8 : Ii8<0x83, MRM1r, (outs GR32:$dst),
2046 (ins GR32:$src1, i32i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002047 "or{l}\t{$src2, $dst|$dst, $src2}",
Chris Lattner589ad5d2010-03-25 05:44:01 +00002048 [(set GR32:$dst, EFLAGS, (X86or_flag GR32:$src1,
2049 i32immSExt8:$src2))]>;
Eric Christophera938cfb2010-06-19 00:37:40 +00002050let Constraints = "" in {
Evan Cheng64d80e32007-07-19 01:14:50 +00002051 def OR8mr : I<0x08, MRMDestMem, (outs), (ins i8mem:$dst, GR8:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002052 "or{b}\t{$src, $dst|$dst, $src}",
Dan Gohman09a2609e2009-03-03 19:53:46 +00002053 [(store (or (load addr:$dst), GR8:$src), addr:$dst),
2054 (implicit EFLAGS)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00002055 def OR16mr : I<0x09, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$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), GR16:$src), addr:$dst),
2058 (implicit EFLAGS)]>, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00002059 def OR32mr : I<0x09, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002060 "or{l}\t{$src, $dst|$dst, $src}",
Dan Gohman09a2609e2009-03-03 19:53:46 +00002061 [(store (or (load addr:$dst), GR32:$src), addr:$dst),
2062 (implicit EFLAGS)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00002063 def OR8mi : Ii8<0x80, MRM1m, (outs), (ins i8mem :$dst, i8imm:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002064 "or{b}\t{$src, $dst|$dst, $src}",
Dan Gohman09a2609e2009-03-03 19:53:46 +00002065 [(store (or (loadi8 addr:$dst), imm:$src), addr:$dst),
2066 (implicit EFLAGS)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00002067 def OR16mi : Ii16<0x81, MRM1m, (outs), (ins i16mem:$dst, i16imm:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002068 "or{w}\t{$src, $dst|$dst, $src}",
Dan Gohman09a2609e2009-03-03 19:53:46 +00002069 [(store (or (loadi16 addr:$dst), imm:$src), addr:$dst),
2070 (implicit EFLAGS)]>,
Evan Cheng0ef3a772005-12-13 01:41:36 +00002071 OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00002072 def OR32mi : Ii32<0x81, MRM1m, (outs), (ins i32mem:$dst, i32imm:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002073 "or{l}\t{$src, $dst|$dst, $src}",
Dan Gohman09a2609e2009-03-03 19:53:46 +00002074 [(store (or (loadi32 addr:$dst), imm:$src), addr:$dst),
2075 (implicit EFLAGS)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00002076 def OR16mi8 : Ii8<0x83, MRM1m, (outs), (ins i16mem:$dst, i16i8imm:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002077 "or{w}\t{$src, $dst|$dst, $src}",
Dan Gohman09a2609e2009-03-03 19:53:46 +00002078 [(store (or (load addr:$dst), i16immSExt8:$src), addr:$dst),
2079 (implicit EFLAGS)]>,
Evan Cheng0ef3a772005-12-13 01:41:36 +00002080 OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00002081 def OR32mi8 : Ii8<0x83, MRM1m, (outs), (ins i32mem:$dst, i32i8imm:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002082 "or{l}\t{$src, $dst|$dst, $src}",
Dan Gohman09a2609e2009-03-03 19:53:46 +00002083 [(store (or (load addr:$dst), i32immSExt8:$src), addr:$dst),
2084 (implicit EFLAGS)]>;
Sean Callanand00025a2009-09-11 19:01:56 +00002085
2086 def OR8i8 : Ii8 <0x0C, RawFrm, (outs), (ins i8imm:$src),
2087 "or{b}\t{$src, %al|%al, $src}", []>;
2088 def OR16i16 : Ii16 <0x0D, RawFrm, (outs), (ins i16imm:$src),
2089 "or{w}\t{$src, %ax|%ax, $src}", []>, OpSize;
2090 def OR32i32 : Ii32 <0x0D, RawFrm, (outs), (ins i32imm:$src),
2091 "or{l}\t{$src, %eax|%eax, $src}", []>;
Eric Christophera938cfb2010-06-19 00:37:40 +00002092} // Constraints = ""
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00002093
2094
Evan Cheng359e9372008-06-18 08:13:07 +00002095let isCommutable = 1 in { // X = XOR Y, Z --> X = XOR Z, Y
Bill Wendlingbd0879d2008-05-29 01:02:09 +00002096 def XOR8rr : I<0x30, MRMDestReg,
2097 (outs GR8 :$dst), (ins GR8 :$src1, GR8 :$src2),
2098 "xor{b}\t{$src2, $dst|$dst, $src2}",
Chris Lattner589ad5d2010-03-25 05:44:01 +00002099 [(set GR8:$dst, EFLAGS, (X86xor_flag GR8:$src1,
2100 GR8:$src2))]>;
Bill Wendlingbd0879d2008-05-29 01:02:09 +00002101 def XOR16rr : I<0x31, MRMDestReg,
2102 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
2103 "xor{w}\t{$src2, $dst|$dst, $src2}",
Chris Lattner589ad5d2010-03-25 05:44:01 +00002104 [(set GR16:$dst, EFLAGS, (X86xor_flag GR16:$src1,
2105 GR16:$src2))]>, OpSize;
Bill Wendlingbd0879d2008-05-29 01:02:09 +00002106 def XOR32rr : I<0x31, MRMDestReg,
2107 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
2108 "xor{l}\t{$src2, $dst|$dst, $src2}",
Chris Lattner589ad5d2010-03-25 05:44:01 +00002109 [(set GR32:$dst, EFLAGS, (X86xor_flag GR32:$src1,
2110 GR32:$src2))]>;
Evan Cheng359e9372008-06-18 08:13:07 +00002111} // isCommutable = 1
Chris Lattnercc65bee2005-01-02 02:35:46 +00002112
Sean Callanan108934c2009-12-18 00:01:26 +00002113// XOR instructions with the destination register in REG and the source register
2114// in R/M. Included for the disassembler.
Daniel Dunbardcbab9c2010-05-26 22:21:28 +00002115let isCodeGenOnly = 1 in {
Sean Callanan108934c2009-12-18 00:01:26 +00002116def XOR8rr_REV : I<0x32, MRMSrcReg, (outs GR8:$dst), (ins GR8:$src1, GR8:$src2),
2117 "xor{b}\t{$src2, $dst|$dst, $src2}", []>;
2118def XOR16rr_REV : I<0x33, MRMSrcReg, (outs GR16:$dst),
2119 (ins GR16:$src1, GR16:$src2),
2120 "xor{w}\t{$src2, $dst|$dst, $src2}", []>, OpSize;
2121def XOR32rr_REV : I<0x33, MRMSrcReg, (outs GR32:$dst),
2122 (ins GR32:$src1, GR32:$src2),
2123 "xor{l}\t{$src2, $dst|$dst, $src2}", []>;
Daniel Dunbardcbab9c2010-05-26 22:21:28 +00002124}
Sean Callanan108934c2009-12-18 00:01:26 +00002125
Chris Lattner589ad5d2010-03-25 05:44:01 +00002126def XOR8rm : I<0x32, MRMSrcMem,
Evan Cheng64d80e32007-07-19 01:14:50 +00002127 (outs GR8 :$dst), (ins GR8:$src1, i8mem :$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002128 "xor{b}\t{$src2, $dst|$dst, $src2}",
Chris Lattner589ad5d2010-03-25 05:44:01 +00002129 [(set GR8:$dst, EFLAGS, (X86xor_flag GR8:$src1,
2130 (load addr:$src2)))]>;
2131def XOR16rm : I<0x33, MRMSrcMem,
Evan Cheng64d80e32007-07-19 01:14:50 +00002132 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002133 "xor{w}\t{$src2, $dst|$dst, $src2}",
Chris Lattner589ad5d2010-03-25 05:44:01 +00002134 [(set GR16:$dst, EFLAGS, (X86xor_flag GR16:$src1,
2135 (load addr:$src2)))]>,
Bill Wendlingbd0879d2008-05-29 01:02:09 +00002136 OpSize;
Chris Lattner589ad5d2010-03-25 05:44:01 +00002137def XOR32rm : I<0x33, MRMSrcMem,
Evan Cheng64d80e32007-07-19 01:14:50 +00002138 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002139 "xor{l}\t{$src2, $dst|$dst, $src2}",
Chris Lattner589ad5d2010-03-25 05:44:01 +00002140 [(set GR32:$dst, EFLAGS, (X86xor_flag GR32:$src1,
2141 (load addr:$src2)))]>;
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00002142
Chris Lattner589ad5d2010-03-25 05:44:01 +00002143def XOR8ri : Ii8<0x80, MRM6r,
2144 (outs GR8:$dst), (ins GR8:$src1, i8imm:$src2),
2145 "xor{b}\t{$src2, $dst|$dst, $src2}",
2146 [(set GR8:$dst, EFLAGS, (X86xor_flag GR8:$src1, imm:$src2))]>;
2147def XOR16ri : Ii16<0x81, MRM6r,
2148 (outs GR16:$dst), (ins GR16:$src1, i16imm:$src2),
2149 "xor{w}\t{$src2, $dst|$dst, $src2}",
2150 [(set GR16:$dst, EFLAGS, (X86xor_flag GR16:$src1,
2151 imm:$src2))]>, OpSize;
Bill Wendling75cf88f2008-05-29 03:46:36 +00002152def XOR32ri : Ii32<0x81, MRM6r,
2153 (outs GR32:$dst), (ins GR32:$src1, i32imm:$src2),
2154 "xor{l}\t{$src2, $dst|$dst, $src2}",
Chris Lattner589ad5d2010-03-25 05:44:01 +00002155 [(set GR32:$dst, EFLAGS, (X86xor_flag GR32:$src1,
2156 imm:$src2))]>;
Bill Wendling75cf88f2008-05-29 03:46:36 +00002157def XOR16ri8 : Ii8<0x83, MRM6r,
2158 (outs GR16:$dst), (ins GR16:$src1, i16i8imm:$src2),
2159 "xor{w}\t{$src2, $dst|$dst, $src2}",
Chris Lattner589ad5d2010-03-25 05:44:01 +00002160 [(set GR16:$dst, EFLAGS, (X86xor_flag GR16:$src1,
2161 i16immSExt8:$src2))]>,
Bill Wendling75cf88f2008-05-29 03:46:36 +00002162 OpSize;
2163def XOR32ri8 : Ii8<0x83, MRM6r,
2164 (outs GR32:$dst), (ins GR32:$src1, i32i8imm:$src2),
2165 "xor{l}\t{$src2, $dst|$dst, $src2}",
Chris Lattner589ad5d2010-03-25 05:44:01 +00002166 [(set GR32:$dst, EFLAGS, (X86xor_flag GR32:$src1,
2167 i32immSExt8:$src2))]>;
Bill Wendlingbd0879d2008-05-29 01:02:09 +00002168
Eric Christophera938cfb2010-06-19 00:37:40 +00002169let Constraints = "" in {
Chris Lattner3a173df2004-10-03 20:35:00 +00002170 def XOR8mr : I<0x30, MRMDestMem,
Evan Cheng64d80e32007-07-19 01:14:50 +00002171 (outs), (ins i8mem :$dst, GR8 :$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002172 "xor{b}\t{$src, $dst|$dst, $src}",
Dan Gohman09a2609e2009-03-03 19:53:46 +00002173 [(store (xor (load addr:$dst), GR8:$src), addr:$dst),
2174 (implicit EFLAGS)]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00002175 def XOR16mr : I<0x31, MRMDestMem,
Evan Cheng64d80e32007-07-19 01:14:50 +00002176 (outs), (ins i16mem:$dst, GR16:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002177 "xor{w}\t{$src, $dst|$dst, $src}",
Dan Gohman09a2609e2009-03-03 19:53:46 +00002178 [(store (xor (load addr:$dst), GR16:$src), addr:$dst),
2179 (implicit EFLAGS)]>,
Evan Cheng0ef3a772005-12-13 01:41:36 +00002180 OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00002181 def XOR32mr : I<0x31, MRMDestMem,
Evan Cheng64d80e32007-07-19 01:14:50 +00002182 (outs), (ins i32mem:$dst, GR32:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002183 "xor{l}\t{$src, $dst|$dst, $src}",
Dan Gohman09a2609e2009-03-03 19:53:46 +00002184 [(store (xor (load addr:$dst), GR32:$src), addr:$dst),
2185 (implicit EFLAGS)]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00002186 def XOR8mi : Ii8<0x80, MRM6m,
Evan Cheng64d80e32007-07-19 01:14:50 +00002187 (outs), (ins i8mem :$dst, i8imm :$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002188 "xor{b}\t{$src, $dst|$dst, $src}",
Dan Gohman09a2609e2009-03-03 19:53:46 +00002189 [(store (xor (loadi8 addr:$dst), imm:$src), addr:$dst),
2190 (implicit EFLAGS)]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00002191 def XOR16mi : Ii16<0x81, MRM6m,
Evan Cheng64d80e32007-07-19 01:14:50 +00002192 (outs), (ins i16mem:$dst, i16imm:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002193 "xor{w}\t{$src, $dst|$dst, $src}",
Dan Gohman09a2609e2009-03-03 19:53:46 +00002194 [(store (xor (loadi16 addr:$dst), imm:$src), addr:$dst),
2195 (implicit EFLAGS)]>,
Evan Cheng0ef3a772005-12-13 01:41:36 +00002196 OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00002197 def XOR32mi : Ii32<0x81, MRM6m,
Evan Cheng64d80e32007-07-19 01:14:50 +00002198 (outs), (ins i32mem:$dst, i32imm:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002199 "xor{l}\t{$src, $dst|$dst, $src}",
Dan Gohman09a2609e2009-03-03 19:53:46 +00002200 [(store (xor (loadi32 addr:$dst), imm:$src), addr:$dst),
2201 (implicit EFLAGS)]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00002202 def XOR16mi8 : Ii8<0x83, MRM6m,
Evan Cheng64d80e32007-07-19 01:14:50 +00002203 (outs), (ins i16mem:$dst, i16i8imm :$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002204 "xor{w}\t{$src, $dst|$dst, $src}",
Dan Gohman09a2609e2009-03-03 19:53:46 +00002205 [(store (xor (load addr:$dst), i16immSExt8:$src), addr:$dst),
2206 (implicit EFLAGS)]>,
Evan Cheng0ef3a772005-12-13 01:41:36 +00002207 OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00002208 def XOR32mi8 : Ii8<0x83, MRM6m,
Evan Cheng64d80e32007-07-19 01:14:50 +00002209 (outs), (ins i32mem:$dst, i32i8imm :$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002210 "xor{l}\t{$src, $dst|$dst, $src}",
Dan Gohman09a2609e2009-03-03 19:53:46 +00002211 [(store (xor (load addr:$dst), i32immSExt8:$src), addr:$dst),
2212 (implicit EFLAGS)]>;
Sean Callanan7893ec62009-09-10 19:52:26 +00002213
Chris Lattner589ad5d2010-03-25 05:44:01 +00002214 def XOR8i8 : Ii8 <0x34, RawFrm, (outs), (ins i8imm:$src),
2215 "xor{b}\t{$src, %al|%al, $src}", []>;
2216 def XOR16i16 : Ii16<0x35, RawFrm, (outs), (ins i16imm:$src),
2217 "xor{w}\t{$src, %ax|%ax, $src}", []>, OpSize;
2218 def XOR32i32 : Ii32<0x35, RawFrm, (outs), (ins i32imm:$src),
2219 "xor{l}\t{$src, %eax|%eax, $src}", []>;
Eric Christophera938cfb2010-06-19 00:37:40 +00002220} // Constraints = ""
Evan Cheng24f2ea32007-09-14 21:48:26 +00002221} // Defs = [EFLAGS]
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00002222
2223// Shift instructions
Evan Cheng24f2ea32007-09-14 21:48:26 +00002224let Defs = [EFLAGS] in {
Evan Cheng071a2792007-09-11 19:55:27 +00002225let Uses = [CL] in {
Eric Christophera938cfb2010-06-19 00:37:40 +00002226def SHL8rCL : I<0xD2, MRM4r, (outs GR8 :$dst), (ins GR8 :$src1),
Eli Friedmanaace4b12009-06-19 04:48:38 +00002227 "shl{b}\t{%cl, $dst|$dst, CL}",
Eric Christophera938cfb2010-06-19 00:37:40 +00002228 [(set GR8:$dst, (shl GR8:$src1, CL))]>;
2229def SHL16rCL : I<0xD3, MRM4r, (outs GR16:$dst), (ins GR16:$src1),
Eli Friedmanaace4b12009-06-19 04:48:38 +00002230 "shl{w}\t{%cl, $dst|$dst, CL}",
Eric Christophera938cfb2010-06-19 00:37:40 +00002231 [(set GR16:$dst, (shl GR16:$src1, CL))]>, OpSize;
2232def SHL32rCL : I<0xD3, MRM4r, (outs GR32:$dst), (ins GR32:$src1),
Eli Friedmanaace4b12009-06-19 04:48:38 +00002233 "shl{l}\t{%cl, $dst|$dst, CL}",
Eric Christophera938cfb2010-06-19 00:37:40 +00002234 [(set GR32:$dst, (shl GR32:$src1, CL))]>;
Bill Wendlingbd0879d2008-05-29 01:02:09 +00002235} // Uses = [CL]
Chris Lattnercc65bee2005-01-02 02:35:46 +00002236
Evan Cheng64d80e32007-07-19 01:14:50 +00002237def SHL8ri : Ii8<0xC0, MRM4r, (outs GR8 :$dst), (ins GR8 :$src1, i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002238 "shl{b}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00002239 [(set GR8:$dst, (shl GR8:$src1, (i8 imm:$src2)))]>;
Eric Christophera938cfb2010-06-19 00:37:40 +00002240
Chris Lattnercc65bee2005-01-02 02:35:46 +00002241let isConvertibleToThreeAddress = 1 in { // Can transform into LEA.
Evan Cheng64d80e32007-07-19 01:14:50 +00002242def SHL16ri : Ii8<0xC1, MRM4r, (outs GR16:$dst), (ins GR16:$src1, i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002243 "shl{w}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00002244 [(set GR16:$dst, (shl GR16:$src1, (i8 imm:$src2)))]>, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00002245def SHL32ri : Ii8<0xC1, MRM4r, (outs GR32:$dst), (ins GR32:$src1, i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002246 "shl{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00002247 [(set GR32:$dst, (shl GR32:$src1, (i8 imm:$src2)))]>;
Sean Callanan13cf8e92009-09-16 02:28:43 +00002248
2249// NOTE: We don't include patterns for shifts of a register by one, because
2250// 'add reg,reg' is cheaper.
2251
2252def SHL8r1 : I<0xD0, MRM4r, (outs GR8:$dst), (ins GR8:$src1),
2253 "shl{b}\t$dst", []>;
2254def SHL16r1 : I<0xD1, MRM4r, (outs GR16:$dst), (ins GR16:$src1),
2255 "shl{w}\t$dst", []>, OpSize;
2256def SHL32r1 : I<0xD1, MRM4r, (outs GR32:$dst), (ins GR32:$src1),
2257 "shl{l}\t$dst", []>;
2258
Bill Wendlingbd0879d2008-05-29 01:02:09 +00002259} // isConvertibleToThreeAddress = 1
Evan Cheng09c54572006-06-29 00:36:51 +00002260
Eric Christophera938cfb2010-06-19 00:37:40 +00002261let Constraints = "" in {
Evan Cheng071a2792007-09-11 19:55:27 +00002262 let Uses = [CL] in {
Evan Cheng64d80e32007-07-19 01:14:50 +00002263 def SHL8mCL : I<0xD2, MRM4m, (outs), (ins i8mem :$dst),
Eli Friedmanaace4b12009-06-19 04:48:38 +00002264 "shl{b}\t{%cl, $dst|$dst, CL}",
Evan Cheng071a2792007-09-11 19:55:27 +00002265 [(store (shl (loadi8 addr:$dst), CL), addr:$dst)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00002266 def SHL16mCL : I<0xD3, MRM4m, (outs), (ins i16mem:$dst),
Eli Friedmanaace4b12009-06-19 04:48:38 +00002267 "shl{w}\t{%cl, $dst|$dst, CL}",
Evan Cheng071a2792007-09-11 19:55:27 +00002268 [(store (shl (loadi16 addr:$dst), CL), addr:$dst)]>, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00002269 def SHL32mCL : I<0xD3, MRM4m, (outs), (ins i32mem:$dst),
Eli Friedmanaace4b12009-06-19 04:48:38 +00002270 "shl{l}\t{%cl, $dst|$dst, CL}",
Evan Cheng071a2792007-09-11 19:55:27 +00002271 [(store (shl (loadi32 addr:$dst), CL), addr:$dst)]>;
2272 }
Evan Cheng64d80e32007-07-19 01:14:50 +00002273 def SHL8mi : Ii8<0xC0, MRM4m, (outs), (ins i8mem :$dst, i8imm:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002274 "shl{b}\t{$src, $dst|$dst, $src}",
Evan Cheng763b0292005-12-13 02:34:51 +00002275 [(store (shl (loadi8 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00002276 def SHL16mi : Ii8<0xC1, MRM4m, (outs), (ins i16mem:$dst, i8imm:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002277 "shl{w}\t{$src, $dst|$dst, $src}",
Evan Cheng763b0292005-12-13 02:34:51 +00002278 [(store (shl (loadi16 addr:$dst), (i8 imm:$src)), addr:$dst)]>,
2279 OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00002280 def SHL32mi : Ii8<0xC1, MRM4m, (outs), (ins i32mem:$dst, i8imm:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002281 "shl{l}\t{$src, $dst|$dst, $src}",
Evan Cheng763b0292005-12-13 02:34:51 +00002282 [(store (shl (loadi32 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
Evan Cheng09c54572006-06-29 00:36:51 +00002283
2284 // Shift by 1
Evan Cheng64d80e32007-07-19 01:14:50 +00002285 def SHL8m1 : I<0xD0, MRM4m, (outs), (ins i8mem :$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002286 "shl{b}\t$dst",
Evan Cheng09c54572006-06-29 00:36:51 +00002287 [(store (shl (loadi8 addr:$dst), (i8 1)), addr:$dst)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00002288 def SHL16m1 : I<0xD1, MRM4m, (outs), (ins i16mem:$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002289 "shl{w}\t$dst",
Evan Cheng09c54572006-06-29 00:36:51 +00002290 [(store (shl (loadi16 addr:$dst), (i8 1)), addr:$dst)]>,
2291 OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00002292 def SHL32m1 : I<0xD1, MRM4m, (outs), (ins i32mem:$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002293 "shl{l}\t$dst",
Evan Cheng09c54572006-06-29 00:36:51 +00002294 [(store (shl (loadi32 addr:$dst), (i8 1)), addr:$dst)]>;
Eric Christophera938cfb2010-06-19 00:37:40 +00002295} // Constraints = ""
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00002296
Evan Cheng071a2792007-09-11 19:55:27 +00002297let Uses = [CL] in {
Eric Christophera938cfb2010-06-19 00:37:40 +00002298def SHR8rCL : I<0xD2, MRM5r, (outs GR8 :$dst), (ins GR8 :$src1),
Eli Friedmanaace4b12009-06-19 04:48:38 +00002299 "shr{b}\t{%cl, $dst|$dst, CL}",
Eric Christophera938cfb2010-06-19 00:37:40 +00002300 [(set GR8:$dst, (srl GR8:$src1, CL))]>;
2301def SHR16rCL : I<0xD3, MRM5r, (outs GR16:$dst), (ins GR16:$src1),
Eli Friedmanaace4b12009-06-19 04:48:38 +00002302 "shr{w}\t{%cl, $dst|$dst, CL}",
Eric Christophera938cfb2010-06-19 00:37:40 +00002303 [(set GR16:$dst, (srl GR16:$src1, CL))]>, OpSize;
2304def SHR32rCL : I<0xD3, MRM5r, (outs GR32:$dst), (ins GR32:$src1),
Eli Friedmanaace4b12009-06-19 04:48:38 +00002305 "shr{l}\t{%cl, $dst|$dst, CL}",
Eric Christophera938cfb2010-06-19 00:37:40 +00002306 [(set GR32:$dst, (srl GR32:$src1, CL))]>;
Evan Cheng071a2792007-09-11 19:55:27 +00002307}
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00002308
Evan Cheng64d80e32007-07-19 01:14:50 +00002309def SHR8ri : Ii8<0xC0, MRM5r, (outs GR8:$dst), (ins GR8:$src1, i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002310 "shr{b}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00002311 [(set GR8:$dst, (srl GR8:$src1, (i8 imm:$src2)))]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00002312def SHR16ri : Ii8<0xC1, MRM5r, (outs GR16:$dst), (ins GR16:$src1, i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002313 "shr{w}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00002314 [(set GR16:$dst, (srl GR16:$src1, (i8 imm:$src2)))]>, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00002315def SHR32ri : Ii8<0xC1, MRM5r, (outs GR32:$dst), (ins GR32:$src1, i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002316 "shr{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00002317 [(set GR32:$dst, (srl GR32:$src1, (i8 imm:$src2)))]>;
Chris Lattnerf29ed092004-08-11 05:07:25 +00002318
Evan Cheng09c54572006-06-29 00:36:51 +00002319// Shift by 1
Evan Cheng64d80e32007-07-19 01:14:50 +00002320def SHR8r1 : I<0xD0, MRM5r, (outs GR8:$dst), (ins GR8:$src1),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002321 "shr{b}\t$dst",
Evan Cheng09c54572006-06-29 00:36:51 +00002322 [(set GR8:$dst, (srl GR8:$src1, (i8 1)))]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00002323def SHR16r1 : I<0xD1, MRM5r, (outs GR16:$dst), (ins GR16:$src1),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002324 "shr{w}\t$dst",
Evan Cheng09c54572006-06-29 00:36:51 +00002325 [(set GR16:$dst, (srl GR16:$src1, (i8 1)))]>, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00002326def SHR32r1 : I<0xD1, MRM5r, (outs GR32:$dst), (ins GR32:$src1),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002327 "shr{l}\t$dst",
Evan Cheng09c54572006-06-29 00:36:51 +00002328 [(set GR32:$dst, (srl GR32:$src1, (i8 1)))]>;
2329
Eric Christophera938cfb2010-06-19 00:37:40 +00002330let Constraints = "" in {
Evan Cheng071a2792007-09-11 19:55:27 +00002331 let Uses = [CL] in {
Evan Cheng64d80e32007-07-19 01:14:50 +00002332 def SHR8mCL : I<0xD2, MRM5m, (outs), (ins i8mem :$dst),
Eli Friedmanaace4b12009-06-19 04:48:38 +00002333 "shr{b}\t{%cl, $dst|$dst, CL}",
Evan Cheng071a2792007-09-11 19:55:27 +00002334 [(store (srl (loadi8 addr:$dst), CL), addr:$dst)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00002335 def SHR16mCL : I<0xD3, MRM5m, (outs), (ins i16mem:$dst),
Eli Friedmanaace4b12009-06-19 04:48:38 +00002336 "shr{w}\t{%cl, $dst|$dst, CL}",
Evan Cheng85dd8892005-12-13 07:24:22 +00002337 [(store (srl (loadi16 addr:$dst), CL), addr:$dst)]>,
Evan Cheng071a2792007-09-11 19:55:27 +00002338 OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00002339 def SHR32mCL : I<0xD3, MRM5m, (outs), (ins i32mem:$dst),
Eli Friedmanaace4b12009-06-19 04:48:38 +00002340 "shr{l}\t{%cl, $dst|$dst, CL}",
Evan Cheng071a2792007-09-11 19:55:27 +00002341 [(store (srl (loadi32 addr:$dst), CL), addr:$dst)]>;
2342 }
Evan Cheng64d80e32007-07-19 01:14:50 +00002343 def SHR8mi : Ii8<0xC0, MRM5m, (outs), (ins i8mem :$dst, i8imm:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002344 "shr{b}\t{$src, $dst|$dst, $src}",
Evan Cheng85dd8892005-12-13 07:24:22 +00002345 [(store (srl (loadi8 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00002346 def SHR16mi : Ii8<0xC1, MRM5m, (outs), (ins i16mem:$dst, i8imm:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002347 "shr{w}\t{$src, $dst|$dst, $src}",
Evan Cheng85dd8892005-12-13 07:24:22 +00002348 [(store (srl (loadi16 addr:$dst), (i8 imm:$src)), addr:$dst)]>,
2349 OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00002350 def SHR32mi : Ii8<0xC1, MRM5m, (outs), (ins i32mem:$dst, i8imm:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002351 "shr{l}\t{$src, $dst|$dst, $src}",
Evan Cheng85dd8892005-12-13 07:24:22 +00002352 [(store (srl (loadi32 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
Evan Cheng09c54572006-06-29 00:36:51 +00002353
2354 // Shift by 1
Evan Cheng64d80e32007-07-19 01:14:50 +00002355 def SHR8m1 : I<0xD0, MRM5m, (outs), (ins i8mem :$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002356 "shr{b}\t$dst",
Evan Cheng09c54572006-06-29 00:36:51 +00002357 [(store (srl (loadi8 addr:$dst), (i8 1)), addr:$dst)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00002358 def SHR16m1 : I<0xD1, MRM5m, (outs), (ins i16mem:$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002359 "shr{w}\t$dst",
Evan Cheng09c54572006-06-29 00:36:51 +00002360 [(store (srl (loadi16 addr:$dst), (i8 1)), addr:$dst)]>,OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00002361 def SHR32m1 : I<0xD1, MRM5m, (outs), (ins i32mem:$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002362 "shr{l}\t$dst",
Evan Cheng09c54572006-06-29 00:36:51 +00002363 [(store (srl (loadi32 addr:$dst), (i8 1)), addr:$dst)]>;
Eric Christophera938cfb2010-06-19 00:37:40 +00002364} // Constraints = ""
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00002365
Evan Cheng071a2792007-09-11 19:55:27 +00002366let Uses = [CL] in {
Eric Christophera938cfb2010-06-19 00:37:40 +00002367def SAR8rCL : I<0xD2, MRM7r, (outs GR8 :$dst), (ins GR8 :$src1),
Eli Friedmanaace4b12009-06-19 04:48:38 +00002368 "sar{b}\t{%cl, $dst|$dst, CL}",
Eric Christophera938cfb2010-06-19 00:37:40 +00002369 [(set GR8:$dst, (sra GR8:$src1, CL))]>;
2370def SAR16rCL : I<0xD3, MRM7r, (outs GR16:$dst), (ins GR16:$src1),
Eli Friedmanaace4b12009-06-19 04:48:38 +00002371 "sar{w}\t{%cl, $dst|$dst, CL}",
Eric Christophera938cfb2010-06-19 00:37:40 +00002372 [(set GR16:$dst, (sra GR16:$src1, CL))]>, OpSize;
2373def SAR32rCL : I<0xD3, MRM7r, (outs GR32:$dst), (ins GR32:$src1),
Eli Friedmanaace4b12009-06-19 04:48:38 +00002374 "sar{l}\t{%cl, $dst|$dst, CL}",
Eric Christophera938cfb2010-06-19 00:37:40 +00002375 [(set GR32:$dst, (sra GR32:$src1, CL))]>;
Evan Cheng071a2792007-09-11 19:55:27 +00002376}
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00002377
Evan Cheng64d80e32007-07-19 01:14:50 +00002378def SAR8ri : Ii8<0xC0, MRM7r, (outs GR8 :$dst), (ins GR8 :$src1, i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002379 "sar{b}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00002380 [(set GR8:$dst, (sra GR8:$src1, (i8 imm:$src2)))]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00002381def SAR16ri : Ii8<0xC1, MRM7r, (outs GR16:$dst), (ins GR16:$src1, i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002382 "sar{w}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00002383 [(set GR16:$dst, (sra GR16:$src1, (i8 imm:$src2)))]>,
Chris Lattner3d36a9f2005-12-05 02:40:25 +00002384 OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00002385def SAR32ri : Ii8<0xC1, MRM7r, (outs GR32:$dst), (ins GR32:$src1, i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002386 "sar{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00002387 [(set GR32:$dst, (sra GR32:$src1, (i8 imm:$src2)))]>;
Evan Cheng09c54572006-06-29 00:36:51 +00002388
2389// Shift by 1
Evan Cheng64d80e32007-07-19 01:14:50 +00002390def SAR8r1 : I<0xD0, MRM7r, (outs GR8 :$dst), (ins GR8 :$src1),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002391 "sar{b}\t$dst",
Evan Cheng09c54572006-06-29 00:36:51 +00002392 [(set GR8:$dst, (sra GR8:$src1, (i8 1)))]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00002393def SAR16r1 : I<0xD1, MRM7r, (outs GR16:$dst), (ins GR16:$src1),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002394 "sar{w}\t$dst",
Evan Cheng09c54572006-06-29 00:36:51 +00002395 [(set GR16:$dst, (sra GR16:$src1, (i8 1)))]>, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00002396def SAR32r1 : I<0xD1, MRM7r, (outs GR32:$dst), (ins GR32:$src1),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002397 "sar{l}\t$dst",
Evan Cheng09c54572006-06-29 00:36:51 +00002398 [(set GR32:$dst, (sra GR32:$src1, (i8 1)))]>;
2399
Eric Christophera938cfb2010-06-19 00:37:40 +00002400let Constraints = "" in {
Evan Cheng071a2792007-09-11 19:55:27 +00002401 let Uses = [CL] in {
Evan Cheng64d80e32007-07-19 01:14:50 +00002402 def SAR8mCL : I<0xD2, MRM7m, (outs), (ins i8mem :$dst),
Eli Friedmanaace4b12009-06-19 04:48:38 +00002403 "sar{b}\t{%cl, $dst|$dst, CL}",
Evan Cheng071a2792007-09-11 19:55:27 +00002404 [(store (sra (loadi8 addr:$dst), CL), addr:$dst)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00002405 def SAR16mCL : I<0xD3, MRM7m, (outs), (ins i16mem:$dst),
Eli Friedmanaace4b12009-06-19 04:48:38 +00002406 "sar{w}\t{%cl, $dst|$dst, CL}",
Evan Cheng071a2792007-09-11 19:55:27 +00002407 [(store (sra (loadi16 addr:$dst), CL), addr:$dst)]>, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00002408 def SAR32mCL : I<0xD3, MRM7m, (outs), (ins i32mem:$dst),
Eli Friedmanaace4b12009-06-19 04:48:38 +00002409 "sar{l}\t{%cl, $dst|$dst, CL}",
Evan Cheng071a2792007-09-11 19:55:27 +00002410 [(store (sra (loadi32 addr:$dst), CL), addr:$dst)]>;
2411 }
Evan Cheng64d80e32007-07-19 01:14:50 +00002412 def SAR8mi : Ii8<0xC0, MRM7m, (outs), (ins i8mem :$dst, i8imm:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002413 "sar{b}\t{$src, $dst|$dst, $src}",
Evan Cheng85dd8892005-12-13 07:24:22 +00002414 [(store (sra (loadi8 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00002415 def SAR16mi : Ii8<0xC1, MRM7m, (outs), (ins i16mem:$dst, i8imm:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002416 "sar{w}\t{$src, $dst|$dst, $src}",
Evan Cheng85dd8892005-12-13 07:24:22 +00002417 [(store (sra (loadi16 addr:$dst), (i8 imm:$src)), addr:$dst)]>,
2418 OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00002419 def SAR32mi : Ii8<0xC1, MRM7m, (outs), (ins i32mem:$dst, i8imm:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002420 "sar{l}\t{$src, $dst|$dst, $src}",
Evan Cheng85dd8892005-12-13 07:24:22 +00002421 [(store (sra (loadi32 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
Evan Cheng09c54572006-06-29 00:36:51 +00002422
2423 // Shift by 1
Evan Cheng64d80e32007-07-19 01:14:50 +00002424 def SAR8m1 : I<0xD0, MRM7m, (outs), (ins i8mem :$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002425 "sar{b}\t$dst",
Evan Cheng09c54572006-06-29 00:36:51 +00002426 [(store (sra (loadi8 addr:$dst), (i8 1)), addr:$dst)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00002427 def SAR16m1 : I<0xD1, MRM7m, (outs), (ins i16mem:$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002428 "sar{w}\t$dst",
Evan Cheng09c54572006-06-29 00:36:51 +00002429 [(store (sra (loadi16 addr:$dst), (i8 1)), addr:$dst)]>,
2430 OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00002431 def SAR32m1 : I<0xD1, MRM7m, (outs), (ins i32mem:$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002432 "sar{l}\t$dst",
Evan Cheng09c54572006-06-29 00:36:51 +00002433 [(store (sra (loadi32 addr:$dst), (i8 1)), addr:$dst)]>;
Eric Christophera938cfb2010-06-19 00:37:40 +00002434} // Constraints = ""
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00002435
Chris Lattner40ff6332005-01-19 07:50:03 +00002436// Rotate instructions
Sean Callanana2dc2822009-09-18 19:35:23 +00002437
Eric Christophera938cfb2010-06-19 00:37:40 +00002438def RCL8r1 : I<0xD0, MRM2r, (outs GR8:$dst), (ins GR8:$src1),
Sean Callanana2dc2822009-09-18 19:35:23 +00002439 "rcl{b}\t{1, $dst|$dst, 1}", []>;
Sean Callanana2dc2822009-09-18 19:35:23 +00002440let Uses = [CL] in {
Eric Christophera938cfb2010-06-19 00:37:40 +00002441def RCL8rCL : I<0xD2, MRM2r, (outs GR8:$dst), (ins GR8:$src1),
Sean Callanana2dc2822009-09-18 19:35:23 +00002442 "rcl{b}\t{%cl, $dst|$dst, CL}", []>;
Sean Callanana2dc2822009-09-18 19:35:23 +00002443}
Eric Christophera938cfb2010-06-19 00:37:40 +00002444def RCL8ri : Ii8<0xC0, MRM2r, (outs GR8:$dst), (ins GR8:$src1, i8imm:$cnt),
Sean Callanana2dc2822009-09-18 19:35:23 +00002445 "rcl{b}\t{$cnt, $dst|$dst, $cnt}", []>;
Sean Callanana2dc2822009-09-18 19:35:23 +00002446
Eric Christophera938cfb2010-06-19 00:37:40 +00002447def RCL16r1 : I<0xD1, MRM2r, (outs GR16:$dst), (ins GR16:$src1),
Sean Callanana2dc2822009-09-18 19:35:23 +00002448 "rcl{w}\t{1, $dst|$dst, 1}", []>, OpSize;
Sean Callanana2dc2822009-09-18 19:35:23 +00002449let Uses = [CL] in {
Eric Christophera938cfb2010-06-19 00:37:40 +00002450def RCL16rCL : I<0xD3, MRM2r, (outs GR16:$dst), (ins GR16:$src1),
Sean Callanana2dc2822009-09-18 19:35:23 +00002451 "rcl{w}\t{%cl, $dst|$dst, CL}", []>, OpSize;
Sean Callanana2dc2822009-09-18 19:35:23 +00002452}
Eric Christophera938cfb2010-06-19 00:37:40 +00002453def RCL16ri : Ii8<0xC1, MRM2r, (outs GR16:$dst), (ins GR16:$src1, i8imm:$cnt),
Sean Callanana2dc2822009-09-18 19:35:23 +00002454 "rcl{w}\t{$cnt, $dst|$dst, $cnt}", []>, OpSize;
Sean Callanana2dc2822009-09-18 19:35:23 +00002455
Eric Christophera938cfb2010-06-19 00:37:40 +00002456def RCL32r1 : I<0xD1, MRM2r, (outs GR32:$dst), (ins GR32:$src1),
Sean Callanana2dc2822009-09-18 19:35:23 +00002457 "rcl{l}\t{1, $dst|$dst, 1}", []>;
Sean Callanana2dc2822009-09-18 19:35:23 +00002458let Uses = [CL] in {
Eric Christophera938cfb2010-06-19 00:37:40 +00002459def RCL32rCL : I<0xD3, MRM2r, (outs GR32:$dst), (ins GR32:$src1),
Sean Callanana2dc2822009-09-18 19:35:23 +00002460 "rcl{l}\t{%cl, $dst|$dst, CL}", []>;
Sean Callanana2dc2822009-09-18 19:35:23 +00002461}
Eric Christophera938cfb2010-06-19 00:37:40 +00002462def RCL32ri : Ii8<0xC1, MRM2r, (outs GR32:$dst), (ins GR32:$src1, i8imm:$cnt),
Sean Callanana2dc2822009-09-18 19:35:23 +00002463 "rcl{l}\t{$cnt, $dst|$dst, $cnt}", []>;
Sean Callanana2dc2822009-09-18 19:35:23 +00002464
Eric Christophera938cfb2010-06-19 00:37:40 +00002465def RCR8r1 : I<0xD0, MRM3r, (outs GR8:$dst), (ins GR8:$src1),
Sean Callanana2dc2822009-09-18 19:35:23 +00002466 "rcr{b}\t{1, $dst|$dst, 1}", []>;
Sean Callanana2dc2822009-09-18 19:35:23 +00002467let Uses = [CL] in {
Eric Christophera938cfb2010-06-19 00:37:40 +00002468def RCR8rCL : I<0xD2, MRM3r, (outs GR8:$dst), (ins GR8:$src1),
Sean Callanana2dc2822009-09-18 19:35:23 +00002469 "rcr{b}\t{%cl, $dst|$dst, CL}", []>;
Sean Callanana2dc2822009-09-18 19:35:23 +00002470}
Eric Christophera938cfb2010-06-19 00:37:40 +00002471def RCR8ri : Ii8<0xC0, MRM3r, (outs GR8:$dst), (ins GR8:$src1, i8imm:$cnt),
Sean Callanana2dc2822009-09-18 19:35:23 +00002472 "rcr{b}\t{$cnt, $dst|$dst, $cnt}", []>;
Sean Callanana2dc2822009-09-18 19:35:23 +00002473
Eric Christophera938cfb2010-06-19 00:37:40 +00002474def RCR16r1 : I<0xD1, MRM3r, (outs GR16:$dst), (ins GR16:$src1),
Sean Callanana2dc2822009-09-18 19:35:23 +00002475 "rcr{w}\t{1, $dst|$dst, 1}", []>, OpSize;
Sean Callanana2dc2822009-09-18 19:35:23 +00002476let Uses = [CL] in {
Eric Christophera938cfb2010-06-19 00:37:40 +00002477def RCR16rCL : I<0xD3, MRM3r, (outs GR16:$dst), (ins GR16:$src1),
Sean Callanana2dc2822009-09-18 19:35:23 +00002478 "rcr{w}\t{%cl, $dst|$dst, CL}", []>, OpSize;
Sean Callanana2dc2822009-09-18 19:35:23 +00002479}
Eric Christophera938cfb2010-06-19 00:37:40 +00002480def RCR16ri : Ii8<0xC1, MRM3r, (outs GR16:$dst), (ins GR16:$src1, i8imm:$cnt),
Sean Callanana2dc2822009-09-18 19:35:23 +00002481 "rcr{w}\t{$cnt, $dst|$dst, $cnt}", []>, OpSize;
Sean Callanana2dc2822009-09-18 19:35:23 +00002482
Eric Christophera938cfb2010-06-19 00:37:40 +00002483def RCR32r1 : I<0xD1, MRM3r, (outs GR32:$dst), (ins GR32:$src1),
Sean Callanana2dc2822009-09-18 19:35:23 +00002484 "rcr{l}\t{1, $dst|$dst, 1}", []>;
Sean Callanana2dc2822009-09-18 19:35:23 +00002485let Uses = [CL] in {
Eric Christophera938cfb2010-06-19 00:37:40 +00002486def RCR32rCL : I<0xD3, MRM3r, (outs GR32:$dst), (ins GR32:$src1),
Sean Callanana2dc2822009-09-18 19:35:23 +00002487 "rcr{l}\t{%cl, $dst|$dst, CL}", []>;
Sean Callanana2dc2822009-09-18 19:35:23 +00002488}
Eric Christophera938cfb2010-06-19 00:37:40 +00002489def RCR32ri : Ii8<0xC1, MRM3r, (outs GR32:$dst), (ins GR32:$src1, i8imm:$cnt),
Sean Callanana2dc2822009-09-18 19:35:23 +00002490 "rcr{l}\t{$cnt, $dst|$dst, $cnt}", []>;
Daniel Dunbarccfa1db2010-02-12 01:22:03 +00002491
Eric Christophera938cfb2010-06-19 00:37:40 +00002492let Constraints = "" in {
Daniel Dunbarccfa1db2010-02-12 01:22:03 +00002493def RCL8m1 : I<0xD0, MRM2m, (outs), (ins i8mem:$dst),
2494 "rcl{b}\t{1, $dst|$dst, 1}", []>;
2495def RCL8mi : Ii8<0xC0, MRM2m, (outs), (ins i8mem:$dst, i8imm:$cnt),
2496 "rcl{b}\t{$cnt, $dst|$dst, $cnt}", []>;
2497def RCL16m1 : I<0xD1, MRM2m, (outs), (ins i16mem:$dst),
2498 "rcl{w}\t{1, $dst|$dst, 1}", []>, OpSize;
2499def RCL16mi : Ii8<0xC1, MRM2m, (outs), (ins i16mem:$dst, i8imm:$cnt),
2500 "rcl{w}\t{$cnt, $dst|$dst, $cnt}", []>, OpSize;
2501def RCL32m1 : I<0xD1, MRM2m, (outs), (ins i32mem:$dst),
2502 "rcl{l}\t{1, $dst|$dst, 1}", []>;
2503def RCL32mi : Ii8<0xC1, MRM2m, (outs), (ins i32mem:$dst, i8imm:$cnt),
2504 "rcl{l}\t{$cnt, $dst|$dst, $cnt}", []>;
2505def RCR8m1 : I<0xD0, MRM3m, (outs), (ins i8mem:$dst),
2506 "rcr{b}\t{1, $dst|$dst, 1}", []>;
2507def RCR8mi : Ii8<0xC0, MRM3m, (outs), (ins i8mem:$dst, i8imm:$cnt),
2508 "rcr{b}\t{$cnt, $dst|$dst, $cnt}", []>;
2509def RCR16m1 : I<0xD1, MRM3m, (outs), (ins i16mem:$dst),
2510 "rcr{w}\t{1, $dst|$dst, 1}", []>, OpSize;
2511def RCR16mi : Ii8<0xC1, MRM3m, (outs), (ins i16mem:$dst, i8imm:$cnt),
2512 "rcr{w}\t{$cnt, $dst|$dst, $cnt}", []>, OpSize;
2513def RCR32m1 : I<0xD1, MRM3m, (outs), (ins i32mem:$dst),
2514 "rcr{l}\t{1, $dst|$dst, 1}", []>;
2515def RCR32mi : Ii8<0xC1, MRM3m, (outs), (ins i32mem:$dst, i8imm:$cnt),
Sean Callanana2dc2822009-09-18 19:35:23 +00002516 "rcr{l}\t{$cnt, $dst|$dst, $cnt}", []>;
2517
Daniel Dunbarccfa1db2010-02-12 01:22:03 +00002518let Uses = [CL] in {
2519def RCL8mCL : I<0xD2, MRM2m, (outs), (ins i8mem:$dst),
2520 "rcl{b}\t{%cl, $dst|$dst, CL}", []>;
2521def RCL16mCL : I<0xD3, MRM2m, (outs), (ins i16mem:$dst),
2522 "rcl{w}\t{%cl, $dst|$dst, CL}", []>, OpSize;
2523def RCL32mCL : I<0xD3, MRM2m, (outs), (ins i32mem:$dst),
2524 "rcl{l}\t{%cl, $dst|$dst, CL}", []>;
2525def RCR8mCL : I<0xD2, MRM3m, (outs), (ins i8mem:$dst),
2526 "rcr{b}\t{%cl, $dst|$dst, CL}", []>;
2527def RCR16mCL : I<0xD3, MRM3m, (outs), (ins i16mem:$dst),
2528 "rcr{w}\t{%cl, $dst|$dst, CL}", []>, OpSize;
2529def RCR32mCL : I<0xD3, MRM3m, (outs), (ins i32mem:$dst),
2530 "rcr{l}\t{%cl, $dst|$dst, CL}", []>;
2531}
Eric Christophera938cfb2010-06-19 00:37:40 +00002532} // Constraints = ""
Daniel Dunbarccfa1db2010-02-12 01:22:03 +00002533
Chris Lattner40ff6332005-01-19 07:50:03 +00002534// FIXME: provide shorter instructions when imm8 == 1
Evan Cheng071a2792007-09-11 19:55:27 +00002535let Uses = [CL] in {
Eric Christophera938cfb2010-06-19 00:37:40 +00002536def ROL8rCL : I<0xD2, MRM0r, (outs GR8 :$dst), (ins GR8 :$src1),
Eli Friedmanaace4b12009-06-19 04:48:38 +00002537 "rol{b}\t{%cl, $dst|$dst, CL}",
Eric Christophera938cfb2010-06-19 00:37:40 +00002538 [(set GR8:$dst, (rotl GR8:$src1, CL))]>;
2539def ROL16rCL : I<0xD3, MRM0r, (outs GR16:$dst), (ins GR16:$src1),
Eli Friedmanaace4b12009-06-19 04:48:38 +00002540 "rol{w}\t{%cl, $dst|$dst, CL}",
Eric Christophera938cfb2010-06-19 00:37:40 +00002541 [(set GR16:$dst, (rotl GR16:$src1, CL))]>, OpSize;
2542def ROL32rCL : I<0xD3, MRM0r, (outs GR32:$dst), (ins GR32:$src1),
Eli Friedmanaace4b12009-06-19 04:48:38 +00002543 "rol{l}\t{%cl, $dst|$dst, CL}",
Eric Christophera938cfb2010-06-19 00:37:40 +00002544 [(set GR32:$dst, (rotl GR32:$src1, CL))]>;
Evan Cheng071a2792007-09-11 19:55:27 +00002545}
Chris Lattner40ff6332005-01-19 07:50:03 +00002546
Evan Cheng64d80e32007-07-19 01:14:50 +00002547def ROL8ri : Ii8<0xC0, MRM0r, (outs GR8 :$dst), (ins GR8 :$src1, i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002548 "rol{b}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00002549 [(set GR8:$dst, (rotl GR8:$src1, (i8 imm:$src2)))]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00002550def ROL16ri : Ii8<0xC1, MRM0r, (outs GR16:$dst), (ins GR16:$src1, i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002551 "rol{w}\t{$src2, $dst|$dst, $src2}",
Sean Callanan108934c2009-12-18 00:01:26 +00002552 [(set GR16:$dst, (rotl GR16:$src1, (i8 imm:$src2)))]>,
2553 OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00002554def ROL32ri : Ii8<0xC1, MRM0r, (outs GR32:$dst), (ins GR32:$src1, i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002555 "rol{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00002556 [(set GR32:$dst, (rotl GR32:$src1, (i8 imm:$src2)))]>;
Chris Lattner40ff6332005-01-19 07:50:03 +00002557
Evan Cheng09c54572006-06-29 00:36:51 +00002558// Rotate by 1
Evan Cheng64d80e32007-07-19 01:14:50 +00002559def ROL8r1 : I<0xD0, MRM0r, (outs GR8 :$dst), (ins GR8 :$src1),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002560 "rol{b}\t$dst",
Evan Cheng09c54572006-06-29 00:36:51 +00002561 [(set GR8:$dst, (rotl GR8:$src1, (i8 1)))]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00002562def ROL16r1 : I<0xD1, MRM0r, (outs GR16:$dst), (ins GR16:$src1),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002563 "rol{w}\t$dst",
Evan Cheng09c54572006-06-29 00:36:51 +00002564 [(set GR16:$dst, (rotl GR16:$src1, (i8 1)))]>, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00002565def ROL32r1 : I<0xD1, MRM0r, (outs GR32:$dst), (ins GR32:$src1),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002566 "rol{l}\t$dst",
Evan Cheng09c54572006-06-29 00:36:51 +00002567 [(set GR32:$dst, (rotl GR32:$src1, (i8 1)))]>;
2568
Eric Christophera938cfb2010-06-19 00:37:40 +00002569let Constraints = "" in {
Evan Cheng071a2792007-09-11 19:55:27 +00002570 let Uses = [CL] in {
Evan Cheng64d80e32007-07-19 01:14:50 +00002571 def ROL8mCL : I<0xD2, MRM0m, (outs), (ins i8mem :$dst),
Eli Friedmanaace4b12009-06-19 04:48:38 +00002572 "rol{b}\t{%cl, $dst|$dst, CL}",
Evan Cheng071a2792007-09-11 19:55:27 +00002573 [(store (rotl (loadi8 addr:$dst), CL), addr:$dst)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00002574 def ROL16mCL : I<0xD3, MRM0m, (outs), (ins i16mem:$dst),
Eli Friedmanaace4b12009-06-19 04:48:38 +00002575 "rol{w}\t{%cl, $dst|$dst, CL}",
Evan Cheng071a2792007-09-11 19:55:27 +00002576 [(store (rotl (loadi16 addr:$dst), CL), addr:$dst)]>, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00002577 def ROL32mCL : I<0xD3, MRM0m, (outs), (ins i32mem:$dst),
Eli Friedmanaace4b12009-06-19 04:48:38 +00002578 "rol{l}\t{%cl, $dst|$dst, CL}",
Evan Cheng071a2792007-09-11 19:55:27 +00002579 [(store (rotl (loadi32 addr:$dst), CL), addr:$dst)]>;
2580 }
Evan Cheng64d80e32007-07-19 01:14:50 +00002581 def ROL8mi : Ii8<0xC0, MRM0m, (outs), (ins i8mem :$dst, i8imm:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002582 "rol{b}\t{$src, $dst|$dst, $src}",
Evan Chengeb422a72006-01-11 23:20:05 +00002583 [(store (rotl (loadi8 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00002584 def ROL16mi : Ii8<0xC1, MRM0m, (outs), (ins i16mem:$dst, i8imm:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002585 "rol{w}\t{$src, $dst|$dst, $src}",
Evan Chengeb422a72006-01-11 23:20:05 +00002586 [(store (rotl (loadi16 addr:$dst), (i8 imm:$src)), addr:$dst)]>,
2587 OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00002588 def ROL32mi : Ii8<0xC1, MRM0m, (outs), (ins i32mem:$dst, i8imm:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002589 "rol{l}\t{$src, $dst|$dst, $src}",
Evan Chengeb422a72006-01-11 23:20:05 +00002590 [(store (rotl (loadi32 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
Evan Cheng09c54572006-06-29 00:36:51 +00002591
2592 // Rotate by 1
Evan Cheng64d80e32007-07-19 01:14:50 +00002593 def ROL8m1 : I<0xD0, MRM0m, (outs), (ins i8mem :$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002594 "rol{b}\t$dst",
Evan Cheng09c54572006-06-29 00:36:51 +00002595 [(store (rotl (loadi8 addr:$dst), (i8 1)), addr:$dst)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00002596 def ROL16m1 : I<0xD1, MRM0m, (outs), (ins i16mem:$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002597 "rol{w}\t$dst",
Evan Cheng09c54572006-06-29 00:36:51 +00002598 [(store (rotl (loadi16 addr:$dst), (i8 1)), addr:$dst)]>,
2599 OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00002600 def ROL32m1 : I<0xD1, MRM0m, (outs), (ins i32mem:$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002601 "rol{l}\t$dst",
Evan Cheng09c54572006-06-29 00:36:51 +00002602 [(store (rotl (loadi32 addr:$dst), (i8 1)), addr:$dst)]>;
Eric Christophera938cfb2010-06-19 00:37:40 +00002603} // Constraints = ""
Chris Lattner40ff6332005-01-19 07:50:03 +00002604
Evan Cheng071a2792007-09-11 19:55:27 +00002605let Uses = [CL] in {
Eric Christophera938cfb2010-06-19 00:37:40 +00002606def ROR8rCL : I<0xD2, MRM1r, (outs GR8 :$dst), (ins GR8 :$src1),
Eli Friedmanaace4b12009-06-19 04:48:38 +00002607 "ror{b}\t{%cl, $dst|$dst, CL}",
Eric Christophera938cfb2010-06-19 00:37:40 +00002608 [(set GR8:$dst, (rotr GR8:$src1, CL))]>;
2609def ROR16rCL : I<0xD3, MRM1r, (outs GR16:$dst), (ins GR16:$src1),
Eli Friedmanaace4b12009-06-19 04:48:38 +00002610 "ror{w}\t{%cl, $dst|$dst, CL}",
Eric Christophera938cfb2010-06-19 00:37:40 +00002611 [(set GR16:$dst, (rotr GR16:$src1, CL))]>, OpSize;
2612def ROR32rCL : I<0xD3, MRM1r, (outs GR32:$dst), (ins GR32:$src1),
Eli Friedmanaace4b12009-06-19 04:48:38 +00002613 "ror{l}\t{%cl, $dst|$dst, CL}",
Eric Christophera938cfb2010-06-19 00:37:40 +00002614 [(set GR32:$dst, (rotr GR32:$src1, CL))]>;
Evan Cheng071a2792007-09-11 19:55:27 +00002615}
Chris Lattner40ff6332005-01-19 07:50:03 +00002616
Evan Cheng64d80e32007-07-19 01:14:50 +00002617def ROR8ri : Ii8<0xC0, MRM1r, (outs GR8 :$dst), (ins GR8 :$src1, i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002618 "ror{b}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00002619 [(set GR8:$dst, (rotr GR8:$src1, (i8 imm:$src2)))]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00002620def ROR16ri : Ii8<0xC1, MRM1r, (outs GR16:$dst), (ins GR16:$src1, i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002621 "ror{w}\t{$src2, $dst|$dst, $src2}",
Sean Callanan108934c2009-12-18 00:01:26 +00002622 [(set GR16:$dst, (rotr GR16:$src1, (i8 imm:$src2)))]>,
2623 OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00002624def ROR32ri : Ii8<0xC1, MRM1r, (outs GR32:$dst), (ins GR32:$src1, i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002625 "ror{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00002626 [(set GR32:$dst, (rotr GR32:$src1, (i8 imm:$src2)))]>;
Evan Cheng09c54572006-06-29 00:36:51 +00002627
2628// Rotate by 1
Evan Cheng64d80e32007-07-19 01:14:50 +00002629def ROR8r1 : I<0xD0, MRM1r, (outs GR8 :$dst), (ins GR8 :$src1),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002630 "ror{b}\t$dst",
Evan Cheng09c54572006-06-29 00:36:51 +00002631 [(set GR8:$dst, (rotr GR8:$src1, (i8 1)))]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00002632def ROR16r1 : I<0xD1, MRM1r, (outs GR16:$dst), (ins GR16:$src1),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002633 "ror{w}\t$dst",
Evan Cheng09c54572006-06-29 00:36:51 +00002634 [(set GR16:$dst, (rotr GR16:$src1, (i8 1)))]>, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00002635def ROR32r1 : I<0xD1, MRM1r, (outs GR32:$dst), (ins GR32:$src1),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002636 "ror{l}\t$dst",
Evan Cheng09c54572006-06-29 00:36:51 +00002637 [(set GR32:$dst, (rotr GR32:$src1, (i8 1)))]>;
2638
Eric Christophera938cfb2010-06-19 00:37:40 +00002639let Constraints = "" in {
Evan Cheng071a2792007-09-11 19:55:27 +00002640 let Uses = [CL] in {
Evan Cheng64d80e32007-07-19 01:14:50 +00002641 def ROR8mCL : I<0xD2, MRM1m, (outs), (ins i8mem :$dst),
Eli Friedmanaace4b12009-06-19 04:48:38 +00002642 "ror{b}\t{%cl, $dst|$dst, CL}",
Evan Cheng071a2792007-09-11 19:55:27 +00002643 [(store (rotr (loadi8 addr:$dst), CL), addr:$dst)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00002644 def ROR16mCL : I<0xD3, MRM1m, (outs), (ins i16mem:$dst),
Eli Friedmanaace4b12009-06-19 04:48:38 +00002645 "ror{w}\t{%cl, $dst|$dst, CL}",
Evan Cheng071a2792007-09-11 19:55:27 +00002646 [(store (rotr (loadi16 addr:$dst), CL), addr:$dst)]>, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00002647 def ROR32mCL : I<0xD3, MRM1m, (outs), (ins i32mem:$dst),
Eli Friedmanaace4b12009-06-19 04:48:38 +00002648 "ror{l}\t{%cl, $dst|$dst, CL}",
Evan Cheng071a2792007-09-11 19:55:27 +00002649 [(store (rotr (loadi32 addr:$dst), CL), addr:$dst)]>;
2650 }
Evan Cheng64d80e32007-07-19 01:14:50 +00002651 def ROR8mi : Ii8<0xC0, MRM1m, (outs), (ins i8mem :$dst, i8imm:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002652 "ror{b}\t{$src, $dst|$dst, $src}",
Evan Chengeb422a72006-01-11 23:20:05 +00002653 [(store (rotr (loadi8 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00002654 def ROR16mi : Ii8<0xC1, MRM1m, (outs), (ins i16mem:$dst, i8imm:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002655 "ror{w}\t{$src, $dst|$dst, $src}",
Evan Chengeb422a72006-01-11 23:20:05 +00002656 [(store (rotr (loadi16 addr:$dst), (i8 imm:$src)), addr:$dst)]>,
2657 OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00002658 def ROR32mi : Ii8<0xC1, MRM1m, (outs), (ins i32mem:$dst, i8imm:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002659 "ror{l}\t{$src, $dst|$dst, $src}",
Evan Chengeb422a72006-01-11 23:20:05 +00002660 [(store (rotr (loadi32 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
Evan Cheng09c54572006-06-29 00:36:51 +00002661
2662 // Rotate by 1
Evan Cheng64d80e32007-07-19 01:14:50 +00002663 def ROR8m1 : I<0xD0, MRM1m, (outs), (ins i8mem :$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002664 "ror{b}\t$dst",
Evan Cheng09c54572006-06-29 00:36:51 +00002665 [(store (rotr (loadi8 addr:$dst), (i8 1)), addr:$dst)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00002666 def ROR16m1 : I<0xD1, MRM1m, (outs), (ins i16mem:$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002667 "ror{w}\t$dst",
Evan Cheng09c54572006-06-29 00:36:51 +00002668 [(store (rotr (loadi16 addr:$dst), (i8 1)), addr:$dst)]>,
2669 OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00002670 def ROR32m1 : I<0xD1, MRM1m, (outs), (ins i32mem:$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002671 "ror{l}\t$dst",
Evan Cheng09c54572006-06-29 00:36:51 +00002672 [(store (rotr (loadi32 addr:$dst), (i8 1)), addr:$dst)]>;
Eric Christophera938cfb2010-06-19 00:37:40 +00002673} // Constraints = ""
Chris Lattner40ff6332005-01-19 07:50:03 +00002674
2675
2676// Double shift instructions (generalizations of rotate)
Evan Cheng071a2792007-09-11 19:55:27 +00002677let Uses = [CL] in {
Sean Callanan108934c2009-12-18 00:01:26 +00002678def SHLD32rrCL : I<0xA5, MRMDestReg, (outs GR32:$dst),
2679 (ins GR32:$src1, GR32:$src2),
Eli Friedmanaace4b12009-06-19 04:48:38 +00002680 "shld{l}\t{%cl, $src2, $dst|$dst, $src2, CL}",
Evan Cheng071a2792007-09-11 19:55:27 +00002681 [(set GR32:$dst, (X86shld GR32:$src1, GR32:$src2, CL))]>, TB;
Sean Callanan108934c2009-12-18 00:01:26 +00002682def SHRD32rrCL : I<0xAD, MRMDestReg, (outs GR32:$dst),
2683 (ins GR32:$src1, GR32:$src2),
Eli Friedmanaace4b12009-06-19 04:48:38 +00002684 "shrd{l}\t{%cl, $src2, $dst|$dst, $src2, CL}",
Evan Cheng071a2792007-09-11 19:55:27 +00002685 [(set GR32:$dst, (X86shrd GR32:$src1, GR32:$src2, CL))]>, TB;
Sean Callanan108934c2009-12-18 00:01:26 +00002686def SHLD16rrCL : I<0xA5, MRMDestReg, (outs GR16:$dst),
2687 (ins GR16:$src1, GR16:$src2),
Eli Friedmanaace4b12009-06-19 04:48:38 +00002688 "shld{w}\t{%cl, $src2, $dst|$dst, $src2, CL}",
Evan Cheng069287d2006-05-16 07:21:53 +00002689 [(set GR16:$dst, (X86shld GR16:$src1, GR16:$src2, CL))]>,
Evan Cheng071a2792007-09-11 19:55:27 +00002690 TB, OpSize;
Sean Callanan108934c2009-12-18 00:01:26 +00002691def SHRD16rrCL : I<0xAD, MRMDestReg, (outs GR16:$dst),
2692 (ins GR16:$src1, GR16:$src2),
Eli Friedmanaace4b12009-06-19 04:48:38 +00002693 "shrd{w}\t{%cl, $src2, $dst|$dst, $src2, CL}",
Evan Cheng069287d2006-05-16 07:21:53 +00002694 [(set GR16:$dst, (X86shrd GR16:$src1, GR16:$src2, CL))]>,
Evan Cheng071a2792007-09-11 19:55:27 +00002695 TB, OpSize;
2696}
Chris Lattner41e431b2005-01-19 07:11:01 +00002697
2698let isCommutable = 1 in { // These instructions commute to each other.
Chris Lattner3a173df2004-10-03 20:35:00 +00002699def SHLD32rri8 : Ii8<0xA4, MRMDestReg,
Sean Callanan108934c2009-12-18 00:01:26 +00002700 (outs GR32:$dst),
2701 (ins GR32:$src1, GR32:$src2, i8imm:$src3),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002702 "shld{l}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Evan Cheng069287d2006-05-16 07:21:53 +00002703 [(set GR32:$dst, (X86shld GR32:$src1, GR32:$src2,
Evan Chenge3413162006-01-09 18:33:28 +00002704 (i8 imm:$src3)))]>,
2705 TB;
Chris Lattner3a173df2004-10-03 20:35:00 +00002706def SHRD32rri8 : Ii8<0xAC, MRMDestReg,
Sean Callanan108934c2009-12-18 00:01:26 +00002707 (outs GR32:$dst),
2708 (ins GR32:$src1, GR32:$src2, i8imm:$src3),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002709 "shrd{l}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Evan Cheng069287d2006-05-16 07:21:53 +00002710 [(set GR32:$dst, (X86shrd GR32:$src1, GR32:$src2,
Evan Chenge3413162006-01-09 18:33:28 +00002711 (i8 imm:$src3)))]>,
2712 TB;
Chris Lattner0df53d22005-01-19 07:31:24 +00002713def SHLD16rri8 : Ii8<0xA4, MRMDestReg,
Sean Callanan108934c2009-12-18 00:01:26 +00002714 (outs GR16:$dst),
2715 (ins GR16:$src1, GR16:$src2, i8imm:$src3),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002716 "shld{w}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Evan Cheng069287d2006-05-16 07:21:53 +00002717 [(set GR16:$dst, (X86shld GR16:$src1, GR16:$src2,
Evan Chenge3413162006-01-09 18:33:28 +00002718 (i8 imm:$src3)))]>,
Chris Lattner0df53d22005-01-19 07:31:24 +00002719 TB, OpSize;
2720def SHRD16rri8 : Ii8<0xAC, MRMDestReg,
Sean Callanan108934c2009-12-18 00:01:26 +00002721 (outs GR16:$dst),
2722 (ins GR16:$src1, GR16:$src2, i8imm:$src3),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002723 "shrd{w}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Evan Cheng069287d2006-05-16 07:21:53 +00002724 [(set GR16:$dst, (X86shrd GR16:$src1, GR16:$src2,
Evan Chenge3413162006-01-09 18:33:28 +00002725 (i8 imm:$src3)))]>,
Chris Lattner0df53d22005-01-19 07:31:24 +00002726 TB, OpSize;
Chris Lattner41e431b2005-01-19 07:11:01 +00002727}
Chris Lattner0e967d42004-08-01 08:13:11 +00002728
Eric Christophera938cfb2010-06-19 00:37:40 +00002729let Constraints = "" in {
Evan Cheng071a2792007-09-11 19:55:27 +00002730 let Uses = [CL] in {
Evan Cheng64d80e32007-07-19 01:14:50 +00002731 def SHLD32mrCL : I<0xA5, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
Eli Friedmanaace4b12009-06-19 04:48:38 +00002732 "shld{l}\t{%cl, $src2, $dst|$dst, $src2, CL}",
Evan Cheng069287d2006-05-16 07:21:53 +00002733 [(store (X86shld (loadi32 addr:$dst), GR32:$src2, CL),
Evan Cheng071a2792007-09-11 19:55:27 +00002734 addr:$dst)]>, TB;
Evan Cheng64d80e32007-07-19 01:14:50 +00002735 def SHRD32mrCL : I<0xAD, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
Eli Friedmanaace4b12009-06-19 04:48:38 +00002736 "shrd{l}\t{%cl, $src2, $dst|$dst, $src2, CL}",
Evan Cheng069287d2006-05-16 07:21:53 +00002737 [(store (X86shrd (loadi32 addr:$dst), GR32:$src2, CL),
Evan Cheng071a2792007-09-11 19:55:27 +00002738 addr:$dst)]>, TB;
2739 }
Chris Lattner3a173df2004-10-03 20:35:00 +00002740 def SHLD32mri8 : Ii8<0xA4, MRMDestMem,
Evan Cheng64d80e32007-07-19 01:14:50 +00002741 (outs), (ins i32mem:$dst, GR32:$src2, i8imm:$src3),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002742 "shld{l}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Evan Cheng069287d2006-05-16 07:21:53 +00002743 [(store (X86shld (loadi32 addr:$dst), GR32:$src2,
Evan Chenge3413162006-01-09 18:33:28 +00002744 (i8 imm:$src3)), addr:$dst)]>,
Chris Lattnerf124d5e2005-11-18 01:04:42 +00002745 TB;
Chris Lattner3a173df2004-10-03 20:35:00 +00002746 def SHRD32mri8 : Ii8<0xAC, MRMDestMem,
Evan Cheng64d80e32007-07-19 01:14:50 +00002747 (outs), (ins i32mem:$dst, GR32:$src2, i8imm:$src3),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002748 "shrd{l}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Evan Cheng069287d2006-05-16 07:21:53 +00002749 [(store (X86shrd (loadi32 addr:$dst), GR32:$src2,
Evan Chenge3413162006-01-09 18:33:28 +00002750 (i8 imm:$src3)), addr:$dst)]>,
Chris Lattnerf124d5e2005-11-18 01:04:42 +00002751 TB;
Chris Lattner0df53d22005-01-19 07:31:24 +00002752
Evan Cheng071a2792007-09-11 19:55:27 +00002753 let Uses = [CL] in {
Evan Cheng64d80e32007-07-19 01:14:50 +00002754 def SHLD16mrCL : I<0xA5, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
Eli Friedmanaace4b12009-06-19 04:48:38 +00002755 "shld{w}\t{%cl, $src2, $dst|$dst, $src2, CL}",
Evan Cheng069287d2006-05-16 07:21:53 +00002756 [(store (X86shld (loadi16 addr:$dst), GR16:$src2, CL),
Evan Cheng071a2792007-09-11 19:55:27 +00002757 addr:$dst)]>, TB, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00002758 def SHRD16mrCL : I<0xAD, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
Eli Friedmanaace4b12009-06-19 04:48:38 +00002759 "shrd{w}\t{%cl, $src2, $dst|$dst, $src2, CL}",
Evan Cheng069287d2006-05-16 07:21:53 +00002760 [(store (X86shrd (loadi16 addr:$dst), GR16:$src2, CL),
Evan Cheng071a2792007-09-11 19:55:27 +00002761 addr:$dst)]>, TB, OpSize;
2762 }
Chris Lattner0df53d22005-01-19 07:31:24 +00002763 def SHLD16mri8 : Ii8<0xA4, MRMDestMem,
Evan Cheng64d80e32007-07-19 01:14:50 +00002764 (outs), (ins i16mem:$dst, GR16:$src2, i8imm:$src3),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002765 "shld{w}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Evan Cheng069287d2006-05-16 07:21:53 +00002766 [(store (X86shld (loadi16 addr:$dst), GR16:$src2,
Evan Chenge3413162006-01-09 18:33:28 +00002767 (i8 imm:$src3)), addr:$dst)]>,
Chris Lattner0df53d22005-01-19 07:31:24 +00002768 TB, OpSize;
2769 def SHRD16mri8 : Ii8<0xAC, MRMDestMem,
Evan Cheng64d80e32007-07-19 01:14:50 +00002770 (outs), (ins i16mem:$dst, GR16:$src2, i8imm:$src3),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002771 "shrd{w}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Evan Cheng069287d2006-05-16 07:21:53 +00002772 [(store (X86shrd (loadi16 addr:$dst), GR16:$src2,
Evan Chenge3413162006-01-09 18:33:28 +00002773 (i8 imm:$src3)), addr:$dst)]>,
Chris Lattner0df53d22005-01-19 07:31:24 +00002774 TB, OpSize;
Eric Christophera938cfb2010-06-19 00:37:40 +00002775} // Constraints = ""
Evan Cheng24f2ea32007-09-14 21:48:26 +00002776} // Defs = [EFLAGS]
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00002777
2778
Chris Lattnercc65bee2005-01-02 02:35:46 +00002779// Arithmetic.
Evan Cheng24f2ea32007-09-14 21:48:26 +00002780let Defs = [EFLAGS] in {
Chris Lattnercc65bee2005-01-02 02:35:46 +00002781let isCommutable = 1 in { // X = ADD Y, Z --> X = ADD Z, Y
Bill Wendlingab55ebd2008-12-12 00:56:36 +00002782// Register-Register Addition
2783def ADD8rr : I<0x00, MRMDestReg, (outs GR8 :$dst),
2784 (ins GR8 :$src1, GR8 :$src2),
2785 "add{b}\t{$src2, $dst|$dst, $src2}",
Chris Lattnerec856802010-03-27 00:45:04 +00002786 [(set GR8:$dst, EFLAGS, (X86add_flag GR8:$src1, GR8:$src2))]>;
Bill Wendlingab55ebd2008-12-12 00:56:36 +00002787
Chris Lattnercc65bee2005-01-02 02:35:46 +00002788let isConvertibleToThreeAddress = 1 in { // Can transform into LEA.
Bill Wendlingab55ebd2008-12-12 00:56:36 +00002789// Register-Register Addition
Evan Cheng071a2792007-09-11 19:55:27 +00002790def ADD16rr : I<0x01, MRMDestReg, (outs GR16:$dst),
2791 (ins GR16:$src1, GR16:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002792 "add{w}\t{$src2, $dst|$dst, $src2}",
Chris Lattnerec856802010-03-27 00:45:04 +00002793 [(set GR16:$dst, EFLAGS, (X86add_flag GR16:$src1,
2794 GR16:$src2))]>, OpSize;
Evan Cheng071a2792007-09-11 19:55:27 +00002795def ADD32rr : I<0x01, MRMDestReg, (outs GR32:$dst),
2796 (ins GR32:$src1, GR32:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002797 "add{l}\t{$src2, $dst|$dst, $src2}",
Chris Lattnerec856802010-03-27 00:45:04 +00002798 [(set GR32:$dst, EFLAGS, (X86add_flag GR32:$src1,
2799 GR32:$src2))]>;
Chris Lattnercc65bee2005-01-02 02:35:46 +00002800} // end isConvertibleToThreeAddress
2801} // end isCommutable
Bill Wendlingab55ebd2008-12-12 00:56:36 +00002802
Daniel Dunbarf291be32010-03-09 22:50:46 +00002803// These are alternate spellings for use by the disassembler, we mark them as
2804// code gen only to ensure they aren't matched by the assembler.
2805let isCodeGenOnly = 1 in {
2806 def ADD8rr_alt: I<0x02, MRMSrcReg, (outs GR8:$dst), (ins GR8:$src1, GR8:$src2),
2807 "add{b}\t{$src2, $dst|$dst, $src2}", []>;
2808 def ADD16rr_alt: I<0x03, MRMSrcReg,(outs GR16:$dst),(ins GR16:$src1, GR16:$src2),
2809 "add{w}\t{$src2, $dst|$dst, $src2}", []>, OpSize;
Evan Cheng18ac4102010-04-05 22:21:09 +00002810 def ADD32rr_alt: I<0x03, MRMSrcReg,(outs GR32:$dst),(ins GR32:$src1, GR32:$src2),
Daniel Dunbarf291be32010-03-09 22:50:46 +00002811 "add{l}\t{$src2, $dst|$dst, $src2}", []>;
2812}
2813
Bill Wendlingab55ebd2008-12-12 00:56:36 +00002814// Register-Memory Addition
Evan Cheng071a2792007-09-11 19:55:27 +00002815def ADD8rm : I<0x02, MRMSrcMem, (outs GR8 :$dst),
2816 (ins GR8 :$src1, i8mem :$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002817 "add{b}\t{$src2, $dst|$dst, $src2}",
Chris Lattnerec856802010-03-27 00:45:04 +00002818 [(set GR8:$dst, EFLAGS, (X86add_flag GR8:$src1,
2819 (load addr:$src2)))]>;
Evan Cheng071a2792007-09-11 19:55:27 +00002820def ADD16rm : I<0x03, MRMSrcMem, (outs GR16:$dst),
2821 (ins GR16:$src1, i16mem:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002822 "add{w}\t{$src2, $dst|$dst, $src2}",
Chris Lattnerec856802010-03-27 00:45:04 +00002823 [(set GR16:$dst, EFLAGS, (X86add_flag GR16:$src1,
2824 (load addr:$src2)))]>, OpSize;
Evan Cheng071a2792007-09-11 19:55:27 +00002825def ADD32rm : I<0x03, MRMSrcMem, (outs GR32:$dst),
2826 (ins GR32:$src1, i32mem:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002827 "add{l}\t{$src2, $dst|$dst, $src2}",
Chris Lattnerec856802010-03-27 00:45:04 +00002828 [(set GR32:$dst, EFLAGS, (X86add_flag GR32:$src1,
2829 (load addr:$src2)))]>;
Sean Callanan37be5902009-09-15 20:53:57 +00002830
Bill Wendlingab55ebd2008-12-12 00:56:36 +00002831// Register-Integer Addition
2832def ADD8ri : Ii8<0x80, MRM0r, (outs GR8:$dst), (ins GR8:$src1, i8imm:$src2),
2833 "add{b}\t{$src2, $dst|$dst, $src2}",
Chris Lattnerec856802010-03-27 00:45:04 +00002834 [(set GR8:$dst, EFLAGS,
2835 (X86add_flag GR8:$src1, imm:$src2))]>;
Bill Wendlingab55ebd2008-12-12 00:56:36 +00002836
Chris Lattnercc65bee2005-01-02 02:35:46 +00002837let isConvertibleToThreeAddress = 1 in { // Can transform into LEA.
Bill Wendlingab55ebd2008-12-12 00:56:36 +00002838// Register-Integer Addition
Evan Cheng071a2792007-09-11 19:55:27 +00002839def ADD16ri : Ii16<0x81, MRM0r, (outs GR16:$dst),
2840 (ins GR16:$src1, i16imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002841 "add{w}\t{$src2, $dst|$dst, $src2}",
Chris Lattnerec856802010-03-27 00:45:04 +00002842 [(set GR16:$dst, EFLAGS,
2843 (X86add_flag GR16:$src1, imm:$src2))]>, OpSize;
Evan Cheng071a2792007-09-11 19:55:27 +00002844def ADD32ri : Ii32<0x81, MRM0r, (outs GR32:$dst),
2845 (ins GR32:$src1, i32imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002846 "add{l}\t{$src2, $dst|$dst, $src2}",
Chris Lattnerec856802010-03-27 00:45:04 +00002847 [(set GR32:$dst, EFLAGS,
2848 (X86add_flag GR32:$src1, imm:$src2))]>;
Evan Cheng071a2792007-09-11 19:55:27 +00002849def ADD16ri8 : Ii8<0x83, MRM0r, (outs GR16:$dst),
2850 (ins GR16:$src1, i16i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002851 "add{w}\t{$src2, $dst|$dst, $src2}",
Chris Lattnerec856802010-03-27 00:45:04 +00002852 [(set GR16:$dst, EFLAGS,
2853 (X86add_flag GR16:$src1, i16immSExt8:$src2))]>, OpSize;
Evan Cheng071a2792007-09-11 19:55:27 +00002854def ADD32ri8 : Ii8<0x83, MRM0r, (outs GR32:$dst),
2855 (ins GR32:$src1, i32i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002856 "add{l}\t{$src2, $dst|$dst, $src2}",
Chris Lattnerec856802010-03-27 00:45:04 +00002857 [(set GR32:$dst, EFLAGS,
2858 (X86add_flag GR32:$src1, i32immSExt8:$src2))]>;
Evan Cheng09e3c802006-05-19 18:40:54 +00002859}
Chris Lattner57a02302004-08-11 04:31:00 +00002860
Eric Christophera938cfb2010-06-19 00:37:40 +00002861let Constraints = "" in {
Bill Wendlingab55ebd2008-12-12 00:56:36 +00002862 // Memory-Register Addition
Bill Wendlingd350e022008-12-12 21:15:41 +00002863 def ADD8mr : I<0x00, MRMDestMem, (outs), (ins i8mem:$dst, GR8:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002864 "add{b}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingd350e022008-12-12 21:15:41 +00002865 [(store (add (load addr:$dst), GR8:$src2), addr:$dst),
2866 (implicit EFLAGS)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00002867 def ADD16mr : I<0x01, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002868 "add{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingd350e022008-12-12 21:15:41 +00002869 [(store (add (load addr:$dst), GR16:$src2), addr:$dst),
2870 (implicit EFLAGS)]>, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00002871 def ADD32mr : I<0x01, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002872 "add{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingd350e022008-12-12 21:15:41 +00002873 [(store (add (load addr:$dst), GR32:$src2), addr:$dst),
2874 (implicit EFLAGS)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00002875 def ADD8mi : Ii8<0x80, MRM0m, (outs), (ins i8mem :$dst, i8imm :$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002876 "add{b}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingd350e022008-12-12 21:15:41 +00002877 [(store (add (loadi8 addr:$dst), imm:$src2), addr:$dst),
2878 (implicit EFLAGS)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00002879 def ADD16mi : Ii16<0x81, MRM0m, (outs), (ins i16mem:$dst, i16imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002880 "add{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingd350e022008-12-12 21:15:41 +00002881 [(store (add (loadi16 addr:$dst), imm:$src2), addr:$dst),
2882 (implicit EFLAGS)]>, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00002883 def ADD32mi : Ii32<0x81, MRM0m, (outs), (ins i32mem:$dst, i32imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002884 "add{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingd350e022008-12-12 21:15:41 +00002885 [(store (add (loadi32 addr:$dst), imm:$src2), addr:$dst),
2886 (implicit EFLAGS)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00002887 def ADD16mi8 : Ii8<0x83, MRM0m, (outs), (ins i16mem:$dst, i16i8imm :$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002888 "add{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingd350e022008-12-12 21:15:41 +00002889 [(store (add (load addr:$dst), i16immSExt8:$src2),
2890 addr:$dst),
2891 (implicit EFLAGS)]>, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00002892 def ADD32mi8 : Ii8<0x83, MRM0m, (outs), (ins i32mem:$dst, i32i8imm :$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002893 "add{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingab55ebd2008-12-12 00:56:36 +00002894 [(store (add (load addr:$dst), i32immSExt8:$src2),
Bill Wendlingd350e022008-12-12 21:15:41 +00002895 addr:$dst),
2896 (implicit EFLAGS)]>;
Sean Callananb08ae6b2009-08-11 21:26:06 +00002897
2898 // addition to rAX
2899 def ADD8i8 : Ii8<0x04, RawFrm, (outs), (ins i8imm:$src),
Sean Callanana09caa52009-09-02 00:55:49 +00002900 "add{b}\t{$src, %al|%al, $src}", []>;
Sean Callananb08ae6b2009-08-11 21:26:06 +00002901 def ADD16i16 : Ii16<0x05, RawFrm, (outs), (ins i16imm:$src),
Sean Callanana09caa52009-09-02 00:55:49 +00002902 "add{w}\t{$src, %ax|%ax, $src}", []>, OpSize;
Sean Callananb08ae6b2009-08-11 21:26:06 +00002903 def ADD32i32 : Ii32<0x05, RawFrm, (outs), (ins i32imm:$src),
Sean Callanana09caa52009-09-02 00:55:49 +00002904 "add{l}\t{$src, %eax|%eax, $src}", []>;
Eric Christophera938cfb2010-06-19 00:37:40 +00002905} // Constraints = ""
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00002906
Evan Cheng3154cb62007-10-05 17:59:57 +00002907let Uses = [EFLAGS] in {
Chris Lattner10197ff2005-01-03 01:27:59 +00002908let isCommutable = 1 in { // X = ADC Y, Z --> X = ADC Z, Y
Dale Johannesen874ae252009-06-02 03:12:52 +00002909def ADC8rr : I<0x10, MRMDestReg, (outs GR8:$dst), (ins GR8:$src1, GR8:$src2),
Dale Johannesenca11dae2009-05-18 17:44:15 +00002910 "adc{b}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen874ae252009-06-02 03:12:52 +00002911 [(set GR8:$dst, (adde GR8:$src1, GR8:$src2))]>;
Dale Johannesenca11dae2009-05-18 17:44:15 +00002912def ADC16rr : I<0x11, MRMDestReg, (outs GR16:$dst),
2913 (ins GR16:$src1, GR16:$src2),
2914 "adc{w}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen874ae252009-06-02 03:12:52 +00002915 [(set GR16:$dst, (adde GR16:$src1, GR16:$src2))]>, OpSize;
Dale Johannesenca11dae2009-05-18 17:44:15 +00002916def ADC32rr : I<0x11, MRMDestReg, (outs GR32:$dst),
2917 (ins GR32:$src1, GR32:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002918 "adc{l}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen874ae252009-06-02 03:12:52 +00002919 [(set GR32:$dst, (adde GR32:$src1, GR32:$src2))]>;
Chris Lattner10197ff2005-01-03 01:27:59 +00002920}
Sean Callanan108934c2009-12-18 00:01:26 +00002921
Daniel Dunbardcbab9c2010-05-26 22:21:28 +00002922let isCodeGenOnly = 1 in {
Sean Callanan108934c2009-12-18 00:01:26 +00002923def ADC8rr_REV : I<0x12, MRMSrcReg, (outs GR8:$dst), (ins GR8:$src1, GR8:$src2),
2924 "adc{b}\t{$src2, $dst|$dst, $src2}", []>;
2925def ADC16rr_REV : I<0x13, MRMSrcReg, (outs GR16:$dst),
2926 (ins GR16:$src1, GR16:$src2),
2927 "adc{w}\t{$src2, $dst|$dst, $src2}", []>, OpSize;
2928def ADC32rr_REV : I<0x13, MRMSrcReg, (outs GR32:$dst),
2929 (ins GR32:$src1, GR32:$src2),
2930 "adc{l}\t{$src2, $dst|$dst, $src2}", []>;
Daniel Dunbardcbab9c2010-05-26 22:21:28 +00002931}
Sean Callanan108934c2009-12-18 00:01:26 +00002932
Dale Johannesenca11dae2009-05-18 17:44:15 +00002933def ADC8rm : I<0x12, MRMSrcMem , (outs GR8:$dst),
2934 (ins GR8:$src1, i8mem:$src2),
2935 "adc{b}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen874ae252009-06-02 03:12:52 +00002936 [(set GR8:$dst, (adde GR8:$src1, (load addr:$src2)))]>;
Dale Johannesenca11dae2009-05-18 17:44:15 +00002937def ADC16rm : I<0x13, MRMSrcMem , (outs GR16:$dst),
2938 (ins GR16:$src1, i16mem:$src2),
2939 "adc{w}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen874ae252009-06-02 03:12:52 +00002940 [(set GR16:$dst, (adde GR16:$src1, (load addr:$src2)))]>,
Dale Johannesen94c9cd12009-05-18 21:41:59 +00002941 OpSize;
Dale Johannesenca11dae2009-05-18 17:44:15 +00002942def ADC32rm : I<0x13, MRMSrcMem , (outs GR32:$dst),
2943 (ins GR32:$src1, i32mem:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002944 "adc{l}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen874ae252009-06-02 03:12:52 +00002945 [(set GR32:$dst, (adde GR32:$src1, (load addr:$src2)))]>;
2946def ADC8ri : Ii8<0x80, MRM2r, (outs GR8:$dst), (ins GR8:$src1, i8imm:$src2),
Dale Johannesenca11dae2009-05-18 17:44:15 +00002947 "adc{b}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen874ae252009-06-02 03:12:52 +00002948 [(set GR8:$dst, (adde GR8:$src1, imm:$src2))]>;
Dale Johannesenca11dae2009-05-18 17:44:15 +00002949def ADC16ri : Ii16<0x81, MRM2r, (outs GR16:$dst),
2950 (ins GR16:$src1, i16imm:$src2),
2951 "adc{w}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen874ae252009-06-02 03:12:52 +00002952 [(set GR16:$dst, (adde GR16:$src1, imm:$src2))]>, OpSize;
Dale Johannesenca11dae2009-05-18 17:44:15 +00002953def ADC16ri8 : Ii8<0x83, MRM2r, (outs GR16:$dst),
2954 (ins GR16:$src1, i16i8imm:$src2),
2955 "adc{w}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen874ae252009-06-02 03:12:52 +00002956 [(set GR16:$dst, (adde GR16:$src1, i16immSExt8:$src2))]>,
2957 OpSize;
Dale Johannesenca11dae2009-05-18 17:44:15 +00002958def ADC32ri : Ii32<0x81, MRM2r, (outs GR32:$dst),
2959 (ins GR32:$src1, i32imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002960 "adc{l}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen874ae252009-06-02 03:12:52 +00002961 [(set GR32:$dst, (adde GR32:$src1, imm:$src2))]>;
Dale Johannesenca11dae2009-05-18 17:44:15 +00002962def ADC32ri8 : Ii8<0x83, MRM2r, (outs GR32:$dst),
2963 (ins GR32:$src1, i32i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002964 "adc{l}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen874ae252009-06-02 03:12:52 +00002965 [(set GR32:$dst, (adde GR32:$src1, i32immSExt8:$src2))]>;
Chris Lattner57a02302004-08-11 04:31:00 +00002966
Eric Christophera938cfb2010-06-19 00:37:40 +00002967let Constraints = "" in {
Dale Johannesen874ae252009-06-02 03:12:52 +00002968 def ADC8mr : I<0x10, MRMDestMem, (outs), (ins i8mem:$dst, GR8:$src2),
Dale Johannesenca11dae2009-05-18 17:44:15 +00002969 "adc{b}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen874ae252009-06-02 03:12:52 +00002970 [(store (adde (load addr:$dst), GR8:$src2), addr:$dst)]>;
2971 def ADC16mr : I<0x11, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
Dale Johannesenca11dae2009-05-18 17:44:15 +00002972 "adc{w}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen874ae252009-06-02 03:12:52 +00002973 [(store (adde (load addr:$dst), GR16:$src2), addr:$dst)]>,
2974 OpSize;
2975 def ADC32mr : I<0x11, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002976 "adc{l}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen874ae252009-06-02 03:12:52 +00002977 [(store (adde (load addr:$dst), GR32:$src2), addr:$dst)]>;
2978 def ADC8mi : Ii8<0x80, MRM2m, (outs), (ins i8mem:$dst, i8imm:$src2),
Dale Johannesenca11dae2009-05-18 17:44:15 +00002979 "adc{b}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen874ae252009-06-02 03:12:52 +00002980 [(store (adde (loadi8 addr:$dst), imm:$src2), addr:$dst)]>;
2981 def ADC16mi : Ii16<0x81, MRM2m, (outs), (ins i16mem:$dst, i16imm:$src2),
Dale Johannesenca11dae2009-05-18 17:44:15 +00002982 "adc{w}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen874ae252009-06-02 03:12:52 +00002983 [(store (adde (loadi16 addr:$dst), imm:$src2), addr:$dst)]>,
2984 OpSize;
2985 def ADC16mi8 : Ii8<0x83, MRM2m, (outs), (ins i16mem:$dst, i16i8imm :$src2),
Dale Johannesenca11dae2009-05-18 17:44:15 +00002986 "adc{w}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen874ae252009-06-02 03:12:52 +00002987 [(store (adde (load addr:$dst), i16immSExt8:$src2), addr:$dst)]>,
2988 OpSize;
2989 def ADC32mi : Ii32<0x81, MRM2m, (outs), (ins i32mem:$dst, i32imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002990 "adc{l}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen874ae252009-06-02 03:12:52 +00002991 [(store (adde (loadi32 addr:$dst), imm:$src2), addr:$dst)]>;
2992 def ADC32mi8 : Ii8<0x83, MRM2m, (outs), (ins i32mem:$dst, i32i8imm :$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002993 "adc{l}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen874ae252009-06-02 03:12:52 +00002994 [(store (adde (load addr:$dst), i32immSExt8:$src2), addr:$dst)]>;
Sean Callanand00025a2009-09-11 19:01:56 +00002995
2996 def ADC8i8 : Ii8<0x14, RawFrm, (outs), (ins i8imm:$src),
2997 "adc{b}\t{$src, %al|%al, $src}", []>;
2998 def ADC16i16 : Ii16<0x15, RawFrm, (outs), (ins i16imm:$src),
2999 "adc{w}\t{$src, %ax|%ax, $src}", []>, OpSize;
3000 def ADC32i32 : Ii32<0x15, RawFrm, (outs), (ins i32imm:$src),
3001 "adc{l}\t{$src, %eax|%eax, $src}", []>;
Eric Christophera938cfb2010-06-19 00:37:40 +00003002} // Constraints = ""
Evan Cheng3154cb62007-10-05 17:59:57 +00003003} // Uses = [EFLAGS]
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00003004
Bill Wendlingab55ebd2008-12-12 00:56:36 +00003005// Register-Register Subtraction
3006def SUB8rr : I<0x28, MRMDestReg, (outs GR8:$dst), (ins GR8:$src1, GR8:$src2),
3007 "sub{b}\t{$src2, $dst|$dst, $src2}",
Chris Lattnerec856802010-03-27 00:45:04 +00003008 [(set GR8:$dst, EFLAGS,
3009 (X86sub_flag GR8:$src1, GR8:$src2))]>;
Bill Wendlingab55ebd2008-12-12 00:56:36 +00003010def SUB16rr : I<0x29, MRMDestReg, (outs GR16:$dst), (ins GR16:$src1,GR16:$src2),
3011 "sub{w}\t{$src2, $dst|$dst, $src2}",
Chris Lattnerec856802010-03-27 00:45:04 +00003012 [(set GR16:$dst, EFLAGS,
3013 (X86sub_flag GR16:$src1, GR16:$src2))]>, OpSize;
Bill Wendlingab55ebd2008-12-12 00:56:36 +00003014def SUB32rr : I<0x29, MRMDestReg, (outs GR32:$dst), (ins GR32:$src1,GR32:$src2),
3015 "sub{l}\t{$src2, $dst|$dst, $src2}",
Chris Lattnerec856802010-03-27 00:45:04 +00003016 [(set GR32:$dst, EFLAGS,
3017 (X86sub_flag GR32:$src1, GR32:$src2))]>;
Bill Wendlingab55ebd2008-12-12 00:56:36 +00003018
Daniel Dunbardcbab9c2010-05-26 22:21:28 +00003019let isCodeGenOnly = 1 in {
Sean Callanan108934c2009-12-18 00:01:26 +00003020def SUB8rr_REV : I<0x2A, MRMSrcReg, (outs GR8:$dst), (ins GR8:$src1, GR8:$src2),
3021 "sub{b}\t{$src2, $dst|$dst, $src2}", []>;
3022def SUB16rr_REV : I<0x2B, MRMSrcReg, (outs GR16:$dst),
3023 (ins GR16:$src1, GR16:$src2),
3024 "sub{w}\t{$src2, $dst|$dst, $src2}", []>, OpSize;
3025def SUB32rr_REV : I<0x2B, MRMSrcReg, (outs GR32:$dst),
3026 (ins GR32:$src1, GR32:$src2),
3027 "sub{l}\t{$src2, $dst|$dst, $src2}", []>;
Daniel Dunbardcbab9c2010-05-26 22:21:28 +00003028}
Sean Callanan108934c2009-12-18 00:01:26 +00003029
Bill Wendlingab55ebd2008-12-12 00:56:36 +00003030// Register-Memory Subtraction
3031def SUB8rm : I<0x2A, MRMSrcMem, (outs GR8 :$dst),
3032 (ins GR8 :$src1, i8mem :$src2),
3033 "sub{b}\t{$src2, $dst|$dst, $src2}",
Chris Lattnerec856802010-03-27 00:45:04 +00003034 [(set GR8:$dst, EFLAGS,
3035 (X86sub_flag GR8:$src1, (load addr:$src2)))]>;
Bill Wendlingab55ebd2008-12-12 00:56:36 +00003036def SUB16rm : I<0x2B, MRMSrcMem, (outs GR16:$dst),
3037 (ins GR16:$src1, i16mem:$src2),
3038 "sub{w}\t{$src2, $dst|$dst, $src2}",
Chris Lattnerec856802010-03-27 00:45:04 +00003039 [(set GR16:$dst, EFLAGS,
3040 (X86sub_flag GR16:$src1, (load addr:$src2)))]>, OpSize;
Bill Wendlingab55ebd2008-12-12 00:56:36 +00003041def SUB32rm : I<0x2B, MRMSrcMem, (outs GR32:$dst),
3042 (ins GR32:$src1, i32mem:$src2),
3043 "sub{l}\t{$src2, $dst|$dst, $src2}",
Chris Lattnerec856802010-03-27 00:45:04 +00003044 [(set GR32:$dst, EFLAGS,
3045 (X86sub_flag GR32:$src1, (load addr:$src2)))]>;
Bill Wendlingab55ebd2008-12-12 00:56:36 +00003046
3047// Register-Integer Subtraction
3048def SUB8ri : Ii8 <0x80, MRM5r, (outs GR8:$dst),
3049 (ins GR8:$src1, i8imm:$src2),
3050 "sub{b}\t{$src2, $dst|$dst, $src2}",
Chris Lattnerec856802010-03-27 00:45:04 +00003051 [(set GR8:$dst, EFLAGS,
3052 (X86sub_flag GR8:$src1, imm:$src2))]>;
Bill Wendlingab55ebd2008-12-12 00:56:36 +00003053def SUB16ri : Ii16<0x81, MRM5r, (outs GR16:$dst),
3054 (ins GR16:$src1, i16imm:$src2),
3055 "sub{w}\t{$src2, $dst|$dst, $src2}",
Chris Lattnerec856802010-03-27 00:45:04 +00003056 [(set GR16:$dst, EFLAGS,
3057 (X86sub_flag GR16:$src1, imm:$src2))]>, OpSize;
Bill Wendlingab55ebd2008-12-12 00:56:36 +00003058def SUB32ri : Ii32<0x81, MRM5r, (outs GR32:$dst),
3059 (ins GR32:$src1, i32imm:$src2),
3060 "sub{l}\t{$src2, $dst|$dst, $src2}",
Chris Lattnerec856802010-03-27 00:45:04 +00003061 [(set GR32:$dst, EFLAGS,
3062 (X86sub_flag GR32:$src1, imm:$src2))]>;
Bill Wendlingab55ebd2008-12-12 00:56:36 +00003063def SUB16ri8 : Ii8<0x83, MRM5r, (outs GR16:$dst),
3064 (ins GR16:$src1, i16i8imm:$src2),
3065 "sub{w}\t{$src2, $dst|$dst, $src2}",
Chris Lattnerec856802010-03-27 00:45:04 +00003066 [(set GR16:$dst, EFLAGS,
3067 (X86sub_flag GR16:$src1, i16immSExt8:$src2))]>, OpSize;
Bill Wendlingab55ebd2008-12-12 00:56:36 +00003068def SUB32ri8 : Ii8<0x83, MRM5r, (outs GR32:$dst),
3069 (ins GR32:$src1, i32i8imm:$src2),
3070 "sub{l}\t{$src2, $dst|$dst, $src2}",
Chris Lattnerec856802010-03-27 00:45:04 +00003071 [(set GR32:$dst, EFLAGS,
3072 (X86sub_flag GR32:$src1, i32immSExt8:$src2))]>;
Bill Wendlingab55ebd2008-12-12 00:56:36 +00003073
Eric Christophera938cfb2010-06-19 00:37:40 +00003074let Constraints = "" in {
Bill Wendlingab55ebd2008-12-12 00:56:36 +00003075 // Memory-Register Subtraction
Evan Cheng64d80e32007-07-19 01:14:50 +00003076 def SUB8mr : I<0x28, MRMDestMem, (outs), (ins i8mem :$dst, GR8 :$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003077 "sub{b}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingd350e022008-12-12 21:15:41 +00003078 [(store (sub (load addr:$dst), GR8:$src2), addr:$dst),
3079 (implicit EFLAGS)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00003080 def SUB16mr : I<0x29, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003081 "sub{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingd350e022008-12-12 21:15:41 +00003082 [(store (sub (load addr:$dst), GR16:$src2), addr:$dst),
3083 (implicit EFLAGS)]>, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00003084 def SUB32mr : I<0x29, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003085 "sub{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingd350e022008-12-12 21:15:41 +00003086 [(store (sub (load addr:$dst), GR32:$src2), addr:$dst),
3087 (implicit EFLAGS)]>;
Bill Wendlingab55ebd2008-12-12 00:56:36 +00003088
3089 // Memory-Integer Subtraction
Evan Cheng64d80e32007-07-19 01:14:50 +00003090 def SUB8mi : Ii8<0x80, MRM5m, (outs), (ins i8mem :$dst, i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003091 "sub{b}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingd350e022008-12-12 21:15:41 +00003092 [(store (sub (loadi8 addr:$dst), imm:$src2), addr:$dst),
3093 (implicit EFLAGS)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00003094 def SUB16mi : Ii16<0x81, MRM5m, (outs), (ins i16mem:$dst, i16imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003095 "sub{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingd350e022008-12-12 21:15:41 +00003096 [(store (sub (loadi16 addr:$dst), imm:$src2),addr:$dst),
3097 (implicit EFLAGS)]>, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00003098 def SUB32mi : Ii32<0x81, MRM5m, (outs), (ins i32mem:$dst, i32imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003099 "sub{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingd350e022008-12-12 21:15:41 +00003100 [(store (sub (loadi32 addr:$dst), imm:$src2),addr:$dst),
3101 (implicit EFLAGS)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00003102 def SUB16mi8 : Ii8<0x83, MRM5m, (outs), (ins i16mem:$dst, i16i8imm :$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003103 "sub{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingab55ebd2008-12-12 00:56:36 +00003104 [(store (sub (load addr:$dst), i16immSExt8:$src2),
Bill Wendlingd350e022008-12-12 21:15:41 +00003105 addr:$dst),
3106 (implicit EFLAGS)]>, OpSize;
Bill Wendlingab55ebd2008-12-12 00:56:36 +00003107 def SUB32mi8 : Ii8<0x83, MRM5m, (outs), (ins i32mem:$dst, i32i8imm :$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003108 "sub{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingab55ebd2008-12-12 00:56:36 +00003109 [(store (sub (load addr:$dst), i32immSExt8:$src2),
Bill Wendlingd350e022008-12-12 21:15:41 +00003110 addr:$dst),
3111 (implicit EFLAGS)]>;
Sean Callanand00025a2009-09-11 19:01:56 +00003112
3113 def SUB8i8 : Ii8<0x2C, RawFrm, (outs), (ins i8imm:$src),
3114 "sub{b}\t{$src, %al|%al, $src}", []>;
3115 def SUB16i16 : Ii16<0x2D, RawFrm, (outs), (ins i16imm:$src),
3116 "sub{w}\t{$src, %ax|%ax, $src}", []>, OpSize;
3117 def SUB32i32 : Ii32<0x2D, RawFrm, (outs), (ins i32imm:$src),
3118 "sub{l}\t{$src, %eax|%eax, $src}", []>;
Eric Christophera938cfb2010-06-19 00:37:40 +00003119} // Constraints = ""
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00003120
Evan Cheng3154cb62007-10-05 17:59:57 +00003121let Uses = [EFLAGS] in {
Dale Johannesenca11dae2009-05-18 17:44:15 +00003122def SBB8rr : I<0x18, MRMDestReg, (outs GR8:$dst),
3123 (ins GR8:$src1, GR8:$src2),
3124 "sbb{b}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen874ae252009-06-02 03:12:52 +00003125 [(set GR8:$dst, (sube GR8:$src1, GR8:$src2))]>;
Dale Johannesenca11dae2009-05-18 17:44:15 +00003126def SBB16rr : I<0x19, MRMDestReg, (outs GR16:$dst),
3127 (ins GR16:$src1, GR16:$src2),
3128 "sbb{w}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen874ae252009-06-02 03:12:52 +00003129 [(set GR16:$dst, (sube GR16:$src1, GR16:$src2))]>, OpSize;
Dale Johannesenca11dae2009-05-18 17:44:15 +00003130def SBB32rr : I<0x19, MRMDestReg, (outs GR32:$dst),
3131 (ins GR32:$src1, GR32:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003132 "sbb{l}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen874ae252009-06-02 03:12:52 +00003133 [(set GR32:$dst, (sube GR32:$src1, GR32:$src2))]>;
Chris Lattnerd93d3b02004-10-06 04:01:02 +00003134
Eric Christophera938cfb2010-06-19 00:37:40 +00003135let Constraints = "" in {
Dale Johannesenca11dae2009-05-18 17:44:15 +00003136 def SBB8mr : I<0x18, MRMDestMem, (outs), (ins i8mem:$dst, GR8:$src2),
3137 "sbb{b}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen874ae252009-06-02 03:12:52 +00003138 [(store (sube (load addr:$dst), GR8:$src2), addr:$dst)]>;
Dale Johannesenca11dae2009-05-18 17:44:15 +00003139 def SBB16mr : I<0x19, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
3140 "sbb{w}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen874ae252009-06-02 03:12:52 +00003141 [(store (sube (load addr:$dst), GR16:$src2), addr:$dst)]>,
Dale Johannesen94c9cd12009-05-18 21:41:59 +00003142 OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00003143 def SBB32mr : I<0x19, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003144 "sbb{l}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen874ae252009-06-02 03:12:52 +00003145 [(store (sube (load addr:$dst), GR32:$src2), addr:$dst)]>;
Chris Lattner8f60e4d2010-02-05 22:56:11 +00003146 def SBB8mi : Ii8<0x80, MRM3m, (outs), (ins i8mem:$dst, i8imm:$src2),
3147 "sbb{b}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen874ae252009-06-02 03:12:52 +00003148 [(store (sube (loadi8 addr:$dst), imm:$src2), addr:$dst)]>;
Dale Johannesenca11dae2009-05-18 17:44:15 +00003149 def SBB16mi : Ii16<0x81, MRM3m, (outs), (ins i16mem:$dst, i16imm:$src2),
3150 "sbb{w}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen874ae252009-06-02 03:12:52 +00003151 [(store (sube (loadi16 addr:$dst), imm:$src2), addr:$dst)]>,
Dale Johannesen94c9cd12009-05-18 21:41:59 +00003152 OpSize;
Dale Johannesenca11dae2009-05-18 17:44:15 +00003153 def SBB16mi8 : Ii8<0x83, MRM3m, (outs), (ins i16mem:$dst, i16i8imm :$src2),
3154 "sbb{w}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen874ae252009-06-02 03:12:52 +00003155 [(store (sube (load addr:$dst), i16immSExt8:$src2), addr:$dst)]>,
Dale Johannesen94c9cd12009-05-18 21:41:59 +00003156 OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00003157 def SBB32mi : Ii32<0x81, MRM3m, (outs), (ins i32mem:$dst, i32imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003158 "sbb{l}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen874ae252009-06-02 03:12:52 +00003159 [(store (sube (loadi32 addr:$dst), imm:$src2), addr:$dst)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00003160 def SBB32mi8 : Ii8<0x83, MRM3m, (outs), (ins i32mem:$dst, i32i8imm :$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003161 "sbb{l}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen874ae252009-06-02 03:12:52 +00003162 [(store (sube (load addr:$dst), i32immSExt8:$src2), addr:$dst)]>;
Sean Callanand00025a2009-09-11 19:01:56 +00003163
3164 def SBB8i8 : Ii8<0x1C, RawFrm, (outs), (ins i8imm:$src),
3165 "sbb{b}\t{$src, %al|%al, $src}", []>;
3166 def SBB16i16 : Ii16<0x1D, RawFrm, (outs), (ins i16imm:$src),
3167 "sbb{w}\t{$src, %ax|%ax, $src}", []>, OpSize;
3168 def SBB32i32 : Ii32<0x1D, RawFrm, (outs), (ins i32imm:$src),
3169 "sbb{l}\t{$src, %eax|%eax, $src}", []>;
Eric Christophera938cfb2010-06-19 00:37:40 +00003170} // Constraints = ""
Sean Callanan108934c2009-12-18 00:01:26 +00003171
Daniel Dunbardcbab9c2010-05-26 22:21:28 +00003172let isCodeGenOnly = 1 in {
Sean Callanan108934c2009-12-18 00:01:26 +00003173def SBB8rr_REV : I<0x1A, MRMSrcReg, (outs GR8:$dst), (ins GR8:$src1, GR8:$src2),
3174 "sbb{b}\t{$src2, $dst|$dst, $src2}", []>;
3175def SBB16rr_REV : I<0x1B, MRMSrcReg, (outs GR16:$dst),
3176 (ins GR16:$src1, GR16:$src2),
3177 "sbb{w}\t{$src2, $dst|$dst, $src2}", []>, OpSize;
3178def SBB32rr_REV : I<0x1B, MRMSrcReg, (outs GR32:$dst),
3179 (ins GR32:$src1, GR32:$src2),
3180 "sbb{l}\t{$src2, $dst|$dst, $src2}", []>;
Daniel Dunbardcbab9c2010-05-26 22:21:28 +00003181}
Sean Callanan108934c2009-12-18 00:01:26 +00003182
Dale Johannesenca11dae2009-05-18 17:44:15 +00003183def SBB8rm : I<0x1A, MRMSrcMem, (outs GR8:$dst), (ins GR8:$src1, i8mem:$src2),
3184 "sbb{b}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen874ae252009-06-02 03:12:52 +00003185 [(set GR8:$dst, (sube GR8:$src1, (load addr:$src2)))]>;
Dale Johannesenca11dae2009-05-18 17:44:15 +00003186def SBB16rm : I<0x1B, MRMSrcMem, (outs GR16:$dst),
3187 (ins GR16:$src1, i16mem:$src2),
3188 "sbb{w}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen874ae252009-06-02 03:12:52 +00003189 [(set GR16:$dst, (sube GR16:$src1, (load addr:$src2)))]>,
Dale Johannesen94c9cd12009-05-18 21:41:59 +00003190 OpSize;
Dale Johannesenca11dae2009-05-18 17:44:15 +00003191def SBB32rm : I<0x1B, MRMSrcMem, (outs GR32:$dst),
3192 (ins GR32:$src1, i32mem:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003193 "sbb{l}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen874ae252009-06-02 03:12:52 +00003194 [(set GR32:$dst, (sube GR32:$src1, (load addr:$src2)))]>;
Dale Johannesenca11dae2009-05-18 17:44:15 +00003195def SBB8ri : Ii8<0x80, MRM3r, (outs GR8:$dst), (ins GR8:$src1, i8imm:$src2),
3196 "sbb{b}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen874ae252009-06-02 03:12:52 +00003197 [(set GR8:$dst, (sube GR8:$src1, imm:$src2))]>;
Dale Johannesenca11dae2009-05-18 17:44:15 +00003198def SBB16ri : Ii16<0x81, MRM3r, (outs GR16:$dst),
3199 (ins GR16:$src1, i16imm:$src2),
3200 "sbb{w}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen874ae252009-06-02 03:12:52 +00003201 [(set GR16:$dst, (sube GR16:$src1, imm:$src2))]>, OpSize;
Dale Johannesenca11dae2009-05-18 17:44:15 +00003202def SBB16ri8 : Ii8<0x83, MRM3r, (outs GR16:$dst),
3203 (ins GR16:$src1, i16i8imm:$src2),
3204 "sbb{w}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen874ae252009-06-02 03:12:52 +00003205 [(set GR16:$dst, (sube GR16:$src1, i16immSExt8:$src2))]>,
3206 OpSize;
Dale Johannesenca11dae2009-05-18 17:44:15 +00003207def SBB32ri : Ii32<0x81, MRM3r, (outs GR32:$dst),
3208 (ins GR32:$src1, i32imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003209 "sbb{l}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen874ae252009-06-02 03:12:52 +00003210 [(set GR32:$dst, (sube GR32:$src1, imm:$src2))]>;
Dale Johannesenca11dae2009-05-18 17:44:15 +00003211def SBB32ri8 : Ii8<0x83, MRM3r, (outs GR32:$dst),
3212 (ins GR32:$src1, i32i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003213 "sbb{l}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen874ae252009-06-02 03:12:52 +00003214 [(set GR32:$dst, (sube GR32:$src1, i32immSExt8:$src2))]>;
Evan Cheng3154cb62007-10-05 17:59:57 +00003215} // Uses = [EFLAGS]
Evan Cheng24f2ea32007-09-14 21:48:26 +00003216} // Defs = [EFLAGS]
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00003217
Evan Cheng24f2ea32007-09-14 21:48:26 +00003218let Defs = [EFLAGS] in {
Chris Lattner10197ff2005-01-03 01:27:59 +00003219let isCommutable = 1 in { // X = IMUL Y, Z --> X = IMUL Z, Y
Bill Wendlingd350e022008-12-12 21:15:41 +00003220// Register-Register Signed Integer Multiply
Bill Wendlingab55ebd2008-12-12 00:56:36 +00003221def IMUL16rr : I<0xAF, MRMSrcReg, (outs GR16:$dst), (ins GR16:$src1,GR16:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003222 "imul{w}\t{$src2, $dst|$dst, $src2}",
Chris Lattnerec856802010-03-27 00:45:04 +00003223 [(set GR16:$dst, EFLAGS,
3224 (X86smul_flag GR16:$src1, GR16:$src2))]>, TB, OpSize;
Bill Wendlingab55ebd2008-12-12 00:56:36 +00003225def IMUL32rr : I<0xAF, MRMSrcReg, (outs GR32:$dst), (ins GR32:$src1,GR32:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003226 "imul{l}\t{$src2, $dst|$dst, $src2}",
Chris Lattnerec856802010-03-27 00:45:04 +00003227 [(set GR32:$dst, EFLAGS,
3228 (X86smul_flag GR32:$src1, GR32:$src2))]>, TB;
Chris Lattner10197ff2005-01-03 01:27:59 +00003229}
Bill Wendlingab55ebd2008-12-12 00:56:36 +00003230
Bill Wendlingd350e022008-12-12 21:15:41 +00003231// Register-Memory Signed Integer Multiply
Bill Wendlingab55ebd2008-12-12 00:56:36 +00003232def IMUL16rm : I<0xAF, MRMSrcMem, (outs GR16:$dst),
3233 (ins GR16:$src1, i16mem:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003234 "imul{w}\t{$src2, $dst|$dst, $src2}",
Chris Lattnerec856802010-03-27 00:45:04 +00003235 [(set GR16:$dst, EFLAGS,
3236 (X86smul_flag GR16:$src1, (load addr:$src2)))]>,
3237 TB, OpSize;
Sean Callanan108934c2009-12-18 00:01:26 +00003238def IMUL32rm : I<0xAF, MRMSrcMem, (outs GR32:$dst),
3239 (ins GR32:$src1, i32mem:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003240 "imul{l}\t{$src2, $dst|$dst, $src2}",
Chris Lattnerec856802010-03-27 00:45:04 +00003241 [(set GR32:$dst, EFLAGS,
3242 (X86smul_flag GR32:$src1, (load addr:$src2)))]>, TB;
Evan Cheng24f2ea32007-09-14 21:48:26 +00003243} // Defs = [EFLAGS]
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00003244} // end Two Address instructions
3245
Chris Lattnerf5d3a832004-08-11 05:31:07 +00003246// Suprisingly enough, these are not two address instructions!
Evan Cheng24f2ea32007-09-14 21:48:26 +00003247let Defs = [EFLAGS] in {
Bill Wendlingd350e022008-12-12 21:15:41 +00003248// Register-Integer Signed Integer Multiply
Evan Cheng069287d2006-05-16 07:21:53 +00003249def IMUL16rri : Ii16<0x69, MRMSrcReg, // GR16 = GR16*I16
Evan Cheng64d80e32007-07-19 01:14:50 +00003250 (outs GR16:$dst), (ins GR16:$src1, i16imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003251 "imul{w}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Chris Lattnerec856802010-03-27 00:45:04 +00003252 [(set GR16:$dst, EFLAGS,
3253 (X86smul_flag GR16:$src1, imm:$src2))]>, OpSize;
Evan Cheng069287d2006-05-16 07:21:53 +00003254def IMUL32rri : Ii32<0x69, MRMSrcReg, // GR32 = GR32*I32
Evan Cheng64d80e32007-07-19 01:14:50 +00003255 (outs GR32:$dst), (ins GR32:$src1, i32imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003256 "imul{l}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Chris Lattnerec856802010-03-27 00:45:04 +00003257 [(set GR32:$dst, EFLAGS,
3258 (X86smul_flag GR32:$src1, imm:$src2))]>;
Evan Cheng069287d2006-05-16 07:21:53 +00003259def IMUL16rri8 : Ii8<0x6B, MRMSrcReg, // GR16 = GR16*I8
Evan Cheng64d80e32007-07-19 01:14:50 +00003260 (outs GR16:$dst), (ins GR16:$src1, i16i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003261 "imul{w}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Chris Lattnerec856802010-03-27 00:45:04 +00003262 [(set GR16:$dst, EFLAGS,
3263 (X86smul_flag GR16:$src1, i16immSExt8:$src2))]>,
3264 OpSize;
Evan Cheng069287d2006-05-16 07:21:53 +00003265def IMUL32rri8 : Ii8<0x6B, MRMSrcReg, // GR32 = GR32*I8
Evan Cheng64d80e32007-07-19 01:14:50 +00003266 (outs GR32:$dst), (ins GR32:$src1, i32i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003267 "imul{l}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Chris Lattnerec856802010-03-27 00:45:04 +00003268 [(set GR32:$dst, EFLAGS,
3269 (X86smul_flag GR32:$src1, i32immSExt8:$src2))]>;
Chris Lattnerf5d3a832004-08-11 05:31:07 +00003270
Bill Wendlingd350e022008-12-12 21:15:41 +00003271// Memory-Integer Signed Integer Multiply
Sean Callanan108934c2009-12-18 00:01:26 +00003272def IMUL16rmi : Ii16<0x69, MRMSrcMem, // GR16 = [mem16]*I16
Evan Cheng64d80e32007-07-19 01:14:50 +00003273 (outs GR16:$dst), (ins i16mem:$src1, i16imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003274 "imul{w}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Chris Lattnerec856802010-03-27 00:45:04 +00003275 [(set GR16:$dst, EFLAGS,
3276 (X86smul_flag (load addr:$src1), imm:$src2))]>,
3277 OpSize;
Sean Callanan108934c2009-12-18 00:01:26 +00003278def IMUL32rmi : Ii32<0x69, MRMSrcMem, // GR32 = [mem32]*I32
Evan Cheng64d80e32007-07-19 01:14:50 +00003279 (outs GR32:$dst), (ins i32mem:$src1, i32imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003280 "imul{l}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Chris Lattnerec856802010-03-27 00:45:04 +00003281 [(set GR32:$dst, EFLAGS,
3282 (X86smul_flag (load addr:$src1), imm:$src2))]>;
Evan Cheng069287d2006-05-16 07:21:53 +00003283def IMUL16rmi8 : Ii8<0x6B, MRMSrcMem, // GR16 = [mem16]*I8
Evan Cheng64d80e32007-07-19 01:14:50 +00003284 (outs GR16:$dst), (ins i16mem:$src1, i16i8imm :$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003285 "imul{w}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Chris Lattnerec856802010-03-27 00:45:04 +00003286 [(set GR16:$dst, EFLAGS,
3287 (X86smul_flag (load addr:$src1),
3288 i16immSExt8:$src2))]>, OpSize;
Evan Cheng069287d2006-05-16 07:21:53 +00003289def IMUL32rmi8 : Ii8<0x6B, MRMSrcMem, // GR32 = [mem32]*I8
Evan Cheng64d80e32007-07-19 01:14:50 +00003290 (outs GR32:$dst), (ins i32mem:$src1, i32i8imm: $src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003291 "imul{l}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Chris Lattnerec856802010-03-27 00:45:04 +00003292 [(set GR32:$dst, EFLAGS,
3293 (X86smul_flag (load addr:$src1),
3294 i32immSExt8:$src2))]>;
Evan Cheng24f2ea32007-09-14 21:48:26 +00003295} // Defs = [EFLAGS]
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00003296
3297//===----------------------------------------------------------------------===//
3298// Test instructions are just like AND, except they don't generate a result.
Chris Lattner3a173df2004-10-03 20:35:00 +00003299//
Evan Cheng0488db92007-09-25 01:57:46 +00003300let Defs = [EFLAGS] in {
Chris Lattnercc65bee2005-01-02 02:35:46 +00003301let isCommutable = 1 in { // TEST X, Y --> TEST Y, X
Daniel Dunbarb93c72c2010-03-08 21:10:36 +00003302def TEST8rr : I<0x84, MRMSrcReg, (outs), (ins GR8:$src1, GR8:$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_su GR8:$src1, GR8:$src2), 0))]>;
Daniel Dunbarb93c72c2010-03-08 21:10:36 +00003305def TEST16rr : I<0x85, MRMSrcReg, (outs), (ins GR16:$src1, GR16:$src2),
Evan Chenge5f62042007-09-29 00:00:36 +00003306 "test{w}\t{$src2, $src1|$src1, $src2}",
Chris Lattnere3486a42010-03-19 00:01:11 +00003307 [(set EFLAGS, (X86cmp (and_su GR16:$src1, GR16:$src2),
3308 0))]>,
Evan Chenge5f62042007-09-29 00:00:36 +00003309 OpSize;
Daniel Dunbarb93c72c2010-03-08 21:10:36 +00003310def TEST32rr : I<0x85, MRMSrcReg, (outs), (ins GR32:$src1, GR32:$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_su GR32:$src1, GR32:$src2),
3313 0))]>;
Chris Lattnercc65bee2005-01-02 02:35:46 +00003314}
Evan Cheng734503b2006-09-11 02:19:56 +00003315
Sean Callanan4a93b712009-09-01 18:14:18 +00003316def TEST8i8 : Ii8<0xA8, RawFrm, (outs), (ins i8imm:$src),
3317 "test{b}\t{$src, %al|%al, $src}", []>;
3318def TEST16i16 : Ii16<0xA9, RawFrm, (outs), (ins i16imm:$src),
3319 "test{w}\t{$src, %ax|%ax, $src}", []>, OpSize;
3320def TEST32i32 : Ii32<0xA9, RawFrm, (outs), (ins i32imm:$src),
3321 "test{l}\t{$src, %eax|%eax, $src}", []>;
3322
Evan Cheng64d80e32007-07-19 01:14:50 +00003323def TEST8rm : I<0x84, MRMSrcMem, (outs), (ins GR8 :$src1, i8mem :$src2),
Evan Chenge5f62042007-09-29 00:00:36 +00003324 "test{b}\t{$src2, $src1|$src1, $src2}",
Chris Lattnere3486a42010-03-19 00:01:11 +00003325 [(set EFLAGS, (X86cmp (and GR8:$src1, (loadi8 addr:$src2)),
3326 0))]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00003327def TEST16rm : I<0x85, MRMSrcMem, (outs), (ins GR16:$src1, i16mem:$src2),
Evan Chenge5f62042007-09-29 00:00:36 +00003328 "test{w}\t{$src2, $src1|$src1, $src2}",
Chris Lattnere3486a42010-03-19 00:01:11 +00003329 [(set EFLAGS, (X86cmp (and GR16:$src1,
3330 (loadi16 addr:$src2)), 0))]>, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00003331def TEST32rm : I<0x85, MRMSrcMem, (outs), (ins GR32:$src1, i32mem:$src2),
Evan Chenge5f62042007-09-29 00:00:36 +00003332 "test{l}\t{$src2, $src1|$src1, $src2}",
Chris Lattnere3486a42010-03-19 00:01:11 +00003333 [(set EFLAGS, (X86cmp (and GR32:$src1,
3334 (loadi32 addr:$src2)), 0))]>;
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00003335
Evan Cheng069287d2006-05-16 07:21:53 +00003336def TEST8ri : Ii8 <0xF6, MRM0r, // flags = GR8 & imm8
Evan Cheng64d80e32007-07-19 01:14:50 +00003337 (outs), (ins GR8:$src1, i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003338 "test{b}\t{$src2, $src1|$src1, $src2}",
Chris Lattnere3486a42010-03-19 00:01:11 +00003339 [(set EFLAGS, (X86cmp (and_su GR8:$src1, imm:$src2), 0))]>;
Evan Cheng069287d2006-05-16 07:21:53 +00003340def TEST16ri : Ii16<0xF7, MRM0r, // flags = GR16 & imm16
Evan Cheng64d80e32007-07-19 01:14:50 +00003341 (outs), (ins GR16:$src1, i16imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003342 "test{w}\t{$src2, $src1|$src1, $src2}",
Chris Lattnere3486a42010-03-19 00:01:11 +00003343 [(set EFLAGS, (X86cmp (and_su GR16:$src1, imm:$src2), 0))]>,
3344 OpSize;
Evan Cheng069287d2006-05-16 07:21:53 +00003345def TEST32ri : Ii32<0xF7, MRM0r, // flags = GR32 & imm32
Evan Cheng64d80e32007-07-19 01:14:50 +00003346 (outs), (ins GR32:$src1, i32imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003347 "test{l}\t{$src2, $src1|$src1, $src2}",
Chris Lattnere3486a42010-03-19 00:01:11 +00003348 [(set EFLAGS, (X86cmp (and_su GR32:$src1, imm:$src2), 0))]>;
Evan Cheng734503b2006-09-11 02:19:56 +00003349
Evan Chenge5f62042007-09-29 00:00:36 +00003350def TEST8mi : Ii8 <0xF6, MRM0m, // flags = [mem8] & imm8
Evan Cheng64d80e32007-07-19 01:14:50 +00003351 (outs), (ins i8mem:$src1, i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003352 "test{b}\t{$src2, $src1|$src1, $src2}",
Chris Lattnere3486a42010-03-19 00:01:11 +00003353 [(set EFLAGS, (X86cmp (and (loadi8 addr:$src1), imm:$src2),
3354 0))]>;
Evan Chenge5f62042007-09-29 00:00:36 +00003355def TEST16mi : Ii16<0xF7, MRM0m, // flags = [mem16] & imm16
Evan Cheng64d80e32007-07-19 01:14:50 +00003356 (outs), (ins i16mem:$src1, i16imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003357 "test{w}\t{$src2, $src1|$src1, $src2}",
Chris Lattnere3486a42010-03-19 00:01:11 +00003358 [(set EFLAGS, (X86cmp (and (loadi16 addr:$src1), imm:$src2),
3359 0))]>, OpSize;
Evan Chenge5f62042007-09-29 00:00:36 +00003360def TEST32mi : Ii32<0xF7, MRM0m, // flags = [mem32] & imm32
Evan Cheng64d80e32007-07-19 01:14:50 +00003361 (outs), (ins i32mem:$src1, i32imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003362 "test{l}\t{$src2, $src1|$src1, $src2}",
Chris Lattnere3486a42010-03-19 00:01:11 +00003363 [(set EFLAGS, (X86cmp (and (loadi32 addr:$src1), imm:$src2),
3364 0))]>;
Evan Cheng0488db92007-09-25 01:57:46 +00003365} // Defs = [EFLAGS]
3366
3367
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00003368// Condition code ops, incl. set if equal/not equal/...
Chris Lattnerba7e7562008-01-10 07:59:24 +00003369let Defs = [EFLAGS], Uses = [AH], neverHasSideEffects = 1 in
Evan Cheng071a2792007-09-11 19:55:27 +00003370def SAHF : I<0x9E, RawFrm, (outs), (ins), "sahf", []>; // flags = AH
Chris Lattnerba7e7562008-01-10 07:59:24 +00003371let Defs = [AH], Uses = [EFLAGS], neverHasSideEffects = 1 in
Evan Cheng071a2792007-09-11 19:55:27 +00003372def LAHF : I<0x9F, RawFrm, (outs), (ins), "lahf", []>; // AH = flags
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00003373
Evan Cheng0488db92007-09-25 01:57:46 +00003374let Uses = [EFLAGS] in {
Evan Chengad9c0a32009-12-15 00:53:42 +00003375// Use sbb to materialize carry bit.
Evan Chengad9c0a32009-12-15 00:53:42 +00003376let Defs = [EFLAGS], isCodeGenOnly = 1 in {
Chris Lattnerc74e3332010-02-05 21:13:48 +00003377// FIXME: These are pseudo ops that should be replaced with Pat<> patterns.
3378// However, Pat<> can't replicate the destination reg into the inputs of the
3379// result.
3380// FIXME: Change these to have encoding Pseudo when X86MCCodeEmitter replaces
3381// X86CodeEmitter.
3382def SETB_C8r : I<0x18, MRMInitReg, (outs GR8:$dst), (ins), "",
Evan Chengad9c0a32009-12-15 00:53:42 +00003383 [(set GR8:$dst, (X86setcc_c X86_COND_B, EFLAGS))]>;
Chris Lattnerc74e3332010-02-05 21:13:48 +00003384def SETB_C16r : I<0x19, MRMInitReg, (outs GR16:$dst), (ins), "",
Evan Cheng2e489c42009-12-16 00:53:11 +00003385 [(set GR16:$dst, (X86setcc_c X86_COND_B, EFLAGS))]>,
Evan Chengad9c0a32009-12-15 00:53:42 +00003386 OpSize;
Chris Lattnerc74e3332010-02-05 21:13:48 +00003387def SETB_C32r : I<0x19, MRMInitReg, (outs GR32:$dst), (ins), "",
Evan Cheng2e489c42009-12-16 00:53:11 +00003388 [(set GR32:$dst, (X86setcc_c X86_COND_B, EFLAGS))]>;
Evan Chengad9c0a32009-12-15 00:53:42 +00003389} // isCodeGenOnly
3390
Chris Lattner3a173df2004-10-03 20:35:00 +00003391def SETEr : I<0x94, MRM0r,
Evan Cheng64d80e32007-07-19 01:14:50 +00003392 (outs GR8 :$dst), (ins),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003393 "sete\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +00003394 [(set GR8:$dst, (X86setcc X86_COND_E, EFLAGS))]>,
Evan Cheng069287d2006-05-16 07:21:53 +00003395 TB; // GR8 = ==
Chris Lattner3a173df2004-10-03 20:35:00 +00003396def SETEm : I<0x94, MRM0m,
Evan Cheng64d80e32007-07-19 01:14:50 +00003397 (outs), (ins i8mem:$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003398 "sete\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +00003399 [(store (X86setcc X86_COND_E, EFLAGS), addr:$dst)]>,
Evan Chengd5781fc2005-12-21 20:21:51 +00003400 TB; // [mem8] = ==
Bill Wendling9f248742008-12-02 00:07:05 +00003401
Chris Lattner3a173df2004-10-03 20:35:00 +00003402def SETNEr : I<0x95, MRM0r,
Evan Cheng64d80e32007-07-19 01:14:50 +00003403 (outs GR8 :$dst), (ins),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003404 "setne\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +00003405 [(set GR8:$dst, (X86setcc X86_COND_NE, EFLAGS))]>,
Evan Cheng069287d2006-05-16 07:21:53 +00003406 TB; // GR8 = !=
Chris Lattner3a173df2004-10-03 20:35:00 +00003407def SETNEm : I<0x95, MRM0m,
Evan Cheng64d80e32007-07-19 01:14:50 +00003408 (outs), (ins i8mem:$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003409 "setne\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +00003410 [(store (X86setcc X86_COND_NE, EFLAGS), addr:$dst)]>,
Evan Chengd5781fc2005-12-21 20:21:51 +00003411 TB; // [mem8] = !=
Bill Wendling9f248742008-12-02 00:07:05 +00003412
Evan Chengd5781fc2005-12-21 20:21:51 +00003413def SETLr : I<0x9C, MRM0r,
Evan Cheng64d80e32007-07-19 01:14:50 +00003414 (outs GR8 :$dst), (ins),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003415 "setl\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +00003416 [(set GR8:$dst, (X86setcc X86_COND_L, EFLAGS))]>,
Evan Cheng069287d2006-05-16 07:21:53 +00003417 TB; // GR8 = < signed
Evan Chengd5781fc2005-12-21 20:21:51 +00003418def SETLm : I<0x9C, MRM0m,
Evan Cheng64d80e32007-07-19 01:14:50 +00003419 (outs), (ins i8mem:$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003420 "setl\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +00003421 [(store (X86setcc X86_COND_L, EFLAGS), addr:$dst)]>,
Evan Chengd5781fc2005-12-21 20:21:51 +00003422 TB; // [mem8] = < signed
Bill Wendling9f248742008-12-02 00:07:05 +00003423
Evan Chengd5781fc2005-12-21 20:21:51 +00003424def SETGEr : I<0x9D, MRM0r,
Evan Cheng64d80e32007-07-19 01:14:50 +00003425 (outs GR8 :$dst), (ins),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003426 "setge\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +00003427 [(set GR8:$dst, (X86setcc X86_COND_GE, EFLAGS))]>,
Evan Cheng069287d2006-05-16 07:21:53 +00003428 TB; // GR8 = >= signed
Evan Chengd5781fc2005-12-21 20:21:51 +00003429def SETGEm : I<0x9D, MRM0m,
Evan Cheng64d80e32007-07-19 01:14:50 +00003430 (outs), (ins i8mem:$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003431 "setge\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +00003432 [(store (X86setcc X86_COND_GE, EFLAGS), addr:$dst)]>,
Evan Chengd5781fc2005-12-21 20:21:51 +00003433 TB; // [mem8] = >= signed
Bill Wendling9f248742008-12-02 00:07:05 +00003434
Evan Chengd5781fc2005-12-21 20:21:51 +00003435def SETLEr : I<0x9E, MRM0r,
Evan Cheng64d80e32007-07-19 01:14:50 +00003436 (outs GR8 :$dst), (ins),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003437 "setle\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +00003438 [(set GR8:$dst, (X86setcc X86_COND_LE, EFLAGS))]>,
Evan Cheng069287d2006-05-16 07:21:53 +00003439 TB; // GR8 = <= signed
Evan Chengd5781fc2005-12-21 20:21:51 +00003440def SETLEm : I<0x9E, MRM0m,
Evan Cheng64d80e32007-07-19 01:14:50 +00003441 (outs), (ins i8mem:$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003442 "setle\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +00003443 [(store (X86setcc X86_COND_LE, EFLAGS), addr:$dst)]>,
Evan Chengd5781fc2005-12-21 20:21:51 +00003444 TB; // [mem8] = <= signed
Bill Wendling9f248742008-12-02 00:07:05 +00003445
Evan Chengd5781fc2005-12-21 20:21:51 +00003446def SETGr : I<0x9F, MRM0r,
Evan Cheng64d80e32007-07-19 01:14:50 +00003447 (outs GR8 :$dst), (ins),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003448 "setg\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +00003449 [(set GR8:$dst, (X86setcc X86_COND_G, EFLAGS))]>,
Evan Cheng069287d2006-05-16 07:21:53 +00003450 TB; // GR8 = > signed
Evan Chengd5781fc2005-12-21 20:21:51 +00003451def SETGm : I<0x9F, MRM0m,
Evan Cheng64d80e32007-07-19 01:14:50 +00003452 (outs), (ins i8mem:$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003453 "setg\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +00003454 [(store (X86setcc X86_COND_G, EFLAGS), addr:$dst)]>,
Evan Chengd5781fc2005-12-21 20:21:51 +00003455 TB; // [mem8] = > signed
3456
3457def SETBr : I<0x92, MRM0r,
Evan Cheng64d80e32007-07-19 01:14:50 +00003458 (outs GR8 :$dst), (ins),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003459 "setb\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +00003460 [(set GR8:$dst, (X86setcc X86_COND_B, EFLAGS))]>,
Evan Cheng069287d2006-05-16 07:21:53 +00003461 TB; // GR8 = < unsign
Evan Chengd5781fc2005-12-21 20:21:51 +00003462def SETBm : I<0x92, MRM0m,
Evan Cheng64d80e32007-07-19 01:14:50 +00003463 (outs), (ins i8mem:$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003464 "setb\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +00003465 [(store (X86setcc X86_COND_B, EFLAGS), addr:$dst)]>,
Evan Chengd5781fc2005-12-21 20:21:51 +00003466 TB; // [mem8] = < unsign
Bill Wendling9f248742008-12-02 00:07:05 +00003467
Evan Chengd5781fc2005-12-21 20:21:51 +00003468def SETAEr : I<0x93, MRM0r,
Evan Cheng64d80e32007-07-19 01:14:50 +00003469 (outs GR8 :$dst), (ins),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003470 "setae\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +00003471 [(set GR8:$dst, (X86setcc X86_COND_AE, EFLAGS))]>,
Evan Cheng069287d2006-05-16 07:21:53 +00003472 TB; // GR8 = >= unsign
Evan Chengd5781fc2005-12-21 20:21:51 +00003473def SETAEm : I<0x93, MRM0m,
Evan Cheng64d80e32007-07-19 01:14:50 +00003474 (outs), (ins i8mem:$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003475 "setae\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +00003476 [(store (X86setcc X86_COND_AE, EFLAGS), addr:$dst)]>,
Evan Chengd5781fc2005-12-21 20:21:51 +00003477 TB; // [mem8] = >= unsign
Bill Wendling9f248742008-12-02 00:07:05 +00003478
Chris Lattner3a173df2004-10-03 20:35:00 +00003479def SETBEr : I<0x96, MRM0r,
Evan Cheng64d80e32007-07-19 01:14:50 +00003480 (outs GR8 :$dst), (ins),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003481 "setbe\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +00003482 [(set GR8:$dst, (X86setcc X86_COND_BE, EFLAGS))]>,
Evan Cheng069287d2006-05-16 07:21:53 +00003483 TB; // GR8 = <= unsign
Chris Lattner3a173df2004-10-03 20:35:00 +00003484def SETBEm : I<0x96, MRM0m,
Evan Cheng64d80e32007-07-19 01:14:50 +00003485 (outs), (ins i8mem:$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003486 "setbe\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +00003487 [(store (X86setcc X86_COND_BE, EFLAGS), addr:$dst)]>,
Evan Chengd5781fc2005-12-21 20:21:51 +00003488 TB; // [mem8] = <= unsign
Bill Wendling9f248742008-12-02 00:07:05 +00003489
Chris Lattner3a173df2004-10-03 20:35:00 +00003490def SETAr : I<0x97, MRM0r,
Evan Cheng64d80e32007-07-19 01:14:50 +00003491 (outs GR8 :$dst), (ins),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003492 "seta\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +00003493 [(set GR8:$dst, (X86setcc X86_COND_A, EFLAGS))]>,
Evan Cheng069287d2006-05-16 07:21:53 +00003494 TB; // GR8 = > signed
Chris Lattner3a173df2004-10-03 20:35:00 +00003495def SETAm : I<0x97, MRM0m,
Evan Cheng64d80e32007-07-19 01:14:50 +00003496 (outs), (ins i8mem:$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003497 "seta\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +00003498 [(store (X86setcc X86_COND_A, EFLAGS), addr:$dst)]>,
Evan Chengd5781fc2005-12-21 20:21:51 +00003499 TB; // [mem8] = > signed
Evan Chengd9558e02006-01-06 00:43:03 +00003500
Chris Lattner3a173df2004-10-03 20:35:00 +00003501def SETSr : I<0x98, MRM0r,
Evan Cheng64d80e32007-07-19 01:14:50 +00003502 (outs GR8 :$dst), (ins),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003503 "sets\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +00003504 [(set GR8:$dst, (X86setcc X86_COND_S, EFLAGS))]>,
Evan Cheng069287d2006-05-16 07:21:53 +00003505 TB; // GR8 = <sign bit>
Chris Lattner3a173df2004-10-03 20:35:00 +00003506def SETSm : I<0x98, MRM0m,
Evan Cheng64d80e32007-07-19 01:14:50 +00003507 (outs), (ins i8mem:$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003508 "sets\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +00003509 [(store (X86setcc X86_COND_S, EFLAGS), addr:$dst)]>,
Evan Chengd9558e02006-01-06 00:43:03 +00003510 TB; // [mem8] = <sign bit>
Chris Lattner3a173df2004-10-03 20:35:00 +00003511def SETNSr : I<0x99, MRM0r,
Evan Cheng64d80e32007-07-19 01:14:50 +00003512 (outs GR8 :$dst), (ins),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003513 "setns\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +00003514 [(set GR8:$dst, (X86setcc X86_COND_NS, EFLAGS))]>,
Evan Cheng069287d2006-05-16 07:21:53 +00003515 TB; // GR8 = !<sign bit>
Chris Lattner3a173df2004-10-03 20:35:00 +00003516def SETNSm : I<0x99, MRM0m,
Evan Cheng64d80e32007-07-19 01:14:50 +00003517 (outs), (ins i8mem:$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003518 "setns\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +00003519 [(store (X86setcc X86_COND_NS, EFLAGS), addr:$dst)]>,
Evan Chengd9558e02006-01-06 00:43:03 +00003520 TB; // [mem8] = !<sign bit>
Bill Wendling9f248742008-12-02 00:07:05 +00003521
Chris Lattner3a173df2004-10-03 20:35:00 +00003522def SETPr : I<0x9A, MRM0r,
Evan Cheng64d80e32007-07-19 01:14:50 +00003523 (outs GR8 :$dst), (ins),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003524 "setp\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +00003525 [(set GR8:$dst, (X86setcc X86_COND_P, EFLAGS))]>,
Evan Cheng069287d2006-05-16 07:21:53 +00003526 TB; // GR8 = parity
Chris Lattner3a173df2004-10-03 20:35:00 +00003527def SETPm : I<0x9A, MRM0m,
Evan Cheng64d80e32007-07-19 01:14:50 +00003528 (outs), (ins i8mem:$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003529 "setp\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +00003530 [(store (X86setcc X86_COND_P, EFLAGS), addr:$dst)]>,
Evan Chengd9558e02006-01-06 00:43:03 +00003531 TB; // [mem8] = parity
Chris Lattnercc65bee2005-01-02 02:35:46 +00003532def SETNPr : I<0x9B, MRM0r,
Evan Cheng64d80e32007-07-19 01:14:50 +00003533 (outs GR8 :$dst), (ins),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003534 "setnp\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +00003535 [(set GR8:$dst, (X86setcc X86_COND_NP, EFLAGS))]>,
Evan Cheng069287d2006-05-16 07:21:53 +00003536 TB; // GR8 = not parity
Chris Lattnercc65bee2005-01-02 02:35:46 +00003537def SETNPm : I<0x9B, MRM0m,
Evan Cheng64d80e32007-07-19 01:14:50 +00003538 (outs), (ins i8mem:$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003539 "setnp\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +00003540 [(store (X86setcc X86_COND_NP, EFLAGS), addr:$dst)]>,
Evan Chengd9558e02006-01-06 00:43:03 +00003541 TB; // [mem8] = not parity
Bill Wendling9f248742008-12-02 00:07:05 +00003542
3543def SETOr : I<0x90, MRM0r,
3544 (outs GR8 :$dst), (ins),
3545 "seto\t$dst",
3546 [(set GR8:$dst, (X86setcc X86_COND_O, EFLAGS))]>,
3547 TB; // GR8 = overflow
3548def SETOm : I<0x90, MRM0m,
3549 (outs), (ins i8mem:$dst),
3550 "seto\t$dst",
3551 [(store (X86setcc X86_COND_O, EFLAGS), addr:$dst)]>,
3552 TB; // [mem8] = overflow
3553def SETNOr : I<0x91, MRM0r,
3554 (outs GR8 :$dst), (ins),
3555 "setno\t$dst",
3556 [(set GR8:$dst, (X86setcc X86_COND_NO, EFLAGS))]>,
3557 TB; // GR8 = not overflow
3558def SETNOm : I<0x91, MRM0m,
3559 (outs), (ins i8mem:$dst),
3560 "setno\t$dst",
3561 [(store (X86setcc X86_COND_NO, EFLAGS), addr:$dst)]>,
3562 TB; // [mem8] = not overflow
Evan Cheng0488db92007-09-25 01:57:46 +00003563} // Uses = [EFLAGS]
3564
Chris Lattner1cca5e32003-08-03 21:54:21 +00003565
3566// Integer comparisons
Evan Cheng24f2ea32007-09-14 21:48:26 +00003567let Defs = [EFLAGS] in {
Sean Callanana09caa52009-09-02 00:55:49 +00003568def CMP8i8 : Ii8<0x3C, RawFrm, (outs), (ins i8imm:$src),
3569 "cmp{b}\t{$src, %al|%al, $src}", []>;
3570def CMP16i16 : Ii16<0x3D, RawFrm, (outs), (ins i16imm:$src),
3571 "cmp{w}\t{$src, %ax|%ax, $src}", []>, OpSize;
3572def CMP32i32 : Ii32<0x3D, RawFrm, (outs), (ins i32imm:$src),
3573 "cmp{l}\t{$src, %eax|%eax, $src}", []>;
3574
Chris Lattner3a173df2004-10-03 20:35:00 +00003575def CMP8rr : I<0x38, MRMDestReg,
Evan Cheng64d80e32007-07-19 01:14:50 +00003576 (outs), (ins GR8 :$src1, GR8 :$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003577 "cmp{b}\t{$src2, $src1|$src1, $src2}",
Chris Lattnere3486a42010-03-19 00:01:11 +00003578 [(set EFLAGS, (X86cmp GR8:$src1, GR8:$src2))]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00003579def CMP16rr : I<0x39, MRMDestReg,
Evan Cheng64d80e32007-07-19 01:14:50 +00003580 (outs), (ins GR16:$src1, GR16:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003581 "cmp{w}\t{$src2, $src1|$src1, $src2}",
Chris Lattnere3486a42010-03-19 00:01:11 +00003582 [(set EFLAGS, (X86cmp GR16:$src1, GR16:$src2))]>, OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00003583def CMP32rr : I<0x39, MRMDestReg,
Evan Cheng64d80e32007-07-19 01:14:50 +00003584 (outs), (ins GR32:$src1, GR32:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003585 "cmp{l}\t{$src2, $src1|$src1, $src2}",
Chris Lattnere3486a42010-03-19 00:01:11 +00003586 [(set EFLAGS, (X86cmp GR32:$src1, GR32:$src2))]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00003587def CMP8mr : I<0x38, MRMDestMem,
Evan Cheng64d80e32007-07-19 01:14:50 +00003588 (outs), (ins i8mem :$src1, GR8 :$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003589 "cmp{b}\t{$src2, $src1|$src1, $src2}",
Chris Lattnere3486a42010-03-19 00:01:11 +00003590 [(set EFLAGS, (X86cmp (loadi8 addr:$src1), GR8:$src2))]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00003591def CMP16mr : I<0x39, MRMDestMem,
Evan Cheng64d80e32007-07-19 01:14:50 +00003592 (outs), (ins i16mem:$src1, GR16:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003593 "cmp{w}\t{$src2, $src1|$src1, $src2}",
Chris Lattnere3486a42010-03-19 00:01:11 +00003594 [(set EFLAGS, (X86cmp (loadi16 addr:$src1), GR16:$src2))]>,
3595 OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00003596def CMP32mr : I<0x39, MRMDestMem,
Evan Cheng64d80e32007-07-19 01:14:50 +00003597 (outs), (ins i32mem:$src1, GR32:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003598 "cmp{l}\t{$src2, $src1|$src1, $src2}",
Chris Lattnere3486a42010-03-19 00:01:11 +00003599 [(set EFLAGS, (X86cmp (loadi32 addr:$src1), GR32:$src2))]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00003600def CMP8rm : I<0x3A, MRMSrcMem,
Evan Cheng64d80e32007-07-19 01:14:50 +00003601 (outs), (ins GR8 :$src1, i8mem :$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003602 "cmp{b}\t{$src2, $src1|$src1, $src2}",
Chris Lattnere3486a42010-03-19 00:01:11 +00003603 [(set EFLAGS, (X86cmp GR8:$src1, (loadi8 addr:$src2)))]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00003604def CMP16rm : I<0x3B, MRMSrcMem,
Evan Cheng64d80e32007-07-19 01:14:50 +00003605 (outs), (ins GR16:$src1, i16mem:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003606 "cmp{w}\t{$src2, $src1|$src1, $src2}",
Chris Lattnere3486a42010-03-19 00:01:11 +00003607 [(set EFLAGS, (X86cmp GR16:$src1, (loadi16 addr:$src2)))]>,
3608 OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00003609def CMP32rm : I<0x3B, MRMSrcMem,
Evan Cheng64d80e32007-07-19 01:14:50 +00003610 (outs), (ins GR32:$src1, i32mem:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003611 "cmp{l}\t{$src2, $src1|$src1, $src2}",
Chris Lattnere3486a42010-03-19 00:01:11 +00003612 [(set EFLAGS, (X86cmp GR32:$src1, (loadi32 addr:$src2)))]>;
Daniel Dunbar1e8ee892010-03-09 22:50:40 +00003613
3614// These are alternate spellings for use by the disassembler, we mark them as
3615// code gen only to ensure they aren't matched by the assembler.
3616let isCodeGenOnly = 1 in {
3617 def CMP8rr_alt : I<0x3A, MRMSrcReg, (outs), (ins GR8:$src1, GR8:$src2),
3618 "cmp{b}\t{$src2, $src1|$src1, $src2}", []>;
3619 def CMP16rr_alt : I<0x3B, MRMSrcReg, (outs), (ins GR16:$src1, GR16:$src2),
3620 "cmp{w}\t{$src2, $src1|$src1, $src2}", []>, OpSize;
3621 def CMP32rr_alt : I<0x3B, MRMSrcReg, (outs), (ins GR32:$src1, GR32:$src2),
3622 "cmp{l}\t{$src2, $src1|$src1, $src2}", []>;
3623}
3624
Chris Lattner3a173df2004-10-03 20:35:00 +00003625def CMP8ri : Ii8<0x80, MRM7r,
Evan Cheng64d80e32007-07-19 01:14:50 +00003626 (outs), (ins GR8:$src1, i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003627 "cmp{b}\t{$src2, $src1|$src1, $src2}",
Chris Lattnere3486a42010-03-19 00:01:11 +00003628 [(set EFLAGS, (X86cmp GR8:$src1, imm:$src2))]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00003629def CMP16ri : Ii16<0x81, MRM7r,
Evan Cheng64d80e32007-07-19 01:14:50 +00003630 (outs), (ins GR16:$src1, i16imm:$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, imm:$src2))]>, OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00003633def CMP32ri : Ii32<0x81, MRM7r,
Evan Cheng64d80e32007-07-19 01:14:50 +00003634 (outs), (ins GR32:$src1, i32imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003635 "cmp{l}\t{$src2, $src1|$src1, $src2}",
Chris Lattnere3486a42010-03-19 00:01:11 +00003636 [(set EFLAGS, (X86cmp GR32:$src1, imm:$src2))]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00003637def CMP8mi : Ii8 <0x80, MRM7m,
Evan Cheng64d80e32007-07-19 01:14:50 +00003638 (outs), (ins i8mem :$src1, i8imm :$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003639 "cmp{b}\t{$src2, $src1|$src1, $src2}",
Chris Lattnere3486a42010-03-19 00:01:11 +00003640 [(set EFLAGS, (X86cmp (loadi8 addr:$src1), imm:$src2))]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00003641def CMP16mi : Ii16<0x81, MRM7m,
Evan Cheng64d80e32007-07-19 01:14:50 +00003642 (outs), (ins i16mem:$src1, i16imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003643 "cmp{w}\t{$src2, $src1|$src1, $src2}",
Chris Lattnere3486a42010-03-19 00:01:11 +00003644 [(set EFLAGS, (X86cmp (loadi16 addr:$src1), imm:$src2))]>,
3645 OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00003646def CMP32mi : Ii32<0x81, MRM7m,
Evan Cheng64d80e32007-07-19 01:14:50 +00003647 (outs), (ins i32mem:$src1, i32imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003648 "cmp{l}\t{$src2, $src1|$src1, $src2}",
Chris Lattnere3486a42010-03-19 00:01:11 +00003649 [(set EFLAGS, (X86cmp (loadi32 addr:$src1), imm:$src2))]>;
Chris Lattner29b4dd02006-03-23 16:13:50 +00003650def CMP16ri8 : Ii8<0x83, MRM7r,
Evan Cheng64d80e32007-07-19 01:14:50 +00003651 (outs), (ins GR16:$src1, i16i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003652 "cmp{w}\t{$src2, $src1|$src1, $src2}",
Chris Lattnere3486a42010-03-19 00:01:11 +00003653 [(set EFLAGS, (X86cmp GR16:$src1, i16immSExt8:$src2))]>,
3654 OpSize;
Chris Lattner29b4dd02006-03-23 16:13:50 +00003655def CMP16mi8 : Ii8<0x83, MRM7m,
Evan Cheng64d80e32007-07-19 01:14:50 +00003656 (outs), (ins i16mem:$src1, i16i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003657 "cmp{w}\t{$src2, $src1|$src1, $src2}",
Chris Lattnere3486a42010-03-19 00:01:11 +00003658 [(set EFLAGS, (X86cmp (loadi16 addr:$src1),
3659 i16immSExt8:$src2))]>, OpSize;
Chris Lattner29b4dd02006-03-23 16:13:50 +00003660def CMP32mi8 : Ii8<0x83, MRM7m,
Evan Cheng64d80e32007-07-19 01:14:50 +00003661 (outs), (ins i32mem:$src1, i32i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003662 "cmp{l}\t{$src2, $src1|$src1, $src2}",
Chris Lattnere3486a42010-03-19 00:01:11 +00003663 [(set EFLAGS, (X86cmp (loadi32 addr:$src1),
3664 i32immSExt8:$src2))]>;
Chris Lattner29b4dd02006-03-23 16:13:50 +00003665def CMP32ri8 : Ii8<0x83, MRM7r,
Evan Cheng64d80e32007-07-19 01:14:50 +00003666 (outs), (ins GR32:$src1, i32i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003667 "cmp{l}\t{$src2, $src1|$src1, $src2}",
Chris Lattnere3486a42010-03-19 00:01:11 +00003668 [(set EFLAGS, (X86cmp GR32:$src1, i32immSExt8:$src2))]>;
Evan Cheng0488db92007-09-25 01:57:46 +00003669} // Defs = [EFLAGS]
3670
Dan Gohmanc7a37d42008-12-23 22:45:23 +00003671// Bit tests.
Dan Gohmanc7a37d42008-12-23 22:45:23 +00003672// TODO: BTC, BTR, and BTS
3673let Defs = [EFLAGS] in {
Dan Gohman0c89b7e2009-01-13 20:32:45 +00003674def BT16rr : I<0xA3, MRMDestReg, (outs), (ins GR16:$src1, GR16:$src2),
Dan Gohmanc7a37d42008-12-23 22:45:23 +00003675 "bt{w}\t{$src2, $src1|$src1, $src2}",
Chris Lattnere3486a42010-03-19 00:01:11 +00003676 [(set EFLAGS, (X86bt GR16:$src1, GR16:$src2))]>, OpSize, TB;
Dan Gohman0c89b7e2009-01-13 20:32:45 +00003677def BT32rr : I<0xA3, MRMDestReg, (outs), (ins GR32:$src1, GR32:$src2),
Dan Gohmanc7a37d42008-12-23 22:45:23 +00003678 "bt{l}\t{$src2, $src1|$src1, $src2}",
Chris Lattnere3486a42010-03-19 00:01:11 +00003679 [(set EFLAGS, (X86bt GR32:$src1, GR32:$src2))]>, TB;
Dan Gohmanf31408d2009-01-13 23:23:30 +00003680
3681// Unlike with the register+register form, the memory+register form of the
3682// bt instruction does not ignore the high bits of the index. From ISel's
Sean Callanan108934c2009-12-18 00:01:26 +00003683// perspective, this is pretty bizarre. Make these instructions disassembly
3684// only for now.
3685
3686def BT16mr : I<0xA3, MRMDestMem, (outs), (ins i16mem:$src1, GR16:$src2),
3687 "bt{w}\t{$src2, $src1|$src1, $src2}",
Dan Gohmanf31408d2009-01-13 23:23:30 +00003688// [(X86bt (loadi16 addr:$src1), GR16:$src2),
Sean Callanan108934c2009-12-18 00:01:26 +00003689// (implicit EFLAGS)]
3690 []
3691 >, OpSize, TB, Requires<[FastBTMem]>;
3692def BT32mr : I<0xA3, MRMDestMem, (outs), (ins i32mem:$src1, GR32:$src2),
3693 "bt{l}\t{$src2, $src1|$src1, $src2}",
Dan Gohmanf31408d2009-01-13 23:23:30 +00003694// [(X86bt (loadi32 addr:$src1), GR32:$src2),
Sean Callanan108934c2009-12-18 00:01:26 +00003695// (implicit EFLAGS)]
3696 []
3697 >, TB, Requires<[FastBTMem]>;
Dan Gohman4afe15b2009-01-13 20:33:23 +00003698
3699def BT16ri8 : Ii8<0xBA, MRM4r, (outs), (ins GR16:$src1, i16i8imm:$src2),
3700 "bt{w}\t{$src2, $src1|$src1, $src2}",
Chris Lattnere3486a42010-03-19 00:01:11 +00003701 [(set EFLAGS, (X86bt GR16:$src1, i16immSExt8:$src2))]>,
3702 OpSize, TB;
Dan Gohman4afe15b2009-01-13 20:33:23 +00003703def BT32ri8 : Ii8<0xBA, MRM4r, (outs), (ins GR32:$src1, i32i8imm:$src2),
3704 "bt{l}\t{$src2, $src1|$src1, $src2}",
Chris Lattnere3486a42010-03-19 00:01:11 +00003705 [(set EFLAGS, (X86bt GR32:$src1, i32immSExt8:$src2))]>, TB;
Dan Gohman4afe15b2009-01-13 20:33:23 +00003706// Note that these instructions don't need FastBTMem because that
3707// only applies when the other operand is in a register. When it's
3708// an immediate, bt is still fast.
3709def BT16mi8 : Ii8<0xBA, MRM4m, (outs), (ins i16mem:$src1, i16i8imm:$src2),
3710 "bt{w}\t{$src2, $src1|$src1, $src2}",
Chris Lattnere3486a42010-03-19 00:01:11 +00003711 [(set EFLAGS, (X86bt (loadi16 addr:$src1), i16immSExt8:$src2))
3712 ]>, OpSize, TB;
Dan Gohman4afe15b2009-01-13 20:33:23 +00003713def BT32mi8 : Ii8<0xBA, MRM4m, (outs), (ins i32mem:$src1, i32i8imm:$src2),
3714 "bt{l}\t{$src2, $src1|$src1, $src2}",
Chris Lattnere3486a42010-03-19 00:01:11 +00003715 [(set EFLAGS, (X86bt (loadi32 addr:$src1), i32immSExt8:$src2))
3716 ]>, TB;
Sean Callanan108934c2009-12-18 00:01:26 +00003717
3718def BTC16rr : I<0xBB, MRMDestReg, (outs), (ins GR16:$src1, GR16:$src2),
3719 "btc{w}\t{$src2, $src1|$src1, $src2}", []>, OpSize, TB;
3720def BTC32rr : I<0xBB, MRMDestReg, (outs), (ins GR32:$src1, GR32:$src2),
3721 "btc{l}\t{$src2, $src1|$src1, $src2}", []>, TB;
3722def BTC16mr : I<0xBB, MRMDestMem, (outs), (ins i16mem:$src1, GR16:$src2),
3723 "btc{w}\t{$src2, $src1|$src1, $src2}", []>, OpSize, TB;
3724def BTC32mr : I<0xBB, MRMDestMem, (outs), (ins i32mem:$src1, GR32:$src2),
3725 "btc{l}\t{$src2, $src1|$src1, $src2}", []>, TB;
3726def BTC16ri8 : Ii8<0xBA, MRM7r, (outs), (ins GR16:$src1, i16i8imm:$src2),
3727 "btc{w}\t{$src2, $src1|$src1, $src2}", []>, OpSize, TB;
3728def BTC32ri8 : Ii8<0xBA, MRM7r, (outs), (ins GR32:$src1, i32i8imm:$src2),
3729 "btc{l}\t{$src2, $src1|$src1, $src2}", []>, TB;
3730def BTC16mi8 : Ii8<0xBA, MRM7m, (outs), (ins i16mem:$src1, i16i8imm:$src2),
3731 "btc{w}\t{$src2, $src1|$src1, $src2}", []>, OpSize, TB;
3732def BTC32mi8 : Ii8<0xBA, MRM7m, (outs), (ins i32mem:$src1, i32i8imm:$src2),
3733 "btc{l}\t{$src2, $src1|$src1, $src2}", []>, TB;
3734
3735def BTR16rr : I<0xB3, MRMDestReg, (outs), (ins GR16:$src1, GR16:$src2),
3736 "btr{w}\t{$src2, $src1|$src1, $src2}", []>, OpSize, TB;
3737def BTR32rr : I<0xB3, MRMDestReg, (outs), (ins GR32:$src1, GR32:$src2),
3738 "btr{l}\t{$src2, $src1|$src1, $src2}", []>, TB;
3739def BTR16mr : I<0xB3, MRMDestMem, (outs), (ins i16mem:$src1, GR16:$src2),
3740 "btr{w}\t{$src2, $src1|$src1, $src2}", []>, OpSize, TB;
3741def BTR32mr : I<0xB3, MRMDestMem, (outs), (ins i32mem:$src1, GR32:$src2),
3742 "btr{l}\t{$src2, $src1|$src1, $src2}", []>, TB;
3743def BTR16ri8 : Ii8<0xBA, MRM6r, (outs), (ins GR16:$src1, i16i8imm:$src2),
3744 "btr{w}\t{$src2, $src1|$src1, $src2}", []>, OpSize, TB;
3745def BTR32ri8 : Ii8<0xBA, MRM6r, (outs), (ins GR32:$src1, i32i8imm:$src2),
3746 "btr{l}\t{$src2, $src1|$src1, $src2}", []>, TB;
3747def BTR16mi8 : Ii8<0xBA, MRM6m, (outs), (ins i16mem:$src1, i16i8imm:$src2),
3748 "btr{w}\t{$src2, $src1|$src1, $src2}", []>, OpSize, TB;
3749def BTR32mi8 : Ii8<0xBA, MRM6m, (outs), (ins i32mem:$src1, i32i8imm:$src2),
3750 "btr{l}\t{$src2, $src1|$src1, $src2}", []>, TB;
3751
3752def BTS16rr : I<0xAB, MRMDestReg, (outs), (ins GR16:$src1, GR16:$src2),
3753 "bts{w}\t{$src2, $src1|$src1, $src2}", []>, OpSize, TB;
3754def BTS32rr : I<0xAB, MRMDestReg, (outs), (ins GR32:$src1, GR32:$src2),
3755 "bts{l}\t{$src2, $src1|$src1, $src2}", []>, TB;
3756def BTS16mr : I<0xAB, MRMDestMem, (outs), (ins i16mem:$src1, GR16:$src2),
3757 "bts{w}\t{$src2, $src1|$src1, $src2}", []>, OpSize, TB;
3758def BTS32mr : I<0xAB, MRMDestMem, (outs), (ins i32mem:$src1, GR32:$src2),
3759 "bts{l}\t{$src2, $src1|$src1, $src2}", []>, TB;
3760def BTS16ri8 : Ii8<0xBA, MRM5r, (outs), (ins GR16:$src1, i16i8imm:$src2),
3761 "bts{w}\t{$src2, $src1|$src1, $src2}", []>, OpSize, TB;
3762def BTS32ri8 : Ii8<0xBA, MRM5r, (outs), (ins GR32:$src1, i32i8imm:$src2),
3763 "bts{l}\t{$src2, $src1|$src1, $src2}", []>, TB;
3764def BTS16mi8 : Ii8<0xBA, MRM5m, (outs), (ins i16mem:$src1, i16i8imm:$src2),
3765 "bts{w}\t{$src2, $src1|$src1, $src2}", []>, OpSize, TB;
3766def BTS32mi8 : Ii8<0xBA, MRM5m, (outs), (ins i32mem:$src1, i32i8imm:$src2),
3767 "bts{l}\t{$src2, $src1|$src1, $src2}", []>, TB;
Dan Gohmanc7a37d42008-12-23 22:45:23 +00003768} // Defs = [EFLAGS]
3769
Chris Lattner1cca5e32003-08-03 21:54:21 +00003770// Sign/Zero extenders
Dan Gohman11ba3b12008-07-30 18:09:17 +00003771// Use movsbl intead of movsbw; we don't care about the high 16 bits
3772// of the register here. This has a smaller encoding and avoids a
Sean Callanan108934c2009-12-18 00:01:26 +00003773// partial-register update. Actual movsbw included for the disassembler.
3774def MOVSX16rr8W : I<0xBE, MRMSrcReg, (outs GR16:$dst), (ins GR8:$src),
3775 "movs{bw|x}\t{$src, $dst|$dst, $src}", []>, TB, OpSize;
3776def MOVSX16rm8W : I<0xBE, MRMSrcMem, (outs GR16:$dst), (ins i8mem:$src),
3777 "movs{bw|x}\t{$src, $dst|$dst, $src}", []>, TB, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00003778def MOVSX16rr8 : I<0xBE, MRMSrcReg, (outs GR16:$dst), (ins GR8 :$src),
Chris Lattner172862a2009-10-19 19:51:42 +00003779 "", [(set GR16:$dst, (sext GR8:$src))]>, TB;
Evan Cheng64d80e32007-07-19 01:14:50 +00003780def MOVSX16rm8 : I<0xBE, MRMSrcMem, (outs GR16:$dst), (ins i8mem :$src),
Chris Lattner172862a2009-10-19 19:51:42 +00003781 "", [(set GR16:$dst, (sextloadi16i8 addr:$src))]>, TB;
Evan Cheng64d80e32007-07-19 01:14:50 +00003782def MOVSX32rr8 : I<0xBE, MRMSrcReg, (outs GR32:$dst), (ins GR8 :$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003783 "movs{bl|x}\t{$src, $dst|$dst, $src}",
Evan Cheng069287d2006-05-16 07:21:53 +00003784 [(set GR32:$dst, (sext GR8:$src))]>, TB;
Evan Cheng64d80e32007-07-19 01:14:50 +00003785def MOVSX32rm8 : I<0xBE, MRMSrcMem, (outs GR32:$dst), (ins i8mem :$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003786 "movs{bl|x}\t{$src, $dst|$dst, $src}",
Evan Cheng069287d2006-05-16 07:21:53 +00003787 [(set GR32:$dst, (sextloadi32i8 addr:$src))]>, TB;
Evan Cheng64d80e32007-07-19 01:14:50 +00003788def MOVSX32rr16: I<0xBF, MRMSrcReg, (outs GR32:$dst), (ins GR16:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003789 "movs{wl|x}\t{$src, $dst|$dst, $src}",
Evan Cheng069287d2006-05-16 07:21:53 +00003790 [(set GR32:$dst, (sext GR16:$src))]>, TB;
Evan Cheng64d80e32007-07-19 01:14:50 +00003791def MOVSX32rm16: I<0xBF, MRMSrcMem, (outs GR32:$dst), (ins i16mem:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003792 "movs{wl|x}\t{$src, $dst|$dst, $src}",
Evan Cheng069287d2006-05-16 07:21:53 +00003793 [(set GR32:$dst, (sextloadi32i16 addr:$src))]>, TB;
Alkis Evlogimenosa7be9822004-02-17 09:14:23 +00003794
Dan Gohman11ba3b12008-07-30 18:09:17 +00003795// Use movzbl intead of movzbw; we don't care about the high 16 bits
3796// of the register here. This has a smaller encoding and avoids a
Sean Callanan108934c2009-12-18 00:01:26 +00003797// partial-register update. Actual movzbw included for the disassembler.
3798def MOVZX16rr8W : I<0xB6, MRMSrcReg, (outs GR16:$dst), (ins GR8:$src),
3799 "movz{bw|x}\t{$src, $dst|$dst, $src}", []>, TB, OpSize;
3800def MOVZX16rm8W : I<0xB6, MRMSrcMem, (outs GR16:$dst), (ins i8mem:$src),
3801 "movz{bw|x}\t{$src, $dst|$dst, $src}", []>, TB, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00003802def MOVZX16rr8 : I<0xB6, MRMSrcReg, (outs GR16:$dst), (ins GR8 :$src),
Chris Lattner172862a2009-10-19 19:51:42 +00003803 "", [(set GR16:$dst, (zext GR8:$src))]>, TB;
Evan Cheng64d80e32007-07-19 01:14:50 +00003804def MOVZX16rm8 : I<0xB6, MRMSrcMem, (outs GR16:$dst), (ins i8mem :$src),
Chris Lattner172862a2009-10-19 19:51:42 +00003805 "", [(set GR16:$dst, (zextloadi16i8 addr:$src))]>, TB;
Evan Cheng64d80e32007-07-19 01:14:50 +00003806def MOVZX32rr8 : I<0xB6, MRMSrcReg, (outs GR32:$dst), (ins GR8 :$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003807 "movz{bl|x}\t{$src, $dst|$dst, $src}",
Evan Cheng069287d2006-05-16 07:21:53 +00003808 [(set GR32:$dst, (zext GR8:$src))]>, TB;
Evan Cheng64d80e32007-07-19 01:14:50 +00003809def MOVZX32rm8 : I<0xB6, MRMSrcMem, (outs GR32:$dst), (ins i8mem :$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003810 "movz{bl|x}\t{$src, $dst|$dst, $src}",
Evan Cheng069287d2006-05-16 07:21:53 +00003811 [(set GR32:$dst, (zextloadi32i8 addr:$src))]>, TB;
Evan Cheng64d80e32007-07-19 01:14:50 +00003812def MOVZX32rr16: I<0xB7, MRMSrcReg, (outs GR32:$dst), (ins GR16:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003813 "movz{wl|x}\t{$src, $dst|$dst, $src}",
Evan Cheng069287d2006-05-16 07:21:53 +00003814 [(set GR32:$dst, (zext GR16:$src))]>, TB;
Evan Cheng64d80e32007-07-19 01:14:50 +00003815def MOVZX32rm16: I<0xB7, MRMSrcMem, (outs GR32:$dst), (ins i16mem:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003816 "movz{wl|x}\t{$src, $dst|$dst, $src}",
Evan Cheng069287d2006-05-16 07:21:53 +00003817 [(set GR32:$dst, (zextloadi32i16 addr:$src))]>, TB;
Evan Cheng7a7e8372005-12-14 02:22:27 +00003818
Dan Gohmanf451cb82010-02-10 16:03:48 +00003819// These are the same as the regular MOVZX32rr8 and MOVZX32rm8
Dan Gohman21e3dfb2009-04-13 16:09:41 +00003820// except that they use GR32_NOREX for the output operand register class
3821// instead of GR32. This allows them to operate on h registers on x86-64.
3822def MOVZX32_NOREXrr8 : I<0xB6, MRMSrcReg,
3823 (outs GR32_NOREX:$dst), (ins GR8:$src),
3824 "movz{bl|x}\t{$src, $dst|$dst, $src} # NOREX",
3825 []>, TB;
Dan Gohman78e04d42009-04-30 03:11:48 +00003826let mayLoad = 1 in
Dan Gohman21e3dfb2009-04-13 16:09:41 +00003827def MOVZX32_NOREXrm8 : I<0xB6, MRMSrcMem,
3828 (outs GR32_NOREX:$dst), (ins i8mem:$src),
3829 "movz{bl|x}\t{$src, $dst|$dst, $src} # NOREX",
3830 []>, TB;
3831
Chris Lattnerba7e7562008-01-10 07:59:24 +00003832let neverHasSideEffects = 1 in {
3833 let Defs = [AX], Uses = [AL] in
3834 def CBW : I<0x98, RawFrm, (outs), (ins),
3835 "{cbtw|cbw}", []>, OpSize; // AX = signext(AL)
3836 let Defs = [EAX], Uses = [AX] in
3837 def CWDE : I<0x98, RawFrm, (outs), (ins),
3838 "{cwtl|cwde}", []>; // EAX = signext(AX)
Evan Chengf91c1012006-05-31 22:05:11 +00003839
Chris Lattnerba7e7562008-01-10 07:59:24 +00003840 let Defs = [AX,DX], Uses = [AX] in
3841 def CWD : I<0x99, RawFrm, (outs), (ins),
3842 "{cwtd|cwd}", []>, OpSize; // DX:AX = signext(AX)
3843 let Defs = [EAX,EDX], Uses = [EAX] in
3844 def CDQ : I<0x99, RawFrm, (outs), (ins),
3845 "{cltd|cdq}", []>; // EDX:EAX = signext(EAX)
3846}
Evan Cheng747a90d2006-02-21 02:24:38 +00003847
Evan Cheng747a90d2006-02-21 02:24:38 +00003848//===----------------------------------------------------------------------===//
3849// Alias Instructions
3850//===----------------------------------------------------------------------===//
3851
3852// Alias instructions that map movr0 to xor.
3853// FIXME: remove when we can teach regalloc that xor reg, reg is ok.
Chris Lattner35e0e842010-02-05 21:21:06 +00003854// FIXME: Set encoding to pseudo.
Daniel Dunbar7417b762009-08-11 22:17:52 +00003855let Defs = [EFLAGS], isReMaterializable = 1, isAsCheapAsAMove = 1,
3856 isCodeGenOnly = 1 in {
Chris Lattner35e0e842010-02-05 21:21:06 +00003857def MOV8r0 : I<0x30, MRMInitReg, (outs GR8 :$dst), (ins), "",
Evan Cheng069287d2006-05-16 07:21:53 +00003858 [(set GR8:$dst, 0)]>;
Dan Gohmanf1b4d262010-01-12 04:42:54 +00003859
3860// We want to rewrite MOV16r0 in terms of MOV32r0, because it's a smaller
3861// encoding and avoids a partial-register update sometimes, but doing so
3862// at isel time interferes with rematerialization in the current register
3863// allocator. For now, this is rewritten when the instruction is lowered
3864// to an MCInst.
3865def MOV16r0 : I<0x31, MRMInitReg, (outs GR16:$dst), (ins),
3866 "",
3867 [(set GR16:$dst, 0)]>, OpSize;
Chris Lattner6a381822009-12-23 01:30:26 +00003868
Chris Lattner35e0e842010-02-05 21:21:06 +00003869// FIXME: Set encoding to pseudo.
3870def MOV32r0 : I<0x31, MRMInitReg, (outs GR32:$dst), (ins), "",
Chris Lattnerac105c42009-12-23 01:46:40 +00003871 [(set GR32:$dst, 0)]>;
3872}
Chris Lattner6a381822009-12-23 01:30:26 +00003873
Evan Cheng510e4782006-01-09 23:10:28 +00003874//===----------------------------------------------------------------------===//
Lauro Ramos Venanciob3a04172007-04-20 21:38:10 +00003875// Thread Local Storage Instructions
3876//
3877
Eric Christopher37106af2010-06-24 02:07:57 +00003878// ELF TLS Support
Rafael Espindola15f1b662009-04-24 12:59:40 +00003879// All calls clobber the non-callee saved registers. ESP is marked as
3880// a use to prevent stack-pointer assignments that appear immediately
3881// before calls from potentially appearing dead.
3882let Defs = [EAX, ECX, EDX, FP0, FP1, FP2, FP3, FP4, FP5, FP6, ST0,
3883 MM0, MM1, MM2, MM3, MM4, MM5, MM6, MM7,
3884 XMM0, XMM1, XMM2, XMM3, XMM4, XMM5, XMM6, XMM7,
3885 XMM8, XMM9, XMM10, XMM11, XMM12, XMM13, XMM14, XMM15, EFLAGS],
Chris Lattner5c0b16d2009-06-20 20:38:48 +00003886 Uses = [ESP] in
Chris Lattner599b5312010-07-08 23:46:44 +00003887def TLS_addr32 : I<0, Pseudo, (outs), (ins i32mem:$sym),
Chris Lattner5c0b16d2009-06-20 20:38:48 +00003888 "leal\t$sym, %eax; "
Dan Gohman4d47b9b2009-04-27 15:13:28 +00003889 "call\t___tls_get_addr@PLT",
Chris Lattner5c0b16d2009-06-20 20:38:48 +00003890 [(X86tlsaddr tls32addr:$sym)]>,
Rafael Espindola2ee3db32009-04-17 14:35:58 +00003891 Requires<[In32BitMode]>;
Lauro Ramos Venanciob3a04172007-04-20 21:38:10 +00003892
Eric Christopher37106af2010-06-24 02:07:57 +00003893// Darwin TLS Support
Eric Christopher18ebf742010-06-23 08:01:49 +00003894// For i386, the address of the thunk is passed on the stack, on return the
3895// address of the variable is in %eax. %ecx is trashed during the function
Eric Christopher749bb7e2010-06-23 20:49:35 +00003896// call. All other registers are preserved.
3897let Defs = [EAX, ECX],
3898 Uses = [ESP],
Eric Christopher30ef0e52010-06-03 04:07:48 +00003899 usesCustomInserter = 1 in
Eric Christopher54415362010-06-08 22:04:25 +00003900def TLSCall_32 : I<0, Pseudo, (outs), (ins i32mem:$sym),
Eric Christopher749bb7e2010-06-23 20:49:35 +00003901 "# TLSCall_32",
Eric Christopher54415362010-06-08 22:04:25 +00003902 [(X86TLSCall addr:$sym)]>,
Eric Christopher30ef0e52010-06-03 04:07:48 +00003903 Requires<[In32BitMode]>;
3904
Daniel Dunbar0c420fc2009-08-11 22:24:40 +00003905let AddedComplexity = 5, isCodeGenOnly = 1 in
Nate Begeman51a04372009-01-26 01:24:32 +00003906def GS_MOV32rm : I<0x8B, MRMSrcMem, (outs GR32:$dst), (ins i32mem:$src),
3907 "movl\t%gs:$src, $dst",
3908 [(set GR32:$dst, (gsload addr:$src))]>, SegGS;
3909
Daniel Dunbar0c420fc2009-08-11 22:24:40 +00003910let AddedComplexity = 5, isCodeGenOnly = 1 in
Chris Lattner1777d0c2009-05-05 18:52:19 +00003911def FS_MOV32rm : I<0x8B, MRMSrcMem, (outs GR32:$dst), (ins i32mem:$src),
3912 "movl\t%fs:$src, $dst",
3913 [(set GR32:$dst, (fsload addr:$src))]>, SegFS;
3914
Lauro Ramos Venanciob3a04172007-04-20 21:38:10 +00003915//===----------------------------------------------------------------------===//
Anton Korobeynikov2365f512007-07-14 14:06:15 +00003916// EH Pseudo Instructions
3917//
3918let isTerminator = 1, isReturn = 1, isBarrier = 1,
Daniel Dunbar1ca3a0b2009-08-27 07:58:05 +00003919 hasCtrlDep = 1, isCodeGenOnly = 1 in {
Evan Cheng64d80e32007-07-19 01:14:50 +00003920def EH_RETURN : I<0xC3, RawFrm, (outs), (ins GR32:$addr),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003921 "ret\t#eh_return, addr: $addr",
Anton Korobeynikov2365f512007-07-14 14:06:15 +00003922 [(X86ehret GR32:$addr)]>;
3923
3924}
3925
3926//===----------------------------------------------------------------------===//
Andrew Lenharthab0b9492008-02-21 06:45:13 +00003927// Atomic support
3928//
Andrew Lenharthea7da502008-03-01 13:37:02 +00003929
Eric Christopher9a9d2752010-07-22 02:48:34 +00003930// Memory barriers
3931let hasSideEffects = 1 in {
3932def Int_MemBarrier : I<0, Pseudo, (outs), (ins),
3933 "#MEMBARRIER",
3934 [(X86MemBarrier)]>, Requires<[HasSSE2]>;
3935
3936// TODO: Get this to fold the constant into the instruction.
3937let Uses = [ESP] in
3938def Int_MemBarrierNoSSE : I<0x0B, Pseudo, (outs), (ins GR32:$zero),
3939 "lock\n\t"
3940 "or{l}\t{$zero, (%esp)|(%esp), $zero}",
3941 [(X86MemBarrierNoSSE GR32:$zero)]>, LOCK;
3942}
3943
Evan Chengbb6939d2008-04-19 01:20:30 +00003944// Atomic swap. These are just normal xchg instructions. But since a memory
3945// operand is referenced, the atomicity is ensured.
Dan Gohman165660e2008-08-06 15:52:50 +00003946let Constraints = "$val = $dst" in {
Sean Callanan108934c2009-12-18 00:01:26 +00003947def XCHG32rm : I<0x87, MRMSrcMem, (outs GR32:$dst),
3948 (ins GR32:$val, i32mem:$ptr),
Evan Chengbb6939d2008-04-19 01:20:30 +00003949 "xchg{l}\t{$val, $ptr|$ptr, $val}",
3950 [(set GR32:$dst, (atomic_swap_32 addr:$ptr, GR32:$val))]>;
Sean Callanan108934c2009-12-18 00:01:26 +00003951def XCHG16rm : I<0x87, MRMSrcMem, (outs GR16:$dst),
3952 (ins GR16:$val, i16mem:$ptr),
Evan Chengbb6939d2008-04-19 01:20:30 +00003953 "xchg{w}\t{$val, $ptr|$ptr, $val}",
3954 [(set GR16:$dst, (atomic_swap_16 addr:$ptr, GR16:$val))]>,
3955 OpSize;
Sean Callanan108934c2009-12-18 00:01:26 +00003956def XCHG8rm : I<0x86, MRMSrcMem, (outs GR8:$dst), (ins GR8:$val, i8mem:$ptr),
Evan Chengbb6939d2008-04-19 01:20:30 +00003957 "xchg{b}\t{$val, $ptr|$ptr, $val}",
3958 [(set GR8:$dst, (atomic_swap_8 addr:$ptr, GR8:$val))]>;
Sean Callanan108934c2009-12-18 00:01:26 +00003959
3960def XCHG32rr : I<0x87, MRMSrcReg, (outs GR32:$dst), (ins GR32:$val, GR32:$src),
3961 "xchg{l}\t{$val, $src|$src, $val}", []>;
3962def XCHG16rr : I<0x87, MRMSrcReg, (outs GR16:$dst), (ins GR16:$val, GR16:$src),
3963 "xchg{w}\t{$val, $src|$src, $val}", []>, OpSize;
3964def XCHG8rr : I<0x86, MRMSrcReg, (outs GR8:$dst), (ins GR8:$val, GR8:$src),
3965 "xchg{b}\t{$val, $src|$src, $val}", []>;
Evan Chengbb6939d2008-04-19 01:20:30 +00003966}
3967
Sean Callanan108934c2009-12-18 00:01:26 +00003968def XCHG16ar : I<0x90, AddRegFrm, (outs), (ins GR16:$src),
3969 "xchg{w}\t{$src, %ax|%ax, $src}", []>, OpSize;
3970def XCHG32ar : I<0x90, AddRegFrm, (outs), (ins GR32:$src),
3971 "xchg{l}\t{$src, %eax|%eax, $src}", []>;
3972
Evan Cheng7e032802008-04-18 20:55:36 +00003973// Atomic compare and swap.
Andrew Lenharth26ed8692008-03-01 21:52:34 +00003974let Defs = [EAX, EFLAGS], Uses = [EAX] in {
Evan Cheng7e032802008-04-18 20:55:36 +00003975def LCMPXCHG32 : I<0xB1, MRMDestMem, (outs), (ins i32mem:$ptr, GR32:$swap),
Dan Gohman4d47b9b2009-04-27 15:13:28 +00003976 "lock\n\t"
3977 "cmpxchg{l}\t{$swap, $ptr|$ptr, $swap}",
Evan Cheng32967d22008-03-04 03:20:06 +00003978 [(X86cas addr:$ptr, GR32:$swap, 4)]>, TB, LOCK;
Andrew Lenharthea7da502008-03-01 13:37:02 +00003979}
Dale Johannesen48c1bc22008-10-02 18:53:47 +00003980let Defs = [EAX, EDX, EFLAGS], Uses = [EAX, EBX, ECX, EDX] in {
Evan Chengb093bd02010-01-08 01:29:19 +00003981def LCMPXCHG8B : I<0xC7, MRM1m, (outs), (ins i64mem:$ptr),
Dan Gohman4d47b9b2009-04-27 15:13:28 +00003982 "lock\n\t"
3983 "cmpxchg8b\t$ptr",
Andrew Lenharthd19189e2008-03-05 01:15:49 +00003984 [(X86cas8 addr:$ptr)]>, TB, LOCK;
3985}
Andrew Lenharth26ed8692008-03-01 21:52:34 +00003986
3987let Defs = [AX, EFLAGS], Uses = [AX] in {
Evan Cheng7e032802008-04-18 20:55:36 +00003988def LCMPXCHG16 : I<0xB1, MRMDestMem, (outs), (ins i16mem:$ptr, GR16:$swap),
Dan Gohman4d47b9b2009-04-27 15:13:28 +00003989 "lock\n\t"
3990 "cmpxchg{w}\t{$swap, $ptr|$ptr, $swap}",
Evan Cheng32967d22008-03-04 03:20:06 +00003991 [(X86cas addr:$ptr, GR16:$swap, 2)]>, TB, OpSize, LOCK;
Andrew Lenharthea7da502008-03-01 13:37:02 +00003992}
Andrew Lenharth26ed8692008-03-01 21:52:34 +00003993let Defs = [AL, EFLAGS], Uses = [AL] in {
Evan Cheng7e032802008-04-18 20:55:36 +00003994def LCMPXCHG8 : I<0xB0, MRMDestMem, (outs), (ins i8mem:$ptr, GR8:$swap),
Dan Gohman4d47b9b2009-04-27 15:13:28 +00003995 "lock\n\t"
3996 "cmpxchg{b}\t{$swap, $ptr|$ptr, $swap}",
Evan Cheng32967d22008-03-04 03:20:06 +00003997 [(X86cas addr:$ptr, GR8:$swap, 1)]>, TB, LOCK;
Andrew Lenharthea7da502008-03-01 13:37:02 +00003998}
3999
Evan Cheng7e032802008-04-18 20:55:36 +00004000// Atomic exchange and add
4001let Constraints = "$val = $dst", Defs = [EFLAGS] in {
Sean Callanan108934c2009-12-18 00:01:26 +00004002def LXADD32 : I<0xC1, MRMSrcMem, (outs GR32:$dst), (ins GR32:$val, i32mem:$ptr),
Dan Gohman4d47b9b2009-04-27 15:13:28 +00004003 "lock\n\t"
4004 "xadd{l}\t{$val, $ptr|$ptr, $val}",
Mon P Wang28873102008-06-25 08:15:39 +00004005 [(set GR32:$dst, (atomic_load_add_32 addr:$ptr, GR32:$val))]>,
Evan Cheng7e032802008-04-18 20:55:36 +00004006 TB, LOCK;
Sean Callanan108934c2009-12-18 00:01:26 +00004007def LXADD16 : I<0xC1, MRMSrcMem, (outs GR16:$dst), (ins GR16:$val, i16mem:$ptr),
Dan Gohman4d47b9b2009-04-27 15:13:28 +00004008 "lock\n\t"
4009 "xadd{w}\t{$val, $ptr|$ptr, $val}",
Mon P Wang28873102008-06-25 08:15:39 +00004010 [(set GR16:$dst, (atomic_load_add_16 addr:$ptr, GR16:$val))]>,
Evan Cheng7e032802008-04-18 20:55:36 +00004011 TB, OpSize, LOCK;
Sean Callanan108934c2009-12-18 00:01:26 +00004012def LXADD8 : I<0xC0, MRMSrcMem, (outs GR8:$dst), (ins GR8:$val, i8mem:$ptr),
Dan Gohman4d47b9b2009-04-27 15:13:28 +00004013 "lock\n\t"
4014 "xadd{b}\t{$val, $ptr|$ptr, $val}",
Mon P Wang28873102008-06-25 08:15:39 +00004015 [(set GR8:$dst, (atomic_load_add_8 addr:$ptr, GR8:$val))]>,
Evan Cheng7e032802008-04-18 20:55:36 +00004016 TB, LOCK;
Andrew Lenharthea7da502008-03-01 13:37:02 +00004017}
4018
Sean Callanan108934c2009-12-18 00:01:26 +00004019def XADD8rr : I<0xC0, MRMDestReg, (outs GR8:$dst), (ins GR8:$src),
4020 "xadd{b}\t{$src, $dst|$dst, $src}", []>, TB;
4021def XADD16rr : I<0xC1, MRMDestReg, (outs GR16:$dst), (ins GR16:$src),
4022 "xadd{w}\t{$src, $dst|$dst, $src}", []>, TB, OpSize;
4023def XADD32rr : I<0xC1, MRMDestReg, (outs GR32:$dst), (ins GR32:$src),
4024 "xadd{l}\t{$src, $dst|$dst, $src}", []>, TB;
4025
Dan Gohman7f357ec2010-05-14 16:34:55 +00004026let mayLoad = 1, mayStore = 1 in {
Sean Callanan108934c2009-12-18 00:01:26 +00004027def XADD8rm : I<0xC0, MRMDestMem, (outs), (ins i8mem:$dst, GR8:$src),
4028 "xadd{b}\t{$src, $dst|$dst, $src}", []>, TB;
4029def XADD16rm : I<0xC1, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src),
4030 "xadd{w}\t{$src, $dst|$dst, $src}", []>, TB, OpSize;
4031def XADD32rm : I<0xC1, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src),
4032 "xadd{l}\t{$src, $dst|$dst, $src}", []>, TB;
Dan Gohman7f357ec2010-05-14 16:34:55 +00004033}
Sean Callanan108934c2009-12-18 00:01:26 +00004034
4035def CMPXCHG8rr : I<0xB0, MRMDestReg, (outs GR8:$dst), (ins GR8:$src),
4036 "cmpxchg{b}\t{$src, $dst|$dst, $src}", []>, TB;
4037def CMPXCHG16rr : I<0xB1, MRMDestReg, (outs GR16:$dst), (ins GR16:$src),
4038 "cmpxchg{w}\t{$src, $dst|$dst, $src}", []>, TB, OpSize;
4039def CMPXCHG32rr : I<0xB1, MRMDestReg, (outs GR32:$dst), (ins GR32:$src),
4040 "cmpxchg{l}\t{$src, $dst|$dst, $src}", []>, TB;
4041
Dan Gohman7f357ec2010-05-14 16:34:55 +00004042let mayLoad = 1, mayStore = 1 in {
Sean Callanan108934c2009-12-18 00:01:26 +00004043def CMPXCHG8rm : I<0xB0, MRMDestMem, (outs), (ins i8mem:$dst, GR8:$src),
4044 "cmpxchg{b}\t{$src, $dst|$dst, $src}", []>, TB;
4045def CMPXCHG16rm : I<0xB1, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src),
4046 "cmpxchg{w}\t{$src, $dst|$dst, $src}", []>, TB, OpSize;
4047def CMPXCHG32rm : I<0xB1, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src),
4048 "cmpxchg{l}\t{$src, $dst|$dst, $src}", []>, TB;
Dan Gohman7f357ec2010-05-14 16:34:55 +00004049}
Sean Callanan108934c2009-12-18 00:01:26 +00004050
Evan Chengb093bd02010-01-08 01:29:19 +00004051let Defs = [EAX, EDX, EFLAGS], Uses = [EAX, EBX, ECX, EDX] in
Sean Callanan108934c2009-12-18 00:01:26 +00004052def CMPXCHG8B : I<0xC7, MRM1m, (outs), (ins i64mem:$dst),
4053 "cmpxchg8b\t$dst", []>, TB;
4054
Evan Cheng37b73872009-07-30 08:33:02 +00004055// Optimized codegen when the non-memory output is not used.
4056// FIXME: Use normal add / sub instructions and add lock prefix dynamically.
Dan Gohman7f357ec2010-05-14 16:34:55 +00004057let Defs = [EFLAGS], mayLoad = 1, mayStore = 1 in {
Evan Cheng37b73872009-07-30 08:33:02 +00004058def LOCK_ADD8mr : I<0x00, MRMDestMem, (outs), (ins i8mem:$dst, GR8:$src2),
4059 "lock\n\t"
4060 "add{b}\t{$src2, $dst|$dst, $src2}", []>, LOCK;
4061def LOCK_ADD16mr : I<0x01, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
4062 "lock\n\t"
4063 "add{w}\t{$src2, $dst|$dst, $src2}", []>, OpSize, LOCK;
4064def LOCK_ADD32mr : I<0x01, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
4065 "lock\n\t"
4066 "add{l}\t{$src2, $dst|$dst, $src2}", []>, LOCK;
4067def LOCK_ADD8mi : Ii8<0x80, MRM0m, (outs), (ins i8mem :$dst, i8imm :$src2),
4068 "lock\n\t"
4069 "add{b}\t{$src2, $dst|$dst, $src2}", []>, LOCK;
4070def LOCK_ADD16mi : Ii16<0x81, MRM0m, (outs), (ins i16mem:$dst, i16imm:$src2),
4071 "lock\n\t"
4072 "add{w}\t{$src2, $dst|$dst, $src2}", []>, LOCK;
4073def LOCK_ADD32mi : Ii32<0x81, MRM0m, (outs), (ins i32mem:$dst, i32imm:$src2),
4074 "lock\n\t"
4075 "add{l}\t{$src2, $dst|$dst, $src2}", []>, LOCK;
4076def LOCK_ADD16mi8 : Ii8<0x83, MRM0m, (outs), (ins i16mem:$dst, i16i8imm :$src2),
4077 "lock\n\t"
4078 "add{w}\t{$src2, $dst|$dst, $src2}", []>, OpSize, LOCK;
4079def LOCK_ADD32mi8 : Ii8<0x83, MRM0m, (outs), (ins i32mem:$dst, i32i8imm :$src2),
4080 "lock\n\t"
4081 "add{l}\t{$src2, $dst|$dst, $src2}", []>, LOCK;
4082
4083def LOCK_INC8m : I<0xFE, MRM0m, (outs), (ins i8mem :$dst),
4084 "lock\n\t"
4085 "inc{b}\t$dst", []>, LOCK;
4086def LOCK_INC16m : I<0xFF, MRM0m, (outs), (ins i16mem:$dst),
4087 "lock\n\t"
4088 "inc{w}\t$dst", []>, OpSize, LOCK;
4089def LOCK_INC32m : I<0xFF, MRM0m, (outs), (ins i32mem:$dst),
4090 "lock\n\t"
4091 "inc{l}\t$dst", []>, LOCK;
4092
4093def LOCK_SUB8mr : I<0x28, MRMDestMem, (outs), (ins i8mem :$dst, GR8 :$src2),
4094 "lock\n\t"
4095 "sub{b}\t{$src2, $dst|$dst, $src2}", []>, LOCK;
4096def LOCK_SUB16mr : I<0x29, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
4097 "lock\n\t"
4098 "sub{w}\t{$src2, $dst|$dst, $src2}", []>, OpSize, LOCK;
4099def LOCK_SUB32mr : I<0x29, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
4100 "lock\n\t"
4101 "sub{l}\t{$src2, $dst|$dst, $src2}", []>, LOCK;
4102def LOCK_SUB8mi : Ii8<0x80, MRM5m, (outs), (ins i8mem :$dst, i8imm:$src2),
4103 "lock\n\t"
4104 "sub{b}\t{$src2, $dst|$dst, $src2}", []>, LOCK;
4105def LOCK_SUB16mi : Ii16<0x81, MRM5m, (outs), (ins i16mem:$dst, i16imm:$src2),
4106 "lock\n\t"
4107 "sub{w}\t{$src2, $dst|$dst, $src2}", []>, OpSize, LOCK;
4108def LOCK_SUB32mi : Ii32<0x81, MRM5m, (outs), (ins i32mem:$dst, i32imm:$src2),
4109 "lock\n\t"
4110 "sub{l}\t{$src2, $dst|$dst, $src2}", []>, LOCK;
Sean Callanan108934c2009-12-18 00:01:26 +00004111def LOCK_SUB16mi8 : Ii8<0x83, MRM5m, (outs), (ins i16mem:$dst, i16i8imm :$src2),
Evan Cheng37b73872009-07-30 08:33:02 +00004112 "lock\n\t"
4113 "sub{w}\t{$src2, $dst|$dst, $src2}", []>, OpSize, LOCK;
4114def LOCK_SUB32mi8 : Ii8<0x83, MRM5m, (outs), (ins i32mem:$dst, i32i8imm :$src2),
4115 "lock\n\t"
4116 "sub{l}\t{$src2, $dst|$dst, $src2}", []>, LOCK;
4117
4118def LOCK_DEC8m : I<0xFE, MRM1m, (outs), (ins i8mem :$dst),
4119 "lock\n\t"
4120 "dec{b}\t$dst", []>, LOCK;
4121def LOCK_DEC16m : I<0xFF, MRM1m, (outs), (ins i16mem:$dst),
4122 "lock\n\t"
4123 "dec{w}\t$dst", []>, OpSize, LOCK;
4124def LOCK_DEC32m : I<0xFF, MRM1m, (outs), (ins i32mem:$dst),
4125 "lock\n\t"
4126 "dec{l}\t$dst", []>, LOCK;
Dan Gohmanbab42bd2009-10-20 18:14:49 +00004127}
Evan Cheng37b73872009-07-30 08:33:02 +00004128
Mon P Wang28873102008-06-25 08:15:39 +00004129// Atomic exchange, and, or, xor
Mon P Wang63307c32008-05-05 19:05:59 +00004130let Constraints = "$val = $dst", Defs = [EFLAGS],
Dan Gohman533297b2009-10-29 18:10:34 +00004131 usesCustomInserter = 1 in {
Dan Gohman9499b712008-05-12 20:22:45 +00004132def ATOMAND32 : I<0, Pseudo, (outs GR32:$dst),(ins i32mem:$ptr, GR32:$val),
Nick Lewycky6ecf5ce2008-12-07 03:49:52 +00004133 "#ATOMAND32 PSEUDO!",
Dale Johannesene00a8a22008-08-28 02:44:49 +00004134 [(set GR32:$dst, (atomic_load_and_32 addr:$ptr, GR32:$val))]>;
Dan Gohman9499b712008-05-12 20:22:45 +00004135def ATOMOR32 : I<0, Pseudo, (outs GR32:$dst),(ins i32mem:$ptr, GR32:$val),
Nick Lewycky6ecf5ce2008-12-07 03:49:52 +00004136 "#ATOMOR32 PSEUDO!",
Dale Johannesene00a8a22008-08-28 02:44:49 +00004137 [(set GR32:$dst, (atomic_load_or_32 addr:$ptr, GR32:$val))]>;
Dan Gohman9499b712008-05-12 20:22:45 +00004138def ATOMXOR32 : I<0, Pseudo,(outs GR32:$dst),(ins i32mem:$ptr, GR32:$val),
Nick Lewycky6ecf5ce2008-12-07 03:49:52 +00004139 "#ATOMXOR32 PSEUDO!",
Dale Johannesene00a8a22008-08-28 02:44:49 +00004140 [(set GR32:$dst, (atomic_load_xor_32 addr:$ptr, GR32:$val))]>;
Andrew Lenharth507a58a2008-06-14 05:48:15 +00004141def ATOMNAND32 : I<0, Pseudo,(outs GR32:$dst),(ins i32mem:$ptr, GR32:$val),
Nick Lewycky6ecf5ce2008-12-07 03:49:52 +00004142 "#ATOMNAND32 PSEUDO!",
Dale Johannesene00a8a22008-08-28 02:44:49 +00004143 [(set GR32:$dst, (atomic_load_nand_32 addr:$ptr, GR32:$val))]>;
Dan Gohman9499b712008-05-12 20:22:45 +00004144def ATOMMIN32: I<0, Pseudo, (outs GR32:$dst), (ins i32mem:$ptr, GR32:$val),
Nick Lewycky6ecf5ce2008-12-07 03:49:52 +00004145 "#ATOMMIN32 PSEUDO!",
Dale Johannesene00a8a22008-08-28 02:44:49 +00004146 [(set GR32:$dst, (atomic_load_min_32 addr:$ptr, GR32:$val))]>;
Dan Gohman9499b712008-05-12 20:22:45 +00004147def ATOMMAX32: I<0, Pseudo, (outs GR32:$dst),(ins i32mem:$ptr, GR32:$val),
Nick Lewycky6ecf5ce2008-12-07 03:49:52 +00004148 "#ATOMMAX32 PSEUDO!",
Dale Johannesene00a8a22008-08-28 02:44:49 +00004149 [(set GR32:$dst, (atomic_load_max_32 addr:$ptr, GR32:$val))]>;
Dan Gohman9499b712008-05-12 20:22:45 +00004150def ATOMUMIN32: I<0, Pseudo, (outs GR32:$dst),(ins i32mem:$ptr, GR32:$val),
Nick Lewycky6ecf5ce2008-12-07 03:49:52 +00004151 "#ATOMUMIN32 PSEUDO!",
Dale Johannesene00a8a22008-08-28 02:44:49 +00004152 [(set GR32:$dst, (atomic_load_umin_32 addr:$ptr, GR32:$val))]>;
Dan Gohman9499b712008-05-12 20:22:45 +00004153def ATOMUMAX32: I<0, Pseudo, (outs GR32:$dst),(ins i32mem:$ptr, GR32:$val),
Nick Lewycky6ecf5ce2008-12-07 03:49:52 +00004154 "#ATOMUMAX32 PSEUDO!",
Dale Johannesene00a8a22008-08-28 02:44:49 +00004155 [(set GR32:$dst, (atomic_load_umax_32 addr:$ptr, GR32:$val))]>;
Dale Johannesen140be2d2008-08-19 18:47:28 +00004156
4157def ATOMAND16 : I<0, Pseudo, (outs GR16:$dst),(ins i16mem:$ptr, GR16:$val),
Nick Lewycky6ecf5ce2008-12-07 03:49:52 +00004158 "#ATOMAND16 PSEUDO!",
Dale Johannesene00a8a22008-08-28 02:44:49 +00004159 [(set GR16:$dst, (atomic_load_and_16 addr:$ptr, GR16:$val))]>;
Dale Johannesen140be2d2008-08-19 18:47:28 +00004160def ATOMOR16 : I<0, Pseudo, (outs GR16:$dst),(ins i16mem:$ptr, GR16:$val),
Nick Lewycky6ecf5ce2008-12-07 03:49:52 +00004161 "#ATOMOR16 PSEUDO!",
Dale Johannesene00a8a22008-08-28 02:44:49 +00004162 [(set GR16:$dst, (atomic_load_or_16 addr:$ptr, GR16:$val))]>;
Dale Johannesen140be2d2008-08-19 18:47:28 +00004163def ATOMXOR16 : I<0, Pseudo,(outs GR16:$dst),(ins i16mem:$ptr, GR16:$val),
Nick Lewycky6ecf5ce2008-12-07 03:49:52 +00004164 "#ATOMXOR16 PSEUDO!",
Dale Johannesene00a8a22008-08-28 02:44:49 +00004165 [(set GR16:$dst, (atomic_load_xor_16 addr:$ptr, GR16:$val))]>;
Dale Johannesen140be2d2008-08-19 18:47:28 +00004166def ATOMNAND16 : I<0, Pseudo,(outs GR16:$dst),(ins i16mem:$ptr, GR16:$val),
Nick Lewycky6ecf5ce2008-12-07 03:49:52 +00004167 "#ATOMNAND16 PSEUDO!",
Dale Johannesene00a8a22008-08-28 02:44:49 +00004168 [(set GR16:$dst, (atomic_load_nand_16 addr:$ptr, GR16:$val))]>;
Dale Johannesen140be2d2008-08-19 18:47:28 +00004169def ATOMMIN16: I<0, Pseudo, (outs GR16:$dst), (ins i16mem:$ptr, GR16:$val),
Nick Lewycky6ecf5ce2008-12-07 03:49:52 +00004170 "#ATOMMIN16 PSEUDO!",
Dale Johannesene00a8a22008-08-28 02:44:49 +00004171 [(set GR16:$dst, (atomic_load_min_16 addr:$ptr, GR16:$val))]>;
Dale Johannesen140be2d2008-08-19 18:47:28 +00004172def ATOMMAX16: I<0, Pseudo, (outs GR16:$dst),(ins i16mem:$ptr, GR16:$val),
Nick Lewycky6ecf5ce2008-12-07 03:49:52 +00004173 "#ATOMMAX16 PSEUDO!",
Dale Johannesene00a8a22008-08-28 02:44:49 +00004174 [(set GR16:$dst, (atomic_load_max_16 addr:$ptr, GR16:$val))]>;
Dale Johannesen140be2d2008-08-19 18:47:28 +00004175def ATOMUMIN16: I<0, Pseudo, (outs GR16:$dst),(ins i16mem:$ptr, GR16:$val),
Nick Lewycky6ecf5ce2008-12-07 03:49:52 +00004176 "#ATOMUMIN16 PSEUDO!",
Dale Johannesene00a8a22008-08-28 02:44:49 +00004177 [(set GR16:$dst, (atomic_load_umin_16 addr:$ptr, GR16:$val))]>;
Dale Johannesen140be2d2008-08-19 18:47:28 +00004178def ATOMUMAX16: I<0, Pseudo, (outs GR16:$dst),(ins i16mem:$ptr, GR16:$val),
Nick Lewycky6ecf5ce2008-12-07 03:49:52 +00004179 "#ATOMUMAX16 PSEUDO!",
Dale Johannesene00a8a22008-08-28 02:44:49 +00004180 [(set GR16:$dst, (atomic_load_umax_16 addr:$ptr, GR16:$val))]>;
Dale Johannesen140be2d2008-08-19 18:47:28 +00004181
4182def ATOMAND8 : I<0, Pseudo, (outs GR8:$dst),(ins i8mem:$ptr, GR8:$val),
Nick Lewycky6ecf5ce2008-12-07 03:49:52 +00004183 "#ATOMAND8 PSEUDO!",
Dale Johannesene00a8a22008-08-28 02:44:49 +00004184 [(set GR8:$dst, (atomic_load_and_8 addr:$ptr, GR8:$val))]>;
Dale Johannesen140be2d2008-08-19 18:47:28 +00004185def ATOMOR8 : I<0, Pseudo, (outs GR8:$dst),(ins i8mem:$ptr, GR8:$val),
Nick Lewycky6ecf5ce2008-12-07 03:49:52 +00004186 "#ATOMOR8 PSEUDO!",
Dale Johannesene00a8a22008-08-28 02:44:49 +00004187 [(set GR8:$dst, (atomic_load_or_8 addr:$ptr, GR8:$val))]>;
Dale Johannesen140be2d2008-08-19 18:47:28 +00004188def ATOMXOR8 : I<0, Pseudo,(outs GR8:$dst),(ins i8mem:$ptr, GR8:$val),
Nick Lewycky6ecf5ce2008-12-07 03:49:52 +00004189 "#ATOMXOR8 PSEUDO!",
Dale Johannesene00a8a22008-08-28 02:44:49 +00004190 [(set GR8:$dst, (atomic_load_xor_8 addr:$ptr, GR8:$val))]>;
Dale Johannesen140be2d2008-08-19 18:47:28 +00004191def ATOMNAND8 : I<0, Pseudo,(outs GR8:$dst),(ins i8mem:$ptr, GR8:$val),
Nick Lewycky6ecf5ce2008-12-07 03:49:52 +00004192 "#ATOMNAND8 PSEUDO!",
Dale Johannesene00a8a22008-08-28 02:44:49 +00004193 [(set GR8:$dst, (atomic_load_nand_8 addr:$ptr, GR8:$val))]>;
Mon P Wang63307c32008-05-05 19:05:59 +00004194}
4195
Dale Johannesen48c1bc22008-10-02 18:53:47 +00004196let Constraints = "$val1 = $dst1, $val2 = $dst2",
4197 Defs = [EFLAGS, EAX, EBX, ECX, EDX],
4198 Uses = [EAX, EBX, ECX, EDX],
Dale Johannesen1b54c7f2008-10-03 19:41:08 +00004199 mayLoad = 1, mayStore = 1,
Dan Gohman533297b2009-10-29 18:10:34 +00004200 usesCustomInserter = 1 in {
Dale Johannesen48c1bc22008-10-02 18:53:47 +00004201def ATOMAND6432 : I<0, Pseudo, (outs GR32:$dst1, GR32:$dst2),
4202 (ins i64mem:$ptr, GR32:$val1, GR32:$val2),
Nick Lewycky6ecf5ce2008-12-07 03:49:52 +00004203 "#ATOMAND6432 PSEUDO!", []>;
Dale Johannesen48c1bc22008-10-02 18:53:47 +00004204def ATOMOR6432 : I<0, Pseudo, (outs GR32:$dst1, GR32:$dst2),
4205 (ins i64mem:$ptr, GR32:$val1, GR32:$val2),
Nick Lewycky6ecf5ce2008-12-07 03:49:52 +00004206 "#ATOMOR6432 PSEUDO!", []>;
Dale Johannesen48c1bc22008-10-02 18:53:47 +00004207def ATOMXOR6432 : I<0, Pseudo, (outs GR32:$dst1, GR32:$dst2),
4208 (ins i64mem:$ptr, GR32:$val1, GR32:$val2),
Nick Lewycky6ecf5ce2008-12-07 03:49:52 +00004209 "#ATOMXOR6432 PSEUDO!", []>;
Dale Johannesen48c1bc22008-10-02 18:53:47 +00004210def ATOMNAND6432 : I<0, Pseudo, (outs GR32:$dst1, GR32:$dst2),
4211 (ins i64mem:$ptr, GR32:$val1, GR32:$val2),
Nick Lewycky6ecf5ce2008-12-07 03:49:52 +00004212 "#ATOMNAND6432 PSEUDO!", []>;
Dale Johannesen48c1bc22008-10-02 18:53:47 +00004213def ATOMADD6432 : I<0, Pseudo, (outs GR32:$dst1, GR32:$dst2),
4214 (ins i64mem:$ptr, GR32:$val1, GR32:$val2),
Nick Lewycky6ecf5ce2008-12-07 03:49:52 +00004215 "#ATOMADD6432 PSEUDO!", []>;
Dale Johannesen48c1bc22008-10-02 18:53:47 +00004216def ATOMSUB6432 : I<0, Pseudo, (outs GR32:$dst1, GR32:$dst2),
4217 (ins i64mem:$ptr, GR32:$val1, GR32:$val2),
Nick Lewycky6ecf5ce2008-12-07 03:49:52 +00004218 "#ATOMSUB6432 PSEUDO!", []>;
Dale Johannesen880ae362008-10-03 22:25:52 +00004219def ATOMSWAP6432 : I<0, Pseudo, (outs GR32:$dst1, GR32:$dst2),
4220 (ins i64mem:$ptr, GR32:$val1, GR32:$val2),
Nick Lewycky6ecf5ce2008-12-07 03:49:52 +00004221 "#ATOMSWAP6432 PSEUDO!", []>;
Dale Johannesen48c1bc22008-10-02 18:53:47 +00004222}
4223
Sean Callanan358f1ef2009-09-16 21:55:34 +00004224// Segmentation support instructions.
4225
4226def LAR16rm : I<0x02, MRMSrcMem, (outs GR16:$dst), (ins i16mem:$src),
4227 "lar{w}\t{$src, $dst|$dst, $src}", []>, TB, OpSize;
4228def LAR16rr : I<0x02, MRMSrcReg, (outs GR16:$dst), (ins GR16:$src),
4229 "lar{w}\t{$src, $dst|$dst, $src}", []>, TB, OpSize;
4230
4231// i16mem operand in LAR32rm and GR32 operand in LAR32rr is not a typo.
4232def LAR32rm : I<0x02, MRMSrcMem, (outs GR32:$dst), (ins i16mem:$src),
4233 "lar{l}\t{$src, $dst|$dst, $src}", []>, TB;
4234def LAR32rr : I<0x02, MRMSrcReg, (outs GR32:$dst), (ins GR32:$src),
4235 "lar{l}\t{$src, $dst|$dst, $src}", []>, TB;
Sean Callanan108934c2009-12-18 00:01:26 +00004236
4237def LSL16rm : I<0x03, MRMSrcMem, (outs GR16:$dst), (ins i16mem:$src),
4238 "lsl{w}\t{$src, $dst|$dst, $src}", []>, TB, OpSize;
4239def LSL16rr : I<0x03, MRMSrcReg, (outs GR16:$dst), (ins GR16:$src),
4240 "lsl{w}\t{$src, $dst|$dst, $src}", []>, TB, OpSize;
4241def LSL32rm : I<0x03, MRMSrcMem, (outs GR32:$dst), (ins i32mem:$src),
4242 "lsl{l}\t{$src, $dst|$dst, $src}", []>, TB;
4243def LSL32rr : I<0x03, MRMSrcReg, (outs GR32:$dst), (ins GR32:$src),
4244 "lsl{l}\t{$src, $dst|$dst, $src}", []>, TB;
4245
Sean Callanan95a5a7d2010-02-13 01:48:34 +00004246def INVLPG : I<0x01, MRM7m, (outs), (ins i8mem:$addr), "invlpg\t$addr", []>, TB;
Sean Callanan108934c2009-12-18 00:01:26 +00004247
4248def STRr : I<0x00, MRM1r, (outs GR16:$dst), (ins),
4249 "str{w}\t{$dst}", []>, TB;
4250def STRm : I<0x00, MRM1m, (outs i16mem:$dst), (ins),
4251 "str{w}\t{$dst}", []>, TB;
4252def LTRr : I<0x00, MRM3r, (outs), (ins GR16:$src),
4253 "ltr{w}\t{$src}", []>, TB;
4254def LTRm : I<0x00, MRM3m, (outs), (ins i16mem:$src),
4255 "ltr{w}\t{$src}", []>, TB;
4256
4257def PUSHFS16 : I<0xa0, RawFrm, (outs), (ins),
4258 "push{w}\t%fs", []>, OpSize, TB;
4259def PUSHFS32 : I<0xa0, RawFrm, (outs), (ins),
4260 "push{l}\t%fs", []>, TB;
4261def PUSHGS16 : I<0xa8, RawFrm, (outs), (ins),
4262 "push{w}\t%gs", []>, OpSize, TB;
4263def PUSHGS32 : I<0xa8, RawFrm, (outs), (ins),
4264 "push{l}\t%gs", []>, TB;
4265
4266def POPFS16 : I<0xa1, RawFrm, (outs), (ins),
4267 "pop{w}\t%fs", []>, OpSize, TB;
4268def POPFS32 : I<0xa1, RawFrm, (outs), (ins),
4269 "pop{l}\t%fs", []>, TB;
4270def POPGS16 : I<0xa9, RawFrm, (outs), (ins),
4271 "pop{w}\t%gs", []>, OpSize, TB;
4272def POPGS32 : I<0xa9, RawFrm, (outs), (ins),
4273 "pop{l}\t%gs", []>, TB;
4274
4275def LDS16rm : I<0xc5, MRMSrcMem, (outs GR16:$dst), (ins opaque32mem:$src),
4276 "lds{w}\t{$src, $dst|$dst, $src}", []>, OpSize;
4277def LDS32rm : I<0xc5, MRMSrcMem, (outs GR32:$dst), (ins opaque48mem:$src),
4278 "lds{l}\t{$src, $dst|$dst, $src}", []>;
4279def LSS16rm : I<0xb2, MRMSrcMem, (outs GR16:$dst), (ins opaque32mem:$src),
4280 "lss{w}\t{$src, $dst|$dst, $src}", []>, TB, OpSize;
4281def LSS32rm : I<0xb2, MRMSrcMem, (outs GR32:$dst), (ins opaque48mem:$src),
4282 "lss{l}\t{$src, $dst|$dst, $src}", []>, TB;
4283def LES16rm : I<0xc4, MRMSrcMem, (outs GR16:$dst), (ins opaque32mem:$src),
4284 "les{w}\t{$src, $dst|$dst, $src}", []>, OpSize;
4285def LES32rm : I<0xc4, MRMSrcMem, (outs GR32:$dst), (ins opaque48mem:$src),
4286 "les{l}\t{$src, $dst|$dst, $src}", []>;
4287def LFS16rm : I<0xb4, MRMSrcMem, (outs GR16:$dst), (ins opaque32mem:$src),
4288 "lfs{w}\t{$src, $dst|$dst, $src}", []>, TB, OpSize;
4289def LFS32rm : I<0xb4, MRMSrcMem, (outs GR32:$dst), (ins opaque48mem:$src),
4290 "lfs{l}\t{$src, $dst|$dst, $src}", []>, TB;
4291def LGS16rm : I<0xb5, MRMSrcMem, (outs GR16:$dst), (ins opaque32mem:$src),
4292 "lgs{w}\t{$src, $dst|$dst, $src}", []>, TB, OpSize;
4293def LGS32rm : I<0xb5, MRMSrcMem, (outs GR32:$dst), (ins opaque48mem:$src),
4294 "lgs{l}\t{$src, $dst|$dst, $src}", []>, TB;
4295
4296def VERRr : I<0x00, MRM4r, (outs), (ins GR16:$seg),
4297 "verr\t$seg", []>, TB;
4298def VERRm : I<0x00, MRM4m, (outs), (ins i16mem:$seg),
4299 "verr\t$seg", []>, TB;
4300def VERWr : I<0x00, MRM5r, (outs), (ins GR16:$seg),
4301 "verw\t$seg", []>, TB;
4302def VERWm : I<0x00, MRM5m, (outs), (ins i16mem:$seg),
4303 "verw\t$seg", []>, TB;
4304
4305// Descriptor-table support instructions
4306
4307def SGDTm : I<0x01, MRM0m, (outs opaque48mem:$dst), (ins),
4308 "sgdt\t$dst", []>, TB;
4309def SIDTm : I<0x01, MRM1m, (outs opaque48mem:$dst), (ins),
4310 "sidt\t$dst", []>, TB;
4311def SLDT16r : I<0x00, MRM0r, (outs GR16:$dst), (ins),
4312 "sldt{w}\t$dst", []>, TB;
4313def SLDT16m : I<0x00, MRM0m, (outs i16mem:$dst), (ins),
4314 "sldt{w}\t$dst", []>, TB;
4315def LGDTm : I<0x01, MRM2m, (outs), (ins opaque48mem:$src),
4316 "lgdt\t$src", []>, TB;
4317def LIDTm : I<0x01, MRM3m, (outs), (ins opaque48mem:$src),
4318 "lidt\t$src", []>, TB;
4319def LLDT16r : I<0x00, MRM2r, (outs), (ins GR16:$src),
4320 "lldt{w}\t$src", []>, TB;
4321def LLDT16m : I<0x00, MRM2m, (outs), (ins i16mem:$src),
4322 "lldt{w}\t$src", []>, TB;
Sean Callanan9a86f102009-09-16 22:59:28 +00004323
Kevin Enderby12ce0de2010-02-03 21:04:42 +00004324// Lock instruction prefix
4325def LOCK_PREFIX : I<0xF0, RawFrm, (outs), (ins), "lock", []>;
4326
4327// Repeat string operation instruction prefixes
4328// These uses the DF flag in the EFLAGS register to inc or dec ECX
4329let Defs = [ECX], Uses = [ECX,EFLAGS] in {
4330// Repeat (used with INS, OUTS, MOVS, LODS and STOS)
4331def REP_PREFIX : I<0xF3, RawFrm, (outs), (ins), "rep", []>;
4332// Repeat while not equal (used with CMPS and SCAS)
4333def REPNE_PREFIX : I<0xF2, RawFrm, (outs), (ins), "repne", []>;
4334}
4335
4336// Segment override instruction prefixes
4337def CS_PREFIX : I<0x2E, RawFrm, (outs), (ins), "cs", []>;
4338def SS_PREFIX : I<0x36, RawFrm, (outs), (ins), "ss", []>;
4339def DS_PREFIX : I<0x3E, RawFrm, (outs), (ins), "ds", []>;
4340def ES_PREFIX : I<0x26, RawFrm, (outs), (ins), "es", []>;
4341def FS_PREFIX : I<0x64, RawFrm, (outs), (ins), "fs", []>;
4342def GS_PREFIX : I<0x65, RawFrm, (outs), (ins), "gs", []>;
4343
Sean Callanan9a86f102009-09-16 22:59:28 +00004344// String manipulation instructions
4345
4346def LODSB : I<0xAC, RawFrm, (outs), (ins), "lodsb", []>;
4347def LODSW : I<0xAD, RawFrm, (outs), (ins), "lodsw", []>, OpSize;
Sean Callanan108934c2009-12-18 00:01:26 +00004348def LODSD : I<0xAD, RawFrm, (outs), (ins), "lods{l|d}", []>;
4349
4350def OUTSB : I<0x6E, RawFrm, (outs), (ins), "outsb", []>;
4351def OUTSW : I<0x6F, RawFrm, (outs), (ins), "outsw", []>, OpSize;
4352def OUTSD : I<0x6F, RawFrm, (outs), (ins), "outs{l|d}", []>;
4353
4354// CPU flow control instructions
4355
4356def HLT : I<0xF4, RawFrm, (outs), (ins), "hlt", []>;
4357def RSM : I<0xAA, RawFrm, (outs), (ins), "rsm", []>, TB;
4358
4359// FPU control instructions
4360
4361def FNINIT : I<0xE3, RawFrm, (outs), (ins), "fninit", []>, DB;
4362
4363// Flag instructions
4364
4365def CLC : I<0xF8, RawFrm, (outs), (ins), "clc", []>;
4366def STC : I<0xF9, RawFrm, (outs), (ins), "stc", []>;
4367def CLI : I<0xFA, RawFrm, (outs), (ins), "cli", []>;
4368def STI : I<0xFB, RawFrm, (outs), (ins), "sti", []>;
4369def CLD : I<0xFC, RawFrm, (outs), (ins), "cld", []>;
4370def STD : I<0xFD, RawFrm, (outs), (ins), "std", []>;
4371def CMC : I<0xF5, RawFrm, (outs), (ins), "cmc", []>;
4372
4373def CLTS : I<0x06, RawFrm, (outs), (ins), "clts", []>, TB;
4374
4375// Table lookup instructions
4376
4377def XLAT : I<0xD7, RawFrm, (outs), (ins), "xlatb", []>;
4378
4379// Specialized register support
4380
4381def WRMSR : I<0x30, RawFrm, (outs), (ins), "wrmsr", []>, TB;
4382def RDMSR : I<0x32, RawFrm, (outs), (ins), "rdmsr", []>, TB;
4383def RDPMC : I<0x33, RawFrm, (outs), (ins), "rdpmc", []>, TB;
4384
4385def SMSW16r : I<0x01, MRM4r, (outs GR16:$dst), (ins),
4386 "smsw{w}\t$dst", []>, OpSize, TB;
4387def SMSW32r : I<0x01, MRM4r, (outs GR32:$dst), (ins),
4388 "smsw{l}\t$dst", []>, TB;
4389// For memory operands, there is only a 16-bit form
4390def SMSW16m : I<0x01, MRM4m, (outs i16mem:$dst), (ins),
4391 "smsw{w}\t$dst", []>, TB;
4392
4393def LMSW16r : I<0x01, MRM6r, (outs), (ins GR16:$src),
4394 "lmsw{w}\t$src", []>, TB;
4395def LMSW16m : I<0x01, MRM6m, (outs), (ins i16mem:$src),
4396 "lmsw{w}\t$src", []>, TB;
4397
4398def CPUID : I<0xA2, RawFrm, (outs), (ins), "cpuid", []>, TB;
4399
4400// Cache instructions
4401
4402def INVD : I<0x08, RawFrm, (outs), (ins), "invd", []>, TB;
4403def WBINVD : I<0x09, RawFrm, (outs), (ins), "wbinvd", []>, TB;
4404
4405// VMX instructions
4406
4407// 66 0F 38 80
Sean Callanan95a5a7d2010-02-13 01:48:34 +00004408def INVEPT : I<0x80, RawFrm, (outs), (ins), "invept", []>, OpSize, T8;
Sean Callanan108934c2009-12-18 00:01:26 +00004409// 66 0F 38 81
Sean Callanan95a5a7d2010-02-13 01:48:34 +00004410def INVVPID : I<0x81, RawFrm, (outs), (ins), "invvpid", []>, OpSize, T8;
Sean Callanan108934c2009-12-18 00:01:26 +00004411// 0F 01 C1
Chris Lattnerfdfeb692010-02-12 20:49:41 +00004412def VMCALL : I<0x01, MRM_C1, (outs), (ins), "vmcall", []>, TB;
Sean Callanan108934c2009-12-18 00:01:26 +00004413def VMCLEARm : I<0xC7, MRM6m, (outs), (ins i64mem:$vmcs),
4414 "vmclear\t$vmcs", []>, OpSize, TB;
4415// 0F 01 C2
Chris Lattnera599de22010-02-13 00:41:14 +00004416def VMLAUNCH : I<0x01, MRM_C2, (outs), (ins), "vmlaunch", []>, TB;
Sean Callanan108934c2009-12-18 00:01:26 +00004417// 0F 01 C3
Chris Lattnera599de22010-02-13 00:41:14 +00004418def VMRESUME : I<0x01, MRM_C3, (outs), (ins), "vmresume", []>, TB;
Sean Callanan108934c2009-12-18 00:01:26 +00004419def VMPTRLDm : I<0xC7, MRM6m, (outs), (ins i64mem:$vmcs),
4420 "vmptrld\t$vmcs", []>, TB;
4421def VMPTRSTm : I<0xC7, MRM7m, (outs i64mem:$vmcs), (ins),
4422 "vmptrst\t$vmcs", []>, TB;
4423def VMREAD64rm : I<0x78, MRMDestMem, (outs i64mem:$dst), (ins GR64:$src),
4424 "vmread{q}\t{$src, $dst|$dst, $src}", []>, TB;
4425def VMREAD64rr : I<0x78, MRMDestReg, (outs GR64:$dst), (ins GR64:$src),
4426 "vmread{q}\t{$src, $dst|$dst, $src}", []>, TB;
4427def VMREAD32rm : I<0x78, MRMDestMem, (outs i32mem:$dst), (ins GR32:$src),
4428 "vmread{l}\t{$src, $dst|$dst, $src}", []>, TB;
4429def VMREAD32rr : I<0x78, MRMDestReg, (outs GR32:$dst), (ins GR32:$src),
4430 "vmread{l}\t{$src, $dst|$dst, $src}", []>, TB;
4431def VMWRITE64rm : I<0x79, MRMSrcMem, (outs GR64:$dst), (ins i64mem:$src),
4432 "vmwrite{q}\t{$src, $dst|$dst, $src}", []>, TB;
4433def VMWRITE64rr : I<0x79, MRMSrcReg, (outs GR64:$dst), (ins GR64:$src),
4434 "vmwrite{q}\t{$src, $dst|$dst, $src}", []>, TB;
4435def VMWRITE32rm : I<0x79, MRMSrcMem, (outs GR32:$dst), (ins i32mem:$src),
4436 "vmwrite{l}\t{$src, $dst|$dst, $src}", []>, TB;
4437def VMWRITE32rr : I<0x79, MRMSrcReg, (outs GR32:$dst), (ins GR32:$src),
4438 "vmwrite{l}\t{$src, $dst|$dst, $src}", []>, TB;
4439// 0F 01 C4
Chris Lattnera599de22010-02-13 00:41:14 +00004440def VMXOFF : I<0x01, MRM_C4, (outs), (ins), "vmxoff", []>, TB;
Sean Callanan108934c2009-12-18 00:01:26 +00004441def VMXON : I<0xC7, MRM6m, (outs), (ins i64mem:$vmxon),
Kevin Enderby0e822402010-03-08 22:17:26 +00004442 "vmxon\t{$vmxon}", []>, XS;
Sean Callanan358f1ef2009-09-16 21:55:34 +00004443
Andrew Lenharthab0b9492008-02-21 06:45:13 +00004444//===----------------------------------------------------------------------===//
Evan Cheng510e4782006-01-09 23:10:28 +00004445// Non-Instruction Patterns
4446//===----------------------------------------------------------------------===//
4447
Bill Wendling056292f2008-09-16 21:48:12 +00004448// ConstantPool GlobalAddress, ExternalSymbol, and JumpTable
Evan Cheng71fb8342006-02-25 10:02:21 +00004449def : Pat<(i32 (X86Wrapper tconstpool :$dst)), (MOV32ri tconstpool :$dst)>;
Nate Begeman37efe672006-04-22 18:53:45 +00004450def : Pat<(i32 (X86Wrapper tjumptable :$dst)), (MOV32ri tjumptable :$dst)>;
Nate Begeman6795ebb2008-04-12 00:47:57 +00004451def : Pat<(i32 (X86Wrapper tglobaltlsaddr:$dst)),(MOV32ri tglobaltlsaddr:$dst)>;
Evan Cheng71fb8342006-02-25 10:02:21 +00004452def : Pat<(i32 (X86Wrapper tglobaladdr :$dst)), (MOV32ri tglobaladdr :$dst)>;
4453def : Pat<(i32 (X86Wrapper texternalsym:$dst)), (MOV32ri texternalsym:$dst)>;
Dan Gohmanf705adb2009-10-30 01:28:02 +00004454def : Pat<(i32 (X86Wrapper tblockaddress:$dst)), (MOV32ri tblockaddress:$dst)>;
Evan Cheng71fb8342006-02-25 10:02:21 +00004455
Evan Cheng069287d2006-05-16 07:21:53 +00004456def : Pat<(add GR32:$src1, (X86Wrapper tconstpool:$src2)),
4457 (ADD32ri GR32:$src1, tconstpool:$src2)>;
4458def : Pat<(add GR32:$src1, (X86Wrapper tjumptable:$src2)),
4459 (ADD32ri GR32:$src1, tjumptable:$src2)>;
4460def : Pat<(add GR32:$src1, (X86Wrapper tglobaladdr :$src2)),
4461 (ADD32ri GR32:$src1, tglobaladdr:$src2)>;
4462def : Pat<(add GR32:$src1, (X86Wrapper texternalsym:$src2)),
4463 (ADD32ri GR32:$src1, texternalsym:$src2)>;
Dan Gohmanf705adb2009-10-30 01:28:02 +00004464def : Pat<(add GR32:$src1, (X86Wrapper tblockaddress:$src2)),
4465 (ADD32ri GR32:$src1, tblockaddress:$src2)>;
Evan Cheng71fb8342006-02-25 10:02:21 +00004466
Evan Chengfc8feb12006-05-19 07:30:36 +00004467def : Pat<(store (i32 (X86Wrapper tglobaladdr:$src)), addr:$dst),
Evan Cheng71fb8342006-02-25 10:02:21 +00004468 (MOV32mi addr:$dst, tglobaladdr:$src)>;
Evan Chengfc8feb12006-05-19 07:30:36 +00004469def : Pat<(store (i32 (X86Wrapper texternalsym:$src)), addr:$dst),
Evan Cheng71fb8342006-02-25 10:02:21 +00004470 (MOV32mi addr:$dst, texternalsym:$src)>;
Dan Gohmanf705adb2009-10-30 01:28:02 +00004471def : Pat<(store (i32 (X86Wrapper tblockaddress:$src)), addr:$dst),
4472 (MOV32mi addr:$dst, tblockaddress:$src)>;
Evan Cheng71fb8342006-02-25 10:02:21 +00004473
Evan Cheng510e4782006-01-09 23:10:28 +00004474// Calls
Arnold Schwaighoferc85e1712007-10-11 19:40:01 +00004475// tailcall stuff
Evan Chengf48ef032010-03-14 03:48:46 +00004476def : Pat<(X86tcret GR32_TC:$dst, imm:$off),
4477 (TCRETURNri GR32_TC:$dst, imm:$off)>,
4478 Requires<[In32BitMode]>;
4479
Evan Chengcb0f06e2010-03-25 00:10:31 +00004480// FIXME: This is disabled for 32-bit PIC mode because the global base
4481// register which is part of the address mode may be assigned a
4482// callee-saved register.
Evan Chengf48ef032010-03-14 03:48:46 +00004483def : Pat<(X86tcret (load addr:$dst), imm:$off),
4484 (TCRETURNmi addr:$dst, imm:$off)>,
Evan Chengcb0f06e2010-03-25 00:10:31 +00004485 Requires<[In32BitMode, IsNotPIC]>;
Arnold Schwaighoferc85e1712007-10-11 19:40:01 +00004486
4487def : Pat<(X86tcret (i32 tglobaladdr:$dst), imm:$off),
Evan Chengf48ef032010-03-14 03:48:46 +00004488 (TCRETURNdi texternalsym:$dst, imm:$off)>,
4489 Requires<[In32BitMode]>;
Arnold Schwaighoferc85e1712007-10-11 19:40:01 +00004490
4491def : Pat<(X86tcret (i32 texternalsym:$dst), imm:$off),
Evan Chengf48ef032010-03-14 03:48:46 +00004492 (TCRETURNdi texternalsym:$dst, imm:$off)>,
4493 Requires<[In32BitMode]>;
Evan Chengfea89c12006-04-27 08:40:39 +00004494
Dan Gohmancadb2262009-08-02 16:10:01 +00004495// Normal calls, with various flavors of addresses.
Evan Cheng25ab6902006-09-08 06:48:29 +00004496def : Pat<(X86call (i32 tglobaladdr:$dst)),
Evan Cheng510e4782006-01-09 23:10:28 +00004497 (CALLpcrel32 tglobaladdr:$dst)>;
Evan Cheng25ab6902006-09-08 06:48:29 +00004498def : Pat<(X86call (i32 texternalsym:$dst)),
Evan Cheng8700e142006-01-11 06:09:51 +00004499 (CALLpcrel32 texternalsym:$dst)>;
Evan Chengd7f666a2009-05-20 04:53:57 +00004500def : Pat<(X86call (i32 imm:$dst)),
4501 (CALLpcrel32 imm:$dst)>, Requires<[CallImmAddr]>;
Evan Cheng510e4782006-01-09 23:10:28 +00004502
4503// X86 specific add which produces a flag.
Evan Cheng069287d2006-05-16 07:21:53 +00004504def : Pat<(addc GR32:$src1, GR32:$src2),
4505 (ADD32rr GR32:$src1, GR32:$src2)>;
4506def : Pat<(addc GR32:$src1, (load addr:$src2)),
4507 (ADD32rm GR32:$src1, addr:$src2)>;
4508def : Pat<(addc GR32:$src1, imm:$src2),
4509 (ADD32ri GR32:$src1, imm:$src2)>;
4510def : Pat<(addc GR32:$src1, i32immSExt8:$src2),
4511 (ADD32ri8 GR32:$src1, i32immSExt8:$src2)>;
Evan Cheng510e4782006-01-09 23:10:28 +00004512
Evan Cheng069287d2006-05-16 07:21:53 +00004513def : Pat<(subc GR32:$src1, GR32:$src2),
4514 (SUB32rr GR32:$src1, GR32:$src2)>;
4515def : Pat<(subc GR32:$src1, (load addr:$src2)),
4516 (SUB32rm GR32:$src1, addr:$src2)>;
4517def : Pat<(subc GR32:$src1, imm:$src2),
4518 (SUB32ri GR32:$src1, imm:$src2)>;
4519def : Pat<(subc GR32:$src1, i32immSExt8:$src2),
4520 (SUB32ri8 GR32:$src1, i32immSExt8:$src2)>;
Evan Cheng510e4782006-01-09 23:10:28 +00004521
Chris Lattnerffc0b262006-09-07 20:33:45 +00004522// Comparisons.
4523
4524// TEST R,R is smaller than CMP R,0
Chris Lattnere3486a42010-03-19 00:01:11 +00004525def : Pat<(X86cmp GR8:$src1, 0),
Chris Lattnerffc0b262006-09-07 20:33:45 +00004526 (TEST8rr GR8:$src1, GR8:$src1)>;
Chris Lattnere3486a42010-03-19 00:01:11 +00004527def : Pat<(X86cmp GR16:$src1, 0),
Chris Lattnerffc0b262006-09-07 20:33:45 +00004528 (TEST16rr GR16:$src1, GR16:$src1)>;
Chris Lattnere3486a42010-03-19 00:01:11 +00004529def : Pat<(X86cmp GR32:$src1, 0),
Chris Lattnerffc0b262006-09-07 20:33:45 +00004530 (TEST32rr GR32:$src1, GR32:$src1)>;
4531
Dan Gohmanfbb74862009-01-07 01:00:24 +00004532// Conditional moves with folded loads with operands swapped and conditions
4533// inverted.
4534def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_B, EFLAGS),
4535 (CMOVAE16rm GR16:$src2, addr:$src1)>;
4536def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_B, EFLAGS),
4537 (CMOVAE32rm GR32:$src2, addr:$src1)>;
4538def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_AE, EFLAGS),
4539 (CMOVB16rm GR16:$src2, addr:$src1)>;
4540def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_AE, EFLAGS),
4541 (CMOVB32rm GR32:$src2, addr:$src1)>;
4542def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_E, EFLAGS),
4543 (CMOVNE16rm GR16:$src2, addr:$src1)>;
4544def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_E, EFLAGS),
4545 (CMOVNE32rm GR32:$src2, addr:$src1)>;
4546def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_NE, EFLAGS),
4547 (CMOVE16rm GR16:$src2, addr:$src1)>;
4548def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_NE, EFLAGS),
4549 (CMOVE32rm GR32:$src2, addr:$src1)>;
4550def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_BE, EFLAGS),
4551 (CMOVA16rm GR16:$src2, addr:$src1)>;
4552def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_BE, EFLAGS),
4553 (CMOVA32rm GR32:$src2, addr:$src1)>;
4554def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_A, EFLAGS),
4555 (CMOVBE16rm GR16:$src2, addr:$src1)>;
4556def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_A, EFLAGS),
4557 (CMOVBE32rm GR32:$src2, addr:$src1)>;
4558def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_L, EFLAGS),
4559 (CMOVGE16rm GR16:$src2, addr:$src1)>;
4560def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_L, EFLAGS),
4561 (CMOVGE32rm GR32:$src2, addr:$src1)>;
4562def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_GE, EFLAGS),
4563 (CMOVL16rm GR16:$src2, addr:$src1)>;
4564def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_GE, EFLAGS),
4565 (CMOVL32rm GR32:$src2, addr:$src1)>;
4566def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_LE, EFLAGS),
4567 (CMOVG16rm GR16:$src2, addr:$src1)>;
4568def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_LE, EFLAGS),
4569 (CMOVG32rm GR32:$src2, addr:$src1)>;
4570def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_G, EFLAGS),
4571 (CMOVLE16rm GR16:$src2, addr:$src1)>;
4572def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_G, EFLAGS),
4573 (CMOVLE32rm GR32:$src2, addr:$src1)>;
4574def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_P, EFLAGS),
4575 (CMOVNP16rm GR16:$src2, addr:$src1)>;
4576def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_P, EFLAGS),
4577 (CMOVNP32rm GR32:$src2, addr:$src1)>;
4578def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_NP, EFLAGS),
4579 (CMOVP16rm GR16:$src2, addr:$src1)>;
4580def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_NP, EFLAGS),
4581 (CMOVP32rm GR32:$src2, addr:$src1)>;
4582def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_S, EFLAGS),
4583 (CMOVNS16rm GR16:$src2, addr:$src1)>;
4584def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_S, EFLAGS),
4585 (CMOVNS32rm GR32:$src2, addr:$src1)>;
4586def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_NS, EFLAGS),
4587 (CMOVS16rm GR16:$src2, addr:$src1)>;
4588def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_NS, EFLAGS),
4589 (CMOVS32rm GR32:$src2, addr:$src1)>;
4590def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_O, EFLAGS),
4591 (CMOVNO16rm GR16:$src2, addr:$src1)>;
4592def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_O, EFLAGS),
4593 (CMOVNO32rm GR32:$src2, addr:$src1)>;
4594def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_NO, EFLAGS),
4595 (CMOVO16rm GR16:$src2, addr:$src1)>;
4596def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_NO, EFLAGS),
4597 (CMOVO32rm GR32:$src2, addr:$src1)>;
4598
Duncan Sandsf9c98e62008-01-23 20:39:46 +00004599// zextload bool -> zextload byte
Evan Chenge5d93432006-01-17 07:02:46 +00004600def : Pat<(zextloadi8i1 addr:$src), (MOV8rm addr:$src)>;
Evan Cheng510e4782006-01-09 23:10:28 +00004601def : Pat<(zextloadi16i1 addr:$src), (MOVZX16rm8 addr:$src)>;
4602def : Pat<(zextloadi32i1 addr:$src), (MOVZX32rm8 addr:$src)>;
4603
4604// extload bool -> extload byte
Evan Cheng47137242006-05-05 08:23:07 +00004605def : Pat<(extloadi8i1 addr:$src), (MOV8rm addr:$src)>;
Dan Gohmanaf70e5c2009-08-26 14:59:13 +00004606def : Pat<(extloadi16i1 addr:$src), (MOVZX16rm8 addr:$src)>;
Evan Cheng47137242006-05-05 08:23:07 +00004607def : Pat<(extloadi32i1 addr:$src), (MOVZX32rm8 addr:$src)>;
Dan Gohmanaf70e5c2009-08-26 14:59:13 +00004608def : Pat<(extloadi16i8 addr:$src), (MOVZX16rm8 addr:$src)>;
Evan Cheng47137242006-05-05 08:23:07 +00004609def : Pat<(extloadi32i8 addr:$src), (MOVZX32rm8 addr:$src)>;
4610def : Pat<(extloadi32i16 addr:$src), (MOVZX32rm16 addr:$src)>;
Evan Cheng510e4782006-01-09 23:10:28 +00004611
Dan Gohmanaf70e5c2009-08-26 14:59:13 +00004612// anyext. Define these to do an explicit zero-extend to
4613// avoid partial-register updates.
4614def : Pat<(i16 (anyext GR8 :$src)), (MOVZX16rr8 GR8 :$src)>;
4615def : Pat<(i32 (anyext GR8 :$src)), (MOVZX32rr8 GR8 :$src)>;
Evan Cheng5528e7b2010-04-21 01:47:12 +00004616
Evan Cheng2bce5f4b2010-04-28 08:30:49 +00004617// Except for i16 -> i32 since isel expect i16 ops to be promoted to i32.
Evan Cheng5528e7b2010-04-21 01:47:12 +00004618def : Pat<(i32 (anyext GR16:$src)),
Jakob Stoklund Olesen3458e9e2010-05-24 14:48:17 +00004619 (INSERT_SUBREG (i32 (IMPLICIT_DEF)), GR16:$src, sub_16bit)>;
Evan Cheng5528e7b2010-04-21 01:47:12 +00004620
Evan Cheng510e4782006-01-09 23:10:28 +00004621
Evan Chengcfa260b2006-01-06 02:31:59 +00004622//===----------------------------------------------------------------------===//
4623// Some peepholes
4624//===----------------------------------------------------------------------===//
4625
Dan Gohman63f97202008-10-17 01:33:43 +00004626// Odd encoding trick: -128 fits into an 8-bit immediate field while
4627// +128 doesn't, so in this special case use a sub instead of an add.
4628def : Pat<(add GR16:$src1, 128),
4629 (SUB16ri8 GR16:$src1, -128)>;
4630def : Pat<(store (add (loadi16 addr:$dst), 128), addr:$dst),
4631 (SUB16mi8 addr:$dst, -128)>;
4632def : Pat<(add GR32:$src1, 128),
4633 (SUB32ri8 GR32:$src1, -128)>;
4634def : Pat<(store (add (loadi32 addr:$dst), 128), addr:$dst),
4635 (SUB32mi8 addr:$dst, -128)>;
4636
Dan Gohman11ba3b12008-07-30 18:09:17 +00004637// r & (2^16-1) ==> movz
4638def : Pat<(and GR32:$src1, 0xffff),
Jakob Stoklund Olesen3458e9e2010-05-24 14:48:17 +00004639 (MOVZX32rr16 (EXTRACT_SUBREG GR32:$src1, sub_16bit))>;
Dan Gohman8a1510d2008-08-06 18:27:21 +00004640// r & (2^8-1) ==> movz
4641def : Pat<(and GR32:$src1, 0xff),
Anton Korobeynikov3a639a02009-11-02 00:11:39 +00004642 (MOVZX32rr8 (EXTRACT_SUBREG (i32 (COPY_TO_REGCLASS GR32:$src1,
4643 GR32_ABCD)),
Jakob Stoklund Olesen3458e9e2010-05-24 14:48:17 +00004644 sub_8bit))>,
Dan Gohman8a1510d2008-08-06 18:27:21 +00004645 Requires<[In32BitMode]>;
4646// r & (2^8-1) ==> movz
4647def : Pat<(and GR16:$src1, 0xff),
Anton Korobeynikov3a639a02009-11-02 00:11:39 +00004648 (MOVZX16rr8 (EXTRACT_SUBREG (i16 (COPY_TO_REGCLASS GR16:$src1,
4649 GR16_ABCD)),
Jakob Stoklund Olesen3458e9e2010-05-24 14:48:17 +00004650 sub_8bit))>,
Dan Gohman0bfa1bf2008-08-20 21:27:32 +00004651 Requires<[In32BitMode]>;
4652
4653// sext_inreg patterns
4654def : Pat<(sext_inreg GR32:$src, i16),
Jakob Stoklund Olesen3458e9e2010-05-24 14:48:17 +00004655 (MOVSX32rr16 (EXTRACT_SUBREG GR32:$src, sub_16bit))>;
Dan Gohman0bfa1bf2008-08-20 21:27:32 +00004656def : Pat<(sext_inreg GR32:$src, i8),
Anton Korobeynikov3a639a02009-11-02 00:11:39 +00004657 (MOVSX32rr8 (EXTRACT_SUBREG (i32 (COPY_TO_REGCLASS GR32:$src,
4658 GR32_ABCD)),
Jakob Stoklund Olesen3458e9e2010-05-24 14:48:17 +00004659 sub_8bit))>,
Dan Gohman0bfa1bf2008-08-20 21:27:32 +00004660 Requires<[In32BitMode]>;
4661def : Pat<(sext_inreg GR16:$src, i8),
Anton Korobeynikov3a639a02009-11-02 00:11:39 +00004662 (MOVSX16rr8 (EXTRACT_SUBREG (i16 (COPY_TO_REGCLASS GR16:$src,
4663 GR16_ABCD)),
Jakob Stoklund Olesen3458e9e2010-05-24 14:48:17 +00004664 sub_8bit))>,
Dan Gohman0bfa1bf2008-08-20 21:27:32 +00004665 Requires<[In32BitMode]>;
4666
4667// trunc patterns
4668def : Pat<(i16 (trunc GR32:$src)),
Jakob Stoklund Olesen3458e9e2010-05-24 14:48:17 +00004669 (EXTRACT_SUBREG GR32:$src, sub_16bit)>;
Dan Gohman0bfa1bf2008-08-20 21:27:32 +00004670def : Pat<(i8 (trunc GR32:$src)),
Anton Korobeynikov3a639a02009-11-02 00:11:39 +00004671 (EXTRACT_SUBREG (i32 (COPY_TO_REGCLASS GR32:$src, GR32_ABCD)),
Jakob Stoklund Olesen3458e9e2010-05-24 14:48:17 +00004672 sub_8bit)>,
Dan Gohman0bfa1bf2008-08-20 21:27:32 +00004673 Requires<[In32BitMode]>;
4674def : Pat<(i8 (trunc GR16:$src)),
Anton Korobeynikov3a639a02009-11-02 00:11:39 +00004675 (EXTRACT_SUBREG (i16 (COPY_TO_REGCLASS GR16:$src, GR16_ABCD)),
Jakob Stoklund Olesen3458e9e2010-05-24 14:48:17 +00004676 sub_8bit)>,
Dan Gohman21e3dfb2009-04-13 16:09:41 +00004677 Requires<[In32BitMode]>;
4678
4679// h-register tricks
4680def : Pat<(i8 (trunc (srl_su GR16:$src, (i8 8)))),
Evan Cheng1c45acf2010-04-27 21:46:03 +00004681 (EXTRACT_SUBREG (i16 (COPY_TO_REGCLASS GR16:$src, GR16_ABCD)),
Jakob Stoklund Olesen3458e9e2010-05-24 14:48:17 +00004682 sub_8bit_hi)>,
Dan Gohman21e3dfb2009-04-13 16:09:41 +00004683 Requires<[In32BitMode]>;
4684def : Pat<(i8 (trunc (srl_su GR32:$src, (i8 8)))),
Evan Cheng1c45acf2010-04-27 21:46:03 +00004685 (EXTRACT_SUBREG (i32 (COPY_TO_REGCLASS GR32:$src, GR32_ABCD)),
Jakob Stoklund Olesen3458e9e2010-05-24 14:48:17 +00004686 sub_8bit_hi)>,
Dan Gohman21e3dfb2009-04-13 16:09:41 +00004687 Requires<[In32BitMode]>;
Dan Gohman7e0d64a2010-01-11 17:21:05 +00004688def : Pat<(srl GR16:$src, (i8 8)),
Dan Gohman21e3dfb2009-04-13 16:09:41 +00004689 (EXTRACT_SUBREG
4690 (MOVZX32rr8
Anton Korobeynikov3a639a02009-11-02 00:11:39 +00004691 (EXTRACT_SUBREG (i16 (COPY_TO_REGCLASS GR16:$src, GR16_ABCD)),
Jakob Stoklund Olesen3458e9e2010-05-24 14:48:17 +00004692 sub_8bit_hi)),
4693 sub_16bit)>,
Dan Gohman21e3dfb2009-04-13 16:09:41 +00004694 Requires<[In32BitMode]>;
Evan Chengcb219f02009-05-29 01:44:43 +00004695def : Pat<(i32 (zext (srl_su GR16:$src, (i8 8)))),
Sean Callanan108934c2009-12-18 00:01:26 +00004696 (MOVZX32rr8 (EXTRACT_SUBREG (i16 (COPY_TO_REGCLASS GR16:$src,
4697 GR16_ABCD)),
Jakob Stoklund Olesen3458e9e2010-05-24 14:48:17 +00004698 sub_8bit_hi))>,
Evan Chengcb219f02009-05-29 01:44:43 +00004699 Requires<[In32BitMode]>;
Dan Gohmanaf70e5c2009-08-26 14:59:13 +00004700def : Pat<(i32 (anyext (srl_su GR16:$src, (i8 8)))),
Sean Callanan108934c2009-12-18 00:01:26 +00004701 (MOVZX32rr8 (EXTRACT_SUBREG (i16 (COPY_TO_REGCLASS GR16:$src,
4702 GR16_ABCD)),
Jakob Stoklund Olesen3458e9e2010-05-24 14:48:17 +00004703 sub_8bit_hi))>,
Dan Gohmanaf70e5c2009-08-26 14:59:13 +00004704 Requires<[In32BitMode]>;
Dan Gohman21e3dfb2009-04-13 16:09:41 +00004705def : Pat<(and (srl_su GR32:$src, (i8 8)), (i32 255)),
Sean Callanan108934c2009-12-18 00:01:26 +00004706 (MOVZX32rr8 (EXTRACT_SUBREG (i32 (COPY_TO_REGCLASS GR32:$src,
4707 GR32_ABCD)),
Jakob Stoklund Olesen3458e9e2010-05-24 14:48:17 +00004708 sub_8bit_hi))>,
Dan Gohman8a1510d2008-08-06 18:27:21 +00004709 Requires<[In32BitMode]>;
Evan Cheng2bce5f4b2010-04-28 08:30:49 +00004710def : Pat<(srl (and_su GR32:$src, 0xff00), (i8 8)),
4711 (MOVZX32rr8 (EXTRACT_SUBREG (i32 (COPY_TO_REGCLASS GR32:$src,
4712 GR32_ABCD)),
Jakob Stoklund Olesen3458e9e2010-05-24 14:48:17 +00004713 sub_8bit_hi))>,
Evan Cheng2bce5f4b2010-04-28 08:30:49 +00004714 Requires<[In32BitMode]>;
Dan Gohman11ba3b12008-07-30 18:09:17 +00004715
Evan Chengcfa260b2006-01-06 02:31:59 +00004716// (shl x, 1) ==> (add x, x)
Evan Cheng069287d2006-05-16 07:21:53 +00004717def : Pat<(shl GR8 :$src1, (i8 1)), (ADD8rr GR8 :$src1, GR8 :$src1)>;
4718def : Pat<(shl GR16:$src1, (i8 1)), (ADD16rr GR16:$src1, GR16:$src1)>;
4719def : Pat<(shl GR32:$src1, (i8 1)), (ADD32rr GR32:$src1, GR32:$src1)>;
Evan Cheng68b951a2006-01-19 01:56:29 +00004720
Evan Chengeb9f8922008-08-30 02:03:58 +00004721// (shl x (and y, 31)) ==> (shl x, y)
Chris Lattner6d9f86b2010-02-23 06:54:29 +00004722def : Pat<(shl GR8:$src1, (and CL, 31)),
Evan Chengeb9f8922008-08-30 02:03:58 +00004723 (SHL8rCL GR8:$src1)>;
Chris Lattner6d9f86b2010-02-23 06:54:29 +00004724def : Pat<(shl GR16:$src1, (and CL, 31)),
Evan Chengeb9f8922008-08-30 02:03:58 +00004725 (SHL16rCL GR16:$src1)>;
Chris Lattner6d9f86b2010-02-23 06:54:29 +00004726def : Pat<(shl GR32:$src1, (and CL, 31)),
Evan Chengeb9f8922008-08-30 02:03:58 +00004727 (SHL32rCL GR32:$src1)>;
Chris Lattner6d9f86b2010-02-23 06:54:29 +00004728def : Pat<(store (shl (loadi8 addr:$dst), (and CL, 31)), addr:$dst),
Evan Chengeb9f8922008-08-30 02:03:58 +00004729 (SHL8mCL addr:$dst)>;
Chris Lattner6d9f86b2010-02-23 06:54:29 +00004730def : Pat<(store (shl (loadi16 addr:$dst), (and CL, 31)), addr:$dst),
Evan Chengeb9f8922008-08-30 02:03:58 +00004731 (SHL16mCL addr:$dst)>;
Chris Lattner6d9f86b2010-02-23 06:54:29 +00004732def : Pat<(store (shl (loadi32 addr:$dst), (and CL, 31)), addr:$dst),
Evan Chengeb9f8922008-08-30 02:03:58 +00004733 (SHL32mCL addr:$dst)>;
4734
Chris Lattner6d9f86b2010-02-23 06:54:29 +00004735def : Pat<(srl GR8:$src1, (and CL, 31)),
Evan Chengeb9f8922008-08-30 02:03:58 +00004736 (SHR8rCL GR8:$src1)>;
Chris Lattner6d9f86b2010-02-23 06:54:29 +00004737def : Pat<(srl GR16:$src1, (and CL, 31)),
Evan Chengeb9f8922008-08-30 02:03:58 +00004738 (SHR16rCL GR16:$src1)>;
Chris Lattner6d9f86b2010-02-23 06:54:29 +00004739def : Pat<(srl GR32:$src1, (and CL, 31)),
Evan Chengeb9f8922008-08-30 02:03:58 +00004740 (SHR32rCL GR32:$src1)>;
Chris Lattner6d9f86b2010-02-23 06:54:29 +00004741def : Pat<(store (srl (loadi8 addr:$dst), (and CL, 31)), addr:$dst),
Evan Chengeb9f8922008-08-30 02:03:58 +00004742 (SHR8mCL addr:$dst)>;
Chris Lattner6d9f86b2010-02-23 06:54:29 +00004743def : Pat<(store (srl (loadi16 addr:$dst), (and CL, 31)), addr:$dst),
Evan Chengeb9f8922008-08-30 02:03:58 +00004744 (SHR16mCL addr:$dst)>;
Chris Lattner6d9f86b2010-02-23 06:54:29 +00004745def : Pat<(store (srl (loadi32 addr:$dst), (and CL, 31)), addr:$dst),
Evan Chengeb9f8922008-08-30 02:03:58 +00004746 (SHR32mCL addr:$dst)>;
4747
Chris Lattner6d9f86b2010-02-23 06:54:29 +00004748def : Pat<(sra GR8:$src1, (and CL, 31)),
Evan Chengeb9f8922008-08-30 02:03:58 +00004749 (SAR8rCL GR8:$src1)>;
Chris Lattner6d9f86b2010-02-23 06:54:29 +00004750def : Pat<(sra GR16:$src1, (and CL, 31)),
Evan Chengeb9f8922008-08-30 02:03:58 +00004751 (SAR16rCL GR16:$src1)>;
Chris Lattner6d9f86b2010-02-23 06:54:29 +00004752def : Pat<(sra GR32:$src1, (and CL, 31)),
Evan Chengeb9f8922008-08-30 02:03:58 +00004753 (SAR32rCL GR32:$src1)>;
Chris Lattner6d9f86b2010-02-23 06:54:29 +00004754def : Pat<(store (sra (loadi8 addr:$dst), (and CL, 31)), addr:$dst),
Evan Chengeb9f8922008-08-30 02:03:58 +00004755 (SAR8mCL addr:$dst)>;
Chris Lattner6d9f86b2010-02-23 06:54:29 +00004756def : Pat<(store (sra (loadi16 addr:$dst), (and CL, 31)), addr:$dst),
Evan Chengeb9f8922008-08-30 02:03:58 +00004757 (SAR16mCL addr:$dst)>;
Chris Lattner6d9f86b2010-02-23 06:54:29 +00004758def : Pat<(store (sra (loadi32 addr:$dst), (and CL, 31)), addr:$dst),
Evan Chengeb9f8922008-08-30 02:03:58 +00004759 (SAR32mCL addr:$dst)>;
4760
Evan Cheng2e489c42009-12-16 00:53:11 +00004761// (anyext (setcc_carry)) -> (setcc_carry)
4762def : Pat<(i16 (anyext (i8 (X86setcc_c X86_COND_B, EFLAGS)))),
Evan Chengad9c0a32009-12-15 00:53:42 +00004763 (SETB_C16r)>;
Evan Cheng2e489c42009-12-16 00:53:11 +00004764def : Pat<(i32 (anyext (i8 (X86setcc_c X86_COND_B, EFLAGS)))),
Evan Chengad9c0a32009-12-15 00:53:42 +00004765 (SETB_C32r)>;
Evan Chenge5b51ac2010-04-17 06:13:15 +00004766def : Pat<(i32 (anyext (i16 (X86setcc_c X86_COND_B, EFLAGS)))),
4767 (SETB_C32r)>;
Evan Chengad9c0a32009-12-15 00:53:42 +00004768
Evan Cheng199c4242010-01-11 22:03:29 +00004769// (or x1, x2) -> (add x1, x2) if two operands are known not to share bits.
Evan Cheng3bda2012010-01-12 18:31:19 +00004770let AddedComplexity = 5 in { // Try this before the selecting to OR
Chris Lattnera0f70172010-03-24 00:15:23 +00004771def : Pat<(or_is_add GR16:$src1, imm:$src2),
Evan Cheng4b0345b2010-01-11 17:03:47 +00004772 (ADD16ri GR16:$src1, imm:$src2)>;
Chris Lattnera0f70172010-03-24 00:15:23 +00004773def : Pat<(or_is_add GR32:$src1, imm:$src2),
Evan Cheng4b0345b2010-01-11 17:03:47 +00004774 (ADD32ri GR32:$src1, imm:$src2)>;
Chris Lattnera0f70172010-03-24 00:15:23 +00004775def : Pat<(or_is_add GR16:$src1, i16immSExt8:$src2),
Evan Cheng4b0345b2010-01-11 17:03:47 +00004776 (ADD16ri8 GR16:$src1, i16immSExt8:$src2)>;
Chris Lattnera0f70172010-03-24 00:15:23 +00004777def : Pat<(or_is_add GR32:$src1, i32immSExt8:$src2),
Evan Cheng4b0345b2010-01-11 17:03:47 +00004778 (ADD32ri8 GR32:$src1, i32immSExt8:$src2)>;
Chris Lattnera0f70172010-03-24 00:15:23 +00004779def : Pat<(or_is_add GR16:$src1, GR16:$src2),
Evan Cheng199c4242010-01-11 22:03:29 +00004780 (ADD16rr GR16:$src1, GR16:$src2)>;
Chris Lattnera0f70172010-03-24 00:15:23 +00004781def : Pat<(or_is_add GR32:$src1, GR32:$src2),
Evan Cheng199c4242010-01-11 22:03:29 +00004782 (ADD32rr GR32:$src1, GR32:$src2)>;
Evan Cheng3bda2012010-01-12 18:31:19 +00004783} // AddedComplexity
Evan Cheng4b0345b2010-01-11 17:03:47 +00004784
Evan Cheng4e4c71e2006-02-21 20:00:20 +00004785//===----------------------------------------------------------------------===//
Dan Gohman076aee32009-03-04 19:44:21 +00004786// EFLAGS-defining Patterns
Bill Wendlingd350e022008-12-12 21:15:41 +00004787//===----------------------------------------------------------------------===//
4788
Chris Lattnerec856802010-03-27 00:45:04 +00004789// add reg, reg
4790def : Pat<(add GR8 :$src1, GR8 :$src2), (ADD8rr GR8 :$src1, GR8 :$src2)>;
4791def : Pat<(add GR16:$src1, GR16:$src2), (ADD16rr GR16:$src1, GR16:$src2)>;
4792def : Pat<(add GR32:$src1, GR32:$src2), (ADD32rr GR32:$src1, GR32:$src2)>;
Bill Wendlingd350e022008-12-12 21:15:41 +00004793
Chris Lattnerec856802010-03-27 00:45:04 +00004794// add reg, mem
4795def : Pat<(add GR8:$src1, (loadi8 addr:$src2)),
Bill Wendlingd350e022008-12-12 21:15:41 +00004796 (ADD8rm GR8:$src1, addr:$src2)>;
Chris Lattnerec856802010-03-27 00:45:04 +00004797def : Pat<(add GR16:$src1, (loadi16 addr:$src2)),
Bill Wendlingd350e022008-12-12 21:15:41 +00004798 (ADD16rm GR16:$src1, addr:$src2)>;
Chris Lattnerec856802010-03-27 00:45:04 +00004799def : Pat<(add GR32:$src1, (loadi32 addr:$src2)),
Bill Wendlingd350e022008-12-12 21:15:41 +00004800 (ADD32rm GR32:$src1, addr:$src2)>;
4801
Chris Lattnerec856802010-03-27 00:45:04 +00004802// add reg, imm
4803def : Pat<(add GR8 :$src1, imm:$src2), (ADD8ri GR8:$src1 , imm:$src2)>;
4804def : Pat<(add GR16:$src1, imm:$src2), (ADD16ri GR16:$src1, imm:$src2)>;
4805def : Pat<(add GR32:$src1, imm:$src2), (ADD32ri GR32:$src1, imm:$src2)>;
4806def : Pat<(add GR16:$src1, i16immSExt8:$src2),
Bill Wendlingd350e022008-12-12 21:15:41 +00004807 (ADD16ri8 GR16:$src1, i16immSExt8:$src2)>;
Chris Lattnerec856802010-03-27 00:45:04 +00004808def : Pat<(add GR32:$src1, i32immSExt8:$src2),
Bill Wendlingd350e022008-12-12 21:15:41 +00004809 (ADD32ri8 GR32:$src1, i32immSExt8:$src2)>;
4810
Chris Lattnerec856802010-03-27 00:45:04 +00004811// sub reg, reg
4812def : Pat<(sub GR8 :$src1, GR8 :$src2), (SUB8rr GR8 :$src1, GR8 :$src2)>;
4813def : Pat<(sub GR16:$src1, GR16:$src2), (SUB16rr GR16:$src1, GR16:$src2)>;
4814def : Pat<(sub GR32:$src1, GR32:$src2), (SUB32rr GR32:$src1, GR32:$src2)>;
Bill Wendlingd350e022008-12-12 21:15:41 +00004815
Chris Lattnerec856802010-03-27 00:45:04 +00004816// sub reg, mem
4817def : Pat<(sub GR8:$src1, (loadi8 addr:$src2)),
Bill Wendlingd350e022008-12-12 21:15:41 +00004818 (SUB8rm GR8:$src1, addr:$src2)>;
Chris Lattnerec856802010-03-27 00:45:04 +00004819def : Pat<(sub GR16:$src1, (loadi16 addr:$src2)),
Bill Wendlingd350e022008-12-12 21:15:41 +00004820 (SUB16rm GR16:$src1, addr:$src2)>;
Chris Lattnerec856802010-03-27 00:45:04 +00004821def : Pat<(sub GR32:$src1, (loadi32 addr:$src2)),
Bill Wendlingd350e022008-12-12 21:15:41 +00004822 (SUB32rm GR32:$src1, addr:$src2)>;
4823
Chris Lattnerec856802010-03-27 00:45:04 +00004824// sub reg, imm
4825def : Pat<(sub GR8:$src1, imm:$src2),
Bill Wendlingd350e022008-12-12 21:15:41 +00004826 (SUB8ri GR8:$src1, imm:$src2)>;
Chris Lattnerec856802010-03-27 00:45:04 +00004827def : Pat<(sub GR16:$src1, imm:$src2),
Bill Wendlingd350e022008-12-12 21:15:41 +00004828 (SUB16ri GR16:$src1, imm:$src2)>;
Chris Lattnerec856802010-03-27 00:45:04 +00004829def : Pat<(sub GR32:$src1, imm:$src2),
Bill Wendlingd350e022008-12-12 21:15:41 +00004830 (SUB32ri GR32:$src1, imm:$src2)>;
Chris Lattnerec856802010-03-27 00:45:04 +00004831def : Pat<(sub GR16:$src1, i16immSExt8:$src2),
Bill Wendlingd350e022008-12-12 21:15:41 +00004832 (SUB16ri8 GR16:$src1, i16immSExt8:$src2)>;
Chris Lattnerec856802010-03-27 00:45:04 +00004833def : Pat<(sub GR32:$src1, i32immSExt8:$src2),
Bill Wendlingd350e022008-12-12 21:15:41 +00004834 (SUB32ri8 GR32:$src1, i32immSExt8:$src2)>;
4835
Chris Lattnerec856802010-03-27 00:45:04 +00004836// mul reg, reg
4837def : Pat<(mul GR16:$src1, GR16:$src2),
Bill Wendlingd350e022008-12-12 21:15:41 +00004838 (IMUL16rr GR16:$src1, GR16:$src2)>;
Chris Lattnerec856802010-03-27 00:45:04 +00004839def : Pat<(mul GR32:$src1, GR32:$src2),
Bill Wendlingd350e022008-12-12 21:15:41 +00004840 (IMUL32rr GR32:$src1, GR32:$src2)>;
4841
Chris Lattnerec856802010-03-27 00:45:04 +00004842// mul reg, mem
4843def : Pat<(mul GR16:$src1, (loadi16 addr:$src2)),
Bill Wendlingd350e022008-12-12 21:15:41 +00004844 (IMUL16rm GR16:$src1, addr:$src2)>;
Chris Lattnerec856802010-03-27 00:45:04 +00004845def : Pat<(mul GR32:$src1, (loadi32 addr:$src2)),
Bill Wendlingd350e022008-12-12 21:15:41 +00004846 (IMUL32rm GR32:$src1, addr:$src2)>;
4847
Chris Lattnerec856802010-03-27 00:45:04 +00004848// mul reg, imm
4849def : Pat<(mul GR16:$src1, imm:$src2),
Bill Wendlingd350e022008-12-12 21:15:41 +00004850 (IMUL16rri GR16:$src1, imm:$src2)>;
Chris Lattnerec856802010-03-27 00:45:04 +00004851def : Pat<(mul GR32:$src1, imm:$src2),
Bill Wendlingd350e022008-12-12 21:15:41 +00004852 (IMUL32rri GR32:$src1, imm:$src2)>;
Chris Lattnerec856802010-03-27 00:45:04 +00004853def : Pat<(mul GR16:$src1, i16immSExt8:$src2),
Bill Wendlingd350e022008-12-12 21:15:41 +00004854 (IMUL16rri8 GR16:$src1, i16immSExt8:$src2)>;
Chris Lattnerec856802010-03-27 00:45:04 +00004855def : Pat<(mul GR32:$src1, i32immSExt8:$src2),
Bill Wendlingd350e022008-12-12 21:15:41 +00004856 (IMUL32rri8 GR32:$src1, i32immSExt8:$src2)>;
4857
Chris Lattnerec856802010-03-27 00:45:04 +00004858// reg = mul mem, imm
4859def : Pat<(mul (loadi16 addr:$src1), imm:$src2),
Bill Wendlingd350e022008-12-12 21:15:41 +00004860 (IMUL16rmi addr:$src1, imm:$src2)>;
Chris Lattnerec856802010-03-27 00:45:04 +00004861def : Pat<(mul (loadi32 addr:$src1), imm:$src2),
Bill Wendlingd350e022008-12-12 21:15:41 +00004862 (IMUL32rmi addr:$src1, imm:$src2)>;
Chris Lattnerec856802010-03-27 00:45:04 +00004863def : Pat<(mul (loadi16 addr:$src1), i16immSExt8:$src2),
Bill Wendlingd350e022008-12-12 21:15:41 +00004864 (IMUL16rmi8 addr:$src1, i16immSExt8:$src2)>;
Chris Lattnerec856802010-03-27 00:45:04 +00004865def : Pat<(mul (loadi32 addr:$src1), i32immSExt8:$src2),
Bill Wendlingd350e022008-12-12 21:15:41 +00004866 (IMUL32rmi8 addr:$src1, i32immSExt8:$src2)>;
4867
Dan Gohman076aee32009-03-04 19:44:21 +00004868// Optimize multiply by 2 with EFLAGS result.
Evan Cheng6a86bd72009-01-27 03:30:42 +00004869let AddedComplexity = 2 in {
Chris Lattnerbaba4bb2010-03-27 02:47:14 +00004870def : Pat<(X86smul_flag GR16:$src1, 2), (ADD16rr GR16:$src1, GR16:$src1)>;
4871def : Pat<(X86smul_flag GR32:$src1, 2), (ADD32rr GR32:$src1, GR32:$src1)>;
Evan Cheng6a86bd72009-01-27 03:30:42 +00004872}
4873
Chris Lattner589ad5d2010-03-25 05:44:01 +00004874// Patterns for nodes that do not produce flags, for instructions that do.
Chris Lattnerc54a2f12010-03-24 01:02:12 +00004875
Chris Lattner589ad5d2010-03-25 05:44:01 +00004876// Increment reg.
Eric Christophera938cfb2010-06-19 00:37:40 +00004877def : Pat<(add GR8:$src1 , 1), (INC8r GR8:$src1)>;
4878def : Pat<(add GR16:$src1, 1), (INC16r GR16:$src1)>, Requires<[In32BitMode]>;
4879def : Pat<(add GR32:$src1, 1), (INC32r GR32:$src1)>, Requires<[In32BitMode]>;
Dan Gohman076aee32009-03-04 19:44:21 +00004880
Chris Lattner589ad5d2010-03-25 05:44:01 +00004881// Decrement reg.
Eric Christophera938cfb2010-06-19 00:37:40 +00004882def : Pat<(add GR8:$src1 , -1), (DEC8r GR8:$src1)>;
4883def : Pat<(add GR16:$src1, -1), (DEC16r GR16:$src1)>, Requires<[In32BitMode]>;
4884def : Pat<(add GR32:$src1, -1), (DEC32r GR32:$src1)>, Requires<[In32BitMode]>;
Dan Gohman076aee32009-03-04 19:44:21 +00004885
Chris Lattner589ad5d2010-03-25 05:44:01 +00004886// or reg/reg.
4887def : Pat<(or GR8 :$src1, GR8 :$src2), (OR8rr GR8 :$src1, GR8 :$src2)>;
4888def : Pat<(or GR16:$src1, GR16:$src2), (OR16rr GR16:$src1, GR16:$src2)>;
4889def : Pat<(or GR32:$src1, GR32:$src2), (OR32rr GR32:$src1, GR32:$src2)>;
Dan Gohman076aee32009-03-04 19:44:21 +00004890
Chris Lattner589ad5d2010-03-25 05:44:01 +00004891// or reg/mem
4892def : Pat<(or GR8:$src1, (loadi8 addr:$src2)),
Dan Gohmane220c4b2009-09-18 19:59:53 +00004893 (OR8rm GR8:$src1, addr:$src2)>;
Chris Lattner589ad5d2010-03-25 05:44:01 +00004894def : Pat<(or GR16:$src1, (loadi16 addr:$src2)),
Dan Gohmane220c4b2009-09-18 19:59:53 +00004895 (OR16rm GR16:$src1, addr:$src2)>;
Chris Lattner589ad5d2010-03-25 05:44:01 +00004896def : Pat<(or GR32:$src1, (loadi32 addr:$src2)),
Dan Gohmane220c4b2009-09-18 19:59:53 +00004897 (OR32rm GR32:$src1, addr:$src2)>;
4898
Chris Lattner589ad5d2010-03-25 05:44:01 +00004899// or reg/imm
4900def : Pat<(or GR8:$src1 , imm:$src2), (OR8ri GR8 :$src1, imm:$src2)>;
4901def : Pat<(or GR16:$src1, imm:$src2), (OR16ri GR16:$src1, imm:$src2)>;
4902def : Pat<(or GR32:$src1, imm:$src2), (OR32ri GR32:$src1, imm:$src2)>;
4903def : Pat<(or GR16:$src1, i16immSExt8:$src2),
Dan Gohmane220c4b2009-09-18 19:59:53 +00004904 (OR16ri8 GR16:$src1, i16immSExt8:$src2)>;
Chris Lattner589ad5d2010-03-25 05:44:01 +00004905def : Pat<(or GR32:$src1, i32immSExt8:$src2),
Dan Gohmane220c4b2009-09-18 19:59:53 +00004906 (OR32ri8 GR32:$src1, i32immSExt8:$src2)>;
Dan Gohmane220c4b2009-09-18 19:59:53 +00004907
Chris Lattner589ad5d2010-03-25 05:44:01 +00004908// xor reg/reg
4909def : Pat<(xor GR8 :$src1, GR8 :$src2), (XOR8rr GR8 :$src1, GR8 :$src2)>;
4910def : Pat<(xor GR16:$src1, GR16:$src2), (XOR16rr GR16:$src1, GR16:$src2)>;
4911def : Pat<(xor GR32:$src1, GR32:$src2), (XOR32rr GR32:$src1, GR32:$src2)>;
Dan Gohmane220c4b2009-09-18 19:59:53 +00004912
Chris Lattner589ad5d2010-03-25 05:44:01 +00004913// xor reg/mem
4914def : Pat<(xor GR8:$src1, (loadi8 addr:$src2)),
Dan Gohmane220c4b2009-09-18 19:59:53 +00004915 (XOR8rm GR8:$src1, addr:$src2)>;
Chris Lattner589ad5d2010-03-25 05:44:01 +00004916def : Pat<(xor GR16:$src1, (loadi16 addr:$src2)),
Dan Gohmane220c4b2009-09-18 19:59:53 +00004917 (XOR16rm GR16:$src1, addr:$src2)>;
Chris Lattner589ad5d2010-03-25 05:44:01 +00004918def : Pat<(xor GR32:$src1, (loadi32 addr:$src2)),
Dan Gohmane220c4b2009-09-18 19:59:53 +00004919 (XOR32rm GR32:$src1, addr:$src2)>;
4920
Chris Lattner589ad5d2010-03-25 05:44:01 +00004921// xor reg/imm
4922def : Pat<(xor GR8:$src1, imm:$src2),
Dan Gohmane220c4b2009-09-18 19:59:53 +00004923 (XOR8ri GR8:$src1, imm:$src2)>;
Chris Lattner589ad5d2010-03-25 05:44:01 +00004924def : Pat<(xor GR16:$src1, imm:$src2),
Dan Gohmane220c4b2009-09-18 19:59:53 +00004925 (XOR16ri GR16:$src1, imm:$src2)>;
Chris Lattner589ad5d2010-03-25 05:44:01 +00004926def : Pat<(xor GR32:$src1, imm:$src2),
Dan Gohmane220c4b2009-09-18 19:59:53 +00004927 (XOR32ri GR32:$src1, imm:$src2)>;
Chris Lattner589ad5d2010-03-25 05:44:01 +00004928def : Pat<(xor GR16:$src1, i16immSExt8:$src2),
Dan Gohmane220c4b2009-09-18 19:59:53 +00004929 (XOR16ri8 GR16:$src1, i16immSExt8:$src2)>;
Chris Lattner589ad5d2010-03-25 05:44:01 +00004930def : Pat<(xor GR32:$src1, i32immSExt8:$src2),
Dan Gohmane220c4b2009-09-18 19:59:53 +00004931 (XOR32ri8 GR32:$src1, i32immSExt8:$src2)>;
4932
Chris Lattner589ad5d2010-03-25 05:44:01 +00004933// and reg/reg
4934def : Pat<(and GR8 :$src1, GR8 :$src2), (AND8rr GR8 :$src1, GR8 :$src2)>;
4935def : Pat<(and GR16:$src1, GR16:$src2), (AND16rr GR16:$src1, GR16:$src2)>;
4936def : Pat<(and GR32:$src1, GR32:$src2), (AND32rr GR32:$src1, GR32:$src2)>;
Dan Gohmane220c4b2009-09-18 19:59:53 +00004937
Chris Lattner589ad5d2010-03-25 05:44:01 +00004938// and reg/mem
4939def : Pat<(and GR8:$src1, (loadi8 addr:$src2)),
Dan Gohmane220c4b2009-09-18 19:59:53 +00004940 (AND8rm GR8:$src1, addr:$src2)>;
Chris Lattner589ad5d2010-03-25 05:44:01 +00004941def : Pat<(and GR16:$src1, (loadi16 addr:$src2)),
Dan Gohmane220c4b2009-09-18 19:59:53 +00004942 (AND16rm GR16:$src1, addr:$src2)>;
Chris Lattner589ad5d2010-03-25 05:44:01 +00004943def : Pat<(and GR32:$src1, (loadi32 addr:$src2)),
Dan Gohmane220c4b2009-09-18 19:59:53 +00004944 (AND32rm GR32:$src1, addr:$src2)>;
4945
Chris Lattner589ad5d2010-03-25 05:44:01 +00004946// and reg/imm
4947def : Pat<(and GR8:$src1, imm:$src2),
Dan Gohmane220c4b2009-09-18 19:59:53 +00004948 (AND8ri GR8:$src1, imm:$src2)>;
Chris Lattner589ad5d2010-03-25 05:44:01 +00004949def : Pat<(and GR16:$src1, imm:$src2),
Dan Gohmane220c4b2009-09-18 19:59:53 +00004950 (AND16ri GR16:$src1, imm:$src2)>;
Chris Lattner589ad5d2010-03-25 05:44:01 +00004951def : Pat<(and GR32:$src1, imm:$src2),
Dan Gohmane220c4b2009-09-18 19:59:53 +00004952 (AND32ri GR32:$src1, imm:$src2)>;
Chris Lattner589ad5d2010-03-25 05:44:01 +00004953def : Pat<(and GR16:$src1, i16immSExt8:$src2),
Dan Gohmane220c4b2009-09-18 19:59:53 +00004954 (AND16ri8 GR16:$src1, i16immSExt8:$src2)>;
Chris Lattner589ad5d2010-03-25 05:44:01 +00004955def : Pat<(and GR32:$src1, i32immSExt8:$src2),
Dan Gohmane220c4b2009-09-18 19:59:53 +00004956 (AND32ri8 GR32:$src1, i32immSExt8:$src2)>;
4957
Bill Wendlingd350e022008-12-12 21:15:41 +00004958//===----------------------------------------------------------------------===//
Evan Cheng4e4c71e2006-02-21 20:00:20 +00004959// Floating Point Stack Support
4960//===----------------------------------------------------------------------===//
4961
4962include "X86InstrFPStack.td"
4963
4964//===----------------------------------------------------------------------===//
Evan Chengc64a1a92007-07-31 08:04:03 +00004965// X86-64 Support
4966//===----------------------------------------------------------------------===//
4967
Chris Lattner36fe6d22008-01-10 05:50:42 +00004968include "X86Instr64bit.td"
Evan Chengc64a1a92007-07-31 08:04:03 +00004969
4970//===----------------------------------------------------------------------===//
David Greene51898d72010-02-09 23:52:19 +00004971// SIMD support (SSE, MMX and AVX)
4972//===----------------------------------------------------------------------===//
4973
4974include "X86InstrFragmentsSIMD.td"
4975
4976//===----------------------------------------------------------------------===//
Bruno Cardoso Lopes6b7e9162010-07-23 00:54:35 +00004977// FMA - Fused Multiply-Add support (requires FMA)
4978//===----------------------------------------------------------------------===//
4979
4980include "X86InstrFMA.td"
4981
4982//===----------------------------------------------------------------------===//
Evan Cheng4e4c71e2006-02-21 20:00:20 +00004983// XMM Floating point support (requires SSE / SSE2)
4984//===----------------------------------------------------------------------===//
4985
4986include "X86InstrSSE.td"
Evan Cheng80f54042008-04-25 18:19:54 +00004987
4988//===----------------------------------------------------------------------===//
4989// MMX and XMM Packed Integer support (requires MMX, SSE, and SSE2)
4990//===----------------------------------------------------------------------===//
4991
4992include "X86InstrMMX.td"