blob: e310e646e7efdc3bb702940672b6cad11729d222 [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
697// Tail call stuff.
Arnold Schwaighofere2d6bbb2007-10-11 19:40:01 +0000698
Evan Cheng37e7c752007-07-21 00:34:19 +0000699let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1 in
Arnold Schwaighofer6fd37ac2008-03-19 16:39:45 +0000700def TCRETURNdi : I<0, Pseudo, (outs), (ins i32imm:$dst, i32imm:$offset, variable_ops),
Arnold Schwaighofere2d6bbb2007-10-11 19:40:01 +0000701 "#TC_RETURN $dst $offset",
702 []>;
703
704let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1 in
Arnold Schwaighofer6fd37ac2008-03-19 16:39:45 +0000705def TCRETURNri : I<0, Pseudo, (outs), (ins GR32:$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 Schwaighofera0032722008-04-30 09:16:33 +0000710
Chris Lattner357a0ca2009-06-20 19:34:09 +0000711 def TAILJMPd : IBr<0xE9, (ins i32imm_pcrel:$dst), "jmp\t$dst # TAILCALL",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000712 []>;
Evan Cheng37e7c752007-07-21 00:34:19 +0000713let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1 in
Arnold Schwaighofere2d6bbb2007-10-11 19:40:01 +0000714 def TAILJMPr : I<0xFF, MRM4r, (outs), (ins GR32:$dst), "jmp{l}\t{*}$dst # TAILCALL",
715 []>;
Evan Cheng37e7c752007-07-21 00:34:19 +0000716let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +0000717 def TAILJMPm : I<0xFF, MRM4m, (outs), (ins i32mem:$dst),
Arnold Schwaighofere2d6bbb2007-10-11 19:40:01 +0000718 "jmp\t{*}$dst # TAILCALL", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000719
720//===----------------------------------------------------------------------===//
721// Miscellaneous Instructions...
722//
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000723let Defs = [EBP, ESP], Uses = [EBP, ESP], mayLoad = 1, neverHasSideEffects=1 in
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000724def LEAVE : I<0xC9, RawFrm,
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000725 (outs), (ins), "leave", []>;
726
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000727let Defs = [ESP], Uses = [ESP], neverHasSideEffects=1 in {
Sean Callanan9f3c3f52009-09-10 18:29:13 +0000728let mayLoad = 1 in {
729def POP16r : I<0x58, AddRegFrm, (outs GR16:$reg), (ins), "pop{w}\t$reg", []>,
730 OpSize;
731def POP32r : I<0x58, AddRegFrm, (outs GR32:$reg), (ins), "pop{l}\t$reg", []>;
732def POP16rmr: I<0x8F, MRM0r, (outs GR16:$reg), (ins), "pop{w}\t$reg", []>,
733 OpSize;
734def POP16rmm: I<0x8F, MRM0m, (outs i16mem:$dst), (ins), "pop{w}\t$dst", []>,
735 OpSize;
736def POP32rmr: I<0x8F, MRM0r, (outs GR32:$reg), (ins), "pop{l}\t$reg", []>;
737def POP32rmm: I<0x8F, MRM0m, (outs i32mem:$dst), (ins), "pop{l}\t$dst", []>;
738}
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000739
Sean Callanan9f3c3f52009-09-10 18:29:13 +0000740let mayStore = 1 in {
741def PUSH16r : I<0x50, AddRegFrm, (outs), (ins GR16:$reg), "push{w}\t$reg",[]>,
742 OpSize;
Evan Chengd8434332007-09-26 01:29:06 +0000743def PUSH32r : I<0x50, AddRegFrm, (outs), (ins GR32:$reg), "push{l}\t$reg",[]>;
Sean Callanan9f3c3f52009-09-10 18:29:13 +0000744def PUSH16rmr: I<0xFF, MRM6r, (outs), (ins GR16:$reg), "push{w}\t$reg",[]>,
745 OpSize;
746def PUSH16rmm: I<0xFF, MRM6m, (outs), (ins i16mem:$src), "push{w}\t$src",[]>,
747 OpSize;
748def PUSH32rmr: I<0xFF, MRM6r, (outs), (ins GR32:$reg), "push{l}\t$reg",[]>;
749def PUSH32rmm: I<0xFF, MRM6m, (outs), (ins i32mem:$src), "push{l}\t$src",[]>;
750}
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000751}
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000752
Bill Wendling4c2638c2009-06-15 19:39:04 +0000753let Defs = [ESP], Uses = [ESP], neverHasSideEffects = 1, mayStore = 1 in {
754def PUSH32i8 : Ii8<0x6a, RawFrm, (outs), (ins i8imm:$imm),
Bill Wendling0b0437f2009-06-15 20:59:31 +0000755 "push{l}\t$imm", []>;
Bill Wendling4c2638c2009-06-15 19:39:04 +0000756def PUSH32i16 : Ii16<0x68, RawFrm, (outs), (ins i16imm:$imm),
Bill Wendling0b0437f2009-06-15 20:59:31 +0000757 "push{l}\t$imm", []>;
Bill Wendling4c2638c2009-06-15 19:39:04 +0000758def PUSH32i32 : Ii32<0x68, RawFrm, (outs), (ins i32imm:$imm),
Bill Wendling0b0437f2009-06-15 20:59:31 +0000759 "push{l}\t$imm", []>;
Bill Wendling4c2638c2009-06-15 19:39:04 +0000760}
761
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000762let Defs = [ESP, EFLAGS], Uses = [ESP], mayLoad = 1, neverHasSideEffects=1 in
Evan Chengf1341312007-09-26 21:28:00 +0000763def POPFD : I<0x9D, RawFrm, (outs), (ins), "popf", []>;
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000764let Defs = [ESP], Uses = [ESP, EFLAGS], mayStore = 1, neverHasSideEffects=1 in
Evan Chengf1341312007-09-26 21:28:00 +0000765def PUSHFD : I<0x9C, RawFrm, (outs), (ins), "pushf", []>;
Evan Chengd8434332007-09-26 01:29:06 +0000766
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000767let isTwoAddress = 1 in // GR32 = bswap GR32
768 def BSWAP32r : I<0xC8, AddRegFrm,
Evan Chengb783fa32007-07-19 01:14:50 +0000769 (outs GR32:$dst), (ins GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000770 "bswap{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000771 [(set GR32:$dst, (bswap GR32:$src))]>, TB;
772
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000773
Evan Cheng48679f42007-12-14 02:13:44 +0000774// Bit scan instructions.
775let Defs = [EFLAGS] in {
Evan Cheng4e33de92007-12-14 18:49:43 +0000776def BSF16rr : I<0xBC, MRMSrcReg, (outs GR16:$dst), (ins GR16:$src),
Dan Gohmancdb54c62007-12-14 15:10:00 +0000777 "bsf{w}\t{$src, $dst|$dst, $src}",
Evan Cheng7cfbfe32007-12-14 08:30:15 +0000778 [(set GR16:$dst, (X86bsf GR16:$src)), (implicit EFLAGS)]>, TB;
Evan Cheng48679f42007-12-14 02:13:44 +0000779def BSF16rm : I<0xBC, MRMSrcMem, (outs GR16:$dst), (ins i16mem:$src),
Dan Gohmancdb54c62007-12-14 15:10:00 +0000780 "bsf{w}\t{$src, $dst|$dst, $src}",
Evan Cheng7cfbfe32007-12-14 08:30:15 +0000781 [(set GR16:$dst, (X86bsf (loadi16 addr:$src))),
782 (implicit EFLAGS)]>, TB;
Evan Cheng4e33de92007-12-14 18:49:43 +0000783def BSF32rr : I<0xBC, MRMSrcReg, (outs GR32:$dst), (ins GR32:$src),
Dan Gohmancdb54c62007-12-14 15:10:00 +0000784 "bsf{l}\t{$src, $dst|$dst, $src}",
Evan Cheng7cfbfe32007-12-14 08:30:15 +0000785 [(set GR32:$dst, (X86bsf GR32:$src)), (implicit EFLAGS)]>, TB;
Evan Cheng48679f42007-12-14 02:13:44 +0000786def BSF32rm : I<0xBC, MRMSrcMem, (outs GR32:$dst), (ins i32mem:$src),
Dan Gohmancdb54c62007-12-14 15:10:00 +0000787 "bsf{l}\t{$src, $dst|$dst, $src}",
Evan Cheng7cfbfe32007-12-14 08:30:15 +0000788 [(set GR32:$dst, (X86bsf (loadi32 addr:$src))),
789 (implicit EFLAGS)]>, TB;
Evan Cheng48679f42007-12-14 02:13:44 +0000790
Evan Cheng4e33de92007-12-14 18:49:43 +0000791def BSR16rr : I<0xBD, MRMSrcReg, (outs GR16:$dst), (ins GR16:$src),
Dan Gohmancdb54c62007-12-14 15:10:00 +0000792 "bsr{w}\t{$src, $dst|$dst, $src}",
Evan Cheng7cfbfe32007-12-14 08:30:15 +0000793 [(set GR16:$dst, (X86bsr GR16:$src)), (implicit EFLAGS)]>, TB;
Evan Cheng48679f42007-12-14 02:13:44 +0000794def BSR16rm : I<0xBD, MRMSrcMem, (outs GR16:$dst), (ins i16mem:$src),
Dan Gohmancdb54c62007-12-14 15:10:00 +0000795 "bsr{w}\t{$src, $dst|$dst, $src}",
Evan Cheng7cfbfe32007-12-14 08:30:15 +0000796 [(set GR16:$dst, (X86bsr (loadi16 addr:$src))),
797 (implicit EFLAGS)]>, TB;
Evan Cheng4e33de92007-12-14 18:49:43 +0000798def BSR32rr : I<0xBD, MRMSrcReg, (outs GR32:$dst), (ins GR32:$src),
Dan Gohmancdb54c62007-12-14 15:10:00 +0000799 "bsr{l}\t{$src, $dst|$dst, $src}",
Evan Cheng7cfbfe32007-12-14 08:30:15 +0000800 [(set GR32:$dst, (X86bsr GR32:$src)), (implicit EFLAGS)]>, TB;
Evan Cheng48679f42007-12-14 02:13:44 +0000801def BSR32rm : I<0xBD, MRMSrcMem, (outs GR32:$dst), (ins i32mem:$src),
Dan Gohmancdb54c62007-12-14 15:10:00 +0000802 "bsr{l}\t{$src, $dst|$dst, $src}",
Evan Cheng7cfbfe32007-12-14 08:30:15 +0000803 [(set GR32:$dst, (X86bsr (loadi32 addr:$src))),
804 (implicit EFLAGS)]>, TB;
Evan Cheng48679f42007-12-14 02:13:44 +0000805} // Defs = [EFLAGS]
806
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000807let neverHasSideEffects = 1 in
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000808def LEA16r : I<0x8D, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +0000809 (outs GR16:$dst), (ins i32mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000810 "lea{w}\t{$src|$dst}, {$dst|$src}", []>, OpSize;
Evan Cheng1ea8e6b2008-03-27 01:41:09 +0000811let isReMaterializable = 1 in
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000812def LEA32r : I<0x8D, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +0000813 (outs GR32:$dst), (ins lea32mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000814 "lea{l}\t{$src|$dst}, {$dst|$src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000815 [(set GR32:$dst, lea32addr:$src)]>, Requires<[In32BitMode]>;
816
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000817let Defs = [ECX,EDI,ESI], Uses = [ECX,EDI,ESI] in {
Evan Chengb783fa32007-07-19 01:14:50 +0000818def REP_MOVSB : I<0xA4, RawFrm, (outs), (ins), "{rep;movsb|rep movsb}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000819 [(X86rep_movs i8)]>, REP;
Evan Chengb783fa32007-07-19 01:14:50 +0000820def REP_MOVSW : I<0xA5, RawFrm, (outs), (ins), "{rep;movsw|rep movsw}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000821 [(X86rep_movs i16)]>, REP, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +0000822def REP_MOVSD : I<0xA5, RawFrm, (outs), (ins), "{rep;movsl|rep movsd}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000823 [(X86rep_movs i32)]>, REP;
824}
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000825
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000826let Defs = [ECX,EDI], Uses = [AL,ECX,EDI] in
Evan Chengb783fa32007-07-19 01:14:50 +0000827def REP_STOSB : I<0xAA, RawFrm, (outs), (ins), "{rep;stosb|rep stosb}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000828 [(X86rep_stos i8)]>, REP;
829let Defs = [ECX,EDI], Uses = [AX,ECX,EDI] in
Evan Chengb783fa32007-07-19 01:14:50 +0000830def REP_STOSW : I<0xAB, RawFrm, (outs), (ins), "{rep;stosw|rep stosw}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000831 [(X86rep_stos i16)]>, REP, OpSize;
832let Defs = [ECX,EDI], Uses = [EAX,ECX,EDI] in
Evan Chengb783fa32007-07-19 01:14:50 +0000833def REP_STOSD : I<0xAB, RawFrm, (outs), (ins), "{rep;stosl|rep stosd}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000834 [(X86rep_stos i32)]>, REP;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000835
Sean Callanan481f06d2009-09-12 00:37:19 +0000836def SCAS8 : I<0xAE, RawFrm, (outs), (ins), "scas{b}", []>;
837def SCAS16 : I<0xAF, RawFrm, (outs), (ins), "scas{w}", []>, OpSize;
838def SCAS32 : I<0xAF, RawFrm, (outs), (ins), "scas{l}", []>;
839
Sean Callanan25220d62009-09-12 02:25:20 +0000840def CMPS8 : I<0xA6, RawFrm, (outs), (ins), "cmps{b}", []>;
841def CMPS16 : I<0xA7, RawFrm, (outs), (ins), "cmps{w}", []>, OpSize;
842def CMPS32 : I<0xA7, RawFrm, (outs), (ins), "cmps{l}", []>;
843
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000844let Defs = [RAX, RDX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000845def RDTSC : I<0x31, RawFrm, (outs), (ins), "rdtsc", [(X86rdtsc)]>,
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000846 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000847
Anton Korobeynikov39d40ba2008-01-15 07:02:33 +0000848let isBarrier = 1, hasCtrlDep = 1 in {
Chris Lattner56b941f2008-01-15 21:58:22 +0000849def TRAP : I<0x0B, RawFrm, (outs), (ins), "ud2", [(trap)]>, TB;
Anton Korobeynikov39d40ba2008-01-15 07:02:33 +0000850}
851
Chris Lattnerc96e27c2009-08-11 16:58:39 +0000852def SYSCALL : I<0x05, RawFrm,
853 (outs), (ins), "syscall", []>, TB;
854def SYSRET : I<0x07, RawFrm,
855 (outs), (ins), "sysret", []>, TB;
856def SYSENTER : I<0x34, RawFrm,
857 (outs), (ins), "sysenter", []>, TB;
858def SYSEXIT : I<0x35, RawFrm,
859 (outs), (ins), "sysexit", []>, TB;
860
Sean Callanan2c2313a2009-09-12 02:52:41 +0000861def WAIT : I<0x9B, RawFrm, (outs), (ins), "wait", []>;
Chris Lattnerc96e27c2009-08-11 16:58:39 +0000862
863
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000864//===----------------------------------------------------------------------===//
865// Input/Output Instructions...
866//
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000867let Defs = [AL], Uses = [DX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000868def IN8rr : I<0xEC, RawFrm, (outs), (ins),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000869 "in{b}\t{%dx, %al|%AL, %DX}", []>;
870let Defs = [AX], Uses = [DX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000871def IN16rr : I<0xED, RawFrm, (outs), (ins),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000872 "in{w}\t{%dx, %ax|%AX, %DX}", []>, OpSize;
873let Defs = [EAX], Uses = [DX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000874def IN32rr : I<0xED, RawFrm, (outs), (ins),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000875 "in{l}\t{%dx, %eax|%EAX, %DX}", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000876
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000877let Defs = [AL] in
Evan Chengb783fa32007-07-19 01:14:50 +0000878def IN8ri : Ii8<0xE4, RawFrm, (outs), (ins i16i8imm:$port),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000879 "in{b}\t{$port, %al|%AL, $port}", []>;
880let Defs = [AX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000881def IN16ri : Ii8<0xE5, RawFrm, (outs), (ins i16i8imm:$port),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000882 "in{w}\t{$port, %ax|%AX, $port}", []>, OpSize;
883let Defs = [EAX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000884def IN32ri : Ii8<0xE5, RawFrm, (outs), (ins i16i8imm:$port),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000885 "in{l}\t{$port, %eax|%EAX, $port}", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000886
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000887let Uses = [DX, AL] in
Evan Chengb783fa32007-07-19 01:14:50 +0000888def OUT8rr : I<0xEE, RawFrm, (outs), (ins),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000889 "out{b}\t{%al, %dx|%DX, %AL}", []>;
890let Uses = [DX, AX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000891def OUT16rr : I<0xEF, RawFrm, (outs), (ins),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000892 "out{w}\t{%ax, %dx|%DX, %AX}", []>, OpSize;
893let Uses = [DX, EAX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000894def OUT32rr : I<0xEF, RawFrm, (outs), (ins),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000895 "out{l}\t{%eax, %dx|%DX, %EAX}", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000896
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000897let Uses = [AL] in
Evan Chengb783fa32007-07-19 01:14:50 +0000898def OUT8ir : Ii8<0xE6, RawFrm, (outs), (ins i16i8imm:$port),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000899 "out{b}\t{%al, $port|$port, %AL}", []>;
900let Uses = [AX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000901def OUT16ir : Ii8<0xE7, RawFrm, (outs), (ins i16i8imm:$port),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000902 "out{w}\t{%ax, $port|$port, %AX}", []>, OpSize;
903let Uses = [EAX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000904def OUT32ir : Ii8<0xE7, RawFrm, (outs), (ins i16i8imm:$port),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000905 "out{l}\t{%eax, $port|$port, %EAX}", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000906
907//===----------------------------------------------------------------------===//
908// Move Instructions...
909//
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000910let neverHasSideEffects = 1 in {
Evan Chengb783fa32007-07-19 01:14:50 +0000911def MOV8rr : I<0x88, MRMDestReg, (outs GR8 :$dst), (ins GR8 :$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000912 "mov{b}\t{$src, $dst|$dst, $src}", []>;
Evan Chengb783fa32007-07-19 01:14:50 +0000913def MOV16rr : I<0x89, MRMDestReg, (outs GR16:$dst), (ins GR16:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000914 "mov{w}\t{$src, $dst|$dst, $src}", []>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +0000915def MOV32rr : I<0x89, MRMDestReg, (outs GR32:$dst), (ins GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000916 "mov{l}\t{$src, $dst|$dst, $src}", []>;
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000917}
Evan Cheng6f26e8b2008-06-18 08:13:07 +0000918let isReMaterializable = 1, isAsCheapAsAMove = 1 in {
Evan Chengb783fa32007-07-19 01:14:50 +0000919def MOV8ri : Ii8 <0xB0, AddRegFrm, (outs GR8 :$dst), (ins i8imm :$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000920 "mov{b}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000921 [(set GR8:$dst, imm:$src)]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000922def MOV16ri : Ii16<0xB8, AddRegFrm, (outs GR16:$dst), (ins i16imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000923 "mov{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000924 [(set GR16:$dst, imm:$src)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +0000925def MOV32ri : Ii32<0xB8, AddRegFrm, (outs GR32:$dst), (ins i32imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000926 "mov{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000927 [(set GR32:$dst, imm:$src)]>;
928}
Evan Chengb783fa32007-07-19 01:14:50 +0000929def MOV8mi : Ii8 <0xC6, MRM0m, (outs), (ins i8mem :$dst, i8imm :$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000930 "mov{b}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000931 [(store (i8 imm:$src), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000932def MOV16mi : Ii16<0xC7, MRM0m, (outs), (ins i16mem:$dst, i16imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000933 "mov{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000934 [(store (i16 imm:$src), addr:$dst)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +0000935def MOV32mi : Ii32<0xC7, MRM0m, (outs), (ins i32mem:$dst, i32imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000936 "mov{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000937 [(store (i32 imm:$src), addr:$dst)]>;
938
Sean Callanan70953a52009-09-10 18:33:42 +0000939def MOV8o8a : Ii8 <0xA0, RawFrm, (outs), (ins i8imm:$src),
940 "mov{b}\t{$src, %al|%al, $src}", []>;
941def MOV16o16a : Ii16 <0xA1, RawFrm, (outs), (ins i16imm:$src),
942 "mov{w}\t{$src, %ax|%ax, $src}", []>, OpSize;
943def MOV32o32a : Ii32 <0xA1, RawFrm, (outs), (ins i32imm:$src),
944 "mov{l}\t{$src, %eax|%eax, $src}", []>;
945
946def MOV8ao8 : Ii8 <0xA2, RawFrm, (outs i8imm:$dst), (ins),
947 "mov{b}\t{%al, $dst|$dst, %al}", []>;
948def MOV16ao16 : Ii16 <0xA3, RawFrm, (outs i16imm:$dst), (ins),
949 "mov{w}\t{%ax, $dst|$dst, %ax}", []>, OpSize;
950def MOV32ao32 : Ii32 <0xA3, RawFrm, (outs i32imm:$dst), (ins),
951 "mov{l}\t{%eax, $dst|$dst, %eax}", []>;
952
Sean Callananad87a3a2009-09-15 18:47:29 +0000953// Moves to and from segment registers
954def MOV16rs : I<0x8C, MRMDestReg, (outs GR16:$dst), (ins SEGMENT_REG:$src),
955 "mov{w}\t{$src, $dst|$dst, $src}", []>;
956def MOV16ms : I<0x8C, MRMDestMem, (outs i16mem:$dst), (ins SEGMENT_REG:$src),
957 "mov{w}\t{$src, $dst|$dst, $src}", []>;
958def MOV16sr : I<0x8E, MRMSrcReg, (outs SEGMENT_REG:$dst), (ins GR16:$src),
959 "mov{w}\t{$src, $dst|$dst, $src}", []>;
960def MOV16sm : I<0x8E, MRMSrcMem, (outs SEGMENT_REG:$dst), (ins i16mem:$src),
961 "mov{w}\t{$src, $dst|$dst, $src}", []>;
962
Dan Gohman5574cc72008-12-03 18:15:48 +0000963let canFoldAsLoad = 1, isReMaterializable = 1, mayHaveSideEffects = 1 in {
Evan Chengb783fa32007-07-19 01:14:50 +0000964def MOV8rm : I<0x8A, MRMSrcMem, (outs GR8 :$dst), (ins i8mem :$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000965 "mov{b}\t{$src, $dst|$dst, $src}",
Chris Lattner12208612009-04-10 00:16:23 +0000966 [(set GR8:$dst, (loadi8 addr:$src))]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000967def MOV16rm : I<0x8B, MRMSrcMem, (outs GR16:$dst), (ins i16mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000968 "mov{w}\t{$src, $dst|$dst, $src}",
Chris Lattner12208612009-04-10 00:16:23 +0000969 [(set GR16:$dst, (loadi16 addr:$src))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +0000970def MOV32rm : I<0x8B, MRMSrcMem, (outs GR32:$dst), (ins i32mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000971 "mov{l}\t{$src, $dst|$dst, $src}",
Chris Lattner12208612009-04-10 00:16:23 +0000972 [(set GR32:$dst, (loadi32 addr:$src))]>;
Evan Cheng4e84e452007-08-30 05:49:43 +0000973}
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000974
Evan Chengb783fa32007-07-19 01:14:50 +0000975def MOV8mr : I<0x88, MRMDestMem, (outs), (ins i8mem :$dst, GR8 :$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000976 "mov{b}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000977 [(store GR8:$src, addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000978def MOV16mr : I<0x89, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000979 "mov{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000980 [(store GR16:$src, addr:$dst)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +0000981def MOV32mr : I<0x89, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000982 "mov{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000983 [(store GR32:$src, addr:$dst)]>;
Dan Gohman744d4622009-04-13 16:09:41 +0000984
Dan Gohman1d8ce9c2009-04-27 16:41:36 +0000985// Versions of MOV8rr, MOV8mr, and MOV8rm that use i8mem_NOREX and GR8_NOREX so
986// that they can be used for copying and storing h registers, which can't be
987// encoded when a REX prefix is present.
Dan Gohman2da0db32009-04-15 00:04:23 +0000988let neverHasSideEffects = 1 in
Dan Gohman40ddc362009-04-15 19:48:57 +0000989def MOV8rr_NOREX : I<0x88, MRMDestReg,
990 (outs GR8_NOREX:$dst), (ins GR8_NOREX:$src),
Dan Gohman2da0db32009-04-15 00:04:23 +0000991 "mov{b}\t{$src, $dst|$dst, $src} # NOREX", []>;
Evan Chengebc49402009-04-30 00:58:57 +0000992let mayStore = 1 in
Dan Gohman2da0db32009-04-15 00:04:23 +0000993def MOV8mr_NOREX : I<0x88, MRMDestMem,
994 (outs), (ins i8mem_NOREX:$dst, GR8_NOREX:$src),
995 "mov{b}\t{$src, $dst|$dst, $src} # NOREX", []>;
Evan Chengebc49402009-04-30 00:58:57 +0000996let mayLoad = 1,
997 canFoldAsLoad = 1, isReMaterializable = 1, mayHaveSideEffects = 1 in
Dan Gohman1d8ce9c2009-04-27 16:41:36 +0000998def MOV8rm_NOREX : I<0x8A, MRMSrcMem,
999 (outs GR8_NOREX:$dst), (ins i8mem_NOREX:$src),
1000 "mov{b}\t{$src, $dst|$dst, $src} # NOREX", []>;
Dan Gohman744d4622009-04-13 16:09:41 +00001001
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001002//===----------------------------------------------------------------------===//
1003// Fixed-Register Multiplication and Division Instructions...
1004//
1005
1006// Extra precision multiplication
Evan Cheng55687072007-09-14 21:48:26 +00001007let Defs = [AL,AH,EFLAGS], Uses = [AL] in
Dan Gohman91888f02007-07-31 20:11:57 +00001008def MUL8r : I<0xF6, MRM4r, (outs), (ins GR8:$src), "mul{b}\t$src",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001009 // FIXME: Used for 8-bit mul, ignore result upper 8 bits.
1010 // This probably ought to be moved to a def : Pat<> if the
1011 // syntax can be accepted.
Bill Wendlingf5399032008-12-12 21:15:41 +00001012 [(set AL, (mul AL, GR8:$src)),
1013 (implicit EFLAGS)]>; // AL,AH = AL*GR8
1014
Chris Lattnerc7e96e72008-01-11 07:18:17 +00001015let Defs = [AX,DX,EFLAGS], Uses = [AX], neverHasSideEffects = 1 in
Bill Wendlingf5399032008-12-12 21:15:41 +00001016def MUL16r : I<0xF7, MRM4r, (outs), (ins GR16:$src),
1017 "mul{w}\t$src",
1018 []>, OpSize; // AX,DX = AX*GR16
1019
Chris Lattnerc7e96e72008-01-11 07:18:17 +00001020let Defs = [EAX,EDX,EFLAGS], Uses = [EAX], neverHasSideEffects = 1 in
Bill Wendlingf5399032008-12-12 21:15:41 +00001021def MUL32r : I<0xF7, MRM4r, (outs), (ins GR32:$src),
1022 "mul{l}\t$src",
1023 []>; // EAX,EDX = EAX*GR32
1024
Evan Cheng55687072007-09-14 21:48:26 +00001025let Defs = [AL,AH,EFLAGS], Uses = [AL] in
Evan Chengb783fa32007-07-19 01:14:50 +00001026def MUL8m : I<0xF6, MRM4m, (outs), (ins i8mem :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001027 "mul{b}\t$src",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001028 // FIXME: Used for 8-bit mul, ignore result upper 8 bits.
1029 // This probably ought to be moved to a def : Pat<> if the
1030 // syntax can be accepted.
Bill Wendlingf5399032008-12-12 21:15:41 +00001031 [(set AL, (mul AL, (loadi8 addr:$src))),
1032 (implicit EFLAGS)]>; // AL,AH = AL*[mem8]
1033
Chris Lattnerc90ee9c2008-01-10 07:59:24 +00001034let mayLoad = 1, neverHasSideEffects = 1 in {
Evan Cheng55687072007-09-14 21:48:26 +00001035let Defs = [AX,DX,EFLAGS], Uses = [AX] in
Evan Chengb783fa32007-07-19 01:14:50 +00001036def MUL16m : I<0xF7, MRM4m, (outs), (ins i16mem:$src),
Bill Wendlingf5399032008-12-12 21:15:41 +00001037 "mul{w}\t$src",
1038 []>, OpSize; // AX,DX = AX*[mem16]
1039
Evan Cheng55687072007-09-14 21:48:26 +00001040let Defs = [EAX,EDX,EFLAGS], Uses = [EAX] in
Evan Chengb783fa32007-07-19 01:14:50 +00001041def MUL32m : I<0xF7, MRM4m, (outs), (ins i32mem:$src),
Bill Wendlingf5399032008-12-12 21:15:41 +00001042 "mul{l}\t$src",
1043 []>; // EAX,EDX = EAX*[mem32]
Chris Lattnerc90ee9c2008-01-10 07:59:24 +00001044}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001045
Chris Lattnerc90ee9c2008-01-10 07:59:24 +00001046let neverHasSideEffects = 1 in {
Evan Cheng55687072007-09-14 21:48:26 +00001047let Defs = [AL,AH,EFLAGS], Uses = [AL] in
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001048def IMUL8r : I<0xF6, MRM5r, (outs), (ins GR8:$src), "imul{b}\t$src", []>;
1049 // AL,AH = AL*GR8
Evan Cheng55687072007-09-14 21:48:26 +00001050let Defs = [AX,DX,EFLAGS], Uses = [AX] in
Dan Gohman91888f02007-07-31 20:11:57 +00001051def IMUL16r : I<0xF7, MRM5r, (outs), (ins GR16:$src), "imul{w}\t$src", []>,
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001052 OpSize; // AX,DX = AX*GR16
Evan Cheng55687072007-09-14 21:48:26 +00001053let Defs = [EAX,EDX,EFLAGS], Uses = [EAX] in
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001054def IMUL32r : I<0xF7, MRM5r, (outs), (ins GR32:$src), "imul{l}\t$src", []>;
1055 // EAX,EDX = EAX*GR32
Chris Lattnerc90ee9c2008-01-10 07:59:24 +00001056let mayLoad = 1 in {
Evan Cheng55687072007-09-14 21:48:26 +00001057let Defs = [AL,AH,EFLAGS], Uses = [AL] in
Evan Chengb783fa32007-07-19 01:14:50 +00001058def IMUL8m : I<0xF6, MRM5m, (outs), (ins i8mem :$src),
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001059 "imul{b}\t$src", []>; // AL,AH = AL*[mem8]
Evan Cheng55687072007-09-14 21:48:26 +00001060let Defs = [AX,DX,EFLAGS], Uses = [AX] in
Evan Chengb783fa32007-07-19 01:14:50 +00001061def IMUL16m : I<0xF7, MRM5m, (outs), (ins i16mem:$src),
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001062 "imul{w}\t$src", []>, OpSize; // AX,DX = AX*[mem16]
1063let Defs = [EAX,EDX], Uses = [EAX] in
Evan Chengb783fa32007-07-19 01:14:50 +00001064def IMUL32m : I<0xF7, MRM5m, (outs), (ins i32mem:$src),
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001065 "imul{l}\t$src", []>; // EAX,EDX = EAX*[mem32]
Chris Lattnerc90ee9c2008-01-10 07:59:24 +00001066}
Dan Gohmand44572d2008-11-18 21:29:14 +00001067} // neverHasSideEffects
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001068
1069// unsigned division/remainder
Dale Johannesend8fd3562008-10-07 18:54:28 +00001070let Defs = [AL,AH,EFLAGS], Uses = [AX] in
Evan Chengb783fa32007-07-19 01:14:50 +00001071def DIV8r : I<0xF6, MRM6r, (outs), (ins GR8:$src), // AX/r8 = AL,AH
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001072 "div{b}\t$src", []>;
Evan Cheng55687072007-09-14 21:48:26 +00001073let Defs = [AX,DX,EFLAGS], Uses = [AX,DX] in
Evan Chengb783fa32007-07-19 01:14:50 +00001074def DIV16r : I<0xF7, MRM6r, (outs), (ins GR16:$src), // DX:AX/r16 = AX,DX
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001075 "div{w}\t$src", []>, OpSize;
Evan Cheng55687072007-09-14 21:48:26 +00001076let Defs = [EAX,EDX,EFLAGS], Uses = [EAX,EDX] in
Evan Chengb783fa32007-07-19 01:14:50 +00001077def DIV32r : I<0xF7, MRM6r, (outs), (ins GR32:$src), // EDX:EAX/r32 = EAX,EDX
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001078 "div{l}\t$src", []>;
Chris Lattnerc90ee9c2008-01-10 07:59:24 +00001079let mayLoad = 1 in {
Dale Johannesend8fd3562008-10-07 18:54:28 +00001080let Defs = [AL,AH,EFLAGS], Uses = [AX] in
Evan Chengb783fa32007-07-19 01:14:50 +00001081def DIV8m : I<0xF6, MRM6m, (outs), (ins i8mem:$src), // AX/[mem8] = AL,AH
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001082 "div{b}\t$src", []>;
Evan Cheng55687072007-09-14 21:48:26 +00001083let Defs = [AX,DX,EFLAGS], Uses = [AX,DX] in
Evan Chengb783fa32007-07-19 01:14:50 +00001084def DIV16m : I<0xF7, MRM6m, (outs), (ins i16mem:$src), // DX:AX/[mem16] = AX,DX
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001085 "div{w}\t$src", []>, OpSize;
Evan Cheng55687072007-09-14 21:48:26 +00001086let Defs = [EAX,EDX,EFLAGS], Uses = [EAX,EDX] in
Evan Chengb783fa32007-07-19 01:14:50 +00001087def DIV32m : I<0xF7, MRM6m, (outs), (ins i32mem:$src), // EDX:EAX/[mem32] = EAX,EDX
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001088 "div{l}\t$src", []>;
Chris Lattnerc90ee9c2008-01-10 07:59:24 +00001089}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001090
1091// Signed division/remainder.
Dale Johannesend8fd3562008-10-07 18:54:28 +00001092let Defs = [AL,AH,EFLAGS], Uses = [AX] in
Evan Chengb783fa32007-07-19 01:14:50 +00001093def IDIV8r : I<0xF6, MRM7r, (outs), (ins GR8:$src), // AX/r8 = AL,AH
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001094 "idiv{b}\t$src", []>;
Evan Cheng55687072007-09-14 21:48:26 +00001095let Defs = [AX,DX,EFLAGS], Uses = [AX,DX] in
Evan Chengb783fa32007-07-19 01:14:50 +00001096def IDIV16r: I<0xF7, MRM7r, (outs), (ins GR16:$src), // DX:AX/r16 = AX,DX
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001097 "idiv{w}\t$src", []>, OpSize;
Evan Cheng55687072007-09-14 21:48:26 +00001098let Defs = [EAX,EDX,EFLAGS], Uses = [EAX,EDX] in
Evan Chengb783fa32007-07-19 01:14:50 +00001099def IDIV32r: I<0xF7, MRM7r, (outs), (ins GR32:$src), // EDX:EAX/r32 = EAX,EDX
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001100 "idiv{l}\t$src", []>;
Chris Lattnerc90ee9c2008-01-10 07:59:24 +00001101let mayLoad = 1, mayLoad = 1 in {
Dale Johannesend8fd3562008-10-07 18:54:28 +00001102let Defs = [AL,AH,EFLAGS], Uses = [AX] in
Evan Chengb783fa32007-07-19 01:14:50 +00001103def IDIV8m : I<0xF6, MRM7m, (outs), (ins i8mem:$src), // AX/[mem8] = AL,AH
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001104 "idiv{b}\t$src", []>;
Evan Cheng55687072007-09-14 21:48:26 +00001105let Defs = [AX,DX,EFLAGS], Uses = [AX,DX] in
Evan Chengb783fa32007-07-19 01:14:50 +00001106def IDIV16m: I<0xF7, MRM7m, (outs), (ins i16mem:$src), // DX:AX/[mem16] = AX,DX
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001107 "idiv{w}\t$src", []>, OpSize;
Evan Cheng55687072007-09-14 21:48:26 +00001108let Defs = [EAX,EDX,EFLAGS], Uses = [EAX,EDX] in
Evan Chengb783fa32007-07-19 01:14:50 +00001109def IDIV32m: I<0xF7, MRM7m, (outs), (ins i32mem:$src), // EDX:EAX/[mem32] = EAX,EDX
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001110 "idiv{l}\t$src", []>;
Chris Lattnerc90ee9c2008-01-10 07:59:24 +00001111}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001112
1113//===----------------------------------------------------------------------===//
Chris Lattnerc90ee9c2008-01-10 07:59:24 +00001114// Two address Instructions.
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001115//
1116let isTwoAddress = 1 in {
1117
1118// Conditional moves
Evan Cheng950aac02007-09-25 01:57:46 +00001119let Uses = [EFLAGS] in {
Dan Gohman29b998f2009-08-27 00:14:12 +00001120
1121// X86 doesn't have 8-bit conditional moves. Use a customDAGSchedInserter to
1122// emit control flow. An alternative to this is to mark i8 SELECT as Promote,
1123// however that requires promoting the operands, and can induce additional
Dan Gohman1596dd22009-08-29 22:19:15 +00001124// i8 register pressure. Note that CMOV_GR8 is conservatively considered to
1125// clobber EFLAGS, because if one of the operands is zero, the expansion
1126// could involve an xor.
1127let usesCustomDAGSchedInserter = 1, isTwoAddress = 0, Defs = [EFLAGS] in
Dan Gohman29b998f2009-08-27 00:14:12 +00001128def CMOV_GR8 : I<0, Pseudo,
1129 (outs GR8:$dst), (ins GR8:$src1, GR8:$src2, i8imm:$cond),
1130 "#CMOV_GR8 PSEUDO!",
1131 [(set GR8:$dst, (X86cmov GR8:$src1, GR8:$src2,
1132 imm:$cond, EFLAGS))]>;
1133
Dan Gohman90adb6c2009-08-27 18:16:24 +00001134let isCommutable = 1 in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001135def CMOVB16rr : I<0x42, MRMSrcReg, // if <u, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +00001136 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001137 "cmovb\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001138 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001139 X86_COND_B, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001140 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001141def CMOVB32rr : I<0x42, MRMSrcReg, // if <u, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +00001142 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001143 "cmovb\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001144 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001145 X86_COND_B, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001146 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001147def CMOVAE16rr: I<0x43, MRMSrcReg, // if >=u, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +00001148 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001149 "cmovae\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001150 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001151 X86_COND_AE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001152 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001153def CMOVAE32rr: I<0x43, MRMSrcReg, // if >=u, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +00001154 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001155 "cmovae\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001156 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001157 X86_COND_AE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001158 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001159def CMOVE16rr : I<0x44, MRMSrcReg, // if ==, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +00001160 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001161 "cmove\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001162 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001163 X86_COND_E, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001164 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001165def CMOVE32rr : I<0x44, MRMSrcReg, // if ==, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +00001166 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001167 "cmove\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001168 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001169 X86_COND_E, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001170 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001171def CMOVNE16rr: I<0x45, MRMSrcReg, // if !=, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +00001172 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001173 "cmovne\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001174 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001175 X86_COND_NE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001176 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001177def CMOVNE32rr: I<0x45, MRMSrcReg, // if !=, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +00001178 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001179 "cmovne\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001180 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001181 X86_COND_NE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001182 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001183def CMOVBE16rr: I<0x46, MRMSrcReg, // if <=u, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +00001184 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001185 "cmovbe\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001186 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001187 X86_COND_BE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001188 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001189def CMOVBE32rr: I<0x46, MRMSrcReg, // if <=u, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +00001190 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001191 "cmovbe\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001192 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001193 X86_COND_BE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001194 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001195def CMOVA16rr : I<0x47, MRMSrcReg, // if >u, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +00001196 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001197 "cmova\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001198 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001199 X86_COND_A, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001200 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001201def CMOVA32rr : I<0x47, MRMSrcReg, // if >u, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +00001202 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001203 "cmova\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001204 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001205 X86_COND_A, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001206 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001207def CMOVL16rr : I<0x4C, MRMSrcReg, // if <s, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +00001208 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001209 "cmovl\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001210 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001211 X86_COND_L, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001212 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001213def CMOVL32rr : I<0x4C, MRMSrcReg, // if <s, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +00001214 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001215 "cmovl\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001216 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001217 X86_COND_L, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001218 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001219def CMOVGE16rr: I<0x4D, MRMSrcReg, // if >=s, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +00001220 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001221 "cmovge\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001222 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001223 X86_COND_GE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001224 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001225def CMOVGE32rr: I<0x4D, MRMSrcReg, // if >=s, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +00001226 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001227 "cmovge\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001228 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001229 X86_COND_GE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001230 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001231def CMOVLE16rr: I<0x4E, MRMSrcReg, // if <=s, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +00001232 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001233 "cmovle\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001234 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001235 X86_COND_LE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001236 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001237def CMOVLE32rr: I<0x4E, MRMSrcReg, // if <=s, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +00001238 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001239 "cmovle\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001240 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001241 X86_COND_LE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001242 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001243def CMOVG16rr : I<0x4F, MRMSrcReg, // if >s, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +00001244 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001245 "cmovg\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001246 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001247 X86_COND_G, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001248 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001249def CMOVG32rr : I<0x4F, MRMSrcReg, // if >s, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +00001250 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001251 "cmovg\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001252 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001253 X86_COND_G, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001254 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001255def CMOVS16rr : I<0x48, MRMSrcReg, // if signed, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +00001256 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001257 "cmovs\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001258 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001259 X86_COND_S, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001260 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001261def CMOVS32rr : I<0x48, MRMSrcReg, // if signed, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +00001262 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001263 "cmovs\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001264 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001265 X86_COND_S, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001266 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001267def CMOVNS16rr: I<0x49, MRMSrcReg, // if !signed, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +00001268 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001269 "cmovns\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001270 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001271 X86_COND_NS, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001272 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001273def CMOVNS32rr: I<0x49, MRMSrcReg, // if !signed, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +00001274 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001275 "cmovns\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001276 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001277 X86_COND_NS, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001278 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001279def CMOVP16rr : I<0x4A, MRMSrcReg, // if parity, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +00001280 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001281 "cmovp\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001282 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001283 X86_COND_P, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001284 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001285def CMOVP32rr : I<0x4A, MRMSrcReg, // if parity, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +00001286 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001287 "cmovp\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001288 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001289 X86_COND_P, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001290 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001291def CMOVNP16rr : I<0x4B, MRMSrcReg, // if !parity, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +00001292 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001293 "cmovnp\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001294 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001295 X86_COND_NP, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001296 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001297def CMOVNP32rr : I<0x4B, MRMSrcReg, // if !parity, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +00001298 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001299 "cmovnp\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001300 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001301 X86_COND_NP, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001302 TB;
Dan Gohman12fd4d72009-01-07 00:35:10 +00001303def CMOVO16rr : I<0x40, MRMSrcReg, // if overflow, GR16 = GR16
1304 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
1305 "cmovo\t{$src2, $dst|$dst, $src2}",
1306 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
1307 X86_COND_O, EFLAGS))]>,
1308 TB, OpSize;
1309def CMOVO32rr : I<0x40, MRMSrcReg, // if overflow, GR32 = GR32
1310 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
1311 "cmovo\t{$src2, $dst|$dst, $src2}",
1312 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
1313 X86_COND_O, EFLAGS))]>,
Evan Cheng950aac02007-09-25 01:57:46 +00001314 TB;
Dan Gohman12fd4d72009-01-07 00:35:10 +00001315def CMOVNO16rr : I<0x41, MRMSrcReg, // if !overflow, GR16 = GR16
1316 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
1317 "cmovno\t{$src2, $dst|$dst, $src2}",
1318 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
1319 X86_COND_NO, EFLAGS))]>,
1320 TB, OpSize;
1321def CMOVNO32rr : I<0x41, MRMSrcReg, // if !overflow, GR32 = GR32
1322 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
1323 "cmovno\t{$src2, $dst|$dst, $src2}",
1324 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
1325 X86_COND_NO, EFLAGS))]>,
1326 TB;
1327} // isCommutable = 1
Evan Cheng926658c2007-10-05 23:13:21 +00001328
1329def CMOVB16rm : I<0x42, MRMSrcMem, // if <u, GR16 = [mem16]
1330 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1331 "cmovb\t{$src2, $dst|$dst, $src2}",
1332 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1333 X86_COND_B, EFLAGS))]>,
1334 TB, OpSize;
1335def CMOVB32rm : I<0x42, MRMSrcMem, // if <u, GR32 = [mem32]
1336 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1337 "cmovb\t{$src2, $dst|$dst, $src2}",
1338 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1339 X86_COND_B, EFLAGS))]>,
1340 TB;
1341def CMOVAE16rm: I<0x43, MRMSrcMem, // if >=u, GR16 = [mem16]
1342 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1343 "cmovae\t{$src2, $dst|$dst, $src2}",
1344 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1345 X86_COND_AE, EFLAGS))]>,
1346 TB, OpSize;
1347def CMOVAE32rm: I<0x43, MRMSrcMem, // if >=u, GR32 = [mem32]
1348 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1349 "cmovae\t{$src2, $dst|$dst, $src2}",
1350 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1351 X86_COND_AE, EFLAGS))]>,
1352 TB;
1353def CMOVE16rm : I<0x44, MRMSrcMem, // if ==, GR16 = [mem16]
1354 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1355 "cmove\t{$src2, $dst|$dst, $src2}",
1356 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1357 X86_COND_E, EFLAGS))]>,
1358 TB, OpSize;
1359def CMOVE32rm : I<0x44, MRMSrcMem, // if ==, GR32 = [mem32]
1360 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1361 "cmove\t{$src2, $dst|$dst, $src2}",
1362 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1363 X86_COND_E, EFLAGS))]>,
1364 TB;
1365def CMOVNE16rm: I<0x45, MRMSrcMem, // if !=, GR16 = [mem16]
1366 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1367 "cmovne\t{$src2, $dst|$dst, $src2}",
1368 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1369 X86_COND_NE, EFLAGS))]>,
1370 TB, OpSize;
1371def CMOVNE32rm: I<0x45, MRMSrcMem, // if !=, GR32 = [mem32]
1372 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1373 "cmovne\t{$src2, $dst|$dst, $src2}",
1374 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1375 X86_COND_NE, EFLAGS))]>,
1376 TB;
1377def CMOVBE16rm: I<0x46, MRMSrcMem, // if <=u, GR16 = [mem16]
1378 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1379 "cmovbe\t{$src2, $dst|$dst, $src2}",
1380 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1381 X86_COND_BE, EFLAGS))]>,
1382 TB, OpSize;
1383def CMOVBE32rm: I<0x46, MRMSrcMem, // if <=u, GR32 = [mem32]
1384 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1385 "cmovbe\t{$src2, $dst|$dst, $src2}",
1386 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1387 X86_COND_BE, EFLAGS))]>,
1388 TB;
1389def CMOVA16rm : I<0x47, MRMSrcMem, // if >u, GR16 = [mem16]
1390 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1391 "cmova\t{$src2, $dst|$dst, $src2}",
1392 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1393 X86_COND_A, EFLAGS))]>,
1394 TB, OpSize;
1395def CMOVA32rm : I<0x47, MRMSrcMem, // if >u, GR32 = [mem32]
1396 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1397 "cmova\t{$src2, $dst|$dst, $src2}",
1398 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1399 X86_COND_A, EFLAGS))]>,
1400 TB;
1401def CMOVL16rm : I<0x4C, MRMSrcMem, // if <s, GR16 = [mem16]
1402 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1403 "cmovl\t{$src2, $dst|$dst, $src2}",
1404 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1405 X86_COND_L, EFLAGS))]>,
1406 TB, OpSize;
1407def CMOVL32rm : I<0x4C, MRMSrcMem, // if <s, GR32 = [mem32]
1408 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1409 "cmovl\t{$src2, $dst|$dst, $src2}",
1410 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1411 X86_COND_L, EFLAGS))]>,
1412 TB;
1413def CMOVGE16rm: I<0x4D, MRMSrcMem, // if >=s, GR16 = [mem16]
1414 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1415 "cmovge\t{$src2, $dst|$dst, $src2}",
1416 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1417 X86_COND_GE, EFLAGS))]>,
1418 TB, OpSize;
1419def CMOVGE32rm: I<0x4D, MRMSrcMem, // if >=s, GR32 = [mem32]
1420 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1421 "cmovge\t{$src2, $dst|$dst, $src2}",
1422 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1423 X86_COND_GE, EFLAGS))]>,
1424 TB;
1425def CMOVLE16rm: I<0x4E, MRMSrcMem, // if <=s, GR16 = [mem16]
1426 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1427 "cmovle\t{$src2, $dst|$dst, $src2}",
1428 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1429 X86_COND_LE, EFLAGS))]>,
1430 TB, OpSize;
1431def CMOVLE32rm: I<0x4E, MRMSrcMem, // if <=s, GR32 = [mem32]
1432 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1433 "cmovle\t{$src2, $dst|$dst, $src2}",
1434 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1435 X86_COND_LE, EFLAGS))]>,
1436 TB;
1437def CMOVG16rm : I<0x4F, MRMSrcMem, // if >s, GR16 = [mem16]
1438 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1439 "cmovg\t{$src2, $dst|$dst, $src2}",
1440 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1441 X86_COND_G, EFLAGS))]>,
1442 TB, OpSize;
1443def CMOVG32rm : I<0x4F, MRMSrcMem, // if >s, GR32 = [mem32]
1444 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1445 "cmovg\t{$src2, $dst|$dst, $src2}",
1446 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1447 X86_COND_G, EFLAGS))]>,
1448 TB;
1449def CMOVS16rm : I<0x48, MRMSrcMem, // if signed, GR16 = [mem16]
1450 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1451 "cmovs\t{$src2, $dst|$dst, $src2}",
1452 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1453 X86_COND_S, EFLAGS))]>,
1454 TB, OpSize;
1455def CMOVS32rm : I<0x48, MRMSrcMem, // if signed, GR32 = [mem32]
1456 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1457 "cmovs\t{$src2, $dst|$dst, $src2}",
1458 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1459 X86_COND_S, EFLAGS))]>,
1460 TB;
1461def CMOVNS16rm: I<0x49, MRMSrcMem, // if !signed, GR16 = [mem16]
1462 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1463 "cmovns\t{$src2, $dst|$dst, $src2}",
1464 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1465 X86_COND_NS, EFLAGS))]>,
1466 TB, OpSize;
1467def CMOVNS32rm: I<0x49, MRMSrcMem, // if !signed, GR32 = [mem32]
1468 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1469 "cmovns\t{$src2, $dst|$dst, $src2}",
1470 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1471 X86_COND_NS, EFLAGS))]>,
1472 TB;
1473def CMOVP16rm : I<0x4A, MRMSrcMem, // if parity, GR16 = [mem16]
1474 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1475 "cmovp\t{$src2, $dst|$dst, $src2}",
1476 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1477 X86_COND_P, EFLAGS))]>,
1478 TB, OpSize;
1479def CMOVP32rm : I<0x4A, MRMSrcMem, // if parity, GR32 = [mem32]
1480 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1481 "cmovp\t{$src2, $dst|$dst, $src2}",
1482 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1483 X86_COND_P, EFLAGS))]>,
1484 TB;
1485def CMOVNP16rm : I<0x4B, MRMSrcMem, // if !parity, GR16 = [mem16]
1486 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1487 "cmovnp\t{$src2, $dst|$dst, $src2}",
1488 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1489 X86_COND_NP, EFLAGS))]>,
1490 TB, OpSize;
Dan Gohman12fd4d72009-01-07 00:35:10 +00001491def CMOVNP32rm : I<0x4B, MRMSrcMem, // if !parity, GR32 = [mem32]
1492 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1493 "cmovnp\t{$src2, $dst|$dst, $src2}",
1494 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1495 X86_COND_NP, EFLAGS))]>,
1496 TB;
1497def CMOVO16rm : I<0x40, MRMSrcMem, // if overflow, GR16 = [mem16]
1498 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1499 "cmovo\t{$src2, $dst|$dst, $src2}",
1500 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1501 X86_COND_O, EFLAGS))]>,
1502 TB, OpSize;
1503def CMOVO32rm : I<0x40, MRMSrcMem, // if overflow, GR32 = [mem32]
1504 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1505 "cmovo\t{$src2, $dst|$dst, $src2}",
1506 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1507 X86_COND_O, EFLAGS))]>,
1508 TB;
1509def CMOVNO16rm : I<0x41, MRMSrcMem, // if !overflow, GR16 = [mem16]
1510 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1511 "cmovno\t{$src2, $dst|$dst, $src2}",
1512 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1513 X86_COND_NO, EFLAGS))]>,
1514 TB, OpSize;
1515def CMOVNO32rm : I<0x41, MRMSrcMem, // if !overflow, GR32 = [mem32]
1516 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1517 "cmovno\t{$src2, $dst|$dst, $src2}",
1518 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1519 X86_COND_NO, EFLAGS))]>,
1520 TB;
Evan Cheng950aac02007-09-25 01:57:46 +00001521} // Uses = [EFLAGS]
1522
1523
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001524// unary instructions
1525let CodeSize = 2 in {
Evan Cheng55687072007-09-14 21:48:26 +00001526let Defs = [EFLAGS] in {
Dan Gohman91888f02007-07-31 20:11:57 +00001527def NEG8r : I<0xF6, MRM3r, (outs GR8 :$dst), (ins GR8 :$src), "neg{b}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001528 [(set GR8:$dst, (ineg GR8:$src)),
1529 (implicit EFLAGS)]>;
Dan Gohman91888f02007-07-31 20:11:57 +00001530def NEG16r : I<0xF7, MRM3r, (outs GR16:$dst), (ins GR16:$src), "neg{w}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001531 [(set GR16:$dst, (ineg GR16:$src)),
1532 (implicit EFLAGS)]>, OpSize;
Dan Gohman91888f02007-07-31 20:11:57 +00001533def NEG32r : I<0xF7, MRM3r, (outs GR32:$dst), (ins GR32:$src), "neg{l}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001534 [(set GR32:$dst, (ineg GR32:$src)),
1535 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001536let isTwoAddress = 0 in {
Dan Gohman91888f02007-07-31 20:11:57 +00001537 def NEG8m : I<0xF6, MRM3m, (outs), (ins i8mem :$dst), "neg{b}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001538 [(store (ineg (loadi8 addr:$dst)), addr:$dst),
1539 (implicit EFLAGS)]>;
Dan Gohman91888f02007-07-31 20:11:57 +00001540 def NEG16m : I<0xF7, MRM3m, (outs), (ins i16mem:$dst), "neg{w}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001541 [(store (ineg (loadi16 addr:$dst)), addr:$dst),
1542 (implicit EFLAGS)]>, OpSize;
Dan Gohman91888f02007-07-31 20:11:57 +00001543 def NEG32m : I<0xF7, MRM3m, (outs), (ins i32mem:$dst), "neg{l}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001544 [(store (ineg (loadi32 addr:$dst)), addr:$dst),
1545 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001546}
Evan Cheng55687072007-09-14 21:48:26 +00001547} // Defs = [EFLAGS]
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001548
Evan Chengc6cee682009-01-21 02:09:05 +00001549// Match xor -1 to not. Favors these over a move imm + xor to save code size.
1550let AddedComplexity = 15 in {
Dan Gohman91888f02007-07-31 20:11:57 +00001551def NOT8r : I<0xF6, MRM2r, (outs GR8 :$dst), (ins GR8 :$src), "not{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001552 [(set GR8:$dst, (not GR8:$src))]>;
Dan Gohman91888f02007-07-31 20:11:57 +00001553def NOT16r : I<0xF7, MRM2r, (outs GR16:$dst), (ins GR16:$src), "not{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001554 [(set GR16:$dst, (not GR16:$src))]>, OpSize;
Dan Gohman91888f02007-07-31 20:11:57 +00001555def NOT32r : I<0xF7, MRM2r, (outs GR32:$dst), (ins GR32:$src), "not{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001556 [(set GR32:$dst, (not GR32:$src))]>;
Evan Chengc6cee682009-01-21 02:09:05 +00001557}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001558let isTwoAddress = 0 in {
Dan Gohman91888f02007-07-31 20:11:57 +00001559 def NOT8m : I<0xF6, MRM2m, (outs), (ins i8mem :$dst), "not{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001560 [(store (not (loadi8 addr:$dst)), addr:$dst)]>;
Dan Gohman91888f02007-07-31 20:11:57 +00001561 def NOT16m : I<0xF7, MRM2m, (outs), (ins i16mem:$dst), "not{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001562 [(store (not (loadi16 addr:$dst)), addr:$dst)]>, OpSize;
Dan Gohman91888f02007-07-31 20:11:57 +00001563 def NOT32m : I<0xF7, MRM2m, (outs), (ins i32mem:$dst), "not{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001564 [(store (not (loadi32 addr:$dst)), addr:$dst)]>;
1565}
1566} // CodeSize
1567
1568// TODO: inc/dec is slow for P4, but fast for Pentium-M.
Evan Cheng55687072007-09-14 21:48:26 +00001569let Defs = [EFLAGS] in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001570let CodeSize = 2 in
Dan Gohman91888f02007-07-31 20:11:57 +00001571def INC8r : I<0xFE, MRM0r, (outs GR8 :$dst), (ins GR8 :$src), "inc{b}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001572 [(set GR8:$dst, (add GR8:$src, 1)),
1573 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001574let isConvertibleToThreeAddress = 1, CodeSize = 1 in { // Can xform into LEA.
Dan Gohman91888f02007-07-31 20:11:57 +00001575def INC16r : I<0x40, AddRegFrm, (outs GR16:$dst), (ins GR16:$src), "inc{w}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001576 [(set GR16:$dst, (add GR16:$src, 1)),
1577 (implicit EFLAGS)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001578 OpSize, Requires<[In32BitMode]>;
Dan Gohman91888f02007-07-31 20:11:57 +00001579def INC32r : I<0x40, AddRegFrm, (outs GR32:$dst), (ins GR32:$src), "inc{l}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001580 [(set GR32:$dst, (add GR32:$src, 1)),
1581 (implicit EFLAGS)]>, Requires<[In32BitMode]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001582}
1583let isTwoAddress = 0, CodeSize = 2 in {
Dan Gohman91888f02007-07-31 20:11:57 +00001584 def INC8m : I<0xFE, MRM0m, (outs), (ins i8mem :$dst), "inc{b}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001585 [(store (add (loadi8 addr:$dst), 1), addr:$dst),
1586 (implicit EFLAGS)]>;
Dan Gohman91888f02007-07-31 20:11:57 +00001587 def INC16m : I<0xFF, MRM0m, (outs), (ins i16mem:$dst), "inc{w}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001588 [(store (add (loadi16 addr:$dst), 1), addr:$dst),
1589 (implicit EFLAGS)]>,
Evan Cheng4a7e72f2007-10-19 21:23:22 +00001590 OpSize, Requires<[In32BitMode]>;
Dan Gohman91888f02007-07-31 20:11:57 +00001591 def INC32m : I<0xFF, MRM0m, (outs), (ins i32mem:$dst), "inc{l}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001592 [(store (add (loadi32 addr:$dst), 1), addr:$dst),
1593 (implicit EFLAGS)]>,
Evan Cheng4a7e72f2007-10-19 21:23:22 +00001594 Requires<[In32BitMode]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001595}
1596
1597let CodeSize = 2 in
Dan Gohman91888f02007-07-31 20:11:57 +00001598def DEC8r : I<0xFE, MRM1r, (outs GR8 :$dst), (ins GR8 :$src), "dec{b}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001599 [(set GR8:$dst, (add GR8:$src, -1)),
1600 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001601let isConvertibleToThreeAddress = 1, CodeSize = 1 in { // Can xform into LEA.
Dan Gohman91888f02007-07-31 20:11:57 +00001602def DEC16r : I<0x48, AddRegFrm, (outs GR16:$dst), (ins GR16:$src), "dec{w}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001603 [(set GR16:$dst, (add GR16:$src, -1)),
1604 (implicit EFLAGS)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001605 OpSize, Requires<[In32BitMode]>;
Dan Gohman91888f02007-07-31 20:11:57 +00001606def DEC32r : I<0x48, AddRegFrm, (outs GR32:$dst), (ins GR32:$src), "dec{l}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001607 [(set GR32:$dst, (add GR32:$src, -1)),
1608 (implicit EFLAGS)]>, Requires<[In32BitMode]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001609}
1610
1611let isTwoAddress = 0, CodeSize = 2 in {
Dan Gohman91888f02007-07-31 20:11:57 +00001612 def DEC8m : I<0xFE, MRM1m, (outs), (ins i8mem :$dst), "dec{b}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001613 [(store (add (loadi8 addr:$dst), -1), addr:$dst),
1614 (implicit EFLAGS)]>;
Dan Gohman91888f02007-07-31 20:11:57 +00001615 def DEC16m : I<0xFF, MRM1m, (outs), (ins i16mem:$dst), "dec{w}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001616 [(store (add (loadi16 addr:$dst), -1), addr:$dst),
1617 (implicit EFLAGS)]>,
Evan Cheng4a7e72f2007-10-19 21:23:22 +00001618 OpSize, Requires<[In32BitMode]>;
Dan Gohman91888f02007-07-31 20:11:57 +00001619 def DEC32m : I<0xFF, MRM1m, (outs), (ins i32mem:$dst), "dec{l}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001620 [(store (add (loadi32 addr:$dst), -1), addr:$dst),
1621 (implicit EFLAGS)]>,
Evan Cheng4a7e72f2007-10-19 21:23:22 +00001622 Requires<[In32BitMode]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001623}
Evan Cheng55687072007-09-14 21:48:26 +00001624} // Defs = [EFLAGS]
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001625
1626// Logical operators...
Evan Cheng55687072007-09-14 21:48:26 +00001627let Defs = [EFLAGS] in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001628let isCommutable = 1 in { // X = AND Y, Z --> X = AND Z, Y
1629def AND8rr : I<0x20, MRMDestReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001630 (outs GR8 :$dst), (ins GR8 :$src1, GR8 :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001631 "and{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001632 [(set GR8:$dst, (and GR8:$src1, GR8:$src2)),
1633 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001634def AND16rr : I<0x21, MRMDestReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001635 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001636 "and{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001637 [(set GR16:$dst, (and GR16:$src1, GR16:$src2)),
1638 (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001639def AND32rr : I<0x21, MRMDestReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001640 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001641 "and{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001642 [(set GR32:$dst, (and GR32:$src1, GR32:$src2)),
1643 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001644}
1645
1646def AND8rm : I<0x22, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001647 (outs GR8 :$dst), (ins GR8 :$src1, i8mem :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001648 "and{b}\t{$src2, $dst|$dst, $src2}",
Chris Lattner12208612009-04-10 00:16:23 +00001649 [(set GR8:$dst, (and GR8:$src1, (loadi8 addr:$src2))),
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001650 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001651def AND16rm : I<0x23, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001652 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001653 "and{w}\t{$src2, $dst|$dst, $src2}",
Chris Lattner12208612009-04-10 00:16:23 +00001654 [(set GR16:$dst, (and GR16:$src1, (loadi16 addr:$src2))),
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001655 (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001656def AND32rm : I<0x23, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001657 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001658 "and{l}\t{$src2, $dst|$dst, $src2}",
Chris Lattner12208612009-04-10 00:16:23 +00001659 [(set GR32:$dst, (and GR32:$src1, (loadi32 addr:$src2))),
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001660 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001661
1662def AND8ri : Ii8<0x80, MRM4r,
Evan Chengb783fa32007-07-19 01:14:50 +00001663 (outs GR8 :$dst), (ins GR8 :$src1, i8imm :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001664 "and{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001665 [(set GR8:$dst, (and GR8:$src1, imm:$src2)),
1666 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001667def AND16ri : Ii16<0x81, MRM4r,
Evan Chengb783fa32007-07-19 01:14:50 +00001668 (outs GR16:$dst), (ins GR16:$src1, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001669 "and{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001670 [(set GR16:$dst, (and GR16:$src1, imm:$src2)),
1671 (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001672def AND32ri : Ii32<0x81, MRM4r,
Evan Chengb783fa32007-07-19 01:14:50 +00001673 (outs GR32:$dst), (ins GR32:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001674 "and{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001675 [(set GR32:$dst, (and GR32:$src1, imm:$src2)),
1676 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001677def AND16ri8 : Ii8<0x83, MRM4r,
Evan Chengb783fa32007-07-19 01:14:50 +00001678 (outs GR16:$dst), (ins GR16:$src1, i16i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001679 "and{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001680 [(set GR16:$dst, (and GR16:$src1, i16immSExt8:$src2)),
1681 (implicit EFLAGS)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001682 OpSize;
1683def AND32ri8 : Ii8<0x83, MRM4r,
Evan Chengb783fa32007-07-19 01:14:50 +00001684 (outs GR32:$dst), (ins GR32:$src1, i32i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001685 "and{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001686 [(set GR32:$dst, (and GR32:$src1, i32immSExt8:$src2)),
1687 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001688
1689let isTwoAddress = 0 in {
1690 def AND8mr : I<0x20, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001691 (outs), (ins i8mem :$dst, GR8 :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001692 "and{b}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001693 [(store (and (load addr:$dst), GR8:$src), addr:$dst),
1694 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001695 def AND16mr : I<0x21, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001696 (outs), (ins i16mem:$dst, GR16:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001697 "and{w}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001698 [(store (and (load addr:$dst), GR16:$src), addr:$dst),
1699 (implicit EFLAGS)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001700 OpSize;
1701 def AND32mr : I<0x21, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001702 (outs), (ins i32mem:$dst, GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001703 "and{l}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001704 [(store (and (load addr:$dst), GR32:$src), addr:$dst),
1705 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001706 def AND8mi : Ii8<0x80, MRM4m,
Evan Chengb783fa32007-07-19 01:14:50 +00001707 (outs), (ins i8mem :$dst, i8imm :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001708 "and{b}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001709 [(store (and (loadi8 addr:$dst), imm:$src), addr:$dst),
1710 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001711 def AND16mi : Ii16<0x81, MRM4m,
Evan Chengb783fa32007-07-19 01:14:50 +00001712 (outs), (ins i16mem:$dst, i16imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001713 "and{w}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001714 [(store (and (loadi16 addr:$dst), imm:$src), addr:$dst),
1715 (implicit EFLAGS)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001716 OpSize;
1717 def AND32mi : Ii32<0x81, MRM4m,
Evan Chengb783fa32007-07-19 01:14:50 +00001718 (outs), (ins i32mem:$dst, i32imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001719 "and{l}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001720 [(store (and (loadi32 addr:$dst), imm:$src), addr:$dst),
1721 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001722 def AND16mi8 : Ii8<0x83, MRM4m,
Evan Chengb783fa32007-07-19 01:14:50 +00001723 (outs), (ins i16mem:$dst, i16i8imm :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001724 "and{w}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001725 [(store (and (load addr:$dst), i16immSExt8:$src), addr:$dst),
1726 (implicit EFLAGS)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001727 OpSize;
1728 def AND32mi8 : Ii8<0x83, MRM4m,
Evan Chengb783fa32007-07-19 01:14:50 +00001729 (outs), (ins i32mem:$dst, i32i8imm :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001730 "and{l}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001731 [(store (and (load addr:$dst), i32immSExt8:$src), addr:$dst),
1732 (implicit EFLAGS)]>;
Sean Callanan251676e2009-09-02 00:55:49 +00001733
1734 def AND8i8 : Ii8<0x24, RawFrm, (outs), (ins i8imm:$src),
1735 "and{b}\t{$src, %al|%al, $src}", []>;
1736 def AND16i16 : Ii16<0x25, RawFrm, (outs), (ins i16imm:$src),
1737 "and{w}\t{$src, %ax|%ax, $src}", []>, OpSize;
1738 def AND32i32 : Ii32<0x25, RawFrm, (outs), (ins i32imm:$src),
1739 "and{l}\t{$src, %eax|%eax, $src}", []>;
1740
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001741}
1742
1743
1744let isCommutable = 1 in { // X = OR Y, Z --> X = OR Z, Y
Evan Chengb783fa32007-07-19 01:14:50 +00001745def OR8rr : I<0x08, MRMDestReg, (outs GR8 :$dst), (ins GR8 :$src1, GR8 :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001746 "or{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001747 [(set GR8:$dst, (or GR8:$src1, GR8:$src2)),
1748 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001749def OR16rr : I<0x09, MRMDestReg, (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001750 "or{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001751 [(set GR16:$dst, (or GR16:$src1, GR16:$src2)),
1752 (implicit EFLAGS)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001753def OR32rr : I<0x09, MRMDestReg, (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001754 "or{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001755 [(set GR32:$dst, (or GR32:$src1, GR32:$src2)),
1756 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001757}
Evan Chengb783fa32007-07-19 01:14:50 +00001758def OR8rm : I<0x0A, MRMSrcMem , (outs GR8 :$dst), (ins GR8 :$src1, i8mem :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001759 "or{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001760 [(set GR8:$dst, (or GR8:$src1, (load addr:$src2))),
1761 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001762def OR16rm : I<0x0B, MRMSrcMem , (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001763 "or{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001764 [(set GR16:$dst, (or GR16:$src1, (load addr:$src2))),
1765 (implicit EFLAGS)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001766def OR32rm : I<0x0B, MRMSrcMem , (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001767 "or{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001768 [(set GR32:$dst, (or GR32:$src1, (load addr:$src2))),
1769 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001770
Evan Chengb783fa32007-07-19 01:14:50 +00001771def OR8ri : Ii8 <0x80, MRM1r, (outs GR8 :$dst), (ins GR8 :$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001772 "or{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001773 [(set GR8:$dst, (or GR8:$src1, imm:$src2)),
1774 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001775def OR16ri : Ii16<0x81, MRM1r, (outs GR16:$dst), (ins GR16:$src1, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001776 "or{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001777 [(set GR16:$dst, (or GR16:$src1, imm:$src2)),
1778 (implicit EFLAGS)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001779def OR32ri : Ii32<0x81, MRM1r, (outs GR32:$dst), (ins GR32:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001780 "or{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001781 [(set GR32:$dst, (or GR32:$src1, imm:$src2)),
1782 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001783
Evan Chengb783fa32007-07-19 01:14:50 +00001784def OR16ri8 : Ii8<0x83, MRM1r, (outs GR16:$dst), (ins GR16:$src1, i16i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001785 "or{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001786 [(set GR16:$dst, (or GR16:$src1, i16immSExt8:$src2)),
1787 (implicit EFLAGS)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001788def OR32ri8 : Ii8<0x83, MRM1r, (outs GR32:$dst), (ins GR32:$src1, i32i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001789 "or{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001790 [(set GR32:$dst, (or GR32:$src1, i32immSExt8:$src2)),
1791 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001792let isTwoAddress = 0 in {
Evan Chengb783fa32007-07-19 01:14:50 +00001793 def OR8mr : I<0x08, MRMDestMem, (outs), (ins i8mem:$dst, GR8:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001794 "or{b}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001795 [(store (or (load addr:$dst), GR8:$src), addr:$dst),
1796 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001797 def OR16mr : I<0x09, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001798 "or{w}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001799 [(store (or (load addr:$dst), GR16:$src), addr:$dst),
1800 (implicit EFLAGS)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001801 def OR32mr : I<0x09, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001802 "or{l}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001803 [(store (or (load addr:$dst), GR32:$src), addr:$dst),
1804 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001805 def OR8mi : Ii8<0x80, MRM1m, (outs), (ins i8mem :$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001806 "or{b}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001807 [(store (or (loadi8 addr:$dst), imm:$src), addr:$dst),
1808 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001809 def OR16mi : Ii16<0x81, MRM1m, (outs), (ins i16mem:$dst, i16imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001810 "or{w}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001811 [(store (or (loadi16 addr:$dst), imm:$src), addr:$dst),
1812 (implicit EFLAGS)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001813 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001814 def OR32mi : Ii32<0x81, MRM1m, (outs), (ins i32mem:$dst, i32imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001815 "or{l}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001816 [(store (or (loadi32 addr:$dst), imm:$src), addr:$dst),
1817 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001818 def OR16mi8 : Ii8<0x83, MRM1m, (outs), (ins i16mem:$dst, i16i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001819 "or{w}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001820 [(store (or (load addr:$dst), i16immSExt8:$src), addr:$dst),
1821 (implicit EFLAGS)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001822 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001823 def OR32mi8 : Ii8<0x83, MRM1m, (outs), (ins i32mem:$dst, i32i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001824 "or{l}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001825 [(store (or (load addr:$dst), i32immSExt8:$src), addr:$dst),
1826 (implicit EFLAGS)]>;
Sean Callanan8562bef2009-09-11 19:01:56 +00001827
1828 def OR8i8 : Ii8 <0x0C, RawFrm, (outs), (ins i8imm:$src),
1829 "or{b}\t{$src, %al|%al, $src}", []>;
1830 def OR16i16 : Ii16 <0x0D, RawFrm, (outs), (ins i16imm:$src),
1831 "or{w}\t{$src, %ax|%ax, $src}", []>, OpSize;
1832 def OR32i32 : Ii32 <0x0D, RawFrm, (outs), (ins i32imm:$src),
1833 "or{l}\t{$src, %eax|%eax, $src}", []>;
Bill Wendlingba5d5b02008-05-29 01:02:09 +00001834} // isTwoAddress = 0
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001835
1836
Evan Cheng6f26e8b2008-06-18 08:13:07 +00001837let isCommutable = 1 in { // X = XOR Y, Z --> X = XOR Z, Y
Bill Wendlingba5d5b02008-05-29 01:02:09 +00001838 def XOR8rr : I<0x30, MRMDestReg,
1839 (outs GR8 :$dst), (ins GR8 :$src1, GR8 :$src2),
1840 "xor{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001841 [(set GR8:$dst, (xor GR8:$src1, GR8:$src2)),
1842 (implicit EFLAGS)]>;
Bill Wendlingba5d5b02008-05-29 01:02:09 +00001843 def XOR16rr : I<0x31, MRMDestReg,
1844 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
1845 "xor{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001846 [(set GR16:$dst, (xor GR16:$src1, GR16:$src2)),
1847 (implicit EFLAGS)]>, OpSize;
Bill Wendlingba5d5b02008-05-29 01:02:09 +00001848 def XOR32rr : I<0x31, MRMDestReg,
1849 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
1850 "xor{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001851 [(set GR32:$dst, (xor GR32:$src1, GR32:$src2)),
1852 (implicit EFLAGS)]>;
Evan Cheng6f26e8b2008-06-18 08:13:07 +00001853} // isCommutable = 1
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001854
1855def XOR8rm : I<0x32, MRMSrcMem ,
Evan Chengb783fa32007-07-19 01:14:50 +00001856 (outs GR8 :$dst), (ins GR8:$src1, i8mem :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001857 "xor{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001858 [(set GR8:$dst, (xor GR8:$src1, (load addr:$src2))),
1859 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001860def XOR16rm : I<0x33, MRMSrcMem ,
Evan Chengb783fa32007-07-19 01:14:50 +00001861 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001862 "xor{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001863 [(set GR16:$dst, (xor GR16:$src1, (load addr:$src2))),
1864 (implicit EFLAGS)]>,
Bill Wendlingba5d5b02008-05-29 01:02:09 +00001865 OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001866def XOR32rm : I<0x33, MRMSrcMem ,
Evan Chengb783fa32007-07-19 01:14:50 +00001867 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001868 "xor{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001869 [(set GR32:$dst, (xor GR32:$src1, (load addr:$src2))),
1870 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001871
Bill Wendlingbac38eb2008-05-29 03:46:36 +00001872def XOR8ri : Ii8<0x80, MRM6r,
1873 (outs GR8:$dst), (ins GR8:$src1, i8imm:$src2),
1874 "xor{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001875 [(set GR8:$dst, (xor GR8:$src1, imm:$src2)),
1876 (implicit EFLAGS)]>;
Bill Wendlingbac38eb2008-05-29 03:46:36 +00001877def XOR16ri : Ii16<0x81, MRM6r,
1878 (outs GR16:$dst), (ins GR16:$src1, i16imm:$src2),
1879 "xor{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001880 [(set GR16:$dst, (xor GR16:$src1, imm:$src2)),
1881 (implicit EFLAGS)]>, OpSize;
Bill Wendlingbac38eb2008-05-29 03:46:36 +00001882def XOR32ri : Ii32<0x81, MRM6r,
1883 (outs GR32:$dst), (ins GR32:$src1, i32imm:$src2),
1884 "xor{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001885 [(set GR32:$dst, (xor GR32:$src1, imm:$src2)),
1886 (implicit EFLAGS)]>;
Bill Wendlingbac38eb2008-05-29 03:46:36 +00001887def XOR16ri8 : Ii8<0x83, MRM6r,
1888 (outs GR16:$dst), (ins GR16:$src1, i16i8imm:$src2),
1889 "xor{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001890 [(set GR16:$dst, (xor GR16:$src1, i16immSExt8:$src2)),
1891 (implicit EFLAGS)]>,
Bill Wendlingbac38eb2008-05-29 03:46:36 +00001892 OpSize;
1893def XOR32ri8 : Ii8<0x83, MRM6r,
1894 (outs GR32:$dst), (ins GR32:$src1, i32i8imm:$src2),
1895 "xor{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001896 [(set GR32:$dst, (xor GR32:$src1, i32immSExt8:$src2)),
1897 (implicit EFLAGS)]>;
Bill Wendlingba5d5b02008-05-29 01:02:09 +00001898
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001899let isTwoAddress = 0 in {
1900 def XOR8mr : I<0x30, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001901 (outs), (ins i8mem :$dst, GR8 :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001902 "xor{b}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001903 [(store (xor (load addr:$dst), GR8:$src), addr:$dst),
1904 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001905 def XOR16mr : I<0x31, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001906 (outs), (ins i16mem:$dst, GR16:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001907 "xor{w}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001908 [(store (xor (load addr:$dst), GR16:$src), addr:$dst),
1909 (implicit EFLAGS)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001910 OpSize;
1911 def XOR32mr : I<0x31, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001912 (outs), (ins i32mem:$dst, GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001913 "xor{l}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001914 [(store (xor (load addr:$dst), GR32:$src), addr:$dst),
1915 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001916 def XOR8mi : Ii8<0x80, MRM6m,
Evan Chengb783fa32007-07-19 01:14:50 +00001917 (outs), (ins i8mem :$dst, i8imm :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001918 "xor{b}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001919 [(store (xor (loadi8 addr:$dst), imm:$src), addr:$dst),
1920 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001921 def XOR16mi : Ii16<0x81, MRM6m,
Evan Chengb783fa32007-07-19 01:14:50 +00001922 (outs), (ins i16mem:$dst, i16imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001923 "xor{w}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001924 [(store (xor (loadi16 addr:$dst), imm:$src), addr:$dst),
1925 (implicit EFLAGS)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001926 OpSize;
1927 def XOR32mi : Ii32<0x81, MRM6m,
Evan Chengb783fa32007-07-19 01:14:50 +00001928 (outs), (ins i32mem:$dst, i32imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001929 "xor{l}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001930 [(store (xor (loadi32 addr:$dst), imm:$src), addr:$dst),
1931 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001932 def XOR16mi8 : Ii8<0x83, MRM6m,
Evan Chengb783fa32007-07-19 01:14:50 +00001933 (outs), (ins i16mem:$dst, i16i8imm :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001934 "xor{w}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001935 [(store (xor (load addr:$dst), i16immSExt8:$src), addr:$dst),
1936 (implicit EFLAGS)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001937 OpSize;
1938 def XOR32mi8 : Ii8<0x83, MRM6m,
Evan Chengb783fa32007-07-19 01:14:50 +00001939 (outs), (ins i32mem:$dst, i32i8imm :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001940 "xor{l}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001941 [(store (xor (load addr:$dst), i32immSExt8:$src), addr:$dst),
1942 (implicit EFLAGS)]>;
Sean Callanan794457a2009-09-10 19:52:26 +00001943
1944 def XOR8i8 : Ii8 <0x34, RawFrm, (outs), (ins i8imm:$src),
1945 "xor{b}\t{$src, %al|%al, $src}", []>;
1946 def XOR16i16 : Ii16 <0x35, RawFrm, (outs), (ins i16imm:$src),
1947 "xor{w}\t{$src, %ax|%ax, $src}", []>, OpSize;
1948 def XOR32i32 : Ii32 <0x35, RawFrm, (outs), (ins i32imm:$src),
1949 "xor{l}\t{$src, %eax|%eax, $src}", []>;
Bill Wendlingba5d5b02008-05-29 01:02:09 +00001950} // isTwoAddress = 0
Evan Cheng55687072007-09-14 21:48:26 +00001951} // Defs = [EFLAGS]
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001952
1953// Shift instructions
Evan Cheng55687072007-09-14 21:48:26 +00001954let Defs = [EFLAGS] in {
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001955let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00001956def SHL8rCL : I<0xD2, MRM4r, (outs GR8 :$dst), (ins GR8 :$src),
Eli Friedman378ea832009-06-19 04:48:38 +00001957 "shl{b}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001958 [(set GR8:$dst, (shl GR8:$src, CL))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001959def SHL16rCL : I<0xD3, MRM4r, (outs GR16:$dst), (ins GR16:$src),
Eli Friedman378ea832009-06-19 04:48:38 +00001960 "shl{w}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001961 [(set GR16:$dst, (shl GR16:$src, CL))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001962def SHL32rCL : I<0xD3, MRM4r, (outs GR32:$dst), (ins GR32:$src),
Eli Friedman378ea832009-06-19 04:48:38 +00001963 "shl{l}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001964 [(set GR32:$dst, (shl GR32:$src, CL))]>;
Bill Wendlingba5d5b02008-05-29 01:02:09 +00001965} // Uses = [CL]
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001966
Evan Chengb783fa32007-07-19 01:14:50 +00001967def SHL8ri : Ii8<0xC0, MRM4r, (outs GR8 :$dst), (ins GR8 :$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001968 "shl{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001969 [(set GR8:$dst, (shl GR8:$src1, (i8 imm:$src2)))]>;
1970let isConvertibleToThreeAddress = 1 in { // Can transform into LEA.
Evan Chengb783fa32007-07-19 01:14:50 +00001971def SHL16ri : Ii8<0xC1, MRM4r, (outs GR16:$dst), (ins GR16:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001972 "shl{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001973 [(set GR16:$dst, (shl GR16:$src1, (i8 imm:$src2)))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001974def SHL32ri : Ii8<0xC1, MRM4r, (outs GR32:$dst), (ins GR32:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001975 "shl{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001976 [(set GR32:$dst, (shl GR32:$src1, (i8 imm:$src2)))]>;
Sean Callananca503e02009-09-16 02:28:43 +00001977
1978// NOTE: We don't include patterns for shifts of a register by one, because
1979// 'add reg,reg' is cheaper.
1980
1981def SHL8r1 : I<0xD0, MRM4r, (outs GR8:$dst), (ins GR8:$src1),
1982 "shl{b}\t$dst", []>;
1983def SHL16r1 : I<0xD1, MRM4r, (outs GR16:$dst), (ins GR16:$src1),
1984 "shl{w}\t$dst", []>, OpSize;
1985def SHL32r1 : I<0xD1, MRM4r, (outs GR32:$dst), (ins GR32:$src1),
1986 "shl{l}\t$dst", []>;
1987
Bill Wendlingba5d5b02008-05-29 01:02:09 +00001988} // isConvertibleToThreeAddress = 1
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001989
1990let isTwoAddress = 0 in {
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001991 let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00001992 def SHL8mCL : I<0xD2, MRM4m, (outs), (ins i8mem :$dst),
Eli Friedman378ea832009-06-19 04:48:38 +00001993 "shl{b}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001994 [(store (shl (loadi8 addr:$dst), CL), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001995 def SHL16mCL : I<0xD3, MRM4m, (outs), (ins i16mem:$dst),
Eli Friedman378ea832009-06-19 04:48:38 +00001996 "shl{w}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001997 [(store (shl (loadi16 addr:$dst), CL), addr:$dst)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001998 def SHL32mCL : I<0xD3, MRM4m, (outs), (ins i32mem:$dst),
Eli Friedman378ea832009-06-19 04:48:38 +00001999 "shl{l}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002000 [(store (shl (loadi32 addr:$dst), CL), addr:$dst)]>;
2001 }
Evan Chengb783fa32007-07-19 01:14:50 +00002002 def SHL8mi : Ii8<0xC0, MRM4m, (outs), (ins i8mem :$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002003 "shl{b}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002004 [(store (shl (loadi8 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002005 def SHL16mi : Ii8<0xC1, MRM4m, (outs), (ins i16mem:$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002006 "shl{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002007 [(store (shl (loadi16 addr:$dst), (i8 imm:$src)), addr:$dst)]>,
2008 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002009 def SHL32mi : Ii8<0xC1, MRM4m, (outs), (ins i32mem:$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002010 "shl{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002011 [(store (shl (loadi32 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
2012
2013 // Shift by 1
Evan Chengb783fa32007-07-19 01:14:50 +00002014 def SHL8m1 : I<0xD0, MRM4m, (outs), (ins i8mem :$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002015 "shl{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002016 [(store (shl (loadi8 addr:$dst), (i8 1)), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002017 def SHL16m1 : I<0xD1, MRM4m, (outs), (ins i16mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002018 "shl{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002019 [(store (shl (loadi16 addr:$dst), (i8 1)), addr:$dst)]>,
2020 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002021 def SHL32m1 : I<0xD1, MRM4m, (outs), (ins i32mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002022 "shl{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002023 [(store (shl (loadi32 addr:$dst), (i8 1)), addr:$dst)]>;
2024}
2025
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002026let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00002027def SHR8rCL : I<0xD2, MRM5r, (outs GR8 :$dst), (ins GR8 :$src),
Eli Friedman378ea832009-06-19 04:48:38 +00002028 "shr{b}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002029 [(set GR8:$dst, (srl GR8:$src, CL))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002030def SHR16rCL : I<0xD3, MRM5r, (outs GR16:$dst), (ins GR16:$src),
Eli Friedman378ea832009-06-19 04:48:38 +00002031 "shr{w}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002032 [(set GR16:$dst, (srl GR16:$src, CL))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002033def SHR32rCL : I<0xD3, MRM5r, (outs GR32:$dst), (ins GR32:$src),
Eli Friedman378ea832009-06-19 04:48:38 +00002034 "shr{l}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002035 [(set GR32:$dst, (srl GR32:$src, CL))]>;
2036}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002037
Evan Chengb783fa32007-07-19 01:14:50 +00002038def SHR8ri : Ii8<0xC0, MRM5r, (outs GR8:$dst), (ins GR8:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002039 "shr{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002040 [(set GR8:$dst, (srl GR8:$src1, (i8 imm:$src2)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002041def SHR16ri : Ii8<0xC1, MRM5r, (outs GR16:$dst), (ins GR16:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002042 "shr{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002043 [(set GR16:$dst, (srl GR16:$src1, (i8 imm:$src2)))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002044def SHR32ri : Ii8<0xC1, MRM5r, (outs GR32:$dst), (ins GR32:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002045 "shr{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002046 [(set GR32:$dst, (srl GR32:$src1, (i8 imm:$src2)))]>;
2047
2048// Shift by 1
Evan Chengb783fa32007-07-19 01:14:50 +00002049def SHR8r1 : I<0xD0, MRM5r, (outs GR8:$dst), (ins GR8:$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00002050 "shr{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002051 [(set GR8:$dst, (srl GR8:$src1, (i8 1)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002052def SHR16r1 : I<0xD1, MRM5r, (outs GR16:$dst), (ins GR16:$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00002053 "shr{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002054 [(set GR16:$dst, (srl GR16:$src1, (i8 1)))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002055def SHR32r1 : I<0xD1, MRM5r, (outs GR32:$dst), (ins GR32:$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00002056 "shr{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002057 [(set GR32:$dst, (srl GR32:$src1, (i8 1)))]>;
2058
2059let isTwoAddress = 0 in {
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002060 let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00002061 def SHR8mCL : I<0xD2, MRM5m, (outs), (ins i8mem :$dst),
Eli Friedman378ea832009-06-19 04:48:38 +00002062 "shr{b}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002063 [(store (srl (loadi8 addr:$dst), CL), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002064 def SHR16mCL : I<0xD3, MRM5m, (outs), (ins i16mem:$dst),
Eli Friedman378ea832009-06-19 04:48:38 +00002065 "shr{w}\t{%cl, $dst|$dst, CL}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002066 [(store (srl (loadi16 addr:$dst), CL), addr:$dst)]>,
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002067 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002068 def SHR32mCL : I<0xD3, MRM5m, (outs), (ins i32mem:$dst),
Eli Friedman378ea832009-06-19 04:48:38 +00002069 "shr{l}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002070 [(store (srl (loadi32 addr:$dst), CL), addr:$dst)]>;
2071 }
Evan Chengb783fa32007-07-19 01:14:50 +00002072 def SHR8mi : Ii8<0xC0, MRM5m, (outs), (ins i8mem :$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002073 "shr{b}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002074 [(store (srl (loadi8 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002075 def SHR16mi : Ii8<0xC1, MRM5m, (outs), (ins i16mem:$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002076 "shr{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002077 [(store (srl (loadi16 addr:$dst), (i8 imm:$src)), addr:$dst)]>,
2078 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002079 def SHR32mi : Ii8<0xC1, MRM5m, (outs), (ins i32mem:$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002080 "shr{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002081 [(store (srl (loadi32 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
2082
2083 // Shift by 1
Evan Chengb783fa32007-07-19 01:14:50 +00002084 def SHR8m1 : I<0xD0, MRM5m, (outs), (ins i8mem :$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002085 "shr{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002086 [(store (srl (loadi8 addr:$dst), (i8 1)), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002087 def SHR16m1 : I<0xD1, MRM5m, (outs), (ins i16mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002088 "shr{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002089 [(store (srl (loadi16 addr:$dst), (i8 1)), addr:$dst)]>,OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002090 def SHR32m1 : I<0xD1, MRM5m, (outs), (ins i32mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002091 "shr{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002092 [(store (srl (loadi32 addr:$dst), (i8 1)), addr:$dst)]>;
2093}
2094
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002095let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00002096def SAR8rCL : I<0xD2, MRM7r, (outs GR8 :$dst), (ins GR8 :$src),
Eli Friedman378ea832009-06-19 04:48:38 +00002097 "sar{b}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002098 [(set GR8:$dst, (sra GR8:$src, CL))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002099def SAR16rCL : I<0xD3, MRM7r, (outs GR16:$dst), (ins GR16:$src),
Eli Friedman378ea832009-06-19 04:48:38 +00002100 "sar{w}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002101 [(set GR16:$dst, (sra GR16:$src, CL))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002102def SAR32rCL : I<0xD3, MRM7r, (outs GR32:$dst), (ins GR32:$src),
Eli Friedman378ea832009-06-19 04:48:38 +00002103 "sar{l}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002104 [(set GR32:$dst, (sra GR32:$src, CL))]>;
2105}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002106
Evan Chengb783fa32007-07-19 01:14:50 +00002107def SAR8ri : Ii8<0xC0, MRM7r, (outs GR8 :$dst), (ins GR8 :$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002108 "sar{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002109 [(set GR8:$dst, (sra GR8:$src1, (i8 imm:$src2)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002110def SAR16ri : Ii8<0xC1, MRM7r, (outs GR16:$dst), (ins GR16:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002111 "sar{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002112 [(set GR16:$dst, (sra GR16:$src1, (i8 imm:$src2)))]>,
2113 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002114def SAR32ri : Ii8<0xC1, MRM7r, (outs GR32:$dst), (ins GR32:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002115 "sar{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002116 [(set GR32:$dst, (sra GR32:$src1, (i8 imm:$src2)))]>;
2117
2118// Shift by 1
Evan Chengb783fa32007-07-19 01:14:50 +00002119def SAR8r1 : I<0xD0, MRM7r, (outs GR8 :$dst), (ins GR8 :$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00002120 "sar{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002121 [(set GR8:$dst, (sra GR8:$src1, (i8 1)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002122def SAR16r1 : I<0xD1, MRM7r, (outs GR16:$dst), (ins GR16:$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00002123 "sar{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002124 [(set GR16:$dst, (sra GR16:$src1, (i8 1)))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002125def SAR32r1 : I<0xD1, MRM7r, (outs GR32:$dst), (ins GR32:$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00002126 "sar{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002127 [(set GR32:$dst, (sra GR32:$src1, (i8 1)))]>;
2128
2129let isTwoAddress = 0 in {
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002130 let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00002131 def SAR8mCL : I<0xD2, MRM7m, (outs), (ins i8mem :$dst),
Eli Friedman378ea832009-06-19 04:48:38 +00002132 "sar{b}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002133 [(store (sra (loadi8 addr:$dst), CL), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002134 def SAR16mCL : I<0xD3, MRM7m, (outs), (ins i16mem:$dst),
Eli Friedman378ea832009-06-19 04:48:38 +00002135 "sar{w}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002136 [(store (sra (loadi16 addr:$dst), CL), addr:$dst)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002137 def SAR32mCL : I<0xD3, MRM7m, (outs), (ins i32mem:$dst),
Eli Friedman378ea832009-06-19 04:48:38 +00002138 "sar{l}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002139 [(store (sra (loadi32 addr:$dst), CL), addr:$dst)]>;
2140 }
Evan Chengb783fa32007-07-19 01:14:50 +00002141 def SAR8mi : Ii8<0xC0, MRM7m, (outs), (ins i8mem :$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002142 "sar{b}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002143 [(store (sra (loadi8 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002144 def SAR16mi : Ii8<0xC1, MRM7m, (outs), (ins i16mem:$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002145 "sar{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002146 [(store (sra (loadi16 addr:$dst), (i8 imm:$src)), addr:$dst)]>,
2147 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002148 def SAR32mi : Ii8<0xC1, MRM7m, (outs), (ins i32mem:$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002149 "sar{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002150 [(store (sra (loadi32 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
2151
2152 // Shift by 1
Evan Chengb783fa32007-07-19 01:14:50 +00002153 def SAR8m1 : I<0xD0, MRM7m, (outs), (ins i8mem :$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002154 "sar{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002155 [(store (sra (loadi8 addr:$dst), (i8 1)), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002156 def SAR16m1 : I<0xD1, MRM7m, (outs), (ins i16mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002157 "sar{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002158 [(store (sra (loadi16 addr:$dst), (i8 1)), addr:$dst)]>,
2159 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002160 def SAR32m1 : I<0xD1, MRM7m, (outs), (ins i32mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002161 "sar{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002162 [(store (sra (loadi32 addr:$dst), (i8 1)), addr:$dst)]>;
2163}
2164
2165// Rotate instructions
2166// FIXME: provide shorter instructions when imm8 == 1
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002167let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00002168def ROL8rCL : I<0xD2, MRM0r, (outs GR8 :$dst), (ins GR8 :$src),
Eli Friedman378ea832009-06-19 04:48:38 +00002169 "rol{b}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002170 [(set GR8:$dst, (rotl GR8:$src, CL))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002171def ROL16rCL : I<0xD3, MRM0r, (outs GR16:$dst), (ins GR16:$src),
Eli Friedman378ea832009-06-19 04:48:38 +00002172 "rol{w}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002173 [(set GR16:$dst, (rotl GR16:$src, CL))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002174def ROL32rCL : I<0xD3, MRM0r, (outs GR32:$dst), (ins GR32:$src),
Eli Friedman378ea832009-06-19 04:48:38 +00002175 "rol{l}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002176 [(set GR32:$dst, (rotl GR32:$src, CL))]>;
2177}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002178
Evan Chengb783fa32007-07-19 01:14:50 +00002179def ROL8ri : Ii8<0xC0, MRM0r, (outs GR8 :$dst), (ins GR8 :$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002180 "rol{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002181 [(set GR8:$dst, (rotl GR8:$src1, (i8 imm:$src2)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002182def ROL16ri : Ii8<0xC1, MRM0r, (outs GR16:$dst), (ins GR16:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002183 "rol{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002184 [(set GR16:$dst, (rotl GR16:$src1, (i8 imm:$src2)))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002185def ROL32ri : Ii8<0xC1, MRM0r, (outs GR32:$dst), (ins GR32:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002186 "rol{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002187 [(set GR32:$dst, (rotl GR32:$src1, (i8 imm:$src2)))]>;
2188
2189// Rotate by 1
Evan Chengb783fa32007-07-19 01:14:50 +00002190def ROL8r1 : I<0xD0, MRM0r, (outs GR8 :$dst), (ins GR8 :$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00002191 "rol{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002192 [(set GR8:$dst, (rotl GR8:$src1, (i8 1)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002193def ROL16r1 : I<0xD1, MRM0r, (outs GR16:$dst), (ins GR16:$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00002194 "rol{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002195 [(set GR16:$dst, (rotl GR16:$src1, (i8 1)))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002196def ROL32r1 : I<0xD1, MRM0r, (outs GR32:$dst), (ins GR32:$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00002197 "rol{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002198 [(set GR32:$dst, (rotl GR32:$src1, (i8 1)))]>;
2199
2200let isTwoAddress = 0 in {
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002201 let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00002202 def ROL8mCL : I<0xD2, MRM0m, (outs), (ins i8mem :$dst),
Eli Friedman378ea832009-06-19 04:48:38 +00002203 "rol{b}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002204 [(store (rotl (loadi8 addr:$dst), CL), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002205 def ROL16mCL : I<0xD3, MRM0m, (outs), (ins i16mem:$dst),
Eli Friedman378ea832009-06-19 04:48:38 +00002206 "rol{w}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002207 [(store (rotl (loadi16 addr:$dst), CL), addr:$dst)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002208 def ROL32mCL : I<0xD3, MRM0m, (outs), (ins i32mem:$dst),
Eli Friedman378ea832009-06-19 04:48:38 +00002209 "rol{l}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002210 [(store (rotl (loadi32 addr:$dst), CL), addr:$dst)]>;
2211 }
Evan Chengb783fa32007-07-19 01:14:50 +00002212 def ROL8mi : Ii8<0xC0, MRM0m, (outs), (ins i8mem :$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002213 "rol{b}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002214 [(store (rotl (loadi8 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002215 def ROL16mi : Ii8<0xC1, MRM0m, (outs), (ins i16mem:$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002216 "rol{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002217 [(store (rotl (loadi16 addr:$dst), (i8 imm:$src)), addr:$dst)]>,
2218 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002219 def ROL32mi : Ii8<0xC1, MRM0m, (outs), (ins i32mem:$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002220 "rol{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002221 [(store (rotl (loadi32 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
2222
2223 // Rotate by 1
Evan Chengb783fa32007-07-19 01:14:50 +00002224 def ROL8m1 : I<0xD0, MRM0m, (outs), (ins i8mem :$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002225 "rol{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002226 [(store (rotl (loadi8 addr:$dst), (i8 1)), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002227 def ROL16m1 : I<0xD1, MRM0m, (outs), (ins i16mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002228 "rol{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002229 [(store (rotl (loadi16 addr:$dst), (i8 1)), addr:$dst)]>,
2230 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002231 def ROL32m1 : I<0xD1, MRM0m, (outs), (ins i32mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002232 "rol{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002233 [(store (rotl (loadi32 addr:$dst), (i8 1)), addr:$dst)]>;
2234}
2235
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002236let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00002237def ROR8rCL : I<0xD2, MRM1r, (outs GR8 :$dst), (ins GR8 :$src),
Eli Friedman378ea832009-06-19 04:48:38 +00002238 "ror{b}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002239 [(set GR8:$dst, (rotr GR8:$src, CL))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002240def ROR16rCL : I<0xD3, MRM1r, (outs GR16:$dst), (ins GR16:$src),
Eli Friedman378ea832009-06-19 04:48:38 +00002241 "ror{w}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002242 [(set GR16:$dst, (rotr GR16:$src, CL))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002243def ROR32rCL : I<0xD3, MRM1r, (outs GR32:$dst), (ins GR32:$src),
Eli Friedman378ea832009-06-19 04:48:38 +00002244 "ror{l}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002245 [(set GR32:$dst, (rotr GR32:$src, CL))]>;
2246}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002247
Evan Chengb783fa32007-07-19 01:14:50 +00002248def ROR8ri : Ii8<0xC0, MRM1r, (outs GR8 :$dst), (ins GR8 :$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002249 "ror{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002250 [(set GR8:$dst, (rotr GR8:$src1, (i8 imm:$src2)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002251def ROR16ri : Ii8<0xC1, MRM1r, (outs GR16:$dst), (ins GR16:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002252 "ror{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002253 [(set GR16:$dst, (rotr GR16:$src1, (i8 imm:$src2)))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002254def ROR32ri : Ii8<0xC1, MRM1r, (outs GR32:$dst), (ins GR32:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002255 "ror{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002256 [(set GR32:$dst, (rotr GR32:$src1, (i8 imm:$src2)))]>;
2257
2258// Rotate by 1
Evan Chengb783fa32007-07-19 01:14:50 +00002259def ROR8r1 : I<0xD0, MRM1r, (outs GR8 :$dst), (ins GR8 :$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00002260 "ror{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002261 [(set GR8:$dst, (rotr GR8:$src1, (i8 1)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002262def ROR16r1 : I<0xD1, MRM1r, (outs GR16:$dst), (ins GR16:$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00002263 "ror{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002264 [(set GR16:$dst, (rotr GR16:$src1, (i8 1)))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002265def ROR32r1 : I<0xD1, MRM1r, (outs GR32:$dst), (ins GR32:$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00002266 "ror{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002267 [(set GR32:$dst, (rotr GR32:$src1, (i8 1)))]>;
2268
2269let isTwoAddress = 0 in {
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002270 let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00002271 def ROR8mCL : I<0xD2, MRM1m, (outs), (ins i8mem :$dst),
Eli Friedman378ea832009-06-19 04:48:38 +00002272 "ror{b}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002273 [(store (rotr (loadi8 addr:$dst), CL), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002274 def ROR16mCL : I<0xD3, MRM1m, (outs), (ins i16mem:$dst),
Eli Friedman378ea832009-06-19 04:48:38 +00002275 "ror{w}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002276 [(store (rotr (loadi16 addr:$dst), CL), addr:$dst)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002277 def ROR32mCL : I<0xD3, MRM1m, (outs), (ins i32mem:$dst),
Eli Friedman378ea832009-06-19 04:48:38 +00002278 "ror{l}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002279 [(store (rotr (loadi32 addr:$dst), CL), addr:$dst)]>;
2280 }
Evan Chengb783fa32007-07-19 01:14:50 +00002281 def ROR8mi : Ii8<0xC0, MRM1m, (outs), (ins i8mem :$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002282 "ror{b}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002283 [(store (rotr (loadi8 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002284 def ROR16mi : Ii8<0xC1, MRM1m, (outs), (ins i16mem:$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002285 "ror{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002286 [(store (rotr (loadi16 addr:$dst), (i8 imm:$src)), addr:$dst)]>,
2287 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002288 def ROR32mi : Ii8<0xC1, MRM1m, (outs), (ins i32mem:$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002289 "ror{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002290 [(store (rotr (loadi32 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
2291
2292 // Rotate by 1
Evan Chengb783fa32007-07-19 01:14:50 +00002293 def ROR8m1 : I<0xD0, MRM1m, (outs), (ins i8mem :$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002294 "ror{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002295 [(store (rotr (loadi8 addr:$dst), (i8 1)), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002296 def ROR16m1 : I<0xD1, MRM1m, (outs), (ins i16mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002297 "ror{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002298 [(store (rotr (loadi16 addr:$dst), (i8 1)), addr:$dst)]>,
2299 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002300 def ROR32m1 : I<0xD1, MRM1m, (outs), (ins i32mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002301 "ror{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002302 [(store (rotr (loadi32 addr:$dst), (i8 1)), addr:$dst)]>;
2303}
2304
2305
2306
2307// Double shift instructions (generalizations of rotate)
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002308let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00002309def SHLD32rrCL : I<0xA5, MRMDestReg, (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Eli Friedman378ea832009-06-19 04:48:38 +00002310 "shld{l}\t{%cl, $src2, $dst|$dst, $src2, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002311 [(set GR32:$dst, (X86shld GR32:$src1, GR32:$src2, CL))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00002312def SHRD32rrCL : I<0xAD, MRMDestReg, (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Eli Friedman378ea832009-06-19 04:48:38 +00002313 "shrd{l}\t{%cl, $src2, $dst|$dst, $src2, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002314 [(set GR32:$dst, (X86shrd GR32:$src1, GR32:$src2, CL))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00002315def SHLD16rrCL : I<0xA5, MRMDestReg, (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Eli Friedman378ea832009-06-19 04:48:38 +00002316 "shld{w}\t{%cl, $src2, $dst|$dst, $src2, CL}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002317 [(set GR16:$dst, (X86shld GR16:$src1, GR16:$src2, CL))]>,
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002318 TB, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002319def SHRD16rrCL : I<0xAD, MRMDestReg, (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Eli Friedman378ea832009-06-19 04:48:38 +00002320 "shrd{w}\t{%cl, $src2, $dst|$dst, $src2, CL}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002321 [(set GR16:$dst, (X86shrd GR16:$src1, GR16:$src2, CL))]>,
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002322 TB, OpSize;
2323}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002324
2325let isCommutable = 1 in { // These instructions commute to each other.
2326def SHLD32rri8 : Ii8<0xA4, MRMDestReg,
Evan Chengb783fa32007-07-19 01:14:50 +00002327 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2, i8imm:$src3),
Dan Gohman91888f02007-07-31 20:11:57 +00002328 "shld{l}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002329 [(set GR32:$dst, (X86shld GR32:$src1, GR32:$src2,
2330 (i8 imm:$src3)))]>,
2331 TB;
2332def SHRD32rri8 : Ii8<0xAC, MRMDestReg,
Evan Chengb783fa32007-07-19 01:14:50 +00002333 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2, i8imm:$src3),
Dan Gohman91888f02007-07-31 20:11:57 +00002334 "shrd{l}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002335 [(set GR32:$dst, (X86shrd GR32:$src1, GR32:$src2,
2336 (i8 imm:$src3)))]>,
2337 TB;
2338def SHLD16rri8 : Ii8<0xA4, MRMDestReg,
Evan Chengb783fa32007-07-19 01:14:50 +00002339 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2, i8imm:$src3),
Dan Gohman91888f02007-07-31 20:11:57 +00002340 "shld{w}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002341 [(set GR16:$dst, (X86shld GR16:$src1, GR16:$src2,
2342 (i8 imm:$src3)))]>,
2343 TB, OpSize;
2344def SHRD16rri8 : Ii8<0xAC, MRMDestReg,
Evan Chengb783fa32007-07-19 01:14:50 +00002345 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2, i8imm:$src3),
Dan Gohman91888f02007-07-31 20:11:57 +00002346 "shrd{w}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002347 [(set GR16:$dst, (X86shrd GR16:$src1, GR16:$src2,
2348 (i8 imm:$src3)))]>,
2349 TB, OpSize;
2350}
2351
2352let isTwoAddress = 0 in {
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002353 let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00002354 def SHLD32mrCL : I<0xA5, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
Eli Friedman378ea832009-06-19 04:48:38 +00002355 "shld{l}\t{%cl, $src2, $dst|$dst, $src2, CL}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002356 [(store (X86shld (loadi32 addr:$dst), GR32:$src2, CL),
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002357 addr:$dst)]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00002358 def SHRD32mrCL : I<0xAD, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
Eli Friedman378ea832009-06-19 04:48:38 +00002359 "shrd{l}\t{%cl, $src2, $dst|$dst, $src2, CL}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002360 [(store (X86shrd (loadi32 addr:$dst), GR32:$src2, CL),
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002361 addr:$dst)]>, TB;
2362 }
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002363 def SHLD32mri8 : Ii8<0xA4, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00002364 (outs), (ins i32mem:$dst, GR32:$src2, i8imm:$src3),
Dan Gohman91888f02007-07-31 20:11:57 +00002365 "shld{l}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002366 [(store (X86shld (loadi32 addr:$dst), GR32:$src2,
2367 (i8 imm:$src3)), addr:$dst)]>,
2368 TB;
2369 def SHRD32mri8 : Ii8<0xAC, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00002370 (outs), (ins i32mem:$dst, GR32:$src2, i8imm:$src3),
Dan Gohman91888f02007-07-31 20:11:57 +00002371 "shrd{l}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002372 [(store (X86shrd (loadi32 addr:$dst), GR32:$src2,
2373 (i8 imm:$src3)), addr:$dst)]>,
2374 TB;
2375
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002376 let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00002377 def SHLD16mrCL : I<0xA5, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
Eli Friedman378ea832009-06-19 04:48:38 +00002378 "shld{w}\t{%cl, $src2, $dst|$dst, $src2, CL}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002379 [(store (X86shld (loadi16 addr:$dst), GR16:$src2, CL),
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002380 addr:$dst)]>, TB, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002381 def SHRD16mrCL : I<0xAD, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
Eli Friedman378ea832009-06-19 04:48:38 +00002382 "shrd{w}\t{%cl, $src2, $dst|$dst, $src2, CL}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002383 [(store (X86shrd (loadi16 addr:$dst), GR16:$src2, CL),
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002384 addr:$dst)]>, TB, OpSize;
2385 }
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002386 def SHLD16mri8 : Ii8<0xA4, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00002387 (outs), (ins i16mem:$dst, GR16:$src2, i8imm:$src3),
Dan Gohman91888f02007-07-31 20:11:57 +00002388 "shld{w}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002389 [(store (X86shld (loadi16 addr:$dst), GR16:$src2,
2390 (i8 imm:$src3)), addr:$dst)]>,
2391 TB, OpSize;
2392 def SHRD16mri8 : Ii8<0xAC, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00002393 (outs), (ins i16mem:$dst, GR16:$src2, i8imm:$src3),
Dan Gohman91888f02007-07-31 20:11:57 +00002394 "shrd{w}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002395 [(store (X86shrd (loadi16 addr:$dst), GR16:$src2,
2396 (i8 imm:$src3)), addr:$dst)]>,
2397 TB, OpSize;
2398}
Evan Cheng55687072007-09-14 21:48:26 +00002399} // Defs = [EFLAGS]
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002400
2401
2402// Arithmetic.
Evan Cheng55687072007-09-14 21:48:26 +00002403let Defs = [EFLAGS] in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002404let isCommutable = 1 in { // X = ADD Y, Z --> X = ADD Z, Y
Bill Wendlingae034ed2008-12-12 00:56:36 +00002405// Register-Register Addition
2406def ADD8rr : I<0x00, MRMDestReg, (outs GR8 :$dst),
2407 (ins GR8 :$src1, GR8 :$src2),
2408 "add{b}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002409 [(set GR8:$dst, (add GR8:$src1, GR8:$src2)),
Bill Wendlingae034ed2008-12-12 00:56:36 +00002410 (implicit EFLAGS)]>;
2411
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002412let isConvertibleToThreeAddress = 1 in { // Can transform into LEA.
Bill Wendlingae034ed2008-12-12 00:56:36 +00002413// Register-Register Addition
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002414def ADD16rr : I<0x01, MRMDestReg, (outs GR16:$dst),
2415 (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002416 "add{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002417 [(set GR16:$dst, (add GR16:$src1, GR16:$src2)),
2418 (implicit EFLAGS)]>, OpSize;
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002419def ADD32rr : I<0x01, MRMDestReg, (outs GR32:$dst),
2420 (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002421 "add{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002422 [(set GR32:$dst, (add GR32:$src1, GR32:$src2)),
2423 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002424} // end isConvertibleToThreeAddress
2425} // end isCommutable
Bill Wendlingae034ed2008-12-12 00:56:36 +00002426
2427// Register-Memory Addition
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002428def ADD8rm : I<0x02, MRMSrcMem, (outs GR8 :$dst),
2429 (ins GR8 :$src1, i8mem :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002430 "add{b}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002431 [(set GR8:$dst, (add GR8:$src1, (load addr:$src2))),
2432 (implicit EFLAGS)]>;
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002433def ADD16rm : I<0x03, MRMSrcMem, (outs GR16:$dst),
2434 (ins GR16:$src1, i16mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002435 "add{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002436 [(set GR16:$dst, (add GR16:$src1, (load addr:$src2))),
2437 (implicit EFLAGS)]>, OpSize;
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002438def ADD32rm : I<0x03, MRMSrcMem, (outs GR32:$dst),
2439 (ins GR32:$src1, i32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002440 "add{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002441 [(set GR32:$dst, (add GR32:$src1, (load addr:$src2))),
2442 (implicit EFLAGS)]>;
Sean Callanan7e7df0e2009-09-15 20:53:57 +00002443
Sean Callanan84df9312009-09-15 21:43:27 +00002444// Register-Register Addition - Equivalent to the normal rr forms (ADD8rr,
2445// ADD16rr, and ADD32rr), but differently encoded.
Sean Callanan7e7df0e2009-09-15 20:53:57 +00002446def ADD8mrmrr: I<0x02, MRMSrcReg, (outs GR8:$dst), (ins GR8:$src1, GR8:$src2),
2447 "add{b}\t{$src2, $dst|$dst, $src2}", []>;
2448def ADD16mrmrr: I<0x03, MRMSrcReg,(outs GR16:$dst),(ins GR16:$src1, GR16:$src2),
2449 "add{w}\t{$src2, $dst|$dst, $src2}", []>, OpSize;
2450def ADD32mrmrr: I<0x03, MRMSrcReg,(outs GR16:$dst),(ins GR16:$src1, GR16:$src2),
2451 "add{l}\t{$src2, $dst|$dst, $src2}", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002452
Bill Wendlingae034ed2008-12-12 00:56:36 +00002453// Register-Integer Addition
2454def ADD8ri : Ii8<0x80, MRM0r, (outs GR8:$dst), (ins GR8:$src1, i8imm:$src2),
2455 "add{b}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002456 [(set GR8:$dst, (add GR8:$src1, imm:$src2)),
2457 (implicit EFLAGS)]>;
Bill Wendlingae034ed2008-12-12 00:56:36 +00002458
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002459let isConvertibleToThreeAddress = 1 in { // Can transform into LEA.
Bill Wendlingae034ed2008-12-12 00:56:36 +00002460// Register-Integer Addition
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002461def ADD16ri : Ii16<0x81, MRM0r, (outs GR16:$dst),
2462 (ins GR16:$src1, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002463 "add{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002464 [(set GR16:$dst, (add GR16:$src1, imm:$src2)),
2465 (implicit EFLAGS)]>, OpSize;
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002466def ADD32ri : Ii32<0x81, MRM0r, (outs GR32:$dst),
2467 (ins GR32:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002468 "add{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002469 [(set GR32:$dst, (add GR32:$src1, imm:$src2)),
2470 (implicit EFLAGS)]>;
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002471def ADD16ri8 : Ii8<0x83, MRM0r, (outs GR16:$dst),
2472 (ins GR16:$src1, i16i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002473 "add{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002474 [(set GR16:$dst, (add GR16:$src1, i16immSExt8:$src2)),
2475 (implicit EFLAGS)]>, OpSize;
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002476def ADD32ri8 : Ii8<0x83, MRM0r, (outs GR32:$dst),
2477 (ins GR32:$src1, i32i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002478 "add{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002479 [(set GR32:$dst, (add GR32:$src1, i32immSExt8:$src2)),
2480 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002481}
2482
2483let isTwoAddress = 0 in {
Bill Wendlingae034ed2008-12-12 00:56:36 +00002484 // Memory-Register Addition
Bill Wendlingf5399032008-12-12 21:15:41 +00002485 def ADD8mr : I<0x00, MRMDestMem, (outs), (ins i8mem:$dst, GR8:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002486 "add{b}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002487 [(store (add (load addr:$dst), GR8:$src2), addr:$dst),
2488 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002489 def ADD16mr : I<0x01, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002490 "add{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002491 [(store (add (load addr:$dst), GR16:$src2), addr:$dst),
2492 (implicit EFLAGS)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002493 def ADD32mr : I<0x01, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002494 "add{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002495 [(store (add (load addr:$dst), GR32:$src2), addr:$dst),
2496 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002497 def ADD8mi : Ii8<0x80, MRM0m, (outs), (ins i8mem :$dst, i8imm :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002498 "add{b}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002499 [(store (add (loadi8 addr:$dst), imm:$src2), addr:$dst),
2500 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002501 def ADD16mi : Ii16<0x81, MRM0m, (outs), (ins i16mem:$dst, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002502 "add{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002503 [(store (add (loadi16 addr:$dst), imm:$src2), addr:$dst),
2504 (implicit EFLAGS)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002505 def ADD32mi : Ii32<0x81, MRM0m, (outs), (ins i32mem:$dst, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002506 "add{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002507 [(store (add (loadi32 addr:$dst), imm:$src2), addr:$dst),
2508 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002509 def ADD16mi8 : Ii8<0x83, MRM0m, (outs), (ins i16mem:$dst, i16i8imm :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002510 "add{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002511 [(store (add (load addr:$dst), i16immSExt8:$src2),
2512 addr:$dst),
2513 (implicit EFLAGS)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002514 def ADD32mi8 : Ii8<0x83, MRM0m, (outs), (ins i32mem:$dst, i32i8imm :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002515 "add{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingae034ed2008-12-12 00:56:36 +00002516 [(store (add (load addr:$dst), i32immSExt8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00002517 addr:$dst),
2518 (implicit EFLAGS)]>;
Sean Callanan0316b342009-08-11 21:26:06 +00002519
2520 // addition to rAX
2521 def ADD8i8 : Ii8<0x04, RawFrm, (outs), (ins i8imm:$src),
Sean Callanan251676e2009-09-02 00:55:49 +00002522 "add{b}\t{$src, %al|%al, $src}", []>;
Sean Callanan0316b342009-08-11 21:26:06 +00002523 def ADD16i16 : Ii16<0x05, RawFrm, (outs), (ins i16imm:$src),
Sean Callanan251676e2009-09-02 00:55:49 +00002524 "add{w}\t{$src, %ax|%ax, $src}", []>, OpSize;
Sean Callanan0316b342009-08-11 21:26:06 +00002525 def ADD32i32 : Ii32<0x05, RawFrm, (outs), (ins i32imm:$src),
Sean Callanan251676e2009-09-02 00:55:49 +00002526 "add{l}\t{$src, %eax|%eax, $src}", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002527}
2528
Evan Cheng259471d2007-10-05 17:59:57 +00002529let Uses = [EFLAGS] in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002530let isCommutable = 1 in { // X = ADC Y, Z --> X = ADC Z, Y
Dale Johannesen747fe522009-06-02 03:12:52 +00002531def ADC8rr : I<0x10, MRMDestReg, (outs GR8:$dst), (ins GR8:$src1, GR8:$src2),
Dale Johannesen06b83f12009-05-18 17:44:15 +00002532 "adc{b}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002533 [(set GR8:$dst, (adde GR8:$src1, GR8:$src2))]>;
Dale Johannesen06b83f12009-05-18 17:44:15 +00002534def ADC16rr : I<0x11, MRMDestReg, (outs GR16:$dst),
2535 (ins GR16:$src1, GR16:$src2),
2536 "adc{w}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002537 [(set GR16:$dst, (adde GR16:$src1, GR16:$src2))]>, OpSize;
Dale Johannesen06b83f12009-05-18 17:44:15 +00002538def ADC32rr : I<0x11, MRMDestReg, (outs GR32:$dst),
2539 (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002540 "adc{l}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002541 [(set GR32:$dst, (adde GR32:$src1, GR32:$src2))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002542}
Dale Johannesen06b83f12009-05-18 17:44:15 +00002543def ADC8rm : I<0x12, MRMSrcMem , (outs GR8:$dst),
2544 (ins GR8:$src1, i8mem:$src2),
2545 "adc{b}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002546 [(set GR8:$dst, (adde GR8:$src1, (load addr:$src2)))]>;
Dale Johannesen06b83f12009-05-18 17:44:15 +00002547def ADC16rm : I<0x13, MRMSrcMem , (outs GR16:$dst),
2548 (ins GR16:$src1, i16mem:$src2),
2549 "adc{w}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002550 [(set GR16:$dst, (adde GR16:$src1, (load addr:$src2)))]>,
Dale Johannesen067cfb22009-05-18 21:41:59 +00002551 OpSize;
Dale Johannesen06b83f12009-05-18 17:44:15 +00002552def ADC32rm : I<0x13, MRMSrcMem , (outs GR32:$dst),
2553 (ins GR32:$src1, i32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002554 "adc{l}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002555 [(set GR32:$dst, (adde GR32:$src1, (load addr:$src2)))]>;
2556def ADC8ri : Ii8<0x80, MRM2r, (outs GR8:$dst), (ins GR8:$src1, i8imm:$src2),
Dale Johannesen06b83f12009-05-18 17:44:15 +00002557 "adc{b}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002558 [(set GR8:$dst, (adde GR8:$src1, imm:$src2))]>;
Dale Johannesen06b83f12009-05-18 17:44:15 +00002559def ADC16ri : Ii16<0x81, MRM2r, (outs GR16:$dst),
2560 (ins GR16:$src1, i16imm:$src2),
2561 "adc{w}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002562 [(set GR16:$dst, (adde GR16:$src1, imm:$src2))]>, OpSize;
Dale Johannesen06b83f12009-05-18 17:44:15 +00002563def ADC16ri8 : Ii8<0x83, MRM2r, (outs GR16:$dst),
2564 (ins GR16:$src1, i16i8imm:$src2),
2565 "adc{w}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002566 [(set GR16:$dst, (adde GR16:$src1, i16immSExt8:$src2))]>,
2567 OpSize;
Dale Johannesen06b83f12009-05-18 17:44:15 +00002568def ADC32ri : Ii32<0x81, MRM2r, (outs GR32:$dst),
2569 (ins GR32:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002570 "adc{l}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002571 [(set GR32:$dst, (adde GR32:$src1, imm:$src2))]>;
Dale Johannesen06b83f12009-05-18 17:44:15 +00002572def ADC32ri8 : Ii8<0x83, MRM2r, (outs GR32:$dst),
2573 (ins GR32:$src1, i32i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002574 "adc{l}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002575 [(set GR32:$dst, (adde GR32:$src1, i32immSExt8:$src2))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002576
2577let isTwoAddress = 0 in {
Dale Johannesen747fe522009-06-02 03:12:52 +00002578 def ADC8mr : I<0x10, MRMDestMem, (outs), (ins i8mem:$dst, GR8:$src2),
Dale Johannesen06b83f12009-05-18 17:44:15 +00002579 "adc{b}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002580 [(store (adde (load addr:$dst), GR8:$src2), addr:$dst)]>;
2581 def ADC16mr : I<0x11, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
Dale Johannesen06b83f12009-05-18 17:44:15 +00002582 "adc{w}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002583 [(store (adde (load addr:$dst), GR16:$src2), addr:$dst)]>,
2584 OpSize;
2585 def ADC32mr : I<0x11, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002586 "adc{l}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002587 [(store (adde (load addr:$dst), GR32:$src2), addr:$dst)]>;
2588 def ADC8mi : Ii8<0x80, MRM2m, (outs), (ins i8mem:$dst, i8imm:$src2),
Dale Johannesen06b83f12009-05-18 17:44:15 +00002589 "adc{b}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002590 [(store (adde (loadi8 addr:$dst), imm:$src2), addr:$dst)]>;
2591 def ADC16mi : Ii16<0x81, MRM2m, (outs), (ins i16mem:$dst, i16imm:$src2),
Dale Johannesen06b83f12009-05-18 17:44:15 +00002592 "adc{w}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002593 [(store (adde (loadi16 addr:$dst), imm:$src2), addr:$dst)]>,
2594 OpSize;
2595 def ADC16mi8 : Ii8<0x83, MRM2m, (outs), (ins i16mem:$dst, i16i8imm :$src2),
Dale Johannesen06b83f12009-05-18 17:44:15 +00002596 "adc{w}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002597 [(store (adde (load addr:$dst), i16immSExt8:$src2), addr:$dst)]>,
2598 OpSize;
2599 def ADC32mi : Ii32<0x81, MRM2m, (outs), (ins i32mem:$dst, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002600 "adc{l}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002601 [(store (adde (loadi32 addr:$dst), imm:$src2), addr:$dst)]>;
2602 def ADC32mi8 : Ii8<0x83, MRM2m, (outs), (ins i32mem:$dst, i32i8imm :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002603 "adc{l}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002604 [(store (adde (load addr:$dst), i32immSExt8:$src2), addr:$dst)]>;
Sean Callanan8562bef2009-09-11 19:01:56 +00002605
2606 def ADC8i8 : Ii8<0x14, RawFrm, (outs), (ins i8imm:$src),
2607 "adc{b}\t{$src, %al|%al, $src}", []>;
2608 def ADC16i16 : Ii16<0x15, RawFrm, (outs), (ins i16imm:$src),
2609 "adc{w}\t{$src, %ax|%ax, $src}", []>, OpSize;
2610 def ADC32i32 : Ii32<0x15, RawFrm, (outs), (ins i32imm:$src),
2611 "adc{l}\t{$src, %eax|%eax, $src}", []>;
Dale Johannesen747fe522009-06-02 03:12:52 +00002612}
Evan Cheng259471d2007-10-05 17:59:57 +00002613} // Uses = [EFLAGS]
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002614
Bill Wendlingae034ed2008-12-12 00:56:36 +00002615// Register-Register Subtraction
2616def SUB8rr : I<0x28, MRMDestReg, (outs GR8:$dst), (ins GR8:$src1, GR8:$src2),
2617 "sub{b}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002618 [(set GR8:$dst, (sub GR8:$src1, GR8:$src2)),
2619 (implicit EFLAGS)]>;
Bill Wendlingae034ed2008-12-12 00:56:36 +00002620def SUB16rr : I<0x29, MRMDestReg, (outs GR16:$dst), (ins GR16:$src1,GR16:$src2),
2621 "sub{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002622 [(set GR16:$dst, (sub GR16:$src1, GR16:$src2)),
2623 (implicit EFLAGS)]>, OpSize;
Bill Wendlingae034ed2008-12-12 00:56:36 +00002624def SUB32rr : I<0x29, MRMDestReg, (outs GR32:$dst), (ins GR32:$src1,GR32:$src2),
2625 "sub{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002626 [(set GR32:$dst, (sub GR32:$src1, GR32:$src2)),
2627 (implicit EFLAGS)]>;
Bill Wendlingae034ed2008-12-12 00:56:36 +00002628
2629// Register-Memory Subtraction
2630def SUB8rm : I<0x2A, MRMSrcMem, (outs GR8 :$dst),
2631 (ins GR8 :$src1, i8mem :$src2),
2632 "sub{b}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002633 [(set GR8:$dst, (sub GR8:$src1, (load addr:$src2))),
2634 (implicit EFLAGS)]>;
Bill Wendlingae034ed2008-12-12 00:56:36 +00002635def SUB16rm : I<0x2B, MRMSrcMem, (outs GR16:$dst),
2636 (ins GR16:$src1, i16mem:$src2),
2637 "sub{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002638 [(set GR16:$dst, (sub GR16:$src1, (load addr:$src2))),
2639 (implicit EFLAGS)]>, OpSize;
Bill Wendlingae034ed2008-12-12 00:56:36 +00002640def SUB32rm : I<0x2B, MRMSrcMem, (outs GR32:$dst),
2641 (ins GR32:$src1, i32mem:$src2),
2642 "sub{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002643 [(set GR32:$dst, (sub GR32:$src1, (load addr:$src2))),
2644 (implicit EFLAGS)]>;
Bill Wendlingae034ed2008-12-12 00:56:36 +00002645
2646// Register-Integer Subtraction
2647def SUB8ri : Ii8 <0x80, MRM5r, (outs GR8:$dst),
2648 (ins GR8:$src1, i8imm:$src2),
2649 "sub{b}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002650 [(set GR8:$dst, (sub GR8:$src1, imm:$src2)),
2651 (implicit EFLAGS)]>;
Bill Wendlingae034ed2008-12-12 00:56:36 +00002652def SUB16ri : Ii16<0x81, MRM5r, (outs GR16:$dst),
2653 (ins GR16:$src1, i16imm:$src2),
2654 "sub{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002655 [(set GR16:$dst, (sub GR16:$src1, imm:$src2)),
2656 (implicit EFLAGS)]>, OpSize;
Bill Wendlingae034ed2008-12-12 00:56:36 +00002657def SUB32ri : Ii32<0x81, MRM5r, (outs GR32:$dst),
2658 (ins GR32:$src1, i32imm:$src2),
2659 "sub{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002660 [(set GR32:$dst, (sub GR32:$src1, imm:$src2)),
2661 (implicit EFLAGS)]>;
Bill Wendlingae034ed2008-12-12 00:56:36 +00002662def SUB16ri8 : Ii8<0x83, MRM5r, (outs GR16:$dst),
2663 (ins GR16:$src1, i16i8imm:$src2),
2664 "sub{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002665 [(set GR16:$dst, (sub GR16:$src1, i16immSExt8:$src2)),
2666 (implicit EFLAGS)]>, OpSize;
Bill Wendlingae034ed2008-12-12 00:56:36 +00002667def SUB32ri8 : Ii8<0x83, MRM5r, (outs GR32:$dst),
2668 (ins GR32:$src1, i32i8imm:$src2),
2669 "sub{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002670 [(set GR32:$dst, (sub GR32:$src1, i32immSExt8:$src2)),
2671 (implicit EFLAGS)]>;
Bill Wendlingae034ed2008-12-12 00:56:36 +00002672
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002673let isTwoAddress = 0 in {
Bill Wendlingae034ed2008-12-12 00:56:36 +00002674 // Memory-Register Subtraction
Evan Chengb783fa32007-07-19 01:14:50 +00002675 def SUB8mr : I<0x28, MRMDestMem, (outs), (ins i8mem :$dst, GR8 :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002676 "sub{b}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002677 [(store (sub (load addr:$dst), GR8:$src2), addr:$dst),
2678 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002679 def SUB16mr : I<0x29, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002680 "sub{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002681 [(store (sub (load addr:$dst), GR16:$src2), addr:$dst),
2682 (implicit EFLAGS)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002683 def SUB32mr : I<0x29, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002684 "sub{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002685 [(store (sub (load addr:$dst), GR32:$src2), addr:$dst),
2686 (implicit EFLAGS)]>;
Bill Wendlingae034ed2008-12-12 00:56:36 +00002687
2688 // Memory-Integer Subtraction
Evan Chengb783fa32007-07-19 01:14:50 +00002689 def SUB8mi : Ii8<0x80, MRM5m, (outs), (ins i8mem :$dst, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002690 "sub{b}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002691 [(store (sub (loadi8 addr:$dst), imm:$src2), addr:$dst),
2692 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002693 def SUB16mi : Ii16<0x81, MRM5m, (outs), (ins i16mem:$dst, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002694 "sub{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002695 [(store (sub (loadi16 addr:$dst), imm:$src2),addr:$dst),
2696 (implicit EFLAGS)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002697 def SUB32mi : Ii32<0x81, MRM5m, (outs), (ins i32mem:$dst, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002698 "sub{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002699 [(store (sub (loadi32 addr:$dst), imm:$src2),addr:$dst),
2700 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002701 def SUB16mi8 : Ii8<0x83, MRM5m, (outs), (ins i16mem:$dst, i16i8imm :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002702 "sub{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingae034ed2008-12-12 00:56:36 +00002703 [(store (sub (load addr:$dst), i16immSExt8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00002704 addr:$dst),
2705 (implicit EFLAGS)]>, OpSize;
Bill Wendlingae034ed2008-12-12 00:56:36 +00002706 def SUB32mi8 : Ii8<0x83, MRM5m, (outs), (ins i32mem:$dst, i32i8imm :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002707 "sub{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingae034ed2008-12-12 00:56:36 +00002708 [(store (sub (load addr:$dst), i32immSExt8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00002709 addr:$dst),
2710 (implicit EFLAGS)]>;
Sean Callanan8562bef2009-09-11 19:01:56 +00002711
2712 def SUB8i8 : Ii8<0x2C, RawFrm, (outs), (ins i8imm:$src),
2713 "sub{b}\t{$src, %al|%al, $src}", []>;
2714 def SUB16i16 : Ii16<0x2D, RawFrm, (outs), (ins i16imm:$src),
2715 "sub{w}\t{$src, %ax|%ax, $src}", []>, OpSize;
2716 def SUB32i32 : Ii32<0x2D, RawFrm, (outs), (ins i32imm:$src),
2717 "sub{l}\t{$src, %eax|%eax, $src}", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002718}
2719
Evan Cheng259471d2007-10-05 17:59:57 +00002720let Uses = [EFLAGS] in {
Dale Johannesen06b83f12009-05-18 17:44:15 +00002721def SBB8rr : I<0x18, MRMDestReg, (outs GR8:$dst),
2722 (ins GR8:$src1, GR8:$src2),
2723 "sbb{b}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002724 [(set GR8:$dst, (sube GR8:$src1, GR8:$src2))]>;
Dale Johannesen06b83f12009-05-18 17:44:15 +00002725def SBB16rr : I<0x19, MRMDestReg, (outs GR16:$dst),
2726 (ins GR16:$src1, GR16:$src2),
2727 "sbb{w}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002728 [(set GR16:$dst, (sube GR16:$src1, GR16:$src2))]>, OpSize;
Dale Johannesen06b83f12009-05-18 17:44:15 +00002729def SBB32rr : I<0x19, MRMDestReg, (outs GR32:$dst),
2730 (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002731 "sbb{l}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002732 [(set GR32:$dst, (sube GR32:$src1, GR32:$src2))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002733
2734let isTwoAddress = 0 in {
Dale Johannesen06b83f12009-05-18 17:44:15 +00002735 def SBB8mr : I<0x18, MRMDestMem, (outs), (ins i8mem:$dst, GR8:$src2),
2736 "sbb{b}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002737 [(store (sube (load addr:$dst), GR8:$src2), addr:$dst)]>;
Dale Johannesen06b83f12009-05-18 17:44:15 +00002738 def SBB16mr : I<0x19, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
2739 "sbb{w}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002740 [(store (sube (load addr:$dst), GR16:$src2), addr:$dst)]>,
Dale Johannesen067cfb22009-05-18 21:41:59 +00002741 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002742 def SBB32mr : I<0x19, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002743 "sbb{l}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002744 [(store (sube (load addr:$dst), GR32:$src2), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002745 def SBB8mi : Ii32<0x80, MRM3m, (outs), (ins i8mem:$dst, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002746 "sbb{b}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002747 [(store (sube (loadi8 addr:$dst), imm:$src2), addr:$dst)]>;
Dale Johannesen06b83f12009-05-18 17:44:15 +00002748 def SBB16mi : Ii16<0x81, MRM3m, (outs), (ins i16mem:$dst, i16imm:$src2),
2749 "sbb{w}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002750 [(store (sube (loadi16 addr:$dst), imm:$src2), addr:$dst)]>,
Dale Johannesen067cfb22009-05-18 21:41:59 +00002751 OpSize;
Dale Johannesen06b83f12009-05-18 17:44:15 +00002752 def SBB16mi8 : Ii8<0x83, MRM3m, (outs), (ins i16mem:$dst, i16i8imm :$src2),
2753 "sbb{w}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002754 [(store (sube (load addr:$dst), i16immSExt8:$src2), addr:$dst)]>,
Dale Johannesen067cfb22009-05-18 21:41:59 +00002755 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002756 def SBB32mi : Ii32<0x81, MRM3m, (outs), (ins i32mem:$dst, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002757 "sbb{l}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002758 [(store (sube (loadi32 addr:$dst), imm:$src2), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002759 def SBB32mi8 : Ii8<0x83, MRM3m, (outs), (ins i32mem:$dst, i32i8imm :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002760 "sbb{l}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002761 [(store (sube (load addr:$dst), i32immSExt8:$src2), addr:$dst)]>;
Sean Callanan8562bef2009-09-11 19:01:56 +00002762
2763 def SBB8i8 : Ii8<0x1C, RawFrm, (outs), (ins i8imm:$src),
2764 "sbb{b}\t{$src, %al|%al, $src}", []>;
2765 def SBB16i16 : Ii16<0x1D, RawFrm, (outs), (ins i16imm:$src),
2766 "sbb{w}\t{$src, %ax|%ax, $src}", []>, OpSize;
2767 def SBB32i32 : Ii32<0x1D, RawFrm, (outs), (ins i32imm:$src),
2768 "sbb{l}\t{$src, %eax|%eax, $src}", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002769}
Dale Johannesen06b83f12009-05-18 17:44:15 +00002770def SBB8rm : I<0x1A, MRMSrcMem, (outs GR8:$dst), (ins GR8:$src1, i8mem:$src2),
2771 "sbb{b}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002772 [(set GR8:$dst, (sube GR8:$src1, (load addr:$src2)))]>;
Dale Johannesen06b83f12009-05-18 17:44:15 +00002773def SBB16rm : I<0x1B, MRMSrcMem, (outs GR16:$dst),
2774 (ins GR16:$src1, i16mem:$src2),
2775 "sbb{w}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002776 [(set GR16:$dst, (sube GR16:$src1, (load addr:$src2)))]>,
Dale Johannesen067cfb22009-05-18 21:41:59 +00002777 OpSize;
Dale Johannesen06b83f12009-05-18 17:44:15 +00002778def SBB32rm : I<0x1B, MRMSrcMem, (outs GR32:$dst),
2779 (ins GR32:$src1, i32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002780 "sbb{l}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002781 [(set GR32:$dst, (sube GR32:$src1, (load addr:$src2)))]>;
Dale Johannesen06b83f12009-05-18 17:44:15 +00002782def SBB8ri : Ii8<0x80, MRM3r, (outs GR8:$dst), (ins GR8:$src1, i8imm:$src2),
2783 "sbb{b}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002784 [(set GR8:$dst, (sube GR8:$src1, imm:$src2))]>;
Dale Johannesen06b83f12009-05-18 17:44:15 +00002785def SBB16ri : Ii16<0x81, MRM3r, (outs GR16:$dst),
2786 (ins GR16:$src1, i16imm:$src2),
2787 "sbb{w}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002788 [(set GR16:$dst, (sube GR16:$src1, imm:$src2))]>, OpSize;
Dale Johannesen06b83f12009-05-18 17:44:15 +00002789def SBB16ri8 : Ii8<0x83, MRM3r, (outs GR16:$dst),
2790 (ins GR16:$src1, i16i8imm:$src2),
2791 "sbb{w}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002792 [(set GR16:$dst, (sube GR16:$src1, i16immSExt8:$src2))]>,
2793 OpSize;
Dale Johannesen06b83f12009-05-18 17:44:15 +00002794def SBB32ri : Ii32<0x81, MRM3r, (outs GR32:$dst),
2795 (ins GR32:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002796 "sbb{l}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002797 [(set GR32:$dst, (sube GR32:$src1, imm:$src2))]>;
Dale Johannesen06b83f12009-05-18 17:44:15 +00002798def SBB32ri8 : Ii8<0x83, MRM3r, (outs GR32:$dst),
2799 (ins GR32:$src1, i32i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002800 "sbb{l}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002801 [(set GR32:$dst, (sube GR32:$src1, i32immSExt8:$src2))]>;
Evan Cheng259471d2007-10-05 17:59:57 +00002802} // Uses = [EFLAGS]
Evan Cheng55687072007-09-14 21:48:26 +00002803} // Defs = [EFLAGS]
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002804
Evan Cheng55687072007-09-14 21:48:26 +00002805let Defs = [EFLAGS] in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002806let isCommutable = 1 in { // X = IMUL Y, Z --> X = IMUL Z, Y
Bill Wendlingf5399032008-12-12 21:15:41 +00002807// Register-Register Signed Integer Multiply
Bill Wendlingae034ed2008-12-12 00:56:36 +00002808def IMUL16rr : I<0xAF, MRMSrcReg, (outs GR16:$dst), (ins GR16:$src1,GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002809 "imul{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002810 [(set GR16:$dst, (mul GR16:$src1, GR16:$src2)),
2811 (implicit EFLAGS)]>, TB, OpSize;
Bill Wendlingae034ed2008-12-12 00:56:36 +00002812def IMUL32rr : I<0xAF, MRMSrcReg, (outs GR32:$dst), (ins GR32:$src1,GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002813 "imul{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002814 [(set GR32:$dst, (mul GR32:$src1, GR32:$src2)),
2815 (implicit EFLAGS)]>, TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002816}
Bill Wendlingae034ed2008-12-12 00:56:36 +00002817
Bill Wendlingf5399032008-12-12 21:15:41 +00002818// Register-Memory Signed Integer Multiply
Bill Wendlingae034ed2008-12-12 00:56:36 +00002819def IMUL16rm : I<0xAF, MRMSrcMem, (outs GR16:$dst),
2820 (ins GR16:$src1, i16mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002821 "imul{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002822 [(set GR16:$dst, (mul GR16:$src1, (load addr:$src2))),
2823 (implicit EFLAGS)]>, TB, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002824def IMUL32rm : I<0xAF, MRMSrcMem, (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002825 "imul{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002826 [(set GR32:$dst, (mul GR32:$src1, (load addr:$src2))),
2827 (implicit EFLAGS)]>, TB;
Evan Cheng55687072007-09-14 21:48:26 +00002828} // Defs = [EFLAGS]
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002829} // end Two Address instructions
2830
2831// Suprisingly enough, these are not two address instructions!
Evan Cheng55687072007-09-14 21:48:26 +00002832let Defs = [EFLAGS] in {
Bill Wendlingf5399032008-12-12 21:15:41 +00002833// Register-Integer Signed Integer Multiply
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002834def IMUL16rri : Ii16<0x69, MRMSrcReg, // GR16 = GR16*I16
Evan Chengb783fa32007-07-19 01:14:50 +00002835 (outs GR16:$dst), (ins GR16:$src1, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002836 "imul{w}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002837 [(set GR16:$dst, (mul GR16:$src1, imm:$src2)),
2838 (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002839def IMUL32rri : Ii32<0x69, MRMSrcReg, // GR32 = GR32*I32
Evan Chengb783fa32007-07-19 01:14:50 +00002840 (outs GR32:$dst), (ins GR32:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002841 "imul{l}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002842 [(set GR32:$dst, (mul GR32:$src1, imm:$src2)),
2843 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002844def IMUL16rri8 : Ii8<0x6B, MRMSrcReg, // GR16 = GR16*I8
Evan Chengb783fa32007-07-19 01:14:50 +00002845 (outs GR16:$dst), (ins GR16:$src1, i16i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002846 "imul{w}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002847 [(set GR16:$dst, (mul GR16:$src1, i16immSExt8:$src2)),
2848 (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002849def IMUL32rri8 : Ii8<0x6B, MRMSrcReg, // GR32 = GR32*I8
Evan Chengb783fa32007-07-19 01:14:50 +00002850 (outs GR32:$dst), (ins GR32:$src1, i32i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002851 "imul{l}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002852 [(set GR32:$dst, (mul GR32:$src1, i32immSExt8:$src2)),
2853 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002854
Bill Wendlingf5399032008-12-12 21:15:41 +00002855// Memory-Integer Signed Integer Multiply
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002856def IMUL16rmi : Ii16<0x69, MRMSrcMem, // GR16 = [mem16]*I16
Evan Chengb783fa32007-07-19 01:14:50 +00002857 (outs GR16:$dst), (ins i16mem:$src1, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002858 "imul{w}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002859 [(set GR16:$dst, (mul (load addr:$src1), imm:$src2)),
2860 (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002861def IMUL32rmi : Ii32<0x69, MRMSrcMem, // GR32 = [mem32]*I32
Evan Chengb783fa32007-07-19 01:14:50 +00002862 (outs GR32:$dst), (ins i32mem:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002863 "imul{l}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002864 [(set GR32:$dst, (mul (load addr:$src1), imm:$src2)),
2865 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002866def IMUL16rmi8 : Ii8<0x6B, MRMSrcMem, // GR16 = [mem16]*I8
Evan Chengb783fa32007-07-19 01:14:50 +00002867 (outs GR16:$dst), (ins i16mem:$src1, i16i8imm :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002868 "imul{w}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Bill Wendlingae034ed2008-12-12 00:56:36 +00002869 [(set GR16:$dst, (mul (load addr:$src1),
Bill Wendlingf5399032008-12-12 21:15:41 +00002870 i16immSExt8:$src2)),
2871 (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002872def IMUL32rmi8 : Ii8<0x6B, MRMSrcMem, // GR32 = [mem32]*I8
Evan Chengb783fa32007-07-19 01:14:50 +00002873 (outs GR32:$dst), (ins i32mem:$src1, i32i8imm: $src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002874 "imul{l}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Bill Wendlingae034ed2008-12-12 00:56:36 +00002875 [(set GR32:$dst, (mul (load addr:$src1),
Bill Wendlingf5399032008-12-12 21:15:41 +00002876 i32immSExt8:$src2)),
2877 (implicit EFLAGS)]>;
Evan Cheng55687072007-09-14 21:48:26 +00002878} // Defs = [EFLAGS]
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002879
2880//===----------------------------------------------------------------------===//
2881// Test instructions are just like AND, except they don't generate a result.
2882//
Evan Cheng950aac02007-09-25 01:57:46 +00002883let Defs = [EFLAGS] in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002884let isCommutable = 1 in { // TEST X, Y --> TEST Y, X
Evan Chengb783fa32007-07-19 01:14:50 +00002885def TEST8rr : I<0x84, MRMDestReg, (outs), (ins GR8:$src1, GR8:$src2),
Evan Cheng621216e2007-09-29 00:00:36 +00002886 "test{b}\t{$src2, $src1|$src1, $src2}",
Chris Lattner21da6382008-02-19 17:37:35 +00002887 [(X86cmp (and_su GR8:$src1, GR8:$src2), 0),
Evan Cheng621216e2007-09-29 00:00:36 +00002888 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002889def TEST16rr : I<0x85, MRMDestReg, (outs), (ins GR16:$src1, GR16:$src2),
Evan Cheng621216e2007-09-29 00:00:36 +00002890 "test{w}\t{$src2, $src1|$src1, $src2}",
Chris Lattner21da6382008-02-19 17:37:35 +00002891 [(X86cmp (and_su GR16:$src1, GR16:$src2), 0),
Evan Cheng621216e2007-09-29 00:00:36 +00002892 (implicit EFLAGS)]>,
2893 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002894def TEST32rr : I<0x85, MRMDestReg, (outs), (ins GR32:$src1, GR32:$src2),
Evan Cheng621216e2007-09-29 00:00:36 +00002895 "test{l}\t{$src2, $src1|$src1, $src2}",
Chris Lattner21da6382008-02-19 17:37:35 +00002896 [(X86cmp (and_su GR32:$src1, GR32:$src2), 0),
Evan Cheng621216e2007-09-29 00:00:36 +00002897 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002898}
2899
Sean Callanan3e4b1a32009-09-01 18:14:18 +00002900def TEST8i8 : Ii8<0xA8, RawFrm, (outs), (ins i8imm:$src),
2901 "test{b}\t{$src, %al|%al, $src}", []>;
2902def TEST16i16 : Ii16<0xA9, RawFrm, (outs), (ins i16imm:$src),
2903 "test{w}\t{$src, %ax|%ax, $src}", []>, OpSize;
2904def TEST32i32 : Ii32<0xA9, RawFrm, (outs), (ins i32imm:$src),
2905 "test{l}\t{$src, %eax|%eax, $src}", []>;
2906
Evan Chengb783fa32007-07-19 01:14:50 +00002907def TEST8rm : I<0x84, MRMSrcMem, (outs), (ins GR8 :$src1, i8mem :$src2),
Evan Cheng621216e2007-09-29 00:00:36 +00002908 "test{b}\t{$src2, $src1|$src1, $src2}",
2909 [(X86cmp (and GR8:$src1, (loadi8 addr:$src2)), 0),
2910 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002911def TEST16rm : I<0x85, MRMSrcMem, (outs), (ins GR16:$src1, i16mem:$src2),
Evan Cheng621216e2007-09-29 00:00:36 +00002912 "test{w}\t{$src2, $src1|$src1, $src2}",
2913 [(X86cmp (and GR16:$src1, (loadi16 addr:$src2)), 0),
2914 (implicit EFLAGS)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002915def TEST32rm : I<0x85, MRMSrcMem, (outs), (ins GR32:$src1, i32mem:$src2),
Evan Cheng621216e2007-09-29 00:00:36 +00002916 "test{l}\t{$src2, $src1|$src1, $src2}",
2917 [(X86cmp (and GR32:$src1, (loadi32 addr:$src2)), 0),
2918 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002919
2920def TEST8ri : Ii8 <0xF6, MRM0r, // flags = GR8 & imm8
Evan Chengb783fa32007-07-19 01:14:50 +00002921 (outs), (ins GR8:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002922 "test{b}\t{$src2, $src1|$src1, $src2}",
Chris Lattner21da6382008-02-19 17:37:35 +00002923 [(X86cmp (and_su GR8:$src1, imm:$src2), 0),
Evan Cheng621216e2007-09-29 00:00:36 +00002924 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002925def TEST16ri : Ii16<0xF7, MRM0r, // flags = GR16 & imm16
Evan Chengb783fa32007-07-19 01:14:50 +00002926 (outs), (ins GR16:$src1, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002927 "test{w}\t{$src2, $src1|$src1, $src2}",
Chris Lattner21da6382008-02-19 17:37:35 +00002928 [(X86cmp (and_su GR16:$src1, imm:$src2), 0),
Evan Cheng621216e2007-09-29 00:00:36 +00002929 (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002930def TEST32ri : Ii32<0xF7, MRM0r, // flags = GR32 & imm32
Evan Chengb783fa32007-07-19 01:14:50 +00002931 (outs), (ins GR32:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002932 "test{l}\t{$src2, $src1|$src1, $src2}",
Chris Lattner21da6382008-02-19 17:37:35 +00002933 [(X86cmp (and_su GR32:$src1, imm:$src2), 0),
Evan Cheng621216e2007-09-29 00:00:36 +00002934 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002935
Evan Cheng621216e2007-09-29 00:00:36 +00002936def TEST8mi : Ii8 <0xF6, MRM0m, // flags = [mem8] & imm8
Evan Chengb783fa32007-07-19 01:14:50 +00002937 (outs), (ins i8mem:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002938 "test{b}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002939 [(X86cmp (and (loadi8 addr:$src1), imm:$src2), 0),
2940 (implicit EFLAGS)]>;
2941def TEST16mi : Ii16<0xF7, MRM0m, // flags = [mem16] & imm16
Evan Chengb783fa32007-07-19 01:14:50 +00002942 (outs), (ins i16mem:$src1, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002943 "test{w}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002944 [(X86cmp (and (loadi16 addr:$src1), imm:$src2), 0),
2945 (implicit EFLAGS)]>, OpSize;
2946def TEST32mi : Ii32<0xF7, MRM0m, // flags = [mem32] & imm32
Evan Chengb783fa32007-07-19 01:14:50 +00002947 (outs), (ins i32mem:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002948 "test{l}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002949 [(X86cmp (and (loadi32 addr:$src1), imm:$src2), 0),
Evan Cheng950aac02007-09-25 01:57:46 +00002950 (implicit EFLAGS)]>;
2951} // Defs = [EFLAGS]
2952
2953
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002954// Condition code ops, incl. set if equal/not equal/...
Chris Lattnerc90ee9c2008-01-10 07:59:24 +00002955let Defs = [EFLAGS], Uses = [AH], neverHasSideEffects = 1 in
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002956def SAHF : I<0x9E, RawFrm, (outs), (ins), "sahf", []>; // flags = AH
Chris Lattnerc90ee9c2008-01-10 07:59:24 +00002957let Defs = [AH], Uses = [EFLAGS], neverHasSideEffects = 1 in
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002958def LAHF : I<0x9F, RawFrm, (outs), (ins), "lahf", []>; // AH = flags
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002959
Evan Cheng950aac02007-09-25 01:57:46 +00002960let Uses = [EFLAGS] in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002961def SETEr : I<0x94, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00002962 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002963 "sete\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002964 [(set GR8:$dst, (X86setcc X86_COND_E, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002965 TB; // GR8 = ==
2966def SETEm : I<0x94, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00002967 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002968 "sete\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002969 [(store (X86setcc X86_COND_E, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002970 TB; // [mem8] = ==
Bill Wendling0c52d0a2008-12-02 00:07:05 +00002971
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002972def SETNEr : I<0x95, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00002973 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002974 "setne\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002975 [(set GR8:$dst, (X86setcc X86_COND_NE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002976 TB; // GR8 = !=
2977def SETNEm : I<0x95, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00002978 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002979 "setne\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002980 [(store (X86setcc X86_COND_NE, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002981 TB; // [mem8] = !=
Bill Wendling0c52d0a2008-12-02 00:07:05 +00002982
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002983def SETLr : I<0x9C, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00002984 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002985 "setl\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002986 [(set GR8:$dst, (X86setcc X86_COND_L, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002987 TB; // GR8 = < signed
2988def SETLm : I<0x9C, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00002989 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002990 "setl\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002991 [(store (X86setcc X86_COND_L, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002992 TB; // [mem8] = < signed
Bill Wendling0c52d0a2008-12-02 00:07:05 +00002993
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002994def SETGEr : I<0x9D, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00002995 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002996 "setge\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002997 [(set GR8:$dst, (X86setcc X86_COND_GE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002998 TB; // GR8 = >= signed
2999def SETGEm : I<0x9D, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00003000 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00003001 "setge\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00003002 [(store (X86setcc X86_COND_GE, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003003 TB; // [mem8] = >= signed
Bill Wendling0c52d0a2008-12-02 00:07:05 +00003004
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003005def SETLEr : I<0x9E, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00003006 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00003007 "setle\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00003008 [(set GR8:$dst, (X86setcc X86_COND_LE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003009 TB; // GR8 = <= signed
3010def SETLEm : I<0x9E, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00003011 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00003012 "setle\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00003013 [(store (X86setcc X86_COND_LE, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003014 TB; // [mem8] = <= signed
Bill Wendling0c52d0a2008-12-02 00:07:05 +00003015
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003016def SETGr : I<0x9F, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00003017 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00003018 "setg\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00003019 [(set GR8:$dst, (X86setcc X86_COND_G, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003020 TB; // GR8 = > signed
3021def SETGm : I<0x9F, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00003022 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00003023 "setg\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00003024 [(store (X86setcc X86_COND_G, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003025 TB; // [mem8] = > signed
3026
3027def SETBr : I<0x92, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00003028 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00003029 "setb\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00003030 [(set GR8:$dst, (X86setcc X86_COND_B, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003031 TB; // GR8 = < unsign
3032def SETBm : I<0x92, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00003033 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00003034 "setb\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00003035 [(store (X86setcc X86_COND_B, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003036 TB; // [mem8] = < unsign
Bill Wendling0c52d0a2008-12-02 00:07:05 +00003037
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003038def SETAEr : I<0x93, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00003039 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00003040 "setae\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00003041 [(set GR8:$dst, (X86setcc X86_COND_AE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003042 TB; // GR8 = >= unsign
3043def SETAEm : I<0x93, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00003044 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00003045 "setae\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00003046 [(store (X86setcc X86_COND_AE, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003047 TB; // [mem8] = >= unsign
Bill Wendling0c52d0a2008-12-02 00:07:05 +00003048
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003049def SETBEr : I<0x96, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00003050 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00003051 "setbe\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00003052 [(set GR8:$dst, (X86setcc X86_COND_BE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003053 TB; // GR8 = <= unsign
3054def SETBEm : I<0x96, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00003055 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00003056 "setbe\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00003057 [(store (X86setcc X86_COND_BE, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003058 TB; // [mem8] = <= unsign
Bill Wendling0c52d0a2008-12-02 00:07:05 +00003059
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003060def SETAr : I<0x97, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00003061 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00003062 "seta\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00003063 [(set GR8:$dst, (X86setcc X86_COND_A, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003064 TB; // GR8 = > signed
3065def SETAm : I<0x97, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00003066 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00003067 "seta\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00003068 [(store (X86setcc X86_COND_A, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003069 TB; // [mem8] = > signed
3070
3071def SETSr : I<0x98, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00003072 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00003073 "sets\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00003074 [(set GR8:$dst, (X86setcc X86_COND_S, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003075 TB; // GR8 = <sign bit>
3076def SETSm : I<0x98, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00003077 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00003078 "sets\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00003079 [(store (X86setcc X86_COND_S, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003080 TB; // [mem8] = <sign bit>
3081def SETNSr : I<0x99, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00003082 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00003083 "setns\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00003084 [(set GR8:$dst, (X86setcc X86_COND_NS, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003085 TB; // GR8 = !<sign bit>
3086def SETNSm : I<0x99, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00003087 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00003088 "setns\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00003089 [(store (X86setcc X86_COND_NS, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003090 TB; // [mem8] = !<sign bit>
Bill Wendling0c52d0a2008-12-02 00:07:05 +00003091
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003092def SETPr : I<0x9A, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00003093 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00003094 "setp\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00003095 [(set GR8:$dst, (X86setcc X86_COND_P, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003096 TB; // GR8 = parity
3097def SETPm : I<0x9A, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00003098 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00003099 "setp\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00003100 [(store (X86setcc X86_COND_P, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003101 TB; // [mem8] = parity
3102def SETNPr : I<0x9B, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00003103 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00003104 "setnp\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00003105 [(set GR8:$dst, (X86setcc X86_COND_NP, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003106 TB; // GR8 = not parity
3107def SETNPm : I<0x9B, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00003108 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00003109 "setnp\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00003110 [(store (X86setcc X86_COND_NP, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003111 TB; // [mem8] = not parity
Bill Wendling0c52d0a2008-12-02 00:07:05 +00003112
3113def SETOr : I<0x90, MRM0r,
3114 (outs GR8 :$dst), (ins),
3115 "seto\t$dst",
3116 [(set GR8:$dst, (X86setcc X86_COND_O, EFLAGS))]>,
3117 TB; // GR8 = overflow
3118def SETOm : I<0x90, MRM0m,
3119 (outs), (ins i8mem:$dst),
3120 "seto\t$dst",
3121 [(store (X86setcc X86_COND_O, EFLAGS), addr:$dst)]>,
3122 TB; // [mem8] = overflow
3123def SETNOr : I<0x91, MRM0r,
3124 (outs GR8 :$dst), (ins),
3125 "setno\t$dst",
3126 [(set GR8:$dst, (X86setcc X86_COND_NO, EFLAGS))]>,
3127 TB; // GR8 = not overflow
3128def SETNOm : I<0x91, MRM0m,
3129 (outs), (ins i8mem:$dst),
3130 "setno\t$dst",
3131 [(store (X86setcc X86_COND_NO, EFLAGS), addr:$dst)]>,
3132 TB; // [mem8] = not overflow
Evan Cheng950aac02007-09-25 01:57:46 +00003133} // Uses = [EFLAGS]
3134
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003135
3136// Integer comparisons
Evan Cheng55687072007-09-14 21:48:26 +00003137let Defs = [EFLAGS] in {
Sean Callanan251676e2009-09-02 00:55:49 +00003138def CMP8i8 : Ii8<0x3C, RawFrm, (outs), (ins i8imm:$src),
3139 "cmp{b}\t{$src, %al|%al, $src}", []>;
3140def CMP16i16 : Ii16<0x3D, RawFrm, (outs), (ins i16imm:$src),
3141 "cmp{w}\t{$src, %ax|%ax, $src}", []>, OpSize;
3142def CMP32i32 : Ii32<0x3D, RawFrm, (outs), (ins i32imm:$src),
3143 "cmp{l}\t{$src, %eax|%eax, $src}", []>;
3144
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003145def CMP8rr : I<0x38, MRMDestReg,
Evan Chengb783fa32007-07-19 01:14:50 +00003146 (outs), (ins GR8 :$src1, GR8 :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00003147 "cmp{b}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00003148 [(X86cmp GR8:$src1, GR8:$src2), (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003149def CMP16rr : I<0x39, MRMDestReg,
Evan Chengb783fa32007-07-19 01:14:50 +00003150 (outs), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00003151 "cmp{w}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00003152 [(X86cmp GR16:$src1, GR16:$src2), (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003153def CMP32rr : I<0x39, MRMDestReg,
Evan Chengb783fa32007-07-19 01:14:50 +00003154 (outs), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00003155 "cmp{l}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00003156 [(X86cmp GR32:$src1, GR32:$src2), (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003157def CMP8mr : I<0x38, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00003158 (outs), (ins i8mem :$src1, GR8 :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00003159 "cmp{b}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00003160 [(X86cmp (loadi8 addr:$src1), GR8:$src2),
3161 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003162def CMP16mr : I<0x39, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00003163 (outs), (ins i16mem:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00003164 "cmp{w}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00003165 [(X86cmp (loadi16 addr:$src1), GR16:$src2),
3166 (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003167def CMP32mr : I<0x39, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00003168 (outs), (ins i32mem:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00003169 "cmp{l}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00003170 [(X86cmp (loadi32 addr:$src1), GR32:$src2),
3171 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003172def CMP8rm : I<0x3A, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00003173 (outs), (ins GR8 :$src1, i8mem :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00003174 "cmp{b}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00003175 [(X86cmp GR8:$src1, (loadi8 addr:$src2)),
3176 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003177def CMP16rm : I<0x3B, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00003178 (outs), (ins GR16:$src1, i16mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00003179 "cmp{w}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00003180 [(X86cmp GR16:$src1, (loadi16 addr:$src2)),
3181 (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003182def CMP32rm : I<0x3B, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00003183 (outs), (ins GR32:$src1, i32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00003184 "cmp{l}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00003185 [(X86cmp GR32:$src1, (loadi32 addr:$src2)),
3186 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003187def CMP8ri : Ii8<0x80, MRM7r,
Evan Chengb783fa32007-07-19 01:14:50 +00003188 (outs), (ins GR8:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00003189 "cmp{b}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00003190 [(X86cmp GR8:$src1, imm:$src2), (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003191def CMP16ri : Ii16<0x81, MRM7r,
Evan Chengb783fa32007-07-19 01:14:50 +00003192 (outs), (ins GR16:$src1, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00003193 "cmp{w}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00003194 [(X86cmp GR16:$src1, imm:$src2),
3195 (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003196def CMP32ri : Ii32<0x81, MRM7r,
Evan Chengb783fa32007-07-19 01:14:50 +00003197 (outs), (ins GR32:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00003198 "cmp{l}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00003199 [(X86cmp GR32:$src1, imm:$src2), (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003200def CMP8mi : Ii8 <0x80, MRM7m,
Evan Chengb783fa32007-07-19 01:14:50 +00003201 (outs), (ins i8mem :$src1, i8imm :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00003202 "cmp{b}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00003203 [(X86cmp (loadi8 addr:$src1), imm:$src2),
3204 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003205def CMP16mi : Ii16<0x81, MRM7m,
Evan Chengb783fa32007-07-19 01:14:50 +00003206 (outs), (ins i16mem:$src1, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00003207 "cmp{w}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00003208 [(X86cmp (loadi16 addr:$src1), imm:$src2),
3209 (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003210def CMP32mi : Ii32<0x81, MRM7m,
Evan Chengb783fa32007-07-19 01:14:50 +00003211 (outs), (ins i32mem:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00003212 "cmp{l}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00003213 [(X86cmp (loadi32 addr:$src1), imm:$src2),
3214 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003215def CMP16ri8 : Ii8<0x83, MRM7r,
Evan Chengb783fa32007-07-19 01:14:50 +00003216 (outs), (ins GR16:$src1, i16i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00003217 "cmp{w}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00003218 [(X86cmp GR16:$src1, i16immSExt8:$src2),
3219 (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003220def CMP16mi8 : Ii8<0x83, MRM7m,
Evan Chengb783fa32007-07-19 01:14:50 +00003221 (outs), (ins i16mem:$src1, i16i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00003222 "cmp{w}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00003223 [(X86cmp (loadi16 addr:$src1), i16immSExt8:$src2),
3224 (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003225def CMP32mi8 : Ii8<0x83, MRM7m,
Evan Chengb783fa32007-07-19 01:14:50 +00003226 (outs), (ins i32mem:$src1, i32i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00003227 "cmp{l}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00003228 [(X86cmp (loadi32 addr:$src1), i32immSExt8:$src2),
3229 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003230def CMP32ri8 : Ii8<0x83, MRM7r,
Evan Chengb783fa32007-07-19 01:14:50 +00003231 (outs), (ins GR32:$src1, i32i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00003232 "cmp{l}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00003233 [(X86cmp GR32:$src1, i32immSExt8:$src2),
Evan Cheng950aac02007-09-25 01:57:46 +00003234 (implicit EFLAGS)]>;
3235} // Defs = [EFLAGS]
3236
Dan Gohman7fe9b7f2008-12-23 22:45:23 +00003237// Bit tests.
Dan Gohman7fe9b7f2008-12-23 22:45:23 +00003238// TODO: BTC, BTR, and BTS
3239let Defs = [EFLAGS] in {
Dan Gohmanfc4eddb2009-01-13 20:32:45 +00003240def BT16rr : I<0xA3, MRMDestReg, (outs), (ins GR16:$src1, GR16:$src2),
Dan Gohman7fe9b7f2008-12-23 22:45:23 +00003241 "bt{w}\t{$src2, $src1|$src1, $src2}",
3242 [(X86bt GR16:$src1, GR16:$src2),
Chris Lattner5a95cde2008-12-25 01:32:49 +00003243 (implicit EFLAGS)]>, OpSize, TB;
Dan Gohmanfc4eddb2009-01-13 20:32:45 +00003244def BT32rr : I<0xA3, MRMDestReg, (outs), (ins GR32:$src1, GR32:$src2),
Dan Gohman7fe9b7f2008-12-23 22:45:23 +00003245 "bt{l}\t{$src2, $src1|$src1, $src2}",
3246 [(X86bt GR32:$src1, GR32:$src2),
Chris Lattner5a95cde2008-12-25 01:32:49 +00003247 (implicit EFLAGS)]>, TB;
Dan Gohman85a228c2009-01-13 23:23:30 +00003248
3249// Unlike with the register+register form, the memory+register form of the
3250// bt instruction does not ignore the high bits of the index. From ISel's
3251// perspective, this is pretty bizarre. Disable these instructions for now.
3252//def BT16mr : I<0xA3, MRMDestMem, (outs), (ins i16mem:$src1, GR16:$src2),
3253// "bt{w}\t{$src2, $src1|$src1, $src2}",
3254// [(X86bt (loadi16 addr:$src1), GR16:$src2),
3255// (implicit EFLAGS)]>, OpSize, TB, Requires<[FastBTMem]>;
3256//def BT32mr : I<0xA3, MRMDestMem, (outs), (ins i32mem:$src1, GR32:$src2),
3257// "bt{l}\t{$src2, $src1|$src1, $src2}",
3258// [(X86bt (loadi32 addr:$src1), GR32:$src2),
3259// (implicit EFLAGS)]>, TB, Requires<[FastBTMem]>;
Dan Gohman46fb1cf2009-01-13 20:33:23 +00003260
3261def BT16ri8 : Ii8<0xBA, MRM4r, (outs), (ins GR16:$src1, i16i8imm:$src2),
3262 "bt{w}\t{$src2, $src1|$src1, $src2}",
3263 [(X86bt GR16:$src1, i16immSExt8:$src2),
3264 (implicit EFLAGS)]>, OpSize, TB;
3265def BT32ri8 : Ii8<0xBA, MRM4r, (outs), (ins GR32:$src1, i32i8imm:$src2),
3266 "bt{l}\t{$src2, $src1|$src1, $src2}",
3267 [(X86bt GR32:$src1, i32immSExt8:$src2),
3268 (implicit EFLAGS)]>, TB;
3269// Note that these instructions don't need FastBTMem because that
3270// only applies when the other operand is in a register. When it's
3271// an immediate, bt is still fast.
3272def BT16mi8 : Ii8<0xBA, MRM4m, (outs), (ins i16mem:$src1, i16i8imm:$src2),
3273 "bt{w}\t{$src2, $src1|$src1, $src2}",
3274 [(X86bt (loadi16 addr:$src1), i16immSExt8:$src2),
3275 (implicit EFLAGS)]>, OpSize, TB;
3276def BT32mi8 : Ii8<0xBA, MRM4m, (outs), (ins i32mem:$src1, i32i8imm:$src2),
3277 "bt{l}\t{$src2, $src1|$src1, $src2}",
3278 [(X86bt (loadi32 addr:$src1), i32immSExt8:$src2),
3279 (implicit EFLAGS)]>, TB;
Dan Gohman7fe9b7f2008-12-23 22:45:23 +00003280} // Defs = [EFLAGS]
3281
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003282// Sign/Zero extenders
Dan Gohman9203ab42008-07-30 18:09:17 +00003283// Use movsbl intead of movsbw; we don't care about the high 16 bits
3284// of the register here. This has a smaller encoding and avoids a
3285// partial-register update.
Evan Chengb783fa32007-07-19 01:14:50 +00003286def MOVSX16rr8 : I<0xBE, MRMSrcReg, (outs GR16:$dst), (ins GR8 :$src),
Dan Gohman9203ab42008-07-30 18:09:17 +00003287 "movs{bl|x}\t{$src, ${dst:subreg32}|${dst:subreg32}, $src}",
3288 [(set GR16:$dst, (sext GR8:$src))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00003289def MOVSX16rm8 : I<0xBE, MRMSrcMem, (outs GR16:$dst), (ins i8mem :$src),
Dan Gohman9203ab42008-07-30 18:09:17 +00003290 "movs{bl|x}\t{$src, ${dst:subreg32}|${dst:subreg32}, $src}",
3291 [(set GR16:$dst, (sextloadi16i8 addr:$src))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00003292def MOVSX32rr8 : I<0xBE, MRMSrcReg, (outs GR32:$dst), (ins GR8 :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00003293 "movs{bl|x}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003294 [(set GR32:$dst, (sext GR8:$src))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00003295def MOVSX32rm8 : I<0xBE, MRMSrcMem, (outs GR32:$dst), (ins i8mem :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00003296 "movs{bl|x}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003297 [(set GR32:$dst, (sextloadi32i8 addr:$src))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00003298def MOVSX32rr16: I<0xBF, MRMSrcReg, (outs GR32:$dst), (ins GR16:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00003299 "movs{wl|x}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003300 [(set GR32:$dst, (sext GR16:$src))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00003301def MOVSX32rm16: I<0xBF, MRMSrcMem, (outs GR32:$dst), (ins i16mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00003302 "movs{wl|x}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003303 [(set GR32:$dst, (sextloadi32i16 addr:$src))]>, TB;
3304
Dan Gohman9203ab42008-07-30 18:09:17 +00003305// Use movzbl intead of movzbw; we don't care about the high 16 bits
3306// of the register here. This has a smaller encoding and avoids a
3307// partial-register update.
Evan Chengb783fa32007-07-19 01:14:50 +00003308def MOVZX16rr8 : I<0xB6, MRMSrcReg, (outs GR16:$dst), (ins GR8 :$src),
Dan Gohman9203ab42008-07-30 18:09:17 +00003309 "movz{bl|x}\t{$src, ${dst:subreg32}|${dst:subreg32}, $src}",
3310 [(set GR16:$dst, (zext GR8:$src))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00003311def MOVZX16rm8 : I<0xB6, MRMSrcMem, (outs GR16:$dst), (ins i8mem :$src),
Dan Gohman9203ab42008-07-30 18:09:17 +00003312 "movz{bl|x}\t{$src, ${dst:subreg32}|${dst:subreg32}, $src}",
3313 [(set GR16:$dst, (zextloadi16i8 addr:$src))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00003314def MOVZX32rr8 : I<0xB6, MRMSrcReg, (outs GR32:$dst), (ins GR8 :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00003315 "movz{bl|x}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003316 [(set GR32:$dst, (zext GR8:$src))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00003317def MOVZX32rm8 : I<0xB6, MRMSrcMem, (outs GR32:$dst), (ins i8mem :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00003318 "movz{bl|x}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003319 [(set GR32:$dst, (zextloadi32i8 addr:$src))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00003320def MOVZX32rr16: I<0xB7, MRMSrcReg, (outs GR32:$dst), (ins GR16:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00003321 "movz{wl|x}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003322 [(set GR32:$dst, (zext GR16:$src))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00003323def MOVZX32rm16: I<0xB7, MRMSrcMem, (outs GR32:$dst), (ins i16mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00003324 "movz{wl|x}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003325 [(set GR32:$dst, (zextloadi32i16 addr:$src))]>, TB;
3326
Dan Gohman744d4622009-04-13 16:09:41 +00003327// These are the same as the regular regular MOVZX32rr8 and MOVZX32rm8
3328// except that they use GR32_NOREX for the output operand register class
3329// instead of GR32. This allows them to operate on h registers on x86-64.
3330def MOVZX32_NOREXrr8 : I<0xB6, MRMSrcReg,
3331 (outs GR32_NOREX:$dst), (ins GR8:$src),
3332 "movz{bl|x}\t{$src, $dst|$dst, $src} # NOREX",
3333 []>, TB;
Dan Gohman89f4cda2009-04-30 03:11:48 +00003334let mayLoad = 1 in
Dan Gohman744d4622009-04-13 16:09:41 +00003335def MOVZX32_NOREXrm8 : I<0xB6, MRMSrcMem,
3336 (outs GR32_NOREX:$dst), (ins i8mem:$src),
3337 "movz{bl|x}\t{$src, $dst|$dst, $src} # NOREX",
3338 []>, TB;
3339
Chris Lattnerc90ee9c2008-01-10 07:59:24 +00003340let neverHasSideEffects = 1 in {
3341 let Defs = [AX], Uses = [AL] in
3342 def CBW : I<0x98, RawFrm, (outs), (ins),
3343 "{cbtw|cbw}", []>, OpSize; // AX = signext(AL)
3344 let Defs = [EAX], Uses = [AX] in
3345 def CWDE : I<0x98, RawFrm, (outs), (ins),
3346 "{cwtl|cwde}", []>; // EAX = signext(AX)
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003347
Chris Lattnerc90ee9c2008-01-10 07:59:24 +00003348 let Defs = [AX,DX], Uses = [AX] in
3349 def CWD : I<0x99, RawFrm, (outs), (ins),
3350 "{cwtd|cwd}", []>, OpSize; // DX:AX = signext(AX)
3351 let Defs = [EAX,EDX], Uses = [EAX] in
3352 def CDQ : I<0x99, RawFrm, (outs), (ins),
3353 "{cltd|cdq}", []>; // EDX:EAX = signext(EAX)
3354}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003355
3356//===----------------------------------------------------------------------===//
3357// Alias Instructions
3358//===----------------------------------------------------------------------===//
3359
3360// Alias instructions that map movr0 to xor.
3361// FIXME: remove when we can teach regalloc that xor reg, reg is ok.
Daniel Dunbara0e62002009-08-11 22:17:52 +00003362let Defs = [EFLAGS], isReMaterializable = 1, isAsCheapAsAMove = 1,
3363 isCodeGenOnly = 1 in {
Evan Chengb783fa32007-07-19 01:14:50 +00003364def MOV8r0 : I<0x30, MRMInitReg, (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00003365 "xor{b}\t$dst, $dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003366 [(set GR8:$dst, 0)]>;
Dan Gohman9203ab42008-07-30 18:09:17 +00003367// Use xorl instead of xorw since we don't care about the high 16 bits,
3368// it's smaller, and it avoids a partial-register update.
Evan Chengb783fa32007-07-19 01:14:50 +00003369def MOV16r0 : I<0x31, MRMInitReg, (outs GR16:$dst), (ins),
Dan Gohman9203ab42008-07-30 18:09:17 +00003370 "xor{l}\t${dst:subreg32}, ${dst:subreg32}",
3371 [(set GR16:$dst, 0)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00003372def MOV32r0 : I<0x31, MRMInitReg, (outs GR32:$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00003373 "xor{l}\t$dst, $dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003374 [(set GR32:$dst, 0)]>;
Dan Gohman8aef09b2007-09-07 21:32:51 +00003375}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003376
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003377//===----------------------------------------------------------------------===//
3378// Thread Local Storage Instructions
3379//
3380
Rafael Espindola7fc4b8d2009-04-24 12:59:40 +00003381// All calls clobber the non-callee saved registers. ESP is marked as
3382// a use to prevent stack-pointer assignments that appear immediately
3383// before calls from potentially appearing dead.
3384let Defs = [EAX, ECX, EDX, FP0, FP1, FP2, FP3, FP4, FP5, FP6, ST0,
3385 MM0, MM1, MM2, MM3, MM4, MM5, MM6, MM7,
3386 XMM0, XMM1, XMM2, XMM3, XMM4, XMM5, XMM6, XMM7,
3387 XMM8, XMM9, XMM10, XMM11, XMM12, XMM13, XMM14, XMM15, EFLAGS],
Chris Lattnerf1940742009-06-20 20:38:48 +00003388 Uses = [ESP] in
3389def TLS_addr32 : I<0, Pseudo, (outs), (ins lea32mem:$sym),
3390 "leal\t$sym, %eax; "
Dan Gohman70a8a112009-04-27 15:13:28 +00003391 "call\t___tls_get_addr@PLT",
Chris Lattnerf1940742009-06-20 20:38:48 +00003392 [(X86tlsaddr tls32addr:$sym)]>,
Rafael Espindolaaf759ab2009-04-17 14:35:58 +00003393 Requires<[In32BitMode]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003394
Daniel Dunbar75a07302009-08-11 22:24:40 +00003395let AddedComplexity = 5, isCodeGenOnly = 1 in
sampo9cc09a32009-01-26 01:24:32 +00003396def GS_MOV32rm : I<0x8B, MRMSrcMem, (outs GR32:$dst), (ins i32mem:$src),
3397 "movl\t%gs:$src, $dst",
3398 [(set GR32:$dst, (gsload addr:$src))]>, SegGS;
3399
Daniel Dunbar75a07302009-08-11 22:24:40 +00003400let AddedComplexity = 5, isCodeGenOnly = 1 in
Chris Lattnera7c2d8a2009-05-05 18:52:19 +00003401def FS_MOV32rm : I<0x8B, MRMSrcMem, (outs GR32:$dst), (ins i32mem:$src),
3402 "movl\t%fs:$src, $dst",
3403 [(set GR32:$dst, (fsload addr:$src))]>, SegFS;
3404
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003405//===----------------------------------------------------------------------===//
3406// DWARF Pseudo Instructions
3407//
3408
Evan Chengb783fa32007-07-19 01:14:50 +00003409def DWARF_LOC : I<0, Pseudo, (outs),
3410 (ins i32imm:$line, i32imm:$col, i32imm:$file),
Chris Lattner64b54552009-07-10 22:34:11 +00003411 ".loc\t$file $line $col",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003412 [(dwarf_loc (i32 imm:$line), (i32 imm:$col),
3413 (i32 imm:$file))]>;
3414
3415//===----------------------------------------------------------------------===//
3416// EH Pseudo Instructions
3417//
3418let isTerminator = 1, isReturn = 1, isBarrier = 1,
Daniel Dunbar75513bd2009-08-27 07:58:05 +00003419 hasCtrlDep = 1, isCodeGenOnly = 1 in {
Evan Chengb783fa32007-07-19 01:14:50 +00003420def EH_RETURN : I<0xC3, RawFrm, (outs), (ins GR32:$addr),
Dan Gohman91888f02007-07-31 20:11:57 +00003421 "ret\t#eh_return, addr: $addr",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003422 [(X86ehret GR32:$addr)]>;
3423
3424}
3425
3426//===----------------------------------------------------------------------===//
Andrew Lenharthe44f3902008-02-21 06:45:13 +00003427// Atomic support
3428//
Andrew Lenharth7a5a4b22008-03-01 13:37:02 +00003429
Evan Cheng3e171562008-04-19 01:20:30 +00003430// Atomic swap. These are just normal xchg instructions. But since a memory
3431// operand is referenced, the atomicity is ensured.
Dan Gohmana41a1c092008-08-06 15:52:50 +00003432let Constraints = "$val = $dst" in {
Evan Cheng3e171562008-04-19 01:20:30 +00003433def XCHG32rm : I<0x87, MRMSrcMem, (outs GR32:$dst), (ins i32mem:$ptr, GR32:$val),
3434 "xchg{l}\t{$val, $ptr|$ptr, $val}",
3435 [(set GR32:$dst, (atomic_swap_32 addr:$ptr, GR32:$val))]>;
3436def XCHG16rm : I<0x87, MRMSrcMem, (outs GR16:$dst), (ins i16mem:$ptr, GR16:$val),
3437 "xchg{w}\t{$val, $ptr|$ptr, $val}",
3438 [(set GR16:$dst, (atomic_swap_16 addr:$ptr, GR16:$val))]>,
3439 OpSize;
3440def XCHG8rm : I<0x86, MRMSrcMem, (outs GR8:$dst), (ins i8mem:$ptr, GR8:$val),
3441 "xchg{b}\t{$val, $ptr|$ptr, $val}",
3442 [(set GR8:$dst, (atomic_swap_8 addr:$ptr, GR8:$val))]>;
3443}
3444
Evan Chengd49dbb82008-04-18 20:55:36 +00003445// Atomic compare and swap.
Andrew Lenharth7dfe23f2008-03-01 21:52:34 +00003446let Defs = [EAX, EFLAGS], Uses = [EAX] in {
Evan Chengd49dbb82008-04-18 20:55:36 +00003447def LCMPXCHG32 : I<0xB1, MRMDestMem, (outs), (ins i32mem:$ptr, GR32:$swap),
Dan Gohman70a8a112009-04-27 15:13:28 +00003448 "lock\n\t"
3449 "cmpxchg{l}\t{$swap, $ptr|$ptr, $swap}",
Evan Cheng09fbdee2008-03-04 03:20:06 +00003450 [(X86cas addr:$ptr, GR32:$swap, 4)]>, TB, LOCK;
Andrew Lenharth7a5a4b22008-03-01 13:37:02 +00003451}
Dale Johannesenf160d802008-10-02 18:53:47 +00003452let Defs = [EAX, EDX, EFLAGS], Uses = [EAX, EBX, ECX, EDX] in {
Anton Korobeynikovc4067392008-07-22 16:22:48 +00003453def LCMPXCHG8B : I<0xC7, MRM1m, (outs), (ins i32mem:$ptr),
Dan Gohman70a8a112009-04-27 15:13:28 +00003454 "lock\n\t"
3455 "cmpxchg8b\t$ptr",
Andrew Lenharth81580822008-03-05 01:15:49 +00003456 [(X86cas8 addr:$ptr)]>, TB, LOCK;
3457}
Andrew Lenharth7dfe23f2008-03-01 21:52:34 +00003458
3459let Defs = [AX, EFLAGS], Uses = [AX] in {
Evan Chengd49dbb82008-04-18 20:55:36 +00003460def LCMPXCHG16 : I<0xB1, MRMDestMem, (outs), (ins i16mem:$ptr, GR16:$swap),
Dan Gohman70a8a112009-04-27 15:13:28 +00003461 "lock\n\t"
3462 "cmpxchg{w}\t{$swap, $ptr|$ptr, $swap}",
Evan Cheng09fbdee2008-03-04 03:20:06 +00003463 [(X86cas addr:$ptr, GR16:$swap, 2)]>, TB, OpSize, LOCK;
Andrew Lenharth7a5a4b22008-03-01 13:37:02 +00003464}
Andrew Lenharth7dfe23f2008-03-01 21:52:34 +00003465let Defs = [AL, EFLAGS], Uses = [AL] in {
Evan Chengd49dbb82008-04-18 20:55:36 +00003466def LCMPXCHG8 : I<0xB0, MRMDestMem, (outs), (ins i8mem:$ptr, GR8:$swap),
Dan Gohman70a8a112009-04-27 15:13:28 +00003467 "lock\n\t"
3468 "cmpxchg{b}\t{$swap, $ptr|$ptr, $swap}",
Evan Cheng09fbdee2008-03-04 03:20:06 +00003469 [(X86cas addr:$ptr, GR8:$swap, 1)]>, TB, LOCK;
Andrew Lenharth7a5a4b22008-03-01 13:37:02 +00003470}
3471
Evan Chengd49dbb82008-04-18 20:55:36 +00003472// Atomic exchange and add
3473let Constraints = "$val = $dst", Defs = [EFLAGS] in {
3474def LXADD32 : I<0xC1, MRMSrcMem, (outs GR32:$dst), (ins i32mem:$ptr, GR32:$val),
Dan Gohman70a8a112009-04-27 15:13:28 +00003475 "lock\n\t"
3476 "xadd{l}\t{$val, $ptr|$ptr, $val}",
Mon P Wang6bde9ec2008-06-25 08:15:39 +00003477 [(set GR32:$dst, (atomic_load_add_32 addr:$ptr, GR32:$val))]>,
Evan Chengd49dbb82008-04-18 20:55:36 +00003478 TB, LOCK;
3479def LXADD16 : I<0xC1, MRMSrcMem, (outs GR16:$dst), (ins i16mem:$ptr, GR16:$val),
Dan Gohman70a8a112009-04-27 15:13:28 +00003480 "lock\n\t"
3481 "xadd{w}\t{$val, $ptr|$ptr, $val}",
Mon P Wang6bde9ec2008-06-25 08:15:39 +00003482 [(set GR16:$dst, (atomic_load_add_16 addr:$ptr, GR16:$val))]>,
Evan Chengd49dbb82008-04-18 20:55:36 +00003483 TB, OpSize, LOCK;
3484def LXADD8 : I<0xC0, MRMSrcMem, (outs GR8:$dst), (ins i8mem:$ptr, GR8:$val),
Dan Gohman70a8a112009-04-27 15:13:28 +00003485 "lock\n\t"
3486 "xadd{b}\t{$val, $ptr|$ptr, $val}",
Mon P Wang6bde9ec2008-06-25 08:15:39 +00003487 [(set GR8:$dst, (atomic_load_add_8 addr:$ptr, GR8:$val))]>,
Evan Chengd49dbb82008-04-18 20:55:36 +00003488 TB, LOCK;
Andrew Lenharth7a5a4b22008-03-01 13:37:02 +00003489}
3490
Evan Chengb723fb52009-07-30 08:33:02 +00003491// Optimized codegen when the non-memory output is not used.
3492// FIXME: Use normal add / sub instructions and add lock prefix dynamically.
3493def LOCK_ADD8mr : I<0x00, MRMDestMem, (outs), (ins i8mem:$dst, GR8:$src2),
3494 "lock\n\t"
3495 "add{b}\t{$src2, $dst|$dst, $src2}", []>, LOCK;
3496def LOCK_ADD16mr : I<0x01, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
3497 "lock\n\t"
3498 "add{w}\t{$src2, $dst|$dst, $src2}", []>, OpSize, LOCK;
3499def LOCK_ADD32mr : I<0x01, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
3500 "lock\n\t"
3501 "add{l}\t{$src2, $dst|$dst, $src2}", []>, LOCK;
3502def LOCK_ADD8mi : Ii8<0x80, MRM0m, (outs), (ins i8mem :$dst, i8imm :$src2),
3503 "lock\n\t"
3504 "add{b}\t{$src2, $dst|$dst, $src2}", []>, LOCK;
3505def LOCK_ADD16mi : Ii16<0x81, MRM0m, (outs), (ins i16mem:$dst, i16imm:$src2),
3506 "lock\n\t"
3507 "add{w}\t{$src2, $dst|$dst, $src2}", []>, LOCK;
3508def LOCK_ADD32mi : Ii32<0x81, MRM0m, (outs), (ins i32mem:$dst, i32imm:$src2),
3509 "lock\n\t"
3510 "add{l}\t{$src2, $dst|$dst, $src2}", []>, LOCK;
3511def LOCK_ADD16mi8 : Ii8<0x83, MRM0m, (outs), (ins i16mem:$dst, i16i8imm :$src2),
3512 "lock\n\t"
3513 "add{w}\t{$src2, $dst|$dst, $src2}", []>, OpSize, LOCK;
3514def LOCK_ADD32mi8 : Ii8<0x83, MRM0m, (outs), (ins i32mem:$dst, i32i8imm :$src2),
3515 "lock\n\t"
3516 "add{l}\t{$src2, $dst|$dst, $src2}", []>, LOCK;
3517
3518def LOCK_INC8m : I<0xFE, MRM0m, (outs), (ins i8mem :$dst),
3519 "lock\n\t"
3520 "inc{b}\t$dst", []>, LOCK;
3521def LOCK_INC16m : I<0xFF, MRM0m, (outs), (ins i16mem:$dst),
3522 "lock\n\t"
3523 "inc{w}\t$dst", []>, OpSize, LOCK;
3524def LOCK_INC32m : I<0xFF, MRM0m, (outs), (ins i32mem:$dst),
3525 "lock\n\t"
3526 "inc{l}\t$dst", []>, LOCK;
3527
3528def LOCK_SUB8mr : I<0x28, MRMDestMem, (outs), (ins i8mem :$dst, GR8 :$src2),
3529 "lock\n\t"
3530 "sub{b}\t{$src2, $dst|$dst, $src2}", []>, LOCK;
3531def LOCK_SUB16mr : I<0x29, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
3532 "lock\n\t"
3533 "sub{w}\t{$src2, $dst|$dst, $src2}", []>, OpSize, LOCK;
3534def LOCK_SUB32mr : I<0x29, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
3535 "lock\n\t"
3536 "sub{l}\t{$src2, $dst|$dst, $src2}", []>, LOCK;
3537def LOCK_SUB8mi : Ii8<0x80, MRM5m, (outs), (ins i8mem :$dst, i8imm:$src2),
3538 "lock\n\t"
3539 "sub{b}\t{$src2, $dst|$dst, $src2}", []>, LOCK;
3540def LOCK_SUB16mi : Ii16<0x81, MRM5m, (outs), (ins i16mem:$dst, i16imm:$src2),
3541 "lock\n\t"
3542 "sub{w}\t{$src2, $dst|$dst, $src2}", []>, OpSize, LOCK;
3543def LOCK_SUB32mi : Ii32<0x81, MRM5m, (outs), (ins i32mem:$dst, i32imm:$src2),
3544 "lock\n\t"
3545 "sub{l}\t{$src2, $dst|$dst, $src2}", []>, LOCK;
3546def LOCK_SUB16mi8 : Ii8<0x83, MRM5m, (outs), (ins i16mem:$dst, i16i8imm :$src2),
3547 "lock\n\t"
3548 "sub{w}\t{$src2, $dst|$dst, $src2}", []>, OpSize, LOCK;
3549def LOCK_SUB32mi8 : Ii8<0x83, MRM5m, (outs), (ins i32mem:$dst, i32i8imm :$src2),
3550 "lock\n\t"
3551 "sub{l}\t{$src2, $dst|$dst, $src2}", []>, LOCK;
3552
3553def LOCK_DEC8m : I<0xFE, MRM1m, (outs), (ins i8mem :$dst),
3554 "lock\n\t"
3555 "dec{b}\t$dst", []>, LOCK;
3556def LOCK_DEC16m : I<0xFF, MRM1m, (outs), (ins i16mem:$dst),
3557 "lock\n\t"
3558 "dec{w}\t$dst", []>, OpSize, LOCK;
3559def LOCK_DEC32m : I<0xFF, MRM1m, (outs), (ins i32mem:$dst),
3560 "lock\n\t"
3561 "dec{l}\t$dst", []>, LOCK;
3562
Mon P Wang6bde9ec2008-06-25 08:15:39 +00003563// Atomic exchange, and, or, xor
Mon P Wang078a62d2008-05-05 19:05:59 +00003564let Constraints = "$val = $dst", Defs = [EFLAGS],
3565 usesCustomDAGSchedInserter = 1 in {
Dan Gohman8aeb61f2008-05-12 20:22:45 +00003566def ATOMAND32 : I<0, Pseudo, (outs GR32:$dst),(ins i32mem:$ptr, GR32:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003567 "#ATOMAND32 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003568 [(set GR32:$dst, (atomic_load_and_32 addr:$ptr, GR32:$val))]>;
Dan Gohman8aeb61f2008-05-12 20:22:45 +00003569def ATOMOR32 : I<0, Pseudo, (outs GR32:$dst),(ins i32mem:$ptr, GR32:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003570 "#ATOMOR32 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003571 [(set GR32:$dst, (atomic_load_or_32 addr:$ptr, GR32:$val))]>;
Dan Gohman8aeb61f2008-05-12 20:22:45 +00003572def ATOMXOR32 : I<0, Pseudo,(outs GR32:$dst),(ins i32mem:$ptr, GR32:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003573 "#ATOMXOR32 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003574 [(set GR32:$dst, (atomic_load_xor_32 addr:$ptr, GR32:$val))]>;
Andrew Lenharthaf02d592008-06-14 05:48:15 +00003575def ATOMNAND32 : I<0, Pseudo,(outs GR32:$dst),(ins i32mem:$ptr, GR32:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003576 "#ATOMNAND32 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003577 [(set GR32:$dst, (atomic_load_nand_32 addr:$ptr, GR32:$val))]>;
Dan Gohman8aeb61f2008-05-12 20:22:45 +00003578def ATOMMIN32: I<0, Pseudo, (outs GR32:$dst), (ins i32mem:$ptr, GR32:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003579 "#ATOMMIN32 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003580 [(set GR32:$dst, (atomic_load_min_32 addr:$ptr, GR32:$val))]>;
Dan Gohman8aeb61f2008-05-12 20:22:45 +00003581def ATOMMAX32: I<0, Pseudo, (outs GR32:$dst),(ins i32mem:$ptr, GR32:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003582 "#ATOMMAX32 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003583 [(set GR32:$dst, (atomic_load_max_32 addr:$ptr, GR32:$val))]>;
Dan Gohman8aeb61f2008-05-12 20:22:45 +00003584def ATOMUMIN32: I<0, Pseudo, (outs GR32:$dst),(ins i32mem:$ptr, GR32:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003585 "#ATOMUMIN32 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003586 [(set GR32:$dst, (atomic_load_umin_32 addr:$ptr, GR32:$val))]>;
Dan Gohman8aeb61f2008-05-12 20:22:45 +00003587def ATOMUMAX32: I<0, Pseudo, (outs GR32:$dst),(ins i32mem:$ptr, GR32:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003588 "#ATOMUMAX32 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003589 [(set GR32:$dst, (atomic_load_umax_32 addr:$ptr, GR32:$val))]>;
Dale Johannesend20e4452008-08-19 18:47:28 +00003590
3591def ATOMAND16 : I<0, Pseudo, (outs GR16:$dst),(ins i16mem:$ptr, GR16:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003592 "#ATOMAND16 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003593 [(set GR16:$dst, (atomic_load_and_16 addr:$ptr, GR16:$val))]>;
Dale Johannesend20e4452008-08-19 18:47:28 +00003594def ATOMOR16 : I<0, Pseudo, (outs GR16:$dst),(ins i16mem:$ptr, GR16:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003595 "#ATOMOR16 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003596 [(set GR16:$dst, (atomic_load_or_16 addr:$ptr, GR16:$val))]>;
Dale Johannesend20e4452008-08-19 18:47:28 +00003597def ATOMXOR16 : I<0, Pseudo,(outs GR16:$dst),(ins i16mem:$ptr, GR16:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003598 "#ATOMXOR16 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003599 [(set GR16:$dst, (atomic_load_xor_16 addr:$ptr, GR16:$val))]>;
Dale Johannesend20e4452008-08-19 18:47:28 +00003600def ATOMNAND16 : I<0, Pseudo,(outs GR16:$dst),(ins i16mem:$ptr, GR16:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003601 "#ATOMNAND16 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003602 [(set GR16:$dst, (atomic_load_nand_16 addr:$ptr, GR16:$val))]>;
Dale Johannesend20e4452008-08-19 18:47:28 +00003603def ATOMMIN16: I<0, Pseudo, (outs GR16:$dst), (ins i16mem:$ptr, GR16:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003604 "#ATOMMIN16 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003605 [(set GR16:$dst, (atomic_load_min_16 addr:$ptr, GR16:$val))]>;
Dale Johannesend20e4452008-08-19 18:47:28 +00003606def ATOMMAX16: I<0, Pseudo, (outs GR16:$dst),(ins i16mem:$ptr, GR16:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003607 "#ATOMMAX16 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003608 [(set GR16:$dst, (atomic_load_max_16 addr:$ptr, GR16:$val))]>;
Dale Johannesend20e4452008-08-19 18:47:28 +00003609def ATOMUMIN16: I<0, Pseudo, (outs GR16:$dst),(ins i16mem:$ptr, GR16:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003610 "#ATOMUMIN16 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003611 [(set GR16:$dst, (atomic_load_umin_16 addr:$ptr, GR16:$val))]>;
Dale Johannesend20e4452008-08-19 18:47:28 +00003612def ATOMUMAX16: I<0, Pseudo, (outs GR16:$dst),(ins i16mem:$ptr, GR16:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003613 "#ATOMUMAX16 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003614 [(set GR16:$dst, (atomic_load_umax_16 addr:$ptr, GR16:$val))]>;
Dale Johannesend20e4452008-08-19 18:47:28 +00003615
3616def ATOMAND8 : I<0, Pseudo, (outs GR8:$dst),(ins i8mem:$ptr, GR8:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003617 "#ATOMAND8 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003618 [(set GR8:$dst, (atomic_load_and_8 addr:$ptr, GR8:$val))]>;
Dale Johannesend20e4452008-08-19 18:47:28 +00003619def ATOMOR8 : I<0, Pseudo, (outs GR8:$dst),(ins i8mem:$ptr, GR8:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003620 "#ATOMOR8 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003621 [(set GR8:$dst, (atomic_load_or_8 addr:$ptr, GR8:$val))]>;
Dale Johannesend20e4452008-08-19 18:47:28 +00003622def ATOMXOR8 : I<0, Pseudo,(outs GR8:$dst),(ins i8mem:$ptr, GR8:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003623 "#ATOMXOR8 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003624 [(set GR8:$dst, (atomic_load_xor_8 addr:$ptr, GR8:$val))]>;
Dale Johannesend20e4452008-08-19 18:47:28 +00003625def ATOMNAND8 : I<0, Pseudo,(outs GR8:$dst),(ins i8mem:$ptr, GR8:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003626 "#ATOMNAND8 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003627 [(set GR8:$dst, (atomic_load_nand_8 addr:$ptr, GR8:$val))]>;
Mon P Wang078a62d2008-05-05 19:05:59 +00003628}
3629
Dale Johannesenf160d802008-10-02 18:53:47 +00003630let Constraints = "$val1 = $dst1, $val2 = $dst2",
3631 Defs = [EFLAGS, EAX, EBX, ECX, EDX],
3632 Uses = [EAX, EBX, ECX, EDX],
Dale Johannesen44eb5372008-10-03 19:41:08 +00003633 mayLoad = 1, mayStore = 1,
Dale Johannesenf160d802008-10-02 18:53:47 +00003634 usesCustomDAGSchedInserter = 1 in {
3635def ATOMAND6432 : I<0, Pseudo, (outs GR32:$dst1, GR32:$dst2),
3636 (ins i64mem:$ptr, GR32:$val1, GR32:$val2),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003637 "#ATOMAND6432 PSEUDO!", []>;
Dale Johannesenf160d802008-10-02 18:53:47 +00003638def ATOMOR6432 : I<0, Pseudo, (outs GR32:$dst1, GR32:$dst2),
3639 (ins i64mem:$ptr, GR32:$val1, GR32:$val2),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003640 "#ATOMOR6432 PSEUDO!", []>;
Dale Johannesenf160d802008-10-02 18:53:47 +00003641def ATOMXOR6432 : I<0, Pseudo, (outs GR32:$dst1, GR32:$dst2),
3642 (ins i64mem:$ptr, GR32:$val1, GR32:$val2),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003643 "#ATOMXOR6432 PSEUDO!", []>;
Dale Johannesenf160d802008-10-02 18:53:47 +00003644def ATOMNAND6432 : I<0, Pseudo, (outs GR32:$dst1, GR32:$dst2),
3645 (ins i64mem:$ptr, GR32:$val1, GR32:$val2),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003646 "#ATOMNAND6432 PSEUDO!", []>;
Dale Johannesenf160d802008-10-02 18:53:47 +00003647def ATOMADD6432 : I<0, Pseudo, (outs GR32:$dst1, GR32:$dst2),
3648 (ins i64mem:$ptr, GR32:$val1, GR32:$val2),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003649 "#ATOMADD6432 PSEUDO!", []>;
Dale Johannesenf160d802008-10-02 18:53:47 +00003650def ATOMSUB6432 : I<0, Pseudo, (outs GR32:$dst1, GR32:$dst2),
3651 (ins i64mem:$ptr, GR32:$val1, GR32:$val2),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003652 "#ATOMSUB6432 PSEUDO!", []>;
Dale Johannesen51c58ee2008-10-03 22:25:52 +00003653def ATOMSWAP6432 : I<0, Pseudo, (outs GR32:$dst1, GR32:$dst2),
3654 (ins i64mem:$ptr, GR32:$val1, GR32:$val2),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003655 "#ATOMSWAP6432 PSEUDO!", []>;
Dale Johannesenf160d802008-10-02 18:53:47 +00003656}
3657
Andrew Lenharthe44f3902008-02-21 06:45:13 +00003658//===----------------------------------------------------------------------===//
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003659// Non-Instruction Patterns
3660//===----------------------------------------------------------------------===//
3661
Bill Wendlingfef06052008-09-16 21:48:12 +00003662// ConstantPool GlobalAddress, ExternalSymbol, and JumpTable
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003663def : Pat<(i32 (X86Wrapper tconstpool :$dst)), (MOV32ri tconstpool :$dst)>;
3664def : Pat<(i32 (X86Wrapper tjumptable :$dst)), (MOV32ri tjumptable :$dst)>;
Nate Begemanb52948972008-04-12 00:47:57 +00003665def : Pat<(i32 (X86Wrapper tglobaltlsaddr:$dst)),(MOV32ri tglobaltlsaddr:$dst)>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003666def : Pat<(i32 (X86Wrapper tglobaladdr :$dst)), (MOV32ri tglobaladdr :$dst)>;
3667def : Pat<(i32 (X86Wrapper texternalsym:$dst)), (MOV32ri texternalsym:$dst)>;
3668
3669def : Pat<(add GR32:$src1, (X86Wrapper tconstpool:$src2)),
3670 (ADD32ri GR32:$src1, tconstpool:$src2)>;
3671def : Pat<(add GR32:$src1, (X86Wrapper tjumptable:$src2)),
3672 (ADD32ri GR32:$src1, tjumptable:$src2)>;
3673def : Pat<(add GR32:$src1, (X86Wrapper tglobaladdr :$src2)),
3674 (ADD32ri GR32:$src1, tglobaladdr:$src2)>;
3675def : Pat<(add GR32:$src1, (X86Wrapper texternalsym:$src2)),
3676 (ADD32ri GR32:$src1, texternalsym:$src2)>;
3677
3678def : Pat<(store (i32 (X86Wrapper tglobaladdr:$src)), addr:$dst),
3679 (MOV32mi addr:$dst, tglobaladdr:$src)>;
3680def : Pat<(store (i32 (X86Wrapper texternalsym:$src)), addr:$dst),
3681 (MOV32mi addr:$dst, texternalsym:$src)>;
3682
3683// Calls
Arnold Schwaighofere2d6bbb2007-10-11 19:40:01 +00003684// tailcall stuff
Arnold Schwaighofere2d6bbb2007-10-11 19:40:01 +00003685def : Pat<(X86tcret GR32:$dst, imm:$off),
3686 (TCRETURNri GR32:$dst, imm:$off)>;
3687
3688def : Pat<(X86tcret (i32 tglobaladdr:$dst), imm:$off),
3689 (TCRETURNdi texternalsym:$dst, imm:$off)>;
3690
3691def : Pat<(X86tcret (i32 texternalsym:$dst), imm:$off),
3692 (TCRETURNdi texternalsym:$dst, imm:$off)>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003693
Dan Gohmance5dbff2009-08-02 16:10:01 +00003694// Normal calls, with various flavors of addresses.
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003695def : Pat<(X86call (i32 tglobaladdr:$dst)),
3696 (CALLpcrel32 tglobaladdr:$dst)>;
3697def : Pat<(X86call (i32 texternalsym:$dst)),
3698 (CALLpcrel32 texternalsym:$dst)>;
Evan Cheng6d35a4d2009-05-20 04:53:57 +00003699def : Pat<(X86call (i32 imm:$dst)),
3700 (CALLpcrel32 imm:$dst)>, Requires<[CallImmAddr]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003701
3702// X86 specific add which produces a flag.
3703def : Pat<(addc GR32:$src1, GR32:$src2),
3704 (ADD32rr GR32:$src1, GR32:$src2)>;
3705def : Pat<(addc GR32:$src1, (load addr:$src2)),
3706 (ADD32rm GR32:$src1, addr:$src2)>;
3707def : Pat<(addc GR32:$src1, imm:$src2),
3708 (ADD32ri GR32:$src1, imm:$src2)>;
3709def : Pat<(addc GR32:$src1, i32immSExt8:$src2),
3710 (ADD32ri8 GR32:$src1, i32immSExt8:$src2)>;
3711
3712def : Pat<(subc GR32:$src1, GR32:$src2),
3713 (SUB32rr GR32:$src1, GR32:$src2)>;
3714def : Pat<(subc GR32:$src1, (load addr:$src2)),
3715 (SUB32rm GR32:$src1, addr:$src2)>;
3716def : Pat<(subc GR32:$src1, imm:$src2),
3717 (SUB32ri GR32:$src1, imm:$src2)>;
3718def : Pat<(subc GR32:$src1, i32immSExt8:$src2),
3719 (SUB32ri8 GR32:$src1, i32immSExt8:$src2)>;
3720
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003721// Comparisons.
3722
3723// TEST R,R is smaller than CMP R,0
Evan Cheng621216e2007-09-29 00:00:36 +00003724def : Pat<(parallel (X86cmp GR8:$src1, 0), (implicit EFLAGS)),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003725 (TEST8rr GR8:$src1, GR8:$src1)>;
Evan Cheng621216e2007-09-29 00:00:36 +00003726def : Pat<(parallel (X86cmp GR16:$src1, 0), (implicit EFLAGS)),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003727 (TEST16rr GR16:$src1, GR16:$src1)>;
Evan Cheng621216e2007-09-29 00:00:36 +00003728def : Pat<(parallel (X86cmp GR32:$src1, 0), (implicit EFLAGS)),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003729 (TEST32rr GR32:$src1, GR32:$src1)>;
3730
Dan Gohman0a3c5222009-01-07 01:00:24 +00003731// Conditional moves with folded loads with operands swapped and conditions
3732// inverted.
3733def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_B, EFLAGS),
3734 (CMOVAE16rm GR16:$src2, addr:$src1)>;
3735def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_B, EFLAGS),
3736 (CMOVAE32rm GR32:$src2, addr:$src1)>;
3737def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_AE, EFLAGS),
3738 (CMOVB16rm GR16:$src2, addr:$src1)>;
3739def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_AE, EFLAGS),
3740 (CMOVB32rm GR32:$src2, addr:$src1)>;
3741def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_E, EFLAGS),
3742 (CMOVNE16rm GR16:$src2, addr:$src1)>;
3743def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_E, EFLAGS),
3744 (CMOVNE32rm GR32:$src2, addr:$src1)>;
3745def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_NE, EFLAGS),
3746 (CMOVE16rm GR16:$src2, addr:$src1)>;
3747def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_NE, EFLAGS),
3748 (CMOVE32rm GR32:$src2, addr:$src1)>;
3749def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_BE, EFLAGS),
3750 (CMOVA16rm GR16:$src2, addr:$src1)>;
3751def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_BE, EFLAGS),
3752 (CMOVA32rm GR32:$src2, addr:$src1)>;
3753def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_A, EFLAGS),
3754 (CMOVBE16rm GR16:$src2, addr:$src1)>;
3755def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_A, EFLAGS),
3756 (CMOVBE32rm GR32:$src2, addr:$src1)>;
3757def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_L, EFLAGS),
3758 (CMOVGE16rm GR16:$src2, addr:$src1)>;
3759def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_L, EFLAGS),
3760 (CMOVGE32rm GR32:$src2, addr:$src1)>;
3761def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_GE, EFLAGS),
3762 (CMOVL16rm GR16:$src2, addr:$src1)>;
3763def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_GE, EFLAGS),
3764 (CMOVL32rm GR32:$src2, addr:$src1)>;
3765def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_LE, EFLAGS),
3766 (CMOVG16rm GR16:$src2, addr:$src1)>;
3767def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_LE, EFLAGS),
3768 (CMOVG32rm GR32:$src2, addr:$src1)>;
3769def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_G, EFLAGS),
3770 (CMOVLE16rm GR16:$src2, addr:$src1)>;
3771def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_G, EFLAGS),
3772 (CMOVLE32rm GR32:$src2, addr:$src1)>;
3773def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_P, EFLAGS),
3774 (CMOVNP16rm GR16:$src2, addr:$src1)>;
3775def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_P, EFLAGS),
3776 (CMOVNP32rm GR32:$src2, addr:$src1)>;
3777def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_NP, EFLAGS),
3778 (CMOVP16rm GR16:$src2, addr:$src1)>;
3779def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_NP, EFLAGS),
3780 (CMOVP32rm GR32:$src2, addr:$src1)>;
3781def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_S, EFLAGS),
3782 (CMOVNS16rm GR16:$src2, addr:$src1)>;
3783def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_S, EFLAGS),
3784 (CMOVNS32rm GR32:$src2, addr:$src1)>;
3785def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_NS, EFLAGS),
3786 (CMOVS16rm GR16:$src2, addr:$src1)>;
3787def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_NS, EFLAGS),
3788 (CMOVS32rm GR32:$src2, addr:$src1)>;
3789def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_O, EFLAGS),
3790 (CMOVNO16rm GR16:$src2, addr:$src1)>;
3791def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_O, EFLAGS),
3792 (CMOVNO32rm GR32:$src2, addr:$src1)>;
3793def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_NO, EFLAGS),
3794 (CMOVO16rm GR16:$src2, addr:$src1)>;
3795def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_NO, EFLAGS),
3796 (CMOVO32rm GR32:$src2, addr:$src1)>;
3797
Duncan Sands082524c2008-01-23 20:39:46 +00003798// zextload bool -> zextload byte
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003799def : Pat<(zextloadi8i1 addr:$src), (MOV8rm addr:$src)>;
3800def : Pat<(zextloadi16i1 addr:$src), (MOVZX16rm8 addr:$src)>;
3801def : Pat<(zextloadi32i1 addr:$src), (MOVZX32rm8 addr:$src)>;
3802
3803// extload bool -> extload byte
3804def : Pat<(extloadi8i1 addr:$src), (MOV8rm addr:$src)>;
Dan Gohman9959b052009-08-26 14:59:13 +00003805def : Pat<(extloadi16i1 addr:$src), (MOVZX16rm8 addr:$src)>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003806def : Pat<(extloadi32i1 addr:$src), (MOVZX32rm8 addr:$src)>;
Dan Gohman9959b052009-08-26 14:59:13 +00003807def : Pat<(extloadi16i8 addr:$src), (MOVZX16rm8 addr:$src)>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003808def : Pat<(extloadi32i8 addr:$src), (MOVZX32rm8 addr:$src)>;
3809def : Pat<(extloadi32i16 addr:$src), (MOVZX32rm16 addr:$src)>;
3810
Dan Gohman9959b052009-08-26 14:59:13 +00003811// anyext. Define these to do an explicit zero-extend to
3812// avoid partial-register updates.
3813def : Pat<(i16 (anyext GR8 :$src)), (MOVZX16rr8 GR8 :$src)>;
3814def : Pat<(i32 (anyext GR8 :$src)), (MOVZX32rr8 GR8 :$src)>;
3815def : Pat<(i32 (anyext GR16:$src)), (MOVZX32rr16 GR16:$src)>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003816
Evan Chengf2abee72007-12-13 00:43:27 +00003817// (and (i32 load), 255) -> (zextload i8)
Evan Cheng1e5e5452008-09-29 17:26:18 +00003818def : Pat<(i32 (and (nvloadi32 addr:$src), (i32 255))),
3819 (MOVZX32rm8 addr:$src)>;
3820def : Pat<(i32 (and (nvloadi32 addr:$src), (i32 65535))),
3821 (MOVZX32rm16 addr:$src)>;
Evan Chengf2abee72007-12-13 00:43:27 +00003822
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003823//===----------------------------------------------------------------------===//
3824// Some peepholes
3825//===----------------------------------------------------------------------===//
3826
Dan Gohman5a5e6e92008-10-17 01:33:43 +00003827// Odd encoding trick: -128 fits into an 8-bit immediate field while
3828// +128 doesn't, so in this special case use a sub instead of an add.
3829def : Pat<(add GR16:$src1, 128),
3830 (SUB16ri8 GR16:$src1, -128)>;
3831def : Pat<(store (add (loadi16 addr:$dst), 128), addr:$dst),
3832 (SUB16mi8 addr:$dst, -128)>;
3833def : Pat<(add GR32:$src1, 128),
3834 (SUB32ri8 GR32:$src1, -128)>;
3835def : Pat<(store (add (loadi32 addr:$dst), 128), addr:$dst),
3836 (SUB32mi8 addr:$dst, -128)>;
3837
Dan Gohman9203ab42008-07-30 18:09:17 +00003838// r & (2^16-1) ==> movz
3839def : Pat<(and GR32:$src1, 0xffff),
Dan Gohman744d4622009-04-13 16:09:41 +00003840 (MOVZX32rr16 (EXTRACT_SUBREG GR32:$src1, x86_subreg_16bit))>;
Dan Gohman5beb1ff2008-08-06 18:27:21 +00003841// r & (2^8-1) ==> movz
3842def : Pat<(and GR32:$src1, 0xff),
Dan Gohman6e438702009-04-27 16:33:14 +00003843 (MOVZX32rr8 (EXTRACT_SUBREG (COPY_TO_REGCLASS GR32:$src1, GR32_ABCD),
Dan Gohman744d4622009-04-13 16:09:41 +00003844 x86_subreg_8bit))>,
Dan Gohman5beb1ff2008-08-06 18:27:21 +00003845 Requires<[In32BitMode]>;
3846// r & (2^8-1) ==> movz
3847def : Pat<(and GR16:$src1, 0xff),
Dan Gohman6e438702009-04-27 16:33:14 +00003848 (MOVZX16rr8 (EXTRACT_SUBREG (COPY_TO_REGCLASS GR16:$src1, GR16_ABCD),
Dan Gohman744d4622009-04-13 16:09:41 +00003849 x86_subreg_8bit))>,
Dan Gohmandd612bb2008-08-20 21:27:32 +00003850 Requires<[In32BitMode]>;
3851
3852// sext_inreg patterns
3853def : Pat<(sext_inreg GR32:$src, i16),
Dan Gohman744d4622009-04-13 16:09:41 +00003854 (MOVSX32rr16 (EXTRACT_SUBREG GR32:$src, x86_subreg_16bit))>;
Dan Gohmandd612bb2008-08-20 21:27:32 +00003855def : Pat<(sext_inreg GR32:$src, i8),
Dan Gohman6e438702009-04-27 16:33:14 +00003856 (MOVSX32rr8 (EXTRACT_SUBREG (COPY_TO_REGCLASS GR32:$src, GR32_ABCD),
Dan Gohman744d4622009-04-13 16:09:41 +00003857 x86_subreg_8bit))>,
Dan Gohmandd612bb2008-08-20 21:27:32 +00003858 Requires<[In32BitMode]>;
3859def : Pat<(sext_inreg GR16:$src, i8),
Dan Gohman6e438702009-04-27 16:33:14 +00003860 (MOVSX16rr8 (EXTRACT_SUBREG (COPY_TO_REGCLASS GR16:$src, GR16_ABCD),
Dan Gohman744d4622009-04-13 16:09:41 +00003861 x86_subreg_8bit))>,
Dan Gohmandd612bb2008-08-20 21:27:32 +00003862 Requires<[In32BitMode]>;
3863
3864// trunc patterns
3865def : Pat<(i16 (trunc GR32:$src)),
Dan Gohman744d4622009-04-13 16:09:41 +00003866 (EXTRACT_SUBREG GR32:$src, x86_subreg_16bit)>;
Dan Gohmandd612bb2008-08-20 21:27:32 +00003867def : Pat<(i8 (trunc GR32:$src)),
Dan Gohman6e438702009-04-27 16:33:14 +00003868 (EXTRACT_SUBREG (COPY_TO_REGCLASS GR32:$src, GR32_ABCD),
Dan Gohman744d4622009-04-13 16:09:41 +00003869 x86_subreg_8bit)>,
Dan Gohmandd612bb2008-08-20 21:27:32 +00003870 Requires<[In32BitMode]>;
3871def : Pat<(i8 (trunc GR16:$src)),
Dan Gohman6e438702009-04-27 16:33:14 +00003872 (EXTRACT_SUBREG (COPY_TO_REGCLASS GR16:$src, GR16_ABCD),
Dan Gohman744d4622009-04-13 16:09:41 +00003873 x86_subreg_8bit)>,
3874 Requires<[In32BitMode]>;
3875
3876// h-register tricks
3877def : Pat<(i8 (trunc (srl_su GR16:$src, (i8 8)))),
Dan Gohman6e438702009-04-27 16:33:14 +00003878 (EXTRACT_SUBREG (COPY_TO_REGCLASS GR16:$src, GR16_ABCD),
Dan Gohman744d4622009-04-13 16:09:41 +00003879 x86_subreg_8bit_hi)>,
3880 Requires<[In32BitMode]>;
3881def : Pat<(i8 (trunc (srl_su GR32:$src, (i8 8)))),
Dan Gohman6e438702009-04-27 16:33:14 +00003882 (EXTRACT_SUBREG (COPY_TO_REGCLASS GR32:$src, GR32_ABCD),
Dan Gohman744d4622009-04-13 16:09:41 +00003883 x86_subreg_8bit_hi)>,
3884 Requires<[In32BitMode]>;
3885def : Pat<(srl_su GR16:$src, (i8 8)),
3886 (EXTRACT_SUBREG
3887 (MOVZX32rr8
Dan Gohman6e438702009-04-27 16:33:14 +00003888 (EXTRACT_SUBREG (COPY_TO_REGCLASS GR16:$src, GR16_ABCD),
Dan Gohman744d4622009-04-13 16:09:41 +00003889 x86_subreg_8bit_hi)),
3890 x86_subreg_16bit)>,
3891 Requires<[In32BitMode]>;
Evan Cheng957ca282009-05-29 01:44:43 +00003892def : Pat<(i32 (zext (srl_su GR16:$src, (i8 8)))),
3893 (MOVZX32rr8 (EXTRACT_SUBREG (COPY_TO_REGCLASS GR16:$src, GR16_ABCD),
3894 x86_subreg_8bit_hi))>,
3895 Requires<[In32BitMode]>;
Dan Gohman9959b052009-08-26 14:59:13 +00003896def : Pat<(i32 (anyext (srl_su GR16:$src, (i8 8)))),
3897 (MOVZX32rr8 (EXTRACT_SUBREG (COPY_TO_REGCLASS GR16:$src, GR16_ABCD),
3898 x86_subreg_8bit_hi))>,
3899 Requires<[In32BitMode]>;
Dan Gohman744d4622009-04-13 16:09:41 +00003900def : Pat<(and (srl_su GR32:$src, (i8 8)), (i32 255)),
Dan Gohman6e438702009-04-27 16:33:14 +00003901 (MOVZX32rr8 (EXTRACT_SUBREG (COPY_TO_REGCLASS GR32:$src, GR32_ABCD),
Dan Gohman744d4622009-04-13 16:09:41 +00003902 x86_subreg_8bit_hi))>,
Dan Gohman5beb1ff2008-08-06 18:27:21 +00003903 Requires<[In32BitMode]>;
Dan Gohman9203ab42008-07-30 18:09:17 +00003904
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003905// (shl x, 1) ==> (add x, x)
3906def : Pat<(shl GR8 :$src1, (i8 1)), (ADD8rr GR8 :$src1, GR8 :$src1)>;
3907def : Pat<(shl GR16:$src1, (i8 1)), (ADD16rr GR16:$src1, GR16:$src1)>;
3908def : Pat<(shl GR32:$src1, (i8 1)), (ADD32rr GR32:$src1, GR32:$src1)>;
3909
Evan Cheng76a64c72008-08-30 02:03:58 +00003910// (shl x (and y, 31)) ==> (shl x, y)
3911def : Pat<(shl GR8:$src1, (and CL:$amt, 31)),
3912 (SHL8rCL GR8:$src1)>;
3913def : Pat<(shl GR16:$src1, (and CL:$amt, 31)),
3914 (SHL16rCL GR16:$src1)>;
3915def : Pat<(shl GR32:$src1, (and CL:$amt, 31)),
3916 (SHL32rCL GR32:$src1)>;
3917def : Pat<(store (shl (loadi8 addr:$dst), (and CL:$amt, 31)), addr:$dst),
3918 (SHL8mCL addr:$dst)>;
3919def : Pat<(store (shl (loadi16 addr:$dst), (and CL:$amt, 31)), addr:$dst),
3920 (SHL16mCL addr:$dst)>;
3921def : Pat<(store (shl (loadi32 addr:$dst), (and CL:$amt, 31)), addr:$dst),
3922 (SHL32mCL addr:$dst)>;
3923
3924def : Pat<(srl GR8:$src1, (and CL:$amt, 31)),
3925 (SHR8rCL GR8:$src1)>;
3926def : Pat<(srl GR16:$src1, (and CL:$amt, 31)),
3927 (SHR16rCL GR16:$src1)>;
3928def : Pat<(srl GR32:$src1, (and CL:$amt, 31)),
3929 (SHR32rCL GR32:$src1)>;
3930def : Pat<(store (srl (loadi8 addr:$dst), (and CL:$amt, 31)), addr:$dst),
3931 (SHR8mCL addr:$dst)>;
3932def : Pat<(store (srl (loadi16 addr:$dst), (and CL:$amt, 31)), addr:$dst),
3933 (SHR16mCL addr:$dst)>;
3934def : Pat<(store (srl (loadi32 addr:$dst), (and CL:$amt, 31)), addr:$dst),
3935 (SHR32mCL addr:$dst)>;
3936
3937def : Pat<(sra GR8:$src1, (and CL:$amt, 31)),
3938 (SAR8rCL GR8:$src1)>;
3939def : Pat<(sra GR16:$src1, (and CL:$amt, 31)),
3940 (SAR16rCL GR16:$src1)>;
3941def : Pat<(sra GR32:$src1, (and CL:$amt, 31)),
3942 (SAR32rCL GR32:$src1)>;
3943def : Pat<(store (sra (loadi8 addr:$dst), (and CL:$amt, 31)), addr:$dst),
3944 (SAR8mCL addr:$dst)>;
3945def : Pat<(store (sra (loadi16 addr:$dst), (and CL:$amt, 31)), addr:$dst),
3946 (SAR16mCL addr:$dst)>;
3947def : Pat<(store (sra (loadi32 addr:$dst), (and CL:$amt, 31)), addr:$dst),
3948 (SAR32mCL addr:$dst)>;
3949
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003950// (or (x >> c) | (y << (32 - c))) ==> (shrd32 x, y, c)
3951def : Pat<(or (srl GR32:$src1, CL:$amt),
3952 (shl GR32:$src2, (sub 32, CL:$amt))),
3953 (SHRD32rrCL GR32:$src1, GR32:$src2)>;
3954
3955def : Pat<(store (or (srl (loadi32 addr:$dst), CL:$amt),
3956 (shl GR32:$src2, (sub 32, CL:$amt))), addr:$dst),
3957 (SHRD32mrCL addr:$dst, GR32:$src2)>;
3958
Dan Gohman921581d2008-10-17 01:23:35 +00003959def : Pat<(or (srl GR32:$src1, (i8 (trunc ECX:$amt))),
3960 (shl GR32:$src2, (i8 (trunc (sub 32, ECX:$amt))))),
3961 (SHRD32rrCL GR32:$src1, GR32:$src2)>;
3962
3963def : Pat<(store (or (srl (loadi32 addr:$dst), (i8 (trunc ECX:$amt))),
3964 (shl GR32:$src2, (i8 (trunc (sub 32, ECX:$amt))))),
3965 addr:$dst),
3966 (SHRD32mrCL addr:$dst, GR32:$src2)>;
3967
3968def : Pat<(shrd GR32:$src1, (i8 imm:$amt1), GR32:$src2, (i8 imm:$amt2)),
3969 (SHRD32rri8 GR32:$src1, GR32:$src2, (i8 imm:$amt1))>;
3970
3971def : Pat<(store (shrd (loadi32 addr:$dst), (i8 imm:$amt1),
3972 GR32:$src2, (i8 imm:$amt2)), addr:$dst),
3973 (SHRD32mri8 addr:$dst, GR32:$src2, (i8 imm:$amt1))>;
3974
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003975// (or (x << c) | (y >> (32 - c))) ==> (shld32 x, y, c)
3976def : Pat<(or (shl GR32:$src1, CL:$amt),
3977 (srl GR32:$src2, (sub 32, CL:$amt))),
3978 (SHLD32rrCL GR32:$src1, GR32:$src2)>;
3979
3980def : Pat<(store (or (shl (loadi32 addr:$dst), CL:$amt),
3981 (srl GR32:$src2, (sub 32, CL:$amt))), addr:$dst),
3982 (SHLD32mrCL addr:$dst, GR32:$src2)>;
3983
Dan Gohman921581d2008-10-17 01:23:35 +00003984def : Pat<(or (shl GR32:$src1, (i8 (trunc ECX:$amt))),
3985 (srl GR32:$src2, (i8 (trunc (sub 32, ECX:$amt))))),
3986 (SHLD32rrCL GR32:$src1, GR32:$src2)>;
3987
3988def : Pat<(store (or (shl (loadi32 addr:$dst), (i8 (trunc ECX:$amt))),
3989 (srl GR32:$src2, (i8 (trunc (sub 32, ECX:$amt))))),
3990 addr:$dst),
3991 (SHLD32mrCL addr:$dst, GR32:$src2)>;
3992
3993def : Pat<(shld GR32:$src1, (i8 imm:$amt1), GR32:$src2, (i8 imm:$amt2)),
3994 (SHLD32rri8 GR32:$src1, GR32:$src2, (i8 imm:$amt1))>;
3995
3996def : Pat<(store (shld (loadi32 addr:$dst), (i8 imm:$amt1),
3997 GR32:$src2, (i8 imm:$amt2)), addr:$dst),
3998 (SHLD32mri8 addr:$dst, GR32:$src2, (i8 imm:$amt1))>;
3999
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004000// (or (x >> c) | (y << (16 - c))) ==> (shrd16 x, y, c)
4001def : Pat<(or (srl GR16:$src1, CL:$amt),
4002 (shl GR16:$src2, (sub 16, CL:$amt))),
4003 (SHRD16rrCL GR16:$src1, GR16:$src2)>;
4004
4005def : Pat<(store (or (srl (loadi16 addr:$dst), CL:$amt),
4006 (shl GR16:$src2, (sub 16, CL:$amt))), addr:$dst),
4007 (SHRD16mrCL addr:$dst, GR16:$src2)>;
4008
Dan Gohman921581d2008-10-17 01:23:35 +00004009def : Pat<(or (srl GR16:$src1, (i8 (trunc CX:$amt))),
4010 (shl GR16:$src2, (i8 (trunc (sub 16, CX:$amt))))),
4011 (SHRD16rrCL GR16:$src1, GR16:$src2)>;
4012
4013def : Pat<(store (or (srl (loadi16 addr:$dst), (i8 (trunc CX:$amt))),
4014 (shl GR16:$src2, (i8 (trunc (sub 16, CX:$amt))))),
4015 addr:$dst),
4016 (SHRD16mrCL addr:$dst, GR16:$src2)>;
4017
4018def : Pat<(shrd GR16:$src1, (i8 imm:$amt1), GR16:$src2, (i8 imm:$amt2)),
4019 (SHRD16rri8 GR16:$src1, GR16:$src2, (i8 imm:$amt1))>;
4020
4021def : Pat<(store (shrd (loadi16 addr:$dst), (i8 imm:$amt1),
4022 GR16:$src2, (i8 imm:$amt2)), addr:$dst),
4023 (SHRD16mri8 addr:$dst, GR16:$src2, (i8 imm:$amt1))>;
4024
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004025// (or (x << c) | (y >> (16 - c))) ==> (shld16 x, y, c)
4026def : Pat<(or (shl GR16:$src1, CL:$amt),
4027 (srl GR16:$src2, (sub 16, CL:$amt))),
4028 (SHLD16rrCL GR16:$src1, GR16:$src2)>;
4029
4030def : Pat<(store (or (shl (loadi16 addr:$dst), CL:$amt),
4031 (srl GR16:$src2, (sub 16, CL:$amt))), addr:$dst),
4032 (SHLD16mrCL addr:$dst, GR16:$src2)>;
4033
Dan Gohman921581d2008-10-17 01:23:35 +00004034def : Pat<(or (shl GR16:$src1, (i8 (trunc CX:$amt))),
4035 (srl GR16:$src2, (i8 (trunc (sub 16, CX:$amt))))),
4036 (SHLD16rrCL GR16:$src1, GR16:$src2)>;
4037
4038def : Pat<(store (or (shl (loadi16 addr:$dst), (i8 (trunc CX:$amt))),
4039 (srl GR16:$src2, (i8 (trunc (sub 16, CX:$amt))))),
4040 addr:$dst),
4041 (SHLD16mrCL addr:$dst, GR16:$src2)>;
4042
4043def : Pat<(shld GR16:$src1, (i8 imm:$amt1), GR16:$src2, (i8 imm:$amt2)),
4044 (SHLD16rri8 GR16:$src1, GR16:$src2, (i8 imm:$amt1))>;
4045
4046def : Pat<(store (shld (loadi16 addr:$dst), (i8 imm:$amt1),
4047 GR16:$src2, (i8 imm:$amt2)), addr:$dst),
4048 (SHLD16mri8 addr:$dst, GR16:$src2, (i8 imm:$amt1))>;
4049
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004050//===----------------------------------------------------------------------===//
Dan Gohman99a12192009-03-04 19:44:21 +00004051// EFLAGS-defining Patterns
Bill Wendlingf5399032008-12-12 21:15:41 +00004052//===----------------------------------------------------------------------===//
4053
Dan Gohman99a12192009-03-04 19:44:21 +00004054// Register-Register Addition with EFLAGS result
4055def : Pat<(parallel (X86add_flag GR8:$src1, GR8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004056 (implicit EFLAGS)),
4057 (ADD8rr GR8:$src1, GR8:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00004058def : Pat<(parallel (X86add_flag GR16:$src1, GR16:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004059 (implicit EFLAGS)),
4060 (ADD16rr GR16:$src1, GR16:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00004061def : Pat<(parallel (X86add_flag GR32:$src1, GR32:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004062 (implicit EFLAGS)),
4063 (ADD32rr GR32:$src1, GR32:$src2)>;
4064
Dan Gohman99a12192009-03-04 19:44:21 +00004065// Register-Memory Addition with EFLAGS result
4066def : Pat<(parallel (X86add_flag GR8:$src1, (loadi8 addr:$src2)),
Bill Wendlingf5399032008-12-12 21:15:41 +00004067 (implicit EFLAGS)),
4068 (ADD8rm GR8:$src1, addr:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00004069def : Pat<(parallel (X86add_flag GR16:$src1, (loadi16 addr:$src2)),
Bill Wendlingf5399032008-12-12 21:15:41 +00004070 (implicit EFLAGS)),
4071 (ADD16rm GR16:$src1, addr:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00004072def : Pat<(parallel (X86add_flag GR32:$src1, (loadi32 addr:$src2)),
Bill Wendlingf5399032008-12-12 21:15:41 +00004073 (implicit EFLAGS)),
4074 (ADD32rm GR32:$src1, addr:$src2)>;
4075
Dan Gohman99a12192009-03-04 19:44:21 +00004076// Register-Integer Addition with EFLAGS result
4077def : Pat<(parallel (X86add_flag GR8:$src1, imm:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004078 (implicit EFLAGS)),
4079 (ADD8ri GR8:$src1, imm:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00004080def : Pat<(parallel (X86add_flag GR16:$src1, imm:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004081 (implicit EFLAGS)),
4082 (ADD16ri GR16:$src1, imm:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00004083def : Pat<(parallel (X86add_flag GR32:$src1, imm:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004084 (implicit EFLAGS)),
4085 (ADD32ri GR32:$src1, imm:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00004086def : Pat<(parallel (X86add_flag GR16:$src1, i16immSExt8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004087 (implicit EFLAGS)),
4088 (ADD16ri8 GR16:$src1, i16immSExt8:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00004089def : Pat<(parallel (X86add_flag GR32:$src1, i32immSExt8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004090 (implicit EFLAGS)),
4091 (ADD32ri8 GR32:$src1, i32immSExt8:$src2)>;
4092
Dan Gohman99a12192009-03-04 19:44:21 +00004093// Memory-Register Addition with EFLAGS result
4094def : Pat<(parallel (store (X86add_flag (loadi8 addr:$dst), GR8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004095 addr:$dst),
4096 (implicit EFLAGS)),
4097 (ADD8mr addr:$dst, GR8:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00004098def : Pat<(parallel (store (X86add_flag (loadi16 addr:$dst), GR16:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004099 addr:$dst),
4100 (implicit EFLAGS)),
4101 (ADD16mr addr:$dst, GR16:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00004102def : Pat<(parallel (store (X86add_flag (loadi32 addr:$dst), GR32:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004103 addr:$dst),
4104 (implicit EFLAGS)),
4105 (ADD32mr addr:$dst, GR32:$src2)>;
Dale Johannesen06b83f12009-05-18 17:44:15 +00004106
4107// Memory-Integer Addition with EFLAGS result
Dan Gohman99a12192009-03-04 19:44:21 +00004108def : Pat<(parallel (store (X86add_flag (loadi8 addr:$dst), imm:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004109 addr:$dst),
4110 (implicit EFLAGS)),
4111 (ADD8mi addr:$dst, imm:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00004112def : Pat<(parallel (store (X86add_flag (loadi16 addr:$dst), imm:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004113 addr:$dst),
4114 (implicit EFLAGS)),
4115 (ADD16mi addr:$dst, imm:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00004116def : Pat<(parallel (store (X86add_flag (loadi32 addr:$dst), imm:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004117 addr:$dst),
4118 (implicit EFLAGS)),
4119 (ADD32mi addr:$dst, imm:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00004120def : Pat<(parallel (store (X86add_flag (loadi16 addr:$dst), i16immSExt8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004121 addr:$dst),
4122 (implicit EFLAGS)),
4123 (ADD16mi8 addr:$dst, i16immSExt8:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00004124def : Pat<(parallel (store (X86add_flag (loadi32 addr:$dst), i32immSExt8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004125 addr:$dst),
4126 (implicit EFLAGS)),
4127 (ADD32mi8 addr:$dst, i32immSExt8:$src2)>;
4128
Dan Gohman99a12192009-03-04 19:44:21 +00004129// Register-Register Subtraction with EFLAGS result
4130def : Pat<(parallel (X86sub_flag GR8:$src1, GR8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004131 (implicit EFLAGS)),
4132 (SUB8rr GR8:$src1, GR8:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00004133def : Pat<(parallel (X86sub_flag GR16:$src1, GR16:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004134 (implicit EFLAGS)),
4135 (SUB16rr GR16:$src1, GR16:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00004136def : Pat<(parallel (X86sub_flag GR32:$src1, GR32:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004137 (implicit EFLAGS)),
4138 (SUB32rr GR32:$src1, GR32:$src2)>;
4139
Dan Gohman99a12192009-03-04 19:44:21 +00004140// Register-Memory Subtraction with EFLAGS result
4141def : Pat<(parallel (X86sub_flag GR8:$src1, (loadi8 addr:$src2)),
Bill Wendlingf5399032008-12-12 21:15:41 +00004142 (implicit EFLAGS)),
4143 (SUB8rm GR8:$src1, addr:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00004144def : Pat<(parallel (X86sub_flag GR16:$src1, (loadi16 addr:$src2)),
Bill Wendlingf5399032008-12-12 21:15:41 +00004145 (implicit EFLAGS)),
4146 (SUB16rm GR16:$src1, addr:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00004147def : Pat<(parallel (X86sub_flag GR32:$src1, (loadi32 addr:$src2)),
Bill Wendlingf5399032008-12-12 21:15:41 +00004148 (implicit EFLAGS)),
4149 (SUB32rm GR32:$src1, addr:$src2)>;
4150
Dan Gohman99a12192009-03-04 19:44:21 +00004151// Register-Integer Subtraction with EFLAGS result
4152def : Pat<(parallel (X86sub_flag GR8:$src1, imm:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004153 (implicit EFLAGS)),
4154 (SUB8ri GR8:$src1, imm:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00004155def : Pat<(parallel (X86sub_flag GR16:$src1, imm:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004156 (implicit EFLAGS)),
4157 (SUB16ri GR16:$src1, imm:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00004158def : Pat<(parallel (X86sub_flag GR32:$src1, imm:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004159 (implicit EFLAGS)),
4160 (SUB32ri GR32:$src1, imm:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00004161def : Pat<(parallel (X86sub_flag GR16:$src1, i16immSExt8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004162 (implicit EFLAGS)),
4163 (SUB16ri8 GR16:$src1, i16immSExt8:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00004164def : Pat<(parallel (X86sub_flag GR32:$src1, i32immSExt8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004165 (implicit EFLAGS)),
4166 (SUB32ri8 GR32:$src1, i32immSExt8:$src2)>;
4167
Dan Gohman99a12192009-03-04 19:44:21 +00004168// Memory-Register Subtraction with EFLAGS result
4169def : Pat<(parallel (store (X86sub_flag (loadi8 addr:$dst), GR8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004170 addr:$dst),
4171 (implicit EFLAGS)),
4172 (SUB8mr addr:$dst, GR8:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00004173def : Pat<(parallel (store (X86sub_flag (loadi16 addr:$dst), GR16:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004174 addr:$dst),
4175 (implicit EFLAGS)),
4176 (SUB16mr addr:$dst, GR16:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00004177def : Pat<(parallel (store (X86sub_flag (loadi32 addr:$dst), GR32:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004178 addr:$dst),
4179 (implicit EFLAGS)),
4180 (SUB32mr addr:$dst, GR32:$src2)>;
4181
Dan Gohman99a12192009-03-04 19:44:21 +00004182// Memory-Integer Subtraction with EFLAGS result
4183def : Pat<(parallel (store (X86sub_flag (loadi8 addr:$dst), imm:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004184 addr:$dst),
4185 (implicit EFLAGS)),
4186 (SUB8mi addr:$dst, imm:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00004187def : Pat<(parallel (store (X86sub_flag (loadi16 addr:$dst), imm:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004188 addr:$dst),
4189 (implicit EFLAGS)),
4190 (SUB16mi addr:$dst, imm:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00004191def : Pat<(parallel (store (X86sub_flag (loadi32 addr:$dst), imm:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004192 addr:$dst),
4193 (implicit EFLAGS)),
4194 (SUB32mi addr:$dst, imm:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00004195def : Pat<(parallel (store (X86sub_flag (loadi16 addr:$dst), i16immSExt8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004196 addr:$dst),
4197 (implicit EFLAGS)),
4198 (SUB16mi8 addr:$dst, i16immSExt8:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00004199def : Pat<(parallel (store (X86sub_flag (loadi32 addr:$dst), i32immSExt8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004200 addr:$dst),
4201 (implicit EFLAGS)),
4202 (SUB32mi8 addr:$dst, i32immSExt8:$src2)>;
4203
4204
Dan Gohman99a12192009-03-04 19:44:21 +00004205// Register-Register Signed Integer Multiply with EFLAGS result
4206def : Pat<(parallel (X86smul_flag GR16:$src1, GR16:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004207 (implicit EFLAGS)),
4208 (IMUL16rr GR16:$src1, GR16:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00004209def : Pat<(parallel (X86smul_flag GR32:$src1, GR32:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004210 (implicit EFLAGS)),
4211 (IMUL32rr GR32:$src1, GR32:$src2)>;
4212
Dan Gohman99a12192009-03-04 19:44:21 +00004213// Register-Memory Signed Integer Multiply with EFLAGS result
4214def : Pat<(parallel (X86smul_flag GR16:$src1, (loadi16 addr:$src2)),
Bill Wendlingf5399032008-12-12 21:15:41 +00004215 (implicit EFLAGS)),
4216 (IMUL16rm GR16:$src1, addr:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00004217def : Pat<(parallel (X86smul_flag GR32:$src1, (loadi32 addr:$src2)),
Bill Wendlingf5399032008-12-12 21:15:41 +00004218 (implicit EFLAGS)),
4219 (IMUL32rm GR32:$src1, addr:$src2)>;
4220
Dan Gohman99a12192009-03-04 19:44:21 +00004221// Register-Integer Signed Integer Multiply with EFLAGS result
4222def : Pat<(parallel (X86smul_flag GR16:$src1, imm:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004223 (implicit EFLAGS)),
4224 (IMUL16rri GR16:$src1, imm:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00004225def : Pat<(parallel (X86smul_flag GR32:$src1, imm:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004226 (implicit EFLAGS)),
4227 (IMUL32rri GR32:$src1, imm:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00004228def : Pat<(parallel (X86smul_flag GR16:$src1, i16immSExt8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004229 (implicit EFLAGS)),
4230 (IMUL16rri8 GR16:$src1, i16immSExt8:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00004231def : Pat<(parallel (X86smul_flag GR32:$src1, i32immSExt8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004232 (implicit EFLAGS)),
4233 (IMUL32rri8 GR32:$src1, i32immSExt8:$src2)>;
4234
Dan Gohman99a12192009-03-04 19:44:21 +00004235// Memory-Integer Signed Integer Multiply with EFLAGS result
4236def : Pat<(parallel (X86smul_flag (loadi16 addr:$src1), imm:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004237 (implicit EFLAGS)),
4238 (IMUL16rmi addr:$src1, imm:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00004239def : Pat<(parallel (X86smul_flag (loadi32 addr:$src1), imm:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004240 (implicit EFLAGS)),
4241 (IMUL32rmi addr:$src1, imm:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00004242def : Pat<(parallel (X86smul_flag (loadi16 addr:$src1), i16immSExt8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004243 (implicit EFLAGS)),
4244 (IMUL16rmi8 addr:$src1, i16immSExt8:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00004245def : Pat<(parallel (X86smul_flag (loadi32 addr:$src1), i32immSExt8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004246 (implicit EFLAGS)),
4247 (IMUL32rmi8 addr:$src1, i32immSExt8:$src2)>;
4248
Dan Gohman99a12192009-03-04 19:44:21 +00004249// Optimize multiply by 2 with EFLAGS result.
Evan Cheng00cf7932009-01-27 03:30:42 +00004250let AddedComplexity = 2 in {
Dan Gohman99a12192009-03-04 19:44:21 +00004251def : Pat<(parallel (X86smul_flag GR16:$src1, 2),
Evan Cheng00cf7932009-01-27 03:30:42 +00004252 (implicit EFLAGS)),
4253 (ADD16rr GR16:$src1, GR16:$src1)>;
4254
Dan Gohman99a12192009-03-04 19:44:21 +00004255def : Pat<(parallel (X86smul_flag GR32:$src1, 2),
Evan Cheng00cf7932009-01-27 03:30:42 +00004256 (implicit EFLAGS)),
4257 (ADD32rr GR32:$src1, GR32:$src1)>;
4258}
4259
Dan Gohman99a12192009-03-04 19:44:21 +00004260// INC and DEC with EFLAGS result. Note that these do not set CF.
4261def : Pat<(parallel (X86inc_flag GR8:$src), (implicit EFLAGS)),
4262 (INC8r GR8:$src)>;
4263def : Pat<(parallel (store (i8 (X86inc_flag (loadi8 addr:$dst))), addr:$dst),
4264 (implicit EFLAGS)),
4265 (INC8m addr:$dst)>;
4266def : Pat<(parallel (X86dec_flag GR8:$src), (implicit EFLAGS)),
4267 (DEC8r GR8:$src)>;
4268def : Pat<(parallel (store (i8 (X86dec_flag (loadi8 addr:$dst))), addr:$dst),
4269 (implicit EFLAGS)),
4270 (DEC8m addr:$dst)>;
4271
4272def : Pat<(parallel (X86inc_flag GR16:$src), (implicit EFLAGS)),
Dan Gohmaneebcac72009-03-05 21:32:23 +00004273 (INC16r GR16:$src)>, Requires<[In32BitMode]>;
Dan Gohman99a12192009-03-04 19:44:21 +00004274def : Pat<(parallel (store (i16 (X86inc_flag (loadi16 addr:$dst))), addr:$dst),
4275 (implicit EFLAGS)),
Dan Gohmaneebcac72009-03-05 21:32:23 +00004276 (INC16m addr:$dst)>, Requires<[In32BitMode]>;
Dan Gohman99a12192009-03-04 19:44:21 +00004277def : Pat<(parallel (X86dec_flag GR16:$src), (implicit EFLAGS)),
Dan Gohmaneebcac72009-03-05 21:32:23 +00004278 (DEC16r GR16:$src)>, Requires<[In32BitMode]>;
Dan Gohman99a12192009-03-04 19:44:21 +00004279def : Pat<(parallel (store (i16 (X86dec_flag (loadi16 addr:$dst))), addr:$dst),
4280 (implicit EFLAGS)),
Dan Gohmaneebcac72009-03-05 21:32:23 +00004281 (DEC16m addr:$dst)>, Requires<[In32BitMode]>;
Dan Gohman99a12192009-03-04 19:44:21 +00004282
4283def : Pat<(parallel (X86inc_flag GR32:$src), (implicit EFLAGS)),
Dan Gohmaneebcac72009-03-05 21:32:23 +00004284 (INC32r GR32:$src)>, Requires<[In32BitMode]>;
Dan Gohman99a12192009-03-04 19:44:21 +00004285def : Pat<(parallel (store (i32 (X86inc_flag (loadi32 addr:$dst))), addr:$dst),
4286 (implicit EFLAGS)),
Dan Gohmaneebcac72009-03-05 21:32:23 +00004287 (INC32m addr:$dst)>, Requires<[In32BitMode]>;
Dan Gohman99a12192009-03-04 19:44:21 +00004288def : Pat<(parallel (X86dec_flag GR32:$src), (implicit EFLAGS)),
Dan Gohmaneebcac72009-03-05 21:32:23 +00004289 (DEC32r GR32:$src)>, Requires<[In32BitMode]>;
Dan Gohman99a12192009-03-04 19:44:21 +00004290def : Pat<(parallel (store (i32 (X86dec_flag (loadi32 addr:$dst))), addr:$dst),
4291 (implicit EFLAGS)),
Dan Gohmaneebcac72009-03-05 21:32:23 +00004292 (DEC32m addr:$dst)>, Requires<[In32BitMode]>;
Dan Gohman99a12192009-03-04 19:44:21 +00004293
Dan Gohmane84197b2009-09-03 17:18:51 +00004294// -disable-16bit support.
4295def : Pat<(truncstorei16 (i32 imm:$src), addr:$dst),
4296 (MOV16mi addr:$dst, imm:$src)>;
4297def : Pat<(truncstorei16 GR32:$src, addr:$dst),
4298 (MOV16mr addr:$dst, (EXTRACT_SUBREG GR32:$src, x86_subreg_16bit))>;
4299def : Pat<(i32 (sextloadi16 addr:$dst)),
4300 (MOVSX32rm16 addr:$dst)>;
4301def : Pat<(i32 (zextloadi16 addr:$dst)),
4302 (MOVZX32rm16 addr:$dst)>;
4303def : Pat<(i32 (extloadi16 addr:$dst)),
4304 (MOVZX32rm16 addr:$dst)>;
4305
Bill Wendlingf5399032008-12-12 21:15:41 +00004306//===----------------------------------------------------------------------===//
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004307// Floating Point Stack Support
4308//===----------------------------------------------------------------------===//
4309
4310include "X86InstrFPStack.td"
4311
4312//===----------------------------------------------------------------------===//
Evan Cheng86ab7d32007-07-31 08:04:03 +00004313// X86-64 Support
4314//===----------------------------------------------------------------------===//
4315
Chris Lattner2de8d2b2008-01-10 05:50:42 +00004316include "X86Instr64bit.td"
Evan Cheng86ab7d32007-07-31 08:04:03 +00004317
4318//===----------------------------------------------------------------------===//
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004319// XMM Floating point support (requires SSE / SSE2)
4320//===----------------------------------------------------------------------===//
4321
4322include "X86InstrSSE.td"
Evan Cheng5e4d1e72008-04-25 18:19:54 +00004323
4324//===----------------------------------------------------------------------===//
4325// MMX and XMM Packed Integer support (requires MMX, SSE, and SSE2)
4326//===----------------------------------------------------------------------===//
4327
4328include "X86InstrMMX.td"