blob: 6835176485a3285bb311ac220958bb4a977cd70f [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
Evan Cheng4621d272010-01-11 17:03:47 +0000496// Treat an 'or' node is as an 'add' if the or'ed bits are known to be zero.
497def or_is_add : PatFrag<(ops node:$lhs, node:$rhs), (or node:$lhs, node:$rhs),[{
498 if (ConstantSDNode *CN = dyn_cast<ConstantSDNode>(N->getOperand(1)))
499 return CurDAG->MaskedValueIsZero(N->getOperand(0), CN->getAPIntValue());
500 return false;
501}]>;
502def or_not_add : PatFrag<(ops node:$lhs, node:$rhs),(or node:$lhs, node:$rhs),[{
503 ConstantSDNode *CN = dyn_cast<ConstantSDNode>(N->getOperand(1));
504 if (!CN) return true;
505 return !CurDAG->MaskedValueIsZero(N->getOperand(0), CN->getAPIntValue());
506}]>;
507
Dan Gohman921581d2008-10-17 01:23:35 +0000508// 'shld' and 'shrd' instruction patterns. Note that even though these have
509// the srl and shl in their patterns, the C++ code must still check for them,
510// because predicates are tested before children nodes are explored.
511
512def shrd : PatFrag<(ops node:$src1, node:$amt1, node:$src2, node:$amt2),
513 (or (srl node:$src1, node:$amt1),
514 (shl node:$src2, node:$amt2)), [{
515 assert(N->getOpcode() == ISD::OR);
516 return N->getOperand(0).getOpcode() == ISD::SRL &&
517 N->getOperand(1).getOpcode() == ISD::SHL &&
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
524def shld : PatFrag<(ops node:$src1, node:$amt1, node:$src2, node:$amt2),
525 (or (shl node:$src1, node:$amt1),
526 (srl node:$src2, node:$amt2)), [{
527 assert(N->getOpcode() == ISD::OR);
528 return N->getOperand(0).getOpcode() == ISD::SHL &&
529 N->getOperand(1).getOpcode() == ISD::SRL &&
530 isa<ConstantSDNode>(N->getOperand(0).getOperand(1)) &&
531 isa<ConstantSDNode>(N->getOperand(1).getOperand(1)) &&
532 N->getOperand(0).getConstantOperandVal(1) ==
533 N->getValueSizeInBits(0) - N->getOperand(1).getConstantOperandVal(1);
534}]>;
535
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000536//===----------------------------------------------------------------------===//
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000537// Instruction list...
538//
539
540// ADJCALLSTACKDOWN/UP implicitly use/def ESP because they may be expanded into
541// a stack adjustment and the codegen must know that they may modify the stack
542// pointer before prolog-epilog rewriting occurs.
Chris Lattnerb56cc342008-03-11 03:23:40 +0000543// Pessimistically assume ADJCALLSTACKDOWN / ADJCALLSTACKUP will become
544// sub / add which can clobber EFLAGS.
Evan Cheng037364a2007-09-28 01:19:48 +0000545let Defs = [ESP, EFLAGS], Uses = [ESP] in {
Dan Gohman01c9f772008-10-01 18:28:06 +0000546def ADJCALLSTACKDOWN32 : I<0, Pseudo, (outs), (ins i32imm:$amt),
547 "#ADJCALLSTACKDOWN",
Chris Lattnerfe5d4022008-10-11 22:08:30 +0000548 [(X86callseq_start timm:$amt)]>,
Dan Gohman01c9f772008-10-01 18:28:06 +0000549 Requires<[In32BitMode]>;
550def ADJCALLSTACKUP32 : I<0, Pseudo, (outs), (ins i32imm:$amt1, i32imm:$amt2),
551 "#ADJCALLSTACKUP",
Chris Lattnerfe5d4022008-10-11 22:08:30 +0000552 [(X86callseq_end timm:$amt1, timm:$amt2)]>,
Dan Gohman01c9f772008-10-01 18:28:06 +0000553 Requires<[In32BitMode]>;
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000554}
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000555
Dan Gohman34228bf2009-08-15 01:38:56 +0000556// x86-64 va_start lowering magic.
Dan Gohman30afe012009-10-29 18:10:34 +0000557let usesCustomInserter = 1 in
Dan Gohman34228bf2009-08-15 01:38:56 +0000558def VASTART_SAVE_XMM_REGS : I<0, Pseudo,
559 (outs),
560 (ins GR8:$al,
561 i64imm:$regsavefi, i64imm:$offset,
562 variable_ops),
563 "#VASTART_SAVE_XMM_REGS $al, $regsavefi, $offset",
564 [(X86vastart_save_xmm_regs GR8:$al,
565 imm:$regsavefi,
566 imm:$offset)]>;
567
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000568// Nop
Sean Callananf94a0542009-07-23 23:39:34 +0000569let neverHasSideEffects = 1 in {
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000570 def NOOP : I<0x90, RawFrm, (outs), (ins), "nop", []>;
Sean Callanan2c48df22009-12-18 00:01:26 +0000571 def NOOPW : I<0x1f, MRM0m, (outs), (ins i16mem:$zero),
572 "nop{w}\t$zero", []>, TB, OpSize;
Sean Callananf94a0542009-07-23 23:39:34 +0000573 def NOOPL : I<0x1f, MRM0m, (outs), (ins i32mem:$zero),
Sean Callanan2c48df22009-12-18 00:01:26 +0000574 "nop{l}\t$zero", []>, TB;
Sean Callananf94a0542009-07-23 23:39:34 +0000575}
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000576
Sean Callanan9b195f82009-08-11 01:09:06 +0000577// Trap
Dan Gohman8112b942009-11-11 18:07:16 +0000578def INT3 : I<0xcc, RawFrm, (outs), (ins), "int\t3", []>;
Sean Callanan9b195f82009-08-11 01:09:06 +0000579def INT : I<0xcd, RawFrm, (outs), (ins i8imm:$trap), "int\t$trap", []>;
Sean Callanan2c48df22009-12-18 00:01:26 +0000580def IRET16 : I<0xcf, RawFrm, (outs), (ins), "iret{w}", []>, OpSize;
581def IRET32 : I<0xcf, RawFrm, (outs), (ins), "iret{l}", []>;
Sean Callanan9b195f82009-08-11 01:09:06 +0000582
Chris Lattner2aa10da2009-09-20 07:32:00 +0000583// PIC base construction. This expands to code that looks like this:
584// call $next_inst
585// popl %destreg"
Dan Gohman9499cfe2008-10-01 04:14:30 +0000586let neverHasSideEffects = 1, isNotDuplicable = 1, Uses = [ESP] in
Chris Lattnera7e959d2009-09-20 07:28:26 +0000587 def MOVPC32r : Ii32<0xE8, Pseudo, (outs GR32:$reg), (ins i32imm:$label),
Chris Lattner2aa10da2009-09-20 07:32:00 +0000588 "", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000589
590//===----------------------------------------------------------------------===//
591// Control Flow Instructions...
592//
593
594// Return instructions.
595let isTerminator = 1, isReturn = 1, isBarrier = 1,
Chris Lattnerb56cc342008-03-11 03:23:40 +0000596 hasCtrlDep = 1, FPForm = SpecialFP, FPFormBits = SpecialFP.Value in {
Dan Gohman2c4be2a2008-05-31 02:11:25 +0000597 def RET : I <0xC3, RawFrm, (outs), (ins variable_ops),
Chris Lattnerb56cc342008-03-11 03:23:40 +0000598 "ret",
Dan Gohman2c4be2a2008-05-31 02:11:25 +0000599 [(X86retflag 0)]>;
Chris Lattnerb56cc342008-03-11 03:23:40 +0000600 def RETI : Ii16<0xC2, RawFrm, (outs), (ins i16imm:$amt, variable_ops),
601 "ret\t$amt",
Dan Gohmane84197b2009-09-03 17:18:51 +0000602 [(X86retflag timm:$amt)]>;
Sean Callanan7a012572009-09-15 23:37:51 +0000603 def LRET : I <0xCB, RawFrm, (outs), (ins),
604 "lret", []>;
605 def LRETI : Ii16<0xCA, RawFrm, (outs), (ins i16imm:$amt),
606 "lret\t$amt", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000607}
608
609// All branches are RawFrm, Void, Branch, and Terminators
Evan Cheng37e7c752007-07-21 00:34:19 +0000610let isBranch = 1, isTerminator = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +0000611 class IBr<bits<8> opcode, dag ins, string asm, list<dag> pattern> :
612 I<opcode, RawFrm, (outs), ins, asm, pattern>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000613
Sean Callananc0608152009-07-22 01:05:20 +0000614let isBranch = 1, isBarrier = 1 in {
Dan Gohman91888f02007-07-31 20:11:57 +0000615 def JMP : IBr<0xE9, (ins brtarget:$dst), "jmp\t$dst", [(br bb:$dst)]>;
Sean Callananc0608152009-07-22 01:05:20 +0000616 def JMP8 : IBr<0xEB, (ins brtarget8:$dst), "jmp\t$dst", []>;
617}
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000618
Owen Andersonf8053082007-11-12 07:39:39 +0000619// Indirect branches
620let isBranch = 1, isTerminator = 1, isBarrier = 1, isIndirectBranch = 1 in {
Dan Gohman91888f02007-07-31 20:11:57 +0000621 def JMP32r : I<0xFF, MRM4r, (outs), (ins GR32:$dst), "jmp{l}\t{*}$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000622 [(brind GR32:$dst)]>;
Dan Gohman91888f02007-07-31 20:11:57 +0000623 def JMP32m : I<0xFF, MRM4m, (outs), (ins i32mem:$dst), "jmp{l}\t{*}$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000624 [(brind (loadi32 addr:$dst))]>;
Sean Callananb7e73392009-09-15 00:35:17 +0000625
626 def FARJMP16i : Iseg16<0xEA, RawFrm, (outs),
627 (ins i16imm:$seg, i16imm:$off),
628 "ljmp{w}\t$seg, $off", []>, OpSize;
629 def FARJMP32i : Iseg32<0xEA, RawFrm, (outs),
630 (ins i16imm:$seg, i32imm:$off),
631 "ljmp{l}\t$seg, $off", []>;
632
633 def FARJMP16m : I<0xFF, MRM5m, (outs), (ins opaque32mem:$dst),
Sean Callanan66fdfa02009-09-03 00:04:47 +0000634 "ljmp{w}\t{*}$dst", []>, OpSize;
Sean Callananb7e73392009-09-15 00:35:17 +0000635 def FARJMP32m : I<0xFF, MRM5m, (outs), (ins opaque48mem:$dst),
Sean Callanan66fdfa02009-09-03 00:04:47 +0000636 "ljmp{l}\t{*}$dst", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000637}
638
639// Conditional branches
Evan Cheng950aac02007-09-25 01:57:46 +0000640let Uses = [EFLAGS] in {
Evan Chengd11052b2009-07-21 06:00:18 +0000641// Short conditional jumps
642def JO8 : IBr<0x70, (ins brtarget8:$dst), "jo\t$dst", []>;
643def JNO8 : IBr<0x71, (ins brtarget8:$dst), "jno\t$dst", []>;
644def JB8 : IBr<0x72, (ins brtarget8:$dst), "jb\t$dst", []>;
645def JAE8 : IBr<0x73, (ins brtarget8:$dst), "jae\t$dst", []>;
646def JE8 : IBr<0x74, (ins brtarget8:$dst), "je\t$dst", []>;
647def JNE8 : IBr<0x75, (ins brtarget8:$dst), "jne\t$dst", []>;
648def JBE8 : IBr<0x76, (ins brtarget8:$dst), "jbe\t$dst", []>;
649def JA8 : IBr<0x77, (ins brtarget8:$dst), "ja\t$dst", []>;
650def JS8 : IBr<0x78, (ins brtarget8:$dst), "js\t$dst", []>;
651def JNS8 : IBr<0x79, (ins brtarget8:$dst), "jns\t$dst", []>;
652def JP8 : IBr<0x7A, (ins brtarget8:$dst), "jp\t$dst", []>;
653def JNP8 : IBr<0x7B, (ins brtarget8:$dst), "jnp\t$dst", []>;
654def JL8 : IBr<0x7C, (ins brtarget8:$dst), "jl\t$dst", []>;
655def JGE8 : IBr<0x7D, (ins brtarget8:$dst), "jge\t$dst", []>;
656def JLE8 : IBr<0x7E, (ins brtarget8:$dst), "jle\t$dst", []>;
657def JG8 : IBr<0x7F, (ins brtarget8:$dst), "jg\t$dst", []>;
658
659def JCXZ8 : IBr<0xE3, (ins brtarget8:$dst), "jcxz\t$dst", []>;
660
Dan Gohman91888f02007-07-31 20:11:57 +0000661def JE : IBr<0x84, (ins brtarget:$dst), "je\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000662 [(X86brcond bb:$dst, X86_COND_E, EFLAGS)]>, TB;
Dan Gohman91888f02007-07-31 20:11:57 +0000663def JNE : IBr<0x85, (ins brtarget:$dst), "jne\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000664 [(X86brcond bb:$dst, X86_COND_NE, EFLAGS)]>, TB;
Dan Gohman91888f02007-07-31 20:11:57 +0000665def JL : IBr<0x8C, (ins brtarget:$dst), "jl\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000666 [(X86brcond bb:$dst, X86_COND_L, EFLAGS)]>, TB;
Dan Gohman91888f02007-07-31 20:11:57 +0000667def JLE : IBr<0x8E, (ins brtarget:$dst), "jle\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000668 [(X86brcond bb:$dst, X86_COND_LE, EFLAGS)]>, TB;
Dan Gohman91888f02007-07-31 20:11:57 +0000669def JG : IBr<0x8F, (ins brtarget:$dst), "jg\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000670 [(X86brcond bb:$dst, X86_COND_G, EFLAGS)]>, TB;
Dan Gohman91888f02007-07-31 20:11:57 +0000671def JGE : IBr<0x8D, (ins brtarget:$dst), "jge\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000672 [(X86brcond bb:$dst, X86_COND_GE, EFLAGS)]>, TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000673
Dan Gohman91888f02007-07-31 20:11:57 +0000674def JB : IBr<0x82, (ins brtarget:$dst), "jb\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000675 [(X86brcond bb:$dst, X86_COND_B, EFLAGS)]>, TB;
Dan Gohman91888f02007-07-31 20:11:57 +0000676def JBE : IBr<0x86, (ins brtarget:$dst), "jbe\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000677 [(X86brcond bb:$dst, X86_COND_BE, EFLAGS)]>, TB;
Dan Gohman91888f02007-07-31 20:11:57 +0000678def JA : IBr<0x87, (ins brtarget:$dst), "ja\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000679 [(X86brcond bb:$dst, X86_COND_A, EFLAGS)]>, TB;
Dan Gohman91888f02007-07-31 20:11:57 +0000680def JAE : IBr<0x83, (ins brtarget:$dst), "jae\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000681 [(X86brcond bb:$dst, X86_COND_AE, EFLAGS)]>, TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000682
Dan Gohman91888f02007-07-31 20:11:57 +0000683def JS : IBr<0x88, (ins brtarget:$dst), "js\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000684 [(X86brcond bb:$dst, X86_COND_S, EFLAGS)]>, TB;
Dan Gohman91888f02007-07-31 20:11:57 +0000685def JNS : IBr<0x89, (ins brtarget:$dst), "jns\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000686 [(X86brcond bb:$dst, X86_COND_NS, EFLAGS)]>, TB;
Dan Gohman91888f02007-07-31 20:11:57 +0000687def JP : IBr<0x8A, (ins brtarget:$dst), "jp\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000688 [(X86brcond bb:$dst, X86_COND_P, EFLAGS)]>, TB;
Dan Gohman91888f02007-07-31 20:11:57 +0000689def JNP : IBr<0x8B, (ins brtarget:$dst), "jnp\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000690 [(X86brcond bb:$dst, X86_COND_NP, EFLAGS)]>, TB;
Dan Gohman91888f02007-07-31 20:11:57 +0000691def JO : IBr<0x80, (ins brtarget:$dst), "jo\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000692 [(X86brcond bb:$dst, X86_COND_O, EFLAGS)]>, TB;
Dan Gohman91888f02007-07-31 20:11:57 +0000693def JNO : IBr<0x81, (ins brtarget:$dst), "jno\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000694 [(X86brcond bb:$dst, X86_COND_NO, EFLAGS)]>, TB;
Evan Cheng950aac02007-09-25 01:57:46 +0000695} // Uses = [EFLAGS]
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000696
Sean Callanan503784b2009-09-16 21:50:07 +0000697// Loop instructions
698
699def LOOP : I<0xE2, RawFrm, (ins brtarget8:$dst), (outs), "loop\t$dst", []>;
700def LOOPE : I<0xE1, RawFrm, (ins brtarget8:$dst), (outs), "loope\t$dst", []>;
701def LOOPNE : I<0xE0, RawFrm, (ins brtarget8:$dst), (outs), "loopne\t$dst", []>;
702
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000703//===----------------------------------------------------------------------===//
704// Call Instructions...
705//
Evan Cheng37e7c752007-07-21 00:34:19 +0000706let isCall = 1 in
Dan Gohman01c9f772008-10-01 18:28:06 +0000707 // All calls clobber the non-callee saved registers. ESP is marked as
708 // a use to prevent stack-pointer assignments that appear immediately
709 // before calls from potentially appearing dead. Uses for argument
710 // registers are added manually.
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000711 let Defs = [EAX, ECX, EDX, FP0, FP1, FP2, FP3, FP4, FP5, FP6, ST0,
712 MM0, MM1, MM2, MM3, MM4, MM5, MM6, MM7,
Evan Cheng2293b252008-10-17 21:02:22 +0000713 XMM0, XMM1, XMM2, XMM3, XMM4, XMM5, XMM6, XMM7,
714 XMM8, XMM9, XMM10, XMM11, XMM12, XMM13, XMM14, XMM15, EFLAGS],
Dan Gohman9499cfe2008-10-01 04:14:30 +0000715 Uses = [ESP] in {
Chris Lattner357a0ca2009-06-20 19:34:09 +0000716 def CALLpcrel32 : Ii32<0xE8, RawFrm,
717 (outs), (ins i32imm_pcrel:$dst,variable_ops),
718 "call\t$dst", []>;
Evan Chengb783fa32007-07-19 01:14:50 +0000719 def CALL32r : I<0xFF, MRM2r, (outs), (ins GR32:$dst, variable_ops),
Dan Gohman91888f02007-07-31 20:11:57 +0000720 "call\t{*}$dst", [(X86call GR32:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000721 def CALL32m : I<0xFF, MRM2m, (outs), (ins i32mem:$dst, variable_ops),
Dan Gohmanea4faba2008-05-29 21:50:34 +0000722 "call\t{*}$dst", [(X86call (loadi32 addr:$dst))]>;
Sean Callanan66fdfa02009-09-03 00:04:47 +0000723
Sean Callananb7e73392009-09-15 00:35:17 +0000724 def FARCALL16i : Iseg16<0x9A, RawFrm, (outs),
725 (ins i16imm:$seg, i16imm:$off),
726 "lcall{w}\t$seg, $off", []>, OpSize;
727 def FARCALL32i : Iseg32<0x9A, RawFrm, (outs),
728 (ins i16imm:$seg, i32imm:$off),
729 "lcall{l}\t$seg, $off", []>;
730
731 def FARCALL16m : I<0xFF, MRM3m, (outs), (ins opaque32mem:$dst),
Sean Callanan66fdfa02009-09-03 00:04:47 +0000732 "lcall{w}\t{*}$dst", []>, OpSize;
Sean Callananb7e73392009-09-15 00:35:17 +0000733 def FARCALL32m : I<0xFF, MRM3m, (outs), (ins opaque48mem:$dst),
Sean Callanan66fdfa02009-09-03 00:04:47 +0000734 "lcall{l}\t{*}$dst", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000735 }
736
Sean Callanan51b7a992009-09-16 02:57:13 +0000737// Constructing a stack frame.
738
739def ENTER : I<0xC8, RawFrm, (outs), (ins i16imm:$len, i8imm:$lvl),
740 "enter\t$len, $lvl", []>;
741
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000742// Tail call stuff.
Arnold Schwaighofere2d6bbb2007-10-11 19:40:01 +0000743
Evan Cheng37e7c752007-07-21 00:34:19 +0000744let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1 in
Sean Callanan2c48df22009-12-18 00:01:26 +0000745def TCRETURNdi : I<0, Pseudo, (outs),
746 (ins i32imm:$dst, i32imm:$offset, variable_ops),
Arnold Schwaighofere2d6bbb2007-10-11 19:40:01 +0000747 "#TC_RETURN $dst $offset",
748 []>;
749
750let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1 in
Sean Callanan2c48df22009-12-18 00:01:26 +0000751def TCRETURNri : I<0, Pseudo, (outs),
752 (ins GR32:$dst, i32imm:$offset, variable_ops),
Arnold Schwaighofere2d6bbb2007-10-11 19:40:01 +0000753 "#TC_RETURN $dst $offset",
754 []>;
755
756let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1 in
Chris Lattner357a0ca2009-06-20 19:34:09 +0000757 def TAILJMPd : IBr<0xE9, (ins i32imm_pcrel:$dst), "jmp\t$dst # TAILCALL",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000758 []>;
Evan Cheng37e7c752007-07-21 00:34:19 +0000759let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1 in
Sean Callanan2c48df22009-12-18 00:01:26 +0000760 def TAILJMPr : I<0xFF, MRM4r, (outs), (ins GR32:$dst),
761 "jmp{l}\t{*}$dst # TAILCALL",
Arnold Schwaighofere2d6bbb2007-10-11 19:40:01 +0000762 []>;
Evan Cheng37e7c752007-07-21 00:34:19 +0000763let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +0000764 def TAILJMPm : I<0xFF, MRM4m, (outs), (ins i32mem:$dst),
Arnold Schwaighofere2d6bbb2007-10-11 19:40:01 +0000765 "jmp\t{*}$dst # TAILCALL", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000766
767//===----------------------------------------------------------------------===//
768// Miscellaneous Instructions...
769//
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000770let Defs = [EBP, ESP], Uses = [EBP, ESP], mayLoad = 1, neverHasSideEffects=1 in
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000771def LEAVE : I<0xC9, RawFrm,
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000772 (outs), (ins), "leave", []>;
773
Sean Callanan2c48df22009-12-18 00:01:26 +0000774def POPCNT16rr : I<0xB8, MRMSrcReg, (outs GR16:$dst), (ins GR16:$src),
775 "popcnt{w}\t{$src, $dst|$dst, $src}", []>, OpSize, XS;
776def POPCNT16rm : I<0xB8, MRMSrcMem, (outs GR16:$dst), (ins i16mem:$src),
777 "popcnt{w}\t{$src, $dst|$dst, $src}", []>, OpSize, XS;
778def POPCNT32rr : I<0xB8, MRMSrcReg, (outs GR32:$dst), (ins GR32:$src),
779 "popcnt{l}\t{$src, $dst|$dst, $src}", []>, XS;
780def POPCNT32rm : I<0xB8, MRMSrcMem, (outs GR32:$dst), (ins i32mem:$src),
781 "popcnt{l}\t{$src, $dst|$dst, $src}", []>, XS;
782
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000783let Defs = [ESP], Uses = [ESP], neverHasSideEffects=1 in {
Sean Callanan9f3c3f52009-09-10 18:29:13 +0000784let mayLoad = 1 in {
785def POP16r : I<0x58, AddRegFrm, (outs GR16:$reg), (ins), "pop{w}\t$reg", []>,
786 OpSize;
787def POP32r : I<0x58, AddRegFrm, (outs GR32:$reg), (ins), "pop{l}\t$reg", []>;
788def POP16rmr: I<0x8F, MRM0r, (outs GR16:$reg), (ins), "pop{w}\t$reg", []>,
789 OpSize;
790def POP16rmm: I<0x8F, MRM0m, (outs i16mem:$dst), (ins), "pop{w}\t$dst", []>,
791 OpSize;
792def POP32rmr: I<0x8F, MRM0r, (outs GR32:$reg), (ins), "pop{l}\t$reg", []>;
793def POP32rmm: I<0x8F, MRM0m, (outs i32mem:$dst), (ins), "pop{l}\t$dst", []>;
794}
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000795
Sean Callanan9f3c3f52009-09-10 18:29:13 +0000796let mayStore = 1 in {
797def PUSH16r : I<0x50, AddRegFrm, (outs), (ins GR16:$reg), "push{w}\t$reg",[]>,
798 OpSize;
Evan Chengd8434332007-09-26 01:29:06 +0000799def PUSH32r : I<0x50, AddRegFrm, (outs), (ins GR32:$reg), "push{l}\t$reg",[]>;
Sean Callanan9f3c3f52009-09-10 18:29:13 +0000800def PUSH16rmr: I<0xFF, MRM6r, (outs), (ins GR16:$reg), "push{w}\t$reg",[]>,
801 OpSize;
802def PUSH16rmm: I<0xFF, MRM6m, (outs), (ins i16mem:$src), "push{w}\t$src",[]>,
803 OpSize;
804def PUSH32rmr: I<0xFF, MRM6r, (outs), (ins GR32:$reg), "push{l}\t$reg",[]>;
805def PUSH32rmm: I<0xFF, MRM6m, (outs), (ins i32mem:$src), "push{l}\t$src",[]>;
806}
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000807}
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000808
Bill Wendling4c2638c2009-06-15 19:39:04 +0000809let Defs = [ESP], Uses = [ESP], neverHasSideEffects = 1, mayStore = 1 in {
810def PUSH32i8 : Ii8<0x6a, RawFrm, (outs), (ins i8imm:$imm),
Bill Wendling0b0437f2009-06-15 20:59:31 +0000811 "push{l}\t$imm", []>;
Bill Wendling4c2638c2009-06-15 19:39:04 +0000812def PUSH32i16 : Ii16<0x68, RawFrm, (outs), (ins i16imm:$imm),
Bill Wendling0b0437f2009-06-15 20:59:31 +0000813 "push{l}\t$imm", []>;
Bill Wendling4c2638c2009-06-15 19:39:04 +0000814def PUSH32i32 : Ii32<0x68, RawFrm, (outs), (ins i32imm:$imm),
Bill Wendling0b0437f2009-06-15 20:59:31 +0000815 "push{l}\t$imm", []>;
Bill Wendling4c2638c2009-06-15 19:39:04 +0000816}
817
Sean Callanan2c48df22009-12-18 00:01:26 +0000818let Defs = [ESP, EFLAGS], Uses = [ESP], mayLoad = 1, neverHasSideEffects=1 in {
819def POPF : I<0x9D, RawFrm, (outs), (ins), "popf{w}", []>, OpSize;
820def POPFD : I<0x9D, RawFrm, (outs), (ins), "popf{l}", []>;
821}
822let Defs = [ESP], Uses = [ESP, EFLAGS], mayStore = 1, neverHasSideEffects=1 in {
823def PUSHF : I<0x9C, RawFrm, (outs), (ins), "pushf{w}", []>, OpSize;
824def PUSHFD : I<0x9C, RawFrm, (outs), (ins), "pushf{l}", []>;
825}
Evan Chengd8434332007-09-26 01:29:06 +0000826
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000827let isTwoAddress = 1 in // GR32 = bswap GR32
828 def BSWAP32r : I<0xC8, AddRegFrm,
Evan Chengb783fa32007-07-19 01:14:50 +0000829 (outs GR32:$dst), (ins GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000830 "bswap{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000831 [(set GR32:$dst, (bswap GR32:$src))]>, TB;
832
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000833
Evan Cheng48679f42007-12-14 02:13:44 +0000834// Bit scan instructions.
835let Defs = [EFLAGS] in {
Evan Cheng4e33de92007-12-14 18:49:43 +0000836def BSF16rr : I<0xBC, MRMSrcReg, (outs GR16:$dst), (ins GR16:$src),
Dan Gohmancdb54c62007-12-14 15:10:00 +0000837 "bsf{w}\t{$src, $dst|$dst, $src}",
Evan Cheng7cfbfe32007-12-14 08:30:15 +0000838 [(set GR16:$dst, (X86bsf GR16:$src)), (implicit EFLAGS)]>, TB;
Evan Cheng48679f42007-12-14 02:13:44 +0000839def BSF16rm : I<0xBC, MRMSrcMem, (outs GR16:$dst), (ins i16mem:$src),
Dan Gohmancdb54c62007-12-14 15:10:00 +0000840 "bsf{w}\t{$src, $dst|$dst, $src}",
Evan Cheng7cfbfe32007-12-14 08:30:15 +0000841 [(set GR16:$dst, (X86bsf (loadi16 addr:$src))),
842 (implicit EFLAGS)]>, TB;
Evan Cheng4e33de92007-12-14 18:49:43 +0000843def BSF32rr : I<0xBC, MRMSrcReg, (outs GR32:$dst), (ins GR32:$src),
Dan Gohmancdb54c62007-12-14 15:10:00 +0000844 "bsf{l}\t{$src, $dst|$dst, $src}",
Evan Cheng7cfbfe32007-12-14 08:30:15 +0000845 [(set GR32:$dst, (X86bsf GR32:$src)), (implicit EFLAGS)]>, TB;
Evan Cheng48679f42007-12-14 02:13:44 +0000846def BSF32rm : I<0xBC, MRMSrcMem, (outs GR32:$dst), (ins i32mem:$src),
Dan Gohmancdb54c62007-12-14 15:10:00 +0000847 "bsf{l}\t{$src, $dst|$dst, $src}",
Evan Cheng7cfbfe32007-12-14 08:30:15 +0000848 [(set GR32:$dst, (X86bsf (loadi32 addr:$src))),
849 (implicit EFLAGS)]>, TB;
Evan Cheng48679f42007-12-14 02:13:44 +0000850
Evan Cheng4e33de92007-12-14 18:49:43 +0000851def BSR16rr : I<0xBD, MRMSrcReg, (outs GR16:$dst), (ins GR16:$src),
Dan Gohmancdb54c62007-12-14 15:10:00 +0000852 "bsr{w}\t{$src, $dst|$dst, $src}",
Evan Cheng7cfbfe32007-12-14 08:30:15 +0000853 [(set GR16:$dst, (X86bsr GR16:$src)), (implicit EFLAGS)]>, TB;
Evan Cheng48679f42007-12-14 02:13:44 +0000854def BSR16rm : I<0xBD, MRMSrcMem, (outs GR16:$dst), (ins i16mem:$src),
Dan Gohmancdb54c62007-12-14 15:10:00 +0000855 "bsr{w}\t{$src, $dst|$dst, $src}",
Evan Cheng7cfbfe32007-12-14 08:30:15 +0000856 [(set GR16:$dst, (X86bsr (loadi16 addr:$src))),
857 (implicit EFLAGS)]>, TB;
Evan Cheng4e33de92007-12-14 18:49:43 +0000858def BSR32rr : I<0xBD, MRMSrcReg, (outs GR32:$dst), (ins GR32:$src),
Dan Gohmancdb54c62007-12-14 15:10:00 +0000859 "bsr{l}\t{$src, $dst|$dst, $src}",
Evan Cheng7cfbfe32007-12-14 08:30:15 +0000860 [(set GR32:$dst, (X86bsr GR32:$src)), (implicit EFLAGS)]>, TB;
Evan Cheng48679f42007-12-14 02:13:44 +0000861def BSR32rm : I<0xBD, MRMSrcMem, (outs GR32:$dst), (ins i32mem:$src),
Dan Gohmancdb54c62007-12-14 15:10:00 +0000862 "bsr{l}\t{$src, $dst|$dst, $src}",
Evan Cheng7cfbfe32007-12-14 08:30:15 +0000863 [(set GR32:$dst, (X86bsr (loadi32 addr:$src))),
864 (implicit EFLAGS)]>, TB;
Evan Cheng48679f42007-12-14 02:13:44 +0000865} // Defs = [EFLAGS]
866
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000867let neverHasSideEffects = 1 in
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000868def LEA16r : I<0x8D, MRMSrcMem,
Evan Chengca348202009-12-12 18:51:56 +0000869 (outs GR16:$dst), (ins lea32mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000870 "lea{w}\t{$src|$dst}, {$dst|$src}", []>, OpSize;
Evan Cheng1ea8e6b2008-03-27 01:41:09 +0000871let isReMaterializable = 1 in
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000872def LEA32r : I<0x8D, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +0000873 (outs GR32:$dst), (ins lea32mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000874 "lea{l}\t{$src|$dst}, {$dst|$src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000875 [(set GR32:$dst, lea32addr:$src)]>, Requires<[In32BitMode]>;
876
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000877let Defs = [ECX,EDI,ESI], Uses = [ECX,EDI,ESI] in {
Evan Chengb783fa32007-07-19 01:14:50 +0000878def REP_MOVSB : I<0xA4, RawFrm, (outs), (ins), "{rep;movsb|rep movsb}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000879 [(X86rep_movs i8)]>, REP;
Evan Chengb783fa32007-07-19 01:14:50 +0000880def REP_MOVSW : I<0xA5, RawFrm, (outs), (ins), "{rep;movsw|rep movsw}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000881 [(X86rep_movs i16)]>, REP, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +0000882def REP_MOVSD : I<0xA5, RawFrm, (outs), (ins), "{rep;movsl|rep movsd}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000883 [(X86rep_movs i32)]>, REP;
884}
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000885
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000886let Defs = [ECX,EDI], Uses = [AL,ECX,EDI] in
Evan Chengb783fa32007-07-19 01:14:50 +0000887def REP_STOSB : I<0xAA, RawFrm, (outs), (ins), "{rep;stosb|rep stosb}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000888 [(X86rep_stos i8)]>, REP;
889let Defs = [ECX,EDI], Uses = [AX,ECX,EDI] in
Evan Chengb783fa32007-07-19 01:14:50 +0000890def REP_STOSW : I<0xAB, RawFrm, (outs), (ins), "{rep;stosw|rep stosw}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000891 [(X86rep_stos i16)]>, REP, OpSize;
892let Defs = [ECX,EDI], Uses = [EAX,ECX,EDI] in
Evan Chengb783fa32007-07-19 01:14:50 +0000893def REP_STOSD : I<0xAB, RawFrm, (outs), (ins), "{rep;stosl|rep stosd}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000894 [(X86rep_stos i32)]>, REP;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000895
Sean Callanan481f06d2009-09-12 00:37:19 +0000896def SCAS8 : I<0xAE, RawFrm, (outs), (ins), "scas{b}", []>;
897def SCAS16 : I<0xAF, RawFrm, (outs), (ins), "scas{w}", []>, OpSize;
898def SCAS32 : I<0xAF, RawFrm, (outs), (ins), "scas{l}", []>;
899
Sean Callanan25220d62009-09-12 02:25:20 +0000900def CMPS8 : I<0xA6, RawFrm, (outs), (ins), "cmps{b}", []>;
901def CMPS16 : I<0xA7, RawFrm, (outs), (ins), "cmps{w}", []>, OpSize;
902def CMPS32 : I<0xA7, RawFrm, (outs), (ins), "cmps{l}", []>;
903
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000904let Defs = [RAX, RDX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000905def RDTSC : I<0x31, RawFrm, (outs), (ins), "rdtsc", [(X86rdtsc)]>,
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000906 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000907
Anton Korobeynikov39d40ba2008-01-15 07:02:33 +0000908let isBarrier = 1, hasCtrlDep = 1 in {
Chris Lattner56b941f2008-01-15 21:58:22 +0000909def TRAP : I<0x0B, RawFrm, (outs), (ins), "ud2", [(trap)]>, TB;
Anton Korobeynikov39d40ba2008-01-15 07:02:33 +0000910}
911
Chris Lattnerc96e27c2009-08-11 16:58:39 +0000912def SYSCALL : I<0x05, RawFrm,
913 (outs), (ins), "syscall", []>, TB;
914def SYSRET : I<0x07, RawFrm,
915 (outs), (ins), "sysret", []>, TB;
916def SYSENTER : I<0x34, RawFrm,
917 (outs), (ins), "sysenter", []>, TB;
918def SYSEXIT : I<0x35, RawFrm,
919 (outs), (ins), "sysexit", []>, TB;
920
Sean Callanan2c2313a2009-09-12 02:52:41 +0000921def WAIT : I<0x9B, RawFrm, (outs), (ins), "wait", []>;
Chris Lattnerc96e27c2009-08-11 16:58:39 +0000922
923
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000924//===----------------------------------------------------------------------===//
925// Input/Output Instructions...
926//
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000927let Defs = [AL], Uses = [DX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000928def IN8rr : I<0xEC, RawFrm, (outs), (ins),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000929 "in{b}\t{%dx, %al|%AL, %DX}", []>;
930let Defs = [AX], Uses = [DX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000931def IN16rr : I<0xED, RawFrm, (outs), (ins),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000932 "in{w}\t{%dx, %ax|%AX, %DX}", []>, OpSize;
933let Defs = [EAX], Uses = [DX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000934def IN32rr : I<0xED, RawFrm, (outs), (ins),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000935 "in{l}\t{%dx, %eax|%EAX, %DX}", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000936
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000937let Defs = [AL] in
Evan Chengb783fa32007-07-19 01:14:50 +0000938def IN8ri : Ii8<0xE4, RawFrm, (outs), (ins i16i8imm:$port),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000939 "in{b}\t{$port, %al|%AL, $port}", []>;
940let Defs = [AX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000941def IN16ri : Ii8<0xE5, RawFrm, (outs), (ins i16i8imm:$port),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000942 "in{w}\t{$port, %ax|%AX, $port}", []>, OpSize;
943let Defs = [EAX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000944def IN32ri : Ii8<0xE5, RawFrm, (outs), (ins i16i8imm:$port),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000945 "in{l}\t{$port, %eax|%EAX, $port}", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000946
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000947let Uses = [DX, AL] in
Evan Chengb783fa32007-07-19 01:14:50 +0000948def OUT8rr : I<0xEE, RawFrm, (outs), (ins),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000949 "out{b}\t{%al, %dx|%DX, %AL}", []>;
950let Uses = [DX, AX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000951def OUT16rr : I<0xEF, RawFrm, (outs), (ins),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000952 "out{w}\t{%ax, %dx|%DX, %AX}", []>, OpSize;
953let Uses = [DX, EAX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000954def OUT32rr : I<0xEF, RawFrm, (outs), (ins),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000955 "out{l}\t{%eax, %dx|%DX, %EAX}", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000956
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000957let Uses = [AL] in
Evan Chengb783fa32007-07-19 01:14:50 +0000958def OUT8ir : Ii8<0xE6, RawFrm, (outs), (ins i16i8imm:$port),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000959 "out{b}\t{%al, $port|$port, %AL}", []>;
960let Uses = [AX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000961def OUT16ir : Ii8<0xE7, RawFrm, (outs), (ins i16i8imm:$port),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000962 "out{w}\t{%ax, $port|$port, %AX}", []>, OpSize;
963let Uses = [EAX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000964def OUT32ir : Ii8<0xE7, RawFrm, (outs), (ins i16i8imm:$port),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000965 "out{l}\t{%eax, $port|$port, %EAX}", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000966
Sean Callanan2c48df22009-12-18 00:01:26 +0000967def IN8 : I<0x6C, RawFrm, (outs), (ins),
968 "ins{b}", []>;
969def IN16 : I<0x6D, RawFrm, (outs), (ins),
970 "ins{w}", []>, OpSize;
971def IN32 : I<0x6D, RawFrm, (outs), (ins),
972 "ins{l}", []>;
973
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000974//===----------------------------------------------------------------------===//
975// Move Instructions...
976//
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000977let neverHasSideEffects = 1 in {
Evan Chengb783fa32007-07-19 01:14:50 +0000978def MOV8rr : I<0x88, MRMDestReg, (outs GR8 :$dst), (ins GR8 :$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000979 "mov{b}\t{$src, $dst|$dst, $src}", []>;
Evan Chengb783fa32007-07-19 01:14:50 +0000980def MOV16rr : I<0x89, MRMDestReg, (outs GR16:$dst), (ins GR16:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000981 "mov{w}\t{$src, $dst|$dst, $src}", []>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +0000982def MOV32rr : I<0x89, MRMDestReg, (outs GR32:$dst), (ins GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000983 "mov{l}\t{$src, $dst|$dst, $src}", []>;
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000984}
Evan Cheng6f26e8b2008-06-18 08:13:07 +0000985let isReMaterializable = 1, isAsCheapAsAMove = 1 in {
Evan Chengb783fa32007-07-19 01:14:50 +0000986def MOV8ri : Ii8 <0xB0, AddRegFrm, (outs GR8 :$dst), (ins i8imm :$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000987 "mov{b}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000988 [(set GR8:$dst, imm:$src)]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000989def MOV16ri : Ii16<0xB8, AddRegFrm, (outs GR16:$dst), (ins i16imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000990 "mov{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000991 [(set GR16:$dst, imm:$src)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +0000992def MOV32ri : Ii32<0xB8, AddRegFrm, (outs GR32:$dst), (ins i32imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000993 "mov{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000994 [(set GR32:$dst, imm:$src)]>;
995}
Evan Chengb783fa32007-07-19 01:14:50 +0000996def MOV8mi : Ii8 <0xC6, MRM0m, (outs), (ins i8mem :$dst, i8imm :$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000997 "mov{b}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000998 [(store (i8 imm:$src), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000999def MOV16mi : Ii16<0xC7, MRM0m, (outs), (ins i16mem:$dst, i16imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001000 "mov{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001001 [(store (i16 imm:$src), addr:$dst)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001002def MOV32mi : Ii32<0xC7, MRM0m, (outs), (ins i32mem:$dst, i32imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001003 "mov{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001004 [(store (i32 imm:$src), addr:$dst)]>;
1005
Sean Callanan2c48df22009-12-18 00:01:26 +00001006def MOV8o8a : Ii8 <0xA0, RawFrm, (outs), (ins offset8:$src),
Sean Callanan70953a52009-09-10 18:33:42 +00001007 "mov{b}\t{$src, %al|%al, $src}", []>;
Sean Callanan2c48df22009-12-18 00:01:26 +00001008def MOV16o16a : Ii16 <0xA1, RawFrm, (outs), (ins offset16:$src),
Sean Callanan70953a52009-09-10 18:33:42 +00001009 "mov{w}\t{$src, %ax|%ax, $src}", []>, OpSize;
Sean Callanan2c48df22009-12-18 00:01:26 +00001010def MOV32o32a : Ii32 <0xA1, RawFrm, (outs), (ins offset32:$src),
Sean Callanan70953a52009-09-10 18:33:42 +00001011 "mov{l}\t{$src, %eax|%eax, $src}", []>;
1012
Sean Callanan2c48df22009-12-18 00:01:26 +00001013def MOV8ao8 : Ii8 <0xA2, RawFrm, (outs offset8:$dst), (ins),
Sean Callanan70953a52009-09-10 18:33:42 +00001014 "mov{b}\t{%al, $dst|$dst, %al}", []>;
Sean Callanan2c48df22009-12-18 00:01:26 +00001015def MOV16ao16 : Ii16 <0xA3, RawFrm, (outs offset16:$dst), (ins),
Sean Callanan70953a52009-09-10 18:33:42 +00001016 "mov{w}\t{%ax, $dst|$dst, %ax}", []>, OpSize;
Sean Callanan2c48df22009-12-18 00:01:26 +00001017def MOV32ao32 : Ii32 <0xA3, RawFrm, (outs offset32:$dst), (ins),
Sean Callanan70953a52009-09-10 18:33:42 +00001018 "mov{l}\t{%eax, $dst|$dst, %eax}", []>;
1019
Sean Callananad87a3a2009-09-15 18:47:29 +00001020// Moves to and from segment registers
1021def MOV16rs : I<0x8C, MRMDestReg, (outs GR16:$dst), (ins SEGMENT_REG:$src),
1022 "mov{w}\t{$src, $dst|$dst, $src}", []>;
1023def MOV16ms : I<0x8C, MRMDestMem, (outs i16mem:$dst), (ins SEGMENT_REG:$src),
1024 "mov{w}\t{$src, $dst|$dst, $src}", []>;
1025def MOV16sr : I<0x8E, MRMSrcReg, (outs SEGMENT_REG:$dst), (ins GR16:$src),
1026 "mov{w}\t{$src, $dst|$dst, $src}", []>;
1027def MOV16sm : I<0x8E, MRMSrcMem, (outs SEGMENT_REG:$dst), (ins i16mem:$src),
1028 "mov{w}\t{$src, $dst|$dst, $src}", []>;
1029
Sean Callanan2c48df22009-12-18 00:01:26 +00001030def MOV8rr_REV : I<0x8A, MRMSrcReg, (outs GR8:$dst), (ins GR8:$src),
1031 "mov{b}\t{$src, $dst|$dst, $src}", []>;
1032def MOV16rr_REV : I<0x8B, MRMSrcReg, (outs GR16:$dst), (ins GR16:$src),
1033 "mov{w}\t{$src, $dst|$dst, $src}", []>, OpSize;
1034def MOV32rr_REV : I<0x8B, MRMSrcReg, (outs GR32:$dst), (ins GR32:$src),
1035 "mov{l}\t{$src, $dst|$dst, $src}", []>;
1036
Dan Gohman5574cc72008-12-03 18:15:48 +00001037let canFoldAsLoad = 1, isReMaterializable = 1, mayHaveSideEffects = 1 in {
Evan Chengb783fa32007-07-19 01:14:50 +00001038def MOV8rm : I<0x8A, MRMSrcMem, (outs GR8 :$dst), (ins i8mem :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001039 "mov{b}\t{$src, $dst|$dst, $src}",
Chris Lattner12208612009-04-10 00:16:23 +00001040 [(set GR8:$dst, (loadi8 addr:$src))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001041def MOV16rm : I<0x8B, MRMSrcMem, (outs GR16:$dst), (ins i16mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001042 "mov{w}\t{$src, $dst|$dst, $src}",
Chris Lattner12208612009-04-10 00:16:23 +00001043 [(set GR16:$dst, (loadi16 addr:$src))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001044def MOV32rm : I<0x8B, MRMSrcMem, (outs GR32:$dst), (ins i32mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001045 "mov{l}\t{$src, $dst|$dst, $src}",
Chris Lattner12208612009-04-10 00:16:23 +00001046 [(set GR32:$dst, (loadi32 addr:$src))]>;
Evan Cheng4e84e452007-08-30 05:49:43 +00001047}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001048
Evan Chengb783fa32007-07-19 01:14:50 +00001049def MOV8mr : I<0x88, MRMDestMem, (outs), (ins i8mem :$dst, GR8 :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001050 "mov{b}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001051 [(store GR8:$src, addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001052def MOV16mr : I<0x89, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001053 "mov{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001054 [(store GR16:$src, addr:$dst)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001055def MOV32mr : I<0x89, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001056 "mov{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001057 [(store GR32:$src, addr:$dst)]>;
Dan Gohman744d4622009-04-13 16:09:41 +00001058
Dan Gohman1d8ce9c2009-04-27 16:41:36 +00001059// Versions of MOV8rr, MOV8mr, and MOV8rm that use i8mem_NOREX and GR8_NOREX so
1060// that they can be used for copying and storing h registers, which can't be
1061// encoded when a REX prefix is present.
Dan Gohman2da0db32009-04-15 00:04:23 +00001062let neverHasSideEffects = 1 in
Dan Gohman40ddc362009-04-15 19:48:57 +00001063def MOV8rr_NOREX : I<0x88, MRMDestReg,
1064 (outs GR8_NOREX:$dst), (ins GR8_NOREX:$src),
Dan Gohman2da0db32009-04-15 00:04:23 +00001065 "mov{b}\t{$src, $dst|$dst, $src} # NOREX", []>;
Evan Chengebc49402009-04-30 00:58:57 +00001066let mayStore = 1 in
Dan Gohman2da0db32009-04-15 00:04:23 +00001067def MOV8mr_NOREX : I<0x88, MRMDestMem,
1068 (outs), (ins i8mem_NOREX:$dst, GR8_NOREX:$src),
1069 "mov{b}\t{$src, $dst|$dst, $src} # NOREX", []>;
Evan Chengebc49402009-04-30 00:58:57 +00001070let mayLoad = 1,
1071 canFoldAsLoad = 1, isReMaterializable = 1, mayHaveSideEffects = 1 in
Dan Gohman1d8ce9c2009-04-27 16:41:36 +00001072def MOV8rm_NOREX : I<0x8A, MRMSrcMem,
1073 (outs GR8_NOREX:$dst), (ins i8mem_NOREX:$src),
1074 "mov{b}\t{$src, $dst|$dst, $src} # NOREX", []>;
Dan Gohman744d4622009-04-13 16:09:41 +00001075
Sean Callanan2c48df22009-12-18 00:01:26 +00001076// Moves to and from debug registers
1077def MOV32rd : I<0x21, MRMDestReg, (outs GR32:$dst), (ins DEBUG_REG:$src),
1078 "mov{l}\t{$src, $dst|$dst, $src}", []>, TB;
1079def MOV32dr : I<0x23, MRMSrcReg, (outs DEBUG_REG:$dst), (ins GR32:$src),
1080 "mov{l}\t{$src, $dst|$dst, $src}", []>, TB;
1081
1082// Moves to and from control registers
1083def MOV32rc : I<0x20, MRMDestReg, (outs GR32:$dst), (ins CONTROL_REG_32:$src),
1084 "mov{q}\t{$src, $dst|$dst, $src}", []>, TB;
1085def MOV32cr : I<0x22, MRMSrcReg, (outs CONTROL_REG_32:$dst), (ins GR32:$src),
1086 "mov{q}\t{$src, $dst|$dst, $src}", []>, TB;
1087
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001088//===----------------------------------------------------------------------===//
1089// Fixed-Register Multiplication and Division Instructions...
1090//
1091
1092// Extra precision multiplication
Evan Cheng55687072007-09-14 21:48:26 +00001093let Defs = [AL,AH,EFLAGS], Uses = [AL] in
Dan Gohman91888f02007-07-31 20:11:57 +00001094def MUL8r : I<0xF6, MRM4r, (outs), (ins GR8:$src), "mul{b}\t$src",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001095 // FIXME: Used for 8-bit mul, ignore result upper 8 bits.
1096 // This probably ought to be moved to a def : Pat<> if the
1097 // syntax can be accepted.
Bill Wendlingf5399032008-12-12 21:15:41 +00001098 [(set AL, (mul AL, GR8:$src)),
1099 (implicit EFLAGS)]>; // AL,AH = AL*GR8
1100
Chris Lattnerc7e96e72008-01-11 07:18:17 +00001101let Defs = [AX,DX,EFLAGS], Uses = [AX], neverHasSideEffects = 1 in
Bill Wendlingf5399032008-12-12 21:15:41 +00001102def MUL16r : I<0xF7, MRM4r, (outs), (ins GR16:$src),
1103 "mul{w}\t$src",
1104 []>, OpSize; // AX,DX = AX*GR16
1105
Chris Lattnerc7e96e72008-01-11 07:18:17 +00001106let Defs = [EAX,EDX,EFLAGS], Uses = [EAX], neverHasSideEffects = 1 in
Bill Wendlingf5399032008-12-12 21:15:41 +00001107def MUL32r : I<0xF7, MRM4r, (outs), (ins GR32:$src),
1108 "mul{l}\t$src",
1109 []>; // EAX,EDX = EAX*GR32
1110
Evan Cheng55687072007-09-14 21:48:26 +00001111let Defs = [AL,AH,EFLAGS], Uses = [AL] in
Evan Chengb783fa32007-07-19 01:14:50 +00001112def MUL8m : I<0xF6, MRM4m, (outs), (ins i8mem :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001113 "mul{b}\t$src",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001114 // FIXME: Used for 8-bit mul, ignore result upper 8 bits.
1115 // This probably ought to be moved to a def : Pat<> if the
1116 // syntax can be accepted.
Bill Wendlingf5399032008-12-12 21:15:41 +00001117 [(set AL, (mul AL, (loadi8 addr:$src))),
1118 (implicit EFLAGS)]>; // AL,AH = AL*[mem8]
1119
Chris Lattnerc90ee9c2008-01-10 07:59:24 +00001120let mayLoad = 1, neverHasSideEffects = 1 in {
Evan Cheng55687072007-09-14 21:48:26 +00001121let Defs = [AX,DX,EFLAGS], Uses = [AX] in
Evan Chengb783fa32007-07-19 01:14:50 +00001122def MUL16m : I<0xF7, MRM4m, (outs), (ins i16mem:$src),
Bill Wendlingf5399032008-12-12 21:15:41 +00001123 "mul{w}\t$src",
1124 []>, OpSize; // AX,DX = AX*[mem16]
1125
Evan Cheng55687072007-09-14 21:48:26 +00001126let Defs = [EAX,EDX,EFLAGS], Uses = [EAX] in
Evan Chengb783fa32007-07-19 01:14:50 +00001127def MUL32m : I<0xF7, MRM4m, (outs), (ins i32mem:$src),
Bill Wendlingf5399032008-12-12 21:15:41 +00001128 "mul{l}\t$src",
1129 []>; // EAX,EDX = EAX*[mem32]
Chris Lattnerc90ee9c2008-01-10 07:59:24 +00001130}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001131
Chris Lattnerc90ee9c2008-01-10 07:59:24 +00001132let neverHasSideEffects = 1 in {
Evan Cheng55687072007-09-14 21:48:26 +00001133let Defs = [AL,AH,EFLAGS], Uses = [AL] in
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001134def IMUL8r : I<0xF6, MRM5r, (outs), (ins GR8:$src), "imul{b}\t$src", []>;
1135 // AL,AH = AL*GR8
Evan Cheng55687072007-09-14 21:48:26 +00001136let Defs = [AX,DX,EFLAGS], Uses = [AX] in
Dan Gohman91888f02007-07-31 20:11:57 +00001137def IMUL16r : I<0xF7, MRM5r, (outs), (ins GR16:$src), "imul{w}\t$src", []>,
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001138 OpSize; // AX,DX = AX*GR16
Evan Cheng55687072007-09-14 21:48:26 +00001139let Defs = [EAX,EDX,EFLAGS], Uses = [EAX] in
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001140def IMUL32r : I<0xF7, MRM5r, (outs), (ins GR32:$src), "imul{l}\t$src", []>;
1141 // EAX,EDX = EAX*GR32
Chris Lattnerc90ee9c2008-01-10 07:59:24 +00001142let mayLoad = 1 in {
Evan Cheng55687072007-09-14 21:48:26 +00001143let Defs = [AL,AH,EFLAGS], Uses = [AL] in
Evan Chengb783fa32007-07-19 01:14:50 +00001144def IMUL8m : I<0xF6, MRM5m, (outs), (ins i8mem :$src),
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001145 "imul{b}\t$src", []>; // AL,AH = AL*[mem8]
Evan Cheng55687072007-09-14 21:48:26 +00001146let Defs = [AX,DX,EFLAGS], Uses = [AX] in
Evan Chengb783fa32007-07-19 01:14:50 +00001147def IMUL16m : I<0xF7, MRM5m, (outs), (ins i16mem:$src),
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001148 "imul{w}\t$src", []>, OpSize; // AX,DX = AX*[mem16]
Eli Friedman3939db02009-12-26 20:08:30 +00001149let Defs = [EAX,EDX,EFLAGS], Uses = [EAX] in
Evan Chengb783fa32007-07-19 01:14:50 +00001150def IMUL32m : I<0xF7, MRM5m, (outs), (ins i32mem:$src),
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001151 "imul{l}\t$src", []>; // EAX,EDX = EAX*[mem32]
Chris Lattnerc90ee9c2008-01-10 07:59:24 +00001152}
Dan Gohmand44572d2008-11-18 21:29:14 +00001153} // neverHasSideEffects
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001154
1155// unsigned division/remainder
Dale Johannesend8fd3562008-10-07 18:54:28 +00001156let Defs = [AL,AH,EFLAGS], Uses = [AX] in
Sean Callanan2c48df22009-12-18 00:01:26 +00001157def DIV8r : I<0xF6, MRM6r, (outs), (ins GR8:$src), // AX/r8 = AL,AH
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001158 "div{b}\t$src", []>;
Evan Cheng55687072007-09-14 21:48:26 +00001159let Defs = [AX,DX,EFLAGS], Uses = [AX,DX] in
Sean Callanan2c48df22009-12-18 00:01:26 +00001160def DIV16r : I<0xF7, MRM6r, (outs), (ins GR16:$src), // DX:AX/r16 = AX,DX
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001161 "div{w}\t$src", []>, OpSize;
Evan Cheng55687072007-09-14 21:48:26 +00001162let Defs = [EAX,EDX,EFLAGS], Uses = [EAX,EDX] in
Sean Callanan2c48df22009-12-18 00:01:26 +00001163def DIV32r : I<0xF7, MRM6r, (outs), (ins GR32:$src), // EDX:EAX/r32 = EAX,EDX
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001164 "div{l}\t$src", []>;
Chris Lattnerc90ee9c2008-01-10 07:59:24 +00001165let mayLoad = 1 in {
Dale Johannesend8fd3562008-10-07 18:54:28 +00001166let Defs = [AL,AH,EFLAGS], Uses = [AX] in
Sean Callanan2c48df22009-12-18 00:01:26 +00001167def DIV8m : I<0xF6, MRM6m, (outs), (ins i8mem:$src), // AX/[mem8] = AL,AH
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001168 "div{b}\t$src", []>;
Evan Cheng55687072007-09-14 21:48:26 +00001169let Defs = [AX,DX,EFLAGS], Uses = [AX,DX] in
Sean Callanan2c48df22009-12-18 00:01:26 +00001170def DIV16m : I<0xF7, MRM6m, (outs), (ins i16mem:$src), // DX:AX/[mem16] = AX,DX
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001171 "div{w}\t$src", []>, OpSize;
Evan Cheng55687072007-09-14 21:48:26 +00001172let Defs = [EAX,EDX,EFLAGS], Uses = [EAX,EDX] in
Sean Callanan2c48df22009-12-18 00:01:26 +00001173 // EDX:EAX/[mem32] = EAX,EDX
1174def DIV32m : I<0xF7, MRM6m, (outs), (ins i32mem:$src),
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001175 "div{l}\t$src", []>;
Chris Lattnerc90ee9c2008-01-10 07:59:24 +00001176}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001177
1178// Signed division/remainder.
Dale Johannesend8fd3562008-10-07 18:54:28 +00001179let Defs = [AL,AH,EFLAGS], Uses = [AX] in
Sean Callanan2c48df22009-12-18 00:01:26 +00001180def IDIV8r : I<0xF6, MRM7r, (outs), (ins GR8:$src), // AX/r8 = AL,AH
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001181 "idiv{b}\t$src", []>;
Evan Cheng55687072007-09-14 21:48:26 +00001182let Defs = [AX,DX,EFLAGS], Uses = [AX,DX] in
Sean Callanan2c48df22009-12-18 00:01:26 +00001183def IDIV16r: I<0xF7, MRM7r, (outs), (ins GR16:$src), // DX:AX/r16 = AX,DX
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001184 "idiv{w}\t$src", []>, OpSize;
Evan Cheng55687072007-09-14 21:48:26 +00001185let Defs = [EAX,EDX,EFLAGS], Uses = [EAX,EDX] in
Sean Callanan2c48df22009-12-18 00:01:26 +00001186def IDIV32r: I<0xF7, MRM7r, (outs), (ins GR32:$src), // EDX:EAX/r32 = EAX,EDX
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001187 "idiv{l}\t$src", []>;
Chris Lattnerc90ee9c2008-01-10 07:59:24 +00001188let mayLoad = 1, mayLoad = 1 in {
Dale Johannesend8fd3562008-10-07 18:54:28 +00001189let Defs = [AL,AH,EFLAGS], Uses = [AX] in
Sean Callanan2c48df22009-12-18 00:01:26 +00001190def IDIV8m : I<0xF6, MRM7m, (outs), (ins i8mem:$src), // AX/[mem8] = AL,AH
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001191 "idiv{b}\t$src", []>;
Evan Cheng55687072007-09-14 21:48:26 +00001192let Defs = [AX,DX,EFLAGS], Uses = [AX,DX] in
Sean Callanan2c48df22009-12-18 00:01:26 +00001193def IDIV16m: I<0xF7, MRM7m, (outs), (ins i16mem:$src), // DX:AX/[mem16] = AX,DX
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001194 "idiv{w}\t$src", []>, OpSize;
Evan Cheng55687072007-09-14 21:48:26 +00001195let Defs = [EAX,EDX,EFLAGS], Uses = [EAX,EDX] in
Sean Callanan2c48df22009-12-18 00:01:26 +00001196def IDIV32m: I<0xF7, MRM7m, (outs), (ins i32mem:$src),
1197 // EDX:EAX/[mem32] = EAX,EDX
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001198 "idiv{l}\t$src", []>;
Chris Lattnerc90ee9c2008-01-10 07:59:24 +00001199}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001200
1201//===----------------------------------------------------------------------===//
Chris Lattnerc90ee9c2008-01-10 07:59:24 +00001202// Two address Instructions.
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001203//
1204let isTwoAddress = 1 in {
1205
1206// Conditional moves
Evan Cheng950aac02007-09-25 01:57:46 +00001207let Uses = [EFLAGS] in {
Dan Gohman29b998f2009-08-27 00:14:12 +00001208
Dan Gohman30afe012009-10-29 18:10:34 +00001209// X86 doesn't have 8-bit conditional moves. Use a customInserter to
Dan Gohman29b998f2009-08-27 00:14:12 +00001210// emit control flow. An alternative to this is to mark i8 SELECT as Promote,
1211// however that requires promoting the operands, and can induce additional
Dan Gohman1596dd22009-08-29 22:19:15 +00001212// i8 register pressure. Note that CMOV_GR8 is conservatively considered to
1213// clobber EFLAGS, because if one of the operands is zero, the expansion
1214// could involve an xor.
Dan Gohman30afe012009-10-29 18:10:34 +00001215let usesCustomInserter = 1, isTwoAddress = 0, Defs = [EFLAGS] in
Dan Gohman29b998f2009-08-27 00:14:12 +00001216def CMOV_GR8 : I<0, Pseudo,
1217 (outs GR8:$dst), (ins GR8:$src1, GR8:$src2, i8imm:$cond),
1218 "#CMOV_GR8 PSEUDO!",
1219 [(set GR8:$dst, (X86cmov GR8:$src1, GR8:$src2,
1220 imm:$cond, EFLAGS))]>;
1221
Dan Gohman90adb6c2009-08-27 18:16:24 +00001222let isCommutable = 1 in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001223def CMOVB16rr : I<0x42, 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 "cmovb{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_B, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001228 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001229def CMOVB32rr : I<0x42, 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 "cmovb{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_B, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001234 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001235def CMOVAE16rr: I<0x43, MRMSrcReg, // if >=u, 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 "cmovae{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_AE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001240 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001241def CMOVAE32rr: I<0x43, MRMSrcReg, // if >=u, 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 "cmovae{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_AE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001246 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001247def CMOVE16rr : I<0x44, 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 "cmove{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_E, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001252 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001253def CMOVE32rr : I<0x44, 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 "cmove{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_E, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001258 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001259def CMOVNE16rr: I<0x45, MRMSrcReg, // if !=, 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 "cmovne{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_NE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001264 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001265def CMOVNE32rr: I<0x45, MRMSrcReg, // if !=, 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 "cmovne{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_NE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001270 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001271def CMOVBE16rr: I<0x46, 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 "cmovbe{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_BE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001276 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001277def CMOVBE32rr: I<0x46, 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 "cmovbe{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_BE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001282 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001283def CMOVA16rr : I<0x47, MRMSrcReg, // if >u, 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 "cmova{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_A, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001288 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001289def CMOVA32rr : I<0x47, MRMSrcReg, // if >u, 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 "cmova{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_A, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001294 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001295def CMOVL16rr : I<0x4C, 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 "cmovl{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_L, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001300 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001301def CMOVL32rr : I<0x4C, 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 "cmovl{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_L, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001306 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001307def CMOVGE16rr: I<0x4D, 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 "cmovge{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_GE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001312 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001313def CMOVGE32rr: I<0x4D, 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 "cmovge{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_GE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001318 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001319def CMOVLE16rr: I<0x4E, 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 "cmovle{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_LE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001324 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001325def CMOVLE32rr: I<0x4E, 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 "cmovle{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_LE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001330 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001331def CMOVG16rr : I<0x4F, MRMSrcReg, // if >s, 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 "cmovg{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_G, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001336 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001337def CMOVG32rr : I<0x4F, MRMSrcReg, // if >s, 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 "cmovg{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_G, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001342 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001343def CMOVS16rr : I<0x48, 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 "cmovs{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_S, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001348 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001349def CMOVS32rr : I<0x48, 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 "cmovs{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_S, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001354 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001355def CMOVNS16rr: I<0x49, MRMSrcReg, // if !signed, 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 "cmovns{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_NS, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001360 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001361def CMOVNS32rr: I<0x49, MRMSrcReg, // if !signed, 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 "cmovns{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_NS, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001366 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001367def CMOVP16rr : I<0x4A, 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 "cmovp{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_P, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001372 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001373def CMOVP32rr : I<0x4A, 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 "cmovp{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_P, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001378 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001379def CMOVNP16rr : I<0x4B, MRMSrcReg, // if !parity, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +00001380 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Sean Callanan2c48df22009-12-18 00:01:26 +00001381 "cmovnp{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001382 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001383 X86_COND_NP, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001384 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001385def CMOVNP32rr : I<0x4B, MRMSrcReg, // if !parity, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +00001386 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Sean Callanan2c48df22009-12-18 00:01:26 +00001387 "cmovnp{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001388 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001389 X86_COND_NP, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001390 TB;
Dan Gohman12fd4d72009-01-07 00:35:10 +00001391def CMOVO16rr : I<0x40, MRMSrcReg, // if overflow, GR16 = GR16
1392 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Sean Callanan2c48df22009-12-18 00:01:26 +00001393 "cmovo{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_O, EFLAGS))]>,
1396 TB, OpSize;
1397def CMOVO32rr : I<0x40, MRMSrcReg, // if overflow, GR32 = GR32
1398 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Sean Callanan2c48df22009-12-18 00:01:26 +00001399 "cmovo{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_O, EFLAGS))]>,
Evan Cheng950aac02007-09-25 01:57:46 +00001402 TB;
Dan Gohman12fd4d72009-01-07 00:35:10 +00001403def CMOVNO16rr : I<0x41, MRMSrcReg, // if !overflow, GR16 = GR16
1404 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Sean Callanan2c48df22009-12-18 00:01:26 +00001405 "cmovno{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohman12fd4d72009-01-07 00:35:10 +00001406 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
1407 X86_COND_NO, EFLAGS))]>,
1408 TB, OpSize;
1409def CMOVNO32rr : I<0x41, MRMSrcReg, // if !overflow, GR32 = GR32
1410 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Sean Callanan2c48df22009-12-18 00:01:26 +00001411 "cmovno{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohman12fd4d72009-01-07 00:35:10 +00001412 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
1413 X86_COND_NO, EFLAGS))]>,
1414 TB;
1415} // isCommutable = 1
Evan Cheng926658c2007-10-05 23:13:21 +00001416
1417def CMOVB16rm : I<0x42, MRMSrcMem, // if <u, GR16 = [mem16]
1418 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
Sean Callanan2c48df22009-12-18 00:01:26 +00001419 "cmovb{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_B, EFLAGS))]>,
1422 TB, OpSize;
1423def CMOVB32rm : I<0x42, MRMSrcMem, // if <u, GR32 = [mem32]
1424 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Sean Callanan2c48df22009-12-18 00:01:26 +00001425 "cmovb{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_B, EFLAGS))]>,
1428 TB;
1429def CMOVAE16rm: I<0x43, MRMSrcMem, // if >=u, GR16 = [mem16]
1430 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
Sean Callanan2c48df22009-12-18 00:01:26 +00001431 "cmovae{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_AE, EFLAGS))]>,
1434 TB, OpSize;
1435def CMOVAE32rm: I<0x43, MRMSrcMem, // if >=u, GR32 = [mem32]
1436 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Sean Callanan2c48df22009-12-18 00:01:26 +00001437 "cmovae{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_AE, EFLAGS))]>,
1440 TB;
1441def CMOVE16rm : I<0x44, MRMSrcMem, // if ==, GR16 = [mem16]
1442 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
Sean Callanan2c48df22009-12-18 00:01:26 +00001443 "cmove{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_E, EFLAGS))]>,
1446 TB, OpSize;
1447def CMOVE32rm : I<0x44, MRMSrcMem, // if ==, GR32 = [mem32]
1448 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Sean Callanan2c48df22009-12-18 00:01:26 +00001449 "cmove{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_E, EFLAGS))]>,
1452 TB;
1453def CMOVNE16rm: I<0x45, MRMSrcMem, // if !=, GR16 = [mem16]
1454 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
Sean Callanan2c48df22009-12-18 00:01:26 +00001455 "cmovne{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_NE, EFLAGS))]>,
1458 TB, OpSize;
1459def CMOVNE32rm: I<0x45, MRMSrcMem, // if !=, GR32 = [mem32]
1460 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Sean Callanan2c48df22009-12-18 00:01:26 +00001461 "cmovne{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_NE, EFLAGS))]>,
1464 TB;
1465def CMOVBE16rm: I<0x46, MRMSrcMem, // if <=u, GR16 = [mem16]
1466 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
Sean Callanan2c48df22009-12-18 00:01:26 +00001467 "cmovbe{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_BE, EFLAGS))]>,
1470 TB, OpSize;
1471def CMOVBE32rm: I<0x46, MRMSrcMem, // if <=u, GR32 = [mem32]
1472 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Sean Callanan2c48df22009-12-18 00:01:26 +00001473 "cmovbe{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_BE, EFLAGS))]>,
1476 TB;
1477def CMOVA16rm : I<0x47, MRMSrcMem, // if >u, GR16 = [mem16]
1478 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
Sean Callanan2c48df22009-12-18 00:01:26 +00001479 "cmova{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_A, EFLAGS))]>,
1482 TB, OpSize;
1483def CMOVA32rm : I<0x47, MRMSrcMem, // if >u, GR32 = [mem32]
1484 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Sean Callanan2c48df22009-12-18 00:01:26 +00001485 "cmova{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_A, EFLAGS))]>,
1488 TB;
1489def CMOVL16rm : I<0x4C, MRMSrcMem, // if <s, GR16 = [mem16]
1490 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
Sean Callanan2c48df22009-12-18 00:01:26 +00001491 "cmovl{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_L, EFLAGS))]>,
1494 TB, OpSize;
1495def CMOVL32rm : I<0x4C, MRMSrcMem, // if <s, GR32 = [mem32]
1496 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Sean Callanan2c48df22009-12-18 00:01:26 +00001497 "cmovl{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_L, EFLAGS))]>,
1500 TB;
1501def CMOVGE16rm: I<0x4D, MRMSrcMem, // if >=s, GR16 = [mem16]
1502 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
Sean Callanan2c48df22009-12-18 00:01:26 +00001503 "cmovge{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_GE, EFLAGS))]>,
1506 TB, OpSize;
1507def CMOVGE32rm: I<0x4D, MRMSrcMem, // if >=s, GR32 = [mem32]
1508 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Sean Callanan2c48df22009-12-18 00:01:26 +00001509 "cmovge{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_GE, EFLAGS))]>,
1512 TB;
1513def CMOVLE16rm: I<0x4E, MRMSrcMem, // if <=s, GR16 = [mem16]
1514 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
Sean Callanan2c48df22009-12-18 00:01:26 +00001515 "cmovle{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_LE, EFLAGS))]>,
1518 TB, OpSize;
1519def CMOVLE32rm: I<0x4E, MRMSrcMem, // if <=s, GR32 = [mem32]
1520 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Sean Callanan2c48df22009-12-18 00:01:26 +00001521 "cmovle{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_LE, EFLAGS))]>,
1524 TB;
1525def CMOVG16rm : I<0x4F, MRMSrcMem, // if >s, GR16 = [mem16]
1526 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
Sean Callanan2c48df22009-12-18 00:01:26 +00001527 "cmovg{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_G, EFLAGS))]>,
1530 TB, OpSize;
1531def CMOVG32rm : I<0x4F, MRMSrcMem, // if >s, GR32 = [mem32]
1532 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Sean Callanan2c48df22009-12-18 00:01:26 +00001533 "cmovg{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_G, EFLAGS))]>,
1536 TB;
1537def CMOVS16rm : I<0x48, MRMSrcMem, // if signed, GR16 = [mem16]
1538 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
Sean Callanan2c48df22009-12-18 00:01:26 +00001539 "cmovs{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_S, EFLAGS))]>,
1542 TB, OpSize;
1543def CMOVS32rm : I<0x48, MRMSrcMem, // if signed, GR32 = [mem32]
1544 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Sean Callanan2c48df22009-12-18 00:01:26 +00001545 "cmovs{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_S, EFLAGS))]>,
1548 TB;
1549def CMOVNS16rm: I<0x49, MRMSrcMem, // if !signed, GR16 = [mem16]
1550 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
Sean Callanan2c48df22009-12-18 00:01:26 +00001551 "cmovns{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_NS, EFLAGS))]>,
1554 TB, OpSize;
1555def CMOVNS32rm: I<0x49, MRMSrcMem, // if !signed, GR32 = [mem32]
1556 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Sean Callanan2c48df22009-12-18 00:01:26 +00001557 "cmovns{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_NS, EFLAGS))]>,
1560 TB;
1561def CMOVP16rm : I<0x4A, MRMSrcMem, // if parity, GR16 = [mem16]
1562 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
Sean Callanan2c48df22009-12-18 00:01:26 +00001563 "cmovp{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_P, EFLAGS))]>,
1566 TB, OpSize;
1567def CMOVP32rm : I<0x4A, MRMSrcMem, // if parity, GR32 = [mem32]
1568 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Sean Callanan2c48df22009-12-18 00:01:26 +00001569 "cmovp{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng926658c2007-10-05 23:13:21 +00001570 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1571 X86_COND_P, EFLAGS))]>,
1572 TB;
1573def CMOVNP16rm : I<0x4B, MRMSrcMem, // if !parity, GR16 = [mem16]
1574 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
Sean Callanan2c48df22009-12-18 00:01:26 +00001575 "cmovnp{w}\t{$src2, $dst|$dst, $src2}",
Evan Cheng926658c2007-10-05 23:13:21 +00001576 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1577 X86_COND_NP, EFLAGS))]>,
1578 TB, OpSize;
Dan Gohman12fd4d72009-01-07 00:35:10 +00001579def CMOVNP32rm : I<0x4B, MRMSrcMem, // if !parity, GR32 = [mem32]
1580 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Sean Callanan2c48df22009-12-18 00:01:26 +00001581 "cmovnp{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_NP, EFLAGS))]>,
1584 TB;
1585def CMOVO16rm : I<0x40, MRMSrcMem, // if overflow, GR16 = [mem16]
1586 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
Sean Callanan2c48df22009-12-18 00:01:26 +00001587 "cmovo{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_O, EFLAGS))]>,
1590 TB, OpSize;
1591def CMOVO32rm : I<0x40, MRMSrcMem, // if overflow, GR32 = [mem32]
1592 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Sean Callanan2c48df22009-12-18 00:01:26 +00001593 "cmovo{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_O, EFLAGS))]>,
1596 TB;
1597def CMOVNO16rm : I<0x41, MRMSrcMem, // if !overflow, GR16 = [mem16]
1598 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
Sean Callanan2c48df22009-12-18 00:01:26 +00001599 "cmovno{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohman12fd4d72009-01-07 00:35:10 +00001600 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1601 X86_COND_NO, EFLAGS))]>,
1602 TB, OpSize;
1603def CMOVNO32rm : I<0x41, MRMSrcMem, // if !overflow, GR32 = [mem32]
1604 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Sean Callanan2c48df22009-12-18 00:01:26 +00001605 "cmovno{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohman12fd4d72009-01-07 00:35:10 +00001606 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1607 X86_COND_NO, EFLAGS))]>,
1608 TB;
Evan Cheng950aac02007-09-25 01:57:46 +00001609} // Uses = [EFLAGS]
1610
1611
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001612// unary instructions
1613let CodeSize = 2 in {
Evan Cheng55687072007-09-14 21:48:26 +00001614let Defs = [EFLAGS] in {
Dan Gohman91888f02007-07-31 20:11:57 +00001615def NEG8r : I<0xF6, MRM3r, (outs GR8 :$dst), (ins GR8 :$src), "neg{b}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001616 [(set GR8:$dst, (ineg GR8:$src)),
1617 (implicit EFLAGS)]>;
Dan Gohman91888f02007-07-31 20:11:57 +00001618def NEG16r : I<0xF7, MRM3r, (outs GR16:$dst), (ins GR16:$src), "neg{w}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001619 [(set GR16:$dst, (ineg GR16:$src)),
1620 (implicit EFLAGS)]>, OpSize;
Dan Gohman91888f02007-07-31 20:11:57 +00001621def NEG32r : I<0xF7, MRM3r, (outs GR32:$dst), (ins GR32:$src), "neg{l}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001622 [(set GR32:$dst, (ineg GR32:$src)),
1623 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001624let isTwoAddress = 0 in {
Dan Gohman91888f02007-07-31 20:11:57 +00001625 def NEG8m : I<0xF6, MRM3m, (outs), (ins i8mem :$dst), "neg{b}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001626 [(store (ineg (loadi8 addr:$dst)), addr:$dst),
1627 (implicit EFLAGS)]>;
Dan Gohman91888f02007-07-31 20:11:57 +00001628 def NEG16m : I<0xF7, MRM3m, (outs), (ins i16mem:$dst), "neg{w}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001629 [(store (ineg (loadi16 addr:$dst)), addr:$dst),
1630 (implicit EFLAGS)]>, OpSize;
Dan Gohman91888f02007-07-31 20:11:57 +00001631 def NEG32m : I<0xF7, MRM3m, (outs), (ins i32mem:$dst), "neg{l}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001632 [(store (ineg (loadi32 addr:$dst)), addr:$dst),
1633 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001634}
Evan Cheng55687072007-09-14 21:48:26 +00001635} // Defs = [EFLAGS]
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001636
Evan Chengc6cee682009-01-21 02:09:05 +00001637// Match xor -1 to not. Favors these over a move imm + xor to save code size.
1638let AddedComplexity = 15 in {
Dan Gohman91888f02007-07-31 20:11:57 +00001639def NOT8r : I<0xF6, MRM2r, (outs GR8 :$dst), (ins GR8 :$src), "not{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001640 [(set GR8:$dst, (not GR8:$src))]>;
Dan Gohman91888f02007-07-31 20:11:57 +00001641def NOT16r : I<0xF7, MRM2r, (outs GR16:$dst), (ins GR16:$src), "not{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001642 [(set GR16:$dst, (not GR16:$src))]>, OpSize;
Dan Gohman91888f02007-07-31 20:11:57 +00001643def NOT32r : I<0xF7, MRM2r, (outs GR32:$dst), (ins GR32:$src), "not{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001644 [(set GR32:$dst, (not GR32:$src))]>;
Evan Chengc6cee682009-01-21 02:09:05 +00001645}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001646let isTwoAddress = 0 in {
Dan Gohman91888f02007-07-31 20:11:57 +00001647 def NOT8m : I<0xF6, MRM2m, (outs), (ins i8mem :$dst), "not{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001648 [(store (not (loadi8 addr:$dst)), addr:$dst)]>;
Dan Gohman91888f02007-07-31 20:11:57 +00001649 def NOT16m : I<0xF7, MRM2m, (outs), (ins i16mem:$dst), "not{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001650 [(store (not (loadi16 addr:$dst)), addr:$dst)]>, OpSize;
Dan Gohman91888f02007-07-31 20:11:57 +00001651 def NOT32m : I<0xF7, MRM2m, (outs), (ins i32mem:$dst), "not{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001652 [(store (not (loadi32 addr:$dst)), addr:$dst)]>;
1653}
1654} // CodeSize
1655
1656// TODO: inc/dec is slow for P4, but fast for Pentium-M.
Evan Cheng55687072007-09-14 21:48:26 +00001657let Defs = [EFLAGS] in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001658let CodeSize = 2 in
Dan Gohman91888f02007-07-31 20:11:57 +00001659def INC8r : I<0xFE, MRM0r, (outs GR8 :$dst), (ins GR8 :$src), "inc{b}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001660 [(set GR8:$dst, (add GR8:$src, 1)),
1661 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001662let isConvertibleToThreeAddress = 1, CodeSize = 1 in { // Can xform into LEA.
Sean Callanan2c48df22009-12-18 00:01:26 +00001663def INC16r : I<0x40, AddRegFrm, (outs GR16:$dst), (ins GR16:$src),
1664 "inc{w}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001665 [(set GR16:$dst, (add GR16:$src, 1)),
1666 (implicit EFLAGS)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001667 OpSize, Requires<[In32BitMode]>;
Sean Callanan2c48df22009-12-18 00:01:26 +00001668def INC32r : I<0x40, AddRegFrm, (outs GR32:$dst), (ins GR32:$src),
1669 "inc{l}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001670 [(set GR32:$dst, (add GR32:$src, 1)),
1671 (implicit EFLAGS)]>, Requires<[In32BitMode]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001672}
1673let isTwoAddress = 0, CodeSize = 2 in {
Dan Gohman91888f02007-07-31 20:11:57 +00001674 def INC8m : I<0xFE, MRM0m, (outs), (ins i8mem :$dst), "inc{b}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001675 [(store (add (loadi8 addr:$dst), 1), addr:$dst),
1676 (implicit EFLAGS)]>;
Dan Gohman91888f02007-07-31 20:11:57 +00001677 def INC16m : I<0xFF, MRM0m, (outs), (ins i16mem:$dst), "inc{w}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001678 [(store (add (loadi16 addr:$dst), 1), addr:$dst),
1679 (implicit EFLAGS)]>,
Evan Cheng4a7e72f2007-10-19 21:23:22 +00001680 OpSize, Requires<[In32BitMode]>;
Dan Gohman91888f02007-07-31 20:11:57 +00001681 def INC32m : I<0xFF, MRM0m, (outs), (ins i32mem:$dst), "inc{l}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001682 [(store (add (loadi32 addr:$dst), 1), addr:$dst),
1683 (implicit EFLAGS)]>,
Evan Cheng4a7e72f2007-10-19 21:23:22 +00001684 Requires<[In32BitMode]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001685}
1686
1687let CodeSize = 2 in
Dan Gohman91888f02007-07-31 20:11:57 +00001688def DEC8r : I<0xFE, MRM1r, (outs GR8 :$dst), (ins GR8 :$src), "dec{b}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001689 [(set GR8:$dst, (add GR8:$src, -1)),
1690 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001691let isConvertibleToThreeAddress = 1, CodeSize = 1 in { // Can xform into LEA.
Sean Callanan2c48df22009-12-18 00:01:26 +00001692def DEC16r : I<0x48, AddRegFrm, (outs GR16:$dst), (ins GR16:$src),
1693 "dec{w}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001694 [(set GR16:$dst, (add GR16:$src, -1)),
1695 (implicit EFLAGS)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001696 OpSize, Requires<[In32BitMode]>;
Sean Callanan2c48df22009-12-18 00:01:26 +00001697def DEC32r : I<0x48, AddRegFrm, (outs GR32:$dst), (ins GR32:$src),
1698 "dec{l}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001699 [(set GR32:$dst, (add GR32:$src, -1)),
1700 (implicit EFLAGS)]>, Requires<[In32BitMode]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001701}
1702
1703let isTwoAddress = 0, CodeSize = 2 in {
Dan Gohman91888f02007-07-31 20:11:57 +00001704 def DEC8m : I<0xFE, MRM1m, (outs), (ins i8mem :$dst), "dec{b}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001705 [(store (add (loadi8 addr:$dst), -1), addr:$dst),
1706 (implicit EFLAGS)]>;
Dan Gohman91888f02007-07-31 20:11:57 +00001707 def DEC16m : I<0xFF, MRM1m, (outs), (ins i16mem:$dst), "dec{w}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001708 [(store (add (loadi16 addr:$dst), -1), addr:$dst),
1709 (implicit EFLAGS)]>,
Evan Cheng4a7e72f2007-10-19 21:23:22 +00001710 OpSize, Requires<[In32BitMode]>;
Dan Gohman91888f02007-07-31 20:11:57 +00001711 def DEC32m : I<0xFF, MRM1m, (outs), (ins i32mem:$dst), "dec{l}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001712 [(store (add (loadi32 addr:$dst), -1), addr:$dst),
1713 (implicit EFLAGS)]>,
Evan Cheng4a7e72f2007-10-19 21:23:22 +00001714 Requires<[In32BitMode]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001715}
Evan Cheng55687072007-09-14 21:48:26 +00001716} // Defs = [EFLAGS]
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001717
1718// Logical operators...
Evan Cheng55687072007-09-14 21:48:26 +00001719let Defs = [EFLAGS] in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001720let isCommutable = 1 in { // X = AND Y, Z --> X = AND Z, Y
1721def AND8rr : I<0x20, MRMDestReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001722 (outs GR8 :$dst), (ins GR8 :$src1, GR8 :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001723 "and{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001724 [(set GR8:$dst, (and GR8:$src1, GR8:$src2)),
1725 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001726def AND16rr : I<0x21, MRMDestReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001727 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001728 "and{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001729 [(set GR16:$dst, (and GR16:$src1, GR16:$src2)),
1730 (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001731def AND32rr : I<0x21, MRMDestReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001732 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001733 "and{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001734 [(set GR32:$dst, (and GR32:$src1, GR32:$src2)),
1735 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001736}
1737
Sean Callanan2c48df22009-12-18 00:01:26 +00001738// AND instructions with the destination register in REG and the source register
1739// in R/M. Included for the disassembler.
1740def AND8rr_REV : I<0x22, MRMSrcReg, (outs GR8:$dst), (ins GR8:$src1, GR8:$src2),
1741 "and{b}\t{$src2, $dst|$dst, $src2}", []>;
1742def AND16rr_REV : I<0x23, MRMSrcReg, (outs GR16:$dst),
1743 (ins GR16:$src1, GR16:$src2),
1744 "and{w}\t{$src2, $dst|$dst, $src2}", []>, OpSize;
1745def AND32rr_REV : I<0x23, MRMSrcReg, (outs GR32:$dst),
1746 (ins GR32:$src1, GR32:$src2),
1747 "and{l}\t{$src2, $dst|$dst, $src2}", []>;
1748
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001749def AND8rm : I<0x22, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001750 (outs GR8 :$dst), (ins GR8 :$src1, i8mem :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001751 "and{b}\t{$src2, $dst|$dst, $src2}",
Chris Lattner12208612009-04-10 00:16:23 +00001752 [(set GR8:$dst, (and GR8:$src1, (loadi8 addr:$src2))),
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001753 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001754def AND16rm : I<0x23, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001755 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001756 "and{w}\t{$src2, $dst|$dst, $src2}",
Chris Lattner12208612009-04-10 00:16:23 +00001757 [(set GR16:$dst, (and GR16:$src1, (loadi16 addr:$src2))),
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001758 (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001759def AND32rm : I<0x23, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001760 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001761 "and{l}\t{$src2, $dst|$dst, $src2}",
Chris Lattner12208612009-04-10 00:16:23 +00001762 [(set GR32:$dst, (and GR32:$src1, (loadi32 addr:$src2))),
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001763 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001764
1765def AND8ri : Ii8<0x80, MRM4r,
Evan Chengb783fa32007-07-19 01:14:50 +00001766 (outs GR8 :$dst), (ins GR8 :$src1, i8imm :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001767 "and{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001768 [(set GR8:$dst, (and GR8:$src1, imm:$src2)),
1769 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001770def AND16ri : Ii16<0x81, MRM4r,
Evan Chengb783fa32007-07-19 01:14:50 +00001771 (outs GR16:$dst), (ins GR16:$src1, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001772 "and{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001773 [(set GR16:$dst, (and GR16:$src1, imm:$src2)),
1774 (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001775def AND32ri : Ii32<0x81, MRM4r,
Evan Chengb783fa32007-07-19 01:14:50 +00001776 (outs GR32:$dst), (ins GR32:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001777 "and{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001778 [(set GR32:$dst, (and GR32:$src1, imm:$src2)),
1779 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001780def AND16ri8 : Ii8<0x83, MRM4r,
Evan Chengb783fa32007-07-19 01:14:50 +00001781 (outs GR16:$dst), (ins GR16:$src1, i16i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001782 "and{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001783 [(set GR16:$dst, (and GR16:$src1, i16immSExt8:$src2)),
1784 (implicit EFLAGS)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001785 OpSize;
1786def AND32ri8 : Ii8<0x83, MRM4r,
Evan Chengb783fa32007-07-19 01:14:50 +00001787 (outs GR32:$dst), (ins GR32:$src1, i32i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001788 "and{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001789 [(set GR32:$dst, (and GR32:$src1, i32immSExt8:$src2)),
1790 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001791
1792let isTwoAddress = 0 in {
1793 def AND8mr : I<0x20, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001794 (outs), (ins i8mem :$dst, GR8 :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001795 "and{b}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001796 [(store (and (load addr:$dst), GR8:$src), addr:$dst),
1797 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001798 def AND16mr : I<0x21, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001799 (outs), (ins i16mem:$dst, GR16:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001800 "and{w}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001801 [(store (and (load addr:$dst), GR16:$src), addr:$dst),
1802 (implicit EFLAGS)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001803 OpSize;
1804 def AND32mr : I<0x21, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001805 (outs), (ins i32mem:$dst, GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001806 "and{l}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001807 [(store (and (load addr:$dst), GR32:$src), addr:$dst),
1808 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001809 def AND8mi : Ii8<0x80, MRM4m,
Evan Chengb783fa32007-07-19 01:14:50 +00001810 (outs), (ins i8mem :$dst, i8imm :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001811 "and{b}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001812 [(store (and (loadi8 addr:$dst), imm:$src), addr:$dst),
1813 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001814 def AND16mi : Ii16<0x81, MRM4m,
Evan Chengb783fa32007-07-19 01:14:50 +00001815 (outs), (ins i16mem:$dst, i16imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001816 "and{w}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001817 [(store (and (loadi16 addr:$dst), imm:$src), addr:$dst),
1818 (implicit EFLAGS)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001819 OpSize;
1820 def AND32mi : Ii32<0x81, MRM4m,
Evan Chengb783fa32007-07-19 01:14:50 +00001821 (outs), (ins i32mem:$dst, i32imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001822 "and{l}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001823 [(store (and (loadi32 addr:$dst), imm:$src), addr:$dst),
1824 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001825 def AND16mi8 : Ii8<0x83, MRM4m,
Evan Chengb783fa32007-07-19 01:14:50 +00001826 (outs), (ins i16mem:$dst, i16i8imm :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001827 "and{w}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001828 [(store (and (load addr:$dst), i16immSExt8:$src), addr:$dst),
1829 (implicit EFLAGS)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001830 OpSize;
1831 def AND32mi8 : Ii8<0x83, MRM4m,
Evan Chengb783fa32007-07-19 01:14:50 +00001832 (outs), (ins i32mem:$dst, i32i8imm :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001833 "and{l}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001834 [(store (and (load addr:$dst), i32immSExt8:$src), addr:$dst),
1835 (implicit EFLAGS)]>;
Sean Callanan251676e2009-09-02 00:55:49 +00001836
1837 def AND8i8 : Ii8<0x24, RawFrm, (outs), (ins i8imm:$src),
1838 "and{b}\t{$src, %al|%al, $src}", []>;
1839 def AND16i16 : Ii16<0x25, RawFrm, (outs), (ins i16imm:$src),
1840 "and{w}\t{$src, %ax|%ax, $src}", []>, OpSize;
1841 def AND32i32 : Ii32<0x25, RawFrm, (outs), (ins i32imm:$src),
1842 "and{l}\t{$src, %eax|%eax, $src}", []>;
1843
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001844}
1845
1846
1847let isCommutable = 1 in { // X = OR Y, Z --> X = OR Z, Y
Sean Callanan2c48df22009-12-18 00:01:26 +00001848def OR8rr : I<0x08, MRMDestReg, (outs GR8 :$dst),
1849 (ins GR8 :$src1, GR8 :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001850 "or{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001851 [(set GR8:$dst, (or GR8:$src1, GR8:$src2)),
1852 (implicit EFLAGS)]>;
Sean Callanan2c48df22009-12-18 00:01:26 +00001853def OR16rr : I<0x09, MRMDestReg, (outs GR16:$dst),
1854 (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001855 "or{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001856 [(set GR16:$dst, (or GR16:$src1, GR16:$src2)),
1857 (implicit EFLAGS)]>, OpSize;
Sean Callanan2c48df22009-12-18 00:01:26 +00001858def OR32rr : I<0x09, MRMDestReg, (outs GR32:$dst),
1859 (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001860 "or{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001861 [(set GR32:$dst, (or GR32:$src1, GR32:$src2)),
1862 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001863}
Sean Callanan2c48df22009-12-18 00:01:26 +00001864
1865// OR instructions with the destination register in REG and the source register
1866// in R/M. Included for the disassembler.
1867def OR8rr_REV : I<0x0A, MRMSrcReg, (outs GR8:$dst), (ins GR8:$src1, GR8:$src2),
1868 "or{b}\t{$src2, $dst|$dst, $src2}", []>;
1869def OR16rr_REV : I<0x0B, MRMSrcReg, (outs GR16:$dst),
1870 (ins GR16:$src1, GR16:$src2),
1871 "or{w}\t{$src2, $dst|$dst, $src2}", []>, OpSize;
1872def OR32rr_REV : I<0x0B, MRMSrcReg, (outs GR32:$dst),
1873 (ins GR32:$src1, GR32:$src2),
1874 "or{l}\t{$src2, $dst|$dst, $src2}", []>;
1875
1876def OR8rm : I<0x0A, MRMSrcMem , (outs GR8 :$dst),
1877 (ins GR8 :$src1, i8mem :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001878 "or{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001879 [(set GR8:$dst, (or GR8:$src1, (load addr:$src2))),
1880 (implicit EFLAGS)]>;
Sean Callanan2c48df22009-12-18 00:01:26 +00001881def OR16rm : I<0x0B, MRMSrcMem , (outs GR16:$dst),
1882 (ins GR16:$src1, i16mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001883 "or{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001884 [(set GR16:$dst, (or GR16:$src1, (load addr:$src2))),
1885 (implicit EFLAGS)]>, OpSize;
Sean Callanan2c48df22009-12-18 00:01:26 +00001886def OR32rm : I<0x0B, MRMSrcMem , (outs GR32:$dst),
1887 (ins GR32:$src1, i32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001888 "or{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001889 [(set GR32:$dst, (or GR32:$src1, (load addr:$src2))),
1890 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001891
Sean Callanan2c48df22009-12-18 00:01:26 +00001892def OR8ri : Ii8 <0x80, MRM1r, (outs GR8 :$dst),
1893 (ins GR8 :$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001894 "or{b}\t{$src2, $dst|$dst, $src2}",
Evan Cheng4621d272010-01-11 17:03:47 +00001895 [(set GR8:$dst, (or_not_add GR8:$src1, imm:$src2)),
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001896 (implicit EFLAGS)]>;
Sean Callanan2c48df22009-12-18 00:01:26 +00001897def OR16ri : Ii16<0x81, MRM1r, (outs GR16:$dst),
1898 (ins GR16:$src1, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001899 "or{w}\t{$src2, $dst|$dst, $src2}",
Evan Cheng4621d272010-01-11 17:03:47 +00001900 [(set GR16:$dst, (or_not_add GR16:$src1, imm:$src2)),
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001901 (implicit EFLAGS)]>, OpSize;
Sean Callanan2c48df22009-12-18 00:01:26 +00001902def OR32ri : Ii32<0x81, MRM1r, (outs GR32:$dst),
1903 (ins GR32:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001904 "or{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng4621d272010-01-11 17:03:47 +00001905 [(set GR32:$dst, (or_not_add GR32:$src1, imm:$src2)),
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001906 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001907
Sean Callanan2c48df22009-12-18 00:01:26 +00001908def OR16ri8 : Ii8<0x83, MRM1r, (outs GR16:$dst),
1909 (ins GR16:$src1, i16i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001910 "or{w}\t{$src2, $dst|$dst, $src2}",
Evan Cheng4621d272010-01-11 17:03:47 +00001911 [(set GR16:$dst, (or_not_add GR16:$src1, i16immSExt8:$src2)),
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001912 (implicit EFLAGS)]>, OpSize;
Sean Callanan2c48df22009-12-18 00:01:26 +00001913def OR32ri8 : Ii8<0x83, MRM1r, (outs GR32:$dst),
1914 (ins GR32:$src1, i32i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001915 "or{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng4621d272010-01-11 17:03:47 +00001916 [(set GR32:$dst, (or_not_add GR32:$src1, i32immSExt8:$src2)),
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001917 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001918let isTwoAddress = 0 in {
Evan Chengb783fa32007-07-19 01:14:50 +00001919 def OR8mr : I<0x08, MRMDestMem, (outs), (ins i8mem:$dst, GR8:$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 (load addr:$dst), GR8:$src), addr:$dst),
1922 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001923 def OR16mr : I<0x09, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$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 (load addr:$dst), GR16:$src), addr:$dst),
1926 (implicit EFLAGS)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001927 def OR32mr : I<0x09, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001928 "or{l}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001929 [(store (or (load addr:$dst), GR32:$src), addr:$dst),
1930 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001931 def OR8mi : Ii8<0x80, MRM1m, (outs), (ins i8mem :$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001932 "or{b}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001933 [(store (or (loadi8 addr:$dst), imm:$src), addr:$dst),
1934 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001935 def OR16mi : Ii16<0x81, MRM1m, (outs), (ins i16mem:$dst, i16imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001936 "or{w}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001937 [(store (or (loadi16 addr:$dst), imm:$src), addr:$dst),
1938 (implicit EFLAGS)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001939 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001940 def OR32mi : Ii32<0x81, MRM1m, (outs), (ins i32mem:$dst, i32imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001941 "or{l}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001942 [(store (or (loadi32 addr:$dst), imm:$src), addr:$dst),
1943 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001944 def OR16mi8 : Ii8<0x83, MRM1m, (outs), (ins i16mem:$dst, i16i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001945 "or{w}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001946 [(store (or (load addr:$dst), i16immSExt8:$src), addr:$dst),
1947 (implicit EFLAGS)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001948 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001949 def OR32mi8 : Ii8<0x83, MRM1m, (outs), (ins i32mem:$dst, i32i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001950 "or{l}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001951 [(store (or (load addr:$dst), i32immSExt8:$src), addr:$dst),
1952 (implicit EFLAGS)]>;
Sean Callanan8562bef2009-09-11 19:01:56 +00001953
1954 def OR8i8 : Ii8 <0x0C, RawFrm, (outs), (ins i8imm:$src),
1955 "or{b}\t{$src, %al|%al, $src}", []>;
1956 def OR16i16 : Ii16 <0x0D, RawFrm, (outs), (ins i16imm:$src),
1957 "or{w}\t{$src, %ax|%ax, $src}", []>, OpSize;
1958 def OR32i32 : Ii32 <0x0D, RawFrm, (outs), (ins i32imm:$src),
1959 "or{l}\t{$src, %eax|%eax, $src}", []>;
Bill Wendlingba5d5b02008-05-29 01:02:09 +00001960} // isTwoAddress = 0
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001961
1962
Evan Cheng6f26e8b2008-06-18 08:13:07 +00001963let isCommutable = 1 in { // X = XOR Y, Z --> X = XOR Z, Y
Bill Wendlingba5d5b02008-05-29 01:02:09 +00001964 def XOR8rr : I<0x30, MRMDestReg,
1965 (outs GR8 :$dst), (ins GR8 :$src1, GR8 :$src2),
1966 "xor{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001967 [(set GR8:$dst, (xor GR8:$src1, GR8:$src2)),
1968 (implicit EFLAGS)]>;
Bill Wendlingba5d5b02008-05-29 01:02:09 +00001969 def XOR16rr : I<0x31, MRMDestReg,
1970 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
1971 "xor{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001972 [(set GR16:$dst, (xor GR16:$src1, GR16:$src2)),
1973 (implicit EFLAGS)]>, OpSize;
Bill Wendlingba5d5b02008-05-29 01:02:09 +00001974 def XOR32rr : I<0x31, MRMDestReg,
1975 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
1976 "xor{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001977 [(set GR32:$dst, (xor GR32:$src1, GR32:$src2)),
1978 (implicit EFLAGS)]>;
Evan Cheng6f26e8b2008-06-18 08:13:07 +00001979} // isCommutable = 1
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001980
Sean Callanan2c48df22009-12-18 00:01:26 +00001981// XOR instructions with the destination register in REG and the source register
1982// in R/M. Included for the disassembler.
1983def XOR8rr_REV : I<0x32, MRMSrcReg, (outs GR8:$dst), (ins GR8:$src1, GR8:$src2),
1984 "xor{b}\t{$src2, $dst|$dst, $src2}", []>;
1985def XOR16rr_REV : I<0x33, MRMSrcReg, (outs GR16:$dst),
1986 (ins GR16:$src1, GR16:$src2),
1987 "xor{w}\t{$src2, $dst|$dst, $src2}", []>, OpSize;
1988def XOR32rr_REV : I<0x33, MRMSrcReg, (outs GR32:$dst),
1989 (ins GR32:$src1, GR32:$src2),
1990 "xor{l}\t{$src2, $dst|$dst, $src2}", []>;
1991
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001992def XOR8rm : I<0x32, MRMSrcMem ,
Evan Chengb783fa32007-07-19 01:14:50 +00001993 (outs GR8 :$dst), (ins GR8:$src1, i8mem :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001994 "xor{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001995 [(set GR8:$dst, (xor GR8:$src1, (load addr:$src2))),
1996 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001997def XOR16rm : I<0x33, MRMSrcMem ,
Evan Chengb783fa32007-07-19 01:14:50 +00001998 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001999 "xor{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00002000 [(set GR16:$dst, (xor GR16:$src1, (load addr:$src2))),
2001 (implicit EFLAGS)]>,
Bill Wendlingba5d5b02008-05-29 01:02:09 +00002002 OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002003def XOR32rm : I<0x33, MRMSrcMem ,
Evan Chengb783fa32007-07-19 01:14:50 +00002004 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002005 "xor{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00002006 [(set GR32:$dst, (xor GR32:$src1, (load addr:$src2))),
2007 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002008
Bill Wendlingbac38eb2008-05-29 03:46:36 +00002009def XOR8ri : Ii8<0x80, MRM6r,
2010 (outs GR8:$dst), (ins GR8:$src1, i8imm:$src2),
2011 "xor{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00002012 [(set GR8:$dst, (xor GR8:$src1, imm:$src2)),
2013 (implicit EFLAGS)]>;
Bill Wendlingbac38eb2008-05-29 03:46:36 +00002014def XOR16ri : Ii16<0x81, MRM6r,
2015 (outs GR16:$dst), (ins GR16:$src1, i16imm:$src2),
2016 "xor{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00002017 [(set GR16:$dst, (xor GR16:$src1, imm:$src2)),
2018 (implicit EFLAGS)]>, OpSize;
Bill Wendlingbac38eb2008-05-29 03:46:36 +00002019def XOR32ri : Ii32<0x81, MRM6r,
2020 (outs GR32:$dst), (ins GR32:$src1, i32imm:$src2),
2021 "xor{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00002022 [(set GR32:$dst, (xor GR32:$src1, imm:$src2)),
2023 (implicit EFLAGS)]>;
Bill Wendlingbac38eb2008-05-29 03:46:36 +00002024def XOR16ri8 : Ii8<0x83, MRM6r,
2025 (outs GR16:$dst), (ins GR16:$src1, i16i8imm:$src2),
2026 "xor{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00002027 [(set GR16:$dst, (xor GR16:$src1, i16immSExt8:$src2)),
2028 (implicit EFLAGS)]>,
Bill Wendlingbac38eb2008-05-29 03:46:36 +00002029 OpSize;
2030def XOR32ri8 : Ii8<0x83, MRM6r,
2031 (outs GR32:$dst), (ins GR32:$src1, i32i8imm:$src2),
2032 "xor{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00002033 [(set GR32:$dst, (xor GR32:$src1, i32immSExt8:$src2)),
2034 (implicit EFLAGS)]>;
Bill Wendlingba5d5b02008-05-29 01:02:09 +00002035
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002036let isTwoAddress = 0 in {
2037 def XOR8mr : I<0x30, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00002038 (outs), (ins i8mem :$dst, GR8 :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002039 "xor{b}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00002040 [(store (xor (load addr:$dst), GR8:$src), addr:$dst),
2041 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002042 def XOR16mr : I<0x31, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00002043 (outs), (ins i16mem:$dst, GR16:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002044 "xor{w}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00002045 [(store (xor (load addr:$dst), GR16:$src), addr:$dst),
2046 (implicit EFLAGS)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002047 OpSize;
2048 def XOR32mr : I<0x31, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00002049 (outs), (ins i32mem:$dst, GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002050 "xor{l}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00002051 [(store (xor (load addr:$dst), GR32:$src), addr:$dst),
2052 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002053 def XOR8mi : Ii8<0x80, MRM6m,
Evan Chengb783fa32007-07-19 01:14:50 +00002054 (outs), (ins i8mem :$dst, i8imm :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002055 "xor{b}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00002056 [(store (xor (loadi8 addr:$dst), imm:$src), addr:$dst),
2057 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002058 def XOR16mi : Ii16<0x81, MRM6m,
Evan Chengb783fa32007-07-19 01:14:50 +00002059 (outs), (ins i16mem:$dst, i16imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002060 "xor{w}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00002061 [(store (xor (loadi16 addr:$dst), imm:$src), addr:$dst),
2062 (implicit EFLAGS)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002063 OpSize;
2064 def XOR32mi : Ii32<0x81, MRM6m,
Evan Chengb783fa32007-07-19 01:14:50 +00002065 (outs), (ins i32mem:$dst, i32imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002066 "xor{l}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00002067 [(store (xor (loadi32 addr:$dst), imm:$src), addr:$dst),
2068 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002069 def XOR16mi8 : Ii8<0x83, MRM6m,
Evan Chengb783fa32007-07-19 01:14:50 +00002070 (outs), (ins i16mem:$dst, i16i8imm :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002071 "xor{w}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00002072 [(store (xor (load addr:$dst), i16immSExt8:$src), addr:$dst),
2073 (implicit EFLAGS)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002074 OpSize;
2075 def XOR32mi8 : Ii8<0x83, MRM6m,
Evan Chengb783fa32007-07-19 01:14:50 +00002076 (outs), (ins i32mem:$dst, i32i8imm :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002077 "xor{l}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00002078 [(store (xor (load addr:$dst), i32immSExt8:$src), addr:$dst),
2079 (implicit EFLAGS)]>;
Sean Callanan794457a2009-09-10 19:52:26 +00002080
2081 def XOR8i8 : Ii8 <0x34, RawFrm, (outs), (ins i8imm:$src),
2082 "xor{b}\t{$src, %al|%al, $src}", []>;
2083 def XOR16i16 : Ii16 <0x35, RawFrm, (outs), (ins i16imm:$src),
2084 "xor{w}\t{$src, %ax|%ax, $src}", []>, OpSize;
2085 def XOR32i32 : Ii32 <0x35, RawFrm, (outs), (ins i32imm:$src),
2086 "xor{l}\t{$src, %eax|%eax, $src}", []>;
Bill Wendlingba5d5b02008-05-29 01:02:09 +00002087} // isTwoAddress = 0
Evan Cheng55687072007-09-14 21:48:26 +00002088} // Defs = [EFLAGS]
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002089
2090// Shift instructions
Evan Cheng55687072007-09-14 21:48:26 +00002091let Defs = [EFLAGS] in {
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002092let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00002093def SHL8rCL : I<0xD2, MRM4r, (outs GR8 :$dst), (ins GR8 :$src),
Eli Friedman378ea832009-06-19 04:48:38 +00002094 "shl{b}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002095 [(set GR8:$dst, (shl GR8:$src, CL))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002096def SHL16rCL : I<0xD3, MRM4r, (outs GR16:$dst), (ins GR16:$src),
Eli Friedman378ea832009-06-19 04:48:38 +00002097 "shl{w}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002098 [(set GR16:$dst, (shl GR16:$src, CL))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002099def SHL32rCL : I<0xD3, MRM4r, (outs GR32:$dst), (ins GR32:$src),
Eli Friedman378ea832009-06-19 04:48:38 +00002100 "shl{l}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002101 [(set GR32:$dst, (shl GR32:$src, CL))]>;
Bill Wendlingba5d5b02008-05-29 01:02:09 +00002102} // Uses = [CL]
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002103
Evan Chengb783fa32007-07-19 01:14:50 +00002104def SHL8ri : Ii8<0xC0, MRM4r, (outs GR8 :$dst), (ins GR8 :$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002105 "shl{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002106 [(set GR8:$dst, (shl GR8:$src1, (i8 imm:$src2)))]>;
2107let isConvertibleToThreeAddress = 1 in { // Can transform into LEA.
Evan Chengb783fa32007-07-19 01:14:50 +00002108def SHL16ri : Ii8<0xC1, MRM4r, (outs GR16:$dst), (ins GR16:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002109 "shl{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002110 [(set GR16:$dst, (shl GR16:$src1, (i8 imm:$src2)))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002111def SHL32ri : Ii8<0xC1, MRM4r, (outs GR32:$dst), (ins GR32:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002112 "shl{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002113 [(set GR32:$dst, (shl GR32:$src1, (i8 imm:$src2)))]>;
Sean Callananca503e02009-09-16 02:28:43 +00002114
2115// NOTE: We don't include patterns for shifts of a register by one, because
2116// 'add reg,reg' is cheaper.
2117
2118def SHL8r1 : I<0xD0, MRM4r, (outs GR8:$dst), (ins GR8:$src1),
2119 "shl{b}\t$dst", []>;
2120def SHL16r1 : I<0xD1, MRM4r, (outs GR16:$dst), (ins GR16:$src1),
2121 "shl{w}\t$dst", []>, OpSize;
2122def SHL32r1 : I<0xD1, MRM4r, (outs GR32:$dst), (ins GR32:$src1),
2123 "shl{l}\t$dst", []>;
2124
Bill Wendlingba5d5b02008-05-29 01:02:09 +00002125} // isConvertibleToThreeAddress = 1
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002126
2127let isTwoAddress = 0 in {
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002128 let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00002129 def SHL8mCL : I<0xD2, MRM4m, (outs), (ins i8mem :$dst),
Eli Friedman378ea832009-06-19 04:48:38 +00002130 "shl{b}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002131 [(store (shl (loadi8 addr:$dst), CL), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002132 def SHL16mCL : I<0xD3, MRM4m, (outs), (ins i16mem:$dst),
Eli Friedman378ea832009-06-19 04:48:38 +00002133 "shl{w}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002134 [(store (shl (loadi16 addr:$dst), CL), addr:$dst)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002135 def SHL32mCL : I<0xD3, MRM4m, (outs), (ins i32mem:$dst),
Eli Friedman378ea832009-06-19 04:48:38 +00002136 "shl{l}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002137 [(store (shl (loadi32 addr:$dst), CL), addr:$dst)]>;
2138 }
Evan Chengb783fa32007-07-19 01:14:50 +00002139 def SHL8mi : Ii8<0xC0, MRM4m, (outs), (ins i8mem :$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002140 "shl{b}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002141 [(store (shl (loadi8 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002142 def SHL16mi : Ii8<0xC1, MRM4m, (outs), (ins i16mem:$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002143 "shl{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002144 [(store (shl (loadi16 addr:$dst), (i8 imm:$src)), addr:$dst)]>,
2145 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002146 def SHL32mi : Ii8<0xC1, MRM4m, (outs), (ins i32mem:$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002147 "shl{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002148 [(store (shl (loadi32 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
2149
2150 // Shift by 1
Evan Chengb783fa32007-07-19 01:14:50 +00002151 def SHL8m1 : I<0xD0, MRM4m, (outs), (ins i8mem :$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002152 "shl{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002153 [(store (shl (loadi8 addr:$dst), (i8 1)), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002154 def SHL16m1 : I<0xD1, MRM4m, (outs), (ins i16mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002155 "shl{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002156 [(store (shl (loadi16 addr:$dst), (i8 1)), addr:$dst)]>,
2157 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002158 def SHL32m1 : I<0xD1, MRM4m, (outs), (ins i32mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002159 "shl{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002160 [(store (shl (loadi32 addr:$dst), (i8 1)), addr:$dst)]>;
2161}
2162
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002163let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00002164def SHR8rCL : I<0xD2, MRM5r, (outs GR8 :$dst), (ins GR8 :$src),
Eli Friedman378ea832009-06-19 04:48:38 +00002165 "shr{b}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002166 [(set GR8:$dst, (srl GR8:$src, CL))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002167def SHR16rCL : I<0xD3, MRM5r, (outs GR16:$dst), (ins GR16:$src),
Eli Friedman378ea832009-06-19 04:48:38 +00002168 "shr{w}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002169 [(set GR16:$dst, (srl GR16:$src, CL))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002170def SHR32rCL : I<0xD3, MRM5r, (outs GR32:$dst), (ins GR32:$src),
Eli Friedman378ea832009-06-19 04:48:38 +00002171 "shr{l}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002172 [(set GR32:$dst, (srl GR32:$src, CL))]>;
2173}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002174
Evan Chengb783fa32007-07-19 01:14:50 +00002175def SHR8ri : Ii8<0xC0, MRM5r, (outs GR8:$dst), (ins GR8:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002176 "shr{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002177 [(set GR8:$dst, (srl GR8:$src1, (i8 imm:$src2)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002178def SHR16ri : Ii8<0xC1, MRM5r, (outs GR16:$dst), (ins GR16:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002179 "shr{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002180 [(set GR16:$dst, (srl GR16:$src1, (i8 imm:$src2)))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002181def SHR32ri : Ii8<0xC1, MRM5r, (outs GR32:$dst), (ins GR32:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002182 "shr{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002183 [(set GR32:$dst, (srl GR32:$src1, (i8 imm:$src2)))]>;
2184
2185// Shift by 1
Evan Chengb783fa32007-07-19 01:14:50 +00002186def SHR8r1 : I<0xD0, MRM5r, (outs GR8:$dst), (ins GR8:$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00002187 "shr{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002188 [(set GR8:$dst, (srl GR8:$src1, (i8 1)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002189def SHR16r1 : I<0xD1, MRM5r, (outs GR16:$dst), (ins GR16:$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00002190 "shr{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002191 [(set GR16:$dst, (srl GR16:$src1, (i8 1)))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002192def SHR32r1 : I<0xD1, MRM5r, (outs GR32:$dst), (ins GR32:$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00002193 "shr{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002194 [(set GR32:$dst, (srl GR32:$src1, (i8 1)))]>;
2195
2196let isTwoAddress = 0 in {
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002197 let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00002198 def SHR8mCL : I<0xD2, MRM5m, (outs), (ins i8mem :$dst),
Eli Friedman378ea832009-06-19 04:48:38 +00002199 "shr{b}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002200 [(store (srl (loadi8 addr:$dst), CL), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002201 def SHR16mCL : I<0xD3, MRM5m, (outs), (ins i16mem:$dst),
Eli Friedman378ea832009-06-19 04:48:38 +00002202 "shr{w}\t{%cl, $dst|$dst, CL}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002203 [(store (srl (loadi16 addr:$dst), CL), addr:$dst)]>,
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002204 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002205 def SHR32mCL : I<0xD3, MRM5m, (outs), (ins i32mem:$dst),
Eli Friedman378ea832009-06-19 04:48:38 +00002206 "shr{l}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002207 [(store (srl (loadi32 addr:$dst), CL), addr:$dst)]>;
2208 }
Evan Chengb783fa32007-07-19 01:14:50 +00002209 def SHR8mi : Ii8<0xC0, MRM5m, (outs), (ins i8mem :$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002210 "shr{b}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002211 [(store (srl (loadi8 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002212 def SHR16mi : Ii8<0xC1, MRM5m, (outs), (ins i16mem:$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002213 "shr{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002214 [(store (srl (loadi16 addr:$dst), (i8 imm:$src)), addr:$dst)]>,
2215 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002216 def SHR32mi : Ii8<0xC1, MRM5m, (outs), (ins i32mem:$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002217 "shr{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002218 [(store (srl (loadi32 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
2219
2220 // Shift by 1
Evan Chengb783fa32007-07-19 01:14:50 +00002221 def SHR8m1 : I<0xD0, MRM5m, (outs), (ins i8mem :$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002222 "shr{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002223 [(store (srl (loadi8 addr:$dst), (i8 1)), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002224 def SHR16m1 : I<0xD1, MRM5m, (outs), (ins i16mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002225 "shr{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002226 [(store (srl (loadi16 addr:$dst), (i8 1)), addr:$dst)]>,OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002227 def SHR32m1 : I<0xD1, MRM5m, (outs), (ins i32mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002228 "shr{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002229 [(store (srl (loadi32 addr:$dst), (i8 1)), addr:$dst)]>;
2230}
2231
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002232let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00002233def SAR8rCL : I<0xD2, MRM7r, (outs GR8 :$dst), (ins GR8 :$src),
Eli Friedman378ea832009-06-19 04:48:38 +00002234 "sar{b}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002235 [(set GR8:$dst, (sra GR8:$src, CL))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002236def SAR16rCL : I<0xD3, MRM7r, (outs GR16:$dst), (ins GR16:$src),
Eli Friedman378ea832009-06-19 04:48:38 +00002237 "sar{w}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002238 [(set GR16:$dst, (sra GR16:$src, CL))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002239def SAR32rCL : I<0xD3, MRM7r, (outs GR32:$dst), (ins GR32:$src),
Eli Friedman378ea832009-06-19 04:48:38 +00002240 "sar{l}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002241 [(set GR32:$dst, (sra GR32:$src, CL))]>;
2242}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002243
Evan Chengb783fa32007-07-19 01:14:50 +00002244def SAR8ri : Ii8<0xC0, MRM7r, (outs GR8 :$dst), (ins GR8 :$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002245 "sar{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002246 [(set GR8:$dst, (sra GR8:$src1, (i8 imm:$src2)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002247def SAR16ri : Ii8<0xC1, MRM7r, (outs GR16:$dst), (ins GR16:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002248 "sar{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002249 [(set GR16:$dst, (sra GR16:$src1, (i8 imm:$src2)))]>,
2250 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002251def SAR32ri : Ii8<0xC1, MRM7r, (outs GR32:$dst), (ins GR32:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002252 "sar{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002253 [(set GR32:$dst, (sra GR32:$src1, (i8 imm:$src2)))]>;
2254
2255// Shift by 1
Evan Chengb783fa32007-07-19 01:14:50 +00002256def SAR8r1 : I<0xD0, MRM7r, (outs GR8 :$dst), (ins GR8 :$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00002257 "sar{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002258 [(set GR8:$dst, (sra GR8:$src1, (i8 1)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002259def SAR16r1 : I<0xD1, MRM7r, (outs GR16:$dst), (ins GR16:$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00002260 "sar{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002261 [(set GR16:$dst, (sra GR16:$src1, (i8 1)))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002262def SAR32r1 : I<0xD1, MRM7r, (outs GR32:$dst), (ins GR32:$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00002263 "sar{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002264 [(set GR32:$dst, (sra GR32:$src1, (i8 1)))]>;
2265
2266let isTwoAddress = 0 in {
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002267 let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00002268 def SAR8mCL : I<0xD2, MRM7m, (outs), (ins i8mem :$dst),
Eli Friedman378ea832009-06-19 04:48:38 +00002269 "sar{b}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002270 [(store (sra (loadi8 addr:$dst), CL), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002271 def SAR16mCL : I<0xD3, MRM7m, (outs), (ins i16mem:$dst),
Eli Friedman378ea832009-06-19 04:48:38 +00002272 "sar{w}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002273 [(store (sra (loadi16 addr:$dst), CL), addr:$dst)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002274 def SAR32mCL : I<0xD3, MRM7m, (outs), (ins i32mem:$dst),
Eli Friedman378ea832009-06-19 04:48:38 +00002275 "sar{l}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002276 [(store (sra (loadi32 addr:$dst), CL), addr:$dst)]>;
2277 }
Evan Chengb783fa32007-07-19 01:14:50 +00002278 def SAR8mi : Ii8<0xC0, MRM7m, (outs), (ins i8mem :$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002279 "sar{b}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002280 [(store (sra (loadi8 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002281 def SAR16mi : Ii8<0xC1, MRM7m, (outs), (ins i16mem:$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002282 "sar{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002283 [(store (sra (loadi16 addr:$dst), (i8 imm:$src)), addr:$dst)]>,
2284 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002285 def SAR32mi : Ii8<0xC1, MRM7m, (outs), (ins i32mem:$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002286 "sar{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002287 [(store (sra (loadi32 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
2288
2289 // Shift by 1
Evan Chengb783fa32007-07-19 01:14:50 +00002290 def SAR8m1 : I<0xD0, MRM7m, (outs), (ins i8mem :$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002291 "sar{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002292 [(store (sra (loadi8 addr:$dst), (i8 1)), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002293 def SAR16m1 : I<0xD1, MRM7m, (outs), (ins i16mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002294 "sar{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002295 [(store (sra (loadi16 addr:$dst), (i8 1)), addr:$dst)]>,
2296 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002297 def SAR32m1 : I<0xD1, MRM7m, (outs), (ins i32mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002298 "sar{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002299 [(store (sra (loadi32 addr:$dst), (i8 1)), addr:$dst)]>;
2300}
2301
2302// Rotate instructions
Sean Callanan3c8eecd2009-09-18 19:35:23 +00002303
2304def RCL8r1 : I<0xD0, MRM2r, (outs GR8:$dst), (ins GR8:$src),
2305 "rcl{b}\t{1, $dst|$dst, 1}", []>;
2306def RCL8m1 : I<0xD0, MRM2m, (outs i8mem:$dst), (ins i8mem:$src),
2307 "rcl{b}\t{1, $dst|$dst, 1}", []>;
2308let Uses = [CL] in {
2309def RCL8rCL : I<0xD2, MRM2r, (outs GR8:$dst), (ins GR8:$src),
2310 "rcl{b}\t{%cl, $dst|$dst, CL}", []>;
2311def RCL8mCL : I<0xD2, MRM2m, (outs i8mem:$dst), (ins i8mem:$src),
2312 "rcl{b}\t{%cl, $dst|$dst, CL}", []>;
2313}
2314def RCL8ri : Ii8<0xC0, MRM2r, (outs GR8:$dst), (ins GR8:$src, i8imm:$cnt),
2315 "rcl{b}\t{$cnt, $dst|$dst, $cnt}", []>;
2316def RCL8mi : Ii8<0xC0, MRM2m, (outs i8mem:$dst), (ins i8mem:$src, i8imm:$cnt),
2317 "rcl{b}\t{$cnt, $dst|$dst, $cnt}", []>;
2318
2319def RCL16r1 : I<0xD1, MRM2r, (outs GR16:$dst), (ins GR16:$src),
2320 "rcl{w}\t{1, $dst|$dst, 1}", []>, OpSize;
2321def RCL16m1 : I<0xD1, MRM2m, (outs i16mem:$dst), (ins i16mem:$src),
2322 "rcl{w}\t{1, $dst|$dst, 1}", []>, OpSize;
2323let Uses = [CL] in {
2324def RCL16rCL : I<0xD3, MRM2r, (outs GR16:$dst), (ins GR16:$src),
2325 "rcl{w}\t{%cl, $dst|$dst, CL}", []>, OpSize;
2326def RCL16mCL : I<0xD3, MRM2m, (outs i16mem:$dst), (ins i16mem:$src),
2327 "rcl{w}\t{%cl, $dst|$dst, CL}", []>, OpSize;
2328}
2329def RCL16ri : Ii8<0xC1, MRM2r, (outs GR16:$dst), (ins GR16:$src, i8imm:$cnt),
2330 "rcl{w}\t{$cnt, $dst|$dst, $cnt}", []>, OpSize;
Sean Callanan2c48df22009-12-18 00:01:26 +00002331def RCL16mi : Ii8<0xC1, MRM2m, (outs i16mem:$dst),
2332 (ins i16mem:$src, i8imm:$cnt),
Sean Callanan3c8eecd2009-09-18 19:35:23 +00002333 "rcl{w}\t{$cnt, $dst|$dst, $cnt}", []>, OpSize;
2334
2335def RCL32r1 : I<0xD1, MRM2r, (outs GR32:$dst), (ins GR32:$src),
2336 "rcl{l}\t{1, $dst|$dst, 1}", []>;
2337def RCL32m1 : I<0xD1, MRM2m, (outs i32mem:$dst), (ins i32mem:$src),
2338 "rcl{l}\t{1, $dst|$dst, 1}", []>;
2339let Uses = [CL] in {
2340def RCL32rCL : I<0xD3, MRM2r, (outs GR32:$dst), (ins GR32:$src),
2341 "rcl{l}\t{%cl, $dst|$dst, CL}", []>;
2342def RCL32mCL : I<0xD3, MRM2m, (outs i32mem:$dst), (ins i32mem:$src),
2343 "rcl{l}\t{%cl, $dst|$dst, CL}", []>;
2344}
2345def RCL32ri : Ii8<0xC1, MRM2r, (outs GR32:$dst), (ins GR32:$src, i8imm:$cnt),
2346 "rcl{l}\t{$cnt, $dst|$dst, $cnt}", []>;
Sean Callanan2c48df22009-12-18 00:01:26 +00002347def RCL32mi : Ii8<0xC1, MRM2m, (outs i32mem:$dst),
2348 (ins i32mem:$src, i8imm:$cnt),
Sean Callanan3c8eecd2009-09-18 19:35:23 +00002349 "rcl{l}\t{$cnt, $dst|$dst, $cnt}", []>;
2350
2351def RCR8r1 : I<0xD0, MRM3r, (outs GR8:$dst), (ins GR8:$src),
2352 "rcr{b}\t{1, $dst|$dst, 1}", []>;
2353def RCR8m1 : I<0xD0, MRM3m, (outs i8mem:$dst), (ins i8mem:$src),
2354 "rcr{b}\t{1, $dst|$dst, 1}", []>;
2355let Uses = [CL] in {
2356def RCR8rCL : I<0xD2, MRM3r, (outs GR8:$dst), (ins GR8:$src),
2357 "rcr{b}\t{%cl, $dst|$dst, CL}", []>;
2358def RCR8mCL : I<0xD2, MRM3m, (outs i8mem:$dst), (ins i8mem:$src),
2359 "rcr{b}\t{%cl, $dst|$dst, CL}", []>;
2360}
2361def RCR8ri : Ii8<0xC0, MRM3r, (outs GR8:$dst), (ins GR8:$src, i8imm:$cnt),
2362 "rcr{b}\t{$cnt, $dst|$dst, $cnt}", []>;
2363def RCR8mi : Ii8<0xC0, MRM3m, (outs i8mem:$dst), (ins i8mem:$src, i8imm:$cnt),
2364 "rcr{b}\t{$cnt, $dst|$dst, $cnt}", []>;
2365
2366def RCR16r1 : I<0xD1, MRM3r, (outs GR16:$dst), (ins GR16:$src),
2367 "rcr{w}\t{1, $dst|$dst, 1}", []>, OpSize;
2368def RCR16m1 : I<0xD1, MRM3m, (outs i16mem:$dst), (ins i16mem:$src),
2369 "rcr{w}\t{1, $dst|$dst, 1}", []>, OpSize;
2370let Uses = [CL] in {
2371def RCR16rCL : I<0xD3, MRM3r, (outs GR16:$dst), (ins GR16:$src),
2372 "rcr{w}\t{%cl, $dst|$dst, CL}", []>, OpSize;
2373def RCR16mCL : I<0xD3, MRM3m, (outs i16mem:$dst), (ins i16mem:$src),
2374 "rcr{w}\t{%cl, $dst|$dst, CL}", []>, OpSize;
2375}
2376def RCR16ri : Ii8<0xC1, MRM3r, (outs GR16:$dst), (ins GR16:$src, i8imm:$cnt),
2377 "rcr{w}\t{$cnt, $dst|$dst, $cnt}", []>, OpSize;
Sean Callanan2c48df22009-12-18 00:01:26 +00002378def RCR16mi : Ii8<0xC1, MRM3m, (outs i16mem:$dst),
2379 (ins i16mem:$src, i8imm:$cnt),
Sean Callanan3c8eecd2009-09-18 19:35:23 +00002380 "rcr{w}\t{$cnt, $dst|$dst, $cnt}", []>, OpSize;
2381
2382def RCR32r1 : I<0xD1, MRM3r, (outs GR32:$dst), (ins GR32:$src),
2383 "rcr{l}\t{1, $dst|$dst, 1}", []>;
2384def RCR32m1 : I<0xD1, MRM3m, (outs i32mem:$dst), (ins i32mem:$src),
2385 "rcr{l}\t{1, $dst|$dst, 1}", []>;
2386let Uses = [CL] in {
2387def RCR32rCL : I<0xD3, MRM3r, (outs GR32:$dst), (ins GR32:$src),
2388 "rcr{l}\t{%cl, $dst|$dst, CL}", []>;
2389def RCR32mCL : I<0xD3, MRM3m, (outs i32mem:$dst), (ins i32mem:$src),
2390 "rcr{l}\t{%cl, $dst|$dst, CL}", []>;
2391}
2392def RCR32ri : Ii8<0xC1, MRM3r, (outs GR32:$dst), (ins GR32:$src, i8imm:$cnt),
2393 "rcr{l}\t{$cnt, $dst|$dst, $cnt}", []>;
Sean Callanan2c48df22009-12-18 00:01:26 +00002394def RCR32mi : Ii8<0xC1, MRM3m, (outs i32mem:$dst),
2395 (ins i32mem:$src, i8imm:$cnt),
Sean Callanan3c8eecd2009-09-18 19:35:23 +00002396 "rcr{l}\t{$cnt, $dst|$dst, $cnt}", []>;
2397
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002398// FIXME: provide shorter instructions when imm8 == 1
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002399let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00002400def ROL8rCL : I<0xD2, MRM0r, (outs GR8 :$dst), (ins GR8 :$src),
Eli Friedman378ea832009-06-19 04:48:38 +00002401 "rol{b}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002402 [(set GR8:$dst, (rotl GR8:$src, CL))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002403def ROL16rCL : I<0xD3, MRM0r, (outs GR16:$dst), (ins GR16:$src),
Eli Friedman378ea832009-06-19 04:48:38 +00002404 "rol{w}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002405 [(set GR16:$dst, (rotl GR16:$src, CL))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002406def ROL32rCL : I<0xD3, MRM0r, (outs GR32:$dst), (ins GR32:$src),
Eli Friedman378ea832009-06-19 04:48:38 +00002407 "rol{l}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002408 [(set GR32:$dst, (rotl GR32:$src, CL))]>;
2409}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002410
Evan Chengb783fa32007-07-19 01:14:50 +00002411def ROL8ri : Ii8<0xC0, MRM0r, (outs GR8 :$dst), (ins GR8 :$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002412 "rol{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002413 [(set GR8:$dst, (rotl GR8:$src1, (i8 imm:$src2)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002414def ROL16ri : Ii8<0xC1, MRM0r, (outs GR16:$dst), (ins GR16:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002415 "rol{w}\t{$src2, $dst|$dst, $src2}",
Sean Callanan2c48df22009-12-18 00:01:26 +00002416 [(set GR16:$dst, (rotl GR16:$src1, (i8 imm:$src2)))]>,
2417 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002418def ROL32ri : Ii8<0xC1, MRM0r, (outs GR32:$dst), (ins GR32:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002419 "rol{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002420 [(set GR32:$dst, (rotl GR32:$src1, (i8 imm:$src2)))]>;
2421
2422// Rotate by 1
Evan Chengb783fa32007-07-19 01:14:50 +00002423def ROL8r1 : I<0xD0, MRM0r, (outs GR8 :$dst), (ins GR8 :$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00002424 "rol{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002425 [(set GR8:$dst, (rotl GR8:$src1, (i8 1)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002426def ROL16r1 : I<0xD1, MRM0r, (outs GR16:$dst), (ins GR16:$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00002427 "rol{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002428 [(set GR16:$dst, (rotl GR16:$src1, (i8 1)))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002429def ROL32r1 : I<0xD1, MRM0r, (outs GR32:$dst), (ins GR32:$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00002430 "rol{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002431 [(set GR32:$dst, (rotl GR32:$src1, (i8 1)))]>;
2432
2433let isTwoAddress = 0 in {
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002434 let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00002435 def ROL8mCL : I<0xD2, MRM0m, (outs), (ins i8mem :$dst),
Eli Friedman378ea832009-06-19 04:48:38 +00002436 "rol{b}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002437 [(store (rotl (loadi8 addr:$dst), CL), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002438 def ROL16mCL : I<0xD3, MRM0m, (outs), (ins i16mem:$dst),
Eli Friedman378ea832009-06-19 04:48:38 +00002439 "rol{w}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002440 [(store (rotl (loadi16 addr:$dst), CL), addr:$dst)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002441 def ROL32mCL : I<0xD3, MRM0m, (outs), (ins i32mem:$dst),
Eli Friedman378ea832009-06-19 04:48:38 +00002442 "rol{l}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002443 [(store (rotl (loadi32 addr:$dst), CL), addr:$dst)]>;
2444 }
Evan Chengb783fa32007-07-19 01:14:50 +00002445 def ROL8mi : Ii8<0xC0, MRM0m, (outs), (ins i8mem :$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002446 "rol{b}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002447 [(store (rotl (loadi8 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002448 def ROL16mi : Ii8<0xC1, MRM0m, (outs), (ins i16mem:$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002449 "rol{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002450 [(store (rotl (loadi16 addr:$dst), (i8 imm:$src)), addr:$dst)]>,
2451 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002452 def ROL32mi : Ii8<0xC1, MRM0m, (outs), (ins i32mem:$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002453 "rol{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002454 [(store (rotl (loadi32 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
2455
2456 // Rotate by 1
Evan Chengb783fa32007-07-19 01:14:50 +00002457 def ROL8m1 : I<0xD0, MRM0m, (outs), (ins i8mem :$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002458 "rol{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002459 [(store (rotl (loadi8 addr:$dst), (i8 1)), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002460 def ROL16m1 : I<0xD1, MRM0m, (outs), (ins i16mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002461 "rol{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002462 [(store (rotl (loadi16 addr:$dst), (i8 1)), addr:$dst)]>,
2463 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002464 def ROL32m1 : I<0xD1, MRM0m, (outs), (ins i32mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002465 "rol{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002466 [(store (rotl (loadi32 addr:$dst), (i8 1)), addr:$dst)]>;
2467}
2468
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002469let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00002470def ROR8rCL : I<0xD2, MRM1r, (outs GR8 :$dst), (ins GR8 :$src),
Eli Friedman378ea832009-06-19 04:48:38 +00002471 "ror{b}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002472 [(set GR8:$dst, (rotr GR8:$src, CL))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002473def ROR16rCL : I<0xD3, MRM1r, (outs GR16:$dst), (ins GR16:$src),
Eli Friedman378ea832009-06-19 04:48:38 +00002474 "ror{w}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002475 [(set GR16:$dst, (rotr GR16:$src, CL))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002476def ROR32rCL : I<0xD3, MRM1r, (outs GR32:$dst), (ins GR32:$src),
Eli Friedman378ea832009-06-19 04:48:38 +00002477 "ror{l}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002478 [(set GR32:$dst, (rotr GR32:$src, CL))]>;
2479}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002480
Evan Chengb783fa32007-07-19 01:14:50 +00002481def ROR8ri : Ii8<0xC0, MRM1r, (outs GR8 :$dst), (ins GR8 :$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002482 "ror{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002483 [(set GR8:$dst, (rotr GR8:$src1, (i8 imm:$src2)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002484def ROR16ri : Ii8<0xC1, MRM1r, (outs GR16:$dst), (ins GR16:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002485 "ror{w}\t{$src2, $dst|$dst, $src2}",
Sean Callanan2c48df22009-12-18 00:01:26 +00002486 [(set GR16:$dst, (rotr GR16:$src1, (i8 imm:$src2)))]>,
2487 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002488def ROR32ri : Ii8<0xC1, MRM1r, (outs GR32:$dst), (ins GR32:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002489 "ror{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002490 [(set GR32:$dst, (rotr GR32:$src1, (i8 imm:$src2)))]>;
2491
2492// Rotate by 1
Evan Chengb783fa32007-07-19 01:14:50 +00002493def ROR8r1 : I<0xD0, MRM1r, (outs GR8 :$dst), (ins GR8 :$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00002494 "ror{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002495 [(set GR8:$dst, (rotr GR8:$src1, (i8 1)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002496def ROR16r1 : I<0xD1, MRM1r, (outs GR16:$dst), (ins GR16:$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00002497 "ror{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002498 [(set GR16:$dst, (rotr GR16:$src1, (i8 1)))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002499def ROR32r1 : I<0xD1, MRM1r, (outs GR32:$dst), (ins GR32:$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00002500 "ror{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002501 [(set GR32:$dst, (rotr GR32:$src1, (i8 1)))]>;
2502
2503let isTwoAddress = 0 in {
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002504 let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00002505 def ROR8mCL : I<0xD2, MRM1m, (outs), (ins i8mem :$dst),
Eli Friedman378ea832009-06-19 04:48:38 +00002506 "ror{b}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002507 [(store (rotr (loadi8 addr:$dst), CL), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002508 def ROR16mCL : I<0xD3, MRM1m, (outs), (ins i16mem:$dst),
Eli Friedman378ea832009-06-19 04:48:38 +00002509 "ror{w}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002510 [(store (rotr (loadi16 addr:$dst), CL), addr:$dst)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002511 def ROR32mCL : I<0xD3, MRM1m, (outs), (ins i32mem:$dst),
Eli Friedman378ea832009-06-19 04:48:38 +00002512 "ror{l}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002513 [(store (rotr (loadi32 addr:$dst), CL), addr:$dst)]>;
2514 }
Evan Chengb783fa32007-07-19 01:14:50 +00002515 def ROR8mi : Ii8<0xC0, MRM1m, (outs), (ins i8mem :$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002516 "ror{b}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002517 [(store (rotr (loadi8 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002518 def ROR16mi : Ii8<0xC1, MRM1m, (outs), (ins i16mem:$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002519 "ror{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002520 [(store (rotr (loadi16 addr:$dst), (i8 imm:$src)), addr:$dst)]>,
2521 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002522 def ROR32mi : Ii8<0xC1, MRM1m, (outs), (ins i32mem:$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002523 "ror{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002524 [(store (rotr (loadi32 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
2525
2526 // Rotate by 1
Evan Chengb783fa32007-07-19 01:14:50 +00002527 def ROR8m1 : I<0xD0, MRM1m, (outs), (ins i8mem :$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002528 "ror{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002529 [(store (rotr (loadi8 addr:$dst), (i8 1)), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002530 def ROR16m1 : I<0xD1, MRM1m, (outs), (ins i16mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002531 "ror{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002532 [(store (rotr (loadi16 addr:$dst), (i8 1)), addr:$dst)]>,
2533 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002534 def ROR32m1 : I<0xD1, MRM1m, (outs), (ins i32mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002535 "ror{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002536 [(store (rotr (loadi32 addr:$dst), (i8 1)), addr:$dst)]>;
2537}
2538
2539
2540
2541// Double shift instructions (generalizations of rotate)
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002542let Uses = [CL] in {
Sean Callanan2c48df22009-12-18 00:01:26 +00002543def SHLD32rrCL : I<0xA5, MRMDestReg, (outs GR32:$dst),
2544 (ins GR32:$src1, GR32:$src2),
Eli Friedman378ea832009-06-19 04:48:38 +00002545 "shld{l}\t{%cl, $src2, $dst|$dst, $src2, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002546 [(set GR32:$dst, (X86shld GR32:$src1, GR32:$src2, CL))]>, TB;
Sean Callanan2c48df22009-12-18 00:01:26 +00002547def SHRD32rrCL : I<0xAD, MRMDestReg, (outs GR32:$dst),
2548 (ins GR32:$src1, GR32:$src2),
Eli Friedman378ea832009-06-19 04:48:38 +00002549 "shrd{l}\t{%cl, $src2, $dst|$dst, $src2, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002550 [(set GR32:$dst, (X86shrd GR32:$src1, GR32:$src2, CL))]>, TB;
Sean Callanan2c48df22009-12-18 00:01:26 +00002551def SHLD16rrCL : I<0xA5, MRMDestReg, (outs GR16:$dst),
2552 (ins GR16:$src1, GR16:$src2),
Eli Friedman378ea832009-06-19 04:48:38 +00002553 "shld{w}\t{%cl, $src2, $dst|$dst, $src2, CL}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002554 [(set GR16:$dst, (X86shld GR16:$src1, GR16:$src2, CL))]>,
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002555 TB, OpSize;
Sean Callanan2c48df22009-12-18 00:01:26 +00002556def SHRD16rrCL : I<0xAD, MRMDestReg, (outs GR16:$dst),
2557 (ins GR16:$src1, GR16:$src2),
Eli Friedman378ea832009-06-19 04:48:38 +00002558 "shrd{w}\t{%cl, $src2, $dst|$dst, $src2, CL}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002559 [(set GR16:$dst, (X86shrd GR16:$src1, GR16:$src2, CL))]>,
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002560 TB, OpSize;
2561}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002562
2563let isCommutable = 1 in { // These instructions commute to each other.
2564def SHLD32rri8 : Ii8<0xA4, MRMDestReg,
Sean Callanan2c48df22009-12-18 00:01:26 +00002565 (outs GR32:$dst),
2566 (ins GR32:$src1, GR32:$src2, i8imm:$src3),
Dan Gohman91888f02007-07-31 20:11:57 +00002567 "shld{l}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002568 [(set GR32:$dst, (X86shld GR32:$src1, GR32:$src2,
2569 (i8 imm:$src3)))]>,
2570 TB;
2571def SHRD32rri8 : Ii8<0xAC, MRMDestReg,
Sean Callanan2c48df22009-12-18 00:01:26 +00002572 (outs GR32:$dst),
2573 (ins GR32:$src1, GR32:$src2, i8imm:$src3),
Dan Gohman91888f02007-07-31 20:11:57 +00002574 "shrd{l}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002575 [(set GR32:$dst, (X86shrd GR32:$src1, GR32:$src2,
2576 (i8 imm:$src3)))]>,
2577 TB;
2578def SHLD16rri8 : Ii8<0xA4, MRMDestReg,
Sean Callanan2c48df22009-12-18 00:01:26 +00002579 (outs GR16:$dst),
2580 (ins GR16:$src1, GR16:$src2, i8imm:$src3),
Dan Gohman91888f02007-07-31 20:11:57 +00002581 "shld{w}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002582 [(set GR16:$dst, (X86shld GR16:$src1, GR16:$src2,
2583 (i8 imm:$src3)))]>,
2584 TB, OpSize;
2585def SHRD16rri8 : Ii8<0xAC, MRMDestReg,
Sean Callanan2c48df22009-12-18 00:01:26 +00002586 (outs GR16:$dst),
2587 (ins GR16:$src1, GR16:$src2, i8imm:$src3),
Dan Gohman91888f02007-07-31 20:11:57 +00002588 "shrd{w}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002589 [(set GR16:$dst, (X86shrd GR16:$src1, GR16:$src2,
2590 (i8 imm:$src3)))]>,
2591 TB, OpSize;
2592}
2593
2594let isTwoAddress = 0 in {
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002595 let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00002596 def SHLD32mrCL : I<0xA5, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
Eli Friedman378ea832009-06-19 04:48:38 +00002597 "shld{l}\t{%cl, $src2, $dst|$dst, $src2, CL}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002598 [(store (X86shld (loadi32 addr:$dst), GR32:$src2, CL),
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002599 addr:$dst)]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00002600 def SHRD32mrCL : I<0xAD, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
Eli Friedman378ea832009-06-19 04:48:38 +00002601 "shrd{l}\t{%cl, $src2, $dst|$dst, $src2, CL}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002602 [(store (X86shrd (loadi32 addr:$dst), GR32:$src2, CL),
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002603 addr:$dst)]>, TB;
2604 }
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002605 def SHLD32mri8 : Ii8<0xA4, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00002606 (outs), (ins i32mem:$dst, GR32:$src2, i8imm:$src3),
Dan Gohman91888f02007-07-31 20:11:57 +00002607 "shld{l}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002608 [(store (X86shld (loadi32 addr:$dst), GR32:$src2,
2609 (i8 imm:$src3)), addr:$dst)]>,
2610 TB;
2611 def SHRD32mri8 : Ii8<0xAC, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00002612 (outs), (ins i32mem:$dst, GR32:$src2, i8imm:$src3),
Dan Gohman91888f02007-07-31 20:11:57 +00002613 "shrd{l}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002614 [(store (X86shrd (loadi32 addr:$dst), GR32:$src2,
2615 (i8 imm:$src3)), addr:$dst)]>,
2616 TB;
2617
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002618 let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00002619 def SHLD16mrCL : I<0xA5, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
Eli Friedman378ea832009-06-19 04:48:38 +00002620 "shld{w}\t{%cl, $src2, $dst|$dst, $src2, CL}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002621 [(store (X86shld (loadi16 addr:$dst), GR16:$src2, CL),
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002622 addr:$dst)]>, TB, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002623 def SHRD16mrCL : I<0xAD, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
Eli Friedman378ea832009-06-19 04:48:38 +00002624 "shrd{w}\t{%cl, $src2, $dst|$dst, $src2, CL}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002625 [(store (X86shrd (loadi16 addr:$dst), GR16:$src2, CL),
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002626 addr:$dst)]>, TB, OpSize;
2627 }
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002628 def SHLD16mri8 : Ii8<0xA4, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00002629 (outs), (ins i16mem:$dst, GR16:$src2, i8imm:$src3),
Dan Gohman91888f02007-07-31 20:11:57 +00002630 "shld{w}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002631 [(store (X86shld (loadi16 addr:$dst), GR16:$src2,
2632 (i8 imm:$src3)), addr:$dst)]>,
2633 TB, OpSize;
2634 def SHRD16mri8 : Ii8<0xAC, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00002635 (outs), (ins i16mem:$dst, GR16:$src2, i8imm:$src3),
Dan Gohman91888f02007-07-31 20:11:57 +00002636 "shrd{w}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002637 [(store (X86shrd (loadi16 addr:$dst), GR16:$src2,
2638 (i8 imm:$src3)), addr:$dst)]>,
2639 TB, OpSize;
2640}
Evan Cheng55687072007-09-14 21:48:26 +00002641} // Defs = [EFLAGS]
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002642
2643
2644// Arithmetic.
Evan Cheng55687072007-09-14 21:48:26 +00002645let Defs = [EFLAGS] in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002646let isCommutable = 1 in { // X = ADD Y, Z --> X = ADD Z, Y
Bill Wendlingae034ed2008-12-12 00:56:36 +00002647// Register-Register Addition
2648def ADD8rr : I<0x00, MRMDestReg, (outs GR8 :$dst),
2649 (ins GR8 :$src1, GR8 :$src2),
2650 "add{b}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002651 [(set GR8:$dst, (add GR8:$src1, GR8:$src2)),
Bill Wendlingae034ed2008-12-12 00:56:36 +00002652 (implicit EFLAGS)]>;
2653
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002654let isConvertibleToThreeAddress = 1 in { // Can transform into LEA.
Bill Wendlingae034ed2008-12-12 00:56:36 +00002655// Register-Register Addition
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002656def ADD16rr : I<0x01, MRMDestReg, (outs GR16:$dst),
2657 (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002658 "add{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002659 [(set GR16:$dst, (add GR16:$src1, GR16:$src2)),
2660 (implicit EFLAGS)]>, OpSize;
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002661def ADD32rr : I<0x01, MRMDestReg, (outs GR32:$dst),
2662 (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002663 "add{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002664 [(set GR32:$dst, (add GR32:$src1, GR32:$src2)),
2665 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002666} // end isConvertibleToThreeAddress
2667} // end isCommutable
Bill Wendlingae034ed2008-12-12 00:56:36 +00002668
2669// Register-Memory Addition
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002670def ADD8rm : I<0x02, MRMSrcMem, (outs GR8 :$dst),
2671 (ins GR8 :$src1, i8mem :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002672 "add{b}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002673 [(set GR8:$dst, (add GR8:$src1, (load addr:$src2))),
2674 (implicit EFLAGS)]>;
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002675def ADD16rm : I<0x03, MRMSrcMem, (outs GR16:$dst),
2676 (ins GR16:$src1, i16mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002677 "add{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002678 [(set GR16:$dst, (add GR16:$src1, (load addr:$src2))),
2679 (implicit EFLAGS)]>, OpSize;
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002680def ADD32rm : I<0x03, MRMSrcMem, (outs GR32:$dst),
2681 (ins GR32:$src1, i32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002682 "add{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002683 [(set GR32:$dst, (add GR32:$src1, (load addr:$src2))),
2684 (implicit EFLAGS)]>;
Sean Callanan7e7df0e2009-09-15 20:53:57 +00002685
Sean Callanan84df9312009-09-15 21:43:27 +00002686// Register-Register Addition - Equivalent to the normal rr forms (ADD8rr,
2687// ADD16rr, and ADD32rr), but differently encoded.
Sean Callanan7e7df0e2009-09-15 20:53:57 +00002688def ADD8mrmrr: I<0x02, MRMSrcReg, (outs GR8:$dst), (ins GR8:$src1, GR8:$src2),
2689 "add{b}\t{$src2, $dst|$dst, $src2}", []>;
2690def ADD16mrmrr: I<0x03, MRMSrcReg,(outs GR16:$dst),(ins GR16:$src1, GR16:$src2),
2691 "add{w}\t{$src2, $dst|$dst, $src2}", []>, OpSize;
2692def ADD32mrmrr: I<0x03, MRMSrcReg,(outs GR16:$dst),(ins GR16:$src1, GR16:$src2),
2693 "add{l}\t{$src2, $dst|$dst, $src2}", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002694
Bill Wendlingae034ed2008-12-12 00:56:36 +00002695// Register-Integer Addition
2696def ADD8ri : Ii8<0x80, MRM0r, (outs GR8:$dst), (ins GR8:$src1, i8imm:$src2),
2697 "add{b}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002698 [(set GR8:$dst, (add GR8:$src1, imm:$src2)),
2699 (implicit EFLAGS)]>;
Bill Wendlingae034ed2008-12-12 00:56:36 +00002700
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002701let isConvertibleToThreeAddress = 1 in { // Can transform into LEA.
Bill Wendlingae034ed2008-12-12 00:56:36 +00002702// Register-Integer Addition
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002703def ADD16ri : Ii16<0x81, MRM0r, (outs GR16:$dst),
2704 (ins GR16:$src1, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002705 "add{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002706 [(set GR16:$dst, (add GR16:$src1, imm:$src2)),
2707 (implicit EFLAGS)]>, OpSize;
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002708def ADD32ri : Ii32<0x81, MRM0r, (outs GR32:$dst),
2709 (ins GR32:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002710 "add{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002711 [(set GR32:$dst, (add GR32:$src1, imm:$src2)),
2712 (implicit EFLAGS)]>;
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002713def ADD16ri8 : Ii8<0x83, MRM0r, (outs GR16:$dst),
2714 (ins GR16:$src1, i16i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002715 "add{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002716 [(set GR16:$dst, (add GR16:$src1, i16immSExt8:$src2)),
2717 (implicit EFLAGS)]>, OpSize;
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002718def ADD32ri8 : Ii8<0x83, MRM0r, (outs GR32:$dst),
2719 (ins GR32:$src1, i32i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002720 "add{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002721 [(set GR32:$dst, (add GR32:$src1, i32immSExt8:$src2)),
2722 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002723}
2724
2725let isTwoAddress = 0 in {
Bill Wendlingae034ed2008-12-12 00:56:36 +00002726 // Memory-Register Addition
Bill Wendlingf5399032008-12-12 21:15:41 +00002727 def ADD8mr : I<0x00, MRMDestMem, (outs), (ins i8mem:$dst, GR8:$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 (load addr:$dst), GR8:$src2), addr:$dst),
2730 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002731 def ADD16mr : I<0x01, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$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 (load addr:$dst), GR16:$src2), addr:$dst),
2734 (implicit EFLAGS)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002735 def ADD32mr : I<0x01, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$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 (load addr:$dst), GR32:$src2), addr:$dst),
2738 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002739 def ADD8mi : Ii8<0x80, MRM0m, (outs), (ins i8mem :$dst, i8imm :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002740 "add{b}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002741 [(store (add (loadi8 addr:$dst), imm:$src2), addr:$dst),
2742 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002743 def ADD16mi : Ii16<0x81, MRM0m, (outs), (ins i16mem:$dst, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002744 "add{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002745 [(store (add (loadi16 addr:$dst), imm:$src2), addr:$dst),
2746 (implicit EFLAGS)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002747 def ADD32mi : Ii32<0x81, MRM0m, (outs), (ins i32mem:$dst, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002748 "add{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002749 [(store (add (loadi32 addr:$dst), imm:$src2), addr:$dst),
2750 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002751 def ADD16mi8 : Ii8<0x83, MRM0m, (outs), (ins i16mem:$dst, i16i8imm :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002752 "add{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002753 [(store (add (load addr:$dst), i16immSExt8:$src2),
2754 addr:$dst),
2755 (implicit EFLAGS)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002756 def ADD32mi8 : Ii8<0x83, MRM0m, (outs), (ins i32mem:$dst, i32i8imm :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002757 "add{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingae034ed2008-12-12 00:56:36 +00002758 [(store (add (load addr:$dst), i32immSExt8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00002759 addr:$dst),
2760 (implicit EFLAGS)]>;
Sean Callanan0316b342009-08-11 21:26:06 +00002761
2762 // addition to rAX
2763 def ADD8i8 : Ii8<0x04, RawFrm, (outs), (ins i8imm:$src),
Sean Callanan251676e2009-09-02 00:55:49 +00002764 "add{b}\t{$src, %al|%al, $src}", []>;
Sean Callanan0316b342009-08-11 21:26:06 +00002765 def ADD16i16 : Ii16<0x05, RawFrm, (outs), (ins i16imm:$src),
Sean Callanan251676e2009-09-02 00:55:49 +00002766 "add{w}\t{$src, %ax|%ax, $src}", []>, OpSize;
Sean Callanan0316b342009-08-11 21:26:06 +00002767 def ADD32i32 : Ii32<0x05, RawFrm, (outs), (ins i32imm:$src),
Sean Callanan251676e2009-09-02 00:55:49 +00002768 "add{l}\t{$src, %eax|%eax, $src}", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002769}
2770
Evan Cheng259471d2007-10-05 17:59:57 +00002771let Uses = [EFLAGS] in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002772let isCommutable = 1 in { // X = ADC Y, Z --> X = ADC Z, Y
Dale Johannesen747fe522009-06-02 03:12:52 +00002773def ADC8rr : I<0x10, MRMDestReg, (outs GR8:$dst), (ins GR8:$src1, GR8:$src2),
Dale Johannesen06b83f12009-05-18 17:44:15 +00002774 "adc{b}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002775 [(set GR8:$dst, (adde GR8:$src1, GR8:$src2))]>;
Dale Johannesen06b83f12009-05-18 17:44:15 +00002776def ADC16rr : I<0x11, MRMDestReg, (outs GR16:$dst),
2777 (ins GR16:$src1, GR16:$src2),
2778 "adc{w}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002779 [(set GR16:$dst, (adde GR16:$src1, GR16:$src2))]>, OpSize;
Dale Johannesen06b83f12009-05-18 17:44:15 +00002780def ADC32rr : I<0x11, MRMDestReg, (outs GR32:$dst),
2781 (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002782 "adc{l}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002783 [(set GR32:$dst, (adde GR32:$src1, GR32:$src2))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002784}
Sean Callanan2c48df22009-12-18 00:01:26 +00002785
2786def ADC8rr_REV : I<0x12, MRMSrcReg, (outs GR8:$dst), (ins GR8:$src1, GR8:$src2),
2787 "adc{b}\t{$src2, $dst|$dst, $src2}", []>;
2788def ADC16rr_REV : I<0x13, MRMSrcReg, (outs GR16:$dst),
2789 (ins GR16:$src1, GR16:$src2),
2790 "adc{w}\t{$src2, $dst|$dst, $src2}", []>, OpSize;
2791def ADC32rr_REV : I<0x13, MRMSrcReg, (outs GR32:$dst),
2792 (ins GR32:$src1, GR32:$src2),
2793 "adc{l}\t{$src2, $dst|$dst, $src2}", []>;
2794
Dale Johannesen06b83f12009-05-18 17:44:15 +00002795def ADC8rm : I<0x12, MRMSrcMem , (outs GR8:$dst),
2796 (ins GR8:$src1, i8mem:$src2),
2797 "adc{b}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002798 [(set GR8:$dst, (adde GR8:$src1, (load addr:$src2)))]>;
Dale Johannesen06b83f12009-05-18 17:44:15 +00002799def ADC16rm : I<0x13, MRMSrcMem , (outs GR16:$dst),
2800 (ins GR16:$src1, i16mem:$src2),
2801 "adc{w}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002802 [(set GR16:$dst, (adde GR16:$src1, (load addr:$src2)))]>,
Dale Johannesen067cfb22009-05-18 21:41:59 +00002803 OpSize;
Dale Johannesen06b83f12009-05-18 17:44:15 +00002804def ADC32rm : I<0x13, MRMSrcMem , (outs GR32:$dst),
2805 (ins GR32:$src1, i32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002806 "adc{l}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002807 [(set GR32:$dst, (adde GR32:$src1, (load addr:$src2)))]>;
2808def ADC8ri : Ii8<0x80, MRM2r, (outs GR8:$dst), (ins GR8:$src1, i8imm:$src2),
Dale Johannesen06b83f12009-05-18 17:44:15 +00002809 "adc{b}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002810 [(set GR8:$dst, (adde GR8:$src1, imm:$src2))]>;
Dale Johannesen06b83f12009-05-18 17:44:15 +00002811def ADC16ri : Ii16<0x81, MRM2r, (outs GR16:$dst),
2812 (ins GR16:$src1, i16imm:$src2),
2813 "adc{w}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002814 [(set GR16:$dst, (adde GR16:$src1, imm:$src2))]>, OpSize;
Dale Johannesen06b83f12009-05-18 17:44:15 +00002815def ADC16ri8 : Ii8<0x83, MRM2r, (outs GR16:$dst),
2816 (ins GR16:$src1, i16i8imm:$src2),
2817 "adc{w}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002818 [(set GR16:$dst, (adde GR16:$src1, i16immSExt8:$src2))]>,
2819 OpSize;
Dale Johannesen06b83f12009-05-18 17:44:15 +00002820def ADC32ri : Ii32<0x81, MRM2r, (outs GR32:$dst),
2821 (ins GR32:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002822 "adc{l}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002823 [(set GR32:$dst, (adde GR32:$src1, imm:$src2))]>;
Dale Johannesen06b83f12009-05-18 17:44:15 +00002824def ADC32ri8 : Ii8<0x83, MRM2r, (outs GR32:$dst),
2825 (ins GR32:$src1, i32i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002826 "adc{l}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002827 [(set GR32:$dst, (adde GR32:$src1, i32immSExt8:$src2))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002828
2829let isTwoAddress = 0 in {
Dale Johannesen747fe522009-06-02 03:12:52 +00002830 def ADC8mr : I<0x10, MRMDestMem, (outs), (ins i8mem:$dst, GR8:$src2),
Dale Johannesen06b83f12009-05-18 17:44:15 +00002831 "adc{b}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002832 [(store (adde (load addr:$dst), GR8:$src2), addr:$dst)]>;
2833 def ADC16mr : I<0x11, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
Dale Johannesen06b83f12009-05-18 17:44:15 +00002834 "adc{w}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002835 [(store (adde (load addr:$dst), GR16:$src2), addr:$dst)]>,
2836 OpSize;
2837 def ADC32mr : I<0x11, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002838 "adc{l}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002839 [(store (adde (load addr:$dst), GR32:$src2), addr:$dst)]>;
2840 def ADC8mi : Ii8<0x80, MRM2m, (outs), (ins i8mem:$dst, i8imm:$src2),
Dale Johannesen06b83f12009-05-18 17:44:15 +00002841 "adc{b}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002842 [(store (adde (loadi8 addr:$dst), imm:$src2), addr:$dst)]>;
2843 def ADC16mi : Ii16<0x81, MRM2m, (outs), (ins i16mem:$dst, i16imm:$src2),
Dale Johannesen06b83f12009-05-18 17:44:15 +00002844 "adc{w}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002845 [(store (adde (loadi16 addr:$dst), imm:$src2), addr:$dst)]>,
2846 OpSize;
2847 def ADC16mi8 : Ii8<0x83, MRM2m, (outs), (ins i16mem:$dst, i16i8imm :$src2),
Dale Johannesen06b83f12009-05-18 17:44:15 +00002848 "adc{w}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002849 [(store (adde (load addr:$dst), i16immSExt8:$src2), addr:$dst)]>,
2850 OpSize;
2851 def ADC32mi : Ii32<0x81, MRM2m, (outs), (ins i32mem:$dst, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002852 "adc{l}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002853 [(store (adde (loadi32 addr:$dst), imm:$src2), addr:$dst)]>;
2854 def ADC32mi8 : Ii8<0x83, MRM2m, (outs), (ins i32mem:$dst, i32i8imm :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002855 "adc{l}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002856 [(store (adde (load addr:$dst), i32immSExt8:$src2), addr:$dst)]>;
Sean Callanan8562bef2009-09-11 19:01:56 +00002857
2858 def ADC8i8 : Ii8<0x14, RawFrm, (outs), (ins i8imm:$src),
2859 "adc{b}\t{$src, %al|%al, $src}", []>;
2860 def ADC16i16 : Ii16<0x15, RawFrm, (outs), (ins i16imm:$src),
2861 "adc{w}\t{$src, %ax|%ax, $src}", []>, OpSize;
2862 def ADC32i32 : Ii32<0x15, RawFrm, (outs), (ins i32imm:$src),
2863 "adc{l}\t{$src, %eax|%eax, $src}", []>;
Dale Johannesen747fe522009-06-02 03:12:52 +00002864}
Evan Cheng259471d2007-10-05 17:59:57 +00002865} // Uses = [EFLAGS]
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002866
Bill Wendlingae034ed2008-12-12 00:56:36 +00002867// Register-Register Subtraction
2868def SUB8rr : I<0x28, MRMDestReg, (outs GR8:$dst), (ins GR8:$src1, GR8:$src2),
2869 "sub{b}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002870 [(set GR8:$dst, (sub GR8:$src1, GR8:$src2)),
2871 (implicit EFLAGS)]>;
Bill Wendlingae034ed2008-12-12 00:56:36 +00002872def SUB16rr : I<0x29, MRMDestReg, (outs GR16:$dst), (ins GR16:$src1,GR16:$src2),
2873 "sub{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002874 [(set GR16:$dst, (sub GR16:$src1, GR16:$src2)),
2875 (implicit EFLAGS)]>, OpSize;
Bill Wendlingae034ed2008-12-12 00:56:36 +00002876def SUB32rr : I<0x29, MRMDestReg, (outs GR32:$dst), (ins GR32:$src1,GR32:$src2),
2877 "sub{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002878 [(set GR32:$dst, (sub GR32:$src1, GR32:$src2)),
2879 (implicit EFLAGS)]>;
Bill Wendlingae034ed2008-12-12 00:56:36 +00002880
Sean Callanan2c48df22009-12-18 00:01:26 +00002881def SUB8rr_REV : I<0x2A, MRMSrcReg, (outs GR8:$dst), (ins GR8:$src1, GR8:$src2),
2882 "sub{b}\t{$src2, $dst|$dst, $src2}", []>;
2883def SUB16rr_REV : I<0x2B, MRMSrcReg, (outs GR16:$dst),
2884 (ins GR16:$src1, GR16:$src2),
2885 "sub{w}\t{$src2, $dst|$dst, $src2}", []>, OpSize;
2886def SUB32rr_REV : I<0x2B, MRMSrcReg, (outs GR32:$dst),
2887 (ins GR32:$src1, GR32:$src2),
2888 "sub{l}\t{$src2, $dst|$dst, $src2}", []>;
2889
Bill Wendlingae034ed2008-12-12 00:56:36 +00002890// Register-Memory Subtraction
2891def SUB8rm : I<0x2A, MRMSrcMem, (outs GR8 :$dst),
2892 (ins GR8 :$src1, i8mem :$src2),
2893 "sub{b}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002894 [(set GR8:$dst, (sub GR8:$src1, (load addr:$src2))),
2895 (implicit EFLAGS)]>;
Bill Wendlingae034ed2008-12-12 00:56:36 +00002896def SUB16rm : I<0x2B, MRMSrcMem, (outs GR16:$dst),
2897 (ins GR16:$src1, i16mem:$src2),
2898 "sub{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002899 [(set GR16:$dst, (sub GR16:$src1, (load addr:$src2))),
2900 (implicit EFLAGS)]>, OpSize;
Bill Wendlingae034ed2008-12-12 00:56:36 +00002901def SUB32rm : I<0x2B, MRMSrcMem, (outs GR32:$dst),
2902 (ins GR32:$src1, i32mem:$src2),
2903 "sub{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002904 [(set GR32:$dst, (sub GR32:$src1, (load addr:$src2))),
2905 (implicit EFLAGS)]>;
Bill Wendlingae034ed2008-12-12 00:56:36 +00002906
2907// Register-Integer Subtraction
2908def SUB8ri : Ii8 <0x80, MRM5r, (outs GR8:$dst),
2909 (ins GR8:$src1, i8imm:$src2),
2910 "sub{b}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002911 [(set GR8:$dst, (sub GR8:$src1, imm:$src2)),
2912 (implicit EFLAGS)]>;
Bill Wendlingae034ed2008-12-12 00:56:36 +00002913def SUB16ri : Ii16<0x81, MRM5r, (outs GR16:$dst),
2914 (ins GR16:$src1, i16imm:$src2),
2915 "sub{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002916 [(set GR16:$dst, (sub GR16:$src1, imm:$src2)),
2917 (implicit EFLAGS)]>, OpSize;
Bill Wendlingae034ed2008-12-12 00:56:36 +00002918def SUB32ri : Ii32<0x81, MRM5r, (outs GR32:$dst),
2919 (ins GR32:$src1, i32imm:$src2),
2920 "sub{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002921 [(set GR32:$dst, (sub GR32:$src1, imm:$src2)),
2922 (implicit EFLAGS)]>;
Bill Wendlingae034ed2008-12-12 00:56:36 +00002923def SUB16ri8 : Ii8<0x83, MRM5r, (outs GR16:$dst),
2924 (ins GR16:$src1, i16i8imm:$src2),
2925 "sub{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002926 [(set GR16:$dst, (sub GR16:$src1, i16immSExt8:$src2)),
2927 (implicit EFLAGS)]>, OpSize;
Bill Wendlingae034ed2008-12-12 00:56:36 +00002928def SUB32ri8 : Ii8<0x83, MRM5r, (outs GR32:$dst),
2929 (ins GR32:$src1, i32i8imm:$src2),
2930 "sub{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002931 [(set GR32:$dst, (sub GR32:$src1, i32immSExt8:$src2)),
2932 (implicit EFLAGS)]>;
Bill Wendlingae034ed2008-12-12 00:56:36 +00002933
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002934let isTwoAddress = 0 in {
Bill Wendlingae034ed2008-12-12 00:56:36 +00002935 // Memory-Register Subtraction
Evan Chengb783fa32007-07-19 01:14:50 +00002936 def SUB8mr : I<0x28, MRMDestMem, (outs), (ins i8mem :$dst, GR8 :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002937 "sub{b}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002938 [(store (sub (load addr:$dst), GR8:$src2), addr:$dst),
2939 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002940 def SUB16mr : I<0x29, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002941 "sub{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002942 [(store (sub (load addr:$dst), GR16:$src2), addr:$dst),
2943 (implicit EFLAGS)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002944 def SUB32mr : I<0x29, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002945 "sub{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002946 [(store (sub (load addr:$dst), GR32:$src2), addr:$dst),
2947 (implicit EFLAGS)]>;
Bill Wendlingae034ed2008-12-12 00:56:36 +00002948
2949 // Memory-Integer Subtraction
Evan Chengb783fa32007-07-19 01:14:50 +00002950 def SUB8mi : Ii8<0x80, MRM5m, (outs), (ins i8mem :$dst, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002951 "sub{b}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002952 [(store (sub (loadi8 addr:$dst), imm:$src2), addr:$dst),
2953 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002954 def SUB16mi : Ii16<0x81, MRM5m, (outs), (ins i16mem:$dst, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002955 "sub{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002956 [(store (sub (loadi16 addr:$dst), imm:$src2),addr:$dst),
2957 (implicit EFLAGS)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002958 def SUB32mi : Ii32<0x81, MRM5m, (outs), (ins i32mem:$dst, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002959 "sub{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002960 [(store (sub (loadi32 addr:$dst), imm:$src2),addr:$dst),
2961 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002962 def SUB16mi8 : Ii8<0x83, MRM5m, (outs), (ins i16mem:$dst, i16i8imm :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002963 "sub{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingae034ed2008-12-12 00:56:36 +00002964 [(store (sub (load addr:$dst), i16immSExt8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00002965 addr:$dst),
2966 (implicit EFLAGS)]>, OpSize;
Bill Wendlingae034ed2008-12-12 00:56:36 +00002967 def SUB32mi8 : Ii8<0x83, MRM5m, (outs), (ins i32mem:$dst, i32i8imm :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002968 "sub{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingae034ed2008-12-12 00:56:36 +00002969 [(store (sub (load addr:$dst), i32immSExt8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00002970 addr:$dst),
2971 (implicit EFLAGS)]>;
Sean Callanan8562bef2009-09-11 19:01:56 +00002972
2973 def SUB8i8 : Ii8<0x2C, RawFrm, (outs), (ins i8imm:$src),
2974 "sub{b}\t{$src, %al|%al, $src}", []>;
2975 def SUB16i16 : Ii16<0x2D, RawFrm, (outs), (ins i16imm:$src),
2976 "sub{w}\t{$src, %ax|%ax, $src}", []>, OpSize;
2977 def SUB32i32 : Ii32<0x2D, RawFrm, (outs), (ins i32imm:$src),
2978 "sub{l}\t{$src, %eax|%eax, $src}", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002979}
2980
Evan Cheng259471d2007-10-05 17:59:57 +00002981let Uses = [EFLAGS] in {
Dale Johannesen06b83f12009-05-18 17:44:15 +00002982def SBB8rr : I<0x18, MRMDestReg, (outs GR8:$dst),
2983 (ins GR8:$src1, GR8:$src2),
2984 "sbb{b}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002985 [(set GR8:$dst, (sube GR8:$src1, GR8:$src2))]>;
Dale Johannesen06b83f12009-05-18 17:44:15 +00002986def SBB16rr : I<0x19, MRMDestReg, (outs GR16:$dst),
2987 (ins GR16:$src1, GR16:$src2),
2988 "sbb{w}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002989 [(set GR16:$dst, (sube GR16:$src1, GR16:$src2))]>, OpSize;
Dale Johannesen06b83f12009-05-18 17:44:15 +00002990def SBB32rr : I<0x19, MRMDestReg, (outs GR32:$dst),
2991 (ins GR32:$src1, 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 [(set GR32:$dst, (sube GR32:$src1, GR32:$src2))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002994
2995let isTwoAddress = 0 in {
Dale Johannesen06b83f12009-05-18 17:44:15 +00002996 def SBB8mr : I<0x18, MRMDestMem, (outs), (ins i8mem:$dst, GR8:$src2),
2997 "sbb{b}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002998 [(store (sube (load addr:$dst), GR8:$src2), addr:$dst)]>;
Dale Johannesen06b83f12009-05-18 17:44:15 +00002999 def SBB16mr : I<0x19, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
3000 "sbb{w}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00003001 [(store (sube (load addr:$dst), GR16:$src2), addr:$dst)]>,
Dale Johannesen067cfb22009-05-18 21:41:59 +00003002 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00003003 def SBB32mr : I<0x19, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00003004 "sbb{l}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00003005 [(store (sube (load addr:$dst), GR32:$src2), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00003006 def SBB8mi : Ii32<0x80, MRM3m, (outs), (ins i8mem:$dst, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00003007 "sbb{b}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00003008 [(store (sube (loadi8 addr:$dst), imm:$src2), addr:$dst)]>;
Dale Johannesen06b83f12009-05-18 17:44:15 +00003009 def SBB16mi : Ii16<0x81, MRM3m, (outs), (ins i16mem:$dst, i16imm:$src2),
3010 "sbb{w}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00003011 [(store (sube (loadi16 addr:$dst), imm:$src2), addr:$dst)]>,
Dale Johannesen067cfb22009-05-18 21:41:59 +00003012 OpSize;
Dale Johannesen06b83f12009-05-18 17:44:15 +00003013 def SBB16mi8 : Ii8<0x83, MRM3m, (outs), (ins i16mem:$dst, i16i8imm :$src2),
3014 "sbb{w}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00003015 [(store (sube (load addr:$dst), i16immSExt8:$src2), addr:$dst)]>,
Dale Johannesen067cfb22009-05-18 21:41:59 +00003016 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00003017 def SBB32mi : Ii32<0x81, MRM3m, (outs), (ins i32mem:$dst, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00003018 "sbb{l}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00003019 [(store (sube (loadi32 addr:$dst), imm:$src2), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00003020 def SBB32mi8 : Ii8<0x83, MRM3m, (outs), (ins i32mem:$dst, i32i8imm :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00003021 "sbb{l}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00003022 [(store (sube (load addr:$dst), i32immSExt8:$src2), addr:$dst)]>;
Sean Callanan8562bef2009-09-11 19:01:56 +00003023
3024 def SBB8i8 : Ii8<0x1C, RawFrm, (outs), (ins i8imm:$src),
3025 "sbb{b}\t{$src, %al|%al, $src}", []>;
3026 def SBB16i16 : Ii16<0x1D, RawFrm, (outs), (ins i16imm:$src),
3027 "sbb{w}\t{$src, %ax|%ax, $src}", []>, OpSize;
3028 def SBB32i32 : Ii32<0x1D, RawFrm, (outs), (ins i32imm:$src),
3029 "sbb{l}\t{$src, %eax|%eax, $src}", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003030}
Sean Callanan2c48df22009-12-18 00:01:26 +00003031
3032def SBB8rr_REV : I<0x1A, MRMSrcReg, (outs GR8:$dst), (ins GR8:$src1, GR8:$src2),
3033 "sbb{b}\t{$src2, $dst|$dst, $src2}", []>;
3034def SBB16rr_REV : I<0x1B, MRMSrcReg, (outs GR16:$dst),
3035 (ins GR16:$src1, GR16:$src2),
3036 "sbb{w}\t{$src2, $dst|$dst, $src2}", []>, OpSize;
3037def SBB32rr_REV : I<0x1B, MRMSrcReg, (outs GR32:$dst),
3038 (ins GR32:$src1, GR32:$src2),
3039 "sbb{l}\t{$src2, $dst|$dst, $src2}", []>;
3040
Dale Johannesen06b83f12009-05-18 17:44:15 +00003041def SBB8rm : I<0x1A, MRMSrcMem, (outs GR8:$dst), (ins GR8:$src1, i8mem:$src2),
3042 "sbb{b}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00003043 [(set GR8:$dst, (sube GR8:$src1, (load addr:$src2)))]>;
Dale Johannesen06b83f12009-05-18 17:44:15 +00003044def SBB16rm : I<0x1B, MRMSrcMem, (outs GR16:$dst),
3045 (ins GR16:$src1, i16mem:$src2),
3046 "sbb{w}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00003047 [(set GR16:$dst, (sube GR16:$src1, (load addr:$src2)))]>,
Dale Johannesen067cfb22009-05-18 21:41:59 +00003048 OpSize;
Dale Johannesen06b83f12009-05-18 17:44:15 +00003049def SBB32rm : I<0x1B, MRMSrcMem, (outs GR32:$dst),
3050 (ins GR32:$src1, i32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00003051 "sbb{l}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00003052 [(set GR32:$dst, (sube GR32:$src1, (load addr:$src2)))]>;
Dale Johannesen06b83f12009-05-18 17:44:15 +00003053def SBB8ri : Ii8<0x80, MRM3r, (outs GR8:$dst), (ins GR8:$src1, i8imm:$src2),
3054 "sbb{b}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00003055 [(set GR8:$dst, (sube GR8:$src1, imm:$src2))]>;
Dale Johannesen06b83f12009-05-18 17:44:15 +00003056def SBB16ri : Ii16<0x81, MRM3r, (outs GR16:$dst),
3057 (ins GR16:$src1, i16imm:$src2),
3058 "sbb{w}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00003059 [(set GR16:$dst, (sube GR16:$src1, imm:$src2))]>, OpSize;
Dale Johannesen06b83f12009-05-18 17:44:15 +00003060def SBB16ri8 : Ii8<0x83, MRM3r, (outs GR16:$dst),
3061 (ins GR16:$src1, i16i8imm:$src2),
3062 "sbb{w}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00003063 [(set GR16:$dst, (sube GR16:$src1, i16immSExt8:$src2))]>,
3064 OpSize;
Dale Johannesen06b83f12009-05-18 17:44:15 +00003065def SBB32ri : Ii32<0x81, MRM3r, (outs GR32:$dst),
3066 (ins GR32:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00003067 "sbb{l}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00003068 [(set GR32:$dst, (sube GR32:$src1, imm:$src2))]>;
Dale Johannesen06b83f12009-05-18 17:44:15 +00003069def SBB32ri8 : Ii8<0x83, MRM3r, (outs GR32:$dst),
3070 (ins GR32:$src1, i32i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00003071 "sbb{l}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00003072 [(set GR32:$dst, (sube GR32:$src1, i32immSExt8:$src2))]>;
Evan Cheng259471d2007-10-05 17:59:57 +00003073} // Uses = [EFLAGS]
Evan Cheng55687072007-09-14 21:48:26 +00003074} // Defs = [EFLAGS]
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003075
Evan Cheng55687072007-09-14 21:48:26 +00003076let Defs = [EFLAGS] in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003077let isCommutable = 1 in { // X = IMUL Y, Z --> X = IMUL Z, Y
Bill Wendlingf5399032008-12-12 21:15:41 +00003078// Register-Register Signed Integer Multiply
Bill Wendlingae034ed2008-12-12 00:56:36 +00003079def IMUL16rr : I<0xAF, MRMSrcReg, (outs GR16:$dst), (ins GR16:$src1,GR16:$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, GR16:$src2)),
3082 (implicit EFLAGS)]>, TB, OpSize;
Bill Wendlingae034ed2008-12-12 00:56:36 +00003083def IMUL32rr : I<0xAF, MRMSrcReg, (outs GR32:$dst), (ins GR32:$src1,GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00003084 "imul{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00003085 [(set GR32:$dst, (mul GR32:$src1, GR32:$src2)),
3086 (implicit EFLAGS)]>, TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003087}
Bill Wendlingae034ed2008-12-12 00:56:36 +00003088
Bill Wendlingf5399032008-12-12 21:15:41 +00003089// Register-Memory Signed Integer Multiply
Bill Wendlingae034ed2008-12-12 00:56:36 +00003090def IMUL16rm : I<0xAF, MRMSrcMem, (outs GR16:$dst),
3091 (ins GR16:$src1, i16mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00003092 "imul{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00003093 [(set GR16:$dst, (mul GR16:$src1, (load addr:$src2))),
3094 (implicit EFLAGS)]>, TB, OpSize;
Sean Callanan2c48df22009-12-18 00:01:26 +00003095def IMUL32rm : I<0xAF, MRMSrcMem, (outs GR32:$dst),
3096 (ins GR32:$src1, i32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00003097 "imul{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00003098 [(set GR32:$dst, (mul GR32:$src1, (load addr:$src2))),
3099 (implicit EFLAGS)]>, TB;
Evan Cheng55687072007-09-14 21:48:26 +00003100} // Defs = [EFLAGS]
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003101} // end Two Address instructions
3102
3103// Suprisingly enough, these are not two address instructions!
Evan Cheng55687072007-09-14 21:48:26 +00003104let Defs = [EFLAGS] in {
Bill Wendlingf5399032008-12-12 21:15:41 +00003105// Register-Integer Signed Integer Multiply
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003106def IMUL16rri : Ii16<0x69, MRMSrcReg, // GR16 = GR16*I16
Evan Chengb783fa32007-07-19 01:14:50 +00003107 (outs GR16:$dst), (ins GR16:$src1, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00003108 "imul{w}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00003109 [(set GR16:$dst, (mul GR16:$src1, imm:$src2)),
3110 (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003111def IMUL32rri : Ii32<0x69, MRMSrcReg, // GR32 = GR32*I32
Evan Chengb783fa32007-07-19 01:14:50 +00003112 (outs GR32:$dst), (ins GR32:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00003113 "imul{l}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00003114 [(set GR32:$dst, (mul GR32:$src1, imm:$src2)),
3115 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003116def IMUL16rri8 : Ii8<0x6B, MRMSrcReg, // GR16 = GR16*I8
Evan Chengb783fa32007-07-19 01:14:50 +00003117 (outs GR16:$dst), (ins GR16:$src1, i16i8imm:$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 GR16:$src1, i16immSExt8:$src2)),
3120 (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003121def IMUL32rri8 : Ii8<0x6B, MRMSrcReg, // GR32 = GR32*I8
Evan Chengb783fa32007-07-19 01:14:50 +00003122 (outs GR32:$dst), (ins GR32:$src1, i32i8imm:$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 GR32:$src1, i32immSExt8:$src2)),
3125 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003126
Bill Wendlingf5399032008-12-12 21:15:41 +00003127// Memory-Integer Signed Integer Multiply
Sean Callanan2c48df22009-12-18 00:01:26 +00003128def IMUL16rmi : Ii16<0x69, MRMSrcMem, // GR16 = [mem16]*I16
Evan Chengb783fa32007-07-19 01:14:50 +00003129 (outs GR16:$dst), (ins i16mem:$src1, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00003130 "imul{w}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00003131 [(set GR16:$dst, (mul (load addr:$src1), imm:$src2)),
3132 (implicit EFLAGS)]>, OpSize;
Sean Callanan2c48df22009-12-18 00:01:26 +00003133def IMUL32rmi : Ii32<0x69, MRMSrcMem, // GR32 = [mem32]*I32
Evan Chengb783fa32007-07-19 01:14:50 +00003134 (outs GR32:$dst), (ins i32mem:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00003135 "imul{l}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00003136 [(set GR32:$dst, (mul (load addr:$src1), imm:$src2)),
3137 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003138def IMUL16rmi8 : Ii8<0x6B, MRMSrcMem, // GR16 = [mem16]*I8
Evan Chengb783fa32007-07-19 01:14:50 +00003139 (outs GR16:$dst), (ins i16mem:$src1, i16i8imm :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00003140 "imul{w}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Bill Wendlingae034ed2008-12-12 00:56:36 +00003141 [(set GR16:$dst, (mul (load addr:$src1),
Bill Wendlingf5399032008-12-12 21:15:41 +00003142 i16immSExt8:$src2)),
3143 (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003144def IMUL32rmi8 : Ii8<0x6B, MRMSrcMem, // GR32 = [mem32]*I8
Evan Chengb783fa32007-07-19 01:14:50 +00003145 (outs GR32:$dst), (ins i32mem:$src1, i32i8imm: $src2),
Dan Gohman91888f02007-07-31 20:11:57 +00003146 "imul{l}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Bill Wendlingae034ed2008-12-12 00:56:36 +00003147 [(set GR32:$dst, (mul (load addr:$src1),
Bill Wendlingf5399032008-12-12 21:15:41 +00003148 i32immSExt8:$src2)),
3149 (implicit EFLAGS)]>;
Evan Cheng55687072007-09-14 21:48:26 +00003150} // Defs = [EFLAGS]
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003151
3152//===----------------------------------------------------------------------===//
3153// Test instructions are just like AND, except they don't generate a result.
3154//
Evan Cheng950aac02007-09-25 01:57:46 +00003155let Defs = [EFLAGS] in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003156let isCommutable = 1 in { // TEST X, Y --> TEST Y, X
Evan Chengb783fa32007-07-19 01:14:50 +00003157def TEST8rr : I<0x84, MRMDestReg, (outs), (ins GR8:$src1, GR8:$src2),
Evan Cheng621216e2007-09-29 00:00:36 +00003158 "test{b}\t{$src2, $src1|$src1, $src2}",
Chris Lattner21da6382008-02-19 17:37:35 +00003159 [(X86cmp (and_su GR8:$src1, GR8:$src2), 0),
Evan Cheng621216e2007-09-29 00:00:36 +00003160 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00003161def TEST16rr : I<0x85, MRMDestReg, (outs), (ins GR16:$src1, GR16:$src2),
Evan Cheng621216e2007-09-29 00:00:36 +00003162 "test{w}\t{$src2, $src1|$src1, $src2}",
Chris Lattner21da6382008-02-19 17:37:35 +00003163 [(X86cmp (and_su GR16:$src1, GR16:$src2), 0),
Evan Cheng621216e2007-09-29 00:00:36 +00003164 (implicit EFLAGS)]>,
3165 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00003166def TEST32rr : I<0x85, MRMDestReg, (outs), (ins GR32:$src1, GR32:$src2),
Evan Cheng621216e2007-09-29 00:00:36 +00003167 "test{l}\t{$src2, $src1|$src1, $src2}",
Chris Lattner21da6382008-02-19 17:37:35 +00003168 [(X86cmp (and_su GR32:$src1, GR32:$src2), 0),
Evan Cheng621216e2007-09-29 00:00:36 +00003169 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003170}
3171
Sean Callanan3e4b1a32009-09-01 18:14:18 +00003172def TEST8i8 : Ii8<0xA8, RawFrm, (outs), (ins i8imm:$src),
3173 "test{b}\t{$src, %al|%al, $src}", []>;
3174def TEST16i16 : Ii16<0xA9, RawFrm, (outs), (ins i16imm:$src),
3175 "test{w}\t{$src, %ax|%ax, $src}", []>, OpSize;
3176def TEST32i32 : Ii32<0xA9, RawFrm, (outs), (ins i32imm:$src),
3177 "test{l}\t{$src, %eax|%eax, $src}", []>;
3178
Evan Chengb783fa32007-07-19 01:14:50 +00003179def TEST8rm : I<0x84, MRMSrcMem, (outs), (ins GR8 :$src1, i8mem :$src2),
Evan Cheng621216e2007-09-29 00:00:36 +00003180 "test{b}\t{$src2, $src1|$src1, $src2}",
3181 [(X86cmp (and GR8:$src1, (loadi8 addr:$src2)), 0),
3182 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00003183def TEST16rm : I<0x85, MRMSrcMem, (outs), (ins GR16:$src1, i16mem:$src2),
Evan Cheng621216e2007-09-29 00:00:36 +00003184 "test{w}\t{$src2, $src1|$src1, $src2}",
3185 [(X86cmp (and GR16:$src1, (loadi16 addr:$src2)), 0),
3186 (implicit EFLAGS)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00003187def TEST32rm : I<0x85, MRMSrcMem, (outs), (ins GR32:$src1, i32mem:$src2),
Evan Cheng621216e2007-09-29 00:00:36 +00003188 "test{l}\t{$src2, $src1|$src1, $src2}",
3189 [(X86cmp (and GR32:$src1, (loadi32 addr:$src2)), 0),
3190 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003191
3192def TEST8ri : Ii8 <0xF6, MRM0r, // flags = GR8 & imm8
Evan Chengb783fa32007-07-19 01:14:50 +00003193 (outs), (ins GR8:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00003194 "test{b}\t{$src2, $src1|$src1, $src2}",
Chris Lattner21da6382008-02-19 17:37:35 +00003195 [(X86cmp (and_su GR8:$src1, imm:$src2), 0),
Evan Cheng621216e2007-09-29 00:00:36 +00003196 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003197def TEST16ri : Ii16<0xF7, MRM0r, // flags = GR16 & imm16
Evan Chengb783fa32007-07-19 01:14:50 +00003198 (outs), (ins GR16:$src1, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00003199 "test{w}\t{$src2, $src1|$src1, $src2}",
Chris Lattner21da6382008-02-19 17:37:35 +00003200 [(X86cmp (and_su GR16:$src1, imm:$src2), 0),
Evan Cheng621216e2007-09-29 00:00:36 +00003201 (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003202def TEST32ri : Ii32<0xF7, MRM0r, // flags = GR32 & imm32
Evan Chengb783fa32007-07-19 01:14:50 +00003203 (outs), (ins GR32:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00003204 "test{l}\t{$src2, $src1|$src1, $src2}",
Chris Lattner21da6382008-02-19 17:37:35 +00003205 [(X86cmp (and_su GR32:$src1, imm:$src2), 0),
Evan Cheng621216e2007-09-29 00:00:36 +00003206 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003207
Evan Cheng621216e2007-09-29 00:00:36 +00003208def TEST8mi : Ii8 <0xF6, MRM0m, // flags = [mem8] & imm8
Evan Chengb783fa32007-07-19 01:14:50 +00003209 (outs), (ins i8mem:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00003210 "test{b}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00003211 [(X86cmp (and (loadi8 addr:$src1), imm:$src2), 0),
3212 (implicit EFLAGS)]>;
3213def TEST16mi : Ii16<0xF7, MRM0m, // flags = [mem16] & imm16
Evan Chengb783fa32007-07-19 01:14:50 +00003214 (outs), (ins i16mem:$src1, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00003215 "test{w}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00003216 [(X86cmp (and (loadi16 addr:$src1), imm:$src2), 0),
3217 (implicit EFLAGS)]>, OpSize;
3218def TEST32mi : Ii32<0xF7, MRM0m, // flags = [mem32] & imm32
Evan Chengb783fa32007-07-19 01:14:50 +00003219 (outs), (ins i32mem:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00003220 "test{l}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00003221 [(X86cmp (and (loadi32 addr:$src1), imm:$src2), 0),
Evan Cheng950aac02007-09-25 01:57:46 +00003222 (implicit EFLAGS)]>;
3223} // Defs = [EFLAGS]
3224
3225
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003226// Condition code ops, incl. set if equal/not equal/...
Chris Lattnerc90ee9c2008-01-10 07:59:24 +00003227let Defs = [EFLAGS], Uses = [AH], neverHasSideEffects = 1 in
Evan Cheng6e4d1d92007-09-11 19:55:27 +00003228def SAHF : I<0x9E, RawFrm, (outs), (ins), "sahf", []>; // flags = AH
Chris Lattnerc90ee9c2008-01-10 07:59:24 +00003229let Defs = [AH], Uses = [EFLAGS], neverHasSideEffects = 1 in
Evan Cheng6e4d1d92007-09-11 19:55:27 +00003230def LAHF : I<0x9F, RawFrm, (outs), (ins), "lahf", []>; // AH = flags
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003231
Evan Cheng950aac02007-09-25 01:57:46 +00003232let Uses = [EFLAGS] in {
Evan Cheng834ae6b2009-12-15 00:53:42 +00003233// Use sbb to materialize carry bit.
3234
3235let Defs = [EFLAGS], isCodeGenOnly = 1 in {
3236def SETB_C8r : I<0x18, MRMInitReg, (outs GR8:$dst), (ins),
3237 "sbb{b}\t$dst, $dst",
3238 [(set GR8:$dst, (X86setcc_c X86_COND_B, EFLAGS))]>;
3239def SETB_C16r : I<0x19, MRMInitReg, (outs GR16:$dst), (ins),
3240 "sbb{w}\t$dst, $dst",
Evan Chengedeb1692009-12-16 00:53:11 +00003241 [(set GR16:$dst, (X86setcc_c X86_COND_B, EFLAGS))]>,
Evan Cheng834ae6b2009-12-15 00:53:42 +00003242 OpSize;
3243def SETB_C32r : I<0x19, MRMInitReg, (outs GR32:$dst), (ins),
3244 "sbb{l}\t$dst, $dst",
Evan Chengedeb1692009-12-16 00:53:11 +00003245 [(set GR32:$dst, (X86setcc_c X86_COND_B, EFLAGS))]>;
Evan Cheng834ae6b2009-12-15 00:53:42 +00003246} // isCodeGenOnly
3247
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003248def SETEr : I<0x94, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00003249 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00003250 "sete\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00003251 [(set GR8:$dst, (X86setcc X86_COND_E, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003252 TB; // GR8 = ==
3253def SETEm : I<0x94, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00003254 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00003255 "sete\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00003256 [(store (X86setcc X86_COND_E, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003257 TB; // [mem8] = ==
Bill Wendling0c52d0a2008-12-02 00:07:05 +00003258
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003259def SETNEr : I<0x95, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00003260 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00003261 "setne\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00003262 [(set GR8:$dst, (X86setcc X86_COND_NE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003263 TB; // GR8 = !=
3264def SETNEm : I<0x95, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00003265 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00003266 "setne\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00003267 [(store (X86setcc X86_COND_NE, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003268 TB; // [mem8] = !=
Bill Wendling0c52d0a2008-12-02 00:07:05 +00003269
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003270def SETLr : I<0x9C, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00003271 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00003272 "setl\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00003273 [(set GR8:$dst, (X86setcc X86_COND_L, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003274 TB; // GR8 = < signed
3275def SETLm : I<0x9C, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00003276 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00003277 "setl\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00003278 [(store (X86setcc X86_COND_L, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003279 TB; // [mem8] = < signed
Bill Wendling0c52d0a2008-12-02 00:07:05 +00003280
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003281def SETGEr : I<0x9D, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00003282 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00003283 "setge\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00003284 [(set GR8:$dst, (X86setcc X86_COND_GE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003285 TB; // GR8 = >= signed
3286def SETGEm : I<0x9D, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00003287 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00003288 "setge\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00003289 [(store (X86setcc X86_COND_GE, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003290 TB; // [mem8] = >= signed
Bill Wendling0c52d0a2008-12-02 00:07:05 +00003291
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003292def SETLEr : I<0x9E, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00003293 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00003294 "setle\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00003295 [(set GR8:$dst, (X86setcc X86_COND_LE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003296 TB; // GR8 = <= signed
3297def SETLEm : I<0x9E, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00003298 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00003299 "setle\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00003300 [(store (X86setcc X86_COND_LE, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003301 TB; // [mem8] = <= signed
Bill Wendling0c52d0a2008-12-02 00:07:05 +00003302
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003303def SETGr : I<0x9F, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00003304 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00003305 "setg\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00003306 [(set GR8:$dst, (X86setcc X86_COND_G, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003307 TB; // GR8 = > signed
3308def SETGm : I<0x9F, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00003309 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00003310 "setg\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00003311 [(store (X86setcc X86_COND_G, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003312 TB; // [mem8] = > signed
3313
3314def SETBr : I<0x92, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00003315 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00003316 "setb\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00003317 [(set GR8:$dst, (X86setcc X86_COND_B, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003318 TB; // GR8 = < unsign
3319def SETBm : I<0x92, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00003320 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00003321 "setb\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00003322 [(store (X86setcc X86_COND_B, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003323 TB; // [mem8] = < unsign
Bill Wendling0c52d0a2008-12-02 00:07:05 +00003324
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003325def SETAEr : I<0x93, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00003326 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00003327 "setae\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00003328 [(set GR8:$dst, (X86setcc X86_COND_AE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003329 TB; // GR8 = >= unsign
3330def SETAEm : I<0x93, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00003331 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00003332 "setae\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00003333 [(store (X86setcc X86_COND_AE, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003334 TB; // [mem8] = >= unsign
Bill Wendling0c52d0a2008-12-02 00:07:05 +00003335
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003336def SETBEr : I<0x96, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00003337 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00003338 "setbe\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00003339 [(set GR8:$dst, (X86setcc X86_COND_BE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003340 TB; // GR8 = <= unsign
3341def SETBEm : I<0x96, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00003342 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00003343 "setbe\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00003344 [(store (X86setcc X86_COND_BE, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003345 TB; // [mem8] = <= unsign
Bill Wendling0c52d0a2008-12-02 00:07:05 +00003346
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003347def SETAr : I<0x97, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00003348 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00003349 "seta\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00003350 [(set GR8:$dst, (X86setcc X86_COND_A, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003351 TB; // GR8 = > signed
3352def SETAm : I<0x97, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00003353 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00003354 "seta\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00003355 [(store (X86setcc X86_COND_A, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003356 TB; // [mem8] = > signed
3357
3358def SETSr : I<0x98, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00003359 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00003360 "sets\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00003361 [(set GR8:$dst, (X86setcc X86_COND_S, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003362 TB; // GR8 = <sign bit>
3363def SETSm : I<0x98, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00003364 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00003365 "sets\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00003366 [(store (X86setcc X86_COND_S, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003367 TB; // [mem8] = <sign bit>
3368def SETNSr : I<0x99, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00003369 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00003370 "setns\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00003371 [(set GR8:$dst, (X86setcc X86_COND_NS, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003372 TB; // GR8 = !<sign bit>
3373def SETNSm : I<0x99, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00003374 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00003375 "setns\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00003376 [(store (X86setcc X86_COND_NS, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003377 TB; // [mem8] = !<sign bit>
Bill Wendling0c52d0a2008-12-02 00:07:05 +00003378
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003379def SETPr : I<0x9A, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00003380 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00003381 "setp\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00003382 [(set GR8:$dst, (X86setcc X86_COND_P, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003383 TB; // GR8 = parity
3384def SETPm : I<0x9A, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00003385 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00003386 "setp\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00003387 [(store (X86setcc X86_COND_P, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003388 TB; // [mem8] = parity
3389def SETNPr : I<0x9B, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00003390 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00003391 "setnp\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00003392 [(set GR8:$dst, (X86setcc X86_COND_NP, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003393 TB; // GR8 = not parity
3394def SETNPm : I<0x9B, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00003395 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00003396 "setnp\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00003397 [(store (X86setcc X86_COND_NP, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003398 TB; // [mem8] = not parity
Bill Wendling0c52d0a2008-12-02 00:07:05 +00003399
3400def SETOr : I<0x90, MRM0r,
3401 (outs GR8 :$dst), (ins),
3402 "seto\t$dst",
3403 [(set GR8:$dst, (X86setcc X86_COND_O, EFLAGS))]>,
3404 TB; // GR8 = overflow
3405def SETOm : I<0x90, MRM0m,
3406 (outs), (ins i8mem:$dst),
3407 "seto\t$dst",
3408 [(store (X86setcc X86_COND_O, EFLAGS), addr:$dst)]>,
3409 TB; // [mem8] = overflow
3410def SETNOr : I<0x91, MRM0r,
3411 (outs GR8 :$dst), (ins),
3412 "setno\t$dst",
3413 [(set GR8:$dst, (X86setcc X86_COND_NO, EFLAGS))]>,
3414 TB; // GR8 = not overflow
3415def SETNOm : I<0x91, MRM0m,
3416 (outs), (ins i8mem:$dst),
3417 "setno\t$dst",
3418 [(store (X86setcc X86_COND_NO, EFLAGS), addr:$dst)]>,
3419 TB; // [mem8] = not overflow
Evan Cheng950aac02007-09-25 01:57:46 +00003420} // Uses = [EFLAGS]
3421
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003422
3423// Integer comparisons
Evan Cheng55687072007-09-14 21:48:26 +00003424let Defs = [EFLAGS] in {
Sean Callanan251676e2009-09-02 00:55:49 +00003425def CMP8i8 : Ii8<0x3C, RawFrm, (outs), (ins i8imm:$src),
3426 "cmp{b}\t{$src, %al|%al, $src}", []>;
3427def CMP16i16 : Ii16<0x3D, RawFrm, (outs), (ins i16imm:$src),
3428 "cmp{w}\t{$src, %ax|%ax, $src}", []>, OpSize;
3429def CMP32i32 : Ii32<0x3D, RawFrm, (outs), (ins i32imm:$src),
3430 "cmp{l}\t{$src, %eax|%eax, $src}", []>;
3431
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003432def CMP8rr : I<0x38, MRMDestReg,
Evan Chengb783fa32007-07-19 01:14:50 +00003433 (outs), (ins GR8 :$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 GR8:$src1, GR8:$src2), (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003436def CMP16rr : I<0x39, MRMDestReg,
Evan Chengb783fa32007-07-19 01:14:50 +00003437 (outs), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00003438 "cmp{w}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00003439 [(X86cmp GR16:$src1, GR16:$src2), (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003440def CMP32rr : I<0x39, MRMDestReg,
Evan Chengb783fa32007-07-19 01:14:50 +00003441 (outs), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00003442 "cmp{l}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00003443 [(X86cmp GR32:$src1, GR32:$src2), (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003444def CMP8mr : I<0x38, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00003445 (outs), (ins i8mem :$src1, GR8 :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00003446 "cmp{b}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00003447 [(X86cmp (loadi8 addr:$src1), GR8:$src2),
3448 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003449def CMP16mr : I<0x39, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00003450 (outs), (ins i16mem:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00003451 "cmp{w}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00003452 [(X86cmp (loadi16 addr:$src1), GR16:$src2),
3453 (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003454def CMP32mr : I<0x39, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00003455 (outs), (ins i32mem:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00003456 "cmp{l}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00003457 [(X86cmp (loadi32 addr:$src1), GR32:$src2),
3458 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003459def CMP8rm : I<0x3A, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00003460 (outs), (ins GR8 :$src1, i8mem :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00003461 "cmp{b}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00003462 [(X86cmp GR8:$src1, (loadi8 addr:$src2)),
3463 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003464def CMP16rm : I<0x3B, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00003465 (outs), (ins GR16:$src1, i16mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00003466 "cmp{w}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00003467 [(X86cmp GR16:$src1, (loadi16 addr:$src2)),
3468 (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003469def CMP32rm : I<0x3B, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00003470 (outs), (ins GR32:$src1, i32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00003471 "cmp{l}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00003472 [(X86cmp GR32:$src1, (loadi32 addr:$src2)),
3473 (implicit EFLAGS)]>;
Sean Callanan11490dc2009-09-16 21:11:23 +00003474def CMP8mrmrr : I<0x3A, MRMSrcReg, (outs), (ins GR8:$src1, GR8:$src2),
3475 "cmp{b}\t{$src2, $src1|$src1, $src2}", []>;
3476def CMP16mrmrr : I<0x3B, MRMSrcReg, (outs), (ins GR16:$src1, GR16:$src2),
3477 "cmp{w}\t{$src2, $src1|$src1, $src2}", []>, OpSize;
3478def CMP32mrmrr : I<0x3B, MRMSrcReg, (outs), (ins GR32:$src1, GR32:$src2),
3479 "cmp{l}\t{$src2, $src1|$src1, $src2}", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003480def CMP8ri : Ii8<0x80, MRM7r,
Evan Chengb783fa32007-07-19 01:14:50 +00003481 (outs), (ins GR8:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00003482 "cmp{b}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00003483 [(X86cmp GR8:$src1, imm:$src2), (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003484def CMP16ri : Ii16<0x81, MRM7r,
Evan Chengb783fa32007-07-19 01:14:50 +00003485 (outs), (ins GR16:$src1, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00003486 "cmp{w}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00003487 [(X86cmp GR16:$src1, imm:$src2),
3488 (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003489def CMP32ri : Ii32<0x81, MRM7r,
Evan Chengb783fa32007-07-19 01:14:50 +00003490 (outs), (ins GR32:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00003491 "cmp{l}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00003492 [(X86cmp GR32:$src1, imm:$src2), (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003493def CMP8mi : Ii8 <0x80, MRM7m,
Evan Chengb783fa32007-07-19 01:14:50 +00003494 (outs), (ins i8mem :$src1, i8imm :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00003495 "cmp{b}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00003496 [(X86cmp (loadi8 addr:$src1), imm:$src2),
3497 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003498def CMP16mi : Ii16<0x81, MRM7m,
Evan Chengb783fa32007-07-19 01:14:50 +00003499 (outs), (ins i16mem:$src1, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00003500 "cmp{w}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00003501 [(X86cmp (loadi16 addr:$src1), imm:$src2),
3502 (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003503def CMP32mi : Ii32<0x81, MRM7m,
Evan Chengb783fa32007-07-19 01:14:50 +00003504 (outs), (ins i32mem:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00003505 "cmp{l}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00003506 [(X86cmp (loadi32 addr:$src1), imm:$src2),
3507 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003508def CMP16ri8 : Ii8<0x83, MRM7r,
Evan Chengb783fa32007-07-19 01:14:50 +00003509 (outs), (ins GR16:$src1, i16i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00003510 "cmp{w}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00003511 [(X86cmp GR16:$src1, i16immSExt8:$src2),
3512 (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003513def CMP16mi8 : Ii8<0x83, MRM7m,
Evan Chengb783fa32007-07-19 01:14:50 +00003514 (outs), (ins i16mem:$src1, i16i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00003515 "cmp{w}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00003516 [(X86cmp (loadi16 addr:$src1), i16immSExt8:$src2),
3517 (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003518def CMP32mi8 : Ii8<0x83, MRM7m,
Evan Chengb783fa32007-07-19 01:14:50 +00003519 (outs), (ins i32mem:$src1, i32i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00003520 "cmp{l}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00003521 [(X86cmp (loadi32 addr:$src1), i32immSExt8:$src2),
3522 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003523def CMP32ri8 : Ii8<0x83, MRM7r,
Evan Chengb783fa32007-07-19 01:14:50 +00003524 (outs), (ins GR32:$src1, i32i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00003525 "cmp{l}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00003526 [(X86cmp GR32:$src1, i32immSExt8:$src2),
Evan Cheng950aac02007-09-25 01:57:46 +00003527 (implicit EFLAGS)]>;
3528} // Defs = [EFLAGS]
3529
Dan Gohman7fe9b7f2008-12-23 22:45:23 +00003530// Bit tests.
Dan Gohman7fe9b7f2008-12-23 22:45:23 +00003531// TODO: BTC, BTR, and BTS
3532let Defs = [EFLAGS] in {
Dan Gohmanfc4eddb2009-01-13 20:32:45 +00003533def BT16rr : I<0xA3, MRMDestReg, (outs), (ins GR16:$src1, GR16:$src2),
Dan Gohman7fe9b7f2008-12-23 22:45:23 +00003534 "bt{w}\t{$src2, $src1|$src1, $src2}",
3535 [(X86bt GR16:$src1, GR16:$src2),
Chris Lattner5a95cde2008-12-25 01:32:49 +00003536 (implicit EFLAGS)]>, OpSize, TB;
Dan Gohmanfc4eddb2009-01-13 20:32:45 +00003537def BT32rr : I<0xA3, MRMDestReg, (outs), (ins GR32:$src1, GR32:$src2),
Dan Gohman7fe9b7f2008-12-23 22:45:23 +00003538 "bt{l}\t{$src2, $src1|$src1, $src2}",
3539 [(X86bt GR32:$src1, GR32:$src2),
Chris Lattner5a95cde2008-12-25 01:32:49 +00003540 (implicit EFLAGS)]>, TB;
Dan Gohman85a228c2009-01-13 23:23:30 +00003541
3542// Unlike with the register+register form, the memory+register form of the
3543// bt instruction does not ignore the high bits of the index. From ISel's
Sean Callanan2c48df22009-12-18 00:01:26 +00003544// perspective, this is pretty bizarre. Make these instructions disassembly
3545// only for now.
3546
3547def BT16mr : I<0xA3, MRMDestMem, (outs), (ins i16mem:$src1, GR16:$src2),
3548 "bt{w}\t{$src2, $src1|$src1, $src2}",
Dan Gohman85a228c2009-01-13 23:23:30 +00003549// [(X86bt (loadi16 addr:$src1), GR16:$src2),
Sean Callanan2c48df22009-12-18 00:01:26 +00003550// (implicit EFLAGS)]
3551 []
3552 >, OpSize, TB, Requires<[FastBTMem]>;
3553def BT32mr : I<0xA3, MRMDestMem, (outs), (ins i32mem:$src1, GR32:$src2),
3554 "bt{l}\t{$src2, $src1|$src1, $src2}",
Dan Gohman85a228c2009-01-13 23:23:30 +00003555// [(X86bt (loadi32 addr:$src1), GR32:$src2),
Sean Callanan2c48df22009-12-18 00:01:26 +00003556// (implicit EFLAGS)]
3557 []
3558 >, TB, Requires<[FastBTMem]>;
Dan Gohman46fb1cf2009-01-13 20:33:23 +00003559
3560def BT16ri8 : Ii8<0xBA, MRM4r, (outs), (ins GR16:$src1, i16i8imm:$src2),
3561 "bt{w}\t{$src2, $src1|$src1, $src2}",
3562 [(X86bt GR16:$src1, i16immSExt8:$src2),
3563 (implicit EFLAGS)]>, OpSize, TB;
3564def BT32ri8 : Ii8<0xBA, MRM4r, (outs), (ins GR32:$src1, i32i8imm:$src2),
3565 "bt{l}\t{$src2, $src1|$src1, $src2}",
3566 [(X86bt GR32:$src1, i32immSExt8:$src2),
3567 (implicit EFLAGS)]>, TB;
3568// Note that these instructions don't need FastBTMem because that
3569// only applies when the other operand is in a register. When it's
3570// an immediate, bt is still fast.
3571def BT16mi8 : Ii8<0xBA, MRM4m, (outs), (ins i16mem:$src1, i16i8imm:$src2),
3572 "bt{w}\t{$src2, $src1|$src1, $src2}",
3573 [(X86bt (loadi16 addr:$src1), i16immSExt8:$src2),
3574 (implicit EFLAGS)]>, OpSize, TB;
3575def BT32mi8 : Ii8<0xBA, MRM4m, (outs), (ins i32mem:$src1, i32i8imm:$src2),
3576 "bt{l}\t{$src2, $src1|$src1, $src2}",
3577 [(X86bt (loadi32 addr:$src1), i32immSExt8:$src2),
3578 (implicit EFLAGS)]>, TB;
Sean Callanan2c48df22009-12-18 00:01:26 +00003579
3580def BTC16rr : I<0xBB, MRMDestReg, (outs), (ins GR16:$src1, GR16:$src2),
3581 "btc{w}\t{$src2, $src1|$src1, $src2}", []>, OpSize, TB;
3582def BTC32rr : I<0xBB, MRMDestReg, (outs), (ins GR32:$src1, GR32:$src2),
3583 "btc{l}\t{$src2, $src1|$src1, $src2}", []>, TB;
3584def BTC16mr : I<0xBB, MRMDestMem, (outs), (ins i16mem:$src1, GR16:$src2),
3585 "btc{w}\t{$src2, $src1|$src1, $src2}", []>, OpSize, TB;
3586def BTC32mr : I<0xBB, MRMDestMem, (outs), (ins i32mem:$src1, GR32:$src2),
3587 "btc{l}\t{$src2, $src1|$src1, $src2}", []>, TB;
3588def BTC16ri8 : Ii8<0xBA, MRM7r, (outs), (ins GR16:$src1, i16i8imm:$src2),
3589 "btc{w}\t{$src2, $src1|$src1, $src2}", []>, OpSize, TB;
3590def BTC32ri8 : Ii8<0xBA, MRM7r, (outs), (ins GR32:$src1, i32i8imm:$src2),
3591 "btc{l}\t{$src2, $src1|$src1, $src2}", []>, TB;
3592def BTC16mi8 : Ii8<0xBA, MRM7m, (outs), (ins i16mem:$src1, i16i8imm:$src2),
3593 "btc{w}\t{$src2, $src1|$src1, $src2}", []>, OpSize, TB;
3594def BTC32mi8 : Ii8<0xBA, MRM7m, (outs), (ins i32mem:$src1, i32i8imm:$src2),
3595 "btc{l}\t{$src2, $src1|$src1, $src2}", []>, TB;
3596
3597def BTR16rr : I<0xB3, MRMDestReg, (outs), (ins GR16:$src1, GR16:$src2),
3598 "btr{w}\t{$src2, $src1|$src1, $src2}", []>, OpSize, TB;
3599def BTR32rr : I<0xB3, MRMDestReg, (outs), (ins GR32:$src1, GR32:$src2),
3600 "btr{l}\t{$src2, $src1|$src1, $src2}", []>, TB;
3601def BTR16mr : I<0xB3, MRMDestMem, (outs), (ins i16mem:$src1, GR16:$src2),
3602 "btr{w}\t{$src2, $src1|$src1, $src2}", []>, OpSize, TB;
3603def BTR32mr : I<0xB3, MRMDestMem, (outs), (ins i32mem:$src1, GR32:$src2),
3604 "btr{l}\t{$src2, $src1|$src1, $src2}", []>, TB;
3605def BTR16ri8 : Ii8<0xBA, MRM6r, (outs), (ins GR16:$src1, i16i8imm:$src2),
3606 "btr{w}\t{$src2, $src1|$src1, $src2}", []>, OpSize, TB;
3607def BTR32ri8 : Ii8<0xBA, MRM6r, (outs), (ins GR32:$src1, i32i8imm:$src2),
3608 "btr{l}\t{$src2, $src1|$src1, $src2}", []>, TB;
3609def BTR16mi8 : Ii8<0xBA, MRM6m, (outs), (ins i16mem:$src1, i16i8imm:$src2),
3610 "btr{w}\t{$src2, $src1|$src1, $src2}", []>, OpSize, TB;
3611def BTR32mi8 : Ii8<0xBA, MRM6m, (outs), (ins i32mem:$src1, i32i8imm:$src2),
3612 "btr{l}\t{$src2, $src1|$src1, $src2}", []>, TB;
3613
3614def BTS16rr : I<0xAB, MRMDestReg, (outs), (ins GR16:$src1, GR16:$src2),
3615 "bts{w}\t{$src2, $src1|$src1, $src2}", []>, OpSize, TB;
3616def BTS32rr : I<0xAB, MRMDestReg, (outs), (ins GR32:$src1, GR32:$src2),
3617 "bts{l}\t{$src2, $src1|$src1, $src2}", []>, TB;
3618def BTS16mr : I<0xAB, MRMDestMem, (outs), (ins i16mem:$src1, GR16:$src2),
3619 "bts{w}\t{$src2, $src1|$src1, $src2}", []>, OpSize, TB;
3620def BTS32mr : I<0xAB, MRMDestMem, (outs), (ins i32mem:$src1, GR32:$src2),
3621 "bts{l}\t{$src2, $src1|$src1, $src2}", []>, TB;
3622def BTS16ri8 : Ii8<0xBA, MRM5r, (outs), (ins GR16:$src1, i16i8imm:$src2),
3623 "bts{w}\t{$src2, $src1|$src1, $src2}", []>, OpSize, TB;
3624def BTS32ri8 : Ii8<0xBA, MRM5r, (outs), (ins GR32:$src1, i32i8imm:$src2),
3625 "bts{l}\t{$src2, $src1|$src1, $src2}", []>, TB;
3626def BTS16mi8 : Ii8<0xBA, MRM5m, (outs), (ins i16mem:$src1, i16i8imm:$src2),
3627 "bts{w}\t{$src2, $src1|$src1, $src2}", []>, OpSize, TB;
3628def BTS32mi8 : Ii8<0xBA, MRM5m, (outs), (ins i32mem:$src1, i32i8imm:$src2),
3629 "bts{l}\t{$src2, $src1|$src1, $src2}", []>, TB;
Dan Gohman7fe9b7f2008-12-23 22:45:23 +00003630} // Defs = [EFLAGS]
3631
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003632// Sign/Zero extenders
Dan Gohman9203ab42008-07-30 18:09:17 +00003633// Use movsbl intead of movsbw; we don't care about the high 16 bits
3634// of the register here. This has a smaller encoding and avoids a
Sean Callanan2c48df22009-12-18 00:01:26 +00003635// partial-register update. Actual movsbw included for the disassembler.
3636def MOVSX16rr8W : I<0xBE, MRMSrcReg, (outs GR16:$dst), (ins GR8:$src),
3637 "movs{bw|x}\t{$src, $dst|$dst, $src}", []>, TB, OpSize;
3638def MOVSX16rm8W : I<0xBE, MRMSrcMem, (outs GR16:$dst), (ins i8mem:$src),
3639 "movs{bw|x}\t{$src, $dst|$dst, $src}", []>, TB, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00003640def MOVSX16rr8 : I<0xBE, MRMSrcReg, (outs GR16:$dst), (ins GR8 :$src),
Chris Lattnerbe7efcc2009-10-19 19:51:42 +00003641 "", [(set GR16:$dst, (sext GR8:$src))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00003642def MOVSX16rm8 : I<0xBE, MRMSrcMem, (outs GR16:$dst), (ins i8mem :$src),
Chris Lattnerbe7efcc2009-10-19 19:51:42 +00003643 "", [(set GR16:$dst, (sextloadi16i8 addr:$src))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00003644def MOVSX32rr8 : I<0xBE, MRMSrcReg, (outs GR32:$dst), (ins GR8 :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00003645 "movs{bl|x}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003646 [(set GR32:$dst, (sext GR8:$src))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00003647def MOVSX32rm8 : I<0xBE, MRMSrcMem, (outs GR32:$dst), (ins i8mem :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00003648 "movs{bl|x}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003649 [(set GR32:$dst, (sextloadi32i8 addr:$src))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00003650def MOVSX32rr16: I<0xBF, MRMSrcReg, (outs GR32:$dst), (ins GR16:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00003651 "movs{wl|x}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003652 [(set GR32:$dst, (sext GR16:$src))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00003653def MOVSX32rm16: I<0xBF, MRMSrcMem, (outs GR32:$dst), (ins i16mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00003654 "movs{wl|x}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003655 [(set GR32:$dst, (sextloadi32i16 addr:$src))]>, TB;
3656
Dan Gohman9203ab42008-07-30 18:09:17 +00003657// Use movzbl intead of movzbw; we don't care about the high 16 bits
3658// of the register here. This has a smaller encoding and avoids a
Sean Callanan2c48df22009-12-18 00:01:26 +00003659// partial-register update. Actual movzbw included for the disassembler.
3660def MOVZX16rr8W : I<0xB6, MRMSrcReg, (outs GR16:$dst), (ins GR8:$src),
3661 "movz{bw|x}\t{$src, $dst|$dst, $src}", []>, TB, OpSize;
3662def MOVZX16rm8W : I<0xB6, MRMSrcMem, (outs GR16:$dst), (ins i8mem:$src),
3663 "movz{bw|x}\t{$src, $dst|$dst, $src}", []>, TB, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00003664def MOVZX16rr8 : I<0xB6, MRMSrcReg, (outs GR16:$dst), (ins GR8 :$src),
Chris Lattnerbe7efcc2009-10-19 19:51:42 +00003665 "", [(set GR16:$dst, (zext GR8:$src))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00003666def MOVZX16rm8 : I<0xB6, MRMSrcMem, (outs GR16:$dst), (ins i8mem :$src),
Chris Lattnerbe7efcc2009-10-19 19:51:42 +00003667 "", [(set GR16:$dst, (zextloadi16i8 addr:$src))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00003668def MOVZX32rr8 : I<0xB6, MRMSrcReg, (outs GR32:$dst), (ins GR8 :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00003669 "movz{bl|x}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003670 [(set GR32:$dst, (zext GR8:$src))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00003671def MOVZX32rm8 : I<0xB6, MRMSrcMem, (outs GR32:$dst), (ins i8mem :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00003672 "movz{bl|x}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003673 [(set GR32:$dst, (zextloadi32i8 addr:$src))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00003674def MOVZX32rr16: I<0xB7, MRMSrcReg, (outs GR32:$dst), (ins GR16:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00003675 "movz{wl|x}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003676 [(set GR32:$dst, (zext GR16:$src))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00003677def MOVZX32rm16: I<0xB7, MRMSrcMem, (outs GR32:$dst), (ins i16mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00003678 "movz{wl|x}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003679 [(set GR32:$dst, (zextloadi32i16 addr:$src))]>, TB;
3680
Dan Gohman744d4622009-04-13 16:09:41 +00003681// These are the same as the regular regular MOVZX32rr8 and MOVZX32rm8
3682// except that they use GR32_NOREX for the output operand register class
3683// instead of GR32. This allows them to operate on h registers on x86-64.
3684def MOVZX32_NOREXrr8 : I<0xB6, MRMSrcReg,
3685 (outs GR32_NOREX:$dst), (ins GR8:$src),
3686 "movz{bl|x}\t{$src, $dst|$dst, $src} # NOREX",
3687 []>, TB;
Dan Gohman89f4cda2009-04-30 03:11:48 +00003688let mayLoad = 1 in
Dan Gohman744d4622009-04-13 16:09:41 +00003689def MOVZX32_NOREXrm8 : I<0xB6, MRMSrcMem,
3690 (outs GR32_NOREX:$dst), (ins i8mem:$src),
3691 "movz{bl|x}\t{$src, $dst|$dst, $src} # NOREX",
3692 []>, TB;
3693
Chris Lattnerc90ee9c2008-01-10 07:59:24 +00003694let neverHasSideEffects = 1 in {
3695 let Defs = [AX], Uses = [AL] in
3696 def CBW : I<0x98, RawFrm, (outs), (ins),
3697 "{cbtw|cbw}", []>, OpSize; // AX = signext(AL)
3698 let Defs = [EAX], Uses = [AX] in
3699 def CWDE : I<0x98, RawFrm, (outs), (ins),
3700 "{cwtl|cwde}", []>; // EAX = signext(AX)
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003701
Chris Lattnerc90ee9c2008-01-10 07:59:24 +00003702 let Defs = [AX,DX], Uses = [AX] in
3703 def CWD : I<0x99, RawFrm, (outs), (ins),
3704 "{cwtd|cwd}", []>, OpSize; // DX:AX = signext(AX)
3705 let Defs = [EAX,EDX], Uses = [EAX] in
3706 def CDQ : I<0x99, RawFrm, (outs), (ins),
3707 "{cltd|cdq}", []>; // EDX:EAX = signext(EAX)
3708}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003709
3710//===----------------------------------------------------------------------===//
3711// Alias Instructions
3712//===----------------------------------------------------------------------===//
3713
3714// Alias instructions that map movr0 to xor.
3715// FIXME: remove when we can teach regalloc that xor reg, reg is ok.
Daniel Dunbara0e62002009-08-11 22:17:52 +00003716let Defs = [EFLAGS], isReMaterializable = 1, isAsCheapAsAMove = 1,
3717 isCodeGenOnly = 1 in {
Evan Chengb783fa32007-07-19 01:14:50 +00003718def MOV8r0 : I<0x30, MRMInitReg, (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00003719 "xor{b}\t$dst, $dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003720 [(set GR8:$dst, 0)]>;
Chris Lattnerb5b1b862009-12-23 01:30:26 +00003721
Chris Lattner2ba53dc2009-12-23 01:46:40 +00003722def MOV32r0 : I<0x31, MRMInitReg, (outs GR32:$dst), (ins),
3723 "xor{l}\t$dst, $dst",
3724 [(set GR32:$dst, 0)]>;
3725}
Chris Lattnerb5b1b862009-12-23 01:30:26 +00003726
Dan Gohman9203ab42008-07-30 18:09:17 +00003727// Use xorl instead of xorw since we don't care about the high 16 bits,
3728// it's smaller, and it avoids a partial-register update.
Chris Lattnerb5b1b862009-12-23 01:30:26 +00003729let AddedComplexity = 1 in
3730def : Pat<(i16 0),
3731 (EXTRACT_SUBREG (MOV32r0), x86_subreg_16bit)>;
3732
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003733//===----------------------------------------------------------------------===//
3734// Thread Local Storage Instructions
3735//
3736
Rafael Espindola7fc4b8d2009-04-24 12:59:40 +00003737// All calls clobber the non-callee saved registers. ESP is marked as
3738// a use to prevent stack-pointer assignments that appear immediately
3739// before calls from potentially appearing dead.
3740let Defs = [EAX, ECX, EDX, FP0, FP1, FP2, FP3, FP4, FP5, FP6, ST0,
3741 MM0, MM1, MM2, MM3, MM4, MM5, MM6, MM7,
3742 XMM0, XMM1, XMM2, XMM3, XMM4, XMM5, XMM6, XMM7,
3743 XMM8, XMM9, XMM10, XMM11, XMM12, XMM13, XMM14, XMM15, EFLAGS],
Chris Lattnerf1940742009-06-20 20:38:48 +00003744 Uses = [ESP] in
3745def TLS_addr32 : I<0, Pseudo, (outs), (ins lea32mem:$sym),
3746 "leal\t$sym, %eax; "
Dan Gohman70a8a112009-04-27 15:13:28 +00003747 "call\t___tls_get_addr@PLT",
Chris Lattnerf1940742009-06-20 20:38:48 +00003748 [(X86tlsaddr tls32addr:$sym)]>,
Rafael Espindolaaf759ab2009-04-17 14:35:58 +00003749 Requires<[In32BitMode]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003750
Daniel Dunbar75a07302009-08-11 22:24:40 +00003751let AddedComplexity = 5, isCodeGenOnly = 1 in
sampo9cc09a32009-01-26 01:24:32 +00003752def GS_MOV32rm : I<0x8B, MRMSrcMem, (outs GR32:$dst), (ins i32mem:$src),
3753 "movl\t%gs:$src, $dst",
3754 [(set GR32:$dst, (gsload addr:$src))]>, SegGS;
3755
Daniel Dunbar75a07302009-08-11 22:24:40 +00003756let AddedComplexity = 5, isCodeGenOnly = 1 in
Chris Lattnera7c2d8a2009-05-05 18:52:19 +00003757def FS_MOV32rm : I<0x8B, MRMSrcMem, (outs GR32:$dst), (ins i32mem:$src),
3758 "movl\t%fs:$src, $dst",
3759 [(set GR32:$dst, (fsload addr:$src))]>, SegFS;
3760
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003761//===----------------------------------------------------------------------===//
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003762// EH Pseudo Instructions
3763//
3764let isTerminator = 1, isReturn = 1, isBarrier = 1,
Daniel Dunbar75513bd2009-08-27 07:58:05 +00003765 hasCtrlDep = 1, isCodeGenOnly = 1 in {
Evan Chengb783fa32007-07-19 01:14:50 +00003766def EH_RETURN : I<0xC3, RawFrm, (outs), (ins GR32:$addr),
Dan Gohman91888f02007-07-31 20:11:57 +00003767 "ret\t#eh_return, addr: $addr",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003768 [(X86ehret GR32:$addr)]>;
3769
3770}
3771
3772//===----------------------------------------------------------------------===//
Andrew Lenharthe44f3902008-02-21 06:45:13 +00003773// Atomic support
3774//
Andrew Lenharth7a5a4b22008-03-01 13:37:02 +00003775
Evan Cheng3e171562008-04-19 01:20:30 +00003776// Atomic swap. These are just normal xchg instructions. But since a memory
3777// operand is referenced, the atomicity is ensured.
Dan Gohmana41a1c092008-08-06 15:52:50 +00003778let Constraints = "$val = $dst" in {
Sean Callanan2c48df22009-12-18 00:01:26 +00003779def XCHG32rm : I<0x87, MRMSrcMem, (outs GR32:$dst),
3780 (ins GR32:$val, i32mem:$ptr),
Evan Cheng3e171562008-04-19 01:20:30 +00003781 "xchg{l}\t{$val, $ptr|$ptr, $val}",
3782 [(set GR32:$dst, (atomic_swap_32 addr:$ptr, GR32:$val))]>;
Sean Callanan2c48df22009-12-18 00:01:26 +00003783def XCHG16rm : I<0x87, MRMSrcMem, (outs GR16:$dst),
3784 (ins GR16:$val, i16mem:$ptr),
Evan Cheng3e171562008-04-19 01:20:30 +00003785 "xchg{w}\t{$val, $ptr|$ptr, $val}",
3786 [(set GR16:$dst, (atomic_swap_16 addr:$ptr, GR16:$val))]>,
3787 OpSize;
Sean Callanan2c48df22009-12-18 00:01:26 +00003788def XCHG8rm : I<0x86, MRMSrcMem, (outs GR8:$dst), (ins GR8:$val, i8mem:$ptr),
Evan Cheng3e171562008-04-19 01:20:30 +00003789 "xchg{b}\t{$val, $ptr|$ptr, $val}",
3790 [(set GR8:$dst, (atomic_swap_8 addr:$ptr, GR8:$val))]>;
Sean Callanan2c48df22009-12-18 00:01:26 +00003791
3792def XCHG32rr : I<0x87, MRMSrcReg, (outs GR32:$dst), (ins GR32:$val, GR32:$src),
3793 "xchg{l}\t{$val, $src|$src, $val}", []>;
3794def XCHG16rr : I<0x87, MRMSrcReg, (outs GR16:$dst), (ins GR16:$val, GR16:$src),
3795 "xchg{w}\t{$val, $src|$src, $val}", []>, OpSize;
3796def XCHG8rr : I<0x86, MRMSrcReg, (outs GR8:$dst), (ins GR8:$val, GR8:$src),
3797 "xchg{b}\t{$val, $src|$src, $val}", []>;
Evan Cheng3e171562008-04-19 01:20:30 +00003798}
3799
Sean Callanan2c48df22009-12-18 00:01:26 +00003800def XCHG16ar : I<0x90, AddRegFrm, (outs), (ins GR16:$src),
3801 "xchg{w}\t{$src, %ax|%ax, $src}", []>, OpSize;
3802def XCHG32ar : I<0x90, AddRegFrm, (outs), (ins GR32:$src),
3803 "xchg{l}\t{$src, %eax|%eax, $src}", []>;
3804
Evan Chengd49dbb82008-04-18 20:55:36 +00003805// Atomic compare and swap.
Andrew Lenharth7dfe23f2008-03-01 21:52:34 +00003806let Defs = [EAX, EFLAGS], Uses = [EAX] in {
Evan Chengd49dbb82008-04-18 20:55:36 +00003807def LCMPXCHG32 : I<0xB1, MRMDestMem, (outs), (ins i32mem:$ptr, GR32:$swap),
Dan Gohman70a8a112009-04-27 15:13:28 +00003808 "lock\n\t"
3809 "cmpxchg{l}\t{$swap, $ptr|$ptr, $swap}",
Evan Cheng09fbdee2008-03-04 03:20:06 +00003810 [(X86cas addr:$ptr, GR32:$swap, 4)]>, TB, LOCK;
Andrew Lenharth7a5a4b22008-03-01 13:37:02 +00003811}
Dale Johannesenf160d802008-10-02 18:53:47 +00003812let Defs = [EAX, EDX, EFLAGS], Uses = [EAX, EBX, ECX, EDX] in {
Evan Cheng3896a6f2010-01-08 01:29:19 +00003813def LCMPXCHG8B : I<0xC7, MRM1m, (outs), (ins i64mem:$ptr),
Dan Gohman70a8a112009-04-27 15:13:28 +00003814 "lock\n\t"
3815 "cmpxchg8b\t$ptr",
Andrew Lenharth81580822008-03-05 01:15:49 +00003816 [(X86cas8 addr:$ptr)]>, TB, LOCK;
3817}
Andrew Lenharth7dfe23f2008-03-01 21:52:34 +00003818
3819let Defs = [AX, EFLAGS], Uses = [AX] in {
Evan Chengd49dbb82008-04-18 20:55:36 +00003820def LCMPXCHG16 : I<0xB1, MRMDestMem, (outs), (ins i16mem:$ptr, GR16:$swap),
Dan Gohman70a8a112009-04-27 15:13:28 +00003821 "lock\n\t"
3822 "cmpxchg{w}\t{$swap, $ptr|$ptr, $swap}",
Evan Cheng09fbdee2008-03-04 03:20:06 +00003823 [(X86cas addr:$ptr, GR16:$swap, 2)]>, TB, OpSize, LOCK;
Andrew Lenharth7a5a4b22008-03-01 13:37:02 +00003824}
Andrew Lenharth7dfe23f2008-03-01 21:52:34 +00003825let Defs = [AL, EFLAGS], Uses = [AL] in {
Evan Chengd49dbb82008-04-18 20:55:36 +00003826def LCMPXCHG8 : I<0xB0, MRMDestMem, (outs), (ins i8mem:$ptr, GR8:$swap),
Dan Gohman70a8a112009-04-27 15:13:28 +00003827 "lock\n\t"
3828 "cmpxchg{b}\t{$swap, $ptr|$ptr, $swap}",
Evan Cheng09fbdee2008-03-04 03:20:06 +00003829 [(X86cas addr:$ptr, GR8:$swap, 1)]>, TB, LOCK;
Andrew Lenharth7a5a4b22008-03-01 13:37:02 +00003830}
3831
Evan Chengd49dbb82008-04-18 20:55:36 +00003832// Atomic exchange and add
3833let Constraints = "$val = $dst", Defs = [EFLAGS] in {
Sean Callanan2c48df22009-12-18 00:01:26 +00003834def LXADD32 : I<0xC1, MRMSrcMem, (outs GR32:$dst), (ins GR32:$val, i32mem:$ptr),
Dan Gohman70a8a112009-04-27 15:13:28 +00003835 "lock\n\t"
3836 "xadd{l}\t{$val, $ptr|$ptr, $val}",
Mon P Wang6bde9ec2008-06-25 08:15:39 +00003837 [(set GR32:$dst, (atomic_load_add_32 addr:$ptr, GR32:$val))]>,
Evan Chengd49dbb82008-04-18 20:55:36 +00003838 TB, LOCK;
Sean Callanan2c48df22009-12-18 00:01:26 +00003839def LXADD16 : I<0xC1, MRMSrcMem, (outs GR16:$dst), (ins GR16:$val, i16mem:$ptr),
Dan Gohman70a8a112009-04-27 15:13:28 +00003840 "lock\n\t"
3841 "xadd{w}\t{$val, $ptr|$ptr, $val}",
Mon P Wang6bde9ec2008-06-25 08:15:39 +00003842 [(set GR16:$dst, (atomic_load_add_16 addr:$ptr, GR16:$val))]>,
Evan Chengd49dbb82008-04-18 20:55:36 +00003843 TB, OpSize, LOCK;
Sean Callanan2c48df22009-12-18 00:01:26 +00003844def LXADD8 : I<0xC0, MRMSrcMem, (outs GR8:$dst), (ins GR8:$val, i8mem:$ptr),
Dan Gohman70a8a112009-04-27 15:13:28 +00003845 "lock\n\t"
3846 "xadd{b}\t{$val, $ptr|$ptr, $val}",
Mon P Wang6bde9ec2008-06-25 08:15:39 +00003847 [(set GR8:$dst, (atomic_load_add_8 addr:$ptr, GR8:$val))]>,
Evan Chengd49dbb82008-04-18 20:55:36 +00003848 TB, LOCK;
Andrew Lenharth7a5a4b22008-03-01 13:37:02 +00003849}
3850
Sean Callanan2c48df22009-12-18 00:01:26 +00003851def XADD8rr : I<0xC0, MRMDestReg, (outs GR8:$dst), (ins GR8:$src),
3852 "xadd{b}\t{$src, $dst|$dst, $src}", []>, TB;
3853def XADD16rr : I<0xC1, MRMDestReg, (outs GR16:$dst), (ins GR16:$src),
3854 "xadd{w}\t{$src, $dst|$dst, $src}", []>, TB, OpSize;
3855def XADD32rr : I<0xC1, MRMDestReg, (outs GR32:$dst), (ins GR32:$src),
3856 "xadd{l}\t{$src, $dst|$dst, $src}", []>, TB;
3857
3858def XADD8rm : I<0xC0, MRMDestMem, (outs), (ins i8mem:$dst, GR8:$src),
3859 "xadd{b}\t{$src, $dst|$dst, $src}", []>, TB;
3860def XADD16rm : I<0xC1, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src),
3861 "xadd{w}\t{$src, $dst|$dst, $src}", []>, TB, OpSize;
3862def XADD32rm : I<0xC1, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src),
3863 "xadd{l}\t{$src, $dst|$dst, $src}", []>, TB;
3864
3865def CMPXCHG8rr : I<0xB0, MRMDestReg, (outs GR8:$dst), (ins GR8:$src),
3866 "cmpxchg{b}\t{$src, $dst|$dst, $src}", []>, TB;
3867def CMPXCHG16rr : I<0xB1, MRMDestReg, (outs GR16:$dst), (ins GR16:$src),
3868 "cmpxchg{w}\t{$src, $dst|$dst, $src}", []>, TB, OpSize;
3869def CMPXCHG32rr : I<0xB1, MRMDestReg, (outs GR32:$dst), (ins GR32:$src),
3870 "cmpxchg{l}\t{$src, $dst|$dst, $src}", []>, TB;
3871
3872def CMPXCHG8rm : I<0xB0, MRMDestMem, (outs), (ins i8mem:$dst, GR8:$src),
3873 "cmpxchg{b}\t{$src, $dst|$dst, $src}", []>, TB;
3874def CMPXCHG16rm : I<0xB1, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src),
3875 "cmpxchg{w}\t{$src, $dst|$dst, $src}", []>, TB, OpSize;
3876def CMPXCHG32rm : I<0xB1, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src),
3877 "cmpxchg{l}\t{$src, $dst|$dst, $src}", []>, TB;
3878
Evan Cheng3896a6f2010-01-08 01:29:19 +00003879let Defs = [EAX, EDX, EFLAGS], Uses = [EAX, EBX, ECX, EDX] in
Sean Callanan2c48df22009-12-18 00:01:26 +00003880def CMPXCHG8B : I<0xC7, MRM1m, (outs), (ins i64mem:$dst),
3881 "cmpxchg8b\t$dst", []>, TB;
3882
Evan Chengb723fb52009-07-30 08:33:02 +00003883// Optimized codegen when the non-memory output is not used.
3884// FIXME: Use normal add / sub instructions and add lock prefix dynamically.
Dan Gohman1c286992009-10-20 18:14:49 +00003885let Defs = [EFLAGS] in {
Evan Chengb723fb52009-07-30 08:33:02 +00003886def LOCK_ADD8mr : I<0x00, MRMDestMem, (outs), (ins i8mem:$dst, GR8:$src2),
3887 "lock\n\t"
3888 "add{b}\t{$src2, $dst|$dst, $src2}", []>, LOCK;
3889def LOCK_ADD16mr : I<0x01, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
3890 "lock\n\t"
3891 "add{w}\t{$src2, $dst|$dst, $src2}", []>, OpSize, LOCK;
3892def LOCK_ADD32mr : I<0x01, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
3893 "lock\n\t"
3894 "add{l}\t{$src2, $dst|$dst, $src2}", []>, LOCK;
3895def LOCK_ADD8mi : Ii8<0x80, MRM0m, (outs), (ins i8mem :$dst, i8imm :$src2),
3896 "lock\n\t"
3897 "add{b}\t{$src2, $dst|$dst, $src2}", []>, LOCK;
3898def LOCK_ADD16mi : Ii16<0x81, MRM0m, (outs), (ins i16mem:$dst, i16imm:$src2),
3899 "lock\n\t"
3900 "add{w}\t{$src2, $dst|$dst, $src2}", []>, LOCK;
3901def LOCK_ADD32mi : Ii32<0x81, MRM0m, (outs), (ins i32mem:$dst, i32imm:$src2),
3902 "lock\n\t"
3903 "add{l}\t{$src2, $dst|$dst, $src2}", []>, LOCK;
3904def LOCK_ADD16mi8 : Ii8<0x83, MRM0m, (outs), (ins i16mem:$dst, i16i8imm :$src2),
3905 "lock\n\t"
3906 "add{w}\t{$src2, $dst|$dst, $src2}", []>, OpSize, LOCK;
3907def LOCK_ADD32mi8 : Ii8<0x83, MRM0m, (outs), (ins i32mem:$dst, i32i8imm :$src2),
3908 "lock\n\t"
3909 "add{l}\t{$src2, $dst|$dst, $src2}", []>, LOCK;
3910
3911def LOCK_INC8m : I<0xFE, MRM0m, (outs), (ins i8mem :$dst),
3912 "lock\n\t"
3913 "inc{b}\t$dst", []>, LOCK;
3914def LOCK_INC16m : I<0xFF, MRM0m, (outs), (ins i16mem:$dst),
3915 "lock\n\t"
3916 "inc{w}\t$dst", []>, OpSize, LOCK;
3917def LOCK_INC32m : I<0xFF, MRM0m, (outs), (ins i32mem:$dst),
3918 "lock\n\t"
3919 "inc{l}\t$dst", []>, LOCK;
3920
3921def LOCK_SUB8mr : I<0x28, MRMDestMem, (outs), (ins i8mem :$dst, GR8 :$src2),
3922 "lock\n\t"
3923 "sub{b}\t{$src2, $dst|$dst, $src2}", []>, LOCK;
3924def LOCK_SUB16mr : I<0x29, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
3925 "lock\n\t"
3926 "sub{w}\t{$src2, $dst|$dst, $src2}", []>, OpSize, LOCK;
3927def LOCK_SUB32mr : I<0x29, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
3928 "lock\n\t"
3929 "sub{l}\t{$src2, $dst|$dst, $src2}", []>, LOCK;
3930def LOCK_SUB8mi : Ii8<0x80, MRM5m, (outs), (ins i8mem :$dst, i8imm:$src2),
3931 "lock\n\t"
3932 "sub{b}\t{$src2, $dst|$dst, $src2}", []>, LOCK;
3933def LOCK_SUB16mi : Ii16<0x81, MRM5m, (outs), (ins i16mem:$dst, i16imm:$src2),
3934 "lock\n\t"
3935 "sub{w}\t{$src2, $dst|$dst, $src2}", []>, OpSize, LOCK;
3936def LOCK_SUB32mi : Ii32<0x81, MRM5m, (outs), (ins i32mem:$dst, i32imm:$src2),
3937 "lock\n\t"
3938 "sub{l}\t{$src2, $dst|$dst, $src2}", []>, LOCK;
Sean Callanan2c48df22009-12-18 00:01:26 +00003939def LOCK_SUB16mi8 : Ii8<0x83, MRM5m, (outs), (ins i16mem:$dst, i16i8imm :$src2),
Evan Chengb723fb52009-07-30 08:33:02 +00003940 "lock\n\t"
3941 "sub{w}\t{$src2, $dst|$dst, $src2}", []>, OpSize, LOCK;
3942def LOCK_SUB32mi8 : Ii8<0x83, MRM5m, (outs), (ins i32mem:$dst, i32i8imm :$src2),
3943 "lock\n\t"
3944 "sub{l}\t{$src2, $dst|$dst, $src2}", []>, LOCK;
3945
3946def LOCK_DEC8m : I<0xFE, MRM1m, (outs), (ins i8mem :$dst),
3947 "lock\n\t"
3948 "dec{b}\t$dst", []>, LOCK;
3949def LOCK_DEC16m : I<0xFF, MRM1m, (outs), (ins i16mem:$dst),
3950 "lock\n\t"
3951 "dec{w}\t$dst", []>, OpSize, LOCK;
3952def LOCK_DEC32m : I<0xFF, MRM1m, (outs), (ins i32mem:$dst),
3953 "lock\n\t"
3954 "dec{l}\t$dst", []>, LOCK;
Dan Gohman1c286992009-10-20 18:14:49 +00003955}
Evan Chengb723fb52009-07-30 08:33:02 +00003956
Mon P Wang6bde9ec2008-06-25 08:15:39 +00003957// Atomic exchange, and, or, xor
Mon P Wang078a62d2008-05-05 19:05:59 +00003958let Constraints = "$val = $dst", Defs = [EFLAGS],
Dan Gohman30afe012009-10-29 18:10:34 +00003959 usesCustomInserter = 1 in {
Dan Gohman8aeb61f2008-05-12 20:22:45 +00003960def ATOMAND32 : I<0, Pseudo, (outs GR32:$dst),(ins i32mem:$ptr, GR32:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003961 "#ATOMAND32 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003962 [(set GR32:$dst, (atomic_load_and_32 addr:$ptr, GR32:$val))]>;
Dan Gohman8aeb61f2008-05-12 20:22:45 +00003963def ATOMOR32 : I<0, Pseudo, (outs GR32:$dst),(ins i32mem:$ptr, GR32:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003964 "#ATOMOR32 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003965 [(set GR32:$dst, (atomic_load_or_32 addr:$ptr, GR32:$val))]>;
Dan Gohman8aeb61f2008-05-12 20:22:45 +00003966def ATOMXOR32 : I<0, Pseudo,(outs GR32:$dst),(ins i32mem:$ptr, GR32:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003967 "#ATOMXOR32 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003968 [(set GR32:$dst, (atomic_load_xor_32 addr:$ptr, GR32:$val))]>;
Andrew Lenharthaf02d592008-06-14 05:48:15 +00003969def ATOMNAND32 : I<0, Pseudo,(outs GR32:$dst),(ins i32mem:$ptr, GR32:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003970 "#ATOMNAND32 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003971 [(set GR32:$dst, (atomic_load_nand_32 addr:$ptr, GR32:$val))]>;
Dan Gohman8aeb61f2008-05-12 20:22:45 +00003972def ATOMMIN32: I<0, Pseudo, (outs GR32:$dst), (ins i32mem:$ptr, GR32:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003973 "#ATOMMIN32 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003974 [(set GR32:$dst, (atomic_load_min_32 addr:$ptr, GR32:$val))]>;
Dan Gohman8aeb61f2008-05-12 20:22:45 +00003975def ATOMMAX32: I<0, Pseudo, (outs GR32:$dst),(ins i32mem:$ptr, GR32:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003976 "#ATOMMAX32 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003977 [(set GR32:$dst, (atomic_load_max_32 addr:$ptr, GR32:$val))]>;
Dan Gohman8aeb61f2008-05-12 20:22:45 +00003978def ATOMUMIN32: I<0, Pseudo, (outs GR32:$dst),(ins i32mem:$ptr, GR32:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003979 "#ATOMUMIN32 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003980 [(set GR32:$dst, (atomic_load_umin_32 addr:$ptr, GR32:$val))]>;
Dan Gohman8aeb61f2008-05-12 20:22:45 +00003981def ATOMUMAX32: I<0, Pseudo, (outs GR32:$dst),(ins i32mem:$ptr, GR32:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003982 "#ATOMUMAX32 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003983 [(set GR32:$dst, (atomic_load_umax_32 addr:$ptr, GR32:$val))]>;
Dale Johannesend20e4452008-08-19 18:47:28 +00003984
3985def ATOMAND16 : I<0, Pseudo, (outs GR16:$dst),(ins i16mem:$ptr, GR16:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003986 "#ATOMAND16 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003987 [(set GR16:$dst, (atomic_load_and_16 addr:$ptr, GR16:$val))]>;
Dale Johannesend20e4452008-08-19 18:47:28 +00003988def ATOMOR16 : I<0, Pseudo, (outs GR16:$dst),(ins i16mem:$ptr, GR16:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003989 "#ATOMOR16 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003990 [(set GR16:$dst, (atomic_load_or_16 addr:$ptr, GR16:$val))]>;
Dale Johannesend20e4452008-08-19 18:47:28 +00003991def ATOMXOR16 : I<0, Pseudo,(outs GR16:$dst),(ins i16mem:$ptr, GR16:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003992 "#ATOMXOR16 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003993 [(set GR16:$dst, (atomic_load_xor_16 addr:$ptr, GR16:$val))]>;
Dale Johannesend20e4452008-08-19 18:47:28 +00003994def ATOMNAND16 : I<0, Pseudo,(outs GR16:$dst),(ins i16mem:$ptr, GR16:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003995 "#ATOMNAND16 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003996 [(set GR16:$dst, (atomic_load_nand_16 addr:$ptr, GR16:$val))]>;
Dale Johannesend20e4452008-08-19 18:47:28 +00003997def ATOMMIN16: I<0, Pseudo, (outs GR16:$dst), (ins i16mem:$ptr, GR16:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003998 "#ATOMMIN16 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003999 [(set GR16:$dst, (atomic_load_min_16 addr:$ptr, GR16:$val))]>;
Dale Johannesend20e4452008-08-19 18:47:28 +00004000def ATOMMAX16: I<0, Pseudo, (outs GR16:$dst),(ins i16mem:$ptr, GR16:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00004001 "#ATOMMAX16 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00004002 [(set GR16:$dst, (atomic_load_max_16 addr:$ptr, GR16:$val))]>;
Dale Johannesend20e4452008-08-19 18:47:28 +00004003def ATOMUMIN16: I<0, Pseudo, (outs GR16:$dst),(ins i16mem:$ptr, GR16:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00004004 "#ATOMUMIN16 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00004005 [(set GR16:$dst, (atomic_load_umin_16 addr:$ptr, GR16:$val))]>;
Dale Johannesend20e4452008-08-19 18:47:28 +00004006def ATOMUMAX16: I<0, Pseudo, (outs GR16:$dst),(ins i16mem:$ptr, GR16:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00004007 "#ATOMUMAX16 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00004008 [(set GR16:$dst, (atomic_load_umax_16 addr:$ptr, GR16:$val))]>;
Dale Johannesend20e4452008-08-19 18:47:28 +00004009
4010def ATOMAND8 : I<0, Pseudo, (outs GR8:$dst),(ins i8mem:$ptr, GR8:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00004011 "#ATOMAND8 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00004012 [(set GR8:$dst, (atomic_load_and_8 addr:$ptr, GR8:$val))]>;
Dale Johannesend20e4452008-08-19 18:47:28 +00004013def ATOMOR8 : I<0, Pseudo, (outs GR8:$dst),(ins i8mem:$ptr, GR8:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00004014 "#ATOMOR8 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00004015 [(set GR8:$dst, (atomic_load_or_8 addr:$ptr, GR8:$val))]>;
Dale Johannesend20e4452008-08-19 18:47:28 +00004016def ATOMXOR8 : I<0, Pseudo,(outs GR8:$dst),(ins i8mem:$ptr, GR8:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00004017 "#ATOMXOR8 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00004018 [(set GR8:$dst, (atomic_load_xor_8 addr:$ptr, GR8:$val))]>;
Dale Johannesend20e4452008-08-19 18:47:28 +00004019def ATOMNAND8 : I<0, Pseudo,(outs GR8:$dst),(ins i8mem:$ptr, GR8:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00004020 "#ATOMNAND8 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00004021 [(set GR8:$dst, (atomic_load_nand_8 addr:$ptr, GR8:$val))]>;
Mon P Wang078a62d2008-05-05 19:05:59 +00004022}
4023
Dale Johannesenf160d802008-10-02 18:53:47 +00004024let Constraints = "$val1 = $dst1, $val2 = $dst2",
4025 Defs = [EFLAGS, EAX, EBX, ECX, EDX],
4026 Uses = [EAX, EBX, ECX, EDX],
Dale Johannesen44eb5372008-10-03 19:41:08 +00004027 mayLoad = 1, mayStore = 1,
Dan Gohman30afe012009-10-29 18:10:34 +00004028 usesCustomInserter = 1 in {
Dale Johannesenf160d802008-10-02 18:53:47 +00004029def ATOMAND6432 : I<0, Pseudo, (outs GR32:$dst1, GR32:$dst2),
4030 (ins i64mem:$ptr, GR32:$val1, GR32:$val2),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00004031 "#ATOMAND6432 PSEUDO!", []>;
Dale Johannesenf160d802008-10-02 18:53:47 +00004032def ATOMOR6432 : I<0, Pseudo, (outs GR32:$dst1, GR32:$dst2),
4033 (ins i64mem:$ptr, GR32:$val1, GR32:$val2),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00004034 "#ATOMOR6432 PSEUDO!", []>;
Dale Johannesenf160d802008-10-02 18:53:47 +00004035def ATOMXOR6432 : I<0, Pseudo, (outs GR32:$dst1, GR32:$dst2),
4036 (ins i64mem:$ptr, GR32:$val1, GR32:$val2),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00004037 "#ATOMXOR6432 PSEUDO!", []>;
Dale Johannesenf160d802008-10-02 18:53:47 +00004038def ATOMNAND6432 : I<0, Pseudo, (outs GR32:$dst1, GR32:$dst2),
4039 (ins i64mem:$ptr, GR32:$val1, GR32:$val2),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00004040 "#ATOMNAND6432 PSEUDO!", []>;
Dale Johannesenf160d802008-10-02 18:53:47 +00004041def ATOMADD6432 : I<0, Pseudo, (outs GR32:$dst1, GR32:$dst2),
4042 (ins i64mem:$ptr, GR32:$val1, GR32:$val2),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00004043 "#ATOMADD6432 PSEUDO!", []>;
Dale Johannesenf160d802008-10-02 18:53:47 +00004044def ATOMSUB6432 : I<0, Pseudo, (outs GR32:$dst1, GR32:$dst2),
4045 (ins i64mem:$ptr, GR32:$val1, GR32:$val2),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00004046 "#ATOMSUB6432 PSEUDO!", []>;
Dale Johannesen51c58ee2008-10-03 22:25:52 +00004047def ATOMSWAP6432 : I<0, Pseudo, (outs GR32:$dst1, GR32:$dst2),
4048 (ins i64mem:$ptr, GR32:$val1, GR32:$val2),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00004049 "#ATOMSWAP6432 PSEUDO!", []>;
Dale Johannesenf160d802008-10-02 18:53:47 +00004050}
4051
Sean Callanan2eddf5d2009-09-16 21:55:34 +00004052// Segmentation support instructions.
4053
4054def LAR16rm : I<0x02, MRMSrcMem, (outs GR16:$dst), (ins i16mem:$src),
4055 "lar{w}\t{$src, $dst|$dst, $src}", []>, TB, OpSize;
4056def LAR16rr : I<0x02, MRMSrcReg, (outs GR16:$dst), (ins GR16:$src),
4057 "lar{w}\t{$src, $dst|$dst, $src}", []>, TB, OpSize;
4058
4059// i16mem operand in LAR32rm and GR32 operand in LAR32rr is not a typo.
4060def LAR32rm : I<0x02, MRMSrcMem, (outs GR32:$dst), (ins i16mem:$src),
4061 "lar{l}\t{$src, $dst|$dst, $src}", []>, TB;
4062def LAR32rr : I<0x02, MRMSrcReg, (outs GR32:$dst), (ins GR32:$src),
4063 "lar{l}\t{$src, $dst|$dst, $src}", []>, TB;
Sean Callanan2c48df22009-12-18 00:01:26 +00004064
4065def LSL16rm : I<0x03, MRMSrcMem, (outs GR16:$dst), (ins i16mem:$src),
4066 "lsl{w}\t{$src, $dst|$dst, $src}", []>, TB, OpSize;
4067def LSL16rr : I<0x03, MRMSrcReg, (outs GR16:$dst), (ins GR16:$src),
4068 "lsl{w}\t{$src, $dst|$dst, $src}", []>, TB, OpSize;
4069def LSL32rm : I<0x03, MRMSrcMem, (outs GR32:$dst), (ins i32mem:$src),
4070 "lsl{l}\t{$src, $dst|$dst, $src}", []>, TB;
4071def LSL32rr : I<0x03, MRMSrcReg, (outs GR32:$dst), (ins GR32:$src),
4072 "lsl{l}\t{$src, $dst|$dst, $src}", []>, TB;
4073
4074def INVLPG : I<0x01, RawFrm, (outs), (ins), "invlpg", []>, TB;
4075
4076def STRr : I<0x00, MRM1r, (outs GR16:$dst), (ins),
4077 "str{w}\t{$dst}", []>, TB;
4078def STRm : I<0x00, MRM1m, (outs i16mem:$dst), (ins),
4079 "str{w}\t{$dst}", []>, TB;
4080def LTRr : I<0x00, MRM3r, (outs), (ins GR16:$src),
4081 "ltr{w}\t{$src}", []>, TB;
4082def LTRm : I<0x00, MRM3m, (outs), (ins i16mem:$src),
4083 "ltr{w}\t{$src}", []>, TB;
4084
4085def PUSHFS16 : I<0xa0, RawFrm, (outs), (ins),
4086 "push{w}\t%fs", []>, OpSize, TB;
4087def PUSHFS32 : I<0xa0, RawFrm, (outs), (ins),
4088 "push{l}\t%fs", []>, TB;
4089def PUSHGS16 : I<0xa8, RawFrm, (outs), (ins),
4090 "push{w}\t%gs", []>, OpSize, TB;
4091def PUSHGS32 : I<0xa8, RawFrm, (outs), (ins),
4092 "push{l}\t%gs", []>, TB;
4093
4094def POPFS16 : I<0xa1, RawFrm, (outs), (ins),
4095 "pop{w}\t%fs", []>, OpSize, TB;
4096def POPFS32 : I<0xa1, RawFrm, (outs), (ins),
4097 "pop{l}\t%fs", []>, TB;
4098def POPGS16 : I<0xa9, RawFrm, (outs), (ins),
4099 "pop{w}\t%gs", []>, OpSize, TB;
4100def POPGS32 : I<0xa9, RawFrm, (outs), (ins),
4101 "pop{l}\t%gs", []>, TB;
4102
4103def LDS16rm : I<0xc5, MRMSrcMem, (outs GR16:$dst), (ins opaque32mem:$src),
4104 "lds{w}\t{$src, $dst|$dst, $src}", []>, OpSize;
4105def LDS32rm : I<0xc5, MRMSrcMem, (outs GR32:$dst), (ins opaque48mem:$src),
4106 "lds{l}\t{$src, $dst|$dst, $src}", []>;
4107def LSS16rm : I<0xb2, MRMSrcMem, (outs GR16:$dst), (ins opaque32mem:$src),
4108 "lss{w}\t{$src, $dst|$dst, $src}", []>, TB, OpSize;
4109def LSS32rm : I<0xb2, MRMSrcMem, (outs GR32:$dst), (ins opaque48mem:$src),
4110 "lss{l}\t{$src, $dst|$dst, $src}", []>, TB;
4111def LES16rm : I<0xc4, MRMSrcMem, (outs GR16:$dst), (ins opaque32mem:$src),
4112 "les{w}\t{$src, $dst|$dst, $src}", []>, OpSize;
4113def LES32rm : I<0xc4, MRMSrcMem, (outs GR32:$dst), (ins opaque48mem:$src),
4114 "les{l}\t{$src, $dst|$dst, $src}", []>;
4115def LFS16rm : I<0xb4, MRMSrcMem, (outs GR16:$dst), (ins opaque32mem:$src),
4116 "lfs{w}\t{$src, $dst|$dst, $src}", []>, TB, OpSize;
4117def LFS32rm : I<0xb4, MRMSrcMem, (outs GR32:$dst), (ins opaque48mem:$src),
4118 "lfs{l}\t{$src, $dst|$dst, $src}", []>, TB;
4119def LGS16rm : I<0xb5, MRMSrcMem, (outs GR16:$dst), (ins opaque32mem:$src),
4120 "lgs{w}\t{$src, $dst|$dst, $src}", []>, TB, OpSize;
4121def LGS32rm : I<0xb5, MRMSrcMem, (outs GR32:$dst), (ins opaque48mem:$src),
4122 "lgs{l}\t{$src, $dst|$dst, $src}", []>, TB;
4123
4124def VERRr : I<0x00, MRM4r, (outs), (ins GR16:$seg),
4125 "verr\t$seg", []>, TB;
4126def VERRm : I<0x00, MRM4m, (outs), (ins i16mem:$seg),
4127 "verr\t$seg", []>, TB;
4128def VERWr : I<0x00, MRM5r, (outs), (ins GR16:$seg),
4129 "verw\t$seg", []>, TB;
4130def VERWm : I<0x00, MRM5m, (outs), (ins i16mem:$seg),
4131 "verw\t$seg", []>, TB;
4132
4133// Descriptor-table support instructions
4134
4135def SGDTm : I<0x01, MRM0m, (outs opaque48mem:$dst), (ins),
4136 "sgdt\t$dst", []>, TB;
4137def SIDTm : I<0x01, MRM1m, (outs opaque48mem:$dst), (ins),
4138 "sidt\t$dst", []>, TB;
4139def SLDT16r : I<0x00, MRM0r, (outs GR16:$dst), (ins),
4140 "sldt{w}\t$dst", []>, TB;
4141def SLDT16m : I<0x00, MRM0m, (outs i16mem:$dst), (ins),
4142 "sldt{w}\t$dst", []>, TB;
4143def LGDTm : I<0x01, MRM2m, (outs), (ins opaque48mem:$src),
4144 "lgdt\t$src", []>, TB;
4145def LIDTm : I<0x01, MRM3m, (outs), (ins opaque48mem:$src),
4146 "lidt\t$src", []>, TB;
4147def LLDT16r : I<0x00, MRM2r, (outs), (ins GR16:$src),
4148 "lldt{w}\t$src", []>, TB;
4149def LLDT16m : I<0x00, MRM2m, (outs), (ins i16mem:$src),
4150 "lldt{w}\t$src", []>, TB;
Sean Callanan23f33d72009-09-16 22:59:28 +00004151
4152// String manipulation instructions
4153
4154def LODSB : I<0xAC, RawFrm, (outs), (ins), "lodsb", []>;
4155def LODSW : I<0xAD, RawFrm, (outs), (ins), "lodsw", []>, OpSize;
Sean Callanan2c48df22009-12-18 00:01:26 +00004156def LODSD : I<0xAD, RawFrm, (outs), (ins), "lods{l|d}", []>;
4157
4158def OUTSB : I<0x6E, RawFrm, (outs), (ins), "outsb", []>;
4159def OUTSW : I<0x6F, RawFrm, (outs), (ins), "outsw", []>, OpSize;
4160def OUTSD : I<0x6F, RawFrm, (outs), (ins), "outs{l|d}", []>;
4161
4162// CPU flow control instructions
4163
4164def HLT : I<0xF4, RawFrm, (outs), (ins), "hlt", []>;
4165def RSM : I<0xAA, RawFrm, (outs), (ins), "rsm", []>, TB;
4166
4167// FPU control instructions
4168
4169def FNINIT : I<0xE3, RawFrm, (outs), (ins), "fninit", []>, DB;
4170
4171// Flag instructions
4172
4173def CLC : I<0xF8, RawFrm, (outs), (ins), "clc", []>;
4174def STC : I<0xF9, RawFrm, (outs), (ins), "stc", []>;
4175def CLI : I<0xFA, RawFrm, (outs), (ins), "cli", []>;
4176def STI : I<0xFB, RawFrm, (outs), (ins), "sti", []>;
4177def CLD : I<0xFC, RawFrm, (outs), (ins), "cld", []>;
4178def STD : I<0xFD, RawFrm, (outs), (ins), "std", []>;
4179def CMC : I<0xF5, RawFrm, (outs), (ins), "cmc", []>;
4180
4181def CLTS : I<0x06, RawFrm, (outs), (ins), "clts", []>, TB;
4182
4183// Table lookup instructions
4184
4185def XLAT : I<0xD7, RawFrm, (outs), (ins), "xlatb", []>;
4186
4187// Specialized register support
4188
4189def WRMSR : I<0x30, RawFrm, (outs), (ins), "wrmsr", []>, TB;
4190def RDMSR : I<0x32, RawFrm, (outs), (ins), "rdmsr", []>, TB;
4191def RDPMC : I<0x33, RawFrm, (outs), (ins), "rdpmc", []>, TB;
4192
4193def SMSW16r : I<0x01, MRM4r, (outs GR16:$dst), (ins),
4194 "smsw{w}\t$dst", []>, OpSize, TB;
4195def SMSW32r : I<0x01, MRM4r, (outs GR32:$dst), (ins),
4196 "smsw{l}\t$dst", []>, TB;
4197// For memory operands, there is only a 16-bit form
4198def SMSW16m : I<0x01, MRM4m, (outs i16mem:$dst), (ins),
4199 "smsw{w}\t$dst", []>, TB;
4200
4201def LMSW16r : I<0x01, MRM6r, (outs), (ins GR16:$src),
4202 "lmsw{w}\t$src", []>, TB;
4203def LMSW16m : I<0x01, MRM6m, (outs), (ins i16mem:$src),
4204 "lmsw{w}\t$src", []>, TB;
4205
4206def CPUID : I<0xA2, RawFrm, (outs), (ins), "cpuid", []>, TB;
4207
4208// Cache instructions
4209
4210def INVD : I<0x08, RawFrm, (outs), (ins), "invd", []>, TB;
4211def WBINVD : I<0x09, RawFrm, (outs), (ins), "wbinvd", []>, TB;
4212
4213// VMX instructions
4214
4215// 66 0F 38 80
4216def INVEPT : I<0x38, RawFrm, (outs), (ins), "invept", []>, OpSize, TB;
4217// 66 0F 38 81
4218def INVVPID : I<0x38, RawFrm, (outs), (ins), "invvpid", []>, OpSize, TB;
4219// 0F 01 C1
4220def VMCALL : I<0x01, RawFrm, (outs), (ins), "vmcall", []>, TB;
4221def VMCLEARm : I<0xC7, MRM6m, (outs), (ins i64mem:$vmcs),
4222 "vmclear\t$vmcs", []>, OpSize, TB;
4223// 0F 01 C2
4224def VMLAUNCH : I<0x01, RawFrm, (outs), (ins), "vmlaunch", []>, TB;
4225// 0F 01 C3
4226def VMRESUME : I<0x01, RawFrm, (outs), (ins), "vmresume", []>, TB;
4227def VMPTRLDm : I<0xC7, MRM6m, (outs), (ins i64mem:$vmcs),
4228 "vmptrld\t$vmcs", []>, TB;
4229def VMPTRSTm : I<0xC7, MRM7m, (outs i64mem:$vmcs), (ins),
4230 "vmptrst\t$vmcs", []>, TB;
4231def VMREAD64rm : I<0x78, MRMDestMem, (outs i64mem:$dst), (ins GR64:$src),
4232 "vmread{q}\t{$src, $dst|$dst, $src}", []>, TB;
4233def VMREAD64rr : I<0x78, MRMDestReg, (outs GR64:$dst), (ins GR64:$src),
4234 "vmread{q}\t{$src, $dst|$dst, $src}", []>, TB;
4235def VMREAD32rm : I<0x78, MRMDestMem, (outs i32mem:$dst), (ins GR32:$src),
4236 "vmread{l}\t{$src, $dst|$dst, $src}", []>, TB;
4237def VMREAD32rr : I<0x78, MRMDestReg, (outs GR32:$dst), (ins GR32:$src),
4238 "vmread{l}\t{$src, $dst|$dst, $src}", []>, TB;
4239def VMWRITE64rm : I<0x79, MRMSrcMem, (outs GR64:$dst), (ins i64mem:$src),
4240 "vmwrite{q}\t{$src, $dst|$dst, $src}", []>, TB;
4241def VMWRITE64rr : I<0x79, MRMSrcReg, (outs GR64:$dst), (ins GR64:$src),
4242 "vmwrite{q}\t{$src, $dst|$dst, $src}", []>, TB;
4243def VMWRITE32rm : I<0x79, MRMSrcMem, (outs GR32:$dst), (ins i32mem:$src),
4244 "vmwrite{l}\t{$src, $dst|$dst, $src}", []>, TB;
4245def VMWRITE32rr : I<0x79, MRMSrcReg, (outs GR32:$dst), (ins GR32:$src),
4246 "vmwrite{l}\t{$src, $dst|$dst, $src}", []>, TB;
4247// 0F 01 C4
4248def VMXOFF : I<0x01, RawFrm, (outs), (ins), "vmxoff", []>, OpSize;
4249def VMXON : I<0xC7, MRM6m, (outs), (ins i64mem:$vmxon),
4250 "vmxon\t{$vmxon}", []>, XD;
Sean Callanan2eddf5d2009-09-16 21:55:34 +00004251
Andrew Lenharthe44f3902008-02-21 06:45:13 +00004252//===----------------------------------------------------------------------===//
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004253// Non-Instruction Patterns
4254//===----------------------------------------------------------------------===//
4255
Bill Wendlingfef06052008-09-16 21:48:12 +00004256// ConstantPool GlobalAddress, ExternalSymbol, and JumpTable
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004257def : Pat<(i32 (X86Wrapper tconstpool :$dst)), (MOV32ri tconstpool :$dst)>;
4258def : Pat<(i32 (X86Wrapper tjumptable :$dst)), (MOV32ri tjumptable :$dst)>;
Nate Begemanb52948972008-04-12 00:47:57 +00004259def : Pat<(i32 (X86Wrapper tglobaltlsaddr:$dst)),(MOV32ri tglobaltlsaddr:$dst)>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004260def : Pat<(i32 (X86Wrapper tglobaladdr :$dst)), (MOV32ri tglobaladdr :$dst)>;
4261def : Pat<(i32 (X86Wrapper texternalsym:$dst)), (MOV32ri texternalsym:$dst)>;
Dan Gohman064403e2009-10-30 01:28:02 +00004262def : Pat<(i32 (X86Wrapper tblockaddress:$dst)), (MOV32ri tblockaddress:$dst)>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004263
4264def : Pat<(add GR32:$src1, (X86Wrapper tconstpool:$src2)),
4265 (ADD32ri GR32:$src1, tconstpool:$src2)>;
4266def : Pat<(add GR32:$src1, (X86Wrapper tjumptable:$src2)),
4267 (ADD32ri GR32:$src1, tjumptable:$src2)>;
4268def : Pat<(add GR32:$src1, (X86Wrapper tglobaladdr :$src2)),
4269 (ADD32ri GR32:$src1, tglobaladdr:$src2)>;
4270def : Pat<(add GR32:$src1, (X86Wrapper texternalsym:$src2)),
4271 (ADD32ri GR32:$src1, texternalsym:$src2)>;
Dan Gohman064403e2009-10-30 01:28:02 +00004272def : Pat<(add GR32:$src1, (X86Wrapper tblockaddress:$src2)),
4273 (ADD32ri GR32:$src1, tblockaddress:$src2)>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004274
4275def : Pat<(store (i32 (X86Wrapper tglobaladdr:$src)), addr:$dst),
4276 (MOV32mi addr:$dst, tglobaladdr:$src)>;
4277def : Pat<(store (i32 (X86Wrapper texternalsym:$src)), addr:$dst),
4278 (MOV32mi addr:$dst, texternalsym:$src)>;
Dan Gohman064403e2009-10-30 01:28:02 +00004279def : Pat<(store (i32 (X86Wrapper tblockaddress:$src)), addr:$dst),
4280 (MOV32mi addr:$dst, tblockaddress:$src)>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004281
4282// Calls
Arnold Schwaighofere2d6bbb2007-10-11 19:40:01 +00004283// tailcall stuff
Arnold Schwaighofere2d6bbb2007-10-11 19:40:01 +00004284def : Pat<(X86tcret GR32:$dst, imm:$off),
4285 (TCRETURNri GR32:$dst, imm:$off)>;
4286
4287def : Pat<(X86tcret (i32 tglobaladdr:$dst), imm:$off),
4288 (TCRETURNdi texternalsym:$dst, imm:$off)>;
4289
4290def : Pat<(X86tcret (i32 texternalsym:$dst), imm:$off),
4291 (TCRETURNdi texternalsym:$dst, imm:$off)>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004292
Dan Gohmance5dbff2009-08-02 16:10:01 +00004293// Normal calls, with various flavors of addresses.
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004294def : Pat<(X86call (i32 tglobaladdr:$dst)),
4295 (CALLpcrel32 tglobaladdr:$dst)>;
4296def : Pat<(X86call (i32 texternalsym:$dst)),
4297 (CALLpcrel32 texternalsym:$dst)>;
Evan Cheng6d35a4d2009-05-20 04:53:57 +00004298def : Pat<(X86call (i32 imm:$dst)),
4299 (CALLpcrel32 imm:$dst)>, Requires<[CallImmAddr]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004300
4301// X86 specific add which produces a flag.
4302def : Pat<(addc GR32:$src1, GR32:$src2),
4303 (ADD32rr GR32:$src1, GR32:$src2)>;
4304def : Pat<(addc GR32:$src1, (load addr:$src2)),
4305 (ADD32rm GR32:$src1, addr:$src2)>;
4306def : Pat<(addc GR32:$src1, imm:$src2),
4307 (ADD32ri GR32:$src1, imm:$src2)>;
4308def : Pat<(addc GR32:$src1, i32immSExt8:$src2),
4309 (ADD32ri8 GR32:$src1, i32immSExt8:$src2)>;
4310
4311def : Pat<(subc GR32:$src1, GR32:$src2),
4312 (SUB32rr GR32:$src1, GR32:$src2)>;
4313def : Pat<(subc GR32:$src1, (load addr:$src2)),
4314 (SUB32rm GR32:$src1, addr:$src2)>;
4315def : Pat<(subc GR32:$src1, imm:$src2),
4316 (SUB32ri GR32:$src1, imm:$src2)>;
4317def : Pat<(subc GR32:$src1, i32immSExt8:$src2),
4318 (SUB32ri8 GR32:$src1, i32immSExt8:$src2)>;
4319
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004320// Comparisons.
4321
4322// TEST R,R is smaller than CMP R,0
Evan Cheng621216e2007-09-29 00:00:36 +00004323def : Pat<(parallel (X86cmp GR8:$src1, 0), (implicit EFLAGS)),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004324 (TEST8rr GR8:$src1, GR8:$src1)>;
Evan Cheng621216e2007-09-29 00:00:36 +00004325def : Pat<(parallel (X86cmp GR16:$src1, 0), (implicit EFLAGS)),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004326 (TEST16rr GR16:$src1, GR16:$src1)>;
Evan Cheng621216e2007-09-29 00:00:36 +00004327def : Pat<(parallel (X86cmp GR32:$src1, 0), (implicit EFLAGS)),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004328 (TEST32rr GR32:$src1, GR32:$src1)>;
4329
Dan Gohman0a3c5222009-01-07 01:00:24 +00004330// Conditional moves with folded loads with operands swapped and conditions
4331// inverted.
4332def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_B, EFLAGS),
4333 (CMOVAE16rm GR16:$src2, addr:$src1)>;
4334def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_B, EFLAGS),
4335 (CMOVAE32rm GR32:$src2, addr:$src1)>;
4336def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_AE, EFLAGS),
4337 (CMOVB16rm GR16:$src2, addr:$src1)>;
4338def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_AE, EFLAGS),
4339 (CMOVB32rm GR32:$src2, addr:$src1)>;
4340def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_E, EFLAGS),
4341 (CMOVNE16rm GR16:$src2, addr:$src1)>;
4342def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_E, EFLAGS),
4343 (CMOVNE32rm GR32:$src2, addr:$src1)>;
4344def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_NE, EFLAGS),
4345 (CMOVE16rm GR16:$src2, addr:$src1)>;
4346def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_NE, EFLAGS),
4347 (CMOVE32rm GR32:$src2, addr:$src1)>;
4348def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_BE, EFLAGS),
4349 (CMOVA16rm GR16:$src2, addr:$src1)>;
4350def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_BE, EFLAGS),
4351 (CMOVA32rm GR32:$src2, addr:$src1)>;
4352def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_A, EFLAGS),
4353 (CMOVBE16rm GR16:$src2, addr:$src1)>;
4354def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_A, EFLAGS),
4355 (CMOVBE32rm GR32:$src2, addr:$src1)>;
4356def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_L, EFLAGS),
4357 (CMOVGE16rm GR16:$src2, addr:$src1)>;
4358def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_L, EFLAGS),
4359 (CMOVGE32rm GR32:$src2, addr:$src1)>;
4360def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_GE, EFLAGS),
4361 (CMOVL16rm GR16:$src2, addr:$src1)>;
4362def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_GE, EFLAGS),
4363 (CMOVL32rm GR32:$src2, addr:$src1)>;
4364def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_LE, EFLAGS),
4365 (CMOVG16rm GR16:$src2, addr:$src1)>;
4366def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_LE, EFLAGS),
4367 (CMOVG32rm GR32:$src2, addr:$src1)>;
4368def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_G, EFLAGS),
4369 (CMOVLE16rm GR16:$src2, addr:$src1)>;
4370def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_G, EFLAGS),
4371 (CMOVLE32rm GR32:$src2, addr:$src1)>;
4372def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_P, EFLAGS),
4373 (CMOVNP16rm GR16:$src2, addr:$src1)>;
4374def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_P, EFLAGS),
4375 (CMOVNP32rm GR32:$src2, addr:$src1)>;
4376def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_NP, EFLAGS),
4377 (CMOVP16rm GR16:$src2, addr:$src1)>;
4378def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_NP, EFLAGS),
4379 (CMOVP32rm GR32:$src2, addr:$src1)>;
4380def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_S, EFLAGS),
4381 (CMOVNS16rm GR16:$src2, addr:$src1)>;
4382def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_S, EFLAGS),
4383 (CMOVNS32rm GR32:$src2, addr:$src1)>;
4384def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_NS, EFLAGS),
4385 (CMOVS16rm GR16:$src2, addr:$src1)>;
4386def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_NS, EFLAGS),
4387 (CMOVS32rm GR32:$src2, addr:$src1)>;
4388def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_O, EFLAGS),
4389 (CMOVNO16rm GR16:$src2, addr:$src1)>;
4390def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_O, EFLAGS),
4391 (CMOVNO32rm GR32:$src2, addr:$src1)>;
4392def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_NO, EFLAGS),
4393 (CMOVO16rm GR16:$src2, addr:$src1)>;
4394def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_NO, EFLAGS),
4395 (CMOVO32rm GR32:$src2, addr:$src1)>;
4396
Duncan Sands082524c2008-01-23 20:39:46 +00004397// zextload bool -> zextload byte
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004398def : Pat<(zextloadi8i1 addr:$src), (MOV8rm addr:$src)>;
4399def : Pat<(zextloadi16i1 addr:$src), (MOVZX16rm8 addr:$src)>;
4400def : Pat<(zextloadi32i1 addr:$src), (MOVZX32rm8 addr:$src)>;
4401
4402// extload bool -> extload byte
4403def : Pat<(extloadi8i1 addr:$src), (MOV8rm addr:$src)>;
Dan Gohman9959b052009-08-26 14:59:13 +00004404def : Pat<(extloadi16i1 addr:$src), (MOVZX16rm8 addr:$src)>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004405def : Pat<(extloadi32i1 addr:$src), (MOVZX32rm8 addr:$src)>;
Dan Gohman9959b052009-08-26 14:59:13 +00004406def : Pat<(extloadi16i8 addr:$src), (MOVZX16rm8 addr:$src)>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004407def : Pat<(extloadi32i8 addr:$src), (MOVZX32rm8 addr:$src)>;
4408def : Pat<(extloadi32i16 addr:$src), (MOVZX32rm16 addr:$src)>;
4409
Dan Gohman9959b052009-08-26 14:59:13 +00004410// anyext. Define these to do an explicit zero-extend to
4411// avoid partial-register updates.
4412def : Pat<(i16 (anyext GR8 :$src)), (MOVZX16rr8 GR8 :$src)>;
4413def : Pat<(i32 (anyext GR8 :$src)), (MOVZX32rr8 GR8 :$src)>;
4414def : Pat<(i32 (anyext GR16:$src)), (MOVZX32rr16 GR16:$src)>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004415
Evan Chengf2abee72007-12-13 00:43:27 +00004416// (and (i32 load), 255) -> (zextload i8)
Evan Cheng1e5e5452008-09-29 17:26:18 +00004417def : Pat<(i32 (and (nvloadi32 addr:$src), (i32 255))),
4418 (MOVZX32rm8 addr:$src)>;
4419def : Pat<(i32 (and (nvloadi32 addr:$src), (i32 65535))),
4420 (MOVZX32rm16 addr:$src)>;
Evan Chengf2abee72007-12-13 00:43:27 +00004421
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004422//===----------------------------------------------------------------------===//
4423// Some peepholes
4424//===----------------------------------------------------------------------===//
4425
Dan Gohman5a5e6e92008-10-17 01:33:43 +00004426// Odd encoding trick: -128 fits into an 8-bit immediate field while
4427// +128 doesn't, so in this special case use a sub instead of an add.
4428def : Pat<(add GR16:$src1, 128),
4429 (SUB16ri8 GR16:$src1, -128)>;
4430def : Pat<(store (add (loadi16 addr:$dst), 128), addr:$dst),
4431 (SUB16mi8 addr:$dst, -128)>;
4432def : Pat<(add GR32:$src1, 128),
4433 (SUB32ri8 GR32:$src1, -128)>;
4434def : Pat<(store (add (loadi32 addr:$dst), 128), addr:$dst),
4435 (SUB32mi8 addr:$dst, -128)>;
4436
Dan Gohman9203ab42008-07-30 18:09:17 +00004437// r & (2^16-1) ==> movz
4438def : Pat<(and GR32:$src1, 0xffff),
Dan Gohman744d4622009-04-13 16:09:41 +00004439 (MOVZX32rr16 (EXTRACT_SUBREG GR32:$src1, x86_subreg_16bit))>;
Dan Gohman5beb1ff2008-08-06 18:27:21 +00004440// r & (2^8-1) ==> movz
4441def : Pat<(and GR32:$src1, 0xff),
Anton Korobeynikovd9331212009-11-02 00:11:39 +00004442 (MOVZX32rr8 (EXTRACT_SUBREG (i32 (COPY_TO_REGCLASS GR32:$src1,
4443 GR32_ABCD)),
Dan Gohman744d4622009-04-13 16:09:41 +00004444 x86_subreg_8bit))>,
Dan Gohman5beb1ff2008-08-06 18:27:21 +00004445 Requires<[In32BitMode]>;
4446// r & (2^8-1) ==> movz
4447def : Pat<(and GR16:$src1, 0xff),
Anton Korobeynikovd9331212009-11-02 00:11:39 +00004448 (MOVZX16rr8 (EXTRACT_SUBREG (i16 (COPY_TO_REGCLASS GR16:$src1,
4449 GR16_ABCD)),
Dan Gohman744d4622009-04-13 16:09:41 +00004450 x86_subreg_8bit))>,
Dan Gohmandd612bb2008-08-20 21:27:32 +00004451 Requires<[In32BitMode]>;
4452
4453// sext_inreg patterns
4454def : Pat<(sext_inreg GR32:$src, i16),
Dan Gohman744d4622009-04-13 16:09:41 +00004455 (MOVSX32rr16 (EXTRACT_SUBREG GR32:$src, x86_subreg_16bit))>;
Dan Gohmandd612bb2008-08-20 21:27:32 +00004456def : Pat<(sext_inreg GR32:$src, i8),
Anton Korobeynikovd9331212009-11-02 00:11:39 +00004457 (MOVSX32rr8 (EXTRACT_SUBREG (i32 (COPY_TO_REGCLASS GR32:$src,
4458 GR32_ABCD)),
Dan Gohman744d4622009-04-13 16:09:41 +00004459 x86_subreg_8bit))>,
Dan Gohmandd612bb2008-08-20 21:27:32 +00004460 Requires<[In32BitMode]>;
4461def : Pat<(sext_inreg GR16:$src, i8),
Anton Korobeynikovd9331212009-11-02 00:11:39 +00004462 (MOVSX16rr8 (EXTRACT_SUBREG (i16 (COPY_TO_REGCLASS GR16:$src,
4463 GR16_ABCD)),
Dan Gohman744d4622009-04-13 16:09:41 +00004464 x86_subreg_8bit))>,
Dan Gohmandd612bb2008-08-20 21:27:32 +00004465 Requires<[In32BitMode]>;
4466
4467// trunc patterns
4468def : Pat<(i16 (trunc GR32:$src)),
Dan Gohman744d4622009-04-13 16:09:41 +00004469 (EXTRACT_SUBREG GR32:$src, x86_subreg_16bit)>;
Dan Gohmandd612bb2008-08-20 21:27:32 +00004470def : Pat<(i8 (trunc GR32:$src)),
Anton Korobeynikovd9331212009-11-02 00:11:39 +00004471 (EXTRACT_SUBREG (i32 (COPY_TO_REGCLASS GR32:$src, GR32_ABCD)),
Dan Gohman744d4622009-04-13 16:09:41 +00004472 x86_subreg_8bit)>,
Dan Gohmandd612bb2008-08-20 21:27:32 +00004473 Requires<[In32BitMode]>;
4474def : Pat<(i8 (trunc GR16:$src)),
Anton Korobeynikovd9331212009-11-02 00:11:39 +00004475 (EXTRACT_SUBREG (i16 (COPY_TO_REGCLASS GR16:$src, GR16_ABCD)),
Dan Gohman744d4622009-04-13 16:09:41 +00004476 x86_subreg_8bit)>,
4477 Requires<[In32BitMode]>;
4478
4479// h-register tricks
4480def : Pat<(i8 (trunc (srl_su GR16:$src, (i8 8)))),
Anton Korobeynikovd9331212009-11-02 00:11:39 +00004481 (EXTRACT_SUBREG (i32 (COPY_TO_REGCLASS GR16:$src, GR16_ABCD)),
Dan Gohman744d4622009-04-13 16:09:41 +00004482 x86_subreg_8bit_hi)>,
4483 Requires<[In32BitMode]>;
4484def : Pat<(i8 (trunc (srl_su GR32:$src, (i8 8)))),
Anton Korobeynikovd9331212009-11-02 00:11:39 +00004485 (EXTRACT_SUBREG (i16 (COPY_TO_REGCLASS GR32:$src, GR32_ABCD)),
Dan Gohman744d4622009-04-13 16:09:41 +00004486 x86_subreg_8bit_hi)>,
4487 Requires<[In32BitMode]>;
4488def : Pat<(srl_su GR16:$src, (i8 8)),
4489 (EXTRACT_SUBREG
4490 (MOVZX32rr8
Anton Korobeynikovd9331212009-11-02 00:11:39 +00004491 (EXTRACT_SUBREG (i16 (COPY_TO_REGCLASS GR16:$src, GR16_ABCD)),
Dan Gohman744d4622009-04-13 16:09:41 +00004492 x86_subreg_8bit_hi)),
4493 x86_subreg_16bit)>,
4494 Requires<[In32BitMode]>;
Evan Cheng957ca282009-05-29 01:44:43 +00004495def : Pat<(i32 (zext (srl_su GR16:$src, (i8 8)))),
Sean Callanan2c48df22009-12-18 00:01:26 +00004496 (MOVZX32rr8 (EXTRACT_SUBREG (i16 (COPY_TO_REGCLASS GR16:$src,
4497 GR16_ABCD)),
Evan Cheng957ca282009-05-29 01:44:43 +00004498 x86_subreg_8bit_hi))>,
4499 Requires<[In32BitMode]>;
Dan Gohman9959b052009-08-26 14:59:13 +00004500def : Pat<(i32 (anyext (srl_su GR16:$src, (i8 8)))),
Sean Callanan2c48df22009-12-18 00:01:26 +00004501 (MOVZX32rr8 (EXTRACT_SUBREG (i16 (COPY_TO_REGCLASS GR16:$src,
4502 GR16_ABCD)),
Dan Gohman9959b052009-08-26 14:59:13 +00004503 x86_subreg_8bit_hi))>,
4504 Requires<[In32BitMode]>;
Dan Gohman744d4622009-04-13 16:09:41 +00004505def : Pat<(and (srl_su GR32:$src, (i8 8)), (i32 255)),
Sean Callanan2c48df22009-12-18 00:01:26 +00004506 (MOVZX32rr8 (EXTRACT_SUBREG (i32 (COPY_TO_REGCLASS GR32:$src,
4507 GR32_ABCD)),
Dan Gohman744d4622009-04-13 16:09:41 +00004508 x86_subreg_8bit_hi))>,
Dan Gohman5beb1ff2008-08-06 18:27:21 +00004509 Requires<[In32BitMode]>;
Dan Gohman9203ab42008-07-30 18:09:17 +00004510
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004511// (shl x, 1) ==> (add x, x)
4512def : Pat<(shl GR8 :$src1, (i8 1)), (ADD8rr GR8 :$src1, GR8 :$src1)>;
4513def : Pat<(shl GR16:$src1, (i8 1)), (ADD16rr GR16:$src1, GR16:$src1)>;
4514def : Pat<(shl GR32:$src1, (i8 1)), (ADD32rr GR32:$src1, GR32:$src1)>;
4515
Evan Cheng76a64c72008-08-30 02:03:58 +00004516// (shl x (and y, 31)) ==> (shl x, y)
4517def : Pat<(shl GR8:$src1, (and CL:$amt, 31)),
4518 (SHL8rCL GR8:$src1)>;
4519def : Pat<(shl GR16:$src1, (and CL:$amt, 31)),
4520 (SHL16rCL GR16:$src1)>;
4521def : Pat<(shl GR32:$src1, (and CL:$amt, 31)),
4522 (SHL32rCL GR32:$src1)>;
4523def : Pat<(store (shl (loadi8 addr:$dst), (and CL:$amt, 31)), addr:$dst),
4524 (SHL8mCL addr:$dst)>;
4525def : Pat<(store (shl (loadi16 addr:$dst), (and CL:$amt, 31)), addr:$dst),
4526 (SHL16mCL addr:$dst)>;
4527def : Pat<(store (shl (loadi32 addr:$dst), (and CL:$amt, 31)), addr:$dst),
4528 (SHL32mCL addr:$dst)>;
4529
4530def : Pat<(srl GR8:$src1, (and CL:$amt, 31)),
4531 (SHR8rCL GR8:$src1)>;
4532def : Pat<(srl GR16:$src1, (and CL:$amt, 31)),
4533 (SHR16rCL GR16:$src1)>;
4534def : Pat<(srl GR32:$src1, (and CL:$amt, 31)),
4535 (SHR32rCL GR32:$src1)>;
4536def : Pat<(store (srl (loadi8 addr:$dst), (and CL:$amt, 31)), addr:$dst),
4537 (SHR8mCL addr:$dst)>;
4538def : Pat<(store (srl (loadi16 addr:$dst), (and CL:$amt, 31)), addr:$dst),
4539 (SHR16mCL addr:$dst)>;
4540def : Pat<(store (srl (loadi32 addr:$dst), (and CL:$amt, 31)), addr:$dst),
4541 (SHR32mCL addr:$dst)>;
4542
4543def : Pat<(sra GR8:$src1, (and CL:$amt, 31)),
4544 (SAR8rCL GR8:$src1)>;
4545def : Pat<(sra GR16:$src1, (and CL:$amt, 31)),
4546 (SAR16rCL GR16:$src1)>;
4547def : Pat<(sra GR32:$src1, (and CL:$amt, 31)),
4548 (SAR32rCL GR32:$src1)>;
4549def : Pat<(store (sra (loadi8 addr:$dst), (and CL:$amt, 31)), addr:$dst),
4550 (SAR8mCL addr:$dst)>;
4551def : Pat<(store (sra (loadi16 addr:$dst), (and CL:$amt, 31)), addr:$dst),
4552 (SAR16mCL addr:$dst)>;
4553def : Pat<(store (sra (loadi32 addr:$dst), (and CL:$amt, 31)), addr:$dst),
4554 (SAR32mCL addr:$dst)>;
4555
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004556// (or (x >> c) | (y << (32 - c))) ==> (shrd32 x, y, c)
4557def : Pat<(or (srl GR32:$src1, CL:$amt),
4558 (shl GR32:$src2, (sub 32, CL:$amt))),
4559 (SHRD32rrCL GR32:$src1, GR32:$src2)>;
4560
4561def : Pat<(store (or (srl (loadi32 addr:$dst), CL:$amt),
4562 (shl GR32:$src2, (sub 32, CL:$amt))), addr:$dst),
4563 (SHRD32mrCL addr:$dst, GR32:$src2)>;
4564
Dan Gohman921581d2008-10-17 01:23:35 +00004565def : Pat<(or (srl GR32:$src1, (i8 (trunc ECX:$amt))),
4566 (shl GR32:$src2, (i8 (trunc (sub 32, ECX:$amt))))),
4567 (SHRD32rrCL GR32:$src1, GR32:$src2)>;
4568
4569def : Pat<(store (or (srl (loadi32 addr:$dst), (i8 (trunc ECX:$amt))),
4570 (shl GR32:$src2, (i8 (trunc (sub 32, ECX:$amt))))),
4571 addr:$dst),
4572 (SHRD32mrCL addr:$dst, GR32:$src2)>;
4573
4574def : Pat<(shrd GR32:$src1, (i8 imm:$amt1), GR32:$src2, (i8 imm:$amt2)),
4575 (SHRD32rri8 GR32:$src1, GR32:$src2, (i8 imm:$amt1))>;
4576
4577def : Pat<(store (shrd (loadi32 addr:$dst), (i8 imm:$amt1),
4578 GR32:$src2, (i8 imm:$amt2)), addr:$dst),
4579 (SHRD32mri8 addr:$dst, GR32:$src2, (i8 imm:$amt1))>;
4580
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004581// (or (x << c) | (y >> (32 - c))) ==> (shld32 x, y, c)
4582def : Pat<(or (shl GR32:$src1, CL:$amt),
4583 (srl GR32:$src2, (sub 32, CL:$amt))),
4584 (SHLD32rrCL GR32:$src1, GR32:$src2)>;
4585
4586def : Pat<(store (or (shl (loadi32 addr:$dst), CL:$amt),
4587 (srl GR32:$src2, (sub 32, CL:$amt))), addr:$dst),
4588 (SHLD32mrCL addr:$dst, GR32:$src2)>;
4589
Dan Gohman921581d2008-10-17 01:23:35 +00004590def : Pat<(or (shl GR32:$src1, (i8 (trunc ECX:$amt))),
4591 (srl GR32:$src2, (i8 (trunc (sub 32, ECX:$amt))))),
4592 (SHLD32rrCL GR32:$src1, GR32:$src2)>;
4593
4594def : Pat<(store (or (shl (loadi32 addr:$dst), (i8 (trunc ECX:$amt))),
4595 (srl GR32:$src2, (i8 (trunc (sub 32, ECX:$amt))))),
4596 addr:$dst),
4597 (SHLD32mrCL addr:$dst, GR32:$src2)>;
4598
4599def : Pat<(shld GR32:$src1, (i8 imm:$amt1), GR32:$src2, (i8 imm:$amt2)),
4600 (SHLD32rri8 GR32:$src1, GR32:$src2, (i8 imm:$amt1))>;
4601
4602def : Pat<(store (shld (loadi32 addr:$dst), (i8 imm:$amt1),
4603 GR32:$src2, (i8 imm:$amt2)), addr:$dst),
4604 (SHLD32mri8 addr:$dst, GR32:$src2, (i8 imm:$amt1))>;
4605
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004606// (or (x >> c) | (y << (16 - c))) ==> (shrd16 x, y, c)
4607def : Pat<(or (srl GR16:$src1, CL:$amt),
4608 (shl GR16:$src2, (sub 16, CL:$amt))),
4609 (SHRD16rrCL GR16:$src1, GR16:$src2)>;
4610
4611def : Pat<(store (or (srl (loadi16 addr:$dst), CL:$amt),
4612 (shl GR16:$src2, (sub 16, CL:$amt))), addr:$dst),
4613 (SHRD16mrCL addr:$dst, GR16:$src2)>;
4614
Dan Gohman921581d2008-10-17 01:23:35 +00004615def : Pat<(or (srl GR16:$src1, (i8 (trunc CX:$amt))),
4616 (shl GR16:$src2, (i8 (trunc (sub 16, CX:$amt))))),
4617 (SHRD16rrCL GR16:$src1, GR16:$src2)>;
4618
4619def : Pat<(store (or (srl (loadi16 addr:$dst), (i8 (trunc CX:$amt))),
4620 (shl GR16:$src2, (i8 (trunc (sub 16, CX:$amt))))),
4621 addr:$dst),
4622 (SHRD16mrCL addr:$dst, GR16:$src2)>;
4623
4624def : Pat<(shrd GR16:$src1, (i8 imm:$amt1), GR16:$src2, (i8 imm:$amt2)),
4625 (SHRD16rri8 GR16:$src1, GR16:$src2, (i8 imm:$amt1))>;
4626
4627def : Pat<(store (shrd (loadi16 addr:$dst), (i8 imm:$amt1),
4628 GR16:$src2, (i8 imm:$amt2)), addr:$dst),
4629 (SHRD16mri8 addr:$dst, GR16:$src2, (i8 imm:$amt1))>;
4630
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004631// (or (x << c) | (y >> (16 - c))) ==> (shld16 x, y, c)
4632def : Pat<(or (shl GR16:$src1, CL:$amt),
4633 (srl GR16:$src2, (sub 16, CL:$amt))),
4634 (SHLD16rrCL GR16:$src1, GR16:$src2)>;
4635
4636def : Pat<(store (or (shl (loadi16 addr:$dst), CL:$amt),
4637 (srl GR16:$src2, (sub 16, CL:$amt))), addr:$dst),
4638 (SHLD16mrCL addr:$dst, GR16:$src2)>;
4639
Dan Gohman921581d2008-10-17 01:23:35 +00004640def : Pat<(or (shl GR16:$src1, (i8 (trunc CX:$amt))),
4641 (srl GR16:$src2, (i8 (trunc (sub 16, CX:$amt))))),
4642 (SHLD16rrCL GR16:$src1, GR16:$src2)>;
4643
4644def : Pat<(store (or (shl (loadi16 addr:$dst), (i8 (trunc CX:$amt))),
4645 (srl GR16:$src2, (i8 (trunc (sub 16, CX:$amt))))),
4646 addr:$dst),
4647 (SHLD16mrCL addr:$dst, GR16:$src2)>;
4648
4649def : Pat<(shld GR16:$src1, (i8 imm:$amt1), GR16:$src2, (i8 imm:$amt2)),
4650 (SHLD16rri8 GR16:$src1, GR16:$src2, (i8 imm:$amt1))>;
4651
4652def : Pat<(store (shld (loadi16 addr:$dst), (i8 imm:$amt1),
4653 GR16:$src2, (i8 imm:$amt2)), addr:$dst),
4654 (SHLD16mri8 addr:$dst, GR16:$src2, (i8 imm:$amt1))>;
4655
Evan Chengedeb1692009-12-16 00:53:11 +00004656// (anyext (setcc_carry)) -> (setcc_carry)
4657def : Pat<(i16 (anyext (i8 (X86setcc_c X86_COND_B, EFLAGS)))),
Evan Cheng834ae6b2009-12-15 00:53:42 +00004658 (SETB_C16r)>;
Evan Chengedeb1692009-12-16 00:53:11 +00004659def : Pat<(i32 (anyext (i8 (X86setcc_c X86_COND_B, EFLAGS)))),
Evan Cheng834ae6b2009-12-15 00:53:42 +00004660 (SETB_C32r)>;
4661
Evan Cheng4621d272010-01-11 17:03:47 +00004662// (or x, c) -> (add x, c) if masked bits are known zero.
4663def : Pat<(parallel (or_is_add GR8:$src1, imm:$src2),
4664 (implicit EFLAGS)),
4665 (ADD8ri GR8:$src1, imm:$src2)>;
4666def : Pat<(parallel (or_is_add GR16:$src1, imm:$src2),
4667 (implicit EFLAGS)),
4668 (ADD16ri GR16:$src1, imm:$src2)>;
4669def : Pat<(parallel (or_is_add GR32:$src1, imm:$src2),
4670 (implicit EFLAGS)),
4671 (ADD32ri GR32:$src1, imm:$src2)>;
4672def : Pat<(parallel (or_is_add GR16:$src1, i16immSExt8:$src2),
4673 (implicit EFLAGS)),
4674 (ADD16ri8 GR16:$src1, i16immSExt8:$src2)>;
4675def : Pat<(parallel (or_is_add GR32:$src1, i32immSExt8:$src2),
4676 (implicit EFLAGS)),
4677 (ADD32ri8 GR32:$src1, i32immSExt8:$src2)>;
4678
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004679//===----------------------------------------------------------------------===//
Dan Gohman99a12192009-03-04 19:44:21 +00004680// EFLAGS-defining Patterns
Bill Wendlingf5399032008-12-12 21:15:41 +00004681//===----------------------------------------------------------------------===//
4682
Dan Gohman99a12192009-03-04 19:44:21 +00004683// Register-Register Addition with EFLAGS result
4684def : Pat<(parallel (X86add_flag GR8:$src1, GR8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004685 (implicit EFLAGS)),
4686 (ADD8rr GR8:$src1, GR8:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00004687def : Pat<(parallel (X86add_flag GR16:$src1, GR16:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004688 (implicit EFLAGS)),
4689 (ADD16rr GR16:$src1, GR16:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00004690def : Pat<(parallel (X86add_flag GR32:$src1, GR32:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004691 (implicit EFLAGS)),
4692 (ADD32rr GR32:$src1, GR32:$src2)>;
4693
Dan Gohman99a12192009-03-04 19:44:21 +00004694// Register-Memory Addition with EFLAGS result
4695def : Pat<(parallel (X86add_flag GR8:$src1, (loadi8 addr:$src2)),
Bill Wendlingf5399032008-12-12 21:15:41 +00004696 (implicit EFLAGS)),
4697 (ADD8rm GR8:$src1, addr:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00004698def : Pat<(parallel (X86add_flag GR16:$src1, (loadi16 addr:$src2)),
Bill Wendlingf5399032008-12-12 21:15:41 +00004699 (implicit EFLAGS)),
4700 (ADD16rm GR16:$src1, addr:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00004701def : Pat<(parallel (X86add_flag GR32:$src1, (loadi32 addr:$src2)),
Bill Wendlingf5399032008-12-12 21:15:41 +00004702 (implicit EFLAGS)),
4703 (ADD32rm GR32:$src1, addr:$src2)>;
4704
Dan Gohman99a12192009-03-04 19:44:21 +00004705// Register-Integer Addition with EFLAGS result
4706def : Pat<(parallel (X86add_flag GR8:$src1, imm:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004707 (implicit EFLAGS)),
4708 (ADD8ri GR8:$src1, imm:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00004709def : Pat<(parallel (X86add_flag GR16:$src1, imm:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004710 (implicit EFLAGS)),
4711 (ADD16ri GR16:$src1, imm:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00004712def : Pat<(parallel (X86add_flag GR32:$src1, imm:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004713 (implicit EFLAGS)),
4714 (ADD32ri GR32:$src1, imm:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00004715def : Pat<(parallel (X86add_flag GR16:$src1, i16immSExt8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004716 (implicit EFLAGS)),
4717 (ADD16ri8 GR16:$src1, i16immSExt8:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00004718def : Pat<(parallel (X86add_flag GR32:$src1, i32immSExt8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004719 (implicit EFLAGS)),
4720 (ADD32ri8 GR32:$src1, i32immSExt8:$src2)>;
4721
Dan Gohman99a12192009-03-04 19:44:21 +00004722// Memory-Register Addition with EFLAGS result
4723def : Pat<(parallel (store (X86add_flag (loadi8 addr:$dst), GR8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004724 addr:$dst),
4725 (implicit EFLAGS)),
4726 (ADD8mr addr:$dst, GR8:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00004727def : Pat<(parallel (store (X86add_flag (loadi16 addr:$dst), GR16:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004728 addr:$dst),
4729 (implicit EFLAGS)),
4730 (ADD16mr addr:$dst, GR16:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00004731def : Pat<(parallel (store (X86add_flag (loadi32 addr:$dst), GR32:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004732 addr:$dst),
4733 (implicit EFLAGS)),
4734 (ADD32mr addr:$dst, GR32:$src2)>;
Dale Johannesen06b83f12009-05-18 17:44:15 +00004735
4736// Memory-Integer Addition with EFLAGS result
Dan Gohman99a12192009-03-04 19:44:21 +00004737def : Pat<(parallel (store (X86add_flag (loadi8 addr:$dst), imm:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004738 addr:$dst),
4739 (implicit EFLAGS)),
4740 (ADD8mi addr:$dst, imm:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00004741def : Pat<(parallel (store (X86add_flag (loadi16 addr:$dst), imm:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004742 addr:$dst),
4743 (implicit EFLAGS)),
4744 (ADD16mi addr:$dst, imm:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00004745def : Pat<(parallel (store (X86add_flag (loadi32 addr:$dst), imm:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004746 addr:$dst),
4747 (implicit EFLAGS)),
4748 (ADD32mi addr:$dst, imm:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00004749def : Pat<(parallel (store (X86add_flag (loadi16 addr:$dst), i16immSExt8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004750 addr:$dst),
4751 (implicit EFLAGS)),
4752 (ADD16mi8 addr:$dst, i16immSExt8:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00004753def : Pat<(parallel (store (X86add_flag (loadi32 addr:$dst), i32immSExt8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004754 addr:$dst),
4755 (implicit EFLAGS)),
4756 (ADD32mi8 addr:$dst, i32immSExt8:$src2)>;
4757
Dan Gohman99a12192009-03-04 19:44:21 +00004758// Register-Register Subtraction with EFLAGS result
4759def : Pat<(parallel (X86sub_flag GR8:$src1, GR8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004760 (implicit EFLAGS)),
4761 (SUB8rr GR8:$src1, GR8:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00004762def : Pat<(parallel (X86sub_flag GR16:$src1, GR16:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004763 (implicit EFLAGS)),
4764 (SUB16rr GR16:$src1, GR16:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00004765def : Pat<(parallel (X86sub_flag GR32:$src1, GR32:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004766 (implicit EFLAGS)),
4767 (SUB32rr GR32:$src1, GR32:$src2)>;
4768
Dan Gohman99a12192009-03-04 19:44:21 +00004769// Register-Memory Subtraction with EFLAGS result
4770def : Pat<(parallel (X86sub_flag GR8:$src1, (loadi8 addr:$src2)),
Bill Wendlingf5399032008-12-12 21:15:41 +00004771 (implicit EFLAGS)),
4772 (SUB8rm GR8:$src1, addr:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00004773def : Pat<(parallel (X86sub_flag GR16:$src1, (loadi16 addr:$src2)),
Bill Wendlingf5399032008-12-12 21:15:41 +00004774 (implicit EFLAGS)),
4775 (SUB16rm GR16:$src1, addr:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00004776def : Pat<(parallel (X86sub_flag GR32:$src1, (loadi32 addr:$src2)),
Bill Wendlingf5399032008-12-12 21:15:41 +00004777 (implicit EFLAGS)),
4778 (SUB32rm GR32:$src1, addr:$src2)>;
4779
Dan Gohman99a12192009-03-04 19:44:21 +00004780// Register-Integer Subtraction with EFLAGS result
4781def : Pat<(parallel (X86sub_flag GR8:$src1, imm:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004782 (implicit EFLAGS)),
4783 (SUB8ri GR8:$src1, imm:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00004784def : Pat<(parallel (X86sub_flag GR16:$src1, imm:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004785 (implicit EFLAGS)),
4786 (SUB16ri GR16:$src1, imm:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00004787def : Pat<(parallel (X86sub_flag GR32:$src1, imm:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004788 (implicit EFLAGS)),
4789 (SUB32ri GR32:$src1, imm:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00004790def : Pat<(parallel (X86sub_flag GR16:$src1, i16immSExt8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004791 (implicit EFLAGS)),
4792 (SUB16ri8 GR16:$src1, i16immSExt8:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00004793def : Pat<(parallel (X86sub_flag GR32:$src1, i32immSExt8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004794 (implicit EFLAGS)),
4795 (SUB32ri8 GR32:$src1, i32immSExt8:$src2)>;
4796
Dan Gohman99a12192009-03-04 19:44:21 +00004797// Memory-Register Subtraction with EFLAGS result
4798def : Pat<(parallel (store (X86sub_flag (loadi8 addr:$dst), GR8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004799 addr:$dst),
4800 (implicit EFLAGS)),
4801 (SUB8mr addr:$dst, GR8:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00004802def : Pat<(parallel (store (X86sub_flag (loadi16 addr:$dst), GR16:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004803 addr:$dst),
4804 (implicit EFLAGS)),
4805 (SUB16mr addr:$dst, GR16:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00004806def : Pat<(parallel (store (X86sub_flag (loadi32 addr:$dst), GR32:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004807 addr:$dst),
4808 (implicit EFLAGS)),
4809 (SUB32mr addr:$dst, GR32:$src2)>;
4810
Dan Gohman99a12192009-03-04 19:44:21 +00004811// Memory-Integer Subtraction with EFLAGS result
4812def : Pat<(parallel (store (X86sub_flag (loadi8 addr:$dst), imm:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004813 addr:$dst),
4814 (implicit EFLAGS)),
4815 (SUB8mi addr:$dst, imm:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00004816def : Pat<(parallel (store (X86sub_flag (loadi16 addr:$dst), imm:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004817 addr:$dst),
4818 (implicit EFLAGS)),
4819 (SUB16mi addr:$dst, imm:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00004820def : Pat<(parallel (store (X86sub_flag (loadi32 addr:$dst), imm:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004821 addr:$dst),
4822 (implicit EFLAGS)),
4823 (SUB32mi addr:$dst, imm:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00004824def : Pat<(parallel (store (X86sub_flag (loadi16 addr:$dst), i16immSExt8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004825 addr:$dst),
4826 (implicit EFLAGS)),
4827 (SUB16mi8 addr:$dst, i16immSExt8:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00004828def : Pat<(parallel (store (X86sub_flag (loadi32 addr:$dst), i32immSExt8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004829 addr:$dst),
4830 (implicit EFLAGS)),
4831 (SUB32mi8 addr:$dst, i32immSExt8:$src2)>;
4832
4833
Dan Gohman99a12192009-03-04 19:44:21 +00004834// Register-Register Signed Integer Multiply with EFLAGS result
4835def : Pat<(parallel (X86smul_flag GR16:$src1, GR16:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004836 (implicit EFLAGS)),
4837 (IMUL16rr GR16:$src1, GR16:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00004838def : Pat<(parallel (X86smul_flag GR32:$src1, GR32:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004839 (implicit EFLAGS)),
4840 (IMUL32rr GR32:$src1, GR32:$src2)>;
4841
Dan Gohman99a12192009-03-04 19:44:21 +00004842// Register-Memory Signed Integer Multiply with EFLAGS result
4843def : Pat<(parallel (X86smul_flag GR16:$src1, (loadi16 addr:$src2)),
Bill Wendlingf5399032008-12-12 21:15:41 +00004844 (implicit EFLAGS)),
4845 (IMUL16rm GR16:$src1, addr:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00004846def : Pat<(parallel (X86smul_flag GR32:$src1, (loadi32 addr:$src2)),
Bill Wendlingf5399032008-12-12 21:15:41 +00004847 (implicit EFLAGS)),
4848 (IMUL32rm GR32:$src1, addr:$src2)>;
4849
Dan Gohman99a12192009-03-04 19:44:21 +00004850// Register-Integer Signed Integer Multiply with EFLAGS result
4851def : Pat<(parallel (X86smul_flag GR16:$src1, imm:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004852 (implicit EFLAGS)),
4853 (IMUL16rri GR16:$src1, imm:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00004854def : Pat<(parallel (X86smul_flag GR32:$src1, imm:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004855 (implicit EFLAGS)),
4856 (IMUL32rri GR32:$src1, imm:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00004857def : Pat<(parallel (X86smul_flag GR16:$src1, i16immSExt8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004858 (implicit EFLAGS)),
4859 (IMUL16rri8 GR16:$src1, i16immSExt8:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00004860def : Pat<(parallel (X86smul_flag GR32:$src1, i32immSExt8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004861 (implicit EFLAGS)),
4862 (IMUL32rri8 GR32:$src1, i32immSExt8:$src2)>;
4863
Dan Gohman99a12192009-03-04 19:44:21 +00004864// Memory-Integer Signed Integer Multiply with EFLAGS result
4865def : Pat<(parallel (X86smul_flag (loadi16 addr:$src1), imm:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004866 (implicit EFLAGS)),
4867 (IMUL16rmi addr:$src1, imm:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00004868def : Pat<(parallel (X86smul_flag (loadi32 addr:$src1), imm:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004869 (implicit EFLAGS)),
4870 (IMUL32rmi addr:$src1, imm:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00004871def : Pat<(parallel (X86smul_flag (loadi16 addr:$src1), i16immSExt8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004872 (implicit EFLAGS)),
4873 (IMUL16rmi8 addr:$src1, i16immSExt8:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00004874def : Pat<(parallel (X86smul_flag (loadi32 addr:$src1), i32immSExt8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004875 (implicit EFLAGS)),
4876 (IMUL32rmi8 addr:$src1, i32immSExt8:$src2)>;
4877
Dan Gohman99a12192009-03-04 19:44:21 +00004878// Optimize multiply by 2 with EFLAGS result.
Evan Cheng00cf7932009-01-27 03:30:42 +00004879let AddedComplexity = 2 in {
Dan Gohman99a12192009-03-04 19:44:21 +00004880def : Pat<(parallel (X86smul_flag GR16:$src1, 2),
Evan Cheng00cf7932009-01-27 03:30:42 +00004881 (implicit EFLAGS)),
4882 (ADD16rr GR16:$src1, GR16:$src1)>;
4883
Dan Gohman99a12192009-03-04 19:44:21 +00004884def : Pat<(parallel (X86smul_flag GR32:$src1, 2),
Evan Cheng00cf7932009-01-27 03:30:42 +00004885 (implicit EFLAGS)),
4886 (ADD32rr GR32:$src1, GR32:$src1)>;
4887}
4888
Dan Gohman99a12192009-03-04 19:44:21 +00004889// INC and DEC with EFLAGS result. Note that these do not set CF.
4890def : Pat<(parallel (X86inc_flag GR8:$src), (implicit EFLAGS)),
4891 (INC8r GR8:$src)>;
4892def : Pat<(parallel (store (i8 (X86inc_flag (loadi8 addr:$dst))), addr:$dst),
4893 (implicit EFLAGS)),
4894 (INC8m addr:$dst)>;
4895def : Pat<(parallel (X86dec_flag GR8:$src), (implicit EFLAGS)),
4896 (DEC8r GR8:$src)>;
4897def : Pat<(parallel (store (i8 (X86dec_flag (loadi8 addr:$dst))), addr:$dst),
4898 (implicit EFLAGS)),
4899 (DEC8m addr:$dst)>;
4900
4901def : Pat<(parallel (X86inc_flag GR16:$src), (implicit EFLAGS)),
Dan Gohmaneebcac72009-03-05 21:32:23 +00004902 (INC16r GR16:$src)>, Requires<[In32BitMode]>;
Dan Gohman99a12192009-03-04 19:44:21 +00004903def : Pat<(parallel (store (i16 (X86inc_flag (loadi16 addr:$dst))), addr:$dst),
4904 (implicit EFLAGS)),
Dan Gohmaneebcac72009-03-05 21:32:23 +00004905 (INC16m addr:$dst)>, Requires<[In32BitMode]>;
Dan Gohman99a12192009-03-04 19:44:21 +00004906def : Pat<(parallel (X86dec_flag GR16:$src), (implicit EFLAGS)),
Dan Gohmaneebcac72009-03-05 21:32:23 +00004907 (DEC16r GR16:$src)>, Requires<[In32BitMode]>;
Dan Gohman99a12192009-03-04 19:44:21 +00004908def : Pat<(parallel (store (i16 (X86dec_flag (loadi16 addr:$dst))), addr:$dst),
4909 (implicit EFLAGS)),
Dan Gohmaneebcac72009-03-05 21:32:23 +00004910 (DEC16m addr:$dst)>, Requires<[In32BitMode]>;
Dan Gohman99a12192009-03-04 19:44:21 +00004911
4912def : Pat<(parallel (X86inc_flag GR32:$src), (implicit EFLAGS)),
Dan Gohmaneebcac72009-03-05 21:32:23 +00004913 (INC32r GR32:$src)>, Requires<[In32BitMode]>;
Dan Gohman99a12192009-03-04 19:44:21 +00004914def : Pat<(parallel (store (i32 (X86inc_flag (loadi32 addr:$dst))), addr:$dst),
4915 (implicit EFLAGS)),
Dan Gohmaneebcac72009-03-05 21:32:23 +00004916 (INC32m addr:$dst)>, Requires<[In32BitMode]>;
Dan Gohman99a12192009-03-04 19:44:21 +00004917def : Pat<(parallel (X86dec_flag GR32:$src), (implicit EFLAGS)),
Dan Gohmaneebcac72009-03-05 21:32:23 +00004918 (DEC32r GR32:$src)>, Requires<[In32BitMode]>;
Dan Gohman99a12192009-03-04 19:44:21 +00004919def : Pat<(parallel (store (i32 (X86dec_flag (loadi32 addr:$dst))), addr:$dst),
4920 (implicit EFLAGS)),
Dan Gohmaneebcac72009-03-05 21:32:23 +00004921 (DEC32m addr:$dst)>, Requires<[In32BitMode]>;
Dan Gohman99a12192009-03-04 19:44:21 +00004922
Dan Gohman12e03292009-09-18 19:59:53 +00004923// Register-Register Or with EFLAGS result
4924def : Pat<(parallel (X86or_flag GR8:$src1, GR8:$src2),
4925 (implicit EFLAGS)),
4926 (OR8rr GR8:$src1, GR8:$src2)>;
4927def : Pat<(parallel (X86or_flag GR16:$src1, GR16:$src2),
4928 (implicit EFLAGS)),
4929 (OR16rr GR16:$src1, GR16:$src2)>;
4930def : Pat<(parallel (X86or_flag GR32:$src1, GR32:$src2),
4931 (implicit EFLAGS)),
4932 (OR32rr GR32:$src1, GR32:$src2)>;
4933
4934// Register-Memory Or with EFLAGS result
4935def : Pat<(parallel (X86or_flag GR8:$src1, (loadi8 addr:$src2)),
4936 (implicit EFLAGS)),
4937 (OR8rm GR8:$src1, addr:$src2)>;
4938def : Pat<(parallel (X86or_flag GR16:$src1, (loadi16 addr:$src2)),
4939 (implicit EFLAGS)),
4940 (OR16rm GR16:$src1, addr:$src2)>;
4941def : Pat<(parallel (X86or_flag GR32:$src1, (loadi32 addr:$src2)),
4942 (implicit EFLAGS)),
4943 (OR32rm GR32:$src1, addr:$src2)>;
4944
4945// Register-Integer Or with EFLAGS result
4946def : Pat<(parallel (X86or_flag GR8:$src1, imm:$src2),
4947 (implicit EFLAGS)),
4948 (OR8ri GR8:$src1, imm:$src2)>;
4949def : Pat<(parallel (X86or_flag GR16:$src1, imm:$src2),
4950 (implicit EFLAGS)),
4951 (OR16ri GR16:$src1, imm:$src2)>;
4952def : Pat<(parallel (X86or_flag GR32:$src1, imm:$src2),
4953 (implicit EFLAGS)),
4954 (OR32ri GR32:$src1, imm:$src2)>;
4955def : Pat<(parallel (X86or_flag GR16:$src1, i16immSExt8:$src2),
4956 (implicit EFLAGS)),
4957 (OR16ri8 GR16:$src1, i16immSExt8:$src2)>;
4958def : Pat<(parallel (X86or_flag GR32:$src1, i32immSExt8:$src2),
4959 (implicit EFLAGS)),
4960 (OR32ri8 GR32:$src1, i32immSExt8:$src2)>;
4961
4962// Memory-Register Or with EFLAGS result
4963def : Pat<(parallel (store (X86or_flag (loadi8 addr:$dst), GR8:$src2),
4964 addr:$dst),
4965 (implicit EFLAGS)),
4966 (OR8mr addr:$dst, GR8:$src2)>;
4967def : Pat<(parallel (store (X86or_flag (loadi16 addr:$dst), GR16:$src2),
4968 addr:$dst),
4969 (implicit EFLAGS)),
4970 (OR16mr addr:$dst, GR16:$src2)>;
4971def : Pat<(parallel (store (X86or_flag (loadi32 addr:$dst), GR32:$src2),
4972 addr:$dst),
4973 (implicit EFLAGS)),
4974 (OR32mr addr:$dst, GR32:$src2)>;
4975
4976// Memory-Integer Or with EFLAGS result
4977def : Pat<(parallel (store (X86or_flag (loadi8 addr:$dst), imm:$src2),
4978 addr:$dst),
4979 (implicit EFLAGS)),
4980 (OR8mi addr:$dst, imm:$src2)>;
4981def : Pat<(parallel (store (X86or_flag (loadi16 addr:$dst), imm:$src2),
4982 addr:$dst),
4983 (implicit EFLAGS)),
4984 (OR16mi addr:$dst, imm:$src2)>;
4985def : Pat<(parallel (store (X86or_flag (loadi32 addr:$dst), imm:$src2),
4986 addr:$dst),
4987 (implicit EFLAGS)),
4988 (OR32mi addr:$dst, imm:$src2)>;
4989def : Pat<(parallel (store (X86or_flag (loadi16 addr:$dst), i16immSExt8:$src2),
4990 addr:$dst),
4991 (implicit EFLAGS)),
4992 (OR16mi8 addr:$dst, i16immSExt8:$src2)>;
4993def : Pat<(parallel (store (X86or_flag (loadi32 addr:$dst), i32immSExt8:$src2),
4994 addr:$dst),
4995 (implicit EFLAGS)),
4996 (OR32mi8 addr:$dst, i32immSExt8:$src2)>;
4997
4998// Register-Register XOr with EFLAGS result
4999def : Pat<(parallel (X86xor_flag GR8:$src1, GR8:$src2),
5000 (implicit EFLAGS)),
5001 (XOR8rr GR8:$src1, GR8:$src2)>;
5002def : Pat<(parallel (X86xor_flag GR16:$src1, GR16:$src2),
5003 (implicit EFLAGS)),
5004 (XOR16rr GR16:$src1, GR16:$src2)>;
5005def : Pat<(parallel (X86xor_flag GR32:$src1, GR32:$src2),
5006 (implicit EFLAGS)),
5007 (XOR32rr GR32:$src1, GR32:$src2)>;
5008
5009// Register-Memory XOr with EFLAGS result
5010def : Pat<(parallel (X86xor_flag GR8:$src1, (loadi8 addr:$src2)),
5011 (implicit EFLAGS)),
5012 (XOR8rm GR8:$src1, addr:$src2)>;
5013def : Pat<(parallel (X86xor_flag GR16:$src1, (loadi16 addr:$src2)),
5014 (implicit EFLAGS)),
5015 (XOR16rm GR16:$src1, addr:$src2)>;
5016def : Pat<(parallel (X86xor_flag GR32:$src1, (loadi32 addr:$src2)),
5017 (implicit EFLAGS)),
5018 (XOR32rm GR32:$src1, addr:$src2)>;
5019
5020// Register-Integer XOr with EFLAGS result
5021def : Pat<(parallel (X86xor_flag GR8:$src1, imm:$src2),
5022 (implicit EFLAGS)),
5023 (XOR8ri GR8:$src1, imm:$src2)>;
5024def : Pat<(parallel (X86xor_flag GR16:$src1, imm:$src2),
5025 (implicit EFLAGS)),
5026 (XOR16ri GR16:$src1, imm:$src2)>;
5027def : Pat<(parallel (X86xor_flag GR32:$src1, imm:$src2),
5028 (implicit EFLAGS)),
5029 (XOR32ri GR32:$src1, imm:$src2)>;
5030def : Pat<(parallel (X86xor_flag GR16:$src1, i16immSExt8:$src2),
5031 (implicit EFLAGS)),
5032 (XOR16ri8 GR16:$src1, i16immSExt8:$src2)>;
5033def : Pat<(parallel (X86xor_flag GR32:$src1, i32immSExt8:$src2),
5034 (implicit EFLAGS)),
5035 (XOR32ri8 GR32:$src1, i32immSExt8:$src2)>;
5036
5037// Memory-Register XOr with EFLAGS result
5038def : Pat<(parallel (store (X86xor_flag (loadi8 addr:$dst), GR8:$src2),
5039 addr:$dst),
5040 (implicit EFLAGS)),
5041 (XOR8mr addr:$dst, GR8:$src2)>;
5042def : Pat<(parallel (store (X86xor_flag (loadi16 addr:$dst), GR16:$src2),
5043 addr:$dst),
5044 (implicit EFLAGS)),
5045 (XOR16mr addr:$dst, GR16:$src2)>;
5046def : Pat<(parallel (store (X86xor_flag (loadi32 addr:$dst), GR32:$src2),
5047 addr:$dst),
5048 (implicit EFLAGS)),
5049 (XOR32mr addr:$dst, GR32:$src2)>;
5050
5051// Memory-Integer XOr with EFLAGS result
5052def : Pat<(parallel (store (X86xor_flag (loadi8 addr:$dst), imm:$src2),
5053 addr:$dst),
5054 (implicit EFLAGS)),
5055 (XOR8mi addr:$dst, imm:$src2)>;
5056def : Pat<(parallel (store (X86xor_flag (loadi16 addr:$dst), imm:$src2),
5057 addr:$dst),
5058 (implicit EFLAGS)),
5059 (XOR16mi addr:$dst, imm:$src2)>;
5060def : Pat<(parallel (store (X86xor_flag (loadi32 addr:$dst), imm:$src2),
5061 addr:$dst),
5062 (implicit EFLAGS)),
5063 (XOR32mi addr:$dst, imm:$src2)>;
5064def : Pat<(parallel (store (X86xor_flag (loadi16 addr:$dst), i16immSExt8:$src2),
5065 addr:$dst),
5066 (implicit EFLAGS)),
5067 (XOR16mi8 addr:$dst, i16immSExt8:$src2)>;
5068def : Pat<(parallel (store (X86xor_flag (loadi32 addr:$dst), i32immSExt8:$src2),
5069 addr:$dst),
5070 (implicit EFLAGS)),
5071 (XOR32mi8 addr:$dst, i32immSExt8:$src2)>;
5072
5073// Register-Register And with EFLAGS result
5074def : Pat<(parallel (X86and_flag GR8:$src1, GR8:$src2),
5075 (implicit EFLAGS)),
5076 (AND8rr GR8:$src1, GR8:$src2)>;
5077def : Pat<(parallel (X86and_flag GR16:$src1, GR16:$src2),
5078 (implicit EFLAGS)),
5079 (AND16rr GR16:$src1, GR16:$src2)>;
5080def : Pat<(parallel (X86and_flag GR32:$src1, GR32:$src2),
5081 (implicit EFLAGS)),
5082 (AND32rr GR32:$src1, GR32:$src2)>;
5083
5084// Register-Memory And with EFLAGS result
5085def : Pat<(parallel (X86and_flag GR8:$src1, (loadi8 addr:$src2)),
5086 (implicit EFLAGS)),
5087 (AND8rm GR8:$src1, addr:$src2)>;
5088def : Pat<(parallel (X86and_flag GR16:$src1, (loadi16 addr:$src2)),
5089 (implicit EFLAGS)),
5090 (AND16rm GR16:$src1, addr:$src2)>;
5091def : Pat<(parallel (X86and_flag GR32:$src1, (loadi32 addr:$src2)),
5092 (implicit EFLAGS)),
5093 (AND32rm GR32:$src1, addr:$src2)>;
5094
5095// Register-Integer And with EFLAGS result
5096def : Pat<(parallel (X86and_flag GR8:$src1, imm:$src2),
5097 (implicit EFLAGS)),
5098 (AND8ri GR8:$src1, imm:$src2)>;
5099def : Pat<(parallel (X86and_flag GR16:$src1, imm:$src2),
5100 (implicit EFLAGS)),
5101 (AND16ri GR16:$src1, imm:$src2)>;
5102def : Pat<(parallel (X86and_flag GR32:$src1, imm:$src2),
5103 (implicit EFLAGS)),
5104 (AND32ri GR32:$src1, imm:$src2)>;
5105def : Pat<(parallel (X86and_flag GR16:$src1, i16immSExt8:$src2),
5106 (implicit EFLAGS)),
5107 (AND16ri8 GR16:$src1, i16immSExt8:$src2)>;
5108def : Pat<(parallel (X86and_flag GR32:$src1, i32immSExt8:$src2),
5109 (implicit EFLAGS)),
5110 (AND32ri8 GR32:$src1, i32immSExt8:$src2)>;
5111
5112// Memory-Register And with EFLAGS result
5113def : Pat<(parallel (store (X86and_flag (loadi8 addr:$dst), GR8:$src2),
5114 addr:$dst),
5115 (implicit EFLAGS)),
5116 (AND8mr addr:$dst, GR8:$src2)>;
5117def : Pat<(parallel (store (X86and_flag (loadi16 addr:$dst), GR16:$src2),
5118 addr:$dst),
5119 (implicit EFLAGS)),
5120 (AND16mr addr:$dst, GR16:$src2)>;
5121def : Pat<(parallel (store (X86and_flag (loadi32 addr:$dst), GR32:$src2),
5122 addr:$dst),
5123 (implicit EFLAGS)),
5124 (AND32mr addr:$dst, GR32:$src2)>;
5125
5126// Memory-Integer And with EFLAGS result
5127def : Pat<(parallel (store (X86and_flag (loadi8 addr:$dst), imm:$src2),
5128 addr:$dst),
5129 (implicit EFLAGS)),
5130 (AND8mi addr:$dst, imm:$src2)>;
5131def : Pat<(parallel (store (X86and_flag (loadi16 addr:$dst), imm:$src2),
5132 addr:$dst),
5133 (implicit EFLAGS)),
5134 (AND16mi addr:$dst, imm:$src2)>;
5135def : Pat<(parallel (store (X86and_flag (loadi32 addr:$dst), imm:$src2),
5136 addr:$dst),
5137 (implicit EFLAGS)),
5138 (AND32mi addr:$dst, imm:$src2)>;
5139def : Pat<(parallel (store (X86and_flag (loadi16 addr:$dst), i16immSExt8:$src2),
5140 addr:$dst),
5141 (implicit EFLAGS)),
5142 (AND16mi8 addr:$dst, i16immSExt8:$src2)>;
5143def : Pat<(parallel (store (X86and_flag (loadi32 addr:$dst), i32immSExt8:$src2),
5144 addr:$dst),
5145 (implicit EFLAGS)),
5146 (AND32mi8 addr:$dst, i32immSExt8:$src2)>;
5147
Dan Gohmane84197b2009-09-03 17:18:51 +00005148// -disable-16bit support.
5149def : Pat<(truncstorei16 (i32 imm:$src), addr:$dst),
5150 (MOV16mi addr:$dst, imm:$src)>;
5151def : Pat<(truncstorei16 GR32:$src, addr:$dst),
5152 (MOV16mr addr:$dst, (EXTRACT_SUBREG GR32:$src, x86_subreg_16bit))>;
5153def : Pat<(i32 (sextloadi16 addr:$dst)),
5154 (MOVSX32rm16 addr:$dst)>;
5155def : Pat<(i32 (zextloadi16 addr:$dst)),
5156 (MOVZX32rm16 addr:$dst)>;
5157def : Pat<(i32 (extloadi16 addr:$dst)),
5158 (MOVZX32rm16 addr:$dst)>;
5159
Bill Wendlingf5399032008-12-12 21:15:41 +00005160//===----------------------------------------------------------------------===//
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005161// Floating Point Stack Support
5162//===----------------------------------------------------------------------===//
5163
5164include "X86InstrFPStack.td"
5165
5166//===----------------------------------------------------------------------===//
Evan Cheng86ab7d32007-07-31 08:04:03 +00005167// X86-64 Support
5168//===----------------------------------------------------------------------===//
5169
Chris Lattner2de8d2b2008-01-10 05:50:42 +00005170include "X86Instr64bit.td"
Evan Cheng86ab7d32007-07-31 08:04:03 +00005171
5172//===----------------------------------------------------------------------===//
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005173// XMM Floating point support (requires SSE / SSE2)
5174//===----------------------------------------------------------------------===//
5175
5176include "X86InstrSSE.td"
Evan Cheng5e4d1e72008-04-25 18:19:54 +00005177
5178//===----------------------------------------------------------------------===//
5179// MMX and XMM Packed Integer support (requires MMX, SSE, and SSE2)
5180//===----------------------------------------------------------------------===//
5181
5182include "X86InstrMMX.td"