blob: e6a240d60094ca5891fa5513a262347be4ab78ea [file] [log] [blame]
Sean Callanan108934c2009-12-18 00:01:26 +00001
John Criswell856ba762003-10-21 15:17:13 +00002//
3// The LLVM Compiler Infrastructure
4//
Chris Lattner4ee451d2007-12-29 20:36:04 +00005// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
John Criswell856ba762003-10-21 15:17:13 +00007//
8//===----------------------------------------------------------------------===//
Chris Lattner1cca5e32003-08-03 21:54:21 +00009//
10// This file describes the X86 instruction set, defining the instructions, and
11// properties of the instructions which are needed for code generation, machine
12// code emission, and analysis.
13//
14//===----------------------------------------------------------------------===//
15
Evan Chengaed7c722005-12-17 01:24:02 +000016//===----------------------------------------------------------------------===//
17// X86 specific DAG Nodes.
18//
19
Evan Chenge3413162006-01-09 18:33:28 +000020def SDTIntShiftDOp: SDTypeProfile<1, 3,
21 [SDTCisSameAs<0, 1>, SDTCisSameAs<0, 2>,
22 SDTCisInt<0>, SDTCisInt<3>]>;
23
Evan Cheng71fb9ad2006-01-26 00:29:36 +000024def SDTX86CmpTest : SDTypeProfile<0, 2, [SDTCisSameAs<0, 1>]>;
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.
31def SDTUnaryArithWithFlags : SDTypeProfile<1, 1,
32 [SDTCisInt<0>]>;
33def SDTBinaryArithWithFlags : SDTypeProfile<1, 2,
34 [SDTCisSameAs<0, 1>,
35 SDTCisSameAs<0, 2>,
36 SDTCisInt<0>]>;
Evan Chenge5f62042007-09-29 00:00:36 +000037def SDTX86BrCond : SDTypeProfile<0, 3,
Evan Cheng0488db92007-09-25 01:57:46 +000038 [SDTCisVT<0, OtherVT>,
39 SDTCisVT<1, i8>, SDTCisVT<2, i32>]>;
Evan Chengaed7c722005-12-17 01:24:02 +000040
Evan Chenge5f62042007-09-29 00:00:36 +000041def SDTX86SetCC : SDTypeProfile<1, 2,
Evan Cheng0488db92007-09-25 01:57:46 +000042 [SDTCisVT<0, i8>,
43 SDTCisVT<1, i8>, SDTCisVT<2, i32>]>;
Evan Cheng2e489c42009-12-16 00:53:11 +000044def SDTX86SetCC_C : SDTypeProfile<1, 2,
45 [SDTCisInt<0>,
46 SDTCisVT<1, i8>, SDTCisVT<2, i32>]>;
Evan Chengd5781fc2005-12-21 20:21:51 +000047
Andrew Lenharth26ed8692008-03-01 21:52:34 +000048def SDTX86cas : SDTypeProfile<0, 3, [SDTCisPtrTy<0>, SDTCisInt<1>,
49 SDTCisVT<2, i8>]>;
Andrew Lenharthd19189e2008-03-05 01:15:49 +000050def SDTX86cas8 : SDTypeProfile<0, 1, [SDTCisPtrTy<0>]>;
Andrew Lenharth26ed8692008-03-01 21:52:34 +000051
Dale Johannesen48c1bc22008-10-02 18:53:47 +000052def SDTX86atomicBinary : SDTypeProfile<2, 3, [SDTCisInt<0>, SDTCisInt<1>,
53 SDTCisPtrTy<2>, SDTCisInt<3>,SDTCisInt<4>]>;
Chris Lattner447ff682008-03-11 03:23:40 +000054def SDTX86Ret : SDTypeProfile<0, -1, [SDTCisVT<0, i16>]>;
Evan Cheng898101c2005-12-19 23:12:38 +000055
Sean Callanan1c97ceb2009-06-23 23:25:37 +000056def SDT_X86CallSeqStart : SDCallSeqStart<[SDTCisVT<0, i32>]>;
57def SDT_X86CallSeqEnd : SDCallSeqEnd<[SDTCisVT<0, i32>,
58 SDTCisVT<1, i32>]>;
Evan Chenge3413162006-01-09 18:33:28 +000059
Dan Gohmand35121a2008-05-29 19:57:41 +000060def SDT_X86Call : SDTypeProfile<0, -1, [SDTCisVT<0, iPTR>]>;
Evan Chenge3413162006-01-09 18:33:28 +000061
Dan Gohmand6708ea2009-08-15 01:38:56 +000062def SDT_X86VASTART_SAVE_XMM_REGS : SDTypeProfile<0, -1, [SDTCisVT<0, i8>,
63 SDTCisVT<1, iPTR>,
64 SDTCisVT<2, iPTR>]>;
65
Evan Cheng67f92a72006-01-11 22:15:48 +000066def SDTX86RepStr : SDTypeProfile<0, 1, [SDTCisVT<0, OtherVT>]>;
67
Anton Korobeynikov043f3c22010-03-06 19:32:29 +000068def SDTX86Void : SDTypeProfile<0, 0, []>;
Evan Chengd90eb7f2006-01-05 00:27:02 +000069
Evan Cheng71fb8342006-02-25 10:02:21 +000070def SDTX86Wrapper : SDTypeProfile<1, 1, [SDTCisSameAs<0, 1>, SDTCisPtrTy<0>]>;
71
Rafael Espindola2ee3db32009-04-17 14:35:58 +000072def SDT_X86TLSADDR : SDTypeProfile<0, 1, [SDTCisInt<0>]>;
Lauro Ramos Venanciob3a04172007-04-20 21:38:10 +000073
Rafael Espindola094fad32009-04-08 21:14:34 +000074def SDT_X86SegmentBaseAddress : SDTypeProfile<1, 1, [SDTCisPtrTy<0>]>;
Lauro Ramos Venanciob3a04172007-04-20 21:38:10 +000075
Anton Korobeynikov2365f512007-07-14 14:06:15 +000076def SDT_X86EHRET : SDTypeProfile<0, 1, [SDTCisInt<0>]>;
77
Arnold Schwaighoferc85e1712007-10-11 19:40:01 +000078def SDT_X86TCRET : SDTypeProfile<0, 2, [SDTCisPtrTy<0>, SDTCisVT<1, i32>]>;
79
Evan Cheng18efe262007-12-14 02:13:44 +000080def X86bsf : SDNode<"X86ISD::BSF", SDTIntUnaryOp>;
81def X86bsr : SDNode<"X86ISD::BSR", SDTIntUnaryOp>;
Evan Chenge3413162006-01-09 18:33:28 +000082def X86shld : SDNode<"X86ISD::SHLD", SDTIntShiftDOp>;
83def X86shrd : SDNode<"X86ISD::SHRD", SDTIntShiftDOp>;
Evan Chengb077b842005-12-21 02:39:21 +000084
Evan Chenge5f62042007-09-29 00:00:36 +000085def X86cmp : SDNode<"X86ISD::CMP" , SDTX86CmpTest>;
Evan Chengb077b842005-12-21 02:39:21 +000086
Dan Gohmanc7a37d42008-12-23 22:45:23 +000087def X86bt : SDNode<"X86ISD::BT", SDTX86CmpTest>;
88
Evan Chenge5f62042007-09-29 00:00:36 +000089def X86cmov : SDNode<"X86ISD::CMOV", SDTX86Cmov>;
Evan Chenge3413162006-01-09 18:33:28 +000090def X86brcond : SDNode<"X86ISD::BRCOND", SDTX86BrCond,
Evan Cheng0488db92007-09-25 01:57:46 +000091 [SDNPHasChain]>;
Evan Chenge5f62042007-09-29 00:00:36 +000092def X86setcc : SDNode<"X86ISD::SETCC", SDTX86SetCC>;
Evan Cheng2e489c42009-12-16 00:53:11 +000093def X86setcc_c : SDNode<"X86ISD::SETCC_CARRY", SDTX86SetCC_C>;
Evan Chengb077b842005-12-21 02:39:21 +000094
Andrew Lenharth26ed8692008-03-01 21:52:34 +000095def X86cas : SDNode<"X86ISD::LCMPXCHG_DAG", SDTX86cas,
96 [SDNPHasChain, SDNPInFlag, SDNPOutFlag, SDNPMayStore,
97 SDNPMayLoad]>;
Andrew Lenharthd19189e2008-03-05 01:15:49 +000098def X86cas8 : SDNode<"X86ISD::LCMPXCHG8_DAG", SDTX86cas8,
99 [SDNPHasChain, SDNPInFlag, SDNPOutFlag, SDNPMayStore,
100 SDNPMayLoad]>;
Dale Johannesen48c1bc22008-10-02 18:53:47 +0000101def X86AtomAdd64 : SDNode<"X86ISD::ATOMADD64_DAG", SDTX86atomicBinary,
102 [SDNPHasChain, SDNPMayStore,
103 SDNPMayLoad, SDNPMemOperand]>;
104def X86AtomSub64 : SDNode<"X86ISD::ATOMSUB64_DAG", SDTX86atomicBinary,
105 [SDNPHasChain, SDNPMayStore,
106 SDNPMayLoad, SDNPMemOperand]>;
107def X86AtomOr64 : SDNode<"X86ISD::ATOMOR64_DAG", SDTX86atomicBinary,
108 [SDNPHasChain, SDNPMayStore,
109 SDNPMayLoad, SDNPMemOperand]>;
110def X86AtomXor64 : SDNode<"X86ISD::ATOMXOR64_DAG", SDTX86atomicBinary,
111 [SDNPHasChain, SDNPMayStore,
112 SDNPMayLoad, SDNPMemOperand]>;
113def X86AtomAnd64 : SDNode<"X86ISD::ATOMAND64_DAG", SDTX86atomicBinary,
114 [SDNPHasChain, SDNPMayStore,
115 SDNPMayLoad, SDNPMemOperand]>;
116def X86AtomNand64 : SDNode<"X86ISD::ATOMNAND64_DAG", SDTX86atomicBinary,
117 [SDNPHasChain, SDNPMayStore,
118 SDNPMayLoad, SDNPMemOperand]>;
Dale Johannesen880ae362008-10-03 22:25:52 +0000119def X86AtomSwap64 : SDNode<"X86ISD::ATOMSWAP64_DAG", SDTX86atomicBinary,
120 [SDNPHasChain, SDNPMayStore,
121 SDNPMayLoad, SDNPMemOperand]>;
Evan Chenge3413162006-01-09 18:33:28 +0000122def X86retflag : SDNode<"X86ISD::RET_FLAG", SDTX86Ret,
123 [SDNPHasChain, SDNPOptInFlag]>;
Evan Chengb077b842005-12-21 02:39:21 +0000124
Dan Gohmand6708ea2009-08-15 01:38:56 +0000125def X86vastart_save_xmm_regs :
126 SDNode<"X86ISD::VASTART_SAVE_XMM_REGS",
127 SDT_X86VASTART_SAVE_XMM_REGS,
128 [SDNPHasChain]>;
129
Evan Chenge3413162006-01-09 18:33:28 +0000130def X86callseq_start :
131 SDNode<"ISD::CALLSEQ_START", SDT_X86CallSeqStart,
Evan Chengbb7b8442006-08-11 09:03:33 +0000132 [SDNPHasChain, SDNPOutFlag]>;
Evan Chenge3413162006-01-09 18:33:28 +0000133def X86callseq_end :
134 SDNode<"ISD::CALLSEQ_END", SDT_X86CallSeqEnd,
Arnold Schwaighoferc85e1712007-10-11 19:40:01 +0000135 [SDNPHasChain, SDNPOptInFlag, SDNPOutFlag]>;
Evan Chengb077b842005-12-21 02:39:21 +0000136
Evan Chenge3413162006-01-09 18:33:28 +0000137def X86call : SDNode<"X86ISD::CALL", SDT_X86Call,
138 [SDNPHasChain, SDNPOutFlag, SDNPOptInFlag]>;
Evan Chengaed7c722005-12-17 01:24:02 +0000139
Evan Cheng67f92a72006-01-11 22:15:48 +0000140def X86rep_stos: SDNode<"X86ISD::REP_STOS", SDTX86RepStr,
Chris Lattner9b37aaf2008-01-10 05:12:37 +0000141 [SDNPHasChain, SDNPInFlag, SDNPOutFlag, SDNPMayStore]>;
Evan Cheng67f92a72006-01-11 22:15:48 +0000142def X86rep_movs: SDNode<"X86ISD::REP_MOVS", SDTX86RepStr,
Chris Lattner9b37aaf2008-01-10 05:12:37 +0000143 [SDNPHasChain, SDNPInFlag, SDNPOutFlag, SDNPMayStore,
144 SDNPMayLoad]>;
Evan Cheng67f92a72006-01-11 22:15:48 +0000145
Anton Korobeynikov043f3c22010-03-06 19:32:29 +0000146def X86rdtsc : SDNode<"X86ISD::RDTSC_DAG", SDTX86Void,
Chris Lattnerba7e7562008-01-10 07:59:24 +0000147 [SDNPHasChain, SDNPOutFlag, SDNPSideEffect]>;
Evan Chengd90eb7f2006-01-05 00:27:02 +0000148
Evan Cheng0085a282006-11-30 21:55:46 +0000149def X86Wrapper : SDNode<"X86ISD::Wrapper", SDTX86Wrapper>;
150def X86WrapperRIP : SDNode<"X86ISD::WrapperRIP", SDTX86Wrapper>;
Evan Cheng71fb8342006-02-25 10:02:21 +0000151
Lauro Ramos Venanciob3a04172007-04-20 21:38:10 +0000152def X86tlsaddr : SDNode<"X86ISD::TLSADDR", SDT_X86TLSADDR,
Anton Korobeynikov6625eff2008-05-04 21:36:32 +0000153 [SDNPHasChain, SDNPOptInFlag, SDNPOutFlag]>;
Rafael Espindola094fad32009-04-08 21:14:34 +0000154def X86SegmentBaseAddress : SDNode<"X86ISD::SegmentBaseAddress",
155 SDT_X86SegmentBaseAddress, []>;
Lauro Ramos Venanciob3a04172007-04-20 21:38:10 +0000156
Anton Korobeynikov2365f512007-07-14 14:06:15 +0000157def X86ehret : SDNode<"X86ISD::EH_RETURN", SDT_X86EHRET,
158 [SDNPHasChain]>;
159
Arnold Schwaighoferc85e1712007-10-11 19:40:01 +0000160def X86tcret : SDNode<"X86ISD::TC_RETURN", SDT_X86TCRET,
161 [SDNPHasChain, SDNPOptInFlag]>;
Lauro Ramos Venanciob3a04172007-04-20 21:38:10 +0000162
Dan Gohman43ffe672010-01-04 20:51:05 +0000163def X86add_flag : SDNode<"X86ISD::ADD", SDTBinaryArithWithFlags,
Dan Gohman4361bbf2010-01-05 00:44:20 +0000164 [SDNPCommutative]>;
Dan Gohman076aee32009-03-04 19:44:21 +0000165def X86sub_flag : SDNode<"X86ISD::SUB", SDTBinaryArithWithFlags>;
Dan Gohman43ffe672010-01-04 20:51:05 +0000166def X86smul_flag : SDNode<"X86ISD::SMUL", SDTBinaryArithWithFlags,
Dan Gohman4361bbf2010-01-05 00:44:20 +0000167 [SDNPCommutative]>;
Dan Gohman43ffe672010-01-04 20:51:05 +0000168def X86umul_flag : SDNode<"X86ISD::UMUL", SDTUnaryArithWithFlags,
Dan Gohman4361bbf2010-01-05 00:44:20 +0000169 [SDNPCommutative]>;
Dan Gohman076aee32009-03-04 19:44:21 +0000170def X86inc_flag : SDNode<"X86ISD::INC", SDTUnaryArithWithFlags>;
171def X86dec_flag : SDNode<"X86ISD::DEC", SDTUnaryArithWithFlags>;
Dan Gohman43ffe672010-01-04 20:51:05 +0000172def X86or_flag : SDNode<"X86ISD::OR", SDTBinaryArithWithFlags,
Dan Gohman4361bbf2010-01-05 00:44:20 +0000173 [SDNPCommutative]>;
Dan Gohman43ffe672010-01-04 20:51:05 +0000174def X86xor_flag : SDNode<"X86ISD::XOR", SDTBinaryArithWithFlags,
Dan Gohman4361bbf2010-01-05 00:44:20 +0000175 [SDNPCommutative]>;
Dan Gohman43ffe672010-01-04 20:51:05 +0000176def X86and_flag : SDNode<"X86ISD::AND", SDTBinaryArithWithFlags,
Dan Gohman4361bbf2010-01-05 00:44:20 +0000177 [SDNPCommutative]>;
Bill Wendlingab55ebd2008-12-12 00:56:36 +0000178
Evan Cheng73f24c92009-03-30 21:36:47 +0000179def X86mul_imm : SDNode<"X86ISD::MUL_IMM", SDTIntBinOp>;
180
Anton Korobeynikov043f3c22010-03-06 19:32:29 +0000181def X86MingwAlloca : SDNode<"X86ISD::MINGW_ALLOCA", SDTX86Void,
182 [SDNPHasChain, SDNPInFlag, SDNPOutFlag]>;
183
Evan Chengaed7c722005-12-17 01:24:02 +0000184//===----------------------------------------------------------------------===//
185// X86 Operand Definitions.
186//
187
Dan Gohmana4714e02009-07-30 01:56:29 +0000188// A version of ptr_rc which excludes SP, ESP, and RSP. This is used for
189// the index operand of an address, to conform to x86 encoding restrictions.
190def ptr_rc_nosp : PointerLikeRegClass<1>;
Chris Lattner7680e732009-06-20 19:34:09 +0000191
Chris Lattner66fa1dc2004-08-11 02:25:00 +0000192// *mem - Operand definitions for the funky X86 addressing mode operands.
193//
Daniel Dunbar338825c2009-08-10 18:41:10 +0000194def X86MemAsmOperand : AsmOperandClass {
195 let Name = "Mem";
Daniel Dunbar8e001172009-08-10 19:08:02 +0000196 let SuperClass = ?;
Daniel Dunbar338825c2009-08-10 18:41:10 +0000197}
Daniel Dunbarb834f5d2010-01-30 01:02:48 +0000198def X86AbsMemAsmOperand : AsmOperandClass {
199 let Name = "AbsMem";
200 let SuperClass = X86MemAsmOperand;
201}
Daniel Dunbarec2b1f12010-01-30 00:24:00 +0000202def X86NoSegMemAsmOperand : AsmOperandClass {
203 let Name = "NoSegMem";
204 let SuperClass = X86MemAsmOperand;
205}
Evan Chengaf78ef52006-05-17 21:21:41 +0000206class X86MemOperand<string printMethod> : Operand<iPTR> {
Nate Begeman391c5d22005-11-30 18:54:35 +0000207 let PrintMethod = printMethod;
Dan Gohmana4714e02009-07-30 01:56:29 +0000208 let MIOperandInfo = (ops ptr_rc, i8imm, ptr_rc_nosp, i32imm, i8imm);
Daniel Dunbar338825c2009-08-10 18:41:10 +0000209 let ParserMatchClass = X86MemAsmOperand;
Chris Lattner66fa1dc2004-08-11 02:25:00 +0000210}
Nate Begeman391c5d22005-11-30 18:54:35 +0000211
Sean Callanan9947bbb2009-09-03 00:04:47 +0000212def opaque32mem : X86MemOperand<"printopaquemem">;
213def opaque48mem : X86MemOperand<"printopaquemem">;
214def opaque80mem : X86MemOperand<"printopaquemem">;
Sean Callanan108934c2009-12-18 00:01:26 +0000215def opaque512mem : X86MemOperand<"printopaquemem">;
216
Chris Lattner45432512005-12-17 19:47:05 +0000217def i8mem : X86MemOperand<"printi8mem">;
218def i16mem : X86MemOperand<"printi16mem">;
219def i32mem : X86MemOperand<"printi32mem">;
220def i64mem : X86MemOperand<"printi64mem">;
Evan Cheng470a6ad2006-02-22 02:26:30 +0000221def i128mem : X86MemOperand<"printi128mem">;
Chris Lattnere895c612009-09-20 07:17:49 +0000222//def i256mem : X86MemOperand<"printi256mem">;
Chris Lattner45432512005-12-17 19:47:05 +0000223def f32mem : X86MemOperand<"printf32mem">;
224def f64mem : X86MemOperand<"printf64mem">;
Dale Johannesen59a58732007-08-05 18:49:15 +0000225def f80mem : X86MemOperand<"printf80mem">;
Evan Cheng223547a2006-01-31 22:28:30 +0000226def f128mem : X86MemOperand<"printf128mem">;
Chris Lattnere895c612009-09-20 07:17:49 +0000227//def f256mem : X86MemOperand<"printf256mem">;
Nate Begeman391c5d22005-11-30 18:54:35 +0000228
Dan Gohman21e3dfb2009-04-13 16:09:41 +0000229// A version of i8mem for use on x86-64 that uses GR64_NOREX instead of
230// plain GR64, so that it doesn't potentially require a REX prefix.
231def i8mem_NOREX : Operand<i64> {
232 let PrintMethod = "printi8mem";
Dan Gohmana4714e02009-07-30 01:56:29 +0000233 let MIOperandInfo = (ops GR64_NOREX, i8imm, GR64_NOREX_NOSP, i32imm, i8imm);
Daniel Dunbar338825c2009-08-10 18:41:10 +0000234 let ParserMatchClass = X86MemAsmOperand;
Dan Gohman21e3dfb2009-04-13 16:09:41 +0000235}
236
Evan Chengf48ef032010-03-14 03:48:46 +0000237// Special i32mem for addresses of load folding tail calls. These are not
238// allowed to use callee-saved registers since they must be scheduled
239// after callee-saved register are popped.
240def i32mem_TC : Operand<i32> {
241 let PrintMethod = "printi32mem";
242 let MIOperandInfo = (ops GR32_TC, i8imm, GR32_TC, i32imm, i8imm);
243 let ParserMatchClass = X86MemAsmOperand;
244}
245
Evan Cheng25ab6902006-09-08 06:48:29 +0000246def lea32mem : Operand<i32> {
Rafael Espindola094fad32009-04-08 21:14:34 +0000247 let PrintMethod = "printlea32mem";
Dan Gohman74f6f9a2009-08-05 17:40:24 +0000248 let MIOperandInfo = (ops GR32, i8imm, GR32_NOSP, i32imm);
Daniel Dunbarec2b1f12010-01-30 00:24:00 +0000249 let ParserMatchClass = X86NoSegMemAsmOperand;
Evan Cheng25ab6902006-09-08 06:48:29 +0000250}
251
Daniel Dunbarb834f5d2010-01-30 01:02:48 +0000252let ParserMatchClass = X86AbsMemAsmOperand,
253 PrintMethod = "print_pcrel_imm" in {
Daniel Dunbar728e5eb2010-01-30 00:24:12 +0000254def i32imm_pcrel : Operand<i32>;
255
256def offset8 : Operand<i64>;
257def offset16 : Operand<i64>;
258def offset32 : Operand<i64>;
259def offset64 : Operand<i64>;
260
261// Branch targets have OtherVT type and print as pc-relative values.
262def brtarget : Operand<OtherVT>;
263def brtarget8 : Operand<OtherVT>;
264
265}
266
Nate Begeman16b04f32005-07-15 00:38:55 +0000267def SSECC : Operand<i8> {
268 let PrintMethod = "printSSECC";
269}
Chris Lattner66fa1dc2004-08-11 02:25:00 +0000270
Daniel Dunbar338825c2009-08-10 18:41:10 +0000271def ImmSExt8AsmOperand : AsmOperandClass {
272 let Name = "ImmSExt8";
273 let SuperClass = ImmAsmOperand;
274}
275
Chris Lattnerf124d5e2005-11-18 01:04:42 +0000276// A couple of more descriptive operand definitions.
277// 16-bits but only 8 bits are significant.
Daniel Dunbar5fe63382009-08-09 07:20:21 +0000278def i16i8imm : Operand<i16> {
Daniel Dunbar338825c2009-08-10 18:41:10 +0000279 let ParserMatchClass = ImmSExt8AsmOperand;
Daniel Dunbar5fe63382009-08-09 07:20:21 +0000280}
Chris Lattnerf124d5e2005-11-18 01:04:42 +0000281// 32-bits but only 8 bits are significant.
Daniel Dunbar5fe63382009-08-09 07:20:21 +0000282def i32i8imm : Operand<i32> {
Daniel Dunbar338825c2009-08-10 18:41:10 +0000283 let ParserMatchClass = ImmSExt8AsmOperand;
Daniel Dunbar5fe63382009-08-09 07:20:21 +0000284}
Chris Lattnerf124d5e2005-11-18 01:04:42 +0000285
Evan Chengaed7c722005-12-17 01:24:02 +0000286//===----------------------------------------------------------------------===//
287// X86 Complex Pattern Definitions.
288//
289
Evan Chengec693f72005-12-08 02:01:35 +0000290// Define X86 specific addressing mode.
Rafael Espindola094fad32009-04-08 21:14:34 +0000291def addr : ComplexPattern<iPTR, 5, "SelectAddr", [], []>;
Evan Cheng25ab6902006-09-08 06:48:29 +0000292def lea32addr : ComplexPattern<i32, 4, "SelectLEAAddr",
Dan Gohmana98634b2009-08-02 16:09:17 +0000293 [add, sub, mul, X86mul_imm, shl, or, frameindex],
294 []>;
Chris Lattner5c0b16d2009-06-20 20:38:48 +0000295def tls32addr : ComplexPattern<i32, 4, "SelectTLSADDRAddr",
296 [tglobaltlsaddr], []>;
Evan Chengec693f72005-12-08 02:01:35 +0000297
Evan Chengaed7c722005-12-17 01:24:02 +0000298//===----------------------------------------------------------------------===//
Evan Chengbbc8ddb2005-12-20 22:59:51 +0000299// X86 Instruction Predicate Definitions.
Evan Cheng28b514392006-12-05 19:50:18 +0000300def HasMMX : Predicate<"Subtarget->hasMMX()">;
301def HasSSE1 : Predicate<"Subtarget->hasSSE1()">;
302def HasSSE2 : Predicate<"Subtarget->hasSSE2()">;
303def HasSSE3 : Predicate<"Subtarget->hasSSE3()">;
Bill Wendlingbb1ee052007-04-10 22:10:25 +0000304def HasSSSE3 : Predicate<"Subtarget->hasSSSE3()">;
Nate Begeman63ec90a2008-02-03 07:18:54 +0000305def HasSSE41 : Predicate<"Subtarget->hasSSE41()">;
306def HasSSE42 : Predicate<"Subtarget->hasSSE42()">;
David Greene343dadb2009-06-26 22:46:54 +0000307def HasSSE4A : Predicate<"Subtarget->hasSSE4A()">;
308def HasAVX : Predicate<"Subtarget->hasAVX()">;
309def HasFMA3 : Predicate<"Subtarget->hasFMA3()">;
310def HasFMA4 : Predicate<"Subtarget->hasFMA4()">;
Dale Johannesenf1fc3a82007-09-23 14:52:20 +0000311def FPStackf32 : Predicate<"!Subtarget->hasSSE1()">;
312def FPStackf64 : Predicate<"!Subtarget->hasSSE2()">;
Evan Cheng28b514392006-12-05 19:50:18 +0000313def In32BitMode : Predicate<"!Subtarget->is64Bit()">;
314def In64BitMode : Predicate<"Subtarget->is64Bit()">;
Anton Korobeynikovcf6b7392009-08-03 08:12:53 +0000315def IsWin64 : Predicate<"Subtarget->isTargetWin64()">;
316def NotWin64 : Predicate<"!Subtarget->isTargetWin64()">;
Anton Korobeynikovd7697d02009-08-06 11:23:24 +0000317def SmallCode : Predicate<"TM.getCodeModel() == CodeModel::Small">;
318def KernelCode : Predicate<"TM.getCodeModel() == CodeModel::Kernel">;
319def FarData : Predicate<"TM.getCodeModel() != CodeModel::Small &&"
Anton Korobeynikov186fa1d2009-08-06 09:11:19 +0000320 "TM.getCodeModel() != CodeModel::Kernel">;
Anton Korobeynikovd7697d02009-08-06 11:23:24 +0000321def NearData : Predicate<"TM.getCodeModel() == CodeModel::Small ||"
322 "TM.getCodeModel() == CodeModel::Kernel">;
Evan Cheng28b514392006-12-05 19:50:18 +0000323def IsStatic : Predicate<"TM.getRelocationModel() == Reloc::Static">;
Evan Chengb1f49812009-12-22 17:47:23 +0000324def OptForSize : Predicate<"OptForSize">;
Evan Chengb7a75a52008-09-26 23:41:32 +0000325def OptForSpeed : Predicate<"!OptForSize">;
Evan Chengccb69762009-01-02 05:35:45 +0000326def FastBTMem : Predicate<"!Subtarget->isBTMemSlow()">;
Evan Chengd7f666a2009-05-20 04:53:57 +0000327def CallImmAddr : Predicate<"Subtarget->IsLegalToCallImmediateAddr(TM)">;
Evan Chengbbc8ddb2005-12-20 22:59:51 +0000328
329//===----------------------------------------------------------------------===//
Evan Chengc64a1a92007-07-31 08:04:03 +0000330// X86 Instruction Format Definitions.
Evan Chengaed7c722005-12-17 01:24:02 +0000331//
332
Evan Chengc64a1a92007-07-31 08:04:03 +0000333include "X86InstrFormats.td"
Chris Lattner1cca5e32003-08-03 21:54:21 +0000334
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +0000335//===----------------------------------------------------------------------===//
Chris Lattnerf124d5e2005-11-18 01:04:42 +0000336// Pattern fragments...
337//
Evan Chengd9558e02006-01-06 00:43:03 +0000338
339// X86 specific condition code. These correspond to CondCode in
Nate Begeman9a225302007-05-06 04:00:55 +0000340// X86InstrInfo.h. They must be kept in synch.
Dan Gohman653456c2009-01-07 00:15:08 +0000341def X86_COND_A : PatLeaf<(i8 0)>; // alt. COND_NBE
342def X86_COND_AE : PatLeaf<(i8 1)>; // alt. COND_NC
343def X86_COND_B : PatLeaf<(i8 2)>; // alt. COND_C
344def X86_COND_BE : PatLeaf<(i8 3)>; // alt. COND_NA
345def X86_COND_E : PatLeaf<(i8 4)>; // alt. COND_Z
346def X86_COND_G : PatLeaf<(i8 5)>; // alt. COND_NLE
347def X86_COND_GE : PatLeaf<(i8 6)>; // alt. COND_NL
348def X86_COND_L : PatLeaf<(i8 7)>; // alt. COND_NGE
349def X86_COND_LE : PatLeaf<(i8 8)>; // alt. COND_NG
350def X86_COND_NE : PatLeaf<(i8 9)>; // alt. COND_NZ
Evan Chengd9558e02006-01-06 00:43:03 +0000351def X86_COND_NO : PatLeaf<(i8 10)>;
Dan Gohman653456c2009-01-07 00:15:08 +0000352def X86_COND_NP : PatLeaf<(i8 11)>; // alt. COND_PO
Evan Chengd9558e02006-01-06 00:43:03 +0000353def X86_COND_NS : PatLeaf<(i8 12)>;
Dan Gohman653456c2009-01-07 00:15:08 +0000354def X86_COND_O : PatLeaf<(i8 13)>;
355def X86_COND_P : PatLeaf<(i8 14)>; // alt. COND_PE
356def X86_COND_S : PatLeaf<(i8 15)>;
Evan Chengd9558e02006-01-06 00:43:03 +0000357
Chris Lattner18409912010-03-03 01:45:01 +0000358def immSext8 : PatLeaf<(imm), [{
359 return N->getSExtValue() == (int8_t)N->getSExtValue();
Chris Lattnerf124d5e2005-11-18 01:04:42 +0000360}]>;
361
Chris Lattner18409912010-03-03 01:45:01 +0000362def i16immSExt8 : PatLeaf<(i16 immSext8)>;
363def i32immSExt8 : PatLeaf<(i32 immSext8)>;
Evan Chengb3558542005-12-13 00:01:09 +0000364
Chris Lattnerf85eff72010-03-03 01:52:59 +0000365/// Load patterns: these constraint the match to the right address space.
366def dsload : PatFrag<(ops node:$ptr), (load node:$ptr), [{
367 if (const Value *Src = cast<LoadSDNode>(N)->getSrcValue())
368 if (const PointerType *PT = dyn_cast<PointerType>(Src->getType()))
369 if (PT->getAddressSpace() > 255)
370 return false;
371 return true;
372}]>;
373
374def gsload : PatFrag<(ops node:$ptr), (load node:$ptr), [{
375 if (const Value *Src = cast<LoadSDNode>(N)->getSrcValue())
376 if (const PointerType *PT = dyn_cast<PointerType>(Src->getType()))
377 return PT->getAddressSpace() == 256;
378 return false;
379}]>;
380
381def fsload : PatFrag<(ops node:$ptr), (load node:$ptr), [{
382 if (const Value *Src = cast<LoadSDNode>(N)->getSrcValue())
383 if (const PointerType *PT = dyn_cast<PointerType>(Src->getType()))
384 return PT->getAddressSpace() == 257;
385 return false;
386}]>;
387
388
Evan Cheng605c4152005-12-13 01:57:51 +0000389// Helper fragments for loads.
Evan Chengb6564432008-05-13 18:59:59 +0000390// It's always safe to treat a anyext i16 load as a i32 load if the i16 is
391// known to be 32-bit aligned or better. Ditto for i8 to i16.
Dan Gohman33586292008-10-15 06:50:19 +0000392def loadi16 : PatFrag<(ops node:$ptr), (i16 (unindexedload node:$ptr)), [{
Dan Gohman67ca6be2008-08-20 15:24:22 +0000393 LoadSDNode *LD = cast<LoadSDNode>(N);
Chris Lattnerc2406f22009-04-10 00:16:23 +0000394 if (const Value *Src = LD->getSrcValue())
395 if (const PointerType *PT = dyn_cast<PointerType>(Src->getType()))
Mon P Wanga7e01d72009-04-27 07:22:10 +0000396 if (PT->getAddressSpace() > 255)
Chris Lattnerc2406f22009-04-10 00:16:23 +0000397 return false;
Dan Gohman67ca6be2008-08-20 15:24:22 +0000398 ISD::LoadExtType ExtType = LD->getExtensionType();
399 if (ExtType == ISD::NON_EXTLOAD)
400 return true;
401 if (ExtType == ISD::EXTLOAD)
402 return LD->getAlignment() >= 2 && !LD->isVolatile();
Evan Chengfa7fd332008-05-13 00:54:02 +0000403 return false;
404}]>;
405
Chris Lattnerf85eff72010-03-03 01:52:59 +0000406def loadi16_anyext : PatFrag<(ops node:$ptr), (i32 (unindexedload node:$ptr)),[{
Evan Chengca57f782008-09-24 23:27:55 +0000407 LoadSDNode *LD = cast<LoadSDNode>(N);
Chris Lattnerc2406f22009-04-10 00:16:23 +0000408 if (const Value *Src = LD->getSrcValue())
409 if (const PointerType *PT = dyn_cast<PointerType>(Src->getType()))
Mon P Wanga7e01d72009-04-27 07:22:10 +0000410 if (PT->getAddressSpace() > 255)
Chris Lattnerc2406f22009-04-10 00:16:23 +0000411 return false;
Evan Chengca57f782008-09-24 23:27:55 +0000412 ISD::LoadExtType ExtType = LD->getExtensionType();
413 if (ExtType == ISD::EXTLOAD)
414 return LD->getAlignment() >= 2 && !LD->isVolatile();
415 return false;
416}]>;
417
Dan Gohman33586292008-10-15 06:50:19 +0000418def loadi32 : PatFrag<(ops node:$ptr), (i32 (unindexedload node:$ptr)), [{
Dan Gohman67ca6be2008-08-20 15:24:22 +0000419 LoadSDNode *LD = cast<LoadSDNode>(N);
Chris Lattnerc2406f22009-04-10 00:16:23 +0000420 if (const Value *Src = LD->getSrcValue())
421 if (const PointerType *PT = dyn_cast<PointerType>(Src->getType()))
Mon P Wanga7e01d72009-04-27 07:22:10 +0000422 if (PT->getAddressSpace() > 255)
Chris Lattnerc2406f22009-04-10 00:16:23 +0000423 return false;
Dan Gohman67ca6be2008-08-20 15:24:22 +0000424 ISD::LoadExtType ExtType = LD->getExtensionType();
425 if (ExtType == ISD::NON_EXTLOAD)
426 return true;
427 if (ExtType == ISD::EXTLOAD)
428 return LD->getAlignment() >= 4 && !LD->isVolatile();
Evan Chengfa7fd332008-05-13 00:54:02 +0000429 return false;
430}]>;
431
Chris Lattnerf85eff72010-03-03 01:52:59 +0000432def loadi8 : PatFrag<(ops node:$ptr), (i8 (dsload node:$ptr))>;
433def loadi64 : PatFrag<(ops node:$ptr), (i64 (dsload node:$ptr))>;
434def loadf32 : PatFrag<(ops node:$ptr), (f32 (dsload node:$ptr))>;
435def loadf64 : PatFrag<(ops node:$ptr), (f64 (dsload node:$ptr))>;
436def loadf80 : PatFrag<(ops node:$ptr), (f80 (dsload node:$ptr))>;
Evan Cheng7a7e8372005-12-14 02:22:27 +0000437
Evan Cheng466685d2006-10-09 20:57:25 +0000438def sextloadi16i8 : PatFrag<(ops node:$ptr), (i16 (sextloadi8 node:$ptr))>;
439def sextloadi32i8 : PatFrag<(ops node:$ptr), (i32 (sextloadi8 node:$ptr))>;
440def sextloadi32i16 : PatFrag<(ops node:$ptr), (i32 (sextloadi16 node:$ptr))>;
Evan Cheng7a7e8372005-12-14 02:22:27 +0000441
Evan Cheng466685d2006-10-09 20:57:25 +0000442def zextloadi8i1 : PatFrag<(ops node:$ptr), (i8 (zextloadi1 node:$ptr))>;
443def zextloadi16i1 : PatFrag<(ops node:$ptr), (i16 (zextloadi1 node:$ptr))>;
444def zextloadi32i1 : PatFrag<(ops node:$ptr), (i32 (zextloadi1 node:$ptr))>;
445def zextloadi16i8 : PatFrag<(ops node:$ptr), (i16 (zextloadi8 node:$ptr))>;
446def zextloadi32i8 : PatFrag<(ops node:$ptr), (i32 (zextloadi8 node:$ptr))>;
447def zextloadi32i16 : PatFrag<(ops node:$ptr), (i32 (zextloadi16 node:$ptr))>;
Evan Cheng7a7e8372005-12-14 02:22:27 +0000448
Evan Cheng466685d2006-10-09 20:57:25 +0000449def extloadi8i1 : PatFrag<(ops node:$ptr), (i8 (extloadi1 node:$ptr))>;
450def extloadi16i1 : PatFrag<(ops node:$ptr), (i16 (extloadi1 node:$ptr))>;
451def extloadi32i1 : PatFrag<(ops node:$ptr), (i32 (extloadi1 node:$ptr))>;
452def extloadi16i8 : PatFrag<(ops node:$ptr), (i16 (extloadi8 node:$ptr))>;
453def extloadi32i8 : PatFrag<(ops node:$ptr), (i32 (extloadi8 node:$ptr))>;
454def extloadi32i16 : PatFrag<(ops node:$ptr), (i32 (extloadi16 node:$ptr))>;
Evan Cheng747a90d2006-02-21 02:24:38 +0000455
Chris Lattnerce2bcc82008-02-19 17:37:35 +0000456
457// An 'and' node with a single use.
458def and_su : PatFrag<(ops node:$lhs, node:$rhs), (and node:$lhs, node:$rhs), [{
Evan Cheng07b7ea12008-03-04 00:40:35 +0000459 return N->hasOneUse();
Chris Lattnerce2bcc82008-02-19 17:37:35 +0000460}]>;
Dan Gohman21e3dfb2009-04-13 16:09:41 +0000461// An 'srl' node with a single use.
462def srl_su : PatFrag<(ops node:$lhs, node:$rhs), (srl node:$lhs, node:$rhs), [{
463 return N->hasOneUse();
464}]>;
465// An 'trunc' node with a single use.
466def trunc_su : PatFrag<(ops node:$src), (trunc node:$src), [{
467 return N->hasOneUse();
468}]>;
Chris Lattnerce2bcc82008-02-19 17:37:35 +0000469
Evan Cheng4b0345b2010-01-11 17:03:47 +0000470// Treat an 'or' node is as an 'add' if the or'ed bits are known to be zero.
471def or_is_add : PatFrag<(ops node:$lhs, node:$rhs), (or node:$lhs, node:$rhs),[{
472 if (ConstantSDNode *CN = dyn_cast<ConstantSDNode>(N->getOperand(1)))
473 return CurDAG->MaskedValueIsZero(N->getOperand(0), CN->getAPIntValue());
Evan Cheng199c4242010-01-11 22:03:29 +0000474 else {
475 unsigned BitWidth = N->getValueType(0).getScalarType().getSizeInBits();
476 APInt Mask = APInt::getAllOnesValue(BitWidth);
477 APInt KnownZero0, KnownOne0;
478 CurDAG->ComputeMaskedBits(N->getOperand(0), Mask, KnownZero0, KnownOne0, 0);
479 APInt KnownZero1, KnownOne1;
480 CurDAG->ComputeMaskedBits(N->getOperand(1), Mask, KnownZero1, KnownOne1, 0);
481 return (~KnownZero0 & ~KnownZero1) == 0;
482 }
Evan Cheng4b0345b2010-01-11 17:03:47 +0000483}]>;
Evan Cheng4b0345b2010-01-11 17:03:47 +0000484
Dan Gohman74feef22008-10-17 01:23:35 +0000485// 'shld' and 'shrd' instruction patterns. Note that even though these have
486// the srl and shl in their patterns, the C++ code must still check for them,
487// because predicates are tested before children nodes are explored.
488
489def shrd : PatFrag<(ops node:$src1, node:$amt1, node:$src2, node:$amt2),
490 (or (srl node:$src1, node:$amt1),
491 (shl node:$src2, node:$amt2)), [{
492 assert(N->getOpcode() == ISD::OR);
493 return N->getOperand(0).getOpcode() == ISD::SRL &&
494 N->getOperand(1).getOpcode() == ISD::SHL &&
495 isa<ConstantSDNode>(N->getOperand(0).getOperand(1)) &&
496 isa<ConstantSDNode>(N->getOperand(1).getOperand(1)) &&
497 N->getOperand(0).getConstantOperandVal(1) ==
498 N->getValueSizeInBits(0) - N->getOperand(1).getConstantOperandVal(1);
499}]>;
500
501def shld : PatFrag<(ops node:$src1, node:$amt1, node:$src2, node:$amt2),
502 (or (shl node:$src1, node:$amt1),
503 (srl node:$src2, node:$amt2)), [{
504 assert(N->getOpcode() == ISD::OR);
505 return N->getOperand(0).getOpcode() == ISD::SHL &&
506 N->getOperand(1).getOpcode() == ISD::SRL &&
507 isa<ConstantSDNode>(N->getOperand(0).getOperand(1)) &&
508 isa<ConstantSDNode>(N->getOperand(1).getOperand(1)) &&
509 N->getOperand(0).getConstantOperandVal(1) ==
510 N->getValueSizeInBits(0) - N->getOperand(1).getConstantOperandVal(1);
511}]>;
512
Chris Lattnerf124d5e2005-11-18 01:04:42 +0000513//===----------------------------------------------------------------------===//
Chris Lattner1cca5e32003-08-03 21:54:21 +0000514// Instruction list...
515//
516
Chris Lattnerf18c0742006-10-12 17:42:56 +0000517// ADJCALLSTACKDOWN/UP implicitly use/def ESP because they may be expanded into
518// a stack adjustment and the codegen must know that they may modify the stack
519// pointer before prolog-epilog rewriting occurs.
Chris Lattner447ff682008-03-11 03:23:40 +0000520// Pessimistically assume ADJCALLSTACKDOWN / ADJCALLSTACKUP will become
521// sub / add which can clobber EFLAGS.
Evan Cheng8decf6b2007-09-28 01:19:48 +0000522let Defs = [ESP, EFLAGS], Uses = [ESP] in {
Dan Gohman6d4b0522008-10-01 18:28:06 +0000523def ADJCALLSTACKDOWN32 : I<0, Pseudo, (outs), (ins i32imm:$amt),
524 "#ADJCALLSTACKDOWN",
Chris Lattnere563bbc2008-10-11 22:08:30 +0000525 [(X86callseq_start timm:$amt)]>,
Dan Gohman6d4b0522008-10-01 18:28:06 +0000526 Requires<[In32BitMode]>;
527def ADJCALLSTACKUP32 : I<0, Pseudo, (outs), (ins i32imm:$amt1, i32imm:$amt2),
528 "#ADJCALLSTACKUP",
Chris Lattnere563bbc2008-10-11 22:08:30 +0000529 [(X86callseq_end timm:$amt1, timm:$amt2)]>,
Dan Gohman6d4b0522008-10-01 18:28:06 +0000530 Requires<[In32BitMode]>;
Evan Cheng071a2792007-09-11 19:55:27 +0000531}
Evan Cheng4a460802006-01-11 00:33:36 +0000532
Dan Gohmand6708ea2009-08-15 01:38:56 +0000533// x86-64 va_start lowering magic.
Anton Korobeynikov043f3c22010-03-06 19:32:29 +0000534let usesCustomInserter = 1 in {
Dan Gohmand6708ea2009-08-15 01:38:56 +0000535def VASTART_SAVE_XMM_REGS : I<0, Pseudo,
536 (outs),
537 (ins GR8:$al,
538 i64imm:$regsavefi, i64imm:$offset,
539 variable_ops),
540 "#VASTART_SAVE_XMM_REGS $al, $regsavefi, $offset",
541 [(X86vastart_save_xmm_regs GR8:$al,
542 imm:$regsavefi,
543 imm:$offset)]>;
544
Anton Korobeynikove765f2b2010-03-06 20:07:32 +0000545// Dynamic stack allocation yields _alloca call for Cygwin/Mingw targets. Calls
546// to _alloca is needed to probe the stack when allocating more than 4k bytes in
547// one go. Touching the stack at 4K increments is necessary to ensure that the
548// guard pages used by the OS virtual memory manager are allocated in correct
549// sequence.
550// The main point of having separate instruction are extra unmodelled effects
551// (compared to ordinary calls) like stack pointer change.
552
Anton Korobeynikov043f3c22010-03-06 19:32:29 +0000553def MINGW_ALLOCA : I<0, Pseudo, (outs), (ins),
Anton Korobeynikove765f2b2010-03-06 20:07:32 +0000554 "# dynamic stack allocation",
Anton Korobeynikov043f3c22010-03-06 19:32:29 +0000555 [(X86MingwAlloca)]>;
556}
557
Evan Cheng4a460802006-01-11 00:33:36 +0000558// Nop
Sean Callanan74e52102009-07-23 23:39:34 +0000559let neverHasSideEffects = 1 in {
Chris Lattnerba7e7562008-01-10 07:59:24 +0000560 def NOOP : I<0x90, RawFrm, (outs), (ins), "nop", []>;
Sean Callanan108934c2009-12-18 00:01:26 +0000561 def NOOPW : I<0x1f, MRM0m, (outs), (ins i16mem:$zero),
562 "nop{w}\t$zero", []>, TB, OpSize;
Sean Callanan74e52102009-07-23 23:39:34 +0000563 def NOOPL : I<0x1f, MRM0m, (outs), (ins i32mem:$zero),
Sean Callanan108934c2009-12-18 00:01:26 +0000564 "nop{l}\t$zero", []>, TB;
Sean Callanan74e52102009-07-23 23:39:34 +0000565}
Evan Cheng4a460802006-01-11 00:33:36 +0000566
Sean Callanan1c5cf1b2009-08-11 01:09:06 +0000567// Trap
Dan Gohmane94975e2009-11-11 18:07:16 +0000568def INT3 : I<0xcc, RawFrm, (outs), (ins), "int\t3", []>;
Sean Callanan1c5cf1b2009-08-11 01:09:06 +0000569def INT : I<0xcd, RawFrm, (outs), (ins i8imm:$trap), "int\t$trap", []>;
Sean Callanan108934c2009-12-18 00:01:26 +0000570def IRET16 : I<0xcf, RawFrm, (outs), (ins), "iret{w}", []>, OpSize;
571def IRET32 : I<0xcf, RawFrm, (outs), (ins), "iret{l}", []>;
Sean Callanan1c5cf1b2009-08-11 01:09:06 +0000572
Chris Lattner71c7ace2009-09-20 07:32:00 +0000573// PIC base construction. This expands to code that looks like this:
574// call $next_inst
575// popl %destreg"
Dan Gohman2662d552008-10-01 04:14:30 +0000576let neverHasSideEffects = 1, isNotDuplicable = 1, Uses = [ESP] in
Chris Lattnerb3c85472009-09-20 07:28:26 +0000577 def MOVPC32r : Ii32<0xE8, Pseudo, (outs GR32:$reg), (ins i32imm:$label),
Chris Lattner71c7ace2009-09-20 07:32:00 +0000578 "", []>;
Evan Cheng8f7f7122006-05-05 05:40:20 +0000579
Chris Lattner1cca5e32003-08-03 21:54:21 +0000580//===----------------------------------------------------------------------===//
Chris Lattnerbd13fb62010-02-11 19:25:55 +0000581// Control Flow Instructions.
Chris Lattner1cca5e32003-08-03 21:54:21 +0000582//
583
Chris Lattner1be48112005-05-13 17:56:48 +0000584// Return instructions.
Evan Cheng2b4ea792005-12-26 09:11:45 +0000585let isTerminator = 1, isReturn = 1, isBarrier = 1,
Chris Lattner447ff682008-03-11 03:23:40 +0000586 hasCtrlDep = 1, FPForm = SpecialFP, FPFormBits = SpecialFP.Value in {
Dan Gohmane4c67cd2008-05-31 02:11:25 +0000587 def RET : I <0xC3, RawFrm, (outs), (ins variable_ops),
Chris Lattner447ff682008-03-11 03:23:40 +0000588 "ret",
Dan Gohmane4c67cd2008-05-31 02:11:25 +0000589 [(X86retflag 0)]>;
Chris Lattner447ff682008-03-11 03:23:40 +0000590 def RETI : Ii16<0xC2, RawFrm, (outs), (ins i16imm:$amt, variable_ops),
591 "ret\t$amt",
Dan Gohman2f67df72009-09-03 17:18:51 +0000592 [(X86retflag timm:$amt)]>;
Sean Callanan356aed52009-09-15 23:37:51 +0000593 def LRET : I <0xCB, RawFrm, (outs), (ins),
594 "lret", []>;
595 def LRETI : Ii16<0xCA, RawFrm, (outs), (ins i16imm:$amt),
596 "lret\t$amt", []>;
Evan Cheng171049d2005-12-23 22:14:32 +0000597}
Chris Lattner1cca5e32003-08-03 21:54:21 +0000598
Chris Lattnerbd13fb62010-02-11 19:25:55 +0000599// Unconditional branches.
Chris Lattnerb8db3312010-02-11 21:45:31 +0000600let isBarrier = 1, isBranch = 1, isTerminator = 1 in {
Chris Lattnera0331192010-02-12 22:27:07 +0000601 def JMP_4 : Ii32PCRel<0xE9, RawFrm, (outs), (ins brtarget:$dst),
602 "jmp\t$dst", [(br bb:$dst)]>;
603 def JMP_1 : Ii8PCRel<0xEB, RawFrm, (outs), (ins brtarget8:$dst),
604 "jmp\t$dst", []>;
Sean Callanan52925882009-07-22 01:05:20 +0000605}
Evan Cheng898101c2005-12-19 23:12:38 +0000606
Chris Lattnerbd13fb62010-02-11 19:25:55 +0000607// Conditional Branches.
608let isBranch = 1, isTerminator = 1, Uses = [EFLAGS] in {
609 multiclass ICBr<bits<8> opc1, bits<8> opc4, string asm, PatFrag Cond> {
Chris Lattnera0331192010-02-12 22:27:07 +0000610 def _1 : Ii8PCRel <opc1, RawFrm, (outs), (ins brtarget8:$dst), asm, []>;
611 def _4 : Ii32PCRel<opc4, RawFrm, (outs), (ins brtarget:$dst), asm,
612 [(X86brcond bb:$dst, Cond, EFLAGS)]>, TB;
Chris Lattnerbd13fb62010-02-11 19:25:55 +0000613 }
614}
615
616defm JO : ICBr<0x70, 0x80, "jo\t$dst" , X86_COND_O>;
Chris Lattner8b442a82010-02-11 19:52:11 +0000617defm JNO : ICBr<0x71, 0x81, "jno\t$dst" , X86_COND_NO>;
Chris Lattnerbd13fb62010-02-11 19:25:55 +0000618defm JB : ICBr<0x72, 0x82, "jb\t$dst" , X86_COND_B>;
619defm JAE : ICBr<0x73, 0x83, "jae\t$dst", X86_COND_AE>;
620defm JE : ICBr<0x74, 0x84, "je\t$dst" , X86_COND_E>;
621defm JNE : ICBr<0x75, 0x85, "jne\t$dst", X86_COND_NE>;
622defm JBE : ICBr<0x76, 0x86, "jbe\t$dst", X86_COND_BE>;
623defm JA : ICBr<0x77, 0x87, "ja\t$dst" , X86_COND_A>;
624defm JS : ICBr<0x78, 0x88, "js\t$dst" , X86_COND_S>;
625defm JNS : ICBr<0x79, 0x89, "jns\t$dst", X86_COND_NS>;
626defm JP : ICBr<0x7A, 0x8A, "jp\t$dst" , X86_COND_P>;
627defm JNP : ICBr<0x7B, 0x8B, "jnp\t$dst", X86_COND_NP>;
628defm JL : ICBr<0x7C, 0x8C, "jl\t$dst" , X86_COND_L>;
629defm JGE : ICBr<0x7D, 0x8D, "jge\t$dst", X86_COND_GE>;
630defm JLE : ICBr<0x7E, 0x8E, "jle\t$dst", X86_COND_LE>;
631defm JG : ICBr<0x7F, 0x8F, "jg\t$dst" , X86_COND_G>;
632
633// FIXME: What about the CX/RCX versions of this instruction?
Chris Lattnerb8db3312010-02-11 21:45:31 +0000634let Uses = [ECX], isBranch = 1, isTerminator = 1 in
Chris Lattnera0331192010-02-12 22:27:07 +0000635 def JCXZ8 : Ii8PCRel<0xE3, RawFrm, (outs), (ins brtarget8:$dst),
636 "jcxz\t$dst", []>;
Chris Lattnerbd13fb62010-02-11 19:25:55 +0000637
638
Owen Anderson20ab2902007-11-12 07:39:39 +0000639// Indirect branches
640let isBranch = 1, isTerminator = 1, isBarrier = 1, isIndirectBranch = 1 in {
Dan Gohmanb1576f52007-07-31 20:11:57 +0000641 def JMP32r : I<0xFF, MRM4r, (outs), (ins GR32:$dst), "jmp{l}\t{*}$dst",
Evan Cheng069287d2006-05-16 07:21:53 +0000642 [(brind GR32:$dst)]>;
Dan Gohmanb1576f52007-07-31 20:11:57 +0000643 def JMP32m : I<0xFF, MRM4m, (outs), (ins i32mem:$dst), "jmp{l}\t{*}$dst",
Evan Cheng25ab6902006-09-08 06:48:29 +0000644 [(brind (loadi32 addr:$dst))]>;
Sean Callanan76f14be2009-09-15 00:35:17 +0000645
646 def FARJMP16i : Iseg16<0xEA, RawFrm, (outs),
647 (ins i16imm:$seg, i16imm:$off),
648 "ljmp{w}\t$seg, $off", []>, OpSize;
649 def FARJMP32i : Iseg32<0xEA, RawFrm, (outs),
650 (ins i16imm:$seg, i32imm:$off),
651 "ljmp{l}\t$seg, $off", []>;
652
653 def FARJMP16m : I<0xFF, MRM5m, (outs), (ins opaque32mem:$dst),
Sean Callanan9947bbb2009-09-03 00:04:47 +0000654 "ljmp{w}\t{*}$dst", []>, OpSize;
Sean Callanan76f14be2009-09-15 00:35:17 +0000655 def FARJMP32m : I<0xFF, MRM5m, (outs), (ins opaque48mem:$dst),
Sean Callanan9947bbb2009-09-03 00:04:47 +0000656 "ljmp{l}\t{*}$dst", []>;
Nate Begeman37efe672006-04-22 18:53:45 +0000657}
658
Chris Lattner1cca5e32003-08-03 21:54:21 +0000659
Sean Callanan7e6d7272009-09-16 21:50:07 +0000660// Loop instructions
661
662def LOOP : I<0xE2, RawFrm, (ins brtarget8:$dst), (outs), "loop\t$dst", []>;
663def LOOPE : I<0xE1, RawFrm, (ins brtarget8:$dst), (outs), "loope\t$dst", []>;
664def LOOPNE : I<0xE0, RawFrm, (ins brtarget8:$dst), (outs), "loopne\t$dst", []>;
665
Chris Lattner1cca5e32003-08-03 21:54:21 +0000666//===----------------------------------------------------------------------===//
667// Call Instructions...
668//
Evan Chengffbacca2007-07-21 00:34:19 +0000669let isCall = 1 in
Dan Gohman6d4b0522008-10-01 18:28:06 +0000670 // All calls clobber the non-callee saved registers. ESP is marked as
671 // a use to prevent stack-pointer assignments that appear immediately
672 // before calls from potentially appearing dead. Uses for argument
673 // registers are added manually.
Nate Begemanf63be7d2005-07-06 18:59:04 +0000674 let Defs = [EAX, ECX, EDX, FP0, FP1, FP2, FP3, FP4, FP5, FP6, ST0,
Bill Wendling3f3a17d2007-04-25 21:31:48 +0000675 MM0, MM1, MM2, MM3, MM4, MM5, MM6, MM7,
Evan Cheng109a5622008-10-17 21:02:22 +0000676 XMM0, XMM1, XMM2, XMM3, XMM4, XMM5, XMM6, XMM7,
677 XMM8, XMM9, XMM10, XMM11, XMM12, XMM13, XMM14, XMM15, EFLAGS],
Dan Gohman2662d552008-10-01 04:14:30 +0000678 Uses = [ESP] in {
Chris Lattnera0331192010-02-12 22:27:07 +0000679 def CALLpcrel32 : Ii32PCRel<0xE8, RawFrm,
Chris Lattner7680e732009-06-20 19:34:09 +0000680 (outs), (ins i32imm_pcrel:$dst,variable_ops),
681 "call\t$dst", []>;
Evan Cheng64d80e32007-07-19 01:14:50 +0000682 def CALL32r : I<0xFF, MRM2r, (outs), (ins GR32:$dst, variable_ops),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000683 "call\t{*}$dst", [(X86call GR32:$dst)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +0000684 def CALL32m : I<0xFF, MRM2m, (outs), (ins i32mem:$dst, variable_ops),
Dan Gohmanb4106172008-05-29 21:50:34 +0000685 "call\t{*}$dst", [(X86call (loadi32 addr:$dst))]>;
Sean Callanan9947bbb2009-09-03 00:04:47 +0000686
Sean Callanan76f14be2009-09-15 00:35:17 +0000687 def FARCALL16i : Iseg16<0x9A, RawFrm, (outs),
688 (ins i16imm:$seg, i16imm:$off),
689 "lcall{w}\t$seg, $off", []>, OpSize;
690 def FARCALL32i : Iseg32<0x9A, RawFrm, (outs),
691 (ins i16imm:$seg, i32imm:$off),
692 "lcall{l}\t$seg, $off", []>;
693
694 def FARCALL16m : I<0xFF, MRM3m, (outs), (ins opaque32mem:$dst),
Sean Callanan9947bbb2009-09-03 00:04:47 +0000695 "lcall{w}\t{*}$dst", []>, OpSize;
Sean Callanan76f14be2009-09-15 00:35:17 +0000696 def FARCALL32m : I<0xFF, MRM3m, (outs), (ins opaque48mem:$dst),
Sean Callanan9947bbb2009-09-03 00:04:47 +0000697 "lcall{l}\t{*}$dst", []>;
Chris Lattner1cca5e32003-08-03 21:54:21 +0000698 }
699
Sean Callanan8d708542009-09-16 02:57:13 +0000700// Constructing a stack frame.
701
702def ENTER : I<0xC8, RawFrm, (outs), (ins i16imm:$len, i8imm:$lvl),
703 "enter\t$len, $lvl", []>;
704
Chris Lattner1e9448b2005-05-15 03:10:37 +0000705// Tail call stuff.
Arnold Schwaighoferc85e1712007-10-11 19:40:01 +0000706
Evan Chengffbacca2007-07-21 00:34:19 +0000707let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1 in
Evan Chengf48ef032010-03-14 03:48:46 +0000708 let Defs = [EAX, ECX, EDX, FP0, FP1, FP2, FP3, FP4, FP5, FP6, ST0,
709 MM0, MM1, MM2, MM3, MM4, MM5, MM6, MM7,
710 XMM0, XMM1, XMM2, XMM3, XMM4, XMM5, XMM6, XMM7,
711 XMM8, XMM9, XMM10, XMM11, XMM12, XMM13, XMM14, XMM15, EFLAGS],
712 Uses = [ESP] in {
713 def TCRETURNdi : I<0, Pseudo, (outs),
714 (ins i32imm_pcrel:$dst, i32imm:$offset, variable_ops),
715 "#TC_RETURN $dst $offset", []>;
716 def TCRETURNri : I<0, Pseudo, (outs),
717 (ins GR32_TC:$dst, i32imm:$offset, variable_ops),
718 "#TC_RETURN $dst $offset", []>;
719 def TCRETURNmi : I<0, Pseudo, (outs),
720 (ins i32mem_TC:$dst, i32imm:$offset, variable_ops),
721 "#TC_RETURN $dst $offset", []>;
Arnold Schwaighoferc85e1712007-10-11 19:40:01 +0000722
Evan Chengf48ef032010-03-14 03:48:46 +0000723 // FIXME: The should be pseudo instructions that are lowered when going to
724 // mcinst.
725 def TAILJMPd : Ii32<0xE9, RawFrm, (outs),
726 (ins i32imm_pcrel:$dst, variable_ops),
Evan Chengaa92bec2010-01-31 07:28:44 +0000727 "jmp\t$dst # TAILCALL",
Evan Chengf10c17f2006-09-22 21:43:59 +0000728 []>;
Evan Chengf48ef032010-03-14 03:48:46 +0000729 def TAILJMPr : I<0xFF, MRM4r, (outs), (ins GR32_TC:$dst, variable_ops),
Sean Callanan108934c2009-12-18 00:01:26 +0000730 "jmp{l}\t{*}$dst # TAILCALL",
Arnold Schwaighoferc85e1712007-10-11 19:40:01 +0000731 []>;
Evan Chengf48ef032010-03-14 03:48:46 +0000732 def TAILJMPm : I<0xFF, MRM4m, (outs), (ins i32mem_TC:$dst, variable_ops),
733 "jmp{l}\t{*}$dst # TAILCALL", []>;
734}
Chris Lattner1e9448b2005-05-15 03:10:37 +0000735
Chris Lattner1cca5e32003-08-03 21:54:21 +0000736//===----------------------------------------------------------------------===//
737// Miscellaneous Instructions...
738//
Chris Lattnerba7e7562008-01-10 07:59:24 +0000739let Defs = [EBP, ESP], Uses = [EBP, ESP], mayLoad = 1, neverHasSideEffects=1 in
Chris Lattner30bf2d82004-08-10 20:17:41 +0000740def LEAVE : I<0xC9, RawFrm,
Evan Cheng071a2792007-09-11 19:55:27 +0000741 (outs), (ins), "leave", []>;
742
Sean Callanan108934c2009-12-18 00:01:26 +0000743def POPCNT16rr : I<0xB8, MRMSrcReg, (outs GR16:$dst), (ins GR16:$src),
744 "popcnt{w}\t{$src, $dst|$dst, $src}", []>, OpSize, XS;
745def POPCNT16rm : I<0xB8, MRMSrcMem, (outs GR16:$dst), (ins i16mem:$src),
746 "popcnt{w}\t{$src, $dst|$dst, $src}", []>, OpSize, XS;
747def POPCNT32rr : I<0xB8, MRMSrcReg, (outs GR32:$dst), (ins GR32:$src),
748 "popcnt{l}\t{$src, $dst|$dst, $src}", []>, XS;
749def POPCNT32rm : I<0xB8, MRMSrcMem, (outs GR32:$dst), (ins i32mem:$src),
750 "popcnt{l}\t{$src, $dst|$dst, $src}", []>, XS;
751
Chris Lattnerba7e7562008-01-10 07:59:24 +0000752let Defs = [ESP], Uses = [ESP], neverHasSideEffects=1 in {
Sean Callanan1f24e012009-09-10 18:29:13 +0000753let mayLoad = 1 in {
754def POP16r : I<0x58, AddRegFrm, (outs GR16:$reg), (ins), "pop{w}\t$reg", []>,
755 OpSize;
756def POP32r : I<0x58, AddRegFrm, (outs GR32:$reg), (ins), "pop{l}\t$reg", []>;
757def POP16rmr: I<0x8F, MRM0r, (outs GR16:$reg), (ins), "pop{w}\t$reg", []>,
758 OpSize;
759def POP16rmm: I<0x8F, MRM0m, (outs i16mem:$dst), (ins), "pop{w}\t$dst", []>,
760 OpSize;
761def POP32rmr: I<0x8F, MRM0r, (outs GR32:$reg), (ins), "pop{l}\t$reg", []>;
762def POP32rmm: I<0x8F, MRM0m, (outs i32mem:$dst), (ins), "pop{l}\t$dst", []>;
763}
Chris Lattner1cca5e32003-08-03 21:54:21 +0000764
Sean Callanan1f24e012009-09-10 18:29:13 +0000765let mayStore = 1 in {
766def PUSH16r : I<0x50, AddRegFrm, (outs), (ins GR16:$reg), "push{w}\t$reg",[]>,
767 OpSize;
Evan Cheng2f245ba2007-09-26 01:29:06 +0000768def PUSH32r : I<0x50, AddRegFrm, (outs), (ins GR32:$reg), "push{l}\t$reg",[]>;
Sean Callanan1f24e012009-09-10 18:29:13 +0000769def PUSH16rmr: I<0xFF, MRM6r, (outs), (ins GR16:$reg), "push{w}\t$reg",[]>,
770 OpSize;
771def PUSH16rmm: I<0xFF, MRM6m, (outs), (ins i16mem:$src), "push{w}\t$src",[]>,
772 OpSize;
773def PUSH32rmr: I<0xFF, MRM6r, (outs), (ins GR32:$reg), "push{l}\t$reg",[]>;
774def PUSH32rmm: I<0xFF, MRM6m, (outs), (ins i32mem:$src), "push{l}\t$src",[]>;
775}
Evan Cheng071a2792007-09-11 19:55:27 +0000776}
Anton Korobeynikov57fc00d2007-04-17 09:20:00 +0000777
Bill Wendling453eb262009-06-15 19:39:04 +0000778let Defs = [ESP], Uses = [ESP], neverHasSideEffects = 1, mayStore = 1 in {
779def PUSH32i8 : Ii8<0x6a, RawFrm, (outs), (ins i8imm:$imm),
Bill Wendling927788c2009-06-15 20:59:31 +0000780 "push{l}\t$imm", []>;
Bill Wendling453eb262009-06-15 19:39:04 +0000781def PUSH32i16 : Ii16<0x68, RawFrm, (outs), (ins i16imm:$imm),
Bill Wendling927788c2009-06-15 20:59:31 +0000782 "push{l}\t$imm", []>;
Bill Wendling453eb262009-06-15 19:39:04 +0000783def PUSH32i32 : Ii32<0x68, RawFrm, (outs), (ins i32imm:$imm),
Bill Wendling927788c2009-06-15 20:59:31 +0000784 "push{l}\t$imm", []>;
Bill Wendling453eb262009-06-15 19:39:04 +0000785}
786
Sean Callanan108934c2009-12-18 00:01:26 +0000787let Defs = [ESP, EFLAGS], Uses = [ESP], mayLoad = 1, neverHasSideEffects=1 in {
788def POPF : I<0x9D, RawFrm, (outs), (ins), "popf{w}", []>, OpSize;
789def POPFD : I<0x9D, RawFrm, (outs), (ins), "popf{l}", []>;
790}
791let Defs = [ESP], Uses = [ESP, EFLAGS], mayStore = 1, neverHasSideEffects=1 in {
792def PUSHF : I<0x9C, RawFrm, (outs), (ins), "pushf{w}", []>, OpSize;
793def PUSHFD : I<0x9C, RawFrm, (outs), (ins), "pushf{l}", []>;
794}
Evan Cheng2f245ba2007-09-26 01:29:06 +0000795
Evan Cheng069287d2006-05-16 07:21:53 +0000796let isTwoAddress = 1 in // GR32 = bswap GR32
Chris Lattner30bf2d82004-08-10 20:17:41 +0000797 def BSWAP32r : I<0xC8, AddRegFrm,
Evan Cheng64d80e32007-07-19 01:14:50 +0000798 (outs GR32:$dst), (ins GR32:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000799 "bswap{l}\t$dst",
Evan Cheng069287d2006-05-16 07:21:53 +0000800 [(set GR32:$dst, (bswap GR32:$src))]>, TB;
Chris Lattner1cca5e32003-08-03 21:54:21 +0000801
Chris Lattner1cca5e32003-08-03 21:54:21 +0000802
Evan Cheng18efe262007-12-14 02:13:44 +0000803// Bit scan instructions.
804let Defs = [EFLAGS] in {
Evan Chengfd9e4732007-12-14 18:49:43 +0000805def BSF16rr : I<0xBC, MRMSrcReg, (outs GR16:$dst), (ins GR16:$src),
Dan Gohman1a8001e2007-12-14 15:10:00 +0000806 "bsf{w}\t{$src, $dst|$dst, $src}",
Evan Cheng152804e2007-12-14 08:30:15 +0000807 [(set GR16:$dst, (X86bsf GR16:$src)), (implicit EFLAGS)]>, TB;
Evan Cheng18efe262007-12-14 02:13:44 +0000808def BSF16rm : I<0xBC, MRMSrcMem, (outs GR16:$dst), (ins i16mem:$src),
Dan Gohman1a8001e2007-12-14 15:10:00 +0000809 "bsf{w}\t{$src, $dst|$dst, $src}",
Evan Cheng152804e2007-12-14 08:30:15 +0000810 [(set GR16:$dst, (X86bsf (loadi16 addr:$src))),
811 (implicit EFLAGS)]>, TB;
Evan Chengfd9e4732007-12-14 18:49:43 +0000812def BSF32rr : I<0xBC, MRMSrcReg, (outs GR32:$dst), (ins GR32:$src),
Dan Gohman1a8001e2007-12-14 15:10:00 +0000813 "bsf{l}\t{$src, $dst|$dst, $src}",
Evan Cheng152804e2007-12-14 08:30:15 +0000814 [(set GR32:$dst, (X86bsf GR32:$src)), (implicit EFLAGS)]>, TB;
Evan Cheng18efe262007-12-14 02:13:44 +0000815def BSF32rm : I<0xBC, MRMSrcMem, (outs GR32:$dst), (ins i32mem:$src),
Dan Gohman1a8001e2007-12-14 15:10:00 +0000816 "bsf{l}\t{$src, $dst|$dst, $src}",
Evan Cheng152804e2007-12-14 08:30:15 +0000817 [(set GR32:$dst, (X86bsf (loadi32 addr:$src))),
818 (implicit EFLAGS)]>, TB;
Evan Cheng18efe262007-12-14 02:13:44 +0000819
Evan Chengfd9e4732007-12-14 18:49:43 +0000820def BSR16rr : I<0xBD, MRMSrcReg, (outs GR16:$dst), (ins GR16:$src),
Dan Gohman1a8001e2007-12-14 15:10:00 +0000821 "bsr{w}\t{$src, $dst|$dst, $src}",
Evan Cheng152804e2007-12-14 08:30:15 +0000822 [(set GR16:$dst, (X86bsr GR16:$src)), (implicit EFLAGS)]>, TB;
Evan Cheng18efe262007-12-14 02:13:44 +0000823def BSR16rm : I<0xBD, MRMSrcMem, (outs GR16:$dst), (ins i16mem:$src),
Dan Gohman1a8001e2007-12-14 15:10:00 +0000824 "bsr{w}\t{$src, $dst|$dst, $src}",
Evan Cheng152804e2007-12-14 08:30:15 +0000825 [(set GR16:$dst, (X86bsr (loadi16 addr:$src))),
826 (implicit EFLAGS)]>, TB;
Evan Chengfd9e4732007-12-14 18:49:43 +0000827def BSR32rr : I<0xBD, MRMSrcReg, (outs GR32:$dst), (ins GR32:$src),
Dan Gohman1a8001e2007-12-14 15:10:00 +0000828 "bsr{l}\t{$src, $dst|$dst, $src}",
Evan Cheng152804e2007-12-14 08:30:15 +0000829 [(set GR32:$dst, (X86bsr GR32:$src)), (implicit EFLAGS)]>, TB;
Evan Cheng18efe262007-12-14 02:13:44 +0000830def BSR32rm : I<0xBD, MRMSrcMem, (outs GR32:$dst), (ins i32mem:$src),
Dan Gohman1a8001e2007-12-14 15:10:00 +0000831 "bsr{l}\t{$src, $dst|$dst, $src}",
Evan Cheng152804e2007-12-14 08:30:15 +0000832 [(set GR32:$dst, (X86bsr (loadi32 addr:$src))),
833 (implicit EFLAGS)]>, TB;
Evan Cheng18efe262007-12-14 02:13:44 +0000834} // Defs = [EFLAGS]
835
Chris Lattnerba7e7562008-01-10 07:59:24 +0000836let neverHasSideEffects = 1 in
Chris Lattner3a173df2004-10-03 20:35:00 +0000837def LEA16r : I<0x8D, MRMSrcMem,
Evan Cheng15b0d972009-12-12 18:51:56 +0000838 (outs GR16:$dst), (ins lea32mem:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000839 "lea{w}\t{$src|$dst}, {$dst|$src}", []>, OpSize;
Evan Chenge771ebd2008-03-27 01:41:09 +0000840let isReMaterializable = 1 in
Chris Lattner3a173df2004-10-03 20:35:00 +0000841def LEA32r : I<0x8D, MRMSrcMem,
Evan Cheng64d80e32007-07-19 01:14:50 +0000842 (outs GR32:$dst), (ins lea32mem:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000843 "lea{l}\t{$src|$dst}, {$dst|$src}",
Evan Cheng25ab6902006-09-08 06:48:29 +0000844 [(set GR32:$dst, lea32addr:$src)]>, Requires<[In32BitMode]>;
Chris Lattner1cca5e32003-08-03 21:54:21 +0000845
Kevin Enderby12ce0de2010-02-03 21:04:42 +0000846let Defs = [ECX,EDI,ESI], Uses = [ECX,EDI,ESI], isCodeGenOnly = 1 in {
Evan Cheng64d80e32007-07-19 01:14:50 +0000847def REP_MOVSB : I<0xA4, RawFrm, (outs), (ins), "{rep;movsb|rep movsb}",
Evan Cheng071a2792007-09-11 19:55:27 +0000848 [(X86rep_movs i8)]>, REP;
Evan Cheng64d80e32007-07-19 01:14:50 +0000849def REP_MOVSW : I<0xA5, RawFrm, (outs), (ins), "{rep;movsw|rep movsw}",
Evan Cheng071a2792007-09-11 19:55:27 +0000850 [(X86rep_movs i16)]>, REP, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +0000851def REP_MOVSD : I<0xA5, RawFrm, (outs), (ins), "{rep;movsl|rep movsd}",
Evan Cheng071a2792007-09-11 19:55:27 +0000852 [(X86rep_movs i32)]>, REP;
853}
Chris Lattner915e5e52004-02-12 17:53:22 +0000854
Kevin Enderby12ce0de2010-02-03 21:04:42 +0000855// These uses the DF flag in the EFLAGS register to inc or dec EDI and ESI
856let Defs = [EDI,ESI], Uses = [EDI,ESI,EFLAGS] in {
857def MOVSB : I<0xA4, RawFrm, (outs), (ins), "{movsb}", []>;
858def MOVSW : I<0xA5, RawFrm, (outs), (ins), "{movsw}", []>, OpSize;
859def MOVSD : I<0xA5, RawFrm, (outs), (ins), "{movsl|movsd}", []>;
860}
861
862let Defs = [ECX,EDI], Uses = [AL,ECX,EDI], isCodeGenOnly = 1 in
Evan Cheng64d80e32007-07-19 01:14:50 +0000863def REP_STOSB : I<0xAA, RawFrm, (outs), (ins), "{rep;stosb|rep stosb}",
Evan Cheng071a2792007-09-11 19:55:27 +0000864 [(X86rep_stos i8)]>, REP;
Kevin Enderby12ce0de2010-02-03 21:04:42 +0000865let Defs = [ECX,EDI], Uses = [AX,ECX,EDI], isCodeGenOnly = 1 in
Evan Cheng64d80e32007-07-19 01:14:50 +0000866def REP_STOSW : I<0xAB, RawFrm, (outs), (ins), "{rep;stosw|rep stosw}",
Evan Cheng071a2792007-09-11 19:55:27 +0000867 [(X86rep_stos i16)]>, REP, OpSize;
Kevin Enderby12ce0de2010-02-03 21:04:42 +0000868let Defs = [ECX,EDI], Uses = [EAX,ECX,EDI], isCodeGenOnly = 1 in
Evan Cheng64d80e32007-07-19 01:14:50 +0000869def REP_STOSD : I<0xAB, RawFrm, (outs), (ins), "{rep;stosl|rep stosd}",
Evan Cheng071a2792007-09-11 19:55:27 +0000870 [(X86rep_stos i32)]>, REP;
Chris Lattner30bf2d82004-08-10 20:17:41 +0000871
Kevin Enderby12ce0de2010-02-03 21:04:42 +0000872// These uses the DF flag in the EFLAGS register to inc or dec EDI and ESI
873let Defs = [EDI], Uses = [AL,EDI,EFLAGS] in
874def STOSB : I<0xAA, RawFrm, (outs), (ins), "{stosb}", []>;
875let Defs = [EDI], Uses = [AX,EDI,EFLAGS] in
876def STOSW : I<0xAB, RawFrm, (outs), (ins), "{stosw}", []>, OpSize;
877let Defs = [EDI], Uses = [EAX,EDI,EFLAGS] in
878def STOSD : I<0xAB, RawFrm, (outs), (ins), "{stosl|stosd}", []>;
879
Sean Callanana82e4652009-09-12 00:37:19 +0000880def SCAS8 : I<0xAE, RawFrm, (outs), (ins), "scas{b}", []>;
881def SCAS16 : I<0xAF, RawFrm, (outs), (ins), "scas{w}", []>, OpSize;
882def SCAS32 : I<0xAF, RawFrm, (outs), (ins), "scas{l}", []>;
883
Sean Callanan6f8f4622009-09-12 02:25:20 +0000884def CMPS8 : I<0xA6, RawFrm, (outs), (ins), "cmps{b}", []>;
885def CMPS16 : I<0xA7, RawFrm, (outs), (ins), "cmps{w}", []>, OpSize;
886def CMPS32 : I<0xA7, RawFrm, (outs), (ins), "cmps{l}", []>;
887
Evan Cheng071a2792007-09-11 19:55:27 +0000888let Defs = [RAX, RDX] in
Evan Cheng64d80e32007-07-19 01:14:50 +0000889def RDTSC : I<0x31, RawFrm, (outs), (ins), "rdtsc", [(X86rdtsc)]>,
Evan Cheng071a2792007-09-11 19:55:27 +0000890 TB;
Chris Lattnerb89abef2004-02-14 04:45:37 +0000891
Sean Callanancebe9552010-02-13 02:06:11 +0000892let Defs = [RAX, RCX, RDX] in
893def RDTSCP : I<0x01, MRM_F9, (outs), (ins), "rdtscp", []>, TB;
894
Anton Korobeynikov66fac792008-01-15 07:02:33 +0000895let isBarrier = 1, hasCtrlDep = 1 in {
Chris Lattnerda68d302008-01-15 21:58:22 +0000896def TRAP : I<0x0B, RawFrm, (outs), (ins), "ud2", [(trap)]>, TB;
Anton Korobeynikov66fac792008-01-15 07:02:33 +0000897}
898
Chris Lattner02552de2009-08-11 16:58:39 +0000899def SYSCALL : I<0x05, RawFrm,
900 (outs), (ins), "syscall", []>, TB;
901def SYSRET : I<0x07, RawFrm,
902 (outs), (ins), "sysret", []>, TB;
903def SYSENTER : I<0x34, RawFrm,
904 (outs), (ins), "sysenter", []>, TB;
905def SYSEXIT : I<0x35, RawFrm,
906 (outs), (ins), "sysexit", []>, TB;
907
Sean Callanan2a46f362009-09-12 02:52:41 +0000908def WAIT : I<0x9B, RawFrm, (outs), (ins), "wait", []>;
Chris Lattner02552de2009-08-11 16:58:39 +0000909
910
Chris Lattner1cca5e32003-08-03 21:54:21 +0000911//===----------------------------------------------------------------------===//
John Criswell4ffff9e2004-04-08 20:31:47 +0000912// Input/Output Instructions...
913//
Evan Cheng071a2792007-09-11 19:55:27 +0000914let Defs = [AL], Uses = [DX] in
Evan Cheng64d80e32007-07-19 01:14:50 +0000915def IN8rr : I<0xEC, RawFrm, (outs), (ins),
Evan Cheng071a2792007-09-11 19:55:27 +0000916 "in{b}\t{%dx, %al|%AL, %DX}", []>;
917let Defs = [AX], Uses = [DX] in
Evan Cheng64d80e32007-07-19 01:14:50 +0000918def IN16rr : I<0xED, RawFrm, (outs), (ins),
Evan Cheng071a2792007-09-11 19:55:27 +0000919 "in{w}\t{%dx, %ax|%AX, %DX}", []>, OpSize;
920let Defs = [EAX], Uses = [DX] in
Evan Cheng64d80e32007-07-19 01:14:50 +0000921def IN32rr : I<0xED, RawFrm, (outs), (ins),
Evan Cheng071a2792007-09-11 19:55:27 +0000922 "in{l}\t{%dx, %eax|%EAX, %DX}", []>;
John Criswell4ffff9e2004-04-08 20:31:47 +0000923
Evan Cheng071a2792007-09-11 19:55:27 +0000924let Defs = [AL] in
Evan Cheng64d80e32007-07-19 01:14:50 +0000925def IN8ri : Ii8<0xE4, RawFrm, (outs), (ins i16i8imm:$port),
Evan Cheng071a2792007-09-11 19:55:27 +0000926 "in{b}\t{$port, %al|%AL, $port}", []>;
927let Defs = [AX] in
Evan Cheng64d80e32007-07-19 01:14:50 +0000928def IN16ri : Ii8<0xE5, RawFrm, (outs), (ins i16i8imm:$port),
Evan Cheng071a2792007-09-11 19:55:27 +0000929 "in{w}\t{$port, %ax|%AX, $port}", []>, OpSize;
930let Defs = [EAX] in
Evan Cheng64d80e32007-07-19 01:14:50 +0000931def IN32ri : Ii8<0xE5, RawFrm, (outs), (ins i16i8imm:$port),
Evan Cheng071a2792007-09-11 19:55:27 +0000932 "in{l}\t{$port, %eax|%EAX, $port}", []>;
Chris Lattner440bbc22004-04-13 17:19:31 +0000933
Evan Cheng071a2792007-09-11 19:55:27 +0000934let Uses = [DX, AL] in
Evan Cheng64d80e32007-07-19 01:14:50 +0000935def OUT8rr : I<0xEE, RawFrm, (outs), (ins),
Evan Cheng071a2792007-09-11 19:55:27 +0000936 "out{b}\t{%al, %dx|%DX, %AL}", []>;
937let Uses = [DX, AX] in
Evan Cheng64d80e32007-07-19 01:14:50 +0000938def OUT16rr : I<0xEF, RawFrm, (outs), (ins),
Evan Cheng071a2792007-09-11 19:55:27 +0000939 "out{w}\t{%ax, %dx|%DX, %AX}", []>, OpSize;
940let Uses = [DX, EAX] in
Evan Cheng64d80e32007-07-19 01:14:50 +0000941def OUT32rr : I<0xEF, RawFrm, (outs), (ins),
Evan Cheng071a2792007-09-11 19:55:27 +0000942 "out{l}\t{%eax, %dx|%DX, %EAX}", []>;
Chris Lattnerffff7082004-08-01 07:44:35 +0000943
Evan Cheng071a2792007-09-11 19:55:27 +0000944let Uses = [AL] in
Evan Cheng64d80e32007-07-19 01:14:50 +0000945def OUT8ir : Ii8<0xE6, RawFrm, (outs), (ins i16i8imm:$port),
Evan Cheng071a2792007-09-11 19:55:27 +0000946 "out{b}\t{%al, $port|$port, %AL}", []>;
947let Uses = [AX] in
Evan Cheng64d80e32007-07-19 01:14:50 +0000948def OUT16ir : Ii8<0xE7, RawFrm, (outs), (ins i16i8imm:$port),
Evan Cheng071a2792007-09-11 19:55:27 +0000949 "out{w}\t{%ax, $port|$port, %AX}", []>, OpSize;
950let Uses = [EAX] in
Evan Cheng64d80e32007-07-19 01:14:50 +0000951def OUT32ir : Ii8<0xE7, RawFrm, (outs), (ins i16i8imm:$port),
Evan Cheng071a2792007-09-11 19:55:27 +0000952 "out{l}\t{%eax, $port|$port, %EAX}", []>;
John Criswell4ffff9e2004-04-08 20:31:47 +0000953
Sean Callanan108934c2009-12-18 00:01:26 +0000954def IN8 : I<0x6C, RawFrm, (outs), (ins),
955 "ins{b}", []>;
956def IN16 : I<0x6D, RawFrm, (outs), (ins),
957 "ins{w}", []>, OpSize;
958def IN32 : I<0x6D, RawFrm, (outs), (ins),
959 "ins{l}", []>;
960
John Criswell4ffff9e2004-04-08 20:31:47 +0000961//===----------------------------------------------------------------------===//
Chris Lattner1cca5e32003-08-03 21:54:21 +0000962// Move Instructions...
963//
Chris Lattnerba7e7562008-01-10 07:59:24 +0000964let neverHasSideEffects = 1 in {
Evan Cheng64d80e32007-07-19 01:14:50 +0000965def MOV8rr : I<0x88, MRMDestReg, (outs GR8 :$dst), (ins GR8 :$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000966 "mov{b}\t{$src, $dst|$dst, $src}", []>;
Evan Cheng64d80e32007-07-19 01:14:50 +0000967def MOV16rr : I<0x89, MRMDestReg, (outs GR16:$dst), (ins GR16:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000968 "mov{w}\t{$src, $dst|$dst, $src}", []>, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +0000969def MOV32rr : I<0x89, MRMDestReg, (outs GR32:$dst), (ins GR32:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000970 "mov{l}\t{$src, $dst|$dst, $src}", []>;
Chris Lattnerba7e7562008-01-10 07:59:24 +0000971}
Evan Cheng359e9372008-06-18 08:13:07 +0000972let isReMaterializable = 1, isAsCheapAsAMove = 1 in {
Evan Cheng64d80e32007-07-19 01:14:50 +0000973def MOV8ri : Ii8 <0xB0, AddRegFrm, (outs GR8 :$dst), (ins i8imm :$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000974 "mov{b}\t{$src, $dst|$dst, $src}",
Evan Cheng069287d2006-05-16 07:21:53 +0000975 [(set GR8:$dst, imm:$src)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +0000976def MOV16ri : Ii16<0xB8, AddRegFrm, (outs GR16:$dst), (ins i16imm:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000977 "mov{w}\t{$src, $dst|$dst, $src}",
Evan Cheng069287d2006-05-16 07:21:53 +0000978 [(set GR16:$dst, imm:$src)]>, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +0000979def MOV32ri : Ii32<0xB8, AddRegFrm, (outs GR32:$dst), (ins i32imm:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000980 "mov{l}\t{$src, $dst|$dst, $src}",
Evan Cheng069287d2006-05-16 07:21:53 +0000981 [(set GR32:$dst, imm:$src)]>;
Dan Gohmand45eddd2007-06-26 00:48:07 +0000982}
Kevin Enderby12ce0de2010-02-03 21:04:42 +0000983
Evan Cheng64d80e32007-07-19 01:14:50 +0000984def MOV8mi : Ii8 <0xC6, MRM0m, (outs), (ins i8mem :$dst, i8imm :$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000985 "mov{b}\t{$src, $dst|$dst, $src}",
Evan Chengb51a0592005-12-10 00:48:20 +0000986 [(store (i8 imm:$src), addr:$dst)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +0000987def MOV16mi : Ii16<0xC7, MRM0m, (outs), (ins i16mem:$dst, i16imm:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000988 "mov{w}\t{$src, $dst|$dst, $src}",
Evan Chengb51a0592005-12-10 00:48:20 +0000989 [(store (i16 imm:$src), addr:$dst)]>, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +0000990def MOV32mi : Ii32<0xC7, MRM0m, (outs), (ins i32mem:$dst, i32imm:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000991 "mov{l}\t{$src, $dst|$dst, $src}",
Evan Chengb51a0592005-12-10 00:48:20 +0000992 [(store (i32 imm:$src), addr:$dst)]>;
Chris Lattner1cca5e32003-08-03 21:54:21 +0000993
Sean Callanan108934c2009-12-18 00:01:26 +0000994def MOV8o8a : Ii8 <0xA0, RawFrm, (outs), (ins offset8:$src),
Sean Callanan2f34a132009-09-10 18:33:42 +0000995 "mov{b}\t{$src, %al|%al, $src}", []>;
Sean Callanan108934c2009-12-18 00:01:26 +0000996def MOV16o16a : Ii16 <0xA1, RawFrm, (outs), (ins offset16:$src),
Sean Callanan2f34a132009-09-10 18:33:42 +0000997 "mov{w}\t{$src, %ax|%ax, $src}", []>, OpSize;
Sean Callanan108934c2009-12-18 00:01:26 +0000998def MOV32o32a : Ii32 <0xA1, RawFrm, (outs), (ins offset32:$src),
Sean Callanan2f34a132009-09-10 18:33:42 +0000999 "mov{l}\t{$src, %eax|%eax, $src}", []>;
1000
Sean Callanan108934c2009-12-18 00:01:26 +00001001def MOV8ao8 : Ii8 <0xA2, RawFrm, (outs offset8:$dst), (ins),
Sean Callanan2f34a132009-09-10 18:33:42 +00001002 "mov{b}\t{%al, $dst|$dst, %al}", []>;
Sean Callanan108934c2009-12-18 00:01:26 +00001003def MOV16ao16 : Ii16 <0xA3, RawFrm, (outs offset16:$dst), (ins),
Sean Callanan2f34a132009-09-10 18:33:42 +00001004 "mov{w}\t{%ax, $dst|$dst, %ax}", []>, OpSize;
Sean Callanan108934c2009-12-18 00:01:26 +00001005def MOV32ao32 : Ii32 <0xA3, RawFrm, (outs offset32:$dst), (ins),
Sean Callanan2f34a132009-09-10 18:33:42 +00001006 "mov{l}\t{%eax, $dst|$dst, %eax}", []>;
1007
Sean Callanan38fee0e2009-09-15 18:47:29 +00001008// Moves to and from segment registers
1009def MOV16rs : I<0x8C, MRMDestReg, (outs GR16:$dst), (ins SEGMENT_REG:$src),
1010 "mov{w}\t{$src, $dst|$dst, $src}", []>;
1011def MOV16ms : I<0x8C, MRMDestMem, (outs i16mem:$dst), (ins SEGMENT_REG:$src),
1012 "mov{w}\t{$src, $dst|$dst, $src}", []>;
1013def MOV16sr : I<0x8E, MRMSrcReg, (outs SEGMENT_REG:$dst), (ins GR16:$src),
1014 "mov{w}\t{$src, $dst|$dst, $src}", []>;
1015def MOV16sm : I<0x8E, MRMSrcMem, (outs SEGMENT_REG:$dst), (ins i16mem:$src),
1016 "mov{w}\t{$src, $dst|$dst, $src}", []>;
1017
Sean Callanan108934c2009-12-18 00:01:26 +00001018def MOV8rr_REV : I<0x8A, MRMSrcReg, (outs GR8:$dst), (ins GR8:$src),
1019 "mov{b}\t{$src, $dst|$dst, $src}", []>;
1020def MOV16rr_REV : I<0x8B, MRMSrcReg, (outs GR16:$dst), (ins GR16:$src),
1021 "mov{w}\t{$src, $dst|$dst, $src}", []>, OpSize;
1022def MOV32rr_REV : I<0x8B, MRMSrcReg, (outs GR32:$dst), (ins GR32:$src),
1023 "mov{l}\t{$src, $dst|$dst, $src}", []>;
1024
Dan Gohmanbc9d98b2010-02-27 23:47:46 +00001025let canFoldAsLoad = 1, isReMaterializable = 1 in {
Evan Cheng64d80e32007-07-19 01:14:50 +00001026def MOV8rm : I<0x8A, MRMSrcMem, (outs GR8 :$dst), (ins i8mem :$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001027 "mov{b}\t{$src, $dst|$dst, $src}",
Chris Lattnerc2406f22009-04-10 00:16:23 +00001028 [(set GR8:$dst, (loadi8 addr:$src))]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00001029def MOV16rm : I<0x8B, MRMSrcMem, (outs GR16:$dst), (ins i16mem:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001030 "mov{w}\t{$src, $dst|$dst, $src}",
Chris Lattnerc2406f22009-04-10 00:16:23 +00001031 [(set GR16:$dst, (loadi16 addr:$src))]>, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00001032def MOV32rm : I<0x8B, MRMSrcMem, (outs GR32:$dst), (ins i32mem:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001033 "mov{l}\t{$src, $dst|$dst, $src}",
Chris Lattnerc2406f22009-04-10 00:16:23 +00001034 [(set GR32:$dst, (loadi32 addr:$src))]>;
Evan Cheng2f394262007-08-30 05:49:43 +00001035}
Chris Lattner1cca5e32003-08-03 21:54:21 +00001036
Evan Cheng64d80e32007-07-19 01:14:50 +00001037def MOV8mr : I<0x88, MRMDestMem, (outs), (ins i8mem :$dst, GR8 :$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001038 "mov{b}\t{$src, $dst|$dst, $src}",
Evan Cheng069287d2006-05-16 07:21:53 +00001039 [(store GR8:$src, addr:$dst)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00001040def MOV16mr : I<0x89, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001041 "mov{w}\t{$src, $dst|$dst, $src}",
Evan Cheng069287d2006-05-16 07:21:53 +00001042 [(store GR16:$src, addr:$dst)]>, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00001043def MOV32mr : I<0x89, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001044 "mov{l}\t{$src, $dst|$dst, $src}",
Evan Cheng069287d2006-05-16 07:21:53 +00001045 [(store GR32:$src, addr:$dst)]>;
Dan Gohman21e3dfb2009-04-13 16:09:41 +00001046
Evan Chengf48ef032010-03-14 03:48:46 +00001047/// Versions of MOV32rr, MOV32rm, and MOV32mr for i32mem_TC and GR32_TC.
1048let neverHasSideEffects = 1 in
1049def MOV32rr_TC : I<0x89, MRMDestReg, (outs GR32_TC:$dst), (ins GR32_TC:$src),
1050 "mov{l}\t{$src, $dst|$dst, $src}", []>;
1051
1052let mayLoad = 1,
1053 canFoldAsLoad = 1, isReMaterializable = 1 in
1054def MOV32rm_TC : I<0x8B, MRMSrcMem, (outs GR32_TC:$dst), (ins i32mem_TC:$src),
1055 "mov{l}\t{$src, $dst|$dst, $src}",
1056 []>;
1057
1058let mayStore = 1 in
1059def MOV32mr_TC : I<0x89, MRMDestMem, (outs), (ins i32mem_TC:$dst, GR32_TC:$src),
1060 "mov{l}\t{$src, $dst|$dst, $src}",
1061 []>;
1062
Dan Gohman4af325d2009-04-27 16:41:36 +00001063// Versions of MOV8rr, MOV8mr, and MOV8rm that use i8mem_NOREX and GR8_NOREX so
1064// that they can be used for copying and storing h registers, which can't be
1065// encoded when a REX prefix is present.
Dan Gohman6d9305c2009-04-15 00:04:23 +00001066let neverHasSideEffects = 1 in
Dan Gohmandf7dfc72009-04-15 19:48:57 +00001067def MOV8rr_NOREX : I<0x88, MRMDestReg,
1068 (outs GR8_NOREX:$dst), (ins GR8_NOREX:$src),
Dan Gohman6d9305c2009-04-15 00:04:23 +00001069 "mov{b}\t{$src, $dst|$dst, $src} # NOREX", []>;
Evan Cheng8c147402009-04-30 00:58:57 +00001070let mayStore = 1 in
Dan Gohman6d9305c2009-04-15 00:04:23 +00001071def MOV8mr_NOREX : I<0x88, MRMDestMem,
1072 (outs), (ins i8mem_NOREX:$dst, GR8_NOREX:$src),
1073 "mov{b}\t{$src, $dst|$dst, $src} # NOREX", []>;
Evan Cheng8c147402009-04-30 00:58:57 +00001074let mayLoad = 1,
Dan Gohmanbc9d98b2010-02-27 23:47:46 +00001075 canFoldAsLoad = 1, isReMaterializable = 1 in
Dan Gohman4af325d2009-04-27 16:41:36 +00001076def MOV8rm_NOREX : I<0x8A, MRMSrcMem,
1077 (outs GR8_NOREX:$dst), (ins i8mem_NOREX:$src),
1078 "mov{b}\t{$src, $dst|$dst, $src} # NOREX", []>;
Dan Gohman21e3dfb2009-04-13 16:09:41 +00001079
Sean Callanan108934c2009-12-18 00:01:26 +00001080// Moves to and from debug registers
1081def MOV32rd : I<0x21, MRMDestReg, (outs GR32:$dst), (ins DEBUG_REG:$src),
1082 "mov{l}\t{$src, $dst|$dst, $src}", []>, TB;
1083def MOV32dr : I<0x23, MRMSrcReg, (outs DEBUG_REG:$dst), (ins GR32:$src),
1084 "mov{l}\t{$src, $dst|$dst, $src}", []>, TB;
1085
1086// Moves to and from control registers
1087def MOV32rc : I<0x20, MRMDestReg, (outs GR32:$dst), (ins CONTROL_REG_32:$src),
1088 "mov{q}\t{$src, $dst|$dst, $src}", []>, TB;
1089def MOV32cr : I<0x22, MRMSrcReg, (outs CONTROL_REG_32:$dst), (ins GR32:$src),
1090 "mov{q}\t{$src, $dst|$dst, $src}", []>, TB;
1091
Chris Lattner1cca5e32003-08-03 21:54:21 +00001092//===----------------------------------------------------------------------===//
1093// Fixed-Register Multiplication and Division Instructions...
1094//
Chris Lattner1cca5e32003-08-03 21:54:21 +00001095
Chris Lattnerc8f45872003-08-04 04:59:56 +00001096// Extra precision multiplication
Jakob Stoklund Olesen3cfe0102010-03-04 20:42:07 +00001097
1098// AL is really implied by AX, by the registers in Defs must match the
1099// SDNode results (i8, i32).
1100let Defs = [AL,EFLAGS,AX], Uses = [AL] in
Dan Gohmanb1576f52007-07-31 20:11:57 +00001101def MUL8r : I<0xF6, MRM4r, (outs), (ins GR8:$src), "mul{b}\t$src",
Evan Chengcf74a7c2006-01-15 10:05:20 +00001102 // FIXME: Used for 8-bit mul, ignore result upper 8 bits.
1103 // This probably ought to be moved to a def : Pat<> if the
1104 // syntax can be accepted.
Bill Wendlingd350e022008-12-12 21:15:41 +00001105 [(set AL, (mul AL, GR8:$src)),
1106 (implicit EFLAGS)]>; // AL,AH = AL*GR8
1107
Chris Lattnera731c9f2008-01-11 07:18:17 +00001108let Defs = [AX,DX,EFLAGS], Uses = [AX], neverHasSideEffects = 1 in
Bill Wendlingd350e022008-12-12 21:15:41 +00001109def MUL16r : I<0xF7, MRM4r, (outs), (ins GR16:$src),
1110 "mul{w}\t$src",
1111 []>, OpSize; // AX,DX = AX*GR16
1112
Chris Lattnera731c9f2008-01-11 07:18:17 +00001113let Defs = [EAX,EDX,EFLAGS], Uses = [EAX], neverHasSideEffects = 1 in
Bill Wendlingd350e022008-12-12 21:15:41 +00001114def MUL32r : I<0xF7, MRM4r, (outs), (ins GR32:$src),
1115 "mul{l}\t$src",
1116 []>; // EAX,EDX = EAX*GR32
1117
Jakob Stoklund Olesen3cfe0102010-03-04 20:42:07 +00001118let Defs = [AL,EFLAGS,AX], Uses = [AL] in
Evan Cheng64d80e32007-07-19 01:14:50 +00001119def MUL8m : I<0xF6, MRM4m, (outs), (ins i8mem :$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001120 "mul{b}\t$src",
Evan Chengcf74a7c2006-01-15 10:05:20 +00001121 // FIXME: Used for 8-bit mul, ignore result upper 8 bits.
1122 // This probably ought to be moved to a def : Pat<> if the
1123 // syntax can be accepted.
Bill Wendlingd350e022008-12-12 21:15:41 +00001124 [(set AL, (mul AL, (loadi8 addr:$src))),
1125 (implicit EFLAGS)]>; // AL,AH = AL*[mem8]
1126
Chris Lattnerba7e7562008-01-10 07:59:24 +00001127let mayLoad = 1, neverHasSideEffects = 1 in {
Evan Cheng24f2ea32007-09-14 21:48:26 +00001128let Defs = [AX,DX,EFLAGS], Uses = [AX] in
Evan Cheng64d80e32007-07-19 01:14:50 +00001129def MUL16m : I<0xF7, MRM4m, (outs), (ins i16mem:$src),
Bill Wendlingd350e022008-12-12 21:15:41 +00001130 "mul{w}\t$src",
1131 []>, OpSize; // AX,DX = AX*[mem16]
1132
Evan Cheng24f2ea32007-09-14 21:48:26 +00001133let Defs = [EAX,EDX,EFLAGS], Uses = [EAX] in
Evan Cheng64d80e32007-07-19 01:14:50 +00001134def MUL32m : I<0xF7, MRM4m, (outs), (ins i32mem:$src),
Bill Wendlingd350e022008-12-12 21:15:41 +00001135 "mul{l}\t$src",
1136 []>; // EAX,EDX = EAX*[mem32]
Chris Lattnerba7e7562008-01-10 07:59:24 +00001137}
Chris Lattner1cca5e32003-08-03 21:54:21 +00001138
Chris Lattnerba7e7562008-01-10 07:59:24 +00001139let neverHasSideEffects = 1 in {
Jakob Stoklund Olesen3cfe0102010-03-04 20:42:07 +00001140let Defs = [AL,EFLAGS,AX], Uses = [AL] in
Evan Cheng071a2792007-09-11 19:55:27 +00001141def IMUL8r : I<0xF6, MRM5r, (outs), (ins GR8:$src), "imul{b}\t$src", []>;
1142 // AL,AH = AL*GR8
Evan Cheng24f2ea32007-09-14 21:48:26 +00001143let Defs = [AX,DX,EFLAGS], Uses = [AX] in
Dan Gohmanb1576f52007-07-31 20:11:57 +00001144def IMUL16r : I<0xF7, MRM5r, (outs), (ins GR16:$src), "imul{w}\t$src", []>,
Evan Cheng071a2792007-09-11 19:55:27 +00001145 OpSize; // AX,DX = AX*GR16
Evan Cheng24f2ea32007-09-14 21:48:26 +00001146let Defs = [EAX,EDX,EFLAGS], Uses = [EAX] in
Evan Cheng071a2792007-09-11 19:55:27 +00001147def IMUL32r : I<0xF7, MRM5r, (outs), (ins GR32:$src), "imul{l}\t$src", []>;
1148 // EAX,EDX = EAX*GR32
Chris Lattnerba7e7562008-01-10 07:59:24 +00001149let mayLoad = 1 in {
Jakob Stoklund Olesen3cfe0102010-03-04 20:42:07 +00001150let Defs = [AL,EFLAGS,AX], Uses = [AL] in
Evan Cheng64d80e32007-07-19 01:14:50 +00001151def IMUL8m : I<0xF6, MRM5m, (outs), (ins i8mem :$src),
Evan Cheng071a2792007-09-11 19:55:27 +00001152 "imul{b}\t$src", []>; // AL,AH = AL*[mem8]
Evan Cheng24f2ea32007-09-14 21:48:26 +00001153let Defs = [AX,DX,EFLAGS], Uses = [AX] in
Evan Cheng64d80e32007-07-19 01:14:50 +00001154def IMUL16m : I<0xF7, MRM5m, (outs), (ins i16mem:$src),
Evan Cheng071a2792007-09-11 19:55:27 +00001155 "imul{w}\t$src", []>, OpSize; // AX,DX = AX*[mem16]
Eli Friedmanba7b1c42009-12-26 20:08:30 +00001156let Defs = [EAX,EDX,EFLAGS], Uses = [EAX] in
Evan Cheng64d80e32007-07-19 01:14:50 +00001157def IMUL32m : I<0xF7, MRM5m, (outs), (ins i32mem:$src),
Evan Cheng071a2792007-09-11 19:55:27 +00001158 "imul{l}\t$src", []>; // EAX,EDX = EAX*[mem32]
Chris Lattnerba7e7562008-01-10 07:59:24 +00001159}
Dan Gohmanc99da132008-11-18 21:29:14 +00001160} // neverHasSideEffects
Chris Lattner1e6a7152005-04-06 04:19:22 +00001161
Chris Lattnerc8f45872003-08-04 04:59:56 +00001162// unsigned division/remainder
Jakob Stoklund Olesen3cfe0102010-03-04 20:42:07 +00001163let Defs = [AL,EFLAGS,AX], Uses = [AX] in
Sean Callanan108934c2009-12-18 00:01:26 +00001164def DIV8r : I<0xF6, MRM6r, (outs), (ins GR8:$src), // AX/r8 = AL,AH
Evan Cheng071a2792007-09-11 19:55:27 +00001165 "div{b}\t$src", []>;
Evan Cheng24f2ea32007-09-14 21:48:26 +00001166let Defs = [AX,DX,EFLAGS], Uses = [AX,DX] in
Sean Callanan108934c2009-12-18 00:01:26 +00001167def DIV16r : I<0xF7, MRM6r, (outs), (ins GR16:$src), // DX:AX/r16 = AX,DX
Evan Cheng071a2792007-09-11 19:55:27 +00001168 "div{w}\t$src", []>, OpSize;
Evan Cheng24f2ea32007-09-14 21:48:26 +00001169let Defs = [EAX,EDX,EFLAGS], Uses = [EAX,EDX] in
Sean Callanan108934c2009-12-18 00:01:26 +00001170def DIV32r : I<0xF7, MRM6r, (outs), (ins GR32:$src), // EDX:EAX/r32 = EAX,EDX
Evan Cheng071a2792007-09-11 19:55:27 +00001171 "div{l}\t$src", []>;
Chris Lattnerba7e7562008-01-10 07:59:24 +00001172let mayLoad = 1 in {
Jakob Stoklund Olesen3cfe0102010-03-04 20:42:07 +00001173let Defs = [AL,EFLAGS,AX], Uses = [AX] in
Sean Callanan108934c2009-12-18 00:01:26 +00001174def DIV8m : I<0xF6, MRM6m, (outs), (ins i8mem:$src), // AX/[mem8] = AL,AH
Evan Cheng071a2792007-09-11 19:55:27 +00001175 "div{b}\t$src", []>;
Evan Cheng24f2ea32007-09-14 21:48:26 +00001176let Defs = [AX,DX,EFLAGS], Uses = [AX,DX] in
Sean Callanan108934c2009-12-18 00:01:26 +00001177def DIV16m : I<0xF7, MRM6m, (outs), (ins i16mem:$src), // DX:AX/[mem16] = AX,DX
Evan Cheng071a2792007-09-11 19:55:27 +00001178 "div{w}\t$src", []>, OpSize;
Evan Cheng24f2ea32007-09-14 21:48:26 +00001179let Defs = [EAX,EDX,EFLAGS], Uses = [EAX,EDX] in
Sean Callanan108934c2009-12-18 00:01:26 +00001180 // EDX:EAX/[mem32] = EAX,EDX
1181def DIV32m : I<0xF7, MRM6m, (outs), (ins i32mem:$src),
Evan Cheng071a2792007-09-11 19:55:27 +00001182 "div{l}\t$src", []>;
Chris Lattnerba7e7562008-01-10 07:59:24 +00001183}
Chris Lattner1cca5e32003-08-03 21:54:21 +00001184
Chris Lattnerfc752712004-08-01 09:52:59 +00001185// Signed division/remainder.
Jakob Stoklund Olesen3cfe0102010-03-04 20:42:07 +00001186let Defs = [AL,EFLAGS,AX], Uses = [AX] in
Sean Callanan108934c2009-12-18 00:01:26 +00001187def IDIV8r : I<0xF6, MRM7r, (outs), (ins GR8:$src), // AX/r8 = AL,AH
Evan Cheng071a2792007-09-11 19:55:27 +00001188 "idiv{b}\t$src", []>;
Evan Cheng24f2ea32007-09-14 21:48:26 +00001189let Defs = [AX,DX,EFLAGS], Uses = [AX,DX] in
Sean Callanan108934c2009-12-18 00:01:26 +00001190def IDIV16r: I<0xF7, MRM7r, (outs), (ins GR16:$src), // DX:AX/r16 = AX,DX
Evan Cheng071a2792007-09-11 19:55:27 +00001191 "idiv{w}\t$src", []>, OpSize;
Evan Cheng24f2ea32007-09-14 21:48:26 +00001192let Defs = [EAX,EDX,EFLAGS], Uses = [EAX,EDX] in
Sean Callanan108934c2009-12-18 00:01:26 +00001193def IDIV32r: I<0xF7, MRM7r, (outs), (ins GR32:$src), // EDX:EAX/r32 = EAX,EDX
Evan Cheng071a2792007-09-11 19:55:27 +00001194 "idiv{l}\t$src", []>;
Chris Lattnerba7e7562008-01-10 07:59:24 +00001195let mayLoad = 1, mayLoad = 1 in {
Jakob Stoklund Olesen3cfe0102010-03-04 20:42:07 +00001196let Defs = [AL,EFLAGS,AX], Uses = [AX] in
Sean Callanan108934c2009-12-18 00:01:26 +00001197def IDIV8m : I<0xF6, MRM7m, (outs), (ins i8mem:$src), // AX/[mem8] = AL,AH
Evan Cheng071a2792007-09-11 19:55:27 +00001198 "idiv{b}\t$src", []>;
Evan Cheng24f2ea32007-09-14 21:48:26 +00001199let Defs = [AX,DX,EFLAGS], Uses = [AX,DX] in
Sean Callanan108934c2009-12-18 00:01:26 +00001200def IDIV16m: I<0xF7, MRM7m, (outs), (ins i16mem:$src), // DX:AX/[mem16] = AX,DX
Evan Cheng071a2792007-09-11 19:55:27 +00001201 "idiv{w}\t$src", []>, OpSize;
Evan Cheng24f2ea32007-09-14 21:48:26 +00001202let Defs = [EAX,EDX,EFLAGS], Uses = [EAX,EDX] in
Sean Callanan108934c2009-12-18 00:01:26 +00001203def IDIV32m: I<0xF7, MRM7m, (outs), (ins i32mem:$src),
1204 // EDX:EAX/[mem32] = EAX,EDX
Evan Cheng071a2792007-09-11 19:55:27 +00001205 "idiv{l}\t$src", []>;
Chris Lattnerba7e7562008-01-10 07:59:24 +00001206}
Chris Lattner1cca5e32003-08-03 21:54:21 +00001207
Chris Lattner1cca5e32003-08-03 21:54:21 +00001208//===----------------------------------------------------------------------===//
Chris Lattnerba7e7562008-01-10 07:59:24 +00001209// Two address Instructions.
Chris Lattner1cca5e32003-08-03 21:54:21 +00001210//
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00001211let isTwoAddress = 1 in {
Chris Lattner1cca5e32003-08-03 21:54:21 +00001212
Alkis Evlogimenosa3f66842004-03-12 17:59:56 +00001213// Conditional moves
Evan Cheng0488db92007-09-25 01:57:46 +00001214let Uses = [EFLAGS] in {
Dan Gohmancbbea0f2009-08-27 00:14:12 +00001215
Dan Gohman533297b2009-10-29 18:10:34 +00001216// X86 doesn't have 8-bit conditional moves. Use a customInserter to
Dan Gohmancbbea0f2009-08-27 00:14:12 +00001217// emit control flow. An alternative to this is to mark i8 SELECT as Promote,
1218// however that requires promoting the operands, and can induce additional
Dan Gohman71a258c2009-08-29 22:19:15 +00001219// i8 register pressure. Note that CMOV_GR8 is conservatively considered to
1220// clobber EFLAGS, because if one of the operands is zero, the expansion
1221// could involve an xor.
Dan Gohman533297b2009-10-29 18:10:34 +00001222let usesCustomInserter = 1, isTwoAddress = 0, Defs = [EFLAGS] in
Dan Gohmancbbea0f2009-08-27 00:14:12 +00001223def CMOV_GR8 : I<0, Pseudo,
1224 (outs GR8:$dst), (ins GR8:$src1, GR8:$src2, i8imm:$cond),
1225 "#CMOV_GR8 PSEUDO!",
1226 [(set GR8:$dst, (X86cmov GR8:$src1, GR8:$src2,
1227 imm:$cond, EFLAGS))]>;
1228
Dan Gohmana4c5c332009-08-27 18:16:24 +00001229let isCommutable = 1 in {
Evan Cheng069287d2006-05-16 07:21:53 +00001230def CMOVB16rr : I<0x42, MRMSrcReg, // if <u, GR16 = GR16
Evan Cheng64d80e32007-07-19 01:14:50 +00001231 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Sean Callanan108934c2009-12-18 00:01:26 +00001232 "cmovb{w}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001233 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Chenge5f62042007-09-29 00:00:36 +00001234 X86_COND_B, EFLAGS))]>,
Evan Cheng71fb9ad2006-01-26 00:29:36 +00001235 TB, OpSize;
Evan Cheng069287d2006-05-16 07:21:53 +00001236def CMOVB32rr : I<0x42, MRMSrcReg, // if <u, GR32 = GR32
Evan Cheng64d80e32007-07-19 01:14:50 +00001237 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Sean Callanan108934c2009-12-18 00:01:26 +00001238 "cmovb{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001239 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Chenge5f62042007-09-29 00:00:36 +00001240 X86_COND_B, EFLAGS))]>,
Evan Cheng71fb9ad2006-01-26 00:29:36 +00001241 TB;
Evan Cheng069287d2006-05-16 07:21:53 +00001242def CMOVAE16rr: I<0x43, MRMSrcReg, // if >=u, GR16 = GR16
Evan Cheng64d80e32007-07-19 01:14:50 +00001243 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Sean Callanan108934c2009-12-18 00:01:26 +00001244 "cmovae{w}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001245 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Chenge5f62042007-09-29 00:00:36 +00001246 X86_COND_AE, EFLAGS))]>,
Evan Cheng71fb9ad2006-01-26 00:29:36 +00001247 TB, OpSize;
Evan Cheng069287d2006-05-16 07:21:53 +00001248def CMOVAE32rr: I<0x43, MRMSrcReg, // if >=u, GR32 = GR32
Evan Cheng64d80e32007-07-19 01:14:50 +00001249 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Sean Callanan108934c2009-12-18 00:01:26 +00001250 "cmovae{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001251 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Chenge5f62042007-09-29 00:00:36 +00001252 X86_COND_AE, EFLAGS))]>,
Evan Cheng71fb9ad2006-01-26 00:29:36 +00001253 TB;
Evan Cheng069287d2006-05-16 07:21:53 +00001254def CMOVE16rr : I<0x44, MRMSrcReg, // if ==, GR16 = GR16
Evan Cheng64d80e32007-07-19 01:14:50 +00001255 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Sean Callanan108934c2009-12-18 00:01:26 +00001256 "cmove{w}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001257 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Chenge5f62042007-09-29 00:00:36 +00001258 X86_COND_E, EFLAGS))]>,
Evan Cheng71fb9ad2006-01-26 00:29:36 +00001259 TB, OpSize;
Evan Cheng069287d2006-05-16 07:21:53 +00001260def CMOVE32rr : I<0x44, MRMSrcReg, // if ==, GR32 = GR32
Evan Cheng64d80e32007-07-19 01:14:50 +00001261 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Sean Callanan108934c2009-12-18 00:01:26 +00001262 "cmove{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001263 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Chenge5f62042007-09-29 00:00:36 +00001264 X86_COND_E, EFLAGS))]>,
Evan Cheng71fb9ad2006-01-26 00:29:36 +00001265 TB;
Evan Cheng069287d2006-05-16 07:21:53 +00001266def CMOVNE16rr: I<0x45, MRMSrcReg, // if !=, GR16 = GR16
Evan Cheng64d80e32007-07-19 01:14:50 +00001267 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Sean Callanan108934c2009-12-18 00:01:26 +00001268 "cmovne{w}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001269 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Chenge5f62042007-09-29 00:00:36 +00001270 X86_COND_NE, EFLAGS))]>,
Evan Cheng71fb9ad2006-01-26 00:29:36 +00001271 TB, OpSize;
Evan Cheng069287d2006-05-16 07:21:53 +00001272def CMOVNE32rr: I<0x45, MRMSrcReg, // if !=, GR32 = GR32
Evan Cheng64d80e32007-07-19 01:14:50 +00001273 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Sean Callanan108934c2009-12-18 00:01:26 +00001274 "cmovne{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001275 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Chenge5f62042007-09-29 00:00:36 +00001276 X86_COND_NE, EFLAGS))]>,
Evan Cheng71fb9ad2006-01-26 00:29:36 +00001277 TB;
Evan Cheng069287d2006-05-16 07:21:53 +00001278def CMOVBE16rr: I<0x46, MRMSrcReg, // if <=u, GR16 = GR16
Evan Cheng64d80e32007-07-19 01:14:50 +00001279 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Sean Callanan108934c2009-12-18 00:01:26 +00001280 "cmovbe{w}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001281 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Chenge5f62042007-09-29 00:00:36 +00001282 X86_COND_BE, EFLAGS))]>,
Evan Cheng71fb9ad2006-01-26 00:29:36 +00001283 TB, OpSize;
Evan Cheng069287d2006-05-16 07:21:53 +00001284def CMOVBE32rr: I<0x46, MRMSrcReg, // if <=u, GR32 = GR32
Evan Cheng64d80e32007-07-19 01:14:50 +00001285 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Sean Callanan108934c2009-12-18 00:01:26 +00001286 "cmovbe{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001287 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Chenge5f62042007-09-29 00:00:36 +00001288 X86_COND_BE, EFLAGS))]>,
Evan Cheng71fb9ad2006-01-26 00:29:36 +00001289 TB;
Evan Cheng069287d2006-05-16 07:21:53 +00001290def CMOVA16rr : I<0x47, MRMSrcReg, // if >u, GR16 = GR16
Evan Cheng64d80e32007-07-19 01:14:50 +00001291 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Sean Callanan108934c2009-12-18 00:01:26 +00001292 "cmova{w}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001293 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Chenge5f62042007-09-29 00:00:36 +00001294 X86_COND_A, EFLAGS))]>,
Evan Cheng71fb9ad2006-01-26 00:29:36 +00001295 TB, OpSize;
Evan Cheng069287d2006-05-16 07:21:53 +00001296def CMOVA32rr : I<0x47, MRMSrcReg, // if >u, GR32 = GR32
Evan Cheng64d80e32007-07-19 01:14:50 +00001297 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Sean Callanan108934c2009-12-18 00:01:26 +00001298 "cmova{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001299 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Chenge5f62042007-09-29 00:00:36 +00001300 X86_COND_A, EFLAGS))]>,
Evan Cheng71fb9ad2006-01-26 00:29:36 +00001301 TB;
Evan Cheng069287d2006-05-16 07:21:53 +00001302def CMOVL16rr : I<0x4C, MRMSrcReg, // if <s, GR16 = GR16
Evan Cheng64d80e32007-07-19 01:14:50 +00001303 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Sean Callanan108934c2009-12-18 00:01:26 +00001304 "cmovl{w}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001305 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Chenge5f62042007-09-29 00:00:36 +00001306 X86_COND_L, EFLAGS))]>,
Evan Cheng71fb9ad2006-01-26 00:29:36 +00001307 TB, OpSize;
Evan Cheng069287d2006-05-16 07:21:53 +00001308def CMOVL32rr : I<0x4C, MRMSrcReg, // if <s, GR32 = GR32
Evan Cheng64d80e32007-07-19 01:14:50 +00001309 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Sean Callanan108934c2009-12-18 00:01:26 +00001310 "cmovl{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001311 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Chenge5f62042007-09-29 00:00:36 +00001312 X86_COND_L, EFLAGS))]>,
Evan Cheng71fb9ad2006-01-26 00:29:36 +00001313 TB;
Evan Cheng069287d2006-05-16 07:21:53 +00001314def CMOVGE16rr: I<0x4D, MRMSrcReg, // if >=s, GR16 = GR16
Evan Cheng64d80e32007-07-19 01:14:50 +00001315 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Sean Callanan108934c2009-12-18 00:01:26 +00001316 "cmovge{w}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001317 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Chenge5f62042007-09-29 00:00:36 +00001318 X86_COND_GE, EFLAGS))]>,
Evan Cheng71fb9ad2006-01-26 00:29:36 +00001319 TB, OpSize;
Evan Cheng069287d2006-05-16 07:21:53 +00001320def CMOVGE32rr: I<0x4D, MRMSrcReg, // if >=s, GR32 = GR32
Evan Cheng64d80e32007-07-19 01:14:50 +00001321 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Sean Callanan108934c2009-12-18 00:01:26 +00001322 "cmovge{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001323 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Chenge5f62042007-09-29 00:00:36 +00001324 X86_COND_GE, EFLAGS))]>,
Evan Cheng71fb9ad2006-01-26 00:29:36 +00001325 TB;
Evan Cheng069287d2006-05-16 07:21:53 +00001326def CMOVLE16rr: I<0x4E, MRMSrcReg, // if <=s, GR16 = GR16
Evan Cheng64d80e32007-07-19 01:14:50 +00001327 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Sean Callanan108934c2009-12-18 00:01:26 +00001328 "cmovle{w}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001329 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Chenge5f62042007-09-29 00:00:36 +00001330 X86_COND_LE, EFLAGS))]>,
Evan Cheng71fb9ad2006-01-26 00:29:36 +00001331 TB, OpSize;
Evan Cheng069287d2006-05-16 07:21:53 +00001332def CMOVLE32rr: I<0x4E, MRMSrcReg, // if <=s, GR32 = GR32
Evan Cheng64d80e32007-07-19 01:14:50 +00001333 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Sean Callanan108934c2009-12-18 00:01:26 +00001334 "cmovle{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001335 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Chenge5f62042007-09-29 00:00:36 +00001336 X86_COND_LE, EFLAGS))]>,
Evan Cheng71fb9ad2006-01-26 00:29:36 +00001337 TB;
Evan Cheng069287d2006-05-16 07:21:53 +00001338def CMOVG16rr : I<0x4F, MRMSrcReg, // if >s, GR16 = GR16
Evan Cheng64d80e32007-07-19 01:14:50 +00001339 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Sean Callanan108934c2009-12-18 00:01:26 +00001340 "cmovg{w}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001341 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Chenge5f62042007-09-29 00:00:36 +00001342 X86_COND_G, EFLAGS))]>,
Evan Cheng71fb9ad2006-01-26 00:29:36 +00001343 TB, OpSize;
Evan Cheng069287d2006-05-16 07:21:53 +00001344def CMOVG32rr : I<0x4F, MRMSrcReg, // if >s, GR32 = GR32
Evan Cheng64d80e32007-07-19 01:14:50 +00001345 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Sean Callanan108934c2009-12-18 00:01:26 +00001346 "cmovg{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001347 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Chenge5f62042007-09-29 00:00:36 +00001348 X86_COND_G, EFLAGS))]>,
Evan Cheng71fb9ad2006-01-26 00:29:36 +00001349 TB;
Evan Cheng069287d2006-05-16 07:21:53 +00001350def CMOVS16rr : I<0x48, MRMSrcReg, // if signed, GR16 = GR16
Evan Cheng64d80e32007-07-19 01:14:50 +00001351 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Sean Callanan108934c2009-12-18 00:01:26 +00001352 "cmovs{w}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001353 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Chenge5f62042007-09-29 00:00:36 +00001354 X86_COND_S, EFLAGS))]>,
Evan Cheng71fb9ad2006-01-26 00:29:36 +00001355 TB, OpSize;
Evan Cheng069287d2006-05-16 07:21:53 +00001356def CMOVS32rr : I<0x48, MRMSrcReg, // if signed, GR32 = GR32
Evan Cheng64d80e32007-07-19 01:14:50 +00001357 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Sean Callanan108934c2009-12-18 00:01:26 +00001358 "cmovs{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001359 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Chenge5f62042007-09-29 00:00:36 +00001360 X86_COND_S, EFLAGS))]>,
Evan Cheng71fb9ad2006-01-26 00:29:36 +00001361 TB;
Evan Cheng069287d2006-05-16 07:21:53 +00001362def CMOVNS16rr: I<0x49, MRMSrcReg, // if !signed, GR16 = GR16
Evan Cheng64d80e32007-07-19 01:14:50 +00001363 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Sean Callanan108934c2009-12-18 00:01:26 +00001364 "cmovns{w}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001365 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Chenge5f62042007-09-29 00:00:36 +00001366 X86_COND_NS, EFLAGS))]>,
Evan Cheng71fb9ad2006-01-26 00:29:36 +00001367 TB, OpSize;
Evan Cheng069287d2006-05-16 07:21:53 +00001368def CMOVNS32rr: I<0x49, MRMSrcReg, // if !signed, GR32 = GR32
Evan Cheng64d80e32007-07-19 01:14:50 +00001369 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Sean Callanan108934c2009-12-18 00:01:26 +00001370 "cmovns{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001371 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Chenge5f62042007-09-29 00:00:36 +00001372 X86_COND_NS, EFLAGS))]>,
Evan Cheng71fb9ad2006-01-26 00:29:36 +00001373 TB;
Evan Cheng069287d2006-05-16 07:21:53 +00001374def CMOVP16rr : I<0x4A, MRMSrcReg, // if parity, GR16 = GR16
Evan Cheng64d80e32007-07-19 01:14:50 +00001375 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Sean Callanan108934c2009-12-18 00:01:26 +00001376 "cmovp{w}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001377 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Chenge5f62042007-09-29 00:00:36 +00001378 X86_COND_P, EFLAGS))]>,
Evan Cheng71fb9ad2006-01-26 00:29:36 +00001379 TB, OpSize;
Evan Cheng069287d2006-05-16 07:21:53 +00001380def CMOVP32rr : I<0x4A, MRMSrcReg, // if parity, GR32 = GR32
Evan Cheng64d80e32007-07-19 01:14:50 +00001381 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Sean Callanan108934c2009-12-18 00:01:26 +00001382 "cmovp{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001383 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Chenge5f62042007-09-29 00:00:36 +00001384 X86_COND_P, EFLAGS))]>,
Evan Cheng71fb9ad2006-01-26 00:29:36 +00001385 TB;
Evan Cheng069287d2006-05-16 07:21:53 +00001386def CMOVNP16rr : I<0x4B, MRMSrcReg, // if !parity, GR16 = GR16
Evan Cheng64d80e32007-07-19 01:14:50 +00001387 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Sean Callanan108934c2009-12-18 00:01:26 +00001388 "cmovnp{w}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001389 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Chenge5f62042007-09-29 00:00:36 +00001390 X86_COND_NP, EFLAGS))]>,
Evan Cheng71fb9ad2006-01-26 00:29:36 +00001391 TB, OpSize;
Evan Cheng069287d2006-05-16 07:21:53 +00001392def CMOVNP32rr : I<0x4B, MRMSrcReg, // if !parity, GR32 = GR32
Evan Cheng64d80e32007-07-19 01:14:50 +00001393 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Sean Callanan108934c2009-12-18 00:01:26 +00001394 "cmovnp{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001395 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Chenge5f62042007-09-29 00:00:36 +00001396 X86_COND_NP, EFLAGS))]>,
Evan Cheng71fb9ad2006-01-26 00:29:36 +00001397 TB;
Dan Gohman305fceb2009-01-07 00:35:10 +00001398def CMOVO16rr : I<0x40, MRMSrcReg, // if overflow, GR16 = GR16
1399 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Sean Callanan108934c2009-12-18 00:01:26 +00001400 "cmovo{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohman305fceb2009-01-07 00:35:10 +00001401 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
1402 X86_COND_O, EFLAGS))]>,
1403 TB, OpSize;
1404def CMOVO32rr : I<0x40, MRMSrcReg, // if overflow, GR32 = GR32
1405 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Sean Callanan108934c2009-12-18 00:01:26 +00001406 "cmovo{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohman305fceb2009-01-07 00:35:10 +00001407 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
1408 X86_COND_O, EFLAGS))]>,
Evan Cheng0488db92007-09-25 01:57:46 +00001409 TB;
Dan Gohman305fceb2009-01-07 00:35:10 +00001410def CMOVNO16rr : I<0x41, MRMSrcReg, // if !overflow, GR16 = GR16
1411 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Sean Callanan108934c2009-12-18 00:01:26 +00001412 "cmovno{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohman305fceb2009-01-07 00:35:10 +00001413 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
1414 X86_COND_NO, EFLAGS))]>,
1415 TB, OpSize;
1416def CMOVNO32rr : I<0x41, MRMSrcReg, // if !overflow, GR32 = GR32
1417 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Sean Callanan108934c2009-12-18 00:01:26 +00001418 "cmovno{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohman305fceb2009-01-07 00:35:10 +00001419 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
1420 X86_COND_NO, EFLAGS))]>,
1421 TB;
1422} // isCommutable = 1
Evan Cheng7ad42d92007-10-05 23:13:21 +00001423
1424def CMOVB16rm : I<0x42, MRMSrcMem, // if <u, GR16 = [mem16]
1425 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
Sean Callanan108934c2009-12-18 00:01:26 +00001426 "cmovb{w}\t{$src2, $dst|$dst, $src2}",
Evan Cheng7ad42d92007-10-05 23:13:21 +00001427 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1428 X86_COND_B, EFLAGS))]>,
1429 TB, OpSize;
1430def CMOVB32rm : I<0x42, MRMSrcMem, // if <u, GR32 = [mem32]
1431 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Sean Callanan108934c2009-12-18 00:01:26 +00001432 "cmovb{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng7ad42d92007-10-05 23:13:21 +00001433 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1434 X86_COND_B, EFLAGS))]>,
1435 TB;
1436def CMOVAE16rm: I<0x43, MRMSrcMem, // if >=u, GR16 = [mem16]
1437 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
Sean Callanan108934c2009-12-18 00:01:26 +00001438 "cmovae{w}\t{$src2, $dst|$dst, $src2}",
Evan Cheng7ad42d92007-10-05 23:13:21 +00001439 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1440 X86_COND_AE, EFLAGS))]>,
1441 TB, OpSize;
1442def CMOVAE32rm: I<0x43, MRMSrcMem, // if >=u, GR32 = [mem32]
1443 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Sean Callanan108934c2009-12-18 00:01:26 +00001444 "cmovae{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng7ad42d92007-10-05 23:13:21 +00001445 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1446 X86_COND_AE, EFLAGS))]>,
1447 TB;
1448def CMOVE16rm : I<0x44, MRMSrcMem, // if ==, GR16 = [mem16]
1449 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
Sean Callanan108934c2009-12-18 00:01:26 +00001450 "cmove{w}\t{$src2, $dst|$dst, $src2}",
Evan Cheng7ad42d92007-10-05 23:13:21 +00001451 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1452 X86_COND_E, EFLAGS))]>,
1453 TB, OpSize;
1454def CMOVE32rm : I<0x44, MRMSrcMem, // if ==, GR32 = [mem32]
1455 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Sean Callanan108934c2009-12-18 00:01:26 +00001456 "cmove{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng7ad42d92007-10-05 23:13:21 +00001457 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1458 X86_COND_E, EFLAGS))]>,
1459 TB;
1460def CMOVNE16rm: I<0x45, MRMSrcMem, // if !=, GR16 = [mem16]
1461 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
Sean Callanan108934c2009-12-18 00:01:26 +00001462 "cmovne{w}\t{$src2, $dst|$dst, $src2}",
Evan Cheng7ad42d92007-10-05 23:13:21 +00001463 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1464 X86_COND_NE, EFLAGS))]>,
1465 TB, OpSize;
1466def CMOVNE32rm: I<0x45, MRMSrcMem, // if !=, GR32 = [mem32]
1467 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Sean Callanan108934c2009-12-18 00:01:26 +00001468 "cmovne{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng7ad42d92007-10-05 23:13:21 +00001469 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1470 X86_COND_NE, EFLAGS))]>,
1471 TB;
1472def CMOVBE16rm: I<0x46, MRMSrcMem, // if <=u, GR16 = [mem16]
1473 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
Sean Callanan108934c2009-12-18 00:01:26 +00001474 "cmovbe{w}\t{$src2, $dst|$dst, $src2}",
Evan Cheng7ad42d92007-10-05 23:13:21 +00001475 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1476 X86_COND_BE, EFLAGS))]>,
1477 TB, OpSize;
1478def CMOVBE32rm: I<0x46, MRMSrcMem, // if <=u, GR32 = [mem32]
1479 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Sean Callanan108934c2009-12-18 00:01:26 +00001480 "cmovbe{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng7ad42d92007-10-05 23:13:21 +00001481 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1482 X86_COND_BE, EFLAGS))]>,
1483 TB;
1484def CMOVA16rm : I<0x47, MRMSrcMem, // if >u, GR16 = [mem16]
1485 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
Sean Callanan108934c2009-12-18 00:01:26 +00001486 "cmova{w}\t{$src2, $dst|$dst, $src2}",
Evan Cheng7ad42d92007-10-05 23:13:21 +00001487 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1488 X86_COND_A, EFLAGS))]>,
1489 TB, OpSize;
1490def CMOVA32rm : I<0x47, MRMSrcMem, // if >u, GR32 = [mem32]
1491 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Sean Callanan108934c2009-12-18 00:01:26 +00001492 "cmova{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng7ad42d92007-10-05 23:13:21 +00001493 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1494 X86_COND_A, EFLAGS))]>,
1495 TB;
1496def CMOVL16rm : I<0x4C, MRMSrcMem, // if <s, GR16 = [mem16]
1497 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
Sean Callanan108934c2009-12-18 00:01:26 +00001498 "cmovl{w}\t{$src2, $dst|$dst, $src2}",
Evan Cheng7ad42d92007-10-05 23:13:21 +00001499 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1500 X86_COND_L, EFLAGS))]>,
1501 TB, OpSize;
1502def CMOVL32rm : I<0x4C, MRMSrcMem, // if <s, GR32 = [mem32]
1503 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Sean Callanan108934c2009-12-18 00:01:26 +00001504 "cmovl{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng7ad42d92007-10-05 23:13:21 +00001505 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1506 X86_COND_L, EFLAGS))]>,
1507 TB;
1508def CMOVGE16rm: I<0x4D, MRMSrcMem, // if >=s, GR16 = [mem16]
1509 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
Sean Callanan108934c2009-12-18 00:01:26 +00001510 "cmovge{w}\t{$src2, $dst|$dst, $src2}",
Evan Cheng7ad42d92007-10-05 23:13:21 +00001511 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1512 X86_COND_GE, EFLAGS))]>,
1513 TB, OpSize;
1514def CMOVGE32rm: I<0x4D, MRMSrcMem, // if >=s, GR32 = [mem32]
1515 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Sean Callanan108934c2009-12-18 00:01:26 +00001516 "cmovge{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng7ad42d92007-10-05 23:13:21 +00001517 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1518 X86_COND_GE, EFLAGS))]>,
1519 TB;
1520def CMOVLE16rm: I<0x4E, MRMSrcMem, // if <=s, GR16 = [mem16]
1521 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
Sean Callanan108934c2009-12-18 00:01:26 +00001522 "cmovle{w}\t{$src2, $dst|$dst, $src2}",
Evan Cheng7ad42d92007-10-05 23:13:21 +00001523 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1524 X86_COND_LE, EFLAGS))]>,
1525 TB, OpSize;
1526def CMOVLE32rm: I<0x4E, MRMSrcMem, // if <=s, GR32 = [mem32]
1527 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Sean Callanan108934c2009-12-18 00:01:26 +00001528 "cmovle{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng7ad42d92007-10-05 23:13:21 +00001529 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1530 X86_COND_LE, EFLAGS))]>,
1531 TB;
1532def CMOVG16rm : I<0x4F, MRMSrcMem, // if >s, GR16 = [mem16]
1533 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
Sean Callanan108934c2009-12-18 00:01:26 +00001534 "cmovg{w}\t{$src2, $dst|$dst, $src2}",
Evan Cheng7ad42d92007-10-05 23:13:21 +00001535 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1536 X86_COND_G, EFLAGS))]>,
1537 TB, OpSize;
1538def CMOVG32rm : I<0x4F, MRMSrcMem, // if >s, GR32 = [mem32]
1539 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Sean Callanan108934c2009-12-18 00:01:26 +00001540 "cmovg{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng7ad42d92007-10-05 23:13:21 +00001541 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1542 X86_COND_G, EFLAGS))]>,
1543 TB;
1544def CMOVS16rm : I<0x48, MRMSrcMem, // if signed, GR16 = [mem16]
1545 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
Sean Callanan108934c2009-12-18 00:01:26 +00001546 "cmovs{w}\t{$src2, $dst|$dst, $src2}",
Evan Cheng7ad42d92007-10-05 23:13:21 +00001547 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1548 X86_COND_S, EFLAGS))]>,
1549 TB, OpSize;
1550def CMOVS32rm : I<0x48, MRMSrcMem, // if signed, GR32 = [mem32]
1551 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Sean Callanan108934c2009-12-18 00:01:26 +00001552 "cmovs{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng7ad42d92007-10-05 23:13:21 +00001553 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1554 X86_COND_S, EFLAGS))]>,
1555 TB;
1556def CMOVNS16rm: I<0x49, MRMSrcMem, // if !signed, GR16 = [mem16]
1557 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
Sean Callanan108934c2009-12-18 00:01:26 +00001558 "cmovns{w}\t{$src2, $dst|$dst, $src2}",
Evan Cheng7ad42d92007-10-05 23:13:21 +00001559 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1560 X86_COND_NS, EFLAGS))]>,
1561 TB, OpSize;
1562def CMOVNS32rm: I<0x49, MRMSrcMem, // if !signed, GR32 = [mem32]
1563 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Sean Callanan108934c2009-12-18 00:01:26 +00001564 "cmovns{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng7ad42d92007-10-05 23:13:21 +00001565 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1566 X86_COND_NS, EFLAGS))]>,
1567 TB;
1568def CMOVP16rm : I<0x4A, MRMSrcMem, // if parity, GR16 = [mem16]
1569 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
Sean Callanan108934c2009-12-18 00:01:26 +00001570 "cmovp{w}\t{$src2, $dst|$dst, $src2}",
Evan Cheng7ad42d92007-10-05 23:13:21 +00001571 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1572 X86_COND_P, EFLAGS))]>,
1573 TB, OpSize;
1574def CMOVP32rm : I<0x4A, MRMSrcMem, // if parity, GR32 = [mem32]
1575 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Sean Callanan108934c2009-12-18 00:01:26 +00001576 "cmovp{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng7ad42d92007-10-05 23:13:21 +00001577 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1578 X86_COND_P, EFLAGS))]>,
1579 TB;
1580def CMOVNP16rm : I<0x4B, MRMSrcMem, // if !parity, GR16 = [mem16]
1581 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
Sean Callanan108934c2009-12-18 00:01:26 +00001582 "cmovnp{w}\t{$src2, $dst|$dst, $src2}",
Evan Cheng7ad42d92007-10-05 23:13:21 +00001583 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1584 X86_COND_NP, EFLAGS))]>,
1585 TB, OpSize;
Dan Gohman305fceb2009-01-07 00:35:10 +00001586def CMOVNP32rm : I<0x4B, MRMSrcMem, // if !parity, GR32 = [mem32]
1587 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Sean Callanan108934c2009-12-18 00:01:26 +00001588 "cmovnp{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohman305fceb2009-01-07 00:35:10 +00001589 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1590 X86_COND_NP, EFLAGS))]>,
1591 TB;
1592def CMOVO16rm : I<0x40, MRMSrcMem, // if overflow, GR16 = [mem16]
1593 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
Sean Callanan108934c2009-12-18 00:01:26 +00001594 "cmovo{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohman305fceb2009-01-07 00:35:10 +00001595 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1596 X86_COND_O, EFLAGS))]>,
1597 TB, OpSize;
1598def CMOVO32rm : I<0x40, MRMSrcMem, // if overflow, GR32 = [mem32]
1599 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Sean Callanan108934c2009-12-18 00:01:26 +00001600 "cmovo{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohman305fceb2009-01-07 00:35:10 +00001601 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1602 X86_COND_O, EFLAGS))]>,
1603 TB;
1604def CMOVNO16rm : I<0x41, MRMSrcMem, // if !overflow, GR16 = [mem16]
1605 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
Sean Callanan108934c2009-12-18 00:01:26 +00001606 "cmovno{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohman305fceb2009-01-07 00:35:10 +00001607 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1608 X86_COND_NO, EFLAGS))]>,
1609 TB, OpSize;
1610def CMOVNO32rm : I<0x41, MRMSrcMem, // if !overflow, GR32 = [mem32]
1611 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Sean Callanan108934c2009-12-18 00:01:26 +00001612 "cmovno{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohman305fceb2009-01-07 00:35:10 +00001613 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1614 X86_COND_NO, EFLAGS))]>,
1615 TB;
Evan Cheng0488db92007-09-25 01:57:46 +00001616} // Uses = [EFLAGS]
1617
1618
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00001619// unary instructions
Evan Cheng1693e482006-07-19 00:27:29 +00001620let CodeSize = 2 in {
Evan Cheng24f2ea32007-09-14 21:48:26 +00001621let Defs = [EFLAGS] in {
Dan Gohmanb1576f52007-07-31 20:11:57 +00001622def NEG8r : I<0xF6, MRM3r, (outs GR8 :$dst), (ins GR8 :$src), "neg{b}\t$dst",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001623 [(set GR8:$dst, (ineg GR8:$src)),
1624 (implicit EFLAGS)]>;
Dan Gohmanb1576f52007-07-31 20:11:57 +00001625def NEG16r : I<0xF7, MRM3r, (outs GR16:$dst), (ins GR16:$src), "neg{w}\t$dst",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001626 [(set GR16:$dst, (ineg GR16:$src)),
1627 (implicit EFLAGS)]>, OpSize;
Dan Gohmanb1576f52007-07-31 20:11:57 +00001628def NEG32r : I<0xF7, MRM3r, (outs GR32:$dst), (ins GR32:$src), "neg{l}\t$dst",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001629 [(set GR32:$dst, (ineg GR32:$src)),
1630 (implicit EFLAGS)]>;
Chris Lattner57a02302004-08-11 04:31:00 +00001631let isTwoAddress = 0 in {
Dan Gohmanb1576f52007-07-31 20:11:57 +00001632 def NEG8m : I<0xF6, MRM3m, (outs), (ins i8mem :$dst), "neg{b}\t$dst",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001633 [(store (ineg (loadi8 addr:$dst)), addr:$dst),
1634 (implicit EFLAGS)]>;
Dan Gohmanb1576f52007-07-31 20:11:57 +00001635 def NEG16m : I<0xF7, MRM3m, (outs), (ins i16mem:$dst), "neg{w}\t$dst",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001636 [(store (ineg (loadi16 addr:$dst)), addr:$dst),
1637 (implicit EFLAGS)]>, OpSize;
Dan Gohmanb1576f52007-07-31 20:11:57 +00001638 def NEG32m : I<0xF7, MRM3m, (outs), (ins i32mem:$dst), "neg{l}\t$dst",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001639 [(store (ineg (loadi32 addr:$dst)), addr:$dst),
1640 (implicit EFLAGS)]>;
Chris Lattner57a02302004-08-11 04:31:00 +00001641}
Evan Cheng24f2ea32007-09-14 21:48:26 +00001642} // Defs = [EFLAGS]
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00001643
Evan Chengaaf414c2009-01-21 02:09:05 +00001644// Match xor -1 to not. Favors these over a move imm + xor to save code size.
1645let AddedComplexity = 15 in {
Dan Gohmanb1576f52007-07-31 20:11:57 +00001646def NOT8r : I<0xF6, MRM2r, (outs GR8 :$dst), (ins GR8 :$src), "not{b}\t$dst",
Evan Cheng069287d2006-05-16 07:21:53 +00001647 [(set GR8:$dst, (not GR8:$src))]>;
Dan Gohmanb1576f52007-07-31 20:11:57 +00001648def NOT16r : I<0xF7, MRM2r, (outs GR16:$dst), (ins GR16:$src), "not{w}\t$dst",
Evan Cheng069287d2006-05-16 07:21:53 +00001649 [(set GR16:$dst, (not GR16:$src))]>, OpSize;
Dan Gohmanb1576f52007-07-31 20:11:57 +00001650def NOT32r : I<0xF7, MRM2r, (outs GR32:$dst), (ins GR32:$src), "not{l}\t$dst",
Evan Cheng069287d2006-05-16 07:21:53 +00001651 [(set GR32:$dst, (not GR32:$src))]>;
Evan Chengaaf414c2009-01-21 02:09:05 +00001652}
Chris Lattner57a02302004-08-11 04:31:00 +00001653let isTwoAddress = 0 in {
Dan Gohmanb1576f52007-07-31 20:11:57 +00001654 def NOT8m : I<0xF6, MRM2m, (outs), (ins i8mem :$dst), "not{b}\t$dst",
Evan Cheng605c4152005-12-13 01:57:51 +00001655 [(store (not (loadi8 addr:$dst)), addr:$dst)]>;
Dan Gohmanb1576f52007-07-31 20:11:57 +00001656 def NOT16m : I<0xF7, MRM2m, (outs), (ins i16mem:$dst), "not{w}\t$dst",
Evan Cheng605c4152005-12-13 01:57:51 +00001657 [(store (not (loadi16 addr:$dst)), addr:$dst)]>, OpSize;
Dan Gohmanb1576f52007-07-31 20:11:57 +00001658 def NOT32m : I<0xF7, MRM2m, (outs), (ins i32mem:$dst), "not{l}\t$dst",
Evan Cheng605c4152005-12-13 01:57:51 +00001659 [(store (not (loadi32 addr:$dst)), addr:$dst)]>;
Chris Lattner57a02302004-08-11 04:31:00 +00001660}
Evan Cheng1693e482006-07-19 00:27:29 +00001661} // CodeSize
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00001662
Evan Chengb51a0592005-12-10 00:48:20 +00001663// TODO: inc/dec is slow for P4, but fast for Pentium-M.
Evan Cheng24f2ea32007-09-14 21:48:26 +00001664let Defs = [EFLAGS] in {
Evan Cheng1693e482006-07-19 00:27:29 +00001665let CodeSize = 2 in
Dan Gohmanb1576f52007-07-31 20:11:57 +00001666def INC8r : I<0xFE, MRM0r, (outs GR8 :$dst), (ins GR8 :$src), "inc{b}\t$dst",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001667 [(set GR8:$dst, (add GR8:$src, 1)),
1668 (implicit EFLAGS)]>;
Evan Cheng1693e482006-07-19 00:27:29 +00001669let isConvertibleToThreeAddress = 1, CodeSize = 1 in { // Can xform into LEA.
Sean Callanan108934c2009-12-18 00:01:26 +00001670def INC16r : I<0x40, AddRegFrm, (outs GR16:$dst), (ins GR16:$src),
1671 "inc{w}\t$dst",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001672 [(set GR16:$dst, (add GR16:$src, 1)),
1673 (implicit EFLAGS)]>,
Evan Cheng25ab6902006-09-08 06:48:29 +00001674 OpSize, Requires<[In32BitMode]>;
Sean Callanan108934c2009-12-18 00:01:26 +00001675def INC32r : I<0x40, AddRegFrm, (outs GR32:$dst), (ins GR32:$src),
1676 "inc{l}\t$dst",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001677 [(set GR32:$dst, (add GR32:$src, 1)),
1678 (implicit EFLAGS)]>, Requires<[In32BitMode]>;
Chris Lattnercc65bee2005-01-02 02:35:46 +00001679}
Evan Cheng1693e482006-07-19 00:27:29 +00001680let isTwoAddress = 0, CodeSize = 2 in {
Dan Gohmanb1576f52007-07-31 20:11:57 +00001681 def INC8m : I<0xFE, MRM0m, (outs), (ins i8mem :$dst), "inc{b}\t$dst",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001682 [(store (add (loadi8 addr:$dst), 1), addr:$dst),
1683 (implicit EFLAGS)]>;
Dan Gohmanb1576f52007-07-31 20:11:57 +00001684 def INC16m : I<0xFF, MRM0m, (outs), (ins i16mem:$dst), "inc{w}\t$dst",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001685 [(store (add (loadi16 addr:$dst), 1), addr:$dst),
1686 (implicit EFLAGS)]>,
Evan Cheng66f71632007-10-19 21:23:22 +00001687 OpSize, Requires<[In32BitMode]>;
Dan Gohmanb1576f52007-07-31 20:11:57 +00001688 def INC32m : I<0xFF, MRM0m, (outs), (ins i32mem:$dst), "inc{l}\t$dst",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001689 [(store (add (loadi32 addr:$dst), 1), addr:$dst),
1690 (implicit EFLAGS)]>,
Evan Cheng66f71632007-10-19 21:23:22 +00001691 Requires<[In32BitMode]>;
Chris Lattner57a02302004-08-11 04:31:00 +00001692}
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00001693
Evan Cheng1693e482006-07-19 00:27:29 +00001694let CodeSize = 2 in
Dan Gohmanb1576f52007-07-31 20:11:57 +00001695def DEC8r : I<0xFE, MRM1r, (outs GR8 :$dst), (ins GR8 :$src), "dec{b}\t$dst",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001696 [(set GR8:$dst, (add GR8:$src, -1)),
1697 (implicit EFLAGS)]>;
Evan Cheng1693e482006-07-19 00:27:29 +00001698let isConvertibleToThreeAddress = 1, CodeSize = 1 in { // Can xform into LEA.
Sean Callanan108934c2009-12-18 00:01:26 +00001699def DEC16r : I<0x48, AddRegFrm, (outs GR16:$dst), (ins GR16:$src),
1700 "dec{w}\t$dst",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001701 [(set GR16:$dst, (add GR16:$src, -1)),
1702 (implicit EFLAGS)]>,
Evan Cheng25ab6902006-09-08 06:48:29 +00001703 OpSize, Requires<[In32BitMode]>;
Sean Callanan108934c2009-12-18 00:01:26 +00001704def DEC32r : I<0x48, AddRegFrm, (outs GR32:$dst), (ins GR32:$src),
1705 "dec{l}\t$dst",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001706 [(set GR32:$dst, (add GR32:$src, -1)),
1707 (implicit EFLAGS)]>, Requires<[In32BitMode]>;
Chris Lattnercc65bee2005-01-02 02:35:46 +00001708}
Chris Lattner57a02302004-08-11 04:31:00 +00001709
Evan Cheng1693e482006-07-19 00:27:29 +00001710let isTwoAddress = 0, CodeSize = 2 in {
Dan Gohmanb1576f52007-07-31 20:11:57 +00001711 def DEC8m : I<0xFE, MRM1m, (outs), (ins i8mem :$dst), "dec{b}\t$dst",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001712 [(store (add (loadi8 addr:$dst), -1), addr:$dst),
1713 (implicit EFLAGS)]>;
Dan Gohmanb1576f52007-07-31 20:11:57 +00001714 def DEC16m : I<0xFF, MRM1m, (outs), (ins i16mem:$dst), "dec{w}\t$dst",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001715 [(store (add (loadi16 addr:$dst), -1), addr:$dst),
1716 (implicit EFLAGS)]>,
Evan Cheng66f71632007-10-19 21:23:22 +00001717 OpSize, Requires<[In32BitMode]>;
Dan Gohmanb1576f52007-07-31 20:11:57 +00001718 def DEC32m : I<0xFF, MRM1m, (outs), (ins i32mem:$dst), "dec{l}\t$dst",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001719 [(store (add (loadi32 addr:$dst), -1), addr:$dst),
1720 (implicit EFLAGS)]>,
Evan Cheng66f71632007-10-19 21:23:22 +00001721 Requires<[In32BitMode]>;
Chris Lattner57a02302004-08-11 04:31:00 +00001722}
Evan Cheng24f2ea32007-09-14 21:48:26 +00001723} // Defs = [EFLAGS]
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00001724
1725// Logical operators...
Evan Cheng24f2ea32007-09-14 21:48:26 +00001726let Defs = [EFLAGS] in {
Chris Lattnercc65bee2005-01-02 02:35:46 +00001727let isCommutable = 1 in { // X = AND Y, Z --> X = AND Z, Y
Chris Lattner3a173df2004-10-03 20:35:00 +00001728def AND8rr : I<0x20, MRMDestReg,
Evan Cheng64d80e32007-07-19 01:14:50 +00001729 (outs GR8 :$dst), (ins GR8 :$src1, GR8 :$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001730 "and{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001731 [(set GR8:$dst, (and GR8:$src1, GR8:$src2)),
1732 (implicit EFLAGS)]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00001733def AND16rr : I<0x21, MRMDestReg,
Evan Cheng64d80e32007-07-19 01:14:50 +00001734 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001735 "and{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001736 [(set GR16:$dst, (and GR16:$src1, GR16:$src2)),
1737 (implicit EFLAGS)]>, OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00001738def AND32rr : I<0x21, MRMDestReg,
Evan Cheng64d80e32007-07-19 01:14:50 +00001739 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001740 "and{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001741 [(set GR32:$dst, (and GR32:$src1, GR32:$src2)),
1742 (implicit EFLAGS)]>;
Chris Lattnercc65bee2005-01-02 02:35:46 +00001743}
Chris Lattner57a02302004-08-11 04:31:00 +00001744
Sean Callanan108934c2009-12-18 00:01:26 +00001745// AND instructions with the destination register in REG and the source register
1746// in R/M. Included for the disassembler.
1747def AND8rr_REV : I<0x22, MRMSrcReg, (outs GR8:$dst), (ins GR8:$src1, GR8:$src2),
1748 "and{b}\t{$src2, $dst|$dst, $src2}", []>;
1749def AND16rr_REV : I<0x23, MRMSrcReg, (outs GR16:$dst),
1750 (ins GR16:$src1, GR16:$src2),
1751 "and{w}\t{$src2, $dst|$dst, $src2}", []>, OpSize;
1752def AND32rr_REV : I<0x23, MRMSrcReg, (outs GR32:$dst),
1753 (ins GR32:$src1, GR32:$src2),
1754 "and{l}\t{$src2, $dst|$dst, $src2}", []>;
1755
Chris Lattner3a173df2004-10-03 20:35:00 +00001756def AND8rm : I<0x22, MRMSrcMem,
Evan Cheng64d80e32007-07-19 01:14:50 +00001757 (outs GR8 :$dst), (ins GR8 :$src1, i8mem :$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001758 "and{b}\t{$src2, $dst|$dst, $src2}",
Chris Lattnerc2406f22009-04-10 00:16:23 +00001759 [(set GR8:$dst, (and GR8:$src1, (loadi8 addr:$src2))),
Dan Gohman09a2609e2009-03-03 19:53:46 +00001760 (implicit EFLAGS)]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00001761def AND16rm : I<0x23, MRMSrcMem,
Evan Cheng64d80e32007-07-19 01:14:50 +00001762 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001763 "and{w}\t{$src2, $dst|$dst, $src2}",
Chris Lattnerc2406f22009-04-10 00:16:23 +00001764 [(set GR16:$dst, (and GR16:$src1, (loadi16 addr:$src2))),
Dan Gohman09a2609e2009-03-03 19:53:46 +00001765 (implicit EFLAGS)]>, OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00001766def AND32rm : I<0x23, MRMSrcMem,
Evan Cheng64d80e32007-07-19 01:14:50 +00001767 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001768 "and{l}\t{$src2, $dst|$dst, $src2}",
Chris Lattnerc2406f22009-04-10 00:16:23 +00001769 [(set GR32:$dst, (and GR32:$src1, (loadi32 addr:$src2))),
Dan Gohman09a2609e2009-03-03 19:53:46 +00001770 (implicit EFLAGS)]>;
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00001771
Chris Lattner3a173df2004-10-03 20:35:00 +00001772def AND8ri : Ii8<0x80, MRM4r,
Evan Cheng64d80e32007-07-19 01:14:50 +00001773 (outs GR8 :$dst), (ins GR8 :$src1, i8imm :$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001774 "and{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001775 [(set GR8:$dst, (and GR8:$src1, imm:$src2)),
1776 (implicit EFLAGS)]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00001777def AND16ri : Ii16<0x81, MRM4r,
Evan Cheng64d80e32007-07-19 01:14:50 +00001778 (outs GR16:$dst), (ins GR16:$src1, i16imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001779 "and{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001780 [(set GR16:$dst, (and GR16:$src1, imm:$src2)),
1781 (implicit EFLAGS)]>, OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00001782def AND32ri : Ii32<0x81, MRM4r,
Evan Cheng64d80e32007-07-19 01:14:50 +00001783 (outs GR32:$dst), (ins GR32:$src1, i32imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001784 "and{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001785 [(set GR32:$dst, (and GR32:$src1, imm:$src2)),
1786 (implicit EFLAGS)]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00001787def AND16ri8 : Ii8<0x83, MRM4r,
Evan Cheng64d80e32007-07-19 01:14:50 +00001788 (outs GR16:$dst), (ins GR16:$src1, i16i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001789 "and{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001790 [(set GR16:$dst, (and GR16:$src1, i16immSExt8:$src2)),
1791 (implicit EFLAGS)]>,
Evan Cheng9b6b6422005-12-13 00:14:11 +00001792 OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00001793def AND32ri8 : Ii8<0x83, MRM4r,
Evan Cheng64d80e32007-07-19 01:14:50 +00001794 (outs GR32:$dst), (ins GR32:$src1, i32i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001795 "and{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001796 [(set GR32:$dst, (and GR32:$src1, i32immSExt8:$src2)),
1797 (implicit EFLAGS)]>;
Chris Lattnerf29ed092004-08-11 05:07:25 +00001798
1799let isTwoAddress = 0 in {
Chris Lattner3a173df2004-10-03 20:35:00 +00001800 def AND8mr : I<0x20, MRMDestMem,
Evan Cheng64d80e32007-07-19 01:14:50 +00001801 (outs), (ins i8mem :$dst, GR8 :$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001802 "and{b}\t{$src, $dst|$dst, $src}",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001803 [(store (and (load addr:$dst), GR8:$src), addr:$dst),
1804 (implicit EFLAGS)]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00001805 def AND16mr : I<0x21, MRMDestMem,
Evan Cheng64d80e32007-07-19 01:14:50 +00001806 (outs), (ins i16mem:$dst, GR16:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001807 "and{w}\t{$src, $dst|$dst, $src}",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001808 [(store (and (load addr:$dst), GR16:$src), addr:$dst),
1809 (implicit EFLAGS)]>,
Evan Cheng0ef3a772005-12-13 01:41:36 +00001810 OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00001811 def AND32mr : I<0x21, MRMDestMem,
Evan Cheng64d80e32007-07-19 01:14:50 +00001812 (outs), (ins i32mem:$dst, GR32:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001813 "and{l}\t{$src, $dst|$dst, $src}",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001814 [(store (and (load addr:$dst), GR32:$src), addr:$dst),
1815 (implicit EFLAGS)]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00001816 def AND8mi : Ii8<0x80, MRM4m,
Evan Cheng64d80e32007-07-19 01:14:50 +00001817 (outs), (ins i8mem :$dst, i8imm :$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001818 "and{b}\t{$src, $dst|$dst, $src}",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001819 [(store (and (loadi8 addr:$dst), imm:$src), addr:$dst),
1820 (implicit EFLAGS)]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00001821 def AND16mi : Ii16<0x81, MRM4m,
Evan Cheng64d80e32007-07-19 01:14:50 +00001822 (outs), (ins i16mem:$dst, i16imm:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001823 "and{w}\t{$src, $dst|$dst, $src}",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001824 [(store (and (loadi16 addr:$dst), imm:$src), addr:$dst),
1825 (implicit EFLAGS)]>,
Evan Cheng0ef3a772005-12-13 01:41:36 +00001826 OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00001827 def AND32mi : Ii32<0x81, MRM4m,
Evan Cheng64d80e32007-07-19 01:14:50 +00001828 (outs), (ins i32mem:$dst, i32imm:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001829 "and{l}\t{$src, $dst|$dst, $src}",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001830 [(store (and (loadi32 addr:$dst), imm:$src), addr:$dst),
1831 (implicit EFLAGS)]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00001832 def AND16mi8 : Ii8<0x83, MRM4m,
Evan Cheng64d80e32007-07-19 01:14:50 +00001833 (outs), (ins i16mem:$dst, i16i8imm :$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001834 "and{w}\t{$src, $dst|$dst, $src}",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001835 [(store (and (load addr:$dst), i16immSExt8:$src), addr:$dst),
1836 (implicit EFLAGS)]>,
Evan Cheng0ef3a772005-12-13 01:41:36 +00001837 OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00001838 def AND32mi8 : Ii8<0x83, MRM4m,
Evan Cheng64d80e32007-07-19 01:14:50 +00001839 (outs), (ins i32mem:$dst, i32i8imm :$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001840 "and{l}\t{$src, $dst|$dst, $src}",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001841 [(store (and (load addr:$dst), i32immSExt8:$src), addr:$dst),
1842 (implicit EFLAGS)]>;
Sean Callanana09caa52009-09-02 00:55:49 +00001843
1844 def AND8i8 : Ii8<0x24, RawFrm, (outs), (ins i8imm:$src),
1845 "and{b}\t{$src, %al|%al, $src}", []>;
1846 def AND16i16 : Ii16<0x25, RawFrm, (outs), (ins i16imm:$src),
1847 "and{w}\t{$src, %ax|%ax, $src}", []>, OpSize;
1848 def AND32i32 : Ii32<0x25, RawFrm, (outs), (ins i32imm:$src),
1849 "and{l}\t{$src, %eax|%eax, $src}", []>;
1850
Chris Lattnerf29ed092004-08-11 05:07:25 +00001851}
1852
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00001853
Chris Lattnercc65bee2005-01-02 02:35:46 +00001854let isCommutable = 1 in { // X = OR Y, Z --> X = OR Z, Y
Sean Callanan108934c2009-12-18 00:01:26 +00001855def OR8rr : I<0x08, MRMDestReg, (outs GR8 :$dst),
1856 (ins GR8 :$src1, GR8 :$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001857 "or{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001858 [(set GR8:$dst, (or GR8:$src1, GR8:$src2)),
1859 (implicit EFLAGS)]>;
Sean Callanan108934c2009-12-18 00:01:26 +00001860def OR16rr : I<0x09, MRMDestReg, (outs GR16:$dst),
1861 (ins GR16:$src1, GR16:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001862 "or{w}\t{$src2, $dst|$dst, $src2}",
Evan Cheng3bda2012010-01-12 18:31:19 +00001863 [(set GR16:$dst, (or GR16:$src1, GR16:$src2)),
Dan Gohman09a2609e2009-03-03 19:53:46 +00001864 (implicit EFLAGS)]>, OpSize;
Sean Callanan108934c2009-12-18 00:01:26 +00001865def OR32rr : I<0x09, MRMDestReg, (outs GR32:$dst),
1866 (ins GR32:$src1, GR32:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001867 "or{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng3bda2012010-01-12 18:31:19 +00001868 [(set GR32:$dst, (or GR32:$src1, GR32:$src2)),
Dan Gohman09a2609e2009-03-03 19:53:46 +00001869 (implicit EFLAGS)]>;
Chris Lattnercc65bee2005-01-02 02:35:46 +00001870}
Sean Callanan108934c2009-12-18 00:01:26 +00001871
1872// OR instructions with the destination register in REG and the source register
1873// in R/M. Included for the disassembler.
1874def OR8rr_REV : I<0x0A, MRMSrcReg, (outs GR8:$dst), (ins GR8:$src1, GR8:$src2),
1875 "or{b}\t{$src2, $dst|$dst, $src2}", []>;
1876def OR16rr_REV : I<0x0B, MRMSrcReg, (outs GR16:$dst),
1877 (ins GR16:$src1, GR16:$src2),
1878 "or{w}\t{$src2, $dst|$dst, $src2}", []>, OpSize;
1879def OR32rr_REV : I<0x0B, MRMSrcReg, (outs GR32:$dst),
1880 (ins GR32:$src1, GR32:$src2),
1881 "or{l}\t{$src2, $dst|$dst, $src2}", []>;
1882
1883def OR8rm : I<0x0A, MRMSrcMem , (outs GR8 :$dst),
1884 (ins GR8 :$src1, i8mem :$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001885 "or{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001886 [(set GR8:$dst, (or GR8:$src1, (load addr:$src2))),
1887 (implicit EFLAGS)]>;
Sean Callanan108934c2009-12-18 00:01:26 +00001888def OR16rm : I<0x0B, MRMSrcMem , (outs GR16:$dst),
1889 (ins GR16:$src1, i16mem:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001890 "or{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001891 [(set GR16:$dst, (or GR16:$src1, (load addr:$src2))),
1892 (implicit EFLAGS)]>, OpSize;
Sean Callanan108934c2009-12-18 00:01:26 +00001893def OR32rm : I<0x0B, MRMSrcMem , (outs GR32:$dst),
1894 (ins GR32:$src1, i32mem:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001895 "or{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001896 [(set GR32:$dst, (or GR32:$src1, (load addr:$src2))),
1897 (implicit EFLAGS)]>;
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00001898
Sean Callanan108934c2009-12-18 00:01:26 +00001899def OR8ri : Ii8 <0x80, MRM1r, (outs GR8 :$dst),
1900 (ins GR8 :$src1, i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001901 "or{b}\t{$src2, $dst|$dst, $src2}",
Evan Chengac000fa2010-01-11 20:18:04 +00001902 [(set GR8:$dst, (or GR8:$src1, imm:$src2)),
Dan Gohman09a2609e2009-03-03 19:53:46 +00001903 (implicit EFLAGS)]>;
Sean Callanan108934c2009-12-18 00:01:26 +00001904def OR16ri : Ii16<0x81, MRM1r, (outs GR16:$dst),
1905 (ins GR16:$src1, i16imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001906 "or{w}\t{$src2, $dst|$dst, $src2}",
Evan Cheng3bda2012010-01-12 18:31:19 +00001907 [(set GR16:$dst, (or GR16:$src1, imm:$src2)),
Dan Gohman09a2609e2009-03-03 19:53:46 +00001908 (implicit EFLAGS)]>, OpSize;
Sean Callanan108934c2009-12-18 00:01:26 +00001909def OR32ri : Ii32<0x81, MRM1r, (outs GR32:$dst),
1910 (ins GR32:$src1, i32imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001911 "or{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng3bda2012010-01-12 18:31:19 +00001912 [(set GR32:$dst, (or GR32:$src1, imm:$src2)),
Dan Gohman09a2609e2009-03-03 19:53:46 +00001913 (implicit EFLAGS)]>;
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00001914
Sean Callanan108934c2009-12-18 00:01:26 +00001915def OR16ri8 : Ii8<0x83, MRM1r, (outs GR16:$dst),
1916 (ins GR16:$src1, i16i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001917 "or{w}\t{$src2, $dst|$dst, $src2}",
Evan Cheng3bda2012010-01-12 18:31:19 +00001918 [(set GR16:$dst, (or GR16:$src1, i16immSExt8:$src2)),
Dan Gohman09a2609e2009-03-03 19:53:46 +00001919 (implicit EFLAGS)]>, OpSize;
Sean Callanan108934c2009-12-18 00:01:26 +00001920def OR32ri8 : Ii8<0x83, MRM1r, (outs GR32:$dst),
1921 (ins GR32:$src1, i32i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001922 "or{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng3bda2012010-01-12 18:31:19 +00001923 [(set GR32:$dst, (or GR32:$src1, i32immSExt8:$src2)),
Dan Gohman09a2609e2009-03-03 19:53:46 +00001924 (implicit EFLAGS)]>;
Chris Lattner57a02302004-08-11 04:31:00 +00001925let isTwoAddress = 0 in {
Evan Cheng64d80e32007-07-19 01:14:50 +00001926 def OR8mr : I<0x08, MRMDestMem, (outs), (ins i8mem:$dst, GR8:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001927 "or{b}\t{$src, $dst|$dst, $src}",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001928 [(store (or (load addr:$dst), GR8:$src), addr:$dst),
1929 (implicit EFLAGS)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00001930 def OR16mr : I<0x09, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001931 "or{w}\t{$src, $dst|$dst, $src}",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001932 [(store (or (load addr:$dst), GR16:$src), addr:$dst),
1933 (implicit EFLAGS)]>, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00001934 def OR32mr : I<0x09, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001935 "or{l}\t{$src, $dst|$dst, $src}",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001936 [(store (or (load addr:$dst), GR32:$src), addr:$dst),
1937 (implicit EFLAGS)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00001938 def OR8mi : Ii8<0x80, MRM1m, (outs), (ins i8mem :$dst, i8imm:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001939 "or{b}\t{$src, $dst|$dst, $src}",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001940 [(store (or (loadi8 addr:$dst), imm:$src), addr:$dst),
1941 (implicit EFLAGS)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00001942 def OR16mi : Ii16<0x81, MRM1m, (outs), (ins i16mem:$dst, i16imm:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001943 "or{w}\t{$src, $dst|$dst, $src}",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001944 [(store (or (loadi16 addr:$dst), imm:$src), addr:$dst),
1945 (implicit EFLAGS)]>,
Evan Cheng0ef3a772005-12-13 01:41:36 +00001946 OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00001947 def OR32mi : Ii32<0x81, MRM1m, (outs), (ins i32mem:$dst, i32imm:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001948 "or{l}\t{$src, $dst|$dst, $src}",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001949 [(store (or (loadi32 addr:$dst), imm:$src), addr:$dst),
1950 (implicit EFLAGS)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00001951 def OR16mi8 : Ii8<0x83, MRM1m, (outs), (ins i16mem:$dst, i16i8imm:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001952 "or{w}\t{$src, $dst|$dst, $src}",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001953 [(store (or (load addr:$dst), i16immSExt8:$src), addr:$dst),
1954 (implicit EFLAGS)]>,
Evan Cheng0ef3a772005-12-13 01:41:36 +00001955 OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00001956 def OR32mi8 : Ii8<0x83, MRM1m, (outs), (ins i32mem:$dst, i32i8imm:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001957 "or{l}\t{$src, $dst|$dst, $src}",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001958 [(store (or (load addr:$dst), i32immSExt8:$src), addr:$dst),
1959 (implicit EFLAGS)]>;
Sean Callanand00025a2009-09-11 19:01:56 +00001960
1961 def OR8i8 : Ii8 <0x0C, RawFrm, (outs), (ins i8imm:$src),
1962 "or{b}\t{$src, %al|%al, $src}", []>;
1963 def OR16i16 : Ii16 <0x0D, RawFrm, (outs), (ins i16imm:$src),
1964 "or{w}\t{$src, %ax|%ax, $src}", []>, OpSize;
1965 def OR32i32 : Ii32 <0x0D, RawFrm, (outs), (ins i32imm:$src),
1966 "or{l}\t{$src, %eax|%eax, $src}", []>;
Bill Wendlingbd0879d2008-05-29 01:02:09 +00001967} // isTwoAddress = 0
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00001968
1969
Evan Cheng359e9372008-06-18 08:13:07 +00001970let isCommutable = 1 in { // X = XOR Y, Z --> X = XOR Z, Y
Bill Wendlingbd0879d2008-05-29 01:02:09 +00001971 def XOR8rr : I<0x30, MRMDestReg,
1972 (outs GR8 :$dst), (ins GR8 :$src1, GR8 :$src2),
1973 "xor{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001974 [(set GR8:$dst, (xor GR8:$src1, GR8:$src2)),
1975 (implicit EFLAGS)]>;
Bill Wendlingbd0879d2008-05-29 01:02:09 +00001976 def XOR16rr : I<0x31, MRMDestReg,
1977 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
1978 "xor{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001979 [(set GR16:$dst, (xor GR16:$src1, GR16:$src2)),
1980 (implicit EFLAGS)]>, OpSize;
Bill Wendlingbd0879d2008-05-29 01:02:09 +00001981 def XOR32rr : I<0x31, MRMDestReg,
1982 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
1983 "xor{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001984 [(set GR32:$dst, (xor GR32:$src1, GR32:$src2)),
1985 (implicit EFLAGS)]>;
Evan Cheng359e9372008-06-18 08:13:07 +00001986} // isCommutable = 1
Chris Lattnercc65bee2005-01-02 02:35:46 +00001987
Sean Callanan108934c2009-12-18 00:01:26 +00001988// XOR instructions with the destination register in REG and the source register
1989// in R/M. Included for the disassembler.
1990def XOR8rr_REV : I<0x32, MRMSrcReg, (outs GR8:$dst), (ins GR8:$src1, GR8:$src2),
1991 "xor{b}\t{$src2, $dst|$dst, $src2}", []>;
1992def XOR16rr_REV : I<0x33, MRMSrcReg, (outs GR16:$dst),
1993 (ins GR16:$src1, GR16:$src2),
1994 "xor{w}\t{$src2, $dst|$dst, $src2}", []>, OpSize;
1995def XOR32rr_REV : I<0x33, MRMSrcReg, (outs GR32:$dst),
1996 (ins GR32:$src1, GR32:$src2),
1997 "xor{l}\t{$src2, $dst|$dst, $src2}", []>;
1998
Chris Lattner3a173df2004-10-03 20:35:00 +00001999def XOR8rm : I<0x32, MRMSrcMem ,
Evan Cheng64d80e32007-07-19 01:14:50 +00002000 (outs GR8 :$dst), (ins GR8:$src1, i8mem :$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002001 "xor{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohman09a2609e2009-03-03 19:53:46 +00002002 [(set GR8:$dst, (xor GR8:$src1, (load addr:$src2))),
2003 (implicit EFLAGS)]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00002004def XOR16rm : I<0x33, MRMSrcMem ,
Evan Cheng64d80e32007-07-19 01:14:50 +00002005 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002006 "xor{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohman09a2609e2009-03-03 19:53:46 +00002007 [(set GR16:$dst, (xor GR16:$src1, (load addr:$src2))),
2008 (implicit EFLAGS)]>,
Bill Wendlingbd0879d2008-05-29 01:02:09 +00002009 OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00002010def XOR32rm : I<0x33, MRMSrcMem ,
Evan Cheng64d80e32007-07-19 01:14:50 +00002011 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002012 "xor{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohman09a2609e2009-03-03 19:53:46 +00002013 [(set GR32:$dst, (xor GR32:$src1, (load addr:$src2))),
2014 (implicit EFLAGS)]>;
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00002015
Bill Wendling75cf88f2008-05-29 03:46:36 +00002016def XOR8ri : Ii8<0x80, MRM6r,
2017 (outs GR8:$dst), (ins GR8:$src1, i8imm:$src2),
2018 "xor{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohman09a2609e2009-03-03 19:53:46 +00002019 [(set GR8:$dst, (xor GR8:$src1, imm:$src2)),
2020 (implicit EFLAGS)]>;
Bill Wendling75cf88f2008-05-29 03:46:36 +00002021def XOR16ri : Ii16<0x81, MRM6r,
2022 (outs GR16:$dst), (ins GR16:$src1, i16imm:$src2),
2023 "xor{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohman09a2609e2009-03-03 19:53:46 +00002024 [(set GR16:$dst, (xor GR16:$src1, imm:$src2)),
2025 (implicit EFLAGS)]>, OpSize;
Bill Wendling75cf88f2008-05-29 03:46:36 +00002026def XOR32ri : Ii32<0x81, MRM6r,
2027 (outs GR32:$dst), (ins GR32:$src1, i32imm:$src2),
2028 "xor{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohman09a2609e2009-03-03 19:53:46 +00002029 [(set GR32:$dst, (xor GR32:$src1, imm:$src2)),
2030 (implicit EFLAGS)]>;
Bill Wendling75cf88f2008-05-29 03:46:36 +00002031def XOR16ri8 : Ii8<0x83, MRM6r,
2032 (outs GR16:$dst), (ins GR16:$src1, i16i8imm:$src2),
2033 "xor{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohman09a2609e2009-03-03 19:53:46 +00002034 [(set GR16:$dst, (xor GR16:$src1, i16immSExt8:$src2)),
2035 (implicit EFLAGS)]>,
Bill Wendling75cf88f2008-05-29 03:46:36 +00002036 OpSize;
2037def XOR32ri8 : Ii8<0x83, MRM6r,
2038 (outs GR32:$dst), (ins GR32:$src1, i32i8imm:$src2),
2039 "xor{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohman09a2609e2009-03-03 19:53:46 +00002040 [(set GR32:$dst, (xor GR32:$src1, i32immSExt8:$src2)),
2041 (implicit EFLAGS)]>;
Bill Wendlingbd0879d2008-05-29 01:02:09 +00002042
Chris Lattner57a02302004-08-11 04:31:00 +00002043let isTwoAddress = 0 in {
Chris Lattner3a173df2004-10-03 20:35:00 +00002044 def XOR8mr : I<0x30, MRMDestMem,
Evan Cheng64d80e32007-07-19 01:14:50 +00002045 (outs), (ins i8mem :$dst, GR8 :$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002046 "xor{b}\t{$src, $dst|$dst, $src}",
Dan Gohman09a2609e2009-03-03 19:53:46 +00002047 [(store (xor (load addr:$dst), GR8:$src), addr:$dst),
2048 (implicit EFLAGS)]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00002049 def XOR16mr : I<0x31, MRMDestMem,
Evan Cheng64d80e32007-07-19 01:14:50 +00002050 (outs), (ins i16mem:$dst, GR16:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002051 "xor{w}\t{$src, $dst|$dst, $src}",
Dan Gohman09a2609e2009-03-03 19:53:46 +00002052 [(store (xor (load addr:$dst), GR16:$src), addr:$dst),
2053 (implicit EFLAGS)]>,
Evan Cheng0ef3a772005-12-13 01:41:36 +00002054 OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00002055 def XOR32mr : I<0x31, MRMDestMem,
Evan Cheng64d80e32007-07-19 01:14:50 +00002056 (outs), (ins i32mem:$dst, GR32:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002057 "xor{l}\t{$src, $dst|$dst, $src}",
Dan Gohman09a2609e2009-03-03 19:53:46 +00002058 [(store (xor (load addr:$dst), GR32:$src), addr:$dst),
2059 (implicit EFLAGS)]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00002060 def XOR8mi : Ii8<0x80, MRM6m,
Evan Cheng64d80e32007-07-19 01:14:50 +00002061 (outs), (ins i8mem :$dst, i8imm :$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002062 "xor{b}\t{$src, $dst|$dst, $src}",
Dan Gohman09a2609e2009-03-03 19:53:46 +00002063 [(store (xor (loadi8 addr:$dst), imm:$src), addr:$dst),
2064 (implicit EFLAGS)]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00002065 def XOR16mi : Ii16<0x81, MRM6m,
Evan Cheng64d80e32007-07-19 01:14:50 +00002066 (outs), (ins i16mem:$dst, i16imm:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002067 "xor{w}\t{$src, $dst|$dst, $src}",
Dan Gohman09a2609e2009-03-03 19:53:46 +00002068 [(store (xor (loadi16 addr:$dst), imm:$src), addr:$dst),
2069 (implicit EFLAGS)]>,
Evan Cheng0ef3a772005-12-13 01:41:36 +00002070 OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00002071 def XOR32mi : Ii32<0x81, MRM6m,
Evan Cheng64d80e32007-07-19 01:14:50 +00002072 (outs), (ins i32mem:$dst, i32imm:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002073 "xor{l}\t{$src, $dst|$dst, $src}",
Dan Gohman09a2609e2009-03-03 19:53:46 +00002074 [(store (xor (loadi32 addr:$dst), imm:$src), addr:$dst),
2075 (implicit EFLAGS)]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00002076 def XOR16mi8 : Ii8<0x83, MRM6m,
Evan Cheng64d80e32007-07-19 01:14:50 +00002077 (outs), (ins i16mem:$dst, i16i8imm :$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002078 "xor{w}\t{$src, $dst|$dst, $src}",
Dan Gohman09a2609e2009-03-03 19:53:46 +00002079 [(store (xor (load addr:$dst), i16immSExt8:$src), addr:$dst),
2080 (implicit EFLAGS)]>,
Evan Cheng0ef3a772005-12-13 01:41:36 +00002081 OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00002082 def XOR32mi8 : Ii8<0x83, MRM6m,
Evan Cheng64d80e32007-07-19 01:14:50 +00002083 (outs), (ins i32mem:$dst, i32i8imm :$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002084 "xor{l}\t{$src, $dst|$dst, $src}",
Dan Gohman09a2609e2009-03-03 19:53:46 +00002085 [(store (xor (load addr:$dst), i32immSExt8:$src), addr:$dst),
2086 (implicit EFLAGS)]>;
Sean Callanan7893ec62009-09-10 19:52:26 +00002087
2088 def XOR8i8 : Ii8 <0x34, RawFrm, (outs), (ins i8imm:$src),
2089 "xor{b}\t{$src, %al|%al, $src}", []>;
2090 def XOR16i16 : Ii16 <0x35, RawFrm, (outs), (ins i16imm:$src),
2091 "xor{w}\t{$src, %ax|%ax, $src}", []>, OpSize;
2092 def XOR32i32 : Ii32 <0x35, RawFrm, (outs), (ins i32imm:$src),
2093 "xor{l}\t{$src, %eax|%eax, $src}", []>;
Bill Wendlingbd0879d2008-05-29 01:02:09 +00002094} // isTwoAddress = 0
Evan Cheng24f2ea32007-09-14 21:48:26 +00002095} // Defs = [EFLAGS]
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00002096
2097// Shift instructions
Evan Cheng24f2ea32007-09-14 21:48:26 +00002098let Defs = [EFLAGS] in {
Evan Cheng071a2792007-09-11 19:55:27 +00002099let Uses = [CL] in {
Evan Cheng64d80e32007-07-19 01:14:50 +00002100def SHL8rCL : I<0xD2, MRM4r, (outs GR8 :$dst), (ins GR8 :$src),
Eli Friedmanaace4b12009-06-19 04:48:38 +00002101 "shl{b}\t{%cl, $dst|$dst, CL}",
Evan Cheng071a2792007-09-11 19:55:27 +00002102 [(set GR8:$dst, (shl GR8:$src, CL))]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00002103def SHL16rCL : I<0xD3, MRM4r, (outs GR16:$dst), (ins GR16:$src),
Eli Friedmanaace4b12009-06-19 04:48:38 +00002104 "shl{w}\t{%cl, $dst|$dst, CL}",
Evan Cheng071a2792007-09-11 19:55:27 +00002105 [(set GR16:$dst, (shl GR16:$src, CL))]>, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00002106def SHL32rCL : I<0xD3, MRM4r, (outs GR32:$dst), (ins GR32:$src),
Eli Friedmanaace4b12009-06-19 04:48:38 +00002107 "shl{l}\t{%cl, $dst|$dst, CL}",
Evan Cheng071a2792007-09-11 19:55:27 +00002108 [(set GR32:$dst, (shl GR32:$src, CL))]>;
Bill Wendlingbd0879d2008-05-29 01:02:09 +00002109} // Uses = [CL]
Chris Lattnercc65bee2005-01-02 02:35:46 +00002110
Evan Cheng64d80e32007-07-19 01:14:50 +00002111def SHL8ri : Ii8<0xC0, MRM4r, (outs GR8 :$dst), (ins GR8 :$src1, i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002112 "shl{b}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00002113 [(set GR8:$dst, (shl GR8:$src1, (i8 imm:$src2)))]>;
Chris Lattnercc65bee2005-01-02 02:35:46 +00002114let isConvertibleToThreeAddress = 1 in { // Can transform into LEA.
Evan Cheng64d80e32007-07-19 01:14:50 +00002115def SHL16ri : Ii8<0xC1, MRM4r, (outs GR16:$dst), (ins GR16:$src1, i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002116 "shl{w}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00002117 [(set GR16:$dst, (shl GR16:$src1, (i8 imm:$src2)))]>, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00002118def SHL32ri : Ii8<0xC1, MRM4r, (outs GR32:$dst), (ins GR32:$src1, i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002119 "shl{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00002120 [(set GR32:$dst, (shl GR32:$src1, (i8 imm:$src2)))]>;
Sean Callanan13cf8e92009-09-16 02:28:43 +00002121
2122// NOTE: We don't include patterns for shifts of a register by one, because
2123// 'add reg,reg' is cheaper.
2124
2125def SHL8r1 : I<0xD0, MRM4r, (outs GR8:$dst), (ins GR8:$src1),
2126 "shl{b}\t$dst", []>;
2127def SHL16r1 : I<0xD1, MRM4r, (outs GR16:$dst), (ins GR16:$src1),
2128 "shl{w}\t$dst", []>, OpSize;
2129def SHL32r1 : I<0xD1, MRM4r, (outs GR32:$dst), (ins GR32:$src1),
2130 "shl{l}\t$dst", []>;
2131
Bill Wendlingbd0879d2008-05-29 01:02:09 +00002132} // isConvertibleToThreeAddress = 1
Evan Cheng09c54572006-06-29 00:36:51 +00002133
Chris Lattnerf29ed092004-08-11 05:07:25 +00002134let isTwoAddress = 0 in {
Evan Cheng071a2792007-09-11 19:55:27 +00002135 let Uses = [CL] in {
Evan Cheng64d80e32007-07-19 01:14:50 +00002136 def SHL8mCL : I<0xD2, MRM4m, (outs), (ins i8mem :$dst),
Eli Friedmanaace4b12009-06-19 04:48:38 +00002137 "shl{b}\t{%cl, $dst|$dst, CL}",
Evan Cheng071a2792007-09-11 19:55:27 +00002138 [(store (shl (loadi8 addr:$dst), CL), addr:$dst)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00002139 def SHL16mCL : I<0xD3, MRM4m, (outs), (ins i16mem:$dst),
Eli Friedmanaace4b12009-06-19 04:48:38 +00002140 "shl{w}\t{%cl, $dst|$dst, CL}",
Evan Cheng071a2792007-09-11 19:55:27 +00002141 [(store (shl (loadi16 addr:$dst), CL), addr:$dst)]>, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00002142 def SHL32mCL : I<0xD3, MRM4m, (outs), (ins i32mem:$dst),
Eli Friedmanaace4b12009-06-19 04:48:38 +00002143 "shl{l}\t{%cl, $dst|$dst, CL}",
Evan Cheng071a2792007-09-11 19:55:27 +00002144 [(store (shl (loadi32 addr:$dst), CL), addr:$dst)]>;
2145 }
Evan Cheng64d80e32007-07-19 01:14:50 +00002146 def SHL8mi : Ii8<0xC0, MRM4m, (outs), (ins i8mem :$dst, i8imm:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002147 "shl{b}\t{$src, $dst|$dst, $src}",
Evan Cheng763b0292005-12-13 02:34:51 +00002148 [(store (shl (loadi8 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00002149 def SHL16mi : Ii8<0xC1, MRM4m, (outs), (ins i16mem:$dst, i8imm:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002150 "shl{w}\t{$src, $dst|$dst, $src}",
Evan Cheng763b0292005-12-13 02:34:51 +00002151 [(store (shl (loadi16 addr:$dst), (i8 imm:$src)), addr:$dst)]>,
2152 OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00002153 def SHL32mi : Ii8<0xC1, MRM4m, (outs), (ins i32mem:$dst, i8imm:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002154 "shl{l}\t{$src, $dst|$dst, $src}",
Evan Cheng763b0292005-12-13 02:34:51 +00002155 [(store (shl (loadi32 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
Evan Cheng09c54572006-06-29 00:36:51 +00002156
2157 // Shift by 1
Evan Cheng64d80e32007-07-19 01:14:50 +00002158 def SHL8m1 : I<0xD0, MRM4m, (outs), (ins i8mem :$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002159 "shl{b}\t$dst",
Evan Cheng09c54572006-06-29 00:36:51 +00002160 [(store (shl (loadi8 addr:$dst), (i8 1)), addr:$dst)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00002161 def SHL16m1 : I<0xD1, MRM4m, (outs), (ins i16mem:$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002162 "shl{w}\t$dst",
Evan Cheng09c54572006-06-29 00:36:51 +00002163 [(store (shl (loadi16 addr:$dst), (i8 1)), addr:$dst)]>,
2164 OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00002165 def SHL32m1 : I<0xD1, MRM4m, (outs), (ins i32mem:$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002166 "shl{l}\t$dst",
Evan Cheng09c54572006-06-29 00:36:51 +00002167 [(store (shl (loadi32 addr:$dst), (i8 1)), addr:$dst)]>;
Chris Lattnerf29ed092004-08-11 05:07:25 +00002168}
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00002169
Evan Cheng071a2792007-09-11 19:55:27 +00002170let Uses = [CL] in {
Evan Cheng64d80e32007-07-19 01:14:50 +00002171def SHR8rCL : I<0xD2, MRM5r, (outs GR8 :$dst), (ins GR8 :$src),
Eli Friedmanaace4b12009-06-19 04:48:38 +00002172 "shr{b}\t{%cl, $dst|$dst, CL}",
Evan Cheng071a2792007-09-11 19:55:27 +00002173 [(set GR8:$dst, (srl GR8:$src, CL))]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00002174def SHR16rCL : I<0xD3, MRM5r, (outs GR16:$dst), (ins GR16:$src),
Eli Friedmanaace4b12009-06-19 04:48:38 +00002175 "shr{w}\t{%cl, $dst|$dst, CL}",
Evan Cheng071a2792007-09-11 19:55:27 +00002176 [(set GR16:$dst, (srl GR16:$src, CL))]>, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00002177def SHR32rCL : I<0xD3, MRM5r, (outs GR32:$dst), (ins GR32:$src),
Eli Friedmanaace4b12009-06-19 04:48:38 +00002178 "shr{l}\t{%cl, $dst|$dst, CL}",
Evan Cheng071a2792007-09-11 19:55:27 +00002179 [(set GR32:$dst, (srl GR32:$src, CL))]>;
2180}
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00002181
Evan Cheng64d80e32007-07-19 01:14:50 +00002182def SHR8ri : Ii8<0xC0, MRM5r, (outs GR8:$dst), (ins GR8:$src1, i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002183 "shr{b}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00002184 [(set GR8:$dst, (srl GR8:$src1, (i8 imm:$src2)))]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00002185def SHR16ri : Ii8<0xC1, MRM5r, (outs GR16:$dst), (ins GR16:$src1, i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002186 "shr{w}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00002187 [(set GR16:$dst, (srl GR16:$src1, (i8 imm:$src2)))]>, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00002188def SHR32ri : Ii8<0xC1, MRM5r, (outs GR32:$dst), (ins GR32:$src1, i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002189 "shr{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00002190 [(set GR32:$dst, (srl GR32:$src1, (i8 imm:$src2)))]>;
Chris Lattnerf29ed092004-08-11 05:07:25 +00002191
Evan Cheng09c54572006-06-29 00:36:51 +00002192// Shift by 1
Evan Cheng64d80e32007-07-19 01:14:50 +00002193def SHR8r1 : I<0xD0, MRM5r, (outs GR8:$dst), (ins GR8:$src1),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002194 "shr{b}\t$dst",
Evan Cheng09c54572006-06-29 00:36:51 +00002195 [(set GR8:$dst, (srl GR8:$src1, (i8 1)))]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00002196def SHR16r1 : I<0xD1, MRM5r, (outs GR16:$dst), (ins GR16:$src1),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002197 "shr{w}\t$dst",
Evan Cheng09c54572006-06-29 00:36:51 +00002198 [(set GR16:$dst, (srl GR16:$src1, (i8 1)))]>, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00002199def SHR32r1 : I<0xD1, MRM5r, (outs GR32:$dst), (ins GR32:$src1),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002200 "shr{l}\t$dst",
Evan Cheng09c54572006-06-29 00:36:51 +00002201 [(set GR32:$dst, (srl GR32:$src1, (i8 1)))]>;
2202
Chris Lattner57a02302004-08-11 04:31:00 +00002203let isTwoAddress = 0 in {
Evan Cheng071a2792007-09-11 19:55:27 +00002204 let Uses = [CL] in {
Evan Cheng64d80e32007-07-19 01:14:50 +00002205 def SHR8mCL : I<0xD2, MRM5m, (outs), (ins i8mem :$dst),
Eli Friedmanaace4b12009-06-19 04:48:38 +00002206 "shr{b}\t{%cl, $dst|$dst, CL}",
Evan Cheng071a2792007-09-11 19:55:27 +00002207 [(store (srl (loadi8 addr:$dst), CL), addr:$dst)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00002208 def SHR16mCL : I<0xD3, MRM5m, (outs), (ins i16mem:$dst),
Eli Friedmanaace4b12009-06-19 04:48:38 +00002209 "shr{w}\t{%cl, $dst|$dst, CL}",
Evan Cheng85dd8892005-12-13 07:24:22 +00002210 [(store (srl (loadi16 addr:$dst), CL), addr:$dst)]>,
Evan Cheng071a2792007-09-11 19:55:27 +00002211 OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00002212 def SHR32mCL : I<0xD3, MRM5m, (outs), (ins i32mem:$dst),
Eli Friedmanaace4b12009-06-19 04:48:38 +00002213 "shr{l}\t{%cl, $dst|$dst, CL}",
Evan Cheng071a2792007-09-11 19:55:27 +00002214 [(store (srl (loadi32 addr:$dst), CL), addr:$dst)]>;
2215 }
Evan Cheng64d80e32007-07-19 01:14:50 +00002216 def SHR8mi : Ii8<0xC0, MRM5m, (outs), (ins i8mem :$dst, i8imm:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002217 "shr{b}\t{$src, $dst|$dst, $src}",
Evan Cheng85dd8892005-12-13 07:24:22 +00002218 [(store (srl (loadi8 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00002219 def SHR16mi : Ii8<0xC1, MRM5m, (outs), (ins i16mem:$dst, i8imm:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002220 "shr{w}\t{$src, $dst|$dst, $src}",
Evan Cheng85dd8892005-12-13 07:24:22 +00002221 [(store (srl (loadi16 addr:$dst), (i8 imm:$src)), addr:$dst)]>,
2222 OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00002223 def SHR32mi : Ii8<0xC1, MRM5m, (outs), (ins i32mem:$dst, i8imm:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002224 "shr{l}\t{$src, $dst|$dst, $src}",
Evan Cheng85dd8892005-12-13 07:24:22 +00002225 [(store (srl (loadi32 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
Evan Cheng09c54572006-06-29 00:36:51 +00002226
2227 // Shift by 1
Evan Cheng64d80e32007-07-19 01:14:50 +00002228 def SHR8m1 : I<0xD0, MRM5m, (outs), (ins i8mem :$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002229 "shr{b}\t$dst",
Evan Cheng09c54572006-06-29 00:36:51 +00002230 [(store (srl (loadi8 addr:$dst), (i8 1)), addr:$dst)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00002231 def SHR16m1 : I<0xD1, MRM5m, (outs), (ins i16mem:$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002232 "shr{w}\t$dst",
Evan Cheng09c54572006-06-29 00:36:51 +00002233 [(store (srl (loadi16 addr:$dst), (i8 1)), addr:$dst)]>,OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00002234 def SHR32m1 : I<0xD1, MRM5m, (outs), (ins i32mem:$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002235 "shr{l}\t$dst",
Evan Cheng09c54572006-06-29 00:36:51 +00002236 [(store (srl (loadi32 addr:$dst), (i8 1)), addr:$dst)]>;
Chris Lattner57a02302004-08-11 04:31:00 +00002237}
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00002238
Evan Cheng071a2792007-09-11 19:55:27 +00002239let Uses = [CL] in {
Evan Cheng64d80e32007-07-19 01:14:50 +00002240def SAR8rCL : I<0xD2, MRM7r, (outs GR8 :$dst), (ins GR8 :$src),
Eli Friedmanaace4b12009-06-19 04:48:38 +00002241 "sar{b}\t{%cl, $dst|$dst, CL}",
Evan Cheng071a2792007-09-11 19:55:27 +00002242 [(set GR8:$dst, (sra GR8:$src, CL))]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00002243def SAR16rCL : I<0xD3, MRM7r, (outs GR16:$dst), (ins GR16:$src),
Eli Friedmanaace4b12009-06-19 04:48:38 +00002244 "sar{w}\t{%cl, $dst|$dst, CL}",
Evan Cheng071a2792007-09-11 19:55:27 +00002245 [(set GR16:$dst, (sra GR16:$src, CL))]>, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00002246def SAR32rCL : I<0xD3, MRM7r, (outs GR32:$dst), (ins GR32:$src),
Eli Friedmanaace4b12009-06-19 04:48:38 +00002247 "sar{l}\t{%cl, $dst|$dst, CL}",
Evan Cheng071a2792007-09-11 19:55:27 +00002248 [(set GR32:$dst, (sra GR32:$src, CL))]>;
2249}
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00002250
Evan Cheng64d80e32007-07-19 01:14:50 +00002251def SAR8ri : Ii8<0xC0, MRM7r, (outs GR8 :$dst), (ins GR8 :$src1, i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002252 "sar{b}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00002253 [(set GR8:$dst, (sra GR8:$src1, (i8 imm:$src2)))]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00002254def SAR16ri : Ii8<0xC1, MRM7r, (outs GR16:$dst), (ins GR16:$src1, i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002255 "sar{w}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00002256 [(set GR16:$dst, (sra GR16:$src1, (i8 imm:$src2)))]>,
Chris Lattner3d36a9f2005-12-05 02:40:25 +00002257 OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00002258def SAR32ri : Ii8<0xC1, MRM7r, (outs GR32:$dst), (ins GR32:$src1, i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002259 "sar{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00002260 [(set GR32:$dst, (sra GR32:$src1, (i8 imm:$src2)))]>;
Evan Cheng09c54572006-06-29 00:36:51 +00002261
2262// Shift by 1
Evan Cheng64d80e32007-07-19 01:14:50 +00002263def SAR8r1 : I<0xD0, MRM7r, (outs GR8 :$dst), (ins GR8 :$src1),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002264 "sar{b}\t$dst",
Evan Cheng09c54572006-06-29 00:36:51 +00002265 [(set GR8:$dst, (sra GR8:$src1, (i8 1)))]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00002266def SAR16r1 : I<0xD1, MRM7r, (outs GR16:$dst), (ins GR16:$src1),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002267 "sar{w}\t$dst",
Evan Cheng09c54572006-06-29 00:36:51 +00002268 [(set GR16:$dst, (sra GR16:$src1, (i8 1)))]>, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00002269def SAR32r1 : I<0xD1, MRM7r, (outs GR32:$dst), (ins GR32:$src1),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002270 "sar{l}\t$dst",
Evan Cheng09c54572006-06-29 00:36:51 +00002271 [(set GR32:$dst, (sra GR32:$src1, (i8 1)))]>;
2272
Chris Lattnerf29ed092004-08-11 05:07:25 +00002273let isTwoAddress = 0 in {
Evan Cheng071a2792007-09-11 19:55:27 +00002274 let Uses = [CL] in {
Evan Cheng64d80e32007-07-19 01:14:50 +00002275 def SAR8mCL : I<0xD2, MRM7m, (outs), (ins i8mem :$dst),
Eli Friedmanaace4b12009-06-19 04:48:38 +00002276 "sar{b}\t{%cl, $dst|$dst, CL}",
Evan Cheng071a2792007-09-11 19:55:27 +00002277 [(store (sra (loadi8 addr:$dst), CL), addr:$dst)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00002278 def SAR16mCL : I<0xD3, MRM7m, (outs), (ins i16mem:$dst),
Eli Friedmanaace4b12009-06-19 04:48:38 +00002279 "sar{w}\t{%cl, $dst|$dst, CL}",
Evan Cheng071a2792007-09-11 19:55:27 +00002280 [(store (sra (loadi16 addr:$dst), CL), addr:$dst)]>, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00002281 def SAR32mCL : I<0xD3, MRM7m, (outs), (ins i32mem:$dst),
Eli Friedmanaace4b12009-06-19 04:48:38 +00002282 "sar{l}\t{%cl, $dst|$dst, CL}",
Evan Cheng071a2792007-09-11 19:55:27 +00002283 [(store (sra (loadi32 addr:$dst), CL), addr:$dst)]>;
2284 }
Evan Cheng64d80e32007-07-19 01:14:50 +00002285 def SAR8mi : Ii8<0xC0, MRM7m, (outs), (ins i8mem :$dst, i8imm:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002286 "sar{b}\t{$src, $dst|$dst, $src}",
Evan Cheng85dd8892005-12-13 07:24:22 +00002287 [(store (sra (loadi8 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00002288 def SAR16mi : Ii8<0xC1, MRM7m, (outs), (ins i16mem:$dst, i8imm:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002289 "sar{w}\t{$src, $dst|$dst, $src}",
Evan Cheng85dd8892005-12-13 07:24:22 +00002290 [(store (sra (loadi16 addr:$dst), (i8 imm:$src)), addr:$dst)]>,
2291 OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00002292 def SAR32mi : Ii8<0xC1, MRM7m, (outs), (ins i32mem:$dst, i8imm:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002293 "sar{l}\t{$src, $dst|$dst, $src}",
Evan Cheng85dd8892005-12-13 07:24:22 +00002294 [(store (sra (loadi32 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
Evan Cheng09c54572006-06-29 00:36:51 +00002295
2296 // Shift by 1
Evan Cheng64d80e32007-07-19 01:14:50 +00002297 def SAR8m1 : I<0xD0, MRM7m, (outs), (ins i8mem :$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002298 "sar{b}\t$dst",
Evan Cheng09c54572006-06-29 00:36:51 +00002299 [(store (sra (loadi8 addr:$dst), (i8 1)), addr:$dst)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00002300 def SAR16m1 : I<0xD1, MRM7m, (outs), (ins i16mem:$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002301 "sar{w}\t$dst",
Evan Cheng09c54572006-06-29 00:36:51 +00002302 [(store (sra (loadi16 addr:$dst), (i8 1)), addr:$dst)]>,
2303 OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00002304 def SAR32m1 : I<0xD1, MRM7m, (outs), (ins i32mem:$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002305 "sar{l}\t$dst",
Evan Cheng09c54572006-06-29 00:36:51 +00002306 [(store (sra (loadi32 addr:$dst), (i8 1)), addr:$dst)]>;
Chris Lattnerf29ed092004-08-11 05:07:25 +00002307}
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00002308
Chris Lattner40ff6332005-01-19 07:50:03 +00002309// Rotate instructions
Sean Callanana2dc2822009-09-18 19:35:23 +00002310
2311def RCL8r1 : I<0xD0, MRM2r, (outs GR8:$dst), (ins GR8:$src),
2312 "rcl{b}\t{1, $dst|$dst, 1}", []>;
Sean Callanana2dc2822009-09-18 19:35:23 +00002313let Uses = [CL] in {
2314def RCL8rCL : I<0xD2, MRM2r, (outs GR8:$dst), (ins GR8:$src),
2315 "rcl{b}\t{%cl, $dst|$dst, CL}", []>;
Sean Callanana2dc2822009-09-18 19:35:23 +00002316}
2317def RCL8ri : Ii8<0xC0, MRM2r, (outs GR8:$dst), (ins GR8:$src, i8imm:$cnt),
2318 "rcl{b}\t{$cnt, $dst|$dst, $cnt}", []>;
Sean Callanana2dc2822009-09-18 19:35:23 +00002319
2320def RCL16r1 : I<0xD1, MRM2r, (outs GR16:$dst), (ins GR16:$src),
2321 "rcl{w}\t{1, $dst|$dst, 1}", []>, OpSize;
Sean Callanana2dc2822009-09-18 19:35:23 +00002322let Uses = [CL] in {
2323def RCL16rCL : I<0xD3, MRM2r, (outs GR16:$dst), (ins GR16:$src),
2324 "rcl{w}\t{%cl, $dst|$dst, CL}", []>, OpSize;
Sean Callanana2dc2822009-09-18 19:35:23 +00002325}
2326def RCL16ri : Ii8<0xC1, MRM2r, (outs GR16:$dst), (ins GR16:$src, i8imm:$cnt),
2327 "rcl{w}\t{$cnt, $dst|$dst, $cnt}", []>, OpSize;
Sean Callanana2dc2822009-09-18 19:35:23 +00002328
2329def RCL32r1 : I<0xD1, MRM2r, (outs GR32:$dst), (ins GR32:$src),
2330 "rcl{l}\t{1, $dst|$dst, 1}", []>;
Sean Callanana2dc2822009-09-18 19:35:23 +00002331let Uses = [CL] in {
2332def RCL32rCL : I<0xD3, MRM2r, (outs GR32:$dst), (ins GR32:$src),
2333 "rcl{l}\t{%cl, $dst|$dst, CL}", []>;
Sean Callanana2dc2822009-09-18 19:35:23 +00002334}
2335def RCL32ri : Ii8<0xC1, MRM2r, (outs GR32:$dst), (ins GR32:$src, i8imm:$cnt),
2336 "rcl{l}\t{$cnt, $dst|$dst, $cnt}", []>;
Sean Callanana2dc2822009-09-18 19:35:23 +00002337
2338def RCR8r1 : I<0xD0, MRM3r, (outs GR8:$dst), (ins GR8:$src),
2339 "rcr{b}\t{1, $dst|$dst, 1}", []>;
Sean Callanana2dc2822009-09-18 19:35:23 +00002340let Uses = [CL] in {
2341def RCR8rCL : I<0xD2, MRM3r, (outs GR8:$dst), (ins GR8:$src),
2342 "rcr{b}\t{%cl, $dst|$dst, CL}", []>;
Sean Callanana2dc2822009-09-18 19:35:23 +00002343}
2344def RCR8ri : Ii8<0xC0, MRM3r, (outs GR8:$dst), (ins GR8:$src, i8imm:$cnt),
2345 "rcr{b}\t{$cnt, $dst|$dst, $cnt}", []>;
Sean Callanana2dc2822009-09-18 19:35:23 +00002346
2347def RCR16r1 : I<0xD1, MRM3r, (outs GR16:$dst), (ins GR16:$src),
2348 "rcr{w}\t{1, $dst|$dst, 1}", []>, OpSize;
Sean Callanana2dc2822009-09-18 19:35:23 +00002349let Uses = [CL] in {
2350def RCR16rCL : I<0xD3, MRM3r, (outs GR16:$dst), (ins GR16:$src),
2351 "rcr{w}\t{%cl, $dst|$dst, CL}", []>, OpSize;
Sean Callanana2dc2822009-09-18 19:35:23 +00002352}
2353def RCR16ri : Ii8<0xC1, MRM3r, (outs GR16:$dst), (ins GR16:$src, i8imm:$cnt),
2354 "rcr{w}\t{$cnt, $dst|$dst, $cnt}", []>, OpSize;
Sean Callanana2dc2822009-09-18 19:35:23 +00002355
2356def RCR32r1 : I<0xD1, MRM3r, (outs GR32:$dst), (ins GR32:$src),
2357 "rcr{l}\t{1, $dst|$dst, 1}", []>;
Sean Callanana2dc2822009-09-18 19:35:23 +00002358let Uses = [CL] in {
2359def RCR32rCL : I<0xD3, MRM3r, (outs GR32:$dst), (ins GR32:$src),
2360 "rcr{l}\t{%cl, $dst|$dst, CL}", []>;
Sean Callanana2dc2822009-09-18 19:35:23 +00002361}
2362def RCR32ri : Ii8<0xC1, MRM3r, (outs GR32:$dst), (ins GR32:$src, i8imm:$cnt),
2363 "rcr{l}\t{$cnt, $dst|$dst, $cnt}", []>;
Daniel Dunbarccfa1db2010-02-12 01:22:03 +00002364
2365let isTwoAddress = 0 in {
2366def RCL8m1 : I<0xD0, MRM2m, (outs), (ins i8mem:$dst),
2367 "rcl{b}\t{1, $dst|$dst, 1}", []>;
2368def RCL8mi : Ii8<0xC0, MRM2m, (outs), (ins i8mem:$dst, i8imm:$cnt),
2369 "rcl{b}\t{$cnt, $dst|$dst, $cnt}", []>;
2370def RCL16m1 : I<0xD1, MRM2m, (outs), (ins i16mem:$dst),
2371 "rcl{w}\t{1, $dst|$dst, 1}", []>, OpSize;
2372def RCL16mi : Ii8<0xC1, MRM2m, (outs), (ins i16mem:$dst, i8imm:$cnt),
2373 "rcl{w}\t{$cnt, $dst|$dst, $cnt}", []>, OpSize;
2374def RCL32m1 : I<0xD1, MRM2m, (outs), (ins i32mem:$dst),
2375 "rcl{l}\t{1, $dst|$dst, 1}", []>;
2376def RCL32mi : Ii8<0xC1, MRM2m, (outs), (ins i32mem:$dst, i8imm:$cnt),
2377 "rcl{l}\t{$cnt, $dst|$dst, $cnt}", []>;
2378def RCR8m1 : I<0xD0, MRM3m, (outs), (ins i8mem:$dst),
2379 "rcr{b}\t{1, $dst|$dst, 1}", []>;
2380def RCR8mi : Ii8<0xC0, MRM3m, (outs), (ins i8mem:$dst, i8imm:$cnt),
2381 "rcr{b}\t{$cnt, $dst|$dst, $cnt}", []>;
2382def RCR16m1 : I<0xD1, MRM3m, (outs), (ins i16mem:$dst),
2383 "rcr{w}\t{1, $dst|$dst, 1}", []>, OpSize;
2384def RCR16mi : Ii8<0xC1, MRM3m, (outs), (ins i16mem:$dst, i8imm:$cnt),
2385 "rcr{w}\t{$cnt, $dst|$dst, $cnt}", []>, OpSize;
2386def RCR32m1 : I<0xD1, MRM3m, (outs), (ins i32mem:$dst),
2387 "rcr{l}\t{1, $dst|$dst, 1}", []>;
2388def RCR32mi : Ii8<0xC1, MRM3m, (outs), (ins i32mem:$dst, i8imm:$cnt),
Sean Callanana2dc2822009-09-18 19:35:23 +00002389 "rcr{l}\t{$cnt, $dst|$dst, $cnt}", []>;
2390
Daniel Dunbarccfa1db2010-02-12 01:22:03 +00002391let Uses = [CL] in {
2392def RCL8mCL : I<0xD2, MRM2m, (outs), (ins i8mem:$dst),
2393 "rcl{b}\t{%cl, $dst|$dst, CL}", []>;
2394def RCL16mCL : I<0xD3, MRM2m, (outs), (ins i16mem:$dst),
2395 "rcl{w}\t{%cl, $dst|$dst, CL}", []>, OpSize;
2396def RCL32mCL : I<0xD3, MRM2m, (outs), (ins i32mem:$dst),
2397 "rcl{l}\t{%cl, $dst|$dst, CL}", []>;
2398def RCR8mCL : I<0xD2, MRM3m, (outs), (ins i8mem:$dst),
2399 "rcr{b}\t{%cl, $dst|$dst, CL}", []>;
2400def RCR16mCL : I<0xD3, MRM3m, (outs), (ins i16mem:$dst),
2401 "rcr{w}\t{%cl, $dst|$dst, CL}", []>, OpSize;
2402def RCR32mCL : I<0xD3, MRM3m, (outs), (ins i32mem:$dst),
2403 "rcr{l}\t{%cl, $dst|$dst, CL}", []>;
2404}
2405}
2406
Chris Lattner40ff6332005-01-19 07:50:03 +00002407// FIXME: provide shorter instructions when imm8 == 1
Evan Cheng071a2792007-09-11 19:55:27 +00002408let Uses = [CL] in {
Evan Cheng64d80e32007-07-19 01:14:50 +00002409def ROL8rCL : I<0xD2, MRM0r, (outs GR8 :$dst), (ins GR8 :$src),
Eli Friedmanaace4b12009-06-19 04:48:38 +00002410 "rol{b}\t{%cl, $dst|$dst, CL}",
Evan Cheng071a2792007-09-11 19:55:27 +00002411 [(set GR8:$dst, (rotl GR8:$src, CL))]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00002412def ROL16rCL : I<0xD3, MRM0r, (outs GR16:$dst), (ins GR16:$src),
Eli Friedmanaace4b12009-06-19 04:48:38 +00002413 "rol{w}\t{%cl, $dst|$dst, CL}",
Evan Cheng071a2792007-09-11 19:55:27 +00002414 [(set GR16:$dst, (rotl GR16:$src, CL))]>, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00002415def ROL32rCL : I<0xD3, MRM0r, (outs GR32:$dst), (ins GR32:$src),
Eli Friedmanaace4b12009-06-19 04:48:38 +00002416 "rol{l}\t{%cl, $dst|$dst, CL}",
Evan Cheng071a2792007-09-11 19:55:27 +00002417 [(set GR32:$dst, (rotl GR32:$src, CL))]>;
2418}
Chris Lattner40ff6332005-01-19 07:50:03 +00002419
Evan Cheng64d80e32007-07-19 01:14:50 +00002420def ROL8ri : Ii8<0xC0, MRM0r, (outs GR8 :$dst), (ins GR8 :$src1, i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002421 "rol{b}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00002422 [(set GR8:$dst, (rotl GR8:$src1, (i8 imm:$src2)))]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00002423def ROL16ri : Ii8<0xC1, MRM0r, (outs GR16:$dst), (ins GR16:$src1, i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002424 "rol{w}\t{$src2, $dst|$dst, $src2}",
Sean Callanan108934c2009-12-18 00:01:26 +00002425 [(set GR16:$dst, (rotl GR16:$src1, (i8 imm:$src2)))]>,
2426 OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00002427def ROL32ri : Ii8<0xC1, MRM0r, (outs GR32:$dst), (ins GR32:$src1, i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002428 "rol{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00002429 [(set GR32:$dst, (rotl GR32:$src1, (i8 imm:$src2)))]>;
Chris Lattner40ff6332005-01-19 07:50:03 +00002430
Evan Cheng09c54572006-06-29 00:36:51 +00002431// Rotate by 1
Evan Cheng64d80e32007-07-19 01:14:50 +00002432def ROL8r1 : I<0xD0, MRM0r, (outs GR8 :$dst), (ins GR8 :$src1),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002433 "rol{b}\t$dst",
Evan Cheng09c54572006-06-29 00:36:51 +00002434 [(set GR8:$dst, (rotl GR8:$src1, (i8 1)))]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00002435def ROL16r1 : I<0xD1, MRM0r, (outs GR16:$dst), (ins GR16:$src1),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002436 "rol{w}\t$dst",
Evan Cheng09c54572006-06-29 00:36:51 +00002437 [(set GR16:$dst, (rotl GR16:$src1, (i8 1)))]>, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00002438def ROL32r1 : I<0xD1, MRM0r, (outs GR32:$dst), (ins GR32:$src1),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002439 "rol{l}\t$dst",
Evan Cheng09c54572006-06-29 00:36:51 +00002440 [(set GR32:$dst, (rotl GR32:$src1, (i8 1)))]>;
2441
Chris Lattner40ff6332005-01-19 07:50:03 +00002442let isTwoAddress = 0 in {
Evan Cheng071a2792007-09-11 19:55:27 +00002443 let Uses = [CL] in {
Evan Cheng64d80e32007-07-19 01:14:50 +00002444 def ROL8mCL : I<0xD2, MRM0m, (outs), (ins i8mem :$dst),
Eli Friedmanaace4b12009-06-19 04:48:38 +00002445 "rol{b}\t{%cl, $dst|$dst, CL}",
Evan Cheng071a2792007-09-11 19:55:27 +00002446 [(store (rotl (loadi8 addr:$dst), CL), addr:$dst)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00002447 def ROL16mCL : I<0xD3, MRM0m, (outs), (ins i16mem:$dst),
Eli Friedmanaace4b12009-06-19 04:48:38 +00002448 "rol{w}\t{%cl, $dst|$dst, CL}",
Evan Cheng071a2792007-09-11 19:55:27 +00002449 [(store (rotl (loadi16 addr:$dst), CL), addr:$dst)]>, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00002450 def ROL32mCL : I<0xD3, MRM0m, (outs), (ins i32mem:$dst),
Eli Friedmanaace4b12009-06-19 04:48:38 +00002451 "rol{l}\t{%cl, $dst|$dst, CL}",
Evan Cheng071a2792007-09-11 19:55:27 +00002452 [(store (rotl (loadi32 addr:$dst), CL), addr:$dst)]>;
2453 }
Evan Cheng64d80e32007-07-19 01:14:50 +00002454 def ROL8mi : Ii8<0xC0, MRM0m, (outs), (ins i8mem :$dst, i8imm:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002455 "rol{b}\t{$src, $dst|$dst, $src}",
Evan Chengeb422a72006-01-11 23:20:05 +00002456 [(store (rotl (loadi8 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00002457 def ROL16mi : Ii8<0xC1, MRM0m, (outs), (ins i16mem:$dst, i8imm:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002458 "rol{w}\t{$src, $dst|$dst, $src}",
Evan Chengeb422a72006-01-11 23:20:05 +00002459 [(store (rotl (loadi16 addr:$dst), (i8 imm:$src)), addr:$dst)]>,
2460 OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00002461 def ROL32mi : Ii8<0xC1, MRM0m, (outs), (ins i32mem:$dst, i8imm:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002462 "rol{l}\t{$src, $dst|$dst, $src}",
Evan Chengeb422a72006-01-11 23:20:05 +00002463 [(store (rotl (loadi32 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
Evan Cheng09c54572006-06-29 00:36:51 +00002464
2465 // Rotate by 1
Evan Cheng64d80e32007-07-19 01:14:50 +00002466 def ROL8m1 : I<0xD0, MRM0m, (outs), (ins i8mem :$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002467 "rol{b}\t$dst",
Evan Cheng09c54572006-06-29 00:36:51 +00002468 [(store (rotl (loadi8 addr:$dst), (i8 1)), addr:$dst)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00002469 def ROL16m1 : I<0xD1, MRM0m, (outs), (ins i16mem:$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002470 "rol{w}\t$dst",
Evan Cheng09c54572006-06-29 00:36:51 +00002471 [(store (rotl (loadi16 addr:$dst), (i8 1)), addr:$dst)]>,
2472 OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00002473 def ROL32m1 : I<0xD1, MRM0m, (outs), (ins i32mem:$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002474 "rol{l}\t$dst",
Evan Cheng09c54572006-06-29 00:36:51 +00002475 [(store (rotl (loadi32 addr:$dst), (i8 1)), addr:$dst)]>;
Chris Lattner40ff6332005-01-19 07:50:03 +00002476}
2477
Evan Cheng071a2792007-09-11 19:55:27 +00002478let Uses = [CL] in {
Evan Cheng64d80e32007-07-19 01:14:50 +00002479def ROR8rCL : I<0xD2, MRM1r, (outs GR8 :$dst), (ins GR8 :$src),
Eli Friedmanaace4b12009-06-19 04:48:38 +00002480 "ror{b}\t{%cl, $dst|$dst, CL}",
Evan Cheng071a2792007-09-11 19:55:27 +00002481 [(set GR8:$dst, (rotr GR8:$src, CL))]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00002482def ROR16rCL : I<0xD3, MRM1r, (outs GR16:$dst), (ins GR16:$src),
Eli Friedmanaace4b12009-06-19 04:48:38 +00002483 "ror{w}\t{%cl, $dst|$dst, CL}",
Evan Cheng071a2792007-09-11 19:55:27 +00002484 [(set GR16:$dst, (rotr GR16:$src, CL))]>, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00002485def ROR32rCL : I<0xD3, MRM1r, (outs GR32:$dst), (ins GR32:$src),
Eli Friedmanaace4b12009-06-19 04:48:38 +00002486 "ror{l}\t{%cl, $dst|$dst, CL}",
Evan Cheng071a2792007-09-11 19:55:27 +00002487 [(set GR32:$dst, (rotr GR32:$src, CL))]>;
2488}
Chris Lattner40ff6332005-01-19 07:50:03 +00002489
Evan Cheng64d80e32007-07-19 01:14:50 +00002490def ROR8ri : Ii8<0xC0, MRM1r, (outs GR8 :$dst), (ins GR8 :$src1, i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002491 "ror{b}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00002492 [(set GR8:$dst, (rotr GR8:$src1, (i8 imm:$src2)))]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00002493def ROR16ri : Ii8<0xC1, MRM1r, (outs GR16:$dst), (ins GR16:$src1, i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002494 "ror{w}\t{$src2, $dst|$dst, $src2}",
Sean Callanan108934c2009-12-18 00:01:26 +00002495 [(set GR16:$dst, (rotr GR16:$src1, (i8 imm:$src2)))]>,
2496 OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00002497def ROR32ri : Ii8<0xC1, MRM1r, (outs GR32:$dst), (ins GR32:$src1, i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002498 "ror{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00002499 [(set GR32:$dst, (rotr GR32:$src1, (i8 imm:$src2)))]>;
Evan Cheng09c54572006-06-29 00:36:51 +00002500
2501// Rotate by 1
Evan Cheng64d80e32007-07-19 01:14:50 +00002502def ROR8r1 : I<0xD0, MRM1r, (outs GR8 :$dst), (ins GR8 :$src1),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002503 "ror{b}\t$dst",
Evan Cheng09c54572006-06-29 00:36:51 +00002504 [(set GR8:$dst, (rotr GR8:$src1, (i8 1)))]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00002505def ROR16r1 : I<0xD1, MRM1r, (outs GR16:$dst), (ins GR16:$src1),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002506 "ror{w}\t$dst",
Evan Cheng09c54572006-06-29 00:36:51 +00002507 [(set GR16:$dst, (rotr GR16:$src1, (i8 1)))]>, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00002508def ROR32r1 : I<0xD1, MRM1r, (outs GR32:$dst), (ins GR32:$src1),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002509 "ror{l}\t$dst",
Evan Cheng09c54572006-06-29 00:36:51 +00002510 [(set GR32:$dst, (rotr GR32:$src1, (i8 1)))]>;
2511
Chris Lattner40ff6332005-01-19 07:50:03 +00002512let isTwoAddress = 0 in {
Evan Cheng071a2792007-09-11 19:55:27 +00002513 let Uses = [CL] in {
Evan Cheng64d80e32007-07-19 01:14:50 +00002514 def ROR8mCL : I<0xD2, MRM1m, (outs), (ins i8mem :$dst),
Eli Friedmanaace4b12009-06-19 04:48:38 +00002515 "ror{b}\t{%cl, $dst|$dst, CL}",
Evan Cheng071a2792007-09-11 19:55:27 +00002516 [(store (rotr (loadi8 addr:$dst), CL), addr:$dst)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00002517 def ROR16mCL : I<0xD3, MRM1m, (outs), (ins i16mem:$dst),
Eli Friedmanaace4b12009-06-19 04:48:38 +00002518 "ror{w}\t{%cl, $dst|$dst, CL}",
Evan Cheng071a2792007-09-11 19:55:27 +00002519 [(store (rotr (loadi16 addr:$dst), CL), addr:$dst)]>, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00002520 def ROR32mCL : I<0xD3, MRM1m, (outs), (ins i32mem:$dst),
Eli Friedmanaace4b12009-06-19 04:48:38 +00002521 "ror{l}\t{%cl, $dst|$dst, CL}",
Evan Cheng071a2792007-09-11 19:55:27 +00002522 [(store (rotr (loadi32 addr:$dst), CL), addr:$dst)]>;
2523 }
Evan Cheng64d80e32007-07-19 01:14:50 +00002524 def ROR8mi : Ii8<0xC0, MRM1m, (outs), (ins i8mem :$dst, i8imm:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002525 "ror{b}\t{$src, $dst|$dst, $src}",
Evan Chengeb422a72006-01-11 23:20:05 +00002526 [(store (rotr (loadi8 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00002527 def ROR16mi : Ii8<0xC1, MRM1m, (outs), (ins i16mem:$dst, i8imm:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002528 "ror{w}\t{$src, $dst|$dst, $src}",
Evan Chengeb422a72006-01-11 23:20:05 +00002529 [(store (rotr (loadi16 addr:$dst), (i8 imm:$src)), addr:$dst)]>,
2530 OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00002531 def ROR32mi : Ii8<0xC1, MRM1m, (outs), (ins i32mem:$dst, i8imm:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002532 "ror{l}\t{$src, $dst|$dst, $src}",
Evan Chengeb422a72006-01-11 23:20:05 +00002533 [(store (rotr (loadi32 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
Evan Cheng09c54572006-06-29 00:36:51 +00002534
2535 // Rotate by 1
Evan Cheng64d80e32007-07-19 01:14:50 +00002536 def ROR8m1 : I<0xD0, MRM1m, (outs), (ins i8mem :$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002537 "ror{b}\t$dst",
Evan Cheng09c54572006-06-29 00:36:51 +00002538 [(store (rotr (loadi8 addr:$dst), (i8 1)), addr:$dst)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00002539 def ROR16m1 : I<0xD1, MRM1m, (outs), (ins i16mem:$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002540 "ror{w}\t$dst",
Evan Cheng09c54572006-06-29 00:36:51 +00002541 [(store (rotr (loadi16 addr:$dst), (i8 1)), addr:$dst)]>,
2542 OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00002543 def ROR32m1 : I<0xD1, MRM1m, (outs), (ins i32mem:$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002544 "ror{l}\t$dst",
Evan Cheng09c54572006-06-29 00:36:51 +00002545 [(store (rotr (loadi32 addr:$dst), (i8 1)), addr:$dst)]>;
Chris Lattner40ff6332005-01-19 07:50:03 +00002546}
2547
2548
2549
2550// Double shift instructions (generalizations of rotate)
Evan Cheng071a2792007-09-11 19:55:27 +00002551let Uses = [CL] in {
Sean Callanan108934c2009-12-18 00:01:26 +00002552def SHLD32rrCL : I<0xA5, MRMDestReg, (outs GR32:$dst),
2553 (ins GR32:$src1, GR32:$src2),
Eli Friedmanaace4b12009-06-19 04:48:38 +00002554 "shld{l}\t{%cl, $src2, $dst|$dst, $src2, CL}",
Evan Cheng071a2792007-09-11 19:55:27 +00002555 [(set GR32:$dst, (X86shld GR32:$src1, GR32:$src2, CL))]>, TB;
Sean Callanan108934c2009-12-18 00:01:26 +00002556def SHRD32rrCL : I<0xAD, MRMDestReg, (outs GR32:$dst),
2557 (ins GR32:$src1, GR32:$src2),
Eli Friedmanaace4b12009-06-19 04:48:38 +00002558 "shrd{l}\t{%cl, $src2, $dst|$dst, $src2, CL}",
Evan Cheng071a2792007-09-11 19:55:27 +00002559 [(set GR32:$dst, (X86shrd GR32:$src1, GR32:$src2, CL))]>, TB;
Sean Callanan108934c2009-12-18 00:01:26 +00002560def SHLD16rrCL : I<0xA5, MRMDestReg, (outs GR16:$dst),
2561 (ins GR16:$src1, GR16:$src2),
Eli Friedmanaace4b12009-06-19 04:48:38 +00002562 "shld{w}\t{%cl, $src2, $dst|$dst, $src2, CL}",
Evan Cheng069287d2006-05-16 07:21:53 +00002563 [(set GR16:$dst, (X86shld GR16:$src1, GR16:$src2, CL))]>,
Evan Cheng071a2792007-09-11 19:55:27 +00002564 TB, OpSize;
Sean Callanan108934c2009-12-18 00:01:26 +00002565def SHRD16rrCL : I<0xAD, MRMDestReg, (outs GR16:$dst),
2566 (ins GR16:$src1, GR16:$src2),
Eli Friedmanaace4b12009-06-19 04:48:38 +00002567 "shrd{w}\t{%cl, $src2, $dst|$dst, $src2, CL}",
Evan Cheng069287d2006-05-16 07:21:53 +00002568 [(set GR16:$dst, (X86shrd GR16:$src1, GR16:$src2, CL))]>,
Evan Cheng071a2792007-09-11 19:55:27 +00002569 TB, OpSize;
2570}
Chris Lattner41e431b2005-01-19 07:11:01 +00002571
2572let isCommutable = 1 in { // These instructions commute to each other.
Chris Lattner3a173df2004-10-03 20:35:00 +00002573def SHLD32rri8 : Ii8<0xA4, MRMDestReg,
Sean Callanan108934c2009-12-18 00:01:26 +00002574 (outs GR32:$dst),
2575 (ins GR32:$src1, GR32:$src2, i8imm:$src3),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002576 "shld{l}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Evan Cheng069287d2006-05-16 07:21:53 +00002577 [(set GR32:$dst, (X86shld GR32:$src1, GR32:$src2,
Evan Chenge3413162006-01-09 18:33:28 +00002578 (i8 imm:$src3)))]>,
2579 TB;
Chris Lattner3a173df2004-10-03 20:35:00 +00002580def SHRD32rri8 : Ii8<0xAC, MRMDestReg,
Sean Callanan108934c2009-12-18 00:01:26 +00002581 (outs GR32:$dst),
2582 (ins GR32:$src1, GR32:$src2, i8imm:$src3),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002583 "shrd{l}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Evan Cheng069287d2006-05-16 07:21:53 +00002584 [(set GR32:$dst, (X86shrd GR32:$src1, GR32:$src2,
Evan Chenge3413162006-01-09 18:33:28 +00002585 (i8 imm:$src3)))]>,
2586 TB;
Chris Lattner0df53d22005-01-19 07:31:24 +00002587def SHLD16rri8 : Ii8<0xA4, MRMDestReg,
Sean Callanan108934c2009-12-18 00:01:26 +00002588 (outs GR16:$dst),
2589 (ins GR16:$src1, GR16:$src2, i8imm:$src3),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002590 "shld{w}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Evan Cheng069287d2006-05-16 07:21:53 +00002591 [(set GR16:$dst, (X86shld GR16:$src1, GR16:$src2,
Evan Chenge3413162006-01-09 18:33:28 +00002592 (i8 imm:$src3)))]>,
Chris Lattner0df53d22005-01-19 07:31:24 +00002593 TB, OpSize;
2594def SHRD16rri8 : Ii8<0xAC, MRMDestReg,
Sean Callanan108934c2009-12-18 00:01:26 +00002595 (outs GR16:$dst),
2596 (ins GR16:$src1, GR16:$src2, i8imm:$src3),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002597 "shrd{w}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Evan Cheng069287d2006-05-16 07:21:53 +00002598 [(set GR16:$dst, (X86shrd GR16:$src1, GR16:$src2,
Evan Chenge3413162006-01-09 18:33:28 +00002599 (i8 imm:$src3)))]>,
Chris Lattner0df53d22005-01-19 07:31:24 +00002600 TB, OpSize;
Chris Lattner41e431b2005-01-19 07:11:01 +00002601}
Chris Lattner0e967d42004-08-01 08:13:11 +00002602
Chris Lattner57a02302004-08-11 04:31:00 +00002603let isTwoAddress = 0 in {
Evan Cheng071a2792007-09-11 19:55:27 +00002604 let Uses = [CL] in {
Evan Cheng64d80e32007-07-19 01:14:50 +00002605 def SHLD32mrCL : I<0xA5, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
Eli Friedmanaace4b12009-06-19 04:48:38 +00002606 "shld{l}\t{%cl, $src2, $dst|$dst, $src2, CL}",
Evan Cheng069287d2006-05-16 07:21:53 +00002607 [(store (X86shld (loadi32 addr:$dst), GR32:$src2, CL),
Evan Cheng071a2792007-09-11 19:55:27 +00002608 addr:$dst)]>, TB;
Evan Cheng64d80e32007-07-19 01:14:50 +00002609 def SHRD32mrCL : I<0xAD, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
Eli Friedmanaace4b12009-06-19 04:48:38 +00002610 "shrd{l}\t{%cl, $src2, $dst|$dst, $src2, CL}",
Evan Cheng069287d2006-05-16 07:21:53 +00002611 [(store (X86shrd (loadi32 addr:$dst), GR32:$src2, CL),
Evan Cheng071a2792007-09-11 19:55:27 +00002612 addr:$dst)]>, TB;
2613 }
Chris Lattner3a173df2004-10-03 20:35:00 +00002614 def SHLD32mri8 : Ii8<0xA4, MRMDestMem,
Evan Cheng64d80e32007-07-19 01:14:50 +00002615 (outs), (ins i32mem:$dst, GR32:$src2, i8imm:$src3),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002616 "shld{l}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Evan Cheng069287d2006-05-16 07:21:53 +00002617 [(store (X86shld (loadi32 addr:$dst), GR32:$src2,
Evan Chenge3413162006-01-09 18:33:28 +00002618 (i8 imm:$src3)), addr:$dst)]>,
Chris Lattnerf124d5e2005-11-18 01:04:42 +00002619 TB;
Chris Lattner3a173df2004-10-03 20:35:00 +00002620 def SHRD32mri8 : Ii8<0xAC, MRMDestMem,
Evan Cheng64d80e32007-07-19 01:14:50 +00002621 (outs), (ins i32mem:$dst, GR32:$src2, i8imm:$src3),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002622 "shrd{l}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Evan Cheng069287d2006-05-16 07:21:53 +00002623 [(store (X86shrd (loadi32 addr:$dst), GR32:$src2,
Evan Chenge3413162006-01-09 18:33:28 +00002624 (i8 imm:$src3)), addr:$dst)]>,
Chris Lattnerf124d5e2005-11-18 01:04:42 +00002625 TB;
Chris Lattner0df53d22005-01-19 07:31:24 +00002626
Evan Cheng071a2792007-09-11 19:55:27 +00002627 let Uses = [CL] in {
Evan Cheng64d80e32007-07-19 01:14:50 +00002628 def SHLD16mrCL : I<0xA5, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
Eli Friedmanaace4b12009-06-19 04:48:38 +00002629 "shld{w}\t{%cl, $src2, $dst|$dst, $src2, CL}",
Evan Cheng069287d2006-05-16 07:21:53 +00002630 [(store (X86shld (loadi16 addr:$dst), GR16:$src2, CL),
Evan Cheng071a2792007-09-11 19:55:27 +00002631 addr:$dst)]>, TB, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00002632 def SHRD16mrCL : I<0xAD, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
Eli Friedmanaace4b12009-06-19 04:48:38 +00002633 "shrd{w}\t{%cl, $src2, $dst|$dst, $src2, CL}",
Evan Cheng069287d2006-05-16 07:21:53 +00002634 [(store (X86shrd (loadi16 addr:$dst), GR16:$src2, CL),
Evan Cheng071a2792007-09-11 19:55:27 +00002635 addr:$dst)]>, TB, OpSize;
2636 }
Chris Lattner0df53d22005-01-19 07:31:24 +00002637 def SHLD16mri8 : Ii8<0xA4, MRMDestMem,
Evan Cheng64d80e32007-07-19 01:14:50 +00002638 (outs), (ins i16mem:$dst, GR16:$src2, i8imm:$src3),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002639 "shld{w}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Evan Cheng069287d2006-05-16 07:21:53 +00002640 [(store (X86shld (loadi16 addr:$dst), GR16:$src2,
Evan Chenge3413162006-01-09 18:33:28 +00002641 (i8 imm:$src3)), addr:$dst)]>,
Chris Lattner0df53d22005-01-19 07:31:24 +00002642 TB, OpSize;
2643 def SHRD16mri8 : Ii8<0xAC, MRMDestMem,
Evan Cheng64d80e32007-07-19 01:14:50 +00002644 (outs), (ins i16mem:$dst, GR16:$src2, i8imm:$src3),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002645 "shrd{w}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Evan Cheng069287d2006-05-16 07:21:53 +00002646 [(store (X86shrd (loadi16 addr:$dst), GR16:$src2,
Evan Chenge3413162006-01-09 18:33:28 +00002647 (i8 imm:$src3)), addr:$dst)]>,
Chris Lattner0df53d22005-01-19 07:31:24 +00002648 TB, OpSize;
Chris Lattner57a02302004-08-11 04:31:00 +00002649}
Evan Cheng24f2ea32007-09-14 21:48:26 +00002650} // Defs = [EFLAGS]
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00002651
2652
Chris Lattnercc65bee2005-01-02 02:35:46 +00002653// Arithmetic.
Evan Cheng24f2ea32007-09-14 21:48:26 +00002654let Defs = [EFLAGS] in {
Chris Lattnercc65bee2005-01-02 02:35:46 +00002655let isCommutable = 1 in { // X = ADD Y, Z --> X = ADD Z, Y
Bill Wendlingab55ebd2008-12-12 00:56:36 +00002656// Register-Register Addition
2657def ADD8rr : I<0x00, MRMDestReg, (outs GR8 :$dst),
2658 (ins GR8 :$src1, GR8 :$src2),
2659 "add{b}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingd350e022008-12-12 21:15:41 +00002660 [(set GR8:$dst, (add GR8:$src1, GR8:$src2)),
Bill Wendlingab55ebd2008-12-12 00:56:36 +00002661 (implicit EFLAGS)]>;
2662
Chris Lattnercc65bee2005-01-02 02:35:46 +00002663let isConvertibleToThreeAddress = 1 in { // Can transform into LEA.
Bill Wendlingab55ebd2008-12-12 00:56:36 +00002664// Register-Register Addition
Evan Cheng071a2792007-09-11 19:55:27 +00002665def ADD16rr : I<0x01, MRMDestReg, (outs GR16:$dst),
2666 (ins GR16:$src1, GR16:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002667 "add{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingd350e022008-12-12 21:15:41 +00002668 [(set GR16:$dst, (add GR16:$src1, GR16:$src2)),
2669 (implicit EFLAGS)]>, OpSize;
Evan Cheng071a2792007-09-11 19:55:27 +00002670def ADD32rr : I<0x01, MRMDestReg, (outs GR32:$dst),
2671 (ins GR32:$src1, GR32:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002672 "add{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingd350e022008-12-12 21:15:41 +00002673 [(set GR32:$dst, (add GR32:$src1, GR32:$src2)),
2674 (implicit EFLAGS)]>;
Chris Lattnercc65bee2005-01-02 02:35:46 +00002675} // end isConvertibleToThreeAddress
2676} // end isCommutable
Bill Wendlingab55ebd2008-12-12 00:56:36 +00002677
Daniel Dunbarf291be32010-03-09 22:50:46 +00002678// These are alternate spellings for use by the disassembler, we mark them as
2679// code gen only to ensure they aren't matched by the assembler.
2680let isCodeGenOnly = 1 in {
2681 def ADD8rr_alt: I<0x02, MRMSrcReg, (outs GR8:$dst), (ins GR8:$src1, GR8:$src2),
2682 "add{b}\t{$src2, $dst|$dst, $src2}", []>;
2683 def ADD16rr_alt: I<0x03, MRMSrcReg,(outs GR16:$dst),(ins GR16:$src1, GR16:$src2),
2684 "add{w}\t{$src2, $dst|$dst, $src2}", []>, OpSize;
2685 def ADD32rr_alt: I<0x03, MRMSrcReg,(outs GR16:$dst),(ins GR16:$src1, GR16:$src2),
2686 "add{l}\t{$src2, $dst|$dst, $src2}", []>;
2687}
2688
Bill Wendlingab55ebd2008-12-12 00:56:36 +00002689// Register-Memory Addition
Evan Cheng071a2792007-09-11 19:55:27 +00002690def ADD8rm : I<0x02, MRMSrcMem, (outs GR8 :$dst),
2691 (ins GR8 :$src1, i8mem :$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002692 "add{b}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingd350e022008-12-12 21:15:41 +00002693 [(set GR8:$dst, (add GR8:$src1, (load addr:$src2))),
2694 (implicit EFLAGS)]>;
Evan Cheng071a2792007-09-11 19:55:27 +00002695def ADD16rm : I<0x03, MRMSrcMem, (outs GR16:$dst),
2696 (ins GR16:$src1, i16mem:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002697 "add{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingd350e022008-12-12 21:15:41 +00002698 [(set GR16:$dst, (add GR16:$src1, (load addr:$src2))),
2699 (implicit EFLAGS)]>, OpSize;
Evan Cheng071a2792007-09-11 19:55:27 +00002700def ADD32rm : I<0x03, MRMSrcMem, (outs GR32:$dst),
2701 (ins GR32:$src1, i32mem:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002702 "add{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingd350e022008-12-12 21:15:41 +00002703 [(set GR32:$dst, (add GR32:$src1, (load addr:$src2))),
2704 (implicit EFLAGS)]>;
Sean Callanan37be5902009-09-15 20:53:57 +00002705
Bill Wendlingab55ebd2008-12-12 00:56:36 +00002706// Register-Integer Addition
2707def ADD8ri : Ii8<0x80, MRM0r, (outs GR8:$dst), (ins GR8:$src1, i8imm:$src2),
2708 "add{b}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingd350e022008-12-12 21:15:41 +00002709 [(set GR8:$dst, (add GR8:$src1, imm:$src2)),
2710 (implicit EFLAGS)]>;
Bill Wendlingab55ebd2008-12-12 00:56:36 +00002711
Chris Lattnercc65bee2005-01-02 02:35:46 +00002712let isConvertibleToThreeAddress = 1 in { // Can transform into LEA.
Bill Wendlingab55ebd2008-12-12 00:56:36 +00002713// Register-Integer Addition
Evan Cheng071a2792007-09-11 19:55:27 +00002714def ADD16ri : Ii16<0x81, MRM0r, (outs GR16:$dst),
2715 (ins GR16:$src1, i16imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002716 "add{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingd350e022008-12-12 21:15:41 +00002717 [(set GR16:$dst, (add GR16:$src1, imm:$src2)),
2718 (implicit EFLAGS)]>, OpSize;
Evan Cheng071a2792007-09-11 19:55:27 +00002719def ADD32ri : Ii32<0x81, MRM0r, (outs GR32:$dst),
2720 (ins GR32:$src1, i32imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002721 "add{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingd350e022008-12-12 21:15:41 +00002722 [(set GR32:$dst, (add GR32:$src1, imm:$src2)),
2723 (implicit EFLAGS)]>;
Evan Cheng071a2792007-09-11 19:55:27 +00002724def ADD16ri8 : Ii8<0x83, MRM0r, (outs GR16:$dst),
2725 (ins GR16:$src1, i16i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002726 "add{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingd350e022008-12-12 21:15:41 +00002727 [(set GR16:$dst, (add GR16:$src1, i16immSExt8:$src2)),
2728 (implicit EFLAGS)]>, OpSize;
Evan Cheng071a2792007-09-11 19:55:27 +00002729def ADD32ri8 : Ii8<0x83, MRM0r, (outs GR32:$dst),
2730 (ins GR32:$src1, i32i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002731 "add{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingd350e022008-12-12 21:15:41 +00002732 [(set GR32:$dst, (add GR32:$src1, i32immSExt8:$src2)),
2733 (implicit EFLAGS)]>;
Evan Cheng09e3c802006-05-19 18:40:54 +00002734}
Chris Lattner57a02302004-08-11 04:31:00 +00002735
2736let isTwoAddress = 0 in {
Bill Wendlingab55ebd2008-12-12 00:56:36 +00002737 // Memory-Register Addition
Bill Wendlingd350e022008-12-12 21:15:41 +00002738 def ADD8mr : I<0x00, MRMDestMem, (outs), (ins i8mem:$dst, GR8:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002739 "add{b}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingd350e022008-12-12 21:15:41 +00002740 [(store (add (load addr:$dst), GR8:$src2), addr:$dst),
2741 (implicit EFLAGS)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00002742 def ADD16mr : I<0x01, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002743 "add{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingd350e022008-12-12 21:15:41 +00002744 [(store (add (load addr:$dst), GR16:$src2), addr:$dst),
2745 (implicit EFLAGS)]>, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00002746 def ADD32mr : I<0x01, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002747 "add{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingd350e022008-12-12 21:15:41 +00002748 [(store (add (load addr:$dst), GR32:$src2), addr:$dst),
2749 (implicit EFLAGS)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00002750 def ADD8mi : Ii8<0x80, MRM0m, (outs), (ins i8mem :$dst, i8imm :$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002751 "add{b}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingd350e022008-12-12 21:15:41 +00002752 [(store (add (loadi8 addr:$dst), imm:$src2), addr:$dst),
2753 (implicit EFLAGS)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00002754 def ADD16mi : Ii16<0x81, MRM0m, (outs), (ins i16mem:$dst, i16imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002755 "add{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingd350e022008-12-12 21:15:41 +00002756 [(store (add (loadi16 addr:$dst), imm:$src2), addr:$dst),
2757 (implicit EFLAGS)]>, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00002758 def ADD32mi : Ii32<0x81, MRM0m, (outs), (ins i32mem:$dst, i32imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002759 "add{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingd350e022008-12-12 21:15:41 +00002760 [(store (add (loadi32 addr:$dst), imm:$src2), addr:$dst),
2761 (implicit EFLAGS)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00002762 def ADD16mi8 : Ii8<0x83, MRM0m, (outs), (ins i16mem:$dst, i16i8imm :$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002763 "add{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingd350e022008-12-12 21:15:41 +00002764 [(store (add (load addr:$dst), i16immSExt8:$src2),
2765 addr:$dst),
2766 (implicit EFLAGS)]>, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00002767 def ADD32mi8 : Ii8<0x83, MRM0m, (outs), (ins i32mem:$dst, i32i8imm :$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002768 "add{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingab55ebd2008-12-12 00:56:36 +00002769 [(store (add (load addr:$dst), i32immSExt8:$src2),
Bill Wendlingd350e022008-12-12 21:15:41 +00002770 addr:$dst),
2771 (implicit EFLAGS)]>;
Sean Callananb08ae6b2009-08-11 21:26:06 +00002772
2773 // addition to rAX
2774 def ADD8i8 : Ii8<0x04, RawFrm, (outs), (ins i8imm:$src),
Sean Callanana09caa52009-09-02 00:55:49 +00002775 "add{b}\t{$src, %al|%al, $src}", []>;
Sean Callananb08ae6b2009-08-11 21:26:06 +00002776 def ADD16i16 : Ii16<0x05, RawFrm, (outs), (ins i16imm:$src),
Sean Callanana09caa52009-09-02 00:55:49 +00002777 "add{w}\t{$src, %ax|%ax, $src}", []>, OpSize;
Sean Callananb08ae6b2009-08-11 21:26:06 +00002778 def ADD32i32 : Ii32<0x05, RawFrm, (outs), (ins i32imm:$src),
Sean Callanana09caa52009-09-02 00:55:49 +00002779 "add{l}\t{$src, %eax|%eax, $src}", []>;
Chris Lattner57a02302004-08-11 04:31:00 +00002780}
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00002781
Evan Cheng3154cb62007-10-05 17:59:57 +00002782let Uses = [EFLAGS] in {
Chris Lattner10197ff2005-01-03 01:27:59 +00002783let isCommutable = 1 in { // X = ADC Y, Z --> X = ADC Z, Y
Dale Johannesen874ae252009-06-02 03:12:52 +00002784def ADC8rr : I<0x10, MRMDestReg, (outs GR8:$dst), (ins GR8:$src1, GR8:$src2),
Dale Johannesenca11dae2009-05-18 17:44:15 +00002785 "adc{b}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen874ae252009-06-02 03:12:52 +00002786 [(set GR8:$dst, (adde GR8:$src1, GR8:$src2))]>;
Dale Johannesenca11dae2009-05-18 17:44:15 +00002787def ADC16rr : I<0x11, MRMDestReg, (outs GR16:$dst),
2788 (ins GR16:$src1, GR16:$src2),
2789 "adc{w}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen874ae252009-06-02 03:12:52 +00002790 [(set GR16:$dst, (adde GR16:$src1, GR16:$src2))]>, OpSize;
Dale Johannesenca11dae2009-05-18 17:44:15 +00002791def ADC32rr : I<0x11, MRMDestReg, (outs GR32:$dst),
2792 (ins GR32:$src1, GR32:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002793 "adc{l}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen874ae252009-06-02 03:12:52 +00002794 [(set GR32:$dst, (adde GR32:$src1, GR32:$src2))]>;
Chris Lattner10197ff2005-01-03 01:27:59 +00002795}
Sean Callanan108934c2009-12-18 00:01:26 +00002796
2797def ADC8rr_REV : I<0x12, MRMSrcReg, (outs GR8:$dst), (ins GR8:$src1, GR8:$src2),
2798 "adc{b}\t{$src2, $dst|$dst, $src2}", []>;
2799def ADC16rr_REV : I<0x13, MRMSrcReg, (outs GR16:$dst),
2800 (ins GR16:$src1, GR16:$src2),
2801 "adc{w}\t{$src2, $dst|$dst, $src2}", []>, OpSize;
2802def ADC32rr_REV : I<0x13, MRMSrcReg, (outs GR32:$dst),
2803 (ins GR32:$src1, GR32:$src2),
2804 "adc{l}\t{$src2, $dst|$dst, $src2}", []>;
2805
Dale Johannesenca11dae2009-05-18 17:44:15 +00002806def ADC8rm : I<0x12, MRMSrcMem , (outs GR8:$dst),
2807 (ins GR8:$src1, i8mem:$src2),
2808 "adc{b}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen874ae252009-06-02 03:12:52 +00002809 [(set GR8:$dst, (adde GR8:$src1, (load addr:$src2)))]>;
Dale Johannesenca11dae2009-05-18 17:44:15 +00002810def ADC16rm : I<0x13, MRMSrcMem , (outs GR16:$dst),
2811 (ins GR16:$src1, i16mem:$src2),
2812 "adc{w}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen874ae252009-06-02 03:12:52 +00002813 [(set GR16:$dst, (adde GR16:$src1, (load addr:$src2)))]>,
Dale Johannesen94c9cd12009-05-18 21:41:59 +00002814 OpSize;
Dale Johannesenca11dae2009-05-18 17:44:15 +00002815def ADC32rm : I<0x13, MRMSrcMem , (outs GR32:$dst),
2816 (ins GR32:$src1, i32mem:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002817 "adc{l}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen874ae252009-06-02 03:12:52 +00002818 [(set GR32:$dst, (adde GR32:$src1, (load addr:$src2)))]>;
2819def ADC8ri : Ii8<0x80, MRM2r, (outs GR8:$dst), (ins GR8:$src1, i8imm:$src2),
Dale Johannesenca11dae2009-05-18 17:44:15 +00002820 "adc{b}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen874ae252009-06-02 03:12:52 +00002821 [(set GR8:$dst, (adde GR8:$src1, imm:$src2))]>;
Dale Johannesenca11dae2009-05-18 17:44:15 +00002822def ADC16ri : Ii16<0x81, MRM2r, (outs GR16:$dst),
2823 (ins GR16:$src1, i16imm:$src2),
2824 "adc{w}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen874ae252009-06-02 03:12:52 +00002825 [(set GR16:$dst, (adde GR16:$src1, imm:$src2))]>, OpSize;
Dale Johannesenca11dae2009-05-18 17:44:15 +00002826def ADC16ri8 : Ii8<0x83, MRM2r, (outs GR16:$dst),
2827 (ins GR16:$src1, i16i8imm:$src2),
2828 "adc{w}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen874ae252009-06-02 03:12:52 +00002829 [(set GR16:$dst, (adde GR16:$src1, i16immSExt8:$src2))]>,
2830 OpSize;
Dale Johannesenca11dae2009-05-18 17:44:15 +00002831def ADC32ri : Ii32<0x81, MRM2r, (outs GR32:$dst),
2832 (ins GR32:$src1, i32imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002833 "adc{l}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen874ae252009-06-02 03:12:52 +00002834 [(set GR32:$dst, (adde GR32:$src1, imm:$src2))]>;
Dale Johannesenca11dae2009-05-18 17:44:15 +00002835def ADC32ri8 : Ii8<0x83, MRM2r, (outs GR32:$dst),
2836 (ins GR32:$src1, i32i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002837 "adc{l}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen874ae252009-06-02 03:12:52 +00002838 [(set GR32:$dst, (adde GR32:$src1, i32immSExt8:$src2))]>;
Chris Lattner57a02302004-08-11 04:31:00 +00002839
2840let isTwoAddress = 0 in {
Dale Johannesen874ae252009-06-02 03:12:52 +00002841 def ADC8mr : I<0x10, MRMDestMem, (outs), (ins i8mem:$dst, GR8:$src2),
Dale Johannesenca11dae2009-05-18 17:44:15 +00002842 "adc{b}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen874ae252009-06-02 03:12:52 +00002843 [(store (adde (load addr:$dst), GR8:$src2), addr:$dst)]>;
2844 def ADC16mr : I<0x11, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
Dale Johannesenca11dae2009-05-18 17:44:15 +00002845 "adc{w}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen874ae252009-06-02 03:12:52 +00002846 [(store (adde (load addr:$dst), GR16:$src2), addr:$dst)]>,
2847 OpSize;
2848 def ADC32mr : I<0x11, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002849 "adc{l}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen874ae252009-06-02 03:12:52 +00002850 [(store (adde (load addr:$dst), GR32:$src2), addr:$dst)]>;
2851 def ADC8mi : Ii8<0x80, MRM2m, (outs), (ins i8mem:$dst, i8imm:$src2),
Dale Johannesenca11dae2009-05-18 17:44:15 +00002852 "adc{b}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen874ae252009-06-02 03:12:52 +00002853 [(store (adde (loadi8 addr:$dst), imm:$src2), addr:$dst)]>;
2854 def ADC16mi : Ii16<0x81, MRM2m, (outs), (ins i16mem:$dst, i16imm:$src2),
Dale Johannesenca11dae2009-05-18 17:44:15 +00002855 "adc{w}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen874ae252009-06-02 03:12:52 +00002856 [(store (adde (loadi16 addr:$dst), imm:$src2), addr:$dst)]>,
2857 OpSize;
2858 def ADC16mi8 : Ii8<0x83, MRM2m, (outs), (ins i16mem:$dst, i16i8imm :$src2),
Dale Johannesenca11dae2009-05-18 17:44:15 +00002859 "adc{w}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen874ae252009-06-02 03:12:52 +00002860 [(store (adde (load addr:$dst), i16immSExt8:$src2), addr:$dst)]>,
2861 OpSize;
2862 def ADC32mi : Ii32<0x81, MRM2m, (outs), (ins i32mem:$dst, i32imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002863 "adc{l}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen874ae252009-06-02 03:12:52 +00002864 [(store (adde (loadi32 addr:$dst), imm:$src2), addr:$dst)]>;
2865 def ADC32mi8 : Ii8<0x83, MRM2m, (outs), (ins i32mem:$dst, i32i8imm :$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002866 "adc{l}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen874ae252009-06-02 03:12:52 +00002867 [(store (adde (load addr:$dst), i32immSExt8:$src2), addr:$dst)]>;
Sean Callanand00025a2009-09-11 19:01:56 +00002868
2869 def ADC8i8 : Ii8<0x14, RawFrm, (outs), (ins i8imm:$src),
2870 "adc{b}\t{$src, %al|%al, $src}", []>;
2871 def ADC16i16 : Ii16<0x15, RawFrm, (outs), (ins i16imm:$src),
2872 "adc{w}\t{$src, %ax|%ax, $src}", []>, OpSize;
2873 def ADC32i32 : Ii32<0x15, RawFrm, (outs), (ins i32imm:$src),
2874 "adc{l}\t{$src, %eax|%eax, $src}", []>;
Dale Johannesen874ae252009-06-02 03:12:52 +00002875}
Evan Cheng3154cb62007-10-05 17:59:57 +00002876} // Uses = [EFLAGS]
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00002877
Bill Wendlingab55ebd2008-12-12 00:56:36 +00002878// Register-Register Subtraction
2879def SUB8rr : I<0x28, MRMDestReg, (outs GR8:$dst), (ins GR8:$src1, GR8:$src2),
2880 "sub{b}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingd350e022008-12-12 21:15:41 +00002881 [(set GR8:$dst, (sub GR8:$src1, GR8:$src2)),
2882 (implicit EFLAGS)]>;
Bill Wendlingab55ebd2008-12-12 00:56:36 +00002883def SUB16rr : I<0x29, MRMDestReg, (outs GR16:$dst), (ins GR16:$src1,GR16:$src2),
2884 "sub{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingd350e022008-12-12 21:15:41 +00002885 [(set GR16:$dst, (sub GR16:$src1, GR16:$src2)),
2886 (implicit EFLAGS)]>, OpSize;
Bill Wendlingab55ebd2008-12-12 00:56:36 +00002887def SUB32rr : I<0x29, MRMDestReg, (outs GR32:$dst), (ins GR32:$src1,GR32:$src2),
2888 "sub{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingd350e022008-12-12 21:15:41 +00002889 [(set GR32:$dst, (sub GR32:$src1, GR32:$src2)),
2890 (implicit EFLAGS)]>;
Bill Wendlingab55ebd2008-12-12 00:56:36 +00002891
Sean Callanan108934c2009-12-18 00:01:26 +00002892def SUB8rr_REV : I<0x2A, MRMSrcReg, (outs GR8:$dst), (ins GR8:$src1, GR8:$src2),
2893 "sub{b}\t{$src2, $dst|$dst, $src2}", []>;
2894def SUB16rr_REV : I<0x2B, MRMSrcReg, (outs GR16:$dst),
2895 (ins GR16:$src1, GR16:$src2),
2896 "sub{w}\t{$src2, $dst|$dst, $src2}", []>, OpSize;
2897def SUB32rr_REV : I<0x2B, MRMSrcReg, (outs GR32:$dst),
2898 (ins GR32:$src1, GR32:$src2),
2899 "sub{l}\t{$src2, $dst|$dst, $src2}", []>;
2900
Bill Wendlingab55ebd2008-12-12 00:56:36 +00002901// Register-Memory Subtraction
2902def SUB8rm : I<0x2A, MRMSrcMem, (outs GR8 :$dst),
2903 (ins GR8 :$src1, i8mem :$src2),
2904 "sub{b}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingd350e022008-12-12 21:15:41 +00002905 [(set GR8:$dst, (sub GR8:$src1, (load addr:$src2))),
2906 (implicit EFLAGS)]>;
Bill Wendlingab55ebd2008-12-12 00:56:36 +00002907def SUB16rm : I<0x2B, MRMSrcMem, (outs GR16:$dst),
2908 (ins GR16:$src1, i16mem:$src2),
2909 "sub{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingd350e022008-12-12 21:15:41 +00002910 [(set GR16:$dst, (sub GR16:$src1, (load addr:$src2))),
2911 (implicit EFLAGS)]>, OpSize;
Bill Wendlingab55ebd2008-12-12 00:56:36 +00002912def SUB32rm : I<0x2B, MRMSrcMem, (outs GR32:$dst),
2913 (ins GR32:$src1, i32mem:$src2),
2914 "sub{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingd350e022008-12-12 21:15:41 +00002915 [(set GR32:$dst, (sub GR32:$src1, (load addr:$src2))),
2916 (implicit EFLAGS)]>;
Bill Wendlingab55ebd2008-12-12 00:56:36 +00002917
2918// Register-Integer Subtraction
2919def SUB8ri : Ii8 <0x80, MRM5r, (outs GR8:$dst),
2920 (ins GR8:$src1, i8imm:$src2),
2921 "sub{b}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingd350e022008-12-12 21:15:41 +00002922 [(set GR8:$dst, (sub GR8:$src1, imm:$src2)),
2923 (implicit EFLAGS)]>;
Bill Wendlingab55ebd2008-12-12 00:56:36 +00002924def SUB16ri : Ii16<0x81, MRM5r, (outs GR16:$dst),
2925 (ins GR16:$src1, i16imm:$src2),
2926 "sub{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingd350e022008-12-12 21:15:41 +00002927 [(set GR16:$dst, (sub GR16:$src1, imm:$src2)),
2928 (implicit EFLAGS)]>, OpSize;
Bill Wendlingab55ebd2008-12-12 00:56:36 +00002929def SUB32ri : Ii32<0x81, MRM5r, (outs GR32:$dst),
2930 (ins GR32:$src1, i32imm:$src2),
2931 "sub{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingd350e022008-12-12 21:15:41 +00002932 [(set GR32:$dst, (sub GR32:$src1, imm:$src2)),
2933 (implicit EFLAGS)]>;
Bill Wendlingab55ebd2008-12-12 00:56:36 +00002934def SUB16ri8 : Ii8<0x83, MRM5r, (outs GR16:$dst),
2935 (ins GR16:$src1, i16i8imm:$src2),
2936 "sub{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingd350e022008-12-12 21:15:41 +00002937 [(set GR16:$dst, (sub GR16:$src1, i16immSExt8:$src2)),
2938 (implicit EFLAGS)]>, OpSize;
Bill Wendlingab55ebd2008-12-12 00:56:36 +00002939def SUB32ri8 : Ii8<0x83, MRM5r, (outs GR32:$dst),
2940 (ins GR32:$src1, i32i8imm:$src2),
2941 "sub{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingd350e022008-12-12 21:15:41 +00002942 [(set GR32:$dst, (sub GR32:$src1, i32immSExt8:$src2)),
2943 (implicit EFLAGS)]>;
Bill Wendlingab55ebd2008-12-12 00:56:36 +00002944
Chris Lattner57a02302004-08-11 04:31:00 +00002945let isTwoAddress = 0 in {
Bill Wendlingab55ebd2008-12-12 00:56:36 +00002946 // Memory-Register Subtraction
Evan Cheng64d80e32007-07-19 01:14:50 +00002947 def SUB8mr : I<0x28, MRMDestMem, (outs), (ins i8mem :$dst, GR8 :$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002948 "sub{b}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingd350e022008-12-12 21:15:41 +00002949 [(store (sub (load addr:$dst), GR8:$src2), addr:$dst),
2950 (implicit EFLAGS)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00002951 def SUB16mr : I<0x29, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002952 "sub{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingd350e022008-12-12 21:15:41 +00002953 [(store (sub (load addr:$dst), GR16:$src2), addr:$dst),
2954 (implicit EFLAGS)]>, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00002955 def SUB32mr : I<0x29, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002956 "sub{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingd350e022008-12-12 21:15:41 +00002957 [(store (sub (load addr:$dst), GR32:$src2), addr:$dst),
2958 (implicit EFLAGS)]>;
Bill Wendlingab55ebd2008-12-12 00:56:36 +00002959
2960 // Memory-Integer Subtraction
Evan Cheng64d80e32007-07-19 01:14:50 +00002961 def SUB8mi : Ii8<0x80, MRM5m, (outs), (ins i8mem :$dst, i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002962 "sub{b}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingd350e022008-12-12 21:15:41 +00002963 [(store (sub (loadi8 addr:$dst), imm:$src2), addr:$dst),
2964 (implicit EFLAGS)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00002965 def SUB16mi : Ii16<0x81, MRM5m, (outs), (ins i16mem:$dst, i16imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002966 "sub{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingd350e022008-12-12 21:15:41 +00002967 [(store (sub (loadi16 addr:$dst), imm:$src2),addr:$dst),
2968 (implicit EFLAGS)]>, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00002969 def SUB32mi : Ii32<0x81, MRM5m, (outs), (ins i32mem:$dst, i32imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002970 "sub{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingd350e022008-12-12 21:15:41 +00002971 [(store (sub (loadi32 addr:$dst), imm:$src2),addr:$dst),
2972 (implicit EFLAGS)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00002973 def SUB16mi8 : Ii8<0x83, MRM5m, (outs), (ins i16mem:$dst, i16i8imm :$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002974 "sub{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingab55ebd2008-12-12 00:56:36 +00002975 [(store (sub (load addr:$dst), i16immSExt8:$src2),
Bill Wendlingd350e022008-12-12 21:15:41 +00002976 addr:$dst),
2977 (implicit EFLAGS)]>, OpSize;
Bill Wendlingab55ebd2008-12-12 00:56:36 +00002978 def SUB32mi8 : Ii8<0x83, MRM5m, (outs), (ins i32mem:$dst, i32i8imm :$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002979 "sub{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingab55ebd2008-12-12 00:56:36 +00002980 [(store (sub (load addr:$dst), i32immSExt8:$src2),
Bill Wendlingd350e022008-12-12 21:15:41 +00002981 addr:$dst),
2982 (implicit EFLAGS)]>;
Sean Callanand00025a2009-09-11 19:01:56 +00002983
2984 def SUB8i8 : Ii8<0x2C, RawFrm, (outs), (ins i8imm:$src),
2985 "sub{b}\t{$src, %al|%al, $src}", []>;
2986 def SUB16i16 : Ii16<0x2D, RawFrm, (outs), (ins i16imm:$src),
2987 "sub{w}\t{$src, %ax|%ax, $src}", []>, OpSize;
2988 def SUB32i32 : Ii32<0x2D, RawFrm, (outs), (ins i32imm:$src),
2989 "sub{l}\t{$src, %eax|%eax, $src}", []>;
Chris Lattner57a02302004-08-11 04:31:00 +00002990}
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00002991
Evan Cheng3154cb62007-10-05 17:59:57 +00002992let Uses = [EFLAGS] in {
Dale Johannesenca11dae2009-05-18 17:44:15 +00002993def SBB8rr : I<0x18, MRMDestReg, (outs GR8:$dst),
2994 (ins GR8:$src1, GR8:$src2),
2995 "sbb{b}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen874ae252009-06-02 03:12:52 +00002996 [(set GR8:$dst, (sube GR8:$src1, GR8:$src2))]>;
Dale Johannesenca11dae2009-05-18 17:44:15 +00002997def SBB16rr : I<0x19, MRMDestReg, (outs GR16:$dst),
2998 (ins GR16:$src1, GR16:$src2),
2999 "sbb{w}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen874ae252009-06-02 03:12:52 +00003000 [(set GR16:$dst, (sube GR16:$src1, GR16:$src2))]>, OpSize;
Dale Johannesenca11dae2009-05-18 17:44:15 +00003001def SBB32rr : I<0x19, MRMDestReg, (outs GR32:$dst),
3002 (ins GR32:$src1, GR32:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003003 "sbb{l}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen874ae252009-06-02 03:12:52 +00003004 [(set GR32:$dst, (sube GR32:$src1, GR32:$src2))]>;
Chris Lattnerd93d3b02004-10-06 04:01:02 +00003005
Chris Lattner57a02302004-08-11 04:31:00 +00003006let isTwoAddress = 0 in {
Dale Johannesenca11dae2009-05-18 17:44:15 +00003007 def SBB8mr : I<0x18, MRMDestMem, (outs), (ins i8mem:$dst, GR8:$src2),
3008 "sbb{b}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen874ae252009-06-02 03:12:52 +00003009 [(store (sube (load addr:$dst), GR8:$src2), addr:$dst)]>;
Dale Johannesenca11dae2009-05-18 17:44:15 +00003010 def SBB16mr : I<0x19, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
3011 "sbb{w}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen874ae252009-06-02 03:12:52 +00003012 [(store (sube (load addr:$dst), GR16:$src2), addr:$dst)]>,
Dale Johannesen94c9cd12009-05-18 21:41:59 +00003013 OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00003014 def SBB32mr : I<0x19, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003015 "sbb{l}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen874ae252009-06-02 03:12:52 +00003016 [(store (sube (load addr:$dst), GR32:$src2), addr:$dst)]>;
Chris Lattner8f60e4d2010-02-05 22:56:11 +00003017 def SBB8mi : Ii8<0x80, MRM3m, (outs), (ins i8mem:$dst, i8imm:$src2),
3018 "sbb{b}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen874ae252009-06-02 03:12:52 +00003019 [(store (sube (loadi8 addr:$dst), imm:$src2), addr:$dst)]>;
Dale Johannesenca11dae2009-05-18 17:44:15 +00003020 def SBB16mi : Ii16<0x81, MRM3m, (outs), (ins i16mem:$dst, i16imm:$src2),
3021 "sbb{w}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen874ae252009-06-02 03:12:52 +00003022 [(store (sube (loadi16 addr:$dst), imm:$src2), addr:$dst)]>,
Dale Johannesen94c9cd12009-05-18 21:41:59 +00003023 OpSize;
Dale Johannesenca11dae2009-05-18 17:44:15 +00003024 def SBB16mi8 : Ii8<0x83, MRM3m, (outs), (ins i16mem:$dst, i16i8imm :$src2),
3025 "sbb{w}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen874ae252009-06-02 03:12:52 +00003026 [(store (sube (load addr:$dst), i16immSExt8:$src2), addr:$dst)]>,
Dale Johannesen94c9cd12009-05-18 21:41:59 +00003027 OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00003028 def SBB32mi : Ii32<0x81, MRM3m, (outs), (ins i32mem:$dst, i32imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003029 "sbb{l}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen874ae252009-06-02 03:12:52 +00003030 [(store (sube (loadi32 addr:$dst), imm:$src2), addr:$dst)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00003031 def SBB32mi8 : Ii8<0x83, MRM3m, (outs), (ins i32mem:$dst, i32i8imm :$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003032 "sbb{l}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen874ae252009-06-02 03:12:52 +00003033 [(store (sube (load addr:$dst), i32immSExt8:$src2), addr:$dst)]>;
Sean Callanand00025a2009-09-11 19:01:56 +00003034
3035 def SBB8i8 : Ii8<0x1C, RawFrm, (outs), (ins i8imm:$src),
3036 "sbb{b}\t{$src, %al|%al, $src}", []>;
3037 def SBB16i16 : Ii16<0x1D, RawFrm, (outs), (ins i16imm:$src),
3038 "sbb{w}\t{$src, %ax|%ax, $src}", []>, OpSize;
3039 def SBB32i32 : Ii32<0x1D, RawFrm, (outs), (ins i32imm:$src),
3040 "sbb{l}\t{$src, %eax|%eax, $src}", []>;
Chris Lattner57a02302004-08-11 04:31:00 +00003041}
Sean Callanan108934c2009-12-18 00:01:26 +00003042
3043def SBB8rr_REV : I<0x1A, MRMSrcReg, (outs GR8:$dst), (ins GR8:$src1, GR8:$src2),
3044 "sbb{b}\t{$src2, $dst|$dst, $src2}", []>;
3045def SBB16rr_REV : I<0x1B, MRMSrcReg, (outs GR16:$dst),
3046 (ins GR16:$src1, GR16:$src2),
3047 "sbb{w}\t{$src2, $dst|$dst, $src2}", []>, OpSize;
3048def SBB32rr_REV : I<0x1B, MRMSrcReg, (outs GR32:$dst),
3049 (ins GR32:$src1, GR32:$src2),
3050 "sbb{l}\t{$src2, $dst|$dst, $src2}", []>;
3051
Dale Johannesenca11dae2009-05-18 17:44:15 +00003052def SBB8rm : I<0x1A, MRMSrcMem, (outs GR8:$dst), (ins GR8:$src1, i8mem:$src2),
3053 "sbb{b}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen874ae252009-06-02 03:12:52 +00003054 [(set GR8:$dst, (sube GR8:$src1, (load addr:$src2)))]>;
Dale Johannesenca11dae2009-05-18 17:44:15 +00003055def SBB16rm : I<0x1B, MRMSrcMem, (outs GR16:$dst),
3056 (ins GR16:$src1, i16mem:$src2),
3057 "sbb{w}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen874ae252009-06-02 03:12:52 +00003058 [(set GR16:$dst, (sube GR16:$src1, (load addr:$src2)))]>,
Dale Johannesen94c9cd12009-05-18 21:41:59 +00003059 OpSize;
Dale Johannesenca11dae2009-05-18 17:44:15 +00003060def SBB32rm : I<0x1B, MRMSrcMem, (outs GR32:$dst),
3061 (ins GR32:$src1, i32mem:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003062 "sbb{l}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen874ae252009-06-02 03:12:52 +00003063 [(set GR32:$dst, (sube GR32:$src1, (load addr:$src2)))]>;
Dale Johannesenca11dae2009-05-18 17:44:15 +00003064def SBB8ri : Ii8<0x80, MRM3r, (outs GR8:$dst), (ins GR8:$src1, i8imm:$src2),
3065 "sbb{b}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen874ae252009-06-02 03:12:52 +00003066 [(set GR8:$dst, (sube GR8:$src1, imm:$src2))]>;
Dale Johannesenca11dae2009-05-18 17:44:15 +00003067def SBB16ri : Ii16<0x81, MRM3r, (outs GR16:$dst),
3068 (ins GR16:$src1, i16imm:$src2),
3069 "sbb{w}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen874ae252009-06-02 03:12:52 +00003070 [(set GR16:$dst, (sube GR16:$src1, imm:$src2))]>, OpSize;
Dale Johannesenca11dae2009-05-18 17:44:15 +00003071def SBB16ri8 : Ii8<0x83, MRM3r, (outs GR16:$dst),
3072 (ins GR16:$src1, i16i8imm:$src2),
3073 "sbb{w}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen874ae252009-06-02 03:12:52 +00003074 [(set GR16:$dst, (sube GR16:$src1, i16immSExt8:$src2))]>,
3075 OpSize;
Dale Johannesenca11dae2009-05-18 17:44:15 +00003076def SBB32ri : Ii32<0x81, MRM3r, (outs GR32:$dst),
3077 (ins GR32:$src1, i32imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003078 "sbb{l}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen874ae252009-06-02 03:12:52 +00003079 [(set GR32:$dst, (sube GR32:$src1, imm:$src2))]>;
Dale Johannesenca11dae2009-05-18 17:44:15 +00003080def SBB32ri8 : Ii8<0x83, MRM3r, (outs GR32:$dst),
3081 (ins GR32:$src1, i32i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003082 "sbb{l}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen874ae252009-06-02 03:12:52 +00003083 [(set GR32:$dst, (sube GR32:$src1, i32immSExt8:$src2))]>;
Evan Cheng3154cb62007-10-05 17:59:57 +00003084} // Uses = [EFLAGS]
Evan Cheng24f2ea32007-09-14 21:48:26 +00003085} // Defs = [EFLAGS]
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00003086
Evan Cheng24f2ea32007-09-14 21:48:26 +00003087let Defs = [EFLAGS] in {
Chris Lattner10197ff2005-01-03 01:27:59 +00003088let isCommutable = 1 in { // X = IMUL Y, Z --> X = IMUL Z, Y
Bill Wendlingd350e022008-12-12 21:15:41 +00003089// Register-Register Signed Integer Multiply
Bill Wendlingab55ebd2008-12-12 00:56:36 +00003090def IMUL16rr : I<0xAF, MRMSrcReg, (outs GR16:$dst), (ins GR16:$src1,GR16:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003091 "imul{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingd350e022008-12-12 21:15:41 +00003092 [(set GR16:$dst, (mul GR16:$src1, GR16:$src2)),
3093 (implicit EFLAGS)]>, TB, OpSize;
Bill Wendlingab55ebd2008-12-12 00:56:36 +00003094def IMUL32rr : I<0xAF, MRMSrcReg, (outs GR32:$dst), (ins GR32:$src1,GR32:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003095 "imul{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingd350e022008-12-12 21:15:41 +00003096 [(set GR32:$dst, (mul GR32:$src1, GR32:$src2)),
3097 (implicit EFLAGS)]>, TB;
Chris Lattner10197ff2005-01-03 01:27:59 +00003098}
Bill Wendlingab55ebd2008-12-12 00:56:36 +00003099
Bill Wendlingd350e022008-12-12 21:15:41 +00003100// Register-Memory Signed Integer Multiply
Bill Wendlingab55ebd2008-12-12 00:56:36 +00003101def IMUL16rm : I<0xAF, MRMSrcMem, (outs GR16:$dst),
3102 (ins GR16:$src1, i16mem:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003103 "imul{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingd350e022008-12-12 21:15:41 +00003104 [(set GR16:$dst, (mul GR16:$src1, (load addr:$src2))),
3105 (implicit EFLAGS)]>, TB, OpSize;
Sean Callanan108934c2009-12-18 00:01:26 +00003106def IMUL32rm : I<0xAF, MRMSrcMem, (outs GR32:$dst),
3107 (ins GR32:$src1, i32mem:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003108 "imul{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingd350e022008-12-12 21:15:41 +00003109 [(set GR32:$dst, (mul GR32:$src1, (load addr:$src2))),
3110 (implicit EFLAGS)]>, TB;
Evan Cheng24f2ea32007-09-14 21:48:26 +00003111} // Defs = [EFLAGS]
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00003112} // end Two Address instructions
3113
Chris Lattnerf5d3a832004-08-11 05:31:07 +00003114// Suprisingly enough, these are not two address instructions!
Evan Cheng24f2ea32007-09-14 21:48:26 +00003115let Defs = [EFLAGS] in {
Bill Wendlingd350e022008-12-12 21:15:41 +00003116// Register-Integer Signed Integer Multiply
Evan Cheng069287d2006-05-16 07:21:53 +00003117def IMUL16rri : Ii16<0x69, MRMSrcReg, // GR16 = GR16*I16
Evan Cheng64d80e32007-07-19 01:14:50 +00003118 (outs GR16:$dst), (ins GR16:$src1, i16imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003119 "imul{w}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Bill Wendlingd350e022008-12-12 21:15:41 +00003120 [(set GR16:$dst, (mul GR16:$src1, imm:$src2)),
3121 (implicit EFLAGS)]>, OpSize;
Evan Cheng069287d2006-05-16 07:21:53 +00003122def IMUL32rri : Ii32<0x69, MRMSrcReg, // GR32 = GR32*I32
Evan Cheng64d80e32007-07-19 01:14:50 +00003123 (outs GR32:$dst), (ins GR32:$src1, i32imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003124 "imul{l}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Bill Wendlingd350e022008-12-12 21:15:41 +00003125 [(set GR32:$dst, (mul GR32:$src1, imm:$src2)),
3126 (implicit EFLAGS)]>;
Evan Cheng069287d2006-05-16 07:21:53 +00003127def IMUL16rri8 : Ii8<0x6B, MRMSrcReg, // GR16 = GR16*I8
Evan Cheng64d80e32007-07-19 01:14:50 +00003128 (outs GR16:$dst), (ins GR16:$src1, i16i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003129 "imul{w}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Bill Wendlingd350e022008-12-12 21:15:41 +00003130 [(set GR16:$dst, (mul GR16:$src1, i16immSExt8:$src2)),
3131 (implicit EFLAGS)]>, OpSize;
Evan Cheng069287d2006-05-16 07:21:53 +00003132def IMUL32rri8 : Ii8<0x6B, MRMSrcReg, // GR32 = GR32*I8
Evan Cheng64d80e32007-07-19 01:14:50 +00003133 (outs GR32:$dst), (ins GR32:$src1, i32i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003134 "imul{l}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Bill Wendlingd350e022008-12-12 21:15:41 +00003135 [(set GR32:$dst, (mul GR32:$src1, i32immSExt8:$src2)),
3136 (implicit EFLAGS)]>;
Chris Lattnerf5d3a832004-08-11 05:31:07 +00003137
Bill Wendlingd350e022008-12-12 21:15:41 +00003138// Memory-Integer Signed Integer Multiply
Sean Callanan108934c2009-12-18 00:01:26 +00003139def IMUL16rmi : Ii16<0x69, MRMSrcMem, // GR16 = [mem16]*I16
Evan Cheng64d80e32007-07-19 01:14:50 +00003140 (outs GR16:$dst), (ins i16mem:$src1, i16imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003141 "imul{w}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Bill Wendlingd350e022008-12-12 21:15:41 +00003142 [(set GR16:$dst, (mul (load addr:$src1), imm:$src2)),
3143 (implicit EFLAGS)]>, OpSize;
Sean Callanan108934c2009-12-18 00:01:26 +00003144def IMUL32rmi : Ii32<0x69, MRMSrcMem, // GR32 = [mem32]*I32
Evan Cheng64d80e32007-07-19 01:14:50 +00003145 (outs GR32:$dst), (ins i32mem:$src1, i32imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003146 "imul{l}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Bill Wendlingd350e022008-12-12 21:15:41 +00003147 [(set GR32:$dst, (mul (load addr:$src1), imm:$src2)),
3148 (implicit EFLAGS)]>;
Evan Cheng069287d2006-05-16 07:21:53 +00003149def IMUL16rmi8 : Ii8<0x6B, MRMSrcMem, // GR16 = [mem16]*I8
Evan Cheng64d80e32007-07-19 01:14:50 +00003150 (outs GR16:$dst), (ins i16mem:$src1, i16i8imm :$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003151 "imul{w}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Bill Wendlingab55ebd2008-12-12 00:56:36 +00003152 [(set GR16:$dst, (mul (load addr:$src1),
Bill Wendlingd350e022008-12-12 21:15:41 +00003153 i16immSExt8:$src2)),
3154 (implicit EFLAGS)]>, OpSize;
Evan Cheng069287d2006-05-16 07:21:53 +00003155def IMUL32rmi8 : Ii8<0x6B, MRMSrcMem, // GR32 = [mem32]*I8
Evan Cheng64d80e32007-07-19 01:14:50 +00003156 (outs GR32:$dst), (ins i32mem:$src1, i32i8imm: $src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003157 "imul{l}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Bill Wendlingab55ebd2008-12-12 00:56:36 +00003158 [(set GR32:$dst, (mul (load addr:$src1),
Bill Wendlingd350e022008-12-12 21:15:41 +00003159 i32immSExt8:$src2)),
3160 (implicit EFLAGS)]>;
Evan Cheng24f2ea32007-09-14 21:48:26 +00003161} // Defs = [EFLAGS]
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00003162
3163//===----------------------------------------------------------------------===//
3164// Test instructions are just like AND, except they don't generate a result.
Chris Lattner3a173df2004-10-03 20:35:00 +00003165//
Evan Cheng0488db92007-09-25 01:57:46 +00003166let Defs = [EFLAGS] in {
Chris Lattnercc65bee2005-01-02 02:35:46 +00003167let isCommutable = 1 in { // TEST X, Y --> TEST Y, X
Daniel Dunbarb93c72c2010-03-08 21:10:36 +00003168def TEST8rr : I<0x84, MRMSrcReg, (outs), (ins GR8:$src1, GR8:$src2),
Evan Chenge5f62042007-09-29 00:00:36 +00003169 "test{b}\t{$src2, $src1|$src1, $src2}",
Chris Lattnerce2bcc82008-02-19 17:37:35 +00003170 [(X86cmp (and_su GR8:$src1, GR8:$src2), 0),
Evan Chenge5f62042007-09-29 00:00:36 +00003171 (implicit EFLAGS)]>;
Daniel Dunbarb93c72c2010-03-08 21:10:36 +00003172def TEST16rr : I<0x85, MRMSrcReg, (outs), (ins GR16:$src1, GR16:$src2),
Evan Chenge5f62042007-09-29 00:00:36 +00003173 "test{w}\t{$src2, $src1|$src1, $src2}",
Chris Lattnerce2bcc82008-02-19 17:37:35 +00003174 [(X86cmp (and_su GR16:$src1, GR16:$src2), 0),
Evan Chenge5f62042007-09-29 00:00:36 +00003175 (implicit EFLAGS)]>,
3176 OpSize;
Daniel Dunbarb93c72c2010-03-08 21:10:36 +00003177def TEST32rr : I<0x85, MRMSrcReg, (outs), (ins GR32:$src1, GR32:$src2),
Evan Chenge5f62042007-09-29 00:00:36 +00003178 "test{l}\t{$src2, $src1|$src1, $src2}",
Chris Lattnerce2bcc82008-02-19 17:37:35 +00003179 [(X86cmp (and_su GR32:$src1, GR32:$src2), 0),
Evan Chenge5f62042007-09-29 00:00:36 +00003180 (implicit EFLAGS)]>;
Chris Lattnercc65bee2005-01-02 02:35:46 +00003181}
Evan Cheng734503b2006-09-11 02:19:56 +00003182
Sean Callanan4a93b712009-09-01 18:14:18 +00003183def TEST8i8 : Ii8<0xA8, RawFrm, (outs), (ins i8imm:$src),
3184 "test{b}\t{$src, %al|%al, $src}", []>;
3185def TEST16i16 : Ii16<0xA9, RawFrm, (outs), (ins i16imm:$src),
3186 "test{w}\t{$src, %ax|%ax, $src}", []>, OpSize;
3187def TEST32i32 : Ii32<0xA9, RawFrm, (outs), (ins i32imm:$src),
3188 "test{l}\t{$src, %eax|%eax, $src}", []>;
3189
Evan Cheng64d80e32007-07-19 01:14:50 +00003190def TEST8rm : I<0x84, MRMSrcMem, (outs), (ins GR8 :$src1, i8mem :$src2),
Evan Chenge5f62042007-09-29 00:00:36 +00003191 "test{b}\t{$src2, $src1|$src1, $src2}",
3192 [(X86cmp (and GR8:$src1, (loadi8 addr:$src2)), 0),
3193 (implicit EFLAGS)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00003194def TEST16rm : I<0x85, MRMSrcMem, (outs), (ins GR16:$src1, i16mem:$src2),
Evan Chenge5f62042007-09-29 00:00:36 +00003195 "test{w}\t{$src2, $src1|$src1, $src2}",
3196 [(X86cmp (and GR16:$src1, (loadi16 addr:$src2)), 0),
3197 (implicit EFLAGS)]>, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00003198def TEST32rm : I<0x85, MRMSrcMem, (outs), (ins GR32:$src1, i32mem:$src2),
Evan Chenge5f62042007-09-29 00:00:36 +00003199 "test{l}\t{$src2, $src1|$src1, $src2}",
3200 [(X86cmp (and GR32:$src1, (loadi32 addr:$src2)), 0),
3201 (implicit EFLAGS)]>;
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00003202
Evan Cheng069287d2006-05-16 07:21:53 +00003203def TEST8ri : Ii8 <0xF6, MRM0r, // flags = GR8 & imm8
Evan Cheng64d80e32007-07-19 01:14:50 +00003204 (outs), (ins GR8:$src1, i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003205 "test{b}\t{$src2, $src1|$src1, $src2}",
Chris Lattnerce2bcc82008-02-19 17:37:35 +00003206 [(X86cmp (and_su GR8:$src1, imm:$src2), 0),
Evan Chenge5f62042007-09-29 00:00:36 +00003207 (implicit EFLAGS)]>;
Evan Cheng069287d2006-05-16 07:21:53 +00003208def TEST16ri : Ii16<0xF7, MRM0r, // flags = GR16 & imm16
Evan Cheng64d80e32007-07-19 01:14:50 +00003209 (outs), (ins GR16:$src1, i16imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003210 "test{w}\t{$src2, $src1|$src1, $src2}",
Chris Lattnerce2bcc82008-02-19 17:37:35 +00003211 [(X86cmp (and_su GR16:$src1, imm:$src2), 0),
Evan Chenge5f62042007-09-29 00:00:36 +00003212 (implicit EFLAGS)]>, OpSize;
Evan Cheng069287d2006-05-16 07:21:53 +00003213def TEST32ri : Ii32<0xF7, MRM0r, // flags = GR32 & imm32
Evan Cheng64d80e32007-07-19 01:14:50 +00003214 (outs), (ins GR32:$src1, i32imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003215 "test{l}\t{$src2, $src1|$src1, $src2}",
Chris Lattnerce2bcc82008-02-19 17:37:35 +00003216 [(X86cmp (and_su GR32:$src1, imm:$src2), 0),
Evan Chenge5f62042007-09-29 00:00:36 +00003217 (implicit EFLAGS)]>;
Evan Cheng734503b2006-09-11 02:19:56 +00003218
Evan Chenge5f62042007-09-29 00:00:36 +00003219def TEST8mi : Ii8 <0xF6, MRM0m, // flags = [mem8] & imm8
Evan Cheng64d80e32007-07-19 01:14:50 +00003220 (outs), (ins i8mem:$src1, i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003221 "test{b}\t{$src2, $src1|$src1, $src2}",
Evan Chenge5f62042007-09-29 00:00:36 +00003222 [(X86cmp (and (loadi8 addr:$src1), imm:$src2), 0),
3223 (implicit EFLAGS)]>;
3224def TEST16mi : Ii16<0xF7, MRM0m, // flags = [mem16] & imm16
Evan Cheng64d80e32007-07-19 01:14:50 +00003225 (outs), (ins i16mem:$src1, i16imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003226 "test{w}\t{$src2, $src1|$src1, $src2}",
Evan Chenge5f62042007-09-29 00:00:36 +00003227 [(X86cmp (and (loadi16 addr:$src1), imm:$src2), 0),
3228 (implicit EFLAGS)]>, OpSize;
3229def TEST32mi : Ii32<0xF7, MRM0m, // flags = [mem32] & imm32
Evan Cheng64d80e32007-07-19 01:14:50 +00003230 (outs), (ins i32mem:$src1, i32imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003231 "test{l}\t{$src2, $src1|$src1, $src2}",
Evan Chenge5f62042007-09-29 00:00:36 +00003232 [(X86cmp (and (loadi32 addr:$src1), imm:$src2), 0),
Evan Cheng0488db92007-09-25 01:57:46 +00003233 (implicit EFLAGS)]>;
3234} // Defs = [EFLAGS]
3235
3236
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00003237// Condition code ops, incl. set if equal/not equal/...
Chris Lattnerba7e7562008-01-10 07:59:24 +00003238let Defs = [EFLAGS], Uses = [AH], neverHasSideEffects = 1 in
Evan Cheng071a2792007-09-11 19:55:27 +00003239def SAHF : I<0x9E, RawFrm, (outs), (ins), "sahf", []>; // flags = AH
Chris Lattnerba7e7562008-01-10 07:59:24 +00003240let Defs = [AH], Uses = [EFLAGS], neverHasSideEffects = 1 in
Evan Cheng071a2792007-09-11 19:55:27 +00003241def LAHF : I<0x9F, RawFrm, (outs), (ins), "lahf", []>; // AH = flags
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00003242
Evan Cheng0488db92007-09-25 01:57:46 +00003243let Uses = [EFLAGS] in {
Evan Chengad9c0a32009-12-15 00:53:42 +00003244// Use sbb to materialize carry bit.
Evan Chengad9c0a32009-12-15 00:53:42 +00003245let Defs = [EFLAGS], isCodeGenOnly = 1 in {
Chris Lattnerc74e3332010-02-05 21:13:48 +00003246// FIXME: These are pseudo ops that should be replaced with Pat<> patterns.
3247// However, Pat<> can't replicate the destination reg into the inputs of the
3248// result.
3249// FIXME: Change these to have encoding Pseudo when X86MCCodeEmitter replaces
3250// X86CodeEmitter.
3251def SETB_C8r : I<0x18, MRMInitReg, (outs GR8:$dst), (ins), "",
Evan Chengad9c0a32009-12-15 00:53:42 +00003252 [(set GR8:$dst, (X86setcc_c X86_COND_B, EFLAGS))]>;
Chris Lattnerc74e3332010-02-05 21:13:48 +00003253def SETB_C16r : I<0x19, MRMInitReg, (outs GR16:$dst), (ins), "",
Evan Cheng2e489c42009-12-16 00:53:11 +00003254 [(set GR16:$dst, (X86setcc_c X86_COND_B, EFLAGS))]>,
Evan Chengad9c0a32009-12-15 00:53:42 +00003255 OpSize;
Chris Lattnerc74e3332010-02-05 21:13:48 +00003256def SETB_C32r : I<0x19, MRMInitReg, (outs GR32:$dst), (ins), "",
Evan Cheng2e489c42009-12-16 00:53:11 +00003257 [(set GR32:$dst, (X86setcc_c X86_COND_B, EFLAGS))]>;
Evan Chengad9c0a32009-12-15 00:53:42 +00003258} // isCodeGenOnly
3259
Chris Lattner3a173df2004-10-03 20:35:00 +00003260def SETEr : I<0x94, MRM0r,
Evan Cheng64d80e32007-07-19 01:14:50 +00003261 (outs GR8 :$dst), (ins),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003262 "sete\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +00003263 [(set GR8:$dst, (X86setcc X86_COND_E, EFLAGS))]>,
Evan Cheng069287d2006-05-16 07:21:53 +00003264 TB; // GR8 = ==
Chris Lattner3a173df2004-10-03 20:35:00 +00003265def SETEm : I<0x94, MRM0m,
Evan Cheng64d80e32007-07-19 01:14:50 +00003266 (outs), (ins i8mem:$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003267 "sete\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +00003268 [(store (X86setcc X86_COND_E, EFLAGS), addr:$dst)]>,
Evan Chengd5781fc2005-12-21 20:21:51 +00003269 TB; // [mem8] = ==
Bill Wendling9f248742008-12-02 00:07:05 +00003270
Chris Lattner3a173df2004-10-03 20:35:00 +00003271def SETNEr : I<0x95, MRM0r,
Evan Cheng64d80e32007-07-19 01:14:50 +00003272 (outs GR8 :$dst), (ins),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003273 "setne\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +00003274 [(set GR8:$dst, (X86setcc X86_COND_NE, EFLAGS))]>,
Evan Cheng069287d2006-05-16 07:21:53 +00003275 TB; // GR8 = !=
Chris Lattner3a173df2004-10-03 20:35:00 +00003276def SETNEm : I<0x95, MRM0m,
Evan Cheng64d80e32007-07-19 01:14:50 +00003277 (outs), (ins i8mem:$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003278 "setne\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +00003279 [(store (X86setcc X86_COND_NE, EFLAGS), addr:$dst)]>,
Evan Chengd5781fc2005-12-21 20:21:51 +00003280 TB; // [mem8] = !=
Bill Wendling9f248742008-12-02 00:07:05 +00003281
Evan Chengd5781fc2005-12-21 20:21:51 +00003282def SETLr : I<0x9C, MRM0r,
Evan Cheng64d80e32007-07-19 01:14:50 +00003283 (outs GR8 :$dst), (ins),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003284 "setl\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +00003285 [(set GR8:$dst, (X86setcc X86_COND_L, EFLAGS))]>,
Evan Cheng069287d2006-05-16 07:21:53 +00003286 TB; // GR8 = < signed
Evan Chengd5781fc2005-12-21 20:21:51 +00003287def SETLm : I<0x9C, MRM0m,
Evan Cheng64d80e32007-07-19 01:14:50 +00003288 (outs), (ins i8mem:$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003289 "setl\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +00003290 [(store (X86setcc X86_COND_L, EFLAGS), addr:$dst)]>,
Evan Chengd5781fc2005-12-21 20:21:51 +00003291 TB; // [mem8] = < signed
Bill Wendling9f248742008-12-02 00:07:05 +00003292
Evan Chengd5781fc2005-12-21 20:21:51 +00003293def SETGEr : I<0x9D, MRM0r,
Evan Cheng64d80e32007-07-19 01:14:50 +00003294 (outs GR8 :$dst), (ins),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003295 "setge\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +00003296 [(set GR8:$dst, (X86setcc X86_COND_GE, EFLAGS))]>,
Evan Cheng069287d2006-05-16 07:21:53 +00003297 TB; // GR8 = >= signed
Evan Chengd5781fc2005-12-21 20:21:51 +00003298def SETGEm : I<0x9D, MRM0m,
Evan Cheng64d80e32007-07-19 01:14:50 +00003299 (outs), (ins i8mem:$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003300 "setge\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +00003301 [(store (X86setcc X86_COND_GE, EFLAGS), addr:$dst)]>,
Evan Chengd5781fc2005-12-21 20:21:51 +00003302 TB; // [mem8] = >= signed
Bill Wendling9f248742008-12-02 00:07:05 +00003303
Evan Chengd5781fc2005-12-21 20:21:51 +00003304def SETLEr : I<0x9E, MRM0r,
Evan Cheng64d80e32007-07-19 01:14:50 +00003305 (outs GR8 :$dst), (ins),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003306 "setle\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +00003307 [(set GR8:$dst, (X86setcc X86_COND_LE, EFLAGS))]>,
Evan Cheng069287d2006-05-16 07:21:53 +00003308 TB; // GR8 = <= signed
Evan Chengd5781fc2005-12-21 20:21:51 +00003309def SETLEm : I<0x9E, MRM0m,
Evan Cheng64d80e32007-07-19 01:14:50 +00003310 (outs), (ins i8mem:$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003311 "setle\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +00003312 [(store (X86setcc X86_COND_LE, EFLAGS), addr:$dst)]>,
Evan Chengd5781fc2005-12-21 20:21:51 +00003313 TB; // [mem8] = <= signed
Bill Wendling9f248742008-12-02 00:07:05 +00003314
Evan Chengd5781fc2005-12-21 20:21:51 +00003315def SETGr : I<0x9F, MRM0r,
Evan Cheng64d80e32007-07-19 01:14:50 +00003316 (outs GR8 :$dst), (ins),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003317 "setg\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +00003318 [(set GR8:$dst, (X86setcc X86_COND_G, EFLAGS))]>,
Evan Cheng069287d2006-05-16 07:21:53 +00003319 TB; // GR8 = > signed
Evan Chengd5781fc2005-12-21 20:21:51 +00003320def SETGm : I<0x9F, MRM0m,
Evan Cheng64d80e32007-07-19 01:14:50 +00003321 (outs), (ins i8mem:$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003322 "setg\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +00003323 [(store (X86setcc X86_COND_G, EFLAGS), addr:$dst)]>,
Evan Chengd5781fc2005-12-21 20:21:51 +00003324 TB; // [mem8] = > signed
3325
3326def SETBr : I<0x92, MRM0r,
Evan Cheng64d80e32007-07-19 01:14:50 +00003327 (outs GR8 :$dst), (ins),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003328 "setb\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +00003329 [(set GR8:$dst, (X86setcc X86_COND_B, EFLAGS))]>,
Evan Cheng069287d2006-05-16 07:21:53 +00003330 TB; // GR8 = < unsign
Evan Chengd5781fc2005-12-21 20:21:51 +00003331def SETBm : I<0x92, MRM0m,
Evan Cheng64d80e32007-07-19 01:14:50 +00003332 (outs), (ins i8mem:$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003333 "setb\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +00003334 [(store (X86setcc X86_COND_B, EFLAGS), addr:$dst)]>,
Evan Chengd5781fc2005-12-21 20:21:51 +00003335 TB; // [mem8] = < unsign
Bill Wendling9f248742008-12-02 00:07:05 +00003336
Evan Chengd5781fc2005-12-21 20:21:51 +00003337def SETAEr : I<0x93, MRM0r,
Evan Cheng64d80e32007-07-19 01:14:50 +00003338 (outs GR8 :$dst), (ins),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003339 "setae\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +00003340 [(set GR8:$dst, (X86setcc X86_COND_AE, EFLAGS))]>,
Evan Cheng069287d2006-05-16 07:21:53 +00003341 TB; // GR8 = >= unsign
Evan Chengd5781fc2005-12-21 20:21:51 +00003342def SETAEm : I<0x93, MRM0m,
Evan Cheng64d80e32007-07-19 01:14:50 +00003343 (outs), (ins i8mem:$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003344 "setae\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +00003345 [(store (X86setcc X86_COND_AE, EFLAGS), addr:$dst)]>,
Evan Chengd5781fc2005-12-21 20:21:51 +00003346 TB; // [mem8] = >= unsign
Bill Wendling9f248742008-12-02 00:07:05 +00003347
Chris Lattner3a173df2004-10-03 20:35:00 +00003348def SETBEr : I<0x96, MRM0r,
Evan Cheng64d80e32007-07-19 01:14:50 +00003349 (outs GR8 :$dst), (ins),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003350 "setbe\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +00003351 [(set GR8:$dst, (X86setcc X86_COND_BE, EFLAGS))]>,
Evan Cheng069287d2006-05-16 07:21:53 +00003352 TB; // GR8 = <= unsign
Chris Lattner3a173df2004-10-03 20:35:00 +00003353def SETBEm : I<0x96, MRM0m,
Evan Cheng64d80e32007-07-19 01:14:50 +00003354 (outs), (ins i8mem:$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003355 "setbe\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +00003356 [(store (X86setcc X86_COND_BE, EFLAGS), addr:$dst)]>,
Evan Chengd5781fc2005-12-21 20:21:51 +00003357 TB; // [mem8] = <= unsign
Bill Wendling9f248742008-12-02 00:07:05 +00003358
Chris Lattner3a173df2004-10-03 20:35:00 +00003359def SETAr : I<0x97, MRM0r,
Evan Cheng64d80e32007-07-19 01:14:50 +00003360 (outs GR8 :$dst), (ins),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003361 "seta\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +00003362 [(set GR8:$dst, (X86setcc X86_COND_A, EFLAGS))]>,
Evan Cheng069287d2006-05-16 07:21:53 +00003363 TB; // GR8 = > signed
Chris Lattner3a173df2004-10-03 20:35:00 +00003364def SETAm : I<0x97, MRM0m,
Evan Cheng64d80e32007-07-19 01:14:50 +00003365 (outs), (ins i8mem:$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003366 "seta\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +00003367 [(store (X86setcc X86_COND_A, EFLAGS), addr:$dst)]>,
Evan Chengd5781fc2005-12-21 20:21:51 +00003368 TB; // [mem8] = > signed
Evan Chengd9558e02006-01-06 00:43:03 +00003369
Chris Lattner3a173df2004-10-03 20:35:00 +00003370def SETSr : I<0x98, MRM0r,
Evan Cheng64d80e32007-07-19 01:14:50 +00003371 (outs GR8 :$dst), (ins),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003372 "sets\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +00003373 [(set GR8:$dst, (X86setcc X86_COND_S, EFLAGS))]>,
Evan Cheng069287d2006-05-16 07:21:53 +00003374 TB; // GR8 = <sign bit>
Chris Lattner3a173df2004-10-03 20:35:00 +00003375def SETSm : I<0x98, MRM0m,
Evan Cheng64d80e32007-07-19 01:14:50 +00003376 (outs), (ins i8mem:$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003377 "sets\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +00003378 [(store (X86setcc X86_COND_S, EFLAGS), addr:$dst)]>,
Evan Chengd9558e02006-01-06 00:43:03 +00003379 TB; // [mem8] = <sign bit>
Chris Lattner3a173df2004-10-03 20:35:00 +00003380def SETNSr : I<0x99, MRM0r,
Evan Cheng64d80e32007-07-19 01:14:50 +00003381 (outs GR8 :$dst), (ins),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003382 "setns\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +00003383 [(set GR8:$dst, (X86setcc X86_COND_NS, EFLAGS))]>,
Evan Cheng069287d2006-05-16 07:21:53 +00003384 TB; // GR8 = !<sign bit>
Chris Lattner3a173df2004-10-03 20:35:00 +00003385def SETNSm : I<0x99, MRM0m,
Evan Cheng64d80e32007-07-19 01:14:50 +00003386 (outs), (ins i8mem:$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003387 "setns\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +00003388 [(store (X86setcc X86_COND_NS, EFLAGS), addr:$dst)]>,
Evan Chengd9558e02006-01-06 00:43:03 +00003389 TB; // [mem8] = !<sign bit>
Bill Wendling9f248742008-12-02 00:07:05 +00003390
Chris Lattner3a173df2004-10-03 20:35:00 +00003391def SETPr : I<0x9A, MRM0r,
Evan Cheng64d80e32007-07-19 01:14:50 +00003392 (outs GR8 :$dst), (ins),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003393 "setp\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +00003394 [(set GR8:$dst, (X86setcc X86_COND_P, EFLAGS))]>,
Evan Cheng069287d2006-05-16 07:21:53 +00003395 TB; // GR8 = parity
Chris Lattner3a173df2004-10-03 20:35:00 +00003396def SETPm : I<0x9A, MRM0m,
Evan Cheng64d80e32007-07-19 01:14:50 +00003397 (outs), (ins i8mem:$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003398 "setp\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +00003399 [(store (X86setcc X86_COND_P, EFLAGS), addr:$dst)]>,
Evan Chengd9558e02006-01-06 00:43:03 +00003400 TB; // [mem8] = parity
Chris Lattnercc65bee2005-01-02 02:35:46 +00003401def SETNPr : I<0x9B, MRM0r,
Evan Cheng64d80e32007-07-19 01:14:50 +00003402 (outs GR8 :$dst), (ins),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003403 "setnp\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +00003404 [(set GR8:$dst, (X86setcc X86_COND_NP, EFLAGS))]>,
Evan Cheng069287d2006-05-16 07:21:53 +00003405 TB; // GR8 = not parity
Chris Lattnercc65bee2005-01-02 02:35:46 +00003406def SETNPm : I<0x9B, MRM0m,
Evan Cheng64d80e32007-07-19 01:14:50 +00003407 (outs), (ins i8mem:$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003408 "setnp\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +00003409 [(store (X86setcc X86_COND_NP, EFLAGS), addr:$dst)]>,
Evan Chengd9558e02006-01-06 00:43:03 +00003410 TB; // [mem8] = not parity
Bill Wendling9f248742008-12-02 00:07:05 +00003411
3412def SETOr : I<0x90, MRM0r,
3413 (outs GR8 :$dst), (ins),
3414 "seto\t$dst",
3415 [(set GR8:$dst, (X86setcc X86_COND_O, EFLAGS))]>,
3416 TB; // GR8 = overflow
3417def SETOm : I<0x90, MRM0m,
3418 (outs), (ins i8mem:$dst),
3419 "seto\t$dst",
3420 [(store (X86setcc X86_COND_O, EFLAGS), addr:$dst)]>,
3421 TB; // [mem8] = overflow
3422def SETNOr : I<0x91, MRM0r,
3423 (outs GR8 :$dst), (ins),
3424 "setno\t$dst",
3425 [(set GR8:$dst, (X86setcc X86_COND_NO, EFLAGS))]>,
3426 TB; // GR8 = not overflow
3427def SETNOm : I<0x91, MRM0m,
3428 (outs), (ins i8mem:$dst),
3429 "setno\t$dst",
3430 [(store (X86setcc X86_COND_NO, EFLAGS), addr:$dst)]>,
3431 TB; // [mem8] = not overflow
Evan Cheng0488db92007-09-25 01:57:46 +00003432} // Uses = [EFLAGS]
3433
Chris Lattner1cca5e32003-08-03 21:54:21 +00003434
3435// Integer comparisons
Evan Cheng24f2ea32007-09-14 21:48:26 +00003436let Defs = [EFLAGS] in {
Sean Callanana09caa52009-09-02 00:55:49 +00003437def CMP8i8 : Ii8<0x3C, RawFrm, (outs), (ins i8imm:$src),
3438 "cmp{b}\t{$src, %al|%al, $src}", []>;
3439def CMP16i16 : Ii16<0x3D, RawFrm, (outs), (ins i16imm:$src),
3440 "cmp{w}\t{$src, %ax|%ax, $src}", []>, OpSize;
3441def CMP32i32 : Ii32<0x3D, RawFrm, (outs), (ins i32imm:$src),
3442 "cmp{l}\t{$src, %eax|%eax, $src}", []>;
3443
Chris Lattner3a173df2004-10-03 20:35:00 +00003444def CMP8rr : I<0x38, MRMDestReg,
Evan Cheng64d80e32007-07-19 01:14:50 +00003445 (outs), (ins GR8 :$src1, GR8 :$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003446 "cmp{b}\t{$src2, $src1|$src1, $src2}",
Evan Chenge5f62042007-09-29 00:00:36 +00003447 [(X86cmp GR8:$src1, GR8:$src2), (implicit EFLAGS)]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00003448def CMP16rr : I<0x39, MRMDestReg,
Evan Cheng64d80e32007-07-19 01:14:50 +00003449 (outs), (ins GR16:$src1, GR16:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003450 "cmp{w}\t{$src2, $src1|$src1, $src2}",
Evan Chenge5f62042007-09-29 00:00:36 +00003451 [(X86cmp GR16:$src1, GR16:$src2), (implicit EFLAGS)]>, OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00003452def CMP32rr : I<0x39, MRMDestReg,
Evan Cheng64d80e32007-07-19 01:14:50 +00003453 (outs), (ins GR32:$src1, GR32:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003454 "cmp{l}\t{$src2, $src1|$src1, $src2}",
Evan Chenge5f62042007-09-29 00:00:36 +00003455 [(X86cmp GR32:$src1, GR32:$src2), (implicit EFLAGS)]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00003456def CMP8mr : I<0x38, MRMDestMem,
Evan Cheng64d80e32007-07-19 01:14:50 +00003457 (outs), (ins i8mem :$src1, GR8 :$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003458 "cmp{b}\t{$src2, $src1|$src1, $src2}",
Evan Chenge5f62042007-09-29 00:00:36 +00003459 [(X86cmp (loadi8 addr:$src1), GR8:$src2),
3460 (implicit EFLAGS)]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00003461def CMP16mr : I<0x39, MRMDestMem,
Evan Cheng64d80e32007-07-19 01:14:50 +00003462 (outs), (ins i16mem:$src1, GR16:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003463 "cmp{w}\t{$src2, $src1|$src1, $src2}",
Evan Chenge5f62042007-09-29 00:00:36 +00003464 [(X86cmp (loadi16 addr:$src1), GR16:$src2),
3465 (implicit EFLAGS)]>, OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00003466def CMP32mr : I<0x39, MRMDestMem,
Evan Cheng64d80e32007-07-19 01:14:50 +00003467 (outs), (ins i32mem:$src1, GR32:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003468 "cmp{l}\t{$src2, $src1|$src1, $src2}",
Evan Chenge5f62042007-09-29 00:00:36 +00003469 [(X86cmp (loadi32 addr:$src1), GR32:$src2),
3470 (implicit EFLAGS)]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00003471def CMP8rm : I<0x3A, MRMSrcMem,
Evan Cheng64d80e32007-07-19 01:14:50 +00003472 (outs), (ins GR8 :$src1, i8mem :$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003473 "cmp{b}\t{$src2, $src1|$src1, $src2}",
Evan Chenge5f62042007-09-29 00:00:36 +00003474 [(X86cmp GR8:$src1, (loadi8 addr:$src2)),
3475 (implicit EFLAGS)]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00003476def CMP16rm : I<0x3B, MRMSrcMem,
Evan Cheng64d80e32007-07-19 01:14:50 +00003477 (outs), (ins GR16:$src1, i16mem:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003478 "cmp{w}\t{$src2, $src1|$src1, $src2}",
Evan Chenge5f62042007-09-29 00:00:36 +00003479 [(X86cmp GR16:$src1, (loadi16 addr:$src2)),
3480 (implicit EFLAGS)]>, OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00003481def CMP32rm : I<0x3B, MRMSrcMem,
Evan Cheng64d80e32007-07-19 01:14:50 +00003482 (outs), (ins GR32:$src1, i32mem:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003483 "cmp{l}\t{$src2, $src1|$src1, $src2}",
Evan Chenge5f62042007-09-29 00:00:36 +00003484 [(X86cmp GR32:$src1, (loadi32 addr:$src2)),
3485 (implicit EFLAGS)]>;
Daniel Dunbar1e8ee892010-03-09 22:50:40 +00003486
3487// These are alternate spellings for use by the disassembler, we mark them as
3488// code gen only to ensure they aren't matched by the assembler.
3489let isCodeGenOnly = 1 in {
3490 def CMP8rr_alt : I<0x3A, MRMSrcReg, (outs), (ins GR8:$src1, GR8:$src2),
3491 "cmp{b}\t{$src2, $src1|$src1, $src2}", []>;
3492 def CMP16rr_alt : I<0x3B, MRMSrcReg, (outs), (ins GR16:$src1, GR16:$src2),
3493 "cmp{w}\t{$src2, $src1|$src1, $src2}", []>, OpSize;
3494 def CMP32rr_alt : I<0x3B, MRMSrcReg, (outs), (ins GR32:$src1, GR32:$src2),
3495 "cmp{l}\t{$src2, $src1|$src1, $src2}", []>;
3496}
3497
Chris Lattner3a173df2004-10-03 20:35:00 +00003498def CMP8ri : Ii8<0x80, MRM7r,
Evan Cheng64d80e32007-07-19 01:14:50 +00003499 (outs), (ins GR8:$src1, i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003500 "cmp{b}\t{$src2, $src1|$src1, $src2}",
Evan Chenge5f62042007-09-29 00:00:36 +00003501 [(X86cmp GR8:$src1, imm:$src2), (implicit EFLAGS)]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00003502def CMP16ri : Ii16<0x81, MRM7r,
Evan Cheng64d80e32007-07-19 01:14:50 +00003503 (outs), (ins GR16:$src1, i16imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003504 "cmp{w}\t{$src2, $src1|$src1, $src2}",
Evan Chenge5f62042007-09-29 00:00:36 +00003505 [(X86cmp GR16:$src1, imm:$src2),
3506 (implicit EFLAGS)]>, OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00003507def CMP32ri : Ii32<0x81, MRM7r,
Evan Cheng64d80e32007-07-19 01:14:50 +00003508 (outs), (ins GR32:$src1, i32imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003509 "cmp{l}\t{$src2, $src1|$src1, $src2}",
Evan Chenge5f62042007-09-29 00:00:36 +00003510 [(X86cmp GR32:$src1, imm:$src2), (implicit EFLAGS)]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00003511def CMP8mi : Ii8 <0x80, MRM7m,
Evan Cheng64d80e32007-07-19 01:14:50 +00003512 (outs), (ins i8mem :$src1, i8imm :$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003513 "cmp{b}\t{$src2, $src1|$src1, $src2}",
Evan Chenge5f62042007-09-29 00:00:36 +00003514 [(X86cmp (loadi8 addr:$src1), imm:$src2),
3515 (implicit EFLAGS)]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00003516def CMP16mi : Ii16<0x81, MRM7m,
Evan Cheng64d80e32007-07-19 01:14:50 +00003517 (outs), (ins i16mem:$src1, i16imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003518 "cmp{w}\t{$src2, $src1|$src1, $src2}",
Evan Chenge5f62042007-09-29 00:00:36 +00003519 [(X86cmp (loadi16 addr:$src1), imm:$src2),
3520 (implicit EFLAGS)]>, OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00003521def CMP32mi : Ii32<0x81, MRM7m,
Evan Cheng64d80e32007-07-19 01:14:50 +00003522 (outs), (ins i32mem:$src1, i32imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003523 "cmp{l}\t{$src2, $src1|$src1, $src2}",
Evan Chenge5f62042007-09-29 00:00:36 +00003524 [(X86cmp (loadi32 addr:$src1), imm:$src2),
3525 (implicit EFLAGS)]>;
Chris Lattner29b4dd02006-03-23 16:13:50 +00003526def CMP16ri8 : Ii8<0x83, MRM7r,
Evan Cheng64d80e32007-07-19 01:14:50 +00003527 (outs), (ins GR16:$src1, i16i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003528 "cmp{w}\t{$src2, $src1|$src1, $src2}",
Evan Chenge5f62042007-09-29 00:00:36 +00003529 [(X86cmp GR16:$src1, i16immSExt8:$src2),
3530 (implicit EFLAGS)]>, OpSize;
Chris Lattner29b4dd02006-03-23 16:13:50 +00003531def CMP16mi8 : Ii8<0x83, MRM7m,
Evan Cheng64d80e32007-07-19 01:14:50 +00003532 (outs), (ins i16mem:$src1, i16i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003533 "cmp{w}\t{$src2, $src1|$src1, $src2}",
Evan Chenge5f62042007-09-29 00:00:36 +00003534 [(X86cmp (loadi16 addr:$src1), i16immSExt8:$src2),
3535 (implicit EFLAGS)]>, OpSize;
Chris Lattner29b4dd02006-03-23 16:13:50 +00003536def CMP32mi8 : Ii8<0x83, MRM7m,
Evan Cheng64d80e32007-07-19 01:14:50 +00003537 (outs), (ins i32mem:$src1, i32i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003538 "cmp{l}\t{$src2, $src1|$src1, $src2}",
Evan Chenge5f62042007-09-29 00:00:36 +00003539 [(X86cmp (loadi32 addr:$src1), i32immSExt8:$src2),
3540 (implicit EFLAGS)]>;
Chris Lattner29b4dd02006-03-23 16:13:50 +00003541def CMP32ri8 : Ii8<0x83, MRM7r,
Evan Cheng64d80e32007-07-19 01:14:50 +00003542 (outs), (ins GR32:$src1, i32i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003543 "cmp{l}\t{$src2, $src1|$src1, $src2}",
Evan Chenge5f62042007-09-29 00:00:36 +00003544 [(X86cmp GR32:$src1, i32immSExt8:$src2),
Evan Cheng0488db92007-09-25 01:57:46 +00003545 (implicit EFLAGS)]>;
3546} // Defs = [EFLAGS]
3547
Dan Gohmanc7a37d42008-12-23 22:45:23 +00003548// Bit tests.
Dan Gohmanc7a37d42008-12-23 22:45:23 +00003549// TODO: BTC, BTR, and BTS
3550let Defs = [EFLAGS] in {
Dan Gohman0c89b7e2009-01-13 20:32:45 +00003551def BT16rr : I<0xA3, MRMDestReg, (outs), (ins GR16:$src1, GR16:$src2),
Dan Gohmanc7a37d42008-12-23 22:45:23 +00003552 "bt{w}\t{$src2, $src1|$src1, $src2}",
3553 [(X86bt GR16:$src1, GR16:$src2),
Chris Lattnerf1e9fd52008-12-25 01:32:49 +00003554 (implicit EFLAGS)]>, OpSize, TB;
Dan Gohman0c89b7e2009-01-13 20:32:45 +00003555def BT32rr : I<0xA3, MRMDestReg, (outs), (ins GR32:$src1, GR32:$src2),
Dan Gohmanc7a37d42008-12-23 22:45:23 +00003556 "bt{l}\t{$src2, $src1|$src1, $src2}",
3557 [(X86bt GR32:$src1, GR32:$src2),
Chris Lattnerf1e9fd52008-12-25 01:32:49 +00003558 (implicit EFLAGS)]>, TB;
Dan Gohmanf31408d2009-01-13 23:23:30 +00003559
3560// Unlike with the register+register form, the memory+register form of the
3561// bt instruction does not ignore the high bits of the index. From ISel's
Sean Callanan108934c2009-12-18 00:01:26 +00003562// perspective, this is pretty bizarre. Make these instructions disassembly
3563// only for now.
3564
3565def BT16mr : I<0xA3, MRMDestMem, (outs), (ins i16mem:$src1, GR16:$src2),
3566 "bt{w}\t{$src2, $src1|$src1, $src2}",
Dan Gohmanf31408d2009-01-13 23:23:30 +00003567// [(X86bt (loadi16 addr:$src1), GR16:$src2),
Sean Callanan108934c2009-12-18 00:01:26 +00003568// (implicit EFLAGS)]
3569 []
3570 >, OpSize, TB, Requires<[FastBTMem]>;
3571def BT32mr : I<0xA3, MRMDestMem, (outs), (ins i32mem:$src1, GR32:$src2),
3572 "bt{l}\t{$src2, $src1|$src1, $src2}",
Dan Gohmanf31408d2009-01-13 23:23:30 +00003573// [(X86bt (loadi32 addr:$src1), GR32:$src2),
Sean Callanan108934c2009-12-18 00:01:26 +00003574// (implicit EFLAGS)]
3575 []
3576 >, TB, Requires<[FastBTMem]>;
Dan Gohman4afe15b2009-01-13 20:33:23 +00003577
3578def BT16ri8 : Ii8<0xBA, MRM4r, (outs), (ins GR16:$src1, i16i8imm:$src2),
3579 "bt{w}\t{$src2, $src1|$src1, $src2}",
3580 [(X86bt GR16:$src1, i16immSExt8:$src2),
3581 (implicit EFLAGS)]>, OpSize, TB;
3582def BT32ri8 : Ii8<0xBA, MRM4r, (outs), (ins GR32:$src1, i32i8imm:$src2),
3583 "bt{l}\t{$src2, $src1|$src1, $src2}",
3584 [(X86bt GR32:$src1, i32immSExt8:$src2),
3585 (implicit EFLAGS)]>, TB;
3586// Note that these instructions don't need FastBTMem because that
3587// only applies when the other operand is in a register. When it's
3588// an immediate, bt is still fast.
3589def BT16mi8 : Ii8<0xBA, MRM4m, (outs), (ins i16mem:$src1, i16i8imm:$src2),
3590 "bt{w}\t{$src2, $src1|$src1, $src2}",
3591 [(X86bt (loadi16 addr:$src1), i16immSExt8:$src2),
3592 (implicit EFLAGS)]>, OpSize, TB;
3593def BT32mi8 : Ii8<0xBA, MRM4m, (outs), (ins i32mem:$src1, i32i8imm:$src2),
3594 "bt{l}\t{$src2, $src1|$src1, $src2}",
3595 [(X86bt (loadi32 addr:$src1), i32immSExt8:$src2),
3596 (implicit EFLAGS)]>, TB;
Sean Callanan108934c2009-12-18 00:01:26 +00003597
3598def BTC16rr : I<0xBB, MRMDestReg, (outs), (ins GR16:$src1, GR16:$src2),
3599 "btc{w}\t{$src2, $src1|$src1, $src2}", []>, OpSize, TB;
3600def BTC32rr : I<0xBB, MRMDestReg, (outs), (ins GR32:$src1, GR32:$src2),
3601 "btc{l}\t{$src2, $src1|$src1, $src2}", []>, TB;
3602def BTC16mr : I<0xBB, MRMDestMem, (outs), (ins i16mem:$src1, GR16:$src2),
3603 "btc{w}\t{$src2, $src1|$src1, $src2}", []>, OpSize, TB;
3604def BTC32mr : I<0xBB, MRMDestMem, (outs), (ins i32mem:$src1, GR32:$src2),
3605 "btc{l}\t{$src2, $src1|$src1, $src2}", []>, TB;
3606def BTC16ri8 : Ii8<0xBA, MRM7r, (outs), (ins GR16:$src1, i16i8imm:$src2),
3607 "btc{w}\t{$src2, $src1|$src1, $src2}", []>, OpSize, TB;
3608def BTC32ri8 : Ii8<0xBA, MRM7r, (outs), (ins GR32:$src1, i32i8imm:$src2),
3609 "btc{l}\t{$src2, $src1|$src1, $src2}", []>, TB;
3610def BTC16mi8 : Ii8<0xBA, MRM7m, (outs), (ins i16mem:$src1, i16i8imm:$src2),
3611 "btc{w}\t{$src2, $src1|$src1, $src2}", []>, OpSize, TB;
3612def BTC32mi8 : Ii8<0xBA, MRM7m, (outs), (ins i32mem:$src1, i32i8imm:$src2),
3613 "btc{l}\t{$src2, $src1|$src1, $src2}", []>, TB;
3614
3615def BTR16rr : I<0xB3, MRMDestReg, (outs), (ins GR16:$src1, GR16:$src2),
3616 "btr{w}\t{$src2, $src1|$src1, $src2}", []>, OpSize, TB;
3617def BTR32rr : I<0xB3, MRMDestReg, (outs), (ins GR32:$src1, GR32:$src2),
3618 "btr{l}\t{$src2, $src1|$src1, $src2}", []>, TB;
3619def BTR16mr : I<0xB3, MRMDestMem, (outs), (ins i16mem:$src1, GR16:$src2),
3620 "btr{w}\t{$src2, $src1|$src1, $src2}", []>, OpSize, TB;
3621def BTR32mr : I<0xB3, MRMDestMem, (outs), (ins i32mem:$src1, GR32:$src2),
3622 "btr{l}\t{$src2, $src1|$src1, $src2}", []>, TB;
3623def BTR16ri8 : Ii8<0xBA, MRM6r, (outs), (ins GR16:$src1, i16i8imm:$src2),
3624 "btr{w}\t{$src2, $src1|$src1, $src2}", []>, OpSize, TB;
3625def BTR32ri8 : Ii8<0xBA, MRM6r, (outs), (ins GR32:$src1, i32i8imm:$src2),
3626 "btr{l}\t{$src2, $src1|$src1, $src2}", []>, TB;
3627def BTR16mi8 : Ii8<0xBA, MRM6m, (outs), (ins i16mem:$src1, i16i8imm:$src2),
3628 "btr{w}\t{$src2, $src1|$src1, $src2}", []>, OpSize, TB;
3629def BTR32mi8 : Ii8<0xBA, MRM6m, (outs), (ins i32mem:$src1, i32i8imm:$src2),
3630 "btr{l}\t{$src2, $src1|$src1, $src2}", []>, TB;
3631
3632def BTS16rr : I<0xAB, MRMDestReg, (outs), (ins GR16:$src1, GR16:$src2),
3633 "bts{w}\t{$src2, $src1|$src1, $src2}", []>, OpSize, TB;
3634def BTS32rr : I<0xAB, MRMDestReg, (outs), (ins GR32:$src1, GR32:$src2),
3635 "bts{l}\t{$src2, $src1|$src1, $src2}", []>, TB;
3636def BTS16mr : I<0xAB, MRMDestMem, (outs), (ins i16mem:$src1, GR16:$src2),
3637 "bts{w}\t{$src2, $src1|$src1, $src2}", []>, OpSize, TB;
3638def BTS32mr : I<0xAB, MRMDestMem, (outs), (ins i32mem:$src1, GR32:$src2),
3639 "bts{l}\t{$src2, $src1|$src1, $src2}", []>, TB;
3640def BTS16ri8 : Ii8<0xBA, MRM5r, (outs), (ins GR16:$src1, i16i8imm:$src2),
3641 "bts{w}\t{$src2, $src1|$src1, $src2}", []>, OpSize, TB;
3642def BTS32ri8 : Ii8<0xBA, MRM5r, (outs), (ins GR32:$src1, i32i8imm:$src2),
3643 "bts{l}\t{$src2, $src1|$src1, $src2}", []>, TB;
3644def BTS16mi8 : Ii8<0xBA, MRM5m, (outs), (ins i16mem:$src1, i16i8imm:$src2),
3645 "bts{w}\t{$src2, $src1|$src1, $src2}", []>, OpSize, TB;
3646def BTS32mi8 : Ii8<0xBA, MRM5m, (outs), (ins i32mem:$src1, i32i8imm:$src2),
3647 "bts{l}\t{$src2, $src1|$src1, $src2}", []>, TB;
Dan Gohmanc7a37d42008-12-23 22:45:23 +00003648} // Defs = [EFLAGS]
3649
Chris Lattner1cca5e32003-08-03 21:54:21 +00003650// Sign/Zero extenders
Dan Gohman11ba3b12008-07-30 18:09:17 +00003651// Use movsbl intead of movsbw; we don't care about the high 16 bits
3652// of the register here. This has a smaller encoding and avoids a
Sean Callanan108934c2009-12-18 00:01:26 +00003653// partial-register update. Actual movsbw included for the disassembler.
3654def MOVSX16rr8W : I<0xBE, MRMSrcReg, (outs GR16:$dst), (ins GR8:$src),
3655 "movs{bw|x}\t{$src, $dst|$dst, $src}", []>, TB, OpSize;
3656def MOVSX16rm8W : I<0xBE, MRMSrcMem, (outs GR16:$dst), (ins i8mem:$src),
3657 "movs{bw|x}\t{$src, $dst|$dst, $src}", []>, TB, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00003658def MOVSX16rr8 : I<0xBE, MRMSrcReg, (outs GR16:$dst), (ins GR8 :$src),
Chris Lattner172862a2009-10-19 19:51:42 +00003659 "", [(set GR16:$dst, (sext GR8:$src))]>, TB;
Evan Cheng64d80e32007-07-19 01:14:50 +00003660def MOVSX16rm8 : I<0xBE, MRMSrcMem, (outs GR16:$dst), (ins i8mem :$src),
Chris Lattner172862a2009-10-19 19:51:42 +00003661 "", [(set GR16:$dst, (sextloadi16i8 addr:$src))]>, TB;
Evan Cheng64d80e32007-07-19 01:14:50 +00003662def MOVSX32rr8 : I<0xBE, MRMSrcReg, (outs GR32:$dst), (ins GR8 :$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003663 "movs{bl|x}\t{$src, $dst|$dst, $src}",
Evan Cheng069287d2006-05-16 07:21:53 +00003664 [(set GR32:$dst, (sext GR8:$src))]>, TB;
Evan Cheng64d80e32007-07-19 01:14:50 +00003665def MOVSX32rm8 : I<0xBE, MRMSrcMem, (outs GR32:$dst), (ins i8mem :$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003666 "movs{bl|x}\t{$src, $dst|$dst, $src}",
Evan Cheng069287d2006-05-16 07:21:53 +00003667 [(set GR32:$dst, (sextloadi32i8 addr:$src))]>, TB;
Evan Cheng64d80e32007-07-19 01:14:50 +00003668def MOVSX32rr16: I<0xBF, MRMSrcReg, (outs GR32:$dst), (ins GR16:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003669 "movs{wl|x}\t{$src, $dst|$dst, $src}",
Evan Cheng069287d2006-05-16 07:21:53 +00003670 [(set GR32:$dst, (sext GR16:$src))]>, TB;
Evan Cheng64d80e32007-07-19 01:14:50 +00003671def MOVSX32rm16: I<0xBF, MRMSrcMem, (outs GR32:$dst), (ins i16mem:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003672 "movs{wl|x}\t{$src, $dst|$dst, $src}",
Evan Cheng069287d2006-05-16 07:21:53 +00003673 [(set GR32:$dst, (sextloadi32i16 addr:$src))]>, TB;
Alkis Evlogimenosa7be9822004-02-17 09:14:23 +00003674
Dan Gohman11ba3b12008-07-30 18:09:17 +00003675// Use movzbl intead of movzbw; we don't care about the high 16 bits
3676// of the register here. This has a smaller encoding and avoids a
Sean Callanan108934c2009-12-18 00:01:26 +00003677// partial-register update. Actual movzbw included for the disassembler.
3678def MOVZX16rr8W : I<0xB6, MRMSrcReg, (outs GR16:$dst), (ins GR8:$src),
3679 "movz{bw|x}\t{$src, $dst|$dst, $src}", []>, TB, OpSize;
3680def MOVZX16rm8W : I<0xB6, MRMSrcMem, (outs GR16:$dst), (ins i8mem:$src),
3681 "movz{bw|x}\t{$src, $dst|$dst, $src}", []>, TB, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00003682def MOVZX16rr8 : I<0xB6, MRMSrcReg, (outs GR16:$dst), (ins GR8 :$src),
Chris Lattner172862a2009-10-19 19:51:42 +00003683 "", [(set GR16:$dst, (zext GR8:$src))]>, TB;
Evan Cheng64d80e32007-07-19 01:14:50 +00003684def MOVZX16rm8 : I<0xB6, MRMSrcMem, (outs GR16:$dst), (ins i8mem :$src),
Chris Lattner172862a2009-10-19 19:51:42 +00003685 "", [(set GR16:$dst, (zextloadi16i8 addr:$src))]>, TB;
Evan Cheng64d80e32007-07-19 01:14:50 +00003686def MOVZX32rr8 : I<0xB6, MRMSrcReg, (outs GR32:$dst), (ins GR8 :$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003687 "movz{bl|x}\t{$src, $dst|$dst, $src}",
Evan Cheng069287d2006-05-16 07:21:53 +00003688 [(set GR32:$dst, (zext GR8:$src))]>, TB;
Evan Cheng64d80e32007-07-19 01:14:50 +00003689def MOVZX32rm8 : I<0xB6, MRMSrcMem, (outs GR32:$dst), (ins i8mem :$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003690 "movz{bl|x}\t{$src, $dst|$dst, $src}",
Evan Cheng069287d2006-05-16 07:21:53 +00003691 [(set GR32:$dst, (zextloadi32i8 addr:$src))]>, TB;
Evan Cheng64d80e32007-07-19 01:14:50 +00003692def MOVZX32rr16: I<0xB7, MRMSrcReg, (outs GR32:$dst), (ins GR16:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003693 "movz{wl|x}\t{$src, $dst|$dst, $src}",
Evan Cheng069287d2006-05-16 07:21:53 +00003694 [(set GR32:$dst, (zext GR16:$src))]>, TB;
Evan Cheng64d80e32007-07-19 01:14:50 +00003695def MOVZX32rm16: I<0xB7, MRMSrcMem, (outs GR32:$dst), (ins i16mem:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003696 "movz{wl|x}\t{$src, $dst|$dst, $src}",
Evan Cheng069287d2006-05-16 07:21:53 +00003697 [(set GR32:$dst, (zextloadi32i16 addr:$src))]>, TB;
Evan Cheng7a7e8372005-12-14 02:22:27 +00003698
Dan Gohmanf451cb82010-02-10 16:03:48 +00003699// These are the same as the regular MOVZX32rr8 and MOVZX32rm8
Dan Gohman21e3dfb2009-04-13 16:09:41 +00003700// except that they use GR32_NOREX for the output operand register class
3701// instead of GR32. This allows them to operate on h registers on x86-64.
3702def MOVZX32_NOREXrr8 : I<0xB6, MRMSrcReg,
3703 (outs GR32_NOREX:$dst), (ins GR8:$src),
3704 "movz{bl|x}\t{$src, $dst|$dst, $src} # NOREX",
3705 []>, TB;
Dan Gohman78e04d42009-04-30 03:11:48 +00003706let mayLoad = 1 in
Dan Gohman21e3dfb2009-04-13 16:09:41 +00003707def MOVZX32_NOREXrm8 : I<0xB6, MRMSrcMem,
3708 (outs GR32_NOREX:$dst), (ins i8mem:$src),
3709 "movz{bl|x}\t{$src, $dst|$dst, $src} # NOREX",
3710 []>, TB;
3711
Chris Lattnerba7e7562008-01-10 07:59:24 +00003712let neverHasSideEffects = 1 in {
3713 let Defs = [AX], Uses = [AL] in
3714 def CBW : I<0x98, RawFrm, (outs), (ins),
3715 "{cbtw|cbw}", []>, OpSize; // AX = signext(AL)
3716 let Defs = [EAX], Uses = [AX] in
3717 def CWDE : I<0x98, RawFrm, (outs), (ins),
3718 "{cwtl|cwde}", []>; // EAX = signext(AX)
Evan Chengf91c1012006-05-31 22:05:11 +00003719
Chris Lattnerba7e7562008-01-10 07:59:24 +00003720 let Defs = [AX,DX], Uses = [AX] in
3721 def CWD : I<0x99, RawFrm, (outs), (ins),
3722 "{cwtd|cwd}", []>, OpSize; // DX:AX = signext(AX)
3723 let Defs = [EAX,EDX], Uses = [EAX] in
3724 def CDQ : I<0x99, RawFrm, (outs), (ins),
3725 "{cltd|cdq}", []>; // EDX:EAX = signext(EAX)
3726}
Evan Cheng747a90d2006-02-21 02:24:38 +00003727
Evan Cheng747a90d2006-02-21 02:24:38 +00003728//===----------------------------------------------------------------------===//
3729// Alias Instructions
3730//===----------------------------------------------------------------------===//
3731
3732// Alias instructions that map movr0 to xor.
3733// FIXME: remove when we can teach regalloc that xor reg, reg is ok.
Chris Lattner35e0e842010-02-05 21:21:06 +00003734// FIXME: Set encoding to pseudo.
Daniel Dunbar7417b762009-08-11 22:17:52 +00003735let Defs = [EFLAGS], isReMaterializable = 1, isAsCheapAsAMove = 1,
3736 isCodeGenOnly = 1 in {
Chris Lattner35e0e842010-02-05 21:21:06 +00003737def MOV8r0 : I<0x30, MRMInitReg, (outs GR8 :$dst), (ins), "",
Evan Cheng069287d2006-05-16 07:21:53 +00003738 [(set GR8:$dst, 0)]>;
Dan Gohmanf1b4d262010-01-12 04:42:54 +00003739
3740// We want to rewrite MOV16r0 in terms of MOV32r0, because it's a smaller
3741// encoding and avoids a partial-register update sometimes, but doing so
3742// at isel time interferes with rematerialization in the current register
3743// allocator. For now, this is rewritten when the instruction is lowered
3744// to an MCInst.
3745def MOV16r0 : I<0x31, MRMInitReg, (outs GR16:$dst), (ins),
3746 "",
3747 [(set GR16:$dst, 0)]>, OpSize;
Chris Lattner6a381822009-12-23 01:30:26 +00003748
Chris Lattner35e0e842010-02-05 21:21:06 +00003749// FIXME: Set encoding to pseudo.
3750def MOV32r0 : I<0x31, MRMInitReg, (outs GR32:$dst), (ins), "",
Chris Lattnerac105c42009-12-23 01:46:40 +00003751 [(set GR32:$dst, 0)]>;
3752}
Chris Lattner6a381822009-12-23 01:30:26 +00003753
Evan Cheng510e4782006-01-09 23:10:28 +00003754//===----------------------------------------------------------------------===//
Lauro Ramos Venanciob3a04172007-04-20 21:38:10 +00003755// Thread Local Storage Instructions
3756//
3757
Rafael Espindola15f1b662009-04-24 12:59:40 +00003758// All calls clobber the non-callee saved registers. ESP is marked as
3759// a use to prevent stack-pointer assignments that appear immediately
3760// before calls from potentially appearing dead.
3761let Defs = [EAX, ECX, EDX, FP0, FP1, FP2, FP3, FP4, FP5, FP6, ST0,
3762 MM0, MM1, MM2, MM3, MM4, MM5, MM6, MM7,
3763 XMM0, XMM1, XMM2, XMM3, XMM4, XMM5, XMM6, XMM7,
3764 XMM8, XMM9, XMM10, XMM11, XMM12, XMM13, XMM14, XMM15, EFLAGS],
Chris Lattner5c0b16d2009-06-20 20:38:48 +00003765 Uses = [ESP] in
3766def TLS_addr32 : I<0, Pseudo, (outs), (ins lea32mem:$sym),
3767 "leal\t$sym, %eax; "
Dan Gohman4d47b9b2009-04-27 15:13:28 +00003768 "call\t___tls_get_addr@PLT",
Chris Lattner5c0b16d2009-06-20 20:38:48 +00003769 [(X86tlsaddr tls32addr:$sym)]>,
Rafael Espindola2ee3db32009-04-17 14:35:58 +00003770 Requires<[In32BitMode]>;
Lauro Ramos Venanciob3a04172007-04-20 21:38:10 +00003771
Daniel Dunbar0c420fc2009-08-11 22:24:40 +00003772let AddedComplexity = 5, isCodeGenOnly = 1 in
Nate Begeman51a04372009-01-26 01:24:32 +00003773def GS_MOV32rm : I<0x8B, MRMSrcMem, (outs GR32:$dst), (ins i32mem:$src),
3774 "movl\t%gs:$src, $dst",
3775 [(set GR32:$dst, (gsload addr:$src))]>, SegGS;
3776
Daniel Dunbar0c420fc2009-08-11 22:24:40 +00003777let AddedComplexity = 5, isCodeGenOnly = 1 in
Chris Lattner1777d0c2009-05-05 18:52:19 +00003778def FS_MOV32rm : I<0x8B, MRMSrcMem, (outs GR32:$dst), (ins i32mem:$src),
3779 "movl\t%fs:$src, $dst",
3780 [(set GR32:$dst, (fsload addr:$src))]>, SegFS;
3781
Lauro Ramos Venanciob3a04172007-04-20 21:38:10 +00003782//===----------------------------------------------------------------------===//
Anton Korobeynikov2365f512007-07-14 14:06:15 +00003783// EH Pseudo Instructions
3784//
3785let isTerminator = 1, isReturn = 1, isBarrier = 1,
Daniel Dunbar1ca3a0b2009-08-27 07:58:05 +00003786 hasCtrlDep = 1, isCodeGenOnly = 1 in {
Evan Cheng64d80e32007-07-19 01:14:50 +00003787def EH_RETURN : I<0xC3, RawFrm, (outs), (ins GR32:$addr),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003788 "ret\t#eh_return, addr: $addr",
Anton Korobeynikov2365f512007-07-14 14:06:15 +00003789 [(X86ehret GR32:$addr)]>;
3790
3791}
3792
3793//===----------------------------------------------------------------------===//
Andrew Lenharthab0b9492008-02-21 06:45:13 +00003794// Atomic support
3795//
Andrew Lenharthea7da502008-03-01 13:37:02 +00003796
Evan Chengbb6939d2008-04-19 01:20:30 +00003797// Atomic swap. These are just normal xchg instructions. But since a memory
3798// operand is referenced, the atomicity is ensured.
Dan Gohman165660e2008-08-06 15:52:50 +00003799let Constraints = "$val = $dst" in {
Sean Callanan108934c2009-12-18 00:01:26 +00003800def XCHG32rm : I<0x87, MRMSrcMem, (outs GR32:$dst),
3801 (ins GR32:$val, i32mem:$ptr),
Evan Chengbb6939d2008-04-19 01:20:30 +00003802 "xchg{l}\t{$val, $ptr|$ptr, $val}",
3803 [(set GR32:$dst, (atomic_swap_32 addr:$ptr, GR32:$val))]>;
Sean Callanan108934c2009-12-18 00:01:26 +00003804def XCHG16rm : I<0x87, MRMSrcMem, (outs GR16:$dst),
3805 (ins GR16:$val, i16mem:$ptr),
Evan Chengbb6939d2008-04-19 01:20:30 +00003806 "xchg{w}\t{$val, $ptr|$ptr, $val}",
3807 [(set GR16:$dst, (atomic_swap_16 addr:$ptr, GR16:$val))]>,
3808 OpSize;
Sean Callanan108934c2009-12-18 00:01:26 +00003809def XCHG8rm : I<0x86, MRMSrcMem, (outs GR8:$dst), (ins GR8:$val, i8mem:$ptr),
Evan Chengbb6939d2008-04-19 01:20:30 +00003810 "xchg{b}\t{$val, $ptr|$ptr, $val}",
3811 [(set GR8:$dst, (atomic_swap_8 addr:$ptr, GR8:$val))]>;
Sean Callanan108934c2009-12-18 00:01:26 +00003812
3813def XCHG32rr : I<0x87, MRMSrcReg, (outs GR32:$dst), (ins GR32:$val, GR32:$src),
3814 "xchg{l}\t{$val, $src|$src, $val}", []>;
3815def XCHG16rr : I<0x87, MRMSrcReg, (outs GR16:$dst), (ins GR16:$val, GR16:$src),
3816 "xchg{w}\t{$val, $src|$src, $val}", []>, OpSize;
3817def XCHG8rr : I<0x86, MRMSrcReg, (outs GR8:$dst), (ins GR8:$val, GR8:$src),
3818 "xchg{b}\t{$val, $src|$src, $val}", []>;
Evan Chengbb6939d2008-04-19 01:20:30 +00003819}
3820
Sean Callanan108934c2009-12-18 00:01:26 +00003821def XCHG16ar : I<0x90, AddRegFrm, (outs), (ins GR16:$src),
3822 "xchg{w}\t{$src, %ax|%ax, $src}", []>, OpSize;
3823def XCHG32ar : I<0x90, AddRegFrm, (outs), (ins GR32:$src),
3824 "xchg{l}\t{$src, %eax|%eax, $src}", []>;
3825
Evan Cheng7e032802008-04-18 20:55:36 +00003826// Atomic compare and swap.
Andrew Lenharth26ed8692008-03-01 21:52:34 +00003827let Defs = [EAX, EFLAGS], Uses = [EAX] in {
Evan Cheng7e032802008-04-18 20:55:36 +00003828def LCMPXCHG32 : I<0xB1, MRMDestMem, (outs), (ins i32mem:$ptr, GR32:$swap),
Dan Gohman4d47b9b2009-04-27 15:13:28 +00003829 "lock\n\t"
3830 "cmpxchg{l}\t{$swap, $ptr|$ptr, $swap}",
Evan Cheng32967d22008-03-04 03:20:06 +00003831 [(X86cas addr:$ptr, GR32:$swap, 4)]>, TB, LOCK;
Andrew Lenharthea7da502008-03-01 13:37:02 +00003832}
Dale Johannesen48c1bc22008-10-02 18:53:47 +00003833let Defs = [EAX, EDX, EFLAGS], Uses = [EAX, EBX, ECX, EDX] in {
Evan Chengb093bd02010-01-08 01:29:19 +00003834def LCMPXCHG8B : I<0xC7, MRM1m, (outs), (ins i64mem:$ptr),
Dan Gohman4d47b9b2009-04-27 15:13:28 +00003835 "lock\n\t"
3836 "cmpxchg8b\t$ptr",
Andrew Lenharthd19189e2008-03-05 01:15:49 +00003837 [(X86cas8 addr:$ptr)]>, TB, LOCK;
3838}
Andrew Lenharth26ed8692008-03-01 21:52:34 +00003839
3840let Defs = [AX, EFLAGS], Uses = [AX] in {
Evan Cheng7e032802008-04-18 20:55:36 +00003841def LCMPXCHG16 : I<0xB1, MRMDestMem, (outs), (ins i16mem:$ptr, GR16:$swap),
Dan Gohman4d47b9b2009-04-27 15:13:28 +00003842 "lock\n\t"
3843 "cmpxchg{w}\t{$swap, $ptr|$ptr, $swap}",
Evan Cheng32967d22008-03-04 03:20:06 +00003844 [(X86cas addr:$ptr, GR16:$swap, 2)]>, TB, OpSize, LOCK;
Andrew Lenharthea7da502008-03-01 13:37:02 +00003845}
Andrew Lenharth26ed8692008-03-01 21:52:34 +00003846let Defs = [AL, EFLAGS], Uses = [AL] in {
Evan Cheng7e032802008-04-18 20:55:36 +00003847def LCMPXCHG8 : I<0xB0, MRMDestMem, (outs), (ins i8mem:$ptr, GR8:$swap),
Dan Gohman4d47b9b2009-04-27 15:13:28 +00003848 "lock\n\t"
3849 "cmpxchg{b}\t{$swap, $ptr|$ptr, $swap}",
Evan Cheng32967d22008-03-04 03:20:06 +00003850 [(X86cas addr:$ptr, GR8:$swap, 1)]>, TB, LOCK;
Andrew Lenharthea7da502008-03-01 13:37:02 +00003851}
3852
Evan Cheng7e032802008-04-18 20:55:36 +00003853// Atomic exchange and add
3854let Constraints = "$val = $dst", Defs = [EFLAGS] in {
Sean Callanan108934c2009-12-18 00:01:26 +00003855def LXADD32 : I<0xC1, MRMSrcMem, (outs GR32:$dst), (ins GR32:$val, i32mem:$ptr),
Dan Gohman4d47b9b2009-04-27 15:13:28 +00003856 "lock\n\t"
3857 "xadd{l}\t{$val, $ptr|$ptr, $val}",
Mon P Wang28873102008-06-25 08:15:39 +00003858 [(set GR32:$dst, (atomic_load_add_32 addr:$ptr, GR32:$val))]>,
Evan Cheng7e032802008-04-18 20:55:36 +00003859 TB, LOCK;
Sean Callanan108934c2009-12-18 00:01:26 +00003860def LXADD16 : I<0xC1, MRMSrcMem, (outs GR16:$dst), (ins GR16:$val, i16mem:$ptr),
Dan Gohman4d47b9b2009-04-27 15:13:28 +00003861 "lock\n\t"
3862 "xadd{w}\t{$val, $ptr|$ptr, $val}",
Mon P Wang28873102008-06-25 08:15:39 +00003863 [(set GR16:$dst, (atomic_load_add_16 addr:$ptr, GR16:$val))]>,
Evan Cheng7e032802008-04-18 20:55:36 +00003864 TB, OpSize, LOCK;
Sean Callanan108934c2009-12-18 00:01:26 +00003865def LXADD8 : I<0xC0, MRMSrcMem, (outs GR8:$dst), (ins GR8:$val, i8mem:$ptr),
Dan Gohman4d47b9b2009-04-27 15:13:28 +00003866 "lock\n\t"
3867 "xadd{b}\t{$val, $ptr|$ptr, $val}",
Mon P Wang28873102008-06-25 08:15:39 +00003868 [(set GR8:$dst, (atomic_load_add_8 addr:$ptr, GR8:$val))]>,
Evan Cheng7e032802008-04-18 20:55:36 +00003869 TB, LOCK;
Andrew Lenharthea7da502008-03-01 13:37:02 +00003870}
3871
Sean Callanan108934c2009-12-18 00:01:26 +00003872def XADD8rr : I<0xC0, MRMDestReg, (outs GR8:$dst), (ins GR8:$src),
3873 "xadd{b}\t{$src, $dst|$dst, $src}", []>, TB;
3874def XADD16rr : I<0xC1, MRMDestReg, (outs GR16:$dst), (ins GR16:$src),
3875 "xadd{w}\t{$src, $dst|$dst, $src}", []>, TB, OpSize;
3876def XADD32rr : I<0xC1, MRMDestReg, (outs GR32:$dst), (ins GR32:$src),
3877 "xadd{l}\t{$src, $dst|$dst, $src}", []>, TB;
3878
3879def XADD8rm : I<0xC0, MRMDestMem, (outs), (ins i8mem:$dst, GR8:$src),
3880 "xadd{b}\t{$src, $dst|$dst, $src}", []>, TB;
3881def XADD16rm : I<0xC1, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src),
3882 "xadd{w}\t{$src, $dst|$dst, $src}", []>, TB, OpSize;
3883def XADD32rm : I<0xC1, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src),
3884 "xadd{l}\t{$src, $dst|$dst, $src}", []>, TB;
3885
3886def CMPXCHG8rr : I<0xB0, MRMDestReg, (outs GR8:$dst), (ins GR8:$src),
3887 "cmpxchg{b}\t{$src, $dst|$dst, $src}", []>, TB;
3888def CMPXCHG16rr : I<0xB1, MRMDestReg, (outs GR16:$dst), (ins GR16:$src),
3889 "cmpxchg{w}\t{$src, $dst|$dst, $src}", []>, TB, OpSize;
3890def CMPXCHG32rr : I<0xB1, MRMDestReg, (outs GR32:$dst), (ins GR32:$src),
3891 "cmpxchg{l}\t{$src, $dst|$dst, $src}", []>, TB;
3892
3893def CMPXCHG8rm : I<0xB0, MRMDestMem, (outs), (ins i8mem:$dst, GR8:$src),
3894 "cmpxchg{b}\t{$src, $dst|$dst, $src}", []>, TB;
3895def CMPXCHG16rm : I<0xB1, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src),
3896 "cmpxchg{w}\t{$src, $dst|$dst, $src}", []>, TB, OpSize;
3897def CMPXCHG32rm : I<0xB1, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src),
3898 "cmpxchg{l}\t{$src, $dst|$dst, $src}", []>, TB;
3899
Evan Chengb093bd02010-01-08 01:29:19 +00003900let Defs = [EAX, EDX, EFLAGS], Uses = [EAX, EBX, ECX, EDX] in
Sean Callanan108934c2009-12-18 00:01:26 +00003901def CMPXCHG8B : I<0xC7, MRM1m, (outs), (ins i64mem:$dst),
3902 "cmpxchg8b\t$dst", []>, TB;
3903
Evan Cheng37b73872009-07-30 08:33:02 +00003904// Optimized codegen when the non-memory output is not used.
3905// FIXME: Use normal add / sub instructions and add lock prefix dynamically.
Dan Gohmanbab42bd2009-10-20 18:14:49 +00003906let Defs = [EFLAGS] in {
Evan Cheng37b73872009-07-30 08:33:02 +00003907def LOCK_ADD8mr : I<0x00, MRMDestMem, (outs), (ins i8mem:$dst, GR8:$src2),
3908 "lock\n\t"
3909 "add{b}\t{$src2, $dst|$dst, $src2}", []>, LOCK;
3910def LOCK_ADD16mr : I<0x01, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
3911 "lock\n\t"
3912 "add{w}\t{$src2, $dst|$dst, $src2}", []>, OpSize, LOCK;
3913def LOCK_ADD32mr : I<0x01, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
3914 "lock\n\t"
3915 "add{l}\t{$src2, $dst|$dst, $src2}", []>, LOCK;
3916def LOCK_ADD8mi : Ii8<0x80, MRM0m, (outs), (ins i8mem :$dst, i8imm :$src2),
3917 "lock\n\t"
3918 "add{b}\t{$src2, $dst|$dst, $src2}", []>, LOCK;
3919def LOCK_ADD16mi : Ii16<0x81, MRM0m, (outs), (ins i16mem:$dst, i16imm:$src2),
3920 "lock\n\t"
3921 "add{w}\t{$src2, $dst|$dst, $src2}", []>, LOCK;
3922def LOCK_ADD32mi : Ii32<0x81, MRM0m, (outs), (ins i32mem:$dst, i32imm:$src2),
3923 "lock\n\t"
3924 "add{l}\t{$src2, $dst|$dst, $src2}", []>, LOCK;
3925def LOCK_ADD16mi8 : Ii8<0x83, MRM0m, (outs), (ins i16mem:$dst, i16i8imm :$src2),
3926 "lock\n\t"
3927 "add{w}\t{$src2, $dst|$dst, $src2}", []>, OpSize, LOCK;
3928def LOCK_ADD32mi8 : Ii8<0x83, MRM0m, (outs), (ins i32mem:$dst, i32i8imm :$src2),
3929 "lock\n\t"
3930 "add{l}\t{$src2, $dst|$dst, $src2}", []>, LOCK;
3931
3932def LOCK_INC8m : I<0xFE, MRM0m, (outs), (ins i8mem :$dst),
3933 "lock\n\t"
3934 "inc{b}\t$dst", []>, LOCK;
3935def LOCK_INC16m : I<0xFF, MRM0m, (outs), (ins i16mem:$dst),
3936 "lock\n\t"
3937 "inc{w}\t$dst", []>, OpSize, LOCK;
3938def LOCK_INC32m : I<0xFF, MRM0m, (outs), (ins i32mem:$dst),
3939 "lock\n\t"
3940 "inc{l}\t$dst", []>, LOCK;
3941
3942def LOCK_SUB8mr : I<0x28, MRMDestMem, (outs), (ins i8mem :$dst, GR8 :$src2),
3943 "lock\n\t"
3944 "sub{b}\t{$src2, $dst|$dst, $src2}", []>, LOCK;
3945def LOCK_SUB16mr : I<0x29, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
3946 "lock\n\t"
3947 "sub{w}\t{$src2, $dst|$dst, $src2}", []>, OpSize, LOCK;
3948def LOCK_SUB32mr : I<0x29, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
3949 "lock\n\t"
3950 "sub{l}\t{$src2, $dst|$dst, $src2}", []>, LOCK;
3951def LOCK_SUB8mi : Ii8<0x80, MRM5m, (outs), (ins i8mem :$dst, i8imm:$src2),
3952 "lock\n\t"
3953 "sub{b}\t{$src2, $dst|$dst, $src2}", []>, LOCK;
3954def LOCK_SUB16mi : Ii16<0x81, MRM5m, (outs), (ins i16mem:$dst, i16imm:$src2),
3955 "lock\n\t"
3956 "sub{w}\t{$src2, $dst|$dst, $src2}", []>, OpSize, LOCK;
3957def LOCK_SUB32mi : Ii32<0x81, MRM5m, (outs), (ins i32mem:$dst, i32imm:$src2),
3958 "lock\n\t"
3959 "sub{l}\t{$src2, $dst|$dst, $src2}", []>, LOCK;
Sean Callanan108934c2009-12-18 00:01:26 +00003960def LOCK_SUB16mi8 : Ii8<0x83, MRM5m, (outs), (ins i16mem:$dst, i16i8imm :$src2),
Evan Cheng37b73872009-07-30 08:33:02 +00003961 "lock\n\t"
3962 "sub{w}\t{$src2, $dst|$dst, $src2}", []>, OpSize, LOCK;
3963def LOCK_SUB32mi8 : Ii8<0x83, MRM5m, (outs), (ins i32mem:$dst, i32i8imm :$src2),
3964 "lock\n\t"
3965 "sub{l}\t{$src2, $dst|$dst, $src2}", []>, LOCK;
3966
3967def LOCK_DEC8m : I<0xFE, MRM1m, (outs), (ins i8mem :$dst),
3968 "lock\n\t"
3969 "dec{b}\t$dst", []>, LOCK;
3970def LOCK_DEC16m : I<0xFF, MRM1m, (outs), (ins i16mem:$dst),
3971 "lock\n\t"
3972 "dec{w}\t$dst", []>, OpSize, LOCK;
3973def LOCK_DEC32m : I<0xFF, MRM1m, (outs), (ins i32mem:$dst),
3974 "lock\n\t"
3975 "dec{l}\t$dst", []>, LOCK;
Dan Gohmanbab42bd2009-10-20 18:14:49 +00003976}
Evan Cheng37b73872009-07-30 08:33:02 +00003977
Mon P Wang28873102008-06-25 08:15:39 +00003978// Atomic exchange, and, or, xor
Mon P Wang63307c32008-05-05 19:05:59 +00003979let Constraints = "$val = $dst", Defs = [EFLAGS],
Dan Gohman533297b2009-10-29 18:10:34 +00003980 usesCustomInserter = 1 in {
Dan Gohman9499b712008-05-12 20:22:45 +00003981def ATOMAND32 : I<0, Pseudo, (outs GR32:$dst),(ins i32mem:$ptr, GR32:$val),
Nick Lewycky6ecf5ce2008-12-07 03:49:52 +00003982 "#ATOMAND32 PSEUDO!",
Dale Johannesene00a8a22008-08-28 02:44:49 +00003983 [(set GR32:$dst, (atomic_load_and_32 addr:$ptr, GR32:$val))]>;
Dan Gohman9499b712008-05-12 20:22:45 +00003984def ATOMOR32 : I<0, Pseudo, (outs GR32:$dst),(ins i32mem:$ptr, GR32:$val),
Nick Lewycky6ecf5ce2008-12-07 03:49:52 +00003985 "#ATOMOR32 PSEUDO!",
Dale Johannesene00a8a22008-08-28 02:44:49 +00003986 [(set GR32:$dst, (atomic_load_or_32 addr:$ptr, GR32:$val))]>;
Dan Gohman9499b712008-05-12 20:22:45 +00003987def ATOMXOR32 : I<0, Pseudo,(outs GR32:$dst),(ins i32mem:$ptr, GR32:$val),
Nick Lewycky6ecf5ce2008-12-07 03:49:52 +00003988 "#ATOMXOR32 PSEUDO!",
Dale Johannesene00a8a22008-08-28 02:44:49 +00003989 [(set GR32:$dst, (atomic_load_xor_32 addr:$ptr, GR32:$val))]>;
Andrew Lenharth507a58a2008-06-14 05:48:15 +00003990def ATOMNAND32 : I<0, Pseudo,(outs GR32:$dst),(ins i32mem:$ptr, GR32:$val),
Nick Lewycky6ecf5ce2008-12-07 03:49:52 +00003991 "#ATOMNAND32 PSEUDO!",
Dale Johannesene00a8a22008-08-28 02:44:49 +00003992 [(set GR32:$dst, (atomic_load_nand_32 addr:$ptr, GR32:$val))]>;
Dan Gohman9499b712008-05-12 20:22:45 +00003993def ATOMMIN32: I<0, Pseudo, (outs GR32:$dst), (ins i32mem:$ptr, GR32:$val),
Nick Lewycky6ecf5ce2008-12-07 03:49:52 +00003994 "#ATOMMIN32 PSEUDO!",
Dale Johannesene00a8a22008-08-28 02:44:49 +00003995 [(set GR32:$dst, (atomic_load_min_32 addr:$ptr, GR32:$val))]>;
Dan Gohman9499b712008-05-12 20:22:45 +00003996def ATOMMAX32: I<0, Pseudo, (outs GR32:$dst),(ins i32mem:$ptr, GR32:$val),
Nick Lewycky6ecf5ce2008-12-07 03:49:52 +00003997 "#ATOMMAX32 PSEUDO!",
Dale Johannesene00a8a22008-08-28 02:44:49 +00003998 [(set GR32:$dst, (atomic_load_max_32 addr:$ptr, GR32:$val))]>;
Dan Gohman9499b712008-05-12 20:22:45 +00003999def ATOMUMIN32: I<0, Pseudo, (outs GR32:$dst),(ins i32mem:$ptr, GR32:$val),
Nick Lewycky6ecf5ce2008-12-07 03:49:52 +00004000 "#ATOMUMIN32 PSEUDO!",
Dale Johannesene00a8a22008-08-28 02:44:49 +00004001 [(set GR32:$dst, (atomic_load_umin_32 addr:$ptr, GR32:$val))]>;
Dan Gohman9499b712008-05-12 20:22:45 +00004002def ATOMUMAX32: I<0, Pseudo, (outs GR32:$dst),(ins i32mem:$ptr, GR32:$val),
Nick Lewycky6ecf5ce2008-12-07 03:49:52 +00004003 "#ATOMUMAX32 PSEUDO!",
Dale Johannesene00a8a22008-08-28 02:44:49 +00004004 [(set GR32:$dst, (atomic_load_umax_32 addr:$ptr, GR32:$val))]>;
Dale Johannesen140be2d2008-08-19 18:47:28 +00004005
4006def ATOMAND16 : I<0, Pseudo, (outs GR16:$dst),(ins i16mem:$ptr, GR16:$val),
Nick Lewycky6ecf5ce2008-12-07 03:49:52 +00004007 "#ATOMAND16 PSEUDO!",
Dale Johannesene00a8a22008-08-28 02:44:49 +00004008 [(set GR16:$dst, (atomic_load_and_16 addr:$ptr, GR16:$val))]>;
Dale Johannesen140be2d2008-08-19 18:47:28 +00004009def ATOMOR16 : I<0, Pseudo, (outs GR16:$dst),(ins i16mem:$ptr, GR16:$val),
Nick Lewycky6ecf5ce2008-12-07 03:49:52 +00004010 "#ATOMOR16 PSEUDO!",
Dale Johannesene00a8a22008-08-28 02:44:49 +00004011 [(set GR16:$dst, (atomic_load_or_16 addr:$ptr, GR16:$val))]>;
Dale Johannesen140be2d2008-08-19 18:47:28 +00004012def ATOMXOR16 : I<0, Pseudo,(outs GR16:$dst),(ins i16mem:$ptr, GR16:$val),
Nick Lewycky6ecf5ce2008-12-07 03:49:52 +00004013 "#ATOMXOR16 PSEUDO!",
Dale Johannesene00a8a22008-08-28 02:44:49 +00004014 [(set GR16:$dst, (atomic_load_xor_16 addr:$ptr, GR16:$val))]>;
Dale Johannesen140be2d2008-08-19 18:47:28 +00004015def ATOMNAND16 : I<0, Pseudo,(outs GR16:$dst),(ins i16mem:$ptr, GR16:$val),
Nick Lewycky6ecf5ce2008-12-07 03:49:52 +00004016 "#ATOMNAND16 PSEUDO!",
Dale Johannesene00a8a22008-08-28 02:44:49 +00004017 [(set GR16:$dst, (atomic_load_nand_16 addr:$ptr, GR16:$val))]>;
Dale Johannesen140be2d2008-08-19 18:47:28 +00004018def ATOMMIN16: I<0, Pseudo, (outs GR16:$dst), (ins i16mem:$ptr, GR16:$val),
Nick Lewycky6ecf5ce2008-12-07 03:49:52 +00004019 "#ATOMMIN16 PSEUDO!",
Dale Johannesene00a8a22008-08-28 02:44:49 +00004020 [(set GR16:$dst, (atomic_load_min_16 addr:$ptr, GR16:$val))]>;
Dale Johannesen140be2d2008-08-19 18:47:28 +00004021def ATOMMAX16: I<0, Pseudo, (outs GR16:$dst),(ins i16mem:$ptr, GR16:$val),
Nick Lewycky6ecf5ce2008-12-07 03:49:52 +00004022 "#ATOMMAX16 PSEUDO!",
Dale Johannesene00a8a22008-08-28 02:44:49 +00004023 [(set GR16:$dst, (atomic_load_max_16 addr:$ptr, GR16:$val))]>;
Dale Johannesen140be2d2008-08-19 18:47:28 +00004024def ATOMUMIN16: I<0, Pseudo, (outs GR16:$dst),(ins i16mem:$ptr, GR16:$val),
Nick Lewycky6ecf5ce2008-12-07 03:49:52 +00004025 "#ATOMUMIN16 PSEUDO!",
Dale Johannesene00a8a22008-08-28 02:44:49 +00004026 [(set GR16:$dst, (atomic_load_umin_16 addr:$ptr, GR16:$val))]>;
Dale Johannesen140be2d2008-08-19 18:47:28 +00004027def ATOMUMAX16: I<0, Pseudo, (outs GR16:$dst),(ins i16mem:$ptr, GR16:$val),
Nick Lewycky6ecf5ce2008-12-07 03:49:52 +00004028 "#ATOMUMAX16 PSEUDO!",
Dale Johannesene00a8a22008-08-28 02:44:49 +00004029 [(set GR16:$dst, (atomic_load_umax_16 addr:$ptr, GR16:$val))]>;
Dale Johannesen140be2d2008-08-19 18:47:28 +00004030
4031def ATOMAND8 : I<0, Pseudo, (outs GR8:$dst),(ins i8mem:$ptr, GR8:$val),
Nick Lewycky6ecf5ce2008-12-07 03:49:52 +00004032 "#ATOMAND8 PSEUDO!",
Dale Johannesene00a8a22008-08-28 02:44:49 +00004033 [(set GR8:$dst, (atomic_load_and_8 addr:$ptr, GR8:$val))]>;
Dale Johannesen140be2d2008-08-19 18:47:28 +00004034def ATOMOR8 : I<0, Pseudo, (outs GR8:$dst),(ins i8mem:$ptr, GR8:$val),
Nick Lewycky6ecf5ce2008-12-07 03:49:52 +00004035 "#ATOMOR8 PSEUDO!",
Dale Johannesene00a8a22008-08-28 02:44:49 +00004036 [(set GR8:$dst, (atomic_load_or_8 addr:$ptr, GR8:$val))]>;
Dale Johannesen140be2d2008-08-19 18:47:28 +00004037def ATOMXOR8 : I<0, Pseudo,(outs GR8:$dst),(ins i8mem:$ptr, GR8:$val),
Nick Lewycky6ecf5ce2008-12-07 03:49:52 +00004038 "#ATOMXOR8 PSEUDO!",
Dale Johannesene00a8a22008-08-28 02:44:49 +00004039 [(set GR8:$dst, (atomic_load_xor_8 addr:$ptr, GR8:$val))]>;
Dale Johannesen140be2d2008-08-19 18:47:28 +00004040def ATOMNAND8 : I<0, Pseudo,(outs GR8:$dst),(ins i8mem:$ptr, GR8:$val),
Nick Lewycky6ecf5ce2008-12-07 03:49:52 +00004041 "#ATOMNAND8 PSEUDO!",
Dale Johannesene00a8a22008-08-28 02:44:49 +00004042 [(set GR8:$dst, (atomic_load_nand_8 addr:$ptr, GR8:$val))]>;
Mon P Wang63307c32008-05-05 19:05:59 +00004043}
4044
Dale Johannesen48c1bc22008-10-02 18:53:47 +00004045let Constraints = "$val1 = $dst1, $val2 = $dst2",
4046 Defs = [EFLAGS, EAX, EBX, ECX, EDX],
4047 Uses = [EAX, EBX, ECX, EDX],
Dale Johannesen1b54c7f2008-10-03 19:41:08 +00004048 mayLoad = 1, mayStore = 1,
Dan Gohman533297b2009-10-29 18:10:34 +00004049 usesCustomInserter = 1 in {
Dale Johannesen48c1bc22008-10-02 18:53:47 +00004050def ATOMAND6432 : I<0, Pseudo, (outs GR32:$dst1, GR32:$dst2),
4051 (ins i64mem:$ptr, GR32:$val1, GR32:$val2),
Nick Lewycky6ecf5ce2008-12-07 03:49:52 +00004052 "#ATOMAND6432 PSEUDO!", []>;
Dale Johannesen48c1bc22008-10-02 18:53:47 +00004053def ATOMOR6432 : I<0, Pseudo, (outs GR32:$dst1, GR32:$dst2),
4054 (ins i64mem:$ptr, GR32:$val1, GR32:$val2),
Nick Lewycky6ecf5ce2008-12-07 03:49:52 +00004055 "#ATOMOR6432 PSEUDO!", []>;
Dale Johannesen48c1bc22008-10-02 18:53:47 +00004056def ATOMXOR6432 : I<0, Pseudo, (outs GR32:$dst1, GR32:$dst2),
4057 (ins i64mem:$ptr, GR32:$val1, GR32:$val2),
Nick Lewycky6ecf5ce2008-12-07 03:49:52 +00004058 "#ATOMXOR6432 PSEUDO!", []>;
Dale Johannesen48c1bc22008-10-02 18:53:47 +00004059def ATOMNAND6432 : I<0, Pseudo, (outs GR32:$dst1, GR32:$dst2),
4060 (ins i64mem:$ptr, GR32:$val1, GR32:$val2),
Nick Lewycky6ecf5ce2008-12-07 03:49:52 +00004061 "#ATOMNAND6432 PSEUDO!", []>;
Dale Johannesen48c1bc22008-10-02 18:53:47 +00004062def ATOMADD6432 : I<0, Pseudo, (outs GR32:$dst1, GR32:$dst2),
4063 (ins i64mem:$ptr, GR32:$val1, GR32:$val2),
Nick Lewycky6ecf5ce2008-12-07 03:49:52 +00004064 "#ATOMADD6432 PSEUDO!", []>;
Dale Johannesen48c1bc22008-10-02 18:53:47 +00004065def ATOMSUB6432 : I<0, Pseudo, (outs GR32:$dst1, GR32:$dst2),
4066 (ins i64mem:$ptr, GR32:$val1, GR32:$val2),
Nick Lewycky6ecf5ce2008-12-07 03:49:52 +00004067 "#ATOMSUB6432 PSEUDO!", []>;
Dale Johannesen880ae362008-10-03 22:25:52 +00004068def ATOMSWAP6432 : I<0, Pseudo, (outs GR32:$dst1, GR32:$dst2),
4069 (ins i64mem:$ptr, GR32:$val1, GR32:$val2),
Nick Lewycky6ecf5ce2008-12-07 03:49:52 +00004070 "#ATOMSWAP6432 PSEUDO!", []>;
Dale Johannesen48c1bc22008-10-02 18:53:47 +00004071}
4072
Sean Callanan358f1ef2009-09-16 21:55:34 +00004073// Segmentation support instructions.
4074
4075def LAR16rm : I<0x02, MRMSrcMem, (outs GR16:$dst), (ins i16mem:$src),
4076 "lar{w}\t{$src, $dst|$dst, $src}", []>, TB, OpSize;
4077def LAR16rr : I<0x02, MRMSrcReg, (outs GR16:$dst), (ins GR16:$src),
4078 "lar{w}\t{$src, $dst|$dst, $src}", []>, TB, OpSize;
4079
4080// i16mem operand in LAR32rm and GR32 operand in LAR32rr is not a typo.
4081def LAR32rm : I<0x02, MRMSrcMem, (outs GR32:$dst), (ins i16mem:$src),
4082 "lar{l}\t{$src, $dst|$dst, $src}", []>, TB;
4083def LAR32rr : I<0x02, MRMSrcReg, (outs GR32:$dst), (ins GR32:$src),
4084 "lar{l}\t{$src, $dst|$dst, $src}", []>, TB;
Sean Callanan108934c2009-12-18 00:01:26 +00004085
4086def LSL16rm : I<0x03, MRMSrcMem, (outs GR16:$dst), (ins i16mem:$src),
4087 "lsl{w}\t{$src, $dst|$dst, $src}", []>, TB, OpSize;
4088def LSL16rr : I<0x03, MRMSrcReg, (outs GR16:$dst), (ins GR16:$src),
4089 "lsl{w}\t{$src, $dst|$dst, $src}", []>, TB, OpSize;
4090def LSL32rm : I<0x03, MRMSrcMem, (outs GR32:$dst), (ins i32mem:$src),
4091 "lsl{l}\t{$src, $dst|$dst, $src}", []>, TB;
4092def LSL32rr : I<0x03, MRMSrcReg, (outs GR32:$dst), (ins GR32:$src),
4093 "lsl{l}\t{$src, $dst|$dst, $src}", []>, TB;
4094
Sean Callanan95a5a7d2010-02-13 01:48:34 +00004095def INVLPG : I<0x01, MRM7m, (outs), (ins i8mem:$addr), "invlpg\t$addr", []>, TB;
Sean Callanan108934c2009-12-18 00:01:26 +00004096
4097def STRr : I<0x00, MRM1r, (outs GR16:$dst), (ins),
4098 "str{w}\t{$dst}", []>, TB;
4099def STRm : I<0x00, MRM1m, (outs i16mem:$dst), (ins),
4100 "str{w}\t{$dst}", []>, TB;
4101def LTRr : I<0x00, MRM3r, (outs), (ins GR16:$src),
4102 "ltr{w}\t{$src}", []>, TB;
4103def LTRm : I<0x00, MRM3m, (outs), (ins i16mem:$src),
4104 "ltr{w}\t{$src}", []>, TB;
4105
4106def PUSHFS16 : I<0xa0, RawFrm, (outs), (ins),
4107 "push{w}\t%fs", []>, OpSize, TB;
4108def PUSHFS32 : I<0xa0, RawFrm, (outs), (ins),
4109 "push{l}\t%fs", []>, TB;
4110def PUSHGS16 : I<0xa8, RawFrm, (outs), (ins),
4111 "push{w}\t%gs", []>, OpSize, TB;
4112def PUSHGS32 : I<0xa8, RawFrm, (outs), (ins),
4113 "push{l}\t%gs", []>, TB;
4114
4115def POPFS16 : I<0xa1, RawFrm, (outs), (ins),
4116 "pop{w}\t%fs", []>, OpSize, TB;
4117def POPFS32 : I<0xa1, RawFrm, (outs), (ins),
4118 "pop{l}\t%fs", []>, TB;
4119def POPGS16 : I<0xa9, RawFrm, (outs), (ins),
4120 "pop{w}\t%gs", []>, OpSize, TB;
4121def POPGS32 : I<0xa9, RawFrm, (outs), (ins),
4122 "pop{l}\t%gs", []>, TB;
4123
4124def LDS16rm : I<0xc5, MRMSrcMem, (outs GR16:$dst), (ins opaque32mem:$src),
4125 "lds{w}\t{$src, $dst|$dst, $src}", []>, OpSize;
4126def LDS32rm : I<0xc5, MRMSrcMem, (outs GR32:$dst), (ins opaque48mem:$src),
4127 "lds{l}\t{$src, $dst|$dst, $src}", []>;
4128def LSS16rm : I<0xb2, MRMSrcMem, (outs GR16:$dst), (ins opaque32mem:$src),
4129 "lss{w}\t{$src, $dst|$dst, $src}", []>, TB, OpSize;
4130def LSS32rm : I<0xb2, MRMSrcMem, (outs GR32:$dst), (ins opaque48mem:$src),
4131 "lss{l}\t{$src, $dst|$dst, $src}", []>, TB;
4132def LES16rm : I<0xc4, MRMSrcMem, (outs GR16:$dst), (ins opaque32mem:$src),
4133 "les{w}\t{$src, $dst|$dst, $src}", []>, OpSize;
4134def LES32rm : I<0xc4, MRMSrcMem, (outs GR32:$dst), (ins opaque48mem:$src),
4135 "les{l}\t{$src, $dst|$dst, $src}", []>;
4136def LFS16rm : I<0xb4, MRMSrcMem, (outs GR16:$dst), (ins opaque32mem:$src),
4137 "lfs{w}\t{$src, $dst|$dst, $src}", []>, TB, OpSize;
4138def LFS32rm : I<0xb4, MRMSrcMem, (outs GR32:$dst), (ins opaque48mem:$src),
4139 "lfs{l}\t{$src, $dst|$dst, $src}", []>, TB;
4140def LGS16rm : I<0xb5, MRMSrcMem, (outs GR16:$dst), (ins opaque32mem:$src),
4141 "lgs{w}\t{$src, $dst|$dst, $src}", []>, TB, OpSize;
4142def LGS32rm : I<0xb5, MRMSrcMem, (outs GR32:$dst), (ins opaque48mem:$src),
4143 "lgs{l}\t{$src, $dst|$dst, $src}", []>, TB;
4144
4145def VERRr : I<0x00, MRM4r, (outs), (ins GR16:$seg),
4146 "verr\t$seg", []>, TB;
4147def VERRm : I<0x00, MRM4m, (outs), (ins i16mem:$seg),
4148 "verr\t$seg", []>, TB;
4149def VERWr : I<0x00, MRM5r, (outs), (ins GR16:$seg),
4150 "verw\t$seg", []>, TB;
4151def VERWm : I<0x00, MRM5m, (outs), (ins i16mem:$seg),
4152 "verw\t$seg", []>, TB;
4153
4154// Descriptor-table support instructions
4155
4156def SGDTm : I<0x01, MRM0m, (outs opaque48mem:$dst), (ins),
4157 "sgdt\t$dst", []>, TB;
4158def SIDTm : I<0x01, MRM1m, (outs opaque48mem:$dst), (ins),
4159 "sidt\t$dst", []>, TB;
4160def SLDT16r : I<0x00, MRM0r, (outs GR16:$dst), (ins),
4161 "sldt{w}\t$dst", []>, TB;
4162def SLDT16m : I<0x00, MRM0m, (outs i16mem:$dst), (ins),
4163 "sldt{w}\t$dst", []>, TB;
4164def LGDTm : I<0x01, MRM2m, (outs), (ins opaque48mem:$src),
4165 "lgdt\t$src", []>, TB;
4166def LIDTm : I<0x01, MRM3m, (outs), (ins opaque48mem:$src),
4167 "lidt\t$src", []>, TB;
4168def LLDT16r : I<0x00, MRM2r, (outs), (ins GR16:$src),
4169 "lldt{w}\t$src", []>, TB;
4170def LLDT16m : I<0x00, MRM2m, (outs), (ins i16mem:$src),
4171 "lldt{w}\t$src", []>, TB;
Sean Callanan9a86f102009-09-16 22:59:28 +00004172
Kevin Enderby12ce0de2010-02-03 21:04:42 +00004173// Lock instruction prefix
4174def LOCK_PREFIX : I<0xF0, RawFrm, (outs), (ins), "lock", []>;
4175
4176// Repeat string operation instruction prefixes
4177// These uses the DF flag in the EFLAGS register to inc or dec ECX
4178let Defs = [ECX], Uses = [ECX,EFLAGS] in {
4179// Repeat (used with INS, OUTS, MOVS, LODS and STOS)
4180def REP_PREFIX : I<0xF3, RawFrm, (outs), (ins), "rep", []>;
4181// Repeat while not equal (used with CMPS and SCAS)
4182def REPNE_PREFIX : I<0xF2, RawFrm, (outs), (ins), "repne", []>;
4183}
4184
4185// Segment override instruction prefixes
4186def CS_PREFIX : I<0x2E, RawFrm, (outs), (ins), "cs", []>;
4187def SS_PREFIX : I<0x36, RawFrm, (outs), (ins), "ss", []>;
4188def DS_PREFIX : I<0x3E, RawFrm, (outs), (ins), "ds", []>;
4189def ES_PREFIX : I<0x26, RawFrm, (outs), (ins), "es", []>;
4190def FS_PREFIX : I<0x64, RawFrm, (outs), (ins), "fs", []>;
4191def GS_PREFIX : I<0x65, RawFrm, (outs), (ins), "gs", []>;
4192
Sean Callanan9a86f102009-09-16 22:59:28 +00004193// String manipulation instructions
4194
4195def LODSB : I<0xAC, RawFrm, (outs), (ins), "lodsb", []>;
4196def LODSW : I<0xAD, RawFrm, (outs), (ins), "lodsw", []>, OpSize;
Sean Callanan108934c2009-12-18 00:01:26 +00004197def LODSD : I<0xAD, RawFrm, (outs), (ins), "lods{l|d}", []>;
4198
4199def OUTSB : I<0x6E, RawFrm, (outs), (ins), "outsb", []>;
4200def OUTSW : I<0x6F, RawFrm, (outs), (ins), "outsw", []>, OpSize;
4201def OUTSD : I<0x6F, RawFrm, (outs), (ins), "outs{l|d}", []>;
4202
4203// CPU flow control instructions
4204
4205def HLT : I<0xF4, RawFrm, (outs), (ins), "hlt", []>;
4206def RSM : I<0xAA, RawFrm, (outs), (ins), "rsm", []>, TB;
4207
4208// FPU control instructions
4209
4210def FNINIT : I<0xE3, RawFrm, (outs), (ins), "fninit", []>, DB;
4211
4212// Flag instructions
4213
4214def CLC : I<0xF8, RawFrm, (outs), (ins), "clc", []>;
4215def STC : I<0xF9, RawFrm, (outs), (ins), "stc", []>;
4216def CLI : I<0xFA, RawFrm, (outs), (ins), "cli", []>;
4217def STI : I<0xFB, RawFrm, (outs), (ins), "sti", []>;
4218def CLD : I<0xFC, RawFrm, (outs), (ins), "cld", []>;
4219def STD : I<0xFD, RawFrm, (outs), (ins), "std", []>;
4220def CMC : I<0xF5, RawFrm, (outs), (ins), "cmc", []>;
4221
4222def CLTS : I<0x06, RawFrm, (outs), (ins), "clts", []>, TB;
4223
4224// Table lookup instructions
4225
4226def XLAT : I<0xD7, RawFrm, (outs), (ins), "xlatb", []>;
4227
4228// Specialized register support
4229
4230def WRMSR : I<0x30, RawFrm, (outs), (ins), "wrmsr", []>, TB;
4231def RDMSR : I<0x32, RawFrm, (outs), (ins), "rdmsr", []>, TB;
4232def RDPMC : I<0x33, RawFrm, (outs), (ins), "rdpmc", []>, TB;
4233
4234def SMSW16r : I<0x01, MRM4r, (outs GR16:$dst), (ins),
4235 "smsw{w}\t$dst", []>, OpSize, TB;
4236def SMSW32r : I<0x01, MRM4r, (outs GR32:$dst), (ins),
4237 "smsw{l}\t$dst", []>, TB;
4238// For memory operands, there is only a 16-bit form
4239def SMSW16m : I<0x01, MRM4m, (outs i16mem:$dst), (ins),
4240 "smsw{w}\t$dst", []>, TB;
4241
4242def LMSW16r : I<0x01, MRM6r, (outs), (ins GR16:$src),
4243 "lmsw{w}\t$src", []>, TB;
4244def LMSW16m : I<0x01, MRM6m, (outs), (ins i16mem:$src),
4245 "lmsw{w}\t$src", []>, TB;
4246
4247def CPUID : I<0xA2, RawFrm, (outs), (ins), "cpuid", []>, TB;
4248
4249// Cache instructions
4250
4251def INVD : I<0x08, RawFrm, (outs), (ins), "invd", []>, TB;
4252def WBINVD : I<0x09, RawFrm, (outs), (ins), "wbinvd", []>, TB;
4253
4254// VMX instructions
4255
4256// 66 0F 38 80
Sean Callanan95a5a7d2010-02-13 01:48:34 +00004257def INVEPT : I<0x80, RawFrm, (outs), (ins), "invept", []>, OpSize, T8;
Sean Callanan108934c2009-12-18 00:01:26 +00004258// 66 0F 38 81
Sean Callanan95a5a7d2010-02-13 01:48:34 +00004259def INVVPID : I<0x81, RawFrm, (outs), (ins), "invvpid", []>, OpSize, T8;
Sean Callanan108934c2009-12-18 00:01:26 +00004260// 0F 01 C1
Chris Lattnerfdfeb692010-02-12 20:49:41 +00004261def VMCALL : I<0x01, MRM_C1, (outs), (ins), "vmcall", []>, TB;
Sean Callanan108934c2009-12-18 00:01:26 +00004262def VMCLEARm : I<0xC7, MRM6m, (outs), (ins i64mem:$vmcs),
4263 "vmclear\t$vmcs", []>, OpSize, TB;
4264// 0F 01 C2
Chris Lattnera599de22010-02-13 00:41:14 +00004265def VMLAUNCH : I<0x01, MRM_C2, (outs), (ins), "vmlaunch", []>, TB;
Sean Callanan108934c2009-12-18 00:01:26 +00004266// 0F 01 C3
Chris Lattnera599de22010-02-13 00:41:14 +00004267def VMRESUME : I<0x01, MRM_C3, (outs), (ins), "vmresume", []>, TB;
Sean Callanan108934c2009-12-18 00:01:26 +00004268def VMPTRLDm : I<0xC7, MRM6m, (outs), (ins i64mem:$vmcs),
4269 "vmptrld\t$vmcs", []>, TB;
4270def VMPTRSTm : I<0xC7, MRM7m, (outs i64mem:$vmcs), (ins),
4271 "vmptrst\t$vmcs", []>, TB;
4272def VMREAD64rm : I<0x78, MRMDestMem, (outs i64mem:$dst), (ins GR64:$src),
4273 "vmread{q}\t{$src, $dst|$dst, $src}", []>, TB;
4274def VMREAD64rr : I<0x78, MRMDestReg, (outs GR64:$dst), (ins GR64:$src),
4275 "vmread{q}\t{$src, $dst|$dst, $src}", []>, TB;
4276def VMREAD32rm : I<0x78, MRMDestMem, (outs i32mem:$dst), (ins GR32:$src),
4277 "vmread{l}\t{$src, $dst|$dst, $src}", []>, TB;
4278def VMREAD32rr : I<0x78, MRMDestReg, (outs GR32:$dst), (ins GR32:$src),
4279 "vmread{l}\t{$src, $dst|$dst, $src}", []>, TB;
4280def VMWRITE64rm : I<0x79, MRMSrcMem, (outs GR64:$dst), (ins i64mem:$src),
4281 "vmwrite{q}\t{$src, $dst|$dst, $src}", []>, TB;
4282def VMWRITE64rr : I<0x79, MRMSrcReg, (outs GR64:$dst), (ins GR64:$src),
4283 "vmwrite{q}\t{$src, $dst|$dst, $src}", []>, TB;
4284def VMWRITE32rm : I<0x79, MRMSrcMem, (outs GR32:$dst), (ins i32mem:$src),
4285 "vmwrite{l}\t{$src, $dst|$dst, $src}", []>, TB;
4286def VMWRITE32rr : I<0x79, MRMSrcReg, (outs GR32:$dst), (ins GR32:$src),
4287 "vmwrite{l}\t{$src, $dst|$dst, $src}", []>, TB;
4288// 0F 01 C4
Chris Lattnera599de22010-02-13 00:41:14 +00004289def VMXOFF : I<0x01, MRM_C4, (outs), (ins), "vmxoff", []>, TB;
Sean Callanan108934c2009-12-18 00:01:26 +00004290def VMXON : I<0xC7, MRM6m, (outs), (ins i64mem:$vmxon),
Kevin Enderby0e822402010-03-08 22:17:26 +00004291 "vmxon\t{$vmxon}", []>, XS;
Sean Callanan358f1ef2009-09-16 21:55:34 +00004292
Andrew Lenharthab0b9492008-02-21 06:45:13 +00004293//===----------------------------------------------------------------------===//
Evan Cheng510e4782006-01-09 23:10:28 +00004294// Non-Instruction Patterns
4295//===----------------------------------------------------------------------===//
4296
Bill Wendling056292f2008-09-16 21:48:12 +00004297// ConstantPool GlobalAddress, ExternalSymbol, and JumpTable
Evan Cheng71fb8342006-02-25 10:02:21 +00004298def : Pat<(i32 (X86Wrapper tconstpool :$dst)), (MOV32ri tconstpool :$dst)>;
Nate Begeman37efe672006-04-22 18:53:45 +00004299def : Pat<(i32 (X86Wrapper tjumptable :$dst)), (MOV32ri tjumptable :$dst)>;
Nate Begeman6795ebb2008-04-12 00:47:57 +00004300def : Pat<(i32 (X86Wrapper tglobaltlsaddr:$dst)),(MOV32ri tglobaltlsaddr:$dst)>;
Evan Cheng71fb8342006-02-25 10:02:21 +00004301def : Pat<(i32 (X86Wrapper tglobaladdr :$dst)), (MOV32ri tglobaladdr :$dst)>;
4302def : Pat<(i32 (X86Wrapper texternalsym:$dst)), (MOV32ri texternalsym:$dst)>;
Dan Gohmanf705adb2009-10-30 01:28:02 +00004303def : Pat<(i32 (X86Wrapper tblockaddress:$dst)), (MOV32ri tblockaddress:$dst)>;
Evan Cheng71fb8342006-02-25 10:02:21 +00004304
Evan Cheng069287d2006-05-16 07:21:53 +00004305def : Pat<(add GR32:$src1, (X86Wrapper tconstpool:$src2)),
4306 (ADD32ri GR32:$src1, tconstpool:$src2)>;
4307def : Pat<(add GR32:$src1, (X86Wrapper tjumptable:$src2)),
4308 (ADD32ri GR32:$src1, tjumptable:$src2)>;
4309def : Pat<(add GR32:$src1, (X86Wrapper tglobaladdr :$src2)),
4310 (ADD32ri GR32:$src1, tglobaladdr:$src2)>;
4311def : Pat<(add GR32:$src1, (X86Wrapper texternalsym:$src2)),
4312 (ADD32ri GR32:$src1, texternalsym:$src2)>;
Dan Gohmanf705adb2009-10-30 01:28:02 +00004313def : Pat<(add GR32:$src1, (X86Wrapper tblockaddress:$src2)),
4314 (ADD32ri GR32:$src1, tblockaddress:$src2)>;
Evan Cheng71fb8342006-02-25 10:02:21 +00004315
Evan Chengfc8feb12006-05-19 07:30:36 +00004316def : Pat<(store (i32 (X86Wrapper tglobaladdr:$src)), addr:$dst),
Evan Cheng71fb8342006-02-25 10:02:21 +00004317 (MOV32mi addr:$dst, tglobaladdr:$src)>;
Evan Chengfc8feb12006-05-19 07:30:36 +00004318def : Pat<(store (i32 (X86Wrapper texternalsym:$src)), addr:$dst),
Evan Cheng71fb8342006-02-25 10:02:21 +00004319 (MOV32mi addr:$dst, texternalsym:$src)>;
Dan Gohmanf705adb2009-10-30 01:28:02 +00004320def : Pat<(store (i32 (X86Wrapper tblockaddress:$src)), addr:$dst),
4321 (MOV32mi addr:$dst, tblockaddress:$src)>;
Evan Cheng71fb8342006-02-25 10:02:21 +00004322
Evan Cheng510e4782006-01-09 23:10:28 +00004323// Calls
Arnold Schwaighoferc85e1712007-10-11 19:40:01 +00004324// tailcall stuff
Evan Chengf48ef032010-03-14 03:48:46 +00004325def : Pat<(X86tcret GR32_TC:$dst, imm:$off),
4326 (TCRETURNri GR32_TC:$dst, imm:$off)>,
4327 Requires<[In32BitMode]>;
4328
4329def : Pat<(X86tcret (load addr:$dst), imm:$off),
4330 (TCRETURNmi addr:$dst, imm:$off)>,
4331 Requires<[In32BitMode]>;
Arnold Schwaighoferc85e1712007-10-11 19:40:01 +00004332
4333def : Pat<(X86tcret (i32 tglobaladdr:$dst), imm:$off),
Evan Chengf48ef032010-03-14 03:48:46 +00004334 (TCRETURNdi texternalsym:$dst, imm:$off)>,
4335 Requires<[In32BitMode]>;
Arnold Schwaighoferc85e1712007-10-11 19:40:01 +00004336
4337def : Pat<(X86tcret (i32 texternalsym:$dst), imm:$off),
Evan Chengf48ef032010-03-14 03:48:46 +00004338 (TCRETURNdi texternalsym:$dst, imm:$off)>,
4339 Requires<[In32BitMode]>;
Evan Chengfea89c12006-04-27 08:40:39 +00004340
Dan Gohmancadb2262009-08-02 16:10:01 +00004341// Normal calls, with various flavors of addresses.
Evan Cheng25ab6902006-09-08 06:48:29 +00004342def : Pat<(X86call (i32 tglobaladdr:$dst)),
Evan Cheng510e4782006-01-09 23:10:28 +00004343 (CALLpcrel32 tglobaladdr:$dst)>;
Evan Cheng25ab6902006-09-08 06:48:29 +00004344def : Pat<(X86call (i32 texternalsym:$dst)),
Evan Cheng8700e142006-01-11 06:09:51 +00004345 (CALLpcrel32 texternalsym:$dst)>;
Evan Chengd7f666a2009-05-20 04:53:57 +00004346def : Pat<(X86call (i32 imm:$dst)),
4347 (CALLpcrel32 imm:$dst)>, Requires<[CallImmAddr]>;
Evan Cheng510e4782006-01-09 23:10:28 +00004348
4349// X86 specific add which produces a flag.
Evan Cheng069287d2006-05-16 07:21:53 +00004350def : Pat<(addc GR32:$src1, GR32:$src2),
4351 (ADD32rr GR32:$src1, GR32:$src2)>;
4352def : Pat<(addc GR32:$src1, (load addr:$src2)),
4353 (ADD32rm GR32:$src1, addr:$src2)>;
4354def : Pat<(addc GR32:$src1, imm:$src2),
4355 (ADD32ri GR32:$src1, imm:$src2)>;
4356def : Pat<(addc GR32:$src1, i32immSExt8:$src2),
4357 (ADD32ri8 GR32:$src1, i32immSExt8:$src2)>;
Evan Cheng510e4782006-01-09 23:10:28 +00004358
Evan Cheng069287d2006-05-16 07:21:53 +00004359def : Pat<(subc GR32:$src1, GR32:$src2),
4360 (SUB32rr GR32:$src1, GR32:$src2)>;
4361def : Pat<(subc GR32:$src1, (load addr:$src2)),
4362 (SUB32rm GR32:$src1, addr:$src2)>;
4363def : Pat<(subc GR32:$src1, imm:$src2),
4364 (SUB32ri GR32:$src1, imm:$src2)>;
4365def : Pat<(subc GR32:$src1, i32immSExt8:$src2),
4366 (SUB32ri8 GR32:$src1, i32immSExt8:$src2)>;
Evan Cheng510e4782006-01-09 23:10:28 +00004367
Chris Lattnerffc0b262006-09-07 20:33:45 +00004368// Comparisons.
4369
4370// TEST R,R is smaller than CMP R,0
Evan Chenge5f62042007-09-29 00:00:36 +00004371def : Pat<(parallel (X86cmp GR8:$src1, 0), (implicit EFLAGS)),
Chris Lattnerffc0b262006-09-07 20:33:45 +00004372 (TEST8rr GR8:$src1, GR8:$src1)>;
Evan Chenge5f62042007-09-29 00:00:36 +00004373def : Pat<(parallel (X86cmp GR16:$src1, 0), (implicit EFLAGS)),
Chris Lattnerffc0b262006-09-07 20:33:45 +00004374 (TEST16rr GR16:$src1, GR16:$src1)>;
Evan Chenge5f62042007-09-29 00:00:36 +00004375def : Pat<(parallel (X86cmp GR32:$src1, 0), (implicit EFLAGS)),
Chris Lattnerffc0b262006-09-07 20:33:45 +00004376 (TEST32rr GR32:$src1, GR32:$src1)>;
4377
Dan Gohmanfbb74862009-01-07 01:00:24 +00004378// Conditional moves with folded loads with operands swapped and conditions
4379// inverted.
4380def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_B, EFLAGS),
4381 (CMOVAE16rm GR16:$src2, addr:$src1)>;
4382def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_B, EFLAGS),
4383 (CMOVAE32rm GR32:$src2, addr:$src1)>;
4384def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_AE, EFLAGS),
4385 (CMOVB16rm GR16:$src2, addr:$src1)>;
4386def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_AE, EFLAGS),
4387 (CMOVB32rm GR32:$src2, addr:$src1)>;
4388def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_E, EFLAGS),
4389 (CMOVNE16rm GR16:$src2, addr:$src1)>;
4390def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_E, EFLAGS),
4391 (CMOVNE32rm GR32:$src2, addr:$src1)>;
4392def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_NE, EFLAGS),
4393 (CMOVE16rm GR16:$src2, addr:$src1)>;
4394def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_NE, EFLAGS),
4395 (CMOVE32rm GR32:$src2, addr:$src1)>;
4396def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_BE, EFLAGS),
4397 (CMOVA16rm GR16:$src2, addr:$src1)>;
4398def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_BE, EFLAGS),
4399 (CMOVA32rm GR32:$src2, addr:$src1)>;
4400def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_A, EFLAGS),
4401 (CMOVBE16rm GR16:$src2, addr:$src1)>;
4402def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_A, EFLAGS),
4403 (CMOVBE32rm GR32:$src2, addr:$src1)>;
4404def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_L, EFLAGS),
4405 (CMOVGE16rm GR16:$src2, addr:$src1)>;
4406def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_L, EFLAGS),
4407 (CMOVGE32rm GR32:$src2, addr:$src1)>;
4408def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_GE, EFLAGS),
4409 (CMOVL16rm GR16:$src2, addr:$src1)>;
4410def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_GE, EFLAGS),
4411 (CMOVL32rm GR32:$src2, addr:$src1)>;
4412def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_LE, EFLAGS),
4413 (CMOVG16rm GR16:$src2, addr:$src1)>;
4414def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_LE, EFLAGS),
4415 (CMOVG32rm GR32:$src2, addr:$src1)>;
4416def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_G, EFLAGS),
4417 (CMOVLE16rm GR16:$src2, addr:$src1)>;
4418def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_G, EFLAGS),
4419 (CMOVLE32rm GR32:$src2, addr:$src1)>;
4420def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_P, EFLAGS),
4421 (CMOVNP16rm GR16:$src2, addr:$src1)>;
4422def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_P, EFLAGS),
4423 (CMOVNP32rm GR32:$src2, addr:$src1)>;
4424def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_NP, EFLAGS),
4425 (CMOVP16rm GR16:$src2, addr:$src1)>;
4426def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_NP, EFLAGS),
4427 (CMOVP32rm GR32:$src2, addr:$src1)>;
4428def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_S, EFLAGS),
4429 (CMOVNS16rm GR16:$src2, addr:$src1)>;
4430def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_S, EFLAGS),
4431 (CMOVNS32rm GR32:$src2, addr:$src1)>;
4432def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_NS, EFLAGS),
4433 (CMOVS16rm GR16:$src2, addr:$src1)>;
4434def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_NS, EFLAGS),
4435 (CMOVS32rm GR32:$src2, addr:$src1)>;
4436def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_O, EFLAGS),
4437 (CMOVNO16rm GR16:$src2, addr:$src1)>;
4438def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_O, EFLAGS),
4439 (CMOVNO32rm GR32:$src2, addr:$src1)>;
4440def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_NO, EFLAGS),
4441 (CMOVO16rm GR16:$src2, addr:$src1)>;
4442def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_NO, EFLAGS),
4443 (CMOVO32rm GR32:$src2, addr:$src1)>;
4444
Duncan Sandsf9c98e62008-01-23 20:39:46 +00004445// zextload bool -> zextload byte
Evan Chenge5d93432006-01-17 07:02:46 +00004446def : Pat<(zextloadi8i1 addr:$src), (MOV8rm addr:$src)>;
Evan Cheng510e4782006-01-09 23:10:28 +00004447def : Pat<(zextloadi16i1 addr:$src), (MOVZX16rm8 addr:$src)>;
4448def : Pat<(zextloadi32i1 addr:$src), (MOVZX32rm8 addr:$src)>;
4449
4450// extload bool -> extload byte
Evan Cheng47137242006-05-05 08:23:07 +00004451def : Pat<(extloadi8i1 addr:$src), (MOV8rm addr:$src)>;
Dan Gohmanaf70e5c2009-08-26 14:59:13 +00004452def : Pat<(extloadi16i1 addr:$src), (MOVZX16rm8 addr:$src)>;
Evan Cheng47137242006-05-05 08:23:07 +00004453def : Pat<(extloadi32i1 addr:$src), (MOVZX32rm8 addr:$src)>;
Dan Gohmanaf70e5c2009-08-26 14:59:13 +00004454def : Pat<(extloadi16i8 addr:$src), (MOVZX16rm8 addr:$src)>;
Evan Cheng47137242006-05-05 08:23:07 +00004455def : Pat<(extloadi32i8 addr:$src), (MOVZX32rm8 addr:$src)>;
4456def : Pat<(extloadi32i16 addr:$src), (MOVZX32rm16 addr:$src)>;
Evan Cheng510e4782006-01-09 23:10:28 +00004457
Dan Gohmanaf70e5c2009-08-26 14:59:13 +00004458// anyext. Define these to do an explicit zero-extend to
4459// avoid partial-register updates.
4460def : Pat<(i16 (anyext GR8 :$src)), (MOVZX16rr8 GR8 :$src)>;
4461def : Pat<(i32 (anyext GR8 :$src)), (MOVZX32rr8 GR8 :$src)>;
4462def : Pat<(i32 (anyext GR16:$src)), (MOVZX32rr16 GR16:$src)>;
Evan Cheng510e4782006-01-09 23:10:28 +00004463
Evan Chengcfa260b2006-01-06 02:31:59 +00004464//===----------------------------------------------------------------------===//
4465// Some peepholes
4466//===----------------------------------------------------------------------===//
4467
Dan Gohman63f97202008-10-17 01:33:43 +00004468// Odd encoding trick: -128 fits into an 8-bit immediate field while
4469// +128 doesn't, so in this special case use a sub instead of an add.
4470def : Pat<(add GR16:$src1, 128),
4471 (SUB16ri8 GR16:$src1, -128)>;
4472def : Pat<(store (add (loadi16 addr:$dst), 128), addr:$dst),
4473 (SUB16mi8 addr:$dst, -128)>;
4474def : Pat<(add GR32:$src1, 128),
4475 (SUB32ri8 GR32:$src1, -128)>;
4476def : Pat<(store (add (loadi32 addr:$dst), 128), addr:$dst),
4477 (SUB32mi8 addr:$dst, -128)>;
4478
Dan Gohman11ba3b12008-07-30 18:09:17 +00004479// r & (2^16-1) ==> movz
4480def : Pat<(and GR32:$src1, 0xffff),
Dan Gohman21e3dfb2009-04-13 16:09:41 +00004481 (MOVZX32rr16 (EXTRACT_SUBREG GR32:$src1, x86_subreg_16bit))>;
Dan Gohman8a1510d2008-08-06 18:27:21 +00004482// r & (2^8-1) ==> movz
4483def : Pat<(and GR32:$src1, 0xff),
Anton Korobeynikov3a639a02009-11-02 00:11:39 +00004484 (MOVZX32rr8 (EXTRACT_SUBREG (i32 (COPY_TO_REGCLASS GR32:$src1,
4485 GR32_ABCD)),
Dan Gohman21e3dfb2009-04-13 16:09:41 +00004486 x86_subreg_8bit))>,
Dan Gohman8a1510d2008-08-06 18:27:21 +00004487 Requires<[In32BitMode]>;
4488// r & (2^8-1) ==> movz
4489def : Pat<(and GR16:$src1, 0xff),
Anton Korobeynikov3a639a02009-11-02 00:11:39 +00004490 (MOVZX16rr8 (EXTRACT_SUBREG (i16 (COPY_TO_REGCLASS GR16:$src1,
4491 GR16_ABCD)),
Dan Gohman21e3dfb2009-04-13 16:09:41 +00004492 x86_subreg_8bit))>,
Dan Gohman0bfa1bf2008-08-20 21:27:32 +00004493 Requires<[In32BitMode]>;
4494
4495// sext_inreg patterns
4496def : Pat<(sext_inreg GR32:$src, i16),
Dan Gohman21e3dfb2009-04-13 16:09:41 +00004497 (MOVSX32rr16 (EXTRACT_SUBREG GR32:$src, x86_subreg_16bit))>;
Dan Gohman0bfa1bf2008-08-20 21:27:32 +00004498def : Pat<(sext_inreg GR32:$src, i8),
Anton Korobeynikov3a639a02009-11-02 00:11:39 +00004499 (MOVSX32rr8 (EXTRACT_SUBREG (i32 (COPY_TO_REGCLASS GR32:$src,
4500 GR32_ABCD)),
Dan Gohman21e3dfb2009-04-13 16:09:41 +00004501 x86_subreg_8bit))>,
Dan Gohman0bfa1bf2008-08-20 21:27:32 +00004502 Requires<[In32BitMode]>;
4503def : Pat<(sext_inreg GR16:$src, i8),
Anton Korobeynikov3a639a02009-11-02 00:11:39 +00004504 (MOVSX16rr8 (EXTRACT_SUBREG (i16 (COPY_TO_REGCLASS GR16:$src,
4505 GR16_ABCD)),
Dan Gohman21e3dfb2009-04-13 16:09:41 +00004506 x86_subreg_8bit))>,
Dan Gohman0bfa1bf2008-08-20 21:27:32 +00004507 Requires<[In32BitMode]>;
4508
4509// trunc patterns
4510def : Pat<(i16 (trunc GR32:$src)),
Dan Gohman21e3dfb2009-04-13 16:09:41 +00004511 (EXTRACT_SUBREG GR32:$src, x86_subreg_16bit)>;
Dan Gohman0bfa1bf2008-08-20 21:27:32 +00004512def : Pat<(i8 (trunc GR32:$src)),
Anton Korobeynikov3a639a02009-11-02 00:11:39 +00004513 (EXTRACT_SUBREG (i32 (COPY_TO_REGCLASS GR32:$src, GR32_ABCD)),
Dan Gohman21e3dfb2009-04-13 16:09:41 +00004514 x86_subreg_8bit)>,
Dan Gohman0bfa1bf2008-08-20 21:27:32 +00004515 Requires<[In32BitMode]>;
4516def : Pat<(i8 (trunc GR16:$src)),
Anton Korobeynikov3a639a02009-11-02 00:11:39 +00004517 (EXTRACT_SUBREG (i16 (COPY_TO_REGCLASS GR16:$src, GR16_ABCD)),
Dan Gohman21e3dfb2009-04-13 16:09:41 +00004518 x86_subreg_8bit)>,
4519 Requires<[In32BitMode]>;
4520
4521// h-register tricks
4522def : Pat<(i8 (trunc (srl_su GR16:$src, (i8 8)))),
Anton Korobeynikov3a639a02009-11-02 00:11:39 +00004523 (EXTRACT_SUBREG (i32 (COPY_TO_REGCLASS GR16:$src, GR16_ABCD)),
Dan Gohman21e3dfb2009-04-13 16:09:41 +00004524 x86_subreg_8bit_hi)>,
4525 Requires<[In32BitMode]>;
4526def : Pat<(i8 (trunc (srl_su GR32:$src, (i8 8)))),
Anton Korobeynikov3a639a02009-11-02 00:11:39 +00004527 (EXTRACT_SUBREG (i16 (COPY_TO_REGCLASS GR32:$src, GR32_ABCD)),
Dan Gohman21e3dfb2009-04-13 16:09:41 +00004528 x86_subreg_8bit_hi)>,
4529 Requires<[In32BitMode]>;
Dan Gohman7e0d64a2010-01-11 17:21:05 +00004530def : Pat<(srl GR16:$src, (i8 8)),
Dan Gohman21e3dfb2009-04-13 16:09:41 +00004531 (EXTRACT_SUBREG
4532 (MOVZX32rr8
Anton Korobeynikov3a639a02009-11-02 00:11:39 +00004533 (EXTRACT_SUBREG (i16 (COPY_TO_REGCLASS GR16:$src, GR16_ABCD)),
Dan Gohman21e3dfb2009-04-13 16:09:41 +00004534 x86_subreg_8bit_hi)),
4535 x86_subreg_16bit)>,
4536 Requires<[In32BitMode]>;
Evan Chengcb219f02009-05-29 01:44:43 +00004537def : Pat<(i32 (zext (srl_su GR16:$src, (i8 8)))),
Sean Callanan108934c2009-12-18 00:01:26 +00004538 (MOVZX32rr8 (EXTRACT_SUBREG (i16 (COPY_TO_REGCLASS GR16:$src,
4539 GR16_ABCD)),
Evan Chengcb219f02009-05-29 01:44:43 +00004540 x86_subreg_8bit_hi))>,
4541 Requires<[In32BitMode]>;
Dan Gohmanaf70e5c2009-08-26 14:59:13 +00004542def : Pat<(i32 (anyext (srl_su GR16:$src, (i8 8)))),
Sean Callanan108934c2009-12-18 00:01:26 +00004543 (MOVZX32rr8 (EXTRACT_SUBREG (i16 (COPY_TO_REGCLASS GR16:$src,
4544 GR16_ABCD)),
Dan Gohmanaf70e5c2009-08-26 14:59:13 +00004545 x86_subreg_8bit_hi))>,
4546 Requires<[In32BitMode]>;
Dan Gohman21e3dfb2009-04-13 16:09:41 +00004547def : Pat<(and (srl_su GR32:$src, (i8 8)), (i32 255)),
Sean Callanan108934c2009-12-18 00:01:26 +00004548 (MOVZX32rr8 (EXTRACT_SUBREG (i32 (COPY_TO_REGCLASS GR32:$src,
4549 GR32_ABCD)),
Dan Gohman21e3dfb2009-04-13 16:09:41 +00004550 x86_subreg_8bit_hi))>,
Dan Gohman8a1510d2008-08-06 18:27:21 +00004551 Requires<[In32BitMode]>;
Dan Gohman11ba3b12008-07-30 18:09:17 +00004552
Evan Chengcfa260b2006-01-06 02:31:59 +00004553// (shl x, 1) ==> (add x, x)
Evan Cheng069287d2006-05-16 07:21:53 +00004554def : Pat<(shl GR8 :$src1, (i8 1)), (ADD8rr GR8 :$src1, GR8 :$src1)>;
4555def : Pat<(shl GR16:$src1, (i8 1)), (ADD16rr GR16:$src1, GR16:$src1)>;
4556def : Pat<(shl GR32:$src1, (i8 1)), (ADD32rr GR32:$src1, GR32:$src1)>;
Evan Cheng68b951a2006-01-19 01:56:29 +00004557
Evan Chengeb9f8922008-08-30 02:03:58 +00004558// (shl x (and y, 31)) ==> (shl x, y)
Chris Lattner6d9f86b2010-02-23 06:54:29 +00004559def : Pat<(shl GR8:$src1, (and CL, 31)),
Evan Chengeb9f8922008-08-30 02:03:58 +00004560 (SHL8rCL GR8:$src1)>;
Chris Lattner6d9f86b2010-02-23 06:54:29 +00004561def : Pat<(shl GR16:$src1, (and CL, 31)),
Evan Chengeb9f8922008-08-30 02:03:58 +00004562 (SHL16rCL GR16:$src1)>;
Chris Lattner6d9f86b2010-02-23 06:54:29 +00004563def : Pat<(shl GR32:$src1, (and CL, 31)),
Evan Chengeb9f8922008-08-30 02:03:58 +00004564 (SHL32rCL GR32:$src1)>;
Chris Lattner6d9f86b2010-02-23 06:54:29 +00004565def : Pat<(store (shl (loadi8 addr:$dst), (and CL, 31)), addr:$dst),
Evan Chengeb9f8922008-08-30 02:03:58 +00004566 (SHL8mCL addr:$dst)>;
Chris Lattner6d9f86b2010-02-23 06:54:29 +00004567def : Pat<(store (shl (loadi16 addr:$dst), (and CL, 31)), addr:$dst),
Evan Chengeb9f8922008-08-30 02:03:58 +00004568 (SHL16mCL addr:$dst)>;
Chris Lattner6d9f86b2010-02-23 06:54:29 +00004569def : Pat<(store (shl (loadi32 addr:$dst), (and CL, 31)), addr:$dst),
Evan Chengeb9f8922008-08-30 02:03:58 +00004570 (SHL32mCL addr:$dst)>;
4571
Chris Lattner6d9f86b2010-02-23 06:54:29 +00004572def : Pat<(srl GR8:$src1, (and CL, 31)),
Evan Chengeb9f8922008-08-30 02:03:58 +00004573 (SHR8rCL GR8:$src1)>;
Chris Lattner6d9f86b2010-02-23 06:54:29 +00004574def : Pat<(srl GR16:$src1, (and CL, 31)),
Evan Chengeb9f8922008-08-30 02:03:58 +00004575 (SHR16rCL GR16:$src1)>;
Chris Lattner6d9f86b2010-02-23 06:54:29 +00004576def : Pat<(srl GR32:$src1, (and CL, 31)),
Evan Chengeb9f8922008-08-30 02:03:58 +00004577 (SHR32rCL GR32:$src1)>;
Chris Lattner6d9f86b2010-02-23 06:54:29 +00004578def : Pat<(store (srl (loadi8 addr:$dst), (and CL, 31)), addr:$dst),
Evan Chengeb9f8922008-08-30 02:03:58 +00004579 (SHR8mCL addr:$dst)>;
Chris Lattner6d9f86b2010-02-23 06:54:29 +00004580def : Pat<(store (srl (loadi16 addr:$dst), (and CL, 31)), addr:$dst),
Evan Chengeb9f8922008-08-30 02:03:58 +00004581 (SHR16mCL addr:$dst)>;
Chris Lattner6d9f86b2010-02-23 06:54:29 +00004582def : Pat<(store (srl (loadi32 addr:$dst), (and CL, 31)), addr:$dst),
Evan Chengeb9f8922008-08-30 02:03:58 +00004583 (SHR32mCL addr:$dst)>;
4584
Chris Lattner6d9f86b2010-02-23 06:54:29 +00004585def : Pat<(sra GR8:$src1, (and CL, 31)),
Evan Chengeb9f8922008-08-30 02:03:58 +00004586 (SAR8rCL GR8:$src1)>;
Chris Lattner6d9f86b2010-02-23 06:54:29 +00004587def : Pat<(sra GR16:$src1, (and CL, 31)),
Evan Chengeb9f8922008-08-30 02:03:58 +00004588 (SAR16rCL GR16:$src1)>;
Chris Lattner6d9f86b2010-02-23 06:54:29 +00004589def : Pat<(sra GR32:$src1, (and CL, 31)),
Evan Chengeb9f8922008-08-30 02:03:58 +00004590 (SAR32rCL GR32:$src1)>;
Chris Lattner6d9f86b2010-02-23 06:54:29 +00004591def : Pat<(store (sra (loadi8 addr:$dst), (and CL, 31)), addr:$dst),
Evan Chengeb9f8922008-08-30 02:03:58 +00004592 (SAR8mCL addr:$dst)>;
Chris Lattner6d9f86b2010-02-23 06:54:29 +00004593def : Pat<(store (sra (loadi16 addr:$dst), (and CL, 31)), addr:$dst),
Evan Chengeb9f8922008-08-30 02:03:58 +00004594 (SAR16mCL addr:$dst)>;
Chris Lattner6d9f86b2010-02-23 06:54:29 +00004595def : Pat<(store (sra (loadi32 addr:$dst), (and CL, 31)), addr:$dst),
Evan Chengeb9f8922008-08-30 02:03:58 +00004596 (SAR32mCL addr:$dst)>;
4597
Evan Cheng956044c2006-01-19 23:26:24 +00004598// (or (x >> c) | (y << (32 - c))) ==> (shrd32 x, y, c)
Evan Cheng069287d2006-05-16 07:21:53 +00004599def : Pat<(or (srl GR32:$src1, CL:$amt),
4600 (shl GR32:$src2, (sub 32, CL:$amt))),
4601 (SHRD32rrCL GR32:$src1, GR32:$src2)>;
Evan Cheng68b951a2006-01-19 01:56:29 +00004602
Evan Cheng21d54432006-01-20 01:13:30 +00004603def : Pat<(store (or (srl (loadi32 addr:$dst), CL:$amt),
Evan Cheng069287d2006-05-16 07:21:53 +00004604 (shl GR32:$src2, (sub 32, CL:$amt))), addr:$dst),
4605 (SHRD32mrCL addr:$dst, GR32:$src2)>;
Evan Cheng21d54432006-01-20 01:13:30 +00004606
Dan Gohman74feef22008-10-17 01:23:35 +00004607def : Pat<(or (srl GR32:$src1, (i8 (trunc ECX:$amt))),
4608 (shl GR32:$src2, (i8 (trunc (sub 32, ECX:$amt))))),
4609 (SHRD32rrCL GR32:$src1, GR32:$src2)>;
4610
4611def : Pat<(store (or (srl (loadi32 addr:$dst), (i8 (trunc ECX:$amt))),
4612 (shl GR32:$src2, (i8 (trunc (sub 32, ECX:$amt))))),
4613 addr:$dst),
4614 (SHRD32mrCL addr:$dst, GR32:$src2)>;
4615
Chris Lattner6d9f86b2010-02-23 06:54:29 +00004616def : Pat<(shrd GR32:$src1, (i8 imm:$amt1), GR32:$src2, (i8 imm/*:$amt2*/)),
Dan Gohman74feef22008-10-17 01:23:35 +00004617 (SHRD32rri8 GR32:$src1, GR32:$src2, (i8 imm:$amt1))>;
4618
4619def : Pat<(store (shrd (loadi32 addr:$dst), (i8 imm:$amt1),
Chris Lattner6d9f86b2010-02-23 06:54:29 +00004620 GR32:$src2, (i8 imm/*:$amt2*/)), addr:$dst),
Dan Gohman74feef22008-10-17 01:23:35 +00004621 (SHRD32mri8 addr:$dst, GR32:$src2, (i8 imm:$amt1))>;
4622
Evan Cheng956044c2006-01-19 23:26:24 +00004623// (or (x << c) | (y >> (32 - c))) ==> (shld32 x, y, c)
Evan Cheng069287d2006-05-16 07:21:53 +00004624def : Pat<(or (shl GR32:$src1, CL:$amt),
4625 (srl GR32:$src2, (sub 32, CL:$amt))),
4626 (SHLD32rrCL GR32:$src1, GR32:$src2)>;
Evan Cheng956044c2006-01-19 23:26:24 +00004627
Evan Cheng21d54432006-01-20 01:13:30 +00004628def : Pat<(store (or (shl (loadi32 addr:$dst), CL:$amt),
Evan Cheng069287d2006-05-16 07:21:53 +00004629 (srl GR32:$src2, (sub 32, CL:$amt))), addr:$dst),
4630 (SHLD32mrCL addr:$dst, GR32:$src2)>;
Evan Cheng21d54432006-01-20 01:13:30 +00004631
Dan Gohman74feef22008-10-17 01:23:35 +00004632def : Pat<(or (shl GR32:$src1, (i8 (trunc ECX:$amt))),
4633 (srl GR32:$src2, (i8 (trunc (sub 32, ECX:$amt))))),
4634 (SHLD32rrCL GR32:$src1, GR32:$src2)>;
4635
4636def : Pat<(store (or (shl (loadi32 addr:$dst), (i8 (trunc ECX:$amt))),
4637 (srl GR32:$src2, (i8 (trunc (sub 32, ECX:$amt))))),
4638 addr:$dst),
4639 (SHLD32mrCL addr:$dst, GR32:$src2)>;
4640
Chris Lattner6d9f86b2010-02-23 06:54:29 +00004641def : Pat<(shld GR32:$src1, (i8 imm:$amt1), GR32:$src2, (i8 imm/*:$amt2*/)),
Dan Gohman74feef22008-10-17 01:23:35 +00004642 (SHLD32rri8 GR32:$src1, GR32:$src2, (i8 imm:$amt1))>;
4643
4644def : Pat<(store (shld (loadi32 addr:$dst), (i8 imm:$amt1),
Chris Lattner6d9f86b2010-02-23 06:54:29 +00004645 GR32:$src2, (i8 imm/*:$amt2*/)), addr:$dst),
Dan Gohman74feef22008-10-17 01:23:35 +00004646 (SHLD32mri8 addr:$dst, GR32:$src2, (i8 imm:$amt1))>;
4647
Evan Cheng956044c2006-01-19 23:26:24 +00004648// (or (x >> c) | (y << (16 - c))) ==> (shrd16 x, y, c)
Evan Cheng069287d2006-05-16 07:21:53 +00004649def : Pat<(or (srl GR16:$src1, CL:$amt),
4650 (shl GR16:$src2, (sub 16, CL:$amt))),
4651 (SHRD16rrCL GR16:$src1, GR16:$src2)>;
Evan Cheng956044c2006-01-19 23:26:24 +00004652
Evan Cheng21d54432006-01-20 01:13:30 +00004653def : Pat<(store (or (srl (loadi16 addr:$dst), CL:$amt),
Evan Cheng069287d2006-05-16 07:21:53 +00004654 (shl GR16:$src2, (sub 16, CL:$amt))), addr:$dst),
4655 (SHRD16mrCL addr:$dst, GR16:$src2)>;
Evan Cheng21d54432006-01-20 01:13:30 +00004656
Dan Gohman74feef22008-10-17 01:23:35 +00004657def : Pat<(or (srl GR16:$src1, (i8 (trunc CX:$amt))),
4658 (shl GR16:$src2, (i8 (trunc (sub 16, CX:$amt))))),
4659 (SHRD16rrCL GR16:$src1, GR16:$src2)>;
4660
4661def : Pat<(store (or (srl (loadi16 addr:$dst), (i8 (trunc CX:$amt))),
4662 (shl GR16:$src2, (i8 (trunc (sub 16, CX:$amt))))),
4663 addr:$dst),
4664 (SHRD16mrCL addr:$dst, GR16:$src2)>;
4665
Chris Lattner6d9f86b2010-02-23 06:54:29 +00004666def : Pat<(shrd GR16:$src1, (i8 imm:$amt1), GR16:$src2, (i8 imm/*:$amt2*/)),
Dan Gohman74feef22008-10-17 01:23:35 +00004667 (SHRD16rri8 GR16:$src1, GR16:$src2, (i8 imm:$amt1))>;
4668
4669def : Pat<(store (shrd (loadi16 addr:$dst), (i8 imm:$amt1),
Chris Lattner6d9f86b2010-02-23 06:54:29 +00004670 GR16:$src2, (i8 imm/*:$amt2*/)), addr:$dst),
Dan Gohman74feef22008-10-17 01:23:35 +00004671 (SHRD16mri8 addr:$dst, GR16:$src2, (i8 imm:$amt1))>;
4672
Evan Cheng956044c2006-01-19 23:26:24 +00004673// (or (x << c) | (y >> (16 - c))) ==> (shld16 x, y, c)
Evan Cheng069287d2006-05-16 07:21:53 +00004674def : Pat<(or (shl GR16:$src1, CL:$amt),
4675 (srl GR16:$src2, (sub 16, CL:$amt))),
4676 (SHLD16rrCL GR16:$src1, GR16:$src2)>;
Evan Cheng21d54432006-01-20 01:13:30 +00004677
4678def : Pat<(store (or (shl (loadi16 addr:$dst), CL:$amt),
Evan Cheng069287d2006-05-16 07:21:53 +00004679 (srl GR16:$src2, (sub 16, CL:$amt))), addr:$dst),
4680 (SHLD16mrCL addr:$dst, GR16:$src2)>;
Evan Cheng4e4c71e2006-02-21 20:00:20 +00004681
Dan Gohman74feef22008-10-17 01:23:35 +00004682def : Pat<(or (shl GR16:$src1, (i8 (trunc CX:$amt))),
4683 (srl GR16:$src2, (i8 (trunc (sub 16, CX:$amt))))),
4684 (SHLD16rrCL GR16:$src1, GR16:$src2)>;
4685
4686def : Pat<(store (or (shl (loadi16 addr:$dst), (i8 (trunc CX:$amt))),
4687 (srl GR16:$src2, (i8 (trunc (sub 16, CX:$amt))))),
4688 addr:$dst),
4689 (SHLD16mrCL addr:$dst, GR16:$src2)>;
4690
Chris Lattner6d9f86b2010-02-23 06:54:29 +00004691def : Pat<(shld GR16:$src1, (i8 imm:$amt1), GR16:$src2, (i8 imm/*:$amt2*/)),
Dan Gohman74feef22008-10-17 01:23:35 +00004692 (SHLD16rri8 GR16:$src1, GR16:$src2, (i8 imm:$amt1))>;
4693
4694def : Pat<(store (shld (loadi16 addr:$dst), (i8 imm:$amt1),
Chris Lattner6d9f86b2010-02-23 06:54:29 +00004695 GR16:$src2, (i8 imm/*:$amt2*/)), addr:$dst),
Dan Gohman74feef22008-10-17 01:23:35 +00004696 (SHLD16mri8 addr:$dst, GR16:$src2, (i8 imm:$amt1))>;
4697
Evan Cheng2e489c42009-12-16 00:53:11 +00004698// (anyext (setcc_carry)) -> (setcc_carry)
4699def : Pat<(i16 (anyext (i8 (X86setcc_c X86_COND_B, EFLAGS)))),
Evan Chengad9c0a32009-12-15 00:53:42 +00004700 (SETB_C16r)>;
Evan Cheng2e489c42009-12-16 00:53:11 +00004701def : Pat<(i32 (anyext (i8 (X86setcc_c X86_COND_B, EFLAGS)))),
Evan Chengad9c0a32009-12-15 00:53:42 +00004702 (SETB_C32r)>;
4703
Evan Cheng199c4242010-01-11 22:03:29 +00004704// (or x1, x2) -> (add x1, x2) if two operands are known not to share bits.
Evan Cheng3bda2012010-01-12 18:31:19 +00004705let AddedComplexity = 5 in { // Try this before the selecting to OR
Evan Cheng4b0345b2010-01-11 17:03:47 +00004706def : Pat<(parallel (or_is_add GR16:$src1, imm:$src2),
4707 (implicit EFLAGS)),
4708 (ADD16ri GR16:$src1, imm:$src2)>;
4709def : Pat<(parallel (or_is_add GR32:$src1, imm:$src2),
4710 (implicit EFLAGS)),
4711 (ADD32ri GR32:$src1, imm:$src2)>;
4712def : Pat<(parallel (or_is_add GR16:$src1, i16immSExt8:$src2),
4713 (implicit EFLAGS)),
4714 (ADD16ri8 GR16:$src1, i16immSExt8:$src2)>;
4715def : Pat<(parallel (or_is_add GR32:$src1, i32immSExt8:$src2),
4716 (implicit EFLAGS)),
4717 (ADD32ri8 GR32:$src1, i32immSExt8:$src2)>;
Evan Cheng199c4242010-01-11 22:03:29 +00004718def : Pat<(parallel (or_is_add GR16:$src1, GR16:$src2),
4719 (implicit EFLAGS)),
4720 (ADD16rr GR16:$src1, GR16:$src2)>;
4721def : Pat<(parallel (or_is_add GR32:$src1, GR32:$src2),
4722 (implicit EFLAGS)),
4723 (ADD32rr GR32:$src1, GR32:$src2)>;
Evan Cheng3bda2012010-01-12 18:31:19 +00004724} // AddedComplexity
Evan Cheng4b0345b2010-01-11 17:03:47 +00004725
Evan Cheng4e4c71e2006-02-21 20:00:20 +00004726//===----------------------------------------------------------------------===//
Dan Gohman076aee32009-03-04 19:44:21 +00004727// EFLAGS-defining Patterns
Bill Wendlingd350e022008-12-12 21:15:41 +00004728//===----------------------------------------------------------------------===//
4729
Dan Gohman076aee32009-03-04 19:44:21 +00004730// Register-Register Addition with EFLAGS result
4731def : Pat<(parallel (X86add_flag GR8:$src1, GR8:$src2),
Bill Wendlingd350e022008-12-12 21:15:41 +00004732 (implicit EFLAGS)),
4733 (ADD8rr GR8:$src1, GR8:$src2)>;
Dan Gohman076aee32009-03-04 19:44:21 +00004734def : Pat<(parallel (X86add_flag GR16:$src1, GR16:$src2),
Bill Wendlingd350e022008-12-12 21:15:41 +00004735 (implicit EFLAGS)),
4736 (ADD16rr GR16:$src1, GR16:$src2)>;
Dan Gohman076aee32009-03-04 19:44:21 +00004737def : Pat<(parallel (X86add_flag GR32:$src1, GR32:$src2),
Bill Wendlingd350e022008-12-12 21:15:41 +00004738 (implicit EFLAGS)),
4739 (ADD32rr GR32:$src1, GR32:$src2)>;
4740
Dan Gohman076aee32009-03-04 19:44:21 +00004741// Register-Memory Addition with EFLAGS result
4742def : Pat<(parallel (X86add_flag GR8:$src1, (loadi8 addr:$src2)),
Bill Wendlingd350e022008-12-12 21:15:41 +00004743 (implicit EFLAGS)),
4744 (ADD8rm GR8:$src1, addr:$src2)>;
Dan Gohman076aee32009-03-04 19:44:21 +00004745def : Pat<(parallel (X86add_flag GR16:$src1, (loadi16 addr:$src2)),
Bill Wendlingd350e022008-12-12 21:15:41 +00004746 (implicit EFLAGS)),
4747 (ADD16rm GR16:$src1, addr:$src2)>;
Dan Gohman076aee32009-03-04 19:44:21 +00004748def : Pat<(parallel (X86add_flag GR32:$src1, (loadi32 addr:$src2)),
Bill Wendlingd350e022008-12-12 21:15:41 +00004749 (implicit EFLAGS)),
4750 (ADD32rm GR32:$src1, addr:$src2)>;
4751
Dan Gohman076aee32009-03-04 19:44:21 +00004752// Register-Integer Addition with EFLAGS result
4753def : Pat<(parallel (X86add_flag GR8:$src1, imm:$src2),
Bill Wendlingd350e022008-12-12 21:15:41 +00004754 (implicit EFLAGS)),
4755 (ADD8ri GR8:$src1, imm:$src2)>;
Dan Gohman076aee32009-03-04 19:44:21 +00004756def : Pat<(parallel (X86add_flag GR16:$src1, imm:$src2),
Bill Wendlingd350e022008-12-12 21:15:41 +00004757 (implicit EFLAGS)),
4758 (ADD16ri GR16:$src1, imm:$src2)>;
Dan Gohman076aee32009-03-04 19:44:21 +00004759def : Pat<(parallel (X86add_flag GR32:$src1, imm:$src2),
Bill Wendlingd350e022008-12-12 21:15:41 +00004760 (implicit EFLAGS)),
4761 (ADD32ri GR32:$src1, imm:$src2)>;
Dan Gohman076aee32009-03-04 19:44:21 +00004762def : Pat<(parallel (X86add_flag GR16:$src1, i16immSExt8:$src2),
Bill Wendlingd350e022008-12-12 21:15:41 +00004763 (implicit EFLAGS)),
4764 (ADD16ri8 GR16:$src1, i16immSExt8:$src2)>;
Dan Gohman076aee32009-03-04 19:44:21 +00004765def : Pat<(parallel (X86add_flag GR32:$src1, i32immSExt8:$src2),
Bill Wendlingd350e022008-12-12 21:15:41 +00004766 (implicit EFLAGS)),
4767 (ADD32ri8 GR32:$src1, i32immSExt8:$src2)>;
4768
Dan Gohman076aee32009-03-04 19:44:21 +00004769// Memory-Register Addition with EFLAGS result
4770def : Pat<(parallel (store (X86add_flag (loadi8 addr:$dst), GR8:$src2),
Bill Wendlingd350e022008-12-12 21:15:41 +00004771 addr:$dst),
4772 (implicit EFLAGS)),
4773 (ADD8mr addr:$dst, GR8:$src2)>;
Dan Gohman076aee32009-03-04 19:44:21 +00004774def : Pat<(parallel (store (X86add_flag (loadi16 addr:$dst), GR16:$src2),
Bill Wendlingd350e022008-12-12 21:15:41 +00004775 addr:$dst),
4776 (implicit EFLAGS)),
4777 (ADD16mr addr:$dst, GR16:$src2)>;
Dan Gohman076aee32009-03-04 19:44:21 +00004778def : Pat<(parallel (store (X86add_flag (loadi32 addr:$dst), GR32:$src2),
Bill Wendlingd350e022008-12-12 21:15:41 +00004779 addr:$dst),
4780 (implicit EFLAGS)),
4781 (ADD32mr addr:$dst, GR32:$src2)>;
Dale Johannesenca11dae2009-05-18 17:44:15 +00004782
4783// Memory-Integer Addition with EFLAGS result
Dan Gohman076aee32009-03-04 19:44:21 +00004784def : Pat<(parallel (store (X86add_flag (loadi8 addr:$dst), imm:$src2),
Bill Wendlingd350e022008-12-12 21:15:41 +00004785 addr:$dst),
4786 (implicit EFLAGS)),
4787 (ADD8mi addr:$dst, imm:$src2)>;
Dan Gohman076aee32009-03-04 19:44:21 +00004788def : Pat<(parallel (store (X86add_flag (loadi16 addr:$dst), imm:$src2),
Bill Wendlingd350e022008-12-12 21:15:41 +00004789 addr:$dst),
4790 (implicit EFLAGS)),
4791 (ADD16mi addr:$dst, imm:$src2)>;
Dan Gohman076aee32009-03-04 19:44:21 +00004792def : Pat<(parallel (store (X86add_flag (loadi32 addr:$dst), imm:$src2),
Bill Wendlingd350e022008-12-12 21:15:41 +00004793 addr:$dst),
4794 (implicit EFLAGS)),
4795 (ADD32mi addr:$dst, imm:$src2)>;
Dan Gohman076aee32009-03-04 19:44:21 +00004796def : Pat<(parallel (store (X86add_flag (loadi16 addr:$dst), i16immSExt8:$src2),
Bill Wendlingd350e022008-12-12 21:15:41 +00004797 addr:$dst),
4798 (implicit EFLAGS)),
4799 (ADD16mi8 addr:$dst, i16immSExt8:$src2)>;
Dan Gohman076aee32009-03-04 19:44:21 +00004800def : Pat<(parallel (store (X86add_flag (loadi32 addr:$dst), i32immSExt8:$src2),
Bill Wendlingd350e022008-12-12 21:15:41 +00004801 addr:$dst),
4802 (implicit EFLAGS)),
4803 (ADD32mi8 addr:$dst, i32immSExt8:$src2)>;
4804
Dan Gohman076aee32009-03-04 19:44:21 +00004805// Register-Register Subtraction with EFLAGS result
4806def : Pat<(parallel (X86sub_flag GR8:$src1, GR8:$src2),
Bill Wendlingd350e022008-12-12 21:15:41 +00004807 (implicit EFLAGS)),
4808 (SUB8rr GR8:$src1, GR8:$src2)>;
Dan Gohman076aee32009-03-04 19:44:21 +00004809def : Pat<(parallel (X86sub_flag GR16:$src1, GR16:$src2),
Bill Wendlingd350e022008-12-12 21:15:41 +00004810 (implicit EFLAGS)),
4811 (SUB16rr GR16:$src1, GR16:$src2)>;
Dan Gohman076aee32009-03-04 19:44:21 +00004812def : Pat<(parallel (X86sub_flag GR32:$src1, GR32:$src2),
Bill Wendlingd350e022008-12-12 21:15:41 +00004813 (implicit EFLAGS)),
4814 (SUB32rr GR32:$src1, GR32:$src2)>;
4815
Dan Gohman076aee32009-03-04 19:44:21 +00004816// Register-Memory Subtraction with EFLAGS result
4817def : Pat<(parallel (X86sub_flag GR8:$src1, (loadi8 addr:$src2)),
Bill Wendlingd350e022008-12-12 21:15:41 +00004818 (implicit EFLAGS)),
4819 (SUB8rm GR8:$src1, addr:$src2)>;
Dan Gohman076aee32009-03-04 19:44:21 +00004820def : Pat<(parallel (X86sub_flag GR16:$src1, (loadi16 addr:$src2)),
Bill Wendlingd350e022008-12-12 21:15:41 +00004821 (implicit EFLAGS)),
4822 (SUB16rm GR16:$src1, addr:$src2)>;
Dan Gohman076aee32009-03-04 19:44:21 +00004823def : Pat<(parallel (X86sub_flag GR32:$src1, (loadi32 addr:$src2)),
Bill Wendlingd350e022008-12-12 21:15:41 +00004824 (implicit EFLAGS)),
4825 (SUB32rm GR32:$src1, addr:$src2)>;
4826
Dan Gohman076aee32009-03-04 19:44:21 +00004827// Register-Integer Subtraction with EFLAGS result
4828def : Pat<(parallel (X86sub_flag GR8:$src1, imm:$src2),
Bill Wendlingd350e022008-12-12 21:15:41 +00004829 (implicit EFLAGS)),
4830 (SUB8ri GR8:$src1, imm:$src2)>;
Dan Gohman076aee32009-03-04 19:44:21 +00004831def : Pat<(parallel (X86sub_flag GR16:$src1, imm:$src2),
Bill Wendlingd350e022008-12-12 21:15:41 +00004832 (implicit EFLAGS)),
4833 (SUB16ri GR16:$src1, imm:$src2)>;
Dan Gohman076aee32009-03-04 19:44:21 +00004834def : Pat<(parallel (X86sub_flag GR32:$src1, imm:$src2),
Bill Wendlingd350e022008-12-12 21:15:41 +00004835 (implicit EFLAGS)),
4836 (SUB32ri GR32:$src1, imm:$src2)>;
Dan Gohman076aee32009-03-04 19:44:21 +00004837def : Pat<(parallel (X86sub_flag GR16:$src1, i16immSExt8:$src2),
Bill Wendlingd350e022008-12-12 21:15:41 +00004838 (implicit EFLAGS)),
4839 (SUB16ri8 GR16:$src1, i16immSExt8:$src2)>;
Dan Gohman076aee32009-03-04 19:44:21 +00004840def : Pat<(parallel (X86sub_flag GR32:$src1, i32immSExt8:$src2),
Bill Wendlingd350e022008-12-12 21:15:41 +00004841 (implicit EFLAGS)),
4842 (SUB32ri8 GR32:$src1, i32immSExt8:$src2)>;
4843
Dan Gohman076aee32009-03-04 19:44:21 +00004844// Memory-Register Subtraction with EFLAGS result
4845def : Pat<(parallel (store (X86sub_flag (loadi8 addr:$dst), GR8:$src2),
Bill Wendlingd350e022008-12-12 21:15:41 +00004846 addr:$dst),
4847 (implicit EFLAGS)),
4848 (SUB8mr addr:$dst, GR8:$src2)>;
Dan Gohman076aee32009-03-04 19:44:21 +00004849def : Pat<(parallel (store (X86sub_flag (loadi16 addr:$dst), GR16:$src2),
Bill Wendlingd350e022008-12-12 21:15:41 +00004850 addr:$dst),
4851 (implicit EFLAGS)),
4852 (SUB16mr addr:$dst, GR16:$src2)>;
Dan Gohman076aee32009-03-04 19:44:21 +00004853def : Pat<(parallel (store (X86sub_flag (loadi32 addr:$dst), GR32:$src2),
Bill Wendlingd350e022008-12-12 21:15:41 +00004854 addr:$dst),
4855 (implicit EFLAGS)),
4856 (SUB32mr addr:$dst, GR32:$src2)>;
4857
Dan Gohman076aee32009-03-04 19:44:21 +00004858// Memory-Integer Subtraction with EFLAGS result
4859def : Pat<(parallel (store (X86sub_flag (loadi8 addr:$dst), imm:$src2),
Bill Wendlingd350e022008-12-12 21:15:41 +00004860 addr:$dst),
4861 (implicit EFLAGS)),
4862 (SUB8mi addr:$dst, imm:$src2)>;
Dan Gohman076aee32009-03-04 19:44:21 +00004863def : Pat<(parallel (store (X86sub_flag (loadi16 addr:$dst), imm:$src2),
Bill Wendlingd350e022008-12-12 21:15:41 +00004864 addr:$dst),
4865 (implicit EFLAGS)),
4866 (SUB16mi addr:$dst, imm:$src2)>;
Dan Gohman076aee32009-03-04 19:44:21 +00004867def : Pat<(parallel (store (X86sub_flag (loadi32 addr:$dst), imm:$src2),
Bill Wendlingd350e022008-12-12 21:15:41 +00004868 addr:$dst),
4869 (implicit EFLAGS)),
4870 (SUB32mi addr:$dst, imm:$src2)>;
Dan Gohman076aee32009-03-04 19:44:21 +00004871def : Pat<(parallel (store (X86sub_flag (loadi16 addr:$dst), i16immSExt8:$src2),
Bill Wendlingd350e022008-12-12 21:15:41 +00004872 addr:$dst),
4873 (implicit EFLAGS)),
4874 (SUB16mi8 addr:$dst, i16immSExt8:$src2)>;
Dan Gohman076aee32009-03-04 19:44:21 +00004875def : Pat<(parallel (store (X86sub_flag (loadi32 addr:$dst), i32immSExt8:$src2),
Bill Wendlingd350e022008-12-12 21:15:41 +00004876 addr:$dst),
4877 (implicit EFLAGS)),
4878 (SUB32mi8 addr:$dst, i32immSExt8:$src2)>;
4879
4880
Dan Gohman076aee32009-03-04 19:44:21 +00004881// Register-Register Signed Integer Multiply with EFLAGS result
4882def : Pat<(parallel (X86smul_flag GR16:$src1, GR16:$src2),
Bill Wendlingd350e022008-12-12 21:15:41 +00004883 (implicit EFLAGS)),
4884 (IMUL16rr GR16:$src1, GR16:$src2)>;
Dan Gohman076aee32009-03-04 19:44:21 +00004885def : Pat<(parallel (X86smul_flag GR32:$src1, GR32:$src2),
Bill Wendlingd350e022008-12-12 21:15:41 +00004886 (implicit EFLAGS)),
4887 (IMUL32rr GR32:$src1, GR32:$src2)>;
4888
Dan Gohman076aee32009-03-04 19:44:21 +00004889// Register-Memory Signed Integer Multiply with EFLAGS result
4890def : Pat<(parallel (X86smul_flag GR16:$src1, (loadi16 addr:$src2)),
Bill Wendlingd350e022008-12-12 21:15:41 +00004891 (implicit EFLAGS)),
4892 (IMUL16rm GR16:$src1, addr:$src2)>;
Dan Gohman076aee32009-03-04 19:44:21 +00004893def : Pat<(parallel (X86smul_flag GR32:$src1, (loadi32 addr:$src2)),
Bill Wendlingd350e022008-12-12 21:15:41 +00004894 (implicit EFLAGS)),
4895 (IMUL32rm GR32:$src1, addr:$src2)>;
4896
Dan Gohman076aee32009-03-04 19:44:21 +00004897// Register-Integer Signed Integer Multiply with EFLAGS result
4898def : Pat<(parallel (X86smul_flag GR16:$src1, imm:$src2),
Bill Wendlingd350e022008-12-12 21:15:41 +00004899 (implicit EFLAGS)),
4900 (IMUL16rri GR16:$src1, imm:$src2)>;
Dan Gohman076aee32009-03-04 19:44:21 +00004901def : Pat<(parallel (X86smul_flag GR32:$src1, imm:$src2),
Bill Wendlingd350e022008-12-12 21:15:41 +00004902 (implicit EFLAGS)),
4903 (IMUL32rri GR32:$src1, imm:$src2)>;
Dan Gohman076aee32009-03-04 19:44:21 +00004904def : Pat<(parallel (X86smul_flag GR16:$src1, i16immSExt8:$src2),
Bill Wendlingd350e022008-12-12 21:15:41 +00004905 (implicit EFLAGS)),
4906 (IMUL16rri8 GR16:$src1, i16immSExt8:$src2)>;
Dan Gohman076aee32009-03-04 19:44:21 +00004907def : Pat<(parallel (X86smul_flag GR32:$src1, i32immSExt8:$src2),
Bill Wendlingd350e022008-12-12 21:15:41 +00004908 (implicit EFLAGS)),
4909 (IMUL32rri8 GR32:$src1, i32immSExt8:$src2)>;
4910
Dan Gohman076aee32009-03-04 19:44:21 +00004911// Memory-Integer Signed Integer Multiply with EFLAGS result
4912def : Pat<(parallel (X86smul_flag (loadi16 addr:$src1), imm:$src2),
Bill Wendlingd350e022008-12-12 21:15:41 +00004913 (implicit EFLAGS)),
4914 (IMUL16rmi addr:$src1, imm:$src2)>;
Dan Gohman076aee32009-03-04 19:44:21 +00004915def : Pat<(parallel (X86smul_flag (loadi32 addr:$src1), imm:$src2),
Bill Wendlingd350e022008-12-12 21:15:41 +00004916 (implicit EFLAGS)),
4917 (IMUL32rmi addr:$src1, imm:$src2)>;
Dan Gohman076aee32009-03-04 19:44:21 +00004918def : Pat<(parallel (X86smul_flag (loadi16 addr:$src1), i16immSExt8:$src2),
Bill Wendlingd350e022008-12-12 21:15:41 +00004919 (implicit EFLAGS)),
4920 (IMUL16rmi8 addr:$src1, i16immSExt8:$src2)>;
Dan Gohman076aee32009-03-04 19:44:21 +00004921def : Pat<(parallel (X86smul_flag (loadi32 addr:$src1), i32immSExt8:$src2),
Bill Wendlingd350e022008-12-12 21:15:41 +00004922 (implicit EFLAGS)),
4923 (IMUL32rmi8 addr:$src1, i32immSExt8:$src2)>;
4924
Dan Gohman076aee32009-03-04 19:44:21 +00004925// Optimize multiply by 2 with EFLAGS result.
Evan Cheng6a86bd72009-01-27 03:30:42 +00004926let AddedComplexity = 2 in {
Dan Gohman076aee32009-03-04 19:44:21 +00004927def : Pat<(parallel (X86smul_flag GR16:$src1, 2),
Evan Cheng6a86bd72009-01-27 03:30:42 +00004928 (implicit EFLAGS)),
4929 (ADD16rr GR16:$src1, GR16:$src1)>;
4930
Dan Gohman076aee32009-03-04 19:44:21 +00004931def : Pat<(parallel (X86smul_flag GR32:$src1, 2),
Evan Cheng6a86bd72009-01-27 03:30:42 +00004932 (implicit EFLAGS)),
4933 (ADD32rr GR32:$src1, GR32:$src1)>;
4934}
4935
Dan Gohman076aee32009-03-04 19:44:21 +00004936// INC and DEC with EFLAGS result. Note that these do not set CF.
4937def : Pat<(parallel (X86inc_flag GR8:$src), (implicit EFLAGS)),
4938 (INC8r GR8:$src)>;
4939def : Pat<(parallel (store (i8 (X86inc_flag (loadi8 addr:$dst))), addr:$dst),
4940 (implicit EFLAGS)),
4941 (INC8m addr:$dst)>;
4942def : Pat<(parallel (X86dec_flag GR8:$src), (implicit EFLAGS)),
4943 (DEC8r GR8:$src)>;
4944def : Pat<(parallel (store (i8 (X86dec_flag (loadi8 addr:$dst))), addr:$dst),
4945 (implicit EFLAGS)),
4946 (DEC8m addr:$dst)>;
4947
4948def : Pat<(parallel (X86inc_flag GR16:$src), (implicit EFLAGS)),
Dan Gohman1f4af262009-03-05 21:32:23 +00004949 (INC16r GR16:$src)>, Requires<[In32BitMode]>;
Dan Gohman076aee32009-03-04 19:44:21 +00004950def : Pat<(parallel (store (i16 (X86inc_flag (loadi16 addr:$dst))), addr:$dst),
4951 (implicit EFLAGS)),
Dan Gohman1f4af262009-03-05 21:32:23 +00004952 (INC16m addr:$dst)>, Requires<[In32BitMode]>;
Dan Gohman076aee32009-03-04 19:44:21 +00004953def : Pat<(parallel (X86dec_flag GR16:$src), (implicit EFLAGS)),
Dan Gohman1f4af262009-03-05 21:32:23 +00004954 (DEC16r GR16:$src)>, Requires<[In32BitMode]>;
Dan Gohman076aee32009-03-04 19:44:21 +00004955def : Pat<(parallel (store (i16 (X86dec_flag (loadi16 addr:$dst))), addr:$dst),
4956 (implicit EFLAGS)),
Dan Gohman1f4af262009-03-05 21:32:23 +00004957 (DEC16m addr:$dst)>, Requires<[In32BitMode]>;
Dan Gohman076aee32009-03-04 19:44:21 +00004958
4959def : Pat<(parallel (X86inc_flag GR32:$src), (implicit EFLAGS)),
Dan Gohman1f4af262009-03-05 21:32:23 +00004960 (INC32r GR32:$src)>, Requires<[In32BitMode]>;
Dan Gohman076aee32009-03-04 19:44:21 +00004961def : Pat<(parallel (store (i32 (X86inc_flag (loadi32 addr:$dst))), addr:$dst),
4962 (implicit EFLAGS)),
Dan Gohman1f4af262009-03-05 21:32:23 +00004963 (INC32m addr:$dst)>, Requires<[In32BitMode]>;
Dan Gohman076aee32009-03-04 19:44:21 +00004964def : Pat<(parallel (X86dec_flag GR32:$src), (implicit EFLAGS)),
Dan Gohman1f4af262009-03-05 21:32:23 +00004965 (DEC32r GR32:$src)>, Requires<[In32BitMode]>;
Dan Gohman076aee32009-03-04 19:44:21 +00004966def : Pat<(parallel (store (i32 (X86dec_flag (loadi32 addr:$dst))), addr:$dst),
4967 (implicit EFLAGS)),
Dan Gohman1f4af262009-03-05 21:32:23 +00004968 (DEC32m addr:$dst)>, Requires<[In32BitMode]>;
Dan Gohman076aee32009-03-04 19:44:21 +00004969
Dan Gohmane220c4b2009-09-18 19:59:53 +00004970// Register-Register Or with EFLAGS result
4971def : Pat<(parallel (X86or_flag GR8:$src1, GR8:$src2),
4972 (implicit EFLAGS)),
4973 (OR8rr GR8:$src1, GR8:$src2)>;
4974def : Pat<(parallel (X86or_flag GR16:$src1, GR16:$src2),
4975 (implicit EFLAGS)),
4976 (OR16rr GR16:$src1, GR16:$src2)>;
4977def : Pat<(parallel (X86or_flag GR32:$src1, GR32:$src2),
4978 (implicit EFLAGS)),
4979 (OR32rr GR32:$src1, GR32:$src2)>;
4980
4981// Register-Memory Or with EFLAGS result
4982def : Pat<(parallel (X86or_flag GR8:$src1, (loadi8 addr:$src2)),
4983 (implicit EFLAGS)),
4984 (OR8rm GR8:$src1, addr:$src2)>;
4985def : Pat<(parallel (X86or_flag GR16:$src1, (loadi16 addr:$src2)),
4986 (implicit EFLAGS)),
4987 (OR16rm GR16:$src1, addr:$src2)>;
4988def : Pat<(parallel (X86or_flag GR32:$src1, (loadi32 addr:$src2)),
4989 (implicit EFLAGS)),
4990 (OR32rm GR32:$src1, addr:$src2)>;
4991
4992// Register-Integer Or with EFLAGS result
4993def : Pat<(parallel (X86or_flag GR8:$src1, imm:$src2),
4994 (implicit EFLAGS)),
4995 (OR8ri GR8:$src1, imm:$src2)>;
4996def : Pat<(parallel (X86or_flag GR16:$src1, imm:$src2),
4997 (implicit EFLAGS)),
4998 (OR16ri GR16:$src1, imm:$src2)>;
4999def : Pat<(parallel (X86or_flag GR32:$src1, imm:$src2),
5000 (implicit EFLAGS)),
5001 (OR32ri GR32:$src1, imm:$src2)>;
5002def : Pat<(parallel (X86or_flag GR16:$src1, i16immSExt8:$src2),
5003 (implicit EFLAGS)),
5004 (OR16ri8 GR16:$src1, i16immSExt8:$src2)>;
5005def : Pat<(parallel (X86or_flag GR32:$src1, i32immSExt8:$src2),
5006 (implicit EFLAGS)),
5007 (OR32ri8 GR32:$src1, i32immSExt8:$src2)>;
5008
5009// Memory-Register Or with EFLAGS result
5010def : Pat<(parallel (store (X86or_flag (loadi8 addr:$dst), GR8:$src2),
5011 addr:$dst),
5012 (implicit EFLAGS)),
5013 (OR8mr addr:$dst, GR8:$src2)>;
5014def : Pat<(parallel (store (X86or_flag (loadi16 addr:$dst), GR16:$src2),
5015 addr:$dst),
5016 (implicit EFLAGS)),
5017 (OR16mr addr:$dst, GR16:$src2)>;
5018def : Pat<(parallel (store (X86or_flag (loadi32 addr:$dst), GR32:$src2),
5019 addr:$dst),
5020 (implicit EFLAGS)),
5021 (OR32mr addr:$dst, GR32:$src2)>;
5022
5023// Memory-Integer Or with EFLAGS result
5024def : Pat<(parallel (store (X86or_flag (loadi8 addr:$dst), imm:$src2),
5025 addr:$dst),
5026 (implicit EFLAGS)),
5027 (OR8mi addr:$dst, imm:$src2)>;
5028def : Pat<(parallel (store (X86or_flag (loadi16 addr:$dst), imm:$src2),
5029 addr:$dst),
5030 (implicit EFLAGS)),
5031 (OR16mi addr:$dst, imm:$src2)>;
5032def : Pat<(parallel (store (X86or_flag (loadi32 addr:$dst), imm:$src2),
5033 addr:$dst),
5034 (implicit EFLAGS)),
5035 (OR32mi addr:$dst, imm:$src2)>;
5036def : Pat<(parallel (store (X86or_flag (loadi16 addr:$dst), i16immSExt8:$src2),
5037 addr:$dst),
5038 (implicit EFLAGS)),
5039 (OR16mi8 addr:$dst, i16immSExt8:$src2)>;
5040def : Pat<(parallel (store (X86or_flag (loadi32 addr:$dst), i32immSExt8:$src2),
5041 addr:$dst),
5042 (implicit EFLAGS)),
5043 (OR32mi8 addr:$dst, i32immSExt8:$src2)>;
5044
5045// Register-Register XOr with EFLAGS result
5046def : Pat<(parallel (X86xor_flag GR8:$src1, GR8:$src2),
5047 (implicit EFLAGS)),
5048 (XOR8rr GR8:$src1, GR8:$src2)>;
5049def : Pat<(parallel (X86xor_flag GR16:$src1, GR16:$src2),
5050 (implicit EFLAGS)),
5051 (XOR16rr GR16:$src1, GR16:$src2)>;
5052def : Pat<(parallel (X86xor_flag GR32:$src1, GR32:$src2),
5053 (implicit EFLAGS)),
5054 (XOR32rr GR32:$src1, GR32:$src2)>;
5055
5056// Register-Memory XOr with EFLAGS result
5057def : Pat<(parallel (X86xor_flag GR8:$src1, (loadi8 addr:$src2)),
5058 (implicit EFLAGS)),
5059 (XOR8rm GR8:$src1, addr:$src2)>;
5060def : Pat<(parallel (X86xor_flag GR16:$src1, (loadi16 addr:$src2)),
5061 (implicit EFLAGS)),
5062 (XOR16rm GR16:$src1, addr:$src2)>;
5063def : Pat<(parallel (X86xor_flag GR32:$src1, (loadi32 addr:$src2)),
5064 (implicit EFLAGS)),
5065 (XOR32rm GR32:$src1, addr:$src2)>;
5066
5067// Register-Integer XOr with EFLAGS result
5068def : Pat<(parallel (X86xor_flag GR8:$src1, imm:$src2),
5069 (implicit EFLAGS)),
5070 (XOR8ri GR8:$src1, imm:$src2)>;
5071def : Pat<(parallel (X86xor_flag GR16:$src1, imm:$src2),
5072 (implicit EFLAGS)),
5073 (XOR16ri GR16:$src1, imm:$src2)>;
5074def : Pat<(parallel (X86xor_flag GR32:$src1, imm:$src2),
5075 (implicit EFLAGS)),
5076 (XOR32ri GR32:$src1, imm:$src2)>;
5077def : Pat<(parallel (X86xor_flag GR16:$src1, i16immSExt8:$src2),
5078 (implicit EFLAGS)),
5079 (XOR16ri8 GR16:$src1, i16immSExt8:$src2)>;
5080def : Pat<(parallel (X86xor_flag GR32:$src1, i32immSExt8:$src2),
5081 (implicit EFLAGS)),
5082 (XOR32ri8 GR32:$src1, i32immSExt8:$src2)>;
5083
5084// Memory-Register XOr with EFLAGS result
5085def : Pat<(parallel (store (X86xor_flag (loadi8 addr:$dst), GR8:$src2),
5086 addr:$dst),
5087 (implicit EFLAGS)),
5088 (XOR8mr addr:$dst, GR8:$src2)>;
5089def : Pat<(parallel (store (X86xor_flag (loadi16 addr:$dst), GR16:$src2),
5090 addr:$dst),
5091 (implicit EFLAGS)),
5092 (XOR16mr addr:$dst, GR16:$src2)>;
5093def : Pat<(parallel (store (X86xor_flag (loadi32 addr:$dst), GR32:$src2),
5094 addr:$dst),
5095 (implicit EFLAGS)),
5096 (XOR32mr addr:$dst, GR32:$src2)>;
5097
5098// Memory-Integer XOr with EFLAGS result
5099def : Pat<(parallel (store (X86xor_flag (loadi8 addr:$dst), imm:$src2),
5100 addr:$dst),
5101 (implicit EFLAGS)),
5102 (XOR8mi addr:$dst, imm:$src2)>;
5103def : Pat<(parallel (store (X86xor_flag (loadi16 addr:$dst), imm:$src2),
5104 addr:$dst),
5105 (implicit EFLAGS)),
5106 (XOR16mi addr:$dst, imm:$src2)>;
5107def : Pat<(parallel (store (X86xor_flag (loadi32 addr:$dst), imm:$src2),
5108 addr:$dst),
5109 (implicit EFLAGS)),
5110 (XOR32mi addr:$dst, imm:$src2)>;
5111def : Pat<(parallel (store (X86xor_flag (loadi16 addr:$dst), i16immSExt8:$src2),
5112 addr:$dst),
5113 (implicit EFLAGS)),
5114 (XOR16mi8 addr:$dst, i16immSExt8:$src2)>;
5115def : Pat<(parallel (store (X86xor_flag (loadi32 addr:$dst), i32immSExt8:$src2),
5116 addr:$dst),
5117 (implicit EFLAGS)),
5118 (XOR32mi8 addr:$dst, i32immSExt8:$src2)>;
5119
5120// Register-Register And with EFLAGS result
5121def : Pat<(parallel (X86and_flag GR8:$src1, GR8:$src2),
5122 (implicit EFLAGS)),
5123 (AND8rr GR8:$src1, GR8:$src2)>;
5124def : Pat<(parallel (X86and_flag GR16:$src1, GR16:$src2),
5125 (implicit EFLAGS)),
5126 (AND16rr GR16:$src1, GR16:$src2)>;
5127def : Pat<(parallel (X86and_flag GR32:$src1, GR32:$src2),
5128 (implicit EFLAGS)),
5129 (AND32rr GR32:$src1, GR32:$src2)>;
5130
5131// Register-Memory And with EFLAGS result
5132def : Pat<(parallel (X86and_flag GR8:$src1, (loadi8 addr:$src2)),
5133 (implicit EFLAGS)),
5134 (AND8rm GR8:$src1, addr:$src2)>;
5135def : Pat<(parallel (X86and_flag GR16:$src1, (loadi16 addr:$src2)),
5136 (implicit EFLAGS)),
5137 (AND16rm GR16:$src1, addr:$src2)>;
5138def : Pat<(parallel (X86and_flag GR32:$src1, (loadi32 addr:$src2)),
5139 (implicit EFLAGS)),
5140 (AND32rm GR32:$src1, addr:$src2)>;
5141
5142// Register-Integer And with EFLAGS result
5143def : Pat<(parallel (X86and_flag GR8:$src1, imm:$src2),
5144 (implicit EFLAGS)),
5145 (AND8ri GR8:$src1, imm:$src2)>;
5146def : Pat<(parallel (X86and_flag GR16:$src1, imm:$src2),
5147 (implicit EFLAGS)),
5148 (AND16ri GR16:$src1, imm:$src2)>;
5149def : Pat<(parallel (X86and_flag GR32:$src1, imm:$src2),
5150 (implicit EFLAGS)),
5151 (AND32ri GR32:$src1, imm:$src2)>;
5152def : Pat<(parallel (X86and_flag GR16:$src1, i16immSExt8:$src2),
5153 (implicit EFLAGS)),
5154 (AND16ri8 GR16:$src1, i16immSExt8:$src2)>;
5155def : Pat<(parallel (X86and_flag GR32:$src1, i32immSExt8:$src2),
5156 (implicit EFLAGS)),
5157 (AND32ri8 GR32:$src1, i32immSExt8:$src2)>;
5158
5159// Memory-Register And with EFLAGS result
5160def : Pat<(parallel (store (X86and_flag (loadi8 addr:$dst), GR8:$src2),
5161 addr:$dst),
5162 (implicit EFLAGS)),
5163 (AND8mr addr:$dst, GR8:$src2)>;
5164def : Pat<(parallel (store (X86and_flag (loadi16 addr:$dst), GR16:$src2),
5165 addr:$dst),
5166 (implicit EFLAGS)),
5167 (AND16mr addr:$dst, GR16:$src2)>;
5168def : Pat<(parallel (store (X86and_flag (loadi32 addr:$dst), GR32:$src2),
5169 addr:$dst),
5170 (implicit EFLAGS)),
5171 (AND32mr addr:$dst, GR32:$src2)>;
5172
5173// Memory-Integer And with EFLAGS result
5174def : Pat<(parallel (store (X86and_flag (loadi8 addr:$dst), imm:$src2),
5175 addr:$dst),
5176 (implicit EFLAGS)),
5177 (AND8mi addr:$dst, imm:$src2)>;
5178def : Pat<(parallel (store (X86and_flag (loadi16 addr:$dst), imm:$src2),
5179 addr:$dst),
5180 (implicit EFLAGS)),
5181 (AND16mi addr:$dst, imm:$src2)>;
5182def : Pat<(parallel (store (X86and_flag (loadi32 addr:$dst), imm:$src2),
5183 addr:$dst),
5184 (implicit EFLAGS)),
5185 (AND32mi addr:$dst, imm:$src2)>;
5186def : Pat<(parallel (store (X86and_flag (loadi16 addr:$dst), i16immSExt8:$src2),
5187 addr:$dst),
5188 (implicit EFLAGS)),
5189 (AND16mi8 addr:$dst, i16immSExt8:$src2)>;
5190def : Pat<(parallel (store (X86and_flag (loadi32 addr:$dst), i32immSExt8:$src2),
5191 addr:$dst),
5192 (implicit EFLAGS)),
5193 (AND32mi8 addr:$dst, i32immSExt8:$src2)>;
5194
Dan Gohman2f67df72009-09-03 17:18:51 +00005195// -disable-16bit support.
Chris Lattner341b2742010-03-08 18:55:15 +00005196def : Pat<(truncstorei16 (i16 imm:$src), addr:$dst),
Dan Gohman2f67df72009-09-03 17:18:51 +00005197 (MOV16mi addr:$dst, imm:$src)>;
5198def : Pat<(truncstorei16 GR32:$src, addr:$dst),
5199 (MOV16mr addr:$dst, (EXTRACT_SUBREG GR32:$src, x86_subreg_16bit))>;
5200def : Pat<(i32 (sextloadi16 addr:$dst)),
5201 (MOVSX32rm16 addr:$dst)>;
5202def : Pat<(i32 (zextloadi16 addr:$dst)),
5203 (MOVZX32rm16 addr:$dst)>;
5204def : Pat<(i32 (extloadi16 addr:$dst)),
5205 (MOVZX32rm16 addr:$dst)>;
5206
Bill Wendlingd350e022008-12-12 21:15:41 +00005207//===----------------------------------------------------------------------===//
Evan Cheng4e4c71e2006-02-21 20:00:20 +00005208// Floating Point Stack Support
5209//===----------------------------------------------------------------------===//
5210
5211include "X86InstrFPStack.td"
5212
5213//===----------------------------------------------------------------------===//
Evan Chengc64a1a92007-07-31 08:04:03 +00005214// X86-64 Support
5215//===----------------------------------------------------------------------===//
5216
Chris Lattner36fe6d22008-01-10 05:50:42 +00005217include "X86Instr64bit.td"
Evan Chengc64a1a92007-07-31 08:04:03 +00005218
5219//===----------------------------------------------------------------------===//
David Greene51898d72010-02-09 23:52:19 +00005220// SIMD support (SSE, MMX and AVX)
5221//===----------------------------------------------------------------------===//
5222
5223include "X86InstrFragmentsSIMD.td"
5224
5225//===----------------------------------------------------------------------===//
Evan Cheng4e4c71e2006-02-21 20:00:20 +00005226// XMM Floating point support (requires SSE / SSE2)
5227//===----------------------------------------------------------------------===//
5228
5229include "X86InstrSSE.td"
Evan Cheng80f54042008-04-25 18:19:54 +00005230
5231//===----------------------------------------------------------------------===//
5232// MMX and XMM Packed Integer support (requires MMX, SSE, and SSE2)
5233//===----------------------------------------------------------------------===//
5234
5235include "X86InstrMMX.td"