blob: 3323e23ef8c7b395bdb8a772c6e099ddf070e785 [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}
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000199class X86MemOperand<string printMethod> : Operand<iPTR> {
200 let PrintMethod = printMethod;
Dan Gohmanfe606822009-07-30 01:56:29 +0000201 let MIOperandInfo = (ops ptr_rc, i8imm, ptr_rc_nosp, i32imm, i8imm);
Daniel Dunbar0f10cbf2009-08-10 18:41:10 +0000202 let ParserMatchClass = X86MemAsmOperand;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000203}
204
Sean Callanan66fdfa02009-09-03 00:04:47 +0000205def opaque32mem : X86MemOperand<"printopaquemem">;
206def opaque48mem : X86MemOperand<"printopaquemem">;
207def opaque80mem : X86MemOperand<"printopaquemem">;
Sean Callanan2c48df22009-12-18 00:01:26 +0000208def opaque512mem : X86MemOperand<"printopaquemem">;
209
210def offset8 : Operand<i64> { let PrintMethod = "print_pcrel_imm"; }
211def offset16 : Operand<i64> { let PrintMethod = "print_pcrel_imm"; }
212def offset32 : Operand<i64> { let PrintMethod = "print_pcrel_imm"; }
213def offset64 : Operand<i64> { let PrintMethod = "print_pcrel_imm"; }
Sean Callanan66fdfa02009-09-03 00:04:47 +0000214
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000215def i8mem : X86MemOperand<"printi8mem">;
216def i16mem : X86MemOperand<"printi16mem">;
217def i32mem : X86MemOperand<"printi32mem">;
218def i64mem : X86MemOperand<"printi64mem">;
219def i128mem : X86MemOperand<"printi128mem">;
Chris Lattnerd6153b42009-09-20 07:17:49 +0000220//def i256mem : X86MemOperand<"printi256mem">;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000221def f32mem : X86MemOperand<"printf32mem">;
222def f64mem : X86MemOperand<"printf64mem">;
Dale Johannesen4ab00bd2007-08-05 18:49:15 +0000223def f80mem : X86MemOperand<"printf80mem">;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000224def f128mem : X86MemOperand<"printf128mem">;
Chris Lattnerd6153b42009-09-20 07:17:49 +0000225//def f256mem : X86MemOperand<"printf256mem">;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000226
Dan Gohman744d4622009-04-13 16:09:41 +0000227// A version of i8mem for use on x86-64 that uses GR64_NOREX instead of
228// plain GR64, so that it doesn't potentially require a REX prefix.
229def i8mem_NOREX : Operand<i64> {
230 let PrintMethod = "printi8mem";
Dan Gohmanfe606822009-07-30 01:56:29 +0000231 let MIOperandInfo = (ops GR64_NOREX, i8imm, GR64_NOREX_NOSP, i32imm, i8imm);
Daniel Dunbar0f10cbf2009-08-10 18:41:10 +0000232 let ParserMatchClass = X86MemAsmOperand;
Dan Gohman744d4622009-04-13 16:09:41 +0000233}
234
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000235def lea32mem : Operand<i32> {
Rafael Espindolabca99f72009-04-08 21:14:34 +0000236 let PrintMethod = "printlea32mem";
Dan Gohmanefbd3bc2009-08-05 17:40:24 +0000237 let MIOperandInfo = (ops GR32, i8imm, GR32_NOSP, i32imm);
Daniel Dunbar0f10cbf2009-08-10 18:41:10 +0000238 let ParserMatchClass = X86MemAsmOperand;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000239}
240
241def SSECC : Operand<i8> {
242 let PrintMethod = "printSSECC";
243}
244
Daniel Dunbar0f10cbf2009-08-10 18:41:10 +0000245def ImmSExt8AsmOperand : AsmOperandClass {
246 let Name = "ImmSExt8";
247 let SuperClass = ImmAsmOperand;
248}
249
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000250// A couple of more descriptive operand definitions.
251// 16-bits but only 8 bits are significant.
Daniel Dunbar06d5cb62009-08-09 07:20:21 +0000252def i16i8imm : Operand<i16> {
Daniel Dunbar0f10cbf2009-08-10 18:41:10 +0000253 let ParserMatchClass = ImmSExt8AsmOperand;
Daniel Dunbar06d5cb62009-08-09 07:20:21 +0000254}
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000255// 32-bits but only 8 bits are significant.
Daniel Dunbar06d5cb62009-08-09 07:20:21 +0000256def i32i8imm : Operand<i32> {
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
Chris Lattner357a0ca2009-06-20 19:34:09 +0000260// Branch targets have OtherVT type and print as pc-relative values.
261def brtarget : Operand<OtherVT> {
262 let PrintMethod = "print_pcrel_imm";
263}
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000264
Evan Chengd11052b2009-07-21 06:00:18 +0000265def brtarget8 : Operand<OtherVT> {
266 let PrintMethod = "print_pcrel_imm";
267}
268
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000269//===----------------------------------------------------------------------===//
270// X86 Complex Pattern Definitions.
271//
272
273// Define X86 specific addressing mode.
Rafael Espindolabca99f72009-04-08 21:14:34 +0000274def addr : ComplexPattern<iPTR, 5, "SelectAddr", [], []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000275def lea32addr : ComplexPattern<i32, 4, "SelectLEAAddr",
Dan Gohman0c0d7412009-08-02 16:09:17 +0000276 [add, sub, mul, X86mul_imm, shl, or, frameindex],
277 []>;
Chris Lattnerf1940742009-06-20 20:38:48 +0000278def tls32addr : ComplexPattern<i32, 4, "SelectTLSADDRAddr",
279 [tglobaltlsaddr], []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000280
281//===----------------------------------------------------------------------===//
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000282// X86 Instruction Predicate Definitions.
283def HasMMX : Predicate<"Subtarget->hasMMX()">;
284def HasSSE1 : Predicate<"Subtarget->hasSSE1()">;
285def HasSSE2 : Predicate<"Subtarget->hasSSE2()">;
286def HasSSE3 : Predicate<"Subtarget->hasSSE3()">;
287def HasSSSE3 : Predicate<"Subtarget->hasSSSE3()">;
Nate Begemanb2975562008-02-03 07:18:54 +0000288def HasSSE41 : Predicate<"Subtarget->hasSSE41()">;
289def HasSSE42 : Predicate<"Subtarget->hasSSE42()">;
David Greene8bf22bc2009-06-26 22:46:54 +0000290def HasSSE4A : Predicate<"Subtarget->hasSSE4A()">;
291def HasAVX : Predicate<"Subtarget->hasAVX()">;
292def HasFMA3 : Predicate<"Subtarget->hasFMA3()">;
293def HasFMA4 : Predicate<"Subtarget->hasFMA4()">;
Dale Johannesene0e0fd02007-09-23 14:52:20 +0000294def FPStackf32 : Predicate<"!Subtarget->hasSSE1()">;
295def FPStackf64 : Predicate<"!Subtarget->hasSSE2()">;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000296def In32BitMode : Predicate<"!Subtarget->is64Bit()">;
297def In64BitMode : Predicate<"Subtarget->is64Bit()">;
Anton Korobeynikov2cbcdb72009-08-03 08:12:53 +0000298def IsWin64 : Predicate<"Subtarget->isTargetWin64()">;
299def NotWin64 : Predicate<"!Subtarget->isTargetWin64()">;
Anton Korobeynikov68d4eca2009-08-06 11:23:24 +0000300def SmallCode : Predicate<"TM.getCodeModel() == CodeModel::Small">;
301def KernelCode : Predicate<"TM.getCodeModel() == CodeModel::Kernel">;
302def FarData : Predicate<"TM.getCodeModel() != CodeModel::Small &&"
Anton Korobeynikov7e1178f2009-08-06 09:11:19 +0000303 "TM.getCodeModel() != CodeModel::Kernel">;
Anton Korobeynikov68d4eca2009-08-06 11:23:24 +0000304def NearData : Predicate<"TM.getCodeModel() == CodeModel::Small ||"
305 "TM.getCodeModel() == CodeModel::Kernel">;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000306def IsStatic : Predicate<"TM.getRelocationModel() == Reloc::Static">;
Evan Chengd53fca12009-12-22 17:47:23 +0000307def OptForSize : Predicate<"OptForSize">;
Evan Cheng13559d62008-09-26 23:41:32 +0000308def OptForSpeed : Predicate<"!OptForSize">;
Evan Cheng95a77fd2009-01-02 05:35:45 +0000309def FastBTMem : Predicate<"!Subtarget->isBTMemSlow()">;
Evan Cheng6d35a4d2009-05-20 04:53:57 +0000310def CallImmAddr : Predicate<"Subtarget->IsLegalToCallImmediateAddr(TM)">;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000311
312//===----------------------------------------------------------------------===//
Evan Cheng86ab7d32007-07-31 08:04:03 +0000313// X86 Instruction Format Definitions.
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000314//
315
Evan Cheng86ab7d32007-07-31 08:04:03 +0000316include "X86InstrFormats.td"
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000317
318//===----------------------------------------------------------------------===//
319// Pattern fragments...
320//
321
322// X86 specific condition code. These correspond to CondCode in
323// X86InstrInfo.h. They must be kept in synch.
Dan Gohman0fc9ed62009-01-07 00:15:08 +0000324def X86_COND_A : PatLeaf<(i8 0)>; // alt. COND_NBE
325def X86_COND_AE : PatLeaf<(i8 1)>; // alt. COND_NC
326def X86_COND_B : PatLeaf<(i8 2)>; // alt. COND_C
327def X86_COND_BE : PatLeaf<(i8 3)>; // alt. COND_NA
328def X86_COND_E : PatLeaf<(i8 4)>; // alt. COND_Z
329def X86_COND_G : PatLeaf<(i8 5)>; // alt. COND_NLE
330def X86_COND_GE : PatLeaf<(i8 6)>; // alt. COND_NL
331def X86_COND_L : PatLeaf<(i8 7)>; // alt. COND_NGE
332def X86_COND_LE : PatLeaf<(i8 8)>; // alt. COND_NG
333def X86_COND_NE : PatLeaf<(i8 9)>; // alt. COND_NZ
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000334def X86_COND_NO : PatLeaf<(i8 10)>;
Dan Gohman0fc9ed62009-01-07 00:15:08 +0000335def X86_COND_NP : PatLeaf<(i8 11)>; // alt. COND_PO
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000336def X86_COND_NS : PatLeaf<(i8 12)>;
Dan Gohman0fc9ed62009-01-07 00:15:08 +0000337def X86_COND_O : PatLeaf<(i8 13)>;
338def X86_COND_P : PatLeaf<(i8 14)>; // alt. COND_PE
339def X86_COND_S : PatLeaf<(i8 15)>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000340
341def i16immSExt8 : PatLeaf<(i16 imm), [{
342 // i16immSExt8 predicate - True if the 16-bit immediate fits in a 8-bit
343 // sign extended field.
Dan Gohmanfaeb4a32008-09-12 16:56:44 +0000344 return (int16_t)N->getZExtValue() == (int8_t)N->getZExtValue();
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000345}]>;
346
347def i32immSExt8 : PatLeaf<(i32 imm), [{
348 // i32immSExt8 predicate - True if the 32-bit immediate fits in a 8-bit
349 // sign extended field.
Dan Gohmanfaeb4a32008-09-12 16:56:44 +0000350 return (int32_t)N->getZExtValue() == (int8_t)N->getZExtValue();
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000351}]>;
352
353// Helper fragments for loads.
Evan Chengb3e25ea2008-05-13 18:59:59 +0000354// It's always safe to treat a anyext i16 load as a i32 load if the i16 is
355// known to be 32-bit aligned or better. Ditto for i8 to i16.
Dan Gohman2a174122008-10-15 06:50:19 +0000356def loadi16 : PatFrag<(ops node:$ptr), (i16 (unindexedload node:$ptr)), [{
Dan Gohman8335c412008-08-20 15:24:22 +0000357 LoadSDNode *LD = cast<LoadSDNode>(N);
Chris Lattner12208612009-04-10 00:16:23 +0000358 if (const Value *Src = LD->getSrcValue())
359 if (const PointerType *PT = dyn_cast<PointerType>(Src->getType()))
Mon P Wangdc97d5a2009-04-27 07:22:10 +0000360 if (PT->getAddressSpace() > 255)
Chris Lattner12208612009-04-10 00:16:23 +0000361 return false;
Dan Gohman8335c412008-08-20 15:24:22 +0000362 ISD::LoadExtType ExtType = LD->getExtensionType();
363 if (ExtType == ISD::NON_EXTLOAD)
364 return true;
365 if (ExtType == ISD::EXTLOAD)
366 return LD->getAlignment() >= 2 && !LD->isVolatile();
Evan Cheng8b765e92008-05-13 00:54:02 +0000367 return false;
368}]>;
369
Sean Callanan2c48df22009-12-18 00:01:26 +0000370def loadi16_anyext : PatFrag<(ops node:$ptr), (i32 (unindexedload node:$ptr)),
371[{
Evan Cheng56ec77b2008-09-24 23:27:55 +0000372 LoadSDNode *LD = cast<LoadSDNode>(N);
Chris Lattner12208612009-04-10 00:16:23 +0000373 if (const Value *Src = LD->getSrcValue())
374 if (const PointerType *PT = dyn_cast<PointerType>(Src->getType()))
Mon P Wangdc97d5a2009-04-27 07:22:10 +0000375 if (PT->getAddressSpace() > 255)
Chris Lattner12208612009-04-10 00:16:23 +0000376 return false;
Evan Cheng56ec77b2008-09-24 23:27:55 +0000377 ISD::LoadExtType ExtType = LD->getExtensionType();
378 if (ExtType == ISD::EXTLOAD)
379 return LD->getAlignment() >= 2 && !LD->isVolatile();
380 return false;
381}]>;
382
Dan Gohman2a174122008-10-15 06:50:19 +0000383def loadi32 : PatFrag<(ops node:$ptr), (i32 (unindexedload node:$ptr)), [{
Dan Gohman8335c412008-08-20 15:24:22 +0000384 LoadSDNode *LD = cast<LoadSDNode>(N);
Chris Lattner12208612009-04-10 00:16:23 +0000385 if (const Value *Src = LD->getSrcValue())
386 if (const PointerType *PT = dyn_cast<PointerType>(Src->getType()))
Mon P Wangdc97d5a2009-04-27 07:22:10 +0000387 if (PT->getAddressSpace() > 255)
Chris Lattner12208612009-04-10 00:16:23 +0000388 return false;
Dan Gohman8335c412008-08-20 15:24:22 +0000389 ISD::LoadExtType ExtType = LD->getExtensionType();
390 if (ExtType == ISD::NON_EXTLOAD)
391 return true;
392 if (ExtType == ISD::EXTLOAD)
393 return LD->getAlignment() >= 4 && !LD->isVolatile();
Evan Cheng8b765e92008-05-13 00:54:02 +0000394 return false;
395}]>;
396
Dan Gohman2a174122008-10-15 06:50:19 +0000397def nvloadi32 : PatFrag<(ops node:$ptr), (i32 (unindexedload node:$ptr)), [{
Evan Cheng1e5e5452008-09-29 17:26:18 +0000398 LoadSDNode *LD = cast<LoadSDNode>(N);
Chris Lattner12208612009-04-10 00:16:23 +0000399 if (const Value *Src = LD->getSrcValue())
400 if (const PointerType *PT = dyn_cast<PointerType>(Src->getType()))
Mon P Wangdc97d5a2009-04-27 07:22:10 +0000401 if (PT->getAddressSpace() > 255)
Chris Lattner12208612009-04-10 00:16:23 +0000402 return false;
Evan Cheng1e5e5452008-09-29 17:26:18 +0000403 if (LD->isVolatile())
404 return false;
Evan Cheng1e5e5452008-09-29 17:26:18 +0000405 ISD::LoadExtType ExtType = LD->getExtensionType();
406 if (ExtType == ISD::NON_EXTLOAD)
407 return true;
408 if (ExtType == ISD::EXTLOAD)
409 return LD->getAlignment() >= 4;
410 return false;
411}]>;
412
sampo9cc09a32009-01-26 01:24:32 +0000413def gsload : PatFrag<(ops node:$ptr), (load node:$ptr), [{
Chris Lattner12208612009-04-10 00:16:23 +0000414 if (const Value *Src = cast<LoadSDNode>(N)->getSrcValue())
415 if (const PointerType *PT = dyn_cast<PointerType>(Src->getType()))
416 return PT->getAddressSpace() == 256;
sampo9cc09a32009-01-26 01:24:32 +0000417 return false;
418}]>;
419
Chris Lattnera7c2d8a2009-05-05 18:52:19 +0000420def fsload : PatFrag<(ops node:$ptr), (load node:$ptr), [{
421 if (const Value *Src = cast<LoadSDNode>(N)->getSrcValue())
422 if (const PointerType *PT = dyn_cast<PointerType>(Src->getType()))
423 return PT->getAddressSpace() == 257;
424 return false;
425}]>;
426
Chris Lattner12208612009-04-10 00:16:23 +0000427def loadi8 : PatFrag<(ops node:$ptr), (i8 (load node:$ptr)), [{
428 if (const Value *Src = cast<LoadSDNode>(N)->getSrcValue())
429 if (const PointerType *PT = dyn_cast<PointerType>(Src->getType()))
Mon P Wangdc97d5a2009-04-27 07:22:10 +0000430 if (PT->getAddressSpace() > 255)
Chris Lattner12208612009-04-10 00:16:23 +0000431 return false;
432 return true;
433}]>;
434def loadi64 : PatFrag<(ops node:$ptr), (i64 (load node:$ptr)), [{
435 if (const Value *Src = cast<LoadSDNode>(N)->getSrcValue())
436 if (const PointerType *PT = dyn_cast<PointerType>(Src->getType()))
Mon P Wangdc97d5a2009-04-27 07:22:10 +0000437 if (PT->getAddressSpace() > 255)
Chris Lattner12208612009-04-10 00:16:23 +0000438 return false;
439 return true;
440}]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000441
Chris Lattner12208612009-04-10 00:16:23 +0000442def loadf32 : PatFrag<(ops node:$ptr), (f32 (load node:$ptr)), [{
443 if (const Value *Src = cast<LoadSDNode>(N)->getSrcValue())
444 if (const PointerType *PT = dyn_cast<PointerType>(Src->getType()))
Mon P Wangdc97d5a2009-04-27 07:22:10 +0000445 if (PT->getAddressSpace() > 255)
Chris Lattner12208612009-04-10 00:16:23 +0000446 return false;
447 return true;
448}]>;
449def loadf64 : PatFrag<(ops node:$ptr), (f64 (load node:$ptr)), [{
450 if (const Value *Src = cast<LoadSDNode>(N)->getSrcValue())
451 if (const PointerType *PT = dyn_cast<PointerType>(Src->getType()))
Mon P Wangdc97d5a2009-04-27 07:22:10 +0000452 if (PT->getAddressSpace() > 255)
Chris Lattner12208612009-04-10 00:16:23 +0000453 return false;
454 return true;
455}]>;
456def loadf80 : PatFrag<(ops node:$ptr), (f80 (load node:$ptr)), [{
457 if (const Value *Src = cast<LoadSDNode>(N)->getSrcValue())
458 if (const PointerType *PT = dyn_cast<PointerType>(Src->getType()))
Mon P Wangdc97d5a2009-04-27 07:22:10 +0000459 if (PT->getAddressSpace() > 255)
Chris Lattner12208612009-04-10 00:16:23 +0000460 return false;
461 return true;
462}]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000463
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000464def sextloadi16i8 : PatFrag<(ops node:$ptr), (i16 (sextloadi8 node:$ptr))>;
465def sextloadi32i8 : PatFrag<(ops node:$ptr), (i32 (sextloadi8 node:$ptr))>;
466def sextloadi32i16 : PatFrag<(ops node:$ptr), (i32 (sextloadi16 node:$ptr))>;
467
468def zextloadi8i1 : PatFrag<(ops node:$ptr), (i8 (zextloadi1 node:$ptr))>;
469def zextloadi16i1 : PatFrag<(ops node:$ptr), (i16 (zextloadi1 node:$ptr))>;
470def zextloadi32i1 : PatFrag<(ops node:$ptr), (i32 (zextloadi1 node:$ptr))>;
471def zextloadi16i8 : PatFrag<(ops node:$ptr), (i16 (zextloadi8 node:$ptr))>;
472def zextloadi32i8 : PatFrag<(ops node:$ptr), (i32 (zextloadi8 node:$ptr))>;
473def zextloadi32i16 : PatFrag<(ops node:$ptr), (i32 (zextloadi16 node:$ptr))>;
474
475def extloadi8i1 : PatFrag<(ops node:$ptr), (i8 (extloadi1 node:$ptr))>;
476def extloadi16i1 : PatFrag<(ops node:$ptr), (i16 (extloadi1 node:$ptr))>;
477def extloadi32i1 : PatFrag<(ops node:$ptr), (i32 (extloadi1 node:$ptr))>;
478def extloadi16i8 : PatFrag<(ops node:$ptr), (i16 (extloadi8 node:$ptr))>;
479def extloadi32i8 : PatFrag<(ops node:$ptr), (i32 (extloadi8 node:$ptr))>;
480def extloadi32i16 : PatFrag<(ops node:$ptr), (i32 (extloadi16 node:$ptr))>;
481
Chris Lattner21da6382008-02-19 17:37:35 +0000482
483// An 'and' node with a single use.
484def and_su : PatFrag<(ops node:$lhs, node:$rhs), (and node:$lhs, node:$rhs), [{
Evan Cheng9123cfa2008-03-04 00:40:35 +0000485 return N->hasOneUse();
Chris Lattner21da6382008-02-19 17:37:35 +0000486}]>;
Dan Gohman744d4622009-04-13 16:09:41 +0000487// An 'srl' node with a single use.
488def srl_su : PatFrag<(ops node:$lhs, node:$rhs), (srl node:$lhs, node:$rhs), [{
489 return N->hasOneUse();
490}]>;
491// An 'trunc' node with a single use.
492def trunc_su : PatFrag<(ops node:$src), (trunc node:$src), [{
493 return N->hasOneUse();
494}]>;
Chris Lattner21da6382008-02-19 17:37:35 +0000495
Dan Gohman921581d2008-10-17 01:23:35 +0000496// 'shld' and 'shrd' instruction patterns. Note that even though these have
497// the srl and shl in their patterns, the C++ code must still check for them,
498// because predicates are tested before children nodes are explored.
499
500def shrd : PatFrag<(ops node:$src1, node:$amt1, node:$src2, node:$amt2),
501 (or (srl node:$src1, node:$amt1),
502 (shl node:$src2, node:$amt2)), [{
503 assert(N->getOpcode() == ISD::OR);
504 return N->getOperand(0).getOpcode() == ISD::SRL &&
505 N->getOperand(1).getOpcode() == ISD::SHL &&
506 isa<ConstantSDNode>(N->getOperand(0).getOperand(1)) &&
507 isa<ConstantSDNode>(N->getOperand(1).getOperand(1)) &&
508 N->getOperand(0).getConstantOperandVal(1) ==
509 N->getValueSizeInBits(0) - N->getOperand(1).getConstantOperandVal(1);
510}]>;
511
512def shld : PatFrag<(ops node:$src1, node:$amt1, node:$src2, node:$amt2),
513 (or (shl node:$src1, node:$amt1),
514 (srl node:$src2, node:$amt2)), [{
515 assert(N->getOpcode() == ISD::OR);
516 return N->getOperand(0).getOpcode() == ISD::SHL &&
517 N->getOperand(1).getOpcode() == ISD::SRL &&
518 isa<ConstantSDNode>(N->getOperand(0).getOperand(1)) &&
519 isa<ConstantSDNode>(N->getOperand(1).getOperand(1)) &&
520 N->getOperand(0).getConstantOperandVal(1) ==
521 N->getValueSizeInBits(0) - N->getOperand(1).getConstantOperandVal(1);
522}]>;
523
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000524//===----------------------------------------------------------------------===//
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000525// Instruction list...
526//
527
528// ADJCALLSTACKDOWN/UP implicitly use/def ESP because they may be expanded into
529// a stack adjustment and the codegen must know that they may modify the stack
530// pointer before prolog-epilog rewriting occurs.
Chris Lattnerb56cc342008-03-11 03:23:40 +0000531// Pessimistically assume ADJCALLSTACKDOWN / ADJCALLSTACKUP will become
532// sub / add which can clobber EFLAGS.
Evan Cheng037364a2007-09-28 01:19:48 +0000533let Defs = [ESP, EFLAGS], Uses = [ESP] in {
Dan Gohman01c9f772008-10-01 18:28:06 +0000534def ADJCALLSTACKDOWN32 : I<0, Pseudo, (outs), (ins i32imm:$amt),
535 "#ADJCALLSTACKDOWN",
Chris Lattnerfe5d4022008-10-11 22:08:30 +0000536 [(X86callseq_start timm:$amt)]>,
Dan Gohman01c9f772008-10-01 18:28:06 +0000537 Requires<[In32BitMode]>;
538def ADJCALLSTACKUP32 : I<0, Pseudo, (outs), (ins i32imm:$amt1, i32imm:$amt2),
539 "#ADJCALLSTACKUP",
Chris Lattnerfe5d4022008-10-11 22:08:30 +0000540 [(X86callseq_end timm:$amt1, timm:$amt2)]>,
Dan Gohman01c9f772008-10-01 18:28:06 +0000541 Requires<[In32BitMode]>;
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000542}
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000543
Dan Gohman34228bf2009-08-15 01:38:56 +0000544// x86-64 va_start lowering magic.
Dan Gohman30afe012009-10-29 18:10:34 +0000545let usesCustomInserter = 1 in
Dan Gohman34228bf2009-08-15 01:38:56 +0000546def VASTART_SAVE_XMM_REGS : I<0, Pseudo,
547 (outs),
548 (ins GR8:$al,
549 i64imm:$regsavefi, i64imm:$offset,
550 variable_ops),
551 "#VASTART_SAVE_XMM_REGS $al, $regsavefi, $offset",
552 [(X86vastart_save_xmm_regs GR8:$al,
553 imm:$regsavefi,
554 imm:$offset)]>;
555
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000556// Nop
Sean Callananf94a0542009-07-23 23:39:34 +0000557let neverHasSideEffects = 1 in {
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000558 def NOOP : I<0x90, RawFrm, (outs), (ins), "nop", []>;
Sean Callanan2c48df22009-12-18 00:01:26 +0000559 def NOOPW : I<0x1f, MRM0m, (outs), (ins i16mem:$zero),
560 "nop{w}\t$zero", []>, TB, OpSize;
Sean Callananf94a0542009-07-23 23:39:34 +0000561 def NOOPL : I<0x1f, MRM0m, (outs), (ins i32mem:$zero),
Sean Callanan2c48df22009-12-18 00:01:26 +0000562 "nop{l}\t$zero", []>, TB;
Sean Callananf94a0542009-07-23 23:39:34 +0000563}
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000564
Sean Callanan9b195f82009-08-11 01:09:06 +0000565// Trap
Dan Gohman8112b942009-11-11 18:07:16 +0000566def INT3 : I<0xcc, RawFrm, (outs), (ins), "int\t3", []>;
Sean Callanan9b195f82009-08-11 01:09:06 +0000567def INT : I<0xcd, RawFrm, (outs), (ins i8imm:$trap), "int\t$trap", []>;
Sean Callanan2c48df22009-12-18 00:01:26 +0000568def IRET16 : I<0xcf, RawFrm, (outs), (ins), "iret{w}", []>, OpSize;
569def IRET32 : I<0xcf, RawFrm, (outs), (ins), "iret{l}", []>;
Sean Callanan9b195f82009-08-11 01:09:06 +0000570
Chris Lattner2aa10da2009-09-20 07:32:00 +0000571// PIC base construction. This expands to code that looks like this:
572// call $next_inst
573// popl %destreg"
Dan Gohman9499cfe2008-10-01 04:14:30 +0000574let neverHasSideEffects = 1, isNotDuplicable = 1, Uses = [ESP] in
Chris Lattnera7e959d2009-09-20 07:28:26 +0000575 def MOVPC32r : Ii32<0xE8, Pseudo, (outs GR32:$reg), (ins i32imm:$label),
Chris Lattner2aa10da2009-09-20 07:32:00 +0000576 "", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000577
578//===----------------------------------------------------------------------===//
579// Control Flow Instructions...
580//
581
582// Return instructions.
583let isTerminator = 1, isReturn = 1, isBarrier = 1,
Chris Lattnerb56cc342008-03-11 03:23:40 +0000584 hasCtrlDep = 1, FPForm = SpecialFP, FPFormBits = SpecialFP.Value in {
Dan Gohman2c4be2a2008-05-31 02:11:25 +0000585 def RET : I <0xC3, RawFrm, (outs), (ins variable_ops),
Chris Lattnerb56cc342008-03-11 03:23:40 +0000586 "ret",
Dan Gohman2c4be2a2008-05-31 02:11:25 +0000587 [(X86retflag 0)]>;
Chris Lattnerb56cc342008-03-11 03:23:40 +0000588 def RETI : Ii16<0xC2, RawFrm, (outs), (ins i16imm:$amt, variable_ops),
589 "ret\t$amt",
Dan Gohmane84197b2009-09-03 17:18:51 +0000590 [(X86retflag timm:$amt)]>;
Sean Callanan7a012572009-09-15 23:37:51 +0000591 def LRET : I <0xCB, RawFrm, (outs), (ins),
592 "lret", []>;
593 def LRETI : Ii16<0xCA, RawFrm, (outs), (ins i16imm:$amt),
594 "lret\t$amt", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000595}
596
597// All branches are RawFrm, Void, Branch, and Terminators
Evan Cheng37e7c752007-07-21 00:34:19 +0000598let isBranch = 1, isTerminator = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +0000599 class IBr<bits<8> opcode, dag ins, string asm, list<dag> pattern> :
600 I<opcode, RawFrm, (outs), ins, asm, pattern>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000601
Sean Callananc0608152009-07-22 01:05:20 +0000602let isBranch = 1, isBarrier = 1 in {
Dan Gohman91888f02007-07-31 20:11:57 +0000603 def JMP : IBr<0xE9, (ins brtarget:$dst), "jmp\t$dst", [(br bb:$dst)]>;
Sean Callananc0608152009-07-22 01:05:20 +0000604 def JMP8 : IBr<0xEB, (ins brtarget8:$dst), "jmp\t$dst", []>;
605}
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000606
Owen Andersonf8053082007-11-12 07:39:39 +0000607// Indirect branches
608let isBranch = 1, isTerminator = 1, isBarrier = 1, isIndirectBranch = 1 in {
Dan Gohman91888f02007-07-31 20:11:57 +0000609 def JMP32r : I<0xFF, MRM4r, (outs), (ins GR32:$dst), "jmp{l}\t{*}$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000610 [(brind GR32:$dst)]>;
Dan Gohman91888f02007-07-31 20:11:57 +0000611 def JMP32m : I<0xFF, MRM4m, (outs), (ins i32mem:$dst), "jmp{l}\t{*}$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000612 [(brind (loadi32 addr:$dst))]>;
Sean Callananb7e73392009-09-15 00:35:17 +0000613
614 def FARJMP16i : Iseg16<0xEA, RawFrm, (outs),
615 (ins i16imm:$seg, i16imm:$off),
616 "ljmp{w}\t$seg, $off", []>, OpSize;
617 def FARJMP32i : Iseg32<0xEA, RawFrm, (outs),
618 (ins i16imm:$seg, i32imm:$off),
619 "ljmp{l}\t$seg, $off", []>;
620
621 def FARJMP16m : I<0xFF, MRM5m, (outs), (ins opaque32mem:$dst),
Sean Callanan66fdfa02009-09-03 00:04:47 +0000622 "ljmp{w}\t{*}$dst", []>, OpSize;
Sean Callananb7e73392009-09-15 00:35:17 +0000623 def FARJMP32m : I<0xFF, MRM5m, (outs), (ins opaque48mem:$dst),
Sean Callanan66fdfa02009-09-03 00:04:47 +0000624 "ljmp{l}\t{*}$dst", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000625}
626
627// Conditional branches
Evan Cheng950aac02007-09-25 01:57:46 +0000628let Uses = [EFLAGS] in {
Evan Chengd11052b2009-07-21 06:00:18 +0000629// Short conditional jumps
630def JO8 : IBr<0x70, (ins brtarget8:$dst), "jo\t$dst", []>;
631def JNO8 : IBr<0x71, (ins brtarget8:$dst), "jno\t$dst", []>;
632def JB8 : IBr<0x72, (ins brtarget8:$dst), "jb\t$dst", []>;
633def JAE8 : IBr<0x73, (ins brtarget8:$dst), "jae\t$dst", []>;
634def JE8 : IBr<0x74, (ins brtarget8:$dst), "je\t$dst", []>;
635def JNE8 : IBr<0x75, (ins brtarget8:$dst), "jne\t$dst", []>;
636def JBE8 : IBr<0x76, (ins brtarget8:$dst), "jbe\t$dst", []>;
637def JA8 : IBr<0x77, (ins brtarget8:$dst), "ja\t$dst", []>;
638def JS8 : IBr<0x78, (ins brtarget8:$dst), "js\t$dst", []>;
639def JNS8 : IBr<0x79, (ins brtarget8:$dst), "jns\t$dst", []>;
640def JP8 : IBr<0x7A, (ins brtarget8:$dst), "jp\t$dst", []>;
641def JNP8 : IBr<0x7B, (ins brtarget8:$dst), "jnp\t$dst", []>;
642def JL8 : IBr<0x7C, (ins brtarget8:$dst), "jl\t$dst", []>;
643def JGE8 : IBr<0x7D, (ins brtarget8:$dst), "jge\t$dst", []>;
644def JLE8 : IBr<0x7E, (ins brtarget8:$dst), "jle\t$dst", []>;
645def JG8 : IBr<0x7F, (ins brtarget8:$dst), "jg\t$dst", []>;
646
647def JCXZ8 : IBr<0xE3, (ins brtarget8:$dst), "jcxz\t$dst", []>;
648
Dan Gohman91888f02007-07-31 20:11:57 +0000649def JE : IBr<0x84, (ins brtarget:$dst), "je\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000650 [(X86brcond bb:$dst, X86_COND_E, EFLAGS)]>, TB;
Dan Gohman91888f02007-07-31 20:11:57 +0000651def JNE : IBr<0x85, (ins brtarget:$dst), "jne\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000652 [(X86brcond bb:$dst, X86_COND_NE, EFLAGS)]>, TB;
Dan Gohman91888f02007-07-31 20:11:57 +0000653def JL : IBr<0x8C, (ins brtarget:$dst), "jl\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000654 [(X86brcond bb:$dst, X86_COND_L, EFLAGS)]>, TB;
Dan Gohman91888f02007-07-31 20:11:57 +0000655def JLE : IBr<0x8E, (ins brtarget:$dst), "jle\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000656 [(X86brcond bb:$dst, X86_COND_LE, EFLAGS)]>, TB;
Dan Gohman91888f02007-07-31 20:11:57 +0000657def JG : IBr<0x8F, (ins brtarget:$dst), "jg\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000658 [(X86brcond bb:$dst, X86_COND_G, EFLAGS)]>, TB;
Dan Gohman91888f02007-07-31 20:11:57 +0000659def JGE : IBr<0x8D, (ins brtarget:$dst), "jge\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000660 [(X86brcond bb:$dst, X86_COND_GE, EFLAGS)]>, TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000661
Dan Gohman91888f02007-07-31 20:11:57 +0000662def JB : IBr<0x82, (ins brtarget:$dst), "jb\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000663 [(X86brcond bb:$dst, X86_COND_B, EFLAGS)]>, TB;
Dan Gohman91888f02007-07-31 20:11:57 +0000664def JBE : IBr<0x86, (ins brtarget:$dst), "jbe\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000665 [(X86brcond bb:$dst, X86_COND_BE, EFLAGS)]>, TB;
Dan Gohman91888f02007-07-31 20:11:57 +0000666def JA : IBr<0x87, (ins brtarget:$dst), "ja\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000667 [(X86brcond bb:$dst, X86_COND_A, EFLAGS)]>, TB;
Dan Gohman91888f02007-07-31 20:11:57 +0000668def JAE : IBr<0x83, (ins brtarget:$dst), "jae\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000669 [(X86brcond bb:$dst, X86_COND_AE, EFLAGS)]>, TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000670
Dan Gohman91888f02007-07-31 20:11:57 +0000671def JS : IBr<0x88, (ins brtarget:$dst), "js\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000672 [(X86brcond bb:$dst, X86_COND_S, EFLAGS)]>, TB;
Dan Gohman91888f02007-07-31 20:11:57 +0000673def JNS : IBr<0x89, (ins brtarget:$dst), "jns\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000674 [(X86brcond bb:$dst, X86_COND_NS, EFLAGS)]>, TB;
Dan Gohman91888f02007-07-31 20:11:57 +0000675def JP : IBr<0x8A, (ins brtarget:$dst), "jp\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000676 [(X86brcond bb:$dst, X86_COND_P, EFLAGS)]>, TB;
Dan Gohman91888f02007-07-31 20:11:57 +0000677def JNP : IBr<0x8B, (ins brtarget:$dst), "jnp\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000678 [(X86brcond bb:$dst, X86_COND_NP, EFLAGS)]>, TB;
Dan Gohman91888f02007-07-31 20:11:57 +0000679def JO : IBr<0x80, (ins brtarget:$dst), "jo\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000680 [(X86brcond bb:$dst, X86_COND_O, EFLAGS)]>, TB;
Dan Gohman91888f02007-07-31 20:11:57 +0000681def JNO : IBr<0x81, (ins brtarget:$dst), "jno\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000682 [(X86brcond bb:$dst, X86_COND_NO, EFLAGS)]>, TB;
Evan Cheng950aac02007-09-25 01:57:46 +0000683} // Uses = [EFLAGS]
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000684
Sean Callanan503784b2009-09-16 21:50:07 +0000685// Loop instructions
686
687def LOOP : I<0xE2, RawFrm, (ins brtarget8:$dst), (outs), "loop\t$dst", []>;
688def LOOPE : I<0xE1, RawFrm, (ins brtarget8:$dst), (outs), "loope\t$dst", []>;
689def LOOPNE : I<0xE0, RawFrm, (ins brtarget8:$dst), (outs), "loopne\t$dst", []>;
690
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000691//===----------------------------------------------------------------------===//
692// Call Instructions...
693//
Evan Cheng37e7c752007-07-21 00:34:19 +0000694let isCall = 1 in
Dan Gohman01c9f772008-10-01 18:28:06 +0000695 // All calls clobber the non-callee saved registers. ESP is marked as
696 // a use to prevent stack-pointer assignments that appear immediately
697 // before calls from potentially appearing dead. Uses for argument
698 // registers are added manually.
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000699 let Defs = [EAX, ECX, EDX, FP0, FP1, FP2, FP3, FP4, FP5, FP6, ST0,
700 MM0, MM1, MM2, MM3, MM4, MM5, MM6, MM7,
Evan Cheng2293b252008-10-17 21:02:22 +0000701 XMM0, XMM1, XMM2, XMM3, XMM4, XMM5, XMM6, XMM7,
702 XMM8, XMM9, XMM10, XMM11, XMM12, XMM13, XMM14, XMM15, EFLAGS],
Dan Gohman9499cfe2008-10-01 04:14:30 +0000703 Uses = [ESP] in {
Chris Lattner357a0ca2009-06-20 19:34:09 +0000704 def CALLpcrel32 : Ii32<0xE8, RawFrm,
705 (outs), (ins i32imm_pcrel:$dst,variable_ops),
706 "call\t$dst", []>;
Evan Chengb783fa32007-07-19 01:14:50 +0000707 def CALL32r : I<0xFF, MRM2r, (outs), (ins GR32:$dst, variable_ops),
Dan Gohman91888f02007-07-31 20:11:57 +0000708 "call\t{*}$dst", [(X86call GR32:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000709 def CALL32m : I<0xFF, MRM2m, (outs), (ins i32mem:$dst, variable_ops),
Dan Gohmanea4faba2008-05-29 21:50:34 +0000710 "call\t{*}$dst", [(X86call (loadi32 addr:$dst))]>;
Sean Callanan66fdfa02009-09-03 00:04:47 +0000711
Sean Callananb7e73392009-09-15 00:35:17 +0000712 def FARCALL16i : Iseg16<0x9A, RawFrm, (outs),
713 (ins i16imm:$seg, i16imm:$off),
714 "lcall{w}\t$seg, $off", []>, OpSize;
715 def FARCALL32i : Iseg32<0x9A, RawFrm, (outs),
716 (ins i16imm:$seg, i32imm:$off),
717 "lcall{l}\t$seg, $off", []>;
718
719 def FARCALL16m : I<0xFF, MRM3m, (outs), (ins opaque32mem:$dst),
Sean Callanan66fdfa02009-09-03 00:04:47 +0000720 "lcall{w}\t{*}$dst", []>, OpSize;
Sean Callananb7e73392009-09-15 00:35:17 +0000721 def FARCALL32m : I<0xFF, MRM3m, (outs), (ins opaque48mem:$dst),
Sean Callanan66fdfa02009-09-03 00:04:47 +0000722 "lcall{l}\t{*}$dst", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000723 }
724
Sean Callanan51b7a992009-09-16 02:57:13 +0000725// Constructing a stack frame.
726
727def ENTER : I<0xC8, RawFrm, (outs), (ins i16imm:$len, i8imm:$lvl),
728 "enter\t$len, $lvl", []>;
729
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000730// Tail call stuff.
Arnold Schwaighofere2d6bbb2007-10-11 19:40:01 +0000731
Evan Cheng37e7c752007-07-21 00:34:19 +0000732let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1 in
Sean Callanan2c48df22009-12-18 00:01:26 +0000733def TCRETURNdi : I<0, Pseudo, (outs),
734 (ins i32imm:$dst, i32imm:$offset, variable_ops),
Arnold Schwaighofere2d6bbb2007-10-11 19:40:01 +0000735 "#TC_RETURN $dst $offset",
736 []>;
737
738let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1 in
Sean Callanan2c48df22009-12-18 00:01:26 +0000739def TCRETURNri : I<0, Pseudo, (outs),
740 (ins GR32:$dst, i32imm:$offset, variable_ops),
Arnold Schwaighofere2d6bbb2007-10-11 19:40:01 +0000741 "#TC_RETURN $dst $offset",
742 []>;
743
744let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1 in
Chris Lattner357a0ca2009-06-20 19:34:09 +0000745 def TAILJMPd : IBr<0xE9, (ins i32imm_pcrel:$dst), "jmp\t$dst # TAILCALL",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000746 []>;
Evan Cheng37e7c752007-07-21 00:34:19 +0000747let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1 in
Sean Callanan2c48df22009-12-18 00:01:26 +0000748 def TAILJMPr : I<0xFF, MRM4r, (outs), (ins GR32:$dst),
749 "jmp{l}\t{*}$dst # TAILCALL",
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
Evan Chengb783fa32007-07-19 01:14:50 +0000752 def TAILJMPm : I<0xFF, MRM4m, (outs), (ins i32mem:$dst),
Arnold Schwaighofere2d6bbb2007-10-11 19:40:01 +0000753 "jmp\t{*}$dst # TAILCALL", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000754
755//===----------------------------------------------------------------------===//
756// Miscellaneous Instructions...
757//
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000758let Defs = [EBP, ESP], Uses = [EBP, ESP], mayLoad = 1, neverHasSideEffects=1 in
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000759def LEAVE : I<0xC9, RawFrm,
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000760 (outs), (ins), "leave", []>;
761
Sean Callanan2c48df22009-12-18 00:01:26 +0000762def POPCNT16rr : I<0xB8, MRMSrcReg, (outs GR16:$dst), (ins GR16:$src),
763 "popcnt{w}\t{$src, $dst|$dst, $src}", []>, OpSize, XS;
764def POPCNT16rm : I<0xB8, MRMSrcMem, (outs GR16:$dst), (ins i16mem:$src),
765 "popcnt{w}\t{$src, $dst|$dst, $src}", []>, OpSize, XS;
766def POPCNT32rr : I<0xB8, MRMSrcReg, (outs GR32:$dst), (ins GR32:$src),
767 "popcnt{l}\t{$src, $dst|$dst, $src}", []>, XS;
768def POPCNT32rm : I<0xB8, MRMSrcMem, (outs GR32:$dst), (ins i32mem:$src),
769 "popcnt{l}\t{$src, $dst|$dst, $src}", []>, XS;
770
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000771let Defs = [ESP], Uses = [ESP], neverHasSideEffects=1 in {
Sean Callanan9f3c3f52009-09-10 18:29:13 +0000772let mayLoad = 1 in {
773def POP16r : I<0x58, AddRegFrm, (outs GR16:$reg), (ins), "pop{w}\t$reg", []>,
774 OpSize;
775def POP32r : I<0x58, AddRegFrm, (outs GR32:$reg), (ins), "pop{l}\t$reg", []>;
776def POP16rmr: I<0x8F, MRM0r, (outs GR16:$reg), (ins), "pop{w}\t$reg", []>,
777 OpSize;
778def POP16rmm: I<0x8F, MRM0m, (outs i16mem:$dst), (ins), "pop{w}\t$dst", []>,
779 OpSize;
780def POP32rmr: I<0x8F, MRM0r, (outs GR32:$reg), (ins), "pop{l}\t$reg", []>;
781def POP32rmm: I<0x8F, MRM0m, (outs i32mem:$dst), (ins), "pop{l}\t$dst", []>;
782}
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000783
Sean Callanan9f3c3f52009-09-10 18:29:13 +0000784let mayStore = 1 in {
785def PUSH16r : I<0x50, AddRegFrm, (outs), (ins GR16:$reg), "push{w}\t$reg",[]>,
786 OpSize;
Evan Chengd8434332007-09-26 01:29:06 +0000787def PUSH32r : I<0x50, AddRegFrm, (outs), (ins GR32:$reg), "push{l}\t$reg",[]>;
Sean Callanan9f3c3f52009-09-10 18:29:13 +0000788def PUSH16rmr: I<0xFF, MRM6r, (outs), (ins GR16:$reg), "push{w}\t$reg",[]>,
789 OpSize;
790def PUSH16rmm: I<0xFF, MRM6m, (outs), (ins i16mem:$src), "push{w}\t$src",[]>,
791 OpSize;
792def PUSH32rmr: I<0xFF, MRM6r, (outs), (ins GR32:$reg), "push{l}\t$reg",[]>;
793def PUSH32rmm: I<0xFF, MRM6m, (outs), (ins i32mem:$src), "push{l}\t$src",[]>;
794}
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000795}
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000796
Bill Wendling4c2638c2009-06-15 19:39:04 +0000797let Defs = [ESP], Uses = [ESP], neverHasSideEffects = 1, mayStore = 1 in {
798def PUSH32i8 : Ii8<0x6a, RawFrm, (outs), (ins i8imm:$imm),
Bill Wendling0b0437f2009-06-15 20:59:31 +0000799 "push{l}\t$imm", []>;
Bill Wendling4c2638c2009-06-15 19:39:04 +0000800def PUSH32i16 : Ii16<0x68, RawFrm, (outs), (ins i16imm:$imm),
Bill Wendling0b0437f2009-06-15 20:59:31 +0000801 "push{l}\t$imm", []>;
Bill Wendling4c2638c2009-06-15 19:39:04 +0000802def PUSH32i32 : Ii32<0x68, RawFrm, (outs), (ins i32imm:$imm),
Bill Wendling0b0437f2009-06-15 20:59:31 +0000803 "push{l}\t$imm", []>;
Bill Wendling4c2638c2009-06-15 19:39:04 +0000804}
805
Sean Callanan2c48df22009-12-18 00:01:26 +0000806let Defs = [ESP, EFLAGS], Uses = [ESP], mayLoad = 1, neverHasSideEffects=1 in {
807def POPF : I<0x9D, RawFrm, (outs), (ins), "popf{w}", []>, OpSize;
808def POPFD : I<0x9D, RawFrm, (outs), (ins), "popf{l}", []>;
809}
810let Defs = [ESP], Uses = [ESP, EFLAGS], mayStore = 1, neverHasSideEffects=1 in {
811def PUSHF : I<0x9C, RawFrm, (outs), (ins), "pushf{w}", []>, OpSize;
812def PUSHFD : I<0x9C, RawFrm, (outs), (ins), "pushf{l}", []>;
813}
Evan Chengd8434332007-09-26 01:29:06 +0000814
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000815let isTwoAddress = 1 in // GR32 = bswap GR32
816 def BSWAP32r : I<0xC8, AddRegFrm,
Evan Chengb783fa32007-07-19 01:14:50 +0000817 (outs GR32:$dst), (ins GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000818 "bswap{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000819 [(set GR32:$dst, (bswap GR32:$src))]>, TB;
820
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000821
Evan Cheng48679f42007-12-14 02:13:44 +0000822// Bit scan instructions.
823let Defs = [EFLAGS] in {
Evan Cheng4e33de92007-12-14 18:49:43 +0000824def BSF16rr : I<0xBC, MRMSrcReg, (outs GR16:$dst), (ins GR16:$src),
Dan Gohmancdb54c62007-12-14 15:10:00 +0000825 "bsf{w}\t{$src, $dst|$dst, $src}",
Evan Cheng7cfbfe32007-12-14 08:30:15 +0000826 [(set GR16:$dst, (X86bsf GR16:$src)), (implicit EFLAGS)]>, TB;
Evan Cheng48679f42007-12-14 02:13:44 +0000827def BSF16rm : I<0xBC, MRMSrcMem, (outs GR16:$dst), (ins i16mem:$src),
Dan Gohmancdb54c62007-12-14 15:10:00 +0000828 "bsf{w}\t{$src, $dst|$dst, $src}",
Evan Cheng7cfbfe32007-12-14 08:30:15 +0000829 [(set GR16:$dst, (X86bsf (loadi16 addr:$src))),
830 (implicit EFLAGS)]>, TB;
Evan Cheng4e33de92007-12-14 18:49:43 +0000831def BSF32rr : I<0xBC, MRMSrcReg, (outs GR32:$dst), (ins GR32:$src),
Dan Gohmancdb54c62007-12-14 15:10:00 +0000832 "bsf{l}\t{$src, $dst|$dst, $src}",
Evan Cheng7cfbfe32007-12-14 08:30:15 +0000833 [(set GR32:$dst, (X86bsf GR32:$src)), (implicit EFLAGS)]>, TB;
Evan Cheng48679f42007-12-14 02:13:44 +0000834def BSF32rm : I<0xBC, MRMSrcMem, (outs GR32:$dst), (ins i32mem:$src),
Dan Gohmancdb54c62007-12-14 15:10:00 +0000835 "bsf{l}\t{$src, $dst|$dst, $src}",
Evan Cheng7cfbfe32007-12-14 08:30:15 +0000836 [(set GR32:$dst, (X86bsf (loadi32 addr:$src))),
837 (implicit EFLAGS)]>, TB;
Evan Cheng48679f42007-12-14 02:13:44 +0000838
Evan Cheng4e33de92007-12-14 18:49:43 +0000839def BSR16rr : I<0xBD, MRMSrcReg, (outs GR16:$dst), (ins GR16:$src),
Dan Gohmancdb54c62007-12-14 15:10:00 +0000840 "bsr{w}\t{$src, $dst|$dst, $src}",
Evan Cheng7cfbfe32007-12-14 08:30:15 +0000841 [(set GR16:$dst, (X86bsr GR16:$src)), (implicit EFLAGS)]>, TB;
Evan Cheng48679f42007-12-14 02:13:44 +0000842def BSR16rm : I<0xBD, MRMSrcMem, (outs GR16:$dst), (ins i16mem:$src),
Dan Gohmancdb54c62007-12-14 15:10:00 +0000843 "bsr{w}\t{$src, $dst|$dst, $src}",
Evan Cheng7cfbfe32007-12-14 08:30:15 +0000844 [(set GR16:$dst, (X86bsr (loadi16 addr:$src))),
845 (implicit EFLAGS)]>, TB;
Evan Cheng4e33de92007-12-14 18:49:43 +0000846def BSR32rr : I<0xBD, MRMSrcReg, (outs GR32:$dst), (ins GR32:$src),
Dan Gohmancdb54c62007-12-14 15:10:00 +0000847 "bsr{l}\t{$src, $dst|$dst, $src}",
Evan Cheng7cfbfe32007-12-14 08:30:15 +0000848 [(set GR32:$dst, (X86bsr GR32:$src)), (implicit EFLAGS)]>, TB;
Evan Cheng48679f42007-12-14 02:13:44 +0000849def BSR32rm : I<0xBD, MRMSrcMem, (outs GR32:$dst), (ins i32mem:$src),
Dan Gohmancdb54c62007-12-14 15:10:00 +0000850 "bsr{l}\t{$src, $dst|$dst, $src}",
Evan Cheng7cfbfe32007-12-14 08:30:15 +0000851 [(set GR32:$dst, (X86bsr (loadi32 addr:$src))),
852 (implicit EFLAGS)]>, TB;
Evan Cheng48679f42007-12-14 02:13:44 +0000853} // Defs = [EFLAGS]
854
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000855let neverHasSideEffects = 1 in
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000856def LEA16r : I<0x8D, MRMSrcMem,
Evan Chengca348202009-12-12 18:51:56 +0000857 (outs GR16:$dst), (ins lea32mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000858 "lea{w}\t{$src|$dst}, {$dst|$src}", []>, OpSize;
Evan Cheng1ea8e6b2008-03-27 01:41:09 +0000859let isReMaterializable = 1 in
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000860def LEA32r : I<0x8D, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +0000861 (outs GR32:$dst), (ins lea32mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000862 "lea{l}\t{$src|$dst}, {$dst|$src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000863 [(set GR32:$dst, lea32addr:$src)]>, Requires<[In32BitMode]>;
864
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000865let Defs = [ECX,EDI,ESI], Uses = [ECX,EDI,ESI] in {
Evan Chengb783fa32007-07-19 01:14:50 +0000866def REP_MOVSB : I<0xA4, RawFrm, (outs), (ins), "{rep;movsb|rep movsb}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000867 [(X86rep_movs i8)]>, REP;
Evan Chengb783fa32007-07-19 01:14:50 +0000868def REP_MOVSW : I<0xA5, RawFrm, (outs), (ins), "{rep;movsw|rep movsw}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000869 [(X86rep_movs i16)]>, REP, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +0000870def REP_MOVSD : I<0xA5, RawFrm, (outs), (ins), "{rep;movsl|rep movsd}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000871 [(X86rep_movs i32)]>, REP;
872}
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000873
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000874let Defs = [ECX,EDI], Uses = [AL,ECX,EDI] in
Evan Chengb783fa32007-07-19 01:14:50 +0000875def REP_STOSB : I<0xAA, RawFrm, (outs), (ins), "{rep;stosb|rep stosb}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000876 [(X86rep_stos i8)]>, REP;
877let Defs = [ECX,EDI], Uses = [AX,ECX,EDI] in
Evan Chengb783fa32007-07-19 01:14:50 +0000878def REP_STOSW : I<0xAB, RawFrm, (outs), (ins), "{rep;stosw|rep stosw}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000879 [(X86rep_stos i16)]>, REP, OpSize;
880let Defs = [ECX,EDI], Uses = [EAX,ECX,EDI] in
Evan Chengb783fa32007-07-19 01:14:50 +0000881def REP_STOSD : I<0xAB, RawFrm, (outs), (ins), "{rep;stosl|rep stosd}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000882 [(X86rep_stos i32)]>, REP;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000883
Sean Callanan481f06d2009-09-12 00:37:19 +0000884def SCAS8 : I<0xAE, RawFrm, (outs), (ins), "scas{b}", []>;
885def SCAS16 : I<0xAF, RawFrm, (outs), (ins), "scas{w}", []>, OpSize;
886def SCAS32 : I<0xAF, RawFrm, (outs), (ins), "scas{l}", []>;
887
Sean Callanan25220d62009-09-12 02:25:20 +0000888def CMPS8 : I<0xA6, RawFrm, (outs), (ins), "cmps{b}", []>;
889def CMPS16 : I<0xA7, RawFrm, (outs), (ins), "cmps{w}", []>, OpSize;
890def CMPS32 : I<0xA7, RawFrm, (outs), (ins), "cmps{l}", []>;
891
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000892let Defs = [RAX, RDX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000893def RDTSC : I<0x31, RawFrm, (outs), (ins), "rdtsc", [(X86rdtsc)]>,
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000894 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000895
Anton Korobeynikov39d40ba2008-01-15 07:02:33 +0000896let isBarrier = 1, hasCtrlDep = 1 in {
Chris Lattner56b941f2008-01-15 21:58:22 +0000897def TRAP : I<0x0B, RawFrm, (outs), (ins), "ud2", [(trap)]>, TB;
Anton Korobeynikov39d40ba2008-01-15 07:02:33 +0000898}
899
Chris Lattnerc96e27c2009-08-11 16:58:39 +0000900def SYSCALL : I<0x05, RawFrm,
901 (outs), (ins), "syscall", []>, TB;
902def SYSRET : I<0x07, RawFrm,
903 (outs), (ins), "sysret", []>, TB;
904def SYSENTER : I<0x34, RawFrm,
905 (outs), (ins), "sysenter", []>, TB;
906def SYSEXIT : I<0x35, RawFrm,
907 (outs), (ins), "sysexit", []>, TB;
908
Sean Callanan2c2313a2009-09-12 02:52:41 +0000909def WAIT : I<0x9B, RawFrm, (outs), (ins), "wait", []>;
Chris Lattnerc96e27c2009-08-11 16:58:39 +0000910
911
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000912//===----------------------------------------------------------------------===//
913// Input/Output Instructions...
914//
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000915let Defs = [AL], Uses = [DX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000916def IN8rr : I<0xEC, RawFrm, (outs), (ins),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000917 "in{b}\t{%dx, %al|%AL, %DX}", []>;
918let Defs = [AX], Uses = [DX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000919def IN16rr : I<0xED, RawFrm, (outs), (ins),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000920 "in{w}\t{%dx, %ax|%AX, %DX}", []>, OpSize;
921let Defs = [EAX], Uses = [DX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000922def IN32rr : I<0xED, RawFrm, (outs), (ins),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000923 "in{l}\t{%dx, %eax|%EAX, %DX}", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000924
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000925let Defs = [AL] in
Evan Chengb783fa32007-07-19 01:14:50 +0000926def IN8ri : Ii8<0xE4, RawFrm, (outs), (ins i16i8imm:$port),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000927 "in{b}\t{$port, %al|%AL, $port}", []>;
928let Defs = [AX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000929def IN16ri : Ii8<0xE5, RawFrm, (outs), (ins i16i8imm:$port),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000930 "in{w}\t{$port, %ax|%AX, $port}", []>, OpSize;
931let Defs = [EAX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000932def IN32ri : Ii8<0xE5, RawFrm, (outs), (ins i16i8imm:$port),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000933 "in{l}\t{$port, %eax|%EAX, $port}", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000934
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000935let Uses = [DX, AL] in
Evan Chengb783fa32007-07-19 01:14:50 +0000936def OUT8rr : I<0xEE, RawFrm, (outs), (ins),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000937 "out{b}\t{%al, %dx|%DX, %AL}", []>;
938let Uses = [DX, AX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000939def OUT16rr : I<0xEF, RawFrm, (outs), (ins),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000940 "out{w}\t{%ax, %dx|%DX, %AX}", []>, OpSize;
941let Uses = [DX, EAX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000942def OUT32rr : I<0xEF, RawFrm, (outs), (ins),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000943 "out{l}\t{%eax, %dx|%DX, %EAX}", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000944
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000945let Uses = [AL] in
Evan Chengb783fa32007-07-19 01:14:50 +0000946def OUT8ir : Ii8<0xE6, RawFrm, (outs), (ins i16i8imm:$port),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000947 "out{b}\t{%al, $port|$port, %AL}", []>;
948let Uses = [AX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000949def OUT16ir : Ii8<0xE7, RawFrm, (outs), (ins i16i8imm:$port),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000950 "out{w}\t{%ax, $port|$port, %AX}", []>, OpSize;
951let Uses = [EAX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000952def OUT32ir : Ii8<0xE7, RawFrm, (outs), (ins i16i8imm:$port),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000953 "out{l}\t{%eax, $port|$port, %EAX}", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000954
Sean Callanan2c48df22009-12-18 00:01:26 +0000955def IN8 : I<0x6C, RawFrm, (outs), (ins),
956 "ins{b}", []>;
957def IN16 : I<0x6D, RawFrm, (outs), (ins),
958 "ins{w}", []>, OpSize;
959def IN32 : I<0x6D, RawFrm, (outs), (ins),
960 "ins{l}", []>;
961
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000962//===----------------------------------------------------------------------===//
963// Move Instructions...
964//
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000965let neverHasSideEffects = 1 in {
Evan Chengb783fa32007-07-19 01:14:50 +0000966def MOV8rr : I<0x88, MRMDestReg, (outs GR8 :$dst), (ins GR8 :$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000967 "mov{b}\t{$src, $dst|$dst, $src}", []>;
Evan Chengb783fa32007-07-19 01:14:50 +0000968def MOV16rr : I<0x89, MRMDestReg, (outs GR16:$dst), (ins GR16:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000969 "mov{w}\t{$src, $dst|$dst, $src}", []>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +0000970def MOV32rr : I<0x89, MRMDestReg, (outs GR32:$dst), (ins GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000971 "mov{l}\t{$src, $dst|$dst, $src}", []>;
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000972}
Evan Cheng6f26e8b2008-06-18 08:13:07 +0000973let isReMaterializable = 1, isAsCheapAsAMove = 1 in {
Evan Chengb783fa32007-07-19 01:14:50 +0000974def MOV8ri : Ii8 <0xB0, AddRegFrm, (outs GR8 :$dst), (ins i8imm :$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000975 "mov{b}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000976 [(set GR8:$dst, imm:$src)]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000977def MOV16ri : Ii16<0xB8, AddRegFrm, (outs GR16:$dst), (ins i16imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000978 "mov{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000979 [(set GR16:$dst, imm:$src)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +0000980def MOV32ri : Ii32<0xB8, AddRegFrm, (outs GR32:$dst), (ins i32imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000981 "mov{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000982 [(set GR32:$dst, imm:$src)]>;
983}
Evan Chengb783fa32007-07-19 01:14:50 +0000984def MOV8mi : Ii8 <0xC6, MRM0m, (outs), (ins i8mem :$dst, i8imm :$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000985 "mov{b}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000986 [(store (i8 imm:$src), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000987def MOV16mi : Ii16<0xC7, MRM0m, (outs), (ins i16mem:$dst, i16imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000988 "mov{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000989 [(store (i16 imm:$src), addr:$dst)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +0000990def MOV32mi : Ii32<0xC7, MRM0m, (outs), (ins i32mem:$dst, i32imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000991 "mov{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000992 [(store (i32 imm:$src), addr:$dst)]>;
993
Sean Callanan2c48df22009-12-18 00:01:26 +0000994def MOV8o8a : Ii8 <0xA0, RawFrm, (outs), (ins offset8:$src),
Sean Callanan70953a52009-09-10 18:33:42 +0000995 "mov{b}\t{$src, %al|%al, $src}", []>;
Sean Callanan2c48df22009-12-18 00:01:26 +0000996def MOV16o16a : Ii16 <0xA1, RawFrm, (outs), (ins offset16:$src),
Sean Callanan70953a52009-09-10 18:33:42 +0000997 "mov{w}\t{$src, %ax|%ax, $src}", []>, OpSize;
Sean Callanan2c48df22009-12-18 00:01:26 +0000998def MOV32o32a : Ii32 <0xA1, RawFrm, (outs), (ins offset32:$src),
Sean Callanan70953a52009-09-10 18:33:42 +0000999 "mov{l}\t{$src, %eax|%eax, $src}", []>;
1000
Sean Callanan2c48df22009-12-18 00:01:26 +00001001def MOV8ao8 : Ii8 <0xA2, RawFrm, (outs offset8:$dst), (ins),
Sean Callanan70953a52009-09-10 18:33:42 +00001002 "mov{b}\t{%al, $dst|$dst, %al}", []>;
Sean Callanan2c48df22009-12-18 00:01:26 +00001003def MOV16ao16 : Ii16 <0xA3, RawFrm, (outs offset16:$dst), (ins),
Sean Callanan70953a52009-09-10 18:33:42 +00001004 "mov{w}\t{%ax, $dst|$dst, %ax}", []>, OpSize;
Sean Callanan2c48df22009-12-18 00:01:26 +00001005def MOV32ao32 : Ii32 <0xA3, RawFrm, (outs offset32:$dst), (ins),
Sean Callanan70953a52009-09-10 18:33:42 +00001006 "mov{l}\t{%eax, $dst|$dst, %eax}", []>;
1007
Sean Callananad87a3a2009-09-15 18:47:29 +00001008// Moves to and from segment registers
1009def MOV16rs : I<0x8C, MRMDestReg, (outs GR16:$dst), (ins SEGMENT_REG:$src),
1010 "mov{w}\t{$src, $dst|$dst, $src}", []>;
1011def MOV16ms : I<0x8C, MRMDestMem, (outs i16mem:$dst), (ins SEGMENT_REG:$src),
1012 "mov{w}\t{$src, $dst|$dst, $src}", []>;
1013def MOV16sr : I<0x8E, MRMSrcReg, (outs SEGMENT_REG:$dst), (ins GR16:$src),
1014 "mov{w}\t{$src, $dst|$dst, $src}", []>;
1015def MOV16sm : I<0x8E, MRMSrcMem, (outs SEGMENT_REG:$dst), (ins i16mem:$src),
1016 "mov{w}\t{$src, $dst|$dst, $src}", []>;
1017
Sean Callanan2c48df22009-12-18 00:01:26 +00001018def MOV8rr_REV : I<0x8A, MRMSrcReg, (outs GR8:$dst), (ins GR8:$src),
1019 "mov{b}\t{$src, $dst|$dst, $src}", []>;
1020def MOV16rr_REV : I<0x8B, MRMSrcReg, (outs GR16:$dst), (ins GR16:$src),
1021 "mov{w}\t{$src, $dst|$dst, $src}", []>, OpSize;
1022def MOV32rr_REV : I<0x8B, MRMSrcReg, (outs GR32:$dst), (ins GR32:$src),
1023 "mov{l}\t{$src, $dst|$dst, $src}", []>;
1024
Dan Gohman5574cc72008-12-03 18:15:48 +00001025let canFoldAsLoad = 1, isReMaterializable = 1, mayHaveSideEffects = 1 in {
Evan Chengb783fa32007-07-19 01:14:50 +00001026def MOV8rm : I<0x8A, MRMSrcMem, (outs GR8 :$dst), (ins i8mem :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001027 "mov{b}\t{$src, $dst|$dst, $src}",
Chris Lattner12208612009-04-10 00:16:23 +00001028 [(set GR8:$dst, (loadi8 addr:$src))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001029def MOV16rm : I<0x8B, MRMSrcMem, (outs GR16:$dst), (ins i16mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001030 "mov{w}\t{$src, $dst|$dst, $src}",
Chris Lattner12208612009-04-10 00:16:23 +00001031 [(set GR16:$dst, (loadi16 addr:$src))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001032def MOV32rm : I<0x8B, MRMSrcMem, (outs GR32:$dst), (ins i32mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001033 "mov{l}\t{$src, $dst|$dst, $src}",
Chris Lattner12208612009-04-10 00:16:23 +00001034 [(set GR32:$dst, (loadi32 addr:$src))]>;
Evan Cheng4e84e452007-08-30 05:49:43 +00001035}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001036
Evan Chengb783fa32007-07-19 01:14:50 +00001037def MOV8mr : I<0x88, MRMDestMem, (outs), (ins i8mem :$dst, GR8 :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001038 "mov{b}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001039 [(store GR8:$src, addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001040def MOV16mr : I<0x89, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001041 "mov{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001042 [(store GR16:$src, addr:$dst)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001043def MOV32mr : I<0x89, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001044 "mov{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001045 [(store GR32:$src, addr:$dst)]>;
Dan Gohman744d4622009-04-13 16:09:41 +00001046
Dan Gohman1d8ce9c2009-04-27 16:41:36 +00001047// Versions of MOV8rr, MOV8mr, and MOV8rm that use i8mem_NOREX and GR8_NOREX so
1048// that they can be used for copying and storing h registers, which can't be
1049// encoded when a REX prefix is present.
Dan Gohman2da0db32009-04-15 00:04:23 +00001050let neverHasSideEffects = 1 in
Dan Gohman40ddc362009-04-15 19:48:57 +00001051def MOV8rr_NOREX : I<0x88, MRMDestReg,
1052 (outs GR8_NOREX:$dst), (ins GR8_NOREX:$src),
Dan Gohman2da0db32009-04-15 00:04:23 +00001053 "mov{b}\t{$src, $dst|$dst, $src} # NOREX", []>;
Evan Chengebc49402009-04-30 00:58:57 +00001054let mayStore = 1 in
Dan Gohman2da0db32009-04-15 00:04:23 +00001055def MOV8mr_NOREX : I<0x88, MRMDestMem,
1056 (outs), (ins i8mem_NOREX:$dst, GR8_NOREX:$src),
1057 "mov{b}\t{$src, $dst|$dst, $src} # NOREX", []>;
Evan Chengebc49402009-04-30 00:58:57 +00001058let mayLoad = 1,
1059 canFoldAsLoad = 1, isReMaterializable = 1, mayHaveSideEffects = 1 in
Dan Gohman1d8ce9c2009-04-27 16:41:36 +00001060def MOV8rm_NOREX : I<0x8A, MRMSrcMem,
1061 (outs GR8_NOREX:$dst), (ins i8mem_NOREX:$src),
1062 "mov{b}\t{$src, $dst|$dst, $src} # NOREX", []>;
Dan Gohman744d4622009-04-13 16:09:41 +00001063
Sean Callanan2c48df22009-12-18 00:01:26 +00001064// Moves to and from debug registers
1065def MOV32rd : I<0x21, MRMDestReg, (outs GR32:$dst), (ins DEBUG_REG:$src),
1066 "mov{l}\t{$src, $dst|$dst, $src}", []>, TB;
1067def MOV32dr : I<0x23, MRMSrcReg, (outs DEBUG_REG:$dst), (ins GR32:$src),
1068 "mov{l}\t{$src, $dst|$dst, $src}", []>, TB;
1069
1070// Moves to and from control registers
1071def MOV32rc : I<0x20, MRMDestReg, (outs GR32:$dst), (ins CONTROL_REG_32:$src),
1072 "mov{q}\t{$src, $dst|$dst, $src}", []>, TB;
1073def MOV32cr : I<0x22, MRMSrcReg, (outs CONTROL_REG_32:$dst), (ins GR32:$src),
1074 "mov{q}\t{$src, $dst|$dst, $src}", []>, TB;
1075
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001076//===----------------------------------------------------------------------===//
1077// Fixed-Register Multiplication and Division Instructions...
1078//
1079
1080// Extra precision multiplication
Evan Cheng55687072007-09-14 21:48:26 +00001081let Defs = [AL,AH,EFLAGS], Uses = [AL] in
Dan Gohman91888f02007-07-31 20:11:57 +00001082def MUL8r : I<0xF6, MRM4r, (outs), (ins GR8:$src), "mul{b}\t$src",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001083 // FIXME: Used for 8-bit mul, ignore result upper 8 bits.
1084 // This probably ought to be moved to a def : Pat<> if the
1085 // syntax can be accepted.
Bill Wendlingf5399032008-12-12 21:15:41 +00001086 [(set AL, (mul AL, GR8:$src)),
1087 (implicit EFLAGS)]>; // AL,AH = AL*GR8
1088
Chris Lattnerc7e96e72008-01-11 07:18:17 +00001089let Defs = [AX,DX,EFLAGS], Uses = [AX], neverHasSideEffects = 1 in
Bill Wendlingf5399032008-12-12 21:15:41 +00001090def MUL16r : I<0xF7, MRM4r, (outs), (ins GR16:$src),
1091 "mul{w}\t$src",
1092 []>, OpSize; // AX,DX = AX*GR16
1093
Chris Lattnerc7e96e72008-01-11 07:18:17 +00001094let Defs = [EAX,EDX,EFLAGS], Uses = [EAX], neverHasSideEffects = 1 in
Bill Wendlingf5399032008-12-12 21:15:41 +00001095def MUL32r : I<0xF7, MRM4r, (outs), (ins GR32:$src),
1096 "mul{l}\t$src",
1097 []>; // EAX,EDX = EAX*GR32
1098
Evan Cheng55687072007-09-14 21:48:26 +00001099let Defs = [AL,AH,EFLAGS], Uses = [AL] in
Evan Chengb783fa32007-07-19 01:14:50 +00001100def MUL8m : I<0xF6, MRM4m, (outs), (ins i8mem :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001101 "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, (loadi8 addr:$src))),
1106 (implicit EFLAGS)]>; // AL,AH = AL*[mem8]
1107
Chris Lattnerc90ee9c2008-01-10 07:59:24 +00001108let mayLoad = 1, neverHasSideEffects = 1 in {
Evan Cheng55687072007-09-14 21:48:26 +00001109let Defs = [AX,DX,EFLAGS], Uses = [AX] in
Evan Chengb783fa32007-07-19 01:14:50 +00001110def MUL16m : I<0xF7, MRM4m, (outs), (ins i16mem:$src),
Bill Wendlingf5399032008-12-12 21:15:41 +00001111 "mul{w}\t$src",
1112 []>, OpSize; // AX,DX = AX*[mem16]
1113
Evan Cheng55687072007-09-14 21:48:26 +00001114let Defs = [EAX,EDX,EFLAGS], Uses = [EAX] in
Evan Chengb783fa32007-07-19 01:14:50 +00001115def MUL32m : I<0xF7, MRM4m, (outs), (ins i32mem:$src),
Bill Wendlingf5399032008-12-12 21:15:41 +00001116 "mul{l}\t$src",
1117 []>; // EAX,EDX = EAX*[mem32]
Chris Lattnerc90ee9c2008-01-10 07:59:24 +00001118}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001119
Chris Lattnerc90ee9c2008-01-10 07:59:24 +00001120let neverHasSideEffects = 1 in {
Evan Cheng55687072007-09-14 21:48:26 +00001121let Defs = [AL,AH,EFLAGS], Uses = [AL] in
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001122def IMUL8r : I<0xF6, MRM5r, (outs), (ins GR8:$src), "imul{b}\t$src", []>;
1123 // AL,AH = AL*GR8
Evan Cheng55687072007-09-14 21:48:26 +00001124let Defs = [AX,DX,EFLAGS], Uses = [AX] in
Dan Gohman91888f02007-07-31 20:11:57 +00001125def IMUL16r : I<0xF7, MRM5r, (outs), (ins GR16:$src), "imul{w}\t$src", []>,
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001126 OpSize; // AX,DX = AX*GR16
Evan Cheng55687072007-09-14 21:48:26 +00001127let Defs = [EAX,EDX,EFLAGS], Uses = [EAX] in
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001128def IMUL32r : I<0xF7, MRM5r, (outs), (ins GR32:$src), "imul{l}\t$src", []>;
1129 // EAX,EDX = EAX*GR32
Chris Lattnerc90ee9c2008-01-10 07:59:24 +00001130let mayLoad = 1 in {
Evan Cheng55687072007-09-14 21:48:26 +00001131let Defs = [AL,AH,EFLAGS], Uses = [AL] in
Evan Chengb783fa32007-07-19 01:14:50 +00001132def IMUL8m : I<0xF6, MRM5m, (outs), (ins i8mem :$src),
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001133 "imul{b}\t$src", []>; // AL,AH = AL*[mem8]
Evan Cheng55687072007-09-14 21:48:26 +00001134let Defs = [AX,DX,EFLAGS], Uses = [AX] in
Evan Chengb783fa32007-07-19 01:14:50 +00001135def IMUL16m : I<0xF7, MRM5m, (outs), (ins i16mem:$src),
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001136 "imul{w}\t$src", []>, OpSize; // AX,DX = AX*[mem16]
Eli Friedman3939db02009-12-26 20:08:30 +00001137let Defs = [EAX,EDX,EFLAGS], Uses = [EAX] in
Evan Chengb783fa32007-07-19 01:14:50 +00001138def IMUL32m : I<0xF7, MRM5m, (outs), (ins i32mem:$src),
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001139 "imul{l}\t$src", []>; // EAX,EDX = EAX*[mem32]
Chris Lattnerc90ee9c2008-01-10 07:59:24 +00001140}
Dan Gohmand44572d2008-11-18 21:29:14 +00001141} // neverHasSideEffects
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001142
1143// unsigned division/remainder
Dale Johannesend8fd3562008-10-07 18:54:28 +00001144let Defs = [AL,AH,EFLAGS], Uses = [AX] in
Sean Callanan2c48df22009-12-18 00:01:26 +00001145def DIV8r : I<0xF6, MRM6r, (outs), (ins GR8:$src), // AX/r8 = AL,AH
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001146 "div{b}\t$src", []>;
Evan Cheng55687072007-09-14 21:48:26 +00001147let Defs = [AX,DX,EFLAGS], Uses = [AX,DX] in
Sean Callanan2c48df22009-12-18 00:01:26 +00001148def DIV16r : I<0xF7, MRM6r, (outs), (ins GR16:$src), // DX:AX/r16 = AX,DX
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001149 "div{w}\t$src", []>, OpSize;
Evan Cheng55687072007-09-14 21:48:26 +00001150let Defs = [EAX,EDX,EFLAGS], Uses = [EAX,EDX] in
Sean Callanan2c48df22009-12-18 00:01:26 +00001151def DIV32r : I<0xF7, MRM6r, (outs), (ins GR32:$src), // EDX:EAX/r32 = EAX,EDX
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001152 "div{l}\t$src", []>;
Chris Lattnerc90ee9c2008-01-10 07:59:24 +00001153let mayLoad = 1 in {
Dale Johannesend8fd3562008-10-07 18:54:28 +00001154let Defs = [AL,AH,EFLAGS], Uses = [AX] in
Sean Callanan2c48df22009-12-18 00:01:26 +00001155def DIV8m : I<0xF6, MRM6m, (outs), (ins i8mem:$src), // AX/[mem8] = AL,AH
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001156 "div{b}\t$src", []>;
Evan Cheng55687072007-09-14 21:48:26 +00001157let Defs = [AX,DX,EFLAGS], Uses = [AX,DX] in
Sean Callanan2c48df22009-12-18 00:01:26 +00001158def DIV16m : I<0xF7, MRM6m, (outs), (ins i16mem:$src), // DX:AX/[mem16] = AX,DX
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001159 "div{w}\t$src", []>, OpSize;
Evan Cheng55687072007-09-14 21:48:26 +00001160let Defs = [EAX,EDX,EFLAGS], Uses = [EAX,EDX] in
Sean Callanan2c48df22009-12-18 00:01:26 +00001161 // EDX:EAX/[mem32] = EAX,EDX
1162def DIV32m : I<0xF7, MRM6m, (outs), (ins i32mem:$src),
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001163 "div{l}\t$src", []>;
Chris Lattnerc90ee9c2008-01-10 07:59:24 +00001164}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001165
1166// Signed division/remainder.
Dale Johannesend8fd3562008-10-07 18:54:28 +00001167let Defs = [AL,AH,EFLAGS], Uses = [AX] in
Sean Callanan2c48df22009-12-18 00:01:26 +00001168def IDIV8r : I<0xF6, MRM7r, (outs), (ins GR8:$src), // AX/r8 = AL,AH
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001169 "idiv{b}\t$src", []>;
Evan Cheng55687072007-09-14 21:48:26 +00001170let Defs = [AX,DX,EFLAGS], Uses = [AX,DX] in
Sean Callanan2c48df22009-12-18 00:01:26 +00001171def IDIV16r: I<0xF7, MRM7r, (outs), (ins GR16:$src), // DX:AX/r16 = AX,DX
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001172 "idiv{w}\t$src", []>, OpSize;
Evan Cheng55687072007-09-14 21:48:26 +00001173let Defs = [EAX,EDX,EFLAGS], Uses = [EAX,EDX] in
Sean Callanan2c48df22009-12-18 00:01:26 +00001174def IDIV32r: I<0xF7, MRM7r, (outs), (ins GR32:$src), // EDX:EAX/r32 = EAX,EDX
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001175 "idiv{l}\t$src", []>;
Chris Lattnerc90ee9c2008-01-10 07:59:24 +00001176let mayLoad = 1, mayLoad = 1 in {
Dale Johannesend8fd3562008-10-07 18:54:28 +00001177let Defs = [AL,AH,EFLAGS], Uses = [AX] in
Sean Callanan2c48df22009-12-18 00:01:26 +00001178def IDIV8m : I<0xF6, MRM7m, (outs), (ins i8mem:$src), // AX/[mem8] = AL,AH
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001179 "idiv{b}\t$src", []>;
Evan Cheng55687072007-09-14 21:48:26 +00001180let Defs = [AX,DX,EFLAGS], Uses = [AX,DX] in
Sean Callanan2c48df22009-12-18 00:01:26 +00001181def IDIV16m: I<0xF7, MRM7m, (outs), (ins i16mem:$src), // DX:AX/[mem16] = AX,DX
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001182 "idiv{w}\t$src", []>, OpSize;
Evan Cheng55687072007-09-14 21:48:26 +00001183let Defs = [EAX,EDX,EFLAGS], Uses = [EAX,EDX] in
Sean Callanan2c48df22009-12-18 00:01:26 +00001184def IDIV32m: I<0xF7, MRM7m, (outs), (ins i32mem:$src),
1185 // EDX:EAX/[mem32] = EAX,EDX
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001186 "idiv{l}\t$src", []>;
Chris Lattnerc90ee9c2008-01-10 07:59:24 +00001187}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001188
1189//===----------------------------------------------------------------------===//
Chris Lattnerc90ee9c2008-01-10 07:59:24 +00001190// Two address Instructions.
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001191//
1192let isTwoAddress = 1 in {
1193
1194// Conditional moves
Evan Cheng950aac02007-09-25 01:57:46 +00001195let Uses = [EFLAGS] in {
Dan Gohman29b998f2009-08-27 00:14:12 +00001196
Dan Gohman30afe012009-10-29 18:10:34 +00001197// X86 doesn't have 8-bit conditional moves. Use a customInserter to
Dan Gohman29b998f2009-08-27 00:14:12 +00001198// emit control flow. An alternative to this is to mark i8 SELECT as Promote,
1199// however that requires promoting the operands, and can induce additional
Dan Gohman1596dd22009-08-29 22:19:15 +00001200// i8 register pressure. Note that CMOV_GR8 is conservatively considered to
1201// clobber EFLAGS, because if one of the operands is zero, the expansion
1202// could involve an xor.
Dan Gohman30afe012009-10-29 18:10:34 +00001203let usesCustomInserter = 1, isTwoAddress = 0, Defs = [EFLAGS] in
Dan Gohman29b998f2009-08-27 00:14:12 +00001204def CMOV_GR8 : I<0, Pseudo,
1205 (outs GR8:$dst), (ins GR8:$src1, GR8:$src2, i8imm:$cond),
1206 "#CMOV_GR8 PSEUDO!",
1207 [(set GR8:$dst, (X86cmov GR8:$src1, GR8:$src2,
1208 imm:$cond, EFLAGS))]>;
1209
Dan Gohman90adb6c2009-08-27 18:16:24 +00001210let isCommutable = 1 in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001211def CMOVB16rr : I<0x42, MRMSrcReg, // if <u, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +00001212 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Sean Callanan2c48df22009-12-18 00:01:26 +00001213 "cmovb{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001214 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001215 X86_COND_B, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001216 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001217def CMOVB32rr : I<0x42, MRMSrcReg, // if <u, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +00001218 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Sean Callanan2c48df22009-12-18 00:01:26 +00001219 "cmovb{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001220 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001221 X86_COND_B, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001222 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001223def CMOVAE16rr: I<0x43, MRMSrcReg, // if >=u, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +00001224 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Sean Callanan2c48df22009-12-18 00:01:26 +00001225 "cmovae{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001226 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001227 X86_COND_AE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001228 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001229def CMOVAE32rr: I<0x43, MRMSrcReg, // if >=u, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +00001230 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Sean Callanan2c48df22009-12-18 00:01:26 +00001231 "cmovae{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001232 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001233 X86_COND_AE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001234 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001235def CMOVE16rr : I<0x44, MRMSrcReg, // if ==, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +00001236 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Sean Callanan2c48df22009-12-18 00:01:26 +00001237 "cmove{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001238 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001239 X86_COND_E, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001240 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001241def CMOVE32rr : I<0x44, MRMSrcReg, // if ==, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +00001242 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Sean Callanan2c48df22009-12-18 00:01:26 +00001243 "cmove{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001244 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001245 X86_COND_E, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001246 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001247def CMOVNE16rr: I<0x45, MRMSrcReg, // if !=, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +00001248 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Sean Callanan2c48df22009-12-18 00:01:26 +00001249 "cmovne{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001250 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001251 X86_COND_NE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001252 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001253def CMOVNE32rr: I<0x45, MRMSrcReg, // if !=, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +00001254 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Sean Callanan2c48df22009-12-18 00:01:26 +00001255 "cmovne{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001256 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001257 X86_COND_NE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001258 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001259def CMOVBE16rr: I<0x46, MRMSrcReg, // if <=u, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +00001260 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Sean Callanan2c48df22009-12-18 00:01:26 +00001261 "cmovbe{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001262 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001263 X86_COND_BE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001264 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001265def CMOVBE32rr: I<0x46, MRMSrcReg, // if <=u, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +00001266 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Sean Callanan2c48df22009-12-18 00:01:26 +00001267 "cmovbe{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001268 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001269 X86_COND_BE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001270 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001271def CMOVA16rr : I<0x47, MRMSrcReg, // if >u, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +00001272 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Sean Callanan2c48df22009-12-18 00:01:26 +00001273 "cmova{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001274 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001275 X86_COND_A, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001276 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001277def CMOVA32rr : I<0x47, MRMSrcReg, // if >u, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +00001278 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Sean Callanan2c48df22009-12-18 00:01:26 +00001279 "cmova{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001280 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001281 X86_COND_A, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001282 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001283def CMOVL16rr : I<0x4C, MRMSrcReg, // if <s, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +00001284 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Sean Callanan2c48df22009-12-18 00:01:26 +00001285 "cmovl{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001286 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001287 X86_COND_L, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001288 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001289def CMOVL32rr : I<0x4C, MRMSrcReg, // if <s, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +00001290 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Sean Callanan2c48df22009-12-18 00:01:26 +00001291 "cmovl{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001292 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001293 X86_COND_L, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001294 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001295def CMOVGE16rr: I<0x4D, MRMSrcReg, // if >=s, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +00001296 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Sean Callanan2c48df22009-12-18 00:01:26 +00001297 "cmovge{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001298 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001299 X86_COND_GE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001300 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001301def CMOVGE32rr: I<0x4D, MRMSrcReg, // if >=s, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +00001302 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Sean Callanan2c48df22009-12-18 00:01:26 +00001303 "cmovge{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001304 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001305 X86_COND_GE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001306 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001307def CMOVLE16rr: I<0x4E, MRMSrcReg, // if <=s, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +00001308 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Sean Callanan2c48df22009-12-18 00:01:26 +00001309 "cmovle{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001310 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001311 X86_COND_LE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001312 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001313def CMOVLE32rr: I<0x4E, MRMSrcReg, // if <=s, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +00001314 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Sean Callanan2c48df22009-12-18 00:01:26 +00001315 "cmovle{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001316 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001317 X86_COND_LE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001318 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001319def CMOVG16rr : I<0x4F, MRMSrcReg, // if >s, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +00001320 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Sean Callanan2c48df22009-12-18 00:01:26 +00001321 "cmovg{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001322 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001323 X86_COND_G, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001324 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001325def CMOVG32rr : I<0x4F, MRMSrcReg, // if >s, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +00001326 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Sean Callanan2c48df22009-12-18 00:01:26 +00001327 "cmovg{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001328 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001329 X86_COND_G, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001330 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001331def CMOVS16rr : I<0x48, MRMSrcReg, // if signed, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +00001332 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Sean Callanan2c48df22009-12-18 00:01:26 +00001333 "cmovs{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001334 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001335 X86_COND_S, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001336 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001337def CMOVS32rr : I<0x48, MRMSrcReg, // if signed, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +00001338 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Sean Callanan2c48df22009-12-18 00:01:26 +00001339 "cmovs{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001340 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001341 X86_COND_S, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001342 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001343def CMOVNS16rr: I<0x49, MRMSrcReg, // if !signed, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +00001344 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Sean Callanan2c48df22009-12-18 00:01:26 +00001345 "cmovns{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001346 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001347 X86_COND_NS, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001348 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001349def CMOVNS32rr: I<0x49, MRMSrcReg, // if !signed, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +00001350 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Sean Callanan2c48df22009-12-18 00:01:26 +00001351 "cmovns{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001352 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001353 X86_COND_NS, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001354 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001355def CMOVP16rr : I<0x4A, MRMSrcReg, // if parity, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +00001356 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Sean Callanan2c48df22009-12-18 00:01:26 +00001357 "cmovp{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001358 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001359 X86_COND_P, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001360 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001361def CMOVP32rr : I<0x4A, MRMSrcReg, // if parity, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +00001362 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Sean Callanan2c48df22009-12-18 00:01:26 +00001363 "cmovp{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001364 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001365 X86_COND_P, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001366 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001367def CMOVNP16rr : I<0x4B, MRMSrcReg, // if !parity, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +00001368 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Sean Callanan2c48df22009-12-18 00:01:26 +00001369 "cmovnp{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001370 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001371 X86_COND_NP, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001372 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001373def CMOVNP32rr : I<0x4B, MRMSrcReg, // if !parity, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +00001374 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Sean Callanan2c48df22009-12-18 00:01:26 +00001375 "cmovnp{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001376 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001377 X86_COND_NP, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001378 TB;
Dan Gohman12fd4d72009-01-07 00:35:10 +00001379def CMOVO16rr : I<0x40, MRMSrcReg, // if overflow, GR16 = GR16
1380 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Sean Callanan2c48df22009-12-18 00:01:26 +00001381 "cmovo{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohman12fd4d72009-01-07 00:35:10 +00001382 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
1383 X86_COND_O, EFLAGS))]>,
1384 TB, OpSize;
1385def CMOVO32rr : I<0x40, MRMSrcReg, // if overflow, GR32 = GR32
1386 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Sean Callanan2c48df22009-12-18 00:01:26 +00001387 "cmovo{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohman12fd4d72009-01-07 00:35:10 +00001388 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
1389 X86_COND_O, EFLAGS))]>,
Evan Cheng950aac02007-09-25 01:57:46 +00001390 TB;
Dan Gohman12fd4d72009-01-07 00:35:10 +00001391def CMOVNO16rr : I<0x41, MRMSrcReg, // if !overflow, GR16 = GR16
1392 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Sean Callanan2c48df22009-12-18 00:01:26 +00001393 "cmovno{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohman12fd4d72009-01-07 00:35:10 +00001394 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
1395 X86_COND_NO, EFLAGS))]>,
1396 TB, OpSize;
1397def CMOVNO32rr : I<0x41, MRMSrcReg, // if !overflow, GR32 = GR32
1398 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Sean Callanan2c48df22009-12-18 00:01:26 +00001399 "cmovno{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohman12fd4d72009-01-07 00:35:10 +00001400 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
1401 X86_COND_NO, EFLAGS))]>,
1402 TB;
1403} // isCommutable = 1
Evan Cheng926658c2007-10-05 23:13:21 +00001404
1405def CMOVB16rm : I<0x42, MRMSrcMem, // if <u, GR16 = [mem16]
1406 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
Sean Callanan2c48df22009-12-18 00:01:26 +00001407 "cmovb{w}\t{$src2, $dst|$dst, $src2}",
Evan Cheng926658c2007-10-05 23:13:21 +00001408 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1409 X86_COND_B, EFLAGS))]>,
1410 TB, OpSize;
1411def CMOVB32rm : I<0x42, MRMSrcMem, // if <u, GR32 = [mem32]
1412 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Sean Callanan2c48df22009-12-18 00:01:26 +00001413 "cmovb{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng926658c2007-10-05 23:13:21 +00001414 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1415 X86_COND_B, EFLAGS))]>,
1416 TB;
1417def CMOVAE16rm: I<0x43, MRMSrcMem, // if >=u, GR16 = [mem16]
1418 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
Sean Callanan2c48df22009-12-18 00:01:26 +00001419 "cmovae{w}\t{$src2, $dst|$dst, $src2}",
Evan Cheng926658c2007-10-05 23:13:21 +00001420 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1421 X86_COND_AE, EFLAGS))]>,
1422 TB, OpSize;
1423def CMOVAE32rm: I<0x43, MRMSrcMem, // if >=u, GR32 = [mem32]
1424 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Sean Callanan2c48df22009-12-18 00:01:26 +00001425 "cmovae{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng926658c2007-10-05 23:13:21 +00001426 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1427 X86_COND_AE, EFLAGS))]>,
1428 TB;
1429def CMOVE16rm : I<0x44, MRMSrcMem, // if ==, GR16 = [mem16]
1430 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
Sean Callanan2c48df22009-12-18 00:01:26 +00001431 "cmove{w}\t{$src2, $dst|$dst, $src2}",
Evan Cheng926658c2007-10-05 23:13:21 +00001432 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1433 X86_COND_E, EFLAGS))]>,
1434 TB, OpSize;
1435def CMOVE32rm : I<0x44, MRMSrcMem, // if ==, GR32 = [mem32]
1436 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Sean Callanan2c48df22009-12-18 00:01:26 +00001437 "cmove{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng926658c2007-10-05 23:13:21 +00001438 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1439 X86_COND_E, EFLAGS))]>,
1440 TB;
1441def CMOVNE16rm: I<0x45, MRMSrcMem, // if !=, GR16 = [mem16]
1442 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
Sean Callanan2c48df22009-12-18 00:01:26 +00001443 "cmovne{w}\t{$src2, $dst|$dst, $src2}",
Evan Cheng926658c2007-10-05 23:13:21 +00001444 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1445 X86_COND_NE, EFLAGS))]>,
1446 TB, OpSize;
1447def CMOVNE32rm: I<0x45, MRMSrcMem, // if !=, GR32 = [mem32]
1448 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Sean Callanan2c48df22009-12-18 00:01:26 +00001449 "cmovne{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng926658c2007-10-05 23:13:21 +00001450 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1451 X86_COND_NE, EFLAGS))]>,
1452 TB;
1453def CMOVBE16rm: I<0x46, MRMSrcMem, // if <=u, GR16 = [mem16]
1454 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
Sean Callanan2c48df22009-12-18 00:01:26 +00001455 "cmovbe{w}\t{$src2, $dst|$dst, $src2}",
Evan Cheng926658c2007-10-05 23:13:21 +00001456 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1457 X86_COND_BE, EFLAGS))]>,
1458 TB, OpSize;
1459def CMOVBE32rm: I<0x46, MRMSrcMem, // if <=u, GR32 = [mem32]
1460 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Sean Callanan2c48df22009-12-18 00:01:26 +00001461 "cmovbe{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng926658c2007-10-05 23:13:21 +00001462 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1463 X86_COND_BE, EFLAGS))]>,
1464 TB;
1465def CMOVA16rm : I<0x47, MRMSrcMem, // if >u, GR16 = [mem16]
1466 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
Sean Callanan2c48df22009-12-18 00:01:26 +00001467 "cmova{w}\t{$src2, $dst|$dst, $src2}",
Evan Cheng926658c2007-10-05 23:13:21 +00001468 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1469 X86_COND_A, EFLAGS))]>,
1470 TB, OpSize;
1471def CMOVA32rm : I<0x47, MRMSrcMem, // if >u, GR32 = [mem32]
1472 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Sean Callanan2c48df22009-12-18 00:01:26 +00001473 "cmova{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng926658c2007-10-05 23:13:21 +00001474 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1475 X86_COND_A, EFLAGS))]>,
1476 TB;
1477def CMOVL16rm : I<0x4C, MRMSrcMem, // if <s, GR16 = [mem16]
1478 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
Sean Callanan2c48df22009-12-18 00:01:26 +00001479 "cmovl{w}\t{$src2, $dst|$dst, $src2}",
Evan Cheng926658c2007-10-05 23:13:21 +00001480 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1481 X86_COND_L, EFLAGS))]>,
1482 TB, OpSize;
1483def CMOVL32rm : I<0x4C, MRMSrcMem, // if <s, GR32 = [mem32]
1484 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Sean Callanan2c48df22009-12-18 00:01:26 +00001485 "cmovl{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng926658c2007-10-05 23:13:21 +00001486 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1487 X86_COND_L, EFLAGS))]>,
1488 TB;
1489def CMOVGE16rm: I<0x4D, MRMSrcMem, // if >=s, GR16 = [mem16]
1490 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
Sean Callanan2c48df22009-12-18 00:01:26 +00001491 "cmovge{w}\t{$src2, $dst|$dst, $src2}",
Evan Cheng926658c2007-10-05 23:13:21 +00001492 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1493 X86_COND_GE, EFLAGS))]>,
1494 TB, OpSize;
1495def CMOVGE32rm: I<0x4D, MRMSrcMem, // if >=s, GR32 = [mem32]
1496 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Sean Callanan2c48df22009-12-18 00:01:26 +00001497 "cmovge{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng926658c2007-10-05 23:13:21 +00001498 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1499 X86_COND_GE, EFLAGS))]>,
1500 TB;
1501def CMOVLE16rm: I<0x4E, MRMSrcMem, // if <=s, GR16 = [mem16]
1502 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
Sean Callanan2c48df22009-12-18 00:01:26 +00001503 "cmovle{w}\t{$src2, $dst|$dst, $src2}",
Evan Cheng926658c2007-10-05 23:13:21 +00001504 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1505 X86_COND_LE, EFLAGS))]>,
1506 TB, OpSize;
1507def CMOVLE32rm: I<0x4E, MRMSrcMem, // if <=s, GR32 = [mem32]
1508 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Sean Callanan2c48df22009-12-18 00:01:26 +00001509 "cmovle{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng926658c2007-10-05 23:13:21 +00001510 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1511 X86_COND_LE, EFLAGS))]>,
1512 TB;
1513def CMOVG16rm : I<0x4F, MRMSrcMem, // if >s, GR16 = [mem16]
1514 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
Sean Callanan2c48df22009-12-18 00:01:26 +00001515 "cmovg{w}\t{$src2, $dst|$dst, $src2}",
Evan Cheng926658c2007-10-05 23:13:21 +00001516 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1517 X86_COND_G, EFLAGS))]>,
1518 TB, OpSize;
1519def CMOVG32rm : I<0x4F, MRMSrcMem, // if >s, GR32 = [mem32]
1520 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Sean Callanan2c48df22009-12-18 00:01:26 +00001521 "cmovg{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng926658c2007-10-05 23:13:21 +00001522 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1523 X86_COND_G, EFLAGS))]>,
1524 TB;
1525def CMOVS16rm : I<0x48, MRMSrcMem, // if signed, GR16 = [mem16]
1526 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
Sean Callanan2c48df22009-12-18 00:01:26 +00001527 "cmovs{w}\t{$src2, $dst|$dst, $src2}",
Evan Cheng926658c2007-10-05 23:13:21 +00001528 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1529 X86_COND_S, EFLAGS))]>,
1530 TB, OpSize;
1531def CMOVS32rm : I<0x48, MRMSrcMem, // if signed, GR32 = [mem32]
1532 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Sean Callanan2c48df22009-12-18 00:01:26 +00001533 "cmovs{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng926658c2007-10-05 23:13:21 +00001534 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1535 X86_COND_S, EFLAGS))]>,
1536 TB;
1537def CMOVNS16rm: I<0x49, MRMSrcMem, // if !signed, GR16 = [mem16]
1538 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
Sean Callanan2c48df22009-12-18 00:01:26 +00001539 "cmovns{w}\t{$src2, $dst|$dst, $src2}",
Evan Cheng926658c2007-10-05 23:13:21 +00001540 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1541 X86_COND_NS, EFLAGS))]>,
1542 TB, OpSize;
1543def CMOVNS32rm: I<0x49, MRMSrcMem, // if !signed, GR32 = [mem32]
1544 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Sean Callanan2c48df22009-12-18 00:01:26 +00001545 "cmovns{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng926658c2007-10-05 23:13:21 +00001546 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1547 X86_COND_NS, EFLAGS))]>,
1548 TB;
1549def CMOVP16rm : I<0x4A, MRMSrcMem, // if parity, GR16 = [mem16]
1550 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
Sean Callanan2c48df22009-12-18 00:01:26 +00001551 "cmovp{w}\t{$src2, $dst|$dst, $src2}",
Evan Cheng926658c2007-10-05 23:13:21 +00001552 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1553 X86_COND_P, EFLAGS))]>,
1554 TB, OpSize;
1555def CMOVP32rm : I<0x4A, MRMSrcMem, // if parity, GR32 = [mem32]
1556 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Sean Callanan2c48df22009-12-18 00:01:26 +00001557 "cmovp{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng926658c2007-10-05 23:13:21 +00001558 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1559 X86_COND_P, EFLAGS))]>,
1560 TB;
1561def CMOVNP16rm : I<0x4B, MRMSrcMem, // if !parity, GR16 = [mem16]
1562 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
Sean Callanan2c48df22009-12-18 00:01:26 +00001563 "cmovnp{w}\t{$src2, $dst|$dst, $src2}",
Evan Cheng926658c2007-10-05 23:13:21 +00001564 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1565 X86_COND_NP, EFLAGS))]>,
1566 TB, OpSize;
Dan Gohman12fd4d72009-01-07 00:35:10 +00001567def CMOVNP32rm : I<0x4B, MRMSrcMem, // if !parity, GR32 = [mem32]
1568 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Sean Callanan2c48df22009-12-18 00:01:26 +00001569 "cmovnp{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohman12fd4d72009-01-07 00:35:10 +00001570 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1571 X86_COND_NP, EFLAGS))]>,
1572 TB;
1573def CMOVO16rm : I<0x40, MRMSrcMem, // if overflow, GR16 = [mem16]
1574 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
Sean Callanan2c48df22009-12-18 00:01:26 +00001575 "cmovo{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohman12fd4d72009-01-07 00:35:10 +00001576 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1577 X86_COND_O, EFLAGS))]>,
1578 TB, OpSize;
1579def CMOVO32rm : I<0x40, MRMSrcMem, // if overflow, GR32 = [mem32]
1580 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Sean Callanan2c48df22009-12-18 00:01:26 +00001581 "cmovo{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohman12fd4d72009-01-07 00:35:10 +00001582 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1583 X86_COND_O, EFLAGS))]>,
1584 TB;
1585def CMOVNO16rm : I<0x41, MRMSrcMem, // if !overflow, GR16 = [mem16]
1586 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
Sean Callanan2c48df22009-12-18 00:01:26 +00001587 "cmovno{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohman12fd4d72009-01-07 00:35:10 +00001588 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1589 X86_COND_NO, EFLAGS))]>,
1590 TB, OpSize;
1591def CMOVNO32rm : I<0x41, MRMSrcMem, // if !overflow, GR32 = [mem32]
1592 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Sean Callanan2c48df22009-12-18 00:01:26 +00001593 "cmovno{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohman12fd4d72009-01-07 00:35:10 +00001594 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1595 X86_COND_NO, EFLAGS))]>,
1596 TB;
Evan Cheng950aac02007-09-25 01:57:46 +00001597} // Uses = [EFLAGS]
1598
1599
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001600// unary instructions
1601let CodeSize = 2 in {
Evan Cheng55687072007-09-14 21:48:26 +00001602let Defs = [EFLAGS] in {
Dan Gohman91888f02007-07-31 20:11:57 +00001603def NEG8r : I<0xF6, MRM3r, (outs GR8 :$dst), (ins GR8 :$src), "neg{b}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001604 [(set GR8:$dst, (ineg GR8:$src)),
1605 (implicit EFLAGS)]>;
Dan Gohman91888f02007-07-31 20:11:57 +00001606def NEG16r : I<0xF7, MRM3r, (outs GR16:$dst), (ins GR16:$src), "neg{w}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001607 [(set GR16:$dst, (ineg GR16:$src)),
1608 (implicit EFLAGS)]>, OpSize;
Dan Gohman91888f02007-07-31 20:11:57 +00001609def NEG32r : I<0xF7, MRM3r, (outs GR32:$dst), (ins GR32:$src), "neg{l}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001610 [(set GR32:$dst, (ineg GR32:$src)),
1611 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001612let isTwoAddress = 0 in {
Dan Gohman91888f02007-07-31 20:11:57 +00001613 def NEG8m : I<0xF6, MRM3m, (outs), (ins i8mem :$dst), "neg{b}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001614 [(store (ineg (loadi8 addr:$dst)), addr:$dst),
1615 (implicit EFLAGS)]>;
Dan Gohman91888f02007-07-31 20:11:57 +00001616 def NEG16m : I<0xF7, MRM3m, (outs), (ins i16mem:$dst), "neg{w}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001617 [(store (ineg (loadi16 addr:$dst)), addr:$dst),
1618 (implicit EFLAGS)]>, OpSize;
Dan Gohman91888f02007-07-31 20:11:57 +00001619 def NEG32m : I<0xF7, MRM3m, (outs), (ins i32mem:$dst), "neg{l}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001620 [(store (ineg (loadi32 addr:$dst)), addr:$dst),
1621 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001622}
Evan Cheng55687072007-09-14 21:48:26 +00001623} // Defs = [EFLAGS]
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001624
Evan Chengc6cee682009-01-21 02:09:05 +00001625// Match xor -1 to not. Favors these over a move imm + xor to save code size.
1626let AddedComplexity = 15 in {
Dan Gohman91888f02007-07-31 20:11:57 +00001627def NOT8r : I<0xF6, MRM2r, (outs GR8 :$dst), (ins GR8 :$src), "not{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001628 [(set GR8:$dst, (not GR8:$src))]>;
Dan Gohman91888f02007-07-31 20:11:57 +00001629def NOT16r : I<0xF7, MRM2r, (outs GR16:$dst), (ins GR16:$src), "not{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001630 [(set GR16:$dst, (not GR16:$src))]>, OpSize;
Dan Gohman91888f02007-07-31 20:11:57 +00001631def NOT32r : I<0xF7, MRM2r, (outs GR32:$dst), (ins GR32:$src), "not{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001632 [(set GR32:$dst, (not GR32:$src))]>;
Evan Chengc6cee682009-01-21 02:09:05 +00001633}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001634let isTwoAddress = 0 in {
Dan Gohman91888f02007-07-31 20:11:57 +00001635 def NOT8m : I<0xF6, MRM2m, (outs), (ins i8mem :$dst), "not{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001636 [(store (not (loadi8 addr:$dst)), addr:$dst)]>;
Dan Gohman91888f02007-07-31 20:11:57 +00001637 def NOT16m : I<0xF7, MRM2m, (outs), (ins i16mem:$dst), "not{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001638 [(store (not (loadi16 addr:$dst)), addr:$dst)]>, OpSize;
Dan Gohman91888f02007-07-31 20:11:57 +00001639 def NOT32m : I<0xF7, MRM2m, (outs), (ins i32mem:$dst), "not{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001640 [(store (not (loadi32 addr:$dst)), addr:$dst)]>;
1641}
1642} // CodeSize
1643
1644// TODO: inc/dec is slow for P4, but fast for Pentium-M.
Evan Cheng55687072007-09-14 21:48:26 +00001645let Defs = [EFLAGS] in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001646let CodeSize = 2 in
Dan Gohman91888f02007-07-31 20:11:57 +00001647def INC8r : I<0xFE, MRM0r, (outs GR8 :$dst), (ins GR8 :$src), "inc{b}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001648 [(set GR8:$dst, (add GR8:$src, 1)),
1649 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001650let isConvertibleToThreeAddress = 1, CodeSize = 1 in { // Can xform into LEA.
Sean Callanan2c48df22009-12-18 00:01:26 +00001651def INC16r : I<0x40, AddRegFrm, (outs GR16:$dst), (ins GR16:$src),
1652 "inc{w}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001653 [(set GR16:$dst, (add GR16:$src, 1)),
1654 (implicit EFLAGS)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001655 OpSize, Requires<[In32BitMode]>;
Sean Callanan2c48df22009-12-18 00:01:26 +00001656def INC32r : I<0x40, AddRegFrm, (outs GR32:$dst), (ins GR32:$src),
1657 "inc{l}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001658 [(set GR32:$dst, (add GR32:$src, 1)),
1659 (implicit EFLAGS)]>, Requires<[In32BitMode]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001660}
1661let isTwoAddress = 0, CodeSize = 2 in {
Dan Gohman91888f02007-07-31 20:11:57 +00001662 def INC8m : I<0xFE, MRM0m, (outs), (ins i8mem :$dst), "inc{b}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001663 [(store (add (loadi8 addr:$dst), 1), addr:$dst),
1664 (implicit EFLAGS)]>;
Dan Gohman91888f02007-07-31 20:11:57 +00001665 def INC16m : I<0xFF, MRM0m, (outs), (ins i16mem:$dst), "inc{w}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001666 [(store (add (loadi16 addr:$dst), 1), addr:$dst),
1667 (implicit EFLAGS)]>,
Evan Cheng4a7e72f2007-10-19 21:23:22 +00001668 OpSize, Requires<[In32BitMode]>;
Dan Gohman91888f02007-07-31 20:11:57 +00001669 def INC32m : I<0xFF, MRM0m, (outs), (ins i32mem:$dst), "inc{l}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001670 [(store (add (loadi32 addr:$dst), 1), addr:$dst),
1671 (implicit EFLAGS)]>,
Evan Cheng4a7e72f2007-10-19 21:23:22 +00001672 Requires<[In32BitMode]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001673}
1674
1675let CodeSize = 2 in
Dan Gohman91888f02007-07-31 20:11:57 +00001676def DEC8r : I<0xFE, MRM1r, (outs GR8 :$dst), (ins GR8 :$src), "dec{b}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001677 [(set GR8:$dst, (add GR8:$src, -1)),
1678 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001679let isConvertibleToThreeAddress = 1, CodeSize = 1 in { // Can xform into LEA.
Sean Callanan2c48df22009-12-18 00:01:26 +00001680def DEC16r : I<0x48, AddRegFrm, (outs GR16:$dst), (ins GR16:$src),
1681 "dec{w}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001682 [(set GR16:$dst, (add GR16:$src, -1)),
1683 (implicit EFLAGS)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001684 OpSize, Requires<[In32BitMode]>;
Sean Callanan2c48df22009-12-18 00:01:26 +00001685def DEC32r : I<0x48, AddRegFrm, (outs GR32:$dst), (ins GR32:$src),
1686 "dec{l}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001687 [(set GR32:$dst, (add GR32:$src, -1)),
1688 (implicit EFLAGS)]>, Requires<[In32BitMode]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001689}
1690
1691let isTwoAddress = 0, CodeSize = 2 in {
Dan Gohman91888f02007-07-31 20:11:57 +00001692 def DEC8m : I<0xFE, MRM1m, (outs), (ins i8mem :$dst), "dec{b}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001693 [(store (add (loadi8 addr:$dst), -1), addr:$dst),
1694 (implicit EFLAGS)]>;
Dan Gohman91888f02007-07-31 20:11:57 +00001695 def DEC16m : I<0xFF, MRM1m, (outs), (ins i16mem:$dst), "dec{w}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001696 [(store (add (loadi16 addr:$dst), -1), addr:$dst),
1697 (implicit EFLAGS)]>,
Evan Cheng4a7e72f2007-10-19 21:23:22 +00001698 OpSize, Requires<[In32BitMode]>;
Dan Gohman91888f02007-07-31 20:11:57 +00001699 def DEC32m : I<0xFF, MRM1m, (outs), (ins i32mem:$dst), "dec{l}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001700 [(store (add (loadi32 addr:$dst), -1), addr:$dst),
1701 (implicit EFLAGS)]>,
Evan Cheng4a7e72f2007-10-19 21:23:22 +00001702 Requires<[In32BitMode]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001703}
Evan Cheng55687072007-09-14 21:48:26 +00001704} // Defs = [EFLAGS]
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001705
1706// Logical operators...
Evan Cheng55687072007-09-14 21:48:26 +00001707let Defs = [EFLAGS] in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001708let isCommutable = 1 in { // X = AND Y, Z --> X = AND Z, Y
1709def AND8rr : I<0x20, MRMDestReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001710 (outs GR8 :$dst), (ins GR8 :$src1, GR8 :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001711 "and{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001712 [(set GR8:$dst, (and GR8:$src1, GR8:$src2)),
1713 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001714def AND16rr : I<0x21, MRMDestReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001715 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001716 "and{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001717 [(set GR16:$dst, (and GR16:$src1, GR16:$src2)),
1718 (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001719def AND32rr : I<0x21, MRMDestReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001720 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001721 "and{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001722 [(set GR32:$dst, (and GR32:$src1, GR32:$src2)),
1723 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001724}
1725
Sean Callanan2c48df22009-12-18 00:01:26 +00001726// AND instructions with the destination register in REG and the source register
1727// in R/M. Included for the disassembler.
1728def AND8rr_REV : I<0x22, MRMSrcReg, (outs GR8:$dst), (ins GR8:$src1, GR8:$src2),
1729 "and{b}\t{$src2, $dst|$dst, $src2}", []>;
1730def AND16rr_REV : I<0x23, MRMSrcReg, (outs GR16:$dst),
1731 (ins GR16:$src1, GR16:$src2),
1732 "and{w}\t{$src2, $dst|$dst, $src2}", []>, OpSize;
1733def AND32rr_REV : I<0x23, MRMSrcReg, (outs GR32:$dst),
1734 (ins GR32:$src1, GR32:$src2),
1735 "and{l}\t{$src2, $dst|$dst, $src2}", []>;
1736
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001737def AND8rm : I<0x22, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001738 (outs GR8 :$dst), (ins GR8 :$src1, i8mem :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001739 "and{b}\t{$src2, $dst|$dst, $src2}",
Chris Lattner12208612009-04-10 00:16:23 +00001740 [(set GR8:$dst, (and GR8:$src1, (loadi8 addr:$src2))),
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001741 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001742def AND16rm : I<0x23, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001743 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001744 "and{w}\t{$src2, $dst|$dst, $src2}",
Chris Lattner12208612009-04-10 00:16:23 +00001745 [(set GR16:$dst, (and GR16:$src1, (loadi16 addr:$src2))),
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001746 (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001747def AND32rm : I<0x23, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001748 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001749 "and{l}\t{$src2, $dst|$dst, $src2}",
Chris Lattner12208612009-04-10 00:16:23 +00001750 [(set GR32:$dst, (and GR32:$src1, (loadi32 addr:$src2))),
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001751 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001752
1753def AND8ri : Ii8<0x80, MRM4r,
Evan Chengb783fa32007-07-19 01:14:50 +00001754 (outs GR8 :$dst), (ins GR8 :$src1, i8imm :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001755 "and{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001756 [(set GR8:$dst, (and GR8:$src1, imm:$src2)),
1757 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001758def AND16ri : Ii16<0x81, MRM4r,
Evan Chengb783fa32007-07-19 01:14:50 +00001759 (outs GR16:$dst), (ins GR16:$src1, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001760 "and{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001761 [(set GR16:$dst, (and GR16:$src1, imm:$src2)),
1762 (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001763def AND32ri : Ii32<0x81, MRM4r,
Evan Chengb783fa32007-07-19 01:14:50 +00001764 (outs GR32:$dst), (ins GR32:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001765 "and{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001766 [(set GR32:$dst, (and GR32:$src1, imm:$src2)),
1767 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001768def AND16ri8 : Ii8<0x83, MRM4r,
Evan Chengb783fa32007-07-19 01:14:50 +00001769 (outs GR16:$dst), (ins GR16:$src1, i16i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001770 "and{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001771 [(set GR16:$dst, (and GR16:$src1, i16immSExt8:$src2)),
1772 (implicit EFLAGS)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001773 OpSize;
1774def AND32ri8 : Ii8<0x83, MRM4r,
Evan Chengb783fa32007-07-19 01:14:50 +00001775 (outs GR32:$dst), (ins GR32:$src1, i32i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001776 "and{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001777 [(set GR32:$dst, (and GR32:$src1, i32immSExt8:$src2)),
1778 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001779
1780let isTwoAddress = 0 in {
1781 def AND8mr : I<0x20, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001782 (outs), (ins i8mem :$dst, GR8 :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001783 "and{b}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001784 [(store (and (load addr:$dst), GR8:$src), addr:$dst),
1785 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001786 def AND16mr : I<0x21, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001787 (outs), (ins i16mem:$dst, GR16:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001788 "and{w}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001789 [(store (and (load addr:$dst), GR16:$src), addr:$dst),
1790 (implicit EFLAGS)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001791 OpSize;
1792 def AND32mr : I<0x21, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001793 (outs), (ins i32mem:$dst, GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001794 "and{l}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001795 [(store (and (load addr:$dst), GR32:$src), addr:$dst),
1796 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001797 def AND8mi : Ii8<0x80, MRM4m,
Evan Chengb783fa32007-07-19 01:14:50 +00001798 (outs), (ins i8mem :$dst, i8imm :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001799 "and{b}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001800 [(store (and (loadi8 addr:$dst), imm:$src), addr:$dst),
1801 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001802 def AND16mi : Ii16<0x81, MRM4m,
Evan Chengb783fa32007-07-19 01:14:50 +00001803 (outs), (ins i16mem:$dst, i16imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001804 "and{w}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001805 [(store (and (loadi16 addr:$dst), imm:$src), addr:$dst),
1806 (implicit EFLAGS)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001807 OpSize;
1808 def AND32mi : Ii32<0x81, MRM4m,
Evan Chengb783fa32007-07-19 01:14:50 +00001809 (outs), (ins i32mem:$dst, i32imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001810 "and{l}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001811 [(store (and (loadi32 addr:$dst), imm:$src), addr:$dst),
1812 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001813 def AND16mi8 : Ii8<0x83, MRM4m,
Evan Chengb783fa32007-07-19 01:14:50 +00001814 (outs), (ins i16mem:$dst, i16i8imm :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001815 "and{w}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001816 [(store (and (load addr:$dst), i16immSExt8:$src), addr:$dst),
1817 (implicit EFLAGS)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001818 OpSize;
1819 def AND32mi8 : Ii8<0x83, MRM4m,
Evan Chengb783fa32007-07-19 01:14:50 +00001820 (outs), (ins i32mem:$dst, i32i8imm :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001821 "and{l}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001822 [(store (and (load addr:$dst), i32immSExt8:$src), addr:$dst),
1823 (implicit EFLAGS)]>;
Sean Callanan251676e2009-09-02 00:55:49 +00001824
1825 def AND8i8 : Ii8<0x24, RawFrm, (outs), (ins i8imm:$src),
1826 "and{b}\t{$src, %al|%al, $src}", []>;
1827 def AND16i16 : Ii16<0x25, RawFrm, (outs), (ins i16imm:$src),
1828 "and{w}\t{$src, %ax|%ax, $src}", []>, OpSize;
1829 def AND32i32 : Ii32<0x25, RawFrm, (outs), (ins i32imm:$src),
1830 "and{l}\t{$src, %eax|%eax, $src}", []>;
1831
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001832}
1833
1834
1835let isCommutable = 1 in { // X = OR Y, Z --> X = OR Z, Y
Sean Callanan2c48df22009-12-18 00:01:26 +00001836def OR8rr : I<0x08, MRMDestReg, (outs GR8 :$dst),
1837 (ins GR8 :$src1, GR8 :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001838 "or{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001839 [(set GR8:$dst, (or GR8:$src1, GR8:$src2)),
1840 (implicit EFLAGS)]>;
Sean Callanan2c48df22009-12-18 00:01:26 +00001841def OR16rr : I<0x09, MRMDestReg, (outs GR16:$dst),
1842 (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001843 "or{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001844 [(set GR16:$dst, (or GR16:$src1, GR16:$src2)),
1845 (implicit EFLAGS)]>, OpSize;
Sean Callanan2c48df22009-12-18 00:01:26 +00001846def OR32rr : I<0x09, MRMDestReg, (outs GR32:$dst),
1847 (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001848 "or{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001849 [(set GR32:$dst, (or GR32:$src1, GR32:$src2)),
1850 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001851}
Sean Callanan2c48df22009-12-18 00:01:26 +00001852
1853// OR instructions with the destination register in REG and the source register
1854// in R/M. Included for the disassembler.
1855def OR8rr_REV : I<0x0A, MRMSrcReg, (outs GR8:$dst), (ins GR8:$src1, GR8:$src2),
1856 "or{b}\t{$src2, $dst|$dst, $src2}", []>;
1857def OR16rr_REV : I<0x0B, MRMSrcReg, (outs GR16:$dst),
1858 (ins GR16:$src1, GR16:$src2),
1859 "or{w}\t{$src2, $dst|$dst, $src2}", []>, OpSize;
1860def OR32rr_REV : I<0x0B, MRMSrcReg, (outs GR32:$dst),
1861 (ins GR32:$src1, GR32:$src2),
1862 "or{l}\t{$src2, $dst|$dst, $src2}", []>;
1863
1864def OR8rm : I<0x0A, MRMSrcMem , (outs GR8 :$dst),
1865 (ins GR8 :$src1, i8mem :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001866 "or{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001867 [(set GR8:$dst, (or GR8:$src1, (load addr:$src2))),
1868 (implicit EFLAGS)]>;
Sean Callanan2c48df22009-12-18 00:01:26 +00001869def OR16rm : I<0x0B, MRMSrcMem , (outs GR16:$dst),
1870 (ins GR16:$src1, i16mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001871 "or{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001872 [(set GR16:$dst, (or GR16:$src1, (load addr:$src2))),
1873 (implicit EFLAGS)]>, OpSize;
Sean Callanan2c48df22009-12-18 00:01:26 +00001874def OR32rm : I<0x0B, MRMSrcMem , (outs GR32:$dst),
1875 (ins GR32:$src1, i32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001876 "or{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001877 [(set GR32:$dst, (or GR32:$src1, (load addr:$src2))),
1878 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001879
Sean Callanan2c48df22009-12-18 00:01:26 +00001880def OR8ri : Ii8 <0x80, MRM1r, (outs GR8 :$dst),
1881 (ins GR8 :$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001882 "or{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001883 [(set GR8:$dst, (or GR8:$src1, imm:$src2)),
1884 (implicit EFLAGS)]>;
Sean Callanan2c48df22009-12-18 00:01:26 +00001885def OR16ri : Ii16<0x81, MRM1r, (outs GR16:$dst),
1886 (ins GR16:$src1, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001887 "or{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001888 [(set GR16:$dst, (or GR16:$src1, imm:$src2)),
1889 (implicit EFLAGS)]>, OpSize;
Sean Callanan2c48df22009-12-18 00:01:26 +00001890def OR32ri : Ii32<0x81, MRM1r, (outs GR32:$dst),
1891 (ins GR32:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001892 "or{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001893 [(set GR32:$dst, (or GR32:$src1, imm:$src2)),
1894 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001895
Sean Callanan2c48df22009-12-18 00:01:26 +00001896def OR16ri8 : Ii8<0x83, MRM1r, (outs GR16:$dst),
1897 (ins GR16:$src1, i16i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001898 "or{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001899 [(set GR16:$dst, (or GR16:$src1, i16immSExt8:$src2)),
1900 (implicit EFLAGS)]>, OpSize;
Sean Callanan2c48df22009-12-18 00:01:26 +00001901def OR32ri8 : Ii8<0x83, MRM1r, (outs GR32:$dst),
1902 (ins GR32:$src1, i32i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001903 "or{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001904 [(set GR32:$dst, (or GR32:$src1, i32immSExt8:$src2)),
1905 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001906let isTwoAddress = 0 in {
Evan Chengb783fa32007-07-19 01:14:50 +00001907 def OR8mr : I<0x08, MRMDestMem, (outs), (ins i8mem:$dst, GR8:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001908 "or{b}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001909 [(store (or (load addr:$dst), GR8:$src), addr:$dst),
1910 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001911 def OR16mr : I<0x09, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001912 "or{w}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001913 [(store (or (load addr:$dst), GR16:$src), addr:$dst),
1914 (implicit EFLAGS)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001915 def OR32mr : I<0x09, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001916 "or{l}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001917 [(store (or (load addr:$dst), GR32:$src), addr:$dst),
1918 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001919 def OR8mi : Ii8<0x80, MRM1m, (outs), (ins i8mem :$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001920 "or{b}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001921 [(store (or (loadi8 addr:$dst), imm:$src), addr:$dst),
1922 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001923 def OR16mi : Ii16<0x81, MRM1m, (outs), (ins i16mem:$dst, i16imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001924 "or{w}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001925 [(store (or (loadi16 addr:$dst), imm:$src), addr:$dst),
1926 (implicit EFLAGS)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001927 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001928 def OR32mi : Ii32<0x81, MRM1m, (outs), (ins i32mem:$dst, i32imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001929 "or{l}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001930 [(store (or (loadi32 addr:$dst), imm:$src), addr:$dst),
1931 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001932 def OR16mi8 : Ii8<0x83, MRM1m, (outs), (ins i16mem:$dst, i16i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001933 "or{w}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001934 [(store (or (load addr:$dst), i16immSExt8:$src), addr:$dst),
1935 (implicit EFLAGS)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001936 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001937 def OR32mi8 : Ii8<0x83, MRM1m, (outs), (ins i32mem:$dst, i32i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001938 "or{l}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001939 [(store (or (load addr:$dst), i32immSExt8:$src), addr:$dst),
1940 (implicit EFLAGS)]>;
Sean Callanan8562bef2009-09-11 19:01:56 +00001941
1942 def OR8i8 : Ii8 <0x0C, RawFrm, (outs), (ins i8imm:$src),
1943 "or{b}\t{$src, %al|%al, $src}", []>;
1944 def OR16i16 : Ii16 <0x0D, RawFrm, (outs), (ins i16imm:$src),
1945 "or{w}\t{$src, %ax|%ax, $src}", []>, OpSize;
1946 def OR32i32 : Ii32 <0x0D, RawFrm, (outs), (ins i32imm:$src),
1947 "or{l}\t{$src, %eax|%eax, $src}", []>;
Bill Wendlingba5d5b02008-05-29 01:02:09 +00001948} // isTwoAddress = 0
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001949
1950
Evan Cheng6f26e8b2008-06-18 08:13:07 +00001951let isCommutable = 1 in { // X = XOR Y, Z --> X = XOR Z, Y
Bill Wendlingba5d5b02008-05-29 01:02:09 +00001952 def XOR8rr : I<0x30, MRMDestReg,
1953 (outs GR8 :$dst), (ins GR8 :$src1, GR8 :$src2),
1954 "xor{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001955 [(set GR8:$dst, (xor GR8:$src1, GR8:$src2)),
1956 (implicit EFLAGS)]>;
Bill Wendlingba5d5b02008-05-29 01:02:09 +00001957 def XOR16rr : I<0x31, MRMDestReg,
1958 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
1959 "xor{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001960 [(set GR16:$dst, (xor GR16:$src1, GR16:$src2)),
1961 (implicit EFLAGS)]>, OpSize;
Bill Wendlingba5d5b02008-05-29 01:02:09 +00001962 def XOR32rr : I<0x31, MRMDestReg,
1963 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
1964 "xor{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001965 [(set GR32:$dst, (xor GR32:$src1, GR32:$src2)),
1966 (implicit EFLAGS)]>;
Evan Cheng6f26e8b2008-06-18 08:13:07 +00001967} // isCommutable = 1
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001968
Sean Callanan2c48df22009-12-18 00:01:26 +00001969// XOR instructions with the destination register in REG and the source register
1970// in R/M. Included for the disassembler.
1971def XOR8rr_REV : I<0x32, MRMSrcReg, (outs GR8:$dst), (ins GR8:$src1, GR8:$src2),
1972 "xor{b}\t{$src2, $dst|$dst, $src2}", []>;
1973def XOR16rr_REV : I<0x33, MRMSrcReg, (outs GR16:$dst),
1974 (ins GR16:$src1, GR16:$src2),
1975 "xor{w}\t{$src2, $dst|$dst, $src2}", []>, OpSize;
1976def XOR32rr_REV : I<0x33, MRMSrcReg, (outs GR32:$dst),
1977 (ins GR32:$src1, GR32:$src2),
1978 "xor{l}\t{$src2, $dst|$dst, $src2}", []>;
1979
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001980def XOR8rm : I<0x32, MRMSrcMem ,
Evan Chengb783fa32007-07-19 01:14:50 +00001981 (outs GR8 :$dst), (ins GR8:$src1, i8mem :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001982 "xor{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001983 [(set GR8:$dst, (xor GR8:$src1, (load addr:$src2))),
1984 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001985def XOR16rm : I<0x33, MRMSrcMem ,
Evan Chengb783fa32007-07-19 01:14:50 +00001986 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001987 "xor{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001988 [(set GR16:$dst, (xor GR16:$src1, (load addr:$src2))),
1989 (implicit EFLAGS)]>,
Bill Wendlingba5d5b02008-05-29 01:02:09 +00001990 OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001991def XOR32rm : I<0x33, MRMSrcMem ,
Evan Chengb783fa32007-07-19 01:14:50 +00001992 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001993 "xor{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001994 [(set GR32:$dst, (xor GR32:$src1, (load addr:$src2))),
1995 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001996
Bill Wendlingbac38eb2008-05-29 03:46:36 +00001997def XOR8ri : Ii8<0x80, MRM6r,
1998 (outs GR8:$dst), (ins GR8:$src1, i8imm:$src2),
1999 "xor{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00002000 [(set GR8:$dst, (xor GR8:$src1, imm:$src2)),
2001 (implicit EFLAGS)]>;
Bill Wendlingbac38eb2008-05-29 03:46:36 +00002002def XOR16ri : Ii16<0x81, MRM6r,
2003 (outs GR16:$dst), (ins GR16:$src1, i16imm:$src2),
2004 "xor{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00002005 [(set GR16:$dst, (xor GR16:$src1, imm:$src2)),
2006 (implicit EFLAGS)]>, OpSize;
Bill Wendlingbac38eb2008-05-29 03:46:36 +00002007def XOR32ri : Ii32<0x81, MRM6r,
2008 (outs GR32:$dst), (ins GR32:$src1, i32imm:$src2),
2009 "xor{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00002010 [(set GR32:$dst, (xor GR32:$src1, imm:$src2)),
2011 (implicit EFLAGS)]>;
Bill Wendlingbac38eb2008-05-29 03:46:36 +00002012def XOR16ri8 : Ii8<0x83, MRM6r,
2013 (outs GR16:$dst), (ins GR16:$src1, i16i8imm:$src2),
2014 "xor{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00002015 [(set GR16:$dst, (xor GR16:$src1, i16immSExt8:$src2)),
2016 (implicit EFLAGS)]>,
Bill Wendlingbac38eb2008-05-29 03:46:36 +00002017 OpSize;
2018def XOR32ri8 : Ii8<0x83, MRM6r,
2019 (outs GR32:$dst), (ins GR32:$src1, i32i8imm:$src2),
2020 "xor{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00002021 [(set GR32:$dst, (xor GR32:$src1, i32immSExt8:$src2)),
2022 (implicit EFLAGS)]>;
Bill Wendlingba5d5b02008-05-29 01:02:09 +00002023
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002024let isTwoAddress = 0 in {
2025 def XOR8mr : I<0x30, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00002026 (outs), (ins i8mem :$dst, GR8 :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002027 "xor{b}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00002028 [(store (xor (load addr:$dst), GR8:$src), addr:$dst),
2029 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002030 def XOR16mr : I<0x31, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00002031 (outs), (ins i16mem:$dst, GR16:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002032 "xor{w}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00002033 [(store (xor (load addr:$dst), GR16:$src), addr:$dst),
2034 (implicit EFLAGS)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002035 OpSize;
2036 def XOR32mr : I<0x31, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00002037 (outs), (ins i32mem:$dst, GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002038 "xor{l}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00002039 [(store (xor (load addr:$dst), GR32:$src), addr:$dst),
2040 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002041 def XOR8mi : Ii8<0x80, MRM6m,
Evan Chengb783fa32007-07-19 01:14:50 +00002042 (outs), (ins i8mem :$dst, i8imm :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002043 "xor{b}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00002044 [(store (xor (loadi8 addr:$dst), imm:$src), addr:$dst),
2045 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002046 def XOR16mi : Ii16<0x81, MRM6m,
Evan Chengb783fa32007-07-19 01:14:50 +00002047 (outs), (ins i16mem:$dst, i16imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002048 "xor{w}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00002049 [(store (xor (loadi16 addr:$dst), imm:$src), addr:$dst),
2050 (implicit EFLAGS)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002051 OpSize;
2052 def XOR32mi : Ii32<0x81, MRM6m,
Evan Chengb783fa32007-07-19 01:14:50 +00002053 (outs), (ins i32mem:$dst, i32imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002054 "xor{l}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00002055 [(store (xor (loadi32 addr:$dst), imm:$src), addr:$dst),
2056 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002057 def XOR16mi8 : Ii8<0x83, MRM6m,
Evan Chengb783fa32007-07-19 01:14:50 +00002058 (outs), (ins i16mem:$dst, i16i8imm :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002059 "xor{w}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00002060 [(store (xor (load addr:$dst), i16immSExt8:$src), addr:$dst),
2061 (implicit EFLAGS)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002062 OpSize;
2063 def XOR32mi8 : Ii8<0x83, MRM6m,
Evan Chengb783fa32007-07-19 01:14:50 +00002064 (outs), (ins i32mem:$dst, i32i8imm :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002065 "xor{l}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00002066 [(store (xor (load addr:$dst), i32immSExt8:$src), addr:$dst),
2067 (implicit EFLAGS)]>;
Sean Callanan794457a2009-09-10 19:52:26 +00002068
2069 def XOR8i8 : Ii8 <0x34, RawFrm, (outs), (ins i8imm:$src),
2070 "xor{b}\t{$src, %al|%al, $src}", []>;
2071 def XOR16i16 : Ii16 <0x35, RawFrm, (outs), (ins i16imm:$src),
2072 "xor{w}\t{$src, %ax|%ax, $src}", []>, OpSize;
2073 def XOR32i32 : Ii32 <0x35, RawFrm, (outs), (ins i32imm:$src),
2074 "xor{l}\t{$src, %eax|%eax, $src}", []>;
Bill Wendlingba5d5b02008-05-29 01:02:09 +00002075} // isTwoAddress = 0
Evan Cheng55687072007-09-14 21:48:26 +00002076} // Defs = [EFLAGS]
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002077
2078// Shift instructions
Evan Cheng55687072007-09-14 21:48:26 +00002079let Defs = [EFLAGS] in {
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002080let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00002081def SHL8rCL : I<0xD2, MRM4r, (outs GR8 :$dst), (ins GR8 :$src),
Eli Friedman378ea832009-06-19 04:48:38 +00002082 "shl{b}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002083 [(set GR8:$dst, (shl GR8:$src, CL))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002084def SHL16rCL : I<0xD3, MRM4r, (outs GR16:$dst), (ins GR16:$src),
Eli Friedman378ea832009-06-19 04:48:38 +00002085 "shl{w}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002086 [(set GR16:$dst, (shl GR16:$src, CL))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002087def SHL32rCL : I<0xD3, MRM4r, (outs GR32:$dst), (ins GR32:$src),
Eli Friedman378ea832009-06-19 04:48:38 +00002088 "shl{l}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002089 [(set GR32:$dst, (shl GR32:$src, CL))]>;
Bill Wendlingba5d5b02008-05-29 01:02:09 +00002090} // Uses = [CL]
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002091
Evan Chengb783fa32007-07-19 01:14:50 +00002092def SHL8ri : Ii8<0xC0, MRM4r, (outs GR8 :$dst), (ins GR8 :$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002093 "shl{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002094 [(set GR8:$dst, (shl GR8:$src1, (i8 imm:$src2)))]>;
2095let isConvertibleToThreeAddress = 1 in { // Can transform into LEA.
Evan Chengb783fa32007-07-19 01:14:50 +00002096def SHL16ri : Ii8<0xC1, MRM4r, (outs GR16:$dst), (ins GR16:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002097 "shl{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002098 [(set GR16:$dst, (shl GR16:$src1, (i8 imm:$src2)))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002099def SHL32ri : Ii8<0xC1, MRM4r, (outs GR32:$dst), (ins GR32:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002100 "shl{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002101 [(set GR32:$dst, (shl GR32:$src1, (i8 imm:$src2)))]>;
Sean Callananca503e02009-09-16 02:28:43 +00002102
2103// NOTE: We don't include patterns for shifts of a register by one, because
2104// 'add reg,reg' is cheaper.
2105
2106def SHL8r1 : I<0xD0, MRM4r, (outs GR8:$dst), (ins GR8:$src1),
2107 "shl{b}\t$dst", []>;
2108def SHL16r1 : I<0xD1, MRM4r, (outs GR16:$dst), (ins GR16:$src1),
2109 "shl{w}\t$dst", []>, OpSize;
2110def SHL32r1 : I<0xD1, MRM4r, (outs GR32:$dst), (ins GR32:$src1),
2111 "shl{l}\t$dst", []>;
2112
Bill Wendlingba5d5b02008-05-29 01:02:09 +00002113} // isConvertibleToThreeAddress = 1
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002114
2115let isTwoAddress = 0 in {
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002116 let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00002117 def SHL8mCL : I<0xD2, MRM4m, (outs), (ins i8mem :$dst),
Eli Friedman378ea832009-06-19 04:48:38 +00002118 "shl{b}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002119 [(store (shl (loadi8 addr:$dst), CL), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002120 def SHL16mCL : I<0xD3, MRM4m, (outs), (ins i16mem:$dst),
Eli Friedman378ea832009-06-19 04:48:38 +00002121 "shl{w}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002122 [(store (shl (loadi16 addr:$dst), CL), addr:$dst)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002123 def SHL32mCL : I<0xD3, MRM4m, (outs), (ins i32mem:$dst),
Eli Friedman378ea832009-06-19 04:48:38 +00002124 "shl{l}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002125 [(store (shl (loadi32 addr:$dst), CL), addr:$dst)]>;
2126 }
Evan Chengb783fa32007-07-19 01:14:50 +00002127 def SHL8mi : Ii8<0xC0, MRM4m, (outs), (ins i8mem :$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002128 "shl{b}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002129 [(store (shl (loadi8 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002130 def SHL16mi : Ii8<0xC1, MRM4m, (outs), (ins i16mem:$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002131 "shl{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002132 [(store (shl (loadi16 addr:$dst), (i8 imm:$src)), addr:$dst)]>,
2133 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002134 def SHL32mi : Ii8<0xC1, MRM4m, (outs), (ins i32mem:$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002135 "shl{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002136 [(store (shl (loadi32 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
2137
2138 // Shift by 1
Evan Chengb783fa32007-07-19 01:14:50 +00002139 def SHL8m1 : I<0xD0, MRM4m, (outs), (ins i8mem :$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002140 "shl{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002141 [(store (shl (loadi8 addr:$dst), (i8 1)), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002142 def SHL16m1 : I<0xD1, MRM4m, (outs), (ins i16mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002143 "shl{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002144 [(store (shl (loadi16 addr:$dst), (i8 1)), addr:$dst)]>,
2145 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002146 def SHL32m1 : I<0xD1, MRM4m, (outs), (ins i32mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002147 "shl{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002148 [(store (shl (loadi32 addr:$dst), (i8 1)), addr:$dst)]>;
2149}
2150
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002151let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00002152def SHR8rCL : I<0xD2, MRM5r, (outs GR8 :$dst), (ins GR8 :$src),
Eli Friedman378ea832009-06-19 04:48:38 +00002153 "shr{b}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002154 [(set GR8:$dst, (srl GR8:$src, CL))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002155def SHR16rCL : I<0xD3, MRM5r, (outs GR16:$dst), (ins GR16:$src),
Eli Friedman378ea832009-06-19 04:48:38 +00002156 "shr{w}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002157 [(set GR16:$dst, (srl GR16:$src, CL))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002158def SHR32rCL : I<0xD3, MRM5r, (outs GR32:$dst), (ins GR32:$src),
Eli Friedman378ea832009-06-19 04:48:38 +00002159 "shr{l}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002160 [(set GR32:$dst, (srl GR32:$src, CL))]>;
2161}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002162
Evan Chengb783fa32007-07-19 01:14:50 +00002163def SHR8ri : Ii8<0xC0, MRM5r, (outs GR8:$dst), (ins GR8:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002164 "shr{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002165 [(set GR8:$dst, (srl GR8:$src1, (i8 imm:$src2)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002166def SHR16ri : Ii8<0xC1, MRM5r, (outs GR16:$dst), (ins GR16:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002167 "shr{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002168 [(set GR16:$dst, (srl GR16:$src1, (i8 imm:$src2)))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002169def SHR32ri : Ii8<0xC1, MRM5r, (outs GR32:$dst), (ins GR32:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002170 "shr{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002171 [(set GR32:$dst, (srl GR32:$src1, (i8 imm:$src2)))]>;
2172
2173// Shift by 1
Evan Chengb783fa32007-07-19 01:14:50 +00002174def SHR8r1 : I<0xD0, MRM5r, (outs GR8:$dst), (ins GR8:$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00002175 "shr{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002176 [(set GR8:$dst, (srl GR8:$src1, (i8 1)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002177def SHR16r1 : I<0xD1, MRM5r, (outs GR16:$dst), (ins GR16:$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00002178 "shr{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002179 [(set GR16:$dst, (srl GR16:$src1, (i8 1)))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002180def SHR32r1 : I<0xD1, MRM5r, (outs GR32:$dst), (ins GR32:$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00002181 "shr{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002182 [(set GR32:$dst, (srl GR32:$src1, (i8 1)))]>;
2183
2184let isTwoAddress = 0 in {
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002185 let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00002186 def SHR8mCL : I<0xD2, MRM5m, (outs), (ins i8mem :$dst),
Eli Friedman378ea832009-06-19 04:48:38 +00002187 "shr{b}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002188 [(store (srl (loadi8 addr:$dst), CL), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002189 def SHR16mCL : I<0xD3, MRM5m, (outs), (ins i16mem:$dst),
Eli Friedman378ea832009-06-19 04:48:38 +00002190 "shr{w}\t{%cl, $dst|$dst, CL}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002191 [(store (srl (loadi16 addr:$dst), CL), addr:$dst)]>,
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002192 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002193 def SHR32mCL : I<0xD3, MRM5m, (outs), (ins i32mem:$dst),
Eli Friedman378ea832009-06-19 04:48:38 +00002194 "shr{l}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002195 [(store (srl (loadi32 addr:$dst), CL), addr:$dst)]>;
2196 }
Evan Chengb783fa32007-07-19 01:14:50 +00002197 def SHR8mi : Ii8<0xC0, MRM5m, (outs), (ins i8mem :$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002198 "shr{b}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002199 [(store (srl (loadi8 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002200 def SHR16mi : Ii8<0xC1, MRM5m, (outs), (ins i16mem:$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002201 "shr{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002202 [(store (srl (loadi16 addr:$dst), (i8 imm:$src)), addr:$dst)]>,
2203 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002204 def SHR32mi : Ii8<0xC1, MRM5m, (outs), (ins i32mem:$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002205 "shr{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002206 [(store (srl (loadi32 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
2207
2208 // Shift by 1
Evan Chengb783fa32007-07-19 01:14:50 +00002209 def SHR8m1 : I<0xD0, MRM5m, (outs), (ins i8mem :$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002210 "shr{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002211 [(store (srl (loadi8 addr:$dst), (i8 1)), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002212 def SHR16m1 : I<0xD1, MRM5m, (outs), (ins i16mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002213 "shr{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002214 [(store (srl (loadi16 addr:$dst), (i8 1)), addr:$dst)]>,OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002215 def SHR32m1 : I<0xD1, MRM5m, (outs), (ins i32mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002216 "shr{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002217 [(store (srl (loadi32 addr:$dst), (i8 1)), addr:$dst)]>;
2218}
2219
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002220let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00002221def SAR8rCL : I<0xD2, MRM7r, (outs GR8 :$dst), (ins GR8 :$src),
Eli Friedman378ea832009-06-19 04:48:38 +00002222 "sar{b}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002223 [(set GR8:$dst, (sra GR8:$src, CL))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002224def SAR16rCL : I<0xD3, MRM7r, (outs GR16:$dst), (ins GR16:$src),
Eli Friedman378ea832009-06-19 04:48:38 +00002225 "sar{w}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002226 [(set GR16:$dst, (sra GR16:$src, CL))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002227def SAR32rCL : I<0xD3, MRM7r, (outs GR32:$dst), (ins GR32:$src),
Eli Friedman378ea832009-06-19 04:48:38 +00002228 "sar{l}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002229 [(set GR32:$dst, (sra GR32:$src, CL))]>;
2230}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002231
Evan Chengb783fa32007-07-19 01:14:50 +00002232def SAR8ri : Ii8<0xC0, MRM7r, (outs GR8 :$dst), (ins GR8 :$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002233 "sar{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002234 [(set GR8:$dst, (sra GR8:$src1, (i8 imm:$src2)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002235def SAR16ri : Ii8<0xC1, MRM7r, (outs GR16:$dst), (ins GR16:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002236 "sar{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002237 [(set GR16:$dst, (sra GR16:$src1, (i8 imm:$src2)))]>,
2238 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002239def SAR32ri : Ii8<0xC1, MRM7r, (outs GR32:$dst), (ins GR32:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002240 "sar{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002241 [(set GR32:$dst, (sra GR32:$src1, (i8 imm:$src2)))]>;
2242
2243// Shift by 1
Evan Chengb783fa32007-07-19 01:14:50 +00002244def SAR8r1 : I<0xD0, MRM7r, (outs GR8 :$dst), (ins GR8 :$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00002245 "sar{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002246 [(set GR8:$dst, (sra GR8:$src1, (i8 1)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002247def SAR16r1 : I<0xD1, MRM7r, (outs GR16:$dst), (ins GR16:$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00002248 "sar{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002249 [(set GR16:$dst, (sra GR16:$src1, (i8 1)))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002250def SAR32r1 : I<0xD1, MRM7r, (outs GR32:$dst), (ins GR32:$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00002251 "sar{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002252 [(set GR32:$dst, (sra GR32:$src1, (i8 1)))]>;
2253
2254let isTwoAddress = 0 in {
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002255 let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00002256 def SAR8mCL : I<0xD2, MRM7m, (outs), (ins i8mem :$dst),
Eli Friedman378ea832009-06-19 04:48:38 +00002257 "sar{b}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002258 [(store (sra (loadi8 addr:$dst), CL), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002259 def SAR16mCL : I<0xD3, MRM7m, (outs), (ins i16mem:$dst),
Eli Friedman378ea832009-06-19 04:48:38 +00002260 "sar{w}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002261 [(store (sra (loadi16 addr:$dst), CL), addr:$dst)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002262 def SAR32mCL : I<0xD3, MRM7m, (outs), (ins i32mem:$dst),
Eli Friedman378ea832009-06-19 04:48:38 +00002263 "sar{l}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002264 [(store (sra (loadi32 addr:$dst), CL), addr:$dst)]>;
2265 }
Evan Chengb783fa32007-07-19 01:14:50 +00002266 def SAR8mi : Ii8<0xC0, MRM7m, (outs), (ins i8mem :$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002267 "sar{b}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002268 [(store (sra (loadi8 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002269 def SAR16mi : Ii8<0xC1, MRM7m, (outs), (ins i16mem:$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002270 "sar{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002271 [(store (sra (loadi16 addr:$dst), (i8 imm:$src)), addr:$dst)]>,
2272 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002273 def SAR32mi : Ii8<0xC1, MRM7m, (outs), (ins i32mem:$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002274 "sar{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002275 [(store (sra (loadi32 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
2276
2277 // Shift by 1
Evan Chengb783fa32007-07-19 01:14:50 +00002278 def SAR8m1 : I<0xD0, MRM7m, (outs), (ins i8mem :$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002279 "sar{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002280 [(store (sra (loadi8 addr:$dst), (i8 1)), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002281 def SAR16m1 : I<0xD1, MRM7m, (outs), (ins i16mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002282 "sar{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002283 [(store (sra (loadi16 addr:$dst), (i8 1)), addr:$dst)]>,
2284 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002285 def SAR32m1 : I<0xD1, MRM7m, (outs), (ins i32mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002286 "sar{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002287 [(store (sra (loadi32 addr:$dst), (i8 1)), addr:$dst)]>;
2288}
2289
2290// Rotate instructions
Sean Callanan3c8eecd2009-09-18 19:35:23 +00002291
2292def RCL8r1 : I<0xD0, MRM2r, (outs GR8:$dst), (ins GR8:$src),
2293 "rcl{b}\t{1, $dst|$dst, 1}", []>;
2294def RCL8m1 : I<0xD0, MRM2m, (outs i8mem:$dst), (ins i8mem:$src),
2295 "rcl{b}\t{1, $dst|$dst, 1}", []>;
2296let Uses = [CL] in {
2297def RCL8rCL : I<0xD2, MRM2r, (outs GR8:$dst), (ins GR8:$src),
2298 "rcl{b}\t{%cl, $dst|$dst, CL}", []>;
2299def RCL8mCL : I<0xD2, MRM2m, (outs i8mem:$dst), (ins i8mem:$src),
2300 "rcl{b}\t{%cl, $dst|$dst, CL}", []>;
2301}
2302def RCL8ri : Ii8<0xC0, MRM2r, (outs GR8:$dst), (ins GR8:$src, i8imm:$cnt),
2303 "rcl{b}\t{$cnt, $dst|$dst, $cnt}", []>;
2304def RCL8mi : Ii8<0xC0, MRM2m, (outs i8mem:$dst), (ins i8mem:$src, i8imm:$cnt),
2305 "rcl{b}\t{$cnt, $dst|$dst, $cnt}", []>;
2306
2307def RCL16r1 : I<0xD1, MRM2r, (outs GR16:$dst), (ins GR16:$src),
2308 "rcl{w}\t{1, $dst|$dst, 1}", []>, OpSize;
2309def RCL16m1 : I<0xD1, MRM2m, (outs i16mem:$dst), (ins i16mem:$src),
2310 "rcl{w}\t{1, $dst|$dst, 1}", []>, OpSize;
2311let Uses = [CL] in {
2312def RCL16rCL : I<0xD3, MRM2r, (outs GR16:$dst), (ins GR16:$src),
2313 "rcl{w}\t{%cl, $dst|$dst, CL}", []>, OpSize;
2314def RCL16mCL : I<0xD3, MRM2m, (outs i16mem:$dst), (ins i16mem:$src),
2315 "rcl{w}\t{%cl, $dst|$dst, CL}", []>, OpSize;
2316}
2317def RCL16ri : Ii8<0xC1, MRM2r, (outs GR16:$dst), (ins GR16:$src, i8imm:$cnt),
2318 "rcl{w}\t{$cnt, $dst|$dst, $cnt}", []>, OpSize;
Sean Callanan2c48df22009-12-18 00:01:26 +00002319def RCL16mi : Ii8<0xC1, MRM2m, (outs i16mem:$dst),
2320 (ins i16mem:$src, i8imm:$cnt),
Sean Callanan3c8eecd2009-09-18 19:35:23 +00002321 "rcl{w}\t{$cnt, $dst|$dst, $cnt}", []>, OpSize;
2322
2323def RCL32r1 : I<0xD1, MRM2r, (outs GR32:$dst), (ins GR32:$src),
2324 "rcl{l}\t{1, $dst|$dst, 1}", []>;
2325def RCL32m1 : I<0xD1, MRM2m, (outs i32mem:$dst), (ins i32mem:$src),
2326 "rcl{l}\t{1, $dst|$dst, 1}", []>;
2327let Uses = [CL] in {
2328def RCL32rCL : I<0xD3, MRM2r, (outs GR32:$dst), (ins GR32:$src),
2329 "rcl{l}\t{%cl, $dst|$dst, CL}", []>;
2330def RCL32mCL : I<0xD3, MRM2m, (outs i32mem:$dst), (ins i32mem:$src),
2331 "rcl{l}\t{%cl, $dst|$dst, CL}", []>;
2332}
2333def RCL32ri : Ii8<0xC1, MRM2r, (outs GR32:$dst), (ins GR32:$src, i8imm:$cnt),
2334 "rcl{l}\t{$cnt, $dst|$dst, $cnt}", []>;
Sean Callanan2c48df22009-12-18 00:01:26 +00002335def RCL32mi : Ii8<0xC1, MRM2m, (outs i32mem:$dst),
2336 (ins i32mem:$src, i8imm:$cnt),
Sean Callanan3c8eecd2009-09-18 19:35:23 +00002337 "rcl{l}\t{$cnt, $dst|$dst, $cnt}", []>;
2338
2339def RCR8r1 : I<0xD0, MRM3r, (outs GR8:$dst), (ins GR8:$src),
2340 "rcr{b}\t{1, $dst|$dst, 1}", []>;
2341def RCR8m1 : I<0xD0, MRM3m, (outs i8mem:$dst), (ins i8mem:$src),
2342 "rcr{b}\t{1, $dst|$dst, 1}", []>;
2343let Uses = [CL] in {
2344def RCR8rCL : I<0xD2, MRM3r, (outs GR8:$dst), (ins GR8:$src),
2345 "rcr{b}\t{%cl, $dst|$dst, CL}", []>;
2346def RCR8mCL : I<0xD2, MRM3m, (outs i8mem:$dst), (ins i8mem:$src),
2347 "rcr{b}\t{%cl, $dst|$dst, CL}", []>;
2348}
2349def RCR8ri : Ii8<0xC0, MRM3r, (outs GR8:$dst), (ins GR8:$src, i8imm:$cnt),
2350 "rcr{b}\t{$cnt, $dst|$dst, $cnt}", []>;
2351def RCR8mi : Ii8<0xC0, MRM3m, (outs i8mem:$dst), (ins i8mem:$src, i8imm:$cnt),
2352 "rcr{b}\t{$cnt, $dst|$dst, $cnt}", []>;
2353
2354def RCR16r1 : I<0xD1, MRM3r, (outs GR16:$dst), (ins GR16:$src),
2355 "rcr{w}\t{1, $dst|$dst, 1}", []>, OpSize;
2356def RCR16m1 : I<0xD1, MRM3m, (outs i16mem:$dst), (ins i16mem:$src),
2357 "rcr{w}\t{1, $dst|$dst, 1}", []>, OpSize;
2358let Uses = [CL] in {
2359def RCR16rCL : I<0xD3, MRM3r, (outs GR16:$dst), (ins GR16:$src),
2360 "rcr{w}\t{%cl, $dst|$dst, CL}", []>, OpSize;
2361def RCR16mCL : I<0xD3, MRM3m, (outs i16mem:$dst), (ins i16mem:$src),
2362 "rcr{w}\t{%cl, $dst|$dst, CL}", []>, OpSize;
2363}
2364def RCR16ri : Ii8<0xC1, MRM3r, (outs GR16:$dst), (ins GR16:$src, i8imm:$cnt),
2365 "rcr{w}\t{$cnt, $dst|$dst, $cnt}", []>, OpSize;
Sean Callanan2c48df22009-12-18 00:01:26 +00002366def RCR16mi : Ii8<0xC1, MRM3m, (outs i16mem:$dst),
2367 (ins i16mem:$src, i8imm:$cnt),
Sean Callanan3c8eecd2009-09-18 19:35:23 +00002368 "rcr{w}\t{$cnt, $dst|$dst, $cnt}", []>, OpSize;
2369
2370def RCR32r1 : I<0xD1, MRM3r, (outs GR32:$dst), (ins GR32:$src),
2371 "rcr{l}\t{1, $dst|$dst, 1}", []>;
2372def RCR32m1 : I<0xD1, MRM3m, (outs i32mem:$dst), (ins i32mem:$src),
2373 "rcr{l}\t{1, $dst|$dst, 1}", []>;
2374let Uses = [CL] in {
2375def RCR32rCL : I<0xD3, MRM3r, (outs GR32:$dst), (ins GR32:$src),
2376 "rcr{l}\t{%cl, $dst|$dst, CL}", []>;
2377def RCR32mCL : I<0xD3, MRM3m, (outs i32mem:$dst), (ins i32mem:$src),
2378 "rcr{l}\t{%cl, $dst|$dst, CL}", []>;
2379}
2380def RCR32ri : Ii8<0xC1, MRM3r, (outs GR32:$dst), (ins GR32:$src, i8imm:$cnt),
2381 "rcr{l}\t{$cnt, $dst|$dst, $cnt}", []>;
Sean Callanan2c48df22009-12-18 00:01:26 +00002382def RCR32mi : Ii8<0xC1, MRM3m, (outs i32mem:$dst),
2383 (ins i32mem:$src, i8imm:$cnt),
Sean Callanan3c8eecd2009-09-18 19:35:23 +00002384 "rcr{l}\t{$cnt, $dst|$dst, $cnt}", []>;
2385
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002386// FIXME: provide shorter instructions when imm8 == 1
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002387let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00002388def ROL8rCL : I<0xD2, MRM0r, (outs GR8 :$dst), (ins GR8 :$src),
Eli Friedman378ea832009-06-19 04:48:38 +00002389 "rol{b}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002390 [(set GR8:$dst, (rotl GR8:$src, CL))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002391def ROL16rCL : I<0xD3, MRM0r, (outs GR16:$dst), (ins GR16:$src),
Eli Friedman378ea832009-06-19 04:48:38 +00002392 "rol{w}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002393 [(set GR16:$dst, (rotl GR16:$src, CL))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002394def ROL32rCL : I<0xD3, MRM0r, (outs GR32:$dst), (ins GR32:$src),
Eli Friedman378ea832009-06-19 04:48:38 +00002395 "rol{l}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002396 [(set GR32:$dst, (rotl GR32:$src, CL))]>;
2397}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002398
Evan Chengb783fa32007-07-19 01:14:50 +00002399def ROL8ri : Ii8<0xC0, MRM0r, (outs GR8 :$dst), (ins GR8 :$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002400 "rol{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002401 [(set GR8:$dst, (rotl GR8:$src1, (i8 imm:$src2)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002402def ROL16ri : Ii8<0xC1, MRM0r, (outs GR16:$dst), (ins GR16:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002403 "rol{w}\t{$src2, $dst|$dst, $src2}",
Sean Callanan2c48df22009-12-18 00:01:26 +00002404 [(set GR16:$dst, (rotl GR16:$src1, (i8 imm:$src2)))]>,
2405 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002406def ROL32ri : Ii8<0xC1, MRM0r, (outs GR32:$dst), (ins GR32:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002407 "rol{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002408 [(set GR32:$dst, (rotl GR32:$src1, (i8 imm:$src2)))]>;
2409
2410// Rotate by 1
Evan Chengb783fa32007-07-19 01:14:50 +00002411def ROL8r1 : I<0xD0, MRM0r, (outs GR8 :$dst), (ins GR8 :$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00002412 "rol{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002413 [(set GR8:$dst, (rotl GR8:$src1, (i8 1)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002414def ROL16r1 : I<0xD1, MRM0r, (outs GR16:$dst), (ins GR16:$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00002415 "rol{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002416 [(set GR16:$dst, (rotl GR16:$src1, (i8 1)))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002417def ROL32r1 : I<0xD1, MRM0r, (outs GR32:$dst), (ins GR32:$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00002418 "rol{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002419 [(set GR32:$dst, (rotl GR32:$src1, (i8 1)))]>;
2420
2421let isTwoAddress = 0 in {
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002422 let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00002423 def ROL8mCL : I<0xD2, MRM0m, (outs), (ins i8mem :$dst),
Eli Friedman378ea832009-06-19 04:48:38 +00002424 "rol{b}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002425 [(store (rotl (loadi8 addr:$dst), CL), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002426 def ROL16mCL : I<0xD3, MRM0m, (outs), (ins i16mem:$dst),
Eli Friedman378ea832009-06-19 04:48:38 +00002427 "rol{w}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002428 [(store (rotl (loadi16 addr:$dst), CL), addr:$dst)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002429 def ROL32mCL : I<0xD3, MRM0m, (outs), (ins i32mem:$dst),
Eli Friedman378ea832009-06-19 04:48:38 +00002430 "rol{l}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002431 [(store (rotl (loadi32 addr:$dst), CL), addr:$dst)]>;
2432 }
Evan Chengb783fa32007-07-19 01:14:50 +00002433 def ROL8mi : Ii8<0xC0, MRM0m, (outs), (ins i8mem :$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002434 "rol{b}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002435 [(store (rotl (loadi8 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002436 def ROL16mi : Ii8<0xC1, MRM0m, (outs), (ins i16mem:$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002437 "rol{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002438 [(store (rotl (loadi16 addr:$dst), (i8 imm:$src)), addr:$dst)]>,
2439 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002440 def ROL32mi : Ii8<0xC1, MRM0m, (outs), (ins i32mem:$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002441 "rol{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002442 [(store (rotl (loadi32 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
2443
2444 // Rotate by 1
Evan Chengb783fa32007-07-19 01:14:50 +00002445 def ROL8m1 : I<0xD0, MRM0m, (outs), (ins i8mem :$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002446 "rol{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002447 [(store (rotl (loadi8 addr:$dst), (i8 1)), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002448 def ROL16m1 : I<0xD1, MRM0m, (outs), (ins i16mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002449 "rol{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002450 [(store (rotl (loadi16 addr:$dst), (i8 1)), addr:$dst)]>,
2451 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002452 def ROL32m1 : I<0xD1, MRM0m, (outs), (ins i32mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002453 "rol{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002454 [(store (rotl (loadi32 addr:$dst), (i8 1)), addr:$dst)]>;
2455}
2456
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002457let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00002458def ROR8rCL : I<0xD2, MRM1r, (outs GR8 :$dst), (ins GR8 :$src),
Eli Friedman378ea832009-06-19 04:48:38 +00002459 "ror{b}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002460 [(set GR8:$dst, (rotr GR8:$src, CL))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002461def ROR16rCL : I<0xD3, MRM1r, (outs GR16:$dst), (ins GR16:$src),
Eli Friedman378ea832009-06-19 04:48:38 +00002462 "ror{w}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002463 [(set GR16:$dst, (rotr GR16:$src, CL))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002464def ROR32rCL : I<0xD3, MRM1r, (outs GR32:$dst), (ins GR32:$src),
Eli Friedman378ea832009-06-19 04:48:38 +00002465 "ror{l}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002466 [(set GR32:$dst, (rotr GR32:$src, CL))]>;
2467}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002468
Evan Chengb783fa32007-07-19 01:14:50 +00002469def ROR8ri : Ii8<0xC0, MRM1r, (outs GR8 :$dst), (ins GR8 :$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002470 "ror{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002471 [(set GR8:$dst, (rotr GR8:$src1, (i8 imm:$src2)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002472def ROR16ri : Ii8<0xC1, MRM1r, (outs GR16:$dst), (ins GR16:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002473 "ror{w}\t{$src2, $dst|$dst, $src2}",
Sean Callanan2c48df22009-12-18 00:01:26 +00002474 [(set GR16:$dst, (rotr GR16:$src1, (i8 imm:$src2)))]>,
2475 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002476def ROR32ri : Ii8<0xC1, MRM1r, (outs GR32:$dst), (ins GR32:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002477 "ror{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002478 [(set GR32:$dst, (rotr GR32:$src1, (i8 imm:$src2)))]>;
2479
2480// Rotate by 1
Evan Chengb783fa32007-07-19 01:14:50 +00002481def ROR8r1 : I<0xD0, MRM1r, (outs GR8 :$dst), (ins GR8 :$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00002482 "ror{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002483 [(set GR8:$dst, (rotr GR8:$src1, (i8 1)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002484def ROR16r1 : I<0xD1, MRM1r, (outs GR16:$dst), (ins GR16:$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00002485 "ror{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002486 [(set GR16:$dst, (rotr GR16:$src1, (i8 1)))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002487def ROR32r1 : I<0xD1, MRM1r, (outs GR32:$dst), (ins GR32:$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00002488 "ror{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002489 [(set GR32:$dst, (rotr GR32:$src1, (i8 1)))]>;
2490
2491let isTwoAddress = 0 in {
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002492 let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00002493 def ROR8mCL : I<0xD2, MRM1m, (outs), (ins i8mem :$dst),
Eli Friedman378ea832009-06-19 04:48:38 +00002494 "ror{b}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002495 [(store (rotr (loadi8 addr:$dst), CL), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002496 def ROR16mCL : I<0xD3, MRM1m, (outs), (ins i16mem:$dst),
Eli Friedman378ea832009-06-19 04:48:38 +00002497 "ror{w}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002498 [(store (rotr (loadi16 addr:$dst), CL), addr:$dst)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002499 def ROR32mCL : I<0xD3, MRM1m, (outs), (ins i32mem:$dst),
Eli Friedman378ea832009-06-19 04:48:38 +00002500 "ror{l}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002501 [(store (rotr (loadi32 addr:$dst), CL), addr:$dst)]>;
2502 }
Evan Chengb783fa32007-07-19 01:14:50 +00002503 def ROR8mi : Ii8<0xC0, MRM1m, (outs), (ins i8mem :$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002504 "ror{b}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002505 [(store (rotr (loadi8 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002506 def ROR16mi : Ii8<0xC1, MRM1m, (outs), (ins i16mem:$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002507 "ror{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002508 [(store (rotr (loadi16 addr:$dst), (i8 imm:$src)), addr:$dst)]>,
2509 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002510 def ROR32mi : Ii8<0xC1, MRM1m, (outs), (ins i32mem:$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002511 "ror{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002512 [(store (rotr (loadi32 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
2513
2514 // Rotate by 1
Evan Chengb783fa32007-07-19 01:14:50 +00002515 def ROR8m1 : I<0xD0, MRM1m, (outs), (ins i8mem :$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002516 "ror{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002517 [(store (rotr (loadi8 addr:$dst), (i8 1)), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002518 def ROR16m1 : I<0xD1, MRM1m, (outs), (ins i16mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002519 "ror{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002520 [(store (rotr (loadi16 addr:$dst), (i8 1)), addr:$dst)]>,
2521 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002522 def ROR32m1 : I<0xD1, MRM1m, (outs), (ins i32mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002523 "ror{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002524 [(store (rotr (loadi32 addr:$dst), (i8 1)), addr:$dst)]>;
2525}
2526
2527
2528
2529// Double shift instructions (generalizations of rotate)
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002530let Uses = [CL] in {
Sean Callanan2c48df22009-12-18 00:01:26 +00002531def SHLD32rrCL : I<0xA5, MRMDestReg, (outs GR32:$dst),
2532 (ins GR32:$src1, GR32:$src2),
Eli Friedman378ea832009-06-19 04:48:38 +00002533 "shld{l}\t{%cl, $src2, $dst|$dst, $src2, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002534 [(set GR32:$dst, (X86shld GR32:$src1, GR32:$src2, CL))]>, TB;
Sean Callanan2c48df22009-12-18 00:01:26 +00002535def SHRD32rrCL : I<0xAD, MRMDestReg, (outs GR32:$dst),
2536 (ins GR32:$src1, GR32:$src2),
Eli Friedman378ea832009-06-19 04:48:38 +00002537 "shrd{l}\t{%cl, $src2, $dst|$dst, $src2, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002538 [(set GR32:$dst, (X86shrd GR32:$src1, GR32:$src2, CL))]>, TB;
Sean Callanan2c48df22009-12-18 00:01:26 +00002539def SHLD16rrCL : I<0xA5, MRMDestReg, (outs GR16:$dst),
2540 (ins GR16:$src1, GR16:$src2),
Eli Friedman378ea832009-06-19 04:48:38 +00002541 "shld{w}\t{%cl, $src2, $dst|$dst, $src2, CL}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002542 [(set GR16:$dst, (X86shld GR16:$src1, GR16:$src2, CL))]>,
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002543 TB, OpSize;
Sean Callanan2c48df22009-12-18 00:01:26 +00002544def SHRD16rrCL : I<0xAD, MRMDestReg, (outs GR16:$dst),
2545 (ins GR16:$src1, GR16:$src2),
Eli Friedman378ea832009-06-19 04:48:38 +00002546 "shrd{w}\t{%cl, $src2, $dst|$dst, $src2, CL}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002547 [(set GR16:$dst, (X86shrd GR16:$src1, GR16:$src2, CL))]>,
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002548 TB, OpSize;
2549}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002550
2551let isCommutable = 1 in { // These instructions commute to each other.
2552def SHLD32rri8 : Ii8<0xA4, MRMDestReg,
Sean Callanan2c48df22009-12-18 00:01:26 +00002553 (outs GR32:$dst),
2554 (ins GR32:$src1, GR32:$src2, i8imm:$src3),
Dan Gohman91888f02007-07-31 20:11:57 +00002555 "shld{l}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002556 [(set GR32:$dst, (X86shld GR32:$src1, GR32:$src2,
2557 (i8 imm:$src3)))]>,
2558 TB;
2559def SHRD32rri8 : Ii8<0xAC, MRMDestReg,
Sean Callanan2c48df22009-12-18 00:01:26 +00002560 (outs GR32:$dst),
2561 (ins GR32:$src1, GR32:$src2, i8imm:$src3),
Dan Gohman91888f02007-07-31 20:11:57 +00002562 "shrd{l}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002563 [(set GR32:$dst, (X86shrd GR32:$src1, GR32:$src2,
2564 (i8 imm:$src3)))]>,
2565 TB;
2566def SHLD16rri8 : Ii8<0xA4, MRMDestReg,
Sean Callanan2c48df22009-12-18 00:01:26 +00002567 (outs GR16:$dst),
2568 (ins GR16:$src1, GR16:$src2, i8imm:$src3),
Dan Gohman91888f02007-07-31 20:11:57 +00002569 "shld{w}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002570 [(set GR16:$dst, (X86shld GR16:$src1, GR16:$src2,
2571 (i8 imm:$src3)))]>,
2572 TB, OpSize;
2573def SHRD16rri8 : Ii8<0xAC, MRMDestReg,
Sean Callanan2c48df22009-12-18 00:01:26 +00002574 (outs GR16:$dst),
2575 (ins GR16:$src1, GR16:$src2, i8imm:$src3),
Dan Gohman91888f02007-07-31 20:11:57 +00002576 "shrd{w}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002577 [(set GR16:$dst, (X86shrd GR16:$src1, GR16:$src2,
2578 (i8 imm:$src3)))]>,
2579 TB, OpSize;
2580}
2581
2582let isTwoAddress = 0 in {
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002583 let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00002584 def SHLD32mrCL : I<0xA5, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
Eli Friedman378ea832009-06-19 04:48:38 +00002585 "shld{l}\t{%cl, $src2, $dst|$dst, $src2, CL}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002586 [(store (X86shld (loadi32 addr:$dst), GR32:$src2, CL),
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002587 addr:$dst)]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00002588 def SHRD32mrCL : I<0xAD, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
Eli Friedman378ea832009-06-19 04:48:38 +00002589 "shrd{l}\t{%cl, $src2, $dst|$dst, $src2, CL}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002590 [(store (X86shrd (loadi32 addr:$dst), GR32:$src2, CL),
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002591 addr:$dst)]>, TB;
2592 }
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002593 def SHLD32mri8 : Ii8<0xA4, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00002594 (outs), (ins i32mem:$dst, GR32:$src2, i8imm:$src3),
Dan Gohman91888f02007-07-31 20:11:57 +00002595 "shld{l}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002596 [(store (X86shld (loadi32 addr:$dst), GR32:$src2,
2597 (i8 imm:$src3)), addr:$dst)]>,
2598 TB;
2599 def SHRD32mri8 : Ii8<0xAC, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00002600 (outs), (ins i32mem:$dst, GR32:$src2, i8imm:$src3),
Dan Gohman91888f02007-07-31 20:11:57 +00002601 "shrd{l}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002602 [(store (X86shrd (loadi32 addr:$dst), GR32:$src2,
2603 (i8 imm:$src3)), addr:$dst)]>,
2604 TB;
2605
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002606 let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00002607 def SHLD16mrCL : I<0xA5, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
Eli Friedman378ea832009-06-19 04:48:38 +00002608 "shld{w}\t{%cl, $src2, $dst|$dst, $src2, CL}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002609 [(store (X86shld (loadi16 addr:$dst), GR16:$src2, CL),
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002610 addr:$dst)]>, TB, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002611 def SHRD16mrCL : I<0xAD, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
Eli Friedman378ea832009-06-19 04:48:38 +00002612 "shrd{w}\t{%cl, $src2, $dst|$dst, $src2, CL}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002613 [(store (X86shrd (loadi16 addr:$dst), GR16:$src2, CL),
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002614 addr:$dst)]>, TB, OpSize;
2615 }
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002616 def SHLD16mri8 : Ii8<0xA4, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00002617 (outs), (ins i16mem:$dst, GR16:$src2, i8imm:$src3),
Dan Gohman91888f02007-07-31 20:11:57 +00002618 "shld{w}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002619 [(store (X86shld (loadi16 addr:$dst), GR16:$src2,
2620 (i8 imm:$src3)), addr:$dst)]>,
2621 TB, OpSize;
2622 def SHRD16mri8 : Ii8<0xAC, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00002623 (outs), (ins i16mem:$dst, GR16:$src2, i8imm:$src3),
Dan Gohman91888f02007-07-31 20:11:57 +00002624 "shrd{w}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002625 [(store (X86shrd (loadi16 addr:$dst), GR16:$src2,
2626 (i8 imm:$src3)), addr:$dst)]>,
2627 TB, OpSize;
2628}
Evan Cheng55687072007-09-14 21:48:26 +00002629} // Defs = [EFLAGS]
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002630
2631
2632// Arithmetic.
Evan Cheng55687072007-09-14 21:48:26 +00002633let Defs = [EFLAGS] in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002634let isCommutable = 1 in { // X = ADD Y, Z --> X = ADD Z, Y
Bill Wendlingae034ed2008-12-12 00:56:36 +00002635// Register-Register Addition
2636def ADD8rr : I<0x00, MRMDestReg, (outs GR8 :$dst),
2637 (ins GR8 :$src1, GR8 :$src2),
2638 "add{b}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002639 [(set GR8:$dst, (add GR8:$src1, GR8:$src2)),
Bill Wendlingae034ed2008-12-12 00:56:36 +00002640 (implicit EFLAGS)]>;
2641
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002642let isConvertibleToThreeAddress = 1 in { // Can transform into LEA.
Bill Wendlingae034ed2008-12-12 00:56:36 +00002643// Register-Register Addition
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002644def ADD16rr : I<0x01, MRMDestReg, (outs GR16:$dst),
2645 (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002646 "add{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002647 [(set GR16:$dst, (add GR16:$src1, GR16:$src2)),
2648 (implicit EFLAGS)]>, OpSize;
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002649def ADD32rr : I<0x01, MRMDestReg, (outs GR32:$dst),
2650 (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002651 "add{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002652 [(set GR32:$dst, (add GR32:$src1, GR32:$src2)),
2653 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002654} // end isConvertibleToThreeAddress
2655} // end isCommutable
Bill Wendlingae034ed2008-12-12 00:56:36 +00002656
2657// Register-Memory Addition
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002658def ADD8rm : I<0x02, MRMSrcMem, (outs GR8 :$dst),
2659 (ins GR8 :$src1, i8mem :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002660 "add{b}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002661 [(set GR8:$dst, (add GR8:$src1, (load addr:$src2))),
2662 (implicit EFLAGS)]>;
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002663def ADD16rm : I<0x03, MRMSrcMem, (outs GR16:$dst),
2664 (ins GR16:$src1, i16mem:$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, (load addr:$src2))),
2667 (implicit EFLAGS)]>, OpSize;
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002668def ADD32rm : I<0x03, MRMSrcMem, (outs GR32:$dst),
2669 (ins GR32:$src1, i32mem:$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, (load addr:$src2))),
2672 (implicit EFLAGS)]>;
Sean Callanan7e7df0e2009-09-15 20:53:57 +00002673
Sean Callanan84df9312009-09-15 21:43:27 +00002674// Register-Register Addition - Equivalent to the normal rr forms (ADD8rr,
2675// ADD16rr, and ADD32rr), but differently encoded.
Sean Callanan7e7df0e2009-09-15 20:53:57 +00002676def ADD8mrmrr: I<0x02, MRMSrcReg, (outs GR8:$dst), (ins GR8:$src1, GR8:$src2),
2677 "add{b}\t{$src2, $dst|$dst, $src2}", []>;
2678def ADD16mrmrr: I<0x03, MRMSrcReg,(outs GR16:$dst),(ins GR16:$src1, GR16:$src2),
2679 "add{w}\t{$src2, $dst|$dst, $src2}", []>, OpSize;
2680def ADD32mrmrr: I<0x03, MRMSrcReg,(outs GR16:$dst),(ins GR16:$src1, GR16:$src2),
2681 "add{l}\t{$src2, $dst|$dst, $src2}", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002682
Bill Wendlingae034ed2008-12-12 00:56:36 +00002683// Register-Integer Addition
2684def ADD8ri : Ii8<0x80, MRM0r, (outs GR8:$dst), (ins GR8:$src1, i8imm:$src2),
2685 "add{b}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002686 [(set GR8:$dst, (add GR8:$src1, imm:$src2)),
2687 (implicit EFLAGS)]>;
Bill Wendlingae034ed2008-12-12 00:56:36 +00002688
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002689let isConvertibleToThreeAddress = 1 in { // Can transform into LEA.
Bill Wendlingae034ed2008-12-12 00:56:36 +00002690// Register-Integer Addition
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002691def ADD16ri : Ii16<0x81, MRM0r, (outs GR16:$dst),
2692 (ins GR16:$src1, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002693 "add{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002694 [(set GR16:$dst, (add GR16:$src1, imm:$src2)),
2695 (implicit EFLAGS)]>, OpSize;
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002696def ADD32ri : Ii32<0x81, MRM0r, (outs GR32:$dst),
2697 (ins GR32:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002698 "add{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002699 [(set GR32:$dst, (add GR32:$src1, imm:$src2)),
2700 (implicit EFLAGS)]>;
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002701def ADD16ri8 : Ii8<0x83, MRM0r, (outs GR16:$dst),
2702 (ins GR16:$src1, i16i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002703 "add{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002704 [(set GR16:$dst, (add GR16:$src1, i16immSExt8:$src2)),
2705 (implicit EFLAGS)]>, OpSize;
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002706def ADD32ri8 : Ii8<0x83, MRM0r, (outs GR32:$dst),
2707 (ins GR32:$src1, i32i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002708 "add{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002709 [(set GR32:$dst, (add GR32:$src1, i32immSExt8:$src2)),
2710 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002711}
2712
2713let isTwoAddress = 0 in {
Bill Wendlingae034ed2008-12-12 00:56:36 +00002714 // Memory-Register Addition
Bill Wendlingf5399032008-12-12 21:15:41 +00002715 def ADD8mr : I<0x00, MRMDestMem, (outs), (ins i8mem:$dst, GR8:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002716 "add{b}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002717 [(store (add (load addr:$dst), GR8:$src2), addr:$dst),
2718 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002719 def ADD16mr : I<0x01, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002720 "add{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002721 [(store (add (load addr:$dst), GR16:$src2), addr:$dst),
2722 (implicit EFLAGS)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002723 def ADD32mr : I<0x01, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002724 "add{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002725 [(store (add (load addr:$dst), GR32:$src2), addr:$dst),
2726 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002727 def ADD8mi : Ii8<0x80, MRM0m, (outs), (ins i8mem :$dst, i8imm :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002728 "add{b}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002729 [(store (add (loadi8 addr:$dst), imm:$src2), addr:$dst),
2730 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002731 def ADD16mi : Ii16<0x81, MRM0m, (outs), (ins i16mem:$dst, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002732 "add{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002733 [(store (add (loadi16 addr:$dst), imm:$src2), addr:$dst),
2734 (implicit EFLAGS)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002735 def ADD32mi : Ii32<0x81, MRM0m, (outs), (ins i32mem:$dst, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002736 "add{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002737 [(store (add (loadi32 addr:$dst), imm:$src2), addr:$dst),
2738 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002739 def ADD16mi8 : Ii8<0x83, MRM0m, (outs), (ins i16mem:$dst, i16i8imm :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002740 "add{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002741 [(store (add (load addr:$dst), i16immSExt8:$src2),
2742 addr:$dst),
2743 (implicit EFLAGS)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002744 def ADD32mi8 : Ii8<0x83, MRM0m, (outs), (ins i32mem:$dst, i32i8imm :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002745 "add{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingae034ed2008-12-12 00:56:36 +00002746 [(store (add (load addr:$dst), i32immSExt8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00002747 addr:$dst),
2748 (implicit EFLAGS)]>;
Sean Callanan0316b342009-08-11 21:26:06 +00002749
2750 // addition to rAX
2751 def ADD8i8 : Ii8<0x04, RawFrm, (outs), (ins i8imm:$src),
Sean Callanan251676e2009-09-02 00:55:49 +00002752 "add{b}\t{$src, %al|%al, $src}", []>;
Sean Callanan0316b342009-08-11 21:26:06 +00002753 def ADD16i16 : Ii16<0x05, RawFrm, (outs), (ins i16imm:$src),
Sean Callanan251676e2009-09-02 00:55:49 +00002754 "add{w}\t{$src, %ax|%ax, $src}", []>, OpSize;
Sean Callanan0316b342009-08-11 21:26:06 +00002755 def ADD32i32 : Ii32<0x05, RawFrm, (outs), (ins i32imm:$src),
Sean Callanan251676e2009-09-02 00:55:49 +00002756 "add{l}\t{$src, %eax|%eax, $src}", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002757}
2758
Evan Cheng259471d2007-10-05 17:59:57 +00002759let Uses = [EFLAGS] in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002760let isCommutable = 1 in { // X = ADC Y, Z --> X = ADC Z, Y
Dale Johannesen747fe522009-06-02 03:12:52 +00002761def ADC8rr : I<0x10, MRMDestReg, (outs GR8:$dst), (ins GR8:$src1, GR8:$src2),
Dale Johannesen06b83f12009-05-18 17:44:15 +00002762 "adc{b}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002763 [(set GR8:$dst, (adde GR8:$src1, GR8:$src2))]>;
Dale Johannesen06b83f12009-05-18 17:44:15 +00002764def ADC16rr : I<0x11, MRMDestReg, (outs GR16:$dst),
2765 (ins GR16:$src1, GR16:$src2),
2766 "adc{w}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002767 [(set GR16:$dst, (adde GR16:$src1, GR16:$src2))]>, OpSize;
Dale Johannesen06b83f12009-05-18 17:44:15 +00002768def ADC32rr : I<0x11, MRMDestReg, (outs GR32:$dst),
2769 (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002770 "adc{l}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002771 [(set GR32:$dst, (adde GR32:$src1, GR32:$src2))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002772}
Sean Callanan2c48df22009-12-18 00:01:26 +00002773
2774def ADC8rr_REV : I<0x12, MRMSrcReg, (outs GR8:$dst), (ins GR8:$src1, GR8:$src2),
2775 "adc{b}\t{$src2, $dst|$dst, $src2}", []>;
2776def ADC16rr_REV : I<0x13, MRMSrcReg, (outs GR16:$dst),
2777 (ins GR16:$src1, GR16:$src2),
2778 "adc{w}\t{$src2, $dst|$dst, $src2}", []>, OpSize;
2779def ADC32rr_REV : I<0x13, MRMSrcReg, (outs GR32:$dst),
2780 (ins GR32:$src1, GR32:$src2),
2781 "adc{l}\t{$src2, $dst|$dst, $src2}", []>;
2782
Dale Johannesen06b83f12009-05-18 17:44:15 +00002783def ADC8rm : I<0x12, MRMSrcMem , (outs GR8:$dst),
2784 (ins GR8:$src1, i8mem:$src2),
2785 "adc{b}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002786 [(set GR8:$dst, (adde GR8:$src1, (load addr:$src2)))]>;
Dale Johannesen06b83f12009-05-18 17:44:15 +00002787def ADC16rm : I<0x13, MRMSrcMem , (outs GR16:$dst),
2788 (ins GR16:$src1, i16mem:$src2),
2789 "adc{w}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002790 [(set GR16:$dst, (adde GR16:$src1, (load addr:$src2)))]>,
Dale Johannesen067cfb22009-05-18 21:41:59 +00002791 OpSize;
Dale Johannesen06b83f12009-05-18 17:44:15 +00002792def ADC32rm : I<0x13, MRMSrcMem , (outs GR32:$dst),
2793 (ins GR32:$src1, i32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002794 "adc{l}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002795 [(set GR32:$dst, (adde GR32:$src1, (load addr:$src2)))]>;
2796def ADC8ri : Ii8<0x80, MRM2r, (outs GR8:$dst), (ins GR8:$src1, i8imm:$src2),
Dale Johannesen06b83f12009-05-18 17:44:15 +00002797 "adc{b}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002798 [(set GR8:$dst, (adde GR8:$src1, imm:$src2))]>;
Dale Johannesen06b83f12009-05-18 17:44:15 +00002799def ADC16ri : Ii16<0x81, MRM2r, (outs GR16:$dst),
2800 (ins GR16:$src1, i16imm:$src2),
2801 "adc{w}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002802 [(set GR16:$dst, (adde GR16:$src1, imm:$src2))]>, OpSize;
Dale Johannesen06b83f12009-05-18 17:44:15 +00002803def ADC16ri8 : Ii8<0x83, MRM2r, (outs GR16:$dst),
2804 (ins GR16:$src1, i16i8imm:$src2),
2805 "adc{w}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002806 [(set GR16:$dst, (adde GR16:$src1, i16immSExt8:$src2))]>,
2807 OpSize;
Dale Johannesen06b83f12009-05-18 17:44:15 +00002808def ADC32ri : Ii32<0x81, MRM2r, (outs GR32:$dst),
2809 (ins GR32:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002810 "adc{l}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002811 [(set GR32:$dst, (adde GR32:$src1, imm:$src2))]>;
Dale Johannesen06b83f12009-05-18 17:44:15 +00002812def ADC32ri8 : Ii8<0x83, MRM2r, (outs GR32:$dst),
2813 (ins GR32:$src1, i32i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002814 "adc{l}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002815 [(set GR32:$dst, (adde GR32:$src1, i32immSExt8:$src2))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002816
2817let isTwoAddress = 0 in {
Dale Johannesen747fe522009-06-02 03:12:52 +00002818 def ADC8mr : I<0x10, MRMDestMem, (outs), (ins i8mem:$dst, GR8:$src2),
Dale Johannesen06b83f12009-05-18 17:44:15 +00002819 "adc{b}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002820 [(store (adde (load addr:$dst), GR8:$src2), addr:$dst)]>;
2821 def ADC16mr : I<0x11, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
Dale Johannesen06b83f12009-05-18 17:44:15 +00002822 "adc{w}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002823 [(store (adde (load addr:$dst), GR16:$src2), addr:$dst)]>,
2824 OpSize;
2825 def ADC32mr : I<0x11, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002826 "adc{l}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002827 [(store (adde (load addr:$dst), GR32:$src2), addr:$dst)]>;
2828 def ADC8mi : Ii8<0x80, MRM2m, (outs), (ins i8mem:$dst, i8imm:$src2),
Dale Johannesen06b83f12009-05-18 17:44:15 +00002829 "adc{b}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002830 [(store (adde (loadi8 addr:$dst), imm:$src2), addr:$dst)]>;
2831 def ADC16mi : Ii16<0x81, MRM2m, (outs), (ins i16mem:$dst, i16imm:$src2),
Dale Johannesen06b83f12009-05-18 17:44:15 +00002832 "adc{w}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002833 [(store (adde (loadi16 addr:$dst), imm:$src2), addr:$dst)]>,
2834 OpSize;
2835 def ADC16mi8 : Ii8<0x83, MRM2m, (outs), (ins i16mem:$dst, i16i8imm :$src2),
Dale Johannesen06b83f12009-05-18 17:44:15 +00002836 "adc{w}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002837 [(store (adde (load addr:$dst), i16immSExt8:$src2), addr:$dst)]>,
2838 OpSize;
2839 def ADC32mi : Ii32<0x81, MRM2m, (outs), (ins i32mem:$dst, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002840 "adc{l}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002841 [(store (adde (loadi32 addr:$dst), imm:$src2), addr:$dst)]>;
2842 def ADC32mi8 : Ii8<0x83, MRM2m, (outs), (ins i32mem:$dst, i32i8imm :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002843 "adc{l}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002844 [(store (adde (load addr:$dst), i32immSExt8:$src2), addr:$dst)]>;
Sean Callanan8562bef2009-09-11 19:01:56 +00002845
2846 def ADC8i8 : Ii8<0x14, RawFrm, (outs), (ins i8imm:$src),
2847 "adc{b}\t{$src, %al|%al, $src}", []>;
2848 def ADC16i16 : Ii16<0x15, RawFrm, (outs), (ins i16imm:$src),
2849 "adc{w}\t{$src, %ax|%ax, $src}", []>, OpSize;
2850 def ADC32i32 : Ii32<0x15, RawFrm, (outs), (ins i32imm:$src),
2851 "adc{l}\t{$src, %eax|%eax, $src}", []>;
Dale Johannesen747fe522009-06-02 03:12:52 +00002852}
Evan Cheng259471d2007-10-05 17:59:57 +00002853} // Uses = [EFLAGS]
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002854
Bill Wendlingae034ed2008-12-12 00:56:36 +00002855// Register-Register Subtraction
2856def SUB8rr : I<0x28, MRMDestReg, (outs GR8:$dst), (ins GR8:$src1, GR8:$src2),
2857 "sub{b}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002858 [(set GR8:$dst, (sub GR8:$src1, GR8:$src2)),
2859 (implicit EFLAGS)]>;
Bill Wendlingae034ed2008-12-12 00:56:36 +00002860def SUB16rr : I<0x29, MRMDestReg, (outs GR16:$dst), (ins GR16:$src1,GR16:$src2),
2861 "sub{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002862 [(set GR16:$dst, (sub GR16:$src1, GR16:$src2)),
2863 (implicit EFLAGS)]>, OpSize;
Bill Wendlingae034ed2008-12-12 00:56:36 +00002864def SUB32rr : I<0x29, MRMDestReg, (outs GR32:$dst), (ins GR32:$src1,GR32:$src2),
2865 "sub{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002866 [(set GR32:$dst, (sub GR32:$src1, GR32:$src2)),
2867 (implicit EFLAGS)]>;
Bill Wendlingae034ed2008-12-12 00:56:36 +00002868
Sean Callanan2c48df22009-12-18 00:01:26 +00002869def SUB8rr_REV : I<0x2A, MRMSrcReg, (outs GR8:$dst), (ins GR8:$src1, GR8:$src2),
2870 "sub{b}\t{$src2, $dst|$dst, $src2}", []>;
2871def SUB16rr_REV : I<0x2B, MRMSrcReg, (outs GR16:$dst),
2872 (ins GR16:$src1, GR16:$src2),
2873 "sub{w}\t{$src2, $dst|$dst, $src2}", []>, OpSize;
2874def SUB32rr_REV : I<0x2B, MRMSrcReg, (outs GR32:$dst),
2875 (ins GR32:$src1, GR32:$src2),
2876 "sub{l}\t{$src2, $dst|$dst, $src2}", []>;
2877
Bill Wendlingae034ed2008-12-12 00:56:36 +00002878// Register-Memory Subtraction
2879def SUB8rm : I<0x2A, MRMSrcMem, (outs GR8 :$dst),
2880 (ins GR8 :$src1, i8mem :$src2),
2881 "sub{b}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002882 [(set GR8:$dst, (sub GR8:$src1, (load addr:$src2))),
2883 (implicit EFLAGS)]>;
Bill Wendlingae034ed2008-12-12 00:56:36 +00002884def SUB16rm : I<0x2B, MRMSrcMem, (outs GR16:$dst),
2885 (ins GR16:$src1, i16mem:$src2),
2886 "sub{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002887 [(set GR16:$dst, (sub GR16:$src1, (load addr:$src2))),
2888 (implicit EFLAGS)]>, OpSize;
Bill Wendlingae034ed2008-12-12 00:56:36 +00002889def SUB32rm : I<0x2B, MRMSrcMem, (outs GR32:$dst),
2890 (ins GR32:$src1, i32mem:$src2),
2891 "sub{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002892 [(set GR32:$dst, (sub GR32:$src1, (load addr:$src2))),
2893 (implicit EFLAGS)]>;
Bill Wendlingae034ed2008-12-12 00:56:36 +00002894
2895// Register-Integer Subtraction
2896def SUB8ri : Ii8 <0x80, MRM5r, (outs GR8:$dst),
2897 (ins GR8:$src1, i8imm:$src2),
2898 "sub{b}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002899 [(set GR8:$dst, (sub GR8:$src1, imm:$src2)),
2900 (implicit EFLAGS)]>;
Bill Wendlingae034ed2008-12-12 00:56:36 +00002901def SUB16ri : Ii16<0x81, MRM5r, (outs GR16:$dst),
2902 (ins GR16:$src1, i16imm:$src2),
2903 "sub{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002904 [(set GR16:$dst, (sub GR16:$src1, imm:$src2)),
2905 (implicit EFLAGS)]>, OpSize;
Bill Wendlingae034ed2008-12-12 00:56:36 +00002906def SUB32ri : Ii32<0x81, MRM5r, (outs GR32:$dst),
2907 (ins GR32:$src1, i32imm:$src2),
2908 "sub{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002909 [(set GR32:$dst, (sub GR32:$src1, imm:$src2)),
2910 (implicit EFLAGS)]>;
Bill Wendlingae034ed2008-12-12 00:56:36 +00002911def SUB16ri8 : Ii8<0x83, MRM5r, (outs GR16:$dst),
2912 (ins GR16:$src1, i16i8imm:$src2),
2913 "sub{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002914 [(set GR16:$dst, (sub GR16:$src1, i16immSExt8:$src2)),
2915 (implicit EFLAGS)]>, OpSize;
Bill Wendlingae034ed2008-12-12 00:56:36 +00002916def SUB32ri8 : Ii8<0x83, MRM5r, (outs GR32:$dst),
2917 (ins GR32:$src1, i32i8imm:$src2),
2918 "sub{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002919 [(set GR32:$dst, (sub GR32:$src1, i32immSExt8:$src2)),
2920 (implicit EFLAGS)]>;
Bill Wendlingae034ed2008-12-12 00:56:36 +00002921
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002922let isTwoAddress = 0 in {
Bill Wendlingae034ed2008-12-12 00:56:36 +00002923 // Memory-Register Subtraction
Evan Chengb783fa32007-07-19 01:14:50 +00002924 def SUB8mr : I<0x28, MRMDestMem, (outs), (ins i8mem :$dst, GR8 :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002925 "sub{b}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002926 [(store (sub (load addr:$dst), GR8:$src2), addr:$dst),
2927 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002928 def SUB16mr : I<0x29, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002929 "sub{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002930 [(store (sub (load addr:$dst), GR16:$src2), addr:$dst),
2931 (implicit EFLAGS)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002932 def SUB32mr : I<0x29, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002933 "sub{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002934 [(store (sub (load addr:$dst), GR32:$src2), addr:$dst),
2935 (implicit EFLAGS)]>;
Bill Wendlingae034ed2008-12-12 00:56:36 +00002936
2937 // Memory-Integer Subtraction
Evan Chengb783fa32007-07-19 01:14:50 +00002938 def SUB8mi : Ii8<0x80, MRM5m, (outs), (ins i8mem :$dst, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002939 "sub{b}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002940 [(store (sub (loadi8 addr:$dst), imm:$src2), addr:$dst),
2941 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002942 def SUB16mi : Ii16<0x81, MRM5m, (outs), (ins i16mem:$dst, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002943 "sub{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002944 [(store (sub (loadi16 addr:$dst), imm:$src2),addr:$dst),
2945 (implicit EFLAGS)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002946 def SUB32mi : Ii32<0x81, MRM5m, (outs), (ins i32mem:$dst, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002947 "sub{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002948 [(store (sub (loadi32 addr:$dst), imm:$src2),addr:$dst),
2949 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002950 def SUB16mi8 : Ii8<0x83, MRM5m, (outs), (ins i16mem:$dst, i16i8imm :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002951 "sub{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingae034ed2008-12-12 00:56:36 +00002952 [(store (sub (load addr:$dst), i16immSExt8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00002953 addr:$dst),
2954 (implicit EFLAGS)]>, OpSize;
Bill Wendlingae034ed2008-12-12 00:56:36 +00002955 def SUB32mi8 : Ii8<0x83, MRM5m, (outs), (ins i32mem:$dst, i32i8imm :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002956 "sub{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingae034ed2008-12-12 00:56:36 +00002957 [(store (sub (load addr:$dst), i32immSExt8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00002958 addr:$dst),
2959 (implicit EFLAGS)]>;
Sean Callanan8562bef2009-09-11 19:01:56 +00002960
2961 def SUB8i8 : Ii8<0x2C, RawFrm, (outs), (ins i8imm:$src),
2962 "sub{b}\t{$src, %al|%al, $src}", []>;
2963 def SUB16i16 : Ii16<0x2D, RawFrm, (outs), (ins i16imm:$src),
2964 "sub{w}\t{$src, %ax|%ax, $src}", []>, OpSize;
2965 def SUB32i32 : Ii32<0x2D, RawFrm, (outs), (ins i32imm:$src),
2966 "sub{l}\t{$src, %eax|%eax, $src}", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002967}
2968
Evan Cheng259471d2007-10-05 17:59:57 +00002969let Uses = [EFLAGS] in {
Dale Johannesen06b83f12009-05-18 17:44:15 +00002970def SBB8rr : I<0x18, MRMDestReg, (outs GR8:$dst),
2971 (ins GR8:$src1, GR8:$src2),
2972 "sbb{b}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002973 [(set GR8:$dst, (sube GR8:$src1, GR8:$src2))]>;
Dale Johannesen06b83f12009-05-18 17:44:15 +00002974def SBB16rr : I<0x19, MRMDestReg, (outs GR16:$dst),
2975 (ins GR16:$src1, GR16:$src2),
2976 "sbb{w}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002977 [(set GR16:$dst, (sube GR16:$src1, GR16:$src2))]>, OpSize;
Dale Johannesen06b83f12009-05-18 17:44:15 +00002978def SBB32rr : I<0x19, MRMDestReg, (outs GR32:$dst),
2979 (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002980 "sbb{l}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002981 [(set GR32:$dst, (sube GR32:$src1, GR32:$src2))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002982
2983let isTwoAddress = 0 in {
Dale Johannesen06b83f12009-05-18 17:44:15 +00002984 def SBB8mr : I<0x18, MRMDestMem, (outs), (ins i8mem:$dst, GR8:$src2),
2985 "sbb{b}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002986 [(store (sube (load addr:$dst), GR8:$src2), addr:$dst)]>;
Dale Johannesen06b83f12009-05-18 17:44:15 +00002987 def SBB16mr : I<0x19, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
2988 "sbb{w}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002989 [(store (sube (load addr:$dst), GR16:$src2), addr:$dst)]>,
Dale Johannesen067cfb22009-05-18 21:41:59 +00002990 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002991 def SBB32mr : I<0x19, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002992 "sbb{l}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002993 [(store (sube (load addr:$dst), GR32:$src2), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002994 def SBB8mi : Ii32<0x80, MRM3m, (outs), (ins i8mem:$dst, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002995 "sbb{b}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002996 [(store (sube (loadi8 addr:$dst), imm:$src2), addr:$dst)]>;
Dale Johannesen06b83f12009-05-18 17:44:15 +00002997 def SBB16mi : Ii16<0x81, MRM3m, (outs), (ins i16mem:$dst, i16imm:$src2),
2998 "sbb{w}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002999 [(store (sube (loadi16 addr:$dst), imm:$src2), addr:$dst)]>,
Dale Johannesen067cfb22009-05-18 21:41:59 +00003000 OpSize;
Dale Johannesen06b83f12009-05-18 17:44:15 +00003001 def SBB16mi8 : Ii8<0x83, MRM3m, (outs), (ins i16mem:$dst, i16i8imm :$src2),
3002 "sbb{w}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00003003 [(store (sube (load addr:$dst), i16immSExt8:$src2), addr:$dst)]>,
Dale Johannesen067cfb22009-05-18 21:41:59 +00003004 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00003005 def SBB32mi : Ii32<0x81, MRM3m, (outs), (ins i32mem:$dst, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00003006 "sbb{l}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00003007 [(store (sube (loadi32 addr:$dst), imm:$src2), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00003008 def SBB32mi8 : Ii8<0x83, MRM3m, (outs), (ins i32mem:$dst, i32i8imm :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00003009 "sbb{l}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00003010 [(store (sube (load addr:$dst), i32immSExt8:$src2), addr:$dst)]>;
Sean Callanan8562bef2009-09-11 19:01:56 +00003011
3012 def SBB8i8 : Ii8<0x1C, RawFrm, (outs), (ins i8imm:$src),
3013 "sbb{b}\t{$src, %al|%al, $src}", []>;
3014 def SBB16i16 : Ii16<0x1D, RawFrm, (outs), (ins i16imm:$src),
3015 "sbb{w}\t{$src, %ax|%ax, $src}", []>, OpSize;
3016 def SBB32i32 : Ii32<0x1D, RawFrm, (outs), (ins i32imm:$src),
3017 "sbb{l}\t{$src, %eax|%eax, $src}", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003018}
Sean Callanan2c48df22009-12-18 00:01:26 +00003019
3020def SBB8rr_REV : I<0x1A, MRMSrcReg, (outs GR8:$dst), (ins GR8:$src1, GR8:$src2),
3021 "sbb{b}\t{$src2, $dst|$dst, $src2}", []>;
3022def SBB16rr_REV : I<0x1B, MRMSrcReg, (outs GR16:$dst),
3023 (ins GR16:$src1, GR16:$src2),
3024 "sbb{w}\t{$src2, $dst|$dst, $src2}", []>, OpSize;
3025def SBB32rr_REV : I<0x1B, MRMSrcReg, (outs GR32:$dst),
3026 (ins GR32:$src1, GR32:$src2),
3027 "sbb{l}\t{$src2, $dst|$dst, $src2}", []>;
3028
Dale Johannesen06b83f12009-05-18 17:44:15 +00003029def SBB8rm : I<0x1A, MRMSrcMem, (outs GR8:$dst), (ins GR8:$src1, i8mem:$src2),
3030 "sbb{b}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00003031 [(set GR8:$dst, (sube GR8:$src1, (load addr:$src2)))]>;
Dale Johannesen06b83f12009-05-18 17:44:15 +00003032def SBB16rm : I<0x1B, MRMSrcMem, (outs GR16:$dst),
3033 (ins GR16:$src1, i16mem:$src2),
3034 "sbb{w}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00003035 [(set GR16:$dst, (sube GR16:$src1, (load addr:$src2)))]>,
Dale Johannesen067cfb22009-05-18 21:41:59 +00003036 OpSize;
Dale Johannesen06b83f12009-05-18 17:44:15 +00003037def SBB32rm : I<0x1B, MRMSrcMem, (outs GR32:$dst),
3038 (ins GR32:$src1, i32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00003039 "sbb{l}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00003040 [(set GR32:$dst, (sube GR32:$src1, (load addr:$src2)))]>;
Dale Johannesen06b83f12009-05-18 17:44:15 +00003041def SBB8ri : Ii8<0x80, MRM3r, (outs GR8:$dst), (ins GR8:$src1, i8imm:$src2),
3042 "sbb{b}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00003043 [(set GR8:$dst, (sube GR8:$src1, imm:$src2))]>;
Dale Johannesen06b83f12009-05-18 17:44:15 +00003044def SBB16ri : Ii16<0x81, MRM3r, (outs GR16:$dst),
3045 (ins GR16:$src1, i16imm:$src2),
3046 "sbb{w}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00003047 [(set GR16:$dst, (sube GR16:$src1, imm:$src2))]>, OpSize;
Dale Johannesen06b83f12009-05-18 17:44:15 +00003048def SBB16ri8 : Ii8<0x83, MRM3r, (outs GR16:$dst),
3049 (ins GR16:$src1, i16i8imm:$src2),
3050 "sbb{w}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00003051 [(set GR16:$dst, (sube GR16:$src1, i16immSExt8:$src2))]>,
3052 OpSize;
Dale Johannesen06b83f12009-05-18 17:44:15 +00003053def SBB32ri : Ii32<0x81, MRM3r, (outs GR32:$dst),
3054 (ins GR32:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00003055 "sbb{l}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00003056 [(set GR32:$dst, (sube GR32:$src1, imm:$src2))]>;
Dale Johannesen06b83f12009-05-18 17:44:15 +00003057def SBB32ri8 : Ii8<0x83, MRM3r, (outs GR32:$dst),
3058 (ins GR32:$src1, i32i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00003059 "sbb{l}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00003060 [(set GR32:$dst, (sube GR32:$src1, i32immSExt8:$src2))]>;
Evan Cheng259471d2007-10-05 17:59:57 +00003061} // Uses = [EFLAGS]
Evan Cheng55687072007-09-14 21:48:26 +00003062} // Defs = [EFLAGS]
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003063
Evan Cheng55687072007-09-14 21:48:26 +00003064let Defs = [EFLAGS] in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003065let isCommutable = 1 in { // X = IMUL Y, Z --> X = IMUL Z, Y
Bill Wendlingf5399032008-12-12 21:15:41 +00003066// Register-Register Signed Integer Multiply
Bill Wendlingae034ed2008-12-12 00:56:36 +00003067def IMUL16rr : I<0xAF, MRMSrcReg, (outs GR16:$dst), (ins GR16:$src1,GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00003068 "imul{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00003069 [(set GR16:$dst, (mul GR16:$src1, GR16:$src2)),
3070 (implicit EFLAGS)]>, TB, OpSize;
Bill Wendlingae034ed2008-12-12 00:56:36 +00003071def IMUL32rr : I<0xAF, MRMSrcReg, (outs GR32:$dst), (ins GR32:$src1,GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00003072 "imul{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00003073 [(set GR32:$dst, (mul GR32:$src1, GR32:$src2)),
3074 (implicit EFLAGS)]>, TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003075}
Bill Wendlingae034ed2008-12-12 00:56:36 +00003076
Bill Wendlingf5399032008-12-12 21:15:41 +00003077// Register-Memory Signed Integer Multiply
Bill Wendlingae034ed2008-12-12 00:56:36 +00003078def IMUL16rm : I<0xAF, MRMSrcMem, (outs GR16:$dst),
3079 (ins GR16:$src1, i16mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00003080 "imul{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00003081 [(set GR16:$dst, (mul GR16:$src1, (load addr:$src2))),
3082 (implicit EFLAGS)]>, TB, OpSize;
Sean Callanan2c48df22009-12-18 00:01:26 +00003083def IMUL32rm : I<0xAF, MRMSrcMem, (outs GR32:$dst),
3084 (ins GR32:$src1, i32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00003085 "imul{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00003086 [(set GR32:$dst, (mul GR32:$src1, (load addr:$src2))),
3087 (implicit EFLAGS)]>, TB;
Evan Cheng55687072007-09-14 21:48:26 +00003088} // Defs = [EFLAGS]
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003089} // end Two Address instructions
3090
3091// Suprisingly enough, these are not two address instructions!
Evan Cheng55687072007-09-14 21:48:26 +00003092let Defs = [EFLAGS] in {
Bill Wendlingf5399032008-12-12 21:15:41 +00003093// Register-Integer Signed Integer Multiply
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003094def IMUL16rri : Ii16<0x69, MRMSrcReg, // GR16 = GR16*I16
Evan Chengb783fa32007-07-19 01:14:50 +00003095 (outs GR16:$dst), (ins GR16:$src1, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00003096 "imul{w}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00003097 [(set GR16:$dst, (mul GR16:$src1, imm:$src2)),
3098 (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003099def IMUL32rri : Ii32<0x69, MRMSrcReg, // GR32 = GR32*I32
Evan Chengb783fa32007-07-19 01:14:50 +00003100 (outs GR32:$dst), (ins GR32:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00003101 "imul{l}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00003102 [(set GR32:$dst, (mul GR32:$src1, imm:$src2)),
3103 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003104def IMUL16rri8 : Ii8<0x6B, MRMSrcReg, // GR16 = GR16*I8
Evan Chengb783fa32007-07-19 01:14:50 +00003105 (outs GR16:$dst), (ins GR16:$src1, i16i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00003106 "imul{w}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00003107 [(set GR16:$dst, (mul GR16:$src1, i16immSExt8:$src2)),
3108 (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003109def IMUL32rri8 : Ii8<0x6B, MRMSrcReg, // GR32 = GR32*I8
Evan Chengb783fa32007-07-19 01:14:50 +00003110 (outs GR32:$dst), (ins GR32:$src1, i32i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00003111 "imul{l}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00003112 [(set GR32:$dst, (mul GR32:$src1, i32immSExt8:$src2)),
3113 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003114
Bill Wendlingf5399032008-12-12 21:15:41 +00003115// Memory-Integer Signed Integer Multiply
Sean Callanan2c48df22009-12-18 00:01:26 +00003116def IMUL16rmi : Ii16<0x69, MRMSrcMem, // GR16 = [mem16]*I16
Evan Chengb783fa32007-07-19 01:14:50 +00003117 (outs GR16:$dst), (ins i16mem:$src1, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00003118 "imul{w}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00003119 [(set GR16:$dst, (mul (load addr:$src1), imm:$src2)),
3120 (implicit EFLAGS)]>, OpSize;
Sean Callanan2c48df22009-12-18 00:01:26 +00003121def IMUL32rmi : Ii32<0x69, MRMSrcMem, // GR32 = [mem32]*I32
Evan Chengb783fa32007-07-19 01:14:50 +00003122 (outs GR32:$dst), (ins i32mem:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00003123 "imul{l}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00003124 [(set GR32:$dst, (mul (load addr:$src1), imm:$src2)),
3125 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003126def IMUL16rmi8 : Ii8<0x6B, MRMSrcMem, // GR16 = [mem16]*I8
Evan Chengb783fa32007-07-19 01:14:50 +00003127 (outs GR16:$dst), (ins i16mem:$src1, i16i8imm :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00003128 "imul{w}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Bill Wendlingae034ed2008-12-12 00:56:36 +00003129 [(set GR16:$dst, (mul (load addr:$src1),
Bill Wendlingf5399032008-12-12 21:15:41 +00003130 i16immSExt8:$src2)),
3131 (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003132def IMUL32rmi8 : Ii8<0x6B, MRMSrcMem, // GR32 = [mem32]*I8
Evan Chengb783fa32007-07-19 01:14:50 +00003133 (outs GR32:$dst), (ins i32mem:$src1, i32i8imm: $src2),
Dan Gohman91888f02007-07-31 20:11:57 +00003134 "imul{l}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Bill Wendlingae034ed2008-12-12 00:56:36 +00003135 [(set GR32:$dst, (mul (load addr:$src1),
Bill Wendlingf5399032008-12-12 21:15:41 +00003136 i32immSExt8:$src2)),
3137 (implicit EFLAGS)]>;
Evan Cheng55687072007-09-14 21:48:26 +00003138} // Defs = [EFLAGS]
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003139
3140//===----------------------------------------------------------------------===//
3141// Test instructions are just like AND, except they don't generate a result.
3142//
Evan Cheng950aac02007-09-25 01:57:46 +00003143let Defs = [EFLAGS] in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003144let isCommutable = 1 in { // TEST X, Y --> TEST Y, X
Evan Chengb783fa32007-07-19 01:14:50 +00003145def TEST8rr : I<0x84, MRMDestReg, (outs), (ins GR8:$src1, GR8:$src2),
Evan Cheng621216e2007-09-29 00:00:36 +00003146 "test{b}\t{$src2, $src1|$src1, $src2}",
Chris Lattner21da6382008-02-19 17:37:35 +00003147 [(X86cmp (and_su GR8:$src1, GR8:$src2), 0),
Evan Cheng621216e2007-09-29 00:00:36 +00003148 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00003149def TEST16rr : I<0x85, MRMDestReg, (outs), (ins GR16:$src1, GR16:$src2),
Evan Cheng621216e2007-09-29 00:00:36 +00003150 "test{w}\t{$src2, $src1|$src1, $src2}",
Chris Lattner21da6382008-02-19 17:37:35 +00003151 [(X86cmp (and_su GR16:$src1, GR16:$src2), 0),
Evan Cheng621216e2007-09-29 00:00:36 +00003152 (implicit EFLAGS)]>,
3153 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00003154def TEST32rr : I<0x85, MRMDestReg, (outs), (ins GR32:$src1, GR32:$src2),
Evan Cheng621216e2007-09-29 00:00:36 +00003155 "test{l}\t{$src2, $src1|$src1, $src2}",
Chris Lattner21da6382008-02-19 17:37:35 +00003156 [(X86cmp (and_su GR32:$src1, GR32:$src2), 0),
Evan Cheng621216e2007-09-29 00:00:36 +00003157 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003158}
3159
Sean Callanan3e4b1a32009-09-01 18:14:18 +00003160def TEST8i8 : Ii8<0xA8, RawFrm, (outs), (ins i8imm:$src),
3161 "test{b}\t{$src, %al|%al, $src}", []>;
3162def TEST16i16 : Ii16<0xA9, RawFrm, (outs), (ins i16imm:$src),
3163 "test{w}\t{$src, %ax|%ax, $src}", []>, OpSize;
3164def TEST32i32 : Ii32<0xA9, RawFrm, (outs), (ins i32imm:$src),
3165 "test{l}\t{$src, %eax|%eax, $src}", []>;
3166
Evan Chengb783fa32007-07-19 01:14:50 +00003167def TEST8rm : I<0x84, MRMSrcMem, (outs), (ins GR8 :$src1, i8mem :$src2),
Evan Cheng621216e2007-09-29 00:00:36 +00003168 "test{b}\t{$src2, $src1|$src1, $src2}",
3169 [(X86cmp (and GR8:$src1, (loadi8 addr:$src2)), 0),
3170 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00003171def TEST16rm : I<0x85, MRMSrcMem, (outs), (ins GR16:$src1, i16mem:$src2),
Evan Cheng621216e2007-09-29 00:00:36 +00003172 "test{w}\t{$src2, $src1|$src1, $src2}",
3173 [(X86cmp (and GR16:$src1, (loadi16 addr:$src2)), 0),
3174 (implicit EFLAGS)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00003175def TEST32rm : I<0x85, MRMSrcMem, (outs), (ins GR32:$src1, i32mem:$src2),
Evan Cheng621216e2007-09-29 00:00:36 +00003176 "test{l}\t{$src2, $src1|$src1, $src2}",
3177 [(X86cmp (and GR32:$src1, (loadi32 addr:$src2)), 0),
3178 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003179
3180def TEST8ri : Ii8 <0xF6, MRM0r, // flags = GR8 & imm8
Evan Chengb783fa32007-07-19 01:14:50 +00003181 (outs), (ins GR8:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00003182 "test{b}\t{$src2, $src1|$src1, $src2}",
Chris Lattner21da6382008-02-19 17:37:35 +00003183 [(X86cmp (and_su GR8:$src1, imm:$src2), 0),
Evan Cheng621216e2007-09-29 00:00:36 +00003184 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003185def TEST16ri : Ii16<0xF7, MRM0r, // flags = GR16 & imm16
Evan Chengb783fa32007-07-19 01:14:50 +00003186 (outs), (ins GR16:$src1, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00003187 "test{w}\t{$src2, $src1|$src1, $src2}",
Chris Lattner21da6382008-02-19 17:37:35 +00003188 [(X86cmp (and_su GR16:$src1, imm:$src2), 0),
Evan Cheng621216e2007-09-29 00:00:36 +00003189 (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003190def TEST32ri : Ii32<0xF7, MRM0r, // flags = GR32 & imm32
Evan Chengb783fa32007-07-19 01:14:50 +00003191 (outs), (ins GR32:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00003192 "test{l}\t{$src2, $src1|$src1, $src2}",
Chris Lattner21da6382008-02-19 17:37:35 +00003193 [(X86cmp (and_su GR32:$src1, imm:$src2), 0),
Evan Cheng621216e2007-09-29 00:00:36 +00003194 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003195
Evan Cheng621216e2007-09-29 00:00:36 +00003196def TEST8mi : Ii8 <0xF6, MRM0m, // flags = [mem8] & imm8
Evan Chengb783fa32007-07-19 01:14:50 +00003197 (outs), (ins i8mem:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00003198 "test{b}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00003199 [(X86cmp (and (loadi8 addr:$src1), imm:$src2), 0),
3200 (implicit EFLAGS)]>;
3201def TEST16mi : Ii16<0xF7, MRM0m, // flags = [mem16] & imm16
Evan Chengb783fa32007-07-19 01:14:50 +00003202 (outs), (ins i16mem:$src1, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00003203 "test{w}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00003204 [(X86cmp (and (loadi16 addr:$src1), imm:$src2), 0),
3205 (implicit EFLAGS)]>, OpSize;
3206def TEST32mi : Ii32<0xF7, MRM0m, // flags = [mem32] & imm32
Evan Chengb783fa32007-07-19 01:14:50 +00003207 (outs), (ins i32mem:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00003208 "test{l}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00003209 [(X86cmp (and (loadi32 addr:$src1), imm:$src2), 0),
Evan Cheng950aac02007-09-25 01:57:46 +00003210 (implicit EFLAGS)]>;
3211} // Defs = [EFLAGS]
3212
3213
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003214// Condition code ops, incl. set if equal/not equal/...
Chris Lattnerc90ee9c2008-01-10 07:59:24 +00003215let Defs = [EFLAGS], Uses = [AH], neverHasSideEffects = 1 in
Evan Cheng6e4d1d92007-09-11 19:55:27 +00003216def SAHF : I<0x9E, RawFrm, (outs), (ins), "sahf", []>; // flags = AH
Chris Lattnerc90ee9c2008-01-10 07:59:24 +00003217let Defs = [AH], Uses = [EFLAGS], neverHasSideEffects = 1 in
Evan Cheng6e4d1d92007-09-11 19:55:27 +00003218def LAHF : I<0x9F, RawFrm, (outs), (ins), "lahf", []>; // AH = flags
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003219
Evan Cheng950aac02007-09-25 01:57:46 +00003220let Uses = [EFLAGS] in {
Evan Cheng834ae6b2009-12-15 00:53:42 +00003221// Use sbb to materialize carry bit.
3222
3223let Defs = [EFLAGS], isCodeGenOnly = 1 in {
3224def SETB_C8r : I<0x18, MRMInitReg, (outs GR8:$dst), (ins),
3225 "sbb{b}\t$dst, $dst",
3226 [(set GR8:$dst, (X86setcc_c X86_COND_B, EFLAGS))]>;
3227def SETB_C16r : I<0x19, MRMInitReg, (outs GR16:$dst), (ins),
3228 "sbb{w}\t$dst, $dst",
Evan Chengedeb1692009-12-16 00:53:11 +00003229 [(set GR16:$dst, (X86setcc_c X86_COND_B, EFLAGS))]>,
Evan Cheng834ae6b2009-12-15 00:53:42 +00003230 OpSize;
3231def SETB_C32r : I<0x19, MRMInitReg, (outs GR32:$dst), (ins),
3232 "sbb{l}\t$dst, $dst",
Evan Chengedeb1692009-12-16 00:53:11 +00003233 [(set GR32:$dst, (X86setcc_c X86_COND_B, EFLAGS))]>;
Evan Cheng834ae6b2009-12-15 00:53:42 +00003234} // isCodeGenOnly
3235
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003236def SETEr : I<0x94, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00003237 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00003238 "sete\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00003239 [(set GR8:$dst, (X86setcc X86_COND_E, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003240 TB; // GR8 = ==
3241def SETEm : I<0x94, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00003242 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00003243 "sete\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00003244 [(store (X86setcc X86_COND_E, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003245 TB; // [mem8] = ==
Bill Wendling0c52d0a2008-12-02 00:07:05 +00003246
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003247def SETNEr : I<0x95, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00003248 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00003249 "setne\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00003250 [(set GR8:$dst, (X86setcc X86_COND_NE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003251 TB; // GR8 = !=
3252def SETNEm : I<0x95, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00003253 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00003254 "setne\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00003255 [(store (X86setcc X86_COND_NE, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003256 TB; // [mem8] = !=
Bill Wendling0c52d0a2008-12-02 00:07:05 +00003257
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003258def SETLr : I<0x9C, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00003259 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00003260 "setl\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00003261 [(set GR8:$dst, (X86setcc X86_COND_L, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003262 TB; // GR8 = < signed
3263def SETLm : I<0x9C, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00003264 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00003265 "setl\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00003266 [(store (X86setcc X86_COND_L, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003267 TB; // [mem8] = < signed
Bill Wendling0c52d0a2008-12-02 00:07:05 +00003268
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003269def SETGEr : I<0x9D, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00003270 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00003271 "setge\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00003272 [(set GR8:$dst, (X86setcc X86_COND_GE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003273 TB; // GR8 = >= signed
3274def SETGEm : I<0x9D, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00003275 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00003276 "setge\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00003277 [(store (X86setcc X86_COND_GE, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003278 TB; // [mem8] = >= signed
Bill Wendling0c52d0a2008-12-02 00:07:05 +00003279
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003280def SETLEr : I<0x9E, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00003281 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00003282 "setle\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00003283 [(set GR8:$dst, (X86setcc X86_COND_LE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003284 TB; // GR8 = <= signed
3285def SETLEm : I<0x9E, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00003286 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00003287 "setle\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00003288 [(store (X86setcc X86_COND_LE, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003289 TB; // [mem8] = <= signed
Bill Wendling0c52d0a2008-12-02 00:07:05 +00003290
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003291def SETGr : I<0x9F, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00003292 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00003293 "setg\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00003294 [(set GR8:$dst, (X86setcc X86_COND_G, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003295 TB; // GR8 = > signed
3296def SETGm : I<0x9F, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00003297 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00003298 "setg\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00003299 [(store (X86setcc X86_COND_G, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003300 TB; // [mem8] = > signed
3301
3302def SETBr : I<0x92, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00003303 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00003304 "setb\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00003305 [(set GR8:$dst, (X86setcc X86_COND_B, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003306 TB; // GR8 = < unsign
3307def SETBm : I<0x92, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00003308 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00003309 "setb\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00003310 [(store (X86setcc X86_COND_B, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003311 TB; // [mem8] = < unsign
Bill Wendling0c52d0a2008-12-02 00:07:05 +00003312
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003313def SETAEr : I<0x93, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00003314 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00003315 "setae\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00003316 [(set GR8:$dst, (X86setcc X86_COND_AE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003317 TB; // GR8 = >= unsign
3318def SETAEm : I<0x93, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00003319 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00003320 "setae\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00003321 [(store (X86setcc X86_COND_AE, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003322 TB; // [mem8] = >= unsign
Bill Wendling0c52d0a2008-12-02 00:07:05 +00003323
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003324def SETBEr : I<0x96, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00003325 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00003326 "setbe\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00003327 [(set GR8:$dst, (X86setcc X86_COND_BE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003328 TB; // GR8 = <= unsign
3329def SETBEm : I<0x96, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00003330 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00003331 "setbe\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00003332 [(store (X86setcc X86_COND_BE, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003333 TB; // [mem8] = <= unsign
Bill Wendling0c52d0a2008-12-02 00:07:05 +00003334
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003335def SETAr : I<0x97, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00003336 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00003337 "seta\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00003338 [(set GR8:$dst, (X86setcc X86_COND_A, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003339 TB; // GR8 = > signed
3340def SETAm : I<0x97, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00003341 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00003342 "seta\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00003343 [(store (X86setcc X86_COND_A, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003344 TB; // [mem8] = > signed
3345
3346def SETSr : I<0x98, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00003347 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00003348 "sets\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00003349 [(set GR8:$dst, (X86setcc X86_COND_S, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003350 TB; // GR8 = <sign bit>
3351def SETSm : I<0x98, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00003352 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00003353 "sets\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00003354 [(store (X86setcc X86_COND_S, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003355 TB; // [mem8] = <sign bit>
3356def SETNSr : I<0x99, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00003357 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00003358 "setns\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00003359 [(set GR8:$dst, (X86setcc X86_COND_NS, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003360 TB; // GR8 = !<sign bit>
3361def SETNSm : I<0x99, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00003362 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00003363 "setns\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00003364 [(store (X86setcc X86_COND_NS, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003365 TB; // [mem8] = !<sign bit>
Bill Wendling0c52d0a2008-12-02 00:07:05 +00003366
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003367def SETPr : I<0x9A, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00003368 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00003369 "setp\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00003370 [(set GR8:$dst, (X86setcc X86_COND_P, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003371 TB; // GR8 = parity
3372def SETPm : I<0x9A, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00003373 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00003374 "setp\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00003375 [(store (X86setcc X86_COND_P, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003376 TB; // [mem8] = parity
3377def SETNPr : I<0x9B, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00003378 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00003379 "setnp\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00003380 [(set GR8:$dst, (X86setcc X86_COND_NP, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003381 TB; // GR8 = not parity
3382def SETNPm : I<0x9B, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00003383 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00003384 "setnp\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00003385 [(store (X86setcc X86_COND_NP, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003386 TB; // [mem8] = not parity
Bill Wendling0c52d0a2008-12-02 00:07:05 +00003387
3388def SETOr : I<0x90, MRM0r,
3389 (outs GR8 :$dst), (ins),
3390 "seto\t$dst",
3391 [(set GR8:$dst, (X86setcc X86_COND_O, EFLAGS))]>,
3392 TB; // GR8 = overflow
3393def SETOm : I<0x90, MRM0m,
3394 (outs), (ins i8mem:$dst),
3395 "seto\t$dst",
3396 [(store (X86setcc X86_COND_O, EFLAGS), addr:$dst)]>,
3397 TB; // [mem8] = overflow
3398def SETNOr : I<0x91, MRM0r,
3399 (outs GR8 :$dst), (ins),
3400 "setno\t$dst",
3401 [(set GR8:$dst, (X86setcc X86_COND_NO, EFLAGS))]>,
3402 TB; // GR8 = not overflow
3403def SETNOm : I<0x91, MRM0m,
3404 (outs), (ins i8mem:$dst),
3405 "setno\t$dst",
3406 [(store (X86setcc X86_COND_NO, EFLAGS), addr:$dst)]>,
3407 TB; // [mem8] = not overflow
Evan Cheng950aac02007-09-25 01:57:46 +00003408} // Uses = [EFLAGS]
3409
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003410
3411// Integer comparisons
Evan Cheng55687072007-09-14 21:48:26 +00003412let Defs = [EFLAGS] in {
Sean Callanan251676e2009-09-02 00:55:49 +00003413def CMP8i8 : Ii8<0x3C, RawFrm, (outs), (ins i8imm:$src),
3414 "cmp{b}\t{$src, %al|%al, $src}", []>;
3415def CMP16i16 : Ii16<0x3D, RawFrm, (outs), (ins i16imm:$src),
3416 "cmp{w}\t{$src, %ax|%ax, $src}", []>, OpSize;
3417def CMP32i32 : Ii32<0x3D, RawFrm, (outs), (ins i32imm:$src),
3418 "cmp{l}\t{$src, %eax|%eax, $src}", []>;
3419
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003420def CMP8rr : I<0x38, MRMDestReg,
Evan Chengb783fa32007-07-19 01:14:50 +00003421 (outs), (ins GR8 :$src1, GR8 :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00003422 "cmp{b}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00003423 [(X86cmp GR8:$src1, GR8:$src2), (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003424def CMP16rr : I<0x39, MRMDestReg,
Evan Chengb783fa32007-07-19 01:14:50 +00003425 (outs), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00003426 "cmp{w}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00003427 [(X86cmp GR16:$src1, GR16:$src2), (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003428def CMP32rr : I<0x39, MRMDestReg,
Evan Chengb783fa32007-07-19 01:14:50 +00003429 (outs), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00003430 "cmp{l}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00003431 [(X86cmp GR32:$src1, GR32:$src2), (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003432def CMP8mr : I<0x38, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00003433 (outs), (ins i8mem :$src1, GR8 :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00003434 "cmp{b}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00003435 [(X86cmp (loadi8 addr:$src1), GR8:$src2),
3436 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003437def CMP16mr : I<0x39, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00003438 (outs), (ins i16mem:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00003439 "cmp{w}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00003440 [(X86cmp (loadi16 addr:$src1), GR16:$src2),
3441 (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003442def CMP32mr : I<0x39, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00003443 (outs), (ins i32mem:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00003444 "cmp{l}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00003445 [(X86cmp (loadi32 addr:$src1), GR32:$src2),
3446 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003447def CMP8rm : I<0x3A, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00003448 (outs), (ins GR8 :$src1, i8mem :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00003449 "cmp{b}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00003450 [(X86cmp GR8:$src1, (loadi8 addr:$src2)),
3451 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003452def CMP16rm : I<0x3B, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00003453 (outs), (ins GR16:$src1, i16mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00003454 "cmp{w}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00003455 [(X86cmp GR16:$src1, (loadi16 addr:$src2)),
3456 (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003457def CMP32rm : I<0x3B, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00003458 (outs), (ins GR32:$src1, i32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00003459 "cmp{l}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00003460 [(X86cmp GR32:$src1, (loadi32 addr:$src2)),
3461 (implicit EFLAGS)]>;
Sean Callanan11490dc2009-09-16 21:11:23 +00003462def CMP8mrmrr : I<0x3A, MRMSrcReg, (outs), (ins GR8:$src1, GR8:$src2),
3463 "cmp{b}\t{$src2, $src1|$src1, $src2}", []>;
3464def CMP16mrmrr : I<0x3B, MRMSrcReg, (outs), (ins GR16:$src1, GR16:$src2),
3465 "cmp{w}\t{$src2, $src1|$src1, $src2}", []>, OpSize;
3466def CMP32mrmrr : I<0x3B, MRMSrcReg, (outs), (ins GR32:$src1, GR32:$src2),
3467 "cmp{l}\t{$src2, $src1|$src1, $src2}", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003468def CMP8ri : Ii8<0x80, MRM7r,
Evan Chengb783fa32007-07-19 01:14:50 +00003469 (outs), (ins GR8:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00003470 "cmp{b}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00003471 [(X86cmp GR8:$src1, imm:$src2), (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003472def CMP16ri : Ii16<0x81, MRM7r,
Evan Chengb783fa32007-07-19 01:14:50 +00003473 (outs), (ins GR16:$src1, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00003474 "cmp{w}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00003475 [(X86cmp GR16:$src1, imm:$src2),
3476 (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003477def CMP32ri : Ii32<0x81, MRM7r,
Evan Chengb783fa32007-07-19 01:14:50 +00003478 (outs), (ins GR32:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00003479 "cmp{l}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00003480 [(X86cmp GR32:$src1, imm:$src2), (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003481def CMP8mi : Ii8 <0x80, MRM7m,
Evan Chengb783fa32007-07-19 01:14:50 +00003482 (outs), (ins i8mem :$src1, i8imm :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00003483 "cmp{b}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00003484 [(X86cmp (loadi8 addr:$src1), imm:$src2),
3485 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003486def CMP16mi : Ii16<0x81, MRM7m,
Evan Chengb783fa32007-07-19 01:14:50 +00003487 (outs), (ins i16mem:$src1, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00003488 "cmp{w}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00003489 [(X86cmp (loadi16 addr:$src1), imm:$src2),
3490 (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003491def CMP32mi : Ii32<0x81, MRM7m,
Evan Chengb783fa32007-07-19 01:14:50 +00003492 (outs), (ins i32mem:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00003493 "cmp{l}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00003494 [(X86cmp (loadi32 addr:$src1), imm:$src2),
3495 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003496def CMP16ri8 : Ii8<0x83, MRM7r,
Evan Chengb783fa32007-07-19 01:14:50 +00003497 (outs), (ins GR16:$src1, i16i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00003498 "cmp{w}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00003499 [(X86cmp GR16:$src1, i16immSExt8:$src2),
3500 (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003501def CMP16mi8 : Ii8<0x83, MRM7m,
Evan Chengb783fa32007-07-19 01:14:50 +00003502 (outs), (ins i16mem:$src1, i16i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00003503 "cmp{w}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00003504 [(X86cmp (loadi16 addr:$src1), i16immSExt8:$src2),
3505 (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003506def CMP32mi8 : Ii8<0x83, MRM7m,
Evan Chengb783fa32007-07-19 01:14:50 +00003507 (outs), (ins i32mem:$src1, i32i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00003508 "cmp{l}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00003509 [(X86cmp (loadi32 addr:$src1), i32immSExt8:$src2),
3510 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003511def CMP32ri8 : Ii8<0x83, MRM7r,
Evan Chengb783fa32007-07-19 01:14:50 +00003512 (outs), (ins GR32:$src1, i32i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00003513 "cmp{l}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00003514 [(X86cmp GR32:$src1, i32immSExt8:$src2),
Evan Cheng950aac02007-09-25 01:57:46 +00003515 (implicit EFLAGS)]>;
3516} // Defs = [EFLAGS]
3517
Dan Gohman7fe9b7f2008-12-23 22:45:23 +00003518// Bit tests.
Dan Gohman7fe9b7f2008-12-23 22:45:23 +00003519// TODO: BTC, BTR, and BTS
3520let Defs = [EFLAGS] in {
Dan Gohmanfc4eddb2009-01-13 20:32:45 +00003521def BT16rr : I<0xA3, MRMDestReg, (outs), (ins GR16:$src1, GR16:$src2),
Dan Gohman7fe9b7f2008-12-23 22:45:23 +00003522 "bt{w}\t{$src2, $src1|$src1, $src2}",
3523 [(X86bt GR16:$src1, GR16:$src2),
Chris Lattner5a95cde2008-12-25 01:32:49 +00003524 (implicit EFLAGS)]>, OpSize, TB;
Dan Gohmanfc4eddb2009-01-13 20:32:45 +00003525def BT32rr : I<0xA3, MRMDestReg, (outs), (ins GR32:$src1, GR32:$src2),
Dan Gohman7fe9b7f2008-12-23 22:45:23 +00003526 "bt{l}\t{$src2, $src1|$src1, $src2}",
3527 [(X86bt GR32:$src1, GR32:$src2),
Chris Lattner5a95cde2008-12-25 01:32:49 +00003528 (implicit EFLAGS)]>, TB;
Dan Gohman85a228c2009-01-13 23:23:30 +00003529
3530// Unlike with the register+register form, the memory+register form of the
3531// bt instruction does not ignore the high bits of the index. From ISel's
Sean Callanan2c48df22009-12-18 00:01:26 +00003532// perspective, this is pretty bizarre. Make these instructions disassembly
3533// only for now.
3534
3535def BT16mr : I<0xA3, MRMDestMem, (outs), (ins i16mem:$src1, GR16:$src2),
3536 "bt{w}\t{$src2, $src1|$src1, $src2}",
Dan Gohman85a228c2009-01-13 23:23:30 +00003537// [(X86bt (loadi16 addr:$src1), GR16:$src2),
Sean Callanan2c48df22009-12-18 00:01:26 +00003538// (implicit EFLAGS)]
3539 []
3540 >, OpSize, TB, Requires<[FastBTMem]>;
3541def BT32mr : I<0xA3, MRMDestMem, (outs), (ins i32mem:$src1, GR32:$src2),
3542 "bt{l}\t{$src2, $src1|$src1, $src2}",
Dan Gohman85a228c2009-01-13 23:23:30 +00003543// [(X86bt (loadi32 addr:$src1), GR32:$src2),
Sean Callanan2c48df22009-12-18 00:01:26 +00003544// (implicit EFLAGS)]
3545 []
3546 >, TB, Requires<[FastBTMem]>;
Dan Gohman46fb1cf2009-01-13 20:33:23 +00003547
3548def BT16ri8 : Ii8<0xBA, MRM4r, (outs), (ins GR16:$src1, i16i8imm:$src2),
3549 "bt{w}\t{$src2, $src1|$src1, $src2}",
3550 [(X86bt GR16:$src1, i16immSExt8:$src2),
3551 (implicit EFLAGS)]>, OpSize, TB;
3552def BT32ri8 : Ii8<0xBA, MRM4r, (outs), (ins GR32:$src1, i32i8imm:$src2),
3553 "bt{l}\t{$src2, $src1|$src1, $src2}",
3554 [(X86bt GR32:$src1, i32immSExt8:$src2),
3555 (implicit EFLAGS)]>, TB;
3556// Note that these instructions don't need FastBTMem because that
3557// only applies when the other operand is in a register. When it's
3558// an immediate, bt is still fast.
3559def BT16mi8 : Ii8<0xBA, MRM4m, (outs), (ins i16mem:$src1, i16i8imm:$src2),
3560 "bt{w}\t{$src2, $src1|$src1, $src2}",
3561 [(X86bt (loadi16 addr:$src1), i16immSExt8:$src2),
3562 (implicit EFLAGS)]>, OpSize, TB;
3563def BT32mi8 : Ii8<0xBA, MRM4m, (outs), (ins i32mem:$src1, i32i8imm:$src2),
3564 "bt{l}\t{$src2, $src1|$src1, $src2}",
3565 [(X86bt (loadi32 addr:$src1), i32immSExt8:$src2),
3566 (implicit EFLAGS)]>, TB;
Sean Callanan2c48df22009-12-18 00:01:26 +00003567
3568def BTC16rr : I<0xBB, MRMDestReg, (outs), (ins GR16:$src1, GR16:$src2),
3569 "btc{w}\t{$src2, $src1|$src1, $src2}", []>, OpSize, TB;
3570def BTC32rr : I<0xBB, MRMDestReg, (outs), (ins GR32:$src1, GR32:$src2),
3571 "btc{l}\t{$src2, $src1|$src1, $src2}", []>, TB;
3572def BTC16mr : I<0xBB, MRMDestMem, (outs), (ins i16mem:$src1, GR16:$src2),
3573 "btc{w}\t{$src2, $src1|$src1, $src2}", []>, OpSize, TB;
3574def BTC32mr : I<0xBB, MRMDestMem, (outs), (ins i32mem:$src1, GR32:$src2),
3575 "btc{l}\t{$src2, $src1|$src1, $src2}", []>, TB;
3576def BTC16ri8 : Ii8<0xBA, MRM7r, (outs), (ins GR16:$src1, i16i8imm:$src2),
3577 "btc{w}\t{$src2, $src1|$src1, $src2}", []>, OpSize, TB;
3578def BTC32ri8 : Ii8<0xBA, MRM7r, (outs), (ins GR32:$src1, i32i8imm:$src2),
3579 "btc{l}\t{$src2, $src1|$src1, $src2}", []>, TB;
3580def BTC16mi8 : Ii8<0xBA, MRM7m, (outs), (ins i16mem:$src1, i16i8imm:$src2),
3581 "btc{w}\t{$src2, $src1|$src1, $src2}", []>, OpSize, TB;
3582def BTC32mi8 : Ii8<0xBA, MRM7m, (outs), (ins i32mem:$src1, i32i8imm:$src2),
3583 "btc{l}\t{$src2, $src1|$src1, $src2}", []>, TB;
3584
3585def BTR16rr : I<0xB3, MRMDestReg, (outs), (ins GR16:$src1, GR16:$src2),
3586 "btr{w}\t{$src2, $src1|$src1, $src2}", []>, OpSize, TB;
3587def BTR32rr : I<0xB3, MRMDestReg, (outs), (ins GR32:$src1, GR32:$src2),
3588 "btr{l}\t{$src2, $src1|$src1, $src2}", []>, TB;
3589def BTR16mr : I<0xB3, MRMDestMem, (outs), (ins i16mem:$src1, GR16:$src2),
3590 "btr{w}\t{$src2, $src1|$src1, $src2}", []>, OpSize, TB;
3591def BTR32mr : I<0xB3, MRMDestMem, (outs), (ins i32mem:$src1, GR32:$src2),
3592 "btr{l}\t{$src2, $src1|$src1, $src2}", []>, TB;
3593def BTR16ri8 : Ii8<0xBA, MRM6r, (outs), (ins GR16:$src1, i16i8imm:$src2),
3594 "btr{w}\t{$src2, $src1|$src1, $src2}", []>, OpSize, TB;
3595def BTR32ri8 : Ii8<0xBA, MRM6r, (outs), (ins GR32:$src1, i32i8imm:$src2),
3596 "btr{l}\t{$src2, $src1|$src1, $src2}", []>, TB;
3597def BTR16mi8 : Ii8<0xBA, MRM6m, (outs), (ins i16mem:$src1, i16i8imm:$src2),
3598 "btr{w}\t{$src2, $src1|$src1, $src2}", []>, OpSize, TB;
3599def BTR32mi8 : Ii8<0xBA, MRM6m, (outs), (ins i32mem:$src1, i32i8imm:$src2),
3600 "btr{l}\t{$src2, $src1|$src1, $src2}", []>, TB;
3601
3602def BTS16rr : I<0xAB, MRMDestReg, (outs), (ins GR16:$src1, GR16:$src2),
3603 "bts{w}\t{$src2, $src1|$src1, $src2}", []>, OpSize, TB;
3604def BTS32rr : I<0xAB, MRMDestReg, (outs), (ins GR32:$src1, GR32:$src2),
3605 "bts{l}\t{$src2, $src1|$src1, $src2}", []>, TB;
3606def BTS16mr : I<0xAB, MRMDestMem, (outs), (ins i16mem:$src1, GR16:$src2),
3607 "bts{w}\t{$src2, $src1|$src1, $src2}", []>, OpSize, TB;
3608def BTS32mr : I<0xAB, MRMDestMem, (outs), (ins i32mem:$src1, GR32:$src2),
3609 "bts{l}\t{$src2, $src1|$src1, $src2}", []>, TB;
3610def BTS16ri8 : Ii8<0xBA, MRM5r, (outs), (ins GR16:$src1, i16i8imm:$src2),
3611 "bts{w}\t{$src2, $src1|$src1, $src2}", []>, OpSize, TB;
3612def BTS32ri8 : Ii8<0xBA, MRM5r, (outs), (ins GR32:$src1, i32i8imm:$src2),
3613 "bts{l}\t{$src2, $src1|$src1, $src2}", []>, TB;
3614def BTS16mi8 : Ii8<0xBA, MRM5m, (outs), (ins i16mem:$src1, i16i8imm:$src2),
3615 "bts{w}\t{$src2, $src1|$src1, $src2}", []>, OpSize, TB;
3616def BTS32mi8 : Ii8<0xBA, MRM5m, (outs), (ins i32mem:$src1, i32i8imm:$src2),
3617 "bts{l}\t{$src2, $src1|$src1, $src2}", []>, TB;
Dan Gohman7fe9b7f2008-12-23 22:45:23 +00003618} // Defs = [EFLAGS]
3619
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003620// Sign/Zero extenders
Dan Gohman9203ab42008-07-30 18:09:17 +00003621// Use movsbl intead of movsbw; we don't care about the high 16 bits
3622// of the register here. This has a smaller encoding and avoids a
Sean Callanan2c48df22009-12-18 00:01:26 +00003623// partial-register update. Actual movsbw included for the disassembler.
3624def MOVSX16rr8W : I<0xBE, MRMSrcReg, (outs GR16:$dst), (ins GR8:$src),
3625 "movs{bw|x}\t{$src, $dst|$dst, $src}", []>, TB, OpSize;
3626def MOVSX16rm8W : I<0xBE, MRMSrcMem, (outs GR16:$dst), (ins i8mem:$src),
3627 "movs{bw|x}\t{$src, $dst|$dst, $src}", []>, TB, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00003628def MOVSX16rr8 : I<0xBE, MRMSrcReg, (outs GR16:$dst), (ins GR8 :$src),
Chris Lattnerbe7efcc2009-10-19 19:51:42 +00003629 "", [(set GR16:$dst, (sext GR8:$src))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00003630def MOVSX16rm8 : I<0xBE, MRMSrcMem, (outs GR16:$dst), (ins i8mem :$src),
Chris Lattnerbe7efcc2009-10-19 19:51:42 +00003631 "", [(set GR16:$dst, (sextloadi16i8 addr:$src))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00003632def MOVSX32rr8 : I<0xBE, MRMSrcReg, (outs GR32:$dst), (ins GR8 :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00003633 "movs{bl|x}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003634 [(set GR32:$dst, (sext GR8:$src))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00003635def MOVSX32rm8 : I<0xBE, MRMSrcMem, (outs GR32:$dst), (ins i8mem :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00003636 "movs{bl|x}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003637 [(set GR32:$dst, (sextloadi32i8 addr:$src))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00003638def MOVSX32rr16: I<0xBF, MRMSrcReg, (outs GR32:$dst), (ins GR16:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00003639 "movs{wl|x}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003640 [(set GR32:$dst, (sext GR16:$src))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00003641def MOVSX32rm16: I<0xBF, MRMSrcMem, (outs GR32:$dst), (ins i16mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00003642 "movs{wl|x}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003643 [(set GR32:$dst, (sextloadi32i16 addr:$src))]>, TB;
3644
Dan Gohman9203ab42008-07-30 18:09:17 +00003645// Use movzbl intead of movzbw; we don't care about the high 16 bits
3646// of the register here. This has a smaller encoding and avoids a
Sean Callanan2c48df22009-12-18 00:01:26 +00003647// partial-register update. Actual movzbw included for the disassembler.
3648def MOVZX16rr8W : I<0xB6, MRMSrcReg, (outs GR16:$dst), (ins GR8:$src),
3649 "movz{bw|x}\t{$src, $dst|$dst, $src}", []>, TB, OpSize;
3650def MOVZX16rm8W : I<0xB6, MRMSrcMem, (outs GR16:$dst), (ins i8mem:$src),
3651 "movz{bw|x}\t{$src, $dst|$dst, $src}", []>, TB, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00003652def MOVZX16rr8 : I<0xB6, MRMSrcReg, (outs GR16:$dst), (ins GR8 :$src),
Chris Lattnerbe7efcc2009-10-19 19:51:42 +00003653 "", [(set GR16:$dst, (zext GR8:$src))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00003654def MOVZX16rm8 : I<0xB6, MRMSrcMem, (outs GR16:$dst), (ins i8mem :$src),
Chris Lattnerbe7efcc2009-10-19 19:51:42 +00003655 "", [(set GR16:$dst, (zextloadi16i8 addr:$src))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00003656def MOVZX32rr8 : I<0xB6, MRMSrcReg, (outs GR32:$dst), (ins GR8 :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00003657 "movz{bl|x}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003658 [(set GR32:$dst, (zext GR8:$src))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00003659def MOVZX32rm8 : I<0xB6, MRMSrcMem, (outs GR32:$dst), (ins i8mem :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00003660 "movz{bl|x}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003661 [(set GR32:$dst, (zextloadi32i8 addr:$src))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00003662def MOVZX32rr16: I<0xB7, MRMSrcReg, (outs GR32:$dst), (ins GR16:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00003663 "movz{wl|x}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003664 [(set GR32:$dst, (zext GR16:$src))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00003665def MOVZX32rm16: I<0xB7, MRMSrcMem, (outs GR32:$dst), (ins i16mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00003666 "movz{wl|x}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003667 [(set GR32:$dst, (zextloadi32i16 addr:$src))]>, TB;
3668
Dan Gohman744d4622009-04-13 16:09:41 +00003669// These are the same as the regular regular MOVZX32rr8 and MOVZX32rm8
3670// except that they use GR32_NOREX for the output operand register class
3671// instead of GR32. This allows them to operate on h registers on x86-64.
3672def MOVZX32_NOREXrr8 : I<0xB6, MRMSrcReg,
3673 (outs GR32_NOREX:$dst), (ins GR8:$src),
3674 "movz{bl|x}\t{$src, $dst|$dst, $src} # NOREX",
3675 []>, TB;
Dan Gohman89f4cda2009-04-30 03:11:48 +00003676let mayLoad = 1 in
Dan Gohman744d4622009-04-13 16:09:41 +00003677def MOVZX32_NOREXrm8 : I<0xB6, MRMSrcMem,
3678 (outs GR32_NOREX:$dst), (ins i8mem:$src),
3679 "movz{bl|x}\t{$src, $dst|$dst, $src} # NOREX",
3680 []>, TB;
3681
Chris Lattnerc90ee9c2008-01-10 07:59:24 +00003682let neverHasSideEffects = 1 in {
3683 let Defs = [AX], Uses = [AL] in
3684 def CBW : I<0x98, RawFrm, (outs), (ins),
3685 "{cbtw|cbw}", []>, OpSize; // AX = signext(AL)
3686 let Defs = [EAX], Uses = [AX] in
3687 def CWDE : I<0x98, RawFrm, (outs), (ins),
3688 "{cwtl|cwde}", []>; // EAX = signext(AX)
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003689
Chris Lattnerc90ee9c2008-01-10 07:59:24 +00003690 let Defs = [AX,DX], Uses = [AX] in
3691 def CWD : I<0x99, RawFrm, (outs), (ins),
3692 "{cwtd|cwd}", []>, OpSize; // DX:AX = signext(AX)
3693 let Defs = [EAX,EDX], Uses = [EAX] in
3694 def CDQ : I<0x99, RawFrm, (outs), (ins),
3695 "{cltd|cdq}", []>; // EDX:EAX = signext(EAX)
3696}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003697
3698//===----------------------------------------------------------------------===//
3699// Alias Instructions
3700//===----------------------------------------------------------------------===//
3701
3702// Alias instructions that map movr0 to xor.
3703// FIXME: remove when we can teach regalloc that xor reg, reg is ok.
Daniel Dunbara0e62002009-08-11 22:17:52 +00003704let Defs = [EFLAGS], isReMaterializable = 1, isAsCheapAsAMove = 1,
3705 isCodeGenOnly = 1 in {
Evan Chengb783fa32007-07-19 01:14:50 +00003706def MOV8r0 : I<0x30, MRMInitReg, (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00003707 "xor{b}\t$dst, $dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003708 [(set GR8:$dst, 0)]>;
Chris Lattnerb5b1b862009-12-23 01:30:26 +00003709
Chris Lattner2ba53dc2009-12-23 01:46:40 +00003710def MOV32r0 : I<0x31, MRMInitReg, (outs GR32:$dst), (ins),
3711 "xor{l}\t$dst, $dst",
3712 [(set GR32:$dst, 0)]>;
3713}
Chris Lattnerb5b1b862009-12-23 01:30:26 +00003714
Dan Gohman9203ab42008-07-30 18:09:17 +00003715// Use xorl instead of xorw since we don't care about the high 16 bits,
3716// it's smaller, and it avoids a partial-register update.
Chris Lattnerb5b1b862009-12-23 01:30:26 +00003717let AddedComplexity = 1 in
3718def : Pat<(i16 0),
3719 (EXTRACT_SUBREG (MOV32r0), x86_subreg_16bit)>;
3720
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003721//===----------------------------------------------------------------------===//
3722// Thread Local Storage Instructions
3723//
3724
Rafael Espindola7fc4b8d2009-04-24 12:59:40 +00003725// All calls clobber the non-callee saved registers. ESP is marked as
3726// a use to prevent stack-pointer assignments that appear immediately
3727// before calls from potentially appearing dead.
3728let Defs = [EAX, ECX, EDX, FP0, FP1, FP2, FP3, FP4, FP5, FP6, ST0,
3729 MM0, MM1, MM2, MM3, MM4, MM5, MM6, MM7,
3730 XMM0, XMM1, XMM2, XMM3, XMM4, XMM5, XMM6, XMM7,
3731 XMM8, XMM9, XMM10, XMM11, XMM12, XMM13, XMM14, XMM15, EFLAGS],
Chris Lattnerf1940742009-06-20 20:38:48 +00003732 Uses = [ESP] in
3733def TLS_addr32 : I<0, Pseudo, (outs), (ins lea32mem:$sym),
3734 "leal\t$sym, %eax; "
Dan Gohman70a8a112009-04-27 15:13:28 +00003735 "call\t___tls_get_addr@PLT",
Chris Lattnerf1940742009-06-20 20:38:48 +00003736 [(X86tlsaddr tls32addr:$sym)]>,
Rafael Espindolaaf759ab2009-04-17 14:35:58 +00003737 Requires<[In32BitMode]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003738
Daniel Dunbar75a07302009-08-11 22:24:40 +00003739let AddedComplexity = 5, isCodeGenOnly = 1 in
sampo9cc09a32009-01-26 01:24:32 +00003740def GS_MOV32rm : I<0x8B, MRMSrcMem, (outs GR32:$dst), (ins i32mem:$src),
3741 "movl\t%gs:$src, $dst",
3742 [(set GR32:$dst, (gsload addr:$src))]>, SegGS;
3743
Daniel Dunbar75a07302009-08-11 22:24:40 +00003744let AddedComplexity = 5, isCodeGenOnly = 1 in
Chris Lattnera7c2d8a2009-05-05 18:52:19 +00003745def FS_MOV32rm : I<0x8B, MRMSrcMem, (outs GR32:$dst), (ins i32mem:$src),
3746 "movl\t%fs:$src, $dst",
3747 [(set GR32:$dst, (fsload addr:$src))]>, SegFS;
3748
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003749//===----------------------------------------------------------------------===//
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003750// EH Pseudo Instructions
3751//
3752let isTerminator = 1, isReturn = 1, isBarrier = 1,
Daniel Dunbar75513bd2009-08-27 07:58:05 +00003753 hasCtrlDep = 1, isCodeGenOnly = 1 in {
Evan Chengb783fa32007-07-19 01:14:50 +00003754def EH_RETURN : I<0xC3, RawFrm, (outs), (ins GR32:$addr),
Dan Gohman91888f02007-07-31 20:11:57 +00003755 "ret\t#eh_return, addr: $addr",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003756 [(X86ehret GR32:$addr)]>;
3757
3758}
3759
3760//===----------------------------------------------------------------------===//
Andrew Lenharthe44f3902008-02-21 06:45:13 +00003761// Atomic support
3762//
Andrew Lenharth7a5a4b22008-03-01 13:37:02 +00003763
Evan Cheng3e171562008-04-19 01:20:30 +00003764// Atomic swap. These are just normal xchg instructions. But since a memory
3765// operand is referenced, the atomicity is ensured.
Dan Gohmana41a1c092008-08-06 15:52:50 +00003766let Constraints = "$val = $dst" in {
Sean Callanan2c48df22009-12-18 00:01:26 +00003767def XCHG32rm : I<0x87, MRMSrcMem, (outs GR32:$dst),
3768 (ins GR32:$val, i32mem:$ptr),
Evan Cheng3e171562008-04-19 01:20:30 +00003769 "xchg{l}\t{$val, $ptr|$ptr, $val}",
3770 [(set GR32:$dst, (atomic_swap_32 addr:$ptr, GR32:$val))]>;
Sean Callanan2c48df22009-12-18 00:01:26 +00003771def XCHG16rm : I<0x87, MRMSrcMem, (outs GR16:$dst),
3772 (ins GR16:$val, i16mem:$ptr),
Evan Cheng3e171562008-04-19 01:20:30 +00003773 "xchg{w}\t{$val, $ptr|$ptr, $val}",
3774 [(set GR16:$dst, (atomic_swap_16 addr:$ptr, GR16:$val))]>,
3775 OpSize;
Sean Callanan2c48df22009-12-18 00:01:26 +00003776def XCHG8rm : I<0x86, MRMSrcMem, (outs GR8:$dst), (ins GR8:$val, i8mem:$ptr),
Evan Cheng3e171562008-04-19 01:20:30 +00003777 "xchg{b}\t{$val, $ptr|$ptr, $val}",
3778 [(set GR8:$dst, (atomic_swap_8 addr:$ptr, GR8:$val))]>;
Sean Callanan2c48df22009-12-18 00:01:26 +00003779
3780def XCHG32rr : I<0x87, MRMSrcReg, (outs GR32:$dst), (ins GR32:$val, GR32:$src),
3781 "xchg{l}\t{$val, $src|$src, $val}", []>;
3782def XCHG16rr : I<0x87, MRMSrcReg, (outs GR16:$dst), (ins GR16:$val, GR16:$src),
3783 "xchg{w}\t{$val, $src|$src, $val}", []>, OpSize;
3784def XCHG8rr : I<0x86, MRMSrcReg, (outs GR8:$dst), (ins GR8:$val, GR8:$src),
3785 "xchg{b}\t{$val, $src|$src, $val}", []>;
Evan Cheng3e171562008-04-19 01:20:30 +00003786}
3787
Sean Callanan2c48df22009-12-18 00:01:26 +00003788def XCHG16ar : I<0x90, AddRegFrm, (outs), (ins GR16:$src),
3789 "xchg{w}\t{$src, %ax|%ax, $src}", []>, OpSize;
3790def XCHG32ar : I<0x90, AddRegFrm, (outs), (ins GR32:$src),
3791 "xchg{l}\t{$src, %eax|%eax, $src}", []>;
3792
Evan Chengd49dbb82008-04-18 20:55:36 +00003793// Atomic compare and swap.
Andrew Lenharth7dfe23f2008-03-01 21:52:34 +00003794let Defs = [EAX, EFLAGS], Uses = [EAX] in {
Evan Chengd49dbb82008-04-18 20:55:36 +00003795def LCMPXCHG32 : I<0xB1, MRMDestMem, (outs), (ins i32mem:$ptr, GR32:$swap),
Dan Gohman70a8a112009-04-27 15:13:28 +00003796 "lock\n\t"
3797 "cmpxchg{l}\t{$swap, $ptr|$ptr, $swap}",
Evan Cheng09fbdee2008-03-04 03:20:06 +00003798 [(X86cas addr:$ptr, GR32:$swap, 4)]>, TB, LOCK;
Andrew Lenharth7a5a4b22008-03-01 13:37:02 +00003799}
Dale Johannesenf160d802008-10-02 18:53:47 +00003800let Defs = [EAX, EDX, EFLAGS], Uses = [EAX, EBX, ECX, EDX] in {
Evan Cheng3896a6f2010-01-08 01:29:19 +00003801def LCMPXCHG8B : I<0xC7, MRM1m, (outs), (ins i64mem:$ptr),
Dan Gohman70a8a112009-04-27 15:13:28 +00003802 "lock\n\t"
3803 "cmpxchg8b\t$ptr",
Andrew Lenharth81580822008-03-05 01:15:49 +00003804 [(X86cas8 addr:$ptr)]>, TB, LOCK;
3805}
Andrew Lenharth7dfe23f2008-03-01 21:52:34 +00003806
3807let Defs = [AX, EFLAGS], Uses = [AX] in {
Evan Chengd49dbb82008-04-18 20:55:36 +00003808def LCMPXCHG16 : I<0xB1, MRMDestMem, (outs), (ins i16mem:$ptr, GR16:$swap),
Dan Gohman70a8a112009-04-27 15:13:28 +00003809 "lock\n\t"
3810 "cmpxchg{w}\t{$swap, $ptr|$ptr, $swap}",
Evan Cheng09fbdee2008-03-04 03:20:06 +00003811 [(X86cas addr:$ptr, GR16:$swap, 2)]>, TB, OpSize, LOCK;
Andrew Lenharth7a5a4b22008-03-01 13:37:02 +00003812}
Andrew Lenharth7dfe23f2008-03-01 21:52:34 +00003813let Defs = [AL, EFLAGS], Uses = [AL] in {
Evan Chengd49dbb82008-04-18 20:55:36 +00003814def LCMPXCHG8 : I<0xB0, MRMDestMem, (outs), (ins i8mem:$ptr, GR8:$swap),
Dan Gohman70a8a112009-04-27 15:13:28 +00003815 "lock\n\t"
3816 "cmpxchg{b}\t{$swap, $ptr|$ptr, $swap}",
Evan Cheng09fbdee2008-03-04 03:20:06 +00003817 [(X86cas addr:$ptr, GR8:$swap, 1)]>, TB, LOCK;
Andrew Lenharth7a5a4b22008-03-01 13:37:02 +00003818}
3819
Evan Chengd49dbb82008-04-18 20:55:36 +00003820// Atomic exchange and add
3821let Constraints = "$val = $dst", Defs = [EFLAGS] in {
Sean Callanan2c48df22009-12-18 00:01:26 +00003822def LXADD32 : I<0xC1, MRMSrcMem, (outs GR32:$dst), (ins GR32:$val, i32mem:$ptr),
Dan Gohman70a8a112009-04-27 15:13:28 +00003823 "lock\n\t"
3824 "xadd{l}\t{$val, $ptr|$ptr, $val}",
Mon P Wang6bde9ec2008-06-25 08:15:39 +00003825 [(set GR32:$dst, (atomic_load_add_32 addr:$ptr, GR32:$val))]>,
Evan Chengd49dbb82008-04-18 20:55:36 +00003826 TB, LOCK;
Sean Callanan2c48df22009-12-18 00:01:26 +00003827def LXADD16 : I<0xC1, MRMSrcMem, (outs GR16:$dst), (ins GR16:$val, i16mem:$ptr),
Dan Gohman70a8a112009-04-27 15:13:28 +00003828 "lock\n\t"
3829 "xadd{w}\t{$val, $ptr|$ptr, $val}",
Mon P Wang6bde9ec2008-06-25 08:15:39 +00003830 [(set GR16:$dst, (atomic_load_add_16 addr:$ptr, GR16:$val))]>,
Evan Chengd49dbb82008-04-18 20:55:36 +00003831 TB, OpSize, LOCK;
Sean Callanan2c48df22009-12-18 00:01:26 +00003832def LXADD8 : I<0xC0, MRMSrcMem, (outs GR8:$dst), (ins GR8:$val, i8mem:$ptr),
Dan Gohman70a8a112009-04-27 15:13:28 +00003833 "lock\n\t"
3834 "xadd{b}\t{$val, $ptr|$ptr, $val}",
Mon P Wang6bde9ec2008-06-25 08:15:39 +00003835 [(set GR8:$dst, (atomic_load_add_8 addr:$ptr, GR8:$val))]>,
Evan Chengd49dbb82008-04-18 20:55:36 +00003836 TB, LOCK;
Andrew Lenharth7a5a4b22008-03-01 13:37:02 +00003837}
3838
Sean Callanan2c48df22009-12-18 00:01:26 +00003839def XADD8rr : I<0xC0, MRMDestReg, (outs GR8:$dst), (ins GR8:$src),
3840 "xadd{b}\t{$src, $dst|$dst, $src}", []>, TB;
3841def XADD16rr : I<0xC1, MRMDestReg, (outs GR16:$dst), (ins GR16:$src),
3842 "xadd{w}\t{$src, $dst|$dst, $src}", []>, TB, OpSize;
3843def XADD32rr : I<0xC1, MRMDestReg, (outs GR32:$dst), (ins GR32:$src),
3844 "xadd{l}\t{$src, $dst|$dst, $src}", []>, TB;
3845
3846def XADD8rm : I<0xC0, MRMDestMem, (outs), (ins i8mem:$dst, GR8:$src),
3847 "xadd{b}\t{$src, $dst|$dst, $src}", []>, TB;
3848def XADD16rm : I<0xC1, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src),
3849 "xadd{w}\t{$src, $dst|$dst, $src}", []>, TB, OpSize;
3850def XADD32rm : I<0xC1, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src),
3851 "xadd{l}\t{$src, $dst|$dst, $src}", []>, TB;
3852
3853def CMPXCHG8rr : I<0xB0, MRMDestReg, (outs GR8:$dst), (ins GR8:$src),
3854 "cmpxchg{b}\t{$src, $dst|$dst, $src}", []>, TB;
3855def CMPXCHG16rr : I<0xB1, MRMDestReg, (outs GR16:$dst), (ins GR16:$src),
3856 "cmpxchg{w}\t{$src, $dst|$dst, $src}", []>, TB, OpSize;
3857def CMPXCHG32rr : I<0xB1, MRMDestReg, (outs GR32:$dst), (ins GR32:$src),
3858 "cmpxchg{l}\t{$src, $dst|$dst, $src}", []>, TB;
3859
3860def CMPXCHG8rm : I<0xB0, MRMDestMem, (outs), (ins i8mem:$dst, GR8:$src),
3861 "cmpxchg{b}\t{$src, $dst|$dst, $src}", []>, TB;
3862def CMPXCHG16rm : I<0xB1, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src),
3863 "cmpxchg{w}\t{$src, $dst|$dst, $src}", []>, TB, OpSize;
3864def CMPXCHG32rm : I<0xB1, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src),
3865 "cmpxchg{l}\t{$src, $dst|$dst, $src}", []>, TB;
3866
Evan Cheng3896a6f2010-01-08 01:29:19 +00003867let Defs = [EAX, EDX, EFLAGS], Uses = [EAX, EBX, ECX, EDX] in
Sean Callanan2c48df22009-12-18 00:01:26 +00003868def CMPXCHG8B : I<0xC7, MRM1m, (outs), (ins i64mem:$dst),
3869 "cmpxchg8b\t$dst", []>, TB;
3870
Evan Chengb723fb52009-07-30 08:33:02 +00003871// Optimized codegen when the non-memory output is not used.
3872// FIXME: Use normal add / sub instructions and add lock prefix dynamically.
Dan Gohman1c286992009-10-20 18:14:49 +00003873let Defs = [EFLAGS] in {
Evan Chengb723fb52009-07-30 08:33:02 +00003874def LOCK_ADD8mr : I<0x00, MRMDestMem, (outs), (ins i8mem:$dst, GR8:$src2),
3875 "lock\n\t"
3876 "add{b}\t{$src2, $dst|$dst, $src2}", []>, LOCK;
3877def LOCK_ADD16mr : I<0x01, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
3878 "lock\n\t"
3879 "add{w}\t{$src2, $dst|$dst, $src2}", []>, OpSize, LOCK;
3880def LOCK_ADD32mr : I<0x01, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
3881 "lock\n\t"
3882 "add{l}\t{$src2, $dst|$dst, $src2}", []>, LOCK;
3883def LOCK_ADD8mi : Ii8<0x80, MRM0m, (outs), (ins i8mem :$dst, i8imm :$src2),
3884 "lock\n\t"
3885 "add{b}\t{$src2, $dst|$dst, $src2}", []>, LOCK;
3886def LOCK_ADD16mi : Ii16<0x81, MRM0m, (outs), (ins i16mem:$dst, i16imm:$src2),
3887 "lock\n\t"
3888 "add{w}\t{$src2, $dst|$dst, $src2}", []>, LOCK;
3889def LOCK_ADD32mi : Ii32<0x81, MRM0m, (outs), (ins i32mem:$dst, i32imm:$src2),
3890 "lock\n\t"
3891 "add{l}\t{$src2, $dst|$dst, $src2}", []>, LOCK;
3892def LOCK_ADD16mi8 : Ii8<0x83, MRM0m, (outs), (ins i16mem:$dst, i16i8imm :$src2),
3893 "lock\n\t"
3894 "add{w}\t{$src2, $dst|$dst, $src2}", []>, OpSize, LOCK;
3895def LOCK_ADD32mi8 : Ii8<0x83, MRM0m, (outs), (ins i32mem:$dst, i32i8imm :$src2),
3896 "lock\n\t"
3897 "add{l}\t{$src2, $dst|$dst, $src2}", []>, LOCK;
3898
3899def LOCK_INC8m : I<0xFE, MRM0m, (outs), (ins i8mem :$dst),
3900 "lock\n\t"
3901 "inc{b}\t$dst", []>, LOCK;
3902def LOCK_INC16m : I<0xFF, MRM0m, (outs), (ins i16mem:$dst),
3903 "lock\n\t"
3904 "inc{w}\t$dst", []>, OpSize, LOCK;
3905def LOCK_INC32m : I<0xFF, MRM0m, (outs), (ins i32mem:$dst),
3906 "lock\n\t"
3907 "inc{l}\t$dst", []>, LOCK;
3908
3909def LOCK_SUB8mr : I<0x28, MRMDestMem, (outs), (ins i8mem :$dst, GR8 :$src2),
3910 "lock\n\t"
3911 "sub{b}\t{$src2, $dst|$dst, $src2}", []>, LOCK;
3912def LOCK_SUB16mr : I<0x29, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
3913 "lock\n\t"
3914 "sub{w}\t{$src2, $dst|$dst, $src2}", []>, OpSize, LOCK;
3915def LOCK_SUB32mr : I<0x29, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
3916 "lock\n\t"
3917 "sub{l}\t{$src2, $dst|$dst, $src2}", []>, LOCK;
3918def LOCK_SUB8mi : Ii8<0x80, MRM5m, (outs), (ins i8mem :$dst, i8imm:$src2),
3919 "lock\n\t"
3920 "sub{b}\t{$src2, $dst|$dst, $src2}", []>, LOCK;
3921def LOCK_SUB16mi : Ii16<0x81, MRM5m, (outs), (ins i16mem:$dst, i16imm:$src2),
3922 "lock\n\t"
3923 "sub{w}\t{$src2, $dst|$dst, $src2}", []>, OpSize, LOCK;
3924def LOCK_SUB32mi : Ii32<0x81, MRM5m, (outs), (ins i32mem:$dst, i32imm:$src2),
3925 "lock\n\t"
3926 "sub{l}\t{$src2, $dst|$dst, $src2}", []>, LOCK;
Sean Callanan2c48df22009-12-18 00:01:26 +00003927def LOCK_SUB16mi8 : Ii8<0x83, MRM5m, (outs), (ins i16mem:$dst, i16i8imm :$src2),
Evan Chengb723fb52009-07-30 08:33:02 +00003928 "lock\n\t"
3929 "sub{w}\t{$src2, $dst|$dst, $src2}", []>, OpSize, LOCK;
3930def LOCK_SUB32mi8 : Ii8<0x83, MRM5m, (outs), (ins i32mem:$dst, i32i8imm :$src2),
3931 "lock\n\t"
3932 "sub{l}\t{$src2, $dst|$dst, $src2}", []>, LOCK;
3933
3934def LOCK_DEC8m : I<0xFE, MRM1m, (outs), (ins i8mem :$dst),
3935 "lock\n\t"
3936 "dec{b}\t$dst", []>, LOCK;
3937def LOCK_DEC16m : I<0xFF, MRM1m, (outs), (ins i16mem:$dst),
3938 "lock\n\t"
3939 "dec{w}\t$dst", []>, OpSize, LOCK;
3940def LOCK_DEC32m : I<0xFF, MRM1m, (outs), (ins i32mem:$dst),
3941 "lock\n\t"
3942 "dec{l}\t$dst", []>, LOCK;
Dan Gohman1c286992009-10-20 18:14:49 +00003943}
Evan Chengb723fb52009-07-30 08:33:02 +00003944
Mon P Wang6bde9ec2008-06-25 08:15:39 +00003945// Atomic exchange, and, or, xor
Mon P Wang078a62d2008-05-05 19:05:59 +00003946let Constraints = "$val = $dst", Defs = [EFLAGS],
Dan Gohman30afe012009-10-29 18:10:34 +00003947 usesCustomInserter = 1 in {
Dan Gohman8aeb61f2008-05-12 20:22:45 +00003948def ATOMAND32 : I<0, Pseudo, (outs GR32:$dst),(ins i32mem:$ptr, GR32:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003949 "#ATOMAND32 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003950 [(set GR32:$dst, (atomic_load_and_32 addr:$ptr, GR32:$val))]>;
Dan Gohman8aeb61f2008-05-12 20:22:45 +00003951def ATOMOR32 : I<0, Pseudo, (outs GR32:$dst),(ins i32mem:$ptr, GR32:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003952 "#ATOMOR32 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003953 [(set GR32:$dst, (atomic_load_or_32 addr:$ptr, GR32:$val))]>;
Dan Gohman8aeb61f2008-05-12 20:22:45 +00003954def ATOMXOR32 : I<0, Pseudo,(outs GR32:$dst),(ins i32mem:$ptr, GR32:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003955 "#ATOMXOR32 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003956 [(set GR32:$dst, (atomic_load_xor_32 addr:$ptr, GR32:$val))]>;
Andrew Lenharthaf02d592008-06-14 05:48:15 +00003957def ATOMNAND32 : I<0, Pseudo,(outs GR32:$dst),(ins i32mem:$ptr, GR32:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003958 "#ATOMNAND32 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003959 [(set GR32:$dst, (atomic_load_nand_32 addr:$ptr, GR32:$val))]>;
Dan Gohman8aeb61f2008-05-12 20:22:45 +00003960def ATOMMIN32: I<0, Pseudo, (outs GR32:$dst), (ins i32mem:$ptr, GR32:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003961 "#ATOMMIN32 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003962 [(set GR32:$dst, (atomic_load_min_32 addr:$ptr, GR32:$val))]>;
Dan Gohman8aeb61f2008-05-12 20:22:45 +00003963def ATOMMAX32: I<0, Pseudo, (outs GR32:$dst),(ins i32mem:$ptr, GR32:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003964 "#ATOMMAX32 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003965 [(set GR32:$dst, (atomic_load_max_32 addr:$ptr, GR32:$val))]>;
Dan Gohman8aeb61f2008-05-12 20:22:45 +00003966def ATOMUMIN32: I<0, Pseudo, (outs GR32:$dst),(ins i32mem:$ptr, GR32:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003967 "#ATOMUMIN32 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003968 [(set GR32:$dst, (atomic_load_umin_32 addr:$ptr, GR32:$val))]>;
Dan Gohman8aeb61f2008-05-12 20:22:45 +00003969def ATOMUMAX32: I<0, Pseudo, (outs GR32:$dst),(ins i32mem:$ptr, GR32:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003970 "#ATOMUMAX32 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003971 [(set GR32:$dst, (atomic_load_umax_32 addr:$ptr, GR32:$val))]>;
Dale Johannesend20e4452008-08-19 18:47:28 +00003972
3973def ATOMAND16 : I<0, Pseudo, (outs GR16:$dst),(ins i16mem:$ptr, GR16:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003974 "#ATOMAND16 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003975 [(set GR16:$dst, (atomic_load_and_16 addr:$ptr, GR16:$val))]>;
Dale Johannesend20e4452008-08-19 18:47:28 +00003976def ATOMOR16 : I<0, Pseudo, (outs GR16:$dst),(ins i16mem:$ptr, GR16:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003977 "#ATOMOR16 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003978 [(set GR16:$dst, (atomic_load_or_16 addr:$ptr, GR16:$val))]>;
Dale Johannesend20e4452008-08-19 18:47:28 +00003979def ATOMXOR16 : I<0, Pseudo,(outs GR16:$dst),(ins i16mem:$ptr, GR16:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003980 "#ATOMXOR16 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003981 [(set GR16:$dst, (atomic_load_xor_16 addr:$ptr, GR16:$val))]>;
Dale Johannesend20e4452008-08-19 18:47:28 +00003982def ATOMNAND16 : I<0, Pseudo,(outs GR16:$dst),(ins i16mem:$ptr, GR16:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003983 "#ATOMNAND16 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003984 [(set GR16:$dst, (atomic_load_nand_16 addr:$ptr, GR16:$val))]>;
Dale Johannesend20e4452008-08-19 18:47:28 +00003985def ATOMMIN16: I<0, Pseudo, (outs GR16:$dst), (ins i16mem:$ptr, GR16:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003986 "#ATOMMIN16 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003987 [(set GR16:$dst, (atomic_load_min_16 addr:$ptr, GR16:$val))]>;
Dale Johannesend20e4452008-08-19 18:47:28 +00003988def ATOMMAX16: I<0, Pseudo, (outs GR16:$dst),(ins i16mem:$ptr, GR16:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003989 "#ATOMMAX16 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003990 [(set GR16:$dst, (atomic_load_max_16 addr:$ptr, GR16:$val))]>;
Dale Johannesend20e4452008-08-19 18:47:28 +00003991def ATOMUMIN16: I<0, Pseudo, (outs GR16:$dst),(ins i16mem:$ptr, GR16:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003992 "#ATOMUMIN16 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003993 [(set GR16:$dst, (atomic_load_umin_16 addr:$ptr, GR16:$val))]>;
Dale Johannesend20e4452008-08-19 18:47:28 +00003994def ATOMUMAX16: I<0, Pseudo, (outs GR16:$dst),(ins i16mem:$ptr, GR16:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003995 "#ATOMUMAX16 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003996 [(set GR16:$dst, (atomic_load_umax_16 addr:$ptr, GR16:$val))]>;
Dale Johannesend20e4452008-08-19 18:47:28 +00003997
3998def ATOMAND8 : I<0, Pseudo, (outs GR8:$dst),(ins i8mem:$ptr, GR8:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003999 "#ATOMAND8 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00004000 [(set GR8:$dst, (atomic_load_and_8 addr:$ptr, GR8:$val))]>;
Dale Johannesend20e4452008-08-19 18:47:28 +00004001def ATOMOR8 : I<0, Pseudo, (outs GR8:$dst),(ins i8mem:$ptr, GR8:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00004002 "#ATOMOR8 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00004003 [(set GR8:$dst, (atomic_load_or_8 addr:$ptr, GR8:$val))]>;
Dale Johannesend20e4452008-08-19 18:47:28 +00004004def ATOMXOR8 : I<0, Pseudo,(outs GR8:$dst),(ins i8mem:$ptr, GR8:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00004005 "#ATOMXOR8 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00004006 [(set GR8:$dst, (atomic_load_xor_8 addr:$ptr, GR8:$val))]>;
Dale Johannesend20e4452008-08-19 18:47:28 +00004007def ATOMNAND8 : I<0, Pseudo,(outs GR8:$dst),(ins i8mem:$ptr, GR8:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00004008 "#ATOMNAND8 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00004009 [(set GR8:$dst, (atomic_load_nand_8 addr:$ptr, GR8:$val))]>;
Mon P Wang078a62d2008-05-05 19:05:59 +00004010}
4011
Dale Johannesenf160d802008-10-02 18:53:47 +00004012let Constraints = "$val1 = $dst1, $val2 = $dst2",
4013 Defs = [EFLAGS, EAX, EBX, ECX, EDX],
4014 Uses = [EAX, EBX, ECX, EDX],
Dale Johannesen44eb5372008-10-03 19:41:08 +00004015 mayLoad = 1, mayStore = 1,
Dan Gohman30afe012009-10-29 18:10:34 +00004016 usesCustomInserter = 1 in {
Dale Johannesenf160d802008-10-02 18:53:47 +00004017def ATOMAND6432 : I<0, Pseudo, (outs GR32:$dst1, GR32:$dst2),
4018 (ins i64mem:$ptr, GR32:$val1, GR32:$val2),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00004019 "#ATOMAND6432 PSEUDO!", []>;
Dale Johannesenf160d802008-10-02 18:53:47 +00004020def ATOMOR6432 : I<0, Pseudo, (outs GR32:$dst1, GR32:$dst2),
4021 (ins i64mem:$ptr, GR32:$val1, GR32:$val2),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00004022 "#ATOMOR6432 PSEUDO!", []>;
Dale Johannesenf160d802008-10-02 18:53:47 +00004023def ATOMXOR6432 : I<0, Pseudo, (outs GR32:$dst1, GR32:$dst2),
4024 (ins i64mem:$ptr, GR32:$val1, GR32:$val2),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00004025 "#ATOMXOR6432 PSEUDO!", []>;
Dale Johannesenf160d802008-10-02 18:53:47 +00004026def ATOMNAND6432 : I<0, Pseudo, (outs GR32:$dst1, GR32:$dst2),
4027 (ins i64mem:$ptr, GR32:$val1, GR32:$val2),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00004028 "#ATOMNAND6432 PSEUDO!", []>;
Dale Johannesenf160d802008-10-02 18:53:47 +00004029def ATOMADD6432 : I<0, Pseudo, (outs GR32:$dst1, GR32:$dst2),
4030 (ins i64mem:$ptr, GR32:$val1, GR32:$val2),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00004031 "#ATOMADD6432 PSEUDO!", []>;
Dale Johannesenf160d802008-10-02 18:53:47 +00004032def ATOMSUB6432 : I<0, Pseudo, (outs GR32:$dst1, GR32:$dst2),
4033 (ins i64mem:$ptr, GR32:$val1, GR32:$val2),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00004034 "#ATOMSUB6432 PSEUDO!", []>;
Dale Johannesen51c58ee2008-10-03 22:25:52 +00004035def ATOMSWAP6432 : I<0, Pseudo, (outs GR32:$dst1, GR32:$dst2),
4036 (ins i64mem:$ptr, GR32:$val1, GR32:$val2),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00004037 "#ATOMSWAP6432 PSEUDO!", []>;
Dale Johannesenf160d802008-10-02 18:53:47 +00004038}
4039
Sean Callanan2eddf5d2009-09-16 21:55:34 +00004040// Segmentation support instructions.
4041
4042def LAR16rm : I<0x02, MRMSrcMem, (outs GR16:$dst), (ins i16mem:$src),
4043 "lar{w}\t{$src, $dst|$dst, $src}", []>, TB, OpSize;
4044def LAR16rr : I<0x02, MRMSrcReg, (outs GR16:$dst), (ins GR16:$src),
4045 "lar{w}\t{$src, $dst|$dst, $src}", []>, TB, OpSize;
4046
4047// i16mem operand in LAR32rm and GR32 operand in LAR32rr is not a typo.
4048def LAR32rm : I<0x02, MRMSrcMem, (outs GR32:$dst), (ins i16mem:$src),
4049 "lar{l}\t{$src, $dst|$dst, $src}", []>, TB;
4050def LAR32rr : I<0x02, MRMSrcReg, (outs GR32:$dst), (ins GR32:$src),
4051 "lar{l}\t{$src, $dst|$dst, $src}", []>, TB;
Sean Callanan2c48df22009-12-18 00:01:26 +00004052
4053def LSL16rm : I<0x03, MRMSrcMem, (outs GR16:$dst), (ins i16mem:$src),
4054 "lsl{w}\t{$src, $dst|$dst, $src}", []>, TB, OpSize;
4055def LSL16rr : I<0x03, MRMSrcReg, (outs GR16:$dst), (ins GR16:$src),
4056 "lsl{w}\t{$src, $dst|$dst, $src}", []>, TB, OpSize;
4057def LSL32rm : I<0x03, MRMSrcMem, (outs GR32:$dst), (ins i32mem:$src),
4058 "lsl{l}\t{$src, $dst|$dst, $src}", []>, TB;
4059def LSL32rr : I<0x03, MRMSrcReg, (outs GR32:$dst), (ins GR32:$src),
4060 "lsl{l}\t{$src, $dst|$dst, $src}", []>, TB;
4061
4062def INVLPG : I<0x01, RawFrm, (outs), (ins), "invlpg", []>, TB;
4063
4064def STRr : I<0x00, MRM1r, (outs GR16:$dst), (ins),
4065 "str{w}\t{$dst}", []>, TB;
4066def STRm : I<0x00, MRM1m, (outs i16mem:$dst), (ins),
4067 "str{w}\t{$dst}", []>, TB;
4068def LTRr : I<0x00, MRM3r, (outs), (ins GR16:$src),
4069 "ltr{w}\t{$src}", []>, TB;
4070def LTRm : I<0x00, MRM3m, (outs), (ins i16mem:$src),
4071 "ltr{w}\t{$src}", []>, TB;
4072
4073def PUSHFS16 : I<0xa0, RawFrm, (outs), (ins),
4074 "push{w}\t%fs", []>, OpSize, TB;
4075def PUSHFS32 : I<0xa0, RawFrm, (outs), (ins),
4076 "push{l}\t%fs", []>, TB;
4077def PUSHGS16 : I<0xa8, RawFrm, (outs), (ins),
4078 "push{w}\t%gs", []>, OpSize, TB;
4079def PUSHGS32 : I<0xa8, RawFrm, (outs), (ins),
4080 "push{l}\t%gs", []>, TB;
4081
4082def POPFS16 : I<0xa1, RawFrm, (outs), (ins),
4083 "pop{w}\t%fs", []>, OpSize, TB;
4084def POPFS32 : I<0xa1, RawFrm, (outs), (ins),
4085 "pop{l}\t%fs", []>, TB;
4086def POPGS16 : I<0xa9, RawFrm, (outs), (ins),
4087 "pop{w}\t%gs", []>, OpSize, TB;
4088def POPGS32 : I<0xa9, RawFrm, (outs), (ins),
4089 "pop{l}\t%gs", []>, TB;
4090
4091def LDS16rm : I<0xc5, MRMSrcMem, (outs GR16:$dst), (ins opaque32mem:$src),
4092 "lds{w}\t{$src, $dst|$dst, $src}", []>, OpSize;
4093def LDS32rm : I<0xc5, MRMSrcMem, (outs GR32:$dst), (ins opaque48mem:$src),
4094 "lds{l}\t{$src, $dst|$dst, $src}", []>;
4095def LSS16rm : I<0xb2, MRMSrcMem, (outs GR16:$dst), (ins opaque32mem:$src),
4096 "lss{w}\t{$src, $dst|$dst, $src}", []>, TB, OpSize;
4097def LSS32rm : I<0xb2, MRMSrcMem, (outs GR32:$dst), (ins opaque48mem:$src),
4098 "lss{l}\t{$src, $dst|$dst, $src}", []>, TB;
4099def LES16rm : I<0xc4, MRMSrcMem, (outs GR16:$dst), (ins opaque32mem:$src),
4100 "les{w}\t{$src, $dst|$dst, $src}", []>, OpSize;
4101def LES32rm : I<0xc4, MRMSrcMem, (outs GR32:$dst), (ins opaque48mem:$src),
4102 "les{l}\t{$src, $dst|$dst, $src}", []>;
4103def LFS16rm : I<0xb4, MRMSrcMem, (outs GR16:$dst), (ins opaque32mem:$src),
4104 "lfs{w}\t{$src, $dst|$dst, $src}", []>, TB, OpSize;
4105def LFS32rm : I<0xb4, MRMSrcMem, (outs GR32:$dst), (ins opaque48mem:$src),
4106 "lfs{l}\t{$src, $dst|$dst, $src}", []>, TB;
4107def LGS16rm : I<0xb5, MRMSrcMem, (outs GR16:$dst), (ins opaque32mem:$src),
4108 "lgs{w}\t{$src, $dst|$dst, $src}", []>, TB, OpSize;
4109def LGS32rm : I<0xb5, MRMSrcMem, (outs GR32:$dst), (ins opaque48mem:$src),
4110 "lgs{l}\t{$src, $dst|$dst, $src}", []>, TB;
4111
4112def VERRr : I<0x00, MRM4r, (outs), (ins GR16:$seg),
4113 "verr\t$seg", []>, TB;
4114def VERRm : I<0x00, MRM4m, (outs), (ins i16mem:$seg),
4115 "verr\t$seg", []>, TB;
4116def VERWr : I<0x00, MRM5r, (outs), (ins GR16:$seg),
4117 "verw\t$seg", []>, TB;
4118def VERWm : I<0x00, MRM5m, (outs), (ins i16mem:$seg),
4119 "verw\t$seg", []>, TB;
4120
4121// Descriptor-table support instructions
4122
4123def SGDTm : I<0x01, MRM0m, (outs opaque48mem:$dst), (ins),
4124 "sgdt\t$dst", []>, TB;
4125def SIDTm : I<0x01, MRM1m, (outs opaque48mem:$dst), (ins),
4126 "sidt\t$dst", []>, TB;
4127def SLDT16r : I<0x00, MRM0r, (outs GR16:$dst), (ins),
4128 "sldt{w}\t$dst", []>, TB;
4129def SLDT16m : I<0x00, MRM0m, (outs i16mem:$dst), (ins),
4130 "sldt{w}\t$dst", []>, TB;
4131def LGDTm : I<0x01, MRM2m, (outs), (ins opaque48mem:$src),
4132 "lgdt\t$src", []>, TB;
4133def LIDTm : I<0x01, MRM3m, (outs), (ins opaque48mem:$src),
4134 "lidt\t$src", []>, TB;
4135def LLDT16r : I<0x00, MRM2r, (outs), (ins GR16:$src),
4136 "lldt{w}\t$src", []>, TB;
4137def LLDT16m : I<0x00, MRM2m, (outs), (ins i16mem:$src),
4138 "lldt{w}\t$src", []>, TB;
Sean Callanan23f33d72009-09-16 22:59:28 +00004139
4140// String manipulation instructions
4141
4142def LODSB : I<0xAC, RawFrm, (outs), (ins), "lodsb", []>;
4143def LODSW : I<0xAD, RawFrm, (outs), (ins), "lodsw", []>, OpSize;
Sean Callanan2c48df22009-12-18 00:01:26 +00004144def LODSD : I<0xAD, RawFrm, (outs), (ins), "lods{l|d}", []>;
4145
4146def OUTSB : I<0x6E, RawFrm, (outs), (ins), "outsb", []>;
4147def OUTSW : I<0x6F, RawFrm, (outs), (ins), "outsw", []>, OpSize;
4148def OUTSD : I<0x6F, RawFrm, (outs), (ins), "outs{l|d}", []>;
4149
4150// CPU flow control instructions
4151
4152def HLT : I<0xF4, RawFrm, (outs), (ins), "hlt", []>;
4153def RSM : I<0xAA, RawFrm, (outs), (ins), "rsm", []>, TB;
4154
4155// FPU control instructions
4156
4157def FNINIT : I<0xE3, RawFrm, (outs), (ins), "fninit", []>, DB;
4158
4159// Flag instructions
4160
4161def CLC : I<0xF8, RawFrm, (outs), (ins), "clc", []>;
4162def STC : I<0xF9, RawFrm, (outs), (ins), "stc", []>;
4163def CLI : I<0xFA, RawFrm, (outs), (ins), "cli", []>;
4164def STI : I<0xFB, RawFrm, (outs), (ins), "sti", []>;
4165def CLD : I<0xFC, RawFrm, (outs), (ins), "cld", []>;
4166def STD : I<0xFD, RawFrm, (outs), (ins), "std", []>;
4167def CMC : I<0xF5, RawFrm, (outs), (ins), "cmc", []>;
4168
4169def CLTS : I<0x06, RawFrm, (outs), (ins), "clts", []>, TB;
4170
4171// Table lookup instructions
4172
4173def XLAT : I<0xD7, RawFrm, (outs), (ins), "xlatb", []>;
4174
4175// Specialized register support
4176
4177def WRMSR : I<0x30, RawFrm, (outs), (ins), "wrmsr", []>, TB;
4178def RDMSR : I<0x32, RawFrm, (outs), (ins), "rdmsr", []>, TB;
4179def RDPMC : I<0x33, RawFrm, (outs), (ins), "rdpmc", []>, TB;
4180
4181def SMSW16r : I<0x01, MRM4r, (outs GR16:$dst), (ins),
4182 "smsw{w}\t$dst", []>, OpSize, TB;
4183def SMSW32r : I<0x01, MRM4r, (outs GR32:$dst), (ins),
4184 "smsw{l}\t$dst", []>, TB;
4185// For memory operands, there is only a 16-bit form
4186def SMSW16m : I<0x01, MRM4m, (outs i16mem:$dst), (ins),
4187 "smsw{w}\t$dst", []>, TB;
4188
4189def LMSW16r : I<0x01, MRM6r, (outs), (ins GR16:$src),
4190 "lmsw{w}\t$src", []>, TB;
4191def LMSW16m : I<0x01, MRM6m, (outs), (ins i16mem:$src),
4192 "lmsw{w}\t$src", []>, TB;
4193
4194def CPUID : I<0xA2, RawFrm, (outs), (ins), "cpuid", []>, TB;
4195
4196// Cache instructions
4197
4198def INVD : I<0x08, RawFrm, (outs), (ins), "invd", []>, TB;
4199def WBINVD : I<0x09, RawFrm, (outs), (ins), "wbinvd", []>, TB;
4200
4201// VMX instructions
4202
4203// 66 0F 38 80
4204def INVEPT : I<0x38, RawFrm, (outs), (ins), "invept", []>, OpSize, TB;
4205// 66 0F 38 81
4206def INVVPID : I<0x38, RawFrm, (outs), (ins), "invvpid", []>, OpSize, TB;
4207// 0F 01 C1
4208def VMCALL : I<0x01, RawFrm, (outs), (ins), "vmcall", []>, TB;
4209def VMCLEARm : I<0xC7, MRM6m, (outs), (ins i64mem:$vmcs),
4210 "vmclear\t$vmcs", []>, OpSize, TB;
4211// 0F 01 C2
4212def VMLAUNCH : I<0x01, RawFrm, (outs), (ins), "vmlaunch", []>, TB;
4213// 0F 01 C3
4214def VMRESUME : I<0x01, RawFrm, (outs), (ins), "vmresume", []>, TB;
4215def VMPTRLDm : I<0xC7, MRM6m, (outs), (ins i64mem:$vmcs),
4216 "vmptrld\t$vmcs", []>, TB;
4217def VMPTRSTm : I<0xC7, MRM7m, (outs i64mem:$vmcs), (ins),
4218 "vmptrst\t$vmcs", []>, TB;
4219def VMREAD64rm : I<0x78, MRMDestMem, (outs i64mem:$dst), (ins GR64:$src),
4220 "vmread{q}\t{$src, $dst|$dst, $src}", []>, TB;
4221def VMREAD64rr : I<0x78, MRMDestReg, (outs GR64:$dst), (ins GR64:$src),
4222 "vmread{q}\t{$src, $dst|$dst, $src}", []>, TB;
4223def VMREAD32rm : I<0x78, MRMDestMem, (outs i32mem:$dst), (ins GR32:$src),
4224 "vmread{l}\t{$src, $dst|$dst, $src}", []>, TB;
4225def VMREAD32rr : I<0x78, MRMDestReg, (outs GR32:$dst), (ins GR32:$src),
4226 "vmread{l}\t{$src, $dst|$dst, $src}", []>, TB;
4227def VMWRITE64rm : I<0x79, MRMSrcMem, (outs GR64:$dst), (ins i64mem:$src),
4228 "vmwrite{q}\t{$src, $dst|$dst, $src}", []>, TB;
4229def VMWRITE64rr : I<0x79, MRMSrcReg, (outs GR64:$dst), (ins GR64:$src),
4230 "vmwrite{q}\t{$src, $dst|$dst, $src}", []>, TB;
4231def VMWRITE32rm : I<0x79, MRMSrcMem, (outs GR32:$dst), (ins i32mem:$src),
4232 "vmwrite{l}\t{$src, $dst|$dst, $src}", []>, TB;
4233def VMWRITE32rr : I<0x79, MRMSrcReg, (outs GR32:$dst), (ins GR32:$src),
4234 "vmwrite{l}\t{$src, $dst|$dst, $src}", []>, TB;
4235// 0F 01 C4
4236def VMXOFF : I<0x01, RawFrm, (outs), (ins), "vmxoff", []>, OpSize;
4237def VMXON : I<0xC7, MRM6m, (outs), (ins i64mem:$vmxon),
4238 "vmxon\t{$vmxon}", []>, XD;
Sean Callanan2eddf5d2009-09-16 21:55:34 +00004239
Andrew Lenharthe44f3902008-02-21 06:45:13 +00004240//===----------------------------------------------------------------------===//
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004241// Non-Instruction Patterns
4242//===----------------------------------------------------------------------===//
4243
Bill Wendlingfef06052008-09-16 21:48:12 +00004244// ConstantPool GlobalAddress, ExternalSymbol, and JumpTable
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004245def : Pat<(i32 (X86Wrapper tconstpool :$dst)), (MOV32ri tconstpool :$dst)>;
4246def : Pat<(i32 (X86Wrapper tjumptable :$dst)), (MOV32ri tjumptable :$dst)>;
Nate Begemanb52948972008-04-12 00:47:57 +00004247def : Pat<(i32 (X86Wrapper tglobaltlsaddr:$dst)),(MOV32ri tglobaltlsaddr:$dst)>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004248def : Pat<(i32 (X86Wrapper tglobaladdr :$dst)), (MOV32ri tglobaladdr :$dst)>;
4249def : Pat<(i32 (X86Wrapper texternalsym:$dst)), (MOV32ri texternalsym:$dst)>;
Dan Gohman064403e2009-10-30 01:28:02 +00004250def : Pat<(i32 (X86Wrapper tblockaddress:$dst)), (MOV32ri tblockaddress:$dst)>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004251
4252def : Pat<(add GR32:$src1, (X86Wrapper tconstpool:$src2)),
4253 (ADD32ri GR32:$src1, tconstpool:$src2)>;
4254def : Pat<(add GR32:$src1, (X86Wrapper tjumptable:$src2)),
4255 (ADD32ri GR32:$src1, tjumptable:$src2)>;
4256def : Pat<(add GR32:$src1, (X86Wrapper tglobaladdr :$src2)),
4257 (ADD32ri GR32:$src1, tglobaladdr:$src2)>;
4258def : Pat<(add GR32:$src1, (X86Wrapper texternalsym:$src2)),
4259 (ADD32ri GR32:$src1, texternalsym:$src2)>;
Dan Gohman064403e2009-10-30 01:28:02 +00004260def : Pat<(add GR32:$src1, (X86Wrapper tblockaddress:$src2)),
4261 (ADD32ri GR32:$src1, tblockaddress:$src2)>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004262
4263def : Pat<(store (i32 (X86Wrapper tglobaladdr:$src)), addr:$dst),
4264 (MOV32mi addr:$dst, tglobaladdr:$src)>;
4265def : Pat<(store (i32 (X86Wrapper texternalsym:$src)), addr:$dst),
4266 (MOV32mi addr:$dst, texternalsym:$src)>;
Dan Gohman064403e2009-10-30 01:28:02 +00004267def : Pat<(store (i32 (X86Wrapper tblockaddress:$src)), addr:$dst),
4268 (MOV32mi addr:$dst, tblockaddress:$src)>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004269
4270// Calls
Arnold Schwaighofere2d6bbb2007-10-11 19:40:01 +00004271// tailcall stuff
Arnold Schwaighofere2d6bbb2007-10-11 19:40:01 +00004272def : Pat<(X86tcret GR32:$dst, imm:$off),
4273 (TCRETURNri GR32:$dst, imm:$off)>;
4274
4275def : Pat<(X86tcret (i32 tglobaladdr:$dst), imm:$off),
4276 (TCRETURNdi texternalsym:$dst, imm:$off)>;
4277
4278def : Pat<(X86tcret (i32 texternalsym:$dst), imm:$off),
4279 (TCRETURNdi texternalsym:$dst, imm:$off)>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004280
Dan Gohmance5dbff2009-08-02 16:10:01 +00004281// Normal calls, with various flavors of addresses.
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004282def : Pat<(X86call (i32 tglobaladdr:$dst)),
4283 (CALLpcrel32 tglobaladdr:$dst)>;
4284def : Pat<(X86call (i32 texternalsym:$dst)),
4285 (CALLpcrel32 texternalsym:$dst)>;
Evan Cheng6d35a4d2009-05-20 04:53:57 +00004286def : Pat<(X86call (i32 imm:$dst)),
4287 (CALLpcrel32 imm:$dst)>, Requires<[CallImmAddr]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004288
4289// X86 specific add which produces a flag.
4290def : Pat<(addc GR32:$src1, GR32:$src2),
4291 (ADD32rr GR32:$src1, GR32:$src2)>;
4292def : Pat<(addc GR32:$src1, (load addr:$src2)),
4293 (ADD32rm GR32:$src1, addr:$src2)>;
4294def : Pat<(addc GR32:$src1, imm:$src2),
4295 (ADD32ri GR32:$src1, imm:$src2)>;
4296def : Pat<(addc GR32:$src1, i32immSExt8:$src2),
4297 (ADD32ri8 GR32:$src1, i32immSExt8:$src2)>;
4298
4299def : Pat<(subc GR32:$src1, GR32:$src2),
4300 (SUB32rr GR32:$src1, GR32:$src2)>;
4301def : Pat<(subc GR32:$src1, (load addr:$src2)),
4302 (SUB32rm GR32:$src1, addr:$src2)>;
4303def : Pat<(subc GR32:$src1, imm:$src2),
4304 (SUB32ri GR32:$src1, imm:$src2)>;
4305def : Pat<(subc GR32:$src1, i32immSExt8:$src2),
4306 (SUB32ri8 GR32:$src1, i32immSExt8:$src2)>;
4307
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004308// Comparisons.
4309
4310// TEST R,R is smaller than CMP R,0
Evan Cheng621216e2007-09-29 00:00:36 +00004311def : Pat<(parallel (X86cmp GR8:$src1, 0), (implicit EFLAGS)),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004312 (TEST8rr GR8:$src1, GR8:$src1)>;
Evan Cheng621216e2007-09-29 00:00:36 +00004313def : Pat<(parallel (X86cmp GR16:$src1, 0), (implicit EFLAGS)),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004314 (TEST16rr GR16:$src1, GR16:$src1)>;
Evan Cheng621216e2007-09-29 00:00:36 +00004315def : Pat<(parallel (X86cmp GR32:$src1, 0), (implicit EFLAGS)),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004316 (TEST32rr GR32:$src1, GR32:$src1)>;
4317
Dan Gohman0a3c5222009-01-07 01:00:24 +00004318// Conditional moves with folded loads with operands swapped and conditions
4319// inverted.
4320def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_B, EFLAGS),
4321 (CMOVAE16rm GR16:$src2, addr:$src1)>;
4322def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_B, EFLAGS),
4323 (CMOVAE32rm GR32:$src2, addr:$src1)>;
4324def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_AE, EFLAGS),
4325 (CMOVB16rm GR16:$src2, addr:$src1)>;
4326def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_AE, EFLAGS),
4327 (CMOVB32rm GR32:$src2, addr:$src1)>;
4328def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_E, EFLAGS),
4329 (CMOVNE16rm GR16:$src2, addr:$src1)>;
4330def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_E, EFLAGS),
4331 (CMOVNE32rm GR32:$src2, addr:$src1)>;
4332def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_NE, EFLAGS),
4333 (CMOVE16rm GR16:$src2, addr:$src1)>;
4334def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_NE, EFLAGS),
4335 (CMOVE32rm GR32:$src2, addr:$src1)>;
4336def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_BE, EFLAGS),
4337 (CMOVA16rm GR16:$src2, addr:$src1)>;
4338def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_BE, EFLAGS),
4339 (CMOVA32rm GR32:$src2, addr:$src1)>;
4340def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_A, EFLAGS),
4341 (CMOVBE16rm GR16:$src2, addr:$src1)>;
4342def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_A, EFLAGS),
4343 (CMOVBE32rm GR32:$src2, addr:$src1)>;
4344def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_L, EFLAGS),
4345 (CMOVGE16rm GR16:$src2, addr:$src1)>;
4346def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_L, EFLAGS),
4347 (CMOVGE32rm GR32:$src2, addr:$src1)>;
4348def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_GE, EFLAGS),
4349 (CMOVL16rm GR16:$src2, addr:$src1)>;
4350def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_GE, EFLAGS),
4351 (CMOVL32rm GR32:$src2, addr:$src1)>;
4352def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_LE, EFLAGS),
4353 (CMOVG16rm GR16:$src2, addr:$src1)>;
4354def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_LE, EFLAGS),
4355 (CMOVG32rm GR32:$src2, addr:$src1)>;
4356def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_G, EFLAGS),
4357 (CMOVLE16rm GR16:$src2, addr:$src1)>;
4358def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_G, EFLAGS),
4359 (CMOVLE32rm GR32:$src2, addr:$src1)>;
4360def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_P, EFLAGS),
4361 (CMOVNP16rm GR16:$src2, addr:$src1)>;
4362def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_P, EFLAGS),
4363 (CMOVNP32rm GR32:$src2, addr:$src1)>;
4364def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_NP, EFLAGS),
4365 (CMOVP16rm GR16:$src2, addr:$src1)>;
4366def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_NP, EFLAGS),
4367 (CMOVP32rm GR32:$src2, addr:$src1)>;
4368def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_S, EFLAGS),
4369 (CMOVNS16rm GR16:$src2, addr:$src1)>;
4370def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_S, EFLAGS),
4371 (CMOVNS32rm GR32:$src2, addr:$src1)>;
4372def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_NS, EFLAGS),
4373 (CMOVS16rm GR16:$src2, addr:$src1)>;
4374def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_NS, EFLAGS),
4375 (CMOVS32rm GR32:$src2, addr:$src1)>;
4376def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_O, EFLAGS),
4377 (CMOVNO16rm GR16:$src2, addr:$src1)>;
4378def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_O, EFLAGS),
4379 (CMOVNO32rm GR32:$src2, addr:$src1)>;
4380def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_NO, EFLAGS),
4381 (CMOVO16rm GR16:$src2, addr:$src1)>;
4382def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_NO, EFLAGS),
4383 (CMOVO32rm GR32:$src2, addr:$src1)>;
4384
Duncan Sands082524c2008-01-23 20:39:46 +00004385// zextload bool -> zextload byte
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004386def : Pat<(zextloadi8i1 addr:$src), (MOV8rm addr:$src)>;
4387def : Pat<(zextloadi16i1 addr:$src), (MOVZX16rm8 addr:$src)>;
4388def : Pat<(zextloadi32i1 addr:$src), (MOVZX32rm8 addr:$src)>;
4389
4390// extload bool -> extload byte
4391def : Pat<(extloadi8i1 addr:$src), (MOV8rm addr:$src)>;
Dan Gohman9959b052009-08-26 14:59:13 +00004392def : Pat<(extloadi16i1 addr:$src), (MOVZX16rm8 addr:$src)>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004393def : Pat<(extloadi32i1 addr:$src), (MOVZX32rm8 addr:$src)>;
Dan Gohman9959b052009-08-26 14:59:13 +00004394def : Pat<(extloadi16i8 addr:$src), (MOVZX16rm8 addr:$src)>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004395def : Pat<(extloadi32i8 addr:$src), (MOVZX32rm8 addr:$src)>;
4396def : Pat<(extloadi32i16 addr:$src), (MOVZX32rm16 addr:$src)>;
4397
Dan Gohman9959b052009-08-26 14:59:13 +00004398// anyext. Define these to do an explicit zero-extend to
4399// avoid partial-register updates.
4400def : Pat<(i16 (anyext GR8 :$src)), (MOVZX16rr8 GR8 :$src)>;
4401def : Pat<(i32 (anyext GR8 :$src)), (MOVZX32rr8 GR8 :$src)>;
4402def : Pat<(i32 (anyext GR16:$src)), (MOVZX32rr16 GR16:$src)>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004403
Evan Chengf2abee72007-12-13 00:43:27 +00004404// (and (i32 load), 255) -> (zextload i8)
Evan Cheng1e5e5452008-09-29 17:26:18 +00004405def : Pat<(i32 (and (nvloadi32 addr:$src), (i32 255))),
4406 (MOVZX32rm8 addr:$src)>;
4407def : Pat<(i32 (and (nvloadi32 addr:$src), (i32 65535))),
4408 (MOVZX32rm16 addr:$src)>;
Evan Chengf2abee72007-12-13 00:43:27 +00004409
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004410//===----------------------------------------------------------------------===//
4411// Some peepholes
4412//===----------------------------------------------------------------------===//
4413
Dan Gohman5a5e6e92008-10-17 01:33:43 +00004414// Odd encoding trick: -128 fits into an 8-bit immediate field while
4415// +128 doesn't, so in this special case use a sub instead of an add.
4416def : Pat<(add GR16:$src1, 128),
4417 (SUB16ri8 GR16:$src1, -128)>;
4418def : Pat<(store (add (loadi16 addr:$dst), 128), addr:$dst),
4419 (SUB16mi8 addr:$dst, -128)>;
4420def : Pat<(add GR32:$src1, 128),
4421 (SUB32ri8 GR32:$src1, -128)>;
4422def : Pat<(store (add (loadi32 addr:$dst), 128), addr:$dst),
4423 (SUB32mi8 addr:$dst, -128)>;
4424
Dan Gohman9203ab42008-07-30 18:09:17 +00004425// r & (2^16-1) ==> movz
4426def : Pat<(and GR32:$src1, 0xffff),
Dan Gohman744d4622009-04-13 16:09:41 +00004427 (MOVZX32rr16 (EXTRACT_SUBREG GR32:$src1, x86_subreg_16bit))>;
Dan Gohman5beb1ff2008-08-06 18:27:21 +00004428// r & (2^8-1) ==> movz
4429def : Pat<(and GR32:$src1, 0xff),
Anton Korobeynikovd9331212009-11-02 00:11:39 +00004430 (MOVZX32rr8 (EXTRACT_SUBREG (i32 (COPY_TO_REGCLASS GR32:$src1,
4431 GR32_ABCD)),
Dan Gohman744d4622009-04-13 16:09:41 +00004432 x86_subreg_8bit))>,
Dan Gohman5beb1ff2008-08-06 18:27:21 +00004433 Requires<[In32BitMode]>;
4434// r & (2^8-1) ==> movz
4435def : Pat<(and GR16:$src1, 0xff),
Anton Korobeynikovd9331212009-11-02 00:11:39 +00004436 (MOVZX16rr8 (EXTRACT_SUBREG (i16 (COPY_TO_REGCLASS GR16:$src1,
4437 GR16_ABCD)),
Dan Gohman744d4622009-04-13 16:09:41 +00004438 x86_subreg_8bit))>,
Dan Gohmandd612bb2008-08-20 21:27:32 +00004439 Requires<[In32BitMode]>;
4440
4441// sext_inreg patterns
4442def : Pat<(sext_inreg GR32:$src, i16),
Dan Gohman744d4622009-04-13 16:09:41 +00004443 (MOVSX32rr16 (EXTRACT_SUBREG GR32:$src, x86_subreg_16bit))>;
Dan Gohmandd612bb2008-08-20 21:27:32 +00004444def : Pat<(sext_inreg GR32:$src, i8),
Anton Korobeynikovd9331212009-11-02 00:11:39 +00004445 (MOVSX32rr8 (EXTRACT_SUBREG (i32 (COPY_TO_REGCLASS GR32:$src,
4446 GR32_ABCD)),
Dan Gohman744d4622009-04-13 16:09:41 +00004447 x86_subreg_8bit))>,
Dan Gohmandd612bb2008-08-20 21:27:32 +00004448 Requires<[In32BitMode]>;
4449def : Pat<(sext_inreg GR16:$src, i8),
Anton Korobeynikovd9331212009-11-02 00:11:39 +00004450 (MOVSX16rr8 (EXTRACT_SUBREG (i16 (COPY_TO_REGCLASS GR16:$src,
4451 GR16_ABCD)),
Dan Gohman744d4622009-04-13 16:09:41 +00004452 x86_subreg_8bit))>,
Dan Gohmandd612bb2008-08-20 21:27:32 +00004453 Requires<[In32BitMode]>;
4454
4455// trunc patterns
4456def : Pat<(i16 (trunc GR32:$src)),
Dan Gohman744d4622009-04-13 16:09:41 +00004457 (EXTRACT_SUBREG GR32:$src, x86_subreg_16bit)>;
Dan Gohmandd612bb2008-08-20 21:27:32 +00004458def : Pat<(i8 (trunc GR32:$src)),
Anton Korobeynikovd9331212009-11-02 00:11:39 +00004459 (EXTRACT_SUBREG (i32 (COPY_TO_REGCLASS GR32:$src, GR32_ABCD)),
Dan Gohman744d4622009-04-13 16:09:41 +00004460 x86_subreg_8bit)>,
Dan Gohmandd612bb2008-08-20 21:27:32 +00004461 Requires<[In32BitMode]>;
4462def : Pat<(i8 (trunc GR16:$src)),
Anton Korobeynikovd9331212009-11-02 00:11:39 +00004463 (EXTRACT_SUBREG (i16 (COPY_TO_REGCLASS GR16:$src, GR16_ABCD)),
Dan Gohman744d4622009-04-13 16:09:41 +00004464 x86_subreg_8bit)>,
4465 Requires<[In32BitMode]>;
4466
4467// h-register tricks
4468def : Pat<(i8 (trunc (srl_su GR16:$src, (i8 8)))),
Anton Korobeynikovd9331212009-11-02 00:11:39 +00004469 (EXTRACT_SUBREG (i32 (COPY_TO_REGCLASS GR16:$src, GR16_ABCD)),
Dan Gohman744d4622009-04-13 16:09:41 +00004470 x86_subreg_8bit_hi)>,
4471 Requires<[In32BitMode]>;
4472def : Pat<(i8 (trunc (srl_su GR32:$src, (i8 8)))),
Anton Korobeynikovd9331212009-11-02 00:11:39 +00004473 (EXTRACT_SUBREG (i16 (COPY_TO_REGCLASS GR32:$src, GR32_ABCD)),
Dan Gohman744d4622009-04-13 16:09:41 +00004474 x86_subreg_8bit_hi)>,
4475 Requires<[In32BitMode]>;
4476def : Pat<(srl_su GR16:$src, (i8 8)),
4477 (EXTRACT_SUBREG
4478 (MOVZX32rr8
Anton Korobeynikovd9331212009-11-02 00:11:39 +00004479 (EXTRACT_SUBREG (i16 (COPY_TO_REGCLASS GR16:$src, GR16_ABCD)),
Dan Gohman744d4622009-04-13 16:09:41 +00004480 x86_subreg_8bit_hi)),
4481 x86_subreg_16bit)>,
4482 Requires<[In32BitMode]>;
Evan Cheng957ca282009-05-29 01:44:43 +00004483def : Pat<(i32 (zext (srl_su GR16:$src, (i8 8)))),
Sean Callanan2c48df22009-12-18 00:01:26 +00004484 (MOVZX32rr8 (EXTRACT_SUBREG (i16 (COPY_TO_REGCLASS GR16:$src,
4485 GR16_ABCD)),
Evan Cheng957ca282009-05-29 01:44:43 +00004486 x86_subreg_8bit_hi))>,
4487 Requires<[In32BitMode]>;
Dan Gohman9959b052009-08-26 14:59:13 +00004488def : Pat<(i32 (anyext (srl_su GR16:$src, (i8 8)))),
Sean Callanan2c48df22009-12-18 00:01:26 +00004489 (MOVZX32rr8 (EXTRACT_SUBREG (i16 (COPY_TO_REGCLASS GR16:$src,
4490 GR16_ABCD)),
Dan Gohman9959b052009-08-26 14:59:13 +00004491 x86_subreg_8bit_hi))>,
4492 Requires<[In32BitMode]>;
Dan Gohman744d4622009-04-13 16:09:41 +00004493def : Pat<(and (srl_su GR32:$src, (i8 8)), (i32 255)),
Sean Callanan2c48df22009-12-18 00:01:26 +00004494 (MOVZX32rr8 (EXTRACT_SUBREG (i32 (COPY_TO_REGCLASS GR32:$src,
4495 GR32_ABCD)),
Dan Gohman744d4622009-04-13 16:09:41 +00004496 x86_subreg_8bit_hi))>,
Dan Gohman5beb1ff2008-08-06 18:27:21 +00004497 Requires<[In32BitMode]>;
Dan Gohman9203ab42008-07-30 18:09:17 +00004498
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004499// (shl x, 1) ==> (add x, x)
4500def : Pat<(shl GR8 :$src1, (i8 1)), (ADD8rr GR8 :$src1, GR8 :$src1)>;
4501def : Pat<(shl GR16:$src1, (i8 1)), (ADD16rr GR16:$src1, GR16:$src1)>;
4502def : Pat<(shl GR32:$src1, (i8 1)), (ADD32rr GR32:$src1, GR32:$src1)>;
4503
Evan Cheng76a64c72008-08-30 02:03:58 +00004504// (shl x (and y, 31)) ==> (shl x, y)
4505def : Pat<(shl GR8:$src1, (and CL:$amt, 31)),
4506 (SHL8rCL GR8:$src1)>;
4507def : Pat<(shl GR16:$src1, (and CL:$amt, 31)),
4508 (SHL16rCL GR16:$src1)>;
4509def : Pat<(shl GR32:$src1, (and CL:$amt, 31)),
4510 (SHL32rCL GR32:$src1)>;
4511def : Pat<(store (shl (loadi8 addr:$dst), (and CL:$amt, 31)), addr:$dst),
4512 (SHL8mCL addr:$dst)>;
4513def : Pat<(store (shl (loadi16 addr:$dst), (and CL:$amt, 31)), addr:$dst),
4514 (SHL16mCL addr:$dst)>;
4515def : Pat<(store (shl (loadi32 addr:$dst), (and CL:$amt, 31)), addr:$dst),
4516 (SHL32mCL addr:$dst)>;
4517
4518def : Pat<(srl GR8:$src1, (and CL:$amt, 31)),
4519 (SHR8rCL GR8:$src1)>;
4520def : Pat<(srl GR16:$src1, (and CL:$amt, 31)),
4521 (SHR16rCL GR16:$src1)>;
4522def : Pat<(srl GR32:$src1, (and CL:$amt, 31)),
4523 (SHR32rCL GR32:$src1)>;
4524def : Pat<(store (srl (loadi8 addr:$dst), (and CL:$amt, 31)), addr:$dst),
4525 (SHR8mCL addr:$dst)>;
4526def : Pat<(store (srl (loadi16 addr:$dst), (and CL:$amt, 31)), addr:$dst),
4527 (SHR16mCL addr:$dst)>;
4528def : Pat<(store (srl (loadi32 addr:$dst), (and CL:$amt, 31)), addr:$dst),
4529 (SHR32mCL addr:$dst)>;
4530
4531def : Pat<(sra GR8:$src1, (and CL:$amt, 31)),
4532 (SAR8rCL GR8:$src1)>;
4533def : Pat<(sra GR16:$src1, (and CL:$amt, 31)),
4534 (SAR16rCL GR16:$src1)>;
4535def : Pat<(sra GR32:$src1, (and CL:$amt, 31)),
4536 (SAR32rCL GR32:$src1)>;
4537def : Pat<(store (sra (loadi8 addr:$dst), (and CL:$amt, 31)), addr:$dst),
4538 (SAR8mCL addr:$dst)>;
4539def : Pat<(store (sra (loadi16 addr:$dst), (and CL:$amt, 31)), addr:$dst),
4540 (SAR16mCL addr:$dst)>;
4541def : Pat<(store (sra (loadi32 addr:$dst), (and CL:$amt, 31)), addr:$dst),
4542 (SAR32mCL addr:$dst)>;
4543
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004544// (or (x >> c) | (y << (32 - c))) ==> (shrd32 x, y, c)
4545def : Pat<(or (srl GR32:$src1, CL:$amt),
4546 (shl GR32:$src2, (sub 32, CL:$amt))),
4547 (SHRD32rrCL GR32:$src1, GR32:$src2)>;
4548
4549def : Pat<(store (or (srl (loadi32 addr:$dst), CL:$amt),
4550 (shl GR32:$src2, (sub 32, CL:$amt))), addr:$dst),
4551 (SHRD32mrCL addr:$dst, GR32:$src2)>;
4552
Dan Gohman921581d2008-10-17 01:23:35 +00004553def : Pat<(or (srl GR32:$src1, (i8 (trunc ECX:$amt))),
4554 (shl GR32:$src2, (i8 (trunc (sub 32, ECX:$amt))))),
4555 (SHRD32rrCL GR32:$src1, GR32:$src2)>;
4556
4557def : Pat<(store (or (srl (loadi32 addr:$dst), (i8 (trunc ECX:$amt))),
4558 (shl GR32:$src2, (i8 (trunc (sub 32, ECX:$amt))))),
4559 addr:$dst),
4560 (SHRD32mrCL addr:$dst, GR32:$src2)>;
4561
4562def : Pat<(shrd GR32:$src1, (i8 imm:$amt1), GR32:$src2, (i8 imm:$amt2)),
4563 (SHRD32rri8 GR32:$src1, GR32:$src2, (i8 imm:$amt1))>;
4564
4565def : Pat<(store (shrd (loadi32 addr:$dst), (i8 imm:$amt1),
4566 GR32:$src2, (i8 imm:$amt2)), addr:$dst),
4567 (SHRD32mri8 addr:$dst, GR32:$src2, (i8 imm:$amt1))>;
4568
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004569// (or (x << c) | (y >> (32 - c))) ==> (shld32 x, y, c)
4570def : Pat<(or (shl GR32:$src1, CL:$amt),
4571 (srl GR32:$src2, (sub 32, CL:$amt))),
4572 (SHLD32rrCL GR32:$src1, GR32:$src2)>;
4573
4574def : Pat<(store (or (shl (loadi32 addr:$dst), CL:$amt),
4575 (srl GR32:$src2, (sub 32, CL:$amt))), addr:$dst),
4576 (SHLD32mrCL addr:$dst, GR32:$src2)>;
4577
Dan Gohman921581d2008-10-17 01:23:35 +00004578def : Pat<(or (shl GR32:$src1, (i8 (trunc ECX:$amt))),
4579 (srl GR32:$src2, (i8 (trunc (sub 32, ECX:$amt))))),
4580 (SHLD32rrCL GR32:$src1, GR32:$src2)>;
4581
4582def : Pat<(store (or (shl (loadi32 addr:$dst), (i8 (trunc ECX:$amt))),
4583 (srl GR32:$src2, (i8 (trunc (sub 32, ECX:$amt))))),
4584 addr:$dst),
4585 (SHLD32mrCL addr:$dst, GR32:$src2)>;
4586
4587def : Pat<(shld GR32:$src1, (i8 imm:$amt1), GR32:$src2, (i8 imm:$amt2)),
4588 (SHLD32rri8 GR32:$src1, GR32:$src2, (i8 imm:$amt1))>;
4589
4590def : Pat<(store (shld (loadi32 addr:$dst), (i8 imm:$amt1),
4591 GR32:$src2, (i8 imm:$amt2)), addr:$dst),
4592 (SHLD32mri8 addr:$dst, GR32:$src2, (i8 imm:$amt1))>;
4593
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004594// (or (x >> c) | (y << (16 - c))) ==> (shrd16 x, y, c)
4595def : Pat<(or (srl GR16:$src1, CL:$amt),
4596 (shl GR16:$src2, (sub 16, CL:$amt))),
4597 (SHRD16rrCL GR16:$src1, GR16:$src2)>;
4598
4599def : Pat<(store (or (srl (loadi16 addr:$dst), CL:$amt),
4600 (shl GR16:$src2, (sub 16, CL:$amt))), addr:$dst),
4601 (SHRD16mrCL addr:$dst, GR16:$src2)>;
4602
Dan Gohman921581d2008-10-17 01:23:35 +00004603def : Pat<(or (srl GR16:$src1, (i8 (trunc CX:$amt))),
4604 (shl GR16:$src2, (i8 (trunc (sub 16, CX:$amt))))),
4605 (SHRD16rrCL GR16:$src1, GR16:$src2)>;
4606
4607def : Pat<(store (or (srl (loadi16 addr:$dst), (i8 (trunc CX:$amt))),
4608 (shl GR16:$src2, (i8 (trunc (sub 16, CX:$amt))))),
4609 addr:$dst),
4610 (SHRD16mrCL addr:$dst, GR16:$src2)>;
4611
4612def : Pat<(shrd GR16:$src1, (i8 imm:$amt1), GR16:$src2, (i8 imm:$amt2)),
4613 (SHRD16rri8 GR16:$src1, GR16:$src2, (i8 imm:$amt1))>;
4614
4615def : Pat<(store (shrd (loadi16 addr:$dst), (i8 imm:$amt1),
4616 GR16:$src2, (i8 imm:$amt2)), addr:$dst),
4617 (SHRD16mri8 addr:$dst, GR16:$src2, (i8 imm:$amt1))>;
4618
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004619// (or (x << c) | (y >> (16 - c))) ==> (shld16 x, y, c)
4620def : Pat<(or (shl GR16:$src1, CL:$amt),
4621 (srl GR16:$src2, (sub 16, CL:$amt))),
4622 (SHLD16rrCL GR16:$src1, GR16:$src2)>;
4623
4624def : Pat<(store (or (shl (loadi16 addr:$dst), CL:$amt),
4625 (srl GR16:$src2, (sub 16, CL:$amt))), addr:$dst),
4626 (SHLD16mrCL addr:$dst, GR16:$src2)>;
4627
Dan Gohman921581d2008-10-17 01:23:35 +00004628def : Pat<(or (shl GR16:$src1, (i8 (trunc CX:$amt))),
4629 (srl GR16:$src2, (i8 (trunc (sub 16, CX:$amt))))),
4630 (SHLD16rrCL GR16:$src1, GR16:$src2)>;
4631
4632def : Pat<(store (or (shl (loadi16 addr:$dst), (i8 (trunc CX:$amt))),
4633 (srl GR16:$src2, (i8 (trunc (sub 16, CX:$amt))))),
4634 addr:$dst),
4635 (SHLD16mrCL addr:$dst, GR16:$src2)>;
4636
4637def : Pat<(shld GR16:$src1, (i8 imm:$amt1), GR16:$src2, (i8 imm:$amt2)),
4638 (SHLD16rri8 GR16:$src1, GR16:$src2, (i8 imm:$amt1))>;
4639
4640def : Pat<(store (shld (loadi16 addr:$dst), (i8 imm:$amt1),
4641 GR16:$src2, (i8 imm:$amt2)), addr:$dst),
4642 (SHLD16mri8 addr:$dst, GR16:$src2, (i8 imm:$amt1))>;
4643
Evan Chengedeb1692009-12-16 00:53:11 +00004644// (anyext (setcc_carry)) -> (setcc_carry)
4645def : Pat<(i16 (anyext (i8 (X86setcc_c X86_COND_B, EFLAGS)))),
Evan Cheng834ae6b2009-12-15 00:53:42 +00004646 (SETB_C16r)>;
Evan Chengedeb1692009-12-16 00:53:11 +00004647def : Pat<(i32 (anyext (i8 (X86setcc_c X86_COND_B, EFLAGS)))),
Evan Cheng834ae6b2009-12-15 00:53:42 +00004648 (SETB_C32r)>;
4649
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004650//===----------------------------------------------------------------------===//
Dan Gohman99a12192009-03-04 19:44:21 +00004651// EFLAGS-defining Patterns
Bill Wendlingf5399032008-12-12 21:15:41 +00004652//===----------------------------------------------------------------------===//
4653
Dan Gohman99a12192009-03-04 19:44:21 +00004654// Register-Register Addition with EFLAGS result
4655def : Pat<(parallel (X86add_flag GR8:$src1, GR8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004656 (implicit EFLAGS)),
4657 (ADD8rr GR8:$src1, GR8:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00004658def : Pat<(parallel (X86add_flag GR16:$src1, GR16:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004659 (implicit EFLAGS)),
4660 (ADD16rr GR16:$src1, GR16:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00004661def : Pat<(parallel (X86add_flag GR32:$src1, GR32:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004662 (implicit EFLAGS)),
4663 (ADD32rr GR32:$src1, GR32:$src2)>;
4664
Dan Gohman99a12192009-03-04 19:44:21 +00004665// Register-Memory Addition with EFLAGS result
4666def : Pat<(parallel (X86add_flag GR8:$src1, (loadi8 addr:$src2)),
Bill Wendlingf5399032008-12-12 21:15:41 +00004667 (implicit EFLAGS)),
4668 (ADD8rm GR8:$src1, addr:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00004669def : Pat<(parallel (X86add_flag GR16:$src1, (loadi16 addr:$src2)),
Bill Wendlingf5399032008-12-12 21:15:41 +00004670 (implicit EFLAGS)),
4671 (ADD16rm GR16:$src1, addr:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00004672def : Pat<(parallel (X86add_flag GR32:$src1, (loadi32 addr:$src2)),
Bill Wendlingf5399032008-12-12 21:15:41 +00004673 (implicit EFLAGS)),
4674 (ADD32rm GR32:$src1, addr:$src2)>;
4675
Dan Gohman99a12192009-03-04 19:44:21 +00004676// Register-Integer Addition with EFLAGS result
4677def : Pat<(parallel (X86add_flag GR8:$src1, imm:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004678 (implicit EFLAGS)),
4679 (ADD8ri GR8:$src1, imm:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00004680def : Pat<(parallel (X86add_flag GR16:$src1, imm:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004681 (implicit EFLAGS)),
4682 (ADD16ri GR16:$src1, imm:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00004683def : Pat<(parallel (X86add_flag GR32:$src1, imm:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004684 (implicit EFLAGS)),
4685 (ADD32ri GR32:$src1, imm:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00004686def : Pat<(parallel (X86add_flag GR16:$src1, i16immSExt8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004687 (implicit EFLAGS)),
4688 (ADD16ri8 GR16:$src1, i16immSExt8:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00004689def : Pat<(parallel (X86add_flag GR32:$src1, i32immSExt8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004690 (implicit EFLAGS)),
4691 (ADD32ri8 GR32:$src1, i32immSExt8:$src2)>;
4692
Dan Gohman99a12192009-03-04 19:44:21 +00004693// Memory-Register Addition with EFLAGS result
4694def : Pat<(parallel (store (X86add_flag (loadi8 addr:$dst), GR8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004695 addr:$dst),
4696 (implicit EFLAGS)),
4697 (ADD8mr addr:$dst, GR8:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00004698def : Pat<(parallel (store (X86add_flag (loadi16 addr:$dst), GR16:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004699 addr:$dst),
4700 (implicit EFLAGS)),
4701 (ADD16mr addr:$dst, GR16:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00004702def : Pat<(parallel (store (X86add_flag (loadi32 addr:$dst), GR32:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004703 addr:$dst),
4704 (implicit EFLAGS)),
4705 (ADD32mr addr:$dst, GR32:$src2)>;
Dale Johannesen06b83f12009-05-18 17:44:15 +00004706
4707// Memory-Integer Addition with EFLAGS result
Dan Gohman99a12192009-03-04 19:44:21 +00004708def : Pat<(parallel (store (X86add_flag (loadi8 addr:$dst), imm:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004709 addr:$dst),
4710 (implicit EFLAGS)),
4711 (ADD8mi addr:$dst, imm:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00004712def : Pat<(parallel (store (X86add_flag (loadi16 addr:$dst), imm:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004713 addr:$dst),
4714 (implicit EFLAGS)),
4715 (ADD16mi addr:$dst, imm:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00004716def : Pat<(parallel (store (X86add_flag (loadi32 addr:$dst), imm:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004717 addr:$dst),
4718 (implicit EFLAGS)),
4719 (ADD32mi addr:$dst, imm:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00004720def : Pat<(parallel (store (X86add_flag (loadi16 addr:$dst), i16immSExt8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004721 addr:$dst),
4722 (implicit EFLAGS)),
4723 (ADD16mi8 addr:$dst, i16immSExt8:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00004724def : Pat<(parallel (store (X86add_flag (loadi32 addr:$dst), i32immSExt8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004725 addr:$dst),
4726 (implicit EFLAGS)),
4727 (ADD32mi8 addr:$dst, i32immSExt8:$src2)>;
4728
Dan Gohman99a12192009-03-04 19:44:21 +00004729// Register-Register Subtraction with EFLAGS result
4730def : Pat<(parallel (X86sub_flag GR8:$src1, GR8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004731 (implicit EFLAGS)),
4732 (SUB8rr GR8:$src1, GR8:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00004733def : Pat<(parallel (X86sub_flag GR16:$src1, GR16:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004734 (implicit EFLAGS)),
4735 (SUB16rr GR16:$src1, GR16:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00004736def : Pat<(parallel (X86sub_flag GR32:$src1, GR32:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004737 (implicit EFLAGS)),
4738 (SUB32rr GR32:$src1, GR32:$src2)>;
4739
Dan Gohman99a12192009-03-04 19:44:21 +00004740// Register-Memory Subtraction with EFLAGS result
4741def : Pat<(parallel (X86sub_flag GR8:$src1, (loadi8 addr:$src2)),
Bill Wendlingf5399032008-12-12 21:15:41 +00004742 (implicit EFLAGS)),
4743 (SUB8rm GR8:$src1, addr:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00004744def : Pat<(parallel (X86sub_flag GR16:$src1, (loadi16 addr:$src2)),
Bill Wendlingf5399032008-12-12 21:15:41 +00004745 (implicit EFLAGS)),
4746 (SUB16rm GR16:$src1, addr:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00004747def : Pat<(parallel (X86sub_flag GR32:$src1, (loadi32 addr:$src2)),
Bill Wendlingf5399032008-12-12 21:15:41 +00004748 (implicit EFLAGS)),
4749 (SUB32rm GR32:$src1, addr:$src2)>;
4750
Dan Gohman99a12192009-03-04 19:44:21 +00004751// Register-Integer Subtraction with EFLAGS result
4752def : Pat<(parallel (X86sub_flag GR8:$src1, imm:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004753 (implicit EFLAGS)),
4754 (SUB8ri GR8:$src1, imm:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00004755def : Pat<(parallel (X86sub_flag GR16:$src1, imm:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004756 (implicit EFLAGS)),
4757 (SUB16ri GR16:$src1, imm:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00004758def : Pat<(parallel (X86sub_flag GR32:$src1, imm:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004759 (implicit EFLAGS)),
4760 (SUB32ri GR32:$src1, imm:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00004761def : Pat<(parallel (X86sub_flag GR16:$src1, i16immSExt8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004762 (implicit EFLAGS)),
4763 (SUB16ri8 GR16:$src1, i16immSExt8:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00004764def : Pat<(parallel (X86sub_flag GR32:$src1, i32immSExt8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004765 (implicit EFLAGS)),
4766 (SUB32ri8 GR32:$src1, i32immSExt8:$src2)>;
4767
Dan Gohman99a12192009-03-04 19:44:21 +00004768// Memory-Register Subtraction with EFLAGS result
4769def : Pat<(parallel (store (X86sub_flag (loadi8 addr:$dst), GR8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004770 addr:$dst),
4771 (implicit EFLAGS)),
4772 (SUB8mr addr:$dst, GR8:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00004773def : Pat<(parallel (store (X86sub_flag (loadi16 addr:$dst), GR16:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004774 addr:$dst),
4775 (implicit EFLAGS)),
4776 (SUB16mr addr:$dst, GR16:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00004777def : Pat<(parallel (store (X86sub_flag (loadi32 addr:$dst), GR32:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004778 addr:$dst),
4779 (implicit EFLAGS)),
4780 (SUB32mr addr:$dst, GR32:$src2)>;
4781
Dan Gohman99a12192009-03-04 19:44:21 +00004782// Memory-Integer Subtraction with EFLAGS result
4783def : Pat<(parallel (store (X86sub_flag (loadi8 addr:$dst), imm:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004784 addr:$dst),
4785 (implicit EFLAGS)),
4786 (SUB8mi addr:$dst, imm:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00004787def : Pat<(parallel (store (X86sub_flag (loadi16 addr:$dst), imm:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004788 addr:$dst),
4789 (implicit EFLAGS)),
4790 (SUB16mi addr:$dst, imm:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00004791def : Pat<(parallel (store (X86sub_flag (loadi32 addr:$dst), imm:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004792 addr:$dst),
4793 (implicit EFLAGS)),
4794 (SUB32mi addr:$dst, imm:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00004795def : Pat<(parallel (store (X86sub_flag (loadi16 addr:$dst), i16immSExt8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004796 addr:$dst),
4797 (implicit EFLAGS)),
4798 (SUB16mi8 addr:$dst, i16immSExt8:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00004799def : Pat<(parallel (store (X86sub_flag (loadi32 addr:$dst), i32immSExt8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004800 addr:$dst),
4801 (implicit EFLAGS)),
4802 (SUB32mi8 addr:$dst, i32immSExt8:$src2)>;
4803
4804
Dan Gohman99a12192009-03-04 19:44:21 +00004805// Register-Register Signed Integer Multiply with EFLAGS result
4806def : Pat<(parallel (X86smul_flag GR16:$src1, GR16:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004807 (implicit EFLAGS)),
4808 (IMUL16rr GR16:$src1, GR16:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00004809def : Pat<(parallel (X86smul_flag GR32:$src1, GR32:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004810 (implicit EFLAGS)),
4811 (IMUL32rr GR32:$src1, GR32:$src2)>;
4812
Dan Gohman99a12192009-03-04 19:44:21 +00004813// Register-Memory Signed Integer Multiply with EFLAGS result
4814def : Pat<(parallel (X86smul_flag GR16:$src1, (loadi16 addr:$src2)),
Bill Wendlingf5399032008-12-12 21:15:41 +00004815 (implicit EFLAGS)),
4816 (IMUL16rm GR16:$src1, addr:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00004817def : Pat<(parallel (X86smul_flag GR32:$src1, (loadi32 addr:$src2)),
Bill Wendlingf5399032008-12-12 21:15:41 +00004818 (implicit EFLAGS)),
4819 (IMUL32rm GR32:$src1, addr:$src2)>;
4820
Dan Gohman99a12192009-03-04 19:44:21 +00004821// Register-Integer Signed Integer Multiply with EFLAGS result
4822def : Pat<(parallel (X86smul_flag GR16:$src1, imm:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004823 (implicit EFLAGS)),
4824 (IMUL16rri GR16:$src1, imm:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00004825def : Pat<(parallel (X86smul_flag GR32:$src1, imm:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004826 (implicit EFLAGS)),
4827 (IMUL32rri GR32:$src1, imm:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00004828def : Pat<(parallel (X86smul_flag GR16:$src1, i16immSExt8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004829 (implicit EFLAGS)),
4830 (IMUL16rri8 GR16:$src1, i16immSExt8:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00004831def : Pat<(parallel (X86smul_flag GR32:$src1, i32immSExt8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004832 (implicit EFLAGS)),
4833 (IMUL32rri8 GR32:$src1, i32immSExt8:$src2)>;
4834
Dan Gohman99a12192009-03-04 19:44:21 +00004835// Memory-Integer Signed Integer Multiply with EFLAGS result
4836def : Pat<(parallel (X86smul_flag (loadi16 addr:$src1), imm:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004837 (implicit EFLAGS)),
4838 (IMUL16rmi addr:$src1, imm:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00004839def : Pat<(parallel (X86smul_flag (loadi32 addr:$src1), imm:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004840 (implicit EFLAGS)),
4841 (IMUL32rmi addr:$src1, imm:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00004842def : Pat<(parallel (X86smul_flag (loadi16 addr:$src1), i16immSExt8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004843 (implicit EFLAGS)),
4844 (IMUL16rmi8 addr:$src1, i16immSExt8:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00004845def : Pat<(parallel (X86smul_flag (loadi32 addr:$src1), i32immSExt8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004846 (implicit EFLAGS)),
4847 (IMUL32rmi8 addr:$src1, i32immSExt8:$src2)>;
4848
Dan Gohman99a12192009-03-04 19:44:21 +00004849// Optimize multiply by 2 with EFLAGS result.
Evan Cheng00cf7932009-01-27 03:30:42 +00004850let AddedComplexity = 2 in {
Dan Gohman99a12192009-03-04 19:44:21 +00004851def : Pat<(parallel (X86smul_flag GR16:$src1, 2),
Evan Cheng00cf7932009-01-27 03:30:42 +00004852 (implicit EFLAGS)),
4853 (ADD16rr GR16:$src1, GR16:$src1)>;
4854
Dan Gohman99a12192009-03-04 19:44:21 +00004855def : Pat<(parallel (X86smul_flag GR32:$src1, 2),
Evan Cheng00cf7932009-01-27 03:30:42 +00004856 (implicit EFLAGS)),
4857 (ADD32rr GR32:$src1, GR32:$src1)>;
4858}
4859
Dan Gohman99a12192009-03-04 19:44:21 +00004860// INC and DEC with EFLAGS result. Note that these do not set CF.
4861def : Pat<(parallel (X86inc_flag GR8:$src), (implicit EFLAGS)),
4862 (INC8r GR8:$src)>;
4863def : Pat<(parallel (store (i8 (X86inc_flag (loadi8 addr:$dst))), addr:$dst),
4864 (implicit EFLAGS)),
4865 (INC8m addr:$dst)>;
4866def : Pat<(parallel (X86dec_flag GR8:$src), (implicit EFLAGS)),
4867 (DEC8r GR8:$src)>;
4868def : Pat<(parallel (store (i8 (X86dec_flag (loadi8 addr:$dst))), addr:$dst),
4869 (implicit EFLAGS)),
4870 (DEC8m addr:$dst)>;
4871
4872def : Pat<(parallel (X86inc_flag GR16:$src), (implicit EFLAGS)),
Dan Gohmaneebcac72009-03-05 21:32:23 +00004873 (INC16r GR16:$src)>, Requires<[In32BitMode]>;
Dan Gohman99a12192009-03-04 19:44:21 +00004874def : Pat<(parallel (store (i16 (X86inc_flag (loadi16 addr:$dst))), addr:$dst),
4875 (implicit EFLAGS)),
Dan Gohmaneebcac72009-03-05 21:32:23 +00004876 (INC16m addr:$dst)>, Requires<[In32BitMode]>;
Dan Gohman99a12192009-03-04 19:44:21 +00004877def : Pat<(parallel (X86dec_flag GR16:$src), (implicit EFLAGS)),
Dan Gohmaneebcac72009-03-05 21:32:23 +00004878 (DEC16r GR16:$src)>, Requires<[In32BitMode]>;
Dan Gohman99a12192009-03-04 19:44:21 +00004879def : Pat<(parallel (store (i16 (X86dec_flag (loadi16 addr:$dst))), addr:$dst),
4880 (implicit EFLAGS)),
Dan Gohmaneebcac72009-03-05 21:32:23 +00004881 (DEC16m addr:$dst)>, Requires<[In32BitMode]>;
Dan Gohman99a12192009-03-04 19:44:21 +00004882
4883def : Pat<(parallel (X86inc_flag GR32:$src), (implicit EFLAGS)),
Dan Gohmaneebcac72009-03-05 21:32:23 +00004884 (INC32r GR32:$src)>, Requires<[In32BitMode]>;
Dan Gohman99a12192009-03-04 19:44:21 +00004885def : Pat<(parallel (store (i32 (X86inc_flag (loadi32 addr:$dst))), addr:$dst),
4886 (implicit EFLAGS)),
Dan Gohmaneebcac72009-03-05 21:32:23 +00004887 (INC32m addr:$dst)>, Requires<[In32BitMode]>;
Dan Gohman99a12192009-03-04 19:44:21 +00004888def : Pat<(parallel (X86dec_flag GR32:$src), (implicit EFLAGS)),
Dan Gohmaneebcac72009-03-05 21:32:23 +00004889 (DEC32r GR32:$src)>, Requires<[In32BitMode]>;
Dan Gohman99a12192009-03-04 19:44:21 +00004890def : Pat<(parallel (store (i32 (X86dec_flag (loadi32 addr:$dst))), addr:$dst),
4891 (implicit EFLAGS)),
Dan Gohmaneebcac72009-03-05 21:32:23 +00004892 (DEC32m addr:$dst)>, Requires<[In32BitMode]>;
Dan Gohman99a12192009-03-04 19:44:21 +00004893
Dan Gohman12e03292009-09-18 19:59:53 +00004894// Register-Register Or with EFLAGS result
4895def : Pat<(parallel (X86or_flag GR8:$src1, GR8:$src2),
4896 (implicit EFLAGS)),
4897 (OR8rr GR8:$src1, GR8:$src2)>;
4898def : Pat<(parallel (X86or_flag GR16:$src1, GR16:$src2),
4899 (implicit EFLAGS)),
4900 (OR16rr GR16:$src1, GR16:$src2)>;
4901def : Pat<(parallel (X86or_flag GR32:$src1, GR32:$src2),
4902 (implicit EFLAGS)),
4903 (OR32rr GR32:$src1, GR32:$src2)>;
4904
4905// Register-Memory Or with EFLAGS result
4906def : Pat<(parallel (X86or_flag GR8:$src1, (loadi8 addr:$src2)),
4907 (implicit EFLAGS)),
4908 (OR8rm GR8:$src1, addr:$src2)>;
4909def : Pat<(parallel (X86or_flag GR16:$src1, (loadi16 addr:$src2)),
4910 (implicit EFLAGS)),
4911 (OR16rm GR16:$src1, addr:$src2)>;
4912def : Pat<(parallel (X86or_flag GR32:$src1, (loadi32 addr:$src2)),
4913 (implicit EFLAGS)),
4914 (OR32rm GR32:$src1, addr:$src2)>;
4915
4916// Register-Integer Or with EFLAGS result
4917def : Pat<(parallel (X86or_flag GR8:$src1, imm:$src2),
4918 (implicit EFLAGS)),
4919 (OR8ri GR8:$src1, imm:$src2)>;
4920def : Pat<(parallel (X86or_flag GR16:$src1, imm:$src2),
4921 (implicit EFLAGS)),
4922 (OR16ri GR16:$src1, imm:$src2)>;
4923def : Pat<(parallel (X86or_flag GR32:$src1, imm:$src2),
4924 (implicit EFLAGS)),
4925 (OR32ri GR32:$src1, imm:$src2)>;
4926def : Pat<(parallel (X86or_flag GR16:$src1, i16immSExt8:$src2),
4927 (implicit EFLAGS)),
4928 (OR16ri8 GR16:$src1, i16immSExt8:$src2)>;
4929def : Pat<(parallel (X86or_flag GR32:$src1, i32immSExt8:$src2),
4930 (implicit EFLAGS)),
4931 (OR32ri8 GR32:$src1, i32immSExt8:$src2)>;
4932
4933// Memory-Register Or with EFLAGS result
4934def : Pat<(parallel (store (X86or_flag (loadi8 addr:$dst), GR8:$src2),
4935 addr:$dst),
4936 (implicit EFLAGS)),
4937 (OR8mr addr:$dst, GR8:$src2)>;
4938def : Pat<(parallel (store (X86or_flag (loadi16 addr:$dst), GR16:$src2),
4939 addr:$dst),
4940 (implicit EFLAGS)),
4941 (OR16mr addr:$dst, GR16:$src2)>;
4942def : Pat<(parallel (store (X86or_flag (loadi32 addr:$dst), GR32:$src2),
4943 addr:$dst),
4944 (implicit EFLAGS)),
4945 (OR32mr addr:$dst, GR32:$src2)>;
4946
4947// Memory-Integer Or with EFLAGS result
4948def : Pat<(parallel (store (X86or_flag (loadi8 addr:$dst), imm:$src2),
4949 addr:$dst),
4950 (implicit EFLAGS)),
4951 (OR8mi addr:$dst, imm:$src2)>;
4952def : Pat<(parallel (store (X86or_flag (loadi16 addr:$dst), imm:$src2),
4953 addr:$dst),
4954 (implicit EFLAGS)),
4955 (OR16mi addr:$dst, imm:$src2)>;
4956def : Pat<(parallel (store (X86or_flag (loadi32 addr:$dst), imm:$src2),
4957 addr:$dst),
4958 (implicit EFLAGS)),
4959 (OR32mi addr:$dst, imm:$src2)>;
4960def : Pat<(parallel (store (X86or_flag (loadi16 addr:$dst), i16immSExt8:$src2),
4961 addr:$dst),
4962 (implicit EFLAGS)),
4963 (OR16mi8 addr:$dst, i16immSExt8:$src2)>;
4964def : Pat<(parallel (store (X86or_flag (loadi32 addr:$dst), i32immSExt8:$src2),
4965 addr:$dst),
4966 (implicit EFLAGS)),
4967 (OR32mi8 addr:$dst, i32immSExt8:$src2)>;
4968
4969// Register-Register XOr with EFLAGS result
4970def : Pat<(parallel (X86xor_flag GR8:$src1, GR8:$src2),
4971 (implicit EFLAGS)),
4972 (XOR8rr GR8:$src1, GR8:$src2)>;
4973def : Pat<(parallel (X86xor_flag GR16:$src1, GR16:$src2),
4974 (implicit EFLAGS)),
4975 (XOR16rr GR16:$src1, GR16:$src2)>;
4976def : Pat<(parallel (X86xor_flag GR32:$src1, GR32:$src2),
4977 (implicit EFLAGS)),
4978 (XOR32rr GR32:$src1, GR32:$src2)>;
4979
4980// Register-Memory XOr with EFLAGS result
4981def : Pat<(parallel (X86xor_flag GR8:$src1, (loadi8 addr:$src2)),
4982 (implicit EFLAGS)),
4983 (XOR8rm GR8:$src1, addr:$src2)>;
4984def : Pat<(parallel (X86xor_flag GR16:$src1, (loadi16 addr:$src2)),
4985 (implicit EFLAGS)),
4986 (XOR16rm GR16:$src1, addr:$src2)>;
4987def : Pat<(parallel (X86xor_flag GR32:$src1, (loadi32 addr:$src2)),
4988 (implicit EFLAGS)),
4989 (XOR32rm GR32:$src1, addr:$src2)>;
4990
4991// Register-Integer XOr with EFLAGS result
4992def : Pat<(parallel (X86xor_flag GR8:$src1, imm:$src2),
4993 (implicit EFLAGS)),
4994 (XOR8ri GR8:$src1, imm:$src2)>;
4995def : Pat<(parallel (X86xor_flag GR16:$src1, imm:$src2),
4996 (implicit EFLAGS)),
4997 (XOR16ri GR16:$src1, imm:$src2)>;
4998def : Pat<(parallel (X86xor_flag GR32:$src1, imm:$src2),
4999 (implicit EFLAGS)),
5000 (XOR32ri GR32:$src1, imm:$src2)>;
5001def : Pat<(parallel (X86xor_flag GR16:$src1, i16immSExt8:$src2),
5002 (implicit EFLAGS)),
5003 (XOR16ri8 GR16:$src1, i16immSExt8:$src2)>;
5004def : Pat<(parallel (X86xor_flag GR32:$src1, i32immSExt8:$src2),
5005 (implicit EFLAGS)),
5006 (XOR32ri8 GR32:$src1, i32immSExt8:$src2)>;
5007
5008// Memory-Register XOr with EFLAGS result
5009def : Pat<(parallel (store (X86xor_flag (loadi8 addr:$dst), GR8:$src2),
5010 addr:$dst),
5011 (implicit EFLAGS)),
5012 (XOR8mr addr:$dst, GR8:$src2)>;
5013def : Pat<(parallel (store (X86xor_flag (loadi16 addr:$dst), GR16:$src2),
5014 addr:$dst),
5015 (implicit EFLAGS)),
5016 (XOR16mr addr:$dst, GR16:$src2)>;
5017def : Pat<(parallel (store (X86xor_flag (loadi32 addr:$dst), GR32:$src2),
5018 addr:$dst),
5019 (implicit EFLAGS)),
5020 (XOR32mr addr:$dst, GR32:$src2)>;
5021
5022// Memory-Integer XOr with EFLAGS result
5023def : Pat<(parallel (store (X86xor_flag (loadi8 addr:$dst), imm:$src2),
5024 addr:$dst),
5025 (implicit EFLAGS)),
5026 (XOR8mi addr:$dst, imm:$src2)>;
5027def : Pat<(parallel (store (X86xor_flag (loadi16 addr:$dst), imm:$src2),
5028 addr:$dst),
5029 (implicit EFLAGS)),
5030 (XOR16mi addr:$dst, imm:$src2)>;
5031def : Pat<(parallel (store (X86xor_flag (loadi32 addr:$dst), imm:$src2),
5032 addr:$dst),
5033 (implicit EFLAGS)),
5034 (XOR32mi addr:$dst, imm:$src2)>;
5035def : Pat<(parallel (store (X86xor_flag (loadi16 addr:$dst), i16immSExt8:$src2),
5036 addr:$dst),
5037 (implicit EFLAGS)),
5038 (XOR16mi8 addr:$dst, i16immSExt8:$src2)>;
5039def : Pat<(parallel (store (X86xor_flag (loadi32 addr:$dst), i32immSExt8:$src2),
5040 addr:$dst),
5041 (implicit EFLAGS)),
5042 (XOR32mi8 addr:$dst, i32immSExt8:$src2)>;
5043
5044// Register-Register And with EFLAGS result
5045def : Pat<(parallel (X86and_flag GR8:$src1, GR8:$src2),
5046 (implicit EFLAGS)),
5047 (AND8rr GR8:$src1, GR8:$src2)>;
5048def : Pat<(parallel (X86and_flag GR16:$src1, GR16:$src2),
5049 (implicit EFLAGS)),
5050 (AND16rr GR16:$src1, GR16:$src2)>;
5051def : Pat<(parallel (X86and_flag GR32:$src1, GR32:$src2),
5052 (implicit EFLAGS)),
5053 (AND32rr GR32:$src1, GR32:$src2)>;
5054
5055// Register-Memory And with EFLAGS result
5056def : Pat<(parallel (X86and_flag GR8:$src1, (loadi8 addr:$src2)),
5057 (implicit EFLAGS)),
5058 (AND8rm GR8:$src1, addr:$src2)>;
5059def : Pat<(parallel (X86and_flag GR16:$src1, (loadi16 addr:$src2)),
5060 (implicit EFLAGS)),
5061 (AND16rm GR16:$src1, addr:$src2)>;
5062def : Pat<(parallel (X86and_flag GR32:$src1, (loadi32 addr:$src2)),
5063 (implicit EFLAGS)),
5064 (AND32rm GR32:$src1, addr:$src2)>;
5065
5066// Register-Integer And with EFLAGS result
5067def : Pat<(parallel (X86and_flag GR8:$src1, imm:$src2),
5068 (implicit EFLAGS)),
5069 (AND8ri GR8:$src1, imm:$src2)>;
5070def : Pat<(parallel (X86and_flag GR16:$src1, imm:$src2),
5071 (implicit EFLAGS)),
5072 (AND16ri GR16:$src1, imm:$src2)>;
5073def : Pat<(parallel (X86and_flag GR32:$src1, imm:$src2),
5074 (implicit EFLAGS)),
5075 (AND32ri GR32:$src1, imm:$src2)>;
5076def : Pat<(parallel (X86and_flag GR16:$src1, i16immSExt8:$src2),
5077 (implicit EFLAGS)),
5078 (AND16ri8 GR16:$src1, i16immSExt8:$src2)>;
5079def : Pat<(parallel (X86and_flag GR32:$src1, i32immSExt8:$src2),
5080 (implicit EFLAGS)),
5081 (AND32ri8 GR32:$src1, i32immSExt8:$src2)>;
5082
5083// Memory-Register And with EFLAGS result
5084def : Pat<(parallel (store (X86and_flag (loadi8 addr:$dst), GR8:$src2),
5085 addr:$dst),
5086 (implicit EFLAGS)),
5087 (AND8mr addr:$dst, GR8:$src2)>;
5088def : Pat<(parallel (store (X86and_flag (loadi16 addr:$dst), GR16:$src2),
5089 addr:$dst),
5090 (implicit EFLAGS)),
5091 (AND16mr addr:$dst, GR16:$src2)>;
5092def : Pat<(parallel (store (X86and_flag (loadi32 addr:$dst), GR32:$src2),
5093 addr:$dst),
5094 (implicit EFLAGS)),
5095 (AND32mr addr:$dst, GR32:$src2)>;
5096
5097// Memory-Integer And with EFLAGS result
5098def : Pat<(parallel (store (X86and_flag (loadi8 addr:$dst), imm:$src2),
5099 addr:$dst),
5100 (implicit EFLAGS)),
5101 (AND8mi addr:$dst, imm:$src2)>;
5102def : Pat<(parallel (store (X86and_flag (loadi16 addr:$dst), imm:$src2),
5103 addr:$dst),
5104 (implicit EFLAGS)),
5105 (AND16mi addr:$dst, imm:$src2)>;
5106def : Pat<(parallel (store (X86and_flag (loadi32 addr:$dst), imm:$src2),
5107 addr:$dst),
5108 (implicit EFLAGS)),
5109 (AND32mi addr:$dst, imm:$src2)>;
5110def : Pat<(parallel (store (X86and_flag (loadi16 addr:$dst), i16immSExt8:$src2),
5111 addr:$dst),
5112 (implicit EFLAGS)),
5113 (AND16mi8 addr:$dst, i16immSExt8:$src2)>;
5114def : Pat<(parallel (store (X86and_flag (loadi32 addr:$dst), i32immSExt8:$src2),
5115 addr:$dst),
5116 (implicit EFLAGS)),
5117 (AND32mi8 addr:$dst, i32immSExt8:$src2)>;
5118
Dan Gohmane84197b2009-09-03 17:18:51 +00005119// -disable-16bit support.
5120def : Pat<(truncstorei16 (i32 imm:$src), addr:$dst),
5121 (MOV16mi addr:$dst, imm:$src)>;
5122def : Pat<(truncstorei16 GR32:$src, addr:$dst),
5123 (MOV16mr addr:$dst, (EXTRACT_SUBREG GR32:$src, x86_subreg_16bit))>;
5124def : Pat<(i32 (sextloadi16 addr:$dst)),
5125 (MOVSX32rm16 addr:$dst)>;
5126def : Pat<(i32 (zextloadi16 addr:$dst)),
5127 (MOVZX32rm16 addr:$dst)>;
5128def : Pat<(i32 (extloadi16 addr:$dst)),
5129 (MOVZX32rm16 addr:$dst)>;
5130
Bill Wendlingf5399032008-12-12 21:15:41 +00005131//===----------------------------------------------------------------------===//
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005132// Floating Point Stack Support
5133//===----------------------------------------------------------------------===//
5134
5135include "X86InstrFPStack.td"
5136
5137//===----------------------------------------------------------------------===//
Evan Cheng86ab7d32007-07-31 08:04:03 +00005138// X86-64 Support
5139//===----------------------------------------------------------------------===//
5140
Chris Lattner2de8d2b2008-01-10 05:50:42 +00005141include "X86Instr64bit.td"
Evan Cheng86ab7d32007-07-31 08:04:03 +00005142
5143//===----------------------------------------------------------------------===//
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005144// XMM Floating point support (requires SSE / SSE2)
5145//===----------------------------------------------------------------------===//
5146
5147include "X86InstrSSE.td"
Evan Cheng5e4d1e72008-04-25 18:19:54 +00005148
5149//===----------------------------------------------------------------------===//
5150// MMX and XMM Packed Integer support (requires MMX, SSE, and SSE2)
5151//===----------------------------------------------------------------------===//
5152
5153include "X86InstrMMX.td"