blob: 0b6efaa755c7fade7f7d4e117f581ac91b8b1570 [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 Gohman99a12192009-03-04 19:44:21 +0000163def X86add_flag : SDNode<"X86ISD::ADD", SDTBinaryArithWithFlags>;
164def X86sub_flag : SDNode<"X86ISD::SUB", SDTBinaryArithWithFlags>;
165def X86smul_flag : SDNode<"X86ISD::SMUL", SDTBinaryArithWithFlags>;
166def X86umul_flag : SDNode<"X86ISD::UMUL", SDTUnaryArithWithFlags>;
167def X86inc_flag : SDNode<"X86ISD::INC", SDTUnaryArithWithFlags>;
168def X86dec_flag : SDNode<"X86ISD::DEC", SDTUnaryArithWithFlags>;
Dan Gohman12e03292009-09-18 19:59:53 +0000169def X86or_flag : SDNode<"X86ISD::OR", SDTBinaryArithWithFlags>;
170def X86xor_flag : SDNode<"X86ISD::XOR", SDTBinaryArithWithFlags>;
171def X86and_flag : SDNode<"X86ISD::AND", SDTBinaryArithWithFlags>;
Bill Wendlingae034ed2008-12-12 00:56:36 +0000172
Evan Chengc3495762009-03-30 21:36:47 +0000173def X86mul_imm : SDNode<"X86ISD::MUL_IMM", SDTIntBinOp>;
174
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000175//===----------------------------------------------------------------------===//
176// X86 Operand Definitions.
177//
178
Chris Lattner357a0ca2009-06-20 19:34:09 +0000179def i32imm_pcrel : Operand<i32> {
180 let PrintMethod = "print_pcrel_imm";
181}
182
Dan Gohmanfe606822009-07-30 01:56:29 +0000183// A version of ptr_rc which excludes SP, ESP, and RSP. This is used for
184// the index operand of an address, to conform to x86 encoding restrictions.
185def ptr_rc_nosp : PointerLikeRegClass<1>;
Chris Lattner357a0ca2009-06-20 19:34:09 +0000186
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000187// *mem - Operand definitions for the funky X86 addressing mode operands.
188//
Daniel Dunbar0f10cbf2009-08-10 18:41:10 +0000189def X86MemAsmOperand : AsmOperandClass {
190 let Name = "Mem";
Daniel Dunbar6e9ee792009-08-10 19:08:02 +0000191 let SuperClass = ?;
Daniel Dunbar0f10cbf2009-08-10 18:41:10 +0000192}
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000193class X86MemOperand<string printMethod> : Operand<iPTR> {
194 let PrintMethod = printMethod;
Dan Gohmanfe606822009-07-30 01:56:29 +0000195 let MIOperandInfo = (ops ptr_rc, i8imm, ptr_rc_nosp, i32imm, i8imm);
Daniel Dunbar0f10cbf2009-08-10 18:41:10 +0000196 let ParserMatchClass = X86MemAsmOperand;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000197}
198
Sean Callanan66fdfa02009-09-03 00:04:47 +0000199def opaque32mem : X86MemOperand<"printopaquemem">;
200def opaque48mem : X86MemOperand<"printopaquemem">;
201def opaque80mem : X86MemOperand<"printopaquemem">;
Sean Callanan2c48df22009-12-18 00:01:26 +0000202def opaque512mem : X86MemOperand<"printopaquemem">;
203
204def offset8 : Operand<i64> { let PrintMethod = "print_pcrel_imm"; }
205def offset16 : Operand<i64> { let PrintMethod = "print_pcrel_imm"; }
206def offset32 : Operand<i64> { let PrintMethod = "print_pcrel_imm"; }
207def offset64 : Operand<i64> { let PrintMethod = "print_pcrel_imm"; }
Sean Callanan66fdfa02009-09-03 00:04:47 +0000208
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000209def i8mem : X86MemOperand<"printi8mem">;
210def i16mem : X86MemOperand<"printi16mem">;
211def i32mem : X86MemOperand<"printi32mem">;
212def i64mem : X86MemOperand<"printi64mem">;
213def i128mem : X86MemOperand<"printi128mem">;
Chris Lattnerd6153b42009-09-20 07:17:49 +0000214//def i256mem : X86MemOperand<"printi256mem">;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000215def f32mem : X86MemOperand<"printf32mem">;
216def f64mem : X86MemOperand<"printf64mem">;
Dale Johannesen4ab00bd2007-08-05 18:49:15 +0000217def f80mem : X86MemOperand<"printf80mem">;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000218def f128mem : X86MemOperand<"printf128mem">;
Chris Lattnerd6153b42009-09-20 07:17:49 +0000219//def f256mem : X86MemOperand<"printf256mem">;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000220
Dan Gohman744d4622009-04-13 16:09:41 +0000221// A version of i8mem for use on x86-64 that uses GR64_NOREX instead of
222// plain GR64, so that it doesn't potentially require a REX prefix.
223def i8mem_NOREX : Operand<i64> {
224 let PrintMethod = "printi8mem";
Dan Gohmanfe606822009-07-30 01:56:29 +0000225 let MIOperandInfo = (ops GR64_NOREX, i8imm, GR64_NOREX_NOSP, i32imm, i8imm);
Daniel Dunbar0f10cbf2009-08-10 18:41:10 +0000226 let ParserMatchClass = X86MemAsmOperand;
Dan Gohman744d4622009-04-13 16:09:41 +0000227}
228
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000229def lea32mem : Operand<i32> {
Rafael Espindolabca99f72009-04-08 21:14:34 +0000230 let PrintMethod = "printlea32mem";
Dan Gohmanefbd3bc2009-08-05 17:40:24 +0000231 let MIOperandInfo = (ops GR32, i8imm, GR32_NOSP, i32imm);
Daniel Dunbar0f10cbf2009-08-10 18:41:10 +0000232 let ParserMatchClass = X86MemAsmOperand;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000233}
234
235def SSECC : Operand<i8> {
236 let PrintMethod = "printSSECC";
237}
238
Daniel Dunbar0f10cbf2009-08-10 18:41:10 +0000239def ImmSExt8AsmOperand : AsmOperandClass {
240 let Name = "ImmSExt8";
241 let SuperClass = ImmAsmOperand;
242}
243
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000244// A couple of more descriptive operand definitions.
245// 16-bits but only 8 bits are significant.
Daniel Dunbar06d5cb62009-08-09 07:20:21 +0000246def i16i8imm : Operand<i16> {
Daniel Dunbar0f10cbf2009-08-10 18:41:10 +0000247 let ParserMatchClass = ImmSExt8AsmOperand;
Daniel Dunbar06d5cb62009-08-09 07:20:21 +0000248}
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000249// 32-bits but only 8 bits are significant.
Daniel Dunbar06d5cb62009-08-09 07:20:21 +0000250def i32i8imm : Operand<i32> {
Daniel Dunbar0f10cbf2009-08-10 18:41:10 +0000251 let ParserMatchClass = ImmSExt8AsmOperand;
Daniel Dunbar06d5cb62009-08-09 07:20:21 +0000252}
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000253
Chris Lattner357a0ca2009-06-20 19:34:09 +0000254// Branch targets have OtherVT type and print as pc-relative values.
255def brtarget : Operand<OtherVT> {
256 let PrintMethod = "print_pcrel_imm";
257}
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000258
Evan Chengd11052b2009-07-21 06:00:18 +0000259def brtarget8 : Operand<OtherVT> {
260 let PrintMethod = "print_pcrel_imm";
261}
262
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000263//===----------------------------------------------------------------------===//
264// X86 Complex Pattern Definitions.
265//
266
267// Define X86 specific addressing mode.
Rafael Espindolabca99f72009-04-08 21:14:34 +0000268def addr : ComplexPattern<iPTR, 5, "SelectAddr", [], []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000269def lea32addr : ComplexPattern<i32, 4, "SelectLEAAddr",
Dan Gohman0c0d7412009-08-02 16:09:17 +0000270 [add, sub, mul, X86mul_imm, shl, or, frameindex],
271 []>;
Chris Lattnerf1940742009-06-20 20:38:48 +0000272def tls32addr : ComplexPattern<i32, 4, "SelectTLSADDRAddr",
273 [tglobaltlsaddr], []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000274
275//===----------------------------------------------------------------------===//
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000276// X86 Instruction Predicate Definitions.
277def HasMMX : Predicate<"Subtarget->hasMMX()">;
278def HasSSE1 : Predicate<"Subtarget->hasSSE1()">;
279def HasSSE2 : Predicate<"Subtarget->hasSSE2()">;
280def HasSSE3 : Predicate<"Subtarget->hasSSE3()">;
281def HasSSSE3 : Predicate<"Subtarget->hasSSSE3()">;
Nate Begemanb2975562008-02-03 07:18:54 +0000282def HasSSE41 : Predicate<"Subtarget->hasSSE41()">;
283def HasSSE42 : Predicate<"Subtarget->hasSSE42()">;
David Greene8bf22bc2009-06-26 22:46:54 +0000284def HasSSE4A : Predicate<"Subtarget->hasSSE4A()">;
285def HasAVX : Predicate<"Subtarget->hasAVX()">;
286def HasFMA3 : Predicate<"Subtarget->hasFMA3()">;
287def HasFMA4 : Predicate<"Subtarget->hasFMA4()">;
Dale Johannesene0e0fd02007-09-23 14:52:20 +0000288def FPStackf32 : Predicate<"!Subtarget->hasSSE1()">;
289def FPStackf64 : Predicate<"!Subtarget->hasSSE2()">;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000290def In32BitMode : Predicate<"!Subtarget->is64Bit()">;
291def In64BitMode : Predicate<"Subtarget->is64Bit()">;
Anton Korobeynikov2cbcdb72009-08-03 08:12:53 +0000292def IsWin64 : Predicate<"Subtarget->isTargetWin64()">;
293def NotWin64 : Predicate<"!Subtarget->isTargetWin64()">;
Anton Korobeynikov68d4eca2009-08-06 11:23:24 +0000294def SmallCode : Predicate<"TM.getCodeModel() == CodeModel::Small">;
295def KernelCode : Predicate<"TM.getCodeModel() == CodeModel::Kernel">;
296def FarData : Predicate<"TM.getCodeModel() != CodeModel::Small &&"
Anton Korobeynikov7e1178f2009-08-06 09:11:19 +0000297 "TM.getCodeModel() != CodeModel::Kernel">;
Anton Korobeynikov68d4eca2009-08-06 11:23:24 +0000298def NearData : Predicate<"TM.getCodeModel() == CodeModel::Small ||"
299 "TM.getCodeModel() == CodeModel::Kernel">;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000300def IsStatic : Predicate<"TM.getRelocationModel() == Reloc::Static">;
Evan Cheng13559d62008-09-26 23:41:32 +0000301def OptForSpeed : Predicate<"!OptForSize">;
Evan Cheng95a77fd2009-01-02 05:35:45 +0000302def FastBTMem : Predicate<"!Subtarget->isBTMemSlow()">;
Evan Cheng6d35a4d2009-05-20 04:53:57 +0000303def CallImmAddr : Predicate<"Subtarget->IsLegalToCallImmediateAddr(TM)">;
Evan Chengd3f27fb2009-12-18 07:40:29 +0000304def SSEBreakDep : Predicate<"Subtarget->shouldBreakSSEDep() && !OptForSize">;
305def NoSSEBreakDep: Predicate<"!Subtarget->shouldBreakSSEDep() || OptForSize">;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000306
307//===----------------------------------------------------------------------===//
Evan Cheng86ab7d32007-07-31 08:04:03 +0000308// X86 Instruction Format Definitions.
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000309//
310
Evan Cheng86ab7d32007-07-31 08:04:03 +0000311include "X86InstrFormats.td"
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000312
313//===----------------------------------------------------------------------===//
314// Pattern fragments...
315//
316
317// X86 specific condition code. These correspond to CondCode in
318// X86InstrInfo.h. They must be kept in synch.
Dan Gohman0fc9ed62009-01-07 00:15:08 +0000319def X86_COND_A : PatLeaf<(i8 0)>; // alt. COND_NBE
320def X86_COND_AE : PatLeaf<(i8 1)>; // alt. COND_NC
321def X86_COND_B : PatLeaf<(i8 2)>; // alt. COND_C
322def X86_COND_BE : PatLeaf<(i8 3)>; // alt. COND_NA
323def X86_COND_E : PatLeaf<(i8 4)>; // alt. COND_Z
324def X86_COND_G : PatLeaf<(i8 5)>; // alt. COND_NLE
325def X86_COND_GE : PatLeaf<(i8 6)>; // alt. COND_NL
326def X86_COND_L : PatLeaf<(i8 7)>; // alt. COND_NGE
327def X86_COND_LE : PatLeaf<(i8 8)>; // alt. COND_NG
328def X86_COND_NE : PatLeaf<(i8 9)>; // alt. COND_NZ
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000329def X86_COND_NO : PatLeaf<(i8 10)>;
Dan Gohman0fc9ed62009-01-07 00:15:08 +0000330def X86_COND_NP : PatLeaf<(i8 11)>; // alt. COND_PO
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000331def X86_COND_NS : PatLeaf<(i8 12)>;
Dan Gohman0fc9ed62009-01-07 00:15:08 +0000332def X86_COND_O : PatLeaf<(i8 13)>;
333def X86_COND_P : PatLeaf<(i8 14)>; // alt. COND_PE
334def X86_COND_S : PatLeaf<(i8 15)>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000335
336def i16immSExt8 : PatLeaf<(i16 imm), [{
337 // i16immSExt8 predicate - True if the 16-bit immediate fits in a 8-bit
338 // sign extended field.
Dan Gohmanfaeb4a32008-09-12 16:56:44 +0000339 return (int16_t)N->getZExtValue() == (int8_t)N->getZExtValue();
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000340}]>;
341
342def i32immSExt8 : PatLeaf<(i32 imm), [{
343 // i32immSExt8 predicate - True if the 32-bit immediate fits in a 8-bit
344 // sign extended field.
Dan Gohmanfaeb4a32008-09-12 16:56:44 +0000345 return (int32_t)N->getZExtValue() == (int8_t)N->getZExtValue();
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000346}]>;
347
348// Helper fragments for loads.
Evan Chengb3e25ea2008-05-13 18:59:59 +0000349// It's always safe to treat a anyext i16 load as a i32 load if the i16 is
350// known to be 32-bit aligned or better. Ditto for i8 to i16.
Dan Gohman2a174122008-10-15 06:50:19 +0000351def loadi16 : PatFrag<(ops node:$ptr), (i16 (unindexedload node:$ptr)), [{
Dan Gohman8335c412008-08-20 15:24:22 +0000352 LoadSDNode *LD = cast<LoadSDNode>(N);
Chris Lattner12208612009-04-10 00:16:23 +0000353 if (const Value *Src = LD->getSrcValue())
354 if (const PointerType *PT = dyn_cast<PointerType>(Src->getType()))
Mon P Wangdc97d5a2009-04-27 07:22:10 +0000355 if (PT->getAddressSpace() > 255)
Chris Lattner12208612009-04-10 00:16:23 +0000356 return false;
Dan Gohman8335c412008-08-20 15:24:22 +0000357 ISD::LoadExtType ExtType = LD->getExtensionType();
358 if (ExtType == ISD::NON_EXTLOAD)
359 return true;
360 if (ExtType == ISD::EXTLOAD)
361 return LD->getAlignment() >= 2 && !LD->isVolatile();
Evan Cheng8b765e92008-05-13 00:54:02 +0000362 return false;
363}]>;
364
Sean Callanan2c48df22009-12-18 00:01:26 +0000365def loadi16_anyext : PatFrag<(ops node:$ptr), (i32 (unindexedload node:$ptr)),
366[{
Evan Cheng56ec77b2008-09-24 23:27:55 +0000367 LoadSDNode *LD = cast<LoadSDNode>(N);
Chris Lattner12208612009-04-10 00:16:23 +0000368 if (const Value *Src = LD->getSrcValue())
369 if (const PointerType *PT = dyn_cast<PointerType>(Src->getType()))
Mon P Wangdc97d5a2009-04-27 07:22:10 +0000370 if (PT->getAddressSpace() > 255)
Chris Lattner12208612009-04-10 00:16:23 +0000371 return false;
Evan Cheng56ec77b2008-09-24 23:27:55 +0000372 ISD::LoadExtType ExtType = LD->getExtensionType();
373 if (ExtType == ISD::EXTLOAD)
374 return LD->getAlignment() >= 2 && !LD->isVolatile();
375 return false;
376}]>;
377
Dan Gohman2a174122008-10-15 06:50:19 +0000378def loadi32 : PatFrag<(ops node:$ptr), (i32 (unindexedload node:$ptr)), [{
Dan Gohman8335c412008-08-20 15:24:22 +0000379 LoadSDNode *LD = cast<LoadSDNode>(N);
Chris Lattner12208612009-04-10 00:16:23 +0000380 if (const Value *Src = LD->getSrcValue())
381 if (const PointerType *PT = dyn_cast<PointerType>(Src->getType()))
Mon P Wangdc97d5a2009-04-27 07:22:10 +0000382 if (PT->getAddressSpace() > 255)
Chris Lattner12208612009-04-10 00:16:23 +0000383 return false;
Dan Gohman8335c412008-08-20 15:24:22 +0000384 ISD::LoadExtType ExtType = LD->getExtensionType();
385 if (ExtType == ISD::NON_EXTLOAD)
386 return true;
387 if (ExtType == ISD::EXTLOAD)
388 return LD->getAlignment() >= 4 && !LD->isVolatile();
Evan Cheng8b765e92008-05-13 00:54:02 +0000389 return false;
390}]>;
391
Dan Gohman2a174122008-10-15 06:50:19 +0000392def nvloadi32 : PatFrag<(ops node:$ptr), (i32 (unindexedload node:$ptr)), [{
Evan Cheng1e5e5452008-09-29 17:26:18 +0000393 LoadSDNode *LD = cast<LoadSDNode>(N);
Chris Lattner12208612009-04-10 00:16:23 +0000394 if (const Value *Src = LD->getSrcValue())
395 if (const PointerType *PT = dyn_cast<PointerType>(Src->getType()))
Mon P Wangdc97d5a2009-04-27 07:22:10 +0000396 if (PT->getAddressSpace() > 255)
Chris Lattner12208612009-04-10 00:16:23 +0000397 return false;
Evan Cheng1e5e5452008-09-29 17:26:18 +0000398 if (LD->isVolatile())
399 return false;
Evan Cheng1e5e5452008-09-29 17:26:18 +0000400 ISD::LoadExtType ExtType = LD->getExtensionType();
401 if (ExtType == ISD::NON_EXTLOAD)
402 return true;
403 if (ExtType == ISD::EXTLOAD)
404 return LD->getAlignment() >= 4;
405 return false;
406}]>;
407
sampo9cc09a32009-01-26 01:24:32 +0000408def gsload : PatFrag<(ops node:$ptr), (load node:$ptr), [{
Chris Lattner12208612009-04-10 00:16:23 +0000409 if (const Value *Src = cast<LoadSDNode>(N)->getSrcValue())
410 if (const PointerType *PT = dyn_cast<PointerType>(Src->getType()))
411 return PT->getAddressSpace() == 256;
sampo9cc09a32009-01-26 01:24:32 +0000412 return false;
413}]>;
414
Chris Lattnera7c2d8a2009-05-05 18:52:19 +0000415def fsload : PatFrag<(ops node:$ptr), (load node:$ptr), [{
416 if (const Value *Src = cast<LoadSDNode>(N)->getSrcValue())
417 if (const PointerType *PT = dyn_cast<PointerType>(Src->getType()))
418 return PT->getAddressSpace() == 257;
419 return false;
420}]>;
421
Chris Lattner12208612009-04-10 00:16:23 +0000422def loadi8 : PatFrag<(ops node:$ptr), (i8 (load node:$ptr)), [{
423 if (const Value *Src = cast<LoadSDNode>(N)->getSrcValue())
424 if (const PointerType *PT = dyn_cast<PointerType>(Src->getType()))
Mon P Wangdc97d5a2009-04-27 07:22:10 +0000425 if (PT->getAddressSpace() > 255)
Chris Lattner12208612009-04-10 00:16:23 +0000426 return false;
427 return true;
428}]>;
429def loadi64 : PatFrag<(ops node:$ptr), (i64 (load node:$ptr)), [{
430 if (const Value *Src = cast<LoadSDNode>(N)->getSrcValue())
431 if (const PointerType *PT = dyn_cast<PointerType>(Src->getType()))
Mon P Wangdc97d5a2009-04-27 07:22:10 +0000432 if (PT->getAddressSpace() > 255)
Chris Lattner12208612009-04-10 00:16:23 +0000433 return false;
434 return true;
435}]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000436
Chris Lattner12208612009-04-10 00:16:23 +0000437def loadf32 : PatFrag<(ops node:$ptr), (f32 (load node:$ptr)), [{
438 if (const Value *Src = cast<LoadSDNode>(N)->getSrcValue())
439 if (const PointerType *PT = dyn_cast<PointerType>(Src->getType()))
Mon P Wangdc97d5a2009-04-27 07:22:10 +0000440 if (PT->getAddressSpace() > 255)
Chris Lattner12208612009-04-10 00:16:23 +0000441 return false;
442 return true;
443}]>;
444def loadf64 : PatFrag<(ops node:$ptr), (f64 (load node:$ptr)), [{
445 if (const Value *Src = cast<LoadSDNode>(N)->getSrcValue())
446 if (const PointerType *PT = dyn_cast<PointerType>(Src->getType()))
Mon P Wangdc97d5a2009-04-27 07:22:10 +0000447 if (PT->getAddressSpace() > 255)
Chris Lattner12208612009-04-10 00:16:23 +0000448 return false;
449 return true;
450}]>;
451def loadf80 : PatFrag<(ops node:$ptr), (f80 (load node:$ptr)), [{
452 if (const Value *Src = cast<LoadSDNode>(N)->getSrcValue())
453 if (const PointerType *PT = dyn_cast<PointerType>(Src->getType()))
Mon P Wangdc97d5a2009-04-27 07:22:10 +0000454 if (PT->getAddressSpace() > 255)
Chris Lattner12208612009-04-10 00:16:23 +0000455 return false;
456 return true;
457}]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000458
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000459def sextloadi16i8 : PatFrag<(ops node:$ptr), (i16 (sextloadi8 node:$ptr))>;
460def sextloadi32i8 : PatFrag<(ops node:$ptr), (i32 (sextloadi8 node:$ptr))>;
461def sextloadi32i16 : PatFrag<(ops node:$ptr), (i32 (sextloadi16 node:$ptr))>;
462
463def zextloadi8i1 : PatFrag<(ops node:$ptr), (i8 (zextloadi1 node:$ptr))>;
464def zextloadi16i1 : PatFrag<(ops node:$ptr), (i16 (zextloadi1 node:$ptr))>;
465def zextloadi32i1 : PatFrag<(ops node:$ptr), (i32 (zextloadi1 node:$ptr))>;
466def zextloadi16i8 : PatFrag<(ops node:$ptr), (i16 (zextloadi8 node:$ptr))>;
467def zextloadi32i8 : PatFrag<(ops node:$ptr), (i32 (zextloadi8 node:$ptr))>;
468def zextloadi32i16 : PatFrag<(ops node:$ptr), (i32 (zextloadi16 node:$ptr))>;
469
470def extloadi8i1 : PatFrag<(ops node:$ptr), (i8 (extloadi1 node:$ptr))>;
471def extloadi16i1 : PatFrag<(ops node:$ptr), (i16 (extloadi1 node:$ptr))>;
472def extloadi32i1 : PatFrag<(ops node:$ptr), (i32 (extloadi1 node:$ptr))>;
473def extloadi16i8 : PatFrag<(ops node:$ptr), (i16 (extloadi8 node:$ptr))>;
474def extloadi32i8 : PatFrag<(ops node:$ptr), (i32 (extloadi8 node:$ptr))>;
475def extloadi32i16 : PatFrag<(ops node:$ptr), (i32 (extloadi16 node:$ptr))>;
476
Chris Lattner21da6382008-02-19 17:37:35 +0000477
478// An 'and' node with a single use.
479def and_su : PatFrag<(ops node:$lhs, node:$rhs), (and node:$lhs, node:$rhs), [{
Evan Cheng9123cfa2008-03-04 00:40:35 +0000480 return N->hasOneUse();
Chris Lattner21da6382008-02-19 17:37:35 +0000481}]>;
Dan Gohman744d4622009-04-13 16:09:41 +0000482// An 'srl' node with a single use.
483def srl_su : PatFrag<(ops node:$lhs, node:$rhs), (srl node:$lhs, node:$rhs), [{
484 return N->hasOneUse();
485}]>;
486// An 'trunc' node with a single use.
487def trunc_su : PatFrag<(ops node:$src), (trunc node:$src), [{
488 return N->hasOneUse();
489}]>;
Chris Lattner21da6382008-02-19 17:37:35 +0000490
Dan Gohman921581d2008-10-17 01:23:35 +0000491// 'shld' and 'shrd' instruction patterns. Note that even though these have
492// the srl and shl in their patterns, the C++ code must still check for them,
493// because predicates are tested before children nodes are explored.
494
495def shrd : PatFrag<(ops node:$src1, node:$amt1, node:$src2, node:$amt2),
496 (or (srl node:$src1, node:$amt1),
497 (shl node:$src2, node:$amt2)), [{
498 assert(N->getOpcode() == ISD::OR);
499 return N->getOperand(0).getOpcode() == ISD::SRL &&
500 N->getOperand(1).getOpcode() == ISD::SHL &&
501 isa<ConstantSDNode>(N->getOperand(0).getOperand(1)) &&
502 isa<ConstantSDNode>(N->getOperand(1).getOperand(1)) &&
503 N->getOperand(0).getConstantOperandVal(1) ==
504 N->getValueSizeInBits(0) - N->getOperand(1).getConstantOperandVal(1);
505}]>;
506
507def shld : PatFrag<(ops node:$src1, node:$amt1, node:$src2, node:$amt2),
508 (or (shl node:$src1, node:$amt1),
509 (srl node:$src2, node:$amt2)), [{
510 assert(N->getOpcode() == ISD::OR);
511 return N->getOperand(0).getOpcode() == ISD::SHL &&
512 N->getOperand(1).getOpcode() == ISD::SRL &&
513 isa<ConstantSDNode>(N->getOperand(0).getOperand(1)) &&
514 isa<ConstantSDNode>(N->getOperand(1).getOperand(1)) &&
515 N->getOperand(0).getConstantOperandVal(1) ==
516 N->getValueSizeInBits(0) - N->getOperand(1).getConstantOperandVal(1);
517}]>;
518
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000519//===----------------------------------------------------------------------===//
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000520// Instruction list...
521//
522
523// ADJCALLSTACKDOWN/UP implicitly use/def ESP because they may be expanded into
524// a stack adjustment and the codegen must know that they may modify the stack
525// pointer before prolog-epilog rewriting occurs.
Chris Lattnerb56cc342008-03-11 03:23:40 +0000526// Pessimistically assume ADJCALLSTACKDOWN / ADJCALLSTACKUP will become
527// sub / add which can clobber EFLAGS.
Evan Cheng037364a2007-09-28 01:19:48 +0000528let Defs = [ESP, EFLAGS], Uses = [ESP] in {
Dan Gohman01c9f772008-10-01 18:28:06 +0000529def ADJCALLSTACKDOWN32 : I<0, Pseudo, (outs), (ins i32imm:$amt),
530 "#ADJCALLSTACKDOWN",
Chris Lattnerfe5d4022008-10-11 22:08:30 +0000531 [(X86callseq_start timm:$amt)]>,
Dan Gohman01c9f772008-10-01 18:28:06 +0000532 Requires<[In32BitMode]>;
533def ADJCALLSTACKUP32 : I<0, Pseudo, (outs), (ins i32imm:$amt1, i32imm:$amt2),
534 "#ADJCALLSTACKUP",
Chris Lattnerfe5d4022008-10-11 22:08:30 +0000535 [(X86callseq_end timm:$amt1, timm:$amt2)]>,
Dan Gohman01c9f772008-10-01 18:28:06 +0000536 Requires<[In32BitMode]>;
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000537}
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000538
Dan Gohman34228bf2009-08-15 01:38:56 +0000539// x86-64 va_start lowering magic.
Dan Gohman30afe012009-10-29 18:10:34 +0000540let usesCustomInserter = 1 in
Dan Gohman34228bf2009-08-15 01:38:56 +0000541def VASTART_SAVE_XMM_REGS : I<0, Pseudo,
542 (outs),
543 (ins GR8:$al,
544 i64imm:$regsavefi, i64imm:$offset,
545 variable_ops),
546 "#VASTART_SAVE_XMM_REGS $al, $regsavefi, $offset",
547 [(X86vastart_save_xmm_regs GR8:$al,
548 imm:$regsavefi,
549 imm:$offset)]>;
550
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000551// Nop
Sean Callananf94a0542009-07-23 23:39:34 +0000552let neverHasSideEffects = 1 in {
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000553 def NOOP : I<0x90, RawFrm, (outs), (ins), "nop", []>;
Sean Callanan2c48df22009-12-18 00:01:26 +0000554 def NOOPW : I<0x1f, MRM0m, (outs), (ins i16mem:$zero),
555 "nop{w}\t$zero", []>, TB, OpSize;
Sean Callananf94a0542009-07-23 23:39:34 +0000556 def NOOPL : I<0x1f, MRM0m, (outs), (ins i32mem:$zero),
Sean Callanan2c48df22009-12-18 00:01:26 +0000557 "nop{l}\t$zero", []>, TB;
Sean Callananf94a0542009-07-23 23:39:34 +0000558}
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000559
Sean Callanan9b195f82009-08-11 01:09:06 +0000560// Trap
Dan Gohman8112b942009-11-11 18:07:16 +0000561def INT3 : I<0xcc, RawFrm, (outs), (ins), "int\t3", []>;
Sean Callanan9b195f82009-08-11 01:09:06 +0000562def INT : I<0xcd, RawFrm, (outs), (ins i8imm:$trap), "int\t$trap", []>;
Sean Callanan2c48df22009-12-18 00:01:26 +0000563def IRET16 : I<0xcf, RawFrm, (outs), (ins), "iret{w}", []>, OpSize;
564def IRET32 : I<0xcf, RawFrm, (outs), (ins), "iret{l}", []>;
Sean Callanan9b195f82009-08-11 01:09:06 +0000565
Chris Lattner2aa10da2009-09-20 07:32:00 +0000566// PIC base construction. This expands to code that looks like this:
567// call $next_inst
568// popl %destreg"
Dan Gohman9499cfe2008-10-01 04:14:30 +0000569let neverHasSideEffects = 1, isNotDuplicable = 1, Uses = [ESP] in
Chris Lattnera7e959d2009-09-20 07:28:26 +0000570 def MOVPC32r : Ii32<0xE8, Pseudo, (outs GR32:$reg), (ins i32imm:$label),
Chris Lattner2aa10da2009-09-20 07:32:00 +0000571 "", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000572
573//===----------------------------------------------------------------------===//
574// Control Flow Instructions...
575//
576
577// Return instructions.
578let isTerminator = 1, isReturn = 1, isBarrier = 1,
Chris Lattnerb56cc342008-03-11 03:23:40 +0000579 hasCtrlDep = 1, FPForm = SpecialFP, FPFormBits = SpecialFP.Value in {
Dan Gohman2c4be2a2008-05-31 02:11:25 +0000580 def RET : I <0xC3, RawFrm, (outs), (ins variable_ops),
Chris Lattnerb56cc342008-03-11 03:23:40 +0000581 "ret",
Dan Gohman2c4be2a2008-05-31 02:11:25 +0000582 [(X86retflag 0)]>;
Chris Lattnerb56cc342008-03-11 03:23:40 +0000583 def RETI : Ii16<0xC2, RawFrm, (outs), (ins i16imm:$amt, variable_ops),
584 "ret\t$amt",
Dan Gohmane84197b2009-09-03 17:18:51 +0000585 [(X86retflag timm:$amt)]>;
Sean Callanan7a012572009-09-15 23:37:51 +0000586 def LRET : I <0xCB, RawFrm, (outs), (ins),
587 "lret", []>;
588 def LRETI : Ii16<0xCA, RawFrm, (outs), (ins i16imm:$amt),
589 "lret\t$amt", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000590}
591
592// All branches are RawFrm, Void, Branch, and Terminators
Evan Cheng37e7c752007-07-21 00:34:19 +0000593let isBranch = 1, isTerminator = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +0000594 class IBr<bits<8> opcode, dag ins, string asm, list<dag> pattern> :
595 I<opcode, RawFrm, (outs), ins, asm, pattern>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000596
Sean Callananc0608152009-07-22 01:05:20 +0000597let isBranch = 1, isBarrier = 1 in {
Dan Gohman91888f02007-07-31 20:11:57 +0000598 def JMP : IBr<0xE9, (ins brtarget:$dst), "jmp\t$dst", [(br bb:$dst)]>;
Sean Callananc0608152009-07-22 01:05:20 +0000599 def JMP8 : IBr<0xEB, (ins brtarget8:$dst), "jmp\t$dst", []>;
600}
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000601
Owen Andersonf8053082007-11-12 07:39:39 +0000602// Indirect branches
603let isBranch = 1, isTerminator = 1, isBarrier = 1, isIndirectBranch = 1 in {
Dan Gohman91888f02007-07-31 20:11:57 +0000604 def JMP32r : I<0xFF, MRM4r, (outs), (ins GR32:$dst), "jmp{l}\t{*}$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000605 [(brind GR32:$dst)]>;
Dan Gohman91888f02007-07-31 20:11:57 +0000606 def JMP32m : I<0xFF, MRM4m, (outs), (ins i32mem:$dst), "jmp{l}\t{*}$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000607 [(brind (loadi32 addr:$dst))]>;
Sean Callananb7e73392009-09-15 00:35:17 +0000608
609 def FARJMP16i : Iseg16<0xEA, RawFrm, (outs),
610 (ins i16imm:$seg, i16imm:$off),
611 "ljmp{w}\t$seg, $off", []>, OpSize;
612 def FARJMP32i : Iseg32<0xEA, RawFrm, (outs),
613 (ins i16imm:$seg, i32imm:$off),
614 "ljmp{l}\t$seg, $off", []>;
615
616 def FARJMP16m : I<0xFF, MRM5m, (outs), (ins opaque32mem:$dst),
Sean Callanan66fdfa02009-09-03 00:04:47 +0000617 "ljmp{w}\t{*}$dst", []>, OpSize;
Sean Callananb7e73392009-09-15 00:35:17 +0000618 def FARJMP32m : I<0xFF, MRM5m, (outs), (ins opaque48mem:$dst),
Sean Callanan66fdfa02009-09-03 00:04:47 +0000619 "ljmp{l}\t{*}$dst", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000620}
621
622// Conditional branches
Evan Cheng950aac02007-09-25 01:57:46 +0000623let Uses = [EFLAGS] in {
Evan Chengd11052b2009-07-21 06:00:18 +0000624// Short conditional jumps
625def JO8 : IBr<0x70, (ins brtarget8:$dst), "jo\t$dst", []>;
626def JNO8 : IBr<0x71, (ins brtarget8:$dst), "jno\t$dst", []>;
627def JB8 : IBr<0x72, (ins brtarget8:$dst), "jb\t$dst", []>;
628def JAE8 : IBr<0x73, (ins brtarget8:$dst), "jae\t$dst", []>;
629def JE8 : IBr<0x74, (ins brtarget8:$dst), "je\t$dst", []>;
630def JNE8 : IBr<0x75, (ins brtarget8:$dst), "jne\t$dst", []>;
631def JBE8 : IBr<0x76, (ins brtarget8:$dst), "jbe\t$dst", []>;
632def JA8 : IBr<0x77, (ins brtarget8:$dst), "ja\t$dst", []>;
633def JS8 : IBr<0x78, (ins brtarget8:$dst), "js\t$dst", []>;
634def JNS8 : IBr<0x79, (ins brtarget8:$dst), "jns\t$dst", []>;
635def JP8 : IBr<0x7A, (ins brtarget8:$dst), "jp\t$dst", []>;
636def JNP8 : IBr<0x7B, (ins brtarget8:$dst), "jnp\t$dst", []>;
637def JL8 : IBr<0x7C, (ins brtarget8:$dst), "jl\t$dst", []>;
638def JGE8 : IBr<0x7D, (ins brtarget8:$dst), "jge\t$dst", []>;
639def JLE8 : IBr<0x7E, (ins brtarget8:$dst), "jle\t$dst", []>;
640def JG8 : IBr<0x7F, (ins brtarget8:$dst), "jg\t$dst", []>;
641
642def JCXZ8 : IBr<0xE3, (ins brtarget8:$dst), "jcxz\t$dst", []>;
643
Dan Gohman91888f02007-07-31 20:11:57 +0000644def JE : IBr<0x84, (ins brtarget:$dst), "je\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000645 [(X86brcond bb:$dst, X86_COND_E, EFLAGS)]>, TB;
Dan Gohman91888f02007-07-31 20:11:57 +0000646def JNE : IBr<0x85, (ins brtarget:$dst), "jne\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000647 [(X86brcond bb:$dst, X86_COND_NE, EFLAGS)]>, TB;
Dan Gohman91888f02007-07-31 20:11:57 +0000648def JL : IBr<0x8C, (ins brtarget:$dst), "jl\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000649 [(X86brcond bb:$dst, X86_COND_L, EFLAGS)]>, TB;
Dan Gohman91888f02007-07-31 20:11:57 +0000650def JLE : IBr<0x8E, (ins brtarget:$dst), "jle\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000651 [(X86brcond bb:$dst, X86_COND_LE, EFLAGS)]>, TB;
Dan Gohman91888f02007-07-31 20:11:57 +0000652def JG : IBr<0x8F, (ins brtarget:$dst), "jg\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000653 [(X86brcond bb:$dst, X86_COND_G, EFLAGS)]>, TB;
Dan Gohman91888f02007-07-31 20:11:57 +0000654def JGE : IBr<0x8D, (ins brtarget:$dst), "jge\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000655 [(X86brcond bb:$dst, X86_COND_GE, EFLAGS)]>, TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000656
Dan Gohman91888f02007-07-31 20:11:57 +0000657def JB : IBr<0x82, (ins brtarget:$dst), "jb\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000658 [(X86brcond bb:$dst, X86_COND_B, EFLAGS)]>, TB;
Dan Gohman91888f02007-07-31 20:11:57 +0000659def JBE : IBr<0x86, (ins brtarget:$dst), "jbe\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000660 [(X86brcond bb:$dst, X86_COND_BE, EFLAGS)]>, TB;
Dan Gohman91888f02007-07-31 20:11:57 +0000661def JA : IBr<0x87, (ins brtarget:$dst), "ja\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000662 [(X86brcond bb:$dst, X86_COND_A, EFLAGS)]>, TB;
Dan Gohman91888f02007-07-31 20:11:57 +0000663def JAE : IBr<0x83, (ins brtarget:$dst), "jae\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000664 [(X86brcond bb:$dst, X86_COND_AE, EFLAGS)]>, TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000665
Dan Gohman91888f02007-07-31 20:11:57 +0000666def JS : IBr<0x88, (ins brtarget:$dst), "js\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000667 [(X86brcond bb:$dst, X86_COND_S, EFLAGS)]>, TB;
Dan Gohman91888f02007-07-31 20:11:57 +0000668def JNS : IBr<0x89, (ins brtarget:$dst), "jns\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000669 [(X86brcond bb:$dst, X86_COND_NS, EFLAGS)]>, TB;
Dan Gohman91888f02007-07-31 20:11:57 +0000670def JP : IBr<0x8A, (ins brtarget:$dst), "jp\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000671 [(X86brcond bb:$dst, X86_COND_P, EFLAGS)]>, TB;
Dan Gohman91888f02007-07-31 20:11:57 +0000672def JNP : IBr<0x8B, (ins brtarget:$dst), "jnp\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000673 [(X86brcond bb:$dst, X86_COND_NP, EFLAGS)]>, TB;
Dan Gohman91888f02007-07-31 20:11:57 +0000674def JO : IBr<0x80, (ins brtarget:$dst), "jo\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000675 [(X86brcond bb:$dst, X86_COND_O, EFLAGS)]>, TB;
Dan Gohman91888f02007-07-31 20:11:57 +0000676def JNO : IBr<0x81, (ins brtarget:$dst), "jno\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000677 [(X86brcond bb:$dst, X86_COND_NO, EFLAGS)]>, TB;
Evan Cheng950aac02007-09-25 01:57:46 +0000678} // Uses = [EFLAGS]
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000679
Sean Callanan503784b2009-09-16 21:50:07 +0000680// Loop instructions
681
682def LOOP : I<0xE2, RawFrm, (ins brtarget8:$dst), (outs), "loop\t$dst", []>;
683def LOOPE : I<0xE1, RawFrm, (ins brtarget8:$dst), (outs), "loope\t$dst", []>;
684def LOOPNE : I<0xE0, RawFrm, (ins brtarget8:$dst), (outs), "loopne\t$dst", []>;
685
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000686//===----------------------------------------------------------------------===//
687// Call Instructions...
688//
Evan Cheng37e7c752007-07-21 00:34:19 +0000689let isCall = 1 in
Dan Gohman01c9f772008-10-01 18:28:06 +0000690 // All calls clobber the non-callee saved registers. ESP is marked as
691 // a use to prevent stack-pointer assignments that appear immediately
692 // before calls from potentially appearing dead. Uses for argument
693 // registers are added manually.
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000694 let Defs = [EAX, ECX, EDX, FP0, FP1, FP2, FP3, FP4, FP5, FP6, ST0,
695 MM0, MM1, MM2, MM3, MM4, MM5, MM6, MM7,
Evan Cheng2293b252008-10-17 21:02:22 +0000696 XMM0, XMM1, XMM2, XMM3, XMM4, XMM5, XMM6, XMM7,
697 XMM8, XMM9, XMM10, XMM11, XMM12, XMM13, XMM14, XMM15, EFLAGS],
Dan Gohman9499cfe2008-10-01 04:14:30 +0000698 Uses = [ESP] in {
Chris Lattner357a0ca2009-06-20 19:34:09 +0000699 def CALLpcrel32 : Ii32<0xE8, RawFrm,
700 (outs), (ins i32imm_pcrel:$dst,variable_ops),
701 "call\t$dst", []>;
Evan Chengb783fa32007-07-19 01:14:50 +0000702 def CALL32r : I<0xFF, MRM2r, (outs), (ins GR32:$dst, variable_ops),
Dan Gohman91888f02007-07-31 20:11:57 +0000703 "call\t{*}$dst", [(X86call GR32:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000704 def CALL32m : I<0xFF, MRM2m, (outs), (ins i32mem:$dst, variable_ops),
Dan Gohmanea4faba2008-05-29 21:50:34 +0000705 "call\t{*}$dst", [(X86call (loadi32 addr:$dst))]>;
Sean Callanan66fdfa02009-09-03 00:04:47 +0000706
Sean Callananb7e73392009-09-15 00:35:17 +0000707 def FARCALL16i : Iseg16<0x9A, RawFrm, (outs),
708 (ins i16imm:$seg, i16imm:$off),
709 "lcall{w}\t$seg, $off", []>, OpSize;
710 def FARCALL32i : Iseg32<0x9A, RawFrm, (outs),
711 (ins i16imm:$seg, i32imm:$off),
712 "lcall{l}\t$seg, $off", []>;
713
714 def FARCALL16m : I<0xFF, MRM3m, (outs), (ins opaque32mem:$dst),
Sean Callanan66fdfa02009-09-03 00:04:47 +0000715 "lcall{w}\t{*}$dst", []>, OpSize;
Sean Callananb7e73392009-09-15 00:35:17 +0000716 def FARCALL32m : I<0xFF, MRM3m, (outs), (ins opaque48mem:$dst),
Sean Callanan66fdfa02009-09-03 00:04:47 +0000717 "lcall{l}\t{*}$dst", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000718 }
719
Sean Callanan51b7a992009-09-16 02:57:13 +0000720// Constructing a stack frame.
721
722def ENTER : I<0xC8, RawFrm, (outs), (ins i16imm:$len, i8imm:$lvl),
723 "enter\t$len, $lvl", []>;
724
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000725// Tail call stuff.
Arnold Schwaighofere2d6bbb2007-10-11 19:40:01 +0000726
Evan Cheng37e7c752007-07-21 00:34:19 +0000727let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1 in
Sean Callanan2c48df22009-12-18 00:01:26 +0000728def TCRETURNdi : I<0, Pseudo, (outs),
729 (ins i32imm:$dst, i32imm:$offset, variable_ops),
Arnold Schwaighofere2d6bbb2007-10-11 19:40:01 +0000730 "#TC_RETURN $dst $offset",
731 []>;
732
733let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1 in
Sean Callanan2c48df22009-12-18 00:01:26 +0000734def TCRETURNri : I<0, Pseudo, (outs),
735 (ins GR32:$dst, i32imm:$offset, variable_ops),
Arnold Schwaighofere2d6bbb2007-10-11 19:40:01 +0000736 "#TC_RETURN $dst $offset",
737 []>;
738
739let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1 in
Chris Lattner357a0ca2009-06-20 19:34:09 +0000740 def TAILJMPd : IBr<0xE9, (ins i32imm_pcrel:$dst), "jmp\t$dst # TAILCALL",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000741 []>;
Evan Cheng37e7c752007-07-21 00:34:19 +0000742let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1 in
Sean Callanan2c48df22009-12-18 00:01:26 +0000743 def TAILJMPr : I<0xFF, MRM4r, (outs), (ins GR32:$dst),
744 "jmp{l}\t{*}$dst # TAILCALL",
Arnold Schwaighofere2d6bbb2007-10-11 19:40:01 +0000745 []>;
Evan Cheng37e7c752007-07-21 00:34:19 +0000746let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +0000747 def TAILJMPm : I<0xFF, MRM4m, (outs), (ins i32mem:$dst),
Arnold Schwaighofere2d6bbb2007-10-11 19:40:01 +0000748 "jmp\t{*}$dst # TAILCALL", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000749
750//===----------------------------------------------------------------------===//
751// Miscellaneous Instructions...
752//
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000753let Defs = [EBP, ESP], Uses = [EBP, ESP], mayLoad = 1, neverHasSideEffects=1 in
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000754def LEAVE : I<0xC9, RawFrm,
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000755 (outs), (ins), "leave", []>;
756
Sean Callanan2c48df22009-12-18 00:01:26 +0000757def POPCNT16rr : I<0xB8, MRMSrcReg, (outs GR16:$dst), (ins GR16:$src),
758 "popcnt{w}\t{$src, $dst|$dst, $src}", []>, OpSize, XS;
759def POPCNT16rm : I<0xB8, MRMSrcMem, (outs GR16:$dst), (ins i16mem:$src),
760 "popcnt{w}\t{$src, $dst|$dst, $src}", []>, OpSize, XS;
761def POPCNT32rr : I<0xB8, MRMSrcReg, (outs GR32:$dst), (ins GR32:$src),
762 "popcnt{l}\t{$src, $dst|$dst, $src}", []>, XS;
763def POPCNT32rm : I<0xB8, MRMSrcMem, (outs GR32:$dst), (ins i32mem:$src),
764 "popcnt{l}\t{$src, $dst|$dst, $src}", []>, XS;
765
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000766let Defs = [ESP], Uses = [ESP], neverHasSideEffects=1 in {
Sean Callanan9f3c3f52009-09-10 18:29:13 +0000767let mayLoad = 1 in {
768def POP16r : I<0x58, AddRegFrm, (outs GR16:$reg), (ins), "pop{w}\t$reg", []>,
769 OpSize;
770def POP32r : I<0x58, AddRegFrm, (outs GR32:$reg), (ins), "pop{l}\t$reg", []>;
771def POP16rmr: I<0x8F, MRM0r, (outs GR16:$reg), (ins), "pop{w}\t$reg", []>,
772 OpSize;
773def POP16rmm: I<0x8F, MRM0m, (outs i16mem:$dst), (ins), "pop{w}\t$dst", []>,
774 OpSize;
775def POP32rmr: I<0x8F, MRM0r, (outs GR32:$reg), (ins), "pop{l}\t$reg", []>;
776def POP32rmm: I<0x8F, MRM0m, (outs i32mem:$dst), (ins), "pop{l}\t$dst", []>;
777}
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000778
Sean Callanan9f3c3f52009-09-10 18:29:13 +0000779let mayStore = 1 in {
780def PUSH16r : I<0x50, AddRegFrm, (outs), (ins GR16:$reg), "push{w}\t$reg",[]>,
781 OpSize;
Evan Chengd8434332007-09-26 01:29:06 +0000782def PUSH32r : I<0x50, AddRegFrm, (outs), (ins GR32:$reg), "push{l}\t$reg",[]>;
Sean Callanan9f3c3f52009-09-10 18:29:13 +0000783def PUSH16rmr: I<0xFF, MRM6r, (outs), (ins GR16:$reg), "push{w}\t$reg",[]>,
784 OpSize;
785def PUSH16rmm: I<0xFF, MRM6m, (outs), (ins i16mem:$src), "push{w}\t$src",[]>,
786 OpSize;
787def PUSH32rmr: I<0xFF, MRM6r, (outs), (ins GR32:$reg), "push{l}\t$reg",[]>;
788def PUSH32rmm: I<0xFF, MRM6m, (outs), (ins i32mem:$src), "push{l}\t$src",[]>;
789}
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000790}
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000791
Bill Wendling4c2638c2009-06-15 19:39:04 +0000792let Defs = [ESP], Uses = [ESP], neverHasSideEffects = 1, mayStore = 1 in {
793def PUSH32i8 : Ii8<0x6a, RawFrm, (outs), (ins i8imm:$imm),
Bill Wendling0b0437f2009-06-15 20:59:31 +0000794 "push{l}\t$imm", []>;
Bill Wendling4c2638c2009-06-15 19:39:04 +0000795def PUSH32i16 : Ii16<0x68, RawFrm, (outs), (ins i16imm:$imm),
Bill Wendling0b0437f2009-06-15 20:59:31 +0000796 "push{l}\t$imm", []>;
Bill Wendling4c2638c2009-06-15 19:39:04 +0000797def PUSH32i32 : Ii32<0x68, RawFrm, (outs), (ins i32imm:$imm),
Bill Wendling0b0437f2009-06-15 20:59:31 +0000798 "push{l}\t$imm", []>;
Bill Wendling4c2638c2009-06-15 19:39:04 +0000799}
800
Sean Callanan2c48df22009-12-18 00:01:26 +0000801let Defs = [ESP, EFLAGS], Uses = [ESP], mayLoad = 1, neverHasSideEffects=1 in {
802def POPF : I<0x9D, RawFrm, (outs), (ins), "popf{w}", []>, OpSize;
803def POPFD : I<0x9D, RawFrm, (outs), (ins), "popf{l}", []>;
804}
805let Defs = [ESP], Uses = [ESP, EFLAGS], mayStore = 1, neverHasSideEffects=1 in {
806def PUSHF : I<0x9C, RawFrm, (outs), (ins), "pushf{w}", []>, OpSize;
807def PUSHFD : I<0x9C, RawFrm, (outs), (ins), "pushf{l}", []>;
808}
Evan Chengd8434332007-09-26 01:29:06 +0000809
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000810let isTwoAddress = 1 in // GR32 = bswap GR32
811 def BSWAP32r : I<0xC8, AddRegFrm,
Evan Chengb783fa32007-07-19 01:14:50 +0000812 (outs GR32:$dst), (ins GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000813 "bswap{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000814 [(set GR32:$dst, (bswap GR32:$src))]>, TB;
815
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000816
Evan Cheng48679f42007-12-14 02:13:44 +0000817// Bit scan instructions.
818let Defs = [EFLAGS] in {
Evan Cheng4e33de92007-12-14 18:49:43 +0000819def BSF16rr : I<0xBC, MRMSrcReg, (outs GR16:$dst), (ins GR16:$src),
Dan Gohmancdb54c62007-12-14 15:10:00 +0000820 "bsf{w}\t{$src, $dst|$dst, $src}",
Evan Cheng7cfbfe32007-12-14 08:30:15 +0000821 [(set GR16:$dst, (X86bsf GR16:$src)), (implicit EFLAGS)]>, TB;
Evan Cheng48679f42007-12-14 02:13:44 +0000822def BSF16rm : I<0xBC, MRMSrcMem, (outs GR16:$dst), (ins i16mem:$src),
Dan Gohmancdb54c62007-12-14 15:10:00 +0000823 "bsf{w}\t{$src, $dst|$dst, $src}",
Evan Cheng7cfbfe32007-12-14 08:30:15 +0000824 [(set GR16:$dst, (X86bsf (loadi16 addr:$src))),
825 (implicit EFLAGS)]>, TB;
Evan Cheng4e33de92007-12-14 18:49:43 +0000826def BSF32rr : I<0xBC, MRMSrcReg, (outs GR32:$dst), (ins GR32:$src),
Dan Gohmancdb54c62007-12-14 15:10:00 +0000827 "bsf{l}\t{$src, $dst|$dst, $src}",
Evan Cheng7cfbfe32007-12-14 08:30:15 +0000828 [(set GR32:$dst, (X86bsf GR32:$src)), (implicit EFLAGS)]>, TB;
Evan Cheng48679f42007-12-14 02:13:44 +0000829def BSF32rm : I<0xBC, MRMSrcMem, (outs GR32:$dst), (ins i32mem:$src),
Dan Gohmancdb54c62007-12-14 15:10:00 +0000830 "bsf{l}\t{$src, $dst|$dst, $src}",
Evan Cheng7cfbfe32007-12-14 08:30:15 +0000831 [(set GR32:$dst, (X86bsf (loadi32 addr:$src))),
832 (implicit EFLAGS)]>, TB;
Evan Cheng48679f42007-12-14 02:13:44 +0000833
Evan Cheng4e33de92007-12-14 18:49:43 +0000834def BSR16rr : I<0xBD, MRMSrcReg, (outs GR16:$dst), (ins GR16:$src),
Dan Gohmancdb54c62007-12-14 15:10:00 +0000835 "bsr{w}\t{$src, $dst|$dst, $src}",
Evan Cheng7cfbfe32007-12-14 08:30:15 +0000836 [(set GR16:$dst, (X86bsr GR16:$src)), (implicit EFLAGS)]>, TB;
Evan Cheng48679f42007-12-14 02:13:44 +0000837def BSR16rm : I<0xBD, MRMSrcMem, (outs GR16:$dst), (ins i16mem:$src),
Dan Gohmancdb54c62007-12-14 15:10:00 +0000838 "bsr{w}\t{$src, $dst|$dst, $src}",
Evan Cheng7cfbfe32007-12-14 08:30:15 +0000839 [(set GR16:$dst, (X86bsr (loadi16 addr:$src))),
840 (implicit EFLAGS)]>, TB;
Evan Cheng4e33de92007-12-14 18:49:43 +0000841def BSR32rr : I<0xBD, MRMSrcReg, (outs GR32:$dst), (ins GR32:$src),
Dan Gohmancdb54c62007-12-14 15:10:00 +0000842 "bsr{l}\t{$src, $dst|$dst, $src}",
Evan Cheng7cfbfe32007-12-14 08:30:15 +0000843 [(set GR32:$dst, (X86bsr GR32:$src)), (implicit EFLAGS)]>, TB;
Evan Cheng48679f42007-12-14 02:13:44 +0000844def BSR32rm : I<0xBD, MRMSrcMem, (outs GR32:$dst), (ins i32mem:$src),
Dan Gohmancdb54c62007-12-14 15:10:00 +0000845 "bsr{l}\t{$src, $dst|$dst, $src}",
Evan Cheng7cfbfe32007-12-14 08:30:15 +0000846 [(set GR32:$dst, (X86bsr (loadi32 addr:$src))),
847 (implicit EFLAGS)]>, TB;
Evan Cheng48679f42007-12-14 02:13:44 +0000848} // Defs = [EFLAGS]
849
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000850let neverHasSideEffects = 1 in
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000851def LEA16r : I<0x8D, MRMSrcMem,
Evan Chengca348202009-12-12 18:51:56 +0000852 (outs GR16:$dst), (ins lea32mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000853 "lea{w}\t{$src|$dst}, {$dst|$src}", []>, OpSize;
Evan Cheng1ea8e6b2008-03-27 01:41:09 +0000854let isReMaterializable = 1 in
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000855def LEA32r : I<0x8D, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +0000856 (outs GR32:$dst), (ins lea32mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000857 "lea{l}\t{$src|$dst}, {$dst|$src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000858 [(set GR32:$dst, lea32addr:$src)]>, Requires<[In32BitMode]>;
859
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000860let Defs = [ECX,EDI,ESI], Uses = [ECX,EDI,ESI] in {
Evan Chengb783fa32007-07-19 01:14:50 +0000861def REP_MOVSB : I<0xA4, RawFrm, (outs), (ins), "{rep;movsb|rep movsb}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000862 [(X86rep_movs i8)]>, REP;
Evan Chengb783fa32007-07-19 01:14:50 +0000863def REP_MOVSW : I<0xA5, RawFrm, (outs), (ins), "{rep;movsw|rep movsw}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000864 [(X86rep_movs i16)]>, REP, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +0000865def REP_MOVSD : I<0xA5, RawFrm, (outs), (ins), "{rep;movsl|rep movsd}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000866 [(X86rep_movs i32)]>, REP;
867}
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000868
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000869let Defs = [ECX,EDI], Uses = [AL,ECX,EDI] in
Evan Chengb783fa32007-07-19 01:14:50 +0000870def REP_STOSB : I<0xAA, RawFrm, (outs), (ins), "{rep;stosb|rep stosb}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000871 [(X86rep_stos i8)]>, REP;
872let Defs = [ECX,EDI], Uses = [AX,ECX,EDI] in
Evan Chengb783fa32007-07-19 01:14:50 +0000873def REP_STOSW : I<0xAB, RawFrm, (outs), (ins), "{rep;stosw|rep stosw}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000874 [(X86rep_stos i16)]>, REP, OpSize;
875let Defs = [ECX,EDI], Uses = [EAX,ECX,EDI] in
Evan Chengb783fa32007-07-19 01:14:50 +0000876def REP_STOSD : I<0xAB, RawFrm, (outs), (ins), "{rep;stosl|rep stosd}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000877 [(X86rep_stos i32)]>, REP;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000878
Sean Callanan481f06d2009-09-12 00:37:19 +0000879def SCAS8 : I<0xAE, RawFrm, (outs), (ins), "scas{b}", []>;
880def SCAS16 : I<0xAF, RawFrm, (outs), (ins), "scas{w}", []>, OpSize;
881def SCAS32 : I<0xAF, RawFrm, (outs), (ins), "scas{l}", []>;
882
Sean Callanan25220d62009-09-12 02:25:20 +0000883def CMPS8 : I<0xA6, RawFrm, (outs), (ins), "cmps{b}", []>;
884def CMPS16 : I<0xA7, RawFrm, (outs), (ins), "cmps{w}", []>, OpSize;
885def CMPS32 : I<0xA7, RawFrm, (outs), (ins), "cmps{l}", []>;
886
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000887let Defs = [RAX, RDX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000888def RDTSC : I<0x31, RawFrm, (outs), (ins), "rdtsc", [(X86rdtsc)]>,
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000889 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000890
Anton Korobeynikov39d40ba2008-01-15 07:02:33 +0000891let isBarrier = 1, hasCtrlDep = 1 in {
Chris Lattner56b941f2008-01-15 21:58:22 +0000892def TRAP : I<0x0B, RawFrm, (outs), (ins), "ud2", [(trap)]>, TB;
Anton Korobeynikov39d40ba2008-01-15 07:02:33 +0000893}
894
Chris Lattnerc96e27c2009-08-11 16:58:39 +0000895def SYSCALL : I<0x05, RawFrm,
896 (outs), (ins), "syscall", []>, TB;
897def SYSRET : I<0x07, RawFrm,
898 (outs), (ins), "sysret", []>, TB;
899def SYSENTER : I<0x34, RawFrm,
900 (outs), (ins), "sysenter", []>, TB;
901def SYSEXIT : I<0x35, RawFrm,
902 (outs), (ins), "sysexit", []>, TB;
903
Sean Callanan2c2313a2009-09-12 02:52:41 +0000904def WAIT : I<0x9B, RawFrm, (outs), (ins), "wait", []>;
Chris Lattnerc96e27c2009-08-11 16:58:39 +0000905
906
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000907//===----------------------------------------------------------------------===//
908// Input/Output Instructions...
909//
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000910let Defs = [AL], Uses = [DX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000911def IN8rr : I<0xEC, RawFrm, (outs), (ins),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000912 "in{b}\t{%dx, %al|%AL, %DX}", []>;
913let Defs = [AX], Uses = [DX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000914def IN16rr : I<0xED, RawFrm, (outs), (ins),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000915 "in{w}\t{%dx, %ax|%AX, %DX}", []>, OpSize;
916let Defs = [EAX], Uses = [DX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000917def IN32rr : I<0xED, RawFrm, (outs), (ins),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000918 "in{l}\t{%dx, %eax|%EAX, %DX}", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000919
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000920let Defs = [AL] in
Evan Chengb783fa32007-07-19 01:14:50 +0000921def IN8ri : Ii8<0xE4, RawFrm, (outs), (ins i16i8imm:$port),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000922 "in{b}\t{$port, %al|%AL, $port}", []>;
923let Defs = [AX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000924def IN16ri : Ii8<0xE5, RawFrm, (outs), (ins i16i8imm:$port),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000925 "in{w}\t{$port, %ax|%AX, $port}", []>, OpSize;
926let Defs = [EAX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000927def IN32ri : Ii8<0xE5, RawFrm, (outs), (ins i16i8imm:$port),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000928 "in{l}\t{$port, %eax|%EAX, $port}", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000929
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000930let Uses = [DX, AL] in
Evan Chengb783fa32007-07-19 01:14:50 +0000931def OUT8rr : I<0xEE, RawFrm, (outs), (ins),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000932 "out{b}\t{%al, %dx|%DX, %AL}", []>;
933let Uses = [DX, AX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000934def OUT16rr : I<0xEF, RawFrm, (outs), (ins),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000935 "out{w}\t{%ax, %dx|%DX, %AX}", []>, OpSize;
936let Uses = [DX, EAX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000937def OUT32rr : I<0xEF, RawFrm, (outs), (ins),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000938 "out{l}\t{%eax, %dx|%DX, %EAX}", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000939
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000940let Uses = [AL] in
Evan Chengb783fa32007-07-19 01:14:50 +0000941def OUT8ir : Ii8<0xE6, RawFrm, (outs), (ins i16i8imm:$port),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000942 "out{b}\t{%al, $port|$port, %AL}", []>;
943let Uses = [AX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000944def OUT16ir : Ii8<0xE7, RawFrm, (outs), (ins i16i8imm:$port),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000945 "out{w}\t{%ax, $port|$port, %AX}", []>, OpSize;
946let Uses = [EAX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000947def OUT32ir : Ii8<0xE7, RawFrm, (outs), (ins i16i8imm:$port),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000948 "out{l}\t{%eax, $port|$port, %EAX}", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000949
Sean Callanan2c48df22009-12-18 00:01:26 +0000950def IN8 : I<0x6C, RawFrm, (outs), (ins),
951 "ins{b}", []>;
952def IN16 : I<0x6D, RawFrm, (outs), (ins),
953 "ins{w}", []>, OpSize;
954def IN32 : I<0x6D, RawFrm, (outs), (ins),
955 "ins{l}", []>;
956
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000957//===----------------------------------------------------------------------===//
958// Move Instructions...
959//
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000960let neverHasSideEffects = 1 in {
Evan Chengb783fa32007-07-19 01:14:50 +0000961def MOV8rr : I<0x88, MRMDestReg, (outs GR8 :$dst), (ins GR8 :$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000962 "mov{b}\t{$src, $dst|$dst, $src}", []>;
Evan Chengb783fa32007-07-19 01:14:50 +0000963def MOV16rr : I<0x89, MRMDestReg, (outs GR16:$dst), (ins GR16:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000964 "mov{w}\t{$src, $dst|$dst, $src}", []>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +0000965def MOV32rr : I<0x89, MRMDestReg, (outs GR32:$dst), (ins GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000966 "mov{l}\t{$src, $dst|$dst, $src}", []>;
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000967}
Evan Cheng6f26e8b2008-06-18 08:13:07 +0000968let isReMaterializable = 1, isAsCheapAsAMove = 1 in {
Evan Chengb783fa32007-07-19 01:14:50 +0000969def MOV8ri : Ii8 <0xB0, AddRegFrm, (outs GR8 :$dst), (ins i8imm :$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000970 "mov{b}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000971 [(set GR8:$dst, imm:$src)]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000972def MOV16ri : Ii16<0xB8, AddRegFrm, (outs GR16:$dst), (ins i16imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000973 "mov{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000974 [(set GR16:$dst, imm:$src)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +0000975def MOV32ri : Ii32<0xB8, AddRegFrm, (outs GR32:$dst), (ins i32imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000976 "mov{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000977 [(set GR32:$dst, imm:$src)]>;
978}
Evan Chengb783fa32007-07-19 01:14:50 +0000979def MOV8mi : Ii8 <0xC6, MRM0m, (outs), (ins i8mem :$dst, i8imm :$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000980 "mov{b}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000981 [(store (i8 imm:$src), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000982def MOV16mi : Ii16<0xC7, MRM0m, (outs), (ins i16mem:$dst, i16imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000983 "mov{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000984 [(store (i16 imm:$src), addr:$dst)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +0000985def MOV32mi : Ii32<0xC7, MRM0m, (outs), (ins i32mem:$dst, i32imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000986 "mov{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000987 [(store (i32 imm:$src), addr:$dst)]>;
988
Sean Callanan2c48df22009-12-18 00:01:26 +0000989def MOV8o8a : Ii8 <0xA0, RawFrm, (outs), (ins offset8:$src),
Sean Callanan70953a52009-09-10 18:33:42 +0000990 "mov{b}\t{$src, %al|%al, $src}", []>;
Sean Callanan2c48df22009-12-18 00:01:26 +0000991def MOV16o16a : Ii16 <0xA1, RawFrm, (outs), (ins offset16:$src),
Sean Callanan70953a52009-09-10 18:33:42 +0000992 "mov{w}\t{$src, %ax|%ax, $src}", []>, OpSize;
Sean Callanan2c48df22009-12-18 00:01:26 +0000993def MOV32o32a : Ii32 <0xA1, RawFrm, (outs), (ins offset32:$src),
Sean Callanan70953a52009-09-10 18:33:42 +0000994 "mov{l}\t{$src, %eax|%eax, $src}", []>;
995
Sean Callanan2c48df22009-12-18 00:01:26 +0000996def MOV8ao8 : Ii8 <0xA2, RawFrm, (outs offset8:$dst), (ins),
Sean Callanan70953a52009-09-10 18:33:42 +0000997 "mov{b}\t{%al, $dst|$dst, %al}", []>;
Sean Callanan2c48df22009-12-18 00:01:26 +0000998def MOV16ao16 : Ii16 <0xA3, RawFrm, (outs offset16:$dst), (ins),
Sean Callanan70953a52009-09-10 18:33:42 +0000999 "mov{w}\t{%ax, $dst|$dst, %ax}", []>, OpSize;
Sean Callanan2c48df22009-12-18 00:01:26 +00001000def MOV32ao32 : Ii32 <0xA3, RawFrm, (outs offset32:$dst), (ins),
Sean Callanan70953a52009-09-10 18:33:42 +00001001 "mov{l}\t{%eax, $dst|$dst, %eax}", []>;
1002
Sean Callananad87a3a2009-09-15 18:47:29 +00001003// Moves to and from segment registers
1004def MOV16rs : I<0x8C, MRMDestReg, (outs GR16:$dst), (ins SEGMENT_REG:$src),
1005 "mov{w}\t{$src, $dst|$dst, $src}", []>;
1006def MOV16ms : I<0x8C, MRMDestMem, (outs i16mem:$dst), (ins SEGMENT_REG:$src),
1007 "mov{w}\t{$src, $dst|$dst, $src}", []>;
1008def MOV16sr : I<0x8E, MRMSrcReg, (outs SEGMENT_REG:$dst), (ins GR16:$src),
1009 "mov{w}\t{$src, $dst|$dst, $src}", []>;
1010def MOV16sm : I<0x8E, MRMSrcMem, (outs SEGMENT_REG:$dst), (ins i16mem:$src),
1011 "mov{w}\t{$src, $dst|$dst, $src}", []>;
1012
Sean Callanan2c48df22009-12-18 00:01:26 +00001013def MOV8rr_REV : I<0x8A, MRMSrcReg, (outs GR8:$dst), (ins GR8:$src),
1014 "mov{b}\t{$src, $dst|$dst, $src}", []>;
1015def MOV16rr_REV : I<0x8B, MRMSrcReg, (outs GR16:$dst), (ins GR16:$src),
1016 "mov{w}\t{$src, $dst|$dst, $src}", []>, OpSize;
1017def MOV32rr_REV : I<0x8B, MRMSrcReg, (outs GR32:$dst), (ins GR32:$src),
1018 "mov{l}\t{$src, $dst|$dst, $src}", []>;
1019
Dan Gohman5574cc72008-12-03 18:15:48 +00001020let canFoldAsLoad = 1, isReMaterializable = 1, mayHaveSideEffects = 1 in {
Evan Chengb783fa32007-07-19 01:14:50 +00001021def MOV8rm : I<0x8A, MRMSrcMem, (outs GR8 :$dst), (ins i8mem :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001022 "mov{b}\t{$src, $dst|$dst, $src}",
Chris Lattner12208612009-04-10 00:16:23 +00001023 [(set GR8:$dst, (loadi8 addr:$src))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001024def MOV16rm : I<0x8B, MRMSrcMem, (outs GR16:$dst), (ins i16mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001025 "mov{w}\t{$src, $dst|$dst, $src}",
Chris Lattner12208612009-04-10 00:16:23 +00001026 [(set GR16:$dst, (loadi16 addr:$src))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001027def MOV32rm : I<0x8B, MRMSrcMem, (outs GR32:$dst), (ins i32mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001028 "mov{l}\t{$src, $dst|$dst, $src}",
Chris Lattner12208612009-04-10 00:16:23 +00001029 [(set GR32:$dst, (loadi32 addr:$src))]>;
Evan Cheng4e84e452007-08-30 05:49:43 +00001030}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001031
Evan Chengb783fa32007-07-19 01:14:50 +00001032def MOV8mr : I<0x88, MRMDestMem, (outs), (ins i8mem :$dst, GR8 :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001033 "mov{b}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001034 [(store GR8:$src, addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001035def MOV16mr : I<0x89, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001036 "mov{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001037 [(store GR16:$src, addr:$dst)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001038def MOV32mr : I<0x89, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001039 "mov{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001040 [(store GR32:$src, addr:$dst)]>;
Dan Gohman744d4622009-04-13 16:09:41 +00001041
Dan Gohman1d8ce9c2009-04-27 16:41:36 +00001042// Versions of MOV8rr, MOV8mr, and MOV8rm that use i8mem_NOREX and GR8_NOREX so
1043// that they can be used for copying and storing h registers, which can't be
1044// encoded when a REX prefix is present.
Dan Gohman2da0db32009-04-15 00:04:23 +00001045let neverHasSideEffects = 1 in
Dan Gohman40ddc362009-04-15 19:48:57 +00001046def MOV8rr_NOREX : I<0x88, MRMDestReg,
1047 (outs GR8_NOREX:$dst), (ins GR8_NOREX:$src),
Dan Gohman2da0db32009-04-15 00:04:23 +00001048 "mov{b}\t{$src, $dst|$dst, $src} # NOREX", []>;
Evan Chengebc49402009-04-30 00:58:57 +00001049let mayStore = 1 in
Dan Gohman2da0db32009-04-15 00:04:23 +00001050def MOV8mr_NOREX : I<0x88, MRMDestMem,
1051 (outs), (ins i8mem_NOREX:$dst, GR8_NOREX:$src),
1052 "mov{b}\t{$src, $dst|$dst, $src} # NOREX", []>;
Evan Chengebc49402009-04-30 00:58:57 +00001053let mayLoad = 1,
1054 canFoldAsLoad = 1, isReMaterializable = 1, mayHaveSideEffects = 1 in
Dan Gohman1d8ce9c2009-04-27 16:41:36 +00001055def MOV8rm_NOREX : I<0x8A, MRMSrcMem,
1056 (outs GR8_NOREX:$dst), (ins i8mem_NOREX:$src),
1057 "mov{b}\t{$src, $dst|$dst, $src} # NOREX", []>;
Dan Gohman744d4622009-04-13 16:09:41 +00001058
Sean Callanan2c48df22009-12-18 00:01:26 +00001059// Moves to and from debug registers
1060def MOV32rd : I<0x21, MRMDestReg, (outs GR32:$dst), (ins DEBUG_REG:$src),
1061 "mov{l}\t{$src, $dst|$dst, $src}", []>, TB;
1062def MOV32dr : I<0x23, MRMSrcReg, (outs DEBUG_REG:$dst), (ins GR32:$src),
1063 "mov{l}\t{$src, $dst|$dst, $src}", []>, TB;
1064
1065// Moves to and from control registers
1066def MOV32rc : I<0x20, MRMDestReg, (outs GR32:$dst), (ins CONTROL_REG_32:$src),
1067 "mov{q}\t{$src, $dst|$dst, $src}", []>, TB;
1068def MOV32cr : I<0x22, MRMSrcReg, (outs CONTROL_REG_32:$dst), (ins GR32:$src),
1069 "mov{q}\t{$src, $dst|$dst, $src}", []>, TB;
1070
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001071//===----------------------------------------------------------------------===//
1072// Fixed-Register Multiplication and Division Instructions...
1073//
1074
1075// Extra precision multiplication
Evan Cheng55687072007-09-14 21:48:26 +00001076let Defs = [AL,AH,EFLAGS], Uses = [AL] in
Dan Gohman91888f02007-07-31 20:11:57 +00001077def MUL8r : I<0xF6, MRM4r, (outs), (ins GR8:$src), "mul{b}\t$src",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001078 // FIXME: Used for 8-bit mul, ignore result upper 8 bits.
1079 // This probably ought to be moved to a def : Pat<> if the
1080 // syntax can be accepted.
Bill Wendlingf5399032008-12-12 21:15:41 +00001081 [(set AL, (mul AL, GR8:$src)),
1082 (implicit EFLAGS)]>; // AL,AH = AL*GR8
1083
Chris Lattnerc7e96e72008-01-11 07:18:17 +00001084let Defs = [AX,DX,EFLAGS], Uses = [AX], neverHasSideEffects = 1 in
Bill Wendlingf5399032008-12-12 21:15:41 +00001085def MUL16r : I<0xF7, MRM4r, (outs), (ins GR16:$src),
1086 "mul{w}\t$src",
1087 []>, OpSize; // AX,DX = AX*GR16
1088
Chris Lattnerc7e96e72008-01-11 07:18:17 +00001089let Defs = [EAX,EDX,EFLAGS], Uses = [EAX], neverHasSideEffects = 1 in
Bill Wendlingf5399032008-12-12 21:15:41 +00001090def MUL32r : I<0xF7, MRM4r, (outs), (ins GR32:$src),
1091 "mul{l}\t$src",
1092 []>; // EAX,EDX = EAX*GR32
1093
Evan Cheng55687072007-09-14 21:48:26 +00001094let Defs = [AL,AH,EFLAGS], Uses = [AL] in
Evan Chengb783fa32007-07-19 01:14:50 +00001095def MUL8m : I<0xF6, MRM4m, (outs), (ins i8mem :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001096 "mul{b}\t$src",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001097 // FIXME: Used for 8-bit mul, ignore result upper 8 bits.
1098 // This probably ought to be moved to a def : Pat<> if the
1099 // syntax can be accepted.
Bill Wendlingf5399032008-12-12 21:15:41 +00001100 [(set AL, (mul AL, (loadi8 addr:$src))),
1101 (implicit EFLAGS)]>; // AL,AH = AL*[mem8]
1102
Chris Lattnerc90ee9c2008-01-10 07:59:24 +00001103let mayLoad = 1, neverHasSideEffects = 1 in {
Evan Cheng55687072007-09-14 21:48:26 +00001104let Defs = [AX,DX,EFLAGS], Uses = [AX] in
Evan Chengb783fa32007-07-19 01:14:50 +00001105def MUL16m : I<0xF7, MRM4m, (outs), (ins i16mem:$src),
Bill Wendlingf5399032008-12-12 21:15:41 +00001106 "mul{w}\t$src",
1107 []>, OpSize; // AX,DX = AX*[mem16]
1108
Evan Cheng55687072007-09-14 21:48:26 +00001109let Defs = [EAX,EDX,EFLAGS], Uses = [EAX] in
Evan Chengb783fa32007-07-19 01:14:50 +00001110def MUL32m : I<0xF7, MRM4m, (outs), (ins i32mem:$src),
Bill Wendlingf5399032008-12-12 21:15:41 +00001111 "mul{l}\t$src",
1112 []>; // EAX,EDX = EAX*[mem32]
Chris Lattnerc90ee9c2008-01-10 07:59:24 +00001113}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001114
Chris Lattnerc90ee9c2008-01-10 07:59:24 +00001115let neverHasSideEffects = 1 in {
Evan Cheng55687072007-09-14 21:48:26 +00001116let Defs = [AL,AH,EFLAGS], Uses = [AL] in
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001117def IMUL8r : I<0xF6, MRM5r, (outs), (ins GR8:$src), "imul{b}\t$src", []>;
1118 // AL,AH = AL*GR8
Evan Cheng55687072007-09-14 21:48:26 +00001119let Defs = [AX,DX,EFLAGS], Uses = [AX] in
Dan Gohman91888f02007-07-31 20:11:57 +00001120def IMUL16r : I<0xF7, MRM5r, (outs), (ins GR16:$src), "imul{w}\t$src", []>,
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001121 OpSize; // AX,DX = AX*GR16
Evan Cheng55687072007-09-14 21:48:26 +00001122let Defs = [EAX,EDX,EFLAGS], Uses = [EAX] in
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001123def IMUL32r : I<0xF7, MRM5r, (outs), (ins GR32:$src), "imul{l}\t$src", []>;
1124 // EAX,EDX = EAX*GR32
Chris Lattnerc90ee9c2008-01-10 07:59:24 +00001125let mayLoad = 1 in {
Evan Cheng55687072007-09-14 21:48:26 +00001126let Defs = [AL,AH,EFLAGS], Uses = [AL] in
Evan Chengb783fa32007-07-19 01:14:50 +00001127def IMUL8m : I<0xF6, MRM5m, (outs), (ins i8mem :$src),
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001128 "imul{b}\t$src", []>; // AL,AH = AL*[mem8]
Evan Cheng55687072007-09-14 21:48:26 +00001129let Defs = [AX,DX,EFLAGS], Uses = [AX] in
Evan Chengb783fa32007-07-19 01:14:50 +00001130def IMUL16m : I<0xF7, MRM5m, (outs), (ins i16mem:$src),
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001131 "imul{w}\t$src", []>, OpSize; // AX,DX = AX*[mem16]
1132let Defs = [EAX,EDX], Uses = [EAX] in
Evan Chengb783fa32007-07-19 01:14:50 +00001133def IMUL32m : I<0xF7, MRM5m, (outs), (ins i32mem:$src),
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001134 "imul{l}\t$src", []>; // EAX,EDX = EAX*[mem32]
Chris Lattnerc90ee9c2008-01-10 07:59:24 +00001135}
Dan Gohmand44572d2008-11-18 21:29:14 +00001136} // neverHasSideEffects
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001137
1138// unsigned division/remainder
Dale Johannesend8fd3562008-10-07 18:54:28 +00001139let Defs = [AL,AH,EFLAGS], Uses = [AX] in
Sean Callanan2c48df22009-12-18 00:01:26 +00001140def DIV8r : I<0xF6, MRM6r, (outs), (ins GR8:$src), // AX/r8 = AL,AH
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001141 "div{b}\t$src", []>;
Evan Cheng55687072007-09-14 21:48:26 +00001142let Defs = [AX,DX,EFLAGS], Uses = [AX,DX] in
Sean Callanan2c48df22009-12-18 00:01:26 +00001143def DIV16r : I<0xF7, MRM6r, (outs), (ins GR16:$src), // DX:AX/r16 = AX,DX
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001144 "div{w}\t$src", []>, OpSize;
Evan Cheng55687072007-09-14 21:48:26 +00001145let Defs = [EAX,EDX,EFLAGS], Uses = [EAX,EDX] in
Sean Callanan2c48df22009-12-18 00:01:26 +00001146def DIV32r : I<0xF7, MRM6r, (outs), (ins GR32:$src), // EDX:EAX/r32 = EAX,EDX
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001147 "div{l}\t$src", []>;
Chris Lattnerc90ee9c2008-01-10 07:59:24 +00001148let mayLoad = 1 in {
Dale Johannesend8fd3562008-10-07 18:54:28 +00001149let Defs = [AL,AH,EFLAGS], Uses = [AX] in
Sean Callanan2c48df22009-12-18 00:01:26 +00001150def DIV8m : I<0xF6, MRM6m, (outs), (ins i8mem:$src), // AX/[mem8] = AL,AH
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001151 "div{b}\t$src", []>;
Evan Cheng55687072007-09-14 21:48:26 +00001152let Defs = [AX,DX,EFLAGS], Uses = [AX,DX] in
Sean Callanan2c48df22009-12-18 00:01:26 +00001153def DIV16m : I<0xF7, MRM6m, (outs), (ins i16mem:$src), // DX:AX/[mem16] = AX,DX
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001154 "div{w}\t$src", []>, OpSize;
Evan Cheng55687072007-09-14 21:48:26 +00001155let Defs = [EAX,EDX,EFLAGS], Uses = [EAX,EDX] in
Sean Callanan2c48df22009-12-18 00:01:26 +00001156 // EDX:EAX/[mem32] = EAX,EDX
1157def DIV32m : I<0xF7, MRM6m, (outs), (ins i32mem:$src),
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001158 "div{l}\t$src", []>;
Chris Lattnerc90ee9c2008-01-10 07:59:24 +00001159}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001160
1161// Signed division/remainder.
Dale Johannesend8fd3562008-10-07 18:54:28 +00001162let Defs = [AL,AH,EFLAGS], Uses = [AX] in
Sean Callanan2c48df22009-12-18 00:01:26 +00001163def IDIV8r : I<0xF6, MRM7r, (outs), (ins GR8:$src), // AX/r8 = AL,AH
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001164 "idiv{b}\t$src", []>;
Evan Cheng55687072007-09-14 21:48:26 +00001165let Defs = [AX,DX,EFLAGS], Uses = [AX,DX] in
Sean Callanan2c48df22009-12-18 00:01:26 +00001166def IDIV16r: I<0xF7, MRM7r, (outs), (ins GR16:$src), // DX:AX/r16 = AX,DX
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001167 "idiv{w}\t$src", []>, OpSize;
Evan Cheng55687072007-09-14 21:48:26 +00001168let Defs = [EAX,EDX,EFLAGS], Uses = [EAX,EDX] in
Sean Callanan2c48df22009-12-18 00:01:26 +00001169def IDIV32r: I<0xF7, MRM7r, (outs), (ins GR32:$src), // EDX:EAX/r32 = EAX,EDX
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001170 "idiv{l}\t$src", []>;
Chris Lattnerc90ee9c2008-01-10 07:59:24 +00001171let mayLoad = 1, mayLoad = 1 in {
Dale Johannesend8fd3562008-10-07 18:54:28 +00001172let Defs = [AL,AH,EFLAGS], Uses = [AX] in
Sean Callanan2c48df22009-12-18 00:01:26 +00001173def IDIV8m : I<0xF6, MRM7m, (outs), (ins i8mem:$src), // AX/[mem8] = AL,AH
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001174 "idiv{b}\t$src", []>;
Evan Cheng55687072007-09-14 21:48:26 +00001175let Defs = [AX,DX,EFLAGS], Uses = [AX,DX] in
Sean Callanan2c48df22009-12-18 00:01:26 +00001176def IDIV16m: I<0xF7, MRM7m, (outs), (ins i16mem:$src), // DX:AX/[mem16] = AX,DX
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001177 "idiv{w}\t$src", []>, OpSize;
Evan Cheng55687072007-09-14 21:48:26 +00001178let Defs = [EAX,EDX,EFLAGS], Uses = [EAX,EDX] in
Sean Callanan2c48df22009-12-18 00:01:26 +00001179def IDIV32m: I<0xF7, MRM7m, (outs), (ins i32mem:$src),
1180 // EDX:EAX/[mem32] = EAX,EDX
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001181 "idiv{l}\t$src", []>;
Chris Lattnerc90ee9c2008-01-10 07:59:24 +00001182}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001183
1184//===----------------------------------------------------------------------===//
Chris Lattnerc90ee9c2008-01-10 07:59:24 +00001185// Two address Instructions.
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001186//
1187let isTwoAddress = 1 in {
1188
1189// Conditional moves
Evan Cheng950aac02007-09-25 01:57:46 +00001190let Uses = [EFLAGS] in {
Dan Gohman29b998f2009-08-27 00:14:12 +00001191
Dan Gohman30afe012009-10-29 18:10:34 +00001192// X86 doesn't have 8-bit conditional moves. Use a customInserter to
Dan Gohman29b998f2009-08-27 00:14:12 +00001193// emit control flow. An alternative to this is to mark i8 SELECT as Promote,
1194// however that requires promoting the operands, and can induce additional
Dan Gohman1596dd22009-08-29 22:19:15 +00001195// i8 register pressure. Note that CMOV_GR8 is conservatively considered to
1196// clobber EFLAGS, because if one of the operands is zero, the expansion
1197// could involve an xor.
Dan Gohman30afe012009-10-29 18:10:34 +00001198let usesCustomInserter = 1, isTwoAddress = 0, Defs = [EFLAGS] in
Dan Gohman29b998f2009-08-27 00:14:12 +00001199def CMOV_GR8 : I<0, Pseudo,
1200 (outs GR8:$dst), (ins GR8:$src1, GR8:$src2, i8imm:$cond),
1201 "#CMOV_GR8 PSEUDO!",
1202 [(set GR8:$dst, (X86cmov GR8:$src1, GR8:$src2,
1203 imm:$cond, EFLAGS))]>;
1204
Dan Gohman90adb6c2009-08-27 18:16:24 +00001205let isCommutable = 1 in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001206def CMOVB16rr : I<0x42, MRMSrcReg, // if <u, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +00001207 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Sean Callanan2c48df22009-12-18 00:01:26 +00001208 "cmovb{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001209 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001210 X86_COND_B, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001211 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001212def CMOVB32rr : I<0x42, MRMSrcReg, // if <u, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +00001213 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Sean Callanan2c48df22009-12-18 00:01:26 +00001214 "cmovb{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001215 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001216 X86_COND_B, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001217 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001218def CMOVAE16rr: I<0x43, MRMSrcReg, // if >=u, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +00001219 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Sean Callanan2c48df22009-12-18 00:01:26 +00001220 "cmovae{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001221 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001222 X86_COND_AE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001223 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001224def CMOVAE32rr: I<0x43, MRMSrcReg, // if >=u, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +00001225 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Sean Callanan2c48df22009-12-18 00:01:26 +00001226 "cmovae{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001227 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001228 X86_COND_AE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001229 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001230def CMOVE16rr : I<0x44, MRMSrcReg, // if ==, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +00001231 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Sean Callanan2c48df22009-12-18 00:01:26 +00001232 "cmove{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001233 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001234 X86_COND_E, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001235 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001236def CMOVE32rr : I<0x44, MRMSrcReg, // if ==, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +00001237 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Sean Callanan2c48df22009-12-18 00:01:26 +00001238 "cmove{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001239 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001240 X86_COND_E, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001241 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001242def CMOVNE16rr: I<0x45, MRMSrcReg, // if !=, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +00001243 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Sean Callanan2c48df22009-12-18 00:01:26 +00001244 "cmovne{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001245 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001246 X86_COND_NE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001247 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001248def CMOVNE32rr: I<0x45, MRMSrcReg, // if !=, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +00001249 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Sean Callanan2c48df22009-12-18 00:01:26 +00001250 "cmovne{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001251 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001252 X86_COND_NE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001253 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001254def CMOVBE16rr: I<0x46, MRMSrcReg, // if <=u, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +00001255 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Sean Callanan2c48df22009-12-18 00:01:26 +00001256 "cmovbe{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001257 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001258 X86_COND_BE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001259 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001260def CMOVBE32rr: I<0x46, MRMSrcReg, // if <=u, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +00001261 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Sean Callanan2c48df22009-12-18 00:01:26 +00001262 "cmovbe{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001263 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001264 X86_COND_BE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001265 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001266def CMOVA16rr : I<0x47, MRMSrcReg, // if >u, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +00001267 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Sean Callanan2c48df22009-12-18 00:01:26 +00001268 "cmova{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001269 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001270 X86_COND_A, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001271 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001272def CMOVA32rr : I<0x47, MRMSrcReg, // if >u, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +00001273 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Sean Callanan2c48df22009-12-18 00:01:26 +00001274 "cmova{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001275 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001276 X86_COND_A, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001277 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001278def CMOVL16rr : I<0x4C, MRMSrcReg, // if <s, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +00001279 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Sean Callanan2c48df22009-12-18 00:01:26 +00001280 "cmovl{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001281 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001282 X86_COND_L, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001283 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001284def CMOVL32rr : I<0x4C, MRMSrcReg, // if <s, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +00001285 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Sean Callanan2c48df22009-12-18 00:01:26 +00001286 "cmovl{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001287 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001288 X86_COND_L, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001289 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001290def CMOVGE16rr: I<0x4D, MRMSrcReg, // if >=s, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +00001291 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Sean Callanan2c48df22009-12-18 00:01:26 +00001292 "cmovge{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001293 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001294 X86_COND_GE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001295 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001296def CMOVGE32rr: I<0x4D, MRMSrcReg, // if >=s, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +00001297 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Sean Callanan2c48df22009-12-18 00:01:26 +00001298 "cmovge{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001299 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001300 X86_COND_GE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001301 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001302def CMOVLE16rr: I<0x4E, MRMSrcReg, // if <=s, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +00001303 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Sean Callanan2c48df22009-12-18 00:01:26 +00001304 "cmovle{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001305 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001306 X86_COND_LE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001307 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001308def CMOVLE32rr: I<0x4E, MRMSrcReg, // if <=s, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +00001309 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Sean Callanan2c48df22009-12-18 00:01:26 +00001310 "cmovle{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001311 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001312 X86_COND_LE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001313 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001314def CMOVG16rr : I<0x4F, MRMSrcReg, // if >s, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +00001315 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Sean Callanan2c48df22009-12-18 00:01:26 +00001316 "cmovg{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001317 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001318 X86_COND_G, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001319 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001320def CMOVG32rr : I<0x4F, MRMSrcReg, // if >s, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +00001321 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Sean Callanan2c48df22009-12-18 00:01:26 +00001322 "cmovg{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001323 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001324 X86_COND_G, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001325 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001326def CMOVS16rr : I<0x48, MRMSrcReg, // if signed, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +00001327 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Sean Callanan2c48df22009-12-18 00:01:26 +00001328 "cmovs{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001329 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001330 X86_COND_S, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001331 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001332def CMOVS32rr : I<0x48, MRMSrcReg, // if signed, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +00001333 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Sean Callanan2c48df22009-12-18 00:01:26 +00001334 "cmovs{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001335 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001336 X86_COND_S, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001337 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001338def CMOVNS16rr: I<0x49, MRMSrcReg, // if !signed, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +00001339 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Sean Callanan2c48df22009-12-18 00:01:26 +00001340 "cmovns{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001341 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001342 X86_COND_NS, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001343 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001344def CMOVNS32rr: I<0x49, MRMSrcReg, // if !signed, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +00001345 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Sean Callanan2c48df22009-12-18 00:01:26 +00001346 "cmovns{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001347 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001348 X86_COND_NS, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001349 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001350def CMOVP16rr : I<0x4A, MRMSrcReg, // if parity, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +00001351 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Sean Callanan2c48df22009-12-18 00:01:26 +00001352 "cmovp{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001353 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001354 X86_COND_P, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001355 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001356def CMOVP32rr : I<0x4A, MRMSrcReg, // if parity, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +00001357 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Sean Callanan2c48df22009-12-18 00:01:26 +00001358 "cmovp{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001359 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001360 X86_COND_P, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001361 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001362def CMOVNP16rr : I<0x4B, MRMSrcReg, // if !parity, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +00001363 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Sean Callanan2c48df22009-12-18 00:01:26 +00001364 "cmovnp{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001365 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001366 X86_COND_NP, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001367 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001368def CMOVNP32rr : I<0x4B, MRMSrcReg, // if !parity, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +00001369 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Sean Callanan2c48df22009-12-18 00:01:26 +00001370 "cmovnp{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001371 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001372 X86_COND_NP, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001373 TB;
Dan Gohman12fd4d72009-01-07 00:35:10 +00001374def CMOVO16rr : I<0x40, MRMSrcReg, // if overflow, GR16 = GR16
1375 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Sean Callanan2c48df22009-12-18 00:01:26 +00001376 "cmovo{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohman12fd4d72009-01-07 00:35:10 +00001377 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
1378 X86_COND_O, EFLAGS))]>,
1379 TB, OpSize;
1380def CMOVO32rr : I<0x40, MRMSrcReg, // if overflow, GR32 = GR32
1381 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Sean Callanan2c48df22009-12-18 00:01:26 +00001382 "cmovo{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohman12fd4d72009-01-07 00:35:10 +00001383 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
1384 X86_COND_O, EFLAGS))]>,
Evan Cheng950aac02007-09-25 01:57:46 +00001385 TB;
Dan Gohman12fd4d72009-01-07 00:35:10 +00001386def CMOVNO16rr : I<0x41, MRMSrcReg, // if !overflow, GR16 = GR16
1387 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Sean Callanan2c48df22009-12-18 00:01:26 +00001388 "cmovno{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohman12fd4d72009-01-07 00:35:10 +00001389 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
1390 X86_COND_NO, EFLAGS))]>,
1391 TB, OpSize;
1392def CMOVNO32rr : I<0x41, MRMSrcReg, // if !overflow, GR32 = GR32
1393 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Sean Callanan2c48df22009-12-18 00:01:26 +00001394 "cmovno{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohman12fd4d72009-01-07 00:35:10 +00001395 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
1396 X86_COND_NO, EFLAGS))]>,
1397 TB;
1398} // isCommutable = 1
Evan Cheng926658c2007-10-05 23:13:21 +00001399
1400def CMOVB16rm : I<0x42, MRMSrcMem, // if <u, GR16 = [mem16]
1401 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
Sean Callanan2c48df22009-12-18 00:01:26 +00001402 "cmovb{w}\t{$src2, $dst|$dst, $src2}",
Evan Cheng926658c2007-10-05 23:13:21 +00001403 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1404 X86_COND_B, EFLAGS))]>,
1405 TB, OpSize;
1406def CMOVB32rm : I<0x42, MRMSrcMem, // if <u, GR32 = [mem32]
1407 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Sean Callanan2c48df22009-12-18 00:01:26 +00001408 "cmovb{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng926658c2007-10-05 23:13:21 +00001409 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1410 X86_COND_B, EFLAGS))]>,
1411 TB;
1412def CMOVAE16rm: I<0x43, MRMSrcMem, // if >=u, GR16 = [mem16]
1413 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
Sean Callanan2c48df22009-12-18 00:01:26 +00001414 "cmovae{w}\t{$src2, $dst|$dst, $src2}",
Evan Cheng926658c2007-10-05 23:13:21 +00001415 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1416 X86_COND_AE, EFLAGS))]>,
1417 TB, OpSize;
1418def CMOVAE32rm: I<0x43, MRMSrcMem, // if >=u, GR32 = [mem32]
1419 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Sean Callanan2c48df22009-12-18 00:01:26 +00001420 "cmovae{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng926658c2007-10-05 23:13:21 +00001421 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1422 X86_COND_AE, EFLAGS))]>,
1423 TB;
1424def CMOVE16rm : I<0x44, MRMSrcMem, // if ==, GR16 = [mem16]
1425 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
Sean Callanan2c48df22009-12-18 00:01:26 +00001426 "cmove{w}\t{$src2, $dst|$dst, $src2}",
Evan Cheng926658c2007-10-05 23:13:21 +00001427 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1428 X86_COND_E, EFLAGS))]>,
1429 TB, OpSize;
1430def CMOVE32rm : I<0x44, MRMSrcMem, // if ==, GR32 = [mem32]
1431 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Sean Callanan2c48df22009-12-18 00:01:26 +00001432 "cmove{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng926658c2007-10-05 23:13:21 +00001433 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1434 X86_COND_E, EFLAGS))]>,
1435 TB;
1436def CMOVNE16rm: I<0x45, MRMSrcMem, // if !=, GR16 = [mem16]
1437 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
Sean Callanan2c48df22009-12-18 00:01:26 +00001438 "cmovne{w}\t{$src2, $dst|$dst, $src2}",
Evan Cheng926658c2007-10-05 23:13:21 +00001439 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1440 X86_COND_NE, EFLAGS))]>,
1441 TB, OpSize;
1442def CMOVNE32rm: I<0x45, MRMSrcMem, // if !=, GR32 = [mem32]
1443 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Sean Callanan2c48df22009-12-18 00:01:26 +00001444 "cmovne{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng926658c2007-10-05 23:13:21 +00001445 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1446 X86_COND_NE, EFLAGS))]>,
1447 TB;
1448def CMOVBE16rm: I<0x46, MRMSrcMem, // if <=u, GR16 = [mem16]
1449 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
Sean Callanan2c48df22009-12-18 00:01:26 +00001450 "cmovbe{w}\t{$src2, $dst|$dst, $src2}",
Evan Cheng926658c2007-10-05 23:13:21 +00001451 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1452 X86_COND_BE, EFLAGS))]>,
1453 TB, OpSize;
1454def CMOVBE32rm: I<0x46, MRMSrcMem, // if <=u, GR32 = [mem32]
1455 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Sean Callanan2c48df22009-12-18 00:01:26 +00001456 "cmovbe{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng926658c2007-10-05 23:13:21 +00001457 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1458 X86_COND_BE, EFLAGS))]>,
1459 TB;
1460def CMOVA16rm : I<0x47, MRMSrcMem, // if >u, GR16 = [mem16]
1461 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
Sean Callanan2c48df22009-12-18 00:01:26 +00001462 "cmova{w}\t{$src2, $dst|$dst, $src2}",
Evan Cheng926658c2007-10-05 23:13:21 +00001463 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1464 X86_COND_A, EFLAGS))]>,
1465 TB, OpSize;
1466def CMOVA32rm : I<0x47, MRMSrcMem, // if >u, GR32 = [mem32]
1467 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Sean Callanan2c48df22009-12-18 00:01:26 +00001468 "cmova{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng926658c2007-10-05 23:13:21 +00001469 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1470 X86_COND_A, EFLAGS))]>,
1471 TB;
1472def CMOVL16rm : I<0x4C, MRMSrcMem, // if <s, GR16 = [mem16]
1473 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
Sean Callanan2c48df22009-12-18 00:01:26 +00001474 "cmovl{w}\t{$src2, $dst|$dst, $src2}",
Evan Cheng926658c2007-10-05 23:13:21 +00001475 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1476 X86_COND_L, EFLAGS))]>,
1477 TB, OpSize;
1478def CMOVL32rm : I<0x4C, MRMSrcMem, // if <s, GR32 = [mem32]
1479 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Sean Callanan2c48df22009-12-18 00:01:26 +00001480 "cmovl{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng926658c2007-10-05 23:13:21 +00001481 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1482 X86_COND_L, EFLAGS))]>,
1483 TB;
1484def CMOVGE16rm: I<0x4D, MRMSrcMem, // if >=s, GR16 = [mem16]
1485 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
Sean Callanan2c48df22009-12-18 00:01:26 +00001486 "cmovge{w}\t{$src2, $dst|$dst, $src2}",
Evan Cheng926658c2007-10-05 23:13:21 +00001487 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1488 X86_COND_GE, EFLAGS))]>,
1489 TB, OpSize;
1490def CMOVGE32rm: I<0x4D, MRMSrcMem, // if >=s, GR32 = [mem32]
1491 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Sean Callanan2c48df22009-12-18 00:01:26 +00001492 "cmovge{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng926658c2007-10-05 23:13:21 +00001493 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1494 X86_COND_GE, EFLAGS))]>,
1495 TB;
1496def CMOVLE16rm: I<0x4E, MRMSrcMem, // if <=s, GR16 = [mem16]
1497 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
Sean Callanan2c48df22009-12-18 00:01:26 +00001498 "cmovle{w}\t{$src2, $dst|$dst, $src2}",
Evan Cheng926658c2007-10-05 23:13:21 +00001499 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1500 X86_COND_LE, EFLAGS))]>,
1501 TB, OpSize;
1502def CMOVLE32rm: I<0x4E, MRMSrcMem, // if <=s, GR32 = [mem32]
1503 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Sean Callanan2c48df22009-12-18 00:01:26 +00001504 "cmovle{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng926658c2007-10-05 23:13:21 +00001505 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1506 X86_COND_LE, EFLAGS))]>,
1507 TB;
1508def CMOVG16rm : I<0x4F, MRMSrcMem, // if >s, GR16 = [mem16]
1509 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
Sean Callanan2c48df22009-12-18 00:01:26 +00001510 "cmovg{w}\t{$src2, $dst|$dst, $src2}",
Evan Cheng926658c2007-10-05 23:13:21 +00001511 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1512 X86_COND_G, EFLAGS))]>,
1513 TB, OpSize;
1514def CMOVG32rm : I<0x4F, MRMSrcMem, // if >s, GR32 = [mem32]
1515 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Sean Callanan2c48df22009-12-18 00:01:26 +00001516 "cmovg{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng926658c2007-10-05 23:13:21 +00001517 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1518 X86_COND_G, EFLAGS))]>,
1519 TB;
1520def CMOVS16rm : I<0x48, MRMSrcMem, // if signed, GR16 = [mem16]
1521 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
Sean Callanan2c48df22009-12-18 00:01:26 +00001522 "cmovs{w}\t{$src2, $dst|$dst, $src2}",
Evan Cheng926658c2007-10-05 23:13:21 +00001523 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1524 X86_COND_S, EFLAGS))]>,
1525 TB, OpSize;
1526def CMOVS32rm : I<0x48, MRMSrcMem, // if signed, GR32 = [mem32]
1527 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Sean Callanan2c48df22009-12-18 00:01:26 +00001528 "cmovs{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng926658c2007-10-05 23:13:21 +00001529 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1530 X86_COND_S, EFLAGS))]>,
1531 TB;
1532def CMOVNS16rm: I<0x49, MRMSrcMem, // if !signed, GR16 = [mem16]
1533 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
Sean Callanan2c48df22009-12-18 00:01:26 +00001534 "cmovns{w}\t{$src2, $dst|$dst, $src2}",
Evan Cheng926658c2007-10-05 23:13:21 +00001535 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1536 X86_COND_NS, EFLAGS))]>,
1537 TB, OpSize;
1538def CMOVNS32rm: I<0x49, MRMSrcMem, // if !signed, GR32 = [mem32]
1539 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Sean Callanan2c48df22009-12-18 00:01:26 +00001540 "cmovns{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng926658c2007-10-05 23:13:21 +00001541 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1542 X86_COND_NS, EFLAGS))]>,
1543 TB;
1544def CMOVP16rm : I<0x4A, MRMSrcMem, // if parity, GR16 = [mem16]
1545 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
Sean Callanan2c48df22009-12-18 00:01:26 +00001546 "cmovp{w}\t{$src2, $dst|$dst, $src2}",
Evan Cheng926658c2007-10-05 23:13:21 +00001547 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1548 X86_COND_P, EFLAGS))]>,
1549 TB, OpSize;
1550def CMOVP32rm : I<0x4A, MRMSrcMem, // if parity, GR32 = [mem32]
1551 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Sean Callanan2c48df22009-12-18 00:01:26 +00001552 "cmovp{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng926658c2007-10-05 23:13:21 +00001553 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1554 X86_COND_P, EFLAGS))]>,
1555 TB;
1556def CMOVNP16rm : I<0x4B, MRMSrcMem, // if !parity, GR16 = [mem16]
1557 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
Sean Callanan2c48df22009-12-18 00:01:26 +00001558 "cmovnp{w}\t{$src2, $dst|$dst, $src2}",
Evan Cheng926658c2007-10-05 23:13:21 +00001559 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1560 X86_COND_NP, EFLAGS))]>,
1561 TB, OpSize;
Dan Gohman12fd4d72009-01-07 00:35:10 +00001562def CMOVNP32rm : I<0x4B, MRMSrcMem, // if !parity, GR32 = [mem32]
1563 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Sean Callanan2c48df22009-12-18 00:01:26 +00001564 "cmovnp{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohman12fd4d72009-01-07 00:35:10 +00001565 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1566 X86_COND_NP, EFLAGS))]>,
1567 TB;
1568def CMOVO16rm : I<0x40, MRMSrcMem, // if overflow, GR16 = [mem16]
1569 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
Sean Callanan2c48df22009-12-18 00:01:26 +00001570 "cmovo{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohman12fd4d72009-01-07 00:35:10 +00001571 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1572 X86_COND_O, EFLAGS))]>,
1573 TB, OpSize;
1574def CMOVO32rm : I<0x40, MRMSrcMem, // if overflow, GR32 = [mem32]
1575 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Sean Callanan2c48df22009-12-18 00:01:26 +00001576 "cmovo{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohman12fd4d72009-01-07 00:35:10 +00001577 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1578 X86_COND_O, EFLAGS))]>,
1579 TB;
1580def CMOVNO16rm : I<0x41, MRMSrcMem, // if !overflow, GR16 = [mem16]
1581 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
Sean Callanan2c48df22009-12-18 00:01:26 +00001582 "cmovno{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohman12fd4d72009-01-07 00:35:10 +00001583 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1584 X86_COND_NO, EFLAGS))]>,
1585 TB, OpSize;
1586def CMOVNO32rm : I<0x41, MRMSrcMem, // if !overflow, GR32 = [mem32]
1587 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Sean Callanan2c48df22009-12-18 00:01:26 +00001588 "cmovno{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohman12fd4d72009-01-07 00:35:10 +00001589 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1590 X86_COND_NO, EFLAGS))]>,
1591 TB;
Evan Cheng950aac02007-09-25 01:57:46 +00001592} // Uses = [EFLAGS]
1593
1594
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001595// unary instructions
1596let CodeSize = 2 in {
Evan Cheng55687072007-09-14 21:48:26 +00001597let Defs = [EFLAGS] in {
Dan Gohman91888f02007-07-31 20:11:57 +00001598def NEG8r : I<0xF6, MRM3r, (outs GR8 :$dst), (ins GR8 :$src), "neg{b}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001599 [(set GR8:$dst, (ineg GR8:$src)),
1600 (implicit EFLAGS)]>;
Dan Gohman91888f02007-07-31 20:11:57 +00001601def NEG16r : I<0xF7, MRM3r, (outs GR16:$dst), (ins GR16:$src), "neg{w}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001602 [(set GR16:$dst, (ineg GR16:$src)),
1603 (implicit EFLAGS)]>, OpSize;
Dan Gohman91888f02007-07-31 20:11:57 +00001604def NEG32r : I<0xF7, MRM3r, (outs GR32:$dst), (ins GR32:$src), "neg{l}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001605 [(set GR32:$dst, (ineg GR32:$src)),
1606 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001607let isTwoAddress = 0 in {
Dan Gohman91888f02007-07-31 20:11:57 +00001608 def NEG8m : I<0xF6, MRM3m, (outs), (ins i8mem :$dst), "neg{b}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001609 [(store (ineg (loadi8 addr:$dst)), addr:$dst),
1610 (implicit EFLAGS)]>;
Dan Gohman91888f02007-07-31 20:11:57 +00001611 def NEG16m : I<0xF7, MRM3m, (outs), (ins i16mem:$dst), "neg{w}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001612 [(store (ineg (loadi16 addr:$dst)), addr:$dst),
1613 (implicit EFLAGS)]>, OpSize;
Dan Gohman91888f02007-07-31 20:11:57 +00001614 def NEG32m : I<0xF7, MRM3m, (outs), (ins i32mem:$dst), "neg{l}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001615 [(store (ineg (loadi32 addr:$dst)), addr:$dst),
1616 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001617}
Evan Cheng55687072007-09-14 21:48:26 +00001618} // Defs = [EFLAGS]
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001619
Evan Chengc6cee682009-01-21 02:09:05 +00001620// Match xor -1 to not. Favors these over a move imm + xor to save code size.
1621let AddedComplexity = 15 in {
Dan Gohman91888f02007-07-31 20:11:57 +00001622def NOT8r : I<0xF6, MRM2r, (outs GR8 :$dst), (ins GR8 :$src), "not{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001623 [(set GR8:$dst, (not GR8:$src))]>;
Dan Gohman91888f02007-07-31 20:11:57 +00001624def NOT16r : I<0xF7, MRM2r, (outs GR16:$dst), (ins GR16:$src), "not{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001625 [(set GR16:$dst, (not GR16:$src))]>, OpSize;
Dan Gohman91888f02007-07-31 20:11:57 +00001626def NOT32r : I<0xF7, MRM2r, (outs GR32:$dst), (ins GR32:$src), "not{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001627 [(set GR32:$dst, (not GR32:$src))]>;
Evan Chengc6cee682009-01-21 02:09:05 +00001628}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001629let isTwoAddress = 0 in {
Dan Gohman91888f02007-07-31 20:11:57 +00001630 def NOT8m : I<0xF6, MRM2m, (outs), (ins i8mem :$dst), "not{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001631 [(store (not (loadi8 addr:$dst)), addr:$dst)]>;
Dan Gohman91888f02007-07-31 20:11:57 +00001632 def NOT16m : I<0xF7, MRM2m, (outs), (ins i16mem:$dst), "not{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001633 [(store (not (loadi16 addr:$dst)), addr:$dst)]>, OpSize;
Dan Gohman91888f02007-07-31 20:11:57 +00001634 def NOT32m : I<0xF7, MRM2m, (outs), (ins i32mem:$dst), "not{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001635 [(store (not (loadi32 addr:$dst)), addr:$dst)]>;
1636}
1637} // CodeSize
1638
1639// TODO: inc/dec is slow for P4, but fast for Pentium-M.
Evan Cheng55687072007-09-14 21:48:26 +00001640let Defs = [EFLAGS] in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001641let CodeSize = 2 in
Dan Gohman91888f02007-07-31 20:11:57 +00001642def INC8r : I<0xFE, MRM0r, (outs GR8 :$dst), (ins GR8 :$src), "inc{b}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001643 [(set GR8:$dst, (add GR8:$src, 1)),
1644 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001645let isConvertibleToThreeAddress = 1, CodeSize = 1 in { // Can xform into LEA.
Sean Callanan2c48df22009-12-18 00:01:26 +00001646def INC16r : I<0x40, AddRegFrm, (outs GR16:$dst), (ins GR16:$src),
1647 "inc{w}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001648 [(set GR16:$dst, (add GR16:$src, 1)),
1649 (implicit EFLAGS)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001650 OpSize, Requires<[In32BitMode]>;
Sean Callanan2c48df22009-12-18 00:01:26 +00001651def INC32r : I<0x40, AddRegFrm, (outs GR32:$dst), (ins GR32:$src),
1652 "inc{l}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001653 [(set GR32:$dst, (add GR32:$src, 1)),
1654 (implicit EFLAGS)]>, Requires<[In32BitMode]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001655}
1656let isTwoAddress = 0, CodeSize = 2 in {
Dan Gohman91888f02007-07-31 20:11:57 +00001657 def INC8m : I<0xFE, MRM0m, (outs), (ins i8mem :$dst), "inc{b}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001658 [(store (add (loadi8 addr:$dst), 1), addr:$dst),
1659 (implicit EFLAGS)]>;
Dan Gohman91888f02007-07-31 20:11:57 +00001660 def INC16m : I<0xFF, MRM0m, (outs), (ins i16mem:$dst), "inc{w}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001661 [(store (add (loadi16 addr:$dst), 1), addr:$dst),
1662 (implicit EFLAGS)]>,
Evan Cheng4a7e72f2007-10-19 21:23:22 +00001663 OpSize, Requires<[In32BitMode]>;
Dan Gohman91888f02007-07-31 20:11:57 +00001664 def INC32m : I<0xFF, MRM0m, (outs), (ins i32mem:$dst), "inc{l}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001665 [(store (add (loadi32 addr:$dst), 1), addr:$dst),
1666 (implicit EFLAGS)]>,
Evan Cheng4a7e72f2007-10-19 21:23:22 +00001667 Requires<[In32BitMode]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001668}
1669
1670let CodeSize = 2 in
Dan Gohman91888f02007-07-31 20:11:57 +00001671def DEC8r : I<0xFE, MRM1r, (outs GR8 :$dst), (ins GR8 :$src), "dec{b}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001672 [(set GR8:$dst, (add GR8:$src, -1)),
1673 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001674let isConvertibleToThreeAddress = 1, CodeSize = 1 in { // Can xform into LEA.
Sean Callanan2c48df22009-12-18 00:01:26 +00001675def DEC16r : I<0x48, AddRegFrm, (outs GR16:$dst), (ins GR16:$src),
1676 "dec{w}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001677 [(set GR16:$dst, (add GR16:$src, -1)),
1678 (implicit EFLAGS)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001679 OpSize, Requires<[In32BitMode]>;
Sean Callanan2c48df22009-12-18 00:01:26 +00001680def DEC32r : I<0x48, AddRegFrm, (outs GR32:$dst), (ins GR32:$src),
1681 "dec{l}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001682 [(set GR32:$dst, (add GR32:$src, -1)),
1683 (implicit EFLAGS)]>, Requires<[In32BitMode]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001684}
1685
1686let isTwoAddress = 0, CodeSize = 2 in {
Dan Gohman91888f02007-07-31 20:11:57 +00001687 def DEC8m : I<0xFE, MRM1m, (outs), (ins i8mem :$dst), "dec{b}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001688 [(store (add (loadi8 addr:$dst), -1), addr:$dst),
1689 (implicit EFLAGS)]>;
Dan Gohman91888f02007-07-31 20:11:57 +00001690 def DEC16m : I<0xFF, MRM1m, (outs), (ins i16mem:$dst), "dec{w}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001691 [(store (add (loadi16 addr:$dst), -1), addr:$dst),
1692 (implicit EFLAGS)]>,
Evan Cheng4a7e72f2007-10-19 21:23:22 +00001693 OpSize, Requires<[In32BitMode]>;
Dan Gohman91888f02007-07-31 20:11:57 +00001694 def DEC32m : I<0xFF, MRM1m, (outs), (ins i32mem:$dst), "dec{l}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001695 [(store (add (loadi32 addr:$dst), -1), addr:$dst),
1696 (implicit EFLAGS)]>,
Evan Cheng4a7e72f2007-10-19 21:23:22 +00001697 Requires<[In32BitMode]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001698}
Evan Cheng55687072007-09-14 21:48:26 +00001699} // Defs = [EFLAGS]
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001700
1701// Logical operators...
Evan Cheng55687072007-09-14 21:48:26 +00001702let Defs = [EFLAGS] in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001703let isCommutable = 1 in { // X = AND Y, Z --> X = AND Z, Y
1704def AND8rr : I<0x20, MRMDestReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001705 (outs GR8 :$dst), (ins GR8 :$src1, GR8 :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001706 "and{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001707 [(set GR8:$dst, (and GR8:$src1, GR8:$src2)),
1708 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001709def AND16rr : I<0x21, MRMDestReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001710 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001711 "and{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001712 [(set GR16:$dst, (and GR16:$src1, GR16:$src2)),
1713 (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001714def AND32rr : I<0x21, MRMDestReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001715 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001716 "and{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001717 [(set GR32:$dst, (and GR32:$src1, GR32:$src2)),
1718 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001719}
1720
Sean Callanan2c48df22009-12-18 00:01:26 +00001721// AND instructions with the destination register in REG and the source register
1722// in R/M. Included for the disassembler.
1723def AND8rr_REV : I<0x22, MRMSrcReg, (outs GR8:$dst), (ins GR8:$src1, GR8:$src2),
1724 "and{b}\t{$src2, $dst|$dst, $src2}", []>;
1725def AND16rr_REV : I<0x23, MRMSrcReg, (outs GR16:$dst),
1726 (ins GR16:$src1, GR16:$src2),
1727 "and{w}\t{$src2, $dst|$dst, $src2}", []>, OpSize;
1728def AND32rr_REV : I<0x23, MRMSrcReg, (outs GR32:$dst),
1729 (ins GR32:$src1, GR32:$src2),
1730 "and{l}\t{$src2, $dst|$dst, $src2}", []>;
1731
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001732def AND8rm : I<0x22, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001733 (outs GR8 :$dst), (ins GR8 :$src1, i8mem :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001734 "and{b}\t{$src2, $dst|$dst, $src2}",
Chris Lattner12208612009-04-10 00:16:23 +00001735 [(set GR8:$dst, (and GR8:$src1, (loadi8 addr:$src2))),
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001736 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001737def AND16rm : I<0x23, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001738 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001739 "and{w}\t{$src2, $dst|$dst, $src2}",
Chris Lattner12208612009-04-10 00:16:23 +00001740 [(set GR16:$dst, (and GR16:$src1, (loadi16 addr:$src2))),
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001741 (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001742def AND32rm : I<0x23, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001743 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001744 "and{l}\t{$src2, $dst|$dst, $src2}",
Chris Lattner12208612009-04-10 00:16:23 +00001745 [(set GR32:$dst, (and GR32:$src1, (loadi32 addr:$src2))),
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001746 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001747
1748def AND8ri : Ii8<0x80, MRM4r,
Evan Chengb783fa32007-07-19 01:14:50 +00001749 (outs GR8 :$dst), (ins GR8 :$src1, i8imm :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001750 "and{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001751 [(set GR8:$dst, (and GR8:$src1, imm:$src2)),
1752 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001753def AND16ri : Ii16<0x81, MRM4r,
Evan Chengb783fa32007-07-19 01:14:50 +00001754 (outs GR16:$dst), (ins GR16:$src1, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001755 "and{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001756 [(set GR16:$dst, (and GR16:$src1, imm:$src2)),
1757 (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001758def AND32ri : Ii32<0x81, MRM4r,
Evan Chengb783fa32007-07-19 01:14:50 +00001759 (outs GR32:$dst), (ins GR32:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001760 "and{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001761 [(set GR32:$dst, (and GR32:$src1, imm:$src2)),
1762 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001763def AND16ri8 : Ii8<0x83, MRM4r,
Evan Chengb783fa32007-07-19 01:14:50 +00001764 (outs GR16:$dst), (ins GR16:$src1, i16i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001765 "and{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001766 [(set GR16:$dst, (and GR16:$src1, i16immSExt8:$src2)),
1767 (implicit EFLAGS)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001768 OpSize;
1769def AND32ri8 : Ii8<0x83, MRM4r,
Evan Chengb783fa32007-07-19 01:14:50 +00001770 (outs GR32:$dst), (ins GR32:$src1, i32i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001771 "and{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001772 [(set GR32:$dst, (and GR32:$src1, i32immSExt8:$src2)),
1773 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001774
1775let isTwoAddress = 0 in {
1776 def AND8mr : I<0x20, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001777 (outs), (ins i8mem :$dst, GR8 :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001778 "and{b}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001779 [(store (and (load addr:$dst), GR8:$src), addr:$dst),
1780 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001781 def AND16mr : I<0x21, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001782 (outs), (ins i16mem:$dst, GR16:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001783 "and{w}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001784 [(store (and (load addr:$dst), GR16:$src), addr:$dst),
1785 (implicit EFLAGS)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001786 OpSize;
1787 def AND32mr : I<0x21, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001788 (outs), (ins i32mem:$dst, GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001789 "and{l}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001790 [(store (and (load addr:$dst), GR32:$src), addr:$dst),
1791 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001792 def AND8mi : Ii8<0x80, MRM4m,
Evan Chengb783fa32007-07-19 01:14:50 +00001793 (outs), (ins i8mem :$dst, i8imm :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001794 "and{b}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001795 [(store (and (loadi8 addr:$dst), imm:$src), addr:$dst),
1796 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001797 def AND16mi : Ii16<0x81, MRM4m,
Evan Chengb783fa32007-07-19 01:14:50 +00001798 (outs), (ins i16mem:$dst, i16imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001799 "and{w}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001800 [(store (and (loadi16 addr:$dst), imm:$src), addr:$dst),
1801 (implicit EFLAGS)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001802 OpSize;
1803 def AND32mi : Ii32<0x81, MRM4m,
Evan Chengb783fa32007-07-19 01:14:50 +00001804 (outs), (ins i32mem:$dst, i32imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001805 "and{l}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001806 [(store (and (loadi32 addr:$dst), imm:$src), addr:$dst),
1807 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001808 def AND16mi8 : Ii8<0x83, MRM4m,
Evan Chengb783fa32007-07-19 01:14:50 +00001809 (outs), (ins i16mem:$dst, i16i8imm :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001810 "and{w}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001811 [(store (and (load addr:$dst), i16immSExt8:$src), addr:$dst),
1812 (implicit EFLAGS)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001813 OpSize;
1814 def AND32mi8 : Ii8<0x83, MRM4m,
Evan Chengb783fa32007-07-19 01:14:50 +00001815 (outs), (ins i32mem:$dst, i32i8imm :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001816 "and{l}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001817 [(store (and (load addr:$dst), i32immSExt8:$src), addr:$dst),
1818 (implicit EFLAGS)]>;
Sean Callanan251676e2009-09-02 00:55:49 +00001819
1820 def AND8i8 : Ii8<0x24, RawFrm, (outs), (ins i8imm:$src),
1821 "and{b}\t{$src, %al|%al, $src}", []>;
1822 def AND16i16 : Ii16<0x25, RawFrm, (outs), (ins i16imm:$src),
1823 "and{w}\t{$src, %ax|%ax, $src}", []>, OpSize;
1824 def AND32i32 : Ii32<0x25, RawFrm, (outs), (ins i32imm:$src),
1825 "and{l}\t{$src, %eax|%eax, $src}", []>;
1826
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001827}
1828
1829
1830let isCommutable = 1 in { // X = OR Y, Z --> X = OR Z, Y
Sean Callanan2c48df22009-12-18 00:01:26 +00001831def OR8rr : I<0x08, MRMDestReg, (outs GR8 :$dst),
1832 (ins GR8 :$src1, GR8 :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001833 "or{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001834 [(set GR8:$dst, (or GR8:$src1, GR8:$src2)),
1835 (implicit EFLAGS)]>;
Sean Callanan2c48df22009-12-18 00:01:26 +00001836def OR16rr : I<0x09, MRMDestReg, (outs GR16:$dst),
1837 (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001838 "or{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001839 [(set GR16:$dst, (or GR16:$src1, GR16:$src2)),
1840 (implicit EFLAGS)]>, OpSize;
Sean Callanan2c48df22009-12-18 00:01:26 +00001841def OR32rr : I<0x09, MRMDestReg, (outs GR32:$dst),
1842 (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001843 "or{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001844 [(set GR32:$dst, (or GR32:$src1, GR32:$src2)),
1845 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001846}
Sean Callanan2c48df22009-12-18 00:01:26 +00001847
1848// OR instructions with the destination register in REG and the source register
1849// in R/M. Included for the disassembler.
1850def OR8rr_REV : I<0x0A, MRMSrcReg, (outs GR8:$dst), (ins GR8:$src1, GR8:$src2),
1851 "or{b}\t{$src2, $dst|$dst, $src2}", []>;
1852def OR16rr_REV : I<0x0B, MRMSrcReg, (outs GR16:$dst),
1853 (ins GR16:$src1, GR16:$src2),
1854 "or{w}\t{$src2, $dst|$dst, $src2}", []>, OpSize;
1855def OR32rr_REV : I<0x0B, MRMSrcReg, (outs GR32:$dst),
1856 (ins GR32:$src1, GR32:$src2),
1857 "or{l}\t{$src2, $dst|$dst, $src2}", []>;
1858
1859def OR8rm : I<0x0A, MRMSrcMem , (outs GR8 :$dst),
1860 (ins GR8 :$src1, i8mem :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001861 "or{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001862 [(set GR8:$dst, (or GR8:$src1, (load addr:$src2))),
1863 (implicit EFLAGS)]>;
Sean Callanan2c48df22009-12-18 00:01:26 +00001864def OR16rm : I<0x0B, MRMSrcMem , (outs GR16:$dst),
1865 (ins GR16:$src1, i16mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001866 "or{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001867 [(set GR16:$dst, (or GR16:$src1, (load addr:$src2))),
1868 (implicit EFLAGS)]>, OpSize;
Sean Callanan2c48df22009-12-18 00:01:26 +00001869def OR32rm : I<0x0B, MRMSrcMem , (outs GR32:$dst),
1870 (ins GR32:$src1, i32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001871 "or{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001872 [(set GR32:$dst, (or GR32:$src1, (load addr:$src2))),
1873 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001874
Sean Callanan2c48df22009-12-18 00:01:26 +00001875def OR8ri : Ii8 <0x80, MRM1r, (outs GR8 :$dst),
1876 (ins GR8 :$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001877 "or{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001878 [(set GR8:$dst, (or GR8:$src1, imm:$src2)),
1879 (implicit EFLAGS)]>;
Sean Callanan2c48df22009-12-18 00:01:26 +00001880def OR16ri : Ii16<0x81, MRM1r, (outs GR16:$dst),
1881 (ins GR16:$src1, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001882 "or{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001883 [(set GR16:$dst, (or GR16:$src1, imm:$src2)),
1884 (implicit EFLAGS)]>, OpSize;
Sean Callanan2c48df22009-12-18 00:01:26 +00001885def OR32ri : Ii32<0x81, MRM1r, (outs GR32:$dst),
1886 (ins GR32:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001887 "or{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001888 [(set GR32:$dst, (or GR32:$src1, imm:$src2)),
1889 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001890
Sean Callanan2c48df22009-12-18 00:01:26 +00001891def OR16ri8 : Ii8<0x83, MRM1r, (outs GR16:$dst),
1892 (ins GR16:$src1, i16i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001893 "or{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001894 [(set GR16:$dst, (or GR16:$src1, i16immSExt8:$src2)),
1895 (implicit EFLAGS)]>, OpSize;
Sean Callanan2c48df22009-12-18 00:01:26 +00001896def OR32ri8 : Ii8<0x83, MRM1r, (outs GR32:$dst),
1897 (ins GR32:$src1, i32i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001898 "or{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001899 [(set GR32:$dst, (or GR32:$src1, i32immSExt8:$src2)),
1900 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001901let isTwoAddress = 0 in {
Evan Chengb783fa32007-07-19 01:14:50 +00001902 def OR8mr : I<0x08, MRMDestMem, (outs), (ins i8mem:$dst, GR8:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001903 "or{b}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001904 [(store (or (load addr:$dst), GR8:$src), addr:$dst),
1905 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001906 def OR16mr : I<0x09, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001907 "or{w}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001908 [(store (or (load addr:$dst), GR16:$src), addr:$dst),
1909 (implicit EFLAGS)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001910 def OR32mr : I<0x09, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001911 "or{l}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001912 [(store (or (load addr:$dst), GR32:$src), addr:$dst),
1913 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001914 def OR8mi : Ii8<0x80, MRM1m, (outs), (ins i8mem :$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001915 "or{b}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001916 [(store (or (loadi8 addr:$dst), imm:$src), addr:$dst),
1917 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001918 def OR16mi : Ii16<0x81, MRM1m, (outs), (ins i16mem:$dst, i16imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001919 "or{w}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001920 [(store (or (loadi16 addr:$dst), imm:$src), addr:$dst),
1921 (implicit EFLAGS)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001922 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001923 def OR32mi : Ii32<0x81, MRM1m, (outs), (ins i32mem:$dst, i32imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001924 "or{l}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001925 [(store (or (loadi32 addr:$dst), imm:$src), addr:$dst),
1926 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001927 def OR16mi8 : Ii8<0x83, MRM1m, (outs), (ins i16mem:$dst, i16i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001928 "or{w}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001929 [(store (or (load addr:$dst), i16immSExt8:$src), addr:$dst),
1930 (implicit EFLAGS)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001931 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001932 def OR32mi8 : Ii8<0x83, MRM1m, (outs), (ins i32mem:$dst, i32i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001933 "or{l}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001934 [(store (or (load addr:$dst), i32immSExt8:$src), addr:$dst),
1935 (implicit EFLAGS)]>;
Sean Callanan8562bef2009-09-11 19:01:56 +00001936
1937 def OR8i8 : Ii8 <0x0C, RawFrm, (outs), (ins i8imm:$src),
1938 "or{b}\t{$src, %al|%al, $src}", []>;
1939 def OR16i16 : Ii16 <0x0D, RawFrm, (outs), (ins i16imm:$src),
1940 "or{w}\t{$src, %ax|%ax, $src}", []>, OpSize;
1941 def OR32i32 : Ii32 <0x0D, RawFrm, (outs), (ins i32imm:$src),
1942 "or{l}\t{$src, %eax|%eax, $src}", []>;
Bill Wendlingba5d5b02008-05-29 01:02:09 +00001943} // isTwoAddress = 0
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001944
1945
Evan Cheng6f26e8b2008-06-18 08:13:07 +00001946let isCommutable = 1 in { // X = XOR Y, Z --> X = XOR Z, Y
Bill Wendlingba5d5b02008-05-29 01:02:09 +00001947 def XOR8rr : I<0x30, MRMDestReg,
1948 (outs GR8 :$dst), (ins GR8 :$src1, GR8 :$src2),
1949 "xor{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001950 [(set GR8:$dst, (xor GR8:$src1, GR8:$src2)),
1951 (implicit EFLAGS)]>;
Bill Wendlingba5d5b02008-05-29 01:02:09 +00001952 def XOR16rr : I<0x31, MRMDestReg,
1953 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
1954 "xor{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001955 [(set GR16:$dst, (xor GR16:$src1, GR16:$src2)),
1956 (implicit EFLAGS)]>, OpSize;
Bill Wendlingba5d5b02008-05-29 01:02:09 +00001957 def XOR32rr : I<0x31, MRMDestReg,
1958 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
1959 "xor{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001960 [(set GR32:$dst, (xor GR32:$src1, GR32:$src2)),
1961 (implicit EFLAGS)]>;
Evan Cheng6f26e8b2008-06-18 08:13:07 +00001962} // isCommutable = 1
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001963
Sean Callanan2c48df22009-12-18 00:01:26 +00001964// XOR instructions with the destination register in REG and the source register
1965// in R/M. Included for the disassembler.
1966def XOR8rr_REV : I<0x32, MRMSrcReg, (outs GR8:$dst), (ins GR8:$src1, GR8:$src2),
1967 "xor{b}\t{$src2, $dst|$dst, $src2}", []>;
1968def XOR16rr_REV : I<0x33, MRMSrcReg, (outs GR16:$dst),
1969 (ins GR16:$src1, GR16:$src2),
1970 "xor{w}\t{$src2, $dst|$dst, $src2}", []>, OpSize;
1971def XOR32rr_REV : I<0x33, MRMSrcReg, (outs GR32:$dst),
1972 (ins GR32:$src1, GR32:$src2),
1973 "xor{l}\t{$src2, $dst|$dst, $src2}", []>;
1974
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001975def XOR8rm : I<0x32, MRMSrcMem ,
Evan Chengb783fa32007-07-19 01:14:50 +00001976 (outs GR8 :$dst), (ins GR8:$src1, i8mem :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001977 "xor{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001978 [(set GR8:$dst, (xor GR8:$src1, (load addr:$src2))),
1979 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001980def XOR16rm : I<0x33, MRMSrcMem ,
Evan Chengb783fa32007-07-19 01:14:50 +00001981 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001982 "xor{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001983 [(set GR16:$dst, (xor GR16:$src1, (load addr:$src2))),
1984 (implicit EFLAGS)]>,
Bill Wendlingba5d5b02008-05-29 01:02:09 +00001985 OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001986def XOR32rm : I<0x33, MRMSrcMem ,
Evan Chengb783fa32007-07-19 01:14:50 +00001987 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001988 "xor{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001989 [(set GR32:$dst, (xor GR32:$src1, (load addr:$src2))),
1990 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001991
Bill Wendlingbac38eb2008-05-29 03:46:36 +00001992def XOR8ri : Ii8<0x80, MRM6r,
1993 (outs GR8:$dst), (ins GR8:$src1, i8imm:$src2),
1994 "xor{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001995 [(set GR8:$dst, (xor GR8:$src1, imm:$src2)),
1996 (implicit EFLAGS)]>;
Bill Wendlingbac38eb2008-05-29 03:46:36 +00001997def XOR16ri : Ii16<0x81, MRM6r,
1998 (outs GR16:$dst), (ins GR16:$src1, i16imm:$src2),
1999 "xor{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00002000 [(set GR16:$dst, (xor GR16:$src1, imm:$src2)),
2001 (implicit EFLAGS)]>, OpSize;
Bill Wendlingbac38eb2008-05-29 03:46:36 +00002002def XOR32ri : Ii32<0x81, MRM6r,
2003 (outs GR32:$dst), (ins GR32:$src1, i32imm:$src2),
2004 "xor{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00002005 [(set GR32:$dst, (xor GR32:$src1, imm:$src2)),
2006 (implicit EFLAGS)]>;
Bill Wendlingbac38eb2008-05-29 03:46:36 +00002007def XOR16ri8 : Ii8<0x83, MRM6r,
2008 (outs GR16:$dst), (ins GR16:$src1, i16i8imm:$src2),
2009 "xor{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00002010 [(set GR16:$dst, (xor GR16:$src1, i16immSExt8:$src2)),
2011 (implicit EFLAGS)]>,
Bill Wendlingbac38eb2008-05-29 03:46:36 +00002012 OpSize;
2013def XOR32ri8 : Ii8<0x83, MRM6r,
2014 (outs GR32:$dst), (ins GR32:$src1, i32i8imm:$src2),
2015 "xor{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00002016 [(set GR32:$dst, (xor GR32:$src1, i32immSExt8:$src2)),
2017 (implicit EFLAGS)]>;
Bill Wendlingba5d5b02008-05-29 01:02:09 +00002018
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002019let isTwoAddress = 0 in {
2020 def XOR8mr : I<0x30, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00002021 (outs), (ins i8mem :$dst, GR8 :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002022 "xor{b}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00002023 [(store (xor (load addr:$dst), GR8:$src), addr:$dst),
2024 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002025 def XOR16mr : I<0x31, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00002026 (outs), (ins i16mem:$dst, GR16:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002027 "xor{w}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00002028 [(store (xor (load addr:$dst), GR16:$src), addr:$dst),
2029 (implicit EFLAGS)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002030 OpSize;
2031 def XOR32mr : I<0x31, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00002032 (outs), (ins i32mem:$dst, GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002033 "xor{l}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00002034 [(store (xor (load addr:$dst), GR32:$src), addr:$dst),
2035 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002036 def XOR8mi : Ii8<0x80, MRM6m,
Evan Chengb783fa32007-07-19 01:14:50 +00002037 (outs), (ins i8mem :$dst, i8imm :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002038 "xor{b}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00002039 [(store (xor (loadi8 addr:$dst), imm:$src), addr:$dst),
2040 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002041 def XOR16mi : Ii16<0x81, MRM6m,
Evan Chengb783fa32007-07-19 01:14:50 +00002042 (outs), (ins i16mem:$dst, i16imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002043 "xor{w}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00002044 [(store (xor (loadi16 addr:$dst), imm:$src), addr:$dst),
2045 (implicit EFLAGS)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002046 OpSize;
2047 def XOR32mi : Ii32<0x81, MRM6m,
Evan Chengb783fa32007-07-19 01:14:50 +00002048 (outs), (ins i32mem:$dst, i32imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002049 "xor{l}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00002050 [(store (xor (loadi32 addr:$dst), imm:$src), addr:$dst),
2051 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002052 def XOR16mi8 : Ii8<0x83, MRM6m,
Evan Chengb783fa32007-07-19 01:14:50 +00002053 (outs), (ins i16mem:$dst, i16i8imm :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002054 "xor{w}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00002055 [(store (xor (load addr:$dst), i16immSExt8:$src), addr:$dst),
2056 (implicit EFLAGS)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002057 OpSize;
2058 def XOR32mi8 : Ii8<0x83, MRM6m,
Evan Chengb783fa32007-07-19 01:14:50 +00002059 (outs), (ins i32mem:$dst, i32i8imm :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002060 "xor{l}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00002061 [(store (xor (load addr:$dst), i32immSExt8:$src), addr:$dst),
2062 (implicit EFLAGS)]>;
Sean Callanan794457a2009-09-10 19:52:26 +00002063
2064 def XOR8i8 : Ii8 <0x34, RawFrm, (outs), (ins i8imm:$src),
2065 "xor{b}\t{$src, %al|%al, $src}", []>;
2066 def XOR16i16 : Ii16 <0x35, RawFrm, (outs), (ins i16imm:$src),
2067 "xor{w}\t{$src, %ax|%ax, $src}", []>, OpSize;
2068 def XOR32i32 : Ii32 <0x35, RawFrm, (outs), (ins i32imm:$src),
2069 "xor{l}\t{$src, %eax|%eax, $src}", []>;
Bill Wendlingba5d5b02008-05-29 01:02:09 +00002070} // isTwoAddress = 0
Evan Cheng55687072007-09-14 21:48:26 +00002071} // Defs = [EFLAGS]
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002072
2073// Shift instructions
Evan Cheng55687072007-09-14 21:48:26 +00002074let Defs = [EFLAGS] in {
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002075let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00002076def SHL8rCL : I<0xD2, MRM4r, (outs GR8 :$dst), (ins GR8 :$src),
Eli Friedman378ea832009-06-19 04:48:38 +00002077 "shl{b}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002078 [(set GR8:$dst, (shl GR8:$src, CL))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002079def SHL16rCL : I<0xD3, MRM4r, (outs GR16:$dst), (ins GR16:$src),
Eli Friedman378ea832009-06-19 04:48:38 +00002080 "shl{w}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002081 [(set GR16:$dst, (shl GR16:$src, CL))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002082def SHL32rCL : I<0xD3, MRM4r, (outs GR32:$dst), (ins GR32:$src),
Eli Friedman378ea832009-06-19 04:48:38 +00002083 "shl{l}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002084 [(set GR32:$dst, (shl GR32:$src, CL))]>;
Bill Wendlingba5d5b02008-05-29 01:02:09 +00002085} // Uses = [CL]
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002086
Evan Chengb783fa32007-07-19 01:14:50 +00002087def SHL8ri : Ii8<0xC0, MRM4r, (outs GR8 :$dst), (ins GR8 :$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002088 "shl{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002089 [(set GR8:$dst, (shl GR8:$src1, (i8 imm:$src2)))]>;
2090let isConvertibleToThreeAddress = 1 in { // Can transform into LEA.
Evan Chengb783fa32007-07-19 01:14:50 +00002091def SHL16ri : Ii8<0xC1, MRM4r, (outs GR16:$dst), (ins GR16:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002092 "shl{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002093 [(set GR16:$dst, (shl GR16:$src1, (i8 imm:$src2)))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002094def SHL32ri : Ii8<0xC1, MRM4r, (outs GR32:$dst), (ins GR32:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002095 "shl{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002096 [(set GR32:$dst, (shl GR32:$src1, (i8 imm:$src2)))]>;
Sean Callananca503e02009-09-16 02:28:43 +00002097
2098// NOTE: We don't include patterns for shifts of a register by one, because
2099// 'add reg,reg' is cheaper.
2100
2101def SHL8r1 : I<0xD0, MRM4r, (outs GR8:$dst), (ins GR8:$src1),
2102 "shl{b}\t$dst", []>;
2103def SHL16r1 : I<0xD1, MRM4r, (outs GR16:$dst), (ins GR16:$src1),
2104 "shl{w}\t$dst", []>, OpSize;
2105def SHL32r1 : I<0xD1, MRM4r, (outs GR32:$dst), (ins GR32:$src1),
2106 "shl{l}\t$dst", []>;
2107
Bill Wendlingba5d5b02008-05-29 01:02:09 +00002108} // isConvertibleToThreeAddress = 1
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002109
2110let isTwoAddress = 0 in {
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002111 let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00002112 def SHL8mCL : I<0xD2, MRM4m, (outs), (ins i8mem :$dst),
Eli Friedman378ea832009-06-19 04:48:38 +00002113 "shl{b}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002114 [(store (shl (loadi8 addr:$dst), CL), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002115 def SHL16mCL : I<0xD3, MRM4m, (outs), (ins i16mem:$dst),
Eli Friedman378ea832009-06-19 04:48:38 +00002116 "shl{w}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002117 [(store (shl (loadi16 addr:$dst), CL), addr:$dst)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002118 def SHL32mCL : I<0xD3, MRM4m, (outs), (ins i32mem:$dst),
Eli Friedman378ea832009-06-19 04:48:38 +00002119 "shl{l}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002120 [(store (shl (loadi32 addr:$dst), CL), addr:$dst)]>;
2121 }
Evan Chengb783fa32007-07-19 01:14:50 +00002122 def SHL8mi : Ii8<0xC0, MRM4m, (outs), (ins i8mem :$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002123 "shl{b}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002124 [(store (shl (loadi8 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002125 def SHL16mi : Ii8<0xC1, MRM4m, (outs), (ins i16mem:$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002126 "shl{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002127 [(store (shl (loadi16 addr:$dst), (i8 imm:$src)), addr:$dst)]>,
2128 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002129 def SHL32mi : Ii8<0xC1, MRM4m, (outs), (ins i32mem:$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002130 "shl{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002131 [(store (shl (loadi32 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
2132
2133 // Shift by 1
Evan Chengb783fa32007-07-19 01:14:50 +00002134 def SHL8m1 : I<0xD0, MRM4m, (outs), (ins i8mem :$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002135 "shl{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002136 [(store (shl (loadi8 addr:$dst), (i8 1)), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002137 def SHL16m1 : I<0xD1, MRM4m, (outs), (ins i16mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002138 "shl{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002139 [(store (shl (loadi16 addr:$dst), (i8 1)), addr:$dst)]>,
2140 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002141 def SHL32m1 : I<0xD1, MRM4m, (outs), (ins i32mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002142 "shl{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002143 [(store (shl (loadi32 addr:$dst), (i8 1)), addr:$dst)]>;
2144}
2145
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002146let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00002147def SHR8rCL : I<0xD2, MRM5r, (outs GR8 :$dst), (ins GR8 :$src),
Eli Friedman378ea832009-06-19 04:48:38 +00002148 "shr{b}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002149 [(set GR8:$dst, (srl GR8:$src, CL))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002150def SHR16rCL : I<0xD3, MRM5r, (outs GR16:$dst), (ins GR16:$src),
Eli Friedman378ea832009-06-19 04:48:38 +00002151 "shr{w}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002152 [(set GR16:$dst, (srl GR16:$src, CL))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002153def SHR32rCL : I<0xD3, MRM5r, (outs GR32:$dst), (ins GR32:$src),
Eli Friedman378ea832009-06-19 04:48:38 +00002154 "shr{l}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002155 [(set GR32:$dst, (srl GR32:$src, CL))]>;
2156}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002157
Evan Chengb783fa32007-07-19 01:14:50 +00002158def SHR8ri : Ii8<0xC0, MRM5r, (outs GR8:$dst), (ins GR8:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002159 "shr{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002160 [(set GR8:$dst, (srl GR8:$src1, (i8 imm:$src2)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002161def SHR16ri : Ii8<0xC1, MRM5r, (outs GR16:$dst), (ins GR16:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002162 "shr{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002163 [(set GR16:$dst, (srl GR16:$src1, (i8 imm:$src2)))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002164def SHR32ri : Ii8<0xC1, MRM5r, (outs GR32:$dst), (ins GR32:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002165 "shr{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002166 [(set GR32:$dst, (srl GR32:$src1, (i8 imm:$src2)))]>;
2167
2168// Shift by 1
Evan Chengb783fa32007-07-19 01:14:50 +00002169def SHR8r1 : I<0xD0, MRM5r, (outs GR8:$dst), (ins GR8:$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00002170 "shr{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002171 [(set GR8:$dst, (srl GR8:$src1, (i8 1)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002172def SHR16r1 : I<0xD1, MRM5r, (outs GR16:$dst), (ins GR16:$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00002173 "shr{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002174 [(set GR16:$dst, (srl GR16:$src1, (i8 1)))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002175def SHR32r1 : I<0xD1, MRM5r, (outs GR32:$dst), (ins GR32:$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00002176 "shr{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002177 [(set GR32:$dst, (srl GR32:$src1, (i8 1)))]>;
2178
2179let isTwoAddress = 0 in {
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002180 let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00002181 def SHR8mCL : I<0xD2, MRM5m, (outs), (ins i8mem :$dst),
Eli Friedman378ea832009-06-19 04:48:38 +00002182 "shr{b}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002183 [(store (srl (loadi8 addr:$dst), CL), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002184 def SHR16mCL : I<0xD3, MRM5m, (outs), (ins i16mem:$dst),
Eli Friedman378ea832009-06-19 04:48:38 +00002185 "shr{w}\t{%cl, $dst|$dst, CL}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002186 [(store (srl (loadi16 addr:$dst), CL), addr:$dst)]>,
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002187 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002188 def SHR32mCL : I<0xD3, MRM5m, (outs), (ins i32mem:$dst),
Eli Friedman378ea832009-06-19 04:48:38 +00002189 "shr{l}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002190 [(store (srl (loadi32 addr:$dst), CL), addr:$dst)]>;
2191 }
Evan Chengb783fa32007-07-19 01:14:50 +00002192 def SHR8mi : Ii8<0xC0, MRM5m, (outs), (ins i8mem :$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002193 "shr{b}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002194 [(store (srl (loadi8 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002195 def SHR16mi : Ii8<0xC1, MRM5m, (outs), (ins i16mem:$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002196 "shr{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002197 [(store (srl (loadi16 addr:$dst), (i8 imm:$src)), addr:$dst)]>,
2198 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002199 def SHR32mi : Ii8<0xC1, MRM5m, (outs), (ins i32mem:$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002200 "shr{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002201 [(store (srl (loadi32 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
2202
2203 // Shift by 1
Evan Chengb783fa32007-07-19 01:14:50 +00002204 def SHR8m1 : I<0xD0, MRM5m, (outs), (ins i8mem :$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002205 "shr{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002206 [(store (srl (loadi8 addr:$dst), (i8 1)), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002207 def SHR16m1 : I<0xD1, MRM5m, (outs), (ins i16mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002208 "shr{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002209 [(store (srl (loadi16 addr:$dst), (i8 1)), addr:$dst)]>,OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002210 def SHR32m1 : I<0xD1, MRM5m, (outs), (ins i32mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002211 "shr{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002212 [(store (srl (loadi32 addr:$dst), (i8 1)), addr:$dst)]>;
2213}
2214
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002215let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00002216def SAR8rCL : I<0xD2, MRM7r, (outs GR8 :$dst), (ins GR8 :$src),
Eli Friedman378ea832009-06-19 04:48:38 +00002217 "sar{b}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002218 [(set GR8:$dst, (sra GR8:$src, CL))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002219def SAR16rCL : I<0xD3, MRM7r, (outs GR16:$dst), (ins GR16:$src),
Eli Friedman378ea832009-06-19 04:48:38 +00002220 "sar{w}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002221 [(set GR16:$dst, (sra GR16:$src, CL))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002222def SAR32rCL : I<0xD3, MRM7r, (outs GR32:$dst), (ins GR32:$src),
Eli Friedman378ea832009-06-19 04:48:38 +00002223 "sar{l}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002224 [(set GR32:$dst, (sra GR32:$src, CL))]>;
2225}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002226
Evan Chengb783fa32007-07-19 01:14:50 +00002227def SAR8ri : Ii8<0xC0, MRM7r, (outs GR8 :$dst), (ins GR8 :$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002228 "sar{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002229 [(set GR8:$dst, (sra GR8:$src1, (i8 imm:$src2)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002230def SAR16ri : Ii8<0xC1, MRM7r, (outs GR16:$dst), (ins GR16:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002231 "sar{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002232 [(set GR16:$dst, (sra GR16:$src1, (i8 imm:$src2)))]>,
2233 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002234def SAR32ri : Ii8<0xC1, MRM7r, (outs GR32:$dst), (ins GR32:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002235 "sar{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002236 [(set GR32:$dst, (sra GR32:$src1, (i8 imm:$src2)))]>;
2237
2238// Shift by 1
Evan Chengb783fa32007-07-19 01:14:50 +00002239def SAR8r1 : I<0xD0, MRM7r, (outs GR8 :$dst), (ins GR8 :$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00002240 "sar{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002241 [(set GR8:$dst, (sra GR8:$src1, (i8 1)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002242def SAR16r1 : I<0xD1, MRM7r, (outs GR16:$dst), (ins GR16:$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00002243 "sar{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002244 [(set GR16:$dst, (sra GR16:$src1, (i8 1)))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002245def SAR32r1 : I<0xD1, MRM7r, (outs GR32:$dst), (ins GR32:$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00002246 "sar{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002247 [(set GR32:$dst, (sra GR32:$src1, (i8 1)))]>;
2248
2249let isTwoAddress = 0 in {
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002250 let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00002251 def SAR8mCL : I<0xD2, MRM7m, (outs), (ins i8mem :$dst),
Eli Friedman378ea832009-06-19 04:48:38 +00002252 "sar{b}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002253 [(store (sra (loadi8 addr:$dst), CL), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002254 def SAR16mCL : I<0xD3, MRM7m, (outs), (ins i16mem:$dst),
Eli Friedman378ea832009-06-19 04:48:38 +00002255 "sar{w}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002256 [(store (sra (loadi16 addr:$dst), CL), addr:$dst)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002257 def SAR32mCL : I<0xD3, MRM7m, (outs), (ins i32mem:$dst),
Eli Friedman378ea832009-06-19 04:48:38 +00002258 "sar{l}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002259 [(store (sra (loadi32 addr:$dst), CL), addr:$dst)]>;
2260 }
Evan Chengb783fa32007-07-19 01:14:50 +00002261 def SAR8mi : Ii8<0xC0, MRM7m, (outs), (ins i8mem :$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002262 "sar{b}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002263 [(store (sra (loadi8 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002264 def SAR16mi : Ii8<0xC1, MRM7m, (outs), (ins i16mem:$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002265 "sar{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002266 [(store (sra (loadi16 addr:$dst), (i8 imm:$src)), addr:$dst)]>,
2267 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002268 def SAR32mi : Ii8<0xC1, MRM7m, (outs), (ins i32mem:$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002269 "sar{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002270 [(store (sra (loadi32 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
2271
2272 // Shift by 1
Evan Chengb783fa32007-07-19 01:14:50 +00002273 def SAR8m1 : I<0xD0, MRM7m, (outs), (ins i8mem :$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002274 "sar{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002275 [(store (sra (loadi8 addr:$dst), (i8 1)), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002276 def SAR16m1 : I<0xD1, MRM7m, (outs), (ins i16mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002277 "sar{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002278 [(store (sra (loadi16 addr:$dst), (i8 1)), addr:$dst)]>,
2279 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002280 def SAR32m1 : I<0xD1, MRM7m, (outs), (ins i32mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002281 "sar{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002282 [(store (sra (loadi32 addr:$dst), (i8 1)), addr:$dst)]>;
2283}
2284
2285// Rotate instructions
Sean Callanan3c8eecd2009-09-18 19:35:23 +00002286
2287def RCL8r1 : I<0xD0, MRM2r, (outs GR8:$dst), (ins GR8:$src),
2288 "rcl{b}\t{1, $dst|$dst, 1}", []>;
2289def RCL8m1 : I<0xD0, MRM2m, (outs i8mem:$dst), (ins i8mem:$src),
2290 "rcl{b}\t{1, $dst|$dst, 1}", []>;
2291let Uses = [CL] in {
2292def RCL8rCL : I<0xD2, MRM2r, (outs GR8:$dst), (ins GR8:$src),
2293 "rcl{b}\t{%cl, $dst|$dst, CL}", []>;
2294def RCL8mCL : I<0xD2, MRM2m, (outs i8mem:$dst), (ins i8mem:$src),
2295 "rcl{b}\t{%cl, $dst|$dst, CL}", []>;
2296}
2297def RCL8ri : Ii8<0xC0, MRM2r, (outs GR8:$dst), (ins GR8:$src, i8imm:$cnt),
2298 "rcl{b}\t{$cnt, $dst|$dst, $cnt}", []>;
2299def RCL8mi : Ii8<0xC0, MRM2m, (outs i8mem:$dst), (ins i8mem:$src, i8imm:$cnt),
2300 "rcl{b}\t{$cnt, $dst|$dst, $cnt}", []>;
2301
2302def RCL16r1 : I<0xD1, MRM2r, (outs GR16:$dst), (ins GR16:$src),
2303 "rcl{w}\t{1, $dst|$dst, 1}", []>, OpSize;
2304def RCL16m1 : I<0xD1, MRM2m, (outs i16mem:$dst), (ins i16mem:$src),
2305 "rcl{w}\t{1, $dst|$dst, 1}", []>, OpSize;
2306let Uses = [CL] in {
2307def RCL16rCL : I<0xD3, MRM2r, (outs GR16:$dst), (ins GR16:$src),
2308 "rcl{w}\t{%cl, $dst|$dst, CL}", []>, OpSize;
2309def RCL16mCL : I<0xD3, MRM2m, (outs i16mem:$dst), (ins i16mem:$src),
2310 "rcl{w}\t{%cl, $dst|$dst, CL}", []>, OpSize;
2311}
2312def RCL16ri : Ii8<0xC1, MRM2r, (outs GR16:$dst), (ins GR16:$src, i8imm:$cnt),
2313 "rcl{w}\t{$cnt, $dst|$dst, $cnt}", []>, OpSize;
Sean Callanan2c48df22009-12-18 00:01:26 +00002314def RCL16mi : Ii8<0xC1, MRM2m, (outs i16mem:$dst),
2315 (ins i16mem:$src, i8imm:$cnt),
Sean Callanan3c8eecd2009-09-18 19:35:23 +00002316 "rcl{w}\t{$cnt, $dst|$dst, $cnt}", []>, OpSize;
2317
2318def RCL32r1 : I<0xD1, MRM2r, (outs GR32:$dst), (ins GR32:$src),
2319 "rcl{l}\t{1, $dst|$dst, 1}", []>;
2320def RCL32m1 : I<0xD1, MRM2m, (outs i32mem:$dst), (ins i32mem:$src),
2321 "rcl{l}\t{1, $dst|$dst, 1}", []>;
2322let Uses = [CL] in {
2323def RCL32rCL : I<0xD3, MRM2r, (outs GR32:$dst), (ins GR32:$src),
2324 "rcl{l}\t{%cl, $dst|$dst, CL}", []>;
2325def RCL32mCL : I<0xD3, MRM2m, (outs i32mem:$dst), (ins i32mem:$src),
2326 "rcl{l}\t{%cl, $dst|$dst, CL}", []>;
2327}
2328def RCL32ri : Ii8<0xC1, MRM2r, (outs GR32:$dst), (ins GR32:$src, i8imm:$cnt),
2329 "rcl{l}\t{$cnt, $dst|$dst, $cnt}", []>;
Sean Callanan2c48df22009-12-18 00:01:26 +00002330def RCL32mi : Ii8<0xC1, MRM2m, (outs i32mem:$dst),
2331 (ins i32mem:$src, i8imm:$cnt),
Sean Callanan3c8eecd2009-09-18 19:35:23 +00002332 "rcl{l}\t{$cnt, $dst|$dst, $cnt}", []>;
2333
2334def RCR8r1 : I<0xD0, MRM3r, (outs GR8:$dst), (ins GR8:$src),
2335 "rcr{b}\t{1, $dst|$dst, 1}", []>;
2336def RCR8m1 : I<0xD0, MRM3m, (outs i8mem:$dst), (ins i8mem:$src),
2337 "rcr{b}\t{1, $dst|$dst, 1}", []>;
2338let Uses = [CL] in {
2339def RCR8rCL : I<0xD2, MRM3r, (outs GR8:$dst), (ins GR8:$src),
2340 "rcr{b}\t{%cl, $dst|$dst, CL}", []>;
2341def RCR8mCL : I<0xD2, MRM3m, (outs i8mem:$dst), (ins i8mem:$src),
2342 "rcr{b}\t{%cl, $dst|$dst, CL}", []>;
2343}
2344def RCR8ri : Ii8<0xC0, MRM3r, (outs GR8:$dst), (ins GR8:$src, i8imm:$cnt),
2345 "rcr{b}\t{$cnt, $dst|$dst, $cnt}", []>;
2346def RCR8mi : Ii8<0xC0, MRM3m, (outs i8mem:$dst), (ins i8mem:$src, i8imm:$cnt),
2347 "rcr{b}\t{$cnt, $dst|$dst, $cnt}", []>;
2348
2349def RCR16r1 : I<0xD1, MRM3r, (outs GR16:$dst), (ins GR16:$src),
2350 "rcr{w}\t{1, $dst|$dst, 1}", []>, OpSize;
2351def RCR16m1 : I<0xD1, MRM3m, (outs i16mem:$dst), (ins i16mem:$src),
2352 "rcr{w}\t{1, $dst|$dst, 1}", []>, OpSize;
2353let Uses = [CL] in {
2354def RCR16rCL : I<0xD3, MRM3r, (outs GR16:$dst), (ins GR16:$src),
2355 "rcr{w}\t{%cl, $dst|$dst, CL}", []>, OpSize;
2356def RCR16mCL : I<0xD3, MRM3m, (outs i16mem:$dst), (ins i16mem:$src),
2357 "rcr{w}\t{%cl, $dst|$dst, CL}", []>, OpSize;
2358}
2359def RCR16ri : Ii8<0xC1, MRM3r, (outs GR16:$dst), (ins GR16:$src, i8imm:$cnt),
2360 "rcr{w}\t{$cnt, $dst|$dst, $cnt}", []>, OpSize;
Sean Callanan2c48df22009-12-18 00:01:26 +00002361def RCR16mi : Ii8<0xC1, MRM3m, (outs i16mem:$dst),
2362 (ins i16mem:$src, i8imm:$cnt),
Sean Callanan3c8eecd2009-09-18 19:35:23 +00002363 "rcr{w}\t{$cnt, $dst|$dst, $cnt}", []>, OpSize;
2364
2365def RCR32r1 : I<0xD1, MRM3r, (outs GR32:$dst), (ins GR32:$src),
2366 "rcr{l}\t{1, $dst|$dst, 1}", []>;
2367def RCR32m1 : I<0xD1, MRM3m, (outs i32mem:$dst), (ins i32mem:$src),
2368 "rcr{l}\t{1, $dst|$dst, 1}", []>;
2369let Uses = [CL] in {
2370def RCR32rCL : I<0xD3, MRM3r, (outs GR32:$dst), (ins GR32:$src),
2371 "rcr{l}\t{%cl, $dst|$dst, CL}", []>;
2372def RCR32mCL : I<0xD3, MRM3m, (outs i32mem:$dst), (ins i32mem:$src),
2373 "rcr{l}\t{%cl, $dst|$dst, CL}", []>;
2374}
2375def RCR32ri : Ii8<0xC1, MRM3r, (outs GR32:$dst), (ins GR32:$src, i8imm:$cnt),
2376 "rcr{l}\t{$cnt, $dst|$dst, $cnt}", []>;
Sean Callanan2c48df22009-12-18 00:01:26 +00002377def RCR32mi : Ii8<0xC1, MRM3m, (outs i32mem:$dst),
2378 (ins i32mem:$src, i8imm:$cnt),
Sean Callanan3c8eecd2009-09-18 19:35:23 +00002379 "rcr{l}\t{$cnt, $dst|$dst, $cnt}", []>;
2380
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002381// FIXME: provide shorter instructions when imm8 == 1
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002382let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00002383def ROL8rCL : I<0xD2, MRM0r, (outs GR8 :$dst), (ins GR8 :$src),
Eli Friedman378ea832009-06-19 04:48:38 +00002384 "rol{b}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002385 [(set GR8:$dst, (rotl GR8:$src, CL))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002386def ROL16rCL : I<0xD3, MRM0r, (outs GR16:$dst), (ins GR16:$src),
Eli Friedman378ea832009-06-19 04:48:38 +00002387 "rol{w}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002388 [(set GR16:$dst, (rotl GR16:$src, CL))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002389def ROL32rCL : I<0xD3, MRM0r, (outs GR32:$dst), (ins GR32:$src),
Eli Friedman378ea832009-06-19 04:48:38 +00002390 "rol{l}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002391 [(set GR32:$dst, (rotl GR32:$src, CL))]>;
2392}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002393
Evan Chengb783fa32007-07-19 01:14:50 +00002394def ROL8ri : Ii8<0xC0, MRM0r, (outs GR8 :$dst), (ins GR8 :$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002395 "rol{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002396 [(set GR8:$dst, (rotl GR8:$src1, (i8 imm:$src2)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002397def ROL16ri : Ii8<0xC1, MRM0r, (outs GR16:$dst), (ins GR16:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002398 "rol{w}\t{$src2, $dst|$dst, $src2}",
Sean Callanan2c48df22009-12-18 00:01:26 +00002399 [(set GR16:$dst, (rotl GR16:$src1, (i8 imm:$src2)))]>,
2400 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002401def ROL32ri : Ii8<0xC1, MRM0r, (outs GR32:$dst), (ins GR32:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002402 "rol{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002403 [(set GR32:$dst, (rotl GR32:$src1, (i8 imm:$src2)))]>;
2404
2405// Rotate by 1
Evan Chengb783fa32007-07-19 01:14:50 +00002406def ROL8r1 : I<0xD0, MRM0r, (outs GR8 :$dst), (ins GR8 :$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00002407 "rol{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002408 [(set GR8:$dst, (rotl GR8:$src1, (i8 1)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002409def ROL16r1 : I<0xD1, MRM0r, (outs GR16:$dst), (ins GR16:$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00002410 "rol{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002411 [(set GR16:$dst, (rotl GR16:$src1, (i8 1)))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002412def ROL32r1 : I<0xD1, MRM0r, (outs GR32:$dst), (ins GR32:$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00002413 "rol{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002414 [(set GR32:$dst, (rotl GR32:$src1, (i8 1)))]>;
2415
2416let isTwoAddress = 0 in {
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002417 let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00002418 def ROL8mCL : I<0xD2, MRM0m, (outs), (ins i8mem :$dst),
Eli Friedman378ea832009-06-19 04:48:38 +00002419 "rol{b}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002420 [(store (rotl (loadi8 addr:$dst), CL), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002421 def ROL16mCL : I<0xD3, MRM0m, (outs), (ins i16mem:$dst),
Eli Friedman378ea832009-06-19 04:48:38 +00002422 "rol{w}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002423 [(store (rotl (loadi16 addr:$dst), CL), addr:$dst)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002424 def ROL32mCL : I<0xD3, MRM0m, (outs), (ins i32mem:$dst),
Eli Friedman378ea832009-06-19 04:48:38 +00002425 "rol{l}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002426 [(store (rotl (loadi32 addr:$dst), CL), addr:$dst)]>;
2427 }
Evan Chengb783fa32007-07-19 01:14:50 +00002428 def ROL8mi : Ii8<0xC0, MRM0m, (outs), (ins i8mem :$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002429 "rol{b}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002430 [(store (rotl (loadi8 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002431 def ROL16mi : Ii8<0xC1, MRM0m, (outs), (ins i16mem:$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002432 "rol{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002433 [(store (rotl (loadi16 addr:$dst), (i8 imm:$src)), addr:$dst)]>,
2434 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002435 def ROL32mi : Ii8<0xC1, MRM0m, (outs), (ins i32mem:$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002436 "rol{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002437 [(store (rotl (loadi32 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
2438
2439 // Rotate by 1
Evan Chengb783fa32007-07-19 01:14:50 +00002440 def ROL8m1 : I<0xD0, MRM0m, (outs), (ins i8mem :$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002441 "rol{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002442 [(store (rotl (loadi8 addr:$dst), (i8 1)), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002443 def ROL16m1 : I<0xD1, MRM0m, (outs), (ins i16mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002444 "rol{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002445 [(store (rotl (loadi16 addr:$dst), (i8 1)), addr:$dst)]>,
2446 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002447 def ROL32m1 : I<0xD1, MRM0m, (outs), (ins i32mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002448 "rol{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002449 [(store (rotl (loadi32 addr:$dst), (i8 1)), addr:$dst)]>;
2450}
2451
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002452let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00002453def ROR8rCL : I<0xD2, MRM1r, (outs GR8 :$dst), (ins GR8 :$src),
Eli Friedman378ea832009-06-19 04:48:38 +00002454 "ror{b}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002455 [(set GR8:$dst, (rotr GR8:$src, CL))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002456def ROR16rCL : I<0xD3, MRM1r, (outs GR16:$dst), (ins GR16:$src),
Eli Friedman378ea832009-06-19 04:48:38 +00002457 "ror{w}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002458 [(set GR16:$dst, (rotr GR16:$src, CL))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002459def ROR32rCL : I<0xD3, MRM1r, (outs GR32:$dst), (ins GR32:$src),
Eli Friedman378ea832009-06-19 04:48:38 +00002460 "ror{l}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002461 [(set GR32:$dst, (rotr GR32:$src, CL))]>;
2462}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002463
Evan Chengb783fa32007-07-19 01:14:50 +00002464def ROR8ri : Ii8<0xC0, MRM1r, (outs GR8 :$dst), (ins GR8 :$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002465 "ror{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002466 [(set GR8:$dst, (rotr GR8:$src1, (i8 imm:$src2)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002467def ROR16ri : Ii8<0xC1, MRM1r, (outs GR16:$dst), (ins GR16:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002468 "ror{w}\t{$src2, $dst|$dst, $src2}",
Sean Callanan2c48df22009-12-18 00:01:26 +00002469 [(set GR16:$dst, (rotr GR16:$src1, (i8 imm:$src2)))]>,
2470 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002471def ROR32ri : Ii8<0xC1, MRM1r, (outs GR32:$dst), (ins GR32:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002472 "ror{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002473 [(set GR32:$dst, (rotr GR32:$src1, (i8 imm:$src2)))]>;
2474
2475// Rotate by 1
Evan Chengb783fa32007-07-19 01:14:50 +00002476def ROR8r1 : I<0xD0, MRM1r, (outs GR8 :$dst), (ins GR8 :$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00002477 "ror{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002478 [(set GR8:$dst, (rotr GR8:$src1, (i8 1)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002479def ROR16r1 : I<0xD1, MRM1r, (outs GR16:$dst), (ins GR16:$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00002480 "ror{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002481 [(set GR16:$dst, (rotr GR16:$src1, (i8 1)))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002482def ROR32r1 : I<0xD1, MRM1r, (outs GR32:$dst), (ins GR32:$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00002483 "ror{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002484 [(set GR32:$dst, (rotr GR32:$src1, (i8 1)))]>;
2485
2486let isTwoAddress = 0 in {
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002487 let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00002488 def ROR8mCL : I<0xD2, MRM1m, (outs), (ins i8mem :$dst),
Eli Friedman378ea832009-06-19 04:48:38 +00002489 "ror{b}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002490 [(store (rotr (loadi8 addr:$dst), CL), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002491 def ROR16mCL : I<0xD3, MRM1m, (outs), (ins i16mem:$dst),
Eli Friedman378ea832009-06-19 04:48:38 +00002492 "ror{w}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002493 [(store (rotr (loadi16 addr:$dst), CL), addr:$dst)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002494 def ROR32mCL : I<0xD3, MRM1m, (outs), (ins i32mem:$dst),
Eli Friedman378ea832009-06-19 04:48:38 +00002495 "ror{l}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002496 [(store (rotr (loadi32 addr:$dst), CL), addr:$dst)]>;
2497 }
Evan Chengb783fa32007-07-19 01:14:50 +00002498 def ROR8mi : Ii8<0xC0, MRM1m, (outs), (ins i8mem :$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002499 "ror{b}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002500 [(store (rotr (loadi8 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002501 def ROR16mi : Ii8<0xC1, MRM1m, (outs), (ins i16mem:$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002502 "ror{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002503 [(store (rotr (loadi16 addr:$dst), (i8 imm:$src)), addr:$dst)]>,
2504 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002505 def ROR32mi : Ii8<0xC1, MRM1m, (outs), (ins i32mem:$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002506 "ror{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002507 [(store (rotr (loadi32 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
2508
2509 // Rotate by 1
Evan Chengb783fa32007-07-19 01:14:50 +00002510 def ROR8m1 : I<0xD0, MRM1m, (outs), (ins i8mem :$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002511 "ror{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002512 [(store (rotr (loadi8 addr:$dst), (i8 1)), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002513 def ROR16m1 : I<0xD1, MRM1m, (outs), (ins i16mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002514 "ror{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002515 [(store (rotr (loadi16 addr:$dst), (i8 1)), addr:$dst)]>,
2516 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002517 def ROR32m1 : I<0xD1, MRM1m, (outs), (ins i32mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002518 "ror{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002519 [(store (rotr (loadi32 addr:$dst), (i8 1)), addr:$dst)]>;
2520}
2521
2522
2523
2524// Double shift instructions (generalizations of rotate)
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002525let Uses = [CL] in {
Sean Callanan2c48df22009-12-18 00:01:26 +00002526def SHLD32rrCL : I<0xA5, MRMDestReg, (outs GR32:$dst),
2527 (ins GR32:$src1, GR32:$src2),
Eli Friedman378ea832009-06-19 04:48:38 +00002528 "shld{l}\t{%cl, $src2, $dst|$dst, $src2, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002529 [(set GR32:$dst, (X86shld GR32:$src1, GR32:$src2, CL))]>, TB;
Sean Callanan2c48df22009-12-18 00:01:26 +00002530def SHRD32rrCL : I<0xAD, MRMDestReg, (outs GR32:$dst),
2531 (ins GR32:$src1, GR32:$src2),
Eli Friedman378ea832009-06-19 04:48:38 +00002532 "shrd{l}\t{%cl, $src2, $dst|$dst, $src2, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002533 [(set GR32:$dst, (X86shrd GR32:$src1, GR32:$src2, CL))]>, TB;
Sean Callanan2c48df22009-12-18 00:01:26 +00002534def SHLD16rrCL : I<0xA5, MRMDestReg, (outs GR16:$dst),
2535 (ins GR16:$src1, GR16:$src2),
Eli Friedman378ea832009-06-19 04:48:38 +00002536 "shld{w}\t{%cl, $src2, $dst|$dst, $src2, CL}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002537 [(set GR16:$dst, (X86shld GR16:$src1, GR16:$src2, CL))]>,
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002538 TB, OpSize;
Sean Callanan2c48df22009-12-18 00:01:26 +00002539def SHRD16rrCL : I<0xAD, MRMDestReg, (outs GR16:$dst),
2540 (ins GR16:$src1, GR16:$src2),
Eli Friedman378ea832009-06-19 04:48:38 +00002541 "shrd{w}\t{%cl, $src2, $dst|$dst, $src2, CL}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002542 [(set GR16:$dst, (X86shrd GR16:$src1, GR16:$src2, CL))]>,
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002543 TB, OpSize;
2544}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002545
2546let isCommutable = 1 in { // These instructions commute to each other.
2547def SHLD32rri8 : Ii8<0xA4, MRMDestReg,
Sean Callanan2c48df22009-12-18 00:01:26 +00002548 (outs GR32:$dst),
2549 (ins GR32:$src1, GR32:$src2, i8imm:$src3),
Dan Gohman91888f02007-07-31 20:11:57 +00002550 "shld{l}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002551 [(set GR32:$dst, (X86shld GR32:$src1, GR32:$src2,
2552 (i8 imm:$src3)))]>,
2553 TB;
2554def SHRD32rri8 : Ii8<0xAC, MRMDestReg,
Sean Callanan2c48df22009-12-18 00:01:26 +00002555 (outs GR32:$dst),
2556 (ins GR32:$src1, GR32:$src2, i8imm:$src3),
Dan Gohman91888f02007-07-31 20:11:57 +00002557 "shrd{l}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002558 [(set GR32:$dst, (X86shrd GR32:$src1, GR32:$src2,
2559 (i8 imm:$src3)))]>,
2560 TB;
2561def SHLD16rri8 : Ii8<0xA4, MRMDestReg,
Sean Callanan2c48df22009-12-18 00:01:26 +00002562 (outs GR16:$dst),
2563 (ins GR16:$src1, GR16:$src2, i8imm:$src3),
Dan Gohman91888f02007-07-31 20:11:57 +00002564 "shld{w}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002565 [(set GR16:$dst, (X86shld GR16:$src1, GR16:$src2,
2566 (i8 imm:$src3)))]>,
2567 TB, OpSize;
2568def SHRD16rri8 : Ii8<0xAC, MRMDestReg,
Sean Callanan2c48df22009-12-18 00:01:26 +00002569 (outs GR16:$dst),
2570 (ins GR16:$src1, GR16:$src2, i8imm:$src3),
Dan Gohman91888f02007-07-31 20:11:57 +00002571 "shrd{w}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002572 [(set GR16:$dst, (X86shrd GR16:$src1, GR16:$src2,
2573 (i8 imm:$src3)))]>,
2574 TB, OpSize;
2575}
2576
2577let isTwoAddress = 0 in {
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002578 let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00002579 def SHLD32mrCL : I<0xA5, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
Eli Friedman378ea832009-06-19 04:48:38 +00002580 "shld{l}\t{%cl, $src2, $dst|$dst, $src2, CL}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002581 [(store (X86shld (loadi32 addr:$dst), GR32:$src2, CL),
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002582 addr:$dst)]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00002583 def SHRD32mrCL : I<0xAD, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
Eli Friedman378ea832009-06-19 04:48:38 +00002584 "shrd{l}\t{%cl, $src2, $dst|$dst, $src2, CL}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002585 [(store (X86shrd (loadi32 addr:$dst), GR32:$src2, CL),
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002586 addr:$dst)]>, TB;
2587 }
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002588 def SHLD32mri8 : Ii8<0xA4, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00002589 (outs), (ins i32mem:$dst, GR32:$src2, i8imm:$src3),
Dan Gohman91888f02007-07-31 20:11:57 +00002590 "shld{l}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002591 [(store (X86shld (loadi32 addr:$dst), GR32:$src2,
2592 (i8 imm:$src3)), addr:$dst)]>,
2593 TB;
2594 def SHRD32mri8 : Ii8<0xAC, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00002595 (outs), (ins i32mem:$dst, GR32:$src2, i8imm:$src3),
Dan Gohman91888f02007-07-31 20:11:57 +00002596 "shrd{l}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002597 [(store (X86shrd (loadi32 addr:$dst), GR32:$src2,
2598 (i8 imm:$src3)), addr:$dst)]>,
2599 TB;
2600
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002601 let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00002602 def SHLD16mrCL : I<0xA5, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
Eli Friedman378ea832009-06-19 04:48:38 +00002603 "shld{w}\t{%cl, $src2, $dst|$dst, $src2, CL}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002604 [(store (X86shld (loadi16 addr:$dst), GR16:$src2, CL),
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002605 addr:$dst)]>, TB, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002606 def SHRD16mrCL : I<0xAD, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
Eli Friedman378ea832009-06-19 04:48:38 +00002607 "shrd{w}\t{%cl, $src2, $dst|$dst, $src2, CL}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002608 [(store (X86shrd (loadi16 addr:$dst), GR16:$src2, CL),
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002609 addr:$dst)]>, TB, OpSize;
2610 }
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002611 def SHLD16mri8 : Ii8<0xA4, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00002612 (outs), (ins i16mem:$dst, GR16:$src2, i8imm:$src3),
Dan Gohman91888f02007-07-31 20:11:57 +00002613 "shld{w}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002614 [(store (X86shld (loadi16 addr:$dst), GR16:$src2,
2615 (i8 imm:$src3)), addr:$dst)]>,
2616 TB, OpSize;
2617 def SHRD16mri8 : Ii8<0xAC, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00002618 (outs), (ins i16mem:$dst, GR16:$src2, i8imm:$src3),
Dan Gohman91888f02007-07-31 20:11:57 +00002619 "shrd{w}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002620 [(store (X86shrd (loadi16 addr:$dst), GR16:$src2,
2621 (i8 imm:$src3)), addr:$dst)]>,
2622 TB, OpSize;
2623}
Evan Cheng55687072007-09-14 21:48:26 +00002624} // Defs = [EFLAGS]
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002625
2626
2627// Arithmetic.
Evan Cheng55687072007-09-14 21:48:26 +00002628let Defs = [EFLAGS] in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002629let isCommutable = 1 in { // X = ADD Y, Z --> X = ADD Z, Y
Bill Wendlingae034ed2008-12-12 00:56:36 +00002630// Register-Register Addition
2631def ADD8rr : I<0x00, MRMDestReg, (outs GR8 :$dst),
2632 (ins GR8 :$src1, GR8 :$src2),
2633 "add{b}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002634 [(set GR8:$dst, (add GR8:$src1, GR8:$src2)),
Bill Wendlingae034ed2008-12-12 00:56:36 +00002635 (implicit EFLAGS)]>;
2636
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002637let isConvertibleToThreeAddress = 1 in { // Can transform into LEA.
Bill Wendlingae034ed2008-12-12 00:56:36 +00002638// Register-Register Addition
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002639def ADD16rr : I<0x01, MRMDestReg, (outs GR16:$dst),
2640 (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002641 "add{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002642 [(set GR16:$dst, (add GR16:$src1, GR16:$src2)),
2643 (implicit EFLAGS)]>, OpSize;
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002644def ADD32rr : I<0x01, MRMDestReg, (outs GR32:$dst),
2645 (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002646 "add{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002647 [(set GR32:$dst, (add GR32:$src1, GR32:$src2)),
2648 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002649} // end isConvertibleToThreeAddress
2650} // end isCommutable
Bill Wendlingae034ed2008-12-12 00:56:36 +00002651
2652// Register-Memory Addition
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002653def ADD8rm : I<0x02, MRMSrcMem, (outs GR8 :$dst),
2654 (ins GR8 :$src1, i8mem :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002655 "add{b}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002656 [(set GR8:$dst, (add GR8:$src1, (load addr:$src2))),
2657 (implicit EFLAGS)]>;
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002658def ADD16rm : I<0x03, MRMSrcMem, (outs GR16:$dst),
2659 (ins GR16:$src1, i16mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002660 "add{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002661 [(set GR16:$dst, (add GR16:$src1, (load addr:$src2))),
2662 (implicit EFLAGS)]>, OpSize;
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002663def ADD32rm : I<0x03, MRMSrcMem, (outs GR32:$dst),
2664 (ins GR32:$src1, i32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002665 "add{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002666 [(set GR32:$dst, (add GR32:$src1, (load addr:$src2))),
2667 (implicit EFLAGS)]>;
Sean Callanan7e7df0e2009-09-15 20:53:57 +00002668
Sean Callanan84df9312009-09-15 21:43:27 +00002669// Register-Register Addition - Equivalent to the normal rr forms (ADD8rr,
2670// ADD16rr, and ADD32rr), but differently encoded.
Sean Callanan7e7df0e2009-09-15 20:53:57 +00002671def ADD8mrmrr: I<0x02, MRMSrcReg, (outs GR8:$dst), (ins GR8:$src1, GR8:$src2),
2672 "add{b}\t{$src2, $dst|$dst, $src2}", []>;
2673def ADD16mrmrr: I<0x03, MRMSrcReg,(outs GR16:$dst),(ins GR16:$src1, GR16:$src2),
2674 "add{w}\t{$src2, $dst|$dst, $src2}", []>, OpSize;
2675def ADD32mrmrr: I<0x03, MRMSrcReg,(outs GR16:$dst),(ins GR16:$src1, GR16:$src2),
2676 "add{l}\t{$src2, $dst|$dst, $src2}", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002677
Bill Wendlingae034ed2008-12-12 00:56:36 +00002678// Register-Integer Addition
2679def ADD8ri : Ii8<0x80, MRM0r, (outs GR8:$dst), (ins GR8:$src1, i8imm:$src2),
2680 "add{b}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002681 [(set GR8:$dst, (add GR8:$src1, imm:$src2)),
2682 (implicit EFLAGS)]>;
Bill Wendlingae034ed2008-12-12 00:56:36 +00002683
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002684let isConvertibleToThreeAddress = 1 in { // Can transform into LEA.
Bill Wendlingae034ed2008-12-12 00:56:36 +00002685// Register-Integer Addition
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002686def ADD16ri : Ii16<0x81, MRM0r, (outs GR16:$dst),
2687 (ins GR16:$src1, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002688 "add{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002689 [(set GR16:$dst, (add GR16:$src1, imm:$src2)),
2690 (implicit EFLAGS)]>, OpSize;
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002691def ADD32ri : Ii32<0x81, MRM0r, (outs GR32:$dst),
2692 (ins GR32:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002693 "add{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002694 [(set GR32:$dst, (add GR32:$src1, imm:$src2)),
2695 (implicit EFLAGS)]>;
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002696def ADD16ri8 : Ii8<0x83, MRM0r, (outs GR16:$dst),
2697 (ins GR16:$src1, i16i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002698 "add{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002699 [(set GR16:$dst, (add GR16:$src1, i16immSExt8:$src2)),
2700 (implicit EFLAGS)]>, OpSize;
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002701def ADD32ri8 : Ii8<0x83, MRM0r, (outs GR32:$dst),
2702 (ins GR32:$src1, i32i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002703 "add{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002704 [(set GR32:$dst, (add GR32:$src1, i32immSExt8:$src2)),
2705 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002706}
2707
2708let isTwoAddress = 0 in {
Bill Wendlingae034ed2008-12-12 00:56:36 +00002709 // Memory-Register Addition
Bill Wendlingf5399032008-12-12 21:15:41 +00002710 def ADD8mr : I<0x00, MRMDestMem, (outs), (ins i8mem:$dst, GR8:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002711 "add{b}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002712 [(store (add (load addr:$dst), GR8:$src2), addr:$dst),
2713 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002714 def ADD16mr : I<0x01, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002715 "add{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002716 [(store (add (load addr:$dst), GR16:$src2), addr:$dst),
2717 (implicit EFLAGS)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002718 def ADD32mr : I<0x01, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002719 "add{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002720 [(store (add (load addr:$dst), GR32:$src2), addr:$dst),
2721 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002722 def ADD8mi : Ii8<0x80, MRM0m, (outs), (ins i8mem :$dst, i8imm :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002723 "add{b}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002724 [(store (add (loadi8 addr:$dst), imm:$src2), addr:$dst),
2725 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002726 def ADD16mi : Ii16<0x81, MRM0m, (outs), (ins i16mem:$dst, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002727 "add{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002728 [(store (add (loadi16 addr:$dst), imm:$src2), addr:$dst),
2729 (implicit EFLAGS)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002730 def ADD32mi : Ii32<0x81, MRM0m, (outs), (ins i32mem:$dst, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002731 "add{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002732 [(store (add (loadi32 addr:$dst), imm:$src2), addr:$dst),
2733 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002734 def ADD16mi8 : Ii8<0x83, MRM0m, (outs), (ins i16mem:$dst, i16i8imm :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002735 "add{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002736 [(store (add (load addr:$dst), i16immSExt8:$src2),
2737 addr:$dst),
2738 (implicit EFLAGS)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002739 def ADD32mi8 : Ii8<0x83, MRM0m, (outs), (ins i32mem:$dst, i32i8imm :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002740 "add{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingae034ed2008-12-12 00:56:36 +00002741 [(store (add (load addr:$dst), i32immSExt8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00002742 addr:$dst),
2743 (implicit EFLAGS)]>;
Sean Callanan0316b342009-08-11 21:26:06 +00002744
2745 // addition to rAX
2746 def ADD8i8 : Ii8<0x04, RawFrm, (outs), (ins i8imm:$src),
Sean Callanan251676e2009-09-02 00:55:49 +00002747 "add{b}\t{$src, %al|%al, $src}", []>;
Sean Callanan0316b342009-08-11 21:26:06 +00002748 def ADD16i16 : Ii16<0x05, RawFrm, (outs), (ins i16imm:$src),
Sean Callanan251676e2009-09-02 00:55:49 +00002749 "add{w}\t{$src, %ax|%ax, $src}", []>, OpSize;
Sean Callanan0316b342009-08-11 21:26:06 +00002750 def ADD32i32 : Ii32<0x05, RawFrm, (outs), (ins i32imm:$src),
Sean Callanan251676e2009-09-02 00:55:49 +00002751 "add{l}\t{$src, %eax|%eax, $src}", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002752}
2753
Evan Cheng259471d2007-10-05 17:59:57 +00002754let Uses = [EFLAGS] in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002755let isCommutable = 1 in { // X = ADC Y, Z --> X = ADC Z, Y
Dale Johannesen747fe522009-06-02 03:12:52 +00002756def ADC8rr : I<0x10, MRMDestReg, (outs GR8:$dst), (ins GR8:$src1, GR8:$src2),
Dale Johannesen06b83f12009-05-18 17:44:15 +00002757 "adc{b}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002758 [(set GR8:$dst, (adde GR8:$src1, GR8:$src2))]>;
Dale Johannesen06b83f12009-05-18 17:44:15 +00002759def ADC16rr : I<0x11, MRMDestReg, (outs GR16:$dst),
2760 (ins GR16:$src1, GR16:$src2),
2761 "adc{w}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002762 [(set GR16:$dst, (adde GR16:$src1, GR16:$src2))]>, OpSize;
Dale Johannesen06b83f12009-05-18 17:44:15 +00002763def ADC32rr : I<0x11, MRMDestReg, (outs GR32:$dst),
2764 (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002765 "adc{l}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002766 [(set GR32:$dst, (adde GR32:$src1, GR32:$src2))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002767}
Sean Callanan2c48df22009-12-18 00:01:26 +00002768
2769def ADC8rr_REV : I<0x12, MRMSrcReg, (outs GR8:$dst), (ins GR8:$src1, GR8:$src2),
2770 "adc{b}\t{$src2, $dst|$dst, $src2}", []>;
2771def ADC16rr_REV : I<0x13, MRMSrcReg, (outs GR16:$dst),
2772 (ins GR16:$src1, GR16:$src2),
2773 "adc{w}\t{$src2, $dst|$dst, $src2}", []>, OpSize;
2774def ADC32rr_REV : I<0x13, MRMSrcReg, (outs GR32:$dst),
2775 (ins GR32:$src1, GR32:$src2),
2776 "adc{l}\t{$src2, $dst|$dst, $src2}", []>;
2777
Dale Johannesen06b83f12009-05-18 17:44:15 +00002778def ADC8rm : I<0x12, MRMSrcMem , (outs GR8:$dst),
2779 (ins GR8:$src1, i8mem:$src2),
2780 "adc{b}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002781 [(set GR8:$dst, (adde GR8:$src1, (load addr:$src2)))]>;
Dale Johannesen06b83f12009-05-18 17:44:15 +00002782def ADC16rm : I<0x13, MRMSrcMem , (outs GR16:$dst),
2783 (ins GR16:$src1, i16mem:$src2),
2784 "adc{w}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002785 [(set GR16:$dst, (adde GR16:$src1, (load addr:$src2)))]>,
Dale Johannesen067cfb22009-05-18 21:41:59 +00002786 OpSize;
Dale Johannesen06b83f12009-05-18 17:44:15 +00002787def ADC32rm : I<0x13, MRMSrcMem , (outs GR32:$dst),
2788 (ins GR32:$src1, i32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002789 "adc{l}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002790 [(set GR32:$dst, (adde GR32:$src1, (load addr:$src2)))]>;
2791def ADC8ri : Ii8<0x80, MRM2r, (outs GR8:$dst), (ins GR8:$src1, i8imm:$src2),
Dale Johannesen06b83f12009-05-18 17:44:15 +00002792 "adc{b}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002793 [(set GR8:$dst, (adde GR8:$src1, imm:$src2))]>;
Dale Johannesen06b83f12009-05-18 17:44:15 +00002794def ADC16ri : Ii16<0x81, MRM2r, (outs GR16:$dst),
2795 (ins GR16:$src1, i16imm:$src2),
2796 "adc{w}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002797 [(set GR16:$dst, (adde GR16:$src1, imm:$src2))]>, OpSize;
Dale Johannesen06b83f12009-05-18 17:44:15 +00002798def ADC16ri8 : Ii8<0x83, MRM2r, (outs GR16:$dst),
2799 (ins GR16:$src1, i16i8imm:$src2),
2800 "adc{w}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002801 [(set GR16:$dst, (adde GR16:$src1, i16immSExt8:$src2))]>,
2802 OpSize;
Dale Johannesen06b83f12009-05-18 17:44:15 +00002803def ADC32ri : Ii32<0x81, MRM2r, (outs GR32:$dst),
2804 (ins GR32:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002805 "adc{l}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002806 [(set GR32:$dst, (adde GR32:$src1, imm:$src2))]>;
Dale Johannesen06b83f12009-05-18 17:44:15 +00002807def ADC32ri8 : Ii8<0x83, MRM2r, (outs GR32:$dst),
2808 (ins GR32:$src1, i32i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002809 "adc{l}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002810 [(set GR32:$dst, (adde GR32:$src1, i32immSExt8:$src2))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002811
2812let isTwoAddress = 0 in {
Dale Johannesen747fe522009-06-02 03:12:52 +00002813 def ADC8mr : I<0x10, MRMDestMem, (outs), (ins i8mem:$dst, GR8:$src2),
Dale Johannesen06b83f12009-05-18 17:44:15 +00002814 "adc{b}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002815 [(store (adde (load addr:$dst), GR8:$src2), addr:$dst)]>;
2816 def ADC16mr : I<0x11, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
Dale Johannesen06b83f12009-05-18 17:44:15 +00002817 "adc{w}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002818 [(store (adde (load addr:$dst), GR16:$src2), addr:$dst)]>,
2819 OpSize;
2820 def ADC32mr : I<0x11, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002821 "adc{l}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002822 [(store (adde (load addr:$dst), GR32:$src2), addr:$dst)]>;
2823 def ADC8mi : Ii8<0x80, MRM2m, (outs), (ins i8mem:$dst, i8imm:$src2),
Dale Johannesen06b83f12009-05-18 17:44:15 +00002824 "adc{b}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002825 [(store (adde (loadi8 addr:$dst), imm:$src2), addr:$dst)]>;
2826 def ADC16mi : Ii16<0x81, MRM2m, (outs), (ins i16mem:$dst, i16imm:$src2),
Dale Johannesen06b83f12009-05-18 17:44:15 +00002827 "adc{w}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002828 [(store (adde (loadi16 addr:$dst), imm:$src2), addr:$dst)]>,
2829 OpSize;
2830 def ADC16mi8 : Ii8<0x83, MRM2m, (outs), (ins i16mem:$dst, i16i8imm :$src2),
Dale Johannesen06b83f12009-05-18 17:44:15 +00002831 "adc{w}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002832 [(store (adde (load addr:$dst), i16immSExt8:$src2), addr:$dst)]>,
2833 OpSize;
2834 def ADC32mi : Ii32<0x81, MRM2m, (outs), (ins i32mem:$dst, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002835 "adc{l}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002836 [(store (adde (loadi32 addr:$dst), imm:$src2), addr:$dst)]>;
2837 def ADC32mi8 : Ii8<0x83, MRM2m, (outs), (ins i32mem:$dst, i32i8imm :$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), i32immSExt8:$src2), addr:$dst)]>;
Sean Callanan8562bef2009-09-11 19:01:56 +00002840
2841 def ADC8i8 : Ii8<0x14, RawFrm, (outs), (ins i8imm:$src),
2842 "adc{b}\t{$src, %al|%al, $src}", []>;
2843 def ADC16i16 : Ii16<0x15, RawFrm, (outs), (ins i16imm:$src),
2844 "adc{w}\t{$src, %ax|%ax, $src}", []>, OpSize;
2845 def ADC32i32 : Ii32<0x15, RawFrm, (outs), (ins i32imm:$src),
2846 "adc{l}\t{$src, %eax|%eax, $src}", []>;
Dale Johannesen747fe522009-06-02 03:12:52 +00002847}
Evan Cheng259471d2007-10-05 17:59:57 +00002848} // Uses = [EFLAGS]
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002849
Bill Wendlingae034ed2008-12-12 00:56:36 +00002850// Register-Register Subtraction
2851def SUB8rr : I<0x28, MRMDestReg, (outs GR8:$dst), (ins GR8:$src1, GR8:$src2),
2852 "sub{b}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002853 [(set GR8:$dst, (sub GR8:$src1, GR8:$src2)),
2854 (implicit EFLAGS)]>;
Bill Wendlingae034ed2008-12-12 00:56:36 +00002855def SUB16rr : I<0x29, MRMDestReg, (outs GR16:$dst), (ins GR16:$src1,GR16:$src2),
2856 "sub{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002857 [(set GR16:$dst, (sub GR16:$src1, GR16:$src2)),
2858 (implicit EFLAGS)]>, OpSize;
Bill Wendlingae034ed2008-12-12 00:56:36 +00002859def SUB32rr : I<0x29, MRMDestReg, (outs GR32:$dst), (ins GR32:$src1,GR32:$src2),
2860 "sub{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002861 [(set GR32:$dst, (sub GR32:$src1, GR32:$src2)),
2862 (implicit EFLAGS)]>;
Bill Wendlingae034ed2008-12-12 00:56:36 +00002863
Sean Callanan2c48df22009-12-18 00:01:26 +00002864def SUB8rr_REV : I<0x2A, MRMSrcReg, (outs GR8:$dst), (ins GR8:$src1, GR8:$src2),
2865 "sub{b}\t{$src2, $dst|$dst, $src2}", []>;
2866def SUB16rr_REV : I<0x2B, MRMSrcReg, (outs GR16:$dst),
2867 (ins GR16:$src1, GR16:$src2),
2868 "sub{w}\t{$src2, $dst|$dst, $src2}", []>, OpSize;
2869def SUB32rr_REV : I<0x2B, MRMSrcReg, (outs GR32:$dst),
2870 (ins GR32:$src1, GR32:$src2),
2871 "sub{l}\t{$src2, $dst|$dst, $src2}", []>;
2872
Bill Wendlingae034ed2008-12-12 00:56:36 +00002873// Register-Memory Subtraction
2874def SUB8rm : I<0x2A, MRMSrcMem, (outs GR8 :$dst),
2875 (ins GR8 :$src1, i8mem :$src2),
2876 "sub{b}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002877 [(set GR8:$dst, (sub GR8:$src1, (load addr:$src2))),
2878 (implicit EFLAGS)]>;
Bill Wendlingae034ed2008-12-12 00:56:36 +00002879def SUB16rm : I<0x2B, MRMSrcMem, (outs GR16:$dst),
2880 (ins GR16:$src1, i16mem:$src2),
2881 "sub{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002882 [(set GR16:$dst, (sub GR16:$src1, (load addr:$src2))),
2883 (implicit EFLAGS)]>, OpSize;
Bill Wendlingae034ed2008-12-12 00:56:36 +00002884def SUB32rm : I<0x2B, MRMSrcMem, (outs GR32:$dst),
2885 (ins GR32:$src1, i32mem:$src2),
2886 "sub{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002887 [(set GR32:$dst, (sub GR32:$src1, (load addr:$src2))),
2888 (implicit EFLAGS)]>;
Bill Wendlingae034ed2008-12-12 00:56:36 +00002889
2890// Register-Integer Subtraction
2891def SUB8ri : Ii8 <0x80, MRM5r, (outs GR8:$dst),
2892 (ins GR8:$src1, i8imm:$src2),
2893 "sub{b}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002894 [(set GR8:$dst, (sub GR8:$src1, imm:$src2)),
2895 (implicit EFLAGS)]>;
Bill Wendlingae034ed2008-12-12 00:56:36 +00002896def SUB16ri : Ii16<0x81, MRM5r, (outs GR16:$dst),
2897 (ins GR16:$src1, i16imm:$src2),
2898 "sub{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002899 [(set GR16:$dst, (sub GR16:$src1, imm:$src2)),
2900 (implicit EFLAGS)]>, OpSize;
Bill Wendlingae034ed2008-12-12 00:56:36 +00002901def SUB32ri : Ii32<0x81, MRM5r, (outs GR32:$dst),
2902 (ins GR32:$src1, i32imm:$src2),
2903 "sub{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002904 [(set GR32:$dst, (sub GR32:$src1, imm:$src2)),
2905 (implicit EFLAGS)]>;
Bill Wendlingae034ed2008-12-12 00:56:36 +00002906def SUB16ri8 : Ii8<0x83, MRM5r, (outs GR16:$dst),
2907 (ins GR16:$src1, i16i8imm:$src2),
2908 "sub{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002909 [(set GR16:$dst, (sub GR16:$src1, i16immSExt8:$src2)),
2910 (implicit EFLAGS)]>, OpSize;
Bill Wendlingae034ed2008-12-12 00:56:36 +00002911def SUB32ri8 : Ii8<0x83, MRM5r, (outs GR32:$dst),
2912 (ins GR32:$src1, i32i8imm:$src2),
2913 "sub{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002914 [(set GR32:$dst, (sub GR32:$src1, i32immSExt8:$src2)),
2915 (implicit EFLAGS)]>;
Bill Wendlingae034ed2008-12-12 00:56:36 +00002916
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002917let isTwoAddress = 0 in {
Bill Wendlingae034ed2008-12-12 00:56:36 +00002918 // Memory-Register Subtraction
Evan Chengb783fa32007-07-19 01:14:50 +00002919 def SUB8mr : I<0x28, MRMDestMem, (outs), (ins i8mem :$dst, GR8 :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002920 "sub{b}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002921 [(store (sub (load addr:$dst), GR8:$src2), addr:$dst),
2922 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002923 def SUB16mr : I<0x29, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002924 "sub{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002925 [(store (sub (load addr:$dst), GR16:$src2), addr:$dst),
2926 (implicit EFLAGS)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002927 def SUB32mr : I<0x29, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002928 "sub{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002929 [(store (sub (load addr:$dst), GR32:$src2), addr:$dst),
2930 (implicit EFLAGS)]>;
Bill Wendlingae034ed2008-12-12 00:56:36 +00002931
2932 // Memory-Integer Subtraction
Evan Chengb783fa32007-07-19 01:14:50 +00002933 def SUB8mi : Ii8<0x80, MRM5m, (outs), (ins i8mem :$dst, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002934 "sub{b}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002935 [(store (sub (loadi8 addr:$dst), imm:$src2), addr:$dst),
2936 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002937 def SUB16mi : Ii16<0x81, MRM5m, (outs), (ins i16mem:$dst, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002938 "sub{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002939 [(store (sub (loadi16 addr:$dst), imm:$src2),addr:$dst),
2940 (implicit EFLAGS)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002941 def SUB32mi : Ii32<0x81, MRM5m, (outs), (ins i32mem:$dst, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002942 "sub{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002943 [(store (sub (loadi32 addr:$dst), imm:$src2),addr:$dst),
2944 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002945 def SUB16mi8 : Ii8<0x83, MRM5m, (outs), (ins i16mem:$dst, i16i8imm :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002946 "sub{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingae034ed2008-12-12 00:56:36 +00002947 [(store (sub (load addr:$dst), i16immSExt8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00002948 addr:$dst),
2949 (implicit EFLAGS)]>, OpSize;
Bill Wendlingae034ed2008-12-12 00:56:36 +00002950 def SUB32mi8 : Ii8<0x83, MRM5m, (outs), (ins i32mem:$dst, i32i8imm :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002951 "sub{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingae034ed2008-12-12 00:56:36 +00002952 [(store (sub (load addr:$dst), i32immSExt8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00002953 addr:$dst),
2954 (implicit EFLAGS)]>;
Sean Callanan8562bef2009-09-11 19:01:56 +00002955
2956 def SUB8i8 : Ii8<0x2C, RawFrm, (outs), (ins i8imm:$src),
2957 "sub{b}\t{$src, %al|%al, $src}", []>;
2958 def SUB16i16 : Ii16<0x2D, RawFrm, (outs), (ins i16imm:$src),
2959 "sub{w}\t{$src, %ax|%ax, $src}", []>, OpSize;
2960 def SUB32i32 : Ii32<0x2D, RawFrm, (outs), (ins i32imm:$src),
2961 "sub{l}\t{$src, %eax|%eax, $src}", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002962}
2963
Evan Cheng259471d2007-10-05 17:59:57 +00002964let Uses = [EFLAGS] in {
Dale Johannesen06b83f12009-05-18 17:44:15 +00002965def SBB8rr : I<0x18, MRMDestReg, (outs GR8:$dst),
2966 (ins GR8:$src1, GR8:$src2),
2967 "sbb{b}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002968 [(set GR8:$dst, (sube GR8:$src1, GR8:$src2))]>;
Dale Johannesen06b83f12009-05-18 17:44:15 +00002969def SBB16rr : I<0x19, MRMDestReg, (outs GR16:$dst),
2970 (ins GR16:$src1, GR16:$src2),
2971 "sbb{w}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002972 [(set GR16:$dst, (sube GR16:$src1, GR16:$src2))]>, OpSize;
Dale Johannesen06b83f12009-05-18 17:44:15 +00002973def SBB32rr : I<0x19, MRMDestReg, (outs GR32:$dst),
2974 (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002975 "sbb{l}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002976 [(set GR32:$dst, (sube GR32:$src1, GR32:$src2))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002977
2978let isTwoAddress = 0 in {
Dale Johannesen06b83f12009-05-18 17:44:15 +00002979 def SBB8mr : I<0x18, MRMDestMem, (outs), (ins i8mem:$dst, GR8:$src2),
2980 "sbb{b}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002981 [(store (sube (load addr:$dst), GR8:$src2), addr:$dst)]>;
Dale Johannesen06b83f12009-05-18 17:44:15 +00002982 def SBB16mr : I<0x19, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
2983 "sbb{w}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002984 [(store (sube (load addr:$dst), GR16:$src2), addr:$dst)]>,
Dale Johannesen067cfb22009-05-18 21:41:59 +00002985 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002986 def SBB32mr : I<0x19, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002987 "sbb{l}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002988 [(store (sube (load addr:$dst), GR32:$src2), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002989 def SBB8mi : Ii32<0x80, MRM3m, (outs), (ins i8mem:$dst, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002990 "sbb{b}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002991 [(store (sube (loadi8 addr:$dst), imm:$src2), addr:$dst)]>;
Dale Johannesen06b83f12009-05-18 17:44:15 +00002992 def SBB16mi : Ii16<0x81, MRM3m, (outs), (ins i16mem:$dst, i16imm:$src2),
2993 "sbb{w}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002994 [(store (sube (loadi16 addr:$dst), imm:$src2), addr:$dst)]>,
Dale Johannesen067cfb22009-05-18 21:41:59 +00002995 OpSize;
Dale Johannesen06b83f12009-05-18 17:44:15 +00002996 def SBB16mi8 : Ii8<0x83, MRM3m, (outs), (ins i16mem:$dst, i16i8imm :$src2),
2997 "sbb{w}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002998 [(store (sube (load addr:$dst), i16immSExt8:$src2), addr:$dst)]>,
Dale Johannesen067cfb22009-05-18 21:41:59 +00002999 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00003000 def SBB32mi : Ii32<0x81, MRM3m, (outs), (ins i32mem:$dst, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00003001 "sbb{l}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00003002 [(store (sube (loadi32 addr:$dst), imm:$src2), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00003003 def SBB32mi8 : Ii8<0x83, MRM3m, (outs), (ins i32mem:$dst, i32i8imm :$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), i32immSExt8:$src2), addr:$dst)]>;
Sean Callanan8562bef2009-09-11 19:01:56 +00003006
3007 def SBB8i8 : Ii8<0x1C, RawFrm, (outs), (ins i8imm:$src),
3008 "sbb{b}\t{$src, %al|%al, $src}", []>;
3009 def SBB16i16 : Ii16<0x1D, RawFrm, (outs), (ins i16imm:$src),
3010 "sbb{w}\t{$src, %ax|%ax, $src}", []>, OpSize;
3011 def SBB32i32 : Ii32<0x1D, RawFrm, (outs), (ins i32imm:$src),
3012 "sbb{l}\t{$src, %eax|%eax, $src}", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003013}
Sean Callanan2c48df22009-12-18 00:01:26 +00003014
3015def SBB8rr_REV : I<0x1A, MRMSrcReg, (outs GR8:$dst), (ins GR8:$src1, GR8:$src2),
3016 "sbb{b}\t{$src2, $dst|$dst, $src2}", []>;
3017def SBB16rr_REV : I<0x1B, MRMSrcReg, (outs GR16:$dst),
3018 (ins GR16:$src1, GR16:$src2),
3019 "sbb{w}\t{$src2, $dst|$dst, $src2}", []>, OpSize;
3020def SBB32rr_REV : I<0x1B, MRMSrcReg, (outs GR32:$dst),
3021 (ins GR32:$src1, GR32:$src2),
3022 "sbb{l}\t{$src2, $dst|$dst, $src2}", []>;
3023
Dale Johannesen06b83f12009-05-18 17:44:15 +00003024def SBB8rm : I<0x1A, MRMSrcMem, (outs GR8:$dst), (ins GR8:$src1, i8mem:$src2),
3025 "sbb{b}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00003026 [(set GR8:$dst, (sube GR8:$src1, (load addr:$src2)))]>;
Dale Johannesen06b83f12009-05-18 17:44:15 +00003027def SBB16rm : I<0x1B, MRMSrcMem, (outs GR16:$dst),
3028 (ins GR16:$src1, i16mem:$src2),
3029 "sbb{w}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00003030 [(set GR16:$dst, (sube GR16:$src1, (load addr:$src2)))]>,
Dale Johannesen067cfb22009-05-18 21:41:59 +00003031 OpSize;
Dale Johannesen06b83f12009-05-18 17:44:15 +00003032def SBB32rm : I<0x1B, MRMSrcMem, (outs GR32:$dst),
3033 (ins GR32:$src1, i32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00003034 "sbb{l}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00003035 [(set GR32:$dst, (sube GR32:$src1, (load addr:$src2)))]>;
Dale Johannesen06b83f12009-05-18 17:44:15 +00003036def SBB8ri : Ii8<0x80, MRM3r, (outs GR8:$dst), (ins GR8:$src1, i8imm:$src2),
3037 "sbb{b}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00003038 [(set GR8:$dst, (sube GR8:$src1, imm:$src2))]>;
Dale Johannesen06b83f12009-05-18 17:44:15 +00003039def SBB16ri : Ii16<0x81, MRM3r, (outs GR16:$dst),
3040 (ins GR16:$src1, i16imm:$src2),
3041 "sbb{w}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00003042 [(set GR16:$dst, (sube GR16:$src1, imm:$src2))]>, OpSize;
Dale Johannesen06b83f12009-05-18 17:44:15 +00003043def SBB16ri8 : Ii8<0x83, MRM3r, (outs GR16:$dst),
3044 (ins GR16:$src1, i16i8imm:$src2),
3045 "sbb{w}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00003046 [(set GR16:$dst, (sube GR16:$src1, i16immSExt8:$src2))]>,
3047 OpSize;
Dale Johannesen06b83f12009-05-18 17:44:15 +00003048def SBB32ri : Ii32<0x81, MRM3r, (outs GR32:$dst),
3049 (ins GR32:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00003050 "sbb{l}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00003051 [(set GR32:$dst, (sube GR32:$src1, imm:$src2))]>;
Dale Johannesen06b83f12009-05-18 17:44:15 +00003052def SBB32ri8 : Ii8<0x83, MRM3r, (outs GR32:$dst),
3053 (ins GR32:$src1, i32i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00003054 "sbb{l}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00003055 [(set GR32:$dst, (sube GR32:$src1, i32immSExt8:$src2))]>;
Evan Cheng259471d2007-10-05 17:59:57 +00003056} // Uses = [EFLAGS]
Evan Cheng55687072007-09-14 21:48:26 +00003057} // Defs = [EFLAGS]
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003058
Evan Cheng55687072007-09-14 21:48:26 +00003059let Defs = [EFLAGS] in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003060let isCommutable = 1 in { // X = IMUL Y, Z --> X = IMUL Z, Y
Bill Wendlingf5399032008-12-12 21:15:41 +00003061// Register-Register Signed Integer Multiply
Bill Wendlingae034ed2008-12-12 00:56:36 +00003062def IMUL16rr : I<0xAF, MRMSrcReg, (outs GR16:$dst), (ins GR16:$src1,GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00003063 "imul{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00003064 [(set GR16:$dst, (mul GR16:$src1, GR16:$src2)),
3065 (implicit EFLAGS)]>, TB, OpSize;
Bill Wendlingae034ed2008-12-12 00:56:36 +00003066def IMUL32rr : I<0xAF, MRMSrcReg, (outs GR32:$dst), (ins GR32:$src1,GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00003067 "imul{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00003068 [(set GR32:$dst, (mul GR32:$src1, GR32:$src2)),
3069 (implicit EFLAGS)]>, TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003070}
Bill Wendlingae034ed2008-12-12 00:56:36 +00003071
Bill Wendlingf5399032008-12-12 21:15:41 +00003072// Register-Memory Signed Integer Multiply
Bill Wendlingae034ed2008-12-12 00:56:36 +00003073def IMUL16rm : I<0xAF, MRMSrcMem, (outs GR16:$dst),
3074 (ins GR16:$src1, i16mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00003075 "imul{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00003076 [(set GR16:$dst, (mul GR16:$src1, (load addr:$src2))),
3077 (implicit EFLAGS)]>, TB, OpSize;
Sean Callanan2c48df22009-12-18 00:01:26 +00003078def IMUL32rm : I<0xAF, MRMSrcMem, (outs GR32:$dst),
3079 (ins GR32:$src1, i32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00003080 "imul{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00003081 [(set GR32:$dst, (mul GR32:$src1, (load addr:$src2))),
3082 (implicit EFLAGS)]>, TB;
Evan Cheng55687072007-09-14 21:48:26 +00003083} // Defs = [EFLAGS]
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003084} // end Two Address instructions
3085
3086// Suprisingly enough, these are not two address instructions!
Evan Cheng55687072007-09-14 21:48:26 +00003087let Defs = [EFLAGS] in {
Bill Wendlingf5399032008-12-12 21:15:41 +00003088// Register-Integer Signed Integer Multiply
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003089def IMUL16rri : Ii16<0x69, MRMSrcReg, // GR16 = GR16*I16
Evan Chengb783fa32007-07-19 01:14:50 +00003090 (outs GR16:$dst), (ins GR16:$src1, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00003091 "imul{w}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00003092 [(set GR16:$dst, (mul GR16:$src1, imm:$src2)),
3093 (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003094def IMUL32rri : Ii32<0x69, MRMSrcReg, // GR32 = GR32*I32
Evan Chengb783fa32007-07-19 01:14:50 +00003095 (outs GR32:$dst), (ins GR32:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00003096 "imul{l}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00003097 [(set GR32:$dst, (mul GR32:$src1, imm:$src2)),
3098 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003099def IMUL16rri8 : Ii8<0x6B, MRMSrcReg, // GR16 = GR16*I8
Evan Chengb783fa32007-07-19 01:14:50 +00003100 (outs GR16:$dst), (ins GR16:$src1, i16i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00003101 "imul{w}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00003102 [(set GR16:$dst, (mul GR16:$src1, i16immSExt8:$src2)),
3103 (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003104def IMUL32rri8 : Ii8<0x6B, MRMSrcReg, // GR32 = GR32*I8
Evan Chengb783fa32007-07-19 01:14:50 +00003105 (outs GR32:$dst), (ins GR32:$src1, i32i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00003106 "imul{l}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00003107 [(set GR32:$dst, (mul GR32:$src1, i32immSExt8:$src2)),
3108 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003109
Bill Wendlingf5399032008-12-12 21:15:41 +00003110// Memory-Integer Signed Integer Multiply
Sean Callanan2c48df22009-12-18 00:01:26 +00003111def IMUL16rmi : Ii16<0x69, MRMSrcMem, // GR16 = [mem16]*I16
Evan Chengb783fa32007-07-19 01:14:50 +00003112 (outs GR16:$dst), (ins i16mem:$src1, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00003113 "imul{w}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00003114 [(set GR16:$dst, (mul (load addr:$src1), imm:$src2)),
3115 (implicit EFLAGS)]>, OpSize;
Sean Callanan2c48df22009-12-18 00:01:26 +00003116def IMUL32rmi : Ii32<0x69, MRMSrcMem, // GR32 = [mem32]*I32
Evan Chengb783fa32007-07-19 01:14:50 +00003117 (outs GR32:$dst), (ins i32mem:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00003118 "imul{l}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00003119 [(set GR32:$dst, (mul (load addr:$src1), imm:$src2)),
3120 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003121def IMUL16rmi8 : Ii8<0x6B, MRMSrcMem, // GR16 = [mem16]*I8
Evan Chengb783fa32007-07-19 01:14:50 +00003122 (outs GR16:$dst), (ins i16mem:$src1, i16i8imm :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00003123 "imul{w}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Bill Wendlingae034ed2008-12-12 00:56:36 +00003124 [(set GR16:$dst, (mul (load addr:$src1),
Bill Wendlingf5399032008-12-12 21:15:41 +00003125 i16immSExt8:$src2)),
3126 (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003127def IMUL32rmi8 : Ii8<0x6B, MRMSrcMem, // GR32 = [mem32]*I8
Evan Chengb783fa32007-07-19 01:14:50 +00003128 (outs GR32:$dst), (ins i32mem:$src1, i32i8imm: $src2),
Dan Gohman91888f02007-07-31 20:11:57 +00003129 "imul{l}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Bill Wendlingae034ed2008-12-12 00:56:36 +00003130 [(set GR32:$dst, (mul (load addr:$src1),
Bill Wendlingf5399032008-12-12 21:15:41 +00003131 i32immSExt8:$src2)),
3132 (implicit EFLAGS)]>;
Evan Cheng55687072007-09-14 21:48:26 +00003133} // Defs = [EFLAGS]
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003134
3135//===----------------------------------------------------------------------===//
3136// Test instructions are just like AND, except they don't generate a result.
3137//
Evan Cheng950aac02007-09-25 01:57:46 +00003138let Defs = [EFLAGS] in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003139let isCommutable = 1 in { // TEST X, Y --> TEST Y, X
Evan Chengb783fa32007-07-19 01:14:50 +00003140def TEST8rr : I<0x84, MRMDestReg, (outs), (ins GR8:$src1, GR8:$src2),
Evan Cheng621216e2007-09-29 00:00:36 +00003141 "test{b}\t{$src2, $src1|$src1, $src2}",
Chris Lattner21da6382008-02-19 17:37:35 +00003142 [(X86cmp (and_su GR8:$src1, GR8:$src2), 0),
Evan Cheng621216e2007-09-29 00:00:36 +00003143 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00003144def TEST16rr : I<0x85, MRMDestReg, (outs), (ins GR16:$src1, GR16:$src2),
Evan Cheng621216e2007-09-29 00:00:36 +00003145 "test{w}\t{$src2, $src1|$src1, $src2}",
Chris Lattner21da6382008-02-19 17:37:35 +00003146 [(X86cmp (and_su GR16:$src1, GR16:$src2), 0),
Evan Cheng621216e2007-09-29 00:00:36 +00003147 (implicit EFLAGS)]>,
3148 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00003149def TEST32rr : I<0x85, MRMDestReg, (outs), (ins GR32:$src1, GR32:$src2),
Evan Cheng621216e2007-09-29 00:00:36 +00003150 "test{l}\t{$src2, $src1|$src1, $src2}",
Chris Lattner21da6382008-02-19 17:37:35 +00003151 [(X86cmp (and_su GR32:$src1, GR32:$src2), 0),
Evan Cheng621216e2007-09-29 00:00:36 +00003152 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003153}
3154
Sean Callanan3e4b1a32009-09-01 18:14:18 +00003155def TEST8i8 : Ii8<0xA8, RawFrm, (outs), (ins i8imm:$src),
3156 "test{b}\t{$src, %al|%al, $src}", []>;
3157def TEST16i16 : Ii16<0xA9, RawFrm, (outs), (ins i16imm:$src),
3158 "test{w}\t{$src, %ax|%ax, $src}", []>, OpSize;
3159def TEST32i32 : Ii32<0xA9, RawFrm, (outs), (ins i32imm:$src),
3160 "test{l}\t{$src, %eax|%eax, $src}", []>;
3161
Evan Chengb783fa32007-07-19 01:14:50 +00003162def TEST8rm : I<0x84, MRMSrcMem, (outs), (ins GR8 :$src1, i8mem :$src2),
Evan Cheng621216e2007-09-29 00:00:36 +00003163 "test{b}\t{$src2, $src1|$src1, $src2}",
3164 [(X86cmp (and GR8:$src1, (loadi8 addr:$src2)), 0),
3165 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00003166def TEST16rm : I<0x85, MRMSrcMem, (outs), (ins GR16:$src1, i16mem:$src2),
Evan Cheng621216e2007-09-29 00:00:36 +00003167 "test{w}\t{$src2, $src1|$src1, $src2}",
3168 [(X86cmp (and GR16:$src1, (loadi16 addr:$src2)), 0),
3169 (implicit EFLAGS)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00003170def TEST32rm : I<0x85, MRMSrcMem, (outs), (ins GR32:$src1, i32mem:$src2),
Evan Cheng621216e2007-09-29 00:00:36 +00003171 "test{l}\t{$src2, $src1|$src1, $src2}",
3172 [(X86cmp (and GR32:$src1, (loadi32 addr:$src2)), 0),
3173 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003174
3175def TEST8ri : Ii8 <0xF6, MRM0r, // flags = GR8 & imm8
Evan Chengb783fa32007-07-19 01:14:50 +00003176 (outs), (ins GR8:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00003177 "test{b}\t{$src2, $src1|$src1, $src2}",
Chris Lattner21da6382008-02-19 17:37:35 +00003178 [(X86cmp (and_su GR8:$src1, imm:$src2), 0),
Evan Cheng621216e2007-09-29 00:00:36 +00003179 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003180def TEST16ri : Ii16<0xF7, MRM0r, // flags = GR16 & imm16
Evan Chengb783fa32007-07-19 01:14:50 +00003181 (outs), (ins GR16:$src1, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00003182 "test{w}\t{$src2, $src1|$src1, $src2}",
Chris Lattner21da6382008-02-19 17:37:35 +00003183 [(X86cmp (and_su GR16:$src1, imm:$src2), 0),
Evan Cheng621216e2007-09-29 00:00:36 +00003184 (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003185def TEST32ri : Ii32<0xF7, MRM0r, // flags = GR32 & imm32
Evan Chengb783fa32007-07-19 01:14:50 +00003186 (outs), (ins GR32:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00003187 "test{l}\t{$src2, $src1|$src1, $src2}",
Chris Lattner21da6382008-02-19 17:37:35 +00003188 [(X86cmp (and_su GR32:$src1, imm:$src2), 0),
Evan Cheng621216e2007-09-29 00:00:36 +00003189 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003190
Evan Cheng621216e2007-09-29 00:00:36 +00003191def TEST8mi : Ii8 <0xF6, MRM0m, // flags = [mem8] & imm8
Evan Chengb783fa32007-07-19 01:14:50 +00003192 (outs), (ins i8mem:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00003193 "test{b}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00003194 [(X86cmp (and (loadi8 addr:$src1), imm:$src2), 0),
3195 (implicit EFLAGS)]>;
3196def TEST16mi : Ii16<0xF7, MRM0m, // flags = [mem16] & imm16
Evan Chengb783fa32007-07-19 01:14:50 +00003197 (outs), (ins i16mem:$src1, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00003198 "test{w}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00003199 [(X86cmp (and (loadi16 addr:$src1), imm:$src2), 0),
3200 (implicit EFLAGS)]>, OpSize;
3201def TEST32mi : Ii32<0xF7, MRM0m, // flags = [mem32] & imm32
Evan Chengb783fa32007-07-19 01:14:50 +00003202 (outs), (ins i32mem:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00003203 "test{l}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00003204 [(X86cmp (and (loadi32 addr:$src1), imm:$src2), 0),
Evan Cheng950aac02007-09-25 01:57:46 +00003205 (implicit EFLAGS)]>;
3206} // Defs = [EFLAGS]
3207
3208
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003209// Condition code ops, incl. set if equal/not equal/...
Chris Lattnerc90ee9c2008-01-10 07:59:24 +00003210let Defs = [EFLAGS], Uses = [AH], neverHasSideEffects = 1 in
Evan Cheng6e4d1d92007-09-11 19:55:27 +00003211def SAHF : I<0x9E, RawFrm, (outs), (ins), "sahf", []>; // flags = AH
Chris Lattnerc90ee9c2008-01-10 07:59:24 +00003212let Defs = [AH], Uses = [EFLAGS], neverHasSideEffects = 1 in
Evan Cheng6e4d1d92007-09-11 19:55:27 +00003213def LAHF : I<0x9F, RawFrm, (outs), (ins), "lahf", []>; // AH = flags
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003214
Evan Cheng950aac02007-09-25 01:57:46 +00003215let Uses = [EFLAGS] in {
Evan Cheng834ae6b2009-12-15 00:53:42 +00003216// Use sbb to materialize carry bit.
3217
3218let Defs = [EFLAGS], isCodeGenOnly = 1 in {
3219def SETB_C8r : I<0x18, MRMInitReg, (outs GR8:$dst), (ins),
3220 "sbb{b}\t$dst, $dst",
3221 [(set GR8:$dst, (X86setcc_c X86_COND_B, EFLAGS))]>;
3222def SETB_C16r : I<0x19, MRMInitReg, (outs GR16:$dst), (ins),
3223 "sbb{w}\t$dst, $dst",
Evan Chengedeb1692009-12-16 00:53:11 +00003224 [(set GR16:$dst, (X86setcc_c X86_COND_B, EFLAGS))]>,
Evan Cheng834ae6b2009-12-15 00:53:42 +00003225 OpSize;
3226def SETB_C32r : I<0x19, MRMInitReg, (outs GR32:$dst), (ins),
3227 "sbb{l}\t$dst, $dst",
Evan Chengedeb1692009-12-16 00:53:11 +00003228 [(set GR32:$dst, (X86setcc_c X86_COND_B, EFLAGS))]>;
Evan Cheng834ae6b2009-12-15 00:53:42 +00003229} // isCodeGenOnly
3230
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003231def SETEr : I<0x94, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00003232 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00003233 "sete\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00003234 [(set GR8:$dst, (X86setcc X86_COND_E, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003235 TB; // GR8 = ==
3236def SETEm : I<0x94, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00003237 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00003238 "sete\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00003239 [(store (X86setcc X86_COND_E, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003240 TB; // [mem8] = ==
Bill Wendling0c52d0a2008-12-02 00:07:05 +00003241
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003242def SETNEr : I<0x95, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00003243 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00003244 "setne\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00003245 [(set GR8:$dst, (X86setcc X86_COND_NE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003246 TB; // GR8 = !=
3247def SETNEm : I<0x95, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00003248 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00003249 "setne\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00003250 [(store (X86setcc X86_COND_NE, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003251 TB; // [mem8] = !=
Bill Wendling0c52d0a2008-12-02 00:07:05 +00003252
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003253def SETLr : I<0x9C, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00003254 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00003255 "setl\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00003256 [(set GR8:$dst, (X86setcc X86_COND_L, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003257 TB; // GR8 = < signed
3258def SETLm : I<0x9C, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00003259 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00003260 "setl\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00003261 [(store (X86setcc X86_COND_L, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003262 TB; // [mem8] = < signed
Bill Wendling0c52d0a2008-12-02 00:07:05 +00003263
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003264def SETGEr : I<0x9D, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00003265 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00003266 "setge\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00003267 [(set GR8:$dst, (X86setcc X86_COND_GE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003268 TB; // GR8 = >= signed
3269def SETGEm : I<0x9D, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00003270 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00003271 "setge\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00003272 [(store (X86setcc X86_COND_GE, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003273 TB; // [mem8] = >= signed
Bill Wendling0c52d0a2008-12-02 00:07:05 +00003274
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003275def SETLEr : I<0x9E, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00003276 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00003277 "setle\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00003278 [(set GR8:$dst, (X86setcc X86_COND_LE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003279 TB; // GR8 = <= signed
3280def SETLEm : I<0x9E, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00003281 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00003282 "setle\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00003283 [(store (X86setcc X86_COND_LE, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003284 TB; // [mem8] = <= signed
Bill Wendling0c52d0a2008-12-02 00:07:05 +00003285
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003286def SETGr : I<0x9F, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00003287 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00003288 "setg\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00003289 [(set GR8:$dst, (X86setcc X86_COND_G, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003290 TB; // GR8 = > signed
3291def SETGm : I<0x9F, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00003292 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00003293 "setg\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00003294 [(store (X86setcc X86_COND_G, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003295 TB; // [mem8] = > signed
3296
3297def SETBr : I<0x92, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00003298 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00003299 "setb\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00003300 [(set GR8:$dst, (X86setcc X86_COND_B, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003301 TB; // GR8 = < unsign
3302def SETBm : I<0x92, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00003303 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00003304 "setb\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00003305 [(store (X86setcc X86_COND_B, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003306 TB; // [mem8] = < unsign
Bill Wendling0c52d0a2008-12-02 00:07:05 +00003307
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003308def SETAEr : I<0x93, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00003309 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00003310 "setae\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00003311 [(set GR8:$dst, (X86setcc X86_COND_AE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003312 TB; // GR8 = >= unsign
3313def SETAEm : I<0x93, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00003314 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00003315 "setae\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00003316 [(store (X86setcc X86_COND_AE, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003317 TB; // [mem8] = >= unsign
Bill Wendling0c52d0a2008-12-02 00:07:05 +00003318
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003319def SETBEr : I<0x96, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00003320 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00003321 "setbe\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00003322 [(set GR8:$dst, (X86setcc X86_COND_BE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003323 TB; // GR8 = <= unsign
3324def SETBEm : I<0x96, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00003325 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00003326 "setbe\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00003327 [(store (X86setcc X86_COND_BE, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003328 TB; // [mem8] = <= unsign
Bill Wendling0c52d0a2008-12-02 00:07:05 +00003329
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003330def SETAr : I<0x97, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00003331 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00003332 "seta\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00003333 [(set GR8:$dst, (X86setcc X86_COND_A, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003334 TB; // GR8 = > signed
3335def SETAm : I<0x97, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00003336 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00003337 "seta\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00003338 [(store (X86setcc X86_COND_A, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003339 TB; // [mem8] = > signed
3340
3341def SETSr : I<0x98, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00003342 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00003343 "sets\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00003344 [(set GR8:$dst, (X86setcc X86_COND_S, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003345 TB; // GR8 = <sign bit>
3346def SETSm : I<0x98, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00003347 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00003348 "sets\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00003349 [(store (X86setcc X86_COND_S, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003350 TB; // [mem8] = <sign bit>
3351def SETNSr : I<0x99, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00003352 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00003353 "setns\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00003354 [(set GR8:$dst, (X86setcc X86_COND_NS, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003355 TB; // GR8 = !<sign bit>
3356def SETNSm : I<0x99, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00003357 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00003358 "setns\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00003359 [(store (X86setcc X86_COND_NS, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003360 TB; // [mem8] = !<sign bit>
Bill Wendling0c52d0a2008-12-02 00:07:05 +00003361
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003362def SETPr : I<0x9A, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00003363 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00003364 "setp\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00003365 [(set GR8:$dst, (X86setcc X86_COND_P, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003366 TB; // GR8 = parity
3367def SETPm : I<0x9A, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00003368 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00003369 "setp\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00003370 [(store (X86setcc X86_COND_P, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003371 TB; // [mem8] = parity
3372def SETNPr : I<0x9B, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00003373 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00003374 "setnp\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00003375 [(set GR8:$dst, (X86setcc X86_COND_NP, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003376 TB; // GR8 = not parity
3377def SETNPm : I<0x9B, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00003378 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00003379 "setnp\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00003380 [(store (X86setcc X86_COND_NP, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003381 TB; // [mem8] = not parity
Bill Wendling0c52d0a2008-12-02 00:07:05 +00003382
3383def SETOr : I<0x90, MRM0r,
3384 (outs GR8 :$dst), (ins),
3385 "seto\t$dst",
3386 [(set GR8:$dst, (X86setcc X86_COND_O, EFLAGS))]>,
3387 TB; // GR8 = overflow
3388def SETOm : I<0x90, MRM0m,
3389 (outs), (ins i8mem:$dst),
3390 "seto\t$dst",
3391 [(store (X86setcc X86_COND_O, EFLAGS), addr:$dst)]>,
3392 TB; // [mem8] = overflow
3393def SETNOr : I<0x91, MRM0r,
3394 (outs GR8 :$dst), (ins),
3395 "setno\t$dst",
3396 [(set GR8:$dst, (X86setcc X86_COND_NO, EFLAGS))]>,
3397 TB; // GR8 = not overflow
3398def SETNOm : I<0x91, MRM0m,
3399 (outs), (ins i8mem:$dst),
3400 "setno\t$dst",
3401 [(store (X86setcc X86_COND_NO, EFLAGS), addr:$dst)]>,
3402 TB; // [mem8] = not overflow
Evan Cheng950aac02007-09-25 01:57:46 +00003403} // Uses = [EFLAGS]
3404
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003405
3406// Integer comparisons
Evan Cheng55687072007-09-14 21:48:26 +00003407let Defs = [EFLAGS] in {
Sean Callanan251676e2009-09-02 00:55:49 +00003408def CMP8i8 : Ii8<0x3C, RawFrm, (outs), (ins i8imm:$src),
3409 "cmp{b}\t{$src, %al|%al, $src}", []>;
3410def CMP16i16 : Ii16<0x3D, RawFrm, (outs), (ins i16imm:$src),
3411 "cmp{w}\t{$src, %ax|%ax, $src}", []>, OpSize;
3412def CMP32i32 : Ii32<0x3D, RawFrm, (outs), (ins i32imm:$src),
3413 "cmp{l}\t{$src, %eax|%eax, $src}", []>;
3414
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003415def CMP8rr : I<0x38, MRMDestReg,
Evan Chengb783fa32007-07-19 01:14:50 +00003416 (outs), (ins GR8 :$src1, GR8 :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00003417 "cmp{b}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00003418 [(X86cmp GR8:$src1, GR8:$src2), (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003419def CMP16rr : I<0x39, MRMDestReg,
Evan Chengb783fa32007-07-19 01:14:50 +00003420 (outs), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00003421 "cmp{w}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00003422 [(X86cmp GR16:$src1, GR16:$src2), (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003423def CMP32rr : I<0x39, MRMDestReg,
Evan Chengb783fa32007-07-19 01:14:50 +00003424 (outs), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00003425 "cmp{l}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00003426 [(X86cmp GR32:$src1, GR32:$src2), (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003427def CMP8mr : I<0x38, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00003428 (outs), (ins i8mem :$src1, GR8 :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00003429 "cmp{b}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00003430 [(X86cmp (loadi8 addr:$src1), GR8:$src2),
3431 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003432def CMP16mr : I<0x39, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00003433 (outs), (ins i16mem:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00003434 "cmp{w}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00003435 [(X86cmp (loadi16 addr:$src1), GR16:$src2),
3436 (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003437def CMP32mr : I<0x39, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00003438 (outs), (ins i32mem:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00003439 "cmp{l}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00003440 [(X86cmp (loadi32 addr:$src1), GR32:$src2),
3441 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003442def CMP8rm : I<0x3A, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00003443 (outs), (ins GR8 :$src1, i8mem :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00003444 "cmp{b}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00003445 [(X86cmp GR8:$src1, (loadi8 addr:$src2)),
3446 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003447def CMP16rm : I<0x3B, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00003448 (outs), (ins GR16:$src1, i16mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00003449 "cmp{w}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00003450 [(X86cmp GR16:$src1, (loadi16 addr:$src2)),
3451 (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003452def CMP32rm : I<0x3B, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00003453 (outs), (ins GR32:$src1, i32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00003454 "cmp{l}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00003455 [(X86cmp GR32:$src1, (loadi32 addr:$src2)),
3456 (implicit EFLAGS)]>;
Sean Callanan11490dc2009-09-16 21:11:23 +00003457def CMP8mrmrr : I<0x3A, MRMSrcReg, (outs), (ins GR8:$src1, GR8:$src2),
3458 "cmp{b}\t{$src2, $src1|$src1, $src2}", []>;
3459def CMP16mrmrr : I<0x3B, MRMSrcReg, (outs), (ins GR16:$src1, GR16:$src2),
3460 "cmp{w}\t{$src2, $src1|$src1, $src2}", []>, OpSize;
3461def CMP32mrmrr : I<0x3B, MRMSrcReg, (outs), (ins GR32:$src1, GR32:$src2),
3462 "cmp{l}\t{$src2, $src1|$src1, $src2}", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003463def CMP8ri : Ii8<0x80, MRM7r,
Evan Chengb783fa32007-07-19 01:14:50 +00003464 (outs), (ins GR8:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00003465 "cmp{b}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00003466 [(X86cmp GR8:$src1, imm:$src2), (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003467def CMP16ri : Ii16<0x81, MRM7r,
Evan Chengb783fa32007-07-19 01:14:50 +00003468 (outs), (ins GR16:$src1, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00003469 "cmp{w}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00003470 [(X86cmp GR16:$src1, imm:$src2),
3471 (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003472def CMP32ri : Ii32<0x81, MRM7r,
Evan Chengb783fa32007-07-19 01:14:50 +00003473 (outs), (ins GR32:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00003474 "cmp{l}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00003475 [(X86cmp GR32:$src1, imm:$src2), (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003476def CMP8mi : Ii8 <0x80, MRM7m,
Evan Chengb783fa32007-07-19 01:14:50 +00003477 (outs), (ins i8mem :$src1, i8imm :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00003478 "cmp{b}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00003479 [(X86cmp (loadi8 addr:$src1), imm:$src2),
3480 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003481def CMP16mi : Ii16<0x81, MRM7m,
Evan Chengb783fa32007-07-19 01:14:50 +00003482 (outs), (ins i16mem:$src1, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00003483 "cmp{w}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00003484 [(X86cmp (loadi16 addr:$src1), imm:$src2),
3485 (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003486def CMP32mi : Ii32<0x81, MRM7m,
Evan Chengb783fa32007-07-19 01:14:50 +00003487 (outs), (ins i32mem:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00003488 "cmp{l}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00003489 [(X86cmp (loadi32 addr:$src1), imm:$src2),
3490 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003491def CMP16ri8 : Ii8<0x83, MRM7r,
Evan Chengb783fa32007-07-19 01:14:50 +00003492 (outs), (ins GR16:$src1, i16i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00003493 "cmp{w}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00003494 [(X86cmp GR16:$src1, i16immSExt8:$src2),
3495 (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003496def CMP16mi8 : Ii8<0x83, MRM7m,
Evan Chengb783fa32007-07-19 01:14:50 +00003497 (outs), (ins i16mem:$src1, i16i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00003498 "cmp{w}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00003499 [(X86cmp (loadi16 addr:$src1), i16immSExt8:$src2),
3500 (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003501def CMP32mi8 : Ii8<0x83, MRM7m,
Evan Chengb783fa32007-07-19 01:14:50 +00003502 (outs), (ins i32mem:$src1, i32i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00003503 "cmp{l}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00003504 [(X86cmp (loadi32 addr:$src1), i32immSExt8:$src2),
3505 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003506def CMP32ri8 : Ii8<0x83, MRM7r,
Evan Chengb783fa32007-07-19 01:14:50 +00003507 (outs), (ins GR32:$src1, i32i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00003508 "cmp{l}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00003509 [(X86cmp GR32:$src1, i32immSExt8:$src2),
Evan Cheng950aac02007-09-25 01:57:46 +00003510 (implicit EFLAGS)]>;
3511} // Defs = [EFLAGS]
3512
Dan Gohman7fe9b7f2008-12-23 22:45:23 +00003513// Bit tests.
Dan Gohman7fe9b7f2008-12-23 22:45:23 +00003514// TODO: BTC, BTR, and BTS
3515let Defs = [EFLAGS] in {
Dan Gohmanfc4eddb2009-01-13 20:32:45 +00003516def BT16rr : I<0xA3, MRMDestReg, (outs), (ins GR16:$src1, GR16:$src2),
Dan Gohman7fe9b7f2008-12-23 22:45:23 +00003517 "bt{w}\t{$src2, $src1|$src1, $src2}",
3518 [(X86bt GR16:$src1, GR16:$src2),
Chris Lattner5a95cde2008-12-25 01:32:49 +00003519 (implicit EFLAGS)]>, OpSize, TB;
Dan Gohmanfc4eddb2009-01-13 20:32:45 +00003520def BT32rr : I<0xA3, MRMDestReg, (outs), (ins GR32:$src1, GR32:$src2),
Dan Gohman7fe9b7f2008-12-23 22:45:23 +00003521 "bt{l}\t{$src2, $src1|$src1, $src2}",
3522 [(X86bt GR32:$src1, GR32:$src2),
Chris Lattner5a95cde2008-12-25 01:32:49 +00003523 (implicit EFLAGS)]>, TB;
Dan Gohman85a228c2009-01-13 23:23:30 +00003524
3525// Unlike with the register+register form, the memory+register form of the
3526// bt instruction does not ignore the high bits of the index. From ISel's
Sean Callanan2c48df22009-12-18 00:01:26 +00003527// perspective, this is pretty bizarre. Make these instructions disassembly
3528// only for now.
3529
3530def BT16mr : I<0xA3, MRMDestMem, (outs), (ins i16mem:$src1, GR16:$src2),
3531 "bt{w}\t{$src2, $src1|$src1, $src2}",
Dan Gohman85a228c2009-01-13 23:23:30 +00003532// [(X86bt (loadi16 addr:$src1), GR16:$src2),
Sean Callanan2c48df22009-12-18 00:01:26 +00003533// (implicit EFLAGS)]
3534 []
3535 >, OpSize, TB, Requires<[FastBTMem]>;
3536def BT32mr : I<0xA3, MRMDestMem, (outs), (ins i32mem:$src1, GR32:$src2),
3537 "bt{l}\t{$src2, $src1|$src1, $src2}",
Dan Gohman85a228c2009-01-13 23:23:30 +00003538// [(X86bt (loadi32 addr:$src1), GR32:$src2),
Sean Callanan2c48df22009-12-18 00:01:26 +00003539// (implicit EFLAGS)]
3540 []
3541 >, TB, Requires<[FastBTMem]>;
Dan Gohman46fb1cf2009-01-13 20:33:23 +00003542
3543def BT16ri8 : Ii8<0xBA, MRM4r, (outs), (ins GR16:$src1, i16i8imm:$src2),
3544 "bt{w}\t{$src2, $src1|$src1, $src2}",
3545 [(X86bt GR16:$src1, i16immSExt8:$src2),
3546 (implicit EFLAGS)]>, OpSize, TB;
3547def BT32ri8 : Ii8<0xBA, MRM4r, (outs), (ins GR32:$src1, i32i8imm:$src2),
3548 "bt{l}\t{$src2, $src1|$src1, $src2}",
3549 [(X86bt GR32:$src1, i32immSExt8:$src2),
3550 (implicit EFLAGS)]>, TB;
3551// Note that these instructions don't need FastBTMem because that
3552// only applies when the other operand is in a register. When it's
3553// an immediate, bt is still fast.
3554def BT16mi8 : Ii8<0xBA, MRM4m, (outs), (ins i16mem:$src1, i16i8imm:$src2),
3555 "bt{w}\t{$src2, $src1|$src1, $src2}",
3556 [(X86bt (loadi16 addr:$src1), i16immSExt8:$src2),
3557 (implicit EFLAGS)]>, OpSize, TB;
3558def BT32mi8 : Ii8<0xBA, MRM4m, (outs), (ins i32mem:$src1, i32i8imm:$src2),
3559 "bt{l}\t{$src2, $src1|$src1, $src2}",
3560 [(X86bt (loadi32 addr:$src1), i32immSExt8:$src2),
3561 (implicit EFLAGS)]>, TB;
Sean Callanan2c48df22009-12-18 00:01:26 +00003562
3563def BTC16rr : I<0xBB, MRMDestReg, (outs), (ins GR16:$src1, GR16:$src2),
3564 "btc{w}\t{$src2, $src1|$src1, $src2}", []>, OpSize, TB;
3565def BTC32rr : I<0xBB, MRMDestReg, (outs), (ins GR32:$src1, GR32:$src2),
3566 "btc{l}\t{$src2, $src1|$src1, $src2}", []>, TB;
3567def BTC16mr : I<0xBB, MRMDestMem, (outs), (ins i16mem:$src1, GR16:$src2),
3568 "btc{w}\t{$src2, $src1|$src1, $src2}", []>, OpSize, TB;
3569def BTC32mr : I<0xBB, MRMDestMem, (outs), (ins i32mem:$src1, GR32:$src2),
3570 "btc{l}\t{$src2, $src1|$src1, $src2}", []>, TB;
3571def BTC16ri8 : Ii8<0xBA, MRM7r, (outs), (ins GR16:$src1, i16i8imm:$src2),
3572 "btc{w}\t{$src2, $src1|$src1, $src2}", []>, OpSize, TB;
3573def BTC32ri8 : Ii8<0xBA, MRM7r, (outs), (ins GR32:$src1, i32i8imm:$src2),
3574 "btc{l}\t{$src2, $src1|$src1, $src2}", []>, TB;
3575def BTC16mi8 : Ii8<0xBA, MRM7m, (outs), (ins i16mem:$src1, i16i8imm:$src2),
3576 "btc{w}\t{$src2, $src1|$src1, $src2}", []>, OpSize, TB;
3577def BTC32mi8 : Ii8<0xBA, MRM7m, (outs), (ins i32mem:$src1, i32i8imm:$src2),
3578 "btc{l}\t{$src2, $src1|$src1, $src2}", []>, TB;
3579
3580def BTR16rr : I<0xB3, MRMDestReg, (outs), (ins GR16:$src1, GR16:$src2),
3581 "btr{w}\t{$src2, $src1|$src1, $src2}", []>, OpSize, TB;
3582def BTR32rr : I<0xB3, MRMDestReg, (outs), (ins GR32:$src1, GR32:$src2),
3583 "btr{l}\t{$src2, $src1|$src1, $src2}", []>, TB;
3584def BTR16mr : I<0xB3, MRMDestMem, (outs), (ins i16mem:$src1, GR16:$src2),
3585 "btr{w}\t{$src2, $src1|$src1, $src2}", []>, OpSize, TB;
3586def BTR32mr : I<0xB3, MRMDestMem, (outs), (ins i32mem:$src1, GR32:$src2),
3587 "btr{l}\t{$src2, $src1|$src1, $src2}", []>, TB;
3588def BTR16ri8 : Ii8<0xBA, MRM6r, (outs), (ins GR16:$src1, i16i8imm:$src2),
3589 "btr{w}\t{$src2, $src1|$src1, $src2}", []>, OpSize, TB;
3590def BTR32ri8 : Ii8<0xBA, MRM6r, (outs), (ins GR32:$src1, i32i8imm:$src2),
3591 "btr{l}\t{$src2, $src1|$src1, $src2}", []>, TB;
3592def BTR16mi8 : Ii8<0xBA, MRM6m, (outs), (ins i16mem:$src1, i16i8imm:$src2),
3593 "btr{w}\t{$src2, $src1|$src1, $src2}", []>, OpSize, TB;
3594def BTR32mi8 : Ii8<0xBA, MRM6m, (outs), (ins i32mem:$src1, i32i8imm:$src2),
3595 "btr{l}\t{$src2, $src1|$src1, $src2}", []>, TB;
3596
3597def BTS16rr : I<0xAB, MRMDestReg, (outs), (ins GR16:$src1, GR16:$src2),
3598 "bts{w}\t{$src2, $src1|$src1, $src2}", []>, OpSize, TB;
3599def BTS32rr : I<0xAB, MRMDestReg, (outs), (ins GR32:$src1, GR32:$src2),
3600 "bts{l}\t{$src2, $src1|$src1, $src2}", []>, TB;
3601def BTS16mr : I<0xAB, MRMDestMem, (outs), (ins i16mem:$src1, GR16:$src2),
3602 "bts{w}\t{$src2, $src1|$src1, $src2}", []>, OpSize, TB;
3603def BTS32mr : I<0xAB, MRMDestMem, (outs), (ins i32mem:$src1, GR32:$src2),
3604 "bts{l}\t{$src2, $src1|$src1, $src2}", []>, TB;
3605def BTS16ri8 : Ii8<0xBA, MRM5r, (outs), (ins GR16:$src1, i16i8imm:$src2),
3606 "bts{w}\t{$src2, $src1|$src1, $src2}", []>, OpSize, TB;
3607def BTS32ri8 : Ii8<0xBA, MRM5r, (outs), (ins GR32:$src1, i32i8imm:$src2),
3608 "bts{l}\t{$src2, $src1|$src1, $src2}", []>, TB;
3609def BTS16mi8 : Ii8<0xBA, MRM5m, (outs), (ins i16mem:$src1, i16i8imm:$src2),
3610 "bts{w}\t{$src2, $src1|$src1, $src2}", []>, OpSize, TB;
3611def BTS32mi8 : Ii8<0xBA, MRM5m, (outs), (ins i32mem:$src1, i32i8imm:$src2),
3612 "bts{l}\t{$src2, $src1|$src1, $src2}", []>, TB;
Dan Gohman7fe9b7f2008-12-23 22:45:23 +00003613} // Defs = [EFLAGS]
3614
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003615// Sign/Zero extenders
Dan Gohman9203ab42008-07-30 18:09:17 +00003616// Use movsbl intead of movsbw; we don't care about the high 16 bits
3617// of the register here. This has a smaller encoding and avoids a
Sean Callanan2c48df22009-12-18 00:01:26 +00003618// partial-register update. Actual movsbw included for the disassembler.
3619def MOVSX16rr8W : I<0xBE, MRMSrcReg, (outs GR16:$dst), (ins GR8:$src),
3620 "movs{bw|x}\t{$src, $dst|$dst, $src}", []>, TB, OpSize;
3621def MOVSX16rm8W : I<0xBE, MRMSrcMem, (outs GR16:$dst), (ins i8mem:$src),
3622 "movs{bw|x}\t{$src, $dst|$dst, $src}", []>, TB, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00003623def MOVSX16rr8 : I<0xBE, MRMSrcReg, (outs GR16:$dst), (ins GR8 :$src),
Chris Lattnerbe7efcc2009-10-19 19:51:42 +00003624 "", [(set GR16:$dst, (sext GR8:$src))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00003625def MOVSX16rm8 : I<0xBE, MRMSrcMem, (outs GR16:$dst), (ins i8mem :$src),
Chris Lattnerbe7efcc2009-10-19 19:51:42 +00003626 "", [(set GR16:$dst, (sextloadi16i8 addr:$src))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00003627def MOVSX32rr8 : I<0xBE, MRMSrcReg, (outs GR32:$dst), (ins GR8 :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00003628 "movs{bl|x}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003629 [(set GR32:$dst, (sext GR8:$src))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00003630def MOVSX32rm8 : I<0xBE, MRMSrcMem, (outs GR32:$dst), (ins i8mem :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00003631 "movs{bl|x}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003632 [(set GR32:$dst, (sextloadi32i8 addr:$src))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00003633def MOVSX32rr16: I<0xBF, MRMSrcReg, (outs GR32:$dst), (ins GR16:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00003634 "movs{wl|x}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003635 [(set GR32:$dst, (sext GR16:$src))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00003636def MOVSX32rm16: I<0xBF, MRMSrcMem, (outs GR32:$dst), (ins i16mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00003637 "movs{wl|x}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003638 [(set GR32:$dst, (sextloadi32i16 addr:$src))]>, TB;
3639
Dan Gohman9203ab42008-07-30 18:09:17 +00003640// Use movzbl intead of movzbw; we don't care about the high 16 bits
3641// of the register here. This has a smaller encoding and avoids a
Sean Callanan2c48df22009-12-18 00:01:26 +00003642// partial-register update. Actual movzbw included for the disassembler.
3643def MOVZX16rr8W : I<0xB6, MRMSrcReg, (outs GR16:$dst), (ins GR8:$src),
3644 "movz{bw|x}\t{$src, $dst|$dst, $src}", []>, TB, OpSize;
3645def MOVZX16rm8W : I<0xB6, MRMSrcMem, (outs GR16:$dst), (ins i8mem:$src),
3646 "movz{bw|x}\t{$src, $dst|$dst, $src}", []>, TB, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00003647def MOVZX16rr8 : I<0xB6, MRMSrcReg, (outs GR16:$dst), (ins GR8 :$src),
Chris Lattnerbe7efcc2009-10-19 19:51:42 +00003648 "", [(set GR16:$dst, (zext GR8:$src))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00003649def MOVZX16rm8 : I<0xB6, MRMSrcMem, (outs GR16:$dst), (ins i8mem :$src),
Chris Lattnerbe7efcc2009-10-19 19:51:42 +00003650 "", [(set GR16:$dst, (zextloadi16i8 addr:$src))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00003651def MOVZX32rr8 : I<0xB6, MRMSrcReg, (outs GR32:$dst), (ins GR8 :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00003652 "movz{bl|x}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003653 [(set GR32:$dst, (zext GR8:$src))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00003654def MOVZX32rm8 : I<0xB6, MRMSrcMem, (outs GR32:$dst), (ins i8mem :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00003655 "movz{bl|x}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003656 [(set GR32:$dst, (zextloadi32i8 addr:$src))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00003657def MOVZX32rr16: I<0xB7, MRMSrcReg, (outs GR32:$dst), (ins GR16:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00003658 "movz{wl|x}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003659 [(set GR32:$dst, (zext GR16:$src))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00003660def MOVZX32rm16: I<0xB7, MRMSrcMem, (outs GR32:$dst), (ins i16mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00003661 "movz{wl|x}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003662 [(set GR32:$dst, (zextloadi32i16 addr:$src))]>, TB;
3663
Dan Gohman744d4622009-04-13 16:09:41 +00003664// These are the same as the regular regular MOVZX32rr8 and MOVZX32rm8
3665// except that they use GR32_NOREX for the output operand register class
3666// instead of GR32. This allows them to operate on h registers on x86-64.
3667def MOVZX32_NOREXrr8 : I<0xB6, MRMSrcReg,
3668 (outs GR32_NOREX:$dst), (ins GR8:$src),
3669 "movz{bl|x}\t{$src, $dst|$dst, $src} # NOREX",
3670 []>, TB;
Dan Gohman89f4cda2009-04-30 03:11:48 +00003671let mayLoad = 1 in
Dan Gohman744d4622009-04-13 16:09:41 +00003672def MOVZX32_NOREXrm8 : I<0xB6, MRMSrcMem,
3673 (outs GR32_NOREX:$dst), (ins i8mem:$src),
3674 "movz{bl|x}\t{$src, $dst|$dst, $src} # NOREX",
3675 []>, TB;
3676
Chris Lattnerc90ee9c2008-01-10 07:59:24 +00003677let neverHasSideEffects = 1 in {
3678 let Defs = [AX], Uses = [AL] in
3679 def CBW : I<0x98, RawFrm, (outs), (ins),
3680 "{cbtw|cbw}", []>, OpSize; // AX = signext(AL)
3681 let Defs = [EAX], Uses = [AX] in
3682 def CWDE : I<0x98, RawFrm, (outs), (ins),
3683 "{cwtl|cwde}", []>; // EAX = signext(AX)
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003684
Chris Lattnerc90ee9c2008-01-10 07:59:24 +00003685 let Defs = [AX,DX], Uses = [AX] in
3686 def CWD : I<0x99, RawFrm, (outs), (ins),
3687 "{cwtd|cwd}", []>, OpSize; // DX:AX = signext(AX)
3688 let Defs = [EAX,EDX], Uses = [EAX] in
3689 def CDQ : I<0x99, RawFrm, (outs), (ins),
3690 "{cltd|cdq}", []>; // EDX:EAX = signext(EAX)
3691}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003692
3693//===----------------------------------------------------------------------===//
3694// Alias Instructions
3695//===----------------------------------------------------------------------===//
3696
3697// Alias instructions that map movr0 to xor.
3698// FIXME: remove when we can teach regalloc that xor reg, reg is ok.
Daniel Dunbara0e62002009-08-11 22:17:52 +00003699let Defs = [EFLAGS], isReMaterializable = 1, isAsCheapAsAMove = 1,
3700 isCodeGenOnly = 1 in {
Evan Chengb783fa32007-07-19 01:14:50 +00003701def MOV8r0 : I<0x30, MRMInitReg, (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00003702 "xor{b}\t$dst, $dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003703 [(set GR8:$dst, 0)]>;
Dan Gohman9203ab42008-07-30 18:09:17 +00003704// Use xorl instead of xorw since we don't care about the high 16 bits,
3705// it's smaller, and it avoids a partial-register update.
Chris Lattnerbe7efcc2009-10-19 19:51:42 +00003706def MOV16r0 : I<0x31, MRMInitReg, (outs GR16:$dst), (ins),
3707 "", [(set GR16:$dst, 0)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00003708def MOV32r0 : I<0x31, MRMInitReg, (outs GR32:$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00003709 "xor{l}\t$dst, $dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003710 [(set GR32:$dst, 0)]>;
Dan Gohman8aef09b2007-09-07 21:32:51 +00003711}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003712
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003713//===----------------------------------------------------------------------===//
3714// Thread Local Storage Instructions
3715//
3716
Rafael Espindola7fc4b8d2009-04-24 12:59:40 +00003717// All calls clobber the non-callee saved registers. ESP is marked as
3718// a use to prevent stack-pointer assignments that appear immediately
3719// before calls from potentially appearing dead.
3720let Defs = [EAX, ECX, EDX, FP0, FP1, FP2, FP3, FP4, FP5, FP6, ST0,
3721 MM0, MM1, MM2, MM3, MM4, MM5, MM6, MM7,
3722 XMM0, XMM1, XMM2, XMM3, XMM4, XMM5, XMM6, XMM7,
3723 XMM8, XMM9, XMM10, XMM11, XMM12, XMM13, XMM14, XMM15, EFLAGS],
Chris Lattnerf1940742009-06-20 20:38:48 +00003724 Uses = [ESP] in
3725def TLS_addr32 : I<0, Pseudo, (outs), (ins lea32mem:$sym),
3726 "leal\t$sym, %eax; "
Dan Gohman70a8a112009-04-27 15:13:28 +00003727 "call\t___tls_get_addr@PLT",
Chris Lattnerf1940742009-06-20 20:38:48 +00003728 [(X86tlsaddr tls32addr:$sym)]>,
Rafael Espindolaaf759ab2009-04-17 14:35:58 +00003729 Requires<[In32BitMode]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003730
Daniel Dunbar75a07302009-08-11 22:24:40 +00003731let AddedComplexity = 5, isCodeGenOnly = 1 in
sampo9cc09a32009-01-26 01:24:32 +00003732def GS_MOV32rm : I<0x8B, MRMSrcMem, (outs GR32:$dst), (ins i32mem:$src),
3733 "movl\t%gs:$src, $dst",
3734 [(set GR32:$dst, (gsload addr:$src))]>, SegGS;
3735
Daniel Dunbar75a07302009-08-11 22:24:40 +00003736let AddedComplexity = 5, isCodeGenOnly = 1 in
Chris Lattnera7c2d8a2009-05-05 18:52:19 +00003737def FS_MOV32rm : I<0x8B, MRMSrcMem, (outs GR32:$dst), (ins i32mem:$src),
3738 "movl\t%fs:$src, $dst",
3739 [(set GR32:$dst, (fsload addr:$src))]>, SegFS;
3740
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003741//===----------------------------------------------------------------------===//
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003742// EH Pseudo Instructions
3743//
3744let isTerminator = 1, isReturn = 1, isBarrier = 1,
Daniel Dunbar75513bd2009-08-27 07:58:05 +00003745 hasCtrlDep = 1, isCodeGenOnly = 1 in {
Evan Chengb783fa32007-07-19 01:14:50 +00003746def EH_RETURN : I<0xC3, RawFrm, (outs), (ins GR32:$addr),
Dan Gohman91888f02007-07-31 20:11:57 +00003747 "ret\t#eh_return, addr: $addr",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003748 [(X86ehret GR32:$addr)]>;
3749
3750}
3751
3752//===----------------------------------------------------------------------===//
Andrew Lenharthe44f3902008-02-21 06:45:13 +00003753// Atomic support
3754//
Andrew Lenharth7a5a4b22008-03-01 13:37:02 +00003755
Evan Cheng3e171562008-04-19 01:20:30 +00003756// Atomic swap. These are just normal xchg instructions. But since a memory
3757// operand is referenced, the atomicity is ensured.
Dan Gohmana41a1c092008-08-06 15:52:50 +00003758let Constraints = "$val = $dst" in {
Sean Callanan2c48df22009-12-18 00:01:26 +00003759def XCHG32rm : I<0x87, MRMSrcMem, (outs GR32:$dst),
3760 (ins GR32:$val, i32mem:$ptr),
Evan Cheng3e171562008-04-19 01:20:30 +00003761 "xchg{l}\t{$val, $ptr|$ptr, $val}",
3762 [(set GR32:$dst, (atomic_swap_32 addr:$ptr, GR32:$val))]>;
Sean Callanan2c48df22009-12-18 00:01:26 +00003763def XCHG16rm : I<0x87, MRMSrcMem, (outs GR16:$dst),
3764 (ins GR16:$val, i16mem:$ptr),
Evan Cheng3e171562008-04-19 01:20:30 +00003765 "xchg{w}\t{$val, $ptr|$ptr, $val}",
3766 [(set GR16:$dst, (atomic_swap_16 addr:$ptr, GR16:$val))]>,
3767 OpSize;
Sean Callanan2c48df22009-12-18 00:01:26 +00003768def XCHG8rm : I<0x86, MRMSrcMem, (outs GR8:$dst), (ins GR8:$val, i8mem:$ptr),
Evan Cheng3e171562008-04-19 01:20:30 +00003769 "xchg{b}\t{$val, $ptr|$ptr, $val}",
3770 [(set GR8:$dst, (atomic_swap_8 addr:$ptr, GR8:$val))]>;
Sean Callanan2c48df22009-12-18 00:01:26 +00003771
3772def XCHG32rr : I<0x87, MRMSrcReg, (outs GR32:$dst), (ins GR32:$val, GR32:$src),
3773 "xchg{l}\t{$val, $src|$src, $val}", []>;
3774def XCHG16rr : I<0x87, MRMSrcReg, (outs GR16:$dst), (ins GR16:$val, GR16:$src),
3775 "xchg{w}\t{$val, $src|$src, $val}", []>, OpSize;
3776def XCHG8rr : I<0x86, MRMSrcReg, (outs GR8:$dst), (ins GR8:$val, GR8:$src),
3777 "xchg{b}\t{$val, $src|$src, $val}", []>;
Evan Cheng3e171562008-04-19 01:20:30 +00003778}
3779
Sean Callanan2c48df22009-12-18 00:01:26 +00003780def XCHG16ar : I<0x90, AddRegFrm, (outs), (ins GR16:$src),
3781 "xchg{w}\t{$src, %ax|%ax, $src}", []>, OpSize;
3782def XCHG32ar : I<0x90, AddRegFrm, (outs), (ins GR32:$src),
3783 "xchg{l}\t{$src, %eax|%eax, $src}", []>;
3784
Evan Chengd49dbb82008-04-18 20:55:36 +00003785// Atomic compare and swap.
Andrew Lenharth7dfe23f2008-03-01 21:52:34 +00003786let Defs = [EAX, EFLAGS], Uses = [EAX] in {
Evan Chengd49dbb82008-04-18 20:55:36 +00003787def LCMPXCHG32 : I<0xB1, MRMDestMem, (outs), (ins i32mem:$ptr, GR32:$swap),
Dan Gohman70a8a112009-04-27 15:13:28 +00003788 "lock\n\t"
3789 "cmpxchg{l}\t{$swap, $ptr|$ptr, $swap}",
Evan Cheng09fbdee2008-03-04 03:20:06 +00003790 [(X86cas addr:$ptr, GR32:$swap, 4)]>, TB, LOCK;
Andrew Lenharth7a5a4b22008-03-01 13:37:02 +00003791}
Dale Johannesenf160d802008-10-02 18:53:47 +00003792let Defs = [EAX, EDX, EFLAGS], Uses = [EAX, EBX, ECX, EDX] in {
Anton Korobeynikovc4067392008-07-22 16:22:48 +00003793def LCMPXCHG8B : I<0xC7, MRM1m, (outs), (ins i32mem:$ptr),
Dan Gohman70a8a112009-04-27 15:13:28 +00003794 "lock\n\t"
3795 "cmpxchg8b\t$ptr",
Andrew Lenharth81580822008-03-05 01:15:49 +00003796 [(X86cas8 addr:$ptr)]>, TB, LOCK;
3797}
Andrew Lenharth7dfe23f2008-03-01 21:52:34 +00003798
3799let Defs = [AX, EFLAGS], Uses = [AX] in {
Evan Chengd49dbb82008-04-18 20:55:36 +00003800def LCMPXCHG16 : I<0xB1, MRMDestMem, (outs), (ins i16mem:$ptr, GR16:$swap),
Dan Gohman70a8a112009-04-27 15:13:28 +00003801 "lock\n\t"
3802 "cmpxchg{w}\t{$swap, $ptr|$ptr, $swap}",
Evan Cheng09fbdee2008-03-04 03:20:06 +00003803 [(X86cas addr:$ptr, GR16:$swap, 2)]>, TB, OpSize, LOCK;
Andrew Lenharth7a5a4b22008-03-01 13:37:02 +00003804}
Andrew Lenharth7dfe23f2008-03-01 21:52:34 +00003805let Defs = [AL, EFLAGS], Uses = [AL] in {
Evan Chengd49dbb82008-04-18 20:55:36 +00003806def LCMPXCHG8 : I<0xB0, MRMDestMem, (outs), (ins i8mem:$ptr, GR8:$swap),
Dan Gohman70a8a112009-04-27 15:13:28 +00003807 "lock\n\t"
3808 "cmpxchg{b}\t{$swap, $ptr|$ptr, $swap}",
Evan Cheng09fbdee2008-03-04 03:20:06 +00003809 [(X86cas addr:$ptr, GR8:$swap, 1)]>, TB, LOCK;
Andrew Lenharth7a5a4b22008-03-01 13:37:02 +00003810}
3811
Evan Chengd49dbb82008-04-18 20:55:36 +00003812// Atomic exchange and add
3813let Constraints = "$val = $dst", Defs = [EFLAGS] in {
Sean Callanan2c48df22009-12-18 00:01:26 +00003814def LXADD32 : I<0xC1, MRMSrcMem, (outs GR32:$dst), (ins GR32:$val, i32mem:$ptr),
Dan Gohman70a8a112009-04-27 15:13:28 +00003815 "lock\n\t"
3816 "xadd{l}\t{$val, $ptr|$ptr, $val}",
Mon P Wang6bde9ec2008-06-25 08:15:39 +00003817 [(set GR32:$dst, (atomic_load_add_32 addr:$ptr, GR32:$val))]>,
Evan Chengd49dbb82008-04-18 20:55:36 +00003818 TB, LOCK;
Sean Callanan2c48df22009-12-18 00:01:26 +00003819def LXADD16 : I<0xC1, MRMSrcMem, (outs GR16:$dst), (ins GR16:$val, i16mem:$ptr),
Dan Gohman70a8a112009-04-27 15:13:28 +00003820 "lock\n\t"
3821 "xadd{w}\t{$val, $ptr|$ptr, $val}",
Mon P Wang6bde9ec2008-06-25 08:15:39 +00003822 [(set GR16:$dst, (atomic_load_add_16 addr:$ptr, GR16:$val))]>,
Evan Chengd49dbb82008-04-18 20:55:36 +00003823 TB, OpSize, LOCK;
Sean Callanan2c48df22009-12-18 00:01:26 +00003824def LXADD8 : I<0xC0, MRMSrcMem, (outs GR8:$dst), (ins GR8:$val, i8mem:$ptr),
Dan Gohman70a8a112009-04-27 15:13:28 +00003825 "lock\n\t"
3826 "xadd{b}\t{$val, $ptr|$ptr, $val}",
Mon P Wang6bde9ec2008-06-25 08:15:39 +00003827 [(set GR8:$dst, (atomic_load_add_8 addr:$ptr, GR8:$val))]>,
Evan Chengd49dbb82008-04-18 20:55:36 +00003828 TB, LOCK;
Andrew Lenharth7a5a4b22008-03-01 13:37:02 +00003829}
3830
Sean Callanan2c48df22009-12-18 00:01:26 +00003831def XADD8rr : I<0xC0, MRMDestReg, (outs GR8:$dst), (ins GR8:$src),
3832 "xadd{b}\t{$src, $dst|$dst, $src}", []>, TB;
3833def XADD16rr : I<0xC1, MRMDestReg, (outs GR16:$dst), (ins GR16:$src),
3834 "xadd{w}\t{$src, $dst|$dst, $src}", []>, TB, OpSize;
3835def XADD32rr : I<0xC1, MRMDestReg, (outs GR32:$dst), (ins GR32:$src),
3836 "xadd{l}\t{$src, $dst|$dst, $src}", []>, TB;
3837
3838def XADD8rm : I<0xC0, MRMDestMem, (outs), (ins i8mem:$dst, GR8:$src),
3839 "xadd{b}\t{$src, $dst|$dst, $src}", []>, TB;
3840def XADD16rm : I<0xC1, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src),
3841 "xadd{w}\t{$src, $dst|$dst, $src}", []>, TB, OpSize;
3842def XADD32rm : I<0xC1, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src),
3843 "xadd{l}\t{$src, $dst|$dst, $src}", []>, TB;
3844
3845def CMPXCHG8rr : I<0xB0, MRMDestReg, (outs GR8:$dst), (ins GR8:$src),
3846 "cmpxchg{b}\t{$src, $dst|$dst, $src}", []>, TB;
3847def CMPXCHG16rr : I<0xB1, MRMDestReg, (outs GR16:$dst), (ins GR16:$src),
3848 "cmpxchg{w}\t{$src, $dst|$dst, $src}", []>, TB, OpSize;
3849def CMPXCHG32rr : I<0xB1, MRMDestReg, (outs GR32:$dst), (ins GR32:$src),
3850 "cmpxchg{l}\t{$src, $dst|$dst, $src}", []>, TB;
3851
3852def CMPXCHG8rm : I<0xB0, MRMDestMem, (outs), (ins i8mem:$dst, GR8:$src),
3853 "cmpxchg{b}\t{$src, $dst|$dst, $src}", []>, TB;
3854def CMPXCHG16rm : I<0xB1, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src),
3855 "cmpxchg{w}\t{$src, $dst|$dst, $src}", []>, TB, OpSize;
3856def CMPXCHG32rm : I<0xB1, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src),
3857 "cmpxchg{l}\t{$src, $dst|$dst, $src}", []>, TB;
3858
3859def CMPXCHG8B : I<0xC7, MRM1m, (outs), (ins i64mem:$dst),
3860 "cmpxchg8b\t$dst", []>, TB;
3861
Evan Chengb723fb52009-07-30 08:33:02 +00003862// Optimized codegen when the non-memory output is not used.
3863// FIXME: Use normal add / sub instructions and add lock prefix dynamically.
Dan Gohman1c286992009-10-20 18:14:49 +00003864let Defs = [EFLAGS] in {
Evan Chengb723fb52009-07-30 08:33:02 +00003865def LOCK_ADD8mr : I<0x00, MRMDestMem, (outs), (ins i8mem:$dst, GR8:$src2),
3866 "lock\n\t"
3867 "add{b}\t{$src2, $dst|$dst, $src2}", []>, LOCK;
3868def LOCK_ADD16mr : I<0x01, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
3869 "lock\n\t"
3870 "add{w}\t{$src2, $dst|$dst, $src2}", []>, OpSize, LOCK;
3871def LOCK_ADD32mr : I<0x01, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
3872 "lock\n\t"
3873 "add{l}\t{$src2, $dst|$dst, $src2}", []>, LOCK;
3874def LOCK_ADD8mi : Ii8<0x80, MRM0m, (outs), (ins i8mem :$dst, i8imm :$src2),
3875 "lock\n\t"
3876 "add{b}\t{$src2, $dst|$dst, $src2}", []>, LOCK;
3877def LOCK_ADD16mi : Ii16<0x81, MRM0m, (outs), (ins i16mem:$dst, i16imm:$src2),
3878 "lock\n\t"
3879 "add{w}\t{$src2, $dst|$dst, $src2}", []>, LOCK;
3880def LOCK_ADD32mi : Ii32<0x81, MRM0m, (outs), (ins i32mem:$dst, i32imm:$src2),
3881 "lock\n\t"
3882 "add{l}\t{$src2, $dst|$dst, $src2}", []>, LOCK;
3883def LOCK_ADD16mi8 : Ii8<0x83, MRM0m, (outs), (ins i16mem:$dst, i16i8imm :$src2),
3884 "lock\n\t"
3885 "add{w}\t{$src2, $dst|$dst, $src2}", []>, OpSize, LOCK;
3886def LOCK_ADD32mi8 : Ii8<0x83, MRM0m, (outs), (ins i32mem:$dst, i32i8imm :$src2),
3887 "lock\n\t"
3888 "add{l}\t{$src2, $dst|$dst, $src2}", []>, LOCK;
3889
3890def LOCK_INC8m : I<0xFE, MRM0m, (outs), (ins i8mem :$dst),
3891 "lock\n\t"
3892 "inc{b}\t$dst", []>, LOCK;
3893def LOCK_INC16m : I<0xFF, MRM0m, (outs), (ins i16mem:$dst),
3894 "lock\n\t"
3895 "inc{w}\t$dst", []>, OpSize, LOCK;
3896def LOCK_INC32m : I<0xFF, MRM0m, (outs), (ins i32mem:$dst),
3897 "lock\n\t"
3898 "inc{l}\t$dst", []>, LOCK;
3899
3900def LOCK_SUB8mr : I<0x28, MRMDestMem, (outs), (ins i8mem :$dst, GR8 :$src2),
3901 "lock\n\t"
3902 "sub{b}\t{$src2, $dst|$dst, $src2}", []>, LOCK;
3903def LOCK_SUB16mr : I<0x29, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
3904 "lock\n\t"
3905 "sub{w}\t{$src2, $dst|$dst, $src2}", []>, OpSize, LOCK;
3906def LOCK_SUB32mr : I<0x29, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
3907 "lock\n\t"
3908 "sub{l}\t{$src2, $dst|$dst, $src2}", []>, LOCK;
3909def LOCK_SUB8mi : Ii8<0x80, MRM5m, (outs), (ins i8mem :$dst, i8imm:$src2),
3910 "lock\n\t"
3911 "sub{b}\t{$src2, $dst|$dst, $src2}", []>, LOCK;
3912def LOCK_SUB16mi : Ii16<0x81, MRM5m, (outs), (ins i16mem:$dst, i16imm:$src2),
3913 "lock\n\t"
3914 "sub{w}\t{$src2, $dst|$dst, $src2}", []>, OpSize, LOCK;
3915def LOCK_SUB32mi : Ii32<0x81, MRM5m, (outs), (ins i32mem:$dst, i32imm:$src2),
3916 "lock\n\t"
3917 "sub{l}\t{$src2, $dst|$dst, $src2}", []>, LOCK;
Sean Callanan2c48df22009-12-18 00:01:26 +00003918def LOCK_SUB16mi8 : Ii8<0x83, MRM5m, (outs), (ins i16mem:$dst, i16i8imm :$src2),
Evan Chengb723fb52009-07-30 08:33:02 +00003919 "lock\n\t"
3920 "sub{w}\t{$src2, $dst|$dst, $src2}", []>, OpSize, LOCK;
3921def LOCK_SUB32mi8 : Ii8<0x83, MRM5m, (outs), (ins i32mem:$dst, i32i8imm :$src2),
3922 "lock\n\t"
3923 "sub{l}\t{$src2, $dst|$dst, $src2}", []>, LOCK;
3924
3925def LOCK_DEC8m : I<0xFE, MRM1m, (outs), (ins i8mem :$dst),
3926 "lock\n\t"
3927 "dec{b}\t$dst", []>, LOCK;
3928def LOCK_DEC16m : I<0xFF, MRM1m, (outs), (ins i16mem:$dst),
3929 "lock\n\t"
3930 "dec{w}\t$dst", []>, OpSize, LOCK;
3931def LOCK_DEC32m : I<0xFF, MRM1m, (outs), (ins i32mem:$dst),
3932 "lock\n\t"
3933 "dec{l}\t$dst", []>, LOCK;
Dan Gohman1c286992009-10-20 18:14:49 +00003934}
Evan Chengb723fb52009-07-30 08:33:02 +00003935
Mon P Wang6bde9ec2008-06-25 08:15:39 +00003936// Atomic exchange, and, or, xor
Mon P Wang078a62d2008-05-05 19:05:59 +00003937let Constraints = "$val = $dst", Defs = [EFLAGS],
Dan Gohman30afe012009-10-29 18:10:34 +00003938 usesCustomInserter = 1 in {
Dan Gohman8aeb61f2008-05-12 20:22:45 +00003939def ATOMAND32 : I<0, Pseudo, (outs GR32:$dst),(ins i32mem:$ptr, GR32:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003940 "#ATOMAND32 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003941 [(set GR32:$dst, (atomic_load_and_32 addr:$ptr, GR32:$val))]>;
Dan Gohman8aeb61f2008-05-12 20:22:45 +00003942def ATOMOR32 : I<0, Pseudo, (outs GR32:$dst),(ins i32mem:$ptr, GR32:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003943 "#ATOMOR32 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003944 [(set GR32:$dst, (atomic_load_or_32 addr:$ptr, GR32:$val))]>;
Dan Gohman8aeb61f2008-05-12 20:22:45 +00003945def ATOMXOR32 : I<0, Pseudo,(outs GR32:$dst),(ins i32mem:$ptr, GR32:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003946 "#ATOMXOR32 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003947 [(set GR32:$dst, (atomic_load_xor_32 addr:$ptr, GR32:$val))]>;
Andrew Lenharthaf02d592008-06-14 05:48:15 +00003948def ATOMNAND32 : I<0, Pseudo,(outs GR32:$dst),(ins i32mem:$ptr, GR32:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003949 "#ATOMNAND32 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003950 [(set GR32:$dst, (atomic_load_nand_32 addr:$ptr, GR32:$val))]>;
Dan Gohman8aeb61f2008-05-12 20:22:45 +00003951def ATOMMIN32: I<0, Pseudo, (outs GR32:$dst), (ins i32mem:$ptr, GR32:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003952 "#ATOMMIN32 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003953 [(set GR32:$dst, (atomic_load_min_32 addr:$ptr, GR32:$val))]>;
Dan Gohman8aeb61f2008-05-12 20:22:45 +00003954def ATOMMAX32: I<0, Pseudo, (outs GR32:$dst),(ins i32mem:$ptr, GR32:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003955 "#ATOMMAX32 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003956 [(set GR32:$dst, (atomic_load_max_32 addr:$ptr, GR32:$val))]>;
Dan Gohman8aeb61f2008-05-12 20:22:45 +00003957def ATOMUMIN32: I<0, Pseudo, (outs GR32:$dst),(ins i32mem:$ptr, GR32:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003958 "#ATOMUMIN32 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003959 [(set GR32:$dst, (atomic_load_umin_32 addr:$ptr, GR32:$val))]>;
Dan Gohman8aeb61f2008-05-12 20:22:45 +00003960def ATOMUMAX32: I<0, Pseudo, (outs GR32:$dst),(ins i32mem:$ptr, GR32:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003961 "#ATOMUMAX32 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003962 [(set GR32:$dst, (atomic_load_umax_32 addr:$ptr, GR32:$val))]>;
Dale Johannesend20e4452008-08-19 18:47:28 +00003963
3964def ATOMAND16 : I<0, Pseudo, (outs GR16:$dst),(ins i16mem:$ptr, GR16:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003965 "#ATOMAND16 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003966 [(set GR16:$dst, (atomic_load_and_16 addr:$ptr, GR16:$val))]>;
Dale Johannesend20e4452008-08-19 18:47:28 +00003967def ATOMOR16 : I<0, Pseudo, (outs GR16:$dst),(ins i16mem:$ptr, GR16:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003968 "#ATOMOR16 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003969 [(set GR16:$dst, (atomic_load_or_16 addr:$ptr, GR16:$val))]>;
Dale Johannesend20e4452008-08-19 18:47:28 +00003970def ATOMXOR16 : I<0, Pseudo,(outs GR16:$dst),(ins i16mem:$ptr, GR16:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003971 "#ATOMXOR16 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003972 [(set GR16:$dst, (atomic_load_xor_16 addr:$ptr, GR16:$val))]>;
Dale Johannesend20e4452008-08-19 18:47:28 +00003973def ATOMNAND16 : I<0, Pseudo,(outs GR16:$dst),(ins i16mem:$ptr, GR16:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003974 "#ATOMNAND16 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003975 [(set GR16:$dst, (atomic_load_nand_16 addr:$ptr, GR16:$val))]>;
Dale Johannesend20e4452008-08-19 18:47:28 +00003976def ATOMMIN16: I<0, Pseudo, (outs GR16:$dst), (ins i16mem:$ptr, GR16:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003977 "#ATOMMIN16 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003978 [(set GR16:$dst, (atomic_load_min_16 addr:$ptr, GR16:$val))]>;
Dale Johannesend20e4452008-08-19 18:47:28 +00003979def ATOMMAX16: I<0, Pseudo, (outs GR16:$dst),(ins i16mem:$ptr, GR16:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003980 "#ATOMMAX16 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003981 [(set GR16:$dst, (atomic_load_max_16 addr:$ptr, GR16:$val))]>;
Dale Johannesend20e4452008-08-19 18:47:28 +00003982def ATOMUMIN16: I<0, Pseudo, (outs GR16:$dst),(ins i16mem:$ptr, GR16:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003983 "#ATOMUMIN16 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003984 [(set GR16:$dst, (atomic_load_umin_16 addr:$ptr, GR16:$val))]>;
Dale Johannesend20e4452008-08-19 18:47:28 +00003985def ATOMUMAX16: I<0, Pseudo, (outs GR16:$dst),(ins i16mem:$ptr, GR16:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003986 "#ATOMUMAX16 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003987 [(set GR16:$dst, (atomic_load_umax_16 addr:$ptr, GR16:$val))]>;
Dale Johannesend20e4452008-08-19 18:47:28 +00003988
3989def ATOMAND8 : I<0, Pseudo, (outs GR8:$dst),(ins i8mem:$ptr, GR8:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003990 "#ATOMAND8 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003991 [(set GR8:$dst, (atomic_load_and_8 addr:$ptr, GR8:$val))]>;
Dale Johannesend20e4452008-08-19 18:47:28 +00003992def ATOMOR8 : I<0, Pseudo, (outs GR8:$dst),(ins i8mem:$ptr, GR8:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003993 "#ATOMOR8 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003994 [(set GR8:$dst, (atomic_load_or_8 addr:$ptr, GR8:$val))]>;
Dale Johannesend20e4452008-08-19 18:47:28 +00003995def ATOMXOR8 : I<0, Pseudo,(outs GR8:$dst),(ins i8mem:$ptr, GR8:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003996 "#ATOMXOR8 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003997 [(set GR8:$dst, (atomic_load_xor_8 addr:$ptr, GR8:$val))]>;
Dale Johannesend20e4452008-08-19 18:47:28 +00003998def ATOMNAND8 : I<0, Pseudo,(outs GR8:$dst),(ins i8mem:$ptr, GR8:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003999 "#ATOMNAND8 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00004000 [(set GR8:$dst, (atomic_load_nand_8 addr:$ptr, GR8:$val))]>;
Mon P Wang078a62d2008-05-05 19:05:59 +00004001}
4002
Dale Johannesenf160d802008-10-02 18:53:47 +00004003let Constraints = "$val1 = $dst1, $val2 = $dst2",
4004 Defs = [EFLAGS, EAX, EBX, ECX, EDX],
4005 Uses = [EAX, EBX, ECX, EDX],
Dale Johannesen44eb5372008-10-03 19:41:08 +00004006 mayLoad = 1, mayStore = 1,
Dan Gohman30afe012009-10-29 18:10:34 +00004007 usesCustomInserter = 1 in {
Dale Johannesenf160d802008-10-02 18:53:47 +00004008def ATOMAND6432 : I<0, Pseudo, (outs GR32:$dst1, GR32:$dst2),
4009 (ins i64mem:$ptr, GR32:$val1, GR32:$val2),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00004010 "#ATOMAND6432 PSEUDO!", []>;
Dale Johannesenf160d802008-10-02 18:53:47 +00004011def ATOMOR6432 : I<0, Pseudo, (outs GR32:$dst1, GR32:$dst2),
4012 (ins i64mem:$ptr, GR32:$val1, GR32:$val2),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00004013 "#ATOMOR6432 PSEUDO!", []>;
Dale Johannesenf160d802008-10-02 18:53:47 +00004014def ATOMXOR6432 : I<0, Pseudo, (outs GR32:$dst1, GR32:$dst2),
4015 (ins i64mem:$ptr, GR32:$val1, GR32:$val2),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00004016 "#ATOMXOR6432 PSEUDO!", []>;
Dale Johannesenf160d802008-10-02 18:53:47 +00004017def ATOMNAND6432 : I<0, Pseudo, (outs GR32:$dst1, GR32:$dst2),
4018 (ins i64mem:$ptr, GR32:$val1, GR32:$val2),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00004019 "#ATOMNAND6432 PSEUDO!", []>;
Dale Johannesenf160d802008-10-02 18:53:47 +00004020def ATOMADD6432 : I<0, Pseudo, (outs GR32:$dst1, GR32:$dst2),
4021 (ins i64mem:$ptr, GR32:$val1, GR32:$val2),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00004022 "#ATOMADD6432 PSEUDO!", []>;
Dale Johannesenf160d802008-10-02 18:53:47 +00004023def ATOMSUB6432 : I<0, Pseudo, (outs GR32:$dst1, GR32:$dst2),
4024 (ins i64mem:$ptr, GR32:$val1, GR32:$val2),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00004025 "#ATOMSUB6432 PSEUDO!", []>;
Dale Johannesen51c58ee2008-10-03 22:25:52 +00004026def ATOMSWAP6432 : I<0, Pseudo, (outs GR32:$dst1, GR32:$dst2),
4027 (ins i64mem:$ptr, GR32:$val1, GR32:$val2),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00004028 "#ATOMSWAP6432 PSEUDO!", []>;
Dale Johannesenf160d802008-10-02 18:53:47 +00004029}
4030
Sean Callanan2eddf5d2009-09-16 21:55:34 +00004031// Segmentation support instructions.
4032
4033def LAR16rm : I<0x02, MRMSrcMem, (outs GR16:$dst), (ins i16mem:$src),
4034 "lar{w}\t{$src, $dst|$dst, $src}", []>, TB, OpSize;
4035def LAR16rr : I<0x02, MRMSrcReg, (outs GR16:$dst), (ins GR16:$src),
4036 "lar{w}\t{$src, $dst|$dst, $src}", []>, TB, OpSize;
4037
4038// i16mem operand in LAR32rm and GR32 operand in LAR32rr is not a typo.
4039def LAR32rm : I<0x02, MRMSrcMem, (outs GR32:$dst), (ins i16mem:$src),
4040 "lar{l}\t{$src, $dst|$dst, $src}", []>, TB;
4041def LAR32rr : I<0x02, MRMSrcReg, (outs GR32:$dst), (ins GR32:$src),
4042 "lar{l}\t{$src, $dst|$dst, $src}", []>, TB;
Sean Callanan2c48df22009-12-18 00:01:26 +00004043
4044def LSL16rm : I<0x03, MRMSrcMem, (outs GR16:$dst), (ins i16mem:$src),
4045 "lsl{w}\t{$src, $dst|$dst, $src}", []>, TB, OpSize;
4046def LSL16rr : I<0x03, MRMSrcReg, (outs GR16:$dst), (ins GR16:$src),
4047 "lsl{w}\t{$src, $dst|$dst, $src}", []>, TB, OpSize;
4048def LSL32rm : I<0x03, MRMSrcMem, (outs GR32:$dst), (ins i32mem:$src),
4049 "lsl{l}\t{$src, $dst|$dst, $src}", []>, TB;
4050def LSL32rr : I<0x03, MRMSrcReg, (outs GR32:$dst), (ins GR32:$src),
4051 "lsl{l}\t{$src, $dst|$dst, $src}", []>, TB;
4052
4053def INVLPG : I<0x01, RawFrm, (outs), (ins), "invlpg", []>, TB;
4054
4055def STRr : I<0x00, MRM1r, (outs GR16:$dst), (ins),
4056 "str{w}\t{$dst}", []>, TB;
4057def STRm : I<0x00, MRM1m, (outs i16mem:$dst), (ins),
4058 "str{w}\t{$dst}", []>, TB;
4059def LTRr : I<0x00, MRM3r, (outs), (ins GR16:$src),
4060 "ltr{w}\t{$src}", []>, TB;
4061def LTRm : I<0x00, MRM3m, (outs), (ins i16mem:$src),
4062 "ltr{w}\t{$src}", []>, TB;
4063
4064def PUSHFS16 : I<0xa0, RawFrm, (outs), (ins),
4065 "push{w}\t%fs", []>, OpSize, TB;
4066def PUSHFS32 : I<0xa0, RawFrm, (outs), (ins),
4067 "push{l}\t%fs", []>, TB;
4068def PUSHGS16 : I<0xa8, RawFrm, (outs), (ins),
4069 "push{w}\t%gs", []>, OpSize, TB;
4070def PUSHGS32 : I<0xa8, RawFrm, (outs), (ins),
4071 "push{l}\t%gs", []>, TB;
4072
4073def POPFS16 : I<0xa1, RawFrm, (outs), (ins),
4074 "pop{w}\t%fs", []>, OpSize, TB;
4075def POPFS32 : I<0xa1, RawFrm, (outs), (ins),
4076 "pop{l}\t%fs", []>, TB;
4077def POPGS16 : I<0xa9, RawFrm, (outs), (ins),
4078 "pop{w}\t%gs", []>, OpSize, TB;
4079def POPGS32 : I<0xa9, RawFrm, (outs), (ins),
4080 "pop{l}\t%gs", []>, TB;
4081
4082def LDS16rm : I<0xc5, MRMSrcMem, (outs GR16:$dst), (ins opaque32mem:$src),
4083 "lds{w}\t{$src, $dst|$dst, $src}", []>, OpSize;
4084def LDS32rm : I<0xc5, MRMSrcMem, (outs GR32:$dst), (ins opaque48mem:$src),
4085 "lds{l}\t{$src, $dst|$dst, $src}", []>;
4086def LSS16rm : I<0xb2, MRMSrcMem, (outs GR16:$dst), (ins opaque32mem:$src),
4087 "lss{w}\t{$src, $dst|$dst, $src}", []>, TB, OpSize;
4088def LSS32rm : I<0xb2, MRMSrcMem, (outs GR32:$dst), (ins opaque48mem:$src),
4089 "lss{l}\t{$src, $dst|$dst, $src}", []>, TB;
4090def LES16rm : I<0xc4, MRMSrcMem, (outs GR16:$dst), (ins opaque32mem:$src),
4091 "les{w}\t{$src, $dst|$dst, $src}", []>, OpSize;
4092def LES32rm : I<0xc4, MRMSrcMem, (outs GR32:$dst), (ins opaque48mem:$src),
4093 "les{l}\t{$src, $dst|$dst, $src}", []>;
4094def LFS16rm : I<0xb4, MRMSrcMem, (outs GR16:$dst), (ins opaque32mem:$src),
4095 "lfs{w}\t{$src, $dst|$dst, $src}", []>, TB, OpSize;
4096def LFS32rm : I<0xb4, MRMSrcMem, (outs GR32:$dst), (ins opaque48mem:$src),
4097 "lfs{l}\t{$src, $dst|$dst, $src}", []>, TB;
4098def LGS16rm : I<0xb5, MRMSrcMem, (outs GR16:$dst), (ins opaque32mem:$src),
4099 "lgs{w}\t{$src, $dst|$dst, $src}", []>, TB, OpSize;
4100def LGS32rm : I<0xb5, MRMSrcMem, (outs GR32:$dst), (ins opaque48mem:$src),
4101 "lgs{l}\t{$src, $dst|$dst, $src}", []>, TB;
4102
4103def VERRr : I<0x00, MRM4r, (outs), (ins GR16:$seg),
4104 "verr\t$seg", []>, TB;
4105def VERRm : I<0x00, MRM4m, (outs), (ins i16mem:$seg),
4106 "verr\t$seg", []>, TB;
4107def VERWr : I<0x00, MRM5r, (outs), (ins GR16:$seg),
4108 "verw\t$seg", []>, TB;
4109def VERWm : I<0x00, MRM5m, (outs), (ins i16mem:$seg),
4110 "verw\t$seg", []>, TB;
4111
4112// Descriptor-table support instructions
4113
4114def SGDTm : I<0x01, MRM0m, (outs opaque48mem:$dst), (ins),
4115 "sgdt\t$dst", []>, TB;
4116def SIDTm : I<0x01, MRM1m, (outs opaque48mem:$dst), (ins),
4117 "sidt\t$dst", []>, TB;
4118def SLDT16r : I<0x00, MRM0r, (outs GR16:$dst), (ins),
4119 "sldt{w}\t$dst", []>, TB;
4120def SLDT16m : I<0x00, MRM0m, (outs i16mem:$dst), (ins),
4121 "sldt{w}\t$dst", []>, TB;
4122def LGDTm : I<0x01, MRM2m, (outs), (ins opaque48mem:$src),
4123 "lgdt\t$src", []>, TB;
4124def LIDTm : I<0x01, MRM3m, (outs), (ins opaque48mem:$src),
4125 "lidt\t$src", []>, TB;
4126def LLDT16r : I<0x00, MRM2r, (outs), (ins GR16:$src),
4127 "lldt{w}\t$src", []>, TB;
4128def LLDT16m : I<0x00, MRM2m, (outs), (ins i16mem:$src),
4129 "lldt{w}\t$src", []>, TB;
Sean Callanan23f33d72009-09-16 22:59:28 +00004130
4131// String manipulation instructions
4132
4133def LODSB : I<0xAC, RawFrm, (outs), (ins), "lodsb", []>;
4134def LODSW : I<0xAD, RawFrm, (outs), (ins), "lodsw", []>, OpSize;
Sean Callanan2c48df22009-12-18 00:01:26 +00004135def LODSD : I<0xAD, RawFrm, (outs), (ins), "lods{l|d}", []>;
4136
4137def OUTSB : I<0x6E, RawFrm, (outs), (ins), "outsb", []>;
4138def OUTSW : I<0x6F, RawFrm, (outs), (ins), "outsw", []>, OpSize;
4139def OUTSD : I<0x6F, RawFrm, (outs), (ins), "outs{l|d}", []>;
4140
4141// CPU flow control instructions
4142
4143def HLT : I<0xF4, RawFrm, (outs), (ins), "hlt", []>;
4144def RSM : I<0xAA, RawFrm, (outs), (ins), "rsm", []>, TB;
4145
4146// FPU control instructions
4147
4148def FNINIT : I<0xE3, RawFrm, (outs), (ins), "fninit", []>, DB;
4149
4150// Flag instructions
4151
4152def CLC : I<0xF8, RawFrm, (outs), (ins), "clc", []>;
4153def STC : I<0xF9, RawFrm, (outs), (ins), "stc", []>;
4154def CLI : I<0xFA, RawFrm, (outs), (ins), "cli", []>;
4155def STI : I<0xFB, RawFrm, (outs), (ins), "sti", []>;
4156def CLD : I<0xFC, RawFrm, (outs), (ins), "cld", []>;
4157def STD : I<0xFD, RawFrm, (outs), (ins), "std", []>;
4158def CMC : I<0xF5, RawFrm, (outs), (ins), "cmc", []>;
4159
4160def CLTS : I<0x06, RawFrm, (outs), (ins), "clts", []>, TB;
4161
4162// Table lookup instructions
4163
4164def XLAT : I<0xD7, RawFrm, (outs), (ins), "xlatb", []>;
4165
4166// Specialized register support
4167
4168def WRMSR : I<0x30, RawFrm, (outs), (ins), "wrmsr", []>, TB;
4169def RDMSR : I<0x32, RawFrm, (outs), (ins), "rdmsr", []>, TB;
4170def RDPMC : I<0x33, RawFrm, (outs), (ins), "rdpmc", []>, TB;
4171
4172def SMSW16r : I<0x01, MRM4r, (outs GR16:$dst), (ins),
4173 "smsw{w}\t$dst", []>, OpSize, TB;
4174def SMSW32r : I<0x01, MRM4r, (outs GR32:$dst), (ins),
4175 "smsw{l}\t$dst", []>, TB;
4176// For memory operands, there is only a 16-bit form
4177def SMSW16m : I<0x01, MRM4m, (outs i16mem:$dst), (ins),
4178 "smsw{w}\t$dst", []>, TB;
4179
4180def LMSW16r : I<0x01, MRM6r, (outs), (ins GR16:$src),
4181 "lmsw{w}\t$src", []>, TB;
4182def LMSW16m : I<0x01, MRM6m, (outs), (ins i16mem:$src),
4183 "lmsw{w}\t$src", []>, TB;
4184
4185def CPUID : I<0xA2, RawFrm, (outs), (ins), "cpuid", []>, TB;
4186
4187// Cache instructions
4188
4189def INVD : I<0x08, RawFrm, (outs), (ins), "invd", []>, TB;
4190def WBINVD : I<0x09, RawFrm, (outs), (ins), "wbinvd", []>, TB;
4191
4192// VMX instructions
4193
4194// 66 0F 38 80
4195def INVEPT : I<0x38, RawFrm, (outs), (ins), "invept", []>, OpSize, TB;
4196// 66 0F 38 81
4197def INVVPID : I<0x38, RawFrm, (outs), (ins), "invvpid", []>, OpSize, TB;
4198// 0F 01 C1
4199def VMCALL : I<0x01, RawFrm, (outs), (ins), "vmcall", []>, TB;
4200def VMCLEARm : I<0xC7, MRM6m, (outs), (ins i64mem:$vmcs),
4201 "vmclear\t$vmcs", []>, OpSize, TB;
4202// 0F 01 C2
4203def VMLAUNCH : I<0x01, RawFrm, (outs), (ins), "vmlaunch", []>, TB;
4204// 0F 01 C3
4205def VMRESUME : I<0x01, RawFrm, (outs), (ins), "vmresume", []>, TB;
4206def VMPTRLDm : I<0xC7, MRM6m, (outs), (ins i64mem:$vmcs),
4207 "vmptrld\t$vmcs", []>, TB;
4208def VMPTRSTm : I<0xC7, MRM7m, (outs i64mem:$vmcs), (ins),
4209 "vmptrst\t$vmcs", []>, TB;
4210def VMREAD64rm : I<0x78, MRMDestMem, (outs i64mem:$dst), (ins GR64:$src),
4211 "vmread{q}\t{$src, $dst|$dst, $src}", []>, TB;
4212def VMREAD64rr : I<0x78, MRMDestReg, (outs GR64:$dst), (ins GR64:$src),
4213 "vmread{q}\t{$src, $dst|$dst, $src}", []>, TB;
4214def VMREAD32rm : I<0x78, MRMDestMem, (outs i32mem:$dst), (ins GR32:$src),
4215 "vmread{l}\t{$src, $dst|$dst, $src}", []>, TB;
4216def VMREAD32rr : I<0x78, MRMDestReg, (outs GR32:$dst), (ins GR32:$src),
4217 "vmread{l}\t{$src, $dst|$dst, $src}", []>, TB;
4218def VMWRITE64rm : I<0x79, MRMSrcMem, (outs GR64:$dst), (ins i64mem:$src),
4219 "vmwrite{q}\t{$src, $dst|$dst, $src}", []>, TB;
4220def VMWRITE64rr : I<0x79, MRMSrcReg, (outs GR64:$dst), (ins GR64:$src),
4221 "vmwrite{q}\t{$src, $dst|$dst, $src}", []>, TB;
4222def VMWRITE32rm : I<0x79, MRMSrcMem, (outs GR32:$dst), (ins i32mem:$src),
4223 "vmwrite{l}\t{$src, $dst|$dst, $src}", []>, TB;
4224def VMWRITE32rr : I<0x79, MRMSrcReg, (outs GR32:$dst), (ins GR32:$src),
4225 "vmwrite{l}\t{$src, $dst|$dst, $src}", []>, TB;
4226// 0F 01 C4
4227def VMXOFF : I<0x01, RawFrm, (outs), (ins), "vmxoff", []>, OpSize;
4228def VMXON : I<0xC7, MRM6m, (outs), (ins i64mem:$vmxon),
4229 "vmxon\t{$vmxon}", []>, XD;
Sean Callanan2eddf5d2009-09-16 21:55:34 +00004230
Andrew Lenharthe44f3902008-02-21 06:45:13 +00004231//===----------------------------------------------------------------------===//
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004232// Non-Instruction Patterns
4233//===----------------------------------------------------------------------===//
4234
Bill Wendlingfef06052008-09-16 21:48:12 +00004235// ConstantPool GlobalAddress, ExternalSymbol, and JumpTable
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004236def : Pat<(i32 (X86Wrapper tconstpool :$dst)), (MOV32ri tconstpool :$dst)>;
4237def : Pat<(i32 (X86Wrapper tjumptable :$dst)), (MOV32ri tjumptable :$dst)>;
Nate Begemanb52948972008-04-12 00:47:57 +00004238def : Pat<(i32 (X86Wrapper tglobaltlsaddr:$dst)),(MOV32ri tglobaltlsaddr:$dst)>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004239def : Pat<(i32 (X86Wrapper tglobaladdr :$dst)), (MOV32ri tglobaladdr :$dst)>;
4240def : Pat<(i32 (X86Wrapper texternalsym:$dst)), (MOV32ri texternalsym:$dst)>;
Dan Gohman064403e2009-10-30 01:28:02 +00004241def : Pat<(i32 (X86Wrapper tblockaddress:$dst)), (MOV32ri tblockaddress:$dst)>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004242
4243def : Pat<(add GR32:$src1, (X86Wrapper tconstpool:$src2)),
4244 (ADD32ri GR32:$src1, tconstpool:$src2)>;
4245def : Pat<(add GR32:$src1, (X86Wrapper tjumptable:$src2)),
4246 (ADD32ri GR32:$src1, tjumptable:$src2)>;
4247def : Pat<(add GR32:$src1, (X86Wrapper tglobaladdr :$src2)),
4248 (ADD32ri GR32:$src1, tglobaladdr:$src2)>;
4249def : Pat<(add GR32:$src1, (X86Wrapper texternalsym:$src2)),
4250 (ADD32ri GR32:$src1, texternalsym:$src2)>;
Dan Gohman064403e2009-10-30 01:28:02 +00004251def : Pat<(add GR32:$src1, (X86Wrapper tblockaddress:$src2)),
4252 (ADD32ri GR32:$src1, tblockaddress:$src2)>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004253
4254def : Pat<(store (i32 (X86Wrapper tglobaladdr:$src)), addr:$dst),
4255 (MOV32mi addr:$dst, tglobaladdr:$src)>;
4256def : Pat<(store (i32 (X86Wrapper texternalsym:$src)), addr:$dst),
4257 (MOV32mi addr:$dst, texternalsym:$src)>;
Dan Gohman064403e2009-10-30 01:28:02 +00004258def : Pat<(store (i32 (X86Wrapper tblockaddress:$src)), addr:$dst),
4259 (MOV32mi addr:$dst, tblockaddress:$src)>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004260
4261// Calls
Arnold Schwaighofere2d6bbb2007-10-11 19:40:01 +00004262// tailcall stuff
Arnold Schwaighofere2d6bbb2007-10-11 19:40:01 +00004263def : Pat<(X86tcret GR32:$dst, imm:$off),
4264 (TCRETURNri GR32:$dst, imm:$off)>;
4265
4266def : Pat<(X86tcret (i32 tglobaladdr:$dst), imm:$off),
4267 (TCRETURNdi texternalsym:$dst, imm:$off)>;
4268
4269def : Pat<(X86tcret (i32 texternalsym:$dst), imm:$off),
4270 (TCRETURNdi texternalsym:$dst, imm:$off)>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004271
Dan Gohmance5dbff2009-08-02 16:10:01 +00004272// Normal calls, with various flavors of addresses.
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004273def : Pat<(X86call (i32 tglobaladdr:$dst)),
4274 (CALLpcrel32 tglobaladdr:$dst)>;
4275def : Pat<(X86call (i32 texternalsym:$dst)),
4276 (CALLpcrel32 texternalsym:$dst)>;
Evan Cheng6d35a4d2009-05-20 04:53:57 +00004277def : Pat<(X86call (i32 imm:$dst)),
4278 (CALLpcrel32 imm:$dst)>, Requires<[CallImmAddr]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004279
4280// X86 specific add which produces a flag.
4281def : Pat<(addc GR32:$src1, GR32:$src2),
4282 (ADD32rr GR32:$src1, GR32:$src2)>;
4283def : Pat<(addc GR32:$src1, (load addr:$src2)),
4284 (ADD32rm GR32:$src1, addr:$src2)>;
4285def : Pat<(addc GR32:$src1, imm:$src2),
4286 (ADD32ri GR32:$src1, imm:$src2)>;
4287def : Pat<(addc GR32:$src1, i32immSExt8:$src2),
4288 (ADD32ri8 GR32:$src1, i32immSExt8:$src2)>;
4289
4290def : Pat<(subc GR32:$src1, GR32:$src2),
4291 (SUB32rr GR32:$src1, GR32:$src2)>;
4292def : Pat<(subc GR32:$src1, (load addr:$src2)),
4293 (SUB32rm GR32:$src1, addr:$src2)>;
4294def : Pat<(subc GR32:$src1, imm:$src2),
4295 (SUB32ri GR32:$src1, imm:$src2)>;
4296def : Pat<(subc GR32:$src1, i32immSExt8:$src2),
4297 (SUB32ri8 GR32:$src1, i32immSExt8:$src2)>;
4298
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004299// Comparisons.
4300
4301// TEST R,R is smaller than CMP R,0
Evan Cheng621216e2007-09-29 00:00:36 +00004302def : Pat<(parallel (X86cmp GR8:$src1, 0), (implicit EFLAGS)),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004303 (TEST8rr GR8:$src1, GR8:$src1)>;
Evan Cheng621216e2007-09-29 00:00:36 +00004304def : Pat<(parallel (X86cmp GR16:$src1, 0), (implicit EFLAGS)),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004305 (TEST16rr GR16:$src1, GR16:$src1)>;
Evan Cheng621216e2007-09-29 00:00:36 +00004306def : Pat<(parallel (X86cmp GR32:$src1, 0), (implicit EFLAGS)),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004307 (TEST32rr GR32:$src1, GR32:$src1)>;
4308
Dan Gohman0a3c5222009-01-07 01:00:24 +00004309// Conditional moves with folded loads with operands swapped and conditions
4310// inverted.
4311def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_B, EFLAGS),
4312 (CMOVAE16rm GR16:$src2, addr:$src1)>;
4313def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_B, EFLAGS),
4314 (CMOVAE32rm GR32:$src2, addr:$src1)>;
4315def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_AE, EFLAGS),
4316 (CMOVB16rm GR16:$src2, addr:$src1)>;
4317def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_AE, EFLAGS),
4318 (CMOVB32rm GR32:$src2, addr:$src1)>;
4319def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_E, EFLAGS),
4320 (CMOVNE16rm GR16:$src2, addr:$src1)>;
4321def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_E, EFLAGS),
4322 (CMOVNE32rm GR32:$src2, addr:$src1)>;
4323def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_NE, EFLAGS),
4324 (CMOVE16rm GR16:$src2, addr:$src1)>;
4325def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_NE, EFLAGS),
4326 (CMOVE32rm GR32:$src2, addr:$src1)>;
4327def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_BE, EFLAGS),
4328 (CMOVA16rm GR16:$src2, addr:$src1)>;
4329def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_BE, EFLAGS),
4330 (CMOVA32rm GR32:$src2, addr:$src1)>;
4331def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_A, EFLAGS),
4332 (CMOVBE16rm GR16:$src2, addr:$src1)>;
4333def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_A, EFLAGS),
4334 (CMOVBE32rm GR32:$src2, addr:$src1)>;
4335def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_L, EFLAGS),
4336 (CMOVGE16rm GR16:$src2, addr:$src1)>;
4337def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_L, EFLAGS),
4338 (CMOVGE32rm GR32:$src2, addr:$src1)>;
4339def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_GE, EFLAGS),
4340 (CMOVL16rm GR16:$src2, addr:$src1)>;
4341def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_GE, EFLAGS),
4342 (CMOVL32rm GR32:$src2, addr:$src1)>;
4343def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_LE, EFLAGS),
4344 (CMOVG16rm GR16:$src2, addr:$src1)>;
4345def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_LE, EFLAGS),
4346 (CMOVG32rm GR32:$src2, addr:$src1)>;
4347def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_G, EFLAGS),
4348 (CMOVLE16rm GR16:$src2, addr:$src1)>;
4349def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_G, EFLAGS),
4350 (CMOVLE32rm GR32:$src2, addr:$src1)>;
4351def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_P, EFLAGS),
4352 (CMOVNP16rm GR16:$src2, addr:$src1)>;
4353def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_P, EFLAGS),
4354 (CMOVNP32rm GR32:$src2, addr:$src1)>;
4355def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_NP, EFLAGS),
4356 (CMOVP16rm GR16:$src2, addr:$src1)>;
4357def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_NP, EFLAGS),
4358 (CMOVP32rm GR32:$src2, addr:$src1)>;
4359def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_S, EFLAGS),
4360 (CMOVNS16rm GR16:$src2, addr:$src1)>;
4361def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_S, EFLAGS),
4362 (CMOVNS32rm GR32:$src2, addr:$src1)>;
4363def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_NS, EFLAGS),
4364 (CMOVS16rm GR16:$src2, addr:$src1)>;
4365def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_NS, EFLAGS),
4366 (CMOVS32rm GR32:$src2, addr:$src1)>;
4367def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_O, EFLAGS),
4368 (CMOVNO16rm GR16:$src2, addr:$src1)>;
4369def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_O, EFLAGS),
4370 (CMOVNO32rm GR32:$src2, addr:$src1)>;
4371def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_NO, EFLAGS),
4372 (CMOVO16rm GR16:$src2, addr:$src1)>;
4373def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_NO, EFLAGS),
4374 (CMOVO32rm GR32:$src2, addr:$src1)>;
4375
Duncan Sands082524c2008-01-23 20:39:46 +00004376// zextload bool -> zextload byte
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004377def : Pat<(zextloadi8i1 addr:$src), (MOV8rm addr:$src)>;
4378def : Pat<(zextloadi16i1 addr:$src), (MOVZX16rm8 addr:$src)>;
4379def : Pat<(zextloadi32i1 addr:$src), (MOVZX32rm8 addr:$src)>;
4380
4381// extload bool -> extload byte
4382def : Pat<(extloadi8i1 addr:$src), (MOV8rm addr:$src)>;
Dan Gohman9959b052009-08-26 14:59:13 +00004383def : Pat<(extloadi16i1 addr:$src), (MOVZX16rm8 addr:$src)>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004384def : Pat<(extloadi32i1 addr:$src), (MOVZX32rm8 addr:$src)>;
Dan Gohman9959b052009-08-26 14:59:13 +00004385def : Pat<(extloadi16i8 addr:$src), (MOVZX16rm8 addr:$src)>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004386def : Pat<(extloadi32i8 addr:$src), (MOVZX32rm8 addr:$src)>;
4387def : Pat<(extloadi32i16 addr:$src), (MOVZX32rm16 addr:$src)>;
4388
Dan Gohman9959b052009-08-26 14:59:13 +00004389// anyext. Define these to do an explicit zero-extend to
4390// avoid partial-register updates.
4391def : Pat<(i16 (anyext GR8 :$src)), (MOVZX16rr8 GR8 :$src)>;
4392def : Pat<(i32 (anyext GR8 :$src)), (MOVZX32rr8 GR8 :$src)>;
4393def : Pat<(i32 (anyext GR16:$src)), (MOVZX32rr16 GR16:$src)>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004394
Evan Chengf2abee72007-12-13 00:43:27 +00004395// (and (i32 load), 255) -> (zextload i8)
Evan Cheng1e5e5452008-09-29 17:26:18 +00004396def : Pat<(i32 (and (nvloadi32 addr:$src), (i32 255))),
4397 (MOVZX32rm8 addr:$src)>;
4398def : Pat<(i32 (and (nvloadi32 addr:$src), (i32 65535))),
4399 (MOVZX32rm16 addr:$src)>;
Evan Chengf2abee72007-12-13 00:43:27 +00004400
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004401//===----------------------------------------------------------------------===//
4402// Some peepholes
4403//===----------------------------------------------------------------------===//
4404
Dan Gohman5a5e6e92008-10-17 01:33:43 +00004405// Odd encoding trick: -128 fits into an 8-bit immediate field while
4406// +128 doesn't, so in this special case use a sub instead of an add.
4407def : Pat<(add GR16:$src1, 128),
4408 (SUB16ri8 GR16:$src1, -128)>;
4409def : Pat<(store (add (loadi16 addr:$dst), 128), addr:$dst),
4410 (SUB16mi8 addr:$dst, -128)>;
4411def : Pat<(add GR32:$src1, 128),
4412 (SUB32ri8 GR32:$src1, -128)>;
4413def : Pat<(store (add (loadi32 addr:$dst), 128), addr:$dst),
4414 (SUB32mi8 addr:$dst, -128)>;
4415
Dan Gohman9203ab42008-07-30 18:09:17 +00004416// r & (2^16-1) ==> movz
4417def : Pat<(and GR32:$src1, 0xffff),
Dan Gohman744d4622009-04-13 16:09:41 +00004418 (MOVZX32rr16 (EXTRACT_SUBREG GR32:$src1, x86_subreg_16bit))>;
Dan Gohman5beb1ff2008-08-06 18:27:21 +00004419// r & (2^8-1) ==> movz
4420def : Pat<(and GR32:$src1, 0xff),
Anton Korobeynikovd9331212009-11-02 00:11:39 +00004421 (MOVZX32rr8 (EXTRACT_SUBREG (i32 (COPY_TO_REGCLASS GR32:$src1,
4422 GR32_ABCD)),
Dan Gohman744d4622009-04-13 16:09:41 +00004423 x86_subreg_8bit))>,
Dan Gohman5beb1ff2008-08-06 18:27:21 +00004424 Requires<[In32BitMode]>;
4425// r & (2^8-1) ==> movz
4426def : Pat<(and GR16:$src1, 0xff),
Anton Korobeynikovd9331212009-11-02 00:11:39 +00004427 (MOVZX16rr8 (EXTRACT_SUBREG (i16 (COPY_TO_REGCLASS GR16:$src1,
4428 GR16_ABCD)),
Dan Gohman744d4622009-04-13 16:09:41 +00004429 x86_subreg_8bit))>,
Dan Gohmandd612bb2008-08-20 21:27:32 +00004430 Requires<[In32BitMode]>;
4431
4432// sext_inreg patterns
4433def : Pat<(sext_inreg GR32:$src, i16),
Dan Gohman744d4622009-04-13 16:09:41 +00004434 (MOVSX32rr16 (EXTRACT_SUBREG GR32:$src, x86_subreg_16bit))>;
Dan Gohmandd612bb2008-08-20 21:27:32 +00004435def : Pat<(sext_inreg GR32:$src, i8),
Anton Korobeynikovd9331212009-11-02 00:11:39 +00004436 (MOVSX32rr8 (EXTRACT_SUBREG (i32 (COPY_TO_REGCLASS GR32:$src,
4437 GR32_ABCD)),
Dan Gohman744d4622009-04-13 16:09:41 +00004438 x86_subreg_8bit))>,
Dan Gohmandd612bb2008-08-20 21:27:32 +00004439 Requires<[In32BitMode]>;
4440def : Pat<(sext_inreg GR16:$src, i8),
Anton Korobeynikovd9331212009-11-02 00:11:39 +00004441 (MOVSX16rr8 (EXTRACT_SUBREG (i16 (COPY_TO_REGCLASS GR16:$src,
4442 GR16_ABCD)),
Dan Gohman744d4622009-04-13 16:09:41 +00004443 x86_subreg_8bit))>,
Dan Gohmandd612bb2008-08-20 21:27:32 +00004444 Requires<[In32BitMode]>;
4445
4446// trunc patterns
4447def : Pat<(i16 (trunc GR32:$src)),
Dan Gohman744d4622009-04-13 16:09:41 +00004448 (EXTRACT_SUBREG GR32:$src, x86_subreg_16bit)>;
Dan Gohmandd612bb2008-08-20 21:27:32 +00004449def : Pat<(i8 (trunc GR32:$src)),
Anton Korobeynikovd9331212009-11-02 00:11:39 +00004450 (EXTRACT_SUBREG (i32 (COPY_TO_REGCLASS GR32:$src, GR32_ABCD)),
Dan Gohman744d4622009-04-13 16:09:41 +00004451 x86_subreg_8bit)>,
Dan Gohmandd612bb2008-08-20 21:27:32 +00004452 Requires<[In32BitMode]>;
4453def : Pat<(i8 (trunc GR16:$src)),
Anton Korobeynikovd9331212009-11-02 00:11:39 +00004454 (EXTRACT_SUBREG (i16 (COPY_TO_REGCLASS GR16:$src, GR16_ABCD)),
Dan Gohman744d4622009-04-13 16:09:41 +00004455 x86_subreg_8bit)>,
4456 Requires<[In32BitMode]>;
4457
4458// h-register tricks
4459def : Pat<(i8 (trunc (srl_su GR16:$src, (i8 8)))),
Anton Korobeynikovd9331212009-11-02 00:11:39 +00004460 (EXTRACT_SUBREG (i32 (COPY_TO_REGCLASS GR16:$src, GR16_ABCD)),
Dan Gohman744d4622009-04-13 16:09:41 +00004461 x86_subreg_8bit_hi)>,
4462 Requires<[In32BitMode]>;
4463def : Pat<(i8 (trunc (srl_su GR32:$src, (i8 8)))),
Anton Korobeynikovd9331212009-11-02 00:11:39 +00004464 (EXTRACT_SUBREG (i16 (COPY_TO_REGCLASS GR32:$src, GR32_ABCD)),
Dan Gohman744d4622009-04-13 16:09:41 +00004465 x86_subreg_8bit_hi)>,
4466 Requires<[In32BitMode]>;
4467def : Pat<(srl_su GR16:$src, (i8 8)),
4468 (EXTRACT_SUBREG
4469 (MOVZX32rr8
Anton Korobeynikovd9331212009-11-02 00:11:39 +00004470 (EXTRACT_SUBREG (i16 (COPY_TO_REGCLASS GR16:$src, GR16_ABCD)),
Dan Gohman744d4622009-04-13 16:09:41 +00004471 x86_subreg_8bit_hi)),
4472 x86_subreg_16bit)>,
4473 Requires<[In32BitMode]>;
Evan Cheng957ca282009-05-29 01:44:43 +00004474def : Pat<(i32 (zext (srl_su GR16:$src, (i8 8)))),
Sean Callanan2c48df22009-12-18 00:01:26 +00004475 (MOVZX32rr8 (EXTRACT_SUBREG (i16 (COPY_TO_REGCLASS GR16:$src,
4476 GR16_ABCD)),
Evan Cheng957ca282009-05-29 01:44:43 +00004477 x86_subreg_8bit_hi))>,
4478 Requires<[In32BitMode]>;
Dan Gohman9959b052009-08-26 14:59:13 +00004479def : Pat<(i32 (anyext (srl_su GR16:$src, (i8 8)))),
Sean Callanan2c48df22009-12-18 00:01:26 +00004480 (MOVZX32rr8 (EXTRACT_SUBREG (i16 (COPY_TO_REGCLASS GR16:$src,
4481 GR16_ABCD)),
Dan Gohman9959b052009-08-26 14:59:13 +00004482 x86_subreg_8bit_hi))>,
4483 Requires<[In32BitMode]>;
Dan Gohman744d4622009-04-13 16:09:41 +00004484def : Pat<(and (srl_su GR32:$src, (i8 8)), (i32 255)),
Sean Callanan2c48df22009-12-18 00:01:26 +00004485 (MOVZX32rr8 (EXTRACT_SUBREG (i32 (COPY_TO_REGCLASS GR32:$src,
4486 GR32_ABCD)),
Dan Gohman744d4622009-04-13 16:09:41 +00004487 x86_subreg_8bit_hi))>,
Dan Gohman5beb1ff2008-08-06 18:27:21 +00004488 Requires<[In32BitMode]>;
Dan Gohman9203ab42008-07-30 18:09:17 +00004489
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004490// (shl x, 1) ==> (add x, x)
4491def : Pat<(shl GR8 :$src1, (i8 1)), (ADD8rr GR8 :$src1, GR8 :$src1)>;
4492def : Pat<(shl GR16:$src1, (i8 1)), (ADD16rr GR16:$src1, GR16:$src1)>;
4493def : Pat<(shl GR32:$src1, (i8 1)), (ADD32rr GR32:$src1, GR32:$src1)>;
4494
Evan Cheng76a64c72008-08-30 02:03:58 +00004495// (shl x (and y, 31)) ==> (shl x, y)
4496def : Pat<(shl GR8:$src1, (and CL:$amt, 31)),
4497 (SHL8rCL GR8:$src1)>;
4498def : Pat<(shl GR16:$src1, (and CL:$amt, 31)),
4499 (SHL16rCL GR16:$src1)>;
4500def : Pat<(shl GR32:$src1, (and CL:$amt, 31)),
4501 (SHL32rCL GR32:$src1)>;
4502def : Pat<(store (shl (loadi8 addr:$dst), (and CL:$amt, 31)), addr:$dst),
4503 (SHL8mCL addr:$dst)>;
4504def : Pat<(store (shl (loadi16 addr:$dst), (and CL:$amt, 31)), addr:$dst),
4505 (SHL16mCL addr:$dst)>;
4506def : Pat<(store (shl (loadi32 addr:$dst), (and CL:$amt, 31)), addr:$dst),
4507 (SHL32mCL addr:$dst)>;
4508
4509def : Pat<(srl GR8:$src1, (and CL:$amt, 31)),
4510 (SHR8rCL GR8:$src1)>;
4511def : Pat<(srl GR16:$src1, (and CL:$amt, 31)),
4512 (SHR16rCL GR16:$src1)>;
4513def : Pat<(srl GR32:$src1, (and CL:$amt, 31)),
4514 (SHR32rCL GR32:$src1)>;
4515def : Pat<(store (srl (loadi8 addr:$dst), (and CL:$amt, 31)), addr:$dst),
4516 (SHR8mCL addr:$dst)>;
4517def : Pat<(store (srl (loadi16 addr:$dst), (and CL:$amt, 31)), addr:$dst),
4518 (SHR16mCL addr:$dst)>;
4519def : Pat<(store (srl (loadi32 addr:$dst), (and CL:$amt, 31)), addr:$dst),
4520 (SHR32mCL addr:$dst)>;
4521
4522def : Pat<(sra GR8:$src1, (and CL:$amt, 31)),
4523 (SAR8rCL GR8:$src1)>;
4524def : Pat<(sra GR16:$src1, (and CL:$amt, 31)),
4525 (SAR16rCL GR16:$src1)>;
4526def : Pat<(sra GR32:$src1, (and CL:$amt, 31)),
4527 (SAR32rCL GR32:$src1)>;
4528def : Pat<(store (sra (loadi8 addr:$dst), (and CL:$amt, 31)), addr:$dst),
4529 (SAR8mCL addr:$dst)>;
4530def : Pat<(store (sra (loadi16 addr:$dst), (and CL:$amt, 31)), addr:$dst),
4531 (SAR16mCL addr:$dst)>;
4532def : Pat<(store (sra (loadi32 addr:$dst), (and CL:$amt, 31)), addr:$dst),
4533 (SAR32mCL addr:$dst)>;
4534
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004535// (or (x >> c) | (y << (32 - c))) ==> (shrd32 x, y, c)
4536def : Pat<(or (srl GR32:$src1, CL:$amt),
4537 (shl GR32:$src2, (sub 32, CL:$amt))),
4538 (SHRD32rrCL GR32:$src1, GR32:$src2)>;
4539
4540def : Pat<(store (or (srl (loadi32 addr:$dst), CL:$amt),
4541 (shl GR32:$src2, (sub 32, CL:$amt))), addr:$dst),
4542 (SHRD32mrCL addr:$dst, GR32:$src2)>;
4543
Dan Gohman921581d2008-10-17 01:23:35 +00004544def : Pat<(or (srl GR32:$src1, (i8 (trunc ECX:$amt))),
4545 (shl GR32:$src2, (i8 (trunc (sub 32, ECX:$amt))))),
4546 (SHRD32rrCL GR32:$src1, GR32:$src2)>;
4547
4548def : Pat<(store (or (srl (loadi32 addr:$dst), (i8 (trunc ECX:$amt))),
4549 (shl GR32:$src2, (i8 (trunc (sub 32, ECX:$amt))))),
4550 addr:$dst),
4551 (SHRD32mrCL addr:$dst, GR32:$src2)>;
4552
4553def : Pat<(shrd GR32:$src1, (i8 imm:$amt1), GR32:$src2, (i8 imm:$amt2)),
4554 (SHRD32rri8 GR32:$src1, GR32:$src2, (i8 imm:$amt1))>;
4555
4556def : Pat<(store (shrd (loadi32 addr:$dst), (i8 imm:$amt1),
4557 GR32:$src2, (i8 imm:$amt2)), addr:$dst),
4558 (SHRD32mri8 addr:$dst, GR32:$src2, (i8 imm:$amt1))>;
4559
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004560// (or (x << c) | (y >> (32 - c))) ==> (shld32 x, y, c)
4561def : Pat<(or (shl GR32:$src1, CL:$amt),
4562 (srl GR32:$src2, (sub 32, CL:$amt))),
4563 (SHLD32rrCL GR32:$src1, GR32:$src2)>;
4564
4565def : Pat<(store (or (shl (loadi32 addr:$dst), CL:$amt),
4566 (srl GR32:$src2, (sub 32, CL:$amt))), addr:$dst),
4567 (SHLD32mrCL addr:$dst, GR32:$src2)>;
4568
Dan Gohman921581d2008-10-17 01:23:35 +00004569def : Pat<(or (shl GR32:$src1, (i8 (trunc ECX:$amt))),
4570 (srl GR32:$src2, (i8 (trunc (sub 32, ECX:$amt))))),
4571 (SHLD32rrCL GR32:$src1, GR32:$src2)>;
4572
4573def : Pat<(store (or (shl (loadi32 addr:$dst), (i8 (trunc ECX:$amt))),
4574 (srl GR32:$src2, (i8 (trunc (sub 32, ECX:$amt))))),
4575 addr:$dst),
4576 (SHLD32mrCL addr:$dst, GR32:$src2)>;
4577
4578def : Pat<(shld GR32:$src1, (i8 imm:$amt1), GR32:$src2, (i8 imm:$amt2)),
4579 (SHLD32rri8 GR32:$src1, GR32:$src2, (i8 imm:$amt1))>;
4580
4581def : Pat<(store (shld (loadi32 addr:$dst), (i8 imm:$amt1),
4582 GR32:$src2, (i8 imm:$amt2)), addr:$dst),
4583 (SHLD32mri8 addr:$dst, GR32:$src2, (i8 imm:$amt1))>;
4584
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004585// (or (x >> c) | (y << (16 - c))) ==> (shrd16 x, y, c)
4586def : Pat<(or (srl GR16:$src1, CL:$amt),
4587 (shl GR16:$src2, (sub 16, CL:$amt))),
4588 (SHRD16rrCL GR16:$src1, GR16:$src2)>;
4589
4590def : Pat<(store (or (srl (loadi16 addr:$dst), CL:$amt),
4591 (shl GR16:$src2, (sub 16, CL:$amt))), addr:$dst),
4592 (SHRD16mrCL addr:$dst, GR16:$src2)>;
4593
Dan Gohman921581d2008-10-17 01:23:35 +00004594def : Pat<(or (srl GR16:$src1, (i8 (trunc CX:$amt))),
4595 (shl GR16:$src2, (i8 (trunc (sub 16, CX:$amt))))),
4596 (SHRD16rrCL GR16:$src1, GR16:$src2)>;
4597
4598def : Pat<(store (or (srl (loadi16 addr:$dst), (i8 (trunc CX:$amt))),
4599 (shl GR16:$src2, (i8 (trunc (sub 16, CX:$amt))))),
4600 addr:$dst),
4601 (SHRD16mrCL addr:$dst, GR16:$src2)>;
4602
4603def : Pat<(shrd GR16:$src1, (i8 imm:$amt1), GR16:$src2, (i8 imm:$amt2)),
4604 (SHRD16rri8 GR16:$src1, GR16:$src2, (i8 imm:$amt1))>;
4605
4606def : Pat<(store (shrd (loadi16 addr:$dst), (i8 imm:$amt1),
4607 GR16:$src2, (i8 imm:$amt2)), addr:$dst),
4608 (SHRD16mri8 addr:$dst, GR16:$src2, (i8 imm:$amt1))>;
4609
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004610// (or (x << c) | (y >> (16 - c))) ==> (shld16 x, y, c)
4611def : Pat<(or (shl GR16:$src1, CL:$amt),
4612 (srl GR16:$src2, (sub 16, CL:$amt))),
4613 (SHLD16rrCL GR16:$src1, GR16:$src2)>;
4614
4615def : Pat<(store (or (shl (loadi16 addr:$dst), CL:$amt),
4616 (srl GR16:$src2, (sub 16, CL:$amt))), addr:$dst),
4617 (SHLD16mrCL addr:$dst, GR16:$src2)>;
4618
Dan Gohman921581d2008-10-17 01:23:35 +00004619def : Pat<(or (shl GR16:$src1, (i8 (trunc CX:$amt))),
4620 (srl GR16:$src2, (i8 (trunc (sub 16, CX:$amt))))),
4621 (SHLD16rrCL GR16:$src1, GR16:$src2)>;
4622
4623def : Pat<(store (or (shl (loadi16 addr:$dst), (i8 (trunc CX:$amt))),
4624 (srl GR16:$src2, (i8 (trunc (sub 16, CX:$amt))))),
4625 addr:$dst),
4626 (SHLD16mrCL addr:$dst, GR16:$src2)>;
4627
4628def : Pat<(shld GR16:$src1, (i8 imm:$amt1), GR16:$src2, (i8 imm:$amt2)),
4629 (SHLD16rri8 GR16:$src1, GR16:$src2, (i8 imm:$amt1))>;
4630
4631def : Pat<(store (shld (loadi16 addr:$dst), (i8 imm:$amt1),
4632 GR16:$src2, (i8 imm:$amt2)), addr:$dst),
4633 (SHLD16mri8 addr:$dst, GR16:$src2, (i8 imm:$amt1))>;
4634
Evan Chengedeb1692009-12-16 00:53:11 +00004635// (anyext (setcc_carry)) -> (setcc_carry)
4636def : Pat<(i16 (anyext (i8 (X86setcc_c X86_COND_B, EFLAGS)))),
Evan Cheng834ae6b2009-12-15 00:53:42 +00004637 (SETB_C16r)>;
Evan Chengedeb1692009-12-16 00:53:11 +00004638def : Pat<(i32 (anyext (i8 (X86setcc_c X86_COND_B, EFLAGS)))),
Evan Cheng834ae6b2009-12-15 00:53:42 +00004639 (SETB_C32r)>;
4640
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004641//===----------------------------------------------------------------------===//
Dan Gohman99a12192009-03-04 19:44:21 +00004642// EFLAGS-defining Patterns
Bill Wendlingf5399032008-12-12 21:15:41 +00004643//===----------------------------------------------------------------------===//
4644
Dan Gohman99a12192009-03-04 19:44:21 +00004645// Register-Register Addition with EFLAGS result
4646def : Pat<(parallel (X86add_flag GR8:$src1, GR8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004647 (implicit EFLAGS)),
4648 (ADD8rr GR8:$src1, GR8:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00004649def : Pat<(parallel (X86add_flag GR16:$src1, GR16:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004650 (implicit EFLAGS)),
4651 (ADD16rr GR16:$src1, GR16:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00004652def : Pat<(parallel (X86add_flag GR32:$src1, GR32:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004653 (implicit EFLAGS)),
4654 (ADD32rr GR32:$src1, GR32:$src2)>;
4655
Dan Gohman99a12192009-03-04 19:44:21 +00004656// Register-Memory Addition with EFLAGS result
4657def : Pat<(parallel (X86add_flag GR8:$src1, (loadi8 addr:$src2)),
Bill Wendlingf5399032008-12-12 21:15:41 +00004658 (implicit EFLAGS)),
4659 (ADD8rm GR8:$src1, addr:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00004660def : Pat<(parallel (X86add_flag GR16:$src1, (loadi16 addr:$src2)),
Bill Wendlingf5399032008-12-12 21:15:41 +00004661 (implicit EFLAGS)),
4662 (ADD16rm GR16:$src1, addr:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00004663def : Pat<(parallel (X86add_flag GR32:$src1, (loadi32 addr:$src2)),
Bill Wendlingf5399032008-12-12 21:15:41 +00004664 (implicit EFLAGS)),
4665 (ADD32rm GR32:$src1, addr:$src2)>;
4666
Dan Gohman99a12192009-03-04 19:44:21 +00004667// Register-Integer Addition with EFLAGS result
4668def : Pat<(parallel (X86add_flag GR8:$src1, imm:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004669 (implicit EFLAGS)),
4670 (ADD8ri GR8:$src1, imm:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00004671def : Pat<(parallel (X86add_flag GR16:$src1, imm:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004672 (implicit EFLAGS)),
4673 (ADD16ri GR16:$src1, imm:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00004674def : Pat<(parallel (X86add_flag GR32:$src1, imm:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004675 (implicit EFLAGS)),
4676 (ADD32ri GR32:$src1, imm:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00004677def : Pat<(parallel (X86add_flag GR16:$src1, i16immSExt8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004678 (implicit EFLAGS)),
4679 (ADD16ri8 GR16:$src1, i16immSExt8:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00004680def : Pat<(parallel (X86add_flag GR32:$src1, i32immSExt8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004681 (implicit EFLAGS)),
4682 (ADD32ri8 GR32:$src1, i32immSExt8:$src2)>;
4683
Dan Gohman99a12192009-03-04 19:44:21 +00004684// Memory-Register Addition with EFLAGS result
4685def : Pat<(parallel (store (X86add_flag (loadi8 addr:$dst), GR8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004686 addr:$dst),
4687 (implicit EFLAGS)),
4688 (ADD8mr addr:$dst, GR8:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00004689def : Pat<(parallel (store (X86add_flag (loadi16 addr:$dst), GR16:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004690 addr:$dst),
4691 (implicit EFLAGS)),
4692 (ADD16mr addr:$dst, GR16:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00004693def : Pat<(parallel (store (X86add_flag (loadi32 addr:$dst), GR32:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004694 addr:$dst),
4695 (implicit EFLAGS)),
4696 (ADD32mr addr:$dst, GR32:$src2)>;
Dale Johannesen06b83f12009-05-18 17:44:15 +00004697
4698// Memory-Integer Addition with EFLAGS result
Dan Gohman99a12192009-03-04 19:44:21 +00004699def : Pat<(parallel (store (X86add_flag (loadi8 addr:$dst), imm:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004700 addr:$dst),
4701 (implicit EFLAGS)),
4702 (ADD8mi addr:$dst, imm:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00004703def : Pat<(parallel (store (X86add_flag (loadi16 addr:$dst), imm:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004704 addr:$dst),
4705 (implicit EFLAGS)),
4706 (ADD16mi addr:$dst, imm:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00004707def : Pat<(parallel (store (X86add_flag (loadi32 addr:$dst), imm:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004708 addr:$dst),
4709 (implicit EFLAGS)),
4710 (ADD32mi addr:$dst, imm:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00004711def : Pat<(parallel (store (X86add_flag (loadi16 addr:$dst), i16immSExt8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004712 addr:$dst),
4713 (implicit EFLAGS)),
4714 (ADD16mi8 addr:$dst, i16immSExt8:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00004715def : Pat<(parallel (store (X86add_flag (loadi32 addr:$dst), i32immSExt8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004716 addr:$dst),
4717 (implicit EFLAGS)),
4718 (ADD32mi8 addr:$dst, i32immSExt8:$src2)>;
4719
Dan Gohman99a12192009-03-04 19:44:21 +00004720// Register-Register Subtraction with EFLAGS result
4721def : Pat<(parallel (X86sub_flag GR8:$src1, GR8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004722 (implicit EFLAGS)),
4723 (SUB8rr GR8:$src1, GR8:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00004724def : Pat<(parallel (X86sub_flag GR16:$src1, GR16:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004725 (implicit EFLAGS)),
4726 (SUB16rr GR16:$src1, GR16:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00004727def : Pat<(parallel (X86sub_flag GR32:$src1, GR32:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004728 (implicit EFLAGS)),
4729 (SUB32rr GR32:$src1, GR32:$src2)>;
4730
Dan Gohman99a12192009-03-04 19:44:21 +00004731// Register-Memory Subtraction with EFLAGS result
4732def : Pat<(parallel (X86sub_flag GR8:$src1, (loadi8 addr:$src2)),
Bill Wendlingf5399032008-12-12 21:15:41 +00004733 (implicit EFLAGS)),
4734 (SUB8rm GR8:$src1, addr:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00004735def : Pat<(parallel (X86sub_flag GR16:$src1, (loadi16 addr:$src2)),
Bill Wendlingf5399032008-12-12 21:15:41 +00004736 (implicit EFLAGS)),
4737 (SUB16rm GR16:$src1, addr:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00004738def : Pat<(parallel (X86sub_flag GR32:$src1, (loadi32 addr:$src2)),
Bill Wendlingf5399032008-12-12 21:15:41 +00004739 (implicit EFLAGS)),
4740 (SUB32rm GR32:$src1, addr:$src2)>;
4741
Dan Gohman99a12192009-03-04 19:44:21 +00004742// Register-Integer Subtraction with EFLAGS result
4743def : Pat<(parallel (X86sub_flag GR8:$src1, imm:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004744 (implicit EFLAGS)),
4745 (SUB8ri GR8:$src1, imm:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00004746def : Pat<(parallel (X86sub_flag GR16:$src1, imm:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004747 (implicit EFLAGS)),
4748 (SUB16ri GR16:$src1, imm:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00004749def : Pat<(parallel (X86sub_flag GR32:$src1, imm:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004750 (implicit EFLAGS)),
4751 (SUB32ri GR32:$src1, imm:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00004752def : Pat<(parallel (X86sub_flag GR16:$src1, i16immSExt8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004753 (implicit EFLAGS)),
4754 (SUB16ri8 GR16:$src1, i16immSExt8:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00004755def : Pat<(parallel (X86sub_flag GR32:$src1, i32immSExt8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004756 (implicit EFLAGS)),
4757 (SUB32ri8 GR32:$src1, i32immSExt8:$src2)>;
4758
Dan Gohman99a12192009-03-04 19:44:21 +00004759// Memory-Register Subtraction with EFLAGS result
4760def : Pat<(parallel (store (X86sub_flag (loadi8 addr:$dst), GR8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004761 addr:$dst),
4762 (implicit EFLAGS)),
4763 (SUB8mr addr:$dst, GR8:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00004764def : Pat<(parallel (store (X86sub_flag (loadi16 addr:$dst), GR16:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004765 addr:$dst),
4766 (implicit EFLAGS)),
4767 (SUB16mr addr:$dst, GR16:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00004768def : Pat<(parallel (store (X86sub_flag (loadi32 addr:$dst), GR32:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004769 addr:$dst),
4770 (implicit EFLAGS)),
4771 (SUB32mr addr:$dst, GR32:$src2)>;
4772
Dan Gohman99a12192009-03-04 19:44:21 +00004773// Memory-Integer Subtraction with EFLAGS result
4774def : Pat<(parallel (store (X86sub_flag (loadi8 addr:$dst), imm:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004775 addr:$dst),
4776 (implicit EFLAGS)),
4777 (SUB8mi addr:$dst, imm:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00004778def : Pat<(parallel (store (X86sub_flag (loadi16 addr:$dst), imm:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004779 addr:$dst),
4780 (implicit EFLAGS)),
4781 (SUB16mi addr:$dst, imm:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00004782def : Pat<(parallel (store (X86sub_flag (loadi32 addr:$dst), imm:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004783 addr:$dst),
4784 (implicit EFLAGS)),
4785 (SUB32mi addr:$dst, imm:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00004786def : Pat<(parallel (store (X86sub_flag (loadi16 addr:$dst), i16immSExt8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004787 addr:$dst),
4788 (implicit EFLAGS)),
4789 (SUB16mi8 addr:$dst, i16immSExt8:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00004790def : Pat<(parallel (store (X86sub_flag (loadi32 addr:$dst), i32immSExt8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004791 addr:$dst),
4792 (implicit EFLAGS)),
4793 (SUB32mi8 addr:$dst, i32immSExt8:$src2)>;
4794
4795
Dan Gohman99a12192009-03-04 19:44:21 +00004796// Register-Register Signed Integer Multiply with EFLAGS result
4797def : Pat<(parallel (X86smul_flag GR16:$src1, GR16:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004798 (implicit EFLAGS)),
4799 (IMUL16rr GR16:$src1, GR16:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00004800def : Pat<(parallel (X86smul_flag GR32:$src1, GR32:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004801 (implicit EFLAGS)),
4802 (IMUL32rr GR32:$src1, GR32:$src2)>;
4803
Dan Gohman99a12192009-03-04 19:44:21 +00004804// Register-Memory Signed Integer Multiply with EFLAGS result
4805def : Pat<(parallel (X86smul_flag GR16:$src1, (loadi16 addr:$src2)),
Bill Wendlingf5399032008-12-12 21:15:41 +00004806 (implicit EFLAGS)),
4807 (IMUL16rm GR16:$src1, addr:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00004808def : Pat<(parallel (X86smul_flag GR32:$src1, (loadi32 addr:$src2)),
Bill Wendlingf5399032008-12-12 21:15:41 +00004809 (implicit EFLAGS)),
4810 (IMUL32rm GR32:$src1, addr:$src2)>;
4811
Dan Gohman99a12192009-03-04 19:44:21 +00004812// Register-Integer Signed Integer Multiply with EFLAGS result
4813def : Pat<(parallel (X86smul_flag GR16:$src1, imm:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004814 (implicit EFLAGS)),
4815 (IMUL16rri GR16:$src1, imm:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00004816def : Pat<(parallel (X86smul_flag GR32:$src1, imm:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004817 (implicit EFLAGS)),
4818 (IMUL32rri GR32:$src1, imm:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00004819def : Pat<(parallel (X86smul_flag GR16:$src1, i16immSExt8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004820 (implicit EFLAGS)),
4821 (IMUL16rri8 GR16:$src1, i16immSExt8:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00004822def : Pat<(parallel (X86smul_flag GR32:$src1, i32immSExt8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004823 (implicit EFLAGS)),
4824 (IMUL32rri8 GR32:$src1, i32immSExt8:$src2)>;
4825
Dan Gohman99a12192009-03-04 19:44:21 +00004826// Memory-Integer Signed Integer Multiply with EFLAGS result
4827def : Pat<(parallel (X86smul_flag (loadi16 addr:$src1), imm:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004828 (implicit EFLAGS)),
4829 (IMUL16rmi addr:$src1, imm:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00004830def : Pat<(parallel (X86smul_flag (loadi32 addr:$src1), imm:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004831 (implicit EFLAGS)),
4832 (IMUL32rmi addr:$src1, imm:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00004833def : Pat<(parallel (X86smul_flag (loadi16 addr:$src1), i16immSExt8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004834 (implicit EFLAGS)),
4835 (IMUL16rmi8 addr:$src1, i16immSExt8:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00004836def : Pat<(parallel (X86smul_flag (loadi32 addr:$src1), i32immSExt8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004837 (implicit EFLAGS)),
4838 (IMUL32rmi8 addr:$src1, i32immSExt8:$src2)>;
4839
Dan Gohman99a12192009-03-04 19:44:21 +00004840// Optimize multiply by 2 with EFLAGS result.
Evan Cheng00cf7932009-01-27 03:30:42 +00004841let AddedComplexity = 2 in {
Dan Gohman99a12192009-03-04 19:44:21 +00004842def : Pat<(parallel (X86smul_flag GR16:$src1, 2),
Evan Cheng00cf7932009-01-27 03:30:42 +00004843 (implicit EFLAGS)),
4844 (ADD16rr GR16:$src1, GR16:$src1)>;
4845
Dan Gohman99a12192009-03-04 19:44:21 +00004846def : Pat<(parallel (X86smul_flag GR32:$src1, 2),
Evan Cheng00cf7932009-01-27 03:30:42 +00004847 (implicit EFLAGS)),
4848 (ADD32rr GR32:$src1, GR32:$src1)>;
4849}
4850
Dan Gohman99a12192009-03-04 19:44:21 +00004851// INC and DEC with EFLAGS result. Note that these do not set CF.
4852def : Pat<(parallel (X86inc_flag GR8:$src), (implicit EFLAGS)),
4853 (INC8r GR8:$src)>;
4854def : Pat<(parallel (store (i8 (X86inc_flag (loadi8 addr:$dst))), addr:$dst),
4855 (implicit EFLAGS)),
4856 (INC8m addr:$dst)>;
4857def : Pat<(parallel (X86dec_flag GR8:$src), (implicit EFLAGS)),
4858 (DEC8r GR8:$src)>;
4859def : Pat<(parallel (store (i8 (X86dec_flag (loadi8 addr:$dst))), addr:$dst),
4860 (implicit EFLAGS)),
4861 (DEC8m addr:$dst)>;
4862
4863def : Pat<(parallel (X86inc_flag GR16:$src), (implicit EFLAGS)),
Dan Gohmaneebcac72009-03-05 21:32:23 +00004864 (INC16r GR16:$src)>, Requires<[In32BitMode]>;
Dan Gohman99a12192009-03-04 19:44:21 +00004865def : Pat<(parallel (store (i16 (X86inc_flag (loadi16 addr:$dst))), addr:$dst),
4866 (implicit EFLAGS)),
Dan Gohmaneebcac72009-03-05 21:32:23 +00004867 (INC16m addr:$dst)>, Requires<[In32BitMode]>;
Dan Gohman99a12192009-03-04 19:44:21 +00004868def : Pat<(parallel (X86dec_flag GR16:$src), (implicit EFLAGS)),
Dan Gohmaneebcac72009-03-05 21:32:23 +00004869 (DEC16r GR16:$src)>, Requires<[In32BitMode]>;
Dan Gohman99a12192009-03-04 19:44:21 +00004870def : Pat<(parallel (store (i16 (X86dec_flag (loadi16 addr:$dst))), addr:$dst),
4871 (implicit EFLAGS)),
Dan Gohmaneebcac72009-03-05 21:32:23 +00004872 (DEC16m addr:$dst)>, Requires<[In32BitMode]>;
Dan Gohman99a12192009-03-04 19:44:21 +00004873
4874def : Pat<(parallel (X86inc_flag GR32:$src), (implicit EFLAGS)),
Dan Gohmaneebcac72009-03-05 21:32:23 +00004875 (INC32r GR32:$src)>, Requires<[In32BitMode]>;
Dan Gohman99a12192009-03-04 19:44:21 +00004876def : Pat<(parallel (store (i32 (X86inc_flag (loadi32 addr:$dst))), addr:$dst),
4877 (implicit EFLAGS)),
Dan Gohmaneebcac72009-03-05 21:32:23 +00004878 (INC32m addr:$dst)>, Requires<[In32BitMode]>;
Dan Gohman99a12192009-03-04 19:44:21 +00004879def : Pat<(parallel (X86dec_flag GR32:$src), (implicit EFLAGS)),
Dan Gohmaneebcac72009-03-05 21:32:23 +00004880 (DEC32r GR32:$src)>, Requires<[In32BitMode]>;
Dan Gohman99a12192009-03-04 19:44:21 +00004881def : Pat<(parallel (store (i32 (X86dec_flag (loadi32 addr:$dst))), addr:$dst),
4882 (implicit EFLAGS)),
Dan Gohmaneebcac72009-03-05 21:32:23 +00004883 (DEC32m addr:$dst)>, Requires<[In32BitMode]>;
Dan Gohman99a12192009-03-04 19:44:21 +00004884
Dan Gohman12e03292009-09-18 19:59:53 +00004885// Register-Register Or with EFLAGS result
4886def : Pat<(parallel (X86or_flag GR8:$src1, GR8:$src2),
4887 (implicit EFLAGS)),
4888 (OR8rr GR8:$src1, GR8:$src2)>;
4889def : Pat<(parallel (X86or_flag GR16:$src1, GR16:$src2),
4890 (implicit EFLAGS)),
4891 (OR16rr GR16:$src1, GR16:$src2)>;
4892def : Pat<(parallel (X86or_flag GR32:$src1, GR32:$src2),
4893 (implicit EFLAGS)),
4894 (OR32rr GR32:$src1, GR32:$src2)>;
4895
4896// Register-Memory Or with EFLAGS result
4897def : Pat<(parallel (X86or_flag GR8:$src1, (loadi8 addr:$src2)),
4898 (implicit EFLAGS)),
4899 (OR8rm GR8:$src1, addr:$src2)>;
4900def : Pat<(parallel (X86or_flag GR16:$src1, (loadi16 addr:$src2)),
4901 (implicit EFLAGS)),
4902 (OR16rm GR16:$src1, addr:$src2)>;
4903def : Pat<(parallel (X86or_flag GR32:$src1, (loadi32 addr:$src2)),
4904 (implicit EFLAGS)),
4905 (OR32rm GR32:$src1, addr:$src2)>;
4906
4907// Register-Integer Or with EFLAGS result
4908def : Pat<(parallel (X86or_flag GR8:$src1, imm:$src2),
4909 (implicit EFLAGS)),
4910 (OR8ri GR8:$src1, imm:$src2)>;
4911def : Pat<(parallel (X86or_flag GR16:$src1, imm:$src2),
4912 (implicit EFLAGS)),
4913 (OR16ri GR16:$src1, imm:$src2)>;
4914def : Pat<(parallel (X86or_flag GR32:$src1, imm:$src2),
4915 (implicit EFLAGS)),
4916 (OR32ri GR32:$src1, imm:$src2)>;
4917def : Pat<(parallel (X86or_flag GR16:$src1, i16immSExt8:$src2),
4918 (implicit EFLAGS)),
4919 (OR16ri8 GR16:$src1, i16immSExt8:$src2)>;
4920def : Pat<(parallel (X86or_flag GR32:$src1, i32immSExt8:$src2),
4921 (implicit EFLAGS)),
4922 (OR32ri8 GR32:$src1, i32immSExt8:$src2)>;
4923
4924// Memory-Register Or with EFLAGS result
4925def : Pat<(parallel (store (X86or_flag (loadi8 addr:$dst), GR8:$src2),
4926 addr:$dst),
4927 (implicit EFLAGS)),
4928 (OR8mr addr:$dst, GR8:$src2)>;
4929def : Pat<(parallel (store (X86or_flag (loadi16 addr:$dst), GR16:$src2),
4930 addr:$dst),
4931 (implicit EFLAGS)),
4932 (OR16mr addr:$dst, GR16:$src2)>;
4933def : Pat<(parallel (store (X86or_flag (loadi32 addr:$dst), GR32:$src2),
4934 addr:$dst),
4935 (implicit EFLAGS)),
4936 (OR32mr addr:$dst, GR32:$src2)>;
4937
4938// Memory-Integer Or with EFLAGS result
4939def : Pat<(parallel (store (X86or_flag (loadi8 addr:$dst), imm:$src2),
4940 addr:$dst),
4941 (implicit EFLAGS)),
4942 (OR8mi addr:$dst, imm:$src2)>;
4943def : Pat<(parallel (store (X86or_flag (loadi16 addr:$dst), imm:$src2),
4944 addr:$dst),
4945 (implicit EFLAGS)),
4946 (OR16mi addr:$dst, imm:$src2)>;
4947def : Pat<(parallel (store (X86or_flag (loadi32 addr:$dst), imm:$src2),
4948 addr:$dst),
4949 (implicit EFLAGS)),
4950 (OR32mi addr:$dst, imm:$src2)>;
4951def : Pat<(parallel (store (X86or_flag (loadi16 addr:$dst), i16immSExt8:$src2),
4952 addr:$dst),
4953 (implicit EFLAGS)),
4954 (OR16mi8 addr:$dst, i16immSExt8:$src2)>;
4955def : Pat<(parallel (store (X86or_flag (loadi32 addr:$dst), i32immSExt8:$src2),
4956 addr:$dst),
4957 (implicit EFLAGS)),
4958 (OR32mi8 addr:$dst, i32immSExt8:$src2)>;
4959
4960// Register-Register XOr with EFLAGS result
4961def : Pat<(parallel (X86xor_flag GR8:$src1, GR8:$src2),
4962 (implicit EFLAGS)),
4963 (XOR8rr GR8:$src1, GR8:$src2)>;
4964def : Pat<(parallel (X86xor_flag GR16:$src1, GR16:$src2),
4965 (implicit EFLAGS)),
4966 (XOR16rr GR16:$src1, GR16:$src2)>;
4967def : Pat<(parallel (X86xor_flag GR32:$src1, GR32:$src2),
4968 (implicit EFLAGS)),
4969 (XOR32rr GR32:$src1, GR32:$src2)>;
4970
4971// Register-Memory XOr with EFLAGS result
4972def : Pat<(parallel (X86xor_flag GR8:$src1, (loadi8 addr:$src2)),
4973 (implicit EFLAGS)),
4974 (XOR8rm GR8:$src1, addr:$src2)>;
4975def : Pat<(parallel (X86xor_flag GR16:$src1, (loadi16 addr:$src2)),
4976 (implicit EFLAGS)),
4977 (XOR16rm GR16:$src1, addr:$src2)>;
4978def : Pat<(parallel (X86xor_flag GR32:$src1, (loadi32 addr:$src2)),
4979 (implicit EFLAGS)),
4980 (XOR32rm GR32:$src1, addr:$src2)>;
4981
4982// Register-Integer XOr with EFLAGS result
4983def : Pat<(parallel (X86xor_flag GR8:$src1, imm:$src2),
4984 (implicit EFLAGS)),
4985 (XOR8ri GR8:$src1, imm:$src2)>;
4986def : Pat<(parallel (X86xor_flag GR16:$src1, imm:$src2),
4987 (implicit EFLAGS)),
4988 (XOR16ri GR16:$src1, imm:$src2)>;
4989def : Pat<(parallel (X86xor_flag GR32:$src1, imm:$src2),
4990 (implicit EFLAGS)),
4991 (XOR32ri GR32:$src1, imm:$src2)>;
4992def : Pat<(parallel (X86xor_flag GR16:$src1, i16immSExt8:$src2),
4993 (implicit EFLAGS)),
4994 (XOR16ri8 GR16:$src1, i16immSExt8:$src2)>;
4995def : Pat<(parallel (X86xor_flag GR32:$src1, i32immSExt8:$src2),
4996 (implicit EFLAGS)),
4997 (XOR32ri8 GR32:$src1, i32immSExt8:$src2)>;
4998
4999// Memory-Register XOr with EFLAGS result
5000def : Pat<(parallel (store (X86xor_flag (loadi8 addr:$dst), GR8:$src2),
5001 addr:$dst),
5002 (implicit EFLAGS)),
5003 (XOR8mr addr:$dst, GR8:$src2)>;
5004def : Pat<(parallel (store (X86xor_flag (loadi16 addr:$dst), GR16:$src2),
5005 addr:$dst),
5006 (implicit EFLAGS)),
5007 (XOR16mr addr:$dst, GR16:$src2)>;
5008def : Pat<(parallel (store (X86xor_flag (loadi32 addr:$dst), GR32:$src2),
5009 addr:$dst),
5010 (implicit EFLAGS)),
5011 (XOR32mr addr:$dst, GR32:$src2)>;
5012
5013// Memory-Integer XOr with EFLAGS result
5014def : Pat<(parallel (store (X86xor_flag (loadi8 addr:$dst), imm:$src2),
5015 addr:$dst),
5016 (implicit EFLAGS)),
5017 (XOR8mi addr:$dst, imm:$src2)>;
5018def : Pat<(parallel (store (X86xor_flag (loadi16 addr:$dst), imm:$src2),
5019 addr:$dst),
5020 (implicit EFLAGS)),
5021 (XOR16mi addr:$dst, imm:$src2)>;
5022def : Pat<(parallel (store (X86xor_flag (loadi32 addr:$dst), imm:$src2),
5023 addr:$dst),
5024 (implicit EFLAGS)),
5025 (XOR32mi addr:$dst, imm:$src2)>;
5026def : Pat<(parallel (store (X86xor_flag (loadi16 addr:$dst), i16immSExt8:$src2),
5027 addr:$dst),
5028 (implicit EFLAGS)),
5029 (XOR16mi8 addr:$dst, i16immSExt8:$src2)>;
5030def : Pat<(parallel (store (X86xor_flag (loadi32 addr:$dst), i32immSExt8:$src2),
5031 addr:$dst),
5032 (implicit EFLAGS)),
5033 (XOR32mi8 addr:$dst, i32immSExt8:$src2)>;
5034
5035// Register-Register And with EFLAGS result
5036def : Pat<(parallel (X86and_flag GR8:$src1, GR8:$src2),
5037 (implicit EFLAGS)),
5038 (AND8rr GR8:$src1, GR8:$src2)>;
5039def : Pat<(parallel (X86and_flag GR16:$src1, GR16:$src2),
5040 (implicit EFLAGS)),
5041 (AND16rr GR16:$src1, GR16:$src2)>;
5042def : Pat<(parallel (X86and_flag GR32:$src1, GR32:$src2),
5043 (implicit EFLAGS)),
5044 (AND32rr GR32:$src1, GR32:$src2)>;
5045
5046// Register-Memory And with EFLAGS result
5047def : Pat<(parallel (X86and_flag GR8:$src1, (loadi8 addr:$src2)),
5048 (implicit EFLAGS)),
5049 (AND8rm GR8:$src1, addr:$src2)>;
5050def : Pat<(parallel (X86and_flag GR16:$src1, (loadi16 addr:$src2)),
5051 (implicit EFLAGS)),
5052 (AND16rm GR16:$src1, addr:$src2)>;
5053def : Pat<(parallel (X86and_flag GR32:$src1, (loadi32 addr:$src2)),
5054 (implicit EFLAGS)),
5055 (AND32rm GR32:$src1, addr:$src2)>;
5056
5057// Register-Integer And with EFLAGS result
5058def : Pat<(parallel (X86and_flag GR8:$src1, imm:$src2),
5059 (implicit EFLAGS)),
5060 (AND8ri GR8:$src1, imm:$src2)>;
5061def : Pat<(parallel (X86and_flag GR16:$src1, imm:$src2),
5062 (implicit EFLAGS)),
5063 (AND16ri GR16:$src1, imm:$src2)>;
5064def : Pat<(parallel (X86and_flag GR32:$src1, imm:$src2),
5065 (implicit EFLAGS)),
5066 (AND32ri GR32:$src1, imm:$src2)>;
5067def : Pat<(parallel (X86and_flag GR16:$src1, i16immSExt8:$src2),
5068 (implicit EFLAGS)),
5069 (AND16ri8 GR16:$src1, i16immSExt8:$src2)>;
5070def : Pat<(parallel (X86and_flag GR32:$src1, i32immSExt8:$src2),
5071 (implicit EFLAGS)),
5072 (AND32ri8 GR32:$src1, i32immSExt8:$src2)>;
5073
5074// Memory-Register And with EFLAGS result
5075def : Pat<(parallel (store (X86and_flag (loadi8 addr:$dst), GR8:$src2),
5076 addr:$dst),
5077 (implicit EFLAGS)),
5078 (AND8mr addr:$dst, GR8:$src2)>;
5079def : Pat<(parallel (store (X86and_flag (loadi16 addr:$dst), GR16:$src2),
5080 addr:$dst),
5081 (implicit EFLAGS)),
5082 (AND16mr addr:$dst, GR16:$src2)>;
5083def : Pat<(parallel (store (X86and_flag (loadi32 addr:$dst), GR32:$src2),
5084 addr:$dst),
5085 (implicit EFLAGS)),
5086 (AND32mr addr:$dst, GR32:$src2)>;
5087
5088// Memory-Integer And with EFLAGS result
5089def : Pat<(parallel (store (X86and_flag (loadi8 addr:$dst), imm:$src2),
5090 addr:$dst),
5091 (implicit EFLAGS)),
5092 (AND8mi addr:$dst, imm:$src2)>;
5093def : Pat<(parallel (store (X86and_flag (loadi16 addr:$dst), imm:$src2),
5094 addr:$dst),
5095 (implicit EFLAGS)),
5096 (AND16mi addr:$dst, imm:$src2)>;
5097def : Pat<(parallel (store (X86and_flag (loadi32 addr:$dst), imm:$src2),
5098 addr:$dst),
5099 (implicit EFLAGS)),
5100 (AND32mi addr:$dst, imm:$src2)>;
5101def : Pat<(parallel (store (X86and_flag (loadi16 addr:$dst), i16immSExt8:$src2),
5102 addr:$dst),
5103 (implicit EFLAGS)),
5104 (AND16mi8 addr:$dst, i16immSExt8:$src2)>;
5105def : Pat<(parallel (store (X86and_flag (loadi32 addr:$dst), i32immSExt8:$src2),
5106 addr:$dst),
5107 (implicit EFLAGS)),
5108 (AND32mi8 addr:$dst, i32immSExt8:$src2)>;
5109
Dan Gohmane84197b2009-09-03 17:18:51 +00005110// -disable-16bit support.
5111def : Pat<(truncstorei16 (i32 imm:$src), addr:$dst),
5112 (MOV16mi addr:$dst, imm:$src)>;
5113def : Pat<(truncstorei16 GR32:$src, addr:$dst),
5114 (MOV16mr addr:$dst, (EXTRACT_SUBREG GR32:$src, x86_subreg_16bit))>;
5115def : Pat<(i32 (sextloadi16 addr:$dst)),
5116 (MOVSX32rm16 addr:$dst)>;
5117def : Pat<(i32 (zextloadi16 addr:$dst)),
5118 (MOVZX32rm16 addr:$dst)>;
5119def : Pat<(i32 (extloadi16 addr:$dst)),
5120 (MOVZX32rm16 addr:$dst)>;
5121
Bill Wendlingf5399032008-12-12 21:15:41 +00005122//===----------------------------------------------------------------------===//
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005123// Floating Point Stack Support
5124//===----------------------------------------------------------------------===//
5125
5126include "X86InstrFPStack.td"
5127
5128//===----------------------------------------------------------------------===//
Evan Cheng86ab7d32007-07-31 08:04:03 +00005129// X86-64 Support
5130//===----------------------------------------------------------------------===//
5131
Chris Lattner2de8d2b2008-01-10 05:50:42 +00005132include "X86Instr64bit.td"
Evan Cheng86ab7d32007-07-31 08:04:03 +00005133
5134//===----------------------------------------------------------------------===//
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005135// XMM Floating point support (requires SSE / SSE2)
5136//===----------------------------------------------------------------------===//
5137
5138include "X86InstrSSE.td"
Evan Cheng5e4d1e72008-04-25 18:19:54 +00005139
5140//===----------------------------------------------------------------------===//
5141// MMX and XMM Packed Integer support (requires MMX, SSE, and SSE2)
5142//===----------------------------------------------------------------------===//
5143
5144include "X86InstrMMX.td"