blob: 88dbf67ee6de72d070bd2b485687d5a2eeb885c1 [file] [log] [blame]
Arnold Schwaighofer373e8652007-10-12 21:30:57 +00001//===- X86InstrInfo.td - Describe the X86 Instruction Set --*- tablegen -*-===//
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>]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +000044
Andrew Lenharth7dfe23f2008-03-01 21:52:34 +000045def SDTX86cas : SDTypeProfile<0, 3, [SDTCisPtrTy<0>, SDTCisInt<1>,
46 SDTCisVT<2, i8>]>;
Andrew Lenharth81580822008-03-05 01:15:49 +000047def SDTX86cas8 : SDTypeProfile<0, 1, [SDTCisPtrTy<0>]>;
Andrew Lenharth7dfe23f2008-03-01 21:52:34 +000048
Dale Johannesenf160d802008-10-02 18:53:47 +000049def SDTX86atomicBinary : SDTypeProfile<2, 3, [SDTCisInt<0>, SDTCisInt<1>,
50 SDTCisPtrTy<2>, SDTCisInt<3>,SDTCisInt<4>]>;
Chris Lattnerb56cc342008-03-11 03:23:40 +000051def SDTX86Ret : SDTypeProfile<0, -1, [SDTCisVT<0, i16>]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +000052
Sean Callanan2c8a2592009-06-23 23:25:37 +000053def SDT_X86CallSeqStart : SDCallSeqStart<[SDTCisVT<0, i32>]>;
54def SDT_X86CallSeqEnd : SDCallSeqEnd<[SDTCisVT<0, i32>,
55 SDTCisVT<1, i32>]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +000056
Dan Gohman3329ffe2008-05-29 19:57:41 +000057def SDT_X86Call : SDTypeProfile<0, -1, [SDTCisVT<0, iPTR>]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +000058
Dan Gohman34228bf2009-08-15 01:38:56 +000059def SDT_X86VASTART_SAVE_XMM_REGS : SDTypeProfile<0, -1, [SDTCisVT<0, i8>,
60 SDTCisVT<1, iPTR>,
61 SDTCisVT<2, iPTR>]>;
62
Dan Gohmanf17a25c2007-07-18 16:29:46 +000063def SDTX86RepStr : SDTypeProfile<0, 1, [SDTCisVT<0, OtherVT>]>;
64
65def SDTX86RdTsc : SDTypeProfile<0, 0, []>;
66
67def SDTX86Wrapper : SDTypeProfile<1, 1, [SDTCisSameAs<0, 1>, SDTCisPtrTy<0>]>;
68
Rafael Espindolaaf759ab2009-04-17 14:35:58 +000069def SDT_X86TLSADDR : SDTypeProfile<0, 1, [SDTCisInt<0>]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +000070
Rafael Espindolabca99f72009-04-08 21:14:34 +000071def SDT_X86SegmentBaseAddress : SDTypeProfile<1, 1, [SDTCisPtrTy<0>]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +000072
73def SDT_X86EHRET : SDTypeProfile<0, 1, [SDTCisInt<0>]>;
74
Arnold Schwaighofere2d6bbb2007-10-11 19:40:01 +000075def SDT_X86TCRET : SDTypeProfile<0, 2, [SDTCisPtrTy<0>, SDTCisVT<1, i32>]>;
76
Evan Cheng48679f42007-12-14 02:13:44 +000077def X86bsf : SDNode<"X86ISD::BSF", SDTIntUnaryOp>;
78def X86bsr : SDNode<"X86ISD::BSR", SDTIntUnaryOp>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +000079def X86shld : SDNode<"X86ISD::SHLD", SDTIntShiftDOp>;
80def X86shrd : SDNode<"X86ISD::SHRD", SDTIntShiftDOp>;
81
Evan Cheng621216e2007-09-29 00:00:36 +000082def X86cmp : SDNode<"X86ISD::CMP" , SDTX86CmpTest>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +000083
Dan Gohman7fe9b7f2008-12-23 22:45:23 +000084def X86bt : SDNode<"X86ISD::BT", SDTX86CmpTest>;
85
Evan Cheng621216e2007-09-29 00:00:36 +000086def X86cmov : SDNode<"X86ISD::CMOV", SDTX86Cmov>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +000087def X86brcond : SDNode<"X86ISD::BRCOND", SDTX86BrCond,
Evan Cheng950aac02007-09-25 01:57:46 +000088 [SDNPHasChain]>;
Evan Cheng621216e2007-09-29 00:00:36 +000089def X86setcc : SDNode<"X86ISD::SETCC", SDTX86SetCC>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +000090
Andrew Lenharth7dfe23f2008-03-01 21:52:34 +000091def X86cas : SDNode<"X86ISD::LCMPXCHG_DAG", SDTX86cas,
92 [SDNPHasChain, SDNPInFlag, SDNPOutFlag, SDNPMayStore,
93 SDNPMayLoad]>;
Andrew Lenharth81580822008-03-05 01:15:49 +000094def X86cas8 : SDNode<"X86ISD::LCMPXCHG8_DAG", SDTX86cas8,
95 [SDNPHasChain, SDNPInFlag, SDNPOutFlag, SDNPMayStore,
96 SDNPMayLoad]>;
Dale Johannesenf160d802008-10-02 18:53:47 +000097def X86AtomAdd64 : SDNode<"X86ISD::ATOMADD64_DAG", SDTX86atomicBinary,
98 [SDNPHasChain, SDNPMayStore,
99 SDNPMayLoad, SDNPMemOperand]>;
100def X86AtomSub64 : SDNode<"X86ISD::ATOMSUB64_DAG", SDTX86atomicBinary,
101 [SDNPHasChain, SDNPMayStore,
102 SDNPMayLoad, SDNPMemOperand]>;
103def X86AtomOr64 : SDNode<"X86ISD::ATOMOR64_DAG", SDTX86atomicBinary,
104 [SDNPHasChain, SDNPMayStore,
105 SDNPMayLoad, SDNPMemOperand]>;
106def X86AtomXor64 : SDNode<"X86ISD::ATOMXOR64_DAG", SDTX86atomicBinary,
107 [SDNPHasChain, SDNPMayStore,
108 SDNPMayLoad, SDNPMemOperand]>;
109def X86AtomAnd64 : SDNode<"X86ISD::ATOMAND64_DAG", SDTX86atomicBinary,
110 [SDNPHasChain, SDNPMayStore,
111 SDNPMayLoad, SDNPMemOperand]>;
112def X86AtomNand64 : SDNode<"X86ISD::ATOMNAND64_DAG", SDTX86atomicBinary,
113 [SDNPHasChain, SDNPMayStore,
114 SDNPMayLoad, SDNPMemOperand]>;
Dale Johannesen51c58ee2008-10-03 22:25:52 +0000115def X86AtomSwap64 : SDNode<"X86ISD::ATOMSWAP64_DAG", SDTX86atomicBinary,
116 [SDNPHasChain, SDNPMayStore,
117 SDNPMayLoad, SDNPMemOperand]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000118def X86retflag : SDNode<"X86ISD::RET_FLAG", SDTX86Ret,
119 [SDNPHasChain, SDNPOptInFlag]>;
120
Dan Gohman34228bf2009-08-15 01:38:56 +0000121def X86vastart_save_xmm_regs :
122 SDNode<"X86ISD::VASTART_SAVE_XMM_REGS",
123 SDT_X86VASTART_SAVE_XMM_REGS,
124 [SDNPHasChain]>;
125
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000126def X86callseq_start :
127 SDNode<"ISD::CALLSEQ_START", SDT_X86CallSeqStart,
128 [SDNPHasChain, SDNPOutFlag]>;
129def X86callseq_end :
130 SDNode<"ISD::CALLSEQ_END", SDT_X86CallSeqEnd,
Arnold Schwaighofere2d6bbb2007-10-11 19:40:01 +0000131 [SDNPHasChain, SDNPOptInFlag, SDNPOutFlag]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000132
133def X86call : SDNode<"X86ISD::CALL", SDT_X86Call,
134 [SDNPHasChain, SDNPOutFlag, SDNPOptInFlag]>;
135
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000136def X86rep_stos: SDNode<"X86ISD::REP_STOS", SDTX86RepStr,
Chris Lattnerca4e0fe2008-01-10 05:12:37 +0000137 [SDNPHasChain, SDNPInFlag, SDNPOutFlag, SDNPMayStore]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000138def X86rep_movs: SDNode<"X86ISD::REP_MOVS", SDTX86RepStr,
Chris Lattnerca4e0fe2008-01-10 05:12:37 +0000139 [SDNPHasChain, SDNPInFlag, SDNPOutFlag, SDNPMayStore,
140 SDNPMayLoad]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000141
142def X86rdtsc : SDNode<"X86ISD::RDTSC_DAG",SDTX86RdTsc,
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000143 [SDNPHasChain, SDNPOutFlag, SDNPSideEffect]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000144
145def X86Wrapper : SDNode<"X86ISD::Wrapper", SDTX86Wrapper>;
146def X86WrapperRIP : SDNode<"X86ISD::WrapperRIP", SDTX86Wrapper>;
147
148def X86tlsaddr : SDNode<"X86ISD::TLSADDR", SDT_X86TLSADDR,
Anton Korobeynikov4fbf00b2008-05-04 21:36:32 +0000149 [SDNPHasChain, SDNPOptInFlag, SDNPOutFlag]>;
Rafael Espindolabca99f72009-04-08 21:14:34 +0000150def X86SegmentBaseAddress : SDNode<"X86ISD::SegmentBaseAddress",
151 SDT_X86SegmentBaseAddress, []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000152
153def X86ehret : SDNode<"X86ISD::EH_RETURN", SDT_X86EHRET,
154 [SDNPHasChain]>;
155
Arnold Schwaighofere2d6bbb2007-10-11 19:40:01 +0000156def X86tcret : SDNode<"X86ISD::TC_RETURN", SDT_X86TCRET,
157 [SDNPHasChain, SDNPOptInFlag]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000158
Dan Gohman99a12192009-03-04 19:44:21 +0000159def X86add_flag : SDNode<"X86ISD::ADD", SDTBinaryArithWithFlags>;
160def X86sub_flag : SDNode<"X86ISD::SUB", SDTBinaryArithWithFlags>;
161def X86smul_flag : SDNode<"X86ISD::SMUL", SDTBinaryArithWithFlags>;
162def X86umul_flag : SDNode<"X86ISD::UMUL", SDTUnaryArithWithFlags>;
163def X86inc_flag : SDNode<"X86ISD::INC", SDTUnaryArithWithFlags>;
164def X86dec_flag : SDNode<"X86ISD::DEC", SDTUnaryArithWithFlags>;
Bill Wendlingae034ed2008-12-12 00:56:36 +0000165
Evan Chengc3495762009-03-30 21:36:47 +0000166def X86mul_imm : SDNode<"X86ISD::MUL_IMM", SDTIntBinOp>;
167
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000168//===----------------------------------------------------------------------===//
169// X86 Operand Definitions.
170//
171
Chris Lattner357a0ca2009-06-20 19:34:09 +0000172def i32imm_pcrel : Operand<i32> {
173 let PrintMethod = "print_pcrel_imm";
174}
175
Dan Gohmanfe606822009-07-30 01:56:29 +0000176// A version of ptr_rc which excludes SP, ESP, and RSP. This is used for
177// the index operand of an address, to conform to x86 encoding restrictions.
178def ptr_rc_nosp : PointerLikeRegClass<1>;
Chris Lattner357a0ca2009-06-20 19:34:09 +0000179
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000180// *mem - Operand definitions for the funky X86 addressing mode operands.
181//
Daniel Dunbar0f10cbf2009-08-10 18:41:10 +0000182def X86MemAsmOperand : AsmOperandClass {
183 let Name = "Mem";
Daniel Dunbar6e9ee792009-08-10 19:08:02 +0000184 let SuperClass = ?;
Daniel Dunbar0f10cbf2009-08-10 18:41:10 +0000185}
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000186class X86MemOperand<string printMethod> : Operand<iPTR> {
187 let PrintMethod = printMethod;
Dan Gohmanfe606822009-07-30 01:56:29 +0000188 let MIOperandInfo = (ops ptr_rc, i8imm, ptr_rc_nosp, i32imm, i8imm);
Daniel Dunbar0f10cbf2009-08-10 18:41:10 +0000189 let ParserMatchClass = X86MemAsmOperand;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000190}
191
Sean Callanan66fdfa02009-09-03 00:04:47 +0000192def opaque32mem : X86MemOperand<"printopaquemem">;
193def opaque48mem : X86MemOperand<"printopaquemem">;
194def opaque80mem : X86MemOperand<"printopaquemem">;
195
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000196def i8mem : X86MemOperand<"printi8mem">;
197def i16mem : X86MemOperand<"printi16mem">;
198def i32mem : X86MemOperand<"printi32mem">;
199def i64mem : X86MemOperand<"printi64mem">;
200def i128mem : X86MemOperand<"printi128mem">;
David Greene6b75fca2009-06-30 19:24:59 +0000201def i256mem : X86MemOperand<"printi256mem">;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000202def f32mem : X86MemOperand<"printf32mem">;
203def f64mem : X86MemOperand<"printf64mem">;
Dale Johannesen4ab00bd2007-08-05 18:49:15 +0000204def f80mem : X86MemOperand<"printf80mem">;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000205def f128mem : X86MemOperand<"printf128mem">;
David Greene6b75fca2009-06-30 19:24:59 +0000206def f256mem : X86MemOperand<"printf256mem">;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000207
Dan Gohman744d4622009-04-13 16:09:41 +0000208// A version of i8mem for use on x86-64 that uses GR64_NOREX instead of
209// plain GR64, so that it doesn't potentially require a REX prefix.
210def i8mem_NOREX : Operand<i64> {
211 let PrintMethod = "printi8mem";
Dan Gohmanfe606822009-07-30 01:56:29 +0000212 let MIOperandInfo = (ops GR64_NOREX, i8imm, GR64_NOREX_NOSP, i32imm, i8imm);
Daniel Dunbar0f10cbf2009-08-10 18:41:10 +0000213 let ParserMatchClass = X86MemAsmOperand;
Dan Gohman744d4622009-04-13 16:09:41 +0000214}
215
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000216def lea32mem : Operand<i32> {
Rafael Espindolabca99f72009-04-08 21:14:34 +0000217 let PrintMethod = "printlea32mem";
Dan Gohmanefbd3bc2009-08-05 17:40:24 +0000218 let MIOperandInfo = (ops GR32, i8imm, GR32_NOSP, i32imm);
Daniel Dunbar0f10cbf2009-08-10 18:41:10 +0000219 let ParserMatchClass = X86MemAsmOperand;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000220}
221
222def SSECC : Operand<i8> {
223 let PrintMethod = "printSSECC";
224}
225
226def piclabel: Operand<i32> {
227 let PrintMethod = "printPICLabel";
228}
229
Daniel Dunbar0f10cbf2009-08-10 18:41:10 +0000230def ImmSExt8AsmOperand : AsmOperandClass {
231 let Name = "ImmSExt8";
232 let SuperClass = ImmAsmOperand;
233}
234
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000235// A couple of more descriptive operand definitions.
236// 16-bits but only 8 bits are significant.
Daniel Dunbar06d5cb62009-08-09 07:20:21 +0000237def i16i8imm : Operand<i16> {
Daniel Dunbar0f10cbf2009-08-10 18:41:10 +0000238 let ParserMatchClass = ImmSExt8AsmOperand;
Daniel Dunbar06d5cb62009-08-09 07:20:21 +0000239}
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000240// 32-bits but only 8 bits are significant.
Daniel Dunbar06d5cb62009-08-09 07:20:21 +0000241def i32i8imm : Operand<i32> {
Daniel Dunbar0f10cbf2009-08-10 18:41:10 +0000242 let ParserMatchClass = ImmSExt8AsmOperand;
Daniel Dunbar06d5cb62009-08-09 07:20:21 +0000243}
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000244
Chris Lattner357a0ca2009-06-20 19:34:09 +0000245// Branch targets have OtherVT type and print as pc-relative values.
246def brtarget : Operand<OtherVT> {
247 let PrintMethod = "print_pcrel_imm";
248}
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000249
Evan Chengd11052b2009-07-21 06:00:18 +0000250def brtarget8 : Operand<OtherVT> {
251 let PrintMethod = "print_pcrel_imm";
252}
253
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000254//===----------------------------------------------------------------------===//
255// X86 Complex Pattern Definitions.
256//
257
258// Define X86 specific addressing mode.
Rafael Espindolabca99f72009-04-08 21:14:34 +0000259def addr : ComplexPattern<iPTR, 5, "SelectAddr", [], []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000260def lea32addr : ComplexPattern<i32, 4, "SelectLEAAddr",
Dan Gohman0c0d7412009-08-02 16:09:17 +0000261 [add, sub, mul, X86mul_imm, shl, or, frameindex],
262 []>;
Chris Lattnerf1940742009-06-20 20:38:48 +0000263def tls32addr : ComplexPattern<i32, 4, "SelectTLSADDRAddr",
264 [tglobaltlsaddr], []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000265
266//===----------------------------------------------------------------------===//
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000267// X86 Instruction Predicate Definitions.
268def HasMMX : Predicate<"Subtarget->hasMMX()">;
269def HasSSE1 : Predicate<"Subtarget->hasSSE1()">;
270def HasSSE2 : Predicate<"Subtarget->hasSSE2()">;
271def HasSSE3 : Predicate<"Subtarget->hasSSE3()">;
272def HasSSSE3 : Predicate<"Subtarget->hasSSSE3()">;
Nate Begemanb2975562008-02-03 07:18:54 +0000273def HasSSE41 : Predicate<"Subtarget->hasSSE41()">;
274def HasSSE42 : Predicate<"Subtarget->hasSSE42()">;
David Greene8bf22bc2009-06-26 22:46:54 +0000275def HasSSE4A : Predicate<"Subtarget->hasSSE4A()">;
276def HasAVX : Predicate<"Subtarget->hasAVX()">;
277def HasFMA3 : Predicate<"Subtarget->hasFMA3()">;
278def HasFMA4 : Predicate<"Subtarget->hasFMA4()">;
Dale Johannesene0e0fd02007-09-23 14:52:20 +0000279def FPStackf32 : Predicate<"!Subtarget->hasSSE1()">;
280def FPStackf64 : Predicate<"!Subtarget->hasSSE2()">;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000281def In32BitMode : Predicate<"!Subtarget->is64Bit()">;
282def In64BitMode : Predicate<"Subtarget->is64Bit()">;
Anton Korobeynikov2cbcdb72009-08-03 08:12:53 +0000283def IsWin64 : Predicate<"Subtarget->isTargetWin64()">;
284def NotWin64 : Predicate<"!Subtarget->isTargetWin64()">;
Anton Korobeynikov68d4eca2009-08-06 11:23:24 +0000285def SmallCode : Predicate<"TM.getCodeModel() == CodeModel::Small">;
286def KernelCode : Predicate<"TM.getCodeModel() == CodeModel::Kernel">;
287def FarData : Predicate<"TM.getCodeModel() != CodeModel::Small &&"
Anton Korobeynikov7e1178f2009-08-06 09:11:19 +0000288 "TM.getCodeModel() != CodeModel::Kernel">;
Anton Korobeynikov68d4eca2009-08-06 11:23:24 +0000289def NearData : Predicate<"TM.getCodeModel() == CodeModel::Small ||"
290 "TM.getCodeModel() == CodeModel::Kernel">;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000291def IsStatic : Predicate<"TM.getRelocationModel() == Reloc::Static">;
Evan Cheng13559d62008-09-26 23:41:32 +0000292def OptForSpeed : Predicate<"!OptForSize">;
Evan Cheng95a77fd2009-01-02 05:35:45 +0000293def FastBTMem : Predicate<"!Subtarget->isBTMemSlow()">;
Evan Cheng6d35a4d2009-05-20 04:53:57 +0000294def CallImmAddr : Predicate<"Subtarget->IsLegalToCallImmediateAddr(TM)">;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000295
296//===----------------------------------------------------------------------===//
Evan Cheng86ab7d32007-07-31 08:04:03 +0000297// X86 Instruction Format Definitions.
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000298//
299
Evan Cheng86ab7d32007-07-31 08:04:03 +0000300include "X86InstrFormats.td"
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000301
302//===----------------------------------------------------------------------===//
303// Pattern fragments...
304//
305
306// X86 specific condition code. These correspond to CondCode in
307// X86InstrInfo.h. They must be kept in synch.
Dan Gohman0fc9ed62009-01-07 00:15:08 +0000308def X86_COND_A : PatLeaf<(i8 0)>; // alt. COND_NBE
309def X86_COND_AE : PatLeaf<(i8 1)>; // alt. COND_NC
310def X86_COND_B : PatLeaf<(i8 2)>; // alt. COND_C
311def X86_COND_BE : PatLeaf<(i8 3)>; // alt. COND_NA
312def X86_COND_E : PatLeaf<(i8 4)>; // alt. COND_Z
313def X86_COND_G : PatLeaf<(i8 5)>; // alt. COND_NLE
314def X86_COND_GE : PatLeaf<(i8 6)>; // alt. COND_NL
315def X86_COND_L : PatLeaf<(i8 7)>; // alt. COND_NGE
316def X86_COND_LE : PatLeaf<(i8 8)>; // alt. COND_NG
317def X86_COND_NE : PatLeaf<(i8 9)>; // alt. COND_NZ
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000318def X86_COND_NO : PatLeaf<(i8 10)>;
Dan Gohman0fc9ed62009-01-07 00:15:08 +0000319def X86_COND_NP : PatLeaf<(i8 11)>; // alt. COND_PO
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000320def X86_COND_NS : PatLeaf<(i8 12)>;
Dan Gohman0fc9ed62009-01-07 00:15:08 +0000321def X86_COND_O : PatLeaf<(i8 13)>;
322def X86_COND_P : PatLeaf<(i8 14)>; // alt. COND_PE
323def X86_COND_S : PatLeaf<(i8 15)>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000324
325def i16immSExt8 : PatLeaf<(i16 imm), [{
326 // i16immSExt8 predicate - True if the 16-bit immediate fits in a 8-bit
327 // sign extended field.
Dan Gohmanfaeb4a32008-09-12 16:56:44 +0000328 return (int16_t)N->getZExtValue() == (int8_t)N->getZExtValue();
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000329}]>;
330
331def i32immSExt8 : PatLeaf<(i32 imm), [{
332 // i32immSExt8 predicate - True if the 32-bit immediate fits in a 8-bit
333 // sign extended field.
Dan Gohmanfaeb4a32008-09-12 16:56:44 +0000334 return (int32_t)N->getZExtValue() == (int8_t)N->getZExtValue();
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000335}]>;
336
337// Helper fragments for loads.
Evan Chengb3e25ea2008-05-13 18:59:59 +0000338// It's always safe to treat a anyext i16 load as a i32 load if the i16 is
339// known to be 32-bit aligned or better. Ditto for i8 to i16.
Dan Gohman2a174122008-10-15 06:50:19 +0000340def loadi16 : PatFrag<(ops node:$ptr), (i16 (unindexedload node:$ptr)), [{
Dan Gohman8335c412008-08-20 15:24:22 +0000341 LoadSDNode *LD = cast<LoadSDNode>(N);
Chris Lattner12208612009-04-10 00:16:23 +0000342 if (const Value *Src = LD->getSrcValue())
343 if (const PointerType *PT = dyn_cast<PointerType>(Src->getType()))
Mon P Wangdc97d5a2009-04-27 07:22:10 +0000344 if (PT->getAddressSpace() > 255)
Chris Lattner12208612009-04-10 00:16:23 +0000345 return false;
Dan Gohman8335c412008-08-20 15:24:22 +0000346 ISD::LoadExtType ExtType = LD->getExtensionType();
347 if (ExtType == ISD::NON_EXTLOAD)
348 return true;
349 if (ExtType == ISD::EXTLOAD)
350 return LD->getAlignment() >= 2 && !LD->isVolatile();
Evan Cheng8b765e92008-05-13 00:54:02 +0000351 return false;
352}]>;
353
Dan Gohman2a174122008-10-15 06:50:19 +0000354def loadi16_anyext : PatFrag<(ops node:$ptr), (i32 (unindexedload node:$ptr)), [{
Evan Cheng56ec77b2008-09-24 23:27:55 +0000355 LoadSDNode *LD = cast<LoadSDNode>(N);
Chris Lattner12208612009-04-10 00:16:23 +0000356 if (const Value *Src = LD->getSrcValue())
357 if (const PointerType *PT = dyn_cast<PointerType>(Src->getType()))
Mon P Wangdc97d5a2009-04-27 07:22:10 +0000358 if (PT->getAddressSpace() > 255)
Chris Lattner12208612009-04-10 00:16:23 +0000359 return false;
Evan Cheng56ec77b2008-09-24 23:27:55 +0000360 ISD::LoadExtType ExtType = LD->getExtensionType();
361 if (ExtType == ISD::EXTLOAD)
362 return LD->getAlignment() >= 2 && !LD->isVolatile();
363 return false;
364}]>;
365
Dan Gohman2a174122008-10-15 06:50:19 +0000366def loadi32 : PatFrag<(ops node:$ptr), (i32 (unindexedload node:$ptr)), [{
Dan Gohman8335c412008-08-20 15:24:22 +0000367 LoadSDNode *LD = cast<LoadSDNode>(N);
Chris Lattner12208612009-04-10 00:16:23 +0000368 if (const Value *Src = LD->getSrcValue())
369 if (const PointerType *PT = dyn_cast<PointerType>(Src->getType()))
Mon P Wangdc97d5a2009-04-27 07:22:10 +0000370 if (PT->getAddressSpace() > 255)
Chris Lattner12208612009-04-10 00:16:23 +0000371 return false;
Dan Gohman8335c412008-08-20 15:24:22 +0000372 ISD::LoadExtType ExtType = LD->getExtensionType();
373 if (ExtType == ISD::NON_EXTLOAD)
374 return true;
375 if (ExtType == ISD::EXTLOAD)
376 return LD->getAlignment() >= 4 && !LD->isVolatile();
Evan Cheng8b765e92008-05-13 00:54:02 +0000377 return false;
378}]>;
379
Dan Gohman2a174122008-10-15 06:50:19 +0000380def nvloadi32 : PatFrag<(ops node:$ptr), (i32 (unindexedload node:$ptr)), [{
Evan Cheng1e5e5452008-09-29 17:26:18 +0000381 LoadSDNode *LD = cast<LoadSDNode>(N);
Chris Lattner12208612009-04-10 00:16:23 +0000382 if (const Value *Src = LD->getSrcValue())
383 if (const PointerType *PT = dyn_cast<PointerType>(Src->getType()))
Mon P Wangdc97d5a2009-04-27 07:22:10 +0000384 if (PT->getAddressSpace() > 255)
Chris Lattner12208612009-04-10 00:16:23 +0000385 return false;
Evan Cheng1e5e5452008-09-29 17:26:18 +0000386 if (LD->isVolatile())
387 return false;
Evan Cheng1e5e5452008-09-29 17:26:18 +0000388 ISD::LoadExtType ExtType = LD->getExtensionType();
389 if (ExtType == ISD::NON_EXTLOAD)
390 return true;
391 if (ExtType == ISD::EXTLOAD)
392 return LD->getAlignment() >= 4;
393 return false;
394}]>;
395
sampo9cc09a32009-01-26 01:24:32 +0000396def gsload : PatFrag<(ops node:$ptr), (load node:$ptr), [{
Chris Lattner12208612009-04-10 00:16:23 +0000397 if (const Value *Src = cast<LoadSDNode>(N)->getSrcValue())
398 if (const PointerType *PT = dyn_cast<PointerType>(Src->getType()))
399 return PT->getAddressSpace() == 256;
sampo9cc09a32009-01-26 01:24:32 +0000400 return false;
401}]>;
402
Chris Lattnera7c2d8a2009-05-05 18:52:19 +0000403def fsload : PatFrag<(ops node:$ptr), (load node:$ptr), [{
404 if (const Value *Src = cast<LoadSDNode>(N)->getSrcValue())
405 if (const PointerType *PT = dyn_cast<PointerType>(Src->getType()))
406 return PT->getAddressSpace() == 257;
407 return false;
408}]>;
409
Chris Lattner12208612009-04-10 00:16:23 +0000410def loadi8 : PatFrag<(ops node:$ptr), (i8 (load node:$ptr)), [{
411 if (const Value *Src = cast<LoadSDNode>(N)->getSrcValue())
412 if (const PointerType *PT = dyn_cast<PointerType>(Src->getType()))
Mon P Wangdc97d5a2009-04-27 07:22:10 +0000413 if (PT->getAddressSpace() > 255)
Chris Lattner12208612009-04-10 00:16:23 +0000414 return false;
415 return true;
416}]>;
417def loadi64 : PatFrag<(ops node:$ptr), (i64 (load node:$ptr)), [{
418 if (const Value *Src = cast<LoadSDNode>(N)->getSrcValue())
419 if (const PointerType *PT = dyn_cast<PointerType>(Src->getType()))
Mon P Wangdc97d5a2009-04-27 07:22:10 +0000420 if (PT->getAddressSpace() > 255)
Chris Lattner12208612009-04-10 00:16:23 +0000421 return false;
422 return true;
423}]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000424
Chris Lattner12208612009-04-10 00:16:23 +0000425def loadf32 : PatFrag<(ops node:$ptr), (f32 (load node:$ptr)), [{
426 if (const Value *Src = cast<LoadSDNode>(N)->getSrcValue())
427 if (const PointerType *PT = dyn_cast<PointerType>(Src->getType()))
Mon P Wangdc97d5a2009-04-27 07:22:10 +0000428 if (PT->getAddressSpace() > 255)
Chris Lattner12208612009-04-10 00:16:23 +0000429 return false;
430 return true;
431}]>;
432def loadf64 : PatFrag<(ops node:$ptr), (f64 (load node:$ptr)), [{
433 if (const Value *Src = cast<LoadSDNode>(N)->getSrcValue())
434 if (const PointerType *PT = dyn_cast<PointerType>(Src->getType()))
Mon P Wangdc97d5a2009-04-27 07:22:10 +0000435 if (PT->getAddressSpace() > 255)
Chris Lattner12208612009-04-10 00:16:23 +0000436 return false;
437 return true;
438}]>;
439def loadf80 : PatFrag<(ops node:$ptr), (f80 (load node:$ptr)), [{
440 if (const Value *Src = cast<LoadSDNode>(N)->getSrcValue())
441 if (const PointerType *PT = dyn_cast<PointerType>(Src->getType()))
Mon P Wangdc97d5a2009-04-27 07:22:10 +0000442 if (PT->getAddressSpace() > 255)
Chris Lattner12208612009-04-10 00:16:23 +0000443 return false;
444 return true;
445}]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000446
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000447def sextloadi16i8 : PatFrag<(ops node:$ptr), (i16 (sextloadi8 node:$ptr))>;
448def sextloadi32i8 : PatFrag<(ops node:$ptr), (i32 (sextloadi8 node:$ptr))>;
449def sextloadi32i16 : PatFrag<(ops node:$ptr), (i32 (sextloadi16 node:$ptr))>;
450
451def zextloadi8i1 : PatFrag<(ops node:$ptr), (i8 (zextloadi1 node:$ptr))>;
452def zextloadi16i1 : PatFrag<(ops node:$ptr), (i16 (zextloadi1 node:$ptr))>;
453def zextloadi32i1 : PatFrag<(ops node:$ptr), (i32 (zextloadi1 node:$ptr))>;
454def zextloadi16i8 : PatFrag<(ops node:$ptr), (i16 (zextloadi8 node:$ptr))>;
455def zextloadi32i8 : PatFrag<(ops node:$ptr), (i32 (zextloadi8 node:$ptr))>;
456def zextloadi32i16 : PatFrag<(ops node:$ptr), (i32 (zextloadi16 node:$ptr))>;
457
458def extloadi8i1 : PatFrag<(ops node:$ptr), (i8 (extloadi1 node:$ptr))>;
459def extloadi16i1 : PatFrag<(ops node:$ptr), (i16 (extloadi1 node:$ptr))>;
460def extloadi32i1 : PatFrag<(ops node:$ptr), (i32 (extloadi1 node:$ptr))>;
461def extloadi16i8 : PatFrag<(ops node:$ptr), (i16 (extloadi8 node:$ptr))>;
462def extloadi32i8 : PatFrag<(ops node:$ptr), (i32 (extloadi8 node:$ptr))>;
463def extloadi32i16 : PatFrag<(ops node:$ptr), (i32 (extloadi16 node:$ptr))>;
464
Chris Lattner21da6382008-02-19 17:37:35 +0000465
466// An 'and' node with a single use.
467def and_su : PatFrag<(ops node:$lhs, node:$rhs), (and node:$lhs, node:$rhs), [{
Evan Cheng9123cfa2008-03-04 00:40:35 +0000468 return N->hasOneUse();
Chris Lattner21da6382008-02-19 17:37:35 +0000469}]>;
Dan Gohman744d4622009-04-13 16:09:41 +0000470// An 'srl' node with a single use.
471def srl_su : PatFrag<(ops node:$lhs, node:$rhs), (srl node:$lhs, node:$rhs), [{
472 return N->hasOneUse();
473}]>;
474// An 'trunc' node with a single use.
475def trunc_su : PatFrag<(ops node:$src), (trunc node:$src), [{
476 return N->hasOneUse();
477}]>;
Chris Lattner21da6382008-02-19 17:37:35 +0000478
Dan Gohman921581d2008-10-17 01:23:35 +0000479// 'shld' and 'shrd' instruction patterns. Note that even though these have
480// the srl and shl in their patterns, the C++ code must still check for them,
481// because predicates are tested before children nodes are explored.
482
483def shrd : PatFrag<(ops node:$src1, node:$amt1, node:$src2, node:$amt2),
484 (or (srl node:$src1, node:$amt1),
485 (shl node:$src2, node:$amt2)), [{
486 assert(N->getOpcode() == ISD::OR);
487 return N->getOperand(0).getOpcode() == ISD::SRL &&
488 N->getOperand(1).getOpcode() == ISD::SHL &&
489 isa<ConstantSDNode>(N->getOperand(0).getOperand(1)) &&
490 isa<ConstantSDNode>(N->getOperand(1).getOperand(1)) &&
491 N->getOperand(0).getConstantOperandVal(1) ==
492 N->getValueSizeInBits(0) - N->getOperand(1).getConstantOperandVal(1);
493}]>;
494
495def shld : PatFrag<(ops node:$src1, node:$amt1, node:$src2, node:$amt2),
496 (or (shl node:$src1, node:$amt1),
497 (srl node:$src2, node:$amt2)), [{
498 assert(N->getOpcode() == ISD::OR);
499 return N->getOperand(0).getOpcode() == ISD::SHL &&
500 N->getOperand(1).getOpcode() == ISD::SRL &&
501 isa<ConstantSDNode>(N->getOperand(0).getOperand(1)) &&
502 isa<ConstantSDNode>(N->getOperand(1).getOperand(1)) &&
503 N->getOperand(0).getConstantOperandVal(1) ==
504 N->getValueSizeInBits(0) - N->getOperand(1).getConstantOperandVal(1);
505}]>;
506
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000507//===----------------------------------------------------------------------===//
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000508// Instruction list...
509//
510
511// ADJCALLSTACKDOWN/UP implicitly use/def ESP because they may be expanded into
512// a stack adjustment and the codegen must know that they may modify the stack
513// pointer before prolog-epilog rewriting occurs.
Chris Lattnerb56cc342008-03-11 03:23:40 +0000514// Pessimistically assume ADJCALLSTACKDOWN / ADJCALLSTACKUP will become
515// sub / add which can clobber EFLAGS.
Evan Cheng037364a2007-09-28 01:19:48 +0000516let Defs = [ESP, EFLAGS], Uses = [ESP] in {
Dan Gohman01c9f772008-10-01 18:28:06 +0000517def ADJCALLSTACKDOWN32 : I<0, Pseudo, (outs), (ins i32imm:$amt),
518 "#ADJCALLSTACKDOWN",
Chris Lattnerfe5d4022008-10-11 22:08:30 +0000519 [(X86callseq_start timm:$amt)]>,
Dan Gohman01c9f772008-10-01 18:28:06 +0000520 Requires<[In32BitMode]>;
521def ADJCALLSTACKUP32 : I<0, Pseudo, (outs), (ins i32imm:$amt1, i32imm:$amt2),
522 "#ADJCALLSTACKUP",
Chris Lattnerfe5d4022008-10-11 22:08:30 +0000523 [(X86callseq_end timm:$amt1, timm:$amt2)]>,
Dan Gohman01c9f772008-10-01 18:28:06 +0000524 Requires<[In32BitMode]>;
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000525}
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000526
Dan Gohman34228bf2009-08-15 01:38:56 +0000527// x86-64 va_start lowering magic.
528let usesCustomDAGSchedInserter = 1 in
529def VASTART_SAVE_XMM_REGS : I<0, Pseudo,
530 (outs),
531 (ins GR8:$al,
532 i64imm:$regsavefi, i64imm:$offset,
533 variable_ops),
534 "#VASTART_SAVE_XMM_REGS $al, $regsavefi, $offset",
535 [(X86vastart_save_xmm_regs GR8:$al,
536 imm:$regsavefi,
537 imm:$offset)]>;
538
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000539// Nop
Sean Callananf94a0542009-07-23 23:39:34 +0000540let neverHasSideEffects = 1 in {
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000541 def NOOP : I<0x90, RawFrm, (outs), (ins), "nop", []>;
Sean Callananf94a0542009-07-23 23:39:34 +0000542 def NOOPL : I<0x1f, MRM0m, (outs), (ins i32mem:$zero),
543 "nopl\t$zero", []>, TB;
544}
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000545
Sean Callanan9b195f82009-08-11 01:09:06 +0000546// Trap
547def INT3 : I<0xcc, RawFrm, (outs), (ins), "int 3", []>;
548def INT : I<0xcd, RawFrm, (outs), (ins i8imm:$trap), "int\t$trap", []>;
549
Evan Cheng0729ccf2008-01-05 00:41:47 +0000550// PIC base
Dan Gohman9499cfe2008-10-01 04:14:30 +0000551let neverHasSideEffects = 1, isNotDuplicable = 1, Uses = [ESP] in
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000552 def MOVPC32r : Ii32<0xE8, Pseudo, (outs GR32:$reg), (ins piclabel:$label),
Dan Gohman70a8a112009-04-27 15:13:28 +0000553 "call\t$label\n\t"
554 "pop{l}\t$reg", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000555
556//===----------------------------------------------------------------------===//
557// Control Flow Instructions...
558//
559
560// Return instructions.
561let isTerminator = 1, isReturn = 1, isBarrier = 1,
Chris Lattnerb56cc342008-03-11 03:23:40 +0000562 hasCtrlDep = 1, FPForm = SpecialFP, FPFormBits = SpecialFP.Value in {
Dan Gohman2c4be2a2008-05-31 02:11:25 +0000563 def RET : I <0xC3, RawFrm, (outs), (ins variable_ops),
Chris Lattnerb56cc342008-03-11 03:23:40 +0000564 "ret",
Dan Gohman2c4be2a2008-05-31 02:11:25 +0000565 [(X86retflag 0)]>;
Chris Lattnerb56cc342008-03-11 03:23:40 +0000566 def RETI : Ii16<0xC2, RawFrm, (outs), (ins i16imm:$amt, variable_ops),
567 "ret\t$amt",
Dan Gohmane84197b2009-09-03 17:18:51 +0000568 [(X86retflag timm:$amt)]>;
Sean Callanan7a012572009-09-15 23:37:51 +0000569 def LRET : I <0xCB, RawFrm, (outs), (ins),
570 "lret", []>;
571 def LRETI : Ii16<0xCA, RawFrm, (outs), (ins i16imm:$amt),
572 "lret\t$amt", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000573}
574
575// All branches are RawFrm, Void, Branch, and Terminators
Evan Cheng37e7c752007-07-21 00:34:19 +0000576let isBranch = 1, isTerminator = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +0000577 class IBr<bits<8> opcode, dag ins, string asm, list<dag> pattern> :
578 I<opcode, RawFrm, (outs), ins, asm, pattern>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000579
Sean Callananc0608152009-07-22 01:05:20 +0000580let isBranch = 1, isBarrier = 1 in {
Dan Gohman91888f02007-07-31 20:11:57 +0000581 def JMP : IBr<0xE9, (ins brtarget:$dst), "jmp\t$dst", [(br bb:$dst)]>;
Sean Callananc0608152009-07-22 01:05:20 +0000582 def JMP8 : IBr<0xEB, (ins brtarget8:$dst), "jmp\t$dst", []>;
583}
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000584
Owen Andersonf8053082007-11-12 07:39:39 +0000585// Indirect branches
586let isBranch = 1, isTerminator = 1, isBarrier = 1, isIndirectBranch = 1 in {
Dan Gohman91888f02007-07-31 20:11:57 +0000587 def JMP32r : I<0xFF, MRM4r, (outs), (ins GR32:$dst), "jmp{l}\t{*}$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000588 [(brind GR32:$dst)]>;
Dan Gohman91888f02007-07-31 20:11:57 +0000589 def JMP32m : I<0xFF, MRM4m, (outs), (ins i32mem:$dst), "jmp{l}\t{*}$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000590 [(brind (loadi32 addr:$dst))]>;
Sean Callananb7e73392009-09-15 00:35:17 +0000591
592 def FARJMP16i : Iseg16<0xEA, RawFrm, (outs),
593 (ins i16imm:$seg, i16imm:$off),
594 "ljmp{w}\t$seg, $off", []>, OpSize;
595 def FARJMP32i : Iseg32<0xEA, RawFrm, (outs),
596 (ins i16imm:$seg, i32imm:$off),
597 "ljmp{l}\t$seg, $off", []>;
598
599 def FARJMP16m : I<0xFF, MRM5m, (outs), (ins opaque32mem:$dst),
Sean Callanan66fdfa02009-09-03 00:04:47 +0000600 "ljmp{w}\t{*}$dst", []>, OpSize;
Sean Callananb7e73392009-09-15 00:35:17 +0000601 def FARJMP32m : I<0xFF, MRM5m, (outs), (ins opaque48mem:$dst),
Sean Callanan66fdfa02009-09-03 00:04:47 +0000602 "ljmp{l}\t{*}$dst", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000603}
604
605// Conditional branches
Evan Cheng950aac02007-09-25 01:57:46 +0000606let Uses = [EFLAGS] in {
Evan Chengd11052b2009-07-21 06:00:18 +0000607// Short conditional jumps
608def JO8 : IBr<0x70, (ins brtarget8:$dst), "jo\t$dst", []>;
609def JNO8 : IBr<0x71, (ins brtarget8:$dst), "jno\t$dst", []>;
610def JB8 : IBr<0x72, (ins brtarget8:$dst), "jb\t$dst", []>;
611def JAE8 : IBr<0x73, (ins brtarget8:$dst), "jae\t$dst", []>;
612def JE8 : IBr<0x74, (ins brtarget8:$dst), "je\t$dst", []>;
613def JNE8 : IBr<0x75, (ins brtarget8:$dst), "jne\t$dst", []>;
614def JBE8 : IBr<0x76, (ins brtarget8:$dst), "jbe\t$dst", []>;
615def JA8 : IBr<0x77, (ins brtarget8:$dst), "ja\t$dst", []>;
616def JS8 : IBr<0x78, (ins brtarget8:$dst), "js\t$dst", []>;
617def JNS8 : IBr<0x79, (ins brtarget8:$dst), "jns\t$dst", []>;
618def JP8 : IBr<0x7A, (ins brtarget8:$dst), "jp\t$dst", []>;
619def JNP8 : IBr<0x7B, (ins brtarget8:$dst), "jnp\t$dst", []>;
620def JL8 : IBr<0x7C, (ins brtarget8:$dst), "jl\t$dst", []>;
621def JGE8 : IBr<0x7D, (ins brtarget8:$dst), "jge\t$dst", []>;
622def JLE8 : IBr<0x7E, (ins brtarget8:$dst), "jle\t$dst", []>;
623def JG8 : IBr<0x7F, (ins brtarget8:$dst), "jg\t$dst", []>;
624
625def JCXZ8 : IBr<0xE3, (ins brtarget8:$dst), "jcxz\t$dst", []>;
626
Dan Gohman91888f02007-07-31 20:11:57 +0000627def JE : IBr<0x84, (ins brtarget:$dst), "je\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000628 [(X86brcond bb:$dst, X86_COND_E, EFLAGS)]>, TB;
Dan Gohman91888f02007-07-31 20:11:57 +0000629def JNE : IBr<0x85, (ins brtarget:$dst), "jne\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000630 [(X86brcond bb:$dst, X86_COND_NE, EFLAGS)]>, TB;
Dan Gohman91888f02007-07-31 20:11:57 +0000631def JL : IBr<0x8C, (ins brtarget:$dst), "jl\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000632 [(X86brcond bb:$dst, X86_COND_L, EFLAGS)]>, TB;
Dan Gohman91888f02007-07-31 20:11:57 +0000633def JLE : IBr<0x8E, (ins brtarget:$dst), "jle\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000634 [(X86brcond bb:$dst, X86_COND_LE, EFLAGS)]>, TB;
Dan Gohman91888f02007-07-31 20:11:57 +0000635def JG : IBr<0x8F, (ins brtarget:$dst), "jg\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000636 [(X86brcond bb:$dst, X86_COND_G, EFLAGS)]>, TB;
Dan Gohman91888f02007-07-31 20:11:57 +0000637def JGE : IBr<0x8D, (ins brtarget:$dst), "jge\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000638 [(X86brcond bb:$dst, X86_COND_GE, EFLAGS)]>, TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000639
Dan Gohman91888f02007-07-31 20:11:57 +0000640def JB : IBr<0x82, (ins brtarget:$dst), "jb\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000641 [(X86brcond bb:$dst, X86_COND_B, EFLAGS)]>, TB;
Dan Gohman91888f02007-07-31 20:11:57 +0000642def JBE : IBr<0x86, (ins brtarget:$dst), "jbe\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000643 [(X86brcond bb:$dst, X86_COND_BE, EFLAGS)]>, TB;
Dan Gohman91888f02007-07-31 20:11:57 +0000644def JA : IBr<0x87, (ins brtarget:$dst), "ja\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000645 [(X86brcond bb:$dst, X86_COND_A, EFLAGS)]>, TB;
Dan Gohman91888f02007-07-31 20:11:57 +0000646def JAE : IBr<0x83, (ins brtarget:$dst), "jae\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000647 [(X86brcond bb:$dst, X86_COND_AE, EFLAGS)]>, TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000648
Dan Gohman91888f02007-07-31 20:11:57 +0000649def JS : IBr<0x88, (ins brtarget:$dst), "js\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000650 [(X86brcond bb:$dst, X86_COND_S, EFLAGS)]>, TB;
Dan Gohman91888f02007-07-31 20:11:57 +0000651def JNS : IBr<0x89, (ins brtarget:$dst), "jns\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000652 [(X86brcond bb:$dst, X86_COND_NS, EFLAGS)]>, TB;
Dan Gohman91888f02007-07-31 20:11:57 +0000653def JP : IBr<0x8A, (ins brtarget:$dst), "jp\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000654 [(X86brcond bb:$dst, X86_COND_P, EFLAGS)]>, TB;
Dan Gohman91888f02007-07-31 20:11:57 +0000655def JNP : IBr<0x8B, (ins brtarget:$dst), "jnp\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000656 [(X86brcond bb:$dst, X86_COND_NP, EFLAGS)]>, TB;
Dan Gohman91888f02007-07-31 20:11:57 +0000657def JO : IBr<0x80, (ins brtarget:$dst), "jo\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000658 [(X86brcond bb:$dst, X86_COND_O, EFLAGS)]>, TB;
Dan Gohman91888f02007-07-31 20:11:57 +0000659def JNO : IBr<0x81, (ins brtarget:$dst), "jno\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000660 [(X86brcond bb:$dst, X86_COND_NO, EFLAGS)]>, TB;
Evan Cheng950aac02007-09-25 01:57:46 +0000661} // Uses = [EFLAGS]
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000662
663//===----------------------------------------------------------------------===//
664// Call Instructions...
665//
Evan Cheng37e7c752007-07-21 00:34:19 +0000666let isCall = 1 in
Dan Gohman01c9f772008-10-01 18:28:06 +0000667 // All calls clobber the non-callee saved registers. ESP is marked as
668 // a use to prevent stack-pointer assignments that appear immediately
669 // before calls from potentially appearing dead. Uses for argument
670 // registers are added manually.
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000671 let Defs = [EAX, ECX, EDX, FP0, FP1, FP2, FP3, FP4, FP5, FP6, ST0,
672 MM0, MM1, MM2, MM3, MM4, MM5, MM6, MM7,
Evan Cheng2293b252008-10-17 21:02:22 +0000673 XMM0, XMM1, XMM2, XMM3, XMM4, XMM5, XMM6, XMM7,
674 XMM8, XMM9, XMM10, XMM11, XMM12, XMM13, XMM14, XMM15, EFLAGS],
Dan Gohman9499cfe2008-10-01 04:14:30 +0000675 Uses = [ESP] in {
Chris Lattner357a0ca2009-06-20 19:34:09 +0000676 def CALLpcrel32 : Ii32<0xE8, RawFrm,
677 (outs), (ins i32imm_pcrel:$dst,variable_ops),
678 "call\t$dst", []>;
Evan Chengb783fa32007-07-19 01:14:50 +0000679 def CALL32r : I<0xFF, MRM2r, (outs), (ins GR32:$dst, variable_ops),
Dan Gohman91888f02007-07-31 20:11:57 +0000680 "call\t{*}$dst", [(X86call GR32:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000681 def CALL32m : I<0xFF, MRM2m, (outs), (ins i32mem:$dst, variable_ops),
Dan Gohmanea4faba2008-05-29 21:50:34 +0000682 "call\t{*}$dst", [(X86call (loadi32 addr:$dst))]>;
Sean Callanan66fdfa02009-09-03 00:04:47 +0000683
Sean Callananb7e73392009-09-15 00:35:17 +0000684 def FARCALL16i : Iseg16<0x9A, RawFrm, (outs),
685 (ins i16imm:$seg, i16imm:$off),
686 "lcall{w}\t$seg, $off", []>, OpSize;
687 def FARCALL32i : Iseg32<0x9A, RawFrm, (outs),
688 (ins i16imm:$seg, i32imm:$off),
689 "lcall{l}\t$seg, $off", []>;
690
691 def FARCALL16m : I<0xFF, MRM3m, (outs), (ins opaque32mem:$dst),
Sean Callanan66fdfa02009-09-03 00:04:47 +0000692 "lcall{w}\t{*}$dst", []>, OpSize;
Sean Callananb7e73392009-09-15 00:35:17 +0000693 def FARCALL32m : I<0xFF, MRM3m, (outs), (ins opaque48mem:$dst),
Sean Callanan66fdfa02009-09-03 00:04:47 +0000694 "lcall{l}\t{*}$dst", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000695 }
696
Sean Callanan51b7a992009-09-16 02:57:13 +0000697// Constructing a stack frame.
698
699def ENTER : I<0xC8, RawFrm, (outs), (ins i16imm:$len, i8imm:$lvl),
700 "enter\t$len, $lvl", []>;
701
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000702// Tail call stuff.
Arnold Schwaighofere2d6bbb2007-10-11 19:40:01 +0000703
Evan Cheng37e7c752007-07-21 00:34:19 +0000704let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1 in
Arnold Schwaighofer6fd37ac2008-03-19 16:39:45 +0000705def TCRETURNdi : I<0, Pseudo, (outs), (ins i32imm:$dst, i32imm:$offset, variable_ops),
Arnold Schwaighofere2d6bbb2007-10-11 19:40:01 +0000706 "#TC_RETURN $dst $offset",
707 []>;
708
709let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1 in
Arnold Schwaighofer6fd37ac2008-03-19 16:39:45 +0000710def TCRETURNri : I<0, Pseudo, (outs), (ins GR32:$dst, i32imm:$offset, variable_ops),
Arnold Schwaighofere2d6bbb2007-10-11 19:40:01 +0000711 "#TC_RETURN $dst $offset",
712 []>;
713
714let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1 in
Arnold Schwaighofera0032722008-04-30 09:16:33 +0000715
Chris Lattner357a0ca2009-06-20 19:34:09 +0000716 def TAILJMPd : IBr<0xE9, (ins i32imm_pcrel:$dst), "jmp\t$dst # TAILCALL",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000717 []>;
Evan Cheng37e7c752007-07-21 00:34:19 +0000718let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1 in
Arnold Schwaighofere2d6bbb2007-10-11 19:40:01 +0000719 def TAILJMPr : I<0xFF, MRM4r, (outs), (ins GR32:$dst), "jmp{l}\t{*}$dst # TAILCALL",
720 []>;
Evan Cheng37e7c752007-07-21 00:34:19 +0000721let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +0000722 def TAILJMPm : I<0xFF, MRM4m, (outs), (ins i32mem:$dst),
Arnold Schwaighofere2d6bbb2007-10-11 19:40:01 +0000723 "jmp\t{*}$dst # TAILCALL", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000724
725//===----------------------------------------------------------------------===//
726// Miscellaneous Instructions...
727//
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000728let Defs = [EBP, ESP], Uses = [EBP, ESP], mayLoad = 1, neverHasSideEffects=1 in
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000729def LEAVE : I<0xC9, RawFrm,
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000730 (outs), (ins), "leave", []>;
731
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000732let Defs = [ESP], Uses = [ESP], neverHasSideEffects=1 in {
Sean Callanan9f3c3f52009-09-10 18:29:13 +0000733let mayLoad = 1 in {
734def POP16r : I<0x58, AddRegFrm, (outs GR16:$reg), (ins), "pop{w}\t$reg", []>,
735 OpSize;
736def POP32r : I<0x58, AddRegFrm, (outs GR32:$reg), (ins), "pop{l}\t$reg", []>;
737def POP16rmr: I<0x8F, MRM0r, (outs GR16:$reg), (ins), "pop{w}\t$reg", []>,
738 OpSize;
739def POP16rmm: I<0x8F, MRM0m, (outs i16mem:$dst), (ins), "pop{w}\t$dst", []>,
740 OpSize;
741def POP32rmr: I<0x8F, MRM0r, (outs GR32:$reg), (ins), "pop{l}\t$reg", []>;
742def POP32rmm: I<0x8F, MRM0m, (outs i32mem:$dst), (ins), "pop{l}\t$dst", []>;
743}
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000744
Sean Callanan9f3c3f52009-09-10 18:29:13 +0000745let mayStore = 1 in {
746def PUSH16r : I<0x50, AddRegFrm, (outs), (ins GR16:$reg), "push{w}\t$reg",[]>,
747 OpSize;
Evan Chengd8434332007-09-26 01:29:06 +0000748def PUSH32r : I<0x50, AddRegFrm, (outs), (ins GR32:$reg), "push{l}\t$reg",[]>;
Sean Callanan9f3c3f52009-09-10 18:29:13 +0000749def PUSH16rmr: I<0xFF, MRM6r, (outs), (ins GR16:$reg), "push{w}\t$reg",[]>,
750 OpSize;
751def PUSH16rmm: I<0xFF, MRM6m, (outs), (ins i16mem:$src), "push{w}\t$src",[]>,
752 OpSize;
753def PUSH32rmr: I<0xFF, MRM6r, (outs), (ins GR32:$reg), "push{l}\t$reg",[]>;
754def PUSH32rmm: I<0xFF, MRM6m, (outs), (ins i32mem:$src), "push{l}\t$src",[]>;
755}
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000756}
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000757
Bill Wendling4c2638c2009-06-15 19:39:04 +0000758let Defs = [ESP], Uses = [ESP], neverHasSideEffects = 1, mayStore = 1 in {
759def PUSH32i8 : Ii8<0x6a, RawFrm, (outs), (ins i8imm:$imm),
Bill Wendling0b0437f2009-06-15 20:59:31 +0000760 "push{l}\t$imm", []>;
Bill Wendling4c2638c2009-06-15 19:39:04 +0000761def PUSH32i16 : Ii16<0x68, RawFrm, (outs), (ins i16imm:$imm),
Bill Wendling0b0437f2009-06-15 20:59:31 +0000762 "push{l}\t$imm", []>;
Bill Wendling4c2638c2009-06-15 19:39:04 +0000763def PUSH32i32 : Ii32<0x68, RawFrm, (outs), (ins i32imm:$imm),
Bill Wendling0b0437f2009-06-15 20:59:31 +0000764 "push{l}\t$imm", []>;
Bill Wendling4c2638c2009-06-15 19:39:04 +0000765}
766
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000767let Defs = [ESP, EFLAGS], Uses = [ESP], mayLoad = 1, neverHasSideEffects=1 in
Evan Chengf1341312007-09-26 21:28:00 +0000768def POPFD : I<0x9D, RawFrm, (outs), (ins), "popf", []>;
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000769let Defs = [ESP], Uses = [ESP, EFLAGS], mayStore = 1, neverHasSideEffects=1 in
Evan Chengf1341312007-09-26 21:28:00 +0000770def PUSHFD : I<0x9C, RawFrm, (outs), (ins), "pushf", []>;
Evan Chengd8434332007-09-26 01:29:06 +0000771
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000772let isTwoAddress = 1 in // GR32 = bswap GR32
773 def BSWAP32r : I<0xC8, AddRegFrm,
Evan Chengb783fa32007-07-19 01:14:50 +0000774 (outs GR32:$dst), (ins GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000775 "bswap{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000776 [(set GR32:$dst, (bswap GR32:$src))]>, TB;
777
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000778
Evan Cheng48679f42007-12-14 02:13:44 +0000779// Bit scan instructions.
780let Defs = [EFLAGS] in {
Evan Cheng4e33de92007-12-14 18:49:43 +0000781def BSF16rr : I<0xBC, MRMSrcReg, (outs GR16:$dst), (ins GR16:$src),
Dan Gohmancdb54c62007-12-14 15:10:00 +0000782 "bsf{w}\t{$src, $dst|$dst, $src}",
Evan Cheng7cfbfe32007-12-14 08:30:15 +0000783 [(set GR16:$dst, (X86bsf GR16:$src)), (implicit EFLAGS)]>, TB;
Evan Cheng48679f42007-12-14 02:13:44 +0000784def BSF16rm : I<0xBC, MRMSrcMem, (outs GR16:$dst), (ins i16mem:$src),
Dan Gohmancdb54c62007-12-14 15:10:00 +0000785 "bsf{w}\t{$src, $dst|$dst, $src}",
Evan Cheng7cfbfe32007-12-14 08:30:15 +0000786 [(set GR16:$dst, (X86bsf (loadi16 addr:$src))),
787 (implicit EFLAGS)]>, TB;
Evan Cheng4e33de92007-12-14 18:49:43 +0000788def BSF32rr : I<0xBC, MRMSrcReg, (outs GR32:$dst), (ins GR32:$src),
Dan Gohmancdb54c62007-12-14 15:10:00 +0000789 "bsf{l}\t{$src, $dst|$dst, $src}",
Evan Cheng7cfbfe32007-12-14 08:30:15 +0000790 [(set GR32:$dst, (X86bsf GR32:$src)), (implicit EFLAGS)]>, TB;
Evan Cheng48679f42007-12-14 02:13:44 +0000791def BSF32rm : I<0xBC, MRMSrcMem, (outs GR32:$dst), (ins i32mem:$src),
Dan Gohmancdb54c62007-12-14 15:10:00 +0000792 "bsf{l}\t{$src, $dst|$dst, $src}",
Evan Cheng7cfbfe32007-12-14 08:30:15 +0000793 [(set GR32:$dst, (X86bsf (loadi32 addr:$src))),
794 (implicit EFLAGS)]>, TB;
Evan Cheng48679f42007-12-14 02:13:44 +0000795
Evan Cheng4e33de92007-12-14 18:49:43 +0000796def BSR16rr : I<0xBD, MRMSrcReg, (outs GR16:$dst), (ins GR16:$src),
Dan Gohmancdb54c62007-12-14 15:10:00 +0000797 "bsr{w}\t{$src, $dst|$dst, $src}",
Evan Cheng7cfbfe32007-12-14 08:30:15 +0000798 [(set GR16:$dst, (X86bsr GR16:$src)), (implicit EFLAGS)]>, TB;
Evan Cheng48679f42007-12-14 02:13:44 +0000799def BSR16rm : I<0xBD, MRMSrcMem, (outs GR16:$dst), (ins i16mem:$src),
Dan Gohmancdb54c62007-12-14 15:10:00 +0000800 "bsr{w}\t{$src, $dst|$dst, $src}",
Evan Cheng7cfbfe32007-12-14 08:30:15 +0000801 [(set GR16:$dst, (X86bsr (loadi16 addr:$src))),
802 (implicit EFLAGS)]>, TB;
Evan Cheng4e33de92007-12-14 18:49:43 +0000803def BSR32rr : I<0xBD, MRMSrcReg, (outs GR32:$dst), (ins GR32:$src),
Dan Gohmancdb54c62007-12-14 15:10:00 +0000804 "bsr{l}\t{$src, $dst|$dst, $src}",
Evan Cheng7cfbfe32007-12-14 08:30:15 +0000805 [(set GR32:$dst, (X86bsr GR32:$src)), (implicit EFLAGS)]>, TB;
Evan Cheng48679f42007-12-14 02:13:44 +0000806def BSR32rm : I<0xBD, MRMSrcMem, (outs GR32:$dst), (ins i32mem:$src),
Dan Gohmancdb54c62007-12-14 15:10:00 +0000807 "bsr{l}\t{$src, $dst|$dst, $src}",
Evan Cheng7cfbfe32007-12-14 08:30:15 +0000808 [(set GR32:$dst, (X86bsr (loadi32 addr:$src))),
809 (implicit EFLAGS)]>, TB;
Evan Cheng48679f42007-12-14 02:13:44 +0000810} // Defs = [EFLAGS]
811
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000812let neverHasSideEffects = 1 in
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000813def LEA16r : I<0x8D, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +0000814 (outs GR16:$dst), (ins i32mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000815 "lea{w}\t{$src|$dst}, {$dst|$src}", []>, OpSize;
Evan Cheng1ea8e6b2008-03-27 01:41:09 +0000816let isReMaterializable = 1 in
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000817def LEA32r : I<0x8D, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +0000818 (outs GR32:$dst), (ins lea32mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000819 "lea{l}\t{$src|$dst}, {$dst|$src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000820 [(set GR32:$dst, lea32addr:$src)]>, Requires<[In32BitMode]>;
821
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000822let Defs = [ECX,EDI,ESI], Uses = [ECX,EDI,ESI] in {
Evan Chengb783fa32007-07-19 01:14:50 +0000823def REP_MOVSB : I<0xA4, RawFrm, (outs), (ins), "{rep;movsb|rep movsb}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000824 [(X86rep_movs i8)]>, REP;
Evan Chengb783fa32007-07-19 01:14:50 +0000825def REP_MOVSW : I<0xA5, RawFrm, (outs), (ins), "{rep;movsw|rep movsw}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000826 [(X86rep_movs i16)]>, REP, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +0000827def REP_MOVSD : I<0xA5, RawFrm, (outs), (ins), "{rep;movsl|rep movsd}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000828 [(X86rep_movs i32)]>, REP;
829}
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000830
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000831let Defs = [ECX,EDI], Uses = [AL,ECX,EDI] in
Evan Chengb783fa32007-07-19 01:14:50 +0000832def REP_STOSB : I<0xAA, RawFrm, (outs), (ins), "{rep;stosb|rep stosb}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000833 [(X86rep_stos i8)]>, REP;
834let Defs = [ECX,EDI], Uses = [AX,ECX,EDI] in
Evan Chengb783fa32007-07-19 01:14:50 +0000835def REP_STOSW : I<0xAB, RawFrm, (outs), (ins), "{rep;stosw|rep stosw}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000836 [(X86rep_stos i16)]>, REP, OpSize;
837let Defs = [ECX,EDI], Uses = [EAX,ECX,EDI] in
Evan Chengb783fa32007-07-19 01:14:50 +0000838def REP_STOSD : I<0xAB, RawFrm, (outs), (ins), "{rep;stosl|rep stosd}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000839 [(X86rep_stos i32)]>, REP;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000840
Sean Callanan481f06d2009-09-12 00:37:19 +0000841def SCAS8 : I<0xAE, RawFrm, (outs), (ins), "scas{b}", []>;
842def SCAS16 : I<0xAF, RawFrm, (outs), (ins), "scas{w}", []>, OpSize;
843def SCAS32 : I<0xAF, RawFrm, (outs), (ins), "scas{l}", []>;
844
Sean Callanan25220d62009-09-12 02:25:20 +0000845def CMPS8 : I<0xA6, RawFrm, (outs), (ins), "cmps{b}", []>;
846def CMPS16 : I<0xA7, RawFrm, (outs), (ins), "cmps{w}", []>, OpSize;
847def CMPS32 : I<0xA7, RawFrm, (outs), (ins), "cmps{l}", []>;
848
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000849let Defs = [RAX, RDX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000850def RDTSC : I<0x31, RawFrm, (outs), (ins), "rdtsc", [(X86rdtsc)]>,
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000851 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000852
Anton Korobeynikov39d40ba2008-01-15 07:02:33 +0000853let isBarrier = 1, hasCtrlDep = 1 in {
Chris Lattner56b941f2008-01-15 21:58:22 +0000854def TRAP : I<0x0B, RawFrm, (outs), (ins), "ud2", [(trap)]>, TB;
Anton Korobeynikov39d40ba2008-01-15 07:02:33 +0000855}
856
Chris Lattnerc96e27c2009-08-11 16:58:39 +0000857def SYSCALL : I<0x05, RawFrm,
858 (outs), (ins), "syscall", []>, TB;
859def SYSRET : I<0x07, RawFrm,
860 (outs), (ins), "sysret", []>, TB;
861def SYSENTER : I<0x34, RawFrm,
862 (outs), (ins), "sysenter", []>, TB;
863def SYSEXIT : I<0x35, RawFrm,
864 (outs), (ins), "sysexit", []>, TB;
865
Sean Callanan2c2313a2009-09-12 02:52:41 +0000866def WAIT : I<0x9B, RawFrm, (outs), (ins), "wait", []>;
Chris Lattnerc96e27c2009-08-11 16:58:39 +0000867
868
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000869//===----------------------------------------------------------------------===//
870// Input/Output Instructions...
871//
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000872let Defs = [AL], Uses = [DX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000873def IN8rr : I<0xEC, RawFrm, (outs), (ins),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000874 "in{b}\t{%dx, %al|%AL, %DX}", []>;
875let Defs = [AX], Uses = [DX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000876def IN16rr : I<0xED, RawFrm, (outs), (ins),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000877 "in{w}\t{%dx, %ax|%AX, %DX}", []>, OpSize;
878let Defs = [EAX], Uses = [DX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000879def IN32rr : I<0xED, RawFrm, (outs), (ins),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000880 "in{l}\t{%dx, %eax|%EAX, %DX}", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000881
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000882let Defs = [AL] in
Evan Chengb783fa32007-07-19 01:14:50 +0000883def IN8ri : Ii8<0xE4, RawFrm, (outs), (ins i16i8imm:$port),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000884 "in{b}\t{$port, %al|%AL, $port}", []>;
885let Defs = [AX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000886def IN16ri : Ii8<0xE5, RawFrm, (outs), (ins i16i8imm:$port),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000887 "in{w}\t{$port, %ax|%AX, $port}", []>, OpSize;
888let Defs = [EAX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000889def IN32ri : Ii8<0xE5, RawFrm, (outs), (ins i16i8imm:$port),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000890 "in{l}\t{$port, %eax|%EAX, $port}", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000891
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000892let Uses = [DX, AL] in
Evan Chengb783fa32007-07-19 01:14:50 +0000893def OUT8rr : I<0xEE, RawFrm, (outs), (ins),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000894 "out{b}\t{%al, %dx|%DX, %AL}", []>;
895let Uses = [DX, AX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000896def OUT16rr : I<0xEF, RawFrm, (outs), (ins),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000897 "out{w}\t{%ax, %dx|%DX, %AX}", []>, OpSize;
898let Uses = [DX, EAX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000899def OUT32rr : I<0xEF, RawFrm, (outs), (ins),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000900 "out{l}\t{%eax, %dx|%DX, %EAX}", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000901
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000902let Uses = [AL] in
Evan Chengb783fa32007-07-19 01:14:50 +0000903def OUT8ir : Ii8<0xE6, RawFrm, (outs), (ins i16i8imm:$port),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000904 "out{b}\t{%al, $port|$port, %AL}", []>;
905let Uses = [AX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000906def OUT16ir : Ii8<0xE7, RawFrm, (outs), (ins i16i8imm:$port),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000907 "out{w}\t{%ax, $port|$port, %AX}", []>, OpSize;
908let Uses = [EAX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000909def OUT32ir : Ii8<0xE7, RawFrm, (outs), (ins i16i8imm:$port),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000910 "out{l}\t{%eax, $port|$port, %EAX}", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000911
912//===----------------------------------------------------------------------===//
913// Move Instructions...
914//
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000915let neverHasSideEffects = 1 in {
Evan Chengb783fa32007-07-19 01:14:50 +0000916def MOV8rr : I<0x88, MRMDestReg, (outs GR8 :$dst), (ins GR8 :$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000917 "mov{b}\t{$src, $dst|$dst, $src}", []>;
Evan Chengb783fa32007-07-19 01:14:50 +0000918def MOV16rr : I<0x89, MRMDestReg, (outs GR16:$dst), (ins GR16:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000919 "mov{w}\t{$src, $dst|$dst, $src}", []>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +0000920def MOV32rr : I<0x89, MRMDestReg, (outs GR32:$dst), (ins GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000921 "mov{l}\t{$src, $dst|$dst, $src}", []>;
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000922}
Evan Cheng6f26e8b2008-06-18 08:13:07 +0000923let isReMaterializable = 1, isAsCheapAsAMove = 1 in {
Evan Chengb783fa32007-07-19 01:14:50 +0000924def MOV8ri : Ii8 <0xB0, AddRegFrm, (outs GR8 :$dst), (ins i8imm :$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000925 "mov{b}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000926 [(set GR8:$dst, imm:$src)]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000927def MOV16ri : Ii16<0xB8, AddRegFrm, (outs GR16:$dst), (ins i16imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000928 "mov{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000929 [(set GR16:$dst, imm:$src)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +0000930def MOV32ri : Ii32<0xB8, AddRegFrm, (outs GR32:$dst), (ins i32imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000931 "mov{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000932 [(set GR32:$dst, imm:$src)]>;
933}
Evan Chengb783fa32007-07-19 01:14:50 +0000934def MOV8mi : Ii8 <0xC6, MRM0m, (outs), (ins i8mem :$dst, i8imm :$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000935 "mov{b}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000936 [(store (i8 imm:$src), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000937def MOV16mi : Ii16<0xC7, MRM0m, (outs), (ins i16mem:$dst, i16imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000938 "mov{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000939 [(store (i16 imm:$src), addr:$dst)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +0000940def MOV32mi : Ii32<0xC7, MRM0m, (outs), (ins i32mem:$dst, i32imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000941 "mov{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000942 [(store (i32 imm:$src), addr:$dst)]>;
943
Sean Callanan70953a52009-09-10 18:33:42 +0000944def MOV8o8a : Ii8 <0xA0, RawFrm, (outs), (ins i8imm:$src),
945 "mov{b}\t{$src, %al|%al, $src}", []>;
946def MOV16o16a : Ii16 <0xA1, RawFrm, (outs), (ins i16imm:$src),
947 "mov{w}\t{$src, %ax|%ax, $src}", []>, OpSize;
948def MOV32o32a : Ii32 <0xA1, RawFrm, (outs), (ins i32imm:$src),
949 "mov{l}\t{$src, %eax|%eax, $src}", []>;
950
951def MOV8ao8 : Ii8 <0xA2, RawFrm, (outs i8imm:$dst), (ins),
952 "mov{b}\t{%al, $dst|$dst, %al}", []>;
953def MOV16ao16 : Ii16 <0xA3, RawFrm, (outs i16imm:$dst), (ins),
954 "mov{w}\t{%ax, $dst|$dst, %ax}", []>, OpSize;
955def MOV32ao32 : Ii32 <0xA3, RawFrm, (outs i32imm:$dst), (ins),
956 "mov{l}\t{%eax, $dst|$dst, %eax}", []>;
957
Sean Callananad87a3a2009-09-15 18:47:29 +0000958// Moves to and from segment registers
959def MOV16rs : I<0x8C, MRMDestReg, (outs GR16:$dst), (ins SEGMENT_REG:$src),
960 "mov{w}\t{$src, $dst|$dst, $src}", []>;
961def MOV16ms : I<0x8C, MRMDestMem, (outs i16mem:$dst), (ins SEGMENT_REG:$src),
962 "mov{w}\t{$src, $dst|$dst, $src}", []>;
963def MOV16sr : I<0x8E, MRMSrcReg, (outs SEGMENT_REG:$dst), (ins GR16:$src),
964 "mov{w}\t{$src, $dst|$dst, $src}", []>;
965def MOV16sm : I<0x8E, MRMSrcMem, (outs SEGMENT_REG:$dst), (ins i16mem:$src),
966 "mov{w}\t{$src, $dst|$dst, $src}", []>;
967
Dan Gohman5574cc72008-12-03 18:15:48 +0000968let canFoldAsLoad = 1, isReMaterializable = 1, mayHaveSideEffects = 1 in {
Evan Chengb783fa32007-07-19 01:14:50 +0000969def MOV8rm : I<0x8A, MRMSrcMem, (outs GR8 :$dst), (ins i8mem :$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000970 "mov{b}\t{$src, $dst|$dst, $src}",
Chris Lattner12208612009-04-10 00:16:23 +0000971 [(set GR8:$dst, (loadi8 addr:$src))]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000972def MOV16rm : I<0x8B, MRMSrcMem, (outs GR16:$dst), (ins i16mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000973 "mov{w}\t{$src, $dst|$dst, $src}",
Chris Lattner12208612009-04-10 00:16:23 +0000974 [(set GR16:$dst, (loadi16 addr:$src))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +0000975def MOV32rm : I<0x8B, MRMSrcMem, (outs GR32:$dst), (ins i32mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000976 "mov{l}\t{$src, $dst|$dst, $src}",
Chris Lattner12208612009-04-10 00:16:23 +0000977 [(set GR32:$dst, (loadi32 addr:$src))]>;
Evan Cheng4e84e452007-08-30 05:49:43 +0000978}
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000979
Evan Chengb783fa32007-07-19 01:14:50 +0000980def MOV8mr : I<0x88, MRMDestMem, (outs), (ins i8mem :$dst, GR8 :$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000981 "mov{b}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000982 [(store GR8:$src, addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000983def MOV16mr : I<0x89, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000984 "mov{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000985 [(store GR16:$src, addr:$dst)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +0000986def MOV32mr : I<0x89, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000987 "mov{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000988 [(store GR32:$src, addr:$dst)]>;
Dan Gohman744d4622009-04-13 16:09:41 +0000989
Dan Gohman1d8ce9c2009-04-27 16:41:36 +0000990// Versions of MOV8rr, MOV8mr, and MOV8rm that use i8mem_NOREX and GR8_NOREX so
991// that they can be used for copying and storing h registers, which can't be
992// encoded when a REX prefix is present.
Dan Gohman2da0db32009-04-15 00:04:23 +0000993let neverHasSideEffects = 1 in
Dan Gohman40ddc362009-04-15 19:48:57 +0000994def MOV8rr_NOREX : I<0x88, MRMDestReg,
995 (outs GR8_NOREX:$dst), (ins GR8_NOREX:$src),
Dan Gohman2da0db32009-04-15 00:04:23 +0000996 "mov{b}\t{$src, $dst|$dst, $src} # NOREX", []>;
Evan Chengebc49402009-04-30 00:58:57 +0000997let mayStore = 1 in
Dan Gohman2da0db32009-04-15 00:04:23 +0000998def MOV8mr_NOREX : I<0x88, MRMDestMem,
999 (outs), (ins i8mem_NOREX:$dst, GR8_NOREX:$src),
1000 "mov{b}\t{$src, $dst|$dst, $src} # NOREX", []>;
Evan Chengebc49402009-04-30 00:58:57 +00001001let mayLoad = 1,
1002 canFoldAsLoad = 1, isReMaterializable = 1, mayHaveSideEffects = 1 in
Dan Gohman1d8ce9c2009-04-27 16:41:36 +00001003def MOV8rm_NOREX : I<0x8A, MRMSrcMem,
1004 (outs GR8_NOREX:$dst), (ins i8mem_NOREX:$src),
1005 "mov{b}\t{$src, $dst|$dst, $src} # NOREX", []>;
Dan Gohman744d4622009-04-13 16:09:41 +00001006
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001007//===----------------------------------------------------------------------===//
1008// Fixed-Register Multiplication and Division Instructions...
1009//
1010
1011// Extra precision multiplication
Evan Cheng55687072007-09-14 21:48:26 +00001012let Defs = [AL,AH,EFLAGS], Uses = [AL] in
Dan Gohman91888f02007-07-31 20:11:57 +00001013def MUL8r : I<0xF6, MRM4r, (outs), (ins GR8:$src), "mul{b}\t$src",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001014 // FIXME: Used for 8-bit mul, ignore result upper 8 bits.
1015 // This probably ought to be moved to a def : Pat<> if the
1016 // syntax can be accepted.
Bill Wendlingf5399032008-12-12 21:15:41 +00001017 [(set AL, (mul AL, GR8:$src)),
1018 (implicit EFLAGS)]>; // AL,AH = AL*GR8
1019
Chris Lattnerc7e96e72008-01-11 07:18:17 +00001020let Defs = [AX,DX,EFLAGS], Uses = [AX], neverHasSideEffects = 1 in
Bill Wendlingf5399032008-12-12 21:15:41 +00001021def MUL16r : I<0xF7, MRM4r, (outs), (ins GR16:$src),
1022 "mul{w}\t$src",
1023 []>, OpSize; // AX,DX = AX*GR16
1024
Chris Lattnerc7e96e72008-01-11 07:18:17 +00001025let Defs = [EAX,EDX,EFLAGS], Uses = [EAX], neverHasSideEffects = 1 in
Bill Wendlingf5399032008-12-12 21:15:41 +00001026def MUL32r : I<0xF7, MRM4r, (outs), (ins GR32:$src),
1027 "mul{l}\t$src",
1028 []>; // EAX,EDX = EAX*GR32
1029
Evan Cheng55687072007-09-14 21:48:26 +00001030let Defs = [AL,AH,EFLAGS], Uses = [AL] in
Evan Chengb783fa32007-07-19 01:14:50 +00001031def MUL8m : I<0xF6, MRM4m, (outs), (ins i8mem :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001032 "mul{b}\t$src",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001033 // FIXME: Used for 8-bit mul, ignore result upper 8 bits.
1034 // This probably ought to be moved to a def : Pat<> if the
1035 // syntax can be accepted.
Bill Wendlingf5399032008-12-12 21:15:41 +00001036 [(set AL, (mul AL, (loadi8 addr:$src))),
1037 (implicit EFLAGS)]>; // AL,AH = AL*[mem8]
1038
Chris Lattnerc90ee9c2008-01-10 07:59:24 +00001039let mayLoad = 1, neverHasSideEffects = 1 in {
Evan Cheng55687072007-09-14 21:48:26 +00001040let Defs = [AX,DX,EFLAGS], Uses = [AX] in
Evan Chengb783fa32007-07-19 01:14:50 +00001041def MUL16m : I<0xF7, MRM4m, (outs), (ins i16mem:$src),
Bill Wendlingf5399032008-12-12 21:15:41 +00001042 "mul{w}\t$src",
1043 []>, OpSize; // AX,DX = AX*[mem16]
1044
Evan Cheng55687072007-09-14 21:48:26 +00001045let Defs = [EAX,EDX,EFLAGS], Uses = [EAX] in
Evan Chengb783fa32007-07-19 01:14:50 +00001046def MUL32m : I<0xF7, MRM4m, (outs), (ins i32mem:$src),
Bill Wendlingf5399032008-12-12 21:15:41 +00001047 "mul{l}\t$src",
1048 []>; // EAX,EDX = EAX*[mem32]
Chris Lattnerc90ee9c2008-01-10 07:59:24 +00001049}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001050
Chris Lattnerc90ee9c2008-01-10 07:59:24 +00001051let neverHasSideEffects = 1 in {
Evan Cheng55687072007-09-14 21:48:26 +00001052let Defs = [AL,AH,EFLAGS], Uses = [AL] in
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001053def IMUL8r : I<0xF6, MRM5r, (outs), (ins GR8:$src), "imul{b}\t$src", []>;
1054 // AL,AH = AL*GR8
Evan Cheng55687072007-09-14 21:48:26 +00001055let Defs = [AX,DX,EFLAGS], Uses = [AX] in
Dan Gohman91888f02007-07-31 20:11:57 +00001056def IMUL16r : I<0xF7, MRM5r, (outs), (ins GR16:$src), "imul{w}\t$src", []>,
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001057 OpSize; // AX,DX = AX*GR16
Evan Cheng55687072007-09-14 21:48:26 +00001058let Defs = [EAX,EDX,EFLAGS], Uses = [EAX] in
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001059def IMUL32r : I<0xF7, MRM5r, (outs), (ins GR32:$src), "imul{l}\t$src", []>;
1060 // EAX,EDX = EAX*GR32
Chris Lattnerc90ee9c2008-01-10 07:59:24 +00001061let mayLoad = 1 in {
Evan Cheng55687072007-09-14 21:48:26 +00001062let Defs = [AL,AH,EFLAGS], Uses = [AL] in
Evan Chengb783fa32007-07-19 01:14:50 +00001063def IMUL8m : I<0xF6, MRM5m, (outs), (ins i8mem :$src),
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001064 "imul{b}\t$src", []>; // AL,AH = AL*[mem8]
Evan Cheng55687072007-09-14 21:48:26 +00001065let Defs = [AX,DX,EFLAGS], Uses = [AX] in
Evan Chengb783fa32007-07-19 01:14:50 +00001066def IMUL16m : I<0xF7, MRM5m, (outs), (ins i16mem:$src),
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001067 "imul{w}\t$src", []>, OpSize; // AX,DX = AX*[mem16]
1068let Defs = [EAX,EDX], Uses = [EAX] in
Evan Chengb783fa32007-07-19 01:14:50 +00001069def IMUL32m : I<0xF7, MRM5m, (outs), (ins i32mem:$src),
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001070 "imul{l}\t$src", []>; // EAX,EDX = EAX*[mem32]
Chris Lattnerc90ee9c2008-01-10 07:59:24 +00001071}
Dan Gohmand44572d2008-11-18 21:29:14 +00001072} // neverHasSideEffects
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001073
1074// unsigned division/remainder
Dale Johannesend8fd3562008-10-07 18:54:28 +00001075let Defs = [AL,AH,EFLAGS], Uses = [AX] in
Evan Chengb783fa32007-07-19 01:14:50 +00001076def DIV8r : I<0xF6, MRM6r, (outs), (ins GR8:$src), // AX/r8 = AL,AH
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001077 "div{b}\t$src", []>;
Evan Cheng55687072007-09-14 21:48:26 +00001078let Defs = [AX,DX,EFLAGS], Uses = [AX,DX] in
Evan Chengb783fa32007-07-19 01:14:50 +00001079def DIV16r : I<0xF7, MRM6r, (outs), (ins GR16:$src), // DX:AX/r16 = AX,DX
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001080 "div{w}\t$src", []>, OpSize;
Evan Cheng55687072007-09-14 21:48:26 +00001081let Defs = [EAX,EDX,EFLAGS], Uses = [EAX,EDX] in
Evan Chengb783fa32007-07-19 01:14:50 +00001082def DIV32r : I<0xF7, MRM6r, (outs), (ins GR32:$src), // EDX:EAX/r32 = EAX,EDX
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001083 "div{l}\t$src", []>;
Chris Lattnerc90ee9c2008-01-10 07:59:24 +00001084let mayLoad = 1 in {
Dale Johannesend8fd3562008-10-07 18:54:28 +00001085let Defs = [AL,AH,EFLAGS], Uses = [AX] in
Evan Chengb783fa32007-07-19 01:14:50 +00001086def DIV8m : I<0xF6, MRM6m, (outs), (ins i8mem:$src), // AX/[mem8] = AL,AH
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001087 "div{b}\t$src", []>;
Evan Cheng55687072007-09-14 21:48:26 +00001088let Defs = [AX,DX,EFLAGS], Uses = [AX,DX] in
Evan Chengb783fa32007-07-19 01:14:50 +00001089def DIV16m : I<0xF7, MRM6m, (outs), (ins i16mem:$src), // DX:AX/[mem16] = AX,DX
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001090 "div{w}\t$src", []>, OpSize;
Evan Cheng55687072007-09-14 21:48:26 +00001091let Defs = [EAX,EDX,EFLAGS], Uses = [EAX,EDX] in
Evan Chengb783fa32007-07-19 01:14:50 +00001092def DIV32m : I<0xF7, MRM6m, (outs), (ins i32mem:$src), // EDX:EAX/[mem32] = EAX,EDX
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001093 "div{l}\t$src", []>;
Chris Lattnerc90ee9c2008-01-10 07:59:24 +00001094}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001095
1096// Signed division/remainder.
Dale Johannesend8fd3562008-10-07 18:54:28 +00001097let Defs = [AL,AH,EFLAGS], Uses = [AX] in
Evan Chengb783fa32007-07-19 01:14:50 +00001098def IDIV8r : I<0xF6, MRM7r, (outs), (ins GR8:$src), // AX/r8 = AL,AH
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001099 "idiv{b}\t$src", []>;
Evan Cheng55687072007-09-14 21:48:26 +00001100let Defs = [AX,DX,EFLAGS], Uses = [AX,DX] in
Evan Chengb783fa32007-07-19 01:14:50 +00001101def IDIV16r: I<0xF7, MRM7r, (outs), (ins GR16:$src), // DX:AX/r16 = AX,DX
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001102 "idiv{w}\t$src", []>, OpSize;
Evan Cheng55687072007-09-14 21:48:26 +00001103let Defs = [EAX,EDX,EFLAGS], Uses = [EAX,EDX] in
Evan Chengb783fa32007-07-19 01:14:50 +00001104def IDIV32r: I<0xF7, MRM7r, (outs), (ins GR32:$src), // EDX:EAX/r32 = EAX,EDX
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001105 "idiv{l}\t$src", []>;
Chris Lattnerc90ee9c2008-01-10 07:59:24 +00001106let mayLoad = 1, mayLoad = 1 in {
Dale Johannesend8fd3562008-10-07 18:54:28 +00001107let Defs = [AL,AH,EFLAGS], Uses = [AX] in
Evan Chengb783fa32007-07-19 01:14:50 +00001108def IDIV8m : I<0xF6, MRM7m, (outs), (ins i8mem:$src), // AX/[mem8] = AL,AH
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001109 "idiv{b}\t$src", []>;
Evan Cheng55687072007-09-14 21:48:26 +00001110let Defs = [AX,DX,EFLAGS], Uses = [AX,DX] in
Evan Chengb783fa32007-07-19 01:14:50 +00001111def IDIV16m: I<0xF7, MRM7m, (outs), (ins i16mem:$src), // DX:AX/[mem16] = AX,DX
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001112 "idiv{w}\t$src", []>, OpSize;
Evan Cheng55687072007-09-14 21:48:26 +00001113let Defs = [EAX,EDX,EFLAGS], Uses = [EAX,EDX] in
Evan Chengb783fa32007-07-19 01:14:50 +00001114def IDIV32m: I<0xF7, MRM7m, (outs), (ins i32mem:$src), // EDX:EAX/[mem32] = EAX,EDX
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001115 "idiv{l}\t$src", []>;
Chris Lattnerc90ee9c2008-01-10 07:59:24 +00001116}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001117
1118//===----------------------------------------------------------------------===//
Chris Lattnerc90ee9c2008-01-10 07:59:24 +00001119// Two address Instructions.
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001120//
1121let isTwoAddress = 1 in {
1122
1123// Conditional moves
Evan Cheng950aac02007-09-25 01:57:46 +00001124let Uses = [EFLAGS] in {
Dan Gohman29b998f2009-08-27 00:14:12 +00001125
1126// X86 doesn't have 8-bit conditional moves. Use a customDAGSchedInserter to
1127// emit control flow. An alternative to this is to mark i8 SELECT as Promote,
1128// however that requires promoting the operands, and can induce additional
Dan Gohman1596dd22009-08-29 22:19:15 +00001129// i8 register pressure. Note that CMOV_GR8 is conservatively considered to
1130// clobber EFLAGS, because if one of the operands is zero, the expansion
1131// could involve an xor.
1132let usesCustomDAGSchedInserter = 1, isTwoAddress = 0, Defs = [EFLAGS] in
Dan Gohman29b998f2009-08-27 00:14:12 +00001133def CMOV_GR8 : I<0, Pseudo,
1134 (outs GR8:$dst), (ins GR8:$src1, GR8:$src2, i8imm:$cond),
1135 "#CMOV_GR8 PSEUDO!",
1136 [(set GR8:$dst, (X86cmov GR8:$src1, GR8:$src2,
1137 imm:$cond, EFLAGS))]>;
1138
Dan Gohman90adb6c2009-08-27 18:16:24 +00001139let isCommutable = 1 in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001140def CMOVB16rr : I<0x42, MRMSrcReg, // if <u, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +00001141 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001142 "cmovb\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001143 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001144 X86_COND_B, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001145 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001146def CMOVB32rr : I<0x42, MRMSrcReg, // if <u, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +00001147 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001148 "cmovb\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001149 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001150 X86_COND_B, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001151 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001152def CMOVAE16rr: I<0x43, MRMSrcReg, // if >=u, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +00001153 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001154 "cmovae\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001155 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001156 X86_COND_AE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001157 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001158def CMOVAE32rr: I<0x43, MRMSrcReg, // if >=u, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +00001159 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001160 "cmovae\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001161 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001162 X86_COND_AE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001163 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001164def CMOVE16rr : I<0x44, MRMSrcReg, // if ==, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +00001165 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001166 "cmove\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001167 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001168 X86_COND_E, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001169 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001170def CMOVE32rr : I<0x44, MRMSrcReg, // if ==, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +00001171 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001172 "cmove\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001173 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001174 X86_COND_E, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001175 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001176def CMOVNE16rr: I<0x45, MRMSrcReg, // if !=, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +00001177 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001178 "cmovne\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001179 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001180 X86_COND_NE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001181 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001182def CMOVNE32rr: I<0x45, MRMSrcReg, // if !=, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +00001183 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001184 "cmovne\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001185 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001186 X86_COND_NE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001187 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001188def CMOVBE16rr: I<0x46, MRMSrcReg, // if <=u, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +00001189 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001190 "cmovbe\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001191 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001192 X86_COND_BE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001193 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001194def CMOVBE32rr: I<0x46, MRMSrcReg, // if <=u, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +00001195 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001196 "cmovbe\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001197 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001198 X86_COND_BE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001199 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001200def CMOVA16rr : I<0x47, MRMSrcReg, // if >u, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +00001201 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001202 "cmova\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001203 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001204 X86_COND_A, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001205 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001206def CMOVA32rr : I<0x47, MRMSrcReg, // if >u, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +00001207 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001208 "cmova\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001209 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001210 X86_COND_A, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001211 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001212def CMOVL16rr : I<0x4C, MRMSrcReg, // if <s, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +00001213 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001214 "cmovl\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001215 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001216 X86_COND_L, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001217 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001218def CMOVL32rr : I<0x4C, MRMSrcReg, // if <s, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +00001219 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001220 "cmovl\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001221 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001222 X86_COND_L, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001223 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001224def CMOVGE16rr: I<0x4D, MRMSrcReg, // if >=s, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +00001225 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001226 "cmovge\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001227 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001228 X86_COND_GE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001229 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001230def CMOVGE32rr: I<0x4D, MRMSrcReg, // if >=s, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +00001231 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001232 "cmovge\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001233 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001234 X86_COND_GE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001235 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001236def CMOVLE16rr: I<0x4E, MRMSrcReg, // if <=s, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +00001237 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001238 "cmovle\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001239 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001240 X86_COND_LE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001241 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001242def CMOVLE32rr: I<0x4E, MRMSrcReg, // if <=s, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +00001243 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001244 "cmovle\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001245 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001246 X86_COND_LE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001247 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001248def CMOVG16rr : I<0x4F, MRMSrcReg, // if >s, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +00001249 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001250 "cmovg\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001251 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001252 X86_COND_G, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001253 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001254def CMOVG32rr : I<0x4F, MRMSrcReg, // if >s, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +00001255 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001256 "cmovg\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001257 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001258 X86_COND_G, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001259 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001260def CMOVS16rr : I<0x48, MRMSrcReg, // if signed, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +00001261 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001262 "cmovs\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001263 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001264 X86_COND_S, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001265 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001266def CMOVS32rr : I<0x48, MRMSrcReg, // if signed, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +00001267 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001268 "cmovs\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001269 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001270 X86_COND_S, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001271 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001272def CMOVNS16rr: I<0x49, MRMSrcReg, // if !signed, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +00001273 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001274 "cmovns\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001275 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001276 X86_COND_NS, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001277 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001278def CMOVNS32rr: I<0x49, MRMSrcReg, // if !signed, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +00001279 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001280 "cmovns\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001281 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001282 X86_COND_NS, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001283 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001284def CMOVP16rr : I<0x4A, MRMSrcReg, // if parity, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +00001285 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001286 "cmovp\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001287 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001288 X86_COND_P, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001289 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001290def CMOVP32rr : I<0x4A, MRMSrcReg, // if parity, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +00001291 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001292 "cmovp\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001293 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001294 X86_COND_P, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001295 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001296def CMOVNP16rr : I<0x4B, MRMSrcReg, // if !parity, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +00001297 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001298 "cmovnp\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001299 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001300 X86_COND_NP, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001301 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001302def CMOVNP32rr : I<0x4B, MRMSrcReg, // if !parity, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +00001303 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001304 "cmovnp\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001305 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001306 X86_COND_NP, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001307 TB;
Dan Gohman12fd4d72009-01-07 00:35:10 +00001308def CMOVO16rr : I<0x40, MRMSrcReg, // if overflow, GR16 = GR16
1309 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
1310 "cmovo\t{$src2, $dst|$dst, $src2}",
1311 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
1312 X86_COND_O, EFLAGS))]>,
1313 TB, OpSize;
1314def CMOVO32rr : I<0x40, MRMSrcReg, // if overflow, GR32 = GR32
1315 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
1316 "cmovo\t{$src2, $dst|$dst, $src2}",
1317 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
1318 X86_COND_O, EFLAGS))]>,
Evan Cheng950aac02007-09-25 01:57:46 +00001319 TB;
Dan Gohman12fd4d72009-01-07 00:35:10 +00001320def CMOVNO16rr : I<0x41, MRMSrcReg, // if !overflow, GR16 = GR16
1321 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
1322 "cmovno\t{$src2, $dst|$dst, $src2}",
1323 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
1324 X86_COND_NO, EFLAGS))]>,
1325 TB, OpSize;
1326def CMOVNO32rr : I<0x41, MRMSrcReg, // if !overflow, GR32 = GR32
1327 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
1328 "cmovno\t{$src2, $dst|$dst, $src2}",
1329 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
1330 X86_COND_NO, EFLAGS))]>,
1331 TB;
1332} // isCommutable = 1
Evan Cheng926658c2007-10-05 23:13:21 +00001333
1334def CMOVB16rm : I<0x42, MRMSrcMem, // if <u, GR16 = [mem16]
1335 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1336 "cmovb\t{$src2, $dst|$dst, $src2}",
1337 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1338 X86_COND_B, EFLAGS))]>,
1339 TB, OpSize;
1340def CMOVB32rm : I<0x42, MRMSrcMem, // if <u, GR32 = [mem32]
1341 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1342 "cmovb\t{$src2, $dst|$dst, $src2}",
1343 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1344 X86_COND_B, EFLAGS))]>,
1345 TB;
1346def CMOVAE16rm: I<0x43, MRMSrcMem, // if >=u, GR16 = [mem16]
1347 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1348 "cmovae\t{$src2, $dst|$dst, $src2}",
1349 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1350 X86_COND_AE, EFLAGS))]>,
1351 TB, OpSize;
1352def CMOVAE32rm: I<0x43, MRMSrcMem, // if >=u, GR32 = [mem32]
1353 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1354 "cmovae\t{$src2, $dst|$dst, $src2}",
1355 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1356 X86_COND_AE, EFLAGS))]>,
1357 TB;
1358def CMOVE16rm : I<0x44, MRMSrcMem, // if ==, GR16 = [mem16]
1359 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1360 "cmove\t{$src2, $dst|$dst, $src2}",
1361 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1362 X86_COND_E, EFLAGS))]>,
1363 TB, OpSize;
1364def CMOVE32rm : I<0x44, MRMSrcMem, // if ==, GR32 = [mem32]
1365 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1366 "cmove\t{$src2, $dst|$dst, $src2}",
1367 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1368 X86_COND_E, EFLAGS))]>,
1369 TB;
1370def CMOVNE16rm: I<0x45, MRMSrcMem, // if !=, GR16 = [mem16]
1371 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1372 "cmovne\t{$src2, $dst|$dst, $src2}",
1373 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1374 X86_COND_NE, EFLAGS))]>,
1375 TB, OpSize;
1376def CMOVNE32rm: I<0x45, MRMSrcMem, // if !=, GR32 = [mem32]
1377 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1378 "cmovne\t{$src2, $dst|$dst, $src2}",
1379 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1380 X86_COND_NE, EFLAGS))]>,
1381 TB;
1382def CMOVBE16rm: I<0x46, MRMSrcMem, // if <=u, GR16 = [mem16]
1383 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1384 "cmovbe\t{$src2, $dst|$dst, $src2}",
1385 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1386 X86_COND_BE, EFLAGS))]>,
1387 TB, OpSize;
1388def CMOVBE32rm: I<0x46, MRMSrcMem, // if <=u, GR32 = [mem32]
1389 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1390 "cmovbe\t{$src2, $dst|$dst, $src2}",
1391 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1392 X86_COND_BE, EFLAGS))]>,
1393 TB;
1394def CMOVA16rm : I<0x47, MRMSrcMem, // if >u, GR16 = [mem16]
1395 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1396 "cmova\t{$src2, $dst|$dst, $src2}",
1397 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1398 X86_COND_A, EFLAGS))]>,
1399 TB, OpSize;
1400def CMOVA32rm : I<0x47, MRMSrcMem, // if >u, GR32 = [mem32]
1401 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1402 "cmova\t{$src2, $dst|$dst, $src2}",
1403 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1404 X86_COND_A, EFLAGS))]>,
1405 TB;
1406def CMOVL16rm : I<0x4C, MRMSrcMem, // if <s, GR16 = [mem16]
1407 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1408 "cmovl\t{$src2, $dst|$dst, $src2}",
1409 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1410 X86_COND_L, EFLAGS))]>,
1411 TB, OpSize;
1412def CMOVL32rm : I<0x4C, MRMSrcMem, // if <s, GR32 = [mem32]
1413 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1414 "cmovl\t{$src2, $dst|$dst, $src2}",
1415 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1416 X86_COND_L, EFLAGS))]>,
1417 TB;
1418def CMOVGE16rm: I<0x4D, MRMSrcMem, // if >=s, GR16 = [mem16]
1419 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1420 "cmovge\t{$src2, $dst|$dst, $src2}",
1421 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1422 X86_COND_GE, EFLAGS))]>,
1423 TB, OpSize;
1424def CMOVGE32rm: I<0x4D, MRMSrcMem, // if >=s, GR32 = [mem32]
1425 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1426 "cmovge\t{$src2, $dst|$dst, $src2}",
1427 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1428 X86_COND_GE, EFLAGS))]>,
1429 TB;
1430def CMOVLE16rm: I<0x4E, MRMSrcMem, // if <=s, GR16 = [mem16]
1431 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1432 "cmovle\t{$src2, $dst|$dst, $src2}",
1433 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1434 X86_COND_LE, EFLAGS))]>,
1435 TB, OpSize;
1436def CMOVLE32rm: I<0x4E, MRMSrcMem, // if <=s, GR32 = [mem32]
1437 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1438 "cmovle\t{$src2, $dst|$dst, $src2}",
1439 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1440 X86_COND_LE, EFLAGS))]>,
1441 TB;
1442def CMOVG16rm : I<0x4F, MRMSrcMem, // if >s, GR16 = [mem16]
1443 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1444 "cmovg\t{$src2, $dst|$dst, $src2}",
1445 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1446 X86_COND_G, EFLAGS))]>,
1447 TB, OpSize;
1448def CMOVG32rm : I<0x4F, MRMSrcMem, // if >s, GR32 = [mem32]
1449 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1450 "cmovg\t{$src2, $dst|$dst, $src2}",
1451 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1452 X86_COND_G, EFLAGS))]>,
1453 TB;
1454def CMOVS16rm : I<0x48, MRMSrcMem, // if signed, GR16 = [mem16]
1455 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1456 "cmovs\t{$src2, $dst|$dst, $src2}",
1457 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1458 X86_COND_S, EFLAGS))]>,
1459 TB, OpSize;
1460def CMOVS32rm : I<0x48, MRMSrcMem, // if signed, GR32 = [mem32]
1461 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1462 "cmovs\t{$src2, $dst|$dst, $src2}",
1463 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1464 X86_COND_S, EFLAGS))]>,
1465 TB;
1466def CMOVNS16rm: I<0x49, MRMSrcMem, // if !signed, GR16 = [mem16]
1467 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1468 "cmovns\t{$src2, $dst|$dst, $src2}",
1469 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1470 X86_COND_NS, EFLAGS))]>,
1471 TB, OpSize;
1472def CMOVNS32rm: I<0x49, MRMSrcMem, // if !signed, GR32 = [mem32]
1473 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1474 "cmovns\t{$src2, $dst|$dst, $src2}",
1475 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1476 X86_COND_NS, EFLAGS))]>,
1477 TB;
1478def CMOVP16rm : I<0x4A, MRMSrcMem, // if parity, GR16 = [mem16]
1479 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1480 "cmovp\t{$src2, $dst|$dst, $src2}",
1481 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1482 X86_COND_P, EFLAGS))]>,
1483 TB, OpSize;
1484def CMOVP32rm : I<0x4A, MRMSrcMem, // if parity, GR32 = [mem32]
1485 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1486 "cmovp\t{$src2, $dst|$dst, $src2}",
1487 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1488 X86_COND_P, EFLAGS))]>,
1489 TB;
1490def CMOVNP16rm : I<0x4B, MRMSrcMem, // if !parity, GR16 = [mem16]
1491 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1492 "cmovnp\t{$src2, $dst|$dst, $src2}",
1493 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1494 X86_COND_NP, EFLAGS))]>,
1495 TB, OpSize;
Dan Gohman12fd4d72009-01-07 00:35:10 +00001496def CMOVNP32rm : I<0x4B, MRMSrcMem, // if !parity, GR32 = [mem32]
1497 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1498 "cmovnp\t{$src2, $dst|$dst, $src2}",
1499 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1500 X86_COND_NP, EFLAGS))]>,
1501 TB;
1502def CMOVO16rm : I<0x40, MRMSrcMem, // if overflow, GR16 = [mem16]
1503 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1504 "cmovo\t{$src2, $dst|$dst, $src2}",
1505 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1506 X86_COND_O, EFLAGS))]>,
1507 TB, OpSize;
1508def CMOVO32rm : I<0x40, MRMSrcMem, // if overflow, GR32 = [mem32]
1509 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1510 "cmovo\t{$src2, $dst|$dst, $src2}",
1511 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1512 X86_COND_O, EFLAGS))]>,
1513 TB;
1514def CMOVNO16rm : I<0x41, MRMSrcMem, // if !overflow, GR16 = [mem16]
1515 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1516 "cmovno\t{$src2, $dst|$dst, $src2}",
1517 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1518 X86_COND_NO, EFLAGS))]>,
1519 TB, OpSize;
1520def CMOVNO32rm : I<0x41, MRMSrcMem, // if !overflow, GR32 = [mem32]
1521 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1522 "cmovno\t{$src2, $dst|$dst, $src2}",
1523 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1524 X86_COND_NO, EFLAGS))]>,
1525 TB;
Evan Cheng950aac02007-09-25 01:57:46 +00001526} // Uses = [EFLAGS]
1527
1528
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001529// unary instructions
1530let CodeSize = 2 in {
Evan Cheng55687072007-09-14 21:48:26 +00001531let Defs = [EFLAGS] in {
Dan Gohman91888f02007-07-31 20:11:57 +00001532def NEG8r : I<0xF6, MRM3r, (outs GR8 :$dst), (ins GR8 :$src), "neg{b}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001533 [(set GR8:$dst, (ineg GR8:$src)),
1534 (implicit EFLAGS)]>;
Dan Gohman91888f02007-07-31 20:11:57 +00001535def NEG16r : I<0xF7, MRM3r, (outs GR16:$dst), (ins GR16:$src), "neg{w}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001536 [(set GR16:$dst, (ineg GR16:$src)),
1537 (implicit EFLAGS)]>, OpSize;
Dan Gohman91888f02007-07-31 20:11:57 +00001538def NEG32r : I<0xF7, MRM3r, (outs GR32:$dst), (ins GR32:$src), "neg{l}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001539 [(set GR32:$dst, (ineg GR32:$src)),
1540 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001541let isTwoAddress = 0 in {
Dan Gohman91888f02007-07-31 20:11:57 +00001542 def NEG8m : I<0xF6, MRM3m, (outs), (ins i8mem :$dst), "neg{b}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001543 [(store (ineg (loadi8 addr:$dst)), addr:$dst),
1544 (implicit EFLAGS)]>;
Dan Gohman91888f02007-07-31 20:11:57 +00001545 def NEG16m : I<0xF7, MRM3m, (outs), (ins i16mem:$dst), "neg{w}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001546 [(store (ineg (loadi16 addr:$dst)), addr:$dst),
1547 (implicit EFLAGS)]>, OpSize;
Dan Gohman91888f02007-07-31 20:11:57 +00001548 def NEG32m : I<0xF7, MRM3m, (outs), (ins i32mem:$dst), "neg{l}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001549 [(store (ineg (loadi32 addr:$dst)), addr:$dst),
1550 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001551}
Evan Cheng55687072007-09-14 21:48:26 +00001552} // Defs = [EFLAGS]
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001553
Evan Chengc6cee682009-01-21 02:09:05 +00001554// Match xor -1 to not. Favors these over a move imm + xor to save code size.
1555let AddedComplexity = 15 in {
Dan Gohman91888f02007-07-31 20:11:57 +00001556def NOT8r : I<0xF6, MRM2r, (outs GR8 :$dst), (ins GR8 :$src), "not{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001557 [(set GR8:$dst, (not GR8:$src))]>;
Dan Gohman91888f02007-07-31 20:11:57 +00001558def NOT16r : I<0xF7, MRM2r, (outs GR16:$dst), (ins GR16:$src), "not{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001559 [(set GR16:$dst, (not GR16:$src))]>, OpSize;
Dan Gohman91888f02007-07-31 20:11:57 +00001560def NOT32r : I<0xF7, MRM2r, (outs GR32:$dst), (ins GR32:$src), "not{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001561 [(set GR32:$dst, (not GR32:$src))]>;
Evan Chengc6cee682009-01-21 02:09:05 +00001562}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001563let isTwoAddress = 0 in {
Dan Gohman91888f02007-07-31 20:11:57 +00001564 def NOT8m : I<0xF6, MRM2m, (outs), (ins i8mem :$dst), "not{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001565 [(store (not (loadi8 addr:$dst)), addr:$dst)]>;
Dan Gohman91888f02007-07-31 20:11:57 +00001566 def NOT16m : I<0xF7, MRM2m, (outs), (ins i16mem:$dst), "not{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001567 [(store (not (loadi16 addr:$dst)), addr:$dst)]>, OpSize;
Dan Gohman91888f02007-07-31 20:11:57 +00001568 def NOT32m : I<0xF7, MRM2m, (outs), (ins i32mem:$dst), "not{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001569 [(store (not (loadi32 addr:$dst)), addr:$dst)]>;
1570}
1571} // CodeSize
1572
1573// TODO: inc/dec is slow for P4, but fast for Pentium-M.
Evan Cheng55687072007-09-14 21:48:26 +00001574let Defs = [EFLAGS] in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001575let CodeSize = 2 in
Dan Gohman91888f02007-07-31 20:11:57 +00001576def INC8r : I<0xFE, MRM0r, (outs GR8 :$dst), (ins GR8 :$src), "inc{b}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001577 [(set GR8:$dst, (add GR8:$src, 1)),
1578 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001579let isConvertibleToThreeAddress = 1, CodeSize = 1 in { // Can xform into LEA.
Dan Gohman91888f02007-07-31 20:11:57 +00001580def INC16r : I<0x40, AddRegFrm, (outs GR16:$dst), (ins GR16:$src), "inc{w}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001581 [(set GR16:$dst, (add GR16:$src, 1)),
1582 (implicit EFLAGS)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001583 OpSize, Requires<[In32BitMode]>;
Dan Gohman91888f02007-07-31 20:11:57 +00001584def INC32r : I<0x40, AddRegFrm, (outs GR32:$dst), (ins GR32:$src), "inc{l}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001585 [(set GR32:$dst, (add GR32:$src, 1)),
1586 (implicit EFLAGS)]>, Requires<[In32BitMode]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001587}
1588let isTwoAddress = 0, CodeSize = 2 in {
Dan Gohman91888f02007-07-31 20:11:57 +00001589 def INC8m : I<0xFE, MRM0m, (outs), (ins i8mem :$dst), "inc{b}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001590 [(store (add (loadi8 addr:$dst), 1), addr:$dst),
1591 (implicit EFLAGS)]>;
Dan Gohman91888f02007-07-31 20:11:57 +00001592 def INC16m : I<0xFF, MRM0m, (outs), (ins i16mem:$dst), "inc{w}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001593 [(store (add (loadi16 addr:$dst), 1), addr:$dst),
1594 (implicit EFLAGS)]>,
Evan Cheng4a7e72f2007-10-19 21:23:22 +00001595 OpSize, Requires<[In32BitMode]>;
Dan Gohman91888f02007-07-31 20:11:57 +00001596 def INC32m : I<0xFF, MRM0m, (outs), (ins i32mem:$dst), "inc{l}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001597 [(store (add (loadi32 addr:$dst), 1), addr:$dst),
1598 (implicit EFLAGS)]>,
Evan Cheng4a7e72f2007-10-19 21:23:22 +00001599 Requires<[In32BitMode]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001600}
1601
1602let CodeSize = 2 in
Dan Gohman91888f02007-07-31 20:11:57 +00001603def DEC8r : I<0xFE, MRM1r, (outs GR8 :$dst), (ins GR8 :$src), "dec{b}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001604 [(set GR8:$dst, (add GR8:$src, -1)),
1605 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001606let isConvertibleToThreeAddress = 1, CodeSize = 1 in { // Can xform into LEA.
Dan Gohman91888f02007-07-31 20:11:57 +00001607def DEC16r : I<0x48, AddRegFrm, (outs GR16:$dst), (ins GR16:$src), "dec{w}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001608 [(set GR16:$dst, (add GR16:$src, -1)),
1609 (implicit EFLAGS)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001610 OpSize, Requires<[In32BitMode]>;
Dan Gohman91888f02007-07-31 20:11:57 +00001611def DEC32r : I<0x48, AddRegFrm, (outs GR32:$dst), (ins GR32:$src), "dec{l}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001612 [(set GR32:$dst, (add GR32:$src, -1)),
1613 (implicit EFLAGS)]>, Requires<[In32BitMode]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001614}
1615
1616let isTwoAddress = 0, CodeSize = 2 in {
Dan Gohman91888f02007-07-31 20:11:57 +00001617 def DEC8m : I<0xFE, MRM1m, (outs), (ins i8mem :$dst), "dec{b}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001618 [(store (add (loadi8 addr:$dst), -1), addr:$dst),
1619 (implicit EFLAGS)]>;
Dan Gohman91888f02007-07-31 20:11:57 +00001620 def DEC16m : I<0xFF, MRM1m, (outs), (ins i16mem:$dst), "dec{w}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001621 [(store (add (loadi16 addr:$dst), -1), addr:$dst),
1622 (implicit EFLAGS)]>,
Evan Cheng4a7e72f2007-10-19 21:23:22 +00001623 OpSize, Requires<[In32BitMode]>;
Dan Gohman91888f02007-07-31 20:11:57 +00001624 def DEC32m : I<0xFF, MRM1m, (outs), (ins i32mem:$dst), "dec{l}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001625 [(store (add (loadi32 addr:$dst), -1), addr:$dst),
1626 (implicit EFLAGS)]>,
Evan Cheng4a7e72f2007-10-19 21:23:22 +00001627 Requires<[In32BitMode]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001628}
Evan Cheng55687072007-09-14 21:48:26 +00001629} // Defs = [EFLAGS]
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001630
1631// Logical operators...
Evan Cheng55687072007-09-14 21:48:26 +00001632let Defs = [EFLAGS] in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001633let isCommutable = 1 in { // X = AND Y, Z --> X = AND Z, Y
1634def AND8rr : I<0x20, MRMDestReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001635 (outs GR8 :$dst), (ins GR8 :$src1, GR8 :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001636 "and{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001637 [(set GR8:$dst, (and GR8:$src1, GR8:$src2)),
1638 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001639def AND16rr : I<0x21, MRMDestReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001640 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001641 "and{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001642 [(set GR16:$dst, (and GR16:$src1, GR16:$src2)),
1643 (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001644def AND32rr : I<0x21, MRMDestReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001645 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001646 "and{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001647 [(set GR32:$dst, (and GR32:$src1, GR32:$src2)),
1648 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001649}
1650
1651def AND8rm : I<0x22, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001652 (outs GR8 :$dst), (ins GR8 :$src1, i8mem :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001653 "and{b}\t{$src2, $dst|$dst, $src2}",
Chris Lattner12208612009-04-10 00:16:23 +00001654 [(set GR8:$dst, (and GR8:$src1, (loadi8 addr:$src2))),
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001655 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001656def AND16rm : I<0x23, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001657 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001658 "and{w}\t{$src2, $dst|$dst, $src2}",
Chris Lattner12208612009-04-10 00:16:23 +00001659 [(set GR16:$dst, (and GR16:$src1, (loadi16 addr:$src2))),
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001660 (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001661def AND32rm : I<0x23, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001662 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001663 "and{l}\t{$src2, $dst|$dst, $src2}",
Chris Lattner12208612009-04-10 00:16:23 +00001664 [(set GR32:$dst, (and GR32:$src1, (loadi32 addr:$src2))),
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001665 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001666
1667def AND8ri : Ii8<0x80, MRM4r,
Evan Chengb783fa32007-07-19 01:14:50 +00001668 (outs GR8 :$dst), (ins GR8 :$src1, i8imm :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001669 "and{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001670 [(set GR8:$dst, (and GR8:$src1, imm:$src2)),
1671 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001672def AND16ri : Ii16<0x81, MRM4r,
Evan Chengb783fa32007-07-19 01:14:50 +00001673 (outs GR16:$dst), (ins GR16:$src1, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001674 "and{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001675 [(set GR16:$dst, (and GR16:$src1, imm:$src2)),
1676 (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001677def AND32ri : Ii32<0x81, MRM4r,
Evan Chengb783fa32007-07-19 01:14:50 +00001678 (outs GR32:$dst), (ins GR32:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001679 "and{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001680 [(set GR32:$dst, (and GR32:$src1, imm:$src2)),
1681 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001682def AND16ri8 : Ii8<0x83, MRM4r,
Evan Chengb783fa32007-07-19 01:14:50 +00001683 (outs GR16:$dst), (ins GR16:$src1, i16i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001684 "and{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001685 [(set GR16:$dst, (and GR16:$src1, i16immSExt8:$src2)),
1686 (implicit EFLAGS)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001687 OpSize;
1688def AND32ri8 : Ii8<0x83, MRM4r,
Evan Chengb783fa32007-07-19 01:14:50 +00001689 (outs GR32:$dst), (ins GR32:$src1, i32i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001690 "and{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001691 [(set GR32:$dst, (and GR32:$src1, i32immSExt8:$src2)),
1692 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001693
1694let isTwoAddress = 0 in {
1695 def AND8mr : I<0x20, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001696 (outs), (ins i8mem :$dst, GR8 :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001697 "and{b}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001698 [(store (and (load addr:$dst), GR8:$src), addr:$dst),
1699 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001700 def AND16mr : I<0x21, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001701 (outs), (ins i16mem:$dst, GR16:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001702 "and{w}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001703 [(store (and (load addr:$dst), GR16:$src), addr:$dst),
1704 (implicit EFLAGS)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001705 OpSize;
1706 def AND32mr : I<0x21, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001707 (outs), (ins i32mem:$dst, GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001708 "and{l}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001709 [(store (and (load addr:$dst), GR32:$src), addr:$dst),
1710 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001711 def AND8mi : Ii8<0x80, MRM4m,
Evan Chengb783fa32007-07-19 01:14:50 +00001712 (outs), (ins i8mem :$dst, i8imm :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001713 "and{b}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001714 [(store (and (loadi8 addr:$dst), imm:$src), addr:$dst),
1715 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001716 def AND16mi : Ii16<0x81, MRM4m,
Evan Chengb783fa32007-07-19 01:14:50 +00001717 (outs), (ins i16mem:$dst, i16imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001718 "and{w}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001719 [(store (and (loadi16 addr:$dst), imm:$src), addr:$dst),
1720 (implicit EFLAGS)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001721 OpSize;
1722 def AND32mi : Ii32<0x81, MRM4m,
Evan Chengb783fa32007-07-19 01:14:50 +00001723 (outs), (ins i32mem:$dst, i32imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001724 "and{l}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001725 [(store (and (loadi32 addr:$dst), imm:$src), addr:$dst),
1726 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001727 def AND16mi8 : Ii8<0x83, MRM4m,
Evan Chengb783fa32007-07-19 01:14:50 +00001728 (outs), (ins i16mem:$dst, i16i8imm :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001729 "and{w}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001730 [(store (and (load addr:$dst), i16immSExt8:$src), addr:$dst),
1731 (implicit EFLAGS)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001732 OpSize;
1733 def AND32mi8 : Ii8<0x83, MRM4m,
Evan Chengb783fa32007-07-19 01:14:50 +00001734 (outs), (ins i32mem:$dst, i32i8imm :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001735 "and{l}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001736 [(store (and (load addr:$dst), i32immSExt8:$src), addr:$dst),
1737 (implicit EFLAGS)]>;
Sean Callanan251676e2009-09-02 00:55:49 +00001738
1739 def AND8i8 : Ii8<0x24, RawFrm, (outs), (ins i8imm:$src),
1740 "and{b}\t{$src, %al|%al, $src}", []>;
1741 def AND16i16 : Ii16<0x25, RawFrm, (outs), (ins i16imm:$src),
1742 "and{w}\t{$src, %ax|%ax, $src}", []>, OpSize;
1743 def AND32i32 : Ii32<0x25, RawFrm, (outs), (ins i32imm:$src),
1744 "and{l}\t{$src, %eax|%eax, $src}", []>;
1745
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001746}
1747
1748
1749let isCommutable = 1 in { // X = OR Y, Z --> X = OR Z, Y
Evan Chengb783fa32007-07-19 01:14:50 +00001750def OR8rr : I<0x08, MRMDestReg, (outs GR8 :$dst), (ins GR8 :$src1, GR8 :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001751 "or{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001752 [(set GR8:$dst, (or GR8:$src1, GR8:$src2)),
1753 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001754def OR16rr : I<0x09, MRMDestReg, (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001755 "or{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001756 [(set GR16:$dst, (or GR16:$src1, GR16:$src2)),
1757 (implicit EFLAGS)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001758def OR32rr : I<0x09, MRMDestReg, (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001759 "or{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001760 [(set GR32:$dst, (or GR32:$src1, GR32:$src2)),
1761 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001762}
Evan Chengb783fa32007-07-19 01:14:50 +00001763def OR8rm : I<0x0A, MRMSrcMem , (outs GR8 :$dst), (ins GR8 :$src1, i8mem :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001764 "or{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001765 [(set GR8:$dst, (or GR8:$src1, (load addr:$src2))),
1766 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001767def OR16rm : I<0x0B, MRMSrcMem , (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001768 "or{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001769 [(set GR16:$dst, (or GR16:$src1, (load addr:$src2))),
1770 (implicit EFLAGS)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001771def OR32rm : I<0x0B, MRMSrcMem , (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001772 "or{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001773 [(set GR32:$dst, (or GR32:$src1, (load addr:$src2))),
1774 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001775
Evan Chengb783fa32007-07-19 01:14:50 +00001776def OR8ri : Ii8 <0x80, MRM1r, (outs GR8 :$dst), (ins GR8 :$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001777 "or{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001778 [(set GR8:$dst, (or GR8:$src1, imm:$src2)),
1779 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001780def OR16ri : Ii16<0x81, MRM1r, (outs GR16:$dst), (ins GR16:$src1, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001781 "or{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001782 [(set GR16:$dst, (or GR16:$src1, imm:$src2)),
1783 (implicit EFLAGS)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001784def OR32ri : Ii32<0x81, MRM1r, (outs GR32:$dst), (ins GR32:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001785 "or{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001786 [(set GR32:$dst, (or GR32:$src1, imm:$src2)),
1787 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001788
Evan Chengb783fa32007-07-19 01:14:50 +00001789def OR16ri8 : Ii8<0x83, MRM1r, (outs GR16:$dst), (ins GR16:$src1, i16i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001790 "or{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001791 [(set GR16:$dst, (or GR16:$src1, i16immSExt8:$src2)),
1792 (implicit EFLAGS)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001793def OR32ri8 : Ii8<0x83, MRM1r, (outs GR32:$dst), (ins GR32:$src1, i32i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001794 "or{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001795 [(set GR32:$dst, (or GR32:$src1, i32immSExt8:$src2)),
1796 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001797let isTwoAddress = 0 in {
Evan Chengb783fa32007-07-19 01:14:50 +00001798 def OR8mr : I<0x08, MRMDestMem, (outs), (ins i8mem:$dst, GR8:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001799 "or{b}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001800 [(store (or (load addr:$dst), GR8:$src), addr:$dst),
1801 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001802 def OR16mr : I<0x09, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001803 "or{w}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001804 [(store (or (load addr:$dst), GR16:$src), addr:$dst),
1805 (implicit EFLAGS)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001806 def OR32mr : I<0x09, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001807 "or{l}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001808 [(store (or (load addr:$dst), GR32:$src), addr:$dst),
1809 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001810 def OR8mi : Ii8<0x80, MRM1m, (outs), (ins i8mem :$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001811 "or{b}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001812 [(store (or (loadi8 addr:$dst), imm:$src), addr:$dst),
1813 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001814 def OR16mi : Ii16<0x81, MRM1m, (outs), (ins i16mem:$dst, i16imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001815 "or{w}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001816 [(store (or (loadi16 addr:$dst), imm:$src), addr:$dst),
1817 (implicit EFLAGS)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001818 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001819 def OR32mi : Ii32<0x81, MRM1m, (outs), (ins i32mem:$dst, i32imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001820 "or{l}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001821 [(store (or (loadi32 addr:$dst), imm:$src), addr:$dst),
1822 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001823 def OR16mi8 : Ii8<0x83, MRM1m, (outs), (ins i16mem:$dst, i16i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001824 "or{w}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001825 [(store (or (load addr:$dst), i16immSExt8:$src), addr:$dst),
1826 (implicit EFLAGS)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001827 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001828 def OR32mi8 : Ii8<0x83, MRM1m, (outs), (ins i32mem:$dst, i32i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001829 "or{l}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001830 [(store (or (load addr:$dst), i32immSExt8:$src), addr:$dst),
1831 (implicit EFLAGS)]>;
Sean Callanan8562bef2009-09-11 19:01:56 +00001832
1833 def OR8i8 : Ii8 <0x0C, RawFrm, (outs), (ins i8imm:$src),
1834 "or{b}\t{$src, %al|%al, $src}", []>;
1835 def OR16i16 : Ii16 <0x0D, RawFrm, (outs), (ins i16imm:$src),
1836 "or{w}\t{$src, %ax|%ax, $src}", []>, OpSize;
1837 def OR32i32 : Ii32 <0x0D, RawFrm, (outs), (ins i32imm:$src),
1838 "or{l}\t{$src, %eax|%eax, $src}", []>;
Bill Wendlingba5d5b02008-05-29 01:02:09 +00001839} // isTwoAddress = 0
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001840
1841
Evan Cheng6f26e8b2008-06-18 08:13:07 +00001842let isCommutable = 1 in { // X = XOR Y, Z --> X = XOR Z, Y
Bill Wendlingba5d5b02008-05-29 01:02:09 +00001843 def XOR8rr : I<0x30, MRMDestReg,
1844 (outs GR8 :$dst), (ins GR8 :$src1, GR8 :$src2),
1845 "xor{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001846 [(set GR8:$dst, (xor GR8:$src1, GR8:$src2)),
1847 (implicit EFLAGS)]>;
Bill Wendlingba5d5b02008-05-29 01:02:09 +00001848 def XOR16rr : I<0x31, MRMDestReg,
1849 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
1850 "xor{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001851 [(set GR16:$dst, (xor GR16:$src1, GR16:$src2)),
1852 (implicit EFLAGS)]>, OpSize;
Bill Wendlingba5d5b02008-05-29 01:02:09 +00001853 def XOR32rr : I<0x31, MRMDestReg,
1854 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
1855 "xor{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001856 [(set GR32:$dst, (xor GR32:$src1, GR32:$src2)),
1857 (implicit EFLAGS)]>;
Evan Cheng6f26e8b2008-06-18 08:13:07 +00001858} // isCommutable = 1
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001859
1860def XOR8rm : I<0x32, MRMSrcMem ,
Evan Chengb783fa32007-07-19 01:14:50 +00001861 (outs GR8 :$dst), (ins GR8:$src1, i8mem :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001862 "xor{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001863 [(set GR8:$dst, (xor GR8:$src1, (load addr:$src2))),
1864 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001865def XOR16rm : I<0x33, MRMSrcMem ,
Evan Chengb783fa32007-07-19 01:14:50 +00001866 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001867 "xor{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001868 [(set GR16:$dst, (xor GR16:$src1, (load addr:$src2))),
1869 (implicit EFLAGS)]>,
Bill Wendlingba5d5b02008-05-29 01:02:09 +00001870 OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001871def XOR32rm : I<0x33, MRMSrcMem ,
Evan Chengb783fa32007-07-19 01:14:50 +00001872 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001873 "xor{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001874 [(set GR32:$dst, (xor GR32:$src1, (load addr:$src2))),
1875 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001876
Bill Wendlingbac38eb2008-05-29 03:46:36 +00001877def XOR8ri : Ii8<0x80, MRM6r,
1878 (outs GR8:$dst), (ins GR8:$src1, i8imm:$src2),
1879 "xor{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001880 [(set GR8:$dst, (xor GR8:$src1, imm:$src2)),
1881 (implicit EFLAGS)]>;
Bill Wendlingbac38eb2008-05-29 03:46:36 +00001882def XOR16ri : Ii16<0x81, MRM6r,
1883 (outs GR16:$dst), (ins GR16:$src1, i16imm:$src2),
1884 "xor{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001885 [(set GR16:$dst, (xor GR16:$src1, imm:$src2)),
1886 (implicit EFLAGS)]>, OpSize;
Bill Wendlingbac38eb2008-05-29 03:46:36 +00001887def XOR32ri : Ii32<0x81, MRM6r,
1888 (outs GR32:$dst), (ins GR32:$src1, i32imm:$src2),
1889 "xor{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001890 [(set GR32:$dst, (xor GR32:$src1, imm:$src2)),
1891 (implicit EFLAGS)]>;
Bill Wendlingbac38eb2008-05-29 03:46:36 +00001892def XOR16ri8 : Ii8<0x83, MRM6r,
1893 (outs GR16:$dst), (ins GR16:$src1, i16i8imm:$src2),
1894 "xor{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001895 [(set GR16:$dst, (xor GR16:$src1, i16immSExt8:$src2)),
1896 (implicit EFLAGS)]>,
Bill Wendlingbac38eb2008-05-29 03:46:36 +00001897 OpSize;
1898def XOR32ri8 : Ii8<0x83, MRM6r,
1899 (outs GR32:$dst), (ins GR32:$src1, i32i8imm:$src2),
1900 "xor{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001901 [(set GR32:$dst, (xor GR32:$src1, i32immSExt8:$src2)),
1902 (implicit EFLAGS)]>;
Bill Wendlingba5d5b02008-05-29 01:02:09 +00001903
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001904let isTwoAddress = 0 in {
1905 def XOR8mr : I<0x30, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001906 (outs), (ins i8mem :$dst, GR8 :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001907 "xor{b}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001908 [(store (xor (load addr:$dst), GR8:$src), addr:$dst),
1909 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001910 def XOR16mr : I<0x31, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001911 (outs), (ins i16mem:$dst, GR16:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001912 "xor{w}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001913 [(store (xor (load addr:$dst), GR16:$src), addr:$dst),
1914 (implicit EFLAGS)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001915 OpSize;
1916 def XOR32mr : I<0x31, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001917 (outs), (ins i32mem:$dst, GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001918 "xor{l}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001919 [(store (xor (load addr:$dst), GR32:$src), addr:$dst),
1920 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001921 def XOR8mi : Ii8<0x80, MRM6m,
Evan Chengb783fa32007-07-19 01:14:50 +00001922 (outs), (ins i8mem :$dst, i8imm :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001923 "xor{b}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001924 [(store (xor (loadi8 addr:$dst), imm:$src), addr:$dst),
1925 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001926 def XOR16mi : Ii16<0x81, MRM6m,
Evan Chengb783fa32007-07-19 01:14:50 +00001927 (outs), (ins i16mem:$dst, i16imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001928 "xor{w}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001929 [(store (xor (loadi16 addr:$dst), imm:$src), addr:$dst),
1930 (implicit EFLAGS)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001931 OpSize;
1932 def XOR32mi : Ii32<0x81, MRM6m,
Evan Chengb783fa32007-07-19 01:14:50 +00001933 (outs), (ins i32mem:$dst, i32imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001934 "xor{l}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001935 [(store (xor (loadi32 addr:$dst), imm:$src), addr:$dst),
1936 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001937 def XOR16mi8 : Ii8<0x83, MRM6m,
Evan Chengb783fa32007-07-19 01:14:50 +00001938 (outs), (ins i16mem:$dst, i16i8imm :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001939 "xor{w}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001940 [(store (xor (load addr:$dst), i16immSExt8:$src), addr:$dst),
1941 (implicit EFLAGS)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001942 OpSize;
1943 def XOR32mi8 : Ii8<0x83, MRM6m,
Evan Chengb783fa32007-07-19 01:14:50 +00001944 (outs), (ins i32mem:$dst, i32i8imm :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001945 "xor{l}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001946 [(store (xor (load addr:$dst), i32immSExt8:$src), addr:$dst),
1947 (implicit EFLAGS)]>;
Sean Callanan794457a2009-09-10 19:52:26 +00001948
1949 def XOR8i8 : Ii8 <0x34, RawFrm, (outs), (ins i8imm:$src),
1950 "xor{b}\t{$src, %al|%al, $src}", []>;
1951 def XOR16i16 : Ii16 <0x35, RawFrm, (outs), (ins i16imm:$src),
1952 "xor{w}\t{$src, %ax|%ax, $src}", []>, OpSize;
1953 def XOR32i32 : Ii32 <0x35, RawFrm, (outs), (ins i32imm:$src),
1954 "xor{l}\t{$src, %eax|%eax, $src}", []>;
Bill Wendlingba5d5b02008-05-29 01:02:09 +00001955} // isTwoAddress = 0
Evan Cheng55687072007-09-14 21:48:26 +00001956} // Defs = [EFLAGS]
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001957
1958// Shift instructions
Evan Cheng55687072007-09-14 21:48:26 +00001959let Defs = [EFLAGS] in {
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001960let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00001961def SHL8rCL : I<0xD2, MRM4r, (outs GR8 :$dst), (ins GR8 :$src),
Eli Friedman378ea832009-06-19 04:48:38 +00001962 "shl{b}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001963 [(set GR8:$dst, (shl GR8:$src, CL))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001964def SHL16rCL : I<0xD3, MRM4r, (outs GR16:$dst), (ins GR16:$src),
Eli Friedman378ea832009-06-19 04:48:38 +00001965 "shl{w}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001966 [(set GR16:$dst, (shl GR16:$src, CL))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001967def SHL32rCL : I<0xD3, MRM4r, (outs GR32:$dst), (ins GR32:$src),
Eli Friedman378ea832009-06-19 04:48:38 +00001968 "shl{l}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001969 [(set GR32:$dst, (shl GR32:$src, CL))]>;
Bill Wendlingba5d5b02008-05-29 01:02:09 +00001970} // Uses = [CL]
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001971
Evan Chengb783fa32007-07-19 01:14:50 +00001972def SHL8ri : Ii8<0xC0, MRM4r, (outs GR8 :$dst), (ins GR8 :$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001973 "shl{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001974 [(set GR8:$dst, (shl GR8:$src1, (i8 imm:$src2)))]>;
1975let isConvertibleToThreeAddress = 1 in { // Can transform into LEA.
Evan Chengb783fa32007-07-19 01:14:50 +00001976def SHL16ri : Ii8<0xC1, MRM4r, (outs GR16:$dst), (ins GR16:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001977 "shl{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001978 [(set GR16:$dst, (shl GR16:$src1, (i8 imm:$src2)))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001979def SHL32ri : Ii8<0xC1, MRM4r, (outs GR32:$dst), (ins GR32:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001980 "shl{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001981 [(set GR32:$dst, (shl GR32:$src1, (i8 imm:$src2)))]>;
Sean Callananca503e02009-09-16 02:28:43 +00001982
1983// NOTE: We don't include patterns for shifts of a register by one, because
1984// 'add reg,reg' is cheaper.
1985
1986def SHL8r1 : I<0xD0, MRM4r, (outs GR8:$dst), (ins GR8:$src1),
1987 "shl{b}\t$dst", []>;
1988def SHL16r1 : I<0xD1, MRM4r, (outs GR16:$dst), (ins GR16:$src1),
1989 "shl{w}\t$dst", []>, OpSize;
1990def SHL32r1 : I<0xD1, MRM4r, (outs GR32:$dst), (ins GR32:$src1),
1991 "shl{l}\t$dst", []>;
1992
Bill Wendlingba5d5b02008-05-29 01:02:09 +00001993} // isConvertibleToThreeAddress = 1
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001994
1995let isTwoAddress = 0 in {
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001996 let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00001997 def SHL8mCL : I<0xD2, MRM4m, (outs), (ins i8mem :$dst),
Eli Friedman378ea832009-06-19 04:48:38 +00001998 "shl{b}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001999 [(store (shl (loadi8 addr:$dst), CL), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002000 def SHL16mCL : I<0xD3, MRM4m, (outs), (ins i16mem:$dst),
Eli Friedman378ea832009-06-19 04:48:38 +00002001 "shl{w}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002002 [(store (shl (loadi16 addr:$dst), CL), addr:$dst)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002003 def SHL32mCL : I<0xD3, MRM4m, (outs), (ins i32mem:$dst),
Eli Friedman378ea832009-06-19 04:48:38 +00002004 "shl{l}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002005 [(store (shl (loadi32 addr:$dst), CL), addr:$dst)]>;
2006 }
Evan Chengb783fa32007-07-19 01:14:50 +00002007 def SHL8mi : Ii8<0xC0, MRM4m, (outs), (ins i8mem :$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002008 "shl{b}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002009 [(store (shl (loadi8 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002010 def SHL16mi : Ii8<0xC1, MRM4m, (outs), (ins i16mem:$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002011 "shl{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002012 [(store (shl (loadi16 addr:$dst), (i8 imm:$src)), addr:$dst)]>,
2013 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002014 def SHL32mi : Ii8<0xC1, MRM4m, (outs), (ins i32mem:$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002015 "shl{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002016 [(store (shl (loadi32 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
2017
2018 // Shift by 1
Evan Chengb783fa32007-07-19 01:14:50 +00002019 def SHL8m1 : I<0xD0, MRM4m, (outs), (ins i8mem :$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002020 "shl{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002021 [(store (shl (loadi8 addr:$dst), (i8 1)), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002022 def SHL16m1 : I<0xD1, MRM4m, (outs), (ins i16mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002023 "shl{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002024 [(store (shl (loadi16 addr:$dst), (i8 1)), addr:$dst)]>,
2025 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002026 def SHL32m1 : I<0xD1, MRM4m, (outs), (ins i32mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002027 "shl{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002028 [(store (shl (loadi32 addr:$dst), (i8 1)), addr:$dst)]>;
2029}
2030
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002031let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00002032def SHR8rCL : I<0xD2, MRM5r, (outs GR8 :$dst), (ins GR8 :$src),
Eli Friedman378ea832009-06-19 04:48:38 +00002033 "shr{b}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002034 [(set GR8:$dst, (srl GR8:$src, CL))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002035def SHR16rCL : I<0xD3, MRM5r, (outs GR16:$dst), (ins GR16:$src),
Eli Friedman378ea832009-06-19 04:48:38 +00002036 "shr{w}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002037 [(set GR16:$dst, (srl GR16:$src, CL))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002038def SHR32rCL : I<0xD3, MRM5r, (outs GR32:$dst), (ins GR32:$src),
Eli Friedman378ea832009-06-19 04:48:38 +00002039 "shr{l}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002040 [(set GR32:$dst, (srl GR32:$src, CL))]>;
2041}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002042
Evan Chengb783fa32007-07-19 01:14:50 +00002043def SHR8ri : Ii8<0xC0, MRM5r, (outs GR8:$dst), (ins GR8:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002044 "shr{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002045 [(set GR8:$dst, (srl GR8:$src1, (i8 imm:$src2)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002046def SHR16ri : Ii8<0xC1, MRM5r, (outs GR16:$dst), (ins GR16:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002047 "shr{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002048 [(set GR16:$dst, (srl GR16:$src1, (i8 imm:$src2)))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002049def SHR32ri : Ii8<0xC1, MRM5r, (outs GR32:$dst), (ins GR32:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002050 "shr{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002051 [(set GR32:$dst, (srl GR32:$src1, (i8 imm:$src2)))]>;
2052
2053// Shift by 1
Evan Chengb783fa32007-07-19 01:14:50 +00002054def SHR8r1 : I<0xD0, MRM5r, (outs GR8:$dst), (ins GR8:$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00002055 "shr{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002056 [(set GR8:$dst, (srl GR8:$src1, (i8 1)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002057def SHR16r1 : I<0xD1, MRM5r, (outs GR16:$dst), (ins GR16:$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00002058 "shr{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002059 [(set GR16:$dst, (srl GR16:$src1, (i8 1)))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002060def SHR32r1 : I<0xD1, MRM5r, (outs GR32:$dst), (ins GR32:$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00002061 "shr{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002062 [(set GR32:$dst, (srl GR32:$src1, (i8 1)))]>;
2063
2064let isTwoAddress = 0 in {
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002065 let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00002066 def SHR8mCL : I<0xD2, MRM5m, (outs), (ins i8mem :$dst),
Eli Friedman378ea832009-06-19 04:48:38 +00002067 "shr{b}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002068 [(store (srl (loadi8 addr:$dst), CL), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002069 def SHR16mCL : I<0xD3, MRM5m, (outs), (ins i16mem:$dst),
Eli Friedman378ea832009-06-19 04:48:38 +00002070 "shr{w}\t{%cl, $dst|$dst, CL}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002071 [(store (srl (loadi16 addr:$dst), CL), addr:$dst)]>,
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002072 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002073 def SHR32mCL : I<0xD3, MRM5m, (outs), (ins i32mem:$dst),
Eli Friedman378ea832009-06-19 04:48:38 +00002074 "shr{l}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002075 [(store (srl (loadi32 addr:$dst), CL), addr:$dst)]>;
2076 }
Evan Chengb783fa32007-07-19 01:14:50 +00002077 def SHR8mi : Ii8<0xC0, MRM5m, (outs), (ins i8mem :$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002078 "shr{b}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002079 [(store (srl (loadi8 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002080 def SHR16mi : Ii8<0xC1, MRM5m, (outs), (ins i16mem:$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002081 "shr{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002082 [(store (srl (loadi16 addr:$dst), (i8 imm:$src)), addr:$dst)]>,
2083 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002084 def SHR32mi : Ii8<0xC1, MRM5m, (outs), (ins i32mem:$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002085 "shr{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002086 [(store (srl (loadi32 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
2087
2088 // Shift by 1
Evan Chengb783fa32007-07-19 01:14:50 +00002089 def SHR8m1 : I<0xD0, MRM5m, (outs), (ins i8mem :$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002090 "shr{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002091 [(store (srl (loadi8 addr:$dst), (i8 1)), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002092 def SHR16m1 : I<0xD1, MRM5m, (outs), (ins i16mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002093 "shr{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002094 [(store (srl (loadi16 addr:$dst), (i8 1)), addr:$dst)]>,OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002095 def SHR32m1 : I<0xD1, MRM5m, (outs), (ins i32mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002096 "shr{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002097 [(store (srl (loadi32 addr:$dst), (i8 1)), addr:$dst)]>;
2098}
2099
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002100let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00002101def SAR8rCL : I<0xD2, MRM7r, (outs GR8 :$dst), (ins GR8 :$src),
Eli Friedman378ea832009-06-19 04:48:38 +00002102 "sar{b}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002103 [(set GR8:$dst, (sra GR8:$src, CL))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002104def SAR16rCL : I<0xD3, MRM7r, (outs GR16:$dst), (ins GR16:$src),
Eli Friedman378ea832009-06-19 04:48:38 +00002105 "sar{w}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002106 [(set GR16:$dst, (sra GR16:$src, CL))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002107def SAR32rCL : I<0xD3, MRM7r, (outs GR32:$dst), (ins GR32:$src),
Eli Friedman378ea832009-06-19 04:48:38 +00002108 "sar{l}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002109 [(set GR32:$dst, (sra GR32:$src, CL))]>;
2110}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002111
Evan Chengb783fa32007-07-19 01:14:50 +00002112def SAR8ri : Ii8<0xC0, MRM7r, (outs GR8 :$dst), (ins GR8 :$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002113 "sar{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002114 [(set GR8:$dst, (sra GR8:$src1, (i8 imm:$src2)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002115def SAR16ri : Ii8<0xC1, MRM7r, (outs GR16:$dst), (ins GR16:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002116 "sar{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002117 [(set GR16:$dst, (sra GR16:$src1, (i8 imm:$src2)))]>,
2118 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002119def SAR32ri : Ii8<0xC1, MRM7r, (outs GR32:$dst), (ins GR32:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002120 "sar{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002121 [(set GR32:$dst, (sra GR32:$src1, (i8 imm:$src2)))]>;
2122
2123// Shift by 1
Evan Chengb783fa32007-07-19 01:14:50 +00002124def SAR8r1 : I<0xD0, MRM7r, (outs GR8 :$dst), (ins GR8 :$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00002125 "sar{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002126 [(set GR8:$dst, (sra GR8:$src1, (i8 1)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002127def SAR16r1 : I<0xD1, MRM7r, (outs GR16:$dst), (ins GR16:$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00002128 "sar{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002129 [(set GR16:$dst, (sra GR16:$src1, (i8 1)))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002130def SAR32r1 : I<0xD1, MRM7r, (outs GR32:$dst), (ins GR32:$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00002131 "sar{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002132 [(set GR32:$dst, (sra GR32:$src1, (i8 1)))]>;
2133
2134let isTwoAddress = 0 in {
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002135 let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00002136 def SAR8mCL : I<0xD2, MRM7m, (outs), (ins i8mem :$dst),
Eli Friedman378ea832009-06-19 04:48:38 +00002137 "sar{b}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002138 [(store (sra (loadi8 addr:$dst), CL), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002139 def SAR16mCL : I<0xD3, MRM7m, (outs), (ins i16mem:$dst),
Eli Friedman378ea832009-06-19 04:48:38 +00002140 "sar{w}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002141 [(store (sra (loadi16 addr:$dst), CL), addr:$dst)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002142 def SAR32mCL : I<0xD3, MRM7m, (outs), (ins i32mem:$dst),
Eli Friedman378ea832009-06-19 04:48:38 +00002143 "sar{l}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002144 [(store (sra (loadi32 addr:$dst), CL), addr:$dst)]>;
2145 }
Evan Chengb783fa32007-07-19 01:14:50 +00002146 def SAR8mi : Ii8<0xC0, MRM7m, (outs), (ins i8mem :$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002147 "sar{b}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002148 [(store (sra (loadi8 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002149 def SAR16mi : Ii8<0xC1, MRM7m, (outs), (ins i16mem:$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002150 "sar{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002151 [(store (sra (loadi16 addr:$dst), (i8 imm:$src)), addr:$dst)]>,
2152 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002153 def SAR32mi : Ii8<0xC1, MRM7m, (outs), (ins i32mem:$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002154 "sar{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002155 [(store (sra (loadi32 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
2156
2157 // Shift by 1
Evan Chengb783fa32007-07-19 01:14:50 +00002158 def SAR8m1 : I<0xD0, MRM7m, (outs), (ins i8mem :$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002159 "sar{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002160 [(store (sra (loadi8 addr:$dst), (i8 1)), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002161 def SAR16m1 : I<0xD1, MRM7m, (outs), (ins i16mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002162 "sar{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002163 [(store (sra (loadi16 addr:$dst), (i8 1)), addr:$dst)]>,
2164 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002165 def SAR32m1 : I<0xD1, MRM7m, (outs), (ins i32mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002166 "sar{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002167 [(store (sra (loadi32 addr:$dst), (i8 1)), addr:$dst)]>;
2168}
2169
2170// Rotate instructions
2171// FIXME: provide shorter instructions when imm8 == 1
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002172let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00002173def ROL8rCL : I<0xD2, MRM0r, (outs GR8 :$dst), (ins GR8 :$src),
Eli Friedman378ea832009-06-19 04:48:38 +00002174 "rol{b}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002175 [(set GR8:$dst, (rotl GR8:$src, CL))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002176def ROL16rCL : I<0xD3, MRM0r, (outs GR16:$dst), (ins GR16:$src),
Eli Friedman378ea832009-06-19 04:48:38 +00002177 "rol{w}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002178 [(set GR16:$dst, (rotl GR16:$src, CL))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002179def ROL32rCL : I<0xD3, MRM0r, (outs GR32:$dst), (ins GR32:$src),
Eli Friedman378ea832009-06-19 04:48:38 +00002180 "rol{l}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002181 [(set GR32:$dst, (rotl GR32:$src, CL))]>;
2182}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002183
Evan Chengb783fa32007-07-19 01:14:50 +00002184def ROL8ri : Ii8<0xC0, MRM0r, (outs GR8 :$dst), (ins GR8 :$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002185 "rol{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002186 [(set GR8:$dst, (rotl GR8:$src1, (i8 imm:$src2)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002187def ROL16ri : Ii8<0xC1, MRM0r, (outs GR16:$dst), (ins GR16:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002188 "rol{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002189 [(set GR16:$dst, (rotl GR16:$src1, (i8 imm:$src2)))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002190def ROL32ri : Ii8<0xC1, MRM0r, (outs GR32:$dst), (ins GR32:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002191 "rol{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002192 [(set GR32:$dst, (rotl GR32:$src1, (i8 imm:$src2)))]>;
2193
2194// Rotate by 1
Evan Chengb783fa32007-07-19 01:14:50 +00002195def ROL8r1 : I<0xD0, MRM0r, (outs GR8 :$dst), (ins GR8 :$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00002196 "rol{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002197 [(set GR8:$dst, (rotl GR8:$src1, (i8 1)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002198def ROL16r1 : I<0xD1, MRM0r, (outs GR16:$dst), (ins GR16:$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00002199 "rol{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002200 [(set GR16:$dst, (rotl GR16:$src1, (i8 1)))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002201def ROL32r1 : I<0xD1, MRM0r, (outs GR32:$dst), (ins GR32:$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00002202 "rol{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002203 [(set GR32:$dst, (rotl GR32:$src1, (i8 1)))]>;
2204
2205let isTwoAddress = 0 in {
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002206 let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00002207 def ROL8mCL : I<0xD2, MRM0m, (outs), (ins i8mem :$dst),
Eli Friedman378ea832009-06-19 04:48:38 +00002208 "rol{b}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002209 [(store (rotl (loadi8 addr:$dst), CL), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002210 def ROL16mCL : I<0xD3, MRM0m, (outs), (ins i16mem:$dst),
Eli Friedman378ea832009-06-19 04:48:38 +00002211 "rol{w}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002212 [(store (rotl (loadi16 addr:$dst), CL), addr:$dst)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002213 def ROL32mCL : I<0xD3, MRM0m, (outs), (ins i32mem:$dst),
Eli Friedman378ea832009-06-19 04:48:38 +00002214 "rol{l}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002215 [(store (rotl (loadi32 addr:$dst), CL), addr:$dst)]>;
2216 }
Evan Chengb783fa32007-07-19 01:14:50 +00002217 def ROL8mi : Ii8<0xC0, MRM0m, (outs), (ins i8mem :$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002218 "rol{b}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002219 [(store (rotl (loadi8 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002220 def ROL16mi : Ii8<0xC1, MRM0m, (outs), (ins i16mem:$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002221 "rol{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002222 [(store (rotl (loadi16 addr:$dst), (i8 imm:$src)), addr:$dst)]>,
2223 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002224 def ROL32mi : Ii8<0xC1, MRM0m, (outs), (ins i32mem:$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002225 "rol{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002226 [(store (rotl (loadi32 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
2227
2228 // Rotate by 1
Evan Chengb783fa32007-07-19 01:14:50 +00002229 def ROL8m1 : I<0xD0, MRM0m, (outs), (ins i8mem :$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002230 "rol{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002231 [(store (rotl (loadi8 addr:$dst), (i8 1)), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002232 def ROL16m1 : I<0xD1, MRM0m, (outs), (ins i16mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002233 "rol{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002234 [(store (rotl (loadi16 addr:$dst), (i8 1)), addr:$dst)]>,
2235 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002236 def ROL32m1 : I<0xD1, MRM0m, (outs), (ins i32mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002237 "rol{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002238 [(store (rotl (loadi32 addr:$dst), (i8 1)), addr:$dst)]>;
2239}
2240
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002241let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00002242def ROR8rCL : I<0xD2, MRM1r, (outs GR8 :$dst), (ins GR8 :$src),
Eli Friedman378ea832009-06-19 04:48:38 +00002243 "ror{b}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002244 [(set GR8:$dst, (rotr GR8:$src, CL))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002245def ROR16rCL : I<0xD3, MRM1r, (outs GR16:$dst), (ins GR16:$src),
Eli Friedman378ea832009-06-19 04:48:38 +00002246 "ror{w}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002247 [(set GR16:$dst, (rotr GR16:$src, CL))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002248def ROR32rCL : I<0xD3, MRM1r, (outs GR32:$dst), (ins GR32:$src),
Eli Friedman378ea832009-06-19 04:48:38 +00002249 "ror{l}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002250 [(set GR32:$dst, (rotr GR32:$src, CL))]>;
2251}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002252
Evan Chengb783fa32007-07-19 01:14:50 +00002253def ROR8ri : Ii8<0xC0, MRM1r, (outs GR8 :$dst), (ins GR8 :$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002254 "ror{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002255 [(set GR8:$dst, (rotr GR8:$src1, (i8 imm:$src2)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002256def ROR16ri : Ii8<0xC1, MRM1r, (outs GR16:$dst), (ins GR16:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002257 "ror{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002258 [(set GR16:$dst, (rotr GR16:$src1, (i8 imm:$src2)))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002259def ROR32ri : Ii8<0xC1, MRM1r, (outs GR32:$dst), (ins GR32:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002260 "ror{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002261 [(set GR32:$dst, (rotr GR32:$src1, (i8 imm:$src2)))]>;
2262
2263// Rotate by 1
Evan Chengb783fa32007-07-19 01:14:50 +00002264def ROR8r1 : I<0xD0, MRM1r, (outs GR8 :$dst), (ins GR8 :$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00002265 "ror{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002266 [(set GR8:$dst, (rotr GR8:$src1, (i8 1)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002267def ROR16r1 : I<0xD1, MRM1r, (outs GR16:$dst), (ins GR16:$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00002268 "ror{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002269 [(set GR16:$dst, (rotr GR16:$src1, (i8 1)))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002270def ROR32r1 : I<0xD1, MRM1r, (outs GR32:$dst), (ins GR32:$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00002271 "ror{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002272 [(set GR32:$dst, (rotr GR32:$src1, (i8 1)))]>;
2273
2274let isTwoAddress = 0 in {
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002275 let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00002276 def ROR8mCL : I<0xD2, MRM1m, (outs), (ins i8mem :$dst),
Eli Friedman378ea832009-06-19 04:48:38 +00002277 "ror{b}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002278 [(store (rotr (loadi8 addr:$dst), CL), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002279 def ROR16mCL : I<0xD3, MRM1m, (outs), (ins i16mem:$dst),
Eli Friedman378ea832009-06-19 04:48:38 +00002280 "ror{w}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002281 [(store (rotr (loadi16 addr:$dst), CL), addr:$dst)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002282 def ROR32mCL : I<0xD3, MRM1m, (outs), (ins i32mem:$dst),
Eli Friedman378ea832009-06-19 04:48:38 +00002283 "ror{l}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002284 [(store (rotr (loadi32 addr:$dst), CL), addr:$dst)]>;
2285 }
Evan Chengb783fa32007-07-19 01:14:50 +00002286 def ROR8mi : Ii8<0xC0, MRM1m, (outs), (ins i8mem :$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002287 "ror{b}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002288 [(store (rotr (loadi8 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002289 def ROR16mi : Ii8<0xC1, MRM1m, (outs), (ins i16mem:$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002290 "ror{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002291 [(store (rotr (loadi16 addr:$dst), (i8 imm:$src)), addr:$dst)]>,
2292 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002293 def ROR32mi : Ii8<0xC1, MRM1m, (outs), (ins i32mem:$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002294 "ror{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002295 [(store (rotr (loadi32 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
2296
2297 // Rotate by 1
Evan Chengb783fa32007-07-19 01:14:50 +00002298 def ROR8m1 : I<0xD0, MRM1m, (outs), (ins i8mem :$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002299 "ror{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002300 [(store (rotr (loadi8 addr:$dst), (i8 1)), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002301 def ROR16m1 : I<0xD1, MRM1m, (outs), (ins i16mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002302 "ror{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002303 [(store (rotr (loadi16 addr:$dst), (i8 1)), addr:$dst)]>,
2304 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002305 def ROR32m1 : I<0xD1, MRM1m, (outs), (ins i32mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002306 "ror{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002307 [(store (rotr (loadi32 addr:$dst), (i8 1)), addr:$dst)]>;
2308}
2309
2310
2311
2312// Double shift instructions (generalizations of rotate)
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002313let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00002314def SHLD32rrCL : I<0xA5, MRMDestReg, (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Eli Friedman378ea832009-06-19 04:48:38 +00002315 "shld{l}\t{%cl, $src2, $dst|$dst, $src2, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002316 [(set GR32:$dst, (X86shld GR32:$src1, GR32:$src2, CL))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00002317def SHRD32rrCL : I<0xAD, MRMDestReg, (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Eli Friedman378ea832009-06-19 04:48:38 +00002318 "shrd{l}\t{%cl, $src2, $dst|$dst, $src2, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002319 [(set GR32:$dst, (X86shrd GR32:$src1, GR32:$src2, CL))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00002320def SHLD16rrCL : I<0xA5, MRMDestReg, (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Eli Friedman378ea832009-06-19 04:48:38 +00002321 "shld{w}\t{%cl, $src2, $dst|$dst, $src2, CL}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002322 [(set GR16:$dst, (X86shld GR16:$src1, GR16:$src2, CL))]>,
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002323 TB, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002324def SHRD16rrCL : I<0xAD, MRMDestReg, (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Eli Friedman378ea832009-06-19 04:48:38 +00002325 "shrd{w}\t{%cl, $src2, $dst|$dst, $src2, CL}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002326 [(set GR16:$dst, (X86shrd GR16:$src1, GR16:$src2, CL))]>,
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002327 TB, OpSize;
2328}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002329
2330let isCommutable = 1 in { // These instructions commute to each other.
2331def SHLD32rri8 : Ii8<0xA4, MRMDestReg,
Evan Chengb783fa32007-07-19 01:14:50 +00002332 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2, i8imm:$src3),
Dan Gohman91888f02007-07-31 20:11:57 +00002333 "shld{l}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002334 [(set GR32:$dst, (X86shld GR32:$src1, GR32:$src2,
2335 (i8 imm:$src3)))]>,
2336 TB;
2337def SHRD32rri8 : Ii8<0xAC, MRMDestReg,
Evan Chengb783fa32007-07-19 01:14:50 +00002338 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2, i8imm:$src3),
Dan Gohman91888f02007-07-31 20:11:57 +00002339 "shrd{l}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002340 [(set GR32:$dst, (X86shrd GR32:$src1, GR32:$src2,
2341 (i8 imm:$src3)))]>,
2342 TB;
2343def SHLD16rri8 : Ii8<0xA4, MRMDestReg,
Evan Chengb783fa32007-07-19 01:14:50 +00002344 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2, i8imm:$src3),
Dan Gohman91888f02007-07-31 20:11:57 +00002345 "shld{w}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002346 [(set GR16:$dst, (X86shld GR16:$src1, GR16:$src2,
2347 (i8 imm:$src3)))]>,
2348 TB, OpSize;
2349def SHRD16rri8 : Ii8<0xAC, MRMDestReg,
Evan Chengb783fa32007-07-19 01:14:50 +00002350 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2, i8imm:$src3),
Dan Gohman91888f02007-07-31 20:11:57 +00002351 "shrd{w}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002352 [(set GR16:$dst, (X86shrd GR16:$src1, GR16:$src2,
2353 (i8 imm:$src3)))]>,
2354 TB, OpSize;
2355}
2356
2357let isTwoAddress = 0 in {
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002358 let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00002359 def SHLD32mrCL : I<0xA5, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
Eli Friedman378ea832009-06-19 04:48:38 +00002360 "shld{l}\t{%cl, $src2, $dst|$dst, $src2, CL}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002361 [(store (X86shld (loadi32 addr:$dst), GR32:$src2, CL),
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002362 addr:$dst)]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00002363 def SHRD32mrCL : I<0xAD, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
Eli Friedman378ea832009-06-19 04:48:38 +00002364 "shrd{l}\t{%cl, $src2, $dst|$dst, $src2, CL}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002365 [(store (X86shrd (loadi32 addr:$dst), GR32:$src2, CL),
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002366 addr:$dst)]>, TB;
2367 }
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002368 def SHLD32mri8 : Ii8<0xA4, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00002369 (outs), (ins i32mem:$dst, GR32:$src2, i8imm:$src3),
Dan Gohman91888f02007-07-31 20:11:57 +00002370 "shld{l}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002371 [(store (X86shld (loadi32 addr:$dst), GR32:$src2,
2372 (i8 imm:$src3)), addr:$dst)]>,
2373 TB;
2374 def SHRD32mri8 : Ii8<0xAC, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00002375 (outs), (ins i32mem:$dst, GR32:$src2, i8imm:$src3),
Dan Gohman91888f02007-07-31 20:11:57 +00002376 "shrd{l}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002377 [(store (X86shrd (loadi32 addr:$dst), GR32:$src2,
2378 (i8 imm:$src3)), addr:$dst)]>,
2379 TB;
2380
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002381 let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00002382 def SHLD16mrCL : I<0xA5, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
Eli Friedman378ea832009-06-19 04:48:38 +00002383 "shld{w}\t{%cl, $src2, $dst|$dst, $src2, CL}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002384 [(store (X86shld (loadi16 addr:$dst), GR16:$src2, CL),
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002385 addr:$dst)]>, TB, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002386 def SHRD16mrCL : I<0xAD, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
Eli Friedman378ea832009-06-19 04:48:38 +00002387 "shrd{w}\t{%cl, $src2, $dst|$dst, $src2, CL}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002388 [(store (X86shrd (loadi16 addr:$dst), GR16:$src2, CL),
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002389 addr:$dst)]>, TB, OpSize;
2390 }
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002391 def SHLD16mri8 : Ii8<0xA4, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00002392 (outs), (ins i16mem:$dst, GR16:$src2, i8imm:$src3),
Dan Gohman91888f02007-07-31 20:11:57 +00002393 "shld{w}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002394 [(store (X86shld (loadi16 addr:$dst), GR16:$src2,
2395 (i8 imm:$src3)), addr:$dst)]>,
2396 TB, OpSize;
2397 def SHRD16mri8 : Ii8<0xAC, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00002398 (outs), (ins i16mem:$dst, GR16:$src2, i8imm:$src3),
Dan Gohman91888f02007-07-31 20:11:57 +00002399 "shrd{w}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002400 [(store (X86shrd (loadi16 addr:$dst), GR16:$src2,
2401 (i8 imm:$src3)), addr:$dst)]>,
2402 TB, OpSize;
2403}
Evan Cheng55687072007-09-14 21:48:26 +00002404} // Defs = [EFLAGS]
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002405
2406
2407// Arithmetic.
Evan Cheng55687072007-09-14 21:48:26 +00002408let Defs = [EFLAGS] in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002409let isCommutable = 1 in { // X = ADD Y, Z --> X = ADD Z, Y
Bill Wendlingae034ed2008-12-12 00:56:36 +00002410// Register-Register Addition
2411def ADD8rr : I<0x00, MRMDestReg, (outs GR8 :$dst),
2412 (ins GR8 :$src1, GR8 :$src2),
2413 "add{b}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002414 [(set GR8:$dst, (add GR8:$src1, GR8:$src2)),
Bill Wendlingae034ed2008-12-12 00:56:36 +00002415 (implicit EFLAGS)]>;
2416
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002417let isConvertibleToThreeAddress = 1 in { // Can transform into LEA.
Bill Wendlingae034ed2008-12-12 00:56:36 +00002418// Register-Register Addition
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002419def ADD16rr : I<0x01, MRMDestReg, (outs GR16:$dst),
2420 (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002421 "add{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002422 [(set GR16:$dst, (add GR16:$src1, GR16:$src2)),
2423 (implicit EFLAGS)]>, OpSize;
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002424def ADD32rr : I<0x01, MRMDestReg, (outs GR32:$dst),
2425 (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002426 "add{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002427 [(set GR32:$dst, (add GR32:$src1, GR32:$src2)),
2428 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002429} // end isConvertibleToThreeAddress
2430} // end isCommutable
Bill Wendlingae034ed2008-12-12 00:56:36 +00002431
2432// Register-Memory Addition
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002433def ADD8rm : I<0x02, MRMSrcMem, (outs GR8 :$dst),
2434 (ins GR8 :$src1, i8mem :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002435 "add{b}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002436 [(set GR8:$dst, (add GR8:$src1, (load addr:$src2))),
2437 (implicit EFLAGS)]>;
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002438def ADD16rm : I<0x03, MRMSrcMem, (outs GR16:$dst),
2439 (ins GR16:$src1, i16mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002440 "add{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002441 [(set GR16:$dst, (add GR16:$src1, (load addr:$src2))),
2442 (implicit EFLAGS)]>, OpSize;
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002443def ADD32rm : I<0x03, MRMSrcMem, (outs GR32:$dst),
2444 (ins GR32:$src1, i32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002445 "add{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002446 [(set GR32:$dst, (add GR32:$src1, (load addr:$src2))),
2447 (implicit EFLAGS)]>;
Sean Callanan7e7df0e2009-09-15 20:53:57 +00002448
Sean Callanan84df9312009-09-15 21:43:27 +00002449// Register-Register Addition - Equivalent to the normal rr forms (ADD8rr,
2450// ADD16rr, and ADD32rr), but differently encoded.
Sean Callanan7e7df0e2009-09-15 20:53:57 +00002451def ADD8mrmrr: I<0x02, MRMSrcReg, (outs GR8:$dst), (ins GR8:$src1, GR8:$src2),
2452 "add{b}\t{$src2, $dst|$dst, $src2}", []>;
2453def ADD16mrmrr: I<0x03, MRMSrcReg,(outs GR16:$dst),(ins GR16:$src1, GR16:$src2),
2454 "add{w}\t{$src2, $dst|$dst, $src2}", []>, OpSize;
2455def ADD32mrmrr: I<0x03, MRMSrcReg,(outs GR16:$dst),(ins GR16:$src1, GR16:$src2),
2456 "add{l}\t{$src2, $dst|$dst, $src2}", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002457
Bill Wendlingae034ed2008-12-12 00:56:36 +00002458// Register-Integer Addition
2459def ADD8ri : Ii8<0x80, MRM0r, (outs GR8:$dst), (ins GR8:$src1, i8imm:$src2),
2460 "add{b}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002461 [(set GR8:$dst, (add GR8:$src1, imm:$src2)),
2462 (implicit EFLAGS)]>;
Bill Wendlingae034ed2008-12-12 00:56:36 +00002463
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002464let isConvertibleToThreeAddress = 1 in { // Can transform into LEA.
Bill Wendlingae034ed2008-12-12 00:56:36 +00002465// Register-Integer Addition
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002466def ADD16ri : Ii16<0x81, MRM0r, (outs GR16:$dst),
2467 (ins GR16:$src1, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002468 "add{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002469 [(set GR16:$dst, (add GR16:$src1, imm:$src2)),
2470 (implicit EFLAGS)]>, OpSize;
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002471def ADD32ri : Ii32<0x81, MRM0r, (outs GR32:$dst),
2472 (ins GR32:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002473 "add{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002474 [(set GR32:$dst, (add GR32:$src1, imm:$src2)),
2475 (implicit EFLAGS)]>;
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002476def ADD16ri8 : Ii8<0x83, MRM0r, (outs GR16:$dst),
2477 (ins GR16:$src1, i16i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002478 "add{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002479 [(set GR16:$dst, (add GR16:$src1, i16immSExt8:$src2)),
2480 (implicit EFLAGS)]>, OpSize;
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002481def ADD32ri8 : Ii8<0x83, MRM0r, (outs GR32:$dst),
2482 (ins GR32:$src1, i32i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002483 "add{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002484 [(set GR32:$dst, (add GR32:$src1, i32immSExt8:$src2)),
2485 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002486}
2487
2488let isTwoAddress = 0 in {
Bill Wendlingae034ed2008-12-12 00:56:36 +00002489 // Memory-Register Addition
Bill Wendlingf5399032008-12-12 21:15:41 +00002490 def ADD8mr : I<0x00, MRMDestMem, (outs), (ins i8mem:$dst, GR8:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002491 "add{b}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002492 [(store (add (load addr:$dst), GR8:$src2), addr:$dst),
2493 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002494 def ADD16mr : I<0x01, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002495 "add{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002496 [(store (add (load addr:$dst), GR16:$src2), addr:$dst),
2497 (implicit EFLAGS)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002498 def ADD32mr : I<0x01, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002499 "add{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002500 [(store (add (load addr:$dst), GR32:$src2), addr:$dst),
2501 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002502 def ADD8mi : Ii8<0x80, MRM0m, (outs), (ins i8mem :$dst, i8imm :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002503 "add{b}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002504 [(store (add (loadi8 addr:$dst), imm:$src2), addr:$dst),
2505 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002506 def ADD16mi : Ii16<0x81, MRM0m, (outs), (ins i16mem:$dst, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002507 "add{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002508 [(store (add (loadi16 addr:$dst), imm:$src2), addr:$dst),
2509 (implicit EFLAGS)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002510 def ADD32mi : Ii32<0x81, MRM0m, (outs), (ins i32mem:$dst, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002511 "add{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002512 [(store (add (loadi32 addr:$dst), imm:$src2), addr:$dst),
2513 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002514 def ADD16mi8 : Ii8<0x83, MRM0m, (outs), (ins i16mem:$dst, i16i8imm :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002515 "add{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002516 [(store (add (load addr:$dst), i16immSExt8:$src2),
2517 addr:$dst),
2518 (implicit EFLAGS)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002519 def ADD32mi8 : Ii8<0x83, MRM0m, (outs), (ins i32mem:$dst, i32i8imm :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002520 "add{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingae034ed2008-12-12 00:56:36 +00002521 [(store (add (load addr:$dst), i32immSExt8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00002522 addr:$dst),
2523 (implicit EFLAGS)]>;
Sean Callanan0316b342009-08-11 21:26:06 +00002524
2525 // addition to rAX
2526 def ADD8i8 : Ii8<0x04, RawFrm, (outs), (ins i8imm:$src),
Sean Callanan251676e2009-09-02 00:55:49 +00002527 "add{b}\t{$src, %al|%al, $src}", []>;
Sean Callanan0316b342009-08-11 21:26:06 +00002528 def ADD16i16 : Ii16<0x05, RawFrm, (outs), (ins i16imm:$src),
Sean Callanan251676e2009-09-02 00:55:49 +00002529 "add{w}\t{$src, %ax|%ax, $src}", []>, OpSize;
Sean Callanan0316b342009-08-11 21:26:06 +00002530 def ADD32i32 : Ii32<0x05, RawFrm, (outs), (ins i32imm:$src),
Sean Callanan251676e2009-09-02 00:55:49 +00002531 "add{l}\t{$src, %eax|%eax, $src}", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002532}
2533
Evan Cheng259471d2007-10-05 17:59:57 +00002534let Uses = [EFLAGS] in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002535let isCommutable = 1 in { // X = ADC Y, Z --> X = ADC Z, Y
Dale Johannesen747fe522009-06-02 03:12:52 +00002536def ADC8rr : I<0x10, MRMDestReg, (outs GR8:$dst), (ins GR8:$src1, GR8:$src2),
Dale Johannesen06b83f12009-05-18 17:44:15 +00002537 "adc{b}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002538 [(set GR8:$dst, (adde GR8:$src1, GR8:$src2))]>;
Dale Johannesen06b83f12009-05-18 17:44:15 +00002539def ADC16rr : I<0x11, MRMDestReg, (outs GR16:$dst),
2540 (ins GR16:$src1, GR16:$src2),
2541 "adc{w}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002542 [(set GR16:$dst, (adde GR16:$src1, GR16:$src2))]>, OpSize;
Dale Johannesen06b83f12009-05-18 17:44:15 +00002543def ADC32rr : I<0x11, MRMDestReg, (outs GR32:$dst),
2544 (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002545 "adc{l}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002546 [(set GR32:$dst, (adde GR32:$src1, GR32:$src2))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002547}
Dale Johannesen06b83f12009-05-18 17:44:15 +00002548def ADC8rm : I<0x12, MRMSrcMem , (outs GR8:$dst),
2549 (ins GR8:$src1, i8mem:$src2),
2550 "adc{b}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002551 [(set GR8:$dst, (adde GR8:$src1, (load addr:$src2)))]>;
Dale Johannesen06b83f12009-05-18 17:44:15 +00002552def ADC16rm : I<0x13, MRMSrcMem , (outs GR16:$dst),
2553 (ins GR16:$src1, i16mem:$src2),
2554 "adc{w}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002555 [(set GR16:$dst, (adde GR16:$src1, (load addr:$src2)))]>,
Dale Johannesen067cfb22009-05-18 21:41:59 +00002556 OpSize;
Dale Johannesen06b83f12009-05-18 17:44:15 +00002557def ADC32rm : I<0x13, MRMSrcMem , (outs GR32:$dst),
2558 (ins GR32:$src1, i32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002559 "adc{l}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002560 [(set GR32:$dst, (adde GR32:$src1, (load addr:$src2)))]>;
2561def ADC8ri : Ii8<0x80, MRM2r, (outs GR8:$dst), (ins GR8:$src1, i8imm:$src2),
Dale Johannesen06b83f12009-05-18 17:44:15 +00002562 "adc{b}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002563 [(set GR8:$dst, (adde GR8:$src1, imm:$src2))]>;
Dale Johannesen06b83f12009-05-18 17:44:15 +00002564def ADC16ri : Ii16<0x81, MRM2r, (outs GR16:$dst),
2565 (ins GR16:$src1, i16imm:$src2),
2566 "adc{w}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002567 [(set GR16:$dst, (adde GR16:$src1, imm:$src2))]>, OpSize;
Dale Johannesen06b83f12009-05-18 17:44:15 +00002568def ADC16ri8 : Ii8<0x83, MRM2r, (outs GR16:$dst),
2569 (ins GR16:$src1, i16i8imm:$src2),
2570 "adc{w}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002571 [(set GR16:$dst, (adde GR16:$src1, i16immSExt8:$src2))]>,
2572 OpSize;
Dale Johannesen06b83f12009-05-18 17:44:15 +00002573def ADC32ri : Ii32<0x81, MRM2r, (outs GR32:$dst),
2574 (ins GR32:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002575 "adc{l}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002576 [(set GR32:$dst, (adde GR32:$src1, imm:$src2))]>;
Dale Johannesen06b83f12009-05-18 17:44:15 +00002577def ADC32ri8 : Ii8<0x83, MRM2r, (outs GR32:$dst),
2578 (ins GR32:$src1, i32i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002579 "adc{l}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002580 [(set GR32:$dst, (adde GR32:$src1, i32immSExt8:$src2))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002581
2582let isTwoAddress = 0 in {
Dale Johannesen747fe522009-06-02 03:12:52 +00002583 def ADC8mr : I<0x10, MRMDestMem, (outs), (ins i8mem:$dst, GR8:$src2),
Dale Johannesen06b83f12009-05-18 17:44:15 +00002584 "adc{b}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002585 [(store (adde (load addr:$dst), GR8:$src2), addr:$dst)]>;
2586 def ADC16mr : I<0x11, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
Dale Johannesen06b83f12009-05-18 17:44:15 +00002587 "adc{w}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002588 [(store (adde (load addr:$dst), GR16:$src2), addr:$dst)]>,
2589 OpSize;
2590 def ADC32mr : I<0x11, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002591 "adc{l}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002592 [(store (adde (load addr:$dst), GR32:$src2), addr:$dst)]>;
2593 def ADC8mi : Ii8<0x80, MRM2m, (outs), (ins i8mem:$dst, i8imm:$src2),
Dale Johannesen06b83f12009-05-18 17:44:15 +00002594 "adc{b}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002595 [(store (adde (loadi8 addr:$dst), imm:$src2), addr:$dst)]>;
2596 def ADC16mi : Ii16<0x81, MRM2m, (outs), (ins i16mem:$dst, i16imm:$src2),
Dale Johannesen06b83f12009-05-18 17:44:15 +00002597 "adc{w}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002598 [(store (adde (loadi16 addr:$dst), imm:$src2), addr:$dst)]>,
2599 OpSize;
2600 def ADC16mi8 : Ii8<0x83, MRM2m, (outs), (ins i16mem:$dst, i16i8imm :$src2),
Dale Johannesen06b83f12009-05-18 17:44:15 +00002601 "adc{w}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002602 [(store (adde (load addr:$dst), i16immSExt8:$src2), addr:$dst)]>,
2603 OpSize;
2604 def ADC32mi : Ii32<0x81, MRM2m, (outs), (ins i32mem:$dst, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002605 "adc{l}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002606 [(store (adde (loadi32 addr:$dst), imm:$src2), addr:$dst)]>;
2607 def ADC32mi8 : Ii8<0x83, MRM2m, (outs), (ins i32mem:$dst, i32i8imm :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002608 "adc{l}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002609 [(store (adde (load addr:$dst), i32immSExt8:$src2), addr:$dst)]>;
Sean Callanan8562bef2009-09-11 19:01:56 +00002610
2611 def ADC8i8 : Ii8<0x14, RawFrm, (outs), (ins i8imm:$src),
2612 "adc{b}\t{$src, %al|%al, $src}", []>;
2613 def ADC16i16 : Ii16<0x15, RawFrm, (outs), (ins i16imm:$src),
2614 "adc{w}\t{$src, %ax|%ax, $src}", []>, OpSize;
2615 def ADC32i32 : Ii32<0x15, RawFrm, (outs), (ins i32imm:$src),
2616 "adc{l}\t{$src, %eax|%eax, $src}", []>;
Dale Johannesen747fe522009-06-02 03:12:52 +00002617}
Evan Cheng259471d2007-10-05 17:59:57 +00002618} // Uses = [EFLAGS]
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002619
Bill Wendlingae034ed2008-12-12 00:56:36 +00002620// Register-Register Subtraction
2621def SUB8rr : I<0x28, MRMDestReg, (outs GR8:$dst), (ins GR8:$src1, GR8:$src2),
2622 "sub{b}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002623 [(set GR8:$dst, (sub GR8:$src1, GR8:$src2)),
2624 (implicit EFLAGS)]>;
Bill Wendlingae034ed2008-12-12 00:56:36 +00002625def SUB16rr : I<0x29, MRMDestReg, (outs GR16:$dst), (ins GR16:$src1,GR16:$src2),
2626 "sub{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002627 [(set GR16:$dst, (sub GR16:$src1, GR16:$src2)),
2628 (implicit EFLAGS)]>, OpSize;
Bill Wendlingae034ed2008-12-12 00:56:36 +00002629def SUB32rr : I<0x29, MRMDestReg, (outs GR32:$dst), (ins GR32:$src1,GR32:$src2),
2630 "sub{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002631 [(set GR32:$dst, (sub GR32:$src1, GR32:$src2)),
2632 (implicit EFLAGS)]>;
Bill Wendlingae034ed2008-12-12 00:56:36 +00002633
2634// Register-Memory Subtraction
2635def SUB8rm : I<0x2A, MRMSrcMem, (outs GR8 :$dst),
2636 (ins GR8 :$src1, i8mem :$src2),
2637 "sub{b}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002638 [(set GR8:$dst, (sub GR8:$src1, (load addr:$src2))),
2639 (implicit EFLAGS)]>;
Bill Wendlingae034ed2008-12-12 00:56:36 +00002640def SUB16rm : I<0x2B, MRMSrcMem, (outs GR16:$dst),
2641 (ins GR16:$src1, i16mem:$src2),
2642 "sub{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002643 [(set GR16:$dst, (sub GR16:$src1, (load addr:$src2))),
2644 (implicit EFLAGS)]>, OpSize;
Bill Wendlingae034ed2008-12-12 00:56:36 +00002645def SUB32rm : I<0x2B, MRMSrcMem, (outs GR32:$dst),
2646 (ins GR32:$src1, i32mem:$src2),
2647 "sub{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002648 [(set GR32:$dst, (sub GR32:$src1, (load addr:$src2))),
2649 (implicit EFLAGS)]>;
Bill Wendlingae034ed2008-12-12 00:56:36 +00002650
2651// Register-Integer Subtraction
2652def SUB8ri : Ii8 <0x80, MRM5r, (outs GR8:$dst),
2653 (ins GR8:$src1, i8imm:$src2),
2654 "sub{b}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002655 [(set GR8:$dst, (sub GR8:$src1, imm:$src2)),
2656 (implicit EFLAGS)]>;
Bill Wendlingae034ed2008-12-12 00:56:36 +00002657def SUB16ri : Ii16<0x81, MRM5r, (outs GR16:$dst),
2658 (ins GR16:$src1, i16imm:$src2),
2659 "sub{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002660 [(set GR16:$dst, (sub GR16:$src1, imm:$src2)),
2661 (implicit EFLAGS)]>, OpSize;
Bill Wendlingae034ed2008-12-12 00:56:36 +00002662def SUB32ri : Ii32<0x81, MRM5r, (outs GR32:$dst),
2663 (ins GR32:$src1, i32imm:$src2),
2664 "sub{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002665 [(set GR32:$dst, (sub GR32:$src1, imm:$src2)),
2666 (implicit EFLAGS)]>;
Bill Wendlingae034ed2008-12-12 00:56:36 +00002667def SUB16ri8 : Ii8<0x83, MRM5r, (outs GR16:$dst),
2668 (ins GR16:$src1, i16i8imm:$src2),
2669 "sub{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002670 [(set GR16:$dst, (sub GR16:$src1, i16immSExt8:$src2)),
2671 (implicit EFLAGS)]>, OpSize;
Bill Wendlingae034ed2008-12-12 00:56:36 +00002672def SUB32ri8 : Ii8<0x83, MRM5r, (outs GR32:$dst),
2673 (ins GR32:$src1, i32i8imm:$src2),
2674 "sub{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002675 [(set GR32:$dst, (sub GR32:$src1, i32immSExt8:$src2)),
2676 (implicit EFLAGS)]>;
Bill Wendlingae034ed2008-12-12 00:56:36 +00002677
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002678let isTwoAddress = 0 in {
Bill Wendlingae034ed2008-12-12 00:56:36 +00002679 // Memory-Register Subtraction
Evan Chengb783fa32007-07-19 01:14:50 +00002680 def SUB8mr : I<0x28, MRMDestMem, (outs), (ins i8mem :$dst, GR8 :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002681 "sub{b}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002682 [(store (sub (load addr:$dst), GR8:$src2), addr:$dst),
2683 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002684 def SUB16mr : I<0x29, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002685 "sub{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002686 [(store (sub (load addr:$dst), GR16:$src2), addr:$dst),
2687 (implicit EFLAGS)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002688 def SUB32mr : I<0x29, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002689 "sub{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002690 [(store (sub (load addr:$dst), GR32:$src2), addr:$dst),
2691 (implicit EFLAGS)]>;
Bill Wendlingae034ed2008-12-12 00:56:36 +00002692
2693 // Memory-Integer Subtraction
Evan Chengb783fa32007-07-19 01:14:50 +00002694 def SUB8mi : Ii8<0x80, MRM5m, (outs), (ins i8mem :$dst, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002695 "sub{b}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002696 [(store (sub (loadi8 addr:$dst), imm:$src2), addr:$dst),
2697 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002698 def SUB16mi : Ii16<0x81, MRM5m, (outs), (ins i16mem:$dst, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002699 "sub{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002700 [(store (sub (loadi16 addr:$dst), imm:$src2),addr:$dst),
2701 (implicit EFLAGS)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002702 def SUB32mi : Ii32<0x81, MRM5m, (outs), (ins i32mem:$dst, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002703 "sub{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002704 [(store (sub (loadi32 addr:$dst), imm:$src2),addr:$dst),
2705 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002706 def SUB16mi8 : Ii8<0x83, MRM5m, (outs), (ins i16mem:$dst, i16i8imm :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002707 "sub{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingae034ed2008-12-12 00:56:36 +00002708 [(store (sub (load addr:$dst), i16immSExt8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00002709 addr:$dst),
2710 (implicit EFLAGS)]>, OpSize;
Bill Wendlingae034ed2008-12-12 00:56:36 +00002711 def SUB32mi8 : Ii8<0x83, MRM5m, (outs), (ins i32mem:$dst, i32i8imm :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002712 "sub{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingae034ed2008-12-12 00:56:36 +00002713 [(store (sub (load addr:$dst), i32immSExt8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00002714 addr:$dst),
2715 (implicit EFLAGS)]>;
Sean Callanan8562bef2009-09-11 19:01:56 +00002716
2717 def SUB8i8 : Ii8<0x2C, RawFrm, (outs), (ins i8imm:$src),
2718 "sub{b}\t{$src, %al|%al, $src}", []>;
2719 def SUB16i16 : Ii16<0x2D, RawFrm, (outs), (ins i16imm:$src),
2720 "sub{w}\t{$src, %ax|%ax, $src}", []>, OpSize;
2721 def SUB32i32 : Ii32<0x2D, RawFrm, (outs), (ins i32imm:$src),
2722 "sub{l}\t{$src, %eax|%eax, $src}", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002723}
2724
Evan Cheng259471d2007-10-05 17:59:57 +00002725let Uses = [EFLAGS] in {
Dale Johannesen06b83f12009-05-18 17:44:15 +00002726def SBB8rr : I<0x18, MRMDestReg, (outs GR8:$dst),
2727 (ins GR8:$src1, GR8:$src2),
2728 "sbb{b}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002729 [(set GR8:$dst, (sube GR8:$src1, GR8:$src2))]>;
Dale Johannesen06b83f12009-05-18 17:44:15 +00002730def SBB16rr : I<0x19, MRMDestReg, (outs GR16:$dst),
2731 (ins GR16:$src1, GR16:$src2),
2732 "sbb{w}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002733 [(set GR16:$dst, (sube GR16:$src1, GR16:$src2))]>, OpSize;
Dale Johannesen06b83f12009-05-18 17:44:15 +00002734def SBB32rr : I<0x19, MRMDestReg, (outs GR32:$dst),
2735 (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002736 "sbb{l}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002737 [(set GR32:$dst, (sube GR32:$src1, GR32:$src2))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002738
2739let isTwoAddress = 0 in {
Dale Johannesen06b83f12009-05-18 17:44:15 +00002740 def SBB8mr : I<0x18, MRMDestMem, (outs), (ins i8mem:$dst, GR8:$src2),
2741 "sbb{b}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002742 [(store (sube (load addr:$dst), GR8:$src2), addr:$dst)]>;
Dale Johannesen06b83f12009-05-18 17:44:15 +00002743 def SBB16mr : I<0x19, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
2744 "sbb{w}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002745 [(store (sube (load addr:$dst), GR16:$src2), addr:$dst)]>,
Dale Johannesen067cfb22009-05-18 21:41:59 +00002746 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002747 def SBB32mr : I<0x19, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002748 "sbb{l}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002749 [(store (sube (load addr:$dst), GR32:$src2), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002750 def SBB8mi : Ii32<0x80, MRM3m, (outs), (ins i8mem:$dst, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002751 "sbb{b}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002752 [(store (sube (loadi8 addr:$dst), imm:$src2), addr:$dst)]>;
Dale Johannesen06b83f12009-05-18 17:44:15 +00002753 def SBB16mi : Ii16<0x81, MRM3m, (outs), (ins i16mem:$dst, i16imm:$src2),
2754 "sbb{w}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002755 [(store (sube (loadi16 addr:$dst), imm:$src2), addr:$dst)]>,
Dale Johannesen067cfb22009-05-18 21:41:59 +00002756 OpSize;
Dale Johannesen06b83f12009-05-18 17:44:15 +00002757 def SBB16mi8 : Ii8<0x83, MRM3m, (outs), (ins i16mem:$dst, i16i8imm :$src2),
2758 "sbb{w}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002759 [(store (sube (load addr:$dst), i16immSExt8:$src2), addr:$dst)]>,
Dale Johannesen067cfb22009-05-18 21:41:59 +00002760 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002761 def SBB32mi : Ii32<0x81, MRM3m, (outs), (ins i32mem:$dst, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002762 "sbb{l}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002763 [(store (sube (loadi32 addr:$dst), imm:$src2), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002764 def SBB32mi8 : Ii8<0x83, MRM3m, (outs), (ins i32mem:$dst, i32i8imm :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002765 "sbb{l}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002766 [(store (sube (load addr:$dst), i32immSExt8:$src2), addr:$dst)]>;
Sean Callanan8562bef2009-09-11 19:01:56 +00002767
2768 def SBB8i8 : Ii8<0x1C, RawFrm, (outs), (ins i8imm:$src),
2769 "sbb{b}\t{$src, %al|%al, $src}", []>;
2770 def SBB16i16 : Ii16<0x1D, RawFrm, (outs), (ins i16imm:$src),
2771 "sbb{w}\t{$src, %ax|%ax, $src}", []>, OpSize;
2772 def SBB32i32 : Ii32<0x1D, RawFrm, (outs), (ins i32imm:$src),
2773 "sbb{l}\t{$src, %eax|%eax, $src}", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002774}
Dale Johannesen06b83f12009-05-18 17:44:15 +00002775def SBB8rm : I<0x1A, MRMSrcMem, (outs GR8:$dst), (ins GR8:$src1, i8mem:$src2),
2776 "sbb{b}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002777 [(set GR8:$dst, (sube GR8:$src1, (load addr:$src2)))]>;
Dale Johannesen06b83f12009-05-18 17:44:15 +00002778def SBB16rm : I<0x1B, MRMSrcMem, (outs GR16:$dst),
2779 (ins GR16:$src1, i16mem:$src2),
2780 "sbb{w}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002781 [(set GR16:$dst, (sube GR16:$src1, (load addr:$src2)))]>,
Dale Johannesen067cfb22009-05-18 21:41:59 +00002782 OpSize;
Dale Johannesen06b83f12009-05-18 17:44:15 +00002783def SBB32rm : I<0x1B, MRMSrcMem, (outs GR32:$dst),
2784 (ins GR32:$src1, i32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002785 "sbb{l}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002786 [(set GR32:$dst, (sube GR32:$src1, (load addr:$src2)))]>;
Dale Johannesen06b83f12009-05-18 17:44:15 +00002787def SBB8ri : Ii8<0x80, MRM3r, (outs GR8:$dst), (ins GR8:$src1, i8imm:$src2),
2788 "sbb{b}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002789 [(set GR8:$dst, (sube GR8:$src1, imm:$src2))]>;
Dale Johannesen06b83f12009-05-18 17:44:15 +00002790def SBB16ri : Ii16<0x81, MRM3r, (outs GR16:$dst),
2791 (ins GR16:$src1, i16imm:$src2),
2792 "sbb{w}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002793 [(set GR16:$dst, (sube GR16:$src1, imm:$src2))]>, OpSize;
Dale Johannesen06b83f12009-05-18 17:44:15 +00002794def SBB16ri8 : Ii8<0x83, MRM3r, (outs GR16:$dst),
2795 (ins GR16:$src1, i16i8imm:$src2),
2796 "sbb{w}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002797 [(set GR16:$dst, (sube GR16:$src1, i16immSExt8:$src2))]>,
2798 OpSize;
Dale Johannesen06b83f12009-05-18 17:44:15 +00002799def SBB32ri : Ii32<0x81, MRM3r, (outs GR32:$dst),
2800 (ins GR32:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002801 "sbb{l}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002802 [(set GR32:$dst, (sube GR32:$src1, imm:$src2))]>;
Dale Johannesen06b83f12009-05-18 17:44:15 +00002803def SBB32ri8 : Ii8<0x83, MRM3r, (outs GR32:$dst),
2804 (ins GR32:$src1, i32i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002805 "sbb{l}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002806 [(set GR32:$dst, (sube GR32:$src1, i32immSExt8:$src2))]>;
Evan Cheng259471d2007-10-05 17:59:57 +00002807} // Uses = [EFLAGS]
Evan Cheng55687072007-09-14 21:48:26 +00002808} // Defs = [EFLAGS]
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002809
Evan Cheng55687072007-09-14 21:48:26 +00002810let Defs = [EFLAGS] in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002811let isCommutable = 1 in { // X = IMUL Y, Z --> X = IMUL Z, Y
Bill Wendlingf5399032008-12-12 21:15:41 +00002812// Register-Register Signed Integer Multiply
Bill Wendlingae034ed2008-12-12 00:56:36 +00002813def IMUL16rr : I<0xAF, MRMSrcReg, (outs GR16:$dst), (ins GR16:$src1,GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002814 "imul{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002815 [(set GR16:$dst, (mul GR16:$src1, GR16:$src2)),
2816 (implicit EFLAGS)]>, TB, OpSize;
Bill Wendlingae034ed2008-12-12 00:56:36 +00002817def IMUL32rr : I<0xAF, MRMSrcReg, (outs GR32:$dst), (ins GR32:$src1,GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002818 "imul{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002819 [(set GR32:$dst, (mul GR32:$src1, GR32:$src2)),
2820 (implicit EFLAGS)]>, TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002821}
Bill Wendlingae034ed2008-12-12 00:56:36 +00002822
Bill Wendlingf5399032008-12-12 21:15:41 +00002823// Register-Memory Signed Integer Multiply
Bill Wendlingae034ed2008-12-12 00:56:36 +00002824def IMUL16rm : I<0xAF, MRMSrcMem, (outs GR16:$dst),
2825 (ins GR16:$src1, i16mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002826 "imul{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002827 [(set GR16:$dst, (mul GR16:$src1, (load addr:$src2))),
2828 (implicit EFLAGS)]>, TB, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002829def IMUL32rm : I<0xAF, MRMSrcMem, (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002830 "imul{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002831 [(set GR32:$dst, (mul GR32:$src1, (load addr:$src2))),
2832 (implicit EFLAGS)]>, TB;
Evan Cheng55687072007-09-14 21:48:26 +00002833} // Defs = [EFLAGS]
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002834} // end Two Address instructions
2835
2836// Suprisingly enough, these are not two address instructions!
Evan Cheng55687072007-09-14 21:48:26 +00002837let Defs = [EFLAGS] in {
Bill Wendlingf5399032008-12-12 21:15:41 +00002838// Register-Integer Signed Integer Multiply
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002839def IMUL16rri : Ii16<0x69, MRMSrcReg, // GR16 = GR16*I16
Evan Chengb783fa32007-07-19 01:14:50 +00002840 (outs GR16:$dst), (ins GR16:$src1, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002841 "imul{w}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002842 [(set GR16:$dst, (mul GR16:$src1, imm:$src2)),
2843 (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002844def IMUL32rri : Ii32<0x69, MRMSrcReg, // GR32 = GR32*I32
Evan Chengb783fa32007-07-19 01:14:50 +00002845 (outs GR32:$dst), (ins GR32:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002846 "imul{l}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002847 [(set GR32:$dst, (mul GR32:$src1, imm:$src2)),
2848 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002849def IMUL16rri8 : Ii8<0x6B, MRMSrcReg, // GR16 = GR16*I8
Evan Chengb783fa32007-07-19 01:14:50 +00002850 (outs GR16:$dst), (ins GR16:$src1, i16i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002851 "imul{w}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002852 [(set GR16:$dst, (mul GR16:$src1, i16immSExt8:$src2)),
2853 (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002854def IMUL32rri8 : Ii8<0x6B, MRMSrcReg, // GR32 = GR32*I8
Evan Chengb783fa32007-07-19 01:14:50 +00002855 (outs GR32:$dst), (ins GR32:$src1, i32i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002856 "imul{l}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002857 [(set GR32:$dst, (mul GR32:$src1, i32immSExt8:$src2)),
2858 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002859
Bill Wendlingf5399032008-12-12 21:15:41 +00002860// Memory-Integer Signed Integer Multiply
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002861def IMUL16rmi : Ii16<0x69, MRMSrcMem, // GR16 = [mem16]*I16
Evan Chengb783fa32007-07-19 01:14:50 +00002862 (outs GR16:$dst), (ins i16mem:$src1, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002863 "imul{w}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002864 [(set GR16:$dst, (mul (load addr:$src1), imm:$src2)),
2865 (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002866def IMUL32rmi : Ii32<0x69, MRMSrcMem, // GR32 = [mem32]*I32
Evan Chengb783fa32007-07-19 01:14:50 +00002867 (outs GR32:$dst), (ins i32mem:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002868 "imul{l}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002869 [(set GR32:$dst, (mul (load addr:$src1), imm:$src2)),
2870 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002871def IMUL16rmi8 : Ii8<0x6B, MRMSrcMem, // GR16 = [mem16]*I8
Evan Chengb783fa32007-07-19 01:14:50 +00002872 (outs GR16:$dst), (ins i16mem:$src1, i16i8imm :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002873 "imul{w}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Bill Wendlingae034ed2008-12-12 00:56:36 +00002874 [(set GR16:$dst, (mul (load addr:$src1),
Bill Wendlingf5399032008-12-12 21:15:41 +00002875 i16immSExt8:$src2)),
2876 (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002877def IMUL32rmi8 : Ii8<0x6B, MRMSrcMem, // GR32 = [mem32]*I8
Evan Chengb783fa32007-07-19 01:14:50 +00002878 (outs GR32:$dst), (ins i32mem:$src1, i32i8imm: $src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002879 "imul{l}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Bill Wendlingae034ed2008-12-12 00:56:36 +00002880 [(set GR32:$dst, (mul (load addr:$src1),
Bill Wendlingf5399032008-12-12 21:15:41 +00002881 i32immSExt8:$src2)),
2882 (implicit EFLAGS)]>;
Evan Cheng55687072007-09-14 21:48:26 +00002883} // Defs = [EFLAGS]
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002884
2885//===----------------------------------------------------------------------===//
2886// Test instructions are just like AND, except they don't generate a result.
2887//
Evan Cheng950aac02007-09-25 01:57:46 +00002888let Defs = [EFLAGS] in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002889let isCommutable = 1 in { // TEST X, Y --> TEST Y, X
Evan Chengb783fa32007-07-19 01:14:50 +00002890def TEST8rr : I<0x84, MRMDestReg, (outs), (ins GR8:$src1, GR8:$src2),
Evan Cheng621216e2007-09-29 00:00:36 +00002891 "test{b}\t{$src2, $src1|$src1, $src2}",
Chris Lattner21da6382008-02-19 17:37:35 +00002892 [(X86cmp (and_su GR8:$src1, GR8:$src2), 0),
Evan Cheng621216e2007-09-29 00:00:36 +00002893 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002894def TEST16rr : I<0x85, MRMDestReg, (outs), (ins GR16:$src1, GR16:$src2),
Evan Cheng621216e2007-09-29 00:00:36 +00002895 "test{w}\t{$src2, $src1|$src1, $src2}",
Chris Lattner21da6382008-02-19 17:37:35 +00002896 [(X86cmp (and_su GR16:$src1, GR16:$src2), 0),
Evan Cheng621216e2007-09-29 00:00:36 +00002897 (implicit EFLAGS)]>,
2898 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002899def TEST32rr : I<0x85, MRMDestReg, (outs), (ins GR32:$src1, GR32:$src2),
Evan Cheng621216e2007-09-29 00:00:36 +00002900 "test{l}\t{$src2, $src1|$src1, $src2}",
Chris Lattner21da6382008-02-19 17:37:35 +00002901 [(X86cmp (and_su GR32:$src1, GR32:$src2), 0),
Evan Cheng621216e2007-09-29 00:00:36 +00002902 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002903}
2904
Sean Callanan3e4b1a32009-09-01 18:14:18 +00002905def TEST8i8 : Ii8<0xA8, RawFrm, (outs), (ins i8imm:$src),
2906 "test{b}\t{$src, %al|%al, $src}", []>;
2907def TEST16i16 : Ii16<0xA9, RawFrm, (outs), (ins i16imm:$src),
2908 "test{w}\t{$src, %ax|%ax, $src}", []>, OpSize;
2909def TEST32i32 : Ii32<0xA9, RawFrm, (outs), (ins i32imm:$src),
2910 "test{l}\t{$src, %eax|%eax, $src}", []>;
2911
Evan Chengb783fa32007-07-19 01:14:50 +00002912def TEST8rm : I<0x84, MRMSrcMem, (outs), (ins GR8 :$src1, i8mem :$src2),
Evan Cheng621216e2007-09-29 00:00:36 +00002913 "test{b}\t{$src2, $src1|$src1, $src2}",
2914 [(X86cmp (and GR8:$src1, (loadi8 addr:$src2)), 0),
2915 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002916def TEST16rm : I<0x85, MRMSrcMem, (outs), (ins GR16:$src1, i16mem:$src2),
Evan Cheng621216e2007-09-29 00:00:36 +00002917 "test{w}\t{$src2, $src1|$src1, $src2}",
2918 [(X86cmp (and GR16:$src1, (loadi16 addr:$src2)), 0),
2919 (implicit EFLAGS)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002920def TEST32rm : I<0x85, MRMSrcMem, (outs), (ins GR32:$src1, i32mem:$src2),
Evan Cheng621216e2007-09-29 00:00:36 +00002921 "test{l}\t{$src2, $src1|$src1, $src2}",
2922 [(X86cmp (and GR32:$src1, (loadi32 addr:$src2)), 0),
2923 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002924
2925def TEST8ri : Ii8 <0xF6, MRM0r, // flags = GR8 & imm8
Evan Chengb783fa32007-07-19 01:14:50 +00002926 (outs), (ins GR8:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002927 "test{b}\t{$src2, $src1|$src1, $src2}",
Chris Lattner21da6382008-02-19 17:37:35 +00002928 [(X86cmp (and_su GR8:$src1, imm:$src2), 0),
Evan Cheng621216e2007-09-29 00:00:36 +00002929 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002930def TEST16ri : Ii16<0xF7, MRM0r, // flags = GR16 & imm16
Evan Chengb783fa32007-07-19 01:14:50 +00002931 (outs), (ins GR16:$src1, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002932 "test{w}\t{$src2, $src1|$src1, $src2}",
Chris Lattner21da6382008-02-19 17:37:35 +00002933 [(X86cmp (and_su GR16:$src1, imm:$src2), 0),
Evan Cheng621216e2007-09-29 00:00:36 +00002934 (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002935def TEST32ri : Ii32<0xF7, MRM0r, // flags = GR32 & imm32
Evan Chengb783fa32007-07-19 01:14:50 +00002936 (outs), (ins GR32:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002937 "test{l}\t{$src2, $src1|$src1, $src2}",
Chris Lattner21da6382008-02-19 17:37:35 +00002938 [(X86cmp (and_su GR32:$src1, imm:$src2), 0),
Evan Cheng621216e2007-09-29 00:00:36 +00002939 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002940
Evan Cheng621216e2007-09-29 00:00:36 +00002941def TEST8mi : Ii8 <0xF6, MRM0m, // flags = [mem8] & imm8
Evan Chengb783fa32007-07-19 01:14:50 +00002942 (outs), (ins i8mem:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002943 "test{b}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002944 [(X86cmp (and (loadi8 addr:$src1), imm:$src2), 0),
2945 (implicit EFLAGS)]>;
2946def TEST16mi : Ii16<0xF7, MRM0m, // flags = [mem16] & imm16
Evan Chengb783fa32007-07-19 01:14:50 +00002947 (outs), (ins i16mem:$src1, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002948 "test{w}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002949 [(X86cmp (and (loadi16 addr:$src1), imm:$src2), 0),
2950 (implicit EFLAGS)]>, OpSize;
2951def TEST32mi : Ii32<0xF7, MRM0m, // flags = [mem32] & imm32
Evan Chengb783fa32007-07-19 01:14:50 +00002952 (outs), (ins i32mem:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002953 "test{l}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002954 [(X86cmp (and (loadi32 addr:$src1), imm:$src2), 0),
Evan Cheng950aac02007-09-25 01:57:46 +00002955 (implicit EFLAGS)]>;
2956} // Defs = [EFLAGS]
2957
2958
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002959// Condition code ops, incl. set if equal/not equal/...
Chris Lattnerc90ee9c2008-01-10 07:59:24 +00002960let Defs = [EFLAGS], Uses = [AH], neverHasSideEffects = 1 in
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002961def SAHF : I<0x9E, RawFrm, (outs), (ins), "sahf", []>; // flags = AH
Chris Lattnerc90ee9c2008-01-10 07:59:24 +00002962let Defs = [AH], Uses = [EFLAGS], neverHasSideEffects = 1 in
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002963def LAHF : I<0x9F, RawFrm, (outs), (ins), "lahf", []>; // AH = flags
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002964
Evan Cheng950aac02007-09-25 01:57:46 +00002965let Uses = [EFLAGS] in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002966def SETEr : I<0x94, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00002967 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002968 "sete\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002969 [(set GR8:$dst, (X86setcc X86_COND_E, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002970 TB; // GR8 = ==
2971def SETEm : I<0x94, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00002972 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002973 "sete\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002974 [(store (X86setcc X86_COND_E, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002975 TB; // [mem8] = ==
Bill Wendling0c52d0a2008-12-02 00:07:05 +00002976
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002977def SETNEr : I<0x95, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00002978 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002979 "setne\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002980 [(set GR8:$dst, (X86setcc X86_COND_NE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002981 TB; // GR8 = !=
2982def SETNEm : I<0x95, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00002983 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002984 "setne\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002985 [(store (X86setcc X86_COND_NE, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002986 TB; // [mem8] = !=
Bill Wendling0c52d0a2008-12-02 00:07:05 +00002987
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002988def SETLr : I<0x9C, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00002989 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002990 "setl\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002991 [(set GR8:$dst, (X86setcc X86_COND_L, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002992 TB; // GR8 = < signed
2993def SETLm : I<0x9C, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00002994 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002995 "setl\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002996 [(store (X86setcc X86_COND_L, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002997 TB; // [mem8] = < signed
Bill Wendling0c52d0a2008-12-02 00:07:05 +00002998
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002999def SETGEr : I<0x9D, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00003000 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00003001 "setge\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00003002 [(set GR8:$dst, (X86setcc X86_COND_GE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003003 TB; // GR8 = >= signed
3004def SETGEm : I<0x9D, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00003005 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00003006 "setge\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00003007 [(store (X86setcc X86_COND_GE, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003008 TB; // [mem8] = >= signed
Bill Wendling0c52d0a2008-12-02 00:07:05 +00003009
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003010def SETLEr : I<0x9E, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00003011 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00003012 "setle\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00003013 [(set GR8:$dst, (X86setcc X86_COND_LE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003014 TB; // GR8 = <= signed
3015def SETLEm : I<0x9E, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00003016 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00003017 "setle\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00003018 [(store (X86setcc X86_COND_LE, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003019 TB; // [mem8] = <= signed
Bill Wendling0c52d0a2008-12-02 00:07:05 +00003020
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003021def SETGr : I<0x9F, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00003022 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00003023 "setg\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00003024 [(set GR8:$dst, (X86setcc X86_COND_G, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003025 TB; // GR8 = > signed
3026def SETGm : I<0x9F, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00003027 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00003028 "setg\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00003029 [(store (X86setcc X86_COND_G, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003030 TB; // [mem8] = > signed
3031
3032def SETBr : I<0x92, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00003033 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00003034 "setb\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00003035 [(set GR8:$dst, (X86setcc X86_COND_B, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003036 TB; // GR8 = < unsign
3037def SETBm : I<0x92, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00003038 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00003039 "setb\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00003040 [(store (X86setcc X86_COND_B, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003041 TB; // [mem8] = < unsign
Bill Wendling0c52d0a2008-12-02 00:07:05 +00003042
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003043def SETAEr : I<0x93, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00003044 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00003045 "setae\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00003046 [(set GR8:$dst, (X86setcc X86_COND_AE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003047 TB; // GR8 = >= unsign
3048def SETAEm : I<0x93, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00003049 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00003050 "setae\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00003051 [(store (X86setcc X86_COND_AE, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003052 TB; // [mem8] = >= unsign
Bill Wendling0c52d0a2008-12-02 00:07:05 +00003053
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003054def SETBEr : I<0x96, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00003055 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00003056 "setbe\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00003057 [(set GR8:$dst, (X86setcc X86_COND_BE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003058 TB; // GR8 = <= unsign
3059def SETBEm : I<0x96, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00003060 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00003061 "setbe\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00003062 [(store (X86setcc X86_COND_BE, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003063 TB; // [mem8] = <= unsign
Bill Wendling0c52d0a2008-12-02 00:07:05 +00003064
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003065def SETAr : I<0x97, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00003066 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00003067 "seta\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00003068 [(set GR8:$dst, (X86setcc X86_COND_A, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003069 TB; // GR8 = > signed
3070def SETAm : I<0x97, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00003071 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00003072 "seta\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00003073 [(store (X86setcc X86_COND_A, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003074 TB; // [mem8] = > signed
3075
3076def SETSr : I<0x98, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00003077 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00003078 "sets\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00003079 [(set GR8:$dst, (X86setcc X86_COND_S, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003080 TB; // GR8 = <sign bit>
3081def SETSm : I<0x98, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00003082 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00003083 "sets\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00003084 [(store (X86setcc X86_COND_S, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003085 TB; // [mem8] = <sign bit>
3086def SETNSr : I<0x99, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00003087 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00003088 "setns\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00003089 [(set GR8:$dst, (X86setcc X86_COND_NS, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003090 TB; // GR8 = !<sign bit>
3091def SETNSm : I<0x99, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00003092 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00003093 "setns\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00003094 [(store (X86setcc X86_COND_NS, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003095 TB; // [mem8] = !<sign bit>
Bill Wendling0c52d0a2008-12-02 00:07:05 +00003096
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003097def SETPr : I<0x9A, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00003098 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00003099 "setp\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00003100 [(set GR8:$dst, (X86setcc X86_COND_P, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003101 TB; // GR8 = parity
3102def SETPm : I<0x9A, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00003103 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00003104 "setp\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00003105 [(store (X86setcc X86_COND_P, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003106 TB; // [mem8] = parity
3107def SETNPr : I<0x9B, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00003108 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00003109 "setnp\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00003110 [(set GR8:$dst, (X86setcc X86_COND_NP, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003111 TB; // GR8 = not parity
3112def SETNPm : I<0x9B, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00003113 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00003114 "setnp\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00003115 [(store (X86setcc X86_COND_NP, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003116 TB; // [mem8] = not parity
Bill Wendling0c52d0a2008-12-02 00:07:05 +00003117
3118def SETOr : I<0x90, MRM0r,
3119 (outs GR8 :$dst), (ins),
3120 "seto\t$dst",
3121 [(set GR8:$dst, (X86setcc X86_COND_O, EFLAGS))]>,
3122 TB; // GR8 = overflow
3123def SETOm : I<0x90, MRM0m,
3124 (outs), (ins i8mem:$dst),
3125 "seto\t$dst",
3126 [(store (X86setcc X86_COND_O, EFLAGS), addr:$dst)]>,
3127 TB; // [mem8] = overflow
3128def SETNOr : I<0x91, MRM0r,
3129 (outs GR8 :$dst), (ins),
3130 "setno\t$dst",
3131 [(set GR8:$dst, (X86setcc X86_COND_NO, EFLAGS))]>,
3132 TB; // GR8 = not overflow
3133def SETNOm : I<0x91, MRM0m,
3134 (outs), (ins i8mem:$dst),
3135 "setno\t$dst",
3136 [(store (X86setcc X86_COND_NO, EFLAGS), addr:$dst)]>,
3137 TB; // [mem8] = not overflow
Evan Cheng950aac02007-09-25 01:57:46 +00003138} // Uses = [EFLAGS]
3139
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003140
3141// Integer comparisons
Evan Cheng55687072007-09-14 21:48:26 +00003142let Defs = [EFLAGS] in {
Sean Callanan251676e2009-09-02 00:55:49 +00003143def CMP8i8 : Ii8<0x3C, RawFrm, (outs), (ins i8imm:$src),
3144 "cmp{b}\t{$src, %al|%al, $src}", []>;
3145def CMP16i16 : Ii16<0x3D, RawFrm, (outs), (ins i16imm:$src),
3146 "cmp{w}\t{$src, %ax|%ax, $src}", []>, OpSize;
3147def CMP32i32 : Ii32<0x3D, RawFrm, (outs), (ins i32imm:$src),
3148 "cmp{l}\t{$src, %eax|%eax, $src}", []>;
3149
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003150def CMP8rr : I<0x38, MRMDestReg,
Evan Chengb783fa32007-07-19 01:14:50 +00003151 (outs), (ins GR8 :$src1, GR8 :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00003152 "cmp{b}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00003153 [(X86cmp GR8:$src1, GR8:$src2), (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003154def CMP16rr : I<0x39, MRMDestReg,
Evan Chengb783fa32007-07-19 01:14:50 +00003155 (outs), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00003156 "cmp{w}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00003157 [(X86cmp GR16:$src1, GR16:$src2), (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003158def CMP32rr : I<0x39, MRMDestReg,
Evan Chengb783fa32007-07-19 01:14:50 +00003159 (outs), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00003160 "cmp{l}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00003161 [(X86cmp GR32:$src1, GR32:$src2), (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003162def CMP8mr : I<0x38, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00003163 (outs), (ins i8mem :$src1, GR8 :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00003164 "cmp{b}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00003165 [(X86cmp (loadi8 addr:$src1), GR8:$src2),
3166 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003167def CMP16mr : I<0x39, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00003168 (outs), (ins i16mem:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00003169 "cmp{w}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00003170 [(X86cmp (loadi16 addr:$src1), GR16:$src2),
3171 (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003172def CMP32mr : I<0x39, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00003173 (outs), (ins i32mem:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00003174 "cmp{l}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00003175 [(X86cmp (loadi32 addr:$src1), GR32:$src2),
3176 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003177def CMP8rm : I<0x3A, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00003178 (outs), (ins GR8 :$src1, i8mem :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00003179 "cmp{b}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00003180 [(X86cmp GR8:$src1, (loadi8 addr:$src2)),
3181 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003182def CMP16rm : I<0x3B, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00003183 (outs), (ins GR16:$src1, i16mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00003184 "cmp{w}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00003185 [(X86cmp GR16:$src1, (loadi16 addr:$src2)),
3186 (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003187def CMP32rm : I<0x3B, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00003188 (outs), (ins GR32:$src1, i32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00003189 "cmp{l}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00003190 [(X86cmp GR32:$src1, (loadi32 addr:$src2)),
3191 (implicit EFLAGS)]>;
Sean Callanan11490dc2009-09-16 21:11:23 +00003192def CMP8mrmrr : I<0x3A, MRMSrcReg, (outs), (ins GR8:$src1, GR8:$src2),
3193 "cmp{b}\t{$src2, $src1|$src1, $src2}", []>;
3194def CMP16mrmrr : I<0x3B, MRMSrcReg, (outs), (ins GR16:$src1, GR16:$src2),
3195 "cmp{w}\t{$src2, $src1|$src1, $src2}", []>, OpSize;
3196def CMP32mrmrr : I<0x3B, MRMSrcReg, (outs), (ins GR32:$src1, GR32:$src2),
3197 "cmp{l}\t{$src2, $src1|$src1, $src2}", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003198def CMP8ri : Ii8<0x80, MRM7r,
Evan Chengb783fa32007-07-19 01:14:50 +00003199 (outs), (ins GR8:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00003200 "cmp{b}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00003201 [(X86cmp GR8:$src1, imm:$src2), (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003202def CMP16ri : Ii16<0x81, MRM7r,
Evan Chengb783fa32007-07-19 01:14:50 +00003203 (outs), (ins GR16:$src1, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00003204 "cmp{w}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00003205 [(X86cmp GR16:$src1, imm:$src2),
3206 (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003207def CMP32ri : Ii32<0x81, MRM7r,
Evan Chengb783fa32007-07-19 01:14:50 +00003208 (outs), (ins GR32:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00003209 "cmp{l}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00003210 [(X86cmp GR32:$src1, imm:$src2), (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003211def CMP8mi : Ii8 <0x80, MRM7m,
Evan Chengb783fa32007-07-19 01:14:50 +00003212 (outs), (ins i8mem :$src1, i8imm :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00003213 "cmp{b}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00003214 [(X86cmp (loadi8 addr:$src1), imm:$src2),
3215 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003216def CMP16mi : Ii16<0x81, MRM7m,
Evan Chengb783fa32007-07-19 01:14:50 +00003217 (outs), (ins i16mem:$src1, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00003218 "cmp{w}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00003219 [(X86cmp (loadi16 addr:$src1), imm:$src2),
3220 (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003221def CMP32mi : Ii32<0x81, MRM7m,
Evan Chengb783fa32007-07-19 01:14:50 +00003222 (outs), (ins i32mem:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00003223 "cmp{l}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00003224 [(X86cmp (loadi32 addr:$src1), imm:$src2),
3225 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003226def CMP16ri8 : Ii8<0x83, MRM7r,
Evan Chengb783fa32007-07-19 01:14:50 +00003227 (outs), (ins GR16:$src1, i16i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00003228 "cmp{w}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00003229 [(X86cmp GR16:$src1, i16immSExt8:$src2),
3230 (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003231def CMP16mi8 : Ii8<0x83, MRM7m,
Evan Chengb783fa32007-07-19 01:14:50 +00003232 (outs), (ins i16mem:$src1, i16i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00003233 "cmp{w}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00003234 [(X86cmp (loadi16 addr:$src1), i16immSExt8:$src2),
3235 (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003236def CMP32mi8 : Ii8<0x83, MRM7m,
Evan Chengb783fa32007-07-19 01:14:50 +00003237 (outs), (ins i32mem:$src1, i32i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00003238 "cmp{l}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00003239 [(X86cmp (loadi32 addr:$src1), i32immSExt8:$src2),
3240 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003241def CMP32ri8 : Ii8<0x83, MRM7r,
Evan Chengb783fa32007-07-19 01:14:50 +00003242 (outs), (ins GR32:$src1, i32i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00003243 "cmp{l}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00003244 [(X86cmp GR32:$src1, i32immSExt8:$src2),
Evan Cheng950aac02007-09-25 01:57:46 +00003245 (implicit EFLAGS)]>;
3246} // Defs = [EFLAGS]
3247
Dan Gohman7fe9b7f2008-12-23 22:45:23 +00003248// Bit tests.
Dan Gohman7fe9b7f2008-12-23 22:45:23 +00003249// TODO: BTC, BTR, and BTS
3250let Defs = [EFLAGS] in {
Dan Gohmanfc4eddb2009-01-13 20:32:45 +00003251def BT16rr : I<0xA3, MRMDestReg, (outs), (ins GR16:$src1, GR16:$src2),
Dan Gohman7fe9b7f2008-12-23 22:45:23 +00003252 "bt{w}\t{$src2, $src1|$src1, $src2}",
3253 [(X86bt GR16:$src1, GR16:$src2),
Chris Lattner5a95cde2008-12-25 01:32:49 +00003254 (implicit EFLAGS)]>, OpSize, TB;
Dan Gohmanfc4eddb2009-01-13 20:32:45 +00003255def BT32rr : I<0xA3, MRMDestReg, (outs), (ins GR32:$src1, GR32:$src2),
Dan Gohman7fe9b7f2008-12-23 22:45:23 +00003256 "bt{l}\t{$src2, $src1|$src1, $src2}",
3257 [(X86bt GR32:$src1, GR32:$src2),
Chris Lattner5a95cde2008-12-25 01:32:49 +00003258 (implicit EFLAGS)]>, TB;
Dan Gohman85a228c2009-01-13 23:23:30 +00003259
3260// Unlike with the register+register form, the memory+register form of the
3261// bt instruction does not ignore the high bits of the index. From ISel's
3262// perspective, this is pretty bizarre. Disable these instructions for now.
3263//def BT16mr : I<0xA3, MRMDestMem, (outs), (ins i16mem:$src1, GR16:$src2),
3264// "bt{w}\t{$src2, $src1|$src1, $src2}",
3265// [(X86bt (loadi16 addr:$src1), GR16:$src2),
3266// (implicit EFLAGS)]>, OpSize, TB, Requires<[FastBTMem]>;
3267//def BT32mr : I<0xA3, MRMDestMem, (outs), (ins i32mem:$src1, GR32:$src2),
3268// "bt{l}\t{$src2, $src1|$src1, $src2}",
3269// [(X86bt (loadi32 addr:$src1), GR32:$src2),
3270// (implicit EFLAGS)]>, TB, Requires<[FastBTMem]>;
Dan Gohman46fb1cf2009-01-13 20:33:23 +00003271
3272def BT16ri8 : Ii8<0xBA, MRM4r, (outs), (ins GR16:$src1, i16i8imm:$src2),
3273 "bt{w}\t{$src2, $src1|$src1, $src2}",
3274 [(X86bt GR16:$src1, i16immSExt8:$src2),
3275 (implicit EFLAGS)]>, OpSize, TB;
3276def BT32ri8 : Ii8<0xBA, MRM4r, (outs), (ins GR32:$src1, i32i8imm:$src2),
3277 "bt{l}\t{$src2, $src1|$src1, $src2}",
3278 [(X86bt GR32:$src1, i32immSExt8:$src2),
3279 (implicit EFLAGS)]>, TB;
3280// Note that these instructions don't need FastBTMem because that
3281// only applies when the other operand is in a register. When it's
3282// an immediate, bt is still fast.
3283def BT16mi8 : Ii8<0xBA, MRM4m, (outs), (ins i16mem:$src1, i16i8imm:$src2),
3284 "bt{w}\t{$src2, $src1|$src1, $src2}",
3285 [(X86bt (loadi16 addr:$src1), i16immSExt8:$src2),
3286 (implicit EFLAGS)]>, OpSize, TB;
3287def BT32mi8 : Ii8<0xBA, MRM4m, (outs), (ins i32mem:$src1, i32i8imm:$src2),
3288 "bt{l}\t{$src2, $src1|$src1, $src2}",
3289 [(X86bt (loadi32 addr:$src1), i32immSExt8:$src2),
3290 (implicit EFLAGS)]>, TB;
Dan Gohman7fe9b7f2008-12-23 22:45:23 +00003291} // Defs = [EFLAGS]
3292
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003293// Sign/Zero extenders
Dan Gohman9203ab42008-07-30 18:09:17 +00003294// Use movsbl intead of movsbw; we don't care about the high 16 bits
3295// of the register here. This has a smaller encoding and avoids a
3296// partial-register update.
Evan Chengb783fa32007-07-19 01:14:50 +00003297def MOVSX16rr8 : I<0xBE, MRMSrcReg, (outs GR16:$dst), (ins GR8 :$src),
Dan Gohman9203ab42008-07-30 18:09:17 +00003298 "movs{bl|x}\t{$src, ${dst:subreg32}|${dst:subreg32}, $src}",
3299 [(set GR16:$dst, (sext GR8:$src))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00003300def MOVSX16rm8 : I<0xBE, MRMSrcMem, (outs GR16:$dst), (ins i8mem :$src),
Dan Gohman9203ab42008-07-30 18:09:17 +00003301 "movs{bl|x}\t{$src, ${dst:subreg32}|${dst:subreg32}, $src}",
3302 [(set GR16:$dst, (sextloadi16i8 addr:$src))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00003303def MOVSX32rr8 : I<0xBE, MRMSrcReg, (outs GR32:$dst), (ins GR8 :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00003304 "movs{bl|x}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003305 [(set GR32:$dst, (sext GR8:$src))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00003306def MOVSX32rm8 : I<0xBE, MRMSrcMem, (outs GR32:$dst), (ins i8mem :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00003307 "movs{bl|x}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003308 [(set GR32:$dst, (sextloadi32i8 addr:$src))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00003309def MOVSX32rr16: I<0xBF, MRMSrcReg, (outs GR32:$dst), (ins GR16:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00003310 "movs{wl|x}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003311 [(set GR32:$dst, (sext GR16:$src))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00003312def MOVSX32rm16: I<0xBF, MRMSrcMem, (outs GR32:$dst), (ins i16mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00003313 "movs{wl|x}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003314 [(set GR32:$dst, (sextloadi32i16 addr:$src))]>, TB;
3315
Dan Gohman9203ab42008-07-30 18:09:17 +00003316// Use movzbl intead of movzbw; we don't care about the high 16 bits
3317// of the register here. This has a smaller encoding and avoids a
3318// partial-register update.
Evan Chengb783fa32007-07-19 01:14:50 +00003319def MOVZX16rr8 : I<0xB6, MRMSrcReg, (outs GR16:$dst), (ins GR8 :$src),
Dan Gohman9203ab42008-07-30 18:09:17 +00003320 "movz{bl|x}\t{$src, ${dst:subreg32}|${dst:subreg32}, $src}",
3321 [(set GR16:$dst, (zext GR8:$src))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00003322def MOVZX16rm8 : I<0xB6, MRMSrcMem, (outs GR16:$dst), (ins i8mem :$src),
Dan Gohman9203ab42008-07-30 18:09:17 +00003323 "movz{bl|x}\t{$src, ${dst:subreg32}|${dst:subreg32}, $src}",
3324 [(set GR16:$dst, (zextloadi16i8 addr:$src))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00003325def MOVZX32rr8 : I<0xB6, MRMSrcReg, (outs GR32:$dst), (ins GR8 :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00003326 "movz{bl|x}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003327 [(set GR32:$dst, (zext GR8:$src))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00003328def MOVZX32rm8 : I<0xB6, MRMSrcMem, (outs GR32:$dst), (ins i8mem :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00003329 "movz{bl|x}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003330 [(set GR32:$dst, (zextloadi32i8 addr:$src))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00003331def MOVZX32rr16: I<0xB7, MRMSrcReg, (outs GR32:$dst), (ins GR16:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00003332 "movz{wl|x}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003333 [(set GR32:$dst, (zext GR16:$src))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00003334def MOVZX32rm16: I<0xB7, MRMSrcMem, (outs GR32:$dst), (ins i16mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00003335 "movz{wl|x}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003336 [(set GR32:$dst, (zextloadi32i16 addr:$src))]>, TB;
3337
Dan Gohman744d4622009-04-13 16:09:41 +00003338// These are the same as the regular regular MOVZX32rr8 and MOVZX32rm8
3339// except that they use GR32_NOREX for the output operand register class
3340// instead of GR32. This allows them to operate on h registers on x86-64.
3341def MOVZX32_NOREXrr8 : I<0xB6, MRMSrcReg,
3342 (outs GR32_NOREX:$dst), (ins GR8:$src),
3343 "movz{bl|x}\t{$src, $dst|$dst, $src} # NOREX",
3344 []>, TB;
Dan Gohman89f4cda2009-04-30 03:11:48 +00003345let mayLoad = 1 in
Dan Gohman744d4622009-04-13 16:09:41 +00003346def MOVZX32_NOREXrm8 : I<0xB6, MRMSrcMem,
3347 (outs GR32_NOREX:$dst), (ins i8mem:$src),
3348 "movz{bl|x}\t{$src, $dst|$dst, $src} # NOREX",
3349 []>, TB;
3350
Chris Lattnerc90ee9c2008-01-10 07:59:24 +00003351let neverHasSideEffects = 1 in {
3352 let Defs = [AX], Uses = [AL] in
3353 def CBW : I<0x98, RawFrm, (outs), (ins),
3354 "{cbtw|cbw}", []>, OpSize; // AX = signext(AL)
3355 let Defs = [EAX], Uses = [AX] in
3356 def CWDE : I<0x98, RawFrm, (outs), (ins),
3357 "{cwtl|cwde}", []>; // EAX = signext(AX)
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003358
Chris Lattnerc90ee9c2008-01-10 07:59:24 +00003359 let Defs = [AX,DX], Uses = [AX] in
3360 def CWD : I<0x99, RawFrm, (outs), (ins),
3361 "{cwtd|cwd}", []>, OpSize; // DX:AX = signext(AX)
3362 let Defs = [EAX,EDX], Uses = [EAX] in
3363 def CDQ : I<0x99, RawFrm, (outs), (ins),
3364 "{cltd|cdq}", []>; // EDX:EAX = signext(EAX)
3365}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003366
3367//===----------------------------------------------------------------------===//
3368// Alias Instructions
3369//===----------------------------------------------------------------------===//
3370
3371// Alias instructions that map movr0 to xor.
3372// FIXME: remove when we can teach regalloc that xor reg, reg is ok.
Daniel Dunbara0e62002009-08-11 22:17:52 +00003373let Defs = [EFLAGS], isReMaterializable = 1, isAsCheapAsAMove = 1,
3374 isCodeGenOnly = 1 in {
Evan Chengb783fa32007-07-19 01:14:50 +00003375def MOV8r0 : I<0x30, MRMInitReg, (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00003376 "xor{b}\t$dst, $dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003377 [(set GR8:$dst, 0)]>;
Dan Gohman9203ab42008-07-30 18:09:17 +00003378// Use xorl instead of xorw since we don't care about the high 16 bits,
3379// it's smaller, and it avoids a partial-register update.
Evan Chengb783fa32007-07-19 01:14:50 +00003380def MOV16r0 : I<0x31, MRMInitReg, (outs GR16:$dst), (ins),
Dan Gohman9203ab42008-07-30 18:09:17 +00003381 "xor{l}\t${dst:subreg32}, ${dst:subreg32}",
3382 [(set GR16:$dst, 0)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00003383def MOV32r0 : I<0x31, MRMInitReg, (outs GR32:$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00003384 "xor{l}\t$dst, $dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003385 [(set GR32:$dst, 0)]>;
Dan Gohman8aef09b2007-09-07 21:32:51 +00003386}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003387
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003388//===----------------------------------------------------------------------===//
3389// Thread Local Storage Instructions
3390//
3391
Rafael Espindola7fc4b8d2009-04-24 12:59:40 +00003392// All calls clobber the non-callee saved registers. ESP is marked as
3393// a use to prevent stack-pointer assignments that appear immediately
3394// before calls from potentially appearing dead.
3395let Defs = [EAX, ECX, EDX, FP0, FP1, FP2, FP3, FP4, FP5, FP6, ST0,
3396 MM0, MM1, MM2, MM3, MM4, MM5, MM6, MM7,
3397 XMM0, XMM1, XMM2, XMM3, XMM4, XMM5, XMM6, XMM7,
3398 XMM8, XMM9, XMM10, XMM11, XMM12, XMM13, XMM14, XMM15, EFLAGS],
Chris Lattnerf1940742009-06-20 20:38:48 +00003399 Uses = [ESP] in
3400def TLS_addr32 : I<0, Pseudo, (outs), (ins lea32mem:$sym),
3401 "leal\t$sym, %eax; "
Dan Gohman70a8a112009-04-27 15:13:28 +00003402 "call\t___tls_get_addr@PLT",
Chris Lattnerf1940742009-06-20 20:38:48 +00003403 [(X86tlsaddr tls32addr:$sym)]>,
Rafael Espindolaaf759ab2009-04-17 14:35:58 +00003404 Requires<[In32BitMode]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003405
Daniel Dunbar75a07302009-08-11 22:24:40 +00003406let AddedComplexity = 5, isCodeGenOnly = 1 in
sampo9cc09a32009-01-26 01:24:32 +00003407def GS_MOV32rm : I<0x8B, MRMSrcMem, (outs GR32:$dst), (ins i32mem:$src),
3408 "movl\t%gs:$src, $dst",
3409 [(set GR32:$dst, (gsload addr:$src))]>, SegGS;
3410
Daniel Dunbar75a07302009-08-11 22:24:40 +00003411let AddedComplexity = 5, isCodeGenOnly = 1 in
Chris Lattnera7c2d8a2009-05-05 18:52:19 +00003412def FS_MOV32rm : I<0x8B, MRMSrcMem, (outs GR32:$dst), (ins i32mem:$src),
3413 "movl\t%fs:$src, $dst",
3414 [(set GR32:$dst, (fsload addr:$src))]>, SegFS;
3415
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003416//===----------------------------------------------------------------------===//
3417// DWARF Pseudo Instructions
3418//
3419
Evan Chengb783fa32007-07-19 01:14:50 +00003420def DWARF_LOC : I<0, Pseudo, (outs),
3421 (ins i32imm:$line, i32imm:$col, i32imm:$file),
Chris Lattner64b54552009-07-10 22:34:11 +00003422 ".loc\t$file $line $col",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003423 [(dwarf_loc (i32 imm:$line), (i32 imm:$col),
3424 (i32 imm:$file))]>;
3425
3426//===----------------------------------------------------------------------===//
3427// EH Pseudo Instructions
3428//
3429let isTerminator = 1, isReturn = 1, isBarrier = 1,
Daniel Dunbar75513bd2009-08-27 07:58:05 +00003430 hasCtrlDep = 1, isCodeGenOnly = 1 in {
Evan Chengb783fa32007-07-19 01:14:50 +00003431def EH_RETURN : I<0xC3, RawFrm, (outs), (ins GR32:$addr),
Dan Gohman91888f02007-07-31 20:11:57 +00003432 "ret\t#eh_return, addr: $addr",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003433 [(X86ehret GR32:$addr)]>;
3434
3435}
3436
3437//===----------------------------------------------------------------------===//
Andrew Lenharthe44f3902008-02-21 06:45:13 +00003438// Atomic support
3439//
Andrew Lenharth7a5a4b22008-03-01 13:37:02 +00003440
Evan Cheng3e171562008-04-19 01:20:30 +00003441// Atomic swap. These are just normal xchg instructions. But since a memory
3442// operand is referenced, the atomicity is ensured.
Dan Gohmana41a1c092008-08-06 15:52:50 +00003443let Constraints = "$val = $dst" in {
Evan Cheng3e171562008-04-19 01:20:30 +00003444def XCHG32rm : I<0x87, MRMSrcMem, (outs GR32:$dst), (ins i32mem:$ptr, GR32:$val),
3445 "xchg{l}\t{$val, $ptr|$ptr, $val}",
3446 [(set GR32:$dst, (atomic_swap_32 addr:$ptr, GR32:$val))]>;
3447def XCHG16rm : I<0x87, MRMSrcMem, (outs GR16:$dst), (ins i16mem:$ptr, GR16:$val),
3448 "xchg{w}\t{$val, $ptr|$ptr, $val}",
3449 [(set GR16:$dst, (atomic_swap_16 addr:$ptr, GR16:$val))]>,
3450 OpSize;
3451def XCHG8rm : I<0x86, MRMSrcMem, (outs GR8:$dst), (ins i8mem:$ptr, GR8:$val),
3452 "xchg{b}\t{$val, $ptr|$ptr, $val}",
3453 [(set GR8:$dst, (atomic_swap_8 addr:$ptr, GR8:$val))]>;
3454}
3455
Evan Chengd49dbb82008-04-18 20:55:36 +00003456// Atomic compare and swap.
Andrew Lenharth7dfe23f2008-03-01 21:52:34 +00003457let Defs = [EAX, EFLAGS], Uses = [EAX] in {
Evan Chengd49dbb82008-04-18 20:55:36 +00003458def LCMPXCHG32 : I<0xB1, MRMDestMem, (outs), (ins i32mem:$ptr, GR32:$swap),
Dan Gohman70a8a112009-04-27 15:13:28 +00003459 "lock\n\t"
3460 "cmpxchg{l}\t{$swap, $ptr|$ptr, $swap}",
Evan Cheng09fbdee2008-03-04 03:20:06 +00003461 [(X86cas addr:$ptr, GR32:$swap, 4)]>, TB, LOCK;
Andrew Lenharth7a5a4b22008-03-01 13:37:02 +00003462}
Dale Johannesenf160d802008-10-02 18:53:47 +00003463let Defs = [EAX, EDX, EFLAGS], Uses = [EAX, EBX, ECX, EDX] in {
Anton Korobeynikovc4067392008-07-22 16:22:48 +00003464def LCMPXCHG8B : I<0xC7, MRM1m, (outs), (ins i32mem:$ptr),
Dan Gohman70a8a112009-04-27 15:13:28 +00003465 "lock\n\t"
3466 "cmpxchg8b\t$ptr",
Andrew Lenharth81580822008-03-05 01:15:49 +00003467 [(X86cas8 addr:$ptr)]>, TB, LOCK;
3468}
Andrew Lenharth7dfe23f2008-03-01 21:52:34 +00003469
3470let Defs = [AX, EFLAGS], Uses = [AX] in {
Evan Chengd49dbb82008-04-18 20:55:36 +00003471def LCMPXCHG16 : I<0xB1, MRMDestMem, (outs), (ins i16mem:$ptr, GR16:$swap),
Dan Gohman70a8a112009-04-27 15:13:28 +00003472 "lock\n\t"
3473 "cmpxchg{w}\t{$swap, $ptr|$ptr, $swap}",
Evan Cheng09fbdee2008-03-04 03:20:06 +00003474 [(X86cas addr:$ptr, GR16:$swap, 2)]>, TB, OpSize, LOCK;
Andrew Lenharth7a5a4b22008-03-01 13:37:02 +00003475}
Andrew Lenharth7dfe23f2008-03-01 21:52:34 +00003476let Defs = [AL, EFLAGS], Uses = [AL] in {
Evan Chengd49dbb82008-04-18 20:55:36 +00003477def LCMPXCHG8 : I<0xB0, MRMDestMem, (outs), (ins i8mem:$ptr, GR8:$swap),
Dan Gohman70a8a112009-04-27 15:13:28 +00003478 "lock\n\t"
3479 "cmpxchg{b}\t{$swap, $ptr|$ptr, $swap}",
Evan Cheng09fbdee2008-03-04 03:20:06 +00003480 [(X86cas addr:$ptr, GR8:$swap, 1)]>, TB, LOCK;
Andrew Lenharth7a5a4b22008-03-01 13:37:02 +00003481}
3482
Evan Chengd49dbb82008-04-18 20:55:36 +00003483// Atomic exchange and add
3484let Constraints = "$val = $dst", Defs = [EFLAGS] in {
3485def LXADD32 : I<0xC1, MRMSrcMem, (outs GR32:$dst), (ins i32mem:$ptr, GR32:$val),
Dan Gohman70a8a112009-04-27 15:13:28 +00003486 "lock\n\t"
3487 "xadd{l}\t{$val, $ptr|$ptr, $val}",
Mon P Wang6bde9ec2008-06-25 08:15:39 +00003488 [(set GR32:$dst, (atomic_load_add_32 addr:$ptr, GR32:$val))]>,
Evan Chengd49dbb82008-04-18 20:55:36 +00003489 TB, LOCK;
3490def LXADD16 : I<0xC1, MRMSrcMem, (outs GR16:$dst), (ins i16mem:$ptr, GR16:$val),
Dan Gohman70a8a112009-04-27 15:13:28 +00003491 "lock\n\t"
3492 "xadd{w}\t{$val, $ptr|$ptr, $val}",
Mon P Wang6bde9ec2008-06-25 08:15:39 +00003493 [(set GR16:$dst, (atomic_load_add_16 addr:$ptr, GR16:$val))]>,
Evan Chengd49dbb82008-04-18 20:55:36 +00003494 TB, OpSize, LOCK;
3495def LXADD8 : I<0xC0, MRMSrcMem, (outs GR8:$dst), (ins i8mem:$ptr, GR8:$val),
Dan Gohman70a8a112009-04-27 15:13:28 +00003496 "lock\n\t"
3497 "xadd{b}\t{$val, $ptr|$ptr, $val}",
Mon P Wang6bde9ec2008-06-25 08:15:39 +00003498 [(set GR8:$dst, (atomic_load_add_8 addr:$ptr, GR8:$val))]>,
Evan Chengd49dbb82008-04-18 20:55:36 +00003499 TB, LOCK;
Andrew Lenharth7a5a4b22008-03-01 13:37:02 +00003500}
3501
Evan Chengb723fb52009-07-30 08:33:02 +00003502// Optimized codegen when the non-memory output is not used.
3503// FIXME: Use normal add / sub instructions and add lock prefix dynamically.
3504def LOCK_ADD8mr : I<0x00, MRMDestMem, (outs), (ins i8mem:$dst, GR8:$src2),
3505 "lock\n\t"
3506 "add{b}\t{$src2, $dst|$dst, $src2}", []>, LOCK;
3507def LOCK_ADD16mr : I<0x01, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
3508 "lock\n\t"
3509 "add{w}\t{$src2, $dst|$dst, $src2}", []>, OpSize, LOCK;
3510def LOCK_ADD32mr : I<0x01, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
3511 "lock\n\t"
3512 "add{l}\t{$src2, $dst|$dst, $src2}", []>, LOCK;
3513def LOCK_ADD8mi : Ii8<0x80, MRM0m, (outs), (ins i8mem :$dst, i8imm :$src2),
3514 "lock\n\t"
3515 "add{b}\t{$src2, $dst|$dst, $src2}", []>, LOCK;
3516def LOCK_ADD16mi : Ii16<0x81, MRM0m, (outs), (ins i16mem:$dst, i16imm:$src2),
3517 "lock\n\t"
3518 "add{w}\t{$src2, $dst|$dst, $src2}", []>, LOCK;
3519def LOCK_ADD32mi : Ii32<0x81, MRM0m, (outs), (ins i32mem:$dst, i32imm:$src2),
3520 "lock\n\t"
3521 "add{l}\t{$src2, $dst|$dst, $src2}", []>, LOCK;
3522def LOCK_ADD16mi8 : Ii8<0x83, MRM0m, (outs), (ins i16mem:$dst, i16i8imm :$src2),
3523 "lock\n\t"
3524 "add{w}\t{$src2, $dst|$dst, $src2}", []>, OpSize, LOCK;
3525def LOCK_ADD32mi8 : Ii8<0x83, MRM0m, (outs), (ins i32mem:$dst, i32i8imm :$src2),
3526 "lock\n\t"
3527 "add{l}\t{$src2, $dst|$dst, $src2}", []>, LOCK;
3528
3529def LOCK_INC8m : I<0xFE, MRM0m, (outs), (ins i8mem :$dst),
3530 "lock\n\t"
3531 "inc{b}\t$dst", []>, LOCK;
3532def LOCK_INC16m : I<0xFF, MRM0m, (outs), (ins i16mem:$dst),
3533 "lock\n\t"
3534 "inc{w}\t$dst", []>, OpSize, LOCK;
3535def LOCK_INC32m : I<0xFF, MRM0m, (outs), (ins i32mem:$dst),
3536 "lock\n\t"
3537 "inc{l}\t$dst", []>, LOCK;
3538
3539def LOCK_SUB8mr : I<0x28, MRMDestMem, (outs), (ins i8mem :$dst, GR8 :$src2),
3540 "lock\n\t"
3541 "sub{b}\t{$src2, $dst|$dst, $src2}", []>, LOCK;
3542def LOCK_SUB16mr : I<0x29, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
3543 "lock\n\t"
3544 "sub{w}\t{$src2, $dst|$dst, $src2}", []>, OpSize, LOCK;
3545def LOCK_SUB32mr : I<0x29, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
3546 "lock\n\t"
3547 "sub{l}\t{$src2, $dst|$dst, $src2}", []>, LOCK;
3548def LOCK_SUB8mi : Ii8<0x80, MRM5m, (outs), (ins i8mem :$dst, i8imm:$src2),
3549 "lock\n\t"
3550 "sub{b}\t{$src2, $dst|$dst, $src2}", []>, LOCK;
3551def LOCK_SUB16mi : Ii16<0x81, MRM5m, (outs), (ins i16mem:$dst, i16imm:$src2),
3552 "lock\n\t"
3553 "sub{w}\t{$src2, $dst|$dst, $src2}", []>, OpSize, LOCK;
3554def LOCK_SUB32mi : Ii32<0x81, MRM5m, (outs), (ins i32mem:$dst, i32imm:$src2),
3555 "lock\n\t"
3556 "sub{l}\t{$src2, $dst|$dst, $src2}", []>, LOCK;
3557def LOCK_SUB16mi8 : Ii8<0x83, MRM5m, (outs), (ins i16mem:$dst, i16i8imm :$src2),
3558 "lock\n\t"
3559 "sub{w}\t{$src2, $dst|$dst, $src2}", []>, OpSize, LOCK;
3560def LOCK_SUB32mi8 : Ii8<0x83, MRM5m, (outs), (ins i32mem:$dst, i32i8imm :$src2),
3561 "lock\n\t"
3562 "sub{l}\t{$src2, $dst|$dst, $src2}", []>, LOCK;
3563
3564def LOCK_DEC8m : I<0xFE, MRM1m, (outs), (ins i8mem :$dst),
3565 "lock\n\t"
3566 "dec{b}\t$dst", []>, LOCK;
3567def LOCK_DEC16m : I<0xFF, MRM1m, (outs), (ins i16mem:$dst),
3568 "lock\n\t"
3569 "dec{w}\t$dst", []>, OpSize, LOCK;
3570def LOCK_DEC32m : I<0xFF, MRM1m, (outs), (ins i32mem:$dst),
3571 "lock\n\t"
3572 "dec{l}\t$dst", []>, LOCK;
3573
Mon P Wang6bde9ec2008-06-25 08:15:39 +00003574// Atomic exchange, and, or, xor
Mon P Wang078a62d2008-05-05 19:05:59 +00003575let Constraints = "$val = $dst", Defs = [EFLAGS],
3576 usesCustomDAGSchedInserter = 1 in {
Dan Gohman8aeb61f2008-05-12 20:22:45 +00003577def ATOMAND32 : I<0, Pseudo, (outs GR32:$dst),(ins i32mem:$ptr, GR32:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003578 "#ATOMAND32 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003579 [(set GR32:$dst, (atomic_load_and_32 addr:$ptr, GR32:$val))]>;
Dan Gohman8aeb61f2008-05-12 20:22:45 +00003580def ATOMOR32 : I<0, Pseudo, (outs GR32:$dst),(ins i32mem:$ptr, GR32:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003581 "#ATOMOR32 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003582 [(set GR32:$dst, (atomic_load_or_32 addr:$ptr, GR32:$val))]>;
Dan Gohman8aeb61f2008-05-12 20:22:45 +00003583def ATOMXOR32 : I<0, Pseudo,(outs GR32:$dst),(ins i32mem:$ptr, GR32:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003584 "#ATOMXOR32 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003585 [(set GR32:$dst, (atomic_load_xor_32 addr:$ptr, GR32:$val))]>;
Andrew Lenharthaf02d592008-06-14 05:48:15 +00003586def ATOMNAND32 : I<0, Pseudo,(outs GR32:$dst),(ins i32mem:$ptr, GR32:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003587 "#ATOMNAND32 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003588 [(set GR32:$dst, (atomic_load_nand_32 addr:$ptr, GR32:$val))]>;
Dan Gohman8aeb61f2008-05-12 20:22:45 +00003589def ATOMMIN32: I<0, Pseudo, (outs GR32:$dst), (ins i32mem:$ptr, GR32:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003590 "#ATOMMIN32 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003591 [(set GR32:$dst, (atomic_load_min_32 addr:$ptr, GR32:$val))]>;
Dan Gohman8aeb61f2008-05-12 20:22:45 +00003592def ATOMMAX32: I<0, Pseudo, (outs GR32:$dst),(ins i32mem:$ptr, GR32:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003593 "#ATOMMAX32 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003594 [(set GR32:$dst, (atomic_load_max_32 addr:$ptr, GR32:$val))]>;
Dan Gohman8aeb61f2008-05-12 20:22:45 +00003595def ATOMUMIN32: I<0, Pseudo, (outs GR32:$dst),(ins i32mem:$ptr, GR32:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003596 "#ATOMUMIN32 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003597 [(set GR32:$dst, (atomic_load_umin_32 addr:$ptr, GR32:$val))]>;
Dan Gohman8aeb61f2008-05-12 20:22:45 +00003598def ATOMUMAX32: I<0, Pseudo, (outs GR32:$dst),(ins i32mem:$ptr, GR32:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003599 "#ATOMUMAX32 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003600 [(set GR32:$dst, (atomic_load_umax_32 addr:$ptr, GR32:$val))]>;
Dale Johannesend20e4452008-08-19 18:47:28 +00003601
3602def ATOMAND16 : I<0, Pseudo, (outs GR16:$dst),(ins i16mem:$ptr, GR16:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003603 "#ATOMAND16 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003604 [(set GR16:$dst, (atomic_load_and_16 addr:$ptr, GR16:$val))]>;
Dale Johannesend20e4452008-08-19 18:47:28 +00003605def ATOMOR16 : I<0, Pseudo, (outs GR16:$dst),(ins i16mem:$ptr, GR16:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003606 "#ATOMOR16 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003607 [(set GR16:$dst, (atomic_load_or_16 addr:$ptr, GR16:$val))]>;
Dale Johannesend20e4452008-08-19 18:47:28 +00003608def ATOMXOR16 : I<0, Pseudo,(outs GR16:$dst),(ins i16mem:$ptr, GR16:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003609 "#ATOMXOR16 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003610 [(set GR16:$dst, (atomic_load_xor_16 addr:$ptr, GR16:$val))]>;
Dale Johannesend20e4452008-08-19 18:47:28 +00003611def ATOMNAND16 : I<0, Pseudo,(outs GR16:$dst),(ins i16mem:$ptr, GR16:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003612 "#ATOMNAND16 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003613 [(set GR16:$dst, (atomic_load_nand_16 addr:$ptr, GR16:$val))]>;
Dale Johannesend20e4452008-08-19 18:47:28 +00003614def ATOMMIN16: I<0, Pseudo, (outs GR16:$dst), (ins i16mem:$ptr, GR16:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003615 "#ATOMMIN16 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003616 [(set GR16:$dst, (atomic_load_min_16 addr:$ptr, GR16:$val))]>;
Dale Johannesend20e4452008-08-19 18:47:28 +00003617def ATOMMAX16: I<0, Pseudo, (outs GR16:$dst),(ins i16mem:$ptr, GR16:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003618 "#ATOMMAX16 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003619 [(set GR16:$dst, (atomic_load_max_16 addr:$ptr, GR16:$val))]>;
Dale Johannesend20e4452008-08-19 18:47:28 +00003620def ATOMUMIN16: I<0, Pseudo, (outs GR16:$dst),(ins i16mem:$ptr, GR16:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003621 "#ATOMUMIN16 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003622 [(set GR16:$dst, (atomic_load_umin_16 addr:$ptr, GR16:$val))]>;
Dale Johannesend20e4452008-08-19 18:47:28 +00003623def ATOMUMAX16: I<0, Pseudo, (outs GR16:$dst),(ins i16mem:$ptr, GR16:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003624 "#ATOMUMAX16 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003625 [(set GR16:$dst, (atomic_load_umax_16 addr:$ptr, GR16:$val))]>;
Dale Johannesend20e4452008-08-19 18:47:28 +00003626
3627def ATOMAND8 : I<0, Pseudo, (outs GR8:$dst),(ins i8mem:$ptr, GR8:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003628 "#ATOMAND8 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003629 [(set GR8:$dst, (atomic_load_and_8 addr:$ptr, GR8:$val))]>;
Dale Johannesend20e4452008-08-19 18:47:28 +00003630def ATOMOR8 : I<0, Pseudo, (outs GR8:$dst),(ins i8mem:$ptr, GR8:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003631 "#ATOMOR8 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003632 [(set GR8:$dst, (atomic_load_or_8 addr:$ptr, GR8:$val))]>;
Dale Johannesend20e4452008-08-19 18:47:28 +00003633def ATOMXOR8 : I<0, Pseudo,(outs GR8:$dst),(ins i8mem:$ptr, GR8:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003634 "#ATOMXOR8 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003635 [(set GR8:$dst, (atomic_load_xor_8 addr:$ptr, GR8:$val))]>;
Dale Johannesend20e4452008-08-19 18:47:28 +00003636def ATOMNAND8 : I<0, Pseudo,(outs GR8:$dst),(ins i8mem:$ptr, GR8:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003637 "#ATOMNAND8 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003638 [(set GR8:$dst, (atomic_load_nand_8 addr:$ptr, GR8:$val))]>;
Mon P Wang078a62d2008-05-05 19:05:59 +00003639}
3640
Dale Johannesenf160d802008-10-02 18:53:47 +00003641let Constraints = "$val1 = $dst1, $val2 = $dst2",
3642 Defs = [EFLAGS, EAX, EBX, ECX, EDX],
3643 Uses = [EAX, EBX, ECX, EDX],
Dale Johannesen44eb5372008-10-03 19:41:08 +00003644 mayLoad = 1, mayStore = 1,
Dale Johannesenf160d802008-10-02 18:53:47 +00003645 usesCustomDAGSchedInserter = 1 in {
3646def ATOMAND6432 : I<0, Pseudo, (outs GR32:$dst1, GR32:$dst2),
3647 (ins i64mem:$ptr, GR32:$val1, GR32:$val2),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003648 "#ATOMAND6432 PSEUDO!", []>;
Dale Johannesenf160d802008-10-02 18:53:47 +00003649def ATOMOR6432 : I<0, Pseudo, (outs GR32:$dst1, GR32:$dst2),
3650 (ins i64mem:$ptr, GR32:$val1, GR32:$val2),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003651 "#ATOMOR6432 PSEUDO!", []>;
Dale Johannesenf160d802008-10-02 18:53:47 +00003652def ATOMXOR6432 : I<0, Pseudo, (outs GR32:$dst1, GR32:$dst2),
3653 (ins i64mem:$ptr, GR32:$val1, GR32:$val2),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003654 "#ATOMXOR6432 PSEUDO!", []>;
Dale Johannesenf160d802008-10-02 18:53:47 +00003655def ATOMNAND6432 : I<0, Pseudo, (outs GR32:$dst1, GR32:$dst2),
3656 (ins i64mem:$ptr, GR32:$val1, GR32:$val2),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003657 "#ATOMNAND6432 PSEUDO!", []>;
Dale Johannesenf160d802008-10-02 18:53:47 +00003658def ATOMADD6432 : I<0, Pseudo, (outs GR32:$dst1, GR32:$dst2),
3659 (ins i64mem:$ptr, GR32:$val1, GR32:$val2),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003660 "#ATOMADD6432 PSEUDO!", []>;
Dale Johannesenf160d802008-10-02 18:53:47 +00003661def ATOMSUB6432 : I<0, Pseudo, (outs GR32:$dst1, GR32:$dst2),
3662 (ins i64mem:$ptr, GR32:$val1, GR32:$val2),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003663 "#ATOMSUB6432 PSEUDO!", []>;
Dale Johannesen51c58ee2008-10-03 22:25:52 +00003664def ATOMSWAP6432 : I<0, Pseudo, (outs GR32:$dst1, GR32:$dst2),
3665 (ins i64mem:$ptr, GR32:$val1, GR32:$val2),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003666 "#ATOMSWAP6432 PSEUDO!", []>;
Dale Johannesenf160d802008-10-02 18:53:47 +00003667}
3668
Andrew Lenharthe44f3902008-02-21 06:45:13 +00003669//===----------------------------------------------------------------------===//
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003670// Non-Instruction Patterns
3671//===----------------------------------------------------------------------===//
3672
Bill Wendlingfef06052008-09-16 21:48:12 +00003673// ConstantPool GlobalAddress, ExternalSymbol, and JumpTable
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003674def : Pat<(i32 (X86Wrapper tconstpool :$dst)), (MOV32ri tconstpool :$dst)>;
3675def : Pat<(i32 (X86Wrapper tjumptable :$dst)), (MOV32ri tjumptable :$dst)>;
Nate Begemanb52948972008-04-12 00:47:57 +00003676def : Pat<(i32 (X86Wrapper tglobaltlsaddr:$dst)),(MOV32ri tglobaltlsaddr:$dst)>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003677def : Pat<(i32 (X86Wrapper tglobaladdr :$dst)), (MOV32ri tglobaladdr :$dst)>;
3678def : Pat<(i32 (X86Wrapper texternalsym:$dst)), (MOV32ri texternalsym:$dst)>;
3679
3680def : Pat<(add GR32:$src1, (X86Wrapper tconstpool:$src2)),
3681 (ADD32ri GR32:$src1, tconstpool:$src2)>;
3682def : Pat<(add GR32:$src1, (X86Wrapper tjumptable:$src2)),
3683 (ADD32ri GR32:$src1, tjumptable:$src2)>;
3684def : Pat<(add GR32:$src1, (X86Wrapper tglobaladdr :$src2)),
3685 (ADD32ri GR32:$src1, tglobaladdr:$src2)>;
3686def : Pat<(add GR32:$src1, (X86Wrapper texternalsym:$src2)),
3687 (ADD32ri GR32:$src1, texternalsym:$src2)>;
3688
3689def : Pat<(store (i32 (X86Wrapper tglobaladdr:$src)), addr:$dst),
3690 (MOV32mi addr:$dst, tglobaladdr:$src)>;
3691def : Pat<(store (i32 (X86Wrapper texternalsym:$src)), addr:$dst),
3692 (MOV32mi addr:$dst, texternalsym:$src)>;
3693
3694// Calls
Arnold Schwaighofere2d6bbb2007-10-11 19:40:01 +00003695// tailcall stuff
Arnold Schwaighofere2d6bbb2007-10-11 19:40:01 +00003696def : Pat<(X86tcret GR32:$dst, imm:$off),
3697 (TCRETURNri GR32:$dst, imm:$off)>;
3698
3699def : Pat<(X86tcret (i32 tglobaladdr:$dst), imm:$off),
3700 (TCRETURNdi texternalsym:$dst, imm:$off)>;
3701
3702def : Pat<(X86tcret (i32 texternalsym:$dst), imm:$off),
3703 (TCRETURNdi texternalsym:$dst, imm:$off)>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003704
Dan Gohmance5dbff2009-08-02 16:10:01 +00003705// Normal calls, with various flavors of addresses.
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003706def : Pat<(X86call (i32 tglobaladdr:$dst)),
3707 (CALLpcrel32 tglobaladdr:$dst)>;
3708def : Pat<(X86call (i32 texternalsym:$dst)),
3709 (CALLpcrel32 texternalsym:$dst)>;
Evan Cheng6d35a4d2009-05-20 04:53:57 +00003710def : Pat<(X86call (i32 imm:$dst)),
3711 (CALLpcrel32 imm:$dst)>, Requires<[CallImmAddr]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003712
3713// X86 specific add which produces a flag.
3714def : Pat<(addc GR32:$src1, GR32:$src2),
3715 (ADD32rr GR32:$src1, GR32:$src2)>;
3716def : Pat<(addc GR32:$src1, (load addr:$src2)),
3717 (ADD32rm GR32:$src1, addr:$src2)>;
3718def : Pat<(addc GR32:$src1, imm:$src2),
3719 (ADD32ri GR32:$src1, imm:$src2)>;
3720def : Pat<(addc GR32:$src1, i32immSExt8:$src2),
3721 (ADD32ri8 GR32:$src1, i32immSExt8:$src2)>;
3722
3723def : Pat<(subc GR32:$src1, GR32:$src2),
3724 (SUB32rr GR32:$src1, GR32:$src2)>;
3725def : Pat<(subc GR32:$src1, (load addr:$src2)),
3726 (SUB32rm GR32:$src1, addr:$src2)>;
3727def : Pat<(subc GR32:$src1, imm:$src2),
3728 (SUB32ri GR32:$src1, imm:$src2)>;
3729def : Pat<(subc GR32:$src1, i32immSExt8:$src2),
3730 (SUB32ri8 GR32:$src1, i32immSExt8:$src2)>;
3731
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003732// Comparisons.
3733
3734// TEST R,R is smaller than CMP R,0
Evan Cheng621216e2007-09-29 00:00:36 +00003735def : Pat<(parallel (X86cmp GR8:$src1, 0), (implicit EFLAGS)),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003736 (TEST8rr GR8:$src1, GR8:$src1)>;
Evan Cheng621216e2007-09-29 00:00:36 +00003737def : Pat<(parallel (X86cmp GR16:$src1, 0), (implicit EFLAGS)),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003738 (TEST16rr GR16:$src1, GR16:$src1)>;
Evan Cheng621216e2007-09-29 00:00:36 +00003739def : Pat<(parallel (X86cmp GR32:$src1, 0), (implicit EFLAGS)),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003740 (TEST32rr GR32:$src1, GR32:$src1)>;
3741
Dan Gohman0a3c5222009-01-07 01:00:24 +00003742// Conditional moves with folded loads with operands swapped and conditions
3743// inverted.
3744def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_B, EFLAGS),
3745 (CMOVAE16rm GR16:$src2, addr:$src1)>;
3746def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_B, EFLAGS),
3747 (CMOVAE32rm GR32:$src2, addr:$src1)>;
3748def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_AE, EFLAGS),
3749 (CMOVB16rm GR16:$src2, addr:$src1)>;
3750def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_AE, EFLAGS),
3751 (CMOVB32rm GR32:$src2, addr:$src1)>;
3752def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_E, EFLAGS),
3753 (CMOVNE16rm GR16:$src2, addr:$src1)>;
3754def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_E, EFLAGS),
3755 (CMOVNE32rm GR32:$src2, addr:$src1)>;
3756def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_NE, EFLAGS),
3757 (CMOVE16rm GR16:$src2, addr:$src1)>;
3758def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_NE, EFLAGS),
3759 (CMOVE32rm GR32:$src2, addr:$src1)>;
3760def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_BE, EFLAGS),
3761 (CMOVA16rm GR16:$src2, addr:$src1)>;
3762def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_BE, EFLAGS),
3763 (CMOVA32rm GR32:$src2, addr:$src1)>;
3764def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_A, EFLAGS),
3765 (CMOVBE16rm GR16:$src2, addr:$src1)>;
3766def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_A, EFLAGS),
3767 (CMOVBE32rm GR32:$src2, addr:$src1)>;
3768def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_L, EFLAGS),
3769 (CMOVGE16rm GR16:$src2, addr:$src1)>;
3770def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_L, EFLAGS),
3771 (CMOVGE32rm GR32:$src2, addr:$src1)>;
3772def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_GE, EFLAGS),
3773 (CMOVL16rm GR16:$src2, addr:$src1)>;
3774def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_GE, EFLAGS),
3775 (CMOVL32rm GR32:$src2, addr:$src1)>;
3776def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_LE, EFLAGS),
3777 (CMOVG16rm GR16:$src2, addr:$src1)>;
3778def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_LE, EFLAGS),
3779 (CMOVG32rm GR32:$src2, addr:$src1)>;
3780def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_G, EFLAGS),
3781 (CMOVLE16rm GR16:$src2, addr:$src1)>;
3782def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_G, EFLAGS),
3783 (CMOVLE32rm GR32:$src2, addr:$src1)>;
3784def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_P, EFLAGS),
3785 (CMOVNP16rm GR16:$src2, addr:$src1)>;
3786def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_P, EFLAGS),
3787 (CMOVNP32rm GR32:$src2, addr:$src1)>;
3788def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_NP, EFLAGS),
3789 (CMOVP16rm GR16:$src2, addr:$src1)>;
3790def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_NP, EFLAGS),
3791 (CMOVP32rm GR32:$src2, addr:$src1)>;
3792def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_S, EFLAGS),
3793 (CMOVNS16rm GR16:$src2, addr:$src1)>;
3794def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_S, EFLAGS),
3795 (CMOVNS32rm GR32:$src2, addr:$src1)>;
3796def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_NS, EFLAGS),
3797 (CMOVS16rm GR16:$src2, addr:$src1)>;
3798def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_NS, EFLAGS),
3799 (CMOVS32rm GR32:$src2, addr:$src1)>;
3800def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_O, EFLAGS),
3801 (CMOVNO16rm GR16:$src2, addr:$src1)>;
3802def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_O, EFLAGS),
3803 (CMOVNO32rm GR32:$src2, addr:$src1)>;
3804def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_NO, EFLAGS),
3805 (CMOVO16rm GR16:$src2, addr:$src1)>;
3806def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_NO, EFLAGS),
3807 (CMOVO32rm GR32:$src2, addr:$src1)>;
3808
Duncan Sands082524c2008-01-23 20:39:46 +00003809// zextload bool -> zextload byte
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003810def : Pat<(zextloadi8i1 addr:$src), (MOV8rm addr:$src)>;
3811def : Pat<(zextloadi16i1 addr:$src), (MOVZX16rm8 addr:$src)>;
3812def : Pat<(zextloadi32i1 addr:$src), (MOVZX32rm8 addr:$src)>;
3813
3814// extload bool -> extload byte
3815def : Pat<(extloadi8i1 addr:$src), (MOV8rm addr:$src)>;
Dan Gohman9959b052009-08-26 14:59:13 +00003816def : Pat<(extloadi16i1 addr:$src), (MOVZX16rm8 addr:$src)>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003817def : Pat<(extloadi32i1 addr:$src), (MOVZX32rm8 addr:$src)>;
Dan Gohman9959b052009-08-26 14:59:13 +00003818def : Pat<(extloadi16i8 addr:$src), (MOVZX16rm8 addr:$src)>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003819def : Pat<(extloadi32i8 addr:$src), (MOVZX32rm8 addr:$src)>;
3820def : Pat<(extloadi32i16 addr:$src), (MOVZX32rm16 addr:$src)>;
3821
Dan Gohman9959b052009-08-26 14:59:13 +00003822// anyext. Define these to do an explicit zero-extend to
3823// avoid partial-register updates.
3824def : Pat<(i16 (anyext GR8 :$src)), (MOVZX16rr8 GR8 :$src)>;
3825def : Pat<(i32 (anyext GR8 :$src)), (MOVZX32rr8 GR8 :$src)>;
3826def : Pat<(i32 (anyext GR16:$src)), (MOVZX32rr16 GR16:$src)>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003827
Evan Chengf2abee72007-12-13 00:43:27 +00003828// (and (i32 load), 255) -> (zextload i8)
Evan Cheng1e5e5452008-09-29 17:26:18 +00003829def : Pat<(i32 (and (nvloadi32 addr:$src), (i32 255))),
3830 (MOVZX32rm8 addr:$src)>;
3831def : Pat<(i32 (and (nvloadi32 addr:$src), (i32 65535))),
3832 (MOVZX32rm16 addr:$src)>;
Evan Chengf2abee72007-12-13 00:43:27 +00003833
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003834//===----------------------------------------------------------------------===//
3835// Some peepholes
3836//===----------------------------------------------------------------------===//
3837
Dan Gohman5a5e6e92008-10-17 01:33:43 +00003838// Odd encoding trick: -128 fits into an 8-bit immediate field while
3839// +128 doesn't, so in this special case use a sub instead of an add.
3840def : Pat<(add GR16:$src1, 128),
3841 (SUB16ri8 GR16:$src1, -128)>;
3842def : Pat<(store (add (loadi16 addr:$dst), 128), addr:$dst),
3843 (SUB16mi8 addr:$dst, -128)>;
3844def : Pat<(add GR32:$src1, 128),
3845 (SUB32ri8 GR32:$src1, -128)>;
3846def : Pat<(store (add (loadi32 addr:$dst), 128), addr:$dst),
3847 (SUB32mi8 addr:$dst, -128)>;
3848
Dan Gohman9203ab42008-07-30 18:09:17 +00003849// r & (2^16-1) ==> movz
3850def : Pat<(and GR32:$src1, 0xffff),
Dan Gohman744d4622009-04-13 16:09:41 +00003851 (MOVZX32rr16 (EXTRACT_SUBREG GR32:$src1, x86_subreg_16bit))>;
Dan Gohman5beb1ff2008-08-06 18:27:21 +00003852// r & (2^8-1) ==> movz
3853def : Pat<(and GR32:$src1, 0xff),
Dan Gohman6e438702009-04-27 16:33:14 +00003854 (MOVZX32rr8 (EXTRACT_SUBREG (COPY_TO_REGCLASS GR32:$src1, GR32_ABCD),
Dan Gohman744d4622009-04-13 16:09:41 +00003855 x86_subreg_8bit))>,
Dan Gohman5beb1ff2008-08-06 18:27:21 +00003856 Requires<[In32BitMode]>;
3857// r & (2^8-1) ==> movz
3858def : Pat<(and GR16:$src1, 0xff),
Dan Gohman6e438702009-04-27 16:33:14 +00003859 (MOVZX16rr8 (EXTRACT_SUBREG (COPY_TO_REGCLASS GR16:$src1, GR16_ABCD),
Dan Gohman744d4622009-04-13 16:09:41 +00003860 x86_subreg_8bit))>,
Dan Gohmandd612bb2008-08-20 21:27:32 +00003861 Requires<[In32BitMode]>;
3862
3863// sext_inreg patterns
3864def : Pat<(sext_inreg GR32:$src, i16),
Dan Gohman744d4622009-04-13 16:09:41 +00003865 (MOVSX32rr16 (EXTRACT_SUBREG GR32:$src, x86_subreg_16bit))>;
Dan Gohmandd612bb2008-08-20 21:27:32 +00003866def : Pat<(sext_inreg GR32:$src, i8),
Dan Gohman6e438702009-04-27 16:33:14 +00003867 (MOVSX32rr8 (EXTRACT_SUBREG (COPY_TO_REGCLASS GR32:$src, GR32_ABCD),
Dan Gohman744d4622009-04-13 16:09:41 +00003868 x86_subreg_8bit))>,
Dan Gohmandd612bb2008-08-20 21:27:32 +00003869 Requires<[In32BitMode]>;
3870def : Pat<(sext_inreg GR16:$src, i8),
Dan Gohman6e438702009-04-27 16:33:14 +00003871 (MOVSX16rr8 (EXTRACT_SUBREG (COPY_TO_REGCLASS GR16:$src, GR16_ABCD),
Dan Gohman744d4622009-04-13 16:09:41 +00003872 x86_subreg_8bit))>,
Dan Gohmandd612bb2008-08-20 21:27:32 +00003873 Requires<[In32BitMode]>;
3874
3875// trunc patterns
3876def : Pat<(i16 (trunc GR32:$src)),
Dan Gohman744d4622009-04-13 16:09:41 +00003877 (EXTRACT_SUBREG GR32:$src, x86_subreg_16bit)>;
Dan Gohmandd612bb2008-08-20 21:27:32 +00003878def : Pat<(i8 (trunc GR32:$src)),
Dan Gohman6e438702009-04-27 16:33:14 +00003879 (EXTRACT_SUBREG (COPY_TO_REGCLASS GR32:$src, GR32_ABCD),
Dan Gohman744d4622009-04-13 16:09:41 +00003880 x86_subreg_8bit)>,
Dan Gohmandd612bb2008-08-20 21:27:32 +00003881 Requires<[In32BitMode]>;
3882def : Pat<(i8 (trunc GR16:$src)),
Dan Gohman6e438702009-04-27 16:33:14 +00003883 (EXTRACT_SUBREG (COPY_TO_REGCLASS GR16:$src, GR16_ABCD),
Dan Gohman744d4622009-04-13 16:09:41 +00003884 x86_subreg_8bit)>,
3885 Requires<[In32BitMode]>;
3886
3887// h-register tricks
3888def : Pat<(i8 (trunc (srl_su GR16:$src, (i8 8)))),
Dan Gohman6e438702009-04-27 16:33:14 +00003889 (EXTRACT_SUBREG (COPY_TO_REGCLASS GR16:$src, GR16_ABCD),
Dan Gohman744d4622009-04-13 16:09:41 +00003890 x86_subreg_8bit_hi)>,
3891 Requires<[In32BitMode]>;
3892def : Pat<(i8 (trunc (srl_su GR32:$src, (i8 8)))),
Dan Gohman6e438702009-04-27 16:33:14 +00003893 (EXTRACT_SUBREG (COPY_TO_REGCLASS GR32:$src, GR32_ABCD),
Dan Gohman744d4622009-04-13 16:09:41 +00003894 x86_subreg_8bit_hi)>,
3895 Requires<[In32BitMode]>;
3896def : Pat<(srl_su GR16:$src, (i8 8)),
3897 (EXTRACT_SUBREG
3898 (MOVZX32rr8
Dan Gohman6e438702009-04-27 16:33:14 +00003899 (EXTRACT_SUBREG (COPY_TO_REGCLASS GR16:$src, GR16_ABCD),
Dan Gohman744d4622009-04-13 16:09:41 +00003900 x86_subreg_8bit_hi)),
3901 x86_subreg_16bit)>,
3902 Requires<[In32BitMode]>;
Evan Cheng957ca282009-05-29 01:44:43 +00003903def : Pat<(i32 (zext (srl_su GR16:$src, (i8 8)))),
3904 (MOVZX32rr8 (EXTRACT_SUBREG (COPY_TO_REGCLASS GR16:$src, GR16_ABCD),
3905 x86_subreg_8bit_hi))>,
3906 Requires<[In32BitMode]>;
Dan Gohman9959b052009-08-26 14:59:13 +00003907def : Pat<(i32 (anyext (srl_su GR16:$src, (i8 8)))),
3908 (MOVZX32rr8 (EXTRACT_SUBREG (COPY_TO_REGCLASS GR16:$src, GR16_ABCD),
3909 x86_subreg_8bit_hi))>,
3910 Requires<[In32BitMode]>;
Dan Gohman744d4622009-04-13 16:09:41 +00003911def : Pat<(and (srl_su GR32:$src, (i8 8)), (i32 255)),
Dan Gohman6e438702009-04-27 16:33:14 +00003912 (MOVZX32rr8 (EXTRACT_SUBREG (COPY_TO_REGCLASS GR32:$src, GR32_ABCD),
Dan Gohman744d4622009-04-13 16:09:41 +00003913 x86_subreg_8bit_hi))>,
Dan Gohman5beb1ff2008-08-06 18:27:21 +00003914 Requires<[In32BitMode]>;
Dan Gohman9203ab42008-07-30 18:09:17 +00003915
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003916// (shl x, 1) ==> (add x, x)
3917def : Pat<(shl GR8 :$src1, (i8 1)), (ADD8rr GR8 :$src1, GR8 :$src1)>;
3918def : Pat<(shl GR16:$src1, (i8 1)), (ADD16rr GR16:$src1, GR16:$src1)>;
3919def : Pat<(shl GR32:$src1, (i8 1)), (ADD32rr GR32:$src1, GR32:$src1)>;
3920
Evan Cheng76a64c72008-08-30 02:03:58 +00003921// (shl x (and y, 31)) ==> (shl x, y)
3922def : Pat<(shl GR8:$src1, (and CL:$amt, 31)),
3923 (SHL8rCL GR8:$src1)>;
3924def : Pat<(shl GR16:$src1, (and CL:$amt, 31)),
3925 (SHL16rCL GR16:$src1)>;
3926def : Pat<(shl GR32:$src1, (and CL:$amt, 31)),
3927 (SHL32rCL GR32:$src1)>;
3928def : Pat<(store (shl (loadi8 addr:$dst), (and CL:$amt, 31)), addr:$dst),
3929 (SHL8mCL addr:$dst)>;
3930def : Pat<(store (shl (loadi16 addr:$dst), (and CL:$amt, 31)), addr:$dst),
3931 (SHL16mCL addr:$dst)>;
3932def : Pat<(store (shl (loadi32 addr:$dst), (and CL:$amt, 31)), addr:$dst),
3933 (SHL32mCL addr:$dst)>;
3934
3935def : Pat<(srl GR8:$src1, (and CL:$amt, 31)),
3936 (SHR8rCL GR8:$src1)>;
3937def : Pat<(srl GR16:$src1, (and CL:$amt, 31)),
3938 (SHR16rCL GR16:$src1)>;
3939def : Pat<(srl GR32:$src1, (and CL:$amt, 31)),
3940 (SHR32rCL GR32:$src1)>;
3941def : Pat<(store (srl (loadi8 addr:$dst), (and CL:$amt, 31)), addr:$dst),
3942 (SHR8mCL addr:$dst)>;
3943def : Pat<(store (srl (loadi16 addr:$dst), (and CL:$amt, 31)), addr:$dst),
3944 (SHR16mCL addr:$dst)>;
3945def : Pat<(store (srl (loadi32 addr:$dst), (and CL:$amt, 31)), addr:$dst),
3946 (SHR32mCL addr:$dst)>;
3947
3948def : Pat<(sra GR8:$src1, (and CL:$amt, 31)),
3949 (SAR8rCL GR8:$src1)>;
3950def : Pat<(sra GR16:$src1, (and CL:$amt, 31)),
3951 (SAR16rCL GR16:$src1)>;
3952def : Pat<(sra GR32:$src1, (and CL:$amt, 31)),
3953 (SAR32rCL GR32:$src1)>;
3954def : Pat<(store (sra (loadi8 addr:$dst), (and CL:$amt, 31)), addr:$dst),
3955 (SAR8mCL addr:$dst)>;
3956def : Pat<(store (sra (loadi16 addr:$dst), (and CL:$amt, 31)), addr:$dst),
3957 (SAR16mCL addr:$dst)>;
3958def : Pat<(store (sra (loadi32 addr:$dst), (and CL:$amt, 31)), addr:$dst),
3959 (SAR32mCL addr:$dst)>;
3960
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003961// (or (x >> c) | (y << (32 - c))) ==> (shrd32 x, y, c)
3962def : Pat<(or (srl GR32:$src1, CL:$amt),
3963 (shl GR32:$src2, (sub 32, CL:$amt))),
3964 (SHRD32rrCL GR32:$src1, GR32:$src2)>;
3965
3966def : Pat<(store (or (srl (loadi32 addr:$dst), CL:$amt),
3967 (shl GR32:$src2, (sub 32, CL:$amt))), addr:$dst),
3968 (SHRD32mrCL addr:$dst, GR32:$src2)>;
3969
Dan Gohman921581d2008-10-17 01:23:35 +00003970def : Pat<(or (srl GR32:$src1, (i8 (trunc ECX:$amt))),
3971 (shl GR32:$src2, (i8 (trunc (sub 32, ECX:$amt))))),
3972 (SHRD32rrCL GR32:$src1, GR32:$src2)>;
3973
3974def : Pat<(store (or (srl (loadi32 addr:$dst), (i8 (trunc ECX:$amt))),
3975 (shl GR32:$src2, (i8 (trunc (sub 32, ECX:$amt))))),
3976 addr:$dst),
3977 (SHRD32mrCL addr:$dst, GR32:$src2)>;
3978
3979def : Pat<(shrd GR32:$src1, (i8 imm:$amt1), GR32:$src2, (i8 imm:$amt2)),
3980 (SHRD32rri8 GR32:$src1, GR32:$src2, (i8 imm:$amt1))>;
3981
3982def : Pat<(store (shrd (loadi32 addr:$dst), (i8 imm:$amt1),
3983 GR32:$src2, (i8 imm:$amt2)), addr:$dst),
3984 (SHRD32mri8 addr:$dst, GR32:$src2, (i8 imm:$amt1))>;
3985
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003986// (or (x << c) | (y >> (32 - c))) ==> (shld32 x, y, c)
3987def : Pat<(or (shl GR32:$src1, CL:$amt),
3988 (srl GR32:$src2, (sub 32, CL:$amt))),
3989 (SHLD32rrCL GR32:$src1, GR32:$src2)>;
3990
3991def : Pat<(store (or (shl (loadi32 addr:$dst), CL:$amt),
3992 (srl GR32:$src2, (sub 32, CL:$amt))), addr:$dst),
3993 (SHLD32mrCL addr:$dst, GR32:$src2)>;
3994
Dan Gohman921581d2008-10-17 01:23:35 +00003995def : Pat<(or (shl GR32:$src1, (i8 (trunc ECX:$amt))),
3996 (srl GR32:$src2, (i8 (trunc (sub 32, ECX:$amt))))),
3997 (SHLD32rrCL GR32:$src1, GR32:$src2)>;
3998
3999def : Pat<(store (or (shl (loadi32 addr:$dst), (i8 (trunc ECX:$amt))),
4000 (srl GR32:$src2, (i8 (trunc (sub 32, ECX:$amt))))),
4001 addr:$dst),
4002 (SHLD32mrCL addr:$dst, GR32:$src2)>;
4003
4004def : Pat<(shld GR32:$src1, (i8 imm:$amt1), GR32:$src2, (i8 imm:$amt2)),
4005 (SHLD32rri8 GR32:$src1, GR32:$src2, (i8 imm:$amt1))>;
4006
4007def : Pat<(store (shld (loadi32 addr:$dst), (i8 imm:$amt1),
4008 GR32:$src2, (i8 imm:$amt2)), addr:$dst),
4009 (SHLD32mri8 addr:$dst, GR32:$src2, (i8 imm:$amt1))>;
4010
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004011// (or (x >> c) | (y << (16 - c))) ==> (shrd16 x, y, c)
4012def : Pat<(or (srl GR16:$src1, CL:$amt),
4013 (shl GR16:$src2, (sub 16, CL:$amt))),
4014 (SHRD16rrCL GR16:$src1, GR16:$src2)>;
4015
4016def : Pat<(store (or (srl (loadi16 addr:$dst), CL:$amt),
4017 (shl GR16:$src2, (sub 16, CL:$amt))), addr:$dst),
4018 (SHRD16mrCL addr:$dst, GR16:$src2)>;
4019
Dan Gohman921581d2008-10-17 01:23:35 +00004020def : Pat<(or (srl GR16:$src1, (i8 (trunc CX:$amt))),
4021 (shl GR16:$src2, (i8 (trunc (sub 16, CX:$amt))))),
4022 (SHRD16rrCL GR16:$src1, GR16:$src2)>;
4023
4024def : Pat<(store (or (srl (loadi16 addr:$dst), (i8 (trunc CX:$amt))),
4025 (shl GR16:$src2, (i8 (trunc (sub 16, CX:$amt))))),
4026 addr:$dst),
4027 (SHRD16mrCL addr:$dst, GR16:$src2)>;
4028
4029def : Pat<(shrd GR16:$src1, (i8 imm:$amt1), GR16:$src2, (i8 imm:$amt2)),
4030 (SHRD16rri8 GR16:$src1, GR16:$src2, (i8 imm:$amt1))>;
4031
4032def : Pat<(store (shrd (loadi16 addr:$dst), (i8 imm:$amt1),
4033 GR16:$src2, (i8 imm:$amt2)), addr:$dst),
4034 (SHRD16mri8 addr:$dst, GR16:$src2, (i8 imm:$amt1))>;
4035
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004036// (or (x << c) | (y >> (16 - c))) ==> (shld16 x, y, c)
4037def : Pat<(or (shl GR16:$src1, CL:$amt),
4038 (srl GR16:$src2, (sub 16, CL:$amt))),
4039 (SHLD16rrCL GR16:$src1, GR16:$src2)>;
4040
4041def : Pat<(store (or (shl (loadi16 addr:$dst), CL:$amt),
4042 (srl GR16:$src2, (sub 16, CL:$amt))), addr:$dst),
4043 (SHLD16mrCL addr:$dst, GR16:$src2)>;
4044
Dan Gohman921581d2008-10-17 01:23:35 +00004045def : Pat<(or (shl GR16:$src1, (i8 (trunc CX:$amt))),
4046 (srl GR16:$src2, (i8 (trunc (sub 16, CX:$amt))))),
4047 (SHLD16rrCL GR16:$src1, GR16:$src2)>;
4048
4049def : Pat<(store (or (shl (loadi16 addr:$dst), (i8 (trunc CX:$amt))),
4050 (srl GR16:$src2, (i8 (trunc (sub 16, CX:$amt))))),
4051 addr:$dst),
4052 (SHLD16mrCL addr:$dst, GR16:$src2)>;
4053
4054def : Pat<(shld GR16:$src1, (i8 imm:$amt1), GR16:$src2, (i8 imm:$amt2)),
4055 (SHLD16rri8 GR16:$src1, GR16:$src2, (i8 imm:$amt1))>;
4056
4057def : Pat<(store (shld (loadi16 addr:$dst), (i8 imm:$amt1),
4058 GR16:$src2, (i8 imm:$amt2)), addr:$dst),
4059 (SHLD16mri8 addr:$dst, GR16:$src2, (i8 imm:$amt1))>;
4060
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004061//===----------------------------------------------------------------------===//
Dan Gohman99a12192009-03-04 19:44:21 +00004062// EFLAGS-defining Patterns
Bill Wendlingf5399032008-12-12 21:15:41 +00004063//===----------------------------------------------------------------------===//
4064
Dan Gohman99a12192009-03-04 19:44:21 +00004065// Register-Register Addition with EFLAGS result
4066def : Pat<(parallel (X86add_flag GR8:$src1, GR8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004067 (implicit EFLAGS)),
4068 (ADD8rr GR8:$src1, GR8:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00004069def : Pat<(parallel (X86add_flag GR16:$src1, GR16:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004070 (implicit EFLAGS)),
4071 (ADD16rr GR16:$src1, GR16:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00004072def : Pat<(parallel (X86add_flag GR32:$src1, GR32:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004073 (implicit EFLAGS)),
4074 (ADD32rr GR32:$src1, GR32:$src2)>;
4075
Dan Gohman99a12192009-03-04 19:44:21 +00004076// Register-Memory Addition with EFLAGS result
4077def : Pat<(parallel (X86add_flag GR8:$src1, (loadi8 addr:$src2)),
Bill Wendlingf5399032008-12-12 21:15:41 +00004078 (implicit EFLAGS)),
4079 (ADD8rm GR8:$src1, addr:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00004080def : Pat<(parallel (X86add_flag GR16:$src1, (loadi16 addr:$src2)),
Bill Wendlingf5399032008-12-12 21:15:41 +00004081 (implicit EFLAGS)),
4082 (ADD16rm GR16:$src1, addr:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00004083def : Pat<(parallel (X86add_flag GR32:$src1, (loadi32 addr:$src2)),
Bill Wendlingf5399032008-12-12 21:15:41 +00004084 (implicit EFLAGS)),
4085 (ADD32rm GR32:$src1, addr:$src2)>;
4086
Dan Gohman99a12192009-03-04 19:44:21 +00004087// Register-Integer Addition with EFLAGS result
4088def : Pat<(parallel (X86add_flag GR8:$src1, imm:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004089 (implicit EFLAGS)),
4090 (ADD8ri GR8:$src1, imm:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00004091def : Pat<(parallel (X86add_flag GR16:$src1, imm:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004092 (implicit EFLAGS)),
4093 (ADD16ri GR16:$src1, imm:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00004094def : Pat<(parallel (X86add_flag GR32:$src1, imm:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004095 (implicit EFLAGS)),
4096 (ADD32ri GR32:$src1, imm:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00004097def : Pat<(parallel (X86add_flag GR16:$src1, i16immSExt8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004098 (implicit EFLAGS)),
4099 (ADD16ri8 GR16:$src1, i16immSExt8:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00004100def : Pat<(parallel (X86add_flag GR32:$src1, i32immSExt8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004101 (implicit EFLAGS)),
4102 (ADD32ri8 GR32:$src1, i32immSExt8:$src2)>;
4103
Dan Gohman99a12192009-03-04 19:44:21 +00004104// Memory-Register Addition with EFLAGS result
4105def : Pat<(parallel (store (X86add_flag (loadi8 addr:$dst), GR8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004106 addr:$dst),
4107 (implicit EFLAGS)),
4108 (ADD8mr addr:$dst, GR8:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00004109def : Pat<(parallel (store (X86add_flag (loadi16 addr:$dst), GR16:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004110 addr:$dst),
4111 (implicit EFLAGS)),
4112 (ADD16mr addr:$dst, GR16:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00004113def : Pat<(parallel (store (X86add_flag (loadi32 addr:$dst), GR32:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004114 addr:$dst),
4115 (implicit EFLAGS)),
4116 (ADD32mr addr:$dst, GR32:$src2)>;
Dale Johannesen06b83f12009-05-18 17:44:15 +00004117
4118// Memory-Integer Addition with EFLAGS result
Dan Gohman99a12192009-03-04 19:44:21 +00004119def : Pat<(parallel (store (X86add_flag (loadi8 addr:$dst), imm:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004120 addr:$dst),
4121 (implicit EFLAGS)),
4122 (ADD8mi addr:$dst, imm:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00004123def : Pat<(parallel (store (X86add_flag (loadi16 addr:$dst), imm:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004124 addr:$dst),
4125 (implicit EFLAGS)),
4126 (ADD16mi addr:$dst, imm:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00004127def : Pat<(parallel (store (X86add_flag (loadi32 addr:$dst), imm:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004128 addr:$dst),
4129 (implicit EFLAGS)),
4130 (ADD32mi addr:$dst, imm:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00004131def : Pat<(parallel (store (X86add_flag (loadi16 addr:$dst), i16immSExt8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004132 addr:$dst),
4133 (implicit EFLAGS)),
4134 (ADD16mi8 addr:$dst, i16immSExt8:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00004135def : Pat<(parallel (store (X86add_flag (loadi32 addr:$dst), i32immSExt8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004136 addr:$dst),
4137 (implicit EFLAGS)),
4138 (ADD32mi8 addr:$dst, i32immSExt8:$src2)>;
4139
Dan Gohman99a12192009-03-04 19:44:21 +00004140// Register-Register Subtraction with EFLAGS result
4141def : Pat<(parallel (X86sub_flag GR8:$src1, GR8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004142 (implicit EFLAGS)),
4143 (SUB8rr GR8:$src1, GR8:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00004144def : Pat<(parallel (X86sub_flag GR16:$src1, GR16:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004145 (implicit EFLAGS)),
4146 (SUB16rr GR16:$src1, GR16:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00004147def : Pat<(parallel (X86sub_flag GR32:$src1, GR32:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004148 (implicit EFLAGS)),
4149 (SUB32rr GR32:$src1, GR32:$src2)>;
4150
Dan Gohman99a12192009-03-04 19:44:21 +00004151// Register-Memory Subtraction with EFLAGS result
4152def : Pat<(parallel (X86sub_flag GR8:$src1, (loadi8 addr:$src2)),
Bill Wendlingf5399032008-12-12 21:15:41 +00004153 (implicit EFLAGS)),
4154 (SUB8rm GR8:$src1, addr:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00004155def : Pat<(parallel (X86sub_flag GR16:$src1, (loadi16 addr:$src2)),
Bill Wendlingf5399032008-12-12 21:15:41 +00004156 (implicit EFLAGS)),
4157 (SUB16rm GR16:$src1, addr:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00004158def : Pat<(parallel (X86sub_flag GR32:$src1, (loadi32 addr:$src2)),
Bill Wendlingf5399032008-12-12 21:15:41 +00004159 (implicit EFLAGS)),
4160 (SUB32rm GR32:$src1, addr:$src2)>;
4161
Dan Gohman99a12192009-03-04 19:44:21 +00004162// Register-Integer Subtraction with EFLAGS result
4163def : Pat<(parallel (X86sub_flag GR8:$src1, imm:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004164 (implicit EFLAGS)),
4165 (SUB8ri GR8:$src1, imm:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00004166def : Pat<(parallel (X86sub_flag GR16:$src1, imm:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004167 (implicit EFLAGS)),
4168 (SUB16ri GR16:$src1, imm:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00004169def : Pat<(parallel (X86sub_flag GR32:$src1, imm:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004170 (implicit EFLAGS)),
4171 (SUB32ri GR32:$src1, imm:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00004172def : Pat<(parallel (X86sub_flag GR16:$src1, i16immSExt8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004173 (implicit EFLAGS)),
4174 (SUB16ri8 GR16:$src1, i16immSExt8:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00004175def : Pat<(parallel (X86sub_flag GR32:$src1, i32immSExt8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004176 (implicit EFLAGS)),
4177 (SUB32ri8 GR32:$src1, i32immSExt8:$src2)>;
4178
Dan Gohman99a12192009-03-04 19:44:21 +00004179// Memory-Register Subtraction with EFLAGS result
4180def : Pat<(parallel (store (X86sub_flag (loadi8 addr:$dst), GR8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004181 addr:$dst),
4182 (implicit EFLAGS)),
4183 (SUB8mr addr:$dst, GR8:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00004184def : Pat<(parallel (store (X86sub_flag (loadi16 addr:$dst), GR16:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004185 addr:$dst),
4186 (implicit EFLAGS)),
4187 (SUB16mr addr:$dst, GR16:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00004188def : Pat<(parallel (store (X86sub_flag (loadi32 addr:$dst), GR32:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004189 addr:$dst),
4190 (implicit EFLAGS)),
4191 (SUB32mr addr:$dst, GR32:$src2)>;
4192
Dan Gohman99a12192009-03-04 19:44:21 +00004193// Memory-Integer Subtraction with EFLAGS result
4194def : Pat<(parallel (store (X86sub_flag (loadi8 addr:$dst), imm:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004195 addr:$dst),
4196 (implicit EFLAGS)),
4197 (SUB8mi addr:$dst, imm:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00004198def : Pat<(parallel (store (X86sub_flag (loadi16 addr:$dst), imm:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004199 addr:$dst),
4200 (implicit EFLAGS)),
4201 (SUB16mi addr:$dst, imm:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00004202def : Pat<(parallel (store (X86sub_flag (loadi32 addr:$dst), imm:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004203 addr:$dst),
4204 (implicit EFLAGS)),
4205 (SUB32mi addr:$dst, imm:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00004206def : Pat<(parallel (store (X86sub_flag (loadi16 addr:$dst), i16immSExt8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004207 addr:$dst),
4208 (implicit EFLAGS)),
4209 (SUB16mi8 addr:$dst, i16immSExt8:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00004210def : Pat<(parallel (store (X86sub_flag (loadi32 addr:$dst), i32immSExt8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004211 addr:$dst),
4212 (implicit EFLAGS)),
4213 (SUB32mi8 addr:$dst, i32immSExt8:$src2)>;
4214
4215
Dan Gohman99a12192009-03-04 19:44:21 +00004216// Register-Register Signed Integer Multiply with EFLAGS result
4217def : Pat<(parallel (X86smul_flag GR16:$src1, GR16:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004218 (implicit EFLAGS)),
4219 (IMUL16rr GR16:$src1, GR16:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00004220def : Pat<(parallel (X86smul_flag GR32:$src1, GR32:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004221 (implicit EFLAGS)),
4222 (IMUL32rr GR32:$src1, GR32:$src2)>;
4223
Dan Gohman99a12192009-03-04 19:44:21 +00004224// Register-Memory Signed Integer Multiply with EFLAGS result
4225def : Pat<(parallel (X86smul_flag GR16:$src1, (loadi16 addr:$src2)),
Bill Wendlingf5399032008-12-12 21:15:41 +00004226 (implicit EFLAGS)),
4227 (IMUL16rm GR16:$src1, addr:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00004228def : Pat<(parallel (X86smul_flag GR32:$src1, (loadi32 addr:$src2)),
Bill Wendlingf5399032008-12-12 21:15:41 +00004229 (implicit EFLAGS)),
4230 (IMUL32rm GR32:$src1, addr:$src2)>;
4231
Dan Gohman99a12192009-03-04 19:44:21 +00004232// Register-Integer Signed Integer Multiply with EFLAGS result
4233def : Pat<(parallel (X86smul_flag GR16:$src1, imm:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004234 (implicit EFLAGS)),
4235 (IMUL16rri GR16:$src1, imm:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00004236def : Pat<(parallel (X86smul_flag GR32:$src1, imm:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004237 (implicit EFLAGS)),
4238 (IMUL32rri GR32:$src1, imm:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00004239def : Pat<(parallel (X86smul_flag GR16:$src1, i16immSExt8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004240 (implicit EFLAGS)),
4241 (IMUL16rri8 GR16:$src1, i16immSExt8:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00004242def : Pat<(parallel (X86smul_flag GR32:$src1, i32immSExt8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004243 (implicit EFLAGS)),
4244 (IMUL32rri8 GR32:$src1, i32immSExt8:$src2)>;
4245
Dan Gohman99a12192009-03-04 19:44:21 +00004246// Memory-Integer Signed Integer Multiply with EFLAGS result
4247def : Pat<(parallel (X86smul_flag (loadi16 addr:$src1), imm:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004248 (implicit EFLAGS)),
4249 (IMUL16rmi addr:$src1, imm:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00004250def : Pat<(parallel (X86smul_flag (loadi32 addr:$src1), imm:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004251 (implicit EFLAGS)),
4252 (IMUL32rmi addr:$src1, imm:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00004253def : Pat<(parallel (X86smul_flag (loadi16 addr:$src1), i16immSExt8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004254 (implicit EFLAGS)),
4255 (IMUL16rmi8 addr:$src1, i16immSExt8:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00004256def : Pat<(parallel (X86smul_flag (loadi32 addr:$src1), i32immSExt8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004257 (implicit EFLAGS)),
4258 (IMUL32rmi8 addr:$src1, i32immSExt8:$src2)>;
4259
Dan Gohman99a12192009-03-04 19:44:21 +00004260// Optimize multiply by 2 with EFLAGS result.
Evan Cheng00cf7932009-01-27 03:30:42 +00004261let AddedComplexity = 2 in {
Dan Gohman99a12192009-03-04 19:44:21 +00004262def : Pat<(parallel (X86smul_flag GR16:$src1, 2),
Evan Cheng00cf7932009-01-27 03:30:42 +00004263 (implicit EFLAGS)),
4264 (ADD16rr GR16:$src1, GR16:$src1)>;
4265
Dan Gohman99a12192009-03-04 19:44:21 +00004266def : Pat<(parallel (X86smul_flag GR32:$src1, 2),
Evan Cheng00cf7932009-01-27 03:30:42 +00004267 (implicit EFLAGS)),
4268 (ADD32rr GR32:$src1, GR32:$src1)>;
4269}
4270
Dan Gohman99a12192009-03-04 19:44:21 +00004271// INC and DEC with EFLAGS result. Note that these do not set CF.
4272def : Pat<(parallel (X86inc_flag GR8:$src), (implicit EFLAGS)),
4273 (INC8r GR8:$src)>;
4274def : Pat<(parallel (store (i8 (X86inc_flag (loadi8 addr:$dst))), addr:$dst),
4275 (implicit EFLAGS)),
4276 (INC8m addr:$dst)>;
4277def : Pat<(parallel (X86dec_flag GR8:$src), (implicit EFLAGS)),
4278 (DEC8r GR8:$src)>;
4279def : Pat<(parallel (store (i8 (X86dec_flag (loadi8 addr:$dst))), addr:$dst),
4280 (implicit EFLAGS)),
4281 (DEC8m addr:$dst)>;
4282
4283def : Pat<(parallel (X86inc_flag GR16:$src), (implicit EFLAGS)),
Dan Gohmaneebcac72009-03-05 21:32:23 +00004284 (INC16r GR16:$src)>, Requires<[In32BitMode]>;
Dan Gohman99a12192009-03-04 19:44:21 +00004285def : Pat<(parallel (store (i16 (X86inc_flag (loadi16 addr:$dst))), addr:$dst),
4286 (implicit EFLAGS)),
Dan Gohmaneebcac72009-03-05 21:32:23 +00004287 (INC16m addr:$dst)>, Requires<[In32BitMode]>;
Dan Gohman99a12192009-03-04 19:44:21 +00004288def : Pat<(parallel (X86dec_flag GR16:$src), (implicit EFLAGS)),
Dan Gohmaneebcac72009-03-05 21:32:23 +00004289 (DEC16r GR16:$src)>, Requires<[In32BitMode]>;
Dan Gohman99a12192009-03-04 19:44:21 +00004290def : Pat<(parallel (store (i16 (X86dec_flag (loadi16 addr:$dst))), addr:$dst),
4291 (implicit EFLAGS)),
Dan Gohmaneebcac72009-03-05 21:32:23 +00004292 (DEC16m addr:$dst)>, Requires<[In32BitMode]>;
Dan Gohman99a12192009-03-04 19:44:21 +00004293
4294def : Pat<(parallel (X86inc_flag GR32:$src), (implicit EFLAGS)),
Dan Gohmaneebcac72009-03-05 21:32:23 +00004295 (INC32r GR32:$src)>, Requires<[In32BitMode]>;
Dan Gohman99a12192009-03-04 19:44:21 +00004296def : Pat<(parallel (store (i32 (X86inc_flag (loadi32 addr:$dst))), addr:$dst),
4297 (implicit EFLAGS)),
Dan Gohmaneebcac72009-03-05 21:32:23 +00004298 (INC32m addr:$dst)>, Requires<[In32BitMode]>;
Dan Gohman99a12192009-03-04 19:44:21 +00004299def : Pat<(parallel (X86dec_flag GR32:$src), (implicit EFLAGS)),
Dan Gohmaneebcac72009-03-05 21:32:23 +00004300 (DEC32r GR32:$src)>, Requires<[In32BitMode]>;
Dan Gohman99a12192009-03-04 19:44:21 +00004301def : Pat<(parallel (store (i32 (X86dec_flag (loadi32 addr:$dst))), addr:$dst),
4302 (implicit EFLAGS)),
Dan Gohmaneebcac72009-03-05 21:32:23 +00004303 (DEC32m addr:$dst)>, Requires<[In32BitMode]>;
Dan Gohman99a12192009-03-04 19:44:21 +00004304
Dan Gohmane84197b2009-09-03 17:18:51 +00004305// -disable-16bit support.
4306def : Pat<(truncstorei16 (i32 imm:$src), addr:$dst),
4307 (MOV16mi addr:$dst, imm:$src)>;
4308def : Pat<(truncstorei16 GR32:$src, addr:$dst),
4309 (MOV16mr addr:$dst, (EXTRACT_SUBREG GR32:$src, x86_subreg_16bit))>;
4310def : Pat<(i32 (sextloadi16 addr:$dst)),
4311 (MOVSX32rm16 addr:$dst)>;
4312def : Pat<(i32 (zextloadi16 addr:$dst)),
4313 (MOVZX32rm16 addr:$dst)>;
4314def : Pat<(i32 (extloadi16 addr:$dst)),
4315 (MOVZX32rm16 addr:$dst)>;
4316
Bill Wendlingf5399032008-12-12 21:15:41 +00004317//===----------------------------------------------------------------------===//
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004318// Floating Point Stack Support
4319//===----------------------------------------------------------------------===//
4320
4321include "X86InstrFPStack.td"
4322
4323//===----------------------------------------------------------------------===//
Evan Cheng86ab7d32007-07-31 08:04:03 +00004324// X86-64 Support
4325//===----------------------------------------------------------------------===//
4326
Chris Lattner2de8d2b2008-01-10 05:50:42 +00004327include "X86Instr64bit.td"
Evan Cheng86ab7d32007-07-31 08:04:03 +00004328
4329//===----------------------------------------------------------------------===//
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004330// XMM Floating point support (requires SSE / SSE2)
4331//===----------------------------------------------------------------------===//
4332
4333include "X86InstrSSE.td"
Evan Cheng5e4d1e72008-04-25 18:19:54 +00004334
4335//===----------------------------------------------------------------------===//
4336// MMX and XMM Packed Integer support (requires MMX, SSE, and SSE2)
4337//===----------------------------------------------------------------------===//
4338
4339include "X86InstrMMX.td"