blob: aac9f38c8a92b1dba5ddfe954084db454f7c09d3 [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
Evan Chenge3413162006-01-09 18:33:28 +000068def SDTX86RdTsc : 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
Evan Chenge3413162006-01-09 18:33:28 +0000146def X86rdtsc : SDNode<"X86ISD::RDTSC_DAG",SDTX86RdTsc,
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
Evan Chengaed7c722005-12-17 01:24:02 +0000181//===----------------------------------------------------------------------===//
182// X86 Operand Definitions.
183//
184
Chris Lattner7680e732009-06-20 19:34:09 +0000185def i32imm_pcrel : Operand<i32> {
186 let PrintMethod = "print_pcrel_imm";
187}
188
Dan Gohmana4714e02009-07-30 01:56:29 +0000189// A version of ptr_rc which excludes SP, ESP, and RSP. This is used for
190// the index operand of an address, to conform to x86 encoding restrictions.
191def ptr_rc_nosp : PointerLikeRegClass<1>;
Chris Lattner7680e732009-06-20 19:34:09 +0000192
Chris Lattner66fa1dc2004-08-11 02:25:00 +0000193// *mem - Operand definitions for the funky X86 addressing mode operands.
194//
Daniel Dunbar338825c2009-08-10 18:41:10 +0000195def X86MemAsmOperand : AsmOperandClass {
196 let Name = "Mem";
Daniel Dunbar8e001172009-08-10 19:08:02 +0000197 let SuperClass = ?;
Daniel Dunbar338825c2009-08-10 18:41:10 +0000198}
Evan Chengaf78ef52006-05-17 21:21:41 +0000199class X86MemOperand<string printMethod> : Operand<iPTR> {
Nate Begeman391c5d22005-11-30 18:54:35 +0000200 let PrintMethod = printMethod;
Dan Gohmana4714e02009-07-30 01:56:29 +0000201 let MIOperandInfo = (ops ptr_rc, i8imm, ptr_rc_nosp, i32imm, i8imm);
Daniel Dunbar338825c2009-08-10 18:41:10 +0000202 let ParserMatchClass = X86MemAsmOperand;
Chris Lattner66fa1dc2004-08-11 02:25:00 +0000203}
Nate Begeman391c5d22005-11-30 18:54:35 +0000204
Sean Callanan9947bbb2009-09-03 00:04:47 +0000205def opaque32mem : X86MemOperand<"printopaquemem">;
206def opaque48mem : X86MemOperand<"printopaquemem">;
207def opaque80mem : X86MemOperand<"printopaquemem">;
Sean Callanan108934c2009-12-18 00:01:26 +0000208def opaque512mem : X86MemOperand<"printopaquemem">;
209
210def offset8 : Operand<i64> { let PrintMethod = "print_pcrel_imm"; }
211def offset16 : Operand<i64> { let PrintMethod = "print_pcrel_imm"; }
212def offset32 : Operand<i64> { let PrintMethod = "print_pcrel_imm"; }
213def offset64 : Operand<i64> { let PrintMethod = "print_pcrel_imm"; }
Sean Callanan9947bbb2009-09-03 00:04:47 +0000214
Chris Lattner45432512005-12-17 19:47:05 +0000215def i8mem : X86MemOperand<"printi8mem">;
216def i16mem : X86MemOperand<"printi16mem">;
217def i32mem : X86MemOperand<"printi32mem">;
218def i64mem : X86MemOperand<"printi64mem">;
Evan Cheng470a6ad2006-02-22 02:26:30 +0000219def i128mem : X86MemOperand<"printi128mem">;
Chris Lattnere895c612009-09-20 07:17:49 +0000220//def i256mem : X86MemOperand<"printi256mem">;
Chris Lattner45432512005-12-17 19:47:05 +0000221def f32mem : X86MemOperand<"printf32mem">;
222def f64mem : X86MemOperand<"printf64mem">;
Dale Johannesen59a58732007-08-05 18:49:15 +0000223def f80mem : X86MemOperand<"printf80mem">;
Evan Cheng223547a2006-01-31 22:28:30 +0000224def f128mem : X86MemOperand<"printf128mem">;
Chris Lattnere895c612009-09-20 07:17:49 +0000225//def f256mem : X86MemOperand<"printf256mem">;
Nate Begeman391c5d22005-11-30 18:54:35 +0000226
Dan Gohman21e3dfb2009-04-13 16:09:41 +0000227// A version of i8mem for use on x86-64 that uses GR64_NOREX instead of
228// plain GR64, so that it doesn't potentially require a REX prefix.
229def i8mem_NOREX : Operand<i64> {
230 let PrintMethod = "printi8mem";
Dan Gohmana4714e02009-07-30 01:56:29 +0000231 let MIOperandInfo = (ops GR64_NOREX, i8imm, GR64_NOREX_NOSP, i32imm, i8imm);
Daniel Dunbar338825c2009-08-10 18:41:10 +0000232 let ParserMatchClass = X86MemAsmOperand;
Dan Gohman21e3dfb2009-04-13 16:09:41 +0000233}
234
Evan Cheng25ab6902006-09-08 06:48:29 +0000235def lea32mem : Operand<i32> {
Rafael Espindola094fad32009-04-08 21:14:34 +0000236 let PrintMethod = "printlea32mem";
Dan Gohman74f6f9a2009-08-05 17:40:24 +0000237 let MIOperandInfo = (ops GR32, i8imm, GR32_NOSP, i32imm);
Daniel Dunbar338825c2009-08-10 18:41:10 +0000238 let ParserMatchClass = X86MemAsmOperand;
Evan Cheng25ab6902006-09-08 06:48:29 +0000239}
240
Nate Begeman16b04f32005-07-15 00:38:55 +0000241def SSECC : Operand<i8> {
242 let PrintMethod = "printSSECC";
243}
Chris Lattner66fa1dc2004-08-11 02:25:00 +0000244
Daniel Dunbar338825c2009-08-10 18:41:10 +0000245def ImmSExt8AsmOperand : AsmOperandClass {
246 let Name = "ImmSExt8";
247 let SuperClass = ImmAsmOperand;
248}
249
Chris Lattnerf124d5e2005-11-18 01:04:42 +0000250// A couple of more descriptive operand definitions.
251// 16-bits but only 8 bits are significant.
Daniel Dunbar5fe63382009-08-09 07:20:21 +0000252def i16i8imm : Operand<i16> {
Daniel Dunbar338825c2009-08-10 18:41:10 +0000253 let ParserMatchClass = ImmSExt8AsmOperand;
Daniel Dunbar5fe63382009-08-09 07:20:21 +0000254}
Chris Lattnerf124d5e2005-11-18 01:04:42 +0000255// 32-bits but only 8 bits are significant.
Daniel Dunbar5fe63382009-08-09 07:20:21 +0000256def i32i8imm : Operand<i32> {
Daniel Dunbar338825c2009-08-10 18:41:10 +0000257 let ParserMatchClass = ImmSExt8AsmOperand;
Daniel Dunbar5fe63382009-08-09 07:20:21 +0000258}
Chris Lattnerf124d5e2005-11-18 01:04:42 +0000259
Chris Lattner7680e732009-06-20 19:34:09 +0000260// Branch targets have OtherVT type and print as pc-relative values.
261def brtarget : Operand<OtherVT> {
262 let PrintMethod = "print_pcrel_imm";
263}
Evan Chengd35b8c12005-12-04 08:19:43 +0000264
Evan Cheng77159e32009-07-21 06:00:18 +0000265def brtarget8 : Operand<OtherVT> {
266 let PrintMethod = "print_pcrel_imm";
267}
268
Evan Chengaed7c722005-12-17 01:24:02 +0000269//===----------------------------------------------------------------------===//
270// X86 Complex Pattern Definitions.
271//
272
Evan Chengec693f72005-12-08 02:01:35 +0000273// Define X86 specific addressing mode.
Rafael Espindola094fad32009-04-08 21:14:34 +0000274def addr : ComplexPattern<iPTR, 5, "SelectAddr", [], []>;
Evan Cheng25ab6902006-09-08 06:48:29 +0000275def lea32addr : ComplexPattern<i32, 4, "SelectLEAAddr",
Dan Gohmana98634b2009-08-02 16:09:17 +0000276 [add, sub, mul, X86mul_imm, shl, or, frameindex],
277 []>;
Chris Lattner5c0b16d2009-06-20 20:38:48 +0000278def tls32addr : ComplexPattern<i32, 4, "SelectTLSADDRAddr",
279 [tglobaltlsaddr], []>;
Evan Chengec693f72005-12-08 02:01:35 +0000280
Evan Chengaed7c722005-12-17 01:24:02 +0000281//===----------------------------------------------------------------------===//
Evan Chengbbc8ddb2005-12-20 22:59:51 +0000282// X86 Instruction Predicate Definitions.
Evan Cheng28b514392006-12-05 19:50:18 +0000283def HasMMX : Predicate<"Subtarget->hasMMX()">;
284def HasSSE1 : Predicate<"Subtarget->hasSSE1()">;
285def HasSSE2 : Predicate<"Subtarget->hasSSE2()">;
286def HasSSE3 : Predicate<"Subtarget->hasSSE3()">;
Bill Wendlingbb1ee052007-04-10 22:10:25 +0000287def HasSSSE3 : Predicate<"Subtarget->hasSSSE3()">;
Nate Begeman63ec90a2008-02-03 07:18:54 +0000288def HasSSE41 : Predicate<"Subtarget->hasSSE41()">;
289def HasSSE42 : Predicate<"Subtarget->hasSSE42()">;
David Greene343dadb2009-06-26 22:46:54 +0000290def HasSSE4A : Predicate<"Subtarget->hasSSE4A()">;
291def HasAVX : Predicate<"Subtarget->hasAVX()">;
292def HasFMA3 : Predicate<"Subtarget->hasFMA3()">;
293def HasFMA4 : Predicate<"Subtarget->hasFMA4()">;
Dale Johannesenf1fc3a82007-09-23 14:52:20 +0000294def FPStackf32 : Predicate<"!Subtarget->hasSSE1()">;
295def FPStackf64 : Predicate<"!Subtarget->hasSSE2()">;
Evan Cheng28b514392006-12-05 19:50:18 +0000296def In32BitMode : Predicate<"!Subtarget->is64Bit()">;
297def In64BitMode : Predicate<"Subtarget->is64Bit()">;
Anton Korobeynikovcf6b7392009-08-03 08:12:53 +0000298def IsWin64 : Predicate<"Subtarget->isTargetWin64()">;
299def NotWin64 : Predicate<"!Subtarget->isTargetWin64()">;
Anton Korobeynikovd7697d02009-08-06 11:23:24 +0000300def SmallCode : Predicate<"TM.getCodeModel() == CodeModel::Small">;
301def KernelCode : Predicate<"TM.getCodeModel() == CodeModel::Kernel">;
302def FarData : Predicate<"TM.getCodeModel() != CodeModel::Small &&"
Anton Korobeynikov186fa1d2009-08-06 09:11:19 +0000303 "TM.getCodeModel() != CodeModel::Kernel">;
Anton Korobeynikovd7697d02009-08-06 11:23:24 +0000304def NearData : Predicate<"TM.getCodeModel() == CodeModel::Small ||"
305 "TM.getCodeModel() == CodeModel::Kernel">;
Evan Cheng28b514392006-12-05 19:50:18 +0000306def IsStatic : Predicate<"TM.getRelocationModel() == Reloc::Static">;
Evan Chengb1f49812009-12-22 17:47:23 +0000307def OptForSize : Predicate<"OptForSize">;
Evan Chengb7a75a52008-09-26 23:41:32 +0000308def OptForSpeed : Predicate<"!OptForSize">;
Evan Chengccb69762009-01-02 05:35:45 +0000309def FastBTMem : Predicate<"!Subtarget->isBTMemSlow()">;
Evan Chengd7f666a2009-05-20 04:53:57 +0000310def CallImmAddr : Predicate<"Subtarget->IsLegalToCallImmediateAddr(TM)">;
Evan Chengbbc8ddb2005-12-20 22:59:51 +0000311
312//===----------------------------------------------------------------------===//
Evan Chengc64a1a92007-07-31 08:04:03 +0000313// X86 Instruction Format Definitions.
Evan Chengaed7c722005-12-17 01:24:02 +0000314//
315
Evan Chengc64a1a92007-07-31 08:04:03 +0000316include "X86InstrFormats.td"
Chris Lattner1cca5e32003-08-03 21:54:21 +0000317
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +0000318//===----------------------------------------------------------------------===//
Chris Lattnerf124d5e2005-11-18 01:04:42 +0000319// Pattern fragments...
320//
Evan Chengd9558e02006-01-06 00:43:03 +0000321
322// X86 specific condition code. These correspond to CondCode in
Nate Begeman9a225302007-05-06 04:00:55 +0000323// X86InstrInfo.h. They must be kept in synch.
Dan Gohman653456c2009-01-07 00:15:08 +0000324def X86_COND_A : PatLeaf<(i8 0)>; // alt. COND_NBE
325def X86_COND_AE : PatLeaf<(i8 1)>; // alt. COND_NC
326def X86_COND_B : PatLeaf<(i8 2)>; // alt. COND_C
327def X86_COND_BE : PatLeaf<(i8 3)>; // alt. COND_NA
328def X86_COND_E : PatLeaf<(i8 4)>; // alt. COND_Z
329def X86_COND_G : PatLeaf<(i8 5)>; // alt. COND_NLE
330def X86_COND_GE : PatLeaf<(i8 6)>; // alt. COND_NL
331def X86_COND_L : PatLeaf<(i8 7)>; // alt. COND_NGE
332def X86_COND_LE : PatLeaf<(i8 8)>; // alt. COND_NG
333def X86_COND_NE : PatLeaf<(i8 9)>; // alt. COND_NZ
Evan Chengd9558e02006-01-06 00:43:03 +0000334def X86_COND_NO : PatLeaf<(i8 10)>;
Dan Gohman653456c2009-01-07 00:15:08 +0000335def X86_COND_NP : PatLeaf<(i8 11)>; // alt. COND_PO
Evan Chengd9558e02006-01-06 00:43:03 +0000336def X86_COND_NS : PatLeaf<(i8 12)>;
Dan Gohman653456c2009-01-07 00:15:08 +0000337def X86_COND_O : PatLeaf<(i8 13)>;
338def X86_COND_P : PatLeaf<(i8 14)>; // alt. COND_PE
339def X86_COND_S : PatLeaf<(i8 15)>;
Evan Chengd9558e02006-01-06 00:43:03 +0000340
Evan Cheng9b6b6422005-12-13 00:14:11 +0000341def i16immSExt8 : PatLeaf<(i16 imm), [{
342 // i16immSExt8 predicate - True if the 16-bit immediate fits in a 8-bit
Evan Chengb3558542005-12-13 00:01:09 +0000343 // sign extended field.
Dan Gohmanf5aeb1a2008-09-12 16:56:44 +0000344 return (int16_t)N->getZExtValue() == (int8_t)N->getZExtValue();
Chris Lattnerf124d5e2005-11-18 01:04:42 +0000345}]>;
346
Evan Cheng9b6b6422005-12-13 00:14:11 +0000347def i32immSExt8 : PatLeaf<(i32 imm), [{
348 // i32immSExt8 predicate - True if the 32-bit immediate fits in a 8-bit
Evan Chengb3558542005-12-13 00:01:09 +0000349 // sign extended field.
Dan Gohmanf5aeb1a2008-09-12 16:56:44 +0000350 return (int32_t)N->getZExtValue() == (int8_t)N->getZExtValue();
Evan Chengb3558542005-12-13 00:01:09 +0000351}]>;
352
Evan Cheng605c4152005-12-13 01:57:51 +0000353// Helper fragments for loads.
Evan Chengb6564432008-05-13 18:59:59 +0000354// It's always safe to treat a anyext i16 load as a i32 load if the i16 is
355// known to be 32-bit aligned or better. Ditto for i8 to i16.
Dan Gohman33586292008-10-15 06:50:19 +0000356def loadi16 : PatFrag<(ops node:$ptr), (i16 (unindexedload node:$ptr)), [{
Dan Gohman67ca6be2008-08-20 15:24:22 +0000357 LoadSDNode *LD = cast<LoadSDNode>(N);
Chris Lattnerc2406f22009-04-10 00:16:23 +0000358 if (const Value *Src = LD->getSrcValue())
359 if (const PointerType *PT = dyn_cast<PointerType>(Src->getType()))
Mon P Wanga7e01d72009-04-27 07:22:10 +0000360 if (PT->getAddressSpace() > 255)
Chris Lattnerc2406f22009-04-10 00:16:23 +0000361 return false;
Dan Gohman67ca6be2008-08-20 15:24:22 +0000362 ISD::LoadExtType ExtType = LD->getExtensionType();
363 if (ExtType == ISD::NON_EXTLOAD)
364 return true;
365 if (ExtType == ISD::EXTLOAD)
366 return LD->getAlignment() >= 2 && !LD->isVolatile();
Evan Chengfa7fd332008-05-13 00:54:02 +0000367 return false;
368}]>;
369
Sean Callanan108934c2009-12-18 00:01:26 +0000370def loadi16_anyext : PatFrag<(ops node:$ptr), (i32 (unindexedload node:$ptr)),
371[{
Evan Chengca57f782008-09-24 23:27:55 +0000372 LoadSDNode *LD = cast<LoadSDNode>(N);
Chris Lattnerc2406f22009-04-10 00:16:23 +0000373 if (const Value *Src = LD->getSrcValue())
374 if (const PointerType *PT = dyn_cast<PointerType>(Src->getType()))
Mon P Wanga7e01d72009-04-27 07:22:10 +0000375 if (PT->getAddressSpace() > 255)
Chris Lattnerc2406f22009-04-10 00:16:23 +0000376 return false;
Evan Chengca57f782008-09-24 23:27:55 +0000377 ISD::LoadExtType ExtType = LD->getExtensionType();
378 if (ExtType == ISD::EXTLOAD)
379 return LD->getAlignment() >= 2 && !LD->isVolatile();
380 return false;
381}]>;
382
Dan Gohman33586292008-10-15 06:50:19 +0000383def loadi32 : PatFrag<(ops node:$ptr), (i32 (unindexedload node:$ptr)), [{
Dan Gohman67ca6be2008-08-20 15:24:22 +0000384 LoadSDNode *LD = cast<LoadSDNode>(N);
Chris Lattnerc2406f22009-04-10 00:16:23 +0000385 if (const Value *Src = LD->getSrcValue())
386 if (const PointerType *PT = dyn_cast<PointerType>(Src->getType()))
Mon P Wanga7e01d72009-04-27 07:22:10 +0000387 if (PT->getAddressSpace() > 255)
Chris Lattnerc2406f22009-04-10 00:16:23 +0000388 return false;
Dan Gohman67ca6be2008-08-20 15:24:22 +0000389 ISD::LoadExtType ExtType = LD->getExtensionType();
390 if (ExtType == ISD::NON_EXTLOAD)
391 return true;
392 if (ExtType == ISD::EXTLOAD)
393 return LD->getAlignment() >= 4 && !LD->isVolatile();
Evan Chengfa7fd332008-05-13 00:54:02 +0000394 return false;
395}]>;
396
Dan Gohman33586292008-10-15 06:50:19 +0000397def nvloadi32 : PatFrag<(ops node:$ptr), (i32 (unindexedload node:$ptr)), [{
Evan Chengd47e0b62008-09-29 17:26:18 +0000398 LoadSDNode *LD = cast<LoadSDNode>(N);
Chris Lattnerc2406f22009-04-10 00:16:23 +0000399 if (const Value *Src = LD->getSrcValue())
400 if (const PointerType *PT = dyn_cast<PointerType>(Src->getType()))
Mon P Wanga7e01d72009-04-27 07:22:10 +0000401 if (PT->getAddressSpace() > 255)
Chris Lattnerc2406f22009-04-10 00:16:23 +0000402 return false;
Evan Chengd47e0b62008-09-29 17:26:18 +0000403 if (LD->isVolatile())
404 return false;
Evan Chengd47e0b62008-09-29 17:26:18 +0000405 ISD::LoadExtType ExtType = LD->getExtensionType();
406 if (ExtType == ISD::NON_EXTLOAD)
407 return true;
408 if (ExtType == ISD::EXTLOAD)
409 return LD->getAlignment() >= 4;
410 return false;
411}]>;
412
Nate Begeman51a04372009-01-26 01:24:32 +0000413def gsload : PatFrag<(ops node:$ptr), (load node:$ptr), [{
Chris Lattnerc2406f22009-04-10 00:16:23 +0000414 if (const Value *Src = cast<LoadSDNode>(N)->getSrcValue())
415 if (const PointerType *PT = dyn_cast<PointerType>(Src->getType()))
416 return PT->getAddressSpace() == 256;
Nate Begeman51a04372009-01-26 01:24:32 +0000417 return false;
418}]>;
419
Chris Lattner1777d0c2009-05-05 18:52:19 +0000420def fsload : PatFrag<(ops node:$ptr), (load node:$ptr), [{
421 if (const Value *Src = cast<LoadSDNode>(N)->getSrcValue())
422 if (const PointerType *PT = dyn_cast<PointerType>(Src->getType()))
423 return PT->getAddressSpace() == 257;
424 return false;
425}]>;
426
Chris Lattnerc2406f22009-04-10 00:16:23 +0000427def loadi8 : PatFrag<(ops node:$ptr), (i8 (load node:$ptr)), [{
428 if (const Value *Src = cast<LoadSDNode>(N)->getSrcValue())
429 if (const PointerType *PT = dyn_cast<PointerType>(Src->getType()))
Mon P Wanga7e01d72009-04-27 07:22:10 +0000430 if (PT->getAddressSpace() > 255)
Chris Lattnerc2406f22009-04-10 00:16:23 +0000431 return false;
432 return true;
433}]>;
434def loadi64 : PatFrag<(ops node:$ptr), (i64 (load node:$ptr)), [{
435 if (const Value *Src = cast<LoadSDNode>(N)->getSrcValue())
436 if (const PointerType *PT = dyn_cast<PointerType>(Src->getType()))
Mon P Wanga7e01d72009-04-27 07:22:10 +0000437 if (PT->getAddressSpace() > 255)
Chris Lattnerc2406f22009-04-10 00:16:23 +0000438 return false;
439 return true;
440}]>;
Evan Cheng06a8aa12006-03-17 19:55:52 +0000441
Chris Lattnerc2406f22009-04-10 00:16:23 +0000442def loadf32 : PatFrag<(ops node:$ptr), (f32 (load node:$ptr)), [{
443 if (const Value *Src = cast<LoadSDNode>(N)->getSrcValue())
444 if (const PointerType *PT = dyn_cast<PointerType>(Src->getType()))
Mon P Wanga7e01d72009-04-27 07:22:10 +0000445 if (PT->getAddressSpace() > 255)
Chris Lattnerc2406f22009-04-10 00:16:23 +0000446 return false;
447 return true;
448}]>;
449def loadf64 : PatFrag<(ops node:$ptr), (f64 (load node:$ptr)), [{
450 if (const Value *Src = cast<LoadSDNode>(N)->getSrcValue())
451 if (const PointerType *PT = dyn_cast<PointerType>(Src->getType()))
Mon P Wanga7e01d72009-04-27 07:22:10 +0000452 if (PT->getAddressSpace() > 255)
Chris Lattnerc2406f22009-04-10 00:16:23 +0000453 return false;
454 return true;
455}]>;
456def loadf80 : PatFrag<(ops node:$ptr), (f80 (load node:$ptr)), [{
457 if (const Value *Src = cast<LoadSDNode>(N)->getSrcValue())
458 if (const PointerType *PT = dyn_cast<PointerType>(Src->getType()))
Mon P Wanga7e01d72009-04-27 07:22:10 +0000459 if (PT->getAddressSpace() > 255)
Chris Lattnerc2406f22009-04-10 00:16:23 +0000460 return false;
461 return true;
462}]>;
Evan Cheng7a7e8372005-12-14 02:22:27 +0000463
Evan Cheng466685d2006-10-09 20:57:25 +0000464def sextloadi16i8 : PatFrag<(ops node:$ptr), (i16 (sextloadi8 node:$ptr))>;
465def sextloadi32i8 : PatFrag<(ops node:$ptr), (i32 (sextloadi8 node:$ptr))>;
466def sextloadi32i16 : PatFrag<(ops node:$ptr), (i32 (sextloadi16 node:$ptr))>;
Evan Cheng7a7e8372005-12-14 02:22:27 +0000467
Evan Cheng466685d2006-10-09 20:57:25 +0000468def zextloadi8i1 : PatFrag<(ops node:$ptr), (i8 (zextloadi1 node:$ptr))>;
469def zextloadi16i1 : PatFrag<(ops node:$ptr), (i16 (zextloadi1 node:$ptr))>;
470def zextloadi32i1 : PatFrag<(ops node:$ptr), (i32 (zextloadi1 node:$ptr))>;
471def zextloadi16i8 : PatFrag<(ops node:$ptr), (i16 (zextloadi8 node:$ptr))>;
472def zextloadi32i8 : PatFrag<(ops node:$ptr), (i32 (zextloadi8 node:$ptr))>;
473def zextloadi32i16 : PatFrag<(ops node:$ptr), (i32 (zextloadi16 node:$ptr))>;
Evan Cheng7a7e8372005-12-14 02:22:27 +0000474
Evan Cheng466685d2006-10-09 20:57:25 +0000475def extloadi8i1 : PatFrag<(ops node:$ptr), (i8 (extloadi1 node:$ptr))>;
476def extloadi16i1 : PatFrag<(ops node:$ptr), (i16 (extloadi1 node:$ptr))>;
477def extloadi32i1 : PatFrag<(ops node:$ptr), (i32 (extloadi1 node:$ptr))>;
478def extloadi16i8 : PatFrag<(ops node:$ptr), (i16 (extloadi8 node:$ptr))>;
479def extloadi32i8 : PatFrag<(ops node:$ptr), (i32 (extloadi8 node:$ptr))>;
480def extloadi32i16 : PatFrag<(ops node:$ptr), (i32 (extloadi16 node:$ptr))>;
Evan Cheng747a90d2006-02-21 02:24:38 +0000481
Chris Lattnerce2bcc82008-02-19 17:37:35 +0000482
483// An 'and' node with a single use.
484def and_su : PatFrag<(ops node:$lhs, node:$rhs), (and node:$lhs, node:$rhs), [{
Evan Cheng07b7ea12008-03-04 00:40:35 +0000485 return N->hasOneUse();
Chris Lattnerce2bcc82008-02-19 17:37:35 +0000486}]>;
Dan Gohman21e3dfb2009-04-13 16:09:41 +0000487// An 'srl' node with a single use.
488def srl_su : PatFrag<(ops node:$lhs, node:$rhs), (srl node:$lhs, node:$rhs), [{
489 return N->hasOneUse();
490}]>;
491// An 'trunc' node with a single use.
492def trunc_su : PatFrag<(ops node:$src), (trunc node:$src), [{
493 return N->hasOneUse();
494}]>;
Chris Lattnerce2bcc82008-02-19 17:37:35 +0000495
Evan Cheng4b0345b2010-01-11 17:03:47 +0000496// Treat an 'or' node is as an 'add' if the or'ed bits are known to be zero.
497def or_is_add : PatFrag<(ops node:$lhs, node:$rhs), (or node:$lhs, node:$rhs),[{
498 if (ConstantSDNode *CN = dyn_cast<ConstantSDNode>(N->getOperand(1)))
499 return CurDAG->MaskedValueIsZero(N->getOperand(0), CN->getAPIntValue());
Evan Cheng199c4242010-01-11 22:03:29 +0000500 else {
501 unsigned BitWidth = N->getValueType(0).getScalarType().getSizeInBits();
502 APInt Mask = APInt::getAllOnesValue(BitWidth);
503 APInt KnownZero0, KnownOne0;
504 CurDAG->ComputeMaskedBits(N->getOperand(0), Mask, KnownZero0, KnownOne0, 0);
505 APInt KnownZero1, KnownOne1;
506 CurDAG->ComputeMaskedBits(N->getOperand(1), Mask, KnownZero1, KnownOne1, 0);
507 return (~KnownZero0 & ~KnownZero1) == 0;
508 }
Evan Cheng4b0345b2010-01-11 17:03:47 +0000509}]>;
510def or_not_add : PatFrag<(ops node:$lhs, node:$rhs),(or node:$lhs, node:$rhs),[{
Evan Cheng199c4242010-01-11 22:03:29 +0000511 if (ConstantSDNode *CN = dyn_cast<ConstantSDNode>(N->getOperand(1)))
512 return !CurDAG->MaskedValueIsZero(N->getOperand(0), CN->getAPIntValue());
513 else {
514 unsigned BitWidth = N->getValueType(0).getScalarType().getSizeInBits();
515 APInt Mask = APInt::getAllOnesValue(BitWidth);
516 APInt KnownZero0, KnownOne0;
517 CurDAG->ComputeMaskedBits(N->getOperand(0), Mask, KnownZero0, KnownOne0, 0);
518 APInt KnownZero1, KnownOne1;
519 CurDAG->ComputeMaskedBits(N->getOperand(1), Mask, KnownZero1, KnownOne1, 0);
520 return (~KnownZero0 & ~KnownZero1) != 0;
521 }
Evan Cheng4b0345b2010-01-11 17:03:47 +0000522}]>;
523
Dan Gohman74feef22008-10-17 01:23:35 +0000524// 'shld' and 'shrd' instruction patterns. Note that even though these have
525// the srl and shl in their patterns, the C++ code must still check for them,
526// because predicates are tested before children nodes are explored.
527
528def shrd : PatFrag<(ops node:$src1, node:$amt1, node:$src2, node:$amt2),
529 (or (srl node:$src1, node:$amt1),
530 (shl node:$src2, node:$amt2)), [{
531 assert(N->getOpcode() == ISD::OR);
532 return N->getOperand(0).getOpcode() == ISD::SRL &&
533 N->getOperand(1).getOpcode() == ISD::SHL &&
534 isa<ConstantSDNode>(N->getOperand(0).getOperand(1)) &&
535 isa<ConstantSDNode>(N->getOperand(1).getOperand(1)) &&
536 N->getOperand(0).getConstantOperandVal(1) ==
537 N->getValueSizeInBits(0) - N->getOperand(1).getConstantOperandVal(1);
538}]>;
539
540def shld : PatFrag<(ops node:$src1, node:$amt1, node:$src2, node:$amt2),
541 (or (shl node:$src1, node:$amt1),
542 (srl node:$src2, node:$amt2)), [{
543 assert(N->getOpcode() == ISD::OR);
544 return N->getOperand(0).getOpcode() == ISD::SHL &&
545 N->getOperand(1).getOpcode() == ISD::SRL &&
546 isa<ConstantSDNode>(N->getOperand(0).getOperand(1)) &&
547 isa<ConstantSDNode>(N->getOperand(1).getOperand(1)) &&
548 N->getOperand(0).getConstantOperandVal(1) ==
549 N->getValueSizeInBits(0) - N->getOperand(1).getConstantOperandVal(1);
550}]>;
551
Chris Lattnerf124d5e2005-11-18 01:04:42 +0000552//===----------------------------------------------------------------------===//
Chris Lattner1cca5e32003-08-03 21:54:21 +0000553// Instruction list...
554//
555
Chris Lattnerf18c0742006-10-12 17:42:56 +0000556// ADJCALLSTACKDOWN/UP implicitly use/def ESP because they may be expanded into
557// a stack adjustment and the codegen must know that they may modify the stack
558// pointer before prolog-epilog rewriting occurs.
Chris Lattner447ff682008-03-11 03:23:40 +0000559// Pessimistically assume ADJCALLSTACKDOWN / ADJCALLSTACKUP will become
560// sub / add which can clobber EFLAGS.
Evan Cheng8decf6b2007-09-28 01:19:48 +0000561let Defs = [ESP, EFLAGS], Uses = [ESP] in {
Dan Gohman6d4b0522008-10-01 18:28:06 +0000562def ADJCALLSTACKDOWN32 : I<0, Pseudo, (outs), (ins i32imm:$amt),
563 "#ADJCALLSTACKDOWN",
Chris Lattnere563bbc2008-10-11 22:08:30 +0000564 [(X86callseq_start timm:$amt)]>,
Dan Gohman6d4b0522008-10-01 18:28:06 +0000565 Requires<[In32BitMode]>;
566def ADJCALLSTACKUP32 : I<0, Pseudo, (outs), (ins i32imm:$amt1, i32imm:$amt2),
567 "#ADJCALLSTACKUP",
Chris Lattnere563bbc2008-10-11 22:08:30 +0000568 [(X86callseq_end timm:$amt1, timm:$amt2)]>,
Dan Gohman6d4b0522008-10-01 18:28:06 +0000569 Requires<[In32BitMode]>;
Evan Cheng071a2792007-09-11 19:55:27 +0000570}
Evan Cheng4a460802006-01-11 00:33:36 +0000571
Dan Gohmand6708ea2009-08-15 01:38:56 +0000572// x86-64 va_start lowering magic.
Dan Gohman533297b2009-10-29 18:10:34 +0000573let usesCustomInserter = 1 in
Dan Gohmand6708ea2009-08-15 01:38:56 +0000574def VASTART_SAVE_XMM_REGS : I<0, Pseudo,
575 (outs),
576 (ins GR8:$al,
577 i64imm:$regsavefi, i64imm:$offset,
578 variable_ops),
579 "#VASTART_SAVE_XMM_REGS $al, $regsavefi, $offset",
580 [(X86vastart_save_xmm_regs GR8:$al,
581 imm:$regsavefi,
582 imm:$offset)]>;
583
Evan Cheng4a460802006-01-11 00:33:36 +0000584// Nop
Sean Callanan74e52102009-07-23 23:39:34 +0000585let neverHasSideEffects = 1 in {
Chris Lattnerba7e7562008-01-10 07:59:24 +0000586 def NOOP : I<0x90, RawFrm, (outs), (ins), "nop", []>;
Sean Callanan108934c2009-12-18 00:01:26 +0000587 def NOOPW : I<0x1f, MRM0m, (outs), (ins i16mem:$zero),
588 "nop{w}\t$zero", []>, TB, OpSize;
Sean Callanan74e52102009-07-23 23:39:34 +0000589 def NOOPL : I<0x1f, MRM0m, (outs), (ins i32mem:$zero),
Sean Callanan108934c2009-12-18 00:01:26 +0000590 "nop{l}\t$zero", []>, TB;
Sean Callanan74e52102009-07-23 23:39:34 +0000591}
Evan Cheng4a460802006-01-11 00:33:36 +0000592
Sean Callanan1c5cf1b2009-08-11 01:09:06 +0000593// Trap
Dan Gohmane94975e2009-11-11 18:07:16 +0000594def INT3 : I<0xcc, RawFrm, (outs), (ins), "int\t3", []>;
Sean Callanan1c5cf1b2009-08-11 01:09:06 +0000595def INT : I<0xcd, RawFrm, (outs), (ins i8imm:$trap), "int\t$trap", []>;
Sean Callanan108934c2009-12-18 00:01:26 +0000596def IRET16 : I<0xcf, RawFrm, (outs), (ins), "iret{w}", []>, OpSize;
597def IRET32 : I<0xcf, RawFrm, (outs), (ins), "iret{l}", []>;
Sean Callanan1c5cf1b2009-08-11 01:09:06 +0000598
Chris Lattner71c7ace2009-09-20 07:32:00 +0000599// PIC base construction. This expands to code that looks like this:
600// call $next_inst
601// popl %destreg"
Dan Gohman2662d552008-10-01 04:14:30 +0000602let neverHasSideEffects = 1, isNotDuplicable = 1, Uses = [ESP] in
Chris Lattnerb3c85472009-09-20 07:28:26 +0000603 def MOVPC32r : Ii32<0xE8, Pseudo, (outs GR32:$reg), (ins i32imm:$label),
Chris Lattner71c7ace2009-09-20 07:32:00 +0000604 "", []>;
Evan Cheng8f7f7122006-05-05 05:40:20 +0000605
Chris Lattner1cca5e32003-08-03 21:54:21 +0000606//===----------------------------------------------------------------------===//
607// Control Flow Instructions...
608//
609
Chris Lattner1be48112005-05-13 17:56:48 +0000610// Return instructions.
Evan Cheng2b4ea792005-12-26 09:11:45 +0000611let isTerminator = 1, isReturn = 1, isBarrier = 1,
Chris Lattner447ff682008-03-11 03:23:40 +0000612 hasCtrlDep = 1, FPForm = SpecialFP, FPFormBits = SpecialFP.Value in {
Dan Gohmane4c67cd2008-05-31 02:11:25 +0000613 def RET : I <0xC3, RawFrm, (outs), (ins variable_ops),
Chris Lattner447ff682008-03-11 03:23:40 +0000614 "ret",
Dan Gohmane4c67cd2008-05-31 02:11:25 +0000615 [(X86retflag 0)]>;
Chris Lattner447ff682008-03-11 03:23:40 +0000616 def RETI : Ii16<0xC2, RawFrm, (outs), (ins i16imm:$amt, variable_ops),
617 "ret\t$amt",
Dan Gohman2f67df72009-09-03 17:18:51 +0000618 [(X86retflag timm:$amt)]>;
Sean Callanan356aed52009-09-15 23:37:51 +0000619 def LRET : I <0xCB, RawFrm, (outs), (ins),
620 "lret", []>;
621 def LRETI : Ii16<0xCA, RawFrm, (outs), (ins i16imm:$amt),
622 "lret\t$amt", []>;
Evan Cheng171049d2005-12-23 22:14:32 +0000623}
Chris Lattner1cca5e32003-08-03 21:54:21 +0000624
625// All branches are RawFrm, Void, Branch, and Terminators
Evan Chengffbacca2007-07-21 00:34:19 +0000626let isBranch = 1, isTerminator = 1 in
Evan Cheng64d80e32007-07-19 01:14:50 +0000627 class IBr<bits<8> opcode, dag ins, string asm, list<dag> pattern> :
628 I<opcode, RawFrm, (outs), ins, asm, pattern>;
Chris Lattner1cca5e32003-08-03 21:54:21 +0000629
Sean Callanan52925882009-07-22 01:05:20 +0000630let isBranch = 1, isBarrier = 1 in {
Dan Gohmanb1576f52007-07-31 20:11:57 +0000631 def JMP : IBr<0xE9, (ins brtarget:$dst), "jmp\t$dst", [(br bb:$dst)]>;
Sean Callanan52925882009-07-22 01:05:20 +0000632 def JMP8 : IBr<0xEB, (ins brtarget8:$dst), "jmp\t$dst", []>;
633}
Evan Cheng898101c2005-12-19 23:12:38 +0000634
Owen Anderson20ab2902007-11-12 07:39:39 +0000635// Indirect branches
636let isBranch = 1, isTerminator = 1, isBarrier = 1, isIndirectBranch = 1 in {
Dan Gohmanb1576f52007-07-31 20:11:57 +0000637 def JMP32r : I<0xFF, MRM4r, (outs), (ins GR32:$dst), "jmp{l}\t{*}$dst",
Evan Cheng069287d2006-05-16 07:21:53 +0000638 [(brind GR32:$dst)]>;
Dan Gohmanb1576f52007-07-31 20:11:57 +0000639 def JMP32m : I<0xFF, MRM4m, (outs), (ins i32mem:$dst), "jmp{l}\t{*}$dst",
Evan Cheng25ab6902006-09-08 06:48:29 +0000640 [(brind (loadi32 addr:$dst))]>;
Sean Callanan76f14be2009-09-15 00:35:17 +0000641
642 def FARJMP16i : Iseg16<0xEA, RawFrm, (outs),
643 (ins i16imm:$seg, i16imm:$off),
644 "ljmp{w}\t$seg, $off", []>, OpSize;
645 def FARJMP32i : Iseg32<0xEA, RawFrm, (outs),
646 (ins i16imm:$seg, i32imm:$off),
647 "ljmp{l}\t$seg, $off", []>;
648
649 def FARJMP16m : I<0xFF, MRM5m, (outs), (ins opaque32mem:$dst),
Sean Callanan9947bbb2009-09-03 00:04:47 +0000650 "ljmp{w}\t{*}$dst", []>, OpSize;
Sean Callanan76f14be2009-09-15 00:35:17 +0000651 def FARJMP32m : I<0xFF, MRM5m, (outs), (ins opaque48mem:$dst),
Sean Callanan9947bbb2009-09-03 00:04:47 +0000652 "ljmp{l}\t{*}$dst", []>;
Nate Begeman37efe672006-04-22 18:53:45 +0000653}
654
655// Conditional branches
Evan Cheng0488db92007-09-25 01:57:46 +0000656let Uses = [EFLAGS] in {
Evan Cheng77159e32009-07-21 06:00:18 +0000657// Short conditional jumps
658def JO8 : IBr<0x70, (ins brtarget8:$dst), "jo\t$dst", []>;
659def JNO8 : IBr<0x71, (ins brtarget8:$dst), "jno\t$dst", []>;
660def JB8 : IBr<0x72, (ins brtarget8:$dst), "jb\t$dst", []>;
661def JAE8 : IBr<0x73, (ins brtarget8:$dst), "jae\t$dst", []>;
662def JE8 : IBr<0x74, (ins brtarget8:$dst), "je\t$dst", []>;
663def JNE8 : IBr<0x75, (ins brtarget8:$dst), "jne\t$dst", []>;
664def JBE8 : IBr<0x76, (ins brtarget8:$dst), "jbe\t$dst", []>;
665def JA8 : IBr<0x77, (ins brtarget8:$dst), "ja\t$dst", []>;
666def JS8 : IBr<0x78, (ins brtarget8:$dst), "js\t$dst", []>;
667def JNS8 : IBr<0x79, (ins brtarget8:$dst), "jns\t$dst", []>;
668def JP8 : IBr<0x7A, (ins brtarget8:$dst), "jp\t$dst", []>;
669def JNP8 : IBr<0x7B, (ins brtarget8:$dst), "jnp\t$dst", []>;
670def JL8 : IBr<0x7C, (ins brtarget8:$dst), "jl\t$dst", []>;
671def JGE8 : IBr<0x7D, (ins brtarget8:$dst), "jge\t$dst", []>;
672def JLE8 : IBr<0x7E, (ins brtarget8:$dst), "jle\t$dst", []>;
673def JG8 : IBr<0x7F, (ins brtarget8:$dst), "jg\t$dst", []>;
674
675def JCXZ8 : IBr<0xE3, (ins brtarget8:$dst), "jcxz\t$dst", []>;
676
Dan Gohmanb1576f52007-07-31 20:11:57 +0000677def JE : IBr<0x84, (ins brtarget:$dst), "je\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +0000678 [(X86brcond bb:$dst, X86_COND_E, EFLAGS)]>, TB;
Dan Gohmanb1576f52007-07-31 20:11:57 +0000679def JNE : IBr<0x85, (ins brtarget:$dst), "jne\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +0000680 [(X86brcond bb:$dst, X86_COND_NE, EFLAGS)]>, TB;
Dan Gohmanb1576f52007-07-31 20:11:57 +0000681def JL : IBr<0x8C, (ins brtarget:$dst), "jl\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +0000682 [(X86brcond bb:$dst, X86_COND_L, EFLAGS)]>, TB;
Dan Gohmanb1576f52007-07-31 20:11:57 +0000683def JLE : IBr<0x8E, (ins brtarget:$dst), "jle\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +0000684 [(X86brcond bb:$dst, X86_COND_LE, EFLAGS)]>, TB;
Dan Gohmanb1576f52007-07-31 20:11:57 +0000685def JG : IBr<0x8F, (ins brtarget:$dst), "jg\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +0000686 [(X86brcond bb:$dst, X86_COND_G, EFLAGS)]>, TB;
Dan Gohmanb1576f52007-07-31 20:11:57 +0000687def JGE : IBr<0x8D, (ins brtarget:$dst), "jge\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +0000688 [(X86brcond bb:$dst, X86_COND_GE, EFLAGS)]>, TB;
Evan Cheng898101c2005-12-19 23:12:38 +0000689
Dan Gohmanb1576f52007-07-31 20:11:57 +0000690def JB : IBr<0x82, (ins brtarget:$dst), "jb\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +0000691 [(X86brcond bb:$dst, X86_COND_B, EFLAGS)]>, TB;
Dan Gohmanb1576f52007-07-31 20:11:57 +0000692def JBE : IBr<0x86, (ins brtarget:$dst), "jbe\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +0000693 [(X86brcond bb:$dst, X86_COND_BE, EFLAGS)]>, TB;
Dan Gohmanb1576f52007-07-31 20:11:57 +0000694def JA : IBr<0x87, (ins brtarget:$dst), "ja\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +0000695 [(X86brcond bb:$dst, X86_COND_A, EFLAGS)]>, TB;
Dan Gohmanb1576f52007-07-31 20:11:57 +0000696def JAE : IBr<0x83, (ins brtarget:$dst), "jae\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +0000697 [(X86brcond bb:$dst, X86_COND_AE, EFLAGS)]>, TB;
Evan Cheng898101c2005-12-19 23:12:38 +0000698
Dan Gohmanb1576f52007-07-31 20:11:57 +0000699def JS : IBr<0x88, (ins brtarget:$dst), "js\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +0000700 [(X86brcond bb:$dst, X86_COND_S, EFLAGS)]>, TB;
Dan Gohmanb1576f52007-07-31 20:11:57 +0000701def JNS : IBr<0x89, (ins brtarget:$dst), "jns\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +0000702 [(X86brcond bb:$dst, X86_COND_NS, EFLAGS)]>, TB;
Dan Gohmanb1576f52007-07-31 20:11:57 +0000703def JP : IBr<0x8A, (ins brtarget:$dst), "jp\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +0000704 [(X86brcond bb:$dst, X86_COND_P, EFLAGS)]>, TB;
Dan Gohmanb1576f52007-07-31 20:11:57 +0000705def JNP : IBr<0x8B, (ins brtarget:$dst), "jnp\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +0000706 [(X86brcond bb:$dst, X86_COND_NP, EFLAGS)]>, TB;
Dan Gohmanb1576f52007-07-31 20:11:57 +0000707def JO : IBr<0x80, (ins brtarget:$dst), "jo\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +0000708 [(X86brcond bb:$dst, X86_COND_O, EFLAGS)]>, TB;
Dan Gohmanb1576f52007-07-31 20:11:57 +0000709def JNO : IBr<0x81, (ins brtarget:$dst), "jno\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +0000710 [(X86brcond bb:$dst, X86_COND_NO, EFLAGS)]>, TB;
Evan Cheng0488db92007-09-25 01:57:46 +0000711} // Uses = [EFLAGS]
Chris Lattner1cca5e32003-08-03 21:54:21 +0000712
Sean Callanan7e6d7272009-09-16 21:50:07 +0000713// Loop instructions
714
715def LOOP : I<0xE2, RawFrm, (ins brtarget8:$dst), (outs), "loop\t$dst", []>;
716def LOOPE : I<0xE1, RawFrm, (ins brtarget8:$dst), (outs), "loope\t$dst", []>;
717def LOOPNE : I<0xE0, RawFrm, (ins brtarget8:$dst), (outs), "loopne\t$dst", []>;
718
Chris Lattner1cca5e32003-08-03 21:54:21 +0000719//===----------------------------------------------------------------------===//
720// Call Instructions...
721//
Evan Chengffbacca2007-07-21 00:34:19 +0000722let isCall = 1 in
Dan Gohman6d4b0522008-10-01 18:28:06 +0000723 // All calls clobber the non-callee saved registers. ESP is marked as
724 // a use to prevent stack-pointer assignments that appear immediately
725 // before calls from potentially appearing dead. Uses for argument
726 // registers are added manually.
Nate Begemanf63be7d2005-07-06 18:59:04 +0000727 let Defs = [EAX, ECX, EDX, FP0, FP1, FP2, FP3, FP4, FP5, FP6, ST0,
Bill Wendling3f3a17d2007-04-25 21:31:48 +0000728 MM0, MM1, MM2, MM3, MM4, MM5, MM6, MM7,
Evan Cheng109a5622008-10-17 21:02:22 +0000729 XMM0, XMM1, XMM2, XMM3, XMM4, XMM5, XMM6, XMM7,
730 XMM8, XMM9, XMM10, XMM11, XMM12, XMM13, XMM14, XMM15, EFLAGS],
Dan Gohman2662d552008-10-01 04:14:30 +0000731 Uses = [ESP] in {
Chris Lattner7680e732009-06-20 19:34:09 +0000732 def CALLpcrel32 : Ii32<0xE8, RawFrm,
733 (outs), (ins i32imm_pcrel:$dst,variable_ops),
734 "call\t$dst", []>;
Evan Cheng64d80e32007-07-19 01:14:50 +0000735 def CALL32r : I<0xFF, MRM2r, (outs), (ins GR32:$dst, variable_ops),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000736 "call\t{*}$dst", [(X86call GR32:$dst)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +0000737 def CALL32m : I<0xFF, MRM2m, (outs), (ins i32mem:$dst, variable_ops),
Dan Gohmanb4106172008-05-29 21:50:34 +0000738 "call\t{*}$dst", [(X86call (loadi32 addr:$dst))]>;
Sean Callanan9947bbb2009-09-03 00:04:47 +0000739
Sean Callanan76f14be2009-09-15 00:35:17 +0000740 def FARCALL16i : Iseg16<0x9A, RawFrm, (outs),
741 (ins i16imm:$seg, i16imm:$off),
742 "lcall{w}\t$seg, $off", []>, OpSize;
743 def FARCALL32i : Iseg32<0x9A, RawFrm, (outs),
744 (ins i16imm:$seg, i32imm:$off),
745 "lcall{l}\t$seg, $off", []>;
746
747 def FARCALL16m : I<0xFF, MRM3m, (outs), (ins opaque32mem:$dst),
Sean Callanan9947bbb2009-09-03 00:04:47 +0000748 "lcall{w}\t{*}$dst", []>, OpSize;
Sean Callanan76f14be2009-09-15 00:35:17 +0000749 def FARCALL32m : I<0xFF, MRM3m, (outs), (ins opaque48mem:$dst),
Sean Callanan9947bbb2009-09-03 00:04:47 +0000750 "lcall{l}\t{*}$dst", []>;
Chris Lattner1cca5e32003-08-03 21:54:21 +0000751 }
752
Sean Callanan8d708542009-09-16 02:57:13 +0000753// Constructing a stack frame.
754
755def ENTER : I<0xC8, RawFrm, (outs), (ins i16imm:$len, i8imm:$lvl),
756 "enter\t$len, $lvl", []>;
757
Chris Lattner1e9448b2005-05-15 03:10:37 +0000758// Tail call stuff.
Arnold Schwaighoferc85e1712007-10-11 19:40:01 +0000759
Evan Chengffbacca2007-07-21 00:34:19 +0000760let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1 in
Sean Callanan108934c2009-12-18 00:01:26 +0000761def TCRETURNdi : I<0, Pseudo, (outs),
762 (ins i32imm:$dst, i32imm:$offset, variable_ops),
Arnold Schwaighoferc85e1712007-10-11 19:40:01 +0000763 "#TC_RETURN $dst $offset",
764 []>;
765
766let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1 in
Sean Callanan108934c2009-12-18 00:01:26 +0000767def TCRETURNri : I<0, Pseudo, (outs),
768 (ins GR32:$dst, i32imm:$offset, variable_ops),
Arnold Schwaighoferc85e1712007-10-11 19:40:01 +0000769 "#TC_RETURN $dst $offset",
770 []>;
771
772let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1 in
Chris Lattner7680e732009-06-20 19:34:09 +0000773 def TAILJMPd : IBr<0xE9, (ins i32imm_pcrel:$dst), "jmp\t$dst # TAILCALL",
Evan Chengf10c17f2006-09-22 21:43:59 +0000774 []>;
Evan Chengffbacca2007-07-21 00:34:19 +0000775let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1 in
Sean Callanan108934c2009-12-18 00:01:26 +0000776 def TAILJMPr : I<0xFF, MRM4r, (outs), (ins GR32:$dst),
777 "jmp{l}\t{*}$dst # TAILCALL",
Arnold Schwaighoferc85e1712007-10-11 19:40:01 +0000778 []>;
Evan Chengffbacca2007-07-21 00:34:19 +0000779let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1 in
Evan Cheng64d80e32007-07-19 01:14:50 +0000780 def TAILJMPm : I<0xFF, MRM4m, (outs), (ins i32mem:$dst),
Arnold Schwaighoferc85e1712007-10-11 19:40:01 +0000781 "jmp\t{*}$dst # TAILCALL", []>;
Chris Lattner1e9448b2005-05-15 03:10:37 +0000782
Chris Lattner1cca5e32003-08-03 21:54:21 +0000783//===----------------------------------------------------------------------===//
784// Miscellaneous Instructions...
785//
Chris Lattnerba7e7562008-01-10 07:59:24 +0000786let Defs = [EBP, ESP], Uses = [EBP, ESP], mayLoad = 1, neverHasSideEffects=1 in
Chris Lattner30bf2d82004-08-10 20:17:41 +0000787def LEAVE : I<0xC9, RawFrm,
Evan Cheng071a2792007-09-11 19:55:27 +0000788 (outs), (ins), "leave", []>;
789
Sean Callanan108934c2009-12-18 00:01:26 +0000790def POPCNT16rr : I<0xB8, MRMSrcReg, (outs GR16:$dst), (ins GR16:$src),
791 "popcnt{w}\t{$src, $dst|$dst, $src}", []>, OpSize, XS;
792def POPCNT16rm : I<0xB8, MRMSrcMem, (outs GR16:$dst), (ins i16mem:$src),
793 "popcnt{w}\t{$src, $dst|$dst, $src}", []>, OpSize, XS;
794def POPCNT32rr : I<0xB8, MRMSrcReg, (outs GR32:$dst), (ins GR32:$src),
795 "popcnt{l}\t{$src, $dst|$dst, $src}", []>, XS;
796def POPCNT32rm : I<0xB8, MRMSrcMem, (outs GR32:$dst), (ins i32mem:$src),
797 "popcnt{l}\t{$src, $dst|$dst, $src}", []>, XS;
798
Chris Lattnerba7e7562008-01-10 07:59:24 +0000799let Defs = [ESP], Uses = [ESP], neverHasSideEffects=1 in {
Sean Callanan1f24e012009-09-10 18:29:13 +0000800let mayLoad = 1 in {
801def POP16r : I<0x58, AddRegFrm, (outs GR16:$reg), (ins), "pop{w}\t$reg", []>,
802 OpSize;
803def POP32r : I<0x58, AddRegFrm, (outs GR32:$reg), (ins), "pop{l}\t$reg", []>;
804def POP16rmr: I<0x8F, MRM0r, (outs GR16:$reg), (ins), "pop{w}\t$reg", []>,
805 OpSize;
806def POP16rmm: I<0x8F, MRM0m, (outs i16mem:$dst), (ins), "pop{w}\t$dst", []>,
807 OpSize;
808def POP32rmr: I<0x8F, MRM0r, (outs GR32:$reg), (ins), "pop{l}\t$reg", []>;
809def POP32rmm: I<0x8F, MRM0m, (outs i32mem:$dst), (ins), "pop{l}\t$dst", []>;
810}
Chris Lattner1cca5e32003-08-03 21:54:21 +0000811
Sean Callanan1f24e012009-09-10 18:29:13 +0000812let mayStore = 1 in {
813def PUSH16r : I<0x50, AddRegFrm, (outs), (ins GR16:$reg), "push{w}\t$reg",[]>,
814 OpSize;
Evan Cheng2f245ba2007-09-26 01:29:06 +0000815def PUSH32r : I<0x50, AddRegFrm, (outs), (ins GR32:$reg), "push{l}\t$reg",[]>;
Sean Callanan1f24e012009-09-10 18:29:13 +0000816def PUSH16rmr: I<0xFF, MRM6r, (outs), (ins GR16:$reg), "push{w}\t$reg",[]>,
817 OpSize;
818def PUSH16rmm: I<0xFF, MRM6m, (outs), (ins i16mem:$src), "push{w}\t$src",[]>,
819 OpSize;
820def PUSH32rmr: I<0xFF, MRM6r, (outs), (ins GR32:$reg), "push{l}\t$reg",[]>;
821def PUSH32rmm: I<0xFF, MRM6m, (outs), (ins i32mem:$src), "push{l}\t$src",[]>;
822}
Evan Cheng071a2792007-09-11 19:55:27 +0000823}
Anton Korobeynikov57fc00d2007-04-17 09:20:00 +0000824
Bill Wendling453eb262009-06-15 19:39:04 +0000825let Defs = [ESP], Uses = [ESP], neverHasSideEffects = 1, mayStore = 1 in {
826def PUSH32i8 : Ii8<0x6a, RawFrm, (outs), (ins i8imm:$imm),
Bill Wendling927788c2009-06-15 20:59:31 +0000827 "push{l}\t$imm", []>;
Bill Wendling453eb262009-06-15 19:39:04 +0000828def PUSH32i16 : Ii16<0x68, RawFrm, (outs), (ins i16imm:$imm),
Bill Wendling927788c2009-06-15 20:59:31 +0000829 "push{l}\t$imm", []>;
Bill Wendling453eb262009-06-15 19:39:04 +0000830def PUSH32i32 : Ii32<0x68, RawFrm, (outs), (ins i32imm:$imm),
Bill Wendling927788c2009-06-15 20:59:31 +0000831 "push{l}\t$imm", []>;
Bill Wendling453eb262009-06-15 19:39:04 +0000832}
833
Sean Callanan108934c2009-12-18 00:01:26 +0000834let Defs = [ESP, EFLAGS], Uses = [ESP], mayLoad = 1, neverHasSideEffects=1 in {
835def POPF : I<0x9D, RawFrm, (outs), (ins), "popf{w}", []>, OpSize;
836def POPFD : I<0x9D, RawFrm, (outs), (ins), "popf{l}", []>;
837}
838let Defs = [ESP], Uses = [ESP, EFLAGS], mayStore = 1, neverHasSideEffects=1 in {
839def PUSHF : I<0x9C, RawFrm, (outs), (ins), "pushf{w}", []>, OpSize;
840def PUSHFD : I<0x9C, RawFrm, (outs), (ins), "pushf{l}", []>;
841}
Evan Cheng2f245ba2007-09-26 01:29:06 +0000842
Evan Cheng069287d2006-05-16 07:21:53 +0000843let isTwoAddress = 1 in // GR32 = bswap GR32
Chris Lattner30bf2d82004-08-10 20:17:41 +0000844 def BSWAP32r : I<0xC8, AddRegFrm,
Evan Cheng64d80e32007-07-19 01:14:50 +0000845 (outs GR32:$dst), (ins GR32:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000846 "bswap{l}\t$dst",
Evan Cheng069287d2006-05-16 07:21:53 +0000847 [(set GR32:$dst, (bswap GR32:$src))]>, TB;
Chris Lattner1cca5e32003-08-03 21:54:21 +0000848
Chris Lattner1cca5e32003-08-03 21:54:21 +0000849
Evan Cheng18efe262007-12-14 02:13:44 +0000850// Bit scan instructions.
851let Defs = [EFLAGS] in {
Evan Chengfd9e4732007-12-14 18:49:43 +0000852def BSF16rr : I<0xBC, MRMSrcReg, (outs GR16:$dst), (ins GR16:$src),
Dan Gohman1a8001e2007-12-14 15:10:00 +0000853 "bsf{w}\t{$src, $dst|$dst, $src}",
Evan Cheng152804e2007-12-14 08:30:15 +0000854 [(set GR16:$dst, (X86bsf GR16:$src)), (implicit EFLAGS)]>, TB;
Evan Cheng18efe262007-12-14 02:13:44 +0000855def BSF16rm : I<0xBC, MRMSrcMem, (outs GR16:$dst), (ins i16mem:$src),
Dan Gohman1a8001e2007-12-14 15:10:00 +0000856 "bsf{w}\t{$src, $dst|$dst, $src}",
Evan Cheng152804e2007-12-14 08:30:15 +0000857 [(set GR16:$dst, (X86bsf (loadi16 addr:$src))),
858 (implicit EFLAGS)]>, TB;
Evan Chengfd9e4732007-12-14 18:49:43 +0000859def BSF32rr : I<0xBC, MRMSrcReg, (outs GR32:$dst), (ins GR32:$src),
Dan Gohman1a8001e2007-12-14 15:10:00 +0000860 "bsf{l}\t{$src, $dst|$dst, $src}",
Evan Cheng152804e2007-12-14 08:30:15 +0000861 [(set GR32:$dst, (X86bsf GR32:$src)), (implicit EFLAGS)]>, TB;
Evan Cheng18efe262007-12-14 02:13:44 +0000862def BSF32rm : I<0xBC, MRMSrcMem, (outs GR32:$dst), (ins i32mem:$src),
Dan Gohman1a8001e2007-12-14 15:10:00 +0000863 "bsf{l}\t{$src, $dst|$dst, $src}",
Evan Cheng152804e2007-12-14 08:30:15 +0000864 [(set GR32:$dst, (X86bsf (loadi32 addr:$src))),
865 (implicit EFLAGS)]>, TB;
Evan Cheng18efe262007-12-14 02:13:44 +0000866
Evan Chengfd9e4732007-12-14 18:49:43 +0000867def BSR16rr : I<0xBD, MRMSrcReg, (outs GR16:$dst), (ins GR16:$src),
Dan Gohman1a8001e2007-12-14 15:10:00 +0000868 "bsr{w}\t{$src, $dst|$dst, $src}",
Evan Cheng152804e2007-12-14 08:30:15 +0000869 [(set GR16:$dst, (X86bsr GR16:$src)), (implicit EFLAGS)]>, TB;
Evan Cheng18efe262007-12-14 02:13:44 +0000870def BSR16rm : I<0xBD, MRMSrcMem, (outs GR16:$dst), (ins i16mem:$src),
Dan Gohman1a8001e2007-12-14 15:10:00 +0000871 "bsr{w}\t{$src, $dst|$dst, $src}",
Evan Cheng152804e2007-12-14 08:30:15 +0000872 [(set GR16:$dst, (X86bsr (loadi16 addr:$src))),
873 (implicit EFLAGS)]>, TB;
Evan Chengfd9e4732007-12-14 18:49:43 +0000874def BSR32rr : I<0xBD, MRMSrcReg, (outs GR32:$dst), (ins GR32:$src),
Dan Gohman1a8001e2007-12-14 15:10:00 +0000875 "bsr{l}\t{$src, $dst|$dst, $src}",
Evan Cheng152804e2007-12-14 08:30:15 +0000876 [(set GR32:$dst, (X86bsr GR32:$src)), (implicit EFLAGS)]>, TB;
Evan Cheng18efe262007-12-14 02:13:44 +0000877def BSR32rm : I<0xBD, MRMSrcMem, (outs GR32:$dst), (ins i32mem:$src),
Dan Gohman1a8001e2007-12-14 15:10:00 +0000878 "bsr{l}\t{$src, $dst|$dst, $src}",
Evan Cheng152804e2007-12-14 08:30:15 +0000879 [(set GR32:$dst, (X86bsr (loadi32 addr:$src))),
880 (implicit EFLAGS)]>, TB;
Evan Cheng18efe262007-12-14 02:13:44 +0000881} // Defs = [EFLAGS]
882
Chris Lattnerba7e7562008-01-10 07:59:24 +0000883let neverHasSideEffects = 1 in
Chris Lattner3a173df2004-10-03 20:35:00 +0000884def LEA16r : I<0x8D, MRMSrcMem,
Evan Cheng15b0d972009-12-12 18:51:56 +0000885 (outs GR16:$dst), (ins lea32mem:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000886 "lea{w}\t{$src|$dst}, {$dst|$src}", []>, OpSize;
Evan Chenge771ebd2008-03-27 01:41:09 +0000887let isReMaterializable = 1 in
Chris Lattner3a173df2004-10-03 20:35:00 +0000888def LEA32r : I<0x8D, MRMSrcMem,
Evan Cheng64d80e32007-07-19 01:14:50 +0000889 (outs GR32:$dst), (ins lea32mem:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000890 "lea{l}\t{$src|$dst}, {$dst|$src}",
Evan Cheng25ab6902006-09-08 06:48:29 +0000891 [(set GR32:$dst, lea32addr:$src)]>, Requires<[In32BitMode]>;
Chris Lattner1cca5e32003-08-03 21:54:21 +0000892
Evan Cheng071a2792007-09-11 19:55:27 +0000893let Defs = [ECX,EDI,ESI], Uses = [ECX,EDI,ESI] in {
Evan Cheng64d80e32007-07-19 01:14:50 +0000894def REP_MOVSB : I<0xA4, RawFrm, (outs), (ins), "{rep;movsb|rep movsb}",
Evan Cheng071a2792007-09-11 19:55:27 +0000895 [(X86rep_movs i8)]>, REP;
Evan Cheng64d80e32007-07-19 01:14:50 +0000896def REP_MOVSW : I<0xA5, RawFrm, (outs), (ins), "{rep;movsw|rep movsw}",
Evan Cheng071a2792007-09-11 19:55:27 +0000897 [(X86rep_movs i16)]>, REP, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +0000898def REP_MOVSD : I<0xA5, RawFrm, (outs), (ins), "{rep;movsl|rep movsd}",
Evan Cheng071a2792007-09-11 19:55:27 +0000899 [(X86rep_movs i32)]>, REP;
900}
Chris Lattner915e5e52004-02-12 17:53:22 +0000901
Evan Cheng071a2792007-09-11 19:55:27 +0000902let Defs = [ECX,EDI], Uses = [AL,ECX,EDI] in
Evan Cheng64d80e32007-07-19 01:14:50 +0000903def REP_STOSB : I<0xAA, RawFrm, (outs), (ins), "{rep;stosb|rep stosb}",
Evan Cheng071a2792007-09-11 19:55:27 +0000904 [(X86rep_stos i8)]>, REP;
905let Defs = [ECX,EDI], Uses = [AX,ECX,EDI] in
Evan Cheng64d80e32007-07-19 01:14:50 +0000906def REP_STOSW : I<0xAB, RawFrm, (outs), (ins), "{rep;stosw|rep stosw}",
Evan Cheng071a2792007-09-11 19:55:27 +0000907 [(X86rep_stos i16)]>, REP, OpSize;
908let Defs = [ECX,EDI], Uses = [EAX,ECX,EDI] in
Evan Cheng64d80e32007-07-19 01:14:50 +0000909def REP_STOSD : I<0xAB, RawFrm, (outs), (ins), "{rep;stosl|rep stosd}",
Evan Cheng071a2792007-09-11 19:55:27 +0000910 [(X86rep_stos i32)]>, REP;
Chris Lattner30bf2d82004-08-10 20:17:41 +0000911
Sean Callanana82e4652009-09-12 00:37:19 +0000912def SCAS8 : I<0xAE, RawFrm, (outs), (ins), "scas{b}", []>;
913def SCAS16 : I<0xAF, RawFrm, (outs), (ins), "scas{w}", []>, OpSize;
914def SCAS32 : I<0xAF, RawFrm, (outs), (ins), "scas{l}", []>;
915
Sean Callanan6f8f4622009-09-12 02:25:20 +0000916def CMPS8 : I<0xA6, RawFrm, (outs), (ins), "cmps{b}", []>;
917def CMPS16 : I<0xA7, RawFrm, (outs), (ins), "cmps{w}", []>, OpSize;
918def CMPS32 : I<0xA7, RawFrm, (outs), (ins), "cmps{l}", []>;
919
Evan Cheng071a2792007-09-11 19:55:27 +0000920let Defs = [RAX, RDX] in
Evan Cheng64d80e32007-07-19 01:14:50 +0000921def RDTSC : I<0x31, RawFrm, (outs), (ins), "rdtsc", [(X86rdtsc)]>,
Evan Cheng071a2792007-09-11 19:55:27 +0000922 TB;
Chris Lattnerb89abef2004-02-14 04:45:37 +0000923
Anton Korobeynikov66fac792008-01-15 07:02:33 +0000924let isBarrier = 1, hasCtrlDep = 1 in {
Chris Lattnerda68d302008-01-15 21:58:22 +0000925def TRAP : I<0x0B, RawFrm, (outs), (ins), "ud2", [(trap)]>, TB;
Anton Korobeynikov66fac792008-01-15 07:02:33 +0000926}
927
Chris Lattner02552de2009-08-11 16:58:39 +0000928def SYSCALL : I<0x05, RawFrm,
929 (outs), (ins), "syscall", []>, TB;
930def SYSRET : I<0x07, RawFrm,
931 (outs), (ins), "sysret", []>, TB;
932def SYSENTER : I<0x34, RawFrm,
933 (outs), (ins), "sysenter", []>, TB;
934def SYSEXIT : I<0x35, RawFrm,
935 (outs), (ins), "sysexit", []>, TB;
936
Sean Callanan2a46f362009-09-12 02:52:41 +0000937def WAIT : I<0x9B, RawFrm, (outs), (ins), "wait", []>;
Chris Lattner02552de2009-08-11 16:58:39 +0000938
939
Chris Lattner1cca5e32003-08-03 21:54:21 +0000940//===----------------------------------------------------------------------===//
John Criswell4ffff9e2004-04-08 20:31:47 +0000941// Input/Output Instructions...
942//
Evan Cheng071a2792007-09-11 19:55:27 +0000943let Defs = [AL], Uses = [DX] in
Evan Cheng64d80e32007-07-19 01:14:50 +0000944def IN8rr : I<0xEC, RawFrm, (outs), (ins),
Evan Cheng071a2792007-09-11 19:55:27 +0000945 "in{b}\t{%dx, %al|%AL, %DX}", []>;
946let Defs = [AX], Uses = [DX] in
Evan Cheng64d80e32007-07-19 01:14:50 +0000947def IN16rr : I<0xED, RawFrm, (outs), (ins),
Evan Cheng071a2792007-09-11 19:55:27 +0000948 "in{w}\t{%dx, %ax|%AX, %DX}", []>, OpSize;
949let Defs = [EAX], Uses = [DX] in
Evan Cheng64d80e32007-07-19 01:14:50 +0000950def IN32rr : I<0xED, RawFrm, (outs), (ins),
Evan Cheng071a2792007-09-11 19:55:27 +0000951 "in{l}\t{%dx, %eax|%EAX, %DX}", []>;
John Criswell4ffff9e2004-04-08 20:31:47 +0000952
Evan Cheng071a2792007-09-11 19:55:27 +0000953let Defs = [AL] in
Evan Cheng64d80e32007-07-19 01:14:50 +0000954def IN8ri : Ii8<0xE4, RawFrm, (outs), (ins i16i8imm:$port),
Evan Cheng071a2792007-09-11 19:55:27 +0000955 "in{b}\t{$port, %al|%AL, $port}", []>;
956let Defs = [AX] in
Evan Cheng64d80e32007-07-19 01:14:50 +0000957def IN16ri : Ii8<0xE5, RawFrm, (outs), (ins i16i8imm:$port),
Evan Cheng071a2792007-09-11 19:55:27 +0000958 "in{w}\t{$port, %ax|%AX, $port}", []>, OpSize;
959let Defs = [EAX] in
Evan Cheng64d80e32007-07-19 01:14:50 +0000960def IN32ri : Ii8<0xE5, RawFrm, (outs), (ins i16i8imm:$port),
Evan Cheng071a2792007-09-11 19:55:27 +0000961 "in{l}\t{$port, %eax|%EAX, $port}", []>;
Chris Lattner440bbc22004-04-13 17:19:31 +0000962
Evan Cheng071a2792007-09-11 19:55:27 +0000963let Uses = [DX, AL] in
Evan Cheng64d80e32007-07-19 01:14:50 +0000964def OUT8rr : I<0xEE, RawFrm, (outs), (ins),
Evan Cheng071a2792007-09-11 19:55:27 +0000965 "out{b}\t{%al, %dx|%DX, %AL}", []>;
966let Uses = [DX, AX] in
Evan Cheng64d80e32007-07-19 01:14:50 +0000967def OUT16rr : I<0xEF, RawFrm, (outs), (ins),
Evan Cheng071a2792007-09-11 19:55:27 +0000968 "out{w}\t{%ax, %dx|%DX, %AX}", []>, OpSize;
969let Uses = [DX, EAX] in
Evan Cheng64d80e32007-07-19 01:14:50 +0000970def OUT32rr : I<0xEF, RawFrm, (outs), (ins),
Evan Cheng071a2792007-09-11 19:55:27 +0000971 "out{l}\t{%eax, %dx|%DX, %EAX}", []>;
Chris Lattnerffff7082004-08-01 07:44:35 +0000972
Evan Cheng071a2792007-09-11 19:55:27 +0000973let Uses = [AL] in
Evan Cheng64d80e32007-07-19 01:14:50 +0000974def OUT8ir : Ii8<0xE6, RawFrm, (outs), (ins i16i8imm:$port),
Evan Cheng071a2792007-09-11 19:55:27 +0000975 "out{b}\t{%al, $port|$port, %AL}", []>;
976let Uses = [AX] in
Evan Cheng64d80e32007-07-19 01:14:50 +0000977def OUT16ir : Ii8<0xE7, RawFrm, (outs), (ins i16i8imm:$port),
Evan Cheng071a2792007-09-11 19:55:27 +0000978 "out{w}\t{%ax, $port|$port, %AX}", []>, OpSize;
979let Uses = [EAX] in
Evan Cheng64d80e32007-07-19 01:14:50 +0000980def OUT32ir : Ii8<0xE7, RawFrm, (outs), (ins i16i8imm:$port),
Evan Cheng071a2792007-09-11 19:55:27 +0000981 "out{l}\t{%eax, $port|$port, %EAX}", []>;
John Criswell4ffff9e2004-04-08 20:31:47 +0000982
Sean Callanan108934c2009-12-18 00:01:26 +0000983def IN8 : I<0x6C, RawFrm, (outs), (ins),
984 "ins{b}", []>;
985def IN16 : I<0x6D, RawFrm, (outs), (ins),
986 "ins{w}", []>, OpSize;
987def IN32 : I<0x6D, RawFrm, (outs), (ins),
988 "ins{l}", []>;
989
John Criswell4ffff9e2004-04-08 20:31:47 +0000990//===----------------------------------------------------------------------===//
Chris Lattner1cca5e32003-08-03 21:54:21 +0000991// Move Instructions...
992//
Chris Lattnerba7e7562008-01-10 07:59:24 +0000993let neverHasSideEffects = 1 in {
Evan Cheng64d80e32007-07-19 01:14:50 +0000994def MOV8rr : I<0x88, MRMDestReg, (outs GR8 :$dst), (ins GR8 :$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000995 "mov{b}\t{$src, $dst|$dst, $src}", []>;
Evan Cheng64d80e32007-07-19 01:14:50 +0000996def MOV16rr : I<0x89, MRMDestReg, (outs GR16:$dst), (ins GR16:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000997 "mov{w}\t{$src, $dst|$dst, $src}", []>, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +0000998def MOV32rr : I<0x89, MRMDestReg, (outs GR32:$dst), (ins GR32:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000999 "mov{l}\t{$src, $dst|$dst, $src}", []>;
Chris Lattnerba7e7562008-01-10 07:59:24 +00001000}
Evan Cheng359e9372008-06-18 08:13:07 +00001001let isReMaterializable = 1, isAsCheapAsAMove = 1 in {
Evan Cheng64d80e32007-07-19 01:14:50 +00001002def MOV8ri : Ii8 <0xB0, AddRegFrm, (outs GR8 :$dst), (ins i8imm :$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001003 "mov{b}\t{$src, $dst|$dst, $src}",
Evan Cheng069287d2006-05-16 07:21:53 +00001004 [(set GR8:$dst, imm:$src)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00001005def MOV16ri : Ii16<0xB8, AddRegFrm, (outs GR16:$dst), (ins i16imm:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001006 "mov{w}\t{$src, $dst|$dst, $src}",
Evan Cheng069287d2006-05-16 07:21:53 +00001007 [(set GR16:$dst, imm:$src)]>, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00001008def MOV32ri : Ii32<0xB8, AddRegFrm, (outs GR32:$dst), (ins i32imm:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001009 "mov{l}\t{$src, $dst|$dst, $src}",
Evan Cheng069287d2006-05-16 07:21:53 +00001010 [(set GR32:$dst, imm:$src)]>;
Dan Gohmand45eddd2007-06-26 00:48:07 +00001011}
Evan Cheng64d80e32007-07-19 01:14:50 +00001012def MOV8mi : Ii8 <0xC6, MRM0m, (outs), (ins i8mem :$dst, i8imm :$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001013 "mov{b}\t{$src, $dst|$dst, $src}",
Evan Chengb51a0592005-12-10 00:48:20 +00001014 [(store (i8 imm:$src), addr:$dst)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00001015def MOV16mi : Ii16<0xC7, MRM0m, (outs), (ins i16mem:$dst, i16imm:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001016 "mov{w}\t{$src, $dst|$dst, $src}",
Evan Chengb51a0592005-12-10 00:48:20 +00001017 [(store (i16 imm:$src), addr:$dst)]>, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00001018def MOV32mi : Ii32<0xC7, MRM0m, (outs), (ins i32mem:$dst, i32imm:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001019 "mov{l}\t{$src, $dst|$dst, $src}",
Evan Chengb51a0592005-12-10 00:48:20 +00001020 [(store (i32 imm:$src), addr:$dst)]>;
Chris Lattner1cca5e32003-08-03 21:54:21 +00001021
Sean Callanan108934c2009-12-18 00:01:26 +00001022def MOV8o8a : Ii8 <0xA0, RawFrm, (outs), (ins offset8:$src),
Sean Callanan2f34a132009-09-10 18:33:42 +00001023 "mov{b}\t{$src, %al|%al, $src}", []>;
Sean Callanan108934c2009-12-18 00:01:26 +00001024def MOV16o16a : Ii16 <0xA1, RawFrm, (outs), (ins offset16:$src),
Sean Callanan2f34a132009-09-10 18:33:42 +00001025 "mov{w}\t{$src, %ax|%ax, $src}", []>, OpSize;
Sean Callanan108934c2009-12-18 00:01:26 +00001026def MOV32o32a : Ii32 <0xA1, RawFrm, (outs), (ins offset32:$src),
Sean Callanan2f34a132009-09-10 18:33:42 +00001027 "mov{l}\t{$src, %eax|%eax, $src}", []>;
1028
Sean Callanan108934c2009-12-18 00:01:26 +00001029def MOV8ao8 : Ii8 <0xA2, RawFrm, (outs offset8:$dst), (ins),
Sean Callanan2f34a132009-09-10 18:33:42 +00001030 "mov{b}\t{%al, $dst|$dst, %al}", []>;
Sean Callanan108934c2009-12-18 00:01:26 +00001031def MOV16ao16 : Ii16 <0xA3, RawFrm, (outs offset16:$dst), (ins),
Sean Callanan2f34a132009-09-10 18:33:42 +00001032 "mov{w}\t{%ax, $dst|$dst, %ax}", []>, OpSize;
Sean Callanan108934c2009-12-18 00:01:26 +00001033def MOV32ao32 : Ii32 <0xA3, RawFrm, (outs offset32:$dst), (ins),
Sean Callanan2f34a132009-09-10 18:33:42 +00001034 "mov{l}\t{%eax, $dst|$dst, %eax}", []>;
1035
Sean Callanan38fee0e2009-09-15 18:47:29 +00001036// Moves to and from segment registers
1037def MOV16rs : I<0x8C, MRMDestReg, (outs GR16:$dst), (ins SEGMENT_REG:$src),
1038 "mov{w}\t{$src, $dst|$dst, $src}", []>;
1039def MOV16ms : I<0x8C, MRMDestMem, (outs i16mem:$dst), (ins SEGMENT_REG:$src),
1040 "mov{w}\t{$src, $dst|$dst, $src}", []>;
1041def MOV16sr : I<0x8E, MRMSrcReg, (outs SEGMENT_REG:$dst), (ins GR16:$src),
1042 "mov{w}\t{$src, $dst|$dst, $src}", []>;
1043def MOV16sm : I<0x8E, MRMSrcMem, (outs SEGMENT_REG:$dst), (ins i16mem:$src),
1044 "mov{w}\t{$src, $dst|$dst, $src}", []>;
1045
Sean Callanan108934c2009-12-18 00:01:26 +00001046def MOV8rr_REV : I<0x8A, MRMSrcReg, (outs GR8:$dst), (ins GR8:$src),
1047 "mov{b}\t{$src, $dst|$dst, $src}", []>;
1048def MOV16rr_REV : I<0x8B, MRMSrcReg, (outs GR16:$dst), (ins GR16:$src),
1049 "mov{w}\t{$src, $dst|$dst, $src}", []>, OpSize;
1050def MOV32rr_REV : I<0x8B, MRMSrcReg, (outs GR32:$dst), (ins GR32:$src),
1051 "mov{l}\t{$src, $dst|$dst, $src}", []>;
1052
Dan Gohman15511cf2008-12-03 18:15:48 +00001053let canFoldAsLoad = 1, isReMaterializable = 1, mayHaveSideEffects = 1 in {
Evan Cheng64d80e32007-07-19 01:14:50 +00001054def MOV8rm : I<0x8A, MRMSrcMem, (outs GR8 :$dst), (ins i8mem :$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001055 "mov{b}\t{$src, $dst|$dst, $src}",
Chris Lattnerc2406f22009-04-10 00:16:23 +00001056 [(set GR8:$dst, (loadi8 addr:$src))]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00001057def MOV16rm : I<0x8B, MRMSrcMem, (outs GR16:$dst), (ins i16mem:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001058 "mov{w}\t{$src, $dst|$dst, $src}",
Chris Lattnerc2406f22009-04-10 00:16:23 +00001059 [(set GR16:$dst, (loadi16 addr:$src))]>, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00001060def MOV32rm : I<0x8B, MRMSrcMem, (outs GR32:$dst), (ins i32mem:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001061 "mov{l}\t{$src, $dst|$dst, $src}",
Chris Lattnerc2406f22009-04-10 00:16:23 +00001062 [(set GR32:$dst, (loadi32 addr:$src))]>;
Evan Cheng2f394262007-08-30 05:49:43 +00001063}
Chris Lattner1cca5e32003-08-03 21:54:21 +00001064
Evan Cheng64d80e32007-07-19 01:14:50 +00001065def MOV8mr : I<0x88, MRMDestMem, (outs), (ins i8mem :$dst, GR8 :$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001066 "mov{b}\t{$src, $dst|$dst, $src}",
Evan Cheng069287d2006-05-16 07:21:53 +00001067 [(store GR8:$src, addr:$dst)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00001068def MOV16mr : I<0x89, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001069 "mov{w}\t{$src, $dst|$dst, $src}",
Evan Cheng069287d2006-05-16 07:21:53 +00001070 [(store GR16:$src, addr:$dst)]>, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00001071def MOV32mr : I<0x89, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001072 "mov{l}\t{$src, $dst|$dst, $src}",
Evan Cheng069287d2006-05-16 07:21:53 +00001073 [(store GR32:$src, addr:$dst)]>;
Dan Gohman21e3dfb2009-04-13 16:09:41 +00001074
Dan Gohman4af325d2009-04-27 16:41:36 +00001075// Versions of MOV8rr, MOV8mr, and MOV8rm that use i8mem_NOREX and GR8_NOREX so
1076// that they can be used for copying and storing h registers, which can't be
1077// encoded when a REX prefix is present.
Dan Gohman6d9305c2009-04-15 00:04:23 +00001078let neverHasSideEffects = 1 in
Dan Gohmandf7dfc72009-04-15 19:48:57 +00001079def MOV8rr_NOREX : I<0x88, MRMDestReg,
1080 (outs GR8_NOREX:$dst), (ins GR8_NOREX:$src),
Dan Gohman6d9305c2009-04-15 00:04:23 +00001081 "mov{b}\t{$src, $dst|$dst, $src} # NOREX", []>;
Evan Cheng8c147402009-04-30 00:58:57 +00001082let mayStore = 1 in
Dan Gohman6d9305c2009-04-15 00:04:23 +00001083def MOV8mr_NOREX : I<0x88, MRMDestMem,
1084 (outs), (ins i8mem_NOREX:$dst, GR8_NOREX:$src),
1085 "mov{b}\t{$src, $dst|$dst, $src} # NOREX", []>;
Evan Cheng8c147402009-04-30 00:58:57 +00001086let mayLoad = 1,
1087 canFoldAsLoad = 1, isReMaterializable = 1, mayHaveSideEffects = 1 in
Dan Gohman4af325d2009-04-27 16:41:36 +00001088def MOV8rm_NOREX : I<0x8A, MRMSrcMem,
1089 (outs GR8_NOREX:$dst), (ins i8mem_NOREX:$src),
1090 "mov{b}\t{$src, $dst|$dst, $src} # NOREX", []>;
Dan Gohman21e3dfb2009-04-13 16:09:41 +00001091
Sean Callanan108934c2009-12-18 00:01:26 +00001092// Moves to and from debug registers
1093def MOV32rd : I<0x21, MRMDestReg, (outs GR32:$dst), (ins DEBUG_REG:$src),
1094 "mov{l}\t{$src, $dst|$dst, $src}", []>, TB;
1095def MOV32dr : I<0x23, MRMSrcReg, (outs DEBUG_REG:$dst), (ins GR32:$src),
1096 "mov{l}\t{$src, $dst|$dst, $src}", []>, TB;
1097
1098// Moves to and from control registers
1099def MOV32rc : I<0x20, MRMDestReg, (outs GR32:$dst), (ins CONTROL_REG_32:$src),
1100 "mov{q}\t{$src, $dst|$dst, $src}", []>, TB;
1101def MOV32cr : I<0x22, MRMSrcReg, (outs CONTROL_REG_32:$dst), (ins GR32:$src),
1102 "mov{q}\t{$src, $dst|$dst, $src}", []>, TB;
1103
Chris Lattner1cca5e32003-08-03 21:54:21 +00001104//===----------------------------------------------------------------------===//
1105// Fixed-Register Multiplication and Division Instructions...
1106//
Chris Lattner1cca5e32003-08-03 21:54:21 +00001107
Chris Lattnerc8f45872003-08-04 04:59:56 +00001108// Extra precision multiplication
Evan Cheng24f2ea32007-09-14 21:48:26 +00001109let Defs = [AL,AH,EFLAGS], Uses = [AL] in
Dan Gohmanb1576f52007-07-31 20:11:57 +00001110def MUL8r : I<0xF6, MRM4r, (outs), (ins GR8:$src), "mul{b}\t$src",
Evan Chengcf74a7c2006-01-15 10:05:20 +00001111 // FIXME: Used for 8-bit mul, ignore result upper 8 bits.
1112 // This probably ought to be moved to a def : Pat<> if the
1113 // syntax can be accepted.
Bill Wendlingd350e022008-12-12 21:15:41 +00001114 [(set AL, (mul AL, GR8:$src)),
1115 (implicit EFLAGS)]>; // AL,AH = AL*GR8
1116
Chris Lattnera731c9f2008-01-11 07:18:17 +00001117let Defs = [AX,DX,EFLAGS], Uses = [AX], neverHasSideEffects = 1 in
Bill Wendlingd350e022008-12-12 21:15:41 +00001118def MUL16r : I<0xF7, MRM4r, (outs), (ins GR16:$src),
1119 "mul{w}\t$src",
1120 []>, OpSize; // AX,DX = AX*GR16
1121
Chris Lattnera731c9f2008-01-11 07:18:17 +00001122let Defs = [EAX,EDX,EFLAGS], Uses = [EAX], neverHasSideEffects = 1 in
Bill Wendlingd350e022008-12-12 21:15:41 +00001123def MUL32r : I<0xF7, MRM4r, (outs), (ins GR32:$src),
1124 "mul{l}\t$src",
1125 []>; // EAX,EDX = EAX*GR32
1126
Evan Cheng24f2ea32007-09-14 21:48:26 +00001127let Defs = [AL,AH,EFLAGS], Uses = [AL] in
Evan Cheng64d80e32007-07-19 01:14:50 +00001128def MUL8m : I<0xF6, MRM4m, (outs), (ins i8mem :$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001129 "mul{b}\t$src",
Evan Chengcf74a7c2006-01-15 10:05:20 +00001130 // FIXME: Used for 8-bit mul, ignore result upper 8 bits.
1131 // This probably ought to be moved to a def : Pat<> if the
1132 // syntax can be accepted.
Bill Wendlingd350e022008-12-12 21:15:41 +00001133 [(set AL, (mul AL, (loadi8 addr:$src))),
1134 (implicit EFLAGS)]>; // AL,AH = AL*[mem8]
1135
Chris Lattnerba7e7562008-01-10 07:59:24 +00001136let mayLoad = 1, neverHasSideEffects = 1 in {
Evan Cheng24f2ea32007-09-14 21:48:26 +00001137let Defs = [AX,DX,EFLAGS], Uses = [AX] in
Evan Cheng64d80e32007-07-19 01:14:50 +00001138def MUL16m : I<0xF7, MRM4m, (outs), (ins i16mem:$src),
Bill Wendlingd350e022008-12-12 21:15:41 +00001139 "mul{w}\t$src",
1140 []>, OpSize; // AX,DX = AX*[mem16]
1141
Evan Cheng24f2ea32007-09-14 21:48:26 +00001142let Defs = [EAX,EDX,EFLAGS], Uses = [EAX] in
Evan Cheng64d80e32007-07-19 01:14:50 +00001143def MUL32m : I<0xF7, MRM4m, (outs), (ins i32mem:$src),
Bill Wendlingd350e022008-12-12 21:15:41 +00001144 "mul{l}\t$src",
1145 []>; // EAX,EDX = EAX*[mem32]
Chris Lattnerba7e7562008-01-10 07:59:24 +00001146}
Chris Lattner1cca5e32003-08-03 21:54:21 +00001147
Chris Lattnerba7e7562008-01-10 07:59:24 +00001148let neverHasSideEffects = 1 in {
Evan Cheng24f2ea32007-09-14 21:48:26 +00001149let Defs = [AL,AH,EFLAGS], Uses = [AL] in
Evan Cheng071a2792007-09-11 19:55:27 +00001150def IMUL8r : I<0xF6, MRM5r, (outs), (ins GR8:$src), "imul{b}\t$src", []>;
1151 // AL,AH = AL*GR8
Evan Cheng24f2ea32007-09-14 21:48:26 +00001152let Defs = [AX,DX,EFLAGS], Uses = [AX] in
Dan Gohmanb1576f52007-07-31 20:11:57 +00001153def IMUL16r : I<0xF7, MRM5r, (outs), (ins GR16:$src), "imul{w}\t$src", []>,
Evan Cheng071a2792007-09-11 19:55:27 +00001154 OpSize; // AX,DX = AX*GR16
Evan Cheng24f2ea32007-09-14 21:48:26 +00001155let Defs = [EAX,EDX,EFLAGS], Uses = [EAX] in
Evan Cheng071a2792007-09-11 19:55:27 +00001156def IMUL32r : I<0xF7, MRM5r, (outs), (ins GR32:$src), "imul{l}\t$src", []>;
1157 // EAX,EDX = EAX*GR32
Chris Lattnerba7e7562008-01-10 07:59:24 +00001158let mayLoad = 1 in {
Evan Cheng24f2ea32007-09-14 21:48:26 +00001159let Defs = [AL,AH,EFLAGS], Uses = [AL] in
Evan Cheng64d80e32007-07-19 01:14:50 +00001160def IMUL8m : I<0xF6, MRM5m, (outs), (ins i8mem :$src),
Evan Cheng071a2792007-09-11 19:55:27 +00001161 "imul{b}\t$src", []>; // AL,AH = AL*[mem8]
Evan Cheng24f2ea32007-09-14 21:48:26 +00001162let Defs = [AX,DX,EFLAGS], Uses = [AX] in
Evan Cheng64d80e32007-07-19 01:14:50 +00001163def IMUL16m : I<0xF7, MRM5m, (outs), (ins i16mem:$src),
Evan Cheng071a2792007-09-11 19:55:27 +00001164 "imul{w}\t$src", []>, OpSize; // AX,DX = AX*[mem16]
Eli Friedmanba7b1c42009-12-26 20:08:30 +00001165let Defs = [EAX,EDX,EFLAGS], Uses = [EAX] in
Evan Cheng64d80e32007-07-19 01:14:50 +00001166def IMUL32m : I<0xF7, MRM5m, (outs), (ins i32mem:$src),
Evan Cheng071a2792007-09-11 19:55:27 +00001167 "imul{l}\t$src", []>; // EAX,EDX = EAX*[mem32]
Chris Lattnerba7e7562008-01-10 07:59:24 +00001168}
Dan Gohmanc99da132008-11-18 21:29:14 +00001169} // neverHasSideEffects
Chris Lattner1e6a7152005-04-06 04:19:22 +00001170
Chris Lattnerc8f45872003-08-04 04:59:56 +00001171// unsigned division/remainder
Dale Johannesen2cb48ea2008-10-07 18:54:28 +00001172let Defs = [AL,AH,EFLAGS], Uses = [AX] in
Sean Callanan108934c2009-12-18 00:01:26 +00001173def DIV8r : I<0xF6, MRM6r, (outs), (ins GR8:$src), // AX/r8 = AL,AH
Evan Cheng071a2792007-09-11 19:55:27 +00001174 "div{b}\t$src", []>;
Evan Cheng24f2ea32007-09-14 21:48:26 +00001175let Defs = [AX,DX,EFLAGS], Uses = [AX,DX] in
Sean Callanan108934c2009-12-18 00:01:26 +00001176def DIV16r : I<0xF7, MRM6r, (outs), (ins GR16:$src), // DX:AX/r16 = AX,DX
Evan Cheng071a2792007-09-11 19:55:27 +00001177 "div{w}\t$src", []>, OpSize;
Evan Cheng24f2ea32007-09-14 21:48:26 +00001178let Defs = [EAX,EDX,EFLAGS], Uses = [EAX,EDX] in
Sean Callanan108934c2009-12-18 00:01:26 +00001179def DIV32r : I<0xF7, MRM6r, (outs), (ins GR32:$src), // EDX:EAX/r32 = EAX,EDX
Evan Cheng071a2792007-09-11 19:55:27 +00001180 "div{l}\t$src", []>;
Chris Lattnerba7e7562008-01-10 07:59:24 +00001181let mayLoad = 1 in {
Dale Johannesen2cb48ea2008-10-07 18:54:28 +00001182let Defs = [AL,AH,EFLAGS], Uses = [AX] in
Sean Callanan108934c2009-12-18 00:01:26 +00001183def DIV8m : I<0xF6, MRM6m, (outs), (ins i8mem:$src), // AX/[mem8] = AL,AH
Evan Cheng071a2792007-09-11 19:55:27 +00001184 "div{b}\t$src", []>;
Evan Cheng24f2ea32007-09-14 21:48:26 +00001185let Defs = [AX,DX,EFLAGS], Uses = [AX,DX] in
Sean Callanan108934c2009-12-18 00:01:26 +00001186def DIV16m : I<0xF7, MRM6m, (outs), (ins i16mem:$src), // DX:AX/[mem16] = AX,DX
Evan Cheng071a2792007-09-11 19:55:27 +00001187 "div{w}\t$src", []>, OpSize;
Evan Cheng24f2ea32007-09-14 21:48:26 +00001188let Defs = [EAX,EDX,EFLAGS], Uses = [EAX,EDX] in
Sean Callanan108934c2009-12-18 00:01:26 +00001189 // EDX:EAX/[mem32] = EAX,EDX
1190def DIV32m : I<0xF7, MRM6m, (outs), (ins i32mem:$src),
Evan Cheng071a2792007-09-11 19:55:27 +00001191 "div{l}\t$src", []>;
Chris Lattnerba7e7562008-01-10 07:59:24 +00001192}
Chris Lattner1cca5e32003-08-03 21:54:21 +00001193
Chris Lattnerfc752712004-08-01 09:52:59 +00001194// Signed division/remainder.
Dale Johannesen2cb48ea2008-10-07 18:54:28 +00001195let Defs = [AL,AH,EFLAGS], Uses = [AX] in
Sean Callanan108934c2009-12-18 00:01:26 +00001196def IDIV8r : I<0xF6, MRM7r, (outs), (ins GR8:$src), // AX/r8 = AL,AH
Evan Cheng071a2792007-09-11 19:55:27 +00001197 "idiv{b}\t$src", []>;
Evan Cheng24f2ea32007-09-14 21:48:26 +00001198let Defs = [AX,DX,EFLAGS], Uses = [AX,DX] in
Sean Callanan108934c2009-12-18 00:01:26 +00001199def IDIV16r: I<0xF7, MRM7r, (outs), (ins GR16:$src), // DX:AX/r16 = AX,DX
Evan Cheng071a2792007-09-11 19:55:27 +00001200 "idiv{w}\t$src", []>, OpSize;
Evan Cheng24f2ea32007-09-14 21:48:26 +00001201let Defs = [EAX,EDX,EFLAGS], Uses = [EAX,EDX] in
Sean Callanan108934c2009-12-18 00:01:26 +00001202def IDIV32r: I<0xF7, MRM7r, (outs), (ins GR32:$src), // EDX:EAX/r32 = EAX,EDX
Evan Cheng071a2792007-09-11 19:55:27 +00001203 "idiv{l}\t$src", []>;
Chris Lattnerba7e7562008-01-10 07:59:24 +00001204let mayLoad = 1, mayLoad = 1 in {
Dale Johannesen2cb48ea2008-10-07 18:54:28 +00001205let Defs = [AL,AH,EFLAGS], Uses = [AX] in
Sean Callanan108934c2009-12-18 00:01:26 +00001206def IDIV8m : I<0xF6, MRM7m, (outs), (ins i8mem:$src), // AX/[mem8] = AL,AH
Evan Cheng071a2792007-09-11 19:55:27 +00001207 "idiv{b}\t$src", []>;
Evan Cheng24f2ea32007-09-14 21:48:26 +00001208let Defs = [AX,DX,EFLAGS], Uses = [AX,DX] in
Sean Callanan108934c2009-12-18 00:01:26 +00001209def IDIV16m: I<0xF7, MRM7m, (outs), (ins i16mem:$src), // DX:AX/[mem16] = AX,DX
Evan Cheng071a2792007-09-11 19:55:27 +00001210 "idiv{w}\t$src", []>, OpSize;
Evan Cheng24f2ea32007-09-14 21:48:26 +00001211let Defs = [EAX,EDX,EFLAGS], Uses = [EAX,EDX] in
Sean Callanan108934c2009-12-18 00:01:26 +00001212def IDIV32m: I<0xF7, MRM7m, (outs), (ins i32mem:$src),
1213 // EDX:EAX/[mem32] = EAX,EDX
Evan Cheng071a2792007-09-11 19:55:27 +00001214 "idiv{l}\t$src", []>;
Chris Lattnerba7e7562008-01-10 07:59:24 +00001215}
Chris Lattner1cca5e32003-08-03 21:54:21 +00001216
Chris Lattner1cca5e32003-08-03 21:54:21 +00001217//===----------------------------------------------------------------------===//
Chris Lattnerba7e7562008-01-10 07:59:24 +00001218// Two address Instructions.
Chris Lattner1cca5e32003-08-03 21:54:21 +00001219//
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00001220let isTwoAddress = 1 in {
Chris Lattner1cca5e32003-08-03 21:54:21 +00001221
Alkis Evlogimenosa3f66842004-03-12 17:59:56 +00001222// Conditional moves
Evan Cheng0488db92007-09-25 01:57:46 +00001223let Uses = [EFLAGS] in {
Dan Gohmancbbea0f2009-08-27 00:14:12 +00001224
Dan Gohman533297b2009-10-29 18:10:34 +00001225// X86 doesn't have 8-bit conditional moves. Use a customInserter to
Dan Gohmancbbea0f2009-08-27 00:14:12 +00001226// emit control flow. An alternative to this is to mark i8 SELECT as Promote,
1227// however that requires promoting the operands, and can induce additional
Dan Gohman71a258c2009-08-29 22:19:15 +00001228// i8 register pressure. Note that CMOV_GR8 is conservatively considered to
1229// clobber EFLAGS, because if one of the operands is zero, the expansion
1230// could involve an xor.
Dan Gohman533297b2009-10-29 18:10:34 +00001231let usesCustomInserter = 1, isTwoAddress = 0, Defs = [EFLAGS] in
Dan Gohmancbbea0f2009-08-27 00:14:12 +00001232def CMOV_GR8 : I<0, Pseudo,
1233 (outs GR8:$dst), (ins GR8:$src1, GR8:$src2, i8imm:$cond),
1234 "#CMOV_GR8 PSEUDO!",
1235 [(set GR8:$dst, (X86cmov GR8:$src1, GR8:$src2,
1236 imm:$cond, EFLAGS))]>;
1237
Dan Gohmana4c5c332009-08-27 18:16:24 +00001238let isCommutable = 1 in {
Evan Cheng069287d2006-05-16 07:21:53 +00001239def CMOVB16rr : I<0x42, MRMSrcReg, // if <u, GR16 = GR16
Evan Cheng64d80e32007-07-19 01:14:50 +00001240 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Sean Callanan108934c2009-12-18 00:01:26 +00001241 "cmovb{w}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001242 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Chenge5f62042007-09-29 00:00:36 +00001243 X86_COND_B, EFLAGS))]>,
Evan Cheng71fb9ad2006-01-26 00:29:36 +00001244 TB, OpSize;
Evan Cheng069287d2006-05-16 07:21:53 +00001245def CMOVB32rr : I<0x42, MRMSrcReg, // if <u, GR32 = GR32
Evan Cheng64d80e32007-07-19 01:14:50 +00001246 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Sean Callanan108934c2009-12-18 00:01:26 +00001247 "cmovb{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001248 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Chenge5f62042007-09-29 00:00:36 +00001249 X86_COND_B, EFLAGS))]>,
Evan Cheng71fb9ad2006-01-26 00:29:36 +00001250 TB;
Evan Cheng069287d2006-05-16 07:21:53 +00001251def CMOVAE16rr: I<0x43, MRMSrcReg, // if >=u, GR16 = GR16
Evan Cheng64d80e32007-07-19 01:14:50 +00001252 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Sean Callanan108934c2009-12-18 00:01:26 +00001253 "cmovae{w}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001254 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Chenge5f62042007-09-29 00:00:36 +00001255 X86_COND_AE, EFLAGS))]>,
Evan Cheng71fb9ad2006-01-26 00:29:36 +00001256 TB, OpSize;
Evan Cheng069287d2006-05-16 07:21:53 +00001257def CMOVAE32rr: I<0x43, MRMSrcReg, // if >=u, GR32 = GR32
Evan Cheng64d80e32007-07-19 01:14:50 +00001258 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Sean Callanan108934c2009-12-18 00:01:26 +00001259 "cmovae{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001260 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Chenge5f62042007-09-29 00:00:36 +00001261 X86_COND_AE, EFLAGS))]>,
Evan Cheng71fb9ad2006-01-26 00:29:36 +00001262 TB;
Evan Cheng069287d2006-05-16 07:21:53 +00001263def CMOVE16rr : I<0x44, MRMSrcReg, // if ==, GR16 = GR16
Evan Cheng64d80e32007-07-19 01:14:50 +00001264 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Sean Callanan108934c2009-12-18 00:01:26 +00001265 "cmove{w}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001266 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Chenge5f62042007-09-29 00:00:36 +00001267 X86_COND_E, EFLAGS))]>,
Evan Cheng71fb9ad2006-01-26 00:29:36 +00001268 TB, OpSize;
Evan Cheng069287d2006-05-16 07:21:53 +00001269def CMOVE32rr : I<0x44, MRMSrcReg, // if ==, GR32 = GR32
Evan Cheng64d80e32007-07-19 01:14:50 +00001270 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Sean Callanan108934c2009-12-18 00:01:26 +00001271 "cmove{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001272 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Chenge5f62042007-09-29 00:00:36 +00001273 X86_COND_E, EFLAGS))]>,
Evan Cheng71fb9ad2006-01-26 00:29:36 +00001274 TB;
Evan Cheng069287d2006-05-16 07:21:53 +00001275def CMOVNE16rr: I<0x45, MRMSrcReg, // if !=, GR16 = GR16
Evan Cheng64d80e32007-07-19 01:14:50 +00001276 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Sean Callanan108934c2009-12-18 00:01:26 +00001277 "cmovne{w}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001278 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Chenge5f62042007-09-29 00:00:36 +00001279 X86_COND_NE, EFLAGS))]>,
Evan Cheng71fb9ad2006-01-26 00:29:36 +00001280 TB, OpSize;
Evan Cheng069287d2006-05-16 07:21:53 +00001281def CMOVNE32rr: I<0x45, MRMSrcReg, // if !=, GR32 = GR32
Evan Cheng64d80e32007-07-19 01:14:50 +00001282 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Sean Callanan108934c2009-12-18 00:01:26 +00001283 "cmovne{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001284 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Chenge5f62042007-09-29 00:00:36 +00001285 X86_COND_NE, EFLAGS))]>,
Evan Cheng71fb9ad2006-01-26 00:29:36 +00001286 TB;
Evan Cheng069287d2006-05-16 07:21:53 +00001287def CMOVBE16rr: I<0x46, MRMSrcReg, // if <=u, GR16 = GR16
Evan Cheng64d80e32007-07-19 01:14:50 +00001288 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Sean Callanan108934c2009-12-18 00:01:26 +00001289 "cmovbe{w}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001290 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Chenge5f62042007-09-29 00:00:36 +00001291 X86_COND_BE, EFLAGS))]>,
Evan Cheng71fb9ad2006-01-26 00:29:36 +00001292 TB, OpSize;
Evan Cheng069287d2006-05-16 07:21:53 +00001293def CMOVBE32rr: I<0x46, MRMSrcReg, // if <=u, GR32 = GR32
Evan Cheng64d80e32007-07-19 01:14:50 +00001294 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Sean Callanan108934c2009-12-18 00:01:26 +00001295 "cmovbe{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001296 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Chenge5f62042007-09-29 00:00:36 +00001297 X86_COND_BE, EFLAGS))]>,
Evan Cheng71fb9ad2006-01-26 00:29:36 +00001298 TB;
Evan Cheng069287d2006-05-16 07:21:53 +00001299def CMOVA16rr : I<0x47, MRMSrcReg, // if >u, GR16 = GR16
Evan Cheng64d80e32007-07-19 01:14:50 +00001300 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Sean Callanan108934c2009-12-18 00:01:26 +00001301 "cmova{w}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001302 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Chenge5f62042007-09-29 00:00:36 +00001303 X86_COND_A, EFLAGS))]>,
Evan Cheng71fb9ad2006-01-26 00:29:36 +00001304 TB, OpSize;
Evan Cheng069287d2006-05-16 07:21:53 +00001305def CMOVA32rr : I<0x47, MRMSrcReg, // if >u, GR32 = GR32
Evan Cheng64d80e32007-07-19 01:14:50 +00001306 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Sean Callanan108934c2009-12-18 00:01:26 +00001307 "cmova{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001308 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Chenge5f62042007-09-29 00:00:36 +00001309 X86_COND_A, EFLAGS))]>,
Evan Cheng71fb9ad2006-01-26 00:29:36 +00001310 TB;
Evan Cheng069287d2006-05-16 07:21:53 +00001311def CMOVL16rr : I<0x4C, MRMSrcReg, // if <s, GR16 = GR16
Evan Cheng64d80e32007-07-19 01:14:50 +00001312 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Sean Callanan108934c2009-12-18 00:01:26 +00001313 "cmovl{w}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001314 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Chenge5f62042007-09-29 00:00:36 +00001315 X86_COND_L, EFLAGS))]>,
Evan Cheng71fb9ad2006-01-26 00:29:36 +00001316 TB, OpSize;
Evan Cheng069287d2006-05-16 07:21:53 +00001317def CMOVL32rr : I<0x4C, MRMSrcReg, // if <s, GR32 = GR32
Evan Cheng64d80e32007-07-19 01:14:50 +00001318 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Sean Callanan108934c2009-12-18 00:01:26 +00001319 "cmovl{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001320 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Chenge5f62042007-09-29 00:00:36 +00001321 X86_COND_L, EFLAGS))]>,
Evan Cheng71fb9ad2006-01-26 00:29:36 +00001322 TB;
Evan Cheng069287d2006-05-16 07:21:53 +00001323def CMOVGE16rr: I<0x4D, MRMSrcReg, // if >=s, GR16 = GR16
Evan Cheng64d80e32007-07-19 01:14:50 +00001324 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Sean Callanan108934c2009-12-18 00:01:26 +00001325 "cmovge{w}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001326 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Chenge5f62042007-09-29 00:00:36 +00001327 X86_COND_GE, EFLAGS))]>,
Evan Cheng71fb9ad2006-01-26 00:29:36 +00001328 TB, OpSize;
Evan Cheng069287d2006-05-16 07:21:53 +00001329def CMOVGE32rr: I<0x4D, MRMSrcReg, // if >=s, GR32 = GR32
Evan Cheng64d80e32007-07-19 01:14:50 +00001330 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Sean Callanan108934c2009-12-18 00:01:26 +00001331 "cmovge{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001332 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Chenge5f62042007-09-29 00:00:36 +00001333 X86_COND_GE, EFLAGS))]>,
Evan Cheng71fb9ad2006-01-26 00:29:36 +00001334 TB;
Evan Cheng069287d2006-05-16 07:21:53 +00001335def CMOVLE16rr: I<0x4E, MRMSrcReg, // if <=s, GR16 = GR16
Evan Cheng64d80e32007-07-19 01:14:50 +00001336 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Sean Callanan108934c2009-12-18 00:01:26 +00001337 "cmovle{w}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001338 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Chenge5f62042007-09-29 00:00:36 +00001339 X86_COND_LE, EFLAGS))]>,
Evan Cheng71fb9ad2006-01-26 00:29:36 +00001340 TB, OpSize;
Evan Cheng069287d2006-05-16 07:21:53 +00001341def CMOVLE32rr: I<0x4E, MRMSrcReg, // if <=s, GR32 = GR32
Evan Cheng64d80e32007-07-19 01:14:50 +00001342 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Sean Callanan108934c2009-12-18 00:01:26 +00001343 "cmovle{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001344 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Chenge5f62042007-09-29 00:00:36 +00001345 X86_COND_LE, EFLAGS))]>,
Evan Cheng71fb9ad2006-01-26 00:29:36 +00001346 TB;
Evan Cheng069287d2006-05-16 07:21:53 +00001347def CMOVG16rr : I<0x4F, MRMSrcReg, // if >s, GR16 = GR16
Evan Cheng64d80e32007-07-19 01:14:50 +00001348 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Sean Callanan108934c2009-12-18 00:01:26 +00001349 "cmovg{w}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001350 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Chenge5f62042007-09-29 00:00:36 +00001351 X86_COND_G, EFLAGS))]>,
Evan Cheng71fb9ad2006-01-26 00:29:36 +00001352 TB, OpSize;
Evan Cheng069287d2006-05-16 07:21:53 +00001353def CMOVG32rr : I<0x4F, MRMSrcReg, // if >s, GR32 = GR32
Evan Cheng64d80e32007-07-19 01:14:50 +00001354 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Sean Callanan108934c2009-12-18 00:01:26 +00001355 "cmovg{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001356 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Chenge5f62042007-09-29 00:00:36 +00001357 X86_COND_G, EFLAGS))]>,
Evan Cheng71fb9ad2006-01-26 00:29:36 +00001358 TB;
Evan Cheng069287d2006-05-16 07:21:53 +00001359def CMOVS16rr : I<0x48, MRMSrcReg, // if signed, GR16 = GR16
Evan Cheng64d80e32007-07-19 01:14:50 +00001360 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Sean Callanan108934c2009-12-18 00:01:26 +00001361 "cmovs{w}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001362 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Chenge5f62042007-09-29 00:00:36 +00001363 X86_COND_S, EFLAGS))]>,
Evan Cheng71fb9ad2006-01-26 00:29:36 +00001364 TB, OpSize;
Evan Cheng069287d2006-05-16 07:21:53 +00001365def CMOVS32rr : I<0x48, MRMSrcReg, // if signed, GR32 = GR32
Evan Cheng64d80e32007-07-19 01:14:50 +00001366 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Sean Callanan108934c2009-12-18 00:01:26 +00001367 "cmovs{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001368 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Chenge5f62042007-09-29 00:00:36 +00001369 X86_COND_S, EFLAGS))]>,
Evan Cheng71fb9ad2006-01-26 00:29:36 +00001370 TB;
Evan Cheng069287d2006-05-16 07:21:53 +00001371def CMOVNS16rr: I<0x49, MRMSrcReg, // if !signed, GR16 = GR16
Evan Cheng64d80e32007-07-19 01:14:50 +00001372 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Sean Callanan108934c2009-12-18 00:01:26 +00001373 "cmovns{w}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001374 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Chenge5f62042007-09-29 00:00:36 +00001375 X86_COND_NS, EFLAGS))]>,
Evan Cheng71fb9ad2006-01-26 00:29:36 +00001376 TB, OpSize;
Evan Cheng069287d2006-05-16 07:21:53 +00001377def CMOVNS32rr: I<0x49, MRMSrcReg, // if !signed, GR32 = GR32
Evan Cheng64d80e32007-07-19 01:14:50 +00001378 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Sean Callanan108934c2009-12-18 00:01:26 +00001379 "cmovns{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001380 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Chenge5f62042007-09-29 00:00:36 +00001381 X86_COND_NS, EFLAGS))]>,
Evan Cheng71fb9ad2006-01-26 00:29:36 +00001382 TB;
Evan Cheng069287d2006-05-16 07:21:53 +00001383def CMOVP16rr : I<0x4A, MRMSrcReg, // if parity, GR16 = GR16
Evan Cheng64d80e32007-07-19 01:14:50 +00001384 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Sean Callanan108934c2009-12-18 00:01:26 +00001385 "cmovp{w}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001386 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Chenge5f62042007-09-29 00:00:36 +00001387 X86_COND_P, EFLAGS))]>,
Evan Cheng71fb9ad2006-01-26 00:29:36 +00001388 TB, OpSize;
Evan Cheng069287d2006-05-16 07:21:53 +00001389def CMOVP32rr : I<0x4A, MRMSrcReg, // if parity, GR32 = GR32
Evan Cheng64d80e32007-07-19 01:14:50 +00001390 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Sean Callanan108934c2009-12-18 00:01:26 +00001391 "cmovp{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001392 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Chenge5f62042007-09-29 00:00:36 +00001393 X86_COND_P, EFLAGS))]>,
Evan Cheng71fb9ad2006-01-26 00:29:36 +00001394 TB;
Evan Cheng069287d2006-05-16 07:21:53 +00001395def CMOVNP16rr : I<0x4B, MRMSrcReg, // if !parity, GR16 = GR16
Evan Cheng64d80e32007-07-19 01:14:50 +00001396 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Sean Callanan108934c2009-12-18 00:01:26 +00001397 "cmovnp{w}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001398 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Chenge5f62042007-09-29 00:00:36 +00001399 X86_COND_NP, EFLAGS))]>,
Evan Cheng71fb9ad2006-01-26 00:29:36 +00001400 TB, OpSize;
Evan Cheng069287d2006-05-16 07:21:53 +00001401def CMOVNP32rr : I<0x4B, MRMSrcReg, // if !parity, GR32 = GR32
Evan Cheng64d80e32007-07-19 01:14:50 +00001402 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Sean Callanan108934c2009-12-18 00:01:26 +00001403 "cmovnp{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001404 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Chenge5f62042007-09-29 00:00:36 +00001405 X86_COND_NP, EFLAGS))]>,
Evan Cheng71fb9ad2006-01-26 00:29:36 +00001406 TB;
Dan Gohman305fceb2009-01-07 00:35:10 +00001407def CMOVO16rr : I<0x40, MRMSrcReg, // if overflow, GR16 = GR16
1408 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Sean Callanan108934c2009-12-18 00:01:26 +00001409 "cmovo{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohman305fceb2009-01-07 00:35:10 +00001410 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
1411 X86_COND_O, EFLAGS))]>,
1412 TB, OpSize;
1413def CMOVO32rr : I<0x40, MRMSrcReg, // if overflow, GR32 = GR32
1414 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Sean Callanan108934c2009-12-18 00:01:26 +00001415 "cmovo{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohman305fceb2009-01-07 00:35:10 +00001416 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
1417 X86_COND_O, EFLAGS))]>,
Evan Cheng0488db92007-09-25 01:57:46 +00001418 TB;
Dan Gohman305fceb2009-01-07 00:35:10 +00001419def CMOVNO16rr : I<0x41, MRMSrcReg, // if !overflow, GR16 = GR16
1420 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Sean Callanan108934c2009-12-18 00:01:26 +00001421 "cmovno{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohman305fceb2009-01-07 00:35:10 +00001422 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
1423 X86_COND_NO, EFLAGS))]>,
1424 TB, OpSize;
1425def CMOVNO32rr : I<0x41, MRMSrcReg, // if !overflow, GR32 = GR32
1426 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Sean Callanan108934c2009-12-18 00:01:26 +00001427 "cmovno{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohman305fceb2009-01-07 00:35:10 +00001428 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
1429 X86_COND_NO, EFLAGS))]>,
1430 TB;
1431} // isCommutable = 1
Evan Cheng7ad42d92007-10-05 23:13:21 +00001432
1433def CMOVB16rm : I<0x42, MRMSrcMem, // if <u, GR16 = [mem16]
1434 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
Sean Callanan108934c2009-12-18 00:01:26 +00001435 "cmovb{w}\t{$src2, $dst|$dst, $src2}",
Evan Cheng7ad42d92007-10-05 23:13:21 +00001436 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1437 X86_COND_B, EFLAGS))]>,
1438 TB, OpSize;
1439def CMOVB32rm : I<0x42, MRMSrcMem, // if <u, GR32 = [mem32]
1440 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Sean Callanan108934c2009-12-18 00:01:26 +00001441 "cmovb{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng7ad42d92007-10-05 23:13:21 +00001442 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1443 X86_COND_B, EFLAGS))]>,
1444 TB;
1445def CMOVAE16rm: I<0x43, MRMSrcMem, // if >=u, GR16 = [mem16]
1446 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
Sean Callanan108934c2009-12-18 00:01:26 +00001447 "cmovae{w}\t{$src2, $dst|$dst, $src2}",
Evan Cheng7ad42d92007-10-05 23:13:21 +00001448 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1449 X86_COND_AE, EFLAGS))]>,
1450 TB, OpSize;
1451def CMOVAE32rm: I<0x43, MRMSrcMem, // if >=u, GR32 = [mem32]
1452 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Sean Callanan108934c2009-12-18 00:01:26 +00001453 "cmovae{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng7ad42d92007-10-05 23:13:21 +00001454 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1455 X86_COND_AE, EFLAGS))]>,
1456 TB;
1457def CMOVE16rm : I<0x44, MRMSrcMem, // if ==, GR16 = [mem16]
1458 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
Sean Callanan108934c2009-12-18 00:01:26 +00001459 "cmove{w}\t{$src2, $dst|$dst, $src2}",
Evan Cheng7ad42d92007-10-05 23:13:21 +00001460 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1461 X86_COND_E, EFLAGS))]>,
1462 TB, OpSize;
1463def CMOVE32rm : I<0x44, MRMSrcMem, // if ==, GR32 = [mem32]
1464 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Sean Callanan108934c2009-12-18 00:01:26 +00001465 "cmove{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng7ad42d92007-10-05 23:13:21 +00001466 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1467 X86_COND_E, EFLAGS))]>,
1468 TB;
1469def CMOVNE16rm: I<0x45, MRMSrcMem, // if !=, GR16 = [mem16]
1470 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
Sean Callanan108934c2009-12-18 00:01:26 +00001471 "cmovne{w}\t{$src2, $dst|$dst, $src2}",
Evan Cheng7ad42d92007-10-05 23:13:21 +00001472 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1473 X86_COND_NE, EFLAGS))]>,
1474 TB, OpSize;
1475def CMOVNE32rm: I<0x45, MRMSrcMem, // if !=, GR32 = [mem32]
1476 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Sean Callanan108934c2009-12-18 00:01:26 +00001477 "cmovne{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng7ad42d92007-10-05 23:13:21 +00001478 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1479 X86_COND_NE, EFLAGS))]>,
1480 TB;
1481def CMOVBE16rm: I<0x46, MRMSrcMem, // if <=u, GR16 = [mem16]
1482 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
Sean Callanan108934c2009-12-18 00:01:26 +00001483 "cmovbe{w}\t{$src2, $dst|$dst, $src2}",
Evan Cheng7ad42d92007-10-05 23:13:21 +00001484 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1485 X86_COND_BE, EFLAGS))]>,
1486 TB, OpSize;
1487def CMOVBE32rm: I<0x46, MRMSrcMem, // if <=u, GR32 = [mem32]
1488 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Sean Callanan108934c2009-12-18 00:01:26 +00001489 "cmovbe{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng7ad42d92007-10-05 23:13:21 +00001490 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1491 X86_COND_BE, EFLAGS))]>,
1492 TB;
1493def CMOVA16rm : I<0x47, MRMSrcMem, // if >u, GR16 = [mem16]
1494 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
Sean Callanan108934c2009-12-18 00:01:26 +00001495 "cmova{w}\t{$src2, $dst|$dst, $src2}",
Evan Cheng7ad42d92007-10-05 23:13:21 +00001496 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1497 X86_COND_A, EFLAGS))]>,
1498 TB, OpSize;
1499def CMOVA32rm : I<0x47, MRMSrcMem, // if >u, GR32 = [mem32]
1500 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Sean Callanan108934c2009-12-18 00:01:26 +00001501 "cmova{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng7ad42d92007-10-05 23:13:21 +00001502 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1503 X86_COND_A, EFLAGS))]>,
1504 TB;
1505def CMOVL16rm : I<0x4C, MRMSrcMem, // if <s, GR16 = [mem16]
1506 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
Sean Callanan108934c2009-12-18 00:01:26 +00001507 "cmovl{w}\t{$src2, $dst|$dst, $src2}",
Evan Cheng7ad42d92007-10-05 23:13:21 +00001508 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1509 X86_COND_L, EFLAGS))]>,
1510 TB, OpSize;
1511def CMOVL32rm : I<0x4C, MRMSrcMem, // if <s, GR32 = [mem32]
1512 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Sean Callanan108934c2009-12-18 00:01:26 +00001513 "cmovl{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng7ad42d92007-10-05 23:13:21 +00001514 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1515 X86_COND_L, EFLAGS))]>,
1516 TB;
1517def CMOVGE16rm: I<0x4D, MRMSrcMem, // if >=s, GR16 = [mem16]
1518 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
Sean Callanan108934c2009-12-18 00:01:26 +00001519 "cmovge{w}\t{$src2, $dst|$dst, $src2}",
Evan Cheng7ad42d92007-10-05 23:13:21 +00001520 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1521 X86_COND_GE, EFLAGS))]>,
1522 TB, OpSize;
1523def CMOVGE32rm: I<0x4D, MRMSrcMem, // if >=s, GR32 = [mem32]
1524 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Sean Callanan108934c2009-12-18 00:01:26 +00001525 "cmovge{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng7ad42d92007-10-05 23:13:21 +00001526 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1527 X86_COND_GE, EFLAGS))]>,
1528 TB;
1529def CMOVLE16rm: I<0x4E, MRMSrcMem, // if <=s, GR16 = [mem16]
1530 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
Sean Callanan108934c2009-12-18 00:01:26 +00001531 "cmovle{w}\t{$src2, $dst|$dst, $src2}",
Evan Cheng7ad42d92007-10-05 23:13:21 +00001532 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1533 X86_COND_LE, EFLAGS))]>,
1534 TB, OpSize;
1535def CMOVLE32rm: I<0x4E, MRMSrcMem, // if <=s, GR32 = [mem32]
1536 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Sean Callanan108934c2009-12-18 00:01:26 +00001537 "cmovle{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng7ad42d92007-10-05 23:13:21 +00001538 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1539 X86_COND_LE, EFLAGS))]>,
1540 TB;
1541def CMOVG16rm : I<0x4F, MRMSrcMem, // if >s, GR16 = [mem16]
1542 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
Sean Callanan108934c2009-12-18 00:01:26 +00001543 "cmovg{w}\t{$src2, $dst|$dst, $src2}",
Evan Cheng7ad42d92007-10-05 23:13:21 +00001544 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1545 X86_COND_G, EFLAGS))]>,
1546 TB, OpSize;
1547def CMOVG32rm : I<0x4F, MRMSrcMem, // if >s, GR32 = [mem32]
1548 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Sean Callanan108934c2009-12-18 00:01:26 +00001549 "cmovg{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng7ad42d92007-10-05 23:13:21 +00001550 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1551 X86_COND_G, EFLAGS))]>,
1552 TB;
1553def CMOVS16rm : I<0x48, MRMSrcMem, // if signed, GR16 = [mem16]
1554 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
Sean Callanan108934c2009-12-18 00:01:26 +00001555 "cmovs{w}\t{$src2, $dst|$dst, $src2}",
Evan Cheng7ad42d92007-10-05 23:13:21 +00001556 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1557 X86_COND_S, EFLAGS))]>,
1558 TB, OpSize;
1559def CMOVS32rm : I<0x48, MRMSrcMem, // if signed, GR32 = [mem32]
1560 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Sean Callanan108934c2009-12-18 00:01:26 +00001561 "cmovs{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng7ad42d92007-10-05 23:13:21 +00001562 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1563 X86_COND_S, EFLAGS))]>,
1564 TB;
1565def CMOVNS16rm: I<0x49, MRMSrcMem, // if !signed, GR16 = [mem16]
1566 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
Sean Callanan108934c2009-12-18 00:01:26 +00001567 "cmovns{w}\t{$src2, $dst|$dst, $src2}",
Evan Cheng7ad42d92007-10-05 23:13:21 +00001568 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1569 X86_COND_NS, EFLAGS))]>,
1570 TB, OpSize;
1571def CMOVNS32rm: I<0x49, MRMSrcMem, // if !signed, GR32 = [mem32]
1572 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Sean Callanan108934c2009-12-18 00:01:26 +00001573 "cmovns{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng7ad42d92007-10-05 23:13:21 +00001574 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1575 X86_COND_NS, EFLAGS))]>,
1576 TB;
1577def CMOVP16rm : I<0x4A, MRMSrcMem, // if parity, GR16 = [mem16]
1578 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
Sean Callanan108934c2009-12-18 00:01:26 +00001579 "cmovp{w}\t{$src2, $dst|$dst, $src2}",
Evan Cheng7ad42d92007-10-05 23:13:21 +00001580 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1581 X86_COND_P, EFLAGS))]>,
1582 TB, OpSize;
1583def CMOVP32rm : I<0x4A, MRMSrcMem, // if parity, GR32 = [mem32]
1584 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Sean Callanan108934c2009-12-18 00:01:26 +00001585 "cmovp{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng7ad42d92007-10-05 23:13:21 +00001586 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1587 X86_COND_P, EFLAGS))]>,
1588 TB;
1589def CMOVNP16rm : I<0x4B, MRMSrcMem, // if !parity, GR16 = [mem16]
1590 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
Sean Callanan108934c2009-12-18 00:01:26 +00001591 "cmovnp{w}\t{$src2, $dst|$dst, $src2}",
Evan Cheng7ad42d92007-10-05 23:13:21 +00001592 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1593 X86_COND_NP, EFLAGS))]>,
1594 TB, OpSize;
Dan Gohman305fceb2009-01-07 00:35:10 +00001595def CMOVNP32rm : I<0x4B, MRMSrcMem, // if !parity, GR32 = [mem32]
1596 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Sean Callanan108934c2009-12-18 00:01:26 +00001597 "cmovnp{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohman305fceb2009-01-07 00:35:10 +00001598 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1599 X86_COND_NP, EFLAGS))]>,
1600 TB;
1601def CMOVO16rm : I<0x40, MRMSrcMem, // if overflow, GR16 = [mem16]
1602 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
Sean Callanan108934c2009-12-18 00:01:26 +00001603 "cmovo{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohman305fceb2009-01-07 00:35:10 +00001604 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1605 X86_COND_O, EFLAGS))]>,
1606 TB, OpSize;
1607def CMOVO32rm : I<0x40, MRMSrcMem, // if overflow, GR32 = [mem32]
1608 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Sean Callanan108934c2009-12-18 00:01:26 +00001609 "cmovo{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohman305fceb2009-01-07 00:35:10 +00001610 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1611 X86_COND_O, EFLAGS))]>,
1612 TB;
1613def CMOVNO16rm : I<0x41, MRMSrcMem, // if !overflow, GR16 = [mem16]
1614 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
Sean Callanan108934c2009-12-18 00:01:26 +00001615 "cmovno{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohman305fceb2009-01-07 00:35:10 +00001616 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1617 X86_COND_NO, EFLAGS))]>,
1618 TB, OpSize;
1619def CMOVNO32rm : I<0x41, MRMSrcMem, // if !overflow, GR32 = [mem32]
1620 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Sean Callanan108934c2009-12-18 00:01:26 +00001621 "cmovno{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohman305fceb2009-01-07 00:35:10 +00001622 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1623 X86_COND_NO, EFLAGS))]>,
1624 TB;
Evan Cheng0488db92007-09-25 01:57:46 +00001625} // Uses = [EFLAGS]
1626
1627
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00001628// unary instructions
Evan Cheng1693e482006-07-19 00:27:29 +00001629let CodeSize = 2 in {
Evan Cheng24f2ea32007-09-14 21:48:26 +00001630let Defs = [EFLAGS] in {
Dan Gohmanb1576f52007-07-31 20:11:57 +00001631def NEG8r : I<0xF6, MRM3r, (outs GR8 :$dst), (ins GR8 :$src), "neg{b}\t$dst",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001632 [(set GR8:$dst, (ineg GR8:$src)),
1633 (implicit EFLAGS)]>;
Dan Gohmanb1576f52007-07-31 20:11:57 +00001634def NEG16r : I<0xF7, MRM3r, (outs GR16:$dst), (ins GR16:$src), "neg{w}\t$dst",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001635 [(set GR16:$dst, (ineg GR16:$src)),
1636 (implicit EFLAGS)]>, OpSize;
Dan Gohmanb1576f52007-07-31 20:11:57 +00001637def NEG32r : I<0xF7, MRM3r, (outs GR32:$dst), (ins GR32:$src), "neg{l}\t$dst",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001638 [(set GR32:$dst, (ineg GR32:$src)),
1639 (implicit EFLAGS)]>;
Chris Lattner57a02302004-08-11 04:31:00 +00001640let isTwoAddress = 0 in {
Dan Gohmanb1576f52007-07-31 20:11:57 +00001641 def NEG8m : I<0xF6, MRM3m, (outs), (ins i8mem :$dst), "neg{b}\t$dst",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001642 [(store (ineg (loadi8 addr:$dst)), addr:$dst),
1643 (implicit EFLAGS)]>;
Dan Gohmanb1576f52007-07-31 20:11:57 +00001644 def NEG16m : I<0xF7, MRM3m, (outs), (ins i16mem:$dst), "neg{w}\t$dst",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001645 [(store (ineg (loadi16 addr:$dst)), addr:$dst),
1646 (implicit EFLAGS)]>, OpSize;
Dan Gohmanb1576f52007-07-31 20:11:57 +00001647 def NEG32m : I<0xF7, MRM3m, (outs), (ins i32mem:$dst), "neg{l}\t$dst",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001648 [(store (ineg (loadi32 addr:$dst)), addr:$dst),
1649 (implicit EFLAGS)]>;
Chris Lattner57a02302004-08-11 04:31:00 +00001650}
Evan Cheng24f2ea32007-09-14 21:48:26 +00001651} // Defs = [EFLAGS]
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00001652
Evan Chengaaf414c2009-01-21 02:09:05 +00001653// Match xor -1 to not. Favors these over a move imm + xor to save code size.
1654let AddedComplexity = 15 in {
Dan Gohmanb1576f52007-07-31 20:11:57 +00001655def NOT8r : I<0xF6, MRM2r, (outs GR8 :$dst), (ins GR8 :$src), "not{b}\t$dst",
Evan Cheng069287d2006-05-16 07:21:53 +00001656 [(set GR8:$dst, (not GR8:$src))]>;
Dan Gohmanb1576f52007-07-31 20:11:57 +00001657def NOT16r : I<0xF7, MRM2r, (outs GR16:$dst), (ins GR16:$src), "not{w}\t$dst",
Evan Cheng069287d2006-05-16 07:21:53 +00001658 [(set GR16:$dst, (not GR16:$src))]>, OpSize;
Dan Gohmanb1576f52007-07-31 20:11:57 +00001659def NOT32r : I<0xF7, MRM2r, (outs GR32:$dst), (ins GR32:$src), "not{l}\t$dst",
Evan Cheng069287d2006-05-16 07:21:53 +00001660 [(set GR32:$dst, (not GR32:$src))]>;
Evan Chengaaf414c2009-01-21 02:09:05 +00001661}
Chris Lattner57a02302004-08-11 04:31:00 +00001662let isTwoAddress = 0 in {
Dan Gohmanb1576f52007-07-31 20:11:57 +00001663 def NOT8m : I<0xF6, MRM2m, (outs), (ins i8mem :$dst), "not{b}\t$dst",
Evan Cheng605c4152005-12-13 01:57:51 +00001664 [(store (not (loadi8 addr:$dst)), addr:$dst)]>;
Dan Gohmanb1576f52007-07-31 20:11:57 +00001665 def NOT16m : I<0xF7, MRM2m, (outs), (ins i16mem:$dst), "not{w}\t$dst",
Evan Cheng605c4152005-12-13 01:57:51 +00001666 [(store (not (loadi16 addr:$dst)), addr:$dst)]>, OpSize;
Dan Gohmanb1576f52007-07-31 20:11:57 +00001667 def NOT32m : I<0xF7, MRM2m, (outs), (ins i32mem:$dst), "not{l}\t$dst",
Evan Cheng605c4152005-12-13 01:57:51 +00001668 [(store (not (loadi32 addr:$dst)), addr:$dst)]>;
Chris Lattner57a02302004-08-11 04:31:00 +00001669}
Evan Cheng1693e482006-07-19 00:27:29 +00001670} // CodeSize
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00001671
Evan Chengb51a0592005-12-10 00:48:20 +00001672// TODO: inc/dec is slow for P4, but fast for Pentium-M.
Evan Cheng24f2ea32007-09-14 21:48:26 +00001673let Defs = [EFLAGS] in {
Evan Cheng1693e482006-07-19 00:27:29 +00001674let CodeSize = 2 in
Dan Gohmanb1576f52007-07-31 20:11:57 +00001675def INC8r : I<0xFE, MRM0r, (outs GR8 :$dst), (ins GR8 :$src), "inc{b}\t$dst",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001676 [(set GR8:$dst, (add GR8:$src, 1)),
1677 (implicit EFLAGS)]>;
Evan Cheng1693e482006-07-19 00:27:29 +00001678let isConvertibleToThreeAddress = 1, CodeSize = 1 in { // Can xform into LEA.
Sean Callanan108934c2009-12-18 00:01:26 +00001679def INC16r : I<0x40, AddRegFrm, (outs GR16:$dst), (ins GR16:$src),
1680 "inc{w}\t$dst",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001681 [(set GR16:$dst, (add GR16:$src, 1)),
1682 (implicit EFLAGS)]>,
Evan Cheng25ab6902006-09-08 06:48:29 +00001683 OpSize, Requires<[In32BitMode]>;
Sean Callanan108934c2009-12-18 00:01:26 +00001684def INC32r : I<0x40, AddRegFrm, (outs GR32:$dst), (ins GR32:$src),
1685 "inc{l}\t$dst",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001686 [(set GR32:$dst, (add GR32:$src, 1)),
1687 (implicit EFLAGS)]>, Requires<[In32BitMode]>;
Chris Lattnercc65bee2005-01-02 02:35:46 +00001688}
Evan Cheng1693e482006-07-19 00:27:29 +00001689let isTwoAddress = 0, CodeSize = 2 in {
Dan Gohmanb1576f52007-07-31 20:11:57 +00001690 def INC8m : I<0xFE, MRM0m, (outs), (ins i8mem :$dst), "inc{b}\t$dst",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001691 [(store (add (loadi8 addr:$dst), 1), addr:$dst),
1692 (implicit EFLAGS)]>;
Dan Gohmanb1576f52007-07-31 20:11:57 +00001693 def INC16m : I<0xFF, MRM0m, (outs), (ins i16mem:$dst), "inc{w}\t$dst",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001694 [(store (add (loadi16 addr:$dst), 1), addr:$dst),
1695 (implicit EFLAGS)]>,
Evan Cheng66f71632007-10-19 21:23:22 +00001696 OpSize, Requires<[In32BitMode]>;
Dan Gohmanb1576f52007-07-31 20:11:57 +00001697 def INC32m : I<0xFF, MRM0m, (outs), (ins i32mem:$dst), "inc{l}\t$dst",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001698 [(store (add (loadi32 addr:$dst), 1), addr:$dst),
1699 (implicit EFLAGS)]>,
Evan Cheng66f71632007-10-19 21:23:22 +00001700 Requires<[In32BitMode]>;
Chris Lattner57a02302004-08-11 04:31:00 +00001701}
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00001702
Evan Cheng1693e482006-07-19 00:27:29 +00001703let CodeSize = 2 in
Dan Gohmanb1576f52007-07-31 20:11:57 +00001704def DEC8r : I<0xFE, MRM1r, (outs GR8 :$dst), (ins GR8 :$src), "dec{b}\t$dst",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001705 [(set GR8:$dst, (add GR8:$src, -1)),
1706 (implicit EFLAGS)]>;
Evan Cheng1693e482006-07-19 00:27:29 +00001707let isConvertibleToThreeAddress = 1, CodeSize = 1 in { // Can xform into LEA.
Sean Callanan108934c2009-12-18 00:01:26 +00001708def DEC16r : I<0x48, AddRegFrm, (outs GR16:$dst), (ins GR16:$src),
1709 "dec{w}\t$dst",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001710 [(set GR16:$dst, (add GR16:$src, -1)),
1711 (implicit EFLAGS)]>,
Evan Cheng25ab6902006-09-08 06:48:29 +00001712 OpSize, Requires<[In32BitMode]>;
Sean Callanan108934c2009-12-18 00:01:26 +00001713def DEC32r : I<0x48, AddRegFrm, (outs GR32:$dst), (ins GR32:$src),
1714 "dec{l}\t$dst",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001715 [(set GR32:$dst, (add GR32:$src, -1)),
1716 (implicit EFLAGS)]>, Requires<[In32BitMode]>;
Chris Lattnercc65bee2005-01-02 02:35:46 +00001717}
Chris Lattner57a02302004-08-11 04:31:00 +00001718
Evan Cheng1693e482006-07-19 00:27:29 +00001719let isTwoAddress = 0, CodeSize = 2 in {
Dan Gohmanb1576f52007-07-31 20:11:57 +00001720 def DEC8m : I<0xFE, MRM1m, (outs), (ins i8mem :$dst), "dec{b}\t$dst",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001721 [(store (add (loadi8 addr:$dst), -1), addr:$dst),
1722 (implicit EFLAGS)]>;
Dan Gohmanb1576f52007-07-31 20:11:57 +00001723 def DEC16m : I<0xFF, MRM1m, (outs), (ins i16mem:$dst), "dec{w}\t$dst",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001724 [(store (add (loadi16 addr:$dst), -1), addr:$dst),
1725 (implicit EFLAGS)]>,
Evan Cheng66f71632007-10-19 21:23:22 +00001726 OpSize, Requires<[In32BitMode]>;
Dan Gohmanb1576f52007-07-31 20:11:57 +00001727 def DEC32m : I<0xFF, MRM1m, (outs), (ins i32mem:$dst), "dec{l}\t$dst",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001728 [(store (add (loadi32 addr:$dst), -1), addr:$dst),
1729 (implicit EFLAGS)]>,
Evan Cheng66f71632007-10-19 21:23:22 +00001730 Requires<[In32BitMode]>;
Chris Lattner57a02302004-08-11 04:31:00 +00001731}
Evan Cheng24f2ea32007-09-14 21:48:26 +00001732} // Defs = [EFLAGS]
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00001733
1734// Logical operators...
Evan Cheng24f2ea32007-09-14 21:48:26 +00001735let Defs = [EFLAGS] in {
Chris Lattnercc65bee2005-01-02 02:35:46 +00001736let isCommutable = 1 in { // X = AND Y, Z --> X = AND Z, Y
Chris Lattner3a173df2004-10-03 20:35:00 +00001737def AND8rr : I<0x20, MRMDestReg,
Evan Cheng64d80e32007-07-19 01:14:50 +00001738 (outs GR8 :$dst), (ins GR8 :$src1, GR8 :$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001739 "and{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001740 [(set GR8:$dst, (and GR8:$src1, GR8:$src2)),
1741 (implicit EFLAGS)]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00001742def AND16rr : I<0x21, MRMDestReg,
Evan Cheng64d80e32007-07-19 01:14:50 +00001743 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001744 "and{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001745 [(set GR16:$dst, (and GR16:$src1, GR16:$src2)),
1746 (implicit EFLAGS)]>, OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00001747def AND32rr : I<0x21, MRMDestReg,
Evan Cheng64d80e32007-07-19 01:14:50 +00001748 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001749 "and{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001750 [(set GR32:$dst, (and GR32:$src1, GR32:$src2)),
1751 (implicit EFLAGS)]>;
Chris Lattnercc65bee2005-01-02 02:35:46 +00001752}
Chris Lattner57a02302004-08-11 04:31:00 +00001753
Sean Callanan108934c2009-12-18 00:01:26 +00001754// AND instructions with the destination register in REG and the source register
1755// in R/M. Included for the disassembler.
1756def AND8rr_REV : I<0x22, MRMSrcReg, (outs GR8:$dst), (ins GR8:$src1, GR8:$src2),
1757 "and{b}\t{$src2, $dst|$dst, $src2}", []>;
1758def AND16rr_REV : I<0x23, MRMSrcReg, (outs GR16:$dst),
1759 (ins GR16:$src1, GR16:$src2),
1760 "and{w}\t{$src2, $dst|$dst, $src2}", []>, OpSize;
1761def AND32rr_REV : I<0x23, MRMSrcReg, (outs GR32:$dst),
1762 (ins GR32:$src1, GR32:$src2),
1763 "and{l}\t{$src2, $dst|$dst, $src2}", []>;
1764
Chris Lattner3a173df2004-10-03 20:35:00 +00001765def AND8rm : I<0x22, MRMSrcMem,
Evan Cheng64d80e32007-07-19 01:14:50 +00001766 (outs GR8 :$dst), (ins GR8 :$src1, i8mem :$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001767 "and{b}\t{$src2, $dst|$dst, $src2}",
Chris Lattnerc2406f22009-04-10 00:16:23 +00001768 [(set GR8:$dst, (and GR8:$src1, (loadi8 addr:$src2))),
Dan Gohman09a2609e2009-03-03 19:53:46 +00001769 (implicit EFLAGS)]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00001770def AND16rm : I<0x23, MRMSrcMem,
Evan Cheng64d80e32007-07-19 01:14:50 +00001771 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001772 "and{w}\t{$src2, $dst|$dst, $src2}",
Chris Lattnerc2406f22009-04-10 00:16:23 +00001773 [(set GR16:$dst, (and GR16:$src1, (loadi16 addr:$src2))),
Dan Gohman09a2609e2009-03-03 19:53:46 +00001774 (implicit EFLAGS)]>, OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00001775def AND32rm : I<0x23, MRMSrcMem,
Evan Cheng64d80e32007-07-19 01:14:50 +00001776 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001777 "and{l}\t{$src2, $dst|$dst, $src2}",
Chris Lattnerc2406f22009-04-10 00:16:23 +00001778 [(set GR32:$dst, (and GR32:$src1, (loadi32 addr:$src2))),
Dan Gohman09a2609e2009-03-03 19:53:46 +00001779 (implicit EFLAGS)]>;
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00001780
Chris Lattner3a173df2004-10-03 20:35:00 +00001781def AND8ri : Ii8<0x80, MRM4r,
Evan Cheng64d80e32007-07-19 01:14:50 +00001782 (outs GR8 :$dst), (ins GR8 :$src1, i8imm :$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001783 "and{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001784 [(set GR8:$dst, (and GR8:$src1, imm:$src2)),
1785 (implicit EFLAGS)]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00001786def AND16ri : Ii16<0x81, MRM4r,
Evan Cheng64d80e32007-07-19 01:14:50 +00001787 (outs GR16:$dst), (ins GR16:$src1, i16imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001788 "and{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001789 [(set GR16:$dst, (and GR16:$src1, imm:$src2)),
1790 (implicit EFLAGS)]>, OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00001791def AND32ri : Ii32<0x81, MRM4r,
Evan Cheng64d80e32007-07-19 01:14:50 +00001792 (outs GR32:$dst), (ins GR32:$src1, i32imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001793 "and{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001794 [(set GR32:$dst, (and GR32:$src1, imm:$src2)),
1795 (implicit EFLAGS)]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00001796def AND16ri8 : Ii8<0x83, MRM4r,
Evan Cheng64d80e32007-07-19 01:14:50 +00001797 (outs GR16:$dst), (ins GR16:$src1, i16i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001798 "and{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001799 [(set GR16:$dst, (and GR16:$src1, i16immSExt8:$src2)),
1800 (implicit EFLAGS)]>,
Evan Cheng9b6b6422005-12-13 00:14:11 +00001801 OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00001802def AND32ri8 : Ii8<0x83, MRM4r,
Evan Cheng64d80e32007-07-19 01:14:50 +00001803 (outs GR32:$dst), (ins GR32:$src1, i32i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001804 "and{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001805 [(set GR32:$dst, (and GR32:$src1, i32immSExt8:$src2)),
1806 (implicit EFLAGS)]>;
Chris Lattnerf29ed092004-08-11 05:07:25 +00001807
1808let isTwoAddress = 0 in {
Chris Lattner3a173df2004-10-03 20:35:00 +00001809 def AND8mr : I<0x20, MRMDestMem,
Evan Cheng64d80e32007-07-19 01:14:50 +00001810 (outs), (ins i8mem :$dst, GR8 :$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001811 "and{b}\t{$src, $dst|$dst, $src}",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001812 [(store (and (load addr:$dst), GR8:$src), addr:$dst),
1813 (implicit EFLAGS)]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00001814 def AND16mr : I<0x21, MRMDestMem,
Evan Cheng64d80e32007-07-19 01:14:50 +00001815 (outs), (ins i16mem:$dst, GR16:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001816 "and{w}\t{$src, $dst|$dst, $src}",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001817 [(store (and (load addr:$dst), GR16:$src), addr:$dst),
1818 (implicit EFLAGS)]>,
Evan Cheng0ef3a772005-12-13 01:41:36 +00001819 OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00001820 def AND32mr : I<0x21, MRMDestMem,
Evan Cheng64d80e32007-07-19 01:14:50 +00001821 (outs), (ins i32mem:$dst, GR32:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001822 "and{l}\t{$src, $dst|$dst, $src}",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001823 [(store (and (load addr:$dst), GR32:$src), addr:$dst),
1824 (implicit EFLAGS)]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00001825 def AND8mi : Ii8<0x80, MRM4m,
Evan Cheng64d80e32007-07-19 01:14:50 +00001826 (outs), (ins i8mem :$dst, i8imm :$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001827 "and{b}\t{$src, $dst|$dst, $src}",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001828 [(store (and (loadi8 addr:$dst), imm:$src), addr:$dst),
1829 (implicit EFLAGS)]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00001830 def AND16mi : Ii16<0x81, MRM4m,
Evan Cheng64d80e32007-07-19 01:14:50 +00001831 (outs), (ins i16mem:$dst, i16imm:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001832 "and{w}\t{$src, $dst|$dst, $src}",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001833 [(store (and (loadi16 addr:$dst), imm:$src), addr:$dst),
1834 (implicit EFLAGS)]>,
Evan Cheng0ef3a772005-12-13 01:41:36 +00001835 OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00001836 def AND32mi : Ii32<0x81, MRM4m,
Evan Cheng64d80e32007-07-19 01:14:50 +00001837 (outs), (ins i32mem:$dst, i32imm:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001838 "and{l}\t{$src, $dst|$dst, $src}",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001839 [(store (and (loadi32 addr:$dst), imm:$src), addr:$dst),
1840 (implicit EFLAGS)]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00001841 def AND16mi8 : Ii8<0x83, MRM4m,
Evan Cheng64d80e32007-07-19 01:14:50 +00001842 (outs), (ins i16mem:$dst, i16i8imm :$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001843 "and{w}\t{$src, $dst|$dst, $src}",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001844 [(store (and (load addr:$dst), i16immSExt8:$src), addr:$dst),
1845 (implicit EFLAGS)]>,
Evan Cheng0ef3a772005-12-13 01:41:36 +00001846 OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00001847 def AND32mi8 : Ii8<0x83, MRM4m,
Evan Cheng64d80e32007-07-19 01:14:50 +00001848 (outs), (ins i32mem:$dst, i32i8imm :$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001849 "and{l}\t{$src, $dst|$dst, $src}",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001850 [(store (and (load addr:$dst), i32immSExt8:$src), addr:$dst),
1851 (implicit EFLAGS)]>;
Sean Callanana09caa52009-09-02 00:55:49 +00001852
1853 def AND8i8 : Ii8<0x24, RawFrm, (outs), (ins i8imm:$src),
1854 "and{b}\t{$src, %al|%al, $src}", []>;
1855 def AND16i16 : Ii16<0x25, RawFrm, (outs), (ins i16imm:$src),
1856 "and{w}\t{$src, %ax|%ax, $src}", []>, OpSize;
1857 def AND32i32 : Ii32<0x25, RawFrm, (outs), (ins i32imm:$src),
1858 "and{l}\t{$src, %eax|%eax, $src}", []>;
1859
Chris Lattnerf29ed092004-08-11 05:07:25 +00001860}
1861
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00001862
Chris Lattnercc65bee2005-01-02 02:35:46 +00001863let isCommutable = 1 in { // X = OR Y, Z --> X = OR Z, Y
Sean Callanan108934c2009-12-18 00:01:26 +00001864def OR8rr : I<0x08, MRMDestReg, (outs GR8 :$dst),
1865 (ins GR8 :$src1, GR8 :$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001866 "or{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001867 [(set GR8:$dst, (or GR8:$src1, GR8:$src2)),
1868 (implicit EFLAGS)]>;
Sean Callanan108934c2009-12-18 00:01:26 +00001869def OR16rr : I<0x09, MRMDestReg, (outs GR16:$dst),
1870 (ins GR16:$src1, GR16:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001871 "or{w}\t{$src2, $dst|$dst, $src2}",
Evan Cheng199c4242010-01-11 22:03:29 +00001872 [(set GR16:$dst, (or_not_add GR16:$src1, GR16:$src2)),
Dan Gohman09a2609e2009-03-03 19:53:46 +00001873 (implicit EFLAGS)]>, OpSize;
Sean Callanan108934c2009-12-18 00:01:26 +00001874def OR32rr : I<0x09, MRMDestReg, (outs GR32:$dst),
1875 (ins GR32:$src1, GR32:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001876 "or{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng199c4242010-01-11 22:03:29 +00001877 [(set GR32:$dst, (or_not_add GR32:$src1, GR32:$src2)),
Dan Gohman09a2609e2009-03-03 19:53:46 +00001878 (implicit EFLAGS)]>;
Chris Lattnercc65bee2005-01-02 02:35:46 +00001879}
Sean Callanan108934c2009-12-18 00:01:26 +00001880
1881// OR instructions with the destination register in REG and the source register
1882// in R/M. Included for the disassembler.
1883def OR8rr_REV : I<0x0A, MRMSrcReg, (outs GR8:$dst), (ins GR8:$src1, GR8:$src2),
1884 "or{b}\t{$src2, $dst|$dst, $src2}", []>;
1885def OR16rr_REV : I<0x0B, MRMSrcReg, (outs GR16:$dst),
1886 (ins GR16:$src1, GR16:$src2),
1887 "or{w}\t{$src2, $dst|$dst, $src2}", []>, OpSize;
1888def OR32rr_REV : I<0x0B, MRMSrcReg, (outs GR32:$dst),
1889 (ins GR32:$src1, GR32:$src2),
1890 "or{l}\t{$src2, $dst|$dst, $src2}", []>;
1891
1892def OR8rm : I<0x0A, MRMSrcMem , (outs GR8 :$dst),
1893 (ins GR8 :$src1, i8mem :$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001894 "or{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001895 [(set GR8:$dst, (or GR8:$src1, (load addr:$src2))),
1896 (implicit EFLAGS)]>;
Sean Callanan108934c2009-12-18 00:01:26 +00001897def OR16rm : I<0x0B, MRMSrcMem , (outs GR16:$dst),
1898 (ins GR16:$src1, i16mem:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001899 "or{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001900 [(set GR16:$dst, (or GR16:$src1, (load addr:$src2))),
1901 (implicit EFLAGS)]>, OpSize;
Sean Callanan108934c2009-12-18 00:01:26 +00001902def OR32rm : I<0x0B, MRMSrcMem , (outs GR32:$dst),
1903 (ins GR32:$src1, i32mem:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001904 "or{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001905 [(set GR32:$dst, (or GR32:$src1, (load addr:$src2))),
1906 (implicit EFLAGS)]>;
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00001907
Sean Callanan108934c2009-12-18 00:01:26 +00001908def OR8ri : Ii8 <0x80, MRM1r, (outs GR8 :$dst),
1909 (ins GR8 :$src1, i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001910 "or{b}\t{$src2, $dst|$dst, $src2}",
Evan Chengac000fa2010-01-11 20:18:04 +00001911 [(set GR8:$dst, (or GR8:$src1, imm:$src2)),
Dan Gohman09a2609e2009-03-03 19:53:46 +00001912 (implicit EFLAGS)]>;
Sean Callanan108934c2009-12-18 00:01:26 +00001913def OR16ri : Ii16<0x81, MRM1r, (outs GR16:$dst),
1914 (ins GR16:$src1, i16imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001915 "or{w}\t{$src2, $dst|$dst, $src2}",
Evan Cheng4b0345b2010-01-11 17:03:47 +00001916 [(set GR16:$dst, (or_not_add GR16:$src1, imm:$src2)),
Dan Gohman09a2609e2009-03-03 19:53:46 +00001917 (implicit EFLAGS)]>, OpSize;
Sean Callanan108934c2009-12-18 00:01:26 +00001918def OR32ri : Ii32<0x81, MRM1r, (outs GR32:$dst),
1919 (ins GR32:$src1, i32imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001920 "or{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng4b0345b2010-01-11 17:03:47 +00001921 [(set GR32:$dst, (or_not_add GR32:$src1, imm:$src2)),
Dan Gohman09a2609e2009-03-03 19:53:46 +00001922 (implicit EFLAGS)]>;
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00001923
Sean Callanan108934c2009-12-18 00:01:26 +00001924def OR16ri8 : Ii8<0x83, MRM1r, (outs GR16:$dst),
1925 (ins GR16:$src1, i16i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001926 "or{w}\t{$src2, $dst|$dst, $src2}",
Evan Cheng4b0345b2010-01-11 17:03:47 +00001927 [(set GR16:$dst, (or_not_add GR16:$src1, i16immSExt8:$src2)),
Dan Gohman09a2609e2009-03-03 19:53:46 +00001928 (implicit EFLAGS)]>, OpSize;
Sean Callanan108934c2009-12-18 00:01:26 +00001929def OR32ri8 : Ii8<0x83, MRM1r, (outs GR32:$dst),
1930 (ins GR32:$src1, i32i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001931 "or{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng4b0345b2010-01-11 17:03:47 +00001932 [(set GR32:$dst, (or_not_add GR32:$src1, i32immSExt8:$src2)),
Dan Gohman09a2609e2009-03-03 19:53:46 +00001933 (implicit EFLAGS)]>;
Chris Lattner57a02302004-08-11 04:31:00 +00001934let isTwoAddress = 0 in {
Evan Cheng64d80e32007-07-19 01:14:50 +00001935 def OR8mr : I<0x08, MRMDestMem, (outs), (ins i8mem:$dst, GR8:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001936 "or{b}\t{$src, $dst|$dst, $src}",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001937 [(store (or (load addr:$dst), GR8:$src), addr:$dst),
1938 (implicit EFLAGS)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00001939 def OR16mr : I<0x09, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001940 "or{w}\t{$src, $dst|$dst, $src}",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001941 [(store (or (load addr:$dst), GR16:$src), addr:$dst),
1942 (implicit EFLAGS)]>, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00001943 def OR32mr : I<0x09, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001944 "or{l}\t{$src, $dst|$dst, $src}",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001945 [(store (or (load addr:$dst), GR32:$src), addr:$dst),
1946 (implicit EFLAGS)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00001947 def OR8mi : Ii8<0x80, MRM1m, (outs), (ins i8mem :$dst, i8imm:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001948 "or{b}\t{$src, $dst|$dst, $src}",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001949 [(store (or (loadi8 addr:$dst), imm:$src), addr:$dst),
1950 (implicit EFLAGS)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00001951 def OR16mi : Ii16<0x81, MRM1m, (outs), (ins i16mem:$dst, i16imm:$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 (loadi16 addr:$dst), imm:$src), addr:$dst),
1954 (implicit EFLAGS)]>,
Evan Cheng0ef3a772005-12-13 01:41:36 +00001955 OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00001956 def OR32mi : Ii32<0x81, MRM1m, (outs), (ins i32mem:$dst, i32imm:$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 (loadi32 addr:$dst), imm:$src), addr:$dst),
1959 (implicit EFLAGS)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00001960 def OR16mi8 : Ii8<0x83, MRM1m, (outs), (ins i16mem:$dst, i16i8imm:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001961 "or{w}\t{$src, $dst|$dst, $src}",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001962 [(store (or (load addr:$dst), i16immSExt8:$src), addr:$dst),
1963 (implicit EFLAGS)]>,
Evan Cheng0ef3a772005-12-13 01:41:36 +00001964 OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00001965 def OR32mi8 : Ii8<0x83, MRM1m, (outs), (ins i32mem:$dst, i32i8imm:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001966 "or{l}\t{$src, $dst|$dst, $src}",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001967 [(store (or (load addr:$dst), i32immSExt8:$src), addr:$dst),
1968 (implicit EFLAGS)]>;
Sean Callanand00025a2009-09-11 19:01:56 +00001969
1970 def OR8i8 : Ii8 <0x0C, RawFrm, (outs), (ins i8imm:$src),
1971 "or{b}\t{$src, %al|%al, $src}", []>;
1972 def OR16i16 : Ii16 <0x0D, RawFrm, (outs), (ins i16imm:$src),
1973 "or{w}\t{$src, %ax|%ax, $src}", []>, OpSize;
1974 def OR32i32 : Ii32 <0x0D, RawFrm, (outs), (ins i32imm:$src),
1975 "or{l}\t{$src, %eax|%eax, $src}", []>;
Bill Wendlingbd0879d2008-05-29 01:02:09 +00001976} // isTwoAddress = 0
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00001977
1978
Evan Cheng359e9372008-06-18 08:13:07 +00001979let isCommutable = 1 in { // X = XOR Y, Z --> X = XOR Z, Y
Bill Wendlingbd0879d2008-05-29 01:02:09 +00001980 def XOR8rr : I<0x30, MRMDestReg,
1981 (outs GR8 :$dst), (ins GR8 :$src1, GR8 :$src2),
1982 "xor{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001983 [(set GR8:$dst, (xor GR8:$src1, GR8:$src2)),
1984 (implicit EFLAGS)]>;
Bill Wendlingbd0879d2008-05-29 01:02:09 +00001985 def XOR16rr : I<0x31, MRMDestReg,
1986 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
1987 "xor{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001988 [(set GR16:$dst, (xor GR16:$src1, GR16:$src2)),
1989 (implicit EFLAGS)]>, OpSize;
Bill Wendlingbd0879d2008-05-29 01:02:09 +00001990 def XOR32rr : I<0x31, MRMDestReg,
1991 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
1992 "xor{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001993 [(set GR32:$dst, (xor GR32:$src1, GR32:$src2)),
1994 (implicit EFLAGS)]>;
Evan Cheng359e9372008-06-18 08:13:07 +00001995} // isCommutable = 1
Chris Lattnercc65bee2005-01-02 02:35:46 +00001996
Sean Callanan108934c2009-12-18 00:01:26 +00001997// XOR instructions with the destination register in REG and the source register
1998// in R/M. Included for the disassembler.
1999def XOR8rr_REV : I<0x32, MRMSrcReg, (outs GR8:$dst), (ins GR8:$src1, GR8:$src2),
2000 "xor{b}\t{$src2, $dst|$dst, $src2}", []>;
2001def XOR16rr_REV : I<0x33, MRMSrcReg, (outs GR16:$dst),
2002 (ins GR16:$src1, GR16:$src2),
2003 "xor{w}\t{$src2, $dst|$dst, $src2}", []>, OpSize;
2004def XOR32rr_REV : I<0x33, MRMSrcReg, (outs GR32:$dst),
2005 (ins GR32:$src1, GR32:$src2),
2006 "xor{l}\t{$src2, $dst|$dst, $src2}", []>;
2007
Chris Lattner3a173df2004-10-03 20:35:00 +00002008def XOR8rm : I<0x32, MRMSrcMem ,
Evan Cheng64d80e32007-07-19 01:14:50 +00002009 (outs GR8 :$dst), (ins GR8:$src1, i8mem :$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002010 "xor{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohman09a2609e2009-03-03 19:53:46 +00002011 [(set GR8:$dst, (xor GR8:$src1, (load addr:$src2))),
2012 (implicit EFLAGS)]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00002013def XOR16rm : I<0x33, MRMSrcMem ,
Evan Cheng64d80e32007-07-19 01:14:50 +00002014 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002015 "xor{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohman09a2609e2009-03-03 19:53:46 +00002016 [(set GR16:$dst, (xor GR16:$src1, (load addr:$src2))),
2017 (implicit EFLAGS)]>,
Bill Wendlingbd0879d2008-05-29 01:02:09 +00002018 OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00002019def XOR32rm : I<0x33, MRMSrcMem ,
Evan Cheng64d80e32007-07-19 01:14:50 +00002020 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002021 "xor{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohman09a2609e2009-03-03 19:53:46 +00002022 [(set GR32:$dst, (xor GR32:$src1, (load addr:$src2))),
2023 (implicit EFLAGS)]>;
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00002024
Bill Wendling75cf88f2008-05-29 03:46:36 +00002025def XOR8ri : Ii8<0x80, MRM6r,
2026 (outs GR8:$dst), (ins GR8:$src1, i8imm:$src2),
2027 "xor{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohman09a2609e2009-03-03 19:53:46 +00002028 [(set GR8:$dst, (xor GR8:$src1, imm:$src2)),
2029 (implicit EFLAGS)]>;
Bill Wendling75cf88f2008-05-29 03:46:36 +00002030def XOR16ri : Ii16<0x81, MRM6r,
2031 (outs GR16:$dst), (ins GR16:$src1, i16imm:$src2),
2032 "xor{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohman09a2609e2009-03-03 19:53:46 +00002033 [(set GR16:$dst, (xor GR16:$src1, imm:$src2)),
2034 (implicit EFLAGS)]>, OpSize;
Bill Wendling75cf88f2008-05-29 03:46:36 +00002035def XOR32ri : Ii32<0x81, MRM6r,
2036 (outs GR32:$dst), (ins GR32:$src1, i32imm:$src2),
2037 "xor{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohman09a2609e2009-03-03 19:53:46 +00002038 [(set GR32:$dst, (xor GR32:$src1, imm:$src2)),
2039 (implicit EFLAGS)]>;
Bill Wendling75cf88f2008-05-29 03:46:36 +00002040def XOR16ri8 : Ii8<0x83, MRM6r,
2041 (outs GR16:$dst), (ins GR16:$src1, i16i8imm:$src2),
2042 "xor{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohman09a2609e2009-03-03 19:53:46 +00002043 [(set GR16:$dst, (xor GR16:$src1, i16immSExt8:$src2)),
2044 (implicit EFLAGS)]>,
Bill Wendling75cf88f2008-05-29 03:46:36 +00002045 OpSize;
2046def XOR32ri8 : Ii8<0x83, MRM6r,
2047 (outs GR32:$dst), (ins GR32:$src1, i32i8imm:$src2),
2048 "xor{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohman09a2609e2009-03-03 19:53:46 +00002049 [(set GR32:$dst, (xor GR32:$src1, i32immSExt8:$src2)),
2050 (implicit EFLAGS)]>;
Bill Wendlingbd0879d2008-05-29 01:02:09 +00002051
Chris Lattner57a02302004-08-11 04:31:00 +00002052let isTwoAddress = 0 in {
Chris Lattner3a173df2004-10-03 20:35:00 +00002053 def XOR8mr : I<0x30, MRMDestMem,
Evan Cheng64d80e32007-07-19 01:14:50 +00002054 (outs), (ins i8mem :$dst, GR8 :$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002055 "xor{b}\t{$src, $dst|$dst, $src}",
Dan Gohman09a2609e2009-03-03 19:53:46 +00002056 [(store (xor (load addr:$dst), GR8:$src), addr:$dst),
2057 (implicit EFLAGS)]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00002058 def XOR16mr : I<0x31, MRMDestMem,
Evan Cheng64d80e32007-07-19 01:14:50 +00002059 (outs), (ins i16mem:$dst, GR16:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002060 "xor{w}\t{$src, $dst|$dst, $src}",
Dan Gohman09a2609e2009-03-03 19:53:46 +00002061 [(store (xor (load addr:$dst), GR16:$src), addr:$dst),
2062 (implicit EFLAGS)]>,
Evan Cheng0ef3a772005-12-13 01:41:36 +00002063 OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00002064 def XOR32mr : I<0x31, MRMDestMem,
Evan Cheng64d80e32007-07-19 01:14:50 +00002065 (outs), (ins i32mem:$dst, GR32:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002066 "xor{l}\t{$src, $dst|$dst, $src}",
Dan Gohman09a2609e2009-03-03 19:53:46 +00002067 [(store (xor (load addr:$dst), GR32:$src), addr:$dst),
2068 (implicit EFLAGS)]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00002069 def XOR8mi : Ii8<0x80, MRM6m,
Evan Cheng64d80e32007-07-19 01:14:50 +00002070 (outs), (ins i8mem :$dst, i8imm :$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002071 "xor{b}\t{$src, $dst|$dst, $src}",
Dan Gohman09a2609e2009-03-03 19:53:46 +00002072 [(store (xor (loadi8 addr:$dst), imm:$src), addr:$dst),
2073 (implicit EFLAGS)]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00002074 def XOR16mi : Ii16<0x81, MRM6m,
Evan Cheng64d80e32007-07-19 01:14:50 +00002075 (outs), (ins i16mem:$dst, i16imm:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002076 "xor{w}\t{$src, $dst|$dst, $src}",
Dan Gohman09a2609e2009-03-03 19:53:46 +00002077 [(store (xor (loadi16 addr:$dst), imm:$src), addr:$dst),
2078 (implicit EFLAGS)]>,
Evan Cheng0ef3a772005-12-13 01:41:36 +00002079 OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00002080 def XOR32mi : Ii32<0x81, MRM6m,
Evan Cheng64d80e32007-07-19 01:14:50 +00002081 (outs), (ins i32mem:$dst, i32imm:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002082 "xor{l}\t{$src, $dst|$dst, $src}",
Dan Gohman09a2609e2009-03-03 19:53:46 +00002083 [(store (xor (loadi32 addr:$dst), imm:$src), addr:$dst),
2084 (implicit EFLAGS)]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00002085 def XOR16mi8 : Ii8<0x83, MRM6m,
Evan Cheng64d80e32007-07-19 01:14:50 +00002086 (outs), (ins i16mem:$dst, i16i8imm :$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002087 "xor{w}\t{$src, $dst|$dst, $src}",
Dan Gohman09a2609e2009-03-03 19:53:46 +00002088 [(store (xor (load addr:$dst), i16immSExt8:$src), addr:$dst),
2089 (implicit EFLAGS)]>,
Evan Cheng0ef3a772005-12-13 01:41:36 +00002090 OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00002091 def XOR32mi8 : Ii8<0x83, MRM6m,
Evan Cheng64d80e32007-07-19 01:14:50 +00002092 (outs), (ins i32mem:$dst, i32i8imm :$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002093 "xor{l}\t{$src, $dst|$dst, $src}",
Dan Gohman09a2609e2009-03-03 19:53:46 +00002094 [(store (xor (load addr:$dst), i32immSExt8:$src), addr:$dst),
2095 (implicit EFLAGS)]>;
Sean Callanan7893ec62009-09-10 19:52:26 +00002096
2097 def XOR8i8 : Ii8 <0x34, RawFrm, (outs), (ins i8imm:$src),
2098 "xor{b}\t{$src, %al|%al, $src}", []>;
2099 def XOR16i16 : Ii16 <0x35, RawFrm, (outs), (ins i16imm:$src),
2100 "xor{w}\t{$src, %ax|%ax, $src}", []>, OpSize;
2101 def XOR32i32 : Ii32 <0x35, RawFrm, (outs), (ins i32imm:$src),
2102 "xor{l}\t{$src, %eax|%eax, $src}", []>;
Bill Wendlingbd0879d2008-05-29 01:02:09 +00002103} // isTwoAddress = 0
Evan Cheng24f2ea32007-09-14 21:48:26 +00002104} // Defs = [EFLAGS]
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00002105
2106// Shift instructions
Evan Cheng24f2ea32007-09-14 21:48:26 +00002107let Defs = [EFLAGS] in {
Evan Cheng071a2792007-09-11 19:55:27 +00002108let Uses = [CL] in {
Evan Cheng64d80e32007-07-19 01:14:50 +00002109def SHL8rCL : I<0xD2, MRM4r, (outs GR8 :$dst), (ins GR8 :$src),
Eli Friedmanaace4b12009-06-19 04:48:38 +00002110 "shl{b}\t{%cl, $dst|$dst, CL}",
Evan Cheng071a2792007-09-11 19:55:27 +00002111 [(set GR8:$dst, (shl GR8:$src, CL))]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00002112def SHL16rCL : I<0xD3, MRM4r, (outs GR16:$dst), (ins GR16:$src),
Eli Friedmanaace4b12009-06-19 04:48:38 +00002113 "shl{w}\t{%cl, $dst|$dst, CL}",
Evan Cheng071a2792007-09-11 19:55:27 +00002114 [(set GR16:$dst, (shl GR16:$src, CL))]>, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00002115def SHL32rCL : I<0xD3, MRM4r, (outs GR32:$dst), (ins GR32:$src),
Eli Friedmanaace4b12009-06-19 04:48:38 +00002116 "shl{l}\t{%cl, $dst|$dst, CL}",
Evan Cheng071a2792007-09-11 19:55:27 +00002117 [(set GR32:$dst, (shl GR32:$src, CL))]>;
Bill Wendlingbd0879d2008-05-29 01:02:09 +00002118} // Uses = [CL]
Chris Lattnercc65bee2005-01-02 02:35:46 +00002119
Evan Cheng64d80e32007-07-19 01:14:50 +00002120def SHL8ri : Ii8<0xC0, MRM4r, (outs GR8 :$dst), (ins GR8 :$src1, i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002121 "shl{b}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00002122 [(set GR8:$dst, (shl GR8:$src1, (i8 imm:$src2)))]>;
Chris Lattnercc65bee2005-01-02 02:35:46 +00002123let isConvertibleToThreeAddress = 1 in { // Can transform into LEA.
Evan Cheng64d80e32007-07-19 01:14:50 +00002124def SHL16ri : Ii8<0xC1, MRM4r, (outs GR16:$dst), (ins GR16:$src1, i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002125 "shl{w}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00002126 [(set GR16:$dst, (shl GR16:$src1, (i8 imm:$src2)))]>, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00002127def SHL32ri : Ii8<0xC1, MRM4r, (outs GR32:$dst), (ins GR32:$src1, i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002128 "shl{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00002129 [(set GR32:$dst, (shl GR32:$src1, (i8 imm:$src2)))]>;
Sean Callanan13cf8e92009-09-16 02:28:43 +00002130
2131// NOTE: We don't include patterns for shifts of a register by one, because
2132// 'add reg,reg' is cheaper.
2133
2134def SHL8r1 : I<0xD0, MRM4r, (outs GR8:$dst), (ins GR8:$src1),
2135 "shl{b}\t$dst", []>;
2136def SHL16r1 : I<0xD1, MRM4r, (outs GR16:$dst), (ins GR16:$src1),
2137 "shl{w}\t$dst", []>, OpSize;
2138def SHL32r1 : I<0xD1, MRM4r, (outs GR32:$dst), (ins GR32:$src1),
2139 "shl{l}\t$dst", []>;
2140
Bill Wendlingbd0879d2008-05-29 01:02:09 +00002141} // isConvertibleToThreeAddress = 1
Evan Cheng09c54572006-06-29 00:36:51 +00002142
Chris Lattnerf29ed092004-08-11 05:07:25 +00002143let isTwoAddress = 0 in {
Evan Cheng071a2792007-09-11 19:55:27 +00002144 let Uses = [CL] in {
Evan Cheng64d80e32007-07-19 01:14:50 +00002145 def SHL8mCL : I<0xD2, MRM4m, (outs), (ins i8mem :$dst),
Eli Friedmanaace4b12009-06-19 04:48:38 +00002146 "shl{b}\t{%cl, $dst|$dst, CL}",
Evan Cheng071a2792007-09-11 19:55:27 +00002147 [(store (shl (loadi8 addr:$dst), CL), addr:$dst)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00002148 def SHL16mCL : I<0xD3, MRM4m, (outs), (ins i16mem:$dst),
Eli Friedmanaace4b12009-06-19 04:48:38 +00002149 "shl{w}\t{%cl, $dst|$dst, CL}",
Evan Cheng071a2792007-09-11 19:55:27 +00002150 [(store (shl (loadi16 addr:$dst), CL), addr:$dst)]>, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00002151 def SHL32mCL : I<0xD3, MRM4m, (outs), (ins i32mem:$dst),
Eli Friedmanaace4b12009-06-19 04:48:38 +00002152 "shl{l}\t{%cl, $dst|$dst, CL}",
Evan Cheng071a2792007-09-11 19:55:27 +00002153 [(store (shl (loadi32 addr:$dst), CL), addr:$dst)]>;
2154 }
Evan Cheng64d80e32007-07-19 01:14:50 +00002155 def SHL8mi : Ii8<0xC0, MRM4m, (outs), (ins i8mem :$dst, i8imm:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002156 "shl{b}\t{$src, $dst|$dst, $src}",
Evan Cheng763b0292005-12-13 02:34:51 +00002157 [(store (shl (loadi8 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00002158 def SHL16mi : Ii8<0xC1, MRM4m, (outs), (ins i16mem:$dst, i8imm:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002159 "shl{w}\t{$src, $dst|$dst, $src}",
Evan Cheng763b0292005-12-13 02:34:51 +00002160 [(store (shl (loadi16 addr:$dst), (i8 imm:$src)), addr:$dst)]>,
2161 OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00002162 def SHL32mi : Ii8<0xC1, MRM4m, (outs), (ins i32mem:$dst, i8imm:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002163 "shl{l}\t{$src, $dst|$dst, $src}",
Evan Cheng763b0292005-12-13 02:34:51 +00002164 [(store (shl (loadi32 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
Evan Cheng09c54572006-06-29 00:36:51 +00002165
2166 // Shift by 1
Evan Cheng64d80e32007-07-19 01:14:50 +00002167 def SHL8m1 : I<0xD0, MRM4m, (outs), (ins i8mem :$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002168 "shl{b}\t$dst",
Evan Cheng09c54572006-06-29 00:36:51 +00002169 [(store (shl (loadi8 addr:$dst), (i8 1)), addr:$dst)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00002170 def SHL16m1 : I<0xD1, MRM4m, (outs), (ins i16mem:$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002171 "shl{w}\t$dst",
Evan Cheng09c54572006-06-29 00:36:51 +00002172 [(store (shl (loadi16 addr:$dst), (i8 1)), addr:$dst)]>,
2173 OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00002174 def SHL32m1 : I<0xD1, MRM4m, (outs), (ins i32mem:$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002175 "shl{l}\t$dst",
Evan Cheng09c54572006-06-29 00:36:51 +00002176 [(store (shl (loadi32 addr:$dst), (i8 1)), addr:$dst)]>;
Chris Lattnerf29ed092004-08-11 05:07:25 +00002177}
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00002178
Evan Cheng071a2792007-09-11 19:55:27 +00002179let Uses = [CL] in {
Evan Cheng64d80e32007-07-19 01:14:50 +00002180def SHR8rCL : I<0xD2, MRM5r, (outs GR8 :$dst), (ins GR8 :$src),
Eli Friedmanaace4b12009-06-19 04:48:38 +00002181 "shr{b}\t{%cl, $dst|$dst, CL}",
Evan Cheng071a2792007-09-11 19:55:27 +00002182 [(set GR8:$dst, (srl GR8:$src, CL))]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00002183def SHR16rCL : I<0xD3, MRM5r, (outs GR16:$dst), (ins GR16:$src),
Eli Friedmanaace4b12009-06-19 04:48:38 +00002184 "shr{w}\t{%cl, $dst|$dst, CL}",
Evan Cheng071a2792007-09-11 19:55:27 +00002185 [(set GR16:$dst, (srl GR16:$src, CL))]>, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00002186def SHR32rCL : I<0xD3, MRM5r, (outs GR32:$dst), (ins GR32:$src),
Eli Friedmanaace4b12009-06-19 04:48:38 +00002187 "shr{l}\t{%cl, $dst|$dst, CL}",
Evan Cheng071a2792007-09-11 19:55:27 +00002188 [(set GR32:$dst, (srl GR32:$src, CL))]>;
2189}
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00002190
Evan Cheng64d80e32007-07-19 01:14:50 +00002191def SHR8ri : Ii8<0xC0, MRM5r, (outs GR8:$dst), (ins GR8:$src1, i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002192 "shr{b}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00002193 [(set GR8:$dst, (srl GR8:$src1, (i8 imm:$src2)))]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00002194def SHR16ri : Ii8<0xC1, MRM5r, (outs GR16:$dst), (ins GR16:$src1, i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002195 "shr{w}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00002196 [(set GR16:$dst, (srl GR16:$src1, (i8 imm:$src2)))]>, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00002197def SHR32ri : Ii8<0xC1, MRM5r, (outs GR32:$dst), (ins GR32:$src1, i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002198 "shr{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00002199 [(set GR32:$dst, (srl GR32:$src1, (i8 imm:$src2)))]>;
Chris Lattnerf29ed092004-08-11 05:07:25 +00002200
Evan Cheng09c54572006-06-29 00:36:51 +00002201// Shift by 1
Evan Cheng64d80e32007-07-19 01:14:50 +00002202def SHR8r1 : I<0xD0, MRM5r, (outs GR8:$dst), (ins GR8:$src1),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002203 "shr{b}\t$dst",
Evan Cheng09c54572006-06-29 00:36:51 +00002204 [(set GR8:$dst, (srl GR8:$src1, (i8 1)))]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00002205def SHR16r1 : I<0xD1, MRM5r, (outs GR16:$dst), (ins GR16:$src1),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002206 "shr{w}\t$dst",
Evan Cheng09c54572006-06-29 00:36:51 +00002207 [(set GR16:$dst, (srl GR16:$src1, (i8 1)))]>, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00002208def SHR32r1 : I<0xD1, MRM5r, (outs GR32:$dst), (ins GR32:$src1),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002209 "shr{l}\t$dst",
Evan Cheng09c54572006-06-29 00:36:51 +00002210 [(set GR32:$dst, (srl GR32:$src1, (i8 1)))]>;
2211
Chris Lattner57a02302004-08-11 04:31:00 +00002212let isTwoAddress = 0 in {
Evan Cheng071a2792007-09-11 19:55:27 +00002213 let Uses = [CL] in {
Evan Cheng64d80e32007-07-19 01:14:50 +00002214 def SHR8mCL : I<0xD2, MRM5m, (outs), (ins i8mem :$dst),
Eli Friedmanaace4b12009-06-19 04:48:38 +00002215 "shr{b}\t{%cl, $dst|$dst, CL}",
Evan Cheng071a2792007-09-11 19:55:27 +00002216 [(store (srl (loadi8 addr:$dst), CL), addr:$dst)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00002217 def SHR16mCL : I<0xD3, MRM5m, (outs), (ins i16mem:$dst),
Eli Friedmanaace4b12009-06-19 04:48:38 +00002218 "shr{w}\t{%cl, $dst|$dst, CL}",
Evan Cheng85dd8892005-12-13 07:24:22 +00002219 [(store (srl (loadi16 addr:$dst), CL), addr:$dst)]>,
Evan Cheng071a2792007-09-11 19:55:27 +00002220 OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00002221 def SHR32mCL : I<0xD3, MRM5m, (outs), (ins i32mem:$dst),
Eli Friedmanaace4b12009-06-19 04:48:38 +00002222 "shr{l}\t{%cl, $dst|$dst, CL}",
Evan Cheng071a2792007-09-11 19:55:27 +00002223 [(store (srl (loadi32 addr:$dst), CL), addr:$dst)]>;
2224 }
Evan Cheng64d80e32007-07-19 01:14:50 +00002225 def SHR8mi : Ii8<0xC0, MRM5m, (outs), (ins i8mem :$dst, i8imm:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002226 "shr{b}\t{$src, $dst|$dst, $src}",
Evan Cheng85dd8892005-12-13 07:24:22 +00002227 [(store (srl (loadi8 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00002228 def SHR16mi : Ii8<0xC1, MRM5m, (outs), (ins i16mem:$dst, i8imm:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002229 "shr{w}\t{$src, $dst|$dst, $src}",
Evan Cheng85dd8892005-12-13 07:24:22 +00002230 [(store (srl (loadi16 addr:$dst), (i8 imm:$src)), addr:$dst)]>,
2231 OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00002232 def SHR32mi : Ii8<0xC1, MRM5m, (outs), (ins i32mem:$dst, i8imm:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002233 "shr{l}\t{$src, $dst|$dst, $src}",
Evan Cheng85dd8892005-12-13 07:24:22 +00002234 [(store (srl (loadi32 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
Evan Cheng09c54572006-06-29 00:36:51 +00002235
2236 // Shift by 1
Evan Cheng64d80e32007-07-19 01:14:50 +00002237 def SHR8m1 : I<0xD0, MRM5m, (outs), (ins i8mem :$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002238 "shr{b}\t$dst",
Evan Cheng09c54572006-06-29 00:36:51 +00002239 [(store (srl (loadi8 addr:$dst), (i8 1)), addr:$dst)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00002240 def SHR16m1 : I<0xD1, MRM5m, (outs), (ins i16mem:$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002241 "shr{w}\t$dst",
Evan Cheng09c54572006-06-29 00:36:51 +00002242 [(store (srl (loadi16 addr:$dst), (i8 1)), addr:$dst)]>,OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00002243 def SHR32m1 : I<0xD1, MRM5m, (outs), (ins i32mem:$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002244 "shr{l}\t$dst",
Evan Cheng09c54572006-06-29 00:36:51 +00002245 [(store (srl (loadi32 addr:$dst), (i8 1)), addr:$dst)]>;
Chris Lattner57a02302004-08-11 04:31:00 +00002246}
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00002247
Evan Cheng071a2792007-09-11 19:55:27 +00002248let Uses = [CL] in {
Evan Cheng64d80e32007-07-19 01:14:50 +00002249def SAR8rCL : I<0xD2, MRM7r, (outs GR8 :$dst), (ins GR8 :$src),
Eli Friedmanaace4b12009-06-19 04:48:38 +00002250 "sar{b}\t{%cl, $dst|$dst, CL}",
Evan Cheng071a2792007-09-11 19:55:27 +00002251 [(set GR8:$dst, (sra GR8:$src, CL))]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00002252def SAR16rCL : I<0xD3, MRM7r, (outs GR16:$dst), (ins GR16:$src),
Eli Friedmanaace4b12009-06-19 04:48:38 +00002253 "sar{w}\t{%cl, $dst|$dst, CL}",
Evan Cheng071a2792007-09-11 19:55:27 +00002254 [(set GR16:$dst, (sra GR16:$src, CL))]>, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00002255def SAR32rCL : I<0xD3, MRM7r, (outs GR32:$dst), (ins GR32:$src),
Eli Friedmanaace4b12009-06-19 04:48:38 +00002256 "sar{l}\t{%cl, $dst|$dst, CL}",
Evan Cheng071a2792007-09-11 19:55:27 +00002257 [(set GR32:$dst, (sra GR32:$src, CL))]>;
2258}
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00002259
Evan Cheng64d80e32007-07-19 01:14:50 +00002260def SAR8ri : Ii8<0xC0, MRM7r, (outs GR8 :$dst), (ins GR8 :$src1, i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002261 "sar{b}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00002262 [(set GR8:$dst, (sra GR8:$src1, (i8 imm:$src2)))]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00002263def SAR16ri : Ii8<0xC1, MRM7r, (outs GR16:$dst), (ins GR16:$src1, i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002264 "sar{w}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00002265 [(set GR16:$dst, (sra GR16:$src1, (i8 imm:$src2)))]>,
Chris Lattner3d36a9f2005-12-05 02:40:25 +00002266 OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00002267def SAR32ri : Ii8<0xC1, MRM7r, (outs GR32:$dst), (ins GR32:$src1, i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002268 "sar{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00002269 [(set GR32:$dst, (sra GR32:$src1, (i8 imm:$src2)))]>;
Evan Cheng09c54572006-06-29 00:36:51 +00002270
2271// Shift by 1
Evan Cheng64d80e32007-07-19 01:14:50 +00002272def SAR8r1 : I<0xD0, MRM7r, (outs GR8 :$dst), (ins GR8 :$src1),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002273 "sar{b}\t$dst",
Evan Cheng09c54572006-06-29 00:36:51 +00002274 [(set GR8:$dst, (sra GR8:$src1, (i8 1)))]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00002275def SAR16r1 : I<0xD1, MRM7r, (outs GR16:$dst), (ins GR16:$src1),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002276 "sar{w}\t$dst",
Evan Cheng09c54572006-06-29 00:36:51 +00002277 [(set GR16:$dst, (sra GR16:$src1, (i8 1)))]>, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00002278def SAR32r1 : I<0xD1, MRM7r, (outs GR32:$dst), (ins GR32:$src1),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002279 "sar{l}\t$dst",
Evan Cheng09c54572006-06-29 00:36:51 +00002280 [(set GR32:$dst, (sra GR32:$src1, (i8 1)))]>;
2281
Chris Lattnerf29ed092004-08-11 05:07:25 +00002282let isTwoAddress = 0 in {
Evan Cheng071a2792007-09-11 19:55:27 +00002283 let Uses = [CL] in {
Evan Cheng64d80e32007-07-19 01:14:50 +00002284 def SAR8mCL : I<0xD2, MRM7m, (outs), (ins i8mem :$dst),
Eli Friedmanaace4b12009-06-19 04:48:38 +00002285 "sar{b}\t{%cl, $dst|$dst, CL}",
Evan Cheng071a2792007-09-11 19:55:27 +00002286 [(store (sra (loadi8 addr:$dst), CL), addr:$dst)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00002287 def SAR16mCL : I<0xD3, MRM7m, (outs), (ins i16mem:$dst),
Eli Friedmanaace4b12009-06-19 04:48:38 +00002288 "sar{w}\t{%cl, $dst|$dst, CL}",
Evan Cheng071a2792007-09-11 19:55:27 +00002289 [(store (sra (loadi16 addr:$dst), CL), addr:$dst)]>, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00002290 def SAR32mCL : I<0xD3, MRM7m, (outs), (ins i32mem:$dst),
Eli Friedmanaace4b12009-06-19 04:48:38 +00002291 "sar{l}\t{%cl, $dst|$dst, CL}",
Evan Cheng071a2792007-09-11 19:55:27 +00002292 [(store (sra (loadi32 addr:$dst), CL), addr:$dst)]>;
2293 }
Evan Cheng64d80e32007-07-19 01:14:50 +00002294 def SAR8mi : Ii8<0xC0, MRM7m, (outs), (ins i8mem :$dst, i8imm:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002295 "sar{b}\t{$src, $dst|$dst, $src}",
Evan Cheng85dd8892005-12-13 07:24:22 +00002296 [(store (sra (loadi8 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00002297 def SAR16mi : Ii8<0xC1, MRM7m, (outs), (ins i16mem:$dst, i8imm:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002298 "sar{w}\t{$src, $dst|$dst, $src}",
Evan Cheng85dd8892005-12-13 07:24:22 +00002299 [(store (sra (loadi16 addr:$dst), (i8 imm:$src)), addr:$dst)]>,
2300 OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00002301 def SAR32mi : Ii8<0xC1, MRM7m, (outs), (ins i32mem:$dst, i8imm:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002302 "sar{l}\t{$src, $dst|$dst, $src}",
Evan Cheng85dd8892005-12-13 07:24:22 +00002303 [(store (sra (loadi32 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
Evan Cheng09c54572006-06-29 00:36:51 +00002304
2305 // Shift by 1
Evan Cheng64d80e32007-07-19 01:14:50 +00002306 def SAR8m1 : I<0xD0, MRM7m, (outs), (ins i8mem :$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002307 "sar{b}\t$dst",
Evan Cheng09c54572006-06-29 00:36:51 +00002308 [(store (sra (loadi8 addr:$dst), (i8 1)), addr:$dst)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00002309 def SAR16m1 : I<0xD1, MRM7m, (outs), (ins i16mem:$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002310 "sar{w}\t$dst",
Evan Cheng09c54572006-06-29 00:36:51 +00002311 [(store (sra (loadi16 addr:$dst), (i8 1)), addr:$dst)]>,
2312 OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00002313 def SAR32m1 : I<0xD1, MRM7m, (outs), (ins i32mem:$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002314 "sar{l}\t$dst",
Evan Cheng09c54572006-06-29 00:36:51 +00002315 [(store (sra (loadi32 addr:$dst), (i8 1)), addr:$dst)]>;
Chris Lattnerf29ed092004-08-11 05:07:25 +00002316}
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00002317
Chris Lattner40ff6332005-01-19 07:50:03 +00002318// Rotate instructions
Sean Callanana2dc2822009-09-18 19:35:23 +00002319
2320def RCL8r1 : I<0xD0, MRM2r, (outs GR8:$dst), (ins GR8:$src),
2321 "rcl{b}\t{1, $dst|$dst, 1}", []>;
2322def RCL8m1 : I<0xD0, MRM2m, (outs i8mem:$dst), (ins i8mem:$src),
2323 "rcl{b}\t{1, $dst|$dst, 1}", []>;
2324let Uses = [CL] in {
2325def RCL8rCL : I<0xD2, MRM2r, (outs GR8:$dst), (ins GR8:$src),
2326 "rcl{b}\t{%cl, $dst|$dst, CL}", []>;
2327def RCL8mCL : I<0xD2, MRM2m, (outs i8mem:$dst), (ins i8mem:$src),
2328 "rcl{b}\t{%cl, $dst|$dst, CL}", []>;
2329}
2330def RCL8ri : Ii8<0xC0, MRM2r, (outs GR8:$dst), (ins GR8:$src, i8imm:$cnt),
2331 "rcl{b}\t{$cnt, $dst|$dst, $cnt}", []>;
2332def RCL8mi : Ii8<0xC0, MRM2m, (outs i8mem:$dst), (ins i8mem:$src, i8imm:$cnt),
2333 "rcl{b}\t{$cnt, $dst|$dst, $cnt}", []>;
2334
2335def RCL16r1 : I<0xD1, MRM2r, (outs GR16:$dst), (ins GR16:$src),
2336 "rcl{w}\t{1, $dst|$dst, 1}", []>, OpSize;
2337def RCL16m1 : I<0xD1, MRM2m, (outs i16mem:$dst), (ins i16mem:$src),
2338 "rcl{w}\t{1, $dst|$dst, 1}", []>, OpSize;
2339let Uses = [CL] in {
2340def RCL16rCL : I<0xD3, MRM2r, (outs GR16:$dst), (ins GR16:$src),
2341 "rcl{w}\t{%cl, $dst|$dst, CL}", []>, OpSize;
2342def RCL16mCL : I<0xD3, MRM2m, (outs i16mem:$dst), (ins i16mem:$src),
2343 "rcl{w}\t{%cl, $dst|$dst, CL}", []>, OpSize;
2344}
2345def RCL16ri : Ii8<0xC1, MRM2r, (outs GR16:$dst), (ins GR16:$src, i8imm:$cnt),
2346 "rcl{w}\t{$cnt, $dst|$dst, $cnt}", []>, OpSize;
Sean Callanan108934c2009-12-18 00:01:26 +00002347def RCL16mi : Ii8<0xC1, MRM2m, (outs i16mem:$dst),
2348 (ins i16mem:$src, i8imm:$cnt),
Sean Callanana2dc2822009-09-18 19:35:23 +00002349 "rcl{w}\t{$cnt, $dst|$dst, $cnt}", []>, OpSize;
2350
2351def RCL32r1 : I<0xD1, MRM2r, (outs GR32:$dst), (ins GR32:$src),
2352 "rcl{l}\t{1, $dst|$dst, 1}", []>;
2353def RCL32m1 : I<0xD1, MRM2m, (outs i32mem:$dst), (ins i32mem:$src),
2354 "rcl{l}\t{1, $dst|$dst, 1}", []>;
2355let Uses = [CL] in {
2356def RCL32rCL : I<0xD3, MRM2r, (outs GR32:$dst), (ins GR32:$src),
2357 "rcl{l}\t{%cl, $dst|$dst, CL}", []>;
2358def RCL32mCL : I<0xD3, MRM2m, (outs i32mem:$dst), (ins i32mem:$src),
2359 "rcl{l}\t{%cl, $dst|$dst, CL}", []>;
2360}
2361def RCL32ri : Ii8<0xC1, MRM2r, (outs GR32:$dst), (ins GR32:$src, i8imm:$cnt),
2362 "rcl{l}\t{$cnt, $dst|$dst, $cnt}", []>;
Sean Callanan108934c2009-12-18 00:01:26 +00002363def RCL32mi : Ii8<0xC1, MRM2m, (outs i32mem:$dst),
2364 (ins i32mem:$src, i8imm:$cnt),
Sean Callanana2dc2822009-09-18 19:35:23 +00002365 "rcl{l}\t{$cnt, $dst|$dst, $cnt}", []>;
2366
2367def RCR8r1 : I<0xD0, MRM3r, (outs GR8:$dst), (ins GR8:$src),
2368 "rcr{b}\t{1, $dst|$dst, 1}", []>;
2369def RCR8m1 : I<0xD0, MRM3m, (outs i8mem:$dst), (ins i8mem:$src),
2370 "rcr{b}\t{1, $dst|$dst, 1}", []>;
2371let Uses = [CL] in {
2372def RCR8rCL : I<0xD2, MRM3r, (outs GR8:$dst), (ins GR8:$src),
2373 "rcr{b}\t{%cl, $dst|$dst, CL}", []>;
2374def RCR8mCL : I<0xD2, MRM3m, (outs i8mem:$dst), (ins i8mem:$src),
2375 "rcr{b}\t{%cl, $dst|$dst, CL}", []>;
2376}
2377def RCR8ri : Ii8<0xC0, MRM3r, (outs GR8:$dst), (ins GR8:$src, i8imm:$cnt),
2378 "rcr{b}\t{$cnt, $dst|$dst, $cnt}", []>;
2379def RCR8mi : Ii8<0xC0, MRM3m, (outs i8mem:$dst), (ins i8mem:$src, i8imm:$cnt),
2380 "rcr{b}\t{$cnt, $dst|$dst, $cnt}", []>;
2381
2382def RCR16r1 : I<0xD1, MRM3r, (outs GR16:$dst), (ins GR16:$src),
2383 "rcr{w}\t{1, $dst|$dst, 1}", []>, OpSize;
2384def RCR16m1 : I<0xD1, MRM3m, (outs i16mem:$dst), (ins i16mem:$src),
2385 "rcr{w}\t{1, $dst|$dst, 1}", []>, OpSize;
2386let Uses = [CL] in {
2387def RCR16rCL : I<0xD3, MRM3r, (outs GR16:$dst), (ins GR16:$src),
2388 "rcr{w}\t{%cl, $dst|$dst, CL}", []>, OpSize;
2389def RCR16mCL : I<0xD3, MRM3m, (outs i16mem:$dst), (ins i16mem:$src),
2390 "rcr{w}\t{%cl, $dst|$dst, CL}", []>, OpSize;
2391}
2392def RCR16ri : Ii8<0xC1, MRM3r, (outs GR16:$dst), (ins GR16:$src, i8imm:$cnt),
2393 "rcr{w}\t{$cnt, $dst|$dst, $cnt}", []>, OpSize;
Sean Callanan108934c2009-12-18 00:01:26 +00002394def RCR16mi : Ii8<0xC1, MRM3m, (outs i16mem:$dst),
2395 (ins i16mem:$src, i8imm:$cnt),
Sean Callanana2dc2822009-09-18 19:35:23 +00002396 "rcr{w}\t{$cnt, $dst|$dst, $cnt}", []>, OpSize;
2397
2398def RCR32r1 : I<0xD1, MRM3r, (outs GR32:$dst), (ins GR32:$src),
2399 "rcr{l}\t{1, $dst|$dst, 1}", []>;
2400def RCR32m1 : I<0xD1, MRM3m, (outs i32mem:$dst), (ins i32mem:$src),
2401 "rcr{l}\t{1, $dst|$dst, 1}", []>;
2402let Uses = [CL] in {
2403def RCR32rCL : I<0xD3, MRM3r, (outs GR32:$dst), (ins GR32:$src),
2404 "rcr{l}\t{%cl, $dst|$dst, CL}", []>;
2405def RCR32mCL : I<0xD3, MRM3m, (outs i32mem:$dst), (ins i32mem:$src),
2406 "rcr{l}\t{%cl, $dst|$dst, CL}", []>;
2407}
2408def RCR32ri : Ii8<0xC1, MRM3r, (outs GR32:$dst), (ins GR32:$src, i8imm:$cnt),
2409 "rcr{l}\t{$cnt, $dst|$dst, $cnt}", []>;
Sean Callanan108934c2009-12-18 00:01:26 +00002410def RCR32mi : Ii8<0xC1, MRM3m, (outs i32mem:$dst),
2411 (ins i32mem:$src, i8imm:$cnt),
Sean Callanana2dc2822009-09-18 19:35:23 +00002412 "rcr{l}\t{$cnt, $dst|$dst, $cnt}", []>;
2413
Chris Lattner40ff6332005-01-19 07:50:03 +00002414// FIXME: provide shorter instructions when imm8 == 1
Evan Cheng071a2792007-09-11 19:55:27 +00002415let Uses = [CL] in {
Evan Cheng64d80e32007-07-19 01:14:50 +00002416def ROL8rCL : I<0xD2, MRM0r, (outs GR8 :$dst), (ins GR8 :$src),
Eli Friedmanaace4b12009-06-19 04:48:38 +00002417 "rol{b}\t{%cl, $dst|$dst, CL}",
Evan Cheng071a2792007-09-11 19:55:27 +00002418 [(set GR8:$dst, (rotl GR8:$src, CL))]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00002419def ROL16rCL : I<0xD3, MRM0r, (outs GR16:$dst), (ins GR16:$src),
Eli Friedmanaace4b12009-06-19 04:48:38 +00002420 "rol{w}\t{%cl, $dst|$dst, CL}",
Evan Cheng071a2792007-09-11 19:55:27 +00002421 [(set GR16:$dst, (rotl GR16:$src, CL))]>, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00002422def ROL32rCL : I<0xD3, MRM0r, (outs GR32:$dst), (ins GR32:$src),
Eli Friedmanaace4b12009-06-19 04:48:38 +00002423 "rol{l}\t{%cl, $dst|$dst, CL}",
Evan Cheng071a2792007-09-11 19:55:27 +00002424 [(set GR32:$dst, (rotl GR32:$src, CL))]>;
2425}
Chris Lattner40ff6332005-01-19 07:50:03 +00002426
Evan Cheng64d80e32007-07-19 01:14:50 +00002427def ROL8ri : Ii8<0xC0, MRM0r, (outs GR8 :$dst), (ins GR8 :$src1, i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002428 "rol{b}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00002429 [(set GR8:$dst, (rotl GR8:$src1, (i8 imm:$src2)))]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00002430def ROL16ri : Ii8<0xC1, MRM0r, (outs GR16:$dst), (ins GR16:$src1, i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002431 "rol{w}\t{$src2, $dst|$dst, $src2}",
Sean Callanan108934c2009-12-18 00:01:26 +00002432 [(set GR16:$dst, (rotl GR16:$src1, (i8 imm:$src2)))]>,
2433 OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00002434def ROL32ri : Ii8<0xC1, MRM0r, (outs GR32:$dst), (ins GR32:$src1, i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002435 "rol{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00002436 [(set GR32:$dst, (rotl GR32:$src1, (i8 imm:$src2)))]>;
Chris Lattner40ff6332005-01-19 07:50:03 +00002437
Evan Cheng09c54572006-06-29 00:36:51 +00002438// Rotate by 1
Evan Cheng64d80e32007-07-19 01:14:50 +00002439def ROL8r1 : I<0xD0, MRM0r, (outs GR8 :$dst), (ins GR8 :$src1),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002440 "rol{b}\t$dst",
Evan Cheng09c54572006-06-29 00:36:51 +00002441 [(set GR8:$dst, (rotl GR8:$src1, (i8 1)))]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00002442def ROL16r1 : I<0xD1, MRM0r, (outs GR16:$dst), (ins GR16:$src1),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002443 "rol{w}\t$dst",
Evan Cheng09c54572006-06-29 00:36:51 +00002444 [(set GR16:$dst, (rotl GR16:$src1, (i8 1)))]>, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00002445def ROL32r1 : I<0xD1, MRM0r, (outs GR32:$dst), (ins GR32:$src1),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002446 "rol{l}\t$dst",
Evan Cheng09c54572006-06-29 00:36:51 +00002447 [(set GR32:$dst, (rotl GR32:$src1, (i8 1)))]>;
2448
Chris Lattner40ff6332005-01-19 07:50:03 +00002449let isTwoAddress = 0 in {
Evan Cheng071a2792007-09-11 19:55:27 +00002450 let Uses = [CL] in {
Evan Cheng64d80e32007-07-19 01:14:50 +00002451 def ROL8mCL : I<0xD2, MRM0m, (outs), (ins i8mem :$dst),
Eli Friedmanaace4b12009-06-19 04:48:38 +00002452 "rol{b}\t{%cl, $dst|$dst, CL}",
Evan Cheng071a2792007-09-11 19:55:27 +00002453 [(store (rotl (loadi8 addr:$dst), CL), addr:$dst)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00002454 def ROL16mCL : I<0xD3, MRM0m, (outs), (ins i16mem:$dst),
Eli Friedmanaace4b12009-06-19 04:48:38 +00002455 "rol{w}\t{%cl, $dst|$dst, CL}",
Evan Cheng071a2792007-09-11 19:55:27 +00002456 [(store (rotl (loadi16 addr:$dst), CL), addr:$dst)]>, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00002457 def ROL32mCL : I<0xD3, MRM0m, (outs), (ins i32mem:$dst),
Eli Friedmanaace4b12009-06-19 04:48:38 +00002458 "rol{l}\t{%cl, $dst|$dst, CL}",
Evan Cheng071a2792007-09-11 19:55:27 +00002459 [(store (rotl (loadi32 addr:$dst), CL), addr:$dst)]>;
2460 }
Evan Cheng64d80e32007-07-19 01:14:50 +00002461 def ROL8mi : Ii8<0xC0, MRM0m, (outs), (ins i8mem :$dst, i8imm:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002462 "rol{b}\t{$src, $dst|$dst, $src}",
Evan Chengeb422a72006-01-11 23:20:05 +00002463 [(store (rotl (loadi8 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00002464 def ROL16mi : Ii8<0xC1, MRM0m, (outs), (ins i16mem:$dst, i8imm:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002465 "rol{w}\t{$src, $dst|$dst, $src}",
Evan Chengeb422a72006-01-11 23:20:05 +00002466 [(store (rotl (loadi16 addr:$dst), (i8 imm:$src)), addr:$dst)]>,
2467 OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00002468 def ROL32mi : Ii8<0xC1, MRM0m, (outs), (ins i32mem:$dst, i8imm:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002469 "rol{l}\t{$src, $dst|$dst, $src}",
Evan Chengeb422a72006-01-11 23:20:05 +00002470 [(store (rotl (loadi32 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
Evan Cheng09c54572006-06-29 00:36:51 +00002471
2472 // Rotate by 1
Evan Cheng64d80e32007-07-19 01:14:50 +00002473 def ROL8m1 : I<0xD0, MRM0m, (outs), (ins i8mem :$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002474 "rol{b}\t$dst",
Evan Cheng09c54572006-06-29 00:36:51 +00002475 [(store (rotl (loadi8 addr:$dst), (i8 1)), addr:$dst)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00002476 def ROL16m1 : I<0xD1, MRM0m, (outs), (ins i16mem:$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002477 "rol{w}\t$dst",
Evan Cheng09c54572006-06-29 00:36:51 +00002478 [(store (rotl (loadi16 addr:$dst), (i8 1)), addr:$dst)]>,
2479 OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00002480 def ROL32m1 : I<0xD1, MRM0m, (outs), (ins i32mem:$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002481 "rol{l}\t$dst",
Evan Cheng09c54572006-06-29 00:36:51 +00002482 [(store (rotl (loadi32 addr:$dst), (i8 1)), addr:$dst)]>;
Chris Lattner40ff6332005-01-19 07:50:03 +00002483}
2484
Evan Cheng071a2792007-09-11 19:55:27 +00002485let Uses = [CL] in {
Evan Cheng64d80e32007-07-19 01:14:50 +00002486def ROR8rCL : I<0xD2, MRM1r, (outs GR8 :$dst), (ins GR8 :$src),
Eli Friedmanaace4b12009-06-19 04:48:38 +00002487 "ror{b}\t{%cl, $dst|$dst, CL}",
Evan Cheng071a2792007-09-11 19:55:27 +00002488 [(set GR8:$dst, (rotr GR8:$src, CL))]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00002489def ROR16rCL : I<0xD3, MRM1r, (outs GR16:$dst), (ins GR16:$src),
Eli Friedmanaace4b12009-06-19 04:48:38 +00002490 "ror{w}\t{%cl, $dst|$dst, CL}",
Evan Cheng071a2792007-09-11 19:55:27 +00002491 [(set GR16:$dst, (rotr GR16:$src, CL))]>, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00002492def ROR32rCL : I<0xD3, MRM1r, (outs GR32:$dst), (ins GR32:$src),
Eli Friedmanaace4b12009-06-19 04:48:38 +00002493 "ror{l}\t{%cl, $dst|$dst, CL}",
Evan Cheng071a2792007-09-11 19:55:27 +00002494 [(set GR32:$dst, (rotr GR32:$src, CL))]>;
2495}
Chris Lattner40ff6332005-01-19 07:50:03 +00002496
Evan Cheng64d80e32007-07-19 01:14:50 +00002497def ROR8ri : Ii8<0xC0, MRM1r, (outs GR8 :$dst), (ins GR8 :$src1, i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002498 "ror{b}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00002499 [(set GR8:$dst, (rotr GR8:$src1, (i8 imm:$src2)))]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00002500def ROR16ri : Ii8<0xC1, MRM1r, (outs GR16:$dst), (ins GR16:$src1, i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002501 "ror{w}\t{$src2, $dst|$dst, $src2}",
Sean Callanan108934c2009-12-18 00:01:26 +00002502 [(set GR16:$dst, (rotr GR16:$src1, (i8 imm:$src2)))]>,
2503 OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00002504def ROR32ri : Ii8<0xC1, MRM1r, (outs GR32:$dst), (ins GR32:$src1, i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002505 "ror{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00002506 [(set GR32:$dst, (rotr GR32:$src1, (i8 imm:$src2)))]>;
Evan Cheng09c54572006-06-29 00:36:51 +00002507
2508// Rotate by 1
Evan Cheng64d80e32007-07-19 01:14:50 +00002509def ROR8r1 : I<0xD0, MRM1r, (outs GR8 :$dst), (ins GR8 :$src1),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002510 "ror{b}\t$dst",
Evan Cheng09c54572006-06-29 00:36:51 +00002511 [(set GR8:$dst, (rotr GR8:$src1, (i8 1)))]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00002512def ROR16r1 : I<0xD1, MRM1r, (outs GR16:$dst), (ins GR16:$src1),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002513 "ror{w}\t$dst",
Evan Cheng09c54572006-06-29 00:36:51 +00002514 [(set GR16:$dst, (rotr GR16:$src1, (i8 1)))]>, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00002515def ROR32r1 : I<0xD1, MRM1r, (outs GR32:$dst), (ins GR32:$src1),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002516 "ror{l}\t$dst",
Evan Cheng09c54572006-06-29 00:36:51 +00002517 [(set GR32:$dst, (rotr GR32:$src1, (i8 1)))]>;
2518
Chris Lattner40ff6332005-01-19 07:50:03 +00002519let isTwoAddress = 0 in {
Evan Cheng071a2792007-09-11 19:55:27 +00002520 let Uses = [CL] in {
Evan Cheng64d80e32007-07-19 01:14:50 +00002521 def ROR8mCL : I<0xD2, MRM1m, (outs), (ins i8mem :$dst),
Eli Friedmanaace4b12009-06-19 04:48:38 +00002522 "ror{b}\t{%cl, $dst|$dst, CL}",
Evan Cheng071a2792007-09-11 19:55:27 +00002523 [(store (rotr (loadi8 addr:$dst), CL), addr:$dst)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00002524 def ROR16mCL : I<0xD3, MRM1m, (outs), (ins i16mem:$dst),
Eli Friedmanaace4b12009-06-19 04:48:38 +00002525 "ror{w}\t{%cl, $dst|$dst, CL}",
Evan Cheng071a2792007-09-11 19:55:27 +00002526 [(store (rotr (loadi16 addr:$dst), CL), addr:$dst)]>, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00002527 def ROR32mCL : I<0xD3, MRM1m, (outs), (ins i32mem:$dst),
Eli Friedmanaace4b12009-06-19 04:48:38 +00002528 "ror{l}\t{%cl, $dst|$dst, CL}",
Evan Cheng071a2792007-09-11 19:55:27 +00002529 [(store (rotr (loadi32 addr:$dst), CL), addr:$dst)]>;
2530 }
Evan Cheng64d80e32007-07-19 01:14:50 +00002531 def ROR8mi : Ii8<0xC0, MRM1m, (outs), (ins i8mem :$dst, i8imm:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002532 "ror{b}\t{$src, $dst|$dst, $src}",
Evan Chengeb422a72006-01-11 23:20:05 +00002533 [(store (rotr (loadi8 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00002534 def ROR16mi : Ii8<0xC1, MRM1m, (outs), (ins i16mem:$dst, i8imm:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002535 "ror{w}\t{$src, $dst|$dst, $src}",
Evan Chengeb422a72006-01-11 23:20:05 +00002536 [(store (rotr (loadi16 addr:$dst), (i8 imm:$src)), addr:$dst)]>,
2537 OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00002538 def ROR32mi : Ii8<0xC1, MRM1m, (outs), (ins i32mem:$dst, i8imm:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002539 "ror{l}\t{$src, $dst|$dst, $src}",
Evan Chengeb422a72006-01-11 23:20:05 +00002540 [(store (rotr (loadi32 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
Evan Cheng09c54572006-06-29 00:36:51 +00002541
2542 // Rotate by 1
Evan Cheng64d80e32007-07-19 01:14:50 +00002543 def ROR8m1 : I<0xD0, MRM1m, (outs), (ins i8mem :$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002544 "ror{b}\t$dst",
Evan Cheng09c54572006-06-29 00:36:51 +00002545 [(store (rotr (loadi8 addr:$dst), (i8 1)), addr:$dst)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00002546 def ROR16m1 : I<0xD1, MRM1m, (outs), (ins i16mem:$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002547 "ror{w}\t$dst",
Evan Cheng09c54572006-06-29 00:36:51 +00002548 [(store (rotr (loadi16 addr:$dst), (i8 1)), addr:$dst)]>,
2549 OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00002550 def ROR32m1 : I<0xD1, MRM1m, (outs), (ins i32mem:$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002551 "ror{l}\t$dst",
Evan Cheng09c54572006-06-29 00:36:51 +00002552 [(store (rotr (loadi32 addr:$dst), (i8 1)), addr:$dst)]>;
Chris Lattner40ff6332005-01-19 07:50:03 +00002553}
2554
2555
2556
2557// Double shift instructions (generalizations of rotate)
Evan Cheng071a2792007-09-11 19:55:27 +00002558let Uses = [CL] in {
Sean Callanan108934c2009-12-18 00:01:26 +00002559def SHLD32rrCL : I<0xA5, MRMDestReg, (outs GR32:$dst),
2560 (ins GR32:$src1, GR32:$src2),
Eli Friedmanaace4b12009-06-19 04:48:38 +00002561 "shld{l}\t{%cl, $src2, $dst|$dst, $src2, CL}",
Evan Cheng071a2792007-09-11 19:55:27 +00002562 [(set GR32:$dst, (X86shld GR32:$src1, GR32:$src2, CL))]>, TB;
Sean Callanan108934c2009-12-18 00:01:26 +00002563def SHRD32rrCL : I<0xAD, MRMDestReg, (outs GR32:$dst),
2564 (ins GR32:$src1, GR32:$src2),
Eli Friedmanaace4b12009-06-19 04:48:38 +00002565 "shrd{l}\t{%cl, $src2, $dst|$dst, $src2, CL}",
Evan Cheng071a2792007-09-11 19:55:27 +00002566 [(set GR32:$dst, (X86shrd GR32:$src1, GR32:$src2, CL))]>, TB;
Sean Callanan108934c2009-12-18 00:01:26 +00002567def SHLD16rrCL : I<0xA5, MRMDestReg, (outs GR16:$dst),
2568 (ins GR16:$src1, GR16:$src2),
Eli Friedmanaace4b12009-06-19 04:48:38 +00002569 "shld{w}\t{%cl, $src2, $dst|$dst, $src2, CL}",
Evan Cheng069287d2006-05-16 07:21:53 +00002570 [(set GR16:$dst, (X86shld GR16:$src1, GR16:$src2, CL))]>,
Evan Cheng071a2792007-09-11 19:55:27 +00002571 TB, OpSize;
Sean Callanan108934c2009-12-18 00:01:26 +00002572def SHRD16rrCL : I<0xAD, MRMDestReg, (outs GR16:$dst),
2573 (ins GR16:$src1, GR16:$src2),
Eli Friedmanaace4b12009-06-19 04:48:38 +00002574 "shrd{w}\t{%cl, $src2, $dst|$dst, $src2, CL}",
Evan Cheng069287d2006-05-16 07:21:53 +00002575 [(set GR16:$dst, (X86shrd GR16:$src1, GR16:$src2, CL))]>,
Evan Cheng071a2792007-09-11 19:55:27 +00002576 TB, OpSize;
2577}
Chris Lattner41e431b2005-01-19 07:11:01 +00002578
2579let isCommutable = 1 in { // These instructions commute to each other.
Chris Lattner3a173df2004-10-03 20:35:00 +00002580def SHLD32rri8 : Ii8<0xA4, 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 "shld{l}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Evan Cheng069287d2006-05-16 07:21:53 +00002584 [(set GR32:$dst, (X86shld GR32:$src1, GR32:$src2,
Evan Chenge3413162006-01-09 18:33:28 +00002585 (i8 imm:$src3)))]>,
2586 TB;
Chris Lattner3a173df2004-10-03 20:35:00 +00002587def SHRD32rri8 : Ii8<0xAC, MRMDestReg,
Sean Callanan108934c2009-12-18 00:01:26 +00002588 (outs GR32:$dst),
2589 (ins GR32:$src1, GR32:$src2, i8imm:$src3),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002590 "shrd{l}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Evan Cheng069287d2006-05-16 07:21:53 +00002591 [(set GR32:$dst, (X86shrd GR32:$src1, GR32:$src2,
Evan Chenge3413162006-01-09 18:33:28 +00002592 (i8 imm:$src3)))]>,
2593 TB;
Chris Lattner0df53d22005-01-19 07:31:24 +00002594def SHLD16rri8 : Ii8<0xA4, 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 "shld{w}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Evan Cheng069287d2006-05-16 07:21:53 +00002598 [(set GR16:$dst, (X86shld 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;
2601def SHRD16rri8 : Ii8<0xAC, MRMDestReg,
Sean Callanan108934c2009-12-18 00:01:26 +00002602 (outs GR16:$dst),
2603 (ins GR16:$src1, GR16:$src2, i8imm:$src3),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002604 "shrd{w}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Evan Cheng069287d2006-05-16 07:21:53 +00002605 [(set GR16:$dst, (X86shrd GR16:$src1, GR16:$src2,
Evan Chenge3413162006-01-09 18:33:28 +00002606 (i8 imm:$src3)))]>,
Chris Lattner0df53d22005-01-19 07:31:24 +00002607 TB, OpSize;
Chris Lattner41e431b2005-01-19 07:11:01 +00002608}
Chris Lattner0e967d42004-08-01 08:13:11 +00002609
Chris Lattner57a02302004-08-11 04:31:00 +00002610let isTwoAddress = 0 in {
Evan Cheng071a2792007-09-11 19:55:27 +00002611 let Uses = [CL] in {
Evan Cheng64d80e32007-07-19 01:14:50 +00002612 def SHLD32mrCL : I<0xA5, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
Eli Friedmanaace4b12009-06-19 04:48:38 +00002613 "shld{l}\t{%cl, $src2, $dst|$dst, $src2, CL}",
Evan Cheng069287d2006-05-16 07:21:53 +00002614 [(store (X86shld (loadi32 addr:$dst), GR32:$src2, CL),
Evan Cheng071a2792007-09-11 19:55:27 +00002615 addr:$dst)]>, TB;
Evan Cheng64d80e32007-07-19 01:14:50 +00002616 def SHRD32mrCL : I<0xAD, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
Eli Friedmanaace4b12009-06-19 04:48:38 +00002617 "shrd{l}\t{%cl, $src2, $dst|$dst, $src2, CL}",
Evan Cheng069287d2006-05-16 07:21:53 +00002618 [(store (X86shrd (loadi32 addr:$dst), GR32:$src2, CL),
Evan Cheng071a2792007-09-11 19:55:27 +00002619 addr:$dst)]>, TB;
2620 }
Chris Lattner3a173df2004-10-03 20:35:00 +00002621 def SHLD32mri8 : Ii8<0xA4, MRMDestMem,
Evan Cheng64d80e32007-07-19 01:14:50 +00002622 (outs), (ins i32mem:$dst, GR32:$src2, i8imm:$src3),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002623 "shld{l}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Evan Cheng069287d2006-05-16 07:21:53 +00002624 [(store (X86shld (loadi32 addr:$dst), GR32:$src2,
Evan Chenge3413162006-01-09 18:33:28 +00002625 (i8 imm:$src3)), addr:$dst)]>,
Chris Lattnerf124d5e2005-11-18 01:04:42 +00002626 TB;
Chris Lattner3a173df2004-10-03 20:35:00 +00002627 def SHRD32mri8 : Ii8<0xAC, MRMDestMem,
Evan Cheng64d80e32007-07-19 01:14:50 +00002628 (outs), (ins i32mem:$dst, GR32:$src2, i8imm:$src3),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002629 "shrd{l}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Evan Cheng069287d2006-05-16 07:21:53 +00002630 [(store (X86shrd (loadi32 addr:$dst), GR32:$src2,
Evan Chenge3413162006-01-09 18:33:28 +00002631 (i8 imm:$src3)), addr:$dst)]>,
Chris Lattnerf124d5e2005-11-18 01:04:42 +00002632 TB;
Chris Lattner0df53d22005-01-19 07:31:24 +00002633
Evan Cheng071a2792007-09-11 19:55:27 +00002634 let Uses = [CL] in {
Evan Cheng64d80e32007-07-19 01:14:50 +00002635 def SHLD16mrCL : I<0xA5, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
Eli Friedmanaace4b12009-06-19 04:48:38 +00002636 "shld{w}\t{%cl, $src2, $dst|$dst, $src2, CL}",
Evan Cheng069287d2006-05-16 07:21:53 +00002637 [(store (X86shld (loadi16 addr:$dst), GR16:$src2, CL),
Evan Cheng071a2792007-09-11 19:55:27 +00002638 addr:$dst)]>, TB, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00002639 def SHRD16mrCL : I<0xAD, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
Eli Friedmanaace4b12009-06-19 04:48:38 +00002640 "shrd{w}\t{%cl, $src2, $dst|$dst, $src2, CL}",
Evan Cheng069287d2006-05-16 07:21:53 +00002641 [(store (X86shrd (loadi16 addr:$dst), GR16:$src2, CL),
Evan Cheng071a2792007-09-11 19:55:27 +00002642 addr:$dst)]>, TB, OpSize;
2643 }
Chris Lattner0df53d22005-01-19 07:31:24 +00002644 def SHLD16mri8 : Ii8<0xA4, MRMDestMem,
Evan Cheng64d80e32007-07-19 01:14:50 +00002645 (outs), (ins i16mem:$dst, GR16:$src2, i8imm:$src3),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002646 "shld{w}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Evan Cheng069287d2006-05-16 07:21:53 +00002647 [(store (X86shld (loadi16 addr:$dst), GR16:$src2,
Evan Chenge3413162006-01-09 18:33:28 +00002648 (i8 imm:$src3)), addr:$dst)]>,
Chris Lattner0df53d22005-01-19 07:31:24 +00002649 TB, OpSize;
2650 def SHRD16mri8 : Ii8<0xAC, MRMDestMem,
Evan Cheng64d80e32007-07-19 01:14:50 +00002651 (outs), (ins i16mem:$dst, GR16:$src2, i8imm:$src3),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002652 "shrd{w}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Evan Cheng069287d2006-05-16 07:21:53 +00002653 [(store (X86shrd (loadi16 addr:$dst), GR16:$src2,
Evan Chenge3413162006-01-09 18:33:28 +00002654 (i8 imm:$src3)), addr:$dst)]>,
Chris Lattner0df53d22005-01-19 07:31:24 +00002655 TB, OpSize;
Chris Lattner57a02302004-08-11 04:31:00 +00002656}
Evan Cheng24f2ea32007-09-14 21:48:26 +00002657} // Defs = [EFLAGS]
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00002658
2659
Chris Lattnercc65bee2005-01-02 02:35:46 +00002660// Arithmetic.
Evan Cheng24f2ea32007-09-14 21:48:26 +00002661let Defs = [EFLAGS] in {
Chris Lattnercc65bee2005-01-02 02:35:46 +00002662let isCommutable = 1 in { // X = ADD Y, Z --> X = ADD Z, Y
Bill Wendlingab55ebd2008-12-12 00:56:36 +00002663// Register-Register Addition
2664def ADD8rr : I<0x00, MRMDestReg, (outs GR8 :$dst),
2665 (ins GR8 :$src1, GR8 :$src2),
2666 "add{b}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingd350e022008-12-12 21:15:41 +00002667 [(set GR8:$dst, (add GR8:$src1, GR8:$src2)),
Bill Wendlingab55ebd2008-12-12 00:56:36 +00002668 (implicit EFLAGS)]>;
2669
Chris Lattnercc65bee2005-01-02 02:35:46 +00002670let isConvertibleToThreeAddress = 1 in { // Can transform into LEA.
Bill Wendlingab55ebd2008-12-12 00:56:36 +00002671// Register-Register Addition
Evan Cheng071a2792007-09-11 19:55:27 +00002672def ADD16rr : I<0x01, MRMDestReg, (outs GR16:$dst),
2673 (ins GR16:$src1, GR16:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002674 "add{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingd350e022008-12-12 21:15:41 +00002675 [(set GR16:$dst, (add GR16:$src1, GR16:$src2)),
2676 (implicit EFLAGS)]>, OpSize;
Evan Cheng071a2792007-09-11 19:55:27 +00002677def ADD32rr : I<0x01, MRMDestReg, (outs GR32:$dst),
2678 (ins GR32:$src1, GR32:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002679 "add{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingd350e022008-12-12 21:15:41 +00002680 [(set GR32:$dst, (add GR32:$src1, GR32:$src2)),
2681 (implicit EFLAGS)]>;
Chris Lattnercc65bee2005-01-02 02:35:46 +00002682} // end isConvertibleToThreeAddress
2683} // end isCommutable
Bill Wendlingab55ebd2008-12-12 00:56:36 +00002684
2685// Register-Memory Addition
Evan Cheng071a2792007-09-11 19:55:27 +00002686def ADD8rm : I<0x02, MRMSrcMem, (outs GR8 :$dst),
2687 (ins GR8 :$src1, i8mem :$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002688 "add{b}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingd350e022008-12-12 21:15:41 +00002689 [(set GR8:$dst, (add GR8:$src1, (load addr:$src2))),
2690 (implicit EFLAGS)]>;
Evan Cheng071a2792007-09-11 19:55:27 +00002691def ADD16rm : I<0x03, MRMSrcMem, (outs GR16:$dst),
2692 (ins GR16:$src1, i16mem:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002693 "add{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingd350e022008-12-12 21:15:41 +00002694 [(set GR16:$dst, (add GR16:$src1, (load addr:$src2))),
2695 (implicit EFLAGS)]>, OpSize;
Evan Cheng071a2792007-09-11 19:55:27 +00002696def ADD32rm : I<0x03, MRMSrcMem, (outs GR32:$dst),
2697 (ins GR32:$src1, i32mem:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002698 "add{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingd350e022008-12-12 21:15:41 +00002699 [(set GR32:$dst, (add GR32:$src1, (load addr:$src2))),
2700 (implicit EFLAGS)]>;
Sean Callanan37be5902009-09-15 20:53:57 +00002701
Sean Callanan62c28e32009-09-15 21:43:27 +00002702// Register-Register Addition - Equivalent to the normal rr forms (ADD8rr,
2703// ADD16rr, and ADD32rr), but differently encoded.
Sean Callanan37be5902009-09-15 20:53:57 +00002704def ADD8mrmrr: I<0x02, MRMSrcReg, (outs GR8:$dst), (ins GR8:$src1, GR8:$src2),
2705 "add{b}\t{$src2, $dst|$dst, $src2}", []>;
2706def ADD16mrmrr: I<0x03, MRMSrcReg,(outs GR16:$dst),(ins GR16:$src1, GR16:$src2),
2707 "add{w}\t{$src2, $dst|$dst, $src2}", []>, OpSize;
2708def ADD32mrmrr: I<0x03, MRMSrcReg,(outs GR16:$dst),(ins GR16:$src1, GR16:$src2),
2709 "add{l}\t{$src2, $dst|$dst, $src2}", []>;
Chris Lattnercc65bee2005-01-02 02:35:46 +00002710
Bill Wendlingab55ebd2008-12-12 00:56:36 +00002711// Register-Integer Addition
2712def ADD8ri : Ii8<0x80, MRM0r, (outs GR8:$dst), (ins GR8:$src1, i8imm:$src2),
2713 "add{b}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingd350e022008-12-12 21:15:41 +00002714 [(set GR8:$dst, (add GR8:$src1, imm:$src2)),
2715 (implicit EFLAGS)]>;
Bill Wendlingab55ebd2008-12-12 00:56:36 +00002716
Chris Lattnercc65bee2005-01-02 02:35:46 +00002717let isConvertibleToThreeAddress = 1 in { // Can transform into LEA.
Bill Wendlingab55ebd2008-12-12 00:56:36 +00002718// Register-Integer Addition
Evan Cheng071a2792007-09-11 19:55:27 +00002719def ADD16ri : Ii16<0x81, MRM0r, (outs GR16:$dst),
2720 (ins GR16:$src1, i16imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002721 "add{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingd350e022008-12-12 21:15:41 +00002722 [(set GR16:$dst, (add GR16:$src1, imm:$src2)),
2723 (implicit EFLAGS)]>, OpSize;
Evan Cheng071a2792007-09-11 19:55:27 +00002724def ADD32ri : Ii32<0x81, MRM0r, (outs GR32:$dst),
2725 (ins GR32:$src1, i32imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002726 "add{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingd350e022008-12-12 21:15:41 +00002727 [(set GR32:$dst, (add GR32:$src1, imm:$src2)),
2728 (implicit EFLAGS)]>;
Evan Cheng071a2792007-09-11 19:55:27 +00002729def ADD16ri8 : Ii8<0x83, MRM0r, (outs GR16:$dst),
2730 (ins GR16:$src1, i16i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002731 "add{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingd350e022008-12-12 21:15:41 +00002732 [(set GR16:$dst, (add GR16:$src1, i16immSExt8:$src2)),
2733 (implicit EFLAGS)]>, OpSize;
Evan Cheng071a2792007-09-11 19:55:27 +00002734def ADD32ri8 : Ii8<0x83, MRM0r, (outs GR32:$dst),
2735 (ins GR32:$src1, i32i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002736 "add{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingd350e022008-12-12 21:15:41 +00002737 [(set GR32:$dst, (add GR32:$src1, i32immSExt8:$src2)),
2738 (implicit EFLAGS)]>;
Evan Cheng09e3c802006-05-19 18:40:54 +00002739}
Chris Lattner57a02302004-08-11 04:31:00 +00002740
2741let isTwoAddress = 0 in {
Bill Wendlingab55ebd2008-12-12 00:56:36 +00002742 // Memory-Register Addition
Bill Wendlingd350e022008-12-12 21:15:41 +00002743 def ADD8mr : I<0x00, MRMDestMem, (outs), (ins i8mem:$dst, GR8:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002744 "add{b}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingd350e022008-12-12 21:15:41 +00002745 [(store (add (load addr:$dst), GR8:$src2), addr:$dst),
2746 (implicit EFLAGS)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00002747 def ADD16mr : I<0x01, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002748 "add{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingd350e022008-12-12 21:15:41 +00002749 [(store (add (load addr:$dst), GR16:$src2), addr:$dst),
2750 (implicit EFLAGS)]>, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00002751 def ADD32mr : I<0x01, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002752 "add{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingd350e022008-12-12 21:15:41 +00002753 [(store (add (load addr:$dst), GR32:$src2), addr:$dst),
2754 (implicit EFLAGS)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00002755 def ADD8mi : Ii8<0x80, MRM0m, (outs), (ins i8mem :$dst, i8imm :$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002756 "add{b}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingd350e022008-12-12 21:15:41 +00002757 [(store (add (loadi8 addr:$dst), imm:$src2), addr:$dst),
2758 (implicit EFLAGS)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00002759 def ADD16mi : Ii16<0x81, MRM0m, (outs), (ins i16mem:$dst, i16imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002760 "add{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingd350e022008-12-12 21:15:41 +00002761 [(store (add (loadi16 addr:$dst), imm:$src2), addr:$dst),
2762 (implicit EFLAGS)]>, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00002763 def ADD32mi : Ii32<0x81, MRM0m, (outs), (ins i32mem:$dst, i32imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002764 "add{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingd350e022008-12-12 21:15:41 +00002765 [(store (add (loadi32 addr:$dst), imm:$src2), addr:$dst),
2766 (implicit EFLAGS)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00002767 def ADD16mi8 : Ii8<0x83, MRM0m, (outs), (ins i16mem:$dst, i16i8imm :$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002768 "add{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingd350e022008-12-12 21:15:41 +00002769 [(store (add (load addr:$dst), i16immSExt8:$src2),
2770 addr:$dst),
2771 (implicit EFLAGS)]>, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00002772 def ADD32mi8 : Ii8<0x83, MRM0m, (outs), (ins i32mem:$dst, i32i8imm :$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002773 "add{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingab55ebd2008-12-12 00:56:36 +00002774 [(store (add (load addr:$dst), i32immSExt8:$src2),
Bill Wendlingd350e022008-12-12 21:15:41 +00002775 addr:$dst),
2776 (implicit EFLAGS)]>;
Sean Callananb08ae6b2009-08-11 21:26:06 +00002777
2778 // addition to rAX
2779 def ADD8i8 : Ii8<0x04, RawFrm, (outs), (ins i8imm:$src),
Sean Callanana09caa52009-09-02 00:55:49 +00002780 "add{b}\t{$src, %al|%al, $src}", []>;
Sean Callananb08ae6b2009-08-11 21:26:06 +00002781 def ADD16i16 : Ii16<0x05, RawFrm, (outs), (ins i16imm:$src),
Sean Callanana09caa52009-09-02 00:55:49 +00002782 "add{w}\t{$src, %ax|%ax, $src}", []>, OpSize;
Sean Callananb08ae6b2009-08-11 21:26:06 +00002783 def ADD32i32 : Ii32<0x05, RawFrm, (outs), (ins i32imm:$src),
Sean Callanana09caa52009-09-02 00:55:49 +00002784 "add{l}\t{$src, %eax|%eax, $src}", []>;
Chris Lattner57a02302004-08-11 04:31:00 +00002785}
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00002786
Evan Cheng3154cb62007-10-05 17:59:57 +00002787let Uses = [EFLAGS] in {
Chris Lattner10197ff2005-01-03 01:27:59 +00002788let isCommutable = 1 in { // X = ADC Y, Z --> X = ADC Z, Y
Dale Johannesen874ae252009-06-02 03:12:52 +00002789def ADC8rr : I<0x10, MRMDestReg, (outs GR8:$dst), (ins GR8:$src1, GR8:$src2),
Dale Johannesenca11dae2009-05-18 17:44:15 +00002790 "adc{b}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen874ae252009-06-02 03:12:52 +00002791 [(set GR8:$dst, (adde GR8:$src1, GR8:$src2))]>;
Dale Johannesenca11dae2009-05-18 17:44:15 +00002792def ADC16rr : I<0x11, MRMDestReg, (outs GR16:$dst),
2793 (ins GR16:$src1, GR16:$src2),
2794 "adc{w}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen874ae252009-06-02 03:12:52 +00002795 [(set GR16:$dst, (adde GR16:$src1, GR16:$src2))]>, OpSize;
Dale Johannesenca11dae2009-05-18 17:44:15 +00002796def ADC32rr : I<0x11, MRMDestReg, (outs GR32:$dst),
2797 (ins GR32:$src1, GR32:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002798 "adc{l}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen874ae252009-06-02 03:12:52 +00002799 [(set GR32:$dst, (adde GR32:$src1, GR32:$src2))]>;
Chris Lattner10197ff2005-01-03 01:27:59 +00002800}
Sean Callanan108934c2009-12-18 00:01:26 +00002801
2802def ADC8rr_REV : I<0x12, MRMSrcReg, (outs GR8:$dst), (ins GR8:$src1, GR8:$src2),
2803 "adc{b}\t{$src2, $dst|$dst, $src2}", []>;
2804def ADC16rr_REV : I<0x13, MRMSrcReg, (outs GR16:$dst),
2805 (ins GR16:$src1, GR16:$src2),
2806 "adc{w}\t{$src2, $dst|$dst, $src2}", []>, OpSize;
2807def ADC32rr_REV : I<0x13, MRMSrcReg, (outs GR32:$dst),
2808 (ins GR32:$src1, GR32:$src2),
2809 "adc{l}\t{$src2, $dst|$dst, $src2}", []>;
2810
Dale Johannesenca11dae2009-05-18 17:44:15 +00002811def ADC8rm : I<0x12, MRMSrcMem , (outs GR8:$dst),
2812 (ins GR8:$src1, i8mem:$src2),
2813 "adc{b}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen874ae252009-06-02 03:12:52 +00002814 [(set GR8:$dst, (adde GR8:$src1, (load addr:$src2)))]>;
Dale Johannesenca11dae2009-05-18 17:44:15 +00002815def ADC16rm : I<0x13, MRMSrcMem , (outs GR16:$dst),
2816 (ins GR16:$src1, i16mem:$src2),
2817 "adc{w}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen874ae252009-06-02 03:12:52 +00002818 [(set GR16:$dst, (adde GR16:$src1, (load addr:$src2)))]>,
Dale Johannesen94c9cd12009-05-18 21:41:59 +00002819 OpSize;
Dale Johannesenca11dae2009-05-18 17:44:15 +00002820def ADC32rm : I<0x13, MRMSrcMem , (outs GR32:$dst),
2821 (ins GR32:$src1, i32mem:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002822 "adc{l}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen874ae252009-06-02 03:12:52 +00002823 [(set GR32:$dst, (adde GR32:$src1, (load addr:$src2)))]>;
2824def ADC8ri : Ii8<0x80, MRM2r, (outs GR8:$dst), (ins GR8:$src1, i8imm:$src2),
Dale Johannesenca11dae2009-05-18 17:44:15 +00002825 "adc{b}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen874ae252009-06-02 03:12:52 +00002826 [(set GR8:$dst, (adde GR8:$src1, imm:$src2))]>;
Dale Johannesenca11dae2009-05-18 17:44:15 +00002827def ADC16ri : Ii16<0x81, MRM2r, (outs GR16:$dst),
2828 (ins GR16:$src1, i16imm:$src2),
2829 "adc{w}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen874ae252009-06-02 03:12:52 +00002830 [(set GR16:$dst, (adde GR16:$src1, imm:$src2))]>, OpSize;
Dale Johannesenca11dae2009-05-18 17:44:15 +00002831def ADC16ri8 : Ii8<0x83, MRM2r, (outs GR16:$dst),
2832 (ins GR16:$src1, i16i8imm:$src2),
2833 "adc{w}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen874ae252009-06-02 03:12:52 +00002834 [(set GR16:$dst, (adde GR16:$src1, i16immSExt8:$src2))]>,
2835 OpSize;
Dale Johannesenca11dae2009-05-18 17:44:15 +00002836def ADC32ri : Ii32<0x81, MRM2r, (outs GR32:$dst),
2837 (ins GR32:$src1, i32imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002838 "adc{l}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen874ae252009-06-02 03:12:52 +00002839 [(set GR32:$dst, (adde GR32:$src1, imm:$src2))]>;
Dale Johannesenca11dae2009-05-18 17:44:15 +00002840def ADC32ri8 : Ii8<0x83, MRM2r, (outs GR32:$dst),
2841 (ins GR32:$src1, i32i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002842 "adc{l}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen874ae252009-06-02 03:12:52 +00002843 [(set GR32:$dst, (adde GR32:$src1, i32immSExt8:$src2))]>;
Chris Lattner57a02302004-08-11 04:31:00 +00002844
2845let isTwoAddress = 0 in {
Dale Johannesen874ae252009-06-02 03:12:52 +00002846 def ADC8mr : I<0x10, MRMDestMem, (outs), (ins i8mem:$dst, GR8:$src2),
Dale Johannesenca11dae2009-05-18 17:44:15 +00002847 "adc{b}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen874ae252009-06-02 03:12:52 +00002848 [(store (adde (load addr:$dst), GR8:$src2), addr:$dst)]>;
2849 def ADC16mr : I<0x11, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
Dale Johannesenca11dae2009-05-18 17:44:15 +00002850 "adc{w}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen874ae252009-06-02 03:12:52 +00002851 [(store (adde (load addr:$dst), GR16:$src2), addr:$dst)]>,
2852 OpSize;
2853 def ADC32mr : I<0x11, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002854 "adc{l}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen874ae252009-06-02 03:12:52 +00002855 [(store (adde (load addr:$dst), GR32:$src2), addr:$dst)]>;
2856 def ADC8mi : Ii8<0x80, MRM2m, (outs), (ins i8mem:$dst, i8imm:$src2),
Dale Johannesenca11dae2009-05-18 17:44:15 +00002857 "adc{b}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen874ae252009-06-02 03:12:52 +00002858 [(store (adde (loadi8 addr:$dst), imm:$src2), addr:$dst)]>;
2859 def ADC16mi : Ii16<0x81, MRM2m, (outs), (ins i16mem:$dst, i16imm:$src2),
Dale Johannesenca11dae2009-05-18 17:44:15 +00002860 "adc{w}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen874ae252009-06-02 03:12:52 +00002861 [(store (adde (loadi16 addr:$dst), imm:$src2), addr:$dst)]>,
2862 OpSize;
2863 def ADC16mi8 : Ii8<0x83, MRM2m, (outs), (ins i16mem:$dst, i16i8imm :$src2),
Dale Johannesenca11dae2009-05-18 17:44:15 +00002864 "adc{w}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen874ae252009-06-02 03:12:52 +00002865 [(store (adde (load addr:$dst), i16immSExt8:$src2), addr:$dst)]>,
2866 OpSize;
2867 def ADC32mi : Ii32<0x81, MRM2m, (outs), (ins i32mem:$dst, i32imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002868 "adc{l}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen874ae252009-06-02 03:12:52 +00002869 [(store (adde (loadi32 addr:$dst), imm:$src2), addr:$dst)]>;
2870 def ADC32mi8 : Ii8<0x83, MRM2m, (outs), (ins i32mem:$dst, i32i8imm :$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002871 "adc{l}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen874ae252009-06-02 03:12:52 +00002872 [(store (adde (load addr:$dst), i32immSExt8:$src2), addr:$dst)]>;
Sean Callanand00025a2009-09-11 19:01:56 +00002873
2874 def ADC8i8 : Ii8<0x14, RawFrm, (outs), (ins i8imm:$src),
2875 "adc{b}\t{$src, %al|%al, $src}", []>;
2876 def ADC16i16 : Ii16<0x15, RawFrm, (outs), (ins i16imm:$src),
2877 "adc{w}\t{$src, %ax|%ax, $src}", []>, OpSize;
2878 def ADC32i32 : Ii32<0x15, RawFrm, (outs), (ins i32imm:$src),
2879 "adc{l}\t{$src, %eax|%eax, $src}", []>;
Dale Johannesen874ae252009-06-02 03:12:52 +00002880}
Evan Cheng3154cb62007-10-05 17:59:57 +00002881} // Uses = [EFLAGS]
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00002882
Bill Wendlingab55ebd2008-12-12 00:56:36 +00002883// Register-Register Subtraction
2884def SUB8rr : I<0x28, MRMDestReg, (outs GR8:$dst), (ins GR8:$src1, GR8:$src2),
2885 "sub{b}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingd350e022008-12-12 21:15:41 +00002886 [(set GR8:$dst, (sub GR8:$src1, GR8:$src2)),
2887 (implicit EFLAGS)]>;
Bill Wendlingab55ebd2008-12-12 00:56:36 +00002888def SUB16rr : I<0x29, MRMDestReg, (outs GR16:$dst), (ins GR16:$src1,GR16:$src2),
2889 "sub{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingd350e022008-12-12 21:15:41 +00002890 [(set GR16:$dst, (sub GR16:$src1, GR16:$src2)),
2891 (implicit EFLAGS)]>, OpSize;
Bill Wendlingab55ebd2008-12-12 00:56:36 +00002892def SUB32rr : I<0x29, MRMDestReg, (outs GR32:$dst), (ins GR32:$src1,GR32:$src2),
2893 "sub{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingd350e022008-12-12 21:15:41 +00002894 [(set GR32:$dst, (sub GR32:$src1, GR32:$src2)),
2895 (implicit EFLAGS)]>;
Bill Wendlingab55ebd2008-12-12 00:56:36 +00002896
Sean Callanan108934c2009-12-18 00:01:26 +00002897def SUB8rr_REV : I<0x2A, MRMSrcReg, (outs GR8:$dst), (ins GR8:$src1, GR8:$src2),
2898 "sub{b}\t{$src2, $dst|$dst, $src2}", []>;
2899def SUB16rr_REV : I<0x2B, MRMSrcReg, (outs GR16:$dst),
2900 (ins GR16:$src1, GR16:$src2),
2901 "sub{w}\t{$src2, $dst|$dst, $src2}", []>, OpSize;
2902def SUB32rr_REV : I<0x2B, MRMSrcReg, (outs GR32:$dst),
2903 (ins GR32:$src1, GR32:$src2),
2904 "sub{l}\t{$src2, $dst|$dst, $src2}", []>;
2905
Bill Wendlingab55ebd2008-12-12 00:56:36 +00002906// Register-Memory Subtraction
2907def SUB8rm : I<0x2A, MRMSrcMem, (outs GR8 :$dst),
2908 (ins GR8 :$src1, i8mem :$src2),
2909 "sub{b}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingd350e022008-12-12 21:15:41 +00002910 [(set GR8:$dst, (sub GR8:$src1, (load addr:$src2))),
2911 (implicit EFLAGS)]>;
Bill Wendlingab55ebd2008-12-12 00:56:36 +00002912def SUB16rm : I<0x2B, MRMSrcMem, (outs GR16:$dst),
2913 (ins GR16:$src1, i16mem:$src2),
2914 "sub{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingd350e022008-12-12 21:15:41 +00002915 [(set GR16:$dst, (sub GR16:$src1, (load addr:$src2))),
2916 (implicit EFLAGS)]>, OpSize;
Bill Wendlingab55ebd2008-12-12 00:56:36 +00002917def SUB32rm : I<0x2B, MRMSrcMem, (outs GR32:$dst),
2918 (ins GR32:$src1, i32mem:$src2),
2919 "sub{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingd350e022008-12-12 21:15:41 +00002920 [(set GR32:$dst, (sub GR32:$src1, (load addr:$src2))),
2921 (implicit EFLAGS)]>;
Bill Wendlingab55ebd2008-12-12 00:56:36 +00002922
2923// Register-Integer Subtraction
2924def SUB8ri : Ii8 <0x80, MRM5r, (outs GR8:$dst),
2925 (ins GR8:$src1, i8imm:$src2),
2926 "sub{b}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingd350e022008-12-12 21:15:41 +00002927 [(set GR8:$dst, (sub GR8:$src1, imm:$src2)),
2928 (implicit EFLAGS)]>;
Bill Wendlingab55ebd2008-12-12 00:56:36 +00002929def SUB16ri : Ii16<0x81, MRM5r, (outs GR16:$dst),
2930 (ins GR16:$src1, i16imm:$src2),
2931 "sub{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingd350e022008-12-12 21:15:41 +00002932 [(set GR16:$dst, (sub GR16:$src1, imm:$src2)),
2933 (implicit EFLAGS)]>, OpSize;
Bill Wendlingab55ebd2008-12-12 00:56:36 +00002934def SUB32ri : Ii32<0x81, MRM5r, (outs GR32:$dst),
2935 (ins GR32:$src1, i32imm:$src2),
2936 "sub{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingd350e022008-12-12 21:15:41 +00002937 [(set GR32:$dst, (sub GR32:$src1, imm:$src2)),
2938 (implicit EFLAGS)]>;
Bill Wendlingab55ebd2008-12-12 00:56:36 +00002939def SUB16ri8 : Ii8<0x83, MRM5r, (outs GR16:$dst),
2940 (ins GR16:$src1, i16i8imm:$src2),
2941 "sub{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingd350e022008-12-12 21:15:41 +00002942 [(set GR16:$dst, (sub GR16:$src1, i16immSExt8:$src2)),
2943 (implicit EFLAGS)]>, OpSize;
Bill Wendlingab55ebd2008-12-12 00:56:36 +00002944def SUB32ri8 : Ii8<0x83, MRM5r, (outs GR32:$dst),
2945 (ins GR32:$src1, i32i8imm:$src2),
2946 "sub{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingd350e022008-12-12 21:15:41 +00002947 [(set GR32:$dst, (sub GR32:$src1, i32immSExt8:$src2)),
2948 (implicit EFLAGS)]>;
Bill Wendlingab55ebd2008-12-12 00:56:36 +00002949
Chris Lattner57a02302004-08-11 04:31:00 +00002950let isTwoAddress = 0 in {
Bill Wendlingab55ebd2008-12-12 00:56:36 +00002951 // Memory-Register Subtraction
Evan Cheng64d80e32007-07-19 01:14:50 +00002952 def SUB8mr : I<0x28, MRMDestMem, (outs), (ins i8mem :$dst, GR8 :$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002953 "sub{b}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingd350e022008-12-12 21:15:41 +00002954 [(store (sub (load addr:$dst), GR8:$src2), addr:$dst),
2955 (implicit EFLAGS)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00002956 def SUB16mr : I<0x29, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002957 "sub{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingd350e022008-12-12 21:15:41 +00002958 [(store (sub (load addr:$dst), GR16:$src2), addr:$dst),
2959 (implicit EFLAGS)]>, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00002960 def SUB32mr : I<0x29, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002961 "sub{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingd350e022008-12-12 21:15:41 +00002962 [(store (sub (load addr:$dst), GR32:$src2), addr:$dst),
2963 (implicit EFLAGS)]>;
Bill Wendlingab55ebd2008-12-12 00:56:36 +00002964
2965 // Memory-Integer Subtraction
Evan Cheng64d80e32007-07-19 01:14:50 +00002966 def SUB8mi : Ii8<0x80, MRM5m, (outs), (ins i8mem :$dst, i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002967 "sub{b}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingd350e022008-12-12 21:15:41 +00002968 [(store (sub (loadi8 addr:$dst), imm:$src2), addr:$dst),
2969 (implicit EFLAGS)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00002970 def SUB16mi : Ii16<0x81, MRM5m, (outs), (ins i16mem:$dst, i16imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002971 "sub{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingd350e022008-12-12 21:15:41 +00002972 [(store (sub (loadi16 addr:$dst), imm:$src2),addr:$dst),
2973 (implicit EFLAGS)]>, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00002974 def SUB32mi : Ii32<0x81, MRM5m, (outs), (ins i32mem:$dst, i32imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002975 "sub{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingd350e022008-12-12 21:15:41 +00002976 [(store (sub (loadi32 addr:$dst), imm:$src2),addr:$dst),
2977 (implicit EFLAGS)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00002978 def SUB16mi8 : Ii8<0x83, MRM5m, (outs), (ins i16mem:$dst, i16i8imm :$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002979 "sub{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingab55ebd2008-12-12 00:56:36 +00002980 [(store (sub (load addr:$dst), i16immSExt8:$src2),
Bill Wendlingd350e022008-12-12 21:15:41 +00002981 addr:$dst),
2982 (implicit EFLAGS)]>, OpSize;
Bill Wendlingab55ebd2008-12-12 00:56:36 +00002983 def SUB32mi8 : Ii8<0x83, MRM5m, (outs), (ins i32mem:$dst, i32i8imm :$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002984 "sub{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingab55ebd2008-12-12 00:56:36 +00002985 [(store (sub (load addr:$dst), i32immSExt8:$src2),
Bill Wendlingd350e022008-12-12 21:15:41 +00002986 addr:$dst),
2987 (implicit EFLAGS)]>;
Sean Callanand00025a2009-09-11 19:01:56 +00002988
2989 def SUB8i8 : Ii8<0x2C, RawFrm, (outs), (ins i8imm:$src),
2990 "sub{b}\t{$src, %al|%al, $src}", []>;
2991 def SUB16i16 : Ii16<0x2D, RawFrm, (outs), (ins i16imm:$src),
2992 "sub{w}\t{$src, %ax|%ax, $src}", []>, OpSize;
2993 def SUB32i32 : Ii32<0x2D, RawFrm, (outs), (ins i32imm:$src),
2994 "sub{l}\t{$src, %eax|%eax, $src}", []>;
Chris Lattner57a02302004-08-11 04:31:00 +00002995}
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00002996
Evan Cheng3154cb62007-10-05 17:59:57 +00002997let Uses = [EFLAGS] in {
Dale Johannesenca11dae2009-05-18 17:44:15 +00002998def SBB8rr : I<0x18, MRMDestReg, (outs GR8:$dst),
2999 (ins GR8:$src1, GR8:$src2),
3000 "sbb{b}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen874ae252009-06-02 03:12:52 +00003001 [(set GR8:$dst, (sube GR8:$src1, GR8:$src2))]>;
Dale Johannesenca11dae2009-05-18 17:44:15 +00003002def SBB16rr : I<0x19, MRMDestReg, (outs GR16:$dst),
3003 (ins GR16:$src1, GR16:$src2),
3004 "sbb{w}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen874ae252009-06-02 03:12:52 +00003005 [(set GR16:$dst, (sube GR16:$src1, GR16:$src2))]>, OpSize;
Dale Johannesenca11dae2009-05-18 17:44:15 +00003006def SBB32rr : I<0x19, MRMDestReg, (outs GR32:$dst),
3007 (ins GR32:$src1, GR32:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003008 "sbb{l}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen874ae252009-06-02 03:12:52 +00003009 [(set GR32:$dst, (sube GR32:$src1, GR32:$src2))]>;
Chris Lattnerd93d3b02004-10-06 04:01:02 +00003010
Chris Lattner57a02302004-08-11 04:31:00 +00003011let isTwoAddress = 0 in {
Dale Johannesenca11dae2009-05-18 17:44:15 +00003012 def SBB8mr : I<0x18, MRMDestMem, (outs), (ins i8mem:$dst, GR8:$src2),
3013 "sbb{b}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen874ae252009-06-02 03:12:52 +00003014 [(store (sube (load addr:$dst), GR8:$src2), addr:$dst)]>;
Dale Johannesenca11dae2009-05-18 17:44:15 +00003015 def SBB16mr : I<0x19, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
3016 "sbb{w}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen874ae252009-06-02 03:12:52 +00003017 [(store (sube (load addr:$dst), GR16:$src2), addr:$dst)]>,
Dale Johannesen94c9cd12009-05-18 21:41:59 +00003018 OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00003019 def SBB32mr : I<0x19, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003020 "sbb{l}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen874ae252009-06-02 03:12:52 +00003021 [(store (sube (load addr:$dst), GR32:$src2), addr:$dst)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00003022 def SBB8mi : Ii32<0x80, MRM3m, (outs), (ins i8mem:$dst, i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003023 "sbb{b}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen874ae252009-06-02 03:12:52 +00003024 [(store (sube (loadi8 addr:$dst), imm:$src2), addr:$dst)]>;
Dale Johannesenca11dae2009-05-18 17:44:15 +00003025 def SBB16mi : Ii16<0x81, MRM3m, (outs), (ins i16mem:$dst, i16imm:$src2),
3026 "sbb{w}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen874ae252009-06-02 03:12:52 +00003027 [(store (sube (loadi16 addr:$dst), imm:$src2), addr:$dst)]>,
Dale Johannesen94c9cd12009-05-18 21:41:59 +00003028 OpSize;
Dale Johannesenca11dae2009-05-18 17:44:15 +00003029 def SBB16mi8 : Ii8<0x83, MRM3m, (outs), (ins i16mem:$dst, i16i8imm :$src2),
3030 "sbb{w}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen874ae252009-06-02 03:12:52 +00003031 [(store (sube (load addr:$dst), i16immSExt8:$src2), addr:$dst)]>,
Dale Johannesen94c9cd12009-05-18 21:41:59 +00003032 OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00003033 def SBB32mi : Ii32<0x81, MRM3m, (outs), (ins i32mem:$dst, i32imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003034 "sbb{l}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen874ae252009-06-02 03:12:52 +00003035 [(store (sube (loadi32 addr:$dst), imm:$src2), addr:$dst)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00003036 def SBB32mi8 : Ii8<0x83, MRM3m, (outs), (ins i32mem:$dst, i32i8imm :$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003037 "sbb{l}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen874ae252009-06-02 03:12:52 +00003038 [(store (sube (load addr:$dst), i32immSExt8:$src2), addr:$dst)]>;
Sean Callanand00025a2009-09-11 19:01:56 +00003039
3040 def SBB8i8 : Ii8<0x1C, RawFrm, (outs), (ins i8imm:$src),
3041 "sbb{b}\t{$src, %al|%al, $src}", []>;
3042 def SBB16i16 : Ii16<0x1D, RawFrm, (outs), (ins i16imm:$src),
3043 "sbb{w}\t{$src, %ax|%ax, $src}", []>, OpSize;
3044 def SBB32i32 : Ii32<0x1D, RawFrm, (outs), (ins i32imm:$src),
3045 "sbb{l}\t{$src, %eax|%eax, $src}", []>;
Chris Lattner57a02302004-08-11 04:31:00 +00003046}
Sean Callanan108934c2009-12-18 00:01:26 +00003047
3048def SBB8rr_REV : I<0x1A, MRMSrcReg, (outs GR8:$dst), (ins GR8:$src1, GR8:$src2),
3049 "sbb{b}\t{$src2, $dst|$dst, $src2}", []>;
3050def SBB16rr_REV : I<0x1B, MRMSrcReg, (outs GR16:$dst),
3051 (ins GR16:$src1, GR16:$src2),
3052 "sbb{w}\t{$src2, $dst|$dst, $src2}", []>, OpSize;
3053def SBB32rr_REV : I<0x1B, MRMSrcReg, (outs GR32:$dst),
3054 (ins GR32:$src1, GR32:$src2),
3055 "sbb{l}\t{$src2, $dst|$dst, $src2}", []>;
3056
Dale Johannesenca11dae2009-05-18 17:44:15 +00003057def SBB8rm : I<0x1A, MRMSrcMem, (outs GR8:$dst), (ins GR8:$src1, i8mem:$src2),
3058 "sbb{b}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen874ae252009-06-02 03:12:52 +00003059 [(set GR8:$dst, (sube GR8:$src1, (load addr:$src2)))]>;
Dale Johannesenca11dae2009-05-18 17:44:15 +00003060def SBB16rm : I<0x1B, MRMSrcMem, (outs GR16:$dst),
3061 (ins GR16:$src1, i16mem:$src2),
3062 "sbb{w}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen874ae252009-06-02 03:12:52 +00003063 [(set GR16:$dst, (sube GR16:$src1, (load addr:$src2)))]>,
Dale Johannesen94c9cd12009-05-18 21:41:59 +00003064 OpSize;
Dale Johannesenca11dae2009-05-18 17:44:15 +00003065def SBB32rm : I<0x1B, MRMSrcMem, (outs GR32:$dst),
3066 (ins GR32:$src1, i32mem:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003067 "sbb{l}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen874ae252009-06-02 03:12:52 +00003068 [(set GR32:$dst, (sube GR32:$src1, (load addr:$src2)))]>;
Dale Johannesenca11dae2009-05-18 17:44:15 +00003069def SBB8ri : Ii8<0x80, MRM3r, (outs GR8:$dst), (ins GR8:$src1, i8imm:$src2),
3070 "sbb{b}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen874ae252009-06-02 03:12:52 +00003071 [(set GR8:$dst, (sube GR8:$src1, imm:$src2))]>;
Dale Johannesenca11dae2009-05-18 17:44:15 +00003072def SBB16ri : Ii16<0x81, MRM3r, (outs GR16:$dst),
3073 (ins GR16:$src1, i16imm:$src2),
3074 "sbb{w}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen874ae252009-06-02 03:12:52 +00003075 [(set GR16:$dst, (sube GR16:$src1, imm:$src2))]>, OpSize;
Dale Johannesenca11dae2009-05-18 17:44:15 +00003076def SBB16ri8 : Ii8<0x83, MRM3r, (outs GR16:$dst),
3077 (ins GR16:$src1, i16i8imm:$src2),
3078 "sbb{w}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen874ae252009-06-02 03:12:52 +00003079 [(set GR16:$dst, (sube GR16:$src1, i16immSExt8:$src2))]>,
3080 OpSize;
Dale Johannesenca11dae2009-05-18 17:44:15 +00003081def SBB32ri : Ii32<0x81, MRM3r, (outs GR32:$dst),
3082 (ins GR32:$src1, i32imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003083 "sbb{l}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen874ae252009-06-02 03:12:52 +00003084 [(set GR32:$dst, (sube GR32:$src1, imm:$src2))]>;
Dale Johannesenca11dae2009-05-18 17:44:15 +00003085def SBB32ri8 : Ii8<0x83, MRM3r, (outs GR32:$dst),
3086 (ins GR32:$src1, i32i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003087 "sbb{l}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen874ae252009-06-02 03:12:52 +00003088 [(set GR32:$dst, (sube GR32:$src1, i32immSExt8:$src2))]>;
Evan Cheng3154cb62007-10-05 17:59:57 +00003089} // Uses = [EFLAGS]
Evan Cheng24f2ea32007-09-14 21:48:26 +00003090} // Defs = [EFLAGS]
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00003091
Evan Cheng24f2ea32007-09-14 21:48:26 +00003092let Defs = [EFLAGS] in {
Chris Lattner10197ff2005-01-03 01:27:59 +00003093let isCommutable = 1 in { // X = IMUL Y, Z --> X = IMUL Z, Y
Bill Wendlingd350e022008-12-12 21:15:41 +00003094// Register-Register Signed Integer Multiply
Bill Wendlingab55ebd2008-12-12 00:56:36 +00003095def IMUL16rr : I<0xAF, MRMSrcReg, (outs GR16:$dst), (ins GR16:$src1,GR16:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003096 "imul{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingd350e022008-12-12 21:15:41 +00003097 [(set GR16:$dst, (mul GR16:$src1, GR16:$src2)),
3098 (implicit EFLAGS)]>, TB, OpSize;
Bill Wendlingab55ebd2008-12-12 00:56:36 +00003099def IMUL32rr : I<0xAF, MRMSrcReg, (outs GR32:$dst), (ins GR32:$src1,GR32:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003100 "imul{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingd350e022008-12-12 21:15:41 +00003101 [(set GR32:$dst, (mul GR32:$src1, GR32:$src2)),
3102 (implicit EFLAGS)]>, TB;
Chris Lattner10197ff2005-01-03 01:27:59 +00003103}
Bill Wendlingab55ebd2008-12-12 00:56:36 +00003104
Bill Wendlingd350e022008-12-12 21:15:41 +00003105// Register-Memory Signed Integer Multiply
Bill Wendlingab55ebd2008-12-12 00:56:36 +00003106def IMUL16rm : I<0xAF, MRMSrcMem, (outs GR16:$dst),
3107 (ins GR16:$src1, i16mem:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003108 "imul{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingd350e022008-12-12 21:15:41 +00003109 [(set GR16:$dst, (mul GR16:$src1, (load addr:$src2))),
3110 (implicit EFLAGS)]>, TB, OpSize;
Sean Callanan108934c2009-12-18 00:01:26 +00003111def IMUL32rm : I<0xAF, MRMSrcMem, (outs GR32:$dst),
3112 (ins GR32:$src1, i32mem:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003113 "imul{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingd350e022008-12-12 21:15:41 +00003114 [(set GR32:$dst, (mul GR32:$src1, (load addr:$src2))),
3115 (implicit EFLAGS)]>, TB;
Evan Cheng24f2ea32007-09-14 21:48:26 +00003116} // Defs = [EFLAGS]
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00003117} // end Two Address instructions
3118
Chris Lattnerf5d3a832004-08-11 05:31:07 +00003119// Suprisingly enough, these are not two address instructions!
Evan Cheng24f2ea32007-09-14 21:48:26 +00003120let Defs = [EFLAGS] in {
Bill Wendlingd350e022008-12-12 21:15:41 +00003121// Register-Integer Signed Integer Multiply
Evan Cheng069287d2006-05-16 07:21:53 +00003122def IMUL16rri : Ii16<0x69, MRMSrcReg, // GR16 = GR16*I16
Evan Cheng64d80e32007-07-19 01:14:50 +00003123 (outs GR16:$dst), (ins GR16:$src1, i16imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003124 "imul{w}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Bill Wendlingd350e022008-12-12 21:15:41 +00003125 [(set GR16:$dst, (mul GR16:$src1, imm:$src2)),
3126 (implicit EFLAGS)]>, OpSize;
Evan Cheng069287d2006-05-16 07:21:53 +00003127def IMUL32rri : Ii32<0x69, MRMSrcReg, // GR32 = GR32*I32
Evan Cheng64d80e32007-07-19 01:14:50 +00003128 (outs GR32:$dst), (ins GR32:$src1, i32imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003129 "imul{l}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Bill Wendlingd350e022008-12-12 21:15:41 +00003130 [(set GR32:$dst, (mul GR32:$src1, imm:$src2)),
3131 (implicit EFLAGS)]>;
Evan Cheng069287d2006-05-16 07:21:53 +00003132def IMUL16rri8 : Ii8<0x6B, MRMSrcReg, // GR16 = GR16*I8
Evan Cheng64d80e32007-07-19 01:14:50 +00003133 (outs GR16:$dst), (ins GR16:$src1, i16i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003134 "imul{w}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Bill Wendlingd350e022008-12-12 21:15:41 +00003135 [(set GR16:$dst, (mul GR16:$src1, i16immSExt8:$src2)),
3136 (implicit EFLAGS)]>, OpSize;
Evan Cheng069287d2006-05-16 07:21:53 +00003137def IMUL32rri8 : Ii8<0x6B, MRMSrcReg, // GR32 = GR32*I8
Evan Cheng64d80e32007-07-19 01:14:50 +00003138 (outs GR32:$dst), (ins GR32:$src1, i32i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003139 "imul{l}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Bill Wendlingd350e022008-12-12 21:15:41 +00003140 [(set GR32:$dst, (mul GR32:$src1, i32immSExt8:$src2)),
3141 (implicit EFLAGS)]>;
Chris Lattnerf5d3a832004-08-11 05:31:07 +00003142
Bill Wendlingd350e022008-12-12 21:15:41 +00003143// Memory-Integer Signed Integer Multiply
Sean Callanan108934c2009-12-18 00:01:26 +00003144def IMUL16rmi : Ii16<0x69, MRMSrcMem, // GR16 = [mem16]*I16
Evan Cheng64d80e32007-07-19 01:14:50 +00003145 (outs GR16:$dst), (ins i16mem:$src1, i16imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003146 "imul{w}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Bill Wendlingd350e022008-12-12 21:15:41 +00003147 [(set GR16:$dst, (mul (load addr:$src1), imm:$src2)),
3148 (implicit EFLAGS)]>, OpSize;
Sean Callanan108934c2009-12-18 00:01:26 +00003149def IMUL32rmi : Ii32<0x69, MRMSrcMem, // GR32 = [mem32]*I32
Evan Cheng64d80e32007-07-19 01:14:50 +00003150 (outs GR32:$dst), (ins i32mem:$src1, i32imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003151 "imul{l}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Bill Wendlingd350e022008-12-12 21:15:41 +00003152 [(set GR32:$dst, (mul (load addr:$src1), imm:$src2)),
3153 (implicit EFLAGS)]>;
Evan Cheng069287d2006-05-16 07:21:53 +00003154def IMUL16rmi8 : Ii8<0x6B, MRMSrcMem, // GR16 = [mem16]*I8
Evan Cheng64d80e32007-07-19 01:14:50 +00003155 (outs GR16:$dst), (ins i16mem:$src1, i16i8imm :$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003156 "imul{w}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Bill Wendlingab55ebd2008-12-12 00:56:36 +00003157 [(set GR16:$dst, (mul (load addr:$src1),
Bill Wendlingd350e022008-12-12 21:15:41 +00003158 i16immSExt8:$src2)),
3159 (implicit EFLAGS)]>, OpSize;
Evan Cheng069287d2006-05-16 07:21:53 +00003160def IMUL32rmi8 : Ii8<0x6B, MRMSrcMem, // GR32 = [mem32]*I8
Evan Cheng64d80e32007-07-19 01:14:50 +00003161 (outs GR32:$dst), (ins i32mem:$src1, i32i8imm: $src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003162 "imul{l}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Bill Wendlingab55ebd2008-12-12 00:56:36 +00003163 [(set GR32:$dst, (mul (load addr:$src1),
Bill Wendlingd350e022008-12-12 21:15:41 +00003164 i32immSExt8:$src2)),
3165 (implicit EFLAGS)]>;
Evan Cheng24f2ea32007-09-14 21:48:26 +00003166} // Defs = [EFLAGS]
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00003167
3168//===----------------------------------------------------------------------===//
3169// Test instructions are just like AND, except they don't generate a result.
Chris Lattner3a173df2004-10-03 20:35:00 +00003170//
Evan Cheng0488db92007-09-25 01:57:46 +00003171let Defs = [EFLAGS] in {
Chris Lattnercc65bee2005-01-02 02:35:46 +00003172let isCommutable = 1 in { // TEST X, Y --> TEST Y, X
Evan Cheng64d80e32007-07-19 01:14:50 +00003173def TEST8rr : I<0x84, MRMDestReg, (outs), (ins GR8:$src1, GR8:$src2),
Evan Chenge5f62042007-09-29 00:00:36 +00003174 "test{b}\t{$src2, $src1|$src1, $src2}",
Chris Lattnerce2bcc82008-02-19 17:37:35 +00003175 [(X86cmp (and_su GR8:$src1, GR8:$src2), 0),
Evan Chenge5f62042007-09-29 00:00:36 +00003176 (implicit EFLAGS)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00003177def TEST16rr : I<0x85, MRMDestReg, (outs), (ins GR16:$src1, GR16:$src2),
Evan Chenge5f62042007-09-29 00:00:36 +00003178 "test{w}\t{$src2, $src1|$src1, $src2}",
Chris Lattnerce2bcc82008-02-19 17:37:35 +00003179 [(X86cmp (and_su GR16:$src1, GR16:$src2), 0),
Evan Chenge5f62042007-09-29 00:00:36 +00003180 (implicit EFLAGS)]>,
3181 OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00003182def TEST32rr : I<0x85, MRMDestReg, (outs), (ins GR32:$src1, GR32:$src2),
Evan Chenge5f62042007-09-29 00:00:36 +00003183 "test{l}\t{$src2, $src1|$src1, $src2}",
Chris Lattnerce2bcc82008-02-19 17:37:35 +00003184 [(X86cmp (and_su GR32:$src1, GR32:$src2), 0),
Evan Chenge5f62042007-09-29 00:00:36 +00003185 (implicit EFLAGS)]>;
Chris Lattnercc65bee2005-01-02 02:35:46 +00003186}
Evan Cheng734503b2006-09-11 02:19:56 +00003187
Sean Callanan4a93b712009-09-01 18:14:18 +00003188def TEST8i8 : Ii8<0xA8, RawFrm, (outs), (ins i8imm:$src),
3189 "test{b}\t{$src, %al|%al, $src}", []>;
3190def TEST16i16 : Ii16<0xA9, RawFrm, (outs), (ins i16imm:$src),
3191 "test{w}\t{$src, %ax|%ax, $src}", []>, OpSize;
3192def TEST32i32 : Ii32<0xA9, RawFrm, (outs), (ins i32imm:$src),
3193 "test{l}\t{$src, %eax|%eax, $src}", []>;
3194
Evan Cheng64d80e32007-07-19 01:14:50 +00003195def TEST8rm : I<0x84, MRMSrcMem, (outs), (ins GR8 :$src1, i8mem :$src2),
Evan Chenge5f62042007-09-29 00:00:36 +00003196 "test{b}\t{$src2, $src1|$src1, $src2}",
3197 [(X86cmp (and GR8:$src1, (loadi8 addr:$src2)), 0),
3198 (implicit EFLAGS)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00003199def TEST16rm : I<0x85, MRMSrcMem, (outs), (ins GR16:$src1, i16mem:$src2),
Evan Chenge5f62042007-09-29 00:00:36 +00003200 "test{w}\t{$src2, $src1|$src1, $src2}",
3201 [(X86cmp (and GR16:$src1, (loadi16 addr:$src2)), 0),
3202 (implicit EFLAGS)]>, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00003203def TEST32rm : I<0x85, MRMSrcMem, (outs), (ins GR32:$src1, i32mem:$src2),
Evan Chenge5f62042007-09-29 00:00:36 +00003204 "test{l}\t{$src2, $src1|$src1, $src2}",
3205 [(X86cmp (and GR32:$src1, (loadi32 addr:$src2)), 0),
3206 (implicit EFLAGS)]>;
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00003207
Evan Cheng069287d2006-05-16 07:21:53 +00003208def TEST8ri : Ii8 <0xF6, MRM0r, // flags = GR8 & imm8
Evan Cheng64d80e32007-07-19 01:14:50 +00003209 (outs), (ins GR8:$src1, i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003210 "test{b}\t{$src2, $src1|$src1, $src2}",
Chris Lattnerce2bcc82008-02-19 17:37:35 +00003211 [(X86cmp (and_su GR8:$src1, imm:$src2), 0),
Evan Chenge5f62042007-09-29 00:00:36 +00003212 (implicit EFLAGS)]>;
Evan Cheng069287d2006-05-16 07:21:53 +00003213def TEST16ri : Ii16<0xF7, MRM0r, // flags = GR16 & imm16
Evan Cheng64d80e32007-07-19 01:14:50 +00003214 (outs), (ins GR16:$src1, i16imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003215 "test{w}\t{$src2, $src1|$src1, $src2}",
Chris Lattnerce2bcc82008-02-19 17:37:35 +00003216 [(X86cmp (and_su GR16:$src1, imm:$src2), 0),
Evan Chenge5f62042007-09-29 00:00:36 +00003217 (implicit EFLAGS)]>, OpSize;
Evan Cheng069287d2006-05-16 07:21:53 +00003218def TEST32ri : Ii32<0xF7, MRM0r, // flags = GR32 & imm32
Evan Cheng64d80e32007-07-19 01:14:50 +00003219 (outs), (ins GR32:$src1, i32imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003220 "test{l}\t{$src2, $src1|$src1, $src2}",
Chris Lattnerce2bcc82008-02-19 17:37:35 +00003221 [(X86cmp (and_su GR32:$src1, imm:$src2), 0),
Evan Chenge5f62042007-09-29 00:00:36 +00003222 (implicit EFLAGS)]>;
Evan Cheng734503b2006-09-11 02:19:56 +00003223
Evan Chenge5f62042007-09-29 00:00:36 +00003224def TEST8mi : Ii8 <0xF6, MRM0m, // flags = [mem8] & imm8
Evan Cheng64d80e32007-07-19 01:14:50 +00003225 (outs), (ins i8mem:$src1, i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003226 "test{b}\t{$src2, $src1|$src1, $src2}",
Evan Chenge5f62042007-09-29 00:00:36 +00003227 [(X86cmp (and (loadi8 addr:$src1), imm:$src2), 0),
3228 (implicit EFLAGS)]>;
3229def TEST16mi : Ii16<0xF7, MRM0m, // flags = [mem16] & imm16
Evan Cheng64d80e32007-07-19 01:14:50 +00003230 (outs), (ins i16mem:$src1, i16imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003231 "test{w}\t{$src2, $src1|$src1, $src2}",
Evan Chenge5f62042007-09-29 00:00:36 +00003232 [(X86cmp (and (loadi16 addr:$src1), imm:$src2), 0),
3233 (implicit EFLAGS)]>, OpSize;
3234def TEST32mi : Ii32<0xF7, MRM0m, // flags = [mem32] & imm32
Evan Cheng64d80e32007-07-19 01:14:50 +00003235 (outs), (ins i32mem:$src1, i32imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003236 "test{l}\t{$src2, $src1|$src1, $src2}",
Evan Chenge5f62042007-09-29 00:00:36 +00003237 [(X86cmp (and (loadi32 addr:$src1), imm:$src2), 0),
Evan Cheng0488db92007-09-25 01:57:46 +00003238 (implicit EFLAGS)]>;
3239} // Defs = [EFLAGS]
3240
3241
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00003242// Condition code ops, incl. set if equal/not equal/...
Chris Lattnerba7e7562008-01-10 07:59:24 +00003243let Defs = [EFLAGS], Uses = [AH], neverHasSideEffects = 1 in
Evan Cheng071a2792007-09-11 19:55:27 +00003244def SAHF : I<0x9E, RawFrm, (outs), (ins), "sahf", []>; // flags = AH
Chris Lattnerba7e7562008-01-10 07:59:24 +00003245let Defs = [AH], Uses = [EFLAGS], neverHasSideEffects = 1 in
Evan Cheng071a2792007-09-11 19:55:27 +00003246def LAHF : I<0x9F, RawFrm, (outs), (ins), "lahf", []>; // AH = flags
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00003247
Evan Cheng0488db92007-09-25 01:57:46 +00003248let Uses = [EFLAGS] in {
Evan Chengad9c0a32009-12-15 00:53:42 +00003249// Use sbb to materialize carry bit.
3250
3251let Defs = [EFLAGS], isCodeGenOnly = 1 in {
3252def SETB_C8r : I<0x18, MRMInitReg, (outs GR8:$dst), (ins),
3253 "sbb{b}\t$dst, $dst",
3254 [(set GR8:$dst, (X86setcc_c X86_COND_B, EFLAGS))]>;
3255def SETB_C16r : I<0x19, MRMInitReg, (outs GR16:$dst), (ins),
3256 "sbb{w}\t$dst, $dst",
Evan Cheng2e489c42009-12-16 00:53:11 +00003257 [(set GR16:$dst, (X86setcc_c X86_COND_B, EFLAGS))]>,
Evan Chengad9c0a32009-12-15 00:53:42 +00003258 OpSize;
3259def SETB_C32r : I<0x19, MRMInitReg, (outs GR32:$dst), (ins),
3260 "sbb{l}\t$dst, $dst",
Evan Cheng2e489c42009-12-16 00:53:11 +00003261 [(set GR32:$dst, (X86setcc_c X86_COND_B, EFLAGS))]>;
Evan Chengad9c0a32009-12-15 00:53:42 +00003262} // isCodeGenOnly
3263
Chris Lattner3a173df2004-10-03 20:35:00 +00003264def SETEr : I<0x94, MRM0r,
Evan Cheng64d80e32007-07-19 01:14:50 +00003265 (outs GR8 :$dst), (ins),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003266 "sete\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +00003267 [(set GR8:$dst, (X86setcc X86_COND_E, EFLAGS))]>,
Evan Cheng069287d2006-05-16 07:21:53 +00003268 TB; // GR8 = ==
Chris Lattner3a173df2004-10-03 20:35:00 +00003269def SETEm : I<0x94, MRM0m,
Evan Cheng64d80e32007-07-19 01:14:50 +00003270 (outs), (ins i8mem:$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003271 "sete\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +00003272 [(store (X86setcc X86_COND_E, EFLAGS), addr:$dst)]>,
Evan Chengd5781fc2005-12-21 20:21:51 +00003273 TB; // [mem8] = ==
Bill Wendling9f248742008-12-02 00:07:05 +00003274
Chris Lattner3a173df2004-10-03 20:35:00 +00003275def SETNEr : I<0x95, MRM0r,
Evan Cheng64d80e32007-07-19 01:14:50 +00003276 (outs GR8 :$dst), (ins),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003277 "setne\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +00003278 [(set GR8:$dst, (X86setcc X86_COND_NE, EFLAGS))]>,
Evan Cheng069287d2006-05-16 07:21:53 +00003279 TB; // GR8 = !=
Chris Lattner3a173df2004-10-03 20:35:00 +00003280def SETNEm : I<0x95, MRM0m,
Evan Cheng64d80e32007-07-19 01:14:50 +00003281 (outs), (ins i8mem:$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003282 "setne\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +00003283 [(store (X86setcc X86_COND_NE, EFLAGS), addr:$dst)]>,
Evan Chengd5781fc2005-12-21 20:21:51 +00003284 TB; // [mem8] = !=
Bill Wendling9f248742008-12-02 00:07:05 +00003285
Evan Chengd5781fc2005-12-21 20:21:51 +00003286def SETLr : I<0x9C, MRM0r,
Evan Cheng64d80e32007-07-19 01:14:50 +00003287 (outs GR8 :$dst), (ins),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003288 "setl\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +00003289 [(set GR8:$dst, (X86setcc X86_COND_L, EFLAGS))]>,
Evan Cheng069287d2006-05-16 07:21:53 +00003290 TB; // GR8 = < signed
Evan Chengd5781fc2005-12-21 20:21:51 +00003291def SETLm : I<0x9C, MRM0m,
Evan Cheng64d80e32007-07-19 01:14:50 +00003292 (outs), (ins i8mem:$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003293 "setl\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +00003294 [(store (X86setcc X86_COND_L, EFLAGS), addr:$dst)]>,
Evan Chengd5781fc2005-12-21 20:21:51 +00003295 TB; // [mem8] = < signed
Bill Wendling9f248742008-12-02 00:07:05 +00003296
Evan Chengd5781fc2005-12-21 20:21:51 +00003297def SETGEr : I<0x9D, MRM0r,
Evan Cheng64d80e32007-07-19 01:14:50 +00003298 (outs GR8 :$dst), (ins),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003299 "setge\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +00003300 [(set GR8:$dst, (X86setcc X86_COND_GE, EFLAGS))]>,
Evan Cheng069287d2006-05-16 07:21:53 +00003301 TB; // GR8 = >= signed
Evan Chengd5781fc2005-12-21 20:21:51 +00003302def SETGEm : I<0x9D, MRM0m,
Evan Cheng64d80e32007-07-19 01:14:50 +00003303 (outs), (ins i8mem:$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003304 "setge\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +00003305 [(store (X86setcc X86_COND_GE, EFLAGS), addr:$dst)]>,
Evan Chengd5781fc2005-12-21 20:21:51 +00003306 TB; // [mem8] = >= signed
Bill Wendling9f248742008-12-02 00:07:05 +00003307
Evan Chengd5781fc2005-12-21 20:21:51 +00003308def SETLEr : I<0x9E, MRM0r,
Evan Cheng64d80e32007-07-19 01:14:50 +00003309 (outs GR8 :$dst), (ins),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003310 "setle\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +00003311 [(set GR8:$dst, (X86setcc X86_COND_LE, EFLAGS))]>,
Evan Cheng069287d2006-05-16 07:21:53 +00003312 TB; // GR8 = <= signed
Evan Chengd5781fc2005-12-21 20:21:51 +00003313def SETLEm : I<0x9E, MRM0m,
Evan Cheng64d80e32007-07-19 01:14:50 +00003314 (outs), (ins i8mem:$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003315 "setle\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +00003316 [(store (X86setcc X86_COND_LE, EFLAGS), addr:$dst)]>,
Evan Chengd5781fc2005-12-21 20:21:51 +00003317 TB; // [mem8] = <= signed
Bill Wendling9f248742008-12-02 00:07:05 +00003318
Evan Chengd5781fc2005-12-21 20:21:51 +00003319def SETGr : I<0x9F, MRM0r,
Evan Cheng64d80e32007-07-19 01:14:50 +00003320 (outs GR8 :$dst), (ins),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003321 "setg\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +00003322 [(set GR8:$dst, (X86setcc X86_COND_G, EFLAGS))]>,
Evan Cheng069287d2006-05-16 07:21:53 +00003323 TB; // GR8 = > signed
Evan Chengd5781fc2005-12-21 20:21:51 +00003324def SETGm : I<0x9F, MRM0m,
Evan Cheng64d80e32007-07-19 01:14:50 +00003325 (outs), (ins i8mem:$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003326 "setg\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +00003327 [(store (X86setcc X86_COND_G, EFLAGS), addr:$dst)]>,
Evan Chengd5781fc2005-12-21 20:21:51 +00003328 TB; // [mem8] = > signed
3329
3330def SETBr : I<0x92, MRM0r,
Evan Cheng64d80e32007-07-19 01:14:50 +00003331 (outs GR8 :$dst), (ins),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003332 "setb\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +00003333 [(set GR8:$dst, (X86setcc X86_COND_B, EFLAGS))]>,
Evan Cheng069287d2006-05-16 07:21:53 +00003334 TB; // GR8 = < unsign
Evan Chengd5781fc2005-12-21 20:21:51 +00003335def SETBm : I<0x92, MRM0m,
Evan Cheng64d80e32007-07-19 01:14:50 +00003336 (outs), (ins i8mem:$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003337 "setb\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +00003338 [(store (X86setcc X86_COND_B, EFLAGS), addr:$dst)]>,
Evan Chengd5781fc2005-12-21 20:21:51 +00003339 TB; // [mem8] = < unsign
Bill Wendling9f248742008-12-02 00:07:05 +00003340
Evan Chengd5781fc2005-12-21 20:21:51 +00003341def SETAEr : I<0x93, MRM0r,
Evan Cheng64d80e32007-07-19 01:14:50 +00003342 (outs GR8 :$dst), (ins),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003343 "setae\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +00003344 [(set GR8:$dst, (X86setcc X86_COND_AE, EFLAGS))]>,
Evan Cheng069287d2006-05-16 07:21:53 +00003345 TB; // GR8 = >= unsign
Evan Chengd5781fc2005-12-21 20:21:51 +00003346def SETAEm : I<0x93, MRM0m,
Evan Cheng64d80e32007-07-19 01:14:50 +00003347 (outs), (ins i8mem:$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003348 "setae\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +00003349 [(store (X86setcc X86_COND_AE, EFLAGS), addr:$dst)]>,
Evan Chengd5781fc2005-12-21 20:21:51 +00003350 TB; // [mem8] = >= unsign
Bill Wendling9f248742008-12-02 00:07:05 +00003351
Chris Lattner3a173df2004-10-03 20:35:00 +00003352def SETBEr : I<0x96, MRM0r,
Evan Cheng64d80e32007-07-19 01:14:50 +00003353 (outs GR8 :$dst), (ins),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003354 "setbe\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +00003355 [(set GR8:$dst, (X86setcc X86_COND_BE, EFLAGS))]>,
Evan Cheng069287d2006-05-16 07:21:53 +00003356 TB; // GR8 = <= unsign
Chris Lattner3a173df2004-10-03 20:35:00 +00003357def SETBEm : I<0x96, MRM0m,
Evan Cheng64d80e32007-07-19 01:14:50 +00003358 (outs), (ins i8mem:$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003359 "setbe\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +00003360 [(store (X86setcc X86_COND_BE, EFLAGS), addr:$dst)]>,
Evan Chengd5781fc2005-12-21 20:21:51 +00003361 TB; // [mem8] = <= unsign
Bill Wendling9f248742008-12-02 00:07:05 +00003362
Chris Lattner3a173df2004-10-03 20:35:00 +00003363def SETAr : I<0x97, MRM0r,
Evan Cheng64d80e32007-07-19 01:14:50 +00003364 (outs GR8 :$dst), (ins),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003365 "seta\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +00003366 [(set GR8:$dst, (X86setcc X86_COND_A, EFLAGS))]>,
Evan Cheng069287d2006-05-16 07:21:53 +00003367 TB; // GR8 = > signed
Chris Lattner3a173df2004-10-03 20:35:00 +00003368def SETAm : I<0x97, MRM0m,
Evan Cheng64d80e32007-07-19 01:14:50 +00003369 (outs), (ins i8mem:$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003370 "seta\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +00003371 [(store (X86setcc X86_COND_A, EFLAGS), addr:$dst)]>,
Evan Chengd5781fc2005-12-21 20:21:51 +00003372 TB; // [mem8] = > signed
Evan Chengd9558e02006-01-06 00:43:03 +00003373
Chris Lattner3a173df2004-10-03 20:35:00 +00003374def SETSr : I<0x98, MRM0r,
Evan Cheng64d80e32007-07-19 01:14:50 +00003375 (outs GR8 :$dst), (ins),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003376 "sets\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +00003377 [(set GR8:$dst, (X86setcc X86_COND_S, EFLAGS))]>,
Evan Cheng069287d2006-05-16 07:21:53 +00003378 TB; // GR8 = <sign bit>
Chris Lattner3a173df2004-10-03 20:35:00 +00003379def SETSm : I<0x98, MRM0m,
Evan Cheng64d80e32007-07-19 01:14:50 +00003380 (outs), (ins i8mem:$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003381 "sets\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +00003382 [(store (X86setcc X86_COND_S, EFLAGS), addr:$dst)]>,
Evan Chengd9558e02006-01-06 00:43:03 +00003383 TB; // [mem8] = <sign bit>
Chris Lattner3a173df2004-10-03 20:35:00 +00003384def SETNSr : I<0x99, MRM0r,
Evan Cheng64d80e32007-07-19 01:14:50 +00003385 (outs GR8 :$dst), (ins),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003386 "setns\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +00003387 [(set GR8:$dst, (X86setcc X86_COND_NS, EFLAGS))]>,
Evan Cheng069287d2006-05-16 07:21:53 +00003388 TB; // GR8 = !<sign bit>
Chris Lattner3a173df2004-10-03 20:35:00 +00003389def SETNSm : I<0x99, MRM0m,
Evan Cheng64d80e32007-07-19 01:14:50 +00003390 (outs), (ins i8mem:$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003391 "setns\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +00003392 [(store (X86setcc X86_COND_NS, EFLAGS), addr:$dst)]>,
Evan Chengd9558e02006-01-06 00:43:03 +00003393 TB; // [mem8] = !<sign bit>
Bill Wendling9f248742008-12-02 00:07:05 +00003394
Chris Lattner3a173df2004-10-03 20:35:00 +00003395def SETPr : I<0x9A, MRM0r,
Evan Cheng64d80e32007-07-19 01:14:50 +00003396 (outs GR8 :$dst), (ins),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003397 "setp\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +00003398 [(set GR8:$dst, (X86setcc X86_COND_P, EFLAGS))]>,
Evan Cheng069287d2006-05-16 07:21:53 +00003399 TB; // GR8 = parity
Chris Lattner3a173df2004-10-03 20:35:00 +00003400def SETPm : I<0x9A, MRM0m,
Evan Cheng64d80e32007-07-19 01:14:50 +00003401 (outs), (ins i8mem:$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003402 "setp\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +00003403 [(store (X86setcc X86_COND_P, EFLAGS), addr:$dst)]>,
Evan Chengd9558e02006-01-06 00:43:03 +00003404 TB; // [mem8] = parity
Chris Lattnercc65bee2005-01-02 02:35:46 +00003405def SETNPr : I<0x9B, MRM0r,
Evan Cheng64d80e32007-07-19 01:14:50 +00003406 (outs GR8 :$dst), (ins),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003407 "setnp\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +00003408 [(set GR8:$dst, (X86setcc X86_COND_NP, EFLAGS))]>,
Evan Cheng069287d2006-05-16 07:21:53 +00003409 TB; // GR8 = not parity
Chris Lattnercc65bee2005-01-02 02:35:46 +00003410def SETNPm : I<0x9B, MRM0m,
Evan Cheng64d80e32007-07-19 01:14:50 +00003411 (outs), (ins i8mem:$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003412 "setnp\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +00003413 [(store (X86setcc X86_COND_NP, EFLAGS), addr:$dst)]>,
Evan Chengd9558e02006-01-06 00:43:03 +00003414 TB; // [mem8] = not parity
Bill Wendling9f248742008-12-02 00:07:05 +00003415
3416def SETOr : I<0x90, MRM0r,
3417 (outs GR8 :$dst), (ins),
3418 "seto\t$dst",
3419 [(set GR8:$dst, (X86setcc X86_COND_O, EFLAGS))]>,
3420 TB; // GR8 = overflow
3421def SETOm : I<0x90, MRM0m,
3422 (outs), (ins i8mem:$dst),
3423 "seto\t$dst",
3424 [(store (X86setcc X86_COND_O, EFLAGS), addr:$dst)]>,
3425 TB; // [mem8] = overflow
3426def SETNOr : I<0x91, MRM0r,
3427 (outs GR8 :$dst), (ins),
3428 "setno\t$dst",
3429 [(set GR8:$dst, (X86setcc X86_COND_NO, EFLAGS))]>,
3430 TB; // GR8 = not overflow
3431def SETNOm : I<0x91, MRM0m,
3432 (outs), (ins i8mem:$dst),
3433 "setno\t$dst",
3434 [(store (X86setcc X86_COND_NO, EFLAGS), addr:$dst)]>,
3435 TB; // [mem8] = not overflow
Evan Cheng0488db92007-09-25 01:57:46 +00003436} // Uses = [EFLAGS]
3437
Chris Lattner1cca5e32003-08-03 21:54:21 +00003438
3439// Integer comparisons
Evan Cheng24f2ea32007-09-14 21:48:26 +00003440let Defs = [EFLAGS] in {
Sean Callanana09caa52009-09-02 00:55:49 +00003441def CMP8i8 : Ii8<0x3C, RawFrm, (outs), (ins i8imm:$src),
3442 "cmp{b}\t{$src, %al|%al, $src}", []>;
3443def CMP16i16 : Ii16<0x3D, RawFrm, (outs), (ins i16imm:$src),
3444 "cmp{w}\t{$src, %ax|%ax, $src}", []>, OpSize;
3445def CMP32i32 : Ii32<0x3D, RawFrm, (outs), (ins i32imm:$src),
3446 "cmp{l}\t{$src, %eax|%eax, $src}", []>;
3447
Chris Lattner3a173df2004-10-03 20:35:00 +00003448def CMP8rr : I<0x38, MRMDestReg,
Evan Cheng64d80e32007-07-19 01:14:50 +00003449 (outs), (ins GR8 :$src1, GR8 :$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003450 "cmp{b}\t{$src2, $src1|$src1, $src2}",
Evan Chenge5f62042007-09-29 00:00:36 +00003451 [(X86cmp GR8:$src1, GR8:$src2), (implicit EFLAGS)]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00003452def CMP16rr : I<0x39, MRMDestReg,
Evan Cheng64d80e32007-07-19 01:14:50 +00003453 (outs), (ins GR16:$src1, GR16:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003454 "cmp{w}\t{$src2, $src1|$src1, $src2}",
Evan Chenge5f62042007-09-29 00:00:36 +00003455 [(X86cmp GR16:$src1, GR16:$src2), (implicit EFLAGS)]>, OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00003456def CMP32rr : I<0x39, MRMDestReg,
Evan Cheng64d80e32007-07-19 01:14:50 +00003457 (outs), (ins GR32:$src1, GR32:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003458 "cmp{l}\t{$src2, $src1|$src1, $src2}",
Evan Chenge5f62042007-09-29 00:00:36 +00003459 [(X86cmp GR32:$src1, GR32:$src2), (implicit EFLAGS)]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00003460def CMP8mr : I<0x38, MRMDestMem,
Evan Cheng64d80e32007-07-19 01:14:50 +00003461 (outs), (ins i8mem :$src1, GR8 :$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003462 "cmp{b}\t{$src2, $src1|$src1, $src2}",
Evan Chenge5f62042007-09-29 00:00:36 +00003463 [(X86cmp (loadi8 addr:$src1), GR8:$src2),
3464 (implicit EFLAGS)]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00003465def CMP16mr : I<0x39, MRMDestMem,
Evan Cheng64d80e32007-07-19 01:14:50 +00003466 (outs), (ins i16mem:$src1, GR16:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003467 "cmp{w}\t{$src2, $src1|$src1, $src2}",
Evan Chenge5f62042007-09-29 00:00:36 +00003468 [(X86cmp (loadi16 addr:$src1), GR16:$src2),
3469 (implicit EFLAGS)]>, OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00003470def CMP32mr : I<0x39, MRMDestMem,
Evan Cheng64d80e32007-07-19 01:14:50 +00003471 (outs), (ins i32mem:$src1, GR32:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003472 "cmp{l}\t{$src2, $src1|$src1, $src2}",
Evan Chenge5f62042007-09-29 00:00:36 +00003473 [(X86cmp (loadi32 addr:$src1), GR32:$src2),
3474 (implicit EFLAGS)]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00003475def CMP8rm : I<0x3A, MRMSrcMem,
Evan Cheng64d80e32007-07-19 01:14:50 +00003476 (outs), (ins GR8 :$src1, i8mem :$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003477 "cmp{b}\t{$src2, $src1|$src1, $src2}",
Evan Chenge5f62042007-09-29 00:00:36 +00003478 [(X86cmp GR8:$src1, (loadi8 addr:$src2)),
3479 (implicit EFLAGS)]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00003480def CMP16rm : I<0x3B, MRMSrcMem,
Evan Cheng64d80e32007-07-19 01:14:50 +00003481 (outs), (ins GR16:$src1, i16mem:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003482 "cmp{w}\t{$src2, $src1|$src1, $src2}",
Evan Chenge5f62042007-09-29 00:00:36 +00003483 [(X86cmp GR16:$src1, (loadi16 addr:$src2)),
3484 (implicit EFLAGS)]>, OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00003485def CMP32rm : I<0x3B, MRMSrcMem,
Evan Cheng64d80e32007-07-19 01:14:50 +00003486 (outs), (ins GR32:$src1, i32mem:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003487 "cmp{l}\t{$src2, $src1|$src1, $src2}",
Evan Chenge5f62042007-09-29 00:00:36 +00003488 [(X86cmp GR32:$src1, (loadi32 addr:$src2)),
3489 (implicit EFLAGS)]>;
Sean Callanand2125a02009-09-16 21:11:23 +00003490def CMP8mrmrr : I<0x3A, MRMSrcReg, (outs), (ins GR8:$src1, GR8:$src2),
3491 "cmp{b}\t{$src2, $src1|$src1, $src2}", []>;
3492def CMP16mrmrr : I<0x3B, MRMSrcReg, (outs), (ins GR16:$src1, GR16:$src2),
3493 "cmp{w}\t{$src2, $src1|$src1, $src2}", []>, OpSize;
3494def CMP32mrmrr : I<0x3B, MRMSrcReg, (outs), (ins GR32:$src1, GR32:$src2),
3495 "cmp{l}\t{$src2, $src1|$src1, $src2}", []>;
Chris Lattner3a173df2004-10-03 20:35:00 +00003496def CMP8ri : Ii8<0x80, MRM7r,
Evan Cheng64d80e32007-07-19 01:14:50 +00003497 (outs), (ins GR8:$src1, i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003498 "cmp{b}\t{$src2, $src1|$src1, $src2}",
Evan Chenge5f62042007-09-29 00:00:36 +00003499 [(X86cmp GR8:$src1, imm:$src2), (implicit EFLAGS)]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00003500def CMP16ri : Ii16<0x81, MRM7r,
Evan Cheng64d80e32007-07-19 01:14:50 +00003501 (outs), (ins GR16:$src1, i16imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003502 "cmp{w}\t{$src2, $src1|$src1, $src2}",
Evan Chenge5f62042007-09-29 00:00:36 +00003503 [(X86cmp GR16:$src1, imm:$src2),
3504 (implicit EFLAGS)]>, OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00003505def CMP32ri : Ii32<0x81, MRM7r,
Evan Cheng64d80e32007-07-19 01:14:50 +00003506 (outs), (ins GR32:$src1, i32imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003507 "cmp{l}\t{$src2, $src1|$src1, $src2}",
Evan Chenge5f62042007-09-29 00:00:36 +00003508 [(X86cmp GR32:$src1, imm:$src2), (implicit EFLAGS)]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00003509def CMP8mi : Ii8 <0x80, MRM7m,
Evan Cheng64d80e32007-07-19 01:14:50 +00003510 (outs), (ins i8mem :$src1, i8imm :$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003511 "cmp{b}\t{$src2, $src1|$src1, $src2}",
Evan Chenge5f62042007-09-29 00:00:36 +00003512 [(X86cmp (loadi8 addr:$src1), imm:$src2),
3513 (implicit EFLAGS)]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00003514def CMP16mi : Ii16<0x81, MRM7m,
Evan Cheng64d80e32007-07-19 01:14:50 +00003515 (outs), (ins i16mem:$src1, i16imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003516 "cmp{w}\t{$src2, $src1|$src1, $src2}",
Evan Chenge5f62042007-09-29 00:00:36 +00003517 [(X86cmp (loadi16 addr:$src1), imm:$src2),
3518 (implicit EFLAGS)]>, OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00003519def CMP32mi : Ii32<0x81, MRM7m,
Evan Cheng64d80e32007-07-19 01:14:50 +00003520 (outs), (ins i32mem:$src1, i32imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003521 "cmp{l}\t{$src2, $src1|$src1, $src2}",
Evan Chenge5f62042007-09-29 00:00:36 +00003522 [(X86cmp (loadi32 addr:$src1), imm:$src2),
3523 (implicit EFLAGS)]>;
Chris Lattner29b4dd02006-03-23 16:13:50 +00003524def CMP16ri8 : Ii8<0x83, MRM7r,
Evan Cheng64d80e32007-07-19 01:14:50 +00003525 (outs), (ins GR16:$src1, i16i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003526 "cmp{w}\t{$src2, $src1|$src1, $src2}",
Evan Chenge5f62042007-09-29 00:00:36 +00003527 [(X86cmp GR16:$src1, i16immSExt8:$src2),
3528 (implicit EFLAGS)]>, OpSize;
Chris Lattner29b4dd02006-03-23 16:13:50 +00003529def CMP16mi8 : Ii8<0x83, MRM7m,
Evan Cheng64d80e32007-07-19 01:14:50 +00003530 (outs), (ins i16mem:$src1, i16i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003531 "cmp{w}\t{$src2, $src1|$src1, $src2}",
Evan Chenge5f62042007-09-29 00:00:36 +00003532 [(X86cmp (loadi16 addr:$src1), i16immSExt8:$src2),
3533 (implicit EFLAGS)]>, OpSize;
Chris Lattner29b4dd02006-03-23 16:13:50 +00003534def CMP32mi8 : Ii8<0x83, MRM7m,
Evan Cheng64d80e32007-07-19 01:14:50 +00003535 (outs), (ins i32mem:$src1, i32i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003536 "cmp{l}\t{$src2, $src1|$src1, $src2}",
Evan Chenge5f62042007-09-29 00:00:36 +00003537 [(X86cmp (loadi32 addr:$src1), i32immSExt8:$src2),
3538 (implicit EFLAGS)]>;
Chris Lattner29b4dd02006-03-23 16:13:50 +00003539def CMP32ri8 : Ii8<0x83, MRM7r,
Evan Cheng64d80e32007-07-19 01:14:50 +00003540 (outs), (ins GR32:$src1, i32i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003541 "cmp{l}\t{$src2, $src1|$src1, $src2}",
Evan Chenge5f62042007-09-29 00:00:36 +00003542 [(X86cmp GR32:$src1, i32immSExt8:$src2),
Evan Cheng0488db92007-09-25 01:57:46 +00003543 (implicit EFLAGS)]>;
3544} // Defs = [EFLAGS]
3545
Dan Gohmanc7a37d42008-12-23 22:45:23 +00003546// Bit tests.
Dan Gohmanc7a37d42008-12-23 22:45:23 +00003547// TODO: BTC, BTR, and BTS
3548let Defs = [EFLAGS] in {
Dan Gohman0c89b7e2009-01-13 20:32:45 +00003549def BT16rr : I<0xA3, MRMDestReg, (outs), (ins GR16:$src1, GR16:$src2),
Dan Gohmanc7a37d42008-12-23 22:45:23 +00003550 "bt{w}\t{$src2, $src1|$src1, $src2}",
3551 [(X86bt GR16:$src1, GR16:$src2),
Chris Lattnerf1e9fd52008-12-25 01:32:49 +00003552 (implicit EFLAGS)]>, OpSize, TB;
Dan Gohman0c89b7e2009-01-13 20:32:45 +00003553def BT32rr : I<0xA3, MRMDestReg, (outs), (ins GR32:$src1, GR32:$src2),
Dan Gohmanc7a37d42008-12-23 22:45:23 +00003554 "bt{l}\t{$src2, $src1|$src1, $src2}",
3555 [(X86bt GR32:$src1, GR32:$src2),
Chris Lattnerf1e9fd52008-12-25 01:32:49 +00003556 (implicit EFLAGS)]>, TB;
Dan Gohmanf31408d2009-01-13 23:23:30 +00003557
3558// Unlike with the register+register form, the memory+register form of the
3559// bt instruction does not ignore the high bits of the index. From ISel's
Sean Callanan108934c2009-12-18 00:01:26 +00003560// perspective, this is pretty bizarre. Make these instructions disassembly
3561// only for now.
3562
3563def BT16mr : I<0xA3, MRMDestMem, (outs), (ins i16mem:$src1, GR16:$src2),
3564 "bt{w}\t{$src2, $src1|$src1, $src2}",
Dan Gohmanf31408d2009-01-13 23:23:30 +00003565// [(X86bt (loadi16 addr:$src1), GR16:$src2),
Sean Callanan108934c2009-12-18 00:01:26 +00003566// (implicit EFLAGS)]
3567 []
3568 >, OpSize, TB, Requires<[FastBTMem]>;
3569def BT32mr : I<0xA3, MRMDestMem, (outs), (ins i32mem:$src1, GR32:$src2),
3570 "bt{l}\t{$src2, $src1|$src1, $src2}",
Dan Gohmanf31408d2009-01-13 23:23:30 +00003571// [(X86bt (loadi32 addr:$src1), GR32:$src2),
Sean Callanan108934c2009-12-18 00:01:26 +00003572// (implicit EFLAGS)]
3573 []
3574 >, TB, Requires<[FastBTMem]>;
Dan Gohman4afe15b2009-01-13 20:33:23 +00003575
3576def BT16ri8 : Ii8<0xBA, MRM4r, (outs), (ins GR16:$src1, i16i8imm:$src2),
3577 "bt{w}\t{$src2, $src1|$src1, $src2}",
3578 [(X86bt GR16:$src1, i16immSExt8:$src2),
3579 (implicit EFLAGS)]>, OpSize, TB;
3580def BT32ri8 : Ii8<0xBA, MRM4r, (outs), (ins GR32:$src1, i32i8imm:$src2),
3581 "bt{l}\t{$src2, $src1|$src1, $src2}",
3582 [(X86bt GR32:$src1, i32immSExt8:$src2),
3583 (implicit EFLAGS)]>, TB;
3584// Note that these instructions don't need FastBTMem because that
3585// only applies when the other operand is in a register. When it's
3586// an immediate, bt is still fast.
3587def BT16mi8 : Ii8<0xBA, MRM4m, (outs), (ins i16mem:$src1, i16i8imm:$src2),
3588 "bt{w}\t{$src2, $src1|$src1, $src2}",
3589 [(X86bt (loadi16 addr:$src1), i16immSExt8:$src2),
3590 (implicit EFLAGS)]>, OpSize, TB;
3591def BT32mi8 : Ii8<0xBA, MRM4m, (outs), (ins i32mem:$src1, i32i8imm:$src2),
3592 "bt{l}\t{$src2, $src1|$src1, $src2}",
3593 [(X86bt (loadi32 addr:$src1), i32immSExt8:$src2),
3594 (implicit EFLAGS)]>, TB;
Sean Callanan108934c2009-12-18 00:01:26 +00003595
3596def BTC16rr : I<0xBB, MRMDestReg, (outs), (ins GR16:$src1, GR16:$src2),
3597 "btc{w}\t{$src2, $src1|$src1, $src2}", []>, OpSize, TB;
3598def BTC32rr : I<0xBB, MRMDestReg, (outs), (ins GR32:$src1, GR32:$src2),
3599 "btc{l}\t{$src2, $src1|$src1, $src2}", []>, TB;
3600def BTC16mr : I<0xBB, MRMDestMem, (outs), (ins i16mem:$src1, GR16:$src2),
3601 "btc{w}\t{$src2, $src1|$src1, $src2}", []>, OpSize, TB;
3602def BTC32mr : I<0xBB, MRMDestMem, (outs), (ins i32mem:$src1, GR32:$src2),
3603 "btc{l}\t{$src2, $src1|$src1, $src2}", []>, TB;
3604def BTC16ri8 : Ii8<0xBA, MRM7r, (outs), (ins GR16:$src1, i16i8imm:$src2),
3605 "btc{w}\t{$src2, $src1|$src1, $src2}", []>, OpSize, TB;
3606def BTC32ri8 : Ii8<0xBA, MRM7r, (outs), (ins GR32:$src1, i32i8imm:$src2),
3607 "btc{l}\t{$src2, $src1|$src1, $src2}", []>, TB;
3608def BTC16mi8 : Ii8<0xBA, MRM7m, (outs), (ins i16mem:$src1, i16i8imm:$src2),
3609 "btc{w}\t{$src2, $src1|$src1, $src2}", []>, OpSize, TB;
3610def BTC32mi8 : Ii8<0xBA, MRM7m, (outs), (ins i32mem:$src1, i32i8imm:$src2),
3611 "btc{l}\t{$src2, $src1|$src1, $src2}", []>, TB;
3612
3613def BTR16rr : I<0xB3, MRMDestReg, (outs), (ins GR16:$src1, GR16:$src2),
3614 "btr{w}\t{$src2, $src1|$src1, $src2}", []>, OpSize, TB;
3615def BTR32rr : I<0xB3, MRMDestReg, (outs), (ins GR32:$src1, GR32:$src2),
3616 "btr{l}\t{$src2, $src1|$src1, $src2}", []>, TB;
3617def BTR16mr : I<0xB3, MRMDestMem, (outs), (ins i16mem:$src1, GR16:$src2),
3618 "btr{w}\t{$src2, $src1|$src1, $src2}", []>, OpSize, TB;
3619def BTR32mr : I<0xB3, MRMDestMem, (outs), (ins i32mem:$src1, GR32:$src2),
3620 "btr{l}\t{$src2, $src1|$src1, $src2}", []>, TB;
3621def BTR16ri8 : Ii8<0xBA, MRM6r, (outs), (ins GR16:$src1, i16i8imm:$src2),
3622 "btr{w}\t{$src2, $src1|$src1, $src2}", []>, OpSize, TB;
3623def BTR32ri8 : Ii8<0xBA, MRM6r, (outs), (ins GR32:$src1, i32i8imm:$src2),
3624 "btr{l}\t{$src2, $src1|$src1, $src2}", []>, TB;
3625def BTR16mi8 : Ii8<0xBA, MRM6m, (outs), (ins i16mem:$src1, i16i8imm:$src2),
3626 "btr{w}\t{$src2, $src1|$src1, $src2}", []>, OpSize, TB;
3627def BTR32mi8 : Ii8<0xBA, MRM6m, (outs), (ins i32mem:$src1, i32i8imm:$src2),
3628 "btr{l}\t{$src2, $src1|$src1, $src2}", []>, TB;
3629
3630def BTS16rr : I<0xAB, MRMDestReg, (outs), (ins GR16:$src1, GR16:$src2),
3631 "bts{w}\t{$src2, $src1|$src1, $src2}", []>, OpSize, TB;
3632def BTS32rr : I<0xAB, MRMDestReg, (outs), (ins GR32:$src1, GR32:$src2),
3633 "bts{l}\t{$src2, $src1|$src1, $src2}", []>, TB;
3634def BTS16mr : I<0xAB, MRMDestMem, (outs), (ins i16mem:$src1, GR16:$src2),
3635 "bts{w}\t{$src2, $src1|$src1, $src2}", []>, OpSize, TB;
3636def BTS32mr : I<0xAB, MRMDestMem, (outs), (ins i32mem:$src1, GR32:$src2),
3637 "bts{l}\t{$src2, $src1|$src1, $src2}", []>, TB;
3638def BTS16ri8 : Ii8<0xBA, MRM5r, (outs), (ins GR16:$src1, i16i8imm:$src2),
3639 "bts{w}\t{$src2, $src1|$src1, $src2}", []>, OpSize, TB;
3640def BTS32ri8 : Ii8<0xBA, MRM5r, (outs), (ins GR32:$src1, i32i8imm:$src2),
3641 "bts{l}\t{$src2, $src1|$src1, $src2}", []>, TB;
3642def BTS16mi8 : Ii8<0xBA, MRM5m, (outs), (ins i16mem:$src1, i16i8imm:$src2),
3643 "bts{w}\t{$src2, $src1|$src1, $src2}", []>, OpSize, TB;
3644def BTS32mi8 : Ii8<0xBA, MRM5m, (outs), (ins i32mem:$src1, i32i8imm:$src2),
3645 "bts{l}\t{$src2, $src1|$src1, $src2}", []>, TB;
Dan Gohmanc7a37d42008-12-23 22:45:23 +00003646} // Defs = [EFLAGS]
3647
Chris Lattner1cca5e32003-08-03 21:54:21 +00003648// Sign/Zero extenders
Dan Gohman11ba3b12008-07-30 18:09:17 +00003649// Use movsbl intead of movsbw; we don't care about the high 16 bits
3650// of the register here. This has a smaller encoding and avoids a
Sean Callanan108934c2009-12-18 00:01:26 +00003651// partial-register update. Actual movsbw included for the disassembler.
3652def MOVSX16rr8W : I<0xBE, MRMSrcReg, (outs GR16:$dst), (ins GR8:$src),
3653 "movs{bw|x}\t{$src, $dst|$dst, $src}", []>, TB, OpSize;
3654def MOVSX16rm8W : I<0xBE, MRMSrcMem, (outs GR16:$dst), (ins i8mem:$src),
3655 "movs{bw|x}\t{$src, $dst|$dst, $src}", []>, TB, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00003656def MOVSX16rr8 : I<0xBE, MRMSrcReg, (outs GR16:$dst), (ins GR8 :$src),
Chris Lattner172862a2009-10-19 19:51:42 +00003657 "", [(set GR16:$dst, (sext GR8:$src))]>, TB;
Evan Cheng64d80e32007-07-19 01:14:50 +00003658def MOVSX16rm8 : I<0xBE, MRMSrcMem, (outs GR16:$dst), (ins i8mem :$src),
Chris Lattner172862a2009-10-19 19:51:42 +00003659 "", [(set GR16:$dst, (sextloadi16i8 addr:$src))]>, TB;
Evan Cheng64d80e32007-07-19 01:14:50 +00003660def MOVSX32rr8 : I<0xBE, MRMSrcReg, (outs GR32:$dst), (ins GR8 :$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003661 "movs{bl|x}\t{$src, $dst|$dst, $src}",
Evan Cheng069287d2006-05-16 07:21:53 +00003662 [(set GR32:$dst, (sext GR8:$src))]>, TB;
Evan Cheng64d80e32007-07-19 01:14:50 +00003663def MOVSX32rm8 : I<0xBE, MRMSrcMem, (outs GR32:$dst), (ins i8mem :$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003664 "movs{bl|x}\t{$src, $dst|$dst, $src}",
Evan Cheng069287d2006-05-16 07:21:53 +00003665 [(set GR32:$dst, (sextloadi32i8 addr:$src))]>, TB;
Evan Cheng64d80e32007-07-19 01:14:50 +00003666def MOVSX32rr16: I<0xBF, MRMSrcReg, (outs GR32:$dst), (ins GR16:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003667 "movs{wl|x}\t{$src, $dst|$dst, $src}",
Evan Cheng069287d2006-05-16 07:21:53 +00003668 [(set GR32:$dst, (sext GR16:$src))]>, TB;
Evan Cheng64d80e32007-07-19 01:14:50 +00003669def MOVSX32rm16: I<0xBF, MRMSrcMem, (outs GR32:$dst), (ins i16mem:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003670 "movs{wl|x}\t{$src, $dst|$dst, $src}",
Evan Cheng069287d2006-05-16 07:21:53 +00003671 [(set GR32:$dst, (sextloadi32i16 addr:$src))]>, TB;
Alkis Evlogimenosa7be9822004-02-17 09:14:23 +00003672
Dan Gohman11ba3b12008-07-30 18:09:17 +00003673// Use movzbl intead of movzbw; we don't care about the high 16 bits
3674// of the register here. This has a smaller encoding and avoids a
Sean Callanan108934c2009-12-18 00:01:26 +00003675// partial-register update. Actual movzbw included for the disassembler.
3676def MOVZX16rr8W : I<0xB6, MRMSrcReg, (outs GR16:$dst), (ins GR8:$src),
3677 "movz{bw|x}\t{$src, $dst|$dst, $src}", []>, TB, OpSize;
3678def MOVZX16rm8W : I<0xB6, MRMSrcMem, (outs GR16:$dst), (ins i8mem:$src),
3679 "movz{bw|x}\t{$src, $dst|$dst, $src}", []>, TB, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00003680def MOVZX16rr8 : I<0xB6, MRMSrcReg, (outs GR16:$dst), (ins GR8 :$src),
Chris Lattner172862a2009-10-19 19:51:42 +00003681 "", [(set GR16:$dst, (zext GR8:$src))]>, TB;
Evan Cheng64d80e32007-07-19 01:14:50 +00003682def MOVZX16rm8 : I<0xB6, MRMSrcMem, (outs GR16:$dst), (ins i8mem :$src),
Chris Lattner172862a2009-10-19 19:51:42 +00003683 "", [(set GR16:$dst, (zextloadi16i8 addr:$src))]>, TB;
Evan Cheng64d80e32007-07-19 01:14:50 +00003684def MOVZX32rr8 : I<0xB6, MRMSrcReg, (outs GR32:$dst), (ins GR8 :$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003685 "movz{bl|x}\t{$src, $dst|$dst, $src}",
Evan Cheng069287d2006-05-16 07:21:53 +00003686 [(set GR32:$dst, (zext GR8:$src))]>, TB;
Evan Cheng64d80e32007-07-19 01:14:50 +00003687def MOVZX32rm8 : I<0xB6, MRMSrcMem, (outs GR32:$dst), (ins i8mem :$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003688 "movz{bl|x}\t{$src, $dst|$dst, $src}",
Evan Cheng069287d2006-05-16 07:21:53 +00003689 [(set GR32:$dst, (zextloadi32i8 addr:$src))]>, TB;
Evan Cheng64d80e32007-07-19 01:14:50 +00003690def MOVZX32rr16: I<0xB7, MRMSrcReg, (outs GR32:$dst), (ins GR16:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003691 "movz{wl|x}\t{$src, $dst|$dst, $src}",
Evan Cheng069287d2006-05-16 07:21:53 +00003692 [(set GR32:$dst, (zext GR16:$src))]>, TB;
Evan Cheng64d80e32007-07-19 01:14:50 +00003693def MOVZX32rm16: I<0xB7, MRMSrcMem, (outs GR32:$dst), (ins i16mem:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003694 "movz{wl|x}\t{$src, $dst|$dst, $src}",
Evan Cheng069287d2006-05-16 07:21:53 +00003695 [(set GR32:$dst, (zextloadi32i16 addr:$src))]>, TB;
Evan Cheng7a7e8372005-12-14 02:22:27 +00003696
Dan Gohman21e3dfb2009-04-13 16:09:41 +00003697// These are the same as the regular regular MOVZX32rr8 and MOVZX32rm8
3698// except that they use GR32_NOREX for the output operand register class
3699// instead of GR32. This allows them to operate on h registers on x86-64.
3700def MOVZX32_NOREXrr8 : I<0xB6, MRMSrcReg,
3701 (outs GR32_NOREX:$dst), (ins GR8:$src),
3702 "movz{bl|x}\t{$src, $dst|$dst, $src} # NOREX",
3703 []>, TB;
Dan Gohman78e04d42009-04-30 03:11:48 +00003704let mayLoad = 1 in
Dan Gohman21e3dfb2009-04-13 16:09:41 +00003705def MOVZX32_NOREXrm8 : I<0xB6, MRMSrcMem,
3706 (outs GR32_NOREX:$dst), (ins i8mem:$src),
3707 "movz{bl|x}\t{$src, $dst|$dst, $src} # NOREX",
3708 []>, TB;
3709
Chris Lattnerba7e7562008-01-10 07:59:24 +00003710let neverHasSideEffects = 1 in {
3711 let Defs = [AX], Uses = [AL] in
3712 def CBW : I<0x98, RawFrm, (outs), (ins),
3713 "{cbtw|cbw}", []>, OpSize; // AX = signext(AL)
3714 let Defs = [EAX], Uses = [AX] in
3715 def CWDE : I<0x98, RawFrm, (outs), (ins),
3716 "{cwtl|cwde}", []>; // EAX = signext(AX)
Evan Chengf91c1012006-05-31 22:05:11 +00003717
Chris Lattnerba7e7562008-01-10 07:59:24 +00003718 let Defs = [AX,DX], Uses = [AX] in
3719 def CWD : I<0x99, RawFrm, (outs), (ins),
3720 "{cwtd|cwd}", []>, OpSize; // DX:AX = signext(AX)
3721 let Defs = [EAX,EDX], Uses = [EAX] in
3722 def CDQ : I<0x99, RawFrm, (outs), (ins),
3723 "{cltd|cdq}", []>; // EDX:EAX = signext(EAX)
3724}
Evan Cheng747a90d2006-02-21 02:24:38 +00003725
Evan Cheng747a90d2006-02-21 02:24:38 +00003726//===----------------------------------------------------------------------===//
3727// Alias Instructions
3728//===----------------------------------------------------------------------===//
3729
3730// Alias instructions that map movr0 to xor.
3731// FIXME: remove when we can teach regalloc that xor reg, reg is ok.
Daniel Dunbar7417b762009-08-11 22:17:52 +00003732let Defs = [EFLAGS], isReMaterializable = 1, isAsCheapAsAMove = 1,
3733 isCodeGenOnly = 1 in {
Evan Cheng64d80e32007-07-19 01:14:50 +00003734def MOV8r0 : I<0x30, MRMInitReg, (outs GR8 :$dst), (ins),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003735 "xor{b}\t$dst, $dst",
Evan Cheng069287d2006-05-16 07:21:53 +00003736 [(set GR8:$dst, 0)]>;
Dan Gohmanf1b4d262010-01-12 04:42:54 +00003737
3738// We want to rewrite MOV16r0 in terms of MOV32r0, because it's a smaller
3739// encoding and avoids a partial-register update sometimes, but doing so
3740// at isel time interferes with rematerialization in the current register
3741// allocator. For now, this is rewritten when the instruction is lowered
3742// to an MCInst.
3743def MOV16r0 : I<0x31, MRMInitReg, (outs GR16:$dst), (ins),
3744 "",
3745 [(set GR16:$dst, 0)]>, OpSize;
Chris Lattner6a381822009-12-23 01:30:26 +00003746
Chris Lattnerac105c42009-12-23 01:46:40 +00003747def MOV32r0 : I<0x31, MRMInitReg, (outs GR32:$dst), (ins),
3748 "xor{l}\t$dst, $dst",
3749 [(set GR32:$dst, 0)]>;
3750}
Chris Lattner6a381822009-12-23 01:30:26 +00003751
Evan Cheng510e4782006-01-09 23:10:28 +00003752//===----------------------------------------------------------------------===//
Lauro Ramos Venanciob3a04172007-04-20 21:38:10 +00003753// Thread Local Storage Instructions
3754//
3755
Rafael Espindola15f1b662009-04-24 12:59:40 +00003756// All calls clobber the non-callee saved registers. ESP is marked as
3757// a use to prevent stack-pointer assignments that appear immediately
3758// before calls from potentially appearing dead.
3759let Defs = [EAX, ECX, EDX, FP0, FP1, FP2, FP3, FP4, FP5, FP6, ST0,
3760 MM0, MM1, MM2, MM3, MM4, MM5, MM6, MM7,
3761 XMM0, XMM1, XMM2, XMM3, XMM4, XMM5, XMM6, XMM7,
3762 XMM8, XMM9, XMM10, XMM11, XMM12, XMM13, XMM14, XMM15, EFLAGS],
Chris Lattner5c0b16d2009-06-20 20:38:48 +00003763 Uses = [ESP] in
3764def TLS_addr32 : I<0, Pseudo, (outs), (ins lea32mem:$sym),
3765 "leal\t$sym, %eax; "
Dan Gohman4d47b9b2009-04-27 15:13:28 +00003766 "call\t___tls_get_addr@PLT",
Chris Lattner5c0b16d2009-06-20 20:38:48 +00003767 [(X86tlsaddr tls32addr:$sym)]>,
Rafael Espindola2ee3db32009-04-17 14:35:58 +00003768 Requires<[In32BitMode]>;
Lauro Ramos Venanciob3a04172007-04-20 21:38:10 +00003769
Daniel Dunbar0c420fc2009-08-11 22:24:40 +00003770let AddedComplexity = 5, isCodeGenOnly = 1 in
Nate Begeman51a04372009-01-26 01:24:32 +00003771def GS_MOV32rm : I<0x8B, MRMSrcMem, (outs GR32:$dst), (ins i32mem:$src),
3772 "movl\t%gs:$src, $dst",
3773 [(set GR32:$dst, (gsload addr:$src))]>, SegGS;
3774
Daniel Dunbar0c420fc2009-08-11 22:24:40 +00003775let AddedComplexity = 5, isCodeGenOnly = 1 in
Chris Lattner1777d0c2009-05-05 18:52:19 +00003776def FS_MOV32rm : I<0x8B, MRMSrcMem, (outs GR32:$dst), (ins i32mem:$src),
3777 "movl\t%fs:$src, $dst",
3778 [(set GR32:$dst, (fsload addr:$src))]>, SegFS;
3779
Lauro Ramos Venanciob3a04172007-04-20 21:38:10 +00003780//===----------------------------------------------------------------------===//
Anton Korobeynikov2365f512007-07-14 14:06:15 +00003781// EH Pseudo Instructions
3782//
3783let isTerminator = 1, isReturn = 1, isBarrier = 1,
Daniel Dunbar1ca3a0b2009-08-27 07:58:05 +00003784 hasCtrlDep = 1, isCodeGenOnly = 1 in {
Evan Cheng64d80e32007-07-19 01:14:50 +00003785def EH_RETURN : I<0xC3, RawFrm, (outs), (ins GR32:$addr),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003786 "ret\t#eh_return, addr: $addr",
Anton Korobeynikov2365f512007-07-14 14:06:15 +00003787 [(X86ehret GR32:$addr)]>;
3788
3789}
3790
3791//===----------------------------------------------------------------------===//
Andrew Lenharthab0b9492008-02-21 06:45:13 +00003792// Atomic support
3793//
Andrew Lenharthea7da502008-03-01 13:37:02 +00003794
Evan Chengbb6939d2008-04-19 01:20:30 +00003795// Atomic swap. These are just normal xchg instructions. But since a memory
3796// operand is referenced, the atomicity is ensured.
Dan Gohman165660e2008-08-06 15:52:50 +00003797let Constraints = "$val = $dst" in {
Sean Callanan108934c2009-12-18 00:01:26 +00003798def XCHG32rm : I<0x87, MRMSrcMem, (outs GR32:$dst),
3799 (ins GR32:$val, i32mem:$ptr),
Evan Chengbb6939d2008-04-19 01:20:30 +00003800 "xchg{l}\t{$val, $ptr|$ptr, $val}",
3801 [(set GR32:$dst, (atomic_swap_32 addr:$ptr, GR32:$val))]>;
Sean Callanan108934c2009-12-18 00:01:26 +00003802def XCHG16rm : I<0x87, MRMSrcMem, (outs GR16:$dst),
3803 (ins GR16:$val, i16mem:$ptr),
Evan Chengbb6939d2008-04-19 01:20:30 +00003804 "xchg{w}\t{$val, $ptr|$ptr, $val}",
3805 [(set GR16:$dst, (atomic_swap_16 addr:$ptr, GR16:$val))]>,
3806 OpSize;
Sean Callanan108934c2009-12-18 00:01:26 +00003807def XCHG8rm : I<0x86, MRMSrcMem, (outs GR8:$dst), (ins GR8:$val, i8mem:$ptr),
Evan Chengbb6939d2008-04-19 01:20:30 +00003808 "xchg{b}\t{$val, $ptr|$ptr, $val}",
3809 [(set GR8:$dst, (atomic_swap_8 addr:$ptr, GR8:$val))]>;
Sean Callanan108934c2009-12-18 00:01:26 +00003810
3811def XCHG32rr : I<0x87, MRMSrcReg, (outs GR32:$dst), (ins GR32:$val, GR32:$src),
3812 "xchg{l}\t{$val, $src|$src, $val}", []>;
3813def XCHG16rr : I<0x87, MRMSrcReg, (outs GR16:$dst), (ins GR16:$val, GR16:$src),
3814 "xchg{w}\t{$val, $src|$src, $val}", []>, OpSize;
3815def XCHG8rr : I<0x86, MRMSrcReg, (outs GR8:$dst), (ins GR8:$val, GR8:$src),
3816 "xchg{b}\t{$val, $src|$src, $val}", []>;
Evan Chengbb6939d2008-04-19 01:20:30 +00003817}
3818
Sean Callanan108934c2009-12-18 00:01:26 +00003819def XCHG16ar : I<0x90, AddRegFrm, (outs), (ins GR16:$src),
3820 "xchg{w}\t{$src, %ax|%ax, $src}", []>, OpSize;
3821def XCHG32ar : I<0x90, AddRegFrm, (outs), (ins GR32:$src),
3822 "xchg{l}\t{$src, %eax|%eax, $src}", []>;
3823
Evan Cheng7e032802008-04-18 20:55:36 +00003824// Atomic compare and swap.
Andrew Lenharth26ed8692008-03-01 21:52:34 +00003825let Defs = [EAX, EFLAGS], Uses = [EAX] in {
Evan Cheng7e032802008-04-18 20:55:36 +00003826def LCMPXCHG32 : I<0xB1, MRMDestMem, (outs), (ins i32mem:$ptr, GR32:$swap),
Dan Gohman4d47b9b2009-04-27 15:13:28 +00003827 "lock\n\t"
3828 "cmpxchg{l}\t{$swap, $ptr|$ptr, $swap}",
Evan Cheng32967d22008-03-04 03:20:06 +00003829 [(X86cas addr:$ptr, GR32:$swap, 4)]>, TB, LOCK;
Andrew Lenharthea7da502008-03-01 13:37:02 +00003830}
Dale Johannesen48c1bc22008-10-02 18:53:47 +00003831let Defs = [EAX, EDX, EFLAGS], Uses = [EAX, EBX, ECX, EDX] in {
Evan Chengb093bd02010-01-08 01:29:19 +00003832def LCMPXCHG8B : I<0xC7, MRM1m, (outs), (ins i64mem:$ptr),
Dan Gohman4d47b9b2009-04-27 15:13:28 +00003833 "lock\n\t"
3834 "cmpxchg8b\t$ptr",
Andrew Lenharthd19189e2008-03-05 01:15:49 +00003835 [(X86cas8 addr:$ptr)]>, TB, LOCK;
3836}
Andrew Lenharth26ed8692008-03-01 21:52:34 +00003837
3838let Defs = [AX, EFLAGS], Uses = [AX] in {
Evan Cheng7e032802008-04-18 20:55:36 +00003839def LCMPXCHG16 : I<0xB1, MRMDestMem, (outs), (ins i16mem:$ptr, GR16:$swap),
Dan Gohman4d47b9b2009-04-27 15:13:28 +00003840 "lock\n\t"
3841 "cmpxchg{w}\t{$swap, $ptr|$ptr, $swap}",
Evan Cheng32967d22008-03-04 03:20:06 +00003842 [(X86cas addr:$ptr, GR16:$swap, 2)]>, TB, OpSize, LOCK;
Andrew Lenharthea7da502008-03-01 13:37:02 +00003843}
Andrew Lenharth26ed8692008-03-01 21:52:34 +00003844let Defs = [AL, EFLAGS], Uses = [AL] in {
Evan Cheng7e032802008-04-18 20:55:36 +00003845def LCMPXCHG8 : I<0xB0, MRMDestMem, (outs), (ins i8mem:$ptr, GR8:$swap),
Dan Gohman4d47b9b2009-04-27 15:13:28 +00003846 "lock\n\t"
3847 "cmpxchg{b}\t{$swap, $ptr|$ptr, $swap}",
Evan Cheng32967d22008-03-04 03:20:06 +00003848 [(X86cas addr:$ptr, GR8:$swap, 1)]>, TB, LOCK;
Andrew Lenharthea7da502008-03-01 13:37:02 +00003849}
3850
Evan Cheng7e032802008-04-18 20:55:36 +00003851// Atomic exchange and add
3852let Constraints = "$val = $dst", Defs = [EFLAGS] in {
Sean Callanan108934c2009-12-18 00:01:26 +00003853def LXADD32 : I<0xC1, MRMSrcMem, (outs GR32:$dst), (ins GR32:$val, i32mem:$ptr),
Dan Gohman4d47b9b2009-04-27 15:13:28 +00003854 "lock\n\t"
3855 "xadd{l}\t{$val, $ptr|$ptr, $val}",
Mon P Wang28873102008-06-25 08:15:39 +00003856 [(set GR32:$dst, (atomic_load_add_32 addr:$ptr, GR32:$val))]>,
Evan Cheng7e032802008-04-18 20:55:36 +00003857 TB, LOCK;
Sean Callanan108934c2009-12-18 00:01:26 +00003858def LXADD16 : I<0xC1, MRMSrcMem, (outs GR16:$dst), (ins GR16:$val, i16mem:$ptr),
Dan Gohman4d47b9b2009-04-27 15:13:28 +00003859 "lock\n\t"
3860 "xadd{w}\t{$val, $ptr|$ptr, $val}",
Mon P Wang28873102008-06-25 08:15:39 +00003861 [(set GR16:$dst, (atomic_load_add_16 addr:$ptr, GR16:$val))]>,
Evan Cheng7e032802008-04-18 20:55:36 +00003862 TB, OpSize, LOCK;
Sean Callanan108934c2009-12-18 00:01:26 +00003863def LXADD8 : I<0xC0, MRMSrcMem, (outs GR8:$dst), (ins GR8:$val, i8mem:$ptr),
Dan Gohman4d47b9b2009-04-27 15:13:28 +00003864 "lock\n\t"
3865 "xadd{b}\t{$val, $ptr|$ptr, $val}",
Mon P Wang28873102008-06-25 08:15:39 +00003866 [(set GR8:$dst, (atomic_load_add_8 addr:$ptr, GR8:$val))]>,
Evan Cheng7e032802008-04-18 20:55:36 +00003867 TB, LOCK;
Andrew Lenharthea7da502008-03-01 13:37:02 +00003868}
3869
Sean Callanan108934c2009-12-18 00:01:26 +00003870def XADD8rr : I<0xC0, MRMDestReg, (outs GR8:$dst), (ins GR8:$src),
3871 "xadd{b}\t{$src, $dst|$dst, $src}", []>, TB;
3872def XADD16rr : I<0xC1, MRMDestReg, (outs GR16:$dst), (ins GR16:$src),
3873 "xadd{w}\t{$src, $dst|$dst, $src}", []>, TB, OpSize;
3874def XADD32rr : I<0xC1, MRMDestReg, (outs GR32:$dst), (ins GR32:$src),
3875 "xadd{l}\t{$src, $dst|$dst, $src}", []>, TB;
3876
3877def XADD8rm : I<0xC0, MRMDestMem, (outs), (ins i8mem:$dst, GR8:$src),
3878 "xadd{b}\t{$src, $dst|$dst, $src}", []>, TB;
3879def XADD16rm : I<0xC1, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src),
3880 "xadd{w}\t{$src, $dst|$dst, $src}", []>, TB, OpSize;
3881def XADD32rm : I<0xC1, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src),
3882 "xadd{l}\t{$src, $dst|$dst, $src}", []>, TB;
3883
3884def CMPXCHG8rr : I<0xB0, MRMDestReg, (outs GR8:$dst), (ins GR8:$src),
3885 "cmpxchg{b}\t{$src, $dst|$dst, $src}", []>, TB;
3886def CMPXCHG16rr : I<0xB1, MRMDestReg, (outs GR16:$dst), (ins GR16:$src),
3887 "cmpxchg{w}\t{$src, $dst|$dst, $src}", []>, TB, OpSize;
3888def CMPXCHG32rr : I<0xB1, MRMDestReg, (outs GR32:$dst), (ins GR32:$src),
3889 "cmpxchg{l}\t{$src, $dst|$dst, $src}", []>, TB;
3890
3891def CMPXCHG8rm : I<0xB0, MRMDestMem, (outs), (ins i8mem:$dst, GR8:$src),
3892 "cmpxchg{b}\t{$src, $dst|$dst, $src}", []>, TB;
3893def CMPXCHG16rm : I<0xB1, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src),
3894 "cmpxchg{w}\t{$src, $dst|$dst, $src}", []>, TB, OpSize;
3895def CMPXCHG32rm : I<0xB1, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src),
3896 "cmpxchg{l}\t{$src, $dst|$dst, $src}", []>, TB;
3897
Evan Chengb093bd02010-01-08 01:29:19 +00003898let Defs = [EAX, EDX, EFLAGS], Uses = [EAX, EBX, ECX, EDX] in
Sean Callanan108934c2009-12-18 00:01:26 +00003899def CMPXCHG8B : I<0xC7, MRM1m, (outs), (ins i64mem:$dst),
3900 "cmpxchg8b\t$dst", []>, TB;
3901
Evan Cheng37b73872009-07-30 08:33:02 +00003902// Optimized codegen when the non-memory output is not used.
3903// FIXME: Use normal add / sub instructions and add lock prefix dynamically.
Dan Gohmanbab42bd2009-10-20 18:14:49 +00003904let Defs = [EFLAGS] in {
Evan Cheng37b73872009-07-30 08:33:02 +00003905def LOCK_ADD8mr : I<0x00, MRMDestMem, (outs), (ins i8mem:$dst, GR8:$src2),
3906 "lock\n\t"
3907 "add{b}\t{$src2, $dst|$dst, $src2}", []>, LOCK;
3908def LOCK_ADD16mr : I<0x01, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
3909 "lock\n\t"
3910 "add{w}\t{$src2, $dst|$dst, $src2}", []>, OpSize, LOCK;
3911def LOCK_ADD32mr : I<0x01, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
3912 "lock\n\t"
3913 "add{l}\t{$src2, $dst|$dst, $src2}", []>, LOCK;
3914def LOCK_ADD8mi : Ii8<0x80, MRM0m, (outs), (ins i8mem :$dst, i8imm :$src2),
3915 "lock\n\t"
3916 "add{b}\t{$src2, $dst|$dst, $src2}", []>, LOCK;
3917def LOCK_ADD16mi : Ii16<0x81, MRM0m, (outs), (ins i16mem:$dst, i16imm:$src2),
3918 "lock\n\t"
3919 "add{w}\t{$src2, $dst|$dst, $src2}", []>, LOCK;
3920def LOCK_ADD32mi : Ii32<0x81, MRM0m, (outs), (ins i32mem:$dst, i32imm:$src2),
3921 "lock\n\t"
3922 "add{l}\t{$src2, $dst|$dst, $src2}", []>, LOCK;
3923def LOCK_ADD16mi8 : Ii8<0x83, MRM0m, (outs), (ins i16mem:$dst, i16i8imm :$src2),
3924 "lock\n\t"
3925 "add{w}\t{$src2, $dst|$dst, $src2}", []>, OpSize, LOCK;
3926def LOCK_ADD32mi8 : Ii8<0x83, MRM0m, (outs), (ins i32mem:$dst, i32i8imm :$src2),
3927 "lock\n\t"
3928 "add{l}\t{$src2, $dst|$dst, $src2}", []>, LOCK;
3929
3930def LOCK_INC8m : I<0xFE, MRM0m, (outs), (ins i8mem :$dst),
3931 "lock\n\t"
3932 "inc{b}\t$dst", []>, LOCK;
3933def LOCK_INC16m : I<0xFF, MRM0m, (outs), (ins i16mem:$dst),
3934 "lock\n\t"
3935 "inc{w}\t$dst", []>, OpSize, LOCK;
3936def LOCK_INC32m : I<0xFF, MRM0m, (outs), (ins i32mem:$dst),
3937 "lock\n\t"
3938 "inc{l}\t$dst", []>, LOCK;
3939
3940def LOCK_SUB8mr : I<0x28, MRMDestMem, (outs), (ins i8mem :$dst, GR8 :$src2),
3941 "lock\n\t"
3942 "sub{b}\t{$src2, $dst|$dst, $src2}", []>, LOCK;
3943def LOCK_SUB16mr : I<0x29, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
3944 "lock\n\t"
3945 "sub{w}\t{$src2, $dst|$dst, $src2}", []>, OpSize, LOCK;
3946def LOCK_SUB32mr : I<0x29, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
3947 "lock\n\t"
3948 "sub{l}\t{$src2, $dst|$dst, $src2}", []>, LOCK;
3949def LOCK_SUB8mi : Ii8<0x80, MRM5m, (outs), (ins i8mem :$dst, i8imm:$src2),
3950 "lock\n\t"
3951 "sub{b}\t{$src2, $dst|$dst, $src2}", []>, LOCK;
3952def LOCK_SUB16mi : Ii16<0x81, MRM5m, (outs), (ins i16mem:$dst, i16imm:$src2),
3953 "lock\n\t"
3954 "sub{w}\t{$src2, $dst|$dst, $src2}", []>, OpSize, LOCK;
3955def LOCK_SUB32mi : Ii32<0x81, MRM5m, (outs), (ins i32mem:$dst, i32imm:$src2),
3956 "lock\n\t"
3957 "sub{l}\t{$src2, $dst|$dst, $src2}", []>, LOCK;
Sean Callanan108934c2009-12-18 00:01:26 +00003958def LOCK_SUB16mi8 : Ii8<0x83, MRM5m, (outs), (ins i16mem:$dst, i16i8imm :$src2),
Evan Cheng37b73872009-07-30 08:33:02 +00003959 "lock\n\t"
3960 "sub{w}\t{$src2, $dst|$dst, $src2}", []>, OpSize, LOCK;
3961def LOCK_SUB32mi8 : Ii8<0x83, MRM5m, (outs), (ins i32mem:$dst, i32i8imm :$src2),
3962 "lock\n\t"
3963 "sub{l}\t{$src2, $dst|$dst, $src2}", []>, LOCK;
3964
3965def LOCK_DEC8m : I<0xFE, MRM1m, (outs), (ins i8mem :$dst),
3966 "lock\n\t"
3967 "dec{b}\t$dst", []>, LOCK;
3968def LOCK_DEC16m : I<0xFF, MRM1m, (outs), (ins i16mem:$dst),
3969 "lock\n\t"
3970 "dec{w}\t$dst", []>, OpSize, LOCK;
3971def LOCK_DEC32m : I<0xFF, MRM1m, (outs), (ins i32mem:$dst),
3972 "lock\n\t"
3973 "dec{l}\t$dst", []>, LOCK;
Dan Gohmanbab42bd2009-10-20 18:14:49 +00003974}
Evan Cheng37b73872009-07-30 08:33:02 +00003975
Mon P Wang28873102008-06-25 08:15:39 +00003976// Atomic exchange, and, or, xor
Mon P Wang63307c32008-05-05 19:05:59 +00003977let Constraints = "$val = $dst", Defs = [EFLAGS],
Dan Gohman533297b2009-10-29 18:10:34 +00003978 usesCustomInserter = 1 in {
Dan Gohman9499b712008-05-12 20:22:45 +00003979def ATOMAND32 : I<0, Pseudo, (outs GR32:$dst),(ins i32mem:$ptr, GR32:$val),
Nick Lewycky6ecf5ce2008-12-07 03:49:52 +00003980 "#ATOMAND32 PSEUDO!",
Dale Johannesene00a8a22008-08-28 02:44:49 +00003981 [(set GR32:$dst, (atomic_load_and_32 addr:$ptr, GR32:$val))]>;
Dan Gohman9499b712008-05-12 20:22:45 +00003982def ATOMOR32 : I<0, Pseudo, (outs GR32:$dst),(ins i32mem:$ptr, GR32:$val),
Nick Lewycky6ecf5ce2008-12-07 03:49:52 +00003983 "#ATOMOR32 PSEUDO!",
Dale Johannesene00a8a22008-08-28 02:44:49 +00003984 [(set GR32:$dst, (atomic_load_or_32 addr:$ptr, GR32:$val))]>;
Dan Gohman9499b712008-05-12 20:22:45 +00003985def ATOMXOR32 : I<0, Pseudo,(outs GR32:$dst),(ins i32mem:$ptr, GR32:$val),
Nick Lewycky6ecf5ce2008-12-07 03:49:52 +00003986 "#ATOMXOR32 PSEUDO!",
Dale Johannesene00a8a22008-08-28 02:44:49 +00003987 [(set GR32:$dst, (atomic_load_xor_32 addr:$ptr, GR32:$val))]>;
Andrew Lenharth507a58a2008-06-14 05:48:15 +00003988def ATOMNAND32 : I<0, Pseudo,(outs GR32:$dst),(ins i32mem:$ptr, GR32:$val),
Nick Lewycky6ecf5ce2008-12-07 03:49:52 +00003989 "#ATOMNAND32 PSEUDO!",
Dale Johannesene00a8a22008-08-28 02:44:49 +00003990 [(set GR32:$dst, (atomic_load_nand_32 addr:$ptr, GR32:$val))]>;
Dan Gohman9499b712008-05-12 20:22:45 +00003991def ATOMMIN32: I<0, Pseudo, (outs GR32:$dst), (ins i32mem:$ptr, GR32:$val),
Nick Lewycky6ecf5ce2008-12-07 03:49:52 +00003992 "#ATOMMIN32 PSEUDO!",
Dale Johannesene00a8a22008-08-28 02:44:49 +00003993 [(set GR32:$dst, (atomic_load_min_32 addr:$ptr, GR32:$val))]>;
Dan Gohman9499b712008-05-12 20:22:45 +00003994def ATOMMAX32: I<0, Pseudo, (outs GR32:$dst),(ins i32mem:$ptr, GR32:$val),
Nick Lewycky6ecf5ce2008-12-07 03:49:52 +00003995 "#ATOMMAX32 PSEUDO!",
Dale Johannesene00a8a22008-08-28 02:44:49 +00003996 [(set GR32:$dst, (atomic_load_max_32 addr:$ptr, GR32:$val))]>;
Dan Gohman9499b712008-05-12 20:22:45 +00003997def ATOMUMIN32: I<0, Pseudo, (outs GR32:$dst),(ins i32mem:$ptr, GR32:$val),
Nick Lewycky6ecf5ce2008-12-07 03:49:52 +00003998 "#ATOMUMIN32 PSEUDO!",
Dale Johannesene00a8a22008-08-28 02:44:49 +00003999 [(set GR32:$dst, (atomic_load_umin_32 addr:$ptr, GR32:$val))]>;
Dan Gohman9499b712008-05-12 20:22:45 +00004000def ATOMUMAX32: I<0, Pseudo, (outs GR32:$dst),(ins i32mem:$ptr, GR32:$val),
Nick Lewycky6ecf5ce2008-12-07 03:49:52 +00004001 "#ATOMUMAX32 PSEUDO!",
Dale Johannesene00a8a22008-08-28 02:44:49 +00004002 [(set GR32:$dst, (atomic_load_umax_32 addr:$ptr, GR32:$val))]>;
Dale Johannesen140be2d2008-08-19 18:47:28 +00004003
4004def ATOMAND16 : I<0, Pseudo, (outs GR16:$dst),(ins i16mem:$ptr, GR16:$val),
Nick Lewycky6ecf5ce2008-12-07 03:49:52 +00004005 "#ATOMAND16 PSEUDO!",
Dale Johannesene00a8a22008-08-28 02:44:49 +00004006 [(set GR16:$dst, (atomic_load_and_16 addr:$ptr, GR16:$val))]>;
Dale Johannesen140be2d2008-08-19 18:47:28 +00004007def ATOMOR16 : I<0, Pseudo, (outs GR16:$dst),(ins i16mem:$ptr, GR16:$val),
Nick Lewycky6ecf5ce2008-12-07 03:49:52 +00004008 "#ATOMOR16 PSEUDO!",
Dale Johannesene00a8a22008-08-28 02:44:49 +00004009 [(set GR16:$dst, (atomic_load_or_16 addr:$ptr, GR16:$val))]>;
Dale Johannesen140be2d2008-08-19 18:47:28 +00004010def ATOMXOR16 : I<0, Pseudo,(outs GR16:$dst),(ins i16mem:$ptr, GR16:$val),
Nick Lewycky6ecf5ce2008-12-07 03:49:52 +00004011 "#ATOMXOR16 PSEUDO!",
Dale Johannesene00a8a22008-08-28 02:44:49 +00004012 [(set GR16:$dst, (atomic_load_xor_16 addr:$ptr, GR16:$val))]>;
Dale Johannesen140be2d2008-08-19 18:47:28 +00004013def ATOMNAND16 : I<0, Pseudo,(outs GR16:$dst),(ins i16mem:$ptr, GR16:$val),
Nick Lewycky6ecf5ce2008-12-07 03:49:52 +00004014 "#ATOMNAND16 PSEUDO!",
Dale Johannesene00a8a22008-08-28 02:44:49 +00004015 [(set GR16:$dst, (atomic_load_nand_16 addr:$ptr, GR16:$val))]>;
Dale Johannesen140be2d2008-08-19 18:47:28 +00004016def ATOMMIN16: I<0, Pseudo, (outs GR16:$dst), (ins i16mem:$ptr, GR16:$val),
Nick Lewycky6ecf5ce2008-12-07 03:49:52 +00004017 "#ATOMMIN16 PSEUDO!",
Dale Johannesene00a8a22008-08-28 02:44:49 +00004018 [(set GR16:$dst, (atomic_load_min_16 addr:$ptr, GR16:$val))]>;
Dale Johannesen140be2d2008-08-19 18:47:28 +00004019def ATOMMAX16: I<0, Pseudo, (outs GR16:$dst),(ins i16mem:$ptr, GR16:$val),
Nick Lewycky6ecf5ce2008-12-07 03:49:52 +00004020 "#ATOMMAX16 PSEUDO!",
Dale Johannesene00a8a22008-08-28 02:44:49 +00004021 [(set GR16:$dst, (atomic_load_max_16 addr:$ptr, GR16:$val))]>;
Dale Johannesen140be2d2008-08-19 18:47:28 +00004022def ATOMUMIN16: I<0, Pseudo, (outs GR16:$dst),(ins i16mem:$ptr, GR16:$val),
Nick Lewycky6ecf5ce2008-12-07 03:49:52 +00004023 "#ATOMUMIN16 PSEUDO!",
Dale Johannesene00a8a22008-08-28 02:44:49 +00004024 [(set GR16:$dst, (atomic_load_umin_16 addr:$ptr, GR16:$val))]>;
Dale Johannesen140be2d2008-08-19 18:47:28 +00004025def ATOMUMAX16: I<0, Pseudo, (outs GR16:$dst),(ins i16mem:$ptr, GR16:$val),
Nick Lewycky6ecf5ce2008-12-07 03:49:52 +00004026 "#ATOMUMAX16 PSEUDO!",
Dale Johannesene00a8a22008-08-28 02:44:49 +00004027 [(set GR16:$dst, (atomic_load_umax_16 addr:$ptr, GR16:$val))]>;
Dale Johannesen140be2d2008-08-19 18:47:28 +00004028
4029def ATOMAND8 : I<0, Pseudo, (outs GR8:$dst),(ins i8mem:$ptr, GR8:$val),
Nick Lewycky6ecf5ce2008-12-07 03:49:52 +00004030 "#ATOMAND8 PSEUDO!",
Dale Johannesene00a8a22008-08-28 02:44:49 +00004031 [(set GR8:$dst, (atomic_load_and_8 addr:$ptr, GR8:$val))]>;
Dale Johannesen140be2d2008-08-19 18:47:28 +00004032def ATOMOR8 : I<0, Pseudo, (outs GR8:$dst),(ins i8mem:$ptr, GR8:$val),
Nick Lewycky6ecf5ce2008-12-07 03:49:52 +00004033 "#ATOMOR8 PSEUDO!",
Dale Johannesene00a8a22008-08-28 02:44:49 +00004034 [(set GR8:$dst, (atomic_load_or_8 addr:$ptr, GR8:$val))]>;
Dale Johannesen140be2d2008-08-19 18:47:28 +00004035def ATOMXOR8 : I<0, Pseudo,(outs GR8:$dst),(ins i8mem:$ptr, GR8:$val),
Nick Lewycky6ecf5ce2008-12-07 03:49:52 +00004036 "#ATOMXOR8 PSEUDO!",
Dale Johannesene00a8a22008-08-28 02:44:49 +00004037 [(set GR8:$dst, (atomic_load_xor_8 addr:$ptr, GR8:$val))]>;
Dale Johannesen140be2d2008-08-19 18:47:28 +00004038def ATOMNAND8 : I<0, Pseudo,(outs GR8:$dst),(ins i8mem:$ptr, GR8:$val),
Nick Lewycky6ecf5ce2008-12-07 03:49:52 +00004039 "#ATOMNAND8 PSEUDO!",
Dale Johannesene00a8a22008-08-28 02:44:49 +00004040 [(set GR8:$dst, (atomic_load_nand_8 addr:$ptr, GR8:$val))]>;
Mon P Wang63307c32008-05-05 19:05:59 +00004041}
4042
Dale Johannesen48c1bc22008-10-02 18:53:47 +00004043let Constraints = "$val1 = $dst1, $val2 = $dst2",
4044 Defs = [EFLAGS, EAX, EBX, ECX, EDX],
4045 Uses = [EAX, EBX, ECX, EDX],
Dale Johannesen1b54c7f2008-10-03 19:41:08 +00004046 mayLoad = 1, mayStore = 1,
Dan Gohman533297b2009-10-29 18:10:34 +00004047 usesCustomInserter = 1 in {
Dale Johannesen48c1bc22008-10-02 18:53:47 +00004048def ATOMAND6432 : I<0, Pseudo, (outs GR32:$dst1, GR32:$dst2),
4049 (ins i64mem:$ptr, GR32:$val1, GR32:$val2),
Nick Lewycky6ecf5ce2008-12-07 03:49:52 +00004050 "#ATOMAND6432 PSEUDO!", []>;
Dale Johannesen48c1bc22008-10-02 18:53:47 +00004051def ATOMOR6432 : I<0, Pseudo, (outs GR32:$dst1, GR32:$dst2),
4052 (ins i64mem:$ptr, GR32:$val1, GR32:$val2),
Nick Lewycky6ecf5ce2008-12-07 03:49:52 +00004053 "#ATOMOR6432 PSEUDO!", []>;
Dale Johannesen48c1bc22008-10-02 18:53:47 +00004054def ATOMXOR6432 : I<0, Pseudo, (outs GR32:$dst1, GR32:$dst2),
4055 (ins i64mem:$ptr, GR32:$val1, GR32:$val2),
Nick Lewycky6ecf5ce2008-12-07 03:49:52 +00004056 "#ATOMXOR6432 PSEUDO!", []>;
Dale Johannesen48c1bc22008-10-02 18:53:47 +00004057def ATOMNAND6432 : I<0, Pseudo, (outs GR32:$dst1, GR32:$dst2),
4058 (ins i64mem:$ptr, GR32:$val1, GR32:$val2),
Nick Lewycky6ecf5ce2008-12-07 03:49:52 +00004059 "#ATOMNAND6432 PSEUDO!", []>;
Dale Johannesen48c1bc22008-10-02 18:53:47 +00004060def ATOMADD6432 : I<0, Pseudo, (outs GR32:$dst1, GR32:$dst2),
4061 (ins i64mem:$ptr, GR32:$val1, GR32:$val2),
Nick Lewycky6ecf5ce2008-12-07 03:49:52 +00004062 "#ATOMADD6432 PSEUDO!", []>;
Dale Johannesen48c1bc22008-10-02 18:53:47 +00004063def ATOMSUB6432 : I<0, Pseudo, (outs GR32:$dst1, GR32:$dst2),
4064 (ins i64mem:$ptr, GR32:$val1, GR32:$val2),
Nick Lewycky6ecf5ce2008-12-07 03:49:52 +00004065 "#ATOMSUB6432 PSEUDO!", []>;
Dale Johannesen880ae362008-10-03 22:25:52 +00004066def ATOMSWAP6432 : I<0, Pseudo, (outs GR32:$dst1, GR32:$dst2),
4067 (ins i64mem:$ptr, GR32:$val1, GR32:$val2),
Nick Lewycky6ecf5ce2008-12-07 03:49:52 +00004068 "#ATOMSWAP6432 PSEUDO!", []>;
Dale Johannesen48c1bc22008-10-02 18:53:47 +00004069}
4070
Sean Callanan358f1ef2009-09-16 21:55:34 +00004071// Segmentation support instructions.
4072
4073def LAR16rm : I<0x02, MRMSrcMem, (outs GR16:$dst), (ins i16mem:$src),
4074 "lar{w}\t{$src, $dst|$dst, $src}", []>, TB, OpSize;
4075def LAR16rr : I<0x02, MRMSrcReg, (outs GR16:$dst), (ins GR16:$src),
4076 "lar{w}\t{$src, $dst|$dst, $src}", []>, TB, OpSize;
4077
4078// i16mem operand in LAR32rm and GR32 operand in LAR32rr is not a typo.
4079def LAR32rm : I<0x02, MRMSrcMem, (outs GR32:$dst), (ins i16mem:$src),
4080 "lar{l}\t{$src, $dst|$dst, $src}", []>, TB;
4081def LAR32rr : I<0x02, MRMSrcReg, (outs GR32:$dst), (ins GR32:$src),
4082 "lar{l}\t{$src, $dst|$dst, $src}", []>, TB;
Sean Callanan108934c2009-12-18 00:01:26 +00004083
4084def LSL16rm : I<0x03, MRMSrcMem, (outs GR16:$dst), (ins i16mem:$src),
4085 "lsl{w}\t{$src, $dst|$dst, $src}", []>, TB, OpSize;
4086def LSL16rr : I<0x03, MRMSrcReg, (outs GR16:$dst), (ins GR16:$src),
4087 "lsl{w}\t{$src, $dst|$dst, $src}", []>, TB, OpSize;
4088def LSL32rm : I<0x03, MRMSrcMem, (outs GR32:$dst), (ins i32mem:$src),
4089 "lsl{l}\t{$src, $dst|$dst, $src}", []>, TB;
4090def LSL32rr : I<0x03, MRMSrcReg, (outs GR32:$dst), (ins GR32:$src),
4091 "lsl{l}\t{$src, $dst|$dst, $src}", []>, TB;
4092
4093def INVLPG : I<0x01, RawFrm, (outs), (ins), "invlpg", []>, TB;
4094
4095def STRr : I<0x00, MRM1r, (outs GR16:$dst), (ins),
4096 "str{w}\t{$dst}", []>, TB;
4097def STRm : I<0x00, MRM1m, (outs i16mem:$dst), (ins),
4098 "str{w}\t{$dst}", []>, TB;
4099def LTRr : I<0x00, MRM3r, (outs), (ins GR16:$src),
4100 "ltr{w}\t{$src}", []>, TB;
4101def LTRm : I<0x00, MRM3m, (outs), (ins i16mem:$src),
4102 "ltr{w}\t{$src}", []>, TB;
4103
4104def PUSHFS16 : I<0xa0, RawFrm, (outs), (ins),
4105 "push{w}\t%fs", []>, OpSize, TB;
4106def PUSHFS32 : I<0xa0, RawFrm, (outs), (ins),
4107 "push{l}\t%fs", []>, TB;
4108def PUSHGS16 : I<0xa8, RawFrm, (outs), (ins),
4109 "push{w}\t%gs", []>, OpSize, TB;
4110def PUSHGS32 : I<0xa8, RawFrm, (outs), (ins),
4111 "push{l}\t%gs", []>, TB;
4112
4113def POPFS16 : I<0xa1, RawFrm, (outs), (ins),
4114 "pop{w}\t%fs", []>, OpSize, TB;
4115def POPFS32 : I<0xa1, RawFrm, (outs), (ins),
4116 "pop{l}\t%fs", []>, TB;
4117def POPGS16 : I<0xa9, RawFrm, (outs), (ins),
4118 "pop{w}\t%gs", []>, OpSize, TB;
4119def POPGS32 : I<0xa9, RawFrm, (outs), (ins),
4120 "pop{l}\t%gs", []>, TB;
4121
4122def LDS16rm : I<0xc5, MRMSrcMem, (outs GR16:$dst), (ins opaque32mem:$src),
4123 "lds{w}\t{$src, $dst|$dst, $src}", []>, OpSize;
4124def LDS32rm : I<0xc5, MRMSrcMem, (outs GR32:$dst), (ins opaque48mem:$src),
4125 "lds{l}\t{$src, $dst|$dst, $src}", []>;
4126def LSS16rm : I<0xb2, MRMSrcMem, (outs GR16:$dst), (ins opaque32mem:$src),
4127 "lss{w}\t{$src, $dst|$dst, $src}", []>, TB, OpSize;
4128def LSS32rm : I<0xb2, MRMSrcMem, (outs GR32:$dst), (ins opaque48mem:$src),
4129 "lss{l}\t{$src, $dst|$dst, $src}", []>, TB;
4130def LES16rm : I<0xc4, MRMSrcMem, (outs GR16:$dst), (ins opaque32mem:$src),
4131 "les{w}\t{$src, $dst|$dst, $src}", []>, OpSize;
4132def LES32rm : I<0xc4, MRMSrcMem, (outs GR32:$dst), (ins opaque48mem:$src),
4133 "les{l}\t{$src, $dst|$dst, $src}", []>;
4134def LFS16rm : I<0xb4, MRMSrcMem, (outs GR16:$dst), (ins opaque32mem:$src),
4135 "lfs{w}\t{$src, $dst|$dst, $src}", []>, TB, OpSize;
4136def LFS32rm : I<0xb4, MRMSrcMem, (outs GR32:$dst), (ins opaque48mem:$src),
4137 "lfs{l}\t{$src, $dst|$dst, $src}", []>, TB;
4138def LGS16rm : I<0xb5, MRMSrcMem, (outs GR16:$dst), (ins opaque32mem:$src),
4139 "lgs{w}\t{$src, $dst|$dst, $src}", []>, TB, OpSize;
4140def LGS32rm : I<0xb5, MRMSrcMem, (outs GR32:$dst), (ins opaque48mem:$src),
4141 "lgs{l}\t{$src, $dst|$dst, $src}", []>, TB;
4142
4143def VERRr : I<0x00, MRM4r, (outs), (ins GR16:$seg),
4144 "verr\t$seg", []>, TB;
4145def VERRm : I<0x00, MRM4m, (outs), (ins i16mem:$seg),
4146 "verr\t$seg", []>, TB;
4147def VERWr : I<0x00, MRM5r, (outs), (ins GR16:$seg),
4148 "verw\t$seg", []>, TB;
4149def VERWm : I<0x00, MRM5m, (outs), (ins i16mem:$seg),
4150 "verw\t$seg", []>, TB;
4151
4152// Descriptor-table support instructions
4153
4154def SGDTm : I<0x01, MRM0m, (outs opaque48mem:$dst), (ins),
4155 "sgdt\t$dst", []>, TB;
4156def SIDTm : I<0x01, MRM1m, (outs opaque48mem:$dst), (ins),
4157 "sidt\t$dst", []>, TB;
4158def SLDT16r : I<0x00, MRM0r, (outs GR16:$dst), (ins),
4159 "sldt{w}\t$dst", []>, TB;
4160def SLDT16m : I<0x00, MRM0m, (outs i16mem:$dst), (ins),
4161 "sldt{w}\t$dst", []>, TB;
4162def LGDTm : I<0x01, MRM2m, (outs), (ins opaque48mem:$src),
4163 "lgdt\t$src", []>, TB;
4164def LIDTm : I<0x01, MRM3m, (outs), (ins opaque48mem:$src),
4165 "lidt\t$src", []>, TB;
4166def LLDT16r : I<0x00, MRM2r, (outs), (ins GR16:$src),
4167 "lldt{w}\t$src", []>, TB;
4168def LLDT16m : I<0x00, MRM2m, (outs), (ins i16mem:$src),
4169 "lldt{w}\t$src", []>, TB;
Sean Callanan9a86f102009-09-16 22:59:28 +00004170
4171// String manipulation instructions
4172
4173def LODSB : I<0xAC, RawFrm, (outs), (ins), "lodsb", []>;
4174def LODSW : I<0xAD, RawFrm, (outs), (ins), "lodsw", []>, OpSize;
Sean Callanan108934c2009-12-18 00:01:26 +00004175def LODSD : I<0xAD, RawFrm, (outs), (ins), "lods{l|d}", []>;
4176
4177def OUTSB : I<0x6E, RawFrm, (outs), (ins), "outsb", []>;
4178def OUTSW : I<0x6F, RawFrm, (outs), (ins), "outsw", []>, OpSize;
4179def OUTSD : I<0x6F, RawFrm, (outs), (ins), "outs{l|d}", []>;
4180
4181// CPU flow control instructions
4182
4183def HLT : I<0xF4, RawFrm, (outs), (ins), "hlt", []>;
4184def RSM : I<0xAA, RawFrm, (outs), (ins), "rsm", []>, TB;
4185
4186// FPU control instructions
4187
4188def FNINIT : I<0xE3, RawFrm, (outs), (ins), "fninit", []>, DB;
4189
4190// Flag instructions
4191
4192def CLC : I<0xF8, RawFrm, (outs), (ins), "clc", []>;
4193def STC : I<0xF9, RawFrm, (outs), (ins), "stc", []>;
4194def CLI : I<0xFA, RawFrm, (outs), (ins), "cli", []>;
4195def STI : I<0xFB, RawFrm, (outs), (ins), "sti", []>;
4196def CLD : I<0xFC, RawFrm, (outs), (ins), "cld", []>;
4197def STD : I<0xFD, RawFrm, (outs), (ins), "std", []>;
4198def CMC : I<0xF5, RawFrm, (outs), (ins), "cmc", []>;
4199
4200def CLTS : I<0x06, RawFrm, (outs), (ins), "clts", []>, TB;
4201
4202// Table lookup instructions
4203
4204def XLAT : I<0xD7, RawFrm, (outs), (ins), "xlatb", []>;
4205
4206// Specialized register support
4207
4208def WRMSR : I<0x30, RawFrm, (outs), (ins), "wrmsr", []>, TB;
4209def RDMSR : I<0x32, RawFrm, (outs), (ins), "rdmsr", []>, TB;
4210def RDPMC : I<0x33, RawFrm, (outs), (ins), "rdpmc", []>, TB;
4211
4212def SMSW16r : I<0x01, MRM4r, (outs GR16:$dst), (ins),
4213 "smsw{w}\t$dst", []>, OpSize, TB;
4214def SMSW32r : I<0x01, MRM4r, (outs GR32:$dst), (ins),
4215 "smsw{l}\t$dst", []>, TB;
4216// For memory operands, there is only a 16-bit form
4217def SMSW16m : I<0x01, MRM4m, (outs i16mem:$dst), (ins),
4218 "smsw{w}\t$dst", []>, TB;
4219
4220def LMSW16r : I<0x01, MRM6r, (outs), (ins GR16:$src),
4221 "lmsw{w}\t$src", []>, TB;
4222def LMSW16m : I<0x01, MRM6m, (outs), (ins i16mem:$src),
4223 "lmsw{w}\t$src", []>, TB;
4224
4225def CPUID : I<0xA2, RawFrm, (outs), (ins), "cpuid", []>, TB;
4226
4227// Cache instructions
4228
4229def INVD : I<0x08, RawFrm, (outs), (ins), "invd", []>, TB;
4230def WBINVD : I<0x09, RawFrm, (outs), (ins), "wbinvd", []>, TB;
4231
4232// VMX instructions
4233
4234// 66 0F 38 80
4235def INVEPT : I<0x38, RawFrm, (outs), (ins), "invept", []>, OpSize, TB;
4236// 66 0F 38 81
4237def INVVPID : I<0x38, RawFrm, (outs), (ins), "invvpid", []>, OpSize, TB;
4238// 0F 01 C1
4239def VMCALL : I<0x01, RawFrm, (outs), (ins), "vmcall", []>, TB;
4240def VMCLEARm : I<0xC7, MRM6m, (outs), (ins i64mem:$vmcs),
4241 "vmclear\t$vmcs", []>, OpSize, TB;
4242// 0F 01 C2
4243def VMLAUNCH : I<0x01, RawFrm, (outs), (ins), "vmlaunch", []>, TB;
4244// 0F 01 C3
4245def VMRESUME : I<0x01, RawFrm, (outs), (ins), "vmresume", []>, TB;
4246def VMPTRLDm : I<0xC7, MRM6m, (outs), (ins i64mem:$vmcs),
4247 "vmptrld\t$vmcs", []>, TB;
4248def VMPTRSTm : I<0xC7, MRM7m, (outs i64mem:$vmcs), (ins),
4249 "vmptrst\t$vmcs", []>, TB;
4250def VMREAD64rm : I<0x78, MRMDestMem, (outs i64mem:$dst), (ins GR64:$src),
4251 "vmread{q}\t{$src, $dst|$dst, $src}", []>, TB;
4252def VMREAD64rr : I<0x78, MRMDestReg, (outs GR64:$dst), (ins GR64:$src),
4253 "vmread{q}\t{$src, $dst|$dst, $src}", []>, TB;
4254def VMREAD32rm : I<0x78, MRMDestMem, (outs i32mem:$dst), (ins GR32:$src),
4255 "vmread{l}\t{$src, $dst|$dst, $src}", []>, TB;
4256def VMREAD32rr : I<0x78, MRMDestReg, (outs GR32:$dst), (ins GR32:$src),
4257 "vmread{l}\t{$src, $dst|$dst, $src}", []>, TB;
4258def VMWRITE64rm : I<0x79, MRMSrcMem, (outs GR64:$dst), (ins i64mem:$src),
4259 "vmwrite{q}\t{$src, $dst|$dst, $src}", []>, TB;
4260def VMWRITE64rr : I<0x79, MRMSrcReg, (outs GR64:$dst), (ins GR64:$src),
4261 "vmwrite{q}\t{$src, $dst|$dst, $src}", []>, TB;
4262def VMWRITE32rm : I<0x79, MRMSrcMem, (outs GR32:$dst), (ins i32mem:$src),
4263 "vmwrite{l}\t{$src, $dst|$dst, $src}", []>, TB;
4264def VMWRITE32rr : I<0x79, MRMSrcReg, (outs GR32:$dst), (ins GR32:$src),
4265 "vmwrite{l}\t{$src, $dst|$dst, $src}", []>, TB;
4266// 0F 01 C4
4267def VMXOFF : I<0x01, RawFrm, (outs), (ins), "vmxoff", []>, OpSize;
4268def VMXON : I<0xC7, MRM6m, (outs), (ins i64mem:$vmxon),
4269 "vmxon\t{$vmxon}", []>, XD;
Sean Callanan358f1ef2009-09-16 21:55:34 +00004270
Andrew Lenharthab0b9492008-02-21 06:45:13 +00004271//===----------------------------------------------------------------------===//
Evan Cheng510e4782006-01-09 23:10:28 +00004272// Non-Instruction Patterns
4273//===----------------------------------------------------------------------===//
4274
Bill Wendling056292f2008-09-16 21:48:12 +00004275// ConstantPool GlobalAddress, ExternalSymbol, and JumpTable
Evan Cheng71fb8342006-02-25 10:02:21 +00004276def : Pat<(i32 (X86Wrapper tconstpool :$dst)), (MOV32ri tconstpool :$dst)>;
Nate Begeman37efe672006-04-22 18:53:45 +00004277def : Pat<(i32 (X86Wrapper tjumptable :$dst)), (MOV32ri tjumptable :$dst)>;
Nate Begeman6795ebb2008-04-12 00:47:57 +00004278def : Pat<(i32 (X86Wrapper tglobaltlsaddr:$dst)),(MOV32ri tglobaltlsaddr:$dst)>;
Evan Cheng71fb8342006-02-25 10:02:21 +00004279def : Pat<(i32 (X86Wrapper tglobaladdr :$dst)), (MOV32ri tglobaladdr :$dst)>;
4280def : Pat<(i32 (X86Wrapper texternalsym:$dst)), (MOV32ri texternalsym:$dst)>;
Dan Gohmanf705adb2009-10-30 01:28:02 +00004281def : Pat<(i32 (X86Wrapper tblockaddress:$dst)), (MOV32ri tblockaddress:$dst)>;
Evan Cheng71fb8342006-02-25 10:02:21 +00004282
Evan Cheng069287d2006-05-16 07:21:53 +00004283def : Pat<(add GR32:$src1, (X86Wrapper tconstpool:$src2)),
4284 (ADD32ri GR32:$src1, tconstpool:$src2)>;
4285def : Pat<(add GR32:$src1, (X86Wrapper tjumptable:$src2)),
4286 (ADD32ri GR32:$src1, tjumptable:$src2)>;
4287def : Pat<(add GR32:$src1, (X86Wrapper tglobaladdr :$src2)),
4288 (ADD32ri GR32:$src1, tglobaladdr:$src2)>;
4289def : Pat<(add GR32:$src1, (X86Wrapper texternalsym:$src2)),
4290 (ADD32ri GR32:$src1, texternalsym:$src2)>;
Dan Gohmanf705adb2009-10-30 01:28:02 +00004291def : Pat<(add GR32:$src1, (X86Wrapper tblockaddress:$src2)),
4292 (ADD32ri GR32:$src1, tblockaddress:$src2)>;
Evan Cheng71fb8342006-02-25 10:02:21 +00004293
Evan Chengfc8feb12006-05-19 07:30:36 +00004294def : Pat<(store (i32 (X86Wrapper tglobaladdr:$src)), addr:$dst),
Evan Cheng71fb8342006-02-25 10:02:21 +00004295 (MOV32mi addr:$dst, tglobaladdr:$src)>;
Evan Chengfc8feb12006-05-19 07:30:36 +00004296def : Pat<(store (i32 (X86Wrapper texternalsym:$src)), addr:$dst),
Evan Cheng71fb8342006-02-25 10:02:21 +00004297 (MOV32mi addr:$dst, texternalsym:$src)>;
Dan Gohmanf705adb2009-10-30 01:28:02 +00004298def : Pat<(store (i32 (X86Wrapper tblockaddress:$src)), addr:$dst),
4299 (MOV32mi addr:$dst, tblockaddress:$src)>;
Evan Cheng71fb8342006-02-25 10:02:21 +00004300
Evan Cheng510e4782006-01-09 23:10:28 +00004301// Calls
Arnold Schwaighoferc85e1712007-10-11 19:40:01 +00004302// tailcall stuff
Arnold Schwaighoferc85e1712007-10-11 19:40:01 +00004303def : Pat<(X86tcret GR32:$dst, imm:$off),
4304 (TCRETURNri GR32:$dst, imm:$off)>;
4305
4306def : Pat<(X86tcret (i32 tglobaladdr:$dst), imm:$off),
4307 (TCRETURNdi texternalsym:$dst, imm:$off)>;
4308
4309def : Pat<(X86tcret (i32 texternalsym:$dst), imm:$off),
4310 (TCRETURNdi texternalsym:$dst, imm:$off)>;
Evan Chengfea89c12006-04-27 08:40:39 +00004311
Dan Gohmancadb2262009-08-02 16:10:01 +00004312// Normal calls, with various flavors of addresses.
Evan Cheng25ab6902006-09-08 06:48:29 +00004313def : Pat<(X86call (i32 tglobaladdr:$dst)),
Evan Cheng510e4782006-01-09 23:10:28 +00004314 (CALLpcrel32 tglobaladdr:$dst)>;
Evan Cheng25ab6902006-09-08 06:48:29 +00004315def : Pat<(X86call (i32 texternalsym:$dst)),
Evan Cheng8700e142006-01-11 06:09:51 +00004316 (CALLpcrel32 texternalsym:$dst)>;
Evan Chengd7f666a2009-05-20 04:53:57 +00004317def : Pat<(X86call (i32 imm:$dst)),
4318 (CALLpcrel32 imm:$dst)>, Requires<[CallImmAddr]>;
Evan Cheng510e4782006-01-09 23:10:28 +00004319
4320// X86 specific add which produces a flag.
Evan Cheng069287d2006-05-16 07:21:53 +00004321def : Pat<(addc GR32:$src1, GR32:$src2),
4322 (ADD32rr GR32:$src1, GR32:$src2)>;
4323def : Pat<(addc GR32:$src1, (load addr:$src2)),
4324 (ADD32rm GR32:$src1, addr:$src2)>;
4325def : Pat<(addc GR32:$src1, imm:$src2),
4326 (ADD32ri GR32:$src1, imm:$src2)>;
4327def : Pat<(addc GR32:$src1, i32immSExt8:$src2),
4328 (ADD32ri8 GR32:$src1, i32immSExt8:$src2)>;
Evan Cheng510e4782006-01-09 23:10:28 +00004329
Evan Cheng069287d2006-05-16 07:21:53 +00004330def : Pat<(subc GR32:$src1, GR32:$src2),
4331 (SUB32rr GR32:$src1, GR32:$src2)>;
4332def : Pat<(subc GR32:$src1, (load addr:$src2)),
4333 (SUB32rm GR32:$src1, addr:$src2)>;
4334def : Pat<(subc GR32:$src1, imm:$src2),
4335 (SUB32ri GR32:$src1, imm:$src2)>;
4336def : Pat<(subc GR32:$src1, i32immSExt8:$src2),
4337 (SUB32ri8 GR32:$src1, i32immSExt8:$src2)>;
Evan Cheng510e4782006-01-09 23:10:28 +00004338
Chris Lattnerffc0b262006-09-07 20:33:45 +00004339// Comparisons.
4340
4341// TEST R,R is smaller than CMP R,0
Evan Chenge5f62042007-09-29 00:00:36 +00004342def : Pat<(parallel (X86cmp GR8:$src1, 0), (implicit EFLAGS)),
Chris Lattnerffc0b262006-09-07 20:33:45 +00004343 (TEST8rr GR8:$src1, GR8:$src1)>;
Evan Chenge5f62042007-09-29 00:00:36 +00004344def : Pat<(parallel (X86cmp GR16:$src1, 0), (implicit EFLAGS)),
Chris Lattnerffc0b262006-09-07 20:33:45 +00004345 (TEST16rr GR16:$src1, GR16:$src1)>;
Evan Chenge5f62042007-09-29 00:00:36 +00004346def : Pat<(parallel (X86cmp GR32:$src1, 0), (implicit EFLAGS)),
Chris Lattnerffc0b262006-09-07 20:33:45 +00004347 (TEST32rr GR32:$src1, GR32:$src1)>;
4348
Dan Gohmanfbb74862009-01-07 01:00:24 +00004349// Conditional moves with folded loads with operands swapped and conditions
4350// inverted.
4351def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_B, EFLAGS),
4352 (CMOVAE16rm GR16:$src2, addr:$src1)>;
4353def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_B, EFLAGS),
4354 (CMOVAE32rm GR32:$src2, addr:$src1)>;
4355def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_AE, EFLAGS),
4356 (CMOVB16rm GR16:$src2, addr:$src1)>;
4357def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_AE, EFLAGS),
4358 (CMOVB32rm GR32:$src2, addr:$src1)>;
4359def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_E, EFLAGS),
4360 (CMOVNE16rm GR16:$src2, addr:$src1)>;
4361def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_E, EFLAGS),
4362 (CMOVNE32rm GR32:$src2, addr:$src1)>;
4363def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_NE, EFLAGS),
4364 (CMOVE16rm GR16:$src2, addr:$src1)>;
4365def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_NE, EFLAGS),
4366 (CMOVE32rm GR32:$src2, addr:$src1)>;
4367def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_BE, EFLAGS),
4368 (CMOVA16rm GR16:$src2, addr:$src1)>;
4369def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_BE, EFLAGS),
4370 (CMOVA32rm GR32:$src2, addr:$src1)>;
4371def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_A, EFLAGS),
4372 (CMOVBE16rm GR16:$src2, addr:$src1)>;
4373def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_A, EFLAGS),
4374 (CMOVBE32rm GR32:$src2, addr:$src1)>;
4375def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_L, EFLAGS),
4376 (CMOVGE16rm GR16:$src2, addr:$src1)>;
4377def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_L, EFLAGS),
4378 (CMOVGE32rm GR32:$src2, addr:$src1)>;
4379def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_GE, EFLAGS),
4380 (CMOVL16rm GR16:$src2, addr:$src1)>;
4381def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_GE, EFLAGS),
4382 (CMOVL32rm GR32:$src2, addr:$src1)>;
4383def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_LE, EFLAGS),
4384 (CMOVG16rm GR16:$src2, addr:$src1)>;
4385def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_LE, EFLAGS),
4386 (CMOVG32rm GR32:$src2, addr:$src1)>;
4387def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_G, EFLAGS),
4388 (CMOVLE16rm GR16:$src2, addr:$src1)>;
4389def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_G, EFLAGS),
4390 (CMOVLE32rm GR32:$src2, addr:$src1)>;
4391def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_P, EFLAGS),
4392 (CMOVNP16rm GR16:$src2, addr:$src1)>;
4393def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_P, EFLAGS),
4394 (CMOVNP32rm GR32:$src2, addr:$src1)>;
4395def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_NP, EFLAGS),
4396 (CMOVP16rm GR16:$src2, addr:$src1)>;
4397def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_NP, EFLAGS),
4398 (CMOVP32rm GR32:$src2, addr:$src1)>;
4399def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_S, EFLAGS),
4400 (CMOVNS16rm GR16:$src2, addr:$src1)>;
4401def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_S, EFLAGS),
4402 (CMOVNS32rm GR32:$src2, addr:$src1)>;
4403def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_NS, EFLAGS),
4404 (CMOVS16rm GR16:$src2, addr:$src1)>;
4405def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_NS, EFLAGS),
4406 (CMOVS32rm GR32:$src2, addr:$src1)>;
4407def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_O, EFLAGS),
4408 (CMOVNO16rm GR16:$src2, addr:$src1)>;
4409def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_O, EFLAGS),
4410 (CMOVNO32rm GR32:$src2, addr:$src1)>;
4411def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_NO, EFLAGS),
4412 (CMOVO16rm GR16:$src2, addr:$src1)>;
4413def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_NO, EFLAGS),
4414 (CMOVO32rm GR32:$src2, addr:$src1)>;
4415
Duncan Sandsf9c98e62008-01-23 20:39:46 +00004416// zextload bool -> zextload byte
Evan Chenge5d93432006-01-17 07:02:46 +00004417def : Pat<(zextloadi8i1 addr:$src), (MOV8rm addr:$src)>;
Evan Cheng510e4782006-01-09 23:10:28 +00004418def : Pat<(zextloadi16i1 addr:$src), (MOVZX16rm8 addr:$src)>;
4419def : Pat<(zextloadi32i1 addr:$src), (MOVZX32rm8 addr:$src)>;
4420
4421// extload bool -> extload byte
Evan Cheng47137242006-05-05 08:23:07 +00004422def : Pat<(extloadi8i1 addr:$src), (MOV8rm addr:$src)>;
Dan Gohmanaf70e5c2009-08-26 14:59:13 +00004423def : Pat<(extloadi16i1 addr:$src), (MOVZX16rm8 addr:$src)>;
Evan Cheng47137242006-05-05 08:23:07 +00004424def : Pat<(extloadi32i1 addr:$src), (MOVZX32rm8 addr:$src)>;
Dan Gohmanaf70e5c2009-08-26 14:59:13 +00004425def : Pat<(extloadi16i8 addr:$src), (MOVZX16rm8 addr:$src)>;
Evan Cheng47137242006-05-05 08:23:07 +00004426def : Pat<(extloadi32i8 addr:$src), (MOVZX32rm8 addr:$src)>;
4427def : Pat<(extloadi32i16 addr:$src), (MOVZX32rm16 addr:$src)>;
Evan Cheng510e4782006-01-09 23:10:28 +00004428
Dan Gohmanaf70e5c2009-08-26 14:59:13 +00004429// anyext. Define these to do an explicit zero-extend to
4430// avoid partial-register updates.
4431def : Pat<(i16 (anyext GR8 :$src)), (MOVZX16rr8 GR8 :$src)>;
4432def : Pat<(i32 (anyext GR8 :$src)), (MOVZX32rr8 GR8 :$src)>;
4433def : Pat<(i32 (anyext GR16:$src)), (MOVZX32rr16 GR16:$src)>;
Evan Cheng510e4782006-01-09 23:10:28 +00004434
Evan Cheng1314b002007-12-13 00:43:27 +00004435// (and (i32 load), 255) -> (zextload i8)
Evan Chengd47e0b62008-09-29 17:26:18 +00004436def : Pat<(i32 (and (nvloadi32 addr:$src), (i32 255))),
4437 (MOVZX32rm8 addr:$src)>;
4438def : Pat<(i32 (and (nvloadi32 addr:$src), (i32 65535))),
4439 (MOVZX32rm16 addr:$src)>;
Evan Cheng1314b002007-12-13 00:43:27 +00004440
Evan Chengcfa260b2006-01-06 02:31:59 +00004441//===----------------------------------------------------------------------===//
4442// Some peepholes
4443//===----------------------------------------------------------------------===//
4444
Dan Gohman63f97202008-10-17 01:33:43 +00004445// Odd encoding trick: -128 fits into an 8-bit immediate field while
4446// +128 doesn't, so in this special case use a sub instead of an add.
4447def : Pat<(add GR16:$src1, 128),
4448 (SUB16ri8 GR16:$src1, -128)>;
4449def : Pat<(store (add (loadi16 addr:$dst), 128), addr:$dst),
4450 (SUB16mi8 addr:$dst, -128)>;
4451def : Pat<(add GR32:$src1, 128),
4452 (SUB32ri8 GR32:$src1, -128)>;
4453def : Pat<(store (add (loadi32 addr:$dst), 128), addr:$dst),
4454 (SUB32mi8 addr:$dst, -128)>;
4455
Dan Gohman11ba3b12008-07-30 18:09:17 +00004456// r & (2^16-1) ==> movz
4457def : Pat<(and GR32:$src1, 0xffff),
Dan Gohman21e3dfb2009-04-13 16:09:41 +00004458 (MOVZX32rr16 (EXTRACT_SUBREG GR32:$src1, x86_subreg_16bit))>;
Dan Gohman8a1510d2008-08-06 18:27:21 +00004459// r & (2^8-1) ==> movz
4460def : Pat<(and GR32:$src1, 0xff),
Anton Korobeynikov3a639a02009-11-02 00:11:39 +00004461 (MOVZX32rr8 (EXTRACT_SUBREG (i32 (COPY_TO_REGCLASS GR32:$src1,
4462 GR32_ABCD)),
Dan Gohman21e3dfb2009-04-13 16:09:41 +00004463 x86_subreg_8bit))>,
Dan Gohman8a1510d2008-08-06 18:27:21 +00004464 Requires<[In32BitMode]>;
4465// r & (2^8-1) ==> movz
4466def : Pat<(and GR16:$src1, 0xff),
Anton Korobeynikov3a639a02009-11-02 00:11:39 +00004467 (MOVZX16rr8 (EXTRACT_SUBREG (i16 (COPY_TO_REGCLASS GR16:$src1,
4468 GR16_ABCD)),
Dan Gohman21e3dfb2009-04-13 16:09:41 +00004469 x86_subreg_8bit))>,
Dan Gohman0bfa1bf2008-08-20 21:27:32 +00004470 Requires<[In32BitMode]>;
4471
4472// sext_inreg patterns
4473def : Pat<(sext_inreg GR32:$src, i16),
Dan Gohman21e3dfb2009-04-13 16:09:41 +00004474 (MOVSX32rr16 (EXTRACT_SUBREG GR32:$src, x86_subreg_16bit))>;
Dan Gohman0bfa1bf2008-08-20 21:27:32 +00004475def : Pat<(sext_inreg GR32:$src, i8),
Anton Korobeynikov3a639a02009-11-02 00:11:39 +00004476 (MOVSX32rr8 (EXTRACT_SUBREG (i32 (COPY_TO_REGCLASS GR32:$src,
4477 GR32_ABCD)),
Dan Gohman21e3dfb2009-04-13 16:09:41 +00004478 x86_subreg_8bit))>,
Dan Gohman0bfa1bf2008-08-20 21:27:32 +00004479 Requires<[In32BitMode]>;
4480def : Pat<(sext_inreg GR16:$src, i8),
Anton Korobeynikov3a639a02009-11-02 00:11:39 +00004481 (MOVSX16rr8 (EXTRACT_SUBREG (i16 (COPY_TO_REGCLASS GR16:$src,
4482 GR16_ABCD)),
Dan Gohman21e3dfb2009-04-13 16:09:41 +00004483 x86_subreg_8bit))>,
Dan Gohman0bfa1bf2008-08-20 21:27:32 +00004484 Requires<[In32BitMode]>;
4485
4486// trunc patterns
4487def : Pat<(i16 (trunc GR32:$src)),
Dan Gohman21e3dfb2009-04-13 16:09:41 +00004488 (EXTRACT_SUBREG GR32:$src, x86_subreg_16bit)>;
Dan Gohman0bfa1bf2008-08-20 21:27:32 +00004489def : Pat<(i8 (trunc GR32:$src)),
Anton Korobeynikov3a639a02009-11-02 00:11:39 +00004490 (EXTRACT_SUBREG (i32 (COPY_TO_REGCLASS GR32:$src, GR32_ABCD)),
Dan Gohman21e3dfb2009-04-13 16:09:41 +00004491 x86_subreg_8bit)>,
Dan Gohman0bfa1bf2008-08-20 21:27:32 +00004492 Requires<[In32BitMode]>;
4493def : Pat<(i8 (trunc GR16:$src)),
Anton Korobeynikov3a639a02009-11-02 00:11:39 +00004494 (EXTRACT_SUBREG (i16 (COPY_TO_REGCLASS GR16:$src, GR16_ABCD)),
Dan Gohman21e3dfb2009-04-13 16:09:41 +00004495 x86_subreg_8bit)>,
4496 Requires<[In32BitMode]>;
4497
4498// h-register tricks
4499def : Pat<(i8 (trunc (srl_su GR16:$src, (i8 8)))),
Anton Korobeynikov3a639a02009-11-02 00:11:39 +00004500 (EXTRACT_SUBREG (i32 (COPY_TO_REGCLASS GR16:$src, GR16_ABCD)),
Dan Gohman21e3dfb2009-04-13 16:09:41 +00004501 x86_subreg_8bit_hi)>,
4502 Requires<[In32BitMode]>;
4503def : Pat<(i8 (trunc (srl_su GR32:$src, (i8 8)))),
Anton Korobeynikov3a639a02009-11-02 00:11:39 +00004504 (EXTRACT_SUBREG (i16 (COPY_TO_REGCLASS GR32:$src, GR32_ABCD)),
Dan Gohman21e3dfb2009-04-13 16:09:41 +00004505 x86_subreg_8bit_hi)>,
4506 Requires<[In32BitMode]>;
Dan Gohman7e0d64a2010-01-11 17:21:05 +00004507def : Pat<(srl GR16:$src, (i8 8)),
Dan Gohman21e3dfb2009-04-13 16:09:41 +00004508 (EXTRACT_SUBREG
4509 (MOVZX32rr8
Anton Korobeynikov3a639a02009-11-02 00:11:39 +00004510 (EXTRACT_SUBREG (i16 (COPY_TO_REGCLASS GR16:$src, GR16_ABCD)),
Dan Gohman21e3dfb2009-04-13 16:09:41 +00004511 x86_subreg_8bit_hi)),
4512 x86_subreg_16bit)>,
4513 Requires<[In32BitMode]>;
Evan Chengcb219f02009-05-29 01:44:43 +00004514def : Pat<(i32 (zext (srl_su GR16:$src, (i8 8)))),
Sean Callanan108934c2009-12-18 00:01:26 +00004515 (MOVZX32rr8 (EXTRACT_SUBREG (i16 (COPY_TO_REGCLASS GR16:$src,
4516 GR16_ABCD)),
Evan Chengcb219f02009-05-29 01:44:43 +00004517 x86_subreg_8bit_hi))>,
4518 Requires<[In32BitMode]>;
Dan Gohmanaf70e5c2009-08-26 14:59:13 +00004519def : Pat<(i32 (anyext (srl_su GR16:$src, (i8 8)))),
Sean Callanan108934c2009-12-18 00:01:26 +00004520 (MOVZX32rr8 (EXTRACT_SUBREG (i16 (COPY_TO_REGCLASS GR16:$src,
4521 GR16_ABCD)),
Dan Gohmanaf70e5c2009-08-26 14:59:13 +00004522 x86_subreg_8bit_hi))>,
4523 Requires<[In32BitMode]>;
Dan Gohman21e3dfb2009-04-13 16:09:41 +00004524def : Pat<(and (srl_su GR32:$src, (i8 8)), (i32 255)),
Sean Callanan108934c2009-12-18 00:01:26 +00004525 (MOVZX32rr8 (EXTRACT_SUBREG (i32 (COPY_TO_REGCLASS GR32:$src,
4526 GR32_ABCD)),
Dan Gohman21e3dfb2009-04-13 16:09:41 +00004527 x86_subreg_8bit_hi))>,
Dan Gohman8a1510d2008-08-06 18:27:21 +00004528 Requires<[In32BitMode]>;
Dan Gohman11ba3b12008-07-30 18:09:17 +00004529
Evan Chengcfa260b2006-01-06 02:31:59 +00004530// (shl x, 1) ==> (add x, x)
Evan Cheng069287d2006-05-16 07:21:53 +00004531def : Pat<(shl GR8 :$src1, (i8 1)), (ADD8rr GR8 :$src1, GR8 :$src1)>;
4532def : Pat<(shl GR16:$src1, (i8 1)), (ADD16rr GR16:$src1, GR16:$src1)>;
4533def : Pat<(shl GR32:$src1, (i8 1)), (ADD32rr GR32:$src1, GR32:$src1)>;
Evan Cheng68b951a2006-01-19 01:56:29 +00004534
Evan Chengeb9f8922008-08-30 02:03:58 +00004535// (shl x (and y, 31)) ==> (shl x, y)
4536def : Pat<(shl GR8:$src1, (and CL:$amt, 31)),
4537 (SHL8rCL GR8:$src1)>;
4538def : Pat<(shl GR16:$src1, (and CL:$amt, 31)),
4539 (SHL16rCL GR16:$src1)>;
4540def : Pat<(shl GR32:$src1, (and CL:$amt, 31)),
4541 (SHL32rCL GR32:$src1)>;
4542def : Pat<(store (shl (loadi8 addr:$dst), (and CL:$amt, 31)), addr:$dst),
4543 (SHL8mCL addr:$dst)>;
4544def : Pat<(store (shl (loadi16 addr:$dst), (and CL:$amt, 31)), addr:$dst),
4545 (SHL16mCL addr:$dst)>;
4546def : Pat<(store (shl (loadi32 addr:$dst), (and CL:$amt, 31)), addr:$dst),
4547 (SHL32mCL addr:$dst)>;
4548
4549def : Pat<(srl GR8:$src1, (and CL:$amt, 31)),
4550 (SHR8rCL GR8:$src1)>;
4551def : Pat<(srl GR16:$src1, (and CL:$amt, 31)),
4552 (SHR16rCL GR16:$src1)>;
4553def : Pat<(srl GR32:$src1, (and CL:$amt, 31)),
4554 (SHR32rCL GR32:$src1)>;
4555def : Pat<(store (srl (loadi8 addr:$dst), (and CL:$amt, 31)), addr:$dst),
4556 (SHR8mCL addr:$dst)>;
4557def : Pat<(store (srl (loadi16 addr:$dst), (and CL:$amt, 31)), addr:$dst),
4558 (SHR16mCL addr:$dst)>;
4559def : Pat<(store (srl (loadi32 addr:$dst), (and CL:$amt, 31)), addr:$dst),
4560 (SHR32mCL addr:$dst)>;
4561
4562def : Pat<(sra GR8:$src1, (and CL:$amt, 31)),
4563 (SAR8rCL GR8:$src1)>;
4564def : Pat<(sra GR16:$src1, (and CL:$amt, 31)),
4565 (SAR16rCL GR16:$src1)>;
4566def : Pat<(sra GR32:$src1, (and CL:$amt, 31)),
4567 (SAR32rCL GR32:$src1)>;
4568def : Pat<(store (sra (loadi8 addr:$dst), (and CL:$amt, 31)), addr:$dst),
4569 (SAR8mCL addr:$dst)>;
4570def : Pat<(store (sra (loadi16 addr:$dst), (and CL:$amt, 31)), addr:$dst),
4571 (SAR16mCL addr:$dst)>;
4572def : Pat<(store (sra (loadi32 addr:$dst), (and CL:$amt, 31)), addr:$dst),
4573 (SAR32mCL addr:$dst)>;
4574
Evan Cheng956044c2006-01-19 23:26:24 +00004575// (or (x >> c) | (y << (32 - c))) ==> (shrd32 x, y, c)
Evan Cheng069287d2006-05-16 07:21:53 +00004576def : Pat<(or (srl GR32:$src1, CL:$amt),
4577 (shl GR32:$src2, (sub 32, CL:$amt))),
4578 (SHRD32rrCL GR32:$src1, GR32:$src2)>;
Evan Cheng68b951a2006-01-19 01:56:29 +00004579
Evan Cheng21d54432006-01-20 01:13:30 +00004580def : Pat<(store (or (srl (loadi32 addr:$dst), CL:$amt),
Evan Cheng069287d2006-05-16 07:21:53 +00004581 (shl GR32:$src2, (sub 32, CL:$amt))), addr:$dst),
4582 (SHRD32mrCL addr:$dst, GR32:$src2)>;
Evan Cheng21d54432006-01-20 01:13:30 +00004583
Dan Gohman74feef22008-10-17 01:23:35 +00004584def : Pat<(or (srl GR32:$src1, (i8 (trunc ECX:$amt))),
4585 (shl GR32:$src2, (i8 (trunc (sub 32, ECX:$amt))))),
4586 (SHRD32rrCL GR32:$src1, GR32:$src2)>;
4587
4588def : Pat<(store (or (srl (loadi32 addr:$dst), (i8 (trunc ECX:$amt))),
4589 (shl GR32:$src2, (i8 (trunc (sub 32, ECX:$amt))))),
4590 addr:$dst),
4591 (SHRD32mrCL addr:$dst, GR32:$src2)>;
4592
4593def : Pat<(shrd GR32:$src1, (i8 imm:$amt1), GR32:$src2, (i8 imm:$amt2)),
4594 (SHRD32rri8 GR32:$src1, GR32:$src2, (i8 imm:$amt1))>;
4595
4596def : Pat<(store (shrd (loadi32 addr:$dst), (i8 imm:$amt1),
4597 GR32:$src2, (i8 imm:$amt2)), addr:$dst),
4598 (SHRD32mri8 addr:$dst, GR32:$src2, (i8 imm:$amt1))>;
4599
Evan Cheng956044c2006-01-19 23:26:24 +00004600// (or (x << c) | (y >> (32 - c))) ==> (shld32 x, y, c)
Evan Cheng069287d2006-05-16 07:21:53 +00004601def : Pat<(or (shl GR32:$src1, CL:$amt),
4602 (srl GR32:$src2, (sub 32, CL:$amt))),
4603 (SHLD32rrCL GR32:$src1, GR32:$src2)>;
Evan Cheng956044c2006-01-19 23:26:24 +00004604
Evan Cheng21d54432006-01-20 01:13:30 +00004605def : Pat<(store (or (shl (loadi32 addr:$dst), CL:$amt),
Evan Cheng069287d2006-05-16 07:21:53 +00004606 (srl GR32:$src2, (sub 32, CL:$amt))), addr:$dst),
4607 (SHLD32mrCL addr:$dst, GR32:$src2)>;
Evan Cheng21d54432006-01-20 01:13:30 +00004608
Dan Gohman74feef22008-10-17 01:23:35 +00004609def : Pat<(or (shl GR32:$src1, (i8 (trunc ECX:$amt))),
4610 (srl GR32:$src2, (i8 (trunc (sub 32, ECX:$amt))))),
4611 (SHLD32rrCL GR32:$src1, GR32:$src2)>;
4612
4613def : Pat<(store (or (shl (loadi32 addr:$dst), (i8 (trunc ECX:$amt))),
4614 (srl GR32:$src2, (i8 (trunc (sub 32, ECX:$amt))))),
4615 addr:$dst),
4616 (SHLD32mrCL addr:$dst, GR32:$src2)>;
4617
4618def : Pat<(shld GR32:$src1, (i8 imm:$amt1), GR32:$src2, (i8 imm:$amt2)),
4619 (SHLD32rri8 GR32:$src1, GR32:$src2, (i8 imm:$amt1))>;
4620
4621def : Pat<(store (shld (loadi32 addr:$dst), (i8 imm:$amt1),
4622 GR32:$src2, (i8 imm:$amt2)), addr:$dst),
4623 (SHLD32mri8 addr:$dst, GR32:$src2, (i8 imm:$amt1))>;
4624
Evan Cheng956044c2006-01-19 23:26:24 +00004625// (or (x >> c) | (y << (16 - c))) ==> (shrd16 x, y, c)
Evan Cheng069287d2006-05-16 07:21:53 +00004626def : Pat<(or (srl GR16:$src1, CL:$amt),
4627 (shl GR16:$src2, (sub 16, CL:$amt))),
4628 (SHRD16rrCL GR16:$src1, GR16:$src2)>;
Evan Cheng956044c2006-01-19 23:26:24 +00004629
Evan Cheng21d54432006-01-20 01:13:30 +00004630def : Pat<(store (or (srl (loadi16 addr:$dst), CL:$amt),
Evan Cheng069287d2006-05-16 07:21:53 +00004631 (shl GR16:$src2, (sub 16, CL:$amt))), addr:$dst),
4632 (SHRD16mrCL addr:$dst, GR16:$src2)>;
Evan Cheng21d54432006-01-20 01:13:30 +00004633
Dan Gohman74feef22008-10-17 01:23:35 +00004634def : Pat<(or (srl GR16:$src1, (i8 (trunc CX:$amt))),
4635 (shl GR16:$src2, (i8 (trunc (sub 16, CX:$amt))))),
4636 (SHRD16rrCL GR16:$src1, GR16:$src2)>;
4637
4638def : Pat<(store (or (srl (loadi16 addr:$dst), (i8 (trunc CX:$amt))),
4639 (shl GR16:$src2, (i8 (trunc (sub 16, CX:$amt))))),
4640 addr:$dst),
4641 (SHRD16mrCL addr:$dst, GR16:$src2)>;
4642
4643def : Pat<(shrd GR16:$src1, (i8 imm:$amt1), GR16:$src2, (i8 imm:$amt2)),
4644 (SHRD16rri8 GR16:$src1, GR16:$src2, (i8 imm:$amt1))>;
4645
4646def : Pat<(store (shrd (loadi16 addr:$dst), (i8 imm:$amt1),
4647 GR16:$src2, (i8 imm:$amt2)), addr:$dst),
4648 (SHRD16mri8 addr:$dst, GR16:$src2, (i8 imm:$amt1))>;
4649
Evan Cheng956044c2006-01-19 23:26:24 +00004650// (or (x << c) | (y >> (16 - c))) ==> (shld16 x, y, c)
Evan Cheng069287d2006-05-16 07:21:53 +00004651def : Pat<(or (shl GR16:$src1, CL:$amt),
4652 (srl GR16:$src2, (sub 16, CL:$amt))),
4653 (SHLD16rrCL GR16:$src1, GR16:$src2)>;
Evan Cheng21d54432006-01-20 01:13:30 +00004654
4655def : Pat<(store (or (shl (loadi16 addr:$dst), CL:$amt),
Evan Cheng069287d2006-05-16 07:21:53 +00004656 (srl GR16:$src2, (sub 16, CL:$amt))), addr:$dst),
4657 (SHLD16mrCL addr:$dst, GR16:$src2)>;
Evan Cheng4e4c71e2006-02-21 20:00:20 +00004658
Dan Gohman74feef22008-10-17 01:23:35 +00004659def : Pat<(or (shl GR16:$src1, (i8 (trunc CX:$amt))),
4660 (srl GR16:$src2, (i8 (trunc (sub 16, CX:$amt))))),
4661 (SHLD16rrCL GR16:$src1, GR16:$src2)>;
4662
4663def : Pat<(store (or (shl (loadi16 addr:$dst), (i8 (trunc CX:$amt))),
4664 (srl GR16:$src2, (i8 (trunc (sub 16, CX:$amt))))),
4665 addr:$dst),
4666 (SHLD16mrCL addr:$dst, GR16:$src2)>;
4667
4668def : Pat<(shld GR16:$src1, (i8 imm:$amt1), GR16:$src2, (i8 imm:$amt2)),
4669 (SHLD16rri8 GR16:$src1, GR16:$src2, (i8 imm:$amt1))>;
4670
4671def : Pat<(store (shld (loadi16 addr:$dst), (i8 imm:$amt1),
4672 GR16:$src2, (i8 imm:$amt2)), addr:$dst),
4673 (SHLD16mri8 addr:$dst, GR16:$src2, (i8 imm:$amt1))>;
4674
Evan Cheng2e489c42009-12-16 00:53:11 +00004675// (anyext (setcc_carry)) -> (setcc_carry)
4676def : Pat<(i16 (anyext (i8 (X86setcc_c X86_COND_B, EFLAGS)))),
Evan Chengad9c0a32009-12-15 00:53:42 +00004677 (SETB_C16r)>;
Evan Cheng2e489c42009-12-16 00:53:11 +00004678def : Pat<(i32 (anyext (i8 (X86setcc_c X86_COND_B, EFLAGS)))),
Evan Chengad9c0a32009-12-15 00:53:42 +00004679 (SETB_C32r)>;
4680
Evan Cheng199c4242010-01-11 22:03:29 +00004681// (or x1, x2) -> (add x1, x2) if two operands are known not to share bits.
Evan Cheng4b0345b2010-01-11 17:03:47 +00004682def : Pat<(parallel (or_is_add GR16:$src1, imm:$src2),
4683 (implicit EFLAGS)),
4684 (ADD16ri GR16:$src1, imm:$src2)>;
4685def : Pat<(parallel (or_is_add GR32:$src1, imm:$src2),
4686 (implicit EFLAGS)),
4687 (ADD32ri GR32:$src1, imm:$src2)>;
4688def : Pat<(parallel (or_is_add GR16:$src1, i16immSExt8:$src2),
4689 (implicit EFLAGS)),
4690 (ADD16ri8 GR16:$src1, i16immSExt8:$src2)>;
4691def : Pat<(parallel (or_is_add GR32:$src1, i32immSExt8:$src2),
4692 (implicit EFLAGS)),
4693 (ADD32ri8 GR32:$src1, i32immSExt8:$src2)>;
Evan Cheng199c4242010-01-11 22:03:29 +00004694def : Pat<(parallel (or_is_add GR16:$src1, GR16:$src2),
4695 (implicit EFLAGS)),
4696 (ADD16rr GR16:$src1, GR16:$src2)>;
4697def : Pat<(parallel (or_is_add GR32:$src1, GR32:$src2),
4698 (implicit EFLAGS)),
4699 (ADD32rr GR32:$src1, GR32:$src2)>;
Evan Cheng4b0345b2010-01-11 17:03:47 +00004700
Evan Cheng4e4c71e2006-02-21 20:00:20 +00004701//===----------------------------------------------------------------------===//
Dan Gohman076aee32009-03-04 19:44:21 +00004702// EFLAGS-defining Patterns
Bill Wendlingd350e022008-12-12 21:15:41 +00004703//===----------------------------------------------------------------------===//
4704
Dan Gohman076aee32009-03-04 19:44:21 +00004705// Register-Register Addition with EFLAGS result
4706def : Pat<(parallel (X86add_flag GR8:$src1, GR8:$src2),
Bill Wendlingd350e022008-12-12 21:15:41 +00004707 (implicit EFLAGS)),
4708 (ADD8rr GR8:$src1, GR8:$src2)>;
Dan Gohman076aee32009-03-04 19:44:21 +00004709def : Pat<(parallel (X86add_flag GR16:$src1, GR16:$src2),
Bill Wendlingd350e022008-12-12 21:15:41 +00004710 (implicit EFLAGS)),
4711 (ADD16rr GR16:$src1, GR16:$src2)>;
Dan Gohman076aee32009-03-04 19:44:21 +00004712def : Pat<(parallel (X86add_flag GR32:$src1, GR32:$src2),
Bill Wendlingd350e022008-12-12 21:15:41 +00004713 (implicit EFLAGS)),
4714 (ADD32rr GR32:$src1, GR32:$src2)>;
4715
Dan Gohman076aee32009-03-04 19:44:21 +00004716// Register-Memory Addition with EFLAGS result
4717def : Pat<(parallel (X86add_flag GR8:$src1, (loadi8 addr:$src2)),
Bill Wendlingd350e022008-12-12 21:15:41 +00004718 (implicit EFLAGS)),
4719 (ADD8rm GR8:$src1, addr:$src2)>;
Dan Gohman076aee32009-03-04 19:44:21 +00004720def : Pat<(parallel (X86add_flag GR16:$src1, (loadi16 addr:$src2)),
Bill Wendlingd350e022008-12-12 21:15:41 +00004721 (implicit EFLAGS)),
4722 (ADD16rm GR16:$src1, addr:$src2)>;
Dan Gohman076aee32009-03-04 19:44:21 +00004723def : Pat<(parallel (X86add_flag GR32:$src1, (loadi32 addr:$src2)),
Bill Wendlingd350e022008-12-12 21:15:41 +00004724 (implicit EFLAGS)),
4725 (ADD32rm GR32:$src1, addr:$src2)>;
4726
Dan Gohman076aee32009-03-04 19:44:21 +00004727// Register-Integer Addition with EFLAGS result
4728def : Pat<(parallel (X86add_flag GR8:$src1, imm:$src2),
Bill Wendlingd350e022008-12-12 21:15:41 +00004729 (implicit EFLAGS)),
4730 (ADD8ri GR8:$src1, imm:$src2)>;
Dan Gohman076aee32009-03-04 19:44:21 +00004731def : Pat<(parallel (X86add_flag GR16:$src1, imm:$src2),
Bill Wendlingd350e022008-12-12 21:15:41 +00004732 (implicit EFLAGS)),
4733 (ADD16ri GR16:$src1, imm:$src2)>;
Dan Gohman076aee32009-03-04 19:44:21 +00004734def : Pat<(parallel (X86add_flag GR32:$src1, imm:$src2),
Bill Wendlingd350e022008-12-12 21:15:41 +00004735 (implicit EFLAGS)),
4736 (ADD32ri GR32:$src1, imm:$src2)>;
Dan Gohman076aee32009-03-04 19:44:21 +00004737def : Pat<(parallel (X86add_flag GR16:$src1, i16immSExt8:$src2),
Bill Wendlingd350e022008-12-12 21:15:41 +00004738 (implicit EFLAGS)),
4739 (ADD16ri8 GR16:$src1, i16immSExt8:$src2)>;
Dan Gohman076aee32009-03-04 19:44:21 +00004740def : Pat<(parallel (X86add_flag GR32:$src1, i32immSExt8:$src2),
Bill Wendlingd350e022008-12-12 21:15:41 +00004741 (implicit EFLAGS)),
4742 (ADD32ri8 GR32:$src1, i32immSExt8:$src2)>;
4743
Dan Gohman076aee32009-03-04 19:44:21 +00004744// Memory-Register Addition with EFLAGS result
4745def : Pat<(parallel (store (X86add_flag (loadi8 addr:$dst), GR8:$src2),
Bill Wendlingd350e022008-12-12 21:15:41 +00004746 addr:$dst),
4747 (implicit EFLAGS)),
4748 (ADD8mr addr:$dst, GR8:$src2)>;
Dan Gohman076aee32009-03-04 19:44:21 +00004749def : Pat<(parallel (store (X86add_flag (loadi16 addr:$dst), GR16:$src2),
Bill Wendlingd350e022008-12-12 21:15:41 +00004750 addr:$dst),
4751 (implicit EFLAGS)),
4752 (ADD16mr addr:$dst, GR16:$src2)>;
Dan Gohman076aee32009-03-04 19:44:21 +00004753def : Pat<(parallel (store (X86add_flag (loadi32 addr:$dst), GR32:$src2),
Bill Wendlingd350e022008-12-12 21:15:41 +00004754 addr:$dst),
4755 (implicit EFLAGS)),
4756 (ADD32mr addr:$dst, GR32:$src2)>;
Dale Johannesenca11dae2009-05-18 17:44:15 +00004757
4758// Memory-Integer Addition with EFLAGS result
Dan Gohman076aee32009-03-04 19:44:21 +00004759def : Pat<(parallel (store (X86add_flag (loadi8 addr:$dst), imm:$src2),
Bill Wendlingd350e022008-12-12 21:15:41 +00004760 addr:$dst),
4761 (implicit EFLAGS)),
4762 (ADD8mi addr:$dst, imm:$src2)>;
Dan Gohman076aee32009-03-04 19:44:21 +00004763def : Pat<(parallel (store (X86add_flag (loadi16 addr:$dst), imm:$src2),
Bill Wendlingd350e022008-12-12 21:15:41 +00004764 addr:$dst),
4765 (implicit EFLAGS)),
4766 (ADD16mi addr:$dst, imm:$src2)>;
Dan Gohman076aee32009-03-04 19:44:21 +00004767def : Pat<(parallel (store (X86add_flag (loadi32 addr:$dst), imm:$src2),
Bill Wendlingd350e022008-12-12 21:15:41 +00004768 addr:$dst),
4769 (implicit EFLAGS)),
4770 (ADD32mi addr:$dst, imm:$src2)>;
Dan Gohman076aee32009-03-04 19:44:21 +00004771def : Pat<(parallel (store (X86add_flag (loadi16 addr:$dst), i16immSExt8:$src2),
Bill Wendlingd350e022008-12-12 21:15:41 +00004772 addr:$dst),
4773 (implicit EFLAGS)),
4774 (ADD16mi8 addr:$dst, i16immSExt8:$src2)>;
Dan Gohman076aee32009-03-04 19:44:21 +00004775def : Pat<(parallel (store (X86add_flag (loadi32 addr:$dst), i32immSExt8:$src2),
Bill Wendlingd350e022008-12-12 21:15:41 +00004776 addr:$dst),
4777 (implicit EFLAGS)),
4778 (ADD32mi8 addr:$dst, i32immSExt8:$src2)>;
4779
Dan Gohman076aee32009-03-04 19:44:21 +00004780// Register-Register Subtraction with EFLAGS result
4781def : Pat<(parallel (X86sub_flag GR8:$src1, GR8:$src2),
Bill Wendlingd350e022008-12-12 21:15:41 +00004782 (implicit EFLAGS)),
4783 (SUB8rr GR8:$src1, GR8:$src2)>;
Dan Gohman076aee32009-03-04 19:44:21 +00004784def : Pat<(parallel (X86sub_flag GR16:$src1, GR16:$src2),
Bill Wendlingd350e022008-12-12 21:15:41 +00004785 (implicit EFLAGS)),
4786 (SUB16rr GR16:$src1, GR16:$src2)>;
Dan Gohman076aee32009-03-04 19:44:21 +00004787def : Pat<(parallel (X86sub_flag GR32:$src1, GR32:$src2),
Bill Wendlingd350e022008-12-12 21:15:41 +00004788 (implicit EFLAGS)),
4789 (SUB32rr GR32:$src1, GR32:$src2)>;
4790
Dan Gohman076aee32009-03-04 19:44:21 +00004791// Register-Memory Subtraction with EFLAGS result
4792def : Pat<(parallel (X86sub_flag GR8:$src1, (loadi8 addr:$src2)),
Bill Wendlingd350e022008-12-12 21:15:41 +00004793 (implicit EFLAGS)),
4794 (SUB8rm GR8:$src1, addr:$src2)>;
Dan Gohman076aee32009-03-04 19:44:21 +00004795def : Pat<(parallel (X86sub_flag GR16:$src1, (loadi16 addr:$src2)),
Bill Wendlingd350e022008-12-12 21:15:41 +00004796 (implicit EFLAGS)),
4797 (SUB16rm GR16:$src1, addr:$src2)>;
Dan Gohman076aee32009-03-04 19:44:21 +00004798def : Pat<(parallel (X86sub_flag GR32:$src1, (loadi32 addr:$src2)),
Bill Wendlingd350e022008-12-12 21:15:41 +00004799 (implicit EFLAGS)),
4800 (SUB32rm GR32:$src1, addr:$src2)>;
4801
Dan Gohman076aee32009-03-04 19:44:21 +00004802// Register-Integer Subtraction with EFLAGS result
4803def : Pat<(parallel (X86sub_flag GR8:$src1, imm:$src2),
Bill Wendlingd350e022008-12-12 21:15:41 +00004804 (implicit EFLAGS)),
4805 (SUB8ri GR8:$src1, imm:$src2)>;
Dan Gohman076aee32009-03-04 19:44:21 +00004806def : Pat<(parallel (X86sub_flag GR16:$src1, imm:$src2),
Bill Wendlingd350e022008-12-12 21:15:41 +00004807 (implicit EFLAGS)),
4808 (SUB16ri GR16:$src1, imm:$src2)>;
Dan Gohman076aee32009-03-04 19:44:21 +00004809def : Pat<(parallel (X86sub_flag GR32:$src1, imm:$src2),
Bill Wendlingd350e022008-12-12 21:15:41 +00004810 (implicit EFLAGS)),
4811 (SUB32ri GR32:$src1, imm:$src2)>;
Dan Gohman076aee32009-03-04 19:44:21 +00004812def : Pat<(parallel (X86sub_flag GR16:$src1, i16immSExt8:$src2),
Bill Wendlingd350e022008-12-12 21:15:41 +00004813 (implicit EFLAGS)),
4814 (SUB16ri8 GR16:$src1, i16immSExt8:$src2)>;
Dan Gohman076aee32009-03-04 19:44:21 +00004815def : Pat<(parallel (X86sub_flag GR32:$src1, i32immSExt8:$src2),
Bill Wendlingd350e022008-12-12 21:15:41 +00004816 (implicit EFLAGS)),
4817 (SUB32ri8 GR32:$src1, i32immSExt8:$src2)>;
4818
Dan Gohman076aee32009-03-04 19:44:21 +00004819// Memory-Register Subtraction with EFLAGS result
4820def : Pat<(parallel (store (X86sub_flag (loadi8 addr:$dst), GR8:$src2),
Bill Wendlingd350e022008-12-12 21:15:41 +00004821 addr:$dst),
4822 (implicit EFLAGS)),
4823 (SUB8mr addr:$dst, GR8:$src2)>;
Dan Gohman076aee32009-03-04 19:44:21 +00004824def : Pat<(parallel (store (X86sub_flag (loadi16 addr:$dst), GR16:$src2),
Bill Wendlingd350e022008-12-12 21:15:41 +00004825 addr:$dst),
4826 (implicit EFLAGS)),
4827 (SUB16mr addr:$dst, GR16:$src2)>;
Dan Gohman076aee32009-03-04 19:44:21 +00004828def : Pat<(parallel (store (X86sub_flag (loadi32 addr:$dst), GR32:$src2),
Bill Wendlingd350e022008-12-12 21:15:41 +00004829 addr:$dst),
4830 (implicit EFLAGS)),
4831 (SUB32mr addr:$dst, GR32:$src2)>;
4832
Dan Gohman076aee32009-03-04 19:44:21 +00004833// Memory-Integer Subtraction with EFLAGS result
4834def : Pat<(parallel (store (X86sub_flag (loadi8 addr:$dst), imm:$src2),
Bill Wendlingd350e022008-12-12 21:15:41 +00004835 addr:$dst),
4836 (implicit EFLAGS)),
4837 (SUB8mi addr:$dst, imm:$src2)>;
Dan Gohman076aee32009-03-04 19:44:21 +00004838def : Pat<(parallel (store (X86sub_flag (loadi16 addr:$dst), imm:$src2),
Bill Wendlingd350e022008-12-12 21:15:41 +00004839 addr:$dst),
4840 (implicit EFLAGS)),
4841 (SUB16mi addr:$dst, imm:$src2)>;
Dan Gohman076aee32009-03-04 19:44:21 +00004842def : Pat<(parallel (store (X86sub_flag (loadi32 addr:$dst), imm:$src2),
Bill Wendlingd350e022008-12-12 21:15:41 +00004843 addr:$dst),
4844 (implicit EFLAGS)),
4845 (SUB32mi addr:$dst, imm:$src2)>;
Dan Gohman076aee32009-03-04 19:44:21 +00004846def : Pat<(parallel (store (X86sub_flag (loadi16 addr:$dst), i16immSExt8:$src2),
Bill Wendlingd350e022008-12-12 21:15:41 +00004847 addr:$dst),
4848 (implicit EFLAGS)),
4849 (SUB16mi8 addr:$dst, i16immSExt8:$src2)>;
Dan Gohman076aee32009-03-04 19:44:21 +00004850def : Pat<(parallel (store (X86sub_flag (loadi32 addr:$dst), i32immSExt8:$src2),
Bill Wendlingd350e022008-12-12 21:15:41 +00004851 addr:$dst),
4852 (implicit EFLAGS)),
4853 (SUB32mi8 addr:$dst, i32immSExt8:$src2)>;
4854
4855
Dan Gohman076aee32009-03-04 19:44:21 +00004856// Register-Register Signed Integer Multiply with EFLAGS result
4857def : Pat<(parallel (X86smul_flag GR16:$src1, GR16:$src2),
Bill Wendlingd350e022008-12-12 21:15:41 +00004858 (implicit EFLAGS)),
4859 (IMUL16rr GR16:$src1, GR16:$src2)>;
Dan Gohman076aee32009-03-04 19:44:21 +00004860def : Pat<(parallel (X86smul_flag GR32:$src1, GR32:$src2),
Bill Wendlingd350e022008-12-12 21:15:41 +00004861 (implicit EFLAGS)),
4862 (IMUL32rr GR32:$src1, GR32:$src2)>;
4863
Dan Gohman076aee32009-03-04 19:44:21 +00004864// Register-Memory Signed Integer Multiply with EFLAGS result
4865def : Pat<(parallel (X86smul_flag GR16:$src1, (loadi16 addr:$src2)),
Bill Wendlingd350e022008-12-12 21:15:41 +00004866 (implicit EFLAGS)),
4867 (IMUL16rm GR16:$src1, addr:$src2)>;
Dan Gohman076aee32009-03-04 19:44:21 +00004868def : Pat<(parallel (X86smul_flag GR32:$src1, (loadi32 addr:$src2)),
Bill Wendlingd350e022008-12-12 21:15:41 +00004869 (implicit EFLAGS)),
4870 (IMUL32rm GR32:$src1, addr:$src2)>;
4871
Dan Gohman076aee32009-03-04 19:44:21 +00004872// Register-Integer Signed Integer Multiply with EFLAGS result
4873def : Pat<(parallel (X86smul_flag GR16:$src1, imm:$src2),
Bill Wendlingd350e022008-12-12 21:15:41 +00004874 (implicit EFLAGS)),
4875 (IMUL16rri GR16:$src1, imm:$src2)>;
Dan Gohman076aee32009-03-04 19:44:21 +00004876def : Pat<(parallel (X86smul_flag GR32:$src1, imm:$src2),
Bill Wendlingd350e022008-12-12 21:15:41 +00004877 (implicit EFLAGS)),
4878 (IMUL32rri GR32:$src1, imm:$src2)>;
Dan Gohman076aee32009-03-04 19:44:21 +00004879def : Pat<(parallel (X86smul_flag GR16:$src1, i16immSExt8:$src2),
Bill Wendlingd350e022008-12-12 21:15:41 +00004880 (implicit EFLAGS)),
4881 (IMUL16rri8 GR16:$src1, i16immSExt8:$src2)>;
Dan Gohman076aee32009-03-04 19:44:21 +00004882def : Pat<(parallel (X86smul_flag GR32:$src1, i32immSExt8:$src2),
Bill Wendlingd350e022008-12-12 21:15:41 +00004883 (implicit EFLAGS)),
4884 (IMUL32rri8 GR32:$src1, i32immSExt8:$src2)>;
4885
Dan Gohman076aee32009-03-04 19:44:21 +00004886// Memory-Integer Signed Integer Multiply with EFLAGS result
4887def : Pat<(parallel (X86smul_flag (loadi16 addr:$src1), imm:$src2),
Bill Wendlingd350e022008-12-12 21:15:41 +00004888 (implicit EFLAGS)),
4889 (IMUL16rmi addr:$src1, imm:$src2)>;
Dan Gohman076aee32009-03-04 19:44:21 +00004890def : Pat<(parallel (X86smul_flag (loadi32 addr:$src1), imm:$src2),
Bill Wendlingd350e022008-12-12 21:15:41 +00004891 (implicit EFLAGS)),
4892 (IMUL32rmi addr:$src1, imm:$src2)>;
Dan Gohman076aee32009-03-04 19:44:21 +00004893def : Pat<(parallel (X86smul_flag (loadi16 addr:$src1), i16immSExt8:$src2),
Bill Wendlingd350e022008-12-12 21:15:41 +00004894 (implicit EFLAGS)),
4895 (IMUL16rmi8 addr:$src1, i16immSExt8:$src2)>;
Dan Gohman076aee32009-03-04 19:44:21 +00004896def : Pat<(parallel (X86smul_flag (loadi32 addr:$src1), i32immSExt8:$src2),
Bill Wendlingd350e022008-12-12 21:15:41 +00004897 (implicit EFLAGS)),
4898 (IMUL32rmi8 addr:$src1, i32immSExt8:$src2)>;
4899
Dan Gohman076aee32009-03-04 19:44:21 +00004900// Optimize multiply by 2 with EFLAGS result.
Evan Cheng6a86bd72009-01-27 03:30:42 +00004901let AddedComplexity = 2 in {
Dan Gohman076aee32009-03-04 19:44:21 +00004902def : Pat<(parallel (X86smul_flag GR16:$src1, 2),
Evan Cheng6a86bd72009-01-27 03:30:42 +00004903 (implicit EFLAGS)),
4904 (ADD16rr GR16:$src1, GR16:$src1)>;
4905
Dan Gohman076aee32009-03-04 19:44:21 +00004906def : Pat<(parallel (X86smul_flag GR32:$src1, 2),
Evan Cheng6a86bd72009-01-27 03:30:42 +00004907 (implicit EFLAGS)),
4908 (ADD32rr GR32:$src1, GR32:$src1)>;
4909}
4910
Dan Gohman076aee32009-03-04 19:44:21 +00004911// INC and DEC with EFLAGS result. Note that these do not set CF.
4912def : Pat<(parallel (X86inc_flag GR8:$src), (implicit EFLAGS)),
4913 (INC8r GR8:$src)>;
4914def : Pat<(parallel (store (i8 (X86inc_flag (loadi8 addr:$dst))), addr:$dst),
4915 (implicit EFLAGS)),
4916 (INC8m addr:$dst)>;
4917def : Pat<(parallel (X86dec_flag GR8:$src), (implicit EFLAGS)),
4918 (DEC8r GR8:$src)>;
4919def : Pat<(parallel (store (i8 (X86dec_flag (loadi8 addr:$dst))), addr:$dst),
4920 (implicit EFLAGS)),
4921 (DEC8m addr:$dst)>;
4922
4923def : Pat<(parallel (X86inc_flag GR16:$src), (implicit EFLAGS)),
Dan Gohman1f4af262009-03-05 21:32:23 +00004924 (INC16r GR16:$src)>, Requires<[In32BitMode]>;
Dan Gohman076aee32009-03-04 19:44:21 +00004925def : Pat<(parallel (store (i16 (X86inc_flag (loadi16 addr:$dst))), addr:$dst),
4926 (implicit EFLAGS)),
Dan Gohman1f4af262009-03-05 21:32:23 +00004927 (INC16m addr:$dst)>, Requires<[In32BitMode]>;
Dan Gohman076aee32009-03-04 19:44:21 +00004928def : Pat<(parallel (X86dec_flag GR16:$src), (implicit EFLAGS)),
Dan Gohman1f4af262009-03-05 21:32:23 +00004929 (DEC16r GR16:$src)>, Requires<[In32BitMode]>;
Dan Gohman076aee32009-03-04 19:44:21 +00004930def : Pat<(parallel (store (i16 (X86dec_flag (loadi16 addr:$dst))), addr:$dst),
4931 (implicit EFLAGS)),
Dan Gohman1f4af262009-03-05 21:32:23 +00004932 (DEC16m addr:$dst)>, Requires<[In32BitMode]>;
Dan Gohman076aee32009-03-04 19:44:21 +00004933
4934def : Pat<(parallel (X86inc_flag GR32:$src), (implicit EFLAGS)),
Dan Gohman1f4af262009-03-05 21:32:23 +00004935 (INC32r GR32:$src)>, Requires<[In32BitMode]>;
Dan Gohman076aee32009-03-04 19:44:21 +00004936def : Pat<(parallel (store (i32 (X86inc_flag (loadi32 addr:$dst))), addr:$dst),
4937 (implicit EFLAGS)),
Dan Gohman1f4af262009-03-05 21:32:23 +00004938 (INC32m addr:$dst)>, Requires<[In32BitMode]>;
Dan Gohman076aee32009-03-04 19:44:21 +00004939def : Pat<(parallel (X86dec_flag GR32:$src), (implicit EFLAGS)),
Dan Gohman1f4af262009-03-05 21:32:23 +00004940 (DEC32r GR32:$src)>, Requires<[In32BitMode]>;
Dan Gohman076aee32009-03-04 19:44:21 +00004941def : Pat<(parallel (store (i32 (X86dec_flag (loadi32 addr:$dst))), addr:$dst),
4942 (implicit EFLAGS)),
Dan Gohman1f4af262009-03-05 21:32:23 +00004943 (DEC32m addr:$dst)>, Requires<[In32BitMode]>;
Dan Gohman076aee32009-03-04 19:44:21 +00004944
Dan Gohmane220c4b2009-09-18 19:59:53 +00004945// Register-Register Or with EFLAGS result
4946def : Pat<(parallel (X86or_flag GR8:$src1, GR8:$src2),
4947 (implicit EFLAGS)),
4948 (OR8rr GR8:$src1, GR8:$src2)>;
4949def : Pat<(parallel (X86or_flag GR16:$src1, GR16:$src2),
4950 (implicit EFLAGS)),
4951 (OR16rr GR16:$src1, GR16:$src2)>;
4952def : Pat<(parallel (X86or_flag GR32:$src1, GR32:$src2),
4953 (implicit EFLAGS)),
4954 (OR32rr GR32:$src1, GR32:$src2)>;
4955
4956// Register-Memory Or with EFLAGS result
4957def : Pat<(parallel (X86or_flag GR8:$src1, (loadi8 addr:$src2)),
4958 (implicit EFLAGS)),
4959 (OR8rm GR8:$src1, addr:$src2)>;
4960def : Pat<(parallel (X86or_flag GR16:$src1, (loadi16 addr:$src2)),
4961 (implicit EFLAGS)),
4962 (OR16rm GR16:$src1, addr:$src2)>;
4963def : Pat<(parallel (X86or_flag GR32:$src1, (loadi32 addr:$src2)),
4964 (implicit EFLAGS)),
4965 (OR32rm GR32:$src1, addr:$src2)>;
4966
4967// Register-Integer Or with EFLAGS result
4968def : Pat<(parallel (X86or_flag GR8:$src1, imm:$src2),
4969 (implicit EFLAGS)),
4970 (OR8ri GR8:$src1, imm:$src2)>;
4971def : Pat<(parallel (X86or_flag GR16:$src1, imm:$src2),
4972 (implicit EFLAGS)),
4973 (OR16ri GR16:$src1, imm:$src2)>;
4974def : Pat<(parallel (X86or_flag GR32:$src1, imm:$src2),
4975 (implicit EFLAGS)),
4976 (OR32ri GR32:$src1, imm:$src2)>;
4977def : Pat<(parallel (X86or_flag GR16:$src1, i16immSExt8:$src2),
4978 (implicit EFLAGS)),
4979 (OR16ri8 GR16:$src1, i16immSExt8:$src2)>;
4980def : Pat<(parallel (X86or_flag GR32:$src1, i32immSExt8:$src2),
4981 (implicit EFLAGS)),
4982 (OR32ri8 GR32:$src1, i32immSExt8:$src2)>;
4983
4984// Memory-Register Or with EFLAGS result
4985def : Pat<(parallel (store (X86or_flag (loadi8 addr:$dst), GR8:$src2),
4986 addr:$dst),
4987 (implicit EFLAGS)),
4988 (OR8mr addr:$dst, GR8:$src2)>;
4989def : Pat<(parallel (store (X86or_flag (loadi16 addr:$dst), GR16:$src2),
4990 addr:$dst),
4991 (implicit EFLAGS)),
4992 (OR16mr addr:$dst, GR16:$src2)>;
4993def : Pat<(parallel (store (X86or_flag (loadi32 addr:$dst), GR32:$src2),
4994 addr:$dst),
4995 (implicit EFLAGS)),
4996 (OR32mr addr:$dst, GR32:$src2)>;
4997
4998// Memory-Integer Or with EFLAGS result
4999def : Pat<(parallel (store (X86or_flag (loadi8 addr:$dst), imm:$src2),
5000 addr:$dst),
5001 (implicit EFLAGS)),
5002 (OR8mi addr:$dst, imm:$src2)>;
5003def : Pat<(parallel (store (X86or_flag (loadi16 addr:$dst), imm:$src2),
5004 addr:$dst),
5005 (implicit EFLAGS)),
5006 (OR16mi addr:$dst, imm:$src2)>;
5007def : Pat<(parallel (store (X86or_flag (loadi32 addr:$dst), imm:$src2),
5008 addr:$dst),
5009 (implicit EFLAGS)),
5010 (OR32mi addr:$dst, imm:$src2)>;
5011def : Pat<(parallel (store (X86or_flag (loadi16 addr:$dst), i16immSExt8:$src2),
5012 addr:$dst),
5013 (implicit EFLAGS)),
5014 (OR16mi8 addr:$dst, i16immSExt8:$src2)>;
5015def : Pat<(parallel (store (X86or_flag (loadi32 addr:$dst), i32immSExt8:$src2),
5016 addr:$dst),
5017 (implicit EFLAGS)),
5018 (OR32mi8 addr:$dst, i32immSExt8:$src2)>;
5019
5020// Register-Register XOr with EFLAGS result
5021def : Pat<(parallel (X86xor_flag GR8:$src1, GR8:$src2),
5022 (implicit EFLAGS)),
5023 (XOR8rr GR8:$src1, GR8:$src2)>;
5024def : Pat<(parallel (X86xor_flag GR16:$src1, GR16:$src2),
5025 (implicit EFLAGS)),
5026 (XOR16rr GR16:$src1, GR16:$src2)>;
5027def : Pat<(parallel (X86xor_flag GR32:$src1, GR32:$src2),
5028 (implicit EFLAGS)),
5029 (XOR32rr GR32:$src1, GR32:$src2)>;
5030
5031// Register-Memory XOr with EFLAGS result
5032def : Pat<(parallel (X86xor_flag GR8:$src1, (loadi8 addr:$src2)),
5033 (implicit EFLAGS)),
5034 (XOR8rm GR8:$src1, addr:$src2)>;
5035def : Pat<(parallel (X86xor_flag GR16:$src1, (loadi16 addr:$src2)),
5036 (implicit EFLAGS)),
5037 (XOR16rm GR16:$src1, addr:$src2)>;
5038def : Pat<(parallel (X86xor_flag GR32:$src1, (loadi32 addr:$src2)),
5039 (implicit EFLAGS)),
5040 (XOR32rm GR32:$src1, addr:$src2)>;
5041
5042// Register-Integer XOr with EFLAGS result
5043def : Pat<(parallel (X86xor_flag GR8:$src1, imm:$src2),
5044 (implicit EFLAGS)),
5045 (XOR8ri GR8:$src1, imm:$src2)>;
5046def : Pat<(parallel (X86xor_flag GR16:$src1, imm:$src2),
5047 (implicit EFLAGS)),
5048 (XOR16ri GR16:$src1, imm:$src2)>;
5049def : Pat<(parallel (X86xor_flag GR32:$src1, imm:$src2),
5050 (implicit EFLAGS)),
5051 (XOR32ri GR32:$src1, imm:$src2)>;
5052def : Pat<(parallel (X86xor_flag GR16:$src1, i16immSExt8:$src2),
5053 (implicit EFLAGS)),
5054 (XOR16ri8 GR16:$src1, i16immSExt8:$src2)>;
5055def : Pat<(parallel (X86xor_flag GR32:$src1, i32immSExt8:$src2),
5056 (implicit EFLAGS)),
5057 (XOR32ri8 GR32:$src1, i32immSExt8:$src2)>;
5058
5059// Memory-Register XOr with EFLAGS result
5060def : Pat<(parallel (store (X86xor_flag (loadi8 addr:$dst), GR8:$src2),
5061 addr:$dst),
5062 (implicit EFLAGS)),
5063 (XOR8mr addr:$dst, GR8:$src2)>;
5064def : Pat<(parallel (store (X86xor_flag (loadi16 addr:$dst), GR16:$src2),
5065 addr:$dst),
5066 (implicit EFLAGS)),
5067 (XOR16mr addr:$dst, GR16:$src2)>;
5068def : Pat<(parallel (store (X86xor_flag (loadi32 addr:$dst), GR32:$src2),
5069 addr:$dst),
5070 (implicit EFLAGS)),
5071 (XOR32mr addr:$dst, GR32:$src2)>;
5072
5073// Memory-Integer XOr with EFLAGS result
5074def : Pat<(parallel (store (X86xor_flag (loadi8 addr:$dst), imm:$src2),
5075 addr:$dst),
5076 (implicit EFLAGS)),
5077 (XOR8mi addr:$dst, imm:$src2)>;
5078def : Pat<(parallel (store (X86xor_flag (loadi16 addr:$dst), imm:$src2),
5079 addr:$dst),
5080 (implicit EFLAGS)),
5081 (XOR16mi addr:$dst, imm:$src2)>;
5082def : Pat<(parallel (store (X86xor_flag (loadi32 addr:$dst), imm:$src2),
5083 addr:$dst),
5084 (implicit EFLAGS)),
5085 (XOR32mi addr:$dst, imm:$src2)>;
5086def : Pat<(parallel (store (X86xor_flag (loadi16 addr:$dst), i16immSExt8:$src2),
5087 addr:$dst),
5088 (implicit EFLAGS)),
5089 (XOR16mi8 addr:$dst, i16immSExt8:$src2)>;
5090def : Pat<(parallel (store (X86xor_flag (loadi32 addr:$dst), i32immSExt8:$src2),
5091 addr:$dst),
5092 (implicit EFLAGS)),
5093 (XOR32mi8 addr:$dst, i32immSExt8:$src2)>;
5094
5095// Register-Register And with EFLAGS result
5096def : Pat<(parallel (X86and_flag GR8:$src1, GR8:$src2),
5097 (implicit EFLAGS)),
5098 (AND8rr GR8:$src1, GR8:$src2)>;
5099def : Pat<(parallel (X86and_flag GR16:$src1, GR16:$src2),
5100 (implicit EFLAGS)),
5101 (AND16rr GR16:$src1, GR16:$src2)>;
5102def : Pat<(parallel (X86and_flag GR32:$src1, GR32:$src2),
5103 (implicit EFLAGS)),
5104 (AND32rr GR32:$src1, GR32:$src2)>;
5105
5106// Register-Memory And with EFLAGS result
5107def : Pat<(parallel (X86and_flag GR8:$src1, (loadi8 addr:$src2)),
5108 (implicit EFLAGS)),
5109 (AND8rm GR8:$src1, addr:$src2)>;
5110def : Pat<(parallel (X86and_flag GR16:$src1, (loadi16 addr:$src2)),
5111 (implicit EFLAGS)),
5112 (AND16rm GR16:$src1, addr:$src2)>;
5113def : Pat<(parallel (X86and_flag GR32:$src1, (loadi32 addr:$src2)),
5114 (implicit EFLAGS)),
5115 (AND32rm GR32:$src1, addr:$src2)>;
5116
5117// Register-Integer And with EFLAGS result
5118def : Pat<(parallel (X86and_flag GR8:$src1, imm:$src2),
5119 (implicit EFLAGS)),
5120 (AND8ri GR8:$src1, imm:$src2)>;
5121def : Pat<(parallel (X86and_flag GR16:$src1, imm:$src2),
5122 (implicit EFLAGS)),
5123 (AND16ri GR16:$src1, imm:$src2)>;
5124def : Pat<(parallel (X86and_flag GR32:$src1, imm:$src2),
5125 (implicit EFLAGS)),
5126 (AND32ri GR32:$src1, imm:$src2)>;
5127def : Pat<(parallel (X86and_flag GR16:$src1, i16immSExt8:$src2),
5128 (implicit EFLAGS)),
5129 (AND16ri8 GR16:$src1, i16immSExt8:$src2)>;
5130def : Pat<(parallel (X86and_flag GR32:$src1, i32immSExt8:$src2),
5131 (implicit EFLAGS)),
5132 (AND32ri8 GR32:$src1, i32immSExt8:$src2)>;
5133
5134// Memory-Register And with EFLAGS result
5135def : Pat<(parallel (store (X86and_flag (loadi8 addr:$dst), GR8:$src2),
5136 addr:$dst),
5137 (implicit EFLAGS)),
5138 (AND8mr addr:$dst, GR8:$src2)>;
5139def : Pat<(parallel (store (X86and_flag (loadi16 addr:$dst), GR16:$src2),
5140 addr:$dst),
5141 (implicit EFLAGS)),
5142 (AND16mr addr:$dst, GR16:$src2)>;
5143def : Pat<(parallel (store (X86and_flag (loadi32 addr:$dst), GR32:$src2),
5144 addr:$dst),
5145 (implicit EFLAGS)),
5146 (AND32mr addr:$dst, GR32:$src2)>;
5147
5148// Memory-Integer And with EFLAGS result
5149def : Pat<(parallel (store (X86and_flag (loadi8 addr:$dst), imm:$src2),
5150 addr:$dst),
5151 (implicit EFLAGS)),
5152 (AND8mi addr:$dst, imm:$src2)>;
5153def : Pat<(parallel (store (X86and_flag (loadi16 addr:$dst), imm:$src2),
5154 addr:$dst),
5155 (implicit EFLAGS)),
5156 (AND16mi addr:$dst, imm:$src2)>;
5157def : Pat<(parallel (store (X86and_flag (loadi32 addr:$dst), imm:$src2),
5158 addr:$dst),
5159 (implicit EFLAGS)),
5160 (AND32mi addr:$dst, imm:$src2)>;
5161def : Pat<(parallel (store (X86and_flag (loadi16 addr:$dst), i16immSExt8:$src2),
5162 addr:$dst),
5163 (implicit EFLAGS)),
5164 (AND16mi8 addr:$dst, i16immSExt8:$src2)>;
5165def : Pat<(parallel (store (X86and_flag (loadi32 addr:$dst), i32immSExt8:$src2),
5166 addr:$dst),
5167 (implicit EFLAGS)),
5168 (AND32mi8 addr:$dst, i32immSExt8:$src2)>;
5169
Dan Gohman2f67df72009-09-03 17:18:51 +00005170// -disable-16bit support.
5171def : Pat<(truncstorei16 (i32 imm:$src), addr:$dst),
5172 (MOV16mi addr:$dst, imm:$src)>;
5173def : Pat<(truncstorei16 GR32:$src, addr:$dst),
5174 (MOV16mr addr:$dst, (EXTRACT_SUBREG GR32:$src, x86_subreg_16bit))>;
5175def : Pat<(i32 (sextloadi16 addr:$dst)),
5176 (MOVSX32rm16 addr:$dst)>;
5177def : Pat<(i32 (zextloadi16 addr:$dst)),
5178 (MOVZX32rm16 addr:$dst)>;
5179def : Pat<(i32 (extloadi16 addr:$dst)),
5180 (MOVZX32rm16 addr:$dst)>;
5181
Bill Wendlingd350e022008-12-12 21:15:41 +00005182//===----------------------------------------------------------------------===//
Evan Cheng4e4c71e2006-02-21 20:00:20 +00005183// Floating Point Stack Support
5184//===----------------------------------------------------------------------===//
5185
5186include "X86InstrFPStack.td"
5187
5188//===----------------------------------------------------------------------===//
Evan Chengc64a1a92007-07-31 08:04:03 +00005189// X86-64 Support
5190//===----------------------------------------------------------------------===//
5191
Chris Lattner36fe6d22008-01-10 05:50:42 +00005192include "X86Instr64bit.td"
Evan Chengc64a1a92007-07-31 08:04:03 +00005193
5194//===----------------------------------------------------------------------===//
Evan Cheng4e4c71e2006-02-21 20:00:20 +00005195// XMM Floating point support (requires SSE / SSE2)
5196//===----------------------------------------------------------------------===//
5197
5198include "X86InstrSSE.td"
Evan Cheng80f54042008-04-25 18:19:54 +00005199
5200//===----------------------------------------------------------------------===//
5201// MMX and XMM Packed Integer support (requires MMX, SSE, and SSE2)
5202//===----------------------------------------------------------------------===//
5203
5204include "X86InstrMMX.td"