blob: 6853af39d12219dc794a1c6ddf9d80ae739f93de [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
Chris Lattner357a0ca2009-06-20 19:34:09 +0000185def i32imm_pcrel : Operand<i32> {
186 let PrintMethod = "print_pcrel_imm";
187}
188
Dan Gohmanfe606822009-07-30 01:56:29 +0000189// A version of ptr_rc which excludes SP, ESP, and RSP. This is used for
190// the index operand of an address, to conform to x86 encoding restrictions.
191def ptr_rc_nosp : PointerLikeRegClass<1>;
Chris Lattner357a0ca2009-06-20 19:34:09 +0000192
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000193// *mem - Operand definitions for the funky X86 addressing mode operands.
194//
Daniel Dunbar0f10cbf2009-08-10 18:41:10 +0000195def X86MemAsmOperand : AsmOperandClass {
196 let Name = "Mem";
Daniel Dunbar6e9ee792009-08-10 19:08:02 +0000197 let SuperClass = ?;
Daniel Dunbar0f10cbf2009-08-10 18:41:10 +0000198}
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
214def offset8 : Operand<i64> { let PrintMethod = "print_pcrel_imm"; }
215def offset16 : Operand<i64> { let PrintMethod = "print_pcrel_imm"; }
216def offset32 : Operand<i64> { let PrintMethod = "print_pcrel_imm"; }
217def offset64 : Operand<i64> { let PrintMethod = "print_pcrel_imm"; }
Sean Callanan66fdfa02009-09-03 00:04:47 +0000218
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000219def i8mem : X86MemOperand<"printi8mem">;
220def i16mem : X86MemOperand<"printi16mem">;
221def i32mem : X86MemOperand<"printi32mem">;
222def i64mem : X86MemOperand<"printi64mem">;
223def i128mem : X86MemOperand<"printi128mem">;
Chris Lattnerd6153b42009-09-20 07:17:49 +0000224//def i256mem : X86MemOperand<"printi256mem">;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000225def f32mem : X86MemOperand<"printf32mem">;
226def f64mem : X86MemOperand<"printf64mem">;
Dale Johannesen4ab00bd2007-08-05 18:49:15 +0000227def f80mem : X86MemOperand<"printf80mem">;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000228def f128mem : X86MemOperand<"printf128mem">;
Chris Lattnerd6153b42009-09-20 07:17:49 +0000229//def f256mem : X86MemOperand<"printf256mem">;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000230
Dan Gohman744d4622009-04-13 16:09:41 +0000231// A version of i8mem for use on x86-64 that uses GR64_NOREX instead of
232// plain GR64, so that it doesn't potentially require a REX prefix.
233def i8mem_NOREX : Operand<i64> {
234 let PrintMethod = "printi8mem";
Dan Gohmanfe606822009-07-30 01:56:29 +0000235 let MIOperandInfo = (ops GR64_NOREX, i8imm, GR64_NOREX_NOSP, i32imm, i8imm);
Daniel Dunbar0f10cbf2009-08-10 18:41:10 +0000236 let ParserMatchClass = X86MemAsmOperand;
Dan Gohman744d4622009-04-13 16:09:41 +0000237}
238
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000239def lea32mem : Operand<i32> {
Rafael Espindolabca99f72009-04-08 21:14:34 +0000240 let PrintMethod = "printlea32mem";
Dan Gohmanefbd3bc2009-08-05 17:40:24 +0000241 let MIOperandInfo = (ops GR32, i8imm, GR32_NOSP, i32imm);
Daniel Dunbarfc1b32a2010-01-30 00:24:00 +0000242 let ParserMatchClass = X86NoSegMemAsmOperand;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000243}
244
245def SSECC : Operand<i8> {
246 let PrintMethod = "printSSECC";
247}
248
Daniel Dunbar0f10cbf2009-08-10 18:41:10 +0000249def ImmSExt8AsmOperand : AsmOperandClass {
250 let Name = "ImmSExt8";
251 let SuperClass = ImmAsmOperand;
252}
253
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000254// A couple of more descriptive operand definitions.
255// 16-bits but only 8 bits are significant.
Daniel Dunbar06d5cb62009-08-09 07:20:21 +0000256def i16i8imm : Operand<i16> {
Daniel Dunbar0f10cbf2009-08-10 18:41:10 +0000257 let ParserMatchClass = ImmSExt8AsmOperand;
Daniel Dunbar06d5cb62009-08-09 07:20:21 +0000258}
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000259// 32-bits but only 8 bits are significant.
Daniel Dunbar06d5cb62009-08-09 07:20:21 +0000260def i32i8imm : Operand<i32> {
Daniel Dunbar0f10cbf2009-08-10 18:41:10 +0000261 let ParserMatchClass = ImmSExt8AsmOperand;
Daniel Dunbar06d5cb62009-08-09 07:20:21 +0000262}
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000263
Chris Lattner357a0ca2009-06-20 19:34:09 +0000264// Branch targets have OtherVT type and print as pc-relative values.
265def brtarget : Operand<OtherVT> {
266 let PrintMethod = "print_pcrel_imm";
267}
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000268
Evan Chengd11052b2009-07-21 06:00:18 +0000269def brtarget8 : Operand<OtherVT> {
270 let PrintMethod = "print_pcrel_imm";
271}
272
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000273//===----------------------------------------------------------------------===//
274// X86 Complex Pattern Definitions.
275//
276
277// Define X86 specific addressing mode.
Rafael Espindolabca99f72009-04-08 21:14:34 +0000278def addr : ComplexPattern<iPTR, 5, "SelectAddr", [], []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000279def lea32addr : ComplexPattern<i32, 4, "SelectLEAAddr",
Dan Gohman0c0d7412009-08-02 16:09:17 +0000280 [add, sub, mul, X86mul_imm, shl, or, frameindex],
281 []>;
Chris Lattnerf1940742009-06-20 20:38:48 +0000282def tls32addr : ComplexPattern<i32, 4, "SelectTLSADDRAddr",
283 [tglobaltlsaddr], []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000284
285//===----------------------------------------------------------------------===//
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000286// X86 Instruction Predicate Definitions.
287def HasMMX : Predicate<"Subtarget->hasMMX()">;
288def HasSSE1 : Predicate<"Subtarget->hasSSE1()">;
289def HasSSE2 : Predicate<"Subtarget->hasSSE2()">;
290def HasSSE3 : Predicate<"Subtarget->hasSSE3()">;
291def HasSSSE3 : Predicate<"Subtarget->hasSSSE3()">;
Nate Begemanb2975562008-02-03 07:18:54 +0000292def HasSSE41 : Predicate<"Subtarget->hasSSE41()">;
293def HasSSE42 : Predicate<"Subtarget->hasSSE42()">;
David Greene8bf22bc2009-06-26 22:46:54 +0000294def HasSSE4A : Predicate<"Subtarget->hasSSE4A()">;
295def HasAVX : Predicate<"Subtarget->hasAVX()">;
296def HasFMA3 : Predicate<"Subtarget->hasFMA3()">;
297def HasFMA4 : Predicate<"Subtarget->hasFMA4()">;
Dale Johannesene0e0fd02007-09-23 14:52:20 +0000298def FPStackf32 : Predicate<"!Subtarget->hasSSE1()">;
299def FPStackf64 : Predicate<"!Subtarget->hasSSE2()">;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000300def In32BitMode : Predicate<"!Subtarget->is64Bit()">;
301def In64BitMode : Predicate<"Subtarget->is64Bit()">;
Anton Korobeynikov2cbcdb72009-08-03 08:12:53 +0000302def IsWin64 : Predicate<"Subtarget->isTargetWin64()">;
303def NotWin64 : Predicate<"!Subtarget->isTargetWin64()">;
Anton Korobeynikov68d4eca2009-08-06 11:23:24 +0000304def SmallCode : Predicate<"TM.getCodeModel() == CodeModel::Small">;
305def KernelCode : Predicate<"TM.getCodeModel() == CodeModel::Kernel">;
306def FarData : Predicate<"TM.getCodeModel() != CodeModel::Small &&"
Anton Korobeynikov7e1178f2009-08-06 09:11:19 +0000307 "TM.getCodeModel() != CodeModel::Kernel">;
Anton Korobeynikov68d4eca2009-08-06 11:23:24 +0000308def NearData : Predicate<"TM.getCodeModel() == CodeModel::Small ||"
309 "TM.getCodeModel() == CodeModel::Kernel">;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000310def IsStatic : Predicate<"TM.getRelocationModel() == Reloc::Static">;
Evan Chengd53fca12009-12-22 17:47:23 +0000311def OptForSize : Predicate<"OptForSize">;
Evan Cheng13559d62008-09-26 23:41:32 +0000312def OptForSpeed : Predicate<"!OptForSize">;
Evan Cheng95a77fd2009-01-02 05:35:45 +0000313def FastBTMem : Predicate<"!Subtarget->isBTMemSlow()">;
Evan Cheng6d35a4d2009-05-20 04:53:57 +0000314def CallImmAddr : Predicate<"Subtarget->IsLegalToCallImmediateAddr(TM)">;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000315
316//===----------------------------------------------------------------------===//
Evan Cheng86ab7d32007-07-31 08:04:03 +0000317// X86 Instruction Format Definitions.
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000318//
319
Evan Cheng86ab7d32007-07-31 08:04:03 +0000320include "X86InstrFormats.td"
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000321
322//===----------------------------------------------------------------------===//
323// Pattern fragments...
324//
325
326// X86 specific condition code. These correspond to CondCode in
327// X86InstrInfo.h. They must be kept in synch.
Dan Gohman0fc9ed62009-01-07 00:15:08 +0000328def X86_COND_A : PatLeaf<(i8 0)>; // alt. COND_NBE
329def X86_COND_AE : PatLeaf<(i8 1)>; // alt. COND_NC
330def X86_COND_B : PatLeaf<(i8 2)>; // alt. COND_C
331def X86_COND_BE : PatLeaf<(i8 3)>; // alt. COND_NA
332def X86_COND_E : PatLeaf<(i8 4)>; // alt. COND_Z
333def X86_COND_G : PatLeaf<(i8 5)>; // alt. COND_NLE
334def X86_COND_GE : PatLeaf<(i8 6)>; // alt. COND_NL
335def X86_COND_L : PatLeaf<(i8 7)>; // alt. COND_NGE
336def X86_COND_LE : PatLeaf<(i8 8)>; // alt. COND_NG
337def X86_COND_NE : PatLeaf<(i8 9)>; // alt. COND_NZ
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000338def X86_COND_NO : PatLeaf<(i8 10)>;
Dan Gohman0fc9ed62009-01-07 00:15:08 +0000339def X86_COND_NP : PatLeaf<(i8 11)>; // alt. COND_PO
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000340def X86_COND_NS : PatLeaf<(i8 12)>;
Dan Gohman0fc9ed62009-01-07 00:15:08 +0000341def X86_COND_O : PatLeaf<(i8 13)>;
342def X86_COND_P : PatLeaf<(i8 14)>; // alt. COND_PE
343def X86_COND_S : PatLeaf<(i8 15)>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000344
345def i16immSExt8 : PatLeaf<(i16 imm), [{
346 // i16immSExt8 predicate - True if the 16-bit immediate fits in a 8-bit
347 // sign extended field.
Dan Gohmanfaeb4a32008-09-12 16:56:44 +0000348 return (int16_t)N->getZExtValue() == (int8_t)N->getZExtValue();
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000349}]>;
350
351def i32immSExt8 : PatLeaf<(i32 imm), [{
352 // i32immSExt8 predicate - True if the 32-bit immediate fits in a 8-bit
353 // sign extended field.
Dan Gohmanfaeb4a32008-09-12 16:56:44 +0000354 return (int32_t)N->getZExtValue() == (int8_t)N->getZExtValue();
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000355}]>;
356
357// Helper fragments for loads.
Evan Chengb3e25ea2008-05-13 18:59:59 +0000358// It's always safe to treat a anyext i16 load as a i32 load if the i16 is
359// known to be 32-bit aligned or better. Ditto for i8 to i16.
Dan Gohman2a174122008-10-15 06:50:19 +0000360def loadi16 : PatFrag<(ops node:$ptr), (i16 (unindexedload node:$ptr)), [{
Dan Gohman8335c412008-08-20 15:24:22 +0000361 LoadSDNode *LD = cast<LoadSDNode>(N);
Chris Lattner12208612009-04-10 00:16:23 +0000362 if (const Value *Src = LD->getSrcValue())
363 if (const PointerType *PT = dyn_cast<PointerType>(Src->getType()))
Mon P Wangdc97d5a2009-04-27 07:22:10 +0000364 if (PT->getAddressSpace() > 255)
Chris Lattner12208612009-04-10 00:16:23 +0000365 return false;
Dan Gohman8335c412008-08-20 15:24:22 +0000366 ISD::LoadExtType ExtType = LD->getExtensionType();
367 if (ExtType == ISD::NON_EXTLOAD)
368 return true;
369 if (ExtType == ISD::EXTLOAD)
370 return LD->getAlignment() >= 2 && !LD->isVolatile();
Evan Cheng8b765e92008-05-13 00:54:02 +0000371 return false;
372}]>;
373
Sean Callanan2c48df22009-12-18 00:01:26 +0000374def loadi16_anyext : PatFrag<(ops node:$ptr), (i32 (unindexedload node:$ptr)),
375[{
Evan Cheng56ec77b2008-09-24 23:27:55 +0000376 LoadSDNode *LD = cast<LoadSDNode>(N);
Chris Lattner12208612009-04-10 00:16:23 +0000377 if (const Value *Src = LD->getSrcValue())
378 if (const PointerType *PT = dyn_cast<PointerType>(Src->getType()))
Mon P Wangdc97d5a2009-04-27 07:22:10 +0000379 if (PT->getAddressSpace() > 255)
Chris Lattner12208612009-04-10 00:16:23 +0000380 return false;
Evan Cheng56ec77b2008-09-24 23:27:55 +0000381 ISD::LoadExtType ExtType = LD->getExtensionType();
382 if (ExtType == ISD::EXTLOAD)
383 return LD->getAlignment() >= 2 && !LD->isVolatile();
384 return false;
385}]>;
386
Dan Gohman2a174122008-10-15 06:50:19 +0000387def loadi32 : PatFrag<(ops node:$ptr), (i32 (unindexedload node:$ptr)), [{
Dan Gohman8335c412008-08-20 15:24:22 +0000388 LoadSDNode *LD = cast<LoadSDNode>(N);
Chris Lattner12208612009-04-10 00:16:23 +0000389 if (const Value *Src = LD->getSrcValue())
390 if (const PointerType *PT = dyn_cast<PointerType>(Src->getType()))
Mon P Wangdc97d5a2009-04-27 07:22:10 +0000391 if (PT->getAddressSpace() > 255)
Chris Lattner12208612009-04-10 00:16:23 +0000392 return false;
Dan Gohman8335c412008-08-20 15:24:22 +0000393 ISD::LoadExtType ExtType = LD->getExtensionType();
394 if (ExtType == ISD::NON_EXTLOAD)
395 return true;
396 if (ExtType == ISD::EXTLOAD)
397 return LD->getAlignment() >= 4 && !LD->isVolatile();
Evan Cheng8b765e92008-05-13 00:54:02 +0000398 return false;
399}]>;
400
Dan Gohman2a174122008-10-15 06:50:19 +0000401def nvloadi32 : PatFrag<(ops node:$ptr), (i32 (unindexedload node:$ptr)), [{
Evan Cheng1e5e5452008-09-29 17:26:18 +0000402 LoadSDNode *LD = cast<LoadSDNode>(N);
Chris Lattner12208612009-04-10 00:16:23 +0000403 if (const Value *Src = LD->getSrcValue())
404 if (const PointerType *PT = dyn_cast<PointerType>(Src->getType()))
Mon P Wangdc97d5a2009-04-27 07:22:10 +0000405 if (PT->getAddressSpace() > 255)
Chris Lattner12208612009-04-10 00:16:23 +0000406 return false;
Evan Cheng1e5e5452008-09-29 17:26:18 +0000407 if (LD->isVolatile())
408 return false;
Evan Cheng1e5e5452008-09-29 17:26:18 +0000409 ISD::LoadExtType ExtType = LD->getExtensionType();
410 if (ExtType == ISD::NON_EXTLOAD)
411 return true;
412 if (ExtType == ISD::EXTLOAD)
413 return LD->getAlignment() >= 4;
414 return false;
415}]>;
416
sampo9cc09a32009-01-26 01:24:32 +0000417def gsload : PatFrag<(ops node:$ptr), (load node:$ptr), [{
Chris Lattner12208612009-04-10 00:16:23 +0000418 if (const Value *Src = cast<LoadSDNode>(N)->getSrcValue())
419 if (const PointerType *PT = dyn_cast<PointerType>(Src->getType()))
420 return PT->getAddressSpace() == 256;
sampo9cc09a32009-01-26 01:24:32 +0000421 return false;
422}]>;
423
Chris Lattnera7c2d8a2009-05-05 18:52:19 +0000424def fsload : PatFrag<(ops node:$ptr), (load node:$ptr), [{
425 if (const Value *Src = cast<LoadSDNode>(N)->getSrcValue())
426 if (const PointerType *PT = dyn_cast<PointerType>(Src->getType()))
427 return PT->getAddressSpace() == 257;
428 return false;
429}]>;
430
Chris Lattner12208612009-04-10 00:16:23 +0000431def loadi8 : PatFrag<(ops node:$ptr), (i8 (load node:$ptr)), [{
432 if (const Value *Src = cast<LoadSDNode>(N)->getSrcValue())
433 if (const PointerType *PT = dyn_cast<PointerType>(Src->getType()))
Mon P Wangdc97d5a2009-04-27 07:22:10 +0000434 if (PT->getAddressSpace() > 255)
Chris Lattner12208612009-04-10 00:16:23 +0000435 return false;
436 return true;
437}]>;
438def loadi64 : PatFrag<(ops node:$ptr), (i64 (load node:$ptr)), [{
439 if (const Value *Src = cast<LoadSDNode>(N)->getSrcValue())
440 if (const PointerType *PT = dyn_cast<PointerType>(Src->getType()))
Mon P Wangdc97d5a2009-04-27 07:22:10 +0000441 if (PT->getAddressSpace() > 255)
Chris Lattner12208612009-04-10 00:16:23 +0000442 return false;
443 return true;
444}]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000445
Chris Lattner12208612009-04-10 00:16:23 +0000446def loadf32 : PatFrag<(ops node:$ptr), (f32 (load node:$ptr)), [{
447 if (const Value *Src = cast<LoadSDNode>(N)->getSrcValue())
448 if (const PointerType *PT = dyn_cast<PointerType>(Src->getType()))
Mon P Wangdc97d5a2009-04-27 07:22:10 +0000449 if (PT->getAddressSpace() > 255)
Chris Lattner12208612009-04-10 00:16:23 +0000450 return false;
451 return true;
452}]>;
453def loadf64 : PatFrag<(ops node:$ptr), (f64 (load node:$ptr)), [{
454 if (const Value *Src = cast<LoadSDNode>(N)->getSrcValue())
455 if (const PointerType *PT = dyn_cast<PointerType>(Src->getType()))
Mon P Wangdc97d5a2009-04-27 07:22:10 +0000456 if (PT->getAddressSpace() > 255)
Chris Lattner12208612009-04-10 00:16:23 +0000457 return false;
458 return true;
459}]>;
460def loadf80 : PatFrag<(ops node:$ptr), (f80 (load node:$ptr)), [{
461 if (const Value *Src = cast<LoadSDNode>(N)->getSrcValue())
462 if (const PointerType *PT = dyn_cast<PointerType>(Src->getType()))
Mon P Wangdc97d5a2009-04-27 07:22:10 +0000463 if (PT->getAddressSpace() > 255)
Chris Lattner12208612009-04-10 00:16:23 +0000464 return false;
465 return true;
466}]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000467
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000468def sextloadi16i8 : PatFrag<(ops node:$ptr), (i16 (sextloadi8 node:$ptr))>;
469def sextloadi32i8 : PatFrag<(ops node:$ptr), (i32 (sextloadi8 node:$ptr))>;
470def sextloadi32i16 : PatFrag<(ops node:$ptr), (i32 (sextloadi16 node:$ptr))>;
471
472def zextloadi8i1 : PatFrag<(ops node:$ptr), (i8 (zextloadi1 node:$ptr))>;
473def zextloadi16i1 : PatFrag<(ops node:$ptr), (i16 (zextloadi1 node:$ptr))>;
474def zextloadi32i1 : PatFrag<(ops node:$ptr), (i32 (zextloadi1 node:$ptr))>;
475def zextloadi16i8 : PatFrag<(ops node:$ptr), (i16 (zextloadi8 node:$ptr))>;
476def zextloadi32i8 : PatFrag<(ops node:$ptr), (i32 (zextloadi8 node:$ptr))>;
477def zextloadi32i16 : PatFrag<(ops node:$ptr), (i32 (zextloadi16 node:$ptr))>;
478
479def extloadi8i1 : PatFrag<(ops node:$ptr), (i8 (extloadi1 node:$ptr))>;
480def extloadi16i1 : PatFrag<(ops node:$ptr), (i16 (extloadi1 node:$ptr))>;
481def extloadi32i1 : PatFrag<(ops node:$ptr), (i32 (extloadi1 node:$ptr))>;
482def extloadi16i8 : PatFrag<(ops node:$ptr), (i16 (extloadi8 node:$ptr))>;
483def extloadi32i8 : PatFrag<(ops node:$ptr), (i32 (extloadi8 node:$ptr))>;
484def extloadi32i16 : PatFrag<(ops node:$ptr), (i32 (extloadi16 node:$ptr))>;
485
Chris Lattner21da6382008-02-19 17:37:35 +0000486
487// An 'and' node with a single use.
488def and_su : PatFrag<(ops node:$lhs, node:$rhs), (and node:$lhs, node:$rhs), [{
Evan Cheng9123cfa2008-03-04 00:40:35 +0000489 return N->hasOneUse();
Chris Lattner21da6382008-02-19 17:37:35 +0000490}]>;
Dan Gohman744d4622009-04-13 16:09:41 +0000491// An 'srl' node with a single use.
492def srl_su : PatFrag<(ops node:$lhs, node:$rhs), (srl node:$lhs, node:$rhs), [{
493 return N->hasOneUse();
494}]>;
495// An 'trunc' node with a single use.
496def trunc_su : PatFrag<(ops node:$src), (trunc node:$src), [{
497 return N->hasOneUse();
498}]>;
Chris Lattner21da6382008-02-19 17:37:35 +0000499
Evan Cheng4621d272010-01-11 17:03:47 +0000500// Treat an 'or' node is as an 'add' if the or'ed bits are known to be zero.
501def or_is_add : PatFrag<(ops node:$lhs, node:$rhs), (or node:$lhs, node:$rhs),[{
502 if (ConstantSDNode *CN = dyn_cast<ConstantSDNode>(N->getOperand(1)))
503 return CurDAG->MaskedValueIsZero(N->getOperand(0), CN->getAPIntValue());
Evan Cheng503d9c52010-01-11 22:03:29 +0000504 else {
505 unsigned BitWidth = N->getValueType(0).getScalarType().getSizeInBits();
506 APInt Mask = APInt::getAllOnesValue(BitWidth);
507 APInt KnownZero0, KnownOne0;
508 CurDAG->ComputeMaskedBits(N->getOperand(0), Mask, KnownZero0, KnownOne0, 0);
509 APInt KnownZero1, KnownOne1;
510 CurDAG->ComputeMaskedBits(N->getOperand(1), Mask, KnownZero1, KnownOne1, 0);
511 return (~KnownZero0 & ~KnownZero1) == 0;
512 }
Evan Cheng4621d272010-01-11 17:03:47 +0000513}]>;
Evan Cheng4621d272010-01-11 17:03:47 +0000514
Dan Gohman921581d2008-10-17 01:23:35 +0000515// 'shld' and 'shrd' instruction patterns. Note that even though these have
516// the srl and shl in their patterns, the C++ code must still check for them,
517// because predicates are tested before children nodes are explored.
518
519def shrd : PatFrag<(ops node:$src1, node:$amt1, node:$src2, node:$amt2),
520 (or (srl node:$src1, node:$amt1),
521 (shl node:$src2, node:$amt2)), [{
522 assert(N->getOpcode() == ISD::OR);
523 return N->getOperand(0).getOpcode() == ISD::SRL &&
524 N->getOperand(1).getOpcode() == ISD::SHL &&
525 isa<ConstantSDNode>(N->getOperand(0).getOperand(1)) &&
526 isa<ConstantSDNode>(N->getOperand(1).getOperand(1)) &&
527 N->getOperand(0).getConstantOperandVal(1) ==
528 N->getValueSizeInBits(0) - N->getOperand(1).getConstantOperandVal(1);
529}]>;
530
531def shld : PatFrag<(ops node:$src1, node:$amt1, node:$src2, node:$amt2),
532 (or (shl node:$src1, node:$amt1),
533 (srl node:$src2, node:$amt2)), [{
534 assert(N->getOpcode() == ISD::OR);
535 return N->getOperand(0).getOpcode() == ISD::SHL &&
536 N->getOperand(1).getOpcode() == ISD::SRL &&
537 isa<ConstantSDNode>(N->getOperand(0).getOperand(1)) &&
538 isa<ConstantSDNode>(N->getOperand(1).getOperand(1)) &&
539 N->getOperand(0).getConstantOperandVal(1) ==
540 N->getValueSizeInBits(0) - N->getOperand(1).getConstantOperandVal(1);
541}]>;
542
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000543//===----------------------------------------------------------------------===//
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000544// Instruction list...
545//
546
547// ADJCALLSTACKDOWN/UP implicitly use/def ESP because they may be expanded into
548// a stack adjustment and the codegen must know that they may modify the stack
549// pointer before prolog-epilog rewriting occurs.
Chris Lattnerb56cc342008-03-11 03:23:40 +0000550// Pessimistically assume ADJCALLSTACKDOWN / ADJCALLSTACKUP will become
551// sub / add which can clobber EFLAGS.
Evan Cheng037364a2007-09-28 01:19:48 +0000552let Defs = [ESP, EFLAGS], Uses = [ESP] in {
Dan Gohman01c9f772008-10-01 18:28:06 +0000553def ADJCALLSTACKDOWN32 : I<0, Pseudo, (outs), (ins i32imm:$amt),
554 "#ADJCALLSTACKDOWN",
Chris Lattnerfe5d4022008-10-11 22:08:30 +0000555 [(X86callseq_start timm:$amt)]>,
Dan Gohman01c9f772008-10-01 18:28:06 +0000556 Requires<[In32BitMode]>;
557def ADJCALLSTACKUP32 : I<0, Pseudo, (outs), (ins i32imm:$amt1, i32imm:$amt2),
558 "#ADJCALLSTACKUP",
Chris Lattnerfe5d4022008-10-11 22:08:30 +0000559 [(X86callseq_end timm:$amt1, timm:$amt2)]>,
Dan Gohman01c9f772008-10-01 18:28:06 +0000560 Requires<[In32BitMode]>;
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000561}
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000562
Dan Gohman34228bf2009-08-15 01:38:56 +0000563// x86-64 va_start lowering magic.
Dan Gohman30afe012009-10-29 18:10:34 +0000564let usesCustomInserter = 1 in
Dan Gohman34228bf2009-08-15 01:38:56 +0000565def VASTART_SAVE_XMM_REGS : I<0, Pseudo,
566 (outs),
567 (ins GR8:$al,
568 i64imm:$regsavefi, i64imm:$offset,
569 variable_ops),
570 "#VASTART_SAVE_XMM_REGS $al, $regsavefi, $offset",
571 [(X86vastart_save_xmm_regs GR8:$al,
572 imm:$regsavefi,
573 imm:$offset)]>;
574
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000575// Nop
Sean Callananf94a0542009-07-23 23:39:34 +0000576let neverHasSideEffects = 1 in {
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000577 def NOOP : I<0x90, RawFrm, (outs), (ins), "nop", []>;
Sean Callanan2c48df22009-12-18 00:01:26 +0000578 def NOOPW : I<0x1f, MRM0m, (outs), (ins i16mem:$zero),
579 "nop{w}\t$zero", []>, TB, OpSize;
Sean Callananf94a0542009-07-23 23:39:34 +0000580 def NOOPL : I<0x1f, MRM0m, (outs), (ins i32mem:$zero),
Sean Callanan2c48df22009-12-18 00:01:26 +0000581 "nop{l}\t$zero", []>, TB;
Sean Callananf94a0542009-07-23 23:39:34 +0000582}
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000583
Sean Callanan9b195f82009-08-11 01:09:06 +0000584// Trap
Dan Gohman8112b942009-11-11 18:07:16 +0000585def INT3 : I<0xcc, RawFrm, (outs), (ins), "int\t3", []>;
Sean Callanan9b195f82009-08-11 01:09:06 +0000586def INT : I<0xcd, RawFrm, (outs), (ins i8imm:$trap), "int\t$trap", []>;
Sean Callanan2c48df22009-12-18 00:01:26 +0000587def IRET16 : I<0xcf, RawFrm, (outs), (ins), "iret{w}", []>, OpSize;
588def IRET32 : I<0xcf, RawFrm, (outs), (ins), "iret{l}", []>;
Sean Callanan9b195f82009-08-11 01:09:06 +0000589
Chris Lattner2aa10da2009-09-20 07:32:00 +0000590// PIC base construction. This expands to code that looks like this:
591// call $next_inst
592// popl %destreg"
Dan Gohman9499cfe2008-10-01 04:14:30 +0000593let neverHasSideEffects = 1, isNotDuplicable = 1, Uses = [ESP] in
Chris Lattnera7e959d2009-09-20 07:28:26 +0000594 def MOVPC32r : Ii32<0xE8, Pseudo, (outs GR32:$reg), (ins i32imm:$label),
Chris Lattner2aa10da2009-09-20 07:32:00 +0000595 "", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000596
597//===----------------------------------------------------------------------===//
598// Control Flow Instructions...
599//
600
601// Return instructions.
602let isTerminator = 1, isReturn = 1, isBarrier = 1,
Chris Lattnerb56cc342008-03-11 03:23:40 +0000603 hasCtrlDep = 1, FPForm = SpecialFP, FPFormBits = SpecialFP.Value in {
Dan Gohman2c4be2a2008-05-31 02:11:25 +0000604 def RET : I <0xC3, RawFrm, (outs), (ins variable_ops),
Chris Lattnerb56cc342008-03-11 03:23:40 +0000605 "ret",
Dan Gohman2c4be2a2008-05-31 02:11:25 +0000606 [(X86retflag 0)]>;
Chris Lattnerb56cc342008-03-11 03:23:40 +0000607 def RETI : Ii16<0xC2, RawFrm, (outs), (ins i16imm:$amt, variable_ops),
608 "ret\t$amt",
Dan Gohmane84197b2009-09-03 17:18:51 +0000609 [(X86retflag timm:$amt)]>;
Sean Callanan7a012572009-09-15 23:37:51 +0000610 def LRET : I <0xCB, RawFrm, (outs), (ins),
611 "lret", []>;
612 def LRETI : Ii16<0xCA, RawFrm, (outs), (ins i16imm:$amt),
613 "lret\t$amt", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000614}
615
616// All branches are RawFrm, Void, Branch, and Terminators
Evan Cheng37e7c752007-07-21 00:34:19 +0000617let isBranch = 1, isTerminator = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +0000618 class IBr<bits<8> opcode, dag ins, string asm, list<dag> pattern> :
619 I<opcode, RawFrm, (outs), ins, asm, pattern>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000620
Sean Callananc0608152009-07-22 01:05:20 +0000621let isBranch = 1, isBarrier = 1 in {
Dan Gohman91888f02007-07-31 20:11:57 +0000622 def JMP : IBr<0xE9, (ins brtarget:$dst), "jmp\t$dst", [(br bb:$dst)]>;
Sean Callananc0608152009-07-22 01:05:20 +0000623 def JMP8 : IBr<0xEB, (ins brtarget8:$dst), "jmp\t$dst", []>;
624}
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000625
Owen Andersonf8053082007-11-12 07:39:39 +0000626// Indirect branches
627let isBranch = 1, isTerminator = 1, isBarrier = 1, isIndirectBranch = 1 in {
Dan Gohman91888f02007-07-31 20:11:57 +0000628 def JMP32r : I<0xFF, MRM4r, (outs), (ins GR32:$dst), "jmp{l}\t{*}$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000629 [(brind GR32:$dst)]>;
Dan Gohman91888f02007-07-31 20:11:57 +0000630 def JMP32m : I<0xFF, MRM4m, (outs), (ins i32mem:$dst), "jmp{l}\t{*}$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000631 [(brind (loadi32 addr:$dst))]>;
Sean Callananb7e73392009-09-15 00:35:17 +0000632
633 def FARJMP16i : Iseg16<0xEA, RawFrm, (outs),
634 (ins i16imm:$seg, i16imm:$off),
635 "ljmp{w}\t$seg, $off", []>, OpSize;
636 def FARJMP32i : Iseg32<0xEA, RawFrm, (outs),
637 (ins i16imm:$seg, i32imm:$off),
638 "ljmp{l}\t$seg, $off", []>;
639
640 def FARJMP16m : I<0xFF, MRM5m, (outs), (ins opaque32mem:$dst),
Sean Callanan66fdfa02009-09-03 00:04:47 +0000641 "ljmp{w}\t{*}$dst", []>, OpSize;
Sean Callananb7e73392009-09-15 00:35:17 +0000642 def FARJMP32m : I<0xFF, MRM5m, (outs), (ins opaque48mem:$dst),
Sean Callanan66fdfa02009-09-03 00:04:47 +0000643 "ljmp{l}\t{*}$dst", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000644}
645
646// Conditional branches
Evan Cheng950aac02007-09-25 01:57:46 +0000647let Uses = [EFLAGS] in {
Evan Chengd11052b2009-07-21 06:00:18 +0000648// Short conditional jumps
649def JO8 : IBr<0x70, (ins brtarget8:$dst), "jo\t$dst", []>;
650def JNO8 : IBr<0x71, (ins brtarget8:$dst), "jno\t$dst", []>;
651def JB8 : IBr<0x72, (ins brtarget8:$dst), "jb\t$dst", []>;
652def JAE8 : IBr<0x73, (ins brtarget8:$dst), "jae\t$dst", []>;
653def JE8 : IBr<0x74, (ins brtarget8:$dst), "je\t$dst", []>;
654def JNE8 : IBr<0x75, (ins brtarget8:$dst), "jne\t$dst", []>;
655def JBE8 : IBr<0x76, (ins brtarget8:$dst), "jbe\t$dst", []>;
656def JA8 : IBr<0x77, (ins brtarget8:$dst), "ja\t$dst", []>;
657def JS8 : IBr<0x78, (ins brtarget8:$dst), "js\t$dst", []>;
658def JNS8 : IBr<0x79, (ins brtarget8:$dst), "jns\t$dst", []>;
659def JP8 : IBr<0x7A, (ins brtarget8:$dst), "jp\t$dst", []>;
660def JNP8 : IBr<0x7B, (ins brtarget8:$dst), "jnp\t$dst", []>;
661def JL8 : IBr<0x7C, (ins brtarget8:$dst), "jl\t$dst", []>;
662def JGE8 : IBr<0x7D, (ins brtarget8:$dst), "jge\t$dst", []>;
663def JLE8 : IBr<0x7E, (ins brtarget8:$dst), "jle\t$dst", []>;
664def JG8 : IBr<0x7F, (ins brtarget8:$dst), "jg\t$dst", []>;
665
666def JCXZ8 : IBr<0xE3, (ins brtarget8:$dst), "jcxz\t$dst", []>;
667
Dan Gohman91888f02007-07-31 20:11:57 +0000668def JE : IBr<0x84, (ins brtarget:$dst), "je\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000669 [(X86brcond bb:$dst, X86_COND_E, EFLAGS)]>, TB;
Dan Gohman91888f02007-07-31 20:11:57 +0000670def JNE : IBr<0x85, (ins brtarget:$dst), "jne\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000671 [(X86brcond bb:$dst, X86_COND_NE, EFLAGS)]>, TB;
Dan Gohman91888f02007-07-31 20:11:57 +0000672def JL : IBr<0x8C, (ins brtarget:$dst), "jl\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000673 [(X86brcond bb:$dst, X86_COND_L, EFLAGS)]>, TB;
Dan Gohman91888f02007-07-31 20:11:57 +0000674def JLE : IBr<0x8E, (ins brtarget:$dst), "jle\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000675 [(X86brcond bb:$dst, X86_COND_LE, EFLAGS)]>, TB;
Dan Gohman91888f02007-07-31 20:11:57 +0000676def JG : IBr<0x8F, (ins brtarget:$dst), "jg\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000677 [(X86brcond bb:$dst, X86_COND_G, EFLAGS)]>, TB;
Dan Gohman91888f02007-07-31 20:11:57 +0000678def JGE : IBr<0x8D, (ins brtarget:$dst), "jge\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000679 [(X86brcond bb:$dst, X86_COND_GE, EFLAGS)]>, TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000680
Dan Gohman91888f02007-07-31 20:11:57 +0000681def JB : IBr<0x82, (ins brtarget:$dst), "jb\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000682 [(X86brcond bb:$dst, X86_COND_B, EFLAGS)]>, TB;
Dan Gohman91888f02007-07-31 20:11:57 +0000683def JBE : IBr<0x86, (ins brtarget:$dst), "jbe\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000684 [(X86brcond bb:$dst, X86_COND_BE, EFLAGS)]>, TB;
Dan Gohman91888f02007-07-31 20:11:57 +0000685def JA : IBr<0x87, (ins brtarget:$dst), "ja\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000686 [(X86brcond bb:$dst, X86_COND_A, EFLAGS)]>, TB;
Dan Gohman91888f02007-07-31 20:11:57 +0000687def JAE : IBr<0x83, (ins brtarget:$dst), "jae\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000688 [(X86brcond bb:$dst, X86_COND_AE, EFLAGS)]>, TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000689
Dan Gohman91888f02007-07-31 20:11:57 +0000690def JS : IBr<0x88, (ins brtarget:$dst), "js\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000691 [(X86brcond bb:$dst, X86_COND_S, EFLAGS)]>, TB;
Dan Gohman91888f02007-07-31 20:11:57 +0000692def JNS : IBr<0x89, (ins brtarget:$dst), "jns\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000693 [(X86brcond bb:$dst, X86_COND_NS, EFLAGS)]>, TB;
Dan Gohman91888f02007-07-31 20:11:57 +0000694def JP : IBr<0x8A, (ins brtarget:$dst), "jp\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000695 [(X86brcond bb:$dst, X86_COND_P, EFLAGS)]>, TB;
Dan Gohman91888f02007-07-31 20:11:57 +0000696def JNP : IBr<0x8B, (ins brtarget:$dst), "jnp\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000697 [(X86brcond bb:$dst, X86_COND_NP, EFLAGS)]>, TB;
Dan Gohman91888f02007-07-31 20:11:57 +0000698def JO : IBr<0x80, (ins brtarget:$dst), "jo\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000699 [(X86brcond bb:$dst, X86_COND_O, EFLAGS)]>, TB;
Dan Gohman91888f02007-07-31 20:11:57 +0000700def JNO : IBr<0x81, (ins brtarget:$dst), "jno\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000701 [(X86brcond bb:$dst, X86_COND_NO, EFLAGS)]>, TB;
Evan Cheng950aac02007-09-25 01:57:46 +0000702} // Uses = [EFLAGS]
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000703
Sean Callanan503784b2009-09-16 21:50:07 +0000704// Loop instructions
705
706def LOOP : I<0xE2, RawFrm, (ins brtarget8:$dst), (outs), "loop\t$dst", []>;
707def LOOPE : I<0xE1, RawFrm, (ins brtarget8:$dst), (outs), "loope\t$dst", []>;
708def LOOPNE : I<0xE0, RawFrm, (ins brtarget8:$dst), (outs), "loopne\t$dst", []>;
709
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000710//===----------------------------------------------------------------------===//
711// Call Instructions...
712//
Evan Cheng37e7c752007-07-21 00:34:19 +0000713let isCall = 1 in
Dan Gohman01c9f772008-10-01 18:28:06 +0000714 // All calls clobber the non-callee saved registers. ESP is marked as
715 // a use to prevent stack-pointer assignments that appear immediately
716 // before calls from potentially appearing dead. Uses for argument
717 // registers are added manually.
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000718 let Defs = [EAX, ECX, EDX, FP0, FP1, FP2, FP3, FP4, FP5, FP6, ST0,
719 MM0, MM1, MM2, MM3, MM4, MM5, MM6, MM7,
Evan Cheng2293b252008-10-17 21:02:22 +0000720 XMM0, XMM1, XMM2, XMM3, XMM4, XMM5, XMM6, XMM7,
721 XMM8, XMM9, XMM10, XMM11, XMM12, XMM13, XMM14, XMM15, EFLAGS],
Dan Gohman9499cfe2008-10-01 04:14:30 +0000722 Uses = [ESP] in {
Chris Lattner357a0ca2009-06-20 19:34:09 +0000723 def CALLpcrel32 : Ii32<0xE8, RawFrm,
724 (outs), (ins i32imm_pcrel:$dst,variable_ops),
725 "call\t$dst", []>;
Evan Chengb783fa32007-07-19 01:14:50 +0000726 def CALL32r : I<0xFF, MRM2r, (outs), (ins GR32:$dst, variable_ops),
Dan Gohman91888f02007-07-31 20:11:57 +0000727 "call\t{*}$dst", [(X86call GR32:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000728 def CALL32m : I<0xFF, MRM2m, (outs), (ins i32mem:$dst, variable_ops),
Dan Gohmanea4faba2008-05-29 21:50:34 +0000729 "call\t{*}$dst", [(X86call (loadi32 addr:$dst))]>;
Sean Callanan66fdfa02009-09-03 00:04:47 +0000730
Sean Callananb7e73392009-09-15 00:35:17 +0000731 def FARCALL16i : Iseg16<0x9A, RawFrm, (outs),
732 (ins i16imm:$seg, i16imm:$off),
733 "lcall{w}\t$seg, $off", []>, OpSize;
734 def FARCALL32i : Iseg32<0x9A, RawFrm, (outs),
735 (ins i16imm:$seg, i32imm:$off),
736 "lcall{l}\t$seg, $off", []>;
737
738 def FARCALL16m : I<0xFF, MRM3m, (outs), (ins opaque32mem:$dst),
Sean Callanan66fdfa02009-09-03 00:04:47 +0000739 "lcall{w}\t{*}$dst", []>, OpSize;
Sean Callananb7e73392009-09-15 00:35:17 +0000740 def FARCALL32m : I<0xFF, MRM3m, (outs), (ins opaque48mem:$dst),
Sean Callanan66fdfa02009-09-03 00:04:47 +0000741 "lcall{l}\t{*}$dst", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000742 }
743
Sean Callanan51b7a992009-09-16 02:57:13 +0000744// Constructing a stack frame.
745
746def ENTER : I<0xC8, RawFrm, (outs), (ins i16imm:$len, i8imm:$lvl),
747 "enter\t$len, $lvl", []>;
748
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000749// Tail call stuff.
Arnold Schwaighofere2d6bbb2007-10-11 19:40:01 +0000750
Evan Cheng37e7c752007-07-21 00:34:19 +0000751let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1 in
Sean Callanan2c48df22009-12-18 00:01:26 +0000752def TCRETURNdi : I<0, Pseudo, (outs),
753 (ins i32imm:$dst, i32imm:$offset, variable_ops),
Arnold Schwaighofere2d6bbb2007-10-11 19:40:01 +0000754 "#TC_RETURN $dst $offset",
755 []>;
756
757let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1 in
Sean Callanan2c48df22009-12-18 00:01:26 +0000758def TCRETURNri : I<0, Pseudo, (outs),
759 (ins GR32:$dst, i32imm:$offset, variable_ops),
Arnold Schwaighofere2d6bbb2007-10-11 19:40:01 +0000760 "#TC_RETURN $dst $offset",
761 []>;
762
763let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1 in
Chris Lattner357a0ca2009-06-20 19:34:09 +0000764 def TAILJMPd : IBr<0xE9, (ins i32imm_pcrel:$dst), "jmp\t$dst # TAILCALL",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000765 []>;
Evan Cheng37e7c752007-07-21 00:34:19 +0000766let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1 in
Sean Callanan2c48df22009-12-18 00:01:26 +0000767 def TAILJMPr : I<0xFF, MRM4r, (outs), (ins GR32:$dst),
768 "jmp{l}\t{*}$dst # TAILCALL",
Arnold Schwaighofere2d6bbb2007-10-11 19:40:01 +0000769 []>;
Evan Cheng37e7c752007-07-21 00:34:19 +0000770let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +0000771 def TAILJMPm : I<0xFF, MRM4m, (outs), (ins i32mem:$dst),
Arnold Schwaighofere2d6bbb2007-10-11 19:40:01 +0000772 "jmp\t{*}$dst # TAILCALL", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000773
774//===----------------------------------------------------------------------===//
775// Miscellaneous Instructions...
776//
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000777let Defs = [EBP, ESP], Uses = [EBP, ESP], mayLoad = 1, neverHasSideEffects=1 in
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000778def LEAVE : I<0xC9, RawFrm,
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000779 (outs), (ins), "leave", []>;
780
Sean Callanan2c48df22009-12-18 00:01:26 +0000781def POPCNT16rr : I<0xB8, MRMSrcReg, (outs GR16:$dst), (ins GR16:$src),
782 "popcnt{w}\t{$src, $dst|$dst, $src}", []>, OpSize, XS;
783def POPCNT16rm : I<0xB8, MRMSrcMem, (outs GR16:$dst), (ins i16mem:$src),
784 "popcnt{w}\t{$src, $dst|$dst, $src}", []>, OpSize, XS;
785def POPCNT32rr : I<0xB8, MRMSrcReg, (outs GR32:$dst), (ins GR32:$src),
786 "popcnt{l}\t{$src, $dst|$dst, $src}", []>, XS;
787def POPCNT32rm : I<0xB8, MRMSrcMem, (outs GR32:$dst), (ins i32mem:$src),
788 "popcnt{l}\t{$src, $dst|$dst, $src}", []>, XS;
789
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000790let Defs = [ESP], Uses = [ESP], neverHasSideEffects=1 in {
Sean Callanan9f3c3f52009-09-10 18:29:13 +0000791let mayLoad = 1 in {
792def POP16r : I<0x58, AddRegFrm, (outs GR16:$reg), (ins), "pop{w}\t$reg", []>,
793 OpSize;
794def POP32r : I<0x58, AddRegFrm, (outs GR32:$reg), (ins), "pop{l}\t$reg", []>;
795def POP16rmr: I<0x8F, MRM0r, (outs GR16:$reg), (ins), "pop{w}\t$reg", []>,
796 OpSize;
797def POP16rmm: I<0x8F, MRM0m, (outs i16mem:$dst), (ins), "pop{w}\t$dst", []>,
798 OpSize;
799def POP32rmr: I<0x8F, MRM0r, (outs GR32:$reg), (ins), "pop{l}\t$reg", []>;
800def POP32rmm: I<0x8F, MRM0m, (outs i32mem:$dst), (ins), "pop{l}\t$dst", []>;
801}
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000802
Sean Callanan9f3c3f52009-09-10 18:29:13 +0000803let mayStore = 1 in {
804def PUSH16r : I<0x50, AddRegFrm, (outs), (ins GR16:$reg), "push{w}\t$reg",[]>,
805 OpSize;
Evan Chengd8434332007-09-26 01:29:06 +0000806def PUSH32r : I<0x50, AddRegFrm, (outs), (ins GR32:$reg), "push{l}\t$reg",[]>;
Sean Callanan9f3c3f52009-09-10 18:29:13 +0000807def PUSH16rmr: I<0xFF, MRM6r, (outs), (ins GR16:$reg), "push{w}\t$reg",[]>,
808 OpSize;
809def PUSH16rmm: I<0xFF, MRM6m, (outs), (ins i16mem:$src), "push{w}\t$src",[]>,
810 OpSize;
811def PUSH32rmr: I<0xFF, MRM6r, (outs), (ins GR32:$reg), "push{l}\t$reg",[]>;
812def PUSH32rmm: I<0xFF, MRM6m, (outs), (ins i32mem:$src), "push{l}\t$src",[]>;
813}
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000814}
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000815
Bill Wendling4c2638c2009-06-15 19:39:04 +0000816let Defs = [ESP], Uses = [ESP], neverHasSideEffects = 1, mayStore = 1 in {
817def PUSH32i8 : Ii8<0x6a, RawFrm, (outs), (ins i8imm:$imm),
Bill Wendling0b0437f2009-06-15 20:59:31 +0000818 "push{l}\t$imm", []>;
Bill Wendling4c2638c2009-06-15 19:39:04 +0000819def PUSH32i16 : Ii16<0x68, RawFrm, (outs), (ins i16imm:$imm),
Bill Wendling0b0437f2009-06-15 20:59:31 +0000820 "push{l}\t$imm", []>;
Bill Wendling4c2638c2009-06-15 19:39:04 +0000821def PUSH32i32 : Ii32<0x68, RawFrm, (outs), (ins i32imm:$imm),
Bill Wendling0b0437f2009-06-15 20:59:31 +0000822 "push{l}\t$imm", []>;
Bill Wendling4c2638c2009-06-15 19:39:04 +0000823}
824
Sean Callanan2c48df22009-12-18 00:01:26 +0000825let Defs = [ESP, EFLAGS], Uses = [ESP], mayLoad = 1, neverHasSideEffects=1 in {
826def POPF : I<0x9D, RawFrm, (outs), (ins), "popf{w}", []>, OpSize;
827def POPFD : I<0x9D, RawFrm, (outs), (ins), "popf{l}", []>;
828}
829let Defs = [ESP], Uses = [ESP, EFLAGS], mayStore = 1, neverHasSideEffects=1 in {
830def PUSHF : I<0x9C, RawFrm, (outs), (ins), "pushf{w}", []>, OpSize;
831def PUSHFD : I<0x9C, RawFrm, (outs), (ins), "pushf{l}", []>;
832}
Evan Chengd8434332007-09-26 01:29:06 +0000833
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000834let isTwoAddress = 1 in // GR32 = bswap GR32
835 def BSWAP32r : I<0xC8, AddRegFrm,
Evan Chengb783fa32007-07-19 01:14:50 +0000836 (outs GR32:$dst), (ins GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000837 "bswap{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000838 [(set GR32:$dst, (bswap GR32:$src))]>, TB;
839
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000840
Evan Cheng48679f42007-12-14 02:13:44 +0000841// Bit scan instructions.
842let Defs = [EFLAGS] in {
Evan Cheng4e33de92007-12-14 18:49:43 +0000843def BSF16rr : I<0xBC, MRMSrcReg, (outs GR16:$dst), (ins GR16:$src),
Dan Gohmancdb54c62007-12-14 15:10:00 +0000844 "bsf{w}\t{$src, $dst|$dst, $src}",
Evan Cheng7cfbfe32007-12-14 08:30:15 +0000845 [(set GR16:$dst, (X86bsf GR16:$src)), (implicit EFLAGS)]>, TB;
Evan Cheng48679f42007-12-14 02:13:44 +0000846def BSF16rm : I<0xBC, MRMSrcMem, (outs GR16:$dst), (ins i16mem:$src),
Dan Gohmancdb54c62007-12-14 15:10:00 +0000847 "bsf{w}\t{$src, $dst|$dst, $src}",
Evan Cheng7cfbfe32007-12-14 08:30:15 +0000848 [(set GR16:$dst, (X86bsf (loadi16 addr:$src))),
849 (implicit EFLAGS)]>, TB;
Evan Cheng4e33de92007-12-14 18:49:43 +0000850def BSF32rr : I<0xBC, MRMSrcReg, (outs GR32:$dst), (ins GR32:$src),
Dan Gohmancdb54c62007-12-14 15:10:00 +0000851 "bsf{l}\t{$src, $dst|$dst, $src}",
Evan Cheng7cfbfe32007-12-14 08:30:15 +0000852 [(set GR32:$dst, (X86bsf GR32:$src)), (implicit EFLAGS)]>, TB;
Evan Cheng48679f42007-12-14 02:13:44 +0000853def BSF32rm : I<0xBC, MRMSrcMem, (outs GR32:$dst), (ins i32mem:$src),
Dan Gohmancdb54c62007-12-14 15:10:00 +0000854 "bsf{l}\t{$src, $dst|$dst, $src}",
Evan Cheng7cfbfe32007-12-14 08:30:15 +0000855 [(set GR32:$dst, (X86bsf (loadi32 addr:$src))),
856 (implicit EFLAGS)]>, TB;
Evan Cheng48679f42007-12-14 02:13:44 +0000857
Evan Cheng4e33de92007-12-14 18:49:43 +0000858def BSR16rr : I<0xBD, MRMSrcReg, (outs GR16:$dst), (ins GR16:$src),
Dan Gohmancdb54c62007-12-14 15:10:00 +0000859 "bsr{w}\t{$src, $dst|$dst, $src}",
Evan Cheng7cfbfe32007-12-14 08:30:15 +0000860 [(set GR16:$dst, (X86bsr GR16:$src)), (implicit EFLAGS)]>, TB;
Evan Cheng48679f42007-12-14 02:13:44 +0000861def BSR16rm : I<0xBD, MRMSrcMem, (outs GR16:$dst), (ins i16mem:$src),
Dan Gohmancdb54c62007-12-14 15:10:00 +0000862 "bsr{w}\t{$src, $dst|$dst, $src}",
Evan Cheng7cfbfe32007-12-14 08:30:15 +0000863 [(set GR16:$dst, (X86bsr (loadi16 addr:$src))),
864 (implicit EFLAGS)]>, TB;
Evan Cheng4e33de92007-12-14 18:49:43 +0000865def BSR32rr : I<0xBD, MRMSrcReg, (outs GR32:$dst), (ins GR32:$src),
Dan Gohmancdb54c62007-12-14 15:10:00 +0000866 "bsr{l}\t{$src, $dst|$dst, $src}",
Evan Cheng7cfbfe32007-12-14 08:30:15 +0000867 [(set GR32:$dst, (X86bsr GR32:$src)), (implicit EFLAGS)]>, TB;
Evan Cheng48679f42007-12-14 02:13:44 +0000868def BSR32rm : I<0xBD, MRMSrcMem, (outs GR32:$dst), (ins i32mem:$src),
Dan Gohmancdb54c62007-12-14 15:10:00 +0000869 "bsr{l}\t{$src, $dst|$dst, $src}",
Evan Cheng7cfbfe32007-12-14 08:30:15 +0000870 [(set GR32:$dst, (X86bsr (loadi32 addr:$src))),
871 (implicit EFLAGS)]>, TB;
Evan Cheng48679f42007-12-14 02:13:44 +0000872} // Defs = [EFLAGS]
873
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000874let neverHasSideEffects = 1 in
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000875def LEA16r : I<0x8D, MRMSrcMem,
Evan Chengca348202009-12-12 18:51:56 +0000876 (outs GR16:$dst), (ins lea32mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000877 "lea{w}\t{$src|$dst}, {$dst|$src}", []>, OpSize;
Evan Cheng1ea8e6b2008-03-27 01:41:09 +0000878let isReMaterializable = 1 in
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000879def LEA32r : I<0x8D, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +0000880 (outs GR32:$dst), (ins lea32mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000881 "lea{l}\t{$src|$dst}, {$dst|$src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000882 [(set GR32:$dst, lea32addr:$src)]>, Requires<[In32BitMode]>;
883
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000884let Defs = [ECX,EDI,ESI], Uses = [ECX,EDI,ESI] in {
Evan Chengb783fa32007-07-19 01:14:50 +0000885def REP_MOVSB : I<0xA4, RawFrm, (outs), (ins), "{rep;movsb|rep movsb}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000886 [(X86rep_movs i8)]>, REP;
Evan Chengb783fa32007-07-19 01:14:50 +0000887def REP_MOVSW : I<0xA5, RawFrm, (outs), (ins), "{rep;movsw|rep movsw}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000888 [(X86rep_movs i16)]>, REP, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +0000889def REP_MOVSD : I<0xA5, RawFrm, (outs), (ins), "{rep;movsl|rep movsd}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000890 [(X86rep_movs i32)]>, REP;
891}
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000892
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000893let Defs = [ECX,EDI], Uses = [AL,ECX,EDI] in
Evan Chengb783fa32007-07-19 01:14:50 +0000894def REP_STOSB : I<0xAA, RawFrm, (outs), (ins), "{rep;stosb|rep stosb}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000895 [(X86rep_stos i8)]>, REP;
896let Defs = [ECX,EDI], Uses = [AX,ECX,EDI] in
Evan Chengb783fa32007-07-19 01:14:50 +0000897def REP_STOSW : I<0xAB, RawFrm, (outs), (ins), "{rep;stosw|rep stosw}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000898 [(X86rep_stos i16)]>, REP, OpSize;
899let Defs = [ECX,EDI], Uses = [EAX,ECX,EDI] in
Evan Chengb783fa32007-07-19 01:14:50 +0000900def REP_STOSD : I<0xAB, RawFrm, (outs), (ins), "{rep;stosl|rep stosd}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000901 [(X86rep_stos i32)]>, REP;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000902
Sean Callanan481f06d2009-09-12 00:37:19 +0000903def SCAS8 : I<0xAE, RawFrm, (outs), (ins), "scas{b}", []>;
904def SCAS16 : I<0xAF, RawFrm, (outs), (ins), "scas{w}", []>, OpSize;
905def SCAS32 : I<0xAF, RawFrm, (outs), (ins), "scas{l}", []>;
906
Sean Callanan25220d62009-09-12 02:25:20 +0000907def CMPS8 : I<0xA6, RawFrm, (outs), (ins), "cmps{b}", []>;
908def CMPS16 : I<0xA7, RawFrm, (outs), (ins), "cmps{w}", []>, OpSize;
909def CMPS32 : I<0xA7, RawFrm, (outs), (ins), "cmps{l}", []>;
910
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000911let Defs = [RAX, RDX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000912def RDTSC : I<0x31, RawFrm, (outs), (ins), "rdtsc", [(X86rdtsc)]>,
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000913 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000914
Anton Korobeynikov39d40ba2008-01-15 07:02:33 +0000915let isBarrier = 1, hasCtrlDep = 1 in {
Chris Lattner56b941f2008-01-15 21:58:22 +0000916def TRAP : I<0x0B, RawFrm, (outs), (ins), "ud2", [(trap)]>, TB;
Anton Korobeynikov39d40ba2008-01-15 07:02:33 +0000917}
918
Chris Lattnerc96e27c2009-08-11 16:58:39 +0000919def SYSCALL : I<0x05, RawFrm,
920 (outs), (ins), "syscall", []>, TB;
921def SYSRET : I<0x07, RawFrm,
922 (outs), (ins), "sysret", []>, TB;
923def SYSENTER : I<0x34, RawFrm,
924 (outs), (ins), "sysenter", []>, TB;
925def SYSEXIT : I<0x35, RawFrm,
926 (outs), (ins), "sysexit", []>, TB;
927
Sean Callanan2c2313a2009-09-12 02:52:41 +0000928def WAIT : I<0x9B, RawFrm, (outs), (ins), "wait", []>;
Chris Lattnerc96e27c2009-08-11 16:58:39 +0000929
930
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000931//===----------------------------------------------------------------------===//
932// Input/Output Instructions...
933//
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000934let Defs = [AL], Uses = [DX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000935def IN8rr : I<0xEC, RawFrm, (outs), (ins),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000936 "in{b}\t{%dx, %al|%AL, %DX}", []>;
937let Defs = [AX], Uses = [DX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000938def IN16rr : I<0xED, RawFrm, (outs), (ins),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000939 "in{w}\t{%dx, %ax|%AX, %DX}", []>, OpSize;
940let Defs = [EAX], Uses = [DX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000941def IN32rr : I<0xED, RawFrm, (outs), (ins),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000942 "in{l}\t{%dx, %eax|%EAX, %DX}", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000943
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000944let Defs = [AL] in
Evan Chengb783fa32007-07-19 01:14:50 +0000945def IN8ri : Ii8<0xE4, RawFrm, (outs), (ins i16i8imm:$port),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000946 "in{b}\t{$port, %al|%AL, $port}", []>;
947let Defs = [AX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000948def IN16ri : Ii8<0xE5, RawFrm, (outs), (ins i16i8imm:$port),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000949 "in{w}\t{$port, %ax|%AX, $port}", []>, OpSize;
950let Defs = [EAX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000951def IN32ri : Ii8<0xE5, RawFrm, (outs), (ins i16i8imm:$port),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000952 "in{l}\t{$port, %eax|%EAX, $port}", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000953
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000954let Uses = [DX, AL] in
Evan Chengb783fa32007-07-19 01:14:50 +0000955def OUT8rr : I<0xEE, RawFrm, (outs), (ins),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000956 "out{b}\t{%al, %dx|%DX, %AL}", []>;
957let Uses = [DX, AX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000958def OUT16rr : I<0xEF, RawFrm, (outs), (ins),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000959 "out{w}\t{%ax, %dx|%DX, %AX}", []>, OpSize;
960let Uses = [DX, EAX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000961def OUT32rr : I<0xEF, RawFrm, (outs), (ins),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000962 "out{l}\t{%eax, %dx|%DX, %EAX}", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000963
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000964let Uses = [AL] in
Evan Chengb783fa32007-07-19 01:14:50 +0000965def OUT8ir : Ii8<0xE6, RawFrm, (outs), (ins i16i8imm:$port),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000966 "out{b}\t{%al, $port|$port, %AL}", []>;
967let Uses = [AX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000968def OUT16ir : Ii8<0xE7, RawFrm, (outs), (ins i16i8imm:$port),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000969 "out{w}\t{%ax, $port|$port, %AX}", []>, OpSize;
970let Uses = [EAX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000971def OUT32ir : Ii8<0xE7, RawFrm, (outs), (ins i16i8imm:$port),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000972 "out{l}\t{%eax, $port|$port, %EAX}", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000973
Sean Callanan2c48df22009-12-18 00:01:26 +0000974def IN8 : I<0x6C, RawFrm, (outs), (ins),
975 "ins{b}", []>;
976def IN16 : I<0x6D, RawFrm, (outs), (ins),
977 "ins{w}", []>, OpSize;
978def IN32 : I<0x6D, RawFrm, (outs), (ins),
979 "ins{l}", []>;
980
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000981//===----------------------------------------------------------------------===//
982// Move Instructions...
983//
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000984let neverHasSideEffects = 1 in {
Evan Chengb783fa32007-07-19 01:14:50 +0000985def MOV8rr : I<0x88, MRMDestReg, (outs GR8 :$dst), (ins GR8 :$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000986 "mov{b}\t{$src, $dst|$dst, $src}", []>;
Evan Chengb783fa32007-07-19 01:14:50 +0000987def MOV16rr : I<0x89, MRMDestReg, (outs GR16:$dst), (ins GR16:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000988 "mov{w}\t{$src, $dst|$dst, $src}", []>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +0000989def MOV32rr : I<0x89, MRMDestReg, (outs GR32:$dst), (ins GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000990 "mov{l}\t{$src, $dst|$dst, $src}", []>;
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000991}
Evan Cheng6f26e8b2008-06-18 08:13:07 +0000992let isReMaterializable = 1, isAsCheapAsAMove = 1 in {
Evan Chengb783fa32007-07-19 01:14:50 +0000993def MOV8ri : Ii8 <0xB0, AddRegFrm, (outs GR8 :$dst), (ins i8imm :$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000994 "mov{b}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000995 [(set GR8:$dst, imm:$src)]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000996def MOV16ri : Ii16<0xB8, AddRegFrm, (outs GR16:$dst), (ins i16imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000997 "mov{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000998 [(set GR16:$dst, imm:$src)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +0000999def MOV32ri : Ii32<0xB8, AddRegFrm, (outs GR32:$dst), (ins i32imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001000 "mov{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001001 [(set GR32:$dst, imm:$src)]>;
1002}
Evan Chengb783fa32007-07-19 01:14:50 +00001003def MOV8mi : Ii8 <0xC6, MRM0m, (outs), (ins i8mem :$dst, i8imm :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001004 "mov{b}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001005 [(store (i8 imm:$src), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001006def MOV16mi : Ii16<0xC7, MRM0m, (outs), (ins i16mem:$dst, i16imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001007 "mov{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001008 [(store (i16 imm:$src), addr:$dst)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001009def MOV32mi : Ii32<0xC7, MRM0m, (outs), (ins i32mem:$dst, i32imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001010 "mov{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001011 [(store (i32 imm:$src), addr:$dst)]>;
1012
Sean Callanan2c48df22009-12-18 00:01:26 +00001013def MOV8o8a : Ii8 <0xA0, RawFrm, (outs), (ins offset8:$src),
Sean Callanan70953a52009-09-10 18:33:42 +00001014 "mov{b}\t{$src, %al|%al, $src}", []>;
Sean Callanan2c48df22009-12-18 00:01:26 +00001015def MOV16o16a : Ii16 <0xA1, RawFrm, (outs), (ins offset16:$src),
Sean Callanan70953a52009-09-10 18:33:42 +00001016 "mov{w}\t{$src, %ax|%ax, $src}", []>, OpSize;
Sean Callanan2c48df22009-12-18 00:01:26 +00001017def MOV32o32a : Ii32 <0xA1, RawFrm, (outs), (ins offset32:$src),
Sean Callanan70953a52009-09-10 18:33:42 +00001018 "mov{l}\t{$src, %eax|%eax, $src}", []>;
1019
Sean Callanan2c48df22009-12-18 00:01:26 +00001020def MOV8ao8 : Ii8 <0xA2, RawFrm, (outs offset8:$dst), (ins),
Sean Callanan70953a52009-09-10 18:33:42 +00001021 "mov{b}\t{%al, $dst|$dst, %al}", []>;
Sean Callanan2c48df22009-12-18 00:01:26 +00001022def MOV16ao16 : Ii16 <0xA3, RawFrm, (outs offset16:$dst), (ins),
Sean Callanan70953a52009-09-10 18:33:42 +00001023 "mov{w}\t{%ax, $dst|$dst, %ax}", []>, OpSize;
Sean Callanan2c48df22009-12-18 00:01:26 +00001024def MOV32ao32 : Ii32 <0xA3, RawFrm, (outs offset32:$dst), (ins),
Sean Callanan70953a52009-09-10 18:33:42 +00001025 "mov{l}\t{%eax, $dst|$dst, %eax}", []>;
1026
Sean Callananad87a3a2009-09-15 18:47:29 +00001027// Moves to and from segment registers
1028def MOV16rs : I<0x8C, MRMDestReg, (outs GR16:$dst), (ins SEGMENT_REG:$src),
1029 "mov{w}\t{$src, $dst|$dst, $src}", []>;
1030def MOV16ms : I<0x8C, MRMDestMem, (outs i16mem:$dst), (ins SEGMENT_REG:$src),
1031 "mov{w}\t{$src, $dst|$dst, $src}", []>;
1032def MOV16sr : I<0x8E, MRMSrcReg, (outs SEGMENT_REG:$dst), (ins GR16:$src),
1033 "mov{w}\t{$src, $dst|$dst, $src}", []>;
1034def MOV16sm : I<0x8E, MRMSrcMem, (outs SEGMENT_REG:$dst), (ins i16mem:$src),
1035 "mov{w}\t{$src, $dst|$dst, $src}", []>;
1036
Sean Callanan2c48df22009-12-18 00:01:26 +00001037def MOV8rr_REV : I<0x8A, MRMSrcReg, (outs GR8:$dst), (ins GR8:$src),
1038 "mov{b}\t{$src, $dst|$dst, $src}", []>;
1039def MOV16rr_REV : I<0x8B, MRMSrcReg, (outs GR16:$dst), (ins GR16:$src),
1040 "mov{w}\t{$src, $dst|$dst, $src}", []>, OpSize;
1041def MOV32rr_REV : I<0x8B, MRMSrcReg, (outs GR32:$dst), (ins GR32:$src),
1042 "mov{l}\t{$src, $dst|$dst, $src}", []>;
1043
Dan Gohman5574cc72008-12-03 18:15:48 +00001044let canFoldAsLoad = 1, isReMaterializable = 1, mayHaveSideEffects = 1 in {
Evan Chengb783fa32007-07-19 01:14:50 +00001045def MOV8rm : I<0x8A, MRMSrcMem, (outs GR8 :$dst), (ins i8mem :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001046 "mov{b}\t{$src, $dst|$dst, $src}",
Chris Lattner12208612009-04-10 00:16:23 +00001047 [(set GR8:$dst, (loadi8 addr:$src))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001048def MOV16rm : I<0x8B, MRMSrcMem, (outs GR16:$dst), (ins i16mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001049 "mov{w}\t{$src, $dst|$dst, $src}",
Chris Lattner12208612009-04-10 00:16:23 +00001050 [(set GR16:$dst, (loadi16 addr:$src))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001051def MOV32rm : I<0x8B, MRMSrcMem, (outs GR32:$dst), (ins i32mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001052 "mov{l}\t{$src, $dst|$dst, $src}",
Chris Lattner12208612009-04-10 00:16:23 +00001053 [(set GR32:$dst, (loadi32 addr:$src))]>;
Evan Cheng4e84e452007-08-30 05:49:43 +00001054}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001055
Evan Chengb783fa32007-07-19 01:14:50 +00001056def MOV8mr : I<0x88, MRMDestMem, (outs), (ins i8mem :$dst, GR8 :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001057 "mov{b}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001058 [(store GR8:$src, addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001059def MOV16mr : I<0x89, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001060 "mov{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001061 [(store GR16:$src, addr:$dst)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001062def MOV32mr : I<0x89, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001063 "mov{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001064 [(store GR32:$src, addr:$dst)]>;
Dan Gohman744d4622009-04-13 16:09:41 +00001065
Dan Gohman1d8ce9c2009-04-27 16:41:36 +00001066// Versions of MOV8rr, MOV8mr, and MOV8rm that use i8mem_NOREX and GR8_NOREX so
1067// that they can be used for copying and storing h registers, which can't be
1068// encoded when a REX prefix is present.
Dan Gohman2da0db32009-04-15 00:04:23 +00001069let neverHasSideEffects = 1 in
Dan Gohman40ddc362009-04-15 19:48:57 +00001070def MOV8rr_NOREX : I<0x88, MRMDestReg,
1071 (outs GR8_NOREX:$dst), (ins GR8_NOREX:$src),
Dan Gohman2da0db32009-04-15 00:04:23 +00001072 "mov{b}\t{$src, $dst|$dst, $src} # NOREX", []>;
Evan Chengebc49402009-04-30 00:58:57 +00001073let mayStore = 1 in
Dan Gohman2da0db32009-04-15 00:04:23 +00001074def MOV8mr_NOREX : I<0x88, MRMDestMem,
1075 (outs), (ins i8mem_NOREX:$dst, GR8_NOREX:$src),
1076 "mov{b}\t{$src, $dst|$dst, $src} # NOREX", []>;
Evan Chengebc49402009-04-30 00:58:57 +00001077let mayLoad = 1,
1078 canFoldAsLoad = 1, isReMaterializable = 1, mayHaveSideEffects = 1 in
Dan Gohman1d8ce9c2009-04-27 16:41:36 +00001079def MOV8rm_NOREX : I<0x8A, MRMSrcMem,
1080 (outs GR8_NOREX:$dst), (ins i8mem_NOREX:$src),
1081 "mov{b}\t{$src, $dst|$dst, $src} # NOREX", []>;
Dan Gohman744d4622009-04-13 16:09:41 +00001082
Sean Callanan2c48df22009-12-18 00:01:26 +00001083// Moves to and from debug registers
1084def MOV32rd : I<0x21, MRMDestReg, (outs GR32:$dst), (ins DEBUG_REG:$src),
1085 "mov{l}\t{$src, $dst|$dst, $src}", []>, TB;
1086def MOV32dr : I<0x23, MRMSrcReg, (outs DEBUG_REG:$dst), (ins GR32:$src),
1087 "mov{l}\t{$src, $dst|$dst, $src}", []>, TB;
1088
1089// Moves to and from control registers
1090def MOV32rc : I<0x20, MRMDestReg, (outs GR32:$dst), (ins CONTROL_REG_32:$src),
1091 "mov{q}\t{$src, $dst|$dst, $src}", []>, TB;
1092def MOV32cr : I<0x22, MRMSrcReg, (outs CONTROL_REG_32:$dst), (ins GR32:$src),
1093 "mov{q}\t{$src, $dst|$dst, $src}", []>, TB;
1094
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001095//===----------------------------------------------------------------------===//
1096// Fixed-Register Multiplication and Division Instructions...
1097//
1098
1099// Extra precision multiplication
Evan Cheng55687072007-09-14 21:48:26 +00001100let Defs = [AL,AH,EFLAGS], Uses = [AL] in
Dan Gohman91888f02007-07-31 20:11:57 +00001101def MUL8r : I<0xF6, MRM4r, (outs), (ins GR8:$src), "mul{b}\t$src",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001102 // FIXME: Used for 8-bit mul, ignore result upper 8 bits.
1103 // This probably ought to be moved to a def : Pat<> if the
1104 // syntax can be accepted.
Bill Wendlingf5399032008-12-12 21:15:41 +00001105 [(set AL, (mul AL, GR8:$src)),
1106 (implicit EFLAGS)]>; // AL,AH = AL*GR8
1107
Chris Lattnerc7e96e72008-01-11 07:18:17 +00001108let Defs = [AX,DX,EFLAGS], Uses = [AX], neverHasSideEffects = 1 in
Bill Wendlingf5399032008-12-12 21:15:41 +00001109def MUL16r : I<0xF7, MRM4r, (outs), (ins GR16:$src),
1110 "mul{w}\t$src",
1111 []>, OpSize; // AX,DX = AX*GR16
1112
Chris Lattnerc7e96e72008-01-11 07:18:17 +00001113let Defs = [EAX,EDX,EFLAGS], Uses = [EAX], neverHasSideEffects = 1 in
Bill Wendlingf5399032008-12-12 21:15:41 +00001114def MUL32r : I<0xF7, MRM4r, (outs), (ins GR32:$src),
1115 "mul{l}\t$src",
1116 []>; // EAX,EDX = EAX*GR32
1117
Evan Cheng55687072007-09-14 21:48:26 +00001118let Defs = [AL,AH,EFLAGS], Uses = [AL] in
Evan Chengb783fa32007-07-19 01:14:50 +00001119def MUL8m : I<0xF6, MRM4m, (outs), (ins i8mem :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001120 "mul{b}\t$src",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001121 // FIXME: Used for 8-bit mul, ignore result upper 8 bits.
1122 // This probably ought to be moved to a def : Pat<> if the
1123 // syntax can be accepted.
Bill Wendlingf5399032008-12-12 21:15:41 +00001124 [(set AL, (mul AL, (loadi8 addr:$src))),
1125 (implicit EFLAGS)]>; // AL,AH = AL*[mem8]
1126
Chris Lattnerc90ee9c2008-01-10 07:59:24 +00001127let mayLoad = 1, neverHasSideEffects = 1 in {
Evan Cheng55687072007-09-14 21:48:26 +00001128let Defs = [AX,DX,EFLAGS], Uses = [AX] in
Evan Chengb783fa32007-07-19 01:14:50 +00001129def MUL16m : I<0xF7, MRM4m, (outs), (ins i16mem:$src),
Bill Wendlingf5399032008-12-12 21:15:41 +00001130 "mul{w}\t$src",
1131 []>, OpSize; // AX,DX = AX*[mem16]
1132
Evan Cheng55687072007-09-14 21:48:26 +00001133let Defs = [EAX,EDX,EFLAGS], Uses = [EAX] in
Evan Chengb783fa32007-07-19 01:14:50 +00001134def MUL32m : I<0xF7, MRM4m, (outs), (ins i32mem:$src),
Bill Wendlingf5399032008-12-12 21:15:41 +00001135 "mul{l}\t$src",
1136 []>; // EAX,EDX = EAX*[mem32]
Chris Lattnerc90ee9c2008-01-10 07:59:24 +00001137}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001138
Chris Lattnerc90ee9c2008-01-10 07:59:24 +00001139let neverHasSideEffects = 1 in {
Evan Cheng55687072007-09-14 21:48:26 +00001140let Defs = [AL,AH,EFLAGS], Uses = [AL] in
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001141def IMUL8r : I<0xF6, MRM5r, (outs), (ins GR8:$src), "imul{b}\t$src", []>;
1142 // AL,AH = AL*GR8
Evan Cheng55687072007-09-14 21:48:26 +00001143let Defs = [AX,DX,EFLAGS], Uses = [AX] in
Dan Gohman91888f02007-07-31 20:11:57 +00001144def IMUL16r : I<0xF7, MRM5r, (outs), (ins GR16:$src), "imul{w}\t$src", []>,
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001145 OpSize; // AX,DX = AX*GR16
Evan Cheng55687072007-09-14 21:48:26 +00001146let Defs = [EAX,EDX,EFLAGS], Uses = [EAX] in
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001147def IMUL32r : I<0xF7, MRM5r, (outs), (ins GR32:$src), "imul{l}\t$src", []>;
1148 // EAX,EDX = EAX*GR32
Chris Lattnerc90ee9c2008-01-10 07:59:24 +00001149let mayLoad = 1 in {
Evan Cheng55687072007-09-14 21:48:26 +00001150let Defs = [AL,AH,EFLAGS], Uses = [AL] in
Evan Chengb783fa32007-07-19 01:14:50 +00001151def IMUL8m : I<0xF6, MRM5m, (outs), (ins i8mem :$src),
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001152 "imul{b}\t$src", []>; // AL,AH = AL*[mem8]
Evan Cheng55687072007-09-14 21:48:26 +00001153let Defs = [AX,DX,EFLAGS], Uses = [AX] in
Evan Chengb783fa32007-07-19 01:14:50 +00001154def IMUL16m : I<0xF7, MRM5m, (outs), (ins i16mem:$src),
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001155 "imul{w}\t$src", []>, OpSize; // AX,DX = AX*[mem16]
Eli Friedman3939db02009-12-26 20:08:30 +00001156let Defs = [EAX,EDX,EFLAGS], Uses = [EAX] in
Evan Chengb783fa32007-07-19 01:14:50 +00001157def IMUL32m : I<0xF7, MRM5m, (outs), (ins i32mem:$src),
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001158 "imul{l}\t$src", []>; // EAX,EDX = EAX*[mem32]
Chris Lattnerc90ee9c2008-01-10 07:59:24 +00001159}
Dan Gohmand44572d2008-11-18 21:29:14 +00001160} // neverHasSideEffects
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001161
1162// unsigned division/remainder
Dale Johannesend8fd3562008-10-07 18:54:28 +00001163let Defs = [AL,AH,EFLAGS], Uses = [AX] in
Sean Callanan2c48df22009-12-18 00:01:26 +00001164def DIV8r : I<0xF6, MRM6r, (outs), (ins GR8:$src), // AX/r8 = AL,AH
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001165 "div{b}\t$src", []>;
Evan Cheng55687072007-09-14 21:48:26 +00001166let Defs = [AX,DX,EFLAGS], Uses = [AX,DX] in
Sean Callanan2c48df22009-12-18 00:01:26 +00001167def DIV16r : I<0xF7, MRM6r, (outs), (ins GR16:$src), // DX:AX/r16 = AX,DX
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001168 "div{w}\t$src", []>, OpSize;
Evan Cheng55687072007-09-14 21:48:26 +00001169let Defs = [EAX,EDX,EFLAGS], Uses = [EAX,EDX] in
Sean Callanan2c48df22009-12-18 00:01:26 +00001170def DIV32r : I<0xF7, MRM6r, (outs), (ins GR32:$src), // EDX:EAX/r32 = EAX,EDX
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001171 "div{l}\t$src", []>;
Chris Lattnerc90ee9c2008-01-10 07:59:24 +00001172let mayLoad = 1 in {
Dale Johannesend8fd3562008-10-07 18:54:28 +00001173let Defs = [AL,AH,EFLAGS], Uses = [AX] in
Sean Callanan2c48df22009-12-18 00:01:26 +00001174def DIV8m : I<0xF6, MRM6m, (outs), (ins i8mem:$src), // AX/[mem8] = AL,AH
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001175 "div{b}\t$src", []>;
Evan Cheng55687072007-09-14 21:48:26 +00001176let Defs = [AX,DX,EFLAGS], Uses = [AX,DX] in
Sean Callanan2c48df22009-12-18 00:01:26 +00001177def DIV16m : I<0xF7, MRM6m, (outs), (ins i16mem:$src), // DX:AX/[mem16] = AX,DX
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001178 "div{w}\t$src", []>, OpSize;
Evan Cheng55687072007-09-14 21:48:26 +00001179let Defs = [EAX,EDX,EFLAGS], Uses = [EAX,EDX] in
Sean Callanan2c48df22009-12-18 00:01:26 +00001180 // EDX:EAX/[mem32] = EAX,EDX
1181def DIV32m : I<0xF7, MRM6m, (outs), (ins i32mem:$src),
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001182 "div{l}\t$src", []>;
Chris Lattnerc90ee9c2008-01-10 07:59:24 +00001183}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001184
1185// Signed division/remainder.
Dale Johannesend8fd3562008-10-07 18:54:28 +00001186let Defs = [AL,AH,EFLAGS], Uses = [AX] in
Sean Callanan2c48df22009-12-18 00:01:26 +00001187def IDIV8r : I<0xF6, MRM7r, (outs), (ins GR8:$src), // AX/r8 = AL,AH
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001188 "idiv{b}\t$src", []>;
Evan Cheng55687072007-09-14 21:48:26 +00001189let Defs = [AX,DX,EFLAGS], Uses = [AX,DX] in
Sean Callanan2c48df22009-12-18 00:01:26 +00001190def IDIV16r: I<0xF7, MRM7r, (outs), (ins GR16:$src), // DX:AX/r16 = AX,DX
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001191 "idiv{w}\t$src", []>, OpSize;
Evan Cheng55687072007-09-14 21:48:26 +00001192let Defs = [EAX,EDX,EFLAGS], Uses = [EAX,EDX] in
Sean Callanan2c48df22009-12-18 00:01:26 +00001193def IDIV32r: I<0xF7, MRM7r, (outs), (ins GR32:$src), // EDX:EAX/r32 = EAX,EDX
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001194 "idiv{l}\t$src", []>;
Chris Lattnerc90ee9c2008-01-10 07:59:24 +00001195let mayLoad = 1, mayLoad = 1 in {
Dale Johannesend8fd3562008-10-07 18:54:28 +00001196let Defs = [AL,AH,EFLAGS], Uses = [AX] in
Sean Callanan2c48df22009-12-18 00:01:26 +00001197def IDIV8m : I<0xF6, MRM7m, (outs), (ins i8mem:$src), // AX/[mem8] = AL,AH
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001198 "idiv{b}\t$src", []>;
Evan Cheng55687072007-09-14 21:48:26 +00001199let Defs = [AX,DX,EFLAGS], Uses = [AX,DX] in
Sean Callanan2c48df22009-12-18 00:01:26 +00001200def IDIV16m: I<0xF7, MRM7m, (outs), (ins i16mem:$src), // DX:AX/[mem16] = AX,DX
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001201 "idiv{w}\t$src", []>, OpSize;
Evan Cheng55687072007-09-14 21:48:26 +00001202let Defs = [EAX,EDX,EFLAGS], Uses = [EAX,EDX] in
Sean Callanan2c48df22009-12-18 00:01:26 +00001203def IDIV32m: I<0xF7, MRM7m, (outs), (ins i32mem:$src),
1204 // EDX:EAX/[mem32] = EAX,EDX
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001205 "idiv{l}\t$src", []>;
Chris Lattnerc90ee9c2008-01-10 07:59:24 +00001206}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001207
1208//===----------------------------------------------------------------------===//
Chris Lattnerc90ee9c2008-01-10 07:59:24 +00001209// Two address Instructions.
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001210//
1211let isTwoAddress = 1 in {
1212
1213// Conditional moves
Evan Cheng950aac02007-09-25 01:57:46 +00001214let Uses = [EFLAGS] in {
Dan Gohman29b998f2009-08-27 00:14:12 +00001215
Dan Gohman30afe012009-10-29 18:10:34 +00001216// X86 doesn't have 8-bit conditional moves. Use a customInserter to
Dan Gohman29b998f2009-08-27 00:14:12 +00001217// emit control flow. An alternative to this is to mark i8 SELECT as Promote,
1218// however that requires promoting the operands, and can induce additional
Dan Gohman1596dd22009-08-29 22:19:15 +00001219// i8 register pressure. Note that CMOV_GR8 is conservatively considered to
1220// clobber EFLAGS, because if one of the operands is zero, the expansion
1221// could involve an xor.
Dan Gohman30afe012009-10-29 18:10:34 +00001222let usesCustomInserter = 1, isTwoAddress = 0, Defs = [EFLAGS] in
Dan Gohman29b998f2009-08-27 00:14:12 +00001223def CMOV_GR8 : I<0, Pseudo,
1224 (outs GR8:$dst), (ins GR8:$src1, GR8:$src2, i8imm:$cond),
1225 "#CMOV_GR8 PSEUDO!",
1226 [(set GR8:$dst, (X86cmov GR8:$src1, GR8:$src2,
1227 imm:$cond, EFLAGS))]>;
1228
Dan Gohman90adb6c2009-08-27 18:16:24 +00001229let isCommutable = 1 in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001230def CMOVB16rr : I<0x42, MRMSrcReg, // if <u, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +00001231 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Sean Callanan2c48df22009-12-18 00:01:26 +00001232 "cmovb{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001233 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001234 X86_COND_B, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001235 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001236def CMOVB32rr : I<0x42, MRMSrcReg, // if <u, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +00001237 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Sean Callanan2c48df22009-12-18 00:01:26 +00001238 "cmovb{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001239 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001240 X86_COND_B, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001241 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001242def CMOVAE16rr: I<0x43, MRMSrcReg, // if >=u, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +00001243 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Sean Callanan2c48df22009-12-18 00:01:26 +00001244 "cmovae{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001245 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001246 X86_COND_AE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001247 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001248def CMOVAE32rr: I<0x43, MRMSrcReg, // if >=u, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +00001249 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Sean Callanan2c48df22009-12-18 00:01:26 +00001250 "cmovae{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001251 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001252 X86_COND_AE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001253 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001254def CMOVE16rr : I<0x44, MRMSrcReg, // if ==, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +00001255 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Sean Callanan2c48df22009-12-18 00:01:26 +00001256 "cmove{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001257 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001258 X86_COND_E, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001259 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001260def CMOVE32rr : I<0x44, MRMSrcReg, // if ==, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +00001261 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Sean Callanan2c48df22009-12-18 00:01:26 +00001262 "cmove{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001263 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001264 X86_COND_E, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001265 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001266def CMOVNE16rr: I<0x45, MRMSrcReg, // if !=, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +00001267 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Sean Callanan2c48df22009-12-18 00:01:26 +00001268 "cmovne{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001269 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001270 X86_COND_NE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001271 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001272def CMOVNE32rr: I<0x45, MRMSrcReg, // if !=, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +00001273 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Sean Callanan2c48df22009-12-18 00:01:26 +00001274 "cmovne{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001275 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001276 X86_COND_NE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001277 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001278def CMOVBE16rr: I<0x46, MRMSrcReg, // if <=u, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +00001279 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Sean Callanan2c48df22009-12-18 00:01:26 +00001280 "cmovbe{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001281 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001282 X86_COND_BE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001283 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001284def CMOVBE32rr: I<0x46, MRMSrcReg, // if <=u, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +00001285 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Sean Callanan2c48df22009-12-18 00:01:26 +00001286 "cmovbe{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001287 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001288 X86_COND_BE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001289 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001290def CMOVA16rr : I<0x47, MRMSrcReg, // if >u, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +00001291 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Sean Callanan2c48df22009-12-18 00:01:26 +00001292 "cmova{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001293 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001294 X86_COND_A, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001295 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001296def CMOVA32rr : I<0x47, MRMSrcReg, // if >u, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +00001297 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Sean Callanan2c48df22009-12-18 00:01:26 +00001298 "cmova{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001299 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001300 X86_COND_A, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001301 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001302def CMOVL16rr : I<0x4C, MRMSrcReg, // if <s, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +00001303 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Sean Callanan2c48df22009-12-18 00:01:26 +00001304 "cmovl{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001305 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001306 X86_COND_L, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001307 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001308def CMOVL32rr : I<0x4C, MRMSrcReg, // if <s, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +00001309 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Sean Callanan2c48df22009-12-18 00:01:26 +00001310 "cmovl{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001311 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001312 X86_COND_L, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001313 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001314def CMOVGE16rr: I<0x4D, MRMSrcReg, // if >=s, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +00001315 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Sean Callanan2c48df22009-12-18 00:01:26 +00001316 "cmovge{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001317 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001318 X86_COND_GE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001319 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001320def CMOVGE32rr: I<0x4D, MRMSrcReg, // if >=s, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +00001321 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Sean Callanan2c48df22009-12-18 00:01:26 +00001322 "cmovge{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001323 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001324 X86_COND_GE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001325 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001326def CMOVLE16rr: I<0x4E, MRMSrcReg, // if <=s, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +00001327 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Sean Callanan2c48df22009-12-18 00:01:26 +00001328 "cmovle{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001329 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001330 X86_COND_LE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001331 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001332def CMOVLE32rr: I<0x4E, MRMSrcReg, // if <=s, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +00001333 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Sean Callanan2c48df22009-12-18 00:01:26 +00001334 "cmovle{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001335 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001336 X86_COND_LE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001337 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001338def CMOVG16rr : I<0x4F, MRMSrcReg, // if >s, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +00001339 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Sean Callanan2c48df22009-12-18 00:01:26 +00001340 "cmovg{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001341 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001342 X86_COND_G, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001343 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001344def CMOVG32rr : I<0x4F, MRMSrcReg, // if >s, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +00001345 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Sean Callanan2c48df22009-12-18 00:01:26 +00001346 "cmovg{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001347 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001348 X86_COND_G, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001349 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001350def CMOVS16rr : I<0x48, MRMSrcReg, // if signed, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +00001351 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Sean Callanan2c48df22009-12-18 00:01:26 +00001352 "cmovs{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001353 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001354 X86_COND_S, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001355 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001356def CMOVS32rr : I<0x48, MRMSrcReg, // if signed, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +00001357 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Sean Callanan2c48df22009-12-18 00:01:26 +00001358 "cmovs{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001359 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001360 X86_COND_S, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001361 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001362def CMOVNS16rr: I<0x49, MRMSrcReg, // if !signed, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +00001363 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Sean Callanan2c48df22009-12-18 00:01:26 +00001364 "cmovns{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001365 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001366 X86_COND_NS, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001367 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001368def CMOVNS32rr: I<0x49, MRMSrcReg, // if !signed, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +00001369 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Sean Callanan2c48df22009-12-18 00:01:26 +00001370 "cmovns{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001371 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001372 X86_COND_NS, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001373 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001374def CMOVP16rr : I<0x4A, MRMSrcReg, // if parity, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +00001375 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Sean Callanan2c48df22009-12-18 00:01:26 +00001376 "cmovp{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001377 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001378 X86_COND_P, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001379 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001380def CMOVP32rr : I<0x4A, MRMSrcReg, // if parity, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +00001381 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Sean Callanan2c48df22009-12-18 00:01:26 +00001382 "cmovp{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001383 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001384 X86_COND_P, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001385 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001386def CMOVNP16rr : I<0x4B, MRMSrcReg, // if !parity, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +00001387 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Sean Callanan2c48df22009-12-18 00:01:26 +00001388 "cmovnp{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001389 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001390 X86_COND_NP, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001391 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001392def CMOVNP32rr : I<0x4B, MRMSrcReg, // if !parity, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +00001393 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Sean Callanan2c48df22009-12-18 00:01:26 +00001394 "cmovnp{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001395 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001396 X86_COND_NP, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001397 TB;
Dan Gohman12fd4d72009-01-07 00:35:10 +00001398def CMOVO16rr : I<0x40, MRMSrcReg, // if overflow, GR16 = GR16
1399 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Sean Callanan2c48df22009-12-18 00:01:26 +00001400 "cmovo{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohman12fd4d72009-01-07 00:35:10 +00001401 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
1402 X86_COND_O, EFLAGS))]>,
1403 TB, OpSize;
1404def CMOVO32rr : I<0x40, MRMSrcReg, // if overflow, GR32 = GR32
1405 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Sean Callanan2c48df22009-12-18 00:01:26 +00001406 "cmovo{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohman12fd4d72009-01-07 00:35:10 +00001407 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
1408 X86_COND_O, EFLAGS))]>,
Evan Cheng950aac02007-09-25 01:57:46 +00001409 TB;
Dan Gohman12fd4d72009-01-07 00:35:10 +00001410def CMOVNO16rr : I<0x41, MRMSrcReg, // if !overflow, GR16 = GR16
1411 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Sean Callanan2c48df22009-12-18 00:01:26 +00001412 "cmovno{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohman12fd4d72009-01-07 00:35:10 +00001413 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
1414 X86_COND_NO, EFLAGS))]>,
1415 TB, OpSize;
1416def CMOVNO32rr : I<0x41, MRMSrcReg, // if !overflow, GR32 = GR32
1417 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Sean Callanan2c48df22009-12-18 00:01:26 +00001418 "cmovno{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohman12fd4d72009-01-07 00:35:10 +00001419 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
1420 X86_COND_NO, EFLAGS))]>,
1421 TB;
1422} // isCommutable = 1
Evan Cheng926658c2007-10-05 23:13:21 +00001423
1424def CMOVB16rm : I<0x42, MRMSrcMem, // if <u, GR16 = [mem16]
1425 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
Sean Callanan2c48df22009-12-18 00:01:26 +00001426 "cmovb{w}\t{$src2, $dst|$dst, $src2}",
Evan Cheng926658c2007-10-05 23:13:21 +00001427 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1428 X86_COND_B, EFLAGS))]>,
1429 TB, OpSize;
1430def CMOVB32rm : I<0x42, MRMSrcMem, // if <u, GR32 = [mem32]
1431 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Sean Callanan2c48df22009-12-18 00:01:26 +00001432 "cmovb{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng926658c2007-10-05 23:13:21 +00001433 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1434 X86_COND_B, EFLAGS))]>,
1435 TB;
1436def CMOVAE16rm: I<0x43, MRMSrcMem, // if >=u, GR16 = [mem16]
1437 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
Sean Callanan2c48df22009-12-18 00:01:26 +00001438 "cmovae{w}\t{$src2, $dst|$dst, $src2}",
Evan Cheng926658c2007-10-05 23:13:21 +00001439 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1440 X86_COND_AE, EFLAGS))]>,
1441 TB, OpSize;
1442def CMOVAE32rm: I<0x43, MRMSrcMem, // if >=u, GR32 = [mem32]
1443 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Sean Callanan2c48df22009-12-18 00:01:26 +00001444 "cmovae{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng926658c2007-10-05 23:13:21 +00001445 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1446 X86_COND_AE, EFLAGS))]>,
1447 TB;
1448def CMOVE16rm : I<0x44, MRMSrcMem, // if ==, GR16 = [mem16]
1449 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
Sean Callanan2c48df22009-12-18 00:01:26 +00001450 "cmove{w}\t{$src2, $dst|$dst, $src2}",
Evan Cheng926658c2007-10-05 23:13:21 +00001451 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1452 X86_COND_E, EFLAGS))]>,
1453 TB, OpSize;
1454def CMOVE32rm : I<0x44, MRMSrcMem, // if ==, GR32 = [mem32]
1455 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Sean Callanan2c48df22009-12-18 00:01:26 +00001456 "cmove{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng926658c2007-10-05 23:13:21 +00001457 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1458 X86_COND_E, EFLAGS))]>,
1459 TB;
1460def CMOVNE16rm: I<0x45, MRMSrcMem, // if !=, GR16 = [mem16]
1461 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
Sean Callanan2c48df22009-12-18 00:01:26 +00001462 "cmovne{w}\t{$src2, $dst|$dst, $src2}",
Evan Cheng926658c2007-10-05 23:13:21 +00001463 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1464 X86_COND_NE, EFLAGS))]>,
1465 TB, OpSize;
1466def CMOVNE32rm: I<0x45, MRMSrcMem, // if !=, GR32 = [mem32]
1467 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Sean Callanan2c48df22009-12-18 00:01:26 +00001468 "cmovne{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng926658c2007-10-05 23:13:21 +00001469 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1470 X86_COND_NE, EFLAGS))]>,
1471 TB;
1472def CMOVBE16rm: I<0x46, MRMSrcMem, // if <=u, GR16 = [mem16]
1473 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
Sean Callanan2c48df22009-12-18 00:01:26 +00001474 "cmovbe{w}\t{$src2, $dst|$dst, $src2}",
Evan Cheng926658c2007-10-05 23:13:21 +00001475 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1476 X86_COND_BE, EFLAGS))]>,
1477 TB, OpSize;
1478def CMOVBE32rm: I<0x46, MRMSrcMem, // if <=u, GR32 = [mem32]
1479 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Sean Callanan2c48df22009-12-18 00:01:26 +00001480 "cmovbe{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng926658c2007-10-05 23:13:21 +00001481 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1482 X86_COND_BE, EFLAGS))]>,
1483 TB;
1484def CMOVA16rm : I<0x47, MRMSrcMem, // if >u, GR16 = [mem16]
1485 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
Sean Callanan2c48df22009-12-18 00:01:26 +00001486 "cmova{w}\t{$src2, $dst|$dst, $src2}",
Evan Cheng926658c2007-10-05 23:13:21 +00001487 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1488 X86_COND_A, EFLAGS))]>,
1489 TB, OpSize;
1490def CMOVA32rm : I<0x47, MRMSrcMem, // if >u, GR32 = [mem32]
1491 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Sean Callanan2c48df22009-12-18 00:01:26 +00001492 "cmova{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng926658c2007-10-05 23:13:21 +00001493 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1494 X86_COND_A, EFLAGS))]>,
1495 TB;
1496def CMOVL16rm : I<0x4C, MRMSrcMem, // if <s, GR16 = [mem16]
1497 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
Sean Callanan2c48df22009-12-18 00:01:26 +00001498 "cmovl{w}\t{$src2, $dst|$dst, $src2}",
Evan Cheng926658c2007-10-05 23:13:21 +00001499 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1500 X86_COND_L, EFLAGS))]>,
1501 TB, OpSize;
1502def CMOVL32rm : I<0x4C, MRMSrcMem, // if <s, GR32 = [mem32]
1503 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Sean Callanan2c48df22009-12-18 00:01:26 +00001504 "cmovl{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng926658c2007-10-05 23:13:21 +00001505 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1506 X86_COND_L, EFLAGS))]>,
1507 TB;
1508def CMOVGE16rm: I<0x4D, MRMSrcMem, // if >=s, GR16 = [mem16]
1509 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
Sean Callanan2c48df22009-12-18 00:01:26 +00001510 "cmovge{w}\t{$src2, $dst|$dst, $src2}",
Evan Cheng926658c2007-10-05 23:13:21 +00001511 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1512 X86_COND_GE, EFLAGS))]>,
1513 TB, OpSize;
1514def CMOVGE32rm: I<0x4D, MRMSrcMem, // if >=s, GR32 = [mem32]
1515 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Sean Callanan2c48df22009-12-18 00:01:26 +00001516 "cmovge{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng926658c2007-10-05 23:13:21 +00001517 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1518 X86_COND_GE, EFLAGS))]>,
1519 TB;
1520def CMOVLE16rm: I<0x4E, MRMSrcMem, // if <=s, GR16 = [mem16]
1521 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
Sean Callanan2c48df22009-12-18 00:01:26 +00001522 "cmovle{w}\t{$src2, $dst|$dst, $src2}",
Evan Cheng926658c2007-10-05 23:13:21 +00001523 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1524 X86_COND_LE, EFLAGS))]>,
1525 TB, OpSize;
1526def CMOVLE32rm: I<0x4E, MRMSrcMem, // if <=s, GR32 = [mem32]
1527 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Sean Callanan2c48df22009-12-18 00:01:26 +00001528 "cmovle{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng926658c2007-10-05 23:13:21 +00001529 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1530 X86_COND_LE, EFLAGS))]>,
1531 TB;
1532def CMOVG16rm : I<0x4F, MRMSrcMem, // if >s, GR16 = [mem16]
1533 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
Sean Callanan2c48df22009-12-18 00:01:26 +00001534 "cmovg{w}\t{$src2, $dst|$dst, $src2}",
Evan Cheng926658c2007-10-05 23:13:21 +00001535 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1536 X86_COND_G, EFLAGS))]>,
1537 TB, OpSize;
1538def CMOVG32rm : I<0x4F, MRMSrcMem, // if >s, GR32 = [mem32]
1539 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Sean Callanan2c48df22009-12-18 00:01:26 +00001540 "cmovg{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng926658c2007-10-05 23:13:21 +00001541 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1542 X86_COND_G, EFLAGS))]>,
1543 TB;
1544def CMOVS16rm : I<0x48, MRMSrcMem, // if signed, GR16 = [mem16]
1545 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
Sean Callanan2c48df22009-12-18 00:01:26 +00001546 "cmovs{w}\t{$src2, $dst|$dst, $src2}",
Evan Cheng926658c2007-10-05 23:13:21 +00001547 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1548 X86_COND_S, EFLAGS))]>,
1549 TB, OpSize;
1550def CMOVS32rm : I<0x48, MRMSrcMem, // if signed, GR32 = [mem32]
1551 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Sean Callanan2c48df22009-12-18 00:01:26 +00001552 "cmovs{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng926658c2007-10-05 23:13:21 +00001553 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1554 X86_COND_S, EFLAGS))]>,
1555 TB;
1556def CMOVNS16rm: I<0x49, MRMSrcMem, // if !signed, GR16 = [mem16]
1557 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
Sean Callanan2c48df22009-12-18 00:01:26 +00001558 "cmovns{w}\t{$src2, $dst|$dst, $src2}",
Evan Cheng926658c2007-10-05 23:13:21 +00001559 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1560 X86_COND_NS, EFLAGS))]>,
1561 TB, OpSize;
1562def CMOVNS32rm: I<0x49, MRMSrcMem, // if !signed, GR32 = [mem32]
1563 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Sean Callanan2c48df22009-12-18 00:01:26 +00001564 "cmovns{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng926658c2007-10-05 23:13:21 +00001565 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1566 X86_COND_NS, EFLAGS))]>,
1567 TB;
1568def CMOVP16rm : I<0x4A, MRMSrcMem, // if parity, GR16 = [mem16]
1569 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
Sean Callanan2c48df22009-12-18 00:01:26 +00001570 "cmovp{w}\t{$src2, $dst|$dst, $src2}",
Evan Cheng926658c2007-10-05 23:13:21 +00001571 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1572 X86_COND_P, EFLAGS))]>,
1573 TB, OpSize;
1574def CMOVP32rm : I<0x4A, MRMSrcMem, // if parity, GR32 = [mem32]
1575 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Sean Callanan2c48df22009-12-18 00:01:26 +00001576 "cmovp{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng926658c2007-10-05 23:13:21 +00001577 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1578 X86_COND_P, EFLAGS))]>,
1579 TB;
1580def CMOVNP16rm : I<0x4B, MRMSrcMem, // if !parity, GR16 = [mem16]
1581 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
Sean Callanan2c48df22009-12-18 00:01:26 +00001582 "cmovnp{w}\t{$src2, $dst|$dst, $src2}",
Evan Cheng926658c2007-10-05 23:13:21 +00001583 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1584 X86_COND_NP, EFLAGS))]>,
1585 TB, OpSize;
Dan Gohman12fd4d72009-01-07 00:35:10 +00001586def CMOVNP32rm : I<0x4B, MRMSrcMem, // if !parity, GR32 = [mem32]
1587 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Sean Callanan2c48df22009-12-18 00:01:26 +00001588 "cmovnp{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohman12fd4d72009-01-07 00:35:10 +00001589 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1590 X86_COND_NP, EFLAGS))]>,
1591 TB;
1592def CMOVO16rm : I<0x40, MRMSrcMem, // if overflow, GR16 = [mem16]
1593 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
Sean Callanan2c48df22009-12-18 00:01:26 +00001594 "cmovo{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohman12fd4d72009-01-07 00:35:10 +00001595 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1596 X86_COND_O, EFLAGS))]>,
1597 TB, OpSize;
1598def CMOVO32rm : I<0x40, MRMSrcMem, // if overflow, GR32 = [mem32]
1599 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Sean Callanan2c48df22009-12-18 00:01:26 +00001600 "cmovo{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohman12fd4d72009-01-07 00:35:10 +00001601 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1602 X86_COND_O, EFLAGS))]>,
1603 TB;
1604def CMOVNO16rm : I<0x41, MRMSrcMem, // if !overflow, GR16 = [mem16]
1605 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
Sean Callanan2c48df22009-12-18 00:01:26 +00001606 "cmovno{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohman12fd4d72009-01-07 00:35:10 +00001607 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1608 X86_COND_NO, EFLAGS))]>,
1609 TB, OpSize;
1610def CMOVNO32rm : I<0x41, MRMSrcMem, // if !overflow, GR32 = [mem32]
1611 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Sean Callanan2c48df22009-12-18 00:01:26 +00001612 "cmovno{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohman12fd4d72009-01-07 00:35:10 +00001613 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1614 X86_COND_NO, EFLAGS))]>,
1615 TB;
Evan Cheng950aac02007-09-25 01:57:46 +00001616} // Uses = [EFLAGS]
1617
1618
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001619// unary instructions
1620let CodeSize = 2 in {
Evan Cheng55687072007-09-14 21:48:26 +00001621let Defs = [EFLAGS] in {
Dan Gohman91888f02007-07-31 20:11:57 +00001622def NEG8r : I<0xF6, MRM3r, (outs GR8 :$dst), (ins GR8 :$src), "neg{b}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001623 [(set GR8:$dst, (ineg GR8:$src)),
1624 (implicit EFLAGS)]>;
Dan Gohman91888f02007-07-31 20:11:57 +00001625def NEG16r : I<0xF7, MRM3r, (outs GR16:$dst), (ins GR16:$src), "neg{w}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001626 [(set GR16:$dst, (ineg GR16:$src)),
1627 (implicit EFLAGS)]>, OpSize;
Dan Gohman91888f02007-07-31 20:11:57 +00001628def NEG32r : I<0xF7, MRM3r, (outs GR32:$dst), (ins GR32:$src), "neg{l}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001629 [(set GR32:$dst, (ineg GR32:$src)),
1630 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001631let isTwoAddress = 0 in {
Dan Gohman91888f02007-07-31 20:11:57 +00001632 def NEG8m : I<0xF6, MRM3m, (outs), (ins i8mem :$dst), "neg{b}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001633 [(store (ineg (loadi8 addr:$dst)), addr:$dst),
1634 (implicit EFLAGS)]>;
Dan Gohman91888f02007-07-31 20:11:57 +00001635 def NEG16m : I<0xF7, MRM3m, (outs), (ins i16mem:$dst), "neg{w}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001636 [(store (ineg (loadi16 addr:$dst)), addr:$dst),
1637 (implicit EFLAGS)]>, OpSize;
Dan Gohman91888f02007-07-31 20:11:57 +00001638 def NEG32m : I<0xF7, MRM3m, (outs), (ins i32mem:$dst), "neg{l}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001639 [(store (ineg (loadi32 addr:$dst)), addr:$dst),
1640 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001641}
Evan Cheng55687072007-09-14 21:48:26 +00001642} // Defs = [EFLAGS]
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001643
Evan Chengc6cee682009-01-21 02:09:05 +00001644// Match xor -1 to not. Favors these over a move imm + xor to save code size.
1645let AddedComplexity = 15 in {
Dan Gohman91888f02007-07-31 20:11:57 +00001646def NOT8r : I<0xF6, MRM2r, (outs GR8 :$dst), (ins GR8 :$src), "not{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001647 [(set GR8:$dst, (not GR8:$src))]>;
Dan Gohman91888f02007-07-31 20:11:57 +00001648def NOT16r : I<0xF7, MRM2r, (outs GR16:$dst), (ins GR16:$src), "not{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001649 [(set GR16:$dst, (not GR16:$src))]>, OpSize;
Dan Gohman91888f02007-07-31 20:11:57 +00001650def NOT32r : I<0xF7, MRM2r, (outs GR32:$dst), (ins GR32:$src), "not{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001651 [(set GR32:$dst, (not GR32:$src))]>;
Evan Chengc6cee682009-01-21 02:09:05 +00001652}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001653let isTwoAddress = 0 in {
Dan Gohman91888f02007-07-31 20:11:57 +00001654 def NOT8m : I<0xF6, MRM2m, (outs), (ins i8mem :$dst), "not{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001655 [(store (not (loadi8 addr:$dst)), addr:$dst)]>;
Dan Gohman91888f02007-07-31 20:11:57 +00001656 def NOT16m : I<0xF7, MRM2m, (outs), (ins i16mem:$dst), "not{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001657 [(store (not (loadi16 addr:$dst)), addr:$dst)]>, OpSize;
Dan Gohman91888f02007-07-31 20:11:57 +00001658 def NOT32m : I<0xF7, MRM2m, (outs), (ins i32mem:$dst), "not{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001659 [(store (not (loadi32 addr:$dst)), addr:$dst)]>;
1660}
1661} // CodeSize
1662
1663// TODO: inc/dec is slow for P4, but fast for Pentium-M.
Evan Cheng55687072007-09-14 21:48:26 +00001664let Defs = [EFLAGS] in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001665let CodeSize = 2 in
Dan Gohman91888f02007-07-31 20:11:57 +00001666def INC8r : I<0xFE, MRM0r, (outs GR8 :$dst), (ins GR8 :$src), "inc{b}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001667 [(set GR8:$dst, (add GR8:$src, 1)),
1668 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001669let isConvertibleToThreeAddress = 1, CodeSize = 1 in { // Can xform into LEA.
Sean Callanan2c48df22009-12-18 00:01:26 +00001670def INC16r : I<0x40, AddRegFrm, (outs GR16:$dst), (ins GR16:$src),
1671 "inc{w}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001672 [(set GR16:$dst, (add GR16:$src, 1)),
1673 (implicit EFLAGS)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001674 OpSize, Requires<[In32BitMode]>;
Sean Callanan2c48df22009-12-18 00:01:26 +00001675def INC32r : I<0x40, AddRegFrm, (outs GR32:$dst), (ins GR32:$src),
1676 "inc{l}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001677 [(set GR32:$dst, (add GR32:$src, 1)),
1678 (implicit EFLAGS)]>, Requires<[In32BitMode]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001679}
1680let isTwoAddress = 0, CodeSize = 2 in {
Dan Gohman91888f02007-07-31 20:11:57 +00001681 def INC8m : I<0xFE, MRM0m, (outs), (ins i8mem :$dst), "inc{b}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001682 [(store (add (loadi8 addr:$dst), 1), addr:$dst),
1683 (implicit EFLAGS)]>;
Dan Gohman91888f02007-07-31 20:11:57 +00001684 def INC16m : I<0xFF, MRM0m, (outs), (ins i16mem:$dst), "inc{w}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001685 [(store (add (loadi16 addr:$dst), 1), addr:$dst),
1686 (implicit EFLAGS)]>,
Evan Cheng4a7e72f2007-10-19 21:23:22 +00001687 OpSize, Requires<[In32BitMode]>;
Dan Gohman91888f02007-07-31 20:11:57 +00001688 def INC32m : I<0xFF, MRM0m, (outs), (ins i32mem:$dst), "inc{l}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001689 [(store (add (loadi32 addr:$dst), 1), addr:$dst),
1690 (implicit EFLAGS)]>,
Evan Cheng4a7e72f2007-10-19 21:23:22 +00001691 Requires<[In32BitMode]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001692}
1693
1694let CodeSize = 2 in
Dan Gohman91888f02007-07-31 20:11:57 +00001695def DEC8r : I<0xFE, MRM1r, (outs GR8 :$dst), (ins GR8 :$src), "dec{b}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001696 [(set GR8:$dst, (add GR8:$src, -1)),
1697 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001698let isConvertibleToThreeAddress = 1, CodeSize = 1 in { // Can xform into LEA.
Sean Callanan2c48df22009-12-18 00:01:26 +00001699def DEC16r : I<0x48, AddRegFrm, (outs GR16:$dst), (ins GR16:$src),
1700 "dec{w}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001701 [(set GR16:$dst, (add GR16:$src, -1)),
1702 (implicit EFLAGS)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001703 OpSize, Requires<[In32BitMode]>;
Sean Callanan2c48df22009-12-18 00:01:26 +00001704def DEC32r : I<0x48, AddRegFrm, (outs GR32:$dst), (ins GR32:$src),
1705 "dec{l}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001706 [(set GR32:$dst, (add GR32:$src, -1)),
1707 (implicit EFLAGS)]>, Requires<[In32BitMode]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001708}
1709
1710let isTwoAddress = 0, CodeSize = 2 in {
Dan Gohman91888f02007-07-31 20:11:57 +00001711 def DEC8m : I<0xFE, MRM1m, (outs), (ins i8mem :$dst), "dec{b}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001712 [(store (add (loadi8 addr:$dst), -1), addr:$dst),
1713 (implicit EFLAGS)]>;
Dan Gohman91888f02007-07-31 20:11:57 +00001714 def DEC16m : I<0xFF, MRM1m, (outs), (ins i16mem:$dst), "dec{w}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001715 [(store (add (loadi16 addr:$dst), -1), addr:$dst),
1716 (implicit EFLAGS)]>,
Evan Cheng4a7e72f2007-10-19 21:23:22 +00001717 OpSize, Requires<[In32BitMode]>;
Dan Gohman91888f02007-07-31 20:11:57 +00001718 def DEC32m : I<0xFF, MRM1m, (outs), (ins i32mem:$dst), "dec{l}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001719 [(store (add (loadi32 addr:$dst), -1), addr:$dst),
1720 (implicit EFLAGS)]>,
Evan Cheng4a7e72f2007-10-19 21:23:22 +00001721 Requires<[In32BitMode]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001722}
Evan Cheng55687072007-09-14 21:48:26 +00001723} // Defs = [EFLAGS]
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001724
1725// Logical operators...
Evan Cheng55687072007-09-14 21:48:26 +00001726let Defs = [EFLAGS] in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001727let isCommutable = 1 in { // X = AND Y, Z --> X = AND Z, Y
1728def AND8rr : I<0x20, MRMDestReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001729 (outs GR8 :$dst), (ins GR8 :$src1, GR8 :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001730 "and{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001731 [(set GR8:$dst, (and GR8:$src1, GR8:$src2)),
1732 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001733def AND16rr : I<0x21, MRMDestReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001734 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001735 "and{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001736 [(set GR16:$dst, (and GR16:$src1, GR16:$src2)),
1737 (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001738def AND32rr : I<0x21, MRMDestReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001739 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001740 "and{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001741 [(set GR32:$dst, (and GR32:$src1, GR32:$src2)),
1742 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001743}
1744
Sean Callanan2c48df22009-12-18 00:01:26 +00001745// AND instructions with the destination register in REG and the source register
1746// in R/M. Included for the disassembler.
1747def AND8rr_REV : I<0x22, MRMSrcReg, (outs GR8:$dst), (ins GR8:$src1, GR8:$src2),
1748 "and{b}\t{$src2, $dst|$dst, $src2}", []>;
1749def AND16rr_REV : I<0x23, MRMSrcReg, (outs GR16:$dst),
1750 (ins GR16:$src1, GR16:$src2),
1751 "and{w}\t{$src2, $dst|$dst, $src2}", []>, OpSize;
1752def AND32rr_REV : I<0x23, MRMSrcReg, (outs GR32:$dst),
1753 (ins GR32:$src1, GR32:$src2),
1754 "and{l}\t{$src2, $dst|$dst, $src2}", []>;
1755
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001756def AND8rm : I<0x22, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001757 (outs GR8 :$dst), (ins GR8 :$src1, i8mem :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001758 "and{b}\t{$src2, $dst|$dst, $src2}",
Chris Lattner12208612009-04-10 00:16:23 +00001759 [(set GR8:$dst, (and GR8:$src1, (loadi8 addr:$src2))),
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001760 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001761def AND16rm : I<0x23, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001762 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001763 "and{w}\t{$src2, $dst|$dst, $src2}",
Chris Lattner12208612009-04-10 00:16:23 +00001764 [(set GR16:$dst, (and GR16:$src1, (loadi16 addr:$src2))),
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001765 (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001766def AND32rm : I<0x23, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001767 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001768 "and{l}\t{$src2, $dst|$dst, $src2}",
Chris Lattner12208612009-04-10 00:16:23 +00001769 [(set GR32:$dst, (and GR32:$src1, (loadi32 addr:$src2))),
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001770 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001771
1772def AND8ri : Ii8<0x80, MRM4r,
Evan Chengb783fa32007-07-19 01:14:50 +00001773 (outs GR8 :$dst), (ins GR8 :$src1, i8imm :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001774 "and{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001775 [(set GR8:$dst, (and GR8:$src1, imm:$src2)),
1776 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001777def AND16ri : Ii16<0x81, MRM4r,
Evan Chengb783fa32007-07-19 01:14:50 +00001778 (outs GR16:$dst), (ins GR16:$src1, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001779 "and{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001780 [(set GR16:$dst, (and GR16:$src1, imm:$src2)),
1781 (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001782def AND32ri : Ii32<0x81, MRM4r,
Evan Chengb783fa32007-07-19 01:14:50 +00001783 (outs GR32:$dst), (ins GR32:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001784 "and{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001785 [(set GR32:$dst, (and GR32:$src1, imm:$src2)),
1786 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001787def AND16ri8 : Ii8<0x83, MRM4r,
Evan Chengb783fa32007-07-19 01:14:50 +00001788 (outs GR16:$dst), (ins GR16:$src1, i16i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001789 "and{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001790 [(set GR16:$dst, (and GR16:$src1, i16immSExt8:$src2)),
1791 (implicit EFLAGS)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001792 OpSize;
1793def AND32ri8 : Ii8<0x83, MRM4r,
Evan Chengb783fa32007-07-19 01:14:50 +00001794 (outs GR32:$dst), (ins GR32:$src1, i32i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001795 "and{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001796 [(set GR32:$dst, (and GR32:$src1, i32immSExt8:$src2)),
1797 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001798
1799let isTwoAddress = 0 in {
1800 def AND8mr : I<0x20, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001801 (outs), (ins i8mem :$dst, GR8 :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001802 "and{b}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001803 [(store (and (load addr:$dst), GR8:$src), addr:$dst),
1804 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001805 def AND16mr : I<0x21, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001806 (outs), (ins i16mem:$dst, GR16:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001807 "and{w}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001808 [(store (and (load addr:$dst), GR16:$src), addr:$dst),
1809 (implicit EFLAGS)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001810 OpSize;
1811 def AND32mr : I<0x21, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001812 (outs), (ins i32mem:$dst, GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001813 "and{l}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001814 [(store (and (load addr:$dst), GR32:$src), addr:$dst),
1815 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001816 def AND8mi : Ii8<0x80, MRM4m,
Evan Chengb783fa32007-07-19 01:14:50 +00001817 (outs), (ins i8mem :$dst, i8imm :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001818 "and{b}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001819 [(store (and (loadi8 addr:$dst), imm:$src), addr:$dst),
1820 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001821 def AND16mi : Ii16<0x81, MRM4m,
Evan Chengb783fa32007-07-19 01:14:50 +00001822 (outs), (ins i16mem:$dst, i16imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001823 "and{w}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001824 [(store (and (loadi16 addr:$dst), imm:$src), addr:$dst),
1825 (implicit EFLAGS)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001826 OpSize;
1827 def AND32mi : Ii32<0x81, MRM4m,
Evan Chengb783fa32007-07-19 01:14:50 +00001828 (outs), (ins i32mem:$dst, i32imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001829 "and{l}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001830 [(store (and (loadi32 addr:$dst), imm:$src), addr:$dst),
1831 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001832 def AND16mi8 : Ii8<0x83, MRM4m,
Evan Chengb783fa32007-07-19 01:14:50 +00001833 (outs), (ins i16mem:$dst, i16i8imm :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001834 "and{w}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001835 [(store (and (load addr:$dst), i16immSExt8:$src), addr:$dst),
1836 (implicit EFLAGS)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001837 OpSize;
1838 def AND32mi8 : Ii8<0x83, MRM4m,
Evan Chengb783fa32007-07-19 01:14:50 +00001839 (outs), (ins i32mem:$dst, i32i8imm :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001840 "and{l}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001841 [(store (and (load addr:$dst), i32immSExt8:$src), addr:$dst),
1842 (implicit EFLAGS)]>;
Sean Callanan251676e2009-09-02 00:55:49 +00001843
1844 def AND8i8 : Ii8<0x24, RawFrm, (outs), (ins i8imm:$src),
1845 "and{b}\t{$src, %al|%al, $src}", []>;
1846 def AND16i16 : Ii16<0x25, RawFrm, (outs), (ins i16imm:$src),
1847 "and{w}\t{$src, %ax|%ax, $src}", []>, OpSize;
1848 def AND32i32 : Ii32<0x25, RawFrm, (outs), (ins i32imm:$src),
1849 "and{l}\t{$src, %eax|%eax, $src}", []>;
1850
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001851}
1852
1853
1854let isCommutable = 1 in { // X = OR Y, Z --> X = OR Z, Y
Sean Callanan2c48df22009-12-18 00:01:26 +00001855def OR8rr : I<0x08, MRMDestReg, (outs GR8 :$dst),
1856 (ins GR8 :$src1, GR8 :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001857 "or{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001858 [(set GR8:$dst, (or GR8:$src1, GR8:$src2)),
1859 (implicit EFLAGS)]>;
Sean Callanan2c48df22009-12-18 00:01:26 +00001860def OR16rr : I<0x09, MRMDestReg, (outs GR16:$dst),
1861 (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001862 "or{w}\t{$src2, $dst|$dst, $src2}",
Evan Cheng44a441c2010-01-12 18:31:19 +00001863 [(set GR16:$dst, (or GR16:$src1, GR16:$src2)),
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001864 (implicit EFLAGS)]>, OpSize;
Sean Callanan2c48df22009-12-18 00:01:26 +00001865def OR32rr : I<0x09, MRMDestReg, (outs GR32:$dst),
1866 (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001867 "or{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng44a441c2010-01-12 18:31:19 +00001868 [(set GR32:$dst, (or GR32:$src1, GR32:$src2)),
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001869 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001870}
Sean Callanan2c48df22009-12-18 00:01:26 +00001871
1872// OR instructions with the destination register in REG and the source register
1873// in R/M. Included for the disassembler.
1874def OR8rr_REV : I<0x0A, MRMSrcReg, (outs GR8:$dst), (ins GR8:$src1, GR8:$src2),
1875 "or{b}\t{$src2, $dst|$dst, $src2}", []>;
1876def OR16rr_REV : I<0x0B, MRMSrcReg, (outs GR16:$dst),
1877 (ins GR16:$src1, GR16:$src2),
1878 "or{w}\t{$src2, $dst|$dst, $src2}", []>, OpSize;
1879def OR32rr_REV : I<0x0B, MRMSrcReg, (outs GR32:$dst),
1880 (ins GR32:$src1, GR32:$src2),
1881 "or{l}\t{$src2, $dst|$dst, $src2}", []>;
1882
1883def OR8rm : I<0x0A, MRMSrcMem , (outs GR8 :$dst),
1884 (ins GR8 :$src1, i8mem :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001885 "or{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001886 [(set GR8:$dst, (or GR8:$src1, (load addr:$src2))),
1887 (implicit EFLAGS)]>;
Sean Callanan2c48df22009-12-18 00:01:26 +00001888def OR16rm : I<0x0B, MRMSrcMem , (outs GR16:$dst),
1889 (ins GR16:$src1, i16mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001890 "or{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001891 [(set GR16:$dst, (or GR16:$src1, (load addr:$src2))),
1892 (implicit EFLAGS)]>, OpSize;
Sean Callanan2c48df22009-12-18 00:01:26 +00001893def OR32rm : I<0x0B, MRMSrcMem , (outs GR32:$dst),
1894 (ins GR32:$src1, i32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001895 "or{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001896 [(set GR32:$dst, (or GR32:$src1, (load addr:$src2))),
1897 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001898
Sean Callanan2c48df22009-12-18 00:01:26 +00001899def OR8ri : Ii8 <0x80, MRM1r, (outs GR8 :$dst),
1900 (ins GR8 :$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001901 "or{b}\t{$src2, $dst|$dst, $src2}",
Evan Cheng87516752010-01-11 20:18:04 +00001902 [(set GR8:$dst, (or GR8:$src1, imm:$src2)),
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001903 (implicit EFLAGS)]>;
Sean Callanan2c48df22009-12-18 00:01:26 +00001904def OR16ri : Ii16<0x81, MRM1r, (outs GR16:$dst),
1905 (ins GR16:$src1, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001906 "or{w}\t{$src2, $dst|$dst, $src2}",
Evan Cheng44a441c2010-01-12 18:31:19 +00001907 [(set GR16:$dst, (or GR16:$src1, imm:$src2)),
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001908 (implicit EFLAGS)]>, OpSize;
Sean Callanan2c48df22009-12-18 00:01:26 +00001909def OR32ri : Ii32<0x81, MRM1r, (outs GR32:$dst),
1910 (ins GR32:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001911 "or{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng44a441c2010-01-12 18:31:19 +00001912 [(set GR32:$dst, (or GR32:$src1, imm:$src2)),
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001913 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001914
Sean Callanan2c48df22009-12-18 00:01:26 +00001915def OR16ri8 : Ii8<0x83, MRM1r, (outs GR16:$dst),
1916 (ins GR16:$src1, i16i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001917 "or{w}\t{$src2, $dst|$dst, $src2}",
Evan Cheng44a441c2010-01-12 18:31:19 +00001918 [(set GR16:$dst, (or GR16:$src1, i16immSExt8:$src2)),
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001919 (implicit EFLAGS)]>, OpSize;
Sean Callanan2c48df22009-12-18 00:01:26 +00001920def OR32ri8 : Ii8<0x83, MRM1r, (outs GR32:$dst),
1921 (ins GR32:$src1, i32i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001922 "or{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng44a441c2010-01-12 18:31:19 +00001923 [(set GR32:$dst, (or GR32:$src1, i32immSExt8:$src2)),
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001924 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001925let isTwoAddress = 0 in {
Evan Chengb783fa32007-07-19 01:14:50 +00001926 def OR8mr : I<0x08, MRMDestMem, (outs), (ins i8mem:$dst, GR8:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001927 "or{b}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001928 [(store (or (load addr:$dst), GR8:$src), addr:$dst),
1929 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001930 def OR16mr : I<0x09, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001931 "or{w}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001932 [(store (or (load addr:$dst), GR16:$src), addr:$dst),
1933 (implicit EFLAGS)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001934 def OR32mr : I<0x09, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001935 "or{l}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001936 [(store (or (load addr:$dst), GR32:$src), addr:$dst),
1937 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001938 def OR8mi : Ii8<0x80, MRM1m, (outs), (ins i8mem :$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001939 "or{b}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001940 [(store (or (loadi8 addr:$dst), imm:$src), addr:$dst),
1941 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001942 def OR16mi : Ii16<0x81, MRM1m, (outs), (ins i16mem:$dst, i16imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001943 "or{w}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001944 [(store (or (loadi16 addr:$dst), imm:$src), addr:$dst),
1945 (implicit EFLAGS)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001946 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001947 def OR32mi : Ii32<0x81, MRM1m, (outs), (ins i32mem:$dst, i32imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001948 "or{l}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001949 [(store (or (loadi32 addr:$dst), imm:$src), addr:$dst),
1950 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001951 def OR16mi8 : Ii8<0x83, MRM1m, (outs), (ins i16mem:$dst, i16i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001952 "or{w}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001953 [(store (or (load addr:$dst), i16immSExt8:$src), addr:$dst),
1954 (implicit EFLAGS)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001955 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001956 def OR32mi8 : Ii8<0x83, MRM1m, (outs), (ins i32mem:$dst, i32i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001957 "or{l}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001958 [(store (or (load addr:$dst), i32immSExt8:$src), addr:$dst),
1959 (implicit EFLAGS)]>;
Sean Callanan8562bef2009-09-11 19:01:56 +00001960
1961 def OR8i8 : Ii8 <0x0C, RawFrm, (outs), (ins i8imm:$src),
1962 "or{b}\t{$src, %al|%al, $src}", []>;
1963 def OR16i16 : Ii16 <0x0D, RawFrm, (outs), (ins i16imm:$src),
1964 "or{w}\t{$src, %ax|%ax, $src}", []>, OpSize;
1965 def OR32i32 : Ii32 <0x0D, RawFrm, (outs), (ins i32imm:$src),
1966 "or{l}\t{$src, %eax|%eax, $src}", []>;
Bill Wendlingba5d5b02008-05-29 01:02:09 +00001967} // isTwoAddress = 0
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001968
1969
Evan Cheng6f26e8b2008-06-18 08:13:07 +00001970let isCommutable = 1 in { // X = XOR Y, Z --> X = XOR Z, Y
Bill Wendlingba5d5b02008-05-29 01:02:09 +00001971 def XOR8rr : I<0x30, MRMDestReg,
1972 (outs GR8 :$dst), (ins GR8 :$src1, GR8 :$src2),
1973 "xor{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001974 [(set GR8:$dst, (xor GR8:$src1, GR8:$src2)),
1975 (implicit EFLAGS)]>;
Bill Wendlingba5d5b02008-05-29 01:02:09 +00001976 def XOR16rr : I<0x31, MRMDestReg,
1977 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
1978 "xor{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001979 [(set GR16:$dst, (xor GR16:$src1, GR16:$src2)),
1980 (implicit EFLAGS)]>, OpSize;
Bill Wendlingba5d5b02008-05-29 01:02:09 +00001981 def XOR32rr : I<0x31, MRMDestReg,
1982 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
1983 "xor{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001984 [(set GR32:$dst, (xor GR32:$src1, GR32:$src2)),
1985 (implicit EFLAGS)]>;
Evan Cheng6f26e8b2008-06-18 08:13:07 +00001986} // isCommutable = 1
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001987
Sean Callanan2c48df22009-12-18 00:01:26 +00001988// XOR instructions with the destination register in REG and the source register
1989// in R/M. Included for the disassembler.
1990def XOR8rr_REV : I<0x32, MRMSrcReg, (outs GR8:$dst), (ins GR8:$src1, GR8:$src2),
1991 "xor{b}\t{$src2, $dst|$dst, $src2}", []>;
1992def XOR16rr_REV : I<0x33, MRMSrcReg, (outs GR16:$dst),
1993 (ins GR16:$src1, GR16:$src2),
1994 "xor{w}\t{$src2, $dst|$dst, $src2}", []>, OpSize;
1995def XOR32rr_REV : I<0x33, MRMSrcReg, (outs GR32:$dst),
1996 (ins GR32:$src1, GR32:$src2),
1997 "xor{l}\t{$src2, $dst|$dst, $src2}", []>;
1998
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001999def XOR8rm : I<0x32, MRMSrcMem ,
Evan Chengb783fa32007-07-19 01:14:50 +00002000 (outs GR8 :$dst), (ins GR8:$src1, i8mem :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002001 "xor{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00002002 [(set GR8:$dst, (xor GR8:$src1, (load addr:$src2))),
2003 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002004def XOR16rm : I<0x33, MRMSrcMem ,
Evan Chengb783fa32007-07-19 01:14:50 +00002005 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002006 "xor{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00002007 [(set GR16:$dst, (xor GR16:$src1, (load addr:$src2))),
2008 (implicit EFLAGS)]>,
Bill Wendlingba5d5b02008-05-29 01:02:09 +00002009 OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002010def XOR32rm : I<0x33, MRMSrcMem ,
Evan Chengb783fa32007-07-19 01:14:50 +00002011 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002012 "xor{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00002013 [(set GR32:$dst, (xor GR32:$src1, (load addr:$src2))),
2014 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002015
Bill Wendlingbac38eb2008-05-29 03:46:36 +00002016def XOR8ri : Ii8<0x80, MRM6r,
2017 (outs GR8:$dst), (ins GR8:$src1, i8imm:$src2),
2018 "xor{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00002019 [(set GR8:$dst, (xor GR8:$src1, imm:$src2)),
2020 (implicit EFLAGS)]>;
Bill Wendlingbac38eb2008-05-29 03:46:36 +00002021def XOR16ri : Ii16<0x81, MRM6r,
2022 (outs GR16:$dst), (ins GR16:$src1, i16imm:$src2),
2023 "xor{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00002024 [(set GR16:$dst, (xor GR16:$src1, imm:$src2)),
2025 (implicit EFLAGS)]>, OpSize;
Bill Wendlingbac38eb2008-05-29 03:46:36 +00002026def XOR32ri : Ii32<0x81, MRM6r,
2027 (outs GR32:$dst), (ins GR32:$src1, i32imm:$src2),
2028 "xor{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00002029 [(set GR32:$dst, (xor GR32:$src1, imm:$src2)),
2030 (implicit EFLAGS)]>;
Bill Wendlingbac38eb2008-05-29 03:46:36 +00002031def XOR16ri8 : Ii8<0x83, MRM6r,
2032 (outs GR16:$dst), (ins GR16:$src1, i16i8imm:$src2),
2033 "xor{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00002034 [(set GR16:$dst, (xor GR16:$src1, i16immSExt8:$src2)),
2035 (implicit EFLAGS)]>,
Bill Wendlingbac38eb2008-05-29 03:46:36 +00002036 OpSize;
2037def XOR32ri8 : Ii8<0x83, MRM6r,
2038 (outs GR32:$dst), (ins GR32:$src1, i32i8imm:$src2),
2039 "xor{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00002040 [(set GR32:$dst, (xor GR32:$src1, i32immSExt8:$src2)),
2041 (implicit EFLAGS)]>;
Bill Wendlingba5d5b02008-05-29 01:02:09 +00002042
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002043let isTwoAddress = 0 in {
2044 def XOR8mr : I<0x30, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00002045 (outs), (ins i8mem :$dst, GR8 :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002046 "xor{b}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00002047 [(store (xor (load addr:$dst), GR8:$src), addr:$dst),
2048 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002049 def XOR16mr : I<0x31, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00002050 (outs), (ins i16mem:$dst, GR16:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002051 "xor{w}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00002052 [(store (xor (load addr:$dst), GR16:$src), addr:$dst),
2053 (implicit EFLAGS)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002054 OpSize;
2055 def XOR32mr : I<0x31, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00002056 (outs), (ins i32mem:$dst, GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002057 "xor{l}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00002058 [(store (xor (load addr:$dst), GR32:$src), addr:$dst),
2059 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002060 def XOR8mi : Ii8<0x80, MRM6m,
Evan Chengb783fa32007-07-19 01:14:50 +00002061 (outs), (ins i8mem :$dst, i8imm :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002062 "xor{b}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00002063 [(store (xor (loadi8 addr:$dst), imm:$src), addr:$dst),
2064 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002065 def XOR16mi : Ii16<0x81, MRM6m,
Evan Chengb783fa32007-07-19 01:14:50 +00002066 (outs), (ins i16mem:$dst, i16imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002067 "xor{w}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00002068 [(store (xor (loadi16 addr:$dst), imm:$src), addr:$dst),
2069 (implicit EFLAGS)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002070 OpSize;
2071 def XOR32mi : Ii32<0x81, MRM6m,
Evan Chengb783fa32007-07-19 01:14:50 +00002072 (outs), (ins i32mem:$dst, i32imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002073 "xor{l}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00002074 [(store (xor (loadi32 addr:$dst), imm:$src), addr:$dst),
2075 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002076 def XOR16mi8 : Ii8<0x83, MRM6m,
Evan Chengb783fa32007-07-19 01:14:50 +00002077 (outs), (ins i16mem:$dst, i16i8imm :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002078 "xor{w}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00002079 [(store (xor (load addr:$dst), i16immSExt8:$src), addr:$dst),
2080 (implicit EFLAGS)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002081 OpSize;
2082 def XOR32mi8 : Ii8<0x83, MRM6m,
Evan Chengb783fa32007-07-19 01:14:50 +00002083 (outs), (ins i32mem:$dst, i32i8imm :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002084 "xor{l}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00002085 [(store (xor (load addr:$dst), i32immSExt8:$src), addr:$dst),
2086 (implicit EFLAGS)]>;
Sean Callanan794457a2009-09-10 19:52:26 +00002087
2088 def XOR8i8 : Ii8 <0x34, RawFrm, (outs), (ins i8imm:$src),
2089 "xor{b}\t{$src, %al|%al, $src}", []>;
2090 def XOR16i16 : Ii16 <0x35, RawFrm, (outs), (ins i16imm:$src),
2091 "xor{w}\t{$src, %ax|%ax, $src}", []>, OpSize;
2092 def XOR32i32 : Ii32 <0x35, RawFrm, (outs), (ins i32imm:$src),
2093 "xor{l}\t{$src, %eax|%eax, $src}", []>;
Bill Wendlingba5d5b02008-05-29 01:02:09 +00002094} // isTwoAddress = 0
Evan Cheng55687072007-09-14 21:48:26 +00002095} // Defs = [EFLAGS]
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002096
2097// Shift instructions
Evan Cheng55687072007-09-14 21:48:26 +00002098let Defs = [EFLAGS] in {
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002099let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00002100def SHL8rCL : I<0xD2, MRM4r, (outs GR8 :$dst), (ins GR8 :$src),
Eli Friedman378ea832009-06-19 04:48:38 +00002101 "shl{b}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002102 [(set GR8:$dst, (shl GR8:$src, CL))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002103def SHL16rCL : I<0xD3, MRM4r, (outs GR16:$dst), (ins GR16:$src),
Eli Friedman378ea832009-06-19 04:48:38 +00002104 "shl{w}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002105 [(set GR16:$dst, (shl GR16:$src, CL))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002106def SHL32rCL : I<0xD3, MRM4r, (outs GR32:$dst), (ins GR32:$src),
Eli Friedman378ea832009-06-19 04:48:38 +00002107 "shl{l}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002108 [(set GR32:$dst, (shl GR32:$src, CL))]>;
Bill Wendlingba5d5b02008-05-29 01:02:09 +00002109} // Uses = [CL]
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002110
Evan Chengb783fa32007-07-19 01:14:50 +00002111def SHL8ri : Ii8<0xC0, MRM4r, (outs GR8 :$dst), (ins GR8 :$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002112 "shl{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002113 [(set GR8:$dst, (shl GR8:$src1, (i8 imm:$src2)))]>;
2114let isConvertibleToThreeAddress = 1 in { // Can transform into LEA.
Evan Chengb783fa32007-07-19 01:14:50 +00002115def SHL16ri : Ii8<0xC1, MRM4r, (outs GR16:$dst), (ins GR16:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002116 "shl{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002117 [(set GR16:$dst, (shl GR16:$src1, (i8 imm:$src2)))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002118def SHL32ri : Ii8<0xC1, MRM4r, (outs GR32:$dst), (ins GR32:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002119 "shl{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002120 [(set GR32:$dst, (shl GR32:$src1, (i8 imm:$src2)))]>;
Sean Callananca503e02009-09-16 02:28:43 +00002121
2122// NOTE: We don't include patterns for shifts of a register by one, because
2123// 'add reg,reg' is cheaper.
2124
2125def SHL8r1 : I<0xD0, MRM4r, (outs GR8:$dst), (ins GR8:$src1),
2126 "shl{b}\t$dst", []>;
2127def SHL16r1 : I<0xD1, MRM4r, (outs GR16:$dst), (ins GR16:$src1),
2128 "shl{w}\t$dst", []>, OpSize;
2129def SHL32r1 : I<0xD1, MRM4r, (outs GR32:$dst), (ins GR32:$src1),
2130 "shl{l}\t$dst", []>;
2131
Bill Wendlingba5d5b02008-05-29 01:02:09 +00002132} // isConvertibleToThreeAddress = 1
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002133
2134let isTwoAddress = 0 in {
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002135 let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00002136 def SHL8mCL : I<0xD2, MRM4m, (outs), (ins i8mem :$dst),
Eli Friedman378ea832009-06-19 04:48:38 +00002137 "shl{b}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002138 [(store (shl (loadi8 addr:$dst), CL), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002139 def SHL16mCL : I<0xD3, MRM4m, (outs), (ins i16mem:$dst),
Eli Friedman378ea832009-06-19 04:48:38 +00002140 "shl{w}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002141 [(store (shl (loadi16 addr:$dst), CL), addr:$dst)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002142 def SHL32mCL : I<0xD3, MRM4m, (outs), (ins i32mem:$dst),
Eli Friedman378ea832009-06-19 04:48:38 +00002143 "shl{l}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002144 [(store (shl (loadi32 addr:$dst), CL), addr:$dst)]>;
2145 }
Evan Chengb783fa32007-07-19 01:14:50 +00002146 def SHL8mi : Ii8<0xC0, MRM4m, (outs), (ins i8mem :$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002147 "shl{b}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002148 [(store (shl (loadi8 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002149 def SHL16mi : Ii8<0xC1, MRM4m, (outs), (ins i16mem:$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002150 "shl{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002151 [(store (shl (loadi16 addr:$dst), (i8 imm:$src)), addr:$dst)]>,
2152 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002153 def SHL32mi : Ii8<0xC1, MRM4m, (outs), (ins i32mem:$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002154 "shl{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002155 [(store (shl (loadi32 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
2156
2157 // Shift by 1
Evan Chengb783fa32007-07-19 01:14:50 +00002158 def SHL8m1 : I<0xD0, MRM4m, (outs), (ins i8mem :$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002159 "shl{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002160 [(store (shl (loadi8 addr:$dst), (i8 1)), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002161 def SHL16m1 : I<0xD1, MRM4m, (outs), (ins i16mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002162 "shl{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002163 [(store (shl (loadi16 addr:$dst), (i8 1)), addr:$dst)]>,
2164 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002165 def SHL32m1 : I<0xD1, MRM4m, (outs), (ins i32mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002166 "shl{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002167 [(store (shl (loadi32 addr:$dst), (i8 1)), addr:$dst)]>;
2168}
2169
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002170let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00002171def SHR8rCL : I<0xD2, MRM5r, (outs GR8 :$dst), (ins GR8 :$src),
Eli Friedman378ea832009-06-19 04:48:38 +00002172 "shr{b}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002173 [(set GR8:$dst, (srl GR8:$src, CL))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002174def SHR16rCL : I<0xD3, MRM5r, (outs GR16:$dst), (ins GR16:$src),
Eli Friedman378ea832009-06-19 04:48:38 +00002175 "shr{w}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002176 [(set GR16:$dst, (srl GR16:$src, CL))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002177def SHR32rCL : I<0xD3, MRM5r, (outs GR32:$dst), (ins GR32:$src),
Eli Friedman378ea832009-06-19 04:48:38 +00002178 "shr{l}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002179 [(set GR32:$dst, (srl GR32:$src, CL))]>;
2180}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002181
Evan Chengb783fa32007-07-19 01:14:50 +00002182def SHR8ri : Ii8<0xC0, MRM5r, (outs GR8:$dst), (ins GR8:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002183 "shr{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002184 [(set GR8:$dst, (srl GR8:$src1, (i8 imm:$src2)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002185def SHR16ri : Ii8<0xC1, MRM5r, (outs GR16:$dst), (ins GR16:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002186 "shr{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002187 [(set GR16:$dst, (srl GR16:$src1, (i8 imm:$src2)))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002188def SHR32ri : Ii8<0xC1, MRM5r, (outs GR32:$dst), (ins GR32:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002189 "shr{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002190 [(set GR32:$dst, (srl GR32:$src1, (i8 imm:$src2)))]>;
2191
2192// Shift by 1
Evan Chengb783fa32007-07-19 01:14:50 +00002193def SHR8r1 : I<0xD0, MRM5r, (outs GR8:$dst), (ins GR8:$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00002194 "shr{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002195 [(set GR8:$dst, (srl GR8:$src1, (i8 1)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002196def SHR16r1 : I<0xD1, MRM5r, (outs GR16:$dst), (ins GR16:$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00002197 "shr{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002198 [(set GR16:$dst, (srl GR16:$src1, (i8 1)))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002199def SHR32r1 : I<0xD1, MRM5r, (outs GR32:$dst), (ins GR32:$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00002200 "shr{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002201 [(set GR32:$dst, (srl GR32:$src1, (i8 1)))]>;
2202
2203let isTwoAddress = 0 in {
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002204 let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00002205 def SHR8mCL : I<0xD2, MRM5m, (outs), (ins i8mem :$dst),
Eli Friedman378ea832009-06-19 04:48:38 +00002206 "shr{b}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002207 [(store (srl (loadi8 addr:$dst), CL), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002208 def SHR16mCL : I<0xD3, MRM5m, (outs), (ins i16mem:$dst),
Eli Friedman378ea832009-06-19 04:48:38 +00002209 "shr{w}\t{%cl, $dst|$dst, CL}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002210 [(store (srl (loadi16 addr:$dst), CL), addr:$dst)]>,
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002211 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002212 def SHR32mCL : I<0xD3, MRM5m, (outs), (ins i32mem:$dst),
Eli Friedman378ea832009-06-19 04:48:38 +00002213 "shr{l}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002214 [(store (srl (loadi32 addr:$dst), CL), addr:$dst)]>;
2215 }
Evan Chengb783fa32007-07-19 01:14:50 +00002216 def SHR8mi : Ii8<0xC0, MRM5m, (outs), (ins i8mem :$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002217 "shr{b}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002218 [(store (srl (loadi8 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002219 def SHR16mi : Ii8<0xC1, MRM5m, (outs), (ins i16mem:$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002220 "shr{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002221 [(store (srl (loadi16 addr:$dst), (i8 imm:$src)), addr:$dst)]>,
2222 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002223 def SHR32mi : Ii8<0xC1, MRM5m, (outs), (ins i32mem:$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002224 "shr{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002225 [(store (srl (loadi32 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
2226
2227 // Shift by 1
Evan Chengb783fa32007-07-19 01:14:50 +00002228 def SHR8m1 : I<0xD0, MRM5m, (outs), (ins i8mem :$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002229 "shr{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002230 [(store (srl (loadi8 addr:$dst), (i8 1)), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002231 def SHR16m1 : I<0xD1, MRM5m, (outs), (ins i16mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002232 "shr{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002233 [(store (srl (loadi16 addr:$dst), (i8 1)), addr:$dst)]>,OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002234 def SHR32m1 : I<0xD1, MRM5m, (outs), (ins i32mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002235 "shr{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002236 [(store (srl (loadi32 addr:$dst), (i8 1)), addr:$dst)]>;
2237}
2238
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002239let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00002240def SAR8rCL : I<0xD2, MRM7r, (outs GR8 :$dst), (ins GR8 :$src),
Eli Friedman378ea832009-06-19 04:48:38 +00002241 "sar{b}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002242 [(set GR8:$dst, (sra GR8:$src, CL))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002243def SAR16rCL : I<0xD3, MRM7r, (outs GR16:$dst), (ins GR16:$src),
Eli Friedman378ea832009-06-19 04:48:38 +00002244 "sar{w}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002245 [(set GR16:$dst, (sra GR16:$src, CL))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002246def SAR32rCL : I<0xD3, MRM7r, (outs GR32:$dst), (ins GR32:$src),
Eli Friedman378ea832009-06-19 04:48:38 +00002247 "sar{l}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002248 [(set GR32:$dst, (sra GR32:$src, CL))]>;
2249}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002250
Evan Chengb783fa32007-07-19 01:14:50 +00002251def SAR8ri : Ii8<0xC0, MRM7r, (outs GR8 :$dst), (ins GR8 :$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002252 "sar{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002253 [(set GR8:$dst, (sra GR8:$src1, (i8 imm:$src2)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002254def SAR16ri : Ii8<0xC1, MRM7r, (outs GR16:$dst), (ins GR16:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002255 "sar{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002256 [(set GR16:$dst, (sra GR16:$src1, (i8 imm:$src2)))]>,
2257 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002258def SAR32ri : Ii8<0xC1, MRM7r, (outs GR32:$dst), (ins GR32:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002259 "sar{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002260 [(set GR32:$dst, (sra GR32:$src1, (i8 imm:$src2)))]>;
2261
2262// Shift by 1
Evan Chengb783fa32007-07-19 01:14:50 +00002263def SAR8r1 : I<0xD0, MRM7r, (outs GR8 :$dst), (ins GR8 :$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00002264 "sar{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002265 [(set GR8:$dst, (sra GR8:$src1, (i8 1)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002266def SAR16r1 : I<0xD1, MRM7r, (outs GR16:$dst), (ins GR16:$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00002267 "sar{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002268 [(set GR16:$dst, (sra GR16:$src1, (i8 1)))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002269def SAR32r1 : I<0xD1, MRM7r, (outs GR32:$dst), (ins GR32:$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00002270 "sar{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002271 [(set GR32:$dst, (sra GR32:$src1, (i8 1)))]>;
2272
2273let isTwoAddress = 0 in {
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002274 let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00002275 def SAR8mCL : I<0xD2, MRM7m, (outs), (ins i8mem :$dst),
Eli Friedman378ea832009-06-19 04:48:38 +00002276 "sar{b}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002277 [(store (sra (loadi8 addr:$dst), CL), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002278 def SAR16mCL : I<0xD3, MRM7m, (outs), (ins i16mem:$dst),
Eli Friedman378ea832009-06-19 04:48:38 +00002279 "sar{w}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002280 [(store (sra (loadi16 addr:$dst), CL), addr:$dst)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002281 def SAR32mCL : I<0xD3, MRM7m, (outs), (ins i32mem:$dst),
Eli Friedman378ea832009-06-19 04:48:38 +00002282 "sar{l}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002283 [(store (sra (loadi32 addr:$dst), CL), addr:$dst)]>;
2284 }
Evan Chengb783fa32007-07-19 01:14:50 +00002285 def SAR8mi : Ii8<0xC0, MRM7m, (outs), (ins i8mem :$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002286 "sar{b}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002287 [(store (sra (loadi8 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002288 def SAR16mi : Ii8<0xC1, MRM7m, (outs), (ins i16mem:$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002289 "sar{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002290 [(store (sra (loadi16 addr:$dst), (i8 imm:$src)), addr:$dst)]>,
2291 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002292 def SAR32mi : Ii8<0xC1, MRM7m, (outs), (ins i32mem:$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002293 "sar{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002294 [(store (sra (loadi32 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
2295
2296 // Shift by 1
Evan Chengb783fa32007-07-19 01:14:50 +00002297 def SAR8m1 : I<0xD0, MRM7m, (outs), (ins i8mem :$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002298 "sar{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002299 [(store (sra (loadi8 addr:$dst), (i8 1)), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002300 def SAR16m1 : I<0xD1, MRM7m, (outs), (ins i16mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002301 "sar{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002302 [(store (sra (loadi16 addr:$dst), (i8 1)), addr:$dst)]>,
2303 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002304 def SAR32m1 : I<0xD1, MRM7m, (outs), (ins i32mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002305 "sar{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002306 [(store (sra (loadi32 addr:$dst), (i8 1)), addr:$dst)]>;
2307}
2308
2309// Rotate instructions
Sean Callanan3c8eecd2009-09-18 19:35:23 +00002310
2311def RCL8r1 : I<0xD0, MRM2r, (outs GR8:$dst), (ins GR8:$src),
2312 "rcl{b}\t{1, $dst|$dst, 1}", []>;
2313def RCL8m1 : I<0xD0, MRM2m, (outs i8mem:$dst), (ins i8mem:$src),
2314 "rcl{b}\t{1, $dst|$dst, 1}", []>;
2315let Uses = [CL] in {
2316def RCL8rCL : I<0xD2, MRM2r, (outs GR8:$dst), (ins GR8:$src),
2317 "rcl{b}\t{%cl, $dst|$dst, CL}", []>;
2318def RCL8mCL : I<0xD2, MRM2m, (outs i8mem:$dst), (ins i8mem:$src),
2319 "rcl{b}\t{%cl, $dst|$dst, CL}", []>;
2320}
2321def RCL8ri : Ii8<0xC0, MRM2r, (outs GR8:$dst), (ins GR8:$src, i8imm:$cnt),
2322 "rcl{b}\t{$cnt, $dst|$dst, $cnt}", []>;
2323def RCL8mi : Ii8<0xC0, MRM2m, (outs i8mem:$dst), (ins i8mem:$src, i8imm:$cnt),
2324 "rcl{b}\t{$cnt, $dst|$dst, $cnt}", []>;
2325
2326def RCL16r1 : I<0xD1, MRM2r, (outs GR16:$dst), (ins GR16:$src),
2327 "rcl{w}\t{1, $dst|$dst, 1}", []>, OpSize;
2328def RCL16m1 : I<0xD1, MRM2m, (outs i16mem:$dst), (ins i16mem:$src),
2329 "rcl{w}\t{1, $dst|$dst, 1}", []>, OpSize;
2330let Uses = [CL] in {
2331def RCL16rCL : I<0xD3, MRM2r, (outs GR16:$dst), (ins GR16:$src),
2332 "rcl{w}\t{%cl, $dst|$dst, CL}", []>, OpSize;
2333def RCL16mCL : I<0xD3, MRM2m, (outs i16mem:$dst), (ins i16mem:$src),
2334 "rcl{w}\t{%cl, $dst|$dst, CL}", []>, OpSize;
2335}
2336def RCL16ri : Ii8<0xC1, MRM2r, (outs GR16:$dst), (ins GR16:$src, i8imm:$cnt),
2337 "rcl{w}\t{$cnt, $dst|$dst, $cnt}", []>, OpSize;
Sean Callanan2c48df22009-12-18 00:01:26 +00002338def RCL16mi : Ii8<0xC1, MRM2m, (outs i16mem:$dst),
2339 (ins i16mem:$src, i8imm:$cnt),
Sean Callanan3c8eecd2009-09-18 19:35:23 +00002340 "rcl{w}\t{$cnt, $dst|$dst, $cnt}", []>, OpSize;
2341
2342def RCL32r1 : I<0xD1, MRM2r, (outs GR32:$dst), (ins GR32:$src),
2343 "rcl{l}\t{1, $dst|$dst, 1}", []>;
2344def RCL32m1 : I<0xD1, MRM2m, (outs i32mem:$dst), (ins i32mem:$src),
2345 "rcl{l}\t{1, $dst|$dst, 1}", []>;
2346let Uses = [CL] in {
2347def RCL32rCL : I<0xD3, MRM2r, (outs GR32:$dst), (ins GR32:$src),
2348 "rcl{l}\t{%cl, $dst|$dst, CL}", []>;
2349def RCL32mCL : I<0xD3, MRM2m, (outs i32mem:$dst), (ins i32mem:$src),
2350 "rcl{l}\t{%cl, $dst|$dst, CL}", []>;
2351}
2352def RCL32ri : Ii8<0xC1, MRM2r, (outs GR32:$dst), (ins GR32:$src, i8imm:$cnt),
2353 "rcl{l}\t{$cnt, $dst|$dst, $cnt}", []>;
Sean Callanan2c48df22009-12-18 00:01:26 +00002354def RCL32mi : Ii8<0xC1, MRM2m, (outs i32mem:$dst),
2355 (ins i32mem:$src, i8imm:$cnt),
Sean Callanan3c8eecd2009-09-18 19:35:23 +00002356 "rcl{l}\t{$cnt, $dst|$dst, $cnt}", []>;
2357
2358def RCR8r1 : I<0xD0, MRM3r, (outs GR8:$dst), (ins GR8:$src),
2359 "rcr{b}\t{1, $dst|$dst, 1}", []>;
2360def RCR8m1 : I<0xD0, MRM3m, (outs i8mem:$dst), (ins i8mem:$src),
2361 "rcr{b}\t{1, $dst|$dst, 1}", []>;
2362let Uses = [CL] in {
2363def RCR8rCL : I<0xD2, MRM3r, (outs GR8:$dst), (ins GR8:$src),
2364 "rcr{b}\t{%cl, $dst|$dst, CL}", []>;
2365def RCR8mCL : I<0xD2, MRM3m, (outs i8mem:$dst), (ins i8mem:$src),
2366 "rcr{b}\t{%cl, $dst|$dst, CL}", []>;
2367}
2368def RCR8ri : Ii8<0xC0, MRM3r, (outs GR8:$dst), (ins GR8:$src, i8imm:$cnt),
2369 "rcr{b}\t{$cnt, $dst|$dst, $cnt}", []>;
2370def RCR8mi : Ii8<0xC0, MRM3m, (outs i8mem:$dst), (ins i8mem:$src, i8imm:$cnt),
2371 "rcr{b}\t{$cnt, $dst|$dst, $cnt}", []>;
2372
2373def RCR16r1 : I<0xD1, MRM3r, (outs GR16:$dst), (ins GR16:$src),
2374 "rcr{w}\t{1, $dst|$dst, 1}", []>, OpSize;
2375def RCR16m1 : I<0xD1, MRM3m, (outs i16mem:$dst), (ins i16mem:$src),
2376 "rcr{w}\t{1, $dst|$dst, 1}", []>, OpSize;
2377let Uses = [CL] in {
2378def RCR16rCL : I<0xD3, MRM3r, (outs GR16:$dst), (ins GR16:$src),
2379 "rcr{w}\t{%cl, $dst|$dst, CL}", []>, OpSize;
2380def RCR16mCL : I<0xD3, MRM3m, (outs i16mem:$dst), (ins i16mem:$src),
2381 "rcr{w}\t{%cl, $dst|$dst, CL}", []>, OpSize;
2382}
2383def RCR16ri : Ii8<0xC1, MRM3r, (outs GR16:$dst), (ins GR16:$src, i8imm:$cnt),
2384 "rcr{w}\t{$cnt, $dst|$dst, $cnt}", []>, OpSize;
Sean Callanan2c48df22009-12-18 00:01:26 +00002385def RCR16mi : Ii8<0xC1, MRM3m, (outs i16mem:$dst),
2386 (ins i16mem:$src, i8imm:$cnt),
Sean Callanan3c8eecd2009-09-18 19:35:23 +00002387 "rcr{w}\t{$cnt, $dst|$dst, $cnt}", []>, OpSize;
2388
2389def RCR32r1 : I<0xD1, MRM3r, (outs GR32:$dst), (ins GR32:$src),
2390 "rcr{l}\t{1, $dst|$dst, 1}", []>;
2391def RCR32m1 : I<0xD1, MRM3m, (outs i32mem:$dst), (ins i32mem:$src),
2392 "rcr{l}\t{1, $dst|$dst, 1}", []>;
2393let Uses = [CL] in {
2394def RCR32rCL : I<0xD3, MRM3r, (outs GR32:$dst), (ins GR32:$src),
2395 "rcr{l}\t{%cl, $dst|$dst, CL}", []>;
2396def RCR32mCL : I<0xD3, MRM3m, (outs i32mem:$dst), (ins i32mem:$src),
2397 "rcr{l}\t{%cl, $dst|$dst, CL}", []>;
2398}
2399def RCR32ri : Ii8<0xC1, MRM3r, (outs GR32:$dst), (ins GR32:$src, i8imm:$cnt),
2400 "rcr{l}\t{$cnt, $dst|$dst, $cnt}", []>;
Sean Callanan2c48df22009-12-18 00:01:26 +00002401def RCR32mi : Ii8<0xC1, MRM3m, (outs i32mem:$dst),
2402 (ins i32mem:$src, i8imm:$cnt),
Sean Callanan3c8eecd2009-09-18 19:35:23 +00002403 "rcr{l}\t{$cnt, $dst|$dst, $cnt}", []>;
2404
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002405// FIXME: provide shorter instructions when imm8 == 1
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002406let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00002407def ROL8rCL : I<0xD2, MRM0r, (outs GR8 :$dst), (ins GR8 :$src),
Eli Friedman378ea832009-06-19 04:48:38 +00002408 "rol{b}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002409 [(set GR8:$dst, (rotl GR8:$src, CL))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002410def ROL16rCL : I<0xD3, MRM0r, (outs GR16:$dst), (ins GR16:$src),
Eli Friedman378ea832009-06-19 04:48:38 +00002411 "rol{w}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002412 [(set GR16:$dst, (rotl GR16:$src, CL))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002413def ROL32rCL : I<0xD3, MRM0r, (outs GR32:$dst), (ins GR32:$src),
Eli Friedman378ea832009-06-19 04:48:38 +00002414 "rol{l}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002415 [(set GR32:$dst, (rotl GR32:$src, CL))]>;
2416}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002417
Evan Chengb783fa32007-07-19 01:14:50 +00002418def ROL8ri : Ii8<0xC0, MRM0r, (outs GR8 :$dst), (ins GR8 :$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002419 "rol{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002420 [(set GR8:$dst, (rotl GR8:$src1, (i8 imm:$src2)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002421def ROL16ri : Ii8<0xC1, MRM0r, (outs GR16:$dst), (ins GR16:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002422 "rol{w}\t{$src2, $dst|$dst, $src2}",
Sean Callanan2c48df22009-12-18 00:01:26 +00002423 [(set GR16:$dst, (rotl GR16:$src1, (i8 imm:$src2)))]>,
2424 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002425def ROL32ri : Ii8<0xC1, MRM0r, (outs GR32:$dst), (ins GR32:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002426 "rol{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002427 [(set GR32:$dst, (rotl GR32:$src1, (i8 imm:$src2)))]>;
2428
2429// Rotate by 1
Evan Chengb783fa32007-07-19 01:14:50 +00002430def ROL8r1 : I<0xD0, MRM0r, (outs GR8 :$dst), (ins GR8 :$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00002431 "rol{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002432 [(set GR8:$dst, (rotl GR8:$src1, (i8 1)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002433def ROL16r1 : I<0xD1, MRM0r, (outs GR16:$dst), (ins GR16:$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00002434 "rol{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002435 [(set GR16:$dst, (rotl GR16:$src1, (i8 1)))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002436def ROL32r1 : I<0xD1, MRM0r, (outs GR32:$dst), (ins GR32:$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00002437 "rol{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002438 [(set GR32:$dst, (rotl GR32:$src1, (i8 1)))]>;
2439
2440let isTwoAddress = 0 in {
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002441 let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00002442 def ROL8mCL : I<0xD2, MRM0m, (outs), (ins i8mem :$dst),
Eli Friedman378ea832009-06-19 04:48:38 +00002443 "rol{b}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002444 [(store (rotl (loadi8 addr:$dst), CL), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002445 def ROL16mCL : I<0xD3, MRM0m, (outs), (ins i16mem:$dst),
Eli Friedman378ea832009-06-19 04:48:38 +00002446 "rol{w}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002447 [(store (rotl (loadi16 addr:$dst), CL), addr:$dst)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002448 def ROL32mCL : I<0xD3, MRM0m, (outs), (ins i32mem:$dst),
Eli Friedman378ea832009-06-19 04:48:38 +00002449 "rol{l}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002450 [(store (rotl (loadi32 addr:$dst), CL), addr:$dst)]>;
2451 }
Evan Chengb783fa32007-07-19 01:14:50 +00002452 def ROL8mi : Ii8<0xC0, MRM0m, (outs), (ins i8mem :$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002453 "rol{b}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002454 [(store (rotl (loadi8 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002455 def ROL16mi : Ii8<0xC1, MRM0m, (outs), (ins i16mem:$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002456 "rol{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002457 [(store (rotl (loadi16 addr:$dst), (i8 imm:$src)), addr:$dst)]>,
2458 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002459 def ROL32mi : Ii8<0xC1, MRM0m, (outs), (ins i32mem:$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002460 "rol{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002461 [(store (rotl (loadi32 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
2462
2463 // Rotate by 1
Evan Chengb783fa32007-07-19 01:14:50 +00002464 def ROL8m1 : I<0xD0, MRM0m, (outs), (ins i8mem :$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002465 "rol{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002466 [(store (rotl (loadi8 addr:$dst), (i8 1)), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002467 def ROL16m1 : I<0xD1, MRM0m, (outs), (ins i16mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002468 "rol{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002469 [(store (rotl (loadi16 addr:$dst), (i8 1)), addr:$dst)]>,
2470 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002471 def ROL32m1 : I<0xD1, MRM0m, (outs), (ins i32mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002472 "rol{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002473 [(store (rotl (loadi32 addr:$dst), (i8 1)), addr:$dst)]>;
2474}
2475
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002476let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00002477def ROR8rCL : I<0xD2, MRM1r, (outs GR8 :$dst), (ins GR8 :$src),
Eli Friedman378ea832009-06-19 04:48:38 +00002478 "ror{b}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002479 [(set GR8:$dst, (rotr GR8:$src, CL))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002480def ROR16rCL : I<0xD3, MRM1r, (outs GR16:$dst), (ins GR16:$src),
Eli Friedman378ea832009-06-19 04:48:38 +00002481 "ror{w}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002482 [(set GR16:$dst, (rotr GR16:$src, CL))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002483def ROR32rCL : I<0xD3, MRM1r, (outs GR32:$dst), (ins GR32:$src),
Eli Friedman378ea832009-06-19 04:48:38 +00002484 "ror{l}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002485 [(set GR32:$dst, (rotr GR32:$src, CL))]>;
2486}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002487
Evan Chengb783fa32007-07-19 01:14:50 +00002488def ROR8ri : Ii8<0xC0, MRM1r, (outs GR8 :$dst), (ins GR8 :$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002489 "ror{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002490 [(set GR8:$dst, (rotr GR8:$src1, (i8 imm:$src2)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002491def ROR16ri : Ii8<0xC1, MRM1r, (outs GR16:$dst), (ins GR16:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002492 "ror{w}\t{$src2, $dst|$dst, $src2}",
Sean Callanan2c48df22009-12-18 00:01:26 +00002493 [(set GR16:$dst, (rotr GR16:$src1, (i8 imm:$src2)))]>,
2494 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002495def ROR32ri : Ii8<0xC1, MRM1r, (outs GR32:$dst), (ins GR32:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002496 "ror{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002497 [(set GR32:$dst, (rotr GR32:$src1, (i8 imm:$src2)))]>;
2498
2499// Rotate by 1
Evan Chengb783fa32007-07-19 01:14:50 +00002500def ROR8r1 : I<0xD0, MRM1r, (outs GR8 :$dst), (ins GR8 :$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00002501 "ror{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002502 [(set GR8:$dst, (rotr GR8:$src1, (i8 1)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002503def ROR16r1 : I<0xD1, MRM1r, (outs GR16:$dst), (ins GR16:$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00002504 "ror{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002505 [(set GR16:$dst, (rotr GR16:$src1, (i8 1)))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002506def ROR32r1 : I<0xD1, MRM1r, (outs GR32:$dst), (ins GR32:$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00002507 "ror{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002508 [(set GR32:$dst, (rotr GR32:$src1, (i8 1)))]>;
2509
2510let isTwoAddress = 0 in {
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002511 let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00002512 def ROR8mCL : I<0xD2, MRM1m, (outs), (ins i8mem :$dst),
Eli Friedman378ea832009-06-19 04:48:38 +00002513 "ror{b}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002514 [(store (rotr (loadi8 addr:$dst), CL), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002515 def ROR16mCL : I<0xD3, MRM1m, (outs), (ins i16mem:$dst),
Eli Friedman378ea832009-06-19 04:48:38 +00002516 "ror{w}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002517 [(store (rotr (loadi16 addr:$dst), CL), addr:$dst)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002518 def ROR32mCL : I<0xD3, MRM1m, (outs), (ins i32mem:$dst),
Eli Friedman378ea832009-06-19 04:48:38 +00002519 "ror{l}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002520 [(store (rotr (loadi32 addr:$dst), CL), addr:$dst)]>;
2521 }
Evan Chengb783fa32007-07-19 01:14:50 +00002522 def ROR8mi : Ii8<0xC0, MRM1m, (outs), (ins i8mem :$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002523 "ror{b}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002524 [(store (rotr (loadi8 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002525 def ROR16mi : Ii8<0xC1, MRM1m, (outs), (ins i16mem:$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002526 "ror{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002527 [(store (rotr (loadi16 addr:$dst), (i8 imm:$src)), addr:$dst)]>,
2528 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002529 def ROR32mi : Ii8<0xC1, MRM1m, (outs), (ins i32mem:$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002530 "ror{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002531 [(store (rotr (loadi32 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
2532
2533 // Rotate by 1
Evan Chengb783fa32007-07-19 01:14:50 +00002534 def ROR8m1 : I<0xD0, MRM1m, (outs), (ins i8mem :$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002535 "ror{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002536 [(store (rotr (loadi8 addr:$dst), (i8 1)), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002537 def ROR16m1 : I<0xD1, MRM1m, (outs), (ins i16mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002538 "ror{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002539 [(store (rotr (loadi16 addr:$dst), (i8 1)), addr:$dst)]>,
2540 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002541 def ROR32m1 : I<0xD1, MRM1m, (outs), (ins i32mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002542 "ror{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002543 [(store (rotr (loadi32 addr:$dst), (i8 1)), addr:$dst)]>;
2544}
2545
2546
2547
2548// Double shift instructions (generalizations of rotate)
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002549let Uses = [CL] in {
Sean Callanan2c48df22009-12-18 00:01:26 +00002550def SHLD32rrCL : I<0xA5, MRMDestReg, (outs GR32:$dst),
2551 (ins GR32:$src1, GR32:$src2),
Eli Friedman378ea832009-06-19 04:48:38 +00002552 "shld{l}\t{%cl, $src2, $dst|$dst, $src2, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002553 [(set GR32:$dst, (X86shld GR32:$src1, GR32:$src2, CL))]>, TB;
Sean Callanan2c48df22009-12-18 00:01:26 +00002554def SHRD32rrCL : I<0xAD, MRMDestReg, (outs GR32:$dst),
2555 (ins GR32:$src1, GR32:$src2),
Eli Friedman378ea832009-06-19 04:48:38 +00002556 "shrd{l}\t{%cl, $src2, $dst|$dst, $src2, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002557 [(set GR32:$dst, (X86shrd GR32:$src1, GR32:$src2, CL))]>, TB;
Sean Callanan2c48df22009-12-18 00:01:26 +00002558def SHLD16rrCL : I<0xA5, MRMDestReg, (outs GR16:$dst),
2559 (ins GR16:$src1, GR16:$src2),
Eli Friedman378ea832009-06-19 04:48:38 +00002560 "shld{w}\t{%cl, $src2, $dst|$dst, $src2, CL}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002561 [(set GR16:$dst, (X86shld GR16:$src1, GR16:$src2, CL))]>,
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002562 TB, OpSize;
Sean Callanan2c48df22009-12-18 00:01:26 +00002563def SHRD16rrCL : I<0xAD, MRMDestReg, (outs GR16:$dst),
2564 (ins GR16:$src1, GR16:$src2),
Eli Friedman378ea832009-06-19 04:48:38 +00002565 "shrd{w}\t{%cl, $src2, $dst|$dst, $src2, CL}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002566 [(set GR16:$dst, (X86shrd GR16:$src1, GR16:$src2, CL))]>,
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002567 TB, OpSize;
2568}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002569
2570let isCommutable = 1 in { // These instructions commute to each other.
2571def SHLD32rri8 : Ii8<0xA4, MRMDestReg,
Sean Callanan2c48df22009-12-18 00:01:26 +00002572 (outs GR32:$dst),
2573 (ins GR32:$src1, GR32:$src2, i8imm:$src3),
Dan Gohman91888f02007-07-31 20:11:57 +00002574 "shld{l}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002575 [(set GR32:$dst, (X86shld GR32:$src1, GR32:$src2,
2576 (i8 imm:$src3)))]>,
2577 TB;
2578def SHRD32rri8 : Ii8<0xAC, MRMDestReg,
Sean Callanan2c48df22009-12-18 00:01:26 +00002579 (outs GR32:$dst),
2580 (ins GR32:$src1, GR32:$src2, i8imm:$src3),
Dan Gohman91888f02007-07-31 20:11:57 +00002581 "shrd{l}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002582 [(set GR32:$dst, (X86shrd GR32:$src1, GR32:$src2,
2583 (i8 imm:$src3)))]>,
2584 TB;
2585def SHLD16rri8 : Ii8<0xA4, MRMDestReg,
Sean Callanan2c48df22009-12-18 00:01:26 +00002586 (outs GR16:$dst),
2587 (ins GR16:$src1, GR16:$src2, i8imm:$src3),
Dan Gohman91888f02007-07-31 20:11:57 +00002588 "shld{w}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002589 [(set GR16:$dst, (X86shld GR16:$src1, GR16:$src2,
2590 (i8 imm:$src3)))]>,
2591 TB, OpSize;
2592def SHRD16rri8 : Ii8<0xAC, MRMDestReg,
Sean Callanan2c48df22009-12-18 00:01:26 +00002593 (outs GR16:$dst),
2594 (ins GR16:$src1, GR16:$src2, i8imm:$src3),
Dan Gohman91888f02007-07-31 20:11:57 +00002595 "shrd{w}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002596 [(set GR16:$dst, (X86shrd GR16:$src1, GR16:$src2,
2597 (i8 imm:$src3)))]>,
2598 TB, OpSize;
2599}
2600
2601let isTwoAddress = 0 in {
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002602 let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00002603 def SHLD32mrCL : I<0xA5, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
Eli Friedman378ea832009-06-19 04:48:38 +00002604 "shld{l}\t{%cl, $src2, $dst|$dst, $src2, CL}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002605 [(store (X86shld (loadi32 addr:$dst), GR32:$src2, CL),
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002606 addr:$dst)]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00002607 def SHRD32mrCL : I<0xAD, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
Eli Friedman378ea832009-06-19 04:48:38 +00002608 "shrd{l}\t{%cl, $src2, $dst|$dst, $src2, CL}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002609 [(store (X86shrd (loadi32 addr:$dst), GR32:$src2, CL),
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002610 addr:$dst)]>, TB;
2611 }
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002612 def SHLD32mri8 : Ii8<0xA4, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00002613 (outs), (ins i32mem:$dst, GR32:$src2, i8imm:$src3),
Dan Gohman91888f02007-07-31 20:11:57 +00002614 "shld{l}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002615 [(store (X86shld (loadi32 addr:$dst), GR32:$src2,
2616 (i8 imm:$src3)), addr:$dst)]>,
2617 TB;
2618 def SHRD32mri8 : Ii8<0xAC, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00002619 (outs), (ins i32mem:$dst, GR32:$src2, i8imm:$src3),
Dan Gohman91888f02007-07-31 20:11:57 +00002620 "shrd{l}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002621 [(store (X86shrd (loadi32 addr:$dst), GR32:$src2,
2622 (i8 imm:$src3)), addr:$dst)]>,
2623 TB;
2624
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002625 let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00002626 def SHLD16mrCL : I<0xA5, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
Eli Friedman378ea832009-06-19 04:48:38 +00002627 "shld{w}\t{%cl, $src2, $dst|$dst, $src2, CL}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002628 [(store (X86shld (loadi16 addr:$dst), GR16:$src2, CL),
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002629 addr:$dst)]>, TB, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002630 def SHRD16mrCL : I<0xAD, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
Eli Friedman378ea832009-06-19 04:48:38 +00002631 "shrd{w}\t{%cl, $src2, $dst|$dst, $src2, CL}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002632 [(store (X86shrd (loadi16 addr:$dst), GR16:$src2, CL),
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002633 addr:$dst)]>, TB, OpSize;
2634 }
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002635 def SHLD16mri8 : Ii8<0xA4, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00002636 (outs), (ins i16mem:$dst, GR16:$src2, i8imm:$src3),
Dan Gohman91888f02007-07-31 20:11:57 +00002637 "shld{w}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002638 [(store (X86shld (loadi16 addr:$dst), GR16:$src2,
2639 (i8 imm:$src3)), addr:$dst)]>,
2640 TB, OpSize;
2641 def SHRD16mri8 : Ii8<0xAC, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00002642 (outs), (ins i16mem:$dst, GR16:$src2, i8imm:$src3),
Dan Gohman91888f02007-07-31 20:11:57 +00002643 "shrd{w}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002644 [(store (X86shrd (loadi16 addr:$dst), GR16:$src2,
2645 (i8 imm:$src3)), addr:$dst)]>,
2646 TB, OpSize;
2647}
Evan Cheng55687072007-09-14 21:48:26 +00002648} // Defs = [EFLAGS]
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002649
2650
2651// Arithmetic.
Evan Cheng55687072007-09-14 21:48:26 +00002652let Defs = [EFLAGS] in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002653let isCommutable = 1 in { // X = ADD Y, Z --> X = ADD Z, Y
Bill Wendlingae034ed2008-12-12 00:56:36 +00002654// Register-Register Addition
2655def ADD8rr : I<0x00, MRMDestReg, (outs GR8 :$dst),
2656 (ins GR8 :$src1, GR8 :$src2),
2657 "add{b}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002658 [(set GR8:$dst, (add GR8:$src1, GR8:$src2)),
Bill Wendlingae034ed2008-12-12 00:56:36 +00002659 (implicit EFLAGS)]>;
2660
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002661let isConvertibleToThreeAddress = 1 in { // Can transform into LEA.
Bill Wendlingae034ed2008-12-12 00:56:36 +00002662// Register-Register Addition
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002663def ADD16rr : I<0x01, MRMDestReg, (outs GR16:$dst),
2664 (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002665 "add{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002666 [(set GR16:$dst, (add GR16:$src1, GR16:$src2)),
2667 (implicit EFLAGS)]>, OpSize;
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002668def ADD32rr : I<0x01, MRMDestReg, (outs GR32:$dst),
2669 (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002670 "add{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002671 [(set GR32:$dst, (add GR32:$src1, GR32:$src2)),
2672 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002673} // end isConvertibleToThreeAddress
2674} // end isCommutable
Bill Wendlingae034ed2008-12-12 00:56:36 +00002675
2676// Register-Memory Addition
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002677def ADD8rm : I<0x02, MRMSrcMem, (outs GR8 :$dst),
2678 (ins GR8 :$src1, i8mem :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002679 "add{b}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002680 [(set GR8:$dst, (add GR8:$src1, (load addr:$src2))),
2681 (implicit EFLAGS)]>;
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002682def ADD16rm : I<0x03, MRMSrcMem, (outs GR16:$dst),
2683 (ins GR16:$src1, i16mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002684 "add{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002685 [(set GR16:$dst, (add GR16:$src1, (load addr:$src2))),
2686 (implicit EFLAGS)]>, OpSize;
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002687def ADD32rm : I<0x03, MRMSrcMem, (outs GR32:$dst),
2688 (ins GR32:$src1, i32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002689 "add{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002690 [(set GR32:$dst, (add GR32:$src1, (load addr:$src2))),
2691 (implicit EFLAGS)]>;
Sean Callanan7e7df0e2009-09-15 20:53:57 +00002692
Sean Callanan84df9312009-09-15 21:43:27 +00002693// Register-Register Addition - Equivalent to the normal rr forms (ADD8rr,
2694// ADD16rr, and ADD32rr), but differently encoded.
Sean Callanan7e7df0e2009-09-15 20:53:57 +00002695def ADD8mrmrr: I<0x02, MRMSrcReg, (outs GR8:$dst), (ins GR8:$src1, GR8:$src2),
2696 "add{b}\t{$src2, $dst|$dst, $src2}", []>;
2697def ADD16mrmrr: I<0x03, MRMSrcReg,(outs GR16:$dst),(ins GR16:$src1, GR16:$src2),
2698 "add{w}\t{$src2, $dst|$dst, $src2}", []>, OpSize;
2699def ADD32mrmrr: I<0x03, MRMSrcReg,(outs GR16:$dst),(ins GR16:$src1, GR16:$src2),
2700 "add{l}\t{$src2, $dst|$dst, $src2}", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002701
Bill Wendlingae034ed2008-12-12 00:56:36 +00002702// Register-Integer Addition
2703def ADD8ri : Ii8<0x80, MRM0r, (outs GR8:$dst), (ins GR8:$src1, i8imm:$src2),
2704 "add{b}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002705 [(set GR8:$dst, (add GR8:$src1, imm:$src2)),
2706 (implicit EFLAGS)]>;
Bill Wendlingae034ed2008-12-12 00:56:36 +00002707
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002708let isConvertibleToThreeAddress = 1 in { // Can transform into LEA.
Bill Wendlingae034ed2008-12-12 00:56:36 +00002709// Register-Integer Addition
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002710def ADD16ri : Ii16<0x81, MRM0r, (outs GR16:$dst),
2711 (ins GR16:$src1, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002712 "add{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002713 [(set GR16:$dst, (add GR16:$src1, imm:$src2)),
2714 (implicit EFLAGS)]>, OpSize;
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002715def ADD32ri : Ii32<0x81, MRM0r, (outs GR32:$dst),
2716 (ins GR32:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002717 "add{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002718 [(set GR32:$dst, (add GR32:$src1, imm:$src2)),
2719 (implicit EFLAGS)]>;
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002720def ADD16ri8 : Ii8<0x83, MRM0r, (outs GR16:$dst),
2721 (ins GR16:$src1, i16i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002722 "add{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002723 [(set GR16:$dst, (add GR16:$src1, i16immSExt8:$src2)),
2724 (implicit EFLAGS)]>, OpSize;
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002725def ADD32ri8 : Ii8<0x83, MRM0r, (outs GR32:$dst),
2726 (ins GR32:$src1, i32i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002727 "add{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002728 [(set GR32:$dst, (add GR32:$src1, i32immSExt8:$src2)),
2729 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002730}
2731
2732let isTwoAddress = 0 in {
Bill Wendlingae034ed2008-12-12 00:56:36 +00002733 // Memory-Register Addition
Bill Wendlingf5399032008-12-12 21:15:41 +00002734 def ADD8mr : I<0x00, MRMDestMem, (outs), (ins i8mem:$dst, GR8:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002735 "add{b}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002736 [(store (add (load addr:$dst), GR8:$src2), addr:$dst),
2737 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002738 def ADD16mr : I<0x01, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002739 "add{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002740 [(store (add (load addr:$dst), GR16:$src2), addr:$dst),
2741 (implicit EFLAGS)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002742 def ADD32mr : I<0x01, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002743 "add{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002744 [(store (add (load addr:$dst), GR32:$src2), addr:$dst),
2745 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002746 def ADD8mi : Ii8<0x80, MRM0m, (outs), (ins i8mem :$dst, i8imm :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002747 "add{b}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002748 [(store (add (loadi8 addr:$dst), imm:$src2), addr:$dst),
2749 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002750 def ADD16mi : Ii16<0x81, MRM0m, (outs), (ins i16mem:$dst, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002751 "add{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002752 [(store (add (loadi16 addr:$dst), imm:$src2), addr:$dst),
2753 (implicit EFLAGS)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002754 def ADD32mi : Ii32<0x81, MRM0m, (outs), (ins i32mem:$dst, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002755 "add{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002756 [(store (add (loadi32 addr:$dst), imm:$src2), addr:$dst),
2757 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002758 def ADD16mi8 : Ii8<0x83, MRM0m, (outs), (ins i16mem:$dst, i16i8imm :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002759 "add{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002760 [(store (add (load addr:$dst), i16immSExt8:$src2),
2761 addr:$dst),
2762 (implicit EFLAGS)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002763 def ADD32mi8 : Ii8<0x83, MRM0m, (outs), (ins i32mem:$dst, i32i8imm :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002764 "add{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingae034ed2008-12-12 00:56:36 +00002765 [(store (add (load addr:$dst), i32immSExt8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00002766 addr:$dst),
2767 (implicit EFLAGS)]>;
Sean Callanan0316b342009-08-11 21:26:06 +00002768
2769 // addition to rAX
2770 def ADD8i8 : Ii8<0x04, RawFrm, (outs), (ins i8imm:$src),
Sean Callanan251676e2009-09-02 00:55:49 +00002771 "add{b}\t{$src, %al|%al, $src}", []>;
Sean Callanan0316b342009-08-11 21:26:06 +00002772 def ADD16i16 : Ii16<0x05, RawFrm, (outs), (ins i16imm:$src),
Sean Callanan251676e2009-09-02 00:55:49 +00002773 "add{w}\t{$src, %ax|%ax, $src}", []>, OpSize;
Sean Callanan0316b342009-08-11 21:26:06 +00002774 def ADD32i32 : Ii32<0x05, RawFrm, (outs), (ins i32imm:$src),
Sean Callanan251676e2009-09-02 00:55:49 +00002775 "add{l}\t{$src, %eax|%eax, $src}", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002776}
2777
Evan Cheng259471d2007-10-05 17:59:57 +00002778let Uses = [EFLAGS] in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002779let isCommutable = 1 in { // X = ADC Y, Z --> X = ADC Z, Y
Dale Johannesen747fe522009-06-02 03:12:52 +00002780def ADC8rr : I<0x10, MRMDestReg, (outs GR8:$dst), (ins GR8:$src1, GR8:$src2),
Dale Johannesen06b83f12009-05-18 17:44:15 +00002781 "adc{b}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002782 [(set GR8:$dst, (adde GR8:$src1, GR8:$src2))]>;
Dale Johannesen06b83f12009-05-18 17:44:15 +00002783def ADC16rr : I<0x11, MRMDestReg, (outs GR16:$dst),
2784 (ins GR16:$src1, GR16:$src2),
2785 "adc{w}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002786 [(set GR16:$dst, (adde GR16:$src1, GR16:$src2))]>, OpSize;
Dale Johannesen06b83f12009-05-18 17:44:15 +00002787def ADC32rr : I<0x11, MRMDestReg, (outs GR32:$dst),
2788 (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002789 "adc{l}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002790 [(set GR32:$dst, (adde GR32:$src1, GR32:$src2))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002791}
Sean Callanan2c48df22009-12-18 00:01:26 +00002792
2793def ADC8rr_REV : I<0x12, MRMSrcReg, (outs GR8:$dst), (ins GR8:$src1, GR8:$src2),
2794 "adc{b}\t{$src2, $dst|$dst, $src2}", []>;
2795def ADC16rr_REV : I<0x13, MRMSrcReg, (outs GR16:$dst),
2796 (ins GR16:$src1, GR16:$src2),
2797 "adc{w}\t{$src2, $dst|$dst, $src2}", []>, OpSize;
2798def ADC32rr_REV : I<0x13, MRMSrcReg, (outs GR32:$dst),
2799 (ins GR32:$src1, GR32:$src2),
2800 "adc{l}\t{$src2, $dst|$dst, $src2}", []>;
2801
Dale Johannesen06b83f12009-05-18 17:44:15 +00002802def ADC8rm : I<0x12, MRMSrcMem , (outs GR8:$dst),
2803 (ins GR8:$src1, i8mem:$src2),
2804 "adc{b}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002805 [(set GR8:$dst, (adde GR8:$src1, (load addr:$src2)))]>;
Dale Johannesen06b83f12009-05-18 17:44:15 +00002806def ADC16rm : I<0x13, MRMSrcMem , (outs GR16:$dst),
2807 (ins GR16:$src1, i16mem:$src2),
2808 "adc{w}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002809 [(set GR16:$dst, (adde GR16:$src1, (load addr:$src2)))]>,
Dale Johannesen067cfb22009-05-18 21:41:59 +00002810 OpSize;
Dale Johannesen06b83f12009-05-18 17:44:15 +00002811def ADC32rm : I<0x13, MRMSrcMem , (outs GR32:$dst),
2812 (ins GR32:$src1, i32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002813 "adc{l}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002814 [(set GR32:$dst, (adde GR32:$src1, (load addr:$src2)))]>;
2815def ADC8ri : Ii8<0x80, MRM2r, (outs GR8:$dst), (ins GR8:$src1, i8imm:$src2),
Dale Johannesen06b83f12009-05-18 17:44:15 +00002816 "adc{b}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002817 [(set GR8:$dst, (adde GR8:$src1, imm:$src2))]>;
Dale Johannesen06b83f12009-05-18 17:44:15 +00002818def ADC16ri : Ii16<0x81, MRM2r, (outs GR16:$dst),
2819 (ins GR16:$src1, i16imm:$src2),
2820 "adc{w}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002821 [(set GR16:$dst, (adde GR16:$src1, imm:$src2))]>, OpSize;
Dale Johannesen06b83f12009-05-18 17:44:15 +00002822def ADC16ri8 : Ii8<0x83, MRM2r, (outs GR16:$dst),
2823 (ins GR16:$src1, i16i8imm:$src2),
2824 "adc{w}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002825 [(set GR16:$dst, (adde GR16:$src1, i16immSExt8:$src2))]>,
2826 OpSize;
Dale Johannesen06b83f12009-05-18 17:44:15 +00002827def ADC32ri : Ii32<0x81, MRM2r, (outs GR32:$dst),
2828 (ins GR32:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002829 "adc{l}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002830 [(set GR32:$dst, (adde GR32:$src1, imm:$src2))]>;
Dale Johannesen06b83f12009-05-18 17:44:15 +00002831def ADC32ri8 : Ii8<0x83, MRM2r, (outs GR32:$dst),
2832 (ins GR32:$src1, i32i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002833 "adc{l}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002834 [(set GR32:$dst, (adde GR32:$src1, i32immSExt8:$src2))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002835
2836let isTwoAddress = 0 in {
Dale Johannesen747fe522009-06-02 03:12:52 +00002837 def ADC8mr : I<0x10, MRMDestMem, (outs), (ins i8mem:$dst, GR8:$src2),
Dale Johannesen06b83f12009-05-18 17:44:15 +00002838 "adc{b}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002839 [(store (adde (load addr:$dst), GR8:$src2), addr:$dst)]>;
2840 def ADC16mr : I<0x11, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
Dale Johannesen06b83f12009-05-18 17:44:15 +00002841 "adc{w}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002842 [(store (adde (load addr:$dst), GR16:$src2), addr:$dst)]>,
2843 OpSize;
2844 def ADC32mr : I<0x11, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002845 "adc{l}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002846 [(store (adde (load addr:$dst), GR32:$src2), addr:$dst)]>;
2847 def ADC8mi : Ii8<0x80, MRM2m, (outs), (ins i8mem:$dst, i8imm:$src2),
Dale Johannesen06b83f12009-05-18 17:44:15 +00002848 "adc{b}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002849 [(store (adde (loadi8 addr:$dst), imm:$src2), addr:$dst)]>;
2850 def ADC16mi : Ii16<0x81, MRM2m, (outs), (ins i16mem:$dst, i16imm:$src2),
Dale Johannesen06b83f12009-05-18 17:44:15 +00002851 "adc{w}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002852 [(store (adde (loadi16 addr:$dst), imm:$src2), addr:$dst)]>,
2853 OpSize;
2854 def ADC16mi8 : Ii8<0x83, MRM2m, (outs), (ins i16mem:$dst, i16i8imm :$src2),
Dale Johannesen06b83f12009-05-18 17:44:15 +00002855 "adc{w}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002856 [(store (adde (load addr:$dst), i16immSExt8:$src2), addr:$dst)]>,
2857 OpSize;
2858 def ADC32mi : Ii32<0x81, MRM2m, (outs), (ins i32mem:$dst, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002859 "adc{l}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002860 [(store (adde (loadi32 addr:$dst), imm:$src2), addr:$dst)]>;
2861 def ADC32mi8 : Ii8<0x83, MRM2m, (outs), (ins i32mem:$dst, i32i8imm :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002862 "adc{l}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002863 [(store (adde (load addr:$dst), i32immSExt8:$src2), addr:$dst)]>;
Sean Callanan8562bef2009-09-11 19:01:56 +00002864
2865 def ADC8i8 : Ii8<0x14, RawFrm, (outs), (ins i8imm:$src),
2866 "adc{b}\t{$src, %al|%al, $src}", []>;
2867 def ADC16i16 : Ii16<0x15, RawFrm, (outs), (ins i16imm:$src),
2868 "adc{w}\t{$src, %ax|%ax, $src}", []>, OpSize;
2869 def ADC32i32 : Ii32<0x15, RawFrm, (outs), (ins i32imm:$src),
2870 "adc{l}\t{$src, %eax|%eax, $src}", []>;
Dale Johannesen747fe522009-06-02 03:12:52 +00002871}
Evan Cheng259471d2007-10-05 17:59:57 +00002872} // Uses = [EFLAGS]
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002873
Bill Wendlingae034ed2008-12-12 00:56:36 +00002874// Register-Register Subtraction
2875def SUB8rr : I<0x28, MRMDestReg, (outs GR8:$dst), (ins GR8:$src1, GR8:$src2),
2876 "sub{b}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002877 [(set GR8:$dst, (sub GR8:$src1, GR8:$src2)),
2878 (implicit EFLAGS)]>;
Bill Wendlingae034ed2008-12-12 00:56:36 +00002879def SUB16rr : I<0x29, MRMDestReg, (outs GR16:$dst), (ins GR16:$src1,GR16:$src2),
2880 "sub{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002881 [(set GR16:$dst, (sub GR16:$src1, GR16:$src2)),
2882 (implicit EFLAGS)]>, OpSize;
Bill Wendlingae034ed2008-12-12 00:56:36 +00002883def SUB32rr : I<0x29, MRMDestReg, (outs GR32:$dst), (ins GR32:$src1,GR32:$src2),
2884 "sub{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002885 [(set GR32:$dst, (sub GR32:$src1, GR32:$src2)),
2886 (implicit EFLAGS)]>;
Bill Wendlingae034ed2008-12-12 00:56:36 +00002887
Sean Callanan2c48df22009-12-18 00:01:26 +00002888def SUB8rr_REV : I<0x2A, MRMSrcReg, (outs GR8:$dst), (ins GR8:$src1, GR8:$src2),
2889 "sub{b}\t{$src2, $dst|$dst, $src2}", []>;
2890def SUB16rr_REV : I<0x2B, MRMSrcReg, (outs GR16:$dst),
2891 (ins GR16:$src1, GR16:$src2),
2892 "sub{w}\t{$src2, $dst|$dst, $src2}", []>, OpSize;
2893def SUB32rr_REV : I<0x2B, MRMSrcReg, (outs GR32:$dst),
2894 (ins GR32:$src1, GR32:$src2),
2895 "sub{l}\t{$src2, $dst|$dst, $src2}", []>;
2896
Bill Wendlingae034ed2008-12-12 00:56:36 +00002897// Register-Memory Subtraction
2898def SUB8rm : I<0x2A, MRMSrcMem, (outs GR8 :$dst),
2899 (ins GR8 :$src1, i8mem :$src2),
2900 "sub{b}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002901 [(set GR8:$dst, (sub GR8:$src1, (load addr:$src2))),
2902 (implicit EFLAGS)]>;
Bill Wendlingae034ed2008-12-12 00:56:36 +00002903def SUB16rm : I<0x2B, MRMSrcMem, (outs GR16:$dst),
2904 (ins GR16:$src1, i16mem:$src2),
2905 "sub{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002906 [(set GR16:$dst, (sub GR16:$src1, (load addr:$src2))),
2907 (implicit EFLAGS)]>, OpSize;
Bill Wendlingae034ed2008-12-12 00:56:36 +00002908def SUB32rm : I<0x2B, MRMSrcMem, (outs GR32:$dst),
2909 (ins GR32:$src1, i32mem:$src2),
2910 "sub{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002911 [(set GR32:$dst, (sub GR32:$src1, (load addr:$src2))),
2912 (implicit EFLAGS)]>;
Bill Wendlingae034ed2008-12-12 00:56:36 +00002913
2914// Register-Integer Subtraction
2915def SUB8ri : Ii8 <0x80, MRM5r, (outs GR8:$dst),
2916 (ins GR8:$src1, i8imm:$src2),
2917 "sub{b}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002918 [(set GR8:$dst, (sub GR8:$src1, imm:$src2)),
2919 (implicit EFLAGS)]>;
Bill Wendlingae034ed2008-12-12 00:56:36 +00002920def SUB16ri : Ii16<0x81, MRM5r, (outs GR16:$dst),
2921 (ins GR16:$src1, i16imm:$src2),
2922 "sub{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002923 [(set GR16:$dst, (sub GR16:$src1, imm:$src2)),
2924 (implicit EFLAGS)]>, OpSize;
Bill Wendlingae034ed2008-12-12 00:56:36 +00002925def SUB32ri : Ii32<0x81, MRM5r, (outs GR32:$dst),
2926 (ins GR32:$src1, i32imm:$src2),
2927 "sub{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002928 [(set GR32:$dst, (sub GR32:$src1, imm:$src2)),
2929 (implicit EFLAGS)]>;
Bill Wendlingae034ed2008-12-12 00:56:36 +00002930def SUB16ri8 : Ii8<0x83, MRM5r, (outs GR16:$dst),
2931 (ins GR16:$src1, i16i8imm:$src2),
2932 "sub{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002933 [(set GR16:$dst, (sub GR16:$src1, i16immSExt8:$src2)),
2934 (implicit EFLAGS)]>, OpSize;
Bill Wendlingae034ed2008-12-12 00:56:36 +00002935def SUB32ri8 : Ii8<0x83, MRM5r, (outs GR32:$dst),
2936 (ins GR32:$src1, i32i8imm:$src2),
2937 "sub{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002938 [(set GR32:$dst, (sub GR32:$src1, i32immSExt8:$src2)),
2939 (implicit EFLAGS)]>;
Bill Wendlingae034ed2008-12-12 00:56:36 +00002940
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002941let isTwoAddress = 0 in {
Bill Wendlingae034ed2008-12-12 00:56:36 +00002942 // Memory-Register Subtraction
Evan Chengb783fa32007-07-19 01:14:50 +00002943 def SUB8mr : I<0x28, MRMDestMem, (outs), (ins i8mem :$dst, GR8 :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002944 "sub{b}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002945 [(store (sub (load addr:$dst), GR8:$src2), addr:$dst),
2946 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002947 def SUB16mr : I<0x29, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002948 "sub{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002949 [(store (sub (load addr:$dst), GR16:$src2), addr:$dst),
2950 (implicit EFLAGS)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002951 def SUB32mr : I<0x29, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002952 "sub{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002953 [(store (sub (load addr:$dst), GR32:$src2), addr:$dst),
2954 (implicit EFLAGS)]>;
Bill Wendlingae034ed2008-12-12 00:56:36 +00002955
2956 // Memory-Integer Subtraction
Evan Chengb783fa32007-07-19 01:14:50 +00002957 def SUB8mi : Ii8<0x80, MRM5m, (outs), (ins i8mem :$dst, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002958 "sub{b}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002959 [(store (sub (loadi8 addr:$dst), imm:$src2), addr:$dst),
2960 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002961 def SUB16mi : Ii16<0x81, MRM5m, (outs), (ins i16mem:$dst, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002962 "sub{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002963 [(store (sub (loadi16 addr:$dst), imm:$src2),addr:$dst),
2964 (implicit EFLAGS)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002965 def SUB32mi : Ii32<0x81, MRM5m, (outs), (ins i32mem:$dst, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002966 "sub{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002967 [(store (sub (loadi32 addr:$dst), imm:$src2),addr:$dst),
2968 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002969 def SUB16mi8 : Ii8<0x83, MRM5m, (outs), (ins i16mem:$dst, i16i8imm :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002970 "sub{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingae034ed2008-12-12 00:56:36 +00002971 [(store (sub (load addr:$dst), i16immSExt8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00002972 addr:$dst),
2973 (implicit EFLAGS)]>, OpSize;
Bill Wendlingae034ed2008-12-12 00:56:36 +00002974 def SUB32mi8 : Ii8<0x83, MRM5m, (outs), (ins i32mem:$dst, i32i8imm :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002975 "sub{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingae034ed2008-12-12 00:56:36 +00002976 [(store (sub (load addr:$dst), i32immSExt8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00002977 addr:$dst),
2978 (implicit EFLAGS)]>;
Sean Callanan8562bef2009-09-11 19:01:56 +00002979
2980 def SUB8i8 : Ii8<0x2C, RawFrm, (outs), (ins i8imm:$src),
2981 "sub{b}\t{$src, %al|%al, $src}", []>;
2982 def SUB16i16 : Ii16<0x2D, RawFrm, (outs), (ins i16imm:$src),
2983 "sub{w}\t{$src, %ax|%ax, $src}", []>, OpSize;
2984 def SUB32i32 : Ii32<0x2D, RawFrm, (outs), (ins i32imm:$src),
2985 "sub{l}\t{$src, %eax|%eax, $src}", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002986}
2987
Evan Cheng259471d2007-10-05 17:59:57 +00002988let Uses = [EFLAGS] in {
Dale Johannesen06b83f12009-05-18 17:44:15 +00002989def SBB8rr : I<0x18, MRMDestReg, (outs GR8:$dst),
2990 (ins GR8:$src1, GR8:$src2),
2991 "sbb{b}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002992 [(set GR8:$dst, (sube GR8:$src1, GR8:$src2))]>;
Dale Johannesen06b83f12009-05-18 17:44:15 +00002993def SBB16rr : I<0x19, MRMDestReg, (outs GR16:$dst),
2994 (ins GR16:$src1, GR16:$src2),
2995 "sbb{w}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002996 [(set GR16:$dst, (sube GR16:$src1, GR16:$src2))]>, OpSize;
Dale Johannesen06b83f12009-05-18 17:44:15 +00002997def SBB32rr : I<0x19, MRMDestReg, (outs GR32:$dst),
2998 (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002999 "sbb{l}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00003000 [(set GR32:$dst, (sube GR32:$src1, GR32:$src2))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003001
3002let isTwoAddress = 0 in {
Dale Johannesen06b83f12009-05-18 17:44:15 +00003003 def SBB8mr : I<0x18, MRMDestMem, (outs), (ins i8mem:$dst, GR8:$src2),
3004 "sbb{b}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00003005 [(store (sube (load addr:$dst), GR8:$src2), addr:$dst)]>;
Dale Johannesen06b83f12009-05-18 17:44:15 +00003006 def SBB16mr : I<0x19, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
3007 "sbb{w}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00003008 [(store (sube (load addr:$dst), GR16:$src2), addr:$dst)]>,
Dale Johannesen067cfb22009-05-18 21:41:59 +00003009 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00003010 def SBB32mr : I<0x19, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00003011 "sbb{l}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00003012 [(store (sube (load addr:$dst), GR32:$src2), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00003013 def SBB8mi : Ii32<0x80, MRM3m, (outs), (ins i8mem:$dst, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00003014 "sbb{b}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00003015 [(store (sube (loadi8 addr:$dst), imm:$src2), addr:$dst)]>;
Dale Johannesen06b83f12009-05-18 17:44:15 +00003016 def SBB16mi : Ii16<0x81, MRM3m, (outs), (ins i16mem:$dst, i16imm:$src2),
3017 "sbb{w}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00003018 [(store (sube (loadi16 addr:$dst), imm:$src2), addr:$dst)]>,
Dale Johannesen067cfb22009-05-18 21:41:59 +00003019 OpSize;
Dale Johannesen06b83f12009-05-18 17:44:15 +00003020 def SBB16mi8 : Ii8<0x83, MRM3m, (outs), (ins i16mem:$dst, i16i8imm :$src2),
3021 "sbb{w}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00003022 [(store (sube (load addr:$dst), i16immSExt8:$src2), addr:$dst)]>,
Dale Johannesen067cfb22009-05-18 21:41:59 +00003023 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00003024 def SBB32mi : Ii32<0x81, MRM3m, (outs), (ins i32mem:$dst, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00003025 "sbb{l}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00003026 [(store (sube (loadi32 addr:$dst), imm:$src2), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00003027 def SBB32mi8 : Ii8<0x83, MRM3m, (outs), (ins i32mem:$dst, i32i8imm :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00003028 "sbb{l}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00003029 [(store (sube (load addr:$dst), i32immSExt8:$src2), addr:$dst)]>;
Sean Callanan8562bef2009-09-11 19:01:56 +00003030
3031 def SBB8i8 : Ii8<0x1C, RawFrm, (outs), (ins i8imm:$src),
3032 "sbb{b}\t{$src, %al|%al, $src}", []>;
3033 def SBB16i16 : Ii16<0x1D, RawFrm, (outs), (ins i16imm:$src),
3034 "sbb{w}\t{$src, %ax|%ax, $src}", []>, OpSize;
3035 def SBB32i32 : Ii32<0x1D, RawFrm, (outs), (ins i32imm:$src),
3036 "sbb{l}\t{$src, %eax|%eax, $src}", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003037}
Sean Callanan2c48df22009-12-18 00:01:26 +00003038
3039def SBB8rr_REV : I<0x1A, MRMSrcReg, (outs GR8:$dst), (ins GR8:$src1, GR8:$src2),
3040 "sbb{b}\t{$src2, $dst|$dst, $src2}", []>;
3041def SBB16rr_REV : I<0x1B, MRMSrcReg, (outs GR16:$dst),
3042 (ins GR16:$src1, GR16:$src2),
3043 "sbb{w}\t{$src2, $dst|$dst, $src2}", []>, OpSize;
3044def SBB32rr_REV : I<0x1B, MRMSrcReg, (outs GR32:$dst),
3045 (ins GR32:$src1, GR32:$src2),
3046 "sbb{l}\t{$src2, $dst|$dst, $src2}", []>;
3047
Dale Johannesen06b83f12009-05-18 17:44:15 +00003048def SBB8rm : I<0x1A, MRMSrcMem, (outs GR8:$dst), (ins GR8:$src1, i8mem:$src2),
3049 "sbb{b}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00003050 [(set GR8:$dst, (sube GR8:$src1, (load addr:$src2)))]>;
Dale Johannesen06b83f12009-05-18 17:44:15 +00003051def SBB16rm : I<0x1B, MRMSrcMem, (outs GR16:$dst),
3052 (ins GR16:$src1, i16mem:$src2),
3053 "sbb{w}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00003054 [(set GR16:$dst, (sube GR16:$src1, (load addr:$src2)))]>,
Dale Johannesen067cfb22009-05-18 21:41:59 +00003055 OpSize;
Dale Johannesen06b83f12009-05-18 17:44:15 +00003056def SBB32rm : I<0x1B, MRMSrcMem, (outs GR32:$dst),
3057 (ins GR32:$src1, i32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00003058 "sbb{l}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00003059 [(set GR32:$dst, (sube GR32:$src1, (load addr:$src2)))]>;
Dale Johannesen06b83f12009-05-18 17:44:15 +00003060def SBB8ri : Ii8<0x80, MRM3r, (outs GR8:$dst), (ins GR8:$src1, i8imm:$src2),
3061 "sbb{b}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00003062 [(set GR8:$dst, (sube GR8:$src1, imm:$src2))]>;
Dale Johannesen06b83f12009-05-18 17:44:15 +00003063def SBB16ri : Ii16<0x81, MRM3r, (outs GR16:$dst),
3064 (ins GR16:$src1, i16imm:$src2),
3065 "sbb{w}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00003066 [(set GR16:$dst, (sube GR16:$src1, imm:$src2))]>, OpSize;
Dale Johannesen06b83f12009-05-18 17:44:15 +00003067def SBB16ri8 : Ii8<0x83, MRM3r, (outs GR16:$dst),
3068 (ins GR16:$src1, i16i8imm:$src2),
3069 "sbb{w}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00003070 [(set GR16:$dst, (sube GR16:$src1, i16immSExt8:$src2))]>,
3071 OpSize;
Dale Johannesen06b83f12009-05-18 17:44:15 +00003072def SBB32ri : Ii32<0x81, MRM3r, (outs GR32:$dst),
3073 (ins GR32:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00003074 "sbb{l}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00003075 [(set GR32:$dst, (sube GR32:$src1, imm:$src2))]>;
Dale Johannesen06b83f12009-05-18 17:44:15 +00003076def SBB32ri8 : Ii8<0x83, MRM3r, (outs GR32:$dst),
3077 (ins GR32:$src1, i32i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00003078 "sbb{l}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00003079 [(set GR32:$dst, (sube GR32:$src1, i32immSExt8:$src2))]>;
Evan Cheng259471d2007-10-05 17:59:57 +00003080} // Uses = [EFLAGS]
Evan Cheng55687072007-09-14 21:48:26 +00003081} // Defs = [EFLAGS]
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003082
Evan Cheng55687072007-09-14 21:48:26 +00003083let Defs = [EFLAGS] in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003084let isCommutable = 1 in { // X = IMUL Y, Z --> X = IMUL Z, Y
Bill Wendlingf5399032008-12-12 21:15:41 +00003085// Register-Register Signed Integer Multiply
Bill Wendlingae034ed2008-12-12 00:56:36 +00003086def IMUL16rr : I<0xAF, MRMSrcReg, (outs GR16:$dst), (ins GR16:$src1,GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00003087 "imul{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00003088 [(set GR16:$dst, (mul GR16:$src1, GR16:$src2)),
3089 (implicit EFLAGS)]>, TB, OpSize;
Bill Wendlingae034ed2008-12-12 00:56:36 +00003090def IMUL32rr : I<0xAF, MRMSrcReg, (outs GR32:$dst), (ins GR32:$src1,GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00003091 "imul{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00003092 [(set GR32:$dst, (mul GR32:$src1, GR32:$src2)),
3093 (implicit EFLAGS)]>, TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003094}
Bill Wendlingae034ed2008-12-12 00:56:36 +00003095
Bill Wendlingf5399032008-12-12 21:15:41 +00003096// Register-Memory Signed Integer Multiply
Bill Wendlingae034ed2008-12-12 00:56:36 +00003097def IMUL16rm : I<0xAF, MRMSrcMem, (outs GR16:$dst),
3098 (ins GR16:$src1, i16mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00003099 "imul{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00003100 [(set GR16:$dst, (mul GR16:$src1, (load addr:$src2))),
3101 (implicit EFLAGS)]>, TB, OpSize;
Sean Callanan2c48df22009-12-18 00:01:26 +00003102def IMUL32rm : I<0xAF, MRMSrcMem, (outs GR32:$dst),
3103 (ins GR32:$src1, i32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00003104 "imul{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00003105 [(set GR32:$dst, (mul GR32:$src1, (load addr:$src2))),
3106 (implicit EFLAGS)]>, TB;
Evan Cheng55687072007-09-14 21:48:26 +00003107} // Defs = [EFLAGS]
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003108} // end Two Address instructions
3109
3110// Suprisingly enough, these are not two address instructions!
Evan Cheng55687072007-09-14 21:48:26 +00003111let Defs = [EFLAGS] in {
Bill Wendlingf5399032008-12-12 21:15:41 +00003112// Register-Integer Signed Integer Multiply
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003113def IMUL16rri : Ii16<0x69, MRMSrcReg, // GR16 = GR16*I16
Evan Chengb783fa32007-07-19 01:14:50 +00003114 (outs GR16:$dst), (ins GR16:$src1, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00003115 "imul{w}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00003116 [(set GR16:$dst, (mul GR16:$src1, imm:$src2)),
3117 (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003118def IMUL32rri : Ii32<0x69, MRMSrcReg, // GR32 = GR32*I32
Evan Chengb783fa32007-07-19 01:14:50 +00003119 (outs GR32:$dst), (ins GR32:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00003120 "imul{l}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00003121 [(set GR32:$dst, (mul GR32:$src1, imm:$src2)),
3122 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003123def IMUL16rri8 : Ii8<0x6B, MRMSrcReg, // GR16 = GR16*I8
Evan Chengb783fa32007-07-19 01:14:50 +00003124 (outs GR16:$dst), (ins GR16:$src1, i16i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00003125 "imul{w}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00003126 [(set GR16:$dst, (mul GR16:$src1, i16immSExt8:$src2)),
3127 (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003128def IMUL32rri8 : Ii8<0x6B, MRMSrcReg, // GR32 = GR32*I8
Evan Chengb783fa32007-07-19 01:14:50 +00003129 (outs GR32:$dst), (ins GR32:$src1, i32i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00003130 "imul{l}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00003131 [(set GR32:$dst, (mul GR32:$src1, i32immSExt8:$src2)),
3132 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003133
Bill Wendlingf5399032008-12-12 21:15:41 +00003134// Memory-Integer Signed Integer Multiply
Sean Callanan2c48df22009-12-18 00:01:26 +00003135def IMUL16rmi : Ii16<0x69, MRMSrcMem, // GR16 = [mem16]*I16
Evan Chengb783fa32007-07-19 01:14:50 +00003136 (outs GR16:$dst), (ins i16mem:$src1, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00003137 "imul{w}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00003138 [(set GR16:$dst, (mul (load addr:$src1), imm:$src2)),
3139 (implicit EFLAGS)]>, OpSize;
Sean Callanan2c48df22009-12-18 00:01:26 +00003140def IMUL32rmi : Ii32<0x69, MRMSrcMem, // GR32 = [mem32]*I32
Evan Chengb783fa32007-07-19 01:14:50 +00003141 (outs GR32:$dst), (ins i32mem:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00003142 "imul{l}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00003143 [(set GR32:$dst, (mul (load addr:$src1), imm:$src2)),
3144 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003145def IMUL16rmi8 : Ii8<0x6B, MRMSrcMem, // GR16 = [mem16]*I8
Evan Chengb783fa32007-07-19 01:14:50 +00003146 (outs GR16:$dst), (ins i16mem:$src1, i16i8imm :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00003147 "imul{w}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Bill Wendlingae034ed2008-12-12 00:56:36 +00003148 [(set GR16:$dst, (mul (load addr:$src1),
Bill Wendlingf5399032008-12-12 21:15:41 +00003149 i16immSExt8:$src2)),
3150 (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003151def IMUL32rmi8 : Ii8<0x6B, MRMSrcMem, // GR32 = [mem32]*I8
Evan Chengb783fa32007-07-19 01:14:50 +00003152 (outs GR32:$dst), (ins i32mem:$src1, i32i8imm: $src2),
Dan Gohman91888f02007-07-31 20:11:57 +00003153 "imul{l}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Bill Wendlingae034ed2008-12-12 00:56:36 +00003154 [(set GR32:$dst, (mul (load addr:$src1),
Bill Wendlingf5399032008-12-12 21:15:41 +00003155 i32immSExt8:$src2)),
3156 (implicit EFLAGS)]>;
Evan Cheng55687072007-09-14 21:48:26 +00003157} // Defs = [EFLAGS]
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003158
3159//===----------------------------------------------------------------------===//
3160// Test instructions are just like AND, except they don't generate a result.
3161//
Evan Cheng950aac02007-09-25 01:57:46 +00003162let Defs = [EFLAGS] in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003163let isCommutable = 1 in { // TEST X, Y --> TEST Y, X
Evan Chengb783fa32007-07-19 01:14:50 +00003164def TEST8rr : I<0x84, MRMDestReg, (outs), (ins GR8:$src1, GR8:$src2),
Evan Cheng621216e2007-09-29 00:00:36 +00003165 "test{b}\t{$src2, $src1|$src1, $src2}",
Chris Lattner21da6382008-02-19 17:37:35 +00003166 [(X86cmp (and_su GR8:$src1, GR8:$src2), 0),
Evan Cheng621216e2007-09-29 00:00:36 +00003167 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00003168def TEST16rr : I<0x85, MRMDestReg, (outs), (ins GR16:$src1, GR16:$src2),
Evan Cheng621216e2007-09-29 00:00:36 +00003169 "test{w}\t{$src2, $src1|$src1, $src2}",
Chris Lattner21da6382008-02-19 17:37:35 +00003170 [(X86cmp (and_su GR16:$src1, GR16:$src2), 0),
Evan Cheng621216e2007-09-29 00:00:36 +00003171 (implicit EFLAGS)]>,
3172 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00003173def TEST32rr : I<0x85, MRMDestReg, (outs), (ins GR32:$src1, GR32:$src2),
Evan Cheng621216e2007-09-29 00:00:36 +00003174 "test{l}\t{$src2, $src1|$src1, $src2}",
Chris Lattner21da6382008-02-19 17:37:35 +00003175 [(X86cmp (and_su GR32:$src1, GR32:$src2), 0),
Evan Cheng621216e2007-09-29 00:00:36 +00003176 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003177}
3178
Sean Callanan3e4b1a32009-09-01 18:14:18 +00003179def TEST8i8 : Ii8<0xA8, RawFrm, (outs), (ins i8imm:$src),
3180 "test{b}\t{$src, %al|%al, $src}", []>;
3181def TEST16i16 : Ii16<0xA9, RawFrm, (outs), (ins i16imm:$src),
3182 "test{w}\t{$src, %ax|%ax, $src}", []>, OpSize;
3183def TEST32i32 : Ii32<0xA9, RawFrm, (outs), (ins i32imm:$src),
3184 "test{l}\t{$src, %eax|%eax, $src}", []>;
3185
Evan Chengb783fa32007-07-19 01:14:50 +00003186def TEST8rm : I<0x84, MRMSrcMem, (outs), (ins GR8 :$src1, i8mem :$src2),
Evan Cheng621216e2007-09-29 00:00:36 +00003187 "test{b}\t{$src2, $src1|$src1, $src2}",
3188 [(X86cmp (and GR8:$src1, (loadi8 addr:$src2)), 0),
3189 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00003190def TEST16rm : I<0x85, MRMSrcMem, (outs), (ins GR16:$src1, i16mem:$src2),
Evan Cheng621216e2007-09-29 00:00:36 +00003191 "test{w}\t{$src2, $src1|$src1, $src2}",
3192 [(X86cmp (and GR16:$src1, (loadi16 addr:$src2)), 0),
3193 (implicit EFLAGS)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00003194def TEST32rm : I<0x85, MRMSrcMem, (outs), (ins GR32:$src1, i32mem:$src2),
Evan Cheng621216e2007-09-29 00:00:36 +00003195 "test{l}\t{$src2, $src1|$src1, $src2}",
3196 [(X86cmp (and GR32:$src1, (loadi32 addr:$src2)), 0),
3197 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003198
3199def TEST8ri : Ii8 <0xF6, MRM0r, // flags = GR8 & imm8
Evan Chengb783fa32007-07-19 01:14:50 +00003200 (outs), (ins GR8:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00003201 "test{b}\t{$src2, $src1|$src1, $src2}",
Chris Lattner21da6382008-02-19 17:37:35 +00003202 [(X86cmp (and_su GR8:$src1, imm:$src2), 0),
Evan Cheng621216e2007-09-29 00:00:36 +00003203 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003204def TEST16ri : Ii16<0xF7, MRM0r, // flags = GR16 & imm16
Evan Chengb783fa32007-07-19 01:14:50 +00003205 (outs), (ins GR16:$src1, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00003206 "test{w}\t{$src2, $src1|$src1, $src2}",
Chris Lattner21da6382008-02-19 17:37:35 +00003207 [(X86cmp (and_su GR16:$src1, imm:$src2), 0),
Evan Cheng621216e2007-09-29 00:00:36 +00003208 (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003209def TEST32ri : Ii32<0xF7, MRM0r, // flags = GR32 & imm32
Evan Chengb783fa32007-07-19 01:14:50 +00003210 (outs), (ins GR32:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00003211 "test{l}\t{$src2, $src1|$src1, $src2}",
Chris Lattner21da6382008-02-19 17:37:35 +00003212 [(X86cmp (and_su GR32:$src1, imm:$src2), 0),
Evan Cheng621216e2007-09-29 00:00:36 +00003213 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003214
Evan Cheng621216e2007-09-29 00:00:36 +00003215def TEST8mi : Ii8 <0xF6, MRM0m, // flags = [mem8] & imm8
Evan Chengb783fa32007-07-19 01:14:50 +00003216 (outs), (ins i8mem:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00003217 "test{b}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00003218 [(X86cmp (and (loadi8 addr:$src1), imm:$src2), 0),
3219 (implicit EFLAGS)]>;
3220def TEST16mi : Ii16<0xF7, MRM0m, // flags = [mem16] & imm16
Evan Chengb783fa32007-07-19 01:14:50 +00003221 (outs), (ins i16mem:$src1, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00003222 "test{w}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00003223 [(X86cmp (and (loadi16 addr:$src1), imm:$src2), 0),
3224 (implicit EFLAGS)]>, OpSize;
3225def TEST32mi : Ii32<0xF7, MRM0m, // flags = [mem32] & imm32
Evan Chengb783fa32007-07-19 01:14:50 +00003226 (outs), (ins i32mem:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00003227 "test{l}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00003228 [(X86cmp (and (loadi32 addr:$src1), imm:$src2), 0),
Evan Cheng950aac02007-09-25 01:57:46 +00003229 (implicit EFLAGS)]>;
3230} // Defs = [EFLAGS]
3231
3232
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003233// Condition code ops, incl. set if equal/not equal/...
Chris Lattnerc90ee9c2008-01-10 07:59:24 +00003234let Defs = [EFLAGS], Uses = [AH], neverHasSideEffects = 1 in
Evan Cheng6e4d1d92007-09-11 19:55:27 +00003235def SAHF : I<0x9E, RawFrm, (outs), (ins), "sahf", []>; // flags = AH
Chris Lattnerc90ee9c2008-01-10 07:59:24 +00003236let Defs = [AH], Uses = [EFLAGS], neverHasSideEffects = 1 in
Evan Cheng6e4d1d92007-09-11 19:55:27 +00003237def LAHF : I<0x9F, RawFrm, (outs), (ins), "lahf", []>; // AH = flags
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003238
Evan Cheng950aac02007-09-25 01:57:46 +00003239let Uses = [EFLAGS] in {
Evan Cheng834ae6b2009-12-15 00:53:42 +00003240// Use sbb to materialize carry bit.
3241
3242let Defs = [EFLAGS], isCodeGenOnly = 1 in {
3243def SETB_C8r : I<0x18, MRMInitReg, (outs GR8:$dst), (ins),
3244 "sbb{b}\t$dst, $dst",
3245 [(set GR8:$dst, (X86setcc_c X86_COND_B, EFLAGS))]>;
3246def SETB_C16r : I<0x19, MRMInitReg, (outs GR16:$dst), (ins),
3247 "sbb{w}\t$dst, $dst",
Evan Chengedeb1692009-12-16 00:53:11 +00003248 [(set GR16:$dst, (X86setcc_c X86_COND_B, EFLAGS))]>,
Evan Cheng834ae6b2009-12-15 00:53:42 +00003249 OpSize;
3250def SETB_C32r : I<0x19, MRMInitReg, (outs GR32:$dst), (ins),
3251 "sbb{l}\t$dst, $dst",
Evan Chengedeb1692009-12-16 00:53:11 +00003252 [(set GR32:$dst, (X86setcc_c X86_COND_B, EFLAGS))]>;
Evan Cheng834ae6b2009-12-15 00:53:42 +00003253} // isCodeGenOnly
3254
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003255def SETEr : I<0x94, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00003256 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00003257 "sete\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00003258 [(set GR8:$dst, (X86setcc X86_COND_E, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003259 TB; // GR8 = ==
3260def SETEm : I<0x94, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00003261 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00003262 "sete\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00003263 [(store (X86setcc X86_COND_E, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003264 TB; // [mem8] = ==
Bill Wendling0c52d0a2008-12-02 00:07:05 +00003265
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003266def SETNEr : I<0x95, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00003267 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00003268 "setne\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00003269 [(set GR8:$dst, (X86setcc X86_COND_NE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003270 TB; // GR8 = !=
3271def SETNEm : I<0x95, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00003272 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00003273 "setne\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00003274 [(store (X86setcc X86_COND_NE, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003275 TB; // [mem8] = !=
Bill Wendling0c52d0a2008-12-02 00:07:05 +00003276
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003277def SETLr : I<0x9C, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00003278 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00003279 "setl\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00003280 [(set GR8:$dst, (X86setcc X86_COND_L, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003281 TB; // GR8 = < signed
3282def SETLm : I<0x9C, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00003283 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00003284 "setl\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00003285 [(store (X86setcc X86_COND_L, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003286 TB; // [mem8] = < signed
Bill Wendling0c52d0a2008-12-02 00:07:05 +00003287
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003288def SETGEr : I<0x9D, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00003289 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00003290 "setge\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00003291 [(set GR8:$dst, (X86setcc X86_COND_GE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003292 TB; // GR8 = >= signed
3293def SETGEm : I<0x9D, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00003294 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00003295 "setge\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00003296 [(store (X86setcc X86_COND_GE, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003297 TB; // [mem8] = >= signed
Bill Wendling0c52d0a2008-12-02 00:07:05 +00003298
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003299def SETLEr : I<0x9E, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00003300 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00003301 "setle\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00003302 [(set GR8:$dst, (X86setcc X86_COND_LE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003303 TB; // GR8 = <= signed
3304def SETLEm : I<0x9E, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00003305 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00003306 "setle\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00003307 [(store (X86setcc X86_COND_LE, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003308 TB; // [mem8] = <= signed
Bill Wendling0c52d0a2008-12-02 00:07:05 +00003309
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003310def SETGr : I<0x9F, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00003311 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00003312 "setg\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00003313 [(set GR8:$dst, (X86setcc X86_COND_G, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003314 TB; // GR8 = > signed
3315def SETGm : I<0x9F, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00003316 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00003317 "setg\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00003318 [(store (X86setcc X86_COND_G, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003319 TB; // [mem8] = > signed
3320
3321def SETBr : I<0x92, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00003322 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00003323 "setb\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00003324 [(set GR8:$dst, (X86setcc X86_COND_B, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003325 TB; // GR8 = < unsign
3326def SETBm : I<0x92, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00003327 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00003328 "setb\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00003329 [(store (X86setcc X86_COND_B, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003330 TB; // [mem8] = < unsign
Bill Wendling0c52d0a2008-12-02 00:07:05 +00003331
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003332def SETAEr : I<0x93, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00003333 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00003334 "setae\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00003335 [(set GR8:$dst, (X86setcc X86_COND_AE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003336 TB; // GR8 = >= unsign
3337def SETAEm : I<0x93, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00003338 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00003339 "setae\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00003340 [(store (X86setcc X86_COND_AE, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003341 TB; // [mem8] = >= unsign
Bill Wendling0c52d0a2008-12-02 00:07:05 +00003342
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003343def SETBEr : I<0x96, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00003344 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00003345 "setbe\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00003346 [(set GR8:$dst, (X86setcc X86_COND_BE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003347 TB; // GR8 = <= unsign
3348def SETBEm : I<0x96, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00003349 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00003350 "setbe\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00003351 [(store (X86setcc X86_COND_BE, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003352 TB; // [mem8] = <= unsign
Bill Wendling0c52d0a2008-12-02 00:07:05 +00003353
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003354def SETAr : I<0x97, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00003355 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00003356 "seta\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00003357 [(set GR8:$dst, (X86setcc X86_COND_A, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003358 TB; // GR8 = > signed
3359def SETAm : I<0x97, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00003360 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00003361 "seta\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00003362 [(store (X86setcc X86_COND_A, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003363 TB; // [mem8] = > signed
3364
3365def SETSr : I<0x98, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00003366 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00003367 "sets\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00003368 [(set GR8:$dst, (X86setcc X86_COND_S, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003369 TB; // GR8 = <sign bit>
3370def SETSm : I<0x98, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00003371 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00003372 "sets\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00003373 [(store (X86setcc X86_COND_S, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003374 TB; // [mem8] = <sign bit>
3375def SETNSr : I<0x99, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00003376 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00003377 "setns\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00003378 [(set GR8:$dst, (X86setcc X86_COND_NS, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003379 TB; // GR8 = !<sign bit>
3380def SETNSm : I<0x99, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00003381 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00003382 "setns\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00003383 [(store (X86setcc X86_COND_NS, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003384 TB; // [mem8] = !<sign bit>
Bill Wendling0c52d0a2008-12-02 00:07:05 +00003385
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003386def SETPr : I<0x9A, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00003387 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00003388 "setp\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00003389 [(set GR8:$dst, (X86setcc X86_COND_P, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003390 TB; // GR8 = parity
3391def SETPm : I<0x9A, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00003392 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00003393 "setp\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00003394 [(store (X86setcc X86_COND_P, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003395 TB; // [mem8] = parity
3396def SETNPr : I<0x9B, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00003397 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00003398 "setnp\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00003399 [(set GR8:$dst, (X86setcc X86_COND_NP, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003400 TB; // GR8 = not parity
3401def SETNPm : I<0x9B, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00003402 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00003403 "setnp\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00003404 [(store (X86setcc X86_COND_NP, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003405 TB; // [mem8] = not parity
Bill Wendling0c52d0a2008-12-02 00:07:05 +00003406
3407def SETOr : I<0x90, MRM0r,
3408 (outs GR8 :$dst), (ins),
3409 "seto\t$dst",
3410 [(set GR8:$dst, (X86setcc X86_COND_O, EFLAGS))]>,
3411 TB; // GR8 = overflow
3412def SETOm : I<0x90, MRM0m,
3413 (outs), (ins i8mem:$dst),
3414 "seto\t$dst",
3415 [(store (X86setcc X86_COND_O, EFLAGS), addr:$dst)]>,
3416 TB; // [mem8] = overflow
3417def SETNOr : I<0x91, MRM0r,
3418 (outs GR8 :$dst), (ins),
3419 "setno\t$dst",
3420 [(set GR8:$dst, (X86setcc X86_COND_NO, EFLAGS))]>,
3421 TB; // GR8 = not overflow
3422def SETNOm : I<0x91, MRM0m,
3423 (outs), (ins i8mem:$dst),
3424 "setno\t$dst",
3425 [(store (X86setcc X86_COND_NO, EFLAGS), addr:$dst)]>,
3426 TB; // [mem8] = not overflow
Evan Cheng950aac02007-09-25 01:57:46 +00003427} // Uses = [EFLAGS]
3428
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003429
3430// Integer comparisons
Evan Cheng55687072007-09-14 21:48:26 +00003431let Defs = [EFLAGS] in {
Sean Callanan251676e2009-09-02 00:55:49 +00003432def CMP8i8 : Ii8<0x3C, RawFrm, (outs), (ins i8imm:$src),
3433 "cmp{b}\t{$src, %al|%al, $src}", []>;
3434def CMP16i16 : Ii16<0x3D, RawFrm, (outs), (ins i16imm:$src),
3435 "cmp{w}\t{$src, %ax|%ax, $src}", []>, OpSize;
3436def CMP32i32 : Ii32<0x3D, RawFrm, (outs), (ins i32imm:$src),
3437 "cmp{l}\t{$src, %eax|%eax, $src}", []>;
3438
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003439def CMP8rr : I<0x38, MRMDestReg,
Evan Chengb783fa32007-07-19 01:14:50 +00003440 (outs), (ins GR8 :$src1, GR8 :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00003441 "cmp{b}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00003442 [(X86cmp GR8:$src1, GR8:$src2), (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003443def CMP16rr : I<0x39, MRMDestReg,
Evan Chengb783fa32007-07-19 01:14:50 +00003444 (outs), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00003445 "cmp{w}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00003446 [(X86cmp GR16:$src1, GR16:$src2), (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003447def CMP32rr : I<0x39, MRMDestReg,
Evan Chengb783fa32007-07-19 01:14:50 +00003448 (outs), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00003449 "cmp{l}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00003450 [(X86cmp GR32:$src1, GR32:$src2), (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003451def CMP8mr : I<0x38, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00003452 (outs), (ins i8mem :$src1, GR8 :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00003453 "cmp{b}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00003454 [(X86cmp (loadi8 addr:$src1), GR8:$src2),
3455 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003456def CMP16mr : I<0x39, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00003457 (outs), (ins i16mem:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00003458 "cmp{w}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00003459 [(X86cmp (loadi16 addr:$src1), GR16:$src2),
3460 (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003461def CMP32mr : I<0x39, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00003462 (outs), (ins i32mem:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00003463 "cmp{l}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00003464 [(X86cmp (loadi32 addr:$src1), GR32:$src2),
3465 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003466def CMP8rm : I<0x3A, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00003467 (outs), (ins GR8 :$src1, i8mem :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00003468 "cmp{b}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00003469 [(X86cmp GR8:$src1, (loadi8 addr:$src2)),
3470 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003471def CMP16rm : I<0x3B, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00003472 (outs), (ins GR16:$src1, i16mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00003473 "cmp{w}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00003474 [(X86cmp GR16:$src1, (loadi16 addr:$src2)),
3475 (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003476def CMP32rm : I<0x3B, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00003477 (outs), (ins GR32:$src1, i32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00003478 "cmp{l}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00003479 [(X86cmp GR32:$src1, (loadi32 addr:$src2)),
3480 (implicit EFLAGS)]>;
Sean Callanan11490dc2009-09-16 21:11:23 +00003481def CMP8mrmrr : I<0x3A, MRMSrcReg, (outs), (ins GR8:$src1, GR8:$src2),
3482 "cmp{b}\t{$src2, $src1|$src1, $src2}", []>;
3483def CMP16mrmrr : I<0x3B, MRMSrcReg, (outs), (ins GR16:$src1, GR16:$src2),
3484 "cmp{w}\t{$src2, $src1|$src1, $src2}", []>, OpSize;
3485def CMP32mrmrr : I<0x3B, MRMSrcReg, (outs), (ins GR32:$src1, GR32:$src2),
3486 "cmp{l}\t{$src2, $src1|$src1, $src2}", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003487def CMP8ri : Ii8<0x80, MRM7r,
Evan Chengb783fa32007-07-19 01:14:50 +00003488 (outs), (ins GR8:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00003489 "cmp{b}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00003490 [(X86cmp GR8:$src1, imm:$src2), (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003491def CMP16ri : Ii16<0x81, MRM7r,
Evan Chengb783fa32007-07-19 01:14:50 +00003492 (outs), (ins GR16:$src1, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00003493 "cmp{w}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00003494 [(X86cmp GR16:$src1, imm:$src2),
3495 (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003496def CMP32ri : Ii32<0x81, MRM7r,
Evan Chengb783fa32007-07-19 01:14:50 +00003497 (outs), (ins GR32:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00003498 "cmp{l}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00003499 [(X86cmp GR32:$src1, imm:$src2), (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003500def CMP8mi : Ii8 <0x80, MRM7m,
Evan Chengb783fa32007-07-19 01:14:50 +00003501 (outs), (ins i8mem :$src1, i8imm :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00003502 "cmp{b}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00003503 [(X86cmp (loadi8 addr:$src1), imm:$src2),
3504 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003505def CMP16mi : Ii16<0x81, MRM7m,
Evan Chengb783fa32007-07-19 01:14:50 +00003506 (outs), (ins i16mem:$src1, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00003507 "cmp{w}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00003508 [(X86cmp (loadi16 addr:$src1), imm:$src2),
3509 (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003510def CMP32mi : Ii32<0x81, MRM7m,
Evan Chengb783fa32007-07-19 01:14:50 +00003511 (outs), (ins i32mem:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00003512 "cmp{l}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00003513 [(X86cmp (loadi32 addr:$src1), imm:$src2),
3514 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003515def CMP16ri8 : Ii8<0x83, MRM7r,
Evan Chengb783fa32007-07-19 01:14:50 +00003516 (outs), (ins GR16:$src1, i16i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00003517 "cmp{w}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00003518 [(X86cmp GR16:$src1, i16immSExt8:$src2),
3519 (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003520def CMP16mi8 : Ii8<0x83, MRM7m,
Evan Chengb783fa32007-07-19 01:14:50 +00003521 (outs), (ins i16mem:$src1, i16i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00003522 "cmp{w}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00003523 [(X86cmp (loadi16 addr:$src1), i16immSExt8:$src2),
3524 (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003525def CMP32mi8 : Ii8<0x83, MRM7m,
Evan Chengb783fa32007-07-19 01:14:50 +00003526 (outs), (ins i32mem:$src1, i32i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00003527 "cmp{l}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00003528 [(X86cmp (loadi32 addr:$src1), i32immSExt8:$src2),
3529 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003530def CMP32ri8 : Ii8<0x83, MRM7r,
Evan Chengb783fa32007-07-19 01:14:50 +00003531 (outs), (ins GR32:$src1, i32i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00003532 "cmp{l}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00003533 [(X86cmp GR32:$src1, i32immSExt8:$src2),
Evan Cheng950aac02007-09-25 01:57:46 +00003534 (implicit EFLAGS)]>;
3535} // Defs = [EFLAGS]
3536
Dan Gohman7fe9b7f2008-12-23 22:45:23 +00003537// Bit tests.
Dan Gohman7fe9b7f2008-12-23 22:45:23 +00003538// TODO: BTC, BTR, and BTS
3539let Defs = [EFLAGS] in {
Dan Gohmanfc4eddb2009-01-13 20:32:45 +00003540def BT16rr : I<0xA3, MRMDestReg, (outs), (ins GR16:$src1, GR16:$src2),
Dan Gohman7fe9b7f2008-12-23 22:45:23 +00003541 "bt{w}\t{$src2, $src1|$src1, $src2}",
3542 [(X86bt GR16:$src1, GR16:$src2),
Chris Lattner5a95cde2008-12-25 01:32:49 +00003543 (implicit EFLAGS)]>, OpSize, TB;
Dan Gohmanfc4eddb2009-01-13 20:32:45 +00003544def BT32rr : I<0xA3, MRMDestReg, (outs), (ins GR32:$src1, GR32:$src2),
Dan Gohman7fe9b7f2008-12-23 22:45:23 +00003545 "bt{l}\t{$src2, $src1|$src1, $src2}",
3546 [(X86bt GR32:$src1, GR32:$src2),
Chris Lattner5a95cde2008-12-25 01:32:49 +00003547 (implicit EFLAGS)]>, TB;
Dan Gohman85a228c2009-01-13 23:23:30 +00003548
3549// Unlike with the register+register form, the memory+register form of the
3550// bt instruction does not ignore the high bits of the index. From ISel's
Sean Callanan2c48df22009-12-18 00:01:26 +00003551// perspective, this is pretty bizarre. Make these instructions disassembly
3552// only for now.
3553
3554def BT16mr : I<0xA3, MRMDestMem, (outs), (ins i16mem:$src1, GR16:$src2),
3555 "bt{w}\t{$src2, $src1|$src1, $src2}",
Dan Gohman85a228c2009-01-13 23:23:30 +00003556// [(X86bt (loadi16 addr:$src1), GR16:$src2),
Sean Callanan2c48df22009-12-18 00:01:26 +00003557// (implicit EFLAGS)]
3558 []
3559 >, OpSize, TB, Requires<[FastBTMem]>;
3560def BT32mr : I<0xA3, MRMDestMem, (outs), (ins i32mem:$src1, GR32:$src2),
3561 "bt{l}\t{$src2, $src1|$src1, $src2}",
Dan Gohman85a228c2009-01-13 23:23:30 +00003562// [(X86bt (loadi32 addr:$src1), GR32:$src2),
Sean Callanan2c48df22009-12-18 00:01:26 +00003563// (implicit EFLAGS)]
3564 []
3565 >, TB, Requires<[FastBTMem]>;
Dan Gohman46fb1cf2009-01-13 20:33:23 +00003566
3567def BT16ri8 : Ii8<0xBA, MRM4r, (outs), (ins GR16:$src1, i16i8imm:$src2),
3568 "bt{w}\t{$src2, $src1|$src1, $src2}",
3569 [(X86bt GR16:$src1, i16immSExt8:$src2),
3570 (implicit EFLAGS)]>, OpSize, TB;
3571def BT32ri8 : Ii8<0xBA, MRM4r, (outs), (ins GR32:$src1, i32i8imm:$src2),
3572 "bt{l}\t{$src2, $src1|$src1, $src2}",
3573 [(X86bt GR32:$src1, i32immSExt8:$src2),
3574 (implicit EFLAGS)]>, TB;
3575// Note that these instructions don't need FastBTMem because that
3576// only applies when the other operand is in a register. When it's
3577// an immediate, bt is still fast.
3578def BT16mi8 : Ii8<0xBA, MRM4m, (outs), (ins i16mem:$src1, i16i8imm:$src2),
3579 "bt{w}\t{$src2, $src1|$src1, $src2}",
3580 [(X86bt (loadi16 addr:$src1), i16immSExt8:$src2),
3581 (implicit EFLAGS)]>, OpSize, TB;
3582def BT32mi8 : Ii8<0xBA, MRM4m, (outs), (ins i32mem:$src1, i32i8imm:$src2),
3583 "bt{l}\t{$src2, $src1|$src1, $src2}",
3584 [(X86bt (loadi32 addr:$src1), i32immSExt8:$src2),
3585 (implicit EFLAGS)]>, TB;
Sean Callanan2c48df22009-12-18 00:01:26 +00003586
3587def BTC16rr : I<0xBB, MRMDestReg, (outs), (ins GR16:$src1, GR16:$src2),
3588 "btc{w}\t{$src2, $src1|$src1, $src2}", []>, OpSize, TB;
3589def BTC32rr : I<0xBB, MRMDestReg, (outs), (ins GR32:$src1, GR32:$src2),
3590 "btc{l}\t{$src2, $src1|$src1, $src2}", []>, TB;
3591def BTC16mr : I<0xBB, MRMDestMem, (outs), (ins i16mem:$src1, GR16:$src2),
3592 "btc{w}\t{$src2, $src1|$src1, $src2}", []>, OpSize, TB;
3593def BTC32mr : I<0xBB, MRMDestMem, (outs), (ins i32mem:$src1, GR32:$src2),
3594 "btc{l}\t{$src2, $src1|$src1, $src2}", []>, TB;
3595def BTC16ri8 : Ii8<0xBA, MRM7r, (outs), (ins GR16:$src1, i16i8imm:$src2),
3596 "btc{w}\t{$src2, $src1|$src1, $src2}", []>, OpSize, TB;
3597def BTC32ri8 : Ii8<0xBA, MRM7r, (outs), (ins GR32:$src1, i32i8imm:$src2),
3598 "btc{l}\t{$src2, $src1|$src1, $src2}", []>, TB;
3599def BTC16mi8 : Ii8<0xBA, MRM7m, (outs), (ins i16mem:$src1, i16i8imm:$src2),
3600 "btc{w}\t{$src2, $src1|$src1, $src2}", []>, OpSize, TB;
3601def BTC32mi8 : Ii8<0xBA, MRM7m, (outs), (ins i32mem:$src1, i32i8imm:$src2),
3602 "btc{l}\t{$src2, $src1|$src1, $src2}", []>, TB;
3603
3604def BTR16rr : I<0xB3, MRMDestReg, (outs), (ins GR16:$src1, GR16:$src2),
3605 "btr{w}\t{$src2, $src1|$src1, $src2}", []>, OpSize, TB;
3606def BTR32rr : I<0xB3, MRMDestReg, (outs), (ins GR32:$src1, GR32:$src2),
3607 "btr{l}\t{$src2, $src1|$src1, $src2}", []>, TB;
3608def BTR16mr : I<0xB3, MRMDestMem, (outs), (ins i16mem:$src1, GR16:$src2),
3609 "btr{w}\t{$src2, $src1|$src1, $src2}", []>, OpSize, TB;
3610def BTR32mr : I<0xB3, MRMDestMem, (outs), (ins i32mem:$src1, GR32:$src2),
3611 "btr{l}\t{$src2, $src1|$src1, $src2}", []>, TB;
3612def BTR16ri8 : Ii8<0xBA, MRM6r, (outs), (ins GR16:$src1, i16i8imm:$src2),
3613 "btr{w}\t{$src2, $src1|$src1, $src2}", []>, OpSize, TB;
3614def BTR32ri8 : Ii8<0xBA, MRM6r, (outs), (ins GR32:$src1, i32i8imm:$src2),
3615 "btr{l}\t{$src2, $src1|$src1, $src2}", []>, TB;
3616def BTR16mi8 : Ii8<0xBA, MRM6m, (outs), (ins i16mem:$src1, i16i8imm:$src2),
3617 "btr{w}\t{$src2, $src1|$src1, $src2}", []>, OpSize, TB;
3618def BTR32mi8 : Ii8<0xBA, MRM6m, (outs), (ins i32mem:$src1, i32i8imm:$src2),
3619 "btr{l}\t{$src2, $src1|$src1, $src2}", []>, TB;
3620
3621def BTS16rr : I<0xAB, MRMDestReg, (outs), (ins GR16:$src1, GR16:$src2),
3622 "bts{w}\t{$src2, $src1|$src1, $src2}", []>, OpSize, TB;
3623def BTS32rr : I<0xAB, MRMDestReg, (outs), (ins GR32:$src1, GR32:$src2),
3624 "bts{l}\t{$src2, $src1|$src1, $src2}", []>, TB;
3625def BTS16mr : I<0xAB, MRMDestMem, (outs), (ins i16mem:$src1, GR16:$src2),
3626 "bts{w}\t{$src2, $src1|$src1, $src2}", []>, OpSize, TB;
3627def BTS32mr : I<0xAB, MRMDestMem, (outs), (ins i32mem:$src1, GR32:$src2),
3628 "bts{l}\t{$src2, $src1|$src1, $src2}", []>, TB;
3629def BTS16ri8 : Ii8<0xBA, MRM5r, (outs), (ins GR16:$src1, i16i8imm:$src2),
3630 "bts{w}\t{$src2, $src1|$src1, $src2}", []>, OpSize, TB;
3631def BTS32ri8 : Ii8<0xBA, MRM5r, (outs), (ins GR32:$src1, i32i8imm:$src2),
3632 "bts{l}\t{$src2, $src1|$src1, $src2}", []>, TB;
3633def BTS16mi8 : Ii8<0xBA, MRM5m, (outs), (ins i16mem:$src1, i16i8imm:$src2),
3634 "bts{w}\t{$src2, $src1|$src1, $src2}", []>, OpSize, TB;
3635def BTS32mi8 : Ii8<0xBA, MRM5m, (outs), (ins i32mem:$src1, i32i8imm:$src2),
3636 "bts{l}\t{$src2, $src1|$src1, $src2}", []>, TB;
Dan Gohman7fe9b7f2008-12-23 22:45:23 +00003637} // Defs = [EFLAGS]
3638
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003639// Sign/Zero extenders
Dan Gohman9203ab42008-07-30 18:09:17 +00003640// Use movsbl intead of movsbw; we don't care about the high 16 bits
3641// of the register here. This has a smaller encoding and avoids a
Sean Callanan2c48df22009-12-18 00:01:26 +00003642// partial-register update. Actual movsbw included for the disassembler.
3643def MOVSX16rr8W : I<0xBE, MRMSrcReg, (outs GR16:$dst), (ins GR8:$src),
3644 "movs{bw|x}\t{$src, $dst|$dst, $src}", []>, TB, OpSize;
3645def MOVSX16rm8W : I<0xBE, MRMSrcMem, (outs GR16:$dst), (ins i8mem:$src),
3646 "movs{bw|x}\t{$src, $dst|$dst, $src}", []>, TB, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00003647def MOVSX16rr8 : I<0xBE, MRMSrcReg, (outs GR16:$dst), (ins GR8 :$src),
Chris Lattnerbe7efcc2009-10-19 19:51:42 +00003648 "", [(set GR16:$dst, (sext GR8:$src))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00003649def MOVSX16rm8 : I<0xBE, MRMSrcMem, (outs GR16:$dst), (ins i8mem :$src),
Chris Lattnerbe7efcc2009-10-19 19:51:42 +00003650 "", [(set GR16:$dst, (sextloadi16i8 addr:$src))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00003651def MOVSX32rr8 : I<0xBE, MRMSrcReg, (outs GR32:$dst), (ins GR8 :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00003652 "movs{bl|x}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003653 [(set GR32:$dst, (sext GR8:$src))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00003654def MOVSX32rm8 : I<0xBE, MRMSrcMem, (outs GR32:$dst), (ins i8mem :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00003655 "movs{bl|x}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003656 [(set GR32:$dst, (sextloadi32i8 addr:$src))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00003657def MOVSX32rr16: I<0xBF, MRMSrcReg, (outs GR32:$dst), (ins GR16:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00003658 "movs{wl|x}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003659 [(set GR32:$dst, (sext GR16:$src))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00003660def MOVSX32rm16: I<0xBF, MRMSrcMem, (outs GR32:$dst), (ins i16mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00003661 "movs{wl|x}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003662 [(set GR32:$dst, (sextloadi32i16 addr:$src))]>, TB;
3663
Dan Gohman9203ab42008-07-30 18:09:17 +00003664// Use movzbl intead of movzbw; we don't care about the high 16 bits
3665// of the register here. This has a smaller encoding and avoids a
Sean Callanan2c48df22009-12-18 00:01:26 +00003666// partial-register update. Actual movzbw included for the disassembler.
3667def MOVZX16rr8W : I<0xB6, MRMSrcReg, (outs GR16:$dst), (ins GR8:$src),
3668 "movz{bw|x}\t{$src, $dst|$dst, $src}", []>, TB, OpSize;
3669def MOVZX16rm8W : I<0xB6, MRMSrcMem, (outs GR16:$dst), (ins i8mem:$src),
3670 "movz{bw|x}\t{$src, $dst|$dst, $src}", []>, TB, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00003671def MOVZX16rr8 : I<0xB6, MRMSrcReg, (outs GR16:$dst), (ins GR8 :$src),
Chris Lattnerbe7efcc2009-10-19 19:51:42 +00003672 "", [(set GR16:$dst, (zext GR8:$src))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00003673def MOVZX16rm8 : I<0xB6, MRMSrcMem, (outs GR16:$dst), (ins i8mem :$src),
Chris Lattnerbe7efcc2009-10-19 19:51:42 +00003674 "", [(set GR16:$dst, (zextloadi16i8 addr:$src))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00003675def MOVZX32rr8 : I<0xB6, MRMSrcReg, (outs GR32:$dst), (ins GR8 :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00003676 "movz{bl|x}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003677 [(set GR32:$dst, (zext GR8:$src))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00003678def MOVZX32rm8 : I<0xB6, MRMSrcMem, (outs GR32:$dst), (ins i8mem :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00003679 "movz{bl|x}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003680 [(set GR32:$dst, (zextloadi32i8 addr:$src))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00003681def MOVZX32rr16: I<0xB7, MRMSrcReg, (outs GR32:$dst), (ins GR16:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00003682 "movz{wl|x}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003683 [(set GR32:$dst, (zext GR16:$src))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00003684def MOVZX32rm16: I<0xB7, MRMSrcMem, (outs GR32:$dst), (ins i16mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00003685 "movz{wl|x}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003686 [(set GR32:$dst, (zextloadi32i16 addr:$src))]>, TB;
3687
Dan Gohman744d4622009-04-13 16:09:41 +00003688// These are the same as the regular regular MOVZX32rr8 and MOVZX32rm8
3689// except that they use GR32_NOREX for the output operand register class
3690// instead of GR32. This allows them to operate on h registers on x86-64.
3691def MOVZX32_NOREXrr8 : I<0xB6, MRMSrcReg,
3692 (outs GR32_NOREX:$dst), (ins GR8:$src),
3693 "movz{bl|x}\t{$src, $dst|$dst, $src} # NOREX",
3694 []>, TB;
Dan Gohman89f4cda2009-04-30 03:11:48 +00003695let mayLoad = 1 in
Dan Gohman744d4622009-04-13 16:09:41 +00003696def MOVZX32_NOREXrm8 : I<0xB6, MRMSrcMem,
3697 (outs GR32_NOREX:$dst), (ins i8mem:$src),
3698 "movz{bl|x}\t{$src, $dst|$dst, $src} # NOREX",
3699 []>, TB;
3700
Chris Lattnerc90ee9c2008-01-10 07:59:24 +00003701let neverHasSideEffects = 1 in {
3702 let Defs = [AX], Uses = [AL] in
3703 def CBW : I<0x98, RawFrm, (outs), (ins),
3704 "{cbtw|cbw}", []>, OpSize; // AX = signext(AL)
3705 let Defs = [EAX], Uses = [AX] in
3706 def CWDE : I<0x98, RawFrm, (outs), (ins),
3707 "{cwtl|cwde}", []>; // EAX = signext(AX)
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003708
Chris Lattnerc90ee9c2008-01-10 07:59:24 +00003709 let Defs = [AX,DX], Uses = [AX] in
3710 def CWD : I<0x99, RawFrm, (outs), (ins),
3711 "{cwtd|cwd}", []>, OpSize; // DX:AX = signext(AX)
3712 let Defs = [EAX,EDX], Uses = [EAX] in
3713 def CDQ : I<0x99, RawFrm, (outs), (ins),
3714 "{cltd|cdq}", []>; // EDX:EAX = signext(EAX)
3715}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003716
3717//===----------------------------------------------------------------------===//
3718// Alias Instructions
3719//===----------------------------------------------------------------------===//
3720
3721// Alias instructions that map movr0 to xor.
3722// FIXME: remove when we can teach regalloc that xor reg, reg is ok.
Daniel Dunbara0e62002009-08-11 22:17:52 +00003723let Defs = [EFLAGS], isReMaterializable = 1, isAsCheapAsAMove = 1,
3724 isCodeGenOnly = 1 in {
Evan Chengb783fa32007-07-19 01:14:50 +00003725def MOV8r0 : I<0x30, MRMInitReg, (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00003726 "xor{b}\t$dst, $dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003727 [(set GR8:$dst, 0)]>;
Dan Gohmanb9e1c8d2010-01-12 04:42:54 +00003728
3729// We want to rewrite MOV16r0 in terms of MOV32r0, because it's a smaller
3730// encoding and avoids a partial-register update sometimes, but doing so
3731// at isel time interferes with rematerialization in the current register
3732// allocator. For now, this is rewritten when the instruction is lowered
3733// to an MCInst.
3734def MOV16r0 : I<0x31, MRMInitReg, (outs GR16:$dst), (ins),
3735 "",
3736 [(set GR16:$dst, 0)]>, OpSize;
Chris Lattnerb5b1b862009-12-23 01:30:26 +00003737
Chris Lattner2ba53dc2009-12-23 01:46:40 +00003738def MOV32r0 : I<0x31, MRMInitReg, (outs GR32:$dst), (ins),
3739 "xor{l}\t$dst, $dst",
3740 [(set GR32:$dst, 0)]>;
3741}
Chris Lattnerb5b1b862009-12-23 01:30:26 +00003742
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003743//===----------------------------------------------------------------------===//
3744// Thread Local Storage Instructions
3745//
3746
Rafael Espindola7fc4b8d2009-04-24 12:59:40 +00003747// All calls clobber the non-callee saved registers. ESP is marked as
3748// a use to prevent stack-pointer assignments that appear immediately
3749// before calls from potentially appearing dead.
3750let Defs = [EAX, ECX, EDX, FP0, FP1, FP2, FP3, FP4, FP5, FP6, ST0,
3751 MM0, MM1, MM2, MM3, MM4, MM5, MM6, MM7,
3752 XMM0, XMM1, XMM2, XMM3, XMM4, XMM5, XMM6, XMM7,
3753 XMM8, XMM9, XMM10, XMM11, XMM12, XMM13, XMM14, XMM15, EFLAGS],
Chris Lattnerf1940742009-06-20 20:38:48 +00003754 Uses = [ESP] in
3755def TLS_addr32 : I<0, Pseudo, (outs), (ins lea32mem:$sym),
3756 "leal\t$sym, %eax; "
Dan Gohman70a8a112009-04-27 15:13:28 +00003757 "call\t___tls_get_addr@PLT",
Chris Lattnerf1940742009-06-20 20:38:48 +00003758 [(X86tlsaddr tls32addr:$sym)]>,
Rafael Espindolaaf759ab2009-04-17 14:35:58 +00003759 Requires<[In32BitMode]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003760
Daniel Dunbar75a07302009-08-11 22:24:40 +00003761let AddedComplexity = 5, isCodeGenOnly = 1 in
sampo9cc09a32009-01-26 01:24:32 +00003762def GS_MOV32rm : I<0x8B, MRMSrcMem, (outs GR32:$dst), (ins i32mem:$src),
3763 "movl\t%gs:$src, $dst",
3764 [(set GR32:$dst, (gsload addr:$src))]>, SegGS;
3765
Daniel Dunbar75a07302009-08-11 22:24:40 +00003766let AddedComplexity = 5, isCodeGenOnly = 1 in
Chris Lattnera7c2d8a2009-05-05 18:52:19 +00003767def FS_MOV32rm : I<0x8B, MRMSrcMem, (outs GR32:$dst), (ins i32mem:$src),
3768 "movl\t%fs:$src, $dst",
3769 [(set GR32:$dst, (fsload addr:$src))]>, SegFS;
3770
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003771//===----------------------------------------------------------------------===//
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003772// EH Pseudo Instructions
3773//
3774let isTerminator = 1, isReturn = 1, isBarrier = 1,
Daniel Dunbar75513bd2009-08-27 07:58:05 +00003775 hasCtrlDep = 1, isCodeGenOnly = 1 in {
Evan Chengb783fa32007-07-19 01:14:50 +00003776def EH_RETURN : I<0xC3, RawFrm, (outs), (ins GR32:$addr),
Dan Gohman91888f02007-07-31 20:11:57 +00003777 "ret\t#eh_return, addr: $addr",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003778 [(X86ehret GR32:$addr)]>;
3779
3780}
3781
3782//===----------------------------------------------------------------------===//
Andrew Lenharthe44f3902008-02-21 06:45:13 +00003783// Atomic support
3784//
Andrew Lenharth7a5a4b22008-03-01 13:37:02 +00003785
Evan Cheng3e171562008-04-19 01:20:30 +00003786// Atomic swap. These are just normal xchg instructions. But since a memory
3787// operand is referenced, the atomicity is ensured.
Dan Gohmana41a1c092008-08-06 15:52:50 +00003788let Constraints = "$val = $dst" in {
Sean Callanan2c48df22009-12-18 00:01:26 +00003789def XCHG32rm : I<0x87, MRMSrcMem, (outs GR32:$dst),
3790 (ins GR32:$val, i32mem:$ptr),
Evan Cheng3e171562008-04-19 01:20:30 +00003791 "xchg{l}\t{$val, $ptr|$ptr, $val}",
3792 [(set GR32:$dst, (atomic_swap_32 addr:$ptr, GR32:$val))]>;
Sean Callanan2c48df22009-12-18 00:01:26 +00003793def XCHG16rm : I<0x87, MRMSrcMem, (outs GR16:$dst),
3794 (ins GR16:$val, i16mem:$ptr),
Evan Cheng3e171562008-04-19 01:20:30 +00003795 "xchg{w}\t{$val, $ptr|$ptr, $val}",
3796 [(set GR16:$dst, (atomic_swap_16 addr:$ptr, GR16:$val))]>,
3797 OpSize;
Sean Callanan2c48df22009-12-18 00:01:26 +00003798def XCHG8rm : I<0x86, MRMSrcMem, (outs GR8:$dst), (ins GR8:$val, i8mem:$ptr),
Evan Cheng3e171562008-04-19 01:20:30 +00003799 "xchg{b}\t{$val, $ptr|$ptr, $val}",
3800 [(set GR8:$dst, (atomic_swap_8 addr:$ptr, GR8:$val))]>;
Sean Callanan2c48df22009-12-18 00:01:26 +00003801
3802def XCHG32rr : I<0x87, MRMSrcReg, (outs GR32:$dst), (ins GR32:$val, GR32:$src),
3803 "xchg{l}\t{$val, $src|$src, $val}", []>;
3804def XCHG16rr : I<0x87, MRMSrcReg, (outs GR16:$dst), (ins GR16:$val, GR16:$src),
3805 "xchg{w}\t{$val, $src|$src, $val}", []>, OpSize;
3806def XCHG8rr : I<0x86, MRMSrcReg, (outs GR8:$dst), (ins GR8:$val, GR8:$src),
3807 "xchg{b}\t{$val, $src|$src, $val}", []>;
Evan Cheng3e171562008-04-19 01:20:30 +00003808}
3809
Sean Callanan2c48df22009-12-18 00:01:26 +00003810def XCHG16ar : I<0x90, AddRegFrm, (outs), (ins GR16:$src),
3811 "xchg{w}\t{$src, %ax|%ax, $src}", []>, OpSize;
3812def XCHG32ar : I<0x90, AddRegFrm, (outs), (ins GR32:$src),
3813 "xchg{l}\t{$src, %eax|%eax, $src}", []>;
3814
Evan Chengd49dbb82008-04-18 20:55:36 +00003815// Atomic compare and swap.
Andrew Lenharth7dfe23f2008-03-01 21:52:34 +00003816let Defs = [EAX, EFLAGS], Uses = [EAX] in {
Evan Chengd49dbb82008-04-18 20:55:36 +00003817def LCMPXCHG32 : I<0xB1, MRMDestMem, (outs), (ins i32mem:$ptr, GR32:$swap),
Dan Gohman70a8a112009-04-27 15:13:28 +00003818 "lock\n\t"
3819 "cmpxchg{l}\t{$swap, $ptr|$ptr, $swap}",
Evan Cheng09fbdee2008-03-04 03:20:06 +00003820 [(X86cas addr:$ptr, GR32:$swap, 4)]>, TB, LOCK;
Andrew Lenharth7a5a4b22008-03-01 13:37:02 +00003821}
Dale Johannesenf160d802008-10-02 18:53:47 +00003822let Defs = [EAX, EDX, EFLAGS], Uses = [EAX, EBX, ECX, EDX] in {
Evan Cheng3896a6f2010-01-08 01:29:19 +00003823def LCMPXCHG8B : I<0xC7, MRM1m, (outs), (ins i64mem:$ptr),
Dan Gohman70a8a112009-04-27 15:13:28 +00003824 "lock\n\t"
3825 "cmpxchg8b\t$ptr",
Andrew Lenharth81580822008-03-05 01:15:49 +00003826 [(X86cas8 addr:$ptr)]>, TB, LOCK;
3827}
Andrew Lenharth7dfe23f2008-03-01 21:52:34 +00003828
3829let Defs = [AX, EFLAGS], Uses = [AX] in {
Evan Chengd49dbb82008-04-18 20:55:36 +00003830def LCMPXCHG16 : I<0xB1, MRMDestMem, (outs), (ins i16mem:$ptr, GR16:$swap),
Dan Gohman70a8a112009-04-27 15:13:28 +00003831 "lock\n\t"
3832 "cmpxchg{w}\t{$swap, $ptr|$ptr, $swap}",
Evan Cheng09fbdee2008-03-04 03:20:06 +00003833 [(X86cas addr:$ptr, GR16:$swap, 2)]>, TB, OpSize, LOCK;
Andrew Lenharth7a5a4b22008-03-01 13:37:02 +00003834}
Andrew Lenharth7dfe23f2008-03-01 21:52:34 +00003835let Defs = [AL, EFLAGS], Uses = [AL] in {
Evan Chengd49dbb82008-04-18 20:55:36 +00003836def LCMPXCHG8 : I<0xB0, MRMDestMem, (outs), (ins i8mem:$ptr, GR8:$swap),
Dan Gohman70a8a112009-04-27 15:13:28 +00003837 "lock\n\t"
3838 "cmpxchg{b}\t{$swap, $ptr|$ptr, $swap}",
Evan Cheng09fbdee2008-03-04 03:20:06 +00003839 [(X86cas addr:$ptr, GR8:$swap, 1)]>, TB, LOCK;
Andrew Lenharth7a5a4b22008-03-01 13:37:02 +00003840}
3841
Evan Chengd49dbb82008-04-18 20:55:36 +00003842// Atomic exchange and add
3843let Constraints = "$val = $dst", Defs = [EFLAGS] in {
Sean Callanan2c48df22009-12-18 00:01:26 +00003844def LXADD32 : I<0xC1, MRMSrcMem, (outs GR32:$dst), (ins GR32:$val, i32mem:$ptr),
Dan Gohman70a8a112009-04-27 15:13:28 +00003845 "lock\n\t"
3846 "xadd{l}\t{$val, $ptr|$ptr, $val}",
Mon P Wang6bde9ec2008-06-25 08:15:39 +00003847 [(set GR32:$dst, (atomic_load_add_32 addr:$ptr, GR32:$val))]>,
Evan Chengd49dbb82008-04-18 20:55:36 +00003848 TB, LOCK;
Sean Callanan2c48df22009-12-18 00:01:26 +00003849def LXADD16 : I<0xC1, MRMSrcMem, (outs GR16:$dst), (ins GR16:$val, i16mem:$ptr),
Dan Gohman70a8a112009-04-27 15:13:28 +00003850 "lock\n\t"
3851 "xadd{w}\t{$val, $ptr|$ptr, $val}",
Mon P Wang6bde9ec2008-06-25 08:15:39 +00003852 [(set GR16:$dst, (atomic_load_add_16 addr:$ptr, GR16:$val))]>,
Evan Chengd49dbb82008-04-18 20:55:36 +00003853 TB, OpSize, LOCK;
Sean Callanan2c48df22009-12-18 00:01:26 +00003854def LXADD8 : I<0xC0, MRMSrcMem, (outs GR8:$dst), (ins GR8:$val, i8mem:$ptr),
Dan Gohman70a8a112009-04-27 15:13:28 +00003855 "lock\n\t"
3856 "xadd{b}\t{$val, $ptr|$ptr, $val}",
Mon P Wang6bde9ec2008-06-25 08:15:39 +00003857 [(set GR8:$dst, (atomic_load_add_8 addr:$ptr, GR8:$val))]>,
Evan Chengd49dbb82008-04-18 20:55:36 +00003858 TB, LOCK;
Andrew Lenharth7a5a4b22008-03-01 13:37:02 +00003859}
3860
Sean Callanan2c48df22009-12-18 00:01:26 +00003861def XADD8rr : I<0xC0, MRMDestReg, (outs GR8:$dst), (ins GR8:$src),
3862 "xadd{b}\t{$src, $dst|$dst, $src}", []>, TB;
3863def XADD16rr : I<0xC1, MRMDestReg, (outs GR16:$dst), (ins GR16:$src),
3864 "xadd{w}\t{$src, $dst|$dst, $src}", []>, TB, OpSize;
3865def XADD32rr : I<0xC1, MRMDestReg, (outs GR32:$dst), (ins GR32:$src),
3866 "xadd{l}\t{$src, $dst|$dst, $src}", []>, TB;
3867
3868def XADD8rm : I<0xC0, MRMDestMem, (outs), (ins i8mem:$dst, GR8:$src),
3869 "xadd{b}\t{$src, $dst|$dst, $src}", []>, TB;
3870def XADD16rm : I<0xC1, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src),
3871 "xadd{w}\t{$src, $dst|$dst, $src}", []>, TB, OpSize;
3872def XADD32rm : I<0xC1, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src),
3873 "xadd{l}\t{$src, $dst|$dst, $src}", []>, TB;
3874
3875def CMPXCHG8rr : I<0xB0, MRMDestReg, (outs GR8:$dst), (ins GR8:$src),
3876 "cmpxchg{b}\t{$src, $dst|$dst, $src}", []>, TB;
3877def CMPXCHG16rr : I<0xB1, MRMDestReg, (outs GR16:$dst), (ins GR16:$src),
3878 "cmpxchg{w}\t{$src, $dst|$dst, $src}", []>, TB, OpSize;
3879def CMPXCHG32rr : I<0xB1, MRMDestReg, (outs GR32:$dst), (ins GR32:$src),
3880 "cmpxchg{l}\t{$src, $dst|$dst, $src}", []>, TB;
3881
3882def CMPXCHG8rm : I<0xB0, MRMDestMem, (outs), (ins i8mem:$dst, GR8:$src),
3883 "cmpxchg{b}\t{$src, $dst|$dst, $src}", []>, TB;
3884def CMPXCHG16rm : I<0xB1, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src),
3885 "cmpxchg{w}\t{$src, $dst|$dst, $src}", []>, TB, OpSize;
3886def CMPXCHG32rm : I<0xB1, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src),
3887 "cmpxchg{l}\t{$src, $dst|$dst, $src}", []>, TB;
3888
Evan Cheng3896a6f2010-01-08 01:29:19 +00003889let Defs = [EAX, EDX, EFLAGS], Uses = [EAX, EBX, ECX, EDX] in
Sean Callanan2c48df22009-12-18 00:01:26 +00003890def CMPXCHG8B : I<0xC7, MRM1m, (outs), (ins i64mem:$dst),
3891 "cmpxchg8b\t$dst", []>, TB;
3892
Evan Chengb723fb52009-07-30 08:33:02 +00003893// Optimized codegen when the non-memory output is not used.
3894// FIXME: Use normal add / sub instructions and add lock prefix dynamically.
Dan Gohman1c286992009-10-20 18:14:49 +00003895let Defs = [EFLAGS] in {
Evan Chengb723fb52009-07-30 08:33:02 +00003896def LOCK_ADD8mr : I<0x00, MRMDestMem, (outs), (ins i8mem:$dst, GR8:$src2),
3897 "lock\n\t"
3898 "add{b}\t{$src2, $dst|$dst, $src2}", []>, LOCK;
3899def LOCK_ADD16mr : I<0x01, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
3900 "lock\n\t"
3901 "add{w}\t{$src2, $dst|$dst, $src2}", []>, OpSize, LOCK;
3902def LOCK_ADD32mr : I<0x01, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
3903 "lock\n\t"
3904 "add{l}\t{$src2, $dst|$dst, $src2}", []>, LOCK;
3905def LOCK_ADD8mi : Ii8<0x80, MRM0m, (outs), (ins i8mem :$dst, i8imm :$src2),
3906 "lock\n\t"
3907 "add{b}\t{$src2, $dst|$dst, $src2}", []>, LOCK;
3908def LOCK_ADD16mi : Ii16<0x81, MRM0m, (outs), (ins i16mem:$dst, i16imm:$src2),
3909 "lock\n\t"
3910 "add{w}\t{$src2, $dst|$dst, $src2}", []>, LOCK;
3911def LOCK_ADD32mi : Ii32<0x81, MRM0m, (outs), (ins i32mem:$dst, i32imm:$src2),
3912 "lock\n\t"
3913 "add{l}\t{$src2, $dst|$dst, $src2}", []>, LOCK;
3914def LOCK_ADD16mi8 : Ii8<0x83, MRM0m, (outs), (ins i16mem:$dst, i16i8imm :$src2),
3915 "lock\n\t"
3916 "add{w}\t{$src2, $dst|$dst, $src2}", []>, OpSize, LOCK;
3917def LOCK_ADD32mi8 : Ii8<0x83, MRM0m, (outs), (ins i32mem:$dst, i32i8imm :$src2),
3918 "lock\n\t"
3919 "add{l}\t{$src2, $dst|$dst, $src2}", []>, LOCK;
3920
3921def LOCK_INC8m : I<0xFE, MRM0m, (outs), (ins i8mem :$dst),
3922 "lock\n\t"
3923 "inc{b}\t$dst", []>, LOCK;
3924def LOCK_INC16m : I<0xFF, MRM0m, (outs), (ins i16mem:$dst),
3925 "lock\n\t"
3926 "inc{w}\t$dst", []>, OpSize, LOCK;
3927def LOCK_INC32m : I<0xFF, MRM0m, (outs), (ins i32mem:$dst),
3928 "lock\n\t"
3929 "inc{l}\t$dst", []>, LOCK;
3930
3931def LOCK_SUB8mr : I<0x28, MRMDestMem, (outs), (ins i8mem :$dst, GR8 :$src2),
3932 "lock\n\t"
3933 "sub{b}\t{$src2, $dst|$dst, $src2}", []>, LOCK;
3934def LOCK_SUB16mr : I<0x29, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
3935 "lock\n\t"
3936 "sub{w}\t{$src2, $dst|$dst, $src2}", []>, OpSize, LOCK;
3937def LOCK_SUB32mr : I<0x29, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
3938 "lock\n\t"
3939 "sub{l}\t{$src2, $dst|$dst, $src2}", []>, LOCK;
3940def LOCK_SUB8mi : Ii8<0x80, MRM5m, (outs), (ins i8mem :$dst, i8imm:$src2),
3941 "lock\n\t"
3942 "sub{b}\t{$src2, $dst|$dst, $src2}", []>, LOCK;
3943def LOCK_SUB16mi : Ii16<0x81, MRM5m, (outs), (ins i16mem:$dst, i16imm:$src2),
3944 "lock\n\t"
3945 "sub{w}\t{$src2, $dst|$dst, $src2}", []>, OpSize, LOCK;
3946def LOCK_SUB32mi : Ii32<0x81, MRM5m, (outs), (ins i32mem:$dst, i32imm:$src2),
3947 "lock\n\t"
3948 "sub{l}\t{$src2, $dst|$dst, $src2}", []>, LOCK;
Sean Callanan2c48df22009-12-18 00:01:26 +00003949def LOCK_SUB16mi8 : Ii8<0x83, MRM5m, (outs), (ins i16mem:$dst, i16i8imm :$src2),
Evan Chengb723fb52009-07-30 08:33:02 +00003950 "lock\n\t"
3951 "sub{w}\t{$src2, $dst|$dst, $src2}", []>, OpSize, LOCK;
3952def LOCK_SUB32mi8 : Ii8<0x83, MRM5m, (outs), (ins i32mem:$dst, i32i8imm :$src2),
3953 "lock\n\t"
3954 "sub{l}\t{$src2, $dst|$dst, $src2}", []>, LOCK;
3955
3956def LOCK_DEC8m : I<0xFE, MRM1m, (outs), (ins i8mem :$dst),
3957 "lock\n\t"
3958 "dec{b}\t$dst", []>, LOCK;
3959def LOCK_DEC16m : I<0xFF, MRM1m, (outs), (ins i16mem:$dst),
3960 "lock\n\t"
3961 "dec{w}\t$dst", []>, OpSize, LOCK;
3962def LOCK_DEC32m : I<0xFF, MRM1m, (outs), (ins i32mem:$dst),
3963 "lock\n\t"
3964 "dec{l}\t$dst", []>, LOCK;
Dan Gohman1c286992009-10-20 18:14:49 +00003965}
Evan Chengb723fb52009-07-30 08:33:02 +00003966
Mon P Wang6bde9ec2008-06-25 08:15:39 +00003967// Atomic exchange, and, or, xor
Mon P Wang078a62d2008-05-05 19:05:59 +00003968let Constraints = "$val = $dst", Defs = [EFLAGS],
Dan Gohman30afe012009-10-29 18:10:34 +00003969 usesCustomInserter = 1 in {
Dan Gohman8aeb61f2008-05-12 20:22:45 +00003970def ATOMAND32 : I<0, Pseudo, (outs GR32:$dst),(ins i32mem:$ptr, GR32:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003971 "#ATOMAND32 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003972 [(set GR32:$dst, (atomic_load_and_32 addr:$ptr, GR32:$val))]>;
Dan Gohman8aeb61f2008-05-12 20:22:45 +00003973def ATOMOR32 : I<0, Pseudo, (outs GR32:$dst),(ins i32mem:$ptr, GR32:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003974 "#ATOMOR32 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003975 [(set GR32:$dst, (atomic_load_or_32 addr:$ptr, GR32:$val))]>;
Dan Gohman8aeb61f2008-05-12 20:22:45 +00003976def ATOMXOR32 : I<0, Pseudo,(outs GR32:$dst),(ins i32mem:$ptr, GR32:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003977 "#ATOMXOR32 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003978 [(set GR32:$dst, (atomic_load_xor_32 addr:$ptr, GR32:$val))]>;
Andrew Lenharthaf02d592008-06-14 05:48:15 +00003979def ATOMNAND32 : I<0, Pseudo,(outs GR32:$dst),(ins i32mem:$ptr, GR32:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003980 "#ATOMNAND32 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003981 [(set GR32:$dst, (atomic_load_nand_32 addr:$ptr, GR32:$val))]>;
Dan Gohman8aeb61f2008-05-12 20:22:45 +00003982def ATOMMIN32: I<0, Pseudo, (outs GR32:$dst), (ins i32mem:$ptr, GR32:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003983 "#ATOMMIN32 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003984 [(set GR32:$dst, (atomic_load_min_32 addr:$ptr, GR32:$val))]>;
Dan Gohman8aeb61f2008-05-12 20:22:45 +00003985def ATOMMAX32: I<0, Pseudo, (outs GR32:$dst),(ins i32mem:$ptr, GR32:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003986 "#ATOMMAX32 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003987 [(set GR32:$dst, (atomic_load_max_32 addr:$ptr, GR32:$val))]>;
Dan Gohman8aeb61f2008-05-12 20:22:45 +00003988def ATOMUMIN32: I<0, Pseudo, (outs GR32:$dst),(ins i32mem:$ptr, GR32:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003989 "#ATOMUMIN32 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003990 [(set GR32:$dst, (atomic_load_umin_32 addr:$ptr, GR32:$val))]>;
Dan Gohman8aeb61f2008-05-12 20:22:45 +00003991def ATOMUMAX32: I<0, Pseudo, (outs GR32:$dst),(ins i32mem:$ptr, GR32:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003992 "#ATOMUMAX32 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003993 [(set GR32:$dst, (atomic_load_umax_32 addr:$ptr, GR32:$val))]>;
Dale Johannesend20e4452008-08-19 18:47:28 +00003994
3995def ATOMAND16 : I<0, Pseudo, (outs GR16:$dst),(ins i16mem:$ptr, GR16:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003996 "#ATOMAND16 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003997 [(set GR16:$dst, (atomic_load_and_16 addr:$ptr, GR16:$val))]>;
Dale Johannesend20e4452008-08-19 18:47:28 +00003998def ATOMOR16 : I<0, Pseudo, (outs GR16:$dst),(ins i16mem:$ptr, GR16:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003999 "#ATOMOR16 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00004000 [(set GR16:$dst, (atomic_load_or_16 addr:$ptr, GR16:$val))]>;
Dale Johannesend20e4452008-08-19 18:47:28 +00004001def ATOMXOR16 : I<0, Pseudo,(outs GR16:$dst),(ins i16mem:$ptr, GR16:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00004002 "#ATOMXOR16 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00004003 [(set GR16:$dst, (atomic_load_xor_16 addr:$ptr, GR16:$val))]>;
Dale Johannesend20e4452008-08-19 18:47:28 +00004004def ATOMNAND16 : I<0, Pseudo,(outs GR16:$dst),(ins i16mem:$ptr, GR16:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00004005 "#ATOMNAND16 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00004006 [(set GR16:$dst, (atomic_load_nand_16 addr:$ptr, GR16:$val))]>;
Dale Johannesend20e4452008-08-19 18:47:28 +00004007def ATOMMIN16: I<0, Pseudo, (outs GR16:$dst), (ins i16mem:$ptr, GR16:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00004008 "#ATOMMIN16 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00004009 [(set GR16:$dst, (atomic_load_min_16 addr:$ptr, GR16:$val))]>;
Dale Johannesend20e4452008-08-19 18:47:28 +00004010def ATOMMAX16: I<0, Pseudo, (outs GR16:$dst),(ins i16mem:$ptr, GR16:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00004011 "#ATOMMAX16 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00004012 [(set GR16:$dst, (atomic_load_max_16 addr:$ptr, GR16:$val))]>;
Dale Johannesend20e4452008-08-19 18:47:28 +00004013def ATOMUMIN16: I<0, Pseudo, (outs GR16:$dst),(ins i16mem:$ptr, GR16:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00004014 "#ATOMUMIN16 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00004015 [(set GR16:$dst, (atomic_load_umin_16 addr:$ptr, GR16:$val))]>;
Dale Johannesend20e4452008-08-19 18:47:28 +00004016def ATOMUMAX16: I<0, Pseudo, (outs GR16:$dst),(ins i16mem:$ptr, GR16:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00004017 "#ATOMUMAX16 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00004018 [(set GR16:$dst, (atomic_load_umax_16 addr:$ptr, GR16:$val))]>;
Dale Johannesend20e4452008-08-19 18:47:28 +00004019
4020def ATOMAND8 : I<0, Pseudo, (outs GR8:$dst),(ins i8mem:$ptr, GR8:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00004021 "#ATOMAND8 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00004022 [(set GR8:$dst, (atomic_load_and_8 addr:$ptr, GR8:$val))]>;
Dale Johannesend20e4452008-08-19 18:47:28 +00004023def ATOMOR8 : I<0, Pseudo, (outs GR8:$dst),(ins i8mem:$ptr, GR8:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00004024 "#ATOMOR8 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00004025 [(set GR8:$dst, (atomic_load_or_8 addr:$ptr, GR8:$val))]>;
Dale Johannesend20e4452008-08-19 18:47:28 +00004026def ATOMXOR8 : I<0, Pseudo,(outs GR8:$dst),(ins i8mem:$ptr, GR8:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00004027 "#ATOMXOR8 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00004028 [(set GR8:$dst, (atomic_load_xor_8 addr:$ptr, GR8:$val))]>;
Dale Johannesend20e4452008-08-19 18:47:28 +00004029def ATOMNAND8 : I<0, Pseudo,(outs GR8:$dst),(ins i8mem:$ptr, GR8:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00004030 "#ATOMNAND8 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00004031 [(set GR8:$dst, (atomic_load_nand_8 addr:$ptr, GR8:$val))]>;
Mon P Wang078a62d2008-05-05 19:05:59 +00004032}
4033
Dale Johannesenf160d802008-10-02 18:53:47 +00004034let Constraints = "$val1 = $dst1, $val2 = $dst2",
4035 Defs = [EFLAGS, EAX, EBX, ECX, EDX],
4036 Uses = [EAX, EBX, ECX, EDX],
Dale Johannesen44eb5372008-10-03 19:41:08 +00004037 mayLoad = 1, mayStore = 1,
Dan Gohman30afe012009-10-29 18:10:34 +00004038 usesCustomInserter = 1 in {
Dale Johannesenf160d802008-10-02 18:53:47 +00004039def ATOMAND6432 : I<0, Pseudo, (outs GR32:$dst1, GR32:$dst2),
4040 (ins i64mem:$ptr, GR32:$val1, GR32:$val2),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00004041 "#ATOMAND6432 PSEUDO!", []>;
Dale Johannesenf160d802008-10-02 18:53:47 +00004042def ATOMOR6432 : I<0, Pseudo, (outs GR32:$dst1, GR32:$dst2),
4043 (ins i64mem:$ptr, GR32:$val1, GR32:$val2),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00004044 "#ATOMOR6432 PSEUDO!", []>;
Dale Johannesenf160d802008-10-02 18:53:47 +00004045def ATOMXOR6432 : I<0, Pseudo, (outs GR32:$dst1, GR32:$dst2),
4046 (ins i64mem:$ptr, GR32:$val1, GR32:$val2),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00004047 "#ATOMXOR6432 PSEUDO!", []>;
Dale Johannesenf160d802008-10-02 18:53:47 +00004048def ATOMNAND6432 : I<0, Pseudo, (outs GR32:$dst1, GR32:$dst2),
4049 (ins i64mem:$ptr, GR32:$val1, GR32:$val2),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00004050 "#ATOMNAND6432 PSEUDO!", []>;
Dale Johannesenf160d802008-10-02 18:53:47 +00004051def ATOMADD6432 : I<0, Pseudo, (outs GR32:$dst1, GR32:$dst2),
4052 (ins i64mem:$ptr, GR32:$val1, GR32:$val2),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00004053 "#ATOMADD6432 PSEUDO!", []>;
Dale Johannesenf160d802008-10-02 18:53:47 +00004054def ATOMSUB6432 : I<0, Pseudo, (outs GR32:$dst1, GR32:$dst2),
4055 (ins i64mem:$ptr, GR32:$val1, GR32:$val2),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00004056 "#ATOMSUB6432 PSEUDO!", []>;
Dale Johannesen51c58ee2008-10-03 22:25:52 +00004057def ATOMSWAP6432 : I<0, Pseudo, (outs GR32:$dst1, GR32:$dst2),
4058 (ins i64mem:$ptr, GR32:$val1, GR32:$val2),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00004059 "#ATOMSWAP6432 PSEUDO!", []>;
Dale Johannesenf160d802008-10-02 18:53:47 +00004060}
4061
Sean Callanan2eddf5d2009-09-16 21:55:34 +00004062// Segmentation support instructions.
4063
4064def LAR16rm : I<0x02, MRMSrcMem, (outs GR16:$dst), (ins i16mem:$src),
4065 "lar{w}\t{$src, $dst|$dst, $src}", []>, TB, OpSize;
4066def LAR16rr : I<0x02, MRMSrcReg, (outs GR16:$dst), (ins GR16:$src),
4067 "lar{w}\t{$src, $dst|$dst, $src}", []>, TB, OpSize;
4068
4069// i16mem operand in LAR32rm and GR32 operand in LAR32rr is not a typo.
4070def LAR32rm : I<0x02, MRMSrcMem, (outs GR32:$dst), (ins i16mem:$src),
4071 "lar{l}\t{$src, $dst|$dst, $src}", []>, TB;
4072def LAR32rr : I<0x02, MRMSrcReg, (outs GR32:$dst), (ins GR32:$src),
4073 "lar{l}\t{$src, $dst|$dst, $src}", []>, TB;
Sean Callanan2c48df22009-12-18 00:01:26 +00004074
4075def LSL16rm : I<0x03, MRMSrcMem, (outs GR16:$dst), (ins i16mem:$src),
4076 "lsl{w}\t{$src, $dst|$dst, $src}", []>, TB, OpSize;
4077def LSL16rr : I<0x03, MRMSrcReg, (outs GR16:$dst), (ins GR16:$src),
4078 "lsl{w}\t{$src, $dst|$dst, $src}", []>, TB, OpSize;
4079def LSL32rm : I<0x03, MRMSrcMem, (outs GR32:$dst), (ins i32mem:$src),
4080 "lsl{l}\t{$src, $dst|$dst, $src}", []>, TB;
4081def LSL32rr : I<0x03, MRMSrcReg, (outs GR32:$dst), (ins GR32:$src),
4082 "lsl{l}\t{$src, $dst|$dst, $src}", []>, TB;
4083
4084def INVLPG : I<0x01, RawFrm, (outs), (ins), "invlpg", []>, TB;
4085
4086def STRr : I<0x00, MRM1r, (outs GR16:$dst), (ins),
4087 "str{w}\t{$dst}", []>, TB;
4088def STRm : I<0x00, MRM1m, (outs i16mem:$dst), (ins),
4089 "str{w}\t{$dst}", []>, TB;
4090def LTRr : I<0x00, MRM3r, (outs), (ins GR16:$src),
4091 "ltr{w}\t{$src}", []>, TB;
4092def LTRm : I<0x00, MRM3m, (outs), (ins i16mem:$src),
4093 "ltr{w}\t{$src}", []>, TB;
4094
4095def PUSHFS16 : I<0xa0, RawFrm, (outs), (ins),
4096 "push{w}\t%fs", []>, OpSize, TB;
4097def PUSHFS32 : I<0xa0, RawFrm, (outs), (ins),
4098 "push{l}\t%fs", []>, TB;
4099def PUSHGS16 : I<0xa8, RawFrm, (outs), (ins),
4100 "push{w}\t%gs", []>, OpSize, TB;
4101def PUSHGS32 : I<0xa8, RawFrm, (outs), (ins),
4102 "push{l}\t%gs", []>, TB;
4103
4104def POPFS16 : I<0xa1, RawFrm, (outs), (ins),
4105 "pop{w}\t%fs", []>, OpSize, TB;
4106def POPFS32 : I<0xa1, RawFrm, (outs), (ins),
4107 "pop{l}\t%fs", []>, TB;
4108def POPGS16 : I<0xa9, RawFrm, (outs), (ins),
4109 "pop{w}\t%gs", []>, OpSize, TB;
4110def POPGS32 : I<0xa9, RawFrm, (outs), (ins),
4111 "pop{l}\t%gs", []>, TB;
4112
4113def LDS16rm : I<0xc5, MRMSrcMem, (outs GR16:$dst), (ins opaque32mem:$src),
4114 "lds{w}\t{$src, $dst|$dst, $src}", []>, OpSize;
4115def LDS32rm : I<0xc5, MRMSrcMem, (outs GR32:$dst), (ins opaque48mem:$src),
4116 "lds{l}\t{$src, $dst|$dst, $src}", []>;
4117def LSS16rm : I<0xb2, MRMSrcMem, (outs GR16:$dst), (ins opaque32mem:$src),
4118 "lss{w}\t{$src, $dst|$dst, $src}", []>, TB, OpSize;
4119def LSS32rm : I<0xb2, MRMSrcMem, (outs GR32:$dst), (ins opaque48mem:$src),
4120 "lss{l}\t{$src, $dst|$dst, $src}", []>, TB;
4121def LES16rm : I<0xc4, MRMSrcMem, (outs GR16:$dst), (ins opaque32mem:$src),
4122 "les{w}\t{$src, $dst|$dst, $src}", []>, OpSize;
4123def LES32rm : I<0xc4, MRMSrcMem, (outs GR32:$dst), (ins opaque48mem:$src),
4124 "les{l}\t{$src, $dst|$dst, $src}", []>;
4125def LFS16rm : I<0xb4, MRMSrcMem, (outs GR16:$dst), (ins opaque32mem:$src),
4126 "lfs{w}\t{$src, $dst|$dst, $src}", []>, TB, OpSize;
4127def LFS32rm : I<0xb4, MRMSrcMem, (outs GR32:$dst), (ins opaque48mem:$src),
4128 "lfs{l}\t{$src, $dst|$dst, $src}", []>, TB;
4129def LGS16rm : I<0xb5, MRMSrcMem, (outs GR16:$dst), (ins opaque32mem:$src),
4130 "lgs{w}\t{$src, $dst|$dst, $src}", []>, TB, OpSize;
4131def LGS32rm : I<0xb5, MRMSrcMem, (outs GR32:$dst), (ins opaque48mem:$src),
4132 "lgs{l}\t{$src, $dst|$dst, $src}", []>, TB;
4133
4134def VERRr : I<0x00, MRM4r, (outs), (ins GR16:$seg),
4135 "verr\t$seg", []>, TB;
4136def VERRm : I<0x00, MRM4m, (outs), (ins i16mem:$seg),
4137 "verr\t$seg", []>, TB;
4138def VERWr : I<0x00, MRM5r, (outs), (ins GR16:$seg),
4139 "verw\t$seg", []>, TB;
4140def VERWm : I<0x00, MRM5m, (outs), (ins i16mem:$seg),
4141 "verw\t$seg", []>, TB;
4142
4143// Descriptor-table support instructions
4144
4145def SGDTm : I<0x01, MRM0m, (outs opaque48mem:$dst), (ins),
4146 "sgdt\t$dst", []>, TB;
4147def SIDTm : I<0x01, MRM1m, (outs opaque48mem:$dst), (ins),
4148 "sidt\t$dst", []>, TB;
4149def SLDT16r : I<0x00, MRM0r, (outs GR16:$dst), (ins),
4150 "sldt{w}\t$dst", []>, TB;
4151def SLDT16m : I<0x00, MRM0m, (outs i16mem:$dst), (ins),
4152 "sldt{w}\t$dst", []>, TB;
4153def LGDTm : I<0x01, MRM2m, (outs), (ins opaque48mem:$src),
4154 "lgdt\t$src", []>, TB;
4155def LIDTm : I<0x01, MRM3m, (outs), (ins opaque48mem:$src),
4156 "lidt\t$src", []>, TB;
4157def LLDT16r : I<0x00, MRM2r, (outs), (ins GR16:$src),
4158 "lldt{w}\t$src", []>, TB;
4159def LLDT16m : I<0x00, MRM2m, (outs), (ins i16mem:$src),
4160 "lldt{w}\t$src", []>, TB;
Sean Callanan23f33d72009-09-16 22:59:28 +00004161
4162// String manipulation instructions
4163
4164def LODSB : I<0xAC, RawFrm, (outs), (ins), "lodsb", []>;
4165def LODSW : I<0xAD, RawFrm, (outs), (ins), "lodsw", []>, OpSize;
Sean Callanan2c48df22009-12-18 00:01:26 +00004166def LODSD : I<0xAD, RawFrm, (outs), (ins), "lods{l|d}", []>;
4167
4168def OUTSB : I<0x6E, RawFrm, (outs), (ins), "outsb", []>;
4169def OUTSW : I<0x6F, RawFrm, (outs), (ins), "outsw", []>, OpSize;
4170def OUTSD : I<0x6F, RawFrm, (outs), (ins), "outs{l|d}", []>;
4171
4172// CPU flow control instructions
4173
4174def HLT : I<0xF4, RawFrm, (outs), (ins), "hlt", []>;
4175def RSM : I<0xAA, RawFrm, (outs), (ins), "rsm", []>, TB;
4176
4177// FPU control instructions
4178
4179def FNINIT : I<0xE3, RawFrm, (outs), (ins), "fninit", []>, DB;
4180
4181// Flag instructions
4182
4183def CLC : I<0xF8, RawFrm, (outs), (ins), "clc", []>;
4184def STC : I<0xF9, RawFrm, (outs), (ins), "stc", []>;
4185def CLI : I<0xFA, RawFrm, (outs), (ins), "cli", []>;
4186def STI : I<0xFB, RawFrm, (outs), (ins), "sti", []>;
4187def CLD : I<0xFC, RawFrm, (outs), (ins), "cld", []>;
4188def STD : I<0xFD, RawFrm, (outs), (ins), "std", []>;
4189def CMC : I<0xF5, RawFrm, (outs), (ins), "cmc", []>;
4190
4191def CLTS : I<0x06, RawFrm, (outs), (ins), "clts", []>, TB;
4192
4193// Table lookup instructions
4194
4195def XLAT : I<0xD7, RawFrm, (outs), (ins), "xlatb", []>;
4196
4197// Specialized register support
4198
4199def WRMSR : I<0x30, RawFrm, (outs), (ins), "wrmsr", []>, TB;
4200def RDMSR : I<0x32, RawFrm, (outs), (ins), "rdmsr", []>, TB;
4201def RDPMC : I<0x33, RawFrm, (outs), (ins), "rdpmc", []>, TB;
4202
4203def SMSW16r : I<0x01, MRM4r, (outs GR16:$dst), (ins),
4204 "smsw{w}\t$dst", []>, OpSize, TB;
4205def SMSW32r : I<0x01, MRM4r, (outs GR32:$dst), (ins),
4206 "smsw{l}\t$dst", []>, TB;
4207// For memory operands, there is only a 16-bit form
4208def SMSW16m : I<0x01, MRM4m, (outs i16mem:$dst), (ins),
4209 "smsw{w}\t$dst", []>, TB;
4210
4211def LMSW16r : I<0x01, MRM6r, (outs), (ins GR16:$src),
4212 "lmsw{w}\t$src", []>, TB;
4213def LMSW16m : I<0x01, MRM6m, (outs), (ins i16mem:$src),
4214 "lmsw{w}\t$src", []>, TB;
4215
4216def CPUID : I<0xA2, RawFrm, (outs), (ins), "cpuid", []>, TB;
4217
4218// Cache instructions
4219
4220def INVD : I<0x08, RawFrm, (outs), (ins), "invd", []>, TB;
4221def WBINVD : I<0x09, RawFrm, (outs), (ins), "wbinvd", []>, TB;
4222
4223// VMX instructions
4224
4225// 66 0F 38 80
4226def INVEPT : I<0x38, RawFrm, (outs), (ins), "invept", []>, OpSize, TB;
4227// 66 0F 38 81
4228def INVVPID : I<0x38, RawFrm, (outs), (ins), "invvpid", []>, OpSize, TB;
4229// 0F 01 C1
4230def VMCALL : I<0x01, RawFrm, (outs), (ins), "vmcall", []>, TB;
4231def VMCLEARm : I<0xC7, MRM6m, (outs), (ins i64mem:$vmcs),
4232 "vmclear\t$vmcs", []>, OpSize, TB;
4233// 0F 01 C2
4234def VMLAUNCH : I<0x01, RawFrm, (outs), (ins), "vmlaunch", []>, TB;
4235// 0F 01 C3
4236def VMRESUME : I<0x01, RawFrm, (outs), (ins), "vmresume", []>, TB;
4237def VMPTRLDm : I<0xC7, MRM6m, (outs), (ins i64mem:$vmcs),
4238 "vmptrld\t$vmcs", []>, TB;
4239def VMPTRSTm : I<0xC7, MRM7m, (outs i64mem:$vmcs), (ins),
4240 "vmptrst\t$vmcs", []>, TB;
4241def VMREAD64rm : I<0x78, MRMDestMem, (outs i64mem:$dst), (ins GR64:$src),
4242 "vmread{q}\t{$src, $dst|$dst, $src}", []>, TB;
4243def VMREAD64rr : I<0x78, MRMDestReg, (outs GR64:$dst), (ins GR64:$src),
4244 "vmread{q}\t{$src, $dst|$dst, $src}", []>, TB;
4245def VMREAD32rm : I<0x78, MRMDestMem, (outs i32mem:$dst), (ins GR32:$src),
4246 "vmread{l}\t{$src, $dst|$dst, $src}", []>, TB;
4247def VMREAD32rr : I<0x78, MRMDestReg, (outs GR32:$dst), (ins GR32:$src),
4248 "vmread{l}\t{$src, $dst|$dst, $src}", []>, TB;
4249def VMWRITE64rm : I<0x79, MRMSrcMem, (outs GR64:$dst), (ins i64mem:$src),
4250 "vmwrite{q}\t{$src, $dst|$dst, $src}", []>, TB;
4251def VMWRITE64rr : I<0x79, MRMSrcReg, (outs GR64:$dst), (ins GR64:$src),
4252 "vmwrite{q}\t{$src, $dst|$dst, $src}", []>, TB;
4253def VMWRITE32rm : I<0x79, MRMSrcMem, (outs GR32:$dst), (ins i32mem:$src),
4254 "vmwrite{l}\t{$src, $dst|$dst, $src}", []>, TB;
4255def VMWRITE32rr : I<0x79, MRMSrcReg, (outs GR32:$dst), (ins GR32:$src),
4256 "vmwrite{l}\t{$src, $dst|$dst, $src}", []>, TB;
4257// 0F 01 C4
4258def VMXOFF : I<0x01, RawFrm, (outs), (ins), "vmxoff", []>, OpSize;
4259def VMXON : I<0xC7, MRM6m, (outs), (ins i64mem:$vmxon),
4260 "vmxon\t{$vmxon}", []>, XD;
Sean Callanan2eddf5d2009-09-16 21:55:34 +00004261
Andrew Lenharthe44f3902008-02-21 06:45:13 +00004262//===----------------------------------------------------------------------===//
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004263// Non-Instruction Patterns
4264//===----------------------------------------------------------------------===//
4265
Bill Wendlingfef06052008-09-16 21:48:12 +00004266// ConstantPool GlobalAddress, ExternalSymbol, and JumpTable
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004267def : Pat<(i32 (X86Wrapper tconstpool :$dst)), (MOV32ri tconstpool :$dst)>;
4268def : Pat<(i32 (X86Wrapper tjumptable :$dst)), (MOV32ri tjumptable :$dst)>;
Nate Begemanb52948972008-04-12 00:47:57 +00004269def : Pat<(i32 (X86Wrapper tglobaltlsaddr:$dst)),(MOV32ri tglobaltlsaddr:$dst)>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004270def : Pat<(i32 (X86Wrapper tglobaladdr :$dst)), (MOV32ri tglobaladdr :$dst)>;
4271def : Pat<(i32 (X86Wrapper texternalsym:$dst)), (MOV32ri texternalsym:$dst)>;
Dan Gohman064403e2009-10-30 01:28:02 +00004272def : Pat<(i32 (X86Wrapper tblockaddress:$dst)), (MOV32ri tblockaddress:$dst)>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004273
4274def : Pat<(add GR32:$src1, (X86Wrapper tconstpool:$src2)),
4275 (ADD32ri GR32:$src1, tconstpool:$src2)>;
4276def : Pat<(add GR32:$src1, (X86Wrapper tjumptable:$src2)),
4277 (ADD32ri GR32:$src1, tjumptable:$src2)>;
4278def : Pat<(add GR32:$src1, (X86Wrapper tglobaladdr :$src2)),
4279 (ADD32ri GR32:$src1, tglobaladdr:$src2)>;
4280def : Pat<(add GR32:$src1, (X86Wrapper texternalsym:$src2)),
4281 (ADD32ri GR32:$src1, texternalsym:$src2)>;
Dan Gohman064403e2009-10-30 01:28:02 +00004282def : Pat<(add GR32:$src1, (X86Wrapper tblockaddress:$src2)),
4283 (ADD32ri GR32:$src1, tblockaddress:$src2)>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004284
4285def : Pat<(store (i32 (X86Wrapper tglobaladdr:$src)), addr:$dst),
4286 (MOV32mi addr:$dst, tglobaladdr:$src)>;
4287def : Pat<(store (i32 (X86Wrapper texternalsym:$src)), addr:$dst),
4288 (MOV32mi addr:$dst, texternalsym:$src)>;
Dan Gohman064403e2009-10-30 01:28:02 +00004289def : Pat<(store (i32 (X86Wrapper tblockaddress:$src)), addr:$dst),
4290 (MOV32mi addr:$dst, tblockaddress:$src)>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004291
4292// Calls
Arnold Schwaighofere2d6bbb2007-10-11 19:40:01 +00004293// tailcall stuff
Arnold Schwaighofere2d6bbb2007-10-11 19:40:01 +00004294def : Pat<(X86tcret GR32:$dst, imm:$off),
4295 (TCRETURNri GR32:$dst, imm:$off)>;
4296
4297def : Pat<(X86tcret (i32 tglobaladdr:$dst), imm:$off),
4298 (TCRETURNdi texternalsym:$dst, imm:$off)>;
4299
4300def : Pat<(X86tcret (i32 texternalsym:$dst), imm:$off),
4301 (TCRETURNdi texternalsym:$dst, imm:$off)>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004302
Dan Gohmance5dbff2009-08-02 16:10:01 +00004303// Normal calls, with various flavors of addresses.
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004304def : Pat<(X86call (i32 tglobaladdr:$dst)),
4305 (CALLpcrel32 tglobaladdr:$dst)>;
4306def : Pat<(X86call (i32 texternalsym:$dst)),
4307 (CALLpcrel32 texternalsym:$dst)>;
Evan Cheng6d35a4d2009-05-20 04:53:57 +00004308def : Pat<(X86call (i32 imm:$dst)),
4309 (CALLpcrel32 imm:$dst)>, Requires<[CallImmAddr]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004310
4311// X86 specific add which produces a flag.
4312def : Pat<(addc GR32:$src1, GR32:$src2),
4313 (ADD32rr GR32:$src1, GR32:$src2)>;
4314def : Pat<(addc GR32:$src1, (load addr:$src2)),
4315 (ADD32rm GR32:$src1, addr:$src2)>;
4316def : Pat<(addc GR32:$src1, imm:$src2),
4317 (ADD32ri GR32:$src1, imm:$src2)>;
4318def : Pat<(addc GR32:$src1, i32immSExt8:$src2),
4319 (ADD32ri8 GR32:$src1, i32immSExt8:$src2)>;
4320
4321def : Pat<(subc GR32:$src1, GR32:$src2),
4322 (SUB32rr GR32:$src1, GR32:$src2)>;
4323def : Pat<(subc GR32:$src1, (load addr:$src2)),
4324 (SUB32rm GR32:$src1, addr:$src2)>;
4325def : Pat<(subc GR32:$src1, imm:$src2),
4326 (SUB32ri GR32:$src1, imm:$src2)>;
4327def : Pat<(subc GR32:$src1, i32immSExt8:$src2),
4328 (SUB32ri8 GR32:$src1, i32immSExt8:$src2)>;
4329
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004330// Comparisons.
4331
4332// TEST R,R is smaller than CMP R,0
Evan Cheng621216e2007-09-29 00:00:36 +00004333def : Pat<(parallel (X86cmp GR8:$src1, 0), (implicit EFLAGS)),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004334 (TEST8rr GR8:$src1, GR8:$src1)>;
Evan Cheng621216e2007-09-29 00:00:36 +00004335def : Pat<(parallel (X86cmp GR16:$src1, 0), (implicit EFLAGS)),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004336 (TEST16rr GR16:$src1, GR16:$src1)>;
Evan Cheng621216e2007-09-29 00:00:36 +00004337def : Pat<(parallel (X86cmp GR32:$src1, 0), (implicit EFLAGS)),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004338 (TEST32rr GR32:$src1, GR32:$src1)>;
4339
Dan Gohman0a3c5222009-01-07 01:00:24 +00004340// Conditional moves with folded loads with operands swapped and conditions
4341// inverted.
4342def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_B, EFLAGS),
4343 (CMOVAE16rm GR16:$src2, addr:$src1)>;
4344def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_B, EFLAGS),
4345 (CMOVAE32rm GR32:$src2, addr:$src1)>;
4346def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_AE, EFLAGS),
4347 (CMOVB16rm GR16:$src2, addr:$src1)>;
4348def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_AE, EFLAGS),
4349 (CMOVB32rm GR32:$src2, addr:$src1)>;
4350def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_E, EFLAGS),
4351 (CMOVNE16rm GR16:$src2, addr:$src1)>;
4352def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_E, EFLAGS),
4353 (CMOVNE32rm GR32:$src2, addr:$src1)>;
4354def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_NE, EFLAGS),
4355 (CMOVE16rm GR16:$src2, addr:$src1)>;
4356def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_NE, EFLAGS),
4357 (CMOVE32rm GR32:$src2, addr:$src1)>;
4358def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_BE, EFLAGS),
4359 (CMOVA16rm GR16:$src2, addr:$src1)>;
4360def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_BE, EFLAGS),
4361 (CMOVA32rm GR32:$src2, addr:$src1)>;
4362def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_A, EFLAGS),
4363 (CMOVBE16rm GR16:$src2, addr:$src1)>;
4364def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_A, EFLAGS),
4365 (CMOVBE32rm GR32:$src2, addr:$src1)>;
4366def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_L, EFLAGS),
4367 (CMOVGE16rm GR16:$src2, addr:$src1)>;
4368def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_L, EFLAGS),
4369 (CMOVGE32rm GR32:$src2, addr:$src1)>;
4370def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_GE, EFLAGS),
4371 (CMOVL16rm GR16:$src2, addr:$src1)>;
4372def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_GE, EFLAGS),
4373 (CMOVL32rm GR32:$src2, addr:$src1)>;
4374def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_LE, EFLAGS),
4375 (CMOVG16rm GR16:$src2, addr:$src1)>;
4376def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_LE, EFLAGS),
4377 (CMOVG32rm GR32:$src2, addr:$src1)>;
4378def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_G, EFLAGS),
4379 (CMOVLE16rm GR16:$src2, addr:$src1)>;
4380def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_G, EFLAGS),
4381 (CMOVLE32rm GR32:$src2, addr:$src1)>;
4382def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_P, EFLAGS),
4383 (CMOVNP16rm GR16:$src2, addr:$src1)>;
4384def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_P, EFLAGS),
4385 (CMOVNP32rm GR32:$src2, addr:$src1)>;
4386def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_NP, EFLAGS),
4387 (CMOVP16rm GR16:$src2, addr:$src1)>;
4388def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_NP, EFLAGS),
4389 (CMOVP32rm GR32:$src2, addr:$src1)>;
4390def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_S, EFLAGS),
4391 (CMOVNS16rm GR16:$src2, addr:$src1)>;
4392def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_S, EFLAGS),
4393 (CMOVNS32rm GR32:$src2, addr:$src1)>;
4394def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_NS, EFLAGS),
4395 (CMOVS16rm GR16:$src2, addr:$src1)>;
4396def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_NS, EFLAGS),
4397 (CMOVS32rm GR32:$src2, addr:$src1)>;
4398def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_O, EFLAGS),
4399 (CMOVNO16rm GR16:$src2, addr:$src1)>;
4400def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_O, EFLAGS),
4401 (CMOVNO32rm GR32:$src2, addr:$src1)>;
4402def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_NO, EFLAGS),
4403 (CMOVO16rm GR16:$src2, addr:$src1)>;
4404def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_NO, EFLAGS),
4405 (CMOVO32rm GR32:$src2, addr:$src1)>;
4406
Duncan Sands082524c2008-01-23 20:39:46 +00004407// zextload bool -> zextload byte
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004408def : Pat<(zextloadi8i1 addr:$src), (MOV8rm addr:$src)>;
4409def : Pat<(zextloadi16i1 addr:$src), (MOVZX16rm8 addr:$src)>;
4410def : Pat<(zextloadi32i1 addr:$src), (MOVZX32rm8 addr:$src)>;
4411
4412// extload bool -> extload byte
4413def : Pat<(extloadi8i1 addr:$src), (MOV8rm addr:$src)>;
Dan Gohman9959b052009-08-26 14:59:13 +00004414def : Pat<(extloadi16i1 addr:$src), (MOVZX16rm8 addr:$src)>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004415def : Pat<(extloadi32i1 addr:$src), (MOVZX32rm8 addr:$src)>;
Dan Gohman9959b052009-08-26 14:59:13 +00004416def : Pat<(extloadi16i8 addr:$src), (MOVZX16rm8 addr:$src)>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004417def : Pat<(extloadi32i8 addr:$src), (MOVZX32rm8 addr:$src)>;
4418def : Pat<(extloadi32i16 addr:$src), (MOVZX32rm16 addr:$src)>;
4419
Dan Gohman9959b052009-08-26 14:59:13 +00004420// anyext. Define these to do an explicit zero-extend to
4421// avoid partial-register updates.
4422def : Pat<(i16 (anyext GR8 :$src)), (MOVZX16rr8 GR8 :$src)>;
4423def : Pat<(i32 (anyext GR8 :$src)), (MOVZX32rr8 GR8 :$src)>;
4424def : Pat<(i32 (anyext GR16:$src)), (MOVZX32rr16 GR16:$src)>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004425
Evan Chengf2abee72007-12-13 00:43:27 +00004426// (and (i32 load), 255) -> (zextload i8)
Evan Cheng1e5e5452008-09-29 17:26:18 +00004427def : Pat<(i32 (and (nvloadi32 addr:$src), (i32 255))),
4428 (MOVZX32rm8 addr:$src)>;
4429def : Pat<(i32 (and (nvloadi32 addr:$src), (i32 65535))),
4430 (MOVZX32rm16 addr:$src)>;
Evan Chengf2abee72007-12-13 00:43:27 +00004431
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004432//===----------------------------------------------------------------------===//
4433// Some peepholes
4434//===----------------------------------------------------------------------===//
4435
Dan Gohman5a5e6e92008-10-17 01:33:43 +00004436// Odd encoding trick: -128 fits into an 8-bit immediate field while
4437// +128 doesn't, so in this special case use a sub instead of an add.
4438def : Pat<(add GR16:$src1, 128),
4439 (SUB16ri8 GR16:$src1, -128)>;
4440def : Pat<(store (add (loadi16 addr:$dst), 128), addr:$dst),
4441 (SUB16mi8 addr:$dst, -128)>;
4442def : Pat<(add GR32:$src1, 128),
4443 (SUB32ri8 GR32:$src1, -128)>;
4444def : Pat<(store (add (loadi32 addr:$dst), 128), addr:$dst),
4445 (SUB32mi8 addr:$dst, -128)>;
4446
Dan Gohman9203ab42008-07-30 18:09:17 +00004447// r & (2^16-1) ==> movz
4448def : Pat<(and GR32:$src1, 0xffff),
Dan Gohman744d4622009-04-13 16:09:41 +00004449 (MOVZX32rr16 (EXTRACT_SUBREG GR32:$src1, x86_subreg_16bit))>;
Dan Gohman5beb1ff2008-08-06 18:27:21 +00004450// r & (2^8-1) ==> movz
4451def : Pat<(and GR32:$src1, 0xff),
Anton Korobeynikovd9331212009-11-02 00:11:39 +00004452 (MOVZX32rr8 (EXTRACT_SUBREG (i32 (COPY_TO_REGCLASS GR32:$src1,
4453 GR32_ABCD)),
Dan Gohman744d4622009-04-13 16:09:41 +00004454 x86_subreg_8bit))>,
Dan Gohman5beb1ff2008-08-06 18:27:21 +00004455 Requires<[In32BitMode]>;
4456// r & (2^8-1) ==> movz
4457def : Pat<(and GR16:$src1, 0xff),
Anton Korobeynikovd9331212009-11-02 00:11:39 +00004458 (MOVZX16rr8 (EXTRACT_SUBREG (i16 (COPY_TO_REGCLASS GR16:$src1,
4459 GR16_ABCD)),
Dan Gohman744d4622009-04-13 16:09:41 +00004460 x86_subreg_8bit))>,
Dan Gohmandd612bb2008-08-20 21:27:32 +00004461 Requires<[In32BitMode]>;
4462
4463// sext_inreg patterns
4464def : Pat<(sext_inreg GR32:$src, i16),
Dan Gohman744d4622009-04-13 16:09:41 +00004465 (MOVSX32rr16 (EXTRACT_SUBREG GR32:$src, x86_subreg_16bit))>;
Dan Gohmandd612bb2008-08-20 21:27:32 +00004466def : Pat<(sext_inreg GR32:$src, i8),
Anton Korobeynikovd9331212009-11-02 00:11:39 +00004467 (MOVSX32rr8 (EXTRACT_SUBREG (i32 (COPY_TO_REGCLASS GR32:$src,
4468 GR32_ABCD)),
Dan Gohman744d4622009-04-13 16:09:41 +00004469 x86_subreg_8bit))>,
Dan Gohmandd612bb2008-08-20 21:27:32 +00004470 Requires<[In32BitMode]>;
4471def : Pat<(sext_inreg GR16:$src, i8),
Anton Korobeynikovd9331212009-11-02 00:11:39 +00004472 (MOVSX16rr8 (EXTRACT_SUBREG (i16 (COPY_TO_REGCLASS GR16:$src,
4473 GR16_ABCD)),
Dan Gohman744d4622009-04-13 16:09:41 +00004474 x86_subreg_8bit))>,
Dan Gohmandd612bb2008-08-20 21:27:32 +00004475 Requires<[In32BitMode]>;
4476
4477// trunc patterns
4478def : Pat<(i16 (trunc GR32:$src)),
Dan Gohman744d4622009-04-13 16:09:41 +00004479 (EXTRACT_SUBREG GR32:$src, x86_subreg_16bit)>;
Dan Gohmandd612bb2008-08-20 21:27:32 +00004480def : Pat<(i8 (trunc GR32:$src)),
Anton Korobeynikovd9331212009-11-02 00:11:39 +00004481 (EXTRACT_SUBREG (i32 (COPY_TO_REGCLASS GR32:$src, GR32_ABCD)),
Dan Gohman744d4622009-04-13 16:09:41 +00004482 x86_subreg_8bit)>,
Dan Gohmandd612bb2008-08-20 21:27:32 +00004483 Requires<[In32BitMode]>;
4484def : Pat<(i8 (trunc GR16:$src)),
Anton Korobeynikovd9331212009-11-02 00:11:39 +00004485 (EXTRACT_SUBREG (i16 (COPY_TO_REGCLASS GR16:$src, GR16_ABCD)),
Dan Gohman744d4622009-04-13 16:09:41 +00004486 x86_subreg_8bit)>,
4487 Requires<[In32BitMode]>;
4488
4489// h-register tricks
4490def : Pat<(i8 (trunc (srl_su GR16:$src, (i8 8)))),
Anton Korobeynikovd9331212009-11-02 00:11:39 +00004491 (EXTRACT_SUBREG (i32 (COPY_TO_REGCLASS GR16:$src, GR16_ABCD)),
Dan Gohman744d4622009-04-13 16:09:41 +00004492 x86_subreg_8bit_hi)>,
4493 Requires<[In32BitMode]>;
4494def : Pat<(i8 (trunc (srl_su GR32:$src, (i8 8)))),
Anton Korobeynikovd9331212009-11-02 00:11:39 +00004495 (EXTRACT_SUBREG (i16 (COPY_TO_REGCLASS GR32:$src, GR32_ABCD)),
Dan Gohman744d4622009-04-13 16:09:41 +00004496 x86_subreg_8bit_hi)>,
4497 Requires<[In32BitMode]>;
Dan Gohman5d8f9df2010-01-11 17:21:05 +00004498def : Pat<(srl GR16:$src, (i8 8)),
Dan Gohman744d4622009-04-13 16:09:41 +00004499 (EXTRACT_SUBREG
4500 (MOVZX32rr8
Anton Korobeynikovd9331212009-11-02 00:11:39 +00004501 (EXTRACT_SUBREG (i16 (COPY_TO_REGCLASS GR16:$src, GR16_ABCD)),
Dan Gohman744d4622009-04-13 16:09:41 +00004502 x86_subreg_8bit_hi)),
4503 x86_subreg_16bit)>,
4504 Requires<[In32BitMode]>;
Evan Cheng957ca282009-05-29 01:44:43 +00004505def : Pat<(i32 (zext (srl_su GR16:$src, (i8 8)))),
Sean Callanan2c48df22009-12-18 00:01:26 +00004506 (MOVZX32rr8 (EXTRACT_SUBREG (i16 (COPY_TO_REGCLASS GR16:$src,
4507 GR16_ABCD)),
Evan Cheng957ca282009-05-29 01:44:43 +00004508 x86_subreg_8bit_hi))>,
4509 Requires<[In32BitMode]>;
Dan Gohman9959b052009-08-26 14:59:13 +00004510def : Pat<(i32 (anyext (srl_su GR16:$src, (i8 8)))),
Sean Callanan2c48df22009-12-18 00:01:26 +00004511 (MOVZX32rr8 (EXTRACT_SUBREG (i16 (COPY_TO_REGCLASS GR16:$src,
4512 GR16_ABCD)),
Dan Gohman9959b052009-08-26 14:59:13 +00004513 x86_subreg_8bit_hi))>,
4514 Requires<[In32BitMode]>;
Dan Gohman744d4622009-04-13 16:09:41 +00004515def : Pat<(and (srl_su GR32:$src, (i8 8)), (i32 255)),
Sean Callanan2c48df22009-12-18 00:01:26 +00004516 (MOVZX32rr8 (EXTRACT_SUBREG (i32 (COPY_TO_REGCLASS GR32:$src,
4517 GR32_ABCD)),
Dan Gohman744d4622009-04-13 16:09:41 +00004518 x86_subreg_8bit_hi))>,
Dan Gohman5beb1ff2008-08-06 18:27:21 +00004519 Requires<[In32BitMode]>;
Dan Gohman9203ab42008-07-30 18:09:17 +00004520
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004521// (shl x, 1) ==> (add x, x)
4522def : Pat<(shl GR8 :$src1, (i8 1)), (ADD8rr GR8 :$src1, GR8 :$src1)>;
4523def : Pat<(shl GR16:$src1, (i8 1)), (ADD16rr GR16:$src1, GR16:$src1)>;
4524def : Pat<(shl GR32:$src1, (i8 1)), (ADD32rr GR32:$src1, GR32:$src1)>;
4525
Evan Cheng76a64c72008-08-30 02:03:58 +00004526// (shl x (and y, 31)) ==> (shl x, y)
4527def : Pat<(shl GR8:$src1, (and CL:$amt, 31)),
4528 (SHL8rCL GR8:$src1)>;
4529def : Pat<(shl GR16:$src1, (and CL:$amt, 31)),
4530 (SHL16rCL GR16:$src1)>;
4531def : Pat<(shl GR32:$src1, (and CL:$amt, 31)),
4532 (SHL32rCL GR32:$src1)>;
4533def : Pat<(store (shl (loadi8 addr:$dst), (and CL:$amt, 31)), addr:$dst),
4534 (SHL8mCL addr:$dst)>;
4535def : Pat<(store (shl (loadi16 addr:$dst), (and CL:$amt, 31)), addr:$dst),
4536 (SHL16mCL addr:$dst)>;
4537def : Pat<(store (shl (loadi32 addr:$dst), (and CL:$amt, 31)), addr:$dst),
4538 (SHL32mCL addr:$dst)>;
4539
4540def : Pat<(srl GR8:$src1, (and CL:$amt, 31)),
4541 (SHR8rCL GR8:$src1)>;
4542def : Pat<(srl GR16:$src1, (and CL:$amt, 31)),
4543 (SHR16rCL GR16:$src1)>;
4544def : Pat<(srl GR32:$src1, (and CL:$amt, 31)),
4545 (SHR32rCL GR32:$src1)>;
4546def : Pat<(store (srl (loadi8 addr:$dst), (and CL:$amt, 31)), addr:$dst),
4547 (SHR8mCL addr:$dst)>;
4548def : Pat<(store (srl (loadi16 addr:$dst), (and CL:$amt, 31)), addr:$dst),
4549 (SHR16mCL addr:$dst)>;
4550def : Pat<(store (srl (loadi32 addr:$dst), (and CL:$amt, 31)), addr:$dst),
4551 (SHR32mCL addr:$dst)>;
4552
4553def : Pat<(sra GR8:$src1, (and CL:$amt, 31)),
4554 (SAR8rCL GR8:$src1)>;
4555def : Pat<(sra GR16:$src1, (and CL:$amt, 31)),
4556 (SAR16rCL GR16:$src1)>;
4557def : Pat<(sra GR32:$src1, (and CL:$amt, 31)),
4558 (SAR32rCL GR32:$src1)>;
4559def : Pat<(store (sra (loadi8 addr:$dst), (and CL:$amt, 31)), addr:$dst),
4560 (SAR8mCL addr:$dst)>;
4561def : Pat<(store (sra (loadi16 addr:$dst), (and CL:$amt, 31)), addr:$dst),
4562 (SAR16mCL addr:$dst)>;
4563def : Pat<(store (sra (loadi32 addr:$dst), (and CL:$amt, 31)), addr:$dst),
4564 (SAR32mCL addr:$dst)>;
4565
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004566// (or (x >> c) | (y << (32 - c))) ==> (shrd32 x, y, c)
4567def : Pat<(or (srl GR32:$src1, CL:$amt),
4568 (shl GR32:$src2, (sub 32, CL:$amt))),
4569 (SHRD32rrCL GR32:$src1, GR32:$src2)>;
4570
4571def : Pat<(store (or (srl (loadi32 addr:$dst), CL:$amt),
4572 (shl GR32:$src2, (sub 32, CL:$amt))), addr:$dst),
4573 (SHRD32mrCL addr:$dst, GR32:$src2)>;
4574
Dan Gohman921581d2008-10-17 01:23:35 +00004575def : Pat<(or (srl GR32:$src1, (i8 (trunc ECX:$amt))),
4576 (shl GR32:$src2, (i8 (trunc (sub 32, ECX:$amt))))),
4577 (SHRD32rrCL GR32:$src1, GR32:$src2)>;
4578
4579def : Pat<(store (or (srl (loadi32 addr:$dst), (i8 (trunc ECX:$amt))),
4580 (shl GR32:$src2, (i8 (trunc (sub 32, ECX:$amt))))),
4581 addr:$dst),
4582 (SHRD32mrCL addr:$dst, GR32:$src2)>;
4583
4584def : Pat<(shrd GR32:$src1, (i8 imm:$amt1), GR32:$src2, (i8 imm:$amt2)),
4585 (SHRD32rri8 GR32:$src1, GR32:$src2, (i8 imm:$amt1))>;
4586
4587def : Pat<(store (shrd (loadi32 addr:$dst), (i8 imm:$amt1),
4588 GR32:$src2, (i8 imm:$amt2)), addr:$dst),
4589 (SHRD32mri8 addr:$dst, GR32:$src2, (i8 imm:$amt1))>;
4590
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004591// (or (x << c) | (y >> (32 - c))) ==> (shld32 x, y, c)
4592def : Pat<(or (shl GR32:$src1, CL:$amt),
4593 (srl GR32:$src2, (sub 32, CL:$amt))),
4594 (SHLD32rrCL GR32:$src1, GR32:$src2)>;
4595
4596def : Pat<(store (or (shl (loadi32 addr:$dst), CL:$amt),
4597 (srl GR32:$src2, (sub 32, CL:$amt))), addr:$dst),
4598 (SHLD32mrCL addr:$dst, GR32:$src2)>;
4599
Dan Gohman921581d2008-10-17 01:23:35 +00004600def : Pat<(or (shl GR32:$src1, (i8 (trunc ECX:$amt))),
4601 (srl GR32:$src2, (i8 (trunc (sub 32, ECX:$amt))))),
4602 (SHLD32rrCL GR32:$src1, GR32:$src2)>;
4603
4604def : Pat<(store (or (shl (loadi32 addr:$dst), (i8 (trunc ECX:$amt))),
4605 (srl GR32:$src2, (i8 (trunc (sub 32, ECX:$amt))))),
4606 addr:$dst),
4607 (SHLD32mrCL addr:$dst, GR32:$src2)>;
4608
4609def : Pat<(shld GR32:$src1, (i8 imm:$amt1), GR32:$src2, (i8 imm:$amt2)),
4610 (SHLD32rri8 GR32:$src1, GR32:$src2, (i8 imm:$amt1))>;
4611
4612def : Pat<(store (shld (loadi32 addr:$dst), (i8 imm:$amt1),
4613 GR32:$src2, (i8 imm:$amt2)), addr:$dst),
4614 (SHLD32mri8 addr:$dst, GR32:$src2, (i8 imm:$amt1))>;
4615
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004616// (or (x >> c) | (y << (16 - c))) ==> (shrd16 x, y, c)
4617def : Pat<(or (srl GR16:$src1, CL:$amt),
4618 (shl GR16:$src2, (sub 16, CL:$amt))),
4619 (SHRD16rrCL GR16:$src1, GR16:$src2)>;
4620
4621def : Pat<(store (or (srl (loadi16 addr:$dst), CL:$amt),
4622 (shl GR16:$src2, (sub 16, CL:$amt))), addr:$dst),
4623 (SHRD16mrCL addr:$dst, GR16:$src2)>;
4624
Dan Gohman921581d2008-10-17 01:23:35 +00004625def : Pat<(or (srl GR16:$src1, (i8 (trunc CX:$amt))),
4626 (shl GR16:$src2, (i8 (trunc (sub 16, CX:$amt))))),
4627 (SHRD16rrCL GR16:$src1, GR16:$src2)>;
4628
4629def : Pat<(store (or (srl (loadi16 addr:$dst), (i8 (trunc CX:$amt))),
4630 (shl GR16:$src2, (i8 (trunc (sub 16, CX:$amt))))),
4631 addr:$dst),
4632 (SHRD16mrCL addr:$dst, GR16:$src2)>;
4633
4634def : Pat<(shrd GR16:$src1, (i8 imm:$amt1), GR16:$src2, (i8 imm:$amt2)),
4635 (SHRD16rri8 GR16:$src1, GR16:$src2, (i8 imm:$amt1))>;
4636
4637def : Pat<(store (shrd (loadi16 addr:$dst), (i8 imm:$amt1),
4638 GR16:$src2, (i8 imm:$amt2)), addr:$dst),
4639 (SHRD16mri8 addr:$dst, GR16:$src2, (i8 imm:$amt1))>;
4640
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004641// (or (x << c) | (y >> (16 - c))) ==> (shld16 x, y, c)
4642def : Pat<(or (shl GR16:$src1, CL:$amt),
4643 (srl GR16:$src2, (sub 16, CL:$amt))),
4644 (SHLD16rrCL GR16:$src1, GR16:$src2)>;
4645
4646def : Pat<(store (or (shl (loadi16 addr:$dst), CL:$amt),
4647 (srl GR16:$src2, (sub 16, CL:$amt))), addr:$dst),
4648 (SHLD16mrCL addr:$dst, GR16:$src2)>;
4649
Dan Gohman921581d2008-10-17 01:23:35 +00004650def : Pat<(or (shl GR16:$src1, (i8 (trunc CX:$amt))),
4651 (srl GR16:$src2, (i8 (trunc (sub 16, CX:$amt))))),
4652 (SHLD16rrCL GR16:$src1, GR16:$src2)>;
4653
4654def : Pat<(store (or (shl (loadi16 addr:$dst), (i8 (trunc CX:$amt))),
4655 (srl GR16:$src2, (i8 (trunc (sub 16, CX:$amt))))),
4656 addr:$dst),
4657 (SHLD16mrCL addr:$dst, GR16:$src2)>;
4658
4659def : Pat<(shld GR16:$src1, (i8 imm:$amt1), GR16:$src2, (i8 imm:$amt2)),
4660 (SHLD16rri8 GR16:$src1, GR16:$src2, (i8 imm:$amt1))>;
4661
4662def : Pat<(store (shld (loadi16 addr:$dst), (i8 imm:$amt1),
4663 GR16:$src2, (i8 imm:$amt2)), addr:$dst),
4664 (SHLD16mri8 addr:$dst, GR16:$src2, (i8 imm:$amt1))>;
4665
Evan Chengedeb1692009-12-16 00:53:11 +00004666// (anyext (setcc_carry)) -> (setcc_carry)
4667def : Pat<(i16 (anyext (i8 (X86setcc_c X86_COND_B, EFLAGS)))),
Evan Cheng834ae6b2009-12-15 00:53:42 +00004668 (SETB_C16r)>;
Evan Chengedeb1692009-12-16 00:53:11 +00004669def : Pat<(i32 (anyext (i8 (X86setcc_c X86_COND_B, EFLAGS)))),
Evan Cheng834ae6b2009-12-15 00:53:42 +00004670 (SETB_C32r)>;
4671
Evan Cheng503d9c52010-01-11 22:03:29 +00004672// (or x1, x2) -> (add x1, x2) if two operands are known not to share bits.
Evan Cheng44a441c2010-01-12 18:31:19 +00004673let AddedComplexity = 5 in { // Try this before the selecting to OR
Evan Cheng4621d272010-01-11 17:03:47 +00004674def : Pat<(parallel (or_is_add GR16:$src1, imm:$src2),
4675 (implicit EFLAGS)),
4676 (ADD16ri GR16:$src1, imm:$src2)>;
4677def : Pat<(parallel (or_is_add GR32:$src1, imm:$src2),
4678 (implicit EFLAGS)),
4679 (ADD32ri GR32:$src1, imm:$src2)>;
4680def : Pat<(parallel (or_is_add GR16:$src1, i16immSExt8:$src2),
4681 (implicit EFLAGS)),
4682 (ADD16ri8 GR16:$src1, i16immSExt8:$src2)>;
4683def : Pat<(parallel (or_is_add GR32:$src1, i32immSExt8:$src2),
4684 (implicit EFLAGS)),
4685 (ADD32ri8 GR32:$src1, i32immSExt8:$src2)>;
Evan Cheng503d9c52010-01-11 22:03:29 +00004686def : Pat<(parallel (or_is_add GR16:$src1, GR16:$src2),
4687 (implicit EFLAGS)),
4688 (ADD16rr GR16:$src1, GR16:$src2)>;
4689def : Pat<(parallel (or_is_add GR32:$src1, GR32:$src2),
4690 (implicit EFLAGS)),
4691 (ADD32rr GR32:$src1, GR32:$src2)>;
Evan Cheng44a441c2010-01-12 18:31:19 +00004692} // AddedComplexity
Evan Cheng4621d272010-01-11 17:03:47 +00004693
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004694//===----------------------------------------------------------------------===//
Dan Gohman99a12192009-03-04 19:44:21 +00004695// EFLAGS-defining Patterns
Bill Wendlingf5399032008-12-12 21:15:41 +00004696//===----------------------------------------------------------------------===//
4697
Dan Gohman99a12192009-03-04 19:44:21 +00004698// Register-Register Addition with EFLAGS result
4699def : Pat<(parallel (X86add_flag GR8:$src1, GR8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004700 (implicit EFLAGS)),
4701 (ADD8rr GR8:$src1, GR8:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00004702def : Pat<(parallel (X86add_flag GR16:$src1, GR16:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004703 (implicit EFLAGS)),
4704 (ADD16rr GR16:$src1, GR16:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00004705def : Pat<(parallel (X86add_flag GR32:$src1, GR32:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004706 (implicit EFLAGS)),
4707 (ADD32rr GR32:$src1, GR32:$src2)>;
4708
Dan Gohman99a12192009-03-04 19:44:21 +00004709// Register-Memory Addition with EFLAGS result
4710def : Pat<(parallel (X86add_flag GR8:$src1, (loadi8 addr:$src2)),
Bill Wendlingf5399032008-12-12 21:15:41 +00004711 (implicit EFLAGS)),
4712 (ADD8rm GR8:$src1, addr:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00004713def : Pat<(parallel (X86add_flag GR16:$src1, (loadi16 addr:$src2)),
Bill Wendlingf5399032008-12-12 21:15:41 +00004714 (implicit EFLAGS)),
4715 (ADD16rm GR16:$src1, addr:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00004716def : Pat<(parallel (X86add_flag GR32:$src1, (loadi32 addr:$src2)),
Bill Wendlingf5399032008-12-12 21:15:41 +00004717 (implicit EFLAGS)),
4718 (ADD32rm GR32:$src1, addr:$src2)>;
4719
Dan Gohman99a12192009-03-04 19:44:21 +00004720// Register-Integer Addition with EFLAGS result
4721def : Pat<(parallel (X86add_flag GR8:$src1, imm:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004722 (implicit EFLAGS)),
4723 (ADD8ri GR8:$src1, imm:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00004724def : Pat<(parallel (X86add_flag GR16:$src1, imm:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004725 (implicit EFLAGS)),
4726 (ADD16ri GR16:$src1, imm:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00004727def : Pat<(parallel (X86add_flag GR32:$src1, imm:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004728 (implicit EFLAGS)),
4729 (ADD32ri GR32:$src1, imm:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00004730def : Pat<(parallel (X86add_flag GR16:$src1, i16immSExt8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004731 (implicit EFLAGS)),
4732 (ADD16ri8 GR16:$src1, i16immSExt8:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00004733def : Pat<(parallel (X86add_flag GR32:$src1, i32immSExt8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004734 (implicit EFLAGS)),
4735 (ADD32ri8 GR32:$src1, i32immSExt8:$src2)>;
4736
Dan Gohman99a12192009-03-04 19:44:21 +00004737// Memory-Register Addition with EFLAGS result
4738def : Pat<(parallel (store (X86add_flag (loadi8 addr:$dst), GR8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004739 addr:$dst),
4740 (implicit EFLAGS)),
4741 (ADD8mr addr:$dst, GR8:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00004742def : Pat<(parallel (store (X86add_flag (loadi16 addr:$dst), GR16:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004743 addr:$dst),
4744 (implicit EFLAGS)),
4745 (ADD16mr addr:$dst, GR16:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00004746def : Pat<(parallel (store (X86add_flag (loadi32 addr:$dst), GR32:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004747 addr:$dst),
4748 (implicit EFLAGS)),
4749 (ADD32mr addr:$dst, GR32:$src2)>;
Dale Johannesen06b83f12009-05-18 17:44:15 +00004750
4751// Memory-Integer Addition with EFLAGS result
Dan Gohman99a12192009-03-04 19:44:21 +00004752def : Pat<(parallel (store (X86add_flag (loadi8 addr:$dst), imm:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004753 addr:$dst),
4754 (implicit EFLAGS)),
4755 (ADD8mi addr:$dst, imm:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00004756def : Pat<(parallel (store (X86add_flag (loadi16 addr:$dst), imm:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004757 addr:$dst),
4758 (implicit EFLAGS)),
4759 (ADD16mi addr:$dst, imm:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00004760def : Pat<(parallel (store (X86add_flag (loadi32 addr:$dst), imm:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004761 addr:$dst),
4762 (implicit EFLAGS)),
4763 (ADD32mi addr:$dst, imm:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00004764def : Pat<(parallel (store (X86add_flag (loadi16 addr:$dst), i16immSExt8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004765 addr:$dst),
4766 (implicit EFLAGS)),
4767 (ADD16mi8 addr:$dst, i16immSExt8:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00004768def : Pat<(parallel (store (X86add_flag (loadi32 addr:$dst), i32immSExt8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004769 addr:$dst),
4770 (implicit EFLAGS)),
4771 (ADD32mi8 addr:$dst, i32immSExt8:$src2)>;
4772
Dan Gohman99a12192009-03-04 19:44:21 +00004773// Register-Register Subtraction with EFLAGS result
4774def : Pat<(parallel (X86sub_flag GR8:$src1, GR8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004775 (implicit EFLAGS)),
4776 (SUB8rr GR8:$src1, GR8:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00004777def : Pat<(parallel (X86sub_flag GR16:$src1, GR16:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004778 (implicit EFLAGS)),
4779 (SUB16rr GR16:$src1, GR16:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00004780def : Pat<(parallel (X86sub_flag GR32:$src1, GR32:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004781 (implicit EFLAGS)),
4782 (SUB32rr GR32:$src1, GR32:$src2)>;
4783
Dan Gohman99a12192009-03-04 19:44:21 +00004784// Register-Memory Subtraction with EFLAGS result
4785def : Pat<(parallel (X86sub_flag GR8:$src1, (loadi8 addr:$src2)),
Bill Wendlingf5399032008-12-12 21:15:41 +00004786 (implicit EFLAGS)),
4787 (SUB8rm GR8:$src1, addr:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00004788def : Pat<(parallel (X86sub_flag GR16:$src1, (loadi16 addr:$src2)),
Bill Wendlingf5399032008-12-12 21:15:41 +00004789 (implicit EFLAGS)),
4790 (SUB16rm GR16:$src1, addr:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00004791def : Pat<(parallel (X86sub_flag GR32:$src1, (loadi32 addr:$src2)),
Bill Wendlingf5399032008-12-12 21:15:41 +00004792 (implicit EFLAGS)),
4793 (SUB32rm GR32:$src1, addr:$src2)>;
4794
Dan Gohman99a12192009-03-04 19:44:21 +00004795// Register-Integer Subtraction with EFLAGS result
4796def : Pat<(parallel (X86sub_flag GR8:$src1, imm:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004797 (implicit EFLAGS)),
4798 (SUB8ri GR8:$src1, imm:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00004799def : Pat<(parallel (X86sub_flag GR16:$src1, imm:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004800 (implicit EFLAGS)),
4801 (SUB16ri GR16:$src1, imm:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00004802def : Pat<(parallel (X86sub_flag GR32:$src1, imm:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004803 (implicit EFLAGS)),
4804 (SUB32ri GR32:$src1, imm:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00004805def : Pat<(parallel (X86sub_flag GR16:$src1, i16immSExt8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004806 (implicit EFLAGS)),
4807 (SUB16ri8 GR16:$src1, i16immSExt8:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00004808def : Pat<(parallel (X86sub_flag GR32:$src1, i32immSExt8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004809 (implicit EFLAGS)),
4810 (SUB32ri8 GR32:$src1, i32immSExt8:$src2)>;
4811
Dan Gohman99a12192009-03-04 19:44:21 +00004812// Memory-Register Subtraction with EFLAGS result
4813def : Pat<(parallel (store (X86sub_flag (loadi8 addr:$dst), GR8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004814 addr:$dst),
4815 (implicit EFLAGS)),
4816 (SUB8mr addr:$dst, GR8:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00004817def : Pat<(parallel (store (X86sub_flag (loadi16 addr:$dst), GR16:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004818 addr:$dst),
4819 (implicit EFLAGS)),
4820 (SUB16mr addr:$dst, GR16:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00004821def : Pat<(parallel (store (X86sub_flag (loadi32 addr:$dst), GR32:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004822 addr:$dst),
4823 (implicit EFLAGS)),
4824 (SUB32mr addr:$dst, GR32:$src2)>;
4825
Dan Gohman99a12192009-03-04 19:44:21 +00004826// Memory-Integer Subtraction with EFLAGS result
4827def : Pat<(parallel (store (X86sub_flag (loadi8 addr:$dst), imm:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004828 addr:$dst),
4829 (implicit EFLAGS)),
4830 (SUB8mi addr:$dst, imm:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00004831def : Pat<(parallel (store (X86sub_flag (loadi16 addr:$dst), imm:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004832 addr:$dst),
4833 (implicit EFLAGS)),
4834 (SUB16mi addr:$dst, imm:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00004835def : Pat<(parallel (store (X86sub_flag (loadi32 addr:$dst), imm:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004836 addr:$dst),
4837 (implicit EFLAGS)),
4838 (SUB32mi addr:$dst, imm:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00004839def : Pat<(parallel (store (X86sub_flag (loadi16 addr:$dst), i16immSExt8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004840 addr:$dst),
4841 (implicit EFLAGS)),
4842 (SUB16mi8 addr:$dst, i16immSExt8:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00004843def : Pat<(parallel (store (X86sub_flag (loadi32 addr:$dst), i32immSExt8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004844 addr:$dst),
4845 (implicit EFLAGS)),
4846 (SUB32mi8 addr:$dst, i32immSExt8:$src2)>;
4847
4848
Dan Gohman99a12192009-03-04 19:44:21 +00004849// Register-Register Signed Integer Multiply with EFLAGS result
4850def : Pat<(parallel (X86smul_flag GR16:$src1, GR16:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004851 (implicit EFLAGS)),
4852 (IMUL16rr GR16:$src1, GR16:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00004853def : Pat<(parallel (X86smul_flag GR32:$src1, GR32:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004854 (implicit EFLAGS)),
4855 (IMUL32rr GR32:$src1, GR32:$src2)>;
4856
Dan Gohman99a12192009-03-04 19:44:21 +00004857// Register-Memory Signed Integer Multiply with EFLAGS result
4858def : Pat<(parallel (X86smul_flag GR16:$src1, (loadi16 addr:$src2)),
Bill Wendlingf5399032008-12-12 21:15:41 +00004859 (implicit EFLAGS)),
4860 (IMUL16rm GR16:$src1, addr:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00004861def : Pat<(parallel (X86smul_flag GR32:$src1, (loadi32 addr:$src2)),
Bill Wendlingf5399032008-12-12 21:15:41 +00004862 (implicit EFLAGS)),
4863 (IMUL32rm GR32:$src1, addr:$src2)>;
4864
Dan Gohman99a12192009-03-04 19:44:21 +00004865// Register-Integer Signed Integer Multiply with EFLAGS result
4866def : Pat<(parallel (X86smul_flag GR16:$src1, imm:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004867 (implicit EFLAGS)),
4868 (IMUL16rri GR16:$src1, imm:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00004869def : Pat<(parallel (X86smul_flag GR32:$src1, imm:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004870 (implicit EFLAGS)),
4871 (IMUL32rri GR32:$src1, imm:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00004872def : Pat<(parallel (X86smul_flag GR16:$src1, i16immSExt8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004873 (implicit EFLAGS)),
4874 (IMUL16rri8 GR16:$src1, i16immSExt8:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00004875def : Pat<(parallel (X86smul_flag GR32:$src1, i32immSExt8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004876 (implicit EFLAGS)),
4877 (IMUL32rri8 GR32:$src1, i32immSExt8:$src2)>;
4878
Dan Gohman99a12192009-03-04 19:44:21 +00004879// Memory-Integer Signed Integer Multiply with EFLAGS result
4880def : Pat<(parallel (X86smul_flag (loadi16 addr:$src1), imm:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004881 (implicit EFLAGS)),
4882 (IMUL16rmi addr:$src1, imm:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00004883def : Pat<(parallel (X86smul_flag (loadi32 addr:$src1), imm:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004884 (implicit EFLAGS)),
4885 (IMUL32rmi addr:$src1, imm:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00004886def : Pat<(parallel (X86smul_flag (loadi16 addr:$src1), i16immSExt8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004887 (implicit EFLAGS)),
4888 (IMUL16rmi8 addr:$src1, i16immSExt8:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00004889def : Pat<(parallel (X86smul_flag (loadi32 addr:$src1), i32immSExt8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004890 (implicit EFLAGS)),
4891 (IMUL32rmi8 addr:$src1, i32immSExt8:$src2)>;
4892
Dan Gohman99a12192009-03-04 19:44:21 +00004893// Optimize multiply by 2 with EFLAGS result.
Evan Cheng00cf7932009-01-27 03:30:42 +00004894let AddedComplexity = 2 in {
Dan Gohman99a12192009-03-04 19:44:21 +00004895def : Pat<(parallel (X86smul_flag GR16:$src1, 2),
Evan Cheng00cf7932009-01-27 03:30:42 +00004896 (implicit EFLAGS)),
4897 (ADD16rr GR16:$src1, GR16:$src1)>;
4898
Dan Gohman99a12192009-03-04 19:44:21 +00004899def : Pat<(parallel (X86smul_flag GR32:$src1, 2),
Evan Cheng00cf7932009-01-27 03:30:42 +00004900 (implicit EFLAGS)),
4901 (ADD32rr GR32:$src1, GR32:$src1)>;
4902}
4903
Dan Gohman99a12192009-03-04 19:44:21 +00004904// INC and DEC with EFLAGS result. Note that these do not set CF.
4905def : Pat<(parallel (X86inc_flag GR8:$src), (implicit EFLAGS)),
4906 (INC8r GR8:$src)>;
4907def : Pat<(parallel (store (i8 (X86inc_flag (loadi8 addr:$dst))), addr:$dst),
4908 (implicit EFLAGS)),
4909 (INC8m addr:$dst)>;
4910def : Pat<(parallel (X86dec_flag GR8:$src), (implicit EFLAGS)),
4911 (DEC8r GR8:$src)>;
4912def : Pat<(parallel (store (i8 (X86dec_flag (loadi8 addr:$dst))), addr:$dst),
4913 (implicit EFLAGS)),
4914 (DEC8m addr:$dst)>;
4915
4916def : Pat<(parallel (X86inc_flag GR16:$src), (implicit EFLAGS)),
Dan Gohmaneebcac72009-03-05 21:32:23 +00004917 (INC16r GR16:$src)>, Requires<[In32BitMode]>;
Dan Gohman99a12192009-03-04 19:44:21 +00004918def : Pat<(parallel (store (i16 (X86inc_flag (loadi16 addr:$dst))), addr:$dst),
4919 (implicit EFLAGS)),
Dan Gohmaneebcac72009-03-05 21:32:23 +00004920 (INC16m addr:$dst)>, Requires<[In32BitMode]>;
Dan Gohman99a12192009-03-04 19:44:21 +00004921def : Pat<(parallel (X86dec_flag GR16:$src), (implicit EFLAGS)),
Dan Gohmaneebcac72009-03-05 21:32:23 +00004922 (DEC16r GR16:$src)>, Requires<[In32BitMode]>;
Dan Gohman99a12192009-03-04 19:44:21 +00004923def : Pat<(parallel (store (i16 (X86dec_flag (loadi16 addr:$dst))), addr:$dst),
4924 (implicit EFLAGS)),
Dan Gohmaneebcac72009-03-05 21:32:23 +00004925 (DEC16m addr:$dst)>, Requires<[In32BitMode]>;
Dan Gohman99a12192009-03-04 19:44:21 +00004926
4927def : Pat<(parallel (X86inc_flag GR32:$src), (implicit EFLAGS)),
Dan Gohmaneebcac72009-03-05 21:32:23 +00004928 (INC32r GR32:$src)>, Requires<[In32BitMode]>;
Dan Gohman99a12192009-03-04 19:44:21 +00004929def : Pat<(parallel (store (i32 (X86inc_flag (loadi32 addr:$dst))), addr:$dst),
4930 (implicit EFLAGS)),
Dan Gohmaneebcac72009-03-05 21:32:23 +00004931 (INC32m addr:$dst)>, Requires<[In32BitMode]>;
Dan Gohman99a12192009-03-04 19:44:21 +00004932def : Pat<(parallel (X86dec_flag GR32:$src), (implicit EFLAGS)),
Dan Gohmaneebcac72009-03-05 21:32:23 +00004933 (DEC32r GR32:$src)>, Requires<[In32BitMode]>;
Dan Gohman99a12192009-03-04 19:44:21 +00004934def : Pat<(parallel (store (i32 (X86dec_flag (loadi32 addr:$dst))), addr:$dst),
4935 (implicit EFLAGS)),
Dan Gohmaneebcac72009-03-05 21:32:23 +00004936 (DEC32m addr:$dst)>, Requires<[In32BitMode]>;
Dan Gohman99a12192009-03-04 19:44:21 +00004937
Dan Gohman12e03292009-09-18 19:59:53 +00004938// Register-Register Or with EFLAGS result
4939def : Pat<(parallel (X86or_flag GR8:$src1, GR8:$src2),
4940 (implicit EFLAGS)),
4941 (OR8rr GR8:$src1, GR8:$src2)>;
4942def : Pat<(parallel (X86or_flag GR16:$src1, GR16:$src2),
4943 (implicit EFLAGS)),
4944 (OR16rr GR16:$src1, GR16:$src2)>;
4945def : Pat<(parallel (X86or_flag GR32:$src1, GR32:$src2),
4946 (implicit EFLAGS)),
4947 (OR32rr GR32:$src1, GR32:$src2)>;
4948
4949// Register-Memory Or with EFLAGS result
4950def : Pat<(parallel (X86or_flag GR8:$src1, (loadi8 addr:$src2)),
4951 (implicit EFLAGS)),
4952 (OR8rm GR8:$src1, addr:$src2)>;
4953def : Pat<(parallel (X86or_flag GR16:$src1, (loadi16 addr:$src2)),
4954 (implicit EFLAGS)),
4955 (OR16rm GR16:$src1, addr:$src2)>;
4956def : Pat<(parallel (X86or_flag GR32:$src1, (loadi32 addr:$src2)),
4957 (implicit EFLAGS)),
4958 (OR32rm GR32:$src1, addr:$src2)>;
4959
4960// Register-Integer Or with EFLAGS result
4961def : Pat<(parallel (X86or_flag GR8:$src1, imm:$src2),
4962 (implicit EFLAGS)),
4963 (OR8ri GR8:$src1, imm:$src2)>;
4964def : Pat<(parallel (X86or_flag GR16:$src1, imm:$src2),
4965 (implicit EFLAGS)),
4966 (OR16ri GR16:$src1, imm:$src2)>;
4967def : Pat<(parallel (X86or_flag GR32:$src1, imm:$src2),
4968 (implicit EFLAGS)),
4969 (OR32ri GR32:$src1, imm:$src2)>;
4970def : Pat<(parallel (X86or_flag GR16:$src1, i16immSExt8:$src2),
4971 (implicit EFLAGS)),
4972 (OR16ri8 GR16:$src1, i16immSExt8:$src2)>;
4973def : Pat<(parallel (X86or_flag GR32:$src1, i32immSExt8:$src2),
4974 (implicit EFLAGS)),
4975 (OR32ri8 GR32:$src1, i32immSExt8:$src2)>;
4976
4977// Memory-Register Or with EFLAGS result
4978def : Pat<(parallel (store (X86or_flag (loadi8 addr:$dst), GR8:$src2),
4979 addr:$dst),
4980 (implicit EFLAGS)),
4981 (OR8mr addr:$dst, GR8:$src2)>;
4982def : Pat<(parallel (store (X86or_flag (loadi16 addr:$dst), GR16:$src2),
4983 addr:$dst),
4984 (implicit EFLAGS)),
4985 (OR16mr addr:$dst, GR16:$src2)>;
4986def : Pat<(parallel (store (X86or_flag (loadi32 addr:$dst), GR32:$src2),
4987 addr:$dst),
4988 (implicit EFLAGS)),
4989 (OR32mr addr:$dst, GR32:$src2)>;
4990
4991// Memory-Integer Or with EFLAGS result
4992def : Pat<(parallel (store (X86or_flag (loadi8 addr:$dst), imm:$src2),
4993 addr:$dst),
4994 (implicit EFLAGS)),
4995 (OR8mi addr:$dst, imm:$src2)>;
4996def : Pat<(parallel (store (X86or_flag (loadi16 addr:$dst), imm:$src2),
4997 addr:$dst),
4998 (implicit EFLAGS)),
4999 (OR16mi addr:$dst, imm:$src2)>;
5000def : Pat<(parallel (store (X86or_flag (loadi32 addr:$dst), imm:$src2),
5001 addr:$dst),
5002 (implicit EFLAGS)),
5003 (OR32mi addr:$dst, imm:$src2)>;
5004def : Pat<(parallel (store (X86or_flag (loadi16 addr:$dst), i16immSExt8:$src2),
5005 addr:$dst),
5006 (implicit EFLAGS)),
5007 (OR16mi8 addr:$dst, i16immSExt8:$src2)>;
5008def : Pat<(parallel (store (X86or_flag (loadi32 addr:$dst), i32immSExt8:$src2),
5009 addr:$dst),
5010 (implicit EFLAGS)),
5011 (OR32mi8 addr:$dst, i32immSExt8:$src2)>;
5012
5013// Register-Register XOr with EFLAGS result
5014def : Pat<(parallel (X86xor_flag GR8:$src1, GR8:$src2),
5015 (implicit EFLAGS)),
5016 (XOR8rr GR8:$src1, GR8:$src2)>;
5017def : Pat<(parallel (X86xor_flag GR16:$src1, GR16:$src2),
5018 (implicit EFLAGS)),
5019 (XOR16rr GR16:$src1, GR16:$src2)>;
5020def : Pat<(parallel (X86xor_flag GR32:$src1, GR32:$src2),
5021 (implicit EFLAGS)),
5022 (XOR32rr GR32:$src1, GR32:$src2)>;
5023
5024// Register-Memory XOr with EFLAGS result
5025def : Pat<(parallel (X86xor_flag GR8:$src1, (loadi8 addr:$src2)),
5026 (implicit EFLAGS)),
5027 (XOR8rm GR8:$src1, addr:$src2)>;
5028def : Pat<(parallel (X86xor_flag GR16:$src1, (loadi16 addr:$src2)),
5029 (implicit EFLAGS)),
5030 (XOR16rm GR16:$src1, addr:$src2)>;
5031def : Pat<(parallel (X86xor_flag GR32:$src1, (loadi32 addr:$src2)),
5032 (implicit EFLAGS)),
5033 (XOR32rm GR32:$src1, addr:$src2)>;
5034
5035// Register-Integer XOr with EFLAGS result
5036def : Pat<(parallel (X86xor_flag GR8:$src1, imm:$src2),
5037 (implicit EFLAGS)),
5038 (XOR8ri GR8:$src1, imm:$src2)>;
5039def : Pat<(parallel (X86xor_flag GR16:$src1, imm:$src2),
5040 (implicit EFLAGS)),
5041 (XOR16ri GR16:$src1, imm:$src2)>;
5042def : Pat<(parallel (X86xor_flag GR32:$src1, imm:$src2),
5043 (implicit EFLAGS)),
5044 (XOR32ri GR32:$src1, imm:$src2)>;
5045def : Pat<(parallel (X86xor_flag GR16:$src1, i16immSExt8:$src2),
5046 (implicit EFLAGS)),
5047 (XOR16ri8 GR16:$src1, i16immSExt8:$src2)>;
5048def : Pat<(parallel (X86xor_flag GR32:$src1, i32immSExt8:$src2),
5049 (implicit EFLAGS)),
5050 (XOR32ri8 GR32:$src1, i32immSExt8:$src2)>;
5051
5052// Memory-Register XOr with EFLAGS result
5053def : Pat<(parallel (store (X86xor_flag (loadi8 addr:$dst), GR8:$src2),
5054 addr:$dst),
5055 (implicit EFLAGS)),
5056 (XOR8mr addr:$dst, GR8:$src2)>;
5057def : Pat<(parallel (store (X86xor_flag (loadi16 addr:$dst), GR16:$src2),
5058 addr:$dst),
5059 (implicit EFLAGS)),
5060 (XOR16mr addr:$dst, GR16:$src2)>;
5061def : Pat<(parallel (store (X86xor_flag (loadi32 addr:$dst), GR32:$src2),
5062 addr:$dst),
5063 (implicit EFLAGS)),
5064 (XOR32mr addr:$dst, GR32:$src2)>;
5065
5066// Memory-Integer XOr with EFLAGS result
5067def : Pat<(parallel (store (X86xor_flag (loadi8 addr:$dst), imm:$src2),
5068 addr:$dst),
5069 (implicit EFLAGS)),
5070 (XOR8mi addr:$dst, imm:$src2)>;
5071def : Pat<(parallel (store (X86xor_flag (loadi16 addr:$dst), imm:$src2),
5072 addr:$dst),
5073 (implicit EFLAGS)),
5074 (XOR16mi addr:$dst, imm:$src2)>;
5075def : Pat<(parallel (store (X86xor_flag (loadi32 addr:$dst), imm:$src2),
5076 addr:$dst),
5077 (implicit EFLAGS)),
5078 (XOR32mi addr:$dst, imm:$src2)>;
5079def : Pat<(parallel (store (X86xor_flag (loadi16 addr:$dst), i16immSExt8:$src2),
5080 addr:$dst),
5081 (implicit EFLAGS)),
5082 (XOR16mi8 addr:$dst, i16immSExt8:$src2)>;
5083def : Pat<(parallel (store (X86xor_flag (loadi32 addr:$dst), i32immSExt8:$src2),
5084 addr:$dst),
5085 (implicit EFLAGS)),
5086 (XOR32mi8 addr:$dst, i32immSExt8:$src2)>;
5087
5088// Register-Register And with EFLAGS result
5089def : Pat<(parallel (X86and_flag GR8:$src1, GR8:$src2),
5090 (implicit EFLAGS)),
5091 (AND8rr GR8:$src1, GR8:$src2)>;
5092def : Pat<(parallel (X86and_flag GR16:$src1, GR16:$src2),
5093 (implicit EFLAGS)),
5094 (AND16rr GR16:$src1, GR16:$src2)>;
5095def : Pat<(parallel (X86and_flag GR32:$src1, GR32:$src2),
5096 (implicit EFLAGS)),
5097 (AND32rr GR32:$src1, GR32:$src2)>;
5098
5099// Register-Memory And with EFLAGS result
5100def : Pat<(parallel (X86and_flag GR8:$src1, (loadi8 addr:$src2)),
5101 (implicit EFLAGS)),
5102 (AND8rm GR8:$src1, addr:$src2)>;
5103def : Pat<(parallel (X86and_flag GR16:$src1, (loadi16 addr:$src2)),
5104 (implicit EFLAGS)),
5105 (AND16rm GR16:$src1, addr:$src2)>;
5106def : Pat<(parallel (X86and_flag GR32:$src1, (loadi32 addr:$src2)),
5107 (implicit EFLAGS)),
5108 (AND32rm GR32:$src1, addr:$src2)>;
5109
5110// Register-Integer And with EFLAGS result
5111def : Pat<(parallel (X86and_flag GR8:$src1, imm:$src2),
5112 (implicit EFLAGS)),
5113 (AND8ri GR8:$src1, imm:$src2)>;
5114def : Pat<(parallel (X86and_flag GR16:$src1, imm:$src2),
5115 (implicit EFLAGS)),
5116 (AND16ri GR16:$src1, imm:$src2)>;
5117def : Pat<(parallel (X86and_flag GR32:$src1, imm:$src2),
5118 (implicit EFLAGS)),
5119 (AND32ri GR32:$src1, imm:$src2)>;
5120def : Pat<(parallel (X86and_flag GR16:$src1, i16immSExt8:$src2),
5121 (implicit EFLAGS)),
5122 (AND16ri8 GR16:$src1, i16immSExt8:$src2)>;
5123def : Pat<(parallel (X86and_flag GR32:$src1, i32immSExt8:$src2),
5124 (implicit EFLAGS)),
5125 (AND32ri8 GR32:$src1, i32immSExt8:$src2)>;
5126
5127// Memory-Register And with EFLAGS result
5128def : Pat<(parallel (store (X86and_flag (loadi8 addr:$dst), GR8:$src2),
5129 addr:$dst),
5130 (implicit EFLAGS)),
5131 (AND8mr addr:$dst, GR8:$src2)>;
5132def : Pat<(parallel (store (X86and_flag (loadi16 addr:$dst), GR16:$src2),
5133 addr:$dst),
5134 (implicit EFLAGS)),
5135 (AND16mr addr:$dst, GR16:$src2)>;
5136def : Pat<(parallel (store (X86and_flag (loadi32 addr:$dst), GR32:$src2),
5137 addr:$dst),
5138 (implicit EFLAGS)),
5139 (AND32mr addr:$dst, GR32:$src2)>;
5140
5141// Memory-Integer And with EFLAGS result
5142def : Pat<(parallel (store (X86and_flag (loadi8 addr:$dst), imm:$src2),
5143 addr:$dst),
5144 (implicit EFLAGS)),
5145 (AND8mi addr:$dst, imm:$src2)>;
5146def : Pat<(parallel (store (X86and_flag (loadi16 addr:$dst), imm:$src2),
5147 addr:$dst),
5148 (implicit EFLAGS)),
5149 (AND16mi addr:$dst, imm:$src2)>;
5150def : Pat<(parallel (store (X86and_flag (loadi32 addr:$dst), imm:$src2),
5151 addr:$dst),
5152 (implicit EFLAGS)),
5153 (AND32mi addr:$dst, imm:$src2)>;
5154def : Pat<(parallel (store (X86and_flag (loadi16 addr:$dst), i16immSExt8:$src2),
5155 addr:$dst),
5156 (implicit EFLAGS)),
5157 (AND16mi8 addr:$dst, i16immSExt8:$src2)>;
5158def : Pat<(parallel (store (X86and_flag (loadi32 addr:$dst), i32immSExt8:$src2),
5159 addr:$dst),
5160 (implicit EFLAGS)),
5161 (AND32mi8 addr:$dst, i32immSExt8:$src2)>;
5162
Dan Gohmane84197b2009-09-03 17:18:51 +00005163// -disable-16bit support.
5164def : Pat<(truncstorei16 (i32 imm:$src), addr:$dst),
5165 (MOV16mi addr:$dst, imm:$src)>;
5166def : Pat<(truncstorei16 GR32:$src, addr:$dst),
5167 (MOV16mr addr:$dst, (EXTRACT_SUBREG GR32:$src, x86_subreg_16bit))>;
5168def : Pat<(i32 (sextloadi16 addr:$dst)),
5169 (MOVSX32rm16 addr:$dst)>;
5170def : Pat<(i32 (zextloadi16 addr:$dst)),
5171 (MOVZX32rm16 addr:$dst)>;
5172def : Pat<(i32 (extloadi16 addr:$dst)),
5173 (MOVZX32rm16 addr:$dst)>;
5174
Bill Wendlingf5399032008-12-12 21:15:41 +00005175//===----------------------------------------------------------------------===//
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005176// Floating Point Stack Support
5177//===----------------------------------------------------------------------===//
5178
5179include "X86InstrFPStack.td"
5180
5181//===----------------------------------------------------------------------===//
Evan Cheng86ab7d32007-07-31 08:04:03 +00005182// X86-64 Support
5183//===----------------------------------------------------------------------===//
5184
Chris Lattner2de8d2b2008-01-10 05:50:42 +00005185include "X86Instr64bit.td"
Evan Cheng86ab7d32007-07-31 08:04:03 +00005186
5187//===----------------------------------------------------------------------===//
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005188// XMM Floating point support (requires SSE / SSE2)
5189//===----------------------------------------------------------------------===//
5190
5191include "X86InstrSSE.td"
Evan Cheng5e4d1e72008-04-25 18:19:54 +00005192
5193//===----------------------------------------------------------------------===//
5194// MMX and XMM Packed Integer support (requires MMX, SSE, and SSE2)
5195//===----------------------------------------------------------------------===//
5196
5197include "X86InstrMMX.td"