blob: 5c9498c64f6ddb9c5f66866ca4989faadad48dd5 [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
Evan Cheng213b5be2010-01-31 07:28:44 +0000765 def TAILJMPd : IBr<0xE9, (ins i32imm_pcrel:$dst, variable_ops),
766 "jmp\t$dst # TAILCALL",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000767 []>;
Evan Cheng37e7c752007-07-21 00:34:19 +0000768let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1 in
Evan Cheng213b5be2010-01-31 07:28:44 +0000769 def TAILJMPr : I<0xFF, MRM4r, (outs), (ins GR32:$dst, variable_ops),
Sean Callanan2c48df22009-12-18 00:01:26 +0000770 "jmp{l}\t{*}$dst # TAILCALL",
Arnold Schwaighofere2d6bbb2007-10-11 19:40:01 +0000771 []>;
Evan Cheng37e7c752007-07-21 00:34:19 +0000772let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1 in
Evan Cheng213b5be2010-01-31 07:28:44 +0000773 def TAILJMPm : I<0xFF, MRM4m, (outs), (ins i32mem:$dst, variable_ops),
Arnold Schwaighofere2d6bbb2007-10-11 19:40:01 +0000774 "jmp\t{*}$dst # TAILCALL", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000775
776//===----------------------------------------------------------------------===//
777// Miscellaneous Instructions...
778//
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000779let Defs = [EBP, ESP], Uses = [EBP, ESP], mayLoad = 1, neverHasSideEffects=1 in
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000780def LEAVE : I<0xC9, RawFrm,
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000781 (outs), (ins), "leave", []>;
782
Sean Callanan2c48df22009-12-18 00:01:26 +0000783def POPCNT16rr : I<0xB8, MRMSrcReg, (outs GR16:$dst), (ins GR16:$src),
784 "popcnt{w}\t{$src, $dst|$dst, $src}", []>, OpSize, XS;
785def POPCNT16rm : I<0xB8, MRMSrcMem, (outs GR16:$dst), (ins i16mem:$src),
786 "popcnt{w}\t{$src, $dst|$dst, $src}", []>, OpSize, XS;
787def POPCNT32rr : I<0xB8, MRMSrcReg, (outs GR32:$dst), (ins GR32:$src),
788 "popcnt{l}\t{$src, $dst|$dst, $src}", []>, XS;
789def POPCNT32rm : I<0xB8, MRMSrcMem, (outs GR32:$dst), (ins i32mem:$src),
790 "popcnt{l}\t{$src, $dst|$dst, $src}", []>, XS;
791
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000792let Defs = [ESP], Uses = [ESP], neverHasSideEffects=1 in {
Sean Callanan9f3c3f52009-09-10 18:29:13 +0000793let mayLoad = 1 in {
794def POP16r : I<0x58, AddRegFrm, (outs GR16:$reg), (ins), "pop{w}\t$reg", []>,
795 OpSize;
796def POP32r : I<0x58, AddRegFrm, (outs GR32:$reg), (ins), "pop{l}\t$reg", []>;
797def POP16rmr: I<0x8F, MRM0r, (outs GR16:$reg), (ins), "pop{w}\t$reg", []>,
798 OpSize;
799def POP16rmm: I<0x8F, MRM0m, (outs i16mem:$dst), (ins), "pop{w}\t$dst", []>,
800 OpSize;
801def POP32rmr: I<0x8F, MRM0r, (outs GR32:$reg), (ins), "pop{l}\t$reg", []>;
802def POP32rmm: I<0x8F, MRM0m, (outs i32mem:$dst), (ins), "pop{l}\t$dst", []>;
803}
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000804
Sean Callanan9f3c3f52009-09-10 18:29:13 +0000805let mayStore = 1 in {
806def PUSH16r : I<0x50, AddRegFrm, (outs), (ins GR16:$reg), "push{w}\t$reg",[]>,
807 OpSize;
Evan Chengd8434332007-09-26 01:29:06 +0000808def PUSH32r : I<0x50, AddRegFrm, (outs), (ins GR32:$reg), "push{l}\t$reg",[]>;
Sean Callanan9f3c3f52009-09-10 18:29:13 +0000809def PUSH16rmr: I<0xFF, MRM6r, (outs), (ins GR16:$reg), "push{w}\t$reg",[]>,
810 OpSize;
811def PUSH16rmm: I<0xFF, MRM6m, (outs), (ins i16mem:$src), "push{w}\t$src",[]>,
812 OpSize;
813def PUSH32rmr: I<0xFF, MRM6r, (outs), (ins GR32:$reg), "push{l}\t$reg",[]>;
814def PUSH32rmm: I<0xFF, MRM6m, (outs), (ins i32mem:$src), "push{l}\t$src",[]>;
815}
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000816}
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000817
Bill Wendling4c2638c2009-06-15 19:39:04 +0000818let Defs = [ESP], Uses = [ESP], neverHasSideEffects = 1, mayStore = 1 in {
819def PUSH32i8 : Ii8<0x6a, RawFrm, (outs), (ins i8imm:$imm),
Bill Wendling0b0437f2009-06-15 20:59:31 +0000820 "push{l}\t$imm", []>;
Bill Wendling4c2638c2009-06-15 19:39:04 +0000821def PUSH32i16 : Ii16<0x68, RawFrm, (outs), (ins i16imm:$imm),
Bill Wendling0b0437f2009-06-15 20:59:31 +0000822 "push{l}\t$imm", []>;
Bill Wendling4c2638c2009-06-15 19:39:04 +0000823def PUSH32i32 : Ii32<0x68, RawFrm, (outs), (ins i32imm:$imm),
Bill Wendling0b0437f2009-06-15 20:59:31 +0000824 "push{l}\t$imm", []>;
Bill Wendling4c2638c2009-06-15 19:39:04 +0000825}
826
Sean Callanan2c48df22009-12-18 00:01:26 +0000827let Defs = [ESP, EFLAGS], Uses = [ESP], mayLoad = 1, neverHasSideEffects=1 in {
828def POPF : I<0x9D, RawFrm, (outs), (ins), "popf{w}", []>, OpSize;
829def POPFD : I<0x9D, RawFrm, (outs), (ins), "popf{l}", []>;
830}
831let Defs = [ESP], Uses = [ESP, EFLAGS], mayStore = 1, neverHasSideEffects=1 in {
832def PUSHF : I<0x9C, RawFrm, (outs), (ins), "pushf{w}", []>, OpSize;
833def PUSHFD : I<0x9C, RawFrm, (outs), (ins), "pushf{l}", []>;
834}
Evan Chengd8434332007-09-26 01:29:06 +0000835
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000836let isTwoAddress = 1 in // GR32 = bswap GR32
837 def BSWAP32r : I<0xC8, AddRegFrm,
Evan Chengb783fa32007-07-19 01:14:50 +0000838 (outs GR32:$dst), (ins GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000839 "bswap{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000840 [(set GR32:$dst, (bswap GR32:$src))]>, TB;
841
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000842
Evan Cheng48679f42007-12-14 02:13:44 +0000843// Bit scan instructions.
844let Defs = [EFLAGS] in {
Evan Cheng4e33de92007-12-14 18:49:43 +0000845def BSF16rr : I<0xBC, MRMSrcReg, (outs GR16:$dst), (ins GR16:$src),
Dan Gohmancdb54c62007-12-14 15:10:00 +0000846 "bsf{w}\t{$src, $dst|$dst, $src}",
Evan Cheng7cfbfe32007-12-14 08:30:15 +0000847 [(set GR16:$dst, (X86bsf GR16:$src)), (implicit EFLAGS)]>, TB;
Evan Cheng48679f42007-12-14 02:13:44 +0000848def BSF16rm : I<0xBC, MRMSrcMem, (outs GR16:$dst), (ins i16mem:$src),
Dan Gohmancdb54c62007-12-14 15:10:00 +0000849 "bsf{w}\t{$src, $dst|$dst, $src}",
Evan Cheng7cfbfe32007-12-14 08:30:15 +0000850 [(set GR16:$dst, (X86bsf (loadi16 addr:$src))),
851 (implicit EFLAGS)]>, TB;
Evan Cheng4e33de92007-12-14 18:49:43 +0000852def BSF32rr : I<0xBC, MRMSrcReg, (outs GR32:$dst), (ins GR32:$src),
Dan Gohmancdb54c62007-12-14 15:10:00 +0000853 "bsf{l}\t{$src, $dst|$dst, $src}",
Evan Cheng7cfbfe32007-12-14 08:30:15 +0000854 [(set GR32:$dst, (X86bsf GR32:$src)), (implicit EFLAGS)]>, TB;
Evan Cheng48679f42007-12-14 02:13:44 +0000855def BSF32rm : I<0xBC, MRMSrcMem, (outs GR32:$dst), (ins i32mem:$src),
Dan Gohmancdb54c62007-12-14 15:10:00 +0000856 "bsf{l}\t{$src, $dst|$dst, $src}",
Evan Cheng7cfbfe32007-12-14 08:30:15 +0000857 [(set GR32:$dst, (X86bsf (loadi32 addr:$src))),
858 (implicit EFLAGS)]>, TB;
Evan Cheng48679f42007-12-14 02:13:44 +0000859
Evan Cheng4e33de92007-12-14 18:49:43 +0000860def BSR16rr : I<0xBD, MRMSrcReg, (outs GR16:$dst), (ins GR16:$src),
Dan Gohmancdb54c62007-12-14 15:10:00 +0000861 "bsr{w}\t{$src, $dst|$dst, $src}",
Evan Cheng7cfbfe32007-12-14 08:30:15 +0000862 [(set GR16:$dst, (X86bsr GR16:$src)), (implicit EFLAGS)]>, TB;
Evan Cheng48679f42007-12-14 02:13:44 +0000863def BSR16rm : I<0xBD, MRMSrcMem, (outs GR16:$dst), (ins i16mem:$src),
Dan Gohmancdb54c62007-12-14 15:10:00 +0000864 "bsr{w}\t{$src, $dst|$dst, $src}",
Evan Cheng7cfbfe32007-12-14 08:30:15 +0000865 [(set GR16:$dst, (X86bsr (loadi16 addr:$src))),
866 (implicit EFLAGS)]>, TB;
Evan Cheng4e33de92007-12-14 18:49:43 +0000867def BSR32rr : I<0xBD, MRMSrcReg, (outs GR32:$dst), (ins GR32:$src),
Dan Gohmancdb54c62007-12-14 15:10:00 +0000868 "bsr{l}\t{$src, $dst|$dst, $src}",
Evan Cheng7cfbfe32007-12-14 08:30:15 +0000869 [(set GR32:$dst, (X86bsr GR32:$src)), (implicit EFLAGS)]>, TB;
Evan Cheng48679f42007-12-14 02:13:44 +0000870def BSR32rm : I<0xBD, MRMSrcMem, (outs GR32:$dst), (ins i32mem:$src),
Dan Gohmancdb54c62007-12-14 15:10:00 +0000871 "bsr{l}\t{$src, $dst|$dst, $src}",
Evan Cheng7cfbfe32007-12-14 08:30:15 +0000872 [(set GR32:$dst, (X86bsr (loadi32 addr:$src))),
873 (implicit EFLAGS)]>, TB;
Evan Cheng48679f42007-12-14 02:13:44 +0000874} // Defs = [EFLAGS]
875
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000876let neverHasSideEffects = 1 in
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000877def LEA16r : I<0x8D, MRMSrcMem,
Evan Chengca348202009-12-12 18:51:56 +0000878 (outs GR16:$dst), (ins lea32mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000879 "lea{w}\t{$src|$dst}, {$dst|$src}", []>, OpSize;
Evan Cheng1ea8e6b2008-03-27 01:41:09 +0000880let isReMaterializable = 1 in
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000881def LEA32r : I<0x8D, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +0000882 (outs GR32:$dst), (ins lea32mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000883 "lea{l}\t{$src|$dst}, {$dst|$src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000884 [(set GR32:$dst, lea32addr:$src)]>, Requires<[In32BitMode]>;
885
Kevin Enderby3aa67c02010-02-03 21:04:42 +0000886let Defs = [ECX,EDI,ESI], Uses = [ECX,EDI,ESI], isCodeGenOnly = 1 in {
Evan Chengb783fa32007-07-19 01:14:50 +0000887def REP_MOVSB : I<0xA4, RawFrm, (outs), (ins), "{rep;movsb|rep movsb}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000888 [(X86rep_movs i8)]>, REP;
Evan Chengb783fa32007-07-19 01:14:50 +0000889def REP_MOVSW : I<0xA5, RawFrm, (outs), (ins), "{rep;movsw|rep movsw}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000890 [(X86rep_movs i16)]>, REP, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +0000891def REP_MOVSD : I<0xA5, RawFrm, (outs), (ins), "{rep;movsl|rep movsd}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000892 [(X86rep_movs i32)]>, REP;
893}
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000894
Kevin Enderby3aa67c02010-02-03 21:04:42 +0000895// These uses the DF flag in the EFLAGS register to inc or dec EDI and ESI
896let Defs = [EDI,ESI], Uses = [EDI,ESI,EFLAGS] in {
897def MOVSB : I<0xA4, RawFrm, (outs), (ins), "{movsb}", []>;
898def MOVSW : I<0xA5, RawFrm, (outs), (ins), "{movsw}", []>, OpSize;
899def MOVSD : I<0xA5, RawFrm, (outs), (ins), "{movsl|movsd}", []>;
900}
901
902let Defs = [ECX,EDI], Uses = [AL,ECX,EDI], isCodeGenOnly = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +0000903def REP_STOSB : I<0xAA, RawFrm, (outs), (ins), "{rep;stosb|rep stosb}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000904 [(X86rep_stos i8)]>, REP;
Kevin Enderby3aa67c02010-02-03 21:04:42 +0000905let Defs = [ECX,EDI], Uses = [AX,ECX,EDI], isCodeGenOnly = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +0000906def REP_STOSW : I<0xAB, RawFrm, (outs), (ins), "{rep;stosw|rep stosw}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000907 [(X86rep_stos i16)]>, REP, OpSize;
Kevin Enderby3aa67c02010-02-03 21:04:42 +0000908let Defs = [ECX,EDI], Uses = [EAX,ECX,EDI], isCodeGenOnly = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +0000909def REP_STOSD : I<0xAB, RawFrm, (outs), (ins), "{rep;stosl|rep stosd}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000910 [(X86rep_stos i32)]>, REP;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000911
Kevin Enderby3aa67c02010-02-03 21:04:42 +0000912// These uses the DF flag in the EFLAGS register to inc or dec EDI and ESI
913let Defs = [EDI], Uses = [AL,EDI,EFLAGS] in
914def STOSB : I<0xAA, RawFrm, (outs), (ins), "{stosb}", []>;
915let Defs = [EDI], Uses = [AX,EDI,EFLAGS] in
916def STOSW : I<0xAB, RawFrm, (outs), (ins), "{stosw}", []>, OpSize;
917let Defs = [EDI], Uses = [EAX,EDI,EFLAGS] in
918def STOSD : I<0xAB, RawFrm, (outs), (ins), "{stosl|stosd}", []>;
919
Sean Callanan481f06d2009-09-12 00:37:19 +0000920def SCAS8 : I<0xAE, RawFrm, (outs), (ins), "scas{b}", []>;
921def SCAS16 : I<0xAF, RawFrm, (outs), (ins), "scas{w}", []>, OpSize;
922def SCAS32 : I<0xAF, RawFrm, (outs), (ins), "scas{l}", []>;
923
Sean Callanan25220d62009-09-12 02:25:20 +0000924def CMPS8 : I<0xA6, RawFrm, (outs), (ins), "cmps{b}", []>;
925def CMPS16 : I<0xA7, RawFrm, (outs), (ins), "cmps{w}", []>, OpSize;
926def CMPS32 : I<0xA7, RawFrm, (outs), (ins), "cmps{l}", []>;
927
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000928let Defs = [RAX, RDX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000929def RDTSC : I<0x31, RawFrm, (outs), (ins), "rdtsc", [(X86rdtsc)]>,
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000930 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000931
Anton Korobeynikov39d40ba2008-01-15 07:02:33 +0000932let isBarrier = 1, hasCtrlDep = 1 in {
Chris Lattner56b941f2008-01-15 21:58:22 +0000933def TRAP : I<0x0B, RawFrm, (outs), (ins), "ud2", [(trap)]>, TB;
Anton Korobeynikov39d40ba2008-01-15 07:02:33 +0000934}
935
Chris Lattnerc96e27c2009-08-11 16:58:39 +0000936def SYSCALL : I<0x05, RawFrm,
937 (outs), (ins), "syscall", []>, TB;
938def SYSRET : I<0x07, RawFrm,
939 (outs), (ins), "sysret", []>, TB;
940def SYSENTER : I<0x34, RawFrm,
941 (outs), (ins), "sysenter", []>, TB;
942def SYSEXIT : I<0x35, RawFrm,
943 (outs), (ins), "sysexit", []>, TB;
944
Sean Callanan2c2313a2009-09-12 02:52:41 +0000945def WAIT : I<0x9B, RawFrm, (outs), (ins), "wait", []>;
Chris Lattnerc96e27c2009-08-11 16:58:39 +0000946
947
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000948//===----------------------------------------------------------------------===//
949// Input/Output Instructions...
950//
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000951let Defs = [AL], Uses = [DX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000952def IN8rr : I<0xEC, RawFrm, (outs), (ins),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000953 "in{b}\t{%dx, %al|%AL, %DX}", []>;
954let Defs = [AX], Uses = [DX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000955def IN16rr : I<0xED, RawFrm, (outs), (ins),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000956 "in{w}\t{%dx, %ax|%AX, %DX}", []>, OpSize;
957let Defs = [EAX], Uses = [DX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000958def IN32rr : I<0xED, RawFrm, (outs), (ins),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000959 "in{l}\t{%dx, %eax|%EAX, %DX}", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000960
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000961let Defs = [AL] in
Evan Chengb783fa32007-07-19 01:14:50 +0000962def IN8ri : Ii8<0xE4, RawFrm, (outs), (ins i16i8imm:$port),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000963 "in{b}\t{$port, %al|%AL, $port}", []>;
964let Defs = [AX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000965def IN16ri : Ii8<0xE5, RawFrm, (outs), (ins i16i8imm:$port),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000966 "in{w}\t{$port, %ax|%AX, $port}", []>, OpSize;
967let Defs = [EAX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000968def IN32ri : Ii8<0xE5, RawFrm, (outs), (ins i16i8imm:$port),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000969 "in{l}\t{$port, %eax|%EAX, $port}", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000970
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000971let Uses = [DX, AL] in
Evan Chengb783fa32007-07-19 01:14:50 +0000972def OUT8rr : I<0xEE, RawFrm, (outs), (ins),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000973 "out{b}\t{%al, %dx|%DX, %AL}", []>;
974let Uses = [DX, AX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000975def OUT16rr : I<0xEF, RawFrm, (outs), (ins),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000976 "out{w}\t{%ax, %dx|%DX, %AX}", []>, OpSize;
977let Uses = [DX, EAX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000978def OUT32rr : I<0xEF, RawFrm, (outs), (ins),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000979 "out{l}\t{%eax, %dx|%DX, %EAX}", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000980
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000981let Uses = [AL] in
Evan Chengb783fa32007-07-19 01:14:50 +0000982def OUT8ir : Ii8<0xE6, RawFrm, (outs), (ins i16i8imm:$port),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000983 "out{b}\t{%al, $port|$port, %AL}", []>;
984let Uses = [AX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000985def OUT16ir : Ii8<0xE7, RawFrm, (outs), (ins i16i8imm:$port),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000986 "out{w}\t{%ax, $port|$port, %AX}", []>, OpSize;
987let Uses = [EAX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000988def OUT32ir : Ii8<0xE7, RawFrm, (outs), (ins i16i8imm:$port),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000989 "out{l}\t{%eax, $port|$port, %EAX}", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000990
Sean Callanan2c48df22009-12-18 00:01:26 +0000991def IN8 : I<0x6C, RawFrm, (outs), (ins),
992 "ins{b}", []>;
993def IN16 : I<0x6D, RawFrm, (outs), (ins),
994 "ins{w}", []>, OpSize;
995def IN32 : I<0x6D, RawFrm, (outs), (ins),
996 "ins{l}", []>;
997
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000998//===----------------------------------------------------------------------===//
999// Move Instructions...
1000//
Chris Lattnerc90ee9c2008-01-10 07:59:24 +00001001let neverHasSideEffects = 1 in {
Evan Chengb783fa32007-07-19 01:14:50 +00001002def MOV8rr : I<0x88, MRMDestReg, (outs GR8 :$dst), (ins GR8 :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001003 "mov{b}\t{$src, $dst|$dst, $src}", []>;
Evan Chengb783fa32007-07-19 01:14:50 +00001004def MOV16rr : I<0x89, MRMDestReg, (outs GR16:$dst), (ins GR16:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001005 "mov{w}\t{$src, $dst|$dst, $src}", []>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001006def MOV32rr : I<0x89, MRMDestReg, (outs GR32:$dst), (ins GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001007 "mov{l}\t{$src, $dst|$dst, $src}", []>;
Chris Lattnerc90ee9c2008-01-10 07:59:24 +00001008}
Evan Cheng6f26e8b2008-06-18 08:13:07 +00001009let isReMaterializable = 1, isAsCheapAsAMove = 1 in {
Evan Chengb783fa32007-07-19 01:14:50 +00001010def MOV8ri : Ii8 <0xB0, AddRegFrm, (outs GR8 :$dst), (ins i8imm :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001011 "mov{b}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001012 [(set GR8:$dst, imm:$src)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001013def MOV16ri : Ii16<0xB8, AddRegFrm, (outs GR16:$dst), (ins i16imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001014 "mov{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001015 [(set GR16:$dst, imm:$src)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001016def MOV32ri : Ii32<0xB8, AddRegFrm, (outs GR32:$dst), (ins i32imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001017 "mov{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001018 [(set GR32:$dst, imm:$src)]>;
1019}
Kevin Enderby3aa67c02010-02-03 21:04:42 +00001020
Evan Chengb783fa32007-07-19 01:14:50 +00001021def MOV8mi : Ii8 <0xC6, MRM0m, (outs), (ins i8mem :$dst, i8imm :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001022 "mov{b}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001023 [(store (i8 imm:$src), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001024def MOV16mi : Ii16<0xC7, MRM0m, (outs), (ins i16mem:$dst, i16imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001025 "mov{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001026 [(store (i16 imm:$src), addr:$dst)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001027def MOV32mi : Ii32<0xC7, MRM0m, (outs), (ins i32mem:$dst, i32imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001028 "mov{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001029 [(store (i32 imm:$src), addr:$dst)]>;
1030
Sean Callanan2c48df22009-12-18 00:01:26 +00001031def MOV8o8a : Ii8 <0xA0, RawFrm, (outs), (ins offset8:$src),
Sean Callanan70953a52009-09-10 18:33:42 +00001032 "mov{b}\t{$src, %al|%al, $src}", []>;
Sean Callanan2c48df22009-12-18 00:01:26 +00001033def MOV16o16a : Ii16 <0xA1, RawFrm, (outs), (ins offset16:$src),
Sean Callanan70953a52009-09-10 18:33:42 +00001034 "mov{w}\t{$src, %ax|%ax, $src}", []>, OpSize;
Sean Callanan2c48df22009-12-18 00:01:26 +00001035def MOV32o32a : Ii32 <0xA1, RawFrm, (outs), (ins offset32:$src),
Sean Callanan70953a52009-09-10 18:33:42 +00001036 "mov{l}\t{$src, %eax|%eax, $src}", []>;
1037
Sean Callanan2c48df22009-12-18 00:01:26 +00001038def MOV8ao8 : Ii8 <0xA2, RawFrm, (outs offset8:$dst), (ins),
Sean Callanan70953a52009-09-10 18:33:42 +00001039 "mov{b}\t{%al, $dst|$dst, %al}", []>;
Sean Callanan2c48df22009-12-18 00:01:26 +00001040def MOV16ao16 : Ii16 <0xA3, RawFrm, (outs offset16:$dst), (ins),
Sean Callanan70953a52009-09-10 18:33:42 +00001041 "mov{w}\t{%ax, $dst|$dst, %ax}", []>, OpSize;
Sean Callanan2c48df22009-12-18 00:01:26 +00001042def MOV32ao32 : Ii32 <0xA3, RawFrm, (outs offset32:$dst), (ins),
Sean Callanan70953a52009-09-10 18:33:42 +00001043 "mov{l}\t{%eax, $dst|$dst, %eax}", []>;
1044
Sean Callananad87a3a2009-09-15 18:47:29 +00001045// Moves to and from segment registers
1046def MOV16rs : I<0x8C, MRMDestReg, (outs GR16:$dst), (ins SEGMENT_REG:$src),
1047 "mov{w}\t{$src, $dst|$dst, $src}", []>;
1048def MOV16ms : I<0x8C, MRMDestMem, (outs i16mem:$dst), (ins SEGMENT_REG:$src),
1049 "mov{w}\t{$src, $dst|$dst, $src}", []>;
1050def MOV16sr : I<0x8E, MRMSrcReg, (outs SEGMENT_REG:$dst), (ins GR16:$src),
1051 "mov{w}\t{$src, $dst|$dst, $src}", []>;
1052def MOV16sm : I<0x8E, MRMSrcMem, (outs SEGMENT_REG:$dst), (ins i16mem:$src),
1053 "mov{w}\t{$src, $dst|$dst, $src}", []>;
1054
Sean Callanan2c48df22009-12-18 00:01:26 +00001055def MOV8rr_REV : I<0x8A, MRMSrcReg, (outs GR8:$dst), (ins GR8:$src),
1056 "mov{b}\t{$src, $dst|$dst, $src}", []>;
1057def MOV16rr_REV : I<0x8B, MRMSrcReg, (outs GR16:$dst), (ins GR16:$src),
1058 "mov{w}\t{$src, $dst|$dst, $src}", []>, OpSize;
1059def MOV32rr_REV : I<0x8B, MRMSrcReg, (outs GR32:$dst), (ins GR32:$src),
1060 "mov{l}\t{$src, $dst|$dst, $src}", []>;
1061
Dan Gohman5574cc72008-12-03 18:15:48 +00001062let canFoldAsLoad = 1, isReMaterializable = 1, mayHaveSideEffects = 1 in {
Evan Chengb783fa32007-07-19 01:14:50 +00001063def MOV8rm : I<0x8A, MRMSrcMem, (outs GR8 :$dst), (ins i8mem :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001064 "mov{b}\t{$src, $dst|$dst, $src}",
Chris Lattner12208612009-04-10 00:16:23 +00001065 [(set GR8:$dst, (loadi8 addr:$src))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001066def MOV16rm : I<0x8B, MRMSrcMem, (outs GR16:$dst), (ins i16mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001067 "mov{w}\t{$src, $dst|$dst, $src}",
Chris Lattner12208612009-04-10 00:16:23 +00001068 [(set GR16:$dst, (loadi16 addr:$src))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001069def MOV32rm : I<0x8B, MRMSrcMem, (outs GR32:$dst), (ins i32mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001070 "mov{l}\t{$src, $dst|$dst, $src}",
Chris Lattner12208612009-04-10 00:16:23 +00001071 [(set GR32:$dst, (loadi32 addr:$src))]>;
Evan Cheng4e84e452007-08-30 05:49:43 +00001072}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001073
Evan Chengb783fa32007-07-19 01:14:50 +00001074def MOV8mr : I<0x88, MRMDestMem, (outs), (ins i8mem :$dst, GR8 :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001075 "mov{b}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001076 [(store GR8:$src, addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001077def MOV16mr : I<0x89, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001078 "mov{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001079 [(store GR16:$src, addr:$dst)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001080def MOV32mr : I<0x89, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001081 "mov{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001082 [(store GR32:$src, addr:$dst)]>;
Dan Gohman744d4622009-04-13 16:09:41 +00001083
Dan Gohman1d8ce9c2009-04-27 16:41:36 +00001084// Versions of MOV8rr, MOV8mr, and MOV8rm that use i8mem_NOREX and GR8_NOREX so
1085// that they can be used for copying and storing h registers, which can't be
1086// encoded when a REX prefix is present.
Dan Gohman2da0db32009-04-15 00:04:23 +00001087let neverHasSideEffects = 1 in
Dan Gohman40ddc362009-04-15 19:48:57 +00001088def MOV8rr_NOREX : I<0x88, MRMDestReg,
1089 (outs GR8_NOREX:$dst), (ins GR8_NOREX:$src),
Dan Gohman2da0db32009-04-15 00:04:23 +00001090 "mov{b}\t{$src, $dst|$dst, $src} # NOREX", []>;
Evan Chengebc49402009-04-30 00:58:57 +00001091let mayStore = 1 in
Dan Gohman2da0db32009-04-15 00:04:23 +00001092def MOV8mr_NOREX : I<0x88, MRMDestMem,
1093 (outs), (ins i8mem_NOREX:$dst, GR8_NOREX:$src),
1094 "mov{b}\t{$src, $dst|$dst, $src} # NOREX", []>;
Evan Chengebc49402009-04-30 00:58:57 +00001095let mayLoad = 1,
1096 canFoldAsLoad = 1, isReMaterializable = 1, mayHaveSideEffects = 1 in
Dan Gohman1d8ce9c2009-04-27 16:41:36 +00001097def MOV8rm_NOREX : I<0x8A, MRMSrcMem,
1098 (outs GR8_NOREX:$dst), (ins i8mem_NOREX:$src),
1099 "mov{b}\t{$src, $dst|$dst, $src} # NOREX", []>;
Dan Gohman744d4622009-04-13 16:09:41 +00001100
Sean Callanan2c48df22009-12-18 00:01:26 +00001101// Moves to and from debug registers
1102def MOV32rd : I<0x21, MRMDestReg, (outs GR32:$dst), (ins DEBUG_REG:$src),
1103 "mov{l}\t{$src, $dst|$dst, $src}", []>, TB;
1104def MOV32dr : I<0x23, MRMSrcReg, (outs DEBUG_REG:$dst), (ins GR32:$src),
1105 "mov{l}\t{$src, $dst|$dst, $src}", []>, TB;
1106
1107// Moves to and from control registers
1108def MOV32rc : I<0x20, MRMDestReg, (outs GR32:$dst), (ins CONTROL_REG_32:$src),
1109 "mov{q}\t{$src, $dst|$dst, $src}", []>, TB;
1110def MOV32cr : I<0x22, MRMSrcReg, (outs CONTROL_REG_32:$dst), (ins GR32:$src),
1111 "mov{q}\t{$src, $dst|$dst, $src}", []>, TB;
1112
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001113//===----------------------------------------------------------------------===//
1114// Fixed-Register Multiplication and Division Instructions...
1115//
1116
1117// Extra precision multiplication
Evan Cheng55687072007-09-14 21:48:26 +00001118let Defs = [AL,AH,EFLAGS], Uses = [AL] in
Dan Gohman91888f02007-07-31 20:11:57 +00001119def MUL8r : I<0xF6, MRM4r, (outs), (ins GR8:$src), "mul{b}\t$src",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001120 // FIXME: Used for 8-bit mul, ignore result upper 8 bits.
1121 // This probably ought to be moved to a def : Pat<> if the
1122 // syntax can be accepted.
Bill Wendlingf5399032008-12-12 21:15:41 +00001123 [(set AL, (mul AL, GR8:$src)),
1124 (implicit EFLAGS)]>; // AL,AH = AL*GR8
1125
Chris Lattnerc7e96e72008-01-11 07:18:17 +00001126let Defs = [AX,DX,EFLAGS], Uses = [AX], neverHasSideEffects = 1 in
Bill Wendlingf5399032008-12-12 21:15:41 +00001127def MUL16r : I<0xF7, MRM4r, (outs), (ins GR16:$src),
1128 "mul{w}\t$src",
1129 []>, OpSize; // AX,DX = AX*GR16
1130
Chris Lattnerc7e96e72008-01-11 07:18:17 +00001131let Defs = [EAX,EDX,EFLAGS], Uses = [EAX], neverHasSideEffects = 1 in
Bill Wendlingf5399032008-12-12 21:15:41 +00001132def MUL32r : I<0xF7, MRM4r, (outs), (ins GR32:$src),
1133 "mul{l}\t$src",
1134 []>; // EAX,EDX = EAX*GR32
1135
Evan Cheng55687072007-09-14 21:48:26 +00001136let Defs = [AL,AH,EFLAGS], Uses = [AL] in
Evan Chengb783fa32007-07-19 01:14:50 +00001137def MUL8m : I<0xF6, MRM4m, (outs), (ins i8mem :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001138 "mul{b}\t$src",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001139 // FIXME: Used for 8-bit mul, ignore result upper 8 bits.
1140 // This probably ought to be moved to a def : Pat<> if the
1141 // syntax can be accepted.
Bill Wendlingf5399032008-12-12 21:15:41 +00001142 [(set AL, (mul AL, (loadi8 addr:$src))),
1143 (implicit EFLAGS)]>; // AL,AH = AL*[mem8]
1144
Chris Lattnerc90ee9c2008-01-10 07:59:24 +00001145let mayLoad = 1, neverHasSideEffects = 1 in {
Evan Cheng55687072007-09-14 21:48:26 +00001146let Defs = [AX,DX,EFLAGS], Uses = [AX] in
Evan Chengb783fa32007-07-19 01:14:50 +00001147def MUL16m : I<0xF7, MRM4m, (outs), (ins i16mem:$src),
Bill Wendlingf5399032008-12-12 21:15:41 +00001148 "mul{w}\t$src",
1149 []>, OpSize; // AX,DX = AX*[mem16]
1150
Evan Cheng55687072007-09-14 21:48:26 +00001151let Defs = [EAX,EDX,EFLAGS], Uses = [EAX] in
Evan Chengb783fa32007-07-19 01:14:50 +00001152def MUL32m : I<0xF7, MRM4m, (outs), (ins i32mem:$src),
Bill Wendlingf5399032008-12-12 21:15:41 +00001153 "mul{l}\t$src",
1154 []>; // EAX,EDX = EAX*[mem32]
Chris Lattnerc90ee9c2008-01-10 07:59:24 +00001155}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001156
Chris Lattnerc90ee9c2008-01-10 07:59:24 +00001157let neverHasSideEffects = 1 in {
Evan Cheng55687072007-09-14 21:48:26 +00001158let Defs = [AL,AH,EFLAGS], Uses = [AL] in
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001159def IMUL8r : I<0xF6, MRM5r, (outs), (ins GR8:$src), "imul{b}\t$src", []>;
1160 // AL,AH = AL*GR8
Evan Cheng55687072007-09-14 21:48:26 +00001161let Defs = [AX,DX,EFLAGS], Uses = [AX] in
Dan Gohman91888f02007-07-31 20:11:57 +00001162def IMUL16r : I<0xF7, MRM5r, (outs), (ins GR16:$src), "imul{w}\t$src", []>,
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001163 OpSize; // AX,DX = AX*GR16
Evan Cheng55687072007-09-14 21:48:26 +00001164let Defs = [EAX,EDX,EFLAGS], Uses = [EAX] in
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001165def IMUL32r : I<0xF7, MRM5r, (outs), (ins GR32:$src), "imul{l}\t$src", []>;
1166 // EAX,EDX = EAX*GR32
Chris Lattnerc90ee9c2008-01-10 07:59:24 +00001167let mayLoad = 1 in {
Evan Cheng55687072007-09-14 21:48:26 +00001168let Defs = [AL,AH,EFLAGS], Uses = [AL] in
Evan Chengb783fa32007-07-19 01:14:50 +00001169def IMUL8m : I<0xF6, MRM5m, (outs), (ins i8mem :$src),
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001170 "imul{b}\t$src", []>; // AL,AH = AL*[mem8]
Evan Cheng55687072007-09-14 21:48:26 +00001171let Defs = [AX,DX,EFLAGS], Uses = [AX] in
Evan Chengb783fa32007-07-19 01:14:50 +00001172def IMUL16m : I<0xF7, MRM5m, (outs), (ins i16mem:$src),
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001173 "imul{w}\t$src", []>, OpSize; // AX,DX = AX*[mem16]
Eli Friedman3939db02009-12-26 20:08:30 +00001174let Defs = [EAX,EDX,EFLAGS], Uses = [EAX] in
Evan Chengb783fa32007-07-19 01:14:50 +00001175def IMUL32m : I<0xF7, MRM5m, (outs), (ins i32mem:$src),
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001176 "imul{l}\t$src", []>; // EAX,EDX = EAX*[mem32]
Chris Lattnerc90ee9c2008-01-10 07:59:24 +00001177}
Dan Gohmand44572d2008-11-18 21:29:14 +00001178} // neverHasSideEffects
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001179
1180// unsigned division/remainder
Dale Johannesend8fd3562008-10-07 18:54:28 +00001181let Defs = [AL,AH,EFLAGS], Uses = [AX] in
Sean Callanan2c48df22009-12-18 00:01:26 +00001182def DIV8r : I<0xF6, MRM6r, (outs), (ins GR8:$src), // AX/r8 = AL,AH
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001183 "div{b}\t$src", []>;
Evan Cheng55687072007-09-14 21:48:26 +00001184let Defs = [AX,DX,EFLAGS], Uses = [AX,DX] in
Sean Callanan2c48df22009-12-18 00:01:26 +00001185def DIV16r : I<0xF7, MRM6r, (outs), (ins GR16:$src), // DX:AX/r16 = AX,DX
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001186 "div{w}\t$src", []>, OpSize;
Evan Cheng55687072007-09-14 21:48:26 +00001187let Defs = [EAX,EDX,EFLAGS], Uses = [EAX,EDX] in
Sean Callanan2c48df22009-12-18 00:01:26 +00001188def DIV32r : I<0xF7, MRM6r, (outs), (ins GR32:$src), // EDX:EAX/r32 = EAX,EDX
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001189 "div{l}\t$src", []>;
Chris Lattnerc90ee9c2008-01-10 07:59:24 +00001190let mayLoad = 1 in {
Dale Johannesend8fd3562008-10-07 18:54:28 +00001191let Defs = [AL,AH,EFLAGS], Uses = [AX] in
Sean Callanan2c48df22009-12-18 00:01:26 +00001192def DIV8m : I<0xF6, MRM6m, (outs), (ins i8mem:$src), // AX/[mem8] = AL,AH
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001193 "div{b}\t$src", []>;
Evan Cheng55687072007-09-14 21:48:26 +00001194let Defs = [AX,DX,EFLAGS], Uses = [AX,DX] in
Sean Callanan2c48df22009-12-18 00:01:26 +00001195def DIV16m : I<0xF7, MRM6m, (outs), (ins i16mem:$src), // DX:AX/[mem16] = AX,DX
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001196 "div{w}\t$src", []>, OpSize;
Evan Cheng55687072007-09-14 21:48:26 +00001197let Defs = [EAX,EDX,EFLAGS], Uses = [EAX,EDX] in
Sean Callanan2c48df22009-12-18 00:01:26 +00001198 // EDX:EAX/[mem32] = EAX,EDX
1199def DIV32m : I<0xF7, MRM6m, (outs), (ins i32mem:$src),
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001200 "div{l}\t$src", []>;
Chris Lattnerc90ee9c2008-01-10 07:59:24 +00001201}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001202
1203// Signed division/remainder.
Dale Johannesend8fd3562008-10-07 18:54:28 +00001204let Defs = [AL,AH,EFLAGS], Uses = [AX] in
Sean Callanan2c48df22009-12-18 00:01:26 +00001205def IDIV8r : I<0xF6, MRM7r, (outs), (ins GR8:$src), // AX/r8 = AL,AH
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001206 "idiv{b}\t$src", []>;
Evan Cheng55687072007-09-14 21:48:26 +00001207let Defs = [AX,DX,EFLAGS], Uses = [AX,DX] in
Sean Callanan2c48df22009-12-18 00:01:26 +00001208def IDIV16r: I<0xF7, MRM7r, (outs), (ins GR16:$src), // DX:AX/r16 = AX,DX
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001209 "idiv{w}\t$src", []>, OpSize;
Evan Cheng55687072007-09-14 21:48:26 +00001210let Defs = [EAX,EDX,EFLAGS], Uses = [EAX,EDX] in
Sean Callanan2c48df22009-12-18 00:01:26 +00001211def IDIV32r: I<0xF7, MRM7r, (outs), (ins GR32:$src), // EDX:EAX/r32 = EAX,EDX
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001212 "idiv{l}\t$src", []>;
Chris Lattnerc90ee9c2008-01-10 07:59:24 +00001213let mayLoad = 1, mayLoad = 1 in {
Dale Johannesend8fd3562008-10-07 18:54:28 +00001214let Defs = [AL,AH,EFLAGS], Uses = [AX] in
Sean Callanan2c48df22009-12-18 00:01:26 +00001215def IDIV8m : I<0xF6, MRM7m, (outs), (ins i8mem:$src), // AX/[mem8] = AL,AH
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001216 "idiv{b}\t$src", []>;
Evan Cheng55687072007-09-14 21:48:26 +00001217let Defs = [AX,DX,EFLAGS], Uses = [AX,DX] in
Sean Callanan2c48df22009-12-18 00:01:26 +00001218def IDIV16m: I<0xF7, MRM7m, (outs), (ins i16mem:$src), // DX:AX/[mem16] = AX,DX
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001219 "idiv{w}\t$src", []>, OpSize;
Evan Cheng55687072007-09-14 21:48:26 +00001220let Defs = [EAX,EDX,EFLAGS], Uses = [EAX,EDX] in
Sean Callanan2c48df22009-12-18 00:01:26 +00001221def IDIV32m: I<0xF7, MRM7m, (outs), (ins i32mem:$src),
1222 // EDX:EAX/[mem32] = EAX,EDX
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001223 "idiv{l}\t$src", []>;
Chris Lattnerc90ee9c2008-01-10 07:59:24 +00001224}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001225
1226//===----------------------------------------------------------------------===//
Chris Lattnerc90ee9c2008-01-10 07:59:24 +00001227// Two address Instructions.
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001228//
1229let isTwoAddress = 1 in {
1230
1231// Conditional moves
Evan Cheng950aac02007-09-25 01:57:46 +00001232let Uses = [EFLAGS] in {
Dan Gohman29b998f2009-08-27 00:14:12 +00001233
Dan Gohman30afe012009-10-29 18:10:34 +00001234// X86 doesn't have 8-bit conditional moves. Use a customInserter to
Dan Gohman29b998f2009-08-27 00:14:12 +00001235// emit control flow. An alternative to this is to mark i8 SELECT as Promote,
1236// however that requires promoting the operands, and can induce additional
Dan Gohman1596dd22009-08-29 22:19:15 +00001237// i8 register pressure. Note that CMOV_GR8 is conservatively considered to
1238// clobber EFLAGS, because if one of the operands is zero, the expansion
1239// could involve an xor.
Dan Gohman30afe012009-10-29 18:10:34 +00001240let usesCustomInserter = 1, isTwoAddress = 0, Defs = [EFLAGS] in
Dan Gohman29b998f2009-08-27 00:14:12 +00001241def CMOV_GR8 : I<0, Pseudo,
1242 (outs GR8:$dst), (ins GR8:$src1, GR8:$src2, i8imm:$cond),
1243 "#CMOV_GR8 PSEUDO!",
1244 [(set GR8:$dst, (X86cmov GR8:$src1, GR8:$src2,
1245 imm:$cond, EFLAGS))]>;
1246
Dan Gohman90adb6c2009-08-27 18:16:24 +00001247let isCommutable = 1 in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001248def CMOVB16rr : I<0x42, MRMSrcReg, // if <u, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +00001249 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Sean Callanan2c48df22009-12-18 00:01:26 +00001250 "cmovb{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001251 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001252 X86_COND_B, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001253 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001254def CMOVB32rr : I<0x42, MRMSrcReg, // if <u, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +00001255 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Sean Callanan2c48df22009-12-18 00:01:26 +00001256 "cmovb{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001257 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001258 X86_COND_B, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001259 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001260def CMOVAE16rr: I<0x43, MRMSrcReg, // if >=u, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +00001261 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Sean Callanan2c48df22009-12-18 00:01:26 +00001262 "cmovae{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001263 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001264 X86_COND_AE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001265 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001266def CMOVAE32rr: I<0x43, MRMSrcReg, // if >=u, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +00001267 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Sean Callanan2c48df22009-12-18 00:01:26 +00001268 "cmovae{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001269 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001270 X86_COND_AE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001271 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001272def CMOVE16rr : I<0x44, MRMSrcReg, // if ==, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +00001273 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Sean Callanan2c48df22009-12-18 00:01:26 +00001274 "cmove{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001275 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001276 X86_COND_E, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001277 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001278def CMOVE32rr : I<0x44, MRMSrcReg, // if ==, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +00001279 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Sean Callanan2c48df22009-12-18 00:01:26 +00001280 "cmove{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001281 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001282 X86_COND_E, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001283 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001284def CMOVNE16rr: I<0x45, MRMSrcReg, // if !=, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +00001285 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Sean Callanan2c48df22009-12-18 00:01:26 +00001286 "cmovne{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001287 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001288 X86_COND_NE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001289 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001290def CMOVNE32rr: I<0x45, MRMSrcReg, // if !=, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +00001291 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Sean Callanan2c48df22009-12-18 00:01:26 +00001292 "cmovne{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001293 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001294 X86_COND_NE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001295 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001296def CMOVBE16rr: I<0x46, MRMSrcReg, // if <=u, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +00001297 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Sean Callanan2c48df22009-12-18 00:01:26 +00001298 "cmovbe{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001299 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001300 X86_COND_BE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001301 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001302def CMOVBE32rr: I<0x46, MRMSrcReg, // if <=u, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +00001303 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Sean Callanan2c48df22009-12-18 00:01:26 +00001304 "cmovbe{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001305 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001306 X86_COND_BE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001307 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001308def CMOVA16rr : I<0x47, MRMSrcReg, // if >u, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +00001309 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Sean Callanan2c48df22009-12-18 00:01:26 +00001310 "cmova{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001311 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001312 X86_COND_A, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001313 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001314def CMOVA32rr : I<0x47, MRMSrcReg, // if >u, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +00001315 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Sean Callanan2c48df22009-12-18 00:01:26 +00001316 "cmova{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001317 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001318 X86_COND_A, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001319 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001320def CMOVL16rr : I<0x4C, MRMSrcReg, // if <s, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +00001321 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Sean Callanan2c48df22009-12-18 00:01:26 +00001322 "cmovl{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001323 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001324 X86_COND_L, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001325 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001326def CMOVL32rr : I<0x4C, MRMSrcReg, // if <s, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +00001327 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Sean Callanan2c48df22009-12-18 00:01:26 +00001328 "cmovl{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001329 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001330 X86_COND_L, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001331 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001332def CMOVGE16rr: I<0x4D, MRMSrcReg, // if >=s, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +00001333 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Sean Callanan2c48df22009-12-18 00:01:26 +00001334 "cmovge{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001335 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001336 X86_COND_GE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001337 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001338def CMOVGE32rr: I<0x4D, MRMSrcReg, // if >=s, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +00001339 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Sean Callanan2c48df22009-12-18 00:01:26 +00001340 "cmovge{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001341 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001342 X86_COND_GE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001343 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001344def CMOVLE16rr: I<0x4E, MRMSrcReg, // if <=s, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +00001345 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Sean Callanan2c48df22009-12-18 00:01:26 +00001346 "cmovle{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001347 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001348 X86_COND_LE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001349 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001350def CMOVLE32rr: I<0x4E, MRMSrcReg, // if <=s, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +00001351 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Sean Callanan2c48df22009-12-18 00:01:26 +00001352 "cmovle{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001353 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001354 X86_COND_LE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001355 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001356def CMOVG16rr : I<0x4F, MRMSrcReg, // if >s, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +00001357 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Sean Callanan2c48df22009-12-18 00:01:26 +00001358 "cmovg{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001359 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001360 X86_COND_G, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001361 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001362def CMOVG32rr : I<0x4F, MRMSrcReg, // if >s, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +00001363 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Sean Callanan2c48df22009-12-18 00:01:26 +00001364 "cmovg{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001365 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001366 X86_COND_G, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001367 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001368def CMOVS16rr : I<0x48, MRMSrcReg, // if signed, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +00001369 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Sean Callanan2c48df22009-12-18 00:01:26 +00001370 "cmovs{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001371 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001372 X86_COND_S, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001373 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001374def CMOVS32rr : I<0x48, MRMSrcReg, // if signed, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +00001375 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Sean Callanan2c48df22009-12-18 00:01:26 +00001376 "cmovs{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001377 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001378 X86_COND_S, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001379 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001380def CMOVNS16rr: I<0x49, MRMSrcReg, // if !signed, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +00001381 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Sean Callanan2c48df22009-12-18 00:01:26 +00001382 "cmovns{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001383 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001384 X86_COND_NS, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001385 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001386def CMOVNS32rr: I<0x49, MRMSrcReg, // if !signed, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +00001387 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Sean Callanan2c48df22009-12-18 00:01:26 +00001388 "cmovns{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001389 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001390 X86_COND_NS, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001391 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001392def CMOVP16rr : I<0x4A, MRMSrcReg, // if parity, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +00001393 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Sean Callanan2c48df22009-12-18 00:01:26 +00001394 "cmovp{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001395 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001396 X86_COND_P, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001397 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001398def CMOVP32rr : I<0x4A, MRMSrcReg, // if parity, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +00001399 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Sean Callanan2c48df22009-12-18 00:01:26 +00001400 "cmovp{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001401 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001402 X86_COND_P, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001403 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001404def CMOVNP16rr : I<0x4B, MRMSrcReg, // if !parity, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +00001405 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Sean Callanan2c48df22009-12-18 00:01:26 +00001406 "cmovnp{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001407 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001408 X86_COND_NP, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001409 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001410def CMOVNP32rr : I<0x4B, MRMSrcReg, // if !parity, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +00001411 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Sean Callanan2c48df22009-12-18 00:01:26 +00001412 "cmovnp{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001413 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001414 X86_COND_NP, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001415 TB;
Dan Gohman12fd4d72009-01-07 00:35:10 +00001416def CMOVO16rr : I<0x40, MRMSrcReg, // if overflow, GR16 = GR16
1417 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Sean Callanan2c48df22009-12-18 00:01:26 +00001418 "cmovo{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohman12fd4d72009-01-07 00:35:10 +00001419 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
1420 X86_COND_O, EFLAGS))]>,
1421 TB, OpSize;
1422def CMOVO32rr : I<0x40, MRMSrcReg, // if overflow, GR32 = GR32
1423 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Sean Callanan2c48df22009-12-18 00:01:26 +00001424 "cmovo{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohman12fd4d72009-01-07 00:35:10 +00001425 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
1426 X86_COND_O, EFLAGS))]>,
Evan Cheng950aac02007-09-25 01:57:46 +00001427 TB;
Dan Gohman12fd4d72009-01-07 00:35:10 +00001428def CMOVNO16rr : I<0x41, MRMSrcReg, // if !overflow, GR16 = GR16
1429 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Sean Callanan2c48df22009-12-18 00:01:26 +00001430 "cmovno{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohman12fd4d72009-01-07 00:35:10 +00001431 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
1432 X86_COND_NO, EFLAGS))]>,
1433 TB, OpSize;
1434def CMOVNO32rr : I<0x41, MRMSrcReg, // if !overflow, GR32 = GR32
1435 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Sean Callanan2c48df22009-12-18 00:01:26 +00001436 "cmovno{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohman12fd4d72009-01-07 00:35:10 +00001437 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
1438 X86_COND_NO, EFLAGS))]>,
1439 TB;
1440} // isCommutable = 1
Evan Cheng926658c2007-10-05 23:13:21 +00001441
1442def CMOVB16rm : I<0x42, MRMSrcMem, // if <u, GR16 = [mem16]
1443 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
Sean Callanan2c48df22009-12-18 00:01:26 +00001444 "cmovb{w}\t{$src2, $dst|$dst, $src2}",
Evan Cheng926658c2007-10-05 23:13:21 +00001445 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1446 X86_COND_B, EFLAGS))]>,
1447 TB, OpSize;
1448def CMOVB32rm : I<0x42, MRMSrcMem, // if <u, GR32 = [mem32]
1449 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Sean Callanan2c48df22009-12-18 00:01:26 +00001450 "cmovb{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng926658c2007-10-05 23:13:21 +00001451 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1452 X86_COND_B, EFLAGS))]>,
1453 TB;
1454def CMOVAE16rm: I<0x43, MRMSrcMem, // if >=u, GR16 = [mem16]
1455 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
Sean Callanan2c48df22009-12-18 00:01:26 +00001456 "cmovae{w}\t{$src2, $dst|$dst, $src2}",
Evan Cheng926658c2007-10-05 23:13:21 +00001457 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1458 X86_COND_AE, EFLAGS))]>,
1459 TB, OpSize;
1460def CMOVAE32rm: I<0x43, MRMSrcMem, // if >=u, GR32 = [mem32]
1461 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Sean Callanan2c48df22009-12-18 00:01:26 +00001462 "cmovae{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng926658c2007-10-05 23:13:21 +00001463 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1464 X86_COND_AE, EFLAGS))]>,
1465 TB;
1466def CMOVE16rm : I<0x44, MRMSrcMem, // if ==, GR16 = [mem16]
1467 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
Sean Callanan2c48df22009-12-18 00:01:26 +00001468 "cmove{w}\t{$src2, $dst|$dst, $src2}",
Evan Cheng926658c2007-10-05 23:13:21 +00001469 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1470 X86_COND_E, EFLAGS))]>,
1471 TB, OpSize;
1472def CMOVE32rm : I<0x44, MRMSrcMem, // if ==, GR32 = [mem32]
1473 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Sean Callanan2c48df22009-12-18 00:01:26 +00001474 "cmove{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng926658c2007-10-05 23:13:21 +00001475 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1476 X86_COND_E, EFLAGS))]>,
1477 TB;
1478def CMOVNE16rm: I<0x45, MRMSrcMem, // if !=, GR16 = [mem16]
1479 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
Sean Callanan2c48df22009-12-18 00:01:26 +00001480 "cmovne{w}\t{$src2, $dst|$dst, $src2}",
Evan Cheng926658c2007-10-05 23:13:21 +00001481 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1482 X86_COND_NE, EFLAGS))]>,
1483 TB, OpSize;
1484def CMOVNE32rm: I<0x45, MRMSrcMem, // if !=, GR32 = [mem32]
1485 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Sean Callanan2c48df22009-12-18 00:01:26 +00001486 "cmovne{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng926658c2007-10-05 23:13:21 +00001487 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1488 X86_COND_NE, EFLAGS))]>,
1489 TB;
1490def CMOVBE16rm: I<0x46, MRMSrcMem, // if <=u, GR16 = [mem16]
1491 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
Sean Callanan2c48df22009-12-18 00:01:26 +00001492 "cmovbe{w}\t{$src2, $dst|$dst, $src2}",
Evan Cheng926658c2007-10-05 23:13:21 +00001493 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1494 X86_COND_BE, EFLAGS))]>,
1495 TB, OpSize;
1496def CMOVBE32rm: I<0x46, MRMSrcMem, // if <=u, GR32 = [mem32]
1497 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Sean Callanan2c48df22009-12-18 00:01:26 +00001498 "cmovbe{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng926658c2007-10-05 23:13:21 +00001499 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1500 X86_COND_BE, EFLAGS))]>,
1501 TB;
1502def CMOVA16rm : I<0x47, MRMSrcMem, // if >u, GR16 = [mem16]
1503 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
Sean Callanan2c48df22009-12-18 00:01:26 +00001504 "cmova{w}\t{$src2, $dst|$dst, $src2}",
Evan Cheng926658c2007-10-05 23:13:21 +00001505 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1506 X86_COND_A, EFLAGS))]>,
1507 TB, OpSize;
1508def CMOVA32rm : I<0x47, MRMSrcMem, // if >u, GR32 = [mem32]
1509 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Sean Callanan2c48df22009-12-18 00:01:26 +00001510 "cmova{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng926658c2007-10-05 23:13:21 +00001511 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1512 X86_COND_A, EFLAGS))]>,
1513 TB;
1514def CMOVL16rm : I<0x4C, MRMSrcMem, // if <s, GR16 = [mem16]
1515 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
Sean Callanan2c48df22009-12-18 00:01:26 +00001516 "cmovl{w}\t{$src2, $dst|$dst, $src2}",
Evan Cheng926658c2007-10-05 23:13:21 +00001517 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1518 X86_COND_L, EFLAGS))]>,
1519 TB, OpSize;
1520def CMOVL32rm : I<0x4C, MRMSrcMem, // if <s, GR32 = [mem32]
1521 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Sean Callanan2c48df22009-12-18 00:01:26 +00001522 "cmovl{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng926658c2007-10-05 23:13:21 +00001523 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1524 X86_COND_L, EFLAGS))]>,
1525 TB;
1526def CMOVGE16rm: I<0x4D, MRMSrcMem, // if >=s, GR16 = [mem16]
1527 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
Sean Callanan2c48df22009-12-18 00:01:26 +00001528 "cmovge{w}\t{$src2, $dst|$dst, $src2}",
Evan Cheng926658c2007-10-05 23:13:21 +00001529 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1530 X86_COND_GE, EFLAGS))]>,
1531 TB, OpSize;
1532def CMOVGE32rm: I<0x4D, MRMSrcMem, // if >=s, GR32 = [mem32]
1533 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Sean Callanan2c48df22009-12-18 00:01:26 +00001534 "cmovge{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng926658c2007-10-05 23:13:21 +00001535 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1536 X86_COND_GE, EFLAGS))]>,
1537 TB;
1538def CMOVLE16rm: I<0x4E, MRMSrcMem, // if <=s, GR16 = [mem16]
1539 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
Sean Callanan2c48df22009-12-18 00:01:26 +00001540 "cmovle{w}\t{$src2, $dst|$dst, $src2}",
Evan Cheng926658c2007-10-05 23:13:21 +00001541 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1542 X86_COND_LE, EFLAGS))]>,
1543 TB, OpSize;
1544def CMOVLE32rm: I<0x4E, MRMSrcMem, // if <=s, GR32 = [mem32]
1545 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Sean Callanan2c48df22009-12-18 00:01:26 +00001546 "cmovle{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng926658c2007-10-05 23:13:21 +00001547 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1548 X86_COND_LE, EFLAGS))]>,
1549 TB;
1550def CMOVG16rm : I<0x4F, MRMSrcMem, // if >s, GR16 = [mem16]
1551 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
Sean Callanan2c48df22009-12-18 00:01:26 +00001552 "cmovg{w}\t{$src2, $dst|$dst, $src2}",
Evan Cheng926658c2007-10-05 23:13:21 +00001553 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1554 X86_COND_G, EFLAGS))]>,
1555 TB, OpSize;
1556def CMOVG32rm : I<0x4F, MRMSrcMem, // if >s, GR32 = [mem32]
1557 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Sean Callanan2c48df22009-12-18 00:01:26 +00001558 "cmovg{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng926658c2007-10-05 23:13:21 +00001559 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1560 X86_COND_G, EFLAGS))]>,
1561 TB;
1562def CMOVS16rm : I<0x48, MRMSrcMem, // if signed, GR16 = [mem16]
1563 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
Sean Callanan2c48df22009-12-18 00:01:26 +00001564 "cmovs{w}\t{$src2, $dst|$dst, $src2}",
Evan Cheng926658c2007-10-05 23:13:21 +00001565 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1566 X86_COND_S, EFLAGS))]>,
1567 TB, OpSize;
1568def CMOVS32rm : I<0x48, MRMSrcMem, // if signed, GR32 = [mem32]
1569 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Sean Callanan2c48df22009-12-18 00:01:26 +00001570 "cmovs{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng926658c2007-10-05 23:13:21 +00001571 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1572 X86_COND_S, EFLAGS))]>,
1573 TB;
1574def CMOVNS16rm: I<0x49, MRMSrcMem, // if !signed, GR16 = [mem16]
1575 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
Sean Callanan2c48df22009-12-18 00:01:26 +00001576 "cmovns{w}\t{$src2, $dst|$dst, $src2}",
Evan Cheng926658c2007-10-05 23:13:21 +00001577 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1578 X86_COND_NS, EFLAGS))]>,
1579 TB, OpSize;
1580def CMOVNS32rm: I<0x49, MRMSrcMem, // if !signed, GR32 = [mem32]
1581 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Sean Callanan2c48df22009-12-18 00:01:26 +00001582 "cmovns{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng926658c2007-10-05 23:13:21 +00001583 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1584 X86_COND_NS, EFLAGS))]>,
1585 TB;
1586def CMOVP16rm : I<0x4A, MRMSrcMem, // if parity, GR16 = [mem16]
1587 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
Sean Callanan2c48df22009-12-18 00:01:26 +00001588 "cmovp{w}\t{$src2, $dst|$dst, $src2}",
Evan Cheng926658c2007-10-05 23:13:21 +00001589 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1590 X86_COND_P, EFLAGS))]>,
1591 TB, OpSize;
1592def CMOVP32rm : I<0x4A, MRMSrcMem, // if parity, GR32 = [mem32]
1593 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Sean Callanan2c48df22009-12-18 00:01:26 +00001594 "cmovp{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng926658c2007-10-05 23:13:21 +00001595 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1596 X86_COND_P, EFLAGS))]>,
1597 TB;
1598def CMOVNP16rm : I<0x4B, MRMSrcMem, // if !parity, GR16 = [mem16]
1599 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
Sean Callanan2c48df22009-12-18 00:01:26 +00001600 "cmovnp{w}\t{$src2, $dst|$dst, $src2}",
Evan Cheng926658c2007-10-05 23:13:21 +00001601 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1602 X86_COND_NP, EFLAGS))]>,
1603 TB, OpSize;
Dan Gohman12fd4d72009-01-07 00:35:10 +00001604def CMOVNP32rm : I<0x4B, MRMSrcMem, // if !parity, GR32 = [mem32]
1605 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Sean Callanan2c48df22009-12-18 00:01:26 +00001606 "cmovnp{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohman12fd4d72009-01-07 00:35:10 +00001607 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1608 X86_COND_NP, EFLAGS))]>,
1609 TB;
1610def CMOVO16rm : I<0x40, MRMSrcMem, // if overflow, GR16 = [mem16]
1611 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
Sean Callanan2c48df22009-12-18 00:01:26 +00001612 "cmovo{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohman12fd4d72009-01-07 00:35:10 +00001613 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1614 X86_COND_O, EFLAGS))]>,
1615 TB, OpSize;
1616def CMOVO32rm : I<0x40, MRMSrcMem, // if overflow, GR32 = [mem32]
1617 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Sean Callanan2c48df22009-12-18 00:01:26 +00001618 "cmovo{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohman12fd4d72009-01-07 00:35:10 +00001619 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1620 X86_COND_O, EFLAGS))]>,
1621 TB;
1622def CMOVNO16rm : I<0x41, MRMSrcMem, // if !overflow, GR16 = [mem16]
1623 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
Sean Callanan2c48df22009-12-18 00:01:26 +00001624 "cmovno{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohman12fd4d72009-01-07 00:35:10 +00001625 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1626 X86_COND_NO, EFLAGS))]>,
1627 TB, OpSize;
1628def CMOVNO32rm : I<0x41, MRMSrcMem, // if !overflow, GR32 = [mem32]
1629 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Sean Callanan2c48df22009-12-18 00:01:26 +00001630 "cmovno{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohman12fd4d72009-01-07 00:35:10 +00001631 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1632 X86_COND_NO, EFLAGS))]>,
1633 TB;
Evan Cheng950aac02007-09-25 01:57:46 +00001634} // Uses = [EFLAGS]
1635
1636
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001637// unary instructions
1638let CodeSize = 2 in {
Evan Cheng55687072007-09-14 21:48:26 +00001639let Defs = [EFLAGS] in {
Dan Gohman91888f02007-07-31 20:11:57 +00001640def NEG8r : I<0xF6, MRM3r, (outs GR8 :$dst), (ins GR8 :$src), "neg{b}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001641 [(set GR8:$dst, (ineg GR8:$src)),
1642 (implicit EFLAGS)]>;
Dan Gohman91888f02007-07-31 20:11:57 +00001643def NEG16r : I<0xF7, MRM3r, (outs GR16:$dst), (ins GR16:$src), "neg{w}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001644 [(set GR16:$dst, (ineg GR16:$src)),
1645 (implicit EFLAGS)]>, OpSize;
Dan Gohman91888f02007-07-31 20:11:57 +00001646def NEG32r : I<0xF7, MRM3r, (outs GR32:$dst), (ins GR32:$src), "neg{l}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001647 [(set GR32:$dst, (ineg GR32:$src)),
1648 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001649let isTwoAddress = 0 in {
Dan Gohman91888f02007-07-31 20:11:57 +00001650 def NEG8m : I<0xF6, MRM3m, (outs), (ins i8mem :$dst), "neg{b}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001651 [(store (ineg (loadi8 addr:$dst)), addr:$dst),
1652 (implicit EFLAGS)]>;
Dan Gohman91888f02007-07-31 20:11:57 +00001653 def NEG16m : I<0xF7, MRM3m, (outs), (ins i16mem:$dst), "neg{w}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001654 [(store (ineg (loadi16 addr:$dst)), addr:$dst),
1655 (implicit EFLAGS)]>, OpSize;
Dan Gohman91888f02007-07-31 20:11:57 +00001656 def NEG32m : I<0xF7, MRM3m, (outs), (ins i32mem:$dst), "neg{l}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001657 [(store (ineg (loadi32 addr:$dst)), addr:$dst),
1658 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001659}
Evan Cheng55687072007-09-14 21:48:26 +00001660} // Defs = [EFLAGS]
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001661
Evan Chengc6cee682009-01-21 02:09:05 +00001662// Match xor -1 to not. Favors these over a move imm + xor to save code size.
1663let AddedComplexity = 15 in {
Dan Gohman91888f02007-07-31 20:11:57 +00001664def NOT8r : I<0xF6, MRM2r, (outs GR8 :$dst), (ins GR8 :$src), "not{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001665 [(set GR8:$dst, (not GR8:$src))]>;
Dan Gohman91888f02007-07-31 20:11:57 +00001666def NOT16r : I<0xF7, MRM2r, (outs GR16:$dst), (ins GR16:$src), "not{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001667 [(set GR16:$dst, (not GR16:$src))]>, OpSize;
Dan Gohman91888f02007-07-31 20:11:57 +00001668def NOT32r : I<0xF7, MRM2r, (outs GR32:$dst), (ins GR32:$src), "not{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001669 [(set GR32:$dst, (not GR32:$src))]>;
Evan Chengc6cee682009-01-21 02:09:05 +00001670}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001671let isTwoAddress = 0 in {
Dan Gohman91888f02007-07-31 20:11:57 +00001672 def NOT8m : I<0xF6, MRM2m, (outs), (ins i8mem :$dst), "not{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001673 [(store (not (loadi8 addr:$dst)), addr:$dst)]>;
Dan Gohman91888f02007-07-31 20:11:57 +00001674 def NOT16m : I<0xF7, MRM2m, (outs), (ins i16mem:$dst), "not{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001675 [(store (not (loadi16 addr:$dst)), addr:$dst)]>, OpSize;
Dan Gohman91888f02007-07-31 20:11:57 +00001676 def NOT32m : I<0xF7, MRM2m, (outs), (ins i32mem:$dst), "not{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001677 [(store (not (loadi32 addr:$dst)), addr:$dst)]>;
1678}
1679} // CodeSize
1680
1681// TODO: inc/dec is slow for P4, but fast for Pentium-M.
Evan Cheng55687072007-09-14 21:48:26 +00001682let Defs = [EFLAGS] in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001683let CodeSize = 2 in
Dan Gohman91888f02007-07-31 20:11:57 +00001684def INC8r : I<0xFE, MRM0r, (outs GR8 :$dst), (ins GR8 :$src), "inc{b}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001685 [(set GR8:$dst, (add GR8:$src, 1)),
1686 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001687let isConvertibleToThreeAddress = 1, CodeSize = 1 in { // Can xform into LEA.
Sean Callanan2c48df22009-12-18 00:01:26 +00001688def INC16r : I<0x40, AddRegFrm, (outs GR16:$dst), (ins GR16:$src),
1689 "inc{w}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001690 [(set GR16:$dst, (add GR16:$src, 1)),
1691 (implicit EFLAGS)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001692 OpSize, Requires<[In32BitMode]>;
Sean Callanan2c48df22009-12-18 00:01:26 +00001693def INC32r : I<0x40, AddRegFrm, (outs GR32:$dst), (ins GR32:$src),
1694 "inc{l}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001695 [(set GR32:$dst, (add GR32:$src, 1)),
1696 (implicit EFLAGS)]>, Requires<[In32BitMode]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001697}
1698let isTwoAddress = 0, CodeSize = 2 in {
Dan Gohman91888f02007-07-31 20:11:57 +00001699 def INC8m : I<0xFE, MRM0m, (outs), (ins i8mem :$dst), "inc{b}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001700 [(store (add (loadi8 addr:$dst), 1), addr:$dst),
1701 (implicit EFLAGS)]>;
Dan Gohman91888f02007-07-31 20:11:57 +00001702 def INC16m : I<0xFF, MRM0m, (outs), (ins i16mem:$dst), "inc{w}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001703 [(store (add (loadi16 addr:$dst), 1), addr:$dst),
1704 (implicit EFLAGS)]>,
Evan Cheng4a7e72f2007-10-19 21:23:22 +00001705 OpSize, Requires<[In32BitMode]>;
Dan Gohman91888f02007-07-31 20:11:57 +00001706 def INC32m : I<0xFF, MRM0m, (outs), (ins i32mem:$dst), "inc{l}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001707 [(store (add (loadi32 addr:$dst), 1), addr:$dst),
1708 (implicit EFLAGS)]>,
Evan Cheng4a7e72f2007-10-19 21:23:22 +00001709 Requires<[In32BitMode]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001710}
1711
1712let CodeSize = 2 in
Dan Gohman91888f02007-07-31 20:11:57 +00001713def DEC8r : I<0xFE, MRM1r, (outs GR8 :$dst), (ins GR8 :$src), "dec{b}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001714 [(set GR8:$dst, (add GR8:$src, -1)),
1715 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001716let isConvertibleToThreeAddress = 1, CodeSize = 1 in { // Can xform into LEA.
Sean Callanan2c48df22009-12-18 00:01:26 +00001717def DEC16r : I<0x48, AddRegFrm, (outs GR16:$dst), (ins GR16:$src),
1718 "dec{w}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001719 [(set GR16:$dst, (add GR16:$src, -1)),
1720 (implicit EFLAGS)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001721 OpSize, Requires<[In32BitMode]>;
Sean Callanan2c48df22009-12-18 00:01:26 +00001722def DEC32r : I<0x48, AddRegFrm, (outs GR32:$dst), (ins GR32:$src),
1723 "dec{l}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001724 [(set GR32:$dst, (add GR32:$src, -1)),
1725 (implicit EFLAGS)]>, Requires<[In32BitMode]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001726}
1727
1728let isTwoAddress = 0, CodeSize = 2 in {
Dan Gohman91888f02007-07-31 20:11:57 +00001729 def DEC8m : I<0xFE, MRM1m, (outs), (ins i8mem :$dst), "dec{b}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001730 [(store (add (loadi8 addr:$dst), -1), addr:$dst),
1731 (implicit EFLAGS)]>;
Dan Gohman91888f02007-07-31 20:11:57 +00001732 def DEC16m : I<0xFF, MRM1m, (outs), (ins i16mem:$dst), "dec{w}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001733 [(store (add (loadi16 addr:$dst), -1), addr:$dst),
1734 (implicit EFLAGS)]>,
Evan Cheng4a7e72f2007-10-19 21:23:22 +00001735 OpSize, Requires<[In32BitMode]>;
Dan Gohman91888f02007-07-31 20:11:57 +00001736 def DEC32m : I<0xFF, MRM1m, (outs), (ins i32mem:$dst), "dec{l}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001737 [(store (add (loadi32 addr:$dst), -1), addr:$dst),
1738 (implicit EFLAGS)]>,
Evan Cheng4a7e72f2007-10-19 21:23:22 +00001739 Requires<[In32BitMode]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001740}
Evan Cheng55687072007-09-14 21:48:26 +00001741} // Defs = [EFLAGS]
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001742
1743// Logical operators...
Evan Cheng55687072007-09-14 21:48:26 +00001744let Defs = [EFLAGS] in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001745let isCommutable = 1 in { // X = AND Y, Z --> X = AND Z, Y
1746def AND8rr : I<0x20, MRMDestReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001747 (outs GR8 :$dst), (ins GR8 :$src1, GR8 :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001748 "and{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001749 [(set GR8:$dst, (and GR8:$src1, GR8:$src2)),
1750 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001751def AND16rr : I<0x21, MRMDestReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001752 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001753 "and{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001754 [(set GR16:$dst, (and GR16:$src1, GR16:$src2)),
1755 (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001756def AND32rr : I<0x21, MRMDestReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001757 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001758 "and{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001759 [(set GR32:$dst, (and GR32:$src1, GR32:$src2)),
1760 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001761}
1762
Sean Callanan2c48df22009-12-18 00:01:26 +00001763// AND instructions with the destination register in REG and the source register
1764// in R/M. Included for the disassembler.
1765def AND8rr_REV : I<0x22, MRMSrcReg, (outs GR8:$dst), (ins GR8:$src1, GR8:$src2),
1766 "and{b}\t{$src2, $dst|$dst, $src2}", []>;
1767def AND16rr_REV : I<0x23, MRMSrcReg, (outs GR16:$dst),
1768 (ins GR16:$src1, GR16:$src2),
1769 "and{w}\t{$src2, $dst|$dst, $src2}", []>, OpSize;
1770def AND32rr_REV : I<0x23, MRMSrcReg, (outs GR32:$dst),
1771 (ins GR32:$src1, GR32:$src2),
1772 "and{l}\t{$src2, $dst|$dst, $src2}", []>;
1773
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001774def AND8rm : I<0x22, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001775 (outs GR8 :$dst), (ins GR8 :$src1, i8mem :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001776 "and{b}\t{$src2, $dst|$dst, $src2}",
Chris Lattner12208612009-04-10 00:16:23 +00001777 [(set GR8:$dst, (and GR8:$src1, (loadi8 addr:$src2))),
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001778 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001779def AND16rm : I<0x23, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001780 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001781 "and{w}\t{$src2, $dst|$dst, $src2}",
Chris Lattner12208612009-04-10 00:16:23 +00001782 [(set GR16:$dst, (and GR16:$src1, (loadi16 addr:$src2))),
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001783 (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001784def AND32rm : I<0x23, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001785 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001786 "and{l}\t{$src2, $dst|$dst, $src2}",
Chris Lattner12208612009-04-10 00:16:23 +00001787 [(set GR32:$dst, (and GR32:$src1, (loadi32 addr:$src2))),
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001788 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001789
1790def AND8ri : Ii8<0x80, MRM4r,
Evan Chengb783fa32007-07-19 01:14:50 +00001791 (outs GR8 :$dst), (ins GR8 :$src1, i8imm :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001792 "and{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001793 [(set GR8:$dst, (and GR8:$src1, imm:$src2)),
1794 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001795def AND16ri : Ii16<0x81, MRM4r,
Evan Chengb783fa32007-07-19 01:14:50 +00001796 (outs GR16:$dst), (ins GR16:$src1, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001797 "and{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001798 [(set GR16:$dst, (and GR16:$src1, imm:$src2)),
1799 (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001800def AND32ri : Ii32<0x81, MRM4r,
Evan Chengb783fa32007-07-19 01:14:50 +00001801 (outs GR32:$dst), (ins GR32:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001802 "and{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001803 [(set GR32:$dst, (and GR32:$src1, imm:$src2)),
1804 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001805def AND16ri8 : Ii8<0x83, MRM4r,
Evan Chengb783fa32007-07-19 01:14:50 +00001806 (outs GR16:$dst), (ins GR16:$src1, i16i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001807 "and{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001808 [(set GR16:$dst, (and GR16:$src1, i16immSExt8:$src2)),
1809 (implicit EFLAGS)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001810 OpSize;
1811def AND32ri8 : Ii8<0x83, MRM4r,
Evan Chengb783fa32007-07-19 01:14:50 +00001812 (outs GR32:$dst), (ins GR32:$src1, i32i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001813 "and{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001814 [(set GR32:$dst, (and GR32:$src1, i32immSExt8:$src2)),
1815 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001816
1817let isTwoAddress = 0 in {
1818 def AND8mr : I<0x20, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001819 (outs), (ins i8mem :$dst, GR8 :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001820 "and{b}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001821 [(store (and (load addr:$dst), GR8:$src), addr:$dst),
1822 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001823 def AND16mr : I<0x21, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001824 (outs), (ins i16mem:$dst, GR16:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001825 "and{w}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001826 [(store (and (load addr:$dst), GR16:$src), addr:$dst),
1827 (implicit EFLAGS)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001828 OpSize;
1829 def AND32mr : I<0x21, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001830 (outs), (ins i32mem:$dst, GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001831 "and{l}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001832 [(store (and (load addr:$dst), GR32:$src), addr:$dst),
1833 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001834 def AND8mi : Ii8<0x80, MRM4m,
Evan Chengb783fa32007-07-19 01:14:50 +00001835 (outs), (ins i8mem :$dst, i8imm :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001836 "and{b}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001837 [(store (and (loadi8 addr:$dst), imm:$src), addr:$dst),
1838 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001839 def AND16mi : Ii16<0x81, MRM4m,
Evan Chengb783fa32007-07-19 01:14:50 +00001840 (outs), (ins i16mem:$dst, i16imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001841 "and{w}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001842 [(store (and (loadi16 addr:$dst), imm:$src), addr:$dst),
1843 (implicit EFLAGS)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001844 OpSize;
1845 def AND32mi : Ii32<0x81, MRM4m,
Evan Chengb783fa32007-07-19 01:14:50 +00001846 (outs), (ins i32mem:$dst, i32imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001847 "and{l}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001848 [(store (and (loadi32 addr:$dst), imm:$src), addr:$dst),
1849 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001850 def AND16mi8 : Ii8<0x83, MRM4m,
Evan Chengb783fa32007-07-19 01:14:50 +00001851 (outs), (ins i16mem:$dst, i16i8imm :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001852 "and{w}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001853 [(store (and (load addr:$dst), i16immSExt8:$src), addr:$dst),
1854 (implicit EFLAGS)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001855 OpSize;
1856 def AND32mi8 : Ii8<0x83, MRM4m,
Evan Chengb783fa32007-07-19 01:14:50 +00001857 (outs), (ins i32mem:$dst, i32i8imm :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001858 "and{l}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001859 [(store (and (load addr:$dst), i32immSExt8:$src), addr:$dst),
1860 (implicit EFLAGS)]>;
Sean Callanan251676e2009-09-02 00:55:49 +00001861
1862 def AND8i8 : Ii8<0x24, RawFrm, (outs), (ins i8imm:$src),
1863 "and{b}\t{$src, %al|%al, $src}", []>;
1864 def AND16i16 : Ii16<0x25, RawFrm, (outs), (ins i16imm:$src),
1865 "and{w}\t{$src, %ax|%ax, $src}", []>, OpSize;
1866 def AND32i32 : Ii32<0x25, RawFrm, (outs), (ins i32imm:$src),
1867 "and{l}\t{$src, %eax|%eax, $src}", []>;
1868
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001869}
1870
1871
1872let isCommutable = 1 in { // X = OR Y, Z --> X = OR Z, Y
Sean Callanan2c48df22009-12-18 00:01:26 +00001873def OR8rr : I<0x08, MRMDestReg, (outs GR8 :$dst),
1874 (ins GR8 :$src1, GR8 :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001875 "or{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001876 [(set GR8:$dst, (or GR8:$src1, GR8:$src2)),
1877 (implicit EFLAGS)]>;
Sean Callanan2c48df22009-12-18 00:01:26 +00001878def OR16rr : I<0x09, MRMDestReg, (outs GR16:$dst),
1879 (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001880 "or{w}\t{$src2, $dst|$dst, $src2}",
Evan Cheng44a441c2010-01-12 18:31:19 +00001881 [(set GR16:$dst, (or GR16:$src1, GR16:$src2)),
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001882 (implicit EFLAGS)]>, OpSize;
Sean Callanan2c48df22009-12-18 00:01:26 +00001883def OR32rr : I<0x09, MRMDestReg, (outs GR32:$dst),
1884 (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001885 "or{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng44a441c2010-01-12 18:31:19 +00001886 [(set GR32:$dst, (or GR32:$src1, GR32:$src2)),
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001887 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001888}
Sean Callanan2c48df22009-12-18 00:01:26 +00001889
1890// OR instructions with the destination register in REG and the source register
1891// in R/M. Included for the disassembler.
1892def OR8rr_REV : I<0x0A, MRMSrcReg, (outs GR8:$dst), (ins GR8:$src1, GR8:$src2),
1893 "or{b}\t{$src2, $dst|$dst, $src2}", []>;
1894def OR16rr_REV : I<0x0B, MRMSrcReg, (outs GR16:$dst),
1895 (ins GR16:$src1, GR16:$src2),
1896 "or{w}\t{$src2, $dst|$dst, $src2}", []>, OpSize;
1897def OR32rr_REV : I<0x0B, MRMSrcReg, (outs GR32:$dst),
1898 (ins GR32:$src1, GR32:$src2),
1899 "or{l}\t{$src2, $dst|$dst, $src2}", []>;
1900
1901def OR8rm : I<0x0A, MRMSrcMem , (outs GR8 :$dst),
1902 (ins GR8 :$src1, i8mem :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001903 "or{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001904 [(set GR8:$dst, (or GR8:$src1, (load addr:$src2))),
1905 (implicit EFLAGS)]>;
Sean Callanan2c48df22009-12-18 00:01:26 +00001906def OR16rm : I<0x0B, MRMSrcMem , (outs GR16:$dst),
1907 (ins GR16:$src1, i16mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001908 "or{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001909 [(set GR16:$dst, (or GR16:$src1, (load addr:$src2))),
1910 (implicit EFLAGS)]>, OpSize;
Sean Callanan2c48df22009-12-18 00:01:26 +00001911def OR32rm : I<0x0B, MRMSrcMem , (outs GR32:$dst),
1912 (ins GR32:$src1, i32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001913 "or{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001914 [(set GR32:$dst, (or GR32:$src1, (load addr:$src2))),
1915 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001916
Sean Callanan2c48df22009-12-18 00:01:26 +00001917def OR8ri : Ii8 <0x80, MRM1r, (outs GR8 :$dst),
1918 (ins GR8 :$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001919 "or{b}\t{$src2, $dst|$dst, $src2}",
Evan Cheng87516752010-01-11 20:18:04 +00001920 [(set GR8:$dst, (or GR8:$src1, imm:$src2)),
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001921 (implicit EFLAGS)]>;
Sean Callanan2c48df22009-12-18 00:01:26 +00001922def OR16ri : Ii16<0x81, MRM1r, (outs GR16:$dst),
1923 (ins GR16:$src1, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001924 "or{w}\t{$src2, $dst|$dst, $src2}",
Evan Cheng44a441c2010-01-12 18:31:19 +00001925 [(set GR16:$dst, (or GR16:$src1, imm:$src2)),
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001926 (implicit EFLAGS)]>, OpSize;
Sean Callanan2c48df22009-12-18 00:01:26 +00001927def OR32ri : Ii32<0x81, MRM1r, (outs GR32:$dst),
1928 (ins GR32:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001929 "or{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng44a441c2010-01-12 18:31:19 +00001930 [(set GR32:$dst, (or GR32:$src1, imm:$src2)),
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001931 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001932
Sean Callanan2c48df22009-12-18 00:01:26 +00001933def OR16ri8 : Ii8<0x83, MRM1r, (outs GR16:$dst),
1934 (ins GR16:$src1, i16i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001935 "or{w}\t{$src2, $dst|$dst, $src2}",
Evan Cheng44a441c2010-01-12 18:31:19 +00001936 [(set GR16:$dst, (or GR16:$src1, i16immSExt8:$src2)),
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001937 (implicit EFLAGS)]>, OpSize;
Sean Callanan2c48df22009-12-18 00:01:26 +00001938def OR32ri8 : Ii8<0x83, MRM1r, (outs GR32:$dst),
1939 (ins GR32:$src1, i32i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001940 "or{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng44a441c2010-01-12 18:31:19 +00001941 [(set GR32:$dst, (or GR32:$src1, i32immSExt8:$src2)),
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001942 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001943let isTwoAddress = 0 in {
Evan Chengb783fa32007-07-19 01:14:50 +00001944 def OR8mr : I<0x08, MRMDestMem, (outs), (ins i8mem:$dst, GR8:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001945 "or{b}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001946 [(store (or (load addr:$dst), GR8:$src), addr:$dst),
1947 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001948 def OR16mr : I<0x09, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001949 "or{w}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001950 [(store (or (load addr:$dst), GR16:$src), addr:$dst),
1951 (implicit EFLAGS)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001952 def OR32mr : I<0x09, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001953 "or{l}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001954 [(store (or (load addr:$dst), GR32:$src), addr:$dst),
1955 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001956 def OR8mi : Ii8<0x80, MRM1m, (outs), (ins i8mem :$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001957 "or{b}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001958 [(store (or (loadi8 addr:$dst), imm:$src), addr:$dst),
1959 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001960 def OR16mi : Ii16<0x81, MRM1m, (outs), (ins i16mem:$dst, i16imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001961 "or{w}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001962 [(store (or (loadi16 addr:$dst), imm:$src), addr:$dst),
1963 (implicit EFLAGS)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001964 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001965 def OR32mi : Ii32<0x81, MRM1m, (outs), (ins i32mem:$dst, i32imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001966 "or{l}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001967 [(store (or (loadi32 addr:$dst), imm:$src), addr:$dst),
1968 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001969 def OR16mi8 : Ii8<0x83, MRM1m, (outs), (ins i16mem:$dst, i16i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001970 "or{w}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001971 [(store (or (load addr:$dst), i16immSExt8:$src), addr:$dst),
1972 (implicit EFLAGS)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001973 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001974 def OR32mi8 : Ii8<0x83, MRM1m, (outs), (ins i32mem:$dst, i32i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001975 "or{l}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001976 [(store (or (load addr:$dst), i32immSExt8:$src), addr:$dst),
1977 (implicit EFLAGS)]>;
Sean Callanan8562bef2009-09-11 19:01:56 +00001978
1979 def OR8i8 : Ii8 <0x0C, RawFrm, (outs), (ins i8imm:$src),
1980 "or{b}\t{$src, %al|%al, $src}", []>;
1981 def OR16i16 : Ii16 <0x0D, RawFrm, (outs), (ins i16imm:$src),
1982 "or{w}\t{$src, %ax|%ax, $src}", []>, OpSize;
1983 def OR32i32 : Ii32 <0x0D, RawFrm, (outs), (ins i32imm:$src),
1984 "or{l}\t{$src, %eax|%eax, $src}", []>;
Bill Wendlingba5d5b02008-05-29 01:02:09 +00001985} // isTwoAddress = 0
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001986
1987
Evan Cheng6f26e8b2008-06-18 08:13:07 +00001988let isCommutable = 1 in { // X = XOR Y, Z --> X = XOR Z, Y
Bill Wendlingba5d5b02008-05-29 01:02:09 +00001989 def XOR8rr : I<0x30, MRMDestReg,
1990 (outs GR8 :$dst), (ins GR8 :$src1, GR8 :$src2),
1991 "xor{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001992 [(set GR8:$dst, (xor GR8:$src1, GR8:$src2)),
1993 (implicit EFLAGS)]>;
Bill Wendlingba5d5b02008-05-29 01:02:09 +00001994 def XOR16rr : I<0x31, MRMDestReg,
1995 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
1996 "xor{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001997 [(set GR16:$dst, (xor GR16:$src1, GR16:$src2)),
1998 (implicit EFLAGS)]>, OpSize;
Bill Wendlingba5d5b02008-05-29 01:02:09 +00001999 def XOR32rr : I<0x31, MRMDestReg,
2000 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
2001 "xor{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00002002 [(set GR32:$dst, (xor GR32:$src1, GR32:$src2)),
2003 (implicit EFLAGS)]>;
Evan Cheng6f26e8b2008-06-18 08:13:07 +00002004} // isCommutable = 1
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002005
Sean Callanan2c48df22009-12-18 00:01:26 +00002006// XOR instructions with the destination register in REG and the source register
2007// in R/M. Included for the disassembler.
2008def XOR8rr_REV : I<0x32, MRMSrcReg, (outs GR8:$dst), (ins GR8:$src1, GR8:$src2),
2009 "xor{b}\t{$src2, $dst|$dst, $src2}", []>;
2010def XOR16rr_REV : I<0x33, MRMSrcReg, (outs GR16:$dst),
2011 (ins GR16:$src1, GR16:$src2),
2012 "xor{w}\t{$src2, $dst|$dst, $src2}", []>, OpSize;
2013def XOR32rr_REV : I<0x33, MRMSrcReg, (outs GR32:$dst),
2014 (ins GR32:$src1, GR32:$src2),
2015 "xor{l}\t{$src2, $dst|$dst, $src2}", []>;
2016
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002017def XOR8rm : I<0x32, MRMSrcMem ,
Evan Chengb783fa32007-07-19 01:14:50 +00002018 (outs GR8 :$dst), (ins GR8:$src1, i8mem :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002019 "xor{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00002020 [(set GR8:$dst, (xor GR8:$src1, (load addr:$src2))),
2021 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002022def XOR16rm : I<0x33, MRMSrcMem ,
Evan Chengb783fa32007-07-19 01:14:50 +00002023 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002024 "xor{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00002025 [(set GR16:$dst, (xor GR16:$src1, (load addr:$src2))),
2026 (implicit EFLAGS)]>,
Bill Wendlingba5d5b02008-05-29 01:02:09 +00002027 OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002028def XOR32rm : I<0x33, MRMSrcMem ,
Evan Chengb783fa32007-07-19 01:14:50 +00002029 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002030 "xor{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00002031 [(set GR32:$dst, (xor GR32:$src1, (load addr:$src2))),
2032 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002033
Bill Wendlingbac38eb2008-05-29 03:46:36 +00002034def XOR8ri : Ii8<0x80, MRM6r,
2035 (outs GR8:$dst), (ins GR8:$src1, i8imm:$src2),
2036 "xor{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00002037 [(set GR8:$dst, (xor GR8:$src1, imm:$src2)),
2038 (implicit EFLAGS)]>;
Bill Wendlingbac38eb2008-05-29 03:46:36 +00002039def XOR16ri : Ii16<0x81, MRM6r,
2040 (outs GR16:$dst), (ins GR16:$src1, i16imm:$src2),
2041 "xor{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00002042 [(set GR16:$dst, (xor GR16:$src1, imm:$src2)),
2043 (implicit EFLAGS)]>, OpSize;
Bill Wendlingbac38eb2008-05-29 03:46:36 +00002044def XOR32ri : Ii32<0x81, MRM6r,
2045 (outs GR32:$dst), (ins GR32:$src1, i32imm:$src2),
2046 "xor{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00002047 [(set GR32:$dst, (xor GR32:$src1, imm:$src2)),
2048 (implicit EFLAGS)]>;
Bill Wendlingbac38eb2008-05-29 03:46:36 +00002049def XOR16ri8 : Ii8<0x83, MRM6r,
2050 (outs GR16:$dst), (ins GR16:$src1, i16i8imm:$src2),
2051 "xor{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00002052 [(set GR16:$dst, (xor GR16:$src1, i16immSExt8:$src2)),
2053 (implicit EFLAGS)]>,
Bill Wendlingbac38eb2008-05-29 03:46:36 +00002054 OpSize;
2055def XOR32ri8 : Ii8<0x83, MRM6r,
2056 (outs GR32:$dst), (ins GR32:$src1, i32i8imm:$src2),
2057 "xor{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00002058 [(set GR32:$dst, (xor GR32:$src1, i32immSExt8:$src2)),
2059 (implicit EFLAGS)]>;
Bill Wendlingba5d5b02008-05-29 01:02:09 +00002060
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002061let isTwoAddress = 0 in {
2062 def XOR8mr : I<0x30, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00002063 (outs), (ins i8mem :$dst, GR8 :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002064 "xor{b}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00002065 [(store (xor (load addr:$dst), GR8:$src), addr:$dst),
2066 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002067 def XOR16mr : I<0x31, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00002068 (outs), (ins i16mem:$dst, GR16:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002069 "xor{w}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00002070 [(store (xor (load addr:$dst), GR16:$src), addr:$dst),
2071 (implicit EFLAGS)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002072 OpSize;
2073 def XOR32mr : I<0x31, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00002074 (outs), (ins i32mem:$dst, GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002075 "xor{l}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00002076 [(store (xor (load addr:$dst), GR32:$src), addr:$dst),
2077 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002078 def XOR8mi : Ii8<0x80, MRM6m,
Evan Chengb783fa32007-07-19 01:14:50 +00002079 (outs), (ins i8mem :$dst, i8imm :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002080 "xor{b}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00002081 [(store (xor (loadi8 addr:$dst), imm:$src), addr:$dst),
2082 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002083 def XOR16mi : Ii16<0x81, MRM6m,
Evan Chengb783fa32007-07-19 01:14:50 +00002084 (outs), (ins i16mem:$dst, i16imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002085 "xor{w}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00002086 [(store (xor (loadi16 addr:$dst), imm:$src), addr:$dst),
2087 (implicit EFLAGS)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002088 OpSize;
2089 def XOR32mi : Ii32<0x81, MRM6m,
Evan Chengb783fa32007-07-19 01:14:50 +00002090 (outs), (ins i32mem:$dst, i32imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002091 "xor{l}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00002092 [(store (xor (loadi32 addr:$dst), imm:$src), addr:$dst),
2093 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002094 def XOR16mi8 : Ii8<0x83, MRM6m,
Evan Chengb783fa32007-07-19 01:14:50 +00002095 (outs), (ins i16mem:$dst, i16i8imm :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002096 "xor{w}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00002097 [(store (xor (load addr:$dst), i16immSExt8:$src), addr:$dst),
2098 (implicit EFLAGS)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002099 OpSize;
2100 def XOR32mi8 : Ii8<0x83, MRM6m,
Evan Chengb783fa32007-07-19 01:14:50 +00002101 (outs), (ins i32mem:$dst, i32i8imm :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002102 "xor{l}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00002103 [(store (xor (load addr:$dst), i32immSExt8:$src), addr:$dst),
2104 (implicit EFLAGS)]>;
Sean Callanan794457a2009-09-10 19:52:26 +00002105
2106 def XOR8i8 : Ii8 <0x34, RawFrm, (outs), (ins i8imm:$src),
2107 "xor{b}\t{$src, %al|%al, $src}", []>;
2108 def XOR16i16 : Ii16 <0x35, RawFrm, (outs), (ins i16imm:$src),
2109 "xor{w}\t{$src, %ax|%ax, $src}", []>, OpSize;
2110 def XOR32i32 : Ii32 <0x35, RawFrm, (outs), (ins i32imm:$src),
2111 "xor{l}\t{$src, %eax|%eax, $src}", []>;
Bill Wendlingba5d5b02008-05-29 01:02:09 +00002112} // isTwoAddress = 0
Evan Cheng55687072007-09-14 21:48:26 +00002113} // Defs = [EFLAGS]
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002114
2115// Shift instructions
Evan Cheng55687072007-09-14 21:48:26 +00002116let Defs = [EFLAGS] in {
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002117let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00002118def SHL8rCL : I<0xD2, MRM4r, (outs GR8 :$dst), (ins GR8 :$src),
Eli Friedman378ea832009-06-19 04:48:38 +00002119 "shl{b}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002120 [(set GR8:$dst, (shl GR8:$src, CL))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002121def SHL16rCL : I<0xD3, MRM4r, (outs GR16:$dst), (ins GR16:$src),
Eli Friedman378ea832009-06-19 04:48:38 +00002122 "shl{w}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002123 [(set GR16:$dst, (shl GR16:$src, CL))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002124def SHL32rCL : I<0xD3, MRM4r, (outs GR32:$dst), (ins GR32:$src),
Eli Friedman378ea832009-06-19 04:48:38 +00002125 "shl{l}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002126 [(set GR32:$dst, (shl GR32:$src, CL))]>;
Bill Wendlingba5d5b02008-05-29 01:02:09 +00002127} // Uses = [CL]
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002128
Evan Chengb783fa32007-07-19 01:14:50 +00002129def SHL8ri : Ii8<0xC0, MRM4r, (outs GR8 :$dst), (ins GR8 :$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002130 "shl{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002131 [(set GR8:$dst, (shl GR8:$src1, (i8 imm:$src2)))]>;
2132let isConvertibleToThreeAddress = 1 in { // Can transform into LEA.
Evan Chengb783fa32007-07-19 01:14:50 +00002133def SHL16ri : Ii8<0xC1, MRM4r, (outs GR16:$dst), (ins GR16:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002134 "shl{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002135 [(set GR16:$dst, (shl GR16:$src1, (i8 imm:$src2)))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002136def SHL32ri : Ii8<0xC1, MRM4r, (outs GR32:$dst), (ins GR32:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002137 "shl{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002138 [(set GR32:$dst, (shl GR32:$src1, (i8 imm:$src2)))]>;
Sean Callananca503e02009-09-16 02:28:43 +00002139
2140// NOTE: We don't include patterns for shifts of a register by one, because
2141// 'add reg,reg' is cheaper.
2142
2143def SHL8r1 : I<0xD0, MRM4r, (outs GR8:$dst), (ins GR8:$src1),
2144 "shl{b}\t$dst", []>;
2145def SHL16r1 : I<0xD1, MRM4r, (outs GR16:$dst), (ins GR16:$src1),
2146 "shl{w}\t$dst", []>, OpSize;
2147def SHL32r1 : I<0xD1, MRM4r, (outs GR32:$dst), (ins GR32:$src1),
2148 "shl{l}\t$dst", []>;
2149
Bill Wendlingba5d5b02008-05-29 01:02:09 +00002150} // isConvertibleToThreeAddress = 1
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002151
2152let isTwoAddress = 0 in {
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002153 let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00002154 def SHL8mCL : I<0xD2, MRM4m, (outs), (ins i8mem :$dst),
Eli Friedman378ea832009-06-19 04:48:38 +00002155 "shl{b}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002156 [(store (shl (loadi8 addr:$dst), CL), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002157 def SHL16mCL : I<0xD3, MRM4m, (outs), (ins i16mem:$dst),
Eli Friedman378ea832009-06-19 04:48:38 +00002158 "shl{w}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002159 [(store (shl (loadi16 addr:$dst), CL), addr:$dst)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002160 def SHL32mCL : I<0xD3, MRM4m, (outs), (ins i32mem:$dst),
Eli Friedman378ea832009-06-19 04:48:38 +00002161 "shl{l}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002162 [(store (shl (loadi32 addr:$dst), CL), addr:$dst)]>;
2163 }
Evan Chengb783fa32007-07-19 01:14:50 +00002164 def SHL8mi : Ii8<0xC0, MRM4m, (outs), (ins i8mem :$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002165 "shl{b}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002166 [(store (shl (loadi8 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002167 def SHL16mi : Ii8<0xC1, MRM4m, (outs), (ins i16mem:$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002168 "shl{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002169 [(store (shl (loadi16 addr:$dst), (i8 imm:$src)), addr:$dst)]>,
2170 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002171 def SHL32mi : Ii8<0xC1, MRM4m, (outs), (ins i32mem:$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002172 "shl{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002173 [(store (shl (loadi32 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
2174
2175 // Shift by 1
Evan Chengb783fa32007-07-19 01:14:50 +00002176 def SHL8m1 : I<0xD0, MRM4m, (outs), (ins i8mem :$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002177 "shl{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002178 [(store (shl (loadi8 addr:$dst), (i8 1)), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002179 def SHL16m1 : I<0xD1, MRM4m, (outs), (ins i16mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002180 "shl{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002181 [(store (shl (loadi16 addr:$dst), (i8 1)), addr:$dst)]>,
2182 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002183 def SHL32m1 : I<0xD1, MRM4m, (outs), (ins i32mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002184 "shl{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002185 [(store (shl (loadi32 addr:$dst), (i8 1)), addr:$dst)]>;
2186}
2187
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002188let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00002189def SHR8rCL : I<0xD2, MRM5r, (outs GR8 :$dst), (ins GR8 :$src),
Eli Friedman378ea832009-06-19 04:48:38 +00002190 "shr{b}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002191 [(set GR8:$dst, (srl GR8:$src, CL))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002192def SHR16rCL : I<0xD3, MRM5r, (outs GR16:$dst), (ins GR16:$src),
Eli Friedman378ea832009-06-19 04:48:38 +00002193 "shr{w}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002194 [(set GR16:$dst, (srl GR16:$src, CL))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002195def SHR32rCL : I<0xD3, MRM5r, (outs GR32:$dst), (ins GR32:$src),
Eli Friedman378ea832009-06-19 04:48:38 +00002196 "shr{l}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002197 [(set GR32:$dst, (srl GR32:$src, CL))]>;
2198}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002199
Evan Chengb783fa32007-07-19 01:14:50 +00002200def SHR8ri : Ii8<0xC0, MRM5r, (outs GR8:$dst), (ins GR8:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002201 "shr{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002202 [(set GR8:$dst, (srl GR8:$src1, (i8 imm:$src2)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002203def SHR16ri : Ii8<0xC1, MRM5r, (outs GR16:$dst), (ins GR16:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002204 "shr{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002205 [(set GR16:$dst, (srl GR16:$src1, (i8 imm:$src2)))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002206def SHR32ri : Ii8<0xC1, MRM5r, (outs GR32:$dst), (ins GR32:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002207 "shr{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002208 [(set GR32:$dst, (srl GR32:$src1, (i8 imm:$src2)))]>;
2209
2210// Shift by 1
Evan Chengb783fa32007-07-19 01:14:50 +00002211def SHR8r1 : I<0xD0, MRM5r, (outs GR8:$dst), (ins GR8:$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00002212 "shr{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002213 [(set GR8:$dst, (srl GR8:$src1, (i8 1)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002214def SHR16r1 : I<0xD1, MRM5r, (outs GR16:$dst), (ins GR16:$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00002215 "shr{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002216 [(set GR16:$dst, (srl GR16:$src1, (i8 1)))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002217def SHR32r1 : I<0xD1, MRM5r, (outs GR32:$dst), (ins GR32:$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00002218 "shr{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002219 [(set GR32:$dst, (srl GR32:$src1, (i8 1)))]>;
2220
2221let isTwoAddress = 0 in {
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002222 let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00002223 def SHR8mCL : I<0xD2, MRM5m, (outs), (ins i8mem :$dst),
Eli Friedman378ea832009-06-19 04:48:38 +00002224 "shr{b}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002225 [(store (srl (loadi8 addr:$dst), CL), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002226 def SHR16mCL : I<0xD3, MRM5m, (outs), (ins i16mem:$dst),
Eli Friedman378ea832009-06-19 04:48:38 +00002227 "shr{w}\t{%cl, $dst|$dst, CL}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002228 [(store (srl (loadi16 addr:$dst), CL), addr:$dst)]>,
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002229 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002230 def SHR32mCL : I<0xD3, MRM5m, (outs), (ins i32mem:$dst),
Eli Friedman378ea832009-06-19 04:48:38 +00002231 "shr{l}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002232 [(store (srl (loadi32 addr:$dst), CL), addr:$dst)]>;
2233 }
Evan Chengb783fa32007-07-19 01:14:50 +00002234 def SHR8mi : Ii8<0xC0, MRM5m, (outs), (ins i8mem :$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002235 "shr{b}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002236 [(store (srl (loadi8 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002237 def SHR16mi : Ii8<0xC1, MRM5m, (outs), (ins i16mem:$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002238 "shr{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002239 [(store (srl (loadi16 addr:$dst), (i8 imm:$src)), addr:$dst)]>,
2240 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002241 def SHR32mi : Ii8<0xC1, MRM5m, (outs), (ins i32mem:$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002242 "shr{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002243 [(store (srl (loadi32 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
2244
2245 // Shift by 1
Evan Chengb783fa32007-07-19 01:14:50 +00002246 def SHR8m1 : I<0xD0, MRM5m, (outs), (ins i8mem :$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002247 "shr{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002248 [(store (srl (loadi8 addr:$dst), (i8 1)), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002249 def SHR16m1 : I<0xD1, MRM5m, (outs), (ins i16mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002250 "shr{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002251 [(store (srl (loadi16 addr:$dst), (i8 1)), addr:$dst)]>,OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002252 def SHR32m1 : I<0xD1, MRM5m, (outs), (ins i32mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002253 "shr{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002254 [(store (srl (loadi32 addr:$dst), (i8 1)), addr:$dst)]>;
2255}
2256
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002257let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00002258def SAR8rCL : I<0xD2, MRM7r, (outs GR8 :$dst), (ins GR8 :$src),
Eli Friedman378ea832009-06-19 04:48:38 +00002259 "sar{b}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002260 [(set GR8:$dst, (sra GR8:$src, CL))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002261def SAR16rCL : I<0xD3, MRM7r, (outs GR16:$dst), (ins GR16:$src),
Eli Friedman378ea832009-06-19 04:48:38 +00002262 "sar{w}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002263 [(set GR16:$dst, (sra GR16:$src, CL))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002264def SAR32rCL : I<0xD3, MRM7r, (outs GR32:$dst), (ins GR32:$src),
Eli Friedman378ea832009-06-19 04:48:38 +00002265 "sar{l}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002266 [(set GR32:$dst, (sra GR32:$src, CL))]>;
2267}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002268
Evan Chengb783fa32007-07-19 01:14:50 +00002269def SAR8ri : Ii8<0xC0, MRM7r, (outs GR8 :$dst), (ins GR8 :$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002270 "sar{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002271 [(set GR8:$dst, (sra GR8:$src1, (i8 imm:$src2)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002272def SAR16ri : Ii8<0xC1, MRM7r, (outs GR16:$dst), (ins GR16:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002273 "sar{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002274 [(set GR16:$dst, (sra GR16:$src1, (i8 imm:$src2)))]>,
2275 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002276def SAR32ri : Ii8<0xC1, MRM7r, (outs GR32:$dst), (ins GR32:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002277 "sar{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002278 [(set GR32:$dst, (sra GR32:$src1, (i8 imm:$src2)))]>;
2279
2280// Shift by 1
Evan Chengb783fa32007-07-19 01:14:50 +00002281def SAR8r1 : I<0xD0, MRM7r, (outs GR8 :$dst), (ins GR8 :$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00002282 "sar{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002283 [(set GR8:$dst, (sra GR8:$src1, (i8 1)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002284def SAR16r1 : I<0xD1, MRM7r, (outs GR16:$dst), (ins GR16:$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00002285 "sar{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002286 [(set GR16:$dst, (sra GR16:$src1, (i8 1)))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002287def SAR32r1 : I<0xD1, MRM7r, (outs GR32:$dst), (ins GR32:$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00002288 "sar{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002289 [(set GR32:$dst, (sra GR32:$src1, (i8 1)))]>;
2290
2291let isTwoAddress = 0 in {
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002292 let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00002293 def SAR8mCL : I<0xD2, MRM7m, (outs), (ins i8mem :$dst),
Eli Friedman378ea832009-06-19 04:48:38 +00002294 "sar{b}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002295 [(store (sra (loadi8 addr:$dst), CL), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002296 def SAR16mCL : I<0xD3, MRM7m, (outs), (ins i16mem:$dst),
Eli Friedman378ea832009-06-19 04:48:38 +00002297 "sar{w}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002298 [(store (sra (loadi16 addr:$dst), CL), addr:$dst)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002299 def SAR32mCL : I<0xD3, MRM7m, (outs), (ins i32mem:$dst),
Eli Friedman378ea832009-06-19 04:48:38 +00002300 "sar{l}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002301 [(store (sra (loadi32 addr:$dst), CL), addr:$dst)]>;
2302 }
Evan Chengb783fa32007-07-19 01:14:50 +00002303 def SAR8mi : Ii8<0xC0, MRM7m, (outs), (ins i8mem :$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002304 "sar{b}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002305 [(store (sra (loadi8 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002306 def SAR16mi : Ii8<0xC1, MRM7m, (outs), (ins i16mem:$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002307 "sar{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002308 [(store (sra (loadi16 addr:$dst), (i8 imm:$src)), addr:$dst)]>,
2309 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002310 def SAR32mi : Ii8<0xC1, MRM7m, (outs), (ins i32mem:$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002311 "sar{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002312 [(store (sra (loadi32 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
2313
2314 // Shift by 1
Evan Chengb783fa32007-07-19 01:14:50 +00002315 def SAR8m1 : I<0xD0, MRM7m, (outs), (ins i8mem :$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002316 "sar{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002317 [(store (sra (loadi8 addr:$dst), (i8 1)), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002318 def SAR16m1 : I<0xD1, MRM7m, (outs), (ins i16mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002319 "sar{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002320 [(store (sra (loadi16 addr:$dst), (i8 1)), addr:$dst)]>,
2321 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002322 def SAR32m1 : I<0xD1, MRM7m, (outs), (ins i32mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002323 "sar{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002324 [(store (sra (loadi32 addr:$dst), (i8 1)), addr:$dst)]>;
2325}
2326
2327// Rotate instructions
Sean Callanan3c8eecd2009-09-18 19:35:23 +00002328
2329def RCL8r1 : I<0xD0, MRM2r, (outs GR8:$dst), (ins GR8:$src),
2330 "rcl{b}\t{1, $dst|$dst, 1}", []>;
2331def RCL8m1 : I<0xD0, MRM2m, (outs i8mem:$dst), (ins i8mem:$src),
2332 "rcl{b}\t{1, $dst|$dst, 1}", []>;
2333let Uses = [CL] in {
2334def RCL8rCL : I<0xD2, MRM2r, (outs GR8:$dst), (ins GR8:$src),
2335 "rcl{b}\t{%cl, $dst|$dst, CL}", []>;
2336def RCL8mCL : I<0xD2, MRM2m, (outs i8mem:$dst), (ins i8mem:$src),
2337 "rcl{b}\t{%cl, $dst|$dst, CL}", []>;
2338}
2339def RCL8ri : Ii8<0xC0, MRM2r, (outs GR8:$dst), (ins GR8:$src, i8imm:$cnt),
2340 "rcl{b}\t{$cnt, $dst|$dst, $cnt}", []>;
2341def RCL8mi : Ii8<0xC0, MRM2m, (outs i8mem:$dst), (ins i8mem:$src, i8imm:$cnt),
2342 "rcl{b}\t{$cnt, $dst|$dst, $cnt}", []>;
2343
2344def RCL16r1 : I<0xD1, MRM2r, (outs GR16:$dst), (ins GR16:$src),
2345 "rcl{w}\t{1, $dst|$dst, 1}", []>, OpSize;
2346def RCL16m1 : I<0xD1, MRM2m, (outs i16mem:$dst), (ins i16mem:$src),
2347 "rcl{w}\t{1, $dst|$dst, 1}", []>, OpSize;
2348let Uses = [CL] in {
2349def RCL16rCL : I<0xD3, MRM2r, (outs GR16:$dst), (ins GR16:$src),
2350 "rcl{w}\t{%cl, $dst|$dst, CL}", []>, OpSize;
2351def RCL16mCL : I<0xD3, MRM2m, (outs i16mem:$dst), (ins i16mem:$src),
2352 "rcl{w}\t{%cl, $dst|$dst, CL}", []>, OpSize;
2353}
2354def RCL16ri : Ii8<0xC1, MRM2r, (outs GR16:$dst), (ins GR16:$src, i8imm:$cnt),
2355 "rcl{w}\t{$cnt, $dst|$dst, $cnt}", []>, OpSize;
Sean Callanan2c48df22009-12-18 00:01:26 +00002356def RCL16mi : Ii8<0xC1, MRM2m, (outs i16mem:$dst),
2357 (ins i16mem:$src, i8imm:$cnt),
Sean Callanan3c8eecd2009-09-18 19:35:23 +00002358 "rcl{w}\t{$cnt, $dst|$dst, $cnt}", []>, OpSize;
2359
2360def RCL32r1 : I<0xD1, MRM2r, (outs GR32:$dst), (ins GR32:$src),
2361 "rcl{l}\t{1, $dst|$dst, 1}", []>;
2362def RCL32m1 : I<0xD1, MRM2m, (outs i32mem:$dst), (ins i32mem:$src),
2363 "rcl{l}\t{1, $dst|$dst, 1}", []>;
2364let Uses = [CL] in {
2365def RCL32rCL : I<0xD3, MRM2r, (outs GR32:$dst), (ins GR32:$src),
2366 "rcl{l}\t{%cl, $dst|$dst, CL}", []>;
2367def RCL32mCL : I<0xD3, MRM2m, (outs i32mem:$dst), (ins i32mem:$src),
2368 "rcl{l}\t{%cl, $dst|$dst, CL}", []>;
2369}
2370def RCL32ri : Ii8<0xC1, MRM2r, (outs GR32:$dst), (ins GR32:$src, i8imm:$cnt),
2371 "rcl{l}\t{$cnt, $dst|$dst, $cnt}", []>;
Sean Callanan2c48df22009-12-18 00:01:26 +00002372def RCL32mi : Ii8<0xC1, MRM2m, (outs i32mem:$dst),
2373 (ins i32mem:$src, i8imm:$cnt),
Sean Callanan3c8eecd2009-09-18 19:35:23 +00002374 "rcl{l}\t{$cnt, $dst|$dst, $cnt}", []>;
2375
2376def RCR8r1 : I<0xD0, MRM3r, (outs GR8:$dst), (ins GR8:$src),
2377 "rcr{b}\t{1, $dst|$dst, 1}", []>;
2378def RCR8m1 : I<0xD0, MRM3m, (outs i8mem:$dst), (ins i8mem:$src),
2379 "rcr{b}\t{1, $dst|$dst, 1}", []>;
2380let Uses = [CL] in {
2381def RCR8rCL : I<0xD2, MRM3r, (outs GR8:$dst), (ins GR8:$src),
2382 "rcr{b}\t{%cl, $dst|$dst, CL}", []>;
2383def RCR8mCL : I<0xD2, MRM3m, (outs i8mem:$dst), (ins i8mem:$src),
2384 "rcr{b}\t{%cl, $dst|$dst, CL}", []>;
2385}
2386def RCR8ri : Ii8<0xC0, MRM3r, (outs GR8:$dst), (ins GR8:$src, i8imm:$cnt),
2387 "rcr{b}\t{$cnt, $dst|$dst, $cnt}", []>;
2388def RCR8mi : Ii8<0xC0, MRM3m, (outs i8mem:$dst), (ins i8mem:$src, i8imm:$cnt),
2389 "rcr{b}\t{$cnt, $dst|$dst, $cnt}", []>;
2390
2391def RCR16r1 : I<0xD1, MRM3r, (outs GR16:$dst), (ins GR16:$src),
2392 "rcr{w}\t{1, $dst|$dst, 1}", []>, OpSize;
2393def RCR16m1 : I<0xD1, MRM3m, (outs i16mem:$dst), (ins i16mem:$src),
2394 "rcr{w}\t{1, $dst|$dst, 1}", []>, OpSize;
2395let Uses = [CL] in {
2396def RCR16rCL : I<0xD3, MRM3r, (outs GR16:$dst), (ins GR16:$src),
2397 "rcr{w}\t{%cl, $dst|$dst, CL}", []>, OpSize;
2398def RCR16mCL : I<0xD3, MRM3m, (outs i16mem:$dst), (ins i16mem:$src),
2399 "rcr{w}\t{%cl, $dst|$dst, CL}", []>, OpSize;
2400}
2401def RCR16ri : Ii8<0xC1, MRM3r, (outs GR16:$dst), (ins GR16:$src, i8imm:$cnt),
2402 "rcr{w}\t{$cnt, $dst|$dst, $cnt}", []>, OpSize;
Sean Callanan2c48df22009-12-18 00:01:26 +00002403def RCR16mi : Ii8<0xC1, MRM3m, (outs i16mem:$dst),
2404 (ins i16mem:$src, i8imm:$cnt),
Sean Callanan3c8eecd2009-09-18 19:35:23 +00002405 "rcr{w}\t{$cnt, $dst|$dst, $cnt}", []>, OpSize;
2406
2407def RCR32r1 : I<0xD1, MRM3r, (outs GR32:$dst), (ins GR32:$src),
2408 "rcr{l}\t{1, $dst|$dst, 1}", []>;
2409def RCR32m1 : I<0xD1, MRM3m, (outs i32mem:$dst), (ins i32mem:$src),
2410 "rcr{l}\t{1, $dst|$dst, 1}", []>;
2411let Uses = [CL] in {
2412def RCR32rCL : I<0xD3, MRM3r, (outs GR32:$dst), (ins GR32:$src),
2413 "rcr{l}\t{%cl, $dst|$dst, CL}", []>;
2414def RCR32mCL : I<0xD3, MRM3m, (outs i32mem:$dst), (ins i32mem:$src),
2415 "rcr{l}\t{%cl, $dst|$dst, CL}", []>;
2416}
2417def RCR32ri : Ii8<0xC1, MRM3r, (outs GR32:$dst), (ins GR32:$src, i8imm:$cnt),
2418 "rcr{l}\t{$cnt, $dst|$dst, $cnt}", []>;
Sean Callanan2c48df22009-12-18 00:01:26 +00002419def RCR32mi : Ii8<0xC1, MRM3m, (outs i32mem:$dst),
2420 (ins i32mem:$src, i8imm:$cnt),
Sean Callanan3c8eecd2009-09-18 19:35:23 +00002421 "rcr{l}\t{$cnt, $dst|$dst, $cnt}", []>;
2422
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002423// FIXME: provide shorter instructions when imm8 == 1
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002424let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00002425def ROL8rCL : I<0xD2, MRM0r, (outs GR8 :$dst), (ins GR8 :$src),
Eli Friedman378ea832009-06-19 04:48:38 +00002426 "rol{b}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002427 [(set GR8:$dst, (rotl GR8:$src, CL))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002428def ROL16rCL : I<0xD3, MRM0r, (outs GR16:$dst), (ins GR16:$src),
Eli Friedman378ea832009-06-19 04:48:38 +00002429 "rol{w}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002430 [(set GR16:$dst, (rotl GR16:$src, CL))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002431def ROL32rCL : I<0xD3, MRM0r, (outs GR32:$dst), (ins GR32:$src),
Eli Friedman378ea832009-06-19 04:48:38 +00002432 "rol{l}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002433 [(set GR32:$dst, (rotl GR32:$src, CL))]>;
2434}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002435
Evan Chengb783fa32007-07-19 01:14:50 +00002436def ROL8ri : Ii8<0xC0, MRM0r, (outs GR8 :$dst), (ins GR8 :$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002437 "rol{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002438 [(set GR8:$dst, (rotl GR8:$src1, (i8 imm:$src2)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002439def ROL16ri : Ii8<0xC1, MRM0r, (outs GR16:$dst), (ins GR16:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002440 "rol{w}\t{$src2, $dst|$dst, $src2}",
Sean Callanan2c48df22009-12-18 00:01:26 +00002441 [(set GR16:$dst, (rotl GR16:$src1, (i8 imm:$src2)))]>,
2442 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002443def ROL32ri : Ii8<0xC1, MRM0r, (outs GR32:$dst), (ins GR32:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002444 "rol{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002445 [(set GR32:$dst, (rotl GR32:$src1, (i8 imm:$src2)))]>;
2446
2447// Rotate by 1
Evan Chengb783fa32007-07-19 01:14:50 +00002448def ROL8r1 : I<0xD0, MRM0r, (outs GR8 :$dst), (ins GR8 :$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00002449 "rol{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002450 [(set GR8:$dst, (rotl GR8:$src1, (i8 1)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002451def ROL16r1 : I<0xD1, MRM0r, (outs GR16:$dst), (ins GR16:$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00002452 "rol{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002453 [(set GR16:$dst, (rotl GR16:$src1, (i8 1)))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002454def ROL32r1 : I<0xD1, MRM0r, (outs GR32:$dst), (ins GR32:$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00002455 "rol{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002456 [(set GR32:$dst, (rotl GR32:$src1, (i8 1)))]>;
2457
2458let isTwoAddress = 0 in {
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002459 let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00002460 def ROL8mCL : I<0xD2, MRM0m, (outs), (ins i8mem :$dst),
Eli Friedman378ea832009-06-19 04:48:38 +00002461 "rol{b}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002462 [(store (rotl (loadi8 addr:$dst), CL), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002463 def ROL16mCL : I<0xD3, MRM0m, (outs), (ins i16mem:$dst),
Eli Friedman378ea832009-06-19 04:48:38 +00002464 "rol{w}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002465 [(store (rotl (loadi16 addr:$dst), CL), addr:$dst)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002466 def ROL32mCL : I<0xD3, MRM0m, (outs), (ins i32mem:$dst),
Eli Friedman378ea832009-06-19 04:48:38 +00002467 "rol{l}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002468 [(store (rotl (loadi32 addr:$dst), CL), addr:$dst)]>;
2469 }
Evan Chengb783fa32007-07-19 01:14:50 +00002470 def ROL8mi : Ii8<0xC0, MRM0m, (outs), (ins i8mem :$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002471 "rol{b}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002472 [(store (rotl (loadi8 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002473 def ROL16mi : Ii8<0xC1, MRM0m, (outs), (ins i16mem:$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002474 "rol{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002475 [(store (rotl (loadi16 addr:$dst), (i8 imm:$src)), addr:$dst)]>,
2476 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002477 def ROL32mi : Ii8<0xC1, MRM0m, (outs), (ins i32mem:$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002478 "rol{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002479 [(store (rotl (loadi32 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
2480
2481 // Rotate by 1
Evan Chengb783fa32007-07-19 01:14:50 +00002482 def ROL8m1 : I<0xD0, MRM0m, (outs), (ins i8mem :$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002483 "rol{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002484 [(store (rotl (loadi8 addr:$dst), (i8 1)), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002485 def ROL16m1 : I<0xD1, MRM0m, (outs), (ins i16mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002486 "rol{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002487 [(store (rotl (loadi16 addr:$dst), (i8 1)), addr:$dst)]>,
2488 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002489 def ROL32m1 : I<0xD1, MRM0m, (outs), (ins i32mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002490 "rol{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002491 [(store (rotl (loadi32 addr:$dst), (i8 1)), addr:$dst)]>;
2492}
2493
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002494let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00002495def ROR8rCL : I<0xD2, MRM1r, (outs GR8 :$dst), (ins GR8 :$src),
Eli Friedman378ea832009-06-19 04:48:38 +00002496 "ror{b}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002497 [(set GR8:$dst, (rotr GR8:$src, CL))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002498def ROR16rCL : I<0xD3, MRM1r, (outs GR16:$dst), (ins GR16:$src),
Eli Friedman378ea832009-06-19 04:48:38 +00002499 "ror{w}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002500 [(set GR16:$dst, (rotr GR16:$src, CL))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002501def ROR32rCL : I<0xD3, MRM1r, (outs GR32:$dst), (ins GR32:$src),
Eli Friedman378ea832009-06-19 04:48:38 +00002502 "ror{l}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002503 [(set GR32:$dst, (rotr GR32:$src, CL))]>;
2504}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002505
Evan Chengb783fa32007-07-19 01:14:50 +00002506def ROR8ri : Ii8<0xC0, MRM1r, (outs GR8 :$dst), (ins GR8 :$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002507 "ror{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002508 [(set GR8:$dst, (rotr GR8:$src1, (i8 imm:$src2)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002509def ROR16ri : Ii8<0xC1, MRM1r, (outs GR16:$dst), (ins GR16:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002510 "ror{w}\t{$src2, $dst|$dst, $src2}",
Sean Callanan2c48df22009-12-18 00:01:26 +00002511 [(set GR16:$dst, (rotr GR16:$src1, (i8 imm:$src2)))]>,
2512 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002513def ROR32ri : Ii8<0xC1, MRM1r, (outs GR32:$dst), (ins GR32:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002514 "ror{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002515 [(set GR32:$dst, (rotr GR32:$src1, (i8 imm:$src2)))]>;
2516
2517// Rotate by 1
Evan Chengb783fa32007-07-19 01:14:50 +00002518def ROR8r1 : I<0xD0, MRM1r, (outs GR8 :$dst), (ins GR8 :$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00002519 "ror{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002520 [(set GR8:$dst, (rotr GR8:$src1, (i8 1)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002521def ROR16r1 : I<0xD1, MRM1r, (outs GR16:$dst), (ins GR16:$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00002522 "ror{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002523 [(set GR16:$dst, (rotr GR16:$src1, (i8 1)))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002524def ROR32r1 : I<0xD1, MRM1r, (outs GR32:$dst), (ins GR32:$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00002525 "ror{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002526 [(set GR32:$dst, (rotr GR32:$src1, (i8 1)))]>;
2527
2528let isTwoAddress = 0 in {
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002529 let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00002530 def ROR8mCL : I<0xD2, MRM1m, (outs), (ins i8mem :$dst),
Eli Friedman378ea832009-06-19 04:48:38 +00002531 "ror{b}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002532 [(store (rotr (loadi8 addr:$dst), CL), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002533 def ROR16mCL : I<0xD3, MRM1m, (outs), (ins i16mem:$dst),
Eli Friedman378ea832009-06-19 04:48:38 +00002534 "ror{w}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002535 [(store (rotr (loadi16 addr:$dst), CL), addr:$dst)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002536 def ROR32mCL : I<0xD3, MRM1m, (outs), (ins i32mem:$dst),
Eli Friedman378ea832009-06-19 04:48:38 +00002537 "ror{l}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002538 [(store (rotr (loadi32 addr:$dst), CL), addr:$dst)]>;
2539 }
Evan Chengb783fa32007-07-19 01:14:50 +00002540 def ROR8mi : Ii8<0xC0, MRM1m, (outs), (ins i8mem :$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002541 "ror{b}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002542 [(store (rotr (loadi8 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002543 def ROR16mi : Ii8<0xC1, MRM1m, (outs), (ins i16mem:$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002544 "ror{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002545 [(store (rotr (loadi16 addr:$dst), (i8 imm:$src)), addr:$dst)]>,
2546 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002547 def ROR32mi : Ii8<0xC1, MRM1m, (outs), (ins i32mem:$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002548 "ror{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002549 [(store (rotr (loadi32 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
2550
2551 // Rotate by 1
Evan Chengb783fa32007-07-19 01:14:50 +00002552 def ROR8m1 : I<0xD0, MRM1m, (outs), (ins i8mem :$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002553 "ror{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002554 [(store (rotr (loadi8 addr:$dst), (i8 1)), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002555 def ROR16m1 : I<0xD1, MRM1m, (outs), (ins i16mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002556 "ror{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002557 [(store (rotr (loadi16 addr:$dst), (i8 1)), addr:$dst)]>,
2558 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002559 def ROR32m1 : I<0xD1, MRM1m, (outs), (ins i32mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002560 "ror{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002561 [(store (rotr (loadi32 addr:$dst), (i8 1)), addr:$dst)]>;
2562}
2563
2564
2565
2566// Double shift instructions (generalizations of rotate)
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002567let Uses = [CL] in {
Sean Callanan2c48df22009-12-18 00:01:26 +00002568def SHLD32rrCL : I<0xA5, MRMDestReg, (outs GR32:$dst),
2569 (ins GR32:$src1, GR32:$src2),
Eli Friedman378ea832009-06-19 04:48:38 +00002570 "shld{l}\t{%cl, $src2, $dst|$dst, $src2, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002571 [(set GR32:$dst, (X86shld GR32:$src1, GR32:$src2, CL))]>, TB;
Sean Callanan2c48df22009-12-18 00:01:26 +00002572def SHRD32rrCL : I<0xAD, MRMDestReg, (outs GR32:$dst),
2573 (ins GR32:$src1, GR32:$src2),
Eli Friedman378ea832009-06-19 04:48:38 +00002574 "shrd{l}\t{%cl, $src2, $dst|$dst, $src2, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002575 [(set GR32:$dst, (X86shrd GR32:$src1, GR32:$src2, CL))]>, TB;
Sean Callanan2c48df22009-12-18 00:01:26 +00002576def SHLD16rrCL : I<0xA5, MRMDestReg, (outs GR16:$dst),
2577 (ins GR16:$src1, GR16:$src2),
Eli Friedman378ea832009-06-19 04:48:38 +00002578 "shld{w}\t{%cl, $src2, $dst|$dst, $src2, CL}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002579 [(set GR16:$dst, (X86shld GR16:$src1, GR16:$src2, CL))]>,
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002580 TB, OpSize;
Sean Callanan2c48df22009-12-18 00:01:26 +00002581def SHRD16rrCL : I<0xAD, MRMDestReg, (outs GR16:$dst),
2582 (ins GR16:$src1, GR16:$src2),
Eli Friedman378ea832009-06-19 04:48:38 +00002583 "shrd{w}\t{%cl, $src2, $dst|$dst, $src2, CL}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002584 [(set GR16:$dst, (X86shrd GR16:$src1, GR16:$src2, CL))]>,
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002585 TB, OpSize;
2586}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002587
2588let isCommutable = 1 in { // These instructions commute to each other.
2589def SHLD32rri8 : Ii8<0xA4, MRMDestReg,
Sean Callanan2c48df22009-12-18 00:01:26 +00002590 (outs GR32:$dst),
2591 (ins GR32:$src1, GR32:$src2, i8imm:$src3),
Dan Gohman91888f02007-07-31 20:11:57 +00002592 "shld{l}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002593 [(set GR32:$dst, (X86shld GR32:$src1, GR32:$src2,
2594 (i8 imm:$src3)))]>,
2595 TB;
2596def SHRD32rri8 : Ii8<0xAC, MRMDestReg,
Sean Callanan2c48df22009-12-18 00:01:26 +00002597 (outs GR32:$dst),
2598 (ins GR32:$src1, GR32:$src2, i8imm:$src3),
Dan Gohman91888f02007-07-31 20:11:57 +00002599 "shrd{l}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002600 [(set GR32:$dst, (X86shrd GR32:$src1, GR32:$src2,
2601 (i8 imm:$src3)))]>,
2602 TB;
2603def SHLD16rri8 : Ii8<0xA4, MRMDestReg,
Sean Callanan2c48df22009-12-18 00:01:26 +00002604 (outs GR16:$dst),
2605 (ins GR16:$src1, GR16:$src2, i8imm:$src3),
Dan Gohman91888f02007-07-31 20:11:57 +00002606 "shld{w}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002607 [(set GR16:$dst, (X86shld GR16:$src1, GR16:$src2,
2608 (i8 imm:$src3)))]>,
2609 TB, OpSize;
2610def SHRD16rri8 : Ii8<0xAC, MRMDestReg,
Sean Callanan2c48df22009-12-18 00:01:26 +00002611 (outs GR16:$dst),
2612 (ins GR16:$src1, GR16:$src2, i8imm:$src3),
Dan Gohman91888f02007-07-31 20:11:57 +00002613 "shrd{w}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002614 [(set GR16:$dst, (X86shrd GR16:$src1, GR16:$src2,
2615 (i8 imm:$src3)))]>,
2616 TB, OpSize;
2617}
2618
2619let isTwoAddress = 0 in {
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002620 let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00002621 def SHLD32mrCL : I<0xA5, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
Eli Friedman378ea832009-06-19 04:48:38 +00002622 "shld{l}\t{%cl, $src2, $dst|$dst, $src2, CL}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002623 [(store (X86shld (loadi32 addr:$dst), GR32:$src2, CL),
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002624 addr:$dst)]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00002625 def SHRD32mrCL : I<0xAD, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
Eli Friedman378ea832009-06-19 04:48:38 +00002626 "shrd{l}\t{%cl, $src2, $dst|$dst, $src2, CL}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002627 [(store (X86shrd (loadi32 addr:$dst), GR32:$src2, CL),
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002628 addr:$dst)]>, TB;
2629 }
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002630 def SHLD32mri8 : Ii8<0xA4, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00002631 (outs), (ins i32mem:$dst, GR32:$src2, i8imm:$src3),
Dan Gohman91888f02007-07-31 20:11:57 +00002632 "shld{l}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002633 [(store (X86shld (loadi32 addr:$dst), GR32:$src2,
2634 (i8 imm:$src3)), addr:$dst)]>,
2635 TB;
2636 def SHRD32mri8 : Ii8<0xAC, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00002637 (outs), (ins i32mem:$dst, GR32:$src2, i8imm:$src3),
Dan Gohman91888f02007-07-31 20:11:57 +00002638 "shrd{l}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002639 [(store (X86shrd (loadi32 addr:$dst), GR32:$src2,
2640 (i8 imm:$src3)), addr:$dst)]>,
2641 TB;
2642
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002643 let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00002644 def SHLD16mrCL : I<0xA5, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
Eli Friedman378ea832009-06-19 04:48:38 +00002645 "shld{w}\t{%cl, $src2, $dst|$dst, $src2, CL}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002646 [(store (X86shld (loadi16 addr:$dst), GR16:$src2, CL),
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002647 addr:$dst)]>, TB, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002648 def SHRD16mrCL : I<0xAD, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
Eli Friedman378ea832009-06-19 04:48:38 +00002649 "shrd{w}\t{%cl, $src2, $dst|$dst, $src2, CL}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002650 [(store (X86shrd (loadi16 addr:$dst), GR16:$src2, CL),
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002651 addr:$dst)]>, TB, OpSize;
2652 }
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002653 def SHLD16mri8 : Ii8<0xA4, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00002654 (outs), (ins i16mem:$dst, GR16:$src2, i8imm:$src3),
Dan Gohman91888f02007-07-31 20:11:57 +00002655 "shld{w}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002656 [(store (X86shld (loadi16 addr:$dst), GR16:$src2,
2657 (i8 imm:$src3)), addr:$dst)]>,
2658 TB, OpSize;
2659 def SHRD16mri8 : Ii8<0xAC, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00002660 (outs), (ins i16mem:$dst, GR16:$src2, i8imm:$src3),
Dan Gohman91888f02007-07-31 20:11:57 +00002661 "shrd{w}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002662 [(store (X86shrd (loadi16 addr:$dst), GR16:$src2,
2663 (i8 imm:$src3)), addr:$dst)]>,
2664 TB, OpSize;
2665}
Evan Cheng55687072007-09-14 21:48:26 +00002666} // Defs = [EFLAGS]
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002667
2668
2669// Arithmetic.
Evan Cheng55687072007-09-14 21:48:26 +00002670let Defs = [EFLAGS] in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002671let isCommutable = 1 in { // X = ADD Y, Z --> X = ADD Z, Y
Bill Wendlingae034ed2008-12-12 00:56:36 +00002672// Register-Register Addition
2673def ADD8rr : I<0x00, MRMDestReg, (outs GR8 :$dst),
2674 (ins GR8 :$src1, GR8 :$src2),
2675 "add{b}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002676 [(set GR8:$dst, (add GR8:$src1, GR8:$src2)),
Bill Wendlingae034ed2008-12-12 00:56:36 +00002677 (implicit EFLAGS)]>;
2678
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002679let isConvertibleToThreeAddress = 1 in { // Can transform into LEA.
Bill Wendlingae034ed2008-12-12 00:56:36 +00002680// Register-Register Addition
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002681def ADD16rr : I<0x01, MRMDestReg, (outs GR16:$dst),
2682 (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002683 "add{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002684 [(set GR16:$dst, (add GR16:$src1, GR16:$src2)),
2685 (implicit EFLAGS)]>, OpSize;
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002686def ADD32rr : I<0x01, MRMDestReg, (outs GR32:$dst),
2687 (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002688 "add{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002689 [(set GR32:$dst, (add GR32:$src1, GR32:$src2)),
2690 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002691} // end isConvertibleToThreeAddress
2692} // end isCommutable
Bill Wendlingae034ed2008-12-12 00:56:36 +00002693
2694// Register-Memory Addition
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002695def ADD8rm : I<0x02, MRMSrcMem, (outs GR8 :$dst),
2696 (ins GR8 :$src1, i8mem :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002697 "add{b}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002698 [(set GR8:$dst, (add GR8:$src1, (load addr:$src2))),
2699 (implicit EFLAGS)]>;
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002700def ADD16rm : I<0x03, MRMSrcMem, (outs GR16:$dst),
2701 (ins GR16:$src1, i16mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002702 "add{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002703 [(set GR16:$dst, (add GR16:$src1, (load addr:$src2))),
2704 (implicit EFLAGS)]>, OpSize;
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002705def ADD32rm : I<0x03, MRMSrcMem, (outs GR32:$dst),
2706 (ins GR32:$src1, i32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002707 "add{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002708 [(set GR32:$dst, (add GR32:$src1, (load addr:$src2))),
2709 (implicit EFLAGS)]>;
Sean Callanan7e7df0e2009-09-15 20:53:57 +00002710
Sean Callanan84df9312009-09-15 21:43:27 +00002711// Register-Register Addition - Equivalent to the normal rr forms (ADD8rr,
2712// ADD16rr, and ADD32rr), but differently encoded.
Sean Callanan7e7df0e2009-09-15 20:53:57 +00002713def ADD8mrmrr: I<0x02, MRMSrcReg, (outs GR8:$dst), (ins GR8:$src1, GR8:$src2),
2714 "add{b}\t{$src2, $dst|$dst, $src2}", []>;
2715def ADD16mrmrr: I<0x03, MRMSrcReg,(outs GR16:$dst),(ins GR16:$src1, GR16:$src2),
2716 "add{w}\t{$src2, $dst|$dst, $src2}", []>, OpSize;
2717def ADD32mrmrr: I<0x03, MRMSrcReg,(outs GR16:$dst),(ins GR16:$src1, GR16:$src2),
2718 "add{l}\t{$src2, $dst|$dst, $src2}", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002719
Bill Wendlingae034ed2008-12-12 00:56:36 +00002720// Register-Integer Addition
2721def ADD8ri : Ii8<0x80, MRM0r, (outs GR8:$dst), (ins GR8:$src1, i8imm:$src2),
2722 "add{b}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002723 [(set GR8:$dst, (add GR8:$src1, imm:$src2)),
2724 (implicit EFLAGS)]>;
Bill Wendlingae034ed2008-12-12 00:56:36 +00002725
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002726let isConvertibleToThreeAddress = 1 in { // Can transform into LEA.
Bill Wendlingae034ed2008-12-12 00:56:36 +00002727// Register-Integer Addition
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002728def ADD16ri : Ii16<0x81, MRM0r, (outs GR16:$dst),
2729 (ins GR16:$src1, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002730 "add{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002731 [(set GR16:$dst, (add GR16:$src1, imm:$src2)),
2732 (implicit EFLAGS)]>, OpSize;
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002733def ADD32ri : Ii32<0x81, MRM0r, (outs GR32:$dst),
2734 (ins GR32:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002735 "add{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002736 [(set GR32:$dst, (add GR32:$src1, imm:$src2)),
2737 (implicit EFLAGS)]>;
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002738def ADD16ri8 : Ii8<0x83, MRM0r, (outs GR16:$dst),
2739 (ins GR16:$src1, i16i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002740 "add{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002741 [(set GR16:$dst, (add GR16:$src1, i16immSExt8:$src2)),
2742 (implicit EFLAGS)]>, OpSize;
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002743def ADD32ri8 : Ii8<0x83, MRM0r, (outs GR32:$dst),
2744 (ins GR32:$src1, i32i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002745 "add{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002746 [(set GR32:$dst, (add GR32:$src1, i32immSExt8:$src2)),
2747 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002748}
2749
2750let isTwoAddress = 0 in {
Bill Wendlingae034ed2008-12-12 00:56:36 +00002751 // Memory-Register Addition
Bill Wendlingf5399032008-12-12 21:15:41 +00002752 def ADD8mr : I<0x00, MRMDestMem, (outs), (ins i8mem:$dst, GR8:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002753 "add{b}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002754 [(store (add (load addr:$dst), GR8:$src2), addr:$dst),
2755 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002756 def ADD16mr : I<0x01, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002757 "add{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002758 [(store (add (load addr:$dst), GR16:$src2), addr:$dst),
2759 (implicit EFLAGS)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002760 def ADD32mr : I<0x01, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002761 "add{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002762 [(store (add (load addr:$dst), GR32:$src2), addr:$dst),
2763 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002764 def ADD8mi : Ii8<0x80, MRM0m, (outs), (ins i8mem :$dst, i8imm :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002765 "add{b}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002766 [(store (add (loadi8 addr:$dst), imm:$src2), addr:$dst),
2767 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002768 def ADD16mi : Ii16<0x81, MRM0m, (outs), (ins i16mem:$dst, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002769 "add{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002770 [(store (add (loadi16 addr:$dst), imm:$src2), addr:$dst),
2771 (implicit EFLAGS)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002772 def ADD32mi : Ii32<0x81, MRM0m, (outs), (ins i32mem:$dst, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002773 "add{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002774 [(store (add (loadi32 addr:$dst), imm:$src2), addr:$dst),
2775 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002776 def ADD16mi8 : Ii8<0x83, MRM0m, (outs), (ins i16mem:$dst, i16i8imm :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002777 "add{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002778 [(store (add (load addr:$dst), i16immSExt8:$src2),
2779 addr:$dst),
2780 (implicit EFLAGS)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002781 def ADD32mi8 : Ii8<0x83, MRM0m, (outs), (ins i32mem:$dst, i32i8imm :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002782 "add{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingae034ed2008-12-12 00:56:36 +00002783 [(store (add (load addr:$dst), i32immSExt8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00002784 addr:$dst),
2785 (implicit EFLAGS)]>;
Sean Callanan0316b342009-08-11 21:26:06 +00002786
2787 // addition to rAX
2788 def ADD8i8 : Ii8<0x04, RawFrm, (outs), (ins i8imm:$src),
Sean Callanan251676e2009-09-02 00:55:49 +00002789 "add{b}\t{$src, %al|%al, $src}", []>;
Sean Callanan0316b342009-08-11 21:26:06 +00002790 def ADD16i16 : Ii16<0x05, RawFrm, (outs), (ins i16imm:$src),
Sean Callanan251676e2009-09-02 00:55:49 +00002791 "add{w}\t{$src, %ax|%ax, $src}", []>, OpSize;
Sean Callanan0316b342009-08-11 21:26:06 +00002792 def ADD32i32 : Ii32<0x05, RawFrm, (outs), (ins i32imm:$src),
Sean Callanan251676e2009-09-02 00:55:49 +00002793 "add{l}\t{$src, %eax|%eax, $src}", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002794}
2795
Evan Cheng259471d2007-10-05 17:59:57 +00002796let Uses = [EFLAGS] in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002797let isCommutable = 1 in { // X = ADC Y, Z --> X = ADC Z, Y
Dale Johannesen747fe522009-06-02 03:12:52 +00002798def ADC8rr : I<0x10, MRMDestReg, (outs GR8:$dst), (ins GR8:$src1, GR8:$src2),
Dale Johannesen06b83f12009-05-18 17:44:15 +00002799 "adc{b}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002800 [(set GR8:$dst, (adde GR8:$src1, GR8:$src2))]>;
Dale Johannesen06b83f12009-05-18 17:44:15 +00002801def ADC16rr : I<0x11, MRMDestReg, (outs GR16:$dst),
2802 (ins GR16:$src1, GR16:$src2),
2803 "adc{w}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002804 [(set GR16:$dst, (adde GR16:$src1, GR16:$src2))]>, OpSize;
Dale Johannesen06b83f12009-05-18 17:44:15 +00002805def ADC32rr : I<0x11, MRMDestReg, (outs GR32:$dst),
2806 (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002807 "adc{l}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002808 [(set GR32:$dst, (adde GR32:$src1, GR32:$src2))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002809}
Sean Callanan2c48df22009-12-18 00:01:26 +00002810
2811def ADC8rr_REV : I<0x12, MRMSrcReg, (outs GR8:$dst), (ins GR8:$src1, GR8:$src2),
2812 "adc{b}\t{$src2, $dst|$dst, $src2}", []>;
2813def ADC16rr_REV : I<0x13, MRMSrcReg, (outs GR16:$dst),
2814 (ins GR16:$src1, GR16:$src2),
2815 "adc{w}\t{$src2, $dst|$dst, $src2}", []>, OpSize;
2816def ADC32rr_REV : I<0x13, MRMSrcReg, (outs GR32:$dst),
2817 (ins GR32:$src1, GR32:$src2),
2818 "adc{l}\t{$src2, $dst|$dst, $src2}", []>;
2819
Dale Johannesen06b83f12009-05-18 17:44:15 +00002820def ADC8rm : I<0x12, MRMSrcMem , (outs GR8:$dst),
2821 (ins GR8:$src1, i8mem:$src2),
2822 "adc{b}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002823 [(set GR8:$dst, (adde GR8:$src1, (load addr:$src2)))]>;
Dale Johannesen06b83f12009-05-18 17:44:15 +00002824def ADC16rm : I<0x13, MRMSrcMem , (outs GR16:$dst),
2825 (ins GR16:$src1, i16mem:$src2),
2826 "adc{w}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002827 [(set GR16:$dst, (adde GR16:$src1, (load addr:$src2)))]>,
Dale Johannesen067cfb22009-05-18 21:41:59 +00002828 OpSize;
Dale Johannesen06b83f12009-05-18 17:44:15 +00002829def ADC32rm : I<0x13, MRMSrcMem , (outs GR32:$dst),
2830 (ins GR32:$src1, i32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002831 "adc{l}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002832 [(set GR32:$dst, (adde GR32:$src1, (load addr:$src2)))]>;
2833def ADC8ri : Ii8<0x80, MRM2r, (outs GR8:$dst), (ins GR8:$src1, i8imm:$src2),
Dale Johannesen06b83f12009-05-18 17:44:15 +00002834 "adc{b}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002835 [(set GR8:$dst, (adde GR8:$src1, imm:$src2))]>;
Dale Johannesen06b83f12009-05-18 17:44:15 +00002836def ADC16ri : Ii16<0x81, MRM2r, (outs GR16:$dst),
2837 (ins GR16:$src1, i16imm:$src2),
2838 "adc{w}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002839 [(set GR16:$dst, (adde GR16:$src1, imm:$src2))]>, OpSize;
Dale Johannesen06b83f12009-05-18 17:44:15 +00002840def ADC16ri8 : Ii8<0x83, MRM2r, (outs GR16:$dst),
2841 (ins GR16:$src1, i16i8imm:$src2),
2842 "adc{w}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002843 [(set GR16:$dst, (adde GR16:$src1, i16immSExt8:$src2))]>,
2844 OpSize;
Dale Johannesen06b83f12009-05-18 17:44:15 +00002845def ADC32ri : Ii32<0x81, MRM2r, (outs GR32:$dst),
2846 (ins GR32:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002847 "adc{l}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002848 [(set GR32:$dst, (adde GR32:$src1, imm:$src2))]>;
Dale Johannesen06b83f12009-05-18 17:44:15 +00002849def ADC32ri8 : Ii8<0x83, MRM2r, (outs GR32:$dst),
2850 (ins GR32:$src1, i32i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002851 "adc{l}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002852 [(set GR32:$dst, (adde GR32:$src1, i32immSExt8:$src2))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002853
2854let isTwoAddress = 0 in {
Dale Johannesen747fe522009-06-02 03:12:52 +00002855 def ADC8mr : I<0x10, MRMDestMem, (outs), (ins i8mem:$dst, GR8:$src2),
Dale Johannesen06b83f12009-05-18 17:44:15 +00002856 "adc{b}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002857 [(store (adde (load addr:$dst), GR8:$src2), addr:$dst)]>;
2858 def ADC16mr : I<0x11, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
Dale Johannesen06b83f12009-05-18 17:44:15 +00002859 "adc{w}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002860 [(store (adde (load addr:$dst), GR16:$src2), addr:$dst)]>,
2861 OpSize;
2862 def ADC32mr : I<0x11, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$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), GR32:$src2), addr:$dst)]>;
2865 def ADC8mi : Ii8<0x80, MRM2m, (outs), (ins i8mem:$dst, i8imm:$src2),
Dale Johannesen06b83f12009-05-18 17:44:15 +00002866 "adc{b}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002867 [(store (adde (loadi8 addr:$dst), imm:$src2), addr:$dst)]>;
2868 def ADC16mi : Ii16<0x81, MRM2m, (outs), (ins i16mem:$dst, i16imm:$src2),
Dale Johannesen06b83f12009-05-18 17:44:15 +00002869 "adc{w}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002870 [(store (adde (loadi16 addr:$dst), imm:$src2), addr:$dst)]>,
2871 OpSize;
2872 def ADC16mi8 : Ii8<0x83, MRM2m, (outs), (ins i16mem:$dst, i16i8imm :$src2),
Dale Johannesen06b83f12009-05-18 17:44:15 +00002873 "adc{w}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002874 [(store (adde (load addr:$dst), i16immSExt8:$src2), addr:$dst)]>,
2875 OpSize;
2876 def ADC32mi : Ii32<0x81, MRM2m, (outs), (ins i32mem:$dst, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002877 "adc{l}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002878 [(store (adde (loadi32 addr:$dst), imm:$src2), addr:$dst)]>;
2879 def ADC32mi8 : Ii8<0x83, MRM2m, (outs), (ins i32mem:$dst, i32i8imm :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002880 "adc{l}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002881 [(store (adde (load addr:$dst), i32immSExt8:$src2), addr:$dst)]>;
Sean Callanan8562bef2009-09-11 19:01:56 +00002882
2883 def ADC8i8 : Ii8<0x14, RawFrm, (outs), (ins i8imm:$src),
2884 "adc{b}\t{$src, %al|%al, $src}", []>;
2885 def ADC16i16 : Ii16<0x15, RawFrm, (outs), (ins i16imm:$src),
2886 "adc{w}\t{$src, %ax|%ax, $src}", []>, OpSize;
2887 def ADC32i32 : Ii32<0x15, RawFrm, (outs), (ins i32imm:$src),
2888 "adc{l}\t{$src, %eax|%eax, $src}", []>;
Dale Johannesen747fe522009-06-02 03:12:52 +00002889}
Evan Cheng259471d2007-10-05 17:59:57 +00002890} // Uses = [EFLAGS]
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002891
Bill Wendlingae034ed2008-12-12 00:56:36 +00002892// Register-Register Subtraction
2893def SUB8rr : I<0x28, MRMDestReg, (outs GR8:$dst), (ins GR8:$src1, GR8:$src2),
2894 "sub{b}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002895 [(set GR8:$dst, (sub GR8:$src1, GR8:$src2)),
2896 (implicit EFLAGS)]>;
Bill Wendlingae034ed2008-12-12 00:56:36 +00002897def SUB16rr : I<0x29, MRMDestReg, (outs GR16:$dst), (ins GR16:$src1,GR16:$src2),
2898 "sub{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002899 [(set GR16:$dst, (sub GR16:$src1, GR16:$src2)),
2900 (implicit EFLAGS)]>, OpSize;
Bill Wendlingae034ed2008-12-12 00:56:36 +00002901def SUB32rr : I<0x29, MRMDestReg, (outs GR32:$dst), (ins GR32:$src1,GR32:$src2),
2902 "sub{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002903 [(set GR32:$dst, (sub GR32:$src1, GR32:$src2)),
2904 (implicit EFLAGS)]>;
Bill Wendlingae034ed2008-12-12 00:56:36 +00002905
Sean Callanan2c48df22009-12-18 00:01:26 +00002906def SUB8rr_REV : I<0x2A, MRMSrcReg, (outs GR8:$dst), (ins GR8:$src1, GR8:$src2),
2907 "sub{b}\t{$src2, $dst|$dst, $src2}", []>;
2908def SUB16rr_REV : I<0x2B, MRMSrcReg, (outs GR16:$dst),
2909 (ins GR16:$src1, GR16:$src2),
2910 "sub{w}\t{$src2, $dst|$dst, $src2}", []>, OpSize;
2911def SUB32rr_REV : I<0x2B, MRMSrcReg, (outs GR32:$dst),
2912 (ins GR32:$src1, GR32:$src2),
2913 "sub{l}\t{$src2, $dst|$dst, $src2}", []>;
2914
Bill Wendlingae034ed2008-12-12 00:56:36 +00002915// Register-Memory Subtraction
2916def SUB8rm : I<0x2A, MRMSrcMem, (outs GR8 :$dst),
2917 (ins GR8 :$src1, i8mem :$src2),
2918 "sub{b}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002919 [(set GR8:$dst, (sub GR8:$src1, (load addr:$src2))),
2920 (implicit EFLAGS)]>;
Bill Wendlingae034ed2008-12-12 00:56:36 +00002921def SUB16rm : I<0x2B, MRMSrcMem, (outs GR16:$dst),
2922 (ins GR16:$src1, i16mem:$src2),
2923 "sub{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002924 [(set GR16:$dst, (sub GR16:$src1, (load addr:$src2))),
2925 (implicit EFLAGS)]>, OpSize;
Bill Wendlingae034ed2008-12-12 00:56:36 +00002926def SUB32rm : I<0x2B, MRMSrcMem, (outs GR32:$dst),
2927 (ins GR32:$src1, i32mem:$src2),
2928 "sub{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002929 [(set GR32:$dst, (sub GR32:$src1, (load addr:$src2))),
2930 (implicit EFLAGS)]>;
Bill Wendlingae034ed2008-12-12 00:56:36 +00002931
2932// Register-Integer Subtraction
2933def SUB8ri : Ii8 <0x80, MRM5r, (outs GR8:$dst),
2934 (ins GR8:$src1, i8imm:$src2),
2935 "sub{b}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002936 [(set GR8:$dst, (sub GR8:$src1, imm:$src2)),
2937 (implicit EFLAGS)]>;
Bill Wendlingae034ed2008-12-12 00:56:36 +00002938def SUB16ri : Ii16<0x81, MRM5r, (outs GR16:$dst),
2939 (ins GR16:$src1, i16imm:$src2),
2940 "sub{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002941 [(set GR16:$dst, (sub GR16:$src1, imm:$src2)),
2942 (implicit EFLAGS)]>, OpSize;
Bill Wendlingae034ed2008-12-12 00:56:36 +00002943def SUB32ri : Ii32<0x81, MRM5r, (outs GR32:$dst),
2944 (ins GR32:$src1, i32imm:$src2),
2945 "sub{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002946 [(set GR32:$dst, (sub GR32:$src1, imm:$src2)),
2947 (implicit EFLAGS)]>;
Bill Wendlingae034ed2008-12-12 00:56:36 +00002948def SUB16ri8 : Ii8<0x83, MRM5r, (outs GR16:$dst),
2949 (ins GR16:$src1, i16i8imm:$src2),
2950 "sub{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002951 [(set GR16:$dst, (sub GR16:$src1, i16immSExt8:$src2)),
2952 (implicit EFLAGS)]>, OpSize;
Bill Wendlingae034ed2008-12-12 00:56:36 +00002953def SUB32ri8 : Ii8<0x83, MRM5r, (outs GR32:$dst),
2954 (ins GR32:$src1, i32i8imm:$src2),
2955 "sub{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002956 [(set GR32:$dst, (sub GR32:$src1, i32immSExt8:$src2)),
2957 (implicit EFLAGS)]>;
Bill Wendlingae034ed2008-12-12 00:56:36 +00002958
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002959let isTwoAddress = 0 in {
Bill Wendlingae034ed2008-12-12 00:56:36 +00002960 // Memory-Register Subtraction
Evan Chengb783fa32007-07-19 01:14:50 +00002961 def SUB8mr : I<0x28, MRMDestMem, (outs), (ins i8mem :$dst, GR8 :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002962 "sub{b}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002963 [(store (sub (load addr:$dst), GR8:$src2), addr:$dst),
2964 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002965 def SUB16mr : I<0x29, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002966 "sub{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002967 [(store (sub (load addr:$dst), GR16:$src2), addr:$dst),
2968 (implicit EFLAGS)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002969 def SUB32mr : I<0x29, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002970 "sub{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002971 [(store (sub (load addr:$dst), GR32:$src2), addr:$dst),
2972 (implicit EFLAGS)]>;
Bill Wendlingae034ed2008-12-12 00:56:36 +00002973
2974 // Memory-Integer Subtraction
Evan Chengb783fa32007-07-19 01:14:50 +00002975 def SUB8mi : Ii8<0x80, MRM5m, (outs), (ins i8mem :$dst, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002976 "sub{b}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002977 [(store (sub (loadi8 addr:$dst), imm:$src2), addr:$dst),
2978 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002979 def SUB16mi : Ii16<0x81, MRM5m, (outs), (ins i16mem:$dst, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002980 "sub{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002981 [(store (sub (loadi16 addr:$dst), imm:$src2),addr:$dst),
2982 (implicit EFLAGS)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002983 def SUB32mi : Ii32<0x81, MRM5m, (outs), (ins i32mem:$dst, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002984 "sub{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002985 [(store (sub (loadi32 addr:$dst), imm:$src2),addr:$dst),
2986 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002987 def SUB16mi8 : Ii8<0x83, MRM5m, (outs), (ins i16mem:$dst, i16i8imm :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002988 "sub{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingae034ed2008-12-12 00:56:36 +00002989 [(store (sub (load addr:$dst), i16immSExt8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00002990 addr:$dst),
2991 (implicit EFLAGS)]>, OpSize;
Bill Wendlingae034ed2008-12-12 00:56:36 +00002992 def SUB32mi8 : Ii8<0x83, MRM5m, (outs), (ins i32mem:$dst, i32i8imm :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002993 "sub{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingae034ed2008-12-12 00:56:36 +00002994 [(store (sub (load addr:$dst), i32immSExt8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00002995 addr:$dst),
2996 (implicit EFLAGS)]>;
Sean Callanan8562bef2009-09-11 19:01:56 +00002997
2998 def SUB8i8 : Ii8<0x2C, RawFrm, (outs), (ins i8imm:$src),
2999 "sub{b}\t{$src, %al|%al, $src}", []>;
3000 def SUB16i16 : Ii16<0x2D, RawFrm, (outs), (ins i16imm:$src),
3001 "sub{w}\t{$src, %ax|%ax, $src}", []>, OpSize;
3002 def SUB32i32 : Ii32<0x2D, RawFrm, (outs), (ins i32imm:$src),
3003 "sub{l}\t{$src, %eax|%eax, $src}", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003004}
3005
Evan Cheng259471d2007-10-05 17:59:57 +00003006let Uses = [EFLAGS] in {
Dale Johannesen06b83f12009-05-18 17:44:15 +00003007def SBB8rr : I<0x18, MRMDestReg, (outs GR8:$dst),
3008 (ins GR8:$src1, GR8:$src2),
3009 "sbb{b}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00003010 [(set GR8:$dst, (sube GR8:$src1, GR8:$src2))]>;
Dale Johannesen06b83f12009-05-18 17:44:15 +00003011def SBB16rr : I<0x19, MRMDestReg, (outs GR16:$dst),
3012 (ins GR16:$src1, GR16:$src2),
3013 "sbb{w}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00003014 [(set GR16:$dst, (sube GR16:$src1, GR16:$src2))]>, OpSize;
Dale Johannesen06b83f12009-05-18 17:44:15 +00003015def SBB32rr : I<0x19, MRMDestReg, (outs GR32:$dst),
3016 (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00003017 "sbb{l}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00003018 [(set GR32:$dst, (sube GR32:$src1, GR32:$src2))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003019
3020let isTwoAddress = 0 in {
Dale Johannesen06b83f12009-05-18 17:44:15 +00003021 def SBB8mr : I<0x18, MRMDestMem, (outs), (ins i8mem:$dst, GR8:$src2),
3022 "sbb{b}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00003023 [(store (sube (load addr:$dst), GR8:$src2), addr:$dst)]>;
Dale Johannesen06b83f12009-05-18 17:44:15 +00003024 def SBB16mr : I<0x19, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
3025 "sbb{w}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00003026 [(store (sube (load addr:$dst), GR16:$src2), addr:$dst)]>,
Dale Johannesen067cfb22009-05-18 21:41:59 +00003027 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00003028 def SBB32mr : I<0x19, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$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), GR32:$src2), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00003031 def SBB8mi : Ii32<0x80, MRM3m, (outs), (ins i8mem:$dst, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00003032 "sbb{b}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00003033 [(store (sube (loadi8 addr:$dst), imm:$src2), addr:$dst)]>;
Dale Johannesen06b83f12009-05-18 17:44:15 +00003034 def SBB16mi : Ii16<0x81, MRM3m, (outs), (ins i16mem:$dst, i16imm:$src2),
3035 "sbb{w}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00003036 [(store (sube (loadi16 addr:$dst), imm:$src2), addr:$dst)]>,
Dale Johannesen067cfb22009-05-18 21:41:59 +00003037 OpSize;
Dale Johannesen06b83f12009-05-18 17:44:15 +00003038 def SBB16mi8 : Ii8<0x83, MRM3m, (outs), (ins i16mem:$dst, i16i8imm :$src2),
3039 "sbb{w}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00003040 [(store (sube (load addr:$dst), i16immSExt8:$src2), addr:$dst)]>,
Dale Johannesen067cfb22009-05-18 21:41:59 +00003041 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00003042 def SBB32mi : Ii32<0x81, MRM3m, (outs), (ins i32mem:$dst, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00003043 "sbb{l}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00003044 [(store (sube (loadi32 addr:$dst), imm:$src2), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00003045 def SBB32mi8 : Ii8<0x83, MRM3m, (outs), (ins i32mem:$dst, i32i8imm :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00003046 "sbb{l}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00003047 [(store (sube (load addr:$dst), i32immSExt8:$src2), addr:$dst)]>;
Sean Callanan8562bef2009-09-11 19:01:56 +00003048
3049 def SBB8i8 : Ii8<0x1C, RawFrm, (outs), (ins i8imm:$src),
3050 "sbb{b}\t{$src, %al|%al, $src}", []>;
3051 def SBB16i16 : Ii16<0x1D, RawFrm, (outs), (ins i16imm:$src),
3052 "sbb{w}\t{$src, %ax|%ax, $src}", []>, OpSize;
3053 def SBB32i32 : Ii32<0x1D, RawFrm, (outs), (ins i32imm:$src),
3054 "sbb{l}\t{$src, %eax|%eax, $src}", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003055}
Sean Callanan2c48df22009-12-18 00:01:26 +00003056
3057def SBB8rr_REV : I<0x1A, MRMSrcReg, (outs GR8:$dst), (ins GR8:$src1, GR8:$src2),
3058 "sbb{b}\t{$src2, $dst|$dst, $src2}", []>;
3059def SBB16rr_REV : I<0x1B, MRMSrcReg, (outs GR16:$dst),
3060 (ins GR16:$src1, GR16:$src2),
3061 "sbb{w}\t{$src2, $dst|$dst, $src2}", []>, OpSize;
3062def SBB32rr_REV : I<0x1B, MRMSrcReg, (outs GR32:$dst),
3063 (ins GR32:$src1, GR32:$src2),
3064 "sbb{l}\t{$src2, $dst|$dst, $src2}", []>;
3065
Dale Johannesen06b83f12009-05-18 17:44:15 +00003066def SBB8rm : I<0x1A, MRMSrcMem, (outs GR8:$dst), (ins GR8:$src1, i8mem:$src2),
3067 "sbb{b}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00003068 [(set GR8:$dst, (sube GR8:$src1, (load addr:$src2)))]>;
Dale Johannesen06b83f12009-05-18 17:44:15 +00003069def SBB16rm : I<0x1B, MRMSrcMem, (outs GR16:$dst),
3070 (ins GR16:$src1, i16mem:$src2),
3071 "sbb{w}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00003072 [(set GR16:$dst, (sube GR16:$src1, (load addr:$src2)))]>,
Dale Johannesen067cfb22009-05-18 21:41:59 +00003073 OpSize;
Dale Johannesen06b83f12009-05-18 17:44:15 +00003074def SBB32rm : I<0x1B, MRMSrcMem, (outs GR32:$dst),
3075 (ins GR32:$src1, i32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00003076 "sbb{l}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00003077 [(set GR32:$dst, (sube GR32:$src1, (load addr:$src2)))]>;
Dale Johannesen06b83f12009-05-18 17:44:15 +00003078def SBB8ri : Ii8<0x80, MRM3r, (outs GR8:$dst), (ins GR8:$src1, i8imm:$src2),
3079 "sbb{b}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00003080 [(set GR8:$dst, (sube GR8:$src1, imm:$src2))]>;
Dale Johannesen06b83f12009-05-18 17:44:15 +00003081def SBB16ri : Ii16<0x81, MRM3r, (outs GR16:$dst),
3082 (ins GR16:$src1, i16imm:$src2),
3083 "sbb{w}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00003084 [(set GR16:$dst, (sube GR16:$src1, imm:$src2))]>, OpSize;
Dale Johannesen06b83f12009-05-18 17:44:15 +00003085def SBB16ri8 : Ii8<0x83, MRM3r, (outs GR16:$dst),
3086 (ins GR16:$src1, i16i8imm:$src2),
3087 "sbb{w}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00003088 [(set GR16:$dst, (sube GR16:$src1, i16immSExt8:$src2))]>,
3089 OpSize;
Dale Johannesen06b83f12009-05-18 17:44:15 +00003090def SBB32ri : Ii32<0x81, MRM3r, (outs GR32:$dst),
3091 (ins GR32:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00003092 "sbb{l}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00003093 [(set GR32:$dst, (sube GR32:$src1, imm:$src2))]>;
Dale Johannesen06b83f12009-05-18 17:44:15 +00003094def SBB32ri8 : Ii8<0x83, MRM3r, (outs GR32:$dst),
3095 (ins GR32:$src1, i32i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00003096 "sbb{l}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00003097 [(set GR32:$dst, (sube GR32:$src1, i32immSExt8:$src2))]>;
Evan Cheng259471d2007-10-05 17:59:57 +00003098} // Uses = [EFLAGS]
Evan Cheng55687072007-09-14 21:48:26 +00003099} // Defs = [EFLAGS]
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003100
Evan Cheng55687072007-09-14 21:48:26 +00003101let Defs = [EFLAGS] in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003102let isCommutable = 1 in { // X = IMUL Y, Z --> X = IMUL Z, Y
Bill Wendlingf5399032008-12-12 21:15:41 +00003103// Register-Register Signed Integer Multiply
Bill Wendlingae034ed2008-12-12 00:56:36 +00003104def IMUL16rr : I<0xAF, MRMSrcReg, (outs GR16:$dst), (ins GR16:$src1,GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00003105 "imul{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00003106 [(set GR16:$dst, (mul GR16:$src1, GR16:$src2)),
3107 (implicit EFLAGS)]>, TB, OpSize;
Bill Wendlingae034ed2008-12-12 00:56:36 +00003108def IMUL32rr : I<0xAF, MRMSrcReg, (outs GR32:$dst), (ins GR32:$src1,GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00003109 "imul{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00003110 [(set GR32:$dst, (mul GR32:$src1, GR32:$src2)),
3111 (implicit EFLAGS)]>, TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003112}
Bill Wendlingae034ed2008-12-12 00:56:36 +00003113
Bill Wendlingf5399032008-12-12 21:15:41 +00003114// Register-Memory Signed Integer Multiply
Bill Wendlingae034ed2008-12-12 00:56:36 +00003115def IMUL16rm : I<0xAF, MRMSrcMem, (outs GR16:$dst),
3116 (ins GR16:$src1, i16mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00003117 "imul{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00003118 [(set GR16:$dst, (mul GR16:$src1, (load addr:$src2))),
3119 (implicit EFLAGS)]>, TB, OpSize;
Sean Callanan2c48df22009-12-18 00:01:26 +00003120def IMUL32rm : I<0xAF, MRMSrcMem, (outs GR32:$dst),
3121 (ins GR32:$src1, i32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00003122 "imul{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00003123 [(set GR32:$dst, (mul GR32:$src1, (load addr:$src2))),
3124 (implicit EFLAGS)]>, TB;
Evan Cheng55687072007-09-14 21:48:26 +00003125} // Defs = [EFLAGS]
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003126} // end Two Address instructions
3127
3128// Suprisingly enough, these are not two address instructions!
Evan Cheng55687072007-09-14 21:48:26 +00003129let Defs = [EFLAGS] in {
Bill Wendlingf5399032008-12-12 21:15:41 +00003130// Register-Integer Signed Integer Multiply
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003131def IMUL16rri : Ii16<0x69, MRMSrcReg, // GR16 = GR16*I16
Evan Chengb783fa32007-07-19 01:14:50 +00003132 (outs GR16:$dst), (ins GR16:$src1, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00003133 "imul{w}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00003134 [(set GR16:$dst, (mul GR16:$src1, imm:$src2)),
3135 (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003136def IMUL32rri : Ii32<0x69, MRMSrcReg, // GR32 = GR32*I32
Evan Chengb783fa32007-07-19 01:14:50 +00003137 (outs GR32:$dst), (ins GR32:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00003138 "imul{l}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00003139 [(set GR32:$dst, (mul GR32:$src1, imm:$src2)),
3140 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003141def IMUL16rri8 : Ii8<0x6B, MRMSrcReg, // GR16 = GR16*I8
Evan Chengb783fa32007-07-19 01:14:50 +00003142 (outs GR16:$dst), (ins GR16:$src1, i16i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00003143 "imul{w}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00003144 [(set GR16:$dst, (mul GR16:$src1, i16immSExt8:$src2)),
3145 (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003146def IMUL32rri8 : Ii8<0x6B, MRMSrcReg, // GR32 = GR32*I8
Evan Chengb783fa32007-07-19 01:14:50 +00003147 (outs GR32:$dst), (ins GR32:$src1, i32i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00003148 "imul{l}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00003149 [(set GR32:$dst, (mul GR32:$src1, i32immSExt8:$src2)),
3150 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003151
Bill Wendlingf5399032008-12-12 21:15:41 +00003152// Memory-Integer Signed Integer Multiply
Sean Callanan2c48df22009-12-18 00:01:26 +00003153def IMUL16rmi : Ii16<0x69, MRMSrcMem, // GR16 = [mem16]*I16
Evan Chengb783fa32007-07-19 01:14:50 +00003154 (outs GR16:$dst), (ins i16mem:$src1, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00003155 "imul{w}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00003156 [(set GR16:$dst, (mul (load addr:$src1), imm:$src2)),
3157 (implicit EFLAGS)]>, OpSize;
Sean Callanan2c48df22009-12-18 00:01:26 +00003158def IMUL32rmi : Ii32<0x69, MRMSrcMem, // GR32 = [mem32]*I32
Evan Chengb783fa32007-07-19 01:14:50 +00003159 (outs GR32:$dst), (ins i32mem:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00003160 "imul{l}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00003161 [(set GR32:$dst, (mul (load addr:$src1), imm:$src2)),
3162 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003163def IMUL16rmi8 : Ii8<0x6B, MRMSrcMem, // GR16 = [mem16]*I8
Evan Chengb783fa32007-07-19 01:14:50 +00003164 (outs GR16:$dst), (ins i16mem:$src1, i16i8imm :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00003165 "imul{w}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Bill Wendlingae034ed2008-12-12 00:56:36 +00003166 [(set GR16:$dst, (mul (load addr:$src1),
Bill Wendlingf5399032008-12-12 21:15:41 +00003167 i16immSExt8:$src2)),
3168 (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003169def IMUL32rmi8 : Ii8<0x6B, MRMSrcMem, // GR32 = [mem32]*I8
Evan Chengb783fa32007-07-19 01:14:50 +00003170 (outs GR32:$dst), (ins i32mem:$src1, i32i8imm: $src2),
Dan Gohman91888f02007-07-31 20:11:57 +00003171 "imul{l}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Bill Wendlingae034ed2008-12-12 00:56:36 +00003172 [(set GR32:$dst, (mul (load addr:$src1),
Bill Wendlingf5399032008-12-12 21:15:41 +00003173 i32immSExt8:$src2)),
3174 (implicit EFLAGS)]>;
Evan Cheng55687072007-09-14 21:48:26 +00003175} // Defs = [EFLAGS]
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003176
3177//===----------------------------------------------------------------------===//
3178// Test instructions are just like AND, except they don't generate a result.
3179//
Evan Cheng950aac02007-09-25 01:57:46 +00003180let Defs = [EFLAGS] in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003181let isCommutable = 1 in { // TEST X, Y --> TEST Y, X
Evan Chengb783fa32007-07-19 01:14:50 +00003182def TEST8rr : I<0x84, MRMDestReg, (outs), (ins GR8:$src1, GR8:$src2),
Evan Cheng621216e2007-09-29 00:00:36 +00003183 "test{b}\t{$src2, $src1|$src1, $src2}",
Chris Lattner21da6382008-02-19 17:37:35 +00003184 [(X86cmp (and_su GR8:$src1, GR8:$src2), 0),
Evan Cheng621216e2007-09-29 00:00:36 +00003185 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00003186def TEST16rr : I<0x85, MRMDestReg, (outs), (ins GR16:$src1, GR16:$src2),
Evan Cheng621216e2007-09-29 00:00:36 +00003187 "test{w}\t{$src2, $src1|$src1, $src2}",
Chris Lattner21da6382008-02-19 17:37:35 +00003188 [(X86cmp (and_su GR16:$src1, GR16:$src2), 0),
Evan Cheng621216e2007-09-29 00:00:36 +00003189 (implicit EFLAGS)]>,
3190 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00003191def TEST32rr : I<0x85, MRMDestReg, (outs), (ins GR32:$src1, GR32:$src2),
Evan Cheng621216e2007-09-29 00:00:36 +00003192 "test{l}\t{$src2, $src1|$src1, $src2}",
Chris Lattner21da6382008-02-19 17:37:35 +00003193 [(X86cmp (and_su GR32:$src1, GR32:$src2), 0),
Evan Cheng621216e2007-09-29 00:00:36 +00003194 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003195}
3196
Sean Callanan3e4b1a32009-09-01 18:14:18 +00003197def TEST8i8 : Ii8<0xA8, RawFrm, (outs), (ins i8imm:$src),
3198 "test{b}\t{$src, %al|%al, $src}", []>;
3199def TEST16i16 : Ii16<0xA9, RawFrm, (outs), (ins i16imm:$src),
3200 "test{w}\t{$src, %ax|%ax, $src}", []>, OpSize;
3201def TEST32i32 : Ii32<0xA9, RawFrm, (outs), (ins i32imm:$src),
3202 "test{l}\t{$src, %eax|%eax, $src}", []>;
3203
Evan Chengb783fa32007-07-19 01:14:50 +00003204def TEST8rm : I<0x84, MRMSrcMem, (outs), (ins GR8 :$src1, i8mem :$src2),
Evan Cheng621216e2007-09-29 00:00:36 +00003205 "test{b}\t{$src2, $src1|$src1, $src2}",
3206 [(X86cmp (and GR8:$src1, (loadi8 addr:$src2)), 0),
3207 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00003208def TEST16rm : I<0x85, MRMSrcMem, (outs), (ins GR16:$src1, i16mem:$src2),
Evan Cheng621216e2007-09-29 00:00:36 +00003209 "test{w}\t{$src2, $src1|$src1, $src2}",
3210 [(X86cmp (and GR16:$src1, (loadi16 addr:$src2)), 0),
3211 (implicit EFLAGS)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00003212def TEST32rm : I<0x85, MRMSrcMem, (outs), (ins GR32:$src1, i32mem:$src2),
Evan Cheng621216e2007-09-29 00:00:36 +00003213 "test{l}\t{$src2, $src1|$src1, $src2}",
3214 [(X86cmp (and GR32:$src1, (loadi32 addr:$src2)), 0),
3215 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003216
3217def TEST8ri : Ii8 <0xF6, MRM0r, // flags = GR8 & imm8
Evan Chengb783fa32007-07-19 01:14:50 +00003218 (outs), (ins GR8:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00003219 "test{b}\t{$src2, $src1|$src1, $src2}",
Chris Lattner21da6382008-02-19 17:37:35 +00003220 [(X86cmp (and_su GR8:$src1, imm:$src2), 0),
Evan Cheng621216e2007-09-29 00:00:36 +00003221 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003222def TEST16ri : Ii16<0xF7, MRM0r, // flags = GR16 & imm16
Evan Chengb783fa32007-07-19 01:14:50 +00003223 (outs), (ins GR16:$src1, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00003224 "test{w}\t{$src2, $src1|$src1, $src2}",
Chris Lattner21da6382008-02-19 17:37:35 +00003225 [(X86cmp (and_su GR16:$src1, imm:$src2), 0),
Evan Cheng621216e2007-09-29 00:00:36 +00003226 (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003227def TEST32ri : Ii32<0xF7, MRM0r, // flags = GR32 & imm32
Evan Chengb783fa32007-07-19 01:14:50 +00003228 (outs), (ins GR32:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00003229 "test{l}\t{$src2, $src1|$src1, $src2}",
Chris Lattner21da6382008-02-19 17:37:35 +00003230 [(X86cmp (and_su GR32:$src1, imm:$src2), 0),
Evan Cheng621216e2007-09-29 00:00:36 +00003231 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003232
Evan Cheng621216e2007-09-29 00:00:36 +00003233def TEST8mi : Ii8 <0xF6, MRM0m, // flags = [mem8] & imm8
Evan Chengb783fa32007-07-19 01:14:50 +00003234 (outs), (ins i8mem:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00003235 "test{b}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00003236 [(X86cmp (and (loadi8 addr:$src1), imm:$src2), 0),
3237 (implicit EFLAGS)]>;
3238def TEST16mi : Ii16<0xF7, MRM0m, // flags = [mem16] & imm16
Evan Chengb783fa32007-07-19 01:14:50 +00003239 (outs), (ins i16mem:$src1, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00003240 "test{w}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00003241 [(X86cmp (and (loadi16 addr:$src1), imm:$src2), 0),
3242 (implicit EFLAGS)]>, OpSize;
3243def TEST32mi : Ii32<0xF7, MRM0m, // flags = [mem32] & imm32
Evan Chengb783fa32007-07-19 01:14:50 +00003244 (outs), (ins i32mem:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00003245 "test{l}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00003246 [(X86cmp (and (loadi32 addr:$src1), imm:$src2), 0),
Evan Cheng950aac02007-09-25 01:57:46 +00003247 (implicit EFLAGS)]>;
3248} // Defs = [EFLAGS]
3249
3250
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003251// Condition code ops, incl. set if equal/not equal/...
Chris Lattnerc90ee9c2008-01-10 07:59:24 +00003252let Defs = [EFLAGS], Uses = [AH], neverHasSideEffects = 1 in
Evan Cheng6e4d1d92007-09-11 19:55:27 +00003253def SAHF : I<0x9E, RawFrm, (outs), (ins), "sahf", []>; // flags = AH
Chris Lattnerc90ee9c2008-01-10 07:59:24 +00003254let Defs = [AH], Uses = [EFLAGS], neverHasSideEffects = 1 in
Evan Cheng6e4d1d92007-09-11 19:55:27 +00003255def LAHF : I<0x9F, RawFrm, (outs), (ins), "lahf", []>; // AH = flags
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003256
Evan Cheng950aac02007-09-25 01:57:46 +00003257let Uses = [EFLAGS] in {
Evan Cheng834ae6b2009-12-15 00:53:42 +00003258// Use sbb to materialize carry bit.
3259
3260let Defs = [EFLAGS], isCodeGenOnly = 1 in {
3261def SETB_C8r : I<0x18, MRMInitReg, (outs GR8:$dst), (ins),
3262 "sbb{b}\t$dst, $dst",
3263 [(set GR8:$dst, (X86setcc_c X86_COND_B, EFLAGS))]>;
3264def SETB_C16r : I<0x19, MRMInitReg, (outs GR16:$dst), (ins),
3265 "sbb{w}\t$dst, $dst",
Evan Chengedeb1692009-12-16 00:53:11 +00003266 [(set GR16:$dst, (X86setcc_c X86_COND_B, EFLAGS))]>,
Evan Cheng834ae6b2009-12-15 00:53:42 +00003267 OpSize;
3268def SETB_C32r : I<0x19, MRMInitReg, (outs GR32:$dst), (ins),
3269 "sbb{l}\t$dst, $dst",
Evan Chengedeb1692009-12-16 00:53:11 +00003270 [(set GR32:$dst, (X86setcc_c X86_COND_B, EFLAGS))]>;
Evan Cheng834ae6b2009-12-15 00:53:42 +00003271} // isCodeGenOnly
3272
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003273def SETEr : I<0x94, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00003274 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00003275 "sete\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00003276 [(set GR8:$dst, (X86setcc X86_COND_E, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003277 TB; // GR8 = ==
3278def SETEm : I<0x94, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00003279 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00003280 "sete\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00003281 [(store (X86setcc X86_COND_E, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003282 TB; // [mem8] = ==
Bill Wendling0c52d0a2008-12-02 00:07:05 +00003283
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003284def SETNEr : I<0x95, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00003285 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00003286 "setne\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00003287 [(set GR8:$dst, (X86setcc X86_COND_NE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003288 TB; // GR8 = !=
3289def SETNEm : I<0x95, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00003290 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00003291 "setne\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00003292 [(store (X86setcc X86_COND_NE, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003293 TB; // [mem8] = !=
Bill Wendling0c52d0a2008-12-02 00:07:05 +00003294
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003295def SETLr : I<0x9C, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00003296 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00003297 "setl\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00003298 [(set GR8:$dst, (X86setcc X86_COND_L, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003299 TB; // GR8 = < signed
3300def SETLm : I<0x9C, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00003301 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00003302 "setl\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00003303 [(store (X86setcc X86_COND_L, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003304 TB; // [mem8] = < signed
Bill Wendling0c52d0a2008-12-02 00:07:05 +00003305
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003306def SETGEr : I<0x9D, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00003307 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00003308 "setge\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00003309 [(set GR8:$dst, (X86setcc X86_COND_GE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003310 TB; // GR8 = >= signed
3311def SETGEm : I<0x9D, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00003312 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00003313 "setge\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00003314 [(store (X86setcc X86_COND_GE, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003315 TB; // [mem8] = >= signed
Bill Wendling0c52d0a2008-12-02 00:07:05 +00003316
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003317def SETLEr : I<0x9E, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00003318 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00003319 "setle\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00003320 [(set GR8:$dst, (X86setcc X86_COND_LE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003321 TB; // GR8 = <= signed
3322def SETLEm : I<0x9E, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00003323 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00003324 "setle\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00003325 [(store (X86setcc X86_COND_LE, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003326 TB; // [mem8] = <= signed
Bill Wendling0c52d0a2008-12-02 00:07:05 +00003327
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003328def SETGr : I<0x9F, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00003329 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00003330 "setg\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00003331 [(set GR8:$dst, (X86setcc X86_COND_G, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003332 TB; // GR8 = > signed
3333def SETGm : I<0x9F, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00003334 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00003335 "setg\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00003336 [(store (X86setcc X86_COND_G, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003337 TB; // [mem8] = > signed
3338
3339def SETBr : I<0x92, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00003340 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00003341 "setb\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00003342 [(set GR8:$dst, (X86setcc X86_COND_B, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003343 TB; // GR8 = < unsign
3344def SETBm : I<0x92, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00003345 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00003346 "setb\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00003347 [(store (X86setcc X86_COND_B, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003348 TB; // [mem8] = < unsign
Bill Wendling0c52d0a2008-12-02 00:07:05 +00003349
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003350def SETAEr : I<0x93, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00003351 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00003352 "setae\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00003353 [(set GR8:$dst, (X86setcc X86_COND_AE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003354 TB; // GR8 = >= unsign
3355def SETAEm : I<0x93, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00003356 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00003357 "setae\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00003358 [(store (X86setcc X86_COND_AE, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003359 TB; // [mem8] = >= unsign
Bill Wendling0c52d0a2008-12-02 00:07:05 +00003360
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003361def SETBEr : I<0x96, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00003362 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00003363 "setbe\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00003364 [(set GR8:$dst, (X86setcc X86_COND_BE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003365 TB; // GR8 = <= unsign
3366def SETBEm : I<0x96, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00003367 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00003368 "setbe\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00003369 [(store (X86setcc X86_COND_BE, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003370 TB; // [mem8] = <= unsign
Bill Wendling0c52d0a2008-12-02 00:07:05 +00003371
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003372def SETAr : I<0x97, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00003373 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00003374 "seta\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00003375 [(set GR8:$dst, (X86setcc X86_COND_A, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003376 TB; // GR8 = > signed
3377def SETAm : I<0x97, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00003378 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00003379 "seta\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00003380 [(store (X86setcc X86_COND_A, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003381 TB; // [mem8] = > signed
3382
3383def SETSr : I<0x98, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00003384 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00003385 "sets\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00003386 [(set GR8:$dst, (X86setcc X86_COND_S, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003387 TB; // GR8 = <sign bit>
3388def SETSm : I<0x98, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00003389 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00003390 "sets\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00003391 [(store (X86setcc X86_COND_S, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003392 TB; // [mem8] = <sign bit>
3393def SETNSr : I<0x99, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00003394 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00003395 "setns\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00003396 [(set GR8:$dst, (X86setcc X86_COND_NS, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003397 TB; // GR8 = !<sign bit>
3398def SETNSm : I<0x99, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00003399 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00003400 "setns\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00003401 [(store (X86setcc X86_COND_NS, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003402 TB; // [mem8] = !<sign bit>
Bill Wendling0c52d0a2008-12-02 00:07:05 +00003403
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003404def SETPr : I<0x9A, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00003405 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00003406 "setp\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00003407 [(set GR8:$dst, (X86setcc X86_COND_P, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003408 TB; // GR8 = parity
3409def SETPm : I<0x9A, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00003410 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00003411 "setp\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00003412 [(store (X86setcc X86_COND_P, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003413 TB; // [mem8] = parity
3414def SETNPr : I<0x9B, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00003415 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00003416 "setnp\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00003417 [(set GR8:$dst, (X86setcc X86_COND_NP, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003418 TB; // GR8 = not parity
3419def SETNPm : I<0x9B, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00003420 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00003421 "setnp\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00003422 [(store (X86setcc X86_COND_NP, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003423 TB; // [mem8] = not parity
Bill Wendling0c52d0a2008-12-02 00:07:05 +00003424
3425def SETOr : I<0x90, MRM0r,
3426 (outs GR8 :$dst), (ins),
3427 "seto\t$dst",
3428 [(set GR8:$dst, (X86setcc X86_COND_O, EFLAGS))]>,
3429 TB; // GR8 = overflow
3430def SETOm : I<0x90, MRM0m,
3431 (outs), (ins i8mem:$dst),
3432 "seto\t$dst",
3433 [(store (X86setcc X86_COND_O, EFLAGS), addr:$dst)]>,
3434 TB; // [mem8] = overflow
3435def SETNOr : I<0x91, MRM0r,
3436 (outs GR8 :$dst), (ins),
3437 "setno\t$dst",
3438 [(set GR8:$dst, (X86setcc X86_COND_NO, EFLAGS))]>,
3439 TB; // GR8 = not overflow
3440def SETNOm : I<0x91, MRM0m,
3441 (outs), (ins i8mem:$dst),
3442 "setno\t$dst",
3443 [(store (X86setcc X86_COND_NO, EFLAGS), addr:$dst)]>,
3444 TB; // [mem8] = not overflow
Evan Cheng950aac02007-09-25 01:57:46 +00003445} // Uses = [EFLAGS]
3446
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003447
3448// Integer comparisons
Evan Cheng55687072007-09-14 21:48:26 +00003449let Defs = [EFLAGS] in {
Sean Callanan251676e2009-09-02 00:55:49 +00003450def CMP8i8 : Ii8<0x3C, RawFrm, (outs), (ins i8imm:$src),
3451 "cmp{b}\t{$src, %al|%al, $src}", []>;
3452def CMP16i16 : Ii16<0x3D, RawFrm, (outs), (ins i16imm:$src),
3453 "cmp{w}\t{$src, %ax|%ax, $src}", []>, OpSize;
3454def CMP32i32 : Ii32<0x3D, RawFrm, (outs), (ins i32imm:$src),
3455 "cmp{l}\t{$src, %eax|%eax, $src}", []>;
3456
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003457def CMP8rr : I<0x38, MRMDestReg,
Evan Chengb783fa32007-07-19 01:14:50 +00003458 (outs), (ins GR8 :$src1, GR8 :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00003459 "cmp{b}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00003460 [(X86cmp GR8:$src1, GR8:$src2), (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003461def CMP16rr : I<0x39, MRMDestReg,
Evan Chengb783fa32007-07-19 01:14:50 +00003462 (outs), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00003463 "cmp{w}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00003464 [(X86cmp GR16:$src1, GR16:$src2), (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003465def CMP32rr : I<0x39, MRMDestReg,
Evan Chengb783fa32007-07-19 01:14:50 +00003466 (outs), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00003467 "cmp{l}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00003468 [(X86cmp GR32:$src1, GR32:$src2), (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003469def CMP8mr : I<0x38, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00003470 (outs), (ins i8mem :$src1, GR8 :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00003471 "cmp{b}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00003472 [(X86cmp (loadi8 addr:$src1), GR8:$src2),
3473 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003474def CMP16mr : I<0x39, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00003475 (outs), (ins i16mem:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00003476 "cmp{w}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00003477 [(X86cmp (loadi16 addr:$src1), GR16:$src2),
3478 (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003479def CMP32mr : I<0x39, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00003480 (outs), (ins i32mem:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00003481 "cmp{l}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00003482 [(X86cmp (loadi32 addr:$src1), GR32:$src2),
3483 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003484def CMP8rm : I<0x3A, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00003485 (outs), (ins GR8 :$src1, i8mem :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00003486 "cmp{b}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00003487 [(X86cmp GR8:$src1, (loadi8 addr:$src2)),
3488 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003489def CMP16rm : I<0x3B, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00003490 (outs), (ins GR16:$src1, i16mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00003491 "cmp{w}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00003492 [(X86cmp GR16:$src1, (loadi16 addr:$src2)),
3493 (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003494def CMP32rm : I<0x3B, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00003495 (outs), (ins GR32:$src1, i32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00003496 "cmp{l}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00003497 [(X86cmp GR32:$src1, (loadi32 addr:$src2)),
3498 (implicit EFLAGS)]>;
Sean Callanan11490dc2009-09-16 21:11:23 +00003499def CMP8mrmrr : I<0x3A, MRMSrcReg, (outs), (ins GR8:$src1, GR8:$src2),
3500 "cmp{b}\t{$src2, $src1|$src1, $src2}", []>;
3501def CMP16mrmrr : I<0x3B, MRMSrcReg, (outs), (ins GR16:$src1, GR16:$src2),
3502 "cmp{w}\t{$src2, $src1|$src1, $src2}", []>, OpSize;
3503def CMP32mrmrr : I<0x3B, MRMSrcReg, (outs), (ins GR32:$src1, GR32:$src2),
3504 "cmp{l}\t{$src2, $src1|$src1, $src2}", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003505def CMP8ri : Ii8<0x80, MRM7r,
Evan Chengb783fa32007-07-19 01:14:50 +00003506 (outs), (ins GR8:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00003507 "cmp{b}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00003508 [(X86cmp GR8:$src1, imm:$src2), (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003509def CMP16ri : Ii16<0x81, MRM7r,
Evan Chengb783fa32007-07-19 01:14:50 +00003510 (outs), (ins GR16:$src1, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00003511 "cmp{w}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00003512 [(X86cmp GR16:$src1, imm:$src2),
3513 (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003514def CMP32ri : Ii32<0x81, MRM7r,
Evan Chengb783fa32007-07-19 01:14:50 +00003515 (outs), (ins GR32:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00003516 "cmp{l}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00003517 [(X86cmp GR32:$src1, imm:$src2), (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003518def CMP8mi : Ii8 <0x80, MRM7m,
Evan Chengb783fa32007-07-19 01:14:50 +00003519 (outs), (ins i8mem :$src1, i8imm :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00003520 "cmp{b}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00003521 [(X86cmp (loadi8 addr:$src1), imm:$src2),
3522 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003523def CMP16mi : Ii16<0x81, MRM7m,
Evan Chengb783fa32007-07-19 01:14:50 +00003524 (outs), (ins i16mem:$src1, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00003525 "cmp{w}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00003526 [(X86cmp (loadi16 addr:$src1), imm:$src2),
3527 (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003528def CMP32mi : Ii32<0x81, MRM7m,
Evan Chengb783fa32007-07-19 01:14:50 +00003529 (outs), (ins i32mem:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00003530 "cmp{l}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00003531 [(X86cmp (loadi32 addr:$src1), imm:$src2),
3532 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003533def CMP16ri8 : Ii8<0x83, MRM7r,
Evan Chengb783fa32007-07-19 01:14:50 +00003534 (outs), (ins GR16:$src1, i16i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00003535 "cmp{w}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00003536 [(X86cmp GR16:$src1, i16immSExt8:$src2),
3537 (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003538def CMP16mi8 : Ii8<0x83, MRM7m,
Evan Chengb783fa32007-07-19 01:14:50 +00003539 (outs), (ins i16mem:$src1, i16i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00003540 "cmp{w}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00003541 [(X86cmp (loadi16 addr:$src1), i16immSExt8:$src2),
3542 (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003543def CMP32mi8 : Ii8<0x83, MRM7m,
Evan Chengb783fa32007-07-19 01:14:50 +00003544 (outs), (ins i32mem:$src1, i32i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00003545 "cmp{l}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00003546 [(X86cmp (loadi32 addr:$src1), i32immSExt8:$src2),
3547 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003548def CMP32ri8 : Ii8<0x83, MRM7r,
Evan Chengb783fa32007-07-19 01:14:50 +00003549 (outs), (ins GR32:$src1, i32i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00003550 "cmp{l}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00003551 [(X86cmp GR32:$src1, i32immSExt8:$src2),
Evan Cheng950aac02007-09-25 01:57:46 +00003552 (implicit EFLAGS)]>;
3553} // Defs = [EFLAGS]
3554
Dan Gohman7fe9b7f2008-12-23 22:45:23 +00003555// Bit tests.
Dan Gohman7fe9b7f2008-12-23 22:45:23 +00003556// TODO: BTC, BTR, and BTS
3557let Defs = [EFLAGS] in {
Dan Gohmanfc4eddb2009-01-13 20:32:45 +00003558def BT16rr : I<0xA3, MRMDestReg, (outs), (ins GR16:$src1, GR16:$src2),
Dan Gohman7fe9b7f2008-12-23 22:45:23 +00003559 "bt{w}\t{$src2, $src1|$src1, $src2}",
3560 [(X86bt GR16:$src1, GR16:$src2),
Chris Lattner5a95cde2008-12-25 01:32:49 +00003561 (implicit EFLAGS)]>, OpSize, TB;
Dan Gohmanfc4eddb2009-01-13 20:32:45 +00003562def BT32rr : I<0xA3, MRMDestReg, (outs), (ins GR32:$src1, GR32:$src2),
Dan Gohman7fe9b7f2008-12-23 22:45:23 +00003563 "bt{l}\t{$src2, $src1|$src1, $src2}",
3564 [(X86bt GR32:$src1, GR32:$src2),
Chris Lattner5a95cde2008-12-25 01:32:49 +00003565 (implicit EFLAGS)]>, TB;
Dan Gohman85a228c2009-01-13 23:23:30 +00003566
3567// Unlike with the register+register form, the memory+register form of the
3568// bt instruction does not ignore the high bits of the index. From ISel's
Sean Callanan2c48df22009-12-18 00:01:26 +00003569// perspective, this is pretty bizarre. Make these instructions disassembly
3570// only for now.
3571
3572def BT16mr : I<0xA3, MRMDestMem, (outs), (ins i16mem:$src1, GR16:$src2),
3573 "bt{w}\t{$src2, $src1|$src1, $src2}",
Dan Gohman85a228c2009-01-13 23:23:30 +00003574// [(X86bt (loadi16 addr:$src1), GR16:$src2),
Sean Callanan2c48df22009-12-18 00:01:26 +00003575// (implicit EFLAGS)]
3576 []
3577 >, OpSize, TB, Requires<[FastBTMem]>;
3578def BT32mr : I<0xA3, MRMDestMem, (outs), (ins i32mem:$src1, GR32:$src2),
3579 "bt{l}\t{$src2, $src1|$src1, $src2}",
Dan Gohman85a228c2009-01-13 23:23:30 +00003580// [(X86bt (loadi32 addr:$src1), GR32:$src2),
Sean Callanan2c48df22009-12-18 00:01:26 +00003581// (implicit EFLAGS)]
3582 []
3583 >, TB, Requires<[FastBTMem]>;
Dan Gohman46fb1cf2009-01-13 20:33:23 +00003584
3585def BT16ri8 : Ii8<0xBA, MRM4r, (outs), (ins GR16:$src1, i16i8imm:$src2),
3586 "bt{w}\t{$src2, $src1|$src1, $src2}",
3587 [(X86bt GR16:$src1, i16immSExt8:$src2),
3588 (implicit EFLAGS)]>, OpSize, TB;
3589def BT32ri8 : Ii8<0xBA, MRM4r, (outs), (ins GR32:$src1, i32i8imm:$src2),
3590 "bt{l}\t{$src2, $src1|$src1, $src2}",
3591 [(X86bt GR32:$src1, i32immSExt8:$src2),
3592 (implicit EFLAGS)]>, TB;
3593// Note that these instructions don't need FastBTMem because that
3594// only applies when the other operand is in a register. When it's
3595// an immediate, bt is still fast.
3596def BT16mi8 : Ii8<0xBA, MRM4m, (outs), (ins i16mem:$src1, i16i8imm:$src2),
3597 "bt{w}\t{$src2, $src1|$src1, $src2}",
3598 [(X86bt (loadi16 addr:$src1), i16immSExt8:$src2),
3599 (implicit EFLAGS)]>, OpSize, TB;
3600def BT32mi8 : Ii8<0xBA, MRM4m, (outs), (ins i32mem:$src1, i32i8imm:$src2),
3601 "bt{l}\t{$src2, $src1|$src1, $src2}",
3602 [(X86bt (loadi32 addr:$src1), i32immSExt8:$src2),
3603 (implicit EFLAGS)]>, TB;
Sean Callanan2c48df22009-12-18 00:01:26 +00003604
3605def BTC16rr : I<0xBB, MRMDestReg, (outs), (ins GR16:$src1, GR16:$src2),
3606 "btc{w}\t{$src2, $src1|$src1, $src2}", []>, OpSize, TB;
3607def BTC32rr : I<0xBB, MRMDestReg, (outs), (ins GR32:$src1, GR32:$src2),
3608 "btc{l}\t{$src2, $src1|$src1, $src2}", []>, TB;
3609def BTC16mr : I<0xBB, MRMDestMem, (outs), (ins i16mem:$src1, GR16:$src2),
3610 "btc{w}\t{$src2, $src1|$src1, $src2}", []>, OpSize, TB;
3611def BTC32mr : I<0xBB, MRMDestMem, (outs), (ins i32mem:$src1, GR32:$src2),
3612 "btc{l}\t{$src2, $src1|$src1, $src2}", []>, TB;
3613def BTC16ri8 : Ii8<0xBA, MRM7r, (outs), (ins GR16:$src1, i16i8imm:$src2),
3614 "btc{w}\t{$src2, $src1|$src1, $src2}", []>, OpSize, TB;
3615def BTC32ri8 : Ii8<0xBA, MRM7r, (outs), (ins GR32:$src1, i32i8imm:$src2),
3616 "btc{l}\t{$src2, $src1|$src1, $src2}", []>, TB;
3617def BTC16mi8 : Ii8<0xBA, MRM7m, (outs), (ins i16mem:$src1, i16i8imm:$src2),
3618 "btc{w}\t{$src2, $src1|$src1, $src2}", []>, OpSize, TB;
3619def BTC32mi8 : Ii8<0xBA, MRM7m, (outs), (ins i32mem:$src1, i32i8imm:$src2),
3620 "btc{l}\t{$src2, $src1|$src1, $src2}", []>, TB;
3621
3622def BTR16rr : I<0xB3, MRMDestReg, (outs), (ins GR16:$src1, GR16:$src2),
3623 "btr{w}\t{$src2, $src1|$src1, $src2}", []>, OpSize, TB;
3624def BTR32rr : I<0xB3, MRMDestReg, (outs), (ins GR32:$src1, GR32:$src2),
3625 "btr{l}\t{$src2, $src1|$src1, $src2}", []>, TB;
3626def BTR16mr : I<0xB3, MRMDestMem, (outs), (ins i16mem:$src1, GR16:$src2),
3627 "btr{w}\t{$src2, $src1|$src1, $src2}", []>, OpSize, TB;
3628def BTR32mr : I<0xB3, MRMDestMem, (outs), (ins i32mem:$src1, GR32:$src2),
3629 "btr{l}\t{$src2, $src1|$src1, $src2}", []>, TB;
3630def BTR16ri8 : Ii8<0xBA, MRM6r, (outs), (ins GR16:$src1, i16i8imm:$src2),
3631 "btr{w}\t{$src2, $src1|$src1, $src2}", []>, OpSize, TB;
3632def BTR32ri8 : Ii8<0xBA, MRM6r, (outs), (ins GR32:$src1, i32i8imm:$src2),
3633 "btr{l}\t{$src2, $src1|$src1, $src2}", []>, TB;
3634def BTR16mi8 : Ii8<0xBA, MRM6m, (outs), (ins i16mem:$src1, i16i8imm:$src2),
3635 "btr{w}\t{$src2, $src1|$src1, $src2}", []>, OpSize, TB;
3636def BTR32mi8 : Ii8<0xBA, MRM6m, (outs), (ins i32mem:$src1, i32i8imm:$src2),
3637 "btr{l}\t{$src2, $src1|$src1, $src2}", []>, TB;
3638
3639def BTS16rr : I<0xAB, MRMDestReg, (outs), (ins GR16:$src1, GR16:$src2),
3640 "bts{w}\t{$src2, $src1|$src1, $src2}", []>, OpSize, TB;
3641def BTS32rr : I<0xAB, MRMDestReg, (outs), (ins GR32:$src1, GR32:$src2),
3642 "bts{l}\t{$src2, $src1|$src1, $src2}", []>, TB;
3643def BTS16mr : I<0xAB, MRMDestMem, (outs), (ins i16mem:$src1, GR16:$src2),
3644 "bts{w}\t{$src2, $src1|$src1, $src2}", []>, OpSize, TB;
3645def BTS32mr : I<0xAB, MRMDestMem, (outs), (ins i32mem:$src1, GR32:$src2),
3646 "bts{l}\t{$src2, $src1|$src1, $src2}", []>, TB;
3647def BTS16ri8 : Ii8<0xBA, MRM5r, (outs), (ins GR16:$src1, i16i8imm:$src2),
3648 "bts{w}\t{$src2, $src1|$src1, $src2}", []>, OpSize, TB;
3649def BTS32ri8 : Ii8<0xBA, MRM5r, (outs), (ins GR32:$src1, i32i8imm:$src2),
3650 "bts{l}\t{$src2, $src1|$src1, $src2}", []>, TB;
3651def BTS16mi8 : Ii8<0xBA, MRM5m, (outs), (ins i16mem:$src1, i16i8imm:$src2),
3652 "bts{w}\t{$src2, $src1|$src1, $src2}", []>, OpSize, TB;
3653def BTS32mi8 : Ii8<0xBA, MRM5m, (outs), (ins i32mem:$src1, i32i8imm:$src2),
3654 "bts{l}\t{$src2, $src1|$src1, $src2}", []>, TB;
Dan Gohman7fe9b7f2008-12-23 22:45:23 +00003655} // Defs = [EFLAGS]
3656
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003657// Sign/Zero extenders
Dan Gohman9203ab42008-07-30 18:09:17 +00003658// Use movsbl intead of movsbw; we don't care about the high 16 bits
3659// of the register here. This has a smaller encoding and avoids a
Sean Callanan2c48df22009-12-18 00:01:26 +00003660// partial-register update. Actual movsbw included for the disassembler.
3661def MOVSX16rr8W : I<0xBE, MRMSrcReg, (outs GR16:$dst), (ins GR8:$src),
3662 "movs{bw|x}\t{$src, $dst|$dst, $src}", []>, TB, OpSize;
3663def MOVSX16rm8W : I<0xBE, MRMSrcMem, (outs GR16:$dst), (ins i8mem:$src),
3664 "movs{bw|x}\t{$src, $dst|$dst, $src}", []>, TB, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00003665def MOVSX16rr8 : I<0xBE, MRMSrcReg, (outs GR16:$dst), (ins GR8 :$src),
Chris Lattnerbe7efcc2009-10-19 19:51:42 +00003666 "", [(set GR16:$dst, (sext GR8:$src))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00003667def MOVSX16rm8 : I<0xBE, MRMSrcMem, (outs GR16:$dst), (ins i8mem :$src),
Chris Lattnerbe7efcc2009-10-19 19:51:42 +00003668 "", [(set GR16:$dst, (sextloadi16i8 addr:$src))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00003669def MOVSX32rr8 : I<0xBE, MRMSrcReg, (outs GR32:$dst), (ins GR8 :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00003670 "movs{bl|x}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003671 [(set GR32:$dst, (sext GR8:$src))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00003672def MOVSX32rm8 : I<0xBE, MRMSrcMem, (outs GR32:$dst), (ins i8mem :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00003673 "movs{bl|x}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003674 [(set GR32:$dst, (sextloadi32i8 addr:$src))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00003675def MOVSX32rr16: I<0xBF, MRMSrcReg, (outs GR32:$dst), (ins GR16:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00003676 "movs{wl|x}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003677 [(set GR32:$dst, (sext GR16:$src))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00003678def MOVSX32rm16: I<0xBF, MRMSrcMem, (outs GR32:$dst), (ins i16mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00003679 "movs{wl|x}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003680 [(set GR32:$dst, (sextloadi32i16 addr:$src))]>, TB;
3681
Dan Gohman9203ab42008-07-30 18:09:17 +00003682// Use movzbl intead of movzbw; we don't care about the high 16 bits
3683// of the register here. This has a smaller encoding and avoids a
Sean Callanan2c48df22009-12-18 00:01:26 +00003684// partial-register update. Actual movzbw included for the disassembler.
3685def MOVZX16rr8W : I<0xB6, MRMSrcReg, (outs GR16:$dst), (ins GR8:$src),
3686 "movz{bw|x}\t{$src, $dst|$dst, $src}", []>, TB, OpSize;
3687def MOVZX16rm8W : I<0xB6, MRMSrcMem, (outs GR16:$dst), (ins i8mem:$src),
3688 "movz{bw|x}\t{$src, $dst|$dst, $src}", []>, TB, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00003689def MOVZX16rr8 : I<0xB6, MRMSrcReg, (outs GR16:$dst), (ins GR8 :$src),
Chris Lattnerbe7efcc2009-10-19 19:51:42 +00003690 "", [(set GR16:$dst, (zext GR8:$src))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00003691def MOVZX16rm8 : I<0xB6, MRMSrcMem, (outs GR16:$dst), (ins i8mem :$src),
Chris Lattnerbe7efcc2009-10-19 19:51:42 +00003692 "", [(set GR16:$dst, (zextloadi16i8 addr:$src))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00003693def MOVZX32rr8 : I<0xB6, MRMSrcReg, (outs GR32:$dst), (ins GR8 :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00003694 "movz{bl|x}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003695 [(set GR32:$dst, (zext GR8:$src))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00003696def MOVZX32rm8 : I<0xB6, MRMSrcMem, (outs GR32:$dst), (ins i8mem :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00003697 "movz{bl|x}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003698 [(set GR32:$dst, (zextloadi32i8 addr:$src))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00003699def MOVZX32rr16: I<0xB7, MRMSrcReg, (outs GR32:$dst), (ins GR16:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00003700 "movz{wl|x}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003701 [(set GR32:$dst, (zext GR16:$src))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00003702def MOVZX32rm16: I<0xB7, MRMSrcMem, (outs GR32:$dst), (ins i16mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00003703 "movz{wl|x}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003704 [(set GR32:$dst, (zextloadi32i16 addr:$src))]>, TB;
3705
Dan Gohman744d4622009-04-13 16:09:41 +00003706// These are the same as the regular regular MOVZX32rr8 and MOVZX32rm8
3707// except that they use GR32_NOREX for the output operand register class
3708// instead of GR32. This allows them to operate on h registers on x86-64.
3709def MOVZX32_NOREXrr8 : I<0xB6, MRMSrcReg,
3710 (outs GR32_NOREX:$dst), (ins GR8:$src),
3711 "movz{bl|x}\t{$src, $dst|$dst, $src} # NOREX",
3712 []>, TB;
Dan Gohman89f4cda2009-04-30 03:11:48 +00003713let mayLoad = 1 in
Dan Gohman744d4622009-04-13 16:09:41 +00003714def MOVZX32_NOREXrm8 : I<0xB6, MRMSrcMem,
3715 (outs GR32_NOREX:$dst), (ins i8mem:$src),
3716 "movz{bl|x}\t{$src, $dst|$dst, $src} # NOREX",
3717 []>, TB;
3718
Chris Lattnerc90ee9c2008-01-10 07:59:24 +00003719let neverHasSideEffects = 1 in {
3720 let Defs = [AX], Uses = [AL] in
3721 def CBW : I<0x98, RawFrm, (outs), (ins),
3722 "{cbtw|cbw}", []>, OpSize; // AX = signext(AL)
3723 let Defs = [EAX], Uses = [AX] in
3724 def CWDE : I<0x98, RawFrm, (outs), (ins),
3725 "{cwtl|cwde}", []>; // EAX = signext(AX)
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003726
Chris Lattnerc90ee9c2008-01-10 07:59:24 +00003727 let Defs = [AX,DX], Uses = [AX] in
3728 def CWD : I<0x99, RawFrm, (outs), (ins),
3729 "{cwtd|cwd}", []>, OpSize; // DX:AX = signext(AX)
3730 let Defs = [EAX,EDX], Uses = [EAX] in
3731 def CDQ : I<0x99, RawFrm, (outs), (ins),
3732 "{cltd|cdq}", []>; // EDX:EAX = signext(EAX)
3733}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003734
3735//===----------------------------------------------------------------------===//
3736// Alias Instructions
3737//===----------------------------------------------------------------------===//
3738
3739// Alias instructions that map movr0 to xor.
3740// FIXME: remove when we can teach regalloc that xor reg, reg is ok.
Daniel Dunbara0e62002009-08-11 22:17:52 +00003741let Defs = [EFLAGS], isReMaterializable = 1, isAsCheapAsAMove = 1,
3742 isCodeGenOnly = 1 in {
Evan Chengb783fa32007-07-19 01:14:50 +00003743def MOV8r0 : I<0x30, MRMInitReg, (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00003744 "xor{b}\t$dst, $dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003745 [(set GR8:$dst, 0)]>;
Dan Gohmanb9e1c8d2010-01-12 04:42:54 +00003746
3747// We want to rewrite MOV16r0 in terms of MOV32r0, because it's a smaller
3748// encoding and avoids a partial-register update sometimes, but doing so
3749// at isel time interferes with rematerialization in the current register
3750// allocator. For now, this is rewritten when the instruction is lowered
3751// to an MCInst.
3752def MOV16r0 : I<0x31, MRMInitReg, (outs GR16:$dst), (ins),
3753 "",
3754 [(set GR16:$dst, 0)]>, OpSize;
Chris Lattnerb5b1b862009-12-23 01:30:26 +00003755
Chris Lattner2ba53dc2009-12-23 01:46:40 +00003756def MOV32r0 : I<0x31, MRMInitReg, (outs GR32:$dst), (ins),
3757 "xor{l}\t$dst, $dst",
3758 [(set GR32:$dst, 0)]>;
3759}
Chris Lattnerb5b1b862009-12-23 01:30:26 +00003760
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003761//===----------------------------------------------------------------------===//
3762// Thread Local Storage Instructions
3763//
3764
Rafael Espindola7fc4b8d2009-04-24 12:59:40 +00003765// All calls clobber the non-callee saved registers. ESP is marked as
3766// a use to prevent stack-pointer assignments that appear immediately
3767// before calls from potentially appearing dead.
3768let Defs = [EAX, ECX, EDX, FP0, FP1, FP2, FP3, FP4, FP5, FP6, ST0,
3769 MM0, MM1, MM2, MM3, MM4, MM5, MM6, MM7,
3770 XMM0, XMM1, XMM2, XMM3, XMM4, XMM5, XMM6, XMM7,
3771 XMM8, XMM9, XMM10, XMM11, XMM12, XMM13, XMM14, XMM15, EFLAGS],
Chris Lattnerf1940742009-06-20 20:38:48 +00003772 Uses = [ESP] in
3773def TLS_addr32 : I<0, Pseudo, (outs), (ins lea32mem:$sym),
3774 "leal\t$sym, %eax; "
Dan Gohman70a8a112009-04-27 15:13:28 +00003775 "call\t___tls_get_addr@PLT",
Chris Lattnerf1940742009-06-20 20:38:48 +00003776 [(X86tlsaddr tls32addr:$sym)]>,
Rafael Espindolaaf759ab2009-04-17 14:35:58 +00003777 Requires<[In32BitMode]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003778
Daniel Dunbar75a07302009-08-11 22:24:40 +00003779let AddedComplexity = 5, isCodeGenOnly = 1 in
sampo9cc09a32009-01-26 01:24:32 +00003780def GS_MOV32rm : I<0x8B, MRMSrcMem, (outs GR32:$dst), (ins i32mem:$src),
3781 "movl\t%gs:$src, $dst",
3782 [(set GR32:$dst, (gsload addr:$src))]>, SegGS;
3783
Daniel Dunbar75a07302009-08-11 22:24:40 +00003784let AddedComplexity = 5, isCodeGenOnly = 1 in
Chris Lattnera7c2d8a2009-05-05 18:52:19 +00003785def FS_MOV32rm : I<0x8B, MRMSrcMem, (outs GR32:$dst), (ins i32mem:$src),
3786 "movl\t%fs:$src, $dst",
3787 [(set GR32:$dst, (fsload addr:$src))]>, SegFS;
3788
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003789//===----------------------------------------------------------------------===//
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003790// EH Pseudo Instructions
3791//
3792let isTerminator = 1, isReturn = 1, isBarrier = 1,
Daniel Dunbar75513bd2009-08-27 07:58:05 +00003793 hasCtrlDep = 1, isCodeGenOnly = 1 in {
Evan Chengb783fa32007-07-19 01:14:50 +00003794def EH_RETURN : I<0xC3, RawFrm, (outs), (ins GR32:$addr),
Dan Gohman91888f02007-07-31 20:11:57 +00003795 "ret\t#eh_return, addr: $addr",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003796 [(X86ehret GR32:$addr)]>;
3797
3798}
3799
3800//===----------------------------------------------------------------------===//
Andrew Lenharthe44f3902008-02-21 06:45:13 +00003801// Atomic support
3802//
Andrew Lenharth7a5a4b22008-03-01 13:37:02 +00003803
Evan Cheng3e171562008-04-19 01:20:30 +00003804// Atomic swap. These are just normal xchg instructions. But since a memory
3805// operand is referenced, the atomicity is ensured.
Dan Gohmana41a1c092008-08-06 15:52:50 +00003806let Constraints = "$val = $dst" in {
Sean Callanan2c48df22009-12-18 00:01:26 +00003807def XCHG32rm : I<0x87, MRMSrcMem, (outs GR32:$dst),
3808 (ins GR32:$val, i32mem:$ptr),
Evan Cheng3e171562008-04-19 01:20:30 +00003809 "xchg{l}\t{$val, $ptr|$ptr, $val}",
3810 [(set GR32:$dst, (atomic_swap_32 addr:$ptr, GR32:$val))]>;
Sean Callanan2c48df22009-12-18 00:01:26 +00003811def XCHG16rm : I<0x87, MRMSrcMem, (outs GR16:$dst),
3812 (ins GR16:$val, i16mem:$ptr),
Evan Cheng3e171562008-04-19 01:20:30 +00003813 "xchg{w}\t{$val, $ptr|$ptr, $val}",
3814 [(set GR16:$dst, (atomic_swap_16 addr:$ptr, GR16:$val))]>,
3815 OpSize;
Sean Callanan2c48df22009-12-18 00:01:26 +00003816def XCHG8rm : I<0x86, MRMSrcMem, (outs GR8:$dst), (ins GR8:$val, i8mem:$ptr),
Evan Cheng3e171562008-04-19 01:20:30 +00003817 "xchg{b}\t{$val, $ptr|$ptr, $val}",
3818 [(set GR8:$dst, (atomic_swap_8 addr:$ptr, GR8:$val))]>;
Sean Callanan2c48df22009-12-18 00:01:26 +00003819
3820def XCHG32rr : I<0x87, MRMSrcReg, (outs GR32:$dst), (ins GR32:$val, GR32:$src),
3821 "xchg{l}\t{$val, $src|$src, $val}", []>;
3822def XCHG16rr : I<0x87, MRMSrcReg, (outs GR16:$dst), (ins GR16:$val, GR16:$src),
3823 "xchg{w}\t{$val, $src|$src, $val}", []>, OpSize;
3824def XCHG8rr : I<0x86, MRMSrcReg, (outs GR8:$dst), (ins GR8:$val, GR8:$src),
3825 "xchg{b}\t{$val, $src|$src, $val}", []>;
Evan Cheng3e171562008-04-19 01:20:30 +00003826}
3827
Sean Callanan2c48df22009-12-18 00:01:26 +00003828def XCHG16ar : I<0x90, AddRegFrm, (outs), (ins GR16:$src),
3829 "xchg{w}\t{$src, %ax|%ax, $src}", []>, OpSize;
3830def XCHG32ar : I<0x90, AddRegFrm, (outs), (ins GR32:$src),
3831 "xchg{l}\t{$src, %eax|%eax, $src}", []>;
3832
Evan Chengd49dbb82008-04-18 20:55:36 +00003833// Atomic compare and swap.
Andrew Lenharth7dfe23f2008-03-01 21:52:34 +00003834let Defs = [EAX, EFLAGS], Uses = [EAX] in {
Evan Chengd49dbb82008-04-18 20:55:36 +00003835def LCMPXCHG32 : I<0xB1, MRMDestMem, (outs), (ins i32mem:$ptr, GR32:$swap),
Dan Gohman70a8a112009-04-27 15:13:28 +00003836 "lock\n\t"
3837 "cmpxchg{l}\t{$swap, $ptr|$ptr, $swap}",
Evan Cheng09fbdee2008-03-04 03:20:06 +00003838 [(X86cas addr:$ptr, GR32:$swap, 4)]>, TB, LOCK;
Andrew Lenharth7a5a4b22008-03-01 13:37:02 +00003839}
Dale Johannesenf160d802008-10-02 18:53:47 +00003840let Defs = [EAX, EDX, EFLAGS], Uses = [EAX, EBX, ECX, EDX] in {
Evan Cheng3896a6f2010-01-08 01:29:19 +00003841def LCMPXCHG8B : I<0xC7, MRM1m, (outs), (ins i64mem:$ptr),
Dan Gohman70a8a112009-04-27 15:13:28 +00003842 "lock\n\t"
3843 "cmpxchg8b\t$ptr",
Andrew Lenharth81580822008-03-05 01:15:49 +00003844 [(X86cas8 addr:$ptr)]>, TB, LOCK;
3845}
Andrew Lenharth7dfe23f2008-03-01 21:52:34 +00003846
3847let Defs = [AX, EFLAGS], Uses = [AX] in {
Evan Chengd49dbb82008-04-18 20:55:36 +00003848def LCMPXCHG16 : I<0xB1, MRMDestMem, (outs), (ins i16mem:$ptr, GR16:$swap),
Dan Gohman70a8a112009-04-27 15:13:28 +00003849 "lock\n\t"
3850 "cmpxchg{w}\t{$swap, $ptr|$ptr, $swap}",
Evan Cheng09fbdee2008-03-04 03:20:06 +00003851 [(X86cas addr:$ptr, GR16:$swap, 2)]>, TB, OpSize, LOCK;
Andrew Lenharth7a5a4b22008-03-01 13:37:02 +00003852}
Andrew Lenharth7dfe23f2008-03-01 21:52:34 +00003853let Defs = [AL, EFLAGS], Uses = [AL] in {
Evan Chengd49dbb82008-04-18 20:55:36 +00003854def LCMPXCHG8 : I<0xB0, MRMDestMem, (outs), (ins i8mem:$ptr, GR8:$swap),
Dan Gohman70a8a112009-04-27 15:13:28 +00003855 "lock\n\t"
3856 "cmpxchg{b}\t{$swap, $ptr|$ptr, $swap}",
Evan Cheng09fbdee2008-03-04 03:20:06 +00003857 [(X86cas addr:$ptr, GR8:$swap, 1)]>, TB, LOCK;
Andrew Lenharth7a5a4b22008-03-01 13:37:02 +00003858}
3859
Evan Chengd49dbb82008-04-18 20:55:36 +00003860// Atomic exchange and add
3861let Constraints = "$val = $dst", Defs = [EFLAGS] in {
Sean Callanan2c48df22009-12-18 00:01:26 +00003862def LXADD32 : I<0xC1, MRMSrcMem, (outs GR32:$dst), (ins GR32:$val, i32mem:$ptr),
Dan Gohman70a8a112009-04-27 15:13:28 +00003863 "lock\n\t"
3864 "xadd{l}\t{$val, $ptr|$ptr, $val}",
Mon P Wang6bde9ec2008-06-25 08:15:39 +00003865 [(set GR32:$dst, (atomic_load_add_32 addr:$ptr, GR32:$val))]>,
Evan Chengd49dbb82008-04-18 20:55:36 +00003866 TB, LOCK;
Sean Callanan2c48df22009-12-18 00:01:26 +00003867def LXADD16 : I<0xC1, MRMSrcMem, (outs GR16:$dst), (ins GR16:$val, i16mem:$ptr),
Dan Gohman70a8a112009-04-27 15:13:28 +00003868 "lock\n\t"
3869 "xadd{w}\t{$val, $ptr|$ptr, $val}",
Mon P Wang6bde9ec2008-06-25 08:15:39 +00003870 [(set GR16:$dst, (atomic_load_add_16 addr:$ptr, GR16:$val))]>,
Evan Chengd49dbb82008-04-18 20:55:36 +00003871 TB, OpSize, LOCK;
Sean Callanan2c48df22009-12-18 00:01:26 +00003872def LXADD8 : I<0xC0, MRMSrcMem, (outs GR8:$dst), (ins GR8:$val, i8mem:$ptr),
Dan Gohman70a8a112009-04-27 15:13:28 +00003873 "lock\n\t"
3874 "xadd{b}\t{$val, $ptr|$ptr, $val}",
Mon P Wang6bde9ec2008-06-25 08:15:39 +00003875 [(set GR8:$dst, (atomic_load_add_8 addr:$ptr, GR8:$val))]>,
Evan Chengd49dbb82008-04-18 20:55:36 +00003876 TB, LOCK;
Andrew Lenharth7a5a4b22008-03-01 13:37:02 +00003877}
3878
Sean Callanan2c48df22009-12-18 00:01:26 +00003879def XADD8rr : I<0xC0, MRMDestReg, (outs GR8:$dst), (ins GR8:$src),
3880 "xadd{b}\t{$src, $dst|$dst, $src}", []>, TB;
3881def XADD16rr : I<0xC1, MRMDestReg, (outs GR16:$dst), (ins GR16:$src),
3882 "xadd{w}\t{$src, $dst|$dst, $src}", []>, TB, OpSize;
3883def XADD32rr : I<0xC1, MRMDestReg, (outs GR32:$dst), (ins GR32:$src),
3884 "xadd{l}\t{$src, $dst|$dst, $src}", []>, TB;
3885
3886def XADD8rm : I<0xC0, MRMDestMem, (outs), (ins i8mem:$dst, GR8:$src),
3887 "xadd{b}\t{$src, $dst|$dst, $src}", []>, TB;
3888def XADD16rm : I<0xC1, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src),
3889 "xadd{w}\t{$src, $dst|$dst, $src}", []>, TB, OpSize;
3890def XADD32rm : I<0xC1, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src),
3891 "xadd{l}\t{$src, $dst|$dst, $src}", []>, TB;
3892
3893def CMPXCHG8rr : I<0xB0, MRMDestReg, (outs GR8:$dst), (ins GR8:$src),
3894 "cmpxchg{b}\t{$src, $dst|$dst, $src}", []>, TB;
3895def CMPXCHG16rr : I<0xB1, MRMDestReg, (outs GR16:$dst), (ins GR16:$src),
3896 "cmpxchg{w}\t{$src, $dst|$dst, $src}", []>, TB, OpSize;
3897def CMPXCHG32rr : I<0xB1, MRMDestReg, (outs GR32:$dst), (ins GR32:$src),
3898 "cmpxchg{l}\t{$src, $dst|$dst, $src}", []>, TB;
3899
3900def CMPXCHG8rm : I<0xB0, MRMDestMem, (outs), (ins i8mem:$dst, GR8:$src),
3901 "cmpxchg{b}\t{$src, $dst|$dst, $src}", []>, TB;
3902def CMPXCHG16rm : I<0xB1, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src),
3903 "cmpxchg{w}\t{$src, $dst|$dst, $src}", []>, TB, OpSize;
3904def CMPXCHG32rm : I<0xB1, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src),
3905 "cmpxchg{l}\t{$src, $dst|$dst, $src}", []>, TB;
3906
Evan Cheng3896a6f2010-01-08 01:29:19 +00003907let Defs = [EAX, EDX, EFLAGS], Uses = [EAX, EBX, ECX, EDX] in
Sean Callanan2c48df22009-12-18 00:01:26 +00003908def CMPXCHG8B : I<0xC7, MRM1m, (outs), (ins i64mem:$dst),
3909 "cmpxchg8b\t$dst", []>, TB;
3910
Evan Chengb723fb52009-07-30 08:33:02 +00003911// Optimized codegen when the non-memory output is not used.
3912// FIXME: Use normal add / sub instructions and add lock prefix dynamically.
Dan Gohman1c286992009-10-20 18:14:49 +00003913let Defs = [EFLAGS] in {
Evan Chengb723fb52009-07-30 08:33:02 +00003914def LOCK_ADD8mr : I<0x00, MRMDestMem, (outs), (ins i8mem:$dst, GR8:$src2),
3915 "lock\n\t"
3916 "add{b}\t{$src2, $dst|$dst, $src2}", []>, LOCK;
3917def LOCK_ADD16mr : I<0x01, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
3918 "lock\n\t"
3919 "add{w}\t{$src2, $dst|$dst, $src2}", []>, OpSize, LOCK;
3920def LOCK_ADD32mr : I<0x01, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
3921 "lock\n\t"
3922 "add{l}\t{$src2, $dst|$dst, $src2}", []>, LOCK;
3923def LOCK_ADD8mi : Ii8<0x80, MRM0m, (outs), (ins i8mem :$dst, i8imm :$src2),
3924 "lock\n\t"
3925 "add{b}\t{$src2, $dst|$dst, $src2}", []>, LOCK;
3926def LOCK_ADD16mi : Ii16<0x81, MRM0m, (outs), (ins i16mem:$dst, i16imm:$src2),
3927 "lock\n\t"
3928 "add{w}\t{$src2, $dst|$dst, $src2}", []>, LOCK;
3929def LOCK_ADD32mi : Ii32<0x81, MRM0m, (outs), (ins i32mem:$dst, i32imm:$src2),
3930 "lock\n\t"
3931 "add{l}\t{$src2, $dst|$dst, $src2}", []>, LOCK;
3932def LOCK_ADD16mi8 : Ii8<0x83, MRM0m, (outs), (ins i16mem:$dst, i16i8imm :$src2),
3933 "lock\n\t"
3934 "add{w}\t{$src2, $dst|$dst, $src2}", []>, OpSize, LOCK;
3935def LOCK_ADD32mi8 : Ii8<0x83, MRM0m, (outs), (ins i32mem:$dst, i32i8imm :$src2),
3936 "lock\n\t"
3937 "add{l}\t{$src2, $dst|$dst, $src2}", []>, LOCK;
3938
3939def LOCK_INC8m : I<0xFE, MRM0m, (outs), (ins i8mem :$dst),
3940 "lock\n\t"
3941 "inc{b}\t$dst", []>, LOCK;
3942def LOCK_INC16m : I<0xFF, MRM0m, (outs), (ins i16mem:$dst),
3943 "lock\n\t"
3944 "inc{w}\t$dst", []>, OpSize, LOCK;
3945def LOCK_INC32m : I<0xFF, MRM0m, (outs), (ins i32mem:$dst),
3946 "lock\n\t"
3947 "inc{l}\t$dst", []>, LOCK;
3948
3949def LOCK_SUB8mr : I<0x28, MRMDestMem, (outs), (ins i8mem :$dst, GR8 :$src2),
3950 "lock\n\t"
3951 "sub{b}\t{$src2, $dst|$dst, $src2}", []>, LOCK;
3952def LOCK_SUB16mr : I<0x29, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
3953 "lock\n\t"
3954 "sub{w}\t{$src2, $dst|$dst, $src2}", []>, OpSize, LOCK;
3955def LOCK_SUB32mr : I<0x29, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
3956 "lock\n\t"
3957 "sub{l}\t{$src2, $dst|$dst, $src2}", []>, LOCK;
3958def LOCK_SUB8mi : Ii8<0x80, MRM5m, (outs), (ins i8mem :$dst, i8imm:$src2),
3959 "lock\n\t"
3960 "sub{b}\t{$src2, $dst|$dst, $src2}", []>, LOCK;
3961def LOCK_SUB16mi : Ii16<0x81, MRM5m, (outs), (ins i16mem:$dst, i16imm:$src2),
3962 "lock\n\t"
3963 "sub{w}\t{$src2, $dst|$dst, $src2}", []>, OpSize, LOCK;
3964def LOCK_SUB32mi : Ii32<0x81, MRM5m, (outs), (ins i32mem:$dst, i32imm:$src2),
3965 "lock\n\t"
3966 "sub{l}\t{$src2, $dst|$dst, $src2}", []>, LOCK;
Sean Callanan2c48df22009-12-18 00:01:26 +00003967def LOCK_SUB16mi8 : Ii8<0x83, MRM5m, (outs), (ins i16mem:$dst, i16i8imm :$src2),
Evan Chengb723fb52009-07-30 08:33:02 +00003968 "lock\n\t"
3969 "sub{w}\t{$src2, $dst|$dst, $src2}", []>, OpSize, LOCK;
3970def LOCK_SUB32mi8 : Ii8<0x83, MRM5m, (outs), (ins i32mem:$dst, i32i8imm :$src2),
3971 "lock\n\t"
3972 "sub{l}\t{$src2, $dst|$dst, $src2}", []>, LOCK;
3973
3974def LOCK_DEC8m : I<0xFE, MRM1m, (outs), (ins i8mem :$dst),
3975 "lock\n\t"
3976 "dec{b}\t$dst", []>, LOCK;
3977def LOCK_DEC16m : I<0xFF, MRM1m, (outs), (ins i16mem:$dst),
3978 "lock\n\t"
3979 "dec{w}\t$dst", []>, OpSize, LOCK;
3980def LOCK_DEC32m : I<0xFF, MRM1m, (outs), (ins i32mem:$dst),
3981 "lock\n\t"
3982 "dec{l}\t$dst", []>, LOCK;
Dan Gohman1c286992009-10-20 18:14:49 +00003983}
Evan Chengb723fb52009-07-30 08:33:02 +00003984
Mon P Wang6bde9ec2008-06-25 08:15:39 +00003985// Atomic exchange, and, or, xor
Mon P Wang078a62d2008-05-05 19:05:59 +00003986let Constraints = "$val = $dst", Defs = [EFLAGS],
Dan Gohman30afe012009-10-29 18:10:34 +00003987 usesCustomInserter = 1 in {
Dan Gohman8aeb61f2008-05-12 20:22:45 +00003988def ATOMAND32 : I<0, Pseudo, (outs GR32:$dst),(ins i32mem:$ptr, GR32:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003989 "#ATOMAND32 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003990 [(set GR32:$dst, (atomic_load_and_32 addr:$ptr, GR32:$val))]>;
Dan Gohman8aeb61f2008-05-12 20:22:45 +00003991def ATOMOR32 : I<0, Pseudo, (outs GR32:$dst),(ins i32mem:$ptr, GR32:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003992 "#ATOMOR32 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003993 [(set GR32:$dst, (atomic_load_or_32 addr:$ptr, GR32:$val))]>;
Dan Gohman8aeb61f2008-05-12 20:22:45 +00003994def ATOMXOR32 : I<0, Pseudo,(outs GR32:$dst),(ins i32mem:$ptr, GR32:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003995 "#ATOMXOR32 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003996 [(set GR32:$dst, (atomic_load_xor_32 addr:$ptr, GR32:$val))]>;
Andrew Lenharthaf02d592008-06-14 05:48:15 +00003997def ATOMNAND32 : I<0, Pseudo,(outs GR32:$dst),(ins i32mem:$ptr, GR32:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003998 "#ATOMNAND32 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003999 [(set GR32:$dst, (atomic_load_nand_32 addr:$ptr, GR32:$val))]>;
Dan Gohman8aeb61f2008-05-12 20:22:45 +00004000def ATOMMIN32: I<0, Pseudo, (outs GR32:$dst), (ins i32mem:$ptr, GR32:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00004001 "#ATOMMIN32 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00004002 [(set GR32:$dst, (atomic_load_min_32 addr:$ptr, GR32:$val))]>;
Dan Gohman8aeb61f2008-05-12 20:22:45 +00004003def ATOMMAX32: I<0, Pseudo, (outs GR32:$dst),(ins i32mem:$ptr, GR32:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00004004 "#ATOMMAX32 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00004005 [(set GR32:$dst, (atomic_load_max_32 addr:$ptr, GR32:$val))]>;
Dan Gohman8aeb61f2008-05-12 20:22:45 +00004006def ATOMUMIN32: I<0, Pseudo, (outs GR32:$dst),(ins i32mem:$ptr, GR32:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00004007 "#ATOMUMIN32 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00004008 [(set GR32:$dst, (atomic_load_umin_32 addr:$ptr, GR32:$val))]>;
Dan Gohman8aeb61f2008-05-12 20:22:45 +00004009def ATOMUMAX32: I<0, Pseudo, (outs GR32:$dst),(ins i32mem:$ptr, GR32:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00004010 "#ATOMUMAX32 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00004011 [(set GR32:$dst, (atomic_load_umax_32 addr:$ptr, GR32:$val))]>;
Dale Johannesend20e4452008-08-19 18:47:28 +00004012
4013def ATOMAND16 : I<0, Pseudo, (outs GR16:$dst),(ins i16mem:$ptr, GR16:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00004014 "#ATOMAND16 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00004015 [(set GR16:$dst, (atomic_load_and_16 addr:$ptr, GR16:$val))]>;
Dale Johannesend20e4452008-08-19 18:47:28 +00004016def ATOMOR16 : I<0, Pseudo, (outs GR16:$dst),(ins i16mem:$ptr, GR16:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00004017 "#ATOMOR16 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00004018 [(set GR16:$dst, (atomic_load_or_16 addr:$ptr, GR16:$val))]>;
Dale Johannesend20e4452008-08-19 18:47:28 +00004019def ATOMXOR16 : I<0, Pseudo,(outs GR16:$dst),(ins i16mem:$ptr, GR16:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00004020 "#ATOMXOR16 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00004021 [(set GR16:$dst, (atomic_load_xor_16 addr:$ptr, GR16:$val))]>;
Dale Johannesend20e4452008-08-19 18:47:28 +00004022def ATOMNAND16 : I<0, Pseudo,(outs GR16:$dst),(ins i16mem:$ptr, GR16:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00004023 "#ATOMNAND16 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00004024 [(set GR16:$dst, (atomic_load_nand_16 addr:$ptr, GR16:$val))]>;
Dale Johannesend20e4452008-08-19 18:47:28 +00004025def ATOMMIN16: I<0, Pseudo, (outs GR16:$dst), (ins i16mem:$ptr, GR16:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00004026 "#ATOMMIN16 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00004027 [(set GR16:$dst, (atomic_load_min_16 addr:$ptr, GR16:$val))]>;
Dale Johannesend20e4452008-08-19 18:47:28 +00004028def ATOMMAX16: I<0, Pseudo, (outs GR16:$dst),(ins i16mem:$ptr, GR16:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00004029 "#ATOMMAX16 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00004030 [(set GR16:$dst, (atomic_load_max_16 addr:$ptr, GR16:$val))]>;
Dale Johannesend20e4452008-08-19 18:47:28 +00004031def ATOMUMIN16: I<0, Pseudo, (outs GR16:$dst),(ins i16mem:$ptr, GR16:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00004032 "#ATOMUMIN16 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00004033 [(set GR16:$dst, (atomic_load_umin_16 addr:$ptr, GR16:$val))]>;
Dale Johannesend20e4452008-08-19 18:47:28 +00004034def ATOMUMAX16: I<0, Pseudo, (outs GR16:$dst),(ins i16mem:$ptr, GR16:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00004035 "#ATOMUMAX16 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00004036 [(set GR16:$dst, (atomic_load_umax_16 addr:$ptr, GR16:$val))]>;
Dale Johannesend20e4452008-08-19 18:47:28 +00004037
4038def ATOMAND8 : I<0, Pseudo, (outs GR8:$dst),(ins i8mem:$ptr, GR8:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00004039 "#ATOMAND8 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00004040 [(set GR8:$dst, (atomic_load_and_8 addr:$ptr, GR8:$val))]>;
Dale Johannesend20e4452008-08-19 18:47:28 +00004041def ATOMOR8 : I<0, Pseudo, (outs GR8:$dst),(ins i8mem:$ptr, GR8:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00004042 "#ATOMOR8 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00004043 [(set GR8:$dst, (atomic_load_or_8 addr:$ptr, GR8:$val))]>;
Dale Johannesend20e4452008-08-19 18:47:28 +00004044def ATOMXOR8 : I<0, Pseudo,(outs GR8:$dst),(ins i8mem:$ptr, GR8:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00004045 "#ATOMXOR8 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00004046 [(set GR8:$dst, (atomic_load_xor_8 addr:$ptr, GR8:$val))]>;
Dale Johannesend20e4452008-08-19 18:47:28 +00004047def ATOMNAND8 : I<0, Pseudo,(outs GR8:$dst),(ins i8mem:$ptr, GR8:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00004048 "#ATOMNAND8 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00004049 [(set GR8:$dst, (atomic_load_nand_8 addr:$ptr, GR8:$val))]>;
Mon P Wang078a62d2008-05-05 19:05:59 +00004050}
4051
Dale Johannesenf160d802008-10-02 18:53:47 +00004052let Constraints = "$val1 = $dst1, $val2 = $dst2",
4053 Defs = [EFLAGS, EAX, EBX, ECX, EDX],
4054 Uses = [EAX, EBX, ECX, EDX],
Dale Johannesen44eb5372008-10-03 19:41:08 +00004055 mayLoad = 1, mayStore = 1,
Dan Gohman30afe012009-10-29 18:10:34 +00004056 usesCustomInserter = 1 in {
Dale Johannesenf160d802008-10-02 18:53:47 +00004057def ATOMAND6432 : I<0, Pseudo, (outs GR32:$dst1, GR32:$dst2),
4058 (ins i64mem:$ptr, GR32:$val1, GR32:$val2),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00004059 "#ATOMAND6432 PSEUDO!", []>;
Dale Johannesenf160d802008-10-02 18:53:47 +00004060def ATOMOR6432 : I<0, Pseudo, (outs GR32:$dst1, GR32:$dst2),
4061 (ins i64mem:$ptr, GR32:$val1, GR32:$val2),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00004062 "#ATOMOR6432 PSEUDO!", []>;
Dale Johannesenf160d802008-10-02 18:53:47 +00004063def ATOMXOR6432 : I<0, Pseudo, (outs GR32:$dst1, GR32:$dst2),
4064 (ins i64mem:$ptr, GR32:$val1, GR32:$val2),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00004065 "#ATOMXOR6432 PSEUDO!", []>;
Dale Johannesenf160d802008-10-02 18:53:47 +00004066def ATOMNAND6432 : I<0, Pseudo, (outs GR32:$dst1, GR32:$dst2),
4067 (ins i64mem:$ptr, GR32:$val1, GR32:$val2),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00004068 "#ATOMNAND6432 PSEUDO!", []>;
Dale Johannesenf160d802008-10-02 18:53:47 +00004069def ATOMADD6432 : I<0, Pseudo, (outs GR32:$dst1, GR32:$dst2),
4070 (ins i64mem:$ptr, GR32:$val1, GR32:$val2),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00004071 "#ATOMADD6432 PSEUDO!", []>;
Dale Johannesenf160d802008-10-02 18:53:47 +00004072def ATOMSUB6432 : I<0, Pseudo, (outs GR32:$dst1, GR32:$dst2),
4073 (ins i64mem:$ptr, GR32:$val1, GR32:$val2),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00004074 "#ATOMSUB6432 PSEUDO!", []>;
Dale Johannesen51c58ee2008-10-03 22:25:52 +00004075def ATOMSWAP6432 : I<0, Pseudo, (outs GR32:$dst1, GR32:$dst2),
4076 (ins i64mem:$ptr, GR32:$val1, GR32:$val2),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00004077 "#ATOMSWAP6432 PSEUDO!", []>;
Dale Johannesenf160d802008-10-02 18:53:47 +00004078}
4079
Sean Callanan2eddf5d2009-09-16 21:55:34 +00004080// Segmentation support instructions.
4081
4082def LAR16rm : I<0x02, MRMSrcMem, (outs GR16:$dst), (ins i16mem:$src),
4083 "lar{w}\t{$src, $dst|$dst, $src}", []>, TB, OpSize;
4084def LAR16rr : I<0x02, MRMSrcReg, (outs GR16:$dst), (ins GR16:$src),
4085 "lar{w}\t{$src, $dst|$dst, $src}", []>, TB, OpSize;
4086
4087// i16mem operand in LAR32rm and GR32 operand in LAR32rr is not a typo.
4088def LAR32rm : I<0x02, MRMSrcMem, (outs GR32:$dst), (ins i16mem:$src),
4089 "lar{l}\t{$src, $dst|$dst, $src}", []>, TB;
4090def LAR32rr : I<0x02, MRMSrcReg, (outs GR32:$dst), (ins GR32:$src),
4091 "lar{l}\t{$src, $dst|$dst, $src}", []>, TB;
Sean Callanan2c48df22009-12-18 00:01:26 +00004092
4093def LSL16rm : I<0x03, MRMSrcMem, (outs GR16:$dst), (ins i16mem:$src),
4094 "lsl{w}\t{$src, $dst|$dst, $src}", []>, TB, OpSize;
4095def LSL16rr : I<0x03, MRMSrcReg, (outs GR16:$dst), (ins GR16:$src),
4096 "lsl{w}\t{$src, $dst|$dst, $src}", []>, TB, OpSize;
4097def LSL32rm : I<0x03, MRMSrcMem, (outs GR32:$dst), (ins i32mem:$src),
4098 "lsl{l}\t{$src, $dst|$dst, $src}", []>, TB;
4099def LSL32rr : I<0x03, MRMSrcReg, (outs GR32:$dst), (ins GR32:$src),
4100 "lsl{l}\t{$src, $dst|$dst, $src}", []>, TB;
4101
4102def INVLPG : I<0x01, RawFrm, (outs), (ins), "invlpg", []>, TB;
4103
4104def STRr : I<0x00, MRM1r, (outs GR16:$dst), (ins),
4105 "str{w}\t{$dst}", []>, TB;
4106def STRm : I<0x00, MRM1m, (outs i16mem:$dst), (ins),
4107 "str{w}\t{$dst}", []>, TB;
4108def LTRr : I<0x00, MRM3r, (outs), (ins GR16:$src),
4109 "ltr{w}\t{$src}", []>, TB;
4110def LTRm : I<0x00, MRM3m, (outs), (ins i16mem:$src),
4111 "ltr{w}\t{$src}", []>, TB;
4112
4113def PUSHFS16 : I<0xa0, RawFrm, (outs), (ins),
4114 "push{w}\t%fs", []>, OpSize, TB;
4115def PUSHFS32 : I<0xa0, RawFrm, (outs), (ins),
4116 "push{l}\t%fs", []>, TB;
4117def PUSHGS16 : I<0xa8, RawFrm, (outs), (ins),
4118 "push{w}\t%gs", []>, OpSize, TB;
4119def PUSHGS32 : I<0xa8, RawFrm, (outs), (ins),
4120 "push{l}\t%gs", []>, TB;
4121
4122def POPFS16 : I<0xa1, RawFrm, (outs), (ins),
4123 "pop{w}\t%fs", []>, OpSize, TB;
4124def POPFS32 : I<0xa1, RawFrm, (outs), (ins),
4125 "pop{l}\t%fs", []>, TB;
4126def POPGS16 : I<0xa9, RawFrm, (outs), (ins),
4127 "pop{w}\t%gs", []>, OpSize, TB;
4128def POPGS32 : I<0xa9, RawFrm, (outs), (ins),
4129 "pop{l}\t%gs", []>, TB;
4130
4131def LDS16rm : I<0xc5, MRMSrcMem, (outs GR16:$dst), (ins opaque32mem:$src),
4132 "lds{w}\t{$src, $dst|$dst, $src}", []>, OpSize;
4133def LDS32rm : I<0xc5, MRMSrcMem, (outs GR32:$dst), (ins opaque48mem:$src),
4134 "lds{l}\t{$src, $dst|$dst, $src}", []>;
4135def LSS16rm : I<0xb2, MRMSrcMem, (outs GR16:$dst), (ins opaque32mem:$src),
4136 "lss{w}\t{$src, $dst|$dst, $src}", []>, TB, OpSize;
4137def LSS32rm : I<0xb2, MRMSrcMem, (outs GR32:$dst), (ins opaque48mem:$src),
4138 "lss{l}\t{$src, $dst|$dst, $src}", []>, TB;
4139def LES16rm : I<0xc4, MRMSrcMem, (outs GR16:$dst), (ins opaque32mem:$src),
4140 "les{w}\t{$src, $dst|$dst, $src}", []>, OpSize;
4141def LES32rm : I<0xc4, MRMSrcMem, (outs GR32:$dst), (ins opaque48mem:$src),
4142 "les{l}\t{$src, $dst|$dst, $src}", []>;
4143def LFS16rm : I<0xb4, MRMSrcMem, (outs GR16:$dst), (ins opaque32mem:$src),
4144 "lfs{w}\t{$src, $dst|$dst, $src}", []>, TB, OpSize;
4145def LFS32rm : I<0xb4, MRMSrcMem, (outs GR32:$dst), (ins opaque48mem:$src),
4146 "lfs{l}\t{$src, $dst|$dst, $src}", []>, TB;
4147def LGS16rm : I<0xb5, MRMSrcMem, (outs GR16:$dst), (ins opaque32mem:$src),
4148 "lgs{w}\t{$src, $dst|$dst, $src}", []>, TB, OpSize;
4149def LGS32rm : I<0xb5, MRMSrcMem, (outs GR32:$dst), (ins opaque48mem:$src),
4150 "lgs{l}\t{$src, $dst|$dst, $src}", []>, TB;
4151
4152def VERRr : I<0x00, MRM4r, (outs), (ins GR16:$seg),
4153 "verr\t$seg", []>, TB;
4154def VERRm : I<0x00, MRM4m, (outs), (ins i16mem:$seg),
4155 "verr\t$seg", []>, TB;
4156def VERWr : I<0x00, MRM5r, (outs), (ins GR16:$seg),
4157 "verw\t$seg", []>, TB;
4158def VERWm : I<0x00, MRM5m, (outs), (ins i16mem:$seg),
4159 "verw\t$seg", []>, TB;
4160
4161// Descriptor-table support instructions
4162
4163def SGDTm : I<0x01, MRM0m, (outs opaque48mem:$dst), (ins),
4164 "sgdt\t$dst", []>, TB;
4165def SIDTm : I<0x01, MRM1m, (outs opaque48mem:$dst), (ins),
4166 "sidt\t$dst", []>, TB;
4167def SLDT16r : I<0x00, MRM0r, (outs GR16:$dst), (ins),
4168 "sldt{w}\t$dst", []>, TB;
4169def SLDT16m : I<0x00, MRM0m, (outs i16mem:$dst), (ins),
4170 "sldt{w}\t$dst", []>, TB;
4171def LGDTm : I<0x01, MRM2m, (outs), (ins opaque48mem:$src),
4172 "lgdt\t$src", []>, TB;
4173def LIDTm : I<0x01, MRM3m, (outs), (ins opaque48mem:$src),
4174 "lidt\t$src", []>, TB;
4175def LLDT16r : I<0x00, MRM2r, (outs), (ins GR16:$src),
4176 "lldt{w}\t$src", []>, TB;
4177def LLDT16m : I<0x00, MRM2m, (outs), (ins i16mem:$src),
4178 "lldt{w}\t$src", []>, TB;
Sean Callanan23f33d72009-09-16 22:59:28 +00004179
Kevin Enderby3aa67c02010-02-03 21:04:42 +00004180// Lock instruction prefix
4181def LOCK_PREFIX : I<0xF0, RawFrm, (outs), (ins), "lock", []>;
4182
4183// Repeat string operation instruction prefixes
4184// These uses the DF flag in the EFLAGS register to inc or dec ECX
4185let Defs = [ECX], Uses = [ECX,EFLAGS] in {
4186// Repeat (used with INS, OUTS, MOVS, LODS and STOS)
4187def REP_PREFIX : I<0xF3, RawFrm, (outs), (ins), "rep", []>;
4188// Repeat while not equal (used with CMPS and SCAS)
4189def REPNE_PREFIX : I<0xF2, RawFrm, (outs), (ins), "repne", []>;
4190}
4191
4192// Segment override instruction prefixes
4193def CS_PREFIX : I<0x2E, RawFrm, (outs), (ins), "cs", []>;
4194def SS_PREFIX : I<0x36, RawFrm, (outs), (ins), "ss", []>;
4195def DS_PREFIX : I<0x3E, RawFrm, (outs), (ins), "ds", []>;
4196def ES_PREFIX : I<0x26, RawFrm, (outs), (ins), "es", []>;
4197def FS_PREFIX : I<0x64, RawFrm, (outs), (ins), "fs", []>;
4198def GS_PREFIX : I<0x65, RawFrm, (outs), (ins), "gs", []>;
4199
Sean Callanan23f33d72009-09-16 22:59:28 +00004200// String manipulation instructions
4201
4202def LODSB : I<0xAC, RawFrm, (outs), (ins), "lodsb", []>;
4203def LODSW : I<0xAD, RawFrm, (outs), (ins), "lodsw", []>, OpSize;
Sean Callanan2c48df22009-12-18 00:01:26 +00004204def LODSD : I<0xAD, RawFrm, (outs), (ins), "lods{l|d}", []>;
4205
4206def OUTSB : I<0x6E, RawFrm, (outs), (ins), "outsb", []>;
4207def OUTSW : I<0x6F, RawFrm, (outs), (ins), "outsw", []>, OpSize;
4208def OUTSD : I<0x6F, RawFrm, (outs), (ins), "outs{l|d}", []>;
4209
4210// CPU flow control instructions
4211
4212def HLT : I<0xF4, RawFrm, (outs), (ins), "hlt", []>;
4213def RSM : I<0xAA, RawFrm, (outs), (ins), "rsm", []>, TB;
4214
4215// FPU control instructions
4216
4217def FNINIT : I<0xE3, RawFrm, (outs), (ins), "fninit", []>, DB;
4218
4219// Flag instructions
4220
4221def CLC : I<0xF8, RawFrm, (outs), (ins), "clc", []>;
4222def STC : I<0xF9, RawFrm, (outs), (ins), "stc", []>;
4223def CLI : I<0xFA, RawFrm, (outs), (ins), "cli", []>;
4224def STI : I<0xFB, RawFrm, (outs), (ins), "sti", []>;
4225def CLD : I<0xFC, RawFrm, (outs), (ins), "cld", []>;
4226def STD : I<0xFD, RawFrm, (outs), (ins), "std", []>;
4227def CMC : I<0xF5, RawFrm, (outs), (ins), "cmc", []>;
4228
4229def CLTS : I<0x06, RawFrm, (outs), (ins), "clts", []>, TB;
4230
4231// Table lookup instructions
4232
4233def XLAT : I<0xD7, RawFrm, (outs), (ins), "xlatb", []>;
4234
4235// Specialized register support
4236
4237def WRMSR : I<0x30, RawFrm, (outs), (ins), "wrmsr", []>, TB;
4238def RDMSR : I<0x32, RawFrm, (outs), (ins), "rdmsr", []>, TB;
4239def RDPMC : I<0x33, RawFrm, (outs), (ins), "rdpmc", []>, TB;
4240
4241def SMSW16r : I<0x01, MRM4r, (outs GR16:$dst), (ins),
4242 "smsw{w}\t$dst", []>, OpSize, TB;
4243def SMSW32r : I<0x01, MRM4r, (outs GR32:$dst), (ins),
4244 "smsw{l}\t$dst", []>, TB;
4245// For memory operands, there is only a 16-bit form
4246def SMSW16m : I<0x01, MRM4m, (outs i16mem:$dst), (ins),
4247 "smsw{w}\t$dst", []>, TB;
4248
4249def LMSW16r : I<0x01, MRM6r, (outs), (ins GR16:$src),
4250 "lmsw{w}\t$src", []>, TB;
4251def LMSW16m : I<0x01, MRM6m, (outs), (ins i16mem:$src),
4252 "lmsw{w}\t$src", []>, TB;
4253
4254def CPUID : I<0xA2, RawFrm, (outs), (ins), "cpuid", []>, TB;
4255
4256// Cache instructions
4257
4258def INVD : I<0x08, RawFrm, (outs), (ins), "invd", []>, TB;
4259def WBINVD : I<0x09, RawFrm, (outs), (ins), "wbinvd", []>, TB;
4260
4261// VMX instructions
4262
4263// 66 0F 38 80
4264def INVEPT : I<0x38, RawFrm, (outs), (ins), "invept", []>, OpSize, TB;
4265// 66 0F 38 81
4266def INVVPID : I<0x38, RawFrm, (outs), (ins), "invvpid", []>, OpSize, TB;
4267// 0F 01 C1
4268def VMCALL : I<0x01, RawFrm, (outs), (ins), "vmcall", []>, TB;
4269def VMCLEARm : I<0xC7, MRM6m, (outs), (ins i64mem:$vmcs),
4270 "vmclear\t$vmcs", []>, OpSize, TB;
4271// 0F 01 C2
4272def VMLAUNCH : I<0x01, RawFrm, (outs), (ins), "vmlaunch", []>, TB;
4273// 0F 01 C3
4274def VMRESUME : I<0x01, RawFrm, (outs), (ins), "vmresume", []>, TB;
4275def VMPTRLDm : I<0xC7, MRM6m, (outs), (ins i64mem:$vmcs),
4276 "vmptrld\t$vmcs", []>, TB;
4277def VMPTRSTm : I<0xC7, MRM7m, (outs i64mem:$vmcs), (ins),
4278 "vmptrst\t$vmcs", []>, TB;
4279def VMREAD64rm : I<0x78, MRMDestMem, (outs i64mem:$dst), (ins GR64:$src),
4280 "vmread{q}\t{$src, $dst|$dst, $src}", []>, TB;
4281def VMREAD64rr : I<0x78, MRMDestReg, (outs GR64:$dst), (ins GR64:$src),
4282 "vmread{q}\t{$src, $dst|$dst, $src}", []>, TB;
4283def VMREAD32rm : I<0x78, MRMDestMem, (outs i32mem:$dst), (ins GR32:$src),
4284 "vmread{l}\t{$src, $dst|$dst, $src}", []>, TB;
4285def VMREAD32rr : I<0x78, MRMDestReg, (outs GR32:$dst), (ins GR32:$src),
4286 "vmread{l}\t{$src, $dst|$dst, $src}", []>, TB;
4287def VMWRITE64rm : I<0x79, MRMSrcMem, (outs GR64:$dst), (ins i64mem:$src),
4288 "vmwrite{q}\t{$src, $dst|$dst, $src}", []>, TB;
4289def VMWRITE64rr : I<0x79, MRMSrcReg, (outs GR64:$dst), (ins GR64:$src),
4290 "vmwrite{q}\t{$src, $dst|$dst, $src}", []>, TB;
4291def VMWRITE32rm : I<0x79, MRMSrcMem, (outs GR32:$dst), (ins i32mem:$src),
4292 "vmwrite{l}\t{$src, $dst|$dst, $src}", []>, TB;
4293def VMWRITE32rr : I<0x79, MRMSrcReg, (outs GR32:$dst), (ins GR32:$src),
4294 "vmwrite{l}\t{$src, $dst|$dst, $src}", []>, TB;
4295// 0F 01 C4
4296def VMXOFF : I<0x01, RawFrm, (outs), (ins), "vmxoff", []>, OpSize;
4297def VMXON : I<0xC7, MRM6m, (outs), (ins i64mem:$vmxon),
4298 "vmxon\t{$vmxon}", []>, XD;
Sean Callanan2eddf5d2009-09-16 21:55:34 +00004299
Andrew Lenharthe44f3902008-02-21 06:45:13 +00004300//===----------------------------------------------------------------------===//
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004301// Non-Instruction Patterns
4302//===----------------------------------------------------------------------===//
4303
Bill Wendlingfef06052008-09-16 21:48:12 +00004304// ConstantPool GlobalAddress, ExternalSymbol, and JumpTable
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004305def : Pat<(i32 (X86Wrapper tconstpool :$dst)), (MOV32ri tconstpool :$dst)>;
4306def : Pat<(i32 (X86Wrapper tjumptable :$dst)), (MOV32ri tjumptable :$dst)>;
Nate Begemanb52948972008-04-12 00:47:57 +00004307def : Pat<(i32 (X86Wrapper tglobaltlsaddr:$dst)),(MOV32ri tglobaltlsaddr:$dst)>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004308def : Pat<(i32 (X86Wrapper tglobaladdr :$dst)), (MOV32ri tglobaladdr :$dst)>;
4309def : Pat<(i32 (X86Wrapper texternalsym:$dst)), (MOV32ri texternalsym:$dst)>;
Dan Gohman064403e2009-10-30 01:28:02 +00004310def : Pat<(i32 (X86Wrapper tblockaddress:$dst)), (MOV32ri tblockaddress:$dst)>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004311
4312def : Pat<(add GR32:$src1, (X86Wrapper tconstpool:$src2)),
4313 (ADD32ri GR32:$src1, tconstpool:$src2)>;
4314def : Pat<(add GR32:$src1, (X86Wrapper tjumptable:$src2)),
4315 (ADD32ri GR32:$src1, tjumptable:$src2)>;
4316def : Pat<(add GR32:$src1, (X86Wrapper tglobaladdr :$src2)),
4317 (ADD32ri GR32:$src1, tglobaladdr:$src2)>;
4318def : Pat<(add GR32:$src1, (X86Wrapper texternalsym:$src2)),
4319 (ADD32ri GR32:$src1, texternalsym:$src2)>;
Dan Gohman064403e2009-10-30 01:28:02 +00004320def : Pat<(add GR32:$src1, (X86Wrapper tblockaddress:$src2)),
4321 (ADD32ri GR32:$src1, tblockaddress:$src2)>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004322
4323def : Pat<(store (i32 (X86Wrapper tglobaladdr:$src)), addr:$dst),
4324 (MOV32mi addr:$dst, tglobaladdr:$src)>;
4325def : Pat<(store (i32 (X86Wrapper texternalsym:$src)), addr:$dst),
4326 (MOV32mi addr:$dst, texternalsym:$src)>;
Dan Gohman064403e2009-10-30 01:28:02 +00004327def : Pat<(store (i32 (X86Wrapper tblockaddress:$src)), addr:$dst),
4328 (MOV32mi addr:$dst, tblockaddress:$src)>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004329
4330// Calls
Arnold Schwaighofere2d6bbb2007-10-11 19:40:01 +00004331// tailcall stuff
Arnold Schwaighofere2d6bbb2007-10-11 19:40:01 +00004332def : Pat<(X86tcret GR32:$dst, imm:$off),
4333 (TCRETURNri GR32:$dst, imm:$off)>;
4334
4335def : Pat<(X86tcret (i32 tglobaladdr:$dst), imm:$off),
4336 (TCRETURNdi texternalsym:$dst, imm:$off)>;
4337
4338def : Pat<(X86tcret (i32 texternalsym:$dst), imm:$off),
4339 (TCRETURNdi texternalsym:$dst, imm:$off)>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004340
Dan Gohmance5dbff2009-08-02 16:10:01 +00004341// Normal calls, with various flavors of addresses.
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004342def : Pat<(X86call (i32 tglobaladdr:$dst)),
4343 (CALLpcrel32 tglobaladdr:$dst)>;
4344def : Pat<(X86call (i32 texternalsym:$dst)),
4345 (CALLpcrel32 texternalsym:$dst)>;
Evan Cheng6d35a4d2009-05-20 04:53:57 +00004346def : Pat<(X86call (i32 imm:$dst)),
4347 (CALLpcrel32 imm:$dst)>, Requires<[CallImmAddr]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004348
4349// X86 specific add which produces a flag.
4350def : Pat<(addc GR32:$src1, GR32:$src2),
4351 (ADD32rr GR32:$src1, GR32:$src2)>;
4352def : Pat<(addc GR32:$src1, (load addr:$src2)),
4353 (ADD32rm GR32:$src1, addr:$src2)>;
4354def : Pat<(addc GR32:$src1, imm:$src2),
4355 (ADD32ri GR32:$src1, imm:$src2)>;
4356def : Pat<(addc GR32:$src1, i32immSExt8:$src2),
4357 (ADD32ri8 GR32:$src1, i32immSExt8:$src2)>;
4358
4359def : Pat<(subc GR32:$src1, GR32:$src2),
4360 (SUB32rr GR32:$src1, GR32:$src2)>;
4361def : Pat<(subc GR32:$src1, (load addr:$src2)),
4362 (SUB32rm GR32:$src1, addr:$src2)>;
4363def : Pat<(subc GR32:$src1, imm:$src2),
4364 (SUB32ri GR32:$src1, imm:$src2)>;
4365def : Pat<(subc GR32:$src1, i32immSExt8:$src2),
4366 (SUB32ri8 GR32:$src1, i32immSExt8:$src2)>;
4367
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004368// Comparisons.
4369
4370// TEST R,R is smaller than CMP R,0
Evan Cheng621216e2007-09-29 00:00:36 +00004371def : Pat<(parallel (X86cmp GR8:$src1, 0), (implicit EFLAGS)),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004372 (TEST8rr GR8:$src1, GR8:$src1)>;
Evan Cheng621216e2007-09-29 00:00:36 +00004373def : Pat<(parallel (X86cmp GR16:$src1, 0), (implicit EFLAGS)),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004374 (TEST16rr GR16:$src1, GR16:$src1)>;
Evan Cheng621216e2007-09-29 00:00:36 +00004375def : Pat<(parallel (X86cmp GR32:$src1, 0), (implicit EFLAGS)),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004376 (TEST32rr GR32:$src1, GR32:$src1)>;
4377
Dan Gohman0a3c5222009-01-07 01:00:24 +00004378// Conditional moves with folded loads with operands swapped and conditions
4379// inverted.
4380def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_B, EFLAGS),
4381 (CMOVAE16rm GR16:$src2, addr:$src1)>;
4382def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_B, EFLAGS),
4383 (CMOVAE32rm GR32:$src2, addr:$src1)>;
4384def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_AE, EFLAGS),
4385 (CMOVB16rm GR16:$src2, addr:$src1)>;
4386def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_AE, EFLAGS),
4387 (CMOVB32rm GR32:$src2, addr:$src1)>;
4388def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_E, EFLAGS),
4389 (CMOVNE16rm GR16:$src2, addr:$src1)>;
4390def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_E, EFLAGS),
4391 (CMOVNE32rm GR32:$src2, addr:$src1)>;
4392def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_NE, EFLAGS),
4393 (CMOVE16rm GR16:$src2, addr:$src1)>;
4394def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_NE, EFLAGS),
4395 (CMOVE32rm GR32:$src2, addr:$src1)>;
4396def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_BE, EFLAGS),
4397 (CMOVA16rm GR16:$src2, addr:$src1)>;
4398def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_BE, EFLAGS),
4399 (CMOVA32rm GR32:$src2, addr:$src1)>;
4400def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_A, EFLAGS),
4401 (CMOVBE16rm GR16:$src2, addr:$src1)>;
4402def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_A, EFLAGS),
4403 (CMOVBE32rm GR32:$src2, addr:$src1)>;
4404def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_L, EFLAGS),
4405 (CMOVGE16rm GR16:$src2, addr:$src1)>;
4406def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_L, EFLAGS),
4407 (CMOVGE32rm GR32:$src2, addr:$src1)>;
4408def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_GE, EFLAGS),
4409 (CMOVL16rm GR16:$src2, addr:$src1)>;
4410def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_GE, EFLAGS),
4411 (CMOVL32rm GR32:$src2, addr:$src1)>;
4412def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_LE, EFLAGS),
4413 (CMOVG16rm GR16:$src2, addr:$src1)>;
4414def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_LE, EFLAGS),
4415 (CMOVG32rm GR32:$src2, addr:$src1)>;
4416def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_G, EFLAGS),
4417 (CMOVLE16rm GR16:$src2, addr:$src1)>;
4418def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_G, EFLAGS),
4419 (CMOVLE32rm GR32:$src2, addr:$src1)>;
4420def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_P, EFLAGS),
4421 (CMOVNP16rm GR16:$src2, addr:$src1)>;
4422def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_P, EFLAGS),
4423 (CMOVNP32rm GR32:$src2, addr:$src1)>;
4424def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_NP, EFLAGS),
4425 (CMOVP16rm GR16:$src2, addr:$src1)>;
4426def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_NP, EFLAGS),
4427 (CMOVP32rm GR32:$src2, addr:$src1)>;
4428def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_S, EFLAGS),
4429 (CMOVNS16rm GR16:$src2, addr:$src1)>;
4430def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_S, EFLAGS),
4431 (CMOVNS32rm GR32:$src2, addr:$src1)>;
4432def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_NS, EFLAGS),
4433 (CMOVS16rm GR16:$src2, addr:$src1)>;
4434def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_NS, EFLAGS),
4435 (CMOVS32rm GR32:$src2, addr:$src1)>;
4436def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_O, EFLAGS),
4437 (CMOVNO16rm GR16:$src2, addr:$src1)>;
4438def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_O, EFLAGS),
4439 (CMOVNO32rm GR32:$src2, addr:$src1)>;
4440def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_NO, EFLAGS),
4441 (CMOVO16rm GR16:$src2, addr:$src1)>;
4442def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_NO, EFLAGS),
4443 (CMOVO32rm GR32:$src2, addr:$src1)>;
4444
Duncan Sands082524c2008-01-23 20:39:46 +00004445// zextload bool -> zextload byte
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004446def : Pat<(zextloadi8i1 addr:$src), (MOV8rm addr:$src)>;
4447def : Pat<(zextloadi16i1 addr:$src), (MOVZX16rm8 addr:$src)>;
4448def : Pat<(zextloadi32i1 addr:$src), (MOVZX32rm8 addr:$src)>;
4449
4450// extload bool -> extload byte
4451def : Pat<(extloadi8i1 addr:$src), (MOV8rm addr:$src)>;
Dan Gohman9959b052009-08-26 14:59:13 +00004452def : Pat<(extloadi16i1 addr:$src), (MOVZX16rm8 addr:$src)>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004453def : Pat<(extloadi32i1 addr:$src), (MOVZX32rm8 addr:$src)>;
Dan Gohman9959b052009-08-26 14:59:13 +00004454def : Pat<(extloadi16i8 addr:$src), (MOVZX16rm8 addr:$src)>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004455def : Pat<(extloadi32i8 addr:$src), (MOVZX32rm8 addr:$src)>;
4456def : Pat<(extloadi32i16 addr:$src), (MOVZX32rm16 addr:$src)>;
4457
Dan Gohman9959b052009-08-26 14:59:13 +00004458// anyext. Define these to do an explicit zero-extend to
4459// avoid partial-register updates.
4460def : Pat<(i16 (anyext GR8 :$src)), (MOVZX16rr8 GR8 :$src)>;
4461def : Pat<(i32 (anyext GR8 :$src)), (MOVZX32rr8 GR8 :$src)>;
4462def : Pat<(i32 (anyext GR16:$src)), (MOVZX32rr16 GR16:$src)>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004463
Evan Chengf2abee72007-12-13 00:43:27 +00004464// (and (i32 load), 255) -> (zextload i8)
Evan Cheng1e5e5452008-09-29 17:26:18 +00004465def : Pat<(i32 (and (nvloadi32 addr:$src), (i32 255))),
4466 (MOVZX32rm8 addr:$src)>;
4467def : Pat<(i32 (and (nvloadi32 addr:$src), (i32 65535))),
4468 (MOVZX32rm16 addr:$src)>;
Evan Chengf2abee72007-12-13 00:43:27 +00004469
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004470//===----------------------------------------------------------------------===//
4471// Some peepholes
4472//===----------------------------------------------------------------------===//
4473
Dan Gohman5a5e6e92008-10-17 01:33:43 +00004474// Odd encoding trick: -128 fits into an 8-bit immediate field while
4475// +128 doesn't, so in this special case use a sub instead of an add.
4476def : Pat<(add GR16:$src1, 128),
4477 (SUB16ri8 GR16:$src1, -128)>;
4478def : Pat<(store (add (loadi16 addr:$dst), 128), addr:$dst),
4479 (SUB16mi8 addr:$dst, -128)>;
4480def : Pat<(add GR32:$src1, 128),
4481 (SUB32ri8 GR32:$src1, -128)>;
4482def : Pat<(store (add (loadi32 addr:$dst), 128), addr:$dst),
4483 (SUB32mi8 addr:$dst, -128)>;
4484
Dan Gohman9203ab42008-07-30 18:09:17 +00004485// r & (2^16-1) ==> movz
4486def : Pat<(and GR32:$src1, 0xffff),
Dan Gohman744d4622009-04-13 16:09:41 +00004487 (MOVZX32rr16 (EXTRACT_SUBREG GR32:$src1, x86_subreg_16bit))>;
Dan Gohman5beb1ff2008-08-06 18:27:21 +00004488// r & (2^8-1) ==> movz
4489def : Pat<(and GR32:$src1, 0xff),
Anton Korobeynikovd9331212009-11-02 00:11:39 +00004490 (MOVZX32rr8 (EXTRACT_SUBREG (i32 (COPY_TO_REGCLASS GR32:$src1,
4491 GR32_ABCD)),
Dan Gohman744d4622009-04-13 16:09:41 +00004492 x86_subreg_8bit))>,
Dan Gohman5beb1ff2008-08-06 18:27:21 +00004493 Requires<[In32BitMode]>;
4494// r & (2^8-1) ==> movz
4495def : Pat<(and GR16:$src1, 0xff),
Anton Korobeynikovd9331212009-11-02 00:11:39 +00004496 (MOVZX16rr8 (EXTRACT_SUBREG (i16 (COPY_TO_REGCLASS GR16:$src1,
4497 GR16_ABCD)),
Dan Gohman744d4622009-04-13 16:09:41 +00004498 x86_subreg_8bit))>,
Dan Gohmandd612bb2008-08-20 21:27:32 +00004499 Requires<[In32BitMode]>;
4500
4501// sext_inreg patterns
4502def : Pat<(sext_inreg GR32:$src, i16),
Dan Gohman744d4622009-04-13 16:09:41 +00004503 (MOVSX32rr16 (EXTRACT_SUBREG GR32:$src, x86_subreg_16bit))>;
Dan Gohmandd612bb2008-08-20 21:27:32 +00004504def : Pat<(sext_inreg GR32:$src, i8),
Anton Korobeynikovd9331212009-11-02 00:11:39 +00004505 (MOVSX32rr8 (EXTRACT_SUBREG (i32 (COPY_TO_REGCLASS GR32:$src,
4506 GR32_ABCD)),
Dan Gohman744d4622009-04-13 16:09:41 +00004507 x86_subreg_8bit))>,
Dan Gohmandd612bb2008-08-20 21:27:32 +00004508 Requires<[In32BitMode]>;
4509def : Pat<(sext_inreg GR16:$src, i8),
Anton Korobeynikovd9331212009-11-02 00:11:39 +00004510 (MOVSX16rr8 (EXTRACT_SUBREG (i16 (COPY_TO_REGCLASS GR16:$src,
4511 GR16_ABCD)),
Dan Gohman744d4622009-04-13 16:09:41 +00004512 x86_subreg_8bit))>,
Dan Gohmandd612bb2008-08-20 21:27:32 +00004513 Requires<[In32BitMode]>;
4514
4515// trunc patterns
4516def : Pat<(i16 (trunc GR32:$src)),
Dan Gohman744d4622009-04-13 16:09:41 +00004517 (EXTRACT_SUBREG GR32:$src, x86_subreg_16bit)>;
Dan Gohmandd612bb2008-08-20 21:27:32 +00004518def : Pat<(i8 (trunc GR32:$src)),
Anton Korobeynikovd9331212009-11-02 00:11:39 +00004519 (EXTRACT_SUBREG (i32 (COPY_TO_REGCLASS GR32:$src, GR32_ABCD)),
Dan Gohman744d4622009-04-13 16:09:41 +00004520 x86_subreg_8bit)>,
Dan Gohmandd612bb2008-08-20 21:27:32 +00004521 Requires<[In32BitMode]>;
4522def : Pat<(i8 (trunc GR16:$src)),
Anton Korobeynikovd9331212009-11-02 00:11:39 +00004523 (EXTRACT_SUBREG (i16 (COPY_TO_REGCLASS GR16:$src, GR16_ABCD)),
Dan Gohman744d4622009-04-13 16:09:41 +00004524 x86_subreg_8bit)>,
4525 Requires<[In32BitMode]>;
4526
4527// h-register tricks
4528def : Pat<(i8 (trunc (srl_su GR16:$src, (i8 8)))),
Anton Korobeynikovd9331212009-11-02 00:11:39 +00004529 (EXTRACT_SUBREG (i32 (COPY_TO_REGCLASS GR16:$src, GR16_ABCD)),
Dan Gohman744d4622009-04-13 16:09:41 +00004530 x86_subreg_8bit_hi)>,
4531 Requires<[In32BitMode]>;
4532def : Pat<(i8 (trunc (srl_su GR32:$src, (i8 8)))),
Anton Korobeynikovd9331212009-11-02 00:11:39 +00004533 (EXTRACT_SUBREG (i16 (COPY_TO_REGCLASS GR32:$src, GR32_ABCD)),
Dan Gohman744d4622009-04-13 16:09:41 +00004534 x86_subreg_8bit_hi)>,
4535 Requires<[In32BitMode]>;
Dan Gohman5d8f9df2010-01-11 17:21:05 +00004536def : Pat<(srl GR16:$src, (i8 8)),
Dan Gohman744d4622009-04-13 16:09:41 +00004537 (EXTRACT_SUBREG
4538 (MOVZX32rr8
Anton Korobeynikovd9331212009-11-02 00:11:39 +00004539 (EXTRACT_SUBREG (i16 (COPY_TO_REGCLASS GR16:$src, GR16_ABCD)),
Dan Gohman744d4622009-04-13 16:09:41 +00004540 x86_subreg_8bit_hi)),
4541 x86_subreg_16bit)>,
4542 Requires<[In32BitMode]>;
Evan Cheng957ca282009-05-29 01:44:43 +00004543def : Pat<(i32 (zext (srl_su GR16:$src, (i8 8)))),
Sean Callanan2c48df22009-12-18 00:01:26 +00004544 (MOVZX32rr8 (EXTRACT_SUBREG (i16 (COPY_TO_REGCLASS GR16:$src,
4545 GR16_ABCD)),
Evan Cheng957ca282009-05-29 01:44:43 +00004546 x86_subreg_8bit_hi))>,
4547 Requires<[In32BitMode]>;
Dan Gohman9959b052009-08-26 14:59:13 +00004548def : Pat<(i32 (anyext (srl_su GR16:$src, (i8 8)))),
Sean Callanan2c48df22009-12-18 00:01:26 +00004549 (MOVZX32rr8 (EXTRACT_SUBREG (i16 (COPY_TO_REGCLASS GR16:$src,
4550 GR16_ABCD)),
Dan Gohman9959b052009-08-26 14:59:13 +00004551 x86_subreg_8bit_hi))>,
4552 Requires<[In32BitMode]>;
Dan Gohman744d4622009-04-13 16:09:41 +00004553def : Pat<(and (srl_su GR32:$src, (i8 8)), (i32 255)),
Sean Callanan2c48df22009-12-18 00:01:26 +00004554 (MOVZX32rr8 (EXTRACT_SUBREG (i32 (COPY_TO_REGCLASS GR32:$src,
4555 GR32_ABCD)),
Dan Gohman744d4622009-04-13 16:09:41 +00004556 x86_subreg_8bit_hi))>,
Dan Gohman5beb1ff2008-08-06 18:27:21 +00004557 Requires<[In32BitMode]>;
Dan Gohman9203ab42008-07-30 18:09:17 +00004558
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004559// (shl x, 1) ==> (add x, x)
4560def : Pat<(shl GR8 :$src1, (i8 1)), (ADD8rr GR8 :$src1, GR8 :$src1)>;
4561def : Pat<(shl GR16:$src1, (i8 1)), (ADD16rr GR16:$src1, GR16:$src1)>;
4562def : Pat<(shl GR32:$src1, (i8 1)), (ADD32rr GR32:$src1, GR32:$src1)>;
4563
Evan Cheng76a64c72008-08-30 02:03:58 +00004564// (shl x (and y, 31)) ==> (shl x, y)
4565def : Pat<(shl GR8:$src1, (and CL:$amt, 31)),
4566 (SHL8rCL GR8:$src1)>;
4567def : Pat<(shl GR16:$src1, (and CL:$amt, 31)),
4568 (SHL16rCL GR16:$src1)>;
4569def : Pat<(shl GR32:$src1, (and CL:$amt, 31)),
4570 (SHL32rCL GR32:$src1)>;
4571def : Pat<(store (shl (loadi8 addr:$dst), (and CL:$amt, 31)), addr:$dst),
4572 (SHL8mCL addr:$dst)>;
4573def : Pat<(store (shl (loadi16 addr:$dst), (and CL:$amt, 31)), addr:$dst),
4574 (SHL16mCL addr:$dst)>;
4575def : Pat<(store (shl (loadi32 addr:$dst), (and CL:$amt, 31)), addr:$dst),
4576 (SHL32mCL addr:$dst)>;
4577
4578def : Pat<(srl GR8:$src1, (and CL:$amt, 31)),
4579 (SHR8rCL GR8:$src1)>;
4580def : Pat<(srl GR16:$src1, (and CL:$amt, 31)),
4581 (SHR16rCL GR16:$src1)>;
4582def : Pat<(srl GR32:$src1, (and CL:$amt, 31)),
4583 (SHR32rCL GR32:$src1)>;
4584def : Pat<(store (srl (loadi8 addr:$dst), (and CL:$amt, 31)), addr:$dst),
4585 (SHR8mCL addr:$dst)>;
4586def : Pat<(store (srl (loadi16 addr:$dst), (and CL:$amt, 31)), addr:$dst),
4587 (SHR16mCL addr:$dst)>;
4588def : Pat<(store (srl (loadi32 addr:$dst), (and CL:$amt, 31)), addr:$dst),
4589 (SHR32mCL addr:$dst)>;
4590
4591def : Pat<(sra GR8:$src1, (and CL:$amt, 31)),
4592 (SAR8rCL GR8:$src1)>;
4593def : Pat<(sra GR16:$src1, (and CL:$amt, 31)),
4594 (SAR16rCL GR16:$src1)>;
4595def : Pat<(sra GR32:$src1, (and CL:$amt, 31)),
4596 (SAR32rCL GR32:$src1)>;
4597def : Pat<(store (sra (loadi8 addr:$dst), (and CL:$amt, 31)), addr:$dst),
4598 (SAR8mCL addr:$dst)>;
4599def : Pat<(store (sra (loadi16 addr:$dst), (and CL:$amt, 31)), addr:$dst),
4600 (SAR16mCL addr:$dst)>;
4601def : Pat<(store (sra (loadi32 addr:$dst), (and CL:$amt, 31)), addr:$dst),
4602 (SAR32mCL addr:$dst)>;
4603
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004604// (or (x >> c) | (y << (32 - c))) ==> (shrd32 x, y, c)
4605def : Pat<(or (srl GR32:$src1, CL:$amt),
4606 (shl GR32:$src2, (sub 32, CL:$amt))),
4607 (SHRD32rrCL GR32:$src1, GR32:$src2)>;
4608
4609def : Pat<(store (or (srl (loadi32 addr:$dst), CL:$amt),
4610 (shl GR32:$src2, (sub 32, CL:$amt))), addr:$dst),
4611 (SHRD32mrCL addr:$dst, GR32:$src2)>;
4612
Dan Gohman921581d2008-10-17 01:23:35 +00004613def : Pat<(or (srl GR32:$src1, (i8 (trunc ECX:$amt))),
4614 (shl GR32:$src2, (i8 (trunc (sub 32, ECX:$amt))))),
4615 (SHRD32rrCL GR32:$src1, GR32:$src2)>;
4616
4617def : Pat<(store (or (srl (loadi32 addr:$dst), (i8 (trunc ECX:$amt))),
4618 (shl GR32:$src2, (i8 (trunc (sub 32, ECX:$amt))))),
4619 addr:$dst),
4620 (SHRD32mrCL addr:$dst, GR32:$src2)>;
4621
4622def : Pat<(shrd GR32:$src1, (i8 imm:$amt1), GR32:$src2, (i8 imm:$amt2)),
4623 (SHRD32rri8 GR32:$src1, GR32:$src2, (i8 imm:$amt1))>;
4624
4625def : Pat<(store (shrd (loadi32 addr:$dst), (i8 imm:$amt1),
4626 GR32:$src2, (i8 imm:$amt2)), addr:$dst),
4627 (SHRD32mri8 addr:$dst, GR32:$src2, (i8 imm:$amt1))>;
4628
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004629// (or (x << c) | (y >> (32 - c))) ==> (shld32 x, y, c)
4630def : Pat<(or (shl GR32:$src1, CL:$amt),
4631 (srl GR32:$src2, (sub 32, CL:$amt))),
4632 (SHLD32rrCL GR32:$src1, GR32:$src2)>;
4633
4634def : Pat<(store (or (shl (loadi32 addr:$dst), CL:$amt),
4635 (srl GR32:$src2, (sub 32, CL:$amt))), addr:$dst),
4636 (SHLD32mrCL addr:$dst, GR32:$src2)>;
4637
Dan Gohman921581d2008-10-17 01:23:35 +00004638def : Pat<(or (shl GR32:$src1, (i8 (trunc ECX:$amt))),
4639 (srl GR32:$src2, (i8 (trunc (sub 32, ECX:$amt))))),
4640 (SHLD32rrCL GR32:$src1, GR32:$src2)>;
4641
4642def : Pat<(store (or (shl (loadi32 addr:$dst), (i8 (trunc ECX:$amt))),
4643 (srl GR32:$src2, (i8 (trunc (sub 32, ECX:$amt))))),
4644 addr:$dst),
4645 (SHLD32mrCL addr:$dst, GR32:$src2)>;
4646
4647def : Pat<(shld GR32:$src1, (i8 imm:$amt1), GR32:$src2, (i8 imm:$amt2)),
4648 (SHLD32rri8 GR32:$src1, GR32:$src2, (i8 imm:$amt1))>;
4649
4650def : Pat<(store (shld (loadi32 addr:$dst), (i8 imm:$amt1),
4651 GR32:$src2, (i8 imm:$amt2)), addr:$dst),
4652 (SHLD32mri8 addr:$dst, GR32:$src2, (i8 imm:$amt1))>;
4653
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004654// (or (x >> c) | (y << (16 - c))) ==> (shrd16 x, y, c)
4655def : Pat<(or (srl GR16:$src1, CL:$amt),
4656 (shl GR16:$src2, (sub 16, CL:$amt))),
4657 (SHRD16rrCL GR16:$src1, GR16:$src2)>;
4658
4659def : Pat<(store (or (srl (loadi16 addr:$dst), CL:$amt),
4660 (shl GR16:$src2, (sub 16, CL:$amt))), addr:$dst),
4661 (SHRD16mrCL addr:$dst, GR16:$src2)>;
4662
Dan Gohman921581d2008-10-17 01:23:35 +00004663def : Pat<(or (srl GR16:$src1, (i8 (trunc CX:$amt))),
4664 (shl GR16:$src2, (i8 (trunc (sub 16, CX:$amt))))),
4665 (SHRD16rrCL GR16:$src1, GR16:$src2)>;
4666
4667def : Pat<(store (or (srl (loadi16 addr:$dst), (i8 (trunc CX:$amt))),
4668 (shl GR16:$src2, (i8 (trunc (sub 16, CX:$amt))))),
4669 addr:$dst),
4670 (SHRD16mrCL addr:$dst, GR16:$src2)>;
4671
4672def : Pat<(shrd GR16:$src1, (i8 imm:$amt1), GR16:$src2, (i8 imm:$amt2)),
4673 (SHRD16rri8 GR16:$src1, GR16:$src2, (i8 imm:$amt1))>;
4674
4675def : Pat<(store (shrd (loadi16 addr:$dst), (i8 imm:$amt1),
4676 GR16:$src2, (i8 imm:$amt2)), addr:$dst),
4677 (SHRD16mri8 addr:$dst, GR16:$src2, (i8 imm:$amt1))>;
4678
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004679// (or (x << c) | (y >> (16 - c))) ==> (shld16 x, y, c)
4680def : Pat<(or (shl GR16:$src1, CL:$amt),
4681 (srl GR16:$src2, (sub 16, CL:$amt))),
4682 (SHLD16rrCL GR16:$src1, GR16:$src2)>;
4683
4684def : Pat<(store (or (shl (loadi16 addr:$dst), CL:$amt),
4685 (srl GR16:$src2, (sub 16, CL:$amt))), addr:$dst),
4686 (SHLD16mrCL addr:$dst, GR16:$src2)>;
4687
Dan Gohman921581d2008-10-17 01:23:35 +00004688def : Pat<(or (shl GR16:$src1, (i8 (trunc CX:$amt))),
4689 (srl GR16:$src2, (i8 (trunc (sub 16, CX:$amt))))),
4690 (SHLD16rrCL GR16:$src1, GR16:$src2)>;
4691
4692def : Pat<(store (or (shl (loadi16 addr:$dst), (i8 (trunc CX:$amt))),
4693 (srl GR16:$src2, (i8 (trunc (sub 16, CX:$amt))))),
4694 addr:$dst),
4695 (SHLD16mrCL addr:$dst, GR16:$src2)>;
4696
4697def : Pat<(shld GR16:$src1, (i8 imm:$amt1), GR16:$src2, (i8 imm:$amt2)),
4698 (SHLD16rri8 GR16:$src1, GR16:$src2, (i8 imm:$amt1))>;
4699
4700def : Pat<(store (shld (loadi16 addr:$dst), (i8 imm:$amt1),
4701 GR16:$src2, (i8 imm:$amt2)), addr:$dst),
4702 (SHLD16mri8 addr:$dst, GR16:$src2, (i8 imm:$amt1))>;
4703
Evan Chengedeb1692009-12-16 00:53:11 +00004704// (anyext (setcc_carry)) -> (setcc_carry)
4705def : Pat<(i16 (anyext (i8 (X86setcc_c X86_COND_B, EFLAGS)))),
Evan Cheng834ae6b2009-12-15 00:53:42 +00004706 (SETB_C16r)>;
Evan Chengedeb1692009-12-16 00:53:11 +00004707def : Pat<(i32 (anyext (i8 (X86setcc_c X86_COND_B, EFLAGS)))),
Evan Cheng834ae6b2009-12-15 00:53:42 +00004708 (SETB_C32r)>;
4709
Evan Cheng503d9c52010-01-11 22:03:29 +00004710// (or x1, x2) -> (add x1, x2) if two operands are known not to share bits.
Evan Cheng44a441c2010-01-12 18:31:19 +00004711let AddedComplexity = 5 in { // Try this before the selecting to OR
Evan Cheng4621d272010-01-11 17:03:47 +00004712def : Pat<(parallel (or_is_add GR16:$src1, imm:$src2),
4713 (implicit EFLAGS)),
4714 (ADD16ri GR16:$src1, imm:$src2)>;
4715def : Pat<(parallel (or_is_add GR32:$src1, imm:$src2),
4716 (implicit EFLAGS)),
4717 (ADD32ri GR32:$src1, imm:$src2)>;
4718def : Pat<(parallel (or_is_add GR16:$src1, i16immSExt8:$src2),
4719 (implicit EFLAGS)),
4720 (ADD16ri8 GR16:$src1, i16immSExt8:$src2)>;
4721def : Pat<(parallel (or_is_add GR32:$src1, i32immSExt8:$src2),
4722 (implicit EFLAGS)),
4723 (ADD32ri8 GR32:$src1, i32immSExt8:$src2)>;
Evan Cheng503d9c52010-01-11 22:03:29 +00004724def : Pat<(parallel (or_is_add GR16:$src1, GR16:$src2),
4725 (implicit EFLAGS)),
4726 (ADD16rr GR16:$src1, GR16:$src2)>;
4727def : Pat<(parallel (or_is_add GR32:$src1, GR32:$src2),
4728 (implicit EFLAGS)),
4729 (ADD32rr GR32:$src1, GR32:$src2)>;
Evan Cheng44a441c2010-01-12 18:31:19 +00004730} // AddedComplexity
Evan Cheng4621d272010-01-11 17:03:47 +00004731
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004732//===----------------------------------------------------------------------===//
Dan Gohman99a12192009-03-04 19:44:21 +00004733// EFLAGS-defining Patterns
Bill Wendlingf5399032008-12-12 21:15:41 +00004734//===----------------------------------------------------------------------===//
4735
Dan Gohman99a12192009-03-04 19:44:21 +00004736// Register-Register Addition with EFLAGS result
4737def : Pat<(parallel (X86add_flag GR8:$src1, GR8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004738 (implicit EFLAGS)),
4739 (ADD8rr GR8:$src1, GR8:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00004740def : Pat<(parallel (X86add_flag GR16:$src1, GR16:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004741 (implicit EFLAGS)),
4742 (ADD16rr GR16:$src1, GR16:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00004743def : Pat<(parallel (X86add_flag GR32:$src1, GR32:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004744 (implicit EFLAGS)),
4745 (ADD32rr GR32:$src1, GR32:$src2)>;
4746
Dan Gohman99a12192009-03-04 19:44:21 +00004747// Register-Memory Addition with EFLAGS result
4748def : Pat<(parallel (X86add_flag GR8:$src1, (loadi8 addr:$src2)),
Bill Wendlingf5399032008-12-12 21:15:41 +00004749 (implicit EFLAGS)),
4750 (ADD8rm GR8:$src1, addr:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00004751def : Pat<(parallel (X86add_flag GR16:$src1, (loadi16 addr:$src2)),
Bill Wendlingf5399032008-12-12 21:15:41 +00004752 (implicit EFLAGS)),
4753 (ADD16rm GR16:$src1, addr:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00004754def : Pat<(parallel (X86add_flag GR32:$src1, (loadi32 addr:$src2)),
Bill Wendlingf5399032008-12-12 21:15:41 +00004755 (implicit EFLAGS)),
4756 (ADD32rm GR32:$src1, addr:$src2)>;
4757
Dan Gohman99a12192009-03-04 19:44:21 +00004758// Register-Integer Addition with EFLAGS result
4759def : Pat<(parallel (X86add_flag GR8:$src1, imm:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004760 (implicit EFLAGS)),
4761 (ADD8ri GR8:$src1, imm:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00004762def : Pat<(parallel (X86add_flag GR16:$src1, imm:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004763 (implicit EFLAGS)),
4764 (ADD16ri GR16:$src1, imm:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00004765def : Pat<(parallel (X86add_flag GR32:$src1, imm:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004766 (implicit EFLAGS)),
4767 (ADD32ri GR32:$src1, imm:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00004768def : Pat<(parallel (X86add_flag GR16:$src1, i16immSExt8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004769 (implicit EFLAGS)),
4770 (ADD16ri8 GR16:$src1, i16immSExt8:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00004771def : Pat<(parallel (X86add_flag GR32:$src1, i32immSExt8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004772 (implicit EFLAGS)),
4773 (ADD32ri8 GR32:$src1, i32immSExt8:$src2)>;
4774
Dan Gohman99a12192009-03-04 19:44:21 +00004775// Memory-Register Addition with EFLAGS result
4776def : Pat<(parallel (store (X86add_flag (loadi8 addr:$dst), GR8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004777 addr:$dst),
4778 (implicit EFLAGS)),
4779 (ADD8mr addr:$dst, GR8:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00004780def : Pat<(parallel (store (X86add_flag (loadi16 addr:$dst), GR16:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004781 addr:$dst),
4782 (implicit EFLAGS)),
4783 (ADD16mr addr:$dst, GR16:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00004784def : Pat<(parallel (store (X86add_flag (loadi32 addr:$dst), GR32:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004785 addr:$dst),
4786 (implicit EFLAGS)),
4787 (ADD32mr addr:$dst, GR32:$src2)>;
Dale Johannesen06b83f12009-05-18 17:44:15 +00004788
4789// Memory-Integer Addition with EFLAGS result
Dan Gohman99a12192009-03-04 19:44:21 +00004790def : Pat<(parallel (store (X86add_flag (loadi8 addr:$dst), imm:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004791 addr:$dst),
4792 (implicit EFLAGS)),
4793 (ADD8mi addr:$dst, imm:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00004794def : Pat<(parallel (store (X86add_flag (loadi16 addr:$dst), imm:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004795 addr:$dst),
4796 (implicit EFLAGS)),
4797 (ADD16mi addr:$dst, imm:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00004798def : Pat<(parallel (store (X86add_flag (loadi32 addr:$dst), imm:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004799 addr:$dst),
4800 (implicit EFLAGS)),
4801 (ADD32mi addr:$dst, imm:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00004802def : Pat<(parallel (store (X86add_flag (loadi16 addr:$dst), i16immSExt8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004803 addr:$dst),
4804 (implicit EFLAGS)),
4805 (ADD16mi8 addr:$dst, i16immSExt8:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00004806def : Pat<(parallel (store (X86add_flag (loadi32 addr:$dst), i32immSExt8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004807 addr:$dst),
4808 (implicit EFLAGS)),
4809 (ADD32mi8 addr:$dst, i32immSExt8:$src2)>;
4810
Dan Gohman99a12192009-03-04 19:44:21 +00004811// Register-Register Subtraction with EFLAGS result
4812def : Pat<(parallel (X86sub_flag GR8:$src1, GR8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004813 (implicit EFLAGS)),
4814 (SUB8rr GR8:$src1, GR8:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00004815def : Pat<(parallel (X86sub_flag GR16:$src1, GR16:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004816 (implicit EFLAGS)),
4817 (SUB16rr GR16:$src1, GR16:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00004818def : Pat<(parallel (X86sub_flag GR32:$src1, GR32:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004819 (implicit EFLAGS)),
4820 (SUB32rr GR32:$src1, GR32:$src2)>;
4821
Dan Gohman99a12192009-03-04 19:44:21 +00004822// Register-Memory Subtraction with EFLAGS result
4823def : Pat<(parallel (X86sub_flag GR8:$src1, (loadi8 addr:$src2)),
Bill Wendlingf5399032008-12-12 21:15:41 +00004824 (implicit EFLAGS)),
4825 (SUB8rm GR8:$src1, addr:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00004826def : Pat<(parallel (X86sub_flag GR16:$src1, (loadi16 addr:$src2)),
Bill Wendlingf5399032008-12-12 21:15:41 +00004827 (implicit EFLAGS)),
4828 (SUB16rm GR16:$src1, addr:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00004829def : Pat<(parallel (X86sub_flag GR32:$src1, (loadi32 addr:$src2)),
Bill Wendlingf5399032008-12-12 21:15:41 +00004830 (implicit EFLAGS)),
4831 (SUB32rm GR32:$src1, addr:$src2)>;
4832
Dan Gohman99a12192009-03-04 19:44:21 +00004833// Register-Integer Subtraction with EFLAGS result
4834def : Pat<(parallel (X86sub_flag GR8:$src1, imm:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004835 (implicit EFLAGS)),
4836 (SUB8ri GR8:$src1, imm:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00004837def : Pat<(parallel (X86sub_flag GR16:$src1, imm:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004838 (implicit EFLAGS)),
4839 (SUB16ri GR16:$src1, imm:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00004840def : Pat<(parallel (X86sub_flag GR32:$src1, imm:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004841 (implicit EFLAGS)),
4842 (SUB32ri GR32:$src1, imm:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00004843def : Pat<(parallel (X86sub_flag GR16:$src1, i16immSExt8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004844 (implicit EFLAGS)),
4845 (SUB16ri8 GR16:$src1, i16immSExt8:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00004846def : Pat<(parallel (X86sub_flag GR32:$src1, i32immSExt8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004847 (implicit EFLAGS)),
4848 (SUB32ri8 GR32:$src1, i32immSExt8:$src2)>;
4849
Dan Gohman99a12192009-03-04 19:44:21 +00004850// Memory-Register Subtraction with EFLAGS result
4851def : Pat<(parallel (store (X86sub_flag (loadi8 addr:$dst), GR8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004852 addr:$dst),
4853 (implicit EFLAGS)),
4854 (SUB8mr addr:$dst, GR8:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00004855def : Pat<(parallel (store (X86sub_flag (loadi16 addr:$dst), GR16:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004856 addr:$dst),
4857 (implicit EFLAGS)),
4858 (SUB16mr addr:$dst, GR16:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00004859def : Pat<(parallel (store (X86sub_flag (loadi32 addr:$dst), GR32:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004860 addr:$dst),
4861 (implicit EFLAGS)),
4862 (SUB32mr addr:$dst, GR32:$src2)>;
4863
Dan Gohman99a12192009-03-04 19:44:21 +00004864// Memory-Integer Subtraction with EFLAGS result
4865def : Pat<(parallel (store (X86sub_flag (loadi8 addr:$dst), imm:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004866 addr:$dst),
4867 (implicit EFLAGS)),
4868 (SUB8mi addr:$dst, imm:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00004869def : Pat<(parallel (store (X86sub_flag (loadi16 addr:$dst), imm:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004870 addr:$dst),
4871 (implicit EFLAGS)),
4872 (SUB16mi addr:$dst, imm:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00004873def : Pat<(parallel (store (X86sub_flag (loadi32 addr:$dst), imm:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004874 addr:$dst),
4875 (implicit EFLAGS)),
4876 (SUB32mi addr:$dst, imm:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00004877def : Pat<(parallel (store (X86sub_flag (loadi16 addr:$dst), i16immSExt8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004878 addr:$dst),
4879 (implicit EFLAGS)),
4880 (SUB16mi8 addr:$dst, i16immSExt8:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00004881def : Pat<(parallel (store (X86sub_flag (loadi32 addr:$dst), i32immSExt8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004882 addr:$dst),
4883 (implicit EFLAGS)),
4884 (SUB32mi8 addr:$dst, i32immSExt8:$src2)>;
4885
4886
Dan Gohman99a12192009-03-04 19:44:21 +00004887// Register-Register Signed Integer Multiply with EFLAGS result
4888def : Pat<(parallel (X86smul_flag GR16:$src1, GR16:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004889 (implicit EFLAGS)),
4890 (IMUL16rr GR16:$src1, GR16:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00004891def : Pat<(parallel (X86smul_flag GR32:$src1, GR32:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004892 (implicit EFLAGS)),
4893 (IMUL32rr GR32:$src1, GR32:$src2)>;
4894
Dan Gohman99a12192009-03-04 19:44:21 +00004895// Register-Memory Signed Integer Multiply with EFLAGS result
4896def : Pat<(parallel (X86smul_flag GR16:$src1, (loadi16 addr:$src2)),
Bill Wendlingf5399032008-12-12 21:15:41 +00004897 (implicit EFLAGS)),
4898 (IMUL16rm GR16:$src1, addr:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00004899def : Pat<(parallel (X86smul_flag GR32:$src1, (loadi32 addr:$src2)),
Bill Wendlingf5399032008-12-12 21:15:41 +00004900 (implicit EFLAGS)),
4901 (IMUL32rm GR32:$src1, addr:$src2)>;
4902
Dan Gohman99a12192009-03-04 19:44:21 +00004903// Register-Integer Signed Integer Multiply with EFLAGS result
4904def : Pat<(parallel (X86smul_flag GR16:$src1, imm:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004905 (implicit EFLAGS)),
4906 (IMUL16rri GR16:$src1, imm:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00004907def : Pat<(parallel (X86smul_flag GR32:$src1, imm:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004908 (implicit EFLAGS)),
4909 (IMUL32rri GR32:$src1, imm:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00004910def : Pat<(parallel (X86smul_flag GR16:$src1, i16immSExt8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004911 (implicit EFLAGS)),
4912 (IMUL16rri8 GR16:$src1, i16immSExt8:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00004913def : Pat<(parallel (X86smul_flag GR32:$src1, i32immSExt8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004914 (implicit EFLAGS)),
4915 (IMUL32rri8 GR32:$src1, i32immSExt8:$src2)>;
4916
Dan Gohman99a12192009-03-04 19:44:21 +00004917// Memory-Integer Signed Integer Multiply with EFLAGS result
4918def : Pat<(parallel (X86smul_flag (loadi16 addr:$src1), imm:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004919 (implicit EFLAGS)),
4920 (IMUL16rmi addr:$src1, imm:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00004921def : Pat<(parallel (X86smul_flag (loadi32 addr:$src1), imm:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004922 (implicit EFLAGS)),
4923 (IMUL32rmi addr:$src1, imm:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00004924def : Pat<(parallel (X86smul_flag (loadi16 addr:$src1), i16immSExt8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004925 (implicit EFLAGS)),
4926 (IMUL16rmi8 addr:$src1, i16immSExt8:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00004927def : Pat<(parallel (X86smul_flag (loadi32 addr:$src1), i32immSExt8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004928 (implicit EFLAGS)),
4929 (IMUL32rmi8 addr:$src1, i32immSExt8:$src2)>;
4930
Dan Gohman99a12192009-03-04 19:44:21 +00004931// Optimize multiply by 2 with EFLAGS result.
Evan Cheng00cf7932009-01-27 03:30:42 +00004932let AddedComplexity = 2 in {
Dan Gohman99a12192009-03-04 19:44:21 +00004933def : Pat<(parallel (X86smul_flag GR16:$src1, 2),
Evan Cheng00cf7932009-01-27 03:30:42 +00004934 (implicit EFLAGS)),
4935 (ADD16rr GR16:$src1, GR16:$src1)>;
4936
Dan Gohman99a12192009-03-04 19:44:21 +00004937def : Pat<(parallel (X86smul_flag GR32:$src1, 2),
Evan Cheng00cf7932009-01-27 03:30:42 +00004938 (implicit EFLAGS)),
4939 (ADD32rr GR32:$src1, GR32:$src1)>;
4940}
4941
Dan Gohman99a12192009-03-04 19:44:21 +00004942// INC and DEC with EFLAGS result. Note that these do not set CF.
4943def : Pat<(parallel (X86inc_flag GR8:$src), (implicit EFLAGS)),
4944 (INC8r GR8:$src)>;
4945def : Pat<(parallel (store (i8 (X86inc_flag (loadi8 addr:$dst))), addr:$dst),
4946 (implicit EFLAGS)),
4947 (INC8m addr:$dst)>;
4948def : Pat<(parallel (X86dec_flag GR8:$src), (implicit EFLAGS)),
4949 (DEC8r GR8:$src)>;
4950def : Pat<(parallel (store (i8 (X86dec_flag (loadi8 addr:$dst))), addr:$dst),
4951 (implicit EFLAGS)),
4952 (DEC8m addr:$dst)>;
4953
4954def : Pat<(parallel (X86inc_flag GR16:$src), (implicit EFLAGS)),
Dan Gohmaneebcac72009-03-05 21:32:23 +00004955 (INC16r GR16:$src)>, Requires<[In32BitMode]>;
Dan Gohman99a12192009-03-04 19:44:21 +00004956def : Pat<(parallel (store (i16 (X86inc_flag (loadi16 addr:$dst))), addr:$dst),
4957 (implicit EFLAGS)),
Dan Gohmaneebcac72009-03-05 21:32:23 +00004958 (INC16m addr:$dst)>, Requires<[In32BitMode]>;
Dan Gohman99a12192009-03-04 19:44:21 +00004959def : Pat<(parallel (X86dec_flag GR16:$src), (implicit EFLAGS)),
Dan Gohmaneebcac72009-03-05 21:32:23 +00004960 (DEC16r GR16:$src)>, Requires<[In32BitMode]>;
Dan Gohman99a12192009-03-04 19:44:21 +00004961def : Pat<(parallel (store (i16 (X86dec_flag (loadi16 addr:$dst))), addr:$dst),
4962 (implicit EFLAGS)),
Dan Gohmaneebcac72009-03-05 21:32:23 +00004963 (DEC16m addr:$dst)>, Requires<[In32BitMode]>;
Dan Gohman99a12192009-03-04 19:44:21 +00004964
4965def : Pat<(parallel (X86inc_flag GR32:$src), (implicit EFLAGS)),
Dan Gohmaneebcac72009-03-05 21:32:23 +00004966 (INC32r GR32:$src)>, Requires<[In32BitMode]>;
Dan Gohman99a12192009-03-04 19:44:21 +00004967def : Pat<(parallel (store (i32 (X86inc_flag (loadi32 addr:$dst))), addr:$dst),
4968 (implicit EFLAGS)),
Dan Gohmaneebcac72009-03-05 21:32:23 +00004969 (INC32m addr:$dst)>, Requires<[In32BitMode]>;
Dan Gohman99a12192009-03-04 19:44:21 +00004970def : Pat<(parallel (X86dec_flag GR32:$src), (implicit EFLAGS)),
Dan Gohmaneebcac72009-03-05 21:32:23 +00004971 (DEC32r GR32:$src)>, Requires<[In32BitMode]>;
Dan Gohman99a12192009-03-04 19:44:21 +00004972def : Pat<(parallel (store (i32 (X86dec_flag (loadi32 addr:$dst))), addr:$dst),
4973 (implicit EFLAGS)),
Dan Gohmaneebcac72009-03-05 21:32:23 +00004974 (DEC32m addr:$dst)>, Requires<[In32BitMode]>;
Dan Gohman99a12192009-03-04 19:44:21 +00004975
Dan Gohman12e03292009-09-18 19:59:53 +00004976// Register-Register Or with EFLAGS result
4977def : Pat<(parallel (X86or_flag GR8:$src1, GR8:$src2),
4978 (implicit EFLAGS)),
4979 (OR8rr GR8:$src1, GR8:$src2)>;
4980def : Pat<(parallel (X86or_flag GR16:$src1, GR16:$src2),
4981 (implicit EFLAGS)),
4982 (OR16rr GR16:$src1, GR16:$src2)>;
4983def : Pat<(parallel (X86or_flag GR32:$src1, GR32:$src2),
4984 (implicit EFLAGS)),
4985 (OR32rr GR32:$src1, GR32:$src2)>;
4986
4987// Register-Memory Or with EFLAGS result
4988def : Pat<(parallel (X86or_flag GR8:$src1, (loadi8 addr:$src2)),
4989 (implicit EFLAGS)),
4990 (OR8rm GR8:$src1, addr:$src2)>;
4991def : Pat<(parallel (X86or_flag GR16:$src1, (loadi16 addr:$src2)),
4992 (implicit EFLAGS)),
4993 (OR16rm GR16:$src1, addr:$src2)>;
4994def : Pat<(parallel (X86or_flag GR32:$src1, (loadi32 addr:$src2)),
4995 (implicit EFLAGS)),
4996 (OR32rm GR32:$src1, addr:$src2)>;
4997
4998// Register-Integer Or with EFLAGS result
4999def : Pat<(parallel (X86or_flag GR8:$src1, imm:$src2),
5000 (implicit EFLAGS)),
5001 (OR8ri GR8:$src1, imm:$src2)>;
5002def : Pat<(parallel (X86or_flag GR16:$src1, imm:$src2),
5003 (implicit EFLAGS)),
5004 (OR16ri GR16:$src1, imm:$src2)>;
5005def : Pat<(parallel (X86or_flag GR32:$src1, imm:$src2),
5006 (implicit EFLAGS)),
5007 (OR32ri GR32:$src1, imm:$src2)>;
5008def : Pat<(parallel (X86or_flag GR16:$src1, i16immSExt8:$src2),
5009 (implicit EFLAGS)),
5010 (OR16ri8 GR16:$src1, i16immSExt8:$src2)>;
5011def : Pat<(parallel (X86or_flag GR32:$src1, i32immSExt8:$src2),
5012 (implicit EFLAGS)),
5013 (OR32ri8 GR32:$src1, i32immSExt8:$src2)>;
5014
5015// Memory-Register Or with EFLAGS result
5016def : Pat<(parallel (store (X86or_flag (loadi8 addr:$dst), GR8:$src2),
5017 addr:$dst),
5018 (implicit EFLAGS)),
5019 (OR8mr addr:$dst, GR8:$src2)>;
5020def : Pat<(parallel (store (X86or_flag (loadi16 addr:$dst), GR16:$src2),
5021 addr:$dst),
5022 (implicit EFLAGS)),
5023 (OR16mr addr:$dst, GR16:$src2)>;
5024def : Pat<(parallel (store (X86or_flag (loadi32 addr:$dst), GR32:$src2),
5025 addr:$dst),
5026 (implicit EFLAGS)),
5027 (OR32mr addr:$dst, GR32:$src2)>;
5028
5029// Memory-Integer Or with EFLAGS result
5030def : Pat<(parallel (store (X86or_flag (loadi8 addr:$dst), imm:$src2),
5031 addr:$dst),
5032 (implicit EFLAGS)),
5033 (OR8mi addr:$dst, imm:$src2)>;
5034def : Pat<(parallel (store (X86or_flag (loadi16 addr:$dst), imm:$src2),
5035 addr:$dst),
5036 (implicit EFLAGS)),
5037 (OR16mi addr:$dst, imm:$src2)>;
5038def : Pat<(parallel (store (X86or_flag (loadi32 addr:$dst), imm:$src2),
5039 addr:$dst),
5040 (implicit EFLAGS)),
5041 (OR32mi addr:$dst, imm:$src2)>;
5042def : Pat<(parallel (store (X86or_flag (loadi16 addr:$dst), i16immSExt8:$src2),
5043 addr:$dst),
5044 (implicit EFLAGS)),
5045 (OR16mi8 addr:$dst, i16immSExt8:$src2)>;
5046def : Pat<(parallel (store (X86or_flag (loadi32 addr:$dst), i32immSExt8:$src2),
5047 addr:$dst),
5048 (implicit EFLAGS)),
5049 (OR32mi8 addr:$dst, i32immSExt8:$src2)>;
5050
5051// Register-Register XOr with EFLAGS result
5052def : Pat<(parallel (X86xor_flag GR8:$src1, GR8:$src2),
5053 (implicit EFLAGS)),
5054 (XOR8rr GR8:$src1, GR8:$src2)>;
5055def : Pat<(parallel (X86xor_flag GR16:$src1, GR16:$src2),
5056 (implicit EFLAGS)),
5057 (XOR16rr GR16:$src1, GR16:$src2)>;
5058def : Pat<(parallel (X86xor_flag GR32:$src1, GR32:$src2),
5059 (implicit EFLAGS)),
5060 (XOR32rr GR32:$src1, GR32:$src2)>;
5061
5062// Register-Memory XOr with EFLAGS result
5063def : Pat<(parallel (X86xor_flag GR8:$src1, (loadi8 addr:$src2)),
5064 (implicit EFLAGS)),
5065 (XOR8rm GR8:$src1, addr:$src2)>;
5066def : Pat<(parallel (X86xor_flag GR16:$src1, (loadi16 addr:$src2)),
5067 (implicit EFLAGS)),
5068 (XOR16rm GR16:$src1, addr:$src2)>;
5069def : Pat<(parallel (X86xor_flag GR32:$src1, (loadi32 addr:$src2)),
5070 (implicit EFLAGS)),
5071 (XOR32rm GR32:$src1, addr:$src2)>;
5072
5073// Register-Integer XOr with EFLAGS result
5074def : Pat<(parallel (X86xor_flag GR8:$src1, imm:$src2),
5075 (implicit EFLAGS)),
5076 (XOR8ri GR8:$src1, imm:$src2)>;
5077def : Pat<(parallel (X86xor_flag GR16:$src1, imm:$src2),
5078 (implicit EFLAGS)),
5079 (XOR16ri GR16:$src1, imm:$src2)>;
5080def : Pat<(parallel (X86xor_flag GR32:$src1, imm:$src2),
5081 (implicit EFLAGS)),
5082 (XOR32ri GR32:$src1, imm:$src2)>;
5083def : Pat<(parallel (X86xor_flag GR16:$src1, i16immSExt8:$src2),
5084 (implicit EFLAGS)),
5085 (XOR16ri8 GR16:$src1, i16immSExt8:$src2)>;
5086def : Pat<(parallel (X86xor_flag GR32:$src1, i32immSExt8:$src2),
5087 (implicit EFLAGS)),
5088 (XOR32ri8 GR32:$src1, i32immSExt8:$src2)>;
5089
5090// Memory-Register XOr with EFLAGS result
5091def : Pat<(parallel (store (X86xor_flag (loadi8 addr:$dst), GR8:$src2),
5092 addr:$dst),
5093 (implicit EFLAGS)),
5094 (XOR8mr addr:$dst, GR8:$src2)>;
5095def : Pat<(parallel (store (X86xor_flag (loadi16 addr:$dst), GR16:$src2),
5096 addr:$dst),
5097 (implicit EFLAGS)),
5098 (XOR16mr addr:$dst, GR16:$src2)>;
5099def : Pat<(parallel (store (X86xor_flag (loadi32 addr:$dst), GR32:$src2),
5100 addr:$dst),
5101 (implicit EFLAGS)),
5102 (XOR32mr addr:$dst, GR32:$src2)>;
5103
5104// Memory-Integer XOr with EFLAGS result
5105def : Pat<(parallel (store (X86xor_flag (loadi8 addr:$dst), imm:$src2),
5106 addr:$dst),
5107 (implicit EFLAGS)),
5108 (XOR8mi addr:$dst, imm:$src2)>;
5109def : Pat<(parallel (store (X86xor_flag (loadi16 addr:$dst), imm:$src2),
5110 addr:$dst),
5111 (implicit EFLAGS)),
5112 (XOR16mi addr:$dst, imm:$src2)>;
5113def : Pat<(parallel (store (X86xor_flag (loadi32 addr:$dst), imm:$src2),
5114 addr:$dst),
5115 (implicit EFLAGS)),
5116 (XOR32mi addr:$dst, imm:$src2)>;
5117def : Pat<(parallel (store (X86xor_flag (loadi16 addr:$dst), i16immSExt8:$src2),
5118 addr:$dst),
5119 (implicit EFLAGS)),
5120 (XOR16mi8 addr:$dst, i16immSExt8:$src2)>;
5121def : Pat<(parallel (store (X86xor_flag (loadi32 addr:$dst), i32immSExt8:$src2),
5122 addr:$dst),
5123 (implicit EFLAGS)),
5124 (XOR32mi8 addr:$dst, i32immSExt8:$src2)>;
5125
5126// Register-Register And with EFLAGS result
5127def : Pat<(parallel (X86and_flag GR8:$src1, GR8:$src2),
5128 (implicit EFLAGS)),
5129 (AND8rr GR8:$src1, GR8:$src2)>;
5130def : Pat<(parallel (X86and_flag GR16:$src1, GR16:$src2),
5131 (implicit EFLAGS)),
5132 (AND16rr GR16:$src1, GR16:$src2)>;
5133def : Pat<(parallel (X86and_flag GR32:$src1, GR32:$src2),
5134 (implicit EFLAGS)),
5135 (AND32rr GR32:$src1, GR32:$src2)>;
5136
5137// Register-Memory And with EFLAGS result
5138def : Pat<(parallel (X86and_flag GR8:$src1, (loadi8 addr:$src2)),
5139 (implicit EFLAGS)),
5140 (AND8rm GR8:$src1, addr:$src2)>;
5141def : Pat<(parallel (X86and_flag GR16:$src1, (loadi16 addr:$src2)),
5142 (implicit EFLAGS)),
5143 (AND16rm GR16:$src1, addr:$src2)>;
5144def : Pat<(parallel (X86and_flag GR32:$src1, (loadi32 addr:$src2)),
5145 (implicit EFLAGS)),
5146 (AND32rm GR32:$src1, addr:$src2)>;
5147
5148// Register-Integer And with EFLAGS result
5149def : Pat<(parallel (X86and_flag GR8:$src1, imm:$src2),
5150 (implicit EFLAGS)),
5151 (AND8ri GR8:$src1, imm:$src2)>;
5152def : Pat<(parallel (X86and_flag GR16:$src1, imm:$src2),
5153 (implicit EFLAGS)),
5154 (AND16ri GR16:$src1, imm:$src2)>;
5155def : Pat<(parallel (X86and_flag GR32:$src1, imm:$src2),
5156 (implicit EFLAGS)),
5157 (AND32ri GR32:$src1, imm:$src2)>;
5158def : Pat<(parallel (X86and_flag GR16:$src1, i16immSExt8:$src2),
5159 (implicit EFLAGS)),
5160 (AND16ri8 GR16:$src1, i16immSExt8:$src2)>;
5161def : Pat<(parallel (X86and_flag GR32:$src1, i32immSExt8:$src2),
5162 (implicit EFLAGS)),
5163 (AND32ri8 GR32:$src1, i32immSExt8:$src2)>;
5164
5165// Memory-Register And with EFLAGS result
5166def : Pat<(parallel (store (X86and_flag (loadi8 addr:$dst), GR8:$src2),
5167 addr:$dst),
5168 (implicit EFLAGS)),
5169 (AND8mr addr:$dst, GR8:$src2)>;
5170def : Pat<(parallel (store (X86and_flag (loadi16 addr:$dst), GR16:$src2),
5171 addr:$dst),
5172 (implicit EFLAGS)),
5173 (AND16mr addr:$dst, GR16:$src2)>;
5174def : Pat<(parallel (store (X86and_flag (loadi32 addr:$dst), GR32:$src2),
5175 addr:$dst),
5176 (implicit EFLAGS)),
5177 (AND32mr addr:$dst, GR32:$src2)>;
5178
5179// Memory-Integer And with EFLAGS result
5180def : Pat<(parallel (store (X86and_flag (loadi8 addr:$dst), imm:$src2),
5181 addr:$dst),
5182 (implicit EFLAGS)),
5183 (AND8mi addr:$dst, imm:$src2)>;
5184def : Pat<(parallel (store (X86and_flag (loadi16 addr:$dst), imm:$src2),
5185 addr:$dst),
5186 (implicit EFLAGS)),
5187 (AND16mi addr:$dst, imm:$src2)>;
5188def : Pat<(parallel (store (X86and_flag (loadi32 addr:$dst), imm:$src2),
5189 addr:$dst),
5190 (implicit EFLAGS)),
5191 (AND32mi addr:$dst, imm:$src2)>;
5192def : Pat<(parallel (store (X86and_flag (loadi16 addr:$dst), i16immSExt8:$src2),
5193 addr:$dst),
5194 (implicit EFLAGS)),
5195 (AND16mi8 addr:$dst, i16immSExt8:$src2)>;
5196def : Pat<(parallel (store (X86and_flag (loadi32 addr:$dst), i32immSExt8:$src2),
5197 addr:$dst),
5198 (implicit EFLAGS)),
5199 (AND32mi8 addr:$dst, i32immSExt8:$src2)>;
5200
Dan Gohmane84197b2009-09-03 17:18:51 +00005201// -disable-16bit support.
5202def : Pat<(truncstorei16 (i32 imm:$src), addr:$dst),
5203 (MOV16mi addr:$dst, imm:$src)>;
5204def : Pat<(truncstorei16 GR32:$src, addr:$dst),
5205 (MOV16mr addr:$dst, (EXTRACT_SUBREG GR32:$src, x86_subreg_16bit))>;
5206def : Pat<(i32 (sextloadi16 addr:$dst)),
5207 (MOVSX32rm16 addr:$dst)>;
5208def : Pat<(i32 (zextloadi16 addr:$dst)),
5209 (MOVZX32rm16 addr:$dst)>;
5210def : Pat<(i32 (extloadi16 addr:$dst)),
5211 (MOVZX32rm16 addr:$dst)>;
5212
Bill Wendlingf5399032008-12-12 21:15:41 +00005213//===----------------------------------------------------------------------===//
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005214// Floating Point Stack Support
5215//===----------------------------------------------------------------------===//
5216
5217include "X86InstrFPStack.td"
5218
5219//===----------------------------------------------------------------------===//
Evan Cheng86ab7d32007-07-31 08:04:03 +00005220// X86-64 Support
5221//===----------------------------------------------------------------------===//
5222
Chris Lattner2de8d2b2008-01-10 05:50:42 +00005223include "X86Instr64bit.td"
Evan Cheng86ab7d32007-07-31 08:04:03 +00005224
5225//===----------------------------------------------------------------------===//
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005226// XMM Floating point support (requires SSE / SSE2)
5227//===----------------------------------------------------------------------===//
5228
5229include "X86InstrSSE.td"
Evan Cheng5e4d1e72008-04-25 18:19:54 +00005230
5231//===----------------------------------------------------------------------===//
5232// MMX and XMM Packed Integer support (requires MMX, SSE, and SSE2)
5233//===----------------------------------------------------------------------===//
5234
5235include "X86InstrMMX.td"