blob: b6f9e162dbf818e640609dbd9198a97706ac63cd [file] [log] [blame]
Sean Callanan2c48df22009-12-18 00:01:26 +00001
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002//
3// The LLVM Compiler Infrastructure
4//
Chris Lattner081ce942007-12-29 20:36:04 +00005// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
Dan Gohmanf17a25c2007-07-18 16:29:46 +00007//
8//===----------------------------------------------------------------------===//
9//
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
16//===----------------------------------------------------------------------===//
17// X86 specific DAG Nodes.
18//
19
20def SDTIntShiftDOp: SDTypeProfile<1, 3,
21 [SDTCisSameAs<0, 1>, SDTCisSameAs<0, 2>,
22 SDTCisInt<0>, SDTCisInt<3>]>;
23
24def SDTX86CmpTest : SDTypeProfile<0, 2, [SDTCisSameAs<0, 1>]>;
25
Evan Cheng621216e2007-09-29 00:00:36 +000026def SDTX86Cmov : SDTypeProfile<1, 4,
Evan Cheng950aac02007-09-25 01:57:46 +000027 [SDTCisSameAs<0, 1>, SDTCisSameAs<1, 2>,
28 SDTCisVT<3, i8>, SDTCisVT<4, i32>]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +000029
Dan Gohman99a12192009-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 Cheng621216e2007-09-29 00:00:36 +000037def SDTX86BrCond : SDTypeProfile<0, 3,
Evan Cheng950aac02007-09-25 01:57:46 +000038 [SDTCisVT<0, OtherVT>,
39 SDTCisVT<1, i8>, SDTCisVT<2, i32>]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +000040
Evan Cheng621216e2007-09-29 00:00:36 +000041def SDTX86SetCC : SDTypeProfile<1, 2,
Evan Cheng950aac02007-09-25 01:57:46 +000042 [SDTCisVT<0, i8>,
43 SDTCisVT<1, i8>, SDTCisVT<2, i32>]>;
Evan Chengedeb1692009-12-16 00:53:11 +000044def SDTX86SetCC_C : SDTypeProfile<1, 2,
45 [SDTCisInt<0>,
46 SDTCisVT<1, i8>, SDTCisVT<2, i32>]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +000047
Andrew Lenharth7dfe23f2008-03-01 21:52:34 +000048def SDTX86cas : SDTypeProfile<0, 3, [SDTCisPtrTy<0>, SDTCisInt<1>,
49 SDTCisVT<2, i8>]>;
Andrew Lenharth81580822008-03-05 01:15:49 +000050def SDTX86cas8 : SDTypeProfile<0, 1, [SDTCisPtrTy<0>]>;
Andrew Lenharth7dfe23f2008-03-01 21:52:34 +000051
Dale Johannesenf160d802008-10-02 18:53:47 +000052def SDTX86atomicBinary : SDTypeProfile<2, 3, [SDTCisInt<0>, SDTCisInt<1>,
53 SDTCisPtrTy<2>, SDTCisInt<3>,SDTCisInt<4>]>;
Chris Lattnerb56cc342008-03-11 03:23:40 +000054def SDTX86Ret : SDTypeProfile<0, -1, [SDTCisVT<0, i16>]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +000055
Sean Callanan2c8a2592009-06-23 23:25:37 +000056def SDT_X86CallSeqStart : SDCallSeqStart<[SDTCisVT<0, i32>]>;
57def SDT_X86CallSeqEnd : SDCallSeqEnd<[SDTCisVT<0, i32>,
58 SDTCisVT<1, i32>]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +000059
Dan Gohman3329ffe2008-05-29 19:57:41 +000060def SDT_X86Call : SDTypeProfile<0, -1, [SDTCisVT<0, iPTR>]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +000061
Dan Gohman34228bf2009-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
Dan Gohmanf17a25c2007-07-18 16:29:46 +000066def SDTX86RepStr : SDTypeProfile<0, 1, [SDTCisVT<0, OtherVT>]>;
67
68def SDTX86RdTsc : SDTypeProfile<0, 0, []>;
69
70def SDTX86Wrapper : SDTypeProfile<1, 1, [SDTCisSameAs<0, 1>, SDTCisPtrTy<0>]>;
71
Rafael Espindolaaf759ab2009-04-17 14:35:58 +000072def SDT_X86TLSADDR : SDTypeProfile<0, 1, [SDTCisInt<0>]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +000073
Rafael Espindolabca99f72009-04-08 21:14:34 +000074def SDT_X86SegmentBaseAddress : SDTypeProfile<1, 1, [SDTCisPtrTy<0>]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +000075
76def SDT_X86EHRET : SDTypeProfile<0, 1, [SDTCisInt<0>]>;
77
Arnold Schwaighofere2d6bbb2007-10-11 19:40:01 +000078def SDT_X86TCRET : SDTypeProfile<0, 2, [SDTCisPtrTy<0>, SDTCisVT<1, i32>]>;
79
Evan Cheng48679f42007-12-14 02:13:44 +000080def X86bsf : SDNode<"X86ISD::BSF", SDTIntUnaryOp>;
81def X86bsr : SDNode<"X86ISD::BSR", SDTIntUnaryOp>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +000082def X86shld : SDNode<"X86ISD::SHLD", SDTIntShiftDOp>;
83def X86shrd : SDNode<"X86ISD::SHRD", SDTIntShiftDOp>;
84
Evan Cheng621216e2007-09-29 00:00:36 +000085def X86cmp : SDNode<"X86ISD::CMP" , SDTX86CmpTest>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +000086
Dan Gohman7fe9b7f2008-12-23 22:45:23 +000087def X86bt : SDNode<"X86ISD::BT", SDTX86CmpTest>;
88
Evan Cheng621216e2007-09-29 00:00:36 +000089def X86cmov : SDNode<"X86ISD::CMOV", SDTX86Cmov>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +000090def X86brcond : SDNode<"X86ISD::BRCOND", SDTX86BrCond,
Evan Cheng950aac02007-09-25 01:57:46 +000091 [SDNPHasChain]>;
Evan Cheng621216e2007-09-29 00:00:36 +000092def X86setcc : SDNode<"X86ISD::SETCC", SDTX86SetCC>;
Evan Chengedeb1692009-12-16 00:53:11 +000093def X86setcc_c : SDNode<"X86ISD::SETCC_CARRY", SDTX86SetCC_C>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +000094
Andrew Lenharth7dfe23f2008-03-01 21:52:34 +000095def X86cas : SDNode<"X86ISD::LCMPXCHG_DAG", SDTX86cas,
96 [SDNPHasChain, SDNPInFlag, SDNPOutFlag, SDNPMayStore,
97 SDNPMayLoad]>;
Andrew Lenharth81580822008-03-05 01:15:49 +000098def X86cas8 : SDNode<"X86ISD::LCMPXCHG8_DAG", SDTX86cas8,
99 [SDNPHasChain, SDNPInFlag, SDNPOutFlag, SDNPMayStore,
100 SDNPMayLoad]>;
Dale Johannesenf160d802008-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 Johannesen51c58ee2008-10-03 22:25:52 +0000119def X86AtomSwap64 : SDNode<"X86ISD::ATOMSWAP64_DAG", SDTX86atomicBinary,
120 [SDNPHasChain, SDNPMayStore,
121 SDNPMayLoad, SDNPMemOperand]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000122def X86retflag : SDNode<"X86ISD::RET_FLAG", SDTX86Ret,
123 [SDNPHasChain, SDNPOptInFlag]>;
124
Dan Gohman34228bf2009-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
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000130def X86callseq_start :
131 SDNode<"ISD::CALLSEQ_START", SDT_X86CallSeqStart,
132 [SDNPHasChain, SDNPOutFlag]>;
133def X86callseq_end :
134 SDNode<"ISD::CALLSEQ_END", SDT_X86CallSeqEnd,
Arnold Schwaighofere2d6bbb2007-10-11 19:40:01 +0000135 [SDNPHasChain, SDNPOptInFlag, SDNPOutFlag]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000136
137def X86call : SDNode<"X86ISD::CALL", SDT_X86Call,
138 [SDNPHasChain, SDNPOutFlag, SDNPOptInFlag]>;
139
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000140def X86rep_stos: SDNode<"X86ISD::REP_STOS", SDTX86RepStr,
Chris Lattnerca4e0fe2008-01-10 05:12:37 +0000141 [SDNPHasChain, SDNPInFlag, SDNPOutFlag, SDNPMayStore]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000142def X86rep_movs: SDNode<"X86ISD::REP_MOVS", SDTX86RepStr,
Chris Lattnerca4e0fe2008-01-10 05:12:37 +0000143 [SDNPHasChain, SDNPInFlag, SDNPOutFlag, SDNPMayStore,
144 SDNPMayLoad]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000145
146def X86rdtsc : SDNode<"X86ISD::RDTSC_DAG",SDTX86RdTsc,
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000147 [SDNPHasChain, SDNPOutFlag, SDNPSideEffect]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000148
149def X86Wrapper : SDNode<"X86ISD::Wrapper", SDTX86Wrapper>;
150def X86WrapperRIP : SDNode<"X86ISD::WrapperRIP", SDTX86Wrapper>;
151
152def X86tlsaddr : SDNode<"X86ISD::TLSADDR", SDT_X86TLSADDR,
Anton Korobeynikov4fbf00b2008-05-04 21:36:32 +0000153 [SDNPHasChain, SDNPOptInFlag, SDNPOutFlag]>;
Rafael Espindolabca99f72009-04-08 21:14:34 +0000154def X86SegmentBaseAddress : SDNode<"X86ISD::SegmentBaseAddress",
155 SDT_X86SegmentBaseAddress, []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000156
157def X86ehret : SDNode<"X86ISD::EH_RETURN", SDT_X86EHRET,
158 [SDNPHasChain]>;
159
Arnold Schwaighofere2d6bbb2007-10-11 19:40:01 +0000160def X86tcret : SDNode<"X86ISD::TC_RETURN", SDT_X86TCRET,
161 [SDNPHasChain, SDNPOptInFlag]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000162
Dan Gohmane8a1a482010-01-04 20:51:05 +0000163def X86add_flag : SDNode<"X86ISD::ADD", SDTBinaryArithWithFlags,
Dan Gohman8c9198e2010-01-05 00:44:20 +0000164 [SDNPCommutative]>;
Dan Gohman99a12192009-03-04 19:44:21 +0000165def X86sub_flag : SDNode<"X86ISD::SUB", SDTBinaryArithWithFlags>;
Dan Gohmane8a1a482010-01-04 20:51:05 +0000166def X86smul_flag : SDNode<"X86ISD::SMUL", SDTBinaryArithWithFlags,
Dan Gohman8c9198e2010-01-05 00:44:20 +0000167 [SDNPCommutative]>;
Dan Gohmane8a1a482010-01-04 20:51:05 +0000168def X86umul_flag : SDNode<"X86ISD::UMUL", SDTUnaryArithWithFlags,
Dan Gohman8c9198e2010-01-05 00:44:20 +0000169 [SDNPCommutative]>;
Dan Gohman99a12192009-03-04 19:44:21 +0000170def X86inc_flag : SDNode<"X86ISD::INC", SDTUnaryArithWithFlags>;
171def X86dec_flag : SDNode<"X86ISD::DEC", SDTUnaryArithWithFlags>;
Dan Gohmane8a1a482010-01-04 20:51:05 +0000172def X86or_flag : SDNode<"X86ISD::OR", SDTBinaryArithWithFlags,
Dan Gohman8c9198e2010-01-05 00:44:20 +0000173 [SDNPCommutative]>;
Dan Gohmane8a1a482010-01-04 20:51:05 +0000174def X86xor_flag : SDNode<"X86ISD::XOR", SDTBinaryArithWithFlags,
Dan Gohman8c9198e2010-01-05 00:44:20 +0000175 [SDNPCommutative]>;
Dan Gohmane8a1a482010-01-04 20:51:05 +0000176def X86and_flag : SDNode<"X86ISD::AND", SDTBinaryArithWithFlags,
Dan Gohman8c9198e2010-01-05 00:44:20 +0000177 [SDNPCommutative]>;
Bill Wendlingae034ed2008-12-12 00:56:36 +0000178
Evan Chengc3495762009-03-30 21:36:47 +0000179def X86mul_imm : SDNode<"X86ISD::MUL_IMM", SDTIntBinOp>;
180
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000181//===----------------------------------------------------------------------===//
182// X86 Operand Definitions.
183//
184
Dan Gohmanfe606822009-07-30 01:56:29 +0000185// A version of ptr_rc which excludes SP, ESP, and RSP. This is used for
186// the index operand of an address, to conform to x86 encoding restrictions.
187def ptr_rc_nosp : PointerLikeRegClass<1>;
Chris Lattner357a0ca2009-06-20 19:34:09 +0000188
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000189// *mem - Operand definitions for the funky X86 addressing mode operands.
190//
Daniel Dunbar0f10cbf2009-08-10 18:41:10 +0000191def X86MemAsmOperand : AsmOperandClass {
192 let Name = "Mem";
Daniel Dunbar6e9ee792009-08-10 19:08:02 +0000193 let SuperClass = ?;
Daniel Dunbar0f10cbf2009-08-10 18:41:10 +0000194}
Daniel Dunbar4dcefd72010-01-30 01:02:48 +0000195def X86AbsMemAsmOperand : AsmOperandClass {
196 let Name = "AbsMem";
197 let SuperClass = X86MemAsmOperand;
198}
Daniel Dunbarfc1b32a2010-01-30 00:24:00 +0000199def X86NoSegMemAsmOperand : AsmOperandClass {
200 let Name = "NoSegMem";
201 let SuperClass = X86MemAsmOperand;
202}
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000203class X86MemOperand<string printMethod> : Operand<iPTR> {
204 let PrintMethod = printMethod;
Dan Gohmanfe606822009-07-30 01:56:29 +0000205 let MIOperandInfo = (ops ptr_rc, i8imm, ptr_rc_nosp, i32imm, i8imm);
Daniel Dunbar0f10cbf2009-08-10 18:41:10 +0000206 let ParserMatchClass = X86MemAsmOperand;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000207}
208
Sean Callanan66fdfa02009-09-03 00:04:47 +0000209def opaque32mem : X86MemOperand<"printopaquemem">;
210def opaque48mem : X86MemOperand<"printopaquemem">;
211def opaque80mem : X86MemOperand<"printopaquemem">;
Sean Callanan2c48df22009-12-18 00:01:26 +0000212def opaque512mem : X86MemOperand<"printopaquemem">;
213
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000214def i8mem : X86MemOperand<"printi8mem">;
215def i16mem : X86MemOperand<"printi16mem">;
216def i32mem : X86MemOperand<"printi32mem">;
217def i64mem : X86MemOperand<"printi64mem">;
218def i128mem : X86MemOperand<"printi128mem">;
Chris Lattnerd6153b42009-09-20 07:17:49 +0000219//def i256mem : X86MemOperand<"printi256mem">;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000220def f32mem : X86MemOperand<"printf32mem">;
221def f64mem : X86MemOperand<"printf64mem">;
Dale Johannesen4ab00bd2007-08-05 18:49:15 +0000222def f80mem : X86MemOperand<"printf80mem">;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000223def f128mem : X86MemOperand<"printf128mem">;
Chris Lattnerd6153b42009-09-20 07:17:49 +0000224//def f256mem : X86MemOperand<"printf256mem">;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000225
Dan Gohman744d4622009-04-13 16:09:41 +0000226// A version of i8mem for use on x86-64 that uses GR64_NOREX instead of
227// plain GR64, so that it doesn't potentially require a REX prefix.
228def i8mem_NOREX : Operand<i64> {
229 let PrintMethod = "printi8mem";
Dan Gohmanfe606822009-07-30 01:56:29 +0000230 let MIOperandInfo = (ops GR64_NOREX, i8imm, GR64_NOREX_NOSP, i32imm, i8imm);
Daniel Dunbar0f10cbf2009-08-10 18:41:10 +0000231 let ParserMatchClass = X86MemAsmOperand;
Dan Gohman744d4622009-04-13 16:09:41 +0000232}
233
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000234def lea32mem : Operand<i32> {
Rafael Espindolabca99f72009-04-08 21:14:34 +0000235 let PrintMethod = "printlea32mem";
Dan Gohmanefbd3bc2009-08-05 17:40:24 +0000236 let MIOperandInfo = (ops GR32, i8imm, GR32_NOSP, i32imm);
Daniel Dunbarfc1b32a2010-01-30 00:24:00 +0000237 let ParserMatchClass = X86NoSegMemAsmOperand;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000238}
239
Daniel Dunbar4dcefd72010-01-30 01:02:48 +0000240let ParserMatchClass = X86AbsMemAsmOperand,
241 PrintMethod = "print_pcrel_imm" in {
Daniel Dunbar3da218f2010-01-30 00:24:12 +0000242def i32imm_pcrel : Operand<i32>;
243
244def offset8 : Operand<i64>;
245def offset16 : Operand<i64>;
246def offset32 : Operand<i64>;
247def offset64 : Operand<i64>;
248
249// Branch targets have OtherVT type and print as pc-relative values.
250def brtarget : Operand<OtherVT>;
251def brtarget8 : Operand<OtherVT>;
252
253}
254
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000255def SSECC : Operand<i8> {
256 let PrintMethod = "printSSECC";
257}
258
Daniel Dunbar0f10cbf2009-08-10 18:41:10 +0000259def ImmSExt8AsmOperand : AsmOperandClass {
260 let Name = "ImmSExt8";
261 let SuperClass = ImmAsmOperand;
262}
263
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000264// A couple of more descriptive operand definitions.
265// 16-bits but only 8 bits are significant.
Daniel Dunbar06d5cb62009-08-09 07:20:21 +0000266def i16i8imm : Operand<i16> {
Daniel Dunbar0f10cbf2009-08-10 18:41:10 +0000267 let ParserMatchClass = ImmSExt8AsmOperand;
Daniel Dunbar06d5cb62009-08-09 07:20:21 +0000268}
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000269// 32-bits but only 8 bits are significant.
Daniel Dunbar06d5cb62009-08-09 07:20:21 +0000270def i32i8imm : Operand<i32> {
Daniel Dunbar0f10cbf2009-08-10 18:41:10 +0000271 let ParserMatchClass = ImmSExt8AsmOperand;
Daniel Dunbar06d5cb62009-08-09 07:20:21 +0000272}
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000273
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000274//===----------------------------------------------------------------------===//
275// X86 Complex Pattern Definitions.
276//
277
278// Define X86 specific addressing mode.
Rafael Espindolabca99f72009-04-08 21:14:34 +0000279def addr : ComplexPattern<iPTR, 5, "SelectAddr", [], []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000280def lea32addr : ComplexPattern<i32, 4, "SelectLEAAddr",
Dan Gohman0c0d7412009-08-02 16:09:17 +0000281 [add, sub, mul, X86mul_imm, shl, or, frameindex],
282 []>;
Chris Lattnerf1940742009-06-20 20:38:48 +0000283def tls32addr : ComplexPattern<i32, 4, "SelectTLSADDRAddr",
284 [tglobaltlsaddr], []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000285
286//===----------------------------------------------------------------------===//
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000287// X86 Instruction Predicate Definitions.
288def HasMMX : Predicate<"Subtarget->hasMMX()">;
289def HasSSE1 : Predicate<"Subtarget->hasSSE1()">;
290def HasSSE2 : Predicate<"Subtarget->hasSSE2()">;
291def HasSSE3 : Predicate<"Subtarget->hasSSE3()">;
292def HasSSSE3 : Predicate<"Subtarget->hasSSSE3()">;
Nate Begemanb2975562008-02-03 07:18:54 +0000293def HasSSE41 : Predicate<"Subtarget->hasSSE41()">;
294def HasSSE42 : Predicate<"Subtarget->hasSSE42()">;
David Greene8bf22bc2009-06-26 22:46:54 +0000295def HasSSE4A : Predicate<"Subtarget->hasSSE4A()">;
296def HasAVX : Predicate<"Subtarget->hasAVX()">;
297def HasFMA3 : Predicate<"Subtarget->hasFMA3()">;
298def HasFMA4 : Predicate<"Subtarget->hasFMA4()">;
Dale Johannesene0e0fd02007-09-23 14:52:20 +0000299def FPStackf32 : Predicate<"!Subtarget->hasSSE1()">;
300def FPStackf64 : Predicate<"!Subtarget->hasSSE2()">;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000301def In32BitMode : Predicate<"!Subtarget->is64Bit()">;
302def In64BitMode : Predicate<"Subtarget->is64Bit()">;
Anton Korobeynikov2cbcdb72009-08-03 08:12:53 +0000303def IsWin64 : Predicate<"Subtarget->isTargetWin64()">;
304def NotWin64 : Predicate<"!Subtarget->isTargetWin64()">;
Anton Korobeynikov68d4eca2009-08-06 11:23:24 +0000305def SmallCode : Predicate<"TM.getCodeModel() == CodeModel::Small">;
306def KernelCode : Predicate<"TM.getCodeModel() == CodeModel::Kernel">;
307def FarData : Predicate<"TM.getCodeModel() != CodeModel::Small &&"
Anton Korobeynikov7e1178f2009-08-06 09:11:19 +0000308 "TM.getCodeModel() != CodeModel::Kernel">;
Anton Korobeynikov68d4eca2009-08-06 11:23:24 +0000309def NearData : Predicate<"TM.getCodeModel() == CodeModel::Small ||"
310 "TM.getCodeModel() == CodeModel::Kernel">;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000311def IsStatic : Predicate<"TM.getRelocationModel() == Reloc::Static">;
Evan Chengd53fca12009-12-22 17:47:23 +0000312def OptForSize : Predicate<"OptForSize">;
Evan Cheng13559d62008-09-26 23:41:32 +0000313def OptForSpeed : Predicate<"!OptForSize">;
Evan Cheng95a77fd2009-01-02 05:35:45 +0000314def FastBTMem : Predicate<"!Subtarget->isBTMemSlow()">;
Evan Cheng6d35a4d2009-05-20 04:53:57 +0000315def CallImmAddr : Predicate<"Subtarget->IsLegalToCallImmediateAddr(TM)">;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000316
317//===----------------------------------------------------------------------===//
Evan Cheng86ab7d32007-07-31 08:04:03 +0000318// X86 Instruction Format Definitions.
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000319//
320
Evan Cheng86ab7d32007-07-31 08:04:03 +0000321include "X86InstrFormats.td"
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000322
323//===----------------------------------------------------------------------===//
324// Pattern fragments...
325//
326
327// X86 specific condition code. These correspond to CondCode in
328// X86InstrInfo.h. They must be kept in synch.
Dan Gohman0fc9ed62009-01-07 00:15:08 +0000329def X86_COND_A : PatLeaf<(i8 0)>; // alt. COND_NBE
330def X86_COND_AE : PatLeaf<(i8 1)>; // alt. COND_NC
331def X86_COND_B : PatLeaf<(i8 2)>; // alt. COND_C
332def X86_COND_BE : PatLeaf<(i8 3)>; // alt. COND_NA
333def X86_COND_E : PatLeaf<(i8 4)>; // alt. COND_Z
334def X86_COND_G : PatLeaf<(i8 5)>; // alt. COND_NLE
335def X86_COND_GE : PatLeaf<(i8 6)>; // alt. COND_NL
336def X86_COND_L : PatLeaf<(i8 7)>; // alt. COND_NGE
337def X86_COND_LE : PatLeaf<(i8 8)>; // alt. COND_NG
338def X86_COND_NE : PatLeaf<(i8 9)>; // alt. COND_NZ
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000339def X86_COND_NO : PatLeaf<(i8 10)>;
Dan Gohman0fc9ed62009-01-07 00:15:08 +0000340def X86_COND_NP : PatLeaf<(i8 11)>; // alt. COND_PO
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000341def X86_COND_NS : PatLeaf<(i8 12)>;
Dan Gohman0fc9ed62009-01-07 00:15:08 +0000342def X86_COND_O : PatLeaf<(i8 13)>;
343def X86_COND_P : PatLeaf<(i8 14)>; // alt. COND_PE
344def X86_COND_S : PatLeaf<(i8 15)>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000345
346def i16immSExt8 : PatLeaf<(i16 imm), [{
347 // i16immSExt8 predicate - True if the 16-bit immediate fits in a 8-bit
348 // sign extended field.
Dan Gohmanfaeb4a32008-09-12 16:56:44 +0000349 return (int16_t)N->getZExtValue() == (int8_t)N->getZExtValue();
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000350}]>;
351
352def i32immSExt8 : PatLeaf<(i32 imm), [{
353 // i32immSExt8 predicate - True if the 32-bit immediate fits in a 8-bit
354 // sign extended field.
Dan Gohmanfaeb4a32008-09-12 16:56:44 +0000355 return (int32_t)N->getZExtValue() == (int8_t)N->getZExtValue();
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000356}]>;
357
358// Helper fragments for loads.
Evan Chengb3e25ea2008-05-13 18:59:59 +0000359// It's always safe to treat a anyext i16 load as a i32 load if the i16 is
360// known to be 32-bit aligned or better. Ditto for i8 to i16.
Dan Gohman2a174122008-10-15 06:50:19 +0000361def loadi16 : PatFrag<(ops node:$ptr), (i16 (unindexedload node:$ptr)), [{
Dan Gohman8335c412008-08-20 15:24:22 +0000362 LoadSDNode *LD = cast<LoadSDNode>(N);
Chris Lattner12208612009-04-10 00:16:23 +0000363 if (const Value *Src = LD->getSrcValue())
364 if (const PointerType *PT = dyn_cast<PointerType>(Src->getType()))
Mon P Wangdc97d5a2009-04-27 07:22:10 +0000365 if (PT->getAddressSpace() > 255)
Chris Lattner12208612009-04-10 00:16:23 +0000366 return false;
Dan Gohman8335c412008-08-20 15:24:22 +0000367 ISD::LoadExtType ExtType = LD->getExtensionType();
368 if (ExtType == ISD::NON_EXTLOAD)
369 return true;
370 if (ExtType == ISD::EXTLOAD)
371 return LD->getAlignment() >= 2 && !LD->isVolatile();
Evan Cheng8b765e92008-05-13 00:54:02 +0000372 return false;
373}]>;
374
Sean Callanan2c48df22009-12-18 00:01:26 +0000375def loadi16_anyext : PatFrag<(ops node:$ptr), (i32 (unindexedload node:$ptr)),
376[{
Evan Cheng56ec77b2008-09-24 23:27:55 +0000377 LoadSDNode *LD = cast<LoadSDNode>(N);
Chris Lattner12208612009-04-10 00:16:23 +0000378 if (const Value *Src = LD->getSrcValue())
379 if (const PointerType *PT = dyn_cast<PointerType>(Src->getType()))
Mon P Wangdc97d5a2009-04-27 07:22:10 +0000380 if (PT->getAddressSpace() > 255)
Chris Lattner12208612009-04-10 00:16:23 +0000381 return false;
Evan Cheng56ec77b2008-09-24 23:27:55 +0000382 ISD::LoadExtType ExtType = LD->getExtensionType();
383 if (ExtType == ISD::EXTLOAD)
384 return LD->getAlignment() >= 2 && !LD->isVolatile();
385 return false;
386}]>;
387
Dan Gohman2a174122008-10-15 06:50:19 +0000388def loadi32 : PatFrag<(ops node:$ptr), (i32 (unindexedload node:$ptr)), [{
Dan Gohman8335c412008-08-20 15:24:22 +0000389 LoadSDNode *LD = cast<LoadSDNode>(N);
Chris Lattner12208612009-04-10 00:16:23 +0000390 if (const Value *Src = LD->getSrcValue())
391 if (const PointerType *PT = dyn_cast<PointerType>(Src->getType()))
Mon P Wangdc97d5a2009-04-27 07:22:10 +0000392 if (PT->getAddressSpace() > 255)
Chris Lattner12208612009-04-10 00:16:23 +0000393 return false;
Dan Gohman8335c412008-08-20 15:24:22 +0000394 ISD::LoadExtType ExtType = LD->getExtensionType();
395 if (ExtType == ISD::NON_EXTLOAD)
396 return true;
397 if (ExtType == ISD::EXTLOAD)
398 return LD->getAlignment() >= 4 && !LD->isVolatile();
Evan Cheng8b765e92008-05-13 00:54:02 +0000399 return false;
400}]>;
401
Dan Gohman2a174122008-10-15 06:50:19 +0000402def nvloadi32 : PatFrag<(ops node:$ptr), (i32 (unindexedload node:$ptr)), [{
Evan Cheng1e5e5452008-09-29 17:26:18 +0000403 LoadSDNode *LD = cast<LoadSDNode>(N);
Chris Lattner12208612009-04-10 00:16:23 +0000404 if (const Value *Src = LD->getSrcValue())
405 if (const PointerType *PT = dyn_cast<PointerType>(Src->getType()))
Mon P Wangdc97d5a2009-04-27 07:22:10 +0000406 if (PT->getAddressSpace() > 255)
Chris Lattner12208612009-04-10 00:16:23 +0000407 return false;
Evan Cheng1e5e5452008-09-29 17:26:18 +0000408 if (LD->isVolatile())
409 return false;
Evan Cheng1e5e5452008-09-29 17:26:18 +0000410 ISD::LoadExtType ExtType = LD->getExtensionType();
411 if (ExtType == ISD::NON_EXTLOAD)
412 return true;
413 if (ExtType == ISD::EXTLOAD)
414 return LD->getAlignment() >= 4;
415 return false;
416}]>;
417
sampo9cc09a32009-01-26 01:24:32 +0000418def gsload : PatFrag<(ops node:$ptr), (load node:$ptr), [{
Chris Lattner12208612009-04-10 00:16:23 +0000419 if (const Value *Src = cast<LoadSDNode>(N)->getSrcValue())
420 if (const PointerType *PT = dyn_cast<PointerType>(Src->getType()))
421 return PT->getAddressSpace() == 256;
sampo9cc09a32009-01-26 01:24:32 +0000422 return false;
423}]>;
424
Chris Lattnera7c2d8a2009-05-05 18:52:19 +0000425def fsload : PatFrag<(ops node:$ptr), (load node:$ptr), [{
426 if (const Value *Src = cast<LoadSDNode>(N)->getSrcValue())
427 if (const PointerType *PT = dyn_cast<PointerType>(Src->getType()))
428 return PT->getAddressSpace() == 257;
429 return false;
430}]>;
431
Chris Lattner12208612009-04-10 00:16:23 +0000432def loadi8 : PatFrag<(ops node:$ptr), (i8 (load node:$ptr)), [{
433 if (const Value *Src = cast<LoadSDNode>(N)->getSrcValue())
434 if (const PointerType *PT = dyn_cast<PointerType>(Src->getType()))
Mon P Wangdc97d5a2009-04-27 07:22:10 +0000435 if (PT->getAddressSpace() > 255)
Chris Lattner12208612009-04-10 00:16:23 +0000436 return false;
437 return true;
438}]>;
439def loadi64 : PatFrag<(ops node:$ptr), (i64 (load node:$ptr)), [{
440 if (const Value *Src = cast<LoadSDNode>(N)->getSrcValue())
441 if (const PointerType *PT = dyn_cast<PointerType>(Src->getType()))
Mon P Wangdc97d5a2009-04-27 07:22:10 +0000442 if (PT->getAddressSpace() > 255)
Chris Lattner12208612009-04-10 00:16:23 +0000443 return false;
444 return true;
445}]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000446
Chris Lattner12208612009-04-10 00:16:23 +0000447def loadf32 : PatFrag<(ops node:$ptr), (f32 (load node:$ptr)), [{
448 if (const Value *Src = cast<LoadSDNode>(N)->getSrcValue())
449 if (const PointerType *PT = dyn_cast<PointerType>(Src->getType()))
Mon P Wangdc97d5a2009-04-27 07:22:10 +0000450 if (PT->getAddressSpace() > 255)
Chris Lattner12208612009-04-10 00:16:23 +0000451 return false;
452 return true;
453}]>;
454def loadf64 : PatFrag<(ops node:$ptr), (f64 (load node:$ptr)), [{
455 if (const Value *Src = cast<LoadSDNode>(N)->getSrcValue())
456 if (const PointerType *PT = dyn_cast<PointerType>(Src->getType()))
Mon P Wangdc97d5a2009-04-27 07:22:10 +0000457 if (PT->getAddressSpace() > 255)
Chris Lattner12208612009-04-10 00:16:23 +0000458 return false;
459 return true;
460}]>;
461def loadf80 : PatFrag<(ops node:$ptr), (f80 (load node:$ptr)), [{
462 if (const Value *Src = cast<LoadSDNode>(N)->getSrcValue())
463 if (const PointerType *PT = dyn_cast<PointerType>(Src->getType()))
Mon P Wangdc97d5a2009-04-27 07:22:10 +0000464 if (PT->getAddressSpace() > 255)
Chris Lattner12208612009-04-10 00:16:23 +0000465 return false;
466 return true;
467}]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000468
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000469def sextloadi16i8 : PatFrag<(ops node:$ptr), (i16 (sextloadi8 node:$ptr))>;
470def sextloadi32i8 : PatFrag<(ops node:$ptr), (i32 (sextloadi8 node:$ptr))>;
471def sextloadi32i16 : PatFrag<(ops node:$ptr), (i32 (sextloadi16 node:$ptr))>;
472
473def zextloadi8i1 : PatFrag<(ops node:$ptr), (i8 (zextloadi1 node:$ptr))>;
474def zextloadi16i1 : PatFrag<(ops node:$ptr), (i16 (zextloadi1 node:$ptr))>;
475def zextloadi32i1 : PatFrag<(ops node:$ptr), (i32 (zextloadi1 node:$ptr))>;
476def zextloadi16i8 : PatFrag<(ops node:$ptr), (i16 (zextloadi8 node:$ptr))>;
477def zextloadi32i8 : PatFrag<(ops node:$ptr), (i32 (zextloadi8 node:$ptr))>;
478def zextloadi32i16 : PatFrag<(ops node:$ptr), (i32 (zextloadi16 node:$ptr))>;
479
480def extloadi8i1 : PatFrag<(ops node:$ptr), (i8 (extloadi1 node:$ptr))>;
481def extloadi16i1 : PatFrag<(ops node:$ptr), (i16 (extloadi1 node:$ptr))>;
482def extloadi32i1 : PatFrag<(ops node:$ptr), (i32 (extloadi1 node:$ptr))>;
483def extloadi16i8 : PatFrag<(ops node:$ptr), (i16 (extloadi8 node:$ptr))>;
484def extloadi32i8 : PatFrag<(ops node:$ptr), (i32 (extloadi8 node:$ptr))>;
485def extloadi32i16 : PatFrag<(ops node:$ptr), (i32 (extloadi16 node:$ptr))>;
486
Chris Lattner21da6382008-02-19 17:37:35 +0000487
488// An 'and' node with a single use.
489def and_su : PatFrag<(ops node:$lhs, node:$rhs), (and node:$lhs, node:$rhs), [{
Evan Cheng9123cfa2008-03-04 00:40:35 +0000490 return N->hasOneUse();
Chris Lattner21da6382008-02-19 17:37:35 +0000491}]>;
Dan Gohman744d4622009-04-13 16:09:41 +0000492// An 'srl' node with a single use.
493def srl_su : PatFrag<(ops node:$lhs, node:$rhs), (srl node:$lhs, node:$rhs), [{
494 return N->hasOneUse();
495}]>;
496// An 'trunc' node with a single use.
497def trunc_su : PatFrag<(ops node:$src), (trunc node:$src), [{
498 return N->hasOneUse();
499}]>;
Chris Lattner21da6382008-02-19 17:37:35 +0000500
Evan Cheng4621d272010-01-11 17:03:47 +0000501// Treat an 'or' node is as an 'add' if the or'ed bits are known to be zero.
502def or_is_add : PatFrag<(ops node:$lhs, node:$rhs), (or node:$lhs, node:$rhs),[{
503 if (ConstantSDNode *CN = dyn_cast<ConstantSDNode>(N->getOperand(1)))
504 return CurDAG->MaskedValueIsZero(N->getOperand(0), CN->getAPIntValue());
Evan Cheng503d9c52010-01-11 22:03:29 +0000505 else {
506 unsigned BitWidth = N->getValueType(0).getScalarType().getSizeInBits();
507 APInt Mask = APInt::getAllOnesValue(BitWidth);
508 APInt KnownZero0, KnownOne0;
509 CurDAG->ComputeMaskedBits(N->getOperand(0), Mask, KnownZero0, KnownOne0, 0);
510 APInt KnownZero1, KnownOne1;
511 CurDAG->ComputeMaskedBits(N->getOperand(1), Mask, KnownZero1, KnownOne1, 0);
512 return (~KnownZero0 & ~KnownZero1) == 0;
513 }
Evan Cheng4621d272010-01-11 17:03:47 +0000514}]>;
Evan Cheng4621d272010-01-11 17:03:47 +0000515
Dan Gohman921581d2008-10-17 01:23:35 +0000516// 'shld' and 'shrd' instruction patterns. Note that even though these have
517// the srl and shl in their patterns, the C++ code must still check for them,
518// because predicates are tested before children nodes are explored.
519
520def shrd : PatFrag<(ops node:$src1, node:$amt1, node:$src2, node:$amt2),
521 (or (srl node:$src1, node:$amt1),
522 (shl node:$src2, node:$amt2)), [{
523 assert(N->getOpcode() == ISD::OR);
524 return N->getOperand(0).getOpcode() == ISD::SRL &&
525 N->getOperand(1).getOpcode() == ISD::SHL &&
526 isa<ConstantSDNode>(N->getOperand(0).getOperand(1)) &&
527 isa<ConstantSDNode>(N->getOperand(1).getOperand(1)) &&
528 N->getOperand(0).getConstantOperandVal(1) ==
529 N->getValueSizeInBits(0) - N->getOperand(1).getConstantOperandVal(1);
530}]>;
531
532def shld : PatFrag<(ops node:$src1, node:$amt1, node:$src2, node:$amt2),
533 (or (shl node:$src1, node:$amt1),
534 (srl node:$src2, node:$amt2)), [{
535 assert(N->getOpcode() == ISD::OR);
536 return N->getOperand(0).getOpcode() == ISD::SHL &&
537 N->getOperand(1).getOpcode() == ISD::SRL &&
538 isa<ConstantSDNode>(N->getOperand(0).getOperand(1)) &&
539 isa<ConstantSDNode>(N->getOperand(1).getOperand(1)) &&
540 N->getOperand(0).getConstantOperandVal(1) ==
541 N->getValueSizeInBits(0) - N->getOperand(1).getConstantOperandVal(1);
542}]>;
543
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000544//===----------------------------------------------------------------------===//
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000545// Instruction list...
546//
547
548// ADJCALLSTACKDOWN/UP implicitly use/def ESP because they may be expanded into
549// a stack adjustment and the codegen must know that they may modify the stack
550// pointer before prolog-epilog rewriting occurs.
Chris Lattnerb56cc342008-03-11 03:23:40 +0000551// Pessimistically assume ADJCALLSTACKDOWN / ADJCALLSTACKUP will become
552// sub / add which can clobber EFLAGS.
Evan Cheng037364a2007-09-28 01:19:48 +0000553let Defs = [ESP, EFLAGS], Uses = [ESP] in {
Dan Gohman01c9f772008-10-01 18:28:06 +0000554def ADJCALLSTACKDOWN32 : I<0, Pseudo, (outs), (ins i32imm:$amt),
555 "#ADJCALLSTACKDOWN",
Chris Lattnerfe5d4022008-10-11 22:08:30 +0000556 [(X86callseq_start timm:$amt)]>,
Dan Gohman01c9f772008-10-01 18:28:06 +0000557 Requires<[In32BitMode]>;
558def ADJCALLSTACKUP32 : I<0, Pseudo, (outs), (ins i32imm:$amt1, i32imm:$amt2),
559 "#ADJCALLSTACKUP",
Chris Lattnerfe5d4022008-10-11 22:08:30 +0000560 [(X86callseq_end timm:$amt1, timm:$amt2)]>,
Dan Gohman01c9f772008-10-01 18:28:06 +0000561 Requires<[In32BitMode]>;
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000562}
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000563
Dan Gohman34228bf2009-08-15 01:38:56 +0000564// x86-64 va_start lowering magic.
Dan Gohman30afe012009-10-29 18:10:34 +0000565let usesCustomInserter = 1 in
Dan Gohman34228bf2009-08-15 01:38:56 +0000566def VASTART_SAVE_XMM_REGS : I<0, Pseudo,
567 (outs),
568 (ins GR8:$al,
569 i64imm:$regsavefi, i64imm:$offset,
570 variable_ops),
571 "#VASTART_SAVE_XMM_REGS $al, $regsavefi, $offset",
572 [(X86vastart_save_xmm_regs GR8:$al,
573 imm:$regsavefi,
574 imm:$offset)]>;
575
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000576// Nop
Sean Callananf94a0542009-07-23 23:39:34 +0000577let neverHasSideEffects = 1 in {
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000578 def NOOP : I<0x90, RawFrm, (outs), (ins), "nop", []>;
Sean Callanan2c48df22009-12-18 00:01:26 +0000579 def NOOPW : I<0x1f, MRM0m, (outs), (ins i16mem:$zero),
580 "nop{w}\t$zero", []>, TB, OpSize;
Sean Callananf94a0542009-07-23 23:39:34 +0000581 def NOOPL : I<0x1f, MRM0m, (outs), (ins i32mem:$zero),
Sean Callanan2c48df22009-12-18 00:01:26 +0000582 "nop{l}\t$zero", []>, TB;
Sean Callananf94a0542009-07-23 23:39:34 +0000583}
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000584
Sean Callanan9b195f82009-08-11 01:09:06 +0000585// Trap
Dan Gohman8112b942009-11-11 18:07:16 +0000586def INT3 : I<0xcc, RawFrm, (outs), (ins), "int\t3", []>;
Sean Callanan9b195f82009-08-11 01:09:06 +0000587def INT : I<0xcd, RawFrm, (outs), (ins i8imm:$trap), "int\t$trap", []>;
Sean Callanan2c48df22009-12-18 00:01:26 +0000588def IRET16 : I<0xcf, RawFrm, (outs), (ins), "iret{w}", []>, OpSize;
589def IRET32 : I<0xcf, RawFrm, (outs), (ins), "iret{l}", []>;
Sean Callanan9b195f82009-08-11 01:09:06 +0000590
Chris Lattner2aa10da2009-09-20 07:32:00 +0000591// PIC base construction. This expands to code that looks like this:
592// call $next_inst
593// popl %destreg"
Dan Gohman9499cfe2008-10-01 04:14:30 +0000594let neverHasSideEffects = 1, isNotDuplicable = 1, Uses = [ESP] in
Chris Lattnera7e959d2009-09-20 07:28:26 +0000595 def MOVPC32r : Ii32<0xE8, Pseudo, (outs GR32:$reg), (ins i32imm:$label),
Chris Lattner2aa10da2009-09-20 07:32:00 +0000596 "", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000597
598//===----------------------------------------------------------------------===//
599// Control Flow Instructions...
600//
601
602// Return instructions.
603let isTerminator = 1, isReturn = 1, isBarrier = 1,
Chris Lattnerb56cc342008-03-11 03:23:40 +0000604 hasCtrlDep = 1, FPForm = SpecialFP, FPFormBits = SpecialFP.Value in {
Dan Gohman2c4be2a2008-05-31 02:11:25 +0000605 def RET : I <0xC3, RawFrm, (outs), (ins variable_ops),
Chris Lattnerb56cc342008-03-11 03:23:40 +0000606 "ret",
Dan Gohman2c4be2a2008-05-31 02:11:25 +0000607 [(X86retflag 0)]>;
Chris Lattnerb56cc342008-03-11 03:23:40 +0000608 def RETI : Ii16<0xC2, RawFrm, (outs), (ins i16imm:$amt, variable_ops),
609 "ret\t$amt",
Dan Gohmane84197b2009-09-03 17:18:51 +0000610 [(X86retflag timm:$amt)]>;
Sean Callanan7a012572009-09-15 23:37:51 +0000611 def LRET : I <0xCB, RawFrm, (outs), (ins),
612 "lret", []>;
613 def LRETI : Ii16<0xCA, RawFrm, (outs), (ins i16imm:$amt),
614 "lret\t$amt", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000615}
616
617// All branches are RawFrm, Void, Branch, and Terminators
Evan Cheng37e7c752007-07-21 00:34:19 +0000618let isBranch = 1, isTerminator = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +0000619 class IBr<bits<8> opcode, dag ins, string asm, list<dag> pattern> :
620 I<opcode, RawFrm, (outs), ins, asm, pattern>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000621
Sean Callananc0608152009-07-22 01:05:20 +0000622let isBranch = 1, isBarrier = 1 in {
Dan Gohman91888f02007-07-31 20:11:57 +0000623 def JMP : IBr<0xE9, (ins brtarget:$dst), "jmp\t$dst", [(br bb:$dst)]>;
Sean Callananc0608152009-07-22 01:05:20 +0000624 def JMP8 : IBr<0xEB, (ins brtarget8:$dst), "jmp\t$dst", []>;
625}
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000626
Owen Andersonf8053082007-11-12 07:39:39 +0000627// Indirect branches
628let isBranch = 1, isTerminator = 1, isBarrier = 1, isIndirectBranch = 1 in {
Dan Gohman91888f02007-07-31 20:11:57 +0000629 def JMP32r : I<0xFF, MRM4r, (outs), (ins GR32:$dst), "jmp{l}\t{*}$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000630 [(brind GR32:$dst)]>;
Dan Gohman91888f02007-07-31 20:11:57 +0000631 def JMP32m : I<0xFF, MRM4m, (outs), (ins i32mem:$dst), "jmp{l}\t{*}$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000632 [(brind (loadi32 addr:$dst))]>;
Sean Callananb7e73392009-09-15 00:35:17 +0000633
634 def FARJMP16i : Iseg16<0xEA, RawFrm, (outs),
635 (ins i16imm:$seg, i16imm:$off),
636 "ljmp{w}\t$seg, $off", []>, OpSize;
637 def FARJMP32i : Iseg32<0xEA, RawFrm, (outs),
638 (ins i16imm:$seg, i32imm:$off),
639 "ljmp{l}\t$seg, $off", []>;
640
641 def FARJMP16m : I<0xFF, MRM5m, (outs), (ins opaque32mem:$dst),
Sean Callanan66fdfa02009-09-03 00:04:47 +0000642 "ljmp{w}\t{*}$dst", []>, OpSize;
Sean Callananb7e73392009-09-15 00:35:17 +0000643 def FARJMP32m : I<0xFF, MRM5m, (outs), (ins opaque48mem:$dst),
Sean Callanan66fdfa02009-09-03 00:04:47 +0000644 "ljmp{l}\t{*}$dst", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000645}
646
647// Conditional branches
Evan Cheng950aac02007-09-25 01:57:46 +0000648let Uses = [EFLAGS] in {
Evan Chengd11052b2009-07-21 06:00:18 +0000649// Short conditional jumps
650def JO8 : IBr<0x70, (ins brtarget8:$dst), "jo\t$dst", []>;
651def JNO8 : IBr<0x71, (ins brtarget8:$dst), "jno\t$dst", []>;
652def JB8 : IBr<0x72, (ins brtarget8:$dst), "jb\t$dst", []>;
653def JAE8 : IBr<0x73, (ins brtarget8:$dst), "jae\t$dst", []>;
654def JE8 : IBr<0x74, (ins brtarget8:$dst), "je\t$dst", []>;
655def JNE8 : IBr<0x75, (ins brtarget8:$dst), "jne\t$dst", []>;
656def JBE8 : IBr<0x76, (ins brtarget8:$dst), "jbe\t$dst", []>;
657def JA8 : IBr<0x77, (ins brtarget8:$dst), "ja\t$dst", []>;
658def JS8 : IBr<0x78, (ins brtarget8:$dst), "js\t$dst", []>;
659def JNS8 : IBr<0x79, (ins brtarget8:$dst), "jns\t$dst", []>;
660def JP8 : IBr<0x7A, (ins brtarget8:$dst), "jp\t$dst", []>;
661def JNP8 : IBr<0x7B, (ins brtarget8:$dst), "jnp\t$dst", []>;
662def JL8 : IBr<0x7C, (ins brtarget8:$dst), "jl\t$dst", []>;
663def JGE8 : IBr<0x7D, (ins brtarget8:$dst), "jge\t$dst", []>;
664def JLE8 : IBr<0x7E, (ins brtarget8:$dst), "jle\t$dst", []>;
665def JG8 : IBr<0x7F, (ins brtarget8:$dst), "jg\t$dst", []>;
666
667def JCXZ8 : IBr<0xE3, (ins brtarget8:$dst), "jcxz\t$dst", []>;
668
Dan Gohman91888f02007-07-31 20:11:57 +0000669def JE : IBr<0x84, (ins brtarget:$dst), "je\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000670 [(X86brcond bb:$dst, X86_COND_E, EFLAGS)]>, TB;
Dan Gohman91888f02007-07-31 20:11:57 +0000671def JNE : IBr<0x85, (ins brtarget:$dst), "jne\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000672 [(X86brcond bb:$dst, X86_COND_NE, EFLAGS)]>, TB;
Dan Gohman91888f02007-07-31 20:11:57 +0000673def JL : IBr<0x8C, (ins brtarget:$dst), "jl\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000674 [(X86brcond bb:$dst, X86_COND_L, EFLAGS)]>, TB;
Dan Gohman91888f02007-07-31 20:11:57 +0000675def JLE : IBr<0x8E, (ins brtarget:$dst), "jle\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000676 [(X86brcond bb:$dst, X86_COND_LE, EFLAGS)]>, TB;
Dan Gohman91888f02007-07-31 20:11:57 +0000677def JG : IBr<0x8F, (ins brtarget:$dst), "jg\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000678 [(X86brcond bb:$dst, X86_COND_G, EFLAGS)]>, TB;
Dan Gohman91888f02007-07-31 20:11:57 +0000679def JGE : IBr<0x8D, (ins brtarget:$dst), "jge\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000680 [(X86brcond bb:$dst, X86_COND_GE, EFLAGS)]>, TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000681
Dan Gohman91888f02007-07-31 20:11:57 +0000682def JB : IBr<0x82, (ins brtarget:$dst), "jb\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000683 [(X86brcond bb:$dst, X86_COND_B, EFLAGS)]>, TB;
Dan Gohman91888f02007-07-31 20:11:57 +0000684def JBE : IBr<0x86, (ins brtarget:$dst), "jbe\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000685 [(X86brcond bb:$dst, X86_COND_BE, EFLAGS)]>, TB;
Dan Gohman91888f02007-07-31 20:11:57 +0000686def JA : IBr<0x87, (ins brtarget:$dst), "ja\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000687 [(X86brcond bb:$dst, X86_COND_A, EFLAGS)]>, TB;
Dan Gohman91888f02007-07-31 20:11:57 +0000688def JAE : IBr<0x83, (ins brtarget:$dst), "jae\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000689 [(X86brcond bb:$dst, X86_COND_AE, EFLAGS)]>, TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000690
Dan Gohman91888f02007-07-31 20:11:57 +0000691def JS : IBr<0x88, (ins brtarget:$dst), "js\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000692 [(X86brcond bb:$dst, X86_COND_S, EFLAGS)]>, TB;
Dan Gohman91888f02007-07-31 20:11:57 +0000693def JNS : IBr<0x89, (ins brtarget:$dst), "jns\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000694 [(X86brcond bb:$dst, X86_COND_NS, EFLAGS)]>, TB;
Dan Gohman91888f02007-07-31 20:11:57 +0000695def JP : IBr<0x8A, (ins brtarget:$dst), "jp\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000696 [(X86brcond bb:$dst, X86_COND_P, EFLAGS)]>, TB;
Dan Gohman91888f02007-07-31 20:11:57 +0000697def JNP : IBr<0x8B, (ins brtarget:$dst), "jnp\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000698 [(X86brcond bb:$dst, X86_COND_NP, EFLAGS)]>, TB;
Dan Gohman91888f02007-07-31 20:11:57 +0000699def JO : IBr<0x80, (ins brtarget:$dst), "jo\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000700 [(X86brcond bb:$dst, X86_COND_O, EFLAGS)]>, TB;
Dan Gohman91888f02007-07-31 20:11:57 +0000701def JNO : IBr<0x81, (ins brtarget:$dst), "jno\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000702 [(X86brcond bb:$dst, X86_COND_NO, EFLAGS)]>, TB;
Evan Cheng950aac02007-09-25 01:57:46 +0000703} // Uses = [EFLAGS]
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000704
Sean Callanan503784b2009-09-16 21:50:07 +0000705// Loop instructions
706
707def LOOP : I<0xE2, RawFrm, (ins brtarget8:$dst), (outs), "loop\t$dst", []>;
708def LOOPE : I<0xE1, RawFrm, (ins brtarget8:$dst), (outs), "loope\t$dst", []>;
709def LOOPNE : I<0xE0, RawFrm, (ins brtarget8:$dst), (outs), "loopne\t$dst", []>;
710
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000711//===----------------------------------------------------------------------===//
712// Call Instructions...
713//
Evan Cheng37e7c752007-07-21 00:34:19 +0000714let isCall = 1 in
Dan Gohman01c9f772008-10-01 18:28:06 +0000715 // All calls clobber the non-callee saved registers. ESP is marked as
716 // a use to prevent stack-pointer assignments that appear immediately
717 // before calls from potentially appearing dead. Uses for argument
718 // registers are added manually.
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000719 let Defs = [EAX, ECX, EDX, FP0, FP1, FP2, FP3, FP4, FP5, FP6, ST0,
720 MM0, MM1, MM2, MM3, MM4, MM5, MM6, MM7,
Evan Cheng2293b252008-10-17 21:02:22 +0000721 XMM0, XMM1, XMM2, XMM3, XMM4, XMM5, XMM6, XMM7,
722 XMM8, XMM9, XMM10, XMM11, XMM12, XMM13, XMM14, XMM15, EFLAGS],
Dan Gohman9499cfe2008-10-01 04:14:30 +0000723 Uses = [ESP] in {
Chris Lattner357a0ca2009-06-20 19:34:09 +0000724 def CALLpcrel32 : Ii32<0xE8, RawFrm,
725 (outs), (ins i32imm_pcrel:$dst,variable_ops),
726 "call\t$dst", []>;
Evan Chengb783fa32007-07-19 01:14:50 +0000727 def CALL32r : I<0xFF, MRM2r, (outs), (ins GR32:$dst, variable_ops),
Dan Gohman91888f02007-07-31 20:11:57 +0000728 "call\t{*}$dst", [(X86call GR32:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000729 def CALL32m : I<0xFF, MRM2m, (outs), (ins i32mem:$dst, variable_ops),
Dan Gohmanea4faba2008-05-29 21:50:34 +0000730 "call\t{*}$dst", [(X86call (loadi32 addr:$dst))]>;
Sean Callanan66fdfa02009-09-03 00:04:47 +0000731
Sean Callananb7e73392009-09-15 00:35:17 +0000732 def FARCALL16i : Iseg16<0x9A, RawFrm, (outs),
733 (ins i16imm:$seg, i16imm:$off),
734 "lcall{w}\t$seg, $off", []>, OpSize;
735 def FARCALL32i : Iseg32<0x9A, RawFrm, (outs),
736 (ins i16imm:$seg, i32imm:$off),
737 "lcall{l}\t$seg, $off", []>;
738
739 def FARCALL16m : I<0xFF, MRM3m, (outs), (ins opaque32mem:$dst),
Sean Callanan66fdfa02009-09-03 00:04:47 +0000740 "lcall{w}\t{*}$dst", []>, OpSize;
Sean Callananb7e73392009-09-15 00:35:17 +0000741 def FARCALL32m : I<0xFF, MRM3m, (outs), (ins opaque48mem:$dst),
Sean Callanan66fdfa02009-09-03 00:04:47 +0000742 "lcall{l}\t{*}$dst", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000743 }
744
Sean Callanan51b7a992009-09-16 02:57:13 +0000745// Constructing a stack frame.
746
747def ENTER : I<0xC8, RawFrm, (outs), (ins i16imm:$len, i8imm:$lvl),
748 "enter\t$len, $lvl", []>;
749
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000750// Tail call stuff.
Arnold Schwaighofere2d6bbb2007-10-11 19:40:01 +0000751
Evan Cheng37e7c752007-07-21 00:34:19 +0000752let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1 in
Sean Callanan2c48df22009-12-18 00:01:26 +0000753def TCRETURNdi : I<0, Pseudo, (outs),
754 (ins i32imm:$dst, i32imm:$offset, variable_ops),
Arnold Schwaighofere2d6bbb2007-10-11 19:40:01 +0000755 "#TC_RETURN $dst $offset",
756 []>;
757
758let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1 in
Sean Callanan2c48df22009-12-18 00:01:26 +0000759def TCRETURNri : I<0, Pseudo, (outs),
760 (ins GR32:$dst, i32imm:$offset, variable_ops),
Arnold Schwaighofere2d6bbb2007-10-11 19:40:01 +0000761 "#TC_RETURN $dst $offset",
762 []>;
763
764let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1 in
Chris Lattner357a0ca2009-06-20 19:34:09 +0000765 def TAILJMPd : IBr<0xE9, (ins i32imm_pcrel:$dst), "jmp\t$dst # TAILCALL",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000766 []>;
Evan Cheng37e7c752007-07-21 00:34:19 +0000767let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1 in
Sean Callanan2c48df22009-12-18 00:01:26 +0000768 def TAILJMPr : I<0xFF, MRM4r, (outs), (ins GR32:$dst),
769 "jmp{l}\t{*}$dst # TAILCALL",
Arnold Schwaighofere2d6bbb2007-10-11 19:40:01 +0000770 []>;
Evan Cheng37e7c752007-07-21 00:34:19 +0000771let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +0000772 def TAILJMPm : I<0xFF, MRM4m, (outs), (ins i32mem:$dst),
Arnold Schwaighofere2d6bbb2007-10-11 19:40:01 +0000773 "jmp\t{*}$dst # TAILCALL", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000774
775//===----------------------------------------------------------------------===//
776// Miscellaneous Instructions...
777//
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000778let Defs = [EBP, ESP], Uses = [EBP, ESP], mayLoad = 1, neverHasSideEffects=1 in
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000779def LEAVE : I<0xC9, RawFrm,
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000780 (outs), (ins), "leave", []>;
781
Sean Callanan2c48df22009-12-18 00:01:26 +0000782def POPCNT16rr : I<0xB8, MRMSrcReg, (outs GR16:$dst), (ins GR16:$src),
783 "popcnt{w}\t{$src, $dst|$dst, $src}", []>, OpSize, XS;
784def POPCNT16rm : I<0xB8, MRMSrcMem, (outs GR16:$dst), (ins i16mem:$src),
785 "popcnt{w}\t{$src, $dst|$dst, $src}", []>, OpSize, XS;
786def POPCNT32rr : I<0xB8, MRMSrcReg, (outs GR32:$dst), (ins GR32:$src),
787 "popcnt{l}\t{$src, $dst|$dst, $src}", []>, XS;
788def POPCNT32rm : I<0xB8, MRMSrcMem, (outs GR32:$dst), (ins i32mem:$src),
789 "popcnt{l}\t{$src, $dst|$dst, $src}", []>, XS;
790
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000791let Defs = [ESP], Uses = [ESP], neverHasSideEffects=1 in {
Sean Callanan9f3c3f52009-09-10 18:29:13 +0000792let mayLoad = 1 in {
793def POP16r : I<0x58, AddRegFrm, (outs GR16:$reg), (ins), "pop{w}\t$reg", []>,
794 OpSize;
795def POP32r : I<0x58, AddRegFrm, (outs GR32:$reg), (ins), "pop{l}\t$reg", []>;
796def POP16rmr: I<0x8F, MRM0r, (outs GR16:$reg), (ins), "pop{w}\t$reg", []>,
797 OpSize;
798def POP16rmm: I<0x8F, MRM0m, (outs i16mem:$dst), (ins), "pop{w}\t$dst", []>,
799 OpSize;
800def POP32rmr: I<0x8F, MRM0r, (outs GR32:$reg), (ins), "pop{l}\t$reg", []>;
801def POP32rmm: I<0x8F, MRM0m, (outs i32mem:$dst), (ins), "pop{l}\t$dst", []>;
802}
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000803
Sean Callanan9f3c3f52009-09-10 18:29:13 +0000804let mayStore = 1 in {
805def PUSH16r : I<0x50, AddRegFrm, (outs), (ins GR16:$reg), "push{w}\t$reg",[]>,
806 OpSize;
Evan Chengd8434332007-09-26 01:29:06 +0000807def PUSH32r : I<0x50, AddRegFrm, (outs), (ins GR32:$reg), "push{l}\t$reg",[]>;
Sean Callanan9f3c3f52009-09-10 18:29:13 +0000808def PUSH16rmr: I<0xFF, MRM6r, (outs), (ins GR16:$reg), "push{w}\t$reg",[]>,
809 OpSize;
810def PUSH16rmm: I<0xFF, MRM6m, (outs), (ins i16mem:$src), "push{w}\t$src",[]>,
811 OpSize;
812def PUSH32rmr: I<0xFF, MRM6r, (outs), (ins GR32:$reg), "push{l}\t$reg",[]>;
813def PUSH32rmm: I<0xFF, MRM6m, (outs), (ins i32mem:$src), "push{l}\t$src",[]>;
814}
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000815}
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000816
Bill Wendling4c2638c2009-06-15 19:39:04 +0000817let Defs = [ESP], Uses = [ESP], neverHasSideEffects = 1, mayStore = 1 in {
818def PUSH32i8 : Ii8<0x6a, RawFrm, (outs), (ins i8imm:$imm),
Bill Wendling0b0437f2009-06-15 20:59:31 +0000819 "push{l}\t$imm", []>;
Bill Wendling4c2638c2009-06-15 19:39:04 +0000820def PUSH32i16 : Ii16<0x68, RawFrm, (outs), (ins i16imm:$imm),
Bill Wendling0b0437f2009-06-15 20:59:31 +0000821 "push{l}\t$imm", []>;
Bill Wendling4c2638c2009-06-15 19:39:04 +0000822def PUSH32i32 : Ii32<0x68, RawFrm, (outs), (ins i32imm:$imm),
Bill Wendling0b0437f2009-06-15 20:59:31 +0000823 "push{l}\t$imm", []>;
Bill Wendling4c2638c2009-06-15 19:39:04 +0000824}
825
Sean Callanan2c48df22009-12-18 00:01:26 +0000826let Defs = [ESP, EFLAGS], Uses = [ESP], mayLoad = 1, neverHasSideEffects=1 in {
827def POPF : I<0x9D, RawFrm, (outs), (ins), "popf{w}", []>, OpSize;
828def POPFD : I<0x9D, RawFrm, (outs), (ins), "popf{l}", []>;
829}
830let Defs = [ESP], Uses = [ESP, EFLAGS], mayStore = 1, neverHasSideEffects=1 in {
831def PUSHF : I<0x9C, RawFrm, (outs), (ins), "pushf{w}", []>, OpSize;
832def PUSHFD : I<0x9C, RawFrm, (outs), (ins), "pushf{l}", []>;
833}
Evan Chengd8434332007-09-26 01:29:06 +0000834
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000835let isTwoAddress = 1 in // GR32 = bswap GR32
836 def BSWAP32r : I<0xC8, AddRegFrm,
Evan Chengb783fa32007-07-19 01:14:50 +0000837 (outs GR32:$dst), (ins GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000838 "bswap{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000839 [(set GR32:$dst, (bswap GR32:$src))]>, TB;
840
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000841
Evan Cheng48679f42007-12-14 02:13:44 +0000842// Bit scan instructions.
843let Defs = [EFLAGS] in {
Evan Cheng4e33de92007-12-14 18:49:43 +0000844def BSF16rr : I<0xBC, MRMSrcReg, (outs GR16:$dst), (ins GR16:$src),
Dan Gohmancdb54c62007-12-14 15:10:00 +0000845 "bsf{w}\t{$src, $dst|$dst, $src}",
Evan Cheng7cfbfe32007-12-14 08:30:15 +0000846 [(set GR16:$dst, (X86bsf GR16:$src)), (implicit EFLAGS)]>, TB;
Evan Cheng48679f42007-12-14 02:13:44 +0000847def BSF16rm : I<0xBC, MRMSrcMem, (outs GR16:$dst), (ins i16mem:$src),
Dan Gohmancdb54c62007-12-14 15:10:00 +0000848 "bsf{w}\t{$src, $dst|$dst, $src}",
Evan Cheng7cfbfe32007-12-14 08:30:15 +0000849 [(set GR16:$dst, (X86bsf (loadi16 addr:$src))),
850 (implicit EFLAGS)]>, TB;
Evan Cheng4e33de92007-12-14 18:49:43 +0000851def BSF32rr : I<0xBC, MRMSrcReg, (outs GR32:$dst), (ins GR32:$src),
Dan Gohmancdb54c62007-12-14 15:10:00 +0000852 "bsf{l}\t{$src, $dst|$dst, $src}",
Evan Cheng7cfbfe32007-12-14 08:30:15 +0000853 [(set GR32:$dst, (X86bsf GR32:$src)), (implicit EFLAGS)]>, TB;
Evan Cheng48679f42007-12-14 02:13:44 +0000854def BSF32rm : I<0xBC, MRMSrcMem, (outs GR32:$dst), (ins i32mem:$src),
Dan Gohmancdb54c62007-12-14 15:10:00 +0000855 "bsf{l}\t{$src, $dst|$dst, $src}",
Evan Cheng7cfbfe32007-12-14 08:30:15 +0000856 [(set GR32:$dst, (X86bsf (loadi32 addr:$src))),
857 (implicit EFLAGS)]>, TB;
Evan Cheng48679f42007-12-14 02:13:44 +0000858
Evan Cheng4e33de92007-12-14 18:49:43 +0000859def BSR16rr : I<0xBD, MRMSrcReg, (outs GR16:$dst), (ins GR16:$src),
Dan Gohmancdb54c62007-12-14 15:10:00 +0000860 "bsr{w}\t{$src, $dst|$dst, $src}",
Evan Cheng7cfbfe32007-12-14 08:30:15 +0000861 [(set GR16:$dst, (X86bsr GR16:$src)), (implicit EFLAGS)]>, TB;
Evan Cheng48679f42007-12-14 02:13:44 +0000862def BSR16rm : I<0xBD, MRMSrcMem, (outs GR16:$dst), (ins i16mem:$src),
Dan Gohmancdb54c62007-12-14 15:10:00 +0000863 "bsr{w}\t{$src, $dst|$dst, $src}",
Evan Cheng7cfbfe32007-12-14 08:30:15 +0000864 [(set GR16:$dst, (X86bsr (loadi16 addr:$src))),
865 (implicit EFLAGS)]>, TB;
Evan Cheng4e33de92007-12-14 18:49:43 +0000866def BSR32rr : I<0xBD, MRMSrcReg, (outs GR32:$dst), (ins GR32:$src),
Dan Gohmancdb54c62007-12-14 15:10:00 +0000867 "bsr{l}\t{$src, $dst|$dst, $src}",
Evan Cheng7cfbfe32007-12-14 08:30:15 +0000868 [(set GR32:$dst, (X86bsr GR32:$src)), (implicit EFLAGS)]>, TB;
Evan Cheng48679f42007-12-14 02:13:44 +0000869def BSR32rm : I<0xBD, MRMSrcMem, (outs GR32:$dst), (ins i32mem:$src),
Dan Gohmancdb54c62007-12-14 15:10:00 +0000870 "bsr{l}\t{$src, $dst|$dst, $src}",
Evan Cheng7cfbfe32007-12-14 08:30:15 +0000871 [(set GR32:$dst, (X86bsr (loadi32 addr:$src))),
872 (implicit EFLAGS)]>, TB;
Evan Cheng48679f42007-12-14 02:13:44 +0000873} // Defs = [EFLAGS]
874
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000875let neverHasSideEffects = 1 in
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000876def LEA16r : I<0x8D, MRMSrcMem,
Evan Chengca348202009-12-12 18:51:56 +0000877 (outs GR16:$dst), (ins lea32mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000878 "lea{w}\t{$src|$dst}, {$dst|$src}", []>, OpSize;
Evan Cheng1ea8e6b2008-03-27 01:41:09 +0000879let isReMaterializable = 1 in
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000880def LEA32r : I<0x8D, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +0000881 (outs GR32:$dst), (ins lea32mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000882 "lea{l}\t{$src|$dst}, {$dst|$src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000883 [(set GR32:$dst, lea32addr:$src)]>, Requires<[In32BitMode]>;
884
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000885let Defs = [ECX,EDI,ESI], Uses = [ECX,EDI,ESI] in {
Evan Chengb783fa32007-07-19 01:14:50 +0000886def REP_MOVSB : I<0xA4, RawFrm, (outs), (ins), "{rep;movsb|rep movsb}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000887 [(X86rep_movs i8)]>, REP;
Evan Chengb783fa32007-07-19 01:14:50 +0000888def REP_MOVSW : I<0xA5, RawFrm, (outs), (ins), "{rep;movsw|rep movsw}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000889 [(X86rep_movs i16)]>, REP, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +0000890def REP_MOVSD : I<0xA5, RawFrm, (outs), (ins), "{rep;movsl|rep movsd}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000891 [(X86rep_movs i32)]>, REP;
892}
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000893
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000894let Defs = [ECX,EDI], Uses = [AL,ECX,EDI] in
Evan Chengb783fa32007-07-19 01:14:50 +0000895def REP_STOSB : I<0xAA, RawFrm, (outs), (ins), "{rep;stosb|rep stosb}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000896 [(X86rep_stos i8)]>, REP;
897let Defs = [ECX,EDI], Uses = [AX,ECX,EDI] in
Evan Chengb783fa32007-07-19 01:14:50 +0000898def REP_STOSW : I<0xAB, RawFrm, (outs), (ins), "{rep;stosw|rep stosw}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000899 [(X86rep_stos i16)]>, REP, OpSize;
900let Defs = [ECX,EDI], Uses = [EAX,ECX,EDI] in
Evan Chengb783fa32007-07-19 01:14:50 +0000901def REP_STOSD : I<0xAB, RawFrm, (outs), (ins), "{rep;stosl|rep stosd}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000902 [(X86rep_stos i32)]>, REP;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000903
Sean Callanan481f06d2009-09-12 00:37:19 +0000904def SCAS8 : I<0xAE, RawFrm, (outs), (ins), "scas{b}", []>;
905def SCAS16 : I<0xAF, RawFrm, (outs), (ins), "scas{w}", []>, OpSize;
906def SCAS32 : I<0xAF, RawFrm, (outs), (ins), "scas{l}", []>;
907
Sean Callanan25220d62009-09-12 02:25:20 +0000908def CMPS8 : I<0xA6, RawFrm, (outs), (ins), "cmps{b}", []>;
909def CMPS16 : I<0xA7, RawFrm, (outs), (ins), "cmps{w}", []>, OpSize;
910def CMPS32 : I<0xA7, RawFrm, (outs), (ins), "cmps{l}", []>;
911
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000912let Defs = [RAX, RDX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000913def RDTSC : I<0x31, RawFrm, (outs), (ins), "rdtsc", [(X86rdtsc)]>,
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000914 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000915
Anton Korobeynikov39d40ba2008-01-15 07:02:33 +0000916let isBarrier = 1, hasCtrlDep = 1 in {
Chris Lattner56b941f2008-01-15 21:58:22 +0000917def TRAP : I<0x0B, RawFrm, (outs), (ins), "ud2", [(trap)]>, TB;
Anton Korobeynikov39d40ba2008-01-15 07:02:33 +0000918}
919
Chris Lattnerc96e27c2009-08-11 16:58:39 +0000920def SYSCALL : I<0x05, RawFrm,
921 (outs), (ins), "syscall", []>, TB;
922def SYSRET : I<0x07, RawFrm,
923 (outs), (ins), "sysret", []>, TB;
924def SYSENTER : I<0x34, RawFrm,
925 (outs), (ins), "sysenter", []>, TB;
926def SYSEXIT : I<0x35, RawFrm,
927 (outs), (ins), "sysexit", []>, TB;
928
Sean Callanan2c2313a2009-09-12 02:52:41 +0000929def WAIT : I<0x9B, RawFrm, (outs), (ins), "wait", []>;
Chris Lattnerc96e27c2009-08-11 16:58:39 +0000930
931
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000932//===----------------------------------------------------------------------===//
933// Input/Output Instructions...
934//
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000935let Defs = [AL], Uses = [DX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000936def IN8rr : I<0xEC, RawFrm, (outs), (ins),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000937 "in{b}\t{%dx, %al|%AL, %DX}", []>;
938let Defs = [AX], Uses = [DX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000939def IN16rr : I<0xED, RawFrm, (outs), (ins),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000940 "in{w}\t{%dx, %ax|%AX, %DX}", []>, OpSize;
941let Defs = [EAX], Uses = [DX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000942def IN32rr : I<0xED, RawFrm, (outs), (ins),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000943 "in{l}\t{%dx, %eax|%EAX, %DX}", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000944
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000945let Defs = [AL] in
Evan Chengb783fa32007-07-19 01:14:50 +0000946def IN8ri : Ii8<0xE4, RawFrm, (outs), (ins i16i8imm:$port),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000947 "in{b}\t{$port, %al|%AL, $port}", []>;
948let Defs = [AX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000949def IN16ri : Ii8<0xE5, RawFrm, (outs), (ins i16i8imm:$port),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000950 "in{w}\t{$port, %ax|%AX, $port}", []>, OpSize;
951let Defs = [EAX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000952def IN32ri : Ii8<0xE5, RawFrm, (outs), (ins i16i8imm:$port),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000953 "in{l}\t{$port, %eax|%EAX, $port}", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000954
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000955let Uses = [DX, AL] in
Evan Chengb783fa32007-07-19 01:14:50 +0000956def OUT8rr : I<0xEE, RawFrm, (outs), (ins),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000957 "out{b}\t{%al, %dx|%DX, %AL}", []>;
958let Uses = [DX, AX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000959def OUT16rr : I<0xEF, RawFrm, (outs), (ins),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000960 "out{w}\t{%ax, %dx|%DX, %AX}", []>, OpSize;
961let Uses = [DX, EAX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000962def OUT32rr : I<0xEF, RawFrm, (outs), (ins),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000963 "out{l}\t{%eax, %dx|%DX, %EAX}", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000964
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000965let Uses = [AL] in
Evan Chengb783fa32007-07-19 01:14:50 +0000966def OUT8ir : Ii8<0xE6, RawFrm, (outs), (ins i16i8imm:$port),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000967 "out{b}\t{%al, $port|$port, %AL}", []>;
968let Uses = [AX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000969def OUT16ir : Ii8<0xE7, RawFrm, (outs), (ins i16i8imm:$port),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000970 "out{w}\t{%ax, $port|$port, %AX}", []>, OpSize;
971let Uses = [EAX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000972def OUT32ir : Ii8<0xE7, RawFrm, (outs), (ins i16i8imm:$port),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000973 "out{l}\t{%eax, $port|$port, %EAX}", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000974
Sean Callanan2c48df22009-12-18 00:01:26 +0000975def IN8 : I<0x6C, RawFrm, (outs), (ins),
976 "ins{b}", []>;
977def IN16 : I<0x6D, RawFrm, (outs), (ins),
978 "ins{w}", []>, OpSize;
979def IN32 : I<0x6D, RawFrm, (outs), (ins),
980 "ins{l}", []>;
981
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000982//===----------------------------------------------------------------------===//
983// Move Instructions...
984//
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000985let neverHasSideEffects = 1 in {
Evan Chengb783fa32007-07-19 01:14:50 +0000986def MOV8rr : I<0x88, MRMDestReg, (outs GR8 :$dst), (ins GR8 :$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000987 "mov{b}\t{$src, $dst|$dst, $src}", []>;
Evan Chengb783fa32007-07-19 01:14:50 +0000988def MOV16rr : I<0x89, MRMDestReg, (outs GR16:$dst), (ins GR16:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000989 "mov{w}\t{$src, $dst|$dst, $src}", []>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +0000990def MOV32rr : I<0x89, MRMDestReg, (outs GR32:$dst), (ins GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000991 "mov{l}\t{$src, $dst|$dst, $src}", []>;
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000992}
Evan Cheng6f26e8b2008-06-18 08:13:07 +0000993let isReMaterializable = 1, isAsCheapAsAMove = 1 in {
Evan Chengb783fa32007-07-19 01:14:50 +0000994def MOV8ri : Ii8 <0xB0, AddRegFrm, (outs GR8 :$dst), (ins i8imm :$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000995 "mov{b}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000996 [(set GR8:$dst, imm:$src)]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000997def MOV16ri : Ii16<0xB8, AddRegFrm, (outs GR16:$dst), (ins i16imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000998 "mov{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000999 [(set GR16:$dst, imm:$src)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001000def MOV32ri : Ii32<0xB8, AddRegFrm, (outs GR32:$dst), (ins i32imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001001 "mov{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001002 [(set GR32:$dst, imm:$src)]>;
1003}
Evan Chengb783fa32007-07-19 01:14:50 +00001004def MOV8mi : Ii8 <0xC6, MRM0m, (outs), (ins i8mem :$dst, i8imm :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001005 "mov{b}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001006 [(store (i8 imm:$src), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001007def MOV16mi : Ii16<0xC7, MRM0m, (outs), (ins i16mem:$dst, i16imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001008 "mov{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001009 [(store (i16 imm:$src), addr:$dst)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001010def MOV32mi : Ii32<0xC7, MRM0m, (outs), (ins i32mem:$dst, i32imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001011 "mov{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001012 [(store (i32 imm:$src), addr:$dst)]>;
1013
Sean Callanan2c48df22009-12-18 00:01:26 +00001014def MOV8o8a : Ii8 <0xA0, RawFrm, (outs), (ins offset8:$src),
Sean Callanan70953a52009-09-10 18:33:42 +00001015 "mov{b}\t{$src, %al|%al, $src}", []>;
Sean Callanan2c48df22009-12-18 00:01:26 +00001016def MOV16o16a : Ii16 <0xA1, RawFrm, (outs), (ins offset16:$src),
Sean Callanan70953a52009-09-10 18:33:42 +00001017 "mov{w}\t{$src, %ax|%ax, $src}", []>, OpSize;
Sean Callanan2c48df22009-12-18 00:01:26 +00001018def MOV32o32a : Ii32 <0xA1, RawFrm, (outs), (ins offset32:$src),
Sean Callanan70953a52009-09-10 18:33:42 +00001019 "mov{l}\t{$src, %eax|%eax, $src}", []>;
1020
Sean Callanan2c48df22009-12-18 00:01:26 +00001021def MOV8ao8 : Ii8 <0xA2, RawFrm, (outs offset8:$dst), (ins),
Sean Callanan70953a52009-09-10 18:33:42 +00001022 "mov{b}\t{%al, $dst|$dst, %al}", []>;
Sean Callanan2c48df22009-12-18 00:01:26 +00001023def MOV16ao16 : Ii16 <0xA3, RawFrm, (outs offset16:$dst), (ins),
Sean Callanan70953a52009-09-10 18:33:42 +00001024 "mov{w}\t{%ax, $dst|$dst, %ax}", []>, OpSize;
Sean Callanan2c48df22009-12-18 00:01:26 +00001025def MOV32ao32 : Ii32 <0xA3, RawFrm, (outs offset32:$dst), (ins),
Sean Callanan70953a52009-09-10 18:33:42 +00001026 "mov{l}\t{%eax, $dst|$dst, %eax}", []>;
1027
Sean Callananad87a3a2009-09-15 18:47:29 +00001028// Moves to and from segment registers
1029def MOV16rs : I<0x8C, MRMDestReg, (outs GR16:$dst), (ins SEGMENT_REG:$src),
1030 "mov{w}\t{$src, $dst|$dst, $src}", []>;
1031def MOV16ms : I<0x8C, MRMDestMem, (outs i16mem:$dst), (ins SEGMENT_REG:$src),
1032 "mov{w}\t{$src, $dst|$dst, $src}", []>;
1033def MOV16sr : I<0x8E, MRMSrcReg, (outs SEGMENT_REG:$dst), (ins GR16:$src),
1034 "mov{w}\t{$src, $dst|$dst, $src}", []>;
1035def MOV16sm : I<0x8E, MRMSrcMem, (outs SEGMENT_REG:$dst), (ins i16mem:$src),
1036 "mov{w}\t{$src, $dst|$dst, $src}", []>;
1037
Sean Callanan2c48df22009-12-18 00:01:26 +00001038def MOV8rr_REV : I<0x8A, MRMSrcReg, (outs GR8:$dst), (ins GR8:$src),
1039 "mov{b}\t{$src, $dst|$dst, $src}", []>;
1040def MOV16rr_REV : I<0x8B, MRMSrcReg, (outs GR16:$dst), (ins GR16:$src),
1041 "mov{w}\t{$src, $dst|$dst, $src}", []>, OpSize;
1042def MOV32rr_REV : I<0x8B, MRMSrcReg, (outs GR32:$dst), (ins GR32:$src),
1043 "mov{l}\t{$src, $dst|$dst, $src}", []>;
1044
Dan Gohman5574cc72008-12-03 18:15:48 +00001045let canFoldAsLoad = 1, isReMaterializable = 1, mayHaveSideEffects = 1 in {
Evan Chengb783fa32007-07-19 01:14:50 +00001046def MOV8rm : I<0x8A, MRMSrcMem, (outs GR8 :$dst), (ins i8mem :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001047 "mov{b}\t{$src, $dst|$dst, $src}",
Chris Lattner12208612009-04-10 00:16:23 +00001048 [(set GR8:$dst, (loadi8 addr:$src))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001049def MOV16rm : I<0x8B, MRMSrcMem, (outs GR16:$dst), (ins i16mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001050 "mov{w}\t{$src, $dst|$dst, $src}",
Chris Lattner12208612009-04-10 00:16:23 +00001051 [(set GR16:$dst, (loadi16 addr:$src))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001052def MOV32rm : I<0x8B, MRMSrcMem, (outs GR32:$dst), (ins i32mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001053 "mov{l}\t{$src, $dst|$dst, $src}",
Chris Lattner12208612009-04-10 00:16:23 +00001054 [(set GR32:$dst, (loadi32 addr:$src))]>;
Evan Cheng4e84e452007-08-30 05:49:43 +00001055}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001056
Evan Chengb783fa32007-07-19 01:14:50 +00001057def MOV8mr : I<0x88, MRMDestMem, (outs), (ins i8mem :$dst, GR8 :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001058 "mov{b}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001059 [(store GR8:$src, addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001060def MOV16mr : I<0x89, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001061 "mov{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001062 [(store GR16:$src, addr:$dst)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001063def MOV32mr : I<0x89, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001064 "mov{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001065 [(store GR32:$src, addr:$dst)]>;
Dan Gohman744d4622009-04-13 16:09:41 +00001066
Dan Gohman1d8ce9c2009-04-27 16:41:36 +00001067// Versions of MOV8rr, MOV8mr, and MOV8rm that use i8mem_NOREX and GR8_NOREX so
1068// that they can be used for copying and storing h registers, which can't be
1069// encoded when a REX prefix is present.
Dan Gohman2da0db32009-04-15 00:04:23 +00001070let neverHasSideEffects = 1 in
Dan Gohman40ddc362009-04-15 19:48:57 +00001071def MOV8rr_NOREX : I<0x88, MRMDestReg,
1072 (outs GR8_NOREX:$dst), (ins GR8_NOREX:$src),
Dan Gohman2da0db32009-04-15 00:04:23 +00001073 "mov{b}\t{$src, $dst|$dst, $src} # NOREX", []>;
Evan Chengebc49402009-04-30 00:58:57 +00001074let mayStore = 1 in
Dan Gohman2da0db32009-04-15 00:04:23 +00001075def MOV8mr_NOREX : I<0x88, MRMDestMem,
1076 (outs), (ins i8mem_NOREX:$dst, GR8_NOREX:$src),
1077 "mov{b}\t{$src, $dst|$dst, $src} # NOREX", []>;
Evan Chengebc49402009-04-30 00:58:57 +00001078let mayLoad = 1,
1079 canFoldAsLoad = 1, isReMaterializable = 1, mayHaveSideEffects = 1 in
Dan Gohman1d8ce9c2009-04-27 16:41:36 +00001080def MOV8rm_NOREX : I<0x8A, MRMSrcMem,
1081 (outs GR8_NOREX:$dst), (ins i8mem_NOREX:$src),
1082 "mov{b}\t{$src, $dst|$dst, $src} # NOREX", []>;
Dan Gohman744d4622009-04-13 16:09:41 +00001083
Sean Callanan2c48df22009-12-18 00:01:26 +00001084// Moves to and from debug registers
1085def MOV32rd : I<0x21, MRMDestReg, (outs GR32:$dst), (ins DEBUG_REG:$src),
1086 "mov{l}\t{$src, $dst|$dst, $src}", []>, TB;
1087def MOV32dr : I<0x23, MRMSrcReg, (outs DEBUG_REG:$dst), (ins GR32:$src),
1088 "mov{l}\t{$src, $dst|$dst, $src}", []>, TB;
1089
1090// Moves to and from control registers
1091def MOV32rc : I<0x20, MRMDestReg, (outs GR32:$dst), (ins CONTROL_REG_32:$src),
1092 "mov{q}\t{$src, $dst|$dst, $src}", []>, TB;
1093def MOV32cr : I<0x22, MRMSrcReg, (outs CONTROL_REG_32:$dst), (ins GR32:$src),
1094 "mov{q}\t{$src, $dst|$dst, $src}", []>, TB;
1095
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001096//===----------------------------------------------------------------------===//
1097// Fixed-Register Multiplication and Division Instructions...
1098//
1099
1100// Extra precision multiplication
Evan Cheng55687072007-09-14 21:48:26 +00001101let Defs = [AL,AH,EFLAGS], Uses = [AL] in
Dan Gohman91888f02007-07-31 20:11:57 +00001102def MUL8r : I<0xF6, MRM4r, (outs), (ins GR8:$src), "mul{b}\t$src",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001103 // FIXME: Used for 8-bit mul, ignore result upper 8 bits.
1104 // This probably ought to be moved to a def : Pat<> if the
1105 // syntax can be accepted.
Bill Wendlingf5399032008-12-12 21:15:41 +00001106 [(set AL, (mul AL, GR8:$src)),
1107 (implicit EFLAGS)]>; // AL,AH = AL*GR8
1108
Chris Lattnerc7e96e72008-01-11 07:18:17 +00001109let Defs = [AX,DX,EFLAGS], Uses = [AX], neverHasSideEffects = 1 in
Bill Wendlingf5399032008-12-12 21:15:41 +00001110def MUL16r : I<0xF7, MRM4r, (outs), (ins GR16:$src),
1111 "mul{w}\t$src",
1112 []>, OpSize; // AX,DX = AX*GR16
1113
Chris Lattnerc7e96e72008-01-11 07:18:17 +00001114let Defs = [EAX,EDX,EFLAGS], Uses = [EAX], neverHasSideEffects = 1 in
Bill Wendlingf5399032008-12-12 21:15:41 +00001115def MUL32r : I<0xF7, MRM4r, (outs), (ins GR32:$src),
1116 "mul{l}\t$src",
1117 []>; // EAX,EDX = EAX*GR32
1118
Evan Cheng55687072007-09-14 21:48:26 +00001119let Defs = [AL,AH,EFLAGS], Uses = [AL] in
Evan Chengb783fa32007-07-19 01:14:50 +00001120def MUL8m : I<0xF6, MRM4m, (outs), (ins i8mem :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001121 "mul{b}\t$src",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001122 // FIXME: Used for 8-bit mul, ignore result upper 8 bits.
1123 // This probably ought to be moved to a def : Pat<> if the
1124 // syntax can be accepted.
Bill Wendlingf5399032008-12-12 21:15:41 +00001125 [(set AL, (mul AL, (loadi8 addr:$src))),
1126 (implicit EFLAGS)]>; // AL,AH = AL*[mem8]
1127
Chris Lattnerc90ee9c2008-01-10 07:59:24 +00001128let mayLoad = 1, neverHasSideEffects = 1 in {
Evan Cheng55687072007-09-14 21:48:26 +00001129let Defs = [AX,DX,EFLAGS], Uses = [AX] in
Evan Chengb783fa32007-07-19 01:14:50 +00001130def MUL16m : I<0xF7, MRM4m, (outs), (ins i16mem:$src),
Bill Wendlingf5399032008-12-12 21:15:41 +00001131 "mul{w}\t$src",
1132 []>, OpSize; // AX,DX = AX*[mem16]
1133
Evan Cheng55687072007-09-14 21:48:26 +00001134let Defs = [EAX,EDX,EFLAGS], Uses = [EAX] in
Evan Chengb783fa32007-07-19 01:14:50 +00001135def MUL32m : I<0xF7, MRM4m, (outs), (ins i32mem:$src),
Bill Wendlingf5399032008-12-12 21:15:41 +00001136 "mul{l}\t$src",
1137 []>; // EAX,EDX = EAX*[mem32]
Chris Lattnerc90ee9c2008-01-10 07:59:24 +00001138}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001139
Chris Lattnerc90ee9c2008-01-10 07:59:24 +00001140let neverHasSideEffects = 1 in {
Evan Cheng55687072007-09-14 21:48:26 +00001141let Defs = [AL,AH,EFLAGS], Uses = [AL] in
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001142def IMUL8r : I<0xF6, MRM5r, (outs), (ins GR8:$src), "imul{b}\t$src", []>;
1143 // AL,AH = AL*GR8
Evan Cheng55687072007-09-14 21:48:26 +00001144let Defs = [AX,DX,EFLAGS], Uses = [AX] in
Dan Gohman91888f02007-07-31 20:11:57 +00001145def IMUL16r : I<0xF7, MRM5r, (outs), (ins GR16:$src), "imul{w}\t$src", []>,
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001146 OpSize; // AX,DX = AX*GR16
Evan Cheng55687072007-09-14 21:48:26 +00001147let Defs = [EAX,EDX,EFLAGS], Uses = [EAX] in
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001148def IMUL32r : I<0xF7, MRM5r, (outs), (ins GR32:$src), "imul{l}\t$src", []>;
1149 // EAX,EDX = EAX*GR32
Chris Lattnerc90ee9c2008-01-10 07:59:24 +00001150let mayLoad = 1 in {
Evan Cheng55687072007-09-14 21:48:26 +00001151let Defs = [AL,AH,EFLAGS], Uses = [AL] in
Evan Chengb783fa32007-07-19 01:14:50 +00001152def IMUL8m : I<0xF6, MRM5m, (outs), (ins i8mem :$src),
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001153 "imul{b}\t$src", []>; // AL,AH = AL*[mem8]
Evan Cheng55687072007-09-14 21:48:26 +00001154let Defs = [AX,DX,EFLAGS], Uses = [AX] in
Evan Chengb783fa32007-07-19 01:14:50 +00001155def IMUL16m : I<0xF7, MRM5m, (outs), (ins i16mem:$src),
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001156 "imul{w}\t$src", []>, OpSize; // AX,DX = AX*[mem16]
Eli Friedman3939db02009-12-26 20:08:30 +00001157let Defs = [EAX,EDX,EFLAGS], Uses = [EAX] in
Evan Chengb783fa32007-07-19 01:14:50 +00001158def IMUL32m : I<0xF7, MRM5m, (outs), (ins i32mem:$src),
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001159 "imul{l}\t$src", []>; // EAX,EDX = EAX*[mem32]
Chris Lattnerc90ee9c2008-01-10 07:59:24 +00001160}
Dan Gohmand44572d2008-11-18 21:29:14 +00001161} // neverHasSideEffects
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001162
1163// unsigned division/remainder
Dale Johannesend8fd3562008-10-07 18:54:28 +00001164let Defs = [AL,AH,EFLAGS], Uses = [AX] in
Sean Callanan2c48df22009-12-18 00:01:26 +00001165def DIV8r : I<0xF6, MRM6r, (outs), (ins GR8:$src), // AX/r8 = AL,AH
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001166 "div{b}\t$src", []>;
Evan Cheng55687072007-09-14 21:48:26 +00001167let Defs = [AX,DX,EFLAGS], Uses = [AX,DX] in
Sean Callanan2c48df22009-12-18 00:01:26 +00001168def DIV16r : I<0xF7, MRM6r, (outs), (ins GR16:$src), // DX:AX/r16 = AX,DX
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001169 "div{w}\t$src", []>, OpSize;
Evan Cheng55687072007-09-14 21:48:26 +00001170let Defs = [EAX,EDX,EFLAGS], Uses = [EAX,EDX] in
Sean Callanan2c48df22009-12-18 00:01:26 +00001171def DIV32r : I<0xF7, MRM6r, (outs), (ins GR32:$src), // EDX:EAX/r32 = EAX,EDX
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001172 "div{l}\t$src", []>;
Chris Lattnerc90ee9c2008-01-10 07:59:24 +00001173let mayLoad = 1 in {
Dale Johannesend8fd3562008-10-07 18:54:28 +00001174let Defs = [AL,AH,EFLAGS], Uses = [AX] in
Sean Callanan2c48df22009-12-18 00:01:26 +00001175def DIV8m : I<0xF6, MRM6m, (outs), (ins i8mem:$src), // AX/[mem8] = AL,AH
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001176 "div{b}\t$src", []>;
Evan Cheng55687072007-09-14 21:48:26 +00001177let Defs = [AX,DX,EFLAGS], Uses = [AX,DX] in
Sean Callanan2c48df22009-12-18 00:01:26 +00001178def DIV16m : I<0xF7, MRM6m, (outs), (ins i16mem:$src), // DX:AX/[mem16] = AX,DX
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001179 "div{w}\t$src", []>, OpSize;
Evan Cheng55687072007-09-14 21:48:26 +00001180let Defs = [EAX,EDX,EFLAGS], Uses = [EAX,EDX] in
Sean Callanan2c48df22009-12-18 00:01:26 +00001181 // EDX:EAX/[mem32] = EAX,EDX
1182def DIV32m : I<0xF7, MRM6m, (outs), (ins i32mem:$src),
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001183 "div{l}\t$src", []>;
Chris Lattnerc90ee9c2008-01-10 07:59:24 +00001184}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001185
1186// Signed division/remainder.
Dale Johannesend8fd3562008-10-07 18:54:28 +00001187let Defs = [AL,AH,EFLAGS], Uses = [AX] in
Sean Callanan2c48df22009-12-18 00:01:26 +00001188def IDIV8r : I<0xF6, MRM7r, (outs), (ins GR8:$src), // AX/r8 = AL,AH
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001189 "idiv{b}\t$src", []>;
Evan Cheng55687072007-09-14 21:48:26 +00001190let Defs = [AX,DX,EFLAGS], Uses = [AX,DX] in
Sean Callanan2c48df22009-12-18 00:01:26 +00001191def IDIV16r: I<0xF7, MRM7r, (outs), (ins GR16:$src), // DX:AX/r16 = AX,DX
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001192 "idiv{w}\t$src", []>, OpSize;
Evan Cheng55687072007-09-14 21:48:26 +00001193let Defs = [EAX,EDX,EFLAGS], Uses = [EAX,EDX] in
Sean Callanan2c48df22009-12-18 00:01:26 +00001194def IDIV32r: I<0xF7, MRM7r, (outs), (ins GR32:$src), // EDX:EAX/r32 = EAX,EDX
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001195 "idiv{l}\t$src", []>;
Chris Lattnerc90ee9c2008-01-10 07:59:24 +00001196let mayLoad = 1, mayLoad = 1 in {
Dale Johannesend8fd3562008-10-07 18:54:28 +00001197let Defs = [AL,AH,EFLAGS], Uses = [AX] in
Sean Callanan2c48df22009-12-18 00:01:26 +00001198def IDIV8m : I<0xF6, MRM7m, (outs), (ins i8mem:$src), // AX/[mem8] = AL,AH
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001199 "idiv{b}\t$src", []>;
Evan Cheng55687072007-09-14 21:48:26 +00001200let Defs = [AX,DX,EFLAGS], Uses = [AX,DX] in
Sean Callanan2c48df22009-12-18 00:01:26 +00001201def IDIV16m: I<0xF7, MRM7m, (outs), (ins i16mem:$src), // DX:AX/[mem16] = AX,DX
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001202 "idiv{w}\t$src", []>, OpSize;
Evan Cheng55687072007-09-14 21:48:26 +00001203let Defs = [EAX,EDX,EFLAGS], Uses = [EAX,EDX] in
Sean Callanan2c48df22009-12-18 00:01:26 +00001204def IDIV32m: I<0xF7, MRM7m, (outs), (ins i32mem:$src),
1205 // EDX:EAX/[mem32] = EAX,EDX
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001206 "idiv{l}\t$src", []>;
Chris Lattnerc90ee9c2008-01-10 07:59:24 +00001207}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001208
1209//===----------------------------------------------------------------------===//
Chris Lattnerc90ee9c2008-01-10 07:59:24 +00001210// Two address Instructions.
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001211//
1212let isTwoAddress = 1 in {
1213
1214// Conditional moves
Evan Cheng950aac02007-09-25 01:57:46 +00001215let Uses = [EFLAGS] in {
Dan Gohman29b998f2009-08-27 00:14:12 +00001216
Dan Gohman30afe012009-10-29 18:10:34 +00001217// X86 doesn't have 8-bit conditional moves. Use a customInserter to
Dan Gohman29b998f2009-08-27 00:14:12 +00001218// emit control flow. An alternative to this is to mark i8 SELECT as Promote,
1219// however that requires promoting the operands, and can induce additional
Dan Gohman1596dd22009-08-29 22:19:15 +00001220// i8 register pressure. Note that CMOV_GR8 is conservatively considered to
1221// clobber EFLAGS, because if one of the operands is zero, the expansion
1222// could involve an xor.
Dan Gohman30afe012009-10-29 18:10:34 +00001223let usesCustomInserter = 1, isTwoAddress = 0, Defs = [EFLAGS] in
Dan Gohman29b998f2009-08-27 00:14:12 +00001224def CMOV_GR8 : I<0, Pseudo,
1225 (outs GR8:$dst), (ins GR8:$src1, GR8:$src2, i8imm:$cond),
1226 "#CMOV_GR8 PSEUDO!",
1227 [(set GR8:$dst, (X86cmov GR8:$src1, GR8:$src2,
1228 imm:$cond, EFLAGS))]>;
1229
Dan Gohman90adb6c2009-08-27 18:16:24 +00001230let isCommutable = 1 in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001231def CMOVB16rr : I<0x42, MRMSrcReg, // if <u, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +00001232 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Sean Callanan2c48df22009-12-18 00:01:26 +00001233 "cmovb{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001234 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001235 X86_COND_B, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001236 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001237def CMOVB32rr : I<0x42, MRMSrcReg, // if <u, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +00001238 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Sean Callanan2c48df22009-12-18 00:01:26 +00001239 "cmovb{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001240 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001241 X86_COND_B, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001242 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001243def CMOVAE16rr: I<0x43, MRMSrcReg, // if >=u, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +00001244 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Sean Callanan2c48df22009-12-18 00:01:26 +00001245 "cmovae{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001246 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001247 X86_COND_AE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001248 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001249def CMOVAE32rr: I<0x43, MRMSrcReg, // if >=u, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +00001250 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Sean Callanan2c48df22009-12-18 00:01:26 +00001251 "cmovae{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001252 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001253 X86_COND_AE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001254 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001255def CMOVE16rr : I<0x44, MRMSrcReg, // if ==, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +00001256 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Sean Callanan2c48df22009-12-18 00:01:26 +00001257 "cmove{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001258 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001259 X86_COND_E, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001260 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001261def CMOVE32rr : I<0x44, MRMSrcReg, // if ==, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +00001262 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Sean Callanan2c48df22009-12-18 00:01:26 +00001263 "cmove{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001264 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001265 X86_COND_E, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001266 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001267def CMOVNE16rr: I<0x45, MRMSrcReg, // if !=, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +00001268 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Sean Callanan2c48df22009-12-18 00:01:26 +00001269 "cmovne{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001270 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001271 X86_COND_NE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001272 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001273def CMOVNE32rr: I<0x45, MRMSrcReg, // if !=, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +00001274 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Sean Callanan2c48df22009-12-18 00:01:26 +00001275 "cmovne{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001276 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001277 X86_COND_NE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001278 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001279def CMOVBE16rr: I<0x46, MRMSrcReg, // if <=u, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +00001280 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Sean Callanan2c48df22009-12-18 00:01:26 +00001281 "cmovbe{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001282 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001283 X86_COND_BE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001284 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001285def CMOVBE32rr: I<0x46, MRMSrcReg, // if <=u, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +00001286 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Sean Callanan2c48df22009-12-18 00:01:26 +00001287 "cmovbe{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001288 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001289 X86_COND_BE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001290 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001291def CMOVA16rr : I<0x47, MRMSrcReg, // if >u, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +00001292 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Sean Callanan2c48df22009-12-18 00:01:26 +00001293 "cmova{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001294 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001295 X86_COND_A, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001296 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001297def CMOVA32rr : I<0x47, MRMSrcReg, // if >u, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +00001298 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Sean Callanan2c48df22009-12-18 00:01:26 +00001299 "cmova{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001300 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001301 X86_COND_A, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001302 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001303def CMOVL16rr : I<0x4C, MRMSrcReg, // if <s, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +00001304 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Sean Callanan2c48df22009-12-18 00:01:26 +00001305 "cmovl{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001306 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001307 X86_COND_L, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001308 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001309def CMOVL32rr : I<0x4C, MRMSrcReg, // if <s, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +00001310 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Sean Callanan2c48df22009-12-18 00:01:26 +00001311 "cmovl{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001312 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001313 X86_COND_L, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001314 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001315def CMOVGE16rr: I<0x4D, MRMSrcReg, // if >=s, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +00001316 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Sean Callanan2c48df22009-12-18 00:01:26 +00001317 "cmovge{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001318 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001319 X86_COND_GE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001320 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001321def CMOVGE32rr: I<0x4D, MRMSrcReg, // if >=s, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +00001322 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Sean Callanan2c48df22009-12-18 00:01:26 +00001323 "cmovge{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001324 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001325 X86_COND_GE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001326 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001327def CMOVLE16rr: I<0x4E, MRMSrcReg, // if <=s, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +00001328 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Sean Callanan2c48df22009-12-18 00:01:26 +00001329 "cmovle{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001330 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001331 X86_COND_LE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001332 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001333def CMOVLE32rr: I<0x4E, MRMSrcReg, // if <=s, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +00001334 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Sean Callanan2c48df22009-12-18 00:01:26 +00001335 "cmovle{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001336 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001337 X86_COND_LE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001338 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001339def CMOVG16rr : I<0x4F, MRMSrcReg, // if >s, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +00001340 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Sean Callanan2c48df22009-12-18 00:01:26 +00001341 "cmovg{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001342 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001343 X86_COND_G, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001344 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001345def CMOVG32rr : I<0x4F, MRMSrcReg, // if >s, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +00001346 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Sean Callanan2c48df22009-12-18 00:01:26 +00001347 "cmovg{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001348 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001349 X86_COND_G, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001350 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001351def CMOVS16rr : I<0x48, MRMSrcReg, // if signed, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +00001352 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Sean Callanan2c48df22009-12-18 00:01:26 +00001353 "cmovs{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001354 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001355 X86_COND_S, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001356 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001357def CMOVS32rr : I<0x48, MRMSrcReg, // if signed, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +00001358 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Sean Callanan2c48df22009-12-18 00:01:26 +00001359 "cmovs{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001360 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001361 X86_COND_S, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001362 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001363def CMOVNS16rr: I<0x49, MRMSrcReg, // if !signed, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +00001364 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Sean Callanan2c48df22009-12-18 00:01:26 +00001365 "cmovns{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001366 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001367 X86_COND_NS, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001368 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001369def CMOVNS32rr: I<0x49, MRMSrcReg, // if !signed, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +00001370 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Sean Callanan2c48df22009-12-18 00:01:26 +00001371 "cmovns{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001372 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001373 X86_COND_NS, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001374 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001375def CMOVP16rr : I<0x4A, MRMSrcReg, // if parity, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +00001376 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Sean Callanan2c48df22009-12-18 00:01:26 +00001377 "cmovp{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001378 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001379 X86_COND_P, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001380 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001381def CMOVP32rr : I<0x4A, MRMSrcReg, // if parity, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +00001382 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Sean Callanan2c48df22009-12-18 00:01:26 +00001383 "cmovp{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001384 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001385 X86_COND_P, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001386 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001387def CMOVNP16rr : I<0x4B, MRMSrcReg, // if !parity, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +00001388 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Sean Callanan2c48df22009-12-18 00:01:26 +00001389 "cmovnp{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001390 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001391 X86_COND_NP, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001392 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001393def CMOVNP32rr : I<0x4B, MRMSrcReg, // if !parity, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +00001394 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Sean Callanan2c48df22009-12-18 00:01:26 +00001395 "cmovnp{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001396 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001397 X86_COND_NP, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001398 TB;
Dan Gohman12fd4d72009-01-07 00:35:10 +00001399def CMOVO16rr : I<0x40, MRMSrcReg, // if overflow, GR16 = GR16
1400 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Sean Callanan2c48df22009-12-18 00:01:26 +00001401 "cmovo{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohman12fd4d72009-01-07 00:35:10 +00001402 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
1403 X86_COND_O, EFLAGS))]>,
1404 TB, OpSize;
1405def CMOVO32rr : I<0x40, MRMSrcReg, // if overflow, GR32 = GR32
1406 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Sean Callanan2c48df22009-12-18 00:01:26 +00001407 "cmovo{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohman12fd4d72009-01-07 00:35:10 +00001408 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
1409 X86_COND_O, EFLAGS))]>,
Evan Cheng950aac02007-09-25 01:57:46 +00001410 TB;
Dan Gohman12fd4d72009-01-07 00:35:10 +00001411def CMOVNO16rr : I<0x41, MRMSrcReg, // if !overflow, GR16 = GR16
1412 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Sean Callanan2c48df22009-12-18 00:01:26 +00001413 "cmovno{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohman12fd4d72009-01-07 00:35:10 +00001414 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
1415 X86_COND_NO, EFLAGS))]>,
1416 TB, OpSize;
1417def CMOVNO32rr : I<0x41, MRMSrcReg, // if !overflow, GR32 = GR32
1418 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Sean Callanan2c48df22009-12-18 00:01:26 +00001419 "cmovno{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohman12fd4d72009-01-07 00:35:10 +00001420 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
1421 X86_COND_NO, EFLAGS))]>,
1422 TB;
1423} // isCommutable = 1
Evan Cheng926658c2007-10-05 23:13:21 +00001424
1425def CMOVB16rm : I<0x42, MRMSrcMem, // if <u, GR16 = [mem16]
1426 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
Sean Callanan2c48df22009-12-18 00:01:26 +00001427 "cmovb{w}\t{$src2, $dst|$dst, $src2}",
Evan Cheng926658c2007-10-05 23:13:21 +00001428 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1429 X86_COND_B, EFLAGS))]>,
1430 TB, OpSize;
1431def CMOVB32rm : I<0x42, MRMSrcMem, // if <u, GR32 = [mem32]
1432 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Sean Callanan2c48df22009-12-18 00:01:26 +00001433 "cmovb{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng926658c2007-10-05 23:13:21 +00001434 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1435 X86_COND_B, EFLAGS))]>,
1436 TB;
1437def CMOVAE16rm: I<0x43, MRMSrcMem, // if >=u, GR16 = [mem16]
1438 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
Sean Callanan2c48df22009-12-18 00:01:26 +00001439 "cmovae{w}\t{$src2, $dst|$dst, $src2}",
Evan Cheng926658c2007-10-05 23:13:21 +00001440 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1441 X86_COND_AE, EFLAGS))]>,
1442 TB, OpSize;
1443def CMOVAE32rm: I<0x43, MRMSrcMem, // if >=u, GR32 = [mem32]
1444 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Sean Callanan2c48df22009-12-18 00:01:26 +00001445 "cmovae{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng926658c2007-10-05 23:13:21 +00001446 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1447 X86_COND_AE, EFLAGS))]>,
1448 TB;
1449def CMOVE16rm : I<0x44, MRMSrcMem, // if ==, GR16 = [mem16]
1450 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
Sean Callanan2c48df22009-12-18 00:01:26 +00001451 "cmove{w}\t{$src2, $dst|$dst, $src2}",
Evan Cheng926658c2007-10-05 23:13:21 +00001452 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1453 X86_COND_E, EFLAGS))]>,
1454 TB, OpSize;
1455def CMOVE32rm : I<0x44, MRMSrcMem, // if ==, GR32 = [mem32]
1456 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Sean Callanan2c48df22009-12-18 00:01:26 +00001457 "cmove{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng926658c2007-10-05 23:13:21 +00001458 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1459 X86_COND_E, EFLAGS))]>,
1460 TB;
1461def CMOVNE16rm: I<0x45, MRMSrcMem, // if !=, GR16 = [mem16]
1462 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
Sean Callanan2c48df22009-12-18 00:01:26 +00001463 "cmovne{w}\t{$src2, $dst|$dst, $src2}",
Evan Cheng926658c2007-10-05 23:13:21 +00001464 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1465 X86_COND_NE, EFLAGS))]>,
1466 TB, OpSize;
1467def CMOVNE32rm: I<0x45, MRMSrcMem, // if !=, GR32 = [mem32]
1468 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Sean Callanan2c48df22009-12-18 00:01:26 +00001469 "cmovne{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng926658c2007-10-05 23:13:21 +00001470 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1471 X86_COND_NE, EFLAGS))]>,
1472 TB;
1473def CMOVBE16rm: I<0x46, MRMSrcMem, // if <=u, GR16 = [mem16]
1474 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
Sean Callanan2c48df22009-12-18 00:01:26 +00001475 "cmovbe{w}\t{$src2, $dst|$dst, $src2}",
Evan Cheng926658c2007-10-05 23:13:21 +00001476 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1477 X86_COND_BE, EFLAGS))]>,
1478 TB, OpSize;
1479def CMOVBE32rm: I<0x46, MRMSrcMem, // if <=u, GR32 = [mem32]
1480 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Sean Callanan2c48df22009-12-18 00:01:26 +00001481 "cmovbe{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng926658c2007-10-05 23:13:21 +00001482 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1483 X86_COND_BE, EFLAGS))]>,
1484 TB;
1485def CMOVA16rm : I<0x47, MRMSrcMem, // if >u, GR16 = [mem16]
1486 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
Sean Callanan2c48df22009-12-18 00:01:26 +00001487 "cmova{w}\t{$src2, $dst|$dst, $src2}",
Evan Cheng926658c2007-10-05 23:13:21 +00001488 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1489 X86_COND_A, EFLAGS))]>,
1490 TB, OpSize;
1491def CMOVA32rm : I<0x47, MRMSrcMem, // if >u, GR32 = [mem32]
1492 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Sean Callanan2c48df22009-12-18 00:01:26 +00001493 "cmova{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng926658c2007-10-05 23:13:21 +00001494 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1495 X86_COND_A, EFLAGS))]>,
1496 TB;
1497def CMOVL16rm : I<0x4C, MRMSrcMem, // if <s, GR16 = [mem16]
1498 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
Sean Callanan2c48df22009-12-18 00:01:26 +00001499 "cmovl{w}\t{$src2, $dst|$dst, $src2}",
Evan Cheng926658c2007-10-05 23:13:21 +00001500 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1501 X86_COND_L, EFLAGS))]>,
1502 TB, OpSize;
1503def CMOVL32rm : I<0x4C, MRMSrcMem, // if <s, GR32 = [mem32]
1504 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Sean Callanan2c48df22009-12-18 00:01:26 +00001505 "cmovl{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng926658c2007-10-05 23:13:21 +00001506 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1507 X86_COND_L, EFLAGS))]>,
1508 TB;
1509def CMOVGE16rm: I<0x4D, MRMSrcMem, // if >=s, GR16 = [mem16]
1510 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
Sean Callanan2c48df22009-12-18 00:01:26 +00001511 "cmovge{w}\t{$src2, $dst|$dst, $src2}",
Evan Cheng926658c2007-10-05 23:13:21 +00001512 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1513 X86_COND_GE, EFLAGS))]>,
1514 TB, OpSize;
1515def CMOVGE32rm: I<0x4D, MRMSrcMem, // if >=s, GR32 = [mem32]
1516 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Sean Callanan2c48df22009-12-18 00:01:26 +00001517 "cmovge{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng926658c2007-10-05 23:13:21 +00001518 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1519 X86_COND_GE, EFLAGS))]>,
1520 TB;
1521def CMOVLE16rm: I<0x4E, MRMSrcMem, // if <=s, GR16 = [mem16]
1522 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
Sean Callanan2c48df22009-12-18 00:01:26 +00001523 "cmovle{w}\t{$src2, $dst|$dst, $src2}",
Evan Cheng926658c2007-10-05 23:13:21 +00001524 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1525 X86_COND_LE, EFLAGS))]>,
1526 TB, OpSize;
1527def CMOVLE32rm: I<0x4E, MRMSrcMem, // if <=s, GR32 = [mem32]
1528 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Sean Callanan2c48df22009-12-18 00:01:26 +00001529 "cmovle{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng926658c2007-10-05 23:13:21 +00001530 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1531 X86_COND_LE, EFLAGS))]>,
1532 TB;
1533def CMOVG16rm : I<0x4F, MRMSrcMem, // if >s, GR16 = [mem16]
1534 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
Sean Callanan2c48df22009-12-18 00:01:26 +00001535 "cmovg{w}\t{$src2, $dst|$dst, $src2}",
Evan Cheng926658c2007-10-05 23:13:21 +00001536 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1537 X86_COND_G, EFLAGS))]>,
1538 TB, OpSize;
1539def CMOVG32rm : I<0x4F, MRMSrcMem, // if >s, GR32 = [mem32]
1540 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Sean Callanan2c48df22009-12-18 00:01:26 +00001541 "cmovg{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng926658c2007-10-05 23:13:21 +00001542 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1543 X86_COND_G, EFLAGS))]>,
1544 TB;
1545def CMOVS16rm : I<0x48, MRMSrcMem, // if signed, GR16 = [mem16]
1546 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
Sean Callanan2c48df22009-12-18 00:01:26 +00001547 "cmovs{w}\t{$src2, $dst|$dst, $src2}",
Evan Cheng926658c2007-10-05 23:13:21 +00001548 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1549 X86_COND_S, EFLAGS))]>,
1550 TB, OpSize;
1551def CMOVS32rm : I<0x48, MRMSrcMem, // if signed, GR32 = [mem32]
1552 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Sean Callanan2c48df22009-12-18 00:01:26 +00001553 "cmovs{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng926658c2007-10-05 23:13:21 +00001554 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1555 X86_COND_S, EFLAGS))]>,
1556 TB;
1557def CMOVNS16rm: I<0x49, MRMSrcMem, // if !signed, GR16 = [mem16]
1558 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
Sean Callanan2c48df22009-12-18 00:01:26 +00001559 "cmovns{w}\t{$src2, $dst|$dst, $src2}",
Evan Cheng926658c2007-10-05 23:13:21 +00001560 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1561 X86_COND_NS, EFLAGS))]>,
1562 TB, OpSize;
1563def CMOVNS32rm: I<0x49, MRMSrcMem, // if !signed, GR32 = [mem32]
1564 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Sean Callanan2c48df22009-12-18 00:01:26 +00001565 "cmovns{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng926658c2007-10-05 23:13:21 +00001566 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1567 X86_COND_NS, EFLAGS))]>,
1568 TB;
1569def CMOVP16rm : I<0x4A, MRMSrcMem, // if parity, GR16 = [mem16]
1570 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
Sean Callanan2c48df22009-12-18 00:01:26 +00001571 "cmovp{w}\t{$src2, $dst|$dst, $src2}",
Evan Cheng926658c2007-10-05 23:13:21 +00001572 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1573 X86_COND_P, EFLAGS))]>,
1574 TB, OpSize;
1575def CMOVP32rm : I<0x4A, MRMSrcMem, // if parity, GR32 = [mem32]
1576 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Sean Callanan2c48df22009-12-18 00:01:26 +00001577 "cmovp{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng926658c2007-10-05 23:13:21 +00001578 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1579 X86_COND_P, EFLAGS))]>,
1580 TB;
1581def CMOVNP16rm : I<0x4B, MRMSrcMem, // if !parity, GR16 = [mem16]
1582 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
Sean Callanan2c48df22009-12-18 00:01:26 +00001583 "cmovnp{w}\t{$src2, $dst|$dst, $src2}",
Evan Cheng926658c2007-10-05 23:13:21 +00001584 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1585 X86_COND_NP, EFLAGS))]>,
1586 TB, OpSize;
Dan Gohman12fd4d72009-01-07 00:35:10 +00001587def CMOVNP32rm : I<0x4B, MRMSrcMem, // if !parity, GR32 = [mem32]
1588 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Sean Callanan2c48df22009-12-18 00:01:26 +00001589 "cmovnp{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohman12fd4d72009-01-07 00:35:10 +00001590 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1591 X86_COND_NP, EFLAGS))]>,
1592 TB;
1593def CMOVO16rm : I<0x40, MRMSrcMem, // if overflow, GR16 = [mem16]
1594 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
Sean Callanan2c48df22009-12-18 00:01:26 +00001595 "cmovo{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohman12fd4d72009-01-07 00:35:10 +00001596 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1597 X86_COND_O, EFLAGS))]>,
1598 TB, OpSize;
1599def CMOVO32rm : I<0x40, MRMSrcMem, // if overflow, GR32 = [mem32]
1600 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Sean Callanan2c48df22009-12-18 00:01:26 +00001601 "cmovo{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohman12fd4d72009-01-07 00:35:10 +00001602 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1603 X86_COND_O, EFLAGS))]>,
1604 TB;
1605def CMOVNO16rm : I<0x41, MRMSrcMem, // if !overflow, GR16 = [mem16]
1606 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
Sean Callanan2c48df22009-12-18 00:01:26 +00001607 "cmovno{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohman12fd4d72009-01-07 00:35:10 +00001608 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1609 X86_COND_NO, EFLAGS))]>,
1610 TB, OpSize;
1611def CMOVNO32rm : I<0x41, MRMSrcMem, // if !overflow, GR32 = [mem32]
1612 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Sean Callanan2c48df22009-12-18 00:01:26 +00001613 "cmovno{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohman12fd4d72009-01-07 00:35:10 +00001614 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1615 X86_COND_NO, EFLAGS))]>,
1616 TB;
Evan Cheng950aac02007-09-25 01:57:46 +00001617} // Uses = [EFLAGS]
1618
1619
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001620// unary instructions
1621let CodeSize = 2 in {
Evan Cheng55687072007-09-14 21:48:26 +00001622let Defs = [EFLAGS] in {
Dan Gohman91888f02007-07-31 20:11:57 +00001623def NEG8r : I<0xF6, MRM3r, (outs GR8 :$dst), (ins GR8 :$src), "neg{b}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001624 [(set GR8:$dst, (ineg GR8:$src)),
1625 (implicit EFLAGS)]>;
Dan Gohman91888f02007-07-31 20:11:57 +00001626def NEG16r : I<0xF7, MRM3r, (outs GR16:$dst), (ins GR16:$src), "neg{w}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001627 [(set GR16:$dst, (ineg GR16:$src)),
1628 (implicit EFLAGS)]>, OpSize;
Dan Gohman91888f02007-07-31 20:11:57 +00001629def NEG32r : I<0xF7, MRM3r, (outs GR32:$dst), (ins GR32:$src), "neg{l}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001630 [(set GR32:$dst, (ineg GR32:$src)),
1631 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001632let isTwoAddress = 0 in {
Dan Gohman91888f02007-07-31 20:11:57 +00001633 def NEG8m : I<0xF6, MRM3m, (outs), (ins i8mem :$dst), "neg{b}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001634 [(store (ineg (loadi8 addr:$dst)), addr:$dst),
1635 (implicit EFLAGS)]>;
Dan Gohman91888f02007-07-31 20:11:57 +00001636 def NEG16m : I<0xF7, MRM3m, (outs), (ins i16mem:$dst), "neg{w}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001637 [(store (ineg (loadi16 addr:$dst)), addr:$dst),
1638 (implicit EFLAGS)]>, OpSize;
Dan Gohman91888f02007-07-31 20:11:57 +00001639 def NEG32m : I<0xF7, MRM3m, (outs), (ins i32mem:$dst), "neg{l}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001640 [(store (ineg (loadi32 addr:$dst)), addr:$dst),
1641 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001642}
Evan Cheng55687072007-09-14 21:48:26 +00001643} // Defs = [EFLAGS]
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001644
Evan Chengc6cee682009-01-21 02:09:05 +00001645// Match xor -1 to not. Favors these over a move imm + xor to save code size.
1646let AddedComplexity = 15 in {
Dan Gohman91888f02007-07-31 20:11:57 +00001647def NOT8r : I<0xF6, MRM2r, (outs GR8 :$dst), (ins GR8 :$src), "not{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001648 [(set GR8:$dst, (not GR8:$src))]>;
Dan Gohman91888f02007-07-31 20:11:57 +00001649def NOT16r : I<0xF7, MRM2r, (outs GR16:$dst), (ins GR16:$src), "not{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001650 [(set GR16:$dst, (not GR16:$src))]>, OpSize;
Dan Gohman91888f02007-07-31 20:11:57 +00001651def NOT32r : I<0xF7, MRM2r, (outs GR32:$dst), (ins GR32:$src), "not{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001652 [(set GR32:$dst, (not GR32:$src))]>;
Evan Chengc6cee682009-01-21 02:09:05 +00001653}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001654let isTwoAddress = 0 in {
Dan Gohman91888f02007-07-31 20:11:57 +00001655 def NOT8m : I<0xF6, MRM2m, (outs), (ins i8mem :$dst), "not{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001656 [(store (not (loadi8 addr:$dst)), addr:$dst)]>;
Dan Gohman91888f02007-07-31 20:11:57 +00001657 def NOT16m : I<0xF7, MRM2m, (outs), (ins i16mem:$dst), "not{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001658 [(store (not (loadi16 addr:$dst)), addr:$dst)]>, OpSize;
Dan Gohman91888f02007-07-31 20:11:57 +00001659 def NOT32m : I<0xF7, MRM2m, (outs), (ins i32mem:$dst), "not{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001660 [(store (not (loadi32 addr:$dst)), addr:$dst)]>;
1661}
1662} // CodeSize
1663
1664// TODO: inc/dec is slow for P4, but fast for Pentium-M.
Evan Cheng55687072007-09-14 21:48:26 +00001665let Defs = [EFLAGS] in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001666let CodeSize = 2 in
Dan Gohman91888f02007-07-31 20:11:57 +00001667def INC8r : I<0xFE, MRM0r, (outs GR8 :$dst), (ins GR8 :$src), "inc{b}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001668 [(set GR8:$dst, (add GR8:$src, 1)),
1669 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001670let isConvertibleToThreeAddress = 1, CodeSize = 1 in { // Can xform into LEA.
Sean Callanan2c48df22009-12-18 00:01:26 +00001671def INC16r : I<0x40, AddRegFrm, (outs GR16:$dst), (ins GR16:$src),
1672 "inc{w}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001673 [(set GR16:$dst, (add GR16:$src, 1)),
1674 (implicit EFLAGS)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001675 OpSize, Requires<[In32BitMode]>;
Sean Callanan2c48df22009-12-18 00:01:26 +00001676def INC32r : I<0x40, AddRegFrm, (outs GR32:$dst), (ins GR32:$src),
1677 "inc{l}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001678 [(set GR32:$dst, (add GR32:$src, 1)),
1679 (implicit EFLAGS)]>, Requires<[In32BitMode]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001680}
1681let isTwoAddress = 0, CodeSize = 2 in {
Dan Gohman91888f02007-07-31 20:11:57 +00001682 def INC8m : I<0xFE, MRM0m, (outs), (ins i8mem :$dst), "inc{b}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001683 [(store (add (loadi8 addr:$dst), 1), addr:$dst),
1684 (implicit EFLAGS)]>;
Dan Gohman91888f02007-07-31 20:11:57 +00001685 def INC16m : I<0xFF, MRM0m, (outs), (ins i16mem:$dst), "inc{w}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001686 [(store (add (loadi16 addr:$dst), 1), addr:$dst),
1687 (implicit EFLAGS)]>,
Evan Cheng4a7e72f2007-10-19 21:23:22 +00001688 OpSize, Requires<[In32BitMode]>;
Dan Gohman91888f02007-07-31 20:11:57 +00001689 def INC32m : I<0xFF, MRM0m, (outs), (ins i32mem:$dst), "inc{l}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001690 [(store (add (loadi32 addr:$dst), 1), addr:$dst),
1691 (implicit EFLAGS)]>,
Evan Cheng4a7e72f2007-10-19 21:23:22 +00001692 Requires<[In32BitMode]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001693}
1694
1695let CodeSize = 2 in
Dan Gohman91888f02007-07-31 20:11:57 +00001696def DEC8r : I<0xFE, MRM1r, (outs GR8 :$dst), (ins GR8 :$src), "dec{b}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001697 [(set GR8:$dst, (add GR8:$src, -1)),
1698 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001699let isConvertibleToThreeAddress = 1, CodeSize = 1 in { // Can xform into LEA.
Sean Callanan2c48df22009-12-18 00:01:26 +00001700def DEC16r : I<0x48, AddRegFrm, (outs GR16:$dst), (ins GR16:$src),
1701 "dec{w}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001702 [(set GR16:$dst, (add GR16:$src, -1)),
1703 (implicit EFLAGS)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001704 OpSize, Requires<[In32BitMode]>;
Sean Callanan2c48df22009-12-18 00:01:26 +00001705def DEC32r : I<0x48, AddRegFrm, (outs GR32:$dst), (ins GR32:$src),
1706 "dec{l}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001707 [(set GR32:$dst, (add GR32:$src, -1)),
1708 (implicit EFLAGS)]>, Requires<[In32BitMode]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001709}
1710
1711let isTwoAddress = 0, CodeSize = 2 in {
Dan Gohman91888f02007-07-31 20:11:57 +00001712 def DEC8m : I<0xFE, MRM1m, (outs), (ins i8mem :$dst), "dec{b}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001713 [(store (add (loadi8 addr:$dst), -1), addr:$dst),
1714 (implicit EFLAGS)]>;
Dan Gohman91888f02007-07-31 20:11:57 +00001715 def DEC16m : I<0xFF, MRM1m, (outs), (ins i16mem:$dst), "dec{w}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001716 [(store (add (loadi16 addr:$dst), -1), addr:$dst),
1717 (implicit EFLAGS)]>,
Evan Cheng4a7e72f2007-10-19 21:23:22 +00001718 OpSize, Requires<[In32BitMode]>;
Dan Gohman91888f02007-07-31 20:11:57 +00001719 def DEC32m : I<0xFF, MRM1m, (outs), (ins i32mem:$dst), "dec{l}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001720 [(store (add (loadi32 addr:$dst), -1), addr:$dst),
1721 (implicit EFLAGS)]>,
Evan Cheng4a7e72f2007-10-19 21:23:22 +00001722 Requires<[In32BitMode]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001723}
Evan Cheng55687072007-09-14 21:48:26 +00001724} // Defs = [EFLAGS]
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001725
1726// Logical operators...
Evan Cheng55687072007-09-14 21:48:26 +00001727let Defs = [EFLAGS] in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001728let isCommutable = 1 in { // X = AND Y, Z --> X = AND Z, Y
1729def AND8rr : I<0x20, MRMDestReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001730 (outs GR8 :$dst), (ins GR8 :$src1, GR8 :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001731 "and{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001732 [(set GR8:$dst, (and GR8:$src1, GR8:$src2)),
1733 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001734def AND16rr : I<0x21, MRMDestReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001735 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001736 "and{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001737 [(set GR16:$dst, (and GR16:$src1, GR16:$src2)),
1738 (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001739def AND32rr : I<0x21, MRMDestReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001740 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001741 "and{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001742 [(set GR32:$dst, (and GR32:$src1, GR32:$src2)),
1743 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001744}
1745
Sean Callanan2c48df22009-12-18 00:01:26 +00001746// AND instructions with the destination register in REG and the source register
1747// in R/M. Included for the disassembler.
1748def AND8rr_REV : I<0x22, MRMSrcReg, (outs GR8:$dst), (ins GR8:$src1, GR8:$src2),
1749 "and{b}\t{$src2, $dst|$dst, $src2}", []>;
1750def AND16rr_REV : I<0x23, MRMSrcReg, (outs GR16:$dst),
1751 (ins GR16:$src1, GR16:$src2),
1752 "and{w}\t{$src2, $dst|$dst, $src2}", []>, OpSize;
1753def AND32rr_REV : I<0x23, MRMSrcReg, (outs GR32:$dst),
1754 (ins GR32:$src1, GR32:$src2),
1755 "and{l}\t{$src2, $dst|$dst, $src2}", []>;
1756
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001757def AND8rm : I<0x22, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001758 (outs GR8 :$dst), (ins GR8 :$src1, i8mem :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001759 "and{b}\t{$src2, $dst|$dst, $src2}",
Chris Lattner12208612009-04-10 00:16:23 +00001760 [(set GR8:$dst, (and GR8:$src1, (loadi8 addr:$src2))),
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001761 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001762def AND16rm : I<0x23, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001763 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001764 "and{w}\t{$src2, $dst|$dst, $src2}",
Chris Lattner12208612009-04-10 00:16:23 +00001765 [(set GR16:$dst, (and GR16:$src1, (loadi16 addr:$src2))),
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001766 (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001767def AND32rm : I<0x23, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001768 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001769 "and{l}\t{$src2, $dst|$dst, $src2}",
Chris Lattner12208612009-04-10 00:16:23 +00001770 [(set GR32:$dst, (and GR32:$src1, (loadi32 addr:$src2))),
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001771 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001772
1773def AND8ri : Ii8<0x80, MRM4r,
Evan Chengb783fa32007-07-19 01:14:50 +00001774 (outs GR8 :$dst), (ins GR8 :$src1, i8imm :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001775 "and{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001776 [(set GR8:$dst, (and GR8:$src1, imm:$src2)),
1777 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001778def AND16ri : Ii16<0x81, MRM4r,
Evan Chengb783fa32007-07-19 01:14:50 +00001779 (outs GR16:$dst), (ins GR16:$src1, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001780 "and{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001781 [(set GR16:$dst, (and GR16:$src1, imm:$src2)),
1782 (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001783def AND32ri : Ii32<0x81, MRM4r,
Evan Chengb783fa32007-07-19 01:14:50 +00001784 (outs GR32:$dst), (ins GR32:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001785 "and{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001786 [(set GR32:$dst, (and GR32:$src1, imm:$src2)),
1787 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001788def AND16ri8 : Ii8<0x83, MRM4r,
Evan Chengb783fa32007-07-19 01:14:50 +00001789 (outs GR16:$dst), (ins GR16:$src1, i16i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001790 "and{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001791 [(set GR16:$dst, (and GR16:$src1, i16immSExt8:$src2)),
1792 (implicit EFLAGS)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001793 OpSize;
1794def AND32ri8 : Ii8<0x83, MRM4r,
Evan Chengb783fa32007-07-19 01:14:50 +00001795 (outs GR32:$dst), (ins GR32:$src1, i32i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001796 "and{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001797 [(set GR32:$dst, (and GR32:$src1, i32immSExt8:$src2)),
1798 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001799
1800let isTwoAddress = 0 in {
1801 def AND8mr : I<0x20, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001802 (outs), (ins i8mem :$dst, GR8 :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001803 "and{b}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001804 [(store (and (load addr:$dst), GR8:$src), addr:$dst),
1805 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001806 def AND16mr : I<0x21, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001807 (outs), (ins i16mem:$dst, GR16:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001808 "and{w}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001809 [(store (and (load addr:$dst), GR16:$src), addr:$dst),
1810 (implicit EFLAGS)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001811 OpSize;
1812 def AND32mr : I<0x21, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001813 (outs), (ins i32mem:$dst, GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001814 "and{l}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001815 [(store (and (load addr:$dst), GR32:$src), addr:$dst),
1816 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001817 def AND8mi : Ii8<0x80, MRM4m,
Evan Chengb783fa32007-07-19 01:14:50 +00001818 (outs), (ins i8mem :$dst, i8imm :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001819 "and{b}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001820 [(store (and (loadi8 addr:$dst), imm:$src), addr:$dst),
1821 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001822 def AND16mi : Ii16<0x81, MRM4m,
Evan Chengb783fa32007-07-19 01:14:50 +00001823 (outs), (ins i16mem:$dst, i16imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001824 "and{w}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001825 [(store (and (loadi16 addr:$dst), imm:$src), addr:$dst),
1826 (implicit EFLAGS)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001827 OpSize;
1828 def AND32mi : Ii32<0x81, MRM4m,
Evan Chengb783fa32007-07-19 01:14:50 +00001829 (outs), (ins i32mem:$dst, i32imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001830 "and{l}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001831 [(store (and (loadi32 addr:$dst), imm:$src), addr:$dst),
1832 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001833 def AND16mi8 : Ii8<0x83, MRM4m,
Evan Chengb783fa32007-07-19 01:14:50 +00001834 (outs), (ins i16mem:$dst, i16i8imm :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001835 "and{w}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001836 [(store (and (load addr:$dst), i16immSExt8:$src), addr:$dst),
1837 (implicit EFLAGS)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001838 OpSize;
1839 def AND32mi8 : Ii8<0x83, MRM4m,
Evan Chengb783fa32007-07-19 01:14:50 +00001840 (outs), (ins i32mem:$dst, i32i8imm :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001841 "and{l}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001842 [(store (and (load addr:$dst), i32immSExt8:$src), addr:$dst),
1843 (implicit EFLAGS)]>;
Sean Callanan251676e2009-09-02 00:55:49 +00001844
1845 def AND8i8 : Ii8<0x24, RawFrm, (outs), (ins i8imm:$src),
1846 "and{b}\t{$src, %al|%al, $src}", []>;
1847 def AND16i16 : Ii16<0x25, RawFrm, (outs), (ins i16imm:$src),
1848 "and{w}\t{$src, %ax|%ax, $src}", []>, OpSize;
1849 def AND32i32 : Ii32<0x25, RawFrm, (outs), (ins i32imm:$src),
1850 "and{l}\t{$src, %eax|%eax, $src}", []>;
1851
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001852}
1853
1854
1855let isCommutable = 1 in { // X = OR Y, Z --> X = OR Z, Y
Sean Callanan2c48df22009-12-18 00:01:26 +00001856def OR8rr : I<0x08, MRMDestReg, (outs GR8 :$dst),
1857 (ins GR8 :$src1, GR8 :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001858 "or{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001859 [(set GR8:$dst, (or GR8:$src1, GR8:$src2)),
1860 (implicit EFLAGS)]>;
Sean Callanan2c48df22009-12-18 00:01:26 +00001861def OR16rr : I<0x09, MRMDestReg, (outs GR16:$dst),
1862 (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001863 "or{w}\t{$src2, $dst|$dst, $src2}",
Evan Cheng44a441c2010-01-12 18:31:19 +00001864 [(set GR16:$dst, (or GR16:$src1, GR16:$src2)),
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001865 (implicit EFLAGS)]>, OpSize;
Sean Callanan2c48df22009-12-18 00:01:26 +00001866def OR32rr : I<0x09, MRMDestReg, (outs GR32:$dst),
1867 (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001868 "or{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng44a441c2010-01-12 18:31:19 +00001869 [(set GR32:$dst, (or GR32:$src1, GR32:$src2)),
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001870 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001871}
Sean Callanan2c48df22009-12-18 00:01:26 +00001872
1873// OR instructions with the destination register in REG and the source register
1874// in R/M. Included for the disassembler.
1875def OR8rr_REV : I<0x0A, MRMSrcReg, (outs GR8:$dst), (ins GR8:$src1, GR8:$src2),
1876 "or{b}\t{$src2, $dst|$dst, $src2}", []>;
1877def OR16rr_REV : I<0x0B, MRMSrcReg, (outs GR16:$dst),
1878 (ins GR16:$src1, GR16:$src2),
1879 "or{w}\t{$src2, $dst|$dst, $src2}", []>, OpSize;
1880def OR32rr_REV : I<0x0B, MRMSrcReg, (outs GR32:$dst),
1881 (ins GR32:$src1, GR32:$src2),
1882 "or{l}\t{$src2, $dst|$dst, $src2}", []>;
1883
1884def OR8rm : I<0x0A, MRMSrcMem , (outs GR8 :$dst),
1885 (ins GR8 :$src1, i8mem :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001886 "or{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001887 [(set GR8:$dst, (or GR8:$src1, (load addr:$src2))),
1888 (implicit EFLAGS)]>;
Sean Callanan2c48df22009-12-18 00:01:26 +00001889def OR16rm : I<0x0B, MRMSrcMem , (outs GR16:$dst),
1890 (ins GR16:$src1, i16mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001891 "or{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001892 [(set GR16:$dst, (or GR16:$src1, (load addr:$src2))),
1893 (implicit EFLAGS)]>, OpSize;
Sean Callanan2c48df22009-12-18 00:01:26 +00001894def OR32rm : I<0x0B, MRMSrcMem , (outs GR32:$dst),
1895 (ins GR32:$src1, i32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001896 "or{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001897 [(set GR32:$dst, (or GR32:$src1, (load addr:$src2))),
1898 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001899
Sean Callanan2c48df22009-12-18 00:01:26 +00001900def OR8ri : Ii8 <0x80, MRM1r, (outs GR8 :$dst),
1901 (ins GR8 :$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001902 "or{b}\t{$src2, $dst|$dst, $src2}",
Evan Cheng87516752010-01-11 20:18:04 +00001903 [(set GR8:$dst, (or GR8:$src1, imm:$src2)),
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001904 (implicit EFLAGS)]>;
Sean Callanan2c48df22009-12-18 00:01:26 +00001905def OR16ri : Ii16<0x81, MRM1r, (outs GR16:$dst),
1906 (ins GR16:$src1, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001907 "or{w}\t{$src2, $dst|$dst, $src2}",
Evan Cheng44a441c2010-01-12 18:31:19 +00001908 [(set GR16:$dst, (or GR16:$src1, imm:$src2)),
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001909 (implicit EFLAGS)]>, OpSize;
Sean Callanan2c48df22009-12-18 00:01:26 +00001910def OR32ri : Ii32<0x81, MRM1r, (outs GR32:$dst),
1911 (ins GR32:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001912 "or{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng44a441c2010-01-12 18:31:19 +00001913 [(set GR32:$dst, (or GR32:$src1, imm:$src2)),
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001914 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001915
Sean Callanan2c48df22009-12-18 00:01:26 +00001916def OR16ri8 : Ii8<0x83, MRM1r, (outs GR16:$dst),
1917 (ins GR16:$src1, i16i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001918 "or{w}\t{$src2, $dst|$dst, $src2}",
Evan Cheng44a441c2010-01-12 18:31:19 +00001919 [(set GR16:$dst, (or GR16:$src1, i16immSExt8:$src2)),
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001920 (implicit EFLAGS)]>, OpSize;
Sean Callanan2c48df22009-12-18 00:01:26 +00001921def OR32ri8 : Ii8<0x83, MRM1r, (outs GR32:$dst),
1922 (ins GR32:$src1, i32i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001923 "or{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng44a441c2010-01-12 18:31:19 +00001924 [(set GR32:$dst, (or GR32:$src1, i32immSExt8:$src2)),
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001925 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001926let isTwoAddress = 0 in {
Evan Chengb783fa32007-07-19 01:14:50 +00001927 def OR8mr : I<0x08, MRMDestMem, (outs), (ins i8mem:$dst, GR8:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001928 "or{b}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001929 [(store (or (load addr:$dst), GR8:$src), addr:$dst),
1930 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001931 def OR16mr : I<0x09, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001932 "or{w}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001933 [(store (or (load addr:$dst), GR16:$src), addr:$dst),
1934 (implicit EFLAGS)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001935 def OR32mr : I<0x09, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001936 "or{l}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001937 [(store (or (load addr:$dst), GR32:$src), addr:$dst),
1938 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001939 def OR8mi : Ii8<0x80, MRM1m, (outs), (ins i8mem :$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001940 "or{b}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001941 [(store (or (loadi8 addr:$dst), imm:$src), addr:$dst),
1942 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001943 def OR16mi : Ii16<0x81, MRM1m, (outs), (ins i16mem:$dst, i16imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001944 "or{w}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001945 [(store (or (loadi16 addr:$dst), imm:$src), addr:$dst),
1946 (implicit EFLAGS)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001947 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001948 def OR32mi : Ii32<0x81, MRM1m, (outs), (ins i32mem:$dst, i32imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001949 "or{l}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001950 [(store (or (loadi32 addr:$dst), imm:$src), addr:$dst),
1951 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001952 def OR16mi8 : Ii8<0x83, MRM1m, (outs), (ins i16mem:$dst, i16i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001953 "or{w}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001954 [(store (or (load addr:$dst), i16immSExt8:$src), addr:$dst),
1955 (implicit EFLAGS)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001956 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001957 def OR32mi8 : Ii8<0x83, MRM1m, (outs), (ins i32mem:$dst, i32i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001958 "or{l}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001959 [(store (or (load addr:$dst), i32immSExt8:$src), addr:$dst),
1960 (implicit EFLAGS)]>;
Sean Callanan8562bef2009-09-11 19:01:56 +00001961
1962 def OR8i8 : Ii8 <0x0C, RawFrm, (outs), (ins i8imm:$src),
1963 "or{b}\t{$src, %al|%al, $src}", []>;
1964 def OR16i16 : Ii16 <0x0D, RawFrm, (outs), (ins i16imm:$src),
1965 "or{w}\t{$src, %ax|%ax, $src}", []>, OpSize;
1966 def OR32i32 : Ii32 <0x0D, RawFrm, (outs), (ins i32imm:$src),
1967 "or{l}\t{$src, %eax|%eax, $src}", []>;
Bill Wendlingba5d5b02008-05-29 01:02:09 +00001968} // isTwoAddress = 0
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001969
1970
Evan Cheng6f26e8b2008-06-18 08:13:07 +00001971let isCommutable = 1 in { // X = XOR Y, Z --> X = XOR Z, Y
Bill Wendlingba5d5b02008-05-29 01:02:09 +00001972 def XOR8rr : I<0x30, MRMDestReg,
1973 (outs GR8 :$dst), (ins GR8 :$src1, GR8 :$src2),
1974 "xor{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001975 [(set GR8:$dst, (xor GR8:$src1, GR8:$src2)),
1976 (implicit EFLAGS)]>;
Bill Wendlingba5d5b02008-05-29 01:02:09 +00001977 def XOR16rr : I<0x31, MRMDestReg,
1978 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
1979 "xor{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001980 [(set GR16:$dst, (xor GR16:$src1, GR16:$src2)),
1981 (implicit EFLAGS)]>, OpSize;
Bill Wendlingba5d5b02008-05-29 01:02:09 +00001982 def XOR32rr : I<0x31, MRMDestReg,
1983 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
1984 "xor{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001985 [(set GR32:$dst, (xor GR32:$src1, GR32:$src2)),
1986 (implicit EFLAGS)]>;
Evan Cheng6f26e8b2008-06-18 08:13:07 +00001987} // isCommutable = 1
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001988
Sean Callanan2c48df22009-12-18 00:01:26 +00001989// XOR instructions with the destination register in REG and the source register
1990// in R/M. Included for the disassembler.
1991def XOR8rr_REV : I<0x32, MRMSrcReg, (outs GR8:$dst), (ins GR8:$src1, GR8:$src2),
1992 "xor{b}\t{$src2, $dst|$dst, $src2}", []>;
1993def XOR16rr_REV : I<0x33, MRMSrcReg, (outs GR16:$dst),
1994 (ins GR16:$src1, GR16:$src2),
1995 "xor{w}\t{$src2, $dst|$dst, $src2}", []>, OpSize;
1996def XOR32rr_REV : I<0x33, MRMSrcReg, (outs GR32:$dst),
1997 (ins GR32:$src1, GR32:$src2),
1998 "xor{l}\t{$src2, $dst|$dst, $src2}", []>;
1999
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002000def XOR8rm : I<0x32, MRMSrcMem ,
Evan Chengb783fa32007-07-19 01:14:50 +00002001 (outs GR8 :$dst), (ins GR8:$src1, i8mem :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002002 "xor{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00002003 [(set GR8:$dst, (xor GR8:$src1, (load addr:$src2))),
2004 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002005def XOR16rm : I<0x33, MRMSrcMem ,
Evan Chengb783fa32007-07-19 01:14:50 +00002006 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002007 "xor{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00002008 [(set GR16:$dst, (xor GR16:$src1, (load addr:$src2))),
2009 (implicit EFLAGS)]>,
Bill Wendlingba5d5b02008-05-29 01:02:09 +00002010 OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002011def XOR32rm : I<0x33, MRMSrcMem ,
Evan Chengb783fa32007-07-19 01:14:50 +00002012 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002013 "xor{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00002014 [(set GR32:$dst, (xor GR32:$src1, (load addr:$src2))),
2015 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002016
Bill Wendlingbac38eb2008-05-29 03:46:36 +00002017def XOR8ri : Ii8<0x80, MRM6r,
2018 (outs GR8:$dst), (ins GR8:$src1, i8imm:$src2),
2019 "xor{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00002020 [(set GR8:$dst, (xor GR8:$src1, imm:$src2)),
2021 (implicit EFLAGS)]>;
Bill Wendlingbac38eb2008-05-29 03:46:36 +00002022def XOR16ri : Ii16<0x81, MRM6r,
2023 (outs GR16:$dst), (ins GR16:$src1, i16imm:$src2),
2024 "xor{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00002025 [(set GR16:$dst, (xor GR16:$src1, imm:$src2)),
2026 (implicit EFLAGS)]>, OpSize;
Bill Wendlingbac38eb2008-05-29 03:46:36 +00002027def XOR32ri : Ii32<0x81, MRM6r,
2028 (outs GR32:$dst), (ins GR32:$src1, i32imm:$src2),
2029 "xor{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00002030 [(set GR32:$dst, (xor GR32:$src1, imm:$src2)),
2031 (implicit EFLAGS)]>;
Bill Wendlingbac38eb2008-05-29 03:46:36 +00002032def XOR16ri8 : Ii8<0x83, MRM6r,
2033 (outs GR16:$dst), (ins GR16:$src1, i16i8imm:$src2),
2034 "xor{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00002035 [(set GR16:$dst, (xor GR16:$src1, i16immSExt8:$src2)),
2036 (implicit EFLAGS)]>,
Bill Wendlingbac38eb2008-05-29 03:46:36 +00002037 OpSize;
2038def XOR32ri8 : Ii8<0x83, MRM6r,
2039 (outs GR32:$dst), (ins GR32:$src1, i32i8imm:$src2),
2040 "xor{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00002041 [(set GR32:$dst, (xor GR32:$src1, i32immSExt8:$src2)),
2042 (implicit EFLAGS)]>;
Bill Wendlingba5d5b02008-05-29 01:02:09 +00002043
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002044let isTwoAddress = 0 in {
2045 def XOR8mr : I<0x30, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00002046 (outs), (ins i8mem :$dst, GR8 :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002047 "xor{b}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00002048 [(store (xor (load addr:$dst), GR8:$src), addr:$dst),
2049 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002050 def XOR16mr : I<0x31, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00002051 (outs), (ins i16mem:$dst, GR16:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002052 "xor{w}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00002053 [(store (xor (load addr:$dst), GR16:$src), addr:$dst),
2054 (implicit EFLAGS)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002055 OpSize;
2056 def XOR32mr : I<0x31, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00002057 (outs), (ins i32mem:$dst, GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002058 "xor{l}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00002059 [(store (xor (load addr:$dst), GR32:$src), addr:$dst),
2060 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002061 def XOR8mi : Ii8<0x80, MRM6m,
Evan Chengb783fa32007-07-19 01:14:50 +00002062 (outs), (ins i8mem :$dst, i8imm :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002063 "xor{b}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00002064 [(store (xor (loadi8 addr:$dst), imm:$src), addr:$dst),
2065 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002066 def XOR16mi : Ii16<0x81, MRM6m,
Evan Chengb783fa32007-07-19 01:14:50 +00002067 (outs), (ins i16mem:$dst, i16imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002068 "xor{w}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00002069 [(store (xor (loadi16 addr:$dst), imm:$src), addr:$dst),
2070 (implicit EFLAGS)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002071 OpSize;
2072 def XOR32mi : Ii32<0x81, MRM6m,
Evan Chengb783fa32007-07-19 01:14:50 +00002073 (outs), (ins i32mem:$dst, i32imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002074 "xor{l}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00002075 [(store (xor (loadi32 addr:$dst), imm:$src), addr:$dst),
2076 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002077 def XOR16mi8 : Ii8<0x83, MRM6m,
Evan Chengb783fa32007-07-19 01:14:50 +00002078 (outs), (ins i16mem:$dst, i16i8imm :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002079 "xor{w}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00002080 [(store (xor (load addr:$dst), i16immSExt8:$src), addr:$dst),
2081 (implicit EFLAGS)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002082 OpSize;
2083 def XOR32mi8 : Ii8<0x83, MRM6m,
Evan Chengb783fa32007-07-19 01:14:50 +00002084 (outs), (ins i32mem:$dst, i32i8imm :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002085 "xor{l}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00002086 [(store (xor (load addr:$dst), i32immSExt8:$src), addr:$dst),
2087 (implicit EFLAGS)]>;
Sean Callanan794457a2009-09-10 19:52:26 +00002088
2089 def XOR8i8 : Ii8 <0x34, RawFrm, (outs), (ins i8imm:$src),
2090 "xor{b}\t{$src, %al|%al, $src}", []>;
2091 def XOR16i16 : Ii16 <0x35, RawFrm, (outs), (ins i16imm:$src),
2092 "xor{w}\t{$src, %ax|%ax, $src}", []>, OpSize;
2093 def XOR32i32 : Ii32 <0x35, RawFrm, (outs), (ins i32imm:$src),
2094 "xor{l}\t{$src, %eax|%eax, $src}", []>;
Bill Wendlingba5d5b02008-05-29 01:02:09 +00002095} // isTwoAddress = 0
Evan Cheng55687072007-09-14 21:48:26 +00002096} // Defs = [EFLAGS]
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002097
2098// Shift instructions
Evan Cheng55687072007-09-14 21:48:26 +00002099let Defs = [EFLAGS] in {
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002100let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00002101def SHL8rCL : I<0xD2, MRM4r, (outs GR8 :$dst), (ins GR8 :$src),
Eli Friedman378ea832009-06-19 04:48:38 +00002102 "shl{b}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002103 [(set GR8:$dst, (shl GR8:$src, CL))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002104def SHL16rCL : I<0xD3, MRM4r, (outs GR16:$dst), (ins GR16:$src),
Eli Friedman378ea832009-06-19 04:48:38 +00002105 "shl{w}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002106 [(set GR16:$dst, (shl GR16:$src, CL))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002107def SHL32rCL : I<0xD3, MRM4r, (outs GR32:$dst), (ins GR32:$src),
Eli Friedman378ea832009-06-19 04:48:38 +00002108 "shl{l}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002109 [(set GR32:$dst, (shl GR32:$src, CL))]>;
Bill Wendlingba5d5b02008-05-29 01:02:09 +00002110} // Uses = [CL]
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002111
Evan Chengb783fa32007-07-19 01:14:50 +00002112def SHL8ri : Ii8<0xC0, MRM4r, (outs GR8 :$dst), (ins GR8 :$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002113 "shl{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002114 [(set GR8:$dst, (shl GR8:$src1, (i8 imm:$src2)))]>;
2115let isConvertibleToThreeAddress = 1 in { // Can transform into LEA.
Evan Chengb783fa32007-07-19 01:14:50 +00002116def SHL16ri : Ii8<0xC1, MRM4r, (outs GR16:$dst), (ins GR16:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002117 "shl{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002118 [(set GR16:$dst, (shl GR16:$src1, (i8 imm:$src2)))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002119def SHL32ri : Ii8<0xC1, MRM4r, (outs GR32:$dst), (ins GR32:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002120 "shl{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002121 [(set GR32:$dst, (shl GR32:$src1, (i8 imm:$src2)))]>;
Sean Callananca503e02009-09-16 02:28:43 +00002122
2123// NOTE: We don't include patterns for shifts of a register by one, because
2124// 'add reg,reg' is cheaper.
2125
2126def SHL8r1 : I<0xD0, MRM4r, (outs GR8:$dst), (ins GR8:$src1),
2127 "shl{b}\t$dst", []>;
2128def SHL16r1 : I<0xD1, MRM4r, (outs GR16:$dst), (ins GR16:$src1),
2129 "shl{w}\t$dst", []>, OpSize;
2130def SHL32r1 : I<0xD1, MRM4r, (outs GR32:$dst), (ins GR32:$src1),
2131 "shl{l}\t$dst", []>;
2132
Bill Wendlingba5d5b02008-05-29 01:02:09 +00002133} // isConvertibleToThreeAddress = 1
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002134
2135let isTwoAddress = 0 in {
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002136 let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00002137 def SHL8mCL : I<0xD2, MRM4m, (outs), (ins i8mem :$dst),
Eli Friedman378ea832009-06-19 04:48:38 +00002138 "shl{b}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002139 [(store (shl (loadi8 addr:$dst), CL), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002140 def SHL16mCL : I<0xD3, MRM4m, (outs), (ins i16mem:$dst),
Eli Friedman378ea832009-06-19 04:48:38 +00002141 "shl{w}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002142 [(store (shl (loadi16 addr:$dst), CL), addr:$dst)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002143 def SHL32mCL : I<0xD3, MRM4m, (outs), (ins i32mem:$dst),
Eli Friedman378ea832009-06-19 04:48:38 +00002144 "shl{l}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002145 [(store (shl (loadi32 addr:$dst), CL), addr:$dst)]>;
2146 }
Evan Chengb783fa32007-07-19 01:14:50 +00002147 def SHL8mi : Ii8<0xC0, MRM4m, (outs), (ins i8mem :$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002148 "shl{b}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002149 [(store (shl (loadi8 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002150 def SHL16mi : Ii8<0xC1, MRM4m, (outs), (ins i16mem:$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002151 "shl{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002152 [(store (shl (loadi16 addr:$dst), (i8 imm:$src)), addr:$dst)]>,
2153 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002154 def SHL32mi : Ii8<0xC1, MRM4m, (outs), (ins i32mem:$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002155 "shl{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002156 [(store (shl (loadi32 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
2157
2158 // Shift by 1
Evan Chengb783fa32007-07-19 01:14:50 +00002159 def SHL8m1 : I<0xD0, MRM4m, (outs), (ins i8mem :$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002160 "shl{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002161 [(store (shl (loadi8 addr:$dst), (i8 1)), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002162 def SHL16m1 : I<0xD1, MRM4m, (outs), (ins i16mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002163 "shl{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002164 [(store (shl (loadi16 addr:$dst), (i8 1)), addr:$dst)]>,
2165 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002166 def SHL32m1 : I<0xD1, MRM4m, (outs), (ins i32mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002167 "shl{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002168 [(store (shl (loadi32 addr:$dst), (i8 1)), addr:$dst)]>;
2169}
2170
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002171let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00002172def SHR8rCL : I<0xD2, MRM5r, (outs GR8 :$dst), (ins GR8 :$src),
Eli Friedman378ea832009-06-19 04:48:38 +00002173 "shr{b}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002174 [(set GR8:$dst, (srl GR8:$src, CL))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002175def SHR16rCL : I<0xD3, MRM5r, (outs GR16:$dst), (ins GR16:$src),
Eli Friedman378ea832009-06-19 04:48:38 +00002176 "shr{w}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002177 [(set GR16:$dst, (srl GR16:$src, CL))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002178def SHR32rCL : I<0xD3, MRM5r, (outs GR32:$dst), (ins GR32:$src),
Eli Friedman378ea832009-06-19 04:48:38 +00002179 "shr{l}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002180 [(set GR32:$dst, (srl GR32:$src, CL))]>;
2181}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002182
Evan Chengb783fa32007-07-19 01:14:50 +00002183def SHR8ri : Ii8<0xC0, MRM5r, (outs GR8:$dst), (ins GR8:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002184 "shr{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002185 [(set GR8:$dst, (srl GR8:$src1, (i8 imm:$src2)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002186def SHR16ri : Ii8<0xC1, MRM5r, (outs GR16:$dst), (ins GR16:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002187 "shr{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002188 [(set GR16:$dst, (srl GR16:$src1, (i8 imm:$src2)))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002189def SHR32ri : Ii8<0xC1, MRM5r, (outs GR32:$dst), (ins GR32:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002190 "shr{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002191 [(set GR32:$dst, (srl GR32:$src1, (i8 imm:$src2)))]>;
2192
2193// Shift by 1
Evan Chengb783fa32007-07-19 01:14:50 +00002194def SHR8r1 : I<0xD0, MRM5r, (outs GR8:$dst), (ins GR8:$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00002195 "shr{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002196 [(set GR8:$dst, (srl GR8:$src1, (i8 1)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002197def SHR16r1 : I<0xD1, MRM5r, (outs GR16:$dst), (ins GR16:$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00002198 "shr{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002199 [(set GR16:$dst, (srl GR16:$src1, (i8 1)))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002200def SHR32r1 : I<0xD1, MRM5r, (outs GR32:$dst), (ins GR32:$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00002201 "shr{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002202 [(set GR32:$dst, (srl GR32:$src1, (i8 1)))]>;
2203
2204let isTwoAddress = 0 in {
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002205 let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00002206 def SHR8mCL : I<0xD2, MRM5m, (outs), (ins i8mem :$dst),
Eli Friedman378ea832009-06-19 04:48:38 +00002207 "shr{b}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002208 [(store (srl (loadi8 addr:$dst), CL), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002209 def SHR16mCL : I<0xD3, MRM5m, (outs), (ins i16mem:$dst),
Eli Friedman378ea832009-06-19 04:48:38 +00002210 "shr{w}\t{%cl, $dst|$dst, CL}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002211 [(store (srl (loadi16 addr:$dst), CL), addr:$dst)]>,
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002212 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002213 def SHR32mCL : I<0xD3, MRM5m, (outs), (ins i32mem:$dst),
Eli Friedman378ea832009-06-19 04:48:38 +00002214 "shr{l}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002215 [(store (srl (loadi32 addr:$dst), CL), addr:$dst)]>;
2216 }
Evan Chengb783fa32007-07-19 01:14:50 +00002217 def SHR8mi : Ii8<0xC0, MRM5m, (outs), (ins i8mem :$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002218 "shr{b}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002219 [(store (srl (loadi8 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002220 def SHR16mi : Ii8<0xC1, MRM5m, (outs), (ins i16mem:$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002221 "shr{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002222 [(store (srl (loadi16 addr:$dst), (i8 imm:$src)), addr:$dst)]>,
2223 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002224 def SHR32mi : Ii8<0xC1, MRM5m, (outs), (ins i32mem:$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002225 "shr{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002226 [(store (srl (loadi32 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
2227
2228 // Shift by 1
Evan Chengb783fa32007-07-19 01:14:50 +00002229 def SHR8m1 : I<0xD0, MRM5m, (outs), (ins i8mem :$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002230 "shr{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002231 [(store (srl (loadi8 addr:$dst), (i8 1)), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002232 def SHR16m1 : I<0xD1, MRM5m, (outs), (ins i16mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002233 "shr{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002234 [(store (srl (loadi16 addr:$dst), (i8 1)), addr:$dst)]>,OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002235 def SHR32m1 : I<0xD1, MRM5m, (outs), (ins i32mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002236 "shr{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002237 [(store (srl (loadi32 addr:$dst), (i8 1)), addr:$dst)]>;
2238}
2239
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002240let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00002241def SAR8rCL : I<0xD2, MRM7r, (outs GR8 :$dst), (ins GR8 :$src),
Eli Friedman378ea832009-06-19 04:48:38 +00002242 "sar{b}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002243 [(set GR8:$dst, (sra GR8:$src, CL))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002244def SAR16rCL : I<0xD3, MRM7r, (outs GR16:$dst), (ins GR16:$src),
Eli Friedman378ea832009-06-19 04:48:38 +00002245 "sar{w}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002246 [(set GR16:$dst, (sra GR16:$src, CL))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002247def SAR32rCL : I<0xD3, MRM7r, (outs GR32:$dst), (ins GR32:$src),
Eli Friedman378ea832009-06-19 04:48:38 +00002248 "sar{l}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002249 [(set GR32:$dst, (sra GR32:$src, CL))]>;
2250}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002251
Evan Chengb783fa32007-07-19 01:14:50 +00002252def SAR8ri : Ii8<0xC0, MRM7r, (outs GR8 :$dst), (ins GR8 :$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002253 "sar{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002254 [(set GR8:$dst, (sra GR8:$src1, (i8 imm:$src2)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002255def SAR16ri : Ii8<0xC1, MRM7r, (outs GR16:$dst), (ins GR16:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002256 "sar{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002257 [(set GR16:$dst, (sra GR16:$src1, (i8 imm:$src2)))]>,
2258 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002259def SAR32ri : Ii8<0xC1, MRM7r, (outs GR32:$dst), (ins GR32:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002260 "sar{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002261 [(set GR32:$dst, (sra GR32:$src1, (i8 imm:$src2)))]>;
2262
2263// Shift by 1
Evan Chengb783fa32007-07-19 01:14:50 +00002264def SAR8r1 : I<0xD0, MRM7r, (outs GR8 :$dst), (ins GR8 :$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00002265 "sar{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002266 [(set GR8:$dst, (sra GR8:$src1, (i8 1)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002267def SAR16r1 : I<0xD1, MRM7r, (outs GR16:$dst), (ins GR16:$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00002268 "sar{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002269 [(set GR16:$dst, (sra GR16:$src1, (i8 1)))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002270def SAR32r1 : I<0xD1, MRM7r, (outs GR32:$dst), (ins GR32:$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00002271 "sar{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002272 [(set GR32:$dst, (sra GR32:$src1, (i8 1)))]>;
2273
2274let isTwoAddress = 0 in {
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002275 let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00002276 def SAR8mCL : I<0xD2, MRM7m, (outs), (ins i8mem :$dst),
Eli Friedman378ea832009-06-19 04:48:38 +00002277 "sar{b}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002278 [(store (sra (loadi8 addr:$dst), CL), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002279 def SAR16mCL : I<0xD3, MRM7m, (outs), (ins i16mem:$dst),
Eli Friedman378ea832009-06-19 04:48:38 +00002280 "sar{w}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002281 [(store (sra (loadi16 addr:$dst), CL), addr:$dst)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002282 def SAR32mCL : I<0xD3, MRM7m, (outs), (ins i32mem:$dst),
Eli Friedman378ea832009-06-19 04:48:38 +00002283 "sar{l}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002284 [(store (sra (loadi32 addr:$dst), CL), addr:$dst)]>;
2285 }
Evan Chengb783fa32007-07-19 01:14:50 +00002286 def SAR8mi : Ii8<0xC0, MRM7m, (outs), (ins i8mem :$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002287 "sar{b}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002288 [(store (sra (loadi8 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002289 def SAR16mi : Ii8<0xC1, MRM7m, (outs), (ins i16mem:$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002290 "sar{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002291 [(store (sra (loadi16 addr:$dst), (i8 imm:$src)), addr:$dst)]>,
2292 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002293 def SAR32mi : Ii8<0xC1, MRM7m, (outs), (ins i32mem:$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002294 "sar{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002295 [(store (sra (loadi32 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
2296
2297 // Shift by 1
Evan Chengb783fa32007-07-19 01:14:50 +00002298 def SAR8m1 : I<0xD0, MRM7m, (outs), (ins i8mem :$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002299 "sar{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002300 [(store (sra (loadi8 addr:$dst), (i8 1)), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002301 def SAR16m1 : I<0xD1, MRM7m, (outs), (ins i16mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002302 "sar{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002303 [(store (sra (loadi16 addr:$dst), (i8 1)), addr:$dst)]>,
2304 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002305 def SAR32m1 : I<0xD1, MRM7m, (outs), (ins i32mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002306 "sar{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002307 [(store (sra (loadi32 addr:$dst), (i8 1)), addr:$dst)]>;
2308}
2309
2310// Rotate instructions
Sean Callanan3c8eecd2009-09-18 19:35:23 +00002311
2312def RCL8r1 : I<0xD0, MRM2r, (outs GR8:$dst), (ins GR8:$src),
2313 "rcl{b}\t{1, $dst|$dst, 1}", []>;
2314def RCL8m1 : I<0xD0, MRM2m, (outs i8mem:$dst), (ins i8mem:$src),
2315 "rcl{b}\t{1, $dst|$dst, 1}", []>;
2316let Uses = [CL] in {
2317def RCL8rCL : I<0xD2, MRM2r, (outs GR8:$dst), (ins GR8:$src),
2318 "rcl{b}\t{%cl, $dst|$dst, CL}", []>;
2319def RCL8mCL : I<0xD2, MRM2m, (outs i8mem:$dst), (ins i8mem:$src),
2320 "rcl{b}\t{%cl, $dst|$dst, CL}", []>;
2321}
2322def RCL8ri : Ii8<0xC0, MRM2r, (outs GR8:$dst), (ins GR8:$src, i8imm:$cnt),
2323 "rcl{b}\t{$cnt, $dst|$dst, $cnt}", []>;
2324def RCL8mi : Ii8<0xC0, MRM2m, (outs i8mem:$dst), (ins i8mem:$src, i8imm:$cnt),
2325 "rcl{b}\t{$cnt, $dst|$dst, $cnt}", []>;
2326
2327def RCL16r1 : I<0xD1, MRM2r, (outs GR16:$dst), (ins GR16:$src),
2328 "rcl{w}\t{1, $dst|$dst, 1}", []>, OpSize;
2329def RCL16m1 : I<0xD1, MRM2m, (outs i16mem:$dst), (ins i16mem:$src),
2330 "rcl{w}\t{1, $dst|$dst, 1}", []>, OpSize;
2331let Uses = [CL] in {
2332def RCL16rCL : I<0xD3, MRM2r, (outs GR16:$dst), (ins GR16:$src),
2333 "rcl{w}\t{%cl, $dst|$dst, CL}", []>, OpSize;
2334def RCL16mCL : I<0xD3, MRM2m, (outs i16mem:$dst), (ins i16mem:$src),
2335 "rcl{w}\t{%cl, $dst|$dst, CL}", []>, OpSize;
2336}
2337def RCL16ri : Ii8<0xC1, MRM2r, (outs GR16:$dst), (ins GR16:$src, i8imm:$cnt),
2338 "rcl{w}\t{$cnt, $dst|$dst, $cnt}", []>, OpSize;
Sean Callanan2c48df22009-12-18 00:01:26 +00002339def RCL16mi : Ii8<0xC1, MRM2m, (outs i16mem:$dst),
2340 (ins i16mem:$src, i8imm:$cnt),
Sean Callanan3c8eecd2009-09-18 19:35:23 +00002341 "rcl{w}\t{$cnt, $dst|$dst, $cnt}", []>, OpSize;
2342
2343def RCL32r1 : I<0xD1, MRM2r, (outs GR32:$dst), (ins GR32:$src),
2344 "rcl{l}\t{1, $dst|$dst, 1}", []>;
2345def RCL32m1 : I<0xD1, MRM2m, (outs i32mem:$dst), (ins i32mem:$src),
2346 "rcl{l}\t{1, $dst|$dst, 1}", []>;
2347let Uses = [CL] in {
2348def RCL32rCL : I<0xD3, MRM2r, (outs GR32:$dst), (ins GR32:$src),
2349 "rcl{l}\t{%cl, $dst|$dst, CL}", []>;
2350def RCL32mCL : I<0xD3, MRM2m, (outs i32mem:$dst), (ins i32mem:$src),
2351 "rcl{l}\t{%cl, $dst|$dst, CL}", []>;
2352}
2353def RCL32ri : Ii8<0xC1, MRM2r, (outs GR32:$dst), (ins GR32:$src, i8imm:$cnt),
2354 "rcl{l}\t{$cnt, $dst|$dst, $cnt}", []>;
Sean Callanan2c48df22009-12-18 00:01:26 +00002355def RCL32mi : Ii8<0xC1, MRM2m, (outs i32mem:$dst),
2356 (ins i32mem:$src, i8imm:$cnt),
Sean Callanan3c8eecd2009-09-18 19:35:23 +00002357 "rcl{l}\t{$cnt, $dst|$dst, $cnt}", []>;
2358
2359def RCR8r1 : I<0xD0, MRM3r, (outs GR8:$dst), (ins GR8:$src),
2360 "rcr{b}\t{1, $dst|$dst, 1}", []>;
2361def RCR8m1 : I<0xD0, MRM3m, (outs i8mem:$dst), (ins i8mem:$src),
2362 "rcr{b}\t{1, $dst|$dst, 1}", []>;
2363let Uses = [CL] in {
2364def RCR8rCL : I<0xD2, MRM3r, (outs GR8:$dst), (ins GR8:$src),
2365 "rcr{b}\t{%cl, $dst|$dst, CL}", []>;
2366def RCR8mCL : I<0xD2, MRM3m, (outs i8mem:$dst), (ins i8mem:$src),
2367 "rcr{b}\t{%cl, $dst|$dst, CL}", []>;
2368}
2369def RCR8ri : Ii8<0xC0, MRM3r, (outs GR8:$dst), (ins GR8:$src, i8imm:$cnt),
2370 "rcr{b}\t{$cnt, $dst|$dst, $cnt}", []>;
2371def RCR8mi : Ii8<0xC0, MRM3m, (outs i8mem:$dst), (ins i8mem:$src, i8imm:$cnt),
2372 "rcr{b}\t{$cnt, $dst|$dst, $cnt}", []>;
2373
2374def RCR16r1 : I<0xD1, MRM3r, (outs GR16:$dst), (ins GR16:$src),
2375 "rcr{w}\t{1, $dst|$dst, 1}", []>, OpSize;
2376def RCR16m1 : I<0xD1, MRM3m, (outs i16mem:$dst), (ins i16mem:$src),
2377 "rcr{w}\t{1, $dst|$dst, 1}", []>, OpSize;
2378let Uses = [CL] in {
2379def RCR16rCL : I<0xD3, MRM3r, (outs GR16:$dst), (ins GR16:$src),
2380 "rcr{w}\t{%cl, $dst|$dst, CL}", []>, OpSize;
2381def RCR16mCL : I<0xD3, MRM3m, (outs i16mem:$dst), (ins i16mem:$src),
2382 "rcr{w}\t{%cl, $dst|$dst, CL}", []>, OpSize;
2383}
2384def RCR16ri : Ii8<0xC1, MRM3r, (outs GR16:$dst), (ins GR16:$src, i8imm:$cnt),
2385 "rcr{w}\t{$cnt, $dst|$dst, $cnt}", []>, OpSize;
Sean Callanan2c48df22009-12-18 00:01:26 +00002386def RCR16mi : Ii8<0xC1, MRM3m, (outs i16mem:$dst),
2387 (ins i16mem:$src, i8imm:$cnt),
Sean Callanan3c8eecd2009-09-18 19:35:23 +00002388 "rcr{w}\t{$cnt, $dst|$dst, $cnt}", []>, OpSize;
2389
2390def RCR32r1 : I<0xD1, MRM3r, (outs GR32:$dst), (ins GR32:$src),
2391 "rcr{l}\t{1, $dst|$dst, 1}", []>;
2392def RCR32m1 : I<0xD1, MRM3m, (outs i32mem:$dst), (ins i32mem:$src),
2393 "rcr{l}\t{1, $dst|$dst, 1}", []>;
2394let Uses = [CL] in {
2395def RCR32rCL : I<0xD3, MRM3r, (outs GR32:$dst), (ins GR32:$src),
2396 "rcr{l}\t{%cl, $dst|$dst, CL}", []>;
2397def RCR32mCL : I<0xD3, MRM3m, (outs i32mem:$dst), (ins i32mem:$src),
2398 "rcr{l}\t{%cl, $dst|$dst, CL}", []>;
2399}
2400def RCR32ri : Ii8<0xC1, MRM3r, (outs GR32:$dst), (ins GR32:$src, i8imm:$cnt),
2401 "rcr{l}\t{$cnt, $dst|$dst, $cnt}", []>;
Sean Callanan2c48df22009-12-18 00:01:26 +00002402def RCR32mi : Ii8<0xC1, MRM3m, (outs i32mem:$dst),
2403 (ins i32mem:$src, i8imm:$cnt),
Sean Callanan3c8eecd2009-09-18 19:35:23 +00002404 "rcr{l}\t{$cnt, $dst|$dst, $cnt}", []>;
2405
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002406// FIXME: provide shorter instructions when imm8 == 1
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002407let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00002408def ROL8rCL : I<0xD2, MRM0r, (outs GR8 :$dst), (ins GR8 :$src),
Eli Friedman378ea832009-06-19 04:48:38 +00002409 "rol{b}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002410 [(set GR8:$dst, (rotl GR8:$src, CL))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002411def ROL16rCL : I<0xD3, MRM0r, (outs GR16:$dst), (ins GR16:$src),
Eli Friedman378ea832009-06-19 04:48:38 +00002412 "rol{w}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002413 [(set GR16:$dst, (rotl GR16:$src, CL))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002414def ROL32rCL : I<0xD3, MRM0r, (outs GR32:$dst), (ins GR32:$src),
Eli Friedman378ea832009-06-19 04:48:38 +00002415 "rol{l}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002416 [(set GR32:$dst, (rotl GR32:$src, CL))]>;
2417}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002418
Evan Chengb783fa32007-07-19 01:14:50 +00002419def ROL8ri : Ii8<0xC0, MRM0r, (outs GR8 :$dst), (ins GR8 :$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002420 "rol{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002421 [(set GR8:$dst, (rotl GR8:$src1, (i8 imm:$src2)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002422def ROL16ri : Ii8<0xC1, MRM0r, (outs GR16:$dst), (ins GR16:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002423 "rol{w}\t{$src2, $dst|$dst, $src2}",
Sean Callanan2c48df22009-12-18 00:01:26 +00002424 [(set GR16:$dst, (rotl GR16:$src1, (i8 imm:$src2)))]>,
2425 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002426def ROL32ri : Ii8<0xC1, MRM0r, (outs GR32:$dst), (ins GR32:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002427 "rol{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002428 [(set GR32:$dst, (rotl GR32:$src1, (i8 imm:$src2)))]>;
2429
2430// Rotate by 1
Evan Chengb783fa32007-07-19 01:14:50 +00002431def ROL8r1 : I<0xD0, MRM0r, (outs GR8 :$dst), (ins GR8 :$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00002432 "rol{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002433 [(set GR8:$dst, (rotl GR8:$src1, (i8 1)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002434def ROL16r1 : I<0xD1, MRM0r, (outs GR16:$dst), (ins GR16:$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00002435 "rol{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002436 [(set GR16:$dst, (rotl GR16:$src1, (i8 1)))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002437def ROL32r1 : I<0xD1, MRM0r, (outs GR32:$dst), (ins GR32:$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00002438 "rol{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002439 [(set GR32:$dst, (rotl GR32:$src1, (i8 1)))]>;
2440
2441let isTwoAddress = 0 in {
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002442 let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00002443 def ROL8mCL : I<0xD2, MRM0m, (outs), (ins i8mem :$dst),
Eli Friedman378ea832009-06-19 04:48:38 +00002444 "rol{b}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002445 [(store (rotl (loadi8 addr:$dst), CL), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002446 def ROL16mCL : I<0xD3, MRM0m, (outs), (ins i16mem:$dst),
Eli Friedman378ea832009-06-19 04:48:38 +00002447 "rol{w}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002448 [(store (rotl (loadi16 addr:$dst), CL), addr:$dst)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002449 def ROL32mCL : I<0xD3, MRM0m, (outs), (ins i32mem:$dst),
Eli Friedman378ea832009-06-19 04:48:38 +00002450 "rol{l}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002451 [(store (rotl (loadi32 addr:$dst), CL), addr:$dst)]>;
2452 }
Evan Chengb783fa32007-07-19 01:14:50 +00002453 def ROL8mi : Ii8<0xC0, MRM0m, (outs), (ins i8mem :$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002454 "rol{b}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002455 [(store (rotl (loadi8 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002456 def ROL16mi : Ii8<0xC1, MRM0m, (outs), (ins i16mem:$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002457 "rol{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002458 [(store (rotl (loadi16 addr:$dst), (i8 imm:$src)), addr:$dst)]>,
2459 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002460 def ROL32mi : Ii8<0xC1, MRM0m, (outs), (ins i32mem:$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002461 "rol{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002462 [(store (rotl (loadi32 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
2463
2464 // Rotate by 1
Evan Chengb783fa32007-07-19 01:14:50 +00002465 def ROL8m1 : I<0xD0, MRM0m, (outs), (ins i8mem :$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002466 "rol{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002467 [(store (rotl (loadi8 addr:$dst), (i8 1)), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002468 def ROL16m1 : I<0xD1, MRM0m, (outs), (ins i16mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002469 "rol{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002470 [(store (rotl (loadi16 addr:$dst), (i8 1)), addr:$dst)]>,
2471 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002472 def ROL32m1 : I<0xD1, MRM0m, (outs), (ins i32mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002473 "rol{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002474 [(store (rotl (loadi32 addr:$dst), (i8 1)), addr:$dst)]>;
2475}
2476
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002477let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00002478def ROR8rCL : I<0xD2, MRM1r, (outs GR8 :$dst), (ins GR8 :$src),
Eli Friedman378ea832009-06-19 04:48:38 +00002479 "ror{b}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002480 [(set GR8:$dst, (rotr GR8:$src, CL))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002481def ROR16rCL : I<0xD3, MRM1r, (outs GR16:$dst), (ins GR16:$src),
Eli Friedman378ea832009-06-19 04:48:38 +00002482 "ror{w}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002483 [(set GR16:$dst, (rotr GR16:$src, CL))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002484def ROR32rCL : I<0xD3, MRM1r, (outs GR32:$dst), (ins GR32:$src),
Eli Friedman378ea832009-06-19 04:48:38 +00002485 "ror{l}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002486 [(set GR32:$dst, (rotr GR32:$src, CL))]>;
2487}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002488
Evan Chengb783fa32007-07-19 01:14:50 +00002489def ROR8ri : Ii8<0xC0, MRM1r, (outs GR8 :$dst), (ins GR8 :$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002490 "ror{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002491 [(set GR8:$dst, (rotr GR8:$src1, (i8 imm:$src2)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002492def ROR16ri : Ii8<0xC1, MRM1r, (outs GR16:$dst), (ins GR16:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002493 "ror{w}\t{$src2, $dst|$dst, $src2}",
Sean Callanan2c48df22009-12-18 00:01:26 +00002494 [(set GR16:$dst, (rotr GR16:$src1, (i8 imm:$src2)))]>,
2495 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002496def ROR32ri : Ii8<0xC1, MRM1r, (outs GR32:$dst), (ins GR32:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002497 "ror{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002498 [(set GR32:$dst, (rotr GR32:$src1, (i8 imm:$src2)))]>;
2499
2500// Rotate by 1
Evan Chengb783fa32007-07-19 01:14:50 +00002501def ROR8r1 : I<0xD0, MRM1r, (outs GR8 :$dst), (ins GR8 :$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00002502 "ror{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002503 [(set GR8:$dst, (rotr GR8:$src1, (i8 1)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002504def ROR16r1 : I<0xD1, MRM1r, (outs GR16:$dst), (ins GR16:$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00002505 "ror{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002506 [(set GR16:$dst, (rotr GR16:$src1, (i8 1)))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002507def ROR32r1 : I<0xD1, MRM1r, (outs GR32:$dst), (ins GR32:$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00002508 "ror{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002509 [(set GR32:$dst, (rotr GR32:$src1, (i8 1)))]>;
2510
2511let isTwoAddress = 0 in {
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002512 let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00002513 def ROR8mCL : I<0xD2, MRM1m, (outs), (ins i8mem :$dst),
Eli Friedman378ea832009-06-19 04:48:38 +00002514 "ror{b}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002515 [(store (rotr (loadi8 addr:$dst), CL), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002516 def ROR16mCL : I<0xD3, MRM1m, (outs), (ins i16mem:$dst),
Eli Friedman378ea832009-06-19 04:48:38 +00002517 "ror{w}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002518 [(store (rotr (loadi16 addr:$dst), CL), addr:$dst)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002519 def ROR32mCL : I<0xD3, MRM1m, (outs), (ins i32mem:$dst),
Eli Friedman378ea832009-06-19 04:48:38 +00002520 "ror{l}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002521 [(store (rotr (loadi32 addr:$dst), CL), addr:$dst)]>;
2522 }
Evan Chengb783fa32007-07-19 01:14:50 +00002523 def ROR8mi : Ii8<0xC0, MRM1m, (outs), (ins i8mem :$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002524 "ror{b}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002525 [(store (rotr (loadi8 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002526 def ROR16mi : Ii8<0xC1, MRM1m, (outs), (ins i16mem:$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002527 "ror{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002528 [(store (rotr (loadi16 addr:$dst), (i8 imm:$src)), addr:$dst)]>,
2529 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002530 def ROR32mi : Ii8<0xC1, MRM1m, (outs), (ins i32mem:$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002531 "ror{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002532 [(store (rotr (loadi32 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
2533
2534 // Rotate by 1
Evan Chengb783fa32007-07-19 01:14:50 +00002535 def ROR8m1 : I<0xD0, MRM1m, (outs), (ins i8mem :$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002536 "ror{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002537 [(store (rotr (loadi8 addr:$dst), (i8 1)), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002538 def ROR16m1 : I<0xD1, MRM1m, (outs), (ins i16mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002539 "ror{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002540 [(store (rotr (loadi16 addr:$dst), (i8 1)), addr:$dst)]>,
2541 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002542 def ROR32m1 : I<0xD1, MRM1m, (outs), (ins i32mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002543 "ror{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002544 [(store (rotr (loadi32 addr:$dst), (i8 1)), addr:$dst)]>;
2545}
2546
2547
2548
2549// Double shift instructions (generalizations of rotate)
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002550let Uses = [CL] in {
Sean Callanan2c48df22009-12-18 00:01:26 +00002551def SHLD32rrCL : I<0xA5, MRMDestReg, (outs GR32:$dst),
2552 (ins GR32:$src1, GR32:$src2),
Eli Friedman378ea832009-06-19 04:48:38 +00002553 "shld{l}\t{%cl, $src2, $dst|$dst, $src2, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002554 [(set GR32:$dst, (X86shld GR32:$src1, GR32:$src2, CL))]>, TB;
Sean Callanan2c48df22009-12-18 00:01:26 +00002555def SHRD32rrCL : I<0xAD, MRMDestReg, (outs GR32:$dst),
2556 (ins GR32:$src1, GR32:$src2),
Eli Friedman378ea832009-06-19 04:48:38 +00002557 "shrd{l}\t{%cl, $src2, $dst|$dst, $src2, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002558 [(set GR32:$dst, (X86shrd GR32:$src1, GR32:$src2, CL))]>, TB;
Sean Callanan2c48df22009-12-18 00:01:26 +00002559def SHLD16rrCL : I<0xA5, MRMDestReg, (outs GR16:$dst),
2560 (ins GR16:$src1, GR16:$src2),
Eli Friedman378ea832009-06-19 04:48:38 +00002561 "shld{w}\t{%cl, $src2, $dst|$dst, $src2, CL}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002562 [(set GR16:$dst, (X86shld GR16:$src1, GR16:$src2, CL))]>,
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002563 TB, OpSize;
Sean Callanan2c48df22009-12-18 00:01:26 +00002564def SHRD16rrCL : I<0xAD, MRMDestReg, (outs GR16:$dst),
2565 (ins GR16:$src1, GR16:$src2),
Eli Friedman378ea832009-06-19 04:48:38 +00002566 "shrd{w}\t{%cl, $src2, $dst|$dst, $src2, CL}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002567 [(set GR16:$dst, (X86shrd GR16:$src1, GR16:$src2, CL))]>,
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002568 TB, OpSize;
2569}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002570
2571let isCommutable = 1 in { // These instructions commute to each other.
2572def SHLD32rri8 : Ii8<0xA4, MRMDestReg,
Sean Callanan2c48df22009-12-18 00:01:26 +00002573 (outs GR32:$dst),
2574 (ins GR32:$src1, GR32:$src2, i8imm:$src3),
Dan Gohman91888f02007-07-31 20:11:57 +00002575 "shld{l}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002576 [(set GR32:$dst, (X86shld GR32:$src1, GR32:$src2,
2577 (i8 imm:$src3)))]>,
2578 TB;
2579def SHRD32rri8 : Ii8<0xAC, MRMDestReg,
Sean Callanan2c48df22009-12-18 00:01:26 +00002580 (outs GR32:$dst),
2581 (ins GR32:$src1, GR32:$src2, i8imm:$src3),
Dan Gohman91888f02007-07-31 20:11:57 +00002582 "shrd{l}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002583 [(set GR32:$dst, (X86shrd GR32:$src1, GR32:$src2,
2584 (i8 imm:$src3)))]>,
2585 TB;
2586def SHLD16rri8 : Ii8<0xA4, MRMDestReg,
Sean Callanan2c48df22009-12-18 00:01:26 +00002587 (outs GR16:$dst),
2588 (ins GR16:$src1, GR16:$src2, i8imm:$src3),
Dan Gohman91888f02007-07-31 20:11:57 +00002589 "shld{w}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002590 [(set GR16:$dst, (X86shld GR16:$src1, GR16:$src2,
2591 (i8 imm:$src3)))]>,
2592 TB, OpSize;
2593def SHRD16rri8 : Ii8<0xAC, MRMDestReg,
Sean Callanan2c48df22009-12-18 00:01:26 +00002594 (outs GR16:$dst),
2595 (ins GR16:$src1, GR16:$src2, i8imm:$src3),
Dan Gohman91888f02007-07-31 20:11:57 +00002596 "shrd{w}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002597 [(set GR16:$dst, (X86shrd GR16:$src1, GR16:$src2,
2598 (i8 imm:$src3)))]>,
2599 TB, OpSize;
2600}
2601
2602let isTwoAddress = 0 in {
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002603 let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00002604 def SHLD32mrCL : I<0xA5, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
Eli Friedman378ea832009-06-19 04:48:38 +00002605 "shld{l}\t{%cl, $src2, $dst|$dst, $src2, CL}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002606 [(store (X86shld (loadi32 addr:$dst), GR32:$src2, CL),
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002607 addr:$dst)]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00002608 def SHRD32mrCL : I<0xAD, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
Eli Friedman378ea832009-06-19 04:48:38 +00002609 "shrd{l}\t{%cl, $src2, $dst|$dst, $src2, CL}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002610 [(store (X86shrd (loadi32 addr:$dst), GR32:$src2, CL),
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002611 addr:$dst)]>, TB;
2612 }
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002613 def SHLD32mri8 : Ii8<0xA4, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00002614 (outs), (ins i32mem:$dst, GR32:$src2, i8imm:$src3),
Dan Gohman91888f02007-07-31 20:11:57 +00002615 "shld{l}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002616 [(store (X86shld (loadi32 addr:$dst), GR32:$src2,
2617 (i8 imm:$src3)), addr:$dst)]>,
2618 TB;
2619 def SHRD32mri8 : Ii8<0xAC, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00002620 (outs), (ins i32mem:$dst, GR32:$src2, i8imm:$src3),
Dan Gohman91888f02007-07-31 20:11:57 +00002621 "shrd{l}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002622 [(store (X86shrd (loadi32 addr:$dst), GR32:$src2,
2623 (i8 imm:$src3)), addr:$dst)]>,
2624 TB;
2625
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002626 let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00002627 def SHLD16mrCL : I<0xA5, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
Eli Friedman378ea832009-06-19 04:48:38 +00002628 "shld{w}\t{%cl, $src2, $dst|$dst, $src2, CL}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002629 [(store (X86shld (loadi16 addr:$dst), GR16:$src2, CL),
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002630 addr:$dst)]>, TB, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002631 def SHRD16mrCL : I<0xAD, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
Eli Friedman378ea832009-06-19 04:48:38 +00002632 "shrd{w}\t{%cl, $src2, $dst|$dst, $src2, CL}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002633 [(store (X86shrd (loadi16 addr:$dst), GR16:$src2, CL),
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002634 addr:$dst)]>, TB, OpSize;
2635 }
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002636 def SHLD16mri8 : Ii8<0xA4, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00002637 (outs), (ins i16mem:$dst, GR16:$src2, i8imm:$src3),
Dan Gohman91888f02007-07-31 20:11:57 +00002638 "shld{w}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002639 [(store (X86shld (loadi16 addr:$dst), GR16:$src2,
2640 (i8 imm:$src3)), addr:$dst)]>,
2641 TB, OpSize;
2642 def SHRD16mri8 : Ii8<0xAC, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00002643 (outs), (ins i16mem:$dst, GR16:$src2, i8imm:$src3),
Dan Gohman91888f02007-07-31 20:11:57 +00002644 "shrd{w}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002645 [(store (X86shrd (loadi16 addr:$dst), GR16:$src2,
2646 (i8 imm:$src3)), addr:$dst)]>,
2647 TB, OpSize;
2648}
Evan Cheng55687072007-09-14 21:48:26 +00002649} // Defs = [EFLAGS]
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002650
2651
2652// Arithmetic.
Evan Cheng55687072007-09-14 21:48:26 +00002653let Defs = [EFLAGS] in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002654let isCommutable = 1 in { // X = ADD Y, Z --> X = ADD Z, Y
Bill Wendlingae034ed2008-12-12 00:56:36 +00002655// Register-Register Addition
2656def ADD8rr : I<0x00, MRMDestReg, (outs GR8 :$dst),
2657 (ins GR8 :$src1, GR8 :$src2),
2658 "add{b}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002659 [(set GR8:$dst, (add GR8:$src1, GR8:$src2)),
Bill Wendlingae034ed2008-12-12 00:56:36 +00002660 (implicit EFLAGS)]>;
2661
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002662let isConvertibleToThreeAddress = 1 in { // Can transform into LEA.
Bill Wendlingae034ed2008-12-12 00:56:36 +00002663// Register-Register Addition
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002664def ADD16rr : I<0x01, MRMDestReg, (outs GR16:$dst),
2665 (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002666 "add{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002667 [(set GR16:$dst, (add GR16:$src1, GR16:$src2)),
2668 (implicit EFLAGS)]>, OpSize;
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002669def ADD32rr : I<0x01, MRMDestReg, (outs GR32:$dst),
2670 (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002671 "add{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002672 [(set GR32:$dst, (add GR32:$src1, GR32:$src2)),
2673 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002674} // end isConvertibleToThreeAddress
2675} // end isCommutable
Bill Wendlingae034ed2008-12-12 00:56:36 +00002676
2677// Register-Memory Addition
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002678def ADD8rm : I<0x02, MRMSrcMem, (outs GR8 :$dst),
2679 (ins GR8 :$src1, i8mem :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002680 "add{b}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002681 [(set GR8:$dst, (add GR8:$src1, (load addr:$src2))),
2682 (implicit EFLAGS)]>;
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002683def ADD16rm : I<0x03, MRMSrcMem, (outs GR16:$dst),
2684 (ins GR16:$src1, i16mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002685 "add{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002686 [(set GR16:$dst, (add GR16:$src1, (load addr:$src2))),
2687 (implicit EFLAGS)]>, OpSize;
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002688def ADD32rm : I<0x03, MRMSrcMem, (outs GR32:$dst),
2689 (ins GR32:$src1, i32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002690 "add{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002691 [(set GR32:$dst, (add GR32:$src1, (load addr:$src2))),
2692 (implicit EFLAGS)]>;
Sean Callanan7e7df0e2009-09-15 20:53:57 +00002693
Sean Callanan84df9312009-09-15 21:43:27 +00002694// Register-Register Addition - Equivalent to the normal rr forms (ADD8rr,
2695// ADD16rr, and ADD32rr), but differently encoded.
Sean Callanan7e7df0e2009-09-15 20:53:57 +00002696def ADD8mrmrr: I<0x02, MRMSrcReg, (outs GR8:$dst), (ins GR8:$src1, GR8:$src2),
2697 "add{b}\t{$src2, $dst|$dst, $src2}", []>;
2698def ADD16mrmrr: I<0x03, MRMSrcReg,(outs GR16:$dst),(ins GR16:$src1, GR16:$src2),
2699 "add{w}\t{$src2, $dst|$dst, $src2}", []>, OpSize;
2700def ADD32mrmrr: I<0x03, MRMSrcReg,(outs GR16:$dst),(ins GR16:$src1, GR16:$src2),
2701 "add{l}\t{$src2, $dst|$dst, $src2}", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002702
Bill Wendlingae034ed2008-12-12 00:56:36 +00002703// Register-Integer Addition
2704def ADD8ri : Ii8<0x80, MRM0r, (outs GR8:$dst), (ins GR8:$src1, i8imm:$src2),
2705 "add{b}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002706 [(set GR8:$dst, (add GR8:$src1, imm:$src2)),
2707 (implicit EFLAGS)]>;
Bill Wendlingae034ed2008-12-12 00:56:36 +00002708
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002709let isConvertibleToThreeAddress = 1 in { // Can transform into LEA.
Bill Wendlingae034ed2008-12-12 00:56:36 +00002710// Register-Integer Addition
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002711def ADD16ri : Ii16<0x81, MRM0r, (outs GR16:$dst),
2712 (ins GR16:$src1, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002713 "add{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002714 [(set GR16:$dst, (add GR16:$src1, imm:$src2)),
2715 (implicit EFLAGS)]>, OpSize;
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002716def ADD32ri : Ii32<0x81, MRM0r, (outs GR32:$dst),
2717 (ins GR32:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002718 "add{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002719 [(set GR32:$dst, (add GR32:$src1, imm:$src2)),
2720 (implicit EFLAGS)]>;
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002721def ADD16ri8 : Ii8<0x83, MRM0r, (outs GR16:$dst),
2722 (ins GR16:$src1, i16i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002723 "add{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002724 [(set GR16:$dst, (add GR16:$src1, i16immSExt8:$src2)),
2725 (implicit EFLAGS)]>, OpSize;
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002726def ADD32ri8 : Ii8<0x83, MRM0r, (outs GR32:$dst),
2727 (ins GR32:$src1, i32i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002728 "add{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002729 [(set GR32:$dst, (add GR32:$src1, i32immSExt8:$src2)),
2730 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002731}
2732
2733let isTwoAddress = 0 in {
Bill Wendlingae034ed2008-12-12 00:56:36 +00002734 // Memory-Register Addition
Bill Wendlingf5399032008-12-12 21:15:41 +00002735 def ADD8mr : I<0x00, MRMDestMem, (outs), (ins i8mem:$dst, GR8:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002736 "add{b}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002737 [(store (add (load addr:$dst), GR8:$src2), addr:$dst),
2738 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002739 def ADD16mr : I<0x01, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002740 "add{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002741 [(store (add (load addr:$dst), GR16:$src2), addr:$dst),
2742 (implicit EFLAGS)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002743 def ADD32mr : I<0x01, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002744 "add{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002745 [(store (add (load addr:$dst), GR32:$src2), addr:$dst),
2746 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002747 def ADD8mi : Ii8<0x80, MRM0m, (outs), (ins i8mem :$dst, i8imm :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002748 "add{b}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002749 [(store (add (loadi8 addr:$dst), imm:$src2), addr:$dst),
2750 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002751 def ADD16mi : Ii16<0x81, MRM0m, (outs), (ins i16mem:$dst, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002752 "add{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002753 [(store (add (loadi16 addr:$dst), imm:$src2), addr:$dst),
2754 (implicit EFLAGS)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002755 def ADD32mi : Ii32<0x81, MRM0m, (outs), (ins i32mem:$dst, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002756 "add{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002757 [(store (add (loadi32 addr:$dst), imm:$src2), addr:$dst),
2758 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002759 def ADD16mi8 : Ii8<0x83, MRM0m, (outs), (ins i16mem:$dst, i16i8imm :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002760 "add{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002761 [(store (add (load addr:$dst), i16immSExt8:$src2),
2762 addr:$dst),
2763 (implicit EFLAGS)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002764 def ADD32mi8 : Ii8<0x83, MRM0m, (outs), (ins i32mem:$dst, i32i8imm :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002765 "add{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingae034ed2008-12-12 00:56:36 +00002766 [(store (add (load addr:$dst), i32immSExt8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00002767 addr:$dst),
2768 (implicit EFLAGS)]>;
Sean Callanan0316b342009-08-11 21:26:06 +00002769
2770 // addition to rAX
2771 def ADD8i8 : Ii8<0x04, RawFrm, (outs), (ins i8imm:$src),
Sean Callanan251676e2009-09-02 00:55:49 +00002772 "add{b}\t{$src, %al|%al, $src}", []>;
Sean Callanan0316b342009-08-11 21:26:06 +00002773 def ADD16i16 : Ii16<0x05, RawFrm, (outs), (ins i16imm:$src),
Sean Callanan251676e2009-09-02 00:55:49 +00002774 "add{w}\t{$src, %ax|%ax, $src}", []>, OpSize;
Sean Callanan0316b342009-08-11 21:26:06 +00002775 def ADD32i32 : Ii32<0x05, RawFrm, (outs), (ins i32imm:$src),
Sean Callanan251676e2009-09-02 00:55:49 +00002776 "add{l}\t{$src, %eax|%eax, $src}", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002777}
2778
Evan Cheng259471d2007-10-05 17:59:57 +00002779let Uses = [EFLAGS] in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002780let isCommutable = 1 in { // X = ADC Y, Z --> X = ADC Z, Y
Dale Johannesen747fe522009-06-02 03:12:52 +00002781def ADC8rr : I<0x10, MRMDestReg, (outs GR8:$dst), (ins GR8:$src1, GR8:$src2),
Dale Johannesen06b83f12009-05-18 17:44:15 +00002782 "adc{b}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002783 [(set GR8:$dst, (adde GR8:$src1, GR8:$src2))]>;
Dale Johannesen06b83f12009-05-18 17:44:15 +00002784def ADC16rr : I<0x11, MRMDestReg, (outs GR16:$dst),
2785 (ins GR16:$src1, GR16:$src2),
2786 "adc{w}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002787 [(set GR16:$dst, (adde GR16:$src1, GR16:$src2))]>, OpSize;
Dale Johannesen06b83f12009-05-18 17:44:15 +00002788def ADC32rr : I<0x11, MRMDestReg, (outs GR32:$dst),
2789 (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002790 "adc{l}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002791 [(set GR32:$dst, (adde GR32:$src1, GR32:$src2))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002792}
Sean Callanan2c48df22009-12-18 00:01:26 +00002793
2794def ADC8rr_REV : I<0x12, MRMSrcReg, (outs GR8:$dst), (ins GR8:$src1, GR8:$src2),
2795 "adc{b}\t{$src2, $dst|$dst, $src2}", []>;
2796def ADC16rr_REV : I<0x13, MRMSrcReg, (outs GR16:$dst),
2797 (ins GR16:$src1, GR16:$src2),
2798 "adc{w}\t{$src2, $dst|$dst, $src2}", []>, OpSize;
2799def ADC32rr_REV : I<0x13, MRMSrcReg, (outs GR32:$dst),
2800 (ins GR32:$src1, GR32:$src2),
2801 "adc{l}\t{$src2, $dst|$dst, $src2}", []>;
2802
Dale Johannesen06b83f12009-05-18 17:44:15 +00002803def ADC8rm : I<0x12, MRMSrcMem , (outs GR8:$dst),
2804 (ins GR8:$src1, i8mem:$src2),
2805 "adc{b}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002806 [(set GR8:$dst, (adde GR8:$src1, (load addr:$src2)))]>;
Dale Johannesen06b83f12009-05-18 17:44:15 +00002807def ADC16rm : I<0x13, MRMSrcMem , (outs GR16:$dst),
2808 (ins GR16:$src1, i16mem:$src2),
2809 "adc{w}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002810 [(set GR16:$dst, (adde GR16:$src1, (load addr:$src2)))]>,
Dale Johannesen067cfb22009-05-18 21:41:59 +00002811 OpSize;
Dale Johannesen06b83f12009-05-18 17:44:15 +00002812def ADC32rm : I<0x13, MRMSrcMem , (outs GR32:$dst),
2813 (ins GR32:$src1, i32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002814 "adc{l}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002815 [(set GR32:$dst, (adde GR32:$src1, (load addr:$src2)))]>;
2816def ADC8ri : Ii8<0x80, MRM2r, (outs GR8:$dst), (ins GR8:$src1, i8imm:$src2),
Dale Johannesen06b83f12009-05-18 17:44:15 +00002817 "adc{b}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002818 [(set GR8:$dst, (adde GR8:$src1, imm:$src2))]>;
Dale Johannesen06b83f12009-05-18 17:44:15 +00002819def ADC16ri : Ii16<0x81, MRM2r, (outs GR16:$dst),
2820 (ins GR16:$src1, i16imm:$src2),
2821 "adc{w}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002822 [(set GR16:$dst, (adde GR16:$src1, imm:$src2))]>, OpSize;
Dale Johannesen06b83f12009-05-18 17:44:15 +00002823def ADC16ri8 : Ii8<0x83, MRM2r, (outs GR16:$dst),
2824 (ins GR16:$src1, i16i8imm:$src2),
2825 "adc{w}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002826 [(set GR16:$dst, (adde GR16:$src1, i16immSExt8:$src2))]>,
2827 OpSize;
Dale Johannesen06b83f12009-05-18 17:44:15 +00002828def ADC32ri : Ii32<0x81, MRM2r, (outs GR32:$dst),
2829 (ins GR32:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002830 "adc{l}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002831 [(set GR32:$dst, (adde GR32:$src1, imm:$src2))]>;
Dale Johannesen06b83f12009-05-18 17:44:15 +00002832def ADC32ri8 : Ii8<0x83, MRM2r, (outs GR32:$dst),
2833 (ins GR32:$src1, i32i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002834 "adc{l}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002835 [(set GR32:$dst, (adde GR32:$src1, i32immSExt8:$src2))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002836
2837let isTwoAddress = 0 in {
Dale Johannesen747fe522009-06-02 03:12:52 +00002838 def ADC8mr : I<0x10, MRMDestMem, (outs), (ins i8mem:$dst, GR8:$src2),
Dale Johannesen06b83f12009-05-18 17:44:15 +00002839 "adc{b}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002840 [(store (adde (load addr:$dst), GR8:$src2), addr:$dst)]>;
2841 def ADC16mr : I<0x11, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
Dale Johannesen06b83f12009-05-18 17:44:15 +00002842 "adc{w}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002843 [(store (adde (load addr:$dst), GR16:$src2), addr:$dst)]>,
2844 OpSize;
2845 def ADC32mr : I<0x11, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002846 "adc{l}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002847 [(store (adde (load addr:$dst), GR32:$src2), addr:$dst)]>;
2848 def ADC8mi : Ii8<0x80, MRM2m, (outs), (ins i8mem:$dst, i8imm:$src2),
Dale Johannesen06b83f12009-05-18 17:44:15 +00002849 "adc{b}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002850 [(store (adde (loadi8 addr:$dst), imm:$src2), addr:$dst)]>;
2851 def ADC16mi : Ii16<0x81, MRM2m, (outs), (ins i16mem:$dst, i16imm:$src2),
Dale Johannesen06b83f12009-05-18 17:44:15 +00002852 "adc{w}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002853 [(store (adde (loadi16 addr:$dst), imm:$src2), addr:$dst)]>,
2854 OpSize;
2855 def ADC16mi8 : Ii8<0x83, MRM2m, (outs), (ins i16mem:$dst, i16i8imm :$src2),
Dale Johannesen06b83f12009-05-18 17:44:15 +00002856 "adc{w}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002857 [(store (adde (load addr:$dst), i16immSExt8:$src2), addr:$dst)]>,
2858 OpSize;
2859 def ADC32mi : Ii32<0x81, MRM2m, (outs), (ins i32mem:$dst, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002860 "adc{l}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002861 [(store (adde (loadi32 addr:$dst), imm:$src2), addr:$dst)]>;
2862 def ADC32mi8 : Ii8<0x83, MRM2m, (outs), (ins i32mem:$dst, i32i8imm :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002863 "adc{l}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002864 [(store (adde (load addr:$dst), i32immSExt8:$src2), addr:$dst)]>;
Sean Callanan8562bef2009-09-11 19:01:56 +00002865
2866 def ADC8i8 : Ii8<0x14, RawFrm, (outs), (ins i8imm:$src),
2867 "adc{b}\t{$src, %al|%al, $src}", []>;
2868 def ADC16i16 : Ii16<0x15, RawFrm, (outs), (ins i16imm:$src),
2869 "adc{w}\t{$src, %ax|%ax, $src}", []>, OpSize;
2870 def ADC32i32 : Ii32<0x15, RawFrm, (outs), (ins i32imm:$src),
2871 "adc{l}\t{$src, %eax|%eax, $src}", []>;
Dale Johannesen747fe522009-06-02 03:12:52 +00002872}
Evan Cheng259471d2007-10-05 17:59:57 +00002873} // Uses = [EFLAGS]
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002874
Bill Wendlingae034ed2008-12-12 00:56:36 +00002875// Register-Register Subtraction
2876def SUB8rr : I<0x28, MRMDestReg, (outs GR8:$dst), (ins GR8:$src1, GR8:$src2),
2877 "sub{b}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002878 [(set GR8:$dst, (sub GR8:$src1, GR8:$src2)),
2879 (implicit EFLAGS)]>;
Bill Wendlingae034ed2008-12-12 00:56:36 +00002880def SUB16rr : I<0x29, MRMDestReg, (outs GR16:$dst), (ins GR16:$src1,GR16:$src2),
2881 "sub{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002882 [(set GR16:$dst, (sub GR16:$src1, GR16:$src2)),
2883 (implicit EFLAGS)]>, OpSize;
Bill Wendlingae034ed2008-12-12 00:56:36 +00002884def SUB32rr : I<0x29, MRMDestReg, (outs GR32:$dst), (ins GR32:$src1,GR32:$src2),
2885 "sub{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002886 [(set GR32:$dst, (sub GR32:$src1, GR32:$src2)),
2887 (implicit EFLAGS)]>;
Bill Wendlingae034ed2008-12-12 00:56:36 +00002888
Sean Callanan2c48df22009-12-18 00:01:26 +00002889def SUB8rr_REV : I<0x2A, MRMSrcReg, (outs GR8:$dst), (ins GR8:$src1, GR8:$src2),
2890 "sub{b}\t{$src2, $dst|$dst, $src2}", []>;
2891def SUB16rr_REV : I<0x2B, MRMSrcReg, (outs GR16:$dst),
2892 (ins GR16:$src1, GR16:$src2),
2893 "sub{w}\t{$src2, $dst|$dst, $src2}", []>, OpSize;
2894def SUB32rr_REV : I<0x2B, MRMSrcReg, (outs GR32:$dst),
2895 (ins GR32:$src1, GR32:$src2),
2896 "sub{l}\t{$src2, $dst|$dst, $src2}", []>;
2897
Bill Wendlingae034ed2008-12-12 00:56:36 +00002898// Register-Memory Subtraction
2899def SUB8rm : I<0x2A, MRMSrcMem, (outs GR8 :$dst),
2900 (ins GR8 :$src1, i8mem :$src2),
2901 "sub{b}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002902 [(set GR8:$dst, (sub GR8:$src1, (load addr:$src2))),
2903 (implicit EFLAGS)]>;
Bill Wendlingae034ed2008-12-12 00:56:36 +00002904def SUB16rm : I<0x2B, MRMSrcMem, (outs GR16:$dst),
2905 (ins GR16:$src1, i16mem:$src2),
2906 "sub{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002907 [(set GR16:$dst, (sub GR16:$src1, (load addr:$src2))),
2908 (implicit EFLAGS)]>, OpSize;
Bill Wendlingae034ed2008-12-12 00:56:36 +00002909def SUB32rm : I<0x2B, MRMSrcMem, (outs GR32:$dst),
2910 (ins GR32:$src1, i32mem:$src2),
2911 "sub{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002912 [(set GR32:$dst, (sub GR32:$src1, (load addr:$src2))),
2913 (implicit EFLAGS)]>;
Bill Wendlingae034ed2008-12-12 00:56:36 +00002914
2915// Register-Integer Subtraction
2916def SUB8ri : Ii8 <0x80, MRM5r, (outs GR8:$dst),
2917 (ins GR8:$src1, i8imm:$src2),
2918 "sub{b}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002919 [(set GR8:$dst, (sub GR8:$src1, imm:$src2)),
2920 (implicit EFLAGS)]>;
Bill Wendlingae034ed2008-12-12 00:56:36 +00002921def SUB16ri : Ii16<0x81, MRM5r, (outs GR16:$dst),
2922 (ins GR16:$src1, i16imm:$src2),
2923 "sub{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002924 [(set GR16:$dst, (sub GR16:$src1, imm:$src2)),
2925 (implicit EFLAGS)]>, OpSize;
Bill Wendlingae034ed2008-12-12 00:56:36 +00002926def SUB32ri : Ii32<0x81, MRM5r, (outs GR32:$dst),
2927 (ins GR32:$src1, i32imm:$src2),
2928 "sub{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002929 [(set GR32:$dst, (sub GR32:$src1, imm:$src2)),
2930 (implicit EFLAGS)]>;
Bill Wendlingae034ed2008-12-12 00:56:36 +00002931def SUB16ri8 : Ii8<0x83, MRM5r, (outs GR16:$dst),
2932 (ins GR16:$src1, i16i8imm:$src2),
2933 "sub{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002934 [(set GR16:$dst, (sub GR16:$src1, i16immSExt8:$src2)),
2935 (implicit EFLAGS)]>, OpSize;
Bill Wendlingae034ed2008-12-12 00:56:36 +00002936def SUB32ri8 : Ii8<0x83, MRM5r, (outs GR32:$dst),
2937 (ins GR32:$src1, i32i8imm:$src2),
2938 "sub{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002939 [(set GR32:$dst, (sub GR32:$src1, i32immSExt8:$src2)),
2940 (implicit EFLAGS)]>;
Bill Wendlingae034ed2008-12-12 00:56:36 +00002941
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002942let isTwoAddress = 0 in {
Bill Wendlingae034ed2008-12-12 00:56:36 +00002943 // Memory-Register Subtraction
Evan Chengb783fa32007-07-19 01:14:50 +00002944 def SUB8mr : I<0x28, MRMDestMem, (outs), (ins i8mem :$dst, GR8 :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002945 "sub{b}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002946 [(store (sub (load addr:$dst), GR8:$src2), addr:$dst),
2947 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002948 def SUB16mr : I<0x29, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002949 "sub{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002950 [(store (sub (load addr:$dst), GR16:$src2), addr:$dst),
2951 (implicit EFLAGS)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002952 def SUB32mr : I<0x29, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002953 "sub{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002954 [(store (sub (load addr:$dst), GR32:$src2), addr:$dst),
2955 (implicit EFLAGS)]>;
Bill Wendlingae034ed2008-12-12 00:56:36 +00002956
2957 // Memory-Integer Subtraction
Evan Chengb783fa32007-07-19 01:14:50 +00002958 def SUB8mi : Ii8<0x80, MRM5m, (outs), (ins i8mem :$dst, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002959 "sub{b}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002960 [(store (sub (loadi8 addr:$dst), imm:$src2), addr:$dst),
2961 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002962 def SUB16mi : Ii16<0x81, MRM5m, (outs), (ins i16mem:$dst, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002963 "sub{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002964 [(store (sub (loadi16 addr:$dst), imm:$src2),addr:$dst),
2965 (implicit EFLAGS)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002966 def SUB32mi : Ii32<0x81, MRM5m, (outs), (ins i32mem:$dst, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002967 "sub{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002968 [(store (sub (loadi32 addr:$dst), imm:$src2),addr:$dst),
2969 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002970 def SUB16mi8 : Ii8<0x83, MRM5m, (outs), (ins i16mem:$dst, i16i8imm :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002971 "sub{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingae034ed2008-12-12 00:56:36 +00002972 [(store (sub (load addr:$dst), i16immSExt8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00002973 addr:$dst),
2974 (implicit EFLAGS)]>, OpSize;
Bill Wendlingae034ed2008-12-12 00:56:36 +00002975 def SUB32mi8 : Ii8<0x83, MRM5m, (outs), (ins i32mem:$dst, i32i8imm :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002976 "sub{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingae034ed2008-12-12 00:56:36 +00002977 [(store (sub (load addr:$dst), i32immSExt8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00002978 addr:$dst),
2979 (implicit EFLAGS)]>;
Sean Callanan8562bef2009-09-11 19:01:56 +00002980
2981 def SUB8i8 : Ii8<0x2C, RawFrm, (outs), (ins i8imm:$src),
2982 "sub{b}\t{$src, %al|%al, $src}", []>;
2983 def SUB16i16 : Ii16<0x2D, RawFrm, (outs), (ins i16imm:$src),
2984 "sub{w}\t{$src, %ax|%ax, $src}", []>, OpSize;
2985 def SUB32i32 : Ii32<0x2D, RawFrm, (outs), (ins i32imm:$src),
2986 "sub{l}\t{$src, %eax|%eax, $src}", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002987}
2988
Evan Cheng259471d2007-10-05 17:59:57 +00002989let Uses = [EFLAGS] in {
Dale Johannesen06b83f12009-05-18 17:44:15 +00002990def SBB8rr : I<0x18, MRMDestReg, (outs GR8:$dst),
2991 (ins GR8:$src1, GR8:$src2),
2992 "sbb{b}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002993 [(set GR8:$dst, (sube GR8:$src1, GR8:$src2))]>;
Dale Johannesen06b83f12009-05-18 17:44:15 +00002994def SBB16rr : I<0x19, MRMDestReg, (outs GR16:$dst),
2995 (ins GR16:$src1, GR16:$src2),
2996 "sbb{w}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002997 [(set GR16:$dst, (sube GR16:$src1, GR16:$src2))]>, OpSize;
Dale Johannesen06b83f12009-05-18 17:44:15 +00002998def SBB32rr : I<0x19, MRMDestReg, (outs GR32:$dst),
2999 (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00003000 "sbb{l}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00003001 [(set GR32:$dst, (sube GR32:$src1, GR32:$src2))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003002
3003let isTwoAddress = 0 in {
Dale Johannesen06b83f12009-05-18 17:44:15 +00003004 def SBB8mr : I<0x18, MRMDestMem, (outs), (ins i8mem:$dst, GR8:$src2),
3005 "sbb{b}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00003006 [(store (sube (load addr:$dst), GR8:$src2), addr:$dst)]>;
Dale Johannesen06b83f12009-05-18 17:44:15 +00003007 def SBB16mr : I<0x19, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
3008 "sbb{w}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00003009 [(store (sube (load addr:$dst), GR16:$src2), addr:$dst)]>,
Dale Johannesen067cfb22009-05-18 21:41:59 +00003010 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00003011 def SBB32mr : I<0x19, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00003012 "sbb{l}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00003013 [(store (sube (load addr:$dst), GR32:$src2), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00003014 def SBB8mi : Ii32<0x80, MRM3m, (outs), (ins i8mem:$dst, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00003015 "sbb{b}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00003016 [(store (sube (loadi8 addr:$dst), imm:$src2), addr:$dst)]>;
Dale Johannesen06b83f12009-05-18 17:44:15 +00003017 def SBB16mi : Ii16<0x81, MRM3m, (outs), (ins i16mem:$dst, i16imm:$src2),
3018 "sbb{w}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00003019 [(store (sube (loadi16 addr:$dst), imm:$src2), addr:$dst)]>,
Dale Johannesen067cfb22009-05-18 21:41:59 +00003020 OpSize;
Dale Johannesen06b83f12009-05-18 17:44:15 +00003021 def SBB16mi8 : Ii8<0x83, MRM3m, (outs), (ins i16mem:$dst, i16i8imm :$src2),
3022 "sbb{w}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00003023 [(store (sube (load addr:$dst), i16immSExt8:$src2), addr:$dst)]>,
Dale Johannesen067cfb22009-05-18 21:41:59 +00003024 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00003025 def SBB32mi : Ii32<0x81, MRM3m, (outs), (ins i32mem:$dst, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00003026 "sbb{l}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00003027 [(store (sube (loadi32 addr:$dst), imm:$src2), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00003028 def SBB32mi8 : Ii8<0x83, MRM3m, (outs), (ins i32mem:$dst, i32i8imm :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00003029 "sbb{l}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00003030 [(store (sube (load addr:$dst), i32immSExt8:$src2), addr:$dst)]>;
Sean Callanan8562bef2009-09-11 19:01:56 +00003031
3032 def SBB8i8 : Ii8<0x1C, RawFrm, (outs), (ins i8imm:$src),
3033 "sbb{b}\t{$src, %al|%al, $src}", []>;
3034 def SBB16i16 : Ii16<0x1D, RawFrm, (outs), (ins i16imm:$src),
3035 "sbb{w}\t{$src, %ax|%ax, $src}", []>, OpSize;
3036 def SBB32i32 : Ii32<0x1D, RawFrm, (outs), (ins i32imm:$src),
3037 "sbb{l}\t{$src, %eax|%eax, $src}", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003038}
Sean Callanan2c48df22009-12-18 00:01:26 +00003039
3040def SBB8rr_REV : I<0x1A, MRMSrcReg, (outs GR8:$dst), (ins GR8:$src1, GR8:$src2),
3041 "sbb{b}\t{$src2, $dst|$dst, $src2}", []>;
3042def SBB16rr_REV : I<0x1B, MRMSrcReg, (outs GR16:$dst),
3043 (ins GR16:$src1, GR16:$src2),
3044 "sbb{w}\t{$src2, $dst|$dst, $src2}", []>, OpSize;
3045def SBB32rr_REV : I<0x1B, MRMSrcReg, (outs GR32:$dst),
3046 (ins GR32:$src1, GR32:$src2),
3047 "sbb{l}\t{$src2, $dst|$dst, $src2}", []>;
3048
Dale Johannesen06b83f12009-05-18 17:44:15 +00003049def SBB8rm : I<0x1A, MRMSrcMem, (outs GR8:$dst), (ins GR8:$src1, i8mem:$src2),
3050 "sbb{b}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00003051 [(set GR8:$dst, (sube GR8:$src1, (load addr:$src2)))]>;
Dale Johannesen06b83f12009-05-18 17:44:15 +00003052def SBB16rm : I<0x1B, MRMSrcMem, (outs GR16:$dst),
3053 (ins GR16:$src1, i16mem:$src2),
3054 "sbb{w}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00003055 [(set GR16:$dst, (sube GR16:$src1, (load addr:$src2)))]>,
Dale Johannesen067cfb22009-05-18 21:41:59 +00003056 OpSize;
Dale Johannesen06b83f12009-05-18 17:44:15 +00003057def SBB32rm : I<0x1B, MRMSrcMem, (outs GR32:$dst),
3058 (ins GR32:$src1, i32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00003059 "sbb{l}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00003060 [(set GR32:$dst, (sube GR32:$src1, (load addr:$src2)))]>;
Dale Johannesen06b83f12009-05-18 17:44:15 +00003061def SBB8ri : Ii8<0x80, MRM3r, (outs GR8:$dst), (ins GR8:$src1, i8imm:$src2),
3062 "sbb{b}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00003063 [(set GR8:$dst, (sube GR8:$src1, imm:$src2))]>;
Dale Johannesen06b83f12009-05-18 17:44:15 +00003064def SBB16ri : Ii16<0x81, MRM3r, (outs GR16:$dst),
3065 (ins GR16:$src1, i16imm:$src2),
3066 "sbb{w}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00003067 [(set GR16:$dst, (sube GR16:$src1, imm:$src2))]>, OpSize;
Dale Johannesen06b83f12009-05-18 17:44:15 +00003068def SBB16ri8 : Ii8<0x83, MRM3r, (outs GR16:$dst),
3069 (ins GR16:$src1, i16i8imm:$src2),
3070 "sbb{w}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00003071 [(set GR16:$dst, (sube GR16:$src1, i16immSExt8:$src2))]>,
3072 OpSize;
Dale Johannesen06b83f12009-05-18 17:44:15 +00003073def SBB32ri : Ii32<0x81, MRM3r, (outs GR32:$dst),
3074 (ins GR32:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00003075 "sbb{l}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00003076 [(set GR32:$dst, (sube GR32:$src1, imm:$src2))]>;
Dale Johannesen06b83f12009-05-18 17:44:15 +00003077def SBB32ri8 : Ii8<0x83, MRM3r, (outs GR32:$dst),
3078 (ins GR32:$src1, i32i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00003079 "sbb{l}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00003080 [(set GR32:$dst, (sube GR32:$src1, i32immSExt8:$src2))]>;
Evan Cheng259471d2007-10-05 17:59:57 +00003081} // Uses = [EFLAGS]
Evan Cheng55687072007-09-14 21:48:26 +00003082} // Defs = [EFLAGS]
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003083
Evan Cheng55687072007-09-14 21:48:26 +00003084let Defs = [EFLAGS] in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003085let isCommutable = 1 in { // X = IMUL Y, Z --> X = IMUL Z, Y
Bill Wendlingf5399032008-12-12 21:15:41 +00003086// Register-Register Signed Integer Multiply
Bill Wendlingae034ed2008-12-12 00:56:36 +00003087def IMUL16rr : I<0xAF, MRMSrcReg, (outs GR16:$dst), (ins GR16:$src1,GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00003088 "imul{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00003089 [(set GR16:$dst, (mul GR16:$src1, GR16:$src2)),
3090 (implicit EFLAGS)]>, TB, OpSize;
Bill Wendlingae034ed2008-12-12 00:56:36 +00003091def IMUL32rr : I<0xAF, MRMSrcReg, (outs GR32:$dst), (ins GR32:$src1,GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00003092 "imul{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00003093 [(set GR32:$dst, (mul GR32:$src1, GR32:$src2)),
3094 (implicit EFLAGS)]>, TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003095}
Bill Wendlingae034ed2008-12-12 00:56:36 +00003096
Bill Wendlingf5399032008-12-12 21:15:41 +00003097// Register-Memory Signed Integer Multiply
Bill Wendlingae034ed2008-12-12 00:56:36 +00003098def IMUL16rm : I<0xAF, MRMSrcMem, (outs GR16:$dst),
3099 (ins GR16:$src1, i16mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00003100 "imul{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00003101 [(set GR16:$dst, (mul GR16:$src1, (load addr:$src2))),
3102 (implicit EFLAGS)]>, TB, OpSize;
Sean Callanan2c48df22009-12-18 00:01:26 +00003103def IMUL32rm : I<0xAF, MRMSrcMem, (outs GR32:$dst),
3104 (ins GR32:$src1, i32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00003105 "imul{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00003106 [(set GR32:$dst, (mul GR32:$src1, (load addr:$src2))),
3107 (implicit EFLAGS)]>, TB;
Evan Cheng55687072007-09-14 21:48:26 +00003108} // Defs = [EFLAGS]
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003109} // end Two Address instructions
3110
3111// Suprisingly enough, these are not two address instructions!
Evan Cheng55687072007-09-14 21:48:26 +00003112let Defs = [EFLAGS] in {
Bill Wendlingf5399032008-12-12 21:15:41 +00003113// Register-Integer Signed Integer Multiply
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003114def IMUL16rri : Ii16<0x69, MRMSrcReg, // GR16 = GR16*I16
Evan Chengb783fa32007-07-19 01:14:50 +00003115 (outs GR16:$dst), (ins GR16:$src1, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00003116 "imul{w}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00003117 [(set GR16:$dst, (mul GR16:$src1, imm:$src2)),
3118 (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003119def IMUL32rri : Ii32<0x69, MRMSrcReg, // GR32 = GR32*I32
Evan Chengb783fa32007-07-19 01:14:50 +00003120 (outs GR32:$dst), (ins GR32:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00003121 "imul{l}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00003122 [(set GR32:$dst, (mul GR32:$src1, imm:$src2)),
3123 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003124def IMUL16rri8 : Ii8<0x6B, MRMSrcReg, // GR16 = GR16*I8
Evan Chengb783fa32007-07-19 01:14:50 +00003125 (outs GR16:$dst), (ins GR16:$src1, i16i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00003126 "imul{w}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00003127 [(set GR16:$dst, (mul GR16:$src1, i16immSExt8:$src2)),
3128 (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003129def IMUL32rri8 : Ii8<0x6B, MRMSrcReg, // GR32 = GR32*I8
Evan Chengb783fa32007-07-19 01:14:50 +00003130 (outs GR32:$dst), (ins GR32:$src1, i32i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00003131 "imul{l}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00003132 [(set GR32:$dst, (mul GR32:$src1, i32immSExt8:$src2)),
3133 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003134
Bill Wendlingf5399032008-12-12 21:15:41 +00003135// Memory-Integer Signed Integer Multiply
Sean Callanan2c48df22009-12-18 00:01:26 +00003136def IMUL16rmi : Ii16<0x69, MRMSrcMem, // GR16 = [mem16]*I16
Evan Chengb783fa32007-07-19 01:14:50 +00003137 (outs GR16:$dst), (ins i16mem:$src1, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00003138 "imul{w}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00003139 [(set GR16:$dst, (mul (load addr:$src1), imm:$src2)),
3140 (implicit EFLAGS)]>, OpSize;
Sean Callanan2c48df22009-12-18 00:01:26 +00003141def IMUL32rmi : Ii32<0x69, MRMSrcMem, // GR32 = [mem32]*I32
Evan Chengb783fa32007-07-19 01:14:50 +00003142 (outs GR32:$dst), (ins i32mem:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00003143 "imul{l}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00003144 [(set GR32:$dst, (mul (load addr:$src1), imm:$src2)),
3145 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003146def IMUL16rmi8 : Ii8<0x6B, MRMSrcMem, // GR16 = [mem16]*I8
Evan Chengb783fa32007-07-19 01:14:50 +00003147 (outs GR16:$dst), (ins i16mem:$src1, i16i8imm :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00003148 "imul{w}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Bill Wendlingae034ed2008-12-12 00:56:36 +00003149 [(set GR16:$dst, (mul (load addr:$src1),
Bill Wendlingf5399032008-12-12 21:15:41 +00003150 i16immSExt8:$src2)),
3151 (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003152def IMUL32rmi8 : Ii8<0x6B, MRMSrcMem, // GR32 = [mem32]*I8
Evan Chengb783fa32007-07-19 01:14:50 +00003153 (outs GR32:$dst), (ins i32mem:$src1, i32i8imm: $src2),
Dan Gohman91888f02007-07-31 20:11:57 +00003154 "imul{l}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Bill Wendlingae034ed2008-12-12 00:56:36 +00003155 [(set GR32:$dst, (mul (load addr:$src1),
Bill Wendlingf5399032008-12-12 21:15:41 +00003156 i32immSExt8:$src2)),
3157 (implicit EFLAGS)]>;
Evan Cheng55687072007-09-14 21:48:26 +00003158} // Defs = [EFLAGS]
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003159
3160//===----------------------------------------------------------------------===//
3161// Test instructions are just like AND, except they don't generate a result.
3162//
Evan Cheng950aac02007-09-25 01:57:46 +00003163let Defs = [EFLAGS] in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003164let isCommutable = 1 in { // TEST X, Y --> TEST Y, X
Evan Chengb783fa32007-07-19 01:14:50 +00003165def TEST8rr : I<0x84, MRMDestReg, (outs), (ins GR8:$src1, GR8:$src2),
Evan Cheng621216e2007-09-29 00:00:36 +00003166 "test{b}\t{$src2, $src1|$src1, $src2}",
Chris Lattner21da6382008-02-19 17:37:35 +00003167 [(X86cmp (and_su GR8:$src1, GR8:$src2), 0),
Evan Cheng621216e2007-09-29 00:00:36 +00003168 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00003169def TEST16rr : I<0x85, MRMDestReg, (outs), (ins GR16:$src1, GR16:$src2),
Evan Cheng621216e2007-09-29 00:00:36 +00003170 "test{w}\t{$src2, $src1|$src1, $src2}",
Chris Lattner21da6382008-02-19 17:37:35 +00003171 [(X86cmp (and_su GR16:$src1, GR16:$src2), 0),
Evan Cheng621216e2007-09-29 00:00:36 +00003172 (implicit EFLAGS)]>,
3173 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00003174def TEST32rr : I<0x85, MRMDestReg, (outs), (ins GR32:$src1, GR32:$src2),
Evan Cheng621216e2007-09-29 00:00:36 +00003175 "test{l}\t{$src2, $src1|$src1, $src2}",
Chris Lattner21da6382008-02-19 17:37:35 +00003176 [(X86cmp (and_su GR32:$src1, GR32:$src2), 0),
Evan Cheng621216e2007-09-29 00:00:36 +00003177 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003178}
3179
Sean Callanan3e4b1a32009-09-01 18:14:18 +00003180def TEST8i8 : Ii8<0xA8, RawFrm, (outs), (ins i8imm:$src),
3181 "test{b}\t{$src, %al|%al, $src}", []>;
3182def TEST16i16 : Ii16<0xA9, RawFrm, (outs), (ins i16imm:$src),
3183 "test{w}\t{$src, %ax|%ax, $src}", []>, OpSize;
3184def TEST32i32 : Ii32<0xA9, RawFrm, (outs), (ins i32imm:$src),
3185 "test{l}\t{$src, %eax|%eax, $src}", []>;
3186
Evan Chengb783fa32007-07-19 01:14:50 +00003187def TEST8rm : I<0x84, MRMSrcMem, (outs), (ins GR8 :$src1, i8mem :$src2),
Evan Cheng621216e2007-09-29 00:00:36 +00003188 "test{b}\t{$src2, $src1|$src1, $src2}",
3189 [(X86cmp (and GR8:$src1, (loadi8 addr:$src2)), 0),
3190 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00003191def TEST16rm : I<0x85, MRMSrcMem, (outs), (ins GR16:$src1, i16mem:$src2),
Evan Cheng621216e2007-09-29 00:00:36 +00003192 "test{w}\t{$src2, $src1|$src1, $src2}",
3193 [(X86cmp (and GR16:$src1, (loadi16 addr:$src2)), 0),
3194 (implicit EFLAGS)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00003195def TEST32rm : I<0x85, MRMSrcMem, (outs), (ins GR32:$src1, i32mem:$src2),
Evan Cheng621216e2007-09-29 00:00:36 +00003196 "test{l}\t{$src2, $src1|$src1, $src2}",
3197 [(X86cmp (and GR32:$src1, (loadi32 addr:$src2)), 0),
3198 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003199
3200def TEST8ri : Ii8 <0xF6, MRM0r, // flags = GR8 & imm8
Evan Chengb783fa32007-07-19 01:14:50 +00003201 (outs), (ins GR8:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00003202 "test{b}\t{$src2, $src1|$src1, $src2}",
Chris Lattner21da6382008-02-19 17:37:35 +00003203 [(X86cmp (and_su GR8:$src1, imm:$src2), 0),
Evan Cheng621216e2007-09-29 00:00:36 +00003204 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003205def TEST16ri : Ii16<0xF7, MRM0r, // flags = GR16 & imm16
Evan Chengb783fa32007-07-19 01:14:50 +00003206 (outs), (ins GR16:$src1, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00003207 "test{w}\t{$src2, $src1|$src1, $src2}",
Chris Lattner21da6382008-02-19 17:37:35 +00003208 [(X86cmp (and_su GR16:$src1, imm:$src2), 0),
Evan Cheng621216e2007-09-29 00:00:36 +00003209 (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003210def TEST32ri : Ii32<0xF7, MRM0r, // flags = GR32 & imm32
Evan Chengb783fa32007-07-19 01:14:50 +00003211 (outs), (ins GR32:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00003212 "test{l}\t{$src2, $src1|$src1, $src2}",
Chris Lattner21da6382008-02-19 17:37:35 +00003213 [(X86cmp (and_su GR32:$src1, imm:$src2), 0),
Evan Cheng621216e2007-09-29 00:00:36 +00003214 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003215
Evan Cheng621216e2007-09-29 00:00:36 +00003216def TEST8mi : Ii8 <0xF6, MRM0m, // flags = [mem8] & imm8
Evan Chengb783fa32007-07-19 01:14:50 +00003217 (outs), (ins i8mem:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00003218 "test{b}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00003219 [(X86cmp (and (loadi8 addr:$src1), imm:$src2), 0),
3220 (implicit EFLAGS)]>;
3221def TEST16mi : Ii16<0xF7, MRM0m, // flags = [mem16] & imm16
Evan Chengb783fa32007-07-19 01:14:50 +00003222 (outs), (ins i16mem:$src1, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00003223 "test{w}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00003224 [(X86cmp (and (loadi16 addr:$src1), imm:$src2), 0),
3225 (implicit EFLAGS)]>, OpSize;
3226def TEST32mi : Ii32<0xF7, MRM0m, // flags = [mem32] & imm32
Evan Chengb783fa32007-07-19 01:14:50 +00003227 (outs), (ins i32mem:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00003228 "test{l}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00003229 [(X86cmp (and (loadi32 addr:$src1), imm:$src2), 0),
Evan Cheng950aac02007-09-25 01:57:46 +00003230 (implicit EFLAGS)]>;
3231} // Defs = [EFLAGS]
3232
3233
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003234// Condition code ops, incl. set if equal/not equal/...
Chris Lattnerc90ee9c2008-01-10 07:59:24 +00003235let Defs = [EFLAGS], Uses = [AH], neverHasSideEffects = 1 in
Evan Cheng6e4d1d92007-09-11 19:55:27 +00003236def SAHF : I<0x9E, RawFrm, (outs), (ins), "sahf", []>; // flags = AH
Chris Lattnerc90ee9c2008-01-10 07:59:24 +00003237let Defs = [AH], Uses = [EFLAGS], neverHasSideEffects = 1 in
Evan Cheng6e4d1d92007-09-11 19:55:27 +00003238def LAHF : I<0x9F, RawFrm, (outs), (ins), "lahf", []>; // AH = flags
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003239
Evan Cheng950aac02007-09-25 01:57:46 +00003240let Uses = [EFLAGS] in {
Evan Cheng834ae6b2009-12-15 00:53:42 +00003241// Use sbb to materialize carry bit.
3242
3243let Defs = [EFLAGS], isCodeGenOnly = 1 in {
3244def SETB_C8r : I<0x18, MRMInitReg, (outs GR8:$dst), (ins),
3245 "sbb{b}\t$dst, $dst",
3246 [(set GR8:$dst, (X86setcc_c X86_COND_B, EFLAGS))]>;
3247def SETB_C16r : I<0x19, MRMInitReg, (outs GR16:$dst), (ins),
3248 "sbb{w}\t$dst, $dst",
Evan Chengedeb1692009-12-16 00:53:11 +00003249 [(set GR16:$dst, (X86setcc_c X86_COND_B, EFLAGS))]>,
Evan Cheng834ae6b2009-12-15 00:53:42 +00003250 OpSize;
3251def SETB_C32r : I<0x19, MRMInitReg, (outs GR32:$dst), (ins),
3252 "sbb{l}\t$dst, $dst",
Evan Chengedeb1692009-12-16 00:53:11 +00003253 [(set GR32:$dst, (X86setcc_c X86_COND_B, EFLAGS))]>;
Evan Cheng834ae6b2009-12-15 00:53:42 +00003254} // isCodeGenOnly
3255
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003256def SETEr : I<0x94, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00003257 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00003258 "sete\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00003259 [(set GR8:$dst, (X86setcc X86_COND_E, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003260 TB; // GR8 = ==
3261def SETEm : I<0x94, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00003262 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00003263 "sete\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00003264 [(store (X86setcc X86_COND_E, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003265 TB; // [mem8] = ==
Bill Wendling0c52d0a2008-12-02 00:07:05 +00003266
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003267def SETNEr : I<0x95, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00003268 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00003269 "setne\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00003270 [(set GR8:$dst, (X86setcc X86_COND_NE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003271 TB; // GR8 = !=
3272def SETNEm : I<0x95, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00003273 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00003274 "setne\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00003275 [(store (X86setcc X86_COND_NE, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003276 TB; // [mem8] = !=
Bill Wendling0c52d0a2008-12-02 00:07:05 +00003277
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003278def SETLr : I<0x9C, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00003279 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00003280 "setl\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00003281 [(set GR8:$dst, (X86setcc X86_COND_L, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003282 TB; // GR8 = < signed
3283def SETLm : I<0x9C, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00003284 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00003285 "setl\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00003286 [(store (X86setcc X86_COND_L, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003287 TB; // [mem8] = < signed
Bill Wendling0c52d0a2008-12-02 00:07:05 +00003288
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003289def SETGEr : I<0x9D, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00003290 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00003291 "setge\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00003292 [(set GR8:$dst, (X86setcc X86_COND_GE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003293 TB; // GR8 = >= signed
3294def SETGEm : I<0x9D, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00003295 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00003296 "setge\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00003297 [(store (X86setcc X86_COND_GE, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003298 TB; // [mem8] = >= signed
Bill Wendling0c52d0a2008-12-02 00:07:05 +00003299
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003300def SETLEr : I<0x9E, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00003301 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00003302 "setle\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00003303 [(set GR8:$dst, (X86setcc X86_COND_LE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003304 TB; // GR8 = <= signed
3305def SETLEm : I<0x9E, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00003306 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00003307 "setle\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00003308 [(store (X86setcc X86_COND_LE, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003309 TB; // [mem8] = <= signed
Bill Wendling0c52d0a2008-12-02 00:07:05 +00003310
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003311def SETGr : I<0x9F, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00003312 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00003313 "setg\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00003314 [(set GR8:$dst, (X86setcc X86_COND_G, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003315 TB; // GR8 = > signed
3316def SETGm : I<0x9F, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00003317 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00003318 "setg\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00003319 [(store (X86setcc X86_COND_G, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003320 TB; // [mem8] = > signed
3321
3322def SETBr : I<0x92, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00003323 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00003324 "setb\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00003325 [(set GR8:$dst, (X86setcc X86_COND_B, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003326 TB; // GR8 = < unsign
3327def SETBm : I<0x92, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00003328 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00003329 "setb\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00003330 [(store (X86setcc X86_COND_B, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003331 TB; // [mem8] = < unsign
Bill Wendling0c52d0a2008-12-02 00:07:05 +00003332
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003333def SETAEr : I<0x93, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00003334 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00003335 "setae\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00003336 [(set GR8:$dst, (X86setcc X86_COND_AE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003337 TB; // GR8 = >= unsign
3338def SETAEm : I<0x93, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00003339 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00003340 "setae\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00003341 [(store (X86setcc X86_COND_AE, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003342 TB; // [mem8] = >= unsign
Bill Wendling0c52d0a2008-12-02 00:07:05 +00003343
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003344def SETBEr : I<0x96, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00003345 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00003346 "setbe\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00003347 [(set GR8:$dst, (X86setcc X86_COND_BE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003348 TB; // GR8 = <= unsign
3349def SETBEm : I<0x96, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00003350 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00003351 "setbe\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00003352 [(store (X86setcc X86_COND_BE, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003353 TB; // [mem8] = <= unsign
Bill Wendling0c52d0a2008-12-02 00:07:05 +00003354
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003355def SETAr : I<0x97, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00003356 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00003357 "seta\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00003358 [(set GR8:$dst, (X86setcc X86_COND_A, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003359 TB; // GR8 = > signed
3360def SETAm : I<0x97, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00003361 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00003362 "seta\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00003363 [(store (X86setcc X86_COND_A, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003364 TB; // [mem8] = > signed
3365
3366def SETSr : I<0x98, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00003367 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00003368 "sets\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00003369 [(set GR8:$dst, (X86setcc X86_COND_S, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003370 TB; // GR8 = <sign bit>
3371def SETSm : I<0x98, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00003372 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00003373 "sets\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00003374 [(store (X86setcc X86_COND_S, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003375 TB; // [mem8] = <sign bit>
3376def SETNSr : I<0x99, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00003377 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00003378 "setns\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00003379 [(set GR8:$dst, (X86setcc X86_COND_NS, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003380 TB; // GR8 = !<sign bit>
3381def SETNSm : I<0x99, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00003382 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00003383 "setns\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00003384 [(store (X86setcc X86_COND_NS, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003385 TB; // [mem8] = !<sign bit>
Bill Wendling0c52d0a2008-12-02 00:07:05 +00003386
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003387def SETPr : I<0x9A, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00003388 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00003389 "setp\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00003390 [(set GR8:$dst, (X86setcc X86_COND_P, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003391 TB; // GR8 = parity
3392def SETPm : I<0x9A, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00003393 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00003394 "setp\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00003395 [(store (X86setcc X86_COND_P, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003396 TB; // [mem8] = parity
3397def SETNPr : I<0x9B, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00003398 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00003399 "setnp\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00003400 [(set GR8:$dst, (X86setcc X86_COND_NP, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003401 TB; // GR8 = not parity
3402def SETNPm : I<0x9B, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00003403 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00003404 "setnp\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00003405 [(store (X86setcc X86_COND_NP, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003406 TB; // [mem8] = not parity
Bill Wendling0c52d0a2008-12-02 00:07:05 +00003407
3408def SETOr : I<0x90, MRM0r,
3409 (outs GR8 :$dst), (ins),
3410 "seto\t$dst",
3411 [(set GR8:$dst, (X86setcc X86_COND_O, EFLAGS))]>,
3412 TB; // GR8 = overflow
3413def SETOm : I<0x90, MRM0m,
3414 (outs), (ins i8mem:$dst),
3415 "seto\t$dst",
3416 [(store (X86setcc X86_COND_O, EFLAGS), addr:$dst)]>,
3417 TB; // [mem8] = overflow
3418def SETNOr : I<0x91, MRM0r,
3419 (outs GR8 :$dst), (ins),
3420 "setno\t$dst",
3421 [(set GR8:$dst, (X86setcc X86_COND_NO, EFLAGS))]>,
3422 TB; // GR8 = not overflow
3423def SETNOm : I<0x91, MRM0m,
3424 (outs), (ins i8mem:$dst),
3425 "setno\t$dst",
3426 [(store (X86setcc X86_COND_NO, EFLAGS), addr:$dst)]>,
3427 TB; // [mem8] = not overflow
Evan Cheng950aac02007-09-25 01:57:46 +00003428} // Uses = [EFLAGS]
3429
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003430
3431// Integer comparisons
Evan Cheng55687072007-09-14 21:48:26 +00003432let Defs = [EFLAGS] in {
Sean Callanan251676e2009-09-02 00:55:49 +00003433def CMP8i8 : Ii8<0x3C, RawFrm, (outs), (ins i8imm:$src),
3434 "cmp{b}\t{$src, %al|%al, $src}", []>;
3435def CMP16i16 : Ii16<0x3D, RawFrm, (outs), (ins i16imm:$src),
3436 "cmp{w}\t{$src, %ax|%ax, $src}", []>, OpSize;
3437def CMP32i32 : Ii32<0x3D, RawFrm, (outs), (ins i32imm:$src),
3438 "cmp{l}\t{$src, %eax|%eax, $src}", []>;
3439
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003440def CMP8rr : I<0x38, MRMDestReg,
Evan Chengb783fa32007-07-19 01:14:50 +00003441 (outs), (ins GR8 :$src1, GR8 :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00003442 "cmp{b}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00003443 [(X86cmp GR8:$src1, GR8:$src2), (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003444def CMP16rr : I<0x39, MRMDestReg,
Evan Chengb783fa32007-07-19 01:14:50 +00003445 (outs), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00003446 "cmp{w}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00003447 [(X86cmp GR16:$src1, GR16:$src2), (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003448def CMP32rr : I<0x39, MRMDestReg,
Evan Chengb783fa32007-07-19 01:14:50 +00003449 (outs), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00003450 "cmp{l}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00003451 [(X86cmp GR32:$src1, GR32:$src2), (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003452def CMP8mr : I<0x38, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00003453 (outs), (ins i8mem :$src1, GR8 :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00003454 "cmp{b}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00003455 [(X86cmp (loadi8 addr:$src1), GR8:$src2),
3456 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003457def CMP16mr : I<0x39, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00003458 (outs), (ins i16mem:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00003459 "cmp{w}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00003460 [(X86cmp (loadi16 addr:$src1), GR16:$src2),
3461 (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003462def CMP32mr : I<0x39, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00003463 (outs), (ins i32mem:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00003464 "cmp{l}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00003465 [(X86cmp (loadi32 addr:$src1), GR32:$src2),
3466 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003467def CMP8rm : I<0x3A, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00003468 (outs), (ins GR8 :$src1, i8mem :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00003469 "cmp{b}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00003470 [(X86cmp GR8:$src1, (loadi8 addr:$src2)),
3471 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003472def CMP16rm : I<0x3B, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00003473 (outs), (ins GR16:$src1, i16mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00003474 "cmp{w}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00003475 [(X86cmp GR16:$src1, (loadi16 addr:$src2)),
3476 (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003477def CMP32rm : I<0x3B, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00003478 (outs), (ins GR32:$src1, i32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00003479 "cmp{l}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00003480 [(X86cmp GR32:$src1, (loadi32 addr:$src2)),
3481 (implicit EFLAGS)]>;
Sean Callanan11490dc2009-09-16 21:11:23 +00003482def CMP8mrmrr : I<0x3A, MRMSrcReg, (outs), (ins GR8:$src1, GR8:$src2),
3483 "cmp{b}\t{$src2, $src1|$src1, $src2}", []>;
3484def CMP16mrmrr : I<0x3B, MRMSrcReg, (outs), (ins GR16:$src1, GR16:$src2),
3485 "cmp{w}\t{$src2, $src1|$src1, $src2}", []>, OpSize;
3486def CMP32mrmrr : I<0x3B, MRMSrcReg, (outs), (ins GR32:$src1, GR32:$src2),
3487 "cmp{l}\t{$src2, $src1|$src1, $src2}", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003488def CMP8ri : Ii8<0x80, MRM7r,
Evan Chengb783fa32007-07-19 01:14:50 +00003489 (outs), (ins GR8:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00003490 "cmp{b}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00003491 [(X86cmp GR8:$src1, imm:$src2), (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003492def CMP16ri : Ii16<0x81, MRM7r,
Evan Chengb783fa32007-07-19 01:14:50 +00003493 (outs), (ins GR16:$src1, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00003494 "cmp{w}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00003495 [(X86cmp GR16:$src1, imm:$src2),
3496 (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003497def CMP32ri : Ii32<0x81, MRM7r,
Evan Chengb783fa32007-07-19 01:14:50 +00003498 (outs), (ins GR32:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00003499 "cmp{l}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00003500 [(X86cmp GR32:$src1, imm:$src2), (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003501def CMP8mi : Ii8 <0x80, MRM7m,
Evan Chengb783fa32007-07-19 01:14:50 +00003502 (outs), (ins i8mem :$src1, i8imm :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00003503 "cmp{b}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00003504 [(X86cmp (loadi8 addr:$src1), imm:$src2),
3505 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003506def CMP16mi : Ii16<0x81, MRM7m,
Evan Chengb783fa32007-07-19 01:14:50 +00003507 (outs), (ins i16mem:$src1, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00003508 "cmp{w}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00003509 [(X86cmp (loadi16 addr:$src1), imm:$src2),
3510 (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003511def CMP32mi : Ii32<0x81, MRM7m,
Evan Chengb783fa32007-07-19 01:14:50 +00003512 (outs), (ins i32mem:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00003513 "cmp{l}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00003514 [(X86cmp (loadi32 addr:$src1), imm:$src2),
3515 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003516def CMP16ri8 : Ii8<0x83, MRM7r,
Evan Chengb783fa32007-07-19 01:14:50 +00003517 (outs), (ins GR16:$src1, i16i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00003518 "cmp{w}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00003519 [(X86cmp GR16:$src1, i16immSExt8:$src2),
3520 (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003521def CMP16mi8 : Ii8<0x83, MRM7m,
Evan Chengb783fa32007-07-19 01:14:50 +00003522 (outs), (ins i16mem:$src1, i16i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00003523 "cmp{w}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00003524 [(X86cmp (loadi16 addr:$src1), i16immSExt8:$src2),
3525 (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003526def CMP32mi8 : Ii8<0x83, MRM7m,
Evan Chengb783fa32007-07-19 01:14:50 +00003527 (outs), (ins i32mem:$src1, i32i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00003528 "cmp{l}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00003529 [(X86cmp (loadi32 addr:$src1), i32immSExt8:$src2),
3530 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003531def CMP32ri8 : Ii8<0x83, MRM7r,
Evan Chengb783fa32007-07-19 01:14:50 +00003532 (outs), (ins GR32:$src1, i32i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00003533 "cmp{l}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00003534 [(X86cmp GR32:$src1, i32immSExt8:$src2),
Evan Cheng950aac02007-09-25 01:57:46 +00003535 (implicit EFLAGS)]>;
3536} // Defs = [EFLAGS]
3537
Dan Gohman7fe9b7f2008-12-23 22:45:23 +00003538// Bit tests.
Dan Gohman7fe9b7f2008-12-23 22:45:23 +00003539// TODO: BTC, BTR, and BTS
3540let Defs = [EFLAGS] in {
Dan Gohmanfc4eddb2009-01-13 20:32:45 +00003541def BT16rr : I<0xA3, MRMDestReg, (outs), (ins GR16:$src1, GR16:$src2),
Dan Gohman7fe9b7f2008-12-23 22:45:23 +00003542 "bt{w}\t{$src2, $src1|$src1, $src2}",
3543 [(X86bt GR16:$src1, GR16:$src2),
Chris Lattner5a95cde2008-12-25 01:32:49 +00003544 (implicit EFLAGS)]>, OpSize, TB;
Dan Gohmanfc4eddb2009-01-13 20:32:45 +00003545def BT32rr : I<0xA3, MRMDestReg, (outs), (ins GR32:$src1, GR32:$src2),
Dan Gohman7fe9b7f2008-12-23 22:45:23 +00003546 "bt{l}\t{$src2, $src1|$src1, $src2}",
3547 [(X86bt GR32:$src1, GR32:$src2),
Chris Lattner5a95cde2008-12-25 01:32:49 +00003548 (implicit EFLAGS)]>, TB;
Dan Gohman85a228c2009-01-13 23:23:30 +00003549
3550// Unlike with the register+register form, the memory+register form of the
3551// bt instruction does not ignore the high bits of the index. From ISel's
Sean Callanan2c48df22009-12-18 00:01:26 +00003552// perspective, this is pretty bizarre. Make these instructions disassembly
3553// only for now.
3554
3555def BT16mr : I<0xA3, MRMDestMem, (outs), (ins i16mem:$src1, GR16:$src2),
3556 "bt{w}\t{$src2, $src1|$src1, $src2}",
Dan Gohman85a228c2009-01-13 23:23:30 +00003557// [(X86bt (loadi16 addr:$src1), GR16:$src2),
Sean Callanan2c48df22009-12-18 00:01:26 +00003558// (implicit EFLAGS)]
3559 []
3560 >, OpSize, TB, Requires<[FastBTMem]>;
3561def BT32mr : I<0xA3, MRMDestMem, (outs), (ins i32mem:$src1, GR32:$src2),
3562 "bt{l}\t{$src2, $src1|$src1, $src2}",
Dan Gohman85a228c2009-01-13 23:23:30 +00003563// [(X86bt (loadi32 addr:$src1), GR32:$src2),
Sean Callanan2c48df22009-12-18 00:01:26 +00003564// (implicit EFLAGS)]
3565 []
3566 >, TB, Requires<[FastBTMem]>;
Dan Gohman46fb1cf2009-01-13 20:33:23 +00003567
3568def BT16ri8 : Ii8<0xBA, MRM4r, (outs), (ins GR16:$src1, i16i8imm:$src2),
3569 "bt{w}\t{$src2, $src1|$src1, $src2}",
3570 [(X86bt GR16:$src1, i16immSExt8:$src2),
3571 (implicit EFLAGS)]>, OpSize, TB;
3572def BT32ri8 : Ii8<0xBA, MRM4r, (outs), (ins GR32:$src1, i32i8imm:$src2),
3573 "bt{l}\t{$src2, $src1|$src1, $src2}",
3574 [(X86bt GR32:$src1, i32immSExt8:$src2),
3575 (implicit EFLAGS)]>, TB;
3576// Note that these instructions don't need FastBTMem because that
3577// only applies when the other operand is in a register. When it's
3578// an immediate, bt is still fast.
3579def BT16mi8 : Ii8<0xBA, MRM4m, (outs), (ins i16mem:$src1, i16i8imm:$src2),
3580 "bt{w}\t{$src2, $src1|$src1, $src2}",
3581 [(X86bt (loadi16 addr:$src1), i16immSExt8:$src2),
3582 (implicit EFLAGS)]>, OpSize, TB;
3583def BT32mi8 : Ii8<0xBA, MRM4m, (outs), (ins i32mem:$src1, i32i8imm:$src2),
3584 "bt{l}\t{$src2, $src1|$src1, $src2}",
3585 [(X86bt (loadi32 addr:$src1), i32immSExt8:$src2),
3586 (implicit EFLAGS)]>, TB;
Sean Callanan2c48df22009-12-18 00:01:26 +00003587
3588def BTC16rr : I<0xBB, MRMDestReg, (outs), (ins GR16:$src1, GR16:$src2),
3589 "btc{w}\t{$src2, $src1|$src1, $src2}", []>, OpSize, TB;
3590def BTC32rr : I<0xBB, MRMDestReg, (outs), (ins GR32:$src1, GR32:$src2),
3591 "btc{l}\t{$src2, $src1|$src1, $src2}", []>, TB;
3592def BTC16mr : I<0xBB, MRMDestMem, (outs), (ins i16mem:$src1, GR16:$src2),
3593 "btc{w}\t{$src2, $src1|$src1, $src2}", []>, OpSize, TB;
3594def BTC32mr : I<0xBB, MRMDestMem, (outs), (ins i32mem:$src1, GR32:$src2),
3595 "btc{l}\t{$src2, $src1|$src1, $src2}", []>, TB;
3596def BTC16ri8 : Ii8<0xBA, MRM7r, (outs), (ins GR16:$src1, i16i8imm:$src2),
3597 "btc{w}\t{$src2, $src1|$src1, $src2}", []>, OpSize, TB;
3598def BTC32ri8 : Ii8<0xBA, MRM7r, (outs), (ins GR32:$src1, i32i8imm:$src2),
3599 "btc{l}\t{$src2, $src1|$src1, $src2}", []>, TB;
3600def BTC16mi8 : Ii8<0xBA, MRM7m, (outs), (ins i16mem:$src1, i16i8imm:$src2),
3601 "btc{w}\t{$src2, $src1|$src1, $src2}", []>, OpSize, TB;
3602def BTC32mi8 : Ii8<0xBA, MRM7m, (outs), (ins i32mem:$src1, i32i8imm:$src2),
3603 "btc{l}\t{$src2, $src1|$src1, $src2}", []>, TB;
3604
3605def BTR16rr : I<0xB3, MRMDestReg, (outs), (ins GR16:$src1, GR16:$src2),
3606 "btr{w}\t{$src2, $src1|$src1, $src2}", []>, OpSize, TB;
3607def BTR32rr : I<0xB3, MRMDestReg, (outs), (ins GR32:$src1, GR32:$src2),
3608 "btr{l}\t{$src2, $src1|$src1, $src2}", []>, TB;
3609def BTR16mr : I<0xB3, MRMDestMem, (outs), (ins i16mem:$src1, GR16:$src2),
3610 "btr{w}\t{$src2, $src1|$src1, $src2}", []>, OpSize, TB;
3611def BTR32mr : I<0xB3, MRMDestMem, (outs), (ins i32mem:$src1, GR32:$src2),
3612 "btr{l}\t{$src2, $src1|$src1, $src2}", []>, TB;
3613def BTR16ri8 : Ii8<0xBA, MRM6r, (outs), (ins GR16:$src1, i16i8imm:$src2),
3614 "btr{w}\t{$src2, $src1|$src1, $src2}", []>, OpSize, TB;
3615def BTR32ri8 : Ii8<0xBA, MRM6r, (outs), (ins GR32:$src1, i32i8imm:$src2),
3616 "btr{l}\t{$src2, $src1|$src1, $src2}", []>, TB;
3617def BTR16mi8 : Ii8<0xBA, MRM6m, (outs), (ins i16mem:$src1, i16i8imm:$src2),
3618 "btr{w}\t{$src2, $src1|$src1, $src2}", []>, OpSize, TB;
3619def BTR32mi8 : Ii8<0xBA, MRM6m, (outs), (ins i32mem:$src1, i32i8imm:$src2),
3620 "btr{l}\t{$src2, $src1|$src1, $src2}", []>, TB;
3621
3622def BTS16rr : I<0xAB, MRMDestReg, (outs), (ins GR16:$src1, GR16:$src2),
3623 "bts{w}\t{$src2, $src1|$src1, $src2}", []>, OpSize, TB;
3624def BTS32rr : I<0xAB, MRMDestReg, (outs), (ins GR32:$src1, GR32:$src2),
3625 "bts{l}\t{$src2, $src1|$src1, $src2}", []>, TB;
3626def BTS16mr : I<0xAB, MRMDestMem, (outs), (ins i16mem:$src1, GR16:$src2),
3627 "bts{w}\t{$src2, $src1|$src1, $src2}", []>, OpSize, TB;
3628def BTS32mr : I<0xAB, MRMDestMem, (outs), (ins i32mem:$src1, GR32:$src2),
3629 "bts{l}\t{$src2, $src1|$src1, $src2}", []>, TB;
3630def BTS16ri8 : Ii8<0xBA, MRM5r, (outs), (ins GR16:$src1, i16i8imm:$src2),
3631 "bts{w}\t{$src2, $src1|$src1, $src2}", []>, OpSize, TB;
3632def BTS32ri8 : Ii8<0xBA, MRM5r, (outs), (ins GR32:$src1, i32i8imm:$src2),
3633 "bts{l}\t{$src2, $src1|$src1, $src2}", []>, TB;
3634def BTS16mi8 : Ii8<0xBA, MRM5m, (outs), (ins i16mem:$src1, i16i8imm:$src2),
3635 "bts{w}\t{$src2, $src1|$src1, $src2}", []>, OpSize, TB;
3636def BTS32mi8 : Ii8<0xBA, MRM5m, (outs), (ins i32mem:$src1, i32i8imm:$src2),
3637 "bts{l}\t{$src2, $src1|$src1, $src2}", []>, TB;
Dan Gohman7fe9b7f2008-12-23 22:45:23 +00003638} // Defs = [EFLAGS]
3639
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003640// Sign/Zero extenders
Dan Gohman9203ab42008-07-30 18:09:17 +00003641// Use movsbl intead of movsbw; we don't care about the high 16 bits
3642// of the register here. This has a smaller encoding and avoids a
Sean Callanan2c48df22009-12-18 00:01:26 +00003643// partial-register update. Actual movsbw included for the disassembler.
3644def MOVSX16rr8W : I<0xBE, MRMSrcReg, (outs GR16:$dst), (ins GR8:$src),
3645 "movs{bw|x}\t{$src, $dst|$dst, $src}", []>, TB, OpSize;
3646def MOVSX16rm8W : I<0xBE, MRMSrcMem, (outs GR16:$dst), (ins i8mem:$src),
3647 "movs{bw|x}\t{$src, $dst|$dst, $src}", []>, TB, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00003648def MOVSX16rr8 : I<0xBE, MRMSrcReg, (outs GR16:$dst), (ins GR8 :$src),
Chris Lattnerbe7efcc2009-10-19 19:51:42 +00003649 "", [(set GR16:$dst, (sext GR8:$src))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00003650def MOVSX16rm8 : I<0xBE, MRMSrcMem, (outs GR16:$dst), (ins i8mem :$src),
Chris Lattnerbe7efcc2009-10-19 19:51:42 +00003651 "", [(set GR16:$dst, (sextloadi16i8 addr:$src))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00003652def MOVSX32rr8 : I<0xBE, MRMSrcReg, (outs GR32:$dst), (ins GR8 :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00003653 "movs{bl|x}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003654 [(set GR32:$dst, (sext GR8:$src))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00003655def MOVSX32rm8 : I<0xBE, MRMSrcMem, (outs GR32:$dst), (ins i8mem :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00003656 "movs{bl|x}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003657 [(set GR32:$dst, (sextloadi32i8 addr:$src))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00003658def MOVSX32rr16: I<0xBF, MRMSrcReg, (outs GR32:$dst), (ins GR16:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00003659 "movs{wl|x}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003660 [(set GR32:$dst, (sext GR16:$src))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00003661def MOVSX32rm16: I<0xBF, MRMSrcMem, (outs GR32:$dst), (ins i16mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00003662 "movs{wl|x}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003663 [(set GR32:$dst, (sextloadi32i16 addr:$src))]>, TB;
3664
Dan Gohman9203ab42008-07-30 18:09:17 +00003665// Use movzbl intead of movzbw; we don't care about the high 16 bits
3666// of the register here. This has a smaller encoding and avoids a
Sean Callanan2c48df22009-12-18 00:01:26 +00003667// partial-register update. Actual movzbw included for the disassembler.
3668def MOVZX16rr8W : I<0xB6, MRMSrcReg, (outs GR16:$dst), (ins GR8:$src),
3669 "movz{bw|x}\t{$src, $dst|$dst, $src}", []>, TB, OpSize;
3670def MOVZX16rm8W : I<0xB6, MRMSrcMem, (outs GR16:$dst), (ins i8mem:$src),
3671 "movz{bw|x}\t{$src, $dst|$dst, $src}", []>, TB, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00003672def MOVZX16rr8 : I<0xB6, MRMSrcReg, (outs GR16:$dst), (ins GR8 :$src),
Chris Lattnerbe7efcc2009-10-19 19:51:42 +00003673 "", [(set GR16:$dst, (zext GR8:$src))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00003674def MOVZX16rm8 : I<0xB6, MRMSrcMem, (outs GR16:$dst), (ins i8mem :$src),
Chris Lattnerbe7efcc2009-10-19 19:51:42 +00003675 "", [(set GR16:$dst, (zextloadi16i8 addr:$src))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00003676def MOVZX32rr8 : I<0xB6, MRMSrcReg, (outs GR32:$dst), (ins GR8 :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00003677 "movz{bl|x}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003678 [(set GR32:$dst, (zext GR8:$src))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00003679def MOVZX32rm8 : I<0xB6, MRMSrcMem, (outs GR32:$dst), (ins i8mem :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00003680 "movz{bl|x}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003681 [(set GR32:$dst, (zextloadi32i8 addr:$src))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00003682def MOVZX32rr16: I<0xB7, MRMSrcReg, (outs GR32:$dst), (ins GR16:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00003683 "movz{wl|x}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003684 [(set GR32:$dst, (zext GR16:$src))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00003685def MOVZX32rm16: I<0xB7, MRMSrcMem, (outs GR32:$dst), (ins i16mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00003686 "movz{wl|x}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003687 [(set GR32:$dst, (zextloadi32i16 addr:$src))]>, TB;
3688
Dan Gohman744d4622009-04-13 16:09:41 +00003689// These are the same as the regular regular MOVZX32rr8 and MOVZX32rm8
3690// except that they use GR32_NOREX for the output operand register class
3691// instead of GR32. This allows them to operate on h registers on x86-64.
3692def MOVZX32_NOREXrr8 : I<0xB6, MRMSrcReg,
3693 (outs GR32_NOREX:$dst), (ins GR8:$src),
3694 "movz{bl|x}\t{$src, $dst|$dst, $src} # NOREX",
3695 []>, TB;
Dan Gohman89f4cda2009-04-30 03:11:48 +00003696let mayLoad = 1 in
Dan Gohman744d4622009-04-13 16:09:41 +00003697def MOVZX32_NOREXrm8 : I<0xB6, MRMSrcMem,
3698 (outs GR32_NOREX:$dst), (ins i8mem:$src),
3699 "movz{bl|x}\t{$src, $dst|$dst, $src} # NOREX",
3700 []>, TB;
3701
Chris Lattnerc90ee9c2008-01-10 07:59:24 +00003702let neverHasSideEffects = 1 in {
3703 let Defs = [AX], Uses = [AL] in
3704 def CBW : I<0x98, RawFrm, (outs), (ins),
3705 "{cbtw|cbw}", []>, OpSize; // AX = signext(AL)
3706 let Defs = [EAX], Uses = [AX] in
3707 def CWDE : I<0x98, RawFrm, (outs), (ins),
3708 "{cwtl|cwde}", []>; // EAX = signext(AX)
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003709
Chris Lattnerc90ee9c2008-01-10 07:59:24 +00003710 let Defs = [AX,DX], Uses = [AX] in
3711 def CWD : I<0x99, RawFrm, (outs), (ins),
3712 "{cwtd|cwd}", []>, OpSize; // DX:AX = signext(AX)
3713 let Defs = [EAX,EDX], Uses = [EAX] in
3714 def CDQ : I<0x99, RawFrm, (outs), (ins),
3715 "{cltd|cdq}", []>; // EDX:EAX = signext(EAX)
3716}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003717
3718//===----------------------------------------------------------------------===//
3719// Alias Instructions
3720//===----------------------------------------------------------------------===//
3721
3722// Alias instructions that map movr0 to xor.
3723// FIXME: remove when we can teach regalloc that xor reg, reg is ok.
Daniel Dunbara0e62002009-08-11 22:17:52 +00003724let Defs = [EFLAGS], isReMaterializable = 1, isAsCheapAsAMove = 1,
3725 isCodeGenOnly = 1 in {
Evan Chengb783fa32007-07-19 01:14:50 +00003726def MOV8r0 : I<0x30, MRMInitReg, (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00003727 "xor{b}\t$dst, $dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003728 [(set GR8:$dst, 0)]>;
Dan Gohmanb9e1c8d2010-01-12 04:42:54 +00003729
3730// We want to rewrite MOV16r0 in terms of MOV32r0, because it's a smaller
3731// encoding and avoids a partial-register update sometimes, but doing so
3732// at isel time interferes with rematerialization in the current register
3733// allocator. For now, this is rewritten when the instruction is lowered
3734// to an MCInst.
3735def MOV16r0 : I<0x31, MRMInitReg, (outs GR16:$dst), (ins),
3736 "",
3737 [(set GR16:$dst, 0)]>, OpSize;
Chris Lattnerb5b1b862009-12-23 01:30:26 +00003738
Chris Lattner2ba53dc2009-12-23 01:46:40 +00003739def MOV32r0 : I<0x31, MRMInitReg, (outs GR32:$dst), (ins),
3740 "xor{l}\t$dst, $dst",
3741 [(set GR32:$dst, 0)]>;
3742}
Chris Lattnerb5b1b862009-12-23 01:30:26 +00003743
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003744//===----------------------------------------------------------------------===//
3745// Thread Local Storage Instructions
3746//
3747
Rafael Espindola7fc4b8d2009-04-24 12:59:40 +00003748// All calls clobber the non-callee saved registers. ESP is marked as
3749// a use to prevent stack-pointer assignments that appear immediately
3750// before calls from potentially appearing dead.
3751let Defs = [EAX, ECX, EDX, FP0, FP1, FP2, FP3, FP4, FP5, FP6, ST0,
3752 MM0, MM1, MM2, MM3, MM4, MM5, MM6, MM7,
3753 XMM0, XMM1, XMM2, XMM3, XMM4, XMM5, XMM6, XMM7,
3754 XMM8, XMM9, XMM10, XMM11, XMM12, XMM13, XMM14, XMM15, EFLAGS],
Chris Lattnerf1940742009-06-20 20:38:48 +00003755 Uses = [ESP] in
3756def TLS_addr32 : I<0, Pseudo, (outs), (ins lea32mem:$sym),
3757 "leal\t$sym, %eax; "
Dan Gohman70a8a112009-04-27 15:13:28 +00003758 "call\t___tls_get_addr@PLT",
Chris Lattnerf1940742009-06-20 20:38:48 +00003759 [(X86tlsaddr tls32addr:$sym)]>,
Rafael Espindolaaf759ab2009-04-17 14:35:58 +00003760 Requires<[In32BitMode]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003761
Daniel Dunbar75a07302009-08-11 22:24:40 +00003762let AddedComplexity = 5, isCodeGenOnly = 1 in
sampo9cc09a32009-01-26 01:24:32 +00003763def GS_MOV32rm : I<0x8B, MRMSrcMem, (outs GR32:$dst), (ins i32mem:$src),
3764 "movl\t%gs:$src, $dst",
3765 [(set GR32:$dst, (gsload addr:$src))]>, SegGS;
3766
Daniel Dunbar75a07302009-08-11 22:24:40 +00003767let AddedComplexity = 5, isCodeGenOnly = 1 in
Chris Lattnera7c2d8a2009-05-05 18:52:19 +00003768def FS_MOV32rm : I<0x8B, MRMSrcMem, (outs GR32:$dst), (ins i32mem:$src),
3769 "movl\t%fs:$src, $dst",
3770 [(set GR32:$dst, (fsload addr:$src))]>, SegFS;
3771
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003772//===----------------------------------------------------------------------===//
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003773// EH Pseudo Instructions
3774//
3775let isTerminator = 1, isReturn = 1, isBarrier = 1,
Daniel Dunbar75513bd2009-08-27 07:58:05 +00003776 hasCtrlDep = 1, isCodeGenOnly = 1 in {
Evan Chengb783fa32007-07-19 01:14:50 +00003777def EH_RETURN : I<0xC3, RawFrm, (outs), (ins GR32:$addr),
Dan Gohman91888f02007-07-31 20:11:57 +00003778 "ret\t#eh_return, addr: $addr",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003779 [(X86ehret GR32:$addr)]>;
3780
3781}
3782
3783//===----------------------------------------------------------------------===//
Andrew Lenharthe44f3902008-02-21 06:45:13 +00003784// Atomic support
3785//
Andrew Lenharth7a5a4b22008-03-01 13:37:02 +00003786
Evan Cheng3e171562008-04-19 01:20:30 +00003787// Atomic swap. These are just normal xchg instructions. But since a memory
3788// operand is referenced, the atomicity is ensured.
Dan Gohmana41a1c092008-08-06 15:52:50 +00003789let Constraints = "$val = $dst" in {
Sean Callanan2c48df22009-12-18 00:01:26 +00003790def XCHG32rm : I<0x87, MRMSrcMem, (outs GR32:$dst),
3791 (ins GR32:$val, i32mem:$ptr),
Evan Cheng3e171562008-04-19 01:20:30 +00003792 "xchg{l}\t{$val, $ptr|$ptr, $val}",
3793 [(set GR32:$dst, (atomic_swap_32 addr:$ptr, GR32:$val))]>;
Sean Callanan2c48df22009-12-18 00:01:26 +00003794def XCHG16rm : I<0x87, MRMSrcMem, (outs GR16:$dst),
3795 (ins GR16:$val, i16mem:$ptr),
Evan Cheng3e171562008-04-19 01:20:30 +00003796 "xchg{w}\t{$val, $ptr|$ptr, $val}",
3797 [(set GR16:$dst, (atomic_swap_16 addr:$ptr, GR16:$val))]>,
3798 OpSize;
Sean Callanan2c48df22009-12-18 00:01:26 +00003799def XCHG8rm : I<0x86, MRMSrcMem, (outs GR8:$dst), (ins GR8:$val, i8mem:$ptr),
Evan Cheng3e171562008-04-19 01:20:30 +00003800 "xchg{b}\t{$val, $ptr|$ptr, $val}",
3801 [(set GR8:$dst, (atomic_swap_8 addr:$ptr, GR8:$val))]>;
Sean Callanan2c48df22009-12-18 00:01:26 +00003802
3803def XCHG32rr : I<0x87, MRMSrcReg, (outs GR32:$dst), (ins GR32:$val, GR32:$src),
3804 "xchg{l}\t{$val, $src|$src, $val}", []>;
3805def XCHG16rr : I<0x87, MRMSrcReg, (outs GR16:$dst), (ins GR16:$val, GR16:$src),
3806 "xchg{w}\t{$val, $src|$src, $val}", []>, OpSize;
3807def XCHG8rr : I<0x86, MRMSrcReg, (outs GR8:$dst), (ins GR8:$val, GR8:$src),
3808 "xchg{b}\t{$val, $src|$src, $val}", []>;
Evan Cheng3e171562008-04-19 01:20:30 +00003809}
3810
Sean Callanan2c48df22009-12-18 00:01:26 +00003811def XCHG16ar : I<0x90, AddRegFrm, (outs), (ins GR16:$src),
3812 "xchg{w}\t{$src, %ax|%ax, $src}", []>, OpSize;
3813def XCHG32ar : I<0x90, AddRegFrm, (outs), (ins GR32:$src),
3814 "xchg{l}\t{$src, %eax|%eax, $src}", []>;
3815
Evan Chengd49dbb82008-04-18 20:55:36 +00003816// Atomic compare and swap.
Andrew Lenharth7dfe23f2008-03-01 21:52:34 +00003817let Defs = [EAX, EFLAGS], Uses = [EAX] in {
Evan Chengd49dbb82008-04-18 20:55:36 +00003818def LCMPXCHG32 : I<0xB1, MRMDestMem, (outs), (ins i32mem:$ptr, GR32:$swap),
Dan Gohman70a8a112009-04-27 15:13:28 +00003819 "lock\n\t"
3820 "cmpxchg{l}\t{$swap, $ptr|$ptr, $swap}",
Evan Cheng09fbdee2008-03-04 03:20:06 +00003821 [(X86cas addr:$ptr, GR32:$swap, 4)]>, TB, LOCK;
Andrew Lenharth7a5a4b22008-03-01 13:37:02 +00003822}
Dale Johannesenf160d802008-10-02 18:53:47 +00003823let Defs = [EAX, EDX, EFLAGS], Uses = [EAX, EBX, ECX, EDX] in {
Evan Cheng3896a6f2010-01-08 01:29:19 +00003824def LCMPXCHG8B : I<0xC7, MRM1m, (outs), (ins i64mem:$ptr),
Dan Gohman70a8a112009-04-27 15:13:28 +00003825 "lock\n\t"
3826 "cmpxchg8b\t$ptr",
Andrew Lenharth81580822008-03-05 01:15:49 +00003827 [(X86cas8 addr:$ptr)]>, TB, LOCK;
3828}
Andrew Lenharth7dfe23f2008-03-01 21:52:34 +00003829
3830let Defs = [AX, EFLAGS], Uses = [AX] in {
Evan Chengd49dbb82008-04-18 20:55:36 +00003831def LCMPXCHG16 : I<0xB1, MRMDestMem, (outs), (ins i16mem:$ptr, GR16:$swap),
Dan Gohman70a8a112009-04-27 15:13:28 +00003832 "lock\n\t"
3833 "cmpxchg{w}\t{$swap, $ptr|$ptr, $swap}",
Evan Cheng09fbdee2008-03-04 03:20:06 +00003834 [(X86cas addr:$ptr, GR16:$swap, 2)]>, TB, OpSize, LOCK;
Andrew Lenharth7a5a4b22008-03-01 13:37:02 +00003835}
Andrew Lenharth7dfe23f2008-03-01 21:52:34 +00003836let Defs = [AL, EFLAGS], Uses = [AL] in {
Evan Chengd49dbb82008-04-18 20:55:36 +00003837def LCMPXCHG8 : I<0xB0, MRMDestMem, (outs), (ins i8mem:$ptr, GR8:$swap),
Dan Gohman70a8a112009-04-27 15:13:28 +00003838 "lock\n\t"
3839 "cmpxchg{b}\t{$swap, $ptr|$ptr, $swap}",
Evan Cheng09fbdee2008-03-04 03:20:06 +00003840 [(X86cas addr:$ptr, GR8:$swap, 1)]>, TB, LOCK;
Andrew Lenharth7a5a4b22008-03-01 13:37:02 +00003841}
3842
Evan Chengd49dbb82008-04-18 20:55:36 +00003843// Atomic exchange and add
3844let Constraints = "$val = $dst", Defs = [EFLAGS] in {
Sean Callanan2c48df22009-12-18 00:01:26 +00003845def LXADD32 : I<0xC1, MRMSrcMem, (outs GR32:$dst), (ins GR32:$val, i32mem:$ptr),
Dan Gohman70a8a112009-04-27 15:13:28 +00003846 "lock\n\t"
3847 "xadd{l}\t{$val, $ptr|$ptr, $val}",
Mon P Wang6bde9ec2008-06-25 08:15:39 +00003848 [(set GR32:$dst, (atomic_load_add_32 addr:$ptr, GR32:$val))]>,
Evan Chengd49dbb82008-04-18 20:55:36 +00003849 TB, LOCK;
Sean Callanan2c48df22009-12-18 00:01:26 +00003850def LXADD16 : I<0xC1, MRMSrcMem, (outs GR16:$dst), (ins GR16:$val, i16mem:$ptr),
Dan Gohman70a8a112009-04-27 15:13:28 +00003851 "lock\n\t"
3852 "xadd{w}\t{$val, $ptr|$ptr, $val}",
Mon P Wang6bde9ec2008-06-25 08:15:39 +00003853 [(set GR16:$dst, (atomic_load_add_16 addr:$ptr, GR16:$val))]>,
Evan Chengd49dbb82008-04-18 20:55:36 +00003854 TB, OpSize, LOCK;
Sean Callanan2c48df22009-12-18 00:01:26 +00003855def LXADD8 : I<0xC0, MRMSrcMem, (outs GR8:$dst), (ins GR8:$val, i8mem:$ptr),
Dan Gohman70a8a112009-04-27 15:13:28 +00003856 "lock\n\t"
3857 "xadd{b}\t{$val, $ptr|$ptr, $val}",
Mon P Wang6bde9ec2008-06-25 08:15:39 +00003858 [(set GR8:$dst, (atomic_load_add_8 addr:$ptr, GR8:$val))]>,
Evan Chengd49dbb82008-04-18 20:55:36 +00003859 TB, LOCK;
Andrew Lenharth7a5a4b22008-03-01 13:37:02 +00003860}
3861
Sean Callanan2c48df22009-12-18 00:01:26 +00003862def XADD8rr : I<0xC0, MRMDestReg, (outs GR8:$dst), (ins GR8:$src),
3863 "xadd{b}\t{$src, $dst|$dst, $src}", []>, TB;
3864def XADD16rr : I<0xC1, MRMDestReg, (outs GR16:$dst), (ins GR16:$src),
3865 "xadd{w}\t{$src, $dst|$dst, $src}", []>, TB, OpSize;
3866def XADD32rr : I<0xC1, MRMDestReg, (outs GR32:$dst), (ins GR32:$src),
3867 "xadd{l}\t{$src, $dst|$dst, $src}", []>, TB;
3868
3869def XADD8rm : I<0xC0, MRMDestMem, (outs), (ins i8mem:$dst, GR8:$src),
3870 "xadd{b}\t{$src, $dst|$dst, $src}", []>, TB;
3871def XADD16rm : I<0xC1, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src),
3872 "xadd{w}\t{$src, $dst|$dst, $src}", []>, TB, OpSize;
3873def XADD32rm : I<0xC1, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src),
3874 "xadd{l}\t{$src, $dst|$dst, $src}", []>, TB;
3875
3876def CMPXCHG8rr : I<0xB0, MRMDestReg, (outs GR8:$dst), (ins GR8:$src),
3877 "cmpxchg{b}\t{$src, $dst|$dst, $src}", []>, TB;
3878def CMPXCHG16rr : I<0xB1, MRMDestReg, (outs GR16:$dst), (ins GR16:$src),
3879 "cmpxchg{w}\t{$src, $dst|$dst, $src}", []>, TB, OpSize;
3880def CMPXCHG32rr : I<0xB1, MRMDestReg, (outs GR32:$dst), (ins GR32:$src),
3881 "cmpxchg{l}\t{$src, $dst|$dst, $src}", []>, TB;
3882
3883def CMPXCHG8rm : I<0xB0, MRMDestMem, (outs), (ins i8mem:$dst, GR8:$src),
3884 "cmpxchg{b}\t{$src, $dst|$dst, $src}", []>, TB;
3885def CMPXCHG16rm : I<0xB1, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src),
3886 "cmpxchg{w}\t{$src, $dst|$dst, $src}", []>, TB, OpSize;
3887def CMPXCHG32rm : I<0xB1, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src),
3888 "cmpxchg{l}\t{$src, $dst|$dst, $src}", []>, TB;
3889
Evan Cheng3896a6f2010-01-08 01:29:19 +00003890let Defs = [EAX, EDX, EFLAGS], Uses = [EAX, EBX, ECX, EDX] in
Sean Callanan2c48df22009-12-18 00:01:26 +00003891def CMPXCHG8B : I<0xC7, MRM1m, (outs), (ins i64mem:$dst),
3892 "cmpxchg8b\t$dst", []>, TB;
3893
Evan Chengb723fb52009-07-30 08:33:02 +00003894// Optimized codegen when the non-memory output is not used.
3895// FIXME: Use normal add / sub instructions and add lock prefix dynamically.
Dan Gohman1c286992009-10-20 18:14:49 +00003896let Defs = [EFLAGS] in {
Evan Chengb723fb52009-07-30 08:33:02 +00003897def LOCK_ADD8mr : I<0x00, MRMDestMem, (outs), (ins i8mem:$dst, GR8:$src2),
3898 "lock\n\t"
3899 "add{b}\t{$src2, $dst|$dst, $src2}", []>, LOCK;
3900def LOCK_ADD16mr : I<0x01, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
3901 "lock\n\t"
3902 "add{w}\t{$src2, $dst|$dst, $src2}", []>, OpSize, LOCK;
3903def LOCK_ADD32mr : I<0x01, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
3904 "lock\n\t"
3905 "add{l}\t{$src2, $dst|$dst, $src2}", []>, LOCK;
3906def LOCK_ADD8mi : Ii8<0x80, MRM0m, (outs), (ins i8mem :$dst, i8imm :$src2),
3907 "lock\n\t"
3908 "add{b}\t{$src2, $dst|$dst, $src2}", []>, LOCK;
3909def LOCK_ADD16mi : Ii16<0x81, MRM0m, (outs), (ins i16mem:$dst, i16imm:$src2),
3910 "lock\n\t"
3911 "add{w}\t{$src2, $dst|$dst, $src2}", []>, LOCK;
3912def LOCK_ADD32mi : Ii32<0x81, MRM0m, (outs), (ins i32mem:$dst, i32imm:$src2),
3913 "lock\n\t"
3914 "add{l}\t{$src2, $dst|$dst, $src2}", []>, LOCK;
3915def LOCK_ADD16mi8 : Ii8<0x83, MRM0m, (outs), (ins i16mem:$dst, i16i8imm :$src2),
3916 "lock\n\t"
3917 "add{w}\t{$src2, $dst|$dst, $src2}", []>, OpSize, LOCK;
3918def LOCK_ADD32mi8 : Ii8<0x83, MRM0m, (outs), (ins i32mem:$dst, i32i8imm :$src2),
3919 "lock\n\t"
3920 "add{l}\t{$src2, $dst|$dst, $src2}", []>, LOCK;
3921
3922def LOCK_INC8m : I<0xFE, MRM0m, (outs), (ins i8mem :$dst),
3923 "lock\n\t"
3924 "inc{b}\t$dst", []>, LOCK;
3925def LOCK_INC16m : I<0xFF, MRM0m, (outs), (ins i16mem:$dst),
3926 "lock\n\t"
3927 "inc{w}\t$dst", []>, OpSize, LOCK;
3928def LOCK_INC32m : I<0xFF, MRM0m, (outs), (ins i32mem:$dst),
3929 "lock\n\t"
3930 "inc{l}\t$dst", []>, LOCK;
3931
3932def LOCK_SUB8mr : I<0x28, MRMDestMem, (outs), (ins i8mem :$dst, GR8 :$src2),
3933 "lock\n\t"
3934 "sub{b}\t{$src2, $dst|$dst, $src2}", []>, LOCK;
3935def LOCK_SUB16mr : I<0x29, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
3936 "lock\n\t"
3937 "sub{w}\t{$src2, $dst|$dst, $src2}", []>, OpSize, LOCK;
3938def LOCK_SUB32mr : I<0x29, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
3939 "lock\n\t"
3940 "sub{l}\t{$src2, $dst|$dst, $src2}", []>, LOCK;
3941def LOCK_SUB8mi : Ii8<0x80, MRM5m, (outs), (ins i8mem :$dst, i8imm:$src2),
3942 "lock\n\t"
3943 "sub{b}\t{$src2, $dst|$dst, $src2}", []>, LOCK;
3944def LOCK_SUB16mi : Ii16<0x81, MRM5m, (outs), (ins i16mem:$dst, i16imm:$src2),
3945 "lock\n\t"
3946 "sub{w}\t{$src2, $dst|$dst, $src2}", []>, OpSize, LOCK;
3947def LOCK_SUB32mi : Ii32<0x81, MRM5m, (outs), (ins i32mem:$dst, i32imm:$src2),
3948 "lock\n\t"
3949 "sub{l}\t{$src2, $dst|$dst, $src2}", []>, LOCK;
Sean Callanan2c48df22009-12-18 00:01:26 +00003950def LOCK_SUB16mi8 : Ii8<0x83, MRM5m, (outs), (ins i16mem:$dst, i16i8imm :$src2),
Evan Chengb723fb52009-07-30 08:33:02 +00003951 "lock\n\t"
3952 "sub{w}\t{$src2, $dst|$dst, $src2}", []>, OpSize, LOCK;
3953def LOCK_SUB32mi8 : Ii8<0x83, MRM5m, (outs), (ins i32mem:$dst, i32i8imm :$src2),
3954 "lock\n\t"
3955 "sub{l}\t{$src2, $dst|$dst, $src2}", []>, LOCK;
3956
3957def LOCK_DEC8m : I<0xFE, MRM1m, (outs), (ins i8mem :$dst),
3958 "lock\n\t"
3959 "dec{b}\t$dst", []>, LOCK;
3960def LOCK_DEC16m : I<0xFF, MRM1m, (outs), (ins i16mem:$dst),
3961 "lock\n\t"
3962 "dec{w}\t$dst", []>, OpSize, LOCK;
3963def LOCK_DEC32m : I<0xFF, MRM1m, (outs), (ins i32mem:$dst),
3964 "lock\n\t"
3965 "dec{l}\t$dst", []>, LOCK;
Dan Gohman1c286992009-10-20 18:14:49 +00003966}
Evan Chengb723fb52009-07-30 08:33:02 +00003967
Mon P Wang6bde9ec2008-06-25 08:15:39 +00003968// Atomic exchange, and, or, xor
Mon P Wang078a62d2008-05-05 19:05:59 +00003969let Constraints = "$val = $dst", Defs = [EFLAGS],
Dan Gohman30afe012009-10-29 18:10:34 +00003970 usesCustomInserter = 1 in {
Dan Gohman8aeb61f2008-05-12 20:22:45 +00003971def ATOMAND32 : I<0, Pseudo, (outs GR32:$dst),(ins i32mem:$ptr, GR32:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003972 "#ATOMAND32 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003973 [(set GR32:$dst, (atomic_load_and_32 addr:$ptr, GR32:$val))]>;
Dan Gohman8aeb61f2008-05-12 20:22:45 +00003974def ATOMOR32 : I<0, Pseudo, (outs GR32:$dst),(ins i32mem:$ptr, GR32:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003975 "#ATOMOR32 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003976 [(set GR32:$dst, (atomic_load_or_32 addr:$ptr, GR32:$val))]>;
Dan Gohman8aeb61f2008-05-12 20:22:45 +00003977def ATOMXOR32 : I<0, Pseudo,(outs GR32:$dst),(ins i32mem:$ptr, GR32:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003978 "#ATOMXOR32 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003979 [(set GR32:$dst, (atomic_load_xor_32 addr:$ptr, GR32:$val))]>;
Andrew Lenharthaf02d592008-06-14 05:48:15 +00003980def ATOMNAND32 : I<0, Pseudo,(outs GR32:$dst),(ins i32mem:$ptr, GR32:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003981 "#ATOMNAND32 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003982 [(set GR32:$dst, (atomic_load_nand_32 addr:$ptr, GR32:$val))]>;
Dan Gohman8aeb61f2008-05-12 20:22:45 +00003983def ATOMMIN32: I<0, Pseudo, (outs GR32:$dst), (ins i32mem:$ptr, GR32:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003984 "#ATOMMIN32 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003985 [(set GR32:$dst, (atomic_load_min_32 addr:$ptr, GR32:$val))]>;
Dan Gohman8aeb61f2008-05-12 20:22:45 +00003986def ATOMMAX32: I<0, Pseudo, (outs GR32:$dst),(ins i32mem:$ptr, GR32:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003987 "#ATOMMAX32 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003988 [(set GR32:$dst, (atomic_load_max_32 addr:$ptr, GR32:$val))]>;
Dan Gohman8aeb61f2008-05-12 20:22:45 +00003989def ATOMUMIN32: I<0, Pseudo, (outs GR32:$dst),(ins i32mem:$ptr, GR32:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003990 "#ATOMUMIN32 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003991 [(set GR32:$dst, (atomic_load_umin_32 addr:$ptr, GR32:$val))]>;
Dan Gohman8aeb61f2008-05-12 20:22:45 +00003992def ATOMUMAX32: I<0, Pseudo, (outs GR32:$dst),(ins i32mem:$ptr, GR32:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003993 "#ATOMUMAX32 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003994 [(set GR32:$dst, (atomic_load_umax_32 addr:$ptr, GR32:$val))]>;
Dale Johannesend20e4452008-08-19 18:47:28 +00003995
3996def ATOMAND16 : I<0, Pseudo, (outs GR16:$dst),(ins i16mem:$ptr, GR16:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003997 "#ATOMAND16 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003998 [(set GR16:$dst, (atomic_load_and_16 addr:$ptr, GR16:$val))]>;
Dale Johannesend20e4452008-08-19 18:47:28 +00003999def ATOMOR16 : I<0, Pseudo, (outs GR16:$dst),(ins i16mem:$ptr, GR16:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00004000 "#ATOMOR16 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00004001 [(set GR16:$dst, (atomic_load_or_16 addr:$ptr, GR16:$val))]>;
Dale Johannesend20e4452008-08-19 18:47:28 +00004002def ATOMXOR16 : I<0, Pseudo,(outs GR16:$dst),(ins i16mem:$ptr, GR16:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00004003 "#ATOMXOR16 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00004004 [(set GR16:$dst, (atomic_load_xor_16 addr:$ptr, GR16:$val))]>;
Dale Johannesend20e4452008-08-19 18:47:28 +00004005def ATOMNAND16 : I<0, Pseudo,(outs GR16:$dst),(ins i16mem:$ptr, GR16:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00004006 "#ATOMNAND16 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00004007 [(set GR16:$dst, (atomic_load_nand_16 addr:$ptr, GR16:$val))]>;
Dale Johannesend20e4452008-08-19 18:47:28 +00004008def ATOMMIN16: I<0, Pseudo, (outs GR16:$dst), (ins i16mem:$ptr, GR16:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00004009 "#ATOMMIN16 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00004010 [(set GR16:$dst, (atomic_load_min_16 addr:$ptr, GR16:$val))]>;
Dale Johannesend20e4452008-08-19 18:47:28 +00004011def ATOMMAX16: I<0, Pseudo, (outs GR16:$dst),(ins i16mem:$ptr, GR16:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00004012 "#ATOMMAX16 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00004013 [(set GR16:$dst, (atomic_load_max_16 addr:$ptr, GR16:$val))]>;
Dale Johannesend20e4452008-08-19 18:47:28 +00004014def ATOMUMIN16: I<0, Pseudo, (outs GR16:$dst),(ins i16mem:$ptr, GR16:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00004015 "#ATOMUMIN16 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00004016 [(set GR16:$dst, (atomic_load_umin_16 addr:$ptr, GR16:$val))]>;
Dale Johannesend20e4452008-08-19 18:47:28 +00004017def ATOMUMAX16: I<0, Pseudo, (outs GR16:$dst),(ins i16mem:$ptr, GR16:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00004018 "#ATOMUMAX16 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00004019 [(set GR16:$dst, (atomic_load_umax_16 addr:$ptr, GR16:$val))]>;
Dale Johannesend20e4452008-08-19 18:47:28 +00004020
4021def ATOMAND8 : I<0, Pseudo, (outs GR8:$dst),(ins i8mem:$ptr, GR8:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00004022 "#ATOMAND8 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00004023 [(set GR8:$dst, (atomic_load_and_8 addr:$ptr, GR8:$val))]>;
Dale Johannesend20e4452008-08-19 18:47:28 +00004024def ATOMOR8 : I<0, Pseudo, (outs GR8:$dst),(ins i8mem:$ptr, GR8:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00004025 "#ATOMOR8 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00004026 [(set GR8:$dst, (atomic_load_or_8 addr:$ptr, GR8:$val))]>;
Dale Johannesend20e4452008-08-19 18:47:28 +00004027def ATOMXOR8 : I<0, Pseudo,(outs GR8:$dst),(ins i8mem:$ptr, GR8:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00004028 "#ATOMXOR8 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00004029 [(set GR8:$dst, (atomic_load_xor_8 addr:$ptr, GR8:$val))]>;
Dale Johannesend20e4452008-08-19 18:47:28 +00004030def ATOMNAND8 : I<0, Pseudo,(outs GR8:$dst),(ins i8mem:$ptr, GR8:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00004031 "#ATOMNAND8 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00004032 [(set GR8:$dst, (atomic_load_nand_8 addr:$ptr, GR8:$val))]>;
Mon P Wang078a62d2008-05-05 19:05:59 +00004033}
4034
Dale Johannesenf160d802008-10-02 18:53:47 +00004035let Constraints = "$val1 = $dst1, $val2 = $dst2",
4036 Defs = [EFLAGS, EAX, EBX, ECX, EDX],
4037 Uses = [EAX, EBX, ECX, EDX],
Dale Johannesen44eb5372008-10-03 19:41:08 +00004038 mayLoad = 1, mayStore = 1,
Dan Gohman30afe012009-10-29 18:10:34 +00004039 usesCustomInserter = 1 in {
Dale Johannesenf160d802008-10-02 18:53:47 +00004040def ATOMAND6432 : I<0, Pseudo, (outs GR32:$dst1, GR32:$dst2),
4041 (ins i64mem:$ptr, GR32:$val1, GR32:$val2),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00004042 "#ATOMAND6432 PSEUDO!", []>;
Dale Johannesenf160d802008-10-02 18:53:47 +00004043def ATOMOR6432 : I<0, Pseudo, (outs GR32:$dst1, GR32:$dst2),
4044 (ins i64mem:$ptr, GR32:$val1, GR32:$val2),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00004045 "#ATOMOR6432 PSEUDO!", []>;
Dale Johannesenf160d802008-10-02 18:53:47 +00004046def ATOMXOR6432 : I<0, Pseudo, (outs GR32:$dst1, GR32:$dst2),
4047 (ins i64mem:$ptr, GR32:$val1, GR32:$val2),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00004048 "#ATOMXOR6432 PSEUDO!", []>;
Dale Johannesenf160d802008-10-02 18:53:47 +00004049def ATOMNAND6432 : I<0, Pseudo, (outs GR32:$dst1, GR32:$dst2),
4050 (ins i64mem:$ptr, GR32:$val1, GR32:$val2),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00004051 "#ATOMNAND6432 PSEUDO!", []>;
Dale Johannesenf160d802008-10-02 18:53:47 +00004052def ATOMADD6432 : I<0, Pseudo, (outs GR32:$dst1, GR32:$dst2),
4053 (ins i64mem:$ptr, GR32:$val1, GR32:$val2),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00004054 "#ATOMADD6432 PSEUDO!", []>;
Dale Johannesenf160d802008-10-02 18:53:47 +00004055def ATOMSUB6432 : I<0, Pseudo, (outs GR32:$dst1, GR32:$dst2),
4056 (ins i64mem:$ptr, GR32:$val1, GR32:$val2),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00004057 "#ATOMSUB6432 PSEUDO!", []>;
Dale Johannesen51c58ee2008-10-03 22:25:52 +00004058def ATOMSWAP6432 : I<0, Pseudo, (outs GR32:$dst1, GR32:$dst2),
4059 (ins i64mem:$ptr, GR32:$val1, GR32:$val2),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00004060 "#ATOMSWAP6432 PSEUDO!", []>;
Dale Johannesenf160d802008-10-02 18:53:47 +00004061}
4062
Sean Callanan2eddf5d2009-09-16 21:55:34 +00004063// Segmentation support instructions.
4064
4065def LAR16rm : I<0x02, MRMSrcMem, (outs GR16:$dst), (ins i16mem:$src),
4066 "lar{w}\t{$src, $dst|$dst, $src}", []>, TB, OpSize;
4067def LAR16rr : I<0x02, MRMSrcReg, (outs GR16:$dst), (ins GR16:$src),
4068 "lar{w}\t{$src, $dst|$dst, $src}", []>, TB, OpSize;
4069
4070// i16mem operand in LAR32rm and GR32 operand in LAR32rr is not a typo.
4071def LAR32rm : I<0x02, MRMSrcMem, (outs GR32:$dst), (ins i16mem:$src),
4072 "lar{l}\t{$src, $dst|$dst, $src}", []>, TB;
4073def LAR32rr : I<0x02, MRMSrcReg, (outs GR32:$dst), (ins GR32:$src),
4074 "lar{l}\t{$src, $dst|$dst, $src}", []>, TB;
Sean Callanan2c48df22009-12-18 00:01:26 +00004075
4076def LSL16rm : I<0x03, MRMSrcMem, (outs GR16:$dst), (ins i16mem:$src),
4077 "lsl{w}\t{$src, $dst|$dst, $src}", []>, TB, OpSize;
4078def LSL16rr : I<0x03, MRMSrcReg, (outs GR16:$dst), (ins GR16:$src),
4079 "lsl{w}\t{$src, $dst|$dst, $src}", []>, TB, OpSize;
4080def LSL32rm : I<0x03, MRMSrcMem, (outs GR32:$dst), (ins i32mem:$src),
4081 "lsl{l}\t{$src, $dst|$dst, $src}", []>, TB;
4082def LSL32rr : I<0x03, MRMSrcReg, (outs GR32:$dst), (ins GR32:$src),
4083 "lsl{l}\t{$src, $dst|$dst, $src}", []>, TB;
4084
4085def INVLPG : I<0x01, RawFrm, (outs), (ins), "invlpg", []>, TB;
4086
4087def STRr : I<0x00, MRM1r, (outs GR16:$dst), (ins),
4088 "str{w}\t{$dst}", []>, TB;
4089def STRm : I<0x00, MRM1m, (outs i16mem:$dst), (ins),
4090 "str{w}\t{$dst}", []>, TB;
4091def LTRr : I<0x00, MRM3r, (outs), (ins GR16:$src),
4092 "ltr{w}\t{$src}", []>, TB;
4093def LTRm : I<0x00, MRM3m, (outs), (ins i16mem:$src),
4094 "ltr{w}\t{$src}", []>, TB;
4095
4096def PUSHFS16 : I<0xa0, RawFrm, (outs), (ins),
4097 "push{w}\t%fs", []>, OpSize, TB;
4098def PUSHFS32 : I<0xa0, RawFrm, (outs), (ins),
4099 "push{l}\t%fs", []>, TB;
4100def PUSHGS16 : I<0xa8, RawFrm, (outs), (ins),
4101 "push{w}\t%gs", []>, OpSize, TB;
4102def PUSHGS32 : I<0xa8, RawFrm, (outs), (ins),
4103 "push{l}\t%gs", []>, TB;
4104
4105def POPFS16 : I<0xa1, RawFrm, (outs), (ins),
4106 "pop{w}\t%fs", []>, OpSize, TB;
4107def POPFS32 : I<0xa1, RawFrm, (outs), (ins),
4108 "pop{l}\t%fs", []>, TB;
4109def POPGS16 : I<0xa9, RawFrm, (outs), (ins),
4110 "pop{w}\t%gs", []>, OpSize, TB;
4111def POPGS32 : I<0xa9, RawFrm, (outs), (ins),
4112 "pop{l}\t%gs", []>, TB;
4113
4114def LDS16rm : I<0xc5, MRMSrcMem, (outs GR16:$dst), (ins opaque32mem:$src),
4115 "lds{w}\t{$src, $dst|$dst, $src}", []>, OpSize;
4116def LDS32rm : I<0xc5, MRMSrcMem, (outs GR32:$dst), (ins opaque48mem:$src),
4117 "lds{l}\t{$src, $dst|$dst, $src}", []>;
4118def LSS16rm : I<0xb2, MRMSrcMem, (outs GR16:$dst), (ins opaque32mem:$src),
4119 "lss{w}\t{$src, $dst|$dst, $src}", []>, TB, OpSize;
4120def LSS32rm : I<0xb2, MRMSrcMem, (outs GR32:$dst), (ins opaque48mem:$src),
4121 "lss{l}\t{$src, $dst|$dst, $src}", []>, TB;
4122def LES16rm : I<0xc4, MRMSrcMem, (outs GR16:$dst), (ins opaque32mem:$src),
4123 "les{w}\t{$src, $dst|$dst, $src}", []>, OpSize;
4124def LES32rm : I<0xc4, MRMSrcMem, (outs GR32:$dst), (ins opaque48mem:$src),
4125 "les{l}\t{$src, $dst|$dst, $src}", []>;
4126def LFS16rm : I<0xb4, MRMSrcMem, (outs GR16:$dst), (ins opaque32mem:$src),
4127 "lfs{w}\t{$src, $dst|$dst, $src}", []>, TB, OpSize;
4128def LFS32rm : I<0xb4, MRMSrcMem, (outs GR32:$dst), (ins opaque48mem:$src),
4129 "lfs{l}\t{$src, $dst|$dst, $src}", []>, TB;
4130def LGS16rm : I<0xb5, MRMSrcMem, (outs GR16:$dst), (ins opaque32mem:$src),
4131 "lgs{w}\t{$src, $dst|$dst, $src}", []>, TB, OpSize;
4132def LGS32rm : I<0xb5, MRMSrcMem, (outs GR32:$dst), (ins opaque48mem:$src),
4133 "lgs{l}\t{$src, $dst|$dst, $src}", []>, TB;
4134
4135def VERRr : I<0x00, MRM4r, (outs), (ins GR16:$seg),
4136 "verr\t$seg", []>, TB;
4137def VERRm : I<0x00, MRM4m, (outs), (ins i16mem:$seg),
4138 "verr\t$seg", []>, TB;
4139def VERWr : I<0x00, MRM5r, (outs), (ins GR16:$seg),
4140 "verw\t$seg", []>, TB;
4141def VERWm : I<0x00, MRM5m, (outs), (ins i16mem:$seg),
4142 "verw\t$seg", []>, TB;
4143
4144// Descriptor-table support instructions
4145
4146def SGDTm : I<0x01, MRM0m, (outs opaque48mem:$dst), (ins),
4147 "sgdt\t$dst", []>, TB;
4148def SIDTm : I<0x01, MRM1m, (outs opaque48mem:$dst), (ins),
4149 "sidt\t$dst", []>, TB;
4150def SLDT16r : I<0x00, MRM0r, (outs GR16:$dst), (ins),
4151 "sldt{w}\t$dst", []>, TB;
4152def SLDT16m : I<0x00, MRM0m, (outs i16mem:$dst), (ins),
4153 "sldt{w}\t$dst", []>, TB;
4154def LGDTm : I<0x01, MRM2m, (outs), (ins opaque48mem:$src),
4155 "lgdt\t$src", []>, TB;
4156def LIDTm : I<0x01, MRM3m, (outs), (ins opaque48mem:$src),
4157 "lidt\t$src", []>, TB;
4158def LLDT16r : I<0x00, MRM2r, (outs), (ins GR16:$src),
4159 "lldt{w}\t$src", []>, TB;
4160def LLDT16m : I<0x00, MRM2m, (outs), (ins i16mem:$src),
4161 "lldt{w}\t$src", []>, TB;
Sean Callanan23f33d72009-09-16 22:59:28 +00004162
4163// String manipulation instructions
4164
4165def LODSB : I<0xAC, RawFrm, (outs), (ins), "lodsb", []>;
4166def LODSW : I<0xAD, RawFrm, (outs), (ins), "lodsw", []>, OpSize;
Sean Callanan2c48df22009-12-18 00:01:26 +00004167def LODSD : I<0xAD, RawFrm, (outs), (ins), "lods{l|d}", []>;
4168
4169def OUTSB : I<0x6E, RawFrm, (outs), (ins), "outsb", []>;
4170def OUTSW : I<0x6F, RawFrm, (outs), (ins), "outsw", []>, OpSize;
4171def OUTSD : I<0x6F, RawFrm, (outs), (ins), "outs{l|d}", []>;
4172
4173// CPU flow control instructions
4174
4175def HLT : I<0xF4, RawFrm, (outs), (ins), "hlt", []>;
4176def RSM : I<0xAA, RawFrm, (outs), (ins), "rsm", []>, TB;
4177
4178// FPU control instructions
4179
4180def FNINIT : I<0xE3, RawFrm, (outs), (ins), "fninit", []>, DB;
4181
4182// Flag instructions
4183
4184def CLC : I<0xF8, RawFrm, (outs), (ins), "clc", []>;
4185def STC : I<0xF9, RawFrm, (outs), (ins), "stc", []>;
4186def CLI : I<0xFA, RawFrm, (outs), (ins), "cli", []>;
4187def STI : I<0xFB, RawFrm, (outs), (ins), "sti", []>;
4188def CLD : I<0xFC, RawFrm, (outs), (ins), "cld", []>;
4189def STD : I<0xFD, RawFrm, (outs), (ins), "std", []>;
4190def CMC : I<0xF5, RawFrm, (outs), (ins), "cmc", []>;
4191
4192def CLTS : I<0x06, RawFrm, (outs), (ins), "clts", []>, TB;
4193
4194// Table lookup instructions
4195
4196def XLAT : I<0xD7, RawFrm, (outs), (ins), "xlatb", []>;
4197
4198// Specialized register support
4199
4200def WRMSR : I<0x30, RawFrm, (outs), (ins), "wrmsr", []>, TB;
4201def RDMSR : I<0x32, RawFrm, (outs), (ins), "rdmsr", []>, TB;
4202def RDPMC : I<0x33, RawFrm, (outs), (ins), "rdpmc", []>, TB;
4203
4204def SMSW16r : I<0x01, MRM4r, (outs GR16:$dst), (ins),
4205 "smsw{w}\t$dst", []>, OpSize, TB;
4206def SMSW32r : I<0x01, MRM4r, (outs GR32:$dst), (ins),
4207 "smsw{l}\t$dst", []>, TB;
4208// For memory operands, there is only a 16-bit form
4209def SMSW16m : I<0x01, MRM4m, (outs i16mem:$dst), (ins),
4210 "smsw{w}\t$dst", []>, TB;
4211
4212def LMSW16r : I<0x01, MRM6r, (outs), (ins GR16:$src),
4213 "lmsw{w}\t$src", []>, TB;
4214def LMSW16m : I<0x01, MRM6m, (outs), (ins i16mem:$src),
4215 "lmsw{w}\t$src", []>, TB;
4216
4217def CPUID : I<0xA2, RawFrm, (outs), (ins), "cpuid", []>, TB;
4218
4219// Cache instructions
4220
4221def INVD : I<0x08, RawFrm, (outs), (ins), "invd", []>, TB;
4222def WBINVD : I<0x09, RawFrm, (outs), (ins), "wbinvd", []>, TB;
4223
4224// VMX instructions
4225
4226// 66 0F 38 80
4227def INVEPT : I<0x38, RawFrm, (outs), (ins), "invept", []>, OpSize, TB;
4228// 66 0F 38 81
4229def INVVPID : I<0x38, RawFrm, (outs), (ins), "invvpid", []>, OpSize, TB;
4230// 0F 01 C1
4231def VMCALL : I<0x01, RawFrm, (outs), (ins), "vmcall", []>, TB;
4232def VMCLEARm : I<0xC7, MRM6m, (outs), (ins i64mem:$vmcs),
4233 "vmclear\t$vmcs", []>, OpSize, TB;
4234// 0F 01 C2
4235def VMLAUNCH : I<0x01, RawFrm, (outs), (ins), "vmlaunch", []>, TB;
4236// 0F 01 C3
4237def VMRESUME : I<0x01, RawFrm, (outs), (ins), "vmresume", []>, TB;
4238def VMPTRLDm : I<0xC7, MRM6m, (outs), (ins i64mem:$vmcs),
4239 "vmptrld\t$vmcs", []>, TB;
4240def VMPTRSTm : I<0xC7, MRM7m, (outs i64mem:$vmcs), (ins),
4241 "vmptrst\t$vmcs", []>, TB;
4242def VMREAD64rm : I<0x78, MRMDestMem, (outs i64mem:$dst), (ins GR64:$src),
4243 "vmread{q}\t{$src, $dst|$dst, $src}", []>, TB;
4244def VMREAD64rr : I<0x78, MRMDestReg, (outs GR64:$dst), (ins GR64:$src),
4245 "vmread{q}\t{$src, $dst|$dst, $src}", []>, TB;
4246def VMREAD32rm : I<0x78, MRMDestMem, (outs i32mem:$dst), (ins GR32:$src),
4247 "vmread{l}\t{$src, $dst|$dst, $src}", []>, TB;
4248def VMREAD32rr : I<0x78, MRMDestReg, (outs GR32:$dst), (ins GR32:$src),
4249 "vmread{l}\t{$src, $dst|$dst, $src}", []>, TB;
4250def VMWRITE64rm : I<0x79, MRMSrcMem, (outs GR64:$dst), (ins i64mem:$src),
4251 "vmwrite{q}\t{$src, $dst|$dst, $src}", []>, TB;
4252def VMWRITE64rr : I<0x79, MRMSrcReg, (outs GR64:$dst), (ins GR64:$src),
4253 "vmwrite{q}\t{$src, $dst|$dst, $src}", []>, TB;
4254def VMWRITE32rm : I<0x79, MRMSrcMem, (outs GR32:$dst), (ins i32mem:$src),
4255 "vmwrite{l}\t{$src, $dst|$dst, $src}", []>, TB;
4256def VMWRITE32rr : I<0x79, MRMSrcReg, (outs GR32:$dst), (ins GR32:$src),
4257 "vmwrite{l}\t{$src, $dst|$dst, $src}", []>, TB;
4258// 0F 01 C4
4259def VMXOFF : I<0x01, RawFrm, (outs), (ins), "vmxoff", []>, OpSize;
4260def VMXON : I<0xC7, MRM6m, (outs), (ins i64mem:$vmxon),
4261 "vmxon\t{$vmxon}", []>, XD;
Sean Callanan2eddf5d2009-09-16 21:55:34 +00004262
Andrew Lenharthe44f3902008-02-21 06:45:13 +00004263//===----------------------------------------------------------------------===//
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004264// Non-Instruction Patterns
4265//===----------------------------------------------------------------------===//
4266
Bill Wendlingfef06052008-09-16 21:48:12 +00004267// ConstantPool GlobalAddress, ExternalSymbol, and JumpTable
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004268def : Pat<(i32 (X86Wrapper tconstpool :$dst)), (MOV32ri tconstpool :$dst)>;
4269def : Pat<(i32 (X86Wrapper tjumptable :$dst)), (MOV32ri tjumptable :$dst)>;
Nate Begemanb52948972008-04-12 00:47:57 +00004270def : Pat<(i32 (X86Wrapper tglobaltlsaddr:$dst)),(MOV32ri tglobaltlsaddr:$dst)>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004271def : Pat<(i32 (X86Wrapper tglobaladdr :$dst)), (MOV32ri tglobaladdr :$dst)>;
4272def : Pat<(i32 (X86Wrapper texternalsym:$dst)), (MOV32ri texternalsym:$dst)>;
Dan Gohman064403e2009-10-30 01:28:02 +00004273def : Pat<(i32 (X86Wrapper tblockaddress:$dst)), (MOV32ri tblockaddress:$dst)>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004274
4275def : Pat<(add GR32:$src1, (X86Wrapper tconstpool:$src2)),
4276 (ADD32ri GR32:$src1, tconstpool:$src2)>;
4277def : Pat<(add GR32:$src1, (X86Wrapper tjumptable:$src2)),
4278 (ADD32ri GR32:$src1, tjumptable:$src2)>;
4279def : Pat<(add GR32:$src1, (X86Wrapper tglobaladdr :$src2)),
4280 (ADD32ri GR32:$src1, tglobaladdr:$src2)>;
4281def : Pat<(add GR32:$src1, (X86Wrapper texternalsym:$src2)),
4282 (ADD32ri GR32:$src1, texternalsym:$src2)>;
Dan Gohman064403e2009-10-30 01:28:02 +00004283def : Pat<(add GR32:$src1, (X86Wrapper tblockaddress:$src2)),
4284 (ADD32ri GR32:$src1, tblockaddress:$src2)>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004285
4286def : Pat<(store (i32 (X86Wrapper tglobaladdr:$src)), addr:$dst),
4287 (MOV32mi addr:$dst, tglobaladdr:$src)>;
4288def : Pat<(store (i32 (X86Wrapper texternalsym:$src)), addr:$dst),
4289 (MOV32mi addr:$dst, texternalsym:$src)>;
Dan Gohman064403e2009-10-30 01:28:02 +00004290def : Pat<(store (i32 (X86Wrapper tblockaddress:$src)), addr:$dst),
4291 (MOV32mi addr:$dst, tblockaddress:$src)>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004292
4293// Calls
Arnold Schwaighofere2d6bbb2007-10-11 19:40:01 +00004294// tailcall stuff
Arnold Schwaighofere2d6bbb2007-10-11 19:40:01 +00004295def : Pat<(X86tcret GR32:$dst, imm:$off),
4296 (TCRETURNri GR32:$dst, imm:$off)>;
4297
4298def : Pat<(X86tcret (i32 tglobaladdr:$dst), imm:$off),
4299 (TCRETURNdi texternalsym:$dst, imm:$off)>;
4300
4301def : Pat<(X86tcret (i32 texternalsym:$dst), imm:$off),
4302 (TCRETURNdi texternalsym:$dst, imm:$off)>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004303
Dan Gohmance5dbff2009-08-02 16:10:01 +00004304// Normal calls, with various flavors of addresses.
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004305def : Pat<(X86call (i32 tglobaladdr:$dst)),
4306 (CALLpcrel32 tglobaladdr:$dst)>;
4307def : Pat<(X86call (i32 texternalsym:$dst)),
4308 (CALLpcrel32 texternalsym:$dst)>;
Evan Cheng6d35a4d2009-05-20 04:53:57 +00004309def : Pat<(X86call (i32 imm:$dst)),
4310 (CALLpcrel32 imm:$dst)>, Requires<[CallImmAddr]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004311
4312// X86 specific add which produces a flag.
4313def : Pat<(addc GR32:$src1, GR32:$src2),
4314 (ADD32rr GR32:$src1, GR32:$src2)>;
4315def : Pat<(addc GR32:$src1, (load addr:$src2)),
4316 (ADD32rm GR32:$src1, addr:$src2)>;
4317def : Pat<(addc GR32:$src1, imm:$src2),
4318 (ADD32ri GR32:$src1, imm:$src2)>;
4319def : Pat<(addc GR32:$src1, i32immSExt8:$src2),
4320 (ADD32ri8 GR32:$src1, i32immSExt8:$src2)>;
4321
4322def : Pat<(subc GR32:$src1, GR32:$src2),
4323 (SUB32rr GR32:$src1, GR32:$src2)>;
4324def : Pat<(subc GR32:$src1, (load addr:$src2)),
4325 (SUB32rm GR32:$src1, addr:$src2)>;
4326def : Pat<(subc GR32:$src1, imm:$src2),
4327 (SUB32ri GR32:$src1, imm:$src2)>;
4328def : Pat<(subc GR32:$src1, i32immSExt8:$src2),
4329 (SUB32ri8 GR32:$src1, i32immSExt8:$src2)>;
4330
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004331// Comparisons.
4332
4333// TEST R,R is smaller than CMP R,0
Evan Cheng621216e2007-09-29 00:00:36 +00004334def : Pat<(parallel (X86cmp GR8:$src1, 0), (implicit EFLAGS)),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004335 (TEST8rr GR8:$src1, GR8:$src1)>;
Evan Cheng621216e2007-09-29 00:00:36 +00004336def : Pat<(parallel (X86cmp GR16:$src1, 0), (implicit EFLAGS)),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004337 (TEST16rr GR16:$src1, GR16:$src1)>;
Evan Cheng621216e2007-09-29 00:00:36 +00004338def : Pat<(parallel (X86cmp GR32:$src1, 0), (implicit EFLAGS)),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004339 (TEST32rr GR32:$src1, GR32:$src1)>;
4340
Dan Gohman0a3c5222009-01-07 01:00:24 +00004341// Conditional moves with folded loads with operands swapped and conditions
4342// inverted.
4343def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_B, EFLAGS),
4344 (CMOVAE16rm GR16:$src2, addr:$src1)>;
4345def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_B, EFLAGS),
4346 (CMOVAE32rm GR32:$src2, addr:$src1)>;
4347def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_AE, EFLAGS),
4348 (CMOVB16rm GR16:$src2, addr:$src1)>;
4349def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_AE, EFLAGS),
4350 (CMOVB32rm GR32:$src2, addr:$src1)>;
4351def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_E, EFLAGS),
4352 (CMOVNE16rm GR16:$src2, addr:$src1)>;
4353def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_E, EFLAGS),
4354 (CMOVNE32rm GR32:$src2, addr:$src1)>;
4355def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_NE, EFLAGS),
4356 (CMOVE16rm GR16:$src2, addr:$src1)>;
4357def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_NE, EFLAGS),
4358 (CMOVE32rm GR32:$src2, addr:$src1)>;
4359def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_BE, EFLAGS),
4360 (CMOVA16rm GR16:$src2, addr:$src1)>;
4361def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_BE, EFLAGS),
4362 (CMOVA32rm GR32:$src2, addr:$src1)>;
4363def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_A, EFLAGS),
4364 (CMOVBE16rm GR16:$src2, addr:$src1)>;
4365def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_A, EFLAGS),
4366 (CMOVBE32rm GR32:$src2, addr:$src1)>;
4367def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_L, EFLAGS),
4368 (CMOVGE16rm GR16:$src2, addr:$src1)>;
4369def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_L, EFLAGS),
4370 (CMOVGE32rm GR32:$src2, addr:$src1)>;
4371def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_GE, EFLAGS),
4372 (CMOVL16rm GR16:$src2, addr:$src1)>;
4373def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_GE, EFLAGS),
4374 (CMOVL32rm GR32:$src2, addr:$src1)>;
4375def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_LE, EFLAGS),
4376 (CMOVG16rm GR16:$src2, addr:$src1)>;
4377def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_LE, EFLAGS),
4378 (CMOVG32rm GR32:$src2, addr:$src1)>;
4379def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_G, EFLAGS),
4380 (CMOVLE16rm GR16:$src2, addr:$src1)>;
4381def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_G, EFLAGS),
4382 (CMOVLE32rm GR32:$src2, addr:$src1)>;
4383def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_P, EFLAGS),
4384 (CMOVNP16rm GR16:$src2, addr:$src1)>;
4385def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_P, EFLAGS),
4386 (CMOVNP32rm GR32:$src2, addr:$src1)>;
4387def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_NP, EFLAGS),
4388 (CMOVP16rm GR16:$src2, addr:$src1)>;
4389def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_NP, EFLAGS),
4390 (CMOVP32rm GR32:$src2, addr:$src1)>;
4391def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_S, EFLAGS),
4392 (CMOVNS16rm GR16:$src2, addr:$src1)>;
4393def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_S, EFLAGS),
4394 (CMOVNS32rm GR32:$src2, addr:$src1)>;
4395def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_NS, EFLAGS),
4396 (CMOVS16rm GR16:$src2, addr:$src1)>;
4397def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_NS, EFLAGS),
4398 (CMOVS32rm GR32:$src2, addr:$src1)>;
4399def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_O, EFLAGS),
4400 (CMOVNO16rm GR16:$src2, addr:$src1)>;
4401def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_O, EFLAGS),
4402 (CMOVNO32rm GR32:$src2, addr:$src1)>;
4403def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_NO, EFLAGS),
4404 (CMOVO16rm GR16:$src2, addr:$src1)>;
4405def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_NO, EFLAGS),
4406 (CMOVO32rm GR32:$src2, addr:$src1)>;
4407
Duncan Sands082524c2008-01-23 20:39:46 +00004408// zextload bool -> zextload byte
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004409def : Pat<(zextloadi8i1 addr:$src), (MOV8rm addr:$src)>;
4410def : Pat<(zextloadi16i1 addr:$src), (MOVZX16rm8 addr:$src)>;
4411def : Pat<(zextloadi32i1 addr:$src), (MOVZX32rm8 addr:$src)>;
4412
4413// extload bool -> extload byte
4414def : Pat<(extloadi8i1 addr:$src), (MOV8rm addr:$src)>;
Dan Gohman9959b052009-08-26 14:59:13 +00004415def : Pat<(extloadi16i1 addr:$src), (MOVZX16rm8 addr:$src)>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004416def : Pat<(extloadi32i1 addr:$src), (MOVZX32rm8 addr:$src)>;
Dan Gohman9959b052009-08-26 14:59:13 +00004417def : Pat<(extloadi16i8 addr:$src), (MOVZX16rm8 addr:$src)>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004418def : Pat<(extloadi32i8 addr:$src), (MOVZX32rm8 addr:$src)>;
4419def : Pat<(extloadi32i16 addr:$src), (MOVZX32rm16 addr:$src)>;
4420
Dan Gohman9959b052009-08-26 14:59:13 +00004421// anyext. Define these to do an explicit zero-extend to
4422// avoid partial-register updates.
4423def : Pat<(i16 (anyext GR8 :$src)), (MOVZX16rr8 GR8 :$src)>;
4424def : Pat<(i32 (anyext GR8 :$src)), (MOVZX32rr8 GR8 :$src)>;
4425def : Pat<(i32 (anyext GR16:$src)), (MOVZX32rr16 GR16:$src)>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004426
Evan Chengf2abee72007-12-13 00:43:27 +00004427// (and (i32 load), 255) -> (zextload i8)
Evan Cheng1e5e5452008-09-29 17:26:18 +00004428def : Pat<(i32 (and (nvloadi32 addr:$src), (i32 255))),
4429 (MOVZX32rm8 addr:$src)>;
4430def : Pat<(i32 (and (nvloadi32 addr:$src), (i32 65535))),
4431 (MOVZX32rm16 addr:$src)>;
Evan Chengf2abee72007-12-13 00:43:27 +00004432
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004433//===----------------------------------------------------------------------===//
4434// Some peepholes
4435//===----------------------------------------------------------------------===//
4436
Dan Gohman5a5e6e92008-10-17 01:33:43 +00004437// Odd encoding trick: -128 fits into an 8-bit immediate field while
4438// +128 doesn't, so in this special case use a sub instead of an add.
4439def : Pat<(add GR16:$src1, 128),
4440 (SUB16ri8 GR16:$src1, -128)>;
4441def : Pat<(store (add (loadi16 addr:$dst), 128), addr:$dst),
4442 (SUB16mi8 addr:$dst, -128)>;
4443def : Pat<(add GR32:$src1, 128),
4444 (SUB32ri8 GR32:$src1, -128)>;
4445def : Pat<(store (add (loadi32 addr:$dst), 128), addr:$dst),
4446 (SUB32mi8 addr:$dst, -128)>;
4447
Dan Gohman9203ab42008-07-30 18:09:17 +00004448// r & (2^16-1) ==> movz
4449def : Pat<(and GR32:$src1, 0xffff),
Dan Gohman744d4622009-04-13 16:09:41 +00004450 (MOVZX32rr16 (EXTRACT_SUBREG GR32:$src1, x86_subreg_16bit))>;
Dan Gohman5beb1ff2008-08-06 18:27:21 +00004451// r & (2^8-1) ==> movz
4452def : Pat<(and GR32:$src1, 0xff),
Anton Korobeynikovd9331212009-11-02 00:11:39 +00004453 (MOVZX32rr8 (EXTRACT_SUBREG (i32 (COPY_TO_REGCLASS GR32:$src1,
4454 GR32_ABCD)),
Dan Gohman744d4622009-04-13 16:09:41 +00004455 x86_subreg_8bit))>,
Dan Gohman5beb1ff2008-08-06 18:27:21 +00004456 Requires<[In32BitMode]>;
4457// r & (2^8-1) ==> movz
4458def : Pat<(and GR16:$src1, 0xff),
Anton Korobeynikovd9331212009-11-02 00:11:39 +00004459 (MOVZX16rr8 (EXTRACT_SUBREG (i16 (COPY_TO_REGCLASS GR16:$src1,
4460 GR16_ABCD)),
Dan Gohman744d4622009-04-13 16:09:41 +00004461 x86_subreg_8bit))>,
Dan Gohmandd612bb2008-08-20 21:27:32 +00004462 Requires<[In32BitMode]>;
4463
4464// sext_inreg patterns
4465def : Pat<(sext_inreg GR32:$src, i16),
Dan Gohman744d4622009-04-13 16:09:41 +00004466 (MOVSX32rr16 (EXTRACT_SUBREG GR32:$src, x86_subreg_16bit))>;
Dan Gohmandd612bb2008-08-20 21:27:32 +00004467def : Pat<(sext_inreg GR32:$src, i8),
Anton Korobeynikovd9331212009-11-02 00:11:39 +00004468 (MOVSX32rr8 (EXTRACT_SUBREG (i32 (COPY_TO_REGCLASS GR32:$src,
4469 GR32_ABCD)),
Dan Gohman744d4622009-04-13 16:09:41 +00004470 x86_subreg_8bit))>,
Dan Gohmandd612bb2008-08-20 21:27:32 +00004471 Requires<[In32BitMode]>;
4472def : Pat<(sext_inreg GR16:$src, i8),
Anton Korobeynikovd9331212009-11-02 00:11:39 +00004473 (MOVSX16rr8 (EXTRACT_SUBREG (i16 (COPY_TO_REGCLASS GR16:$src,
4474 GR16_ABCD)),
Dan Gohman744d4622009-04-13 16:09:41 +00004475 x86_subreg_8bit))>,
Dan Gohmandd612bb2008-08-20 21:27:32 +00004476 Requires<[In32BitMode]>;
4477
4478// trunc patterns
4479def : Pat<(i16 (trunc GR32:$src)),
Dan Gohman744d4622009-04-13 16:09:41 +00004480 (EXTRACT_SUBREG GR32:$src, x86_subreg_16bit)>;
Dan Gohmandd612bb2008-08-20 21:27:32 +00004481def : Pat<(i8 (trunc GR32:$src)),
Anton Korobeynikovd9331212009-11-02 00:11:39 +00004482 (EXTRACT_SUBREG (i32 (COPY_TO_REGCLASS GR32:$src, GR32_ABCD)),
Dan Gohman744d4622009-04-13 16:09:41 +00004483 x86_subreg_8bit)>,
Dan Gohmandd612bb2008-08-20 21:27:32 +00004484 Requires<[In32BitMode]>;
4485def : Pat<(i8 (trunc GR16:$src)),
Anton Korobeynikovd9331212009-11-02 00:11:39 +00004486 (EXTRACT_SUBREG (i16 (COPY_TO_REGCLASS GR16:$src, GR16_ABCD)),
Dan Gohman744d4622009-04-13 16:09:41 +00004487 x86_subreg_8bit)>,
4488 Requires<[In32BitMode]>;
4489
4490// h-register tricks
4491def : Pat<(i8 (trunc (srl_su GR16:$src, (i8 8)))),
Anton Korobeynikovd9331212009-11-02 00:11:39 +00004492 (EXTRACT_SUBREG (i32 (COPY_TO_REGCLASS GR16:$src, GR16_ABCD)),
Dan Gohman744d4622009-04-13 16:09:41 +00004493 x86_subreg_8bit_hi)>,
4494 Requires<[In32BitMode]>;
4495def : Pat<(i8 (trunc (srl_su GR32:$src, (i8 8)))),
Anton Korobeynikovd9331212009-11-02 00:11:39 +00004496 (EXTRACT_SUBREG (i16 (COPY_TO_REGCLASS GR32:$src, GR32_ABCD)),
Dan Gohman744d4622009-04-13 16:09:41 +00004497 x86_subreg_8bit_hi)>,
4498 Requires<[In32BitMode]>;
Dan Gohman5d8f9df2010-01-11 17:21:05 +00004499def : Pat<(srl GR16:$src, (i8 8)),
Dan Gohman744d4622009-04-13 16:09:41 +00004500 (EXTRACT_SUBREG
4501 (MOVZX32rr8
Anton Korobeynikovd9331212009-11-02 00:11:39 +00004502 (EXTRACT_SUBREG (i16 (COPY_TO_REGCLASS GR16:$src, GR16_ABCD)),
Dan Gohman744d4622009-04-13 16:09:41 +00004503 x86_subreg_8bit_hi)),
4504 x86_subreg_16bit)>,
4505 Requires<[In32BitMode]>;
Evan Cheng957ca282009-05-29 01:44:43 +00004506def : Pat<(i32 (zext (srl_su GR16:$src, (i8 8)))),
Sean Callanan2c48df22009-12-18 00:01:26 +00004507 (MOVZX32rr8 (EXTRACT_SUBREG (i16 (COPY_TO_REGCLASS GR16:$src,
4508 GR16_ABCD)),
Evan Cheng957ca282009-05-29 01:44:43 +00004509 x86_subreg_8bit_hi))>,
4510 Requires<[In32BitMode]>;
Dan Gohman9959b052009-08-26 14:59:13 +00004511def : Pat<(i32 (anyext (srl_su GR16:$src, (i8 8)))),
Sean Callanan2c48df22009-12-18 00:01:26 +00004512 (MOVZX32rr8 (EXTRACT_SUBREG (i16 (COPY_TO_REGCLASS GR16:$src,
4513 GR16_ABCD)),
Dan Gohman9959b052009-08-26 14:59:13 +00004514 x86_subreg_8bit_hi))>,
4515 Requires<[In32BitMode]>;
Dan Gohman744d4622009-04-13 16:09:41 +00004516def : Pat<(and (srl_su GR32:$src, (i8 8)), (i32 255)),
Sean Callanan2c48df22009-12-18 00:01:26 +00004517 (MOVZX32rr8 (EXTRACT_SUBREG (i32 (COPY_TO_REGCLASS GR32:$src,
4518 GR32_ABCD)),
Dan Gohman744d4622009-04-13 16:09:41 +00004519 x86_subreg_8bit_hi))>,
Dan Gohman5beb1ff2008-08-06 18:27:21 +00004520 Requires<[In32BitMode]>;
Dan Gohman9203ab42008-07-30 18:09:17 +00004521
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004522// (shl x, 1) ==> (add x, x)
4523def : Pat<(shl GR8 :$src1, (i8 1)), (ADD8rr GR8 :$src1, GR8 :$src1)>;
4524def : Pat<(shl GR16:$src1, (i8 1)), (ADD16rr GR16:$src1, GR16:$src1)>;
4525def : Pat<(shl GR32:$src1, (i8 1)), (ADD32rr GR32:$src1, GR32:$src1)>;
4526
Evan Cheng76a64c72008-08-30 02:03:58 +00004527// (shl x (and y, 31)) ==> (shl x, y)
4528def : Pat<(shl GR8:$src1, (and CL:$amt, 31)),
4529 (SHL8rCL GR8:$src1)>;
4530def : Pat<(shl GR16:$src1, (and CL:$amt, 31)),
4531 (SHL16rCL GR16:$src1)>;
4532def : Pat<(shl GR32:$src1, (and CL:$amt, 31)),
4533 (SHL32rCL GR32:$src1)>;
4534def : Pat<(store (shl (loadi8 addr:$dst), (and CL:$amt, 31)), addr:$dst),
4535 (SHL8mCL addr:$dst)>;
4536def : Pat<(store (shl (loadi16 addr:$dst), (and CL:$amt, 31)), addr:$dst),
4537 (SHL16mCL addr:$dst)>;
4538def : Pat<(store (shl (loadi32 addr:$dst), (and CL:$amt, 31)), addr:$dst),
4539 (SHL32mCL addr:$dst)>;
4540
4541def : Pat<(srl GR8:$src1, (and CL:$amt, 31)),
4542 (SHR8rCL GR8:$src1)>;
4543def : Pat<(srl GR16:$src1, (and CL:$amt, 31)),
4544 (SHR16rCL GR16:$src1)>;
4545def : Pat<(srl GR32:$src1, (and CL:$amt, 31)),
4546 (SHR32rCL GR32:$src1)>;
4547def : Pat<(store (srl (loadi8 addr:$dst), (and CL:$amt, 31)), addr:$dst),
4548 (SHR8mCL addr:$dst)>;
4549def : Pat<(store (srl (loadi16 addr:$dst), (and CL:$amt, 31)), addr:$dst),
4550 (SHR16mCL addr:$dst)>;
4551def : Pat<(store (srl (loadi32 addr:$dst), (and CL:$amt, 31)), addr:$dst),
4552 (SHR32mCL addr:$dst)>;
4553
4554def : Pat<(sra GR8:$src1, (and CL:$amt, 31)),
4555 (SAR8rCL GR8:$src1)>;
4556def : Pat<(sra GR16:$src1, (and CL:$amt, 31)),
4557 (SAR16rCL GR16:$src1)>;
4558def : Pat<(sra GR32:$src1, (and CL:$amt, 31)),
4559 (SAR32rCL GR32:$src1)>;
4560def : Pat<(store (sra (loadi8 addr:$dst), (and CL:$amt, 31)), addr:$dst),
4561 (SAR8mCL addr:$dst)>;
4562def : Pat<(store (sra (loadi16 addr:$dst), (and CL:$amt, 31)), addr:$dst),
4563 (SAR16mCL addr:$dst)>;
4564def : Pat<(store (sra (loadi32 addr:$dst), (and CL:$amt, 31)), addr:$dst),
4565 (SAR32mCL addr:$dst)>;
4566
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004567// (or (x >> c) | (y << (32 - c))) ==> (shrd32 x, y, c)
4568def : Pat<(or (srl GR32:$src1, CL:$amt),
4569 (shl GR32:$src2, (sub 32, CL:$amt))),
4570 (SHRD32rrCL GR32:$src1, GR32:$src2)>;
4571
4572def : Pat<(store (or (srl (loadi32 addr:$dst), CL:$amt),
4573 (shl GR32:$src2, (sub 32, CL:$amt))), addr:$dst),
4574 (SHRD32mrCL addr:$dst, GR32:$src2)>;
4575
Dan Gohman921581d2008-10-17 01:23:35 +00004576def : Pat<(or (srl GR32:$src1, (i8 (trunc ECX:$amt))),
4577 (shl GR32:$src2, (i8 (trunc (sub 32, ECX:$amt))))),
4578 (SHRD32rrCL GR32:$src1, GR32:$src2)>;
4579
4580def : Pat<(store (or (srl (loadi32 addr:$dst), (i8 (trunc ECX:$amt))),
4581 (shl GR32:$src2, (i8 (trunc (sub 32, ECX:$amt))))),
4582 addr:$dst),
4583 (SHRD32mrCL addr:$dst, GR32:$src2)>;
4584
4585def : Pat<(shrd GR32:$src1, (i8 imm:$amt1), GR32:$src2, (i8 imm:$amt2)),
4586 (SHRD32rri8 GR32:$src1, GR32:$src2, (i8 imm:$amt1))>;
4587
4588def : Pat<(store (shrd (loadi32 addr:$dst), (i8 imm:$amt1),
4589 GR32:$src2, (i8 imm:$amt2)), addr:$dst),
4590 (SHRD32mri8 addr:$dst, GR32:$src2, (i8 imm:$amt1))>;
4591
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004592// (or (x << c) | (y >> (32 - c))) ==> (shld32 x, y, c)
4593def : Pat<(or (shl GR32:$src1, CL:$amt),
4594 (srl GR32:$src2, (sub 32, CL:$amt))),
4595 (SHLD32rrCL GR32:$src1, GR32:$src2)>;
4596
4597def : Pat<(store (or (shl (loadi32 addr:$dst), CL:$amt),
4598 (srl GR32:$src2, (sub 32, CL:$amt))), addr:$dst),
4599 (SHLD32mrCL addr:$dst, GR32:$src2)>;
4600
Dan Gohman921581d2008-10-17 01:23:35 +00004601def : Pat<(or (shl GR32:$src1, (i8 (trunc ECX:$amt))),
4602 (srl GR32:$src2, (i8 (trunc (sub 32, ECX:$amt))))),
4603 (SHLD32rrCL GR32:$src1, GR32:$src2)>;
4604
4605def : Pat<(store (or (shl (loadi32 addr:$dst), (i8 (trunc ECX:$amt))),
4606 (srl GR32:$src2, (i8 (trunc (sub 32, ECX:$amt))))),
4607 addr:$dst),
4608 (SHLD32mrCL addr:$dst, GR32:$src2)>;
4609
4610def : Pat<(shld GR32:$src1, (i8 imm:$amt1), GR32:$src2, (i8 imm:$amt2)),
4611 (SHLD32rri8 GR32:$src1, GR32:$src2, (i8 imm:$amt1))>;
4612
4613def : Pat<(store (shld (loadi32 addr:$dst), (i8 imm:$amt1),
4614 GR32:$src2, (i8 imm:$amt2)), addr:$dst),
4615 (SHLD32mri8 addr:$dst, GR32:$src2, (i8 imm:$amt1))>;
4616
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004617// (or (x >> c) | (y << (16 - c))) ==> (shrd16 x, y, c)
4618def : Pat<(or (srl GR16:$src1, CL:$amt),
4619 (shl GR16:$src2, (sub 16, CL:$amt))),
4620 (SHRD16rrCL GR16:$src1, GR16:$src2)>;
4621
4622def : Pat<(store (or (srl (loadi16 addr:$dst), CL:$amt),
4623 (shl GR16:$src2, (sub 16, CL:$amt))), addr:$dst),
4624 (SHRD16mrCL addr:$dst, GR16:$src2)>;
4625
Dan Gohman921581d2008-10-17 01:23:35 +00004626def : Pat<(or (srl GR16:$src1, (i8 (trunc CX:$amt))),
4627 (shl GR16:$src2, (i8 (trunc (sub 16, CX:$amt))))),
4628 (SHRD16rrCL GR16:$src1, GR16:$src2)>;
4629
4630def : Pat<(store (or (srl (loadi16 addr:$dst), (i8 (trunc CX:$amt))),
4631 (shl GR16:$src2, (i8 (trunc (sub 16, CX:$amt))))),
4632 addr:$dst),
4633 (SHRD16mrCL addr:$dst, GR16:$src2)>;
4634
4635def : Pat<(shrd GR16:$src1, (i8 imm:$amt1), GR16:$src2, (i8 imm:$amt2)),
4636 (SHRD16rri8 GR16:$src1, GR16:$src2, (i8 imm:$amt1))>;
4637
4638def : Pat<(store (shrd (loadi16 addr:$dst), (i8 imm:$amt1),
4639 GR16:$src2, (i8 imm:$amt2)), addr:$dst),
4640 (SHRD16mri8 addr:$dst, GR16:$src2, (i8 imm:$amt1))>;
4641
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004642// (or (x << c) | (y >> (16 - c))) ==> (shld16 x, y, c)
4643def : Pat<(or (shl GR16:$src1, CL:$amt),
4644 (srl GR16:$src2, (sub 16, CL:$amt))),
4645 (SHLD16rrCL GR16:$src1, GR16:$src2)>;
4646
4647def : Pat<(store (or (shl (loadi16 addr:$dst), CL:$amt),
4648 (srl GR16:$src2, (sub 16, CL:$amt))), addr:$dst),
4649 (SHLD16mrCL addr:$dst, GR16:$src2)>;
4650
Dan Gohman921581d2008-10-17 01:23:35 +00004651def : Pat<(or (shl GR16:$src1, (i8 (trunc CX:$amt))),
4652 (srl GR16:$src2, (i8 (trunc (sub 16, CX:$amt))))),
4653 (SHLD16rrCL GR16:$src1, GR16:$src2)>;
4654
4655def : Pat<(store (or (shl (loadi16 addr:$dst), (i8 (trunc CX:$amt))),
4656 (srl GR16:$src2, (i8 (trunc (sub 16, CX:$amt))))),
4657 addr:$dst),
4658 (SHLD16mrCL addr:$dst, GR16:$src2)>;
4659
4660def : Pat<(shld GR16:$src1, (i8 imm:$amt1), GR16:$src2, (i8 imm:$amt2)),
4661 (SHLD16rri8 GR16:$src1, GR16:$src2, (i8 imm:$amt1))>;
4662
4663def : Pat<(store (shld (loadi16 addr:$dst), (i8 imm:$amt1),
4664 GR16:$src2, (i8 imm:$amt2)), addr:$dst),
4665 (SHLD16mri8 addr:$dst, GR16:$src2, (i8 imm:$amt1))>;
4666
Evan Chengedeb1692009-12-16 00:53:11 +00004667// (anyext (setcc_carry)) -> (setcc_carry)
4668def : Pat<(i16 (anyext (i8 (X86setcc_c X86_COND_B, EFLAGS)))),
Evan Cheng834ae6b2009-12-15 00:53:42 +00004669 (SETB_C16r)>;
Evan Chengedeb1692009-12-16 00:53:11 +00004670def : Pat<(i32 (anyext (i8 (X86setcc_c X86_COND_B, EFLAGS)))),
Evan Cheng834ae6b2009-12-15 00:53:42 +00004671 (SETB_C32r)>;
4672
Evan Cheng503d9c52010-01-11 22:03:29 +00004673// (or x1, x2) -> (add x1, x2) if two operands are known not to share bits.
Evan Cheng44a441c2010-01-12 18:31:19 +00004674let AddedComplexity = 5 in { // Try this before the selecting to OR
Evan Cheng4621d272010-01-11 17:03:47 +00004675def : Pat<(parallel (or_is_add GR16:$src1, imm:$src2),
4676 (implicit EFLAGS)),
4677 (ADD16ri GR16:$src1, imm:$src2)>;
4678def : Pat<(parallel (or_is_add GR32:$src1, imm:$src2),
4679 (implicit EFLAGS)),
4680 (ADD32ri GR32:$src1, imm:$src2)>;
4681def : Pat<(parallel (or_is_add GR16:$src1, i16immSExt8:$src2),
4682 (implicit EFLAGS)),
4683 (ADD16ri8 GR16:$src1, i16immSExt8:$src2)>;
4684def : Pat<(parallel (or_is_add GR32:$src1, i32immSExt8:$src2),
4685 (implicit EFLAGS)),
4686 (ADD32ri8 GR32:$src1, i32immSExt8:$src2)>;
Evan Cheng503d9c52010-01-11 22:03:29 +00004687def : Pat<(parallel (or_is_add GR16:$src1, GR16:$src2),
4688 (implicit EFLAGS)),
4689 (ADD16rr GR16:$src1, GR16:$src2)>;
4690def : Pat<(parallel (or_is_add GR32:$src1, GR32:$src2),
4691 (implicit EFLAGS)),
4692 (ADD32rr GR32:$src1, GR32:$src2)>;
Evan Cheng44a441c2010-01-12 18:31:19 +00004693} // AddedComplexity
Evan Cheng4621d272010-01-11 17:03:47 +00004694
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004695//===----------------------------------------------------------------------===//
Dan Gohman99a12192009-03-04 19:44:21 +00004696// EFLAGS-defining Patterns
Bill Wendlingf5399032008-12-12 21:15:41 +00004697//===----------------------------------------------------------------------===//
4698
Dan Gohman99a12192009-03-04 19:44:21 +00004699// Register-Register Addition with EFLAGS result
4700def : Pat<(parallel (X86add_flag GR8:$src1, GR8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004701 (implicit EFLAGS)),
4702 (ADD8rr GR8:$src1, GR8:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00004703def : Pat<(parallel (X86add_flag GR16:$src1, GR16:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004704 (implicit EFLAGS)),
4705 (ADD16rr GR16:$src1, GR16:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00004706def : Pat<(parallel (X86add_flag GR32:$src1, GR32:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004707 (implicit EFLAGS)),
4708 (ADD32rr GR32:$src1, GR32:$src2)>;
4709
Dan Gohman99a12192009-03-04 19:44:21 +00004710// Register-Memory Addition with EFLAGS result
4711def : Pat<(parallel (X86add_flag GR8:$src1, (loadi8 addr:$src2)),
Bill Wendlingf5399032008-12-12 21:15:41 +00004712 (implicit EFLAGS)),
4713 (ADD8rm GR8:$src1, addr:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00004714def : Pat<(parallel (X86add_flag GR16:$src1, (loadi16 addr:$src2)),
Bill Wendlingf5399032008-12-12 21:15:41 +00004715 (implicit EFLAGS)),
4716 (ADD16rm GR16:$src1, addr:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00004717def : Pat<(parallel (X86add_flag GR32:$src1, (loadi32 addr:$src2)),
Bill Wendlingf5399032008-12-12 21:15:41 +00004718 (implicit EFLAGS)),
4719 (ADD32rm GR32:$src1, addr:$src2)>;
4720
Dan Gohman99a12192009-03-04 19:44:21 +00004721// Register-Integer Addition with EFLAGS result
4722def : Pat<(parallel (X86add_flag GR8:$src1, imm:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004723 (implicit EFLAGS)),
4724 (ADD8ri GR8:$src1, imm:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00004725def : Pat<(parallel (X86add_flag GR16:$src1, imm:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004726 (implicit EFLAGS)),
4727 (ADD16ri GR16:$src1, imm:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00004728def : Pat<(parallel (X86add_flag GR32:$src1, imm:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004729 (implicit EFLAGS)),
4730 (ADD32ri GR32:$src1, imm:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00004731def : Pat<(parallel (X86add_flag GR16:$src1, i16immSExt8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004732 (implicit EFLAGS)),
4733 (ADD16ri8 GR16:$src1, i16immSExt8:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00004734def : Pat<(parallel (X86add_flag GR32:$src1, i32immSExt8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004735 (implicit EFLAGS)),
4736 (ADD32ri8 GR32:$src1, i32immSExt8:$src2)>;
4737
Dan Gohman99a12192009-03-04 19:44:21 +00004738// Memory-Register Addition with EFLAGS result
4739def : Pat<(parallel (store (X86add_flag (loadi8 addr:$dst), GR8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004740 addr:$dst),
4741 (implicit EFLAGS)),
4742 (ADD8mr addr:$dst, GR8:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00004743def : Pat<(parallel (store (X86add_flag (loadi16 addr:$dst), GR16:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004744 addr:$dst),
4745 (implicit EFLAGS)),
4746 (ADD16mr addr:$dst, GR16:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00004747def : Pat<(parallel (store (X86add_flag (loadi32 addr:$dst), GR32:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004748 addr:$dst),
4749 (implicit EFLAGS)),
4750 (ADD32mr addr:$dst, GR32:$src2)>;
Dale Johannesen06b83f12009-05-18 17:44:15 +00004751
4752// Memory-Integer Addition with EFLAGS result
Dan Gohman99a12192009-03-04 19:44:21 +00004753def : Pat<(parallel (store (X86add_flag (loadi8 addr:$dst), imm:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004754 addr:$dst),
4755 (implicit EFLAGS)),
4756 (ADD8mi addr:$dst, imm:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00004757def : Pat<(parallel (store (X86add_flag (loadi16 addr:$dst), imm:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004758 addr:$dst),
4759 (implicit EFLAGS)),
4760 (ADD16mi addr:$dst, imm:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00004761def : Pat<(parallel (store (X86add_flag (loadi32 addr:$dst), imm:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004762 addr:$dst),
4763 (implicit EFLAGS)),
4764 (ADD32mi addr:$dst, imm:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00004765def : Pat<(parallel (store (X86add_flag (loadi16 addr:$dst), i16immSExt8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004766 addr:$dst),
4767 (implicit EFLAGS)),
4768 (ADD16mi8 addr:$dst, i16immSExt8:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00004769def : Pat<(parallel (store (X86add_flag (loadi32 addr:$dst), i32immSExt8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004770 addr:$dst),
4771 (implicit EFLAGS)),
4772 (ADD32mi8 addr:$dst, i32immSExt8:$src2)>;
4773
Dan Gohman99a12192009-03-04 19:44:21 +00004774// Register-Register Subtraction with EFLAGS result
4775def : Pat<(parallel (X86sub_flag GR8:$src1, GR8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004776 (implicit EFLAGS)),
4777 (SUB8rr GR8:$src1, GR8:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00004778def : Pat<(parallel (X86sub_flag GR16:$src1, GR16:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004779 (implicit EFLAGS)),
4780 (SUB16rr GR16:$src1, GR16:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00004781def : Pat<(parallel (X86sub_flag GR32:$src1, GR32:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004782 (implicit EFLAGS)),
4783 (SUB32rr GR32:$src1, GR32:$src2)>;
4784
Dan Gohman99a12192009-03-04 19:44:21 +00004785// Register-Memory Subtraction with EFLAGS result
4786def : Pat<(parallel (X86sub_flag GR8:$src1, (loadi8 addr:$src2)),
Bill Wendlingf5399032008-12-12 21:15:41 +00004787 (implicit EFLAGS)),
4788 (SUB8rm GR8:$src1, addr:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00004789def : Pat<(parallel (X86sub_flag GR16:$src1, (loadi16 addr:$src2)),
Bill Wendlingf5399032008-12-12 21:15:41 +00004790 (implicit EFLAGS)),
4791 (SUB16rm GR16:$src1, addr:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00004792def : Pat<(parallel (X86sub_flag GR32:$src1, (loadi32 addr:$src2)),
Bill Wendlingf5399032008-12-12 21:15:41 +00004793 (implicit EFLAGS)),
4794 (SUB32rm GR32:$src1, addr:$src2)>;
4795
Dan Gohman99a12192009-03-04 19:44:21 +00004796// Register-Integer Subtraction with EFLAGS result
4797def : Pat<(parallel (X86sub_flag GR8:$src1, imm:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004798 (implicit EFLAGS)),
4799 (SUB8ri GR8:$src1, imm:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00004800def : Pat<(parallel (X86sub_flag GR16:$src1, imm:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004801 (implicit EFLAGS)),
4802 (SUB16ri GR16:$src1, imm:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00004803def : Pat<(parallel (X86sub_flag GR32:$src1, imm:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004804 (implicit EFLAGS)),
4805 (SUB32ri GR32:$src1, imm:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00004806def : Pat<(parallel (X86sub_flag GR16:$src1, i16immSExt8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004807 (implicit EFLAGS)),
4808 (SUB16ri8 GR16:$src1, i16immSExt8:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00004809def : Pat<(parallel (X86sub_flag GR32:$src1, i32immSExt8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004810 (implicit EFLAGS)),
4811 (SUB32ri8 GR32:$src1, i32immSExt8:$src2)>;
4812
Dan Gohman99a12192009-03-04 19:44:21 +00004813// Memory-Register Subtraction with EFLAGS result
4814def : Pat<(parallel (store (X86sub_flag (loadi8 addr:$dst), GR8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004815 addr:$dst),
4816 (implicit EFLAGS)),
4817 (SUB8mr addr:$dst, GR8:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00004818def : Pat<(parallel (store (X86sub_flag (loadi16 addr:$dst), GR16:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004819 addr:$dst),
4820 (implicit EFLAGS)),
4821 (SUB16mr addr:$dst, GR16:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00004822def : Pat<(parallel (store (X86sub_flag (loadi32 addr:$dst), GR32:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004823 addr:$dst),
4824 (implicit EFLAGS)),
4825 (SUB32mr addr:$dst, GR32:$src2)>;
4826
Dan Gohman99a12192009-03-04 19:44:21 +00004827// Memory-Integer Subtraction with EFLAGS result
4828def : Pat<(parallel (store (X86sub_flag (loadi8 addr:$dst), imm:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004829 addr:$dst),
4830 (implicit EFLAGS)),
4831 (SUB8mi addr:$dst, imm:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00004832def : Pat<(parallel (store (X86sub_flag (loadi16 addr:$dst), imm:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004833 addr:$dst),
4834 (implicit EFLAGS)),
4835 (SUB16mi addr:$dst, imm:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00004836def : Pat<(parallel (store (X86sub_flag (loadi32 addr:$dst), imm:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004837 addr:$dst),
4838 (implicit EFLAGS)),
4839 (SUB32mi addr:$dst, imm:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00004840def : Pat<(parallel (store (X86sub_flag (loadi16 addr:$dst), i16immSExt8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004841 addr:$dst),
4842 (implicit EFLAGS)),
4843 (SUB16mi8 addr:$dst, i16immSExt8:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00004844def : Pat<(parallel (store (X86sub_flag (loadi32 addr:$dst), i32immSExt8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004845 addr:$dst),
4846 (implicit EFLAGS)),
4847 (SUB32mi8 addr:$dst, i32immSExt8:$src2)>;
4848
4849
Dan Gohman99a12192009-03-04 19:44:21 +00004850// Register-Register Signed Integer Multiply with EFLAGS result
4851def : Pat<(parallel (X86smul_flag GR16:$src1, GR16:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004852 (implicit EFLAGS)),
4853 (IMUL16rr GR16:$src1, GR16:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00004854def : Pat<(parallel (X86smul_flag GR32:$src1, GR32:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004855 (implicit EFLAGS)),
4856 (IMUL32rr GR32:$src1, GR32:$src2)>;
4857
Dan Gohman99a12192009-03-04 19:44:21 +00004858// Register-Memory Signed Integer Multiply with EFLAGS result
4859def : Pat<(parallel (X86smul_flag GR16:$src1, (loadi16 addr:$src2)),
Bill Wendlingf5399032008-12-12 21:15:41 +00004860 (implicit EFLAGS)),
4861 (IMUL16rm GR16:$src1, addr:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00004862def : Pat<(parallel (X86smul_flag GR32:$src1, (loadi32 addr:$src2)),
Bill Wendlingf5399032008-12-12 21:15:41 +00004863 (implicit EFLAGS)),
4864 (IMUL32rm GR32:$src1, addr:$src2)>;
4865
Dan Gohman99a12192009-03-04 19:44:21 +00004866// Register-Integer Signed Integer Multiply with EFLAGS result
4867def : Pat<(parallel (X86smul_flag GR16:$src1, imm:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004868 (implicit EFLAGS)),
4869 (IMUL16rri GR16:$src1, imm:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00004870def : Pat<(parallel (X86smul_flag GR32:$src1, imm:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004871 (implicit EFLAGS)),
4872 (IMUL32rri GR32:$src1, imm:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00004873def : Pat<(parallel (X86smul_flag GR16:$src1, i16immSExt8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004874 (implicit EFLAGS)),
4875 (IMUL16rri8 GR16:$src1, i16immSExt8:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00004876def : Pat<(parallel (X86smul_flag GR32:$src1, i32immSExt8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004877 (implicit EFLAGS)),
4878 (IMUL32rri8 GR32:$src1, i32immSExt8:$src2)>;
4879
Dan Gohman99a12192009-03-04 19:44:21 +00004880// Memory-Integer Signed Integer Multiply with EFLAGS result
4881def : Pat<(parallel (X86smul_flag (loadi16 addr:$src1), imm:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004882 (implicit EFLAGS)),
4883 (IMUL16rmi addr:$src1, imm:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00004884def : Pat<(parallel (X86smul_flag (loadi32 addr:$src1), imm:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004885 (implicit EFLAGS)),
4886 (IMUL32rmi addr:$src1, imm:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00004887def : Pat<(parallel (X86smul_flag (loadi16 addr:$src1), i16immSExt8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004888 (implicit EFLAGS)),
4889 (IMUL16rmi8 addr:$src1, i16immSExt8:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00004890def : Pat<(parallel (X86smul_flag (loadi32 addr:$src1), i32immSExt8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004891 (implicit EFLAGS)),
4892 (IMUL32rmi8 addr:$src1, i32immSExt8:$src2)>;
4893
Dan Gohman99a12192009-03-04 19:44:21 +00004894// Optimize multiply by 2 with EFLAGS result.
Evan Cheng00cf7932009-01-27 03:30:42 +00004895let AddedComplexity = 2 in {
Dan Gohman99a12192009-03-04 19:44:21 +00004896def : Pat<(parallel (X86smul_flag GR16:$src1, 2),
Evan Cheng00cf7932009-01-27 03:30:42 +00004897 (implicit EFLAGS)),
4898 (ADD16rr GR16:$src1, GR16:$src1)>;
4899
Dan Gohman99a12192009-03-04 19:44:21 +00004900def : Pat<(parallel (X86smul_flag GR32:$src1, 2),
Evan Cheng00cf7932009-01-27 03:30:42 +00004901 (implicit EFLAGS)),
4902 (ADD32rr GR32:$src1, GR32:$src1)>;
4903}
4904
Dan Gohman99a12192009-03-04 19:44:21 +00004905// INC and DEC with EFLAGS result. Note that these do not set CF.
4906def : Pat<(parallel (X86inc_flag GR8:$src), (implicit EFLAGS)),
4907 (INC8r GR8:$src)>;
4908def : Pat<(parallel (store (i8 (X86inc_flag (loadi8 addr:$dst))), addr:$dst),
4909 (implicit EFLAGS)),
4910 (INC8m addr:$dst)>;
4911def : Pat<(parallel (X86dec_flag GR8:$src), (implicit EFLAGS)),
4912 (DEC8r GR8:$src)>;
4913def : Pat<(parallel (store (i8 (X86dec_flag (loadi8 addr:$dst))), addr:$dst),
4914 (implicit EFLAGS)),
4915 (DEC8m addr:$dst)>;
4916
4917def : Pat<(parallel (X86inc_flag GR16:$src), (implicit EFLAGS)),
Dan Gohmaneebcac72009-03-05 21:32:23 +00004918 (INC16r GR16:$src)>, Requires<[In32BitMode]>;
Dan Gohman99a12192009-03-04 19:44:21 +00004919def : Pat<(parallel (store (i16 (X86inc_flag (loadi16 addr:$dst))), addr:$dst),
4920 (implicit EFLAGS)),
Dan Gohmaneebcac72009-03-05 21:32:23 +00004921 (INC16m addr:$dst)>, Requires<[In32BitMode]>;
Dan Gohman99a12192009-03-04 19:44:21 +00004922def : Pat<(parallel (X86dec_flag GR16:$src), (implicit EFLAGS)),
Dan Gohmaneebcac72009-03-05 21:32:23 +00004923 (DEC16r GR16:$src)>, Requires<[In32BitMode]>;
Dan Gohman99a12192009-03-04 19:44:21 +00004924def : Pat<(parallel (store (i16 (X86dec_flag (loadi16 addr:$dst))), addr:$dst),
4925 (implicit EFLAGS)),
Dan Gohmaneebcac72009-03-05 21:32:23 +00004926 (DEC16m addr:$dst)>, Requires<[In32BitMode]>;
Dan Gohman99a12192009-03-04 19:44:21 +00004927
4928def : Pat<(parallel (X86inc_flag GR32:$src), (implicit EFLAGS)),
Dan Gohmaneebcac72009-03-05 21:32:23 +00004929 (INC32r GR32:$src)>, Requires<[In32BitMode]>;
Dan Gohman99a12192009-03-04 19:44:21 +00004930def : Pat<(parallel (store (i32 (X86inc_flag (loadi32 addr:$dst))), addr:$dst),
4931 (implicit EFLAGS)),
Dan Gohmaneebcac72009-03-05 21:32:23 +00004932 (INC32m addr:$dst)>, Requires<[In32BitMode]>;
Dan Gohman99a12192009-03-04 19:44:21 +00004933def : Pat<(parallel (X86dec_flag GR32:$src), (implicit EFLAGS)),
Dan Gohmaneebcac72009-03-05 21:32:23 +00004934 (DEC32r GR32:$src)>, Requires<[In32BitMode]>;
Dan Gohman99a12192009-03-04 19:44:21 +00004935def : Pat<(parallel (store (i32 (X86dec_flag (loadi32 addr:$dst))), addr:$dst),
4936 (implicit EFLAGS)),
Dan Gohmaneebcac72009-03-05 21:32:23 +00004937 (DEC32m addr:$dst)>, Requires<[In32BitMode]>;
Dan Gohman99a12192009-03-04 19:44:21 +00004938
Dan Gohman12e03292009-09-18 19:59:53 +00004939// Register-Register Or with EFLAGS result
4940def : Pat<(parallel (X86or_flag GR8:$src1, GR8:$src2),
4941 (implicit EFLAGS)),
4942 (OR8rr GR8:$src1, GR8:$src2)>;
4943def : Pat<(parallel (X86or_flag GR16:$src1, GR16:$src2),
4944 (implicit EFLAGS)),
4945 (OR16rr GR16:$src1, GR16:$src2)>;
4946def : Pat<(parallel (X86or_flag GR32:$src1, GR32:$src2),
4947 (implicit EFLAGS)),
4948 (OR32rr GR32:$src1, GR32:$src2)>;
4949
4950// Register-Memory Or with EFLAGS result
4951def : Pat<(parallel (X86or_flag GR8:$src1, (loadi8 addr:$src2)),
4952 (implicit EFLAGS)),
4953 (OR8rm GR8:$src1, addr:$src2)>;
4954def : Pat<(parallel (X86or_flag GR16:$src1, (loadi16 addr:$src2)),
4955 (implicit EFLAGS)),
4956 (OR16rm GR16:$src1, addr:$src2)>;
4957def : Pat<(parallel (X86or_flag GR32:$src1, (loadi32 addr:$src2)),
4958 (implicit EFLAGS)),
4959 (OR32rm GR32:$src1, addr:$src2)>;
4960
4961// Register-Integer Or with EFLAGS result
4962def : Pat<(parallel (X86or_flag GR8:$src1, imm:$src2),
4963 (implicit EFLAGS)),
4964 (OR8ri GR8:$src1, imm:$src2)>;
4965def : Pat<(parallel (X86or_flag GR16:$src1, imm:$src2),
4966 (implicit EFLAGS)),
4967 (OR16ri GR16:$src1, imm:$src2)>;
4968def : Pat<(parallel (X86or_flag GR32:$src1, imm:$src2),
4969 (implicit EFLAGS)),
4970 (OR32ri GR32:$src1, imm:$src2)>;
4971def : Pat<(parallel (X86or_flag GR16:$src1, i16immSExt8:$src2),
4972 (implicit EFLAGS)),
4973 (OR16ri8 GR16:$src1, i16immSExt8:$src2)>;
4974def : Pat<(parallel (X86or_flag GR32:$src1, i32immSExt8:$src2),
4975 (implicit EFLAGS)),
4976 (OR32ri8 GR32:$src1, i32immSExt8:$src2)>;
4977
4978// Memory-Register Or with EFLAGS result
4979def : Pat<(parallel (store (X86or_flag (loadi8 addr:$dst), GR8:$src2),
4980 addr:$dst),
4981 (implicit EFLAGS)),
4982 (OR8mr addr:$dst, GR8:$src2)>;
4983def : Pat<(parallel (store (X86or_flag (loadi16 addr:$dst), GR16:$src2),
4984 addr:$dst),
4985 (implicit EFLAGS)),
4986 (OR16mr addr:$dst, GR16:$src2)>;
4987def : Pat<(parallel (store (X86or_flag (loadi32 addr:$dst), GR32:$src2),
4988 addr:$dst),
4989 (implicit EFLAGS)),
4990 (OR32mr addr:$dst, GR32:$src2)>;
4991
4992// Memory-Integer Or with EFLAGS result
4993def : Pat<(parallel (store (X86or_flag (loadi8 addr:$dst), imm:$src2),
4994 addr:$dst),
4995 (implicit EFLAGS)),
4996 (OR8mi addr:$dst, imm:$src2)>;
4997def : Pat<(parallel (store (X86or_flag (loadi16 addr:$dst), imm:$src2),
4998 addr:$dst),
4999 (implicit EFLAGS)),
5000 (OR16mi addr:$dst, imm:$src2)>;
5001def : Pat<(parallel (store (X86or_flag (loadi32 addr:$dst), imm:$src2),
5002 addr:$dst),
5003 (implicit EFLAGS)),
5004 (OR32mi addr:$dst, imm:$src2)>;
5005def : Pat<(parallel (store (X86or_flag (loadi16 addr:$dst), i16immSExt8:$src2),
5006 addr:$dst),
5007 (implicit EFLAGS)),
5008 (OR16mi8 addr:$dst, i16immSExt8:$src2)>;
5009def : Pat<(parallel (store (X86or_flag (loadi32 addr:$dst), i32immSExt8:$src2),
5010 addr:$dst),
5011 (implicit EFLAGS)),
5012 (OR32mi8 addr:$dst, i32immSExt8:$src2)>;
5013
5014// Register-Register XOr with EFLAGS result
5015def : Pat<(parallel (X86xor_flag GR8:$src1, GR8:$src2),
5016 (implicit EFLAGS)),
5017 (XOR8rr GR8:$src1, GR8:$src2)>;
5018def : Pat<(parallel (X86xor_flag GR16:$src1, GR16:$src2),
5019 (implicit EFLAGS)),
5020 (XOR16rr GR16:$src1, GR16:$src2)>;
5021def : Pat<(parallel (X86xor_flag GR32:$src1, GR32:$src2),
5022 (implicit EFLAGS)),
5023 (XOR32rr GR32:$src1, GR32:$src2)>;
5024
5025// Register-Memory XOr with EFLAGS result
5026def : Pat<(parallel (X86xor_flag GR8:$src1, (loadi8 addr:$src2)),
5027 (implicit EFLAGS)),
5028 (XOR8rm GR8:$src1, addr:$src2)>;
5029def : Pat<(parallel (X86xor_flag GR16:$src1, (loadi16 addr:$src2)),
5030 (implicit EFLAGS)),
5031 (XOR16rm GR16:$src1, addr:$src2)>;
5032def : Pat<(parallel (X86xor_flag GR32:$src1, (loadi32 addr:$src2)),
5033 (implicit EFLAGS)),
5034 (XOR32rm GR32:$src1, addr:$src2)>;
5035
5036// Register-Integer XOr with EFLAGS result
5037def : Pat<(parallel (X86xor_flag GR8:$src1, imm:$src2),
5038 (implicit EFLAGS)),
5039 (XOR8ri GR8:$src1, imm:$src2)>;
5040def : Pat<(parallel (X86xor_flag GR16:$src1, imm:$src2),
5041 (implicit EFLAGS)),
5042 (XOR16ri GR16:$src1, imm:$src2)>;
5043def : Pat<(parallel (X86xor_flag GR32:$src1, imm:$src2),
5044 (implicit EFLAGS)),
5045 (XOR32ri GR32:$src1, imm:$src2)>;
5046def : Pat<(parallel (X86xor_flag GR16:$src1, i16immSExt8:$src2),
5047 (implicit EFLAGS)),
5048 (XOR16ri8 GR16:$src1, i16immSExt8:$src2)>;
5049def : Pat<(parallel (X86xor_flag GR32:$src1, i32immSExt8:$src2),
5050 (implicit EFLAGS)),
5051 (XOR32ri8 GR32:$src1, i32immSExt8:$src2)>;
5052
5053// Memory-Register XOr with EFLAGS result
5054def : Pat<(parallel (store (X86xor_flag (loadi8 addr:$dst), GR8:$src2),
5055 addr:$dst),
5056 (implicit EFLAGS)),
5057 (XOR8mr addr:$dst, GR8:$src2)>;
5058def : Pat<(parallel (store (X86xor_flag (loadi16 addr:$dst), GR16:$src2),
5059 addr:$dst),
5060 (implicit EFLAGS)),
5061 (XOR16mr addr:$dst, GR16:$src2)>;
5062def : Pat<(parallel (store (X86xor_flag (loadi32 addr:$dst), GR32:$src2),
5063 addr:$dst),
5064 (implicit EFLAGS)),
5065 (XOR32mr addr:$dst, GR32:$src2)>;
5066
5067// Memory-Integer XOr with EFLAGS result
5068def : Pat<(parallel (store (X86xor_flag (loadi8 addr:$dst), imm:$src2),
5069 addr:$dst),
5070 (implicit EFLAGS)),
5071 (XOR8mi addr:$dst, imm:$src2)>;
5072def : Pat<(parallel (store (X86xor_flag (loadi16 addr:$dst), imm:$src2),
5073 addr:$dst),
5074 (implicit EFLAGS)),
5075 (XOR16mi addr:$dst, imm:$src2)>;
5076def : Pat<(parallel (store (X86xor_flag (loadi32 addr:$dst), imm:$src2),
5077 addr:$dst),
5078 (implicit EFLAGS)),
5079 (XOR32mi addr:$dst, imm:$src2)>;
5080def : Pat<(parallel (store (X86xor_flag (loadi16 addr:$dst), i16immSExt8:$src2),
5081 addr:$dst),
5082 (implicit EFLAGS)),
5083 (XOR16mi8 addr:$dst, i16immSExt8:$src2)>;
5084def : Pat<(parallel (store (X86xor_flag (loadi32 addr:$dst), i32immSExt8:$src2),
5085 addr:$dst),
5086 (implicit EFLAGS)),
5087 (XOR32mi8 addr:$dst, i32immSExt8:$src2)>;
5088
5089// Register-Register And with EFLAGS result
5090def : Pat<(parallel (X86and_flag GR8:$src1, GR8:$src2),
5091 (implicit EFLAGS)),
5092 (AND8rr GR8:$src1, GR8:$src2)>;
5093def : Pat<(parallel (X86and_flag GR16:$src1, GR16:$src2),
5094 (implicit EFLAGS)),
5095 (AND16rr GR16:$src1, GR16:$src2)>;
5096def : Pat<(parallel (X86and_flag GR32:$src1, GR32:$src2),
5097 (implicit EFLAGS)),
5098 (AND32rr GR32:$src1, GR32:$src2)>;
5099
5100// Register-Memory And with EFLAGS result
5101def : Pat<(parallel (X86and_flag GR8:$src1, (loadi8 addr:$src2)),
5102 (implicit EFLAGS)),
5103 (AND8rm GR8:$src1, addr:$src2)>;
5104def : Pat<(parallel (X86and_flag GR16:$src1, (loadi16 addr:$src2)),
5105 (implicit EFLAGS)),
5106 (AND16rm GR16:$src1, addr:$src2)>;
5107def : Pat<(parallel (X86and_flag GR32:$src1, (loadi32 addr:$src2)),
5108 (implicit EFLAGS)),
5109 (AND32rm GR32:$src1, addr:$src2)>;
5110
5111// Register-Integer And with EFLAGS result
5112def : Pat<(parallel (X86and_flag GR8:$src1, imm:$src2),
5113 (implicit EFLAGS)),
5114 (AND8ri GR8:$src1, imm:$src2)>;
5115def : Pat<(parallel (X86and_flag GR16:$src1, imm:$src2),
5116 (implicit EFLAGS)),
5117 (AND16ri GR16:$src1, imm:$src2)>;
5118def : Pat<(parallel (X86and_flag GR32:$src1, imm:$src2),
5119 (implicit EFLAGS)),
5120 (AND32ri GR32:$src1, imm:$src2)>;
5121def : Pat<(parallel (X86and_flag GR16:$src1, i16immSExt8:$src2),
5122 (implicit EFLAGS)),
5123 (AND16ri8 GR16:$src1, i16immSExt8:$src2)>;
5124def : Pat<(parallel (X86and_flag GR32:$src1, i32immSExt8:$src2),
5125 (implicit EFLAGS)),
5126 (AND32ri8 GR32:$src1, i32immSExt8:$src2)>;
5127
5128// Memory-Register And with EFLAGS result
5129def : Pat<(parallel (store (X86and_flag (loadi8 addr:$dst), GR8:$src2),
5130 addr:$dst),
5131 (implicit EFLAGS)),
5132 (AND8mr addr:$dst, GR8:$src2)>;
5133def : Pat<(parallel (store (X86and_flag (loadi16 addr:$dst), GR16:$src2),
5134 addr:$dst),
5135 (implicit EFLAGS)),
5136 (AND16mr addr:$dst, GR16:$src2)>;
5137def : Pat<(parallel (store (X86and_flag (loadi32 addr:$dst), GR32:$src2),
5138 addr:$dst),
5139 (implicit EFLAGS)),
5140 (AND32mr addr:$dst, GR32:$src2)>;
5141
5142// Memory-Integer And with EFLAGS result
5143def : Pat<(parallel (store (X86and_flag (loadi8 addr:$dst), imm:$src2),
5144 addr:$dst),
5145 (implicit EFLAGS)),
5146 (AND8mi addr:$dst, imm:$src2)>;
5147def : Pat<(parallel (store (X86and_flag (loadi16 addr:$dst), imm:$src2),
5148 addr:$dst),
5149 (implicit EFLAGS)),
5150 (AND16mi addr:$dst, imm:$src2)>;
5151def : Pat<(parallel (store (X86and_flag (loadi32 addr:$dst), imm:$src2),
5152 addr:$dst),
5153 (implicit EFLAGS)),
5154 (AND32mi addr:$dst, imm:$src2)>;
5155def : Pat<(parallel (store (X86and_flag (loadi16 addr:$dst), i16immSExt8:$src2),
5156 addr:$dst),
5157 (implicit EFLAGS)),
5158 (AND16mi8 addr:$dst, i16immSExt8:$src2)>;
5159def : Pat<(parallel (store (X86and_flag (loadi32 addr:$dst), i32immSExt8:$src2),
5160 addr:$dst),
5161 (implicit EFLAGS)),
5162 (AND32mi8 addr:$dst, i32immSExt8:$src2)>;
5163
Dan Gohmane84197b2009-09-03 17:18:51 +00005164// -disable-16bit support.
5165def : Pat<(truncstorei16 (i32 imm:$src), addr:$dst),
5166 (MOV16mi addr:$dst, imm:$src)>;
5167def : Pat<(truncstorei16 GR32:$src, addr:$dst),
5168 (MOV16mr addr:$dst, (EXTRACT_SUBREG GR32:$src, x86_subreg_16bit))>;
5169def : Pat<(i32 (sextloadi16 addr:$dst)),
5170 (MOVSX32rm16 addr:$dst)>;
5171def : Pat<(i32 (zextloadi16 addr:$dst)),
5172 (MOVZX32rm16 addr:$dst)>;
5173def : Pat<(i32 (extloadi16 addr:$dst)),
5174 (MOVZX32rm16 addr:$dst)>;
5175
Bill Wendlingf5399032008-12-12 21:15:41 +00005176//===----------------------------------------------------------------------===//
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005177// Floating Point Stack Support
5178//===----------------------------------------------------------------------===//
5179
5180include "X86InstrFPStack.td"
5181
5182//===----------------------------------------------------------------------===//
Evan Cheng86ab7d32007-07-31 08:04:03 +00005183// X86-64 Support
5184//===----------------------------------------------------------------------===//
5185
Chris Lattner2de8d2b2008-01-10 05:50:42 +00005186include "X86Instr64bit.td"
Evan Cheng86ab7d32007-07-31 08:04:03 +00005187
5188//===----------------------------------------------------------------------===//
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005189// XMM Floating point support (requires SSE / SSE2)
5190//===----------------------------------------------------------------------===//
5191
5192include "X86InstrSSE.td"
Evan Cheng5e4d1e72008-04-25 18:19:54 +00005193
5194//===----------------------------------------------------------------------===//
5195// MMX and XMM Packed Integer support (requires MMX, SSE, and SSE2)
5196//===----------------------------------------------------------------------===//
5197
5198include "X86InstrMMX.td"