blob: 7411dde89543ede63a13101d9634d8450eaa0e7e [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)">;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000304
305//===----------------------------------------------------------------------===//
Evan Cheng86ab7d32007-07-31 08:04:03 +0000306// X86 Instruction Format Definitions.
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000307//
308
Evan Cheng86ab7d32007-07-31 08:04:03 +0000309include "X86InstrFormats.td"
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000310
311//===----------------------------------------------------------------------===//
312// Pattern fragments...
313//
314
315// X86 specific condition code. These correspond to CondCode in
316// X86InstrInfo.h. They must be kept in synch.
Dan Gohman0fc9ed62009-01-07 00:15:08 +0000317def X86_COND_A : PatLeaf<(i8 0)>; // alt. COND_NBE
318def X86_COND_AE : PatLeaf<(i8 1)>; // alt. COND_NC
319def X86_COND_B : PatLeaf<(i8 2)>; // alt. COND_C
320def X86_COND_BE : PatLeaf<(i8 3)>; // alt. COND_NA
321def X86_COND_E : PatLeaf<(i8 4)>; // alt. COND_Z
322def X86_COND_G : PatLeaf<(i8 5)>; // alt. COND_NLE
323def X86_COND_GE : PatLeaf<(i8 6)>; // alt. COND_NL
324def X86_COND_L : PatLeaf<(i8 7)>; // alt. COND_NGE
325def X86_COND_LE : PatLeaf<(i8 8)>; // alt. COND_NG
326def X86_COND_NE : PatLeaf<(i8 9)>; // alt. COND_NZ
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000327def X86_COND_NO : PatLeaf<(i8 10)>;
Dan Gohman0fc9ed62009-01-07 00:15:08 +0000328def X86_COND_NP : PatLeaf<(i8 11)>; // alt. COND_PO
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000329def X86_COND_NS : PatLeaf<(i8 12)>;
Dan Gohman0fc9ed62009-01-07 00:15:08 +0000330def X86_COND_O : PatLeaf<(i8 13)>;
331def X86_COND_P : PatLeaf<(i8 14)>; // alt. COND_PE
332def X86_COND_S : PatLeaf<(i8 15)>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000333
334def i16immSExt8 : PatLeaf<(i16 imm), [{
335 // i16immSExt8 predicate - True if the 16-bit immediate fits in a 8-bit
336 // sign extended field.
Dan Gohmanfaeb4a32008-09-12 16:56:44 +0000337 return (int16_t)N->getZExtValue() == (int8_t)N->getZExtValue();
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000338}]>;
339
340def i32immSExt8 : PatLeaf<(i32 imm), [{
341 // i32immSExt8 predicate - True if the 32-bit immediate fits in a 8-bit
342 // sign extended field.
Dan Gohmanfaeb4a32008-09-12 16:56:44 +0000343 return (int32_t)N->getZExtValue() == (int8_t)N->getZExtValue();
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000344}]>;
345
346// Helper fragments for loads.
Evan Chengb3e25ea2008-05-13 18:59:59 +0000347// It's always safe to treat a anyext i16 load as a i32 load if the i16 is
348// known to be 32-bit aligned or better. Ditto for i8 to i16.
Dan Gohman2a174122008-10-15 06:50:19 +0000349def loadi16 : PatFrag<(ops node:$ptr), (i16 (unindexedload node:$ptr)), [{
Dan Gohman8335c412008-08-20 15:24:22 +0000350 LoadSDNode *LD = cast<LoadSDNode>(N);
Chris Lattner12208612009-04-10 00:16:23 +0000351 if (const Value *Src = LD->getSrcValue())
352 if (const PointerType *PT = dyn_cast<PointerType>(Src->getType()))
Mon P Wangdc97d5a2009-04-27 07:22:10 +0000353 if (PT->getAddressSpace() > 255)
Chris Lattner12208612009-04-10 00:16:23 +0000354 return false;
Dan Gohman8335c412008-08-20 15:24:22 +0000355 ISD::LoadExtType ExtType = LD->getExtensionType();
356 if (ExtType == ISD::NON_EXTLOAD)
357 return true;
358 if (ExtType == ISD::EXTLOAD)
359 return LD->getAlignment() >= 2 && !LD->isVolatile();
Evan Cheng8b765e92008-05-13 00:54:02 +0000360 return false;
361}]>;
362
Sean Callanan2c48df22009-12-18 00:01:26 +0000363def loadi16_anyext : PatFrag<(ops node:$ptr), (i32 (unindexedload node:$ptr)),
364[{
Evan Cheng56ec77b2008-09-24 23:27:55 +0000365 LoadSDNode *LD = cast<LoadSDNode>(N);
Chris Lattner12208612009-04-10 00:16:23 +0000366 if (const Value *Src = LD->getSrcValue())
367 if (const PointerType *PT = dyn_cast<PointerType>(Src->getType()))
Mon P Wangdc97d5a2009-04-27 07:22:10 +0000368 if (PT->getAddressSpace() > 255)
Chris Lattner12208612009-04-10 00:16:23 +0000369 return false;
Evan Cheng56ec77b2008-09-24 23:27:55 +0000370 ISD::LoadExtType ExtType = LD->getExtensionType();
371 if (ExtType == ISD::EXTLOAD)
372 return LD->getAlignment() >= 2 && !LD->isVolatile();
373 return false;
374}]>;
375
Dan Gohman2a174122008-10-15 06:50:19 +0000376def loadi32 : PatFrag<(ops node:$ptr), (i32 (unindexedload node:$ptr)), [{
Dan Gohman8335c412008-08-20 15:24:22 +0000377 LoadSDNode *LD = cast<LoadSDNode>(N);
Chris Lattner12208612009-04-10 00:16:23 +0000378 if (const Value *Src = LD->getSrcValue())
379 if (const PointerType *PT = dyn_cast<PointerType>(Src->getType()))
Mon P Wangdc97d5a2009-04-27 07:22:10 +0000380 if (PT->getAddressSpace() > 255)
Chris Lattner12208612009-04-10 00:16:23 +0000381 return false;
Dan Gohman8335c412008-08-20 15:24:22 +0000382 ISD::LoadExtType ExtType = LD->getExtensionType();
383 if (ExtType == ISD::NON_EXTLOAD)
384 return true;
385 if (ExtType == ISD::EXTLOAD)
386 return LD->getAlignment() >= 4 && !LD->isVolatile();
Evan Cheng8b765e92008-05-13 00:54:02 +0000387 return false;
388}]>;
389
Dan Gohman2a174122008-10-15 06:50:19 +0000390def nvloadi32 : PatFrag<(ops node:$ptr), (i32 (unindexedload node:$ptr)), [{
Evan Cheng1e5e5452008-09-29 17:26:18 +0000391 LoadSDNode *LD = cast<LoadSDNode>(N);
Chris Lattner12208612009-04-10 00:16:23 +0000392 if (const Value *Src = LD->getSrcValue())
393 if (const PointerType *PT = dyn_cast<PointerType>(Src->getType()))
Mon P Wangdc97d5a2009-04-27 07:22:10 +0000394 if (PT->getAddressSpace() > 255)
Chris Lattner12208612009-04-10 00:16:23 +0000395 return false;
Evan Cheng1e5e5452008-09-29 17:26:18 +0000396 if (LD->isVolatile())
397 return false;
Evan Cheng1e5e5452008-09-29 17:26:18 +0000398 ISD::LoadExtType ExtType = LD->getExtensionType();
399 if (ExtType == ISD::NON_EXTLOAD)
400 return true;
401 if (ExtType == ISD::EXTLOAD)
402 return LD->getAlignment() >= 4;
403 return false;
404}]>;
405
sampo9cc09a32009-01-26 01:24:32 +0000406def gsload : PatFrag<(ops node:$ptr), (load node:$ptr), [{
Chris Lattner12208612009-04-10 00:16:23 +0000407 if (const Value *Src = cast<LoadSDNode>(N)->getSrcValue())
408 if (const PointerType *PT = dyn_cast<PointerType>(Src->getType()))
409 return PT->getAddressSpace() == 256;
sampo9cc09a32009-01-26 01:24:32 +0000410 return false;
411}]>;
412
Chris Lattnera7c2d8a2009-05-05 18:52:19 +0000413def fsload : PatFrag<(ops node:$ptr), (load node:$ptr), [{
414 if (const Value *Src = cast<LoadSDNode>(N)->getSrcValue())
415 if (const PointerType *PT = dyn_cast<PointerType>(Src->getType()))
416 return PT->getAddressSpace() == 257;
417 return false;
418}]>;
419
Chris Lattner12208612009-04-10 00:16:23 +0000420def loadi8 : PatFrag<(ops node:$ptr), (i8 (load node:$ptr)), [{
421 if (const Value *Src = cast<LoadSDNode>(N)->getSrcValue())
422 if (const PointerType *PT = dyn_cast<PointerType>(Src->getType()))
Mon P Wangdc97d5a2009-04-27 07:22:10 +0000423 if (PT->getAddressSpace() > 255)
Chris Lattner12208612009-04-10 00:16:23 +0000424 return false;
425 return true;
426}]>;
427def loadi64 : PatFrag<(ops node:$ptr), (i64 (load node:$ptr)), [{
428 if (const Value *Src = cast<LoadSDNode>(N)->getSrcValue())
429 if (const PointerType *PT = dyn_cast<PointerType>(Src->getType()))
Mon P Wangdc97d5a2009-04-27 07:22:10 +0000430 if (PT->getAddressSpace() > 255)
Chris Lattner12208612009-04-10 00:16:23 +0000431 return false;
432 return true;
433}]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000434
Chris Lattner12208612009-04-10 00:16:23 +0000435def loadf32 : PatFrag<(ops node:$ptr), (f32 (load node:$ptr)), [{
436 if (const Value *Src = cast<LoadSDNode>(N)->getSrcValue())
437 if (const PointerType *PT = dyn_cast<PointerType>(Src->getType()))
Mon P Wangdc97d5a2009-04-27 07:22:10 +0000438 if (PT->getAddressSpace() > 255)
Chris Lattner12208612009-04-10 00:16:23 +0000439 return false;
440 return true;
441}]>;
442def loadf64 : PatFrag<(ops node:$ptr), (f64 (load node:$ptr)), [{
443 if (const Value *Src = cast<LoadSDNode>(N)->getSrcValue())
444 if (const PointerType *PT = dyn_cast<PointerType>(Src->getType()))
Mon P Wangdc97d5a2009-04-27 07:22:10 +0000445 if (PT->getAddressSpace() > 255)
Chris Lattner12208612009-04-10 00:16:23 +0000446 return false;
447 return true;
448}]>;
449def loadf80 : PatFrag<(ops node:$ptr), (f80 (load node:$ptr)), [{
450 if (const Value *Src = cast<LoadSDNode>(N)->getSrcValue())
451 if (const PointerType *PT = dyn_cast<PointerType>(Src->getType()))
Mon P Wangdc97d5a2009-04-27 07:22:10 +0000452 if (PT->getAddressSpace() > 255)
Chris Lattner12208612009-04-10 00:16:23 +0000453 return false;
454 return true;
455}]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000456
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000457def sextloadi16i8 : PatFrag<(ops node:$ptr), (i16 (sextloadi8 node:$ptr))>;
458def sextloadi32i8 : PatFrag<(ops node:$ptr), (i32 (sextloadi8 node:$ptr))>;
459def sextloadi32i16 : PatFrag<(ops node:$ptr), (i32 (sextloadi16 node:$ptr))>;
460
461def zextloadi8i1 : PatFrag<(ops node:$ptr), (i8 (zextloadi1 node:$ptr))>;
462def zextloadi16i1 : PatFrag<(ops node:$ptr), (i16 (zextloadi1 node:$ptr))>;
463def zextloadi32i1 : PatFrag<(ops node:$ptr), (i32 (zextloadi1 node:$ptr))>;
464def zextloadi16i8 : PatFrag<(ops node:$ptr), (i16 (zextloadi8 node:$ptr))>;
465def zextloadi32i8 : PatFrag<(ops node:$ptr), (i32 (zextloadi8 node:$ptr))>;
466def zextloadi32i16 : PatFrag<(ops node:$ptr), (i32 (zextloadi16 node:$ptr))>;
467
468def extloadi8i1 : PatFrag<(ops node:$ptr), (i8 (extloadi1 node:$ptr))>;
469def extloadi16i1 : PatFrag<(ops node:$ptr), (i16 (extloadi1 node:$ptr))>;
470def extloadi32i1 : PatFrag<(ops node:$ptr), (i32 (extloadi1 node:$ptr))>;
471def extloadi16i8 : PatFrag<(ops node:$ptr), (i16 (extloadi8 node:$ptr))>;
472def extloadi32i8 : PatFrag<(ops node:$ptr), (i32 (extloadi8 node:$ptr))>;
473def extloadi32i16 : PatFrag<(ops node:$ptr), (i32 (extloadi16 node:$ptr))>;
474
Chris Lattner21da6382008-02-19 17:37:35 +0000475
476// An 'and' node with a single use.
477def and_su : PatFrag<(ops node:$lhs, node:$rhs), (and node:$lhs, node:$rhs), [{
Evan Cheng9123cfa2008-03-04 00:40:35 +0000478 return N->hasOneUse();
Chris Lattner21da6382008-02-19 17:37:35 +0000479}]>;
Dan Gohman744d4622009-04-13 16:09:41 +0000480// An 'srl' node with a single use.
481def srl_su : PatFrag<(ops node:$lhs, node:$rhs), (srl node:$lhs, node:$rhs), [{
482 return N->hasOneUse();
483}]>;
484// An 'trunc' node with a single use.
485def trunc_su : PatFrag<(ops node:$src), (trunc node:$src), [{
486 return N->hasOneUse();
487}]>;
Chris Lattner21da6382008-02-19 17:37:35 +0000488
Dan Gohman921581d2008-10-17 01:23:35 +0000489// 'shld' and 'shrd' instruction patterns. Note that even though these have
490// the srl and shl in their patterns, the C++ code must still check for them,
491// because predicates are tested before children nodes are explored.
492
493def shrd : PatFrag<(ops node:$src1, node:$amt1, node:$src2, node:$amt2),
494 (or (srl node:$src1, node:$amt1),
495 (shl node:$src2, node:$amt2)), [{
496 assert(N->getOpcode() == ISD::OR);
497 return N->getOperand(0).getOpcode() == ISD::SRL &&
498 N->getOperand(1).getOpcode() == ISD::SHL &&
499 isa<ConstantSDNode>(N->getOperand(0).getOperand(1)) &&
500 isa<ConstantSDNode>(N->getOperand(1).getOperand(1)) &&
501 N->getOperand(0).getConstantOperandVal(1) ==
502 N->getValueSizeInBits(0) - N->getOperand(1).getConstantOperandVal(1);
503}]>;
504
505def shld : PatFrag<(ops node:$src1, node:$amt1, node:$src2, node:$amt2),
506 (or (shl node:$src1, node:$amt1),
507 (srl node:$src2, node:$amt2)), [{
508 assert(N->getOpcode() == ISD::OR);
509 return N->getOperand(0).getOpcode() == ISD::SHL &&
510 N->getOperand(1).getOpcode() == ISD::SRL &&
511 isa<ConstantSDNode>(N->getOperand(0).getOperand(1)) &&
512 isa<ConstantSDNode>(N->getOperand(1).getOperand(1)) &&
513 N->getOperand(0).getConstantOperandVal(1) ==
514 N->getValueSizeInBits(0) - N->getOperand(1).getConstantOperandVal(1);
515}]>;
516
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000517//===----------------------------------------------------------------------===//
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000518// Instruction list...
519//
520
521// ADJCALLSTACKDOWN/UP implicitly use/def ESP because they may be expanded into
522// a stack adjustment and the codegen must know that they may modify the stack
523// pointer before prolog-epilog rewriting occurs.
Chris Lattnerb56cc342008-03-11 03:23:40 +0000524// Pessimistically assume ADJCALLSTACKDOWN / ADJCALLSTACKUP will become
525// sub / add which can clobber EFLAGS.
Evan Cheng037364a2007-09-28 01:19:48 +0000526let Defs = [ESP, EFLAGS], Uses = [ESP] in {
Dan Gohman01c9f772008-10-01 18:28:06 +0000527def ADJCALLSTACKDOWN32 : I<0, Pseudo, (outs), (ins i32imm:$amt),
528 "#ADJCALLSTACKDOWN",
Chris Lattnerfe5d4022008-10-11 22:08:30 +0000529 [(X86callseq_start timm:$amt)]>,
Dan Gohman01c9f772008-10-01 18:28:06 +0000530 Requires<[In32BitMode]>;
531def ADJCALLSTACKUP32 : I<0, Pseudo, (outs), (ins i32imm:$amt1, i32imm:$amt2),
532 "#ADJCALLSTACKUP",
Chris Lattnerfe5d4022008-10-11 22:08:30 +0000533 [(X86callseq_end timm:$amt1, timm:$amt2)]>,
Dan Gohman01c9f772008-10-01 18:28:06 +0000534 Requires<[In32BitMode]>;
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000535}
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000536
Dan Gohman34228bf2009-08-15 01:38:56 +0000537// x86-64 va_start lowering magic.
Dan Gohman30afe012009-10-29 18:10:34 +0000538let usesCustomInserter = 1 in
Dan Gohman34228bf2009-08-15 01:38:56 +0000539def VASTART_SAVE_XMM_REGS : I<0, Pseudo,
540 (outs),
541 (ins GR8:$al,
542 i64imm:$regsavefi, i64imm:$offset,
543 variable_ops),
544 "#VASTART_SAVE_XMM_REGS $al, $regsavefi, $offset",
545 [(X86vastart_save_xmm_regs GR8:$al,
546 imm:$regsavefi,
547 imm:$offset)]>;
548
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000549// Nop
Sean Callananf94a0542009-07-23 23:39:34 +0000550let neverHasSideEffects = 1 in {
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000551 def NOOP : I<0x90, RawFrm, (outs), (ins), "nop", []>;
Sean Callanan2c48df22009-12-18 00:01:26 +0000552 def NOOPW : I<0x1f, MRM0m, (outs), (ins i16mem:$zero),
553 "nop{w}\t$zero", []>, TB, OpSize;
Sean Callananf94a0542009-07-23 23:39:34 +0000554 def NOOPL : I<0x1f, MRM0m, (outs), (ins i32mem:$zero),
Sean Callanan2c48df22009-12-18 00:01:26 +0000555 "nop{l}\t$zero", []>, TB;
Sean Callananf94a0542009-07-23 23:39:34 +0000556}
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000557
Sean Callanan9b195f82009-08-11 01:09:06 +0000558// Trap
Dan Gohman8112b942009-11-11 18:07:16 +0000559def INT3 : I<0xcc, RawFrm, (outs), (ins), "int\t3", []>;
Sean Callanan9b195f82009-08-11 01:09:06 +0000560def INT : I<0xcd, RawFrm, (outs), (ins i8imm:$trap), "int\t$trap", []>;
Sean Callanan2c48df22009-12-18 00:01:26 +0000561def IRET16 : I<0xcf, RawFrm, (outs), (ins), "iret{w}", []>, OpSize;
562def IRET32 : I<0xcf, RawFrm, (outs), (ins), "iret{l}", []>;
Sean Callanan9b195f82009-08-11 01:09:06 +0000563
Chris Lattner2aa10da2009-09-20 07:32:00 +0000564// PIC base construction. This expands to code that looks like this:
565// call $next_inst
566// popl %destreg"
Dan Gohman9499cfe2008-10-01 04:14:30 +0000567let neverHasSideEffects = 1, isNotDuplicable = 1, Uses = [ESP] in
Chris Lattnera7e959d2009-09-20 07:28:26 +0000568 def MOVPC32r : Ii32<0xE8, Pseudo, (outs GR32:$reg), (ins i32imm:$label),
Chris Lattner2aa10da2009-09-20 07:32:00 +0000569 "", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000570
571//===----------------------------------------------------------------------===//
572// Control Flow Instructions...
573//
574
575// Return instructions.
576let isTerminator = 1, isReturn = 1, isBarrier = 1,
Chris Lattnerb56cc342008-03-11 03:23:40 +0000577 hasCtrlDep = 1, FPForm = SpecialFP, FPFormBits = SpecialFP.Value in {
Dan Gohman2c4be2a2008-05-31 02:11:25 +0000578 def RET : I <0xC3, RawFrm, (outs), (ins variable_ops),
Chris Lattnerb56cc342008-03-11 03:23:40 +0000579 "ret",
Dan Gohman2c4be2a2008-05-31 02:11:25 +0000580 [(X86retflag 0)]>;
Chris Lattnerb56cc342008-03-11 03:23:40 +0000581 def RETI : Ii16<0xC2, RawFrm, (outs), (ins i16imm:$amt, variable_ops),
582 "ret\t$amt",
Dan Gohmane84197b2009-09-03 17:18:51 +0000583 [(X86retflag timm:$amt)]>;
Sean Callanan7a012572009-09-15 23:37:51 +0000584 def LRET : I <0xCB, RawFrm, (outs), (ins),
585 "lret", []>;
586 def LRETI : Ii16<0xCA, RawFrm, (outs), (ins i16imm:$amt),
587 "lret\t$amt", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000588}
589
590// All branches are RawFrm, Void, Branch, and Terminators
Evan Cheng37e7c752007-07-21 00:34:19 +0000591let isBranch = 1, isTerminator = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +0000592 class IBr<bits<8> opcode, dag ins, string asm, list<dag> pattern> :
593 I<opcode, RawFrm, (outs), ins, asm, pattern>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000594
Sean Callananc0608152009-07-22 01:05:20 +0000595let isBranch = 1, isBarrier = 1 in {
Dan Gohman91888f02007-07-31 20:11:57 +0000596 def JMP : IBr<0xE9, (ins brtarget:$dst), "jmp\t$dst", [(br bb:$dst)]>;
Sean Callananc0608152009-07-22 01:05:20 +0000597 def JMP8 : IBr<0xEB, (ins brtarget8:$dst), "jmp\t$dst", []>;
598}
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000599
Owen Andersonf8053082007-11-12 07:39:39 +0000600// Indirect branches
601let isBranch = 1, isTerminator = 1, isBarrier = 1, isIndirectBranch = 1 in {
Dan Gohman91888f02007-07-31 20:11:57 +0000602 def JMP32r : I<0xFF, MRM4r, (outs), (ins GR32:$dst), "jmp{l}\t{*}$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000603 [(brind GR32:$dst)]>;
Dan Gohman91888f02007-07-31 20:11:57 +0000604 def JMP32m : I<0xFF, MRM4m, (outs), (ins i32mem:$dst), "jmp{l}\t{*}$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000605 [(brind (loadi32 addr:$dst))]>;
Sean Callananb7e73392009-09-15 00:35:17 +0000606
607 def FARJMP16i : Iseg16<0xEA, RawFrm, (outs),
608 (ins i16imm:$seg, i16imm:$off),
609 "ljmp{w}\t$seg, $off", []>, OpSize;
610 def FARJMP32i : Iseg32<0xEA, RawFrm, (outs),
611 (ins i16imm:$seg, i32imm:$off),
612 "ljmp{l}\t$seg, $off", []>;
613
614 def FARJMP16m : I<0xFF, MRM5m, (outs), (ins opaque32mem:$dst),
Sean Callanan66fdfa02009-09-03 00:04:47 +0000615 "ljmp{w}\t{*}$dst", []>, OpSize;
Sean Callananb7e73392009-09-15 00:35:17 +0000616 def FARJMP32m : I<0xFF, MRM5m, (outs), (ins opaque48mem:$dst),
Sean Callanan66fdfa02009-09-03 00:04:47 +0000617 "ljmp{l}\t{*}$dst", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000618}
619
620// Conditional branches
Evan Cheng950aac02007-09-25 01:57:46 +0000621let Uses = [EFLAGS] in {
Evan Chengd11052b2009-07-21 06:00:18 +0000622// Short conditional jumps
623def JO8 : IBr<0x70, (ins brtarget8:$dst), "jo\t$dst", []>;
624def JNO8 : IBr<0x71, (ins brtarget8:$dst), "jno\t$dst", []>;
625def JB8 : IBr<0x72, (ins brtarget8:$dst), "jb\t$dst", []>;
626def JAE8 : IBr<0x73, (ins brtarget8:$dst), "jae\t$dst", []>;
627def JE8 : IBr<0x74, (ins brtarget8:$dst), "je\t$dst", []>;
628def JNE8 : IBr<0x75, (ins brtarget8:$dst), "jne\t$dst", []>;
629def JBE8 : IBr<0x76, (ins brtarget8:$dst), "jbe\t$dst", []>;
630def JA8 : IBr<0x77, (ins brtarget8:$dst), "ja\t$dst", []>;
631def JS8 : IBr<0x78, (ins brtarget8:$dst), "js\t$dst", []>;
632def JNS8 : IBr<0x79, (ins brtarget8:$dst), "jns\t$dst", []>;
633def JP8 : IBr<0x7A, (ins brtarget8:$dst), "jp\t$dst", []>;
634def JNP8 : IBr<0x7B, (ins brtarget8:$dst), "jnp\t$dst", []>;
635def JL8 : IBr<0x7C, (ins brtarget8:$dst), "jl\t$dst", []>;
636def JGE8 : IBr<0x7D, (ins brtarget8:$dst), "jge\t$dst", []>;
637def JLE8 : IBr<0x7E, (ins brtarget8:$dst), "jle\t$dst", []>;
638def JG8 : IBr<0x7F, (ins brtarget8:$dst), "jg\t$dst", []>;
639
640def JCXZ8 : IBr<0xE3, (ins brtarget8:$dst), "jcxz\t$dst", []>;
641
Dan Gohman91888f02007-07-31 20:11:57 +0000642def JE : IBr<0x84, (ins brtarget:$dst), "je\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000643 [(X86brcond bb:$dst, X86_COND_E, EFLAGS)]>, TB;
Dan Gohman91888f02007-07-31 20:11:57 +0000644def JNE : IBr<0x85, (ins brtarget:$dst), "jne\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000645 [(X86brcond bb:$dst, X86_COND_NE, EFLAGS)]>, TB;
Dan Gohman91888f02007-07-31 20:11:57 +0000646def JL : IBr<0x8C, (ins brtarget:$dst), "jl\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000647 [(X86brcond bb:$dst, X86_COND_L, EFLAGS)]>, TB;
Dan Gohman91888f02007-07-31 20:11:57 +0000648def JLE : IBr<0x8E, (ins brtarget:$dst), "jle\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000649 [(X86brcond bb:$dst, X86_COND_LE, EFLAGS)]>, TB;
Dan Gohman91888f02007-07-31 20:11:57 +0000650def JG : IBr<0x8F, (ins brtarget:$dst), "jg\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000651 [(X86brcond bb:$dst, X86_COND_G, EFLAGS)]>, TB;
Dan Gohman91888f02007-07-31 20:11:57 +0000652def JGE : IBr<0x8D, (ins brtarget:$dst), "jge\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000653 [(X86brcond bb:$dst, X86_COND_GE, EFLAGS)]>, TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000654
Dan Gohman91888f02007-07-31 20:11:57 +0000655def JB : IBr<0x82, (ins brtarget:$dst), "jb\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000656 [(X86brcond bb:$dst, X86_COND_B, EFLAGS)]>, TB;
Dan Gohman91888f02007-07-31 20:11:57 +0000657def JBE : IBr<0x86, (ins brtarget:$dst), "jbe\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000658 [(X86brcond bb:$dst, X86_COND_BE, EFLAGS)]>, TB;
Dan Gohman91888f02007-07-31 20:11:57 +0000659def JA : IBr<0x87, (ins brtarget:$dst), "ja\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000660 [(X86brcond bb:$dst, X86_COND_A, EFLAGS)]>, TB;
Dan Gohman91888f02007-07-31 20:11:57 +0000661def JAE : IBr<0x83, (ins brtarget:$dst), "jae\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000662 [(X86brcond bb:$dst, X86_COND_AE, EFLAGS)]>, TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000663
Dan Gohman91888f02007-07-31 20:11:57 +0000664def JS : IBr<0x88, (ins brtarget:$dst), "js\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000665 [(X86brcond bb:$dst, X86_COND_S, EFLAGS)]>, TB;
Dan Gohman91888f02007-07-31 20:11:57 +0000666def JNS : IBr<0x89, (ins brtarget:$dst), "jns\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000667 [(X86brcond bb:$dst, X86_COND_NS, EFLAGS)]>, TB;
Dan Gohman91888f02007-07-31 20:11:57 +0000668def JP : IBr<0x8A, (ins brtarget:$dst), "jp\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000669 [(X86brcond bb:$dst, X86_COND_P, EFLAGS)]>, TB;
Dan Gohman91888f02007-07-31 20:11:57 +0000670def JNP : IBr<0x8B, (ins brtarget:$dst), "jnp\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000671 [(X86brcond bb:$dst, X86_COND_NP, EFLAGS)]>, TB;
Dan Gohman91888f02007-07-31 20:11:57 +0000672def JO : IBr<0x80, (ins brtarget:$dst), "jo\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000673 [(X86brcond bb:$dst, X86_COND_O, EFLAGS)]>, TB;
Dan Gohman91888f02007-07-31 20:11:57 +0000674def JNO : IBr<0x81, (ins brtarget:$dst), "jno\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000675 [(X86brcond bb:$dst, X86_COND_NO, EFLAGS)]>, TB;
Evan Cheng950aac02007-09-25 01:57:46 +0000676} // Uses = [EFLAGS]
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000677
Sean Callanan503784b2009-09-16 21:50:07 +0000678// Loop instructions
679
680def LOOP : I<0xE2, RawFrm, (ins brtarget8:$dst), (outs), "loop\t$dst", []>;
681def LOOPE : I<0xE1, RawFrm, (ins brtarget8:$dst), (outs), "loope\t$dst", []>;
682def LOOPNE : I<0xE0, RawFrm, (ins brtarget8:$dst), (outs), "loopne\t$dst", []>;
683
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000684//===----------------------------------------------------------------------===//
685// Call Instructions...
686//
Evan Cheng37e7c752007-07-21 00:34:19 +0000687let isCall = 1 in
Dan Gohman01c9f772008-10-01 18:28:06 +0000688 // All calls clobber the non-callee saved registers. ESP is marked as
689 // a use to prevent stack-pointer assignments that appear immediately
690 // before calls from potentially appearing dead. Uses for argument
691 // registers are added manually.
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000692 let Defs = [EAX, ECX, EDX, FP0, FP1, FP2, FP3, FP4, FP5, FP6, ST0,
693 MM0, MM1, MM2, MM3, MM4, MM5, MM6, MM7,
Evan Cheng2293b252008-10-17 21:02:22 +0000694 XMM0, XMM1, XMM2, XMM3, XMM4, XMM5, XMM6, XMM7,
695 XMM8, XMM9, XMM10, XMM11, XMM12, XMM13, XMM14, XMM15, EFLAGS],
Dan Gohman9499cfe2008-10-01 04:14:30 +0000696 Uses = [ESP] in {
Chris Lattner357a0ca2009-06-20 19:34:09 +0000697 def CALLpcrel32 : Ii32<0xE8, RawFrm,
698 (outs), (ins i32imm_pcrel:$dst,variable_ops),
699 "call\t$dst", []>;
Evan Chengb783fa32007-07-19 01:14:50 +0000700 def CALL32r : I<0xFF, MRM2r, (outs), (ins GR32:$dst, variable_ops),
Dan Gohman91888f02007-07-31 20:11:57 +0000701 "call\t{*}$dst", [(X86call GR32:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000702 def CALL32m : I<0xFF, MRM2m, (outs), (ins i32mem:$dst, variable_ops),
Dan Gohmanea4faba2008-05-29 21:50:34 +0000703 "call\t{*}$dst", [(X86call (loadi32 addr:$dst))]>;
Sean Callanan66fdfa02009-09-03 00:04:47 +0000704
Sean Callananb7e73392009-09-15 00:35:17 +0000705 def FARCALL16i : Iseg16<0x9A, RawFrm, (outs),
706 (ins i16imm:$seg, i16imm:$off),
707 "lcall{w}\t$seg, $off", []>, OpSize;
708 def FARCALL32i : Iseg32<0x9A, RawFrm, (outs),
709 (ins i16imm:$seg, i32imm:$off),
710 "lcall{l}\t$seg, $off", []>;
711
712 def FARCALL16m : I<0xFF, MRM3m, (outs), (ins opaque32mem:$dst),
Sean Callanan66fdfa02009-09-03 00:04:47 +0000713 "lcall{w}\t{*}$dst", []>, OpSize;
Sean Callananb7e73392009-09-15 00:35:17 +0000714 def FARCALL32m : I<0xFF, MRM3m, (outs), (ins opaque48mem:$dst),
Sean Callanan66fdfa02009-09-03 00:04:47 +0000715 "lcall{l}\t{*}$dst", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000716 }
717
Sean Callanan51b7a992009-09-16 02:57:13 +0000718// Constructing a stack frame.
719
720def ENTER : I<0xC8, RawFrm, (outs), (ins i16imm:$len, i8imm:$lvl),
721 "enter\t$len, $lvl", []>;
722
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000723// Tail call stuff.
Arnold Schwaighofere2d6bbb2007-10-11 19:40:01 +0000724
Evan Cheng37e7c752007-07-21 00:34:19 +0000725let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1 in
Sean Callanan2c48df22009-12-18 00:01:26 +0000726def TCRETURNdi : I<0, Pseudo, (outs),
727 (ins i32imm:$dst, i32imm:$offset, variable_ops),
Arnold Schwaighofere2d6bbb2007-10-11 19:40:01 +0000728 "#TC_RETURN $dst $offset",
729 []>;
730
731let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1 in
Sean Callanan2c48df22009-12-18 00:01:26 +0000732def TCRETURNri : I<0, Pseudo, (outs),
733 (ins GR32:$dst, i32imm:$offset, variable_ops),
Arnold Schwaighofere2d6bbb2007-10-11 19:40:01 +0000734 "#TC_RETURN $dst $offset",
735 []>;
736
737let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1 in
Chris Lattner357a0ca2009-06-20 19:34:09 +0000738 def TAILJMPd : IBr<0xE9, (ins i32imm_pcrel:$dst), "jmp\t$dst # TAILCALL",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000739 []>;
Evan Cheng37e7c752007-07-21 00:34:19 +0000740let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1 in
Sean Callanan2c48df22009-12-18 00:01:26 +0000741 def TAILJMPr : I<0xFF, MRM4r, (outs), (ins GR32:$dst),
742 "jmp{l}\t{*}$dst # TAILCALL",
Arnold Schwaighofere2d6bbb2007-10-11 19:40:01 +0000743 []>;
Evan Cheng37e7c752007-07-21 00:34:19 +0000744let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +0000745 def TAILJMPm : I<0xFF, MRM4m, (outs), (ins i32mem:$dst),
Arnold Schwaighofere2d6bbb2007-10-11 19:40:01 +0000746 "jmp\t{*}$dst # TAILCALL", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000747
748//===----------------------------------------------------------------------===//
749// Miscellaneous Instructions...
750//
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000751let Defs = [EBP, ESP], Uses = [EBP, ESP], mayLoad = 1, neverHasSideEffects=1 in
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000752def LEAVE : I<0xC9, RawFrm,
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000753 (outs), (ins), "leave", []>;
754
Sean Callanan2c48df22009-12-18 00:01:26 +0000755def POPCNT16rr : I<0xB8, MRMSrcReg, (outs GR16:$dst), (ins GR16:$src),
756 "popcnt{w}\t{$src, $dst|$dst, $src}", []>, OpSize, XS;
757def POPCNT16rm : I<0xB8, MRMSrcMem, (outs GR16:$dst), (ins i16mem:$src),
758 "popcnt{w}\t{$src, $dst|$dst, $src}", []>, OpSize, XS;
759def POPCNT32rr : I<0xB8, MRMSrcReg, (outs GR32:$dst), (ins GR32:$src),
760 "popcnt{l}\t{$src, $dst|$dst, $src}", []>, XS;
761def POPCNT32rm : I<0xB8, MRMSrcMem, (outs GR32:$dst), (ins i32mem:$src),
762 "popcnt{l}\t{$src, $dst|$dst, $src}", []>, XS;
763
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000764let Defs = [ESP], Uses = [ESP], neverHasSideEffects=1 in {
Sean Callanan9f3c3f52009-09-10 18:29:13 +0000765let mayLoad = 1 in {
766def POP16r : I<0x58, AddRegFrm, (outs GR16:$reg), (ins), "pop{w}\t$reg", []>,
767 OpSize;
768def POP32r : I<0x58, AddRegFrm, (outs GR32:$reg), (ins), "pop{l}\t$reg", []>;
769def POP16rmr: I<0x8F, MRM0r, (outs GR16:$reg), (ins), "pop{w}\t$reg", []>,
770 OpSize;
771def POP16rmm: I<0x8F, MRM0m, (outs i16mem:$dst), (ins), "pop{w}\t$dst", []>,
772 OpSize;
773def POP32rmr: I<0x8F, MRM0r, (outs GR32:$reg), (ins), "pop{l}\t$reg", []>;
774def POP32rmm: I<0x8F, MRM0m, (outs i32mem:$dst), (ins), "pop{l}\t$dst", []>;
775}
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000776
Sean Callanan9f3c3f52009-09-10 18:29:13 +0000777let mayStore = 1 in {
778def PUSH16r : I<0x50, AddRegFrm, (outs), (ins GR16:$reg), "push{w}\t$reg",[]>,
779 OpSize;
Evan Chengd8434332007-09-26 01:29:06 +0000780def PUSH32r : I<0x50, AddRegFrm, (outs), (ins GR32:$reg), "push{l}\t$reg",[]>;
Sean Callanan9f3c3f52009-09-10 18:29:13 +0000781def PUSH16rmr: I<0xFF, MRM6r, (outs), (ins GR16:$reg), "push{w}\t$reg",[]>,
782 OpSize;
783def PUSH16rmm: I<0xFF, MRM6m, (outs), (ins i16mem:$src), "push{w}\t$src",[]>,
784 OpSize;
785def PUSH32rmr: I<0xFF, MRM6r, (outs), (ins GR32:$reg), "push{l}\t$reg",[]>;
786def PUSH32rmm: I<0xFF, MRM6m, (outs), (ins i32mem:$src), "push{l}\t$src",[]>;
787}
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000788}
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000789
Bill Wendling4c2638c2009-06-15 19:39:04 +0000790let Defs = [ESP], Uses = [ESP], neverHasSideEffects = 1, mayStore = 1 in {
791def PUSH32i8 : Ii8<0x6a, RawFrm, (outs), (ins i8imm:$imm),
Bill Wendling0b0437f2009-06-15 20:59:31 +0000792 "push{l}\t$imm", []>;
Bill Wendling4c2638c2009-06-15 19:39:04 +0000793def PUSH32i16 : Ii16<0x68, RawFrm, (outs), (ins i16imm:$imm),
Bill Wendling0b0437f2009-06-15 20:59:31 +0000794 "push{l}\t$imm", []>;
Bill Wendling4c2638c2009-06-15 19:39:04 +0000795def PUSH32i32 : Ii32<0x68, RawFrm, (outs), (ins i32imm:$imm),
Bill Wendling0b0437f2009-06-15 20:59:31 +0000796 "push{l}\t$imm", []>;
Bill Wendling4c2638c2009-06-15 19:39:04 +0000797}
798
Sean Callanan2c48df22009-12-18 00:01:26 +0000799let Defs = [ESP, EFLAGS], Uses = [ESP], mayLoad = 1, neverHasSideEffects=1 in {
800def POPF : I<0x9D, RawFrm, (outs), (ins), "popf{w}", []>, OpSize;
801def POPFD : I<0x9D, RawFrm, (outs), (ins), "popf{l}", []>;
802}
803let Defs = [ESP], Uses = [ESP, EFLAGS], mayStore = 1, neverHasSideEffects=1 in {
804def PUSHF : I<0x9C, RawFrm, (outs), (ins), "pushf{w}", []>, OpSize;
805def PUSHFD : I<0x9C, RawFrm, (outs), (ins), "pushf{l}", []>;
806}
Evan Chengd8434332007-09-26 01:29:06 +0000807
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000808let isTwoAddress = 1 in // GR32 = bswap GR32
809 def BSWAP32r : I<0xC8, AddRegFrm,
Evan Chengb783fa32007-07-19 01:14:50 +0000810 (outs GR32:$dst), (ins GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000811 "bswap{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000812 [(set GR32:$dst, (bswap GR32:$src))]>, TB;
813
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000814
Evan Cheng48679f42007-12-14 02:13:44 +0000815// Bit scan instructions.
816let Defs = [EFLAGS] in {
Evan Cheng4e33de92007-12-14 18:49:43 +0000817def BSF16rr : I<0xBC, MRMSrcReg, (outs GR16:$dst), (ins GR16:$src),
Dan Gohmancdb54c62007-12-14 15:10:00 +0000818 "bsf{w}\t{$src, $dst|$dst, $src}",
Evan Cheng7cfbfe32007-12-14 08:30:15 +0000819 [(set GR16:$dst, (X86bsf GR16:$src)), (implicit EFLAGS)]>, TB;
Evan Cheng48679f42007-12-14 02:13:44 +0000820def BSF16rm : I<0xBC, MRMSrcMem, (outs GR16:$dst), (ins i16mem:$src),
Dan Gohmancdb54c62007-12-14 15:10:00 +0000821 "bsf{w}\t{$src, $dst|$dst, $src}",
Evan Cheng7cfbfe32007-12-14 08:30:15 +0000822 [(set GR16:$dst, (X86bsf (loadi16 addr:$src))),
823 (implicit EFLAGS)]>, TB;
Evan Cheng4e33de92007-12-14 18:49:43 +0000824def BSF32rr : I<0xBC, MRMSrcReg, (outs GR32:$dst), (ins GR32:$src),
Dan Gohmancdb54c62007-12-14 15:10:00 +0000825 "bsf{l}\t{$src, $dst|$dst, $src}",
Evan Cheng7cfbfe32007-12-14 08:30:15 +0000826 [(set GR32:$dst, (X86bsf GR32:$src)), (implicit EFLAGS)]>, TB;
Evan Cheng48679f42007-12-14 02:13:44 +0000827def BSF32rm : I<0xBC, MRMSrcMem, (outs GR32:$dst), (ins i32mem:$src),
Dan Gohmancdb54c62007-12-14 15:10:00 +0000828 "bsf{l}\t{$src, $dst|$dst, $src}",
Evan Cheng7cfbfe32007-12-14 08:30:15 +0000829 [(set GR32:$dst, (X86bsf (loadi32 addr:$src))),
830 (implicit EFLAGS)]>, TB;
Evan Cheng48679f42007-12-14 02:13:44 +0000831
Evan Cheng4e33de92007-12-14 18:49:43 +0000832def BSR16rr : I<0xBD, MRMSrcReg, (outs GR16:$dst), (ins GR16:$src),
Dan Gohmancdb54c62007-12-14 15:10:00 +0000833 "bsr{w}\t{$src, $dst|$dst, $src}",
Evan Cheng7cfbfe32007-12-14 08:30:15 +0000834 [(set GR16:$dst, (X86bsr GR16:$src)), (implicit EFLAGS)]>, TB;
Evan Cheng48679f42007-12-14 02:13:44 +0000835def BSR16rm : I<0xBD, MRMSrcMem, (outs GR16:$dst), (ins i16mem:$src),
Dan Gohmancdb54c62007-12-14 15:10:00 +0000836 "bsr{w}\t{$src, $dst|$dst, $src}",
Evan Cheng7cfbfe32007-12-14 08:30:15 +0000837 [(set GR16:$dst, (X86bsr (loadi16 addr:$src))),
838 (implicit EFLAGS)]>, TB;
Evan Cheng4e33de92007-12-14 18:49:43 +0000839def BSR32rr : I<0xBD, MRMSrcReg, (outs GR32:$dst), (ins GR32:$src),
Dan Gohmancdb54c62007-12-14 15:10:00 +0000840 "bsr{l}\t{$src, $dst|$dst, $src}",
Evan Cheng7cfbfe32007-12-14 08:30:15 +0000841 [(set GR32:$dst, (X86bsr GR32:$src)), (implicit EFLAGS)]>, TB;
Evan Cheng48679f42007-12-14 02:13:44 +0000842def BSR32rm : I<0xBD, MRMSrcMem, (outs GR32:$dst), (ins i32mem:$src),
Dan Gohmancdb54c62007-12-14 15:10:00 +0000843 "bsr{l}\t{$src, $dst|$dst, $src}",
Evan Cheng7cfbfe32007-12-14 08:30:15 +0000844 [(set GR32:$dst, (X86bsr (loadi32 addr:$src))),
845 (implicit EFLAGS)]>, TB;
Evan Cheng48679f42007-12-14 02:13:44 +0000846} // Defs = [EFLAGS]
847
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000848let neverHasSideEffects = 1 in
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000849def LEA16r : I<0x8D, MRMSrcMem,
Evan Chengca348202009-12-12 18:51:56 +0000850 (outs GR16:$dst), (ins lea32mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000851 "lea{w}\t{$src|$dst}, {$dst|$src}", []>, OpSize;
Evan Cheng1ea8e6b2008-03-27 01:41:09 +0000852let isReMaterializable = 1 in
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000853def LEA32r : I<0x8D, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +0000854 (outs GR32:$dst), (ins lea32mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000855 "lea{l}\t{$src|$dst}, {$dst|$src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000856 [(set GR32:$dst, lea32addr:$src)]>, Requires<[In32BitMode]>;
857
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000858let Defs = [ECX,EDI,ESI], Uses = [ECX,EDI,ESI] in {
Evan Chengb783fa32007-07-19 01:14:50 +0000859def REP_MOVSB : I<0xA4, RawFrm, (outs), (ins), "{rep;movsb|rep movsb}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000860 [(X86rep_movs i8)]>, REP;
Evan Chengb783fa32007-07-19 01:14:50 +0000861def REP_MOVSW : I<0xA5, RawFrm, (outs), (ins), "{rep;movsw|rep movsw}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000862 [(X86rep_movs i16)]>, REP, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +0000863def REP_MOVSD : I<0xA5, RawFrm, (outs), (ins), "{rep;movsl|rep movsd}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000864 [(X86rep_movs i32)]>, REP;
865}
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000866
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000867let Defs = [ECX,EDI], Uses = [AL,ECX,EDI] in
Evan Chengb783fa32007-07-19 01:14:50 +0000868def REP_STOSB : I<0xAA, RawFrm, (outs), (ins), "{rep;stosb|rep stosb}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000869 [(X86rep_stos i8)]>, REP;
870let Defs = [ECX,EDI], Uses = [AX,ECX,EDI] in
Evan Chengb783fa32007-07-19 01:14:50 +0000871def REP_STOSW : I<0xAB, RawFrm, (outs), (ins), "{rep;stosw|rep stosw}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000872 [(X86rep_stos i16)]>, REP, OpSize;
873let Defs = [ECX,EDI], Uses = [EAX,ECX,EDI] in
Evan Chengb783fa32007-07-19 01:14:50 +0000874def REP_STOSD : I<0xAB, RawFrm, (outs), (ins), "{rep;stosl|rep stosd}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000875 [(X86rep_stos i32)]>, REP;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000876
Sean Callanan481f06d2009-09-12 00:37:19 +0000877def SCAS8 : I<0xAE, RawFrm, (outs), (ins), "scas{b}", []>;
878def SCAS16 : I<0xAF, RawFrm, (outs), (ins), "scas{w}", []>, OpSize;
879def SCAS32 : I<0xAF, RawFrm, (outs), (ins), "scas{l}", []>;
880
Sean Callanan25220d62009-09-12 02:25:20 +0000881def CMPS8 : I<0xA6, RawFrm, (outs), (ins), "cmps{b}", []>;
882def CMPS16 : I<0xA7, RawFrm, (outs), (ins), "cmps{w}", []>, OpSize;
883def CMPS32 : I<0xA7, RawFrm, (outs), (ins), "cmps{l}", []>;
884
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000885let Defs = [RAX, RDX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000886def RDTSC : I<0x31, RawFrm, (outs), (ins), "rdtsc", [(X86rdtsc)]>,
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000887 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000888
Anton Korobeynikov39d40ba2008-01-15 07:02:33 +0000889let isBarrier = 1, hasCtrlDep = 1 in {
Chris Lattner56b941f2008-01-15 21:58:22 +0000890def TRAP : I<0x0B, RawFrm, (outs), (ins), "ud2", [(trap)]>, TB;
Anton Korobeynikov39d40ba2008-01-15 07:02:33 +0000891}
892
Chris Lattnerc96e27c2009-08-11 16:58:39 +0000893def SYSCALL : I<0x05, RawFrm,
894 (outs), (ins), "syscall", []>, TB;
895def SYSRET : I<0x07, RawFrm,
896 (outs), (ins), "sysret", []>, TB;
897def SYSENTER : I<0x34, RawFrm,
898 (outs), (ins), "sysenter", []>, TB;
899def SYSEXIT : I<0x35, RawFrm,
900 (outs), (ins), "sysexit", []>, TB;
901
Sean Callanan2c2313a2009-09-12 02:52:41 +0000902def WAIT : I<0x9B, RawFrm, (outs), (ins), "wait", []>;
Chris Lattnerc96e27c2009-08-11 16:58:39 +0000903
904
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000905//===----------------------------------------------------------------------===//
906// Input/Output Instructions...
907//
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000908let Defs = [AL], Uses = [DX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000909def IN8rr : I<0xEC, RawFrm, (outs), (ins),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000910 "in{b}\t{%dx, %al|%AL, %DX}", []>;
911let Defs = [AX], Uses = [DX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000912def IN16rr : I<0xED, RawFrm, (outs), (ins),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000913 "in{w}\t{%dx, %ax|%AX, %DX}", []>, OpSize;
914let Defs = [EAX], Uses = [DX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000915def IN32rr : I<0xED, RawFrm, (outs), (ins),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000916 "in{l}\t{%dx, %eax|%EAX, %DX}", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000917
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000918let Defs = [AL] in
Evan Chengb783fa32007-07-19 01:14:50 +0000919def IN8ri : Ii8<0xE4, RawFrm, (outs), (ins i16i8imm:$port),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000920 "in{b}\t{$port, %al|%AL, $port}", []>;
921let Defs = [AX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000922def IN16ri : Ii8<0xE5, RawFrm, (outs), (ins i16i8imm:$port),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000923 "in{w}\t{$port, %ax|%AX, $port}", []>, OpSize;
924let Defs = [EAX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000925def IN32ri : Ii8<0xE5, RawFrm, (outs), (ins i16i8imm:$port),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000926 "in{l}\t{$port, %eax|%EAX, $port}", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000927
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000928let Uses = [DX, AL] in
Evan Chengb783fa32007-07-19 01:14:50 +0000929def OUT8rr : I<0xEE, RawFrm, (outs), (ins),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000930 "out{b}\t{%al, %dx|%DX, %AL}", []>;
931let Uses = [DX, AX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000932def OUT16rr : I<0xEF, RawFrm, (outs), (ins),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000933 "out{w}\t{%ax, %dx|%DX, %AX}", []>, OpSize;
934let Uses = [DX, EAX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000935def OUT32rr : I<0xEF, RawFrm, (outs), (ins),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000936 "out{l}\t{%eax, %dx|%DX, %EAX}", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000937
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000938let Uses = [AL] in
Evan Chengb783fa32007-07-19 01:14:50 +0000939def OUT8ir : Ii8<0xE6, RawFrm, (outs), (ins i16i8imm:$port),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000940 "out{b}\t{%al, $port|$port, %AL}", []>;
941let Uses = [AX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000942def OUT16ir : Ii8<0xE7, RawFrm, (outs), (ins i16i8imm:$port),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000943 "out{w}\t{%ax, $port|$port, %AX}", []>, OpSize;
944let Uses = [EAX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000945def OUT32ir : Ii8<0xE7, RawFrm, (outs), (ins i16i8imm:$port),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000946 "out{l}\t{%eax, $port|$port, %EAX}", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000947
Sean Callanan2c48df22009-12-18 00:01:26 +0000948def IN8 : I<0x6C, RawFrm, (outs), (ins),
949 "ins{b}", []>;
950def IN16 : I<0x6D, RawFrm, (outs), (ins),
951 "ins{w}", []>, OpSize;
952def IN32 : I<0x6D, RawFrm, (outs), (ins),
953 "ins{l}", []>;
954
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000955//===----------------------------------------------------------------------===//
956// Move Instructions...
957//
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000958let neverHasSideEffects = 1 in {
Evan Chengb783fa32007-07-19 01:14:50 +0000959def MOV8rr : I<0x88, MRMDestReg, (outs GR8 :$dst), (ins GR8 :$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000960 "mov{b}\t{$src, $dst|$dst, $src}", []>;
Evan Chengb783fa32007-07-19 01:14:50 +0000961def MOV16rr : I<0x89, MRMDestReg, (outs GR16:$dst), (ins GR16:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000962 "mov{w}\t{$src, $dst|$dst, $src}", []>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +0000963def MOV32rr : I<0x89, MRMDestReg, (outs GR32:$dst), (ins GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000964 "mov{l}\t{$src, $dst|$dst, $src}", []>;
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000965}
Evan Cheng6f26e8b2008-06-18 08:13:07 +0000966let isReMaterializable = 1, isAsCheapAsAMove = 1 in {
Evan Chengb783fa32007-07-19 01:14:50 +0000967def MOV8ri : Ii8 <0xB0, AddRegFrm, (outs GR8 :$dst), (ins i8imm :$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000968 "mov{b}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000969 [(set GR8:$dst, imm:$src)]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000970def MOV16ri : Ii16<0xB8, AddRegFrm, (outs GR16:$dst), (ins i16imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000971 "mov{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000972 [(set GR16:$dst, imm:$src)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +0000973def MOV32ri : Ii32<0xB8, AddRegFrm, (outs GR32:$dst), (ins i32imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000974 "mov{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000975 [(set GR32:$dst, imm:$src)]>;
976}
Evan Chengb783fa32007-07-19 01:14:50 +0000977def MOV8mi : Ii8 <0xC6, MRM0m, (outs), (ins i8mem :$dst, i8imm :$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000978 "mov{b}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000979 [(store (i8 imm:$src), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000980def MOV16mi : Ii16<0xC7, MRM0m, (outs), (ins i16mem:$dst, i16imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000981 "mov{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000982 [(store (i16 imm:$src), addr:$dst)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +0000983def MOV32mi : Ii32<0xC7, MRM0m, (outs), (ins i32mem:$dst, i32imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000984 "mov{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000985 [(store (i32 imm:$src), addr:$dst)]>;
986
Sean Callanan2c48df22009-12-18 00:01:26 +0000987def MOV8o8a : Ii8 <0xA0, RawFrm, (outs), (ins offset8:$src),
Sean Callanan70953a52009-09-10 18:33:42 +0000988 "mov{b}\t{$src, %al|%al, $src}", []>;
Sean Callanan2c48df22009-12-18 00:01:26 +0000989def MOV16o16a : Ii16 <0xA1, RawFrm, (outs), (ins offset16:$src),
Sean Callanan70953a52009-09-10 18:33:42 +0000990 "mov{w}\t{$src, %ax|%ax, $src}", []>, OpSize;
Sean Callanan2c48df22009-12-18 00:01:26 +0000991def MOV32o32a : Ii32 <0xA1, RawFrm, (outs), (ins offset32:$src),
Sean Callanan70953a52009-09-10 18:33:42 +0000992 "mov{l}\t{$src, %eax|%eax, $src}", []>;
993
Sean Callanan2c48df22009-12-18 00:01:26 +0000994def MOV8ao8 : Ii8 <0xA2, RawFrm, (outs offset8:$dst), (ins),
Sean Callanan70953a52009-09-10 18:33:42 +0000995 "mov{b}\t{%al, $dst|$dst, %al}", []>;
Sean Callanan2c48df22009-12-18 00:01:26 +0000996def MOV16ao16 : Ii16 <0xA3, RawFrm, (outs offset16:$dst), (ins),
Sean Callanan70953a52009-09-10 18:33:42 +0000997 "mov{w}\t{%ax, $dst|$dst, %ax}", []>, OpSize;
Sean Callanan2c48df22009-12-18 00:01:26 +0000998def MOV32ao32 : Ii32 <0xA3, RawFrm, (outs offset32:$dst), (ins),
Sean Callanan70953a52009-09-10 18:33:42 +0000999 "mov{l}\t{%eax, $dst|$dst, %eax}", []>;
1000
Sean Callananad87a3a2009-09-15 18:47:29 +00001001// Moves to and from segment registers
1002def MOV16rs : I<0x8C, MRMDestReg, (outs GR16:$dst), (ins SEGMENT_REG:$src),
1003 "mov{w}\t{$src, $dst|$dst, $src}", []>;
1004def MOV16ms : I<0x8C, MRMDestMem, (outs i16mem:$dst), (ins SEGMENT_REG:$src),
1005 "mov{w}\t{$src, $dst|$dst, $src}", []>;
1006def MOV16sr : I<0x8E, MRMSrcReg, (outs SEGMENT_REG:$dst), (ins GR16:$src),
1007 "mov{w}\t{$src, $dst|$dst, $src}", []>;
1008def MOV16sm : I<0x8E, MRMSrcMem, (outs SEGMENT_REG:$dst), (ins i16mem:$src),
1009 "mov{w}\t{$src, $dst|$dst, $src}", []>;
1010
Sean Callanan2c48df22009-12-18 00:01:26 +00001011def MOV8rr_REV : I<0x8A, MRMSrcReg, (outs GR8:$dst), (ins GR8:$src),
1012 "mov{b}\t{$src, $dst|$dst, $src}", []>;
1013def MOV16rr_REV : I<0x8B, MRMSrcReg, (outs GR16:$dst), (ins GR16:$src),
1014 "mov{w}\t{$src, $dst|$dst, $src}", []>, OpSize;
1015def MOV32rr_REV : I<0x8B, MRMSrcReg, (outs GR32:$dst), (ins GR32:$src),
1016 "mov{l}\t{$src, $dst|$dst, $src}", []>;
1017
Dan Gohman5574cc72008-12-03 18:15:48 +00001018let canFoldAsLoad = 1, isReMaterializable = 1, mayHaveSideEffects = 1 in {
Evan Chengb783fa32007-07-19 01:14:50 +00001019def MOV8rm : I<0x8A, MRMSrcMem, (outs GR8 :$dst), (ins i8mem :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001020 "mov{b}\t{$src, $dst|$dst, $src}",
Chris Lattner12208612009-04-10 00:16:23 +00001021 [(set GR8:$dst, (loadi8 addr:$src))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001022def MOV16rm : I<0x8B, MRMSrcMem, (outs GR16:$dst), (ins i16mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001023 "mov{w}\t{$src, $dst|$dst, $src}",
Chris Lattner12208612009-04-10 00:16:23 +00001024 [(set GR16:$dst, (loadi16 addr:$src))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001025def MOV32rm : I<0x8B, MRMSrcMem, (outs GR32:$dst), (ins i32mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001026 "mov{l}\t{$src, $dst|$dst, $src}",
Chris Lattner12208612009-04-10 00:16:23 +00001027 [(set GR32:$dst, (loadi32 addr:$src))]>;
Evan Cheng4e84e452007-08-30 05:49:43 +00001028}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001029
Evan Chengb783fa32007-07-19 01:14:50 +00001030def MOV8mr : I<0x88, MRMDestMem, (outs), (ins i8mem :$dst, GR8 :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001031 "mov{b}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001032 [(store GR8:$src, addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001033def MOV16mr : I<0x89, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001034 "mov{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001035 [(store GR16:$src, addr:$dst)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001036def MOV32mr : I<0x89, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001037 "mov{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001038 [(store GR32:$src, addr:$dst)]>;
Dan Gohman744d4622009-04-13 16:09:41 +00001039
Dan Gohman1d8ce9c2009-04-27 16:41:36 +00001040// Versions of MOV8rr, MOV8mr, and MOV8rm that use i8mem_NOREX and GR8_NOREX so
1041// that they can be used for copying and storing h registers, which can't be
1042// encoded when a REX prefix is present.
Dan Gohman2da0db32009-04-15 00:04:23 +00001043let neverHasSideEffects = 1 in
Dan Gohman40ddc362009-04-15 19:48:57 +00001044def MOV8rr_NOREX : I<0x88, MRMDestReg,
1045 (outs GR8_NOREX:$dst), (ins GR8_NOREX:$src),
Dan Gohman2da0db32009-04-15 00:04:23 +00001046 "mov{b}\t{$src, $dst|$dst, $src} # NOREX", []>;
Evan Chengebc49402009-04-30 00:58:57 +00001047let mayStore = 1 in
Dan Gohman2da0db32009-04-15 00:04:23 +00001048def MOV8mr_NOREX : I<0x88, MRMDestMem,
1049 (outs), (ins i8mem_NOREX:$dst, GR8_NOREX:$src),
1050 "mov{b}\t{$src, $dst|$dst, $src} # NOREX", []>;
Evan Chengebc49402009-04-30 00:58:57 +00001051let mayLoad = 1,
1052 canFoldAsLoad = 1, isReMaterializable = 1, mayHaveSideEffects = 1 in
Dan Gohman1d8ce9c2009-04-27 16:41:36 +00001053def MOV8rm_NOREX : I<0x8A, MRMSrcMem,
1054 (outs GR8_NOREX:$dst), (ins i8mem_NOREX:$src),
1055 "mov{b}\t{$src, $dst|$dst, $src} # NOREX", []>;
Dan Gohman744d4622009-04-13 16:09:41 +00001056
Sean Callanan2c48df22009-12-18 00:01:26 +00001057// Moves to and from debug registers
1058def MOV32rd : I<0x21, MRMDestReg, (outs GR32:$dst), (ins DEBUG_REG:$src),
1059 "mov{l}\t{$src, $dst|$dst, $src}", []>, TB;
1060def MOV32dr : I<0x23, MRMSrcReg, (outs DEBUG_REG:$dst), (ins GR32:$src),
1061 "mov{l}\t{$src, $dst|$dst, $src}", []>, TB;
1062
1063// Moves to and from control registers
1064def MOV32rc : I<0x20, MRMDestReg, (outs GR32:$dst), (ins CONTROL_REG_32:$src),
1065 "mov{q}\t{$src, $dst|$dst, $src}", []>, TB;
1066def MOV32cr : I<0x22, MRMSrcReg, (outs CONTROL_REG_32:$dst), (ins GR32:$src),
1067 "mov{q}\t{$src, $dst|$dst, $src}", []>, TB;
1068
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001069//===----------------------------------------------------------------------===//
1070// Fixed-Register Multiplication and Division Instructions...
1071//
1072
1073// Extra precision multiplication
Evan Cheng55687072007-09-14 21:48:26 +00001074let Defs = [AL,AH,EFLAGS], Uses = [AL] in
Dan Gohman91888f02007-07-31 20:11:57 +00001075def MUL8r : I<0xF6, MRM4r, (outs), (ins GR8:$src), "mul{b}\t$src",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001076 // FIXME: Used for 8-bit mul, ignore result upper 8 bits.
1077 // This probably ought to be moved to a def : Pat<> if the
1078 // syntax can be accepted.
Bill Wendlingf5399032008-12-12 21:15:41 +00001079 [(set AL, (mul AL, GR8:$src)),
1080 (implicit EFLAGS)]>; // AL,AH = AL*GR8
1081
Chris Lattnerc7e96e72008-01-11 07:18:17 +00001082let Defs = [AX,DX,EFLAGS], Uses = [AX], neverHasSideEffects = 1 in
Bill Wendlingf5399032008-12-12 21:15:41 +00001083def MUL16r : I<0xF7, MRM4r, (outs), (ins GR16:$src),
1084 "mul{w}\t$src",
1085 []>, OpSize; // AX,DX = AX*GR16
1086
Chris Lattnerc7e96e72008-01-11 07:18:17 +00001087let Defs = [EAX,EDX,EFLAGS], Uses = [EAX], neverHasSideEffects = 1 in
Bill Wendlingf5399032008-12-12 21:15:41 +00001088def MUL32r : I<0xF7, MRM4r, (outs), (ins GR32:$src),
1089 "mul{l}\t$src",
1090 []>; // EAX,EDX = EAX*GR32
1091
Evan Cheng55687072007-09-14 21:48:26 +00001092let Defs = [AL,AH,EFLAGS], Uses = [AL] in
Evan Chengb783fa32007-07-19 01:14:50 +00001093def MUL8m : I<0xF6, MRM4m, (outs), (ins i8mem :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001094 "mul{b}\t$src",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001095 // FIXME: Used for 8-bit mul, ignore result upper 8 bits.
1096 // This probably ought to be moved to a def : Pat<> if the
1097 // syntax can be accepted.
Bill Wendlingf5399032008-12-12 21:15:41 +00001098 [(set AL, (mul AL, (loadi8 addr:$src))),
1099 (implicit EFLAGS)]>; // AL,AH = AL*[mem8]
1100
Chris Lattnerc90ee9c2008-01-10 07:59:24 +00001101let mayLoad = 1, neverHasSideEffects = 1 in {
Evan Cheng55687072007-09-14 21:48:26 +00001102let Defs = [AX,DX,EFLAGS], Uses = [AX] in
Evan Chengb783fa32007-07-19 01:14:50 +00001103def MUL16m : I<0xF7, MRM4m, (outs), (ins i16mem:$src),
Bill Wendlingf5399032008-12-12 21:15:41 +00001104 "mul{w}\t$src",
1105 []>, OpSize; // AX,DX = AX*[mem16]
1106
Evan Cheng55687072007-09-14 21:48:26 +00001107let Defs = [EAX,EDX,EFLAGS], Uses = [EAX] in
Evan Chengb783fa32007-07-19 01:14:50 +00001108def MUL32m : I<0xF7, MRM4m, (outs), (ins i32mem:$src),
Bill Wendlingf5399032008-12-12 21:15:41 +00001109 "mul{l}\t$src",
1110 []>; // EAX,EDX = EAX*[mem32]
Chris Lattnerc90ee9c2008-01-10 07:59:24 +00001111}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001112
Chris Lattnerc90ee9c2008-01-10 07:59:24 +00001113let neverHasSideEffects = 1 in {
Evan Cheng55687072007-09-14 21:48:26 +00001114let Defs = [AL,AH,EFLAGS], Uses = [AL] in
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001115def IMUL8r : I<0xF6, MRM5r, (outs), (ins GR8:$src), "imul{b}\t$src", []>;
1116 // AL,AH = AL*GR8
Evan Cheng55687072007-09-14 21:48:26 +00001117let Defs = [AX,DX,EFLAGS], Uses = [AX] in
Dan Gohman91888f02007-07-31 20:11:57 +00001118def IMUL16r : I<0xF7, MRM5r, (outs), (ins GR16:$src), "imul{w}\t$src", []>,
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001119 OpSize; // AX,DX = AX*GR16
Evan Cheng55687072007-09-14 21:48:26 +00001120let Defs = [EAX,EDX,EFLAGS], Uses = [EAX] in
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001121def IMUL32r : I<0xF7, MRM5r, (outs), (ins GR32:$src), "imul{l}\t$src", []>;
1122 // EAX,EDX = EAX*GR32
Chris Lattnerc90ee9c2008-01-10 07:59:24 +00001123let mayLoad = 1 in {
Evan Cheng55687072007-09-14 21:48:26 +00001124let Defs = [AL,AH,EFLAGS], Uses = [AL] in
Evan Chengb783fa32007-07-19 01:14:50 +00001125def IMUL8m : I<0xF6, MRM5m, (outs), (ins i8mem :$src),
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001126 "imul{b}\t$src", []>; // AL,AH = AL*[mem8]
Evan Cheng55687072007-09-14 21:48:26 +00001127let Defs = [AX,DX,EFLAGS], Uses = [AX] in
Evan Chengb783fa32007-07-19 01:14:50 +00001128def IMUL16m : I<0xF7, MRM5m, (outs), (ins i16mem:$src),
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001129 "imul{w}\t$src", []>, OpSize; // AX,DX = AX*[mem16]
1130let Defs = [EAX,EDX], Uses = [EAX] in
Evan Chengb783fa32007-07-19 01:14:50 +00001131def IMUL32m : I<0xF7, MRM5m, (outs), (ins i32mem:$src),
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001132 "imul{l}\t$src", []>; // EAX,EDX = EAX*[mem32]
Chris Lattnerc90ee9c2008-01-10 07:59:24 +00001133}
Dan Gohmand44572d2008-11-18 21:29:14 +00001134} // neverHasSideEffects
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001135
1136// unsigned division/remainder
Dale Johannesend8fd3562008-10-07 18:54:28 +00001137let Defs = [AL,AH,EFLAGS], Uses = [AX] in
Sean Callanan2c48df22009-12-18 00:01:26 +00001138def DIV8r : I<0xF6, MRM6r, (outs), (ins GR8:$src), // AX/r8 = AL,AH
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001139 "div{b}\t$src", []>;
Evan Cheng55687072007-09-14 21:48:26 +00001140let Defs = [AX,DX,EFLAGS], Uses = [AX,DX] in
Sean Callanan2c48df22009-12-18 00:01:26 +00001141def DIV16r : I<0xF7, MRM6r, (outs), (ins GR16:$src), // DX:AX/r16 = AX,DX
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001142 "div{w}\t$src", []>, OpSize;
Evan Cheng55687072007-09-14 21:48:26 +00001143let Defs = [EAX,EDX,EFLAGS], Uses = [EAX,EDX] in
Sean Callanan2c48df22009-12-18 00:01:26 +00001144def DIV32r : I<0xF7, MRM6r, (outs), (ins GR32:$src), // EDX:EAX/r32 = EAX,EDX
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001145 "div{l}\t$src", []>;
Chris Lattnerc90ee9c2008-01-10 07:59:24 +00001146let mayLoad = 1 in {
Dale Johannesend8fd3562008-10-07 18:54:28 +00001147let Defs = [AL,AH,EFLAGS], Uses = [AX] in
Sean Callanan2c48df22009-12-18 00:01:26 +00001148def DIV8m : I<0xF6, MRM6m, (outs), (ins i8mem:$src), // AX/[mem8] = AL,AH
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001149 "div{b}\t$src", []>;
Evan Cheng55687072007-09-14 21:48:26 +00001150let Defs = [AX,DX,EFLAGS], Uses = [AX,DX] in
Sean Callanan2c48df22009-12-18 00:01:26 +00001151def DIV16m : I<0xF7, MRM6m, (outs), (ins i16mem:$src), // DX:AX/[mem16] = AX,DX
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001152 "div{w}\t$src", []>, OpSize;
Evan Cheng55687072007-09-14 21:48:26 +00001153let Defs = [EAX,EDX,EFLAGS], Uses = [EAX,EDX] in
Sean Callanan2c48df22009-12-18 00:01:26 +00001154 // EDX:EAX/[mem32] = EAX,EDX
1155def DIV32m : I<0xF7, MRM6m, (outs), (ins i32mem:$src),
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001156 "div{l}\t$src", []>;
Chris Lattnerc90ee9c2008-01-10 07:59:24 +00001157}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001158
1159// Signed division/remainder.
Dale Johannesend8fd3562008-10-07 18:54:28 +00001160let Defs = [AL,AH,EFLAGS], Uses = [AX] in
Sean Callanan2c48df22009-12-18 00:01:26 +00001161def IDIV8r : I<0xF6, MRM7r, (outs), (ins GR8:$src), // AX/r8 = AL,AH
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001162 "idiv{b}\t$src", []>;
Evan Cheng55687072007-09-14 21:48:26 +00001163let Defs = [AX,DX,EFLAGS], Uses = [AX,DX] in
Sean Callanan2c48df22009-12-18 00:01:26 +00001164def IDIV16r: I<0xF7, MRM7r, (outs), (ins GR16:$src), // DX:AX/r16 = AX,DX
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001165 "idiv{w}\t$src", []>, OpSize;
Evan Cheng55687072007-09-14 21:48:26 +00001166let Defs = [EAX,EDX,EFLAGS], Uses = [EAX,EDX] in
Sean Callanan2c48df22009-12-18 00:01:26 +00001167def IDIV32r: I<0xF7, MRM7r, (outs), (ins GR32:$src), // EDX:EAX/r32 = EAX,EDX
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001168 "idiv{l}\t$src", []>;
Chris Lattnerc90ee9c2008-01-10 07:59:24 +00001169let mayLoad = 1, mayLoad = 1 in {
Dale Johannesend8fd3562008-10-07 18:54:28 +00001170let Defs = [AL,AH,EFLAGS], Uses = [AX] in
Sean Callanan2c48df22009-12-18 00:01:26 +00001171def IDIV8m : I<0xF6, MRM7m, (outs), (ins i8mem:$src), // AX/[mem8] = AL,AH
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001172 "idiv{b}\t$src", []>;
Evan Cheng55687072007-09-14 21:48:26 +00001173let Defs = [AX,DX,EFLAGS], Uses = [AX,DX] in
Sean Callanan2c48df22009-12-18 00:01:26 +00001174def IDIV16m: I<0xF7, MRM7m, (outs), (ins i16mem:$src), // DX:AX/[mem16] = AX,DX
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001175 "idiv{w}\t$src", []>, OpSize;
Evan Cheng55687072007-09-14 21:48:26 +00001176let Defs = [EAX,EDX,EFLAGS], Uses = [EAX,EDX] in
Sean Callanan2c48df22009-12-18 00:01:26 +00001177def IDIV32m: I<0xF7, MRM7m, (outs), (ins i32mem:$src),
1178 // EDX:EAX/[mem32] = EAX,EDX
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001179 "idiv{l}\t$src", []>;
Chris Lattnerc90ee9c2008-01-10 07:59:24 +00001180}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001181
1182//===----------------------------------------------------------------------===//
Chris Lattnerc90ee9c2008-01-10 07:59:24 +00001183// Two address Instructions.
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001184//
1185let isTwoAddress = 1 in {
1186
1187// Conditional moves
Evan Cheng950aac02007-09-25 01:57:46 +00001188let Uses = [EFLAGS] in {
Dan Gohman29b998f2009-08-27 00:14:12 +00001189
Dan Gohman30afe012009-10-29 18:10:34 +00001190// X86 doesn't have 8-bit conditional moves. Use a customInserter to
Dan Gohman29b998f2009-08-27 00:14:12 +00001191// emit control flow. An alternative to this is to mark i8 SELECT as Promote,
1192// however that requires promoting the operands, and can induce additional
Dan Gohman1596dd22009-08-29 22:19:15 +00001193// i8 register pressure. Note that CMOV_GR8 is conservatively considered to
1194// clobber EFLAGS, because if one of the operands is zero, the expansion
1195// could involve an xor.
Dan Gohman30afe012009-10-29 18:10:34 +00001196let usesCustomInserter = 1, isTwoAddress = 0, Defs = [EFLAGS] in
Dan Gohman29b998f2009-08-27 00:14:12 +00001197def CMOV_GR8 : I<0, Pseudo,
1198 (outs GR8:$dst), (ins GR8:$src1, GR8:$src2, i8imm:$cond),
1199 "#CMOV_GR8 PSEUDO!",
1200 [(set GR8:$dst, (X86cmov GR8:$src1, GR8:$src2,
1201 imm:$cond, EFLAGS))]>;
1202
Dan Gohman90adb6c2009-08-27 18:16:24 +00001203let isCommutable = 1 in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001204def CMOVB16rr : I<0x42, MRMSrcReg, // if <u, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +00001205 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Sean Callanan2c48df22009-12-18 00:01:26 +00001206 "cmovb{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001207 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001208 X86_COND_B, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001209 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001210def CMOVB32rr : I<0x42, MRMSrcReg, // if <u, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +00001211 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Sean Callanan2c48df22009-12-18 00:01:26 +00001212 "cmovb{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001213 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001214 X86_COND_B, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001215 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001216def CMOVAE16rr: I<0x43, MRMSrcReg, // if >=u, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +00001217 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Sean Callanan2c48df22009-12-18 00:01:26 +00001218 "cmovae{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001219 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001220 X86_COND_AE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001221 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001222def CMOVAE32rr: I<0x43, MRMSrcReg, // if >=u, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +00001223 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Sean Callanan2c48df22009-12-18 00:01:26 +00001224 "cmovae{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001225 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001226 X86_COND_AE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001227 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001228def CMOVE16rr : I<0x44, MRMSrcReg, // if ==, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +00001229 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Sean Callanan2c48df22009-12-18 00:01:26 +00001230 "cmove{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001231 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001232 X86_COND_E, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001233 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001234def CMOVE32rr : I<0x44, MRMSrcReg, // if ==, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +00001235 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Sean Callanan2c48df22009-12-18 00:01:26 +00001236 "cmove{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001237 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001238 X86_COND_E, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001239 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001240def CMOVNE16rr: I<0x45, MRMSrcReg, // if !=, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +00001241 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Sean Callanan2c48df22009-12-18 00:01:26 +00001242 "cmovne{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001243 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001244 X86_COND_NE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001245 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001246def CMOVNE32rr: I<0x45, MRMSrcReg, // if !=, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +00001247 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Sean Callanan2c48df22009-12-18 00:01:26 +00001248 "cmovne{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001249 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001250 X86_COND_NE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001251 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001252def CMOVBE16rr: I<0x46, MRMSrcReg, // if <=u, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +00001253 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Sean Callanan2c48df22009-12-18 00:01:26 +00001254 "cmovbe{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001255 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001256 X86_COND_BE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001257 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001258def CMOVBE32rr: I<0x46, MRMSrcReg, // if <=u, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +00001259 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Sean Callanan2c48df22009-12-18 00:01:26 +00001260 "cmovbe{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001261 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001262 X86_COND_BE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001263 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001264def CMOVA16rr : I<0x47, MRMSrcReg, // if >u, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +00001265 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Sean Callanan2c48df22009-12-18 00:01:26 +00001266 "cmova{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001267 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001268 X86_COND_A, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001269 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001270def CMOVA32rr : I<0x47, MRMSrcReg, // if >u, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +00001271 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Sean Callanan2c48df22009-12-18 00:01:26 +00001272 "cmova{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001273 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001274 X86_COND_A, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001275 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001276def CMOVL16rr : I<0x4C, MRMSrcReg, // if <s, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +00001277 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Sean Callanan2c48df22009-12-18 00:01:26 +00001278 "cmovl{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001279 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001280 X86_COND_L, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001281 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001282def CMOVL32rr : I<0x4C, MRMSrcReg, // if <s, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +00001283 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Sean Callanan2c48df22009-12-18 00:01:26 +00001284 "cmovl{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001285 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001286 X86_COND_L, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001287 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001288def CMOVGE16rr: I<0x4D, MRMSrcReg, // if >=s, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +00001289 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Sean Callanan2c48df22009-12-18 00:01:26 +00001290 "cmovge{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001291 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001292 X86_COND_GE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001293 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001294def CMOVGE32rr: I<0x4D, MRMSrcReg, // if >=s, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +00001295 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Sean Callanan2c48df22009-12-18 00:01:26 +00001296 "cmovge{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001297 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001298 X86_COND_GE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001299 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001300def CMOVLE16rr: I<0x4E, MRMSrcReg, // if <=s, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +00001301 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Sean Callanan2c48df22009-12-18 00:01:26 +00001302 "cmovle{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001303 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001304 X86_COND_LE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001305 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001306def CMOVLE32rr: I<0x4E, MRMSrcReg, // if <=s, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +00001307 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Sean Callanan2c48df22009-12-18 00:01:26 +00001308 "cmovle{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001309 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001310 X86_COND_LE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001311 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001312def CMOVG16rr : I<0x4F, MRMSrcReg, // if >s, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +00001313 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Sean Callanan2c48df22009-12-18 00:01:26 +00001314 "cmovg{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001315 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001316 X86_COND_G, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001317 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001318def CMOVG32rr : I<0x4F, MRMSrcReg, // if >s, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +00001319 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Sean Callanan2c48df22009-12-18 00:01:26 +00001320 "cmovg{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001321 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001322 X86_COND_G, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001323 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001324def CMOVS16rr : I<0x48, MRMSrcReg, // if signed, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +00001325 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Sean Callanan2c48df22009-12-18 00:01:26 +00001326 "cmovs{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001327 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001328 X86_COND_S, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001329 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001330def CMOVS32rr : I<0x48, MRMSrcReg, // if signed, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +00001331 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Sean Callanan2c48df22009-12-18 00:01:26 +00001332 "cmovs{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001333 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001334 X86_COND_S, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001335 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001336def CMOVNS16rr: I<0x49, MRMSrcReg, // if !signed, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +00001337 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Sean Callanan2c48df22009-12-18 00:01:26 +00001338 "cmovns{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001339 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001340 X86_COND_NS, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001341 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001342def CMOVNS32rr: I<0x49, MRMSrcReg, // if !signed, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +00001343 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Sean Callanan2c48df22009-12-18 00:01:26 +00001344 "cmovns{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001345 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001346 X86_COND_NS, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001347 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001348def CMOVP16rr : I<0x4A, MRMSrcReg, // if parity, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +00001349 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Sean Callanan2c48df22009-12-18 00:01:26 +00001350 "cmovp{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001351 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001352 X86_COND_P, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001353 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001354def CMOVP32rr : I<0x4A, MRMSrcReg, // if parity, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +00001355 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Sean Callanan2c48df22009-12-18 00:01:26 +00001356 "cmovp{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001357 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001358 X86_COND_P, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001359 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001360def CMOVNP16rr : I<0x4B, MRMSrcReg, // if !parity, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +00001361 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Sean Callanan2c48df22009-12-18 00:01:26 +00001362 "cmovnp{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001363 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001364 X86_COND_NP, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001365 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001366def CMOVNP32rr : I<0x4B, MRMSrcReg, // if !parity, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +00001367 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Sean Callanan2c48df22009-12-18 00:01:26 +00001368 "cmovnp{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001369 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001370 X86_COND_NP, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001371 TB;
Dan Gohman12fd4d72009-01-07 00:35:10 +00001372def CMOVO16rr : I<0x40, MRMSrcReg, // if overflow, GR16 = GR16
1373 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Sean Callanan2c48df22009-12-18 00:01:26 +00001374 "cmovo{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohman12fd4d72009-01-07 00:35:10 +00001375 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
1376 X86_COND_O, EFLAGS))]>,
1377 TB, OpSize;
1378def CMOVO32rr : I<0x40, MRMSrcReg, // if overflow, GR32 = GR32
1379 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Sean Callanan2c48df22009-12-18 00:01:26 +00001380 "cmovo{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohman12fd4d72009-01-07 00:35:10 +00001381 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
1382 X86_COND_O, EFLAGS))]>,
Evan Cheng950aac02007-09-25 01:57:46 +00001383 TB;
Dan Gohman12fd4d72009-01-07 00:35:10 +00001384def CMOVNO16rr : I<0x41, MRMSrcReg, // if !overflow, GR16 = GR16
1385 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Sean Callanan2c48df22009-12-18 00:01:26 +00001386 "cmovno{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohman12fd4d72009-01-07 00:35:10 +00001387 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
1388 X86_COND_NO, EFLAGS))]>,
1389 TB, OpSize;
1390def CMOVNO32rr : I<0x41, MRMSrcReg, // if !overflow, GR32 = GR32
1391 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Sean Callanan2c48df22009-12-18 00:01:26 +00001392 "cmovno{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohman12fd4d72009-01-07 00:35:10 +00001393 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
1394 X86_COND_NO, EFLAGS))]>,
1395 TB;
1396} // isCommutable = 1
Evan Cheng926658c2007-10-05 23:13:21 +00001397
1398def CMOVB16rm : I<0x42, MRMSrcMem, // if <u, GR16 = [mem16]
1399 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
Sean Callanan2c48df22009-12-18 00:01:26 +00001400 "cmovb{w}\t{$src2, $dst|$dst, $src2}",
Evan Cheng926658c2007-10-05 23:13:21 +00001401 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1402 X86_COND_B, EFLAGS))]>,
1403 TB, OpSize;
1404def CMOVB32rm : I<0x42, MRMSrcMem, // if <u, GR32 = [mem32]
1405 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Sean Callanan2c48df22009-12-18 00:01:26 +00001406 "cmovb{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng926658c2007-10-05 23:13:21 +00001407 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1408 X86_COND_B, EFLAGS))]>,
1409 TB;
1410def CMOVAE16rm: I<0x43, MRMSrcMem, // if >=u, GR16 = [mem16]
1411 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
Sean Callanan2c48df22009-12-18 00:01:26 +00001412 "cmovae{w}\t{$src2, $dst|$dst, $src2}",
Evan Cheng926658c2007-10-05 23:13:21 +00001413 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1414 X86_COND_AE, EFLAGS))]>,
1415 TB, OpSize;
1416def CMOVAE32rm: I<0x43, MRMSrcMem, // if >=u, GR32 = [mem32]
1417 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Sean Callanan2c48df22009-12-18 00:01:26 +00001418 "cmovae{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng926658c2007-10-05 23:13:21 +00001419 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1420 X86_COND_AE, EFLAGS))]>,
1421 TB;
1422def CMOVE16rm : I<0x44, MRMSrcMem, // if ==, GR16 = [mem16]
1423 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
Sean Callanan2c48df22009-12-18 00:01:26 +00001424 "cmove{w}\t{$src2, $dst|$dst, $src2}",
Evan Cheng926658c2007-10-05 23:13:21 +00001425 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1426 X86_COND_E, EFLAGS))]>,
1427 TB, OpSize;
1428def CMOVE32rm : I<0x44, MRMSrcMem, // if ==, GR32 = [mem32]
1429 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Sean Callanan2c48df22009-12-18 00:01:26 +00001430 "cmove{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng926658c2007-10-05 23:13:21 +00001431 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1432 X86_COND_E, EFLAGS))]>,
1433 TB;
1434def CMOVNE16rm: I<0x45, MRMSrcMem, // if !=, GR16 = [mem16]
1435 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
Sean Callanan2c48df22009-12-18 00:01:26 +00001436 "cmovne{w}\t{$src2, $dst|$dst, $src2}",
Evan Cheng926658c2007-10-05 23:13:21 +00001437 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1438 X86_COND_NE, EFLAGS))]>,
1439 TB, OpSize;
1440def CMOVNE32rm: I<0x45, MRMSrcMem, // if !=, GR32 = [mem32]
1441 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Sean Callanan2c48df22009-12-18 00:01:26 +00001442 "cmovne{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng926658c2007-10-05 23:13:21 +00001443 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1444 X86_COND_NE, EFLAGS))]>,
1445 TB;
1446def CMOVBE16rm: I<0x46, MRMSrcMem, // if <=u, GR16 = [mem16]
1447 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
Sean Callanan2c48df22009-12-18 00:01:26 +00001448 "cmovbe{w}\t{$src2, $dst|$dst, $src2}",
Evan Cheng926658c2007-10-05 23:13:21 +00001449 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1450 X86_COND_BE, EFLAGS))]>,
1451 TB, OpSize;
1452def CMOVBE32rm: I<0x46, MRMSrcMem, // if <=u, GR32 = [mem32]
1453 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Sean Callanan2c48df22009-12-18 00:01:26 +00001454 "cmovbe{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng926658c2007-10-05 23:13:21 +00001455 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1456 X86_COND_BE, EFLAGS))]>,
1457 TB;
1458def CMOVA16rm : I<0x47, MRMSrcMem, // if >u, GR16 = [mem16]
1459 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
Sean Callanan2c48df22009-12-18 00:01:26 +00001460 "cmova{w}\t{$src2, $dst|$dst, $src2}",
Evan Cheng926658c2007-10-05 23:13:21 +00001461 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1462 X86_COND_A, EFLAGS))]>,
1463 TB, OpSize;
1464def CMOVA32rm : I<0x47, MRMSrcMem, // if >u, GR32 = [mem32]
1465 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Sean Callanan2c48df22009-12-18 00:01:26 +00001466 "cmova{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng926658c2007-10-05 23:13:21 +00001467 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1468 X86_COND_A, EFLAGS))]>,
1469 TB;
1470def CMOVL16rm : I<0x4C, MRMSrcMem, // if <s, GR16 = [mem16]
1471 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
Sean Callanan2c48df22009-12-18 00:01:26 +00001472 "cmovl{w}\t{$src2, $dst|$dst, $src2}",
Evan Cheng926658c2007-10-05 23:13:21 +00001473 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1474 X86_COND_L, EFLAGS))]>,
1475 TB, OpSize;
1476def CMOVL32rm : I<0x4C, MRMSrcMem, // if <s, GR32 = [mem32]
1477 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Sean Callanan2c48df22009-12-18 00:01:26 +00001478 "cmovl{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng926658c2007-10-05 23:13:21 +00001479 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1480 X86_COND_L, EFLAGS))]>,
1481 TB;
1482def CMOVGE16rm: I<0x4D, MRMSrcMem, // if >=s, GR16 = [mem16]
1483 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
Sean Callanan2c48df22009-12-18 00:01:26 +00001484 "cmovge{w}\t{$src2, $dst|$dst, $src2}",
Evan Cheng926658c2007-10-05 23:13:21 +00001485 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1486 X86_COND_GE, EFLAGS))]>,
1487 TB, OpSize;
1488def CMOVGE32rm: I<0x4D, MRMSrcMem, // if >=s, GR32 = [mem32]
1489 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Sean Callanan2c48df22009-12-18 00:01:26 +00001490 "cmovge{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng926658c2007-10-05 23:13:21 +00001491 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1492 X86_COND_GE, EFLAGS))]>,
1493 TB;
1494def CMOVLE16rm: I<0x4E, MRMSrcMem, // if <=s, GR16 = [mem16]
1495 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
Sean Callanan2c48df22009-12-18 00:01:26 +00001496 "cmovle{w}\t{$src2, $dst|$dst, $src2}",
Evan Cheng926658c2007-10-05 23:13:21 +00001497 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1498 X86_COND_LE, EFLAGS))]>,
1499 TB, OpSize;
1500def CMOVLE32rm: I<0x4E, MRMSrcMem, // if <=s, GR32 = [mem32]
1501 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Sean Callanan2c48df22009-12-18 00:01:26 +00001502 "cmovle{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng926658c2007-10-05 23:13:21 +00001503 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1504 X86_COND_LE, EFLAGS))]>,
1505 TB;
1506def CMOVG16rm : I<0x4F, MRMSrcMem, // if >s, GR16 = [mem16]
1507 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
Sean Callanan2c48df22009-12-18 00:01:26 +00001508 "cmovg{w}\t{$src2, $dst|$dst, $src2}",
Evan Cheng926658c2007-10-05 23:13:21 +00001509 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1510 X86_COND_G, EFLAGS))]>,
1511 TB, OpSize;
1512def CMOVG32rm : I<0x4F, MRMSrcMem, // if >s, GR32 = [mem32]
1513 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Sean Callanan2c48df22009-12-18 00:01:26 +00001514 "cmovg{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng926658c2007-10-05 23:13:21 +00001515 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1516 X86_COND_G, EFLAGS))]>,
1517 TB;
1518def CMOVS16rm : I<0x48, MRMSrcMem, // if signed, GR16 = [mem16]
1519 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
Sean Callanan2c48df22009-12-18 00:01:26 +00001520 "cmovs{w}\t{$src2, $dst|$dst, $src2}",
Evan Cheng926658c2007-10-05 23:13:21 +00001521 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1522 X86_COND_S, EFLAGS))]>,
1523 TB, OpSize;
1524def CMOVS32rm : I<0x48, MRMSrcMem, // if signed, GR32 = [mem32]
1525 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Sean Callanan2c48df22009-12-18 00:01:26 +00001526 "cmovs{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng926658c2007-10-05 23:13:21 +00001527 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1528 X86_COND_S, EFLAGS))]>,
1529 TB;
1530def CMOVNS16rm: I<0x49, MRMSrcMem, // if !signed, GR16 = [mem16]
1531 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
Sean Callanan2c48df22009-12-18 00:01:26 +00001532 "cmovns{w}\t{$src2, $dst|$dst, $src2}",
Evan Cheng926658c2007-10-05 23:13:21 +00001533 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1534 X86_COND_NS, EFLAGS))]>,
1535 TB, OpSize;
1536def CMOVNS32rm: I<0x49, MRMSrcMem, // if !signed, GR32 = [mem32]
1537 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Sean Callanan2c48df22009-12-18 00:01:26 +00001538 "cmovns{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng926658c2007-10-05 23:13:21 +00001539 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1540 X86_COND_NS, EFLAGS))]>,
1541 TB;
1542def CMOVP16rm : I<0x4A, MRMSrcMem, // if parity, GR16 = [mem16]
1543 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
Sean Callanan2c48df22009-12-18 00:01:26 +00001544 "cmovp{w}\t{$src2, $dst|$dst, $src2}",
Evan Cheng926658c2007-10-05 23:13:21 +00001545 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1546 X86_COND_P, EFLAGS))]>,
1547 TB, OpSize;
1548def CMOVP32rm : I<0x4A, MRMSrcMem, // if parity, GR32 = [mem32]
1549 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Sean Callanan2c48df22009-12-18 00:01:26 +00001550 "cmovp{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng926658c2007-10-05 23:13:21 +00001551 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1552 X86_COND_P, EFLAGS))]>,
1553 TB;
1554def CMOVNP16rm : I<0x4B, MRMSrcMem, // if !parity, GR16 = [mem16]
1555 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
Sean Callanan2c48df22009-12-18 00:01:26 +00001556 "cmovnp{w}\t{$src2, $dst|$dst, $src2}",
Evan Cheng926658c2007-10-05 23:13:21 +00001557 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1558 X86_COND_NP, EFLAGS))]>,
1559 TB, OpSize;
Dan Gohman12fd4d72009-01-07 00:35:10 +00001560def CMOVNP32rm : I<0x4B, MRMSrcMem, // if !parity, GR32 = [mem32]
1561 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Sean Callanan2c48df22009-12-18 00:01:26 +00001562 "cmovnp{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohman12fd4d72009-01-07 00:35:10 +00001563 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1564 X86_COND_NP, EFLAGS))]>,
1565 TB;
1566def CMOVO16rm : I<0x40, MRMSrcMem, // if overflow, GR16 = [mem16]
1567 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
Sean Callanan2c48df22009-12-18 00:01:26 +00001568 "cmovo{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohman12fd4d72009-01-07 00:35:10 +00001569 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1570 X86_COND_O, EFLAGS))]>,
1571 TB, OpSize;
1572def CMOVO32rm : I<0x40, MRMSrcMem, // if overflow, GR32 = [mem32]
1573 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Sean Callanan2c48df22009-12-18 00:01:26 +00001574 "cmovo{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohman12fd4d72009-01-07 00:35:10 +00001575 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1576 X86_COND_O, EFLAGS))]>,
1577 TB;
1578def CMOVNO16rm : I<0x41, MRMSrcMem, // if !overflow, GR16 = [mem16]
1579 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
Sean Callanan2c48df22009-12-18 00:01:26 +00001580 "cmovno{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohman12fd4d72009-01-07 00:35:10 +00001581 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1582 X86_COND_NO, EFLAGS))]>,
1583 TB, OpSize;
1584def CMOVNO32rm : I<0x41, MRMSrcMem, // if !overflow, GR32 = [mem32]
1585 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Sean Callanan2c48df22009-12-18 00:01:26 +00001586 "cmovno{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohman12fd4d72009-01-07 00:35:10 +00001587 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1588 X86_COND_NO, EFLAGS))]>,
1589 TB;
Evan Cheng950aac02007-09-25 01:57:46 +00001590} // Uses = [EFLAGS]
1591
1592
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001593// unary instructions
1594let CodeSize = 2 in {
Evan Cheng55687072007-09-14 21:48:26 +00001595let Defs = [EFLAGS] in {
Dan Gohman91888f02007-07-31 20:11:57 +00001596def NEG8r : I<0xF6, MRM3r, (outs GR8 :$dst), (ins GR8 :$src), "neg{b}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001597 [(set GR8:$dst, (ineg GR8:$src)),
1598 (implicit EFLAGS)]>;
Dan Gohman91888f02007-07-31 20:11:57 +00001599def NEG16r : I<0xF7, MRM3r, (outs GR16:$dst), (ins GR16:$src), "neg{w}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001600 [(set GR16:$dst, (ineg GR16:$src)),
1601 (implicit EFLAGS)]>, OpSize;
Dan Gohman91888f02007-07-31 20:11:57 +00001602def NEG32r : I<0xF7, MRM3r, (outs GR32:$dst), (ins GR32:$src), "neg{l}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001603 [(set GR32:$dst, (ineg GR32:$src)),
1604 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001605let isTwoAddress = 0 in {
Dan Gohman91888f02007-07-31 20:11:57 +00001606 def NEG8m : I<0xF6, MRM3m, (outs), (ins i8mem :$dst), "neg{b}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001607 [(store (ineg (loadi8 addr:$dst)), addr:$dst),
1608 (implicit EFLAGS)]>;
Dan Gohman91888f02007-07-31 20:11:57 +00001609 def NEG16m : I<0xF7, MRM3m, (outs), (ins i16mem:$dst), "neg{w}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001610 [(store (ineg (loadi16 addr:$dst)), addr:$dst),
1611 (implicit EFLAGS)]>, OpSize;
Dan Gohman91888f02007-07-31 20:11:57 +00001612 def NEG32m : I<0xF7, MRM3m, (outs), (ins i32mem:$dst), "neg{l}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001613 [(store (ineg (loadi32 addr:$dst)), addr:$dst),
1614 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001615}
Evan Cheng55687072007-09-14 21:48:26 +00001616} // Defs = [EFLAGS]
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001617
Evan Chengc6cee682009-01-21 02:09:05 +00001618// Match xor -1 to not. Favors these over a move imm + xor to save code size.
1619let AddedComplexity = 15 in {
Dan Gohman91888f02007-07-31 20:11:57 +00001620def NOT8r : I<0xF6, MRM2r, (outs GR8 :$dst), (ins GR8 :$src), "not{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001621 [(set GR8:$dst, (not GR8:$src))]>;
Dan Gohman91888f02007-07-31 20:11:57 +00001622def NOT16r : I<0xF7, MRM2r, (outs GR16:$dst), (ins GR16:$src), "not{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001623 [(set GR16:$dst, (not GR16:$src))]>, OpSize;
Dan Gohman91888f02007-07-31 20:11:57 +00001624def NOT32r : I<0xF7, MRM2r, (outs GR32:$dst), (ins GR32:$src), "not{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001625 [(set GR32:$dst, (not GR32:$src))]>;
Evan Chengc6cee682009-01-21 02:09:05 +00001626}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001627let isTwoAddress = 0 in {
Dan Gohman91888f02007-07-31 20:11:57 +00001628 def NOT8m : I<0xF6, MRM2m, (outs), (ins i8mem :$dst), "not{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001629 [(store (not (loadi8 addr:$dst)), addr:$dst)]>;
Dan Gohman91888f02007-07-31 20:11:57 +00001630 def NOT16m : I<0xF7, MRM2m, (outs), (ins i16mem:$dst), "not{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001631 [(store (not (loadi16 addr:$dst)), addr:$dst)]>, OpSize;
Dan Gohman91888f02007-07-31 20:11:57 +00001632 def NOT32m : I<0xF7, MRM2m, (outs), (ins i32mem:$dst), "not{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001633 [(store (not (loadi32 addr:$dst)), addr:$dst)]>;
1634}
1635} // CodeSize
1636
1637// TODO: inc/dec is slow for P4, but fast for Pentium-M.
Evan Cheng55687072007-09-14 21:48:26 +00001638let Defs = [EFLAGS] in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001639let CodeSize = 2 in
Dan Gohman91888f02007-07-31 20:11:57 +00001640def INC8r : I<0xFE, MRM0r, (outs GR8 :$dst), (ins GR8 :$src), "inc{b}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001641 [(set GR8:$dst, (add GR8:$src, 1)),
1642 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001643let isConvertibleToThreeAddress = 1, CodeSize = 1 in { // Can xform into LEA.
Sean Callanan2c48df22009-12-18 00:01:26 +00001644def INC16r : I<0x40, AddRegFrm, (outs GR16:$dst), (ins GR16:$src),
1645 "inc{w}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001646 [(set GR16:$dst, (add GR16:$src, 1)),
1647 (implicit EFLAGS)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001648 OpSize, Requires<[In32BitMode]>;
Sean Callanan2c48df22009-12-18 00:01:26 +00001649def INC32r : I<0x40, AddRegFrm, (outs GR32:$dst), (ins GR32:$src),
1650 "inc{l}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001651 [(set GR32:$dst, (add GR32:$src, 1)),
1652 (implicit EFLAGS)]>, Requires<[In32BitMode]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001653}
1654let isTwoAddress = 0, CodeSize = 2 in {
Dan Gohman91888f02007-07-31 20:11:57 +00001655 def INC8m : I<0xFE, MRM0m, (outs), (ins i8mem :$dst), "inc{b}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001656 [(store (add (loadi8 addr:$dst), 1), addr:$dst),
1657 (implicit EFLAGS)]>;
Dan Gohman91888f02007-07-31 20:11:57 +00001658 def INC16m : I<0xFF, MRM0m, (outs), (ins i16mem:$dst), "inc{w}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001659 [(store (add (loadi16 addr:$dst), 1), addr:$dst),
1660 (implicit EFLAGS)]>,
Evan Cheng4a7e72f2007-10-19 21:23:22 +00001661 OpSize, Requires<[In32BitMode]>;
Dan Gohman91888f02007-07-31 20:11:57 +00001662 def INC32m : I<0xFF, MRM0m, (outs), (ins i32mem:$dst), "inc{l}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001663 [(store (add (loadi32 addr:$dst), 1), addr:$dst),
1664 (implicit EFLAGS)]>,
Evan Cheng4a7e72f2007-10-19 21:23:22 +00001665 Requires<[In32BitMode]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001666}
1667
1668let CodeSize = 2 in
Dan Gohman91888f02007-07-31 20:11:57 +00001669def DEC8r : I<0xFE, MRM1r, (outs GR8 :$dst), (ins GR8 :$src), "dec{b}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001670 [(set GR8:$dst, (add GR8:$src, -1)),
1671 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001672let isConvertibleToThreeAddress = 1, CodeSize = 1 in { // Can xform into LEA.
Sean Callanan2c48df22009-12-18 00:01:26 +00001673def DEC16r : I<0x48, AddRegFrm, (outs GR16:$dst), (ins GR16:$src),
1674 "dec{w}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001675 [(set GR16:$dst, (add GR16:$src, -1)),
1676 (implicit EFLAGS)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001677 OpSize, Requires<[In32BitMode]>;
Sean Callanan2c48df22009-12-18 00:01:26 +00001678def DEC32r : I<0x48, AddRegFrm, (outs GR32:$dst), (ins GR32:$src),
1679 "dec{l}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001680 [(set GR32:$dst, (add GR32:$src, -1)),
1681 (implicit EFLAGS)]>, Requires<[In32BitMode]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001682}
1683
1684let isTwoAddress = 0, CodeSize = 2 in {
Dan Gohman91888f02007-07-31 20:11:57 +00001685 def DEC8m : I<0xFE, MRM1m, (outs), (ins i8mem :$dst), "dec{b}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001686 [(store (add (loadi8 addr:$dst), -1), addr:$dst),
1687 (implicit EFLAGS)]>;
Dan Gohman91888f02007-07-31 20:11:57 +00001688 def DEC16m : I<0xFF, MRM1m, (outs), (ins i16mem:$dst), "dec{w}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001689 [(store (add (loadi16 addr:$dst), -1), addr:$dst),
1690 (implicit EFLAGS)]>,
Evan Cheng4a7e72f2007-10-19 21:23:22 +00001691 OpSize, Requires<[In32BitMode]>;
Dan Gohman91888f02007-07-31 20:11:57 +00001692 def DEC32m : I<0xFF, MRM1m, (outs), (ins i32mem:$dst), "dec{l}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001693 [(store (add (loadi32 addr:$dst), -1), addr:$dst),
1694 (implicit EFLAGS)]>,
Evan Cheng4a7e72f2007-10-19 21:23:22 +00001695 Requires<[In32BitMode]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001696}
Evan Cheng55687072007-09-14 21:48:26 +00001697} // Defs = [EFLAGS]
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001698
1699// Logical operators...
Evan Cheng55687072007-09-14 21:48:26 +00001700let Defs = [EFLAGS] in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001701let isCommutable = 1 in { // X = AND Y, Z --> X = AND Z, Y
1702def AND8rr : I<0x20, MRMDestReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001703 (outs GR8 :$dst), (ins GR8 :$src1, GR8 :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001704 "and{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001705 [(set GR8:$dst, (and GR8:$src1, GR8:$src2)),
1706 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001707def AND16rr : I<0x21, MRMDestReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001708 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001709 "and{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001710 [(set GR16:$dst, (and GR16:$src1, GR16:$src2)),
1711 (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001712def AND32rr : I<0x21, MRMDestReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001713 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001714 "and{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001715 [(set GR32:$dst, (and GR32:$src1, GR32:$src2)),
1716 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001717}
1718
Sean Callanan2c48df22009-12-18 00:01:26 +00001719// AND instructions with the destination register in REG and the source register
1720// in R/M. Included for the disassembler.
1721def AND8rr_REV : I<0x22, MRMSrcReg, (outs GR8:$dst), (ins GR8:$src1, GR8:$src2),
1722 "and{b}\t{$src2, $dst|$dst, $src2}", []>;
1723def AND16rr_REV : I<0x23, MRMSrcReg, (outs GR16:$dst),
1724 (ins GR16:$src1, GR16:$src2),
1725 "and{w}\t{$src2, $dst|$dst, $src2}", []>, OpSize;
1726def AND32rr_REV : I<0x23, MRMSrcReg, (outs GR32:$dst),
1727 (ins GR32:$src1, GR32:$src2),
1728 "and{l}\t{$src2, $dst|$dst, $src2}", []>;
1729
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001730def AND8rm : I<0x22, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001731 (outs GR8 :$dst), (ins GR8 :$src1, i8mem :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001732 "and{b}\t{$src2, $dst|$dst, $src2}",
Chris Lattner12208612009-04-10 00:16:23 +00001733 [(set GR8:$dst, (and GR8:$src1, (loadi8 addr:$src2))),
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001734 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001735def AND16rm : I<0x23, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001736 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001737 "and{w}\t{$src2, $dst|$dst, $src2}",
Chris Lattner12208612009-04-10 00:16:23 +00001738 [(set GR16:$dst, (and GR16:$src1, (loadi16 addr:$src2))),
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001739 (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001740def AND32rm : I<0x23, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001741 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001742 "and{l}\t{$src2, $dst|$dst, $src2}",
Chris Lattner12208612009-04-10 00:16:23 +00001743 [(set GR32:$dst, (and GR32:$src1, (loadi32 addr:$src2))),
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001744 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001745
1746def AND8ri : Ii8<0x80, MRM4r,
Evan Chengb783fa32007-07-19 01:14:50 +00001747 (outs GR8 :$dst), (ins GR8 :$src1, i8imm :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001748 "and{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001749 [(set GR8:$dst, (and GR8:$src1, imm:$src2)),
1750 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001751def AND16ri : Ii16<0x81, MRM4r,
Evan Chengb783fa32007-07-19 01:14:50 +00001752 (outs GR16:$dst), (ins GR16:$src1, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001753 "and{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001754 [(set GR16:$dst, (and GR16:$src1, imm:$src2)),
1755 (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001756def AND32ri : Ii32<0x81, MRM4r,
Evan Chengb783fa32007-07-19 01:14:50 +00001757 (outs GR32:$dst), (ins GR32:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001758 "and{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001759 [(set GR32:$dst, (and GR32:$src1, imm:$src2)),
1760 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001761def AND16ri8 : Ii8<0x83, MRM4r,
Evan Chengb783fa32007-07-19 01:14:50 +00001762 (outs GR16:$dst), (ins GR16:$src1, i16i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001763 "and{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001764 [(set GR16:$dst, (and GR16:$src1, i16immSExt8:$src2)),
1765 (implicit EFLAGS)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001766 OpSize;
1767def AND32ri8 : Ii8<0x83, MRM4r,
Evan Chengb783fa32007-07-19 01:14:50 +00001768 (outs GR32:$dst), (ins GR32:$src1, i32i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001769 "and{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001770 [(set GR32:$dst, (and GR32:$src1, i32immSExt8:$src2)),
1771 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001772
1773let isTwoAddress = 0 in {
1774 def AND8mr : I<0x20, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001775 (outs), (ins i8mem :$dst, GR8 :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001776 "and{b}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001777 [(store (and (load addr:$dst), GR8:$src), addr:$dst),
1778 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001779 def AND16mr : I<0x21, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001780 (outs), (ins i16mem:$dst, GR16:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001781 "and{w}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001782 [(store (and (load addr:$dst), GR16:$src), addr:$dst),
1783 (implicit EFLAGS)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001784 OpSize;
1785 def AND32mr : I<0x21, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001786 (outs), (ins i32mem:$dst, GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001787 "and{l}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001788 [(store (and (load addr:$dst), GR32:$src), addr:$dst),
1789 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001790 def AND8mi : Ii8<0x80, MRM4m,
Evan Chengb783fa32007-07-19 01:14:50 +00001791 (outs), (ins i8mem :$dst, i8imm :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001792 "and{b}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001793 [(store (and (loadi8 addr:$dst), imm:$src), addr:$dst),
1794 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001795 def AND16mi : Ii16<0x81, MRM4m,
Evan Chengb783fa32007-07-19 01:14:50 +00001796 (outs), (ins i16mem:$dst, i16imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001797 "and{w}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001798 [(store (and (loadi16 addr:$dst), imm:$src), addr:$dst),
1799 (implicit EFLAGS)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001800 OpSize;
1801 def AND32mi : Ii32<0x81, MRM4m,
Evan Chengb783fa32007-07-19 01:14:50 +00001802 (outs), (ins i32mem:$dst, i32imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001803 "and{l}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001804 [(store (and (loadi32 addr:$dst), imm:$src), addr:$dst),
1805 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001806 def AND16mi8 : Ii8<0x83, MRM4m,
Evan Chengb783fa32007-07-19 01:14:50 +00001807 (outs), (ins i16mem:$dst, i16i8imm :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001808 "and{w}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001809 [(store (and (load addr:$dst), i16immSExt8:$src), addr:$dst),
1810 (implicit EFLAGS)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001811 OpSize;
1812 def AND32mi8 : Ii8<0x83, MRM4m,
Evan Chengb783fa32007-07-19 01:14:50 +00001813 (outs), (ins i32mem:$dst, i32i8imm :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001814 "and{l}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001815 [(store (and (load addr:$dst), i32immSExt8:$src), addr:$dst),
1816 (implicit EFLAGS)]>;
Sean Callanan251676e2009-09-02 00:55:49 +00001817
1818 def AND8i8 : Ii8<0x24, RawFrm, (outs), (ins i8imm:$src),
1819 "and{b}\t{$src, %al|%al, $src}", []>;
1820 def AND16i16 : Ii16<0x25, RawFrm, (outs), (ins i16imm:$src),
1821 "and{w}\t{$src, %ax|%ax, $src}", []>, OpSize;
1822 def AND32i32 : Ii32<0x25, RawFrm, (outs), (ins i32imm:$src),
1823 "and{l}\t{$src, %eax|%eax, $src}", []>;
1824
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001825}
1826
1827
1828let isCommutable = 1 in { // X = OR Y, Z --> X = OR Z, Y
Sean Callanan2c48df22009-12-18 00:01:26 +00001829def OR8rr : I<0x08, MRMDestReg, (outs GR8 :$dst),
1830 (ins GR8 :$src1, GR8 :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001831 "or{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001832 [(set GR8:$dst, (or GR8:$src1, GR8:$src2)),
1833 (implicit EFLAGS)]>;
Sean Callanan2c48df22009-12-18 00:01:26 +00001834def OR16rr : I<0x09, MRMDestReg, (outs GR16:$dst),
1835 (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001836 "or{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001837 [(set GR16:$dst, (or GR16:$src1, GR16:$src2)),
1838 (implicit EFLAGS)]>, OpSize;
Sean Callanan2c48df22009-12-18 00:01:26 +00001839def OR32rr : I<0x09, MRMDestReg, (outs GR32:$dst),
1840 (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001841 "or{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001842 [(set GR32:$dst, (or GR32:$src1, GR32:$src2)),
1843 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001844}
Sean Callanan2c48df22009-12-18 00:01:26 +00001845
1846// OR instructions with the destination register in REG and the source register
1847// in R/M. Included for the disassembler.
1848def OR8rr_REV : I<0x0A, MRMSrcReg, (outs GR8:$dst), (ins GR8:$src1, GR8:$src2),
1849 "or{b}\t{$src2, $dst|$dst, $src2}", []>;
1850def OR16rr_REV : I<0x0B, MRMSrcReg, (outs GR16:$dst),
1851 (ins GR16:$src1, GR16:$src2),
1852 "or{w}\t{$src2, $dst|$dst, $src2}", []>, OpSize;
1853def OR32rr_REV : I<0x0B, MRMSrcReg, (outs GR32:$dst),
1854 (ins GR32:$src1, GR32:$src2),
1855 "or{l}\t{$src2, $dst|$dst, $src2}", []>;
1856
1857def OR8rm : I<0x0A, MRMSrcMem , (outs GR8 :$dst),
1858 (ins GR8 :$src1, i8mem :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001859 "or{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001860 [(set GR8:$dst, (or GR8:$src1, (load addr:$src2))),
1861 (implicit EFLAGS)]>;
Sean Callanan2c48df22009-12-18 00:01:26 +00001862def OR16rm : I<0x0B, MRMSrcMem , (outs GR16:$dst),
1863 (ins GR16:$src1, i16mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001864 "or{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001865 [(set GR16:$dst, (or GR16:$src1, (load addr:$src2))),
1866 (implicit EFLAGS)]>, OpSize;
Sean Callanan2c48df22009-12-18 00:01:26 +00001867def OR32rm : I<0x0B, MRMSrcMem , (outs GR32:$dst),
1868 (ins GR32:$src1, i32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001869 "or{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001870 [(set GR32:$dst, (or GR32:$src1, (load addr:$src2))),
1871 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001872
Sean Callanan2c48df22009-12-18 00:01:26 +00001873def OR8ri : Ii8 <0x80, MRM1r, (outs GR8 :$dst),
1874 (ins GR8 :$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001875 "or{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001876 [(set GR8:$dst, (or GR8:$src1, imm:$src2)),
1877 (implicit EFLAGS)]>;
Sean Callanan2c48df22009-12-18 00:01:26 +00001878def OR16ri : Ii16<0x81, MRM1r, (outs GR16:$dst),
1879 (ins GR16:$src1, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001880 "or{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001881 [(set GR16:$dst, (or GR16:$src1, imm:$src2)),
1882 (implicit EFLAGS)]>, OpSize;
Sean Callanan2c48df22009-12-18 00:01:26 +00001883def OR32ri : Ii32<0x81, MRM1r, (outs GR32:$dst),
1884 (ins GR32:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001885 "or{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001886 [(set GR32:$dst, (or GR32:$src1, imm:$src2)),
1887 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001888
Sean Callanan2c48df22009-12-18 00:01:26 +00001889def OR16ri8 : Ii8<0x83, MRM1r, (outs GR16:$dst),
1890 (ins GR16:$src1, i16i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001891 "or{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001892 [(set GR16:$dst, (or GR16:$src1, i16immSExt8:$src2)),
1893 (implicit EFLAGS)]>, OpSize;
Sean Callanan2c48df22009-12-18 00:01:26 +00001894def OR32ri8 : Ii8<0x83, MRM1r, (outs GR32:$dst),
1895 (ins GR32:$src1, i32i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001896 "or{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001897 [(set GR32:$dst, (or GR32:$src1, i32immSExt8:$src2)),
1898 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001899let isTwoAddress = 0 in {
Evan Chengb783fa32007-07-19 01:14:50 +00001900 def OR8mr : I<0x08, MRMDestMem, (outs), (ins i8mem:$dst, GR8:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001901 "or{b}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001902 [(store (or (load addr:$dst), GR8:$src), addr:$dst),
1903 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001904 def OR16mr : I<0x09, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001905 "or{w}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001906 [(store (or (load addr:$dst), GR16:$src), addr:$dst),
1907 (implicit EFLAGS)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001908 def OR32mr : I<0x09, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001909 "or{l}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001910 [(store (or (load addr:$dst), GR32:$src), addr:$dst),
1911 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001912 def OR8mi : Ii8<0x80, MRM1m, (outs), (ins i8mem :$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001913 "or{b}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001914 [(store (or (loadi8 addr:$dst), imm:$src), addr:$dst),
1915 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001916 def OR16mi : Ii16<0x81, MRM1m, (outs), (ins i16mem:$dst, i16imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001917 "or{w}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001918 [(store (or (loadi16 addr:$dst), imm:$src), addr:$dst),
1919 (implicit EFLAGS)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001920 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001921 def OR32mi : Ii32<0x81, MRM1m, (outs), (ins i32mem:$dst, i32imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001922 "or{l}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001923 [(store (or (loadi32 addr:$dst), imm:$src), addr:$dst),
1924 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001925 def OR16mi8 : Ii8<0x83, MRM1m, (outs), (ins i16mem:$dst, i16i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001926 "or{w}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001927 [(store (or (load addr:$dst), i16immSExt8:$src), addr:$dst),
1928 (implicit EFLAGS)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001929 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001930 def OR32mi8 : Ii8<0x83, MRM1m, (outs), (ins i32mem:$dst, i32i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001931 "or{l}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001932 [(store (or (load addr:$dst), i32immSExt8:$src), addr:$dst),
1933 (implicit EFLAGS)]>;
Sean Callanan8562bef2009-09-11 19:01:56 +00001934
1935 def OR8i8 : Ii8 <0x0C, RawFrm, (outs), (ins i8imm:$src),
1936 "or{b}\t{$src, %al|%al, $src}", []>;
1937 def OR16i16 : Ii16 <0x0D, RawFrm, (outs), (ins i16imm:$src),
1938 "or{w}\t{$src, %ax|%ax, $src}", []>, OpSize;
1939 def OR32i32 : Ii32 <0x0D, RawFrm, (outs), (ins i32imm:$src),
1940 "or{l}\t{$src, %eax|%eax, $src}", []>;
Bill Wendlingba5d5b02008-05-29 01:02:09 +00001941} // isTwoAddress = 0
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001942
1943
Evan Cheng6f26e8b2008-06-18 08:13:07 +00001944let isCommutable = 1 in { // X = XOR Y, Z --> X = XOR Z, Y
Bill Wendlingba5d5b02008-05-29 01:02:09 +00001945 def XOR8rr : I<0x30, MRMDestReg,
1946 (outs GR8 :$dst), (ins GR8 :$src1, GR8 :$src2),
1947 "xor{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001948 [(set GR8:$dst, (xor GR8:$src1, GR8:$src2)),
1949 (implicit EFLAGS)]>;
Bill Wendlingba5d5b02008-05-29 01:02:09 +00001950 def XOR16rr : I<0x31, MRMDestReg,
1951 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
1952 "xor{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001953 [(set GR16:$dst, (xor GR16:$src1, GR16:$src2)),
1954 (implicit EFLAGS)]>, OpSize;
Bill Wendlingba5d5b02008-05-29 01:02:09 +00001955 def XOR32rr : I<0x31, MRMDestReg,
1956 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
1957 "xor{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001958 [(set GR32:$dst, (xor GR32:$src1, GR32:$src2)),
1959 (implicit EFLAGS)]>;
Evan Cheng6f26e8b2008-06-18 08:13:07 +00001960} // isCommutable = 1
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001961
Sean Callanan2c48df22009-12-18 00:01:26 +00001962// XOR instructions with the destination register in REG and the source register
1963// in R/M. Included for the disassembler.
1964def XOR8rr_REV : I<0x32, MRMSrcReg, (outs GR8:$dst), (ins GR8:$src1, GR8:$src2),
1965 "xor{b}\t{$src2, $dst|$dst, $src2}", []>;
1966def XOR16rr_REV : I<0x33, MRMSrcReg, (outs GR16:$dst),
1967 (ins GR16:$src1, GR16:$src2),
1968 "xor{w}\t{$src2, $dst|$dst, $src2}", []>, OpSize;
1969def XOR32rr_REV : I<0x33, MRMSrcReg, (outs GR32:$dst),
1970 (ins GR32:$src1, GR32:$src2),
1971 "xor{l}\t{$src2, $dst|$dst, $src2}", []>;
1972
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001973def XOR8rm : I<0x32, MRMSrcMem ,
Evan Chengb783fa32007-07-19 01:14:50 +00001974 (outs GR8 :$dst), (ins GR8:$src1, i8mem :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001975 "xor{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001976 [(set GR8:$dst, (xor GR8:$src1, (load addr:$src2))),
1977 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001978def XOR16rm : I<0x33, MRMSrcMem ,
Evan Chengb783fa32007-07-19 01:14:50 +00001979 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001980 "xor{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001981 [(set GR16:$dst, (xor GR16:$src1, (load addr:$src2))),
1982 (implicit EFLAGS)]>,
Bill Wendlingba5d5b02008-05-29 01:02:09 +00001983 OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001984def XOR32rm : I<0x33, MRMSrcMem ,
Evan Chengb783fa32007-07-19 01:14:50 +00001985 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001986 "xor{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001987 [(set GR32:$dst, (xor GR32:$src1, (load addr:$src2))),
1988 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001989
Bill Wendlingbac38eb2008-05-29 03:46:36 +00001990def XOR8ri : Ii8<0x80, MRM6r,
1991 (outs GR8:$dst), (ins GR8:$src1, i8imm:$src2),
1992 "xor{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001993 [(set GR8:$dst, (xor GR8:$src1, imm:$src2)),
1994 (implicit EFLAGS)]>;
Bill Wendlingbac38eb2008-05-29 03:46:36 +00001995def XOR16ri : Ii16<0x81, MRM6r,
1996 (outs GR16:$dst), (ins GR16:$src1, i16imm:$src2),
1997 "xor{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001998 [(set GR16:$dst, (xor GR16:$src1, imm:$src2)),
1999 (implicit EFLAGS)]>, OpSize;
Bill Wendlingbac38eb2008-05-29 03:46:36 +00002000def XOR32ri : Ii32<0x81, MRM6r,
2001 (outs GR32:$dst), (ins GR32:$src1, i32imm:$src2),
2002 "xor{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00002003 [(set GR32:$dst, (xor GR32:$src1, imm:$src2)),
2004 (implicit EFLAGS)]>;
Bill Wendlingbac38eb2008-05-29 03:46:36 +00002005def XOR16ri8 : Ii8<0x83, MRM6r,
2006 (outs GR16:$dst), (ins GR16:$src1, i16i8imm:$src2),
2007 "xor{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00002008 [(set GR16:$dst, (xor GR16:$src1, i16immSExt8:$src2)),
2009 (implicit EFLAGS)]>,
Bill Wendlingbac38eb2008-05-29 03:46:36 +00002010 OpSize;
2011def XOR32ri8 : Ii8<0x83, MRM6r,
2012 (outs GR32:$dst), (ins GR32:$src1, i32i8imm:$src2),
2013 "xor{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00002014 [(set GR32:$dst, (xor GR32:$src1, i32immSExt8:$src2)),
2015 (implicit EFLAGS)]>;
Bill Wendlingba5d5b02008-05-29 01:02:09 +00002016
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002017let isTwoAddress = 0 in {
2018 def XOR8mr : I<0x30, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00002019 (outs), (ins i8mem :$dst, GR8 :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002020 "xor{b}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00002021 [(store (xor (load addr:$dst), GR8:$src), addr:$dst),
2022 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002023 def XOR16mr : I<0x31, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00002024 (outs), (ins i16mem:$dst, GR16:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002025 "xor{w}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00002026 [(store (xor (load addr:$dst), GR16:$src), addr:$dst),
2027 (implicit EFLAGS)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002028 OpSize;
2029 def XOR32mr : I<0x31, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00002030 (outs), (ins i32mem:$dst, GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002031 "xor{l}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00002032 [(store (xor (load addr:$dst), GR32:$src), addr:$dst),
2033 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002034 def XOR8mi : Ii8<0x80, MRM6m,
Evan Chengb783fa32007-07-19 01:14:50 +00002035 (outs), (ins i8mem :$dst, i8imm :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002036 "xor{b}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00002037 [(store (xor (loadi8 addr:$dst), imm:$src), addr:$dst),
2038 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002039 def XOR16mi : Ii16<0x81, MRM6m,
Evan Chengb783fa32007-07-19 01:14:50 +00002040 (outs), (ins i16mem:$dst, i16imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002041 "xor{w}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00002042 [(store (xor (loadi16 addr:$dst), imm:$src), addr:$dst),
2043 (implicit EFLAGS)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002044 OpSize;
2045 def XOR32mi : Ii32<0x81, MRM6m,
Evan Chengb783fa32007-07-19 01:14:50 +00002046 (outs), (ins i32mem:$dst, i32imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002047 "xor{l}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00002048 [(store (xor (loadi32 addr:$dst), imm:$src), addr:$dst),
2049 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002050 def XOR16mi8 : Ii8<0x83, MRM6m,
Evan Chengb783fa32007-07-19 01:14:50 +00002051 (outs), (ins i16mem:$dst, i16i8imm :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002052 "xor{w}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00002053 [(store (xor (load addr:$dst), i16immSExt8:$src), addr:$dst),
2054 (implicit EFLAGS)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002055 OpSize;
2056 def XOR32mi8 : Ii8<0x83, MRM6m,
Evan Chengb783fa32007-07-19 01:14:50 +00002057 (outs), (ins i32mem:$dst, i32i8imm :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002058 "xor{l}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00002059 [(store (xor (load addr:$dst), i32immSExt8:$src), addr:$dst),
2060 (implicit EFLAGS)]>;
Sean Callanan794457a2009-09-10 19:52:26 +00002061
2062 def XOR8i8 : Ii8 <0x34, RawFrm, (outs), (ins i8imm:$src),
2063 "xor{b}\t{$src, %al|%al, $src}", []>;
2064 def XOR16i16 : Ii16 <0x35, RawFrm, (outs), (ins i16imm:$src),
2065 "xor{w}\t{$src, %ax|%ax, $src}", []>, OpSize;
2066 def XOR32i32 : Ii32 <0x35, RawFrm, (outs), (ins i32imm:$src),
2067 "xor{l}\t{$src, %eax|%eax, $src}", []>;
Bill Wendlingba5d5b02008-05-29 01:02:09 +00002068} // isTwoAddress = 0
Evan Cheng55687072007-09-14 21:48:26 +00002069} // Defs = [EFLAGS]
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002070
2071// Shift instructions
Evan Cheng55687072007-09-14 21:48:26 +00002072let Defs = [EFLAGS] in {
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002073let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00002074def SHL8rCL : I<0xD2, MRM4r, (outs GR8 :$dst), (ins GR8 :$src),
Eli Friedman378ea832009-06-19 04:48:38 +00002075 "shl{b}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002076 [(set GR8:$dst, (shl GR8:$src, CL))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002077def SHL16rCL : I<0xD3, MRM4r, (outs GR16:$dst), (ins GR16:$src),
Eli Friedman378ea832009-06-19 04:48:38 +00002078 "shl{w}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002079 [(set GR16:$dst, (shl GR16:$src, CL))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002080def SHL32rCL : I<0xD3, MRM4r, (outs GR32:$dst), (ins GR32:$src),
Eli Friedman378ea832009-06-19 04:48:38 +00002081 "shl{l}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002082 [(set GR32:$dst, (shl GR32:$src, CL))]>;
Bill Wendlingba5d5b02008-05-29 01:02:09 +00002083} // Uses = [CL]
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002084
Evan Chengb783fa32007-07-19 01:14:50 +00002085def SHL8ri : Ii8<0xC0, MRM4r, (outs GR8 :$dst), (ins GR8 :$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002086 "shl{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002087 [(set GR8:$dst, (shl GR8:$src1, (i8 imm:$src2)))]>;
2088let isConvertibleToThreeAddress = 1 in { // Can transform into LEA.
Evan Chengb783fa32007-07-19 01:14:50 +00002089def SHL16ri : Ii8<0xC1, MRM4r, (outs GR16:$dst), (ins GR16:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002090 "shl{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002091 [(set GR16:$dst, (shl GR16:$src1, (i8 imm:$src2)))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002092def SHL32ri : Ii8<0xC1, MRM4r, (outs GR32:$dst), (ins GR32:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002093 "shl{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002094 [(set GR32:$dst, (shl GR32:$src1, (i8 imm:$src2)))]>;
Sean Callananca503e02009-09-16 02:28:43 +00002095
2096// NOTE: We don't include patterns for shifts of a register by one, because
2097// 'add reg,reg' is cheaper.
2098
2099def SHL8r1 : I<0xD0, MRM4r, (outs GR8:$dst), (ins GR8:$src1),
2100 "shl{b}\t$dst", []>;
2101def SHL16r1 : I<0xD1, MRM4r, (outs GR16:$dst), (ins GR16:$src1),
2102 "shl{w}\t$dst", []>, OpSize;
2103def SHL32r1 : I<0xD1, MRM4r, (outs GR32:$dst), (ins GR32:$src1),
2104 "shl{l}\t$dst", []>;
2105
Bill Wendlingba5d5b02008-05-29 01:02:09 +00002106} // isConvertibleToThreeAddress = 1
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002107
2108let isTwoAddress = 0 in {
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002109 let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00002110 def SHL8mCL : I<0xD2, MRM4m, (outs), (ins i8mem :$dst),
Eli Friedman378ea832009-06-19 04:48:38 +00002111 "shl{b}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002112 [(store (shl (loadi8 addr:$dst), CL), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002113 def SHL16mCL : I<0xD3, MRM4m, (outs), (ins i16mem:$dst),
Eli Friedman378ea832009-06-19 04:48:38 +00002114 "shl{w}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002115 [(store (shl (loadi16 addr:$dst), CL), addr:$dst)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002116 def SHL32mCL : I<0xD3, MRM4m, (outs), (ins i32mem:$dst),
Eli Friedman378ea832009-06-19 04:48:38 +00002117 "shl{l}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002118 [(store (shl (loadi32 addr:$dst), CL), addr:$dst)]>;
2119 }
Evan Chengb783fa32007-07-19 01:14:50 +00002120 def SHL8mi : Ii8<0xC0, MRM4m, (outs), (ins i8mem :$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002121 "shl{b}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002122 [(store (shl (loadi8 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002123 def SHL16mi : Ii8<0xC1, MRM4m, (outs), (ins i16mem:$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002124 "shl{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002125 [(store (shl (loadi16 addr:$dst), (i8 imm:$src)), addr:$dst)]>,
2126 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002127 def SHL32mi : Ii8<0xC1, MRM4m, (outs), (ins i32mem:$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002128 "shl{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002129 [(store (shl (loadi32 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
2130
2131 // Shift by 1
Evan Chengb783fa32007-07-19 01:14:50 +00002132 def SHL8m1 : I<0xD0, MRM4m, (outs), (ins i8mem :$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002133 "shl{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002134 [(store (shl (loadi8 addr:$dst), (i8 1)), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002135 def SHL16m1 : I<0xD1, MRM4m, (outs), (ins i16mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002136 "shl{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002137 [(store (shl (loadi16 addr:$dst), (i8 1)), addr:$dst)]>,
2138 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002139 def SHL32m1 : I<0xD1, MRM4m, (outs), (ins i32mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002140 "shl{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002141 [(store (shl (loadi32 addr:$dst), (i8 1)), addr:$dst)]>;
2142}
2143
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002144let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00002145def SHR8rCL : I<0xD2, MRM5r, (outs GR8 :$dst), (ins GR8 :$src),
Eli Friedman378ea832009-06-19 04:48:38 +00002146 "shr{b}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002147 [(set GR8:$dst, (srl GR8:$src, CL))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002148def SHR16rCL : I<0xD3, MRM5r, (outs GR16:$dst), (ins GR16:$src),
Eli Friedman378ea832009-06-19 04:48:38 +00002149 "shr{w}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002150 [(set GR16:$dst, (srl GR16:$src, CL))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002151def SHR32rCL : I<0xD3, MRM5r, (outs GR32:$dst), (ins GR32:$src),
Eli Friedman378ea832009-06-19 04:48:38 +00002152 "shr{l}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002153 [(set GR32:$dst, (srl GR32:$src, CL))]>;
2154}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002155
Evan Chengb783fa32007-07-19 01:14:50 +00002156def SHR8ri : Ii8<0xC0, MRM5r, (outs GR8:$dst), (ins GR8:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002157 "shr{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002158 [(set GR8:$dst, (srl GR8:$src1, (i8 imm:$src2)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002159def SHR16ri : Ii8<0xC1, MRM5r, (outs GR16:$dst), (ins GR16:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002160 "shr{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002161 [(set GR16:$dst, (srl GR16:$src1, (i8 imm:$src2)))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002162def SHR32ri : Ii8<0xC1, MRM5r, (outs GR32:$dst), (ins GR32:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002163 "shr{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002164 [(set GR32:$dst, (srl GR32:$src1, (i8 imm:$src2)))]>;
2165
2166// Shift by 1
Evan Chengb783fa32007-07-19 01:14:50 +00002167def SHR8r1 : I<0xD0, MRM5r, (outs GR8:$dst), (ins GR8:$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00002168 "shr{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002169 [(set GR8:$dst, (srl GR8:$src1, (i8 1)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002170def SHR16r1 : I<0xD1, MRM5r, (outs GR16:$dst), (ins GR16:$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00002171 "shr{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002172 [(set GR16:$dst, (srl GR16:$src1, (i8 1)))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002173def SHR32r1 : I<0xD1, MRM5r, (outs GR32:$dst), (ins GR32:$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00002174 "shr{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002175 [(set GR32:$dst, (srl GR32:$src1, (i8 1)))]>;
2176
2177let isTwoAddress = 0 in {
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002178 let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00002179 def SHR8mCL : I<0xD2, MRM5m, (outs), (ins i8mem :$dst),
Eli Friedman378ea832009-06-19 04:48:38 +00002180 "shr{b}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002181 [(store (srl (loadi8 addr:$dst), CL), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002182 def SHR16mCL : I<0xD3, MRM5m, (outs), (ins i16mem:$dst),
Eli Friedman378ea832009-06-19 04:48:38 +00002183 "shr{w}\t{%cl, $dst|$dst, CL}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002184 [(store (srl (loadi16 addr:$dst), CL), addr:$dst)]>,
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002185 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002186 def SHR32mCL : I<0xD3, MRM5m, (outs), (ins i32mem:$dst),
Eli Friedman378ea832009-06-19 04:48:38 +00002187 "shr{l}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002188 [(store (srl (loadi32 addr:$dst), CL), addr:$dst)]>;
2189 }
Evan Chengb783fa32007-07-19 01:14:50 +00002190 def SHR8mi : Ii8<0xC0, MRM5m, (outs), (ins i8mem :$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002191 "shr{b}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002192 [(store (srl (loadi8 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002193 def SHR16mi : Ii8<0xC1, MRM5m, (outs), (ins i16mem:$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002194 "shr{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002195 [(store (srl (loadi16 addr:$dst), (i8 imm:$src)), addr:$dst)]>,
2196 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002197 def SHR32mi : Ii8<0xC1, MRM5m, (outs), (ins i32mem:$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002198 "shr{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002199 [(store (srl (loadi32 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
2200
2201 // Shift by 1
Evan Chengb783fa32007-07-19 01:14:50 +00002202 def SHR8m1 : I<0xD0, MRM5m, (outs), (ins i8mem :$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002203 "shr{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002204 [(store (srl (loadi8 addr:$dst), (i8 1)), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002205 def SHR16m1 : I<0xD1, MRM5m, (outs), (ins i16mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002206 "shr{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002207 [(store (srl (loadi16 addr:$dst), (i8 1)), addr:$dst)]>,OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002208 def SHR32m1 : I<0xD1, MRM5m, (outs), (ins i32mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002209 "shr{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002210 [(store (srl (loadi32 addr:$dst), (i8 1)), addr:$dst)]>;
2211}
2212
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002213let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00002214def SAR8rCL : I<0xD2, MRM7r, (outs GR8 :$dst), (ins GR8 :$src),
Eli Friedman378ea832009-06-19 04:48:38 +00002215 "sar{b}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002216 [(set GR8:$dst, (sra GR8:$src, CL))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002217def SAR16rCL : I<0xD3, MRM7r, (outs GR16:$dst), (ins GR16:$src),
Eli Friedman378ea832009-06-19 04:48:38 +00002218 "sar{w}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002219 [(set GR16:$dst, (sra GR16:$src, CL))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002220def SAR32rCL : I<0xD3, MRM7r, (outs GR32:$dst), (ins GR32:$src),
Eli Friedman378ea832009-06-19 04:48:38 +00002221 "sar{l}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002222 [(set GR32:$dst, (sra GR32:$src, CL))]>;
2223}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002224
Evan Chengb783fa32007-07-19 01:14:50 +00002225def SAR8ri : Ii8<0xC0, MRM7r, (outs GR8 :$dst), (ins GR8 :$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002226 "sar{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002227 [(set GR8:$dst, (sra GR8:$src1, (i8 imm:$src2)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002228def SAR16ri : Ii8<0xC1, MRM7r, (outs GR16:$dst), (ins GR16:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002229 "sar{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002230 [(set GR16:$dst, (sra GR16:$src1, (i8 imm:$src2)))]>,
2231 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002232def SAR32ri : Ii8<0xC1, MRM7r, (outs GR32:$dst), (ins GR32:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002233 "sar{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002234 [(set GR32:$dst, (sra GR32:$src1, (i8 imm:$src2)))]>;
2235
2236// Shift by 1
Evan Chengb783fa32007-07-19 01:14:50 +00002237def SAR8r1 : I<0xD0, MRM7r, (outs GR8 :$dst), (ins GR8 :$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00002238 "sar{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002239 [(set GR8:$dst, (sra GR8:$src1, (i8 1)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002240def SAR16r1 : I<0xD1, MRM7r, (outs GR16:$dst), (ins GR16:$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00002241 "sar{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002242 [(set GR16:$dst, (sra GR16:$src1, (i8 1)))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002243def SAR32r1 : I<0xD1, MRM7r, (outs GR32:$dst), (ins GR32:$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00002244 "sar{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002245 [(set GR32:$dst, (sra GR32:$src1, (i8 1)))]>;
2246
2247let isTwoAddress = 0 in {
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002248 let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00002249 def SAR8mCL : I<0xD2, MRM7m, (outs), (ins i8mem :$dst),
Eli Friedman378ea832009-06-19 04:48:38 +00002250 "sar{b}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002251 [(store (sra (loadi8 addr:$dst), CL), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002252 def SAR16mCL : I<0xD3, MRM7m, (outs), (ins i16mem:$dst),
Eli Friedman378ea832009-06-19 04:48:38 +00002253 "sar{w}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002254 [(store (sra (loadi16 addr:$dst), CL), addr:$dst)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002255 def SAR32mCL : I<0xD3, MRM7m, (outs), (ins i32mem:$dst),
Eli Friedman378ea832009-06-19 04:48:38 +00002256 "sar{l}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002257 [(store (sra (loadi32 addr:$dst), CL), addr:$dst)]>;
2258 }
Evan Chengb783fa32007-07-19 01:14:50 +00002259 def SAR8mi : Ii8<0xC0, MRM7m, (outs), (ins i8mem :$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002260 "sar{b}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002261 [(store (sra (loadi8 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002262 def SAR16mi : Ii8<0xC1, MRM7m, (outs), (ins i16mem:$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002263 "sar{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002264 [(store (sra (loadi16 addr:$dst), (i8 imm:$src)), addr:$dst)]>,
2265 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002266 def SAR32mi : Ii8<0xC1, MRM7m, (outs), (ins i32mem:$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002267 "sar{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002268 [(store (sra (loadi32 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
2269
2270 // Shift by 1
Evan Chengb783fa32007-07-19 01:14:50 +00002271 def SAR8m1 : I<0xD0, MRM7m, (outs), (ins i8mem :$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002272 "sar{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002273 [(store (sra (loadi8 addr:$dst), (i8 1)), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002274 def SAR16m1 : I<0xD1, MRM7m, (outs), (ins i16mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002275 "sar{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002276 [(store (sra (loadi16 addr:$dst), (i8 1)), addr:$dst)]>,
2277 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002278 def SAR32m1 : I<0xD1, MRM7m, (outs), (ins i32mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002279 "sar{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002280 [(store (sra (loadi32 addr:$dst), (i8 1)), addr:$dst)]>;
2281}
2282
2283// Rotate instructions
Sean Callanan3c8eecd2009-09-18 19:35:23 +00002284
2285def RCL8r1 : I<0xD0, MRM2r, (outs GR8:$dst), (ins GR8:$src),
2286 "rcl{b}\t{1, $dst|$dst, 1}", []>;
2287def RCL8m1 : I<0xD0, MRM2m, (outs i8mem:$dst), (ins i8mem:$src),
2288 "rcl{b}\t{1, $dst|$dst, 1}", []>;
2289let Uses = [CL] in {
2290def RCL8rCL : I<0xD2, MRM2r, (outs GR8:$dst), (ins GR8:$src),
2291 "rcl{b}\t{%cl, $dst|$dst, CL}", []>;
2292def RCL8mCL : I<0xD2, MRM2m, (outs i8mem:$dst), (ins i8mem:$src),
2293 "rcl{b}\t{%cl, $dst|$dst, CL}", []>;
2294}
2295def RCL8ri : Ii8<0xC0, MRM2r, (outs GR8:$dst), (ins GR8:$src, i8imm:$cnt),
2296 "rcl{b}\t{$cnt, $dst|$dst, $cnt}", []>;
2297def RCL8mi : Ii8<0xC0, MRM2m, (outs i8mem:$dst), (ins i8mem:$src, i8imm:$cnt),
2298 "rcl{b}\t{$cnt, $dst|$dst, $cnt}", []>;
2299
2300def RCL16r1 : I<0xD1, MRM2r, (outs GR16:$dst), (ins GR16:$src),
2301 "rcl{w}\t{1, $dst|$dst, 1}", []>, OpSize;
2302def RCL16m1 : I<0xD1, MRM2m, (outs i16mem:$dst), (ins i16mem:$src),
2303 "rcl{w}\t{1, $dst|$dst, 1}", []>, OpSize;
2304let Uses = [CL] in {
2305def RCL16rCL : I<0xD3, MRM2r, (outs GR16:$dst), (ins GR16:$src),
2306 "rcl{w}\t{%cl, $dst|$dst, CL}", []>, OpSize;
2307def RCL16mCL : I<0xD3, MRM2m, (outs i16mem:$dst), (ins i16mem:$src),
2308 "rcl{w}\t{%cl, $dst|$dst, CL}", []>, OpSize;
2309}
2310def RCL16ri : Ii8<0xC1, MRM2r, (outs GR16:$dst), (ins GR16:$src, i8imm:$cnt),
2311 "rcl{w}\t{$cnt, $dst|$dst, $cnt}", []>, OpSize;
Sean Callanan2c48df22009-12-18 00:01:26 +00002312def RCL16mi : Ii8<0xC1, MRM2m, (outs i16mem:$dst),
2313 (ins i16mem:$src, i8imm:$cnt),
Sean Callanan3c8eecd2009-09-18 19:35:23 +00002314 "rcl{w}\t{$cnt, $dst|$dst, $cnt}", []>, OpSize;
2315
2316def RCL32r1 : I<0xD1, MRM2r, (outs GR32:$dst), (ins GR32:$src),
2317 "rcl{l}\t{1, $dst|$dst, 1}", []>;
2318def RCL32m1 : I<0xD1, MRM2m, (outs i32mem:$dst), (ins i32mem:$src),
2319 "rcl{l}\t{1, $dst|$dst, 1}", []>;
2320let Uses = [CL] in {
2321def RCL32rCL : I<0xD3, MRM2r, (outs GR32:$dst), (ins GR32:$src),
2322 "rcl{l}\t{%cl, $dst|$dst, CL}", []>;
2323def RCL32mCL : I<0xD3, MRM2m, (outs i32mem:$dst), (ins i32mem:$src),
2324 "rcl{l}\t{%cl, $dst|$dst, CL}", []>;
2325}
2326def RCL32ri : Ii8<0xC1, MRM2r, (outs GR32:$dst), (ins GR32:$src, i8imm:$cnt),
2327 "rcl{l}\t{$cnt, $dst|$dst, $cnt}", []>;
Sean Callanan2c48df22009-12-18 00:01:26 +00002328def RCL32mi : Ii8<0xC1, MRM2m, (outs i32mem:$dst),
2329 (ins i32mem:$src, i8imm:$cnt),
Sean Callanan3c8eecd2009-09-18 19:35:23 +00002330 "rcl{l}\t{$cnt, $dst|$dst, $cnt}", []>;
2331
2332def RCR8r1 : I<0xD0, MRM3r, (outs GR8:$dst), (ins GR8:$src),
2333 "rcr{b}\t{1, $dst|$dst, 1}", []>;
2334def RCR8m1 : I<0xD0, MRM3m, (outs i8mem:$dst), (ins i8mem:$src),
2335 "rcr{b}\t{1, $dst|$dst, 1}", []>;
2336let Uses = [CL] in {
2337def RCR8rCL : I<0xD2, MRM3r, (outs GR8:$dst), (ins GR8:$src),
2338 "rcr{b}\t{%cl, $dst|$dst, CL}", []>;
2339def RCR8mCL : I<0xD2, MRM3m, (outs i8mem:$dst), (ins i8mem:$src),
2340 "rcr{b}\t{%cl, $dst|$dst, CL}", []>;
2341}
2342def RCR8ri : Ii8<0xC0, MRM3r, (outs GR8:$dst), (ins GR8:$src, i8imm:$cnt),
2343 "rcr{b}\t{$cnt, $dst|$dst, $cnt}", []>;
2344def RCR8mi : Ii8<0xC0, MRM3m, (outs i8mem:$dst), (ins i8mem:$src, i8imm:$cnt),
2345 "rcr{b}\t{$cnt, $dst|$dst, $cnt}", []>;
2346
2347def RCR16r1 : I<0xD1, MRM3r, (outs GR16:$dst), (ins GR16:$src),
2348 "rcr{w}\t{1, $dst|$dst, 1}", []>, OpSize;
2349def RCR16m1 : I<0xD1, MRM3m, (outs i16mem:$dst), (ins i16mem:$src),
2350 "rcr{w}\t{1, $dst|$dst, 1}", []>, OpSize;
2351let Uses = [CL] in {
2352def RCR16rCL : I<0xD3, MRM3r, (outs GR16:$dst), (ins GR16:$src),
2353 "rcr{w}\t{%cl, $dst|$dst, CL}", []>, OpSize;
2354def RCR16mCL : I<0xD3, MRM3m, (outs i16mem:$dst), (ins i16mem:$src),
2355 "rcr{w}\t{%cl, $dst|$dst, CL}", []>, OpSize;
2356}
2357def RCR16ri : Ii8<0xC1, MRM3r, (outs GR16:$dst), (ins GR16:$src, i8imm:$cnt),
2358 "rcr{w}\t{$cnt, $dst|$dst, $cnt}", []>, OpSize;
Sean Callanan2c48df22009-12-18 00:01:26 +00002359def RCR16mi : Ii8<0xC1, MRM3m, (outs i16mem:$dst),
2360 (ins i16mem:$src, i8imm:$cnt),
Sean Callanan3c8eecd2009-09-18 19:35:23 +00002361 "rcr{w}\t{$cnt, $dst|$dst, $cnt}", []>, OpSize;
2362
2363def RCR32r1 : I<0xD1, MRM3r, (outs GR32:$dst), (ins GR32:$src),
2364 "rcr{l}\t{1, $dst|$dst, 1}", []>;
2365def RCR32m1 : I<0xD1, MRM3m, (outs i32mem:$dst), (ins i32mem:$src),
2366 "rcr{l}\t{1, $dst|$dst, 1}", []>;
2367let Uses = [CL] in {
2368def RCR32rCL : I<0xD3, MRM3r, (outs GR32:$dst), (ins GR32:$src),
2369 "rcr{l}\t{%cl, $dst|$dst, CL}", []>;
2370def RCR32mCL : I<0xD3, MRM3m, (outs i32mem:$dst), (ins i32mem:$src),
2371 "rcr{l}\t{%cl, $dst|$dst, CL}", []>;
2372}
2373def RCR32ri : Ii8<0xC1, MRM3r, (outs GR32:$dst), (ins GR32:$src, i8imm:$cnt),
2374 "rcr{l}\t{$cnt, $dst|$dst, $cnt}", []>;
Sean Callanan2c48df22009-12-18 00:01:26 +00002375def RCR32mi : Ii8<0xC1, MRM3m, (outs i32mem:$dst),
2376 (ins i32mem:$src, i8imm:$cnt),
Sean Callanan3c8eecd2009-09-18 19:35:23 +00002377 "rcr{l}\t{$cnt, $dst|$dst, $cnt}", []>;
2378
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002379// FIXME: provide shorter instructions when imm8 == 1
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002380let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00002381def ROL8rCL : I<0xD2, MRM0r, (outs GR8 :$dst), (ins GR8 :$src),
Eli Friedman378ea832009-06-19 04:48:38 +00002382 "rol{b}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002383 [(set GR8:$dst, (rotl GR8:$src, CL))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002384def ROL16rCL : I<0xD3, MRM0r, (outs GR16:$dst), (ins GR16:$src),
Eli Friedman378ea832009-06-19 04:48:38 +00002385 "rol{w}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002386 [(set GR16:$dst, (rotl GR16:$src, CL))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002387def ROL32rCL : I<0xD3, MRM0r, (outs GR32:$dst), (ins GR32:$src),
Eli Friedman378ea832009-06-19 04:48:38 +00002388 "rol{l}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002389 [(set GR32:$dst, (rotl GR32:$src, CL))]>;
2390}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002391
Evan Chengb783fa32007-07-19 01:14:50 +00002392def ROL8ri : Ii8<0xC0, MRM0r, (outs GR8 :$dst), (ins GR8 :$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002393 "rol{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002394 [(set GR8:$dst, (rotl GR8:$src1, (i8 imm:$src2)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002395def ROL16ri : Ii8<0xC1, MRM0r, (outs GR16:$dst), (ins GR16:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002396 "rol{w}\t{$src2, $dst|$dst, $src2}",
Sean Callanan2c48df22009-12-18 00:01:26 +00002397 [(set GR16:$dst, (rotl GR16:$src1, (i8 imm:$src2)))]>,
2398 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002399def ROL32ri : Ii8<0xC1, MRM0r, (outs GR32:$dst), (ins GR32:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002400 "rol{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002401 [(set GR32:$dst, (rotl GR32:$src1, (i8 imm:$src2)))]>;
2402
2403// Rotate by 1
Evan Chengb783fa32007-07-19 01:14:50 +00002404def ROL8r1 : I<0xD0, MRM0r, (outs GR8 :$dst), (ins GR8 :$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00002405 "rol{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002406 [(set GR8:$dst, (rotl GR8:$src1, (i8 1)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002407def ROL16r1 : I<0xD1, MRM0r, (outs GR16:$dst), (ins GR16:$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00002408 "rol{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002409 [(set GR16:$dst, (rotl GR16:$src1, (i8 1)))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002410def ROL32r1 : I<0xD1, MRM0r, (outs GR32:$dst), (ins GR32:$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00002411 "rol{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002412 [(set GR32:$dst, (rotl GR32:$src1, (i8 1)))]>;
2413
2414let isTwoAddress = 0 in {
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002415 let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00002416 def ROL8mCL : I<0xD2, MRM0m, (outs), (ins i8mem :$dst),
Eli Friedman378ea832009-06-19 04:48:38 +00002417 "rol{b}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002418 [(store (rotl (loadi8 addr:$dst), CL), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002419 def ROL16mCL : I<0xD3, MRM0m, (outs), (ins i16mem:$dst),
Eli Friedman378ea832009-06-19 04:48:38 +00002420 "rol{w}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002421 [(store (rotl (loadi16 addr:$dst), CL), addr:$dst)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002422 def ROL32mCL : I<0xD3, MRM0m, (outs), (ins i32mem:$dst),
Eli Friedman378ea832009-06-19 04:48:38 +00002423 "rol{l}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002424 [(store (rotl (loadi32 addr:$dst), CL), addr:$dst)]>;
2425 }
Evan Chengb783fa32007-07-19 01:14:50 +00002426 def ROL8mi : Ii8<0xC0, MRM0m, (outs), (ins i8mem :$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002427 "rol{b}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002428 [(store (rotl (loadi8 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002429 def ROL16mi : Ii8<0xC1, MRM0m, (outs), (ins i16mem:$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002430 "rol{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002431 [(store (rotl (loadi16 addr:$dst), (i8 imm:$src)), addr:$dst)]>,
2432 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002433 def ROL32mi : Ii8<0xC1, MRM0m, (outs), (ins i32mem:$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002434 "rol{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002435 [(store (rotl (loadi32 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
2436
2437 // Rotate by 1
Evan Chengb783fa32007-07-19 01:14:50 +00002438 def ROL8m1 : I<0xD0, MRM0m, (outs), (ins i8mem :$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002439 "rol{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002440 [(store (rotl (loadi8 addr:$dst), (i8 1)), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002441 def ROL16m1 : I<0xD1, MRM0m, (outs), (ins i16mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002442 "rol{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002443 [(store (rotl (loadi16 addr:$dst), (i8 1)), addr:$dst)]>,
2444 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002445 def ROL32m1 : I<0xD1, MRM0m, (outs), (ins i32mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002446 "rol{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002447 [(store (rotl (loadi32 addr:$dst), (i8 1)), addr:$dst)]>;
2448}
2449
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002450let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00002451def ROR8rCL : I<0xD2, MRM1r, (outs GR8 :$dst), (ins GR8 :$src),
Eli Friedman378ea832009-06-19 04:48:38 +00002452 "ror{b}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002453 [(set GR8:$dst, (rotr GR8:$src, CL))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002454def ROR16rCL : I<0xD3, MRM1r, (outs GR16:$dst), (ins GR16:$src),
Eli Friedman378ea832009-06-19 04:48:38 +00002455 "ror{w}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002456 [(set GR16:$dst, (rotr GR16:$src, CL))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002457def ROR32rCL : I<0xD3, MRM1r, (outs GR32:$dst), (ins GR32:$src),
Eli Friedman378ea832009-06-19 04:48:38 +00002458 "ror{l}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002459 [(set GR32:$dst, (rotr GR32:$src, CL))]>;
2460}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002461
Evan Chengb783fa32007-07-19 01:14:50 +00002462def ROR8ri : Ii8<0xC0, MRM1r, (outs GR8 :$dst), (ins GR8 :$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002463 "ror{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002464 [(set GR8:$dst, (rotr GR8:$src1, (i8 imm:$src2)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002465def ROR16ri : Ii8<0xC1, MRM1r, (outs GR16:$dst), (ins GR16:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002466 "ror{w}\t{$src2, $dst|$dst, $src2}",
Sean Callanan2c48df22009-12-18 00:01:26 +00002467 [(set GR16:$dst, (rotr GR16:$src1, (i8 imm:$src2)))]>,
2468 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002469def ROR32ri : Ii8<0xC1, MRM1r, (outs GR32:$dst), (ins GR32:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002470 "ror{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002471 [(set GR32:$dst, (rotr GR32:$src1, (i8 imm:$src2)))]>;
2472
2473// Rotate by 1
Evan Chengb783fa32007-07-19 01:14:50 +00002474def ROR8r1 : I<0xD0, MRM1r, (outs GR8 :$dst), (ins GR8 :$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00002475 "ror{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002476 [(set GR8:$dst, (rotr GR8:$src1, (i8 1)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002477def ROR16r1 : I<0xD1, MRM1r, (outs GR16:$dst), (ins GR16:$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00002478 "ror{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002479 [(set GR16:$dst, (rotr GR16:$src1, (i8 1)))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002480def ROR32r1 : I<0xD1, MRM1r, (outs GR32:$dst), (ins GR32:$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00002481 "ror{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002482 [(set GR32:$dst, (rotr GR32:$src1, (i8 1)))]>;
2483
2484let isTwoAddress = 0 in {
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002485 let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00002486 def ROR8mCL : I<0xD2, MRM1m, (outs), (ins i8mem :$dst),
Eli Friedman378ea832009-06-19 04:48:38 +00002487 "ror{b}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002488 [(store (rotr (loadi8 addr:$dst), CL), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002489 def ROR16mCL : I<0xD3, MRM1m, (outs), (ins i16mem:$dst),
Eli Friedman378ea832009-06-19 04:48:38 +00002490 "ror{w}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002491 [(store (rotr (loadi16 addr:$dst), CL), addr:$dst)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002492 def ROR32mCL : I<0xD3, MRM1m, (outs), (ins i32mem:$dst),
Eli Friedman378ea832009-06-19 04:48:38 +00002493 "ror{l}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002494 [(store (rotr (loadi32 addr:$dst), CL), addr:$dst)]>;
2495 }
Evan Chengb783fa32007-07-19 01:14:50 +00002496 def ROR8mi : Ii8<0xC0, MRM1m, (outs), (ins i8mem :$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002497 "ror{b}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002498 [(store (rotr (loadi8 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002499 def ROR16mi : Ii8<0xC1, MRM1m, (outs), (ins i16mem:$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002500 "ror{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002501 [(store (rotr (loadi16 addr:$dst), (i8 imm:$src)), addr:$dst)]>,
2502 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002503 def ROR32mi : Ii8<0xC1, MRM1m, (outs), (ins i32mem:$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002504 "ror{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002505 [(store (rotr (loadi32 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
2506
2507 // Rotate by 1
Evan Chengb783fa32007-07-19 01:14:50 +00002508 def ROR8m1 : I<0xD0, MRM1m, (outs), (ins i8mem :$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002509 "ror{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002510 [(store (rotr (loadi8 addr:$dst), (i8 1)), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002511 def ROR16m1 : I<0xD1, MRM1m, (outs), (ins i16mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002512 "ror{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002513 [(store (rotr (loadi16 addr:$dst), (i8 1)), addr:$dst)]>,
2514 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002515 def ROR32m1 : I<0xD1, MRM1m, (outs), (ins i32mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002516 "ror{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002517 [(store (rotr (loadi32 addr:$dst), (i8 1)), addr:$dst)]>;
2518}
2519
2520
2521
2522// Double shift instructions (generalizations of rotate)
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002523let Uses = [CL] in {
Sean Callanan2c48df22009-12-18 00:01:26 +00002524def SHLD32rrCL : I<0xA5, MRMDestReg, (outs GR32:$dst),
2525 (ins GR32:$src1, GR32:$src2),
Eli Friedman378ea832009-06-19 04:48:38 +00002526 "shld{l}\t{%cl, $src2, $dst|$dst, $src2, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002527 [(set GR32:$dst, (X86shld GR32:$src1, GR32:$src2, CL))]>, TB;
Sean Callanan2c48df22009-12-18 00:01:26 +00002528def SHRD32rrCL : I<0xAD, MRMDestReg, (outs GR32:$dst),
2529 (ins GR32:$src1, GR32:$src2),
Eli Friedman378ea832009-06-19 04:48:38 +00002530 "shrd{l}\t{%cl, $src2, $dst|$dst, $src2, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002531 [(set GR32:$dst, (X86shrd GR32:$src1, GR32:$src2, CL))]>, TB;
Sean Callanan2c48df22009-12-18 00:01:26 +00002532def SHLD16rrCL : I<0xA5, MRMDestReg, (outs GR16:$dst),
2533 (ins GR16:$src1, GR16:$src2),
Eli Friedman378ea832009-06-19 04:48:38 +00002534 "shld{w}\t{%cl, $src2, $dst|$dst, $src2, CL}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002535 [(set GR16:$dst, (X86shld GR16:$src1, GR16:$src2, CL))]>,
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002536 TB, OpSize;
Sean Callanan2c48df22009-12-18 00:01:26 +00002537def SHRD16rrCL : I<0xAD, MRMDestReg, (outs GR16:$dst),
2538 (ins GR16:$src1, GR16:$src2),
Eli Friedman378ea832009-06-19 04:48:38 +00002539 "shrd{w}\t{%cl, $src2, $dst|$dst, $src2, CL}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002540 [(set GR16:$dst, (X86shrd GR16:$src1, GR16:$src2, CL))]>,
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002541 TB, OpSize;
2542}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002543
2544let isCommutable = 1 in { // These instructions commute to each other.
2545def SHLD32rri8 : Ii8<0xA4, MRMDestReg,
Sean Callanan2c48df22009-12-18 00:01:26 +00002546 (outs GR32:$dst),
2547 (ins GR32:$src1, GR32:$src2, i8imm:$src3),
Dan Gohman91888f02007-07-31 20:11:57 +00002548 "shld{l}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002549 [(set GR32:$dst, (X86shld GR32:$src1, GR32:$src2,
2550 (i8 imm:$src3)))]>,
2551 TB;
2552def SHRD32rri8 : Ii8<0xAC, MRMDestReg,
Sean Callanan2c48df22009-12-18 00:01:26 +00002553 (outs GR32:$dst),
2554 (ins GR32:$src1, GR32:$src2, i8imm:$src3),
Dan Gohman91888f02007-07-31 20:11:57 +00002555 "shrd{l}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002556 [(set GR32:$dst, (X86shrd GR32:$src1, GR32:$src2,
2557 (i8 imm:$src3)))]>,
2558 TB;
2559def SHLD16rri8 : Ii8<0xA4, MRMDestReg,
Sean Callanan2c48df22009-12-18 00:01:26 +00002560 (outs GR16:$dst),
2561 (ins GR16:$src1, GR16:$src2, i8imm:$src3),
Dan Gohman91888f02007-07-31 20:11:57 +00002562 "shld{w}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002563 [(set GR16:$dst, (X86shld GR16:$src1, GR16:$src2,
2564 (i8 imm:$src3)))]>,
2565 TB, OpSize;
2566def SHRD16rri8 : Ii8<0xAC, MRMDestReg,
Sean Callanan2c48df22009-12-18 00:01:26 +00002567 (outs GR16:$dst),
2568 (ins GR16:$src1, GR16:$src2, i8imm:$src3),
Dan Gohman91888f02007-07-31 20:11:57 +00002569 "shrd{w}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002570 [(set GR16:$dst, (X86shrd GR16:$src1, GR16:$src2,
2571 (i8 imm:$src3)))]>,
2572 TB, OpSize;
2573}
2574
2575let isTwoAddress = 0 in {
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002576 let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00002577 def SHLD32mrCL : I<0xA5, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
Eli Friedman378ea832009-06-19 04:48:38 +00002578 "shld{l}\t{%cl, $src2, $dst|$dst, $src2, CL}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002579 [(store (X86shld (loadi32 addr:$dst), GR32:$src2, CL),
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002580 addr:$dst)]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00002581 def SHRD32mrCL : I<0xAD, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
Eli Friedman378ea832009-06-19 04:48:38 +00002582 "shrd{l}\t{%cl, $src2, $dst|$dst, $src2, CL}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002583 [(store (X86shrd (loadi32 addr:$dst), GR32:$src2, CL),
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002584 addr:$dst)]>, TB;
2585 }
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002586 def SHLD32mri8 : Ii8<0xA4, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00002587 (outs), (ins i32mem:$dst, GR32:$src2, i8imm:$src3),
Dan Gohman91888f02007-07-31 20:11:57 +00002588 "shld{l}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002589 [(store (X86shld (loadi32 addr:$dst), GR32:$src2,
2590 (i8 imm:$src3)), addr:$dst)]>,
2591 TB;
2592 def SHRD32mri8 : Ii8<0xAC, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00002593 (outs), (ins i32mem:$dst, GR32:$src2, i8imm:$src3),
Dan Gohman91888f02007-07-31 20:11:57 +00002594 "shrd{l}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002595 [(store (X86shrd (loadi32 addr:$dst), GR32:$src2,
2596 (i8 imm:$src3)), addr:$dst)]>,
2597 TB;
2598
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002599 let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00002600 def SHLD16mrCL : I<0xA5, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
Eli Friedman378ea832009-06-19 04:48:38 +00002601 "shld{w}\t{%cl, $src2, $dst|$dst, $src2, CL}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002602 [(store (X86shld (loadi16 addr:$dst), GR16:$src2, CL),
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002603 addr:$dst)]>, TB, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002604 def SHRD16mrCL : I<0xAD, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
Eli Friedman378ea832009-06-19 04:48:38 +00002605 "shrd{w}\t{%cl, $src2, $dst|$dst, $src2, CL}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002606 [(store (X86shrd (loadi16 addr:$dst), GR16:$src2, CL),
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002607 addr:$dst)]>, TB, OpSize;
2608 }
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002609 def SHLD16mri8 : Ii8<0xA4, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00002610 (outs), (ins i16mem:$dst, GR16:$src2, i8imm:$src3),
Dan Gohman91888f02007-07-31 20:11:57 +00002611 "shld{w}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002612 [(store (X86shld (loadi16 addr:$dst), GR16:$src2,
2613 (i8 imm:$src3)), addr:$dst)]>,
2614 TB, OpSize;
2615 def SHRD16mri8 : Ii8<0xAC, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00002616 (outs), (ins i16mem:$dst, GR16:$src2, i8imm:$src3),
Dan Gohman91888f02007-07-31 20:11:57 +00002617 "shrd{w}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002618 [(store (X86shrd (loadi16 addr:$dst), GR16:$src2,
2619 (i8 imm:$src3)), addr:$dst)]>,
2620 TB, OpSize;
2621}
Evan Cheng55687072007-09-14 21:48:26 +00002622} // Defs = [EFLAGS]
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002623
2624
2625// Arithmetic.
Evan Cheng55687072007-09-14 21:48:26 +00002626let Defs = [EFLAGS] in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002627let isCommutable = 1 in { // X = ADD Y, Z --> X = ADD Z, Y
Bill Wendlingae034ed2008-12-12 00:56:36 +00002628// Register-Register Addition
2629def ADD8rr : I<0x00, MRMDestReg, (outs GR8 :$dst),
2630 (ins GR8 :$src1, GR8 :$src2),
2631 "add{b}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002632 [(set GR8:$dst, (add GR8:$src1, GR8:$src2)),
Bill Wendlingae034ed2008-12-12 00:56:36 +00002633 (implicit EFLAGS)]>;
2634
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002635let isConvertibleToThreeAddress = 1 in { // Can transform into LEA.
Bill Wendlingae034ed2008-12-12 00:56:36 +00002636// Register-Register Addition
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002637def ADD16rr : I<0x01, MRMDestReg, (outs GR16:$dst),
2638 (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002639 "add{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002640 [(set GR16:$dst, (add GR16:$src1, GR16:$src2)),
2641 (implicit EFLAGS)]>, OpSize;
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002642def ADD32rr : I<0x01, MRMDestReg, (outs GR32:$dst),
2643 (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002644 "add{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002645 [(set GR32:$dst, (add GR32:$src1, GR32:$src2)),
2646 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002647} // end isConvertibleToThreeAddress
2648} // end isCommutable
Bill Wendlingae034ed2008-12-12 00:56:36 +00002649
2650// Register-Memory Addition
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002651def ADD8rm : I<0x02, MRMSrcMem, (outs GR8 :$dst),
2652 (ins GR8 :$src1, i8mem :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002653 "add{b}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002654 [(set GR8:$dst, (add GR8:$src1, (load addr:$src2))),
2655 (implicit EFLAGS)]>;
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002656def ADD16rm : I<0x03, MRMSrcMem, (outs GR16:$dst),
2657 (ins GR16:$src1, i16mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002658 "add{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002659 [(set GR16:$dst, (add GR16:$src1, (load addr:$src2))),
2660 (implicit EFLAGS)]>, OpSize;
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002661def ADD32rm : I<0x03, MRMSrcMem, (outs GR32:$dst),
2662 (ins GR32:$src1, i32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002663 "add{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002664 [(set GR32:$dst, (add GR32:$src1, (load addr:$src2))),
2665 (implicit EFLAGS)]>;
Sean Callanan7e7df0e2009-09-15 20:53:57 +00002666
Sean Callanan84df9312009-09-15 21:43:27 +00002667// Register-Register Addition - Equivalent to the normal rr forms (ADD8rr,
2668// ADD16rr, and ADD32rr), but differently encoded.
Sean Callanan7e7df0e2009-09-15 20:53:57 +00002669def ADD8mrmrr: I<0x02, MRMSrcReg, (outs GR8:$dst), (ins GR8:$src1, GR8:$src2),
2670 "add{b}\t{$src2, $dst|$dst, $src2}", []>;
2671def ADD16mrmrr: I<0x03, MRMSrcReg,(outs GR16:$dst),(ins GR16:$src1, GR16:$src2),
2672 "add{w}\t{$src2, $dst|$dst, $src2}", []>, OpSize;
2673def ADD32mrmrr: I<0x03, MRMSrcReg,(outs GR16:$dst),(ins GR16:$src1, GR16:$src2),
2674 "add{l}\t{$src2, $dst|$dst, $src2}", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002675
Bill Wendlingae034ed2008-12-12 00:56:36 +00002676// Register-Integer Addition
2677def ADD8ri : Ii8<0x80, MRM0r, (outs GR8:$dst), (ins GR8:$src1, i8imm:$src2),
2678 "add{b}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002679 [(set GR8:$dst, (add GR8:$src1, imm:$src2)),
2680 (implicit EFLAGS)]>;
Bill Wendlingae034ed2008-12-12 00:56:36 +00002681
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002682let isConvertibleToThreeAddress = 1 in { // Can transform into LEA.
Bill Wendlingae034ed2008-12-12 00:56:36 +00002683// Register-Integer Addition
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002684def ADD16ri : Ii16<0x81, MRM0r, (outs GR16:$dst),
2685 (ins GR16:$src1, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002686 "add{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002687 [(set GR16:$dst, (add GR16:$src1, imm:$src2)),
2688 (implicit EFLAGS)]>, OpSize;
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002689def ADD32ri : Ii32<0x81, MRM0r, (outs GR32:$dst),
2690 (ins GR32:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002691 "add{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002692 [(set GR32:$dst, (add GR32:$src1, imm:$src2)),
2693 (implicit EFLAGS)]>;
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002694def ADD16ri8 : Ii8<0x83, MRM0r, (outs GR16:$dst),
2695 (ins GR16:$src1, i16i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002696 "add{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002697 [(set GR16:$dst, (add GR16:$src1, i16immSExt8:$src2)),
2698 (implicit EFLAGS)]>, OpSize;
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002699def ADD32ri8 : Ii8<0x83, MRM0r, (outs GR32:$dst),
2700 (ins GR32:$src1, i32i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002701 "add{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002702 [(set GR32:$dst, (add GR32:$src1, i32immSExt8:$src2)),
2703 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002704}
2705
2706let isTwoAddress = 0 in {
Bill Wendlingae034ed2008-12-12 00:56:36 +00002707 // Memory-Register Addition
Bill Wendlingf5399032008-12-12 21:15:41 +00002708 def ADD8mr : I<0x00, MRMDestMem, (outs), (ins i8mem:$dst, GR8:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002709 "add{b}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002710 [(store (add (load addr:$dst), GR8:$src2), addr:$dst),
2711 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002712 def ADD16mr : I<0x01, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002713 "add{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002714 [(store (add (load addr:$dst), GR16:$src2), addr:$dst),
2715 (implicit EFLAGS)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002716 def ADD32mr : I<0x01, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002717 "add{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002718 [(store (add (load addr:$dst), GR32:$src2), addr:$dst),
2719 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002720 def ADD8mi : Ii8<0x80, MRM0m, (outs), (ins i8mem :$dst, i8imm :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002721 "add{b}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002722 [(store (add (loadi8 addr:$dst), imm:$src2), addr:$dst),
2723 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002724 def ADD16mi : Ii16<0x81, MRM0m, (outs), (ins i16mem:$dst, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002725 "add{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002726 [(store (add (loadi16 addr:$dst), imm:$src2), addr:$dst),
2727 (implicit EFLAGS)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002728 def ADD32mi : Ii32<0x81, MRM0m, (outs), (ins i32mem:$dst, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002729 "add{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002730 [(store (add (loadi32 addr:$dst), imm:$src2), addr:$dst),
2731 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002732 def ADD16mi8 : Ii8<0x83, MRM0m, (outs), (ins i16mem:$dst, i16i8imm :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002733 "add{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002734 [(store (add (load addr:$dst), i16immSExt8:$src2),
2735 addr:$dst),
2736 (implicit EFLAGS)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002737 def ADD32mi8 : Ii8<0x83, MRM0m, (outs), (ins i32mem:$dst, i32i8imm :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002738 "add{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingae034ed2008-12-12 00:56:36 +00002739 [(store (add (load addr:$dst), i32immSExt8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00002740 addr:$dst),
2741 (implicit EFLAGS)]>;
Sean Callanan0316b342009-08-11 21:26:06 +00002742
2743 // addition to rAX
2744 def ADD8i8 : Ii8<0x04, RawFrm, (outs), (ins i8imm:$src),
Sean Callanan251676e2009-09-02 00:55:49 +00002745 "add{b}\t{$src, %al|%al, $src}", []>;
Sean Callanan0316b342009-08-11 21:26:06 +00002746 def ADD16i16 : Ii16<0x05, RawFrm, (outs), (ins i16imm:$src),
Sean Callanan251676e2009-09-02 00:55:49 +00002747 "add{w}\t{$src, %ax|%ax, $src}", []>, OpSize;
Sean Callanan0316b342009-08-11 21:26:06 +00002748 def ADD32i32 : Ii32<0x05, RawFrm, (outs), (ins i32imm:$src),
Sean Callanan251676e2009-09-02 00:55:49 +00002749 "add{l}\t{$src, %eax|%eax, $src}", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002750}
2751
Evan Cheng259471d2007-10-05 17:59:57 +00002752let Uses = [EFLAGS] in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002753let isCommutable = 1 in { // X = ADC Y, Z --> X = ADC Z, Y
Dale Johannesen747fe522009-06-02 03:12:52 +00002754def ADC8rr : I<0x10, MRMDestReg, (outs GR8:$dst), (ins GR8:$src1, GR8:$src2),
Dale Johannesen06b83f12009-05-18 17:44:15 +00002755 "adc{b}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002756 [(set GR8:$dst, (adde GR8:$src1, GR8:$src2))]>;
Dale Johannesen06b83f12009-05-18 17:44:15 +00002757def ADC16rr : I<0x11, MRMDestReg, (outs GR16:$dst),
2758 (ins GR16:$src1, GR16:$src2),
2759 "adc{w}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002760 [(set GR16:$dst, (adde GR16:$src1, GR16:$src2))]>, OpSize;
Dale Johannesen06b83f12009-05-18 17:44:15 +00002761def ADC32rr : I<0x11, MRMDestReg, (outs GR32:$dst),
2762 (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002763 "adc{l}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002764 [(set GR32:$dst, (adde GR32:$src1, GR32:$src2))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002765}
Sean Callanan2c48df22009-12-18 00:01:26 +00002766
2767def ADC8rr_REV : I<0x12, MRMSrcReg, (outs GR8:$dst), (ins GR8:$src1, GR8:$src2),
2768 "adc{b}\t{$src2, $dst|$dst, $src2}", []>;
2769def ADC16rr_REV : I<0x13, MRMSrcReg, (outs GR16:$dst),
2770 (ins GR16:$src1, GR16:$src2),
2771 "adc{w}\t{$src2, $dst|$dst, $src2}", []>, OpSize;
2772def ADC32rr_REV : I<0x13, MRMSrcReg, (outs GR32:$dst),
2773 (ins GR32:$src1, GR32:$src2),
2774 "adc{l}\t{$src2, $dst|$dst, $src2}", []>;
2775
Dale Johannesen06b83f12009-05-18 17:44:15 +00002776def ADC8rm : I<0x12, MRMSrcMem , (outs GR8:$dst),
2777 (ins GR8:$src1, i8mem:$src2),
2778 "adc{b}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002779 [(set GR8:$dst, (adde GR8:$src1, (load addr:$src2)))]>;
Dale Johannesen06b83f12009-05-18 17:44:15 +00002780def ADC16rm : I<0x13, MRMSrcMem , (outs GR16:$dst),
2781 (ins GR16:$src1, i16mem:$src2),
2782 "adc{w}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002783 [(set GR16:$dst, (adde GR16:$src1, (load addr:$src2)))]>,
Dale Johannesen067cfb22009-05-18 21:41:59 +00002784 OpSize;
Dale Johannesen06b83f12009-05-18 17:44:15 +00002785def ADC32rm : I<0x13, MRMSrcMem , (outs GR32:$dst),
2786 (ins GR32:$src1, i32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002787 "adc{l}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002788 [(set GR32:$dst, (adde GR32:$src1, (load addr:$src2)))]>;
2789def ADC8ri : Ii8<0x80, MRM2r, (outs GR8:$dst), (ins GR8:$src1, i8imm:$src2),
Dale Johannesen06b83f12009-05-18 17:44:15 +00002790 "adc{b}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002791 [(set GR8:$dst, (adde GR8:$src1, imm:$src2))]>;
Dale Johannesen06b83f12009-05-18 17:44:15 +00002792def ADC16ri : Ii16<0x81, MRM2r, (outs GR16:$dst),
2793 (ins GR16:$src1, i16imm:$src2),
2794 "adc{w}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002795 [(set GR16:$dst, (adde GR16:$src1, imm:$src2))]>, OpSize;
Dale Johannesen06b83f12009-05-18 17:44:15 +00002796def ADC16ri8 : Ii8<0x83, MRM2r, (outs GR16:$dst),
2797 (ins GR16:$src1, i16i8imm:$src2),
2798 "adc{w}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002799 [(set GR16:$dst, (adde GR16:$src1, i16immSExt8:$src2))]>,
2800 OpSize;
Dale Johannesen06b83f12009-05-18 17:44:15 +00002801def ADC32ri : Ii32<0x81, MRM2r, (outs GR32:$dst),
2802 (ins GR32:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002803 "adc{l}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002804 [(set GR32:$dst, (adde GR32:$src1, imm:$src2))]>;
Dale Johannesen06b83f12009-05-18 17:44:15 +00002805def ADC32ri8 : Ii8<0x83, MRM2r, (outs GR32:$dst),
2806 (ins GR32:$src1, i32i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002807 "adc{l}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002808 [(set GR32:$dst, (adde GR32:$src1, i32immSExt8:$src2))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002809
2810let isTwoAddress = 0 in {
Dale Johannesen747fe522009-06-02 03:12:52 +00002811 def ADC8mr : I<0x10, MRMDestMem, (outs), (ins i8mem:$dst, GR8:$src2),
Dale Johannesen06b83f12009-05-18 17:44:15 +00002812 "adc{b}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002813 [(store (adde (load addr:$dst), GR8:$src2), addr:$dst)]>;
2814 def ADC16mr : I<0x11, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
Dale Johannesen06b83f12009-05-18 17:44:15 +00002815 "adc{w}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002816 [(store (adde (load addr:$dst), GR16:$src2), addr:$dst)]>,
2817 OpSize;
2818 def ADC32mr : I<0x11, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002819 "adc{l}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002820 [(store (adde (load addr:$dst), GR32:$src2), addr:$dst)]>;
2821 def ADC8mi : Ii8<0x80, MRM2m, (outs), (ins i8mem:$dst, i8imm:$src2),
Dale Johannesen06b83f12009-05-18 17:44:15 +00002822 "adc{b}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002823 [(store (adde (loadi8 addr:$dst), imm:$src2), addr:$dst)]>;
2824 def ADC16mi : Ii16<0x81, MRM2m, (outs), (ins i16mem:$dst, i16imm:$src2),
Dale Johannesen06b83f12009-05-18 17:44:15 +00002825 "adc{w}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002826 [(store (adde (loadi16 addr:$dst), imm:$src2), addr:$dst)]>,
2827 OpSize;
2828 def ADC16mi8 : Ii8<0x83, MRM2m, (outs), (ins i16mem:$dst, i16i8imm :$src2),
Dale Johannesen06b83f12009-05-18 17:44:15 +00002829 "adc{w}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002830 [(store (adde (load addr:$dst), i16immSExt8:$src2), addr:$dst)]>,
2831 OpSize;
2832 def ADC32mi : Ii32<0x81, MRM2m, (outs), (ins i32mem:$dst, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002833 "adc{l}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002834 [(store (adde (loadi32 addr:$dst), imm:$src2), addr:$dst)]>;
2835 def ADC32mi8 : Ii8<0x83, MRM2m, (outs), (ins i32mem:$dst, i32i8imm :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002836 "adc{l}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002837 [(store (adde (load addr:$dst), i32immSExt8:$src2), addr:$dst)]>;
Sean Callanan8562bef2009-09-11 19:01:56 +00002838
2839 def ADC8i8 : Ii8<0x14, RawFrm, (outs), (ins i8imm:$src),
2840 "adc{b}\t{$src, %al|%al, $src}", []>;
2841 def ADC16i16 : Ii16<0x15, RawFrm, (outs), (ins i16imm:$src),
2842 "adc{w}\t{$src, %ax|%ax, $src}", []>, OpSize;
2843 def ADC32i32 : Ii32<0x15, RawFrm, (outs), (ins i32imm:$src),
2844 "adc{l}\t{$src, %eax|%eax, $src}", []>;
Dale Johannesen747fe522009-06-02 03:12:52 +00002845}
Evan Cheng259471d2007-10-05 17:59:57 +00002846} // Uses = [EFLAGS]
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002847
Bill Wendlingae034ed2008-12-12 00:56:36 +00002848// Register-Register Subtraction
2849def SUB8rr : I<0x28, MRMDestReg, (outs GR8:$dst), (ins GR8:$src1, GR8:$src2),
2850 "sub{b}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002851 [(set GR8:$dst, (sub GR8:$src1, GR8:$src2)),
2852 (implicit EFLAGS)]>;
Bill Wendlingae034ed2008-12-12 00:56:36 +00002853def SUB16rr : I<0x29, MRMDestReg, (outs GR16:$dst), (ins GR16:$src1,GR16:$src2),
2854 "sub{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002855 [(set GR16:$dst, (sub GR16:$src1, GR16:$src2)),
2856 (implicit EFLAGS)]>, OpSize;
Bill Wendlingae034ed2008-12-12 00:56:36 +00002857def SUB32rr : I<0x29, MRMDestReg, (outs GR32:$dst), (ins GR32:$src1,GR32:$src2),
2858 "sub{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002859 [(set GR32:$dst, (sub GR32:$src1, GR32:$src2)),
2860 (implicit EFLAGS)]>;
Bill Wendlingae034ed2008-12-12 00:56:36 +00002861
Sean Callanan2c48df22009-12-18 00:01:26 +00002862def SUB8rr_REV : I<0x2A, MRMSrcReg, (outs GR8:$dst), (ins GR8:$src1, GR8:$src2),
2863 "sub{b}\t{$src2, $dst|$dst, $src2}", []>;
2864def SUB16rr_REV : I<0x2B, MRMSrcReg, (outs GR16:$dst),
2865 (ins GR16:$src1, GR16:$src2),
2866 "sub{w}\t{$src2, $dst|$dst, $src2}", []>, OpSize;
2867def SUB32rr_REV : I<0x2B, MRMSrcReg, (outs GR32:$dst),
2868 (ins GR32:$src1, GR32:$src2),
2869 "sub{l}\t{$src2, $dst|$dst, $src2}", []>;
2870
Bill Wendlingae034ed2008-12-12 00:56:36 +00002871// Register-Memory Subtraction
2872def SUB8rm : I<0x2A, MRMSrcMem, (outs GR8 :$dst),
2873 (ins GR8 :$src1, i8mem :$src2),
2874 "sub{b}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002875 [(set GR8:$dst, (sub GR8:$src1, (load addr:$src2))),
2876 (implicit EFLAGS)]>;
Bill Wendlingae034ed2008-12-12 00:56:36 +00002877def SUB16rm : I<0x2B, MRMSrcMem, (outs GR16:$dst),
2878 (ins GR16:$src1, i16mem:$src2),
2879 "sub{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002880 [(set GR16:$dst, (sub GR16:$src1, (load addr:$src2))),
2881 (implicit EFLAGS)]>, OpSize;
Bill Wendlingae034ed2008-12-12 00:56:36 +00002882def SUB32rm : I<0x2B, MRMSrcMem, (outs GR32:$dst),
2883 (ins GR32:$src1, i32mem:$src2),
2884 "sub{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002885 [(set GR32:$dst, (sub GR32:$src1, (load addr:$src2))),
2886 (implicit EFLAGS)]>;
Bill Wendlingae034ed2008-12-12 00:56:36 +00002887
2888// Register-Integer Subtraction
2889def SUB8ri : Ii8 <0x80, MRM5r, (outs GR8:$dst),
2890 (ins GR8:$src1, i8imm:$src2),
2891 "sub{b}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002892 [(set GR8:$dst, (sub GR8:$src1, imm:$src2)),
2893 (implicit EFLAGS)]>;
Bill Wendlingae034ed2008-12-12 00:56:36 +00002894def SUB16ri : Ii16<0x81, MRM5r, (outs GR16:$dst),
2895 (ins GR16:$src1, i16imm:$src2),
2896 "sub{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002897 [(set GR16:$dst, (sub GR16:$src1, imm:$src2)),
2898 (implicit EFLAGS)]>, OpSize;
Bill Wendlingae034ed2008-12-12 00:56:36 +00002899def SUB32ri : Ii32<0x81, MRM5r, (outs GR32:$dst),
2900 (ins GR32:$src1, i32imm:$src2),
2901 "sub{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002902 [(set GR32:$dst, (sub GR32:$src1, imm:$src2)),
2903 (implicit EFLAGS)]>;
Bill Wendlingae034ed2008-12-12 00:56:36 +00002904def SUB16ri8 : Ii8<0x83, MRM5r, (outs GR16:$dst),
2905 (ins GR16:$src1, i16i8imm:$src2),
2906 "sub{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002907 [(set GR16:$dst, (sub GR16:$src1, i16immSExt8:$src2)),
2908 (implicit EFLAGS)]>, OpSize;
Bill Wendlingae034ed2008-12-12 00:56:36 +00002909def SUB32ri8 : Ii8<0x83, MRM5r, (outs GR32:$dst),
2910 (ins GR32:$src1, i32i8imm:$src2),
2911 "sub{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002912 [(set GR32:$dst, (sub GR32:$src1, i32immSExt8:$src2)),
2913 (implicit EFLAGS)]>;
Bill Wendlingae034ed2008-12-12 00:56:36 +00002914
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002915let isTwoAddress = 0 in {
Bill Wendlingae034ed2008-12-12 00:56:36 +00002916 // Memory-Register Subtraction
Evan Chengb783fa32007-07-19 01:14:50 +00002917 def SUB8mr : I<0x28, MRMDestMem, (outs), (ins i8mem :$dst, GR8 :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002918 "sub{b}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002919 [(store (sub (load addr:$dst), GR8:$src2), addr:$dst),
2920 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002921 def SUB16mr : I<0x29, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002922 "sub{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002923 [(store (sub (load addr:$dst), GR16:$src2), addr:$dst),
2924 (implicit EFLAGS)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002925 def SUB32mr : I<0x29, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002926 "sub{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002927 [(store (sub (load addr:$dst), GR32:$src2), addr:$dst),
2928 (implicit EFLAGS)]>;
Bill Wendlingae034ed2008-12-12 00:56:36 +00002929
2930 // Memory-Integer Subtraction
Evan Chengb783fa32007-07-19 01:14:50 +00002931 def SUB8mi : Ii8<0x80, MRM5m, (outs), (ins i8mem :$dst, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002932 "sub{b}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002933 [(store (sub (loadi8 addr:$dst), imm:$src2), addr:$dst),
2934 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002935 def SUB16mi : Ii16<0x81, MRM5m, (outs), (ins i16mem:$dst, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002936 "sub{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002937 [(store (sub (loadi16 addr:$dst), imm:$src2),addr:$dst),
2938 (implicit EFLAGS)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002939 def SUB32mi : Ii32<0x81, MRM5m, (outs), (ins i32mem:$dst, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002940 "sub{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002941 [(store (sub (loadi32 addr:$dst), imm:$src2),addr:$dst),
2942 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002943 def SUB16mi8 : Ii8<0x83, MRM5m, (outs), (ins i16mem:$dst, i16i8imm :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002944 "sub{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingae034ed2008-12-12 00:56:36 +00002945 [(store (sub (load addr:$dst), i16immSExt8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00002946 addr:$dst),
2947 (implicit EFLAGS)]>, OpSize;
Bill Wendlingae034ed2008-12-12 00:56:36 +00002948 def SUB32mi8 : Ii8<0x83, MRM5m, (outs), (ins i32mem:$dst, i32i8imm :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002949 "sub{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingae034ed2008-12-12 00:56:36 +00002950 [(store (sub (load addr:$dst), i32immSExt8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00002951 addr:$dst),
2952 (implicit EFLAGS)]>;
Sean Callanan8562bef2009-09-11 19:01:56 +00002953
2954 def SUB8i8 : Ii8<0x2C, RawFrm, (outs), (ins i8imm:$src),
2955 "sub{b}\t{$src, %al|%al, $src}", []>;
2956 def SUB16i16 : Ii16<0x2D, RawFrm, (outs), (ins i16imm:$src),
2957 "sub{w}\t{$src, %ax|%ax, $src}", []>, OpSize;
2958 def SUB32i32 : Ii32<0x2D, RawFrm, (outs), (ins i32imm:$src),
2959 "sub{l}\t{$src, %eax|%eax, $src}", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002960}
2961
Evan Cheng259471d2007-10-05 17:59:57 +00002962let Uses = [EFLAGS] in {
Dale Johannesen06b83f12009-05-18 17:44:15 +00002963def SBB8rr : I<0x18, MRMDestReg, (outs GR8:$dst),
2964 (ins GR8:$src1, GR8:$src2),
2965 "sbb{b}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002966 [(set GR8:$dst, (sube GR8:$src1, GR8:$src2))]>;
Dale Johannesen06b83f12009-05-18 17:44:15 +00002967def SBB16rr : I<0x19, MRMDestReg, (outs GR16:$dst),
2968 (ins GR16:$src1, GR16:$src2),
2969 "sbb{w}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002970 [(set GR16:$dst, (sube GR16:$src1, GR16:$src2))]>, OpSize;
Dale Johannesen06b83f12009-05-18 17:44:15 +00002971def SBB32rr : I<0x19, MRMDestReg, (outs GR32:$dst),
2972 (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002973 "sbb{l}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002974 [(set GR32:$dst, (sube GR32:$src1, GR32:$src2))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002975
2976let isTwoAddress = 0 in {
Dale Johannesen06b83f12009-05-18 17:44:15 +00002977 def SBB8mr : I<0x18, MRMDestMem, (outs), (ins i8mem:$dst, GR8:$src2),
2978 "sbb{b}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002979 [(store (sube (load addr:$dst), GR8:$src2), addr:$dst)]>;
Dale Johannesen06b83f12009-05-18 17:44:15 +00002980 def SBB16mr : I<0x19, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
2981 "sbb{w}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002982 [(store (sube (load addr:$dst), GR16:$src2), addr:$dst)]>,
Dale Johannesen067cfb22009-05-18 21:41:59 +00002983 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002984 def SBB32mr : I<0x19, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002985 "sbb{l}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002986 [(store (sube (load addr:$dst), GR32:$src2), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002987 def SBB8mi : Ii32<0x80, MRM3m, (outs), (ins i8mem:$dst, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002988 "sbb{b}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002989 [(store (sube (loadi8 addr:$dst), imm:$src2), addr:$dst)]>;
Dale Johannesen06b83f12009-05-18 17:44:15 +00002990 def SBB16mi : Ii16<0x81, MRM3m, (outs), (ins i16mem:$dst, i16imm:$src2),
2991 "sbb{w}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002992 [(store (sube (loadi16 addr:$dst), imm:$src2), addr:$dst)]>,
Dale Johannesen067cfb22009-05-18 21:41:59 +00002993 OpSize;
Dale Johannesen06b83f12009-05-18 17:44:15 +00002994 def SBB16mi8 : Ii8<0x83, MRM3m, (outs), (ins i16mem:$dst, i16i8imm :$src2),
2995 "sbb{w}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002996 [(store (sube (load addr:$dst), i16immSExt8:$src2), addr:$dst)]>,
Dale Johannesen067cfb22009-05-18 21:41:59 +00002997 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002998 def SBB32mi : Ii32<0x81, MRM3m, (outs), (ins i32mem:$dst, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002999 "sbb{l}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00003000 [(store (sube (loadi32 addr:$dst), imm:$src2), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00003001 def SBB32mi8 : Ii8<0x83, MRM3m, (outs), (ins i32mem:$dst, i32i8imm :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00003002 "sbb{l}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00003003 [(store (sube (load addr:$dst), i32immSExt8:$src2), addr:$dst)]>;
Sean Callanan8562bef2009-09-11 19:01:56 +00003004
3005 def SBB8i8 : Ii8<0x1C, RawFrm, (outs), (ins i8imm:$src),
3006 "sbb{b}\t{$src, %al|%al, $src}", []>;
3007 def SBB16i16 : Ii16<0x1D, RawFrm, (outs), (ins i16imm:$src),
3008 "sbb{w}\t{$src, %ax|%ax, $src}", []>, OpSize;
3009 def SBB32i32 : Ii32<0x1D, RawFrm, (outs), (ins i32imm:$src),
3010 "sbb{l}\t{$src, %eax|%eax, $src}", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003011}
Sean Callanan2c48df22009-12-18 00:01:26 +00003012
3013def SBB8rr_REV : I<0x1A, MRMSrcReg, (outs GR8:$dst), (ins GR8:$src1, GR8:$src2),
3014 "sbb{b}\t{$src2, $dst|$dst, $src2}", []>;
3015def SBB16rr_REV : I<0x1B, MRMSrcReg, (outs GR16:$dst),
3016 (ins GR16:$src1, GR16:$src2),
3017 "sbb{w}\t{$src2, $dst|$dst, $src2}", []>, OpSize;
3018def SBB32rr_REV : I<0x1B, MRMSrcReg, (outs GR32:$dst),
3019 (ins GR32:$src1, GR32:$src2),
3020 "sbb{l}\t{$src2, $dst|$dst, $src2}", []>;
3021
Dale Johannesen06b83f12009-05-18 17:44:15 +00003022def SBB8rm : I<0x1A, MRMSrcMem, (outs GR8:$dst), (ins GR8:$src1, i8mem:$src2),
3023 "sbb{b}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00003024 [(set GR8:$dst, (sube GR8:$src1, (load addr:$src2)))]>;
Dale Johannesen06b83f12009-05-18 17:44:15 +00003025def SBB16rm : I<0x1B, MRMSrcMem, (outs GR16:$dst),
3026 (ins GR16:$src1, i16mem:$src2),
3027 "sbb{w}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00003028 [(set GR16:$dst, (sube GR16:$src1, (load addr:$src2)))]>,
Dale Johannesen067cfb22009-05-18 21:41:59 +00003029 OpSize;
Dale Johannesen06b83f12009-05-18 17:44:15 +00003030def SBB32rm : I<0x1B, MRMSrcMem, (outs GR32:$dst),
3031 (ins GR32:$src1, i32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00003032 "sbb{l}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00003033 [(set GR32:$dst, (sube GR32:$src1, (load addr:$src2)))]>;
Dale Johannesen06b83f12009-05-18 17:44:15 +00003034def SBB8ri : Ii8<0x80, MRM3r, (outs GR8:$dst), (ins GR8:$src1, i8imm:$src2),
3035 "sbb{b}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00003036 [(set GR8:$dst, (sube GR8:$src1, imm:$src2))]>;
Dale Johannesen06b83f12009-05-18 17:44:15 +00003037def SBB16ri : Ii16<0x81, MRM3r, (outs GR16:$dst),
3038 (ins GR16:$src1, i16imm:$src2),
3039 "sbb{w}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00003040 [(set GR16:$dst, (sube GR16:$src1, imm:$src2))]>, OpSize;
Dale Johannesen06b83f12009-05-18 17:44:15 +00003041def SBB16ri8 : Ii8<0x83, MRM3r, (outs GR16:$dst),
3042 (ins GR16:$src1, i16i8imm:$src2),
3043 "sbb{w}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00003044 [(set GR16:$dst, (sube GR16:$src1, i16immSExt8:$src2))]>,
3045 OpSize;
Dale Johannesen06b83f12009-05-18 17:44:15 +00003046def SBB32ri : Ii32<0x81, MRM3r, (outs GR32:$dst),
3047 (ins GR32:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00003048 "sbb{l}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00003049 [(set GR32:$dst, (sube GR32:$src1, imm:$src2))]>;
Dale Johannesen06b83f12009-05-18 17:44:15 +00003050def SBB32ri8 : Ii8<0x83, MRM3r, (outs GR32:$dst),
3051 (ins GR32:$src1, i32i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00003052 "sbb{l}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00003053 [(set GR32:$dst, (sube GR32:$src1, i32immSExt8:$src2))]>;
Evan Cheng259471d2007-10-05 17:59:57 +00003054} // Uses = [EFLAGS]
Evan Cheng55687072007-09-14 21:48:26 +00003055} // Defs = [EFLAGS]
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003056
Evan Cheng55687072007-09-14 21:48:26 +00003057let Defs = [EFLAGS] in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003058let isCommutable = 1 in { // X = IMUL Y, Z --> X = IMUL Z, Y
Bill Wendlingf5399032008-12-12 21:15:41 +00003059// Register-Register Signed Integer Multiply
Bill Wendlingae034ed2008-12-12 00:56:36 +00003060def IMUL16rr : I<0xAF, MRMSrcReg, (outs GR16:$dst), (ins GR16:$src1,GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00003061 "imul{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00003062 [(set GR16:$dst, (mul GR16:$src1, GR16:$src2)),
3063 (implicit EFLAGS)]>, TB, OpSize;
Bill Wendlingae034ed2008-12-12 00:56:36 +00003064def IMUL32rr : I<0xAF, MRMSrcReg, (outs GR32:$dst), (ins GR32:$src1,GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00003065 "imul{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00003066 [(set GR32:$dst, (mul GR32:$src1, GR32:$src2)),
3067 (implicit EFLAGS)]>, TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003068}
Bill Wendlingae034ed2008-12-12 00:56:36 +00003069
Bill Wendlingf5399032008-12-12 21:15:41 +00003070// Register-Memory Signed Integer Multiply
Bill Wendlingae034ed2008-12-12 00:56:36 +00003071def IMUL16rm : I<0xAF, MRMSrcMem, (outs GR16:$dst),
3072 (ins GR16:$src1, i16mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00003073 "imul{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00003074 [(set GR16:$dst, (mul GR16:$src1, (load addr:$src2))),
3075 (implicit EFLAGS)]>, TB, OpSize;
Sean Callanan2c48df22009-12-18 00:01:26 +00003076def IMUL32rm : I<0xAF, MRMSrcMem, (outs GR32:$dst),
3077 (ins GR32:$src1, i32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00003078 "imul{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00003079 [(set GR32:$dst, (mul GR32:$src1, (load addr:$src2))),
3080 (implicit EFLAGS)]>, TB;
Evan Cheng55687072007-09-14 21:48:26 +00003081} // Defs = [EFLAGS]
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003082} // end Two Address instructions
3083
3084// Suprisingly enough, these are not two address instructions!
Evan Cheng55687072007-09-14 21:48:26 +00003085let Defs = [EFLAGS] in {
Bill Wendlingf5399032008-12-12 21:15:41 +00003086// Register-Integer Signed Integer Multiply
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003087def IMUL16rri : Ii16<0x69, MRMSrcReg, // GR16 = GR16*I16
Evan Chengb783fa32007-07-19 01:14:50 +00003088 (outs GR16:$dst), (ins GR16:$src1, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00003089 "imul{w}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00003090 [(set GR16:$dst, (mul GR16:$src1, imm:$src2)),
3091 (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003092def IMUL32rri : Ii32<0x69, MRMSrcReg, // GR32 = GR32*I32
Evan Chengb783fa32007-07-19 01:14:50 +00003093 (outs GR32:$dst), (ins GR32:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00003094 "imul{l}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00003095 [(set GR32:$dst, (mul GR32:$src1, imm:$src2)),
3096 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003097def IMUL16rri8 : Ii8<0x6B, MRMSrcReg, // GR16 = GR16*I8
Evan Chengb783fa32007-07-19 01:14:50 +00003098 (outs GR16:$dst), (ins GR16:$src1, i16i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00003099 "imul{w}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00003100 [(set GR16:$dst, (mul GR16:$src1, i16immSExt8:$src2)),
3101 (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003102def IMUL32rri8 : Ii8<0x6B, MRMSrcReg, // GR32 = GR32*I8
Evan Chengb783fa32007-07-19 01:14:50 +00003103 (outs GR32:$dst), (ins GR32:$src1, i32i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00003104 "imul{l}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00003105 [(set GR32:$dst, (mul GR32:$src1, i32immSExt8:$src2)),
3106 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003107
Bill Wendlingf5399032008-12-12 21:15:41 +00003108// Memory-Integer Signed Integer Multiply
Sean Callanan2c48df22009-12-18 00:01:26 +00003109def IMUL16rmi : Ii16<0x69, MRMSrcMem, // GR16 = [mem16]*I16
Evan Chengb783fa32007-07-19 01:14:50 +00003110 (outs GR16:$dst), (ins i16mem:$src1, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00003111 "imul{w}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00003112 [(set GR16:$dst, (mul (load addr:$src1), imm:$src2)),
3113 (implicit EFLAGS)]>, OpSize;
Sean Callanan2c48df22009-12-18 00:01:26 +00003114def IMUL32rmi : Ii32<0x69, MRMSrcMem, // GR32 = [mem32]*I32
Evan Chengb783fa32007-07-19 01:14:50 +00003115 (outs GR32:$dst), (ins i32mem:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00003116 "imul{l}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00003117 [(set GR32:$dst, (mul (load addr:$src1), imm:$src2)),
3118 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003119def IMUL16rmi8 : Ii8<0x6B, MRMSrcMem, // GR16 = [mem16]*I8
Evan Chengb783fa32007-07-19 01:14:50 +00003120 (outs GR16:$dst), (ins i16mem:$src1, i16i8imm :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00003121 "imul{w}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Bill Wendlingae034ed2008-12-12 00:56:36 +00003122 [(set GR16:$dst, (mul (load addr:$src1),
Bill Wendlingf5399032008-12-12 21:15:41 +00003123 i16immSExt8:$src2)),
3124 (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003125def IMUL32rmi8 : Ii8<0x6B, MRMSrcMem, // GR32 = [mem32]*I8
Evan Chengb783fa32007-07-19 01:14:50 +00003126 (outs GR32:$dst), (ins i32mem:$src1, i32i8imm: $src2),
Dan Gohman91888f02007-07-31 20:11:57 +00003127 "imul{l}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Bill Wendlingae034ed2008-12-12 00:56:36 +00003128 [(set GR32:$dst, (mul (load addr:$src1),
Bill Wendlingf5399032008-12-12 21:15:41 +00003129 i32immSExt8:$src2)),
3130 (implicit EFLAGS)]>;
Evan Cheng55687072007-09-14 21:48:26 +00003131} // Defs = [EFLAGS]
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003132
3133//===----------------------------------------------------------------------===//
3134// Test instructions are just like AND, except they don't generate a result.
3135//
Evan Cheng950aac02007-09-25 01:57:46 +00003136let Defs = [EFLAGS] in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003137let isCommutable = 1 in { // TEST X, Y --> TEST Y, X
Evan Chengb783fa32007-07-19 01:14:50 +00003138def TEST8rr : I<0x84, MRMDestReg, (outs), (ins GR8:$src1, GR8:$src2),
Evan Cheng621216e2007-09-29 00:00:36 +00003139 "test{b}\t{$src2, $src1|$src1, $src2}",
Chris Lattner21da6382008-02-19 17:37:35 +00003140 [(X86cmp (and_su GR8:$src1, GR8:$src2), 0),
Evan Cheng621216e2007-09-29 00:00:36 +00003141 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00003142def TEST16rr : I<0x85, MRMDestReg, (outs), (ins GR16:$src1, GR16:$src2),
Evan Cheng621216e2007-09-29 00:00:36 +00003143 "test{w}\t{$src2, $src1|$src1, $src2}",
Chris Lattner21da6382008-02-19 17:37:35 +00003144 [(X86cmp (and_su GR16:$src1, GR16:$src2), 0),
Evan Cheng621216e2007-09-29 00:00:36 +00003145 (implicit EFLAGS)]>,
3146 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00003147def TEST32rr : I<0x85, MRMDestReg, (outs), (ins GR32:$src1, GR32:$src2),
Evan Cheng621216e2007-09-29 00:00:36 +00003148 "test{l}\t{$src2, $src1|$src1, $src2}",
Chris Lattner21da6382008-02-19 17:37:35 +00003149 [(X86cmp (and_su GR32:$src1, GR32:$src2), 0),
Evan Cheng621216e2007-09-29 00:00:36 +00003150 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003151}
3152
Sean Callanan3e4b1a32009-09-01 18:14:18 +00003153def TEST8i8 : Ii8<0xA8, RawFrm, (outs), (ins i8imm:$src),
3154 "test{b}\t{$src, %al|%al, $src}", []>;
3155def TEST16i16 : Ii16<0xA9, RawFrm, (outs), (ins i16imm:$src),
3156 "test{w}\t{$src, %ax|%ax, $src}", []>, OpSize;
3157def TEST32i32 : Ii32<0xA9, RawFrm, (outs), (ins i32imm:$src),
3158 "test{l}\t{$src, %eax|%eax, $src}", []>;
3159
Evan Chengb783fa32007-07-19 01:14:50 +00003160def TEST8rm : I<0x84, MRMSrcMem, (outs), (ins GR8 :$src1, i8mem :$src2),
Evan Cheng621216e2007-09-29 00:00:36 +00003161 "test{b}\t{$src2, $src1|$src1, $src2}",
3162 [(X86cmp (and GR8:$src1, (loadi8 addr:$src2)), 0),
3163 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00003164def TEST16rm : I<0x85, MRMSrcMem, (outs), (ins GR16:$src1, i16mem:$src2),
Evan Cheng621216e2007-09-29 00:00:36 +00003165 "test{w}\t{$src2, $src1|$src1, $src2}",
3166 [(X86cmp (and GR16:$src1, (loadi16 addr:$src2)), 0),
3167 (implicit EFLAGS)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00003168def TEST32rm : I<0x85, MRMSrcMem, (outs), (ins GR32:$src1, i32mem:$src2),
Evan Cheng621216e2007-09-29 00:00:36 +00003169 "test{l}\t{$src2, $src1|$src1, $src2}",
3170 [(X86cmp (and GR32:$src1, (loadi32 addr:$src2)), 0),
3171 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003172
3173def TEST8ri : Ii8 <0xF6, MRM0r, // flags = GR8 & imm8
Evan Chengb783fa32007-07-19 01:14:50 +00003174 (outs), (ins GR8:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00003175 "test{b}\t{$src2, $src1|$src1, $src2}",
Chris Lattner21da6382008-02-19 17:37:35 +00003176 [(X86cmp (and_su GR8:$src1, imm:$src2), 0),
Evan Cheng621216e2007-09-29 00:00:36 +00003177 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003178def TEST16ri : Ii16<0xF7, MRM0r, // flags = GR16 & imm16
Evan Chengb783fa32007-07-19 01:14:50 +00003179 (outs), (ins GR16:$src1, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00003180 "test{w}\t{$src2, $src1|$src1, $src2}",
Chris Lattner21da6382008-02-19 17:37:35 +00003181 [(X86cmp (and_su GR16:$src1, imm:$src2), 0),
Evan Cheng621216e2007-09-29 00:00:36 +00003182 (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003183def TEST32ri : Ii32<0xF7, MRM0r, // flags = GR32 & imm32
Evan Chengb783fa32007-07-19 01:14:50 +00003184 (outs), (ins GR32:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00003185 "test{l}\t{$src2, $src1|$src1, $src2}",
Chris Lattner21da6382008-02-19 17:37:35 +00003186 [(X86cmp (and_su GR32:$src1, imm:$src2), 0),
Evan Cheng621216e2007-09-29 00:00:36 +00003187 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003188
Evan Cheng621216e2007-09-29 00:00:36 +00003189def TEST8mi : Ii8 <0xF6, MRM0m, // flags = [mem8] & imm8
Evan Chengb783fa32007-07-19 01:14:50 +00003190 (outs), (ins i8mem:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00003191 "test{b}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00003192 [(X86cmp (and (loadi8 addr:$src1), imm:$src2), 0),
3193 (implicit EFLAGS)]>;
3194def TEST16mi : Ii16<0xF7, MRM0m, // flags = [mem16] & imm16
Evan Chengb783fa32007-07-19 01:14:50 +00003195 (outs), (ins i16mem:$src1, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00003196 "test{w}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00003197 [(X86cmp (and (loadi16 addr:$src1), imm:$src2), 0),
3198 (implicit EFLAGS)]>, OpSize;
3199def TEST32mi : Ii32<0xF7, MRM0m, // flags = [mem32] & imm32
Evan Chengb783fa32007-07-19 01:14:50 +00003200 (outs), (ins i32mem:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00003201 "test{l}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00003202 [(X86cmp (and (loadi32 addr:$src1), imm:$src2), 0),
Evan Cheng950aac02007-09-25 01:57:46 +00003203 (implicit EFLAGS)]>;
3204} // Defs = [EFLAGS]
3205
3206
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003207// Condition code ops, incl. set if equal/not equal/...
Chris Lattnerc90ee9c2008-01-10 07:59:24 +00003208let Defs = [EFLAGS], Uses = [AH], neverHasSideEffects = 1 in
Evan Cheng6e4d1d92007-09-11 19:55:27 +00003209def SAHF : I<0x9E, RawFrm, (outs), (ins), "sahf", []>; // flags = AH
Chris Lattnerc90ee9c2008-01-10 07:59:24 +00003210let Defs = [AH], Uses = [EFLAGS], neverHasSideEffects = 1 in
Evan Cheng6e4d1d92007-09-11 19:55:27 +00003211def LAHF : I<0x9F, RawFrm, (outs), (ins), "lahf", []>; // AH = flags
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003212
Evan Cheng950aac02007-09-25 01:57:46 +00003213let Uses = [EFLAGS] in {
Evan Cheng834ae6b2009-12-15 00:53:42 +00003214// Use sbb to materialize carry bit.
3215
3216let Defs = [EFLAGS], isCodeGenOnly = 1 in {
3217def SETB_C8r : I<0x18, MRMInitReg, (outs GR8:$dst), (ins),
3218 "sbb{b}\t$dst, $dst",
3219 [(set GR8:$dst, (X86setcc_c X86_COND_B, EFLAGS))]>;
3220def SETB_C16r : I<0x19, MRMInitReg, (outs GR16:$dst), (ins),
3221 "sbb{w}\t$dst, $dst",
Evan Chengedeb1692009-12-16 00:53:11 +00003222 [(set GR16:$dst, (X86setcc_c X86_COND_B, EFLAGS))]>,
Evan Cheng834ae6b2009-12-15 00:53:42 +00003223 OpSize;
3224def SETB_C32r : I<0x19, MRMInitReg, (outs GR32:$dst), (ins),
3225 "sbb{l}\t$dst, $dst",
Evan Chengedeb1692009-12-16 00:53:11 +00003226 [(set GR32:$dst, (X86setcc_c X86_COND_B, EFLAGS))]>;
Evan Cheng834ae6b2009-12-15 00:53:42 +00003227} // isCodeGenOnly
3228
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003229def SETEr : I<0x94, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00003230 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00003231 "sete\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00003232 [(set GR8:$dst, (X86setcc X86_COND_E, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003233 TB; // GR8 = ==
3234def SETEm : I<0x94, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00003235 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00003236 "sete\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00003237 [(store (X86setcc X86_COND_E, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003238 TB; // [mem8] = ==
Bill Wendling0c52d0a2008-12-02 00:07:05 +00003239
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003240def SETNEr : I<0x95, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00003241 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00003242 "setne\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00003243 [(set GR8:$dst, (X86setcc X86_COND_NE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003244 TB; // GR8 = !=
3245def SETNEm : I<0x95, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00003246 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00003247 "setne\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00003248 [(store (X86setcc X86_COND_NE, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003249 TB; // [mem8] = !=
Bill Wendling0c52d0a2008-12-02 00:07:05 +00003250
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003251def SETLr : I<0x9C, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00003252 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00003253 "setl\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00003254 [(set GR8:$dst, (X86setcc X86_COND_L, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003255 TB; // GR8 = < signed
3256def SETLm : I<0x9C, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00003257 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00003258 "setl\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00003259 [(store (X86setcc X86_COND_L, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003260 TB; // [mem8] = < signed
Bill Wendling0c52d0a2008-12-02 00:07:05 +00003261
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003262def SETGEr : I<0x9D, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00003263 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00003264 "setge\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00003265 [(set GR8:$dst, (X86setcc X86_COND_GE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003266 TB; // GR8 = >= signed
3267def SETGEm : I<0x9D, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00003268 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00003269 "setge\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00003270 [(store (X86setcc X86_COND_GE, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003271 TB; // [mem8] = >= signed
Bill Wendling0c52d0a2008-12-02 00:07:05 +00003272
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003273def SETLEr : I<0x9E, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00003274 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00003275 "setle\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00003276 [(set GR8:$dst, (X86setcc X86_COND_LE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003277 TB; // GR8 = <= signed
3278def SETLEm : I<0x9E, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00003279 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00003280 "setle\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00003281 [(store (X86setcc X86_COND_LE, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003282 TB; // [mem8] = <= signed
Bill Wendling0c52d0a2008-12-02 00:07:05 +00003283
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003284def SETGr : I<0x9F, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00003285 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00003286 "setg\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00003287 [(set GR8:$dst, (X86setcc X86_COND_G, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003288 TB; // GR8 = > signed
3289def SETGm : I<0x9F, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00003290 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00003291 "setg\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00003292 [(store (X86setcc X86_COND_G, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003293 TB; // [mem8] = > signed
3294
3295def SETBr : I<0x92, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00003296 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00003297 "setb\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00003298 [(set GR8:$dst, (X86setcc X86_COND_B, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003299 TB; // GR8 = < unsign
3300def SETBm : I<0x92, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00003301 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00003302 "setb\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00003303 [(store (X86setcc X86_COND_B, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003304 TB; // [mem8] = < unsign
Bill Wendling0c52d0a2008-12-02 00:07:05 +00003305
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003306def SETAEr : I<0x93, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00003307 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00003308 "setae\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00003309 [(set GR8:$dst, (X86setcc X86_COND_AE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003310 TB; // GR8 = >= unsign
3311def SETAEm : I<0x93, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00003312 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00003313 "setae\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00003314 [(store (X86setcc X86_COND_AE, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003315 TB; // [mem8] = >= unsign
Bill Wendling0c52d0a2008-12-02 00:07:05 +00003316
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003317def SETBEr : I<0x96, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00003318 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00003319 "setbe\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00003320 [(set GR8:$dst, (X86setcc X86_COND_BE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003321 TB; // GR8 = <= unsign
3322def SETBEm : I<0x96, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00003323 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00003324 "setbe\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00003325 [(store (X86setcc X86_COND_BE, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003326 TB; // [mem8] = <= unsign
Bill Wendling0c52d0a2008-12-02 00:07:05 +00003327
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003328def SETAr : I<0x97, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00003329 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00003330 "seta\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00003331 [(set GR8:$dst, (X86setcc X86_COND_A, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003332 TB; // GR8 = > signed
3333def SETAm : I<0x97, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00003334 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00003335 "seta\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00003336 [(store (X86setcc X86_COND_A, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003337 TB; // [mem8] = > signed
3338
3339def SETSr : I<0x98, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00003340 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00003341 "sets\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00003342 [(set GR8:$dst, (X86setcc X86_COND_S, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003343 TB; // GR8 = <sign bit>
3344def SETSm : I<0x98, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00003345 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00003346 "sets\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00003347 [(store (X86setcc X86_COND_S, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003348 TB; // [mem8] = <sign bit>
3349def SETNSr : I<0x99, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00003350 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00003351 "setns\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00003352 [(set GR8:$dst, (X86setcc X86_COND_NS, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003353 TB; // GR8 = !<sign bit>
3354def SETNSm : I<0x99, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00003355 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00003356 "setns\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00003357 [(store (X86setcc X86_COND_NS, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003358 TB; // [mem8] = !<sign bit>
Bill Wendling0c52d0a2008-12-02 00:07:05 +00003359
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003360def SETPr : I<0x9A, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00003361 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00003362 "setp\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00003363 [(set GR8:$dst, (X86setcc X86_COND_P, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003364 TB; // GR8 = parity
3365def SETPm : I<0x9A, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00003366 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00003367 "setp\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00003368 [(store (X86setcc X86_COND_P, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003369 TB; // [mem8] = parity
3370def SETNPr : I<0x9B, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00003371 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00003372 "setnp\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00003373 [(set GR8:$dst, (X86setcc X86_COND_NP, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003374 TB; // GR8 = not parity
3375def SETNPm : I<0x9B, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00003376 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00003377 "setnp\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00003378 [(store (X86setcc X86_COND_NP, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003379 TB; // [mem8] = not parity
Bill Wendling0c52d0a2008-12-02 00:07:05 +00003380
3381def SETOr : I<0x90, MRM0r,
3382 (outs GR8 :$dst), (ins),
3383 "seto\t$dst",
3384 [(set GR8:$dst, (X86setcc X86_COND_O, EFLAGS))]>,
3385 TB; // GR8 = overflow
3386def SETOm : I<0x90, MRM0m,
3387 (outs), (ins i8mem:$dst),
3388 "seto\t$dst",
3389 [(store (X86setcc X86_COND_O, EFLAGS), addr:$dst)]>,
3390 TB; // [mem8] = overflow
3391def SETNOr : I<0x91, MRM0r,
3392 (outs GR8 :$dst), (ins),
3393 "setno\t$dst",
3394 [(set GR8:$dst, (X86setcc X86_COND_NO, EFLAGS))]>,
3395 TB; // GR8 = not overflow
3396def SETNOm : I<0x91, MRM0m,
3397 (outs), (ins i8mem:$dst),
3398 "setno\t$dst",
3399 [(store (X86setcc X86_COND_NO, EFLAGS), addr:$dst)]>,
3400 TB; // [mem8] = not overflow
Evan Cheng950aac02007-09-25 01:57:46 +00003401} // Uses = [EFLAGS]
3402
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003403
3404// Integer comparisons
Evan Cheng55687072007-09-14 21:48:26 +00003405let Defs = [EFLAGS] in {
Sean Callanan251676e2009-09-02 00:55:49 +00003406def CMP8i8 : Ii8<0x3C, RawFrm, (outs), (ins i8imm:$src),
3407 "cmp{b}\t{$src, %al|%al, $src}", []>;
3408def CMP16i16 : Ii16<0x3D, RawFrm, (outs), (ins i16imm:$src),
3409 "cmp{w}\t{$src, %ax|%ax, $src}", []>, OpSize;
3410def CMP32i32 : Ii32<0x3D, RawFrm, (outs), (ins i32imm:$src),
3411 "cmp{l}\t{$src, %eax|%eax, $src}", []>;
3412
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003413def CMP8rr : I<0x38, MRMDestReg,
Evan Chengb783fa32007-07-19 01:14:50 +00003414 (outs), (ins GR8 :$src1, GR8 :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00003415 "cmp{b}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00003416 [(X86cmp GR8:$src1, GR8:$src2), (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003417def CMP16rr : I<0x39, MRMDestReg,
Evan Chengb783fa32007-07-19 01:14:50 +00003418 (outs), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00003419 "cmp{w}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00003420 [(X86cmp GR16:$src1, GR16:$src2), (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003421def CMP32rr : I<0x39, MRMDestReg,
Evan Chengb783fa32007-07-19 01:14:50 +00003422 (outs), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00003423 "cmp{l}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00003424 [(X86cmp GR32:$src1, GR32:$src2), (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003425def CMP8mr : I<0x38, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00003426 (outs), (ins i8mem :$src1, GR8 :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00003427 "cmp{b}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00003428 [(X86cmp (loadi8 addr:$src1), GR8:$src2),
3429 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003430def CMP16mr : I<0x39, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00003431 (outs), (ins i16mem:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00003432 "cmp{w}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00003433 [(X86cmp (loadi16 addr:$src1), GR16:$src2),
3434 (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003435def CMP32mr : I<0x39, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00003436 (outs), (ins i32mem:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00003437 "cmp{l}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00003438 [(X86cmp (loadi32 addr:$src1), GR32:$src2),
3439 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003440def CMP8rm : I<0x3A, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00003441 (outs), (ins GR8 :$src1, i8mem :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00003442 "cmp{b}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00003443 [(X86cmp GR8:$src1, (loadi8 addr:$src2)),
3444 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003445def CMP16rm : I<0x3B, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00003446 (outs), (ins GR16:$src1, i16mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00003447 "cmp{w}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00003448 [(X86cmp GR16:$src1, (loadi16 addr:$src2)),
3449 (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003450def CMP32rm : I<0x3B, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00003451 (outs), (ins GR32:$src1, i32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00003452 "cmp{l}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00003453 [(X86cmp GR32:$src1, (loadi32 addr:$src2)),
3454 (implicit EFLAGS)]>;
Sean Callanan11490dc2009-09-16 21:11:23 +00003455def CMP8mrmrr : I<0x3A, MRMSrcReg, (outs), (ins GR8:$src1, GR8:$src2),
3456 "cmp{b}\t{$src2, $src1|$src1, $src2}", []>;
3457def CMP16mrmrr : I<0x3B, MRMSrcReg, (outs), (ins GR16:$src1, GR16:$src2),
3458 "cmp{w}\t{$src2, $src1|$src1, $src2}", []>, OpSize;
3459def CMP32mrmrr : I<0x3B, MRMSrcReg, (outs), (ins GR32:$src1, GR32:$src2),
3460 "cmp{l}\t{$src2, $src1|$src1, $src2}", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003461def CMP8ri : Ii8<0x80, MRM7r,
Evan Chengb783fa32007-07-19 01:14:50 +00003462 (outs), (ins GR8:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00003463 "cmp{b}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00003464 [(X86cmp GR8:$src1, imm:$src2), (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003465def CMP16ri : Ii16<0x81, MRM7r,
Evan Chengb783fa32007-07-19 01:14:50 +00003466 (outs), (ins GR16:$src1, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00003467 "cmp{w}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00003468 [(X86cmp GR16:$src1, imm:$src2),
3469 (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003470def CMP32ri : Ii32<0x81, MRM7r,
Evan Chengb783fa32007-07-19 01:14:50 +00003471 (outs), (ins GR32:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00003472 "cmp{l}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00003473 [(X86cmp GR32:$src1, imm:$src2), (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003474def CMP8mi : Ii8 <0x80, MRM7m,
Evan Chengb783fa32007-07-19 01:14:50 +00003475 (outs), (ins i8mem :$src1, i8imm :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00003476 "cmp{b}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00003477 [(X86cmp (loadi8 addr:$src1), imm:$src2),
3478 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003479def CMP16mi : Ii16<0x81, MRM7m,
Evan Chengb783fa32007-07-19 01:14:50 +00003480 (outs), (ins i16mem:$src1, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00003481 "cmp{w}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00003482 [(X86cmp (loadi16 addr:$src1), imm:$src2),
3483 (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003484def CMP32mi : Ii32<0x81, MRM7m,
Evan Chengb783fa32007-07-19 01:14:50 +00003485 (outs), (ins i32mem:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00003486 "cmp{l}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00003487 [(X86cmp (loadi32 addr:$src1), imm:$src2),
3488 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003489def CMP16ri8 : Ii8<0x83, MRM7r,
Evan Chengb783fa32007-07-19 01:14:50 +00003490 (outs), (ins GR16:$src1, i16i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00003491 "cmp{w}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00003492 [(X86cmp GR16:$src1, i16immSExt8:$src2),
3493 (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003494def CMP16mi8 : Ii8<0x83, MRM7m,
Evan Chengb783fa32007-07-19 01:14:50 +00003495 (outs), (ins i16mem:$src1, i16i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00003496 "cmp{w}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00003497 [(X86cmp (loadi16 addr:$src1), i16immSExt8:$src2),
3498 (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003499def CMP32mi8 : Ii8<0x83, MRM7m,
Evan Chengb783fa32007-07-19 01:14:50 +00003500 (outs), (ins i32mem:$src1, i32i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00003501 "cmp{l}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00003502 [(X86cmp (loadi32 addr:$src1), i32immSExt8:$src2),
3503 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003504def CMP32ri8 : Ii8<0x83, MRM7r,
Evan Chengb783fa32007-07-19 01:14:50 +00003505 (outs), (ins GR32:$src1, i32i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00003506 "cmp{l}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00003507 [(X86cmp GR32:$src1, i32immSExt8:$src2),
Evan Cheng950aac02007-09-25 01:57:46 +00003508 (implicit EFLAGS)]>;
3509} // Defs = [EFLAGS]
3510
Dan Gohman7fe9b7f2008-12-23 22:45:23 +00003511// Bit tests.
Dan Gohman7fe9b7f2008-12-23 22:45:23 +00003512// TODO: BTC, BTR, and BTS
3513let Defs = [EFLAGS] in {
Dan Gohmanfc4eddb2009-01-13 20:32:45 +00003514def BT16rr : I<0xA3, MRMDestReg, (outs), (ins GR16:$src1, GR16:$src2),
Dan Gohman7fe9b7f2008-12-23 22:45:23 +00003515 "bt{w}\t{$src2, $src1|$src1, $src2}",
3516 [(X86bt GR16:$src1, GR16:$src2),
Chris Lattner5a95cde2008-12-25 01:32:49 +00003517 (implicit EFLAGS)]>, OpSize, TB;
Dan Gohmanfc4eddb2009-01-13 20:32:45 +00003518def BT32rr : I<0xA3, MRMDestReg, (outs), (ins GR32:$src1, GR32:$src2),
Dan Gohman7fe9b7f2008-12-23 22:45:23 +00003519 "bt{l}\t{$src2, $src1|$src1, $src2}",
3520 [(X86bt GR32:$src1, GR32:$src2),
Chris Lattner5a95cde2008-12-25 01:32:49 +00003521 (implicit EFLAGS)]>, TB;
Dan Gohman85a228c2009-01-13 23:23:30 +00003522
3523// Unlike with the register+register form, the memory+register form of the
3524// bt instruction does not ignore the high bits of the index. From ISel's
Sean Callanan2c48df22009-12-18 00:01:26 +00003525// perspective, this is pretty bizarre. Make these instructions disassembly
3526// only for now.
3527
3528def BT16mr : I<0xA3, MRMDestMem, (outs), (ins i16mem:$src1, GR16:$src2),
3529 "bt{w}\t{$src2, $src1|$src1, $src2}",
Dan Gohman85a228c2009-01-13 23:23:30 +00003530// [(X86bt (loadi16 addr:$src1), GR16:$src2),
Sean Callanan2c48df22009-12-18 00:01:26 +00003531// (implicit EFLAGS)]
3532 []
3533 >, OpSize, TB, Requires<[FastBTMem]>;
3534def BT32mr : I<0xA3, MRMDestMem, (outs), (ins i32mem:$src1, GR32:$src2),
3535 "bt{l}\t{$src2, $src1|$src1, $src2}",
Dan Gohman85a228c2009-01-13 23:23:30 +00003536// [(X86bt (loadi32 addr:$src1), GR32:$src2),
Sean Callanan2c48df22009-12-18 00:01:26 +00003537// (implicit EFLAGS)]
3538 []
3539 >, TB, Requires<[FastBTMem]>;
Dan Gohman46fb1cf2009-01-13 20:33:23 +00003540
3541def BT16ri8 : Ii8<0xBA, MRM4r, (outs), (ins GR16:$src1, i16i8imm:$src2),
3542 "bt{w}\t{$src2, $src1|$src1, $src2}",
3543 [(X86bt GR16:$src1, i16immSExt8:$src2),
3544 (implicit EFLAGS)]>, OpSize, TB;
3545def BT32ri8 : Ii8<0xBA, MRM4r, (outs), (ins GR32:$src1, i32i8imm:$src2),
3546 "bt{l}\t{$src2, $src1|$src1, $src2}",
3547 [(X86bt GR32:$src1, i32immSExt8:$src2),
3548 (implicit EFLAGS)]>, TB;
3549// Note that these instructions don't need FastBTMem because that
3550// only applies when the other operand is in a register. When it's
3551// an immediate, bt is still fast.
3552def BT16mi8 : Ii8<0xBA, MRM4m, (outs), (ins i16mem:$src1, i16i8imm:$src2),
3553 "bt{w}\t{$src2, $src1|$src1, $src2}",
3554 [(X86bt (loadi16 addr:$src1), i16immSExt8:$src2),
3555 (implicit EFLAGS)]>, OpSize, TB;
3556def BT32mi8 : Ii8<0xBA, MRM4m, (outs), (ins i32mem:$src1, i32i8imm:$src2),
3557 "bt{l}\t{$src2, $src1|$src1, $src2}",
3558 [(X86bt (loadi32 addr:$src1), i32immSExt8:$src2),
3559 (implicit EFLAGS)]>, TB;
Sean Callanan2c48df22009-12-18 00:01:26 +00003560
3561def BTC16rr : I<0xBB, MRMDestReg, (outs), (ins GR16:$src1, GR16:$src2),
3562 "btc{w}\t{$src2, $src1|$src1, $src2}", []>, OpSize, TB;
3563def BTC32rr : I<0xBB, MRMDestReg, (outs), (ins GR32:$src1, GR32:$src2),
3564 "btc{l}\t{$src2, $src1|$src1, $src2}", []>, TB;
3565def BTC16mr : I<0xBB, MRMDestMem, (outs), (ins i16mem:$src1, GR16:$src2),
3566 "btc{w}\t{$src2, $src1|$src1, $src2}", []>, OpSize, TB;
3567def BTC32mr : I<0xBB, MRMDestMem, (outs), (ins i32mem:$src1, GR32:$src2),
3568 "btc{l}\t{$src2, $src1|$src1, $src2}", []>, TB;
3569def BTC16ri8 : Ii8<0xBA, MRM7r, (outs), (ins GR16:$src1, i16i8imm:$src2),
3570 "btc{w}\t{$src2, $src1|$src1, $src2}", []>, OpSize, TB;
3571def BTC32ri8 : Ii8<0xBA, MRM7r, (outs), (ins GR32:$src1, i32i8imm:$src2),
3572 "btc{l}\t{$src2, $src1|$src1, $src2}", []>, TB;
3573def BTC16mi8 : Ii8<0xBA, MRM7m, (outs), (ins i16mem:$src1, i16i8imm:$src2),
3574 "btc{w}\t{$src2, $src1|$src1, $src2}", []>, OpSize, TB;
3575def BTC32mi8 : Ii8<0xBA, MRM7m, (outs), (ins i32mem:$src1, i32i8imm:$src2),
3576 "btc{l}\t{$src2, $src1|$src1, $src2}", []>, TB;
3577
3578def BTR16rr : I<0xB3, MRMDestReg, (outs), (ins GR16:$src1, GR16:$src2),
3579 "btr{w}\t{$src2, $src1|$src1, $src2}", []>, OpSize, TB;
3580def BTR32rr : I<0xB3, MRMDestReg, (outs), (ins GR32:$src1, GR32:$src2),
3581 "btr{l}\t{$src2, $src1|$src1, $src2}", []>, TB;
3582def BTR16mr : I<0xB3, MRMDestMem, (outs), (ins i16mem:$src1, GR16:$src2),
3583 "btr{w}\t{$src2, $src1|$src1, $src2}", []>, OpSize, TB;
3584def BTR32mr : I<0xB3, MRMDestMem, (outs), (ins i32mem:$src1, GR32:$src2),
3585 "btr{l}\t{$src2, $src1|$src1, $src2}", []>, TB;
3586def BTR16ri8 : Ii8<0xBA, MRM6r, (outs), (ins GR16:$src1, i16i8imm:$src2),
3587 "btr{w}\t{$src2, $src1|$src1, $src2}", []>, OpSize, TB;
3588def BTR32ri8 : Ii8<0xBA, MRM6r, (outs), (ins GR32:$src1, i32i8imm:$src2),
3589 "btr{l}\t{$src2, $src1|$src1, $src2}", []>, TB;
3590def BTR16mi8 : Ii8<0xBA, MRM6m, (outs), (ins i16mem:$src1, i16i8imm:$src2),
3591 "btr{w}\t{$src2, $src1|$src1, $src2}", []>, OpSize, TB;
3592def BTR32mi8 : Ii8<0xBA, MRM6m, (outs), (ins i32mem:$src1, i32i8imm:$src2),
3593 "btr{l}\t{$src2, $src1|$src1, $src2}", []>, TB;
3594
3595def BTS16rr : I<0xAB, MRMDestReg, (outs), (ins GR16:$src1, GR16:$src2),
3596 "bts{w}\t{$src2, $src1|$src1, $src2}", []>, OpSize, TB;
3597def BTS32rr : I<0xAB, MRMDestReg, (outs), (ins GR32:$src1, GR32:$src2),
3598 "bts{l}\t{$src2, $src1|$src1, $src2}", []>, TB;
3599def BTS16mr : I<0xAB, MRMDestMem, (outs), (ins i16mem:$src1, GR16:$src2),
3600 "bts{w}\t{$src2, $src1|$src1, $src2}", []>, OpSize, TB;
3601def BTS32mr : I<0xAB, MRMDestMem, (outs), (ins i32mem:$src1, GR32:$src2),
3602 "bts{l}\t{$src2, $src1|$src1, $src2}", []>, TB;
3603def BTS16ri8 : Ii8<0xBA, MRM5r, (outs), (ins GR16:$src1, i16i8imm:$src2),
3604 "bts{w}\t{$src2, $src1|$src1, $src2}", []>, OpSize, TB;
3605def BTS32ri8 : Ii8<0xBA, MRM5r, (outs), (ins GR32:$src1, i32i8imm:$src2),
3606 "bts{l}\t{$src2, $src1|$src1, $src2}", []>, TB;
3607def BTS16mi8 : Ii8<0xBA, MRM5m, (outs), (ins i16mem:$src1, i16i8imm:$src2),
3608 "bts{w}\t{$src2, $src1|$src1, $src2}", []>, OpSize, TB;
3609def BTS32mi8 : Ii8<0xBA, MRM5m, (outs), (ins i32mem:$src1, i32i8imm:$src2),
3610 "bts{l}\t{$src2, $src1|$src1, $src2}", []>, TB;
Dan Gohman7fe9b7f2008-12-23 22:45:23 +00003611} // Defs = [EFLAGS]
3612
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003613// Sign/Zero extenders
Dan Gohman9203ab42008-07-30 18:09:17 +00003614// Use movsbl intead of movsbw; we don't care about the high 16 bits
3615// of the register here. This has a smaller encoding and avoids a
Sean Callanan2c48df22009-12-18 00:01:26 +00003616// partial-register update. Actual movsbw included for the disassembler.
3617def MOVSX16rr8W : I<0xBE, MRMSrcReg, (outs GR16:$dst), (ins GR8:$src),
3618 "movs{bw|x}\t{$src, $dst|$dst, $src}", []>, TB, OpSize;
3619def MOVSX16rm8W : I<0xBE, MRMSrcMem, (outs GR16:$dst), (ins i8mem:$src),
3620 "movs{bw|x}\t{$src, $dst|$dst, $src}", []>, TB, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00003621def MOVSX16rr8 : I<0xBE, MRMSrcReg, (outs GR16:$dst), (ins GR8 :$src),
Chris Lattnerbe7efcc2009-10-19 19:51:42 +00003622 "", [(set GR16:$dst, (sext GR8:$src))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00003623def MOVSX16rm8 : I<0xBE, MRMSrcMem, (outs GR16:$dst), (ins i8mem :$src),
Chris Lattnerbe7efcc2009-10-19 19:51:42 +00003624 "", [(set GR16:$dst, (sextloadi16i8 addr:$src))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00003625def MOVSX32rr8 : I<0xBE, MRMSrcReg, (outs GR32:$dst), (ins GR8 :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00003626 "movs{bl|x}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003627 [(set GR32:$dst, (sext GR8:$src))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00003628def MOVSX32rm8 : I<0xBE, MRMSrcMem, (outs GR32:$dst), (ins i8mem :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00003629 "movs{bl|x}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003630 [(set GR32:$dst, (sextloadi32i8 addr:$src))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00003631def MOVSX32rr16: I<0xBF, MRMSrcReg, (outs GR32:$dst), (ins GR16:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00003632 "movs{wl|x}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003633 [(set GR32:$dst, (sext GR16:$src))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00003634def MOVSX32rm16: I<0xBF, MRMSrcMem, (outs GR32:$dst), (ins i16mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00003635 "movs{wl|x}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003636 [(set GR32:$dst, (sextloadi32i16 addr:$src))]>, TB;
3637
Dan Gohman9203ab42008-07-30 18:09:17 +00003638// Use movzbl intead of movzbw; we don't care about the high 16 bits
3639// of the register here. This has a smaller encoding and avoids a
Sean Callanan2c48df22009-12-18 00:01:26 +00003640// partial-register update. Actual movzbw included for the disassembler.
3641def MOVZX16rr8W : I<0xB6, MRMSrcReg, (outs GR16:$dst), (ins GR8:$src),
3642 "movz{bw|x}\t{$src, $dst|$dst, $src}", []>, TB, OpSize;
3643def MOVZX16rm8W : I<0xB6, MRMSrcMem, (outs GR16:$dst), (ins i8mem:$src),
3644 "movz{bw|x}\t{$src, $dst|$dst, $src}", []>, TB, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00003645def MOVZX16rr8 : I<0xB6, MRMSrcReg, (outs GR16:$dst), (ins GR8 :$src),
Chris Lattnerbe7efcc2009-10-19 19:51:42 +00003646 "", [(set GR16:$dst, (zext GR8:$src))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00003647def MOVZX16rm8 : I<0xB6, MRMSrcMem, (outs GR16:$dst), (ins i8mem :$src),
Chris Lattnerbe7efcc2009-10-19 19:51:42 +00003648 "", [(set GR16:$dst, (zextloadi16i8 addr:$src))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00003649def MOVZX32rr8 : I<0xB6, MRMSrcReg, (outs GR32:$dst), (ins GR8 :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00003650 "movz{bl|x}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003651 [(set GR32:$dst, (zext GR8:$src))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00003652def MOVZX32rm8 : I<0xB6, MRMSrcMem, (outs GR32:$dst), (ins i8mem :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00003653 "movz{bl|x}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003654 [(set GR32:$dst, (zextloadi32i8 addr:$src))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00003655def MOVZX32rr16: I<0xB7, MRMSrcReg, (outs GR32:$dst), (ins GR16:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00003656 "movz{wl|x}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003657 [(set GR32:$dst, (zext GR16:$src))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00003658def MOVZX32rm16: I<0xB7, MRMSrcMem, (outs GR32:$dst), (ins i16mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00003659 "movz{wl|x}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003660 [(set GR32:$dst, (zextloadi32i16 addr:$src))]>, TB;
3661
Dan Gohman744d4622009-04-13 16:09:41 +00003662// These are the same as the regular regular MOVZX32rr8 and MOVZX32rm8
3663// except that they use GR32_NOREX for the output operand register class
3664// instead of GR32. This allows them to operate on h registers on x86-64.
3665def MOVZX32_NOREXrr8 : I<0xB6, MRMSrcReg,
3666 (outs GR32_NOREX:$dst), (ins GR8:$src),
3667 "movz{bl|x}\t{$src, $dst|$dst, $src} # NOREX",
3668 []>, TB;
Dan Gohman89f4cda2009-04-30 03:11:48 +00003669let mayLoad = 1 in
Dan Gohman744d4622009-04-13 16:09:41 +00003670def MOVZX32_NOREXrm8 : I<0xB6, MRMSrcMem,
3671 (outs GR32_NOREX:$dst), (ins i8mem:$src),
3672 "movz{bl|x}\t{$src, $dst|$dst, $src} # NOREX",
3673 []>, TB;
3674
Chris Lattnerc90ee9c2008-01-10 07:59:24 +00003675let neverHasSideEffects = 1 in {
3676 let Defs = [AX], Uses = [AL] in
3677 def CBW : I<0x98, RawFrm, (outs), (ins),
3678 "{cbtw|cbw}", []>, OpSize; // AX = signext(AL)
3679 let Defs = [EAX], Uses = [AX] in
3680 def CWDE : I<0x98, RawFrm, (outs), (ins),
3681 "{cwtl|cwde}", []>; // EAX = signext(AX)
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003682
Chris Lattnerc90ee9c2008-01-10 07:59:24 +00003683 let Defs = [AX,DX], Uses = [AX] in
3684 def CWD : I<0x99, RawFrm, (outs), (ins),
3685 "{cwtd|cwd}", []>, OpSize; // DX:AX = signext(AX)
3686 let Defs = [EAX,EDX], Uses = [EAX] in
3687 def CDQ : I<0x99, RawFrm, (outs), (ins),
3688 "{cltd|cdq}", []>; // EDX:EAX = signext(EAX)
3689}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003690
3691//===----------------------------------------------------------------------===//
3692// Alias Instructions
3693//===----------------------------------------------------------------------===//
3694
3695// Alias instructions that map movr0 to xor.
3696// FIXME: remove when we can teach regalloc that xor reg, reg is ok.
Daniel Dunbara0e62002009-08-11 22:17:52 +00003697let Defs = [EFLAGS], isReMaterializable = 1, isAsCheapAsAMove = 1,
3698 isCodeGenOnly = 1 in {
Evan Chengb783fa32007-07-19 01:14:50 +00003699def MOV8r0 : I<0x30, MRMInitReg, (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00003700 "xor{b}\t$dst, $dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003701 [(set GR8:$dst, 0)]>;
Dan Gohman9203ab42008-07-30 18:09:17 +00003702// Use xorl instead of xorw since we don't care about the high 16 bits,
3703// it's smaller, and it avoids a partial-register update.
Chris Lattnerbe7efcc2009-10-19 19:51:42 +00003704def MOV16r0 : I<0x31, MRMInitReg, (outs GR16:$dst), (ins),
3705 "", [(set GR16:$dst, 0)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00003706def MOV32r0 : I<0x31, MRMInitReg, (outs GR32:$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00003707 "xor{l}\t$dst, $dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003708 [(set GR32:$dst, 0)]>;
Dan Gohman8aef09b2007-09-07 21:32:51 +00003709}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003710
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003711//===----------------------------------------------------------------------===//
3712// Thread Local Storage Instructions
3713//
3714
Rafael Espindola7fc4b8d2009-04-24 12:59:40 +00003715// All calls clobber the non-callee saved registers. ESP is marked as
3716// a use to prevent stack-pointer assignments that appear immediately
3717// before calls from potentially appearing dead.
3718let Defs = [EAX, ECX, EDX, FP0, FP1, FP2, FP3, FP4, FP5, FP6, ST0,
3719 MM0, MM1, MM2, MM3, MM4, MM5, MM6, MM7,
3720 XMM0, XMM1, XMM2, XMM3, XMM4, XMM5, XMM6, XMM7,
3721 XMM8, XMM9, XMM10, XMM11, XMM12, XMM13, XMM14, XMM15, EFLAGS],
Chris Lattnerf1940742009-06-20 20:38:48 +00003722 Uses = [ESP] in
3723def TLS_addr32 : I<0, Pseudo, (outs), (ins lea32mem:$sym),
3724 "leal\t$sym, %eax; "
Dan Gohman70a8a112009-04-27 15:13:28 +00003725 "call\t___tls_get_addr@PLT",
Chris Lattnerf1940742009-06-20 20:38:48 +00003726 [(X86tlsaddr tls32addr:$sym)]>,
Rafael Espindolaaf759ab2009-04-17 14:35:58 +00003727 Requires<[In32BitMode]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003728
Daniel Dunbar75a07302009-08-11 22:24:40 +00003729let AddedComplexity = 5, isCodeGenOnly = 1 in
sampo9cc09a32009-01-26 01:24:32 +00003730def GS_MOV32rm : I<0x8B, MRMSrcMem, (outs GR32:$dst), (ins i32mem:$src),
3731 "movl\t%gs:$src, $dst",
3732 [(set GR32:$dst, (gsload addr:$src))]>, SegGS;
3733
Daniel Dunbar75a07302009-08-11 22:24:40 +00003734let AddedComplexity = 5, isCodeGenOnly = 1 in
Chris Lattnera7c2d8a2009-05-05 18:52:19 +00003735def FS_MOV32rm : I<0x8B, MRMSrcMem, (outs GR32:$dst), (ins i32mem:$src),
3736 "movl\t%fs:$src, $dst",
3737 [(set GR32:$dst, (fsload addr:$src))]>, SegFS;
3738
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003739//===----------------------------------------------------------------------===//
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003740// EH Pseudo Instructions
3741//
3742let isTerminator = 1, isReturn = 1, isBarrier = 1,
Daniel Dunbar75513bd2009-08-27 07:58:05 +00003743 hasCtrlDep = 1, isCodeGenOnly = 1 in {
Evan Chengb783fa32007-07-19 01:14:50 +00003744def EH_RETURN : I<0xC3, RawFrm, (outs), (ins GR32:$addr),
Dan Gohman91888f02007-07-31 20:11:57 +00003745 "ret\t#eh_return, addr: $addr",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003746 [(X86ehret GR32:$addr)]>;
3747
3748}
3749
3750//===----------------------------------------------------------------------===//
Andrew Lenharthe44f3902008-02-21 06:45:13 +00003751// Atomic support
3752//
Andrew Lenharth7a5a4b22008-03-01 13:37:02 +00003753
Evan Cheng3e171562008-04-19 01:20:30 +00003754// Atomic swap. These are just normal xchg instructions. But since a memory
3755// operand is referenced, the atomicity is ensured.
Dan Gohmana41a1c092008-08-06 15:52:50 +00003756let Constraints = "$val = $dst" in {
Sean Callanan2c48df22009-12-18 00:01:26 +00003757def XCHG32rm : I<0x87, MRMSrcMem, (outs GR32:$dst),
3758 (ins GR32:$val, i32mem:$ptr),
Evan Cheng3e171562008-04-19 01:20:30 +00003759 "xchg{l}\t{$val, $ptr|$ptr, $val}",
3760 [(set GR32:$dst, (atomic_swap_32 addr:$ptr, GR32:$val))]>;
Sean Callanan2c48df22009-12-18 00:01:26 +00003761def XCHG16rm : I<0x87, MRMSrcMem, (outs GR16:$dst),
3762 (ins GR16:$val, i16mem:$ptr),
Evan Cheng3e171562008-04-19 01:20:30 +00003763 "xchg{w}\t{$val, $ptr|$ptr, $val}",
3764 [(set GR16:$dst, (atomic_swap_16 addr:$ptr, GR16:$val))]>,
3765 OpSize;
Sean Callanan2c48df22009-12-18 00:01:26 +00003766def XCHG8rm : I<0x86, MRMSrcMem, (outs GR8:$dst), (ins GR8:$val, i8mem:$ptr),
Evan Cheng3e171562008-04-19 01:20:30 +00003767 "xchg{b}\t{$val, $ptr|$ptr, $val}",
3768 [(set GR8:$dst, (atomic_swap_8 addr:$ptr, GR8:$val))]>;
Sean Callanan2c48df22009-12-18 00:01:26 +00003769
3770def XCHG32rr : I<0x87, MRMSrcReg, (outs GR32:$dst), (ins GR32:$val, GR32:$src),
3771 "xchg{l}\t{$val, $src|$src, $val}", []>;
3772def XCHG16rr : I<0x87, MRMSrcReg, (outs GR16:$dst), (ins GR16:$val, GR16:$src),
3773 "xchg{w}\t{$val, $src|$src, $val}", []>, OpSize;
3774def XCHG8rr : I<0x86, MRMSrcReg, (outs GR8:$dst), (ins GR8:$val, GR8:$src),
3775 "xchg{b}\t{$val, $src|$src, $val}", []>;
Evan Cheng3e171562008-04-19 01:20:30 +00003776}
3777
Sean Callanan2c48df22009-12-18 00:01:26 +00003778def XCHG16ar : I<0x90, AddRegFrm, (outs), (ins GR16:$src),
3779 "xchg{w}\t{$src, %ax|%ax, $src}", []>, OpSize;
3780def XCHG32ar : I<0x90, AddRegFrm, (outs), (ins GR32:$src),
3781 "xchg{l}\t{$src, %eax|%eax, $src}", []>;
3782
Evan Chengd49dbb82008-04-18 20:55:36 +00003783// Atomic compare and swap.
Andrew Lenharth7dfe23f2008-03-01 21:52:34 +00003784let Defs = [EAX, EFLAGS], Uses = [EAX] in {
Evan Chengd49dbb82008-04-18 20:55:36 +00003785def LCMPXCHG32 : I<0xB1, MRMDestMem, (outs), (ins i32mem:$ptr, GR32:$swap),
Dan Gohman70a8a112009-04-27 15:13:28 +00003786 "lock\n\t"
3787 "cmpxchg{l}\t{$swap, $ptr|$ptr, $swap}",
Evan Cheng09fbdee2008-03-04 03:20:06 +00003788 [(X86cas addr:$ptr, GR32:$swap, 4)]>, TB, LOCK;
Andrew Lenharth7a5a4b22008-03-01 13:37:02 +00003789}
Dale Johannesenf160d802008-10-02 18:53:47 +00003790let Defs = [EAX, EDX, EFLAGS], Uses = [EAX, EBX, ECX, EDX] in {
Anton Korobeynikovc4067392008-07-22 16:22:48 +00003791def LCMPXCHG8B : I<0xC7, MRM1m, (outs), (ins i32mem:$ptr),
Dan Gohman70a8a112009-04-27 15:13:28 +00003792 "lock\n\t"
3793 "cmpxchg8b\t$ptr",
Andrew Lenharth81580822008-03-05 01:15:49 +00003794 [(X86cas8 addr:$ptr)]>, TB, LOCK;
3795}
Andrew Lenharth7dfe23f2008-03-01 21:52:34 +00003796
3797let Defs = [AX, EFLAGS], Uses = [AX] in {
Evan Chengd49dbb82008-04-18 20:55:36 +00003798def LCMPXCHG16 : I<0xB1, MRMDestMem, (outs), (ins i16mem:$ptr, GR16:$swap),
Dan Gohman70a8a112009-04-27 15:13:28 +00003799 "lock\n\t"
3800 "cmpxchg{w}\t{$swap, $ptr|$ptr, $swap}",
Evan Cheng09fbdee2008-03-04 03:20:06 +00003801 [(X86cas addr:$ptr, GR16:$swap, 2)]>, TB, OpSize, LOCK;
Andrew Lenharth7a5a4b22008-03-01 13:37:02 +00003802}
Andrew Lenharth7dfe23f2008-03-01 21:52:34 +00003803let Defs = [AL, EFLAGS], Uses = [AL] in {
Evan Chengd49dbb82008-04-18 20:55:36 +00003804def LCMPXCHG8 : I<0xB0, MRMDestMem, (outs), (ins i8mem:$ptr, GR8:$swap),
Dan Gohman70a8a112009-04-27 15:13:28 +00003805 "lock\n\t"
3806 "cmpxchg{b}\t{$swap, $ptr|$ptr, $swap}",
Evan Cheng09fbdee2008-03-04 03:20:06 +00003807 [(X86cas addr:$ptr, GR8:$swap, 1)]>, TB, LOCK;
Andrew Lenharth7a5a4b22008-03-01 13:37:02 +00003808}
3809
Evan Chengd49dbb82008-04-18 20:55:36 +00003810// Atomic exchange and add
3811let Constraints = "$val = $dst", Defs = [EFLAGS] in {
Sean Callanan2c48df22009-12-18 00:01:26 +00003812def LXADD32 : I<0xC1, MRMSrcMem, (outs GR32:$dst), (ins GR32:$val, i32mem:$ptr),
Dan Gohman70a8a112009-04-27 15:13:28 +00003813 "lock\n\t"
3814 "xadd{l}\t{$val, $ptr|$ptr, $val}",
Mon P Wang6bde9ec2008-06-25 08:15:39 +00003815 [(set GR32:$dst, (atomic_load_add_32 addr:$ptr, GR32:$val))]>,
Evan Chengd49dbb82008-04-18 20:55:36 +00003816 TB, LOCK;
Sean Callanan2c48df22009-12-18 00:01:26 +00003817def LXADD16 : I<0xC1, MRMSrcMem, (outs GR16:$dst), (ins GR16:$val, i16mem:$ptr),
Dan Gohman70a8a112009-04-27 15:13:28 +00003818 "lock\n\t"
3819 "xadd{w}\t{$val, $ptr|$ptr, $val}",
Mon P Wang6bde9ec2008-06-25 08:15:39 +00003820 [(set GR16:$dst, (atomic_load_add_16 addr:$ptr, GR16:$val))]>,
Evan Chengd49dbb82008-04-18 20:55:36 +00003821 TB, OpSize, LOCK;
Sean Callanan2c48df22009-12-18 00:01:26 +00003822def LXADD8 : I<0xC0, MRMSrcMem, (outs GR8:$dst), (ins GR8:$val, i8mem:$ptr),
Dan Gohman70a8a112009-04-27 15:13:28 +00003823 "lock\n\t"
3824 "xadd{b}\t{$val, $ptr|$ptr, $val}",
Mon P Wang6bde9ec2008-06-25 08:15:39 +00003825 [(set GR8:$dst, (atomic_load_add_8 addr:$ptr, GR8:$val))]>,
Evan Chengd49dbb82008-04-18 20:55:36 +00003826 TB, LOCK;
Andrew Lenharth7a5a4b22008-03-01 13:37:02 +00003827}
3828
Sean Callanan2c48df22009-12-18 00:01:26 +00003829def XADD8rr : I<0xC0, MRMDestReg, (outs GR8:$dst), (ins GR8:$src),
3830 "xadd{b}\t{$src, $dst|$dst, $src}", []>, TB;
3831def XADD16rr : I<0xC1, MRMDestReg, (outs GR16:$dst), (ins GR16:$src),
3832 "xadd{w}\t{$src, $dst|$dst, $src}", []>, TB, OpSize;
3833def XADD32rr : I<0xC1, MRMDestReg, (outs GR32:$dst), (ins GR32:$src),
3834 "xadd{l}\t{$src, $dst|$dst, $src}", []>, TB;
3835
3836def XADD8rm : I<0xC0, MRMDestMem, (outs), (ins i8mem:$dst, GR8:$src),
3837 "xadd{b}\t{$src, $dst|$dst, $src}", []>, TB;
3838def XADD16rm : I<0xC1, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src),
3839 "xadd{w}\t{$src, $dst|$dst, $src}", []>, TB, OpSize;
3840def XADD32rm : I<0xC1, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src),
3841 "xadd{l}\t{$src, $dst|$dst, $src}", []>, TB;
3842
3843def CMPXCHG8rr : I<0xB0, MRMDestReg, (outs GR8:$dst), (ins GR8:$src),
3844 "cmpxchg{b}\t{$src, $dst|$dst, $src}", []>, TB;
3845def CMPXCHG16rr : I<0xB1, MRMDestReg, (outs GR16:$dst), (ins GR16:$src),
3846 "cmpxchg{w}\t{$src, $dst|$dst, $src}", []>, TB, OpSize;
3847def CMPXCHG32rr : I<0xB1, MRMDestReg, (outs GR32:$dst), (ins GR32:$src),
3848 "cmpxchg{l}\t{$src, $dst|$dst, $src}", []>, TB;
3849
3850def CMPXCHG8rm : I<0xB0, MRMDestMem, (outs), (ins i8mem:$dst, GR8:$src),
3851 "cmpxchg{b}\t{$src, $dst|$dst, $src}", []>, TB;
3852def CMPXCHG16rm : I<0xB1, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src),
3853 "cmpxchg{w}\t{$src, $dst|$dst, $src}", []>, TB, OpSize;
3854def CMPXCHG32rm : I<0xB1, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src),
3855 "cmpxchg{l}\t{$src, $dst|$dst, $src}", []>, TB;
3856
3857def CMPXCHG8B : I<0xC7, MRM1m, (outs), (ins i64mem:$dst),
3858 "cmpxchg8b\t$dst", []>, TB;
3859
Evan Chengb723fb52009-07-30 08:33:02 +00003860// Optimized codegen when the non-memory output is not used.
3861// FIXME: Use normal add / sub instructions and add lock prefix dynamically.
Dan Gohman1c286992009-10-20 18:14:49 +00003862let Defs = [EFLAGS] in {
Evan Chengb723fb52009-07-30 08:33:02 +00003863def LOCK_ADD8mr : I<0x00, MRMDestMem, (outs), (ins i8mem:$dst, GR8:$src2),
3864 "lock\n\t"
3865 "add{b}\t{$src2, $dst|$dst, $src2}", []>, LOCK;
3866def LOCK_ADD16mr : I<0x01, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
3867 "lock\n\t"
3868 "add{w}\t{$src2, $dst|$dst, $src2}", []>, OpSize, LOCK;
3869def LOCK_ADD32mr : I<0x01, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
3870 "lock\n\t"
3871 "add{l}\t{$src2, $dst|$dst, $src2}", []>, LOCK;
3872def LOCK_ADD8mi : Ii8<0x80, MRM0m, (outs), (ins i8mem :$dst, i8imm :$src2),
3873 "lock\n\t"
3874 "add{b}\t{$src2, $dst|$dst, $src2}", []>, LOCK;
3875def LOCK_ADD16mi : Ii16<0x81, MRM0m, (outs), (ins i16mem:$dst, i16imm:$src2),
3876 "lock\n\t"
3877 "add{w}\t{$src2, $dst|$dst, $src2}", []>, LOCK;
3878def LOCK_ADD32mi : Ii32<0x81, MRM0m, (outs), (ins i32mem:$dst, i32imm:$src2),
3879 "lock\n\t"
3880 "add{l}\t{$src2, $dst|$dst, $src2}", []>, LOCK;
3881def LOCK_ADD16mi8 : Ii8<0x83, MRM0m, (outs), (ins i16mem:$dst, i16i8imm :$src2),
3882 "lock\n\t"
3883 "add{w}\t{$src2, $dst|$dst, $src2}", []>, OpSize, LOCK;
3884def LOCK_ADD32mi8 : Ii8<0x83, MRM0m, (outs), (ins i32mem:$dst, i32i8imm :$src2),
3885 "lock\n\t"
3886 "add{l}\t{$src2, $dst|$dst, $src2}", []>, LOCK;
3887
3888def LOCK_INC8m : I<0xFE, MRM0m, (outs), (ins i8mem :$dst),
3889 "lock\n\t"
3890 "inc{b}\t$dst", []>, LOCK;
3891def LOCK_INC16m : I<0xFF, MRM0m, (outs), (ins i16mem:$dst),
3892 "lock\n\t"
3893 "inc{w}\t$dst", []>, OpSize, LOCK;
3894def LOCK_INC32m : I<0xFF, MRM0m, (outs), (ins i32mem:$dst),
3895 "lock\n\t"
3896 "inc{l}\t$dst", []>, LOCK;
3897
3898def LOCK_SUB8mr : I<0x28, MRMDestMem, (outs), (ins i8mem :$dst, GR8 :$src2),
3899 "lock\n\t"
3900 "sub{b}\t{$src2, $dst|$dst, $src2}", []>, LOCK;
3901def LOCK_SUB16mr : I<0x29, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
3902 "lock\n\t"
3903 "sub{w}\t{$src2, $dst|$dst, $src2}", []>, OpSize, LOCK;
3904def LOCK_SUB32mr : I<0x29, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
3905 "lock\n\t"
3906 "sub{l}\t{$src2, $dst|$dst, $src2}", []>, LOCK;
3907def LOCK_SUB8mi : Ii8<0x80, MRM5m, (outs), (ins i8mem :$dst, i8imm:$src2),
3908 "lock\n\t"
3909 "sub{b}\t{$src2, $dst|$dst, $src2}", []>, LOCK;
3910def LOCK_SUB16mi : Ii16<0x81, MRM5m, (outs), (ins i16mem:$dst, i16imm:$src2),
3911 "lock\n\t"
3912 "sub{w}\t{$src2, $dst|$dst, $src2}", []>, OpSize, LOCK;
3913def LOCK_SUB32mi : Ii32<0x81, MRM5m, (outs), (ins i32mem:$dst, i32imm:$src2),
3914 "lock\n\t"
3915 "sub{l}\t{$src2, $dst|$dst, $src2}", []>, LOCK;
Sean Callanan2c48df22009-12-18 00:01:26 +00003916def LOCK_SUB16mi8 : Ii8<0x83, MRM5m, (outs), (ins i16mem:$dst, i16i8imm :$src2),
Evan Chengb723fb52009-07-30 08:33:02 +00003917 "lock\n\t"
3918 "sub{w}\t{$src2, $dst|$dst, $src2}", []>, OpSize, LOCK;
3919def LOCK_SUB32mi8 : Ii8<0x83, MRM5m, (outs), (ins i32mem:$dst, i32i8imm :$src2),
3920 "lock\n\t"
3921 "sub{l}\t{$src2, $dst|$dst, $src2}", []>, LOCK;
3922
3923def LOCK_DEC8m : I<0xFE, MRM1m, (outs), (ins i8mem :$dst),
3924 "lock\n\t"
3925 "dec{b}\t$dst", []>, LOCK;
3926def LOCK_DEC16m : I<0xFF, MRM1m, (outs), (ins i16mem:$dst),
3927 "lock\n\t"
3928 "dec{w}\t$dst", []>, OpSize, LOCK;
3929def LOCK_DEC32m : I<0xFF, MRM1m, (outs), (ins i32mem:$dst),
3930 "lock\n\t"
3931 "dec{l}\t$dst", []>, LOCK;
Dan Gohman1c286992009-10-20 18:14:49 +00003932}
Evan Chengb723fb52009-07-30 08:33:02 +00003933
Mon P Wang6bde9ec2008-06-25 08:15:39 +00003934// Atomic exchange, and, or, xor
Mon P Wang078a62d2008-05-05 19:05:59 +00003935let Constraints = "$val = $dst", Defs = [EFLAGS],
Dan Gohman30afe012009-10-29 18:10:34 +00003936 usesCustomInserter = 1 in {
Dan Gohman8aeb61f2008-05-12 20:22:45 +00003937def ATOMAND32 : I<0, Pseudo, (outs GR32:$dst),(ins i32mem:$ptr, GR32:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003938 "#ATOMAND32 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003939 [(set GR32:$dst, (atomic_load_and_32 addr:$ptr, GR32:$val))]>;
Dan Gohman8aeb61f2008-05-12 20:22:45 +00003940def ATOMOR32 : I<0, Pseudo, (outs GR32:$dst),(ins i32mem:$ptr, GR32:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003941 "#ATOMOR32 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003942 [(set GR32:$dst, (atomic_load_or_32 addr:$ptr, GR32:$val))]>;
Dan Gohman8aeb61f2008-05-12 20:22:45 +00003943def ATOMXOR32 : I<0, Pseudo,(outs GR32:$dst),(ins i32mem:$ptr, GR32:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003944 "#ATOMXOR32 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003945 [(set GR32:$dst, (atomic_load_xor_32 addr:$ptr, GR32:$val))]>;
Andrew Lenharthaf02d592008-06-14 05:48:15 +00003946def ATOMNAND32 : I<0, Pseudo,(outs GR32:$dst),(ins i32mem:$ptr, GR32:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003947 "#ATOMNAND32 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003948 [(set GR32:$dst, (atomic_load_nand_32 addr:$ptr, GR32:$val))]>;
Dan Gohman8aeb61f2008-05-12 20:22:45 +00003949def ATOMMIN32: I<0, Pseudo, (outs GR32:$dst), (ins i32mem:$ptr, GR32:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003950 "#ATOMMIN32 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003951 [(set GR32:$dst, (atomic_load_min_32 addr:$ptr, GR32:$val))]>;
Dan Gohman8aeb61f2008-05-12 20:22:45 +00003952def ATOMMAX32: I<0, Pseudo, (outs GR32:$dst),(ins i32mem:$ptr, GR32:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003953 "#ATOMMAX32 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003954 [(set GR32:$dst, (atomic_load_max_32 addr:$ptr, GR32:$val))]>;
Dan Gohman8aeb61f2008-05-12 20:22:45 +00003955def ATOMUMIN32: I<0, Pseudo, (outs GR32:$dst),(ins i32mem:$ptr, GR32:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003956 "#ATOMUMIN32 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003957 [(set GR32:$dst, (atomic_load_umin_32 addr:$ptr, GR32:$val))]>;
Dan Gohman8aeb61f2008-05-12 20:22:45 +00003958def ATOMUMAX32: I<0, Pseudo, (outs GR32:$dst),(ins i32mem:$ptr, GR32:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003959 "#ATOMUMAX32 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003960 [(set GR32:$dst, (atomic_load_umax_32 addr:$ptr, GR32:$val))]>;
Dale Johannesend20e4452008-08-19 18:47:28 +00003961
3962def ATOMAND16 : I<0, Pseudo, (outs GR16:$dst),(ins i16mem:$ptr, GR16:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003963 "#ATOMAND16 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003964 [(set GR16:$dst, (atomic_load_and_16 addr:$ptr, GR16:$val))]>;
Dale Johannesend20e4452008-08-19 18:47:28 +00003965def ATOMOR16 : I<0, Pseudo, (outs GR16:$dst),(ins i16mem:$ptr, GR16:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003966 "#ATOMOR16 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003967 [(set GR16:$dst, (atomic_load_or_16 addr:$ptr, GR16:$val))]>;
Dale Johannesend20e4452008-08-19 18:47:28 +00003968def ATOMXOR16 : I<0, Pseudo,(outs GR16:$dst),(ins i16mem:$ptr, GR16:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003969 "#ATOMXOR16 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003970 [(set GR16:$dst, (atomic_load_xor_16 addr:$ptr, GR16:$val))]>;
Dale Johannesend20e4452008-08-19 18:47:28 +00003971def ATOMNAND16 : I<0, Pseudo,(outs GR16:$dst),(ins i16mem:$ptr, GR16:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003972 "#ATOMNAND16 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003973 [(set GR16:$dst, (atomic_load_nand_16 addr:$ptr, GR16:$val))]>;
Dale Johannesend20e4452008-08-19 18:47:28 +00003974def ATOMMIN16: I<0, Pseudo, (outs GR16:$dst), (ins i16mem:$ptr, GR16:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003975 "#ATOMMIN16 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003976 [(set GR16:$dst, (atomic_load_min_16 addr:$ptr, GR16:$val))]>;
Dale Johannesend20e4452008-08-19 18:47:28 +00003977def ATOMMAX16: I<0, Pseudo, (outs GR16:$dst),(ins i16mem:$ptr, GR16:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003978 "#ATOMMAX16 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003979 [(set GR16:$dst, (atomic_load_max_16 addr:$ptr, GR16:$val))]>;
Dale Johannesend20e4452008-08-19 18:47:28 +00003980def ATOMUMIN16: I<0, Pseudo, (outs GR16:$dst),(ins i16mem:$ptr, GR16:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003981 "#ATOMUMIN16 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003982 [(set GR16:$dst, (atomic_load_umin_16 addr:$ptr, GR16:$val))]>;
Dale Johannesend20e4452008-08-19 18:47:28 +00003983def ATOMUMAX16: I<0, Pseudo, (outs GR16:$dst),(ins i16mem:$ptr, GR16:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003984 "#ATOMUMAX16 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003985 [(set GR16:$dst, (atomic_load_umax_16 addr:$ptr, GR16:$val))]>;
Dale Johannesend20e4452008-08-19 18:47:28 +00003986
3987def ATOMAND8 : I<0, Pseudo, (outs GR8:$dst),(ins i8mem:$ptr, GR8:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003988 "#ATOMAND8 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003989 [(set GR8:$dst, (atomic_load_and_8 addr:$ptr, GR8:$val))]>;
Dale Johannesend20e4452008-08-19 18:47:28 +00003990def ATOMOR8 : I<0, Pseudo, (outs GR8:$dst),(ins i8mem:$ptr, GR8:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003991 "#ATOMOR8 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003992 [(set GR8:$dst, (atomic_load_or_8 addr:$ptr, GR8:$val))]>;
Dale Johannesend20e4452008-08-19 18:47:28 +00003993def ATOMXOR8 : I<0, Pseudo,(outs GR8:$dst),(ins i8mem:$ptr, GR8:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003994 "#ATOMXOR8 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003995 [(set GR8:$dst, (atomic_load_xor_8 addr:$ptr, GR8:$val))]>;
Dale Johannesend20e4452008-08-19 18:47:28 +00003996def ATOMNAND8 : I<0, Pseudo,(outs GR8:$dst),(ins i8mem:$ptr, GR8:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003997 "#ATOMNAND8 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003998 [(set GR8:$dst, (atomic_load_nand_8 addr:$ptr, GR8:$val))]>;
Mon P Wang078a62d2008-05-05 19:05:59 +00003999}
4000
Dale Johannesenf160d802008-10-02 18:53:47 +00004001let Constraints = "$val1 = $dst1, $val2 = $dst2",
4002 Defs = [EFLAGS, EAX, EBX, ECX, EDX],
4003 Uses = [EAX, EBX, ECX, EDX],
Dale Johannesen44eb5372008-10-03 19:41:08 +00004004 mayLoad = 1, mayStore = 1,
Dan Gohman30afe012009-10-29 18:10:34 +00004005 usesCustomInserter = 1 in {
Dale Johannesenf160d802008-10-02 18:53:47 +00004006def ATOMAND6432 : I<0, Pseudo, (outs GR32:$dst1, GR32:$dst2),
4007 (ins i64mem:$ptr, GR32:$val1, GR32:$val2),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00004008 "#ATOMAND6432 PSEUDO!", []>;
Dale Johannesenf160d802008-10-02 18:53:47 +00004009def ATOMOR6432 : I<0, Pseudo, (outs GR32:$dst1, GR32:$dst2),
4010 (ins i64mem:$ptr, GR32:$val1, GR32:$val2),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00004011 "#ATOMOR6432 PSEUDO!", []>;
Dale Johannesenf160d802008-10-02 18:53:47 +00004012def ATOMXOR6432 : I<0, Pseudo, (outs GR32:$dst1, GR32:$dst2),
4013 (ins i64mem:$ptr, GR32:$val1, GR32:$val2),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00004014 "#ATOMXOR6432 PSEUDO!", []>;
Dale Johannesenf160d802008-10-02 18:53:47 +00004015def ATOMNAND6432 : I<0, Pseudo, (outs GR32:$dst1, GR32:$dst2),
4016 (ins i64mem:$ptr, GR32:$val1, GR32:$val2),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00004017 "#ATOMNAND6432 PSEUDO!", []>;
Dale Johannesenf160d802008-10-02 18:53:47 +00004018def ATOMADD6432 : I<0, Pseudo, (outs GR32:$dst1, GR32:$dst2),
4019 (ins i64mem:$ptr, GR32:$val1, GR32:$val2),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00004020 "#ATOMADD6432 PSEUDO!", []>;
Dale Johannesenf160d802008-10-02 18:53:47 +00004021def ATOMSUB6432 : I<0, Pseudo, (outs GR32:$dst1, GR32:$dst2),
4022 (ins i64mem:$ptr, GR32:$val1, GR32:$val2),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00004023 "#ATOMSUB6432 PSEUDO!", []>;
Dale Johannesen51c58ee2008-10-03 22:25:52 +00004024def ATOMSWAP6432 : I<0, Pseudo, (outs GR32:$dst1, GR32:$dst2),
4025 (ins i64mem:$ptr, GR32:$val1, GR32:$val2),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00004026 "#ATOMSWAP6432 PSEUDO!", []>;
Dale Johannesenf160d802008-10-02 18:53:47 +00004027}
4028
Sean Callanan2eddf5d2009-09-16 21:55:34 +00004029// Segmentation support instructions.
4030
4031def LAR16rm : I<0x02, MRMSrcMem, (outs GR16:$dst), (ins i16mem:$src),
4032 "lar{w}\t{$src, $dst|$dst, $src}", []>, TB, OpSize;
4033def LAR16rr : I<0x02, MRMSrcReg, (outs GR16:$dst), (ins GR16:$src),
4034 "lar{w}\t{$src, $dst|$dst, $src}", []>, TB, OpSize;
4035
4036// i16mem operand in LAR32rm and GR32 operand in LAR32rr is not a typo.
4037def LAR32rm : I<0x02, MRMSrcMem, (outs GR32:$dst), (ins i16mem:$src),
4038 "lar{l}\t{$src, $dst|$dst, $src}", []>, TB;
4039def LAR32rr : I<0x02, MRMSrcReg, (outs GR32:$dst), (ins GR32:$src),
4040 "lar{l}\t{$src, $dst|$dst, $src}", []>, TB;
Sean Callanan2c48df22009-12-18 00:01:26 +00004041
4042def LSL16rm : I<0x03, MRMSrcMem, (outs GR16:$dst), (ins i16mem:$src),
4043 "lsl{w}\t{$src, $dst|$dst, $src}", []>, TB, OpSize;
4044def LSL16rr : I<0x03, MRMSrcReg, (outs GR16:$dst), (ins GR16:$src),
4045 "lsl{w}\t{$src, $dst|$dst, $src}", []>, TB, OpSize;
4046def LSL32rm : I<0x03, MRMSrcMem, (outs GR32:$dst), (ins i32mem:$src),
4047 "lsl{l}\t{$src, $dst|$dst, $src}", []>, TB;
4048def LSL32rr : I<0x03, MRMSrcReg, (outs GR32:$dst), (ins GR32:$src),
4049 "lsl{l}\t{$src, $dst|$dst, $src}", []>, TB;
4050
4051def INVLPG : I<0x01, RawFrm, (outs), (ins), "invlpg", []>, TB;
4052
4053def STRr : I<0x00, MRM1r, (outs GR16:$dst), (ins),
4054 "str{w}\t{$dst}", []>, TB;
4055def STRm : I<0x00, MRM1m, (outs i16mem:$dst), (ins),
4056 "str{w}\t{$dst}", []>, TB;
4057def LTRr : I<0x00, MRM3r, (outs), (ins GR16:$src),
4058 "ltr{w}\t{$src}", []>, TB;
4059def LTRm : I<0x00, MRM3m, (outs), (ins i16mem:$src),
4060 "ltr{w}\t{$src}", []>, TB;
4061
4062def PUSHFS16 : I<0xa0, RawFrm, (outs), (ins),
4063 "push{w}\t%fs", []>, OpSize, TB;
4064def PUSHFS32 : I<0xa0, RawFrm, (outs), (ins),
4065 "push{l}\t%fs", []>, TB;
4066def PUSHGS16 : I<0xa8, RawFrm, (outs), (ins),
4067 "push{w}\t%gs", []>, OpSize, TB;
4068def PUSHGS32 : I<0xa8, RawFrm, (outs), (ins),
4069 "push{l}\t%gs", []>, TB;
4070
4071def POPFS16 : I<0xa1, RawFrm, (outs), (ins),
4072 "pop{w}\t%fs", []>, OpSize, TB;
4073def POPFS32 : I<0xa1, RawFrm, (outs), (ins),
4074 "pop{l}\t%fs", []>, TB;
4075def POPGS16 : I<0xa9, RawFrm, (outs), (ins),
4076 "pop{w}\t%gs", []>, OpSize, TB;
4077def POPGS32 : I<0xa9, RawFrm, (outs), (ins),
4078 "pop{l}\t%gs", []>, TB;
4079
4080def LDS16rm : I<0xc5, MRMSrcMem, (outs GR16:$dst), (ins opaque32mem:$src),
4081 "lds{w}\t{$src, $dst|$dst, $src}", []>, OpSize;
4082def LDS32rm : I<0xc5, MRMSrcMem, (outs GR32:$dst), (ins opaque48mem:$src),
4083 "lds{l}\t{$src, $dst|$dst, $src}", []>;
4084def LSS16rm : I<0xb2, MRMSrcMem, (outs GR16:$dst), (ins opaque32mem:$src),
4085 "lss{w}\t{$src, $dst|$dst, $src}", []>, TB, OpSize;
4086def LSS32rm : I<0xb2, MRMSrcMem, (outs GR32:$dst), (ins opaque48mem:$src),
4087 "lss{l}\t{$src, $dst|$dst, $src}", []>, TB;
4088def LES16rm : I<0xc4, MRMSrcMem, (outs GR16:$dst), (ins opaque32mem:$src),
4089 "les{w}\t{$src, $dst|$dst, $src}", []>, OpSize;
4090def LES32rm : I<0xc4, MRMSrcMem, (outs GR32:$dst), (ins opaque48mem:$src),
4091 "les{l}\t{$src, $dst|$dst, $src}", []>;
4092def LFS16rm : I<0xb4, MRMSrcMem, (outs GR16:$dst), (ins opaque32mem:$src),
4093 "lfs{w}\t{$src, $dst|$dst, $src}", []>, TB, OpSize;
4094def LFS32rm : I<0xb4, MRMSrcMem, (outs GR32:$dst), (ins opaque48mem:$src),
4095 "lfs{l}\t{$src, $dst|$dst, $src}", []>, TB;
4096def LGS16rm : I<0xb5, MRMSrcMem, (outs GR16:$dst), (ins opaque32mem:$src),
4097 "lgs{w}\t{$src, $dst|$dst, $src}", []>, TB, OpSize;
4098def LGS32rm : I<0xb5, MRMSrcMem, (outs GR32:$dst), (ins opaque48mem:$src),
4099 "lgs{l}\t{$src, $dst|$dst, $src}", []>, TB;
4100
4101def VERRr : I<0x00, MRM4r, (outs), (ins GR16:$seg),
4102 "verr\t$seg", []>, TB;
4103def VERRm : I<0x00, MRM4m, (outs), (ins i16mem:$seg),
4104 "verr\t$seg", []>, TB;
4105def VERWr : I<0x00, MRM5r, (outs), (ins GR16:$seg),
4106 "verw\t$seg", []>, TB;
4107def VERWm : I<0x00, MRM5m, (outs), (ins i16mem:$seg),
4108 "verw\t$seg", []>, TB;
4109
4110// Descriptor-table support instructions
4111
4112def SGDTm : I<0x01, MRM0m, (outs opaque48mem:$dst), (ins),
4113 "sgdt\t$dst", []>, TB;
4114def SIDTm : I<0x01, MRM1m, (outs opaque48mem:$dst), (ins),
4115 "sidt\t$dst", []>, TB;
4116def SLDT16r : I<0x00, MRM0r, (outs GR16:$dst), (ins),
4117 "sldt{w}\t$dst", []>, TB;
4118def SLDT16m : I<0x00, MRM0m, (outs i16mem:$dst), (ins),
4119 "sldt{w}\t$dst", []>, TB;
4120def LGDTm : I<0x01, MRM2m, (outs), (ins opaque48mem:$src),
4121 "lgdt\t$src", []>, TB;
4122def LIDTm : I<0x01, MRM3m, (outs), (ins opaque48mem:$src),
4123 "lidt\t$src", []>, TB;
4124def LLDT16r : I<0x00, MRM2r, (outs), (ins GR16:$src),
4125 "lldt{w}\t$src", []>, TB;
4126def LLDT16m : I<0x00, MRM2m, (outs), (ins i16mem:$src),
4127 "lldt{w}\t$src", []>, TB;
Sean Callanan23f33d72009-09-16 22:59:28 +00004128
4129// String manipulation instructions
4130
4131def LODSB : I<0xAC, RawFrm, (outs), (ins), "lodsb", []>;
4132def LODSW : I<0xAD, RawFrm, (outs), (ins), "lodsw", []>, OpSize;
Sean Callanan2c48df22009-12-18 00:01:26 +00004133def LODSD : I<0xAD, RawFrm, (outs), (ins), "lods{l|d}", []>;
4134
4135def OUTSB : I<0x6E, RawFrm, (outs), (ins), "outsb", []>;
4136def OUTSW : I<0x6F, RawFrm, (outs), (ins), "outsw", []>, OpSize;
4137def OUTSD : I<0x6F, RawFrm, (outs), (ins), "outs{l|d}", []>;
4138
4139// CPU flow control instructions
4140
4141def HLT : I<0xF4, RawFrm, (outs), (ins), "hlt", []>;
4142def RSM : I<0xAA, RawFrm, (outs), (ins), "rsm", []>, TB;
4143
4144// FPU control instructions
4145
4146def FNINIT : I<0xE3, RawFrm, (outs), (ins), "fninit", []>, DB;
4147
4148// Flag instructions
4149
4150def CLC : I<0xF8, RawFrm, (outs), (ins), "clc", []>;
4151def STC : I<0xF9, RawFrm, (outs), (ins), "stc", []>;
4152def CLI : I<0xFA, RawFrm, (outs), (ins), "cli", []>;
4153def STI : I<0xFB, RawFrm, (outs), (ins), "sti", []>;
4154def CLD : I<0xFC, RawFrm, (outs), (ins), "cld", []>;
4155def STD : I<0xFD, RawFrm, (outs), (ins), "std", []>;
4156def CMC : I<0xF5, RawFrm, (outs), (ins), "cmc", []>;
4157
4158def CLTS : I<0x06, RawFrm, (outs), (ins), "clts", []>, TB;
4159
4160// Table lookup instructions
4161
4162def XLAT : I<0xD7, RawFrm, (outs), (ins), "xlatb", []>;
4163
4164// Specialized register support
4165
4166def WRMSR : I<0x30, RawFrm, (outs), (ins), "wrmsr", []>, TB;
4167def RDMSR : I<0x32, RawFrm, (outs), (ins), "rdmsr", []>, TB;
4168def RDPMC : I<0x33, RawFrm, (outs), (ins), "rdpmc", []>, TB;
4169
4170def SMSW16r : I<0x01, MRM4r, (outs GR16:$dst), (ins),
4171 "smsw{w}\t$dst", []>, OpSize, TB;
4172def SMSW32r : I<0x01, MRM4r, (outs GR32:$dst), (ins),
4173 "smsw{l}\t$dst", []>, TB;
4174// For memory operands, there is only a 16-bit form
4175def SMSW16m : I<0x01, MRM4m, (outs i16mem:$dst), (ins),
4176 "smsw{w}\t$dst", []>, TB;
4177
4178def LMSW16r : I<0x01, MRM6r, (outs), (ins GR16:$src),
4179 "lmsw{w}\t$src", []>, TB;
4180def LMSW16m : I<0x01, MRM6m, (outs), (ins i16mem:$src),
4181 "lmsw{w}\t$src", []>, TB;
4182
4183def CPUID : I<0xA2, RawFrm, (outs), (ins), "cpuid", []>, TB;
4184
4185// Cache instructions
4186
4187def INVD : I<0x08, RawFrm, (outs), (ins), "invd", []>, TB;
4188def WBINVD : I<0x09, RawFrm, (outs), (ins), "wbinvd", []>, TB;
4189
4190// VMX instructions
4191
4192// 66 0F 38 80
4193def INVEPT : I<0x38, RawFrm, (outs), (ins), "invept", []>, OpSize, TB;
4194// 66 0F 38 81
4195def INVVPID : I<0x38, RawFrm, (outs), (ins), "invvpid", []>, OpSize, TB;
4196// 0F 01 C1
4197def VMCALL : I<0x01, RawFrm, (outs), (ins), "vmcall", []>, TB;
4198def VMCLEARm : I<0xC7, MRM6m, (outs), (ins i64mem:$vmcs),
4199 "vmclear\t$vmcs", []>, OpSize, TB;
4200// 0F 01 C2
4201def VMLAUNCH : I<0x01, RawFrm, (outs), (ins), "vmlaunch", []>, TB;
4202// 0F 01 C3
4203def VMRESUME : I<0x01, RawFrm, (outs), (ins), "vmresume", []>, TB;
4204def VMPTRLDm : I<0xC7, MRM6m, (outs), (ins i64mem:$vmcs),
4205 "vmptrld\t$vmcs", []>, TB;
4206def VMPTRSTm : I<0xC7, MRM7m, (outs i64mem:$vmcs), (ins),
4207 "vmptrst\t$vmcs", []>, TB;
4208def VMREAD64rm : I<0x78, MRMDestMem, (outs i64mem:$dst), (ins GR64:$src),
4209 "vmread{q}\t{$src, $dst|$dst, $src}", []>, TB;
4210def VMREAD64rr : I<0x78, MRMDestReg, (outs GR64:$dst), (ins GR64:$src),
4211 "vmread{q}\t{$src, $dst|$dst, $src}", []>, TB;
4212def VMREAD32rm : I<0x78, MRMDestMem, (outs i32mem:$dst), (ins GR32:$src),
4213 "vmread{l}\t{$src, $dst|$dst, $src}", []>, TB;
4214def VMREAD32rr : I<0x78, MRMDestReg, (outs GR32:$dst), (ins GR32:$src),
4215 "vmread{l}\t{$src, $dst|$dst, $src}", []>, TB;
4216def VMWRITE64rm : I<0x79, MRMSrcMem, (outs GR64:$dst), (ins i64mem:$src),
4217 "vmwrite{q}\t{$src, $dst|$dst, $src}", []>, TB;
4218def VMWRITE64rr : I<0x79, MRMSrcReg, (outs GR64:$dst), (ins GR64:$src),
4219 "vmwrite{q}\t{$src, $dst|$dst, $src}", []>, TB;
4220def VMWRITE32rm : I<0x79, MRMSrcMem, (outs GR32:$dst), (ins i32mem:$src),
4221 "vmwrite{l}\t{$src, $dst|$dst, $src}", []>, TB;
4222def VMWRITE32rr : I<0x79, MRMSrcReg, (outs GR32:$dst), (ins GR32:$src),
4223 "vmwrite{l}\t{$src, $dst|$dst, $src}", []>, TB;
4224// 0F 01 C4
4225def VMXOFF : I<0x01, RawFrm, (outs), (ins), "vmxoff", []>, OpSize;
4226def VMXON : I<0xC7, MRM6m, (outs), (ins i64mem:$vmxon),
4227 "vmxon\t{$vmxon}", []>, XD;
Sean Callanan2eddf5d2009-09-16 21:55:34 +00004228
Andrew Lenharthe44f3902008-02-21 06:45:13 +00004229//===----------------------------------------------------------------------===//
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004230// Non-Instruction Patterns
4231//===----------------------------------------------------------------------===//
4232
Bill Wendlingfef06052008-09-16 21:48:12 +00004233// ConstantPool GlobalAddress, ExternalSymbol, and JumpTable
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004234def : Pat<(i32 (X86Wrapper tconstpool :$dst)), (MOV32ri tconstpool :$dst)>;
4235def : Pat<(i32 (X86Wrapper tjumptable :$dst)), (MOV32ri tjumptable :$dst)>;
Nate Begemanb52948972008-04-12 00:47:57 +00004236def : Pat<(i32 (X86Wrapper tglobaltlsaddr:$dst)),(MOV32ri tglobaltlsaddr:$dst)>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004237def : Pat<(i32 (X86Wrapper tglobaladdr :$dst)), (MOV32ri tglobaladdr :$dst)>;
4238def : Pat<(i32 (X86Wrapper texternalsym:$dst)), (MOV32ri texternalsym:$dst)>;
Dan Gohman064403e2009-10-30 01:28:02 +00004239def : Pat<(i32 (X86Wrapper tblockaddress:$dst)), (MOV32ri tblockaddress:$dst)>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004240
4241def : Pat<(add GR32:$src1, (X86Wrapper tconstpool:$src2)),
4242 (ADD32ri GR32:$src1, tconstpool:$src2)>;
4243def : Pat<(add GR32:$src1, (X86Wrapper tjumptable:$src2)),
4244 (ADD32ri GR32:$src1, tjumptable:$src2)>;
4245def : Pat<(add GR32:$src1, (X86Wrapper tglobaladdr :$src2)),
4246 (ADD32ri GR32:$src1, tglobaladdr:$src2)>;
4247def : Pat<(add GR32:$src1, (X86Wrapper texternalsym:$src2)),
4248 (ADD32ri GR32:$src1, texternalsym:$src2)>;
Dan Gohman064403e2009-10-30 01:28:02 +00004249def : Pat<(add GR32:$src1, (X86Wrapper tblockaddress:$src2)),
4250 (ADD32ri GR32:$src1, tblockaddress:$src2)>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004251
4252def : Pat<(store (i32 (X86Wrapper tglobaladdr:$src)), addr:$dst),
4253 (MOV32mi addr:$dst, tglobaladdr:$src)>;
4254def : Pat<(store (i32 (X86Wrapper texternalsym:$src)), addr:$dst),
4255 (MOV32mi addr:$dst, texternalsym:$src)>;
Dan Gohman064403e2009-10-30 01:28:02 +00004256def : Pat<(store (i32 (X86Wrapper tblockaddress:$src)), addr:$dst),
4257 (MOV32mi addr:$dst, tblockaddress:$src)>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004258
4259// Calls
Arnold Schwaighofere2d6bbb2007-10-11 19:40:01 +00004260// tailcall stuff
Arnold Schwaighofere2d6bbb2007-10-11 19:40:01 +00004261def : Pat<(X86tcret GR32:$dst, imm:$off),
4262 (TCRETURNri GR32:$dst, imm:$off)>;
4263
4264def : Pat<(X86tcret (i32 tglobaladdr:$dst), imm:$off),
4265 (TCRETURNdi texternalsym:$dst, imm:$off)>;
4266
4267def : Pat<(X86tcret (i32 texternalsym:$dst), imm:$off),
4268 (TCRETURNdi texternalsym:$dst, imm:$off)>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004269
Dan Gohmance5dbff2009-08-02 16:10:01 +00004270// Normal calls, with various flavors of addresses.
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004271def : Pat<(X86call (i32 tglobaladdr:$dst)),
4272 (CALLpcrel32 tglobaladdr:$dst)>;
4273def : Pat<(X86call (i32 texternalsym:$dst)),
4274 (CALLpcrel32 texternalsym:$dst)>;
Evan Cheng6d35a4d2009-05-20 04:53:57 +00004275def : Pat<(X86call (i32 imm:$dst)),
4276 (CALLpcrel32 imm:$dst)>, Requires<[CallImmAddr]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004277
4278// X86 specific add which produces a flag.
4279def : Pat<(addc GR32:$src1, GR32:$src2),
4280 (ADD32rr GR32:$src1, GR32:$src2)>;
4281def : Pat<(addc GR32:$src1, (load addr:$src2)),
4282 (ADD32rm GR32:$src1, addr:$src2)>;
4283def : Pat<(addc GR32:$src1, imm:$src2),
4284 (ADD32ri GR32:$src1, imm:$src2)>;
4285def : Pat<(addc GR32:$src1, i32immSExt8:$src2),
4286 (ADD32ri8 GR32:$src1, i32immSExt8:$src2)>;
4287
4288def : Pat<(subc GR32:$src1, GR32:$src2),
4289 (SUB32rr GR32:$src1, GR32:$src2)>;
4290def : Pat<(subc GR32:$src1, (load addr:$src2)),
4291 (SUB32rm GR32:$src1, addr:$src2)>;
4292def : Pat<(subc GR32:$src1, imm:$src2),
4293 (SUB32ri GR32:$src1, imm:$src2)>;
4294def : Pat<(subc GR32:$src1, i32immSExt8:$src2),
4295 (SUB32ri8 GR32:$src1, i32immSExt8:$src2)>;
4296
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004297// Comparisons.
4298
4299// TEST R,R is smaller than CMP R,0
Evan Cheng621216e2007-09-29 00:00:36 +00004300def : Pat<(parallel (X86cmp GR8:$src1, 0), (implicit EFLAGS)),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004301 (TEST8rr GR8:$src1, GR8:$src1)>;
Evan Cheng621216e2007-09-29 00:00:36 +00004302def : Pat<(parallel (X86cmp GR16:$src1, 0), (implicit EFLAGS)),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004303 (TEST16rr GR16:$src1, GR16:$src1)>;
Evan Cheng621216e2007-09-29 00:00:36 +00004304def : Pat<(parallel (X86cmp GR32:$src1, 0), (implicit EFLAGS)),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004305 (TEST32rr GR32:$src1, GR32:$src1)>;
4306
Dan Gohman0a3c5222009-01-07 01:00:24 +00004307// Conditional moves with folded loads with operands swapped and conditions
4308// inverted.
4309def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_B, EFLAGS),
4310 (CMOVAE16rm GR16:$src2, addr:$src1)>;
4311def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_B, EFLAGS),
4312 (CMOVAE32rm GR32:$src2, addr:$src1)>;
4313def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_AE, EFLAGS),
4314 (CMOVB16rm GR16:$src2, addr:$src1)>;
4315def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_AE, EFLAGS),
4316 (CMOVB32rm GR32:$src2, addr:$src1)>;
4317def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_E, EFLAGS),
4318 (CMOVNE16rm GR16:$src2, addr:$src1)>;
4319def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_E, EFLAGS),
4320 (CMOVNE32rm GR32:$src2, addr:$src1)>;
4321def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_NE, EFLAGS),
4322 (CMOVE16rm GR16:$src2, addr:$src1)>;
4323def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_NE, EFLAGS),
4324 (CMOVE32rm GR32:$src2, addr:$src1)>;
4325def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_BE, EFLAGS),
4326 (CMOVA16rm GR16:$src2, addr:$src1)>;
4327def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_BE, EFLAGS),
4328 (CMOVA32rm GR32:$src2, addr:$src1)>;
4329def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_A, EFLAGS),
4330 (CMOVBE16rm GR16:$src2, addr:$src1)>;
4331def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_A, EFLAGS),
4332 (CMOVBE32rm GR32:$src2, addr:$src1)>;
4333def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_L, EFLAGS),
4334 (CMOVGE16rm GR16:$src2, addr:$src1)>;
4335def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_L, EFLAGS),
4336 (CMOVGE32rm GR32:$src2, addr:$src1)>;
4337def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_GE, EFLAGS),
4338 (CMOVL16rm GR16:$src2, addr:$src1)>;
4339def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_GE, EFLAGS),
4340 (CMOVL32rm GR32:$src2, addr:$src1)>;
4341def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_LE, EFLAGS),
4342 (CMOVG16rm GR16:$src2, addr:$src1)>;
4343def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_LE, EFLAGS),
4344 (CMOVG32rm GR32:$src2, addr:$src1)>;
4345def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_G, EFLAGS),
4346 (CMOVLE16rm GR16:$src2, addr:$src1)>;
4347def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_G, EFLAGS),
4348 (CMOVLE32rm GR32:$src2, addr:$src1)>;
4349def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_P, EFLAGS),
4350 (CMOVNP16rm GR16:$src2, addr:$src1)>;
4351def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_P, EFLAGS),
4352 (CMOVNP32rm GR32:$src2, addr:$src1)>;
4353def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_NP, EFLAGS),
4354 (CMOVP16rm GR16:$src2, addr:$src1)>;
4355def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_NP, EFLAGS),
4356 (CMOVP32rm GR32:$src2, addr:$src1)>;
4357def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_S, EFLAGS),
4358 (CMOVNS16rm GR16:$src2, addr:$src1)>;
4359def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_S, EFLAGS),
4360 (CMOVNS32rm GR32:$src2, addr:$src1)>;
4361def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_NS, EFLAGS),
4362 (CMOVS16rm GR16:$src2, addr:$src1)>;
4363def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_NS, EFLAGS),
4364 (CMOVS32rm GR32:$src2, addr:$src1)>;
4365def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_O, EFLAGS),
4366 (CMOVNO16rm GR16:$src2, addr:$src1)>;
4367def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_O, EFLAGS),
4368 (CMOVNO32rm GR32:$src2, addr:$src1)>;
4369def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_NO, EFLAGS),
4370 (CMOVO16rm GR16:$src2, addr:$src1)>;
4371def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_NO, EFLAGS),
4372 (CMOVO32rm GR32:$src2, addr:$src1)>;
4373
Duncan Sands082524c2008-01-23 20:39:46 +00004374// zextload bool -> zextload byte
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004375def : Pat<(zextloadi8i1 addr:$src), (MOV8rm addr:$src)>;
4376def : Pat<(zextloadi16i1 addr:$src), (MOVZX16rm8 addr:$src)>;
4377def : Pat<(zextloadi32i1 addr:$src), (MOVZX32rm8 addr:$src)>;
4378
4379// extload bool -> extload byte
4380def : Pat<(extloadi8i1 addr:$src), (MOV8rm addr:$src)>;
Dan Gohman9959b052009-08-26 14:59:13 +00004381def : Pat<(extloadi16i1 addr:$src), (MOVZX16rm8 addr:$src)>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004382def : Pat<(extloadi32i1 addr:$src), (MOVZX32rm8 addr:$src)>;
Dan Gohman9959b052009-08-26 14:59:13 +00004383def : Pat<(extloadi16i8 addr:$src), (MOVZX16rm8 addr:$src)>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004384def : Pat<(extloadi32i8 addr:$src), (MOVZX32rm8 addr:$src)>;
4385def : Pat<(extloadi32i16 addr:$src), (MOVZX32rm16 addr:$src)>;
4386
Dan Gohman9959b052009-08-26 14:59:13 +00004387// anyext. Define these to do an explicit zero-extend to
4388// avoid partial-register updates.
4389def : Pat<(i16 (anyext GR8 :$src)), (MOVZX16rr8 GR8 :$src)>;
4390def : Pat<(i32 (anyext GR8 :$src)), (MOVZX32rr8 GR8 :$src)>;
4391def : Pat<(i32 (anyext GR16:$src)), (MOVZX32rr16 GR16:$src)>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004392
Evan Chengf2abee72007-12-13 00:43:27 +00004393// (and (i32 load), 255) -> (zextload i8)
Evan Cheng1e5e5452008-09-29 17:26:18 +00004394def : Pat<(i32 (and (nvloadi32 addr:$src), (i32 255))),
4395 (MOVZX32rm8 addr:$src)>;
4396def : Pat<(i32 (and (nvloadi32 addr:$src), (i32 65535))),
4397 (MOVZX32rm16 addr:$src)>;
Evan Chengf2abee72007-12-13 00:43:27 +00004398
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004399//===----------------------------------------------------------------------===//
4400// Some peepholes
4401//===----------------------------------------------------------------------===//
4402
Dan Gohman5a5e6e92008-10-17 01:33:43 +00004403// Odd encoding trick: -128 fits into an 8-bit immediate field while
4404// +128 doesn't, so in this special case use a sub instead of an add.
4405def : Pat<(add GR16:$src1, 128),
4406 (SUB16ri8 GR16:$src1, -128)>;
4407def : Pat<(store (add (loadi16 addr:$dst), 128), addr:$dst),
4408 (SUB16mi8 addr:$dst, -128)>;
4409def : Pat<(add GR32:$src1, 128),
4410 (SUB32ri8 GR32:$src1, -128)>;
4411def : Pat<(store (add (loadi32 addr:$dst), 128), addr:$dst),
4412 (SUB32mi8 addr:$dst, -128)>;
4413
Dan Gohman9203ab42008-07-30 18:09:17 +00004414// r & (2^16-1) ==> movz
4415def : Pat<(and GR32:$src1, 0xffff),
Dan Gohman744d4622009-04-13 16:09:41 +00004416 (MOVZX32rr16 (EXTRACT_SUBREG GR32:$src1, x86_subreg_16bit))>;
Dan Gohman5beb1ff2008-08-06 18:27:21 +00004417// r & (2^8-1) ==> movz
4418def : Pat<(and GR32:$src1, 0xff),
Anton Korobeynikovd9331212009-11-02 00:11:39 +00004419 (MOVZX32rr8 (EXTRACT_SUBREG (i32 (COPY_TO_REGCLASS GR32:$src1,
4420 GR32_ABCD)),
Dan Gohman744d4622009-04-13 16:09:41 +00004421 x86_subreg_8bit))>,
Dan Gohman5beb1ff2008-08-06 18:27:21 +00004422 Requires<[In32BitMode]>;
4423// r & (2^8-1) ==> movz
4424def : Pat<(and GR16:$src1, 0xff),
Anton Korobeynikovd9331212009-11-02 00:11:39 +00004425 (MOVZX16rr8 (EXTRACT_SUBREG (i16 (COPY_TO_REGCLASS GR16:$src1,
4426 GR16_ABCD)),
Dan Gohman744d4622009-04-13 16:09:41 +00004427 x86_subreg_8bit))>,
Dan Gohmandd612bb2008-08-20 21:27:32 +00004428 Requires<[In32BitMode]>;
4429
4430// sext_inreg patterns
4431def : Pat<(sext_inreg GR32:$src, i16),
Dan Gohman744d4622009-04-13 16:09:41 +00004432 (MOVSX32rr16 (EXTRACT_SUBREG GR32:$src, x86_subreg_16bit))>;
Dan Gohmandd612bb2008-08-20 21:27:32 +00004433def : Pat<(sext_inreg GR32:$src, i8),
Anton Korobeynikovd9331212009-11-02 00:11:39 +00004434 (MOVSX32rr8 (EXTRACT_SUBREG (i32 (COPY_TO_REGCLASS GR32:$src,
4435 GR32_ABCD)),
Dan Gohman744d4622009-04-13 16:09:41 +00004436 x86_subreg_8bit))>,
Dan Gohmandd612bb2008-08-20 21:27:32 +00004437 Requires<[In32BitMode]>;
4438def : Pat<(sext_inreg GR16:$src, i8),
Anton Korobeynikovd9331212009-11-02 00:11:39 +00004439 (MOVSX16rr8 (EXTRACT_SUBREG (i16 (COPY_TO_REGCLASS GR16:$src,
4440 GR16_ABCD)),
Dan Gohman744d4622009-04-13 16:09:41 +00004441 x86_subreg_8bit))>,
Dan Gohmandd612bb2008-08-20 21:27:32 +00004442 Requires<[In32BitMode]>;
4443
4444// trunc patterns
4445def : Pat<(i16 (trunc GR32:$src)),
Dan Gohman744d4622009-04-13 16:09:41 +00004446 (EXTRACT_SUBREG GR32:$src, x86_subreg_16bit)>;
Dan Gohmandd612bb2008-08-20 21:27:32 +00004447def : Pat<(i8 (trunc GR32:$src)),
Anton Korobeynikovd9331212009-11-02 00:11:39 +00004448 (EXTRACT_SUBREG (i32 (COPY_TO_REGCLASS GR32:$src, GR32_ABCD)),
Dan Gohman744d4622009-04-13 16:09:41 +00004449 x86_subreg_8bit)>,
Dan Gohmandd612bb2008-08-20 21:27:32 +00004450 Requires<[In32BitMode]>;
4451def : Pat<(i8 (trunc GR16:$src)),
Anton Korobeynikovd9331212009-11-02 00:11:39 +00004452 (EXTRACT_SUBREG (i16 (COPY_TO_REGCLASS GR16:$src, GR16_ABCD)),
Dan Gohman744d4622009-04-13 16:09:41 +00004453 x86_subreg_8bit)>,
4454 Requires<[In32BitMode]>;
4455
4456// h-register tricks
4457def : Pat<(i8 (trunc (srl_su GR16:$src, (i8 8)))),
Anton Korobeynikovd9331212009-11-02 00:11:39 +00004458 (EXTRACT_SUBREG (i32 (COPY_TO_REGCLASS GR16:$src, GR16_ABCD)),
Dan Gohman744d4622009-04-13 16:09:41 +00004459 x86_subreg_8bit_hi)>,
4460 Requires<[In32BitMode]>;
4461def : Pat<(i8 (trunc (srl_su GR32:$src, (i8 8)))),
Anton Korobeynikovd9331212009-11-02 00:11:39 +00004462 (EXTRACT_SUBREG (i16 (COPY_TO_REGCLASS GR32:$src, GR32_ABCD)),
Dan Gohman744d4622009-04-13 16:09:41 +00004463 x86_subreg_8bit_hi)>,
4464 Requires<[In32BitMode]>;
4465def : Pat<(srl_su GR16:$src, (i8 8)),
4466 (EXTRACT_SUBREG
4467 (MOVZX32rr8
Anton Korobeynikovd9331212009-11-02 00:11:39 +00004468 (EXTRACT_SUBREG (i16 (COPY_TO_REGCLASS GR16:$src, GR16_ABCD)),
Dan Gohman744d4622009-04-13 16:09:41 +00004469 x86_subreg_8bit_hi)),
4470 x86_subreg_16bit)>,
4471 Requires<[In32BitMode]>;
Evan Cheng957ca282009-05-29 01:44:43 +00004472def : Pat<(i32 (zext (srl_su GR16:$src, (i8 8)))),
Sean Callanan2c48df22009-12-18 00:01:26 +00004473 (MOVZX32rr8 (EXTRACT_SUBREG (i16 (COPY_TO_REGCLASS GR16:$src,
4474 GR16_ABCD)),
Evan Cheng957ca282009-05-29 01:44:43 +00004475 x86_subreg_8bit_hi))>,
4476 Requires<[In32BitMode]>;
Dan Gohman9959b052009-08-26 14:59:13 +00004477def : Pat<(i32 (anyext (srl_su GR16:$src, (i8 8)))),
Sean Callanan2c48df22009-12-18 00:01:26 +00004478 (MOVZX32rr8 (EXTRACT_SUBREG (i16 (COPY_TO_REGCLASS GR16:$src,
4479 GR16_ABCD)),
Dan Gohman9959b052009-08-26 14:59:13 +00004480 x86_subreg_8bit_hi))>,
4481 Requires<[In32BitMode]>;
Dan Gohman744d4622009-04-13 16:09:41 +00004482def : Pat<(and (srl_su GR32:$src, (i8 8)), (i32 255)),
Sean Callanan2c48df22009-12-18 00:01:26 +00004483 (MOVZX32rr8 (EXTRACT_SUBREG (i32 (COPY_TO_REGCLASS GR32:$src,
4484 GR32_ABCD)),
Dan Gohman744d4622009-04-13 16:09:41 +00004485 x86_subreg_8bit_hi))>,
Dan Gohman5beb1ff2008-08-06 18:27:21 +00004486 Requires<[In32BitMode]>;
Dan Gohman9203ab42008-07-30 18:09:17 +00004487
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004488// (shl x, 1) ==> (add x, x)
4489def : Pat<(shl GR8 :$src1, (i8 1)), (ADD8rr GR8 :$src1, GR8 :$src1)>;
4490def : Pat<(shl GR16:$src1, (i8 1)), (ADD16rr GR16:$src1, GR16:$src1)>;
4491def : Pat<(shl GR32:$src1, (i8 1)), (ADD32rr GR32:$src1, GR32:$src1)>;
4492
Evan Cheng76a64c72008-08-30 02:03:58 +00004493// (shl x (and y, 31)) ==> (shl x, y)
4494def : Pat<(shl GR8:$src1, (and CL:$amt, 31)),
4495 (SHL8rCL GR8:$src1)>;
4496def : Pat<(shl GR16:$src1, (and CL:$amt, 31)),
4497 (SHL16rCL GR16:$src1)>;
4498def : Pat<(shl GR32:$src1, (and CL:$amt, 31)),
4499 (SHL32rCL GR32:$src1)>;
4500def : Pat<(store (shl (loadi8 addr:$dst), (and CL:$amt, 31)), addr:$dst),
4501 (SHL8mCL addr:$dst)>;
4502def : Pat<(store (shl (loadi16 addr:$dst), (and CL:$amt, 31)), addr:$dst),
4503 (SHL16mCL addr:$dst)>;
4504def : Pat<(store (shl (loadi32 addr:$dst), (and CL:$amt, 31)), addr:$dst),
4505 (SHL32mCL addr:$dst)>;
4506
4507def : Pat<(srl GR8:$src1, (and CL:$amt, 31)),
4508 (SHR8rCL GR8:$src1)>;
4509def : Pat<(srl GR16:$src1, (and CL:$amt, 31)),
4510 (SHR16rCL GR16:$src1)>;
4511def : Pat<(srl GR32:$src1, (and CL:$amt, 31)),
4512 (SHR32rCL GR32:$src1)>;
4513def : Pat<(store (srl (loadi8 addr:$dst), (and CL:$amt, 31)), addr:$dst),
4514 (SHR8mCL addr:$dst)>;
4515def : Pat<(store (srl (loadi16 addr:$dst), (and CL:$amt, 31)), addr:$dst),
4516 (SHR16mCL addr:$dst)>;
4517def : Pat<(store (srl (loadi32 addr:$dst), (and CL:$amt, 31)), addr:$dst),
4518 (SHR32mCL addr:$dst)>;
4519
4520def : Pat<(sra GR8:$src1, (and CL:$amt, 31)),
4521 (SAR8rCL GR8:$src1)>;
4522def : Pat<(sra GR16:$src1, (and CL:$amt, 31)),
4523 (SAR16rCL GR16:$src1)>;
4524def : Pat<(sra GR32:$src1, (and CL:$amt, 31)),
4525 (SAR32rCL GR32:$src1)>;
4526def : Pat<(store (sra (loadi8 addr:$dst), (and CL:$amt, 31)), addr:$dst),
4527 (SAR8mCL addr:$dst)>;
4528def : Pat<(store (sra (loadi16 addr:$dst), (and CL:$amt, 31)), addr:$dst),
4529 (SAR16mCL addr:$dst)>;
4530def : Pat<(store (sra (loadi32 addr:$dst), (and CL:$amt, 31)), addr:$dst),
4531 (SAR32mCL addr:$dst)>;
4532
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004533// (or (x >> c) | (y << (32 - c))) ==> (shrd32 x, y, c)
4534def : Pat<(or (srl GR32:$src1, CL:$amt),
4535 (shl GR32:$src2, (sub 32, CL:$amt))),
4536 (SHRD32rrCL GR32:$src1, GR32:$src2)>;
4537
4538def : Pat<(store (or (srl (loadi32 addr:$dst), CL:$amt),
4539 (shl GR32:$src2, (sub 32, CL:$amt))), addr:$dst),
4540 (SHRD32mrCL addr:$dst, GR32:$src2)>;
4541
Dan Gohman921581d2008-10-17 01:23:35 +00004542def : Pat<(or (srl GR32:$src1, (i8 (trunc ECX:$amt))),
4543 (shl GR32:$src2, (i8 (trunc (sub 32, ECX:$amt))))),
4544 (SHRD32rrCL GR32:$src1, GR32:$src2)>;
4545
4546def : Pat<(store (or (srl (loadi32 addr:$dst), (i8 (trunc ECX:$amt))),
4547 (shl GR32:$src2, (i8 (trunc (sub 32, ECX:$amt))))),
4548 addr:$dst),
4549 (SHRD32mrCL addr:$dst, GR32:$src2)>;
4550
4551def : Pat<(shrd GR32:$src1, (i8 imm:$amt1), GR32:$src2, (i8 imm:$amt2)),
4552 (SHRD32rri8 GR32:$src1, GR32:$src2, (i8 imm:$amt1))>;
4553
4554def : Pat<(store (shrd (loadi32 addr:$dst), (i8 imm:$amt1),
4555 GR32:$src2, (i8 imm:$amt2)), addr:$dst),
4556 (SHRD32mri8 addr:$dst, GR32:$src2, (i8 imm:$amt1))>;
4557
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004558// (or (x << c) | (y >> (32 - c))) ==> (shld32 x, y, c)
4559def : Pat<(or (shl GR32:$src1, CL:$amt),
4560 (srl GR32:$src2, (sub 32, CL:$amt))),
4561 (SHLD32rrCL GR32:$src1, GR32:$src2)>;
4562
4563def : Pat<(store (or (shl (loadi32 addr:$dst), CL:$amt),
4564 (srl GR32:$src2, (sub 32, CL:$amt))), addr:$dst),
4565 (SHLD32mrCL addr:$dst, GR32:$src2)>;
4566
Dan Gohman921581d2008-10-17 01:23:35 +00004567def : Pat<(or (shl GR32:$src1, (i8 (trunc ECX:$amt))),
4568 (srl GR32:$src2, (i8 (trunc (sub 32, ECX:$amt))))),
4569 (SHLD32rrCL GR32:$src1, GR32:$src2)>;
4570
4571def : Pat<(store (or (shl (loadi32 addr:$dst), (i8 (trunc ECX:$amt))),
4572 (srl GR32:$src2, (i8 (trunc (sub 32, ECX:$amt))))),
4573 addr:$dst),
4574 (SHLD32mrCL addr:$dst, GR32:$src2)>;
4575
4576def : Pat<(shld GR32:$src1, (i8 imm:$amt1), GR32:$src2, (i8 imm:$amt2)),
4577 (SHLD32rri8 GR32:$src1, GR32:$src2, (i8 imm:$amt1))>;
4578
4579def : Pat<(store (shld (loadi32 addr:$dst), (i8 imm:$amt1),
4580 GR32:$src2, (i8 imm:$amt2)), addr:$dst),
4581 (SHLD32mri8 addr:$dst, GR32:$src2, (i8 imm:$amt1))>;
4582
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004583// (or (x >> c) | (y << (16 - c))) ==> (shrd16 x, y, c)
4584def : Pat<(or (srl GR16:$src1, CL:$amt),
4585 (shl GR16:$src2, (sub 16, CL:$amt))),
4586 (SHRD16rrCL GR16:$src1, GR16:$src2)>;
4587
4588def : Pat<(store (or (srl (loadi16 addr:$dst), CL:$amt),
4589 (shl GR16:$src2, (sub 16, CL:$amt))), addr:$dst),
4590 (SHRD16mrCL addr:$dst, GR16:$src2)>;
4591
Dan Gohman921581d2008-10-17 01:23:35 +00004592def : Pat<(or (srl GR16:$src1, (i8 (trunc CX:$amt))),
4593 (shl GR16:$src2, (i8 (trunc (sub 16, CX:$amt))))),
4594 (SHRD16rrCL GR16:$src1, GR16:$src2)>;
4595
4596def : Pat<(store (or (srl (loadi16 addr:$dst), (i8 (trunc CX:$amt))),
4597 (shl GR16:$src2, (i8 (trunc (sub 16, CX:$amt))))),
4598 addr:$dst),
4599 (SHRD16mrCL addr:$dst, GR16:$src2)>;
4600
4601def : Pat<(shrd GR16:$src1, (i8 imm:$amt1), GR16:$src2, (i8 imm:$amt2)),
4602 (SHRD16rri8 GR16:$src1, GR16:$src2, (i8 imm:$amt1))>;
4603
4604def : Pat<(store (shrd (loadi16 addr:$dst), (i8 imm:$amt1),
4605 GR16:$src2, (i8 imm:$amt2)), addr:$dst),
4606 (SHRD16mri8 addr:$dst, GR16:$src2, (i8 imm:$amt1))>;
4607
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004608// (or (x << c) | (y >> (16 - c))) ==> (shld16 x, y, c)
4609def : Pat<(or (shl GR16:$src1, CL:$amt),
4610 (srl GR16:$src2, (sub 16, CL:$amt))),
4611 (SHLD16rrCL GR16:$src1, GR16:$src2)>;
4612
4613def : Pat<(store (or (shl (loadi16 addr:$dst), CL:$amt),
4614 (srl GR16:$src2, (sub 16, CL:$amt))), addr:$dst),
4615 (SHLD16mrCL addr:$dst, GR16:$src2)>;
4616
Dan Gohman921581d2008-10-17 01:23:35 +00004617def : Pat<(or (shl GR16:$src1, (i8 (trunc CX:$amt))),
4618 (srl GR16:$src2, (i8 (trunc (sub 16, CX:$amt))))),
4619 (SHLD16rrCL GR16:$src1, GR16:$src2)>;
4620
4621def : Pat<(store (or (shl (loadi16 addr:$dst), (i8 (trunc CX:$amt))),
4622 (srl GR16:$src2, (i8 (trunc (sub 16, CX:$amt))))),
4623 addr:$dst),
4624 (SHLD16mrCL addr:$dst, GR16:$src2)>;
4625
4626def : Pat<(shld GR16:$src1, (i8 imm:$amt1), GR16:$src2, (i8 imm:$amt2)),
4627 (SHLD16rri8 GR16:$src1, GR16:$src2, (i8 imm:$amt1))>;
4628
4629def : Pat<(store (shld (loadi16 addr:$dst), (i8 imm:$amt1),
4630 GR16:$src2, (i8 imm:$amt2)), addr:$dst),
4631 (SHLD16mri8 addr:$dst, GR16:$src2, (i8 imm:$amt1))>;
4632
Evan Chengedeb1692009-12-16 00:53:11 +00004633// (anyext (setcc_carry)) -> (setcc_carry)
4634def : Pat<(i16 (anyext (i8 (X86setcc_c X86_COND_B, EFLAGS)))),
Evan Cheng834ae6b2009-12-15 00:53:42 +00004635 (SETB_C16r)>;
Evan Chengedeb1692009-12-16 00:53:11 +00004636def : Pat<(i32 (anyext (i8 (X86setcc_c X86_COND_B, EFLAGS)))),
Evan Cheng834ae6b2009-12-15 00:53:42 +00004637 (SETB_C32r)>;
4638
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004639//===----------------------------------------------------------------------===//
Dan Gohman99a12192009-03-04 19:44:21 +00004640// EFLAGS-defining Patterns
Bill Wendlingf5399032008-12-12 21:15:41 +00004641//===----------------------------------------------------------------------===//
4642
Dan Gohman99a12192009-03-04 19:44:21 +00004643// Register-Register Addition with EFLAGS result
4644def : Pat<(parallel (X86add_flag GR8:$src1, GR8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004645 (implicit EFLAGS)),
4646 (ADD8rr GR8:$src1, GR8:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00004647def : Pat<(parallel (X86add_flag GR16:$src1, GR16:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004648 (implicit EFLAGS)),
4649 (ADD16rr GR16:$src1, GR16:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00004650def : Pat<(parallel (X86add_flag GR32:$src1, GR32:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004651 (implicit EFLAGS)),
4652 (ADD32rr GR32:$src1, GR32:$src2)>;
4653
Dan Gohman99a12192009-03-04 19:44:21 +00004654// Register-Memory Addition with EFLAGS result
4655def : Pat<(parallel (X86add_flag GR8:$src1, (loadi8 addr:$src2)),
Bill Wendlingf5399032008-12-12 21:15:41 +00004656 (implicit EFLAGS)),
4657 (ADD8rm GR8:$src1, addr:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00004658def : Pat<(parallel (X86add_flag GR16:$src1, (loadi16 addr:$src2)),
Bill Wendlingf5399032008-12-12 21:15:41 +00004659 (implicit EFLAGS)),
4660 (ADD16rm GR16:$src1, addr:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00004661def : Pat<(parallel (X86add_flag GR32:$src1, (loadi32 addr:$src2)),
Bill Wendlingf5399032008-12-12 21:15:41 +00004662 (implicit EFLAGS)),
4663 (ADD32rm GR32:$src1, addr:$src2)>;
4664
Dan Gohman99a12192009-03-04 19:44:21 +00004665// Register-Integer Addition with EFLAGS result
4666def : Pat<(parallel (X86add_flag GR8:$src1, imm:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004667 (implicit EFLAGS)),
4668 (ADD8ri GR8:$src1, imm:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00004669def : Pat<(parallel (X86add_flag GR16:$src1, imm:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004670 (implicit EFLAGS)),
4671 (ADD16ri GR16:$src1, imm:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00004672def : Pat<(parallel (X86add_flag GR32:$src1, imm:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004673 (implicit EFLAGS)),
4674 (ADD32ri GR32:$src1, imm:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00004675def : Pat<(parallel (X86add_flag GR16:$src1, i16immSExt8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004676 (implicit EFLAGS)),
4677 (ADD16ri8 GR16:$src1, i16immSExt8:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00004678def : Pat<(parallel (X86add_flag GR32:$src1, i32immSExt8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004679 (implicit EFLAGS)),
4680 (ADD32ri8 GR32:$src1, i32immSExt8:$src2)>;
4681
Dan Gohman99a12192009-03-04 19:44:21 +00004682// Memory-Register Addition with EFLAGS result
4683def : Pat<(parallel (store (X86add_flag (loadi8 addr:$dst), GR8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004684 addr:$dst),
4685 (implicit EFLAGS)),
4686 (ADD8mr addr:$dst, GR8:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00004687def : Pat<(parallel (store (X86add_flag (loadi16 addr:$dst), GR16:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004688 addr:$dst),
4689 (implicit EFLAGS)),
4690 (ADD16mr addr:$dst, GR16:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00004691def : Pat<(parallel (store (X86add_flag (loadi32 addr:$dst), GR32:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004692 addr:$dst),
4693 (implicit EFLAGS)),
4694 (ADD32mr addr:$dst, GR32:$src2)>;
Dale Johannesen06b83f12009-05-18 17:44:15 +00004695
4696// Memory-Integer Addition with EFLAGS result
Dan Gohman99a12192009-03-04 19:44:21 +00004697def : Pat<(parallel (store (X86add_flag (loadi8 addr:$dst), imm:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004698 addr:$dst),
4699 (implicit EFLAGS)),
4700 (ADD8mi addr:$dst, imm:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00004701def : Pat<(parallel (store (X86add_flag (loadi16 addr:$dst), imm:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004702 addr:$dst),
4703 (implicit EFLAGS)),
4704 (ADD16mi addr:$dst, imm:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00004705def : Pat<(parallel (store (X86add_flag (loadi32 addr:$dst), imm:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004706 addr:$dst),
4707 (implicit EFLAGS)),
4708 (ADD32mi addr:$dst, imm:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00004709def : Pat<(parallel (store (X86add_flag (loadi16 addr:$dst), i16immSExt8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004710 addr:$dst),
4711 (implicit EFLAGS)),
4712 (ADD16mi8 addr:$dst, i16immSExt8:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00004713def : Pat<(parallel (store (X86add_flag (loadi32 addr:$dst), i32immSExt8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004714 addr:$dst),
4715 (implicit EFLAGS)),
4716 (ADD32mi8 addr:$dst, i32immSExt8:$src2)>;
4717
Dan Gohman99a12192009-03-04 19:44:21 +00004718// Register-Register Subtraction with EFLAGS result
4719def : Pat<(parallel (X86sub_flag GR8:$src1, GR8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004720 (implicit EFLAGS)),
4721 (SUB8rr GR8:$src1, GR8:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00004722def : Pat<(parallel (X86sub_flag GR16:$src1, GR16:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004723 (implicit EFLAGS)),
4724 (SUB16rr GR16:$src1, GR16:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00004725def : Pat<(parallel (X86sub_flag GR32:$src1, GR32:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004726 (implicit EFLAGS)),
4727 (SUB32rr GR32:$src1, GR32:$src2)>;
4728
Dan Gohman99a12192009-03-04 19:44:21 +00004729// Register-Memory Subtraction with EFLAGS result
4730def : Pat<(parallel (X86sub_flag GR8:$src1, (loadi8 addr:$src2)),
Bill Wendlingf5399032008-12-12 21:15:41 +00004731 (implicit EFLAGS)),
4732 (SUB8rm GR8:$src1, addr:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00004733def : Pat<(parallel (X86sub_flag GR16:$src1, (loadi16 addr:$src2)),
Bill Wendlingf5399032008-12-12 21:15:41 +00004734 (implicit EFLAGS)),
4735 (SUB16rm GR16:$src1, addr:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00004736def : Pat<(parallel (X86sub_flag GR32:$src1, (loadi32 addr:$src2)),
Bill Wendlingf5399032008-12-12 21:15:41 +00004737 (implicit EFLAGS)),
4738 (SUB32rm GR32:$src1, addr:$src2)>;
4739
Dan Gohman99a12192009-03-04 19:44:21 +00004740// Register-Integer Subtraction with EFLAGS result
4741def : Pat<(parallel (X86sub_flag GR8:$src1, imm:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004742 (implicit EFLAGS)),
4743 (SUB8ri GR8:$src1, imm:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00004744def : Pat<(parallel (X86sub_flag GR16:$src1, imm:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004745 (implicit EFLAGS)),
4746 (SUB16ri GR16:$src1, imm:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00004747def : Pat<(parallel (X86sub_flag GR32:$src1, imm:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004748 (implicit EFLAGS)),
4749 (SUB32ri GR32:$src1, imm:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00004750def : Pat<(parallel (X86sub_flag GR16:$src1, i16immSExt8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004751 (implicit EFLAGS)),
4752 (SUB16ri8 GR16:$src1, i16immSExt8:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00004753def : Pat<(parallel (X86sub_flag GR32:$src1, i32immSExt8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004754 (implicit EFLAGS)),
4755 (SUB32ri8 GR32:$src1, i32immSExt8:$src2)>;
4756
Dan Gohman99a12192009-03-04 19:44:21 +00004757// Memory-Register Subtraction with EFLAGS result
4758def : Pat<(parallel (store (X86sub_flag (loadi8 addr:$dst), GR8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004759 addr:$dst),
4760 (implicit EFLAGS)),
4761 (SUB8mr addr:$dst, GR8:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00004762def : Pat<(parallel (store (X86sub_flag (loadi16 addr:$dst), GR16:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004763 addr:$dst),
4764 (implicit EFLAGS)),
4765 (SUB16mr addr:$dst, GR16:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00004766def : Pat<(parallel (store (X86sub_flag (loadi32 addr:$dst), GR32:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004767 addr:$dst),
4768 (implicit EFLAGS)),
4769 (SUB32mr addr:$dst, GR32:$src2)>;
4770
Dan Gohman99a12192009-03-04 19:44:21 +00004771// Memory-Integer Subtraction with EFLAGS result
4772def : Pat<(parallel (store (X86sub_flag (loadi8 addr:$dst), imm:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004773 addr:$dst),
4774 (implicit EFLAGS)),
4775 (SUB8mi addr:$dst, imm:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00004776def : Pat<(parallel (store (X86sub_flag (loadi16 addr:$dst), imm:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004777 addr:$dst),
4778 (implicit EFLAGS)),
4779 (SUB16mi addr:$dst, imm:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00004780def : Pat<(parallel (store (X86sub_flag (loadi32 addr:$dst), imm:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004781 addr:$dst),
4782 (implicit EFLAGS)),
4783 (SUB32mi addr:$dst, imm:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00004784def : Pat<(parallel (store (X86sub_flag (loadi16 addr:$dst), i16immSExt8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004785 addr:$dst),
4786 (implicit EFLAGS)),
4787 (SUB16mi8 addr:$dst, i16immSExt8:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00004788def : Pat<(parallel (store (X86sub_flag (loadi32 addr:$dst), i32immSExt8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004789 addr:$dst),
4790 (implicit EFLAGS)),
4791 (SUB32mi8 addr:$dst, i32immSExt8:$src2)>;
4792
4793
Dan Gohman99a12192009-03-04 19:44:21 +00004794// Register-Register Signed Integer Multiply with EFLAGS result
4795def : Pat<(parallel (X86smul_flag GR16:$src1, GR16:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004796 (implicit EFLAGS)),
4797 (IMUL16rr GR16:$src1, GR16:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00004798def : Pat<(parallel (X86smul_flag GR32:$src1, GR32:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004799 (implicit EFLAGS)),
4800 (IMUL32rr GR32:$src1, GR32:$src2)>;
4801
Dan Gohman99a12192009-03-04 19:44:21 +00004802// Register-Memory Signed Integer Multiply with EFLAGS result
4803def : Pat<(parallel (X86smul_flag GR16:$src1, (loadi16 addr:$src2)),
Bill Wendlingf5399032008-12-12 21:15:41 +00004804 (implicit EFLAGS)),
4805 (IMUL16rm GR16:$src1, addr:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00004806def : Pat<(parallel (X86smul_flag GR32:$src1, (loadi32 addr:$src2)),
Bill Wendlingf5399032008-12-12 21:15:41 +00004807 (implicit EFLAGS)),
4808 (IMUL32rm GR32:$src1, addr:$src2)>;
4809
Dan Gohman99a12192009-03-04 19:44:21 +00004810// Register-Integer Signed Integer Multiply with EFLAGS result
4811def : Pat<(parallel (X86smul_flag GR16:$src1, imm:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004812 (implicit EFLAGS)),
4813 (IMUL16rri GR16:$src1, imm:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00004814def : Pat<(parallel (X86smul_flag GR32:$src1, imm:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004815 (implicit EFLAGS)),
4816 (IMUL32rri GR32:$src1, imm:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00004817def : Pat<(parallel (X86smul_flag GR16:$src1, i16immSExt8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004818 (implicit EFLAGS)),
4819 (IMUL16rri8 GR16:$src1, i16immSExt8:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00004820def : Pat<(parallel (X86smul_flag GR32:$src1, i32immSExt8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004821 (implicit EFLAGS)),
4822 (IMUL32rri8 GR32:$src1, i32immSExt8:$src2)>;
4823
Dan Gohman99a12192009-03-04 19:44:21 +00004824// Memory-Integer Signed Integer Multiply with EFLAGS result
4825def : Pat<(parallel (X86smul_flag (loadi16 addr:$src1), imm:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004826 (implicit EFLAGS)),
4827 (IMUL16rmi addr:$src1, imm:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00004828def : Pat<(parallel (X86smul_flag (loadi32 addr:$src1), imm:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004829 (implicit EFLAGS)),
4830 (IMUL32rmi addr:$src1, imm:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00004831def : Pat<(parallel (X86smul_flag (loadi16 addr:$src1), i16immSExt8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004832 (implicit EFLAGS)),
4833 (IMUL16rmi8 addr:$src1, i16immSExt8:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00004834def : Pat<(parallel (X86smul_flag (loadi32 addr:$src1), i32immSExt8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004835 (implicit EFLAGS)),
4836 (IMUL32rmi8 addr:$src1, i32immSExt8:$src2)>;
4837
Dan Gohman99a12192009-03-04 19:44:21 +00004838// Optimize multiply by 2 with EFLAGS result.
Evan Cheng00cf7932009-01-27 03:30:42 +00004839let AddedComplexity = 2 in {
Dan Gohman99a12192009-03-04 19:44:21 +00004840def : Pat<(parallel (X86smul_flag GR16:$src1, 2),
Evan Cheng00cf7932009-01-27 03:30:42 +00004841 (implicit EFLAGS)),
4842 (ADD16rr GR16:$src1, GR16:$src1)>;
4843
Dan Gohman99a12192009-03-04 19:44:21 +00004844def : Pat<(parallel (X86smul_flag GR32:$src1, 2),
Evan Cheng00cf7932009-01-27 03:30:42 +00004845 (implicit EFLAGS)),
4846 (ADD32rr GR32:$src1, GR32:$src1)>;
4847}
4848
Dan Gohman99a12192009-03-04 19:44:21 +00004849// INC and DEC with EFLAGS result. Note that these do not set CF.
4850def : Pat<(parallel (X86inc_flag GR8:$src), (implicit EFLAGS)),
4851 (INC8r GR8:$src)>;
4852def : Pat<(parallel (store (i8 (X86inc_flag (loadi8 addr:$dst))), addr:$dst),
4853 (implicit EFLAGS)),
4854 (INC8m addr:$dst)>;
4855def : Pat<(parallel (X86dec_flag GR8:$src), (implicit EFLAGS)),
4856 (DEC8r GR8:$src)>;
4857def : Pat<(parallel (store (i8 (X86dec_flag (loadi8 addr:$dst))), addr:$dst),
4858 (implicit EFLAGS)),
4859 (DEC8m addr:$dst)>;
4860
4861def : Pat<(parallel (X86inc_flag GR16:$src), (implicit EFLAGS)),
Dan Gohmaneebcac72009-03-05 21:32:23 +00004862 (INC16r GR16:$src)>, Requires<[In32BitMode]>;
Dan Gohman99a12192009-03-04 19:44:21 +00004863def : Pat<(parallel (store (i16 (X86inc_flag (loadi16 addr:$dst))), addr:$dst),
4864 (implicit EFLAGS)),
Dan Gohmaneebcac72009-03-05 21:32:23 +00004865 (INC16m addr:$dst)>, Requires<[In32BitMode]>;
Dan Gohman99a12192009-03-04 19:44:21 +00004866def : Pat<(parallel (X86dec_flag GR16:$src), (implicit EFLAGS)),
Dan Gohmaneebcac72009-03-05 21:32:23 +00004867 (DEC16r GR16:$src)>, Requires<[In32BitMode]>;
Dan Gohman99a12192009-03-04 19:44:21 +00004868def : Pat<(parallel (store (i16 (X86dec_flag (loadi16 addr:$dst))), addr:$dst),
4869 (implicit EFLAGS)),
Dan Gohmaneebcac72009-03-05 21:32:23 +00004870 (DEC16m addr:$dst)>, Requires<[In32BitMode]>;
Dan Gohman99a12192009-03-04 19:44:21 +00004871
4872def : Pat<(parallel (X86inc_flag GR32:$src), (implicit EFLAGS)),
Dan Gohmaneebcac72009-03-05 21:32:23 +00004873 (INC32r GR32:$src)>, Requires<[In32BitMode]>;
Dan Gohman99a12192009-03-04 19:44:21 +00004874def : Pat<(parallel (store (i32 (X86inc_flag (loadi32 addr:$dst))), addr:$dst),
4875 (implicit EFLAGS)),
Dan Gohmaneebcac72009-03-05 21:32:23 +00004876 (INC32m addr:$dst)>, Requires<[In32BitMode]>;
Dan Gohman99a12192009-03-04 19:44:21 +00004877def : Pat<(parallel (X86dec_flag GR32:$src), (implicit EFLAGS)),
Dan Gohmaneebcac72009-03-05 21:32:23 +00004878 (DEC32r GR32:$src)>, Requires<[In32BitMode]>;
Dan Gohman99a12192009-03-04 19:44:21 +00004879def : Pat<(parallel (store (i32 (X86dec_flag (loadi32 addr:$dst))), addr:$dst),
4880 (implicit EFLAGS)),
Dan Gohmaneebcac72009-03-05 21:32:23 +00004881 (DEC32m addr:$dst)>, Requires<[In32BitMode]>;
Dan Gohman99a12192009-03-04 19:44:21 +00004882
Dan Gohman12e03292009-09-18 19:59:53 +00004883// Register-Register Or with EFLAGS result
4884def : Pat<(parallel (X86or_flag GR8:$src1, GR8:$src2),
4885 (implicit EFLAGS)),
4886 (OR8rr GR8:$src1, GR8:$src2)>;
4887def : Pat<(parallel (X86or_flag GR16:$src1, GR16:$src2),
4888 (implicit EFLAGS)),
4889 (OR16rr GR16:$src1, GR16:$src2)>;
4890def : Pat<(parallel (X86or_flag GR32:$src1, GR32:$src2),
4891 (implicit EFLAGS)),
4892 (OR32rr GR32:$src1, GR32:$src2)>;
4893
4894// Register-Memory Or with EFLAGS result
4895def : Pat<(parallel (X86or_flag GR8:$src1, (loadi8 addr:$src2)),
4896 (implicit EFLAGS)),
4897 (OR8rm GR8:$src1, addr:$src2)>;
4898def : Pat<(parallel (X86or_flag GR16:$src1, (loadi16 addr:$src2)),
4899 (implicit EFLAGS)),
4900 (OR16rm GR16:$src1, addr:$src2)>;
4901def : Pat<(parallel (X86or_flag GR32:$src1, (loadi32 addr:$src2)),
4902 (implicit EFLAGS)),
4903 (OR32rm GR32:$src1, addr:$src2)>;
4904
4905// Register-Integer Or with EFLAGS result
4906def : Pat<(parallel (X86or_flag GR8:$src1, imm:$src2),
4907 (implicit EFLAGS)),
4908 (OR8ri GR8:$src1, imm:$src2)>;
4909def : Pat<(parallel (X86or_flag GR16:$src1, imm:$src2),
4910 (implicit EFLAGS)),
4911 (OR16ri GR16:$src1, imm:$src2)>;
4912def : Pat<(parallel (X86or_flag GR32:$src1, imm:$src2),
4913 (implicit EFLAGS)),
4914 (OR32ri GR32:$src1, imm:$src2)>;
4915def : Pat<(parallel (X86or_flag GR16:$src1, i16immSExt8:$src2),
4916 (implicit EFLAGS)),
4917 (OR16ri8 GR16:$src1, i16immSExt8:$src2)>;
4918def : Pat<(parallel (X86or_flag GR32:$src1, i32immSExt8:$src2),
4919 (implicit EFLAGS)),
4920 (OR32ri8 GR32:$src1, i32immSExt8:$src2)>;
4921
4922// Memory-Register Or with EFLAGS result
4923def : Pat<(parallel (store (X86or_flag (loadi8 addr:$dst), GR8:$src2),
4924 addr:$dst),
4925 (implicit EFLAGS)),
4926 (OR8mr addr:$dst, GR8:$src2)>;
4927def : Pat<(parallel (store (X86or_flag (loadi16 addr:$dst), GR16:$src2),
4928 addr:$dst),
4929 (implicit EFLAGS)),
4930 (OR16mr addr:$dst, GR16:$src2)>;
4931def : Pat<(parallel (store (X86or_flag (loadi32 addr:$dst), GR32:$src2),
4932 addr:$dst),
4933 (implicit EFLAGS)),
4934 (OR32mr addr:$dst, GR32:$src2)>;
4935
4936// Memory-Integer Or with EFLAGS result
4937def : Pat<(parallel (store (X86or_flag (loadi8 addr:$dst), imm:$src2),
4938 addr:$dst),
4939 (implicit EFLAGS)),
4940 (OR8mi addr:$dst, imm:$src2)>;
4941def : Pat<(parallel (store (X86or_flag (loadi16 addr:$dst), imm:$src2),
4942 addr:$dst),
4943 (implicit EFLAGS)),
4944 (OR16mi addr:$dst, imm:$src2)>;
4945def : Pat<(parallel (store (X86or_flag (loadi32 addr:$dst), imm:$src2),
4946 addr:$dst),
4947 (implicit EFLAGS)),
4948 (OR32mi addr:$dst, imm:$src2)>;
4949def : Pat<(parallel (store (X86or_flag (loadi16 addr:$dst), i16immSExt8:$src2),
4950 addr:$dst),
4951 (implicit EFLAGS)),
4952 (OR16mi8 addr:$dst, i16immSExt8:$src2)>;
4953def : Pat<(parallel (store (X86or_flag (loadi32 addr:$dst), i32immSExt8:$src2),
4954 addr:$dst),
4955 (implicit EFLAGS)),
4956 (OR32mi8 addr:$dst, i32immSExt8:$src2)>;
4957
4958// Register-Register XOr with EFLAGS result
4959def : Pat<(parallel (X86xor_flag GR8:$src1, GR8:$src2),
4960 (implicit EFLAGS)),
4961 (XOR8rr GR8:$src1, GR8:$src2)>;
4962def : Pat<(parallel (X86xor_flag GR16:$src1, GR16:$src2),
4963 (implicit EFLAGS)),
4964 (XOR16rr GR16:$src1, GR16:$src2)>;
4965def : Pat<(parallel (X86xor_flag GR32:$src1, GR32:$src2),
4966 (implicit EFLAGS)),
4967 (XOR32rr GR32:$src1, GR32:$src2)>;
4968
4969// Register-Memory XOr with EFLAGS result
4970def : Pat<(parallel (X86xor_flag GR8:$src1, (loadi8 addr:$src2)),
4971 (implicit EFLAGS)),
4972 (XOR8rm GR8:$src1, addr:$src2)>;
4973def : Pat<(parallel (X86xor_flag GR16:$src1, (loadi16 addr:$src2)),
4974 (implicit EFLAGS)),
4975 (XOR16rm GR16:$src1, addr:$src2)>;
4976def : Pat<(parallel (X86xor_flag GR32:$src1, (loadi32 addr:$src2)),
4977 (implicit EFLAGS)),
4978 (XOR32rm GR32:$src1, addr:$src2)>;
4979
4980// Register-Integer XOr with EFLAGS result
4981def : Pat<(parallel (X86xor_flag GR8:$src1, imm:$src2),
4982 (implicit EFLAGS)),
4983 (XOR8ri GR8:$src1, imm:$src2)>;
4984def : Pat<(parallel (X86xor_flag GR16:$src1, imm:$src2),
4985 (implicit EFLAGS)),
4986 (XOR16ri GR16:$src1, imm:$src2)>;
4987def : Pat<(parallel (X86xor_flag GR32:$src1, imm:$src2),
4988 (implicit EFLAGS)),
4989 (XOR32ri GR32:$src1, imm:$src2)>;
4990def : Pat<(parallel (X86xor_flag GR16:$src1, i16immSExt8:$src2),
4991 (implicit EFLAGS)),
4992 (XOR16ri8 GR16:$src1, i16immSExt8:$src2)>;
4993def : Pat<(parallel (X86xor_flag GR32:$src1, i32immSExt8:$src2),
4994 (implicit EFLAGS)),
4995 (XOR32ri8 GR32:$src1, i32immSExt8:$src2)>;
4996
4997// Memory-Register XOr with EFLAGS result
4998def : Pat<(parallel (store (X86xor_flag (loadi8 addr:$dst), GR8:$src2),
4999 addr:$dst),
5000 (implicit EFLAGS)),
5001 (XOR8mr addr:$dst, GR8:$src2)>;
5002def : Pat<(parallel (store (X86xor_flag (loadi16 addr:$dst), GR16:$src2),
5003 addr:$dst),
5004 (implicit EFLAGS)),
5005 (XOR16mr addr:$dst, GR16:$src2)>;
5006def : Pat<(parallel (store (X86xor_flag (loadi32 addr:$dst), GR32:$src2),
5007 addr:$dst),
5008 (implicit EFLAGS)),
5009 (XOR32mr addr:$dst, GR32:$src2)>;
5010
5011// Memory-Integer XOr with EFLAGS result
5012def : Pat<(parallel (store (X86xor_flag (loadi8 addr:$dst), imm:$src2),
5013 addr:$dst),
5014 (implicit EFLAGS)),
5015 (XOR8mi addr:$dst, imm:$src2)>;
5016def : Pat<(parallel (store (X86xor_flag (loadi16 addr:$dst), imm:$src2),
5017 addr:$dst),
5018 (implicit EFLAGS)),
5019 (XOR16mi addr:$dst, imm:$src2)>;
5020def : Pat<(parallel (store (X86xor_flag (loadi32 addr:$dst), imm:$src2),
5021 addr:$dst),
5022 (implicit EFLAGS)),
5023 (XOR32mi addr:$dst, imm:$src2)>;
5024def : Pat<(parallel (store (X86xor_flag (loadi16 addr:$dst), i16immSExt8:$src2),
5025 addr:$dst),
5026 (implicit EFLAGS)),
5027 (XOR16mi8 addr:$dst, i16immSExt8:$src2)>;
5028def : Pat<(parallel (store (X86xor_flag (loadi32 addr:$dst), i32immSExt8:$src2),
5029 addr:$dst),
5030 (implicit EFLAGS)),
5031 (XOR32mi8 addr:$dst, i32immSExt8:$src2)>;
5032
5033// Register-Register And with EFLAGS result
5034def : Pat<(parallel (X86and_flag GR8:$src1, GR8:$src2),
5035 (implicit EFLAGS)),
5036 (AND8rr GR8:$src1, GR8:$src2)>;
5037def : Pat<(parallel (X86and_flag GR16:$src1, GR16:$src2),
5038 (implicit EFLAGS)),
5039 (AND16rr GR16:$src1, GR16:$src2)>;
5040def : Pat<(parallel (X86and_flag GR32:$src1, GR32:$src2),
5041 (implicit EFLAGS)),
5042 (AND32rr GR32:$src1, GR32:$src2)>;
5043
5044// Register-Memory And with EFLAGS result
5045def : Pat<(parallel (X86and_flag GR8:$src1, (loadi8 addr:$src2)),
5046 (implicit EFLAGS)),
5047 (AND8rm GR8:$src1, addr:$src2)>;
5048def : Pat<(parallel (X86and_flag GR16:$src1, (loadi16 addr:$src2)),
5049 (implicit EFLAGS)),
5050 (AND16rm GR16:$src1, addr:$src2)>;
5051def : Pat<(parallel (X86and_flag GR32:$src1, (loadi32 addr:$src2)),
5052 (implicit EFLAGS)),
5053 (AND32rm GR32:$src1, addr:$src2)>;
5054
5055// Register-Integer And with EFLAGS result
5056def : Pat<(parallel (X86and_flag GR8:$src1, imm:$src2),
5057 (implicit EFLAGS)),
5058 (AND8ri GR8:$src1, imm:$src2)>;
5059def : Pat<(parallel (X86and_flag GR16:$src1, imm:$src2),
5060 (implicit EFLAGS)),
5061 (AND16ri GR16:$src1, imm:$src2)>;
5062def : Pat<(parallel (X86and_flag GR32:$src1, imm:$src2),
5063 (implicit EFLAGS)),
5064 (AND32ri GR32:$src1, imm:$src2)>;
5065def : Pat<(parallel (X86and_flag GR16:$src1, i16immSExt8:$src2),
5066 (implicit EFLAGS)),
5067 (AND16ri8 GR16:$src1, i16immSExt8:$src2)>;
5068def : Pat<(parallel (X86and_flag GR32:$src1, i32immSExt8:$src2),
5069 (implicit EFLAGS)),
5070 (AND32ri8 GR32:$src1, i32immSExt8:$src2)>;
5071
5072// Memory-Register And with EFLAGS result
5073def : Pat<(parallel (store (X86and_flag (loadi8 addr:$dst), GR8:$src2),
5074 addr:$dst),
5075 (implicit EFLAGS)),
5076 (AND8mr addr:$dst, GR8:$src2)>;
5077def : Pat<(parallel (store (X86and_flag (loadi16 addr:$dst), GR16:$src2),
5078 addr:$dst),
5079 (implicit EFLAGS)),
5080 (AND16mr addr:$dst, GR16:$src2)>;
5081def : Pat<(parallel (store (X86and_flag (loadi32 addr:$dst), GR32:$src2),
5082 addr:$dst),
5083 (implicit EFLAGS)),
5084 (AND32mr addr:$dst, GR32:$src2)>;
5085
5086// Memory-Integer And with EFLAGS result
5087def : Pat<(parallel (store (X86and_flag (loadi8 addr:$dst), imm:$src2),
5088 addr:$dst),
5089 (implicit EFLAGS)),
5090 (AND8mi addr:$dst, imm:$src2)>;
5091def : Pat<(parallel (store (X86and_flag (loadi16 addr:$dst), imm:$src2),
5092 addr:$dst),
5093 (implicit EFLAGS)),
5094 (AND16mi addr:$dst, imm:$src2)>;
5095def : Pat<(parallel (store (X86and_flag (loadi32 addr:$dst), imm:$src2),
5096 addr:$dst),
5097 (implicit EFLAGS)),
5098 (AND32mi addr:$dst, imm:$src2)>;
5099def : Pat<(parallel (store (X86and_flag (loadi16 addr:$dst), i16immSExt8:$src2),
5100 addr:$dst),
5101 (implicit EFLAGS)),
5102 (AND16mi8 addr:$dst, i16immSExt8:$src2)>;
5103def : Pat<(parallel (store (X86and_flag (loadi32 addr:$dst), i32immSExt8:$src2),
5104 addr:$dst),
5105 (implicit EFLAGS)),
5106 (AND32mi8 addr:$dst, i32immSExt8:$src2)>;
5107
Dan Gohmane84197b2009-09-03 17:18:51 +00005108// -disable-16bit support.
5109def : Pat<(truncstorei16 (i32 imm:$src), addr:$dst),
5110 (MOV16mi addr:$dst, imm:$src)>;
5111def : Pat<(truncstorei16 GR32:$src, addr:$dst),
5112 (MOV16mr addr:$dst, (EXTRACT_SUBREG GR32:$src, x86_subreg_16bit))>;
5113def : Pat<(i32 (sextloadi16 addr:$dst)),
5114 (MOVSX32rm16 addr:$dst)>;
5115def : Pat<(i32 (zextloadi16 addr:$dst)),
5116 (MOVZX32rm16 addr:$dst)>;
5117def : Pat<(i32 (extloadi16 addr:$dst)),
5118 (MOVZX32rm16 addr:$dst)>;
5119
Bill Wendlingf5399032008-12-12 21:15:41 +00005120//===----------------------------------------------------------------------===//
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005121// Floating Point Stack Support
5122//===----------------------------------------------------------------------===//
5123
5124include "X86InstrFPStack.td"
5125
5126//===----------------------------------------------------------------------===//
Evan Cheng86ab7d32007-07-31 08:04:03 +00005127// X86-64 Support
5128//===----------------------------------------------------------------------===//
5129
Chris Lattner2de8d2b2008-01-10 05:50:42 +00005130include "X86Instr64bit.td"
Evan Cheng86ab7d32007-07-31 08:04:03 +00005131
5132//===----------------------------------------------------------------------===//
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005133// XMM Floating point support (requires SSE / SSE2)
5134//===----------------------------------------------------------------------===//
5135
5136include "X86InstrSSE.td"
Evan Cheng5e4d1e72008-04-25 18:19:54 +00005137
5138//===----------------------------------------------------------------------===//
5139// MMX and XMM Packed Integer support (requires MMX, SSE, and SSE2)
5140//===----------------------------------------------------------------------===//
5141
5142include "X86InstrMMX.td"